mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Generate descriptor set layout bindings in generated C++ headers. (flutter/engine#34779)
This commit is contained in:
parent
59b2b68853
commit
1867ab94c4
@ -147,6 +147,34 @@ std::move({{ arg.argument_name }}){% if not loop.is_last %}, {% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
// ===========================================================================
|
||||
// Metadata for Vulkan =======================================================
|
||||
// ===========================================================================
|
||||
#ifdef IMPELLER_ENABLE_VULKAN_REFLECTION
|
||||
{% if length(buffers)+length(sampled_images) > 0 %}
|
||||
static constexpr std::array<VkDescriptorSetLayoutBinding,{{length(buffers)+length(sampled_images)}}> kDescriptorSetLayouts{
|
||||
{% for buffer in buffers %}
|
||||
VkDescriptorSetLayoutBinding{
|
||||
{{buffer.binding}}, // binding = {{buffer.binding}}
|
||||
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, // descriptorType = Uniform Buffer
|
||||
1, // descriptorCount = 1
|
||||
{{to_vk_shader_stage_flag_bits(shader_stage)}}, // stageFlags = {{to_shader_stage(shader_stage)}}
|
||||
nullptr, // pImmutableSamplers = NULL
|
||||
},
|
||||
{% endfor %}
|
||||
{% for sampled_image in sampled_images %}
|
||||
VkDescriptorSetLayoutBinding{
|
||||
{{sampled_image.binding}}, // binding = {{sampled_image.binding}}
|
||||
VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, // descriptorType = Sampled Image
|
||||
1, // descriptorCount = 1
|
||||
{{to_vk_shader_stage_flag_bits(shader_stage)}},// stageFlags = {{to_shader_stage(shader_stage)}}
|
||||
nullptr, // pImmutableSamplers = NULL
|
||||
},
|
||||
{% endfor %}
|
||||
};
|
||||
{% endif %}
|
||||
#endif
|
||||
|
||||
}; // struct {{camel_case(shader_name)}}{{camel_case(shader_stage)}}Shader
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@ -108,6 +108,28 @@ static std::string StringToShaderStage(std::string str) {
|
||||
return "ShaderStage::kUnknown";
|
||||
}
|
||||
|
||||
static std::string StringToVkShaderStage(std::string str) {
|
||||
if (str == "vertex") {
|
||||
return "VK_SHADER_STAGE_VERTEX_BIT";
|
||||
}
|
||||
if (str == "fragment") {
|
||||
return "VK_SHADER_STAGE_FRAGMENT_BIT";
|
||||
}
|
||||
|
||||
if (str == "tessellation_control") {
|
||||
return "VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT";
|
||||
}
|
||||
|
||||
if (str == "tessellation_evaluation") {
|
||||
return "VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT";
|
||||
}
|
||||
|
||||
if (str == "compute") {
|
||||
return "VK_SHADER_STAGE_COMPUTE_BIT";
|
||||
}
|
||||
return "VK_SHADER_STAGE_ALL_GRAPHICS";
|
||||
}
|
||||
|
||||
Reflector::Reflector(Options options,
|
||||
std::shared_ptr<const spirv_cross::ParsedIR> ir,
|
||||
std::shared_ptr<fml::Mapping> shader_data,
|
||||
@ -367,6 +389,10 @@ std::shared_ptr<fml::Mapping> Reflector::InflateTemplate(
|
||||
[type = compiler_.GetType()](inja::Arguments& args) {
|
||||
return ToString(type);
|
||||
});
|
||||
env.add_callback(
|
||||
"to_vk_shader_stage_flag_bits", 1u, [](inja::Arguments& args) {
|
||||
return StringToVkShaderStage(args.at(0u)->get<std::string>());
|
||||
});
|
||||
|
||||
auto inflated_template =
|
||||
std::make_shared<std::string>(env.render(tmpl, *template_arguments_));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user