ID3D12GraphicsCommandList 介面 (d3d12.h)

封裝用於轉譯的圖形命令清單。 包含用來檢測命令清單執行的 API,以及用於設定和清除管線狀態。

注意這個介面的最新版本是 Windows 10 Creators Update 中引進的ID3D12GraphicsCommandList1。 以 Windows 10 Creators Update 為目標的應用程式應該使用 ID3D12GraphicsCommandList1 介面,而不是 ID3D12GraphicsCommandList
 

繼承

ID3D12GraphicsCommandList 介面繼承自 ID3D12CommandListID3D12GraphicsCommandList 也有下列類型的成員:

方法

ID3D12GraphicsCommandList 介面具有這些方法。

 
ID3D12GraphicsCommandList::BeginEvent

不適合直接呼叫。  使用 PIX 事件執行時間將事件插入命令清單中。 (ID3D12GraphicsCommandList.BeginEvent)
ID3D12GraphicsCommandList::BeginQuery

啟動執行中的查詢。 (ID3D12GraphicsCommandList.BeginQuery)
ID3D12GraphicsCommandList::ClearDepthStencilView

清除深度樣板資源。 (ID3D12GraphicsCommandList.ClearDepthStencilView)
ID3D12GraphicsCommandList::ClearRenderTargetView

將轉譯目標中的所有項目設定為一個值。
ID3D12GraphicsCommandList::ClearState

將直接命令清單的狀態重設為建立命令清單時所在的狀態。 (ID3D12GraphicsCommandList.ClearState)
ID3D12GraphicsCommandList::ClearUnorderedAccessViewFloat

將未排序存取檢視中的所有項目設定為指定的浮點值。
ID3D12GraphicsCommandList::ClearUnorderedAccessViewUint

將未排序存取檢視中的所有元素設定為指定的整數值, (UAV) 。
ID3D12GraphicsCommandList::Close

表示命令清單的錄製已完成。 (ID3D12GraphicsCommandList.Close)
ID3D12GraphicsCommandList::CopyBufferRegion

將緩衝區的區域從一個資源複製到另一個資源。
ID3D12GraphicsCommandList::CopyResource

將來源資源的整個內容複製到目的地資源。
ID3D12GraphicsCommandList::CopyTextureRegion

此方法會使用 GPU 在兩個位置之間複製紋理數據。 來源和目的地可能會參考位於緩衝區資源或紋理資源內的紋理數據。
ID3D12GraphicsCommandList::CopyTiles

將磚從緩衝區複製到磚資源,反之亦然。 (ID3D12GraphicsCommandList.CopyTiles)
ID3D12GraphicsCommandList::D iscardResource

捨棄資源。
ID3D12GraphicsCommandList::D ispatch

在線程群組上執行計算著色器。
ID3D12GraphicsCommandList::D rawIndexedInstanced

繪製已編製索引、實例的基本類型。
ID3D12GraphicsCommandList::D rawInstanced

繪製非索引的實例基本類型。
ID3D12GraphicsCommandList::EndEvent

不適合直接呼叫。  使用 PIX 事件執行時間將事件插入命令清單中。 (ID3D12GraphicsCommandList.EndEvent)
ID3D12GraphicsCommandList::EndQuery

結束執行中的查詢。
ID3D12GraphicsCommandList::ExecuteBundle

執行套件組合。
ID3D12GraphicsCommandList::ExecuteIndirect

應用程式會使用ExecuteIndirect方法執行間接繪製/分派。
ID3D12GraphicsCommandList::IASetIndexBuffer

設定索引緩衝區的檢視。
ID3D12GraphicsCommandList::IASetPrimitiveTopology

系結基本類型的相關信息,以及描述輸入組合器階段之輸入數據的數據順序。 (ID3D12GraphicsCommandList.IASetPrimitiveTopology)
ID3D12GraphicsCommandList::IASetVertexBuffers

設定頂點緩衝區的CPU描述元句柄。
ID3D12GraphicsCommandList::OMSetBlendFactor

設定調色器、轉譯目標或兩者之值的混合因數。
ID3D12GraphicsCommandList::OMSetRenderTargets

