Skip to content

Timeline semaphores and resource state tracking issues #2441

@mbechard

Description

@mbechard

Describe the Issue
Hey, I'm having a validation error show up that I think is incorrect. I have a texture that is updated from the transfer queue and then used as a sampler in the graphics queue. The transfer queue releases the texture and does a TransferDst->ShaderRead layout transition. The graphics queue acquires it and records a usage of it, and then gives the texture pointer back to the transfer queue thread for future updates. The way the engine is setup the transfer queue will submit commands often, while the graphics queue will do it once or twice per frame.
What often happens is that the transfer queue will re-use and submit the new usage of that texture before the graphics queue has submitted it's usage. This is all protected by timeline semaphores to ensure the actual usage isn't occurring in the transfer queue until the graphics queue is actually done with it. But the submission is out of order (in different queues).

When submitting the command buffer for the graphics queue, the error states:
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL--instead, current layout is VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. Which I think is occurring because the transfer queue has already submitted a new command buffer that is doing another release operation with a TransferDst->ShaderRead transition included, and this submission is changing the state tracking in the validation layer too soon.

It seems like the layout changes are recorded/validated at submission time, ignoring the fact that the timeline semaphore should be waited on before recording/validating the layout change in the validation layers. Likely since previous to timeline semaphores the binary semaphore submit-before-wait rule allowed for this logic.

I think with timeline semaphores the validation now should wait until any timeline semaphores it's waiting on have been submitted so this state tracking occurs in the correct order.

Am I correct that this is the current behavior? I suppose the work around for now is to do a CPU wait on the timeline semaphore before submission when using validation layers.

Valid Usage ID
UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout

Environment:

  • OS: WIndows 10
  • GPU: RTX5000
  • 1.2.162.0

Metadata

Metadata

Labels

SynchronizationSynchronization Validation Object Issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions