mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-22 21:55:52 +00:00
Add early return test case to D3D12_Shader_DebugData
Change python to search backwards through the instruction info to find the value for a source variable
This commit is contained in:
@@ -150,6 +150,13 @@ struct TestStruct
|
||||
testResult.x = testStruct.anon.a.x;
|
||||
testResult.y = testStruct.anon.b.x;
|
||||
}
|
||||
else if(testIndex == 4)
|
||||
{
|
||||
testResult.x = intVal * 7;
|
||||
testResult.y = intVal * 5;
|
||||
SET_DATA(testIndex, testResult);
|
||||
EARLY_RETURN;
|
||||
}
|
||||
else
|
||||
{
|
||||
testResult = 0.4f;
|
||||
@@ -161,6 +168,8 @@ struct TestStruct
|
||||
|
||||
std::string pixel = R"EOSHADER(
|
||||
|
||||
#define SET_DATA(INDEX, DATA)
|
||||
#define EARLY_RETURN return testResult
|
||||
#define TEST_INDEX IN.tri
|
||||
)EOSHADER" + testDefines +
|
||||
R"EOSHADER(
|
||||
@@ -178,12 +187,19 @@ float4 main(v2f IN) : SV_Target0
|
||||
|
||||
std::string compute = R"EOSHADER(
|
||||
|
||||
RWStructuredBuffer<float4> bufOut : register(u0);
|
||||
|
||||
void SetOutput(uint index, float4 data)
|
||||
{
|
||||
bufOut[index] = data;
|
||||
}
|
||||
|
||||
#define SET_DATA(INDEX, DATA) SetOutput(INDEX, DATA)
|
||||
#define EARLY_RETURN return
|
||||
#define TEST_INDEX inTestIndex
|
||||
)EOSHADER" + testDefines +
|
||||
R"EOSHADER(
|
||||
|
||||
RWStructuredBuffer<float4> bufOut : register(u0);
|
||||
|
||||
[numthreads(1,1,1)]
|
||||
void main(int inTestIndex: SV_GroupID)
|
||||
{
|
||||
@@ -191,7 +207,7 @@ void main(int inTestIndex: SV_GroupID)
|
||||
)EOSHADER" + testsBody +
|
||||
R"EOSHADER(
|
||||
|
||||
bufOut[testIndex] = testResult;
|
||||
SetOutput(testIndex, testResult);
|
||||
}
|
||||
|
||||
)EOSHADER";
|
||||
|
||||
@@ -706,7 +706,7 @@ class TestCase:
|
||||
|
||||
raise KeyError("Couldn't find {} in debug vars".format(path))
|
||||
|
||||
raise KeyError("Couldn't parse path {}".format(path))
|
||||
raise KeyError(f"Couldn't find '{path}' in debug vars or parse it")
|
||||
|
||||
|
||||
def evaluate_source_var(self, sourceVar: rd.SourceVariableMapping, debugVars) -> rd.ShaderVariable:
|
||||
|
||||
@@ -125,7 +125,19 @@ class D3D12_Shader_DebugData_Zoo(rdtest.TestCase):
|
||||
shaderSrcRaw = debugInfo.files[0].contents
|
||||
varsToCheck = self.parse_shader_source(shaderSrcRaw, realTestResult, test)
|
||||
for name, varType, expectedValue in varsToCheck:
|
||||
debuggedValue = self.get_source_shader_var_value(trace.instInfo[-1].sourceVars, name, varType, variables)
|
||||
debuggedValue = None
|
||||
countInst = len(trace.instInfo)
|
||||
for inst in range(countInst):
|
||||
sourceVars = trace.instInfo[countInst-1-inst].sourceVars
|
||||
try:
|
||||
debuggedValue = self.get_source_shader_var_value(sourceVars, name, varType, variables)
|
||||
except KeyError as ex:
|
||||
continue
|
||||
except rdtest.TestFailureException as ex:
|
||||
continue
|
||||
break
|
||||
if debuggedValue is None:
|
||||
raise rdtest.TestFailureException(f"Couldn't find source variable {name} {varType}")
|
||||
if not rdtest.value_compare(expectedValue, debuggedValue):
|
||||
raise rdtest.TestFailureException(f"'{name}' {varType} debugger {debuggedValue} doesn't match expected {expectedValue}")
|
||||
rdtest.log.success(f"{len(varsToCheck)} source variables matched as expected")
|
||||
@@ -184,7 +196,19 @@ class D3D12_Shader_DebugData_Zoo(rdtest.TestCase):
|
||||
varsToCheck = self.parse_shader_source(shaderSrcRaw, realTestResult, test)
|
||||
try:
|
||||
for name, varType, expectedValue in varsToCheck:
|
||||
debuggedValue = self.get_source_shader_var_value(trace.instInfo[-1].sourceVars, name, varType, variables)
|
||||
debuggedValue = None
|
||||
countInst = len(trace.instInfo)
|
||||
for inst in range(countInst):
|
||||
sourceVars = trace.instInfo[countInst-1-inst].sourceVars
|
||||
try:
|
||||
debuggedValue = self.get_source_shader_var_value(sourceVars, name, varType, variables)
|
||||
except KeyError as ex:
|
||||
continue
|
||||
except rdtest.TestFailureException as ex:
|
||||
continue
|
||||
break
|
||||
if debuggedValue is None:
|
||||
raise rdtest.TestFailureException(f"Couldn't find source variable {name} {varType}")
|
||||
if not rdtest.value_compare(expectedValue, debuggedValue):
|
||||
raise rdtest.TestFailureException(f"'{name}' {varType} debugger {debuggedValue} doesn't match expected {expectedValue}")
|
||||
rdtest.log.success(f"{len(varsToCheck)} source variables matched as expected")
|
||||
|
||||
Reference in New Issue
Block a user