Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YUV image barrier problem #1361

Open
yakswa opened this issue Sep 3, 2024 · 0 comments
Open

YUV image barrier problem #1361

yakswa opened this issue Sep 3, 2024 · 0 comments

Comments

@yakswa
Copy link

yakswa commented Sep 3, 2024

Environment information:

  • AGI version: Version 2023-3.3.1:dev-20230519-7ee513c558ab754b6cf5c9ab2c662dc918ff92e9
  • Host OS: MacOS 14.6.1(23G93) , Apple M1 Max
    If tracing on Android:
  • Device model: Galaxy S10+
  • Android Version: 12

Bug description
Capture was successful, but Replay failed.

I Made eG8B8R82Plane420Unorm image from memory buffer
similar like this code blocks
https://github.com/zaps166/QmVk/blob/1d7bdad222f33bdd4e3ee7b15bb63ffcfa1d280f/Image.cpp#L570-L581

std::vector<vk::BindImageMemoryInfo> bindImageMemoryInfos;
std::vector<vk::BindImagePlaneMemoryInfo> bindImagePlaneMemoryInfos;
bindImageMemoryInfos.resize(m_planeCount);
bindImagePlaneMemoryInfos.resize(m_planeCount);
vk::DeviceSize offset = 0;
for (uint32_t i = 0; i < m_planeCount; ++i)
{
    bindImagePlaneMemoryInfos[i].setPlaneAspect(getPlaneBit(i));
    bindImageMemoryInfos[i].setPNext(&bindImagePlaneMemoryInfos[i]);
    bindImageMemoryInfos[i].setImage(m_externalImage);
    bindImageMemoryInfos[i].setMemory(m_externalImageDeviceMemory);
    bindImageMemoryInfos[i].setMemoryOffset(offset);
    offset += memReqs[i].memoryRequirements.size;
}

auto result = device.bindImageMemory2(static_cast<uint32_t>(bindImageMemoryInfos.size()), bindImageMemoryInfos.data());

and then add barrier command to commandBuffer

barrier.image = yuvImage;
for (uint32_t i = 0; i < m_planeCount; ++i)
{
    barrier.subresourceRange.aspectMask = getPlaneBit(i);
    commandBuffer.pipelineBarrier(eTopOfPipe, eTransfer, {}, nullptr, nullptr, barrier);
}

occurred this problem

When I change yuvimage to normal image then no problem
My program don't have any validation error

Reproduction steps
Steps to reproduce the behavior:

Stacktrace
Please paste a stacktrace here if it's available.

panic: uint8(0x0@0)[0].Slice(0, 921600) - out of bounds [recovered]
	panic: Panic at command 25:vkQueueSubmit(queue: 0x7d5589c7b0, submitCount: 1, pSubmits: 0x0000007ba7bf4110, fence: 0x0) → VK_SUCCESS:
uint8(0x0@0)[0].Slice(0, 921600) - out of bounds [recovered]
	panic: 
--- *resolve.ResourcesResolvable ---
 capture:{ID:{data:"\xc1\xf5\x10\x1dB\x8e\xbc+\xe1J\xed\xd76\r\x18z\xef\x8b\xe1\x0e"}}  config:{replay_device:{ID:{data:"K\x14\xf0H--2\xe3=\xf6\xb8x\xd5(n_i\xb4\x8a\x9c"}}}
 Store():
  gapis/database/database.go:56  github.com/google/gapid/gapis/database.Build
  gapis/resolve/resources.go:35  github.com/google/gapid/gapis/resolve.Resources
  gapis/resolve/resolve.go:357  github.com/google/gapid/gapis/resolve.ResolveInternal
  gapis/resolve/resolve.go:279  github.com/google/gapid/gapis/resolve.ResolveService
  gapis/resolve/get.go:33  github.com/google/gapid/gapis/resolve.(*GetResolvable).Resolve
  gapis/database/memory.go:137  github.com/google/gapid/gapis/database.(*record).resolve
  gapis/database/memory.go:241  github.com/google/gapid/gapis/database.(*memory).resolveLocked.func1
  core/app/crash/crash.go:65  github.com/google/gapid/core/app/crash.Go.func1

 Build() #0:
  gapis/database/database.go:60  github.com/google/gapid/gapis/database.Build
  gapis/resolve/resources.go:35  github.com/google/gapid/gapis/resolve.Resources
  gapis/resolve/resolve.go:357  github.com/google/gapid/gapis/resolve.ResolveInternal
  gapis/resolve/resolve.go:279  github.com/google/gapid/gapis/resolve.ResolveService
  gapis/resolve/get.go:33  github.com/google/gapid/gapis/resolve.(*GetResolvable).Resolve
  gapis/database/memory.go:137  github.com/google/gapid/gapis/database.(*record).resolve
  gapis/database/memory.go:241  github.com/google/gapid/gapis/database.(*memory).resolveLocked.func1
  core/app/crash/crash.go:65  github.com/google/gapid/core/app/crash.Go.func1

