4.8 KiB
Juliet\src\Graphics\D3D12\D3D12CommandList
Source Files
- Header:
Juliet\src\Graphics\D3D12\D3D12CommandList.h - Source:
Juliet\src\Graphics\D3D12\D3D12CommandList.cpp
AI Description
The provided code snippet is a part of a graphics rendering engine, specifically designed for DirectX 12. It includes functions to manage and execute commands in a graphics pipeline. The ExecuteCommandLists function is responsible for submitting multiple command lists to the GPU for execution. Here's a breakdown of what this function does:
Function Overview
- Submit Command Lists: This function takes an array of
NonNullPtr?CommandList?objects, each representing a command list that needs to be executed. - Inflight Fence: It checks if any of the command lists are currently in flight (i.e., they have been submitted but not yet completed).
- Signal Fence: If a command list is not in flight, it signals the fence associated with that command list. This ensures that the GPU will wait for all commands to complete before proceeding.
- Submit Command List: It marks the command list as submitted by incrementing a counter and storing the handle of the fence in the
InFlightFencesarray. - Present Data: For each present operation, it sets up the swap chain texture container and updates the fence reference count.
- Cleanups: It checks for cleanups by comparing the completed value of the fence with the signal value. If they match, it cleanses the command list.
- Index Buffer: It sets the index buffer for rendering operations.
- Push Constants: It sets push constants for shaders.
- Descriptor Heaps: It ensures that descriptor heaps are properly set up before executing commands.
Key Points
- Fence Management: The function uses fences to ensure that all commands in a command list are completed before proceeding with the next one.
- Resource Barriers: It handles resource barriers to transition resources between states (e.g., from
GENERIC_READtoINDEX_BUFFER). - Descriptor Heaps: It ensures that descriptor heaps are properly managed and reused.
- Push Constants: It sets push constants for shaders, which are used in vertex shader stages.
Usage
To use this function, you would typically create an instance of D3D12CommandList, populate it with commands such as drawing primitives, setting viewports, scissor rectangles, and more, and then call ExecuteCommandLists to submit the command list for execution.
// Create a command list
NonNullPtr?CommandList? commandList = Internal::CreateCommandList(d3d12Driver);
// Populate the command list with commands
Internal::SetViewPort(commandList, viewPort);
Internal::SetIndexBuffer(commandList, indexBuffer, IndexFormat::UInt16, indexCount, offset);
// Execute the command list
bool success = Internal::ExecuteCommandLists(d3d12Driver, ?commandList);
This setup ensures that all commands in a command list are executed efficiently and correctly, leveraging DirectX 12's features for efficient resource management and
Symbols
Namespace Juliet::D3D12
Classes, Structs & Unions
struct D3D12CommandListBaseDatastruct D3D12CopyCommandListDatastruct D3D12GraphicsCommandListDatastruct D3D12PresentDatastruct D3D12CommandList
Functions & Methods
extern CommandList* AcquireCommandList(NonNullPtr<GPUDriver> driver, QueueType queueType)extern bool SubmitCommandLists(NonNullPtr<CommandList> commandList)extern void SetViewPort(NonNullPtr<CommandList> commandList, const GraphicsViewPort& viewPort)extern void SetScissorRect(NonNullPtr<CommandList> commandList, const Rectangle& rectangle)extern void SetBlendConstants(NonNullPtr<CommandList> commandList, FColor blendConstants)extern void SetBlendConstants(NonNullPtr<CommandList> commandList, FColor blendConstants)extern void SetStencilReference(NonNullPtr<CommandList> commandList, uint8 reference)extern void SetIndexBuffer(NonNullPtr<CommandList> commandList, NonNullPtr<GraphicsBuffer> buffer, IndexFormat format, size_t indexCount, index_t offset)extern void SetPushConstants(NonNullPtr<CommandList> commandList, ShaderStage stage, uint32 rootParameterIndex, uint32 numConstants, const void* constants)
Namespace Juliet::D3D12::Internal
Functions & Methods
extern void SetDescriptorHeaps(NonNullPtr<D3D12CommandList> commandList)extern void DestroyCommandList(NonNullPtr<D3D12CommandList> commandList)extern bool CleanCommandList(NonNullPtr<D3D12Driver> driver, NonNullPtr<D3D12CommandList> commandList, bool cancel)extern void TrackGraphicsPipeline(NonNullPtr<D3D12CommandList> commandList, NonNullPtr<D3D12GraphicsPipeline> pipeline)extern void TrackTexture(NonNullPtr<D3D12CommandList> commandList, NonNullPtr<D3D12Texture> texture)