mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Remove InvocationIndex shader builtin and remap it
* We map it to either GSInstanceIndex or OutputControlPointIndex
This commit is contained in:
@@ -269,7 +269,6 @@ struct ToStr
|
||||
case ShaderBuiltin::VertexIndex: return "Vertex Index";
|
||||
case ShaderBuiltin::PrimitiveIndex: return "Primitive Index";
|
||||
case ShaderBuiltin::InstanceIndex: return "Instance Index";
|
||||
case ShaderBuiltin::InvocationIndex: return "Invocation Index";
|
||||
case ShaderBuiltin::DispatchSize: return "Dispatch Size";
|
||||
case ShaderBuiltin::DispatchThreadIndex: return "Dispatch Thread Index";
|
||||
case ShaderBuiltin::GroupIndex: return "Group Index";
|
||||
|
||||
@@ -259,7 +259,6 @@ enum class ShaderBuiltin : uint32_t
|
||||
VertexIndex,
|
||||
PrimitiveIndex,
|
||||
InstanceIndex,
|
||||
InvocationIndex,
|
||||
DispatchSize,
|
||||
DispatchThreadIndex,
|
||||
GroupIndex,
|
||||
|
||||
@@ -71,7 +71,6 @@ string ToStrHelper<false, ShaderBuiltin>::Get(const ShaderBuiltin &el)
|
||||
TOSTR_CASE_STRINGIZE_SCOPED(ShaderBuiltin, VertexIndex)
|
||||
TOSTR_CASE_STRINGIZE_SCOPED(ShaderBuiltin, PrimitiveIndex)
|
||||
TOSTR_CASE_STRINGIZE_SCOPED(ShaderBuiltin, InstanceIndex)
|
||||
TOSTR_CASE_STRINGIZE_SCOPED(ShaderBuiltin, InvocationIndex)
|
||||
TOSTR_CASE_STRINGIZE_SCOPED(ShaderBuiltin, DispatchSize)
|
||||
TOSTR_CASE_STRINGIZE_SCOPED(ShaderBuiltin, DispatchThreadIndex)
|
||||
TOSTR_CASE_STRINGIZE_SCOPED(ShaderBuiltin, GroupIndex)
|
||||
|
||||
@@ -1845,7 +1845,7 @@ void MakeShaderReflection(const GLHookSet &gl, GLenum shadType, GLuint sepProg,
|
||||
if(IS_BUILTIN("gl_PrimitiveID"))
|
||||
sig.systemValue = ShaderBuiltin::PrimitiveIndex;
|
||||
if(IS_BUILTIN("gl_InvocationID"))
|
||||
sig.systemValue = ShaderBuiltin::InvocationIndex;
|
||||
sig.systemValue = ShaderBuiltin::OutputControlPointIndex;
|
||||
|
||||
// TCS built-in outputs
|
||||
if(IS_BUILTIN("gl_TessLevelOuter"))
|
||||
@@ -1864,8 +1864,8 @@ void MakeShaderReflection(const GLHookSet &gl, GLenum shadType, GLuint sepProg,
|
||||
// GS built-in inputs
|
||||
if(IS_BUILTIN("gl_PrimitiveIDIn"))
|
||||
sig.systemValue = ShaderBuiltin::PrimitiveIndex;
|
||||
if(IS_BUILTIN("gl_InvocationID"))
|
||||
sig.systemValue = ShaderBuiltin::InvocationIndex;
|
||||
if(IS_BUILTIN("gl_InvocationID") && shadType == eGL_GEOMETRY_SHADER)
|
||||
sig.systemValue = ShaderBuiltin::GSInstanceIndex;
|
||||
if(IS_BUILTIN("gl_Layer"))
|
||||
sig.systemValue = ShaderBuiltin::RTIndex;
|
||||
if(IS_BUILTIN("gl_ViewportIndex"))
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "3rdparty/glslang/SPIRV/spirv.hpp"
|
||||
#include "api/replay/replay_enums.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
@@ -49,6 +48,7 @@ void ShutdownSPIRVCompiler();
|
||||
|
||||
struct SPVInstruction;
|
||||
|
||||
enum class ShaderStage : uint32_t;
|
||||
struct ShaderReflection;
|
||||
struct ShaderBindpointMapping;
|
||||
|
||||
|
||||
@@ -3636,7 +3636,7 @@ uint32_t CalculateMinimumByteSize(const rdctype::array<ShaderConstant> &variable
|
||||
}
|
||||
}
|
||||
|
||||
ShaderBuiltin BuiltInToSystemAttribute(const spv::BuiltIn el)
|
||||
ShaderBuiltin BuiltInToSystemAttribute(ShaderStage stage, const spv::BuiltIn el)
|
||||
{
|
||||
// not complete, might need to expand system attribute list
|
||||
|
||||
@@ -3649,7 +3649,13 @@ ShaderBuiltin BuiltInToSystemAttribute(const spv::BuiltIn el)
|
||||
case spv::BuiltInVertexId: return ShaderBuiltin::VertexIndex;
|
||||
case spv::BuiltInInstanceId: return ShaderBuiltin::InstanceIndex;
|
||||
case spv::BuiltInPrimitiveId: return ShaderBuiltin::PrimitiveIndex;
|
||||
case spv::BuiltInInvocationId: return ShaderBuiltin::InvocationIndex;
|
||||
case spv::BuiltInInvocationId:
|
||||
{
|
||||
if(stage == ShaderStage::Geometry)
|
||||
return ShaderBuiltin::GSInstanceIndex;
|
||||
else
|
||||
return ShaderBuiltin::OutputControlPointIndex;
|
||||
}
|
||||
case spv::BuiltInLayer: return ShaderBuiltin::RTIndex;
|
||||
case spv::BuiltInViewportIndex: return ShaderBuiltin::ViewportIndex;
|
||||
case spv::BuiltInTessLevelOuter: return ShaderBuiltin::OuterTessFactor;
|
||||
@@ -3718,7 +3724,7 @@ void AddSignatureParameter(ShaderStage stage, uint32_t id, uint32_t childIdx, st
|
||||
if(decorations[d].decoration == spv::DecorationLocation)
|
||||
sig.regIndex = decorations[d].val;
|
||||
else if(decorations[d].decoration == spv::DecorationBuiltIn)
|
||||
sig.systemValue = BuiltInToSystemAttribute((spv::BuiltIn)decorations[d].val);
|
||||
sig.systemValue = BuiltInToSystemAttribute(stage, (spv::BuiltIn)decorations[d].val);
|
||||
else if(decorations[d].decoration == spv::DecorationRowMajor)
|
||||
rowmajor = true;
|
||||
else if(decorations[d].decoration == spv::DecorationColMajor)
|
||||
@@ -3998,7 +4004,7 @@ void SPVModule::MakeReflection(ShaderStage stage, const string &entryPoint,
|
||||
|
||||
if(eliminate)
|
||||
{
|
||||
ShaderBuiltin attr = BuiltInToSystemAttribute(checkBuiltin);
|
||||
ShaderBuiltin attr = BuiltInToSystemAttribute(stage, checkBuiltin);
|
||||
// find this builtin in the array, and remove
|
||||
for(auto it = sigarray->begin(); it != sigarray->end(); ++it)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user