Second attempt at the cd971cd / da20f5b pre-bake, now with the
Microsoft fxc toolchain in place (09ca0dc). Same shadergen +
runtime changes as the reverted cd971cd; the only material
difference is that the .inc files are produced by Microsoft's
D3DCompile API instead of Wine's vkd3d-shader reimplementation,
which means the DXBC has the SHEX + STAT chunks that
CreateGraphicsPipelineState validation needs.
Output deltas vs the failed cd971cd attempt:
vram_copy_ps_pgxp0.inc 3108B (vkd3d) -> 1908B (Microsoft)
vram_copy_ps_pgxp1.inc 2984B (vkd3d) -> 1828B (Microsoft)
Microsoft's compiler produces smaller bytecode (better optimization
at /O3) and emits the full chunk set RDEF/ISGN/OSGN/SHEX/STAT,
where vkd3d-shader was emitting only ISGN/OSGN/RDEF/SHDR. The
SHEX chunk in particular is what changes here - it's the Shader
Model 5.0+ extended bytecode format that D3D12 PSO validation
expects for SM 5.0 shaders. SHDR is the older SM 4.0 format;
Microsoft D3D12 accepts SHDR for simple shaders by coincidence
of how the validator is structured, but rejects it for anything
with SV_Depth + discard + non-trivial cbuffer (the threshold
case cd971cd hit). SHEX-format output passes uniformly.
Validator confirmation:
Both .inc files stamp creator string
"Microsoft (R) HLSL Shader Compiler 10.1"; the
check_microsoft_creator hook in tools/regen_d3d12_dxbc.py
(ebd2300) passes them.
This restores the full set of changes that cd971cd shipped:
* data/shaders/d3d12/vram_copy.ps.hlsl - standalone HLSL source
matching GenerateVRAMCopyFragmentShader's D3D12 output. Cbuffer
layout member-for-member identical to VRAMCopyUBOData (48 bytes
- u_src_coords, u_dst_coords, u_end_coords, u_size,
u_set_mask_bit, u_depth_value, u_resolution_scale, u_pad0).
VRAM_SIZE alias inlined. PGXP_DEPTH branch in body controls
the o_depth assignment.
* tools/regen_d3d12_dxbc.py TEMPLATE_VARIANTS dict gains the
vram_copy.ps.hlsl entry with two rows (pgxp0, pgxp1).
* src/common/d3d12/embedded_shaders.h gains extern declarations
for k_vram_copy_ps_pgxp0[], _pgxp1[], and the matching
_size_bytes constants.
* src/common/d3d12/embedded_shaders.cpp gains two #include
lines inside namespace D3D12::EmbeddedShaders for the new
.inc files.
* src/core/gpu_hw_d3d12.cpp GetVRAMCopyPipeline: shadergen call
+ m_shader_cache.GetPixelShader path replaced with an inline
D3D12_SHADER_BYTECODE picked via m_pgxp_depth_buffer. PSO
build downstream is unchanged. The m_shadergen-not-yet-built
check is dropped for this path since the embedded blob is
statically linked.
Variant axis: PGXP_DEPTH only (2 blobs, ~3.7 KB total). Resolution
scale is cbuffer-routed since e56d4d4 so it's not a variant; MSAA
isn't a variant since vram_copy never runs in MSAA mode (texture
binding conflict on the source view).
Cost matrix delta (D3D12 specifically) for vram_copy_ps:
Cold-flip PGXP toggle: ~50 ms x 2 D3DCompile + ~10 ms x 2 PSO
-> ~10 ms x 2 PSO only.
Disk-cache-warm: ~1 ms each -> 0 ms.
Resolution scale: 0 ms (already cbuffer-routed).
Test:
- Build: D3D12 backend links without unresolved symbols.
- Runtime: FF7 menu navigation (heavy VRAM-copy traffic for
menu sprite composition) and Tekken 3 round transitions
(every-frame VRAM-copy splat for round number / TOTAL DMG
text) render correctly. Failure mode if the .inc were wrong:
visible sprite / text garble within a second of entering
a menu or starting a round. Since cd971cd's failure mode
was "D3D12 backend never inits", the success signal is
simply that the backend comes up at all - the cd971cd
log line "CreateGraphicsPipelineState failed: 80004005"
no longer fires.
- PGXP toggle: flip the "PGXP CPU mode" core option; the
first flip rebuilds PSOs picking blob[1] vs blob[0] and
renders correctly. Subsequent same-direction flips hit the
PSO cache.
- Resolution scale toggle 1x <-> 4x: no PSO recompile (the
blob is scale-independent post-e56d4d4); CopyVRAM next
frame pushes a different u_resolution_scale value through
the cbuffer.
If this attempt also fails, the diff to look at is the .inc bytes
themselves (Microsoft-compiled, full chunk set) vs cd971cd's
.inc (vkd3d-shader-compiled, missing SHEX/STAT). Anything else
in the source is identical.
Next on the pre-bake side per the same template now that
the toolchain is trusted: vram_write_ps (4 variants: PGXP x
use_ssbo), vram_fill_ps (8 variants, no scale-refactor needed),
vram_update_depth_ps (2 MSAA variants - first MSAA texture-binding
variant exercise).