Skip to content

Commit

Permalink
Fix some test failures by consistently stripping gl_PerVertex_Var prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
baldurk committed Nov 17, 2023
1 parent 48222bf commit 0d9ea80
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 80 deletions.
2 changes: 2 additions & 0 deletions renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,8 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s
sourceVar.columns = var.columns;
sourceVar.signatureIndex = sigNames.indexOf(debugVarName);

StripCommonGLPrefixes(sourceVar.name);

for(uint32_t x = 0; x < uint32_t(var.rows) * var.columns; x++)
sourceVar.variables.push_back(DebugVariableReference(
isInput ? DebugVariableType::Input : DebugVariableType::Variable, debugVarName, x));
Expand Down
34 changes: 19 additions & 15 deletions renderdoc/driver/shaders/spirv/spirv_reflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@
#include "spirv_editor.h"
#include "spirv_op_helpers.h"

void StripCommonGLPrefixes(rdcstr &name)
{
// remove certain common prefixes that generate only useless noise from GLSL. This is mostly
// irrelevant for the majority of cases but is primarily relevant for single-component outputs
// like gl_PointSize or gl_CullPrimitiveEXT
const rdcstr prefixesToRemove[] = {
"gl_PerVertex.", "gl_PerVertex_var.", "gl_MeshVerticesEXT.",
"gl_MeshVerticesEXT_var.", "gl_MeshPrimitivesEXT.", "gl_MeshPrimitivesEXT_var.",
};

for(const rdcstr &prefix : prefixesToRemove)
{
int offs = name.find(prefix);
if(offs == 0)
name.erase(0, prefix.length());
}
}

