Add test for D3D12 descriptor heap allocation lifetimes

Adds a white box test to ensure that D3D12 descriptor heap allocations
only are valid during the serial they are created on.

Bug: dawn:1701
Change-Id: I1e1587ab602d5472fbba9e751bf3cd1e6e5ead11
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132266
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Brandon Jones 2023-05-10 18:51:52 +00:00 committed by Dawn LUCI CQ
parent 48e2b114be
commit dfaeb429f8
1 changed files with 20 additions and 0 deletions

View File

@ -1043,6 +1043,26 @@ TEST_P(D3D12DescriptorHeapTests, AllocateDeallocateMany) {
}
}
// Verifies that gpu descriptor heap allocations are only valid during the serial they were created
// on.
TEST_P(D3D12DescriptorHeapTests, InvalidateAllocationAfterSerial) {
Device* d3dDevice = reinterpret_cast<Device*>(device.Get());
ShaderVisibleDescriptorAllocator* gpuAllocator =
d3dDevice->GetViewShaderVisibleDescriptorAllocator();
GPUDescriptorHeapAllocation gpuHeapDescAllocation;
D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptor;
gpuAllocator->AllocateGPUDescriptors(1, d3dDevice->GetPendingCommandSerial(),
&baseCPUDescriptor, &gpuHeapDescAllocation);
EXPECT_TRUE(gpuAllocator->IsAllocationStillValid(gpuHeapDescAllocation));
EXPECT_TRUE(d3dDevice->NextSerial().IsSuccess());
EXPECT_FALSE(gpuAllocator->IsAllocationStillValid(gpuHeapDescAllocation));
}
DAWN_INSTANTIATE_TEST(D3D12DescriptorHeapTests,
D3D12Backend(),
D3D12Backend({"use_d3d12_small_shader_visible_heap"}));