Commit 793198b
authored
webgl: populate uniformLocsById on first glUniform (#26846)
PR created with AI assistance.
`$webglGetUniformLocation` reads `program.uniformLocsById` to resolve a
uniform location integer to a `WebGLUniformLocation`. `uniformLocsById`
is reset to `0` by `glLinkProgram` and lazily allocated by
`$webglPrepareUniformLocationsBeforeFirstUse`, but that prepare call
only ran on the `glGetUniformLocation()` path. As a result, calling
`glUniform*()` on a freshly linked program before any
`glGetUniformLocation()` — which is the intended usage with
`-sGL_EXPLICIT_UNIFORM_LOCATION` and `explicit layout(location=N)` —
silently no-opped: `$webglGetUniformLocation` read
`uniformLocsById[location]` off the integer `0`, returned `undefined`,
and `GLctx.uniform*()` dropped the call with no error.
Fix: call `$webglPrepareUniformLocationsBeforeFirstUse(p)` at the top of
`$webglGetUniformLocation`, inside the `GL_TRACK_ERRORS` guard. The
prepare call is idempotent (guards on `!uniformLocsById`), so the
steady-state overhead is a single property read.
Adds `browser.test_webgl_uniform_before_get_location` with two
parameterizations (default and `-sGL_ASSERTIONS`).
Fixes: #266721 parent 4aefc6e commit 793198b
3 files changed
Lines changed: 106 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
606 | | - | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
607 | 609 | | |
608 | 610 | | |
609 | 611 | | |
| |||
2171 | 2173 | | |
2172 | 2174 | | |
2173 | 2175 | | |
| 2176 | + | |
2174 | 2177 | | |
2175 | 2178 | | |
2176 | 2179 | | |
| |||
2182 | 2185 | | |
2183 | 2186 | | |
2184 | 2187 | | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
2185 | 2196 | | |
2186 | 2197 | | |
2187 | 2198 | | |
| |||
3865 | 3876 | | |
3866 | 3877 | | |
3867 | 3878 | | |
3868 | | - | |
| 3879 | + | |
3869 | 3880 | | |
3870 | 3881 | | |
3871 | 3882 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1235 | 1235 | | |
1236 | 1236 | | |
1237 | 1237 | | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
1238 | 1246 | | |
1239 | 1247 | | |
1240 | 1248 | | |
| |||
0 commit comments