ID3D12GraphicsCommandList interface
Encapsulates a list of graphics commands for rendering. Includes APIs for instrumenting the command list execution, and for setting and clearing the pipeline state.
Members
The ID3D12GraphicsCommandList interface inherits from ID3D12CommandList. ID3D12GraphicsCommandList also has these types of members:
Methods
The ID3D12GraphicsCommandList interface has these methods.
| Method | Description |
|---|---|
| BeginEvent |
Not intended to be called directly. Use the PIX event runtime to insert events into a command list. |
| BeginQuery |
Starts a query running. |
| ClearDepthStencilView |
Clears the depth-stencil resource. |
| ClearRenderTargetView |
Sets all the elements in a render target to one value. |
| ClearState |
Resets the state of a direct command list back to the state it was in when the command list was created. |
| ClearUnorderedAccessViewFloat |
Sets all the elements in a unordered access view to the specified float values. |
| ClearUnorderedAccessViewUint |
Sets all the elements in a unordered-access view to the specified integer values. |
| Close |
Indicates that recording to the command list has finished. |
| CopyBufferRegion |
Copies a region of a buffer from one resource to another. |
| CopyResource |
Copies the entire contents of the source resource to the destination resource. |
| CopyTextureRegion |
This method uses the GPU to copy texture data between two locations. Both the source and the destination may reference texture data located within either a buffer resource or a texture resource. |
| CopyTiles |
Copies tiles from buffer to tiled resource or vice versa. |
| DiscardResource |
Discards a resource. |
| Dispatch |
Executes a command list from a thread group. |
| DrawIndexedInstanced |
Draws indexed, instanced primitives. |
| DrawInstanced |
Draws non-indexed, instanced primitives. |
| EndEvent |
Not intended to be called directly. Use the PIX event runtime to insert events into a command list. |
| EndQuery |
Ends a running query. |
| ExecuteBundle |
Executes a bundle. |
| ExecuteIndirect |
Apps perform indirect draws/dispatches using the ExecuteIndirect method. |
| IASetIndexBuffer |
Sets the view for the index buffer. |
| IASetPrimitiveTopology |
Bind information about the primitive type, and data order that describes input data for the input assembler stage. |
| IASetVertexBuffers |
Sets a CPU descriptor handle for the vertex buffers. |
| OMSetBlendFactor |
Sets the blend factor that modulate values for a pixel shader, render target, or both. |
| OMSetRenderTargets |
Sets CPU descriptor handles for the render targets and depth stencil. |
| OMSetStencilRef |
Sets the reference value for depth stencil tests. |
| Reset |
Resets a command list back to its initial state as if a new command list was just created. |
| ResolveQueryData |
Extracts data from a query. ResolveQueryData works with all heap types (default, upload, and readback). |
| ResolveSubresource |
Copy a multi-sampled resource into a non-multi-sampled resource. |
| ResourceBarrier |
Notifies the driver that it needs to synchronize multiple accesses to resources. |
| RSSetScissorRects |
Binds an array of scissor rectangles to the rasterizer stage. |
| RSSetViewports |
Bind an array of viewports to the rasterizer stage of the pipeline. |
| SetComputeRoot32BitConstant |
Sets a constant in the compute root signature. |
| SetComputeRoot32BitConstants |
Sets a group of constants in the compute root signature. |
| SetComputeRootConstantBufferView |
Sets a CPU descriptor handle for the constant buffer in the compute root signature. |
| SetComputeRootDescriptorTable |
Sets a descriptor table into the compute root signature. |
| SetComputeRootShaderResourceView |
Sets a CPU descriptor handle for the shader resource in the compute root signature. |
| SetComputeRootSignature |
Sets the layout of the compute root signature. |
| SetComputeRootUnorderedAccessView |
Sets a CPU descriptor handle for the unordered-access-view resource in the compute root signature. |
| SetDescriptorHeaps |
Changes the currently bound descriptor heaps that are associated with a command list. |
| SetGraphicsRoot32BitConstant |
Sets a constant in the graphics root signature. |
| SetGraphicsRoot32BitConstants |
Sets a group of constants in the graphics root signature. |
| SetGraphicsRootConstantBufferView |
Sets a CPU descriptor handle for the constant buffer in the graphics root signature. |
| SetGraphicsRootDescriptorTable |
Sets a descriptor table into the graphics root signature. |
| SetGraphicsRootShaderResourceView |
Sets a CPU descriptor handle for the shader resource in the graphics root signature. |
| SetGraphicsRootSignature |
Sets the layout of the graphics root signature. |
| SetGraphicsRootUnorderedAccessView |
Sets a CPU descriptor handle for the unordered-access-view resource in the graphics root signature. |
| SetMarker |
Not intended to be called directly. Use the PIX event runtime to insert events into a command list. |
| SetPipelineState |
Sets all shaders and programs most of the fixed-function state of the GPU pipeline. |
| SetPredication |
Sets a rendering predicate. |
| SOSetTargets |
Sets the stream output buffer views. |
Remarks
This interface is new to D3D12, encapsulating much of the functionality of the ID3D11CommandList interface, and including the new functionality described in Rendering.
Examples
The D3D12nBodyGravity sample uses ID3D12GraphicsCommandList as follows:
Declare the pipeline objects.
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;
Populating command lists.
// 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()); }
Refer to the Example Code in the D3D12 Reference.
Requirements
|
Header |
|
|---|---|
|
Library |
|
|
DLL |
|
See also