Commit Graph
56 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 7a13881245 DepthRaster: fix host buffer overflows in the depth raster queue
CalculateDepthDraw guarded depthVertexCount_ with vertexCount, which is the
index count - but depthVertexCount_ grows by the number of decoded vertices,
which for an indexed draw can be far larger. Two draws with 6 indices spanning
40000 vertices each therefore passed the check and wrote ~700KB past the end of
depthTransformed_. It also never bounded depthIndexCount_ against depthIndices_
at all, which only has room for 3 indices per vertex slot while draws routinely
produce more. Pass the decoded count in separately and check both.

DepthRasterClipIndexedTriangles duplicated culling-disabled triangles twice: once
in the collect loop (added for Syphon Filter, #21498) and again in the output
stage, which was the older code and should have been removed then. So it emitted
four triangles per input triangle into buffers sized for one, and did twice the
rasterization work it needed to in that mode. Removed the output-stage copy, and
gave the function the output capacity so it stops when full - even at 2x, a
culling-disabled draw over ~32k indices doesn't fit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DCPmm7FoQUoqrbMdhfqhQ2
2026-08-30 22:33:01 +02:00
Henrik Rydgård f60e27a9b7 Just some refactoring of the GPUStatistics struct, and more use of StringWriter 2026-05-29 14:40:31 +02:00
Henrik Rydgård 0b154ca6ef Depth raster: Handle triangles with culling disabled properly. 2026-03-31 18:17:01 -06:00
Henrik Rydgård 8ed898c5e6 GPU: Constify VertexDecoder pointers, remove in some cases 2025-05-14 15:13:59 +02:00
Henrik Rydgård fd88f79d07 CrossSIMD: Fix more no-simd fallbacks. The depth rasterizer now works in TEST_FALLBACK mode. 2025-02-10 11:51:22 -06:00
Henrik Rydgård 206d4d1fea Implement the low-quality depth raster mode, default to it on Android/iOS.
I really can't tell much of a difference in practice...
2024-12-31 11:19:38 +01:00
Henrik Rydgård f85d7db5b1 Comment fixes, buildfix 2024-12-31 02:39:58 +01:00
Henrik Rydgård dee5fe6990 Fix issue in Midnight Club where Z now wrapped around at a distance, after removing the clamp. Might as well cull. 2024-12-31 02:30:05 +01:00
Henrik Rydgård 7ddd7024f4 Revert unintentional change. Warning fix 2024-12-31 02:17:33 +01:00
Henrik Rydgård e0991a7070 DepthRaster: Improved guardband rejection, fixing glitches. 2024-12-31 01:59:15 +01:00
Henrik Rydgård bcab17fcf3 Parallelize triangle setup. However, some glitches appear... 2024-12-31 01:59:11 +01:00
Henrik Rydgård 36c5065d5d Add crude guardband culling to depth rasterizer 2024-12-31 01:59:11 +01:00
Henrik Rydgård de09dec9d1 Move branches out of triangle setup 2024-12-31 01:41:25 +01:00
Henrik Rydgård 373569bf64 More prep. Add triangle loop. 2024-12-31 01:41:22 +01:00
Henrik Rydgård 2eed309d29 Simplify more 2024-12-31 01:41:22 +01:00
Henrik Rydgård d435945b7c Simplify 2024-12-31 01:41:22 +01:00
Henrik Rydgård 69b35e9146 Inline edge calculations 2024-12-31 01:41:05 +01:00
Henrik Rydgård 1195c630c3 Some variable renaming 2024-12-29 14:03:06 +01:00
Henrik Rydgård f70889ad49 Better triangle area calculation, thanks fp64 for the reminder 2024-12-29 13:45:01 +01:00
Henrik Rydgård d325bb872b Prepare for tiled depth raster 2024-12-29 10:05:32 +01:00
Henrik Rydgård ef934df0f2 Compute and cull by triangle area early before writing 4-groups of triangles 2024-12-29 01:21:16 +01:00
Henrik Rydgård e8786fc401 Cull 4-groups of triangles early 2024-12-29 01:12:53 +01:00
Henrik Rydgård 4ef3ac474a Just minor cleanup and prep in depth raster 2024-12-28 23:16:59 +01:00
Henrik Rydgård 1e8eb88bf0 Unify the ends of the two depth draw paths 2024-12-28 19:22:23 +01:00
Henrik Rydgård 66926e28c1 Simplify / fix through mode triangles 2024-12-28 18:51:37 +01:00
Henrik Rydgård 3c3dfe5273 Reorganize depth raster draw state handling 2024-12-28 18:51:34 +01:00
Henrik Rydgård 8b10ee3937 Depth Z: Add a stat for Z-culling, correctly distinguish the small/backface stats 2024-12-28 18:45:03 +01:00
Henrik Rydgård 8c069917b5 Depth raster optimizations: Merge viewport into projection matrix, prepare for further SIMD-ification (#19769)
* Remove some old redundant reports

* Fix scissor off by one

* More CrossSIMD

* Move the viewport scale out to the proj matrix

* DepthRaster: Also merge the viewport translation into the projection matrix.

* Depth raster: Do the triangle clipping in batches of 4 triangles

* Cleanup
2024-12-28 10:36:39 +01:00
Henrik Rydgård cc040ab251 Depth raster: Bugfix, minor opt (#19768)
* Correct two errors in CrossSIMD.h, thanks hiroyuki177

Fixes #19767

* DepthRaster: Merge offset into viewport X/Y
2024-12-26 20:23:52 +01:00
Henrik Rydgård 0e59cd7641 DepthRaster: Fix typo breaking LESS depth comparison mode on x86(64) 2024-12-24 23:26:32 +01:00
Henrik Rydgård b39a09e87b Specialize DepthRasterTriangle for the comparison modes using templating. 2024-12-22 19:24:12 +01:00
Henrik Rydgård ab088cf158 Depth raster: Clip rects to scissor too. Fixes some crashes 2024-12-22 14:14:55 +01:00
Henrik Rydgård 3ccb01b09c Depth Raster: Add more stats, discard triangles with < 10 px area. Still good results. 2024-12-22 10:32:20 +01:00
Henrik Rydgård 19434ff303 Keep the depth in floating point to save some conversions 2024-12-22 10:32:19 +01:00
Henrik Rydgård 0629a98f97 Add some depth raster stats 2024-12-22 10:32:15 +01:00
Henrik Rydgård d53635e096 Optimize the triangle inner loop a little more 2024-12-22 10:32:15 +01:00
Henrik Rydgård 2371fdfedd Rework depth raster to fully support software transform 2024-12-21 21:22:22 +01:00
Henrik Rydgård 80cb57f8bb Cleanup 2024-12-21 14:28:01 +01:00
Henrik Rydgård 5df88fc1aa Convert the rect implementation to CrossSIMD 2024-12-21 14:28:01 +01:00
Henrik Rydgård 73ae6da757 Reimplement the depth rasterizer with SIMD. 2024-12-21 14:28:00 +01:00
Henrik Rydgård d1b50ea543 Comment 2024-12-21 14:28:00 +01:00
Henrik Rydgård ad1809875a Minor sign check optimization 2024-12-21 14:28:00 +01:00
Henrik Rydgård f886578c0e DepthRaster: Fix backface culling 2024-12-21 14:28:00 +01:00
Henrik Rydgård a344d0225f DepthRaster: Fix bug where we used the wrong vertex count. 2024-12-21 14:28:00 +01:00
Henrik Rydgård 820e7369b9 Speed up DepthRasterClipIndexedTriangles with CrossSIMD 2024-12-21 14:28:00 +01:00
Henrik Rydgård 67078d439b Depth raster: Switch to a SoA data layout for the screen space verts 2024-12-21 14:28:00 +01:00
Henrik Rydgård 6a1010afb0 Use CrossSIMD to optimize DecodeAndTransformForDepthRaster
Checked the output, the generated assembly is great!
2024-12-21 14:28:00 +01:00
Henrik Rydgård bdf4b69207 Warning fixes, minor cleanup 2024-12-21 14:28:00 +01:00
Henrik Rydgård bdb5f3a91b Reorganize the depth vertex pipeline for future optimizations 2024-12-21 14:27:59 +01:00
Henrik Rydgård dd31518272 DepthRaster: Merge the decode and transform steps 2024-12-21 14:27:59 +01:00