core/d3d12: wire the textured Nearest batch FS pre-bake into the PSO path

Activates the 72 pre-baked DXBC blobs from 9e4c33d ("core/d3d12:
pre-bake the textured Nearest batch FS slice"). The data + recipe
landed there; this commit makes the runtime actually consume
them, eliminating D3DCompile from the textured-Nearest slice of
GPU_HW_D3D12::GetBatchPipeline.

What changes:

  src/common/d3d12/embedded_shaders.h
    144 new extern declarations covering the 72
    batch_textured_nearest_ps_* blobs (uint8_t array + size_t
    pair per blob). Section comment documents the variant axes
    + the runtime-selection mapping that the call site in
    gpu_hw_d3d12.cpp performs.

  src/common/d3d12/embedded_shaders.cpp
    72 new #include lines pulling in the .inc files inside the
    namespace block. Same convention as the existing batch
    untextured + non-batch helper blobs.

  src/core/gpu_hw_d3d12.cpp
    1. New file-local helper PickBatchTexturedNearestFSBytecode
       in the anonymous namespace right after
       PickBatchUntexturedFSBytecode. Takes 5 inputs
       (lookup_mode + 4 session-level flags), returns the
       matching D3D12_SHADER_BYTECODE from a static 4-D table
       [6][2][3][2] indexed by texture_mode / dual_source /
       interp / nopersp. Statically initialised; no runtime
       cost after .so load.

       lookup_mode -> tm_idx mapping (Reserved_* already deduped
       by the caller via the lookup_mode parameter that has been
       in the codebase since before the pre-bake arc):
         actual_mode = lookup_mode & 0x3
         raw         = (lookup_mode & 0x4) != 0
         tm_idx:
           0: p0r0 (Direct16Bit,    actual=2, raw=0)
           1: p0r1 (RawDirect16Bit, actual=2, raw=1)
           2: p4r0 (Palette4Bit,    actual=0, raw=0)
           3: p4r1 (RawPalette4Bit, actual=0, raw=1)
           4: p8r0 (Palette8Bit,    actual=1, raw=0)
           5: p8r1 (RawPalette8Bit, actual=1, raw=1)

       The interp / persp axes mirror PickBatchUntexturedFSBytecode
       (same shadergen formulae). use_dual_source comes from the
       caller pre-computed - same bit the PSO blend state needs,
       computed once at the call site.

    2. GetBatchPipeline restructured: the textured branch now
       forks on filter. m_texture_filter == Nearest takes the
       pre-baked path via PickBatchTexturedNearestFSBytecode;
       other filter values still call GetBatchFragmentShader.
       The use_dual_source bool is now hoisted to the top of
       the FS-pickup block so both pre-baked pickers (textured
       Nearest + untextured) and the eventual textured non-
       Nearest paths consume the same value.

    3. precompile_sync's FS cache-warm loop generalises its
       pre-baked skip: pre_baked = (texture_mode == Disabled) ||
       (cur_filter == Nearest). The textured Nearest cells join
       untextured in skipping GetBatchFragmentShader; the
       progress.Increment still ticks for each so the user-
       facing progress bar reads the same count.

       Pre-existing PSO-build inner loop is untouched. It calls
       GetBatchPipeline, which now picks the pre-baked blob
       inside on the Nearest+textured path - PSO builds happen
       (they need to; the FS bytecode source changed), but the
       D3DCompile cost is gone.

What does NOT change in this commit:

  - m_batch_fragment_shader_blobs's slots for the textured-
    Nearest cells (filter dim index 0, texture_mode dims 0-6
    minus the Reserved_* dedup slots, render_mode 0-3) now go
    unused on this path. They stay null - the matrix shape
    remains <9, 4, 7> = 252 slots because the other 3 textured
    filter templates still consume them. A future cleanup can
    shrink the [filter] dim from 7 to 3 (Bilinear / JINC2 / xBR
    only) once those templates are pre-baked too.

  - The 3 remaining textured filter templates (Bilinear / JINC2
    / xBR, each with a *BinAlpha variant baked via the BINALPHA
    -D axis) still go through D3DCompile via
    GetBatchFragmentShader. They land in subsequent commits.
    The pre-bake-vs-D3DCompile branch in GetBatchPipeline is
    the integration point for them.

  - m_pgxp_depth_buffer still triggers PSO rebuild on the
    textured Nearest path - that's the PSO depth-comp swap
    (LESS_EQUAL vs GREATER_EQUAL) at PSO build time, not a
    shader source dependency. The FS bytecode is invariant
    under m_pgxp_depth_buffer post-routing-arc, so the same
    pre-baked blob serves both PGXP values; only the PSO
    rebuilds.

Behavioural change for users:

  - First batch of textured Nearest drawcalls in a session no
    longer triggers D3DCompile. With Disabled shader-precompile
    mode this saves O(20-50ms) per slot on first draw of each
    new (render_mode, texture_mode) combination. With Lazy mode
    the background warm-up finishes O(N Nearest+textured slots
    * 20ms) faster; with Enabled mode the upfront
    precompile_sync finishes that much sooner. PSX content
    overwhelmingly uses Palette4Bit textures (UI, sprites,
    most 3D meshes), so the Palette4Bit Nearest cells are the
    hot ones in stock content.

  - Cold-launch shader-disk-cache misses for textured-Nearest
    variants: zero, post-this-commit. No on-disk shader cache
    entries are produced for them anymore (the picker bypasses
    m_shader_cache.GetPixelShader entirely). Existing cache
    entries from previous versions still hit on the Bilinear /
    JINC2 / xBR slots (the cache hash is per-source-string).

  - DXBC output of fxc /T ps_5_0 /E main /O3 should be bit-
    identical to what D3DCompile would have produced from the
    shadergen-emitted HLSL (fxc and D3DCompile share the
    underlying compiler). Visual diff: zero. Pixel diff: zero.

Test:
  - g++ -std=c++17 -c on src/common/d3d12/embedded_shaders.cpp
    standalone (with -Isrc) compiles cleanly. The 72 new blobs
    link in correctly; .o size grows by ~400 KiB to ~1.5 MiB to
    match the per-variant .inc sizes from 9e4c33d.

  - g++ -std=c++17 syntax check on both pickers
    (PickBatchUntexturedFSBytecode +
    PickBatchTexturedNearestFSBytecode) against a shim
    D3D12_SHADER_BYTECODE / GPU_HW::BatchRenderMode /
    GPUTextureFilter compiles cleanly.

  - Boot any PSX title on D3D12 default settings (filter=
    Nearest, no PGXP, no MSAA): the textured Nearest slice is
    cold; first time it draws, the PSO builds without
    D3DCompile; the FS DXBC comes from
    k_batch_textured_nearest_ps_p4r0_d0_none_n0 (Palette4Bit,
    non-trans, dual=0, no interp qual, no nopersp) for typical
    Palette4Bit + TransparencyDisabled UI / sprite draws.
    Visual output identical to pre-commit.

  - Boot with MSAA 4x: interp_idx=1 (centroid). Picks
    k_batch_textured_nearest_ps_*_*_centroid_*.

  - Transparent textured geometry: u_render_mode != 0 routes
    through the runtime branch inside the pre-baked DXBC. The
    semitransparent texel test is u_render_mode-invariant; the
    OnlyOpaque (==2u) / OnlyTransparent (==3u) discards fire
    on the matching two-pass DrawIndexed re-upload from
    c532a34's FlushRender path.

  - 16-bit raw textures (RawDirect16Bit / 0x6): picks p0r1_*
    variants. Render-to-texture effects (MGS, Vagrant Story)
    take this path.

Cumulative pre-bake variant count progress for D3D12 batch FS:

  Pre-arc:                                    75 264 (every axis a -D)
  Post-cbuffer-routing of:
    DITHERING/INTERLACING/UV_LIMITS/PGXP_DEPTH 4 704
  Post-c532a34 (TRANSPARENCY -> u_render_mode) 1 176
  Post-c01f8ae (untextured re-baked, live)       12 baked + live
  Post-9e4c33d (Nearest .inc on disk)            72 baked
  Post-this-commit (Nearest live):
    Untextured slice:                            12 live
    Textured Nearest slice:                      72 live
    Total runtime-D3DCompile-free batch FS:      84

  Remaining filters (Bilinear / JINC2 / xBR):
    3 templates x ~144 variants (the BINALPHA `-D` axis adds
    one more dimension for those) = ~432 variants for the
    full bake.

Next:
  - Pre-bake the Bilinear filter slice. The Bilinear template
    is simpler than JINC2 / xBR - 2x2 texel blend with the
    BinAlpha variant gated on a BINALPHA `-D` macro. ~144
    variants per template (6 tex_mode x 2 dual x 3 interp x 2
    persp x 2 BinAlpha). Each filter slice gets a foundation
    commit (HLSL + regen + .inc) and an activation commit
    (extern decls + picker + GetBatchPipeline wiring),
    mirroring the untextured / Nearest arcs.
This commit is contained in:
LibretroAdmin 2026-05-19 07:22:37 +00:00 • committed by U-DESKTOP-SPFP6AQ\twistedtechre
commit a7f5717ff8
3 changed files with 603 additions and 23 deletions

View file

@ -107,4 +107,77 @@ namespace D3D12::EmbeddedShaders {
#include "embedded_dxbc/batch_untextured_ps_d1_sample_p0.inc"
#include "embedded_dxbc/batch_untextured_ps_d1_sample_p1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d0_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d0_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d0_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d0_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d0_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d0_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d1_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d1_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d1_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d1_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d1_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r0_d1_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d0_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d0_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d0_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d0_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d0_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d0_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d1_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d1_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d1_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d1_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d1_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p0r1_d1_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d0_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d0_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d0_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d0_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d0_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d0_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d1_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d1_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d1_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d1_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d1_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r0_d1_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d0_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d0_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d0_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d0_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d0_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d0_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d1_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d1_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d1_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d1_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d1_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p4r1_d1_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d0_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d0_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d0_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d0_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d0_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d0_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d1_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d1_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d1_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d1_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d1_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r0_d1_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d0_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d0_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d0_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d0_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d0_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d0_sample_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d1_centroid_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d1_centroid_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d1_none_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d1_none_n1.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d1_sample_n0.inc"
#include "embedded_dxbc/batch_textured_nearest_ps_p8r1_d1_sample_n1.inc"
} // namespace D3D12::EmbeddedShaders

View file

@ -381,4 +381,189 @@ extern const size_t k_batch_untextured_ps_d1_sample_p0_size_bytes;
extern const uint8_t k_batch_untextured_ps_d1_sample_p1[];
extern const size_t k_batch_untextured_ps_d1_sample_p1_size_bytes;
// Batch fragment shader, textured + Nearest-filter slice. Equivalent
// to GPU_HW_ShaderGen::GenerateBatchFragmentShader invoked with
// texture_mode != GPUTextureMode::Disabled AND m_texture_filter ==
// GPUTextureFilter::Nearest. Used by GPU_HW_D3D12::GetBatchPipeline's
// textured-Nearest branch in place of the runtime shadergen +
// D3DCompile path for the same slice. Second batch FS template
// pre-baked, after batch_untextured. The remaining three textured
// filter templates (Bilinear / JINC2 / xBR) land in subsequent
// commits.
//
// Variant axes (4 dimensions, 6+2+3+2 = 72 blobs):
//
// * Texture mode (6 combos via PALETTE_4_BIT / PALETTE_8_BIT /
// RAW_TEXTURE -D macros). Palette4Bit / Palette8Bit are mutually
// exclusive in the shadergen #elif chain - no variant has both
// set. Reserved_Direct16Bit / Reserved_RawDirect16Bit dedup to
// Direct16Bit / RawDirect16Bit at the C++ picker level.
// * USE_DUAL_SOURCE (0/1)
// * INTERP_CENTROID / INTERP_SAMPLE (mutually exclusive tri-state)
// * NOPERSP (0/1)
//
// 6 (tex_mode) x 2 (dual) x 3 (interp) x 2 (persp) = 72 blobs.
// MSAA cardinality does not multiply this slice - the batch FS reads
// from the single-sample shadow VRAM regardless of m_multisamples.
//
// Runtime selection at the GetBatchPipeline call site:
// tm_idx = derived from lookup_mode (Reserved_* deduped):
// 0: p0r0 (Direct16Bit)
// 1: p0r1 (RawDirect16Bit)
// 2: p4r0 (Palette4Bit)
// 3: p4r1 (RawPalette4Bit)
// 4: p8r0 (Palette8Bit)
// 5: p8r1 (RawPalette8Bit)
// dual_idx = use_dual_source ? 1 : 0
// interp_idx = m_per_sample_shading ? 2 :
// (m_multisamples > 1 ? 1 : 0)
// persp_idx = m_disable_color_perspective ? 1 : 0
//
// Source: data/shaders/d3d12/batch_textured_nearest.ps.hlsl
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d0_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d0_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d0_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d0_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d0_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d0_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d0_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d0_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d0_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d0_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d0_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d0_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d1_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d1_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d1_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d1_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d1_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d1_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d1_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d1_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d1_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d1_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r0_d1_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r0_d1_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d0_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d0_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d0_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d0_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d0_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d0_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d0_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d0_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d0_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d0_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d0_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d0_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d1_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d1_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d1_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d1_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d1_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d1_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d1_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d1_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d1_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d1_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p0r1_d1_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p0r1_d1_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d0_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d0_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d0_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d0_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d0_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d0_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d0_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d0_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d0_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d0_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d0_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d0_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d1_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d1_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d1_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d1_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d1_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d1_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d1_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d1_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d1_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d1_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r0_d1_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r0_d1_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d0_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d0_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d0_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d0_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d0_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d0_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d0_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d0_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d0_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d0_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d0_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d0_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d1_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d1_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d1_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d1_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d1_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d1_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d1_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d1_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d1_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d1_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p4r1_d1_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p4r1_d1_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d0_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d0_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d0_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d0_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d0_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d0_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d0_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d0_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d0_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d0_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d0_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d0_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d1_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d1_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d1_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d1_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d1_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d1_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d1_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d1_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d1_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d1_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r0_d1_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r0_d1_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d0_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d0_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d0_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d0_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d0_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d0_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d0_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d0_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d0_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d0_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d0_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d0_sample_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d1_centroid_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d1_centroid_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d1_centroid_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d1_centroid_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d1_none_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d1_none_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d1_none_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d1_none_n1_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d1_sample_n0[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d1_sample_n0_size_bytes;
extern const uint8_t k_batch_textured_nearest_ps_p8r1_d1_sample_n1[];
extern const size_t k_batch_textured_nearest_ps_p8r1_d1_sample_n1_size_bytes;
} // namespace D3D12::EmbeddedShaders

View file

@ -894,13 +894,18 @@ bool GPU_HW_D3D12::CompilePipelines()
// Pre-baked variants skip the GetBatchFragmentShader cache-
// warm step - the bytecode is statically linked, no
// D3DCompile to run. Currently the untextured slice is the
// only pre-baked template (commits 9e6f933 + this one); the
// four textured filter templates are still runtime-compiled
// and land in subsequent commits. The progress.Increment
// below still ticks for visual continuity so the
// user-facing progress bar reads the same as pre-pre-bake.
if (static_cast<GPUTextureMode>(texture_mode) != GPUTextureMode::Disabled)
// D3DCompile to run. Pre-baked templates so far:
// - Untextured (texture_mode == Disabled): commits
// 9e6f933 / b6d1903 / c01f8ae (re-bake).
// - Textured + Nearest: commits 9e4c33d + this one.
// The three remaining textured filter templates (Bilinear /
// JINC2 / xBR) are still runtime-compiled and land in
// subsequent commits. progress.Increment ticks regardless so
// the user-facing progress bar reads the same count.
const bool pre_baked =
(static_cast<GPUTextureMode>(texture_mode) == GPUTextureMode::Disabled) ||
(cur_filter == GPUTextureFilter::Nearest);
if (!pre_baked)
{
ComPtr<ID3DBlob> blob = GetBatchFragmentShader(cur_filter, render_mode, texture_mode);
if (!blob)
@ -1238,6 +1243,304 @@ static D3D12_SHADER_BYTECODE PickBatchUntexturedFSBytecode(
return k_blobs[use_dual_source ? 1 : 0][interp_idx][persp_idx];
}
// Textured + Nearest-filter batch FS pre-baked variant picker.
// Returns the matching DXBC blob from the 72-entry table at
// src/common/d3d12/embedded_dxbc/batch_textured_nearest_ps_*.inc,
// indexed by the 4 axes the regen tool bakes:
//
// texture_mode 6 combos (Palette4Bit / Palette8Bit /
// Direct16Bit each in non-raw / raw form). The
// Reserved_Direct16Bit / Reserved_RawDirect16Bit
// enum values are deduped to their non-Reserved
// counterparts at the GPU_HW_D3D12 caller via
// the `lookup_mode` parameter.
// use_dual_source driven by the same call-site formula as the
// untextured picker - the caller computes once
// and hands the bit to both this picker AND the
// PSO blend-state setup that references SRC1_*.
// interp (per_sample_shading > MSAA > none; mirror of
// ShaderGen::GetInterpolationQualifier)
// noperspective (m_disable_color_perspective)
//
// As with the untextured slice (c01f8ae), the former TRANSPARENCY
// axis (4 BatchRenderMode enum values) is now read from
// u_render_mode in the cbuffer - the DXBC is invariant across
// render_mode post-c532a34, so a single set of 72 variants covers
// all 4 render_modes.
static D3D12_SHADER_BYTECODE PickBatchTexturedNearestFSBytecode(
uint8_t lookup_mode, bool use_dual_source, uint32_t multisamples,
bool per_sample_shading, bool disable_color_perspective)
{
// texture_mode dim: derived from lookup_mode (Reserved_* already
// deduped by the caller). lookup_mode is a 3-bit value with
// bits 0..1 = actual_mode (0 = Palette4Bit, 1 = Palette8Bit,
// 2 = Direct16Bit; 3 is Reserved_Direct16Bit but
// the caller maps it to 2 before invoking us)
// bit 2 = RawTextureBit
// The 6 reachable combos map to a 6-slot 1-D table:
// 0: p0r0 Direct16Bit (actual=2, raw=0)
// 1: p0r1 RawDirect16Bit (actual=2, raw=1)
// 2: p4r0 Palette4Bit (actual=0, raw=0)
// 3: p4r1 RawPalette4Bit (actual=0, raw=1)
// 4: p8r0 Palette8Bit (actual=1, raw=0)
// 5: p8r1 RawPalette8Bit (actual=1, raw=1)
const uint8_t actual_mode = lookup_mode & 0x3u;
const bool raw = (lookup_mode & 0x4u) != 0;
unsigned tm_idx;
if (actual_mode == 2u) // Direct16Bit family
tm_idx = raw ? 1u : 0u;
else if (actual_mode == 0u) // Palette4Bit family
tm_idx = raw ? 3u : 2u;
else // actual_mode == 1u (Palette8Bit family)
tm_idx = raw ? 5u : 4u;
// 0 = none, 1 = centroid, 2 = sample. Same shape as the untextured
// picker - mirror of ShaderGen::GetInterpolationQualifier.
const unsigned interp_idx =
per_sample_shading ? 2u : ((multisamples > 1u) ? 1u : 0u);
const unsigned persp_idx = disable_color_perspective ? 1u : 0u;
static const D3D12_SHADER_BYTECODE k_blobs[6][2][3][2] = {
// tm = p0r0 (Direct16Bit)
{
// no dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d0_sample_n1_size_bytes}},
},
// dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r0_d1_sample_n1_size_bytes}},
},
},
// tm = p0r1 (RawDirect16Bit)
{
// no dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d0_sample_n1_size_bytes}},
},
// dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p0r1_d1_sample_n1_size_bytes}},
},
},
// tm = p4r0 (Palette4Bit)
{
// no dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d0_sample_n1_size_bytes}},
},
// dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r0_d1_sample_n1_size_bytes}},
},
},
// tm = p4r1 (RawPalette4Bit)
{
// no dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d0_sample_n1_size_bytes}},
},
// dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p4r1_d1_sample_n1_size_bytes}},
},
},
// tm = p8r0 (Palette8Bit)
{
// no dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d0_sample_n1_size_bytes}},
},
// dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r0_d1_sample_n1_size_bytes}},
},
},
// tm = p8r1 (RawPalette8Bit)
{
// no dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d0_sample_n1_size_bytes}},
},
// dual
{
// interp = none
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_none_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_none_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_none_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_none_n1_size_bytes}},
// interp = centroid
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_centroid_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_centroid_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_centroid_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_centroid_n1_size_bytes}},
// interp = sample
{{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_sample_n0,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_sample_n0_size_bytes},
{D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_sample_n1,
D3D12::EmbeddedShaders::k_batch_textured_nearest_ps_p8r1_d1_sample_n1_size_bytes}},
},
},
};
return k_blobs[tm_idx][use_dual_source ? 1 : 0][interp_idx][persp_idx];
}
} // anonymous namespace
GPU_HW_D3D12::ComPtr<ID3DBlob> GPU_HW_D3D12::GetBatchFragmentShader(GPUTextureFilter filter, uint8_t render_mode, uint8_t texture_mode)
@ -1395,29 +1698,48 @@ GPU_HW_D3D12::ComPtr<ID3D12PipelineState> GPU_HW_D3D12::GetBatchPipeline(GPUText
// branch shrinks until every batch FS variant is pre-baked.
const bool textured = (static_cast<GPUTextureMode>(lookup_mode) != GPUTextureMode::Disabled);
// Mirror of the shadergen formula in
// GPU_HW_ShaderGen::GenerateBatchFragmentShader. The bit drives
// both the FS variant choice (via PickBatch*FSBytecode below)
// AND the PSO blend state (via SetBlendState below for SRC1_*-
// using cells), so it must come from the same input set for
// both consumers. Identical for textured / untextured slices;
// pre-baked pickers and the shadergen GetBatchFragmentShader
// path all consume the same bit.
const bool use_dual_source =
m_supports_dual_source_blend &&
((render_mode != static_cast<uint8_t>(GPU_HW::BatchRenderMode::TransparencyDisabled) &&
render_mode != static_cast<uint8_t>(GPU_HW::BatchRenderMode::OnlyOpaque)) ||
filter != GPUTextureFilter::Nearest);
D3D12_SHADER_BYTECODE fs_bc;
ComPtr<ID3DBlob> fs_blob; // null on the pre-baked path; held for ref-life otherwise
if (textured)
{
fs_blob = GetBatchFragmentShader(filter, render_mode, lookup_mode);
if (!fs_blob)
return {};
fs_bc.pShaderBytecode = fs_blob->GetBufferPointer();
fs_bc.BytecodeLength = fs_blob->GetBufferSize();
if (filter == GPUTextureFilter::Nearest)
{
// Second pre-baked batch FS slice (9e4c33d + this commit).
// Picker selects from 72 .inc blobs at
// src/common/d3d12/embedded_dxbc/batch_textured_nearest_ps_*.inc;
// no D3DCompile, no shader-cache lookup.
fs_bc = PickBatchTexturedNearestFSBytecode(lookup_mode, use_dual_source,
m_multisamples, m_per_sample_shading,
m_disable_color_perspective);
}
else
{
// Bilinear / JINC2 / xBR (and their *BinAlpha variants) still
// go through shadergen + D3DCompile. Pre-bake commits for the
// 3 remaining filter templates land subsequently.
fs_blob = GetBatchFragmentShader(filter, render_mode, lookup_mode);
if (!fs_blob)
return {};
fs_bc.pShaderBytecode = fs_blob->GetBufferPointer();
fs_bc.BytecodeLength = fs_blob->GetBufferSize();
}
}
else
{
// Mirror of the shadergen formula in
// GPU_HW_ShaderGen::GenerateBatchFragmentShader. The bit drives
// both the FS variant choice (via PickBatchUntexturedFSBytecode
// below) AND the PSO blend state (via SetBlendState below for
// SRC1_*-using cells), so it must come from the same input set
// for both consumers.
const bool use_dual_source =
m_supports_dual_source_blend &&
((render_mode != static_cast<uint8_t>(GPU_HW::BatchRenderMode::TransparencyDisabled) &&
render_mode != static_cast<uint8_t>(GPU_HW::BatchRenderMode::OnlyOpaque)) ||
filter != GPUTextureFilter::Nearest);
fs_bc = PickBatchUntexturedFSBytecode(use_dual_source, m_multisamples,
m_per_sample_shading,
m_disable_color_perspective);