145 auto shader_bundle = std::make_unique<fb::shaderbundle::BackendShaderT>();
149 shader_bundle->entrypoint = entrypoint_;
150 const auto stage =
ToStage(stage_);
151 if (!stage.has_value()) {
155 shader_bundle->stage = stage.value();
161 if (shader_->GetSize() > 0u) {
162 shader_bundle->shader = {shader_->GetMapping(),
163 shader_->GetMapping() + shader_->GetSize()};
165 for (
const auto& uniform : uniform_structs_) {
166 auto desc = std::make_unique<fb::shaderbundle::ShaderUniformStructT>();
168 desc->name = uniform.name;
169 if (desc->name.empty()) {
173 desc->ext_res_0 = uniform.ext_res_0;
174 desc->set = uniform.set;
175 desc->binding = uniform.binding;
176 desc->size_in_bytes = uniform.size_in_bytes;
178 for (
const auto& field : uniform.fields) {
180 std::make_unique<fb::shaderbundle::ShaderUniformStructFieldT>();
181 field_desc->name = field.name;
183 if (!
type.has_value()) {
187 field_desc->type =
type.value();
188 field_desc->offset_in_bytes = field.offset_in_bytes;
189 field_desc->element_size_in_bytes = field.element_size_in_bytes;
190 field_desc->total_size_in_bytes = field.total_size_in_bytes;
191 field_desc->array_elements = field.array_elements.value_or(0);
192 desc->fields.push_back(std::move(field_desc));
195 shader_bundle->uniform_structs.emplace_back(std::move(desc));
198 for (
const auto& texture : uniform_textures_) {
199 auto desc = std::make_unique<fb::shaderbundle::ShaderUniformTextureT>();
200 desc->name = texture.name;
201 if (desc->name.empty()) {
205 desc->ext_res_0 = texture.ext_res_0;
206 desc->set = texture.set;
207 desc->binding = texture.binding;
208 shader_bundle->uniform_textures.emplace_back(std::move(desc));
211 for (
const auto& input : inputs_) {
212 auto desc = std::make_unique<fb::shaderbundle::ShaderInputT>();
214 desc->name = input.name;
216 if (desc->name.empty()) {
220 desc->location = input.location;
221 desc->set = input.set;
222 desc->binding = input.binding;
224 if (!input_type.has_value()) {
228 desc->type = input_type.value();
229 desc->bit_width = input.bit_width;
230 desc->vec_size = input.vec_size;
231 desc->columns = input.columns;
232 desc->offset = input.offset;
234 shader_bundle->inputs.emplace_back(std::move(desc));
237 return shader_bundle;
static std::optional< fb::Stage > ToStage(spv::ExecutionModel stage)
static std::optional< fb::UniformDataType > ToUniformType(spirv_cross::SPIRType::BaseType type)
static std::optional< fb::InputDataType > ToInputType(spirv_cross::SPIRType::BaseType type)