The interface for a shader program.
More...
#include <rendering_api.hpp>
Inherits LiteFX::SharedObject.
Inherited by LiteFX::Rendering::ShaderProgram< DirectX12ShaderModule >, LiteFX::Rendering::ShaderProgram< VulkanShaderModule >, and LiteFX::Rendering::ShaderProgram< TShaderModule >.
|
template<typename T , typename... TArgs> |
static auto | create (TArgs &&... args) -> SharedPtr< T > |
| Generic factory method used to create instances of the shared object.
|
|
The interface for a shader program.
A shader program differs in it's functionality as well as the contained shader modules, depending on the pipeline type it gets assigned to. A shader program can be of any of the following types:
-
Rasterization: A rasterization pipeline is a traditional pipeline, that can contain at maximum one module of the following stages: Vertex, Tessellation Control, Tessellation Evaluation, Geometry, Fragment. A vertex and fragment shader are required for rasterization programs.
-
Mesh shading: If mesh shader support is enabled (through the device feature GraphicsDeviceFeatures::MeshShaders), a mesh shading program can contain at maximum one module of the following stages: Task, Mesh, Fragment. A mesh and fragment shader are required for a mesh shading program.
-
Compute: A compute shader program must only contain a single module for the Compute stage.
-
Ray-tracing: If ray tracing support is enabled (through the device feature GraphicsDeviceFeatures::RayTracing), a ray tracing program can contain modules of the following stages: Ray Generation, Any Hit, Closest Hit, Intersection, Miss, Callable. There must be exactly one Ray Generation module. All other modules can occur multiple times. To build a ray tracing pipeline, all shaders should be added to a single shader program, which is then passed to the pipeline during creation.
Shaders from different program types must not be mixed. For example, it is not valid to add a compute module to a rasterization program. The only exception to this is the ShaderStage::Fragment module, which can be added to a mesh pipeline, as well as a rasterization pipeline.
◆ IShaderProgram() [1/3]
LiteFX::Rendering::IShaderProgram::IShaderProgram |
( |
| ) |
|
|
protecteddefaultnoexcept |
◆ ~IShaderProgram()
LiteFX::Rendering::IShaderProgram::~IShaderProgram |
( |
| ) |
|
|
overridedefaultnoexcept |
◆ IShaderProgram() [2/3]
LiteFX::Rendering::IShaderProgram::IShaderProgram |
( |
const IShaderProgram & | | ) |
|
|
delete |
◆ IShaderProgram() [3/3]
LiteFX::Rendering::IShaderProgram::IShaderProgram |
( |
IShaderProgram && | | ) |
|
|
deletenoexcept |
◆ buildShaderRecordCollection()
Builds a shader record collection based on the current shader program.
- Returns
- The shader record collection instance.
◆ contains() [1/2]
bool LiteFX::Rendering::IShaderProgram::contains |
( |
const IShaderModule & | module | ) |
const |
|
inline |
Returns true
, if the program contains the provided shader module and false
otherwise.
- Parameters
-
module | The module to look up in the shader program. |
- Returns
true
, if the program contains the provided shader module and false
otherwise.
◆ contains() [2/2]
bool LiteFX::Rendering::IShaderProgram::contains |
( |
StringView | name | ) |
const |
|
inline |
Returns true
, if the program contains a shader module with the provided name or file name and false
otherwise.
- Parameters
-
name | The case-sensitive name or file name of the shader module to look up. |
- Returns
true
, if the program contains a shader module with the provided name or file name and false
otherwise.
◆ modules()
Returns the modules, the shader program is build from.
- Returns
- The modules, the shader program is build from.
◆ operator=() [1/2]
auto LiteFX::Rendering::IShaderProgram::operator= |
( |
const IShaderProgram & | | ) |
|
|
delete |
◆ operator=() [2/2]
auto LiteFX::Rendering::IShaderProgram::operator= |
( |
IShaderProgram && | | ) |
|
|
deletenoexcept |
◆ operator[]()
Returns a pointer to shader module based on its (case-sensitive) name.
- Parameters
-
name | The name or file name of the shader module. |
- Returns
- A pointer to the shader module, or
nullptr
, if it was not found.
◆ reflectPipelineLayout()
Uses shader reflection to extract the pipeline layout of a shader. May not be available in all backends.
Note that shader reflection may not yield different results than you would expect, especially when using DirectX 12. For more information on how to use shader reflection and how to write portable shaders, refer to the shader development guide in the wiki.
In particular, shader reflection is not able to restore:
-
Input attachments in DirectX. Instead, input attachments are treated as
DescriptorType::Texture
. This is usually not a problem, since DirectX does not have a concept of render pass outputs/inputs anyway. However, keep this in mind, if you want to filter descriptors based on their type, for example. Immutable sampler states in Vulkan. Those are only restored in DirectX, if an explicit root signature has been provided. For this reason, it is best not to use them, if you want to use shader reflection.
- Returns
- The pipeline layout extracted from shader reflection.