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S,EAAG,UAER,EAAkB,KAAK,cAAc,cACrC,EAAO,KAAK,MAAK,WACT,GACA,GAER,KAEW,OAAX,EACA,MAAO,CAAC,EAAc,MAE1B,KADA,EAAU,EAAQ,WAAW,WAEzB,MAAO,CAAC,EAAc,MAC1B,EAAG,MAAQ,EACf,KAAK,EAED,OADA,EAAG,KAAK,KAAK,CAAC,EAAG,EAAG,CAAE,IACf,CAAC,EAAa,WAAW,KAAK,cAAc,qBACvD,KAAK,EAGL,KAAK,EAED,OADA,EAAG,OACI,CAAC,EAAa,GACzB,KAAK,EAEL,MAAO,CAAC,EAAc,IAAI,cAAc,EAAS,EAAQ,EAAS,EAAS,eAEnF,GACJ,GACJ,EACO,CACX,CAtE6C,GAwEzC,OAAwB,SAAU,GAElC,SAAS,EAAO,QACI,IAAZ,IAAsB,EAAU,CAAC,GACrC,IAAI,EAAQ,EAAO,KAAK,OAAS,KAGjC,OAFA,EAAM,QAAU,EAChB,EAAM,KAAO,gBACN,CACX,CAOA,OAdA,MAAM,UAAU,EAAQ,GAQxB,EAAO,UAAU,KAAO,SAAU,GAC9B,KAAK,QAAQ,mBAAqB,IAAI,yBAAyB,MAAM,SAAS,CAAE,mBAAoB,+BAAiC,KAAK,SAAU,EACxJ,EACA,EAAO,UAAU,QAAU,kBAChB,KAAK,QAAQ,kBACxB,EACO,CACX,CAhB2B,CAgBzB,MAAM,wBAER,QAAQ,OAAS,OACjB,QAAQ,yBAA2B","file":"/npm/@antv/g-plugin-webgpu-device@1.9.17/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/@antv/g-plugin-webgpu-device@1.9.17/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nvar tslib = require('tslib');\nvar gLite = require('@antv/g-lite');\nvar gPluginDeviceRenderer = require('@antv/g-plugin-device-renderer');\nvar util = require('@antv/util');\nvar EventEmitter = require('eventemitter3');\n\nlet wasm;\n\nconst cachedTextDecoder =\n  typeof TextDecoder !== 'undefined'\n    ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true })\n    : {\n        decode: () => {\n          throw Error('TextDecoder not available');\n        },\n      };\n\nif (typeof TextDecoder !== 'undefined') {\n  cachedTextDecoder.decode();\n}\n\nlet cachedUint8Memory0 = null;\n\nfunction getUint8Memory0() {\n  if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {\n    cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);\n  }\n  return cachedUint8Memory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n  ptr = ptr >>> 0;\n  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));\n}\n\nconst heap = new Array(128).fill(undefined);\n\nheap.push(undefined, null, true, false);\n\nlet heap_next = heap.length;\n\nfunction addHeapObject(obj) {\n  if (heap_next === heap.length) heap.push(heap.length + 1);\n  const idx = heap_next;\n  heap_next = heap[idx];\n\n  heap[idx] = obj;\n  return idx;\n}\n\nfunction getObject(idx) {\n  return heap[idx];\n}\n\nfunction dropObject(idx) {\n  if (idx < 132) return;\n  heap[idx] = heap_next;\n  heap_next = idx;\n}\n\nfunction takeObject(idx) {\n  const ret = getObject(idx);\n  dropObject(idx);\n  return ret;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nconst cachedTextEncoder =\n  typeof TextEncoder !== 'undefined'\n    ? new TextEncoder('utf-8')\n    : {\n        encode: () => {\n          throw Error('TextEncoder not available');\n        },\n      };\n\nconst encodeString =\n  typeof cachedTextEncoder.encodeInto === 'function'\n    ? function (arg, view) {\n        return cachedTextEncoder.encodeInto(arg, view);\n      }\n    : function (arg, view) {\n        const buf = cachedTextEncoder.encode(arg);\n        view.set(buf);\n        return {\n          read: arg.length,\n          written: buf.length,\n        };\n      };\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n  if (realloc === undefined) {\n    const buf = cachedTextEncoder.encode(arg);\n    const ptr = malloc(buf.length, 1) >>> 0;\n    getUint8Memory0()\n      .subarray(ptr, ptr + buf.length)\n      .set(buf);\n    WASM_VECTOR_LEN = buf.length;\n    return ptr;\n  }\n\n  let len = arg.length;\n  let ptr = malloc(len, 1) >>> 0;\n\n  const mem = getUint8Memory0();\n\n  let offset = 0;\n\n  for (; offset < len; offset++) {\n    const code = arg.charCodeAt(offset);\n    if (code > 0x7f) break;\n    mem[ptr + offset] = code;\n  }\n\n  if (offset !== len) {\n    if (offset !== 0) {\n      arg = arg.slice(offset);\n    }\n    ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;\n    const view = getUint8Memory0().subarray(ptr + offset, ptr + len);\n    const ret = encodeString(arg, view);\n\n    offset += ret.written;\n  }\n\n  WASM_VECTOR_LEN = offset;\n  return ptr;\n}\n\nlet cachedInt32Memory0 = null;\n\nfunction getInt32Memory0() {\n  if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {\n    cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);\n  }\n  return cachedInt32Memory0;\n}\n/**\n * @param {string} source\n * @param {string} stage\n * @param {boolean} validation_enabled\n * @returns {string}\n */\nfunction glsl_compile(source, stage, validation_enabled) {\n  let deferred3_0;\n  let deferred3_1;\n  try {\n    const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n    const ptr0 = passStringToWasm0(\n      source,\n      wasm.__wbindgen_malloc,\n      wasm.__wbindgen_realloc,\n    );\n    const len0 = WASM_VECTOR_LEN;\n    const ptr1 = passStringToWasm0(\n      stage,\n      wasm.__wbindgen_malloc,\n      wasm.__wbindgen_realloc,\n    );\n    const len1 = WASM_VECTOR_LEN;\n    wasm.glsl_compile(retptr, ptr0, len0, ptr1, len1, validation_enabled);\n    var r0 = getInt32Memory0()[retptr / 4 + 0];\n    var r1 = getInt32Memory0()[retptr / 4 + 1];\n    deferred3_0 = r0;\n    deferred3_1 = r1;\n    return getStringFromWasm0(r0, r1);\n  } finally {\n    wasm.__wbindgen_add_to_stack_pointer(16);\n    wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n  }\n}\n\nasync function __wbg_load(module, imports) {\n  if (typeof Response === 'function' && module instanceof Response) {\n    if (typeof WebAssembly.instantiateStreaming === 'function') {\n      try {\n        return await WebAssembly.instantiateStreaming(module, imports);\n      } catch (e) {\n        if (module.headers.get('Content-Type') != 'application/wasm') {\n          console.warn(\n            '`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n',\n            e,\n          );\n        } else {\n          throw e;\n        }\n      }\n    }\n\n    const bytes = await module.arrayBuffer();\n    return await WebAssembly.instantiate(bytes, imports);\n  } else {\n    const instance = await WebAssembly.instantiate(module, imports);\n\n    if (instance instanceof WebAssembly.Instance) {\n      return { instance, module };\n    } else {\n      return instance;\n    }\n  }\n}\n\nfunction __wbg_get_imports() {\n  const imports = {};\n  imports.wbg = {};\n  imports.wbg.__wbindgen_string_new = function (arg0, arg1) {\n    const ret = getStringFromWasm0(arg0, arg1);\n    return addHeapObject(ret);\n  };\n  imports.wbg.__wbindgen_object_drop_ref = function (arg0) {\n    takeObject(arg0);\n  };\n  imports.wbg.__wbg_log_1d3ae0273d8f4f8a = function (arg0) {\n    console.log(getObject(arg0));\n  };\n  imports.wbg.__wbg_log_576ca876af0d4a77 = function (arg0, arg1) {\n    console.log(getObject(arg0), getObject(arg1));\n  };\n  imports.wbg.__wbindgen_throw = function (arg0, arg1) {\n    throw new Error(getStringFromWasm0(arg0, arg1));\n  };\n\n  return imports;\n}\n\nfunction __wbg_finalize_init(instance, module) {\n  wasm = instance.exports;\n  __wbg_init.__wbindgen_wasm_module = module;\n  cachedInt32Memory0 = null;\n  cachedUint8Memory0 = null;\n\n  return wasm;\n}\n\nasync function __wbg_init(input) {\n  if (wasm !== undefined) return wasm;\n  const imports = __wbg_get_imports();\n\n  if (\n    typeof input === 'string' ||\n    (typeof Request === 'function' && input instanceof Request) ||\n    (typeof URL === 'function' && input instanceof URL)\n  ) {\n    input = fetch(input);\n  }\n\n  const { instance, module } = await __wbg_load(await input, imports);\n\n  return __wbg_finalize_init(instance, module);\n}\n\n/**\n * @see https://github.com/gpuweb/cts/blob/main/src/webgpu/constants.ts\n */\nvar GPUTextureUsage$1;\n(function (GPUTextureUsage) {\n    GPUTextureUsage[GPUTextureUsage[\"COPY_SRC\"] = 1] = \"COPY_SRC\";\n    GPUTextureUsage[GPUTextureUsage[\"COPY_DST\"] = 2] = \"COPY_DST\";\n    GPUTextureUsage[GPUTextureUsage[\"TEXTURE_BINDING\"] = 4] = \"TEXTURE_BINDING\";\n    // SAMPLED= 0x04,\n    GPUTextureUsage[GPUTextureUsage[\"STORAGE_BINDING\"] = 8] = \"STORAGE_BINDING\";\n    GPUTextureUsage[GPUTextureUsage[\"STORAGE\"] = 8] = \"STORAGE\";\n    GPUTextureUsage[GPUTextureUsage[\"RENDER_ATTACHMENT\"] = 16] = \"RENDER_ATTACHMENT\";\n})(GPUTextureUsage$1 || (GPUTextureUsage$1 = {}));\n// @see https://www.w3.org/TR/webgpu/#typedefdef-gpumapmodeflags\nvar GPUMapMode;\n(function (GPUMapMode) {\n    GPUMapMode[GPUMapMode[\"READ\"] = 1] = \"READ\";\n    GPUMapMode[GPUMapMode[\"WRITE\"] = 2] = \"WRITE\";\n})(GPUMapMode || (GPUMapMode = {}));\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/API/GPUTexture/usage#value\n */\nfunction translateTextureUsage(usage) {\n    var gpuUsage = 0;\n    if (usage & gPluginDeviceRenderer.TextureUsage.SAMPLED)\n        gpuUsage |= GPUTextureUsage$1.TEXTURE_BINDING | GPUTextureUsage$1.COPY_DST;\n    if (usage & gPluginDeviceRenderer.TextureUsage.RENDER_TARGET)\n        gpuUsage |=\n            GPUTextureUsage$1.RENDER_ATTACHMENT |\n                GPUTextureUsage$1.TEXTURE_BINDING |\n                GPUTextureUsage$1.COPY_SRC |\n                GPUTextureUsage$1.COPY_DST;\n    return gpuUsage;\n}\nfunction translateTextureFormat(format) {\n    if (format === gPluginDeviceRenderer.Format.U8_R_NORM)\n        return 'r8unorm';\n    else if (format === gPluginDeviceRenderer.Format.U8_RG_NORM)\n        return 'rg8unorm';\n    else if (format === gPluginDeviceRenderer.Format.U8_RGBA_RT)\n        return 'bgra8unorm';\n    else if (format === gPluginDeviceRenderer.Format.U8_RGBA_RT_SRGB)\n        return 'bgra8unorm-srgb';\n    else if (format === gPluginDeviceRenderer.Format.U8_RGBA_NORM)\n        return 'rgba8unorm';\n    else if (format === gPluginDeviceRenderer.Format.U8_RGBA_SRGB)\n        return 'rgba8unorm-srgb';\n    else if (format === gPluginDeviceRenderer.Format.S8_R_NORM)\n        return 'r8snorm';\n    else if (format === gPluginDeviceRenderer.Format.S8_RG_NORM)\n        return 'rg8snorm';\n    else if (format === gPluginDeviceRenderer.Format.S8_RGBA_NORM)\n        return 'rgba8snorm';\n    else if (format === gPluginDeviceRenderer.Format.U32_R)\n        return 'r32uint';\n    else if (format === gPluginDeviceRenderer.Format.F16_RGBA)\n        return 'rgba16float';\n    else if (format === gPluginDeviceRenderer.Format.F32_RGBA)\n        return 'rgba32float';\n    else if (format === gPluginDeviceRenderer.Format.D24)\n        return 'depth24plus';\n    else if (format === gPluginDeviceRenderer.Format.D24_S8)\n        return 'depth24plus-stencil8';\n    else if (format === gPluginDeviceRenderer.Format.D32F)\n        return 'depth32float';\n    else if (format === gPluginDeviceRenderer.Format.D32F_S8)\n        return 'depth32float-stencil8';\n    else if (format === gPluginDeviceRenderer.Format.BC1)\n        return 'bc1-rgba-unorm';\n    else if (format === gPluginDeviceRenderer.Format.BC1_SRGB)\n        return 'bc1-rgba-unorm-srgb';\n    else if (format === gPluginDeviceRenderer.Format.BC2)\n        return 'bc2-rgba-unorm';\n    else if (format === gPluginDeviceRenderer.Format.BC2_SRGB)\n        return 'bc2-rgba-unorm-srgb';\n    else if (format === gPluginDeviceRenderer.Format.BC3)\n        return 'bc3-rgba-unorm';\n    else if (format === gPluginDeviceRenderer.Format.BC3_SRGB)\n        return 'bc3-rgba-unorm-srgb';\n    else if (format === gPluginDeviceRenderer.Format.BC4_SNORM)\n        return 'bc4-r-snorm';\n    else if (format === gPluginDeviceRenderer.Format.BC4_UNORM)\n        return 'bc4-r-unorm';\n    else if (format === gPluginDeviceRenderer.Format.BC5_SNORM)\n        return 'bc5-rg-snorm';\n    else if (format === gPluginDeviceRenderer.Format.BC5_UNORM)\n        return 'bc5-rg-unorm';\n    else\n        throw 'whoops';\n}\nfunction translateTextureDimension(dimension) {\n    if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_2D)\n        return '2d';\n    else if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_CUBE_MAP)\n        return '2d';\n    else if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_2D_ARRAY)\n        return '2d';\n    else if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_3D)\n        return '3d';\n    else\n        throw new Error('whoops');\n}\nfunction translateBufferUsage(usage_) {\n    var usage = 0;\n    if (usage_ & gPluginDeviceRenderer.BufferUsage.INDEX)\n        usage |= GPUBufferUsage.INDEX;\n    if (usage_ & gPluginDeviceRenderer.BufferUsage.VERTEX)\n        usage |= GPUBufferUsage.VERTEX;\n    if (usage_ & gPluginDeviceRenderer.BufferUsage.UNIFORM)\n        usage |= GPUBufferUsage.UNIFORM;\n    if (usage_ & gPluginDeviceRenderer.BufferUsage.STORAGE)\n        usage |= GPUBufferUsage.STORAGE;\n    if (usage_ & gPluginDeviceRenderer.BufferUsage.COPY_SRC)\n        usage |= GPUBufferUsage.COPY_SRC;\n    usage |= GPUBufferUsage.COPY_DST;\n    return usage;\n}\nfunction translateWrapMode(wrapMode) {\n    if (wrapMode === gPluginDeviceRenderer.WrapMode.CLAMP)\n        return 'clamp-to-edge';\n    else if (wrapMode === gPluginDeviceRenderer.WrapMode.REPEAT)\n        return 'repeat';\n    else if (wrapMode === gPluginDeviceRenderer.WrapMode.MIRROR)\n        return 'mirror-repeat';\n    else\n        throw new Error('whoops');\n}\nfunction translateMinMagFilter(texFilter) {\n    if (texFilter === gPluginDeviceRenderer.TexFilterMode.BILINEAR)\n        return 'linear';\n    else if (texFilter === gPluginDeviceRenderer.TexFilterMode.POINT)\n        return 'nearest';\n    else\n        throw new Error('whoops');\n}\n// @see https://www.w3.org/TR/webgpu/#enumdef-gpumipmapfiltermode\nfunction translateMipFilter(mipFilter) {\n    if (mipFilter === gPluginDeviceRenderer.MipFilterMode.LINEAR)\n        return 'linear';\n    else if (mipFilter === gPluginDeviceRenderer.MipFilterMode.NEAREST)\n        return 'nearest';\n    else if (mipFilter === gPluginDeviceRenderer.MipFilterMode.NO_MIP)\n        return 'nearest';\n    else\n        throw new Error('whoops');\n}\nfunction translateSampleType(type) {\n    if (type === gPluginDeviceRenderer.SamplerFormatKind.Float)\n        return 'float';\n    else if (type === gPluginDeviceRenderer.SamplerFormatKind.Depth)\n        return 'depth';\n    else\n        throw new Error('whoops');\n}\nfunction translateBindGroupSamplerBinding(sampler) {\n    if (sampler.formatKind === gPluginDeviceRenderer.SamplerFormatKind.Depth && sampler.comparison) {\n        return { type: 'comparison' };\n    }\n    else if (sampler.formatKind === gPluginDeviceRenderer.SamplerFormatKind.Float) {\n        return { type: 'filtering' };\n    }\n    else {\n        return { type: 'non-filtering' };\n    }\n}\nfunction translateViewDimension(dimension) {\n    if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_2D)\n        return '2d';\n    else if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_2D_ARRAY)\n        return '2d-array';\n    else if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_3D)\n        return '3d';\n    else if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_CUBE_MAP)\n        return 'cube';\n    else\n        throw new Error('whoops');\n}\nfunction translateBindGroupTextureBinding(sampler) {\n    return {\n        sampleType: translateSampleType(sampler.formatKind),\n        viewDimension: translateViewDimension(sampler.dimension),\n    };\n}\nfunction getPlatformBuffer(buffer_) {\n    var buffer = buffer_;\n    return buffer.gpuBuffer;\n}\nfunction getPlatformSampler(sampler_) {\n    var sampler = sampler_;\n    return sampler.gpuSampler;\n}\nfunction getPlatformQuerySet(queryPool_) {\n    var queryPool = queryPool_;\n    return queryPool.querySet;\n}\nfunction translateQueryPoolType(type) {\n    if (type === gPluginDeviceRenderer.QueryPoolType.OcclusionConservative)\n        return 'occlusion';\n    else\n        throw new Error('whoops');\n}\n/**\n * @see https://www.w3.org/TR/webgpu/#primitive-state\n */\nfunction translateTopology(topology) {\n    switch (topology) {\n        case gPluginDeviceRenderer.PrimitiveTopology.TRIANGLES:\n            return 'triangle-list';\n        case gPluginDeviceRenderer.PrimitiveTopology.POINTS:\n            return 'point-list';\n        case gPluginDeviceRenderer.PrimitiveTopology.TRIANGLE_STRIP:\n            return 'triangle-strip';\n        case gPluginDeviceRenderer.PrimitiveTopology.LINES:\n            return 'line-list';\n        case gPluginDeviceRenderer.PrimitiveTopology.LINE_STRIP:\n            return 'line-strip';\n        default:\n            throw new Error('Unknown primitive topology mode');\n    }\n}\n/**\n * @see https://www.w3.org/TR/webgpu/#enumdef-gpucullmode\n */\nfunction translateCullMode(cullMode) {\n    if (cullMode === gPluginDeviceRenderer.CullMode.NONE)\n        return 'none';\n    else if (cullMode === gPluginDeviceRenderer.CullMode.FRONT)\n        return 'front';\n    else if (cullMode === gPluginDeviceRenderer.CullMode.BACK)\n        return 'back';\n    else\n        throw new Error('whoops');\n}\n/**\n * @see https://www.w3.org/TR/webgpu/#enumdef-gpufrontface\n */\nfunction translateFrontFace(frontFaceMode) {\n    if (frontFaceMode === gPluginDeviceRenderer.FrontFace.CCW)\n        return 'ccw';\n    else if (frontFaceMode === gPluginDeviceRenderer.FrontFace.CW)\n        return 'cw';\n    else\n        throw new Error('whoops');\n}\nfunction translatePrimitiveState(topology, megaStateDescriptor) {\n    return {\n        topology: translateTopology(topology),\n        cullMode: translateCullMode(megaStateDescriptor.cullMode),\n        frontFace: translateFrontFace(megaStateDescriptor.frontFace),\n    };\n}\n/**\n * @see https://www.w3.org/TR/webgpu/#enumdef-gpublendfactor\n */\nfunction translateBlendFactor(factor) {\n    if (factor === gPluginDeviceRenderer.BlendFactor.ZERO)\n        return 'zero';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.ONE)\n        return 'one';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.SRC)\n        return 'src';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.ONE_MINUS_SRC)\n        return 'one-minus-src';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.DST)\n        return 'dst';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.ONE_MINUS_DST)\n        return 'one-minus-dst';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.SRC_ALPHA)\n        return 'src-alpha';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.ONE_MINUS_SRC_ALPHA)\n        return 'one-minus-src-alpha';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.DST_ALPHA)\n        return 'dst-alpha';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.ONE_MINUS_DST_ALPHA)\n        return 'one-minus-dst-alpha';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.CONST)\n        return 'constant';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.ONE_MINUS_CONSTANT)\n        return 'one-minus-constant';\n    else if (factor === gPluginDeviceRenderer.BlendFactor.SRC_ALPHA_SATURATE)\n        return 'src-alpha-saturated';\n    else\n        throw new Error('whoops');\n}\n/**\n * @see https://www.w3.org/TR/webgpu/#enumdef-gpublendoperation\n */\nfunction translateBlendMode(mode) {\n    if (mode === gPluginDeviceRenderer.BlendMode.ADD)\n        return 'add';\n    else if (mode === gPluginDeviceRenderer.BlendMode.SUBSTRACT)\n        return 'subtract';\n    else if (mode === gPluginDeviceRenderer.BlendMode.REVERSE_SUBSTRACT)\n        return 'reverse-subtract';\n    else if (mode === gPluginDeviceRenderer.BlendMode.MIN)\n        return 'min';\n    else if (mode === gPluginDeviceRenderer.BlendMode.MAX)\n        return 'max';\n    else\n        throw new Error('whoops');\n}\nfunction translateBlendComponent(ch) {\n    return {\n        operation: translateBlendMode(ch.blendMode),\n        srcFactor: translateBlendFactor(ch.blendSrcFactor),\n        dstFactor: translateBlendFactor(ch.blendDstFactor),\n    };\n}\nfunction blendComponentIsNil(ch) {\n    return (ch.blendMode === gPluginDeviceRenderer.BlendMode.ADD &&\n        ch.blendSrcFactor === gPluginDeviceRenderer.BlendFactor.ONE &&\n        ch.blendDstFactor === gPluginDeviceRenderer.BlendFactor.ZERO);\n}\nfunction translateBlendState(attachmentState) {\n    if (blendComponentIsNil(attachmentState.rgbBlendState) &&\n        blendComponentIsNil(attachmentState.alphaBlendState)) {\n        return undefined;\n    }\n    else {\n        return {\n            color: translateBlendComponent(attachmentState.rgbBlendState),\n            alpha: translateBlendComponent(attachmentState.alphaBlendState),\n        };\n    }\n}\nfunction translateColorState(attachmentState, format) {\n    return {\n        format: translateTextureFormat(format),\n        blend: translateBlendState(attachmentState),\n        writeMask: attachmentState.channelWriteMask,\n    };\n}\nfunction translateTargets(colorAttachmentFormats, megaStateDescriptor) {\n    return megaStateDescriptor.attachmentsState.map(function (attachmentState, i) {\n        return translateColorState(attachmentState, colorAttachmentFormats[i]);\n    });\n}\n// @see https://www.w3.org/TR/webgpu/#enumdef-gpucomparefunction\nfunction translateCompareMode(compareMode) {\n    if (compareMode === gPluginDeviceRenderer.CompareMode.NEVER)\n        return 'never';\n    else if (compareMode === gPluginDeviceRenderer.CompareMode.LESS)\n        return 'less';\n    else if (compareMode === gPluginDeviceRenderer.CompareMode.EQUAL)\n        return 'equal';\n    else if (compareMode === gPluginDeviceRenderer.CompareMode.LEQUAL)\n        return 'less-equal';\n    else if (compareMode === gPluginDeviceRenderer.CompareMode.GREATER)\n        return 'greater';\n    else if (compareMode === gPluginDeviceRenderer.CompareMode.NOTEQUAL)\n        return 'not-equal';\n    else if (compareMode === gPluginDeviceRenderer.CompareMode.GEQUAL)\n        return 'greater-equal';\n    else if (compareMode === gPluginDeviceRenderer.CompareMode.ALWAYS)\n        return 'always';\n    else\n        throw new Error('whoops');\n}\nfunction translateDepthStencilState(format, megaStateDescriptor) {\n    if (util.isNil(format))\n        return undefined;\n    return {\n        format: translateTextureFormat(format),\n        depthWriteEnabled: !!megaStateDescriptor.depthWrite,\n        depthCompare: translateCompareMode(megaStateDescriptor.depthCompare),\n        depthBias: megaStateDescriptor.polygonOffset ? 1 : 0,\n        depthBiasSlopeScale: megaStateDescriptor.polygonOffset ? 1 : 0,\n    };\n}\nfunction translateIndexFormat(format) {\n    if (format === null)\n        return undefined;\n    else if (format === gPluginDeviceRenderer.Format.U16_R)\n        return 'uint16';\n    else if (format === gPluginDeviceRenderer.Format.U32_R)\n        return 'uint32';\n    else\n        throw new Error('whoops');\n}\nfunction translateVertexStepMode(stepMode) {\n    if (stepMode === gPluginDeviceRenderer.VertexStepMode.VERTEX)\n        return 'vertex';\n    else if (stepMode === gPluginDeviceRenderer.VertexStepMode.INSTANCE)\n        return 'instance';\n    else\n        throw new Error('whoops');\n}\nfunction translateVertexFormat(format) {\n    if (format === gPluginDeviceRenderer.Format.U8_R)\n        return 'uint8x2';\n    else if (format === gPluginDeviceRenderer.Format.U8_RG)\n        return 'uint8x2';\n    else if (format === gPluginDeviceRenderer.Format.U8_RGB)\n        return 'uint8x4';\n    else if (format === gPluginDeviceRenderer.Format.U8_RGBA)\n        return 'uint8x4';\n    else if (format === gPluginDeviceRenderer.Format.U8_RG_NORM)\n        return 'unorm8x2';\n    else if (format === gPluginDeviceRenderer.Format.U8_RGBA_NORM)\n        return 'unorm8x4';\n    else if (format === gPluginDeviceRenderer.Format.S8_RGB_NORM)\n        return 'snorm8x4';\n    else if (format === gPluginDeviceRenderer.Format.S8_RGBA_NORM)\n        return 'snorm8x4';\n    else if (format === gPluginDeviceRenderer.Format.U16_RG_NORM)\n        return 'unorm16x2';\n    else if (format === gPluginDeviceRenderer.Format.U16_RGBA_NORM)\n        return 'unorm16x4';\n    else if (format === gPluginDeviceRenderer.Format.S16_RG_NORM)\n        return 'snorm16x2';\n    else if (format === gPluginDeviceRenderer.Format.S16_RGBA_NORM)\n        return 'snorm16x4';\n    else if (format === gPluginDeviceRenderer.Format.S16_RG)\n        return 'uint16x2';\n    else if (format === gPluginDeviceRenderer.Format.F16_RG)\n        return 'float16x2';\n    else if (format === gPluginDeviceRenderer.Format.F16_RGBA)\n        return 'float16x4';\n    else if (format === gPluginDeviceRenderer.Format.F32_R)\n        return 'float32';\n    else if (format === gPluginDeviceRenderer.Format.F32_RG)\n        return 'float32x2';\n    else if (format === gPluginDeviceRenderer.Format.F32_RGB)\n        return 'float32x3';\n    else if (format === gPluginDeviceRenderer.Format.F32_RGBA)\n        return 'float32x4';\n    else\n        throw 'whoops';\n}\nfunction isFormatTextureCompressionBC(format) {\n    var formatTypeFlags = gPluginDeviceRenderer.getFormatTypeFlags(format);\n    switch (formatTypeFlags) {\n        case gPluginDeviceRenderer.FormatTypeFlags.BC1:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC2:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC3:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC4_SNORM:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC4_UNORM:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC5_SNORM:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC5_UNORM:\n            return true;\n        default:\n            return false;\n    }\n}\nfunction getFormatBlockSize(format) {\n    var formatTypeFlags = gPluginDeviceRenderer.getFormatTypeFlags(format);\n    switch (formatTypeFlags) {\n        case gPluginDeviceRenderer.FormatTypeFlags.BC1:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC2:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC3:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC4_SNORM:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC4_UNORM:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC5_SNORM:\n        case gPluginDeviceRenderer.FormatTypeFlags.BC5_UNORM:\n            return 4;\n        default:\n            return 1;\n    }\n}\nfunction allocateAndCopyTypedBuffer(type, sizeOrDstBuffer, sizeInBytes, copyBuffer) {\n    if (sizeInBytes === void 0) { sizeInBytes = false; }\n    switch (type) {\n        case gPluginDeviceRenderer.Format.S8_R:\n        case gPluginDeviceRenderer.Format.S8_R_NORM:\n        case gPluginDeviceRenderer.Format.S8_RG_NORM:\n        case gPluginDeviceRenderer.Format.S8_RGB_NORM:\n        case gPluginDeviceRenderer.Format.S8_RGBA_NORM: {\n            var buffer_1 = sizeOrDstBuffer instanceof ArrayBuffer\n                ? new Int8Array(sizeOrDstBuffer)\n                : new Int8Array(sizeOrDstBuffer);\n            if (copyBuffer) {\n                buffer_1.set(new Int8Array(copyBuffer));\n            }\n            return buffer_1;\n        }\n        case gPluginDeviceRenderer.Format.U8_R:\n        case gPluginDeviceRenderer.Format.U8_R_NORM:\n        case gPluginDeviceRenderer.Format.U8_RG:\n        case gPluginDeviceRenderer.Format.U8_RG_NORM:\n        case gPluginDeviceRenderer.Format.U8_RGB:\n        case gPluginDeviceRenderer.Format.U8_RGB_NORM:\n        case gPluginDeviceRenderer.Format.U8_RGB_SRGB:\n        case gPluginDeviceRenderer.Format.U8_RGBA:\n        case gPluginDeviceRenderer.Format.U8_RGBA_NORM:\n        case gPluginDeviceRenderer.Format.U8_RGBA_SRGB: {\n            var buffer_2 = sizeOrDstBuffer instanceof ArrayBuffer\n                ? new Uint8Array(sizeOrDstBuffer)\n                : new Uint8Array(sizeOrDstBuffer);\n            if (copyBuffer) {\n                buffer_2.set(new Uint8Array(copyBuffer));\n            }\n            return buffer_2;\n        }\n        case gPluginDeviceRenderer.Format.S16_R:\n        case gPluginDeviceRenderer.Format.S16_RG:\n        case gPluginDeviceRenderer.Format.S16_RG_NORM:\n        case gPluginDeviceRenderer.Format.S16_RGB_NORM:\n        case gPluginDeviceRenderer.Format.S16_RGBA:\n        case gPluginDeviceRenderer.Format.S16_RGBA_NORM: {\n            var buffer_3 = sizeOrDstBuffer instanceof ArrayBuffer\n                ? new Int16Array(sizeOrDstBuffer)\n                : new Int16Array(sizeInBytes ? sizeOrDstBuffer / 2 : sizeOrDstBuffer);\n            if (copyBuffer) {\n                buffer_3.set(new Int16Array(copyBuffer));\n            }\n            return buffer_3;\n        }\n        case gPluginDeviceRenderer.Format.U16_R:\n        case gPluginDeviceRenderer.Format.U16_RGB:\n        case gPluginDeviceRenderer.Format.U16_RGBA_5551:\n        case gPluginDeviceRenderer.Format.U16_RGBA_NORM:\n        case gPluginDeviceRenderer.Format.U16_RG_NORM:\n        case gPluginDeviceRenderer.Format.U16_R_NORM: {\n            var buffer_4 = sizeOrDstBuffer instanceof ArrayBuffer\n                ? new Uint16Array(sizeOrDstBuffer)\n                : new Uint16Array(sizeInBytes ? sizeOrDstBuffer / 2 : sizeOrDstBuffer);\n            if (copyBuffer) {\n                buffer_4.set(new Uint16Array(copyBuffer));\n            }\n            return buffer_4;\n        }\n        case gPluginDeviceRenderer.Format.S32_R: {\n            var buffer_5 = sizeOrDstBuffer instanceof ArrayBuffer\n                ? new Int32Array(sizeOrDstBuffer)\n                : new Int32Array(sizeInBytes ? sizeOrDstBuffer / 4 : sizeOrDstBuffer);\n            if (copyBuffer) {\n                buffer_5.set(new Int32Array(copyBuffer));\n            }\n            return buffer_5;\n        }\n        case gPluginDeviceRenderer.Format.U32_R:\n        case gPluginDeviceRenderer.Format.U32_RG: {\n            var buffer_6 = sizeOrDstBuffer instanceof ArrayBuffer\n                ? new Uint32Array(sizeOrDstBuffer)\n                : new Uint32Array(sizeInBytes ? sizeOrDstBuffer / 4 : sizeOrDstBuffer);\n            if (copyBuffer) {\n                buffer_6.set(new Uint32Array(copyBuffer));\n            }\n            return buffer_6;\n        }\n        case gPluginDeviceRenderer.Format.F32_R:\n        case gPluginDeviceRenderer.Format.F32_RG:\n        case gPluginDeviceRenderer.Format.F32_RGB:\n        case gPluginDeviceRenderer.Format.F32_RGBA: {\n            var buffer_7 = sizeOrDstBuffer instanceof ArrayBuffer\n                ? new Float32Array(sizeOrDstBuffer)\n                : new Float32Array(sizeInBytes ? sizeOrDstBuffer / 4 : sizeOrDstBuffer);\n            if (copyBuffer) {\n                buffer_7.set(new Float32Array(copyBuffer));\n            }\n            return buffer_7;\n        }\n    }\n    var buffer = sizeOrDstBuffer instanceof ArrayBuffer\n        ? new Uint8Array(sizeOrDstBuffer)\n        : new Uint8Array(sizeOrDstBuffer);\n    if (copyBuffer) {\n        buffer.set(new Uint8Array(copyBuffer));\n    }\n    return buffer;\n}\n/**\n * Converts a half float to a number\n * @param value half float to convert\n * @returns converted half float\n */\nfunction halfFloat2Number(value) {\n    var s = (value & 0x8000) >> 15;\n    var e = (value & 0x7c00) >> 10;\n    var f = value & 0x03ff;\n    if (e === 0) {\n        return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));\n    }\n    else if (e == 0x1f) {\n        return f ? NaN : (s ? -1 : 1) * Infinity;\n    }\n    return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + f / Math.pow(2, 10));\n}\n\nvar ResourceBase_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(ResourceBase_WebGPU, _super);\n    function ResourceBase_WebGPU(_a) {\n        var id = _a.id, device = _a.device;\n        var _this = _super.call(this) || this;\n        _this.id = id;\n        _this.device = device;\n        return _this;\n    }\n    ResourceBase_WebGPU.prototype.destroy = function () { };\n    return ResourceBase_WebGPU;\n}(EventEmitter));\n\nvar Bindings_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(Bindings_WebGPU, _super);\n    function Bindings_WebGPU(_a) {\n        var id = _a.id, device = _a.device, descriptor = _a.descriptor;\n        var _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.Bindings;\n        var pipeline = descriptor.pipeline, bindingLayout = descriptor.bindingLayout;\n        gPluginDeviceRenderer.assert(!!pipeline);\n        var bindGroupLayout = _this.device['createBindGroupLayout'](bindingLayout);\n        // entries orders: Storage(read-only storage) Uniform Sampler\n        var gpuBindGroupEntries = [[], []];\n        var numBindings = 0;\n        if (bindingLayout.storageEntries) {\n            for (var i = 0; i < bindingLayout.storageEntries.length; i++) {\n                var binding = descriptor.storageBufferBindings[i];\n                gPluginDeviceRenderer.assert(binding.wordCount > 0);\n                var gpuBufferBinding = {\n                    buffer: getPlatformBuffer(binding.buffer),\n                    offset: 0,\n                    size: binding.wordCount << 2,\n                };\n                gpuBindGroupEntries[0].push({\n                    binding: numBindings++,\n                    resource: gpuBufferBinding,\n                });\n            }\n        }\n        for (var i = 0; i < bindingLayout.numUniformBuffers; i++) {\n            var binding = descriptor.uniformBufferBindings[i];\n            gPluginDeviceRenderer.assert(binding.wordCount > 0);\n            var gpuBufferBinding = {\n                buffer: getPlatformBuffer(binding.buffer),\n                offset: 0,\n                size: binding.wordCount << 2,\n            };\n            gpuBindGroupEntries[0].push({\n                binding: numBindings++,\n                resource: gpuBufferBinding,\n            });\n        }\n        numBindings = 0;\n        for (var i = 0; i < bindingLayout.numSamplers; i++) {\n            var samplerEntry = bindingLayout.samplerEntries !== undefined\n                ? bindingLayout.samplerEntries[i]\n                : gPluginDeviceRenderer.defaultBindingLayoutSamplerDescriptor;\n            var binding = descriptor.samplerBindings[i];\n            var texture = binding.texture !== null\n                ? binding.texture\n                : _this.device['getFallbackTexture'](samplerEntry);\n            gPluginDeviceRenderer.assert(samplerEntry.dimension === texture.dimension);\n            gPluginDeviceRenderer.assert(samplerEntry.formatKind ===\n                gPluginDeviceRenderer.getFormatSamplerKind(texture.pixelFormat));\n            var gpuTextureView = texture.gpuTextureView;\n            gpuBindGroupEntries[1].push({\n                binding: numBindings++,\n                resource: gpuTextureView,\n            });\n            var sampler = binding.sampler !== null\n                ? binding.sampler\n                : _this.device['getFallbackSampler'](samplerEntry);\n            var gpuSampler = getPlatformSampler(sampler);\n            gpuBindGroupEntries[1].push({\n                binding: numBindings++,\n                resource: gpuSampler,\n            });\n        }\n        _this.gpuBindGroup = gpuBindGroupEntries\n            .filter(function (entries) { return entries.length > 0; })\n            .map(function (gpuBindGroupEntries, i) {\n            return _this.device.device.createBindGroup({\n                // layout: bindGroupLayout.gpuBindGroupLayout[i],\n                layout: pipeline.getBindGroupLayout(i),\n                entries: gpuBindGroupEntries,\n            });\n        });\n        _this.bindingLayout = descriptor.bindingLayout;\n        _this.bindGroupLayout = bindGroupLayout;\n        return _this;\n    }\n    return Bindings_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar Buffer_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(Buffer_WebGPU, _super);\n    function Buffer_WebGPU(_a) {\n        var id = _a.id, device = _a.device, descriptor = _a.descriptor;\n        var _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.Buffer;\n        var usage = descriptor.usage, viewOrSize = descriptor.viewOrSize;\n        var useMapRead = !!(usage & gPluginDeviceRenderer.BufferUsage.MAP_READ);\n        _this.usage = translateBufferUsage(usage);\n        // Buffer usages (BufferUsage::(MapRead|CopyDst|Storage)) is invalid. If a buffer usage contains BufferUsage::MapRead the only other allowed usage is BufferUsage::CopyDst.\n        // @see https://www.w3.org/TR/webgpu/#dom-gpubufferusage-copy_dst\n        if (useMapRead) {\n            _this.usage = gPluginDeviceRenderer.BufferUsage.MAP_READ | gPluginDeviceRenderer.BufferUsage.COPY_DST;\n        }\n        var mapBuffer = !util.isNumber(viewOrSize);\n        // this.size = isView(viewOrSize) ? viewOrSize.byteLength : viewOrSize * 4;\n        _this.view = !util.isNumber(viewOrSize) ? viewOrSize : null;\n        // 4 bytes alignments (because of the upload which requires this)\n        _this.size = util.isNumber(viewOrSize)\n            ? gPluginDeviceRenderer.align(viewOrSize, 4)\n            : gPluginDeviceRenderer.align(viewOrSize.byteLength, 4);\n        if (!util.isNumber(viewOrSize)) {\n            _this.gpuBuffer = _this.device.device.createBuffer({\n                usage: _this.usage,\n                size: _this.size,\n                mappedAtCreation: true,\n            });\n            var ctor = (viewOrSize && viewOrSize.constructor) || Float32Array;\n            // @ts-ignore\n            new ctor(_this.gpuBuffer.getMappedRange()).set(viewOrSize);\n            _this.gpuBuffer.unmap();\n        }\n        else {\n            _this.gpuBuffer = _this.device.device.createBuffer({\n                usage: _this.usage,\n                size: _this.size,\n                mappedAtCreation: useMapRead ? mapBuffer : false,\n            });\n        }\n        return _this;\n    }\n    Buffer_WebGPU.prototype.setSubData = function (dstByteOffset, src, srcByteOffset, byteLength) {\n        if (srcByteOffset === void 0) { srcByteOffset = 0; }\n        if (byteLength === void 0) { byteLength = 0; }\n        var buffer = this.gpuBuffer;\n        byteLength = byteLength || src.byteLength;\n        byteLength = Math.min(byteLength, this.size - dstByteOffset);\n        // After Migration to Canary\n        var chunkStart = src.byteOffset + srcByteOffset;\n        var chunkEnd = chunkStart + byteLength;\n        // 4 bytes alignments for upload\n        var alignedLength = (byteLength + 3) & ~3;\n        if (alignedLength !== byteLength) {\n            var tempView = new Uint8Array(src.buffer.slice(chunkStart, chunkEnd));\n            src = new Uint8Array(alignedLength);\n            src.set(tempView);\n            srcByteOffset = 0;\n            chunkStart = 0;\n            chunkEnd = alignedLength;\n            byteLength = alignedLength;\n        }\n        // Chunk\n        var maxChunk = 1024 * 1024 * 15;\n        var offset = 0;\n        while (chunkEnd - (chunkStart + offset) > maxChunk) {\n            this.device.device.queue.writeBuffer(buffer, dstByteOffset + offset, src.buffer, chunkStart + offset, maxChunk);\n            offset += maxChunk;\n        }\n        this.device.device.queue.writeBuffer(buffer, dstByteOffset + offset, src.buffer, chunkStart + offset, byteLength - offset);\n    };\n    Buffer_WebGPU.prototype.destroy = function () {\n        _super.prototype.destroy.call(this);\n        // @see https://www.w3.org/TR/webgpu/#dom-gpubuffer-destroy\n        this.gpuBuffer.destroy();\n    };\n    return Buffer_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar ComputePass_WebGPU = /** @class */ (function () {\n    function ComputePass_WebGPU() {\n        this.commandEncoder = null;\n        this.gpuComputePassEncoder = null;\n    }\n    /**\n     * @see https://www.w3.org/TR/webgpu/#dom-gpucomputepassencoder-dispatchworkgroups\n     */\n    ComputePass_WebGPU.prototype.dispatchWorkgroups = function (workgroupCountX, workgroupCountY, workgroupCountZ) {\n        this.gpuComputePassEncoder.dispatchWorkgroups(workgroupCountX, workgroupCountY, workgroupCountZ);\n    };\n    /**\n     * @see https://www.w3.org/TR/webgpu/#dom-gpucomputepassencoder-dispatchworkgroupsindirect\n     */\n    ComputePass_WebGPU.prototype.dispatchWorkgroupsIndirect = function (indirectBuffer, indirectOffset) {\n        this.gpuComputePassEncoder.dispatchWorkgroupsIndirect(indirectBuffer.gpuBuffer, indirectOffset);\n    };\n    ComputePass_WebGPU.prototype.finish = function () {\n        this.gpuComputePassEncoder.end();\n        this.gpuComputePassEncoder = null;\n        return this.commandEncoder.finish();\n    };\n    /**\n     * @see https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-begincomputepass\n     */\n    ComputePass_WebGPU.prototype.beginComputePass = function () {\n        gPluginDeviceRenderer.assert(this.gpuComputePassEncoder === null);\n        this.gpuComputePassEncoder = this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor);\n    };\n    ComputePass_WebGPU.prototype.setPipeline = function (pipeline_) {\n        var pipeline = pipeline_;\n        var gpuComputePipeline = gPluginDeviceRenderer.assertExists(pipeline.gpuComputePipeline);\n        this.gpuComputePassEncoder.setPipeline(gpuComputePipeline);\n    };\n    ComputePass_WebGPU.prototype.setBindings = function (bindingLayoutIndex, bindings_, dynamicByteOffsets) {\n        var bindings = bindings_;\n        this.gpuComputePassEncoder.setBindGroup(bindingLayoutIndex, bindings.gpuBindGroup[0], dynamicByteOffsets);\n    };\n    ComputePass_WebGPU.prototype.pushDebugGroup = function (name) {\n        this.gpuComputePassEncoder.pushDebugGroup(name);\n    };\n    ComputePass_WebGPU.prototype.popDebugGroup = function () {\n        this.gpuComputePassEncoder.popDebugGroup();\n    };\n    ComputePass_WebGPU.prototype.insertDebugMarker = function (markerLabel) {\n        this.gpuComputePassEncoder.insertDebugMarker(markerLabel);\n    };\n    return ComputePass_WebGPU;\n}());\n\nvar ComputePipeline_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(ComputePipeline_WebGPU, _super);\n    function ComputePipeline_WebGPU(_a) {\n        var id = _a.id, device = _a.device, descriptor = _a.descriptor;\n        var _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.ComputePipeline;\n        _this.gpuComputePipeline = null;\n        _this.descriptor = descriptor;\n        var program = descriptor.program;\n        var computeStage = program.computeStage;\n        if (computeStage === null)\n            return _this;\n        var gpuComputePipeline = {\n            layout: 'auto',\n            compute: tslib.__assign({}, computeStage),\n        };\n        // @see https://www.w3.org/TR/webgpu/#dom-gpudevice-createrenderpipeline\n        _this.gpuComputePipeline =\n            _this.device.device.createComputePipeline(gpuComputePipeline);\n        if (_this.name !== undefined) {\n            _this.gpuComputePipeline.label = _this.name;\n        }\n        return _this;\n    }\n    ComputePipeline_WebGPU.prototype.getBindGroupLayout = function (index) {\n        return this.gpuComputePipeline.getBindGroupLayout(index);\n    };\n    return ComputePipeline_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar InputLayout_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(InputLayout_WebGPU, _super);\n    function InputLayout_WebGPU(_a) {\n        var id = _a.id, device = _a.device, descriptor = _a.descriptor;\n        var _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.InputLayout;\n        var buffers = [];\n        for (var i = 0; i < descriptor.vertexAttributeDescriptors.length; i++) {\n            var attr = descriptor.vertexAttributeDescriptors[i];\n            var attribute = {\n                shaderLocation: attr.location,\n                format: translateVertexFormat(attr.format),\n                offset: attr.bufferByteOffset,\n            };\n            if (buffers[attr.bufferIndex] !== undefined) {\n                buffers[attr.bufferIndex].attributes.push(attribute);\n            }\n            else {\n                var b = gPluginDeviceRenderer.assertExists(descriptor.vertexBufferDescriptors[attr.bufferIndex]);\n                var arrayStride = b.byteStride;\n                var stepMode = translateVertexStepMode(b.stepMode);\n                var attributes = [attribute];\n                buffers[attr.bufferIndex] = { arrayStride: arrayStride, stepMode: stepMode, attributes: attributes };\n            }\n        }\n        _this.indexFormat = translateIndexFormat(descriptor.indexBufferFormat);\n        _this.buffers = buffers;\n        return _this;\n    }\n    return InputLayout_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar Program_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(Program_WebGPU, _super);\n    function Program_WebGPU(_a) {\n        var id = _a.id, device = _a.device, descriptor = _a.descriptor;\n        var _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.Program;\n        _this.vertexStage = null;\n        _this.fragmentStage = null;\n        _this.computeStage = null;\n        _this.descriptor = descriptor;\n        if (descriptor.vertex) {\n            _this.vertexStage = _this.createShaderStage(descriptor.vertex, 'vertex');\n        }\n        if (descriptor.fragment) {\n            _this.fragmentStage = _this.createShaderStage(descriptor.fragment, 'fragment');\n        }\n        if (descriptor.compute) {\n            // Only support WGSL now\n            _this.computeStage = _this.createShaderStage(descriptor.compute, 'compute');\n        }\n        return _this;\n    }\n    Program_WebGPU.prototype.setUniformsLegacy = function (uniforms) {\n    };\n    Program_WebGPU.prototype.createShaderStage = function (shader, shaderStage) {\n        var e_1, _a;\n        var validationEnabled = false;\n        // Use user-defined WGSL first.\n        var code = shader.wgsl;\n        if (!code) {\n            try {\n                code = this.device['glsl_compile'](shader.glsl, shaderStage, validationEnabled);\n            }\n            catch (e) {\n                console.error(e, shader.glsl);\n                throw new Error('whoops');\n            }\n        }\n        var _loop_1 = function (depthTextureName) {\n            if (!code.includes(depthTextureName))\n                return \"continue\";\n            code = code.replace(\"var T_\".concat(depthTextureName, \": texture_2d<f32>;\"), \"var T_\".concat(depthTextureName, \": texture_depth_2d;\"));\n            code = code.replace(new RegExp(\"textureSample\\\\(T_\".concat(depthTextureName, \"(.*)\\\\);$\"), 'gm'), function (sub, cap) {\n                return \"vec4<f32>(textureSample(T_\".concat(depthTextureName).concat(cap, \"), 0.0, 0.0, 0.0);\");\n            });\n        };\n        try {\n            // Workaround for https://github.com/gfx-rs/naga/issues/1355\n            for (var _b = tslib.__values(['u_TextureFramebufferDepth']), _c = _b.next(); !_c.done; _c = _b.next()) {\n                var depthTextureName = _c.value;\n                _loop_1(depthTextureName);\n            }\n        }\n        catch (e_1_1) { e_1 = { error: e_1_1 }; }\n        finally {\n            try {\n                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n            }\n            finally { if (e_1) throw e_1.error; }\n        }\n        // @see https://www.w3.org/TR/webgpu/#dom-gpudevice-createshadermodule\n        var shaderModule = this.device.device.createShaderModule({ code: code });\n        return { module: shaderModule, entryPoint: 'main' };\n    };\n    return Program_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar QueryPool_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(QueryPool_WebGPU, _super);\n    function QueryPool_WebGPU(_a) {\n        var id = _a.id, device = _a.device, descriptor = _a.descriptor;\n        var _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.QueryPool;\n        var elemCount = descriptor.elemCount, type = descriptor.type;\n        _this.querySet = _this.device.device.createQuerySet({\n            type: translateQueryPoolType(type),\n            count: elemCount,\n        });\n        _this.resolveBuffer = _this.device.device.createBuffer({\n            size: elemCount * 8,\n            usage: GPUBufferUsage.QUERY_RESOLVE | GPUBufferUsage.COPY_SRC,\n        });\n        _this.cpuBuffer = _this.device.device.createBuffer({\n            size: elemCount * 8,\n            usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,\n        });\n        _this.results = null;\n        return _this;\n    }\n    QueryPool_WebGPU.prototype.queryResultOcclusion = function (dstOffs) {\n        if (this.results === null)\n            return null;\n        return this.results[dstOffs] !== BigInt(0);\n    };\n    QueryPool_WebGPU.prototype.destroy = function () {\n        _super.prototype.destroy.call(this);\n        this.querySet.destroy();\n        this.resolveBuffer.destroy();\n        this.cpuBuffer.destroy();\n    };\n    return QueryPool_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar Readback_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(Readback_WebGPU, _super);\n    function Readback_WebGPU(_a) {\n        var id = _a.id, device = _a.device;\n        var _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.Readback;\n        return _this;\n    }\n    Readback_WebGPU.prototype.readTexture = function (t, x, y, width, height, dst, dstOffset, length) {\n        if (dstOffset === void 0) { dstOffset = 0; }\n        return tslib.__awaiter(this, void 0, void 0, function () {\n            var texture, faceIndex, blockInformation, bytesPerRow, bytesPerRowAligned, size, buffer, commandEncoder;\n            return tslib.__generator(this, function (_a) {\n                texture = t;\n                faceIndex = 0;\n                blockInformation = this.getBlockInformationFromFormat(texture.format);\n                bytesPerRow = Math.ceil(width / blockInformation.width) * blockInformation.length;\n                bytesPerRowAligned = Math.ceil(bytesPerRow / 256) * 256;\n                size = bytesPerRowAligned * height;\n                buffer = this.device.createBuffer({\n                    usage: gPluginDeviceRenderer.BufferUsage.STORAGE | gPluginDeviceRenderer.BufferUsage.MAP_READ | gPluginDeviceRenderer.BufferUsage.COPY_DST,\n                    hint: gPluginDeviceRenderer.BufferFrequencyHint.STATIC,\n                    viewOrSize: size,\n                });\n                commandEncoder = this.device.device.createCommandEncoder();\n                // @see https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-copytexturetobuffer\n                commandEncoder.copyTextureToBuffer({\n                    texture: texture.gpuTexture,\n                    mipLevel: 0,\n                    origin: {\n                        x: x,\n                        y: y,\n                        z: Math.max(faceIndex, 0),\n                    },\n                }, {\n                    buffer: buffer.gpuBuffer,\n                    offset: 0,\n                    bytesPerRow: bytesPerRowAligned,\n                }, {\n                    width: width,\n                    height: height,\n                    depthOrArrayLayers: 1,\n                });\n                this.device.device.queue.submit([commandEncoder.finish()]);\n                return [2 /*return*/, this.readBuffer(buffer, 0, dst.byteLength === size ? dst : null, dstOffset, size, texture.pixelFormat)];\n            });\n        });\n    };\n    Readback_WebGPU.prototype.readTextureSync = function (t, x, y, width, height, dst, dstOffset, length) {\n        throw new Error(gLite.ERROR_MSG_METHOD_NOT_IMPLEMENTED);\n    };\n    Readback_WebGPU.prototype.readBuffer = function (b, srcByteOffset, dstArrayBufferView, dstOffset, _size, type, noDataConversion, destroy) {\n        var _this = this;\n        if (srcByteOffset === void 0) { srcByteOffset = 0; }\n        if (dstArrayBufferView === void 0) { dstArrayBufferView = null; }\n        if (_size === void 0) { _size = 0; }\n        if (type === void 0) { type = gPluginDeviceRenderer.Format.U8_RGB; }\n        if (noDataConversion === void 0) { noDataConversion = false; }\n        var buffer = b;\n        var size = _size || buffer.size;\n        var dst = dstArrayBufferView || buffer.view;\n        var floatFormat = \n        // @ts-ignore\n        (dst && dst.constructor && dst.constructor.BYTES_PER_ELEMENT) ||\n            gPluginDeviceRenderer.getFormatCompByteSize(type);\n        var gpuReadBuffer = buffer;\n        // can read buffer directly?\n        if (!(buffer.usage & gPluginDeviceRenderer.BufferUsage.MAP_READ &&\n            buffer.usage & gPluginDeviceRenderer.BufferUsage.COPY_DST)) {\n            var commandEncoder = this.device.device.createCommandEncoder();\n            gpuReadBuffer = this.device.createBuffer({\n                usage: gPluginDeviceRenderer.BufferUsage.STORAGE | gPluginDeviceRenderer.BufferUsage.MAP_READ | gPluginDeviceRenderer.BufferUsage.COPY_DST,\n                hint: gPluginDeviceRenderer.BufferFrequencyHint.STATIC,\n                viewOrSize: size,\n            });\n            // Encode commands for copying buffer to buffer.\n            commandEncoder.copyBufferToBuffer(buffer.gpuBuffer /* source buffer */, srcByteOffset /* source offset */, gpuReadBuffer.gpuBuffer /* destination buffer */, 0 /* destination offset */, size /* size */);\n            this.device.device.queue.submit([commandEncoder.finish()]);\n        }\n        return new Promise(function (resolve, reject) {\n            gpuReadBuffer.gpuBuffer\n                .mapAsync(GPUMapMode.READ, srcByteOffset, size)\n                .then(function () {\n                var copyArrayBuffer = gpuReadBuffer.gpuBuffer.getMappedRange(srcByteOffset, size);\n                var data = dst;\n                if (noDataConversion) {\n                    if (data === null) {\n                        data = allocateAndCopyTypedBuffer(type, size, true, copyArrayBuffer);\n                    }\n                    else {\n                        // @ts-ignore\n                        data = allocateAndCopyTypedBuffer(type, data.buffer, undefined, copyArrayBuffer);\n                    }\n                }\n                else {\n                    if (data === null) {\n                        switch (floatFormat) {\n                            case 1: // byte format\n                                data = new Uint8Array(size);\n                                data.set(new Uint8Array(copyArrayBuffer));\n                                break;\n                            case 2: // half float\n                                // TODO WEBGPU use computer shaders (or render pass) to make the conversion?\n                                data = _this.getHalfFloatAsFloatRGBAArrayBuffer(size / 2, copyArrayBuffer);\n                                break;\n                            case 4: // float\n                                data = new Float32Array(size / 4);\n                                data.set(new Float32Array(copyArrayBuffer));\n                                break;\n                        }\n                    }\n                    else {\n                        switch (floatFormat) {\n                            case 1: // byte format\n                                data = new Uint8Array(data.buffer);\n                                data.set(new Uint8Array(copyArrayBuffer));\n                                break;\n                            case 2: // half float\n                                // TODO WEBGPU use computer shaders (or render pass) to make the conversion?\n                                data = _this.getHalfFloatAsFloatRGBAArrayBuffer(size / 2, copyArrayBuffer, dst);\n                                break;\n                            case 4: // float\n                                var ctor = (dst && dst.constructor) || Float32Array;\n                                // @ts-ignore\n                                data = new ctor(data.buffer);\n                                // @ts-ignore\n                                data.set(new ctor(copyArrayBuffer));\n                                break;\n                        }\n                    }\n                }\n                // if (bytesPerRow !== bytesPerRowAligned) {\n                //   // TODO WEBGPU use computer shaders (or render pass) to build the final buffer data?\n                //   if (floatFormat === 1 && !noDataConversion) {\n                //     // half float have been converted to float above\n                //     bytesPerRow *= 2;\n                //     bytesPerRowAligned *= 2;\n                //   }\n                //   const data2 = new Uint8Array(data!.buffer);\n                //   let offset = bytesPerRow,\n                //     offset2 = 0;\n                //   for (let y = 1; y < height; ++y) {\n                //     offset2 = y * bytesPerRowAligned;\n                //     for (let x = 0; x < bytesPerRow; ++x) {\n                //       data2[offset++] = data2[offset2++];\n                //     }\n                //   }\n                //   if (floatFormat !== 0 && !noDataConversion) {\n                //     data = new Float32Array(data2.buffer, 0, offset / 4);\n                //   } else {\n                //     data = new Uint8Array(data2.buffer, 0, offset);\n                //   }\n                // }\n                gpuReadBuffer.gpuBuffer.unmap();\n                resolve(data);\n            }, function (reason) { return reject(reason); });\n        });\n    };\n    Readback_WebGPU.prototype.getHalfFloatAsFloatRGBAArrayBuffer = function (dataLength, arrayBuffer, destArray) {\n        if (!destArray) {\n            destArray = new Float32Array(dataLength);\n        }\n        var srcData = new Uint16Array(arrayBuffer);\n        while (dataLength--) {\n            destArray[dataLength] = halfFloat2Number(srcData[dataLength]);\n        }\n        return destArray;\n    };\n    Readback_WebGPU.prototype.getBlockInformationFromFormat = function (format) {\n        switch (format) {\n            // 8 bits formats\n            case 'r8unorm':\n            case 'r8snorm':\n            case 'r8uint':\n            case 'r8sint':\n                return { width: 1, height: 1, length: 1 };\n            // 16 bits formats\n            case 'r16uint':\n            case 'r16sint':\n            case 'r16float':\n            case 'rg8unorm':\n            case 'rg8snorm':\n            case 'rg8uint':\n            case 'rg8sint':\n                return { width: 1, height: 1, length: 2 };\n            // 32 bits formats\n            case 'r32uint':\n            case 'r32sint':\n            case 'r32float':\n            case 'rg16uint':\n            case 'rg16sint':\n            case 'rg16float':\n            case 'rgba8unorm':\n            case 'rgba8unorm-srgb':\n            case 'rgba8snorm':\n            case 'rgba8uint':\n            case 'rgba8sint':\n            case 'bgra8unorm':\n            case 'bgra8unorm-srgb':\n            case 'rgb9e5ufloat':\n            case 'rgb10a2unorm':\n            case 'rg11b10ufloat':\n                return { width: 1, height: 1, length: 4 };\n            // 64 bits formats\n            case 'rg32uint':\n            case 'rg32sint':\n            case 'rg32float':\n            case 'rgba16uint':\n            case 'rgba16sint':\n            case 'rgba16float':\n                return { width: 1, height: 1, length: 8 };\n            // 128 bits formats\n            case 'rgba32uint':\n            case 'rgba32sint':\n            case 'rgba32float':\n                return { width: 1, height: 1, length: 16 };\n            // Depth and stencil formats\n            case 'stencil8':\n                throw new Error('No fixed size for Stencil8 format!');\n            case 'depth16unorm':\n                return { width: 1, height: 1, length: 2 };\n            case 'depth24plus':\n                throw new Error('No fixed size for Depth24Plus format!');\n            case 'depth24plus-stencil8':\n                throw new Error('No fixed size for Depth24PlusStencil8 format!');\n            case 'depth32float':\n                return { width: 1, height: 1, length: 4 };\n            // case 'depth24unorm-stencil8':\n            //   return { width: 1, height: 1, length: 4 };\n            case 'depth32float-stencil8':\n                return { width: 1, height: 1, length: 5 };\n            // BC compressed formats usable if \"texture-compression-bc\" is both\n            // supported by the device/user agent and enabled in requestDevice.\n            case 'bc7-rgba-unorm':\n            case 'bc7-rgba-unorm-srgb':\n            case 'bc6h-rgb-ufloat':\n            case 'bc6h-rgb-float':\n            case 'bc2-rgba-unorm':\n            case 'bc2-rgba-unorm-srgb':\n            case 'bc3-rgba-unorm':\n            case 'bc3-rgba-unorm-srgb':\n            case 'bc5-rg-unorm':\n            case 'bc5-rg-snorm':\n                return { width: 4, height: 4, length: 16 };\n            case 'bc4-r-unorm':\n            case 'bc4-r-snorm':\n            case 'bc1-rgba-unorm':\n            case 'bc1-rgba-unorm-srgb':\n                return { width: 4, height: 4, length: 8 };\n            default:\n                return { width: 1, height: 1, length: 4 };\n        }\n    };\n    return Readback_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar RenderPass_WebGPU = /** @class */ (function () {\n    function RenderPass_WebGPU() {\n        this.commandEncoder = null;\n        this.gpuRenderPassEncoder = null;\n        this.gfxColorAttachment = [];\n        this.gfxColorAttachmentLevel = [];\n        this.gfxColorResolveTo = [];\n        this.gfxColorResolveToLevel = [];\n        this.gfxDepthStencilAttachment = null;\n        this.gfxDepthStencilResolveTo = null;\n        this.gpuColorAttachments = [];\n        this.gpuDepthStencilAttachment = {\n            view: null,\n            depthLoadOp: 'load',\n            depthStoreOp: 'store',\n            stencilLoadOp: 'load',\n            stencilStoreOp: 'store',\n        };\n        this.gpuRenderPassDescriptor = {\n            colorAttachments: this.gpuColorAttachments,\n            depthStencilAttachment: this.gpuDepthStencilAttachment,\n        };\n    }\n    RenderPass_WebGPU.prototype.getTextureView = function (target, level) {\n        gPluginDeviceRenderer.assert(level < target.numLevels);\n        if (target.numLevels === 1)\n            return target.gpuTextureView;\n        else\n            return target.gpuTexture.createView({\n                baseMipLevel: level,\n                mipLevelCount: 1,\n            });\n    };\n    RenderPass_WebGPU.prototype.setRenderPassDescriptor = function (descriptor) {\n        var _a, _b, _c, _d, _e, _f;\n        this.descriptor = descriptor;\n        this.gpuRenderPassDescriptor.colorAttachments = this.gpuColorAttachments;\n        var numColorAttachments = descriptor.colorAttachment.length;\n        this.gfxColorAttachment.length = numColorAttachments;\n        this.gfxColorResolveTo.length = numColorAttachments;\n        for (var i = 0; i < descriptor.colorAttachment.length; i++) {\n            var colorAttachment = descriptor\n                .colorAttachment[i];\n            var colorResolveTo = descriptor\n                .colorResolveTo[i];\n            // Do some dumb juggling...\n            if (colorAttachment === null && colorResolveTo !== null) {\n                colorAttachment = colorResolveTo;\n                colorResolveTo = null;\n            }\n            this.gfxColorAttachment[i] = colorAttachment;\n            this.gfxColorResolveTo[i] = colorResolveTo;\n            this.gfxColorAttachmentLevel[i] =\n                ((_a = descriptor.colorAttachmentLevel) === null || _a === void 0 ? void 0 : _a[i]) || 0;\n            this.gfxColorResolveToLevel[i] = ((_b = descriptor.colorResolveToLevel) === null || _b === void 0 ? void 0 : _b[i]) || 0;\n            if (colorAttachment !== null) {\n                if (this.gpuColorAttachments[i] === undefined) {\n                    this.gpuColorAttachments[i] = {};\n                }\n                var dstAttachment = this.gpuColorAttachments[i];\n                dstAttachment.view = this.getTextureView(colorAttachment, ((_c = this.gfxColorAttachmentLevel) === null || _c === void 0 ? void 0 : _c[i]) || 0);\n                var clearColor = (_e = (_d = descriptor.colorClearColor) === null || _d === void 0 ? void 0 : _d[i]) !== null && _e !== void 0 ? _e : 'load';\n                if (clearColor === 'load') {\n                    dstAttachment.loadOp = 'load';\n                }\n                else {\n                    dstAttachment.loadOp = 'clear';\n                    dstAttachment.clearValue = clearColor;\n                }\n                dstAttachment.storeOp = ((_f = descriptor.colorStore) === null || _f === void 0 ? void 0 : _f[i])\n                    ? 'store'\n                    : 'discard';\n                dstAttachment.resolveTarget = undefined;\n                if (colorResolveTo !== null) {\n                    if (colorAttachment.sampleCount > 1) {\n                        dstAttachment.resolveTarget = this.getTextureView(colorResolveTo, this.gfxColorResolveToLevel[i]);\n                    }\n                    else {\n                        dstAttachment.storeOp = 'store';\n                    }\n                }\n            }\n            else {\n                // https://github.com/gpuweb/gpuweb/issues/1250\n                this.gpuColorAttachments.length = i;\n                this.gfxColorAttachment.length = i;\n                this.gfxColorResolveTo.length = i;\n                break;\n            }\n        }\n        this.gfxDepthStencilAttachment =\n            descriptor.depthStencilAttachment;\n        this.gfxDepthStencilResolveTo =\n            descriptor.depthStencilResolveTo;\n        if (descriptor.depthStencilAttachment) {\n            var dsAttachment = descriptor.depthStencilAttachment;\n            var dstAttachment = this.gpuDepthStencilAttachment;\n            dstAttachment.view = dsAttachment.gpuTextureView;\n            var hasDepth = !!(gPluginDeviceRenderer.getFormatFlags(dsAttachment.pixelFormat) & gPluginDeviceRenderer.FormatFlags.Depth);\n            if (hasDepth) {\n                if (descriptor.depthClearValue === 'load') {\n                    dstAttachment.depthLoadOp = 'load';\n                }\n                else {\n                    dstAttachment.depthLoadOp = 'clear';\n                    dstAttachment.depthClearValue = descriptor.depthClearValue;\n                }\n                if (descriptor.depthStencilStore ||\n                    this.gfxDepthStencilResolveTo !== null)\n                    dstAttachment.depthStoreOp = 'store';\n                else\n                    dstAttachment.depthStoreOp = 'discard';\n            }\n            else {\n                dstAttachment.depthLoadOp = undefined;\n                dstAttachment.depthStoreOp = undefined;\n            }\n            var hasStencil = !!(gPluginDeviceRenderer.getFormatFlags(dsAttachment.pixelFormat) & gPluginDeviceRenderer.FormatFlags.Stencil);\n            if (hasStencil) {\n                if (descriptor.stencilClearValue === 'load') {\n                    dstAttachment.stencilLoadOp = 'load';\n                }\n                else {\n                    dstAttachment.stencilLoadOp = 'clear';\n                    dstAttachment.stencilClearValue = descriptor.stencilClearValue;\n                }\n                if (descriptor.depthStencilStore ||\n                    this.gfxDepthStencilResolveTo !== null)\n                    dstAttachment.stencilStoreOp = 'store';\n                else\n                    dstAttachment.stencilStoreOp = 'discard';\n            }\n            else {\n                dstAttachment.stencilLoadOp = undefined;\n                dstAttachment.stencilStoreOp = undefined;\n            }\n            this.gpuRenderPassDescriptor.depthStencilAttachment =\n                this.gpuDepthStencilAttachment;\n        }\n        else {\n            this.gpuRenderPassDescriptor.depthStencilAttachment = undefined;\n        }\n        this.gpuRenderPassDescriptor.occlusionQuerySet = !util.isNil(descriptor.occlusionQueryPool)\n            ? getPlatformQuerySet(descriptor.occlusionQueryPool)\n            : undefined;\n    };\n    RenderPass_WebGPU.prototype.beginRenderPass = function (renderPassDescriptor) {\n        gPluginDeviceRenderer.assert(this.gpuRenderPassEncoder === null);\n        this.setRenderPassDescriptor(renderPassDescriptor);\n        this.gpuRenderPassEncoder = this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor);\n    };\n    RenderPass_WebGPU.prototype.setViewport = function (x, y, w, h) {\n        this.gpuRenderPassEncoder.setViewport(x, y, w, h, 0, 1);\n    };\n    RenderPass_WebGPU.prototype.setScissor = function (x, y, w, h) {\n        this.gpuRenderPassEncoder.setScissorRect(x, y, w, h);\n    };\n    RenderPass_WebGPU.prototype.setPipeline = function (pipeline_) {\n        var pipeline = pipeline_;\n        var gpuRenderPipeline = gPluginDeviceRenderer.assertExists(pipeline.gpuRenderPipeline);\n        this.gpuRenderPassEncoder.setPipeline(gpuRenderPipeline);\n    };\n    RenderPass_WebGPU.prototype.setVertexInput = function (inputLayout_, vertexBuffers, indexBuffer) {\n        if (inputLayout_ === null)\n            return;\n        var inputLayout = inputLayout_;\n        if (indexBuffer !== null)\n            this.gpuRenderPassEncoder.setIndexBuffer(getPlatformBuffer(indexBuffer.buffer), gPluginDeviceRenderer.assertExists(inputLayout.indexFormat), indexBuffer.byteOffset);\n        for (var i = 0; i < vertexBuffers.length; i++) {\n            var b = vertexBuffers[i];\n            if (b === null)\n                continue;\n            this.gpuRenderPassEncoder.setVertexBuffer(i, getPlatformBuffer(b.buffer), b.byteOffset);\n        }\n    };\n    RenderPass_WebGPU.prototype.setBindings = function (bindingLayoutIndex, bindings_, dynamicByteOffsets) {\n        var bindings = bindings_;\n        this.gpuRenderPassEncoder.setBindGroup(bindingLayoutIndex + 0, bindings.gpuBindGroup[0], dynamicByteOffsets.slice(0, bindings.bindingLayout.numUniformBuffers));\n        if (bindings.gpuBindGroup[1]) {\n            this.gpuRenderPassEncoder.setBindGroup(bindingLayoutIndex + 1, bindings.gpuBindGroup[1]);\n        }\n    };\n    RenderPass_WebGPU.prototype.setStencilRef = function (ref) {\n        this.gpuRenderPassEncoder.setStencilReference(ref);\n    };\n    /**\n     * @see https://www.w3.org/TR/webgpu/#dom-gpurendercommandsmixin-draw\n     */\n    RenderPass_WebGPU.prototype.draw = function (vertexCount, instanceCount, firstVertex, firstInstance) {\n        this.gpuRenderPassEncoder.draw(vertexCount, instanceCount, firstVertex, firstInstance);\n    };\n    /**\n     * @see https://www.w3.org/TR/webgpu/#dom-gpurendercommandsmixin-drawindexed\n     */\n    RenderPass_WebGPU.prototype.drawIndexed = function (indexCount, instanceCount, firstIndex, baseVertex, firstInstance) {\n        this.gpuRenderPassEncoder.drawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);\n    };\n    /**\n     * @see https://www.w3.org/TR/webgpu/#dom-gpurendercommandsmixin-drawindirect\n     */\n    RenderPass_WebGPU.prototype.drawIndirect = function (indirectBuffer, indirectOffset) {\n        // TODO\n    };\n    RenderPass_WebGPU.prototype.beginOcclusionQuery = function (dstOffs) {\n        this.gpuRenderPassEncoder.beginOcclusionQuery(dstOffs);\n    };\n    RenderPass_WebGPU.prototype.endOcclusionQuery = function (dstOffs) {\n        this.gpuRenderPassEncoder.endOcclusionQuery();\n    };\n    RenderPass_WebGPU.prototype.pushDebugGroup = function (name) {\n        this.gpuRenderPassEncoder.pushDebugGroup(name);\n    };\n    RenderPass_WebGPU.prototype.popDebugGroup = function () {\n        this.gpuRenderPassEncoder.popDebugGroup();\n    };\n    RenderPass_WebGPU.prototype.insertDebugMarker = function (markerLabel) {\n        this.gpuRenderPassEncoder.insertDebugMarker(markerLabel);\n    };\n    RenderPass_WebGPU.prototype.finish = function () {\n        this.gpuRenderPassEncoder.end();\n        this.gpuRenderPassEncoder = null;\n        // Fake a resolve with a copy for non-MSAA.\n        for (var i = 0; i < this.gfxColorAttachment.length; i++) {\n            var colorAttachment = this.gfxColorAttachment[i];\n            var colorResolveTo = this.gfxColorResolveTo[i];\n            if (colorAttachment !== null &&\n                colorResolveTo !== null &&\n                colorAttachment.sampleCount === 1) {\n                this.copyAttachment(colorResolveTo, this.gfxColorAttachmentLevel[i], colorAttachment, this.gfxColorResolveToLevel[i]);\n            }\n        }\n        if (this.gfxDepthStencilAttachment && this.gfxDepthStencilResolveTo) {\n            if (this.gfxDepthStencilAttachment.sampleCount > 1) ;\n            else {\n                this.copyAttachment(this.gfxDepthStencilResolveTo, 0, this.gfxDepthStencilAttachment, 0);\n            }\n        }\n        return this.commandEncoder.finish();\n    };\n    RenderPass_WebGPU.prototype.copyAttachment = function (dst, dstLevel, src, srcLevel) {\n        gPluginDeviceRenderer.assert(src.sampleCount === 1);\n        var srcCopy = {\n            texture: src.gpuTexture,\n            mipLevel: srcLevel,\n        };\n        var dstCopy = {\n            texture: dst.gpuTexture,\n            mipLevel: dstLevel,\n        };\n        gPluginDeviceRenderer.assert(src.width >>> srcLevel === dst.width >>> dstLevel);\n        gPluginDeviceRenderer.assert(src.height >>> srcLevel === dst.height >>> dstLevel);\n        gPluginDeviceRenderer.assert(!!(src.usage & GPUTextureUsage$1.COPY_SRC));\n        gPluginDeviceRenderer.assert(!!(dst.usage & GPUTextureUsage$1.COPY_DST));\n        this.commandEncoder.copyTextureToTexture(srcCopy, dstCopy, [\n            dst.width,\n            dst.height,\n            1,\n        ]);\n    };\n    return RenderPass_WebGPU;\n}());\n\nvar RenderPipeline_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(RenderPipeline_WebGPU, _super);\n    function RenderPipeline_WebGPU(_a) {\n        var id = _a.id, device = _a.device, descriptor = _a.descriptor;\n        var _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.RenderPipeline;\n        _this.isCreatingAsync = false;\n        _this.gpuRenderPipeline = null;\n        _this.descriptor = descriptor;\n        _this.device['createRenderPipelineInternal'](_this, false);\n        return _this;\n    }\n    RenderPipeline_WebGPU.prototype.getBindGroupLayout = function (index) {\n        return this.gpuRenderPipeline.getBindGroupLayout(index);\n    };\n    return RenderPipeline_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar Sampler_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(Sampler_WebGPU, _super);\n    function Sampler_WebGPU(_a) {\n        var id = _a.id, device = _a.device, descriptor = _a.descriptor;\n        var _this = this;\n        var _b, _c;\n        _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.Sampler;\n        var lodMinClamp = descriptor.minLOD;\n        var lodMaxClamp = descriptor.mipFilter === gPluginDeviceRenderer.MipFilterMode.NO_MIP\n            ? descriptor.minLOD\n            : descriptor.maxLOD;\n        var maxAnisotropy = (_b = descriptor.maxAnisotropy) !== null && _b !== void 0 ? _b : 1;\n        if (maxAnisotropy > 1)\n            gPluginDeviceRenderer.assert(descriptor.minFilter === gPluginDeviceRenderer.TexFilterMode.BILINEAR &&\n                descriptor.magFilter === gPluginDeviceRenderer.TexFilterMode.BILINEAR &&\n                descriptor.mipFilter === gPluginDeviceRenderer.MipFilterMode.LINEAR);\n        _this.gpuSampler = _this.device.device.createSampler({\n            addressModeU: translateWrapMode(descriptor.wrapS),\n            addressModeV: translateWrapMode(descriptor.wrapT),\n            addressModeW: translateWrapMode((_c = descriptor.wrapQ) !== null && _c !== void 0 ? _c : descriptor.wrapS),\n            lodMinClamp: lodMinClamp,\n            lodMaxClamp: lodMaxClamp,\n            minFilter: translateMinMagFilter(descriptor.minFilter),\n            magFilter: translateMinMagFilter(descriptor.magFilter),\n            mipmapFilter: translateMipFilter(descriptor.mipFilter),\n            compare: descriptor.compareMode !== undefined\n                ? translateCompareMode(descriptor.compareMode)\n                : undefined,\n            maxAnisotropy: maxAnisotropy,\n        });\n        return _this;\n    }\n    return Sampler_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar Texture_WebGPU = /** @class */ (function (_super) {\n    tslib.__extends(Texture_WebGPU, _super);\n    function Texture_WebGPU(_a) {\n        var id = _a.id, device = _a.device, descriptor = _a.descriptor, skipCreate = _a.skipCreate, sampleCount = _a.sampleCount;\n        var _this = this;\n        var _b, _c, _d;\n        _this = _super.call(this, { id: id, device: device }) || this;\n        _this.type = gPluginDeviceRenderer.ResourceType.Texture;\n        _this.device.createTextureShared({\n            pixelFormat: descriptor.pixelFormat,\n            dimension: (_b = descriptor.dimension) !== null && _b !== void 0 ? _b : gPluginDeviceRenderer.TextureDimension.TEXTURE_2D,\n            width: descriptor.width,\n            height: descriptor.height,\n            depthOrArrayLayers: (_c = descriptor.depth) !== null && _c !== void 0 ? _c : 1,\n            numLevels: (_d = descriptor.numLevels) !== null && _d !== void 0 ? _d : 1,\n            usage: descriptor.usage,\n            sampleCount: sampleCount !== null && sampleCount !== void 0 ? sampleCount : 1,\n        }, _this, skipCreate);\n        return _this;\n    }\n    Texture_WebGPU.prototype.textureFromImageBitmapOrCanvas = function (device, sources, depthOrArrayLayers) {\n        var width = sources[0].width;\n        var height = sources[0].height;\n        var textureDescriptor = {\n            // Unlike in WebGL, the size of our texture must be set at texture creation time.\n            // This means we have to wait until the image is loaded to create the texture, since we won't\n            // know the size until then.\n            size: { width: width, height: height, depthOrArrayLayers: depthOrArrayLayers },\n            format: 'rgba8unorm',\n            usage: GPUTextureUsage.TEXTURE_BINDING |\n                GPUTextureUsage.COPY_DST |\n                GPUTextureUsage.RENDER_ATTACHMENT,\n        };\n        var texture = device.createTexture(textureDescriptor);\n        for (var i = 0; i < sources.length; i++) {\n            var source = sources[0];\n            device.queue.copyExternalImageToTexture({ source: source }, { texture: texture, origin: [0, 0, i] }, [width, height]);\n        }\n        return [texture, width, height];\n    };\n    Texture_WebGPU.prototype.isImageBitmapOrCanvases = function (datas) {\n        var data = datas[0];\n        return (data instanceof ImageBitmap ||\n            data instanceof HTMLCanvasElement ||\n            data instanceof OffscreenCanvas);\n    };\n    Texture_WebGPU.prototype.isVideo = function (datas) {\n        var data = datas[0];\n        return data instanceof HTMLVideoElement;\n    };\n    /**\n     * @see https://toji.dev/webgpu-best-practices/img-textures\n     */\n    Texture_WebGPU.prototype.setImageData = function (datas, firstMipLevel) {\n        var _a;\n        var device = this.device.device;\n        var texture;\n        var width;\n        var height;\n        if (this.isImageBitmapOrCanvases(datas)) {\n            _a = tslib.__read(this.textureFromImageBitmapOrCanvas(device, datas, this.depthOrArrayLayers), 3), texture = _a[0], width = _a[1], height = _a[2];\n        }\n        else if (this.isVideo(datas)) {\n            // @see https://toji.dev/webgpu-best-practices/img-textures#creating-a-texture-from-an-htmlvideoelement-video-tag\n            texture = device.importExternalTexture({\n                source: datas[0],\n            });\n        }\n        else ;\n        this.width = width;\n        this.height = height;\n        this.gpuTexture = texture;\n        this.gpuTextureView = texture.createView();\n    };\n    Texture_WebGPU.prototype.destroy = function () {\n        _super.prototype.destroy.call(this);\n        // @see https://www.w3.org/TR/webgpu/#dom-gputexture-destroy\n        this.gpuTexture.destroy();\n    };\n    return Texture_WebGPU;\n}(ResourceBase_WebGPU));\n\nvar Device_WebGPU = /** @class */ (function () {\n    function Device_WebGPU(adapter, device, canvas, canvasContext, glsl_compile) {\n        this.swapChainWidth = 0;\n        this.swapChainHeight = 0;\n        this.swapChainTextureUsage = GPUTextureUsage$1.RENDER_ATTACHMENT | GPUTextureUsage$1.COPY_DST;\n        this._resourceUniqueId = 0;\n        this.renderPassPool = [];\n        this.computePassPool = [];\n        this.bindGroupLayoutCache = new gPluginDeviceRenderer.HashMap(gPluginDeviceRenderer.bindingLayoutDescriptorEqual, gPluginDeviceRenderer.nullHashFunc);\n        this.featureTextureCompressionBC = false;\n        // VendorInfo\n        this.platformString = 'WebGPU';\n        this.glslVersion = \"#version 440\";\n        this.explicitBindingLocations = true;\n        this.separateSamplerTextures = true;\n        this.viewportOrigin = gPluginDeviceRenderer.ViewportOrigin.UPPER_LEFT;\n        this.clipSpaceNearZ = gPluginDeviceRenderer.ClipSpaceNearZ.ZERO;\n        this.supportsSyncPipelineCompilation = false;\n        this.supportMRT = true;\n        this.device = device;\n        this.canvas = canvas;\n        this.canvasContext = canvasContext;\n        this.glsl_compile = glsl_compile;\n        this.fallbackTexture2D = this.createFallbackTexture(gPluginDeviceRenderer.TextureDimension.TEXTURE_2D, gPluginDeviceRenderer.SamplerFormatKind.Float);\n        this.setResourceName(this.fallbackTexture2D, 'Fallback Texture2D');\n        this.fallbackTexture2DDepth = this.createFallbackTexture(gPluginDeviceRenderer.TextureDimension.TEXTURE_2D, gPluginDeviceRenderer.SamplerFormatKind.Depth);\n        this.setResourceName(this.fallbackTexture2DDepth, 'Fallback Depth Texture2D');\n        this.fallbackTexture2DArray = this.createFallbackTexture(gPluginDeviceRenderer.TextureDimension.TEXTURE_2D_ARRAY, gPluginDeviceRenderer.SamplerFormatKind.Float);\n        this.setResourceName(this.fallbackTexture2DArray, 'Fallback Texture2DArray');\n        this.fallbackTexture3D = this.createFallbackTexture(gPluginDeviceRenderer.TextureDimension.TEXTURE_3D, gPluginDeviceRenderer.SamplerFormatKind.Float);\n        this.setResourceName(this.fallbackTexture3D, 'Fallback Texture3D');\n        this.fallbackTextureCube = this.createFallbackTexture(gPluginDeviceRenderer.TextureDimension.TEXTURE_CUBE_MAP, gPluginDeviceRenderer.SamplerFormatKind.Float);\n        this.setResourceName(this.fallbackTextureCube, 'Fallback TextureCube');\n        this.fallbackSamplerFiltering = this.createSampler({\n            wrapS: gPluginDeviceRenderer.WrapMode.REPEAT,\n            wrapT: gPluginDeviceRenderer.WrapMode.REPEAT,\n            minFilter: gPluginDeviceRenderer.TexFilterMode.POINT,\n            magFilter: gPluginDeviceRenderer.TexFilterMode.POINT,\n            mipFilter: gPluginDeviceRenderer.MipFilterMode.NEAREST,\n        });\n        this.setResourceName(this.fallbackSamplerFiltering, 'Fallback Sampler Filtering');\n        this.fallbackSamplerComparison = this.createSampler({\n            wrapS: gPluginDeviceRenderer.WrapMode.REPEAT,\n            wrapT: gPluginDeviceRenderer.WrapMode.REPEAT,\n            minFilter: gPluginDeviceRenderer.TexFilterMode.POINT,\n            magFilter: gPluginDeviceRenderer.TexFilterMode.POINT,\n            mipFilter: gPluginDeviceRenderer.MipFilterMode.NEAREST,\n            compareMode: gPluginDeviceRenderer.CompareMode.ALWAYS,\n        });\n        this.setResourceName(this.fallbackSamplerComparison, 'Fallback Sampler Comparison Filtering');\n        // Firefox doesn't support GPUDevice.features yet...\n        if (this.device.features) {\n            this.featureTextureCompressionBC = this.device.features.has('texture-compression-bc');\n        }\n        this.device.onuncapturederror = function (event) {\n            console.error(event.error);\n        };\n        this.swapChainFormat = navigator.gpu.getPreferredCanvasFormat();\n        // @see https://www.w3.org/TR/webgpu/#canvas-configuration\n        this.canvasContext.configure({\n            device: this.device,\n            format: this.swapChainFormat,\n            usage: this.swapChainTextureUsage,\n            // @see https://www.w3.org/TR/webgpu/#gpucanvasalphamode\n            // alphaMode: 'opaque',\n            alphaMode: 'premultiplied',\n        });\n    }\n    Device_WebGPU.prototype.destroy = function () { };\n    // SwapChain\n    Device_WebGPU.prototype.configureSwapChain = function (width, height) {\n        if (this.swapChainWidth === width && this.swapChainHeight === height)\n            return;\n        this.swapChainWidth = width;\n        this.swapChainHeight = height;\n    };\n    Device_WebGPU.prototype.getOnscreenTexture = function () {\n        // @see https://www.w3.org/TR/webgpu/#dom-gpucanvascontext-getcurrenttexture\n        var gpuTexture = this.canvasContext.getCurrentTexture();\n        var gpuTextureView = gpuTexture.createView();\n        var texture = new Texture_WebGPU({\n            id: 0,\n            device: this,\n            descriptor: {\n                pixelFormat: gPluginDeviceRenderer.Format.U8_RGBA_RT,\n                width: this.swapChainWidth,\n                height: this.swapChainHeight,\n                depth: 0,\n                dimension: gPluginDeviceRenderer.TextureDimension.TEXTURE_2D,\n                numLevels: 1,\n                usage: this.swapChainTextureUsage,\n            },\n            skipCreate: true,\n        });\n        texture.depthOrArrayLayers = 1;\n        texture.sampleCount = 1;\n        texture.gpuTexture = gpuTexture;\n        texture.gpuTextureView = gpuTextureView;\n        texture.name = 'Onscreen';\n        this.setResourceName(texture, 'Onscreen Texture');\n        return texture;\n    };\n    Device_WebGPU.prototype.getDevice = function () {\n        return this;\n    };\n    Device_WebGPU.prototype.getCanvas = function () {\n        return this.canvas;\n    };\n    Device_WebGPU.prototype.beginFrame = function () {\n        // assert(this.frameCommandEncoder === null);\n        // this.frameCommandEncoder = this.device.createCommandEncoder();\n    };\n    Device_WebGPU.prototype.endFrame = function () {\n        // assert(this.frameCommandEncoder !== null);\n        // this.device.queue.submit([this.frameCommandEncoder.finish()]);\n        // this.frameCommandEncoder = null;\n        // for (let i = 0; i < this.queryPoolsSubmitted.length; i++) {\n        //   const queryPool = this.queryPoolsSubmitted[i];\n        //   queryPool.cpuBuffer.mapAsync(GPUMapMode.READ).then(() => {\n        //     queryPool.results = new BigUint64Array(\n        //       queryPool.cpuBuffer.getMappedRange(),\n        //     );\n        //   });\n        // }\n        // this.queryPoolsSubmitted.length = 0;\n    };\n    Device_WebGPU.prototype.getNextUniqueId = function () {\n        return ++this._resourceUniqueId;\n    };\n    Device_WebGPU.prototype.createBuffer = function (descriptor) {\n        return new Buffer_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: descriptor,\n        });\n    };\n    Device_WebGPU.prototype.createTexture = function (descriptor) {\n        return new Texture_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: descriptor,\n        });\n    };\n    /**\n     * @see https://www.w3.org/TR/webgpu/#dom-gpudevice-createsampler\n     * @see https://www.w3.org/TR/webgpu/#GPUSamplerDescriptor\n     */\n    Device_WebGPU.prototype.createSampler = function (descriptor) {\n        return new Sampler_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: descriptor,\n        });\n    };\n    Device_WebGPU.prototype.createRenderTarget = function (descriptor) {\n        var texture = new Texture_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: tslib.__assign(tslib.__assign({}, descriptor), { dimension: gPluginDeviceRenderer.TextureDimension.TEXTURE_2D, numLevels: 1, depth: 1, usage: gPluginDeviceRenderer.TextureUsage.RENDER_TARGET }),\n            sampleCount: descriptor.sampleCount,\n        });\n        texture.depthOrArrayLayers = 1;\n        // @ts-ignore\n        texture.type = gPluginDeviceRenderer.ResourceType.RenderTarget;\n        return texture;\n    };\n    Device_WebGPU.prototype.createRenderTargetFromTexture = function (texture) {\n        var _a = texture, pixelFormat = _a.pixelFormat, width = _a.width, height = _a.height, depthOrArrayLayers = _a.depthOrArrayLayers, sampleCount = _a.sampleCount, numLevels = _a.numLevels, gpuTexture = _a.gpuTexture, gpuTextureView = _a.gpuTextureView, usage = _a.usage;\n        gPluginDeviceRenderer.assert(!!(usage & GPUTextureUsage$1.RENDER_ATTACHMENT));\n        var attachment = new Texture_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: {\n                pixelFormat: pixelFormat,\n                width: width,\n                height: height,\n                depth: depthOrArrayLayers,\n                dimension: gPluginDeviceRenderer.TextureDimension.TEXTURE_2D,\n                numLevels: numLevels,\n                usage: usage,\n            },\n            skipCreate: true,\n        });\n        attachment.depthOrArrayLayers = depthOrArrayLayers;\n        attachment.sampleCount = sampleCount;\n        attachment.gpuTexture = gpuTexture;\n        attachment.gpuTextureView = gpuTextureView;\n        return attachment;\n    };\n    Device_WebGPU.prototype.createProgram = function (descriptor) {\n        var _a, _b;\n        // preprocess GLSL first\n        if ((_a = descriptor.vertex) === null || _a === void 0 ? void 0 : _a.glsl) {\n            descriptor.vertex.glsl = gPluginDeviceRenderer.preprocessShader_GLSL(this.queryVendorInfo(), 'vert', descriptor.vertex.glsl);\n        }\n        if ((_b = descriptor.fragment) === null || _b === void 0 ? void 0 : _b.glsl) {\n            descriptor.fragment.glsl = gPluginDeviceRenderer.preprocessShader_GLSL(this.queryVendorInfo(), 'frag', descriptor.fragment.glsl);\n        }\n        return new Program_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: descriptor,\n        });\n    };\n    Device_WebGPU.prototype.createTextureShared = function (descriptor, texture, skipCreate) {\n        var size = {\n            width: descriptor.width,\n            height: descriptor.height,\n            depthOrArrayLayers: descriptor.depthOrArrayLayers,\n        };\n        var mipLevelCount = descriptor.numLevels;\n        var format = translateTextureFormat(descriptor.pixelFormat);\n        var dimension = translateTextureDimension(descriptor.dimension);\n        var usage = translateTextureUsage(descriptor.usage);\n        texture.format = format;\n        texture.dimension = descriptor.dimension;\n        texture.pixelFormat = descriptor.pixelFormat;\n        texture.width = descriptor.width;\n        texture.height = descriptor.height;\n        texture.depthOrArrayLayers = descriptor.depthOrArrayLayers;\n        texture.numLevels = mipLevelCount;\n        texture.usage = usage;\n        texture.sampleCount = descriptor.sampleCount;\n        if (!skipCreate) {\n            var gpuTexture = this.device.createTexture({\n                size: size,\n                mipLevelCount: mipLevelCount,\n                format: format,\n                dimension: dimension,\n                sampleCount: descriptor.sampleCount,\n                usage: usage,\n            });\n            var gpuTextureView = gpuTexture.createView();\n            texture.gpuTexture = gpuTexture;\n            texture.gpuTextureView = gpuTextureView;\n        }\n    };\n    Device_WebGPU.prototype.getFallbackSampler = function (samplerEntry) {\n        var formatKind = samplerEntry.formatKind;\n        if (formatKind === gPluginDeviceRenderer.SamplerFormatKind.Depth && samplerEntry.comparison) {\n            return this.fallbackSamplerComparison;\n        }\n        else {\n            return this.fallbackSamplerFiltering;\n        }\n    };\n    Device_WebGPU.prototype.getFallbackTexture = function (samplerEntry) {\n        var dimension = samplerEntry.dimension, formatKind = samplerEntry.formatKind;\n        if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_2D)\n            return formatKind === gPluginDeviceRenderer.SamplerFormatKind.Depth\n                ? this.fallbackTexture2DDepth\n                : this.fallbackTexture2D;\n        else if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_2D_ARRAY)\n            return this.fallbackTexture2DArray;\n        else if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_3D)\n            return this.fallbackTexture3D;\n        else if (dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_CUBE_MAP)\n            return this.fallbackTextureCube;\n        else\n            throw new Error('whoops');\n    };\n    Device_WebGPU.prototype.createFallbackTexture = function (dimension, formatKind) {\n        var depth = dimension === gPluginDeviceRenderer.TextureDimension.TEXTURE_CUBE_MAP ? 6 : 1;\n        var pixelFormat = formatKind === gPluginDeviceRenderer.SamplerFormatKind.Float ? gPluginDeviceRenderer.Format.U8_RGBA_NORM : gPluginDeviceRenderer.Format.D24;\n        return this.createTexture({\n            dimension: dimension,\n            pixelFormat: pixelFormat,\n            usage: gPluginDeviceRenderer.TextureUsage.SAMPLED,\n            width: 1,\n            height: 1,\n            depth: depth,\n            numLevels: 1,\n        });\n    };\n    Device_WebGPU.prototype.createBindings = function (descriptor) {\n        return new Bindings_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: descriptor,\n        });\n    };\n    Device_WebGPU.prototype.createInputLayout = function (descriptor) {\n        return new InputLayout_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: descriptor,\n        });\n    };\n    Device_WebGPU.prototype.createComputePipeline = function (descriptor) {\n        return new ComputePipeline_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: descriptor,\n        });\n    };\n    Device_WebGPU.prototype.createRenderPipeline = function (descriptor) {\n        return new RenderPipeline_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: tslib.__assign({}, descriptor),\n        });\n    };\n    Device_WebGPU.prototype.createQueryPool = function (type, elemCount) {\n        return new QueryPool_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n            descriptor: {\n                type: type,\n                elemCount: elemCount,\n            },\n        });\n    };\n    Device_WebGPU.prototype.createBindGroupLayout = function (bindingLayout) {\n        var gpuBindGroupLayout = this.bindGroupLayoutCache.get(bindingLayout);\n        if (gpuBindGroupLayout === null) {\n            gpuBindGroupLayout = this._createBindGroupLayoutInternal(bindingLayout);\n            this.bindGroupLayoutCache.add(bindingLayout, gpuBindGroupLayout);\n        }\n        return gpuBindGroupLayout;\n    };\n    Device_WebGPU.prototype._createBindGroupLayoutInternal = function (bindingLayout) {\n        var _this = this;\n        var entries = [[], []];\n        if (bindingLayout.storageEntries) {\n            for (var i = 0; i < bindingLayout.storageEntries.length; i++) {\n                entries[0].push({\n                    binding: entries[0].length,\n                    visibility: GPUShaderStage.COMPUTE,\n                    buffer: { type: bindingLayout.storageEntries[i].type },\n                });\n            }\n        }\n        for (var i = 0; i < bindingLayout.numUniformBuffers; i++)\n            entries[0].push({\n                binding: entries[0].length,\n                visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,\n                buffer: { type: 'uniform', hasDynamicOffset: true },\n            });\n        for (var i = 0; i < bindingLayout.numSamplers; i++) {\n            var samplerEntry = bindingLayout.samplerEntries !== undefined\n                ? bindingLayout.samplerEntries[i]\n                : gPluginDeviceRenderer.defaultBindingLayoutSamplerDescriptor;\n            entries[1].push({\n                binding: entries[1].length,\n                visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,\n                texture: translateBindGroupTextureBinding(samplerEntry),\n            });\n            entries[1].push({\n                binding: entries[1].length,\n                visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,\n                sampler: translateBindGroupSamplerBinding(samplerEntry),\n            });\n        }\n        var gpuBindGroupLayout = entries\n            .map(function (entries) {\n            return entries.length ? _this.device.createBindGroupLayout({ entries: entries }) : null;\n        })\n            .filter(function (layout) { return !!layout; });\n        return { gpuBindGroupLayout: gpuBindGroupLayout };\n    };\n    Device_WebGPU.prototype._createPipelineLayout = function (bindingLayouts) {\n        var _this = this;\n        var bindGroupLayouts = bindingLayouts.flatMap(function (bindingLayout) {\n            return _this.createBindGroupLayout(bindingLayout).gpuBindGroupLayout;\n        });\n        return this.device.createPipelineLayout({ bindGroupLayouts: bindGroupLayouts });\n    };\n    Device_WebGPU.prototype.createRenderPipelineInternal = function (renderPipeline, async) {\n        // if (this.device.createRenderPipelineAsync === undefined) {\n        //   async = false;\n        // }\n        var _a;\n        // // If we're already in the process of creating a the pipeline async, no need to kick the process off again...\n        // if (async && renderPipeline.isCreatingAsync) {\n        //   return;\n        // }\n        if (renderPipeline.gpuRenderPipeline !== null) {\n            return;\n        }\n        var descriptor = renderPipeline.descriptor;\n        var program = descriptor.program;\n        var vertexStage = program.vertexStage, fragmentStage = program.fragmentStage;\n        if (vertexStage === null || fragmentStage === null)\n            return;\n        descriptor.megaStateDescriptor = tslib.__assign(tslib.__assign({}, gPluginDeviceRenderer.copyMegaState(gPluginDeviceRenderer.defaultMegaState)), descriptor.megaStateDescriptor);\n        var layout = this._createPipelineLayout(descriptor.bindingLayouts || []);\n        var primitive = translatePrimitiveState((_a = descriptor.topology) !== null && _a !== void 0 ? _a : gPluginDeviceRenderer.PrimitiveTopology.TRIANGLES, descriptor.megaStateDescriptor);\n        var targets = translateTargets(descriptor.colorAttachmentFormats, descriptor.megaStateDescriptor);\n        var depthStencil = translateDepthStencilState(descriptor.depthStencilAttachmentFormat, descriptor.megaStateDescriptor);\n        var buffers = undefined;\n        if (descriptor.inputLayout !== null)\n            buffers = descriptor.inputLayout.buffers;\n        var sampleCount = descriptor.sampleCount;\n        // renderPipeline.isCreatingAsync = true;\n        var gpuRenderPipelineDescriptor = {\n            layout: layout,\n            // layout: 'auto',\n            vertex: tslib.__assign(tslib.__assign({}, vertexStage), { buffers: buffers }),\n            primitive: primitive,\n            depthStencil: depthStencil,\n            multisample: {\n                count: sampleCount,\n            },\n            fragment: tslib.__assign(tslib.__assign({}, fragmentStage), { targets: targets }),\n        };\n        // TODO: async creation\n        // @see https://www.w3.org/TR/webgpu/#dom-gpudevice-createrenderpipeline\n        // renderPipeline.gpuRenderPipeline =\n        //   this.device.createRenderPipeline(gpuRenderPipeline);\n        // if (renderPipeline.name !== undefined)\n        //   renderPipeline.gpuRenderPipeline.label = renderPipeline.name;\n        // if (async) {\n        //   const gpuRenderPipeline = await this.device.createRenderPipelineAsync(\n        //     gpuRenderPipelineDescriptor,\n        //   );\n        //   // We might have created a sync pipeline while we were async building; no way to cancel the async\n        //   // pipeline build at this point, so just chuck it out :/\n        //   if (renderPipeline.gpuRenderPipeline === null)\n        //     renderPipeline.gpuRenderPipeline = gpuRenderPipeline;\n        // } else {\n        renderPipeline.gpuRenderPipeline = this.device.createRenderPipeline(gpuRenderPipelineDescriptor);\n        // }\n        // // if (renderPipeline.ResourceName !== undefined)\n        // //     renderPipeline.gpuRenderPipeline.label = renderPipeline.ResourceName;\n        // renderPipeline.isCreatingAsync = false;\n    };\n    Device_WebGPU.prototype.createReadback = function () {\n        return new Readback_WebGPU({\n            id: this.getNextUniqueId(),\n            device: this,\n        });\n    };\n    Device_WebGPU.prototype.createRenderPass = function (renderPassDescriptor) {\n        var pass = this.renderPassPool.pop();\n        if (pass === undefined) {\n            pass = new RenderPass_WebGPU();\n        }\n        pass.commandEncoder = this.device.createCommandEncoder();\n        pass.beginRenderPass(renderPassDescriptor);\n        return pass;\n    };\n    Device_WebGPU.prototype.createComputePass = function () {\n        var pass = this.computePassPool.pop();\n        if (pass === undefined)\n            pass = new ComputePass_WebGPU();\n        pass.commandEncoder = this.device.createCommandEncoder();\n        pass.beginComputePass();\n        return pass;\n    };\n    Device_WebGPU.prototype.submitPass = function (_pass) {\n        var queue = this.device.queue;\n        var pass = _pass;\n        var commands = pass.finish();\n        queue.submit([commands]);\n        pass.commandEncoder = null;\n        // if (pass instanceof RenderPass_WebGPU) {\n        //   pass.finish();\n        //   this.renderPassPool.push(pass);\n        //   if (pass.occlusionQueryPool !== null) {\n        //     this.queryPoolsSubmitted.push(pass.occlusionQueryPool);\n        //   }\n        // } else if (pass instanceof ComputePass_WebGPU) {\n        //   pass.finish();\n        //   this.computePassPool.push(pass);\n        // }\n    };\n    Device_WebGPU.prototype.copySubTexture2D = function (dst_, dstX, dstY, src_, srcX, srcY) {\n        var cmd = this.device.createCommandEncoder();\n        var dst = dst_;\n        var src = src_;\n        var srcCopy = {\n            texture: src.gpuTexture,\n            origin: [srcX, srcY, 0],\n        };\n        var dstCopy = {\n            texture: dst.gpuTexture,\n            origin: [dstX, dstY, 0],\n        };\n        gPluginDeviceRenderer.assert(!!(src.usage & GPUTextureUsage$1.COPY_SRC));\n        gPluginDeviceRenderer.assert(!!(dst.usage & GPUTextureUsage$1.COPY_DST));\n        cmd.copyTextureToTexture(srcCopy, dstCopy, [src.width, src.height, 1]);\n        this.device.queue.submit([cmd.finish()]);\n    };\n    Device_WebGPU.prototype.queryLimits = function () {\n        // GPUAdapter.limits\n        // @see https://www.w3.org/TR/webgpu/#gpu-supportedlimits\n        return {\n            uniformBufferMaxPageWordSize: this.device.limits.maxUniformBufferBindingSize >>> 2,\n            uniformBufferWordAlignment: this.device.limits.minUniformBufferOffsetAlignment >>> 2,\n            supportedSampleCounts: [1],\n            occlusionQueriesRecommended: true,\n            computeShadersSupported: true,\n        };\n    };\n    Device_WebGPU.prototype.queryTextureFormatSupported = function (format, width, height) {\n        if (isFormatTextureCompressionBC(format)) {\n            if (!this.featureTextureCompressionBC)\n                return false;\n            var bb = getFormatBlockSize(format);\n            if (width % bb !== 0 || height % bb !== 0)\n                return false;\n            return this.featureTextureCompressionBC;\n        }\n        switch (format) {\n            case gPluginDeviceRenderer.Format.U16_RGBA_NORM:\n                return false;\n            case gPluginDeviceRenderer.Format.F32_RGBA:\n                return false; // unfilterable\n        }\n        return true;\n    };\n    Device_WebGPU.prototype.queryPlatformAvailable = function () {\n        // TODO: should listen to lost event\n        return true;\n    };\n    Device_WebGPU.prototype.queryVendorInfo = function () {\n        return this;\n    };\n    Device_WebGPU.prototype.queryRenderPass = function (o) {\n        var pass = o;\n        return pass.descriptor;\n    };\n    Device_WebGPU.prototype.queryRenderTarget = function (o) {\n        var attachment = o;\n        return attachment;\n    };\n    Device_WebGPU.prototype.setResourceName = function (o, s) {\n        o.name = s;\n        if (o.type === gPluginDeviceRenderer.ResourceType.Buffer) {\n            var r = o;\n            r.gpuBuffer.label = s;\n        }\n        else if (o.type === gPluginDeviceRenderer.ResourceType.Texture) {\n            var r = o;\n            r.gpuTexture.label = s;\n            r.gpuTextureView.label = s;\n        }\n        else if (o.type === gPluginDeviceRenderer.ResourceType.RenderTarget) {\n            var r = o;\n            r.gpuTexture.label = s;\n            r.gpuTextureView.label = s;\n        }\n        else if (o.type === gPluginDeviceRenderer.ResourceType.Sampler) {\n            var r = o;\n            r.gpuSampler.label = s;\n        }\n        else if (o.type === gPluginDeviceRenderer.ResourceType.RenderPipeline) {\n            var r = o;\n            if (r.gpuRenderPipeline !== null)\n                r.gpuRenderPipeline.label = s;\n        }\n    };\n    Device_WebGPU.prototype.setResourceLeakCheck = function (o, v) { };\n    Device_WebGPU.prototype.checkForLeaks = function () { };\n    Device_WebGPU.prototype.programPatched = function (o) { };\n    Device_WebGPU.prototype.pipelineQueryReady = function (o) {\n        var renderPipeline = o;\n        return renderPipeline.gpuRenderPipeline !== null;\n    };\n    Device_WebGPU.prototype.pipelineForceReady = function (o) {\n        var renderPipeline = o;\n        this.createRenderPipelineInternal(renderPipeline, false);\n    };\n    return Device_WebGPU;\n}());\n\nvar WebGPUDeviceContribution = /** @class */ (function () {\n    function WebGPUDeviceContribution(pluginOptions, runtime) {\n        this.pluginOptions = pluginOptions;\n        this.runtime = runtime;\n    }\n    WebGPUDeviceContribution.prototype.createSwapChain = function ($canvas) {\n        return tslib.__awaiter(this, void 0, void 0, function () {\n            var adapter, e_1, optionalFeatures, requiredFeatures, device, onContextLost_1, context;\n            return tslib.__generator(this, function (_a) {\n                switch (_a.label) {\n                    case 0:\n                        if (this.runtime.globalThis.navigator.gpu === undefined)\n                            return [2 /*return*/, null];\n                        adapter = null;\n                        _a.label = 1;\n                    case 1:\n                        _a.trys.push([1, 3, , 4]);\n                        return [4 /*yield*/, this.runtime.globalThis.navigator.gpu.requestAdapter()];\n                    case 2:\n                        adapter = _a.sent();\n                        return [3 /*break*/, 4];\n                    case 3:\n                        e_1 = _a.sent();\n                        console.log(e_1);\n                        return [3 /*break*/, 4];\n                    case 4:\n                        if (adapter === null)\n                            return [2 /*return*/, null];\n                        optionalFeatures = [\n                            // 'depth24unorm-stencil8',\n                            'depth32float-stencil8',\n                            'texture-compression-bc',\n                        ];\n                        requiredFeatures = optionalFeatures.filter(function (feature) {\n                            return adapter.features.has(feature);\n                        });\n                        return [4 /*yield*/, adapter.requestDevice({ requiredFeatures: requiredFeatures })];\n                    case 5:\n                        device = _a.sent();\n                        if (device) {\n                            onContextLost_1 = this.pluginOptions.onContextLost;\n                            device.lost.then(function () {\n                                if (onContextLost_1) {\n                                    onContextLost_1();\n                                }\n                            });\n                        }\n                        if (device === null)\n                            return [2 /*return*/, null];\n                        context = $canvas.getContext('webgpu');\n                        if (!context)\n                            return [2 /*return*/, null];\n                        _a.label = 6;\n                    case 6:\n                        _a.trys.push([6, 8, , 9]);\n                        return [4 /*yield*/, __wbg_init(this.pluginOptions.shaderCompilerPath)];\n                    case 7:\n                        _a.sent();\n                        return [3 /*break*/, 9];\n                    case 8:\n                        _a.sent();\n                        return [3 /*break*/, 9];\n                    case 9: \n                    // @ts-ignore\n                    return [2 /*return*/, new Device_WebGPU(adapter, device, $canvas, context, glsl_compile)];\n                }\n            });\n        });\n    };\n    return WebGPUDeviceContribution;\n}());\n\nvar Plugin = /** @class */ (function (_super) {\n    tslib.__extends(Plugin, _super);\n    function Plugin(options) {\n        if (options === void 0) { options = {}; }\n        var _this = _super.call(this) || this;\n        _this.options = options;\n        _this.name = 'webgpu-device';\n        return _this;\n    }\n    Plugin.prototype.init = function (runtime) {\n        this.context.deviceContribution = new WebGPUDeviceContribution(tslib.__assign({ shaderCompilerPath: '/glsl_wgsl_compiler_bg.wasm' }, this.options), runtime);\n    };\n    Plugin.prototype.destroy = function () {\n        delete this.context.deviceContribution;\n    };\n    return Plugin;\n}(gLite.AbstractRendererPlugin));\n\nexports.Plugin = Plugin;\nexports.WebGPUDeviceContribution = WebGPUDeviceContribution;\n\n"]}