This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Vulkan: Crash in driver when recording an image layout transition

Hi,

The following image layout transition seems to consistently crash the driver in the Galaxy S8 with Mali:

 VkImageMemoryBarrier image_memory_barrier{ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
image_memory_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
image_memory_barrier.dstAccessMask = VK_PIPELINE_STAGE_TRANSFER_BIT;
image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
image_memory_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
image_memory_barrier.image = image;
image_memory_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
image_memory_barrier.subresourceRange.baseMipLevel = 0;
image_memory_barrier.subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
image_memory_barrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vkCmdPipelineBarrier(cmd, srcStageMask, dstStageMask, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier);

Crashes instantly when calling vkCmdPipelineBarrier - I would have expected a crash later when executing the command buffer but it doesn't get there.

NativeApp : The suspiciuous transition! From SRCOPT to DEPTHOPT. fb->depth.image = 0x7be2f7cab0
DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
DEBUG : Build fingerprint: 'samsung/dream2ltexx/dream2lte:7.0/NRD90M/G955FXXU1AQJ1:user/release-keys'
DEBUG : Revision: '10'
DEBUG : ABI: 'arm64'
DEBUG : pid: 24532, tid: 24865, name: RenderMan >>> org.ppsspp.ppsspp <<<
DEBUG : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7be4103080
DEBUG : x0 0000000000000a3b x1 0000007bee6c9f50 x2 0000007bee6c9c38 x3 0000007be4103020
DEBUG : x4 0000007be2f7db58 x5 0000007bee6c9f08 x6 00000000011864d0 x7 00000000ffffffff
DEBUG : x8 0000000000000006 x9 0000000000000098 x10 0000000000000000 x11 0000000000000003
DEBUG : x12 0000000000000000 x13 0000000000000000 x14 0000007be2f7cab0 x15 0000000000000000
DEBUG : x16 0000007be2f7cb50 x17 000000000001d83e x18 000000000001d83f x19 0000007bf81bd000
DEBUG : x20 0000007bee6c9cd0 x21 0000000000000000 x22 0000007bee6c9ef0 x23 0000007c0df849e8
DEBUG : x24 0000000000000000 x25 0000000000001000 x26 0000007bee6c9c48 x27 0000007bee6c9c38
DEBUG : x28 0000000000000300 x29 0000007bee6c9ed0 x30 0000007bf61f4d74
DEBUG : sp 0000007bee6c9bb0 pc 0000007bf61ee4a4 pstate 0000000000000000
DEBUG :
DEBUG : backtrace:
DEBUG : #00 pc 000000000062d4a4 /system/vendor/lib64/egl/libGLES_mali.so
DEBUG : #01 pc 0000000000633d70 /system/vendor/lib64/egl/libGLES_mali.so
DEBUG : #02 pc 0000000000018aa0 /system/lib64/libvulkan.so
DEBUG : #03 pc 00000000004d7128 /data/app/org.ppsspp.ppsspp-1/lib/arm64/libppsspp_jni.so (_Z22TransitionImageLayout2P17VkCommandBuffer_TP9VkImage_Tj13VkImageLayoutS3_jjjj+200)
DEBUG : #04 pc 00000000005c4c78 /data/app/org.ppsspp.ppsspp-1/lib/arm64/libppsspp_jni.so (_ZN17VulkanQueueRunner36PerformBindFramebufferAsRenderTargetERK7VKRStepP17VkCommandBuffer_T+528)

The image is valid and this passes all Vulkan validation layers.

Replacing oldLayout with VK_IMAGE_LAYOUT_UNDEFINED works fine but I do want to keep the depth buffer contents, and that would not guarantee that. I will however apply this workaround when Mali is detected for now, I guess...

Hoping for a fix in the future.

Henrik