Henrik Rydgård
381c1134ac
Remove unnecessary scaling and then un-scaling of through-mode Z coordinates
2026-06-03 15:59:36 +02:00
Henrik Rydgård
86212f5384
Correct minor shader generator bug for depthclamp case.
2026-06-02 15:58:47 +02:00
Henrik Rydgård
8113cb9147
Misc cleanup and renaming
2026-06-02 11:39:33 +02:00
Henrik Rydgård
e75d9f8a5f
Unify the bounding depth checks, correct them if minmax clip is needed
2026-05-30 19:07:59 +02:00
Henrik Rydgård
0eede05f5f
Implement fragment shader depth clamp and min/max discard. Slow on some hardware, but it's a fallback.
2026-05-30 19:07:59 +02:00
Henrik Rydgård
de266c3d6c
Add the appropriate epsilons to cull distance. Fixes the NBA issue.
...
It's a bit odd that this draw doesn't go through software transform
though.
2026-05-30 19:07:59 +02:00
Henrik Rydgård
5ad24adc93
Cleanup, increase the max cull count. Flatout water works now.
2026-05-30 19:07:59 +02:00
Henrik Rydgård
3599c4002b
Through mode draws should not be min/max tested
2026-05-30 19:07:59 +02:00
Henrik Rydgård
9979d5544d
Round off Z for the min/max tests. Gets both Test Drive map and Wipeout Pure shadows working at the same time..
2026-05-30 19:07:59 +02:00
Henrik Rydgård
eaacbbc226
D3D and OpenGL shader buildfixes
2026-05-30 19:07:59 +02:00
Henrik Rydgård
058b1af285
Revert to software on out-of-bounds projected depth
2026-05-30 19:07:59 +02:00
Henrik Rydgård
b9ef43f4de
VertexShaderGenerator work
2026-05-30 19:07:59 +02:00
Henrik Rydgård
36f5664c5e
Re-enable cull distance in vertex shader, fix some test errors
2026-05-30 19:07:58 +02:00
Henrik Rydgård
f55adcc3a1
Apply a small depth bias to simulate rounding of Z. Fix min/max clip plane math
2026-05-30 19:07:58 +02:00
Henrik Rydgård
f0d715feaa
During culling, evaluate minZ,maxZ,minW,maxW, and use them to cull some things. Also, assorted vshader work.
2026-05-30 19:07:58 +02:00
Henrik Rydgård
5808afef10
Implement minZ/maxZ through user clip planes
2026-05-30 19:07:58 +02:00
Henrik Rydgård
2f73bea7f0
Correct Z in through mode, add another check to range culling
2026-05-30 19:07:58 +02:00
Henrik Rydgård
490469c4e6
Re-implement range culling
2026-05-30 19:07:58 +02:00
Henrik Rydgård
ae98055cec
Delete a lot of legacy depth and viewport code, fix OpenGL
2026-05-30 19:07:58 +02:00
Henrik Rydgård
62d8cf22de
Move the viewport transform to software in SW transform mode
...
transform fix
2026-05-30 19:07:58 +02:00
Henrik Rydgård
5aedd2f1e3
Hardware transform seems to work, software transform still has issues
2026-05-30 19:07:58 +02:00
Henrik Rydgård
69c7c75124
Replace u_proj_through with a simple scale/offset
...
First reasonable output appears.
2026-05-30 19:07:58 +02:00
Henrik Rydgård
4a55fc6724
Prepare TestBoundingBoxFast for optimization
2026-05-25 13:37:27 +02:00
Henrik Rydgård
736d054b8f
Remove the u_proj_though matrix from the uniform buffer
2026-05-19 16:33:45 +02:00
Henrik Rydgård
e108828bcc
Unify Z handling between the backends
2026-05-19 15:17:44 +02:00
Henrik Rydgård
d243737c11
Revert "Convert the pre-rotation to just the matrix multiplication."
...
After the previous commit, the optimization is no longer needed, and
unnecessarily bloats the uniform buffer.
This reverts commit 62bcb1785e809649ba88b49e24c5217f457fa040.
2026-05-17 11:02:35 +02:00
Henrik Rydgård
4b93a870db
Optimize out pre-rotation entirely from vertex shaders when not needed
2026-05-17 11:01:50 +02:00
Henrik Rydgård
947217d1be
Convert the pre-rotation to just the matrix multiplication.
2026-05-17 10:59:40 +02:00
Henrik Rydgård
065a68ef4f
Split out screen rotation from the projection matrix
2026-05-17 10:58:54 +02:00
Henrik Rydgård
afb764e6ae
Rendering: Unify the Y-flipping state across backends (now only applied in-shader, not through matrices).
2026-05-14 23:30:06 +02:00
Chris Healy and cphealy
9ed5dcdc27
GPU: Use inversesqrt for light distance and half-vector calculations
...
Replace length()/normalize() with inversesqrt() pattern for better
performance on mobile GPUs. The inversesqrt instruction is a single
hardware operation, while length() requires sqrt(dot()) and normalize()
requires inversesqrt internally plus a multiply.
Changes:
1. Light distance calculation:
Before: distance = length(toLight); toLight /= distance;
After: distSq = dot(toLight, toLight);
invDist = inversesqrt(distSq);
distance = distSq * invDist;
toLight *= invDist;
2. Specular half-vector normalization:
Before: ldot = dot(normalize(toLight + vec3(0,0,1)), worldnormal);
After: halfVec = toLight + vec3(0,0,1);
halfInvLen = inversesqrt(dot(halfVec, halfVec));
ldot = dot(halfVec, worldnormal) * halfInvLen;
Also reuses distSq in attenuation calculation to avoid recomputing
distance*distance.
Offline shader compiler results (vertex shader with 4-light ubershader):
Mali (malioc):
G31 (Bifrost): 44.90 -> 40.50 cycles (-9.8%)
G52 (Bifrost): 14.97 -> 13.50 cycles (-9.8%)
G310 (Valhall): 13.88 -> 12.88 cycles (-7.2%)
G57 (Valhall): 7.60 -> 6.97 cycles (-8.3%)
PowerVR (Profiling Compilers):
Series 8 GE8300: 322 -> 302 ALU cycles (-6.2%)
Series 9 GM9445: 296 -> 280 ALU cycles (-5.4%)
Series B BXM: 560 -> 540 instructions (-3.6%)
Signed-off-by: Chris Healy <cphealy@gmail.com >
2026-03-08 19:13:41 -07:00
Henrik Rydgård
6cfea96e58
Remove D3D9 support, to make future changes easier
2025-06-10 15:07:16 +02:00
Henrik Rydgård
df6ed8cfc9
Do some cleanup of #includes in GPU
2024-12-18 13:57:26 +01:00
Henrik Rydgård
702e77454a
Hardware transform: Clamp the specular coefficient to 0.0 before taking the power.
2024-09-25 21:09:13 +02:00
Lubos
3154a5fac1
OpenXR - VR camera features on any platform
2024-08-07 09:25:12 +02:00
Henrik Rydgård
fab034d866
Fix minor difference between ubershader and specialized vshaders
2024-07-24 20:50:33 +02:00
Lubos
a9b5a4739e
Fix math of simple stereo
2024-06-25 16:06:03 +02:00
Luboš V and GitHub
27152b1e47
OpenXR - Forgotten usages
2024-06-24 19:43:17 +02:00
Luboš V and GitHub
dd9bc42b0a
OpenXR - Remove multiview from shader
2024-06-24 19:24:46 +02:00
Lubos
7b089effa0
OpenXR - Use single VR projection matrix
2024-06-03 18:29:06 +02:00
Henrik Rydgård
e3177ac870
Make some global string pointers const, not just the strings.
...
Minor cleanup.
2023-12-29 14:09:45 +01:00
Henrik Rydgård
0f3dca5cea
Revert a bad "optimization" I made in #18587
2023-12-25 12:03:09 +01:00
Henrik Rydgård
2238fab601
Minor lighting optimization in vshader
2023-12-20 14:47:49 +01:00
Herman Semenov
0748ce610f
[GPU/Common/D3D11/Directx9/GLES/Vulkan] Using reserve if possible
2023-12-15 14:08:22 +03:00
Henrik Rydgård
b42670cf59
Manually revert the rest of the lmode optimization
2023-05-09 18:44:24 +02:00
Henrik Rydgård
0babac5c5f
Manually revert "Remove LM flag from vshader too" ( #16718 )
...
Reverts #16718
Though maybe we can keep this one? Let's see.
2023-05-09 18:44:18 +02:00
Henrik Rydgård
f42c682d34
Revert "Merge pull request #16628 from hrydgard/remove-fog-fshader-flag"
...
This reverts commit 10dee90c83 , reversing
changes made to 34c11c8acf .
2023-05-08 22:01:38 +02:00
Unknown W. Brackets
9fcc1509e4
GPU: Correct depth clip/cull for zero scale.
2023-03-05 08:51:45 -08:00
Unknown W. Brackets
0f3f2e361f
GLES: More uint const paranoia.
...
We don't use indexing on GLES now, but better to stay consistent.
2023-01-12 17:41:55 -08:00
Henrik Rydgård
86f34c52a4
Revert bad shader optimization
2023-01-12 00:30:41 +01:00