mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-08 11:30:06 +00:00
34d4f78f03
Before this change, using gl_MeshPrimitivesEXT in mesh shader would unconditionally create gl_MeshPrimitivesEXT.gl_PrimitiveShadingRateEXT field and add PrimitiveShadingRateKHR capability to the output SPIRV file, which would subsequently trigger validation errors when creating the shader module unless the application requested primitive shading rate feature. What should happen instead is that unless GL_EXT_fragment_shading_rate extension is enabled, we should not allow using gl_PrimitiveShadingRateEXT and should not emit the associated fields into the output. This change fixes this by using existing filterMember mechanism that is already used in a few other cases like this, and adjusting the required extension on the field member which will generate an error when gl_PrimitiveShadingRateEXT is used without enabling the extension.
77 lines
2.6 KiB
Plaintext
77 lines
2.6 KiB
Plaintext
#version 460
|
|
|
|
#define MAX_VER 81
|
|
#define MAX_PRIM 32
|
|
|
|
#define BARRIER() \
|
|
memoryBarrierShared(); \
|
|
barrier();
|
|
|
|
#extension GL_EXT_mesh_shader : enable
|
|
#extension GL_EXT_fragment_shading_rate : enable
|
|
|
|
layout(local_size_x = 32, local_size_y=1, local_size_z=1) in;
|
|
|
|
layout(max_vertices=MAX_VER) out;
|
|
layout(max_primitives=MAX_PRIM) out;
|
|
layout(triangles) out;
|
|
|
|
// test use of builtins in mesh shaders:
|
|
|
|
void main()
|
|
{
|
|
uint iid = gl_LocalInvocationID.x;
|
|
uint gid = gl_WorkGroupID.x;
|
|
uvec3 numWorkGrous = gl_NumWorkGroups;
|
|
uint vertexCount = MAX_VER; // vertexCount <= max_vertices
|
|
uint primitiveCount = MAX_PRIM; // primitiveCount <= max_primtives
|
|
SetMeshOutputsEXT(vertexCount, primitiveCount);
|
|
|
|
gl_MeshVerticesEXT[iid].gl_Position = vec4(1.0);
|
|
gl_MeshVerticesEXT[iid].gl_PointSize = 2.0;
|
|
gl_MeshVerticesEXT[iid].gl_ClipDistance[3] = 3.0;
|
|
gl_MeshVerticesEXT[iid].gl_CullDistance[2] = 4.0;
|
|
|
|
BARRIER();
|
|
|
|
gl_MeshVerticesEXT[iid+1].gl_Position = gl_MeshVerticesEXT[iid].gl_Position;
|
|
gl_MeshVerticesEXT[iid+1].gl_PointSize = gl_MeshVerticesEXT[iid].gl_PointSize;
|
|
gl_MeshVerticesEXT[iid+1].gl_ClipDistance[3] = gl_MeshVerticesEXT[iid].gl_ClipDistance[3];
|
|
gl_MeshVerticesEXT[iid+1].gl_CullDistance[2] = gl_MeshVerticesEXT[iid].gl_CullDistance[2];
|
|
|
|
BARRIER();
|
|
|
|
gl_MeshPrimitivesEXT[iid].gl_PrimitiveID = 6;
|
|
gl_MeshPrimitivesEXT[iid].gl_Layer = 7;
|
|
gl_MeshPrimitivesEXT[iid].gl_ViewportIndex = 8;
|
|
gl_MeshPrimitivesEXT[iid].gl_CullPrimitiveEXT = false;
|
|
gl_MeshPrimitivesEXT[iid].gl_PrimitiveShadingRateEXT = 0;
|
|
|
|
BARRIER();
|
|
|
|
gl_MeshPrimitivesEXT[iid+1].gl_PrimitiveID = gl_MeshPrimitivesEXT[iid].gl_PrimitiveID;
|
|
gl_MeshPrimitivesEXT[iid+1].gl_Layer = gl_MeshPrimitivesEXT[iid].gl_Layer;
|
|
gl_MeshPrimitivesEXT[iid+1].gl_ViewportIndex = gl_MeshPrimitivesEXT[iid].gl_ViewportIndex;
|
|
gl_MeshPrimitivesEXT[iid+1].gl_CullPrimitiveEXT = gl_MeshPrimitivesEXT[iid].gl_CullPrimitiveEXT;
|
|
gl_MeshPrimitivesEXT[iid+1].gl_PrimitiveShadingRateEXT = 0;
|
|
|
|
BARRIER();
|
|
|
|
// check bound limits
|
|
gl_PrimitiveTriangleIndicesEXT[0] = uvec3(257); // should truncate 257 -> 1, range is between [0, vertexCount-1]
|
|
gl_PrimitiveTriangleIndicesEXT[primitiveCount - 1] = uvec3(2); // array size is primitiveCount*3 for triangle
|
|
gl_PrimitiveTriangleIndicesEXT[gid] = gl_PrimitiveTriangleIndicesEXT[gid-1];
|
|
|
|
BARRIER();
|
|
}
|
|
|
|
// test use of builtins enabled by other extensions
|
|
#extension GL_ARB_shader_draw_parameters : enable
|
|
#extension GL_EXT_multiview : enable
|
|
|
|
void testAdditionalBuiltins()
|
|
{
|
|
int id = gl_DrawIDARB; // GL_ARB_shader_draw_parameters
|
|
int viewIdx = gl_ViewIndex; // GL_EXT_multiview
|
|
|
|
} |