From a5ac4999b4dea546a7ef824669ab1809224b6448 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 4 Mar 2021 16:25:58 -0800 Subject: Refactor `gfx` to surface `CommandBuffer` interface. (#1735) * Refactor `gfx` to surface `CommandBuffer` interface. * Fixes. * Fix code review issues, and make vulkan runnable on devices without VK_EXT_extended_dynamic_states. * Update solution files * Move out-of-date examples to examples/experimental Co-authored-by: Yong He --- tools/gfx/d3d12/resource-d3d12.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'tools/gfx/d3d12/resource-d3d12.cpp') diff --git a/tools/gfx/d3d12/resource-d3d12.cpp b/tools/gfx/d3d12/resource-d3d12.cpp index 27de868b6..397eee665 100644 --- a/tools/gfx/d3d12/resource-d3d12.cpp +++ b/tools/gfx/d3d12/resource-d3d12.cpp @@ -60,13 +60,15 @@ void D3D12BarrierSubmitter::transition(ID3D12Resource* resource, D3D12_RESOURCE_ return resource ? D3DUtil::calcFormat(usage, resource->GetDesc().Format) : DXGI_FORMAT_UNKNOWN; } -void D3D12ResourceBase::transition(D3D12_RESOURCE_STATES nextState, D3D12BarrierSubmitter& submitter) +void D3D12ResourceBase::transition( + D3D12_RESOURCE_STATES oldState, + D3D12_RESOURCE_STATES nextState, + D3D12BarrierSubmitter& submitter) { // Transition only if there is a resource - if (m_resource) + if (m_resource && oldState != nextState) { - submitter.transition(m_resource, m_state, nextState); - m_state = nextState; + submitter.transition(m_resource, oldState, nextState); } } @@ -155,7 +157,7 @@ void D3D12Resource::setDebugName(const wchar_t* name) } } -void D3D12Resource::setResource(ID3D12Resource* resource, D3D12_RESOURCE_STATES initialState) +void D3D12Resource::setResource(ID3D12Resource* resource) { if (resource != m_resource) { @@ -169,8 +171,6 @@ void D3D12Resource::setResource(ID3D12Resource* resource, D3D12_RESOURCE_STATES } m_resource = resource; } - m_prevState = initialState; - m_state = initialState; } void D3D12Resource::setResourceNull() @@ -187,7 +187,7 @@ Result D3D12Resource::initCommitted(ID3D12Device* device, const D3D12_HEAP_PROPE setResourceNull(); ComPtr resource; SLANG_RETURN_ON_FAIL(device->CreateCommittedResource(&heapProps, heapFlags, &resourceDesc, initState, clearValue, IID_PPV_ARGS(resource.writeRef()))); - setResource(resource, initState); + setResource(resource); return SLANG_OK; } @@ -205,10 +205,4 @@ void D3D12Resource::swap(ComPtr& resourceInOut) resourceInOut.attach(tmp); } -void D3D12Resource::setState(D3D12_RESOURCE_STATES state) -{ - m_prevState = state; - m_state = state; -} - } // renderer_test -- cgit v1.2.3