From 1e380e166f76008e1b68d047b2d6dd74f93fb07f Mon Sep 17 00:00:00 2001 From: tedin7 Date: Tue, 24 Nov 2026 23:56:34 +0100 Subject: [PATCH 1/4] feat: translate BUF_FMT_2_10_10_10_UNORM typed buffer loads in gfx2hlsl Part of #1723 --- CMakeLists.txt | 3 + .../startup_gfx2hlsl_tbuffer_2101010_check.py | 125 ++++++++++++++++++ tools/startup/gfx2hlsl.py | 5 +- 3 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 tests/startup_gfx2hlsl_tbuffer_2101010_check.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 05927f896..d8c64abd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2745,6 +2745,9 @@ if(EXISTS "${INTAKE_PYTHON}") # A typed buffer load of BUF_FMT_16_16_16_16_FLOAT reads four halves from one 8-byte element (#1695). add_test(NAME startup_gfx2hlsl_tbuffer_16f COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_tbuffer_16f_check.py") + # A typed buffer load of BUF_FMT_2_10_10_10_UNORM reads three 10-bit fields and a 2-bit one from one dword (#1723). + add_test(NAME startup_gfx2hlsl_tbuffer_2101010 COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_tbuffer_2101010_check.py") # 32-bit scalar complement logic: s_nand_b32, s_nor_b32 and s_xnor_b32 against an integer reference (#1919). add_test(NAME startup_gfx2hlsl_sop2_complement COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_sop2_complement_check.py") diff --git a/tests/startup_gfx2hlsl_tbuffer_2101010_check.py b/tests/startup_gfx2hlsl_tbuffer_2101010_check.py new file mode 100644 index 000000000..1f9fbae09 --- /dev/null +++ b/tests/startup_gfx2hlsl_tbuffer_2101010_check.py @@ -0,0 +1,125 @@ +"""Packed 2-10-10-10 UNORM typed buffer loads in tools/startup/gfx2hlsl.py (Part of #1723). + +usage: startup_gfx2hlsl_tbuffer_2101010_check.py + +`BUF_FMT_2_10_10_10_UNORM` stores x, y and z as 10-bit fields and w as a 2-bit field in one dword, lowest bits +first. The format table did not name it, so a typed load of it was refused with +`buffer format BUF_FMT_2_10_10_10_UNORM`. DXGI_FORMAT_R10G10B10A2_UNORM (24) in an input layout maps to it. + +The instruction bytes are constructed here from the field layout the checked-in decoder reads +(`tools/disasm_rdna2.py`, the MTBUF branch): no game-derived bytes are used. Each case encodes the instruction, +decodes it, translates it, and then evaluates the emitted component expressions against a reference that +decodes the same dword from the format definition (UNORM n / (2^bits - 1)). +""" +import os +import re +import struct +import sys + +here = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.join(here, '..', 'tools')) +sys.path.insert(0, os.path.join(here, '..', 'tools', 'startup')) +import gfx2hlsl as G # noqa: E402 + +failures = [] + + +def check(label, condition, detail=''): + print(f"{label}: {'ok' if condition else 'MISMATCH'}") + if not condition: + failures.append(label) + if detail: + print(' ' + detail) + + +MTBUF_LOAD = {'x': 0, 'xy': 1, 'xyz': 2, 'xyzw': 3} +MTBUF_FORMAT_2_10_10_10_UNORM = 50 +MTBUF_FORMAT_2_10_10_10_SNORM = 51 # a sibling the table must keep refusing + + +def encode_mtbuf(op, fmt, *, vdata=0, vaddr=0, srsrc=4, soffset=128): + """Encode one MTBUF instruction (idxen); returns the 8 bytes the decoder reads.""" + w0 = (0b111010 << 26) | ((fmt & 0x7f) << 19) | ((op & 0x7) << 16) | (1 << 13) + w1 = (vaddr & 0xff) | ((vdata & 0xff) << 8) | (((srsrc // 4) & 0x1f) << 16) | (((op >> 3) & 1) << 21) | (soffset << 24) + return struct.pack(';` lines with `w` bound to the loaded dword; returns {N: value}.""" + out = {} + for line in lines: + m = re.fullmatch(r'v(\d+) = (.*);', line.strip()) + if m: + out[int(m.group(1))] = eval(m.group(2), {'U': lambda x: x, 'ldu': lambda *_: 0}, {'w': word}) + return out + + +def reference(word): + return [(word & 1023) / 1023.0, ((word >> 10) & 1023) / 1023.0, ((word >> 20) & 1023) / 1023.0, (word >> 30) / 3.0] + + +code = encode_mtbuf(MTBUF_LOAD['xyzw'], MTBUF_FORMAT_2_10_10_10_UNORM, vdata=1, vaddr=2, srsrc=4) +asm, lines = translate_bytes(code) +check('decodes the named format', 'BUF_FMT_2_10_10_10_UNORM' in asm[0], repr(asm)) +check('the word is loaded with ldu', any('w = ldu(r0, a)' in l for l in lines), repr(lines)) + +for word in (0x00000000, 0xffffffff, 0x4012a3ff, 0x8007fc01, 0xc0000000, 0x2aaaaaaa, 0x155ff3d1): + got = run_components(lines, word) + want = reference(word) + check('all four components for 0x%08x' % word, [got.get(1 + i) for i in range(4)] == want, + 'got %r want %r' % (got, want)) + +# Fewer components read the same leading fields. +_, lines_xy = translate_bytes(encode_mtbuf(MTBUF_LOAD['xy'], MTBUF_FORMAT_2_10_10_10_UNORM, vdata=1, vaddr=2)) +got = run_components(lines_xy, 0x4012a3ff) +check('the xy form reads two components', sorted(got) == [1, 2] and [got[1], got[2]] == reference(0x4012a3ff)[:2], repr(got)) + +# The input-layout mapping: DXGI_FORMAT_R10G10B10A2_UNORM is 24, one dword per element. +check('DXGI 24 maps to the format', G.FETCH_DXGI.get(24) == ('BUF_FMT_2_10_10_10_UNORM', 4), repr(G.FETCH_DXGI.get(24))) + +# A sibling format stays refused. +try: + translate_bytes(encode_mtbuf(MTBUF_LOAD['xyzw'], MTBUF_FORMAT_2_10_10_10_SNORM, vdata=1, vaddr=2)) + refused = False +except G.Unsupported: + refused = True +check('the SNORM sibling stays refused', refused) + +if failures: + print('FAIL') + for text in failures: + print(' ' + text) + sys.exit(1) +print('PASS') diff --git a/tools/startup/gfx2hlsl.py b/tools/startup/gfx2hlsl.py index 36890a6ec..3095bf6e9 100644 --- a/tools/startup/gfx2hlsl.py +++ b/tools/startup/gfx2hlsl.py @@ -123,7 +123,8 @@ def strip_header(code): FETCH_DXGI = {2: ('BUF_FMT_32_32_32_32_FLOAT', 16), 6: ('BUF_FMT_32_32_32_FLOAT', 12), 16: ('BUF_FMT_32_32_FLOAT', 8), 41: ('BUF_FMT_32_FLOAT', 4), 28: ('BUF_FMT_8_8_8_8_UNORM', 4), 49: ('BUF_FMT_8_8_UNORM', 2), 61: ('BUF_FMT_8_UNORM', 1), 34: ('BUF_FMT_16_16_FLOAT', 4), 35: ('BUF_FMT_16_16_UNORM', 4), - 37: ('BUF_FMT_16_16_SNORM', 4), 30: ('BUF_FMT_8_8_8_8_UINT', 4)} + 37: ('BUF_FMT_16_16_SNORM', 4), 30: ('BUF_FMT_8_8_8_8_UINT', 4), + 24: ('BUF_FMT_2_10_10_10_UNORM', 4)} # Typed buffer loads: (word load or None, the four component expressions). Components a format lacks read as # 0, 0, 0, 1 here, as in the existing tbuffer translation; that default is an assumption, not a measurement. FETCH_FORMATS = { @@ -132,6 +133,8 @@ def strip_header(code): 'BUF_FMT_8_8_UNORM': ('ldu({0}, a)', ['U((w & 255) / 255.0)', 'U(((w >> 8) & 255) / 255.0)', '0u', 'U(1.0)']), 'BUF_FMT_8_UNORM': ('ldu({0}, a)', ['U((w & 255) / 255.0)', '0u', '0u', 'U(1.0)']), 'BUF_FMT_8_UINT': ('{0}.Load(a & ~3u) >> ((a & 3u) * 8u)', ['w & 255u', '0u', '0u', '1u']), + # Three 10-bit fields and a 2-bit one in one dword, lowest bits first: x, y, z, then w. + 'BUF_FMT_2_10_10_10_UNORM': ('ldu({0}, a)', ['U((w & 1023) / 1023.0)', 'U(((w >> 10) & 1023) / 1023.0)', 'U(((w >> 20) & 1023) / 1023.0)', 'U((w >> 30) / 3.0)']), 'BUF_FMT_16_16_UNORM': ('ldu({0}, a)', ['U((w & 65535) / 65535.0)', 'U((w >> 16) / 65535.0)', '0u', 'U(1.0)']), # SNORM: sign-extend each half, divide by 32767 and clamp to -1.0, so that -32768 and -32767 both give -1.0 # (Direct3D / Vulkan SNORM rule; LLVM 15 and Mesa ac_formats name the format 16_16_SNORM, number 24). From 328b603d9d9a807d2df79e9528320e9d3acbc0f1 Mon Sep 17 00:00:00 2001 From: tedin7 Date: Wed, 25 Nov 2026 11:55:57 +0100 Subject: [PATCH 2/4] docs: document BUF_FMT_2_10_10_10_UNORM typed buffer fetch --- docs/experiments.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/experiments.md b/docs/experiments.md index 093385c93..e0550b7df 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -286,6 +286,8 @@ ctest --preset dev --no-tests=error -R '^startup_vertex_fetch_formats_(controls| `BUF_FMT_16_16_SNORM` (format 24, DXGI `R16G16_SNORM` 37) sign-extends each half, divides by 32767 and clamps to -1.0, so -32768 and -32767 both give -1.0 (the Direct3D and Vulkan SNORM rule, as in LLVM 15 and Mesa `ac_formats`). The device run compares `round(v * 32767)` against the same byte decode, with a wrong reference that reads the halves unsigned and a mutated translation that does the same. The pattern the harness writes to t0 holds no 0x8000, so `startup_vertex_fetch_formats_controls` also evaluates the emitted expressions on 0x8000, 0x8001, 0x7fff, 0x0000, 0xffff and 0x4000 in each half, and four wrong forms (unsigned read, no clamp, divisor 32768, one half for both) must fail that check. The D3D12 draw has not been run on Linux. +`BUF_FMT_2_10_10_10_UNORM` (gfx10 format 50, DXGI `R10G10B10A2_UNORM` 24) reads one dword with x, y and z as 10-bit fields in bits 9:0, 19:10 and 29:20 and w as the 2-bit field in bits 31:30, each divided by its maximum (1023, 1023, 1023, 3). This is the 10-bit-x layout that Mesa maps R10G10B10A2 to; `BUF_FMT_10_10_10_2_UNORM` (format 44) has a 2-bit x and is not added here. It is checked on Linux by the Python evaluation `startup_gfx2hlsl_tbuffer_2101010`, which also covers the DXGI table entry; no D3D12 draw has been run for it. + `BUF_FMT_8_8_8_8_UINT` (gfx10 format 60, DXGI `R8G8B8A8_UINT` 30) reads four unsigned bytes into X, Y, Z and W in increasing address order. With stride 5 and byte offset 3, the 16-vertex fixture visits all four dword alignments. On WARP, all 64 component words matched the byte reference. Swapping channels in the reference or normalizing the green byte in the generated shader each triggered a mismatch. ### Combined `idxen` + `offen`, scalar `soffset` and MUBUF/MTBUF modifier checks From 1c5960644b788511900831d2253521cf0b91442a Mon Sep 17 00:00:00 2001 From: tedin7 Date: Thu, 26 Nov 2026 01:28:06 +0100 Subject: [PATCH 3/4] docs: list R10G10B10A2_UNORM in the descriptor FORMAT table (#1723) --- docs/experiments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/experiments.md b/docs/experiments.md index 0d156cdb1..16c8aa869 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -403,7 +403,7 @@ ctest --preset dev --no-tests=error -R '^startup_vertex_fetch_formats_(controls| A typed buffer view that the title creates through the runtime (`CreateShaderResourceView`, `BUFFER`, no flags, no structure stride) leaves no hardware descriptor in the table. For this case the draw builds word 3 the way the console driver builds it from the view, using `view_word3()` in `src/startup_stubs/buffer_format_word3.h`: -- FORMAT is the code of the DXGI format whose typed read gives the same components. The 14 formats in the switch are covered: `R8_UNORM` 1, `R8_UINT` 5, `R8G8_UNORM` 14, `R32_FLOAT` 22, `R16G16_UNORM` 23, `R16G16_SNORM` 24, `R16G16_UINT` 27, `R16G16_FLOAT` 29, `R8G8B8A8_UNORM` 56, `R8G8B8A8_UINT` 60, `R32G32_FLOAT` 64, `R16G16B16A16_FLOAT` 71, `R32G32B32_FLOAT` 74 and `R32G32B32A32_FLOAT` 77. The codes are the LLVM 15 `llvm-mc -mcpu=gfx1013` encodings of the tbuffer `format:` operand. +- FORMAT is the code of the DXGI format whose typed read gives the same components. The 15 formats in the switch are covered: `R8_UNORM` 1, `R8_UINT` 5, `R8G8_UNORM` 14, `R32_FLOAT` 22, `R16G16_UNORM` 23, `R16G16_SNORM` 24, `R16G16_UINT` 27, `R16G16_FLOAT` 29, `R10G10B10A2_UNORM` 50, `R8G8B8A8_UNORM` 56, `R8G8B8A8_UINT` 60, `R32G32_FLOAT` 64, `R16G16B16A16_FLOAT` 71, `R32G32B32_FLOAT` 74 and `R32G32B32A32_FLOAT` 77. The codes are the LLVM 15 `llvm-mc -mcpu=gfx1013` encodings of the tbuffer `format:` operand. - DST_SEL comes from `Shader4ComponentMapping`: a channel becomes 4 to 7, a forced 0 becomes 0 and a forced 1 becomes 1. The draw is refused, not read as zeros, whenever a translated formatted load has no resolved word 3: From a2e70c73d2b16e42a1bb0adbb016a37507f916da Mon Sep 17 00:00:00 2001 From: c1 Date: Thu, 26 Nov 2026 07:34:43 +0100 Subject: [PATCH 4/4] fix: bump shader cache revision to 20 for format 50; cover R10G10B10A2 in the word3 check Move x2w-startup-shader-19/19cs to 20/20cs (the run-time FORMAT switch gains case 50), update the known-answer keys, add R10G10B10A2_UNORM to the decoded formats and to the view_word3 identity check, and refresh the docs. --- docs/experiments.md | 2 +- docs/startup-runtime.md | 4 ++-- src/startup_stubs/d3d12_draw.inl | 4 ++-- tests/startup_buffer_format_word3_check.cpp | 4 +++- tests/startup_compute_request_offline_check.py | 4 ++-- tests/startup_gfx2hlsl_buffer_store_check.py | 2 +- tests/startup_gfx2hlsl_const_copy_join_check.py | 2 +- tests/startup_gfx2hlsl_fract_check.py | 4 ++-- tests/startup_indirect_draw_indexed.cpp | 2 +- tests/startup_packed_position_provenance_check.py | 2 +- tests/startup_resource_retire_title.cpp | 2 +- tests/startup_shader_cache_key_check.py | 6 +++--- tools/startup/gfx2hlsl.py | 4 ++-- 13 files changed, 22 insertions(+), 20 deletions(-) diff --git a/docs/experiments.md b/docs/experiments.md index f81909a97..7ae776ba1 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -402,7 +402,7 @@ ctest --preset dev --no-tests=error -R '^startup_vertex_fetch_formats_(controls| `BUF_FMT_16_16_SNORM` (format 24, DXGI `R16G16_SNORM` 37) sign-extends each half, divides by 32767 and clamps to -1.0, so -32768 and -32767 both give -1.0 (the Direct3D and Vulkan SNORM rule, as in LLVM 15 and Mesa `ac_formats`). The device run compares `round(v * 32767)` against the same byte decode, with a wrong reference that reads the halves unsigned and a mutated translation that does the same. The pattern the harness writes to t0 holds no 0x8000, so `startup_vertex_fetch_formats_controls` also evaluates the emitted expressions on 0x8000, 0x8001, 0x7fff, 0x0000, 0xffff and 0x4000 in each half, and four wrong forms (unsigned read, no clamp, divisor 32768, one half for both) must fail that check. The D3D12 draw has not been run on Linux. -`BUF_FMT_2_10_10_10_UNORM` (gfx10 format 50, DXGI `R10G10B10A2_UNORM` 24) reads one dword with x, y and z as 10-bit fields in bits 9:0, 19:10 and 29:20 and w as the 2-bit field in bits 31:30, each divided by its maximum (1023, 1023, 1023, 3). This is the 10-bit-x layout that Mesa maps R10G10B10A2 to; `BUF_FMT_10_10_10_2_UNORM` (format 44) has a 2-bit x and is not added here. It is checked on Linux by the Python evaluation `startup_gfx2hlsl_tbuffer_2101010`, which also covers the DXGI table entry; no D3D12 draw has been run for it. +`BUF_FMT_2_10_10_10_UNORM` (gfx10 format 50, DXGI `R10G10B10A2_UNORM` 24) reads one dword with x, y and z as 10-bit fields in bits 9:0, 19:10 and 29:20 and w as the 2-bit field in bits 31:30, each divided by its maximum (1023, 1023, 1023, 3). This is the 10-bit-x layout that Mesa maps R10G10B10A2 to; `BUF_FMT_10_10_10_2_UNORM` (format 44) has a 2-bit x and is not added here. It is checked on Linux by the Python evaluation `startup_gfx2hlsl_tbuffer_2101010`, which also covers the DXGI table entry; the D3D12 draws `startup_vertex_fetch_formats_warp` and `startup_vertex_fetch_formats_hardware` read it back (stride 6 / offset 2 and through the descriptor path). In a graphics shader with only forward branches, a 32-bit root-table pointer diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index ac25b37e1..d0f03ec51 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -208,9 +208,9 @@ The translation is refused when: - either header has another size; - the code reads an attribute the table does not list. -The shader cache revision is `x2w-startup-shader-19`. Revision 19 folds `s_mov_b32` from a scalar register that +The shader cache revision is `x2w-startup-shader-20`. Revision 20 decodes MTBUF/MUBUF format 50 (`R10G10B10A2_UNORM`) in the run-time FORMAT switch, so cached shaders from revision 19 are not reused. Revision 19 folds `s_mov_b32` from a scalar register that holds a plain constant, so later reads of the copy use the constant word. The matching compute -(`x2w-startup-shader-19cs`) key advances because that stage uses the shared lowering. The fixed slot 57 mesh +(`x2w-startup-shader-20cs`) key advances because that stage uses the shared lowering. The fixed slot 57 mesh (`x2w-startup-mesh-57-3`) key stays, because that shader is not translated from guest code. Revisions before 19 read a register copied from a constant as a run-time value. Revision 18 preserves the sign of zero in floating-point min, max, min3, max3 and med3. diff --git a/src/startup_stubs/d3d12_draw.inl b/src/startup_stubs/d3d12_draw.inl index e4335cedf..00a7b5e8a 100644 --- a/src/startup_stubs/d3d12_draw.inl +++ b/src/startup_stubs/d3d12_draw.inl @@ -353,7 +353,7 @@ Translation* cached_translation(const void* a, std::size_t a_bytes, const void* { // Keep pre-fix desktop bytecode and manifests out of this ABI's cache. // tools/startup/gfx2hlsl.py hashes the same bytes, without a trailing NUL. - constexpr char revision[] = "x2w-startup-shader-19"; + constexpr char revision[] = "x2w-startup-shader-20"; const u64 seed = fnv_bytes(revision, sizeof(revision) - 1); u64 key = fnv_bytes(root_blob.data(), root_blob.size(), fnv_bytes(b, b_bytes, fnv_bytes(a, a_bytes, seed))); // A stream's input layout (stream_input_layout) feeds the vertex fetch, so it is part of the key. @@ -474,7 +474,7 @@ u64 publish_compute_request(const void* desc) std::vector fields(sizeof(words)); words[0] = words[1] = words[3] = words[5] = words[7] = words[9] = words[10] = 0; std::memcpy(fields.data(), words, sizeof(words)); - constexpr char compute_revision[] = "x2w-startup-shader-19cs"; // tools/startup/gfx2hlsl.py compute_key + constexpr char compute_revision[] = "x2w-startup-shader-20cs"; // tools/startup/gfx2hlsl.py compute_key u64 key = fnv_bytes(compute_revision, sizeof(compute_revision) - 1); const std::vector* order[] = {&code, &data, &root_blob, &fields, &state_a, &state_b}; for (const auto* part : order) key = fnv_part(*part, key); diff --git a/tests/startup_buffer_format_word3_check.cpp b/tests/startup_buffer_format_word3_check.cpp index 8df22b7b4..5e245ecd9 100644 --- a/tests/startup_buffer_format_word3_check.cpp +++ b/tests/startup_buffer_format_word3_check.cpp @@ -45,6 +45,8 @@ int main(int argc, char** argv) std::uint32_t word = 0; check("float4 identity", !x2w_startup::view_word3(typed(DXGI_FORMAT_R32G32B32A32_FLOAT), word) && word == (77u << 12 | identity)); + check("R10G10B10A2 unorm identity", !x2w_startup::view_word3(typed(DXGI_FORMAT_R10G10B10A2_UNORM), word) && + word == (50u << 12 | identity)); check("half2 identity", !x2w_startup::view_word3(typed(DXGI_FORMAT_R16G16_FLOAT), word) && word == (29u << 12 | identity)); check("snorm2 identity", !x2w_startup::view_word3(typed(DXGI_FORMAT_R16G16_SNORM), word) && word == (24u << 12 | identity)); check("uint8 identity", !x2w_startup::view_word3(typed(DXGI_FORMAT_R8_UINT), word) && word == (5u << 12 | identity)); @@ -59,7 +61,7 @@ int main(int argc, char** argv) const DXGI_FORMAT decoded[] = {DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R16G16_UNORM, DXGI_FORMAT_R16G16_SNORM, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R32G32B32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R8G8B8A8_UINT}; + DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R10G10B10A2_UNORM}; for (DXGI_FORMAT f : decoded) { const std::uint32_t code = x2w_startup::buffer_format_code(f); if (!code || !x2w_startup::formatted_buffer_supported(code)) { diff --git a/tests/startup_compute_request_offline_check.py b/tests/startup_compute_request_offline_check.py index a834a0762..3b6c7fec3 100644 --- a/tests/startup_compute_request_offline_check.py +++ b/tests/startup_compute_request_offline_check.py @@ -25,12 +25,12 @@ DESC = struct.pack('<12Q', 0, 0, 24, 0, 20, 0, len(CODE), 0, len(DATA), 0, 0, 11) STATE_A = struct.pack('<3Q', 1, 0x2c, 0xfff0000000000003) STATE_B = struct.pack('<5I', 0x1234abcd, 0xffff0000, 0, 0, 0) -KEY = 0x63ac0aa21c46da1c # framed key at revision 19cs +KEY = 0x88e751913fcbf7a8 # framed key at revision 20cs def framed_key(): h = 1469598103934665603 - for b in b'x2w-startup-shader-19cs': + for b in b'x2w-startup-shader-20cs': h = ((h ^ b) * 1099511628211) & 0xffffffffffffffff for part in (CODE, DATA, ROOT, DESC, STATE_A, STATE_B): for b in struct.pack(' translated_pipeline(ID3D12Device* guest, ID3D12RootSignature* r bool needs_start, bool table_buffer = false, bool indexed = false, bool rect = false) { // The opaque guest programs identify synthetic cache entries. The actual bound shaders are source-built DXBC. - constexpr char revision[] = "x2w-startup-shader-19"; + constexpr char revision[] = "x2w-startup-shader-20"; static std::uint32_t vertex_ids[]{0xe0000101, 0xe0000102, 0xe0000103}; static std::uint32_t pixel_ids[]{0xe0000202, 0xe0000203, 0xe0000204}; auto& vertex_id = vertex_ids[indexed ? 2 : needs_start]; diff --git a/tests/startup_packed_position_provenance_check.py b/tests/startup_packed_position_provenance_check.py index fea8cc816..8620af940 100644 --- a/tests/startup_packed_position_provenance_check.py +++ b/tests/startup_packed_position_provenance_check.py @@ -206,7 +206,7 @@ def refused(label, cache, key, reason): cache = Path(tmp) bare = G.pipeline_key(VS_WORDS, ps_words(4), root_blob()) check('without a description the key is unchanged', - bare == G.fnv(root_blob(), G.fnv(ps_words(4), G.fnv(VS_WORDS, G.fnv(b'x2w-startup-shader-19'))))) + bare == G.fnv(root_blob(), G.fnv(ps_words(4), G.fnv(VS_WORDS, G.fnv(b'x2w-startup-shader-20'))))) keys = [put_request(cache, ps_words(4), masks) for masks in (TARGET, SAME_V4, DECOY)] check('same stages, root and layout with three mask pairs: three request identities', len(set(keys)) == 3 and bare not in keys diff --git a/tests/startup_resource_retire_title.cpp b/tests/startup_resource_retire_title.cpp index 24c80d3b0..b06474077 100644 --- a/tests/startup_resource_retire_title.cpp +++ b/tests/startup_resource_retire_title.cpp @@ -371,7 +371,7 @@ constexpr UINT draw_side = 4; // 4x4 R8G8B8A8_UNORM target constexpr UINT draw_covered = 3; // scissor leaves the last row and column untouched as the sentinel constexpr int draw_seed = 77; constexpr UINT draw_clear_pixel = 0xffff00ffu; // ClearRenderTargetView({1, 0, 1, 1}) in R8G8B8A8_UNORM -constexpr char draw_revision[] = "x2w-startup-shader-19"; // d3d12_draw.inl cached_translation +constexpr char draw_revision[] = "x2w-startup-shader-20"; // d3d12_draw.inl cached_translation constexpr char draw_vertex_shader[] = R"( struct Varying { float4 position : SV_Position; }; diff --git a/tests/startup_shader_cache_key_check.py b/tests/startup_shader_cache_key_check.py index a0d27d525..fd44bba11 100644 --- a/tests/startup_shader_cache_key_check.py +++ b/tests/startup_shader_cache_key_check.py @@ -49,10 +49,10 @@ def check_request(blobs, key, diagnostic=None, rtv_request=None, layout=None): def main(): # Independently executed C++ runtime fnv_bytes/cached_translation known-answer vector. - # Revision x2w-startup-shader-19 excludes NUL. Stored order is a, b, root, then optional input layout. + # Revision x2w-startup-shader-20 excludes NUL. Stored order is a, b, root, then optional input layout. vector = (b"\x00VS\xff", b"PS\x00\x80", b"RTS0\x00") - assert gfx2hlsl.pipeline_key(*vector) == 0xf3444b13fe09b4df - assert gfx2hlsl.pipeline_key(*vector, b"ia\x00\xfe") == 0x2039e248f9cad09f + assert gfx2hlsl.pipeline_key(*vector) == 0x4564b4bb15aa0b9b + assert gfx2hlsl.pipeline_key(*vector, b"ia\x00\xfe") == 0x8a4952a88d16d6e3 blobs = (VERTEX, PIXEL, ROOT) canonical = gfx2hlsl.pipeline_key(*blobs) check_request(blobs, canonical) diff --git a/tools/startup/gfx2hlsl.py b/tools/startup/gfx2hlsl.py index d80de8647..42a211707 100644 --- a/tools/startup/gfx2hlsl.py +++ b/tools/startup/gfx2hlsl.py @@ -9799,7 +9799,7 @@ def pipeline_key(vs_code, ps_code, root_blob, layout=b'', ps_inputs=None): SPI_PS_INPUT_ENA and SPI_PS_INPUT_ADDR as little-endian u32. Two pipelines with the same stages, root signature and input layout but different masks are then two requests with their own results. Without a description the key is unchanged.""" - key = fnv(root_blob, fnv(ps_code, fnv(vs_code, fnv(b'x2w-startup-shader-19')))) + key = fnv(root_blob, fnv(ps_code, fnv(vs_code, fnv(b'x2w-startup-shader-20')))) key = fnv(layout, key) if layout else key return key if ps_inputs is None else fnv(b'psin1' + struct.pack('