From e7fe1de5a74ab2685a3237865eb80ca35dc69c6b Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 10 Sep 2024 21:51:24 +0000 Subject: [PATCH 01/22] Add uniformMatrix4fv to ProgramWebGL --- lib/webgl/ProgramWebGL.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/webgl/ProgramWebGL.ts b/lib/webgl/ProgramWebGL.ts index 292cead9..beee8cdd 100644 --- a/lib/webgl/ProgramWebGL.ts +++ b/lib/webgl/ProgramWebGL.ts @@ -357,6 +357,11 @@ export class ProgramWebGL implements IProgram { this._gl.uniform4fv(location, value); } + public uniformMatrix4fv(type: number, transpose: boolean, matrixRawData:Float32Array):void{ + const location = this.getUniformLocation(type) + this._gl.uniformMatrix4fv(type, transpose, matrixRawData) + } + public dispose(): void { // not real delete progs, because maybe will be recreted in nearest future // then progs in prety small, we can store 1000 + without overhead From dcdc834e5820ffd5e4c84db2cb320043ac3eec40 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Fri, 13 Sep 2024 21:49:14 +0000 Subject: [PATCH 02/22] AGALTokenizer fix --- lib/aglsl/AGALTokenizer.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/aglsl/AGALTokenizer.ts b/lib/aglsl/AGALTokenizer.ts index 52c1f2a4..c94b134c 100644 --- a/lib/aglsl/AGALTokenizer.ts +++ b/lib/aglsl/AGALTokenizer.ts @@ -12,17 +12,16 @@ export class AGALTokenizer { } public decribeAGALPart(array: ByteArray | Part): Description { - if (array instanceof ByteArray) { - return this.decribeAGALByteArray(array); - } - - const desc = this.decribeAGALByteArray(array.data); - desc.native = array.native; - - return desc; + if (array instanceof Part) { + const desc = this.decribeAGALByteArray(array.data); + desc.native = array.native; + return desc; + } else + return this.decribeAGALByteArray(array); } public decribeAGALByteArray(bytes: ByteArray): Description { + bytes.position = 0 const header: Header = new Header(); if (bytes.readUnsignedByte() != 0xa0) { @@ -57,6 +56,7 @@ 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(); From d8710fb7135251fdcf6292fa5513af4a359f7af8 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Fri, 13 Sep 2024 21:49:22 +0000 Subject: [PATCH 03/22] Gitignore change --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 070094f9..03c3e8dc 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ npm-debug.log # Misc deploy_key -deploy_key.pub \ No newline at end of file +deploy_key.pub +.vscode/settings.json From a20f073df0ae545f6604088c7db14bf4430ec866 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Fri, 13 Sep 2024 21:55:50 +0000 Subject: [PATCH 04/22] Fix typo --- lib/webgl/ProgramWebGL.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webgl/ProgramWebGL.ts b/lib/webgl/ProgramWebGL.ts index beee8cdd..31c9fd56 100644 --- a/lib/webgl/ProgramWebGL.ts +++ b/lib/webgl/ProgramWebGL.ts @@ -359,7 +359,7 @@ export class ProgramWebGL implements IProgram { public uniformMatrix4fv(type: number, transpose: boolean, matrixRawData:Float32Array):void{ const location = this.getUniformLocation(type) - this._gl.uniformMatrix4fv(type, transpose, matrixRawData) + this._gl.uniformMatrix4fv(location, transpose, matrixRawData) } public dispose(): void { From 57adcbf2896b2f937e819a145fe5339c53308e0d Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Mon, 16 Sep 2024 17:38:48 +0000 Subject: [PATCH 05/22] 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 c94b134c..a3a9cb10 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 31c9fd56..08e2b5f0 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 { From 154b9d4ffc3a71fb4440a8e89e38281dd983de6c Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 17 Sep 2024 13:48:17 +0000 Subject: [PATCH 06/22] Remove uniformMatrix4fv --- lib/aglsl/AGALTokenizer.ts | 4 ++-- lib/webgl/ProgramWebGL.ts | 20 -------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/lib/aglsl/AGALTokenizer.ts b/lib/aglsl/AGALTokenizer.ts index a3a9cb10..1f9e0a5d 100644 --- a/lib/aglsl/AGALTokenizer.ts +++ b/lib/aglsl/AGALTokenizer.ts @@ -17,11 +17,11 @@ export class AGALTokenizer { desc.native = array.native; return desc; } else - return this.decribeAGALByteArray(array); + return this.decribeAGALByteArray(array); } public decribeAGALByteArray(bytes: ByteArray): Description { - bytes.position = 0 + bytes.position = 0; const header: Header = new Header(); if (bytes.readUnsignedByte() != 0xa0) { diff --git a/lib/webgl/ProgramWebGL.ts b/lib/webgl/ProgramWebGL.ts index 08e2b5f0..292cead9 100644 --- a/lib/webgl/ProgramWebGL.ts +++ b/lib/webgl/ProgramWebGL.ts @@ -357,26 +357,6 @@ export class ProgramWebGL implements IProgram { this._gl.uniform4fv(location, value); } - public uniformMatrix4fv(type: number, transpose: boolean, value:Float32Array):void{ - const location = this.getUniformLocation(type) - - 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 { // not real delete progs, because maybe will be recreted in nearest future // then progs in prety small, we can store 1000 + without overhead From 55f77422c836a8fe87e5441bb9022cc3cbe9d9e9 Mon Sep 17 00:00:00 2001 From: Fancy2209 <64917206+Fancy2209@users.noreply.github.com> Date: Tue, 24 Sep 2024 13:18:54 +0000 Subject: [PATCH 07/22] Allow unsafe Vertex Buffer Attributes (allows no program to be set) --- lib/webgl/ContextWebGL.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/webgl/ContextWebGL.ts b/lib/webgl/ContextWebGL.ts index 51e240e9..82e95c0c 100644 --- a/lib/webgl/ContextWebGL.ts +++ b/lib/webgl/ContextWebGL.ts @@ -744,11 +744,18 @@ export class ContextWebGL implements IContextGL { } public setVertexBufferAt( - index: number, buffer: VertexBufferWebGL, bufferOffset: number = 0, format: number = 4 + index: number, buffer: VertexBufferWebGL, bufferOffset: number = 0, format: number = 4, safeAttributeLocation:boolean = true ): void { this.stateChangeCallback && this.stateChangeCallback('setVertexBufferAt'); + if(index < 0) return; + + var location: number + + if(safeAttributeLocation) + location = this._currentProgram ? this._currentProgram.getAttribLocation(index) : -1 + else + location = index; - const location = this._currentProgram ? this._currentProgram.getAttribLocation(index) : -1; const gl = this._gl; // when we try bind any buffers without VAO we should unbound VAO @@ -763,16 +770,17 @@ export class ContextWebGL implements IContextGL { // FOR OSx - IT CAN BE DIFFERENT if (!buffer) { - if (location > -1) { + //if (location > -1) { gl.disableVertexAttribArray(index); - } + gl.bindBuffer(gl.ARRAY_BUFFER, null); + //} return; } //buffer may not have changed if concatenated buffers are being used if (this._currentArrayBuffer != buffer || (this.hasVao && this._vaoContext._lastBoundedVao)) { this._currentArrayBuffer = buffer; - gl.bindBuffer(gl.ARRAY_BUFFER, buffer ? buffer.glBuffer : null); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); } const properties = GL_MAP.VERTEX_BUF_PROPS[format]; From cad577893cd496fdac9d08c146af79543aacae98 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 24 Sep 2024 14:43:04 +0000 Subject: [PATCH 08/22] Undo Null Changes for now --- lib/webgl/ContextWebGL.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/webgl/ContextWebGL.ts b/lib/webgl/ContextWebGL.ts index 82e95c0c..980c7d30 100644 --- a/lib/webgl/ContextWebGL.ts +++ b/lib/webgl/ContextWebGL.ts @@ -770,17 +770,16 @@ export class ContextWebGL implements IContextGL { // FOR OSx - IT CAN BE DIFFERENT if (!buffer) { - //if (location > -1) { + if (location > -1) { gl.disableVertexAttribArray(index); - gl.bindBuffer(gl.ARRAY_BUFFER, null); - //} + } return; } //buffer may not have changed if concatenated buffers are being used if (this._currentArrayBuffer != buffer || (this.hasVao && this._vaoContext._lastBoundedVao)) { this._currentArrayBuffer = buffer; - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer ? buffer.glBuffer : null); } const properties = GL_MAP.VERTEX_BUF_PROPS[format]; From 48db95417c80492fba8e16aaebb68fff84bdef03 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 24 Sep 2024 15:23:06 +0000 Subject: [PATCH 09/22] Fix null stuff --- lib/webgl/ContextWebGL.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/webgl/ContextWebGL.ts b/lib/webgl/ContextWebGL.ts index 980c7d30..e557c247 100644 --- a/lib/webgl/ContextWebGL.ts +++ b/lib/webgl/ContextWebGL.ts @@ -770,16 +770,17 @@ export class ContextWebGL implements IContextGL { // FOR OSx - IT CAN BE DIFFERENT if (!buffer) { - if (location > -1) { + //if (location > -1) { gl.disableVertexAttribArray(index); - } + //gl.bindBuffer(gl.ARRAY_BUFFER, null); + //} return; } //buffer may not have changed if concatenated buffers are being used if (this._currentArrayBuffer != buffer || (this.hasVao && this._vaoContext._lastBoundedVao)) { this._currentArrayBuffer = buffer; - gl.bindBuffer(gl.ARRAY_BUFFER, buffer ? buffer.glBuffer : null); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer.glBuffer); } const properties = GL_MAP.VERTEX_BUF_PROPS[format]; From 4a8d63c980813e3c7f9c68623d7052e8186d7243 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 24 Sep 2024 15:27:53 +0000 Subject: [PATCH 10/22] Additional null fix --- lib/webgl/ContextWebGL.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/webgl/ContextWebGL.ts b/lib/webgl/ContextWebGL.ts index e557c247..75f31370 100644 --- a/lib/webgl/ContextWebGL.ts +++ b/lib/webgl/ContextWebGL.ts @@ -747,7 +747,6 @@ export class ContextWebGL implements IContextGL { index: number, buffer: VertexBufferWebGL, bufferOffset: number = 0, format: number = 4, safeAttributeLocation:boolean = true ): void { this.stateChangeCallback && this.stateChangeCallback('setVertexBufferAt'); - if(index < 0) return; var location: number @@ -770,10 +769,10 @@ export class ContextWebGL implements IContextGL { // FOR OSx - IT CAN BE DIFFERENT if (!buffer) { - //if (location > -1) { + if (location > -1) { gl.disableVertexAttribArray(index); //gl.bindBuffer(gl.ARRAY_BUFFER, null); - //} + } return; } From 79c814c6755c8b45ad4ac5a50e7f0f52bff38239 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 1 Oct 2024 13:46:56 +0000 Subject: [PATCH 11/22] undo accident --- lib/webgl/ContextWebGL.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webgl/ContextWebGL.ts b/lib/webgl/ContextWebGL.ts index 75f31370..4d62e679 100644 --- a/lib/webgl/ContextWebGL.ts +++ b/lib/webgl/ContextWebGL.ts @@ -779,7 +779,7 @@ export class ContextWebGL implements IContextGL { //buffer may not have changed if concatenated buffers are being used if (this._currentArrayBuffer != buffer || (this.hasVao && this._vaoContext._lastBoundedVao)) { this._currentArrayBuffer = buffer; - gl.bindBuffer(gl.ARRAY_BUFFER, buffer.glBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer ? buffer.glBuffer : 1); } const properties = GL_MAP.VERTEX_BUF_PROPS[format]; From 32ff8d0ec5507e6ee88c905d704f8df250702e04 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Thu, 3 Oct 2024 18:01:09 +0000 Subject: [PATCH 12/22] Add profiles --- lib/base/ContextGLProfile.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/base/ContextGLProfile.ts b/lib/base/ContextGLProfile.ts index 776ee8b0..593e4b87 100644 --- a/lib/base/ContextGLProfile.ts +++ b/lib/base/ContextGLProfile.ts @@ -2,5 +2,9 @@ export enum ContextGLProfile { BASELINE, BASELINE_CONSTRAINED, - BASELINE_EXTENDED + BASELINE_EXTENDED, + STANDARD, + STANDARD_CONSTRAINED, + STANDARD_EXTENDED, + ENHANCED } \ No newline at end of file From 1be2d80a29b7dda811d17b131c92ee2f8cdd2103 Mon Sep 17 00:00:00 2001 From: Fancy2209 <64917206+Fancy2209@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:13:01 +0000 Subject: [PATCH 13/22] undo uneeded changes --- lib/webgl/ContextWebGL.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/webgl/ContextWebGL.ts b/lib/webgl/ContextWebGL.ts index 4d62e679..2a3ac492 100644 --- a/lib/webgl/ContextWebGL.ts +++ b/lib/webgl/ContextWebGL.ts @@ -747,14 +747,8 @@ export class ContextWebGL implements IContextGL { index: number, buffer: VertexBufferWebGL, bufferOffset: number = 0, format: number = 4, safeAttributeLocation:boolean = true ): void { this.stateChangeCallback && this.stateChangeCallback('setVertexBufferAt'); - - var location: number - - if(safeAttributeLocation) - location = this._currentProgram ? this._currentProgram.getAttribLocation(index) : -1 - else - location = index; - + + const location = safeAttributeLocation ? this._currentProgram ? this._currentProgram.getAttribLocation(index) : -1 : index; const gl = this._gl; // when we try bind any buffers without VAO we should unbound VAO @@ -771,7 +765,6 @@ export class ContextWebGL implements IContextGL { if (!buffer) { if (location > -1) { gl.disableVertexAttribArray(index); - //gl.bindBuffer(gl.ARRAY_BUFFER, null); } return; } @@ -779,7 +772,7 @@ export class ContextWebGL implements IContextGL { //buffer may not have changed if concatenated buffers are being used if (this._currentArrayBuffer != buffer || (this.hasVao && this._vaoContext._lastBoundedVao)) { this._currentArrayBuffer = buffer; - gl.bindBuffer(gl.ARRAY_BUFFER, buffer ? buffer.glBuffer : 1); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer ? buffer.glBuffer : null); } const properties = GL_MAP.VERTEX_BUF_PROPS[format]; From 14bbb01ddc52dea853f8bfe23ee05205b48e8731 Mon Sep 17 00:00:00 2001 From: Fancy2209 Date: Fri, 28 Mar 2025 22:08:03 -0100 Subject: [PATCH 14/22] Fixed by eslint --- lib/base/IContextGL.ts | 2 +- lib/webgl/ContextWebGL.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/base/IContextGL.ts b/lib/base/IContextGL.ts index 651fbdf5..bd027468 100644 --- a/lib/base/IContextGL.ts +++ b/lib/base/IContextGL.ts @@ -99,7 +99,7 @@ export interface IContextGL setTextureAt(sampler: number, texture: ITextureBase); - setVertexBufferAt(index: number, buffer: IVertexBuffer, bufferOffset?: number, format?: number); + setVertexBufferAt(index: number, buffer: IVertexBuffer, bufferOffset?: number, format?: number, safeAttributeLocation?: boolean); setRenderToTexture( target: ITextureBase, diff --git a/lib/webgl/ContextWebGL.ts b/lib/webgl/ContextWebGL.ts index 2a3ac492..9f7f5ccb 100644 --- a/lib/webgl/ContextWebGL.ts +++ b/lib/webgl/ContextWebGL.ts @@ -25,6 +25,7 @@ import { Settings } from '../Settings'; import { FenceContextWebGL } from './FenceContextWebGL'; import * as GL_MAP from './ConstantsWebGL'; import { StatsWebGL } from './StatsWebGL'; +import { IVertexBuffer } from '../base/IVertexBuffer'; let _DEBUG_renderMode: '' | 'line' = ''; @@ -744,10 +745,10 @@ export class ContextWebGL implements IContextGL { } public setVertexBufferAt( - index: number, buffer: VertexBufferWebGL, bufferOffset: number = 0, format: number = 4, safeAttributeLocation:boolean = true + index: number, buffer: VertexBufferWebGL, bufferOffset: number = 0, format: number = 4, safeAttributeLocation: boolean = true ): void { this.stateChangeCallback && this.stateChangeCallback('setVertexBufferAt'); - + const location = safeAttributeLocation ? this._currentProgram ? this._currentProgram.getAttribLocation(index) : -1 : index; const gl = this._gl; From f5e371567d9f08249782f4f8ad930e576359985a Mon Sep 17 00:00:00 2001 From: Fancy2209 Date: Fri, 28 Mar 2025 22:56:23 -0100 Subject: [PATCH 15/22] Fix error related to vertexContatData in TaskBase --- lib/filters/tasks/TaskBase.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filters/tasks/TaskBase.ts b/lib/filters/tasks/TaskBase.ts index 6c70d3b9..fe13a44f 100644 --- a/lib/filters/tasks/TaskBase.ts +++ b/lib/filters/tasks/TaskBase.ts @@ -10,7 +10,7 @@ import { ContextGLProgramType } from '../../base/ContextGLProgramType'; import { _Stage_ImageBase, Image2D } from '../../image'; export class TaskBase { - protected _vertexConstantData = new Float32Array([ + protected _vertexConstantData:Float32Array = new Float32Array([ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]); From 30f547089796a7e9de6564ca34316b820e8e8e5b Mon Sep 17 00:00:00 2001 From: Fancy2209 Date: Wed, 8 Oct 2025 21:21:19 +0000 Subject: [PATCH 16/22] Fix setTextureAt with null texture --- lib/webgl/TextureContextWebGL.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/webgl/TextureContextWebGL.ts b/lib/webgl/TextureContextWebGL.ts index 2dde5796..09463ce0 100644 --- a/lib/webgl/TextureContextWebGL.ts +++ b/lib/webgl/TextureContextWebGL.ts @@ -109,7 +109,6 @@ export class TextureContextWebGL { public setTextureAt(sampler: number, texture: TextureWebGL): number { const gl = this._context._gl; const samplerState = this._samplerStates[sampler]; - const textureType = GL_MAP.TEXTURE[texture.textureType]; if ((texture || samplerState.type)) { gl.activeTexture(gl.TEXTURE0 + sampler); @@ -132,6 +131,8 @@ export class TextureContextWebGL { return -1; } + const textureType = GL_MAP.TEXTURE[texture.textureType]; + texture._state.id = sampler; this.bindTexture(texture, false, textureType); From 47783b2f993a6532517971e30ed0feedc8a1a9c2 Mon Sep 17 00:00:00 2001 From: Fancy2209 Date: Wed, 8 Oct 2025 21:21:54 +0000 Subject: [PATCH 17/22] Add hack so that firefox works --- lib/webgl/ProgramWebGL.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webgl/ProgramWebGL.ts b/lib/webgl/ProgramWebGL.ts index 292cead9..ee03d12f 100644 --- a/lib/webgl/ProgramWebGL.ts +++ b/lib/webgl/ProgramWebGL.ts @@ -300,7 +300,7 @@ export class ProgramWebGL implements IProgram { const arr: ArrayLike = data; - if (arr.length !== info.size * size) { + if (arr.length !== info.size * size && arr.length !== info.size * size * 2) { throw ( `[ProgramWebGL] Invalid data length for ${name}, expected ${info.size * size}, actual ${arr.length}` From 85832189b21549335e8bb025157a015d9c1051c6 Mon Sep 17 00:00:00 2001 From: Fancy2209 Date: Wed, 8 Oct 2025 21:22:32 +0000 Subject: [PATCH 18/22] Remove safeAttributeLocation bool fromsetVertexBufferAt , as it wasn't needed and causing issues --- lib/base/IContextGL.ts | 2 +- lib/webgl/ContextWebGL.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/base/IContextGL.ts b/lib/base/IContextGL.ts index bd027468..651fbdf5 100644 --- a/lib/base/IContextGL.ts +++ b/lib/base/IContextGL.ts @@ -99,7 +99,7 @@ export interface IContextGL setTextureAt(sampler: number, texture: ITextureBase); - setVertexBufferAt(index: number, buffer: IVertexBuffer, bufferOffset?: number, format?: number, safeAttributeLocation?: boolean); + setVertexBufferAt(index: number, buffer: IVertexBuffer, bufferOffset?: number, format?: number); setRenderToTexture( target: ITextureBase, diff --git a/lib/webgl/ContextWebGL.ts b/lib/webgl/ContextWebGL.ts index 9f7f5ccb..9bdb2786 100644 --- a/lib/webgl/ContextWebGL.ts +++ b/lib/webgl/ContextWebGL.ts @@ -745,11 +745,11 @@ export class ContextWebGL implements IContextGL { } public setVertexBufferAt( - index: number, buffer: VertexBufferWebGL, bufferOffset: number = 0, format: number = 4, safeAttributeLocation: boolean = true + index: number, buffer: VertexBufferWebGL, bufferOffset: number = 0, format: number = 4 ): void { this.stateChangeCallback && this.stateChangeCallback('setVertexBufferAt'); - const location = safeAttributeLocation ? this._currentProgram ? this._currentProgram.getAttribLocation(index) : -1 : index; + const location = this._currentProgram ? this._currentProgram.getAttribLocation(index) : -1; const gl = this._gl; // when we try bind any buffers without VAO we should unbound VAO From dbdcf3b0734cfe28c1ac65af172606db82b3ceb4 Mon Sep 17 00:00:00 2001 From: Fancy2209 Date: Wed, 8 Oct 2025 22:01:06 +0000 Subject: [PATCH 19/22] Add workaround for grabLocationData not finding all uniforms (e.g. Away3D, where fc wasn't beeing found) --- lib/webgl/ProgramWebGL.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/webgl/ProgramWebGL.ts b/lib/webgl/ProgramWebGL.ts index ee03d12f..d2656636 100644 --- a/lib/webgl/ProgramWebGL.ts +++ b/lib/webgl/ProgramWebGL.ts @@ -243,10 +243,18 @@ export class ProgramWebGL implements IProgram { : indexOrName; const info = this._program.uniforms[name]; - if (!info) - return null; - + { + // Needed because sometimes the uniform exists, but grabLocationData didn't find it + let loc = this._gl.getUniformLocation(this.glProgram, name); + if(loc != null) + { + const info = this._gl.getUniform(this.glProgram, loc); + this._program.uniforms[name] = {type: info.type, size: info.size, location: loc}; + return loc; + } + else return null; + } return info.location; } @@ -373,6 +381,6 @@ export class ProgramWebGL implements IProgram { } public get glProgram(): WebGLProgram { - return this._program; + return this._program.program; } } \ No newline at end of file From 9f9eebbe77ec3305a80a2eb1c3f343d1f97a7528 Mon Sep 17 00:00:00 2001 From: Fancy2209 <64917206+Fancy2209@users.noreply.github.com> Date: Thu, 9 Oct 2025 08:45:02 +0000 Subject: [PATCH 20/22] Undo previous commit --- lib/webgl/ProgramWebGL.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/webgl/ProgramWebGL.ts b/lib/webgl/ProgramWebGL.ts index d2656636..058e059d 100644 --- a/lib/webgl/ProgramWebGL.ts +++ b/lib/webgl/ProgramWebGL.ts @@ -247,13 +247,9 @@ export class ProgramWebGL implements IProgram { { // Needed because sometimes the uniform exists, but grabLocationData didn't find it let loc = this._gl.getUniformLocation(this.glProgram, name); + if(loc != null) - { - const info = this._gl.getUniform(this.glProgram, loc); - this._program.uniforms[name] = {type: info.type, size: info.size, location: loc}; - return loc; - } - else return null; + return null; } return info.location; } @@ -383,4 +379,4 @@ export class ProgramWebGL implements IProgram { public get glProgram(): WebGLProgram { return this._program.program; } -} \ No newline at end of file +} From 835a2fc13a0ab2d3820176cfe525e432d9894db6 Mon Sep 17 00:00:00 2001 From: Fancy2209 <64917206+Fancy2209@users.noreply.github.com> Date: Thu, 9 Oct 2025 08:46:52 +0000 Subject: [PATCH 21/22] Update ProgramWebGL.ts --- lib/webgl/ProgramWebGL.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/webgl/ProgramWebGL.ts b/lib/webgl/ProgramWebGL.ts index 058e059d..a42a36ae 100644 --- a/lib/webgl/ProgramWebGL.ts +++ b/lib/webgl/ProgramWebGL.ts @@ -243,14 +243,10 @@ export class ProgramWebGL implements IProgram { : indexOrName; const info = this._program.uniforms[name]; + if (!info) - { - // Needed because sometimes the uniform exists, but grabLocationData didn't find it - let loc = this._gl.getUniformLocation(this.glProgram, name); - - if(loc != null) - return null; - } + return null; + return info.location; } From fc2633241efdb0bff9d9f8c7e5353db52fa24df4 Mon Sep 17 00:00:00 2001 From: Fancy2209 <64917206+Fancy2209@users.noreply.github.com> Date: Thu, 9 Oct 2025 08:48:02 +0000 Subject: [PATCH 22/22] Update ProgramWebGL.ts --- lib/webgl/ProgramWebGL.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/webgl/ProgramWebGL.ts b/lib/webgl/ProgramWebGL.ts index a42a36ae..b274ea06 100644 --- a/lib/webgl/ProgramWebGL.ts +++ b/lib/webgl/ProgramWebGL.ts @@ -243,10 +243,10 @@ export class ProgramWebGL implements IProgram { : indexOrName; const info = this._program.uniforms[name]; - + if (!info) return null; - + return info.location; }