3.7 KiB
Juliet\src\Graphics\D3D12\D3D12GraphicsPipeline
Source Files
- Header:
Juliet\src\Graphics\D3D12\D3D12GraphicsPipeline.h - Source:
Juliet\src\Graphics\D3D12\D3D12GraphicsPipeline.cpp
AI Description
The provided code snippet is a part of a graphics rendering system, specifically for creating and managing graphics pipelines in a DirectX 12 environment. The CreateGraphicsPipeline function takes a GPUDriver object and a GraphicsPipelineCreateInfo structure as input parameters and returns a pointer to the created GraphicsPipeline. This pipeline is responsible for handling vertex and fragment shaders, rasterization, blending, depth/stencil operations, and other rendering states.
Here's a breakdown of the key components and functionalities:
-
Shader Conversion: The function converts the provided vertex and fragment shaders from their Juliet shader format to DirectX 12 shader bytecode. This involves copying the shader data and patching it back after overwriting the bytecode if necessary.
-
Rasterizer State: The rasterizer state is converted from a
GraphicsPipelineCreateInfostructure to aD3D12_RASTERIZER_DESC. This includes settings such as line width, fill mode, depth testing, stencil testing, etc. -
Blend State: Similar to the rasterizer state, the blend state is converted from a
GraphicsPipelineCreateInfostructure to aD3D12_BLEND_STATE. This involves setting up blending factors, operations, and write masks for different color channels. -
Depth Stencil State: The depth stencil state is also converted from a
GraphicsPipelineCreateInfostructure to aD3D12_DEPTH_STENCIL_DESC. This includes settings such as depth enable, write mask, depth function, stencil enable, stencil read/write masks, and stencil operations. -
Pipeline Creation: After converting all the necessary states, the pipeline state is created using the DirectX 12 device's
CreateGraphicsPipelineStatemethod. The resulting pipeline state is stored in theGraphicsPipelineobject. -
Vertex Strides: The function also sets up vertex strides for each vertex buffer description in the
GraphicsPipelineCreateInfo. This helps in determining how much data to read from each vertex buffer when rendering. -
Primitive Type: The primitive type of the pipeline is set based on the provided
GraphicsPipelineCreateInfo. -
Root Signature: The root signature is bound to the pipeline using the
BindlessRootSignatureobject, which likely contains the necessary shader resources and parameters. -
Memory Management: The function handles memory allocation for the
GraphicsPipelineobject and its associated resources such as shaders, vertex buffers, and render targets.
This code snippet is crucial for setting up the rendering pipeline in a DirectX 12 application, ensuring that the graphics are rendered correctly according to the specified requirements.
Symbols
Namespace Juliet::D3D12
Classes, Structs & Unions
struct D3D12GraphicsRootSignaturestruct D3D12GraphicsPipeline
Functions & Methods
extern GraphicsPipeline* CreateGraphicsPipeline(NonNullPtr<GPUDriver> driver, const GraphicsPipelineCreateInfo& createInfo)extern void DestroyGraphicsPipeline(NonNullPtr<GPUDriver> driver, NonNullPtr<GraphicsPipeline> graphicsPipeline)extern bool UpdateGraphicsPipelineShaders(NonNullPtr<GPUDriver> driver, NonNullPtr<GraphicsPipeline> graphicsPipeline, Shader* optional_vertexShader, Shader* optional_fragmentShader)
Namespace Juliet::D3D12::Internal
Functions & Methods
extern void ReleaseGraphicsPipeline(NonNullPtr<D3D12GraphicsPipeline> d3d12GraphicsPipeline)