Skip to content

d3d12: slot 80 flag 0x20 gives the dispatch dimensions in threads, not groups #164

Backlog

Description

@3kynox

Summary

dispatch_flagged (#156) records a slot 80 call as an ordinary dispatch and ignores its flags word. The comment above it says the call carries the words of the hardware dispatch packet. Read as the hardware's dispatch initiator, the two flag values XboxBvhBuilder passes are not neutral:

Bit Value Field
5 0x20 USE_THREAD_DIMENSIONS
15 0x8000 CS_W32_EN

Source: COMPUTE_DISPATCH_INITIATOR__USE_THREAD_DIMENSIONS__SHIFT 0x5 and COMPUTE_DISPATCH_INITIATOR__CS_W32_EN__SHIFT 0xf in the Linux kernel's drivers/gpu/drm/amd/include/asic_reg/gc/gc_10_3_0_sh_mask.h.

With USE_THREAD_DIMENSIONS set, X, Y and Z count threads, not thread groups. ProjectScarlett 1.0.2.1 calls slot 80 with:

  • flags=0x20, counts (45, 1, 1)
  • flags=0x8020, counts (1, 1, 1)

Recorded as groups, the first call runs 45 whole thread groups where the builder asked for 45 threads. A program whose group size is above one then runs threads the builder never meant to start, and they can write past the end of its buffers.

What I have and have not checked

  • The two flag values and their counts are what this title passes on my machine. I saw no other value.
  • That the flags word is the hardware initiator is an inference: I have no console documentation for slot 80. The two values fit it: the thread-dimension bit alone, and the same bit with the 32-wide-wave bit.
  • I have not observed the overrun. On my side the builder's programs are replaced by empty stand-ins.

What a fix needs

  • The thread-group size of the bound compute program, to turn a thread count into a group count, rounded up.
  • A way to keep the surplus threads of the last group from writing, for example a bound passed to the translated program.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions