diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index fefab1b75..4306a6d4e 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -165,7 +165,14 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV { editor.Remove(it); } - else if(decorate.decoration == rdcspv::Decoration::Location) + // same with flat/noperspective + else if(decorate.decoration == rdcspv::Decoration::Flat || + decorate.decoration == rdcspv::Decoration::NoPerspective) + { + editor.Remove(it); + } + else if(decorate.decoration == rdcspv::Decoration::Location || + decorate.decoration == rdcspv::Decoration::Component) { // we don't have to do anything, the ID mapping is in the rdcspv::PatchData, so just discard // the location information @@ -1025,6 +1032,8 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV rdcspv::Id result = ops.add(rdcspv::OpImageFetch(ins[i].vec4ID, editor.MakeId(), rawimg, idx)); + uint32_t comp = Bits::CountTrailingZeroes(uint32_t(refl.inputSignature[i].regChannelMask)); + if(refl.inputSignature[i].compType == CompType::Double) { // since doubles are packed into two uints, we now need to fetch more data and do @@ -1081,8 +1090,8 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV // for one component, extract x // baseType value = result.x; - result = - ops.add(rdcspv::OpCompositeExtract(ins[i].basetypeID, editor.MakeId(), result, {0})); + result = ops.add( + rdcspv::OpCompositeExtract(ins[i].basetypeID, editor.MakeId(), result, {comp})); } else if(refl.inputSignature[i].compCount != 4) { @@ -1091,7 +1100,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV rdcarray swizzle; for(uint32_t c = 0; c < refl.inputSignature[i].compCount; c++) - swizzle.push_back(c); + swizzle.push_back(c + comp); // baseTypeN value = result.xyz; result = ops.add(rdcspv::OpVectorShuffle(ins[i].basetypeID, editor.MakeId(), result, diff --git a/util/test/demos/vk/vk_vertex_attr_zoo.cpp b/util/test/demos/vk/vk_vertex_attr_zoo.cpp index c31921c64..48d830c6b 100644 --- a/util/test/demos/vk/vk_vertex_attr_zoo.cpp +++ b/util/test/demos/vk/vk_vertex_attr_zoo.cpp @@ -48,7 +48,9 @@ RD_TEST(VK_Vertex_Attr_Zoo, VulkanGraphicsTest) layout(location = 0) in vec4 InSNorm; layout(location = 1) in vec4 InUNorm; layout(location = 2) in vec4 InUScaled; -layout(location = 3) in uvec4 InUInt; +layout(location = 3) in uvec2 InUInt; +layout(location = 3, component = 2) in uint InUInt1; +layout(location = 3, component = 3) in uint InUInt2; layout(location = 4) in dvec2 InDouble; layout(location = 5) in vec2 InArray[2]; layout(location = 7) in mat2x2 InMatrix; @@ -56,7 +58,9 @@ layout(location = 7) in mat2x2 InMatrix; layout(location = 0) out vec4 OutSNorm; layout(location = 1) out vec4 OutUNorm; layout(location = 2) out vec4 OutUScaled; -layout(location = 3) out uvec4 OutUInt; +layout(location = 3) flat out uvec2 OutUInt; +layout(location = 3, component = 2) flat out uint OutUInt1; +layout(location = 3, component = 3) flat out uint OutUInt2; layout(location = 4) out dvec2 OutDouble; layout(location = 5) out vec2 OutArray[2]; layout(location = 7) out mat2x2 OutMatrix; @@ -72,6 +76,8 @@ void main() OutUScaled = InUScaled; OutDouble = InDouble; OutUInt = InUInt; + OutUInt1 = InUInt1; + OutUInt2 = InUInt2; OutUNorm = InUNorm; OutArray = InArray; OutMatrix = InMatrix; @@ -85,7 +91,9 @@ void main() layout(location = 0) in vec4 InSNorm; layout(location = 1) in vec4 InUNorm; layout(location = 2) in vec4 InUScaled; -layout(location = 3) flat in uvec4 InUInt; +layout(location = 3) flat in uvec2 InUInt; +layout(location = 3, component = 2) flat in uint InUInt1; +layout(location = 3, component = 3) flat in uint InUInt2; layout(location = 4) flat in dvec2 InDouble; layout(location = 5) in vec2 InArray[2]; layout(location = 7) in mat2x2 InMatrix; @@ -111,7 +119,7 @@ void main() Color = vec4(0.3f, 0, 0, 1); // Similar for UInt - if(InUInt.x > 65535 || InUInt.y > 65535 || InUInt.z > 65535 || InUInt.w > 65535) + if(InUInt.x > 65535 || InUInt.y > 65535 || InUInt1.x > 65535 || InUInt2.x > 65535) Color = vec4(0.4f, 0, 0, 1); // doubles are all in range [-10, 10] @@ -130,7 +138,9 @@ layout(triangle_strip, max_vertices = 3) out; layout(location = 0) in vec4 InSNorm[3]; layout(location = 1) in vec4 InUNorm[3]; layout(location = 2) in vec4 InUScaled[3]; -layout(location = 3) in uvec4 InUInt[3]; +layout(location = 3) flat in uvec2 InUInt[3]; +layout(location = 3, component = 2) flat in uint InUInt1[3]; +layout(location = 3, component = 3) flat in uint InUInt2[3]; layout(location = 4) in dvec2 InDouble[3]; layout(location = 5) in vec2 InArray[3][2]; layout(location = 7) in mat2x2 InMatrix[3]; @@ -138,7 +148,9 @@ layout(location = 7) in mat2x2 InMatrix[3]; layout(location = 0) out vec4 OutSNorm; layout(location = 1) out vec4 OutUNorm; layout(location = 2) out vec4 OutUScaled; -layout(location = 3) out uvec4 OutUInt; +layout(location = 3) flat out uvec2 OutUInt; +layout(location = 3, component = 2) flat out uint OutUInt1; +layout(location = 3, component = 3) flat out uint OutUInt2; layout(location = 4) out dvec2 OutDouble; layout(location = 5) out vec2 OutArray[2]; layout(location = 7) out mat2x2 OutMatrix; @@ -153,6 +165,8 @@ void main() OutUScaled = InUScaled[i]; OutDouble = InDouble[i]; OutUInt = InUInt[i]; + OutUInt1 = InUInt1[i]; + OutUInt2 = InUInt2[i]; OutUNorm = InUNorm[i]; OutArray = InArray[i]; OutMatrix = InMatrix[i]; diff --git a/util/test/tests/Vulkan/VK_Vertex_Attr_Zoo.py b/util/test/tests/Vulkan/VK_Vertex_Attr_Zoo.py index 618477227..e37959b79 100644 --- a/util/test/tests/Vulkan/VK_Vertex_Attr_Zoo.py +++ b/util/test/tests/Vulkan/VK_Vertex_Attr_Zoo.py @@ -18,7 +18,9 @@ class VK_Vertex_Attr_Zoo(rdtest.TestCase): 'SNorm': [1.0, -1.0, 1.0, -1.0], 'UNorm': [12345.0/65535.0, 6789.0/65535.0, 1234.0/65535.0, 567.0/65535.0], 'UScaled': [12345.0, 6789.0, 1234.0, 567.0], - 'UInt': [12345, 6789, 1234, 567], + 'UInt': [12345, 6789], + 'UInt1': [1234], + 'UInt2': [567], 'Double': [9.8765432109, -5.6789012345], 'Array[0]': [1.0, 2.0], 'Array[1]': [3.0, 4.0], @@ -29,7 +31,9 @@ class VK_Vertex_Attr_Zoo(rdtest.TestCase): 'SNorm': [32766.0/32767.0, -32766.0/32767.0, 16000.0/32767.0, -16000.0/32767.0], 'UNorm': [56.0/65535.0, 7890.0/65535.0, 123.0/65535.0, 4567.0/65535.0], 'UScaled': [56.0, 7890.0, 123.0, 4567.0], - 'UInt': [56, 7890, 123, 4567], + 'UInt': [56, 7890], + 'UInt1': [123], + 'UInt2': [4567], 'Double': [-7.89012345678, 6.54321098765], 'Array[0]': [11.0, 12.0], 'Array[1]': [13.0, 14.0], @@ -40,7 +44,9 @@ class VK_Vertex_Attr_Zoo(rdtest.TestCase): 'SNorm': [5.0/32767.0, -5.0/32767.0, 0.0, 0.0], 'UNorm': [8765.0/65535.0, 43210.0/65535.0, 987.0/65535.0, 65432.0/65535.0], 'UScaled': [8765.0, 43210.0, 987.0, 65432.0], - 'UInt': [8765, 43210, 987, 65432], + 'UInt': [8765, 43210], + 'UInt1': [987], + 'UInt2': [65432], 'Double': [0.1234567890123, 4.5678901234], 'Array[0]': [21.0, 22.0], 'Array[1]': [23.0, 24.0], @@ -54,8 +60,12 @@ class VK_Vertex_Attr_Zoo(rdtest.TestCase): for idx in ref: in_ref[idx] = {} for key in ref[idx]: + if 'UInt' in key: + continue in_ref[idx]['In' + key] = ref[idx][key] + in_ref[idx]['InUInt2'] = ref[idx]['UInt'] + ref[idx]['UInt1'] + ref[idx]['UInt2'] + # Copy the ref values and prepend 'Out' out_ref = {} for idx in ref: