[Impeller] Enable SSBOs in the Vulkan backend. (flutter/engine#40908)
[Impeller] Enable SSBOs in the Vulkan backend.
This commit is contained in:
@@ -162,14 +162,14 @@ std::move({{ arg.argument_name }}){% if not loop.is_last %}, {% endif %}
|
||||
{% for buffer in buffers %}
|
||||
DescriptorSetLayout{
|
||||
{{buffer.binding}}, // binding = {{buffer.binding}}
|
||||
DescriptorType::kUniformBuffer, // descriptor_type = Uniform Buffer
|
||||
{{buffer.descriptor_type}}, // descriptor_type = {{buffer.descriptor_type}}
|
||||
{{to_shader_stage(shader_stage)}}, // shader_stage = {{to_shader_stage(shader_stage)}}
|
||||
},
|
||||
{% endfor %}
|
||||
{% for sampled_image in sampled_images %}
|
||||
DescriptorSetLayout{
|
||||
{{sampled_image.binding}}, // binding = {{sampled_image.binding}}
|
||||
DescriptorType::kSampledImage, // descriptor_type = Sampled Image
|
||||
{{sampled_image.descriptor_type}}, // descriptor_type = {{sampled_image.descriptor_type}}
|
||||
{{to_shader_stage(shader_stage)}}, // shader_stage = {{to_shader_stage(shader_stage)}}
|
||||
},
|
||||
{% endfor %}
|
||||
|
||||
@@ -205,7 +205,8 @@ std::optional<nlohmann::json> Reflector::GenerateTemplateArguments() const {
|
||||
if (auto uniform_buffers_json =
|
||||
ReflectResources(shader_resources.uniform_buffers);
|
||||
uniform_buffers_json.has_value()) {
|
||||
for (const auto& uniform_buffer : uniform_buffers_json.value()) {
|
||||
for (auto uniform_buffer : uniform_buffers_json.value()) {
|
||||
uniform_buffer["descriptor_type"] = "DescriptorType::kUniformBuffer";
|
||||
buffers.emplace_back(std::move(uniform_buffer));
|
||||
}
|
||||
} else {
|
||||
@@ -214,7 +215,8 @@ std::optional<nlohmann::json> Reflector::GenerateTemplateArguments() const {
|
||||
if (auto storage_buffers_json =
|
||||
ReflectResources(shader_resources.storage_buffers);
|
||||
storage_buffers_json.has_value()) {
|
||||
for (const auto& uniform_buffer : storage_buffers_json.value()) {
|
||||
for (auto uniform_buffer : storage_buffers_json.value()) {
|
||||
uniform_buffer["descriptor_type"] = "DescriptorType::kStorageBuffer";
|
||||
buffers.emplace_back(std::move(uniform_buffer));
|
||||
}
|
||||
} else {
|
||||
@@ -244,12 +246,15 @@ std::optional<nlohmann::json> Reflector::GenerateTemplateArguments() const {
|
||||
}
|
||||
auto& sampled_images = root["sampled_images"] = nlohmann::json::array_t{};
|
||||
for (auto value : combined_sampled_images.value()) {
|
||||
value["descriptor_type"] = "DescriptorType::kSampledImage";
|
||||
sampled_images.emplace_back(std::move(value));
|
||||
}
|
||||
for (auto value : images.value()) {
|
||||
value["descriptor_type"] = "DescriptorType::kImage";
|
||||
sampled_images.emplace_back(std::move(value));
|
||||
}
|
||||
for (auto value : samplers.value()) {
|
||||
value["descriptor_type"] = "DescriptorType::kSampledSampler";
|
||||
sampled_images.emplace_back(std::move(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,14 +208,22 @@ static void SetDefaultLimitations(shaderc::CompileOptions& compiler_opts) {
|
||||
}
|
||||
|
||||
static void SetBindingBaseOffset(shaderc::CompileOptions& options) {
|
||||
constexpr uint32_t kFragBindingBase = 128;
|
||||
constexpr size_t kNumUniformKinds =
|
||||
static_cast<int>(shaderc_uniform_kind::shaderc_uniform_kind_buffer) + 1;
|
||||
for (size_t uniform_kind = 0; uniform_kind < kNumUniformKinds;
|
||||
uniform_kind++) {
|
||||
constexpr uint32_t kBindingBaseOffset = 64;
|
||||
static const shaderc_uniform_kind kUniformKinds[] = {
|
||||
shaderc_uniform_kind::shaderc_uniform_kind_sampler,
|
||||
shaderc_uniform_kind::shaderc_uniform_kind_texture,
|
||||
shaderc_uniform_kind::shaderc_uniform_kind_image,
|
||||
shaderc_uniform_kind::shaderc_uniform_kind_buffer, // UBOs
|
||||
shaderc_uniform_kind::shaderc_uniform_kind_storage_buffer, // SSBOs
|
||||
};
|
||||
|
||||
for (size_t i = 0u; i < sizeof(kUniformKinds) / sizeof(shaderc_uniform_kind);
|
||||
i++) {
|
||||
options.SetBindingBaseForStage(
|
||||
ToShaderCShaderKind(SourceType::kFragmentShader),
|
||||
static_cast<shaderc_uniform_kind>(uniform_kind), kFragBindingBase);
|
||||
shaderc_shader_kind::shaderc_fragment_shader, //
|
||||
kUniformKinds[i], //
|
||||
kBindingBaseOffset //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,8 +125,11 @@ struct SampledImageSlot {
|
||||
};
|
||||
|
||||
enum class DescriptorType {
|
||||
kSampledImage,
|
||||
kUniformBuffer,
|
||||
kStorageBuffer,
|
||||
kSampledImage,
|
||||
kImage,
|
||||
kSampler,
|
||||
};
|
||||
|
||||
struct DescriptorSetLayout {
|
||||
|
||||
@@ -310,7 +310,7 @@ bool CapabilitiesVK::SupportsOffscreenMSAA() const {
|
||||
|
||||
// |Capabilities|
|
||||
bool CapabilitiesVK::SupportsSSBO() const {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// |Capabilities|
|
||||
|
||||
@@ -183,7 +183,7 @@ DebugReportVK::Result DebugReportVK::OnDebugCallback(
|
||||
VALIDATION_LOG << stream.str();
|
||||
}
|
||||
|
||||
return Result::kAbort;
|
||||
return Result::kContinue;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -19,6 +19,9 @@ static vk::UniqueDescriptorPool CreatePool(const vk::Device& device,
|
||||
std::vector<vk::DescriptorPoolSize> pools = {
|
||||
{vk::DescriptorType::eCombinedImageSampler, pool_count},
|
||||
{vk::DescriptorType::eUniformBuffer, pool_count},
|
||||
{vk::DescriptorType::eStorageBuffer, pool_count},
|
||||
{vk::DescriptorType::eSampledImage, pool_count},
|
||||
{vk::DescriptorType::eSampler, pool_count},
|
||||
};
|
||||
|
||||
vk::DescriptorPoolCreateInfo pool_info;
|
||||
|
||||
@@ -279,6 +279,15 @@ constexpr vk::DescriptorSetLayoutBinding ToVKDescriptorSetLayoutBinding(
|
||||
case DescriptorType::kUniformBuffer:
|
||||
desc_type = vk::DescriptorType::eUniformBuffer;
|
||||
break;
|
||||
case DescriptorType::kStorageBuffer:
|
||||
desc_type = vk::DescriptorType::eStorageBuffer;
|
||||
break;
|
||||
case DescriptorType::kImage:
|
||||
desc_type = vk::DescriptorType::eSampledImage;
|
||||
break;
|
||||
case DescriptorType::kSampler:
|
||||
desc_type = vk::DescriptorType::eSampler;
|
||||
break;
|
||||
}
|
||||
binding.descriptorType = desc_type;
|
||||
binding.stageFlags = ToVkShaderStage(layout.shader_stage);
|
||||
|
||||
Reference in New Issue
Block a user