--- *resolve.GetResolvable ---
 path:{resources:{capture:{ID:{data:"\xc1\xf5\x10\x1dB\x8e\xbc+\xe1J\xed\xd76\r\x18z\xef\x8b\xe1\x0e"}}}}  config:{replay_device:{ID:{data:"K\x14\xf0H--2\xe3=\xf6\xb8x\xd5(n_i\xb4\x8a\x9c"}}}
 Store():
  gapis/database/database.go:56  github.com/google/gapid/gapis/database.Build
  gapis/resolve/get.go:26  github.com/google/gapid/gapis/resolve.Get
  gapis/server/server.go:387  github.com/google/gapid/gapis/server.(*server).Get
  gapis/server/grpc.go:227  github.com/google/gapid/gapis/server.(*grpcServer).Get
  bazel-out/darwin-opt/bin/gapis/service/service_go_proto_/github.com/google/gapid/gapis/service/service.pb.go:15840  github.com/google/gapid/gapis/service._Gapid_Get_Handler.func1
  core/app/auth/auth.go:110  github.com/google/gapid/core/app/auth.UnaryServerInterceptor.func1
  bazel-out/darwin-opt/bin/gapis/service/service_go_proto_/github.com/google/gapid/gapis/service/service.pb.go:15842  github.com/google/gapid/gapis/service._Gapid_Get_Handler
  external/org_golang_google_grpc/server.go:1295  google.golang.org/grpc.(*Server).processUnaryRPC
  external/org_golang_google_grpc/server.go:1636  google.golang.org/grpc.(*Server).handleStream

 Build() #0:
  gapis/database/database.go:60  github.com/google/gapid/gapis/database.Build
  gapis/resolve/get.go:26  github.com/google/gapid/gapis/resolve.Get
  gapis/server/server.go:387  github.com/google/gapid/gapis/server.(*server).Get
  gapis/server/grpc.go:227  github.com/google/gapid/gapis/server.(*grpcServer).Get
  bazel-out/darwin-opt/bin/gapis/service/service_go_proto_/github.com/google/gapid/gapis/service/service.pb.go:15840  github.com/google/gapid/gapis/service._Gapid_Get_Handler.func1
  core/app/auth/auth.go:110  github.com/google/gapid/core/app/auth.UnaryServerInterceptor.func1
  bazel-out/darwin-opt/bin/gapis/service/service_go_proto_/github.com/google/gapid/gapis/service/service.pb.go:15842  github.com/google/gapid/gapis/service._Gapid_Get_Handler
  external/org_golang_google_grpc/server.go:1295  google.golang.org/grpc.(*Server).processUnaryRPC
  external/org_golang_google_grpc/server.go:1636  google.golang.org/grpc.(*Server).handleStream
 [recovered]
	panic: 
