Skip to content

Commit

Permalink
Update tests to new descriptor interface
Browse files Browse the repository at this point in the history
  • Loading branch information
baldurk committed Apr 10, 2024
1 parent fbed56a commit 9de4a79
Show file tree
Hide file tree
Showing 82 changed files with 881 additions and 796 deletions.
6 changes: 2 additions & 4 deletions util/test/demos/d3d12/d3d12_reflection_zoo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,13 @@ float4 main(float4 pos : SV_Position) : SV_Target0

setMarker(cmd, "DXBC");
cmd->SetPipelineState(dxbc);
// don't have to actually draw anything, saves us from needing to bind any descriptors. We
// can still check the reflection
cmd->DrawInstanced(0, 0, 0, 0);
cmd->DrawInstanced(3, 1, 0, 0);

if(m_DXILSupport)
{
setMarker(cmd, "DXIL");
cmd->SetPipelineState(dxil);
cmd->DrawInstanced(0, 0, 0, 0);
cmd->DrawInstanced(3, 1, 0, 0);
}

FinishUsingBackbuffer(cmd, D3D12_RESOURCE_STATE_RENDER_TARGET);
Expand Down
4 changes: 2 additions & 2 deletions util/test/rdtest/shared/Buffer_Truncation.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ def check_capture(self):

stage = rd.ShaderStage.Pixel

cbuf: rd.BoundCBuffer = pipe.GetConstantBuffer(stage, 0, 0)
cbuf = pipe.GetConstantBlock(stage, 0, 0).descriptor

if self.find_action('NoCBufferRange') == None:
self.check(cbuf.byteSize == 256)

variables = self.controller.GetCBufferVariableContents(pipe.GetGraphicsPipelineObject(),
pipe.GetShader(stage), stage,
pipe.GetShaderEntryPoint(stage), 0,
cbuf.resourceId, cbuf.byteOffset, cbuf.byteSize)
cbuf.resource, cbuf.byteOffset, cbuf.byteSize)

outcol: rd.ShaderVariable = variables[1]

Expand Down
2 changes: 1 addition & 1 deletion util/test/rdtest/shared/Draw_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def check_action(self, action: rd.ActionDescription, ref_data):
vsout_pos_name = sig.semanticName
break

out_tex = self.pipe.GetOutputTargets()[0].resourceId
out_tex = self.pipe.GetOutputTargets()[0].resource

vsin_ref = {}
restarts = []
Expand Down
12 changes: 6 additions & 6 deletions util/test/rdtest/shared/Overlay_Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def check_capture(self, base_event=0):

pipe: rd.PipeState = self.controller.GetPipelineState()

col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resourceId
col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resource

tex = rd.TextureDisplay()
tex.resourceId = col_tex
Expand Down Expand Up @@ -438,7 +438,7 @@ def check_capture(self, base_event=0):

pipe: rd.PipeState = self.controller.GetPipelineState()

col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resourceId
col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resource

for overlay in rd.DebugOverlay:
if overlay == rd.DebugOverlay.NoOverlay:
Expand Down Expand Up @@ -555,7 +555,7 @@ def check_capture(self, base_event=0):

self.controller.SetFrameEvent(mask_marker.next.eventId, True)

col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resourceId
col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resource

# Check just highlight drawcall to make sure it renders on sample 0
tex.resourceId = col_tex
Expand Down Expand Up @@ -585,9 +585,9 @@ def check_capture(self, base_event=0):
# Now check clear-before-X by hand, for colour and for depth
self.controller.SetFrameEvent(test_marker.next.eventId, True)

col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resourceId
col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resource

depth_tex: rd.ResourceId = pipe.GetDepthTarget().resourceId
depth_tex = pipe.GetDepthTarget().resource

eps = 1.0/256.0

Expand Down Expand Up @@ -726,7 +726,7 @@ def check_capture(self, base_event=0):

pipe: rd.PipeState = self.controller.GetPipelineState()

