From 990fc7b9661a57fd2d41928e2ce8641767b4d22d Mon Sep 17 00:00:00 2001 From: tedin7 Date: Thu, 26 Nov 2026 02:32:10 +0100 Subject: [PATCH 1/4] fix: fold s_mov_b32 copies of a constant SGPR so llc-built inline samplers translate llc builds a zero sampler as s_mov_b32 s15, 0 then s_mov_b32 s12, s15. The copy kept no symbol, so the sampler operand held None and the shader was refused. The copy now keeps the constant. Extends startup_inline_sampler_check with a copied-constant sampler control. (cherry picked from commit da03456187fe80e5bf53c800f32766df5cb02504) --- tests/startup_inline_sampler_check.py | 17 +++++++++++++++++ tools/startup/gfx2hlsl.py | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/tests/startup_inline_sampler_check.py b/tests/startup_inline_sampler_check.py index f73fe79b25..fb2145e892 100644 --- a/tests/startup_inline_sampler_check.py +++ b/tests/startup_inline_sampler_check.py @@ -74,8 +74,25 @@ def bare_stage(symbols=None): except AttributeError: pass +# llc builds a constant sampler by copying one zeroed SGPR into the other words (s_mov_b32 s25, s24). +COPY_WORDS = IMAGE_WORDS.replace( + bytes.fromhex('800398be' '800399be' '80039abe' '80039bbe'), + bytes.fromhex('800398be' '180399be' '18039abe' '18039bbe'), +) + + +def check_copied_constant_sampler(): + """A sampler word copied from a constant SGPR is that constant, not an unknown value.""" + assert COPY_WORDS != IMAGE_WORDS + expected = [l for l in translate(IMAGE_WORDS).manifest().splitlines() if l.startswith('smp ')] + got = [l for l in translate(COPY_WORDS).manifest().splitlines() if l.startswith('smp ')] + assert got == expected and got, (got, expected) + print('copied constant sampler folds to %s' % got[0]) + + def controls(): check_compare_sampler_constant() + check_copied_constant_sampler() fixtures = [] for name, code, words in ( ('clamp', CLAMP_WORDS, (0x2, 0, 0x00100000, 0)), diff --git a/tools/startup/gfx2hlsl.py b/tools/startup/gfx2hlsl.py index 061534962f..07931214d5 100644 --- a/tools/startup/gfx2hlsl.py +++ b/tools/startup/gfx2hlsl.py @@ -4284,6 +4284,14 @@ def src_sym(t): self.set_s(d + 1, '0x%08xu' % ((value >> 32) & 0xffffffff), ('const', (value >> 32) & 0xffffffff)) self.masks.discard(d) return None + if base == 's_mov_b32' and not pair and len(srcs) == 1 and reg_range(srcs[0]) and reg_range(srcs[0])[0] == 's' \ + and reg_range(srcs[0])[1] == reg_range(srcs[0])[2] and self.is_const(reg_range(srcs[0])[1]) is not None: + # A copy of an SGPR holding a known constant is that constant (llc copies a zero into an inline + # sampler word: s_mov_b32 s12, s15 after s_mov_b32 s15, 0). + value = self.is_const(reg_range(srcs[0])[1]) + self.set_s(d, '0x%08xu' % value, ('const', value)) + self.masks.discard(d) + return None if base in SCALAR_CONST_FOLD: # Constant operands give a known word, so a descriptor built from them (an inline sampler from # s_movk_i32, s_bfm_b32, s_mov_b32 and s_brev_b32 into s[N:N+3]) is a constant descriptor. From b6ad103467eb0719fcf5a2e7c0400985de9e7a42 Mon Sep 17 00:00:00 2001 From: tedin7 Date: Thu, 26 Nov 2026 02:35:40 +0100 Subject: [PATCH 2/4] fix: copy folds only a plain constant; add negative controls for copied samplers Do not fold a copy of the tagged unassigned placeholder. Tests: placeholder copy, run-time source and a copy after the source was rewritten must not fold. (cherry picked from commit cbd9717507808d3110e71c3e5e3cd735b23d27e8) --- tests/startup_inline_sampler_check.py | 48 +++++++++++++++++++++++++++ tools/startup/gfx2hlsl.py | 5 +-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/tests/startup_inline_sampler_check.py b/tests/startup_inline_sampler_check.py index fb2145e892..c8e4bee3ad 100644 --- a/tests/startup_inline_sampler_check.py +++ b/tests/startup_inline_sampler_check.py @@ -90,9 +90,57 @@ def check_copied_constant_sampler(): print('copied constant sampler folds to %s' % got[0]) +def copy_symbol(symbols, copy='s_mov_b32 s12, s15'): + """The symbol s12 holds after `copy` runs on a bare stage that starts with `symbols`.""" + class Pipe: + sampler_heap = False + + stage = G.Stage.__new__(G.Stage) + stage.pipe, stage.sym, stage.lines = Pipe(), dict(symbols), [] + stage.used_s, stage.used_v, stage.uniform_v, stage.exec_known = set(), set(), set(), True + stage.has_branches, stage.masks = False, set() + stage.one(copy.split()[0], copy) + return stage.sym.get(12) + + +def check_copy_only_folds_plain_constants(): + """Only a plain ('const', value) copies as a constant; every other source must not fold.""" + assert copy_symbol({15: ('const', 0)}) == ('const', 0) + # The default-sampler placeholder is tagged 'unassigned': a copy of it is no run-time constant. + assert copy_symbol({15: ('const', 0, 'unassigned')}) != ('const', 0) + # A register that holds a root constant or nothing known is not a constant. + assert copy_symbol({15: ('ud', 1)}) != ('const', 1) + assert copy_symbol({}) is None + # A copy after the source was overwritten takes the new value, never the old one. + assert copy_symbol({15: ('const', 7)}) == ('const', 7) + print('copies fold only plain constants') + + +def check_copied_sampler_after_overwrite(): + """A sampler word copied after its source was rewritten by a run-time value or another constant.""" + prefix = bytes.fromhex('800398be') # s_mov_b32 s24, 0 + copies = bytes.fromhex('180399be' '18039abe' '18039bbe') + anchor = prefix + copies + assert anchor in COPY_WORDS + runtime = COPY_WORDS.replace(anchor, prefix + bytes.fromhex('090398be') + copies) # s24 = s9 (root constant) + try: + translate(runtime) + except G.Unsupported as error: + assert 'holds' in str(error), error + else: + raise AssertionError('a sampler copied from a run-time register was accepted') + # s28 = 0, then s28 = 1, then s27 = s28; s24..s26 stay literal zeros + one = COPY_WORDS.replace(anchor, bytes.fromhex('800398be' '800399be' '80039abe' '80039cbe' '81039cbe' '1c039bbe')) + smp = [l for l in translate(one).manifest().splitlines() if l.startswith('smp ')] + assert smp == ['smp 0 0x0 0x0 0x0 0x1'], smp + print('copy after overwrite: run-time source refused, new constant wins (%s)' % smp[0]) + + def controls(): check_compare_sampler_constant() check_copied_constant_sampler() + check_copy_only_folds_plain_constants() + check_copied_sampler_after_overwrite() fixtures = [] for name, code, words in ( ('clamp', CLAMP_WORDS, (0x2, 0, 0x00100000, 0)), diff --git a/tools/startup/gfx2hlsl.py b/tools/startup/gfx2hlsl.py index 07931214d5..7baede5aa0 100644 --- a/tools/startup/gfx2hlsl.py +++ b/tools/startup/gfx2hlsl.py @@ -4285,8 +4285,9 @@ def src_sym(t): self.masks.discard(d) return None if base == 's_mov_b32' and not pair and len(srcs) == 1 and reg_range(srcs[0]) and reg_range(srcs[0])[0] == 's' \ - and reg_range(srcs[0])[1] == reg_range(srcs[0])[2] and self.is_const(reg_range(srcs[0])[1]) is not None: - # A copy of an SGPR holding a known constant is that constant (llc copies a zero into an inline + and reg_range(srcs[0])[1] == reg_range(srcs[0])[2] and len(self.sym.get(reg_range(srcs[0])[1]) or ()) == 2 \ + and self.is_const(reg_range(srcs[0])[1]) is not None: + # A copy of an SGPR holding a plain known constant (not the tagged unassigned placeholder) is that constant (llc copies a zero into an inline # sampler word: s_mov_b32 s12, s15 after s_mov_b32 s15, 0). value = self.is_const(reg_range(srcs[0])[1]) self.set_s(d, '0x%08xu' % value, ('const', value)) From a52f1d75e6223a3a29beb627ffa06b35a07c14a7 Mon Sep 17 00:00:00 2001 From: tedin7 Date: Thu, 26 Nov 2026 04:33:13 +0100 Subject: [PATCH 3/4] test: draw the copied-constant inline sampler and its wrong-value control check_draw now also draws a shader whose sampler word 0 is built in s29 and copied into s24; it must read the clamped texel with its own sampler and mismatch with the wrap sampler. --- tests/startup_inline_sampler_check.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/startup_inline_sampler_check.py b/tests/startup_inline_sampler_check.py index c8e4bee3ad..7077e31fbb 100644 --- a/tests/startup_inline_sampler_check.py +++ b/tests/startup_inline_sampler_check.py @@ -35,6 +35,11 @@ WRAP_SOURCE = CLAMP_SOURCE.replace('s_bfm_b32 s24, s28, 33', 's_bfm_b32 s24, 0, 33') WRAP_WORDS = CLAMP_WORDS.replace(bytes.fromhex('1ca11892'), bytes.fromhex('80a11892')) +# The clamp sampler with word 0 built in s29 and copied into s24 (s_mov_b32 s24, s29): only the copy fold lets +# the four words be read as constants, so the draw below depends on it. +COPY_CLAMP_SOURCE = CLAMP_SOURCE.replace('s_bfm_b32 s24, s28, 33', 's_bfm_b32 s29, s28, 33\ns_mov_b32 s24, s29') +COPY_CLAMP_WORDS = CLAMP_WORDS.replace(bytes.fromhex('1ca11892'), bytes.fromhex('1ca11d92' '1d0398be')) + # s9 is root constant 1. Overwrite a previously folded word to check that the # run-time write clears its constant value before the sampler is consumed. DYNAMIC_SOURCE = CLAMP_SOURCE.replace('v_mov_b32 v0,', 's_bfm_b32 s24, s9, 33\nv_mov_b32 v0,') @@ -145,6 +150,7 @@ def controls(): for name, code, words in ( ('clamp', CLAMP_WORDS, (0x2, 0, 0x00100000, 0)), ('wrap', WRAP_WORDS, (0, 0, 0x00100000, 0)), + ('copied clamp', COPY_CLAMP_WORDS, (0x2, 0, 0x00100000, 0)), ): pipe = translate(code) manifest = pipe.manifest() @@ -163,8 +169,9 @@ def controls(): print('root-constant mask width: inline sampler refused (%s)' % error) else: raise AssertionError('run-time write to s24 was accepted as an inline sampler') - (clamp_ps, clamp_line), (_, wrap_line) = fixtures - return clamp_ps, clamp_line, wrap_line + (clamp_ps, clamp_line), (_, wrap_line), (copy_ps, copy_line) = fixtures + assert copy_line == clamp_line, (copy_line, clamp_line) + return clamp_ps, clamp_line, wrap_line, copy_ps def check_binary(llvm_mc): @@ -172,14 +179,15 @@ def check_binary(llvm_mc): ('clamp', CLAMP_SOURCE, CLAMP_WORDS), ('wrap', WRAP_SOURCE, WRAP_WORDS), ('root constant', DYNAMIC_SOURCE, DYNAMIC_WORDS), + ('copied clamp', COPY_CLAMP_SOURCE, COPY_CLAMP_WORDS), ): built = assemble(llvm_mc, source) assert built == recorded, '%s: assembled %s, recorded %s' % (name, built.hex(), recorded.hex()) - print('all three fixture programs match llvm-mc') + print('all four fixture programs match llvm-mc') def check_draw(dxc, renderer, adapter, fxc=None): - ps, clamp, wrap = controls() + ps, clamp, wrap, copy_ps = controls() expected_clamp = texel(1, 0, 0) expected_wrap = texel(0, 0, 0) compilers = [('dxc', dxc, 'vs_6_0', 'ps_6_0')] @@ -194,9 +202,13 @@ def check_draw(dxc, renderer, adapter, fxc=None): for kind, compiler, vs_profile, ps_profile in compilers: vs = compile_hlsl(compiler, kind, FULLSCREEN_VS, 'fullscreen', vs_profile, directory) shader = compile_hlsl(compiler, kind, ps, 'inline_sampler', ps_profile, directory) - command = [renderer, adapter, '--startup-image-3d', str(vs), str(shader), '0.25', expected_clamp] - # Hold shader, texture, and reference fixed. Only the manifest sampler changes. - for label, line, result in (('clamp', clamp, 0), ('wrap control', wrap, 1)): + copy_shader = compile_hlsl(compiler, kind, copy_ps, 'inline_sampler_copy', ps_profile, directory) + # Hold shader, texture, and reference fixed. Only the manifest sampler changes. The copied-word shader + # is drawn with its own sampler (must read the clamped texel) and with the wrap sampler (must mismatch). + for label, shader_path, line, result in (('clamp', shader, clamp, 0), ('wrap control', shader, wrap, 1), + ('copied-word clamp', copy_shader, clamp, 0), + ('copied-word wrap control', copy_shader, wrap, 1)): + command = [renderer, adapter, '--startup-image-3d', str(vs), str(shader_path), '0.25', expected_clamp] run = subprocess.run([*command, line], capture_output=True, text=True) print(run.stdout, end='', flush=True) if run.returncode == 77: From 2381d5c69681d7d81c6244f3c9ecf4c79680d284 Mon Sep 17 00:00:00 2001 From: c1 Date: Thu, 26 Nov 2026 06:55:12 +0100 Subject: [PATCH 4/4] fix: bump shader cache revision to 19 for the constant-copy fold, pin run-time write and join --- .github/workflows/windows.yml | 1 + AGENTS.md | 1 + CMakeLists.txt | 3 + docs/startup-runtime.md | 9 +- src/startup_stubs/d3d12_draw.inl | 4 +- .../startup_compute_request_offline_check.py | 4 +- tests/startup_gfx2hlsl_buffer_store_check.py | 4 +- .../startup_gfx2hlsl_const_copy_join_check.py | 96 +++++++++++++++++++ tests/startup_gfx2hlsl_fract_check.py | 4 +- tests/startup_indirect_draw_indexed.cpp | 2 +- tests/startup_inline_sampler_check.py | 2 +- ...tartup_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 +- 15 files changed, 124 insertions(+), 20 deletions(-) create mode 100644 tests/startup_gfx2hlsl_const_copy_join_check.py diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index cb71ae8c54..cc8fab1cf2 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -361,6 +361,7 @@ jobs: tests/startup_gfx2hlsl_sad_check.py \ tests/startup_gfx2hlsl_sad_hi_msad_check.py \ tests/startup_gfx2hlsl_scalar_brev_fold_check.py \ + tests/startup_gfx2hlsl_const_copy_join_check.py \ tests/startup_gfx2hlsl_s_bit_scan_check.py \ tests/startup_gfx2hlsl_pack_b32_f16_check.py \ tests/startup_inline_sampler_check.py \ diff --git a/AGENTS.md b/AGENTS.md index 402377e163..efc6cea3a4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -267,6 +267,7 @@ python3 -m venv out/pe-env ./out/pe-env/bin/python -B tests/startup_gfx2hlsl_f32_nan_check.py ./out/pe-env/bin/python -B tests/startup_gfx2hlsl_sopk_signext_check.py ./out/pe-env/bin/python -B tests/startup_gfx2hlsl_scalar_brev_fold_check.py +./out/pe-env/bin/python -B tests/startup_gfx2hlsl_const_copy_join_check.py ./out/pe-env/bin/python -B tests/startup_gfx2hlsl_pack_b32_f16_check.py ./out/pe-env/bin/python -B tests/run_checks_parallel_check.py ./out/pe-env/bin/python -B tests/startup_gfx2hlsl_handler_arity_check.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 01038e677d..1d62b82765 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3494,6 +3494,9 @@ if(EXISTS "${INTAKE_PYTHON}") # s_brev_b32 of a known constant folds to a known word (a sampler built from it is a constant descriptor). add_test(NAME startup_gfx2hlsl_scalar_brev_fold COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_scalar_brev_fold_check.py") + # A copy of a plain constant scalar register still assigns at run time and drops its constant at a join. + add_test(NAME startup_gfx2hlsl_const_copy_join COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_const_copy_join_check.py") # v_pack_b32_f16 with op_sel and the neg/abs source modifiers, evaluated against a bit reference. add_test(NAME startup_gfx2hlsl_pack_b32_f16 COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_pack_b32_f16_check.py") diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 4ca94467df..d9dc52ac57 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -208,9 +208,12 @@ 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-18`. Revision 18 preserves the sign of zero in -floating-point min, max, min3, max3 and med3. The matching compute (`x2w-startup-shader-18cs`) and fixed -slot 57 mesh (`x2w-startup-mesh-57-3`) keys advance because those stages use the shared lowering. +The shader cache revision is `x2w-startup-shader-19`. 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-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. Revisions before 17 lower `v_med3_f32` through a branchless median, which returns the smaller of the other two operands when a source is NaN. Revisions before 16 lower `v_fract_f32` through a bare `frac` instead of the clamped `fract32` helper. diff --git a/src/startup_stubs/d3d12_draw.inl b/src/startup_stubs/d3d12_draw.inl index f40b9f42cf..0ebeb4580c 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-18"; + constexpr char revision[] = "x2w-startup-shader-19"; 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-18cs"; // tools/startup/gfx2hlsl.py compute_key + constexpr char compute_revision[] = "x2w-startup-shader-19cs"; // 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_compute_request_offline_check.py b/tests/startup_compute_request_offline_check.py index f2f0299a82..a834a0762a 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 = 0x375fa7c3f8f4a3dd # framed key at revision 18cs +KEY = 0x63ac0aa21c46da1c # framed key at revision 19cs def framed_key(): h = 1469598103934665603 - for b in b'x2w-startup-shader-18cs': + for b in b'x2w-startup-shader-19cs': 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-18"; + constexpr char revision[] = "x2w-startup-shader-19"; 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_inline_sampler_check.py b/tests/startup_inline_sampler_check.py index 7077e31fbb..c0c7003201 100644 --- a/tests/startup_inline_sampler_check.py +++ b/tests/startup_inline_sampler_check.py @@ -116,7 +116,7 @@ def check_copy_only_folds_plain_constants(): # A register that holds a root constant or nothing known is not a constant. assert copy_symbol({15: ('ud', 1)}) != ('const', 1) assert copy_symbol({}) is None - # A copy after the source was overwritten takes the new value, never the old one. + # A copy of a plain constant takes that constant's value. assert copy_symbol({15: ('const', 7)}) == ('const', 7) print('copies fold only plain constants') diff --git a/tests/startup_packed_position_provenance_check.py b/tests/startup_packed_position_provenance_check.py index bd848f3db7..fea8cc816f 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-18'))))) + bare == G.fnv(root_blob(), G.fnv(ps_words(4), G.fnv(VS_WORDS, G.fnv(b'x2w-startup-shader-19'))))) 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 05f8f0a382..24c80d3b0f 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-18"; // d3d12_draw.inl cached_translation +constexpr char draw_revision[] = "x2w-startup-shader-19"; // 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 8de3958200..a0d27d5254 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-18 excludes NUL. Stored order is a, b, root, then optional input layout. + # Revision x2w-startup-shader-19 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) == 0x8d1cb58fb148b30a - assert gfx2hlsl.pipeline_key(*vector, b"ia\x00\xfe") == 0xf9e74efdcb8283d2 + assert gfx2hlsl.pipeline_key(*vector) == 0xf3444b13fe09b4df + assert gfx2hlsl.pipeline_key(*vector, b"ia\x00\xfe") == 0x2039e248f9cad09f 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 38bb69bfae..259273ae22 100644 --- a/tools/startup/gfx2hlsl.py +++ b/tools/startup/gfx2hlsl.py @@ -9356,7 +9356,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-18')))) + key = fnv(root_blob, fnv(ps_code, fnv(vs_code, fnv(b'x2w-startup-shader-19')))) key = fnv(layout, key) if layout else key return key if ps_inputs is None else fnv(b'psin1' + struct.pack('