--- *resolve.ResourcesResolvable ---
 capture:{ID:{data:"\xc1\xf5\x10\x1dB\x8e\xbc+\xe1J\xed\xd76\r\x18z\xef\x8b\xe1\x0e"}}  config:{replay_device:{ID:{data:"K\x14\xf0H--2\xe3=\xf6\xb8x\xd5(n_i\xb4\x8a\x9c"}}}
 Store():
  gapis/database/database.go:56  github.com/google/gapid/gapis/database.Build
  gapis/resolve/resources.go:35  github.com/google/gapid/gapis/resolve.Resources
  gapis/resolve/resolve.go:357  github.com/google/gapid/gapis/resolve.ResolveInternal
  gapis/resolve/resolve.go:279  github.com/google/gapid/gapis/resolve.ResolveService
  gapis/resolve/get.go:33  github.com/google/gapid/gapis/resolve.(*GetResolvable).Resolve
  gapis/database/memory.go:137  github.com/google/gapid/gapis/database.(*record).resolve
  gapis/database/memory.go:241  github.com/google/gapid/gapis/database.(*memory).resolveLocked.func1
  core/app/crash/crash.go:65  github.com/google/gapid/core/app/crash.Go.func1

 Build() #0:
  gapis/database/database.go:60  github.com/google/gapid/gapis/database.Build
  gapis/resolve/resources.go:35  github.com/google/gapid/gapis/resolve.Resources
  gapis/resolve/resolve.go:357  github.com/google/gapid/gapis/resolve.ResolveInternal
  gapis/resolve/resolve.go:279  github.com/google/gapid/gapis/resolve.ResolveService
  gapis/resolve/get.go:33  github.com/google/gapid/gapis/resolve.(*GetResolvable).Resolve
  gapis/database/memory.go:137  github.com/google/gapid/gapis/database.(*record).resolve
  gapis/database/memory.go:241  github.com/google/gapid/gapis/database.(*memory).resolveLocked.func1
  core/app/crash/crash.go:65  github.com/google/gapid/core/app/crash.Go.func1

--- *resolve.GetResolvable ---
 path:{resources:{capture:{ID:{data:"\xc1\xf5\x10\x1dB\x8e\xbc+\xe1J\xed\xd76\r\x18z\xef\x8b\xe1\x0e"}}}}  config:{replay_device:{ID:{data:"K\x14\xf0H--2\xe3=\xf6\xb8x\xd5(n_i\xb4\x8a\x9c"}}}
 Store():
  gapis/database/database.go:56  github.com/google/gapid/gapis/database.Build
  gapis/resolve/get.go:26  github.com/google/gapid/gapis/resolve.Get
  gapis/server/server.go:387  github.com/google/gapid/gapis/server.(*server).Get
  gapis/server/grpc.go:227  github.com/google/gapid/gapis/server.(*grpcServer).Get
  bazel-out/darwin-opt/bin/gapis/service/service_go_proto_/github.com/google/gapid/gapis/service/service.pb.go:15840  github.com/google/gapid/gapis/service._Gapid_Get_Handler.func1
  core/app/auth/auth.go:110  github.com/google/gapid/core/app/auth.UnaryServerInterceptor.func1
  bazel-out/darwin-opt/bin/gapis/service/service_go_proto_/github.com/google/gapid/gapis/service/service.pb.go:15842  github.com/google/gapid/gapis/service._Gapid_Get_Handler
  external/org_golang_google_grpc/server.go:1295  google.golang.org/grpc.(*Server).processUnaryRPC
  external/org_golang_google_grpc/server.go:1636  google.golang.org/grpc.(*Server).handleStream

 Build() #0:
  gapis/database/database.go:60  github.com/google/gapid/gapis/database.Build
  gapis/resolve/get.go:26  github.com/google/gapid/gapis/resolve.Get
  gapis/server/server.go:387  github.com/google/gapid/gapis/server.(*server).Get
  gapis/server/grpc.go:227  github.com/google/gapid/gapis/server.(*grpcServer).Get
  bazel-out/darwin-opt/bin/gapis/service/service_go_proto_/github.com/google/gapid/gapis/service/service.pb.go:15840  github.com/google/gapid/gapis/service._Gapid_Get_Handler.func1
  core/app/auth/auth.go:110  github.com/google/gapid/core/app/auth.UnaryServerInterceptor.func1
  bazel-out/darwin-opt/bin/gapis/service/service_go_proto_/github.com/google/gapid/gapis/service/service.pb.go:15842  github.com/google/gapid/gapis/service._Gapid_Get_Handler
  external/org_golang_google_grpc/server.go:1295  google.golang.org/grpc.(*Server).processUnaryRPC
  external/org_golang_google_grpc/server.go:1636  google.golang.org/grpc.(*Server).handleStream


goroutine 2194 [running]:
github.com/google/gapid/core/app/crash.Crash({0x7dfdbc0, 0xc008e9e770})
	core/app/crash/crash.go:89 +0x7d
github.com/google/gapid/core/app/crash.handler()
	core/app/crash/crash.go:56 +0x2a
