فهرست منبع

Fix command encoder created when not necessary

Popov72 4 سال پیش
والد
کامیت
bb42826707
1فایلهای تغییر یافته به همراه7 افزوده شده و 6 حذف شده
  1. 7 6
      src/Engines/WebGPU/webgpuTextureHelper.ts

+ 7 - 6
src/Engines/WebGPU/webgpuTextureHelper.ts

@@ -655,15 +655,10 @@ export class WebGPUTextureHelper {
         }
     }
 
+    // TODO WEBGPU handle data source not being in the same format than the destination texture?
     public updateTexture(imageBitmap: ImageBitmap | Uint8Array, gpuTexture: GPUTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex: number = 0, mipLevel: number = 0, invertY = false, premultiplyAlpha = false, offsetX = 0, offsetY = 0,
         commandEncoder?: GPUCommandEncoder): void
     {
-        const useOwnCommandEncoder = commandEncoder === undefined;
-
-        if (useOwnCommandEncoder) {
-            commandEncoder = this._device.createCommandEncoder({});
-        }
-
         const blockInformation = this._getBlockInformationFromFormat(format);
 
         const textureCopyView: GPUTextureCopyView = {
@@ -689,6 +684,12 @@ export class WebGPUTextureHelper {
             const aligned = Math.ceil(bytesPerRow / 256) * 256 === bytesPerRow;
 
             if (aligned) {
+                const useOwnCommandEncoder = commandEncoder === undefined;
+
+                if (useOwnCommandEncoder) {
+                    commandEncoder = this._device.createCommandEncoder({});
+                }
+
                 const buffer = this._bufferManager.createRawBuffer(imageBitmap.byteLength, GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC, true);
 
                 const arrayBuffer = buffer.getMappedRange();