mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 13:20:54 +00:00
Basic Test for VK_KHR_Buffer_Address
Compare the pixel shader debugger result against the GPU rendered output Compare the vertex shader debugger results against the postVS output
This commit is contained in:
@@ -54,6 +54,7 @@ RD_TEST(VK_KHR_Buffer_Address, VulkanGraphicsTest)
|
||||
|
||||
#extension GL_EXT_buffer_reference : require
|
||||
#extension GL_EXT_scalar_block_layout : require
|
||||
#extension GL_EXT_buffer_reference_uvec2 : require
|
||||
|
||||
struct v2f
|
||||
{
|
||||
@@ -81,7 +82,8 @@ layout(buffer_reference, scalar, buffer_reference_align = 16) buffer DrawData {
|
||||
};
|
||||
|
||||
layout(push_constant) uniform PushData {
|
||||
DrawData data_ptr;
|
||||
uvec2 data_ptr;
|
||||
DrawData drawdata;
|
||||
} push;
|
||||
|
||||
)EOSHADER";
|
||||
@@ -92,7 +94,7 @@ layout(location = 0) out v2f vertOut;
|
||||
|
||||
void main()
|
||||
{
|
||||
DrawData draw = push.data_ptr;
|
||||
DrawData draw = DrawData(push.data_ptr);
|
||||
DefaultA2V vert = draw.tri.verts[gl_VertexIndex];
|
||||
|
||||
gl_Position = vertOut.pos = vec4(vert.pos*vec3(draw.scale,1) + vec3(draw.offset, 0), 1);
|
||||
@@ -110,7 +112,7 @@ layout(location = 0, index = 0) out vec4 Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
DrawData draw = push.data_ptr;
|
||||
DrawData draw = push.drawdata;
|
||||
|
||||
Color = vertIn.col * draw.tint;
|
||||
}
|
||||
@@ -149,7 +151,7 @@ void main()
|
||||
return 3;
|
||||
|
||||
VkPipelineLayout layout = createPipelineLayout(
|
||||
vkh::PipelineLayoutCreateInfo({}, {vkh::PushConstantRange(VK_SHADER_STAGE_ALL, 0, 8)}));
|
||||
vkh::PipelineLayoutCreateInfo({}, {vkh::PushConstantRange(VK_SHADER_STAGE_ALL, 0, 16)}));
|
||||
|
||||
vkh::GraphicsPipelineCreateInfo pipeCreateInfo;
|
||||
|
||||
@@ -298,20 +300,26 @@ void main()
|
||||
DrawData *bindptr = drawsgpu;
|
||||
drawscpu[0].scale.x = (abs(sinf(time)) + 0.1f) * 0.5f;
|
||||
drawscpu[0].scale.y = 0.5f;
|
||||
setMarker(cmd, "Draw 1");
|
||||
vkCmdPushConstants(cmd, layout, VK_SHADER_STAGE_ALL, 0, 8, &bindptr);
|
||||
vkCmdPushConstants(cmd, layout, VK_SHADER_STAGE_ALL, 8, 8, &bindptr);
|
||||
vkCmdDraw(cmd, 3, 1, 0, 0);
|
||||
|
||||
bindptr++;
|
||||
drawscpu[1].scale.x = 0.5f;
|
||||
drawscpu[1].scale.y = (abs(cosf(time)) + 0.1f) * 0.5f;
|
||||
setMarker(cmd, "Draw 2");
|
||||
vkCmdPushConstants(cmd, layout, VK_SHADER_STAGE_ALL, 0, 8, &bindptr);
|
||||
vkCmdPushConstants(cmd, layout, VK_SHADER_STAGE_ALL, 8, 8, &bindptr);
|
||||
vkCmdDraw(cmd, 3, 1, 0, 0);
|
||||
|
||||
bindptr++;
|
||||
drawscpu[2].scale = Vec2f(0.5f, 0.5f);
|
||||
drawscpu[2].tint = Vec4f(cosf(time) * 0.5f + 0.5f, sinf(time) * 0.5f + 0.5f,
|
||||
cosf(time + 3.14f) * 0.5f + 0.5f, 1.0f);
|
||||
setMarker(cmd, "Draw 3");
|
||||
vkCmdPushConstants(cmd, layout, VK_SHADER_STAGE_ALL, 0, 8, &bindptr);
|
||||
vkCmdPushConstants(cmd, layout, VK_SHADER_STAGE_ALL, 8, 8, &bindptr);
|
||||
vkCmdDraw(cmd, 3, 1, 0, 0);
|
||||
|
||||
vkCmdEndRenderPass(cmd);
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import renderdoc as rd
|
||||
import rdtest
|
||||
|
||||
class VK_KHR_Buffer_Address(rdtest.TestCase):
|
||||
demos_test_name = 'VK_KHR_Buffer_Address'
|
||||
|
||||
def check_capture(self):
|
||||
if not self.controller.GetAPIProperties().shaderDebugging:
|
||||
rdtest.log.success("Shader debugging not enabled, skipping test")
|
||||
return
|
||||
|
||||
x = 100
|
||||
y = 150
|
||||
|
||||
for test_name in ["Draw 1", "Draw 2", "Draw 3"]:
|
||||
rdtest.log.print("Test {}".format(test_name))
|
||||
action: rd.ActionDescription = self.find_action(test_name)
|
||||
action = action.next
|
||||
self.controller.SetFrameEvent(action.eventId, True)
|
||||
pipe: rd.PipeState = self.controller.GetPipelineState()
|
||||
|
||||
if not pipe.GetShaderReflection(rd.ShaderStage.Pixel).debugInfo.debuggable:
|
||||
raise rdtest.TestFailureException("Test {} shader can not be debugged".format(test_name))
|
||||
|
||||
# Debug the pixel shader
|
||||
trace: rd.ShaderDebugTrace = self.controller.DebugPixel(x, y, rd.ReplayController.NoPreference,
|
||||
rd.ReplayController.NoPreference)
|
||||
if trace.debugger is None:
|
||||
self.controller.FreeTrace(trace)
|
||||
raise rdtest.TestFailureException("Test {} did not debug at all".format(test_name))
|
||||
|
||||
cycles, variables = self.process_trace(trace)
|
||||
output: rd.SourceVariableMapping = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, x, y, debugged.value.f32v[0:4])
|
||||
self.controller.FreeTrace(trace)
|
||||
x = x + 100
|
||||
|
||||
inst = 0
|
||||
postvs = self.get_postvs(action, rd.MeshDataStage.VSOut, instance=inst)
|
||||
for vtx in range(action.numIndices):
|
||||
idx = vtx
|
||||
self.check_debug(vtx, idx, inst, postvs)
|
||||
|
||||
rdtest.log.success("All tests matched")
|
||||
|
||||
|
||||
def check_debug(self, vtx, idx, inst, postvs):
|
||||
trace: rd.ShaderDebugTrace = self.controller.DebugVertex(vtx, inst, idx, 0)
|
||||
|
||||
if trace.debugger is None:
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
raise rdtest.TestFailureException("Couldn't debug vertex {} in instance {}".format(vtx, inst))
|
||||
|
||||
cycles, variables = self.process_trace(trace)
|
||||
|
||||
for var in trace.sourceVars:
|
||||
var: rd.SourceVariableMapping
|
||||
if var.variables[0].type == rd.DebugVariableType.Variable and var.signatureIndex >= 0:
|
||||
name = var.name
|
||||
|
||||
if name not in postvs[vtx].keys():
|
||||
raise rdtest.TestFailureException("Don't have expected output for {}".format(name))
|
||||
|
||||
expect = postvs[vtx][name]
|
||||
value = self.evaluate_source_var(var, variables)
|
||||
|
||||
if len(expect) != value.columns:
|
||||
raise rdtest.TestFailureException(
|
||||
"Output {} at vert {} (idx {}) instance {} has different size ({} values) to expectation ({} values)"
|
||||
.format(name, vtx, idx, inst, value.columns, len(expect)))
|
||||
|
||||
debugged = value.value.f32v[0:value.columns]
|
||||
|
||||
if not rdtest.value_compare(expect, debugged):
|
||||
raise rdtest.TestFailureException(
|
||||
"Debugged value {} at vert {} (idx {}) instance {}: {} doesn't exactly match postvs output {}".format(
|
||||
name, vtx, idx, inst, debugged, expect))
|
||||
rdtest.log.success('Successfully debugged vertex {} in instance {}'
|
||||
.format(vtx, inst))
|
||||
|
||||
Reference in New Issue
Block a user