Commit Graph
74 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 20620da37f SoftGPU: Cull primitives entirely outside an x or y plane
Like z, a primitive whose vertices are all beyond the same x or y plane
(|x| > w) isn't drawn, for every primitive type and with clipping on or off;
a vertex on the plane is inside (gpu/probe exp176, gpu/clipping/xycull).
Immediate-mode vertices carry screen coordinates in their clip position, so
only z culls them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 15:09:43 -06:00
Henrik RydgårdandClaude Opus 5.5 700a314542 SoftGPU: Clip vertex texture coordinates in GE arithmetic
The near-plane clipper's new vertices get their texture coordinates with
the same float24 arithmetic as their position, not a float lerp. Fixes the
texel ties under a clipped fan in a GTA frame dump (gpu/probe exp136; clipped
colors and fog still differ).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 15:09:43 -06:00
Henrik RydgårdandClaude Opus 5.5 524fac1c32 SoftGPU: Clip at the near plane like the GE
Measured with gpu/probe exp43-47, bit exact:
- New vertices are interpolated from the inside vertex, t = d_in / (d_in -
  d_out) with d = z + w through the GE adder, using the GE's reciprocal;
  out - in is truncated to float24 before the multiply by t, and t and each
  coordinate use float24 products and adds.
- With one vertex outside, the quad is split from the vertex before it in the
  GE's order: (p, a, b) and (p, b, n). The GE takes odd strip triangles in
  reverse and fan triangles in order, so SendTriangle now says when the
  vertices it gets are reversed from that.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 15:09:42 -06:00
