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 field_desc->vec_size = field.vec_size;
193 field_desc->columns = field.columns;
194 desc->fields.push_back(std::move(field_desc));
197 shader_bundle->uniform_structs.emplace_back(std::move(desc));
200 for (
const auto& texture : uniform_textures_) {
201 auto desc = std::make_unique<fb::shaderbundle::ShaderUniformTextureT>();
202 desc->name = texture.name;
203 if (desc->name.empty()) {
207 desc->ext_res_0 = texture.ext_res_0;
208 desc->set = texture.set;
209 desc->binding = texture.binding;
210 shader_bundle->uniform_textures.emplace_back(std::move(desc));
213 for (
const auto& input : inputs_) {
214 auto desc = std::make_unique<fb::shaderbundle::ShaderInputT>();
216 desc->name = input.name;
218 if (desc->name.empty()) {
222 desc->location = input.location;
223 desc->set = input.set;
224 desc->binding = input.binding;
226 if (!input_type.has_value()) {
230 desc->type = input_type.value();
231 desc->bit_width = input.bit_width;
232 desc->vec_size = input.vec_size;
233 desc->columns = input.columns;
234 desc->offset = input.offset;
236 shader_bundle->inputs.emplace_back(std::move(desc));
239 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)