D3D12 Pixel History Simple D16 test

This commit is contained in:
Jake Turner
2024-01-08 10:06:56 +00:00
parent 3363b29883
commit edbcbe53e2
2 changed files with 71 additions and 0 deletions
@@ -213,6 +213,10 @@ float4 main(v2f vertIn, uint primId : SV_PrimitiveID, uint sampleId : SV_SampleI
{Vec3f(0.6f, 0.3f, 0.3f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 0.0f)},
{Vec3f(0.7f, 0.5f, 0.5f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 1.0f)},
{Vec3f(0.8f, 0.3f, 0.7f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(1.0f, 0.0f)},
// D16 triangle
{Vec3f(-0.7f, 0.5f, 0.33f), Vec4f(1.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 1.0f)},
{Vec3f(-0.6f, 0.3f, 0.33f), Vec4f(1.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 0.0f)},
{Vec3f(-0.8f, 0.3f, 0.33f), Vec4f(1.0f, 1.0f, 0.0f, 1.0f), Vec2f(1.0f, 0.0f)},
};
ID3D12ResourcePtr vb = MakeBuffer().Data(VBData);
@@ -223,6 +227,7 @@ float4 main(v2f vertIn, uint primId : SV_PrimitiveID, uint sampleId : SV_SampleI
const DXGI_FORMAT renderSurfaceFormat = DXGI_FORMAT_R8G8B8A8_TYPELESS;
const DXGI_FORMAT renderViewFormat = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
const DXGI_FORMAT depthFormat = DXGI_FORMAT_D24_UNORM_S8_UINT;
const DXGI_FORMAT depth16Format = DXGI_FORMAT_D16_UNORM;
struct PassResources
{
@@ -233,6 +238,8 @@ float4 main(v2f vertIn, uint primId : SV_PrimitiveID, uint sampleId : SV_SampleI
D3D12_CPU_DESCRIPTOR_HANDLE mainRTV;
ID3D12ResourcePtr mainDS;
D3D12_CPU_DESCRIPTOR_HANDLE mainDSV;
ID3D12ResourcePtr main16DS;
D3D12_CPU_DESCRIPTOR_HANDLE main16DSV;
ID3D12ResourcePtr mipArrayRT;
D3D12_CPU_DESCRIPTOR_HANDLE mipArraySubRTV;
@@ -261,6 +268,7 @@ float4 main(v2f vertIn, uint primId : SV_PrimitiveID, uint sampleId : SV_SampleI
ID3D12PipelineStatePtr depthBoundsPipe;
ID3D12PipelineStatePtr whitePipe;
ID3D12PipelineStatePtr msaaPipe;
ID3D12PipelineStatePtr depth16Pipe;
};
struct DepthBoundsTestStream
@@ -325,6 +333,10 @@ float4 main(v2f vertIn, uint primId : SV_PrimitiveID, uint sampleId : SV_SampleI
pass.mainDS->SetName((L"mainDS" + nameSuffix[i]).c_str());
pass.mainDSV = MakeDSV(pass.mainDS).Format(depthFormat).CreateCPU(dsvIndex++);
pass.main16DS = MakeTexture(depth16Format, screenWidth, screenHeight).DSV();
pass.main16DS->SetName((L"main16DS" + nameSuffix[i]).c_str());
pass.main16DSV = MakeDSV(pass.main16DS).Format(depth16Format).CreateCPU(dsvIndex++);
pass.mipArrayRT =
MakeTexture(renderSurfaceFormat, screenWidth, screenHeight).RTV().Mips(4).Array(5);
pass.mipArrayRT->SetName((L"mipArrayRT" + nameSuffix[i]).c_str());
@@ -457,6 +469,10 @@ float4 main(v2f vertIn, uint primId : SV_PrimitiveID, uint sampleId : SV_SampleI
depthState.StencilEnable = FALSE;
pass.backgroundPipe = baselinePSO;
depthState.StencilEnable = FALSE;
pass.depth16Pipe = baselinePSO.DSV(DXGI_FORMAT_D16_UNORM);
baselinePSO.DSV(depthFormat);
depthState.StencilEnable = TRUE;
pass.noPsPipe = baselinePSO.PS(NULL);
@@ -526,6 +542,8 @@ float4 main(v2f vertIn, uint primId : SV_PrimitiveID, uint sampleId : SV_SampleI
pushMarker(cmd, pass.markerName);
ResourceBarrier(cmd, pass.main16DS, D3D12_RESOURCE_STATE_COMMON,
D3D12_RESOURCE_STATE_DEPTH_WRITE);
ResourceBarrier(cmd, pass.mainDS, D3D12_RESOURCE_STATE_COMMON,
D3D12_RESOURCE_STATE_DEPTH_WRITE);
ResourceBarrier(cmd, pass.mainRT, D3D12_RESOURCE_STATE_COMMON,
@@ -637,6 +655,15 @@ float4 main(v2f vertIn, uint primId : SV_PrimitiveID, uint sampleId : SV_SampleI
cmd->OMSetDepthBounds(0.15f, 1.0f);
cmd->DrawInstanced(6 * 3, 1, 45, 0);
cmd->OMSetRenderTargets(1, &pass.mainRTV, FALSE, &pass.main16DSV);
setMarker(cmd, "Clear Depth 16-bit");
cmd->ClearDepthStencilView(pass.main16DSV, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, NULL);
setMarker(cmd, "Depth 16-bit Test");
cmd->SetPipelineState(pass.depth16Pipe);
cmd->DrawInstanced(3, 1, 69, 0);
ResourceBarrier(cmd, pass.main16DS, D3D12_RESOURCE_STATE_DEPTH_WRITE,
D3D12_RESOURCE_STATE_COMMON);
{
pushMarker(cmd, "Begin MSAA");
@@ -93,6 +93,7 @@ class D3D12_Pixel_History(rdtest.TestCase):
dynamic_stencil_ref_eid = self.find_action("Dynamic Stencil Ref", begin_renderpass_eid).next.eventId
dynamic_stencil_mask_eid = self.find_action("Dynamic Stencil Mask", begin_renderpass_eid).next.eventId
depth_test_eid = self.find_action("Depth Test", begin_renderpass_eid).next.eventId
depth_16bit_test_eid = self.find_action("Depth 16-bit Test", begin_renderpass_eid).next.eventId
depth_bounds_prep_eid = self.find_action("Depth Bounds Prep", begin_renderpass_eid).next.eventId
depth_bounds_clip_eid = self.find_action("Depth Bounds Clip", begin_renderpass_eid).next.eventId
@@ -258,6 +259,21 @@ class D3D12_Pixel_History(rdtest.TestCase):
self.check_events(events, modifs, False)
self.check_pixel_value(tex, x, y, get_post_mod_color(modifs[-1]), sub=sub, cast=rt.typeCast)
# For pixel 70, 100 inside the yellow triangle rendered with 16-bit depth
rdtest.log.print("Testing 16-bit depth format")
self.controller.SetFrameEvent(depth_16bit_test_eid, True)
x, y = 70, 100
rdtest.log.print("Testing pixel {}, {}".format(x, y))
modifs: List[rd.PixelModification] = self.controller.PixelHistory(tex, x, y, sub, rt.typeCast)
events = [
[[event_id, begin_renderpass_eid], [passed, True]],
[[event_id, depth_16bit_test_eid], [primitive_id, 0], [depth_test_failed, False],
[get_shader_out_color, (1.0, 1.0, 0.0, 2.75)], [get_shader_out_depth, 0.33], [get_post_mod_color, (1.0, 1.0, 0.0, 1.0)],
[get_post_mod_depth, 0.33]],
]
self.check_events(events, modifs, False)
self.check_pixel_value(tex, x, y, get_post_mod_color(modifs[-1]), sub=sub, cast=rt.typeCast)
def multisampled_image_test(self, pass_name: str):
begin_pass_action = self.find_action(pass_name)
if begin_pass_action is None:
@@ -424,6 +440,8 @@ class D3D12_Pixel_History(rdtest.TestCase):
stencil_write_eid = self.find_action("Stencil Write", begin_renderpass_eid).next.eventId
unbound_fs_eid = self.find_action("Unbound Fragment Shader", begin_renderpass_eid).next.eventId
background_eid = self.find_action("Background", begin_renderpass_eid).next.eventId
clear_depth_16bit_eid = self.find_action("Clear Depth 16-bit", begin_renderpass_eid).next.eventId
depth_16bit_test_eid = self.find_action("Depth 16-bit Test", begin_renderpass_eid).next.eventId
test_eid = self.find_action("Test Begin", begin_renderpass_eid).next.eventId
x, y = 200, 190
@@ -448,6 +466,32 @@ class D3D12_Pixel_History(rdtest.TestCase):
]
self.check_events(events, modifs, False)
# For pixel 70, 100 inside the yellow triangle rendered with 16-bit depth
rdtest.log.print("Testing 16-bit depth format")
self.controller.SetFrameEvent(depth_16bit_test_eid, True)
pipe: rd.PipeState = self.controller.GetPipelineState()
rt: rd.BoundResource = pipe.GetDepthTarget()
tex = rt.resourceId
tex_details = self.get_texture(tex)
sub = rd.Subresource()
if tex_details.arraysize > 1:
sub.slice = rt.firstSlice
if tex_details.mips > 1:
sub.mip = rt.firstMip
x, y = 70, 100
rdtest.log.print("Testing pixel {}, {}".format(x, y))
modifs: List[rd.PixelModification] = self.controller.PixelHistory(tex, x, y, sub, rt.typeCast)
events = [
[[event_id, clear_depth_16bit_eid], [passed, True]],
[[event_id, depth_16bit_test_eid], [passed, True], [primitive_id, 0], [depth_test_failed, False],
[get_shader_out_depth, 0.33], [get_post_mod_depth, 0.33]],
]
self.check_events(events, modifs, False)
def check_events(self, events, modifs, hasSecondary):
self.check(len(modifs) == len(events), "Expected {} events, got {}".format(len(events), len(modifs)))
# Check for consistency first. For secondary command buffers,