From 8f792db9fd48953376ca8603f5b9bad39372624e Mon Sep 17 00:00:00 2001 From: Xiaoji Chen Date: Thu, 25 Apr 2024 06:03:24 -0700 Subject: [PATCH] fix(webgl): reset buffer binding in WEBGLVertexArray.setBuffer (#2075) --- .../webgl/src/adapter/resources/webgl-transform-feedback.ts | 2 +- modules/webgl/src/adapter/resources/webgl-vertex-array.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/webgl/src/adapter/resources/webgl-transform-feedback.ts b/modules/webgl/src/adapter/resources/webgl-transform-feedback.ts index 73102e779d..9c4bc97c32 100644 --- a/modules/webgl/src/adapter/resources/webgl-transform-feedback.ts +++ b/modules/webgl/src/adapter/resources/webgl-transform-feedback.ts @@ -56,7 +56,7 @@ export class WEBGLTransformFeedback extends TransformFeedback { end(): void { this.gl.endTransformFeedback(); - if (!this.bindOnUse) { + if (this.bindOnUse) { this._unbindBuffers(); } this.gl.bindTransformFeedback(GL.TRANSFORM_FEEDBACK, null); diff --git a/modules/webgl/src/adapter/resources/webgl-vertex-array.ts b/modules/webgl/src/adapter/resources/webgl-vertex-array.ts index 1759bc6ae7..863a2713ef 100644 --- a/modules/webgl/src/adapter/resources/webgl-vertex-array.ts +++ b/modules/webgl/src/adapter/resources/webgl-vertex-array.ts @@ -97,6 +97,9 @@ export class WEBGLVertexArray extends VertexArray { // Attaches ARRAY_BUFFER with specified buffer format to location this.device.gl.vertexAttribPointer(location, size, type, normalized, stride, offset); } + // Clear binding - keeping it may cause [.WebGL-0x12804417100] + // GL_INVALID_OPERATION: A transform feedback buffer that would be written to is also bound to a non-transform-feedback target + this.device.gl.bindBuffer(GL.ARRAY_BUFFER, null); // Mark as non-constant this.device.gl.enableVertexAttribArray(location);