Skip to content

Synchronize the mesh allocation-count clear before request writes - #1

Open
MichaelSmithAI wants to merge 1 commit into
Kam471:mesh-alloc-countsfrom
MichaelSmithAI:fix/mesh-count-init-barrier
Open

MichaelSmithAI wants to merge 1 commit into
Kam471:mesh-alloc-countsfrom
MichaelSmithAI:fix/mesh-count-init-barrier

Conversation

@MichaelSmithAI

Copy link
Copy Markdown

This fixes the initialization order of the shared allocation-count word added in VIctory #586. Thread zero clears the word, and a shader allocation request later stores the group's packed vertex and primitive counts into the same location. In a multi-wave group, the barrier at the final read orders both stores before that read, but leaves the order of the stores undetermined. A valid request can therefore be overwritten with zero.

The generated mesh prologue now emits a group synchronization and shared-memory fence after all lanes reconverge from the thread-zero initialization. The later fence still orders the request before the count is read. This adds one barrier per workgroup on the staged-count path. Its runtime cost is unmeasured.

I checked the disassembly of the existing synthetic 128-thread mesh program that requests three vertices and three primitives. On 9b5e239 the clear and request stores both precede the first barrier. With this change their order is clear → group barrier → request → group barrier → count load. The clear and the branch that skips it both reach the first barrier. Microsoft's DXIL validator accepted the fixed shader and the Linux shader library suite passed all 70 tests.

Native frame output and timing for this follow-up have not been measured. The game measurements in Marvisak#586 belong to the original branch. AI assistance was used for implementation and verification.

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

Successfully merging this pull request may close these issues.

1 participant