From 2adfac21871ead46661f706ed196ed6c241bb888 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 10 Sep 2024 21:51:24 +0000 Subject: [PATCH 01/13] 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 06d74a13ef652151a6d9b294c5fee761fdc11995 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Fri, 13 Sep 2024 21:49:14 +0000 Subject: [PATCH 02/13] 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 6d43e5b92cdc7675216e2d542c15024b64160cce Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Fri, 13 Sep 2024 21:49:22 +0000 Subject: [PATCH 03/13] 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 41f39fc88dd57d0f23d3f7c99d980687a7da9295 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Fri, 13 Sep 2024 21:55:50 +0000 Subject: [PATCH 04/13] 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 88209df9dc4190d0f04b0fd5165073d469b7a520 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Mon, 16 Sep 2024 17:38:48 +0000 Subject: [PATCH 05/13] 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 45858c61211a3210c9944c657e008212dc6c93ba Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 17 Sep 2024 13:48:17 +0000 Subject: [PATCH 06/13] 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 87ebfb7aab3602b8486eb785020ed97642d5db46 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/13] 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 4956b59c3635644c0d8d80b67330f2045aef0ad5 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 24 Sep 2024 14:43:04 +0000 Subject: [PATCH 08/13] 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 68a7d4aeaa5fc34ccd15630b876a3206e48b8030 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 24 Sep 2024 15:23:06 +0000 Subject: [PATCH 09/13] 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 80bdf44b7c3a443ecffa11a386af4818ddf892fa Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 24 Sep 2024 15:27:53 +0000 Subject: [PATCH 10/13] 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 602aad7f9ec0696d97ee86d3c8b4da6059b703f4 Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Tue, 1 Oct 2024 13:46:56 +0000 Subject: [PATCH 11/13] 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 af7520810fc288090b6615b18ec69b0108ba58ad Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Thu, 3 Oct 2024 18:01:09 +0000 Subject: [PATCH 12/13] 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 7c927c4c3cf4f1ed96a0d16688d0f9c57d614a3b 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/13] 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];