Skip to content

Commit 612a5f9

Browse files
authored
Merge pull request #8510 from processing/webgpu-perf
More WebGPU optimizations
2 parents aa45dc1 + 4182f65 commit 612a5f9

8 files changed

Lines changed: 322 additions & 200 deletions

File tree

src/webgl/p5.Shader.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @requires core
77
*/
88

9+
const TypedArray = Object.getPrototypeOf(Uint8Array);
910
class Shader {
1011
constructor(renderer, vertSrc, fragSrc, options = {}) {
1112
this._renderer = renderer;
@@ -1003,18 +1004,14 @@ class Shader {
10031004
* plane(100, 100);
10041005
* }
10051006
*/
1006-
setUniform(uniformName, rawData) {
1007+
setUniform(uniformName, data) {
10071008
this.init();
10081009

10091010
const uniform = this.uniforms[uniformName];
10101011
if (!uniform) {
10111012
return;
10121013
}
10131014

1014-
const data = this._renderer._mapUniformData
1015-
? this._renderer._mapUniformData(uniform, rawData)
1016-
: rawData;
1017-
10181015
if (uniform.isArray) {
10191016
if (
10201017
uniform._cachedData &&
@@ -1027,7 +1024,7 @@ class Shader {
10271024
} else if (uniform._cachedData && uniform._cachedData === data) {
10281025
return;
10291026
} else {
1030-
if (Array.isArray(data)) {
1027+
if (Array.isArray(data) || data instanceof TypedArray) {
10311028
if (uniform._cachedData && this._renderer._arraysEqual(uniform._cachedData, data)) {
10321029
return;
10331030
}

0 commit comments

Comments
 (0)