textures: sample CPU-uploaded RGBA8 and BC7 textures from the shim-startup EXE entry #808
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/814"
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 yummancito on 2026-11-23T07:24:50Z.
Summary
The shim-startup EXE already renders a triangle (#560), reuses a compute-written
texture across three draws (#705) and runs the translated compute -> mesh -> pixel
chain (#682). None of those exercise a texture whose texels are uploaded from the
CPU. This PR adds that path, driven from the same EXE entry and compared byte for
byte across the native EXE, the
pe_mapmapped image and the AOT-recompiled EXE.Advances the EXE-entry raster milestone; no issue is closed.
What it adds
tests/cpu/shim_tex_gpu.cpp,tests/tex_quad.hlsl: a vertex-buffer quad (POSITION +TEXCOORD) sampling an 8x8 texture through an SRV with a point-clamp static sampler.
The texture is created in a DEFAULT heap, filled through an UPLOAD staging buffer
(placed footprints), transitioned to
PIXEL_SHADER_RESOURCE, and read back with afence wait.
R8G8B8A8_UNORM(original asymmetric rule, 64/64 distinct texels) andBC7_UNORM(the repository's mode-6 block builder and the 4 KiB standard-swizzletiled-to-linear conversion from
tests/bc7_draw_check.py).tests/cpu/tex_gen.py: single source of truth for the texel tables and every CPUreference frame; it also emits the header the provider embeds.
tests/cpu/shim_tex_check.pyand ctestcpu_shim_upload_texture_{warp,hardware}.tex,texuv,texbad,bc7,scene) inshim_startup.asm/shim_draw_provider.cpp. Existing requests 1-13 are untouched.cpu: share the shim draw device selection in a header) is a no-behaviorrefactor: the new texture fixture needs the same WARP/hardware selection and the 77
capability skip as
shim_draw_gpu.cpp, and moving the existing helpers intoshim_gpu_device.havoids two copies that could drift. The existing draw tests areunchanged and still pass.
Cases
tex8f9271e5)bc7b2d756a4)scened54d504f)texuv85aac638) and differ from the exact frametexbadba7ee0ab) and differ from the exact frameEvery case must also agree across the three runners, publish a full 16,384-byte frame,
show no extra diagnostics, and keep the startup output unchanged.
Difference from upstream
cpu_shim_texture_reuse_*(#705) writes anR32_UINTtexture from a compute dispatch.This fixture uploads texels from the CPU, uses real vertex data with UVs, covers a
block-compressed format, and has negative controls for the sampling coordinates and for
the upload contents. I found no open PR covering this (checked #613, #522, #506, which
touch other files).
Evidence
Commits under test:
774e6df,70d34e9onupstream/maina81b55a(rebased once to resolve conflicts in
CMakeLists.txtandshim_startup.asmwith thenew shadow draw modes 14-16; my modes 20-24 do not overlap them).
Environment: Windows 11 Pro 10.0.26300, MSVC 19.44.35228, DXC from Vulkan SDK 1.4.363.0.
Hardware adapter: NVIDIA GeForce RTX 5060, driver 621.14 (UMD 32.0.16.2114), LUID 0xc90c.
Software adapter: Microsoft Basic Render Driver, LUID 0x1071b. Debug layer unavailable.
Both presets were configured with
--freshand built from scratch with no extra cache arguments.^cpu_Root signature, texture, shader, PE and memory groups (
desktop_root_signature,era_heap,desktop_memory_query,offscreen_warp,bcpack_*,bc7_*,pixel_aot_*,static_exe_intake,conditional_import_paths,script_*): 73/77 passin each preset, with the same four non-passing tests in dev and release:
pixel_aot_e64_approx_hardware(introduced by #729) andpixel_aot_sdwa_unary_hardwarefail with
E_OUTOFMEMORY(HRESULT 0x8007000E) when creating the translated pixelpipeline on my RTX 5060. Both fail identically on unmodified
upstream/maina81b55aon the same machine (verified by checking out
upstream/maindetached, rebuilding andrunning them), so they are not caused by this PR. I did not touch those tests and did not
open an issue; the only related open issue I found (#312) is about denormal modes, not
this error.
pixel_aot_hardwareandpixel_aot_predicate_rounding_hardwarehit the default 60 sCTest timeout when the area group runs with
-j 4. Run alone with a longer timeout theypass (48-57 s; on unmodified
upstream/mainpredicate_roundingalso takes about 54 s),so they are slow rather than broken, and neither involves files changed here.
Adapter identification: a temporary, uncommitted print in
shim_create_deviceshowed thedevice actually created. With
X2W_SHIM_DRAW_ADAPTER=hardware, casestex,bc7,sceneand
texbadall created the RTX 5060; withwarpall created the Basic Render Driver.Negative-control mutations (each applied to the fixture, rebuilt, and run; each must fail):
no corruption, no UV shift, damaged BC7 block, no SRV rebind in
scene, skipped upload,linear sampler. All six made
cpu_shim_upload_texture_warpfail. Removing the corruptionfails with
texbad native exits: expected 20, got 42; removing the shift fails withtexuv native exits: expected 20, got 42.Bug found and fixed while preparing this
The first version of the staging copy iterated
Footprint.Heightrows. For BC7 that is 8texel rows while only 2 block rows exist (
rows=2,row_bytes=32), so it read 256 bytesfrom a 64-byte table and wrote past the staging buffer. The copy now uses
NumRowsandRowSizeInBytesfromGetCopyableFootprints, andfill_stagingthrows unlessrows * row_bytesequals the source table size exactly and the last row ends inside thestaging buffer. Reintroducing the old row count makes
bc7fail withstaging geometry mismatch: rows=8 ... table_bytes=64.Known risks and limitations
other BC7 modes, arrays or cube maps.
decoder; the GPU decode is the independent side of the comparison.
Files
CMakeLists.txt,README.md,docs/experiments.md,tests/cpu/shim_draw_gpu.cpp,tests/cpu/shim_draw_provider.cpp,tests/cpu/shim_gpu_device.h(new),tests/cpu/shim_startup.asm,tests/cpu/shim_tex_check.py(new),tests/cpu/shim_tex_gpu.cpp(new),tests/cpu/tex_gen.py(new),tests/tex_quad.hlsl(new).817 insertions, 43 deletions.
🤖 Generated with Claude Code