Skip to content

Commit

Permalink
Fix fetching array outputs from vertex shaders
Browse files Browse the repository at this point in the history
* This broke when fixing array outputs from tessellation/geometry shaders!
  • Loading branch information
baldurk committed Apr 26, 2019
1 parent c0603bb commit 2498f7f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions renderdoc/driver/shaders/spirv/spirv_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ struct SPIRVPatchData

// is this input/output part of a matrix
bool isMatrix = false;

// this is an element of an array that's been exploded after [0].
// i.e. this is false for non-arrays, and false for element [0] in an array, then true for
// elements [1], [2], [3], etc..
bool isArraySubsequentElement = false;
};

// matches the input/output signature array, with details of where to fetch the output from in the
Expand Down
5 changes: 4 additions & 1 deletion renderdoc/driver/shaders/spirv/spirv_disassemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4104,7 +4104,10 @@ void AddSignatureParameter(bool isInput, ShaderStage stage, uint32_t id, uint32_

sig.regIndex += RDCMAX(1U, type->matrixSize);
if(isArray)
patch.ID = patch.structID = 0;
{
patch.accessChain.back()++;
patch.isArraySubsequentElement = true;
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions renderdoc/driver/vulkan/vk_postvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,11 @@ static void AddXFBAnnotations(const ShaderReflection &refl, const SPIRVPatchData

for(size_t i = 0; i < outsig.size(); i++)
{
if(outpatch[i].structID && !outpatch[i].accessChain.empty())
if(outpatch[i].isArraySubsequentElement)
{
// do not patch anything as we only patch the base array, but reserve space in the stride
}
else if(outpatch[i].structID && !outpatch[i].accessChain.empty())
{
editor.AddDecoration(SPIRVOperation(
spv::OpMemberDecorate,
Expand All @@ -1265,7 +1269,8 @@ static void AddXFBAnnotations(const ShaderReflection &refl, const SPIRVPatchData

for(size_t i = 0; i < outpatch.size(); i++)
{
if(outpatch[i].ID && vars.find(outpatch[i].ID) == vars.end())
if(outpatch[i].ID && !outpatch[i].isArraySubsequentElement &&
vars.find(outpatch[i].ID) == vars.end())
{
editor.AddDecoration(
SPIRVOperation(spv::OpDecorate, {outpatch[i].ID, (uint32_t)spv::DecorationXfbBuffer, 0}));
Expand Down

0 comments on commit 2498f7f

Please sign in to comment.