panic({0x7dfdbc0, 0xc008e9e770})
	GOROOT/src/runtime/panic.go:884 +0x212
github.com/google/gapid/gapis/database.(*memory).resolvePanicHandler(0xc0001e4020, {0x8e4cc20, 0xc00243ea20})
	gapis/database/debug.go:106 +0x53d
panic({0x7e29b80, 0xc008e9e080})
	GOROOT/src/runtime/panic.go:884 +0x212
github.com/google/gapid/gapis/api.ForeachCmd.func1()
	gapis/api/cmd_foreach.go:45 +0xdf
panic({0x7e29b80, 0xc008e9e070})
	GOROOT/src/runtime/panic.go:884 +0x212
github.com/google/gapid/gapis/api/vulkan.U8ˢ.Slice({0x0, 0x0, 0x0, 0x0, 0x0}, 0x0, 0xe1000)
	bazel-out/darwin-opt/bin/gapis/api/vulkan/api_slices.go:4356 +0x2ce
github.com/google/gapid/gapis/api/vulkan.subAccessImageSubresourceSlice({0x8e4cc20, 0xc008e9b260}, {0x8e6e440, 0xc000c58060}, 0xc0055b5aa0?, 0xc0055acb00?, 0xc005f60bd0, 0x0?, 0x0?, 0x0, ...)
	bazel-out/darwin-opt/bin/gapis/api/vulkan/mutate.go:1309 +0xe05
github.com/google/gapid/gapis/api/vulkan.subAccessImageSubresource({0x8e4cc20?, 0xc008e9b260?}, {0x8e6e440?, 0xc000c58060?}, 0xffffffffffffffff?, 0xc00537c0d0?, 0x5fc8705?, 0xc000c0cd00?, 0x0?, 0x0, ...)
	bazel-out/darwin-opt/bin/gapis/api/vulkan/mutate.go:1327 +0xd0
github.com/google/gapid/gapis/api/vulkan.subWriteImageSubresource({0x8e4cc20?, 0xc008e9b260?}, {0x8e6e440?, 0xc000c58060?}, 0xc005f60bd0?, 0xc007c892c0?, 0xc007c892c0?, 0x0?, 0x19?, 0x0, ...)
	bazel-out/darwin-opt/bin/gapis/api/vulkan/mutate.go:1343 +0xba
github.com/google/gapid/gapis/api/vulkan.subProcessImageBarrier({0x8e4cc20, 0xc008e9b260}, {0x8e6e440, 0xc000c58060}, 0xc000c58060?, 0x34d?, 0xc005f60bd0, 0xc005f60bd0?, 0xc0014e3f80?, 0x0, ...)
	bazel-out/darwin-opt/bin/gapis/api/vulkan/mutate.go:7048 +0x288
github.com/google/gapid/gapis/api/vulkan.subProcessBarriers({0x8e4cc20, 0xc008e9b260}, {0x8e6e440, 0xc000c58060}, 0x10000000000034d?, 0xc008aae980?, 0xc005f60bd0, 0x7d258d9050?, 0xc000f79200?, 0x0, ...)
	bazel-out/darwin-opt/bin/gapis/api/vulkan/mutate.go:6979 +0x76a
github.com/google/gapid/gapis/api/vulkan.subDovkCmdPipelineBarrier({0x8e4cc20, 0xc008e9b260}, {0x8e6e440, 0xc000c58060}, 0x345c72d81d8aac65?, 0xc578b892c5dc6605?, 0xc005f60bd0, 0x7e9228?, 0xad167ed100000090?, 0x0, ...)
	bazel-out/darwin-opt/bin/gapis/api/vulkan/mutate.go:6882 +0x28c
github.com/google/gapid/gapis/api/vulkan.subCallCommand({0x8e4cc20, 0xc008e9b260}, {0x8e6e440, 0xc000c58060}, 0x0?, 0x0?, 0xc005f60bd0, 0x43690400203002?, 0x7204ea95fdab1565?, 0x0, ...)
	bazel-out/darwin-opt/bin/gapis/api/vulkan/mutate.go:5976 +0x48e5
github.com/google/gapid/gapis/api/vulkan.subExecuteSubmit({0x8e4cc20, 0xc008e9b260}, {0x8e6e440, 0xc000c58060}, 0x19, 0xc000c58060?, 0xc005f60bd0, 0x203002?, 0xc008e9b1d0?, 0x0, ...)
	bazel-out/darwin-opt/bin/gapis/api/vulkan/mutate.go:5661 +0x3b5f
