mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-06 06:33:30 +00:00
Only Increment Serials When Necessary On D3D12
Only increments last submitted and last completed serials from the D3D12 backend when commands were submitted to the GPU. Bug: dawn:119 Change-Id: I01748b7f4ac90443adac4cdef29016184f992e9c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32162 Commit-Queue: Brandon Jones <brandon1.jones@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
bc6a700bf5
commit
b6f4d53126
@ -238,6 +238,8 @@ namespace dawn_native {
|
||||
// still check if we have pending work to take care of, rather than hanging and never
|
||||
// reaching the serial the work will be executed on.
|
||||
void AddFutureSerial(ExecutionSerial serial);
|
||||
// Check for passed fences and set the new completed serial
|
||||
void CheckPassedSerials();
|
||||
|
||||
virtual uint32_t GetOptimalBytesPerRowAlignment() const = 0;
|
||||
virtual uint64_t GetOptimalBufferToTextureCopyOffsetAlignment() const = 0;
|
||||
@ -251,8 +253,6 @@ namespace dawn_native {
|
||||
|
||||
// Incrememt mLastSubmittedSerial when we submit the next serial
|
||||
void IncrementLastSubmittedCommandSerial();
|
||||
// Check for passed fences and set the new completed serial
|
||||
void CheckPassedSerials();
|
||||
|
||||
private:
|
||||
virtual ResultOrError<BindGroupBase*> CreateBindGroupImpl(
|
||||
|
@ -228,8 +228,11 @@ namespace dawn_native { namespace d3d12 {
|
||||
mRenderTargetViewAllocator->Tick(completedSerial);
|
||||
mDepthStencilViewAllocator->Tick(completedSerial);
|
||||
mUsedComObjectRefs.ClearUpTo(completedSerial);
|
||||
DAWN_TRY(ExecutePendingCommandContext());
|
||||
DAWN_TRY(NextSerial());
|
||||
|
||||
if (mPendingCommands.IsOpen()) {
|
||||
DAWN_TRY(ExecutePendingCommandContext());
|
||||
DAWN_TRY(NextSerial());
|
||||
}
|
||||
|
||||
DAWN_TRY(CheckDebugLayerAndGenerateErrors());
|
||||
|
||||
@ -256,7 +259,13 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
ExecutionSerial Device::CheckAndUpdateCompletedSerials() {
|
||||
return ExecutionSerial(mFence->GetCompletedValue());
|
||||
ExecutionSerial completeSerial = ExecutionSerial(mFence->GetCompletedValue());
|
||||
|
||||
if (completeSerial <= GetCompletedCommandSerial()) {
|
||||
return ExecutionSerial(0);
|
||||
}
|
||||
|
||||
return completeSerial;
|
||||
}
|
||||
|
||||
void Device::ReferenceUntilUnused(ComPtr<IUnknown> object) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/Toggles.h"
|
||||
#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
|
||||
#include "dawn_native/d3d12/DeviceD3D12.h"
|
||||
@ -230,13 +231,16 @@ TEST_P(D3D12DescriptorHeapTests, PoolHeapsInMultipleSubmits) {
|
||||
|
||||
EXPECT_EQ(allocator->GetShaderVisiblePoolSizeForTesting(), 0u);
|
||||
|
||||
// Allocate + Tick() up to |kFrameDepth| and ensure heaps are always unique.
|
||||
// Allocate + increment internal serials up to |kFrameDepth| and ensure heaps are always unique.
|
||||
for (uint32_t i = 0; i < kFrameDepth; i++) {
|
||||
EXPECT_TRUE(allocator->AllocateAndSwitchShaderVisibleHeap().IsSuccess());
|
||||
ComPtr<ID3D12DescriptorHeap> heap = allocator->GetShaderVisibleHeap();
|
||||
EXPECT_TRUE(std::find(heaps.begin(), heaps.end(), heap) == heaps.end());
|
||||
heaps.push_back(heap);
|
||||
mD3DDevice->Tick();
|
||||
// CheckPassedSerials() will update the last internally completed serial.
|
||||
mD3DDevice->CheckPassedSerials();
|
||||
// NextSerial() will increment the last internally submitted serial.
|
||||
EXPECT_TRUE(mD3DDevice->NextSerial().IsSuccess());
|
||||
}
|
||||
|
||||
// Repeat up to |kFrameDepth| again but ensure heaps are the same in the expected order
|
||||
@ -247,7 +251,8 @@ TEST_P(D3D12DescriptorHeapTests, PoolHeapsInMultipleSubmits) {
|
||||
ComPtr<ID3D12DescriptorHeap> heap = allocator->GetShaderVisibleHeap();
|
||||
EXPECT_TRUE(heaps.front() == heap);
|
||||
heaps.pop_front();
|
||||
mD3DDevice->Tick();
|
||||
mD3DDevice->CheckPassedSerials();
|
||||
EXPECT_TRUE(mD3DDevice->NextSerial().IsSuccess());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(heaps.empty());
|
||||
|
Loading…
x
Reference in New Issue
Block a user