mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Revert "[Impeller] Patch the compiler to account for subpass inputs and PSO metadata." (flutter/engine#45777)
Reverts flutter/engine#45739 fixes https://github.com/flutter/flutter/issues/134666
This commit is contained in:
parent
bc3ff1b5bc
commit
0a381989a4
@ -1667,7 +1667,7 @@ TEST_P(AiksTest, ColorWheel) {
|
||||
auto callback = [&](AiksContext& renderer) -> std::optional<Picture> {
|
||||
// UI state.
|
||||
static bool cache_the_wheel = true;
|
||||
static int current_blend_index = 14;
|
||||
static int current_blend_index = 3;
|
||||
static float dst_alpha = 1;
|
||||
static float src_alpha = 1;
|
||||
static Color color0 = Color::Red();
|
||||
|
||||
@ -173,11 +173,10 @@ std::move({{ arg.argument_name }}){% if not loop.is_last %}, {% endif %}
|
||||
// ===========================================================================
|
||||
// Metadata for Vulkan =======================================================
|
||||
// ===========================================================================
|
||||
static constexpr std::array<DescriptorSetLayout,{{length(buffers)+length(sampled_images)+length(subpass_inputs)}}> kDescriptorSetLayouts{
|
||||
static constexpr std::array<DescriptorSetLayout,{{length(buffers)+length(sampled_images)}}> kDescriptorSetLayouts{
|
||||
{% for buffer in buffers %}
|
||||
DescriptorSetLayout{
|
||||
{{buffer.binding}}, // binding = {{buffer.binding}}
|
||||
{{buffer.input_attachment_index}}, // input_attachment_index = {{buffer.input_attachment_index}}
|
||||
{{buffer.descriptor_type}}, // descriptor_type = {{buffer.descriptor_type}}
|
||||
{{to_shader_stage(shader_stage)}}, // shader_stage = {{to_shader_stage(shader_stage)}}
|
||||
},
|
||||
@ -185,18 +184,9 @@ std::move({{ arg.argument_name }}){% if not loop.is_last %}, {% endif %}
|
||||
{% for sampled_image in sampled_images %}
|
||||
DescriptorSetLayout{
|
||||
{{sampled_image.binding}}, // binding = {{sampled_image.binding}}
|
||||
{{sampled_image.input_attachment_index}}, // input_attachment_index = {{sampled_image.input_attachment_index}}
|
||||
{{sampled_image.descriptor_type}}, // descriptor_type = {{sampled_image.descriptor_type}}
|
||||
{{to_shader_stage(shader_stage)}}, // shader_stage = {{to_shader_stage(shader_stage)}}
|
||||
},
|
||||
{% endfor %}
|
||||
{% for subpass_input in subpass_inputs %}
|
||||
DescriptorSetLayout{
|
||||
{{subpass_input.binding}}, // binding = {{subpass_input.binding}}
|
||||
{{subpass_input.input_attachment_index}}, // input_attachment_index = {{subpass_input.input_attachment_index}}
|
||||
{{subpass_input.descriptor_type}}, // descriptor_type = {{subpass_input.descriptor_type}}
|
||||
{{to_shader_stage(shader_stage)}}, // shader_stage = {{to_shader_stage(shader_stage)}}
|
||||
},
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
|
||||
@ -115,13 +115,15 @@ static CompilerBackend CreateMSLCompiler(
|
||||
static CompilerBackend CreateVulkanCompiler(
|
||||
const spirv_cross::ParsedIR& ir,
|
||||
const SourceOptions& source_options) {
|
||||
auto vk_compiler = std::make_shared<spirv_cross::CompilerGLSL>(ir);
|
||||
spirv_cross::CompilerGLSL::Options sl_options;
|
||||
sl_options.vulkan_semantics = true;
|
||||
sl_options.force_zero_initialized_variables = true;
|
||||
sl_options.es = false;
|
||||
vk_compiler->set_common_options(sl_options);
|
||||
return CompilerBackend(vk_compiler);
|
||||
// TODO(dnfield): It seems like what we'd want is a CompilerGLSL with
|
||||
// vulkan_semantics set to true, but that has regressed some things on GLES
|
||||
// somehow. In the mean time, go back to using CompilerMSL, but set the Metal
|
||||
// Language version to something really high so that we don't get weird
|
||||
// complaints about using Metal features while trying to build Vulkan shaders.
|
||||
// https://github.com/flutter/flutter/issues/123795
|
||||
return CreateMSLCompiler(
|
||||
ir, source_options,
|
||||
spirv_cross::CompilerMSL::Options::make_msl_version(3, 0, 0));
|
||||
}
|
||||
|
||||
static CompilerBackend CreateGLSLCompiler(const spirv_cross::ParsedIR& ir,
|
||||
@ -216,7 +218,6 @@ static CompilerBackend CreateCompiler(const spirv_cross::ParsedIR& ir,
|
||||
break;
|
||||
case TargetPlatform::kSkSL:
|
||||
compiler = CreateSkSLCompiler(ir, source_options);
|
||||
break;
|
||||
}
|
||||
if (!compiler) {
|
||||
return {};
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
|
||||
#include "impeller/compiler/compiler_backend.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "impeller/base/comparable.h"
|
||||
|
||||
namespace impeller {
|
||||
@ -46,7 +44,8 @@ uint32_t CompilerBackend::GetExtendedMSLResourceBinding(
|
||||
if (auto compiler = GetGLSLCompiler()) {
|
||||
return compiler->get_decoration(id, spv::Decoration::DecorationBinding);
|
||||
}
|
||||
return std::numeric_limits<uint32_t>::max();
|
||||
const auto kOOBIndex = static_cast<uint32_t>(-1);
|
||||
return kOOBIndex;
|
||||
}
|
||||
|
||||
const spirv_cross::Compiler* CompilerBackend::GetCompiler() const {
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include "impeller/compiler/reflector.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
@ -217,9 +216,9 @@ std::optional<nlohmann::json> Reflector::GenerateTemplateArguments() const {
|
||||
if (auto storage_buffers_json =
|
||||
ReflectResources(shader_resources.storage_buffers);
|
||||
storage_buffers_json.has_value()) {
|
||||
for (auto storage_buffer : storage_buffers_json.value()) {
|
||||
storage_buffer["descriptor_type"] = "DescriptorType::kStorageBuffer";
|
||||
buffers.emplace_back(std::move(storage_buffer));
|
||||
for (auto uniform_buffer : storage_buffers_json.value()) {
|
||||
uniform_buffer["descriptor_type"] = "DescriptorType::kStorageBuffer";
|
||||
buffers.emplace_back(std::move(uniform_buffer));
|
||||
}
|
||||
} else {
|
||||
return std::nullopt;
|
||||
@ -262,19 +261,6 @@ std::optional<nlohmann::json> Reflector::GenerateTemplateArguments() const {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if (auto inputs = ReflectResources(shader_resources.subpass_inputs);
|
||||
inputs.has_value()) {
|
||||
auto& subpass_inputs = root["subpass_inputs"] = nlohmann::json::array_t{};
|
||||
for (auto input : inputs.value()) {
|
||||
input["descriptor_type"] = "DescriptorType::kSubpassInput";
|
||||
subpass_inputs.emplace_back(std::move(input));
|
||||
}
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto stage_outputs = ReflectResources(shader_resources.stage_outputs);
|
||||
stage_outputs.has_value()) {
|
||||
root["stage_outputs"] = std::move(stage_outputs.value());
|
||||
@ -445,14 +431,6 @@ std::vector<size_t> Reflector::ComputeOffsets(
|
||||
return offsets;
|
||||
}
|
||||
|
||||
static uint32_t GetResourceDecorationIfPresent(const CompilerBackend& compiler,
|
||||
spirv_cross::ID id,
|
||||
spv::Decoration decoration) {
|
||||
return compiler->has_decoration(id, decoration)
|
||||
? compiler->get_decoration(id, decoration)
|
||||
: std::numeric_limits<uint32_t>::max();
|
||||
}
|
||||
|
||||
std::optional<nlohmann::json::object_t> Reflector::ReflectResource(
|
||||
const spirv_cross::Resource& resource,
|
||||
std::optional<size_t> offset) const {
|
||||
@ -467,8 +445,6 @@ std::optional<nlohmann::json::object_t> Reflector::ReflectResource(
|
||||
resource.id, spv::Decoration::DecorationDescriptorSet);
|
||||
result["location"] = compiler_->get_decoration(
|
||||
resource.id, spv::Decoration::DecorationLocation);
|
||||
result["input_attachment_index"] = GetResourceDecorationIfPresent(
|
||||
compiler_, resource.id, spv::Decoration::DecorationInputAttachmentIndex);
|
||||
result["index"] =
|
||||
compiler_->get_decoration(resource.id, spv::Decoration::DecorationIndex);
|
||||
result["ext_res_0"] = compiler_.GetExtendedMSLResourceBinding(
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@ -145,21 +144,12 @@ enum class DescriptorType {
|
||||
kSampledImage,
|
||||
kImage,
|
||||
kSampler,
|
||||
kSubpassInput,
|
||||
};
|
||||
|
||||
struct DescriptorSetLayout {
|
||||
uint32_t binding;
|
||||
uint32_t input_attachment_index;
|
||||
DescriptorType descriptor_type;
|
||||
ShaderStage shader_stage;
|
||||
|
||||
constexpr std::optional<uint32_t> GetInputAttachmentIndexIfValid() const {
|
||||
if (std::numeric_limits<uint32_t>::max() == input_attachment_index) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return input_attachment_index;
|
||||
}
|
||||
};
|
||||
|
||||
template <size_t Size>
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/mapping.h"
|
||||
#include "impeller/entity/vk/entity_shaders_vk.h"
|
||||
#include "impeller/entity/vk/framebuffer_blend_shaders_vk.h"
|
||||
#include "impeller/entity/vk/modern_shaders_vk.h"
|
||||
#include "impeller/fixtures/vk/fixtures_shaders_vk.h"
|
||||
#include "impeller/playground/imgui/vk/imgui_shaders_vk.h"
|
||||
@ -34,9 +33,6 @@ ShaderLibraryMappingsForPlayground() {
|
||||
impeller_entity_shaders_vk_length),
|
||||
std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_vk_data,
|
||||
impeller_modern_shaders_vk_length),
|
||||
std::make_shared<fml::NonOwnedMapping>(
|
||||
impeller_framebuffer_blend_shaders_vk_data,
|
||||
impeller_framebuffer_blend_shaders_vk_length),
|
||||
std::make_shared<fml::NonOwnedMapping>(
|
||||
impeller_fixtures_shaders_vk_data,
|
||||
impeller_fixtures_shaders_vk_length),
|
||||
|
||||
@ -24,9 +24,7 @@ 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::eInputAttachment, pool_count},
|
||||
};
|
||||
{vk::DescriptorType::eStorageBuffer, pool_count}};
|
||||
|
||||
vk::DescriptorPoolCreateInfo pool_info;
|
||||
pool_info.setMaxSets(pools.size() * pool_count);
|
||||
|
||||
@ -274,17 +274,21 @@ constexpr vk::DescriptorType ToVKDescriptorType(DescriptorType type) {
|
||||
switch (type) {
|
||||
case DescriptorType::kSampledImage:
|
||||
return vk::DescriptorType::eCombinedImageSampler;
|
||||
break;
|
||||
case DescriptorType::kUniformBuffer:
|
||||
return vk::DescriptorType::eUniformBuffer;
|
||||
break;
|
||||
case DescriptorType::kStorageBuffer:
|
||||
return vk::DescriptorType::eStorageBuffer;
|
||||
break;
|
||||
case DescriptorType::kImage:
|
||||
return vk::DescriptorType::eSampledImage;
|
||||
break;
|
||||
case DescriptorType::kSampler:
|
||||
return vk::DescriptorType::eSampler;
|
||||
case DescriptorType::kSubpassInput:
|
||||
return vk::DescriptorType::eInputAttachment;
|
||||
break;
|
||||
}
|
||||
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#include "flutter/fml/synchronization/sync_switch.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_impeller.h"
|
||||
#include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h"
|
||||
#import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h"
|
||||
#include "impeller/entity/mtl/entity_shaders.h"
|
||||
#include "impeller/entity/mtl/framebuffer_blend_shaders.h"
|
||||
#include "impeller/entity/mtl/modern_shaders.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user