From 3a60f96079c8aa61432dc5591bb178860db9c0b4 Mon Sep 17 00:00:00 2001 From: Li Hao Date: Tue, 15 Feb 2022 02:05:06 +0000 Subject: [PATCH] Reset root descriptor table for samplers when descriptor heaps are changed When shader-visible heap switch happens, we re-populate all bindgroups and change the descriptor heaps, which need to reset root descriptor tables, but for the samplers which are cached in mBoundRootSamplerTables and not changed, they won't be reset, which make shaders cannot access the sampler heaps. Bug: dawn:1255 Change-Id: Icc142206121af9daf8b9352b4c639f7d7ef8f1d3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76780 Reviewed-by: Corentin Wallez Reviewed-by: Austin Eng Commit-Queue: Hao Li --- src/dawn/native/d3d12/CommandBufferD3D12.cpp | 6 ++++++ src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dawn/native/d3d12/CommandBufferD3D12.cpp b/src/dawn/native/d3d12/CommandBufferD3D12.cpp index 0c88d0b239..83efc938a5 100644 --- a/src/dawn/native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn/native/d3d12/CommandBufferD3D12.cpp @@ -390,6 +390,12 @@ namespace dawn::native::d3d12 { ASSERT(descriptorHeaps[0] != nullptr); ASSERT(descriptorHeaps[1] != nullptr); commandList->SetDescriptorHeaps(descriptorHeaps.size(), descriptorHeaps.data()); + + // Descriptor table state is undefined at the beginning of a command list and after + // descriptor heaps are changed on a command list. Invalidate the root sampler tables to + // reset the root descriptor table for samplers, otherwise the shader cannot access the + // descriptor heaps. + mBoundRootSamplerTables = {}; } private: diff --git a/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp index 82fa79d3c8..5223b6648b 100644 --- a/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp +++ b/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp @@ -740,9 +740,6 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) { DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); - // TODO(crbug.com/dawn/1255): Fails on Win11 with D3D12 debug layer and full validation - DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsBackendValidationEnabled()); - // Create a solid filled texture. wgpu::TextureDescriptor descriptor; descriptor.dimension = wgpu::TextureDimension::e2D;