From 88209df9dc4190d0f04b0fd5165073d469b7a520 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Mon, 16 Sep 2024 17:38:48 +0000 Subject: [PATCH] Finish up uniformMatrix4fv --- lib/aglsl/AGALTokenizer.ts | 1 - lib/webgl/ProgramWebGL.ts | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/aglsl/AGALTokenizer.ts b/lib/aglsl/AGALTokenizer.ts index c94b134..a3a9cb1 100644 --- a/lib/aglsl/AGALTokenizer.ts +++ b/lib/aglsl/AGALTokenizer.ts @@ -56,7 +56,6 @@ export class AGALTokenizer { const desc: Description = new Description(); const tokens: Token[] = []; while (bytes.position < bytes.length) { - console.log(bytes.position) const token: Token = new Token(); token.opcode = bytes.readUnsignedInt(); diff --git a/lib/webgl/ProgramWebGL.ts b/lib/webgl/ProgramWebGL.ts index 31c9fd5..08e2b5f 100644 --- a/lib/webgl/ProgramWebGL.ts +++ b/lib/webgl/ProgramWebGL.ts @@ -357,9 +357,24 @@ export class ProgramWebGL implements IProgram { this._gl.uniform4fv(location, value); } - public uniformMatrix4fv(type: number, transpose: boolean, matrixRawData:Float32Array):void{ + public uniformMatrix4fv(type: number, transpose: boolean, value:Float32Array):void{ const location = this.getUniformLocation(type) - this._gl.uniformMatrix4fv(location, transpose, matrixRawData) + + if (!location) { + return; + } + + if (Settings.ENABLE_UNIFORM_CACHE) { + const hash = this._needCache(type * 4, value); + + // return undef hash if not require to uppload; + if (hash === void 0) { + return; + } + this._uniformCache[type * 4] = hash; + } + + this._gl.uniformMatrix4fv(location, transpose, value) } public dispose(): void {