col_tex = pipe.GetOutputTargets()[0].resourceId
col_tex = pipe.GetOutputTargets()[0].resource
sub = rd.Subresource(pipe.GetOutputTargets()[0].firstMip, pipe.GetOutputTargets()[0].firstSlice, 0)

for overlay in rd.DebugOverlay:
Expand Down
19 changes: 10 additions & 9 deletions util/test/rdtest/shared/Texture_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,21 @@ def check_test(self, fmt_name: str, name: str, test_mode: int):
image_view = (test_mode != Texture_Zoo.TEST_CAPTURE)

if image_view:
bound_res: rd.BoundResource = pipe.GetOutputTargets()[0]
desc = pipe.GetOutputTargets()[0]
else:
bound_res: rd.BoundResource = pipe.GetReadOnlyResources(rd.ShaderStage.Pixel)[0].resources[0]
desc = pipe.GetReadOnlyResources(rd.ShaderStage.Pixel)[0].descriptor

tex_id = desc.resource

texs = self.controller.GetTextures()
for t in texs:
self.textures[t.resourceId] = t

tex_id: rd.ResourceId = bound_res.resourceId
tex: rd.TextureDescription = self.textures[tex_id]

testCompType: rd.CompType = tex.format.compType
if bound_res.typeCast != rd.CompType.Typeless:
testCompType = bound_res.typeCast
testCompType = desc.format.compType
if testCompType == rd.CompType.Typeless:
testCompType = tex.format.compType

pickCompType = testCompType

Expand Down Expand Up @@ -366,13 +367,13 @@ def check_test(self, fmt_name: str, name: str, test_mode: int):
x, y, sl, mp, sm, name, fmt_name, picked, expected))

if not image_view:
output_tex = pipe.GetOutputTargets()[0].resourceId
output_tex = pipe.GetOutputTargets()[0].resource

# in the test captures pick the output texture, it should be identical to the
# (0,0) pixel in slice 0, mip 0, sample 0
view: rd.Viewport = pipe.GetViewport(0)

val: rd.PixelValue = self.pick(pipe.GetOutputTargets()[0].resourceId, int(view.x + view.width / 2),
val: rd.PixelValue = self.pick(pipe.GetOutputTargets()[0].resource, int(view.x + view.width / 2),
int(view.y + view.height / 2), rd.Subresource(), rd.CompType.Typeless)

picked = list(val.floatValue)
Expand Down Expand Up @@ -555,7 +556,7 @@ def check_capture_with_controller(self, proxy_api: str):

pipe = self.controller.GetPipelineState()

tex_id = pipe.GetReadOnlyResources(rd.ShaderStage.Pixel)[0].resources[0].resourceId
tex_id = pipe.GetReadOnlyResources(rd.ShaderStage.Pixel)[0].descriptor.resource

for mip in [0, 1]:
for sl in [16, 17, 18]:
Expand Down
2 changes: 1 addition & 1 deletion util/test/rdtest/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def check_triangle(self, out = None, back = None, fore = None, vp = None):

# if no output is specified, check the current colour output at this action
if out is None:
out = pipe.GetOutputTargets()[0].resourceId
out = pipe.GetOutputTargets()[0].resource

tex_details = self.get_texture(out)

Expand Down
6 changes: 3 additions & 3 deletions util/test/tests/D3D11/D3D11_CBuffer_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ def check_capture(self):
pipe: rd.PipeState = self.controller.GetPipelineState()

stage = rd.ShaderStage.Pixel
cbuf: rd.BoundCBuffer = pipe.GetConstantBuffer(stage, 0, 0)
cbuf = pipe.GetConstantBlock(stage, 0, 0).descriptor

var_check = rdtest.ConstantBufferChecker(
self.controller.GetCBufferVariableContents(pipe.GetGraphicsPipelineObject(),
pipe.GetShader(stage), stage,
pipe.GetShaderEntryPoint(stage), 0,
cbuf.resourceId, cbuf.byteOffset, cbuf.byteSize))
cbuf.resource, cbuf.byteOffset, cbuf.byteSize))

self.check_cbuffer(var_check)

Expand Down Expand Up @@ -76,7 +76,7 @@ def check_capture(self):

