MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / parse_push_constants

Method parse_push_constants

framework/spirv_reflection.cpp:404–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404void SPIRVReflection::parse_push_constants(const spirv_cross::Compiler &compiler, VkShaderStageFlagBits stage, std::vector<ShaderResource> &resources, const ShaderVariant &variant)
405{
406 auto shader_resources = compiler.get_shader_resources();
407
408 for (auto &resource : shader_resources.push_constant_buffers)
409 {
410 const auto &spivr_type = compiler.get_type_from_variable(resource.id);
411
412 std::uint32_t offset = std::numeric_limits<std::uint32_t>::max();
413
414 for (auto i = 0U; i < spivr_type.member_types.size(); ++i)
415 {
416 auto mem_offset = compiler.get_member_decoration(spivr_type.self, i, spv::DecorationOffset);
417
418 offset = std::min(offset, mem_offset);
419 }
420
421 ShaderResource shader_resource{};
422 shader_resource.type = ShaderResourceType::PushConstant;
423 shader_resource.stages = stage;
424 shader_resource.name = resource.name;
425 shader_resource.offset = offset;
426
427 read_resource_size(compiler, resource, shader_resource, variant);
428
429 shader_resource.size -= shader_resource.offset;
430
431 resources.push_back(shader_resource);
432 }
433}
434
435void SPIRVReflection::parse_specialization_constants(const spirv_cross::Compiler &compiler, VkShaderStageFlagBits stage, std::vector<ShaderResource> &resources, const ShaderVariant &variant)
436{

Callers

nothing calls this directly

Calls 2

read_resource_sizeFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected