Third batch FS template to be pre-baked, after batch_untextured
(9e6f933 + b6d1903 + c01f8ae) and batch_textured_nearest
(9e4c33d + a7f5717). Adds the HLSL template + regen recipe + 144
DXBC blobs for the (texture_mode != GPUTextureMode::Disabled
AND m_texture_filter in {Bilinear, BilinearBinAlpha}) slice. No
C++ wiring yet - the activation commit lands next, mirroring the
b6d1903 / a7f5717 untextured / Nearest activation arcs.
Variant matrix (post-c532a34 TRANSPARENCY routing):
* Texture mode (6 combos via 3 -D macros):
Same encoding as batch_textured_nearest. See that template
for the (PALETTE_4_BIT, PALETTE_8_BIT, RAW_TEXTURE) tuple
mapping. PALETTE_4_BIT / PALETTE_8_BIT mutually exclusive.
* USE_DUAL_SOURCE (0/1): drives o_col1 declaration + write.
Same axis as the other batch FS templates. The Bilinear
family is always non-Nearest, so the shadergen formula's
`filter != Nearest` clause is true here; use_dual_source
is just m_supports_dual_source_blend.
* INTERP_CENTROID / INTERP_SAMPLE: interp tri-state qualifier.
Same axis as the other batch FS templates.
* NOPERSP (0/1): `noperspective` on v_col0. Same axis.
* BINALPHA (0/1): NEW axis vs Nearest. Gates the ialpha >= 0.5
quantisation step at the end of FilteredSampleFromVRAM
(BINALPHA=1 => BilinearBinAlpha enum value, BINALPHA=0 =>
standard Bilinear). The two enum values share a single
template with fxc dead-stripping the unused arm.
6 (tex_mode) x 2 (dual) x 3 (interp) x 2 (persp) x 2 (BinAlpha)
= 144 blobs. Double the Nearest count (72) because BINALPHA adds
one dimension. The MSAA axis still does NOT multiply this template
- the batch FS reads from the single-sample shadow VRAM
regardless of m_multisamples.
UV_LIMITS is implicit for all non-Nearest filters: ShouldUseUVLimits
in gpu_hw.cpp forces m_using_uv_limits true when the filter is
non-Nearest. The shader unconditionally clamps to v_uv_limits
without a runtime cbuffer gate; the Nearest template's
`if (u_uv_limits != 0u)` branch becomes dead code here and is
deleted from this template.
Without the c532a34 TRANSPARENCY routing, this template would
have been 144 x 4 = 576 variants on the [render_mode] axis. Worth
the routing commit.
Files in this commit (146 total, no C++ touched):
data/shaders/d3d_common/batch_textured_bilinear.ps.hlsl
Hand-translated mirror of shadergen's textured-Bilinear-
family output. Same shape as the Nearest template:
BatchUBOData cbuffer, Texture2D + SamplerState bindings at
register t0/s0, full ApplyDithering / ApplyTextureWindow /
ApplyUpscaledTextureWindow / FloatToIntegerCoords /
RGBA8ToRGBA5551 / SampleFromVRAM helpers. NEW vs Nearest:
FilteredSampleFromVRAM helper performing 4-tap bilinear
with VRAM-rgba-0000-sentinel handling per-corner, ialpha
weighted-coverage compensation, and the BINALPHA-gated
quantisation. The main() body's transparent-texel discard
becomes `ialpha < 0.5` (replaces the Nearest template's
all-zero discard).
tools/regen_d3d_common_dxbc.py
1. TEMPLATE_VARIANTS gains a batch_textured_bilinear.ps.hlsl
entry with all 144 variant tuples. Variant suffix
encoding: pXrY_d{0,1}_{none,centroid,sample}_n{0,1}_b{0,1}
where the b{0,1} digit encodes BINALPHA (0 = Bilinear,
1 = BilinearBinAlpha).
2. NEW: compile_one() retries fxc invocations that return
success but produce no output file. This is a wine
flakiness symptom (wineserver hangs briefly under load
when wine32 components are in transient bad state) that
only manifests during bulk regeneration on Linux
cross-compile setups. fxc.exe running natively on
Windows doesn't hit this. Up to 5 retries with a warning
to stderr on each transient miss; after 5 the script
exits with a hard error including the last stdout/stderr
for diagnosis. Hard fxc errors (HLSL syntax violations,
non-zero exit code) still fast-fail without retry. The
regenerated bytecode is identical regardless of which
attempt succeeds - fxc is deterministic on identical
source + flags.
src/common/d3d_common/embedded_dxbc/batch_textured_bilinear_ps_*.inc
144 new .inc files, ~5-8 KiB DXBC per variant (~6 KiB
average), totalling ~860 KiB on disk and ~900 KiB embedded
DXBC in the .so. Larger per-variant than the Nearest blobs
(~5500 bytes avg) because the 4-tap bilinear adds ~1 KiB of
code per variant.
What does NOT change in this commit:
- GPU_HW_D3D12::GetBatchPipeline still calls GetBatchFragmentShader
for textured non-Nearest slices (Bilinear / JINC2 / xBR),
which runs shadergen + D3DCompile. The 144 pre-baked Bilinear
blobs are not yet consulted - they sit on disk waiting for
the activation commit.
- GPU_HW_D3D11::GetBatchPixelShader still falls through to
the shadergen + D3DCompile path for non-Nearest filters
(the `else` arm at line 1349+ of gpu_hw_d3d11.cpp).
- src/common/d3d_common/embedded_shaders.{h,cpp} untouched -
they need 288 new extern declarations / includes to surface
the .inc blob symbols to the C++ linker; the activation
commit adds them along with the Bilinear-family picker.
- m_texture_filter == Bilinear / BilinearBinAlpha sessions
still go through D3DCompile on both D3D11 and D3D12 backends
until the activation commit.
Test:
- python3 tools/regen_d3d_common_dxbc.py --fxc /tmp/fxc_lite/
fxc_lite.exe --wine /usr/bin/wine: 326 .inc files generated
(182 pre-existing batch / display / vram_* / downsample +
144 new Bilinear). The new retry logic catches a handful of
transient wine misses per full regen pass; warnings appear
in stderr but the script completes.
- Hand-compile of representative variants:
no /D (p0r0_d0_none_n0_b0): 7228 bytes DXBC
/D PALETTE_4_BIT=1: 8732 bytes
/D PALETTE_4_BIT=1 /D BINALPHA=1: 8760 bytes
/D PALETTE_8_BIT=1 /D BINALPHA=1 /D RAW_TEXTURE=1
/D USE_DUAL_SOURCE=1: 7624 bytes
/D RAW_TEXTURE=1 /D INTERP_SAMPLE=1 /D NOPERSP=1
/D BINALPHA=1 /D USE_DUAL_SOURCE=1: 6120 bytes
All compile cleanly; no fxc warnings or errors on any
combination tested.
Cumulative pre-bake variant count for D3D batch FS:
Pre-arc: 75 264 (every axis a -D)
Post-cbuffer-routing arc: 1 176
Post-c01f8ae (untextured slice live, D3D12 + D3D11):
12 live
Post-a7f5717 (Nearest slice live, D3D12 + D3D11):
84 live (12 + 72)
Post-this-commit (Bilinear slice on disk): +144 baked
(consumers wired in the activation commit)
Next:
- Activation: 288 extern decls + 144 #include lines in
embedded_shaders.{h,cpp}, plus a PickBatchTexturedBilinearFS
helper in D3DCommon::EmbeddedShaders that takes the
additional `binalpha` parameter, and the
GetBatchPipeline / GetBatchPixelShader branches that route
m_texture_filter in {Bilinear, BilinearBinAlpha} +
texture_mode != Disabled to the new picker. Parallel to
a7f5717 (D3D12 Nearest activation) + 74b28be (D3D11 Nearest
activation).
- Then the remaining 2 textured filter templates (JINC2 / xBR
each with BinAlpha) as foundation + activation pairs.