The array size of gl_SampleMask and gl_SampleMaskIn is ceil(gl_MaxSamples/32)

Oes spec says:
    For the both the input array gl_SampleMaskIn[] and the output array gl_SampleMask[], bit B of mask M
    (gl_SampleMaskIn[M] or gl_SampleMask[M]) corresponds to sample 32*M+B. These arrays have
    ceil(gl_MaxSamples/32) elements, where gl_MaxSamples is the maximum number of color samples
    supported by the implementation.

    But glslang report error "array must have size before use length".

    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);
    }

* Add two test items, one is for gl_MaxSapmles = 32 and the other one is for gl_MaxSapmles = 64.
This commit is contained in:
jimihem 2023-12-30 05:23:16 +08:00 committed by GitHub
parent 88c5373ee4
commit db4d6f85af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 402 additions and 1 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

111
Test/gl_MaxSamples_32.conf Normal file
View File

@ -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

111
Test/gl_MaxSamples_64.conf Normal file
View File

@ -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

View File

@ -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);
}

View File

@ -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
#

View File

@ -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))

View File

@ -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",