tombox-xshader: GS output stream != 0 rejected #104

Open
opened 2026-11-22 09:16:44 +00:00 by Trwthh · 1 comment
Trwthh commented 2026-11-22 09:16:44 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by Trwthh on 2026-11-22T09:16:44Z.


Component: crates/tombox-xshader/src/hlsl.rs

What happens: The EXP handler at line 5203-5204 rejects geometry shader exports with stream != 0:

if stream != 0 {
    return Err("GS output stream != 0 unsupported".into());
}

Impact: Games using multi-stream geometry shaders (stream-out for particle systems, shadow volume extrusion, GPU-driven culling feedback) will fail shader translation. The RDNA2 EXP instruction encodes the stream index in bits [25:26], and GS shaders can emit to up to 4 output streams.

ISA reference: RDNA2 ISA manual, section 12.1 (EXP), stream field.

Suggested fix: Map each stream to a separate SV_RenderTargetArrayIndex output or use D3D12 stream-output declarations. The HLSL [maxvertexcount] and stream append semantics need to route each stream index to the correct OutputStream<T>.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6540686158 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/issues/104). Originally posted by [Trwthh](https://github.com/Trwthh) on 2026-11-22T09:16:44Z. --- **Component:** `crates/tombox-xshader/src/hlsl.rs` **What happens:** The EXP handler at line 5203-5204 rejects geometry shader exports with stream != 0: ```rust if stream != 0 { return Err("GS output stream != 0 unsupported".into()); } ``` **Impact:** Games using multi-stream geometry shaders (stream-out for particle systems, shadow volume extrusion, GPU-driven culling feedback) will fail shader translation. The RDNA2 EXP instruction encodes the stream index in bits [25:26], and GS shaders can emit to up to 4 output streams. **ISA reference:** RDNA2 ISA manual, section 12.1 (EXP), stream field. **Suggested fix:** Map each stream to a separate `SV_RenderTargetArrayIndex` output or use D3D12 stream-output declarations. The HLSL `[maxvertexcount]` and stream append semantics need to route each stream index to the correct `OutputStream<T>`.
omonkeyz commented 2026-11-22 14:05:25 +00:00 (Migrated from github.com)
Author

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T14:05:25Z.


Confirmed as a gap, but the stream index comes from the s_sendmsg GS message (imm bits [9:8]) in emit_sendmsg, not from EXP. Streams 1-3 only feed stream-out, and the D3D12 layer has no stream-out path yet, so mapping them to SV_RenderTargetArrayIndex would be wrong. Until stream-out exists (PSO StreamOutput translation plus per-stream PointStream outputs), the translator keeps the explicit error rather than dropping those emits. The only GS among the 3515 cached title shaders uses stream 0. Tracked in docs/BLOCKERS.md (d585b945). Leaving this open for the stream-out work.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7080283380 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/issues/104#issuecomment-7080283380). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-22T14:05:25Z. --- Confirmed as a gap, but the stream index comes from the s_sendmsg GS message (imm bits [9:8]) in emit_sendmsg, not from EXP. Streams 1-3 only feed stream-out, and the D3D12 layer has no stream-out path yet, so mapping them to SV_RenderTargetArrayIndex would be wrong. Until stream-out exists (PSO StreamOutput translation plus per-stream PointStream outputs), the translator keeps the explicit error rather than dropping those emits. The only GS among the 3515 cached title shaders uses stream 0. Tracked in docs/BLOCKERS.md (d585b945). Leaving this open for the stream-out work.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
omonkeyz/xbox-emulator#104
No description provided.