69 if (existingSampler.getName() !=
nullptr && existingSampler.getName()[0] !=
'\0') {
146 texture.first.c_str(),
177 ret->addLayout(layout.first,layout.second);
182 ret->addUniform(uniform.second);
196 ret->addUniform(layout.second);
220 std::string name = constBuffer->
layout().getName();
305 boost::hash_combine(
hash, tex.first);
306 boost::hash_combine(
hash, tex.second);
310 boost::hash_combine(
hash, samp.first);
311 boost::hash_combine(
hash, samp.second);
315 boost::hash_combine(
hash, uni.first);
316 boost::hash_combine(
hash, uni.second);
326 pair.second->release();
333 auto hash = state.
hash();
339 auto passResource = creator(state);
349 pair.second->release();
356 auto hash = state.
hash();
362 auto pipeline = creator(state);
373 FCT::ShaderStages usage;
415 ret->addTexture( tex.second,
m_resourceLayout.findTexture(tex.first.c_str()));
418 ret->addSampler(samp.second,
m_resourceLayout.findSampler(samp.first.c_str()));
421 ret->addConstBuffer(uni.second);
432 auto ret =
m_ctx->createTraditionPipeline();
436 ret->vertexLayout(layout.second);
471 pair.second->release();
474 pair.second->release();
481 auto hash = std::hash<std::string>{}(code);
488 auto shader = creator(code);
497 auto hash = std::hash<std::string>{}(code);
504 auto shader = creator(code);
513 auto hash = ref.
hash;
520 auto shader = creator(ref);
529 auto hash = ref.
hash;
536 auto shader = creator(ref);
579 ref.
hash = std::hash<std::string>{}(code);
589 ref.
hash = std::hash<std::string>{}(code);
622 shader.second->release();
627 shader.second->release();
637 if (resource.second) {
638 resource.second->release();
647 if (pipeline.second) {
648 pipeline.second->release();
constexpr const char * getName() const noexcept
std::map< std::string, FCT::ConstLayout > m_uniformLayouts
ShaderRef cachePixelShader(const std::string &code)
预缓存一个像素着色器并返回其引用。
ShaderCache m_shaderCache
void bindUniform(const Uniform &uniform)
绑定一个 Uniform 常量缓冲区。
std::unordered_map< std::string, const char * > m_textureNames
void clearPassResourceCache()
清空所有已缓存的 PassResource。
void removeTextureSlot(const char *name)
移除一个纹理资源槽位。
void setFixedImage(std::string name, FCT::Image *image)
设置一个固定的图像资源,该资源不会在 begin/end 之间被清除。
void processUnhandledTextureSlots()
FCT::ResourceLayout m_pixelResourceLayout
void attachPass(std::string passName)
将此 Layout 附加到一个渲染通道。
void setPixelLayout(const FCT::PixelLayout &pixelLayout)
设置像素(片元)着色器的输出布局。
void addVertexLayout(const FCT::VertexLayout &vertexLayout)
添加一个顶点布局。
void bindSampler(std::string name, FCT::Sampler *sampler)
绑定一个采样器。
void clearPipelineCache()
清空所有已缓存的渲染管线。
uint32_t m_nextAvailableIndex
uint32_t findNextAvailableIndex()
void bindTexture(std::string name, FCT::Image *image)
绑定一个纹理。
FCT::ResourceLayout m_vertexResourceLayout
ShaderRef cacheVertexShader(const std::string &code)
预缓存一个顶点着色器并返回其引用。
std::map< std::string, Image * > m_textureFromPass
VertexShader * getCacheVertexShader(std::string code)
std::unordered_map< std::string, FCT::Image * > m_fixedImages
TraditionPipelineState m_pipelineState
void bindVertexShader(std::string code)
绑定顶点着色器。
FCT::ResourceLayout m_resourceLayout
std::map< uint32_t, FCT::VertexLayout > m_vertexLayouts
FCT::RHI::RasterizationPipeline * getCurrentPipeline()
PassResourceState m_passResourceState
void addTextureSlot(const FCT::TextureSlot &element)
PassResourceCache m_passResourceCache
FCT::PixelLayout m_pixelLayout
PipelineCache m_pipelineCache
void bindPixelShader(std::string code)
绑定像素着色器。
void addSamplerSlot(const SamplerSlot &samplerSlot)
添加一个采样器资源槽位。
void ctx(FCT::Context *ctx)
重新设置 FCT 上下文。
void clearShaderCache()
清空所有已缓存的着色器。
FCT::PixelShader * allocatePixelShader(std::string code)
PixelShader * getCachePixelShader(std::string code)
Uniform allocateUniform(std::string name)
根据已定义的 UniformSlot 分配一个 Uniform 实例。
FCT::VertexShader * allocateVertexShader(std::string code)
FCT::PassResource * getCurrentPassResource()
void addUniformSlot(const UniformSlot &uniformSlot)
添加一个常量缓冲区(Uniform Buffer)的布局槽位。
std::vector< TextureSlot > m_unhandledTextureSlots
void layout(const ConstLayout &layout)
constexpr ShaderStages getShaderStages() const noexcept
constexpr const char * getName() const noexcept
constexpr ShaderStages getShaderStages() const noexcept
FCT::PixelShader PixelShader
FCT::VertexShader VertexShader
FCT::SamplerElement SamplerSlot
FCT::ConstLayout UniformSlot
FCT::ShaderStages getAllAfterTheStage(FCT::ShaderStage stages)
FCT::PassResource * get(const PassResourceState &state, const std::function< FCT::PassResource *(const PassResourceState &state)> &creator)
std::unordered_map< size_t, FCT::PassResource * > m_passResources
std::unordered_map< std::string, FCT::RHI::ConstBuffer * > boundUniforms
void bindUniform(const std::string &name, const Uniform &uniform)
void bindTexture(const std::string &name, FCT::Image *image)
std::unordered_map< std::string, FCT::Image * > boundTextures
std::unordered_map< std::string, FCT::Sampler * > boundSamplers
void bindSampler(const std::string &name, FCT::Sampler *sampler)
std::unordered_map< size_t, FCT::RHI::RasterizationPipeline * > m_pipelines
FCT::RHI::RasterizationPipeline * get(const TraditionPipelineState &state, const std::function< FCT::RHI::RasterizationPipeline *(const TraditionPipelineState &state)> &creator)
FCT::VertexShader * getVertexShader(const std::string &code, const std::function< FCT::VertexShader *(const std::string &code)> &creator)
std::unordered_map< size_t, FCT::VertexShader * > m_vertexShaders
FCT::PixelShader * getPixelShader(const std::string &code, const std::function< FCT::PixelShader *(const std::string &code)> &creator)
std::unordered_map< size_t, FCT::PixelShader * > m_pixelShaders
FCT::DepthStencilState * depthStencilState
FCT::BlendState * blendState
FCT::PixelShader * pixelShader
FCT::RasterizationState * rasterizationState
bool operator==(const TraditionPipelineState &other) const
FCT::VertexShader * vertexShader
std::map< std::string, Image * > textures
std::map< std::string, ShaderStage > textureSlot
定义着色器代码的引用,包含代码本身、哈希值和类型。