Repository navigation
Recompiler: two-pass mesh groups run in whole console waves #3350
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2642,16 +2642,21 @@ impl Lw { | |
| // ------------------------------------------------------------ exports | ||
|
|
||
| /// Mesh mode `s_sendmsg`: GS_ALLOC_REQ (M0 = primitives << 12 | vertices) into the | ||
| /// record header by lane 0 of each wave. | ||
| /// record header by lane 0 of wave 0, regardless of its EXEC mask. | ||
| pub fn mesh_sendmsg(&mut self, d: &Decoded) -> LResult<()> { | ||
| if Self::fv(d, "SIMM16") & 0xF != 9 { | ||
| return Ok(()); | ||
| } | ||
| let m0 = self.sreg(124); | ||
| let rec = self.mesh.as_ref().expect("mesh").rec; | ||
| let res = self.res.expect("res"); | ||
| // GS_ALLOC_REQ is one request per group, issued by its first console wave; the scalar | ||
| // instruction ignores EXEC, and later waves may widen it themselves. | ||
| let lane = self.lane; | ||
| let first = self.cmpc(Pred::Eq, lane, 0); | ||
| let lane0 = self.cmpc(Pred::Eq, lane, 0); | ||
| let wave = self.mesh.as_ref().expect("mesh").wave; | ||
| let wave0 = self.cmpc(Pred::Eq, wave, 0); | ||
| let first = self.land(lane0, wave0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not certain about this one: with the header written only by wave 0 (also emit.rs:1378), a program whose GS_ALLOC_REQ sits in a block wave 0 skips never writes it. That happens with an execz branch taken because wave 0's lanes are all done, or a capped loop that ends wave 0's lanes early in direct DXIL, which the PR notes as open. Header dwords 0/1 stay zero or hold the previous frame's counts, so the passthrough reads nv/np = 0 or stale. Before, any wave's lane 0 still wrote it. Writing it from the first wave that reaches s_sendmsg (e.g. a per-group flag) would cover both. |
||
| self.guarded(first, &mut |lw| { | ||
| let v = lw.andc(m0, 0x3FF); | ||
| let p = lw.lshrc(m0, 12); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -364,6 +364,22 @@ pub struct MsInterface { | |
| pub const MESH_HEADER: usize = 4; | ||
|
|
||
| impl MsInterface { | ||
| /// The threads a group of this program has on the console: whole waves (`wave64`: of 64 | ||
| /// lanes, else 32) covering its threads and the vertices and primitives it may export. The | ||
| /// console launches those; the program's EXEC at entry has its declared `threads` only, and | ||
| /// it can widen EXEC to export from the other lanes. | ||
| pub fn launch_threads(&self, wave64: bool) -> u32 { | ||
| let lanes = if wave64 { 64 } else { 32 }; | ||
| self.threads.max(self.max_vertices).max(self.max_primitives).max(1).next_multiple_of(lanes).min(1024) | ||
| } | ||
|
|
||
| /// The console's v5 per group: each group gets a disjoint range covering every launched | ||
| /// lane. Output extents can exceed declared threads, and guest code can widen EXEC later, | ||
| /// so this applies to every program, not only ones whose translation proves EXEC widening. | ||
| pub fn group_stride(&self, wave64: bool) -> u32 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not certain about this one, because it depends on unverified hardware behaviour: |
||
| self.launch_threads(wave64) | ||
| } | ||
|
|
||
| /// dwords per vertex: pos0 + every param (4 each, raw bits) | ||
| pub fn vert_dwords(&self) -> usize { | ||
| 4 * (1 + ranked(&self.outputs, true).len()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not certain about this one, because it depends on unverified hardware behaviour: the entry EXEC is still limited to the declared
ms.threads. On the console a group launched withlaunch_threadslanes probably starts with EXEC covering every launched lane, with the guest compiler guarding API threads itself. If so, a mesh program declaring 32 threads with max_vertices=64 that exports from lanes 32..63 without its owns_mov_b64 exec, -1still starts those lanes inactive in both backends (here and emit.rs:5401xcl_slot < threads). The vertex exports are dropped, which is the #3011 symptom. The PR says it didn't check whether retail programs widen EXEC, and the only positive test widens it explicitly.