summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d12/resource-d3d12.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-03-04 16:25:58 -0800
committerGitHub <noreply@github.com>2021-03-04 16:25:58 -0800
commita5ac4999b4dea546a7ef824669ab1809224b6448 (patch)
tree15bb22eb98a94f7f81489deef55396461501d3dc /tools/gfx/d3d12/resource-d3d12.cpp
parent13ff0bd345990c0fdfb7b52ebd5339cddb04889e (diff)
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 <yhe@nvidia.com>
Diffstat (limited to 'tools/gfx/d3d12/resource-d3d12.cpp')
-rw-r--r--tools/gfx/d3d12/resource-d3d12.cpp22
1 files changed, 8 insertions, 14 deletions
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<ID3D12Resource> 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<ID3D12Resource>& resourceInOut)
resourceInOut.attach(tmp);
}
-void D3D12Resource::setState(D3D12_RESOURCE_STATES state)
-{
- m_prevState = state;
- m_state = state;
-}
-
} // renderer_test