Repository navigation
Conversation
|
Oh, the shape draw call count, yes, this issue was something we'd have to get into. From a first glance, the change looks okay to me. If draw order, blending and texturing are properly honoured, it shouldn't result in any visual differences. There is an issue with the code though: It uses C++17 features ( |
kblaschke
left a comment
There was a problem hiding this comment.
Code must compile with C++14, but uses C++17 features.
|
Thanks for taking a look, I'll push an update targeting C++14 when I get some time (probably over the weekend) :) |
194cf2b to
869913d
Compare
|
Sorry I've got no time to look at it earlier, will do over the coming days! Triggered the build workflows, if they're okay this will probably be a quick review. |
|
Test results from GLES on a low-end Android TV, in case they help the review. I backported this PR (fills and additive borders, same rules) to the 4.1.8 renderer, which still uses raw VAO/VBOs, and ran it in an Android TV app: Mali-G52 (OpenGL ES 3.2, driver r44p1), 4x Cortex-A73 at 1.39 GHz, preset held at 854x480, fps averaged over 10 s.
Across 18 more presets with 240-1,536 shape instances (after the change only): 15 run at 39-60 fps, two at 29-31, and one at 10 (mother-of-whirl, below).
The 4.1 backport is here: https://github.com/sinisk3r/tv-visualizer/blob/main/patches/projectm/0001-batch-custom-shape-draws.patch. If it's useful for the |
CustomShape::Draw drew every instance with its own shader/uniform setup, buffer upload and glDrawElements. A shape can have up to 1024 instances, and drivers with a high per-draw cost (macOS's OpenGL-over-Metal layer, which starts a new render pass per draw) spend most of the frame on it: a preset with 1300 instances ran at 15 fps on an M-series Mac. Collect the fills of consecutive instances that share a blend mode and texturing into one indexed triangle list and draw them together. Borders are still drawn per instance, after flushing the batch, so the draw order (and the output) is unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A border forced a flush of the fill batch, then one draw per outline pass (four with thickOutline), each with its own buffer upload, so a 1024-instance shape with borders still made ~5000 draw calls per frame. Additive blending is order-independent, so borders of additive instances are now collected as a line list and drawn right after their fills. Non-additive borders keep the exact per-instance order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
869913d to
abdec6f
Compare
|
@kblaschke Sorry, I had committed using the wrong github user, no code changes in this last push just rebased on latest |
|
@sinisk3r Thank you for testing on a |
Hi, a heads-up before anything else: these changes were written by Claude (LLM/AI), not by me, and I don't know the projectM codebase at all. I've tested them visually and checked the frame rate, but I can't vouch for them beyond that. If you don't take AI-generated contributions, or would rather not review code from someone who can't fully explain it, please feel free to close this outright. No hard feelings.
Background
I'm building a small native macOS frontend for libprojectM 4.x for personal use and experimentation here. These patches came out of chasing slow presets there.
Problem
CustomShape::Draw() makes at least one draw call per instance, and shapes can have up to 1024 instances. On macOS, where OpenGL runs on top of Metal and each draw call is expensive, that cost dominates:
Changes
Results (Apple Silicon, macOS):
Things I'm unsure about
Thanks for projectM!