self.controller.FreeTrace(trace)

self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0.5, 0.5, [536.1, 537.0, 538.0, 539.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0.5, 0.5, [536.1, 537.0, 538.0, 539.0])

rdtest.log.success("Picked value is as expected")

Expand Down
4 changes: 2 additions & 2 deletions util/test/tests/D3D11/D3D11_Deferred_Map.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def check_capture(self):
pipe: rd.PipeState = self.controller.GetPipelineState()

# Top half should be red, bottom half should be green
self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0.5, 0.25, [1.0, 0.0, 0.0, 1.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0.5, 0.75, [0.0, 1.0, 0.0, 1.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0.5, 0.25, [1.0, 0.0, 0.0, 1.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0.5, 0.75, [0.0, 1.0, 0.0, 1.0])

rdtest.log.success("Screen output is as expected")
2 changes: 1 addition & 1 deletion util/test/tests/D3D11/D3D11_Parameter_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def check_capture(self):

tex = rd.TextureDisplay()
tex.overlay = rd.DebugOverlay.Drawcall
tex.resourceId = pipe.GetOutputTargets()[0].resourceId
tex.resourceId = pipe.GetOutputTargets()[0].resource

out: rd.ReplayOutput = self.controller.CreateOutput(rd.CreateHeadlessWindowingData(100, 100),
rd.ReplayOutputType.Texture)
Expand Down
8 changes: 4 additions & 4 deletions util/test/tests/D3D11/D3D11_Pixel_History_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def check_capture(self):

pipe: rd.PipeState = self.controller.GetPipelineState()

rt: rd.BoundResource = pipe.GetOutputTargets()[0]
rt = pipe.GetOutputTargets()[0]

vp: rd.Viewport = pipe.GetViewport(0)

tex = rt.resourceId
tex = rt.resource
x, y = (int(vp.width / 2), int(vp.height / 2))

tex_details = self.get_texture(tex)
Expand All @@ -45,7 +45,7 @@ def check_capture(self):
if tex_details.mips > 1:
sub.mip = rt.firstMip

modifs: List[rd.PixelModification] = self.controller.PixelHistory(tex, x, y, sub, rt.typeCast)
modifs: List[rd.PixelModification] = self.controller.PixelHistory(tex, x, y, sub, rt.format.compType)

# Should be at least two modifications in every test - clear and action
self.check(len(modifs) >= 2)
Expand Down Expand Up @@ -76,7 +76,7 @@ def check_capture(self):
rdtest.log.success("shader output and premod/postmod is consistent")

# The current pixel value should match the last postMod
self.check_pixel_value(tex, x, y, value_selector(modifs[-1].postMod.col), sub=sub, cast=rt.typeCast)
self.check_pixel_value(tex, x, y, value_selector(modifs[-1].postMod.col), sub=sub, cast=rt.format.compType)

# Also the red channel should be zero, as it indicates errors
self.check(float(value_selector(modifs[-1].postMod.col)[0]) == 0.0)
2 changes: 1 addition & 1 deletion util/test/tests/D3D11/D3D11_Primitive_Restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def check_capture(self):
self.check_mesh_data(postvs_ref, postvs_data)

# Check that the rendered mesh is as expected
out = pipe.GetOutputTargets()[0].resourceId
out = pipe.GetOutputTargets()[0].resource
for x in [x*0.01 for x in range(1, 100)]:
self.check_pixel_value(out, x, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(out, x, 0.5, [0.2, 0.2, 0.2, 1.0])
Expand Down
2 changes: 1 addition & 1 deletion util/test/tests/D3D11/D3D11_Refcount_Check.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ def check_capture(self):

pipe: rd.PipeState = self.controller.GetPipelineState()

self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0.5, 0.5, [0.0, 1.0, 0.0, 1.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0.5, 0.5, [0.0, 1.0, 0.0, 1.0])

rdtest.log.success("Captured loaded with color as expected")
8 changes: 4 additions & 4 deletions util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def check_capture(self):
debugged = self.evaluate_source_var(output, variables)

try:
self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4 * test, 0, debugged.value.f32v[0:4])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 4 * test, 0, debugged.value.f32v[0:4])
except rdtest.TestFailureException as ex:
if test in undefined_tests:
rdtest.log.comment("Undefined test {} did not match. {}".format(test, str(ex)))
Expand Down Expand Up @@ -60,8 +60,8 @@ def check_capture(self):
debugged = self.evaluate_source_var(output, variables)

try:
self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0, 4, debugged.value.f32v[0:4])
self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0, 4, [9.0, 66.0, 4.0, 18.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0, 4, debugged.value.f32v[0:4])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0, 4, [9.0, 66.0, 4.0, 18.0])
except rdtest.TestFailureException as ex:
raise rdtest.TestFailureException("Flow test did not match. {}".format(str(ex)))
finally:
Expand Down Expand Up @@ -95,7 +95,7 @@ def check_capture(self):

