Front-end: Implement GL_EXT_shader_non_constant_global_initializers.
This lets ES shaders use non-constant initializers for non-constant globals.
This commit is contained in:
parent
b901ade058
commit
21f1286f57
@ -213,6 +213,12 @@ float fooinit()
|
|||||||
|
|
||||||
int init1 = gl_FrontFacing ? 1 : 2; // ERROR, non-const initializer
|
int init1 = gl_FrontFacing ? 1 : 2; // ERROR, non-const initializer
|
||||||
|
|
||||||
|
#ifdef GL_EXT_shader_non_constant_global_initializers
|
||||||
|
#extension GL_EXT_shader_non_constant_global_initializers : enable
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int init2 = gl_FrontFacing ? 1 : 2;
|
||||||
|
|
||||||
#pragma STDGL invariant(all)
|
#pragma STDGL invariant(all)
|
||||||
|
|
||||||
#line 3000
|
#line 3000
|
||||||
|
@ -82,7 +82,7 @@ ERROR: 0:192: '.' : cannot apply to an array: nothing
|
|||||||
ERROR: 0:193: '.length' : not supported for this version or the enabled extensions
|
ERROR: 0:193: '.length' : not supported for this version or the enabled extensions
|
||||||
ERROR: 0:194: '.' : cannot apply to an array: method
|
ERROR: 0:194: '.' : cannot apply to an array: method
|
||||||
ERROR: 0:194: 'a' : can't use function syntax on variable
|
ERROR: 0:194: 'a' : can't use function syntax on variable
|
||||||
ERROR: 0:214: 'non-constant global initializer' : not supported with this profile: es
|
ERROR: 0:214: 'non-constant global initializer (needs GL_EXT_shader_non_constant_global_initializers)' : not supported for this version or the enabled extensions
|
||||||
ERROR: 0:3000: '#error' : line of this error should be 3000
|
ERROR: 0:3000: '#error' : line of this error should be 3000
|
||||||
ERROR: 0:3002: '' : syntax error
|
ERROR: 0:3002: '' : syntax error
|
||||||
ERROR: 77 compilation errors. No code generated.
|
ERROR: 77 compilation errors. No code generated.
|
||||||
@ -90,6 +90,7 @@ ERROR: 77 compilation errors. No code generated.
|
|||||||
|
|
||||||
Shader version: 100
|
Shader version: 100
|
||||||
Requested GL_EXT_frag_depth
|
Requested GL_EXT_frag_depth
|
||||||
|
Requested GL_EXT_shader_non_constant_global_initializers
|
||||||
Requested GL_EXT_shader_texture_lod
|
Requested GL_EXT_shader_texture_lod
|
||||||
Requested GL_OES_EGL_image_external
|
Requested GL_OES_EGL_image_external
|
||||||
Requested GL_OES_standard_derivatives
|
Requested GL_OES_standard_derivatives
|
||||||
@ -376,6 +377,18 @@ ERROR: node is still EOpNull!
|
|||||||
0:214 false case
|
0:214 false case
|
||||||
0:214 Constant:
|
0:214 Constant:
|
||||||
0:214 2 (const int)
|
0:214 2 (const int)
|
||||||
|
0:220 Sequence
|
||||||
|
0:220 move second child to first child (temp mediump int)
|
||||||
|
0:220 'init2' (global mediump int)
|
||||||
|
0:220 Test condition and select (temp mediump int)
|
||||||
|
0:220 Condition
|
||||||
|
0:220 'gl_FrontFacing' (gl_FrontFacing bool Face)
|
||||||
|
0:220 true case
|
||||||
|
0:220 Constant:
|
||||||
|
0:220 1 (const int)
|
||||||
|
0:220 false case
|
||||||
|
0:220 Constant:
|
||||||
|
0:220 2 (const int)
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
0:? 'a' (global 3-element array of mediump int)
|
0:? 'a' (global 3-element array of mediump int)
|
||||||
0:? 'uint' (global mediump int)
|
0:? 'uint' (global mediump int)
|
||||||
@ -407,6 +420,7 @@ ERROR: node is still EOpNull!
|
|||||||
0:? 'fi3' (const mediump float)
|
0:? 'fi3' (const mediump float)
|
||||||
0:? 5.000000
|
0:? 5.000000
|
||||||
0:? 'init1' (global mediump int)
|
0:? 'init1' (global mediump int)
|
||||||
|
0:? 'init2' (global mediump int)
|
||||||
|
|
||||||
|
|
||||||
Linked fragment stage:
|
Linked fragment stage:
|
||||||
@ -414,6 +428,7 @@ Linked fragment stage:
|
|||||||
|
|
||||||
Shader version: 100
|
Shader version: 100
|
||||||
Requested GL_EXT_frag_depth
|
Requested GL_EXT_frag_depth
|
||||||
|
Requested GL_EXT_shader_non_constant_global_initializers
|
||||||
Requested GL_EXT_shader_texture_lod
|
Requested GL_EXT_shader_texture_lod
|
||||||
Requested GL_OES_EGL_image_external
|
Requested GL_OES_EGL_image_external
|
||||||
Requested GL_OES_standard_derivatives
|
Requested GL_OES_standard_derivatives
|
||||||
@ -700,6 +715,18 @@ ERROR: node is still EOpNull!
|
|||||||
0:214 false case
|
0:214 false case
|
||||||
0:214 Constant:
|
0:214 Constant:
|
||||||
0:214 2 (const int)
|
0:214 2 (const int)
|
||||||
|
0:220 Sequence
|
||||||
|
0:220 move second child to first child (temp mediump int)
|
||||||
|
0:220 'init2' (global mediump int)
|
||||||
|
0:220 Test condition and select (temp mediump int)
|
||||||
|
0:220 Condition
|
||||||
|
0:220 'gl_FrontFacing' (gl_FrontFacing bool Face)
|
||||||
|
0:220 true case
|
||||||
|
0:220 Constant:
|
||||||
|
0:220 1 (const int)
|
||||||
|
0:220 false case
|
||||||
|
0:220 Constant:
|
||||||
|
0:220 2 (const int)
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
0:? 'a' (global 3-element array of mediump int)
|
0:? 'a' (global 3-element array of mediump int)
|
||||||
0:? 'uint' (global mediump int)
|
0:? 'uint' (global mediump int)
|
||||||
@ -731,4 +758,5 @@ ERROR: node is still EOpNull!
|
|||||||
0:? 'fi3' (const mediump float)
|
0:? 'fi3' (const mediump float)
|
||||||
0:? 5.000000
|
0:? 5.000000
|
||||||
0:? 'init1' (global mediump int)
|
0:? 'init1' (global mediump int)
|
||||||
|
0:? 'init2' (global mediump int)
|
||||||
|
|
||||||
|
@ -5083,11 +5083,13 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
|
|||||||
// "In declarations of global variables with no storage qualifier or with a const
|
// "In declarations of global variables with no storage qualifier or with a const
|
||||||
// qualifier any initializer must be a constant expression."
|
// qualifier any initializer must be a constant expression."
|
||||||
if (symbolTable.atGlobalLevel() && ! initializer->getType().getQualifier().isConstant()) {
|
if (symbolTable.atGlobalLevel() && ! initializer->getType().getQualifier().isConstant()) {
|
||||||
const char* initFeature = "non-constant global initializer";
|
const char* initFeature = "non-constant global initializer (needs GL_EXT_shader_non_constant_global_initializers)";
|
||||||
if (relaxedErrors())
|
if (profile == EEsProfile) {
|
||||||
warn(loc, "not allowed in this version", initFeature, "");
|
if (relaxedErrors() && ! extensionTurnedOn(E_GL_EXT_shader_non_constant_global_initializers))
|
||||||
else
|
warn(loc, "not allowed in this version", initFeature, "");
|
||||||
requireProfile(loc, ~EEsProfile, initFeature);
|
else
|
||||||
|
profileRequires(loc, EEsProfile, 0, E_GL_EXT_shader_non_constant_global_initializers, initFeature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +182,8 @@ void TParseVersions::initializeExtensionBehavior()
|
|||||||
extensionBehavior[E_GL_ARB_sparse_texture_clamp] = EBhDisable;
|
extensionBehavior[E_GL_ARB_sparse_texture_clamp] = EBhDisable;
|
||||||
// extensionBehavior[E_GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members
|
// extensionBehavior[E_GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members
|
||||||
|
|
||||||
|
extensionBehavior[E_GL_EXT_shader_non_constant_global_initializers] = EBhDisable;
|
||||||
|
|
||||||
// #line and #include
|
// #line and #include
|
||||||
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
|
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
|
||||||
extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable;
|
extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable;
|
||||||
@ -256,6 +258,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||||||
"#define GL_OES_tessellation_point_size 1\n"
|
"#define GL_OES_tessellation_point_size 1\n"
|
||||||
"#define GL_OES_texture_buffer 1\n"
|
"#define GL_OES_texture_buffer 1\n"
|
||||||
"#define GL_OES_texture_cube_map_array 1\n"
|
"#define GL_OES_texture_cube_map_array 1\n"
|
||||||
|
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
preamble =
|
preamble =
|
||||||
@ -284,6 +287,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||||||
"#define GL_ARB_sparse_texture2 1\n"
|
"#define GL_ARB_sparse_texture2 1\n"
|
||||||
"#define GL_ARB_sparse_texture_clamp 1\n"
|
"#define GL_ARB_sparse_texture_clamp 1\n"
|
||||||
// "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members
|
// "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members
|
||||||
|
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,8 @@ const char* const E_GL_ARB_sparse_texture2 = "GL_ARB_sparse_texture
|
|||||||
const char* const E_GL_ARB_sparse_texture_clamp = "GL_ARB_sparse_texture_clamp";
|
const char* const E_GL_ARB_sparse_texture_clamp = "GL_ARB_sparse_texture_clamp";
|
||||||
//const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
|
//const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
|
||||||
|
|
||||||
|
const char* const E_GL_EXT_shader_non_constant_global_initializers = "GL_EXT_shader_non_constant_global_initializers";
|
||||||
|
|
||||||
// #line and #include
|
// #line and #include
|
||||||
const char* const E_GL_GOOGLE_cpp_style_line_directive = "GL_GOOGLE_cpp_style_line_directive";
|
const char* const E_GL_GOOGLE_cpp_style_line_directive = "GL_GOOGLE_cpp_style_line_directive";
|
||||||
const char* const E_GL_GOOGLE_include_directive = "GL_GOOGLE_include_directive";
|
const char* const E_GL_GOOGLE_include_directive = "GL_GOOGLE_include_directive";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user