mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-14 05:50:51 +00:00
Add test of descriptor buffer
This commit is contained in:
@@ -108,6 +108,7 @@ set(VULKAN_SRC
|
||||
vk/vk_counters.cpp
|
||||
vk/vk_custom_border_color.cpp
|
||||
vk/vk_dedicated_allocation.cpp
|
||||
vk/vk_descriptor_buffer.cpp
|
||||
vk/vk_descriptor_index.cpp
|
||||
vk/vk_descriptor_reuse.cpp
|
||||
vk/vk_descriptor_variable_count.cpp
|
||||
|
||||
@@ -312,6 +312,7 @@
|
||||
<ClCompile Include="test_common.cpp" />
|
||||
<ClCompile Include="texture_zoo.cpp" />
|
||||
<ClCompile Include="vk\vk_blend.cpp" />
|
||||
<ClCompile Include="vk\vk_descriptor_buffer.cpp" />
|
||||
<ClCompile Include="vk\vk_compute_only.cpp" />
|
||||
<ClCompile Include="vk\vk_counters.cpp" />
|
||||
<ClCompile Include="vk\vk_custom_border_color.cpp" />
|
||||
|
||||
@@ -712,6 +712,9 @@
|
||||
<ClCompile Include="d3d11\d3d11_groupshared.cpp">
|
||||
<Filter>D3D11\demos</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="vk\vk_descriptor_buffer.cpp">
|
||||
<Filter>Vulkan\demos</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="d3d12\d3d12_shader_debugdata_zoo.cpp">
|
||||
<Filter>D3D12\demos</Filter>
|
||||
</ClCompile>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1089,6 +1089,12 @@ void VulkanGraphicsTest::setName(VkFence obj, const std::string &name)
|
||||
setName(VK_OBJECT_TYPE_FENCE, (uint64_t)obj, name);
|
||||
}
|
||||
|
||||
template <>
|
||||
void VulkanGraphicsTest::setName(VkAccelerationStructureKHR obj, const std::string &name)
|
||||
{
|
||||
setName(VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR, (uint64_t)obj, name);
|
||||
}
|
||||
|
||||
void VulkanGraphicsTest::setName(VkObjectType objType, uint64_t obj, const std::string &name)
|
||||
{
|
||||
if(vkSetDebugUtilsObjectNameEXT)
|
||||
|
||||
@@ -861,7 +861,7 @@ class TestCase:
|
||||
trace = self.controller.DebugPixel(x, y, rd.DebugPixelInputs())
|
||||
if trace.debugger is None:
|
||||
self.controller.FreeTrace(trace)
|
||||
raise TestFailureException(f"Pixel shader could not be debugged.")
|
||||
raise TestFailureException(f"Pixel shader could not be debugged at {x},{y}.")
|
||||
|
||||
_, variables = self.process_trace(trace)
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
@@ -871,7 +871,7 @@ class TestCase:
|
||||
try:
|
||||
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, x, y, debugged.value.f32v[0:4])
|
||||
except TestFailureException as ex:
|
||||
raise TestFailureException(f"Pixel shader did not debug correctly. {ex}")
|
||||
raise TestFailureException(f"Pixel shader did not debug correctly at {x},{y}. {ex}")
|
||||
|
||||
log.success(f"Pixel shader debugging at {x},{y} was successful")
|
||||
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
import renderdoc as rd
|
||||
import struct
|
||||
import rdtest
|
||||
|
||||
|
||||
class VK_Descriptor_Buffer(rdtest.TestCase):
|
||||
demos_test_name = 'VK_Descriptor_Buffer'
|
||||
|
||||
def check_capture(self):
|
||||
eid = 0
|
||||
|
||||
stage = rd.ShaderStage.Pixel
|
||||
|
||||
for test in range(1000):
|
||||
draw = self.find_action(f"Test {test}", eid)
|
||||
|
||||
if draw is None:
|
||||
break
|
||||
|
||||
rdtest.log.begin_section(f"Test {test}")
|
||||
|
||||
eid = draw.eventId
|
||||
|
||||
self.controller.SetFrameEvent(draw.next.eventId, False)
|
||||
|
||||
pipe = self.controller.GetPipelineState()
|
||||
|
||||
v = pipe.GetViewport(0)
|
||||
|
||||
x = int(v.x) + int(v.width / 2)
|
||||
y = int(v.y) + int(v.height // 2)
|
||||
offset = int(v.height // 5)
|
||||
|
||||
refl = pipe.GetShaderReflection(stage)
|
||||
|
||||
if refl.debugInfo.debuggable:
|
||||
self.check_debug_pixel(x, y)
|
||||
self.check_debug_pixel(x, y+offset)
|
||||
self.check_debug_pixel(x, y-offset)
|
||||
else:
|
||||
rdtest.log.comment(f'Shader is not debuggable, not verifying')
|
||||
|
||||
cbs = pipe.GetConstantBlocks(stage, True)
|
||||
|
||||
out = pipe.GetOutputTargets()[0].resource
|
||||
|
||||
res_data = [
|
||||
(pipe.GetReadOnlyResources(stage, True), refl.readOnlyResources),
|
||||
(pipe.GetReadWriteResources(stage, True), refl.readWriteResources),
|
||||
]
|
||||
|
||||
for reslist,refllist in res_data:
|
||||
for res in reslist:
|
||||
expected_name = refllist[res.access.index].name
|
||||
|
||||
if refllist[res.access.index].bindArraySize > 1:
|
||||
if (res.access.arrayElement % 10) == 1:
|
||||
if res.descriptor.resource != rd.ResourceId():
|
||||
raise rdtest.TestFailureException(
|
||||
f"Expected no resource to be bound at {expected_name}[{res.access.arrayElement}")
|
||||
continue
|
||||
|
||||
expected_name = f'{expected_name}_{res.access.arrayElement}'
|
||||
|
||||
if res.descriptor.type == rd.DescriptorType.ImageSampler:
|
||||
sampname = self.get_resource(res.descriptor.secondary).name
|
||||
|
||||
resname = self.get_resource(res.descriptor.resource).name
|
||||
|
||||
expected_samp = f'{expected_name}_samp'
|
||||
expected_name = f'{expected_name}_tex'
|
||||
|
||||
if sampname != expected_samp:
|
||||
raise rdtest.TestFailureException(
|
||||
f"Expected resource {resname} to be named {expected_name}")
|
||||
else:
|
||||
resname = self.get_resource(res.descriptor.resource).name
|
||||
|
||||
if resname != expected_name:
|
||||
raise rdtest.TestFailureException(
|
||||
f"Expected resource {resname} to be named {expected_name}")
|
||||
|
||||
# we don't care about sampler/texture contents, it is enough that we get the right name
|
||||
rdtest.log.success(f"Resource {resname} bound as expected")
|
||||
|
||||
for cb in pipe.GetConstantBlocks(stage, True):
|
||||
expected_name = refl.constantBlocks[cb.access.index].name
|
||||
|
||||
# ignore the push constants
|
||||
if not refl.constantBlocks[cb.access.index].bufferBacked and expected_name == 'push':
|
||||
continue
|
||||
|
||||
if refl.constantBlocks[cb.access.index].bindArraySize > 1:
|
||||
if (cb.access.arrayElement % 10) == 1:
|
||||
if cb.descriptor.resource != rd.ResourceId():
|
||||
raise rdtest.TestFailureException(
|
||||
f"Expected no resource to be bound at {expected_name}[{cb.access.arrayElement}")
|
||||
continue
|
||||
|
||||
expected_name = f'{expected_name}_{cb.access.arrayElement}'
|
||||
|
||||
resname = self.get_resource(cb.descriptor.resource).name
|
||||
|
||||
if resname != expected_name:
|
||||
raise rdtest.TestFailureException(
|
||||
f"Expected resource {resname} to be named {expected_name}")
|
||||
|
||||
data = self.controller.GetBufferData(
|
||||
cb.descriptor.resource, cb.descriptor.byteOffset, cb.descriptor.byteSize)
|
||||
|
||||
floats = struct.unpack_from("8f", data, 0)
|
||||
|
||||
picked = self.controller.PickPixel(
|
||||
out, x, y, rd.Subresource(), rd.CompType.Float)
|
||||
|
||||
output_vec = picked.floatValue[0:4]
|
||||
second_vec = floats[4:8]
|
||||
|
||||
if not rdtest.value_compare(second_vec, output_vec):
|
||||
raise rdtest.TestFailureException(
|
||||
f"Expected buffer data {output_vec}, but got {second_vec}")
|
||||
|
||||
data = self.controller.GetCBufferVariableContents(pipe.GetGraphicsPipelineObject(),
|
||||
pipe.GetShader(
|
||||
stage), stage,
|
||||
pipe.GetShaderEntryPoint(
|
||||
stage),
|
||||
cb.access.index, cb.descriptor.resource,
|
||||
cb.descriptor.byteOffset, cb.descriptor.byteSize)
|
||||
|
||||
if data[0].name != 'data':
|
||||
raise rdtest.TestFailureException(
|
||||
f"Expected 'data' member in cbuffers, got {data[0].name}")
|
||||
|
||||
if len(data[0].members) < 2:
|
||||
raise rdtest.TestFailureException(
|
||||
f"Expected 'data' member in cbuffers to have at least 2 entries, it has {len(data[0].members)}")
|
||||
|
||||
second_vec = data[0].members[1].value.f32v[0:4]
|
||||
|
||||
if not rdtest.value_compare(second_vec, output_vec):
|
||||
raise rdtest.TestFailureException(
|
||||
f"Expected constant data {output_vec}, but got {second_vec}")
|
||||
|
||||
rdtest.log.success(f"CBuffer {resname} bound as expected with correct data")
|
||||
|
||||
rdtest.log.end_section(f"Test {test}")
|
||||
Reference in New Issue
Block a user