From f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Oct 2024 14:49:26 +0800 Subject: format * format * Minor test fixes * enable checking cpp format in ci --- tools/gfx/d3d12/d3d12-resource.cpp | 123 +++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 52 deletions(-) (limited to 'tools/gfx/d3d12/d3d12-resource.cpp') diff --git a/tools/gfx/d3d12/d3d12-resource.cpp b/tools/gfx/d3d12/d3d12-resource.cpp index 8975f5825..273e14f29 100644 --- a/tools/gfx/d3d12/d3d12-resource.cpp +++ b/tools/gfx/d3d12/d3d12-resource.cpp @@ -1,29 +1,34 @@ // d3d12-resource.cpp #include "d3d12-resource.h" -namespace gfx { +namespace gfx +{ using namespace Slang; -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12BarrierSubmitter !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12BarrierSubmitter + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ void D3D12BarrierSubmitter::_flush() { - assert(m_numBarriers > 0); + assert(m_numBarriers > 0); - if (m_commandList) - { - m_commandList->ResourceBarrier(UINT(m_numBarriers), m_barriers); - } - 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++]; + _flush(); + return m_barriers[m_numBarriers++]; } -void D3D12BarrierSubmitter::transition(ID3D12Resource* resource, D3D12_RESOURCE_STATES prevState, D3D12_RESOURCE_STATES nextState) +void D3D12BarrierSubmitter::transition( + ID3D12Resource* resource, + D3D12_RESOURCE_STATES prevState, + D3D12_RESOURCE_STATES nextState) { if (nextState != prevState) { @@ -53,11 +58,13 @@ void D3D12BarrierSubmitter::transition(ID3D12Resource* resource, D3D12_RESOURCE_ } } -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12ResourceBase !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12ResourceBase + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -/* static */DXGI_FORMAT D3D12ResourceBase::calcFormat(D3DUtil::UsageType usage, ID3D12Resource* resource) +/* static */ DXGI_FORMAT +D3D12ResourceBase::calcFormat(D3DUtil::UsageType usage, ID3D12Resource* resource) { - return resource ? D3DUtil::calcFormat(usage, resource->GetDesc().Format) : DXGI_FORMAT_UNKNOWN; + return resource ? D3DUtil::calcFormat(usage, resource->GetDesc().Format) : DXGI_FORMAT_UNKNOWN; } void D3D12ResourceBase::transition( @@ -65,16 +72,16 @@ void D3D12ResourceBase::transition( D3D12_RESOURCE_STATES nextState, D3D12BarrierSubmitter& submitter) { - // Transition only if there is a resource + // 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) +/* static */ void D3D12Resource::setDebugName(ID3D12Resource* resource, const char* name) { if (resource) { @@ -84,63 +91,75 @@ void D3D12ResourceBase::transition( void D3D12Resource::setDebugName(const char* name) { - setDebugName(m_resource, name); + setDebugName(m_resource, name); } void D3D12Resource::setDebugName(const wchar_t* name) { - if (m_resource) - { - m_resource->SetName(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; - } + 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; - } + 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) +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 resource; - SLANG_RETURN_ON_FAIL(device->CreateCommittedResource(&heapProps, heapFlags, &resourceDesc, initState, clearValue, IID_PPV_ARGS(resource.writeRef()))); - setResource(resource); - return SLANG_OK; + setResourceNull(); + ComPtr 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; + ID3D12Resource* resource = m_resource; + m_resource = nullptr; + return resource; } void D3D12Resource::swap(ComPtr& resourceInOut) { - ID3D12Resource* tmp = m_resource; - m_resource = resourceInOut.detach(); - resourceInOut.attach(tmp); + ID3D12Resource* tmp = m_resource; + m_resource = resourceInOut.detach(); + resourceInOut.attach(tmp); } -} // renderer_test +} // namespace gfx -- cgit v1.2.3