void FillSpecConstantVariables(ResourceId shader, const SPIRVPatchData &patchData,
const rdcarray<ShaderConstant> &invars,
rdcarray<ShaderVariable> &outvars,
Expand Down Expand Up @@ -2210,21 +2228,7 @@ void Reflector::AddSignatureParameter(const bool isInput, const ShaderStage stag

if(isArray)
n += StringFormat::Fmt("[%u]", a);

// remove certain common prefixes that generate only useless noise from GLSL. This is mostly
// irrelevant for the majority of cases but is primarily relevant for single-component outputs
// like gl_PointSize or gl_CullPrimitiveEXT
const rdcstr prefixesToRemove[] = {
"gl_PerVertex.", "gl_PerVertex_var.", "gl_MeshVerticesEXT.",
"gl_MeshVerticesEXT_var.", "gl_MeshPrimitivesEXT.", "gl_MeshPrimitivesEXT_var.",
};

for(const rdcstr &prefix : prefixesToRemove)
{
int offs = n.find(prefix);
if(offs == 0)
n.erase(0, prefix.length());
}
StripCommonGLPrefixes(n);

sig.varName = n;

Expand Down
2 changes: 2 additions & 0 deletions renderdoc/driver/shaders/spirv/spirv_reflect.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class Reflector : public Processor

}; // namespace rdcspv

void StripCommonGLPrefixes(rdcstr &name);

void FillSpecConstantVariables(ResourceId shader, const SPIRVPatchData &patchData,
const rdcarray<ShaderConstant> &invars,
rdcarray<ShaderVariable> &outvars,
Expand Down
6 changes: 3 additions & 3 deletions util/test/tests/Vulkan/VK_Dedicated_Allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ def check_capture(self):
0: {
'vtx': 0,
'idx': 0,
'gl_PerVertex_var.gl_Position': [-0.5, 0.5, 0.0, 1.0],
'gl_Position': [-0.5, 0.5, 0.0, 1.0],
'vertOut.pos': [-0.5, 0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 0.0, 0.0, 1.0],
},
1: {
'vtx': 1,
'idx': 1,
'gl_PerVertex_var.gl_Position': [0.0, -0.5, 0.0, 1.0],
'gl_Position': [0.0, -0.5, 0.0, 1.0],
'vertOut.pos': [0.0, -0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 1.0, 0.0, 1.0],
},
2: {
'vtx': 2,
'idx': 2,
'gl_PerVertex_var.gl_Position': [0.5, 0.5, 0.0, 1.0],
'gl_Position': [0.5, 0.5, 0.0, 1.0],
'vertOut.pos': [0.5, 0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [1.0, 0.0, 0.0, 1.0],
Expand Down
6 changes: 3 additions & 3 deletions util/test/tests/Vulkan/VK_Dynamic_Rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ def check_capture(self):
0: {
'vtx': 0,
'idx': 0,
'gl_PerVertex_var.gl_Position': [-0.5, 0.5, 0.0, 1.0],
'gl_Position': [-0.5, 0.5, 0.0, 1.0],
'gout.pos': [-0.5, 0.5, 0.0, 1.0],
'gout.col': [0.0, 1.0, 0.0, 1.0],
'gout.uv': [0.0, 0.0, 0.0, 1.0],
},
1: {
'vtx': 1,
'idx': 1,
'gl_PerVertex_var.gl_Position': [0.0, -0.5, 0.0, 1.0],
'gl_Position': [0.0, -0.5, 0.0, 1.0],
'gout.pos': [0.0, -0.5, 0.0, 1.0],
'gout.col': [0.0, 1.0, 0.0, 1.0],
'gout.uv': [0.0, 1.0, 0.0, 1.0],
},
2: {
'vtx': 2,
'idx': 2,
'gl_PerVertex_var.gl_Position': [0.5, 0.5, 0.0, 1.0],
'gl_Position': [0.5, 0.5, 0.0, 1.0],
'gout.pos': [0.5, 0.5, 0.0, 1.0],
'gout.col': [0.0, 1.0, 0.0, 1.0],
'gout.uv': [1.0, 0.0, 0.0, 1.0],
Expand Down
8 changes: 4 additions & 4 deletions util/test/tests/Vulkan/VK_Extended_Dynamic_State.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@ def check_capture(self):
0: {
'vtx': 0,
'idx': 0,
'gl_PerVertex_var.gl_Position': [-0.75, 0.5, 0.4, 1.0],
'gl_Position': [-0.75, 0.5, 0.4, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 0.0, 0.0, 1.0],
},
1: {
'vtx': 1,
'idx': 1,
'gl_PerVertex_var.gl_Position': [-0.25, -0.5, 0.4, 1.0],
'gl_Position': [-0.25, -0.5, 0.4, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 1.0, 0.0, 1.0],
},
2: {
'vtx': 2,
'idx': 2,
'gl_PerVertex_var.gl_Position': [0.25, 0.5, 0.4, 1.0],
'gl_Position': [0.25, 0.5, 0.4, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [1.0, 0.0, 0.0, 1.0],
},
5: {
'vtx': 5,
'idx': 5,
'gl_PerVertex_var.gl_Position': [0.75, 0.5, 0.6, 1.0],
'gl_Position': [0.75, 0.5, 0.6, 1.0],
'vertOut.col': [0.0, 0.0, 1.0, 1.0],
'vertOut.uv': [1.0, 0.0, 0.0, 1.0],
},
Expand Down
6 changes: 3 additions & 3 deletions util/test/tests/Vulkan/VK_Frame0.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ def check_capture(self):
0: {
'vtx': 0,
'idx': 0,
'gl_PerVertex_var.gl_Position': [-0.5, 0.5, 0.0, 1.0],
'gl_Position': [-0.5, 0.5, 0.0, 1.0],
'vertOut.pos': [-0.5, 0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 0.0, 0.0, 1.0],
},
1: {
'vtx': 1,
'idx': 1,
'gl_PerVertex_var.gl_Position': [0.0, -0.5, 0.0, 1.0],
'gl_Position': [0.0, -0.5, 0.0, 1.0],
'vertOut.pos': [0.0, -0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 1.0, 0.0, 1.0],
},
2: {
'vtx': 2,
'idx': 2,
'gl_PerVertex_var.gl_Position': [0.5, 0.5, 0.0, 1.0],
'gl_Position': [0.5, 0.5, 0.0, 1.0],
'vertOut.pos': [0.5, 0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [1.0, 0.0, 0.0, 1.0],
Expand Down
6 changes: 3 additions & 3 deletions util/test/tests/Vulkan/VK_Graphics_Pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ def check_capture(self):
0: {
'vtx': 0,
'idx': 0,
'gl_PerVertex_var.gl_Position': [-0.5, 0.5, 0.0, 1.0],
'gl_Position': [-0.5, 0.5, 0.0, 1.0],
'vertOut.pos': [-0.5, 0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 0.0, 0.0, 1.0],
},
1: {
'vtx': 1,
'idx': 1,
'gl_PerVertex_var.gl_Position': [0.0, -0.5, 0.0, 1.0],
'gl_Position': [0.0, -0.5, 0.0, 1.0],
'vertOut.pos': [0.0, -0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 1.0, 0.0, 1.0],
},
2: {
'vtx': 2,
'idx': 2,
'gl_PerVertex_var.gl_Position': [0.5, 0.5, 0.0, 1.0],
'gl_Position': [0.5, 0.5, 0.0, 1.0],
'vertOut.pos': [0.5, 0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [1.0, 0.0, 0.0, 1.0],
Expand Down
48 changes: 24 additions & 24 deletions util/test/tests/Vulkan/VK_Indirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ def check_capture(self):
postvs_data = self.get_postvs(action, rd.MeshDataStage.VSOut)

postvs_ref = {
0: {'vtx': 0, 'idx': 0, 'gl_PerVertex_var.gl_Position': [-0.8, -0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 1, 'gl_PerVertex_var.gl_Position': [-0.7, -0.8, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 2, 'gl_PerVertex_var.gl_Position': [-0.6, -0.5, 0.0, 1.0]},
0: {'vtx': 0, 'idx': 0, 'gl_Position': [-0.8, -0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 1, 'gl_Position': [-0.7, -0.8, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 2, 'gl_Position': [-0.6, -0.5, 0.0, 1.0]},
}

self.check_mesh_data(postvs_ref, postvs_data)
Expand All @@ -246,9 +246,9 @@ def check_capture(self):
# These indices are the *output* indices, which have been rebased/remapped, so are not the same as the input
# indices
postvs_ref = {
0: {'vtx': 0, 'idx': 6, 'gl_PerVertex_var.gl_Position': [-0.6, -0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 7, 'gl_PerVertex_var.gl_Position': [-0.5, -0.8, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 8, 'gl_PerVertex_var.gl_Position': [-0.4, -0.5, 0.0, 1.0]},
0: {'vtx': 0, 'idx': 6, 'gl_Position': [-0.6, -0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 7, 'gl_Position': [-0.5, -0.8, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 8, 'gl_Position': [-0.4, -0.5, 0.0, 1.0]},
}

self.check_mesh_data(postvs_ref, postvs_data)
Expand All @@ -269,13 +269,13 @@ def check_capture(self):
postvs_data = self.get_postvs(action, rd.MeshDataStage.VSOut)

postvs_ref = {
0: {'vtx': 0, 'idx': 9, 'gl_PerVertex_var.gl_Position': [-0.4, -0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 10, 'gl_PerVertex_var.gl_Position': [-0.3, -0.8, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 11, 'gl_PerVertex_var.gl_Position': [-0.2, -0.8, 0.0, 1.0]},
0: {'vtx': 0, 'idx': 9, 'gl_Position': [-0.4, -0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 10, 'gl_Position': [-0.3, -0.8, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 11, 'gl_Position': [-0.2, -0.8, 0.0, 1.0]},

3: {'vtx': 3, 'idx': 12, 'gl_PerVertex_var.gl_Position': [-0.1, -0.5, 0.0, 1.0]},
4: {'vtx': 4, 'idx': 13, 'gl_PerVertex_var.gl_Position': [ 0.0, -0.8, 0.0, 1.0]},
5: {'vtx': 5, 'idx': 14, 'gl_PerVertex_var.gl_Position': [ 0.1, -0.8, 0.0, 1.0]},
3: {'vtx': 3, 'idx': 12, 'gl_Position': [-0.1, -0.5, 0.0, 1.0]},
4: {'vtx': 4, 'idx': 13, 'gl_Position': [ 0.0, -0.8, 0.0, 1.0]},
5: {'vtx': 5, 'idx': 14, 'gl_Position': [ 0.1, -0.8, 0.0, 1.0]},
}

self.check_mesh_data(postvs_ref, postvs_data)
Expand Down Expand Up @@ -327,9 +327,9 @@ def check_capture(self):
# These indices are the *output* indices, which have been rebased/remapped, so are not the same as the input
# indices
postvs_ref = {
0: {'vtx': 0, 'idx': 0, 'gl_PerVertex_var.gl_Position': [-0.8, 0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 1, 'gl_PerVertex_var.gl_Position': [-0.7, 0.2, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 2, 'gl_PerVertex_var.gl_Position': [-0.6, 0.5, 0.0, 1.0]},
0: {'vtx': 0, 'idx': 0, 'gl_Position': [-0.8, 0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 1, 'gl_Position': [-0.7, 0.2, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 2, 'gl_Position': [-0.6, 0.5, 0.0, 1.0]},
}

self.check_mesh_data(postvs_ref, postvs_data)
Expand Down Expand Up @@ -357,9 +357,9 @@ def check_capture(self):
# These indices are the *output* indices, which have been rebased/remapped, so are not the same as the input
# indices
postvs_ref = {
0: {'vtx': 0, 'idx': 15, 'gl_PerVertex_var.gl_Position': [-0.6, 0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 16, 'gl_PerVertex_var.gl_Position': [-0.5, 0.2, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 17, 'gl_PerVertex_var.gl_Position': [-0.4, 0.5, 0.0, 1.0]},
0: {'vtx': 0, 'idx': 15, 'gl_Position': [-0.6, 0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 16, 'gl_Position': [-0.5, 0.2, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 17, 'gl_Position': [-0.4, 0.5, 0.0, 1.0]},
}

self.check_mesh_data(postvs_ref, postvs_data)
Expand Down Expand Up @@ -397,13 +397,13 @@ def check_capture(self):
# These indices are the *output* indices, which have been rebased/remapped, so are not the same as the input
# indices
postvs_ref = {
0: {'vtx': 0, 'idx': 18, 'gl_PerVertex_var.gl_Position': [-0.4, 0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 19, 'gl_PerVertex_var.gl_Position': [-0.3, 0.2, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 20, 'gl_PerVertex_var.gl_Position': [-0.2, 0.2, 0.0, 1.0]},
0: {'vtx': 0, 'idx': 18, 'gl_Position': [-0.4, 0.5, 0.0, 1.0]},
1: {'vtx': 1, 'idx': 19, 'gl_Position': [-0.3, 0.2, 0.0, 1.0]},
2: {'vtx': 2, 'idx': 20, 'gl_Position': [-0.2, 0.2, 0.0, 1.0]},

3: {'vtx': 3, 'idx': 21, 'gl_PerVertex_var.gl_Position': [-0.1, 0.5, 0.0, 1.0]},
4: {'vtx': 4, 'idx': 22, 'gl_PerVertex_var.gl_Position': [ 0.0, 0.2, 0.0, 1.0]},
5: {'vtx': 5, 'idx': 23, 'gl_PerVertex_var.gl_Position': [ 0.1, 0.2, 0.0, 1.0]},
3: {'vtx': 3, 'idx': 21, 'gl_Position': [-0.1, 0.5, 0.0, 1.0]},
4: {'vtx': 4, 'idx': 22, 'gl_Position': [ 0.0, 0.2, 0.0, 1.0]},
5: {'vtx': 5, 'idx': 23, 'gl_Position': [ 0.1, 0.2, 0.0, 1.0]},
}

self.check_mesh_data(postvs_ref, postvs_data)
Expand Down
6 changes: 3 additions & 3 deletions util/test/tests/Vulkan/VK_Int8_IBuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def check_capture(self):
0: {
'vtx': 0,
'idx': 0,
'gl_PerVertex_var.gl_Position': [-0.8, -0.2, 0.0, 1.0],
'gl_Position': [-0.8, -0.2, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 0.0, 0.0, 1.0],
},
4: {
'vtx': 4,
'idx': 4,
'gl_PerVertex_var.gl_Position': [0.0, -0.2, 0.0, 1.0],
'gl_Position': [0.0, -0.2, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 0.0, 0.0, 1.0],
},
Expand All @@ -43,7 +43,7 @@ def check_capture(self):
9: {
'vtx': 9,
'idx': 8,
'gl_PerVertex_var.gl_Position': [-0.8, 0.7, 0.0, 1.0],
'gl_Position': [-0.8, 0.7, 0.0, 1.0],
'vertOut.col': [0.0, 0.0, 1.0, 1.0],
'vertOut.uv': [0.0, 0.0, 0.0, 1.0],
},
Expand Down
6 changes: 3 additions & 3 deletions util/test/tests/Vulkan/VK_Large_Buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ def check_capture(self):
0: {
'vtx': 0,
'idx': 0,
'gl_PerVertex_var.gl_Position': [-0.5, 0.5, 0.0, 1.0],
'gl_Position': [-0.5, 0.5, 0.0, 1.0],
'vertOut.pos': [-0.5, 0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 0.0, 0.0, 1.0],
},
1: {
'vtx': 1,
'idx': 1000000,
'gl_PerVertex_var.gl_Position': [0.0, -0.5, 0.0, 1.0],
'gl_Position': [0.0, -0.5, 0.0, 1.0],
'vertOut.pos': [0.0, -0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [0.0, 1.0, 0.0, 1.0],
},
2: {
'vtx': 2,
'idx': 2345678,
'gl_PerVertex_var.gl_Position': [0.5, 0.5, 0.0, 1.0],
'gl_Position': [0.5, 0.5, 0.0, 1.0],
'vertOut.pos': [0.5, 0.5, 0.0, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
'vertOut.uv': [1.0, 0.0, 0.0, 1.0],
Expand Down
8 changes: 4 additions & 4 deletions util/test/tests/Vulkan/VK_Mesh_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ def check_capture(self):
0: {
'vtx': 0,
'idx': 0,
'gl_PerVertex_var.gl_Position': [0.8, 0.8, 0.0, 1.0],
'gl_Position': [0.8, 0.8, 0.0, 1.0],
'uv1': [0.5, 0.5],
},
1: {
'vtx': 1,
'idx': 1,
'gl_PerVertex_var.gl_Position': [0.8, 0.9, 0.0, 1.0],
'gl_Position': [0.8, 0.9, 0.0, 1.0],
'uv1': [0.6, 0.6],
},
2: {
'vtx': 2,
'idx': 2,
'gl_PerVertex_var.gl_Position': [0.9, 0.8, 0.0, 1.0],
'gl_Position': [0.9, 0.8, 0.0, 1.0],
'uv1': [0.7, 0.7],
},
3: {
'vtx': 3,
'idx': 3,
'gl_PerVertex_var.gl_Position': [0.9, 0.9, 0.0, 1.0],
'gl_Position': [0.9, 0.9, 0.0, 1.0],
'uv1': [0.8, 0.8],
},
}
Expand Down
Loading

0 comments on commit 0d9ea80

Please sign in to comment.