Implement cull distances for GLSL 4.5 (but not as an extension yet, just a 4.5 feature).

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27714 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2014-08-13 06:37:59 +00:00
parent 13fd6c9dd7
commit 699684180f
20 changed files with 414 additions and 3 deletions

View file

@ -130,6 +130,8 @@ struct TBuiltInResource {
int maxAtomicCounterBufferSize;
int maxTransformFeedbackBuffers;
int maxTransformFeedbackInterleavedComponents;
int maxCullDistances;
int maxCombinedClipAndCullDistances;
TLimits limits;
};

View file

@ -1221,7 +1221,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
"vec4 gl_Position;" // needs qualifier fixed later
"float gl_PointSize;" // needs qualifier fixed later
"float gl_ClipDistance[];"
);
);
if (IncludeLegacy(version, profile))
stageBuiltins[EShLangVertex].append(
"vec4 gl_ClipVertex;" // needs qualifier fixed later
@ -1232,6 +1232,10 @@ void TBuiltIns::initialize(int version, EProfile profile)
"vec4 gl_TexCoord[];"
"float gl_FogFragCoord;"
);
if (version >= 450)
stageBuiltins[EShLangVertex].append(
"float gl_CullDistance[];"
);
stageBuiltins[EShLangVertex].append(
"};"
"\n");
@ -1285,6 +1289,10 @@ void TBuiltIns::initialize(int version, EProfile profile)
"vec4 gl_TexCoord[];"
"float gl_FogFragCoord;"
);
if (version >= 450)
stageBuiltins[EShLangGeometry].append(
"float gl_CullDistance[];"
);
stageBuiltins[EShLangGeometry].append(
"} gl_in[];"
@ -1304,6 +1312,10 @@ void TBuiltIns::initialize(int version, EProfile profile)
"vec4 gl_TexCoord[];"
"float gl_FogFragCoord;"
);
if (version >= 450)
stageBuiltins[EShLangGeometry].append(
"float gl_CullDistance[];"
);
stageBuiltins[EShLangGeometry].append(
"};"
@ -1356,6 +1368,10 @@ void TBuiltIns::initialize(int version, EProfile profile)
"vec4 gl_TexCoord[];"
"float gl_FogFragCoord;"
);
if (version >= 450)
stageBuiltins[EShLangTessControl].append(
"float gl_CullDistance[];"
);
stageBuiltins[EShLangTessControl].append(
"} gl_out[];"
@ -1397,6 +1413,10 @@ void TBuiltIns::initialize(int version, EProfile profile)
"vec4 gl_TexCoord[];"
"float gl_FogFragCoord;"
);
if (version >= 450)
stageBuiltins[EShLangTessEvaluation].append(
"float gl_CullDistance[];"
);
stageBuiltins[EShLangTessEvaluation].append(
"};"
"\n");
@ -1477,6 +1497,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
if (version >= 450)
stageBuiltins[EShLangFragment].append(
"in float gl_CullDistance[];"
"bool gl_HelperInvocation;" // needs qualifier fixed later
);
} else {
@ -2200,6 +2221,10 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
"vec4 gl_TexCoord[];"
"float gl_FogFragCoord;"
);
if (profile != EEsProfile && version >= 450)
s.append(
"float gl_CullDistance[];"
);
s.append(
"} gl_in[gl_MaxPatchVertices];"
"\n");
@ -2301,6 +2326,14 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append(builtInConstant);
}
// GL_ARB_cull_distance
if (profile != EEsProfile && version >= 450) {
snprintf(builtInConstant, maxSize, "const int gl_MaxCullDistances = %d;", resources.maxCullDistances);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedClipAndCullDistances = %d;", resources.maxCombinedClipAndCullDistances);
s.append(builtInConstant);
}
s.append("\n");
}

View file

@ -2559,6 +2559,7 @@ TSymbol* TParseContext::redeclareBuiltinVariable(TSourceLoc loc, const TString&
//
// Either redeclare the requested block, or give an error message why it can't be done.
//
// TODO: functionality: explicitly sizing members of redeclared blocks is not giving them an explicit size
void TParseContext::redeclareBuiltinBlock(TSourceLoc loc, TTypeList& newTypeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes)
{
const char* feature = "built-in block redeclaration";

View file

@ -169,6 +169,7 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[GL_ARB_shader_image_load_store] = EBhDisable;
extensionBehavior[GL_ARB_shader_atomic_counters] = EBhDisable;
extensionBehavior[GL_ARB_derivative_control] = EBhDisable;
// extensionBehavior[GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members
}
// Get code that is not part of a shared symbol table, is specific to this shader,
@ -184,7 +185,8 @@ const char* TParseContext::getPreamble()
"#define GL_OES_standard_derivatives 1\n"
"#define GL_EXT_frag_depth 1\n"
"#define GL_OES_EGL_image_external 1\n"
"#define GL_EXT_shader_texture_lod 1\n";
"#define GL_EXT_shader_texture_lod 1\n"
;
} else {
return
"#define GL_ES 1\n"
@ -192,7 +194,8 @@ const char* TParseContext::getPreamble()
"#define GL_OES_standard_derivatives 1\n"
"#define GL_EXT_frag_depth 1\n"
"#define GL_OES_EGL_image_external 1\n"
"#define GL_EXT_shader_texture_lod 1\n";
"#define GL_EXT_shader_texture_lod 1\n"
;
}
} else {
return
@ -210,6 +213,7 @@ const char* TParseContext::getPreamble()
"#define GL_ARB_shader_image_load_store 1\n"
"#define GL_ARB_shader_atomic_counters 1\n"
"#define GL_ARB_derivative_control 1\n"
// "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members
;
}
}

View file

@ -93,6 +93,7 @@ const char* const GL_ARB_explicit_attrib_location = "GL_ARB_explicit_attrib_loca
const char* const GL_ARB_shader_image_load_store = "GL_ARB_shader_image_load_store";
const char* const GL_ARB_shader_atomic_counters = "GL_ARB_shader_atomic_counters";
const char* const GL_ARB_derivative_control = "GL_ARB_derivative_control";
//const char* const GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
} // end namespace glslang