FCT
载入中...
搜索中...
未找到
PixelShader.h
浏览该文件的文档.
1//
2// Created by Administrator on 2025/4/9.
3//
5#include "Vertex.h"
6#include "Context.h"
9#ifndef FCT_PIXELSHADER_H
10#define FCT_PIXELSHADER_H
11namespace FCT {
13 public:
15 {
17 }
19 {
20 m_ctx = ctx;
21 }
22 void code(std::string source)
23 {
24 m_userSource = source;
25 }
26 void create()
27 {
28 m_pixelShader = m_ctx->createResource<RHI::PixelShader>();
29 if (m_userSource.empty())
30 {
32 }
33 if (m_binaryCode.code().empty())
34 {
35 preprocess();
36 compile();
37 }
38 m_pixelShader->code(m_binaryCode.code());
39 m_pixelShader->create();
40 }
49 void pixelLayout(const PixelLayout& layout)
50 {
51 m_pixelLayout = layout;
52 }
54 {
55 m_uniformLayouts.push_back(layout);
56 }
58 {
59 m_resourceLayout = layout;
60 }
61 protected:
63 {
64 m_userSource = m_ctx->getGenerator()->generateDefaultPixelMain(m_pixelLayout);
65 }
66 void compile()
67 {
68 m_binaryCode.code(
69 m_ctx->getCompiler()->compile(m_source,"FCTEntry",ShaderKind::FragmentShader)
70 );
71 }
73 {
75 }
80 std::string m_userSource;
81 std::string m_source;
82 std::vector<ConstLayout> m_uniformLayouts;
84 };
85
86}
87#endif //FCT_PIXELSHADER_H
PixelLayout m_pixelLayout
std::vector< ConstLayout > m_uniformLayouts
void code(std::string source)
RHI::ShaderBinary m_binaryCode
PipelineResourceType getType() const override
void pixelLayout(const PixelLayout &layout)
RHI::PixelShader * pixelShader()
PixelShader(Context *ctx)
void addUniform(ConstLayout layout)
RHI::PixelShader * m_pixelShader
ResourceLayout m_resourceLayout
RHI::ShaderBinary binaryCode()
std::string m_userSource
void resourceLayout(ResourceLayout layout)