This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] playground upload to device private on macOS #41001
Merged
auto-submit
merged 3 commits into
flutter:main
from
jonahwilliams:fix_load_texture_for_desktop_mac
Apr 10, 2023
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -400,6 +400,54 @@ std::shared_ptr<Texture> CreateTextureForDecompressedImage( | |
| const std::shared_ptr<Context>& context, | ||
| DecompressedImage& decompressed_image, | ||
| bool enable_mipmapping) { | ||
| // TODO(https://github.com/flutter/flutter/issues/123468): copying buffers to | ||
| // textures is not implemented for GLES/Vulkan. | ||
| #if FML_OS_MACOSX | ||
| impeller::TextureDescriptor texture_descriptor; | ||
| texture_descriptor.storage_mode = impeller::StorageMode::kDevicePrivate; | ||
| texture_descriptor.format = PixelFormat::kR8G8B8A8UNormInt; | ||
| texture_descriptor.size = decompressed_image.GetSize(); | ||
| texture_descriptor.mip_count = | ||
| enable_mipmapping ? decompressed_image.GetSize().MipCount() : 1u; | ||
|
|
||
| auto dest_texture = | ||
| context->GetResourceAllocator()->CreateTexture(texture_descriptor); | ||
| if (!dest_texture) { | ||
| FML_DLOG(ERROR) << "Could not create Impeller texture."; | ||
| return nullptr; | ||
| } | ||
|
|
||
| auto buffer = context->GetResourceAllocator()->CreateBufferWithCopy( | ||
| *decompressed_image.GetAllocation().get()); | ||
|
|
||
| dest_texture->SetLabel( | ||
| impeller::SPrintF("ui.Image(%p)", dest_texture.get()).c_str()); | ||
|
|
||
| auto command_buffer = context->CreateCommandBuffer(); | ||
| if (!command_buffer) { | ||
| FML_DLOG(ERROR) << "Could not create command buffer for mipmap generation."; | ||
| return nullptr; | ||
| } | ||
| command_buffer->SetLabel("Mipmap Command Buffer"); | ||
|
|
||
| auto blit_pass = command_buffer->CreateBlitPass(); | ||
| if (!blit_pass) { | ||
| FML_DLOG(ERROR) << "Could not create blit pass for mipmap generation."; | ||
| return nullptr; | ||
| } | ||
| blit_pass->SetLabel("Mipmap Blit Pass"); | ||
| blit_pass->AddCopy(buffer->AsBufferView(), dest_texture); | ||
| if (texture_descriptor.size.MipCount() > 1) { | ||
|
||
| blit_pass->GenerateMipmap(dest_texture); | ||
| } | ||
|
|
||
| blit_pass->EncodeCommands(context->GetResourceAllocator()); | ||
| if (!command_buffer->SubmitCommands()) { | ||
| FML_DLOG(ERROR) << "Failed to submit blit pass command buffer."; | ||
| return nullptr; | ||
| } | ||
| return dest_texture; | ||
| #else | ||
| auto texture_descriptor = TextureDescriptor{}; | ||
| texture_descriptor.storage_mode = StorageMode::kHostVisible; | ||
| texture_descriptor.format = PixelFormat::kR8G8B8A8UNormInt; | ||
|
|
@@ -420,6 +468,7 @@ std::shared_ptr<Texture> CreateTextureForDecompressedImage( | |
| return nullptr; | ||
| } | ||
| return texture; | ||
| #endif // FML_OS_MACOS | ||
| } | ||
| } // namespace | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The comment doesn't seem to align with the
#if. The if blocks a platform, the comment talks about backends.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.
we don't have an ifdef for metal as far as I know. Technically macOS is only metal, except that we can run vulkan locally so this change breaks that without a modification to this code.
We can also fix this by finishing the blit pass implementation and removing the check altogether.
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.
Looks like this did break something, but hard to tell from CI logs.