core: route UV_LIMITS through the batch UBO
Commit 6 of the batch matrix variant-shrinking arc. Routes
the UV_LIMITS axis out of the C++ shadergen source via the
u_uv_limits cbuffer slot (the second reserved slot in row 3
of the batch UBO; renamed from u_pad1). The VS / FS source is
now invariant under m_uv_limits for the D3D11 / D3D12 /
OpenGL backends that consume the C++ shadergen.
Wider blast radius than the prior cbuffer-routing commits in
this arc: UV_LIMITS doesn't gate body logic only - it gates
the a_uv_limits VS input attribute, the v_uv_limits varying,
and the FS-side v_uv_limits input. The shader SIGNATURE
differs between the two variants, which means the C++ input
layout has to follow suit. D3D11 and D3D12 both had
conditional ATTR4 bindings keyed on m_using_uv_limits; this
commit makes them unconditional. OpenGL was already
unconditional. Vulkan untouched - its batch shaders live in
data/shaders/vulkan/batch.vert.glsl and are pre-compiled
to SPIR-V via tools/regen_vulkan_spirv.py separately from
the C++ shadergen, with their own UV_LIMITS spec axis;
routing that side requires a regen pass and is left as a
follow-up.
Why the input layout can be unconditionally bound:
BatchVertex (gpu_hw.h:47) carries the uv_limits field
unconditionally. Every BatchVertex::Set call site
populates it - with real values from
ComputePolygonUVLimits when m_using_uv_limits is true,
with zero otherwise (the .Set overloads always take a
uv_limits_ parameter). The vertex buffer always has the
4-byte slot at offsetof(BatchVertex, uv_limits); binding
ATTR4 to it always points at valid memory, and reading
zeros when ComputePolygonUVLimits didn't run is safe
because the FS short-circuits on u_uv_limits.
Why the FS texture-filtering arm can use v_uv_limits without
a runtime guard:
ShouldUseUVLimits() (gpu_hw.cpp:23) defines
m_using_uv_limits as "PGXP on OR texture filter !=
Nearest". Whenever TEXTURE_FILTERING != Nearest in the
compiled FS source, m_using_uv_limits is also true at
runtime, so u_uv_limits is 1 and v_uv_limits is valid.
The settings-layer coupling guarantees this; no shader-
side defensive check is needed. The non-filtered FS arm
(TEXTURE_FILTERING == Nearest in source) DOES gate on
u_uv_limits at runtime because PGXP can flip
m_using_uv_limits to true under a Nearest-filter
session.
Shadergen VS prelude: drops DefineMacro UV_LIMITS, replaces
the two-branch DeclareVertexEntryPoint (with vs. without
a_uv_limits / v_uv_limits) with a single textured branch
that always emits both. VS body: drops the inner #if
UV_LIMITS guard around the v_uv_limits write so the varying
is always populated.
Shadergen FS prelude: drops DefineMacro UV_LIMITS, replaces
the two-branch DeclareFragmentEntryPoint (with vs. without
v_uv_limits input) with a single textured branch that
always declares v_uv_limits. FS body: refactors the
texture-sample block from
#if UV_LIMITS
float4 uv_limits = v_uv_limits;
...scale fixup...
#endif
#if TEXTURE_FILTERING
FilteredSampleFromVRAM(..., uv_limits, ...);
#else
#if UV_LIMITS
texcol = SampleFromVRAM(..., clamp(coords, uv_limits.xy, uv_limits.zw));
#else
texcol = SampleFromVRAM(..., coords);
#endif
#endif
to
#if TEXTURE_FILTERING
float4 uv_limits = v_uv_limits;
...scale fixup...
FilteredSampleFromVRAM(..., uv_limits, ...);
#else
if (u_uv_limits != 0u)
{
float4 uv_limits = v_uv_limits;
...scale fixup...
texcol = SampleFromVRAM(..., clamp(coords, uv_limits.xy, uv_limits.zw));
}
else
{
texcol = SampleFromVRAM(..., coords);
}
#endif
The texture-filtering arm uses v_uv_limits unconditionally
(settings coupling guarantee); the non-filtered arm gates
on the cbuffer scalar.
C++ side:
BatchUBOData: u_pad1 -> u_uv_limits. Struct size and
alignment unchanged (still 64 bytes / 4 rows). The last
remaining reserved slot is u_pad2.
Initialize / Reset / UpdateHWSettings: seed u_uv_limits
alongside the other per-session fields. Same shape as
the prior per-session cbuffer-routing commits (u_true_color,
u_scaled_dithering, u_pgxp_depth).
D3D11 CompileShaders: drop the
num_attributes = attributes.size() - (m_using_uv_limits ? 0 : 1)
truncation. The input layout always has 5 entries.
CreateInputLayout's signature-match validation against the
VS bytecode now matches up because the VS unconditionally
declares all 5 inputs.
D3D12 GetBatchPipeline: drop the
if (m_using_uv_limits) gpbuilder.AddVertexAttribute(...)
guard around ATTR4. Same reasoning.
OpenGL: untouched. The VAO setup at
gpu_hw_opengl.cpp:1099-1107 already bound ATTR4
unconditionally, predating this commit.
Vulkan: untouched. gpu_hw_vulkan.cpp:2247 still has the
if (m_using_uv_limits) input-attribute guard, and the
pre-baked SPIR-V from data/shaders/vulkan/batch.vert.glsl
is still UV_LIMITS-conditional. Routing the Vulkan side
needs three changes that aren't in this commit: edit the
GLSL source to drop the #if UV_LIMITS guards, run
tools/regen_vulkan_spirv.py to regenerate the embedded
SPIR-V blobs, and drop the gpu_hw_vulkan.cpp conditional.
Until then Vulkan continues working as before - the
C++ shadergen change doesn't reach Vulkan because its
batch shaders don't go through the C++ shadergen path.
m_using_uv_limits is still kept as a member field and still
appears in shader_source_changed / non_dim_diff. The
shadergen now ignores it (uses m_uv_limits at ctor capture
time but never reads it back for the batch shaders), but
Vulkan still needs it to pick the right pre-baked SPIR-V
blob at runtime (gpu_hw_vulkan.cpp:1654). Removing the
rebuild trigger would break Vulkan; leaving it in is wasted
work for D3D11 / D3D12 / OpenGL but harmless (the
re-emitted shader source is identical, so the disk shader
cache picks the same hash and serves the cached entry). The
proper cleanup happens when Vulkan is also routed.
m_using_uv_limits also still drives the per-vertex
ComputePolygonUVLimits decision (gpu_hw.cpp:740). That's
a CPU-side optimization (skip a computation when the FS
won't use the result) and is independent of the shader
routing - it stays.
Cost matrix delta (D3D12):
UV_LIMITS flip (in practice triggered by PGXP toggle or
by texture filter cross-Nearest transition, both of which
separately trigger rebuilds):
Pre-commit: 2 VS compiles + 252 FS compiles + 2520 PSO
compiles to update for new UV_LIMITS
variant.
Post-commit: identical compile count, but every
compiled blob is now bit-identical to its
pre-flip counterpart so the disk shader
cache serves all of them from cache.
~252 cache hits + ~2520 cache hits
instead of ~252 D3DCompile calls + ~2520
driver PSO assembly calls.
Pre-bake matrix size delta: UV_LIMITS was a captured
shadergen-state axis (not a matrix dim), so the matrix
itself doesn't shrink today. The win is on the pre-bake
side: a future bake of (filter x render x texture x ms)
no longer has UV_LIMITS as a multiplier, halving the
variant count we'd otherwise have to bake.
Pre-bake variant count, cumulative arc progress:
Pre-arc: 7 x 4 x 7 x 2 x 2 x 2 x 6 x 2 x 2 x 2 = 75 264
(filter x render x texture x dither x interlace x
pgxp x ms x per_sample x dcp x uv_limits)
After DITHERING: 7 x 4 x 7 x 2 x 2 x 6 x 2 x 2 x 2 = 37 632
After INTERLACING: 7 x 4 x 7 x 2 x 6 x 2 x 2 x 2 = 18 816
After PGXP-VS: no change to FS pre-bake count
After UV_LIMITS: 7 x 4 x 7 x 2 x 6 x 2 x 2 = 9 408
Still too big for a single-commit pre-bake; the remaining
axes (pgxp, per_sample, dcp) need either routing or a
pragmatic decision to keep them as variant axes. PGXP-FS
routing halves to 4704; collapsing per_sample / dcp via
forced-always settings halves twice more to 1176. That's
the rough target for the eventual pre-bake.
Test:
- Build: D3D11 / D3D12 / OpenGL compile. (Vulkan also
compiles - the C++ shadergen path it doesn't use is
untouched.)
- Default render (PGXP off, filter Nearest): the FS
runtime branch picks the non-clamping path; output is
visually identical to pre-commit.
- Toggle texture filter to Bilinear / JINC2 / xBR:
m_using_uv_limits flips to true on the C++ side, the
FS rebuild produces identical DXBC, u_uv_limits=1 is
pushed to cbuffer, the FS texture-filtering arm uses
v_uv_limits (which is now populated from the also-
unconditional VS write). Output identical to pre-commit
filter-on state.
- Toggle PGXP on with filter Nearest: m_using_uv_limits
flips to true, FS rebuild produces identical DXBC,
u_uv_limits=1 is pushed, the FS non-filtered arm takes
its u_uv_limits != 0 branch and clamps. Output
identical to pre-commit PGXP-on Nearest state.
- Toggle PGXP + filter together: behaves as above.
- Vulkan backend: identical behaviour to pre-commit (its
code path is untouched).
Next:
- The Vulkan-side UV_LIMITS routing follow-up (edit
data/shaders/vulkan/batch.vert.glsl + regen SPIR-V +
drop the .cpp conditional + drop m_using_uv_limits
from shader_source_changed across all backends).
- PGXP_DEPTH for the FS (always-emit SV_Depth perf
measurement first).
- Pre-bake commits once the remaining axes are decided.
This commit is contained in:
parent
49c0f829fc
commit
8b435183ea
5 changed files with 120 additions and 51 deletions
|
|
@ -96,6 +96,7 @@ bool GPU_HW::Initialize(HostDisplay* host_display)
|
|||
m_batch_ubo_data.u_true_color = m_true_color ? 1u : 0u;
|
||||
m_batch_ubo_data.u_scaled_dithering = m_scaled_dithering ? 1u : 0u;
|
||||
m_batch_ubo_data.u_pgxp_depth = m_pgxp_depth_buffer ? 1u : 0u;
|
||||
m_batch_ubo_data.u_uv_limits = m_using_uv_limits ? 1u : 0u;
|
||||
|
||||
UpdateSoftwareRenderer(false);
|
||||
|
||||
|
|
@ -137,6 +138,7 @@ void GPU_HW::Reset(bool clear_vram)
|
|||
m_batch_ubo_data.u_true_color = m_true_color ? 1u : 0u;
|
||||
m_batch_ubo_data.u_scaled_dithering = m_scaled_dithering ? 1u : 0u;
|
||||
m_batch_ubo_data.u_pgxp_depth = m_pgxp_depth_buffer ? 1u : 0u;
|
||||
m_batch_ubo_data.u_uv_limits = m_using_uv_limits ? 1u : 0u;
|
||||
|
||||
m_batch_ubo_dirty = true;
|
||||
m_current_depth = 1;
|
||||
|
|
@ -334,6 +336,7 @@ void GPU_HW::UpdateHWSettings(bool* framebuffer_changed, bool* shaders_changed,
|
|||
m_batch_ubo_data.u_resolution_scale = m_resolution_scale;
|
||||
m_batch_ubo_data.u_true_color = m_true_color ? 1u : 0u;
|
||||
m_batch_ubo_data.u_scaled_dithering = m_scaled_dithering ? 1u : 0u;
|
||||
m_batch_ubo_data.u_uv_limits = m_using_uv_limits ? 1u : 0u;
|
||||
m_batch_ubo_dirty = true;
|
||||
|
||||
if (!m_supports_dual_source_blend && TextureFilterRequiresDualSourceBlend(m_texture_filtering))
|
||||
|
|
|
|||
|
|
@ -157,15 +157,29 @@ protected:
|
|||
// matrix rebuild via shader_source_changed. VS, however, stays
|
||||
// bound across the flip.
|
||||
uint32_t u_pgxp_depth;
|
||||
// Reserved cbuffer slots. The batch UBO has been progressively
|
||||
// u_uv_limits: per-session UV-clamping gate (0 = off, 1 = on).
|
||||
// Used to live as a compile-time UV_LIMITS macro driving the
|
||||
// a_uv_limits vertex input + v_uv_limits varying + body
|
||||
// population. Now a runtime branch on the cbuffer field. The
|
||||
// VS source is invariant under the bit (always writes
|
||||
// v_uv_limits, always declares a_uv_limits); the FS source is
|
||||
// invariant too (the texture-filtering arm uses v_uv_limits
|
||||
// unconditionally thanks to the settings-layer coupling between
|
||||
// TEXTURE_FILTERING != Nearest and m_using_uv_limits=true via
|
||||
// ShouldUseUVLimits(); the non-filtered arm is the cbuffer
|
||||
// runtime branch). D3D11 / D3D12 input layouts always bind
|
||||
// ATTR4 when textured; OpenGL already did; Vulkan untouched
|
||||
// (its own pre-baked SPIR-V path needs a separate regen).
|
||||
uint32_t u_uv_limits;
|
||||
// Reserved cbuffer slot. The batch UBO has been progressively
|
||||
// growing as compile-time #defines move to runtime cbuffer
|
||||
// branches (RESOLUTION_SCALE, TRUE_COLOR, DITHERING_SCALED,
|
||||
// DITHERING, INTERLACING, PGXP_DEPTH for VS). Pre-allocating
|
||||
// the remaining slots in the 4th 16-byte row matches the layout
|
||||
// HLSL would have padded to anyway, and lets follow-up commits
|
||||
// route additional axes (UV_LIMITS, etc.) into a named slot
|
||||
// without changing the cbuffer's external size or alignment.
|
||||
uint32_t u_pad1;
|
||||
// DITHERING, INTERLACING, PGXP_DEPTH for VS, UV_LIMITS).
|
||||
// Pre-allocating the remaining slot in the 4th 16-byte row
|
||||
// matches the layout HLSL would have padded to anyway, and
|
||||
// lets a follow-up commit route one more axis into a named
|
||||
// slot without changing the cbuffer's external size or
|
||||
// alignment.
|
||||
uint32_t u_pad2;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1093,7 +1093,16 @@ bool GPU_HW_D3D11::CompileShaders()
|
|||
if (!vs_bytecode)
|
||||
return false;
|
||||
|
||||
const UINT num_attributes = static_cast<UINT>(attributes.size()) - (m_using_uv_limits ? 0 : 1);
|
||||
// num_attributes is now unconditionally attributes.size(). Before
|
||||
// the UV_LIMITS-to-cbuffer routing commit, this used to drop the
|
||||
// ATTR4 / a_uv_limits binding when m_using_uv_limits was false
|
||||
// (matching the shadergen's conditional emission of the input).
|
||||
// Post-routing, the shadergen always emits a_uv_limits as a VS
|
||||
// input when textured, and BatchVertex always carries the
|
||||
// uv_limits field, so the input layout always binds ATTR4. The
|
||||
// FS gates whether to actually consume the value via the
|
||||
// u_uv_limits cbuffer scalar.
|
||||
const UINT num_attributes = static_cast<UINT>(attributes.size());
|
||||
const HRESULT hr =
|
||||
m_device->CreateInputLayout(attributes.data(), num_attributes, vs_bytecode->GetBufferPointer(),
|
||||
vs_bytecode->GetBufferSize(), m_batch_input_layout.ReleaseAndGetAddressOf());
|
||||
|
|
|
|||
|
|
@ -1295,8 +1295,17 @@ GPU_HW_D3D12::ComPtr<ID3D12PipelineState> GPU_HW_D3D12::GetBatchPipeline(GPUText
|
|||
{
|
||||
gpbuilder.AddVertexAttribute("ATTR", 2, DXGI_FORMAT_R32_UINT, 0, offsetof(BatchVertex, u));
|
||||
gpbuilder.AddVertexAttribute("ATTR", 3, DXGI_FORMAT_R32_UINT, 0, offsetof(BatchVertex, texpage));
|
||||
if (m_using_uv_limits)
|
||||
gpbuilder.AddVertexAttribute("ATTR", 4, DXGI_FORMAT_R8G8B8A8_UNORM, 0, offsetof(BatchVertex, uv_limits));
|
||||
// ATTR4 / a_uv_limits is now bound unconditionally when
|
||||
// textured. Pre-UV_LIMITS-routing this was gated on
|
||||
// m_using_uv_limits because the shadergen only declared the
|
||||
// input when m_uv_limits was true. Post-routing, the shadergen
|
||||
// always emits the a_uv_limits VS input + v_uv_limits varying;
|
||||
// the FS gates whether to consume the value via the
|
||||
// u_uv_limits cbuffer scalar. BatchVertex always carries the
|
||||
// uv_limits field (gpu_hw.h:47), so the binding always points
|
||||
// at a valid 4-byte slot regardless of whether
|
||||
// ComputePolygonUVLimits ran on the vertex.
|
||||
gpbuilder.AddVertexAttribute("ATTR", 4, DXGI_FORMAT_R8G8B8A8_UNORM, 0, offsetof(BatchVertex, uv_limits));
|
||||
}
|
||||
|
||||
gpbuilder.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void GPU_HW_ShaderGen::WriteBatchUniformBuffer(std::stringstream& ss)
|
|||
"float u_dst_alpha_factor", "uint u_interlaced_displayed_field",
|
||||
"bool u_set_mask_while_drawing", "uint u_resolution_scale", "uint u_true_color",
|
||||
"uint u_scaled_dithering", "uint u_dithering",
|
||||
"uint u_interlacing", "uint u_pgxp_depth", "uint u_pad1", "uint u_pad2"},
|
||||
"uint u_interlacing", "uint u_pgxp_depth", "uint u_uv_limits", "uint u_pad2"},
|
||||
false);
|
||||
|
||||
// Alias the historical compile-time constants to their cbuffer-
|
||||
|
|
@ -119,7 +119,21 @@ std::string GPU_HW_ShaderGen::GenerateBatchVertexShader(bool textured)
|
|||
std::stringstream ss;
|
||||
WriteHeader(ss);
|
||||
DefineMacro(ss, "TEXTURED", textured);
|
||||
DefineMacro(ss, "UV_LIMITS", m_uv_limits);
|
||||
// UV_LIMITS used to live as a compile-time #define gating the
|
||||
// a_uv_limits vertex input + v_uv_limits varying + body
|
||||
// population in this VS. It is now routed through the batch UBO
|
||||
// (u_uv_limits) and the VS source unconditionally declares
|
||||
// a_uv_limits / v_uv_limits when textured. BatchVertex always
|
||||
// carries the uv_limits field regardless of m_using_uv_limits
|
||||
// (see gpu_hw.h:47), so the input layout always points at a
|
||||
// valid 4-byte slot - the value is 0 in vertex paths that don't
|
||||
// call ComputePolygonUVLimits, and the FS gates whether to read
|
||||
// it via u_uv_limits. Toggling m_using_uv_limits is now a single
|
||||
// 4-byte cbuffer write; the VS / FS sources are invariant. The
|
||||
// D3D11 / D3D12 input layouts also become unconditional (always
|
||||
// bind ATTR4 when textured); OpenGL was already unconditional;
|
||||
// Vulkan untouched (its own pre-baked SPIR-V path lives in
|
||||
// data/shaders/vulkan/batch.vert.glsl).
|
||||
// PGXP_DEPTH used to live as a compile-time #define driving the
|
||||
// pos_z source selection in the VS body. It is now routed through
|
||||
// the batch UBO (u_pgxp_depth) and the former #if/#else block is
|
||||
|
|
@ -165,19 +179,15 @@ std::string GPU_HW_ShaderGen::GenerateBatchVertexShader(bool textured)
|
|||
|
||||
if (textured)
|
||||
{
|
||||
if (m_uv_limits)
|
||||
{
|
||||
DeclareVertexEntryPoint(
|
||||
ss, {"float4 a_pos", "float4 a_col0", "uint a_texcoord", "uint a_texpage", "float4 a_uv_limits"}, 1, 1,
|
||||
{{"nointerpolation", "uint4 v_texpage"}, {"nointerpolation", "float4 v_uv_limits"}}, false, "", UsingMSAA(),
|
||||
UsingPerSampleShading(), m_disable_color_perspective);
|
||||
}
|
||||
else
|
||||
{
|
||||
DeclareVertexEntryPoint(ss, {"float4 a_pos", "float4 a_col0", "uint a_texcoord", "uint a_texpage"}, 1, 1,
|
||||
{{"nointerpolation", "uint4 v_texpage"}}, false, "", UsingMSAA(), UsingPerSampleShading(),
|
||||
m_disable_color_perspective);
|
||||
}
|
||||
// a_uv_limits / v_uv_limits emitted unconditionally now. The
|
||||
// FS-side runtime branch on u_uv_limits gates whether the value
|
||||
// is consumed; the VS just always passes it through. BatchVertex
|
||||
// always carries the uv_limits field so the input layout's
|
||||
// ATTR4 binding is always valid.
|
||||
DeclareVertexEntryPoint(
|
||||
ss, {"float4 a_pos", "float4 a_col0", "uint a_texcoord", "uint a_texpage", "float4 a_uv_limits"}, 1, 1,
|
||||
{{"nointerpolation", "uint4 v_texpage"}, {"nointerpolation", "float4 v_uv_limits"}}, false, "", UsingMSAA(),
|
||||
UsingPerSampleShading(), m_disable_color_perspective);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -233,9 +243,13 @@ std::string GPU_HW_ShaderGen::GenerateBatchVertexShader(bool textured)
|
|||
v_texpage.z = ((a_texpage >> 16) & 63u) * 16u * RESOLUTION_SCALE;
|
||||
v_texpage.w = ((a_texpage >> 22) & 511u) * RESOLUTION_SCALE;
|
||||
|
||||
#if UV_LIMITS
|
||||
v_uv_limits = a_uv_limits * float4(255.0, 255.0, 255.0, 255.0);
|
||||
#endif
|
||||
// v_uv_limits is always written when textured. When u_uv_limits=0
|
||||
// at runtime the FS short-circuits and doesn't consume this
|
||||
// value, so the (potentially-zero) contents of a_uv_limits are
|
||||
// harmless. The unconditional write costs one MUL per vertex and
|
||||
// one vec4 of interpolant bandwidth - sub-noise on PSX vertex
|
||||
// throughput.
|
||||
v_uv_limits = a_uv_limits * float4(255.0, 255.0, 255.0, 255.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
|
@ -781,7 +795,14 @@ std::string GPU_HW_ShaderGen::GenerateBatchFragmentShader(GPU_HW::BatchRenderMod
|
|||
// - the field LSB changes per frame, the interlacing on/off bit
|
||||
// changes on display-mode changes.
|
||||
DefineMacro(ss, "TEXTURE_FILTERING", m_texture_filter != GPUTextureFilter::Nearest);
|
||||
DefineMacro(ss, "UV_LIMITS", m_uv_limits);
|
||||
// UV_LIMITS: routed to the batch UBO (u_uv_limits) alongside the
|
||||
// VS-side routing - see the GenerateBatchVertexShader prelude
|
||||
// comment for the full reasoning. The FS body has two former
|
||||
// #if UV_LIMITS sites: the texture-filtering path (always uses
|
||||
// v_uv_limits because the settings-layer ShouldUseUVLimits()
|
||||
// couples TEXTURE_FILTERING != Nearest to m_using_uv_limits=true,
|
||||
// so u_uv_limits is guaranteed 1 here) and the non-filtered path
|
||||
// (gated by runtime branch on u_uv_limits).
|
||||
DefineMacro(ss, "USE_DUAL_SOURCE", use_dual_source);
|
||||
DefineMacro(ss, "PGXP_DEPTH", m_pgxp_depth);
|
||||
|
||||
|
|
@ -894,19 +915,16 @@ float4 SampleFromVRAM(uint4 texpage, float2 coords)
|
|||
if (m_texture_filter != GPUTextureFilter::Nearest)
|
||||
WriteBatchTextureFilter(ss, m_texture_filter);
|
||||
|
||||
if (m_uv_limits)
|
||||
{
|
||||
DeclareFragmentEntryPoint(ss, 1, 1,
|
||||
{{"nointerpolation", "uint4 v_texpage"}, {"nointerpolation", "float4 v_uv_limits"}},
|
||||
true, use_dual_source ? 2 : 1, !m_pgxp_depth, UsingMSAA(), UsingPerSampleShading(),
|
||||
false, m_disable_color_perspective);
|
||||
}
|
||||
else
|
||||
{
|
||||
DeclareFragmentEntryPoint(ss, 1, 1, {{"nointerpolation", "uint4 v_texpage"}}, true, use_dual_source ? 2 : 1,
|
||||
!m_pgxp_depth, UsingMSAA(), UsingPerSampleShading(), false,
|
||||
m_disable_color_perspective);
|
||||
}
|
||||
// v_uv_limits emitted unconditionally now; runtime branch on
|
||||
// u_uv_limits inside the FS body decides whether to consume it
|
||||
// for clamping. TEXTURE_FILTERING != Nearest is settings-coupled
|
||||
// to u_uv_limits=1 via ShouldUseUVLimits(), so the
|
||||
// FilteredSampleFromVRAM path can rely on v_uv_limits being
|
||||
// valid without an explicit runtime check there.
|
||||
DeclareFragmentEntryPoint(ss, 1, 1,
|
||||
{{"nointerpolation", "uint4 v_texpage"}, {"nointerpolation", "float4 v_uv_limits"}},
|
||||
true, use_dual_source ? 2 : 1, !m_pgxp_depth, UsingMSAA(), UsingPerSampleShading(),
|
||||
false, m_disable_color_perspective);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -946,27 +964,43 @@ float4 SampleFromVRAM(uint4 texpage, float2 coords)
|
|||
coords /= float2(RESOLUTION_SCALE, RESOLUTION_SCALE);
|
||||
#endif
|
||||
|
||||
#if UV_LIMITS
|
||||
float4 texcol;
|
||||
#if TEXTURE_FILTERING
|
||||
// TEXTURE_FILTERING != Nearest is settings-coupled to
|
||||
// m_using_uv_limits=true via ShouldUseUVLimits(), so u_uv_limits
|
||||
// is guaranteed 1 here and v_uv_limits is valid. No runtime
|
||||
// gate needed for this path.
|
||||
float4 uv_limits = v_uv_limits;
|
||||
#if !PALETTE
|
||||
// Extend the UV range to all "upscaled" pixels. This means 1-pixel-high polygon-based
|
||||
// Extend the UV range to all "upscaled" pixels. This means 1-pixel-high polygon-based
|
||||
// framebuffer effects won't be downsampled. (e.g. Mega Man Legends 2 haze effect)
|
||||
uv_limits *= float(RESOLUTION_SCALE);
|
||||
uv_limits.zw += float(RESOLUTION_SCALE - 1u);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float4 texcol;
|
||||
#if TEXTURE_FILTERING
|
||||
FilteredSampleFromVRAM(v_texpage, coords, uv_limits, texcol, ialpha);
|
||||
if (ialpha < 0.5)
|
||||
discard;
|
||||
#else
|
||||
#if UV_LIMITS
|
||||
// Non-filtered path: u_uv_limits gates whether to clamp. When
|
||||
// PGXP is on (and texture filter is Nearest) the settings layer
|
||||
// sets m_using_uv_limits=true and u_uv_limits=1; we sample with
|
||||
// clamping. When both PGXP and filtering are off, u_uv_limits=0
|
||||
// and we sample without clamping (and v_uv_limits contents are
|
||||
// potentially-zero junk - which is fine because the runtime
|
||||
// branch never reads them).
|
||||
if (u_uv_limits != 0u)
|
||||
{
|
||||
float4 uv_limits = v_uv_limits;
|
||||
#if !PALETTE
|
||||
uv_limits *= float(RESOLUTION_SCALE);
|
||||
uv_limits.zw += float(RESOLUTION_SCALE - 1u);
|
||||
#endif
|
||||
texcol = SampleFromVRAM(v_texpage, clamp(coords, uv_limits.xy, uv_limits.zw));
|
||||
#else
|
||||
}
|
||||
else
|
||||
{
|
||||
texcol = SampleFromVRAM(v_texpage, coords);
|
||||
#endif
|
||||
}
|
||||
if (VECTOR_EQ(texcol, TRANSPARENT_PIXEL_COLOR))
|
||||
discard;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue