Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] More sundry fixes to the Vulkan backend. #40244

Merged
merged 7 commits into from
Mar 13, 2023
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
26 changes: 20 additions & 6 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1409,10 +1409,18 @@ ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/command_buffer_vk.cc +
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/command_buffer_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/command_encoder_vk.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/command_encoder_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/command_pool_vk.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/command_pool_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/context_vk.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/context_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/debug_report_vk.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/debug_report_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/descriptor_pool_vk.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/descriptor_pool_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/device_buffer_vk.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/device_buffer_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/fence_waiter_vk.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/fence_waiter_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/formats_vk.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/formats_vk.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -1454,6 +1462,8 @@ ORIGIN: ../../../flutter/impeller/renderer/buffer.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/buffer.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/buffer_view.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/buffer_view.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/capabilities.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/capabilities.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/command.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/command.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/command_buffer.cc + ../../../flutter/LICENSE
Expand All @@ -1468,13 +1478,10 @@ ORIGIN: ../../../flutter/impeller/renderer/compute_pipeline_descriptor.cc + ../.
ORIGIN: ../../../flutter/impeller/renderer/compute_pipeline_descriptor.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/context.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/context.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/descriptor_set_layout.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/device_buffer.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/device_buffer.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/device_buffer_descriptor.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/device_buffer_descriptor.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/device_capabilities.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/device_capabilities.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/formats.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/formats.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/renderer/gpu_tracer.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -3936,10 +3943,18 @@ FILE: ../../../flutter/impeller/renderer/backend/vulkan/command_buffer_vk.cc
FILE: ../../../flutter/impeller/renderer/backend/vulkan/command_buffer_vk.h
FILE: ../../../flutter/impeller/renderer/backend/vulkan/command_encoder_vk.cc
FILE: ../../../flutter/impeller/renderer/backend/vulkan/command_encoder_vk.h
FILE: ../../../flutter/impeller/renderer/backend/vulkan/command_pool_vk.cc
FILE: ../../../flutter/impeller/renderer/backend/vulkan/command_pool_vk.h
FILE: ../../../flutter/impeller/renderer/backend/vulkan/context_vk.cc
FILE: ../../../flutter/impeller/renderer/backend/vulkan/context_vk.h
FILE: ../../../flutter/impeller/renderer/backend/vulkan/debug_report_vk.cc
FILE: ../../../flutter/impeller/renderer/backend/vulkan/debug_report_vk.h
FILE: ../../../flutter/impeller/renderer/backend/vulkan/descriptor_pool_vk.cc
FILE: ../../../flutter/impeller/renderer/backend/vulkan/descriptor_pool_vk.h
FILE: ../../../flutter/impeller/renderer/backend/vulkan/device_buffer_vk.cc
FILE: ../../../flutter/impeller/renderer/backend/vulkan/device_buffer_vk.h
FILE: ../../../flutter/impeller/renderer/backend/vulkan/fence_waiter_vk.cc
FILE: ../../../flutter/impeller/renderer/backend/vulkan/fence_waiter_vk.h
FILE: ../../../flutter/impeller/renderer/backend/vulkan/formats_vk.cc
FILE: ../../../flutter/impeller/renderer/backend/vulkan/formats_vk.h
FILE: ../../../flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.cc
Expand Down Expand Up @@ -3981,6 +3996,8 @@ FILE: ../../../flutter/impeller/renderer/buffer.cc
FILE: ../../../flutter/impeller/renderer/buffer.h
FILE: ../../../flutter/impeller/renderer/buffer_view.cc
FILE: ../../../flutter/impeller/renderer/buffer_view.h
FILE: ../../../flutter/impeller/renderer/capabilities.cc
FILE: ../../../flutter/impeller/renderer/capabilities.h
FILE: ../../../flutter/impeller/renderer/command.cc
FILE: ../../../flutter/impeller/renderer/command.h
FILE: ../../../flutter/impeller/renderer/command_buffer.cc
Expand All @@ -3995,13 +4012,10 @@ FILE: ../../../flutter/impeller/renderer/compute_pipeline_descriptor.cc
FILE: ../../../flutter/impeller/renderer/compute_pipeline_descriptor.h
FILE: ../../../flutter/impeller/renderer/context.cc
FILE: ../../../flutter/impeller/renderer/context.h
FILE: ../../../flutter/impeller/renderer/descriptor_set_layout.h
FILE: ../../../flutter/impeller/renderer/device_buffer.cc
FILE: ../../../flutter/impeller/renderer/device_buffer.h
FILE: ../../../flutter/impeller/renderer/device_buffer_descriptor.cc
FILE: ../../../flutter/impeller/renderer/device_buffer_descriptor.h
FILE: ../../../flutter/impeller/renderer/device_capabilities.cc
FILE: ../../../flutter/impeller/renderer/device_capabilities.h
FILE: ../../../flutter/impeller/renderer/formats.cc
FILE: ../../../flutter/impeller/renderer/formats.h
FILE: ../../../flutter/impeller/renderer/gpu_tracer.cc
Expand Down
2 changes: 1 addition & 1 deletion impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ bool GenerateMipmap(const std::shared_ptr<Context>& context,
}
pass->GenerateMipmap(std::move(texture), std::move(label));
pass->EncodeCommands(context->GetResourceAllocator());
return true;
return buffer->SubmitCommands();
}

