FCT
|
管理渲染管线的状态、资源布局和缓存。 更多...
#include <layout.h>
类 | |
struct | PassResourceCache |
struct | PassResourceState |
struct | PipelineCache |
struct | ShaderCache |
struct | TraditionPipelineState |
Public 成员函数 | |
构造与上下文设置 | |
template<typename... Args> | |
Layout (FCT::Context *ctx, Args... args) | |
void | ctx (FCT::Context *ctx) |
重新设置 FCT 上下文。 | |
动态布局配置 | |
void | addVertexLayout (const FCT::VertexLayout &vertexLayout) |
添加一个顶点布局。 | |
void | setPixelLayout (const FCT::PixelLayout &pixelLayout) |
设置像素(片元)着色器的输出布局。 | |
void | addUniformSlot (const UniformSlot &uniformSlot) |
添加一个常量缓冲区(Uniform Buffer)的布局槽位。 | |
void | addTextureSlot (const FCT::TextureSlot &element) |
void | addTextureSlot (FCT::TextureElement element) |
添加一个纹理资源槽位。 | |
void | addSamplerSlot (const SamplerSlot &samplerSlot) |
添加一个采样器资源槽位。 | |
void | removeTextureSlot (const char *name) |
移除一个纹理资源槽位。 | |
void | setFixedImage (std::string name, FCT::Image *image) |
设置一个固定的图像资源,该资源不会在 begin/end 之间被清除。 | |
void | attachPass (std::string passName) |
将此 Layout 附加到一个渲染通道。 | |
资源分配与渲染命令 | |
Uniform | allocateUniform (std::string name) |
根据已定义的 UniformSlot 分配一个 Uniform 实例。 | |
void | begin () |
开始一个渲染批次。 | |
void | bindUniform (const Uniform &uniform) |
绑定一个 Uniform 常量缓冲区。 | |
void | bindUniform (Uniform *uniform) |
void | bindTexture (std::string name, FCT::Image *image) |
绑定一个纹理。 | |
void | bindSampler (std::string name, FCT::Sampler *sampler) |
绑定一个采样器。 | |
void | bindVertexShader (std::string code) |
绑定顶点着色器。 | |
void | bindPixelShader (std::string code) |
绑定像素着色器。 | |
void | bindVertexShader (const ShaderRef &ref) |
通过着色器引用绑定顶点着色器。 | |
void | bindPixelShader (const ShaderRef &ref) |
通过着色器引用绑定像素着色器。 | |
template<typename T> | |
void | drawMesh (RHI::CommandBuffer *cmdBuffer, T *mesh) |
绘制一个网格。 | |
template<typename T> | |
void | drawMesh (RHI::CommandBuffer *cmdBuffer, T &mesh) |
绘制一个网格。 | |
void | end () |
结束渲染批次。 | |
缓存管理 | |
ShaderRef | cacheVertexShader (const std::string &code) |
预缓存一个顶点着色器并返回其引用。 | |
ShaderRef | cachePixelShader (const std::string &code) |
预缓存一个像素着色器并返回其引用。 | |
void | clearPassResourceCache () |
清空所有已缓存的 PassResource。 | |
void | clearPipelineCache () |
清空所有已缓存的渲染管线。 | |
void | clearShaderCache () |
清空所有已缓存的着色器。 |
Private 成员函数 | |
template<typename... Args> | |
void | proccessArgs (FCT::VertexLayout vertexLayout, Args... args) |
template<class ... Args> | |
void | proccessArgs (const std::vector< FCT::VertexLayout > &vertexLayouts, Args... args) |
template<typename... Args> | |
void | proccessArgs (SamplerSlot samplerSlot, Args... args) |
template<typename... Args> | |
void | proccessArgs (PassName passName, Args... args) |
template<typename... Args> | |
void | proccessArgs (uint32_t index, FCT::VertexLayout vertexLayout, Args... args) |
template<typename... Args> | |
void | proccessArgs (FCT::PixelLayout pixelLayout, Args... args) |
template<typename... Args> | |
void | proccessArgs (TextureSlot textureSlot, Args... args) |
template<typename... Args> | |
void | proccessArgs (UniformSlot uniformSlot, Args... args) |
void | proccessArgs () |
FCT::PassResource * | getCurrentPassResource () |
FCT::RHI::RasterizationPipeline * | getCurrentPipeline () |
void | bindVertexShader (FCT::VertexShader *shader) |
void | bindPixelShader (FCT::PixelShader *shader) |
FCT::VertexShader * | allocateVertexShader (std::string code) |
FCT::PixelShader * | allocatePixelShader (std::string code) |
VertexShader * | getCacheVertexShader (std::string code) |
PixelShader * | getCachePixelShader (std::string code) |
VertexShader * | getCacheVertexShader (const ShaderRef &ref) |
PixelShader * | getCachePixelShader (const ShaderRef &ref) |
void | processUnhandledTextureSlots () |
uint32_t | findNextAvailableIndex () |
Private 属性 | |
FCT::Context * | m_ctx |
std::map< uint32_t, FCT::VertexLayout > | m_vertexLayouts |
std::map< std::string, FCT::ConstLayout > | m_uniformLayouts |
FCT::PixelLayout | m_pixelLayout |
FCT::ResourceLayout | m_resourceLayout |
FCT::ResourceLayout | m_vertexResourceLayout |
FCT::ResourceLayout | m_pixelResourceLayout |
std::unordered_map< std::string, FCT::Image * > | m_fixedImages |
std::map< std::string, Image * > | m_textureFromPass |
std::unordered_map< std::string, const char * > | m_textureNames |
uint32_t | m_nextAvailableIndex = 0 |
std::vector< TextureSlot > | m_unhandledTextureSlots |
bool | m_hasVertexLayout = false |
bool | m_hasPixelLayout = false |
FCT::RHI::Pass * | m_pass |
PassResourceState | m_passResourceState |
TraditionPipelineState | m_pipelineState |
PassResourceCache | m_passResourceCache |
PipelineCache | m_pipelineCache |
ShaderCache | m_shaderCache |
管理渲染管线的状态、资源布局和缓存。
Layout 是 FCT 库的核心类之一,它封装了与特定渲染效果相关的所有配置, 包括顶点布局、资源(纹理、常量缓冲区、采样器)布局、着色器以及其他管线状态。 它通过构造函数链式配置,并提供了一套完整的渲染命令接口。
FCT::Layout::Layout | ( | FCT::Context * | ctx, |
Args... | args ) |
void FCT::Layout::addSamplerSlot | ( | const SamplerSlot & | samplerSlot | ) |
void FCT::Layout::addTextureSlot | ( | const FCT::TextureSlot & | element | ) |
void FCT::Layout::addTextureSlot | ( | FCT::TextureElement | element | ) |
void FCT::Layout::addUniformSlot | ( | const UniformSlot & | uniformSlot | ) |
添加一个常量缓冲区(Uniform Buffer)的布局槽位。
uniformSlot | 常量缓冲区的布局定义。 |
在文件 layout.cpp 第 47 行定义.
void FCT::Layout::addVertexLayout | ( | const FCT::VertexLayout & | vertexLayout | ) |
|
private |
Uniform FCT::Layout::allocateUniform | ( | std::string | name | ) |
根据已定义的 UniformSlot 分配一个 Uniform 实例。
name | UniformSlot 的名称。 |
在文件 layout.cpp 第 167 行定义.
|
private |
void FCT::Layout::attachPass | ( | std::string | passName | ) |
void FCT::Layout::begin | ( | ) |
void FCT::Layout::bindPixelShader | ( | const ShaderRef & | ref | ) |
|
private |
在文件 layout.cpp 第 243 行定义.
void FCT::Layout::bindPixelShader | ( | std::string | code | ) |
void FCT::Layout::bindSampler | ( | std::string | name, |
FCT::Sampler * | sampler ) |
void FCT::Layout::bindTexture | ( | std::string | name, |
FCT::Image * | image ) |
void FCT::Layout::bindUniform | ( | const Uniform & | uniform | ) |
void FCT::Layout::bindUniform | ( | Uniform * | uniform | ) |
void FCT::Layout::bindVertexShader | ( | const ShaderRef & | ref | ) |
|
private |
在文件 layout.cpp 第 238 行定义.
void FCT::Layout::bindVertexShader | ( | std::string | code | ) |
ShaderRef FCT::Layout::cachePixelShader | ( | const std::string & | code | ) |
预缓存一个像素着色器并返回其引用。
code | 像素着色器的 GLSL 源码。 |
在文件 layout.cpp 第 585 行定义.
ShaderRef FCT::Layout::cacheVertexShader | ( | const std::string & | code | ) |
预缓存一个顶点着色器并返回其引用。
code | 顶点着色器的 GLSL 源码。 |
在文件 layout.cpp 第 575 行定义.
void FCT::Layout::clearPassResourceCache | ( | ) |
void FCT::Layout::clearPipelineCache | ( | ) |
void FCT::Layout::clearShaderCache | ( | ) |
void FCT::Layout::ctx | ( | FCT::Context * | ctx | ) |
void FCT::Layout::drawMesh | ( | RHI::CommandBuffer * | cmdBuffer, |
T & | mesh ) |
绘制一个网格。
T | 网格类型,通常是 FCT::StaticMesh 或 FCT::DynamicMesh。 |
cmdBuffer | RHI 命令缓冲区。 |
mesh | 对要绘制的网格对象的引用。 |
在文件 layout.hpp 第 116 行定义.
void FCT::Layout::drawMesh | ( | RHI::CommandBuffer * | cmdBuffer, |
T * | mesh ) |
绘制一个网格。
T | 网格类型,通常是 FCT::StaticMesh 或 FCT::DynamicMesh。 |
cmdBuffer | RHI 命令缓冲区。 |
mesh | 指向要绘制的网格对象的指针。 |
在文件 layout.hpp 第 104 行定义.
void FCT::Layout::end | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
void FCT::Layout::removeTextureSlot | ( | const char * | name | ) |
void FCT::Layout::setFixedImage | ( | std::string | name, |
FCT::Image * | image ) |
设置一个固定的图像资源,该资源不会在 begin/end 之间被清除。
name | 资源在着色器中的名称。 |
image | 指向 FCT::Image 对象的指针。 |
在文件 layout.cpp 第 27 行定义.
void FCT::Layout::setPixelLayout | ( | const FCT::PixelLayout & | pixelLayout | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |