mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-14 17:55:50 +00:00
Don't allow find_*_source_var to return None
* Almost all callers expect a return value, so better to raise an exception inside and make it non-optional return
This commit is contained in:
@@ -188,11 +188,6 @@ class Subgroup_Zoo(rdtest.TestCase):
|
||||
output_sourcevar = self.find_output_source_var(
|
||||
trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
if output_sourcevar is None:
|
||||
rdtest.log.error("No output variable found")
|
||||
failed = True
|
||||
continue
|
||||
|
||||
debugged = self.evaluate_source_var(
|
||||
output_sourcevar, variables)
|
||||
|
||||
|
||||
@@ -979,19 +979,30 @@ class TestCase:
|
||||
|
||||
return vars[0]
|
||||
|
||||
def has_input_source_var(self, trace: rd.ShaderDebugTrace, builtin: rd.ShaderBuiltin, reg_index: int = -1):
|
||||
refl = self.controller.GetPipelineState().GetShaderReflection(trace.stage)
|
||||
sig_index = self.get_sig_index(refl.inputSignature, builtin, reg_index)
|
||||
return self.find_source_var(trace.sourceVars, sig_index, rd.DebugVariableType.Input) is not None
|
||||
|
||||
def find_input_source_var(self, trace: rd.ShaderDebugTrace, builtin: rd.ShaderBuiltin, reg_index: int = -1):
|
||||
refl = self.controller.GetPipelineState().GetShaderReflection(trace.stage)
|
||||
|
||||
sig_index = self.get_sig_index(refl.inputSignature, builtin, reg_index)
|
||||
|
||||
return self.find_source_var(trace.sourceVars, sig_index, rd.DebugVariableType.Input)
|
||||
ret = self.find_source_var(trace.sourceVars, sig_index, rd.DebugVariableType.Input)
|
||||
if ret is None:
|
||||
raise TestFailureException(f"Couldn't find input source var {builtin!s} / {reg_index}")
|
||||
return ret
|
||||
|
||||
def find_output_source_var(self, trace: rd.ShaderDebugTrace, builtin: rd.ShaderBuiltin, reg_index: int = -1):
|
||||
refl = self.controller.GetPipelineState().GetShaderReflection(trace.stage)
|
||||
|
||||
sig_index = self.get_sig_index(refl.outputSignature, builtin, reg_index)
|
||||
|
||||
return self.find_source_var(trace.sourceVars, sig_index, rd.DebugVariableType.Variable)
|
||||
ret = self.find_source_var(trace.sourceVars, sig_index, rd.DebugVariableType.Variable)
|
||||
if ret is None:
|
||||
raise TestFailureException(f"Couldn't find input source var {builtin!s} / {reg_index}")
|
||||
return ret
|
||||
|
||||
def get_debug_var(self, debugVars: Dict[str, rd.ShaderVariable], path: str) -> rd.ShaderVariable:
|
||||
# first look for exact match
|
||||
@@ -1164,8 +1175,6 @@ class TestCase:
|
||||
|
||||
_, variables = self.process_trace(trace)
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
if output is None:
|
||||
raise TestFailureException(f"Couldn't find colour output source variable")
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
|
||||
@@ -70,8 +70,6 @@ class D3D11_CBuffer_Zoo(rdtest.TestCase):
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
if not rdtest.util.value_compare(debugged.value.f32v[0:4], [542.1, 543.0, 544.0, 545.0]):
|
||||
|
||||
@@ -25,13 +25,14 @@ class D3D11_PrimitiveID(rdtest.TestCase):
|
||||
_, variables = self.process_trace(trace)
|
||||
|
||||
# Find the SV_PrimitiveID variable
|
||||
primInput = self.find_input_source_var(trace, rd.ShaderBuiltin.PrimitiveIndex)
|
||||
if primInput is None:
|
||||
if not self.has_input_source_var(trace, rd.ShaderBuiltin.PrimitiveIndex):
|
||||
# If we didn't find it, then we should be expecting a 0
|
||||
if len(expected_prim) != 1 or expected_prim[0] != 0:
|
||||
rdtest.log.error(f"Expected prim {expected_prim!s} at {x},{y} did not match actual prim {prim}.")
|
||||
return False
|
||||
else:
|
||||
primInput = self.find_input_source_var(trace, rd.ShaderBuiltin.PrimitiveIndex)
|
||||
|
||||
# Look up the matching register in the inputs, and see if the expected value matches
|
||||
inputs = list(trace.inputs)
|
||||
primValue = [var for var in inputs if var.name == primInput.variables[0].name][0]
|
||||
@@ -43,7 +44,7 @@ class D3D11_PrimitiveID(rdtest.TestCase):
|
||||
# since we're testing overlapping primitives in a single action
|
||||
if expected_output is not None:
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
if list(debugged.value.f32v[0:4]) != expected_output:
|
||||
rdtest.log.error(f"Expected value {expected_output} at {x},{y} did not match actual {debugged.value.f32v[0:4]}.")
|
||||
|
||||
@@ -31,8 +31,6 @@ class D3D11_Shader_Debug_Zoo(rdtest.TestCase):
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
try:
|
||||
@@ -62,8 +60,6 @@ class D3D11_Shader_Debug_Zoo(rdtest.TestCase):
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
try:
|
||||
@@ -99,8 +95,6 @@ class D3D11_Shader_Debug_Zoo(rdtest.TestCase):
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
# Validate the debug output result
|
||||
|
||||
@@ -24,8 +24,6 @@ class D3D11_Shader_Linkage_Zoo(rdtest.TestCase):
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
try:
|
||||
|
||||
@@ -204,8 +204,6 @@ class D3D12_CBuffer_Zoo(rdtest.TestCase):
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
if not rdtest.util.value_compare(debugged.value.f32v[0:4], [543.1, 546.0, 545.0, 546.0]):
|
||||
|
||||
@@ -24,14 +24,15 @@ class D3D12_PrimitiveID(rdtest.TestCase):
|
||||
|
||||
cycles, variables = self.process_trace(trace)
|
||||
|
||||
# Find the SV_PrimitiveID variable
|
||||
primInput = self.find_input_source_var(trace, rd.ShaderBuiltin.PrimitiveIndex)
|
||||
if primInput is None:
|
||||
# Find the SV_PrimitiveID variable, optionally
|
||||
if not self.has_input_source_var(trace, rd.ShaderBuiltin.PrimitiveIndex):
|
||||
# If we didn't find it, then we should be expecting a 0
|
||||
if len(expected_prim) != 1 or expected_prim[0] != 0:
|
||||
rdtest.log.error(f"Expected prim {expected_prim!s} at {x},{y} did not match actual prim {prim}.")
|
||||
return False
|
||||
else:
|
||||
primInput = self.find_input_source_var(trace, rd.ShaderBuiltin.PrimitiveIndex)
|
||||
|
||||
# Look up the matching register in the inputs, and see if the expected value matches
|
||||
inputs = list(trace.inputs)
|
||||
primInputName = primInput.variables[0].name
|
||||
@@ -54,7 +55,7 @@ class D3D12_PrimitiveID(rdtest.TestCase):
|
||||
# since we're testing overlapping primitives in a single action
|
||||
if expected_output is not None:
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
if list(debugged.value.f32v[0:4]) != expected_output:
|
||||
rdtest.log.error(f"Expected value {expected_output} at {x},{y} did not match actual {debugged.value.f32v[0:4]}.")
|
||||
|
||||
@@ -14,8 +14,6 @@ class D3D12_Resource_Mapping_Zoo(rdtest.TestCase):
|
||||
cycles, variables = self.process_trace(trace)
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class D3D12_Shader_DebugData_Zoo(rdtest.TestCase):
|
||||
for row in range(rows):
|
||||
var = (f"{name}.row{row}", f"{type}3", value)
|
||||
varsToCheck.append(var)
|
||||
|
||||
|
||||
if not foundStart or not foundEnd:
|
||||
raise rdtest.TestFailureException("Couldn't find TEST_DEBUG_VAR_START and TEST_DEBUG_VAR_END")
|
||||
|
||||
@@ -98,7 +98,7 @@ class D3D12_Shader_DebugData_Zoo(rdtest.TestCase):
|
||||
with self.debug_vertex(0, instId, 0, 0) as debug:
|
||||
cycles, variables = self.process_trace(debug.trace)
|
||||
output = self.find_output_source_var(debug.trace, rd.ShaderBuiltin.Undefined, 1)
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
actual = debugged.value.u32v[0]
|
||||
expected = instId
|
||||
@@ -143,7 +143,7 @@ class D3D12_Shader_DebugData_Zoo(rdtest.TestCase):
|
||||
trace = self.controller.DebugPixel(4 * test, 0, rd.DebugPixelInputs())
|
||||
cycles, variables = self.process_trace(trace)
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
try:
|
||||
@@ -201,7 +201,7 @@ class D3D12_Shader_DebugData_Zoo(rdtest.TestCase):
|
||||
matched = False
|
||||
failed = True
|
||||
break
|
||||
|
||||
|
||||
if debuggedValue is None:
|
||||
raise rdtest.TestFailureException(f"Couldn't find source variable {name} type:{varType}")
|
||||
if not rdtest.value_compare(expectedValue, debuggedValue):
|
||||
@@ -220,7 +220,7 @@ class D3D12_Shader_DebugData_Zoo(rdtest.TestCase):
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
rdtest.log.success(f"Test {test} matched as expected")
|
||||
|
||||
|
||||
rdtest.log.end_section(shaderModels[sm] + " tests")
|
||||
|
||||
csShaderModels = ["cs_6_0"]
|
||||
|
||||
@@ -149,8 +149,6 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase):
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
@@ -200,8 +198,6 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase):
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
@@ -244,7 +240,7 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase):
|
||||
trace = self.controller.DebugPixel(51, 51, inputs)
|
||||
cycles, variables = self.process_trace(trace)
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
@@ -276,7 +272,6 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase):
|
||||
cycles, variables = self.process_trace(trace)
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
@@ -24,8 +24,6 @@ class D3D12_Shader_Linkage_Zoo(rdtest.TestCase):
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
try:
|
||||
|
||||
@@ -51,8 +51,6 @@ class D3D12_Vertex_UAV(rdtest.TestCase):
|
||||
cycles, variables = self.process_trace(trace)
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@ class GL_Shader_Debug_Zoo(rdtest.TestCase):
|
||||
_, variables = self.process_trace(trace)
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
|
||||
@@ -297,9 +297,9 @@ class Iter_Test(rdtest.TestCase):
|
||||
else:
|
||||
rdtest.log.print(f"At event {lastmod.eventId} the target is index {output_index}")
|
||||
|
||||
output_sourcevar = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, output_index)
|
||||
try:
|
||||
output_sourcevar = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, output_index)
|
||||
|
||||
if output_sourcevar is not None:
|
||||
debugged = self.evaluate_source_var(output_sourcevar, variables)
|
||||
|
||||
self.controller.FreeTrace(trace)
|
||||
@@ -328,7 +328,7 @@ class Iter_Test(rdtest.TestCase):
|
||||
f"Debugged value {debugged.name} at EID {lastmod.eventId} {x},{y}: {diff_amt} difference. {debuggedValue} doesn't exactly match history shader output {historyValue}")
|
||||
|
||||
rdtest.log.success(f'Successfully debugged pixel in {cycles} cycles, result matches')
|
||||
else:
|
||||
except rdtest.TestFailureException:
|
||||
# This could be an application error - undefined but seen in the wild
|
||||
rdtest.log.error(f"At EID {lastmod.eventId} No output variable declared for index {output_index}")
|
||||
|
||||
|
||||
@@ -103,9 +103,6 @@ class VK_Graphics_Pipeline(rdtest.TestCase):
|
||||
|
||||
output_sourcevar = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
if output_sourcevar is None:
|
||||
raise rdtest.TestFailureException("Couldn't get colour output value")
|
||||
|
||||
debugged = self.evaluate_source_var(output_sourcevar, variables)
|
||||
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
@@ -21,7 +21,7 @@ class VK_KHR_Buffer_Address(rdtest.TestCase):
|
||||
|
||||
cycles, variables = self.process_trace(trace)
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, x, y, debugged.value.f32v[0:4])
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
@@ -67,9 +67,6 @@ class VK_Multi_Entry(rdtest.TestCase):
|
||||
|
||||
output_sourcevar = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
if output_sourcevar is None:
|
||||
raise rdtest.TestFailureException("Couldn't get colour output value")
|
||||
|
||||
debugged = self.evaluate_source_var(output_sourcevar, variables)
|
||||
|
||||
self.controller.FreeTrace(trace)
|
||||
|
||||
@@ -27,7 +27,7 @@ class VK_Multi_View(rdtest.TestCase):
|
||||
|
||||
cycles, variables = self.process_trace(trace)
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
slice = view + 1
|
||||
sub = rd.Subresource(0, slice, 0)
|
||||
@@ -65,7 +65,7 @@ class VK_Multi_View(rdtest.TestCase):
|
||||
|
||||
cycles, variables = self.process_trace(trace)
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
slice = view + 1
|
||||
sub = rd.Subresource(0, slice, 0)
|
||||
|
||||
@@ -29,8 +29,6 @@ class VK_Shader_Debug_Zoo(rdtest.TestCase):
|
||||
_, variables = self.process_trace(trace)
|
||||
|
||||
output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0)
|
||||
|
||||
assert output is not None
|
||||
|
||||
debugged = self.evaluate_source_var(output, variables)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user