flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.34k stars 27.53k forks source link

[Vulkan] `AiksTests.CanRenderImageRect` has `InvalidImageLayout` validation error #142024

Closed gaaclarke closed 9 months ago

gaaclarke commented 9 months ago

This error was seen while trying to turn on validation in the golden image tests. There are a lot of instances of InvalidImageLayout as reported in https://github.com/flutter/engine/pull/49955#issuecomment-1905077075, hopefully fixing this simplest case will fix them all.

Steps to reproduce:

apply the following patch

--- a/impeller/golden_tests/vulkan_screenshotter.mm
+++ b/impeller/golden_tests/vulkan_screenshotter.mm
@@ -66,8 +66,10 @@ std::unique_ptr<Screenshot> ReadTexture(

 VulkanScreenshotter::VulkanScreenshotter() {
   FML_CHECK(::glfwInit() == GLFW_TRUE);
+  PlaygroundSwitches playground_switches;
+  playground_switches.enable_vulkan_validation = true;
   playground_ =
-      PlaygroundImpl::Create(PlaygroundBackend::kVulkan, PlaygroundSwitches{});
+      PlaygroundImpl::Create(PlaygroundBackend::kVulkan, playground_switches);
 }

 std::unique_ptr<Screenshot> VulkanScreenshotter::MakeScreenshot(

run the following target

impeller_golden_tests --working_dir=<path> --gtest_filter="*CanRenderImageRect*Vulkan"

validation error

[ERROR:flutter/impeller/base/validation.cc(49)] Break on 'ImpellerValidationBreak' to inspect point of failure: 
--- Vulkan Debug Report  ----------------------------------------
|                Severity: Error
|                    Type: { Validation }
|                 ID Name: UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout
|               ID Number: 1303270965
|       Queue Breadcrumbs: [NONE]
|  CMD Buffer Breadcrumbs: Texture Fill, QueueSubmit
|         Related Objects: CommandBuffer [5593919120] [EntityPass Command Buffer: Depth=0 Count=0]
|                 Trigger: Validation Error: [ UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout ] Object 0: handle = 0x14d6c6e90, name = EntityPass Command Buffer: Depth=0 Count=0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x4dae5635 | vkQueueSubmit(): pSubmits[0].pCommandBuffers[0] command buffer VkCommandBuffer 0x14d6c6e90[EntityPass Command Buffer: Depth=0 Count=0] expects VkImage 0x51820000000007b[kalimba.jpg] (subresource: aspectMask 0x1 array layer 0, mip level 0) to be in layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL--instead, current layout is VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL.
-----------------------------------------------------------------
github-actions[bot] commented 9 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.