[Vulkan] A texture left in Common or UnorderedAccess by an earlier command list is sampled with the wrong descriptor layout
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 18/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- csharp
- Área
- computer-graphics
Línea de trabajo
Start from the review on PR #4094 and the sampled-image descriptor path; the named pieces are GetCbLayoutTracker, SubmittedLayoutReplay.RecordAssumed, CorrectAssumedLayouts, SubresourceLayoutTracker, TransitionTexture and RestoreAfterTransfer. Reproduce with the Vulkan validation layer: move a texture to Common, submit, then sample it in a later command list with no transition. Done means an agreed thread-safe tracker design, correction barriers for the sampled layout, and the new single- and multi-threaded tests passing.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Stride version
master, with #4094
Platforms
Windows
Graphics API
Vulkan
What happens
#4094 makes a sampled-image descriptor declare GENERAL when the command list that samples the texture has it in Common or UnorderedAccess. As the review of #4094 points out, this only covers a texture that this command list moved itself: currentCbLayouts is cleared on Reset. A texture moved to Common once, for example in an earlier frame, then sampled in later command lists with no transition of their own, still gets SHADER_READ_ONLY_OPTIMAL while the image is in GENERAL. "Move once, sample later" is a natural pattern for Common, which means any use.
Expected: the descriptor declares the layout the image is in when the command list runs.
Steps to reproduce
- Move a texture to
BarrierLayout.Common, and submit that command list. - In a later command list, sample the texture with no transition (for example with
DrawTexture). - Run with the Vulkan validation layer.
Log and callstack
Cannot use VkImage ... with specific layout SHADER_READ_ONLY_OPTIMAL that doesn't match the previous known layout GENERAL
Screenshots and other details
The fix touches the barrier design, so I'd like to agree on the approach before the PR.
What exists. When a command list first touches a texture through a transition, GetCbLayoutTracker clones the texture's shared tracker and records that layout as assumed (SubmittedLayoutReplay.RecordAssumed). At submission, CorrectAssumedLayouts replays the list's transitions on the layouts the earlier submissions really left, and records correction barriers before the list. The sampled descriptor never joins this: it only looks in currentCbLayouts, deliberately not in the shared tracker, "which can be mutated by other CBs recording concurrently".
Why the obvious change is not enough.
SubresourceLayoutTrackeris a mutable struct with several fields, held in a field of the texture with no synchronization.TransitionTextureandRestoreAfterTransferalready clone it and write it back from the recording thread, which is rare on worker lists today becauseRenderSystem.Drawtransitions the stage's targets on the main list first. If the sampled path read it too, every texture a worker list samples would be exposed, and a torn copy can give a stale layout or aNullReferenceExceptioninGet.- Recording every sampled texture as assumed adds a dictionary entry and recorded transitions per texture per command list, and can add correction barriers where none were recorded before.
- The bound read-only depth case only applies today when the list has no layout for the texture, so it would have to win over the tracked layout.
Proposal.
- Make the shared tracker safe to clone and update from several recording threads, for example by swapping an immutable snapshot, or with a lock around the clone and the write-back.
- Have the sampled descriptor take the tracker as a transition does (
GetCbLayoutTracker), so its layout is assumed at record time and corrected at submission, whatever the submission order. - Keep the bound read-only depth rule first.
Tests: a texture moved to Common in one command list and sampled in a later one, with no transition, checked on Vulkan with sync validation; the multi-threaded draw path through the engine tests.
Does this approach look right, or would you prefer another one, for example documenting that a texture in Common or UnorderedAccess must be transitioned in the command list that samples it?
- Lenguaje dominante
- C#
- Estrellas
- 8k
- Forks
- 1.2k
- Merge medio
- 1 d 1 h
- PR fusionados (30 d)
- 321
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de stride3d/stride
-
area-Build bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
area-Samples enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
stride3d/stride#3386 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
-
area-Physics bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
stride3d/stride#3384 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area-Samples bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
stride3d/stride#3066 · 6 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Docs] Update Entity.cs XML CommentsQuizá libre de nuevo @andyp53 la tomó hace 130 días y no hay ningún pull request abierto. Abiertoarea-Doc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
stride3d/stride#2452 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de stride3d/stride
Issues similares
-
bug priority:low severity:S3
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
squid-farm/talewright#909 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 1 día
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
kronos:develop:queued priority:P0
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
priority:P2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100