MCPcopy Create free account
hub / github.com/carbonengine/trinity / CreateScratch

Method CreateScratch

trinityal/dx12/Tr2ResourceHelper.cpp:130–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130ALResult Tr2ResourceHelper::CreateScratch( Resource& resource, Tr2PrimaryRenderContextAL& renderContext, size_t size )
131{
132 CComPtr<ID3D12Resource> buffer;
133 auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD );
134 auto scratchDesc = BufferDesc( size );
135 CR_RETURN_HR( renderContext.m_device->CreateCommittedResource(
136 &scratchHeap,
137 D3D12_HEAP_FLAG_NONE,
138 &scratchDesc,
139 m_strategy == DYNAMIC ? m_defaultState : D3D12_RESOURCE_STATE_GENERIC_READ,
140 nullptr,
141 IID_PPV_ARGS( &buffer ) ) );
142
143 D3D12_RANGE readRange = { 0, 0 };
144 CR_RETURN_HR( buffer->Map( 0, &readRange, &resource.cpuAddress ) );
145 resource.resource = buffer;
146 resource.frameIndex = renderContext.GetRecordingFrameNumber();
147 resource.gpuAddress = buffer->GetGPUVirtualAddress();
148 if( !m_name.empty() )
149 {
150 SetDebugName( buffer, m_name.c_str() );
151 }
152 return S_OK;
153}
154
155ALResult Tr2ResourceHelper::MapForWriting( void*& data, Tr2LockType::Type lockType, Tr2PrimaryRenderContextAL& renderContext )
156{

Callers

nothing calls this directly

Calls 7

HeapDescFunction · 0.85
BufferDescFunction · 0.85
SetDebugNameFunction · 0.85
GetGPUVirtualAddressMethod · 0.80
emptyMethod · 0.80
MapMethod · 0.45

Tested by

no test coverage detected