Implement GL_EXT_shader_texture_lod.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24177 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-11-22 17:30:34 +00:00
parent 04884e42ed
commit ad43f6f684
5 changed files with 52 additions and 11 deletions

Binary file not shown.

View File

@ -140,13 +140,27 @@ void foo246()
}
#extension GL_OES_EGL_image_external : disable
uniform sampler2D s2Dg;
int foo203940(int a, float b, float a) // ERROR, a redefined
{
texture2DProjGradEXT(s2Dg, vec3(f13), uv2, uv2); // ERROR, extension not enabled
return a;
}
float f123 = 4.0f; // ERROR
float f124 = 5e10F; // ERROR
#extension GL_EXT_shader_texture_lod : enable
uniform samplerCube sCube;
void foo323433()
{
texture2DLodEXT(s2Dg, uv2, f13);
texture2DProjGradEXT(s2Dg, vec3(f13), uv2, uv2);
texture2DGradEXT(s2Dg, uv2, uv2, uv2);
textureCubeGradEXT(sCube, vec3(f13), vec3(f13), vec3(f13));
}
uniform samplerExternalOES badExt; // syntax ERROR

View File

@ -43,9 +43,9 @@
// TBuiltIns::initialize(version,profile) context-independent textual built-ins; add them to the right string
// TBuiltIns::initialize(resources,...) context-dependent textual built-ins; add them to the right string
// IdentifyBuiltIns(...,symbolTable) context-independent programmatic additions/mappings to the symbol table,
// including identify what extensions are needed if a version does not allow a symbol
// including identifying what extensions are needed if a version does not allow a symbol
// IdentifyBuiltIns(...,symbolTable, resources) context-dependent programmatic additions/mappings to the symbol table,
// including identify what extensions are needed if a version does not allow a symbol
// including identifying what extensions are needed if a version does not allow a symbol
//
#include "../Include/intermediate.h"
@ -648,7 +648,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
}
//
// Original-style texture functions existing in both stages.
// Original-style texture functions existing in all stages.
// (Per-stage functions below.)
//
if ((profile == EEsProfile && version == 100) ||
@ -686,12 +686,16 @@ void TBuiltIns::initialize(int version, EProfile profile)
"\n");
}
if (profile == EEsProfile) {
// GL_OES_EGL_image_external, caught by keyword check
if (profile == EEsProfile) {
commonBuiltins.append(
"vec4 texture2D(samplerExternalOES, vec2 coord);"
"vec4 texture2DProj(samplerExternalOES, vec3);"
"vec4 texture2DProj(samplerExternalOES, vec4);"
"vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external, caught by keyword check
"vec4 texture2DProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external, caught by keyword check
"vec4 texture2DProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external, caught by keyword check
"vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);" // GL_EXT_shader_texture_lod
"vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);" // GL_EXT_shader_texture_lod
"vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);" // GL_EXT_shader_texture_lod
"vec4 textureCubeGradEXT(samplerCube, vec3, vec3, vec3);" // GL_EXT_shader_texture_lod
"\n");
}
@ -857,6 +861,15 @@ void TBuiltIns::initialize(int version, EProfile profile)
"\n");
}
if (profile == EEsProfile) {
stageBuiltins[EShLangFragment].append(
"vec4 texture2DLodEXT(sampler2D, vec2, float);" // GL_EXT_shader_texture_lod
"vec4 texture2DProjLodEXT(sampler2D, vec3, float);" // GL_EXT_shader_texture_lod
"vec4 texture2DProjLodEXT(sampler2D, vec4, float);" // GL_EXT_shader_texture_lod
"vec4 textureCubeLodEXT(samplerCube, vec3, float);" // GL_EXT_shader_texture_lod
"\n");
}
stageBuiltins[EShLangFragment].append(
"float dFdx(float p);"
@ -2161,6 +2174,11 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
symbolTable.setFunctionExtensions("dFdy", 1, &GL_OES_standard_derivatives);
symbolTable.setFunctionExtensions("fwidth", 1, &GL_OES_standard_derivatives);
}
if (profile == EEsProfile) {
symbolTable.setFunctionExtensions("texture2DLodEXT", 1, &GL_EXT_shader_texture_lod);
symbolTable.setFunctionExtensions("texture2DProjLodEXT", 1, &GL_EXT_shader_texture_lod);
symbolTable.setFunctionExtensions("textureCubeLodEXT", 1, &GL_EXT_shader_texture_lod);
}
symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &GL_EXT_frag_depth);
break;
@ -2173,9 +2191,15 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
break;
}
if (profile == EEsProfile) {
symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &GL_EXT_shader_texture_lod);
symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &GL_EXT_shader_texture_lod);
symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &GL_EXT_shader_texture_lod);
}
//
// Next, identify which built-ins from the already loaded headers have
// a mapping to an operator. Those that are not identified as such are
// Next, identify which built-ins have a mapping to an operator.
// Those that are not identified as such are
// expected to be resolved through a library of functions, versus as
// operations.
//

View File

@ -153,6 +153,7 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[GL_OES_standard_derivatives] = EBhDisable;
extensionBehavior[GL_EXT_frag_depth] = EBhDisable;
extensionBehavior[GL_OES_EGL_image_external] = EBhDisable;
extensionBehavior[GL_EXT_shader_texture_lod] = EBhDisable;
extensionBehavior[GL_ARB_texture_rectangle] = EBhDisable;
extensionBehavior[GL_3DL_array_objects] = EBhDisable;
@ -171,7 +172,8 @@ const char* TParseContext::getPreamble()
"#define GL_OES_texture_3D 1\n"
"#define GL_OES_standard_derivatives 1\n"
"#define GL_EXT_frag_depth 1\n"
"#define GL_OES_EGL_image_external 1\n";
"#define GL_OES_EGL_image_external 1\n"
"#define GL_EXT_shader_texture_lod 1\n";
} else {
return
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"

View File

@ -76,6 +76,7 @@ const char* const GL_OES_texture_3D = "GL_OES_texture_3D";
const char* const GL_OES_standard_derivatives = "GL_OES_standard_derivatives";
const char* const GL_EXT_frag_depth = "GL_EXT_frag_depth";
const char* const GL_OES_EGL_image_external = "GL_OES_EGL_image_external";
const char* const GL_EXT_shader_texture_lod = "GL_EXT_shader_texture_lod";
const char* const GL_ARB_texture_rectangle = "GL_ARB_texture_rectangle";
const char* const GL_3DL_array_objects = "GL_3DL_array_objects";