TEST_P(AiksTest, CanRenderTiledTexture) {
Expand Down
2 changes: 1 addition & 1 deletion impeller/aiks/picture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ std::shared_ptr<Texture> Picture::RenderToTexture(
// features to Image someday.
auto impeller_context = context.GetContext();
RenderTarget target;
if (impeller_context->GetDeviceCapabilities().SupportsOffscreenMSAA()) {
if (impeller_context->GetCapabilities()->SupportsOffscreenMSAA()) {
target = RenderTarget::CreateOffscreenMSAA(*impeller_context, size);
} else {
target = RenderTarget::CreateOffscreen(*impeller_context, size);
Expand Down
12 changes: 4 additions & 8 deletions impeller/compiler/code_gen_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ constexpr std::string_view kReflectionHeaderTemplate =

#include "impeller/renderer/compute_command.h" {# // nogncheck #}

#include "impeller/renderer/descriptor_set_layout.h" {# // nogncheck #}

#include "impeller/renderer/sampler.h" {# // nogncheck #}

#include "impeller/renderer/shader_types.h" {# // nogncheck #}
Expand Down Expand Up @@ -166,17 +164,15 @@ std::move({{ arg.argument_name }}){% if not loop.is_last %}, {% endif %}
{% for buffer in buffers %}
DescriptorSetLayout{
{{buffer.binding}}, // binding = {{buffer.binding}}
DescriptorType::kUniformBuffer, // descriptorType = Uniform Buffer
1, // descriptorCount = 1
{{to_shader_stage(shader_stage)}}, // stageFlags = {{to_shader_stage(shader_stage)}}
DescriptorType::kUniformBuffer, // descriptor_type = Uniform Buffer
{{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, // descriptorType = Sampled Image
1, // descriptorCount = 1
{{to_shader_stage(shader_stage)}}, // stageFlags = {{to_shader_stage(shader_stage)}}
DescriptorType::kSampledImage, // descriptor_type = Sampled Image
{{to_shader_stage(shader_stage)}}, // shader_stage = {{to_shader_stage(shader_stage)}}
},
{% endfor %}
};
Expand Down
14 changes: 7 additions & 7 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ static std::unique_ptr<PipelineT> CreateDefaultPipeline(
return nullptr;
}
// Apply default ContentContextOptions to the descriptor.
const auto default_color_fmt = context.GetColorAttachmentPixelFormat();
const auto default_color_fmt =
context.GetCapabilities()->GetDefaultColorFormat();
ContentContextOptions{.color_attachment_pixel_format = default_color_fmt}
.ApplyToPipelineDescriptor(*desc);
return std::make_unique<PipelineT>(context, desc);
Expand All @@ -175,15 +176,15 @@ ContentContext::ContentContext(std::shared_ptr<Context> context)
CreateDefaultPipeline<LinearGradientFillPipeline>(*context_);
radial_gradient_fill_pipelines_[{}] =
CreateDefaultPipeline<RadialGradientFillPipeline>(*context_);
if (context_->GetDeviceCapabilities().SupportsSSBO()) {
if (context_->GetCapabilities()->SupportsSSBO()) {
linear_gradient_ssbo_fill_pipelines_[{}] =
CreateDefaultPipeline<LinearGradientSSBOFillPipeline>(*context_);
radial_gradient_ssbo_fill_pipelines_[{}] =
CreateDefaultPipeline<RadialGradientSSBOFillPipeline>(*context_);
sweep_gradient_ssbo_fill_pipelines_[{}] =
CreateDefaultPipeline<SweepGradientSSBOFillPipeline>(*context_);
}
if (context_->GetDeviceCapabilities().SupportsFramebufferFetch()) {
if (context_->GetCapabilities()->SupportsFramebufferFetch()) {
framebuffer_blend_color_pipelines_[{}] =
CreateDefaultPipeline<FramebufferBlendColorPipeline>(*context_);
framebuffer_blend_colorburn_pipelines_[{}] =
Expand Down Expand Up @@ -315,8 +316,7 @@ std::shared_ptr<Texture> ContentContext::MakeSubpass(
auto context = GetContext();

RenderTarget subpass_target;
if (context->GetDeviceCapabilities().SupportsOffscreenMSAA() &&
msaa_enabled) {
if (context->GetCapabilities()->SupportsOffscreenMSAA() && msaa_enabled) {
subpass_target = RenderTarget::CreateOffscreenMSAA(
*context, texture_size, SPrintF("%s Offscreen", label.c_str()),
RenderTarget::kDefaultColorAttachmentConfigMSAA, std::nullopt);
Expand Down Expand Up @@ -374,8 +374,8 @@ std::shared_ptr<Context> ContentContext::GetContext() const {
return context_;
}

const IDeviceCapabilities& ContentContext::GetDeviceCapabilities() const {
return context_->GetDeviceCapabilities();
const Capabilities& ContentContext::GetDeviceCapabilities() const {
return *context_->GetCapabilities();
}

void ContentContext::SetWireframe(bool wireframe) {
Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/contents/content_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "impeller/entity/vertices.frag.h"
#include "impeller/entity/yuv_to_rgb_filter.frag.h"
#include "impeller/entity/yuv_to_rgb_filter.vert.h"
#include "impeller/renderer/device_capabilities.h"
#include "impeller/renderer/capabilities.h"
#include "impeller/renderer/formats.h"
#include "impeller/renderer/pipeline.h"
#include "impeller/scene/scene_context.h"
Expand Down Expand Up @@ -601,7 +601,7 @@ class ContentContext {

std::shared_ptr<GlyphAtlasContext> GetGlyphAtlasContext() const;

const IDeviceCapabilities& GetDeviceCapabilities() const;
const Capabilities& GetDeviceCapabilities() const;

void SetWireframe(bool wireframe);

Expand Down
7 changes: 3 additions & 4 deletions impeller/entity/contents/runtime_effect_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ bool RuntimeEffectContents::Render(const ContentContext& renderer,
/// Get or create runtime stage pipeline.
///

const auto& device_capabilities = context->GetDeviceCapabilities();
const auto color_attachment_format = context->GetColorAttachmentPixelFormat();
const auto stencil_attachment_format =
device_capabilities.GetDefaultStencilFormat();
const auto& caps = context->GetCapabilities();
const auto color_attachment_format = caps->GetDefaultColorFormat();
const auto stencil_attachment_format = caps->GetDefaultStencilFormat();

using VS = RuntimeEffectVertexShader;
PipelineDescriptor desc;
Expand Down
6 changes: 3 additions & 3 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static RenderTarget CreateRenderTarget(ContentContext& renderer,
/// What's important is the `StorageMode` of the textures, which cannot be
/// changed for the lifetime of the textures.

if (context->GetDeviceCapabilities().SupportsOffscreenMSAA()) {
if (context->GetCapabilities()->SupportsOffscreenMSAA()) {
return RenderTarget::CreateOffscreenMSAA(
*context, // context
size, // size
Expand Down Expand Up @@ -210,8 +210,8 @@ bool EntityPass::Render(ContentContext& renderer,
command_buffer->SetLabel("EntityPass Root Command Buffer");

if (renderer.GetContext()
->GetDeviceCapabilities()
.SupportsTextureToTextureBlits()) {
->GetCapabilities()
->SupportsTextureToTextureBlits()) {
auto blit_pass = command_buffer->CreateBlitPass();

blit_pass->AddCopy(offscreen_target.GetRenderTargetTexture(),
Expand Down
5 changes: 2 additions & 3 deletions impeller/playground/backend/metal/playground_impl_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@
}
data_->metal_layer = [CAMetalLayer layer];
data_->metal_layer.device = ContextMTL::Cast(*context).GetMTLDevice();
// This pixel format is one of the documented supported formats.
const auto color_fmt = context->GetColorAttachmentPixelFormat();
data_->metal_layer.pixelFormat = ToMTLPixelFormat(color_fmt);
data_->metal_layer.pixelFormat =
ToMTLPixelFormat(context->GetCapabilities()->GetDefaultColorFormat());
data_->metal_layer.framebufferOnly = NO;
cocoa_window.contentView.layer = data_->metal_layer;
cocoa_window.contentView.wantsLayer = YES;
Expand Down
9 changes: 7 additions & 2 deletions impeller/playground/playground.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,13 @@ std::shared_ptr<Texture> Playground::CreateTextureForFixture(
std::shared_ptr<Texture> Playground::CreateTextureForFixture(
const char* fixture_name,
bool enable_mipmapping) const {
return CreateTextureForFixture(OpenAssetAsMapping(fixture_name),
enable_mipmapping);
auto texture = CreateTextureForFixture(OpenAssetAsMapping(fixture_name),
enable_mipmapping);
if (texture == nullptr) {
return nullptr;
}
texture->SetLabel(fixture_name);
return texture;
}

std::shared_ptr<Texture> Playground::CreateTextureCubeForFixture(
Expand Down
5 changes: 2 additions & 3 deletions impeller/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ impeller_component("renderer") {
"buffer.h",
"buffer_view.cc",
"buffer_view.h",
"capabilities.cc",
"capabilities.h",
"command.cc",
"command.h",
"command_buffer.cc",
Expand All @@ -30,13 +32,10 @@ impeller_component("renderer") {
"compute_pipeline_descriptor.h",
"context.cc",
"context.h",
"descriptor_set_layout.h",
"device_buffer.cc",
"device_buffer.h",
"device_buffer_descriptor.cc",
"device_buffer_descriptor.h",
"device_capabilities.cc",
"device_capabilities.h",
"formats.cc",
"formats.h",
"gpu_tracer.cc",
Expand Down
14 changes: 5 additions & 9 deletions impeller/renderer/backend/gles/context_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "impeller/base/config.h"
#include "impeller/base/validation.h"
#include "impeller/base/work_queue_common.h"
#include "impeller/renderer/device_capabilities.h"
#include "impeller/renderer/capabilities.h"

namespace impeller {

Expand Down Expand Up @@ -72,7 +72,7 @@ ContextGLES::ContextGLES(std::unique_ptr<ProcTableGLES> gl,
// Create the device capabilities.
{
device_capabilities_ =
DeviceCapabilitiesBuilder()
CapabilitiesBuilder()
.SetHasThreadingRestrictions(true)
.SetSupportsOffscreenMSAA(false)
.SetSupportsSSBO(false)
Expand Down Expand Up @@ -145,13 +145,9 @@ std::shared_ptr<WorkQueue> ContextGLES::GetWorkQueue() const {
}

// |Context|
const IDeviceCapabilities& ContextGLES::GetDeviceCapabilities() const {
return *device_capabilities_;
}

// |Context|
PixelFormat ContextGLES::GetColorAttachmentPixelFormat() const {
return PixelFormat::kR8G8B8A8UNormInt;
const std::shared_ptr<const Capabilities>& ContextGLES::GetCapabilities()
const {
return device_capabilities_;
}

} // namespace impeller
9 changes: 3 additions & 6 deletions impeller/renderer/backend/gles/context_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "impeller/renderer/backend/gles/reactor_gles.h"
#include "impeller/renderer/backend/gles/sampler_library_gles.h"
#include "impeller/renderer/backend/gles/shader_library_gles.h"
#include "impeller/renderer/capabilities.h"
#include "impeller/renderer/context.h"
#include "impeller/renderer/device_capabilities.h"

namespace impeller {

Expand Down Expand Up @@ -41,7 +41,7 @@ class ContextGLES final : public Context,
std::shared_ptr<SamplerLibraryGLES> sampler_library_;
std::shared_ptr<WorkQueue> work_queue_;
std::shared_ptr<AllocatorGLES> resource_allocator_;
std::unique_ptr<IDeviceCapabilities> device_capabilities_;
std::shared_ptr<const Capabilities> device_capabilities_;
bool is_valid_ = false;

ContextGLES(
Expand Down Expand Up @@ -70,10 +70,7 @@ class ContextGLES final : public Context,
std::shared_ptr<WorkQueue> GetWorkQueue() const override;

// |Context|
const IDeviceCapabilities& GetDeviceCapabilities() const override;

// |Context|
PixelFormat GetColorAttachmentPixelFormat() const override;
const std::shared_ptr<const Capabilities>& GetCapabilities() const override;

FML_DISALLOW_COPY_AND_ASSIGN(ContextGLES);
};
Expand Down
Loading