diff --git a/Test/baseResults/gl_samplemask_array_size.frag.out b/Test/baseResults/gl_samplemask_array_size.frag.out new file mode 100644 index 000000000..a7d5b7699 --- /dev/null +++ b/Test/baseResults/gl_samplemask_array_size.frag.out @@ -0,0 +1,81 @@ +gl_samplemask_array_size.frag +Shader version: 320 +0:? Sequence +0:4 Function Definition: main( ( global void) +0:4 Function Parameters: +0:6 Sequence +0:6 Sequence +0:6 Sequence +0:6 move second child to first child ( temp mediump int) +0:6 'i' ( temp mediump int) +0:6 Constant: +0:6 0 (const int) +0:6 Loop with condition tested first +0:6 Loop Condition +0:6 Compare Less Than ( temp bool) +0:6 'i' ( temp mediump int) +0:6 Constant: +0:6 1 (const int) +0:6 Loop Body +0:7 move second child to first child ( temp highp int) +0:7 indirect index ( temp highp int SampleMaskIn) +0:7 'gl_SampleMask' ( out runtime-sized array of highp int SampleMaskIn) +0:7 'i' ( temp mediump int) +0:7 Constant: +0:7 -1431655766 (const int) +0:6 Loop Terminal Expression +0:6 Pre-Increment ( temp mediump int) +0:6 'i' ( temp mediump int) +0:9 move second child to first child ( temp mediump 4-component vector of float) +0:9 'fragColor' (layout( location=0) out mediump 4-component vector of float) +0:9 Constant: +0:9 0.000000 +0:9 1.000000 +0:9 0.000000 +0:9 1.000000 +0:? Linker Objects +0:? 'fragColor' (layout( location=0) out mediump 4-component vector of float) +0:? 'gl_SampleMask' ( out runtime-sized array of highp int SampleMaskIn) + + +Linked fragment stage: + + +Shader version: 320 +0:? Sequence +0:4 Function Definition: main( ( global void) +0:4 Function Parameters: +0:6 Sequence +0:6 Sequence +0:6 Sequence +0:6 move second child to first child ( temp mediump int) +0:6 'i' ( temp mediump int) +0:6 Constant: +0:6 0 (const int) +0:6 Loop with condition tested first +0:6 Loop Condition +0:6 Compare Less Than ( temp bool) +0:6 'i' ( temp mediump int) +0:6 Constant: +0:6 1 (const int) +0:6 Loop Body +0:7 move second child to first child ( temp highp int) +0:7 indirect index ( temp highp int SampleMaskIn) +0:7 'gl_SampleMask' ( out 1-element array of highp int SampleMaskIn) +0:7 'i' ( temp mediump int) +0:7 Constant: +0:7 -1431655766 (const int) +0:6 Loop Terminal Expression +0:6 Pre-Increment ( temp mediump int) +0:6 'i' ( temp mediump int) +0:9 move second child to first child ( temp mediump 4-component vector of float) +0:9 'fragColor' (layout( location=0) out mediump 4-component vector of float) +0:9 Constant: +0:9 0.000000 +0:9 1.000000 +0:9 0.000000 +0:9 1.000000 +0:? Linker Objects +0:? 'fragColor' (layout( location=0) out mediump 4-component vector of float) +0:? 'gl_SampleMask' ( out 1-element array of highp int SampleMaskIn) + diff --git a/Test/baseResults/gl_samplemask_array_size_32.frag.out b/Test/baseResults/gl_samplemask_array_size_32.frag.out new file mode 100644 index 000000000..0569873e9 --- /dev/null +++ b/Test/baseResults/gl_samplemask_array_size_32.frag.out @@ -0,0 +1,39 @@ +gl_samplemask_array_size.frag +Shader version: 320 +0:? Sequence +0:4 Function Definition: main( ( global void) +0:4 Function Parameters: +0:6 Sequence +0:6 Sequence +0:6 Sequence +0:6 move second child to first child ( temp mediump int) +0:6 'i' ( temp mediump int) +0:6 Constant: +0:6 0 (const int) +0:6 Loop with condition tested first +0:6 Loop Condition +0:6 Compare Less Than ( temp bool) +0:6 'i' ( temp mediump int) +0:6 Constant: +0:6 1 (const int) +0:6 Loop Body +0:7 move second child to first child ( temp highp int) +0:7 indirect index ( temp highp int SampleMaskIn) +0:7 'gl_SampleMask' ( out runtime-sized array of highp int SampleMaskIn) +0:7 'i' ( temp mediump int) +0:7 Constant: +0:7 -1431655766 (const int) +0:6 Loop Terminal Expression +0:6 Pre-Increment ( temp mediump int) +0:6 'i' ( temp mediump int) +0:9 move second child to first child ( temp mediump 4-component vector of float) +0:9 'fragColor' (layout( location=0) out mediump 4-component vector of float) +0:9 Constant: +0:9 0.000000 +0:9 1.000000 +0:9 0.000000 +0:9 1.000000 +0:? Linker Objects +0:? 'fragColor' (layout( location=0) out mediump 4-component vector of float) +0:? 'gl_SampleMask' ( out runtime-sized array of highp int SampleMaskIn) + diff --git a/Test/baseResults/gl_samplemask_array_size_64.frag.out b/Test/baseResults/gl_samplemask_array_size_64.frag.out new file mode 100644 index 000000000..3780becc9 --- /dev/null +++ b/Test/baseResults/gl_samplemask_array_size_64.frag.out @@ -0,0 +1,39 @@ +gl_samplemask_array_size.frag +Shader version: 320 +0:? Sequence +0:4 Function Definition: main( ( global void) +0:4 Function Parameters: +0:6 Sequence +0:6 Sequence +0:6 Sequence +0:6 move second child to first child ( temp mediump int) +0:6 'i' ( temp mediump int) +0:6 Constant: +0:6 0 (const int) +0:6 Loop with condition tested first +0:6 Loop Condition +0:6 Compare Less Than ( temp bool) +0:6 'i' ( temp mediump int) +0:6 Constant: +0:6 2 (const int) +0:6 Loop Body +0:7 move second child to first child ( temp highp int) +0:7 indirect index ( temp highp int SampleMaskIn) +0:7 'gl_SampleMask' ( out runtime-sized array of highp int SampleMaskIn) +0:7 'i' ( temp mediump int) +0:7 Constant: +0:7 -1431655766 (const int) +0:6 Loop Terminal Expression +0:6 Pre-Increment ( temp mediump int) +0:6 'i' ( temp mediump int) +0:9 move second child to first child ( temp mediump 4-component vector of float) +0:9 'fragColor' (layout( location=0) out mediump 4-component vector of float) +0:9 Constant: +0:9 0.000000 +0:9 1.000000 +0:9 0.000000 +0:9 1.000000 +0:? Linker Objects +0:? 'fragColor' (layout( location=0) out mediump 4-component vector of float) +0:? 'gl_SampleMask' ( out runtime-sized array of highp int SampleMaskIn) + diff --git a/Test/gl_MaxSamples_32.conf b/Test/gl_MaxSamples_32.conf new file mode 100644 index 000000000..a1baaf584 --- /dev/null +++ b/Test/gl_MaxSamples_32.conf @@ -0,0 +1,111 @@ +MaxLights 32 +MaxClipPlanes 6 +MaxTextureUnits 32 +MaxTextureCoords 32 +MaxVertexAttribs 64 +MaxVertexUniformComponents 4096 +MaxVaryingFloats 64 +MaxVertexTextureImageUnits 32 +MaxCombinedTextureImageUnits 80 +MaxTextureImageUnits 32 +MaxFragmentUniformComponents 4096 +MaxDrawBuffers 32 +MaxVertexUniformVectors 128 +MaxVaryingVectors 8 +MaxFragmentUniformVectors 16 +MaxVertexOutputVectors 16 +MaxFragmentInputVectors 15 +MinProgramTexelOffset -8 +MaxProgramTexelOffset 7 +MaxClipDistances 8 +MaxComputeWorkGroupCountX 65535 +MaxComputeWorkGroupCountY 65535 +MaxComputeWorkGroupCountZ 65535 +MaxComputeWorkGroupSizeX 1024 +MaxComputeWorkGroupSizeY 1024 +MaxComputeWorkGroupSizeZ 64 +MaxComputeUniformComponents 1024 +MaxComputeTextureImageUnits 16 +MaxComputeImageUniforms 8 +MaxComputeAtomicCounters 8 +MaxComputeAtomicCounterBuffers 1 +MaxVaryingComponents 60 +MaxVertexOutputComponents 64 +MaxGeometryInputComponents 64 +MaxGeometryOutputComponents 128 +MaxFragmentInputComponents 128 +MaxImageUnits 8 +MaxCombinedImageUnitsAndFragmentOutputs 8 +MaxCombinedShaderOutputResources 8 +MaxImageSamples 0 +MaxVertexImageUniforms 0 +MaxTessControlImageUniforms 0 +MaxTessEvaluationImageUniforms 0 +MaxGeometryImageUniforms 0 +MaxFragmentImageUniforms 8 +MaxCombinedImageUniforms 8 +MaxGeometryTextureImageUnits 16 +MaxGeometryOutputVertices 256 +MaxGeometryTotalOutputComponents 1024 +MaxGeometryUniformComponents 1024 +MaxGeometryVaryingComponents 64 +MaxTessControlInputComponents 128 +MaxTessControlOutputComponents 128 +MaxTessControlTextureImageUnits 16 +MaxTessControlUniformComponents 1024 +MaxTessControlTotalOutputComponents 4096 +MaxTessEvaluationInputComponents 128 +MaxTessEvaluationOutputComponents 128 +MaxTessEvaluationTextureImageUnits 16 +MaxTessEvaluationUniformComponents 1024 +MaxTessPatchComponents 120 +MaxPatchVertices 32 +MaxTessGenLevel 64 +MaxViewports 16 +MaxVertexAtomicCounters 0 +MaxTessControlAtomicCounters 0 +MaxTessEvaluationAtomicCounters 0 +MaxGeometryAtomicCounters 0 +MaxFragmentAtomicCounters 8 +MaxCombinedAtomicCounters 8 +MaxAtomicCounterBindings 1 +MaxVertexAtomicCounterBuffers 0 +MaxTessControlAtomicCounterBuffers 0 +MaxTessEvaluationAtomicCounterBuffers 0 +MaxGeometryAtomicCounterBuffers 0 +MaxFragmentAtomicCounterBuffers 1 +MaxCombinedAtomicCounterBuffers 1 +MaxAtomicCounterBufferSize 16384 +MaxTransformFeedbackBuffers 4 +MaxTransformFeedbackInterleavedComponents 64 +MaxCullDistances 8 +MaxCombinedClipAndCullDistances 8 +MaxSamples 32 +MaxMeshOutputVerticesNV 256 +MaxMeshOutputPrimitivesNV 512 +MaxMeshWorkGroupSizeX_NV 32 +MaxMeshWorkGroupSizeY_NV 1 +MaxMeshWorkGroupSizeZ_NV 1 +MaxTaskWorkGroupSizeX_NV 32 +MaxTaskWorkGroupSizeY_NV 1 +MaxTaskWorkGroupSizeZ_NV 1 +MaxMeshViewCountNV 4 +MaxMeshOutputVerticesEXT 256 +MaxMeshOutputPrimitivesEXT 256 +MaxMeshWorkGroupSizeX_EXT 128 +MaxMeshWorkGroupSizeY_EXT 128 +MaxMeshWorkGroupSizeZ_EXT 128 +MaxTaskWorkGroupSizeX_EXT 128 +MaxTaskWorkGroupSizeY_EXT 128 +MaxTaskWorkGroupSizeZ_EXT 128 +MaxMeshViewCountEXT 4 +MaxDualSourceDrawBuffersEXT 1 +nonInductiveForLoops 1 +whileLoops 1 +doWhileLoops 1 +generalUniformIndexing 1 +generalAttributeMatrixVectorIndexing 1 +generalVaryingIndexing 1 +generalSamplerIndexing 1 +generalVariableIndexing 1 +generalConstantMatrixVectorIndexing 1 \ No newline at end of file diff --git a/Test/gl_MaxSamples_64.conf b/Test/gl_MaxSamples_64.conf new file mode 100644 index 000000000..dcab31977 --- /dev/null +++ b/Test/gl_MaxSamples_64.conf @@ -0,0 +1,111 @@ +MaxLights 32 +MaxClipPlanes 6 +MaxTextureUnits 32 +MaxTextureCoords 32 +MaxVertexAttribs 64 +MaxVertexUniformComponents 4096 +MaxVaryingFloats 64 +MaxVertexTextureImageUnits 32 +MaxCombinedTextureImageUnits 80 +MaxTextureImageUnits 32 +MaxFragmentUniformComponents 4096 +MaxDrawBuffers 32 +MaxVertexUniformVectors 128 +MaxVaryingVectors 8 +MaxFragmentUniformVectors 16 +MaxVertexOutputVectors 16 +MaxFragmentInputVectors 15 +MinProgramTexelOffset -8 +MaxProgramTexelOffset 7 +MaxClipDistances 8 +MaxComputeWorkGroupCountX 65535 +MaxComputeWorkGroupCountY 65535 +MaxComputeWorkGroupCountZ 65535 +MaxComputeWorkGroupSizeX 1024 +MaxComputeWorkGroupSizeY 1024 +MaxComputeWorkGroupSizeZ 64 +MaxComputeUniformComponents 1024 +MaxComputeTextureImageUnits 16 +MaxComputeImageUniforms 8 +MaxComputeAtomicCounters 8 +MaxComputeAtomicCounterBuffers 1 +MaxVaryingComponents 60 +MaxVertexOutputComponents 64 +MaxGeometryInputComponents 64 +MaxGeometryOutputComponents 128 +MaxFragmentInputComponents 128 +MaxImageUnits 8 +MaxCombinedImageUnitsAndFragmentOutputs 8 +MaxCombinedShaderOutputResources 8 +MaxImageSamples 0 +MaxVertexImageUniforms 0 +MaxTessControlImageUniforms 0 +MaxTessEvaluationImageUniforms 0 +MaxGeometryImageUniforms 0 +MaxFragmentImageUniforms 8 +MaxCombinedImageUniforms 8 +MaxGeometryTextureImageUnits 16 +MaxGeometryOutputVertices 256 +MaxGeometryTotalOutputComponents 1024 +MaxGeometryUniformComponents 1024 +MaxGeometryVaryingComponents 64 +MaxTessControlInputComponents 128 +MaxTessControlOutputComponents 128 +MaxTessControlTextureImageUnits 16 +MaxTessControlUniformComponents 1024 +MaxTessControlTotalOutputComponents 4096 +MaxTessEvaluationInputComponents 128 +MaxTessEvaluationOutputComponents 128 +MaxTessEvaluationTextureImageUnits 16 +MaxTessEvaluationUniformComponents 1024 +MaxTessPatchComponents 120 +MaxPatchVertices 32 +MaxTessGenLevel 64 +MaxViewports 16 +MaxVertexAtomicCounters 0 +MaxTessControlAtomicCounters 0 +MaxTessEvaluationAtomicCounters 0 +MaxGeometryAtomicCounters 0 +MaxFragmentAtomicCounters 8 +MaxCombinedAtomicCounters 8 +MaxAtomicCounterBindings 1 +MaxVertexAtomicCounterBuffers 0 +MaxTessControlAtomicCounterBuffers 0 +MaxTessEvaluationAtomicCounterBuffers 0 +MaxGeometryAtomicCounterBuffers 0 +MaxFragmentAtomicCounterBuffers 1 +MaxCombinedAtomicCounterBuffers 1 +MaxAtomicCounterBufferSize 16384 +MaxTransformFeedbackBuffers 4 +MaxTransformFeedbackInterleavedComponents 64 +MaxCullDistances 8 +MaxCombinedClipAndCullDistances 8 +MaxSamples 64 +MaxMeshOutputVerticesNV 256 +MaxMeshOutputPrimitivesNV 512 +MaxMeshWorkGroupSizeX_NV 32 +MaxMeshWorkGroupSizeY_NV 1 +MaxMeshWorkGroupSizeZ_NV 1 +MaxTaskWorkGroupSizeX_NV 32 +MaxTaskWorkGroupSizeY_NV 1 +MaxTaskWorkGroupSizeZ_NV 1 +MaxMeshViewCountNV 4 +MaxMeshOutputVerticesEXT 256 +MaxMeshOutputPrimitivesEXT 256 +MaxMeshWorkGroupSizeX_EXT 128 +MaxMeshWorkGroupSizeY_EXT 128 +MaxMeshWorkGroupSizeZ_EXT 128 +MaxTaskWorkGroupSizeX_EXT 128 +MaxTaskWorkGroupSizeY_EXT 128 +MaxTaskWorkGroupSizeZ_EXT 128 +MaxMeshViewCountEXT 4 +MaxDualSourceDrawBuffersEXT 1 +nonInductiveForLoops 1 +whileLoops 1 +doWhileLoops 1 +generalUniformIndexing 1 +generalAttributeMatrixVectorIndexing 1 +generalVaryingIndexing 1 +generalSamplerIndexing 1 +generalVariableIndexing 1 +generalConstantMatrixVectorIndexing 1 \ No newline at end of file diff --git a/Test/gl_samplemask_array_size.frag b/Test/gl_samplemask_array_size.frag new file mode 100644 index 000000000..52ef84968 --- /dev/null +++ b/Test/gl_samplemask_array_size.frag @@ -0,0 +1,10 @@ +#version 320 es + +layout(location = 0) out mediump vec4 fragColor; +void main (void) +{ + for (int i = 0; i < gl_SampleMask.length(); ++i) + gl_SampleMask[i] = int(0xAAAAAAAA); + + fragColor = vec4(0.0, 1.0, 0.0, 1.0); +} \ No newline at end of file diff --git a/Test/runtests b/Test/runtests index e7e1d33f4..4ab2280bc 100755 --- a/Test/runtests +++ b/Test/runtests @@ -49,6 +49,10 @@ rm -f comp.spv frag.spv geom.spv tesc.spv tese.spv vert.spv run badMacroArgs.frag > $TARGETDIR/badMacroArgs.frag.out diff -b $BASEDIR/badMacroArgs.frag.out $TARGETDIR/badMacroArgs.frag.out || HASERROR=1 +run gl_samplemask_array_size.frag gl_MaxSamples_32.conf -i > $TARGETDIR/gl_samplemask_array_size_32.frag.out +diff -b $BASEDIR/gl_samplemask_array_size_32.frag.out $TARGETDIR/gl_samplemask_array_size_32.frag.out || HASERROR=1 +run gl_samplemask_array_size.frag gl_MaxSamples_64.conf -i > $TARGETDIR/gl_samplemask_array_size_64.frag.out +diff -b $BASEDIR/gl_samplemask_array_size_64.frag.out $TARGETDIR/gl_samplemask_array_size_64.frag.out || HASERROR=1 # # reflection tests # diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index d1aaf3143..f84dc9bec 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -632,7 +632,7 @@ TIntermTyped* TParseContext::handleBracketDereference(const TSourceLoc& loc, TIn else { // input/output blocks either don't exist or can't be variably indexed } - } else if (language == EShLangFragment && base->getQualifier().isPipeOutput()) + } else if (language == EShLangFragment && base->getQualifier().isPipeOutput() && base->getQualifier().builtIn != EbvSampleMask) requireProfile(base->getLoc(), ~EEsProfile, "variable indexing fragment shader output array"); else if (base->getBasicType() == EbtSampler && version >= 130) { const char* explanation = "variable indexing sampler array"; @@ -1759,6 +1759,11 @@ TIntermTyped* TParseContext::handleLengthMethod(const TSourceLoc& loc, TFunction name == "gl_MeshPrimitivesNV") { length = getIoArrayImplicitSize(type.getQualifier()); } + } else if (const auto typed = intermNode->getAsTyped()) { + if (typed->getQualifier().builtIn == EbvSampleMask) { + requireProfile(loc, EEsProfile, "the array size of gl_SampleMask and gl_SampleMaskIn is ceil(gl_MaxSamples/32)"); + length = (resources.maxSamples + 31) / 32; + } } if (length == 0) { if (intermNode->getAsSymbolNode() && isIoResizeArray(type)) diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp index e8cf468bd..44aec44b6 100644 --- a/gtests/AST.FromFile.cpp +++ b/gtests/AST.FromFile.cpp @@ -282,6 +282,7 @@ INSTANTIATE_TEST_SUITE_P( "glsl.es320.subgroupQuad.comp", "glsl.es320.subgroupVote.comp", "glsl.es320.extTextureShadowLod.frag", + "gl_samplemask_array_size.frag", "glsl.ext.textureShadowLod.frag", "terminate.frag", "terminate.vert",