設定轉譯目標和深度樣板的 CPU 描述元句柄。
ID3D12GraphicsCommandList::OMSetStencilRef

設定深度樣板測試的參考值。
ID3D12GraphicsCommandList::Reset

將命令清單重設為其初始狀態,就像剛建立新的命令清單一樣。 (ID3D12GraphicsCommandList.Reset)
ID3D12GraphicsCommandList::ResolveQueryData

從查詢擷取數據。 ResolveQueryData 適用於所有堆積類型, (默認、上傳和回讀) 。  ResolveQueryData 適用於所有堆積類型, (默認、上傳和回讀) 。 .
ID3D12GraphicsCommandList::ResolveSubresource

將多重取樣資源複製到非多重取樣的資源。
ID3D12GraphicsCommandList::ResourceBarrier

通知驅動程式需要同步處理資源的多個存取。 (ID3D12GraphicsCommandList.ResourceBarrier)
ID3D12GraphicsCommandList::RSSetScissorRects

將剪刀或矩形的陣列系結至點陣化階段。
ID3D12GraphicsCommandList::RSSetViewports

將檢視區陣化階段。 (ID3D12GraphicsCommandList.RSSetViewports)
ID3D12GraphicsCommandList::SetComputeRoot32BitConstant

在計算根簽章中設定常數。
ID3D12GraphicsCommandList::SetComputeRoot32BitConstants

設定計算根簽章中的常數群組。
ID3D12GraphicsCommandList::SetComputeRootConstantBufferView

設定計算根簽章中常數緩衝區的 CPU 描述元句柄。
ID3D12GraphicsCommandList::SetComputeRootDescriptorTable

將描述項數據表設定為計算根簽章。
ID3D12GraphicsCommandList::SetComputeRootShaderResourceView

在計算根簽章中設定著色器資源的 CPU 描述項句柄。
ID3D12GraphicsCommandList::SetComputeRootSignature

設定計算根簽章的配置。
ID3D12GraphicsCommandList::SetComputeRootUnorderedAccessView

在計算根簽章中設定 Unordered-access-view 資源的 CPU 描述項句柄。
ID3D12GraphicsCommandList::SetDescriptorHeaps

變更與命令清單相關聯的目前系結描述項堆積。
ID3D12GraphicsCommandList::SetGraphicsRoot32BitConstant

在圖形根簽章中設定常數。
ID3D12GraphicsCommandList::SetGraphicsRoot32BitConstants

在圖形根簽章中設定常數群組。
ID3D12GraphicsCommandList::SetGraphicsRootConstantBufferView

設定圖形根簽章中常數緩衝區的 CPU 描述項句柄。
ID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable

將描述項數據表設定為圖形根簽章。
ID3D12GraphicsCommandList::SetGraphicsRootShaderResourceView

在圖形根簽章中設定著色器資源的 CPU 描述項句柄。
ID3D12GraphicsCommandList::SetGraphicsRootSignature

設定圖形根簽章的配置。
ID3D12GraphicsCommandList::SetGraphicsRootUnorderedAccessView

在圖形根簽章中設定未排序存取檢視資源的CPU描述項句柄。
ID3D12GraphicsCommandList::SetMarker

不適合直接呼叫。  使用 PIX 事件執行時間,將事件插入命令清單中。 (ID3D12GraphicsCommandList.SetMarker)
ID3D12GraphicsCommandList::SetPipelineState

設定圖形處理單位的所有固定函式狀態, (GPU) 管線的所有著色器和程式。
ID3D12GraphicsCommandList::SetPredication

設定轉譯述詞。
ID3D12GraphicsCommandList::SOSetTargets

設定數據流輸出緩衝區檢視。

備註

這個介面是 D3D12 的新功能,封裝 ID3D11CommandList 介面的大部分功能,包括 譯中所述的新功能。

範例

D3D12nBodyGravity 範例會使用 ID3D12GraphicsCommandList,如下所示:

宣告管線物件。

