Particles/Compute.cpp
//-----------------------------------------------------------------------------
// async does things differently
// release shared, placed resources and replace with render device resources.
//-----------------------------------------------------------------------------
async does things differently
release shared, placed resources and replace with render device resources.
async does things differently release shared placed resources and replace with render device resources .
void Compute::SetAsync(
    ComPtr<ID3D12Fence> in_fence,
    ComPtr<ID3D12Resource>* in_buffers,
    UINT in_bufferIndex)
{
    m_sharedRenderFence = in_fence;
    m_bufferIndex = 1-in_bufferIndex;
    D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
    uavDesc.Format = DXGI_FORMAT_UNKNOWN;
    uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
    uavDesc.Buffer.FirstElement = 0;
    uavDesc.Buffer.NumElements = m_numParticles;
    uavDesc.Buffer.StructureByteStride = sizeof(Render::Particle);
    uavDesc.Buffer.CounterOffsetInBytes = 0;
    uavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE;
    for (UINT i = 0; i < m_NUM_BUFFERS; i++)
    {
        m_positionBuffers[i] = in_buffers[i];
        const CD3DX12_CPU_DESCRIPTOR_HANDLE heapHandle(
            m_srvHeap->GetCPUDescriptorHandleForHeapStart(),
            UavParticlePos0 + i,
            m_srvUavDescriptorSize);
        m_device->CreateUnorderedAccessView(m_positionBuffers[i].Get(), nullptr, &uavDesc, heapHandle);
    }
    const CD3DX12_CPU_DESCRIPTOR_HANDLE copyPosHandle(m_srvHeap->GetCPUDescriptorHandleForHeapStart(), UavParticlePos0Copy, m_srvUavDescriptorSize);
    m_device->CreateUnorderedAccessView(m_positionBuffers[0].Get(), nullptr, &uavDesc, copyPosHandle);
}
void Compute :: SetAsync ( ComPtr < ID3D12Fence > in_fence , ComPtr < ID3D12Resource > * in_buffers , UINT in_bufferIndex ) { m_sharedRenderFence = in_fence ; m_bufferIndex = 1 - in_bufferIndex ; D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = { } ; uavDesc . Format = DXGI_FORMAT_UNKNOWN ; uavDesc . ViewDimension = D3D12_UAV_DIMENSION_BUFFER ; uavDesc . Buffer . FirstElement = 0 ; uavDesc . Buffer . NumElements = m_numParticles ; uavDesc . Buffer . StructureByteStride = sizeof ( Render :: Particle ) ; uavDesc . Buffer . CounterOffsetInBytes = 0 ; uavDesc . Buffer . Flags = D3D12_BUFFER_UAV_FLAG_NONE ; for ( UINT i = 0 ; i < m_NUM_BUFFERS ; i ++ ) { m_positionBuffers [ i ] = in_buffers [ i ] ; const CD3DX12_CPU_DESCRIPTOR_HANDLE heapHandle ( m_srvHeap -> GetCPUDescriptorHandleForHeapStart ( ) , UavParticlePos0 + i , m_srvUavDescriptorSize ) ; m_device -> CreateUnorderedAccessView ( m_positionBuffers [ i ] . Get ( ) , nullptr , & uavDesc , heapHandle ) ; } const CD3DX12_CPU_DESCRIPTOR_HANDLE copyPosHandle ( m_srvHeap -> GetCPUDescriptorHandleForHeapStart ( ) , UavParticlePos0Copy , m_srvUavDescriptorSize ) ; m_device -> CreateUnorderedAccessView ( m_positionBuffers [ 0 ] . Get ( ) , nullptr , & uavDesc , copyPosHandle ) ; }
async does things differently
release shared, placed resources and replace with render device resources.
async does things differently release shared placed resources and replace with render device resources .
// replace "my" shared resources with the resources from the render adapter // setting heap[2] = heap[0]