Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 1 addition & 11 deletions impeller/compiler/code_gen_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,30 +173,20 @@ 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)}}
},
{% endfor %}
{% 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 %}
};

Expand Down
17 changes: 9 additions & 8 deletions impeller/compiler/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {};
Expand Down
5 changes: 2 additions & 3 deletions impeller/compiler/compiler_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include "impeller/compiler/compiler_backend.h"

#include <limits>

#include "impeller/base/comparable.h"

namespace impeller {
Expand Down Expand Up @@ -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 {
Expand Down
30 changes: 3 additions & 27 deletions impeller/compiler/reflector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "impeller/compiler/reflector.h"

#include <atomic>
#include <limits>
#include <optional>
#include <set>
#include <sstream>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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 {
Expand All @@ -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(
Expand Down
10 changes: 0 additions & 10 deletions impeller/core/shader_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#pragma once

#include <cstddef>
#include <limits>
#include <optional>
#include <string_view>
#include <vector>
Expand Down Expand Up @@ -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>
Expand Down
4 changes: 0 additions & 4 deletions impeller/playground/backend/vulkan/playground_impl_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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),
Expand Down
4 changes: 1 addition & 3 deletions impeller/renderer/backend/vulkan/descriptor_pool_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions impeller/renderer/backend/vulkan/formats_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/embedder/embedder_surface_metal_impeller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down