Particles/Particles.cpp
//-----------------------------------------------------------------------------
// Initialize UI resources
// create SRV heap and root signature
// device comes from the Render object
//-----------------------------------------------------------------------------
Initialize UI resources
create SRV heap and root signature
device comes from the Render object
Initialize UI resources create SRV heap and root signature device comes from the Render object
void Particles::InitGui()
{
    if (!m_enableUI)
    {
        return;
    }
    m_srvHeap.Reset();
    ID3D12Device* pDevice = m_pRender->GetDevice();
    D3D12_DESCRIPTOR_HEAP_DESC srvHeapDesc = {};
    srvHeapDesc.NumDescriptors = 128; 
    srvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
    srvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
    ThrowIfFailed(pDevice->CreateDescriptorHeap(&srvHeapDesc, IID_PPV_ARGS(&m_srvHeap)));
    CD3DX12_CPU_DESCRIPTOR_HANDLE cpu(m_srvHeap->GetCPUDescriptorHandleForHeapStart());
    CD3DX12_GPU_DESCRIPTOR_HANDLE gpu(m_srvHeap->GetGPUDescriptorHandleForHeapStart());
    ImGui_ImplDX12_Shutdown();
    ImGui_ImplDX12_Init(
        pDevice,
        Render::GetNumFrames(),
        DXGI_FORMAT_R8G8B8A8_UNORM,
        cpu.Offset(0, pDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)),
        gpu.Offset(0, pDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)));
    ImGui_ImplDX12_CreateDeviceObjects();
}
void Particles :: InitGui ( ) { if ( ! m_enableUI ) { return ; } m_srvHeap . Reset ( ) ; ID3D12Device * pDevice = m_pRender -> GetDevice ( ) ; D3D12_DESCRIPTOR_HEAP_DESC srvHeapDesc = { } ; srvHeapDesc . NumDescriptors = 128 ; srvHeapDesc . Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ; srvHeapDesc . Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE ; ThrowIfFailed ( pDevice -> CreateDescriptorHeap ( & srvHeapDesc , IID_PPV_ARGS ( & m_srvHeap ) ) ) ; CD3DX12_CPU_DESCRIPTOR_HANDLE cpu ( m_srvHeap -> GetCPUDescriptorHandleForHeapStart ( ) ) ; CD3DX12_GPU_DESCRIPTOR_HANDLE gpu ( m_srvHeap -> GetGPUDescriptorHandleForHeapStart ( ) ) ; ImGui_ImplDX12_Shutdown ( ) ; ImGui_ImplDX12_Init ( pDevice , Render :: GetNumFrames ( ) , DXGI_FORMAT_R8G8B8A8_UNORM , cpu . Offset ( 0 , pDevice -> GetDescriptorHandleIncrementSize ( D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ) ) , gpu . Offset ( 0 , pDevice -> GetDescriptorHandleIncrementSize ( D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ) ) ) ; ImGui_ImplDX12_CreateDeviceObjects ( ) ; }
Initialize UI resources
create SRV heap and root signature
device comes from the Render object
Initialize UI resources create SRV heap and root signature device comes from the Render object
// Describe and create a shader resource view (SRV) heap for the texture. // FIXME: enough?