Skip to content

experimental: derived slot 57 mesh walk with multiple/zero render targets and an opt-in group stride (draft, do not merge) - #3660

Draft
SimSalabimse wants to merge 29 commits into
R0Y00:mainfrom
SimSalabimse:local/mesh57-bounds
Draft

SimSalabimse wants to merge 29 commits into
R0Y00:mainfrom
SimSalabimse:local/mesh57-bounds

Conversation

@SimSalabimse

@SimSalabimse SimSalabimse commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

DRAFT, not for merge. This is here so others can see what is being worked on in the derived slot 57 mesh path and avoid duplicating it. Pieces will be split into small, proven PRs.

Related: #3541, #2413, #3413, #3659.

Current status (1 December 2026)

Still experimental and unproven. Do not merge. The group stride is opt-in and unproven (X2W_MESH57_EXPERIMENT_STRIDE=128).

The branch now also has:

Windows game run on this branch: no crash. The derived walk now reaches native compute +0x374 and refuses at v_readfirstlane_b32. Before this, it stopped at v_add_co_ci_u32 +0x148. Still nothing drawn.

What this branch contains

It builds on #3413. The first 12 commits on this branch, from runtime: opt-in immediate slot 57 mesh for indirect DispatchMesh through Merge origin/main into derived-mesh slice (slot 57), are an earlier state of #3413. #3413 has moved on since, and this branch has not been updated to its latest head or to current main yet, so GitHub shows conflicts. Review #3413 for those commits.

