FCT
载入中...
搜索中...
未找到
ShaderBinary.h
浏览该文件的文档.
1//
2// Created by Administrator on 2025/4/8.
3//
4#include "../ThirdParty.h"
7#ifndef SHADERBINARY_H
8#define SHADERBINARY_H
9
10namespace FCT
11{
12 namespace RHI
13 {
15 public:
17 virtual ~ShaderBinary() {}
18 void code(std::vector<char> code)
19 {
20 m_code = code;
21 m_reflected = false;
22 }
23 std::vector<char> code() const
24 {
25 return m_code;
26 }
27 void location(std::map<std::string, uint32_t> locations)
28 {
29 m_locations = locations;
30 }
31 int32_t locationBySemantic(const std::string& semantic) const
32 {
33 auto it = m_locations.find(semantic);
34 if (it != m_locations.end()) {
35 return it->second;
36 }
37 return -1;
38 }
39 std::map<std::string,std::pair<uint32_t,uint32_t>> constBufferLocations()
40 {
42 }
43 std::map<std::string,ConstLayout> constBufferLayout()
44 {
46 }
47 void addConstBufferLocation(ConstLayout layout, uint32_t set, uint32_t location)
48 {
49 m_constBufferLayout[layout.getName()] = layout;
50 m_constBufferLocations[layout.getName()] = std::make_pair(set, location);
51 }
52
53 void addTextureLocation(TextureElement texture, uint32_t set, uint32_t binding)
54 {
55 m_textureLayout[texture.getName()] = texture;
56 m_textureLocations[texture.getName()] = std::make_pair(set, binding);
57 }
58
59 std::pair<uint32_t, uint32_t> getTextureLocation(const std::string& name) const
60 {
61 auto it = m_textureLocations.find(name);
62 if (it != m_textureLocations.end()) {
63 return it->second;
64 }
65 return std::make_pair(0, 0);
66 }
67
68 TextureElement getTextureElement(const std::string& name) const
69 {
70 auto it = m_textureLayout.find(name);
71 if (it != m_textureLayout.end()) {
72 return it->second;
73 }
74 return TextureElement();
75 }
76
77 std::map<std::string, std::pair<uint32_t, uint32_t>> textureLocations() const
78 {
79 return m_textureLocations;
80 }
81
82 std::map<std::string, TextureElement> textureLayout() const
83 {
84 return m_textureLayout;
85 }
86
87 void addSamplerLocation(SamplerElement sampler, uint32_t set, uint32_t binding)
88 {
89 m_samplerLayout[sampler.getName()] = sampler;
90 m_samplerLocations[sampler.getName()] = std::make_pair(set, binding);
91 }
92
93 std::pair<uint32_t, uint32_t> getSamplerLocation(const std::string& name) const
94 {
95 auto it = m_samplerLocations.find(name);
96 if (it != m_samplerLocations.end()) {
97 return it->second;
98 }
99 return std::make_pair(0, 0);
100 }
101
102 SamplerElement getSamplerElement(const std::string& name) const
103 {
104 auto it = m_samplerLayout.find(name);
105 if (it != m_samplerLayout.end()) {
106 return it->second;
107 }
108 return SamplerElement();
109 }
110
111 std::map<std::string, std::pair<uint32_t, uint32_t>> samplerLocations() const
112 {
113 return m_samplerLocations;
114 }
115
116 std::map<std::string, SamplerElement> samplerLayout() const
117 {
118 return m_samplerLayout;
119 }
120
121 protected:
122 std::vector<char> m_code;
123 std::map<std::string, uint32_t> m_locations;
124 std::map<std::string,std::pair<uint32_t,uint32_t>> m_uniformLocations;
125 std::map<std::string,std::pair<uint32_t,uint32_t>> m_constBufferLocations;
126 std::map<std::string,ConstLayout> m_constBufferLayout;
127 std::map<std::string,std::pair<uint32_t,uint32_t>> m_textureLocations;
128 std::map<std::string,TextureElement> m_textureLayout;
129 std::map<std::string,std::pair<uint32_t,uint32_t>> m_samplerLocations;
130 std::map<std::string,SamplerElement> m_samplerLayout;
131 bool m_reflected = false;
132 };
133 }
134}
135
136
137
138#endif //SHADERBINARY_H
constexpr const char * getName() const noexcept
std::map< std::string, std::pair< uint32_t, uint32_t > > m_samplerLocations
void location(std::map< std::string, uint32_t > locations)
int32_t locationBySemantic(const std::string &semantic) const
void addConstBufferLocation(ConstLayout layout, uint32_t set, uint32_t location)
std::map< std::string, std::pair< uint32_t, uint32_t > > textureLocations() const
void addTextureLocation(TextureElement texture, uint32_t set, uint32_t binding)
std::map< std::string, std::pair< uint32_t, uint32_t > > m_constBufferLocations
std::map< std::string, TextureElement > textureLayout() const
std::pair< uint32_t, uint32_t > getTextureLocation(const std::string &name) const
std::map< std::string, TextureElement > m_textureLayout
std::pair< uint32_t, uint32_t > getSamplerLocation(const std::string &name) const
void addSamplerLocation(SamplerElement sampler, uint32_t set, uint32_t binding)
std::map< std::string, std::pair< uint32_t, uint32_t > > m_textureLocations
std::map< std::string, ConstLayout > m_constBufferLayout
std::vector< char > m_code
std::map< std::string, SamplerElement > m_samplerLayout
void code(std::vector< char > code)
std::map< std::string, ConstLayout > constBufferLayout()
std::map< std::string, uint32_t > m_locations
std::map< std::string, std::pair< uint32_t, uint32_t > > constBufferLocations()
SamplerElement getSamplerElement(const std::string &name) const
std::vector< char > code() const
std::map< std::string, std::pair< uint32_t, uint32_t > > m_uniformLocations
std::map< std::string, SamplerElement > samplerLayout() const
std::map< std::string, std::pair< uint32_t, uint32_t > > samplerLocations() const
TextureElement getTextureElement(const std::string &name) const
constexpr const char * getName() const noexcept
constexpr const char * getName() const noexcept