mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 22:48:50 +00:00
rt::rootsig::pack_stage() lays a root signature out for one stage the way the console compiler does: root order from the stage base, a table one dword (its 32-bit VA), a root view two, constants one per value, and the first parameter that does not fit refused (the spill array behind s[0:1] is not modelled). Compute (base s4) is measured: on the package's FidelityFX DLL, whose 29 compute containers carry their RTS0 next to the console-compiled program, base plus span equals RSRC2 USER_SGPR in 29 of 29, and root_sig_contract.py --model console finds all 20 translated programs compatible (the s0 model contradicts 7). VS/PS/GS s8 and MS s16 stay a census hypothesis. The compute bind point now uses this layout; graphics keeps pack(), since every stage reads one push-constant block and a mesh shader (s16) and a pixel shader (s8) would collide. A signature carries both layouts; binding it where its layout refused it invalidates the list. Test fixtures follow: the compute GLSL shaders read the new places, and the asm fixtures a D3D12 compute PSO runs are built with LEONIDA_USER_DATA_SHIFT=4 (compute_fixture.py shifts every SGPR and the RSRC2 user count), so the standalone harness keeps using them at s0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
3.0 KiB
Plaintext
75 lines
3.0 KiB
Plaintext
#version 460
|
|
// A compute shader written to the translator's runtime contract (docs/design.md, "User data" and "Xbox GPU
|
|
// addresses"), standing in for a translated one in d3d12_compute_test: the 144-byte push-constant block holds
|
|
// s0..s31 (the root arguments), the heap base and the code base, and every memory access goes to heap base +
|
|
// console VA. It reads each kind of root argument the D3D12 layer packs, in the console compute layout
|
|
// (rt::rootsig::pack_stage, from s4, one dword per table; s0..s3 are the driver's):
|
|
// s4, s5 root constants: base and step
|
|
// s6:s7 a root UAV: the console VA of the output buffer
|
|
// s8 a descriptor table: the 32-bit console VA of its first entry (the heaps live below 4 GiB); that entry
|
|
// is a 64-bit console VA the application wrote itself
|
|
// code the shader's own program (FSSM blob), dword 1
|
|
// and writes out[i] = s4 + s5 * i + table_target[i % 4] + code[1].
|
|
#extension GL_EXT_buffer_reference : require
|
|
#extension GL_EXT_buffer_reference_uvec2 : require
|
|
|
|
layout(local_size_x = 64) in;
|
|
|
|
layout(buffer_reference, std430, buffer_reference_align = 4) buffer Words {
|
|
uint w[];
|
|
};
|
|
|
|
layout(push_constant) uniform UserData {
|
|
uint s[32];
|
|
uvec2 heap_base;
|
|
uvec2 code_base;
|
|
} pc;
|
|
|
|
uvec2 add64(uvec2 a, uvec2 b) {
|
|
uint carry;
|
|
const uint low = uaddCarry(a.x, b.x, carry);
|
|
return uvec2(low, a.y + b.y + carry);
|
|
}
|
|
|
|
Words at(uvec2 va) {
|
|
return Words(add64(pc.heap_base, va));
|
|
}
|
|
|
|
void main() {
|
|
const uint i = gl_GlobalInvocationID.x;
|
|
Words table = at(uvec2(pc.s[8], 0u));
|
|
Words result = at(uvec2(pc.s[6], pc.s[7]));
|
|
if (pc.s[5] == 0u) {
|
|
// CBV V# mode: table holds a 16-byte GFX10 raw buffer descriptor written by CreateConstantBufferView.
|
|
const uint num_records = table.w[2];
|
|
const uint byte_off = pc.s[4] + i * 4u;
|
|
if (byte_off + 4u <= num_records) {
|
|
Words cbv = at(uvec2(table.w[0], table.w[1] & 0xFFFFu));
|
|
result.w[i] = cbv.w[byte_off >> 2u];
|
|
} else {
|
|
result.w[i] = 0u;
|
|
}
|
|
return;
|
|
}
|
|
if (pc.s[5] == 0xFFFFFFFFu) {
|
|
// Buffer SRV V# mode: decode 16-byte GFX10 buffer descriptor written by CreateShaderResourceView.
|
|
const uint stride = (table.w[1] >> 16u) & 0x3FFFu;
|
|
const uint num_records = table.w[2];
|
|
const uint oob_select = (table.w[3] >> 28u) & 3u;
|
|
const uvec2 base = uvec2(table.w[0], table.w[1] & 0xFFFFu);
|
|
if (oob_select == 3u) {
|
|
const uint byte_off = pc.s[4] + i * 4u;
|
|
result.w[i] = (byte_off + 4u <= num_records) ? at(base).w[byte_off >> 2u] : 0u;
|
|
} else if (oob_select == 1u && stride >= 4u) {
|
|
const uint idx = pc.s[4] + i;
|
|
result.w[i] = (idx < num_records) ? at(base).w[(idx * stride) >> 2u] : 0u;
|
|
} else {
|
|
result.w[i] = 0u;
|
|
}
|
|
return;
|
|
}
|
|
Words constants = at(uvec2(table.w[0], table.w[1]));
|
|
Words code = at(pc.code_base);
|
|
result.w[i] = pc.s[4] + pc.s[5] * i + constants.w[i % 4] + code.w[1];
|
|
}
|