Ported from EmuCoreX with sashkinbro's approval. The GPU family alone was
never enough to decide behaviour: the same Mali part behaves differently
under ARM's proprietary driver than under Mesa PanVK, a lesson this tree
learned twice the expensive way - the r44p1 DEVICE_LOST fix had to be
gated on driverID rather than vendorID, and the 8 Elite push-descriptor
disable likewise. Driver identity, version and a bug set are now recorded
in a table, so the next device quirk is an entry rather than another
bespoke branch. Twenty-five rules, with match confidence so a vendor-wide
rule never overrides a driver-version-specific one.
The shaders gain gpu_bitwise_and / gpu_bitwise_not / gpu_boolean_not,
whose bodies the device emits: plain a & b normally, scalarized where the
database says the driver miscompiles vector bitwise ops. A device matching
no rule renders exactly as before.
opengl/tfx_fs.glsl already carried this fix as IAND3/UAND2/UAND4 macros
gated on GPU_PROFILE_MALI. Those are replaced by the shared helpers, but
the GL macro is deliberately (workaround || IsMaliGPUProfile()): Mali
reached through ANGLE or Panfrost resolves a non-ARM driver and matches no
rule, so a database-only gate would have silently removed a fix those
users have today. Widening only.
SHADER_CACHE_VERSION 108 -> 109. Every TFX and convert shader's source
text changed, so a blob cached from 108 no longer matches the source that
produced it; without the bump users would get stale binaries and garbage
rendering after updating.
RewriteConstantLoads is deliberately absent - the database records
BrokenConstantLoad with no workaround bits, so the macro would be
permanently zero and the shader code dead.
Shaders validated offline with glslc across 136 Vulkan and 296 GL/GLES
permutations, every macro on and off; the failure set is byte-identical to
the pre-change baseline.
The Android shader tree carried capability-gated blocks that bin was missing,
even though the shared C++ backends emit every gating macro on all platforms
(GSDeviceOGL.cpp:2006-2010, GSDeviceVK.cpp:4769 — GPU_PROFILE_MALI,
HAS_ARM/EXT_SHADER_FRAMEBUFFER_FETCH, HAS_ARM_DEPTH_FETCH, HAS_CLIP_CONTROL,
DISABLE_DUAL_SOURCE). bin was simply the stale copy; the desktop GL backend is
already wired to consume the mobile shader structure (see the GPU_PROFILE_MALI
reference at GSDeviceOGL.cpp:1067). Collapse the two to one superset so drift
becomes impossible.
- opengl/{convert,interlace,present,tfx_fs,tfx_vgs}.glsl, vulkan/present.glsl:
adopt the Android version verbatim. Every difference is either macro-gated
(desktop path preserved in the #else — e.g. the tfx_vgs z-remap lives under
#else of #if HAS_CLIP_CONTROL, dead on desktop which has ARB_clip_control) or
a GLES-strict float/cast tweak that is behaviorally identical on desktop.
- vulkan/tfx.glsl: hand-merged. Union in the additive tiler blocks (Mali
EQUAL_WZ z-nudge on both the direct and VS_EXPAND paths, the
VS_PROVOKING_VERTEX_LAST and !VS_IIP provoking-vertex handling) and drop
layout(depth_less) per its float32-rounding correctness rationale, while
KEEPING bin's newer two-flag ROV implementation (rov_discard_color/depth) —
that path is dead on mobile since ROV is now off on all tilers. Preprocessor
structure verified balanced and identical to Android's directive counts.
dx11/tfx.fx is Windows-only (never compiled on mobile) and the two remaining
vulkan files differ only in trailing whitespace, so they stay as-is; the mobile
copies get removed and generated from bin in the build-plumbing step.
Add support for depth feedback loops either via texture barriers or copies.
DX12 and OpenGL do depth feedback by creating a temporary color texture to hold Z and using multiple color outputs.
Use the depth feedback for accurate AFAIL (enabled via INI setting).
The idea is to adjust the alpha destination for more
accurate hw blending which will work on all renderers.
Old behavior has Ad in range within 0-1 whereas for blending 0-2 is needed.
copy rt -> adjust the alpha -> copy back the adjusted alpha-> restore old alpha after blending is done