# Validate the debug output result
try:
self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4, 4, debugged.value.f32v[0:4], sub=rd.Subresource(0, 0, test))
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 4, 4, debugged.value.f32v[0:4], sub=rd.Subresource(0, 0, test))
except rdtest.TestFailureException as ex:
failed = True
rdtest.log.error("Test {} did not match. {}".format(test, str(ex)))
Expand Down
2 changes: 1 addition & 1 deletion util/test/tests/D3D11/D3D11_Shader_Editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def check_capture(self):
psrefl2: rd.ShaderReflection = pipe.GetShaderReflection(rd.ShaderStage.Pixel)
vsrefl: rd.ShaderReflection = pipe.GetShaderReflection(rd.ShaderStage.Vertex)

tex: rd.ResourceId = pipe.GetOutputTargets()[0].resourceId
tex: rd.ResourceId = pipe.GetOutputTargets()[0].resource

# Both triangles should be green
self.check_pixel_value(tex, 0.25, 0.5, [0.0, 1.0, 0.0, 1.0])
Expand Down
2 changes: 1 addition & 1 deletion util/test/tests/D3D11/D3D11_Shader_Linkage_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def check_capture(self):
debugged = self.evaluate_source_var(output, variables)

try:
self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 200, 150, debugged.value.f32v[0:4])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 200, 150, debugged.value.f32v[0:4])
except rdtest.TestFailureException as ex:
failed = True
rdtest.log.error("Test {} did not match. {}".format(event_name, str(ex)))
Expand Down
4 changes: 2 additions & 2 deletions util/test/tests/D3D11/D3D11_Untyped_Backbuffer_Descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def check_capture(self):

pipe: rd.PipeState = self.controller.GetPipelineState()

self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0.25, 0.5, [1.0, 1.0, 1.0, 1.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0.25, 0.5, [1.0, 1.0, 1.0, 1.0])

rdtest.log.success("Picked value for first action is as expected")

Expand All @@ -24,6 +24,6 @@ def check_capture(self):

pipe: rd.PipeState = self.controller.GetPipelineState()

self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0.75, 0.5, [1.0, 1.0, 1.0, 1.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0.75, 0.5, [1.0, 1.0, 1.0, 1.0])

rdtest.log.success("Picked value for second action is as expected")
2 changes: 1 addition & 1 deletion util/test/tests/D3D11/D3D11_Vertex_Attr_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ def check_capture(self):

pipe: rd.PipeState = self.controller.GetPipelineState()

self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0.5, 0.5, [0.0, 1.0, 0.0, 1.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0.5, 0.5, [0.0, 1.0, 0.0, 1.0])

rdtest.log.success("Triangle picked value is as expected")
2 changes: 1 addition & 1 deletion util/test/tests/D3D12/D3D12_AMD_Shader_Extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def check_capture(self):
self.controller.SetFrameEvent(action.next.eventId, False)

pipe = self.controller.GetPipelineState()
tex = pipe.GetOutputTargets()[0].resourceId
tex = pipe.GetOutputTargets()[0].resource
vp = pipe.GetViewport(0)

