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
24 {
25 if (m_pixelShader)
26 {
27 m_pixelShader->release();
28 }
29 }
30 void code(std::string source)
31 {
32 m_userSource = source;
33 }
34 void create()
35 {
36 m_pixelShader = m_ctx->createResource<RHI::PixelShader>();
37 if (m_userSource.empty())
38 {
40 }
41 if (m_binaryCode.code().empty())
42 {
43 preprocess();
44 compile();
45 }
46 m_pixelShader->code(m_binaryCode.code());
47 m_pixelShader->create();
48 }
57 void pixelLayout(const PixelLayout& layout)
58 {
59 m_pixelLayout = layout;
60 }
62 {
63 m_uniformLayouts.push_back(layout);
64 }
66 {
67 m_resourceLayout = layout;
68 }
69 protected:
71 {
72 m_userSource = m_ctx->getGenerator()->generateDefaultPixelMain(m_pixelLayout);
73 }
74 void compile()
75 {
76 m_binaryCode.code(
77 m_ctx->getCompiler()->compile(m_source,"FCTEntry",ShaderKind::FragmentShader)
78 );
79 }
81 {
83 }
88 std::string m_userSource;
89 std::string m_source;
90 std::vector<ConstLayout> m_uniformLayouts;
92 };
93
94}
95#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)