startup: lower D16 image_load_mip in gfx2hlsl #2567
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2575"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by consolelogkyo on 2026-11-25T21:31:26Z.
Summary
Extend the D16 MIMG load lowering in
tools/startup/gfx2hlsl.py(#2139) from level-zeroimage_loadto explicit-mipimage_load_mipon 2D, 3D and 2D-array resources:tools/startup/gfx2hlsl.py): Acceptd16alongsideunorm,glc,slcanddlconimage_load_mip(Texture2D<float4>.Load(int3(x, y, mip))andTexture2DArray<float4>/Texture3D<float4>.Load(int4(x, y, slice_or_z, mip))), including non-sequential address (NSA) register lists and both vertex and pixel stages.pack16_d16(pack16_rne+ exactpack16_unorm16selected per SRV viaudsrc <ud> d16unorm16 <index>),d16srv <index> exactmanifest gating against the 14 GPU-verified exact DXGI formats (src/startup_stubs/d16_image_format.h), and odd-dmasklow-16-bit provenance tracking (low16_only_v).tests/startup_image_3d.cpp,tests/offscreen_check.cpp,tests/startup_image_load_d16_check.py,tests/startup_image_load_mip_check.py,tests/startup_image_2d_array_check.py): Extendoffscreen_check --startup-image-load-d16(r16_unorm[_array],rgba32f[_array]) to two-mip (8x2mip 0 +4x1mip 1, including0xffafand0xffefdouble-rounding discriminators on mip 1) 2D and two-slice 2D-array textures, adding explicit-mip fixtures C (2D) and D (2D-array), odd-dmaskupper-half poison checks, and six new GPU negative-control mutations (mip_zero,mip_drop_nsa,mip_rtz,mip_double_round,swap_slice_mip,array_drop_nsa).Scope & Refusals
a16,tfe,lwe,r128, set reserved MIMG bits,dmask:0x0, 1D and cube dimensions, compute-staged16image loads, non-exact bound SRV formats, whole-word reads after odd-dmaskD16 loads (including passing an odd-dmaskVGPR as aLoadcoordinate), and mismatched destination or address register widths remain refused.Verification
Verified on rebased
origin/main(381abc31) on Windows 11 26H2 across:Microsoft Basic Render Driver(1414:008c, driver10.0.26100.9818),debug_layer=enabled,debug_errors=0 debug_warnings=0AMD Radeon RX 9070 XT(1002:7550, driver32.0.32029.2010),debug_layer=enabled,debug_errors=0 debug_warnings=0vs_6_0/ps_6_0) and FXC (vs_5_1/ps_5_1)Results:
image_load_mipacross mips 0 and 1) and D (2D-arrayimage_load_mipacross slices 0..1 and mips 0..1) match all 64 readback words per draw onR16_UNORMandR32G32B32A32_FLOAT2D and 2D-array textures under both DXC and FXC, and stay bit-identical when0xdead0000is injected into bits31:16of odd-dmaskregisters.mip_zero,mip_drop_nsa,mip_rtz,mip_double_round,swap_slice_mip,array_drop_nsa) fail against the reference words (returncode == 1) and match their corresponding mutated CPU models (returncode == 0) on both WARP and Radeon RX 9070 XT under DXC and FXC.ctestpassedstartup_image_load_d16_{controls,warp,hardware},startup_image_load_mip_{controls,warp,hardware},startup_image_2d_array_{controls,warp,hardware},startup_d16_srv_{warp,hardware},startup_d16_image_format,startup_translator, and all 76startup_gfx2hlsl_*control tests.llvm-mc-15(binary) andlibLLVM-15.so.1(decode) steps (covered bydisasm_rdna2round-trip checks locally and by GitHub Actions Linux CI).Part of #2023
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:37:12Z.
Review: COMMENTED
Review of head
28e58482(comment only, no approval).Result: sound. No blocking findings.
What I checked
tools/startup/gfx2hlsl.py: the change is small.image_load_mipnow takesd16through the same checks asimage_load(destination width, SRV format list,pack16_d16narrowing, odd-dmask low-16 tracking). The refusal text now names the real instruction. The 14 exact SRV formats still matchd16_image_format.h.startup_image_load_d16_check.pynow covers all 15 dmasks for load and load_mip, 2D / NSA / 3D / 2D-array, VS and PS, and the mip 1 double-rounding cases. The GPU readback path (offscreen_check --startup-image-load-d16) now has 2-mip and 2-slice fixtures with the CPU reference.loadpath,startup_image_load_mip_check.pyandstartup_image_2d_array_check.pystill pass unchanged in behavior. No duplicate PR: #2139 (level-zero d16) is merged, #2119 is closed.Commands run in a clean worktree on this head
python3 -B tests/startup_image_load_d16_check.py,tests/startup_image_load_mip_check.py,tests/startup_image_2d_array_check.py: passpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: cleanpacked_d16limited back toloadonly: d16 check failsload: d16 check failsD16_UNORM16_SRV_FORMATS: d16 check failsThe D3D12 GPU readback part is covered by the Win2025 WARP run, which I will post separately.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T21:33:54Z.
Seven mutations of the D16 path, all caught — and the refusal text naming the instruction is now enforced too
Control modes run clean here, device-free
That last line is a good sign on its own: the 2D-array fixture carries seven mutants that each read a different cell of a
42-cell model, so the model is checked against itself rather than against a hand-written expectation.
Mutations of
tools/startup/gfx2hlsl.pypacked_d16reverts tohow == 'load'onlyhow == 'load'op_namepinned to'image_load'(refusal misnames the instruction)D16_EXACT_SRV_FORMATSmembership check removedexpected_dstloses the+ 1) // 2roundingmippinned to'0'(load_mip reads mip 0 regardless)The third one is the one I would not have expected to be caught, and it is worth saying why that matters: pinning
op_namechanges only the text of a refusal, not whether it refuses. The d16 check catches it, so the fixtureasserts that a refusal names the instruction it came from. That is exactly the convention you asked for when the
gfx2hlslscalar-table guard went in, and it is now enforced on this path as well — a reader ofUnsupported: image_load d16 destination …can no longer be looking at aload_mipthat mislabelled itself.The last one is the substantive risk of the change —
load_mipexists to read a mip level, and pinning it to zero wouldleave every non-zero-level load silently reading level 0 — and it is caught by all three, including the 42-cell model.
Worth noting on proportions
13 lines of production change against 480 lines of fixture is the right ratio for a change whose claim is "this
instruction now lowers correctly on the device". I ran only the control modes here; the GPU half (
offscreen_check,startup_image_3d) I did not rebuild, so I am not claiming anything about the hardware result —docs/experiments.mdbeing updated alongside suggests you have it.
Reminder in case it bites you:
tools/startup/gfx2hlsl.pyis CRLF, so any patch script needs theread-
\r\n→\n, patch, write-back-\r\ndance. A\nanchor silently never matches.AI-assisted; pure Python, Windows 11 build 26300, no build or GPU for the rows above.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:51:54Z.
Win2025 WARP receipt for head
e789d443after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
e789d443b67d6218163844353a10ddfb8ad1f414:--preset dev):cmake --build --preset dev --target cpu_placed_dxr_provider cpu_shim_draw d3d12_xs_device_obj d3d12_xs_shim d3d12x_compute_list_check d3d12x_desktop_gpu_obj d3d12x_graphics_list_check offscreen_check rcas_coordinate_readback startup_buffer_format_word3_check startup_dump_fence_check startup_indirect_dispatch startup_indirect_draw_indexed startup_list_queries startup_nv12_draw startup_plane_refresh xmem_section_lease_check -- -j 2):6.14s(configure0.00s)ctest --preset dev -R 'startup_image_load_d16|startup_image_load_mip|startup_image_2d_array' --parallel 2 --no-tests=error --output-on-failure): 9/9 passed (35.53s:startup_image_2d_array_hardware9.16s,startup_image_2d_array_warp7.71s,startup_image_load_d16_warp17.88s,startup_image_2d_array_controls0.27s,startup_image_load_d16_controls1.46s,startup_image_load_mip_controls0.15s,startup_image_load_mip_warp0.44s,startup_image_load_mip_hardware0.43s,startup_image_load_d16_hardware16.68s)/O2(--preset release):cmake --build --preset release --target cpu_placed_dxr_provider cpu_shim_draw d3d12_xs_device_obj d3d12_xs_shim d3d12x_compute_list_check d3d12x_desktop_gpu_obj d3d12x_graphics_list_check offscreen_check rcas_coordinate_readback startup_buffer_format_word3_check startup_dump_fence_check startup_indirect_dispatch startup_indirect_draw_indexed startup_list_queries startup_nv12_draw startup_plane_refresh xmem_section_lease_check -- -j 2):35.54s(configure0.00s)ctest --preset release -R 'startup_image_load_d16|startup_image_load_mip|startup_image_2d_array' --parallel 2 --no-tests=error --output-on-failure): 9/9 passed (30.90s:startup_image_2d_array_hardware10.80s,startup_image_2d_array_warp7.02s,startup_image_load_d16_warp17.97s,startup_image_2d_array_controls0.24s,startup_image_load_mip_warp0.33s,startup_image_load_mip_controls0.12s,startup_image_load_d16_controls1.03s,startup_image_load_mip_hardware0.34s,startup_image_load_d16_hardware11.84s)tests/mesh_heap_sampler_check.pyok (1.2s),tests/startup_buffer_address_check.pyok (0.7s),tests/startup_buffer_format_word3_table_check.pyok (0.1s),tests/startup_compute_request_offline_check.pyok (0.8s),tests/startup_compute_translate_check.pyok (0.4s),tests/startup_flat_param_check.pyok (0.2s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.2s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.3s),tests/startup_gfx2hlsl_bit_alu_check.pyok (1.1s),tests/startup_gfx2hlsl_capture_check.pyok (1.4s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.4s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.6s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyok (0.3s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.9s),tests/startup_gfx2hlsl_f32_nan_check.pyok (9.2s),tests/startup_gfx2hlsl_fma_mix_check.pyok (0.2s),tests/startup_gfx2hlsl_getpc_refusal_check.pyok (0.2s),tests/startup_gfx2hlsl_handler_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_image_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_image_get_lod_check.pyok (0.2s),tests/startup_gfx2hlsl_int_med3_check.pyok (0.2s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.5s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.2s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.2s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.6s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (9.1s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (1.7s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (2.2s),tests/startup_gfx2hlsl_refusals_check.pyok (1.4s),tests/startup_gfx2hlsl_root_check.pyok (1.5s),tests/startup_gfx2hlsl_sad_check.pyok (0.8s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.5s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.6s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.6s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.5s),tests/startup_gfx2hlsl_shift64_check.pyok (0.4s),tests/startup_gfx2hlsl_sload_const_offset_check.pyok (0.2s),tests/startup_gfx2hlsl_smem_offset_check.pyok (0.3s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (8.3s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (0.8s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.1s),tests/startup_gfx2hlsl_swap_check.pyok (0.3s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (4.2s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (2.5s),tests/startup_image_2d_array_check.pyok (0.2s),tests/startup_image_3d_check.pyok (0.1s),tests/startup_image_gather_lz_check.pyok (0.6s),tests/startup_image_load_d16_check.pyok (0.8s),tests/startup_image_load_mip_check.pyok (0.1s),tests/startup_image_sample_a16_check.pyok (0.2s),tests/startup_image_sample_b_check.pyok (0.2s),tests/startup_image_sample_c_check.pyok (0.2s),tests/startup_image_sample_l_check.pyok (0.2s),tests/startup_image_sample_lod_check.pyok (0.6s),tests/startup_inline_sampler_check.pyok (0.2s),tests/startup_mesh57_skeleton_check.pyok (0.3s),tests/startup_run_ps1_check.pyok (12.5s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.1s),tests/startup_shader_cache_rekey_check.pyok (2.6s),tests/startup_smem_address_check.pyok (0.2s),tests/startup_stream_fetch_check.pyok (0.4s),tests/startup_stream_interface_check.pyok (0.4s),tests/startup_translator_check.pyok (0.7s)sccache: 113/-4 hits; wall163.5sAI-assisted; commands listed were executed locally.