Henrik RydgårdandClaude Opus 5.5 3d4f945054 SoftGPU: Clip and cull at the near plane like the GE
With depth clip off, the GE doesn't clip triangles and lines at the near
plane: the part beyond it is drawn with extrapolated depth, and a vertex behind
the camera (w <= 0) culls the whole primitive instead. With it on, they're
clipped, and a vertex that gets clipped away can't cull the primitive by being
outside the screen range (w = 0 included). Rects, which aren't clipped, are
culled by a vertex behind the camera either way. Measured with gpu/probe.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 15:09:42 -06:00
Henrik RydgårdandClaude Opus 5.5 f48251c90a SoftGPU: Cull primitives by z like the GE
The GE counts a vertex as outside when |z| > w, comparing the float24 clip
coordinates without dividing, and culls a primitive only when all its vertices
are outside, with depth clamp on or off. Points were never culled, and lines,
triangles and rectangles were culled on a single outside vertex with clamp off.
Measured with gpu/probe for every primitive type, both clamp modes and a
range of w.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 15:09:42 -06:00
Henrik Rydgård 5808afef10 Implement minZ/maxZ through user clip planes 2026-05-30 19:07:58 +02:00
Henrik Rydgård 3e198c53b2 More include cleanup 2024-12-18 13:57:26 +01:00
Unknown W. Brackets 8f404a1961 softgpu: Fix minor typo. 2023-07-25 19:42:36 -07:00
Unknown W. Brackets dc962094f8 softgpu: Correctly fix inversions, matching tests.
Inversions are allowed just fine, but if clipping results in coordinates
outside range, the triangle should be culled.  Fixes more wanted
inversions.
2022-11-30 23:20:39 -08:00
Unknown W. Brackets 909f3feaea softgpu: Allow inversions when w >= -1.0.
This seems to match desired cases well, see #16131.  Likely still
inaccurate to what hardware actually does.
2022-11-26 12:11:56 -08:00
Unknown W. Brackets 71b4407889 softgpu: Throw away all inverted polygons.
This is actually incorrect in some cases, but there are a number of games
affected by inversions, and they're practically always undesired.
2022-11-19 20:30:49 -08:00
Unknown W. Brackets a66056217f softgpu: Avoid splitting rectangles for fog.
If the fog factor would result in the same amount of fog, we're just
adding more work for no reason.
2022-11-13 09:23:06 -08:00
Unknown W. Brackets 21064edfca softgpu: Correct tex on fogged rectangles. 2022-11-13 09:17:29 -08:00
Unknown W. Brackets d33986a5ad softgpu: Cull a triangle with all negative w.
Per tests, this seems to happen but only when all points are below zero.
2022-10-15 11:49:28 -07:00
Unknown W. Brackets 23af9be9f4 softgpu: Handle rectangle texture projection. 2022-09-26 18:44:39 -07:00
Unknown W. Brackets 8376176b2f softgpu: Split clippos out of rasterization vert.
We don't use it, except w, at all in rasterization, so no need to keep it
in the bin queue.
2022-09-26 16:50:40 -07:00
Unknown W. Brackets de080e2594 softgpu: Simplify vertex range culling.
The previous logic was harder to understand and easier to get wrong.
Just drop them when clipping the primitive.
2022-09-18 06:16:25 -07:00
Unknown W. Brackets 7a83f8bab5 softgpu: Use vertType prim override for flags.
These parameters are a real shame, was so clean before...
2022-09-06 22:20:45 -07:00
Unknown W. Brackets cc6491342e softgpu: Prepare dedicated rectangle path.
We're still sometimes using the slow rect-as-triangles path, let's do
something faster.  As a first step, just handle binning.
2022-02-20 09:38:51 -08:00
Unknown W. Brackets 8e7bc80e4b softgpu: Avoid modifying source vertex data.
This was dangerous for strips and fans, which reuse the verts for
subsequent primitives.
2022-02-12 10:39:25 -08:00
Henrik Rydgård eba93f2ee0 Merge pull request #15340 from unknownbrackets/softgpu-textures
Correct UV rotation and through mipmaps, optimize texenv blend a bit
2022-01-24 08:19:34 +01:00
Unknown W. Brackets 818d17183b softgpu: Correct clear mode dither.
It does apply, but have to be careful about alpha.
2022-01-23 12:39:50 -08:00
Unknown W. Brackets 648b71616e softgpu: Correct UV rotation for transformed rects. 2022-01-23 08:15:15 -08:00
Unknown W. Brackets abef17caca softgpu: Simplify mask check.
This performs a bit better.
2022-01-16 23:40:57 -08:00
Unknown W. Brackets 89bc87a388 softgpu: Reduce copying during clipping.
Common case is nothing needs to be clipped.
2022-01-16 23:33:46 -08:00
Unknown W. Brackets cf3384c993 softgpu: Avoid double calculating screenpos. 2022-01-15 11:22:36 -08:00
Unknown W. Brackets a0a9b1e89b softgpu: Add class to manage and enqueue for bins.
For now, just forwarding.
2022-01-13 09:26:59 -08:00
Unknown W. Brackets d5c5e9478e softgpu: Prepare more state per prim call. 2022-01-10 22:12:35 -08:00
Unknown W. Brackets d7a82ab7b8 softgpu: Compute func IDs once per batch of verts.
This saves a decent chunk of time, especially when many verts are being
drawn.
2022-01-10 22:12:35 -08:00
Unknown W. Brackets 6367d5dc8f softgpu: Draw top left of rectangles first.
This helps when things do self-rendering, since this way we won't read
from things we've just written to when scaling down.  See #11623.
2022-01-08 20:53:01 -08:00
Unknown W. Brackets 8db2d37e64 softgpu: Fix depth cull in softgpu.
Was improperly skipping cull for positive Z.
2021-11-05 21:38:13 -07:00
Unknown W. Brackets 121c56e6db softgpu: Clip only on -Z, cull if entirely outside.
This is important for several issues, like #12058 or #12060, where
something is drawn entirely outside valid Z, and should be culled.
2021-09-09 20:13:42 -07:00
Unknown W. Brackets f32f89dd90 Global: Remove some unused variables. 2021-02-15 11:59:45 -08:00
Henrik Rydgård 821817e6d4 Move the profiler to Common 2020-10-04 11:42:16 +02:00
Unknown W. Brackets 5fae2171cc softgpu: Correct cull handling for sprites. 2020-09-08 16:29:45 -07:00
Henrik Rydgård 2e06386cf6 Software renderer clipper: Don't clip on the sides. Fixes #4845 and should fix #7124 for the SW renderer. 2020-08-16 21:38:07 +02:00
Henrik Rydgård 970adfbcc9 Isolate most of the softgpu specialization code to RasterizerRectangle.
See comments.
2019-10-28 09:33:30 +01:00
Henrik Rydgård 86c781e434 Hack around most of the problems with the save/load dialog. Software stretch gets enabled in non-wide mode, so wallpapers work at a cost of speed. 2019-10-27 20:55:32 +01:00
Henrik Rydgård 290e9971a7 More specialization work. 2019-10-27 20:54:36 +01:00
Henrik Rydgård 9099441973 Darkstalkers: Gross hack to avoid the game's own stretch, and present the raw buffer instead for a sharper image. 2019-10-27 20:54:36 +01:00
Henrik Rydgård 2dd7a9aa12 More darkstalkers work 2019-10-27 20:54:36 +01:00
Henrik Rydgård c7f6724f7e Detect sprite drawing (1:1 texture mapping), run a simpler function without the triangle state tracking.
This will allow further simplification and specialization.
2019-10-27 20:54:36 +01:00
Henrik Rydgård 510229b68b SoftGPU: Detect through-mode rectangles from triangle strips 2019-10-27 20:54:36 +01:00
Henrik Rydgård 3a0804a7dd Start slowly migrating from macros 2019-10-27 20:54:36 +01:00
Unknown W. Brackets 11a8857a7e SoftGPU: Correct clipping for flat shading.
It needs to use the provoking color, regardless of culling or clipping.

Fixes Blade Dancer lighting (see #4140.)
2018-11-22 17:48:55 -08:00
Unknown W. Brackets 817b5d7c1c SoftGPU: Support fog on 3D rectangles. 2018-09-09 23:59:48 -07:00
Unknown W. Brackets e22cc7ef6d SoftGPU: Always clip, without special neg z case.
Depth clamping doesn't change whether it clips.  Also, avoid culling when
a vertex is behind the near plane.
2018-08-05 17:47:05 -07:00
Unknown W. Brackets 77f0499f7f GPU: Rename clipping flag to depth clamp.
It seems to just to depth clamp.  When depth clamp happens, it affects
clipping a little, but only for vertices that needed clamping.
2018-08-05 17:11:51 -07:00
Unknown W. Brackets b94ca6e75e Vulkan: Use depth clamping, where available.
This fixes, for example, Shadow of Destiny, even without the hack.
2017-12-26 16:54:39 -08:00
Unknown W. Brackets ed34cf06b8 SoftGPU: Add a clear mode fast path.
This skips a lot of extra work for clears, which are pretty common.
2017-11-11 21:04:32 -08:00