[idd] capture: define immutable texture products

This commit is contained in:
Geoffrey McRae
2026-08-13 15:12:41 +10:00
parent a8eb49fb17
commit 3dd5abb05e
8 changed files with 816 additions and 16 deletions

View File

@@ -236,8 +236,11 @@ void CD3D12CommandSlot::Cancel()
SetEvent(m_availableEvent.Get());
}
bool CD3D12CommandSlot::Execute()
bool CD3D12CommandSlot::Execute(D12Sync * sync)
{
if (sync)
*sync = D12Sync {};
State expected = STATE_RECORDING;
if (!Atomic::CAS(m_state, expected, STATE_SUBMITTED,
std::memory_order_acq_rel))
@@ -256,7 +259,7 @@ bool CD3D12CommandSlot::Execute()
return false;
}
if (m_queue->Submit(*this))
if (m_queue->Submit(*this, sync))
return true;
if (!Atomic::Load(m_submitted, std::memory_order_acquire))
@@ -572,7 +575,7 @@ void CD3D12CommandQueue::WaitForIdle()
}
}
bool CD3D12CommandQueue::Submit(CD3D12CommandSlot& slot)
bool CD3D12CommandQueue::Submit(CD3D12CommandSlot& slot, D12Sync * sync)
{
bool result = false;
CSRWExclusiveLock lock(m_submitLock);
@@ -612,6 +615,14 @@ bool CD3D12CommandQueue::Submit(CD3D12CommandSlot& slot)
break;
}
// Capture the immutable point while submission is serialized. The slot
// may complete and be acquired again as soon as we leave this scope.
if (sync)
{
sync->fence = m_fence;
sync->value = fenceTarget;
}
hr = m_fence->SetEventOnCompletion(fenceTarget, slot.m_event.Get());
if (FAILED(hr))
{

View File

@@ -35,6 +35,32 @@ using namespace Microsoft::WRL::Wrappers::HandleTraits;
class CD3D12CommandQueue;
enum class D12SyncState : uint8_t
{
PENDING,
READY,
FAILED,
};
struct D12Sync
{
ComPtr<ID3D12Fence> fence;
UINT64 value = 0;
bool Valid() const { return fence && value; }
D12SyncState State() const
{
if (!Valid())
return D12SyncState::FAILED;
const UINT64 completed = fence->GetCompletedValue();
if (completed == UINT64_MAX)
return D12SyncState::FAILED;
return completed >= value ?
D12SyncState::READY : D12SyncState::PENDING;
}
bool Done() const { return State() == D12SyncState::READY; }
};
class CD3D12CommandSlot
{
friend class CD3D12CommandQueue;
@@ -104,7 +130,7 @@ class CD3D12CommandSlot
bool Acquire();
void Cancel();
bool Execute();
bool Execute(D12Sync * sync = nullptr);
bool BeginTiming();
void EndTiming();
@@ -162,7 +188,7 @@ class CD3D12CommandQueue
bool m_timingSupported = false;
bool InitTiming(ID3D12Device3 * device, UINT slotCount);
bool Submit(CD3D12CommandSlot& slot);
bool Submit(CD3D12CommandSlot& slot, D12Sync * sync);
bool SnapshotTiming(CD3D12CommandSlot& slot) const;
bool GetGPUTimes(const CD3D12CommandSlot& slot,
uint64_t& start, uint64_t& end) const;