Parcourir la source

GL: Fixed GLSL version when texelFetch is used. Issue #725.

Branimir Karadžić il y a 9 ans
Parent
commit
6484b283dc
1 fichiers modifiés avec 14 ajouts et 6 suppressions
  1. 14 6
      src/renderer_gl.cpp

+ 14 - 6
src/renderer_gl.cpp

@@ -901,6 +901,13 @@ namespace bgfx { namespace gl
 		NULL
 		NULL
 	};
 	};
 
 
+	static const char* s_texelFetch[] =
+	{
+		"texelFetch",
+		"texelFetchOffset",
+		NULL
+	};
+
 	static void GL_APIENTRY stubVertexAttribDivisor(GLuint /*_index*/, GLuint /*_divisor*/)
 	static void GL_APIENTRY stubVertexAttribDivisor(GLuint /*_index*/, GLuint /*_divisor*/)
 	{
 	{
 	}
 	}
@@ -4821,16 +4828,17 @@ namespace bgfx { namespace gl
 				else if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
 				else if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
 					 &&  BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL <= 21) )
 					 &&  BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL <= 21) )
 				{
 				{
-					bool usesTextureLod = true
+					const bool usesTextureLod = true
 						&& s_extension[Extension::ARB_shader_texture_lod].m_supported
 						&& s_extension[Extension::ARB_shader_texture_lod].m_supported
 						&& bx::findIdentifierMatch(code, s_ARB_shader_texture_lod)
 						&& bx::findIdentifierMatch(code, s_ARB_shader_texture_lod)
 						;
 						;
+					const bool usesIUsamplers = !!bx::findIdentifierMatch(code, s_uisamplers);
+					const bool usesTexelFetch = !!bx::findIdentifierMatch(code, s_texelFetch);
 
 
-					bool usesIUsamplers = !!bx::findIdentifierMatch(code, s_uisamplers);
-
-					uint32_t version = usesIUsamplers
-						? 130
-						: (usesTextureLod ? 120 : 0)
+					uint32_t version =
+						  usesTexelFetch || usesIUsamplers ? 130
+						: usesTextureLod ? 120
+						: 0
 						;
 						;
 
 
 					if (0 != version)
 					if (0 != version)