More improvements to how we handle extensions (#6591)
- make sure to initialize all extension booleans, we treat them as feature flags. - be more explicit about #define'ing gl tokens, so we can more easily catch errors later. - don't blindly use extension tokens that might not be available (e.g.: GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_CUBE_MAP_ARRAY). It would probably cause a spurious gl error.
This commit is contained in:
@@ -120,7 +120,12 @@ constexpr inline GLenum getBufferBindingType(BufferObjectBinding bindingType) no
|
||||
case BufferObjectBinding::UNIFORM:
|
||||
return GL_UNIFORM_BUFFER;
|
||||
case BufferObjectBinding::SHADER_STORAGE:
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
return GL_SHADER_STORAGE_BUFFER;
|
||||
#else
|
||||
utils::panic(__func__, __FILE__, __LINE__, "SHADER_STORAGE not supported");
|
||||
return 0x90D2; // just to return something
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "OpenGLContext.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
// change to true to display all GL extensions in the console on start-up
|
||||
#define DEBUG_PRINT_EXTENSIONS false
|
||||
|
||||
@@ -70,7 +72,9 @@ OpenGLContext::OpenGLContext() noexcept {
|
||||
constexpr GLint MAX_FRAGMENT_SAMPLER_COUNT = caps3.MAX_FRAGMENT_SAMPLER_COUNT;
|
||||
|
||||
if constexpr (BACKEND_OPENGL_VERSION == BACKEND_OPENGL_VERSION_GLES) {
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
initExtensionsGLES();
|
||||
#endif
|
||||
if (state.major == 3) {
|
||||
assert_invariant(gets.max_texture_image_units >= 16);
|
||||
assert_invariant(gets.max_combined_texture_image_units >= 32);
|
||||
@@ -88,8 +92,9 @@ OpenGLContext::OpenGLContext() noexcept {
|
||||
}
|
||||
}
|
||||
} else if constexpr (BACKEND_OPENGL_VERSION == BACKEND_OPENGL_VERSION_GL) {
|
||||
// OpenGL version
|
||||
#if defined(GL_VERSION_4_1)
|
||||
initExtensionsGL();
|
||||
#endif
|
||||
if (state.major == 4) {
|
||||
assert_invariant(state.minor >= 1);
|
||||
mShaderModel = ShaderModel::DESKTOP;
|
||||
@@ -351,6 +356,8 @@ void OpenGLContext::setDefaultState() noexcept {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
|
||||
void OpenGLContext::initExtensionsGLES() noexcept {
|
||||
const char * const extensions = (const char*)glGetString(GL_EXTENSIONS);
|
||||
GLUtils::unordered_string_set const exts = GLUtils::split(extensions);
|
||||
@@ -395,6 +402,10 @@ void OpenGLContext::initExtensionsGLES() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // defined(GL_ES_VERSION_2_0)
|
||||
|
||||
#if defined(GL_VERSION_4_1)
|
||||
|
||||
void OpenGLContext::initExtensionsGL() noexcept {
|
||||
GLUtils::unordered_string_set exts;
|
||||
GLint n = 0;
|
||||
@@ -418,21 +429,31 @@ void OpenGLContext::initExtensionsGL() noexcept {
|
||||
ext.EXT_color_buffer_float = true; // Assumes core profile.
|
||||
ext.EXT_color_buffer_half_float = true; // Assumes core profile.
|
||||
ext.EXT_debug_marker = exts.has("GL_EXT_debug_marker"sv);
|
||||
ext.EXT_disjoint_timer_query = true;
|
||||
ext.EXT_multisampled_render_to_texture = false;
|
||||
ext.EXT_multisampled_render_to_texture2 = false;
|
||||
ext.EXT_shader_framebuffer_fetch = exts.has("GL_EXT_shader_framebuffer_fetch"sv);
|
||||
ext.EXT_texture_compression_bptc = exts.has("GL_EXT_texture_compression_bptc"sv);
|
||||
ext.EXT_texture_compression_etc2 = exts.has("GL_ARB_ES3_compatibility"sv);
|
||||
ext.EXT_texture_compression_rgtc = exts.has("GL_EXT_texture_compression_rgtc"sv);
|
||||
ext.EXT_texture_compression_s3tc = exts.has("GL_EXT_texture_compression_s3tc"sv);
|
||||
ext.EXT_texture_compression_s3tc_srgb = exts.has("GL_EXT_texture_compression_s3tc_srgb"sv);
|
||||
ext.EXT_texture_compression_rgtc = exts.has("GL_EXT_texture_compression_rgtc"sv);
|
||||
ext.EXT_texture_compression_bptc = exts.has("GL_EXT_texture_compression_bptc"sv);
|
||||
ext.EXT_texture_cube_map_array = true;
|
||||
ext.EXT_texture_filter_anisotropic = exts.has("GL_EXT_texture_filter_anisotropic"sv);
|
||||
ext.EXT_texture_sRGB = exts.has("GL_EXT_texture_sRGB"sv);
|
||||
ext.GOOGLE_cpp_style_line_directive = exts.has("GL_GOOGLE_cpp_style_line_directive"sv);
|
||||
ext.KHR_debug = major >= 4 && minor >= 3;
|
||||
ext.KHR_texture_compression_astc_hdr = exts.has("GL_KHR_texture_compression_astc_hdr"sv);
|
||||
ext.KHR_texture_compression_astc_ldr = exts.has("GL_KHR_texture_compression_astc_ldr"sv);
|
||||
ext.OES_EGL_image_external_essl3 = exts.has("GL_OES_EGL_image_external_essl3"sv);
|
||||
ext.OES_EGL_image_external_essl3 = false;
|
||||
ext.QCOM_tiled_rendering = false;
|
||||
ext.WEBGL_compressed_texture_etc = false;
|
||||
ext.WEBGL_compressed_texture_s3tc = false;
|
||||
ext.WEBGL_compressed_texture_s3tc_srgb = false;
|
||||
}
|
||||
|
||||
#endif // defined(GL_VERSION_4_1)
|
||||
|
||||
void OpenGLContext::bindBuffer(GLenum target, GLuint buffer) noexcept {
|
||||
if (target == GL_ELEMENT_ARRAY_BUFFER) {
|
||||
constexpr size_t targetIndex = getIndexForBufferTarget(GL_ELEMENT_ARRAY_BUFFER);
|
||||
@@ -613,7 +634,7 @@ void OpenGLContext::resetState() noexcept {
|
||||
GLenum const bufferTargets[] = {
|
||||
GL_UNIFORM_BUFFER,
|
||||
GL_TRANSFORM_FEEDBACK_BUFFER,
|
||||
#if !defined(__EMSCRIPTEN__)
|
||||
#if !defined(__EMSCRIPTEN__) && (defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1))
|
||||
GL_SHADER_STORAGE_BUFFER,
|
||||
#endif
|
||||
GL_ARRAY_BUFFER,
|
||||
@@ -639,23 +660,30 @@ void OpenGLContext::resetState() noexcept {
|
||||
// Reset state.textures to its default state to avoid the complexity and error-prone
|
||||
// nature of resetting the GL state to its existing state
|
||||
state.textures = {};
|
||||
const GLuint textureTargets[] = {
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE_2D_ARRAY,
|
||||
GL_TEXTURE_CUBE_MAP,
|
||||
GL_TEXTURE_3D,
|
||||
const std::pair<GLuint, bool> textureTargets[] = {
|
||||
{ GL_TEXTURE_2D, true },
|
||||
{ GL_TEXTURE_2D_ARRAY, true },
|
||||
{ GL_TEXTURE_CUBE_MAP, true },
|
||||
{ GL_TEXTURE_3D, true },
|
||||
#if !defined(__EMSCRIPTEN__)
|
||||
GL_TEXTURE_2D_MULTISAMPLE,
|
||||
GL_TEXTURE_EXTERNAL_OES,
|
||||
GL_TEXTURE_CUBE_MAP_ARRAY,
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
{ GL_TEXTURE_2D_MULTISAMPLE, true },
|
||||
#endif
|
||||
#if defined(GL_OES_EGL_image_external)
|
||||
{ GL_TEXTURE_EXTERNAL_OES, ext.OES_EGL_image_external_essl3 },
|
||||
#endif
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_EXT_texture_cube_map_array)
|
||||
{ GL_TEXTURE_CUBE_MAP_ARRAY, ext.EXT_texture_cube_map_array },
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
for (GLint unit = 0; unit < gets.max_combined_texture_image_units; ++unit) {
|
||||
glActiveTexture(GL_TEXTURE0 + unit);
|
||||
glBindSampler(unit, 0);
|
||||
|
||||
for (auto const target : textureTargets) {
|
||||
glBindTexture(target, 0);
|
||||
for (auto [target, available] : textureTargets) {
|
||||
if (available) {
|
||||
glBindTexture(target, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
glActiveTexture(GL_TEXTURE0 + state.textures.active);
|
||||
|
||||
@@ -146,21 +146,21 @@ public:
|
||||
bool EXT_color_buffer_half_float;
|
||||
bool EXT_debug_marker;
|
||||
bool EXT_disjoint_timer_query;
|
||||
bool EXT_multisampled_render_to_texture;
|
||||
bool EXT_multisampled_render_to_texture2;
|
||||
bool EXT_multisampled_render_to_texture;
|
||||
bool EXT_shader_framebuffer_fetch;
|
||||
bool KHR_texture_compression_astc_hdr;
|
||||
bool KHR_texture_compression_astc_ldr;
|
||||
bool EXT_texture_compression_bptc;
|
||||
bool EXT_texture_compression_etc2;
|
||||
bool EXT_texture_compression_rgtc;
|
||||
bool EXT_texture_compression_s3tc;
|
||||
bool EXT_texture_compression_s3tc_srgb;
|
||||
bool EXT_texture_compression_rgtc;
|
||||
bool EXT_texture_compression_bptc;
|
||||
bool EXT_texture_cube_map_array;
|
||||
bool EXT_texture_filter_anisotropic;
|
||||
bool EXT_texture_sRGB;
|
||||
bool GOOGLE_cpp_style_line_directive;
|
||||
bool KHR_debug;
|
||||
bool KHR_texture_compression_astc_hdr;
|
||||
bool KHR_texture_compression_astc_ldr;
|
||||
bool OES_EGL_image_external_essl3;
|
||||
bool QCOM_tiled_rendering;
|
||||
bool WEBGL_compressed_texture_etc;
|
||||
@@ -391,8 +391,12 @@ private:
|
||||
RenderPrimitive mDefaultVAO;
|
||||
|
||||
// this is chosen to minimize code size
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
void initExtensionsGLES() noexcept;
|
||||
#endif
|
||||
#if defined(GL_VERSION_4_1)
|
||||
void initExtensionsGL() noexcept;
|
||||
#endif
|
||||
|
||||
template <typename T, typename F>
|
||||
static inline void update_state(T& state, T const& expected, F functor, bool force = false) noexcept {
|
||||
@@ -417,7 +421,9 @@ constexpr size_t OpenGLContext::getIndexForTextureTarget(GLuint target) noexcept
|
||||
case GL_TEXTURE_2D: return 0;
|
||||
case GL_TEXTURE_2D_ARRAY: return 1;
|
||||
case GL_TEXTURE_CUBE_MAP: return 2;
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
case GL_TEXTURE_2D_MULTISAMPLE: return 3;
|
||||
#endif
|
||||
case GL_TEXTURE_EXTERNAL_OES: return 4;
|
||||
case GL_TEXTURE_3D: return 5;
|
||||
case GL_TEXTURE_CUBE_MAP_ARRAY: return 6;
|
||||
@@ -444,9 +450,9 @@ constexpr size_t OpenGLContext::getIndexForCap(GLenum cap) noexcept { //NOLINT
|
||||
#if BACKEND_OPENGL_VERSION == BACKEND_OPENGL_VERSION_GL
|
||||
case GL_PROGRAM_POINT_SIZE: index = 10; break;
|
||||
#endif
|
||||
default: index = 13; break; // should never happen
|
||||
default: break;
|
||||
}
|
||||
assert_invariant(index < 13 && index < state.enables.caps.size());
|
||||
assert_invariant(index < state.enables.caps.size());
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -456,12 +462,14 @@ constexpr size_t OpenGLContext::getIndexForBufferTarget(GLenum target) noexcept
|
||||
// The indexed buffers MUST be first in this list (those usable with bindBufferRange)
|
||||
case GL_UNIFORM_BUFFER: index = 0; break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER: index = 1; break;
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
case GL_SHADER_STORAGE_BUFFER: index = 2; break;
|
||||
#endif
|
||||
case GL_ARRAY_BUFFER: index = 3; break;
|
||||
case GL_ELEMENT_ARRAY_BUFFER: index = 4; break;
|
||||
case GL_PIXEL_PACK_BUFFER: index = 5; break;
|
||||
case GL_PIXEL_UNPACK_BUFFER: index = 6; break;
|
||||
default: index = 7; break; // should never happen
|
||||
default: break;
|
||||
}
|
||||
assert_invariant(index < sizeof(state.buffers.genericBinding)/sizeof(state.buffers.genericBinding[0])); // NOLINT(misc-redundant-expression)
|
||||
return index;
|
||||
@@ -484,21 +492,21 @@ void OpenGLContext::bindSampler(GLuint unit, GLuint sampler) noexcept {
|
||||
}
|
||||
|
||||
void OpenGLContext::setScissor(GLint left, GLint bottom, GLsizei width, GLsizei height) noexcept {
|
||||
vec4gli scissor(left, bottom, width, height);
|
||||
vec4gli const scissor(left, bottom, width, height);
|
||||
update_state(state.window.scissor, scissor, [&]() {
|
||||
glScissor(left, bottom, width, height);
|
||||
});
|
||||
}
|
||||
|
||||
void OpenGLContext::viewport(GLint left, GLint bottom, GLsizei width, GLsizei height) noexcept {
|
||||
vec4gli viewport(left, bottom, width, height);
|
||||
vec4gli const viewport(left, bottom, width, height);
|
||||
update_state(state.window.viewport, viewport, [&]() {
|
||||
glViewport(left, bottom, width, height);
|
||||
});
|
||||
}
|
||||
|
||||
void OpenGLContext::depthRange(GLclampf near, GLclampf far) noexcept {
|
||||
vec2glf depthRange(near, far);
|
||||
vec2glf const depthRange(near, far);
|
||||
update_state(state.window.depthRange, depthRange, [&]() {
|
||||
glDepthRangef(near, far);
|
||||
});
|
||||
@@ -509,7 +517,7 @@ void OpenGLContext::bindVertexArray(RenderPrimitive const* p) noexcept {
|
||||
update_state(state.vao.p, vao, [&]() {
|
||||
glBindVertexArray(vao->vao);
|
||||
// update GL_ELEMENT_ARRAY_BUFFER, which is updated by glBindVertexArray
|
||||
size_t targetIndex = getIndexForBufferTarget(GL_ELEMENT_ARRAY_BUFFER);
|
||||
size_t const targetIndex = getIndexForBufferTarget(GL_ELEMENT_ARRAY_BUFFER);
|
||||
state.buffers.genericBinding[targetIndex] = vao->elementArray;
|
||||
if (UTILS_UNLIKELY(bugs.vao_doesnt_store_element_array_buffer_binding)) {
|
||||
// This shouldn't be needed, but it looks like some drivers don't do the implicit
|
||||
@@ -599,7 +607,7 @@ void OpenGLContext::disableVertexAttribArray(GLuint index) noexcept {
|
||||
}
|
||||
|
||||
void OpenGLContext::enable(GLenum cap) noexcept {
|
||||
size_t index = getIndexForCap(cap);
|
||||
size_t const index = getIndexForCap(cap);
|
||||
if (UTILS_UNLIKELY(!state.enables.caps[index])) {
|
||||
state.enables.caps.set(index);
|
||||
glEnable(cap);
|
||||
@@ -607,7 +615,7 @@ void OpenGLContext::enable(GLenum cap) noexcept {
|
||||
}
|
||||
|
||||
void OpenGLContext::disable(GLenum cap) noexcept {
|
||||
size_t index = getIndexForCap(cap);
|
||||
size_t const index = getIndexForCap(cap);
|
||||
if (UTILS_UNLIKELY(state.enables.caps[index])) {
|
||||
state.enables.caps.unset(index);
|
||||
glDisable(cap);
|
||||
|
||||
@@ -180,7 +180,7 @@ OpenGLDriver::OpenGLDriver(OpenGLPlatform* platform, const Platform::DriverConfi
|
||||
#endif
|
||||
|
||||
// Timer queries are core in GL 3.3, otherwise we need EXT_disjoint_timer_query
|
||||
// iOS headers don't define GL_EXT_disjoint_timer_query, so make aboslutely sure
|
||||
// iOS headers don't define GL_EXT_disjoint_timer_query, so make absolutely sure
|
||||
// we won't use it.
|
||||
#if defined(GL_VERSION_3_3) || defined(GL_EXT_disjoint_timer_query)
|
||||
if (mContext.ext.EXT_disjoint_timer_query ||
|
||||
@@ -545,6 +545,7 @@ void OpenGLDriver::textureStorage(OpenGLDriver::GLTexture* t,
|
||||
GLsizei(width), GLsizei(height), GLsizei(depth) * 6);
|
||||
break;
|
||||
}
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
case GL_TEXTURE_2D_MULTISAMPLE:
|
||||
if constexpr (TEXTURE_2D_MULTISAMPLE_SUPPORTED) {
|
||||
// NOTE: if there is a mix of texture and renderbuffers, "fixed_sample_locations" must be true
|
||||
@@ -562,6 +563,7 @@ void OpenGLDriver::textureStorage(OpenGLDriver::GLTexture* t,
|
||||
PANIC_LOG("GL_TEXTURE_2D_MULTISAMPLE is not supported");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default: // cannot happen
|
||||
break;
|
||||
}
|
||||
@@ -629,6 +631,7 @@ void OpenGLDriver::createTextureR(Handle<HwTexture> th, SamplerType target, uint
|
||||
if (t->samples > 1) {
|
||||
// Note: we can't be here in practice because filament's user API doesn't
|
||||
// allow the creation of multi-sampled textures.
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
if (gl.features.multisample_texture) {
|
||||
// multi-sample texture on GL 3.2 / GLES 3.1 and above
|
||||
t->gl.target = GL_TEXTURE_2D_MULTISAMPLE;
|
||||
@@ -637,6 +640,7 @@ void OpenGLDriver::createTextureR(Handle<HwTexture> th, SamplerType target, uint
|
||||
} else {
|
||||
// Turn off multi-sampling for that texture. It's just not supported.
|
||||
}
|
||||
#endif
|
||||
}
|
||||
textureStorage(t, w, h, depth);
|
||||
}
|
||||
@@ -729,6 +733,7 @@ void OpenGLDriver::importTextureR(Handle<HwTexture> th, intptr_t id,
|
||||
if (t->samples > 1) {
|
||||
// Note: we can't be here in practice because filament's user API doesn't
|
||||
// allow the creation of multi-sampled textures.
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
if (gl.features.multisample_texture) {
|
||||
// multi-sample texture on GL 3.2 / GLES 3.1 and above
|
||||
t->gl.target = GL_TEXTURE_2D_MULTISAMPLE;
|
||||
@@ -736,6 +741,7 @@ void OpenGLDriver::importTextureR(Handle<HwTexture> th, intptr_t id,
|
||||
} else {
|
||||
// Turn off multi-sampling for that texture. It's just not supported.
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CHECK_GL_ERROR(utils::slog.e)
|
||||
@@ -916,7 +922,9 @@ void OpenGLDriver::framebufferTexture(TargetBufferInfo const& binfo,
|
||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
||||
case GL_TEXTURE_2D:
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
case GL_TEXTURE_2D_MULTISAMPLE:
|
||||
#endif
|
||||
if (any(t->usage & TextureUsage::SAMPLEABLE)) {
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment,
|
||||
target, t->gl.id, binfo.level);
|
||||
@@ -1982,7 +1990,9 @@ void OpenGLDriver::generateMipmaps(Handle<HwTexture> th) {
|
||||
|
||||
auto& gl = mContext;
|
||||
GLTexture* t = handle_cast<GLTexture *>(th);
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
assert_invariant(t->gl.target != GL_TEXTURE_2D_MULTISAMPLE);
|
||||
#endif
|
||||
// Note: glGenerateMimap can also fail if the internal format is not both
|
||||
// color-renderable and filterable (i.e.: doesn't work for depth)
|
||||
bindTexture(OpenGLContext::DUMMY_TEXTURE_BINDING, t);
|
||||
|
||||
@@ -121,11 +121,21 @@ void OpenGLProgram::compileShaders(OpenGLContext& context,
|
||||
UTILS_NOUNROLL
|
||||
for (size_t i = 0; i < Program::SHADER_TYPE_COUNT; i++) {
|
||||
const ShaderStage stage = static_cast<ShaderStage>(i);
|
||||
GLenum glShaderType;
|
||||
GLenum glShaderType{};
|
||||
switch (stage) {
|
||||
case ShaderStage::VERTEX: glShaderType = GL_VERTEX_SHADER; break;
|
||||
case ShaderStage::FRAGMENT: glShaderType = GL_FRAGMENT_SHADER; break;
|
||||
case ShaderStage::COMPUTE: glShaderType = GL_COMPUTE_SHADER; break;
|
||||
case ShaderStage::VERTEX:
|
||||
glShaderType = GL_VERTEX_SHADER;
|
||||
break;
|
||||
case ShaderStage::FRAGMENT:
|
||||
glShaderType = GL_FRAGMENT_SHADER;
|
||||
break;
|
||||
case ShaderStage::COMPUTE:
|
||||
#if defined(GL_VERSION_4_1) || defined(GL_ES_VERSION_3_1)
|
||||
glShaderType = GL_COMPUTE_SHADER;
|
||||
#else
|
||||
utils::panic(__func__, __FILE__, __LINE__, "ShaderStage::COMPUTE not supported");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if (UTILS_LIKELY(!shadersSource[i].empty())) {
|
||||
|
||||
@@ -112,99 +112,49 @@ using namespace glext;
|
||||
|
||||
#endif
|
||||
|
||||
// Prevent lots of #ifdef's between desktop and mobile
|
||||
|
||||
#ifdef GL_EXT_disjoint_timer_query
|
||||
# ifndef GL_TIME_ELAPSED
|
||||
# define GL_TIME_ELAPSED GL_TIME_ELAPSED_EXT
|
||||
# endif
|
||||
# define GL_TIME_ELAPSED GL_TIME_ELAPSED_EXT
|
||||
#endif
|
||||
|
||||
#ifdef GL_EXT_clip_control
|
||||
# ifndef GL_LOWER_LEFT
|
||||
# define GL_LOWER_LEFT GL_LOWER_LEFT_EXT
|
||||
# endif
|
||||
# ifndef GL_ZERO_TO_ONE
|
||||
# define GL_ZERO_TO_ONE GL_ZERO_TO_ONE_EXT
|
||||
# endif
|
||||
# define GL_LOWER_LEFT GL_LOWER_LEFT_EXT
|
||||
# define GL_ZERO_TO_ONE GL_ZERO_TO_ONE_EXT
|
||||
#endif
|
||||
|
||||
#ifndef GL_TEXTURE_CUBE_MAP_ARRAY
|
||||
# define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009
|
||||
// we need GL_TEXTURE_CUBE_MAP_ARRAY defined, but we won't use it if the extension/feature
|
||||
// is not available.
|
||||
#if defined(GL_EXT_texture_cube_map_array)
|
||||
# define GL_TEXTURE_CUBE_MAP_ARRAY GL_TEXTURE_CUBE_MAP_ARRAY_EXT
|
||||
#else
|
||||
# define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009
|
||||
#endif
|
||||
|
||||
// Prevent lots of #ifdef's between desktop and mobile
|
||||
|
||||
#if defined(GL_KHR_debug)
|
||||
# ifndef GL_DEBUG_OUTPUT
|
||||
# define GL_DEBUG_OUTPUT GL_DEBUG_OUTPUT_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_OUTPUT_SYNCHRONOUS
|
||||
# define GL_DEBUG_OUTPUT_SYNCHRONOUS GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR
|
||||
# endif
|
||||
|
||||
# ifndef GL_DEBUG_SEVERITY_HIGH
|
||||
# define GL_DEBUG_SEVERITY_HIGH GL_DEBUG_SEVERITY_HIGH_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_SEVERITY_MEDIUM
|
||||
# define GL_DEBUG_SEVERITY_MEDIUM GL_DEBUG_SEVERITY_MEDIUM_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_SEVERITY_LOW
|
||||
# define GL_DEBUG_SEVERITY_LOW GL_DEBUG_SEVERITY_LOW_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_SEVERITY_NOTIFICATION
|
||||
# define GL_DEBUG_SEVERITY_NOTIFICATION GL_DEBUG_SEVERITY_NOTIFICATION_KHR
|
||||
# endif
|
||||
|
||||
# ifndef GL_DEBUG_TYPE_MARKER
|
||||
# define GL_DEBUG_TYPE_MARKER GL_DEBUG_TYPE_MARKER_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_TYPE_ERROR
|
||||
# define GL_DEBUG_TYPE_ERROR GL_DEBUG_TYPE_ERROR_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR
|
||||
# define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR
|
||||
# define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_TYPE_PORTABILITY
|
||||
# define GL_DEBUG_TYPE_PORTABILITY GL_DEBUG_TYPE_PORTABILITY_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_TYPE_PERFORMANCE
|
||||
# define GL_DEBUG_TYPE_PERFORMANCE GL_DEBUG_TYPE_PERFORMANCE_KHR
|
||||
# endif
|
||||
# ifndef GL_DEBUG_TYPE_OTHER
|
||||
# define GL_DEBUG_TYPE_OTHER GL_DEBUG_TYPE_OTHER_KHR
|
||||
# endif
|
||||
|
||||
# define glDebugMessageCallback glDebugMessageCallbackKHR
|
||||
# define GL_DEBUG_OUTPUT GL_DEBUG_OUTPUT_KHR
|
||||
# define GL_DEBUG_OUTPUT_SYNCHRONOUS GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR
|
||||
# define GL_DEBUG_SEVERITY_HIGH GL_DEBUG_SEVERITY_HIGH_KHR
|
||||
# define GL_DEBUG_SEVERITY_MEDIUM GL_DEBUG_SEVERITY_MEDIUM_KHR
|
||||
# define GL_DEBUG_SEVERITY_LOW GL_DEBUG_SEVERITY_LOW_KHR
|
||||
# define GL_DEBUG_SEVERITY_NOTIFICATION GL_DEBUG_SEVERITY_NOTIFICATION_KHR
|
||||
# define GL_DEBUG_TYPE_MARKER GL_DEBUG_TYPE_MARKER_KHR
|
||||
# define GL_DEBUG_TYPE_ERROR GL_DEBUG_TYPE_ERROR_KHR
|
||||
# define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR
|
||||
# define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR
|
||||
# define GL_DEBUG_TYPE_PORTABILITY GL_DEBUG_TYPE_PORTABILITY_KHR
|
||||
# define GL_DEBUG_TYPE_PERFORMANCE GL_DEBUG_TYPE_PERFORMANCE_KHR
|
||||
# define GL_DEBUG_TYPE_OTHER GL_DEBUG_TYPE_OTHER_KHR
|
||||
# define glDebugMessageCallback glDebugMessageCallbackKHR
|
||||
#endif
|
||||
|
||||
/* The iOS SDK only provides OpenGL ES headers up to 3.0. Filament works with OpenGL 3.0, but
|
||||
* requires ES3.1 headers */
|
||||
#if !defined(GL_ES_VERSION_3_1)
|
||||
#define GL_SHADER_STORAGE_BUFFER 0x90D2
|
||||
#define GL_COMPUTE_SHADER 0x91B9
|
||||
|
||||
#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
|
||||
|
||||
// FIXME: The GL_TIME_ELAPSED define is used unconditionally in Filament, but
|
||||
// requires extension support.
|
||||
#ifndef GL_TIME_ELAPSED
|
||||
#define GL_TIME_ELAPSED 0x88BF
|
||||
#endif
|
||||
|
||||
#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A
|
||||
#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C
|
||||
#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D
|
||||
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E
|
||||
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F
|
||||
#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
|
||||
#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
|
||||
#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
|
||||
|
||||
#endif
|
||||
#endif // GL_ES_VERSION_2_0
|
||||
|
||||
// This is just to simplify the implementation (i.e. so we don't have to have #ifdefs everywhere)
|
||||
#ifndef GL_OES_EGL_image_external
|
||||
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
|
||||
#endif
|
||||
|
||||
// This is an odd duck function that exists in WebGL 2.0 but not in OpenGL ES.
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
extern "C" {
|
||||
@@ -237,11 +187,6 @@ void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void *d
|
||||
# define BACKEND_OPENGL_LEVEL BACKEND_OPENGL_LEVEL_GLES20
|
||||
#endif
|
||||
|
||||
// This is just to simplify the implementation (i.e. so we don't have to have #ifdefs everywhere)
|
||||
#ifndef GL_OES_EGL_image_external
|
||||
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
|
||||
#endif
|
||||
|
||||
#include "NullGLES.h"
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_OPENGL_GL_HEADERS_H
|
||||
|
||||
Reference in New Issue
Block a user