Add ShaderBuiltin::MultiViewIndex

Mapped to:
SPIR-V ViewIndex (which was previously mapped to ShaderBuiltin::ViewportIndex)
GL gl_ViewIndex
This commit is contained in:
Jake Turner
2024-01-31 09:11:58 +00:00
parent 045a71082b
commit 226bf7071b
9 changed files with 19 additions and 4 deletions
+1
View File
@@ -1653,6 +1653,7 @@ QString D3DSemanticString(const SigParameter &sig)
lit("SV_Barycentrics"),
lit("SV_CullPrimitive"),
lit("out indices"),
lit("SV_ViewID"),
};
static_assert(arraydim<ShaderBuiltin>() == ARRAY_COUNT(sysValues),
+1 -1
View File
@@ -165,7 +165,7 @@ gl_CullDistance gl_FragCoord gl_FragDepth gl_FrontFacing gl_GlobalInvocationID g
gl_in gl_InstanceID gl_InvocationID gl_Layer gl_LocalInvocationID gl_LocalInvocationIndex
gl_MaxPatchVertices gl_NumWorkGroups gl_out gl_PatchVerticesIn gl_PerVertex gl_PointCoord
gl_PointSize gl_Position gl_PrimitiveID gl_PrimitiveIDIn gl_SampleID gl_SampleMask gl_SampleMaskIn
gl_SamplePosition gl_TessCoord gl_TessLevelInner gl_TessLevelOuter gl_VertexID gl_ViewportIndex
gl_SamplePosition gl_TessCoord gl_TessLevelInner gl_TessLevelOuter gl_VertexID gl_ViewIndex gl_ViewportIndex
gl_WorkGroupID gl_WorkGroupSize
gl_MaxComputeWorkGroupCount gl_MaxComputeWorkGroupSize gl_MaxComputeUniformComponents
+1
View File
@@ -693,6 +693,7 @@ rdcstr DoStringise(const ShaderBuiltin &el)
STRINGISE_ENUM_CLASS_NAMED(Barycentrics, "Barycentrics");
STRINGISE_ENUM_CLASS_NAMED(CullPrimitive, "Cull Primitive Output");
STRINGISE_ENUM_CLASS_NAMED(OutputIndices, "Output Indices");
STRINGISE_ENUM_CLASS_NAMED(MultiViewIndex, "Multiview Index");
}
END_ENUM_STRINGISE();
}
+6
View File
@@ -1109,6 +1109,11 @@ to apply to multiple related things - see :data:`ClipDistance`, :data:`CullDista
.. data:: OutputIndices
An output containing the indices for a meshlet.
.. data:: MultiViewIndex
An input specifying the view being rendered to in multiview rendering. Only valid when multiview rendering is enabled.
)");
enum class ShaderBuiltin : uint32_t
{
@@ -1166,6 +1171,7 @@ enum class ShaderBuiltin : uint32_t
Barycentrics,
CullPrimitive,
OutputIndices,
MultiViewIndex,
Count,
};
+2
View File
@@ -2278,6 +2278,8 @@ void MakeShaderReflection(GLenum shadType, GLuint sepProg, ShaderReflection &ref
sig.systemValue = ShaderBuiltin::GSInstanceIndex;
if(IS_BUILTIN("gl_Layer"))
sig.systemValue = ShaderBuiltin::RTIndex;
if(IS_BUILTIN("gl_ViewID_OVR"))
sig.systemValue = ShaderBuiltin::MultiViewIndex;
if(IS_BUILTIN("gl_ViewportIndex"))
sig.systemValue = ShaderBuiltin::ViewportIndex;
@@ -156,7 +156,7 @@ ShaderBuiltin MakeShaderBuiltin(ShaderStage stage, const rdcspv::BuiltIn el)
case rdcspv::BuiltIn::BaseVertex: return ShaderBuiltin::BaseVertex;
case rdcspv::BuiltIn::BaseInstance: return ShaderBuiltin::BaseInstance;
case rdcspv::BuiltIn::DrawIndex: return ShaderBuiltin::DrawIndex;
case rdcspv::BuiltIn::ViewIndex: return ShaderBuiltin::ViewportIndex;
case rdcspv::BuiltIn::ViewIndex: return ShaderBuiltin::MultiViewIndex;
case rdcspv::BuiltIn::FragStencilRefEXT: return ShaderBuiltin::StencilReference;
case rdcspv::BuiltIn::NumWorkgroups: return ShaderBuiltin::DispatchSize;
case rdcspv::BuiltIn::GlobalInvocationId: return ShaderBuiltin::DispatchThreadIndex;
+4
View File
@@ -1123,6 +1123,10 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl,
{
valueID = instIndexID;
}
else if(builtin == ShaderBuiltin::MultiViewIndex)
{
valueID = viewID;
}
else if(builtin == ShaderBuiltin::ViewportIndex)
{
valueID = viewID;
@@ -791,7 +791,7 @@ void AnnotateShader(const ShaderReflection &refl, const SPIRVPatchData &patchDat
// invalid and we just set 0. Valid for both Vertex and Pixel shaders
if(editor.HasCapability(rdcspv::Capability::MultiView))
{
view = fetchOrAddGlobalInput("rdoc_viewIndex", ShaderBuiltin::ViewportIndex,
view = fetchOrAddGlobalInput("rdoc_viewIndex", ShaderBuiltin::MultiViewIndex,
rdcspv::BuiltIn::ViewIndex, uint32Type, true);
}
else
@@ -888,7 +888,7 @@ void AnnotateShader(const ShaderReflection &refl, const SPIRVPatchData &patchDat
// invalid and we just set 0. Valid for both Vertex and Pixel shaders
if(editor.HasCapability(rdcspv::Capability::MultiView))
{
view = fetchOrAddGlobalInput("rdoc_viewIndex", ShaderBuiltin::ViewportIndex,
view = fetchOrAddGlobalInput("rdoc_viewIndex", ShaderBuiltin::MultiViewIndex,
rdcspv::BuiltIn::ViewIndex, uint32Type, true);
}
else
@@ -4013,6 +4013,7 @@ ShaderDebugTrace *VulkanReplay::DebugVertex(uint32_t eventId, uint32_t vertid, u
builtins[ShaderBuiltin::VertexIndex] = ShaderVariable(rdcstr(), vertid + vertOffset, 0U, 0U, 0U);
builtins[ShaderBuiltin::InstanceIndex] = ShaderVariable(rdcstr(), instid + instOffset, 0U, 0U, 0U);
builtins[ShaderBuiltin::ViewportIndex] = ShaderVariable(rdcstr(), view, 0U, 0U, 0U);
builtins[ShaderBuiltin::MultiViewIndex] = ShaderVariable(rdcstr(), view, 0U, 0U, 0U);
rdcarray<ShaderVariable> &locations = apiWrapper->location_inputs;
for(const VkVertexInputAttributeDescription2EXT &attr : state.vertexAttributes)