mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] fix validation error for playground texture upload. (flutter/engine#49957)
Buffer to image is missing barriers. We don't really need to use this for playgrounds though, as set contents does the right thing more or less. Fixes https://github.com/flutter/flutter/issues/142024
This commit is contained in:
parent
20e12c94dd
commit
89bdfba3d7
@ -63,6 +63,7 @@ static const std::vector<std::string> kSkipTests = {
|
||||
/// TODO(https://github.com/flutter/flutter/issues/142017): Turn on validation
|
||||
/// for all vulkan tests.
|
||||
static const std::vector<std::string> kVulkanValidationTests = {
|
||||
"impeller_Play_AiksTest_CanRenderImageRect_Vulkan",
|
||||
"impeller_Play_AiksTest_CanRenderTextFrame_Vulkan",
|
||||
};
|
||||
|
||||
|
||||
@ -385,29 +385,26 @@ static 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.
|
||||
if (context->GetCapabilities()->SupportsBufferToTextureBlits()) {
|
||||
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 texture_descriptor = TextureDescriptor{};
|
||||
texture_descriptor.storage_mode = StorageMode::kHostVisible;
|
||||
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 texture =
|
||||
context->GetResourceAllocator()->CreateTexture(texture_descriptor);
|
||||
if (!texture) {
|
||||
VALIDATION_LOG << "Could not allocate texture for fixture.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto uploaded = texture->SetContents(decompressed_image.GetAllocation());
|
||||
if (!uploaded) {
|
||||
VALIDATION_LOG << "Could not upload texture to device memory for fixture.";
|
||||
return nullptr;
|
||||
}
|
||||
if (enable_mipmapping) {
|
||||
auto command_buffer = context->CreateCommandBuffer();
|
||||
if (!command_buffer) {
|
||||
FML_DLOG(ERROR)
|
||||
@ -415,47 +412,16 @@ static std::shared_ptr<Texture> CreateTextureForDecompressedImage(
|
||||
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(DeviceBuffer::AsBufferView(buffer), dest_texture);
|
||||
if (enable_mipmapping) {
|
||||
blit_pass->GenerateMipmap(dest_texture);
|
||||
}
|
||||
|
||||
blit_pass->GenerateMipmap(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 { // Doesn't support buffer-to-texture blits.
|
||||
auto texture_descriptor = TextureDescriptor{};
|
||||
texture_descriptor.storage_mode = StorageMode::kHostVisible;
|
||||
texture_descriptor.format = PixelFormat::kR8G8B8A8UNormInt;
|
||||
texture_descriptor.size = decompressed_image.GetSize();
|
||||
texture_descriptor.mip_count =
|
||||
enable_mipmapping ? decompressed_image.GetSize().MipCount() : 1u;
|
||||
|
||||
auto texture =
|
||||
context->GetResourceAllocator()->CreateTexture(texture_descriptor);
|
||||
if (!texture) {
|
||||
VALIDATION_LOG << "Could not allocate texture for fixture.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto uploaded = texture->SetContents(decompressed_image.GetAllocation());
|
||||
if (!uploaded) {
|
||||
VALIDATION_LOG
|
||||
<< "Could not upload texture to device memory for fixture.";
|
||||
return nullptr;
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
||||
std::shared_ptr<Texture> Playground::CreateTextureForMapping(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user