From: John Kessenich Date: Mon, 17 Aug 2015 03:55:59 +0000 (-0600) Subject: Implement GL_OES_sample_variables. X-Git-Tag: upstream/0.1~412 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=556ab3ac9663fa3d3468462d90b3985895d0b72f;p=platform%2Fupstream%2Fglslang.git Implement GL_OES_sample_variables. --- diff --git a/Test/310.frag b/Test/310.frag index f12d75f..6aa54a5 100644 --- a/Test/310.frag +++ b/Test/310.frag @@ -251,3 +251,26 @@ void CAT() highp ivec4 b6 = texture(CA6, vec4(0.5), 0.26); highp uvec4 b7 = texture(CA7, vec4(0.5), 0.27); } + +void badSample() +{ + lowp int a1 = gl_SampleID; // ERROR, need extension + mediump vec2 a2 = gl_SamplePosition; // ERROR, need extension + highp int a3 = gl_SampleMaskIn[0]; // ERROR, need extension + gl_SampleMask[0] = a3; // ERROR, need extension + mediump int n = gl_NumSamples; // ERROR, need extension +} + +#ifdef GL_OES_sample_variables +#extension GL_OES_sample_variables : enable +#endif + +void goodSample() +{ + lowp int a1 = gl_SampleID; + mediump vec2 a2 = gl_SamplePosition; + highp int a3 = gl_SampleMaskIn[0]; + gl_SampleMask[0] = a3; + mediump int n1 = gl_MaxSamples; + mediump int n2 = gl_NumSamples; +} diff --git a/Test/baseResults/310.frag.out b/Test/baseResults/310.frag.out index b48460c..7cf8e48 100644 --- a/Test/baseResults/310.frag.out +++ b/Test/baseResults/310.frag.out @@ -70,7 +70,12 @@ ERROR: 0:212: 'textureGatherOffsets' : required extension not requested: Possibl GL_EXT_gpu_shader5 GL_OES_gpu_shader5 ERROR: 0:223: 'textureGatherOffsets(...)' : must be a compile-time constant: offsets argument -ERROR: 62 compilation errors. No code generated. +ERROR: 0:257: 'gl_SampleID' : required extension not requested: GL_OES_sample_variables +ERROR: 0:258: 'gl_SamplePosition' : required extension not requested: GL_OES_sample_variables +ERROR: 0:259: 'gl_SampleMaskIn' : required extension not requested: GL_OES_sample_variables +ERROR: 0:260: 'gl_SampleMask' : required extension not requested: GL_OES_sample_variables +ERROR: 0:261: 'gl_NumSamples' : required extension not requested: GL_OES_sample_variables +ERROR: 67 compilation errors. No code generated. Shader version: 310 @@ -78,6 +83,7 @@ Requested GL_EXT_shader_io_blocks Requested GL_EXT_texture_cube_map_array Requested GL_OES_geometry_shader Requested GL_OES_gpu_shader5 +Requested GL_OES_sample_variables Requested GL_OES_shader_io_blocks gl_FragCoord pixel center is integer gl_FragCoord origin is upper left @@ -483,6 +489,67 @@ ERROR: node is still EOpNull! 0:252 0.500000 0:252 Constant: 0:252 0.270000 +0:255 Function Definition: badSample( (global void) +0:255 Function Parameters: +0:257 Sequence +0:257 Sequence +0:257 move second child to first child (temp lowp int) +0:257 'a1' (temp lowp int) +0:257 'gl_SampleID' (flat in lowp int SampleId) +0:258 Sequence +0:258 move second child to first child (temp mediump 2-component vector of float) +0:258 'a2' (temp mediump 2-component vector of float) +0:258 'gl_SamplePosition' (smooth in mediump 2-component vector of float SamplePosition) +0:259 Sequence +0:259 move second child to first child (temp highp int) +0:259 'a3' (temp highp int) +0:259 direct index (flat temp highp int SampleMaskIn) +0:259 'gl_SampleMaskIn' (flat in implicitly-sized array of highp int SampleMaskIn) +0:259 Constant: +0:259 0 (const int) +0:260 move second child to first child (temp highp int) +0:260 direct index (temp highp int SampleMaskIn) +0:260 'gl_SampleMask' (out implicitly-sized array of highp int SampleMaskIn) +0:260 Constant: +0:260 0 (const int) +0:260 'a3' (temp highp int) +0:261 Sequence +0:261 move second child to first child (temp mediump int) +0:261 'n' (temp mediump int) +0:261 'gl_NumSamples' (uniform lowp int) +0:268 Function Definition: goodSample( (global void) +0:268 Function Parameters: +0:270 Sequence +0:270 Sequence +0:270 move second child to first child (temp lowp int) +0:270 'a1' (temp lowp int) +0:270 'gl_SampleID' (flat in lowp int SampleId) +0:271 Sequence +0:271 move second child to first child (temp mediump 2-component vector of float) +0:271 'a2' (temp mediump 2-component vector of float) +0:271 'gl_SamplePosition' (smooth in mediump 2-component vector of float SamplePosition) +0:272 Sequence +0:272 move second child to first child (temp highp int) +0:272 'a3' (temp highp int) +0:272 direct index (flat temp highp int SampleMaskIn) +0:272 'gl_SampleMaskIn' (flat in implicitly-sized array of highp int SampleMaskIn) +0:272 Constant: +0:272 0 (const int) +0:273 move second child to first child (temp highp int) +0:273 direct index (temp highp int SampleMaskIn) +0:273 'gl_SampleMask' (out implicitly-sized array of highp int SampleMaskIn) +0:273 Constant: +0:273 0 (const int) +0:273 'a3' (temp highp int) +0:274 Sequence +0:274 move second child to first child (temp mediump int) +0:274 'n1' (temp mediump int) +0:274 Constant: +0:274 4 (const int) +0:275 Sequence +0:275 move second child to first child (temp mediump int) +0:275 'n2' (temp mediump int) +0:275 'gl_NumSamples' (uniform lowp int) 0:? Linker Objects 0:? 'gl_FragCoord' (smooth in mediump 4-component vector of float) 0:? 'v3' (layout(location=2 ) smooth in mediump 3-component vector of float) @@ -556,6 +623,8 @@ ERROR: node is still EOpNull! 0:? 'CA5' (uniform highp samplerCubeArrayShadow) 0:? 'CA6' (uniform highp isamplerCubeArray) 0:? 'CA7' (uniform highp usamplerCubeArray) +0:? 'gl_SampleMaskIn' (flat in implicitly-sized array of highp int SampleMaskIn) +0:? 'gl_SampleMask' (out implicitly-sized array of highp int SampleMaskIn) Linked fragment stage: @@ -567,6 +636,7 @@ Requested GL_EXT_shader_io_blocks Requested GL_EXT_texture_cube_map_array Requested GL_OES_geometry_shader Requested GL_OES_gpu_shader5 +Requested GL_OES_sample_variables Requested GL_OES_shader_io_blocks gl_FragCoord pixel center is integer gl_FragCoord origin is upper left @@ -972,6 +1042,67 @@ ERROR: node is still EOpNull! 0:252 0.500000 0:252 Constant: 0:252 0.270000 +0:255 Function Definition: badSample( (global void) +0:255 Function Parameters: +0:257 Sequence +0:257 Sequence +0:257 move second child to first child (temp lowp int) +0:257 'a1' (temp lowp int) +0:257 'gl_SampleID' (flat in lowp int SampleId) +0:258 Sequence +0:258 move second child to first child (temp mediump 2-component vector of float) +0:258 'a2' (temp mediump 2-component vector of float) +0:258 'gl_SamplePosition' (smooth in mediump 2-component vector of float SamplePosition) +0:259 Sequence +0:259 move second child to first child (temp highp int) +0:259 'a3' (temp highp int) +0:259 direct index (flat temp highp int SampleMaskIn) +0:259 'gl_SampleMaskIn' (flat in 1-element array of highp int SampleMaskIn) +0:259 Constant: +0:259 0 (const int) +0:260 move second child to first child (temp highp int) +0:260 direct index (temp highp int SampleMaskIn) +0:260 'gl_SampleMask' (out 1-element array of highp int SampleMaskIn) +0:260 Constant: +0:260 0 (const int) +0:260 'a3' (temp highp int) +0:261 Sequence +0:261 move second child to first child (temp mediump int) +0:261 'n' (temp mediump int) +0:261 'gl_NumSamples' (uniform lowp int) +0:268 Function Definition: goodSample( (global void) +0:268 Function Parameters: +0:270 Sequence +0:270 Sequence +0:270 move second child to first child (temp lowp int) +0:270 'a1' (temp lowp int) +0:270 'gl_SampleID' (flat in lowp int SampleId) +0:271 Sequence +0:271 move second child to first child (temp mediump 2-component vector of float) +0:271 'a2' (temp mediump 2-component vector of float) +0:271 'gl_SamplePosition' (smooth in mediump 2-component vector of float SamplePosition) +0:272 Sequence +0:272 move second child to first child (temp highp int) +0:272 'a3' (temp highp int) +0:272 direct index (flat temp highp int SampleMaskIn) +0:272 'gl_SampleMaskIn' (flat in 1-element array of highp int SampleMaskIn) +0:272 Constant: +0:272 0 (const int) +0:273 move second child to first child (temp highp int) +0:273 direct index (temp highp int SampleMaskIn) +0:273 'gl_SampleMask' (out 1-element array of highp int SampleMaskIn) +0:273 Constant: +0:273 0 (const int) +0:273 'a3' (temp highp int) +0:274 Sequence +0:274 move second child to first child (temp mediump int) +0:274 'n1' (temp mediump int) +0:274 Constant: +0:274 4 (const int) +0:275 Sequence +0:275 move second child to first child (temp mediump int) +0:275 'n2' (temp mediump int) +0:275 'gl_NumSamples' (uniform lowp int) 0:? Linker Objects 0:? 'gl_FragCoord' (smooth in mediump 4-component vector of float) 0:? 'v3' (layout(location=2 ) smooth in mediump 3-component vector of float) @@ -1045,4 +1176,6 @@ ERROR: node is still EOpNull! 0:? 'CA5' (uniform highp samplerCubeArrayShadow) 0:? 'CA6' (uniform highp isamplerCubeArray) 0:? 'CA7' (uniform highp usamplerCubeArray) +0:? 'gl_SampleMaskIn' (flat in 1-element array of highp int SampleMaskIn) +0:? 'gl_SampleMask' (out 1-element array of highp int SampleMaskIn) diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index d5dfc84..d2b8064 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "2.3.718" +#define GLSLANG_REVISION "2.3.719" #define GLSLANG_DATE "16-Aug-2015" diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 06e522e..354a1aa 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -1766,6 +1766,7 @@ void TBuiltIns::initialize(int version, EProfile profile) " in vec2 gl_SamplePosition;" "flat in int gl_SampleMaskIn[];" " out int gl_SampleMask[];" + "uniform int gl_NumSamples;" ); if (version >= 430) @@ -1782,26 +1783,36 @@ void TBuiltIns::initialize(int version, EProfile profile) } else { // ES profile - if (version == 100) + if (version == 100) { stageBuiltins[EShLangFragment].append( "mediump vec4 gl_FragCoord;" // needs qualifier fixed later " bool gl_FrontFacing;" // needs qualifier fixed later "mediump vec4 gl_FragColor;" // needs qualifier fixed later "mediump vec2 gl_PointCoord;" // needs qualifier fixed later ); - else if (version >= 300) { + } + if (version >= 300) { stageBuiltins[EShLangFragment].append( "highp vec4 gl_FragCoord;" // needs qualifier fixed later " bool gl_FrontFacing;" // needs qualifier fixed later "mediump vec2 gl_PointCoord;" // needs qualifier fixed later "highp float gl_FragDepth;" // needs qualifier fixed later ); - if (version >= 310) - stageBuiltins[EShLangFragment].append( - "bool gl_HelperInvocation;" // needs qualifier fixed later - "flat in highp int gl_PrimitiveID;" // needs qualifier fixed later - "flat in highp int gl_Layer;" // needs qualifier fixed later - ); + } + if (version >= 310) { + stageBuiltins[EShLangFragment].append( + "bool gl_HelperInvocation;" // needs qualifier fixed later + "flat in highp int gl_PrimitiveID;" // needs qualifier fixed later + "flat in highp int gl_Layer;" // needs qualifier fixed later + ); + + stageBuiltins[EShLangFragment].append( // GL_OES_sample_variables + "flat lowp in int gl_SampleID;" + " mediump in vec2 gl_SamplePosition;" + "flat highp in int gl_SampleMaskIn[];" + " highp out int gl_SampleMask[];" + "uniform lowp int gl_NumSamples;" + ); } stageBuiltins[EShLangFragment].append( "highp float gl_FragDepthEXT;" // GL_EXT_frag_depth @@ -2719,7 +2730,8 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf } // GL_ARB_ES3_1_compatibility - if (profile != EEsProfile && version >= 450) { + if ((profile != EEsProfile && version >= 450) || + (profile == EEsProfile && version >= 310)) { snprintf(builtInConstant, maxSize, "const int gl_MaxSamples = %d;", resources.maxSamples); s.append(builtInConstant); } @@ -2935,10 +2947,22 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb BuiltInVariable("gl_ClipDistance", EbvClipDistance, symbolTable); BuiltInVariable("gl_CullDistance", EbvCullDistance, symbolTable); BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable); - BuiltInVariable("gl_SampleID", EbvSampleId, symbolTable); - BuiltInVariable("gl_SamplePosition", EbvSamplePosition, symbolTable); - BuiltInVariable("gl_SampleMaskIn", EbvSampleMask, symbolTable); - BuiltInVariable("gl_SampleMask", EbvSampleMask, symbolTable); + + if ((profile != EEsProfile && version >= 400) || + (profile == EEsProfile && version >= 310)) { + BuiltInVariable("gl_SampleID", EbvSampleId, symbolTable); + BuiltInVariable("gl_SamplePosition", EbvSamplePosition, symbolTable); + BuiltInVariable("gl_SampleMaskIn", EbvSampleMask, symbolTable); + BuiltInVariable("gl_SampleMask", EbvSampleMask, symbolTable); + if (profile == EEsProfile) { + symbolTable.setVariableExtensions("gl_SampleID", 1, &E_GL_OES_sample_variables); + symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_OES_sample_variables); + symbolTable.setVariableExtensions("gl_SampleMaskIn", 1, &E_GL_OES_sample_variables); + symbolTable.setVariableExtensions("gl_SampleMask", 1, &E_GL_OES_sample_variables); + symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_OES_sample_variables); + } + } + BuiltInVariable("gl_Layer", EbvLayer, symbolTable); BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable); diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index dbd37cc..d5abaee 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -181,7 +181,7 @@ void TParseContext::initializeExtensionBehavior() // AEP extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisablePartial; extensionBehavior[E_GL_KHR_blend_equation_advanced] = EBhDisablePartial; - extensionBehavior[E_GL_OES_sample_variables] = EBhDisablePartial; + extensionBehavior[E_GL_OES_sample_variables] = EBhDisable; extensionBehavior[E_GL_OES_shader_image_atomic] = EBhDisablePartial; extensionBehavior[E_GL_OES_shader_multisample_interpolation] = EBhDisablePartial; extensionBehavior[E_GL_OES_texture_storage_multisample_2d_array] = EBhDisable;