-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Support copy from buffer to texture for GLES blitpass, use blit pass to set contents in glyph atlas. #52510
Conversation
@@ -263,7 +263,17 @@ ContentContext::ContentContext( | |||
desc.size = ISize{1, 1}; | |||
empty_texture_ = GetContext()->GetResourceAllocator()->CreateTexture(desc); | |||
auto data = Color::BlackTransparent().ToR8G8B8A8(); | |||
if (!empty_texture_->SetContents(data.data(), 4)) { | |||
auto cmd_buffer = GetContext()->CreateCommandBuffer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to change a few places to use the blitpass to make sure it works. We should eventually remove Texture::SetContents.
@@ -864,6 +853,29 @@ std::optional<Entity> BlendFilterContents::CreateFramebufferAdvancedBlend( | |||
|
|||
std::shared_ptr<CommandBuffer> cmd_buffer = | |||
renderer.GetContext()->CreateCommandBuffer(); | |||
|
|||
// Generate a 1x1 texture to implement foreground color blending. | |||
if (foreground_color.has_value()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better because we don't need to create an extra cmd buffer or host texture for the upload.
@@ -450,6 +473,21 @@ std::shared_ptr<GlyphAtlas> TypographerContextSkia::CreateGlyphAtlas( | |||
} | |||
atlas_context_skia.UpdateBitmap(bitmap); | |||
|
|||
// If the new atlas size is the same size as the previous texture, reuse the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an optimization that was reverted because TextureMTL::SetContents is unsafe.
@chinmaygarde PTAL |
Whoops. Missing this. Looking. |
@@ -31,11 +30,6 @@ class DeviceBuffer { | |||
/// @brief Create a buffer view of this entire buffer. | |||
static BufferView AsBufferView(std::shared_ptr<DeviceBuffer> buffer); | |||
|
|||
virtual std::shared_ptr<Texture> AsTexture( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, I didn't know this API existed.
@@ -20,11 +20,13 @@ class Texture { | |||
|
|||
virtual void SetLabel(std::string_view label) = 0; | |||
|
|||
// Deprecated: use BlitPass::AddCopy instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An issue to followup on cleaning this up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case PixelFormat::kR16G16B16A16Float: | ||
internal_format = GL_RGBA; | ||
external_format = GL_RGBA; | ||
type = GL_HALF_FLOAT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these are supported by GL ES 2.0 but we will probably put these behind a capability check anyway I suppose.
if (!gl_handle.has_value()) { | ||
VALIDATION_LOG | ||
<< "Texture was collected before it could be uploaded to the GPU."; | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return false here right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
BarrierVK barrier; | ||
barrier.cmd_buffer = cmd_buffer; | ||
barrier.src_access = vk::AccessFlagBits::eColorAttachmentWrite | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why you need the ColorAttachmentWrite src access. Only the transfer write should be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the return false;
in the GLES blit, I think everything else lgtm with minor nits. I didn't look super closely at the mostly mechanical replacements of the SetContents
call but I trust those are fine. Thanks!
…tpass, use blit pass to set contents in glyph atlas. (flutter/engine#52510)
…147955) flutter/engine@1c52274...8b0ab93 2024-05-08 [email protected] [Impeller] Support copy from buffer to texture for GLES blitpass, use blit pass to set contents in glyph atlas. (flutter/engine#52510) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
… of origin for buffer to texture copies. (#52555) Based on #52510 Work towards flutter/flutter#138798 Change IPoint destination_origin to IRect destination_region, which allows us to specify an area smaller than the entire texture to replace. This will eventually allow us to only upload individual glyphs. This fixes the cubemap issue I previously hit: each face needs to track initialization separately.
part of flutter/flutter#138798
Works around flutter/flutter#144498 for the glyph atlas.
Adds BlitPass::AddCopy implementation for GLES, which is mostly a copy of Texture::SetContents. Updates the glyph atlas to use a blit pass and device private textures instead of set contents (which is unsafely on Metal).
This also removes DeviceBuffer::AsTexture, which isn't actually used anywhere - and creates a linear texture on iOS (and fails with an unsupported API on simulators).
Note that in general, we don't actually have support for hostVisible textures on GLES or Vulkan. Instead, VMA is falling back to device private textures. We may want to, separately, remove the concept of host visible from textures - and similarly remove the concept of transient from buffers.