The 10 commits on top:

  • startup: copy measured slot 57 spans when shader dump is enabled
  • startup: opt-in slot 57 mesh bounds from the record allocation
  • startup: carry decoded depth and stencil for derived slot 57 meshes
  • startup: accept the derived mesh record multiply chain
  • startup: record a raw buffer load as the derived mesh record word
  • startup: include the mesh exchange header at file scope
  • startup: accept one to eight color targets on a derived mesh: multiple render targets (1..8) in the derived Mesh57 path.
  • startup: accept a depth-only derived mesh when depth or stencil is used: depth-only passes (0 color targets).
  • startup: add an opt-in unproven stride for the derived record group: see below.
  • mesh: lower v_sub_nc_u32 and sibling integer ALU ops: the integer op change, now proposed on its own against current main in shader: accept v_sub_co_u32, v_subrev_co_u32 and v_and_or_b32 in the mesh frontend (Part of #2413) #3659. The no-carry subtracts were already accepted on main by shader: accept any zero VGPR in the mesh group-index exchange #3537.

The experimental group stride

Opt-in only: X2W_MESH57_EXPERIMENT_STRIDE=N. When it is set, the derived record path uses N as the group stride and logs experimental stride, unproven stride=N. When it is unset, behaviour is unchanged and the path still refuses with "group stride is zero".

The stride value is not measured or proven. 128 is used only because the exchange shift (>>7) yields groupId at a stride of 128, per the discussion in #2413 and #3541. This waits on a capture or a confirmation from R0Y00 before any of it is proposed for real.

Current Windows test PC status

AI-assisted (Cursor)

cursoragent and others added 27 commits November 29, 2026 13:11
X2W_MESH57_DERIVE_STATE=1 builds one desktop mesh pipeline from a single
immediate GS_ALLOC_REQ when no reviewed profile was opened, then the
existing ExecuteIndirect path forwards it. The switch off leaves every
current refusal unchanged.

Refs R0Y00#870
Refs R0Y00#2413

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
X2W_MESH57_DERIVE_STATE only attempts a direct DispatchMesh whose pipeline
is slot 57 and has no desktop PSO. Draws and other mesh pipelines stay
refused. A slot 57 pipeline with no captured stages stays refused too.

Refs R0Y00#870
Refs R0Y00#2413

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
X2W_MESH57_DXC_DIR supplies dxcompiler.dll and dxil.dll to the slot 57
derivation alone. X2W_NATIVE_SHADERS stays unset for other programs and is
only a fallback compiler directory for this path. A missing directory still
logs the existing compiler refusal. A present .mesh57-state file is still
honored when the native switch did not open it.

Refs R0Y00#870
Refs R0Y00#2413

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
The opt-in now records each DispatchMesh ExecuteIndirect, including calls
that never enter slot 57 derivation. The fixed-pair check reports which
clause failed, and the heartbeat prints the counts with one sample per
reason. Captured stage bytes stay available for a later attempt while the
switch is on.

Refs R0Y00#870
Refs R0Y00#2413

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
MSVC does not give two copies of the same reason string the same address,
so the census treated the second note as a new reason and kept that sample.
Rows now compare the characters. The host check uses two distinct copies.

Refs R0Y00#870
Refs R0Y00#2413

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
A DispatchMesh derivation now copies a single guest constant block of
1..8 dwords into desktop b0, including a heap-indexed root whose only
parameter is that block. Descriptor roots and other heap-indexed shapes
stay refused by name. A slot 55 pipeline uses its slot 57 base when every
patch is a blend record. The heartbeat adds the derived forward count.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
A slot 55 record that is not a blend tag stays refused, and the reason names the tag. The sample lists the first patch tags and sizes and the first guest-root parameter types. A zero pixel length is an empty descriptor span, not a dropped copy. No reviewed mesh user-SGPR map covers a five-parameter heap-indexed root, so that shape stays refused.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Refuse wave32, an unproven thread count, a non-triangle export, a captured
rasterizer that is not the bound default, and a constant that is not the
word at user SGPR s8. Store a slot 55 refusal on that slot 55 pipeline.
The one-constant device modes use a non-zero word in the export, including
the heap-indexed root the deferred path binds. The five-parameter heap
root stays refused.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
d3d12_xs_device_obj compiles d3d12_capture.inl without X2W_NATIVE_SHADERS.
note_pipeline calls the stage-copy helpers, so mesh57_alloc.h is included
before that file for every translation unit of d3d12_xs_device.cpp.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
The three SRV tables and the root SRV no longer all claim t0 in space 0,
so the root signature can be created. The shape stays five parameters
with the heap-indexed flag, and that root stays refused.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
A 32-bit exec write, including saveexec and wrexec, stays wave32.
Wave size 64 now requires v_mbcnt_hi or a 64-bit exec write.
A slot 55 blend patch retries a base blend or pipeline refusal.
An absent rasterizer is not a refusal.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Bring the 125 commits of upstream main since the PR base (including the
census/triage/stream-key work) into the opt-in X2W_MESH57_DERIVE_STATE
slice. Resolve three content conflicts, keeping both sides' behavior:

- tests/startup_indirect_draw_indexed.cpp: keep the derived_mesh guard
  arg and main's bucket_case/stream_key_case guard args in the arg-validity
  check.
- src/startup_stubs/d3d12_capture.inl: keep the PR's mesh57_reviewed_present
  and mesh57_derive_reason members and main's guest_stream_key member.
- src/startup_stubs/d3d12_xs_device.cpp: keep the PR's plain_constants
  indexing-match relaxation and main's cached_mesh_root refusal census code.

No behavior change beyond the merge: still opt-in, reviewed .mesh57-state
still wins, five-parameter root still refused, tags 0/1 still not blend.

AI-assisted (Cursor)
When the shader dump directory is set, slot 57 pipeline creation copies
descriptor spans whose live length qword matches the measured packing.
Other create paths are unchanged. The copy does not bind mesh counts or
write a profile.
X2W_MESH57_DERIVED_BOUNDS=1 reads an m0 built by s_lshl and s_or
immediately before GS_ALLOC_REQ. The vertex and primitive limits are
the record masks plus one, times 2^k, and only when k is 1. The group
is the smallest multiple of 64 that covers that limit, matching the
direct mesh lane index. SetMeshOutputCounts uses the runtime counts.
The immediate m0 reader is unchanged, and the switch defaults off.
X2W_MESH57_DERIVED_BOUNDS=1 copies the decoded depth-stencil state into
the derived mesh pipeline and uses the depth view already bound on the
list. The dispatch sets the decoded stencil reference for that command.
Depth bounds, differing back-face masks, a multisampled depth buffer,
and a stencil test without a stencil plane stay refused. The switch
still defaults off.
X2W_MESH57_DERIVED_BOUNDS=1 treats v_bfe_u32 as a field extract and
accepts v_mul_lo_u32 by min(base + (1 << k), L) - base when k is a
logical shift right by 29. The limit stays (mask + 1) * 2^k with the
caller-passed k of 1, and a product above 256 stays refused. Unsigned
wrap of that subtract is possible; SetMeshOutputCounts still clamps to
the derived limit. A color-target refusal logs which condition failed,
once per pipeline key. The switch still defaults off.
A buffer load was invisible to the record-m0 reader, so a mask of the loaded
VGPR followed an older ALU write. Only the low VGPR of a raw dword, dwordx2,
dwordx3, or dwordx4 load is the record word, and both fields have to name
that same load. Other data VGPRs, a TFE status VGPR, and format, byte, short,
and d16 loads are ordinary writes. An LDS load writes no VGPR. On an MTBUF
load, word 0 bit 16 is an opcode bit, not LDS.

The group-index exchange is still refused. With the derived-bounds layout the
refusal names the first failed check, and one line per pipeline key is logged.
The accepted sequence is unchanged. With the switch off the refusal sentence
is unchanged.
native_mesh57.inl is included inside the anonymous namespace of the device
translation unit. A header included from there nested x2w_startup inside that
namespace. The header is included at file scope with the other mesh headers.
The record layout still leaves the group stride at 0: the hardware entry
value of v5 is not modelled.
Bring the 148 commits of R0Y00 main since the previous merge (45f9045,
including slot 86 native bindings, present planes, and mesh57 real-shape
work) into the opt-in X2W_MESH57_DERIVE_STATE slice. Resolve five content
conflicts, keeping both sides' behavior:

- CMakeLists.txt: keep the PR's derived-mesh test modes and main's
  guarded, empty, and missing-position allocation tests.
- CMakePresets.json: keep mesh57_derive_alloc_check and the derived-mesh
  pr-filter entries, and main's compile_dxil, present-planes, and
  present-composite targets and filter entries.
- docs/experiments/native-fixed-mesh57.md: keep the PR's opt-in
  allocation section and main's real-shape v6 and partial-EXEC sections.
- src/startup_stubs/d3d12_xs_device.cpp: keep the PR's plain_constants
  field and main's slot 86 heap, texture-map, and Mesh86HeapEntry
  members. Fold the derived-mesh indexing relaxation into
  cached_mesh_root_matches so a one-constant non-heap root still
  matches, without loosening slot 86 heap or texture-map cases.
- src/startup_stubs/native_mesh57.inl: keep main's profile_open_failed
  outcome and profile_error helper, and the PR's mesh57_reviewed_present
  flag after a successful profile open.

No behavior change beyond the merge: still opt-in, reviewed
.mesh57-state still wins, five-parameter root still refused, tags 0/1
still not blend.

AI-assisted (Cursor)
AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
After merging current main, state_block_blend applies the mesh layout
shift itself from the tag at +0x004. The derived-mesh path still passed
a pointer already advanced by +0x54, so the reader looked for the tag
in the wrong place and refused with "unknown state block A layout".
Give it the full block.

AI-assisted (Cursor)
Zero color targets stay refused unless a single-sample depth buffer is bound and the decoded state tests or writes depth or stencil. A pixel color export to an unbound target is refused.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
X2W_MESH57_EXPERIMENT_STRIDE, off by default, may set the record layout stride to a positive integer after the reader has stored 0. Unset and invalid values keep stride 0.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
The native mesh path now accepts the no-carry subtract forms, the carry-out subtract forms, and v_and_or_b32 by calling the existing ALU.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Main's slot 57 and slot 86 behavior stays. The derived mesh path keeps
one to eight color targets, depth-only when depth or stencil is used,
and the opt-in unproven experiment stride. The mesh ALU list keeps
v_sub_co_u32, v_subrev_co_u32 and v_and_or_b32; main already has the
no-carry subtract forms.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
The derived mesh path passes the whole state block A to the blend reader.
That reader applies the mesh shift from the tag at +0x004, so tag 6 blend
words stay at +0x124. An unknown tag is still refused.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
DispatchMesh indexed the bound root by the guest constant parameter
before checking that the vector contains it. A missing or shorter root
aborted in the debug CRT, which does not throw, so the derive log stayed
empty. The mesh mapping and the lowerer now refuse a parameter index past
the root before they read it.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
cursoragent and others added 2 commits December 1, 2026 00:23
A v_readfirstlane_b32 whose source is an SGPR, a constant, or a value
already tracked as wave-uniform is a copy. A VGPR that is not uniform
becomes WaveReadLaneFirst when the instruction runs for the whole wave.
Unknown EXEC, a per-lane mask, a vector destination, and modifiers stay
refused and name the condition that failed.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

# Conflicts:
#	CMakePresets.json
#	docs/startup-runtime.md
#	src/gfx1013_direct_mesh.inl
#	tests/startup_indirect_draw_indexed.cpp
@SimSalabimse

Copy link
Copy Markdown
Contributor Author

I'm pausing slot 57 (Deserialize pipeline) work. The next derived-walk wall is v_cmpx_lt_u32, which is now covered in draft #3713.

A game run shows the title also creating mesh pipelines through slot 86 CreatePipelineState, which currently goes to the placeholder path. Mesh effort is moving to that route (#3639/#3640 belong to others; the shared lowering work lands in #3659/#3713). I'm leaving #3660 open as experimental.

AI-Assisted

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.

2 participants