github.com/google/gapid/gapis/api/vulkan.(*VkQueueSubmit).Mutate(0xc000c58060, {0x8e4cc20, 0xc008e96960}, 0x19, 0xc005f60bd0, 0x0, {0x0?, 0x0})
	bazel-out/darwin-opt/bin/gapis/api/vulkan/mutate.go:20262 +0x1296
github.com/google/gapid/gapis/resolve.(*ResourcesResolvable).Resolve.func6({0x8e4cc20?, 0xc008e96960?}, 0x8e4cc20?, {0x8e6e440, 0xc000c58060})
	gapis/resolve/resources.go:111 +0x6f
github.com/google/gapid/gapis/api.ForeachCmd({0x8e4cc20, 0xc00243eb70}, {0xc000da0000, 0xa7, 0x9?}, 0x1, 0xc00537dcd0)
	gapis/api/cmd_foreach.go:59 +0x333
github.com/google/gapid/gapis/resolve.(*ResourcesResolvable).Resolve(0xc005312300, {0x8e4cc20?, 0xc00243eab0?})
	gapis/resolve/resources.go:108 +0x515
github.com/google/gapid/gapis/database.(*record).resolve(0xc0007f6360, {0x8e4cc20, 0xc00243ea20})
	gapis/database/memory.go:137 +0x363
github.com/google/gapid/gapis/database.(*memory).resolveLocked.func1()
	gapis/database/memory.go:241 +0x106
github.com/google/gapid/core/app/crash.Go.func1()
	core/app/crash/crash.go:65 +0x3f
created by github.com/google/gapid/core/app/crash.Go
	core/app/crash/crash.go:63 +0x56

Screenshots
If applicable, add screenshots to help explain your problem.

Additional debugging information

  • Please attach the generated gapis.log and gapic.log files you will find in the temp folder (e.g. /tmp/ on linux).
  • If using Android: Please attach a full logcat dump (adb logcat -d > logcat-full.txt) that contains logs since AGI was started.

gapic.log
gapis.log

YUV from AHardware buffer also have problems

  • I checked VK_ANDROID_external_memory_android_hardware_buffer is not supported

  • Process step

    • ImageReader.newInstance(width, height, ImageFormat.YUV_420_888, 2);
    • get hardware buffer from imagereader
    • use VkImportAndroidHardwareBufferInfoANDROID
    • use vkYCbcrSampler
    • When using the AGI tool, the following validation errors occur, causing a crash.
    • Logcat
      [E] [Validation] Code 0 :  [ VUID-VkImportAndroidHardwareBufferInfoANDROID-buffer-01881 ] Object: 0x7e4590d630 (Type = 3) | vkAllocateMemory: The AHardwareBuffer_Desc's format ( 35 ) and/or usage ( 0x1000100 ) are not compatible with Vulkan. The Vulkan spec states: If buffer is not NULL, it must be a valid Android hardware buffer object with AHardwareBuffer_Desc::format and AHardwareBuffer_Desc::usage compatible with Vulkan as described in Android Hardware Buffers. (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkImportAndroidHardwareBufferInfoANDROID-buffer-01881)
      [E] [Validation] Code 0 :  [ UNASSIGNED-CoreValidation-vkBindImageMemory-invalid-requirements ] Object: 0x59 (Type = 10) | vkBindImageMemory2() pBindInfos[0]: Must not call vkGetImageMemoryRequirements on VkImage 0x59[] that will be bound to an external Android hardware buffer.
      [E] [Validation] Code 0 :  [ VUID-VkImageViewCreateInfo-None-02273 ] Object: 0x59 (Type = 10) | vkCreateImageView(): pCreateInfo->format VK_FORMAT_UNDEFINED with tiling VK_IMAGE_TILING_OPTIMAL has no supported format features on this physical device. The Vulkan spec states: The format features of the resultant image view must contain at least one bit. (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkImageViewCreateInfo-None-02273)
      libc     A  Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 22845 (pool-5-thread-1), pid 21980 
      
  • Recommend Similar program for reproduction

@yakswa yakswa changed the title YUV image barrier problems YUV image barrier problem Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant