summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d12/resource-d3d12.cpp
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2022-05-17 10:56:14 -0700
committerGitHub <noreply@github.com>2022-05-17 10:56:14 -0700
commit5a3aa6159e0ef0241b528812e1d138f0d7055f22 (patch)
tree71d286e06030ee73f0b739e071cd58dd05d507d1 /tools/gfx/d3d12/resource-d3d12.cpp
parent716e75b9ed1acfaee3dc7f3bc347ad17fca65e05 (diff)
Split render-d3d12.h/cpp into a set of smaller files (#2231)
* Split render-d3d12 into numerous smaller files to make the code easier to parse * Added all new D3D12 files created from splitting render-d3d12 * Fixed several uses of attachment still floating around; Changed resource-d3d12 and descriptor-heap-d3d12 to match naming conventions of new d3d12 implementation header files * Readded files with name changes because changing them from inside VS apparently results in them being treated as new files * Merged in externals changes from master * Small cleanup changes * Rerun CI Co-authored-by: Theresa Foley <10618364+tangent-vector@users.noreply.github.com>
Diffstat (limited to 'tools/gfx/d3d12/resource-d3d12.cpp')
-rw-r--r--tools/gfx/d3d12/resource-d3d12.cpp146
1 files changed, 0 insertions, 146 deletions
diff --git a/tools/gfx/d3d12/resource-d3d12.cpp b/tools/gfx/d3d12/resource-d3d12.cpp
deleted file mode 100644
index 7329b28fd..000000000
--- a/tools/gfx/d3d12/resource-d3d12.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-// resource-d3d12.cpp
-#include "resource-d3d12.h"
-
-namespace gfx {
-using namespace Slang;
-
-/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12BarrierSubmitter !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-
-void D3D12BarrierSubmitter::_flush()
-{
- assert(m_numBarriers > 0);
-
- if (m_commandList)
- {
- m_commandList->ResourceBarrier(UINT(m_numBarriers), m_barriers);
- }
- m_numBarriers = 0;
-}
-
-D3D12_RESOURCE_BARRIER& D3D12BarrierSubmitter::_expandOne()
-{
- _flush();
- return m_barriers[m_numBarriers++];
-}
-
-void D3D12BarrierSubmitter::transition(ID3D12Resource* resource, D3D12_RESOURCE_STATES prevState, D3D12_RESOURCE_STATES nextState)
-{
- if (nextState != prevState)
- {
- D3D12_RESOURCE_BARRIER& barrier = expandOne();
-
- const UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
- const D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
-
- ::memset(&barrier, 0, sizeof(barrier));
- barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
- barrier.Flags = flags;
- barrier.Transition.pResource = resource;
- barrier.Transition.StateBefore = prevState;
- barrier.Transition.StateAfter = nextState;
- barrier.Transition.Subresource = subresource;
- }
- else
- {
- if (nextState == D3D12_RESOURCE_STATE_UNORDERED_ACCESS)
- {
- D3D12_RESOURCE_BARRIER& barrier = expandOne();
-
- ::memset(&barrier, 0, sizeof(barrier));
- barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
- barrier.UAV.pResource = resource;
- }
- }
-}
-
-/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12ResourceBase !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-
-/* static */DXGI_FORMAT D3D12ResourceBase::calcFormat(D3DUtil::UsageType usage, ID3D12Resource* resource)
-{
- return resource ? D3DUtil::calcFormat(usage, resource->GetDesc().Format) : DXGI_FORMAT_UNKNOWN;
-}
-
-void D3D12ResourceBase::transition(
- D3D12_RESOURCE_STATES oldState,
- D3D12_RESOURCE_STATES nextState,
- D3D12BarrierSubmitter& submitter)
-{
- // Transition only if there is a resource
- if (m_resource && oldState != nextState)
- {
- submitter.transition(m_resource, oldState, nextState);
- }
-}
-
-/* !!!!!!!!!!!!!!!!!!!!!!!!! D3D12Resource !!!!!!!!!!!!!!!!!!!!!!!! */
-
-/* static */void D3D12Resource::setDebugName(ID3D12Resource* resource, const char* name)
-{
- if (resource)
- {
- resource->SetName(String(name).toWString().begin());
- }
-}
-
-void D3D12Resource::setDebugName(const char* name)
-{
- setDebugName(m_resource, name);
-}
-
-void D3D12Resource::setDebugName(const wchar_t* name)
-{
- if (m_resource)
- {
- m_resource->SetName(name);
- }
-}
-
-void D3D12Resource::setResource(ID3D12Resource* resource)
-{
- if (resource != m_resource)
- {
- if (resource)
- {
- resource->AddRef();
- }
- if (m_resource)
- {
- m_resource->Release();
- }
- m_resource = resource;
- }
-}
-
-void D3D12Resource::setResourceNull()
-{
- if (m_resource)
- {
- m_resource->Release();
- m_resource = nullptr;
- }
-}
-
-Result D3D12Resource::initCommitted(ID3D12Device* device, const D3D12_HEAP_PROPERTIES& heapProps, D3D12_HEAP_FLAGS heapFlags, const D3D12_RESOURCE_DESC& resourceDesc, D3D12_RESOURCE_STATES initState, const D3D12_CLEAR_VALUE * clearValue)
-{
- setResourceNull();
- ComPtr<ID3D12Resource> resource;
- SLANG_RETURN_ON_FAIL(device->CreateCommittedResource(&heapProps, heapFlags, &resourceDesc, initState, clearValue, IID_PPV_ARGS(resource.writeRef())));
- setResource(resource);
- return SLANG_OK;
-}
-
-ID3D12Resource* D3D12Resource::detach()
-{
- ID3D12Resource* resource = m_resource;
- m_resource = nullptr;
- return resource;
-}
-
-void D3D12Resource::swap(ComPtr<ID3D12Resource>& resourceInOut)
-{
- ID3D12Resource* tmp = m_resource;
- m_resource = resourceInOut.detach();
- resourceInOut.attach(tmp);
-}
-
-} // renderer_test