Explorar el Código

Add missing MRT overrides for webgpu

Popov72 hace 4 años
padre
commit
ab842d5f8a
Se han modificado 1 ficheros con 26 adiciones y 0 borrados
  1. 26 0
      src/Engines/webgpuEngine.ts

+ 26 - 0
src/Engines/webgpuEngine.ts

@@ -2929,6 +2929,32 @@ export class WebGPUEngine extends Engine {
     }
 
     /**
+     * Restores the WebGPU state to only draw on the main color attachment
+     */
+    public restoreSingleAttachment(): void {
+        this.bindAttachments([]);
+    }
+
+    /**
+     * Creates a layout object to draw/clear on specific textures in a MRT
+     * @param textureStatus textureStatus[i] indicates if the i-th is active
+     * @returns A layout to be fed to the engine, calling `bindAttachments`.
+     */
+    public buildTextureLayout(textureStatus: boolean[]): number[] {
+        const result = [];
+
+        for (let i = 0; i < textureStatus.length; i++) {
+            if (textureStatus[i]) {
+                result.push(i + 1);
+            } else {
+                result.push(0);
+            }
+        }
+
+        return result;
+    }
+
+    /**
      * Select a subsets of attachments to draw to.
      * @param attachments index of attachments
      */