Describe how internal array sizes affect frame rate

Vectornaut 2024-08-27 07:07:07 +00:00
parent 3be9c4479c
commit 7826d7b47c

@ -6,8 +6,19 @@ Right now, we're drawing all the spheres in a single fragment shader. For each p
## Performance limits ## 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/). * 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. * **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 ## References