284 {
285 auto kvp = data_.find(
backend);
286 if (kvp == data_.end()) {
287 return nullptr;
288 }
289
290 auto runtime_stage = std::make_unique<fb::RuntimeStageT>();
291 runtime_stage->entrypoint = kvp->second->entrypoint;
292 const auto stage =
ToStage(kvp->second->stage);
293 if (!stage.has_value()) {
295 return nullptr;
296 }
297 runtime_stage->stage = stage.value();
298 if (!kvp->second->shader) {
300 return nullptr;
301 }
302 if (kvp->second->shader->GetSize() > 0u) {
303 runtime_stage->shader = {
304 kvp->second->shader->GetMapping(),
305 kvp->second->shader->GetMapping() + kvp->second->shader->GetSize()};
306 }
307 for (const auto& uniform : kvp->second->uniforms) {
308 auto desc = std::make_unique<fb::UniformDescriptionT>();
309
310 desc->name = uniform.name;
311 if (
desc->name.empty()) {
313 return nullptr;
314 }
315 desc->location = uniform.location;
316 desc->rows = uniform.rows;
317 desc->columns = uniform.columns;
319 if (!uniform_type.has_value()) {
321 return nullptr;
322 }
323 desc->type = uniform_type.value();
324 desc->bit_width = uniform.bit_width;
325 if (uniform.array_elements.has_value()) {
326 desc->array_elements = uniform.array_elements.value();
327 }
328
329 for (const auto& byte_type : uniform.struct_layout) {
330 desc->struct_layout.push_back(
static_cast<fb::StructByteType
>(byte_type));
331 }
332 desc->struct_float_count = uniform.struct_float_count;
333
334 runtime_stage->uniforms.emplace_back(std::move(
desc));
335 }
336
337 for (const auto& input : kvp->second->inputs) {
338 auto desc = std::make_unique<fb::StageInputT>();
339
340 desc->name = input.name;
341
342 if (
desc->name.empty()) {
344 return nullptr;
345 }
346 desc->location = input.location;
347 desc->set = input.set;
348 desc->binding = input.binding;
350 if (!input_type.has_value()) {
352 return nullptr;
353 }
354 desc->type = input_type.value();
355 desc->bit_width = input.bit_width;
356 desc->vec_size = input.vec_size;
357 desc->columns = input.columns;
358 desc->offset = input.offset;
359
360 runtime_stage->inputs.emplace_back(std::move(
desc));
361 }
362
363 return runtime_stage;
364}
static std::optional< fb::InputDataType > ToInputType(spirv_cross::SPIRType::BaseType type)
static std::optional< fb::UniformDataType > ToUniformType(spirv_cross::SPIRType::BaseType type)
static std::optional< fb::Stage > ToStage(spv::ExecutionModel stage)