D3D12_VIEWPORT m_viewport;
D3D12_RECT m_scissorRect;
ComPtr<IDXGISwapChain3> m_swapChain;
ComPtr<ID3D12Device> m_device;
ComPtr<ID3D12Resource> m_renderTargets[FrameCount];
ComPtr<ID3D12CommandAllocator> m_commandAllocator;
ComPtr<ID3D12CommandQueue> m_commandQueue;
ComPtr<ID3D12RootSignature> m_rootSignature;
ComPtr<ID3D12DescriptorHeap> m_rtvHeap;
ComPtr<ID3D12PipelineState> m_pipelineState;
ComPtr<ID3D12GraphicsCommandList> m_commandList;
UINT m_rtvDescriptorSize;

填入命令清單。

// Fill the command list with all the render commands and dependent state.
void D3D12nBodyGravity::PopulateCommandList()
{
    // Command list allocators can only be reset when the associated
    // command lists have finished execution on the GPU; apps should use
    // fences to determine GPU execution progress.
    ThrowIfFailed(m_commandAllocators[m_frameIndex]->Reset());

    // However, when ExecuteCommandList() is called on a particular command
    // list, that command list can then be reset at any time and must be before
    // re-recording.
    ThrowIfFailed(m_commandList->Reset(m_commandAllocators[m_frameIndex].Get(), m_pipelineState.Get()));

    // Set necessary state.
    m_commandList->SetPipelineState(m_pipelineState.Get());
    m_commandList->SetGraphicsRootSignature(m_rootSignature.Get());

    m_commandList->SetGraphicsRootConstantBufferView(RootParameterCB, m_constantBufferGS->GetGPUVirtualAddress() + m_frameIndex * sizeof(ConstantBufferGS));

    ID3D12DescriptorHeap* ppHeaps[] = { m_srvUavHeap.Get() };
    m_commandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps);

    m_commandList->IASetVertexBuffers(0, 1, &m_vertexBufferView);
    m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_POINTLIST);
    m_commandList->RSSetScissorRects(1, &m_scissorRect);

    // Indicate that the back buffer will be used as a render target.
    m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));

    CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart(), m_frameIndex, m_rtvDescriptorSize);
    m_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, nullptr);

    // Record commands.
    const float clearColor[] = { 0.0f, 0.0f, 0.1f, 0.0f };
    m_commandList->ClearRenderTargetView(rtvHandle, clearColor, 0, nullptr);

    // Render the particles.
    float viewportHeight = static_cast<float>(static_cast<UINT>(m_viewport.Height) / m_heightInstances);
    float viewportWidth = static_cast<float>(static_cast<UINT>(m_viewport.Width) / m_widthInstances);
    for (UINT n = 0; n < ThreadCount; n++)
    {
        const UINT srvIndex = n + (m_srvIndex[n] == 0 ? SrvParticlePosVelo0 : SrvParticlePosVelo1);

        D3D12_VIEWPORT viewport;
        viewport.TopLeftX = (n % m_widthInstances) * viewportWidth;
        viewport.TopLeftY = (n / m_widthInstances) * viewportHeight;
        viewport.Width = viewportWidth;
        viewport.Height = viewportHeight;
        viewport.MinDepth = D3D12_MIN_DEPTH;
        viewport.MaxDepth = D3D12_MAX_DEPTH;
        m_commandList->RSSetViewports(1, &viewport);

        CD3DX12_GPU_DESCRIPTOR_HANDLE srvHandle(m_srvUavHeap->GetGPUDescriptorHandleForHeapStart(), srvIndex, m_srvUavDescriptorSize);
        m_commandList->SetGraphicsRootDescriptorTable(RootParameterSRV, srvHandle);

        m_commandList->DrawInstanced(ParticleCount, 1, 0, 0);
    }

    m_commandList->RSSetViewports(1, &m_viewport);

    // Indicate that the back buffer will now be used to present.
    m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));

    ThrowIfFailed(m_commandList->Close());
}

請參閱 D3D12 參考中的範例程式代碼

規格需求

需求
目標平台 Windows
標頭 d3d12.h

另請參閱

核心介面

ID3D12CommandList

ID3D12GraphicsCommandList1