Skip to content

Commit

Permalink
Add ShaderBuiltin::MultiViewIndex
Browse files Browse the repository at this point in the history
Mapped to:
SPIR-V ViewIndex (which was previously mapped to ShaderBuiltin::ViewportIndex)
GL gl_ViewIndex
  • Loading branch information
Zorro666 committed Feb 14, 2024
1 parent 045a710 commit 226bf70
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions qrenderdoc/Code/QRDUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion qrenderdoc/Code/ScintillaSyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions renderdoc/api/replay/renderdoc_tostr.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 6 additions & 0 deletions renderdoc/api/replay/replay_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -1166,6 +1171,7 @@ enum class ShaderBuiltin : uint32_t
Barycentrics,
CullPrimitive,
OutputIndices,
MultiViewIndex,
Count,
};

Expand Down
2 changes: 2 additions & 0 deletions renderdoc/driver/gl/gl_shader_refl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion renderdoc/driver/shaders/spirv/spirv_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions renderdoc/driver/vulkan/vk_postvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions renderdoc/driver/vulkan/vk_shader_feedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions renderdoc/driver/vulkan/vk_shaderdebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 226bf70

Please sign in to comment.