From 7826d7b47c16770cc4dff62b523a68336306e420 Mon Sep 17 00:00:00 2001 From: Vectornaut Date: Tue, 27 Aug 2024 07:07:07 +0000 Subject: [PATCH] Describe how internal array sizes affect frame rate --- Display.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Display.md b/Display.md index e7c4699..6697511 100644 --- a/Display.md +++ b/Display.md @@ -6,8 +6,19 @@ Right now, we're drawing all the spheres in a single fragment shader. For each p ## Performance limits -* **Array size.** As of commit `a34fd0f`, the SPHERE_MAX array size seems to affect frame rate a lot, even though we should only be using the first few elements of each array. Not sure whether this is coming from a depth-sorting bug, a memory handling detail, or something else. +* **Array size.** As of commit `a34fd0f`, the `SPHERE_MAX` array size seems to affect frame rate a lot, even though we should only be using the first few elements of each array. Not sure whether this is coming from a depth-sorting bug, a memory handling detail, or something else. * The logistics of initializing the arrays and working around register limits could be the problem, as described in [this forum post](http://gamedev.net/forums/topic/688607-glsl-shader-slow-when-having-too-big-arrays/5342186/). + * Commit `ec48592` adds a crude frame time monitor, so we can see how changes affect timing. In commit `f62f44b`, we can adjust the size of the internal fragment arrays (controlled by `SPHERE_MAX_INTERNAL`) while keeping the size of the uniforms (controlled by `SPHERE_MAX_UNIFORM`) at `12`. The rough measurements below confirm that the internal array size can affect frame rate a lot, even though we only use the first three spheres' worth of elements. +`SPHERE_MAX_INTERNAL` | Frame time (ms) +-----|----- +3 | 16.7 +4 | 16.7 +5 | 16.7 +6 | 16.8 +8 | 19.7 +10 | 22.4 +12 | 25.1 +14 | 28.6 * **Shader variables.** Browsers seem to limit the number of variables that fragment shaders can store. For example, see this [vulnerability report](https://issues.chromium.org/issues/40067239) and [code review](https://chromium-review.googlesource.com/c/angle/angle/+/4503753) for Chromium. This limit doesn't seem to be part of the OpenGL standard, so it's hard to pin down. ## References