OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
/*
|
2019-08-03 19:43:48 +02:00
|
|
|
* This software is licensed under the terms of the MIT License.
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
2019-01-23 21:10:43 +01:00
|
|
|
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
2019-07-03 20:00:56 +02:00
|
|
|
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "taisei.h"
|
|
|
|
|
|
|
|
#include "texture.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "../api.h"
|
|
|
|
#include "vtable.h"
|
|
|
|
|
|
|
|
static GLTextureFormatTuple* glcommon_find_best_pixformat_internal(GLTextureFormatTuple *formats, PixmapFormat pxfmt) {
|
|
|
|
GLTextureFormatTuple *best = formats;
|
|
|
|
|
|
|
|
if(best->px_fmt == pxfmt) {
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t ideal_channels = PIXMAP_FORMAT_LAYOUT(pxfmt);
|
|
|
|
size_t ideal_depth = PIXMAP_FORMAT_DEPTH(pxfmt);
|
Support 16-bit uint and 32-bit float textures
When textures are loaded as resources, the best available format is now
picked by default. That means that if your source image is 16-bit RGB,
you will get a 16-bit RGB texture (the alpha channel is added only if
necessary). However, grayscale images currently get expanded into RGB(A)
by the loaders automatically, so you will never get less than 3 channels
by default. This is good, because you most often expect grayscale images
to stay gray, and not red.
This behavior can be overriden with the new 'format' key in .tex files.
For example, if you only care about one channel in a gray image, you can
do this to save some VRAM:
format = R16
The following is equivalent:
format = R16U
And so is this:
format = r 16 uint
The general syntax is:
format = <channels><depth>[datatype]
Where:
* Channels is one of: R, RG, RGB, RGBA;
* Depth is one of: 8, 16, 32;
* Datatype is one of: uint (or just u), float (or just f)
All fields are case-insensitive and may be separated by whitespace.
Note that the rendering backend may not support all of these formats,
and fallback to an inferior or a redundant one. The gl33 backend should
support all of them. The gles30 backend only supports 8-bit uint
textures for now.
2018-10-17 22:11:27 +02:00
|
|
|
bool ideal_is_float = PIXMAP_FORMAT_IS_FLOAT(pxfmt);
|
2019-01-25 01:57:36 +01:00
|
|
|
bool best_is_float = PIXMAP_FORMAT_IS_FLOAT(best->px_fmt);
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
|
|
|
|
for(GLTextureFormatTuple *fmt = formats + 1; fmt->px_fmt; ++fmt) {
|
|
|
|
if(pxfmt == fmt->px_fmt) {
|
|
|
|
return fmt;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t best_channels = PIXMAP_FORMAT_LAYOUT(best->px_fmt);
|
|
|
|
size_t best_depth = PIXMAP_FORMAT_DEPTH(best->px_fmt);
|
Support 16-bit uint and 32-bit float textures
When textures are loaded as resources, the best available format is now
picked by default. That means that if your source image is 16-bit RGB,
you will get a 16-bit RGB texture (the alpha channel is added only if
necessary). However, grayscale images currently get expanded into RGB(A)
by the loaders automatically, so you will never get less than 3 channels
by default. This is good, because you most often expect grayscale images
to stay gray, and not red.
This behavior can be overriden with the new 'format' key in .tex files.
For example, if you only care about one channel in a gray image, you can
do this to save some VRAM:
format = R16
The following is equivalent:
format = R16U
And so is this:
format = r 16 uint
The general syntax is:
format = <channels><depth>[datatype]
Where:
* Channels is one of: R, RG, RGB, RGBA;
* Depth is one of: 8, 16, 32;
* Datatype is one of: uint (or just u), float (or just f)
All fields are case-insensitive and may be separated by whitespace.
Note that the rendering backend may not support all of these formats,
and fallback to an inferior or a redundant one. The gl33 backend should
support all of them. The gles30 backend only supports 8-bit uint
textures for now.
2018-10-17 22:11:27 +02:00
|
|
|
best_is_float = PIXMAP_FORMAT_IS_FLOAT(best->px_fmt);
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
|
|
|
|
size_t this_channels = PIXMAP_FORMAT_LAYOUT(fmt->px_fmt);
|
|
|
|
size_t this_depth = PIXMAP_FORMAT_DEPTH(fmt->px_fmt);
|
Support 16-bit uint and 32-bit float textures
When textures are loaded as resources, the best available format is now
picked by default. That means that if your source image is 16-bit RGB,
you will get a 16-bit RGB texture (the alpha channel is added only if
necessary). However, grayscale images currently get expanded into RGB(A)
by the loaders automatically, so you will never get less than 3 channels
by default. This is good, because you most often expect grayscale images
to stay gray, and not red.
This behavior can be overriden with the new 'format' key in .tex files.
For example, if you only care about one channel in a gray image, you can
do this to save some VRAM:
format = R16
The following is equivalent:
format = R16U
And so is this:
format = r 16 uint
The general syntax is:
format = <channels><depth>[datatype]
Where:
* Channels is one of: R, RG, RGB, RGBA;
* Depth is one of: 8, 16, 32;
* Datatype is one of: uint (or just u), float (or just f)
All fields are case-insensitive and may be separated by whitespace.
Note that the rendering backend may not support all of these formats,
and fallback to an inferior or a redundant one. The gl33 backend should
support all of them. The gles30 backend only supports 8-bit uint
textures for now.
2018-10-17 22:11:27 +02:00
|
|
|
bool this_is_float = PIXMAP_FORMAT_IS_FLOAT(fmt->px_fmt);
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
|
|
|
|
if(best_channels < ideal_channels) {
|
Support 16-bit uint and 32-bit float textures
When textures are loaded as resources, the best available format is now
picked by default. That means that if your source image is 16-bit RGB,
you will get a 16-bit RGB texture (the alpha channel is added only if
necessary). However, grayscale images currently get expanded into RGB(A)
by the loaders automatically, so you will never get less than 3 channels
by default. This is good, because you most often expect grayscale images
to stay gray, and not red.
This behavior can be overriden with the new 'format' key in .tex files.
For example, if you only care about one channel in a gray image, you can
do this to save some VRAM:
format = R16
The following is equivalent:
format = R16U
And so is this:
format = r 16 uint
The general syntax is:
format = <channels><depth>[datatype]
Where:
* Channels is one of: R, RG, RGB, RGBA;
* Depth is one of: 8, 16, 32;
* Datatype is one of: uint (or just u), float (or just f)
All fields are case-insensitive and may be separated by whitespace.
Note that the rendering backend may not support all of these formats,
and fallback to an inferior or a redundant one. The gl33 backend should
support all of them. The gles30 backend only supports 8-bit uint
textures for now.
2018-10-17 22:11:27 +02:00
|
|
|
if(
|
|
|
|
this_channels > best_channels || (
|
|
|
|
this_channels == best_channels && (
|
|
|
|
(this_is_float && ideal_is_float && !best_is_float) || this_depth >= ideal_depth
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
best = fmt;
|
|
|
|
}
|
|
|
|
} else if(ideal_is_float && !best_is_float) {
|
|
|
|
if(this_channels >= ideal_channels && (this_is_float || this_depth >= best_depth)) {
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
best = fmt;
|
|
|
|
}
|
|
|
|
} else if(best_depth < ideal_depth) {
|
|
|
|
if(this_channels >= ideal_channels && this_depth >= best_depth) {
|
|
|
|
best = fmt;
|
|
|
|
}
|
|
|
|
} else if(
|
Support 16-bit uint and 32-bit float textures
When textures are loaded as resources, the best available format is now
picked by default. That means that if your source image is 16-bit RGB,
you will get a 16-bit RGB texture (the alpha channel is added only if
necessary). However, grayscale images currently get expanded into RGB(A)
by the loaders automatically, so you will never get less than 3 channels
by default. This is good, because you most often expect grayscale images
to stay gray, and not red.
This behavior can be overriden with the new 'format' key in .tex files.
For example, if you only care about one channel in a gray image, you can
do this to save some VRAM:
format = R16
The following is equivalent:
format = R16U
And so is this:
format = r 16 uint
The general syntax is:
format = <channels><depth>[datatype]
Where:
* Channels is one of: R, RG, RGB, RGBA;
* Depth is one of: 8, 16, 32;
* Datatype is one of: uint (or just u), float (or just f)
All fields are case-insensitive and may be separated by whitespace.
Note that the rendering backend may not support all of these formats,
and fallback to an inferior or a redundant one. The gl33 backend should
support all of them. The gles30 backend only supports 8-bit uint
textures for now.
2018-10-17 22:11:27 +02:00
|
|
|
this_channels >= ideal_channels &&
|
|
|
|
this_depth >= ideal_depth &&
|
|
|
|
this_is_float == ideal_is_float &&
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
(this_channels < best_channels || this_depth < best_depth)
|
|
|
|
) {
|
|
|
|
best = fmt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Support 16-bit uint and 32-bit float textures
When textures are loaded as resources, the best available format is now
picked by default. That means that if your source image is 16-bit RGB,
you will get a 16-bit RGB texture (the alpha channel is added only if
necessary). However, grayscale images currently get expanded into RGB(A)
by the loaders automatically, so you will never get less than 3 channels
by default. This is good, because you most often expect grayscale images
to stay gray, and not red.
This behavior can be overriden with the new 'format' key in .tex files.
For example, if you only care about one channel in a gray image, you can
do this to save some VRAM:
format = R16
The following is equivalent:
format = R16U
And so is this:
format = r 16 uint
The general syntax is:
format = <channels><depth>[datatype]
Where:
* Channels is one of: R, RG, RGB, RGBA;
* Depth is one of: 8, 16, 32;
* Datatype is one of: uint (or just u), float (or just f)
All fields are case-insensitive and may be separated by whitespace.
Note that the rendering backend may not support all of these formats,
and fallback to an inferior or a redundant one. The gl33 backend should
support all of them. The gles30 backend only supports 8-bit uint
textures for now.
2018-10-17 22:11:27 +02:00
|
|
|
log_debug("(%u, %u, %s) --> (%u, %u, %s)",
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
PIXMAP_FORMAT_LAYOUT(pxfmt),
|
|
|
|
PIXMAP_FORMAT_DEPTH(pxfmt),
|
Support 16-bit uint and 32-bit float textures
When textures are loaded as resources, the best available format is now
picked by default. That means that if your source image is 16-bit RGB,
you will get a 16-bit RGB texture (the alpha channel is added only if
necessary). However, grayscale images currently get expanded into RGB(A)
by the loaders automatically, so you will never get less than 3 channels
by default. This is good, because you most often expect grayscale images
to stay gray, and not red.
This behavior can be overriden with the new 'format' key in .tex files.
For example, if you only care about one channel in a gray image, you can
do this to save some VRAM:
format = R16
The following is equivalent:
format = R16U
And so is this:
format = r 16 uint
The general syntax is:
format = <channels><depth>[datatype]
Where:
* Channels is one of: R, RG, RGB, RGBA;
* Depth is one of: 8, 16, 32;
* Datatype is one of: uint (or just u), float (or just f)
All fields are case-insensitive and may be separated by whitespace.
Note that the rendering backend may not support all of these formats,
and fallback to an inferior or a redundant one. The gl33 backend should
support all of them. The gles30 backend only supports 8-bit uint
textures for now.
2018-10-17 22:11:27 +02:00
|
|
|
ideal_is_float ? "float" : "uint",
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
PIXMAP_FORMAT_LAYOUT(best->px_fmt),
|
Support 16-bit uint and 32-bit float textures
When textures are loaded as resources, the best available format is now
picked by default. That means that if your source image is 16-bit RGB,
you will get a 16-bit RGB texture (the alpha channel is added only if
necessary). However, grayscale images currently get expanded into RGB(A)
by the loaders automatically, so you will never get less than 3 channels
by default. This is good, because you most often expect grayscale images
to stay gray, and not red.
This behavior can be overriden with the new 'format' key in .tex files.
For example, if you only care about one channel in a gray image, you can
do this to save some VRAM:
format = R16
The following is equivalent:
format = R16U
And so is this:
format = r 16 uint
The general syntax is:
format = <channels><depth>[datatype]
Where:
* Channels is one of: R, RG, RGB, RGBA;
* Depth is one of: 8, 16, 32;
* Datatype is one of: uint (or just u), float (or just f)
All fields are case-insensitive and may be separated by whitespace.
Note that the rendering backend may not support all of these formats,
and fallback to an inferior or a redundant one. The gl33 backend should
support all of them. The gles30 backend only supports 8-bit uint
textures for now.
2018-10-17 22:11:27 +02:00
|
|
|
PIXMAP_FORMAT_DEPTH(best->px_fmt),
|
|
|
|
best_is_float ? "float" : "uint"
|
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation
Needs to be manually enabled via -Dshader_transpiler=true.
Requires shaderc. https://github.com/google/shaderc
Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.
* Integrate crossc; shader transpilation for GLES now works
* fix leak
* gles30 backend now playable on Mesa with 3.2 context
Some rendering issues are present. Identified so far:
- Marisa's lasers are invisible
- Death effect looks wrong
Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.
* fix marisa lasers in GLES (uniform name clashed with builtin)
* fix player death effect in GLES (another name clash)
* Dump ANGLE's translated shader code in debug log
* fix screenshots
* Drop support for triangle fans, switch to strips
Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.
* crude workaround for an ANGLE bug
* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)
* fix race condition in shaderc initialization
* New SDL_RWops interface for vertex buffers
* Optimize VBO streaming via buffering updates
Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.
* Fix the depth texture binding problem under ANGLE
Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.
* fix GLES2.0 segfault (the backend still doesn't work, though)
* dump GL extensions at info log level, not debug
* get around a Mesa bug; more correct texture format table for GLES2
* Correct GLES3 texture format table according to the spec
Not a Mesa bug after all
* require crossc>=1.5.0, fallback to subproject
* Request at least 8bit per color channel in GL backends
* Forbid lto for static windows builds with shader_transpiler=true
* fix edge case segfault
* Add basic ANGLE bundling support to the build system
Windows only, and no NSIS support yet
* Fix various windows-related build system and installer brokenness
* Disable gles backends by default
* update documentation
2018-10-02 00:36:10 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLTextureFormatTuple* glcommon_find_best_pixformat(TextureType textype, PixmapFormat pxfmt) {
|
|
|
|
GLTextureFormatTuple *formats = GLVT.texture_type_info(textype)->external_formats;
|
|
|
|
return glcommon_find_best_pixformat_internal(formats, pxfmt);
|
|
|
|
}
|
2019-02-22 07:37:52 +01:00
|
|
|
|
|
|
|
GLenum glcommon_texture_base_format(GLenum internal_fmt) {
|
|
|
|
switch(internal_fmt) {
|
|
|
|
// NOTE: semi-generated code
|
|
|
|
case GL_COMPRESSED_RED: return GL_RED;
|
|
|
|
case GL_COMPRESSED_RED_RGTC1: return GL_RED;
|
|
|
|
case GL_COMPRESSED_RG: return GL_RG;
|
|
|
|
case GL_COMPRESSED_RGB: return GL_RGB;
|
|
|
|
case GL_COMPRESSED_RGBA: return GL_RGBA;
|
|
|
|
case GL_COMPRESSED_RG_RGTC2: return GL_RG;
|
|
|
|
case GL_COMPRESSED_SIGNED_RED_RGTC1: return GL_RED;
|
|
|
|
case GL_COMPRESSED_SIGNED_RG_RGTC2: return GL_RG;
|
|
|
|
case GL_COMPRESSED_SRGB: return GL_RGB;
|
|
|
|
case GL_COMPRESSED_SRGB_ALPHA: return GL_RGBA;
|
|
|
|
case GL_DEPTH24_STENCIL8: return GL_DEPTH_STENCIL;
|
|
|
|
case GL_DEPTH32F_STENCIL8: return GL_DEPTH_STENCIL;
|
|
|
|
case GL_DEPTH_COMPONENT16: return GL_DEPTH_COMPONENT;
|
|
|
|
case GL_DEPTH_COMPONENT24: return GL_DEPTH_COMPONENT;
|
|
|
|
case GL_DEPTH_COMPONENT32: return GL_DEPTH_COMPONENT;
|
|
|
|
case GL_DEPTH_COMPONENT32F: return GL_DEPTH_COMPONENT;
|
|
|
|
case GL_R11F_G11F_B10F: return GL_RGB;
|
|
|
|
case GL_R16: return GL_RED;
|
|
|
|
case GL_R16F: return GL_RED;
|
|
|
|
case GL_R16I: return GL_RED;
|
|
|
|
case GL_R16UI: return GL_RED;
|
|
|
|
case GL_R16_SNORM: return GL_RED;
|
|
|
|
case GL_R32F: return GL_RED;
|
|
|
|
case GL_R32I: return GL_RED;
|
|
|
|
case GL_R32UI: return GL_RED;
|
|
|
|
case GL_R3_G3_B2: return GL_RGB;
|
|
|
|
case GL_R8: return GL_RED;
|
|
|
|
case GL_R8I: return GL_RED;
|
|
|
|
case GL_R8UI: return GL_RED;
|
|
|
|
case GL_R8_SNORM: return GL_RED;
|
|
|
|
case GL_RG16: return GL_RG;
|
|
|
|
case GL_RG16F: return GL_RG;
|
|
|
|
case GL_RG16I: return GL_RG;
|
|
|
|
case GL_RG16UI: return GL_RG;
|
|
|
|
case GL_RG16_SNORM: return GL_RG;
|
|
|
|
case GL_RG32F: return GL_RG;
|
|
|
|
case GL_RG32I: return GL_RG;
|
|
|
|
case GL_RG32UI: return GL_RG;
|
|
|
|
case GL_RG8: return GL_RG;
|
|
|
|
case GL_RG8I: return GL_RG;
|
|
|
|
case GL_RG8UI: return GL_RG;
|
|
|
|
case GL_RG8_SNORM: return GL_RG;
|
|
|
|
case GL_RGB10: return GL_RGB;
|
|
|
|
case GL_RGB10_A2: return GL_RGBA;
|
|
|
|
case GL_RGB10_A2UI: return GL_RGBA;
|
|
|
|
case GL_RGB12: return GL_RGB;
|
|
|
|
case GL_RGB16: return GL_RGB;
|
|
|
|
case GL_RGB16F: return GL_RGB;
|
|
|
|
case GL_RGB16I: return GL_RGB;
|
|
|
|
case GL_RGB16UI: return GL_RGB;
|
|
|
|
case GL_RGB16_SNORM: return GL_RGB;
|
|
|
|
case GL_RGB32F: return GL_RGB;
|
|
|
|
case GL_RGB32I: return GL_RGB;
|
|
|
|
case GL_RGB32UI: return GL_RGB;
|
|
|
|
case GL_RGB4: return GL_RGB;
|
|
|
|
case GL_RGB5: return GL_RGB;
|
|
|
|
case GL_RGB5_A1: return GL_RGBA;
|
|
|
|
case GL_RGB8: return GL_RGB;
|
|
|
|
case GL_RGB8I: return GL_RGB;
|
|
|
|
case GL_RGB8UI: return GL_RGB;
|
|
|
|
case GL_RGB8_SNORM: return GL_RGB;
|
|
|
|
case GL_RGB9_E5: return GL_RGB;
|
|
|
|
case GL_RGBA12: return GL_RGBA;
|
|
|
|
case GL_RGBA16: return GL_RGBA;
|
|
|
|
case GL_RGBA16F: return GL_RGBA;
|
|
|
|
case GL_RGBA16I: return GL_RGBA;
|
|
|
|
case GL_RGBA16UI: return GL_RGBA;
|
|
|
|
case GL_RGBA16_SNORM: return GL_RGBA;
|
|
|
|
case GL_RGBA2: return GL_RGBA;
|
|
|
|
case GL_RGBA32F: return GL_RGBA;
|
|
|
|
case GL_RGBA32I: return GL_RGBA;
|
|
|
|
case GL_RGBA32UI: return GL_RGBA;
|
|
|
|
case GL_RGBA4: return GL_RGBA;
|
|
|
|
case GL_RGBA8: return GL_RGBA;
|
|
|
|
case GL_RGBA8I: return GL_RGBA;
|
|
|
|
case GL_RGBA8UI: return GL_RGBA;
|
|
|
|
case GL_RGBA8_SNORM: return GL_RGBA;
|
|
|
|
case GL_SRGB8: return GL_RGB;
|
|
|
|
case GL_SRGB8_ALPHA8: return GL_RGBA;
|
|
|
|
}
|
|
|
|
|
|
|
|
UNREACHABLE;
|
|
|
|
}
|