# Should have barycentrics showing the closest vertex for each pixel in the triangle
Expand Down
26 changes: 12 additions & 14 deletions util/test/tests/D3D12/D3D12_CBuffer_Zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def check_event(self):
stage = rd.ShaderStage.Pixel

refl: rd.ShaderReflection = pipe.GetShaderReflection(stage)
mapping: rd.ShaderBindpointMapping = pipe.GetBindpointMapping(stage)

# Make sure we have three constant buffers - b7 normal, b1 root constants, and space9999999:b0
binds = [
Expand All @@ -60,40 +59,39 @@ def check_event(self):
(999999999, 0),
]

if len(refl.constantBlocks) != len(mapping.constantBlocks) or len(refl.constantBlocks) != len(binds):
if len(refl.constantBlocks) != len(binds):
raise rdtest.TestFailureException(
"Expected {}} constant buffers, only got {} {}".format(len(binds), len(refl.constantBlocks),
len(refl.constantBlocks)))
"Expected {} constant buffers, only got {}".format(len(binds), len(refl.constantBlocks)))

for b in range(0, len(binds)):
if binds[b][0] != mapping.constantBlocks[b].bindset or binds[b][1] != mapping.constantBlocks[b].bind:
if binds[b][0] != refl.constantBlocks[b].fixedBindSetOrSpace or binds[b][1] != refl.constantBlocks[b].fixedBindNumber:
raise rdtest.TestFailureException(
"Unexpected cb[{}] mapping: set {} bind {}".format(b, mapping.constantBlocks[b].bindset,
mapping.constantBlocks[b].bind))
"Unexpected cb[{}] mapping: space {} bind {}".format(b, refl.constantBlocks[b].fixedBindSetOrSpace,
refl.constantBlocks[b].fixedBindNumber))

cbuf: rd.BoundCBuffer = pipe.GetConstantBuffer(stage, 0, 0)
cbuf = pipe.GetConstantBlock(stage, 0, 0).descriptor

var_check = rdtest.ConstantBufferChecker(
self.controller.GetCBufferVariableContents(pipe.GetGraphicsPipelineObject(),
pipe.GetShader(stage), stage,
pipe.GetShaderEntryPoint(stage), 0,
cbuf.resourceId, cbuf.byteOffset, cbuf.byteSize))
cbuf.resource, cbuf.byteOffset, cbuf.byteSize))

cbuf: rd.BoundCBuffer = pipe.GetConstantBuffer(stage, 1, 0)
cbuf = pipe.GetConstantBlock(stage, 1, 0).descriptor

root_check = rdtest.ConstantBufferChecker(
self.controller.GetCBufferVariableContents(pipe.GetGraphicsPipelineObject(),
pipe.GetShader(stage), stage,
pipe.GetShaderEntryPoint(stage), 1,
cbuf.resourceId, cbuf.byteOffset, cbuf.byteSize))
cbuf.resource, cbuf.byteOffset, cbuf.byteSize))

cbuf: rd.BoundCBuffer = pipe.GetConstantBuffer(stage, 2, 0)
cbuf = pipe.GetConstantBlock(stage, 2, 0).descriptor

huge_check = rdtest.ConstantBufferChecker(
self.controller.GetCBufferVariableContents(pipe.GetGraphicsPipelineObject(),
pipe.GetShader(stage), stage,
pipe.GetShaderEntryPoint(stage), 2,
cbuf.resourceId, cbuf.byteOffset, cbuf.byteSize))
cbuf.resource, cbuf.byteOffset, cbuf.byteSize))

self.check_cbuffers(var_check, root_check, huge_check)

Expand Down Expand Up @@ -152,7 +150,7 @@ def check_event(self):

self.controller.FreeTrace(trace)

self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 0.5, 0.5, [536.1, 537.0, 538.0, 539.0])
self.check_pixel_value(pipe.GetOutputTargets()[0].resource, 0.5, 0.5, [536.1, 537.0, 538.0, 539.0])

rdtest.log.success("Picked value is as expected")

Expand Down
Loading

0 comments on commit 9de4a79

Please sign in to comment.