From 34f25bd6c8f4e86f789fa87f6c3196c98051aba7 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 9 Jul 2017 16:55:21 -0300 Subject: [PATCH] ESSL: always enable standard derivative functionality (dFdx, dFdy, fwidth) when available. Added 'shaderderivatives' graphics feature enum. --HG-- branch : minor --- src/modules/graphics/Graphics.cpp | 1 + src/modules/graphics/Graphics.h | 1 + src/modules/graphics/opengl/Graphics.cpp | 3 ++- src/modules/graphics/wrap_Graphics.lua | 3 +++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 2f1430b6d..0efc39735 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -1457,6 +1457,7 @@ StringMap::Entry Graphics::featur { "lighten", FEATURE_LIGHTEN }, { "fullnpot", FEATURE_FULL_NPOT }, { "pixelshaderhighp", FEATURE_PIXEL_SHADER_HIGHP }, + { "shaderderivatives", FEATURE_SHADER_DERIVATIVES }, { "glsl3", FEATURE_GLSL3 }, { "instancing", FEATURE_INSTANCING }, }; diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index ea5788a6f..6a6fc38e6 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -159,6 +159,7 @@ public: FEATURE_LIGHTEN, FEATURE_FULL_NPOT, FEATURE_PIXEL_SHADER_HIGHP, + FEATURE_SHADER_DERIVATIVES, FEATURE_GLSL3, FEATURE_INSTANCING, FEATURE_MAX_ENUM diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 03145126e..0a978e20d 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -1418,9 +1418,10 @@ void Graphics::initCapabilities() capabilities.features[FEATURE_LIGHTEN] = GLAD_VERSION_1_4 || GLAD_ES_VERSION_3_0 || GLAD_EXT_blend_minmax; capabilities.features[FEATURE_FULL_NPOT] = GLAD_VERSION_2_0 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_npot; capabilities.features[FEATURE_PIXEL_SHADER_HIGHP] = gl.isPixelShaderHighpSupported(); + capabilities.features[FEATURE_SHADER_DERIVATIVES] = GLAD_VERSION_2_0 || GLAD_ES_VERSION_3_0 || GLAD_OES_standard_derivatives; capabilities.features[FEATURE_GLSL3] = GLAD_ES_VERSION_3_0 || gl.isCoreProfile(); capabilities.features[FEATURE_INSTANCING] = gl.isInstancingSupported(); - static_assert(FEATURE_MAX_ENUM == 7, "Graphics::initCapabilities must be updated when adding a new graphics feature!"); + static_assert(FEATURE_MAX_ENUM == 8, "Graphics::initCapabilities must be updated when adding a new graphics feature!"); capabilities.limits[LIMIT_POINT_SIZE] = gl.getMaxPointSize(); capabilities.limits[LIMIT_TEXTURE_SIZE] = gl.getMax2DTextureSize(); diff --git a/src/modules/graphics/wrap_Graphics.lua b/src/modules/graphics/wrap_Graphics.lua index 2ab58a6a3..529e7768d 100644 --- a/src/modules/graphics/wrap_Graphics.lua +++ b/src/modules/graphics/wrap_Graphics.lua @@ -62,6 +62,9 @@ GLSL.SYNTAX = [[ #ifdef GL_OES_texture_3D #extension GL_OES_texture_3D : enable #endif +#ifdef GL_OES_standard_derivatives +#extension GL_OES_standard_derivatives : enable +#endif ]] -- Uniforms shared by the vertex and pixel shader stages.