typegpu 0.8.0-alpha.2 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -6
- package/chunk-2UXPGML5.js +7 -0
- package/chunk-2UXPGML5.js.map +1 -0
- package/chunk-3246CM7C.cjs +2 -0
- package/chunk-3246CM7C.cjs.map +1 -0
- package/{chunk-BDGVKGU4.js → chunk-4W5Z7BO4.js} +6 -6
- package/chunk-4W5Z7BO4.js.map +1 -0
- package/{chunk-ESIHND6W.cjs → chunk-5Y6GTBWR.cjs} +3 -3
- package/{chunk-ESIHND6W.cjs.map → chunk-5Y6GTBWR.cjs.map} +1 -1
- package/{chunk-DH4X56C7.js → chunk-7S3IK3D4.js} +2 -2
- package/{chunk-MJ6A4DOA.js → chunk-7XFSK632.js} +2 -2
- package/{chunk-WDMOZFKN.cjs → chunk-PRMFGUQT.cjs} +2 -2
- package/{chunk-WDMOZFKN.cjs.map → chunk-PRMFGUQT.cjs.map} +1 -1
- package/{chunk-44LAYHPR.cjs → chunk-TRE7NUKE.cjs} +6 -6
- package/chunk-TRE7NUKE.cjs.map +1 -0
- package/chunk-VOVQAOVG.js +2 -0
- package/chunk-VOVQAOVG.js.map +1 -0
- package/chunk-ZYGTVBDH.cjs +7 -0
- package/chunk-ZYGTVBDH.cjs.map +1 -0
- package/common/index.cjs +1 -1
- package/common/index.d.cts +1 -1
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/data/index.cjs +1 -1
- package/data/index.d.cts +3 -3
- package/data/index.d.ts +3 -3
- package/data/index.js +1 -1
- package/index.cjs +51 -51
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +40 -40
- package/index.js.map +1 -1
- package/{matrix-UOB09LaW.d.cts → matrix-DHFT4O8f.d.cts} +1 -1
- package/{matrix-CjLuYXH1.d.ts → matrix-DLipCOZF.d.ts} +1 -1
- package/package.json +2 -2
- package/std/index.cjs +1 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +2 -2
- package/std/index.d.ts +2 -2
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/{tgpuConstant-sKeoSjPD.d.ts → tgpuConstant-BU72w5qs.d.cts} +15 -13
- package/{tgpuConstant-sKeoSjPD.d.cts → tgpuConstant-BU72w5qs.d.ts} +15 -13
- package/chunk-44LAYHPR.cjs.map +0 -1
- package/chunk-6OJFCDQF.js +0 -7
- package/chunk-6OJFCDQF.js.map +0 -1
- package/chunk-BDGVKGU4.js.map +0 -1
- package/chunk-CODEFPMD.cjs +0 -2
- package/chunk-CODEFPMD.cjs.map +0 -1
- package/chunk-HLB6TY7I.cjs +0 -7
- package/chunk-HLB6TY7I.cjs.map +0 -1
- package/chunk-ZYSFFI3M.js +0 -2
- package/chunk-ZYSFFI3M.js.map +0 -1
- /package/{chunk-DH4X56C7.js.map → chunk-7S3IK3D4.js.map} +0 -0
- /package/{chunk-MJ6A4DOA.js.map → chunk-7XFSK632.js.map} +0 -0
package/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24; var _class25; var _class26; var _class27; var _class28; var _class29; var _class30; var _class31;var _chunkESIHND6Wcjs = require('./chunk-ESIHND6W.cjs');var _chunkCODEFPMDcjs = require('./chunk-CODEFPMD.cjs');var _chunkHLB6TY7Icjs = require('./chunk-HLB6TY7I.cjs');var _chunk44LAYHPRcjs = require('./chunk-44LAYHPR.cjs');function Jn(t){return _optionalChain([t, 'optionalAccess', _2 => _2[_chunk44LAYHPRcjs.b]])}var R={get(t,e){if(e in t)return Reflect.get(t,e);if(e==="toString"||e===Symbol.toStringTag||e===Symbol.toPrimitive)return()=>t.toString();if(typeof e=="symbol")return;let n=_chunk44LAYHPRcjs.ua.call(void 0, t).dataType,a=_chunkHLB6TY7Icjs.n.call(void 0, n,String(e));if(a.type!=="unknown")return new Proxy({[_chunk44LAYHPRcjs.a]:!0,[_chunk44LAYHPRcjs.f]:o=>_chunk44LAYHPRcjs.aa.call(void 0, `${o.resolve(t).value}.${String(e)}`,a),get[_chunk44LAYHPRcjs.e](){return _chunk44LAYHPRcjs.aa.call(void 0, this,a)},toString:()=>`${String(t)}.${e}`},R)}};function ge(t){let e=t;for(;;){let r=Jn(e);if(!r)break;e=r}return e}function Ir(t,e){return new vr(t,e)}var vr= (_class =class{constructor(e,r){;_class.prototype.__init.call(this);this.dataType=e;this.#e=r}__init() {this[_chunk44LAYHPRcjs.a]={}}#e;$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this,e),this}[_chunk44LAYHPRcjs.f](e){let r=e.getUniqueName(this),n=e.resolve(this.dataType).value,a=e.resolve(this.#e,this.dataType).value;return e.addDeclaration(`const ${r}: ${n} = ${a};`),_chunk44LAYHPRcjs.aa.call(void 0, r,this.dataType)}toString(){return`const:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunk44LAYHPRcjs.b](){let e=this.dataType;return new Proxy({[_chunk44LAYHPRcjs.a]:!0,get[_chunk44LAYHPRcjs.e](){return _chunk44LAYHPRcjs.aa.call(void 0, this,e)},[_chunk44LAYHPRcjs.f]:r=>r.resolve(this),toString:()=>`const:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},R)}get value(){return _chunk44LAYHPRcjs.Da.call(void 0, )?this[_chunk44LAYHPRcjs.b]:this.#e}get $(){return this.value}}, _class);function Xn(t){return new Ur(t)}var Ur= (_class2 =class{constructor(e){;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);this.declaration=e}__init2() {this[_chunk44LAYHPRcjs.a]=!0}__init3() {this.externalsToApply=[]}$uses(e){return this.externalsToApply.push(e),this}[_chunk44LAYHPRcjs.f](e){let r={};for(let a of this.externalsToApply)_chunkESIHND6Wcjs.a.call(void 0, r,a);let n=_chunkESIHND6Wcjs.d.call(void 0, e,r,this.declaration);return e.addDeclaration(n),_chunk44LAYHPRcjs.aa.call(void 0, "",_chunk44LAYHPRcjs.q)}toString(){return`declare: ${this.declaration}`}}, _class2);function Et(t){let e={argTypes:t.in&&Object.keys(t.in).length!==0?[_chunkESIHND6Wcjs.f.call(void 0, t.in)]:[],returnType:_chunk44LAYHPRcjs.q,workgroupSize:[_nullishCoalesce(t.workgroupSize[0], () => (1)),_nullishCoalesce(t.workgroupSize[1], () => (1)),_nullishCoalesce(t.workgroupSize[2], () => (1))],isEntry:!0},r=(n,...a)=>Qa(e,t.workgroupSize,_chunkESIHND6Wcjs.g.call(void 0, n,...a));return Object.assign(Object.assign(r,e),{does:r})}function Qa(t,e,r){let n=_chunkESIHND6Wcjs.e.call(void 0, r,`@compute @workgroup_size(${e.join(", ")}) `),a=t.argTypes[0];return{shell:t,$uses(s){return n.applyExternals(s),this},[_chunk44LAYHPRcjs.a]:!0,[_chunk44LAYHPRcjs.c]:n,$name(s){return _chunk44LAYHPRcjs.k.call(void 0, n,s),_chunk44LAYHPRcjs.l.call(void 0, a)&&a.$name(`${s}_Input`),this},[_chunk44LAYHPRcjs.f](s){return n.resolve(s,t.argTypes,t.returnType)},toString(){return`computeFn:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, n), () => ("<unnamed>"))}`}}}function U(t,e){let r={[_chunk44LAYHPRcjs.a]:!0,argTypes:t,returnType:_nullishCoalesce(e, () => (_chunk44LAYHPRcjs.q)),isEntry:!1};return Object.assign((a,...o)=>Ka(r,_chunkESIHND6Wcjs.g.call(void 0, a,...o)),r)}function He(t){return _chunk44LAYHPRcjs.h.call(void 0, t)&&_optionalChain([t, 'optionalAccess', _3 => _3.resourceType])==="function"}function Ha([t,e]){return`${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, t), () => ("<unnamed>"))}=${e}`}function Ka(t,e){let r=_chunkESIHND6Wcjs.e.call(void 0, e,""),n={shell:t,resourceType:"function",$uses(s){return r.applyExternals(s),this},[_chunk44LAYHPRcjs.c]:r,$name(s){return _chunk44LAYHPRcjs.k.call(void 0, r,s),this},with(s,i){return Zn(o,[[_chunk44LAYHPRcjs.pa.call(void 0, s)?s.slot:s,i]])},[_chunk44LAYHPRcjs.f](s){return typeof e=="string"&&(_chunkESIHND6Wcjs.b.call(void 0, e,t.argTypes,r.applyExternals),_chunkESIHND6Wcjs.c.call(void 0, e,t.returnType,r.applyExternals)),r.resolve(s,t.argTypes,t.returnType)}},a=_chunk44LAYHPRcjs.Ma.call(void 0, (...s)=>_chunk44LAYHPRcjs.xa.call(void 0, ()=>{try{if(typeof e=="string")throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");let i=s.map((l,f)=>_chunk44LAYHPRcjs.rc.call(void 0, t.argTypes[f],l)),u=e(...i);return _chunk44LAYHPRcjs.rc.call(void 0, t.returnType,u)}catch(i){throw i instanceof _chunk44LAYHPRcjs.da?i.appendToTrace(o):new (0, _chunk44LAYHPRcjs.da)(i,[o])}}),(...s)=>_chunk44LAYHPRcjs.aa.call(void 0, new Vt(o,s),t.returnType),"tgpuFnCall",t.argTypes),o=Object.assign(a,n);return o[_chunk44LAYHPRcjs.a].implementation=e,Object.defineProperty(o,"toString",{value(){return`fn:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, r), () => ("<unnamed>"))}`}}),o}function Zn(t,e){let r={resourceType:"function",shell:t.shell,[_chunk44LAYHPRcjs.d]:{inner:t,pairs:e},$uses(o){return t.$uses(o),this},[_chunk44LAYHPRcjs.c]:t,$name(o){return t.$name(o),this},with(o,s){return Zn(a,[...e,[_chunk44LAYHPRcjs.pa.call(void 0, o)?o.slot:o,s]])}},n=_chunk44LAYHPRcjs.Ma.call(void 0, (...o)=>t(...o),(...o)=>_chunk44LAYHPRcjs.aa.call(void 0, new Vt(a,o),t.shell.returnType),"tgpuFnCall",t.shell.argTypes),a=Object.assign(n,r);return a[_chunk44LAYHPRcjs.a].implementation=t[_chunk44LAYHPRcjs.a].implementation,Object.defineProperty(a,"toString",{value(){return`fn:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, t), () => ("<unnamed>"))}[${e.map(Ha).join(", ")}]`}}),a[_chunk44LAYHPRcjs.a].implementation=t[_chunk44LAYHPRcjs.a].implementation,a}var Vt= (_class3 =class{__init4() {this[_chunk44LAYHPRcjs.a]=!0}#e;#r;constructor(e,r){;_class3.prototype.__init4.call(this);this.#e=e,this.#r=r,this[_chunk44LAYHPRcjs.c]=e,this[_chunk44LAYHPRcjs.e]=_chunk44LAYHPRcjs.aa.call(void 0, this,this.#e.shell.returnType)}[_chunk44LAYHPRcjs.f](e){return e.withResetIndentLevel(()=>_chunk44LAYHPRcjs.aa.call(void 0, _chunk44LAYHPRcjs.Ea`${e.resolve(this.#e).value}(${this.#r})`,this.#e.shell.returnType))}toString(){return`call:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}}, _class3);function ea(t){let e={in:t.in,out:t.out,returnType:_chunkESIHND6Wcjs.f.call(void 0, t.out),isEntry:!0},r=(n,...a)=>Ya(e,_chunkESIHND6Wcjs.g.call(void 0, n,...a));return Object.assign(Object.assign(r,e),{does:r})}function Ya(t,e){let r=_chunkESIHND6Wcjs.e.call(void 0, e,"@fragment "),n=t.returnType;return typeof e=="string"&&_chunkESIHND6Wcjs.c.call(void 0, e,n,o=>r.applyExternals(o)),{shell:t,outputType:n,$uses(o){return r.applyExternals(o),this},[_chunk44LAYHPRcjs.a]:!0,[_chunk44LAYHPRcjs.c]:r,$name(o){return _chunk44LAYHPRcjs.k.call(void 0, r,o),_chunk44LAYHPRcjs.l.call(void 0, n)&&n.$name(`${o}_Output`),this},[_chunk44LAYHPRcjs.f](o){let s=t.in?_chunkESIHND6Wcjs.f.call(void 0, t.in,o.varyingLocations).$name(`${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => (""))}_Input`):void 0;return s&&r.applyExternals({In:s}),r.applyExternals({Out:n}),r.resolve(o,s?[s]:[],t.returnType)},toString(){return`fragmentFn:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, r), () => ("<unnamed>"))}`}}}var ta=new Set(["alias","break","case","const","const_assert","continue","continuing","default","diagnostic","discard","else","enable","false","fn","for","if","let","loop","override","requires","return","struct","switch","true","var","while","NULL","Self","abstract","active","alignas","alignof","as","asm","asm_fragment","async","attribute","auto","await","become","cast","catch","class","co_await","co_return","co_yield","coherent","column_major","common","compile","compile_fragment","concept","const_cast","consteval","constexpr","constinit","crate","debugger","decltype","delete","demote","demote_to_helper","do","dynamic_cast","enum","explicit","export","extends","extern","external","fallthrough","filter","final","finally","friend","from","fxgroup","get","goto","groupshared","highp","impl","implements","import","inline","instanceof","interface","layout","lowp","macro","macro_rules","match","mediump","meta","mod","module","move","mut","mutable","namespace","new","nil","noexcept","noinline","nointerpolation","non_coherent","noncoherent","noperspective","null","nullptr","of","operator","package","packoffset","partition","pass","patch","pixelfragment","precise","precision","premerge","priv","protected","pub","public","readonly","ref","regardless","register","reinterpret_cast","require","resource","restrict","self","set","shared","sizeof","smooth","snorm","static","static_assert","static_cast","std","subroutine","super","target","template","this","thread_local","throw","trait","try","type","typedef","typeid","typename","typeof","union","unless","unorm","unsafe","unsized","use","using","varying","virtual","volatile","wgsl","where","with","writeonly","yield"]);function Fr(t){if(t==="_"||t.startsWith("__")||/\s/.test(t))throw new Error(`Invalid identifier '${t}'. Choose an identifier without whitespaces or leading underscores.`);let e=t.split("_")[0];return!ta.has(e)}var _t=class{makeValid(e){return Fr(e)?e:this.makeUnique(e)}},Wt= (_class4 =class extends _t{constructor(...args2) { super(...args2); _class4.prototype.__init5.call(this); }__init5() {this.lastUniqueId=0}makeUnique(e){let r;return e?(r=e.replaceAll(/\s/g,"_"),r=r.replaceAll(/[^\w\d]/g,"")):r="item",`${r}_${this.lastUniqueId++}`}}, _class4),kt= (_class5 =class extends _t{constructor(...args3) { super(...args3); _class5.prototype.__init6.call(this); }__init6() {this._usedNames=new Set(ta)}makeUnique(e){if(e===void 0)throw new Error("Unnamed item found when using a strict name registry");let r=0,n=e;for(;this._usedNames.has(n);)r++,n=`${e}_${r}`;return this._usedNames.add(n),n}}, _class5);function ra(t,e){let r=_chunkESIHND6Wcjs.e.call(void 0, e,"");return{[_chunk44LAYHPRcjs.a]:!0,[_chunk44LAYHPRcjs.c]:r,resourceType:"shellless-impl",[_chunk44LAYHPRcjs.f](n){return r.resolve(n,t,void 0)},toString(){return`fn*:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, r), () => ("<unnamed>"))}`}}}var Ot= (_class6 =class{constructor() { _class6.prototype.__init7.call(this); }__init7() {this.cache=new Map}get(e,r){let n=_chunk44LAYHPRcjs.n.call(void 0, e);if(!_optionalChain([n, 'optionalAccess', _4 => _4.ast]))return;if(!r&&n.ast.params.length>0)throw new Error(`Cannot resolve '${_chunk44LAYHPRcjs.j.call(void 0, e)}' directly, because it expects arguments. Either call it from another function, or wrap it in a shell`);let a=(_nullishCoalesce(r, () => ([]))).map(i=>_chunkHLB6TY7Icjs.p.call(void 0, i.dataType)),o=this.cache.get(e);if(o){let i=o.find(u=>u.argTypes.every((l,f)=>l===a[f]));if(i)return i.value}else o=[],this.cache.set(e,o);let s=ra(a,e);return o.push({argTypes:a,value:s}),s}}, _class6);var Pr=class{constructor(e){this[_chunk44LAYHPRcjs.a]={nameRegistry:e,shelllessRepo:new Ot,memoizedResolves:new WeakMap,memoizedDerived:new WeakMap,listeners:{name:new Set}}}on(e,r){if(e==="name"){let n=this[_chunk44LAYHPRcjs.a].listeners.name;return n.add(r),()=>n.delete(r)}throw new Error(`Unsupported event: ${e}`)}};function na(t,e){let r=t.nameRegistry.makeUnique(_chunk44LAYHPRcjs.j.call(void 0, e));for(let n of t.listeners.name)n({target:e,name:r});return r}function j(t){let{names:e="random"}=t||{};return new Pr(e==="strict"?new kt:new Wt)}function Ke(t){return typeof _optionalChain([t, 'optionalAccess', _5 => _5.format])=="string"}function aa(t,e){let r=[];if(_chunk44LAYHPRcjs.V.call(void 0, t)){if(!Ke(e))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(e._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:e._layout.stride,stepMode:e._layout.stepMode,attributes:[{format:e.format,offset:e.offset,shaderLocation:_nullishCoalesce(_chunk44LAYHPRcjs.U.call(void 0, t), () => (0))}]}]}}let n=[],a=new WeakMap,o=0;for(let[s,i]of Object.entries(t)){if(_chunk44LAYHPRcjs.pc.call(void 0, i))continue;let u=e[s];if(!u)throw new Error(`An attribute by the name of '${s}' was not provided to the shader.`);let l=u._layout,f=a.get(l);f||(r.push(l),f=[],n.push({arrayStride:l.stride,stepMode:l.stepMode,attributes:f}),a.set(l,f)),o=_nullishCoalesce(_chunk44LAYHPRcjs.U.call(void 0, i), () => (o)),f.push({format:u.format,offset:u.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var Ja=["bool","f32","f16","i32","u32","vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","vec2<bool>","vec3<bool>","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","texture_external"];function Xa(t){return Ja.includes(t.type)}function Dr(t,[e,r]){if(!Fr(e))throw new Error(`Property key '${e}' is a reserved WGSL word. Choose a different name.`);return` ${_chunk44LAYHPRcjs.qc.call(void 0, r)}${e}: ${t.resolve(r).value},
|
|
2
|
-
`}function
|
|
3
|
-
${Object.entries(
|
|
4
|
-
${Object.entries(
|
|
5
|
-
}`),r}function
|
|
6
|
-
`},"unorm8x4-bgra":{writeFunction:"setUint8",generator:(t
|
|
7
|
-
`;return n}}};function qt(t,
|
|
8
|
-
`,i+=qt(
|
|
9
|
-
`,i}if(
|
|
10
|
-
`;return i}if(
|
|
11
|
-
`}return
|
|
12
|
-
`}return
|
|
13
|
-
`}function
|
|
14
|
-
Reason: ${
|
|
15
|
-
Falling back to default writer`)}}var Re={bool(){throw new Error("Booleans are not host-shareable")},f32(t,e,r){t.writeFloat32(r)},f16(t,e,r){t.writeFloat16(r)},i32(t,e,r){t.writeInt32(r)},u32(t,e,r){t.writeUint32(r)},u16(t,e,r){t.writeUint16(r)},vec2f(t,e,r){t.writeFloat32(r.x),t.writeFloat32(r.y)},vec2h(t,e,r){t.writeFloat16(r.x),t.writeFloat16(r.y)},vec2i(t,e,r){t.writeInt32(r.x),t.writeInt32(r.y)},vec2u(t,e,r){t.writeUint32(r.x),t.writeUint32(r.y)},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},vec3f(t,e,r){t.writeFloat32(r.x),t.writeFloat32(r.y),t.writeFloat32(r.z)},vec3h(t,e,r){t.writeFloat16(r.x),t.writeFloat16(r.y),t.writeFloat16(r.z)},vec3i(t,e,r){t.writeInt32(r.x),t.writeInt32(r.y),t.writeInt32(r.z)},vec3u(t,e,r){t.writeUint32(r.x),t.writeUint32(r.y),t.writeUint32(r.z)},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},vec4f(t,e,r){t.writeFloat32(r.x),t.writeFloat32(r.y),t.writeFloat32(r.z),t.writeFloat32(r.w)},vec4h(t,e,r){t.writeFloat16(r.x),t.writeFloat16(r.y),t.writeFloat16(r.z),t.writeFloat16(r.w)},vec4i(t,e,r){t.writeInt32(r.x),t.writeInt32(r.y),t.writeInt32(r.z),t.writeInt32(r.w)},vec4u(t,e,r){t.writeUint32(r.x),t.writeUint32(r.y),t.writeUint32(r.z),t.writeUint32(r.w)},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(t,e,r){for(let n=0;n<r.length;++n)t.writeFloat32(r[n])},mat3x3f(t,e,r){for(let n=0;n<r.length;++n)t.writeFloat32(r[n])},mat4x4f(t,e,r){for(let n=0;n<r.length;++n)t.writeFloat32(r[n])},struct(t,e,r){let n=_chunk44LAYHPRcjs.ec.call(void 0, e);$(t,n);for(let[a,o]of Object.entries(e.propTypes))$(t,_chunk44LAYHPRcjs.ec.call(void 0, o)),Le(t,o,r[a]);$(t,n)},array(t,e,r){if(e.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunk44LAYHPRcjs.ec.call(void 0, e);$(t,n);let a=t.currentByteOffset;for(let o=0;o<Math.min(e.elementCount,r.length);o++)$(t,n),Le(t,e.elementType,r[o]);t.seekTo(a+_chunk44LAYHPRcjs.ic.call(void 0, e))},ptr(){throw new Error("Pointers are not host-shareable")},atomic(t,e,r){_optionalChain([Re, 'access', _6 => _6[e.inner.type], 'optionalCall', _7 => _7(t,e,r)])},decorated(t,e,r){let n=_chunk44LAYHPRcjs.fc.call(void 0, e);$(t,n);let a=t.currentByteOffset;_optionalChain([Re, 'access', _8 => _8[_optionalChain([e, 'access', _9 => _9.inner, 'optionalAccess', _10 => _10.type])], 'optionalCall', _11 => _11(t,e.inner,r)]),t.seekTo(a+_chunk44LAYHPRcjs.ic.call(void 0, e))},uint8(t,e,r){t.writeUint8(r)},uint8x2(t,e,r){t.writeUint8(r.x),t.writeUint8(r.y)},uint8x4(t,e,r){t.writeUint8(r.x),t.writeUint8(r.y),t.writeUint8(r.z),t.writeUint8(r.w)},sint8(t,e,r){t.writeInt8(r)},sint8x2(t,e,r){t.writeInt8(r.x),t.writeInt8(r.y)},sint8x4(t,e,r){t.writeInt8(r.x),t.writeInt8(r.y),t.writeInt8(r.z),t.writeInt8(r.w)},unorm8(t,e,r){t.writeUint8(Math.round(r*255))},unorm8x2(t,e,r){t.writeUint8(Math.round(r.x*255)),t.writeUint8(Math.round(r.y*255))},unorm8x4(t,e,r){t.writeUint8(Math.round(r.x*255)),t.writeUint8(Math.round(r.y*255)),t.writeUint8(Math.round(r.z*255)),t.writeUint8(Math.round(r.w*255))},snorm8(t,e,r){t.writeInt8(Math.round(r*127))},snorm8x2(t,e,r){t.writeInt8(Math.round(r.x*127)),t.writeInt8(Math.round(r.y*127))},snorm8x4(t,e,r){t.writeInt8(Math.round(r.x*127)),t.writeInt8(Math.round(r.y*127)),t.writeInt8(Math.round(r.z*127)),t.writeInt8(Math.round(r.w*127))},uint16(t,e,r){t.writeUint16(r)},uint16x2(t,e,r){t.writeUint16(r.x),t.writeUint16(r.y)},uint16x4(t,e,r){t.writeUint16(r.x),t.writeUint16(r.y),t.writeUint16(r.z),t.writeUint16(r.w)},sint16(t,e,r){t.writeInt16(r)},sint16x2(t,e,r){t.writeInt16(r.x),t.writeInt16(r.y)},sint16x4(t,e,r){t.writeInt16(r.x),t.writeInt16(r.y),t.writeInt16(r.z),t.writeInt16(r.w)},unorm16(t,e,r){t.writeUint16(r*65535)},unorm16x2(t,e,r){t.writeUint16(r.x*65535),t.writeUint16(r.y*65535)},unorm16x4(t,e,r){t.writeUint16(r.x*65535),t.writeUint16(r.y*65535),t.writeUint16(r.z*65535),t.writeUint16(r.w*65535)},snorm16(t,e,r){t.writeInt16(Math.round(r*32767))},snorm16x2(t,e,r){t.writeInt16(Math.round(r.x*32767)),t.writeInt16(Math.round(r.y*32767))},snorm16x4(t,e,r){t.writeInt16(Math.round(r.x*32767)),t.writeInt16(Math.round(r.y*32767)),t.writeInt16(Math.round(r.z*32767)),t.writeInt16(Math.round(r.w*32767))},float16(t,e,r){t.writeFloat16(r)},float16x2(t,e,r){t.writeFloat16(r.x),t.writeFloat16(r.y)},float16x4(t,e,r){t.writeFloat16(r.x),t.writeFloat16(r.y),t.writeFloat16(r.z),t.writeFloat16(r.w)},float32(t,e,r){t.writeFloat32(r)},float32x2(t,e,r){t.writeFloat32(r.x),t.writeFloat32(r.y)},float32x3(t,e,r){t.writeFloat32(r.x),t.writeFloat32(r.y),t.writeFloat32(r.z)},float32x4(t,e,r){t.writeFloat32(r.x),t.writeFloat32(r.y),t.writeFloat32(r.z),t.writeFloat32(r.w)},uint32(t,e,r){t.writeUint32(r)},uint32x2(t,e,r){t.writeUint32(r.x),t.writeUint32(r.y)},uint32x3(t,e,r){t.writeUint32(r.x),t.writeUint32(r.y),t.writeUint32(r.z)},uint32x4(t,e,r){t.writeUint32(r.x),t.writeUint32(r.y),t.writeUint32(r.z),t.writeUint32(r.w)},sint32(t,e,r){t.writeInt32(r)},sint32x2(t,e,r){t.writeInt32(r.x),t.writeInt32(r.y)},sint32x3(t,e,r){t.writeInt32(r.x),t.writeInt32(r.y),t.writeInt32(r.z)},sint32x4(t,e,r){t.writeInt32(r.x),t.writeInt32(r.y),t.writeInt32(r.z),t.writeInt32(r.w)},"unorm10-10-10-2"(t,e,r){let n=0;n|=(r.x*1023&1023)<<22,n|=(r.y*1023&1023)<<12,n|=(r.z*1023&1023)<<2,n|=r.w*3&3,t.writeUint32(n)},"unorm8x4-bgra"(t,e,r){t.writeUint8(r.z*255),t.writeUint8(r.y*255),t.writeUint8(r.x*255),t.writeUint8(r.w*255)},disarray(t,e,r){let n=_chunk44LAYHPRcjs.ec.call(void 0, e);$(t,n);let a=t.currentByteOffset;for(let o=0;o<Math.min(e.elementCount,r.length);o++)$(t,n),_optionalChain([Re, 'access', _12 => _12[_optionalChain([e, 'access', _13 => _13.elementType, 'optionalAccess', _14 => _14.type])], 'optionalCall', _15 => _15(t,e.elementType,r[o])]);t.seekTo(a+_chunk44LAYHPRcjs.ic.call(void 0, e))},unstruct(t,e,r){let n=e.propTypes;for(let[a,o]of Object.entries(n))_optionalChain([Re, 'access', _16 => _16[o.type], 'optionalCall', _17 => _17(t,o,r[a])])},"loose-decorated"(t,e,r){let n=_chunk44LAYHPRcjs.fc.call(void 0, e);$(t,n);let a=t.currentByteOffset,o=Re[_optionalChain([e, 'access', _18 => _18.inner, 'optionalAccess', _19 => _19.type])];return _optionalChain([o, 'optionalCall', _20 => _20(t,e.inner,r)]),t.seekTo(a+_chunk44LAYHPRcjs.ic.call(void 0, e)),r}};function Le(t,e,r){let n=Re[e.type];if(!n)throw new Error(`Cannot write data of type '${e.type}'.`);n(t,e,r)}var uo={bool(){throw new Error("Booleans are not host-shareable")},f32(t){return t.readFloat32()},f16(t){return t.readFloat16()},i32(t){return t.readInt32()},u32(t){return t.readUint32()},u16(t){return t.readUint16()},vec2f(t){return _chunk44LAYHPRcjs.Ya.call(void 0, t.readFloat32(),t.readFloat32())},vec3f(t){return _chunk44LAYHPRcjs.bb.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32())},vec4f(t){return _chunk44LAYHPRcjs.gb.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32())},vec2h(t){return _chunk44LAYHPRcjs.Za.call(void 0, t.readFloat16(),t.readFloat16())},vec3h(t){return _chunk44LAYHPRcjs.cb.call(void 0, t.readFloat16(),t.readFloat16(),t.readFloat16())},vec4h(t){return _chunk44LAYHPRcjs.hb.call(void 0, t.readFloat16(),t.readFloat16(),t.readFloat16(),t.readFloat16())},vec2i(t){return _chunk44LAYHPRcjs._a.call(void 0, t.readInt32(),t.readInt32())},vec3i(t){return _chunk44LAYHPRcjs.db.call(void 0, t.readInt32(),t.readInt32(),t.readInt32())},vec4i(t){return _chunk44LAYHPRcjs.ib.call(void 0, t.readInt32(),t.readInt32(),t.readInt32(),t.readInt32())},vec2u(t){return _chunk44LAYHPRcjs.$a.call(void 0, t.readUint32(),t.readUint32())},vec3u(t){return _chunk44LAYHPRcjs.eb.call(void 0, t.readUint32(),t.readUint32(),t.readUint32())},vec4u(t){return _chunk44LAYHPRcjs.jb.call(void 0, t.readUint32(),t.readUint32(),t.readUint32(),t.readUint32())},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(t){return _chunkHLB6TY7Icjs.j.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32())},mat3x3f(t){let e=()=>{let r=t.readFloat32();return t.readFloat32(),r};return _chunkHLB6TY7Icjs.k.call(void 0, t.readFloat32(),t.readFloat32(),e(),t.readFloat32(),t.readFloat32(),e(),t.readFloat32(),t.readFloat32(),e())},mat4x4f(t){return _chunkHLB6TY7Icjs.l.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32())},struct(t,e){let r=_chunk44LAYHPRcjs.ec.call(void 0, e);$(t,r);let n={},a=e.propTypes;for(let[o,s]of Object.entries(a))$(t,_chunk44LAYHPRcjs.ec.call(void 0, s)),n[o]=O(t,s);return $(t,r),n},array(t,e){if(e.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunk44LAYHPRcjs.ec.call(void 0, e),n=[];for(let a=0;a<e.elementCount;a++){$(t,r);let o=e.elementType,s=O(t,o);n.push(s)}return $(t,r),n},ptr(){throw new Error("Pointers are not host-shareable")},atomic(t,e){return O(t,e.inner)},decorated(t,e){let r=_chunk44LAYHPRcjs.fc.call(void 0, e);$(t,r);let n=t.currentByteOffset,a=O(t,e.inner);return t.seekTo(n+_chunk44LAYHPRcjs.ic.call(void 0, e)),a},uint8:t=>t.readUint8(),uint8x2:t=>_chunk44LAYHPRcjs.$a.call(void 0, t.readUint8(),t.readUint8()),uint8x4:t=>_chunk44LAYHPRcjs.jb.call(void 0, t.readUint8(),t.readUint8(),t.readUint8(),t.readUint8()),sint8:t=>t.readInt8(),sint8x2:t=>_chunk44LAYHPRcjs._a.call(void 0, t.readInt8(),t.readInt8()),sint8x4:t=>_chunk44LAYHPRcjs.ib.call(void 0, t.readInt8(),t.readInt8(),t.readInt8(),t.readInt8()),unorm8:t=>t.readUint8()/255,unorm8x2:t=>_chunk44LAYHPRcjs.Ya.call(void 0, t.readUint8()/255,t.readUint8()/255),unorm8x4:t=>_chunk44LAYHPRcjs.gb.call(void 0, t.readUint8()/255,t.readUint8()/255,t.readUint8()/255,t.readUint8()/255),snorm8:t=>t.readInt8()/127,snorm8x2:t=>_chunk44LAYHPRcjs.Ya.call(void 0, t.readInt8()/127,t.readInt8()/127),snorm8x4:t=>_chunk44LAYHPRcjs.gb.call(void 0, t.readInt8()/127,t.readInt8()/127,t.readInt8()/127,t.readInt8()/127),uint16:t=>t.readUint16(),uint16x2:t=>_chunk44LAYHPRcjs.$a.call(void 0, t.readUint16(),t.readUint16()),uint16x4:t=>_chunk44LAYHPRcjs.jb.call(void 0, t.readUint16(),t.readUint16(),t.readUint16(),t.readUint16()),sint16:t=>t.readInt16(),sint16x2:t=>_chunk44LAYHPRcjs._a.call(void 0, t.readInt16(),t.readInt16()),sint16x4:t=>_chunk44LAYHPRcjs.ib.call(void 0, t.readInt16(),t.readInt16(),t.readInt16(),t.readInt16()),unorm16:t=>t.readUint16()/65535,unorm16x2:t=>_chunk44LAYHPRcjs.Ya.call(void 0, t.readUint16()/65535,t.readUint16()/65535),unorm16x4:t=>_chunk44LAYHPRcjs.gb.call(void 0, t.readUint16()/65535,t.readUint16()/65535,t.readUint16()/65535,t.readUint16()/65535),snorm16:t=>t.readInt16()/32767,snorm16x2:t=>_chunk44LAYHPRcjs.Ya.call(void 0, t.readInt16()/32767,t.readInt16()/32767),snorm16x4:t=>_chunk44LAYHPRcjs.gb.call(void 0, t.readInt16()/32767,t.readInt16()/32767,t.readInt16()/32767,t.readInt16()/32767),float16(t){return t.readFloat16()},float16x2:t=>_chunk44LAYHPRcjs.Ya.call(void 0, t.readFloat16(),t.readFloat16()),float16x4:t=>_chunk44LAYHPRcjs.gb.call(void 0, t.readFloat16(),t.readFloat16(),t.readFloat16(),t.readFloat16()),float32:t=>t.readFloat32(),float32x2:t=>_chunk44LAYHPRcjs.Ya.call(void 0, t.readFloat32(),t.readFloat32()),float32x3:t=>_chunk44LAYHPRcjs.bb.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32()),float32x4:t=>_chunk44LAYHPRcjs.gb.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32()),uint32:t=>t.readUint32(),uint32x2:t=>_chunk44LAYHPRcjs.$a.call(void 0, t.readUint32(),t.readUint32()),uint32x3:t=>_chunk44LAYHPRcjs.eb.call(void 0, t.readUint32(),t.readUint32(),t.readUint32()),uint32x4:t=>_chunk44LAYHPRcjs.jb.call(void 0, t.readUint32(),t.readUint32(),t.readUint32(),t.readUint32()),sint32:t=>t.readInt32(),sint32x2:t=>_chunk44LAYHPRcjs._a.call(void 0, t.readInt32(),t.readInt32()),sint32x3:t=>_chunk44LAYHPRcjs.db.call(void 0, t.readInt32(),t.readInt32(),t.readInt32()),sint32x4:t=>_chunk44LAYHPRcjs.ib.call(void 0, t.readInt32(),t.readInt32(),t.readInt32(),t.readInt32()),"unorm10-10-10-2"(t){let e=t.readUint32(),r=(e>>22)/1023,n=(e>>12&1023)/1023,a=(e>>2&1023)/1023,o=(e&3)/3;return _chunk44LAYHPRcjs.gb.call(void 0, r,n,a,o)},"unorm8x4-bgra"(t){let e=t.readByte()/255,r=t.readByte()/255,n=t.readByte()/255,a=t.readByte()/255;return _chunk44LAYHPRcjs.gb.call(void 0, n,r,e,a)},unstruct(t,e){let r={},n=e.propTypes;for(let[a,o]of Object.entries(n))r[a]=O(t,o);return r},disarray(t,e){let r=_chunk44LAYHPRcjs.ec.call(void 0, e),n=[];for(let a=0;a<e.elementCount;a++)$(t,r),n.push(O(t,e.elementType));return $(t,r),n},"loose-decorated"(t,e){$(t,_chunk44LAYHPRcjs.fc.call(void 0, e));let r=t.currentByteOffset,n=O(t,e.inner);return t.seekTo(r+_chunk44LAYHPRcjs.ic.call(void 0, e)),n}};function O(t,e){let r=uo[e.type];if(!r)throw new Error(`Cannot read data of type '${e.type}'.`);return r(t,e)}function ua(t,e){let r=_chunk44LAYHPRcjs.ic.call(void 0, t);if(r===0||e===void 0||e===null)return[];let n=new ArrayBuffer(r),a=new (0, _typedbinary.BufferWriter)(n),o=[];function s(l,f,c,y){if(f!=null){if(_chunk44LAYHPRcjs.D.call(void 0, l)||_chunk44LAYHPRcjs.S.call(void 0, l)){let h=Mt(l);for(let[v,x]of Object.entries(h)){let P=l.propTypes[v];if(!P)continue;let F=f[v];F!==void 0&&s(P,F,c+x.offset,_nullishCoalesce(x.padding, () => (y)))}return}if(_chunk44LAYHPRcjs.C.call(void 0, l)||_chunk44LAYHPRcjs.R.call(void 0, l)){let h=l,v=_chunk44LAYHPRcjs.hc.call(void 0, _chunk44LAYHPRcjs.ic.call(void 0, h.elementType),_chunk44LAYHPRcjs.ec.call(void 0, h.elementType));if(!Array.isArray(f))throw new Error("Partial value for array must be an array");let x=_nullishCoalesce(f, () => ([]));x.sort((P,F)=>P.idx-F.idx);for(let{idx:P,value:F}of x)s(h.elementType,F,c+P*v,v-_chunk44LAYHPRcjs.ic.call(void 0, h.elementType))}else{let h=_chunk44LAYHPRcjs.ic.call(void 0, l);a.seekTo(c),Le(a,l,f),o.push({start:c,end:c+h,padding:y})}}}if(s(t,e,0),o.length===0)return[];let i=[],u=o[0];for(let l=1;l<o.length;l++){let f=o[l];if(!f||!u)throw new Error("Internal error: missing segment");f.start===u.end+(_nullishCoalesce(u.padding, () => (0)))?(u.end=f.end,u.padding=f.padding):(i.push({data:new Uint8Array(n,u.start,u.end-u.start)}),u=f)}if(!u)throw new Error("Internal error: missing segment");return i.push({data:new Uint8Array(n,u.start,u.end-u.start)}),i}function ye(t){return!!_optionalChain([t, 'optionalAccess', _21 => _21.usableAsStorage])}var Ye=class t extends Error{constructor(e){super(`Resource '${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, e), () => ("<unnamed>"))}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,t.prototype)}};function jt(t){return!!t.usableAsUniform}var fa={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},Je= (_class7 =class{constructor(e,r){;_class7.prototype.__init8.call(this);this.usage=e;this.buffer=r;this[_chunk44LAYHPRcjs.a]={dataType:r.dataType},this[_chunk44LAYHPRcjs.c]=r}__init8() {this.resourceType="buffer-usage"}$name(e){return this.buffer.$name(e),this}[_chunk44LAYHPRcjs.f](e){let r=this.buffer.dataType,n=e.getUniqueName(this),{group:a,binding:o}=e.allocateFixedEntry(this.usage==="uniform"?{uniform:r}:{storage:r,access:this.usage},this.buffer),s=fa[this.usage];return e.addDeclaration(`@group(${a}) @binding(${o}) var<${s}> ${n}: ${e.resolve(r).value};`),_chunk44LAYHPRcjs.aa.call(void 0, n,r)}toString(){return`${this.usage}:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunk44LAYHPRcjs.b](){let e=this.buffer.dataType;return new Proxy({[_chunk44LAYHPRcjs.a]:!0,get[_chunk44LAYHPRcjs.e](){return _chunk44LAYHPRcjs.aa.call(void 0, this,e)},[_chunk44LAYHPRcjs.f]:r=>r.resolve(this),toString:()=>`${this.usage}:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},R)}get $(){let e=_chunk44LAYHPRcjs.Ca.call(void 0, ),r=_chunk44LAYHPRcjs.ya.call(void 0, );if(e.type==="normal")throw new (0, _chunk44LAYHPRcjs.ka)(r?`Cannot access ${String(this.buffer)}. TypeGPU functions that depends on GPU resources need to be part of a compute dispatch, draw call or simulation`:".$ and .value are inaccessible during normal JS execution. Try `.read()`");return e.type==="codegen"?this[_chunk44LAYHPRcjs.b]:e.type==="simulate"?(e.buffers.has(this.buffer)||e.buffers.set(this.buffer,_chunk44LAYHPRcjs.rc.call(void 0, this.buffer.dataType,this.buffer.initial)),e.buffers.get(this.buffer)):_chunk44LAYHPRcjs.Ga.call(void 0, e,"bufferUsage.ts#TgpuFixedBufferImpl/$")}get value(){return this.$}set $(e){let r=_chunk44LAYHPRcjs.Ca.call(void 0, ),n=_chunk44LAYHPRcjs.ya.call(void 0, );if(r.type==="normal")throw new (0, _chunk44LAYHPRcjs.ka)(n?`Cannot access ${String(this.buffer)}. TypeGPU functions that depends on GPU resources need to be part of a compute dispatch, draw call or simulation`:".$ and .value are inaccessible during normal JS execution. Try `.write()`");if(r.type==="codegen")throw new Error("Unreachable bufferUsage.ts#TgpuFixedBufferImpl/$");if(r.type==="simulate"){r.buffers.set(this.buffer,e);return}_chunk44LAYHPRcjs.Ga.call(void 0, r,"bufferUsage.ts#TgpuFixedBufferImpl/$")}set value(e){this.$=e}}, _class7),Xe= (_class8 =class{constructor(e,r,n){;_class8.prototype.__init9.call(this);this.usage=e;this.dataType=r;this[_chunk44LAYHPRcjs.a]={dataType:r},this.#e=n,_chunk44LAYHPRcjs.k.call(void 0, this,n.key)}__init9() {this.resourceType="buffer-usage"}#e;[_chunk44LAYHPRcjs.f](e){let r=this.dataType,n=e.getUniqueName(this),a=e.allocateLayoutEntry(this.#e.layout),o=fa[this.usage];return e.addDeclaration(`@group(${a}) @binding(${this.#e.idx}) var<${o}> ${n}: ${e.resolve(r).value};`),_chunk44LAYHPRcjs.aa.call(void 0, n,r)}toString(){return`${this.usage}:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunk44LAYHPRcjs.b](){let e=this.dataType;return new Proxy({[_chunk44LAYHPRcjs.a]:!0,get[_chunk44LAYHPRcjs.e](){return _chunk44LAYHPRcjs.aa.call(void 0, this,e)},[_chunk44LAYHPRcjs.f]:r=>r.resolve(this),toString:()=>`${this.usage}:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},R)}get $(){if(_chunk44LAYHPRcjs.Da.call(void 0, ))return this[_chunk44LAYHPRcjs.b];throw new Error("Direct access to buffer values is possible only as part of a compute dispatch or draw call. Try .read() or .write() instead")}get value(){return this.$}}, _class8),pa=new WeakMap;function da(t){if(!ye(t))throw new Error(`Cannot pass ${t} to asMutable, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let e=pa.get(t);return e||(e=new Je("mutable",t),pa.set(t,e)),e}var la=new WeakMap;function ca(t){if(!ye(t))throw new Error(`Cannot pass ${t} to asReadonly, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let e=la.get(t);return e||(e=new Je("readonly",t),la.set(t,e)),e}var ma=new WeakMap;function ga(t){if(!jt(t))throw new Error(`Cannot pass ${t} to asUniform, as it is not allowed to be used as a uniform. To allow it, call .$usage('uniform') when creating the buffer.`);let e=ma.get(t);return e||(e=new Je("uniform",t),ma.set(t,e)),e}var fo={uniform:ga,mutable:da,readonly:ca};function Ze(t,e,r){return _chunk44LAYHPRcjs.B.call(void 0, e)?new Qt(t,e,r):new Qt(t,e,r,["storage","uniform"])}function pe(t){return t.resourceType==="buffer"}function co(t){return!!t.usableAsVertex}var go=_typedbinary.getSystemEndianness.call(void 0, ),Qt= (_class9 =class{constructor(e,r,n,a){;_class9.prototype.__init10.call(this);_class9.prototype.__init11.call(this);_class9.prototype.__init12.call(this);_class9.prototype.__init13.call(this);_class9.prototype.__init14.call(this);_class9.prototype.__init15.call(this);_class9.prototype.__init16.call(this);_class9.prototype.__init17.call(this);_class9.prototype.__init18.call(this);this._group=e;this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;_chunk44LAYHPRcjs.wa.call(void 0, n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}__init10() {this[_chunk44LAYHPRcjs.a]=!0}__init11() {this.resourceType="buffer"}__init12() {this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}__init13() {this._buffer=null}__init14() {this._destroyed=!1}__init15() {this.usableAsUniform=!1}__init16() {this.usableAsStorage=!1}__init17() {this.usableAsVertex=!1}__init18() {this.usableAsIndex=!1}get buffer(){let e=this._group.device;if(this._destroyed)throw new Error("This buffer has been destroyed");return this._buffer||(this._buffer=e.createBuffer({size:_chunk44LAYHPRcjs.ic.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}),this.initial&&(this._writeToTarget(this._buffer.getMappedRange(),this.initial),this._buffer.unmap())),this._buffer}get destroyed(){return this._destroyed}$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this,e),this._buffer&&(this._buffer.label=e),this}$usage(...e){for(let r of e){if(_optionalChain([this, 'access', _22 => _22._disallowedUsages, 'optionalAccess', _23 => _23.includes, 'call', _24 => _24(r)]))throw new Error(`Buffer of type ${this.dataType.type} cannot be used as ${r}`);this.flags|=r==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=r==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=r==="vertex"?GPUBufferUsage.VERTEX:0,this.flags|=r==="index"?GPUBufferUsage.INDEX:0,this.usableAsUniform=this.usableAsUniform||r==="uniform",this.usableAsStorage=this.usableAsStorage||r==="storage",this.usableAsVertex=this.usableAsVertex||r==="vertex",this.usableAsIndex=this.usableAsIndex||r==="index"}return this}$addFlags(e){if(!this._ownBuffer)throw new Error("Cannot add flags to a buffer that is not managed by TypeGPU.");return e&GPUBufferUsage.MAP_READ?(this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this):e&GPUBufferUsage.MAP_WRITE?(this.flags=GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,this):(this.flags|=e,this)}compileWriter(){Ar(this.dataType)}_writeToTarget(e,r){let n=Ar(this.dataType);if(n)try{n(new DataView(e),0,r,go==="little");return}catch(a){console.error(`Error when using compiled writer for buffer ${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))} - this is likely a bug, please submit an issue at https://github.com/software-mansion/TypeGPU/issues
|
|
16
|
-
Using fallback writer instead.`,a)}
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24; var _class25; var _class26; var _class27; var _class28; var _class29; var _class30;var _chunk5Y6GTBWRcjs = require('./chunk-5Y6GTBWR.cjs');var _chunk3246CM7Ccjs = require('./chunk-3246CM7C.cjs');var _chunkZYGTVBDHcjs = require('./chunk-ZYGTVBDH.cjs');var _chunkTRE7NUKEcjs = require('./chunk-TRE7NUKE.cjs');function Hn(e){return new vr(e)}var vr= (_class =class{constructor(t){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);this.declaration=t}__init() {this[_chunkTRE7NUKEcjs.a]=!0}__init2() {this.externalsToApply=[]}$uses(t){return this.externalsToApply.push(t),this}[_chunkTRE7NUKEcjs.f](t){let r={};for(let a of this.externalsToApply)_chunk5Y6GTBWRcjs.a.call(void 0, r,a);let n=_chunk5Y6GTBWRcjs.d.call(void 0, t,r,this.declaration);return t.addDeclaration(n),_chunkTRE7NUKEcjs.aa.call(void 0, "",_chunkTRE7NUKEcjs.q)}toString(){return`declare: ${this.declaration}`}}, _class);function Et(e){let t={argTypes:e.in&&Object.keys(e.in).length!==0?[_chunk5Y6GTBWRcjs.f.call(void 0, e.in)]:[],returnType:_chunkTRE7NUKEcjs.q,workgroupSize:[_nullishCoalesce(e.workgroupSize[0], () => (1)),_nullishCoalesce(e.workgroupSize[1], () => (1)),_nullishCoalesce(e.workgroupSize[2], () => (1))],isEntry:!0},r=(n,...a)=>qa(t,e.workgroupSize,_chunk5Y6GTBWRcjs.g.call(void 0, n,...a));return Object.assign(Object.assign(r,t),{does:r})}function qa(e,t,r){let n=_chunk5Y6GTBWRcjs.e.call(void 0, r,`@compute @workgroup_size(${t.join(", ")}) `),a=e.argTypes[0];return{shell:e,$uses(s){return n.applyExternals(s),this},[_chunkTRE7NUKEcjs.a]:!0,[_chunkTRE7NUKEcjs.c]:n,$name(s){return _chunkTRE7NUKEcjs.k.call(void 0, n,s),_chunkTRE7NUKEcjs.l.call(void 0, a)&&a.$name(`${s}_Input`),this},[_chunkTRE7NUKEcjs.f](s){return n.resolve(s,e.argTypes,e.returnType)},toString(){return`computeFn:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, n), () => ("<unnamed>"))}`}}}function U(e,t){let r={[_chunkTRE7NUKEcjs.a]:!0,argTypes:e,returnType:_nullishCoalesce(t, () => (_chunkTRE7NUKEcjs.q)),isEntry:!1};return Object.assign((a,...o)=>Qa(r,_chunk5Y6GTBWRcjs.g.call(void 0, a,...o)),r)}function Ke(e){return _chunkTRE7NUKEcjs.h.call(void 0, e)&&_optionalChain([e, 'optionalAccess', _2 => _2.resourceType])==="function"}function ja([e,t]){return`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, e), () => ("<unnamed>"))}=${t}`}function Qa(e,t){let r=_chunk5Y6GTBWRcjs.e.call(void 0, t,""),n={shell:e,resourceType:"function",$uses(s){return r.applyExternals(s),this},[_chunkTRE7NUKEcjs.c]:r,$name(s){return _chunkTRE7NUKEcjs.k.call(void 0, r,s),this},with(s,i){return Kn(o,[[_chunkTRE7NUKEcjs.pa.call(void 0, s)?s.slot:s,i]])},[_chunkTRE7NUKEcjs.f](s){return typeof t=="string"&&(_chunk5Y6GTBWRcjs.b.call(void 0, t,e.argTypes,r.applyExternals),_chunk5Y6GTBWRcjs.c.call(void 0, t,e.returnType,r.applyExternals)),r.resolve(s,e.argTypes,e.returnType)}},a=_chunkTRE7NUKEcjs.La.call(void 0, (...s)=>_chunkTRE7NUKEcjs.xa.call(void 0, ()=>{try{if(typeof t=="string")throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");let i=s.map((l,m)=>_chunkTRE7NUKEcjs.qc.call(void 0, e.argTypes[m],l)),u=t(...i);return _chunkTRE7NUKEcjs.qc.call(void 0, e.returnType,u)}catch(i){throw i instanceof _chunkTRE7NUKEcjs.da?i.appendToTrace(o):new (0, _chunkTRE7NUKEcjs.da)(i,[o])}}),(...s)=>_chunkTRE7NUKEcjs.aa.call(void 0, new Vt(o,s),e.returnType),"tgpuFnCall",e.argTypes),o=Object.assign(a,n);return o[_chunkTRE7NUKEcjs.a].implementation=t,Object.defineProperty(o,"toString",{value(){return`fn:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, r), () => ("<unnamed>"))}`}}),o}function Kn(e,t){let r={resourceType:"function",shell:e.shell,[_chunkTRE7NUKEcjs.d]:{inner:e,pairs:t},$uses(o){return e.$uses(o),this},[_chunkTRE7NUKEcjs.c]:e,$name(o){return e.$name(o),this},with(o,s){return Kn(a,[...t,[_chunkTRE7NUKEcjs.pa.call(void 0, o)?o.slot:o,s]])}},n=_chunkTRE7NUKEcjs.La.call(void 0, (...o)=>e(...o),(...o)=>_chunkTRE7NUKEcjs.aa.call(void 0, new Vt(a,o),e.shell.returnType),"tgpuFnCall",e.shell.argTypes),a=Object.assign(n,r);return a[_chunkTRE7NUKEcjs.a].implementation=e[_chunkTRE7NUKEcjs.a].implementation,Object.defineProperty(a,"toString",{value(){return`fn:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, e), () => ("<unnamed>"))}[${t.map(ja).join(", ")}]`}}),a[_chunkTRE7NUKEcjs.a].implementation=e[_chunkTRE7NUKEcjs.a].implementation,a}var Vt= (_class2 =class{__init3() {this[_chunkTRE7NUKEcjs.a]=!0}#e;#r;constructor(t,r){;_class2.prototype.__init3.call(this);this.#e=t,this.#r=r,this[_chunkTRE7NUKEcjs.c]=t,this[_chunkTRE7NUKEcjs.e]=_chunkTRE7NUKEcjs.aa.call(void 0, this,this.#e.shell.returnType)}[_chunkTRE7NUKEcjs.f](t){return t.withResetIndentLevel(()=>_chunkTRE7NUKEcjs.aa.call(void 0, _chunkTRE7NUKEcjs.Ea`${t.resolve(this.#e).value}(${this.#r})`,this.#e.shell.returnType))}toString(){return`call:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}}, _class2);function Yn(e){let t={in:e.in,out:e.out,returnType:_chunk5Y6GTBWRcjs.f.call(void 0, e.out),isEntry:!0},r=(n,...a)=>Ha(t,_chunk5Y6GTBWRcjs.g.call(void 0, n,...a));return Object.assign(Object.assign(r,t),{does:r})}function Ha(e,t){let r=_chunk5Y6GTBWRcjs.e.call(void 0, t,"@fragment "),n=e.returnType;return typeof t=="string"&&_chunk5Y6GTBWRcjs.c.call(void 0, t,n,o=>r.applyExternals(o)),{shell:e,outputType:n,$uses(o){return r.applyExternals(o),this},[_chunkTRE7NUKEcjs.a]:!0,[_chunkTRE7NUKEcjs.c]:r,$name(o){return _chunkTRE7NUKEcjs.k.call(void 0, r,o),_chunkTRE7NUKEcjs.l.call(void 0, n)&&n.$name(`${o}_Output`),this},[_chunkTRE7NUKEcjs.f](o){let s=e.in?_chunk5Y6GTBWRcjs.f.call(void 0, e.in,o.varyingLocations).$name(`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => (""))}_Input`):void 0;return s&&r.applyExternals({In:s}),r.applyExternals({Out:n}),r.resolve(o,s?[s]:[],e.returnType)},toString(){return`fragmentFn:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, r), () => ("<unnamed>"))}`}}}var Jn=new Set(["alias","break","case","const","const_assert","continue","continuing","default","diagnostic","discard","else","enable","false","fn","for","if","let","loop","override","requires","return","struct","switch","true","var","while","NULL","Self","abstract","active","alignas","alignof","as","asm","asm_fragment","async","attribute","auto","await","become","cast","catch","class","co_await","co_return","co_yield","coherent","column_major","common","compile","compile_fragment","concept","const_cast","consteval","constexpr","constinit","crate","debugger","decltype","delete","demote","demote_to_helper","do","dynamic_cast","enum","explicit","export","extends","extern","external","fallthrough","filter","final","finally","friend","from","fxgroup","get","goto","groupshared","highp","impl","implements","import","inline","instanceof","interface","layout","lowp","macro","macro_rules","match","mediump","meta","mod","module","move","mut","mutable","namespace","new","nil","noexcept","noinline","nointerpolation","non_coherent","noncoherent","noperspective","null","nullptr","of","operator","package","packoffset","partition","pass","patch","pixelfragment","precise","precision","premerge","priv","protected","pub","public","readonly","ref","regardless","register","reinterpret_cast","require","resource","restrict","self","set","shared","sizeof","smooth","snorm","static","static_assert","static_cast","std","subroutine","super","target","template","this","thread_local","throw","trait","try","type","typedef","typeid","typename","typeof","union","unless","unorm","unsafe","unsized","use","using","varying","virtual","volatile","wgsl","where","with","writeonly","yield"]);function Ir(e){if(e==="_"||e.startsWith("__")||/\s/.test(e))throw new Error(`Invalid identifier '${e}'. Choose an identifier without whitespaces or leading underscores.`);let t=e.split("_")[0];return!Jn.has(t)}var _t=class{makeValid(t){return Ir(t)?t:this.makeUnique(t)}},Wt= (_class3 =class extends _t{constructor(...args2) { super(...args2); _class3.prototype.__init4.call(this); }__init4() {this.lastUniqueId=0}makeUnique(t){let r;return t?(r=t.replaceAll(/\s/g,"_"),r=r.replaceAll(/[^\w\d]/g,"")):r="item",`${r}_${this.lastUniqueId++}`}}, _class3),kt= (_class4 =class extends _t{constructor(...args3) { super(...args3); _class4.prototype.__init5.call(this); }__init5() {this._usedNames=new Set(Jn)}makeUnique(t){if(t===void 0)throw new Error("Unnamed item found when using a strict name registry");let r=0,n=t;for(;this._usedNames.has(n);)r++,n=`${t}_${r}`;return this._usedNames.add(n),n}}, _class4);function Xn(e,t){let r=_chunk5Y6GTBWRcjs.e.call(void 0, t,"");return{[_chunkTRE7NUKEcjs.a]:!0,[_chunkTRE7NUKEcjs.c]:r,resourceType:"shellless-impl",[_chunkTRE7NUKEcjs.f](n){return r.resolve(n,e,void 0)},toString(){return`fn*:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, r), () => ("<unnamed>"))}`}}}var Mt= (_class5 =class{constructor() { _class5.prototype.__init6.call(this); }__init6() {this.cache=new Map}get(t,r){let n=_chunkTRE7NUKEcjs.n.call(void 0, t);if(!_optionalChain([n, 'optionalAccess', _3 => _3.ast]))return;if(!r&&n.ast.params.length>0)throw new Error(`Cannot resolve '${_chunkTRE7NUKEcjs.j.call(void 0, t)}' directly, because it expects arguments. Either call it from another function, or wrap it in a shell`);let a=(_nullishCoalesce(r, () => ([]))).map(i=>_chunkZYGTVBDHcjs.o.call(void 0, i.dataType)),o=this.cache.get(t);if(o){let i=o.find(u=>u.argTypes.every((l,m)=>l===a[m]));if(i)return i.value}else o=[],this.cache.set(t,o);let s=Xn(a,t);return o.push({argTypes:a,value:s}),s}}, _class5);var Ur=class{constructor(t){this[_chunkTRE7NUKEcjs.a]={nameRegistry:t,shelllessRepo:new Mt,memoizedResolves:new WeakMap,memoizedDerived:new WeakMap,listeners:{name:new Set}}}on(t,r){if(t==="name"){let n=this[_chunkTRE7NUKEcjs.a].listeners.name;return n.add(r),()=>n.delete(r)}throw new Error(`Unsupported event: ${t}`)}};function Zn(e,t){let r=e.nameRegistry.makeUnique(_chunkTRE7NUKEcjs.j.call(void 0, t));for(let n of e.listeners.name)n({target:t,name:r});return r}function Q(e){let{names:t="random"}=e||{};return new Ur(t==="strict"?new kt:new Wt)}function Ye(e){return typeof _optionalChain([e, 'optionalAccess', _4 => _4.format])=="string"}function ea(e,t){let r=[];if(_chunkTRE7NUKEcjs.V.call(void 0, e)){if(!Ye(t))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(t._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:t._layout.stride,stepMode:t._layout.stepMode,attributes:[{format:t.format,offset:t.offset,shaderLocation:_nullishCoalesce(_chunkTRE7NUKEcjs.U.call(void 0, e), () => (0))}]}]}}let n=[],a=new WeakMap,o=0;for(let[s,i]of Object.entries(e)){if(_chunkTRE7NUKEcjs.oc.call(void 0, i))continue;let u=t[s];if(!u)throw new Error(`An attribute by the name of '${s}' was not provided to the shader.`);let l=u._layout,m=a.get(l);m||(r.push(l),m=[],n.push({arrayStride:l.stride,stepMode:l.stepMode,attributes:m}),a.set(l,m)),o=_nullishCoalesce(_chunkTRE7NUKEcjs.U.call(void 0, i), () => (o)),m.push({format:u.format,offset:u.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var Ka=["bool","f32","f16","i32","u32","vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","vec2<bool>","vec3<bool>","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","texture_external"];function Ya(e){return Ka.includes(e.type)}function Fr(e,[t,r]){if(!Ir(t))throw new Error(`Property key '${t}' is a reserved WGSL word. Choose a different name.`);return` ${_chunkTRE7NUKEcjs.pc.call(void 0, r)}${t}: ${e.resolve(r).value},
|
|
2
|
+
`}function Ja(e,t){if(t[_chunkTRE7NUKEcjs.a].isAbstruct)throw new Error("Cannot resolve abstract struct types to WGSL.");let r=e.getUniqueName(t);return e.addDeclaration(`struct ${r} {
|
|
3
|
+
${Object.entries(t.propTypes).map(n=>Fr(e,n)).join("")}}`),r}function Xa(e,t){let r=e.getUniqueName(t);return e.addDeclaration(`struct ${r} {
|
|
4
|
+
${Object.entries(t.propTypes).map(n=>Ye(n[1])?Fr(e,[n[0],_chunkTRE7NUKEcjs.nb[n[1].format]]):Fr(e,n)).join("")}
|
|
5
|
+
}`),r}function Za(e,t){let r=e.resolve(t.elementType).value;return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function eo(e,t){let r=e.resolve(Ye(t.elementType)?_chunkTRE7NUKEcjs.nb[t.elementType.format]:t.elementType).value;return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function Pr(e,t){if(_chunkTRE7NUKEcjs.Q.call(void 0, t))return t.type==="unstruct"?Xa(e,t):t.type==="disarray"?eo(e,t):t.type==="loose-decorated"?e.resolve(Ye(t.inner)?_chunkTRE7NUKEcjs.nb[t.inner.format]:t.inner).value:e.resolve(_chunkTRE7NUKEcjs.nb[t.type]).value;if(Ya(t))return t.type;if(t.type==="struct")return Ja(e,t);if(t.type==="array")return Za(e,t);if(t.type==="atomic")return`atomic<${Pr(e,t.inner)}>`;if(t.type==="decorated")return e.resolve(t.inner).value;if(t.type==="ptr")return t.addressSpace==="storage"?`ptr<storage, ${e.resolve(t.inner).value}, ${t.access==="read-write"?"read_write":t.access}>`:`ptr<${t.addressSpace}, ${e.resolve(t.inner).value}>`;if(t.type==="abstractInt"||t.type==="abstractFloat"||t.type==="void"||t.type==="u16")throw new Error(`${t.type} has no representation in WGSL`);if(_chunkZYGTVBDHcjs.S.call(void 0, t))return`${t.type}<${t.format}, ${_chunkZYGTVBDHcjs.z[t.access]}>`;if(_chunkZYGTVBDHcjs.R.call(void 0, t))return t.type.startsWith("texture_depth")?t.type:`${t.type}<${t.sampleType.type}>`;if(_chunkZYGTVBDHcjs.x.call(void 0, t)||_chunkZYGTVBDHcjs.w.call(void 0, t))return t.type;_chunkTRE7NUKEcjs.Fa.call(void 0, t,"resolveData")}var Ge=class e{constructor(t){this.bindings=t}with(t,r){return new e([...this.bindings,[_chunkTRE7NUKEcjs.pa.call(void 0, t)?t.slot:t,r]])}pipe(t){let r=t(this);return new e([...this.bindings,...r.bindings])}};function*ta(e){let t=0;for(;;)e.has(t)||(yield t),t++}var _typedbinary = require('typed-binary');function to(e,t){let r="size"in e?e.size:e.currentByteOffset,n=t-1,a=r&n;"skipBytes"in e?e.skipBytes(t-a&n):e.add(t-a&n)}var B=to;var ra=new WeakMap;function Ot(e){let t=ra.get(e);if(t)return t;let r=new _typedbinary.Measurer,n={},a;for(let o in e.propTypes){let s=e.propTypes[o];if(s===void 0)throw new Error(`Property ${o} is undefined in struct`);let i=r.size;B(r,_chunkTRE7NUKEcjs.S.call(void 0, e)?_chunkTRE7NUKEcjs.ec.call(void 0, s):_chunkTRE7NUKEcjs.dc.call(void 0, s)),a&&(a.padding=r.size-i);let u=_chunkTRE7NUKEcjs.hc.call(void 0, s);n[o]={offset:r.size,size:u},a=n[o],r.add(u)}return a&&(a.padding=_chunkTRE7NUKEcjs.gc.call(void 0, _chunkTRE7NUKEcjs.hc.call(void 0, e),_chunkTRE7NUKEcjs.dc.call(void 0, e))-r.size),ra.set(e,n),n}var no=(()=>{try{return new Function("return true"),!0}catch (e2){return!1}})(),Dr=new WeakMap,zt={u32:"u32",vec2u:"u32",vec3u:"u32",vec4u:"u32",u16:"u16",i32:"i32",vec2i:"i32",vec3i:"i32",vec4i:"i32",f32:"f32",vec2f:"f32",vec3f:"f32",vec4f:"f32",f16:"f16",vec2h:"f16",vec3h:"f16",vec4h:"f16",mat2x2f:"f32",mat3x3f:"f32",mat4x4f:"f32"},ao={uint8:"u8",uint8x2:"u8",uint8x4:"u8",sint8:"i8",sint8x2:"i8",sint8x4:"i8",unorm8:"u8",unorm8x2:"u8",unorm8x4:"u8",snorm8:"i8",snorm8x2:"i8",snorm8x4:"i8",uint16:"u16",uint16x2:"u16",uint16x4:"u16",sint16:"i16",sint16x2:"i16",sint16x4:"i16",unorm16:"u16",unorm16x2:"u16",unorm16x4:"u16",snorm16:"i16",snorm16x2:"i16",snorm16x4:"i16",float16:"f16",float16x2:"f16",float16x4:"f16",float32:"f32",float32x2:"f32",float32x3:"f32",float32x4:"f32",uint32:"u32",uint32x2:"u32",uint32x3:"u32",uint32x4:"u32",sint32:"i32",sint32x2:"i32",sint32x3:"i32",sint32x4:"i32"},Nt={u32:"setUint32",i32:"setInt32",f32:"setFloat32",u16:"setUint16",i16:"setInt16",f16:"setFloat16",u8:"setUint8",i8:"setInt8"},oo={unorm8:e=>`Math.round(${e} * 255)`,unorm8x2:e=>`Math.round(${e} * 255)`,unorm8x4:e=>`Math.round(${e} * 255)`,snorm8:e=>`Math.round(${e} * 127)`,snorm8x2:e=>`Math.round(${e} * 127)`,snorm8x4:e=>`Math.round(${e} * 127)`,unorm16:e=>`Math.round(${e} * 65535)`,unorm16x2:e=>`Math.round(${e} * 65535)`,unorm16x4:e=>`Math.round(${e} * 65535)`,snorm16:e=>`Math.round(${e} * 32767)`,snorm16x2:e=>`Math.round(${e} * 32767)`,snorm16x4:e=>`Math.round(${e} * 32767)`},na={"unorm10-10-10-2":{writeFunction:"setUint32",generator:(e,t)=>`output.setUint32(${e}, ((${t}.x*1023&0x3FF)<<22)|((${t}.y*1023&0x3FF)<<12)|((${t}.z*1023&0x3FF)<<2)|(${t}.w*3&3), littleEndian);
|
|
6
|
+
`},"unorm8x4-bgra":{writeFunction:"setUint8",generator:(e,t)=>{let r=["z","y","x","w"],n="";for(let a=0;a<4;a++)n+=`output.setUint8((${e} + ${a}), Math.round(${t}.${r[a]} * 255), littleEndian);
|
|
7
|
+
`;return n}}};function qt(e,t,r,n=0){let a=["i","j","k"][n]||`i${n}`;if(_chunkTRE7NUKEcjs.F.call(void 0, e)||_chunkTRE7NUKEcjs.L.call(void 0, e))return qt(e.inner,t,r,n);if(_chunkTRE7NUKEcjs.D.call(void 0, e)||_chunkTRE7NUKEcjs.S.call(void 0, e)){let s=Ot(e),i="";for(let[u,l]of Object.entries(s)){let m=e.propTypes[u];m&&(i+=qt(m,`(${t} + ${l.offset})`,`${r}.${u}`,n))}return i}if(_chunkTRE7NUKEcjs.C.call(void 0, e)||_chunkTRE7NUKEcjs.R.call(void 0, e)){let s=_chunkTRE7NUKEcjs.gc.call(void 0, _chunkTRE7NUKEcjs.hc.call(void 0, e.elementType),_chunkTRE7NUKEcjs.dc.call(void 0, e)),i="";return i+=`for (let ${a} = 0; ${a} < ${e.elementCount}; ${a}++) {
|
|
8
|
+
`,i+=qt(e.elementType,`(${t} + ${a} * ${s})`,`${r}[${a}]`,n+1),i+=`}
|
|
9
|
+
`,i}if(_chunkTRE7NUKEcjs.v.call(void 0, e)){let s=zt[e.type],i="",u=Nt[s],l=["x","y","z","w"],m=_chunkTRE7NUKEcjs.s.call(void 0, e)?2:_chunkTRE7NUKEcjs.t.call(void 0, e)?3:4;for(let y=0;y<m;y++)i+=`output.${u}((${t} + ${y*4}), ${r}.${l[y]}, littleEndian);
|
|
10
|
+
`;return i}if(_chunkTRE7NUKEcjs.z.call(void 0, e)){let s=zt[e.type],i=Nt[s],u=_chunkTRE7NUKEcjs.x.call(void 0, e)?2:_chunkTRE7NUKEcjs.y.call(void 0, e)?3:4,l=u*u,m=_chunkTRE7NUKEcjs.gc.call(void 0, u*4,8),y="";for(let f=0;f<l;f++){let T=Math.floor(f/u),w=f%u,x=T*m+w*4;y+=`output.${i}((${t} + ${x}), ${r}.columns[${T}].${["x","y","z","w"][w]}, littleEndian);
|
|
11
|
+
`}return y}if(_chunkTRE7NUKEcjs.cc.call(void 0, e)){let s=e.type;if(s in na)return na[s].generator(t,r);let i=ao[s],u=Nt[i],l=_chunkTRE7NUKEcjs.nb[s],m=_chunkTRE7NUKEcjs.u.call(void 0, l)?4:_chunkTRE7NUKEcjs.t.call(void 0, l)?3:_chunkTRE7NUKEcjs.s.call(void 0, l)?2:1,y=i==="u8"||i==="i8"?1:i==="u16"||i==="i16"||i==="f16"?2:4,f=["x","y","z","w"],T=oo[s],w="";for(let x=0;x<m;x++){let P=m===1?r:`${r}.${f[x]}`,F=T?T(P):P;w+=`output.${u}((${t} + ${x*y}), ${F}, littleEndian);
|
|
12
|
+
`}return w}if(!Object.hasOwn(zt,e.type))throw new Error(`Primitive ${e.type} is unsupported by compiled writer`);let o=zt[e.type];return`output.${Nt[o]}(${t}, ${r}, littleEndian);
|
|
13
|
+
`}function Br(e){if(!no){console.warn("This environment does not allow eval - using default writer as fallback");return}if(Dr.has(e))return Dr.get(e);try{let t=qt(e,"offset","value",0),r=new Function("output","offset","value","littleEndian=true",t);return Dr.set(e,r),r}catch(t){console.warn(`Failed to compile writer for schema: ${e}
|
|
14
|
+
Reason: ${t instanceof Error?t.message:String(t)}
|
|
15
|
+
Falling back to default writer`)}}var Ce={bool(){throw new Error("Booleans are not host-shareable")},f32(e,t,r){e.writeFloat32(r)},f16(e,t,r){e.writeFloat16(r)},i32(e,t,r){e.writeInt32(r)},u32(e,t,r){e.writeUint32(r)},u16(e,t,r){e.writeUint16(r)},vec2f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},vec2h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},vec2i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},vec2u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},vec3f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},vec3h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z)},vec3i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},vec3u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},vec4f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},vec4h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},vec4i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},vec4u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat3x3f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat4x4f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},struct(e,t,r){let n=_chunkTRE7NUKEcjs.dc.call(void 0, t);B(e,n);for(let[a,o]of Object.entries(t.propTypes))B(e,_chunkTRE7NUKEcjs.dc.call(void 0, o)),Ee(e,o,r[a]);B(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunkTRE7NUKEcjs.dc.call(void 0, t);B(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)B(e,n),Ee(e,t.elementType,r[o]);e.seekTo(a+_chunkTRE7NUKEcjs.hc.call(void 0, t))},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t,r){_optionalChain([Ce, 'access', _5 => _5[t.inner.type], 'optionalCall', _6 => _6(e,t,r)])},decorated(e,t,r){let n=_chunkTRE7NUKEcjs.ec.call(void 0, t);B(e,n);let a=e.currentByteOffset;_optionalChain([Ce, 'access', _7 => _7[_optionalChain([t, 'access', _8 => _8.inner, 'optionalAccess', _9 => _9.type])], 'optionalCall', _10 => _10(e,t.inner,r)]),e.seekTo(a+_chunkTRE7NUKEcjs.hc.call(void 0, t))},uint8(e,t,r){e.writeUint8(r)},uint8x2(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y)},uint8x4(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y),e.writeUint8(r.z),e.writeUint8(r.w)},sint8(e,t,r){e.writeInt8(r)},sint8x2(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y)},sint8x4(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y),e.writeInt8(r.z),e.writeInt8(r.w)},unorm8(e,t,r){e.writeUint8(Math.round(r*255))},unorm8x2(e,t,r){e.writeUint8(Math.round(r.x*255)),e.writeUint8(Math.round(r.y*255))},unorm8x4(e,t,r){e.writeUint8(Math.round(r.x*255)),e.writeUint8(Math.round(r.y*255)),e.writeUint8(Math.round(r.z*255)),e.writeUint8(Math.round(r.w*255))},snorm8(e,t,r){e.writeInt8(Math.round(r*127))},snorm8x2(e,t,r){e.writeInt8(Math.round(r.x*127)),e.writeInt8(Math.round(r.y*127))},snorm8x4(e,t,r){e.writeInt8(Math.round(r.x*127)),e.writeInt8(Math.round(r.y*127)),e.writeInt8(Math.round(r.z*127)),e.writeInt8(Math.round(r.w*127))},uint16(e,t,r){e.writeUint16(r)},uint16x2(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y)},uint16x4(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y),e.writeUint16(r.z),e.writeUint16(r.w)},sint16(e,t,r){e.writeInt16(r)},sint16x2(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y)},sint16x4(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y),e.writeInt16(r.z),e.writeInt16(r.w)},unorm16(e,t,r){e.writeUint16(r*65535)},unorm16x2(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535)},unorm16x4(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535),e.writeUint16(r.z*65535),e.writeUint16(r.w*65535)},snorm16(e,t,r){e.writeInt16(Math.round(r*32767))},snorm16x2(e,t,r){e.writeInt16(Math.round(r.x*32767)),e.writeInt16(Math.round(r.y*32767))},snorm16x4(e,t,r){e.writeInt16(Math.round(r.x*32767)),e.writeInt16(Math.round(r.y*32767)),e.writeInt16(Math.round(r.z*32767)),e.writeInt16(Math.round(r.w*32767))},float16(e,t,r){e.writeFloat16(r)},float16x2(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},float16x4(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},float32(e,t,r){e.writeFloat32(r)},float32x2(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},float32x3(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},float32x4(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},uint32(e,t,r){e.writeUint32(r)},uint32x2(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},uint32x3(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},uint32x4(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},sint32(e,t,r){e.writeInt32(r)},sint32x2(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},sint32x3(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},sint32x4(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},"unorm10-10-10-2"(e,t,r){let n=0;n|=(r.x*1023&1023)<<22,n|=(r.y*1023&1023)<<12,n|=(r.z*1023&1023)<<2,n|=r.w*3&3,e.writeUint32(n)},"unorm8x4-bgra"(e,t,r){e.writeUint8(r.z*255),e.writeUint8(r.y*255),e.writeUint8(r.x*255),e.writeUint8(r.w*255)},disarray(e,t,r){let n=_chunkTRE7NUKEcjs.dc.call(void 0, t);B(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)B(e,n),_optionalChain([Ce, 'access', _11 => _11[_optionalChain([t, 'access', _12 => _12.elementType, 'optionalAccess', _13 => _13.type])], 'optionalCall', _14 => _14(e,t.elementType,r[o])]);e.seekTo(a+_chunkTRE7NUKEcjs.hc.call(void 0, t))},unstruct(e,t,r){let n=t.propTypes;for(let[a,o]of Object.entries(n))_optionalChain([Ce, 'access', _15 => _15[o.type], 'optionalCall', _16 => _16(e,o,r[a])])},"loose-decorated"(e,t,r){let n=_chunkTRE7NUKEcjs.ec.call(void 0, t);B(e,n);let a=e.currentByteOffset,o=Ce[_optionalChain([t, 'access', _17 => _17.inner, 'optionalAccess', _18 => _18.type])];return _optionalChain([o, 'optionalCall', _19 => _19(e,t.inner,r)]),e.seekTo(a+_chunkTRE7NUKEcjs.hc.call(void 0, t)),r}};function Ee(e,t,r){let n=Ce[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var so={bool(){throw new Error("Booleans are not host-shareable")},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},u16(e){return e.readUint16()},vec2f(e){return _chunkTRE7NUKEcjs.Xa.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunkTRE7NUKEcjs.ab.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunkTRE7NUKEcjs.fb.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2h(e){return _chunkTRE7NUKEcjs.Ya.call(void 0, e.readFloat16(),e.readFloat16())},vec3h(e){return _chunkTRE7NUKEcjs.bb.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16())},vec4h(e){return _chunkTRE7NUKEcjs.gb.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16())},vec2i(e){return _chunkTRE7NUKEcjs.Za.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunkTRE7NUKEcjs.cb.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunkTRE7NUKEcjs.hb.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunkTRE7NUKEcjs._a.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunkTRE7NUKEcjs.db.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunkTRE7NUKEcjs.ib.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(e){return _chunkZYGTVBDHcjs.j.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunkZYGTVBDHcjs.k.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunkZYGTVBDHcjs.l.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},struct(e,t){let r=_chunkTRE7NUKEcjs.dc.call(void 0, t);B(e,r);let n={},a=t.propTypes;for(let[o,s]of Object.entries(a))B(e,_chunkTRE7NUKEcjs.dc.call(void 0, s)),n[o]=O(e,s);return B(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunkTRE7NUKEcjs.dc.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){B(e,r);let o=t.elementType,s=O(e,o);n.push(s)}return B(e,r),n},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t){return O(e,t.inner)},decorated(e,t){let r=_chunkTRE7NUKEcjs.ec.call(void 0, t);B(e,r);let n=e.currentByteOffset,a=O(e,t.inner);return e.seekTo(n+_chunkTRE7NUKEcjs.hc.call(void 0, t)),a},uint8:e=>e.readUint8(),uint8x2:e=>_chunkTRE7NUKEcjs._a.call(void 0, e.readUint8(),e.readUint8()),uint8x4:e=>_chunkTRE7NUKEcjs.ib.call(void 0, e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),sint8:e=>e.readInt8(),sint8x2:e=>_chunkTRE7NUKEcjs.Za.call(void 0, e.readInt8(),e.readInt8()),sint8x4:e=>_chunkTRE7NUKEcjs.hb.call(void 0, e.readInt8(),e.readInt8(),e.readInt8(),e.readInt8()),unorm8:e=>e.readUint8()/255,unorm8x2:e=>_chunkTRE7NUKEcjs.Xa.call(void 0, e.readUint8()/255,e.readUint8()/255),unorm8x4:e=>_chunkTRE7NUKEcjs.fb.call(void 0, e.readUint8()/255,e.readUint8()/255,e.readUint8()/255,e.readUint8()/255),snorm8:e=>e.readInt8()/127,snorm8x2:e=>_chunkTRE7NUKEcjs.Xa.call(void 0, e.readInt8()/127,e.readInt8()/127),snorm8x4:e=>_chunkTRE7NUKEcjs.fb.call(void 0, e.readInt8()/127,e.readInt8()/127,e.readInt8()/127,e.readInt8()/127),uint16:e=>e.readUint16(),uint16x2:e=>_chunkTRE7NUKEcjs._a.call(void 0, e.readUint16(),e.readUint16()),uint16x4:e=>_chunkTRE7NUKEcjs.ib.call(void 0, e.readUint16(),e.readUint16(),e.readUint16(),e.readUint16()),sint16:e=>e.readInt16(),sint16x2:e=>_chunkTRE7NUKEcjs.Za.call(void 0, e.readInt16(),e.readInt16()),sint16x4:e=>_chunkTRE7NUKEcjs.hb.call(void 0, e.readInt16(),e.readInt16(),e.readInt16(),e.readInt16()),unorm16:e=>e.readUint16()/65535,unorm16x2:e=>_chunkTRE7NUKEcjs.Xa.call(void 0, e.readUint16()/65535,e.readUint16()/65535),unorm16x4:e=>_chunkTRE7NUKEcjs.fb.call(void 0, e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535),snorm16:e=>e.readInt16()/32767,snorm16x2:e=>_chunkTRE7NUKEcjs.Xa.call(void 0, e.readInt16()/32767,e.readInt16()/32767),snorm16x4:e=>_chunkTRE7NUKEcjs.fb.call(void 0, e.readInt16()/32767,e.readInt16()/32767,e.readInt16()/32767,e.readInt16()/32767),float16(e){return e.readFloat16()},float16x2:e=>_chunkTRE7NUKEcjs.Xa.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunkTRE7NUKEcjs.fb.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunkTRE7NUKEcjs.Xa.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunkTRE7NUKEcjs.ab.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunkTRE7NUKEcjs.fb.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunkTRE7NUKEcjs._a.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunkTRE7NUKEcjs.db.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunkTRE7NUKEcjs.ib.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunkTRE7NUKEcjs.Za.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunkTRE7NUKEcjs.cb.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunkTRE7NUKEcjs.hb.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32()),"unorm10-10-10-2"(e){let t=e.readUint32(),r=(t>>22)/1023,n=(t>>12&1023)/1023,a=(t>>2&1023)/1023,o=(t&3)/3;return _chunkTRE7NUKEcjs.fb.call(void 0, r,n,a,o)},"unorm8x4-bgra"(e){let t=e.readByte()/255,r=e.readByte()/255,n=e.readByte()/255,a=e.readByte()/255;return _chunkTRE7NUKEcjs.fb.call(void 0, n,r,t,a)},unstruct(e,t){let r={},n=t.propTypes;for(let[a,o]of Object.entries(n))r[a]=O(e,o);return r},disarray(e,t){let r=_chunkTRE7NUKEcjs.dc.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)B(e,r),n.push(O(e,t.elementType));return B(e,r),n},"loose-decorated"(e,t){B(e,_chunkTRE7NUKEcjs.ec.call(void 0, t));let r=e.currentByteOffset,n=O(e,t.inner);return e.seekTo(r+_chunkTRE7NUKEcjs.hc.call(void 0, t)),n}};function O(e,t){let r=so[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}function aa(e,t){let r=_chunkTRE7NUKEcjs.hc.call(void 0, e);if(r===0||t===void 0||t===null)return[];let n=new ArrayBuffer(r),a=new (0, _typedbinary.BufferWriter)(n),o=[];function s(l,m,y,f){if(m!=null){if(_chunkTRE7NUKEcjs.D.call(void 0, l)||_chunkTRE7NUKEcjs.S.call(void 0, l)){let T=Ot(l);for(let[w,x]of Object.entries(T)){let P=l.propTypes[w];if(!P)continue;let F=m[w];F!==void 0&&s(P,F,y+x.offset,_nullishCoalesce(x.padding, () => (f)))}return}if(_chunkTRE7NUKEcjs.C.call(void 0, l)||_chunkTRE7NUKEcjs.R.call(void 0, l)){let T=l,w=_chunkTRE7NUKEcjs.gc.call(void 0, _chunkTRE7NUKEcjs.hc.call(void 0, T.elementType),_chunkTRE7NUKEcjs.dc.call(void 0, T.elementType));if(!Array.isArray(m))throw new Error("Partial value for array must be an array");let x=_nullishCoalesce(m, () => ([]));x.sort((P,F)=>P.idx-F.idx);for(let{idx:P,value:F}of x)s(T.elementType,F,y+P*w,w-_chunkTRE7NUKEcjs.hc.call(void 0, T.elementType))}else{let T=_chunkTRE7NUKEcjs.hc.call(void 0, l);a.seekTo(y),Ee(a,l,m),o.push({start:y,end:y+T,padding:f})}}}if(s(e,t,0),o.length===0)return[];let i=[],u=o[0];for(let l=1;l<o.length;l++){let m=o[l];if(!m||!u)throw new Error("Internal error: missing segment");m.start===u.end+(_nullishCoalesce(u.padding, () => (0)))?(u.end=m.end,u.padding=m.padding):(i.push({data:new Uint8Array(n,u.start,u.end-u.start)}),u=m)}if(!u)throw new Error("Internal error: missing segment");return i.push({data:new Uint8Array(n,u.start,u.end-u.start)}),i}function Te(e){return!!_optionalChain([e, 'optionalAccess', _20 => _20.usableAsStorage])}var Je=class e extends Error{constructor(t){super(`Resource '${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, t), () => ("<unnamed>"))}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function jt(e){return!!e.usableAsUniform}var ua={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},Xe= (_class6 =class{constructor(t,r){;_class6.prototype.__init7.call(this);this.usage=t;this.buffer=r;this[_chunkTRE7NUKEcjs.a]={dataType:r.dataType},this[_chunkTRE7NUKEcjs.c]=r}__init7() {this.resourceType="buffer-usage"}$name(t){return this.buffer.$name(t),this}[_chunkTRE7NUKEcjs.f](t){let r=this.buffer.dataType,n=t.getUniqueName(this),{group:a,binding:o}=t.allocateFixedEntry(this.usage==="uniform"?{uniform:r}:{storage:r,access:this.usage},this.buffer),s=ua[this.usage];return t.addDeclaration(`@group(${a}) @binding(${o}) var<${s}> ${n}: ${t.resolve(r).value};`),_chunkTRE7NUKEcjs.aa.call(void 0, n,r)}toString(){return`${this.usage}:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunkTRE7NUKEcjs.b](){let t=this.buffer.dataType;return new Proxy({[_chunkTRE7NUKEcjs.a]:!0,get[_chunkTRE7NUKEcjs.e](){return _chunkTRE7NUKEcjs.aa.call(void 0, this,t)},[_chunkTRE7NUKEcjs.f]:r=>r.resolve(this),toString:()=>`${this.usage}:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},_chunkZYGTVBDHcjs.r)}get $(){let t=_chunkTRE7NUKEcjs.Ca.call(void 0, ),r=_chunkTRE7NUKEcjs.ya.call(void 0, );if(t.type==="normal")throw new (0, _chunkTRE7NUKEcjs.ka)(r?`Cannot access ${String(this.buffer)}. TypeGPU functions that depends on GPU resources need to be part of a compute dispatch, draw call or simulation`:".$ and .value are inaccessible during normal JS execution. Try `.read()`");return t.type==="codegen"?this[_chunkTRE7NUKEcjs.b]:t.type==="simulate"?(t.buffers.has(this.buffer)||t.buffers.set(this.buffer,_chunkTRE7NUKEcjs.qc.call(void 0, this.buffer.dataType,this.buffer.initial)),t.buffers.get(this.buffer)):_chunkTRE7NUKEcjs.Fa.call(void 0, t,"bufferUsage.ts#TgpuFixedBufferImpl/$")}get value(){return this.$}set $(t){let r=_chunkTRE7NUKEcjs.Ca.call(void 0, ),n=_chunkTRE7NUKEcjs.ya.call(void 0, );if(r.type==="normal")throw new (0, _chunkTRE7NUKEcjs.ka)(n?`Cannot access ${String(this.buffer)}. TypeGPU functions that depends on GPU resources need to be part of a compute dispatch, draw call or simulation`:".$ and .value are inaccessible during normal JS execution. Try `.write()`");if(r.type==="codegen")throw new Error("Unreachable bufferUsage.ts#TgpuFixedBufferImpl/$");if(r.type==="simulate"){r.buffers.set(this.buffer,t);return}_chunkTRE7NUKEcjs.Fa.call(void 0, r,"bufferUsage.ts#TgpuFixedBufferImpl/$")}set value(t){this.$=t}}, _class6),Ze= (_class7 =class{constructor(t,r,n){;_class7.prototype.__init8.call(this);this.usage=t;this.dataType=r;this[_chunkTRE7NUKEcjs.a]={dataType:r},this.#e=n,_chunkTRE7NUKEcjs.k.call(void 0, this,n.key)}__init8() {this.resourceType="buffer-usage"}#e;[_chunkTRE7NUKEcjs.f](t){let r=this.dataType,n=t.getUniqueName(this),a=t.allocateLayoutEntry(this.#e.layout),o=ua[this.usage];return t.addDeclaration(`@group(${a}) @binding(${this.#e.idx}) var<${o}> ${n}: ${t.resolve(r).value};`),_chunkTRE7NUKEcjs.aa.call(void 0, n,r)}toString(){return`${this.usage}:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunkTRE7NUKEcjs.b](){let t=this.dataType;return new Proxy({[_chunkTRE7NUKEcjs.a]:!0,get[_chunkTRE7NUKEcjs.e](){return _chunkTRE7NUKEcjs.aa.call(void 0, this,t)},[_chunkTRE7NUKEcjs.f]:r=>r.resolve(this),toString:()=>`${this.usage}:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},_chunkZYGTVBDHcjs.r)}get $(){if(_chunkTRE7NUKEcjs.Da.call(void 0, ))return this[_chunkTRE7NUKEcjs.b];throw new Error("Direct access to buffer values is possible only as part of a compute dispatch or draw call. Try .read() or .write() instead")}get value(){return this.$}}, _class7),oa=new WeakMap;function pa(e){if(!Te(e))throw new Error(`Cannot pass ${e} to asMutable, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=oa.get(e);return t||(t=new Xe("mutable",e),oa.set(e,t)),t}var sa=new WeakMap;function la(e){if(!Te(e))throw new Error(`Cannot pass ${e} to asReadonly, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=sa.get(e);return t||(t=new Xe("readonly",e),sa.set(e,t)),t}var ia=new WeakMap;function ma(e){if(!jt(e))throw new Error(`Cannot pass ${e} to asUniform, as it is not allowed to be used as a uniform. To allow it, call .$usage('uniform') when creating the buffer.`);let t=ia.get(e);return t||(t=new Xe("uniform",e),ia.set(e,t)),t}var lo={uniform:ma,mutable:pa,readonly:la};function et(e,t,r){return _chunkTRE7NUKEcjs.B.call(void 0, t)?new Qt(e,t,r):new Qt(e,t,r,["storage","uniform"])}function le(e){return e.resourceType==="buffer"}function mo(e){return!!e.usableAsVertex}var fo=_typedbinary.getSystemEndianness.call(void 0, ),Qt= (_class8 =class{constructor(t,r,n,a){;_class8.prototype.__init9.call(this);_class8.prototype.__init10.call(this);_class8.prototype.__init11.call(this);_class8.prototype.__init12.call(this);_class8.prototype.__init13.call(this);_class8.prototype.__init14.call(this);_class8.prototype.__init15.call(this);_class8.prototype.__init16.call(this);_class8.prototype.__init17.call(this);this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;this.#e=t.device,_chunkTRE7NUKEcjs.wa.call(void 0, n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}__init9() {this[_chunkTRE7NUKEcjs.a]=!0}__init10() {this.resourceType="buffer"}__init11() {this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}#e;__init12() {this._buffer=null}__init13() {this._destroyed=!1}__init14() {this.usableAsUniform=!1}__init15() {this.usableAsStorage=!1}__init16() {this.usableAsVertex=!1}__init17() {this.usableAsIndex=!1}get buffer(){if(this._destroyed)throw new Error("This buffer has been destroyed");return this._buffer||(this._buffer=this.#e.createBuffer({size:_chunkTRE7NUKEcjs.hc.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}),this.initial&&(this._writeToTarget(this._buffer.getMappedRange(),this.initial),this._buffer.unmap())),this._buffer}get destroyed(){return this._destroyed}$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this._buffer&&(this._buffer.label=t),this}$usage(...t){for(let r of t){if(_optionalChain([this, 'access', _21 => _21._disallowedUsages, 'optionalAccess', _22 => _22.includes, 'call', _23 => _23(r)]))throw new Error(`Buffer of type ${this.dataType.type} cannot be used as ${r}`);this.flags|=r==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=r==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=r==="vertex"?GPUBufferUsage.VERTEX:0,this.flags|=r==="index"?GPUBufferUsage.INDEX:0,this.usableAsUniform=this.usableAsUniform||r==="uniform",this.usableAsStorage=this.usableAsStorage||r==="storage",this.usableAsVertex=this.usableAsVertex||r==="vertex",this.usableAsIndex=this.usableAsIndex||r==="index"}return this}$addFlags(t){if(!this._ownBuffer)throw new Error("Cannot add flags to a buffer that is not managed by TypeGPU.");return t&GPUBufferUsage.MAP_READ?(this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this):t&GPUBufferUsage.MAP_WRITE?(this.flags=GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,this):(this.flags|=t,this)}compileWriter(){Br(this.dataType)}_writeToTarget(t,r){let n=Br(this.dataType);if(n)try{n(new DataView(t),0,r,fo==="little");return}catch(a){console.error(`Error when using compiled writer for buffer ${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))} - this is likely a bug, please submit an issue at https://github.com/software-mansion/TypeGPU/issues
|
|
16
|
+
Using fallback writer instead.`,a)}Ee(new (0, _typedbinary.BufferWriter)(t),this.dataType,r)}write(t){let r=this.buffer;if(r.mapState==="mapped"){let a=r.getMappedRange();this._writeToTarget(a,t);return}let n=_chunkTRE7NUKEcjs.hc.call(void 0, this.dataType);this._hostBuffer||(this._hostBuffer=new ArrayBuffer(n)),this._writeToTarget(this._hostBuffer,t),this.#e.queue.writeBuffer(r,0,this._hostBuffer,0,n)}writePartial(t){let r=this.buffer,n=aa(this.dataType,t);if(r.mapState==="mapped"){let a=r.getMappedRange(),o=new Uint8Array(a);for(let s of n)o.set(s.data,s.data.byteOffset)}else for(let a of n)this.#e.queue.writeBuffer(r,a.data.byteOffset,a.data,0,a.data.byteLength)}clear(){let t=this.buffer;if(t.mapState==="mapped"){new Uint8Array(t.getMappedRange()).fill(0);return}let r=this.#e.createCommandEncoder();r.clearBuffer(t),this.#e.queue.submit([r.finish()])}copyFrom(t){if(this.buffer.mapState==="mapped")throw new Error("Cannot copy to a mapped buffer.");let r=_chunkTRE7NUKEcjs.hc.call(void 0, this.dataType),n=this.#e.createCommandEncoder();n.copyBufferToBuffer(t.buffer,0,this.buffer,0,r),this.#e.queue.submit([n.finish()])}async read(){let t=this.buffer;if(t.mapState==="mapped"){let o=t.getMappedRange();return O(new (0, _typedbinary.BufferReader)(o),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let o=t.getMappedRange(),s=O(new (0, _typedbinary.BufferReader)(o),this.dataType);return t.unmap(),s}let r=this.#e.createBuffer({size:_chunkTRE7NUKEcjs.hc.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),n=this.#e.createCommandEncoder();n.copyBufferToBuffer(t,0,r,0,_chunkTRE7NUKEcjs.hc.call(void 0, this.dataType)),this.#e.queue.submit([n.finish()]),await r.mapAsync(GPUMapMode.READ,0,_chunkTRE7NUKEcjs.hc.call(void 0, this.dataType));let a=O(new (0, _typedbinary.BufferReader)(r.getMappedRange()),this.dataType);return r.unmap(),r.destroy(),a}as(t){return _optionalChain([lo, 'access', _24 => _24[t], 'optionalCall', _25 => _25(this)])}destroy(){this._destroyed||(this._destroyed=!0,this._ownBuffer&&_optionalChain([this, 'access', _26 => _26._buffer, 'optionalAccess', _27 => _27.destroy, 'call', _28 => _28()]))}toString(){return`buffer:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}}, _class8);function fa(e,t){return new Kt(_chunkZYGTVBDHcjs.u.call(void 0, ),e,t)}function da(e,t){return new Kt(_chunkZYGTVBDHcjs.v.call(void 0, ),e,t)}function tt(e){let t=e;return _optionalChain([t, 'optionalAccess', _29 => _29.resourceType])==="sampler"&&!!t[_chunkTRE7NUKEcjs.a]}function rt(e){let t=e;return _optionalChain([t, 'optionalAccess', _30 => _30.resourceType])==="sampler-comparison"&&!!t[_chunkTRE7NUKEcjs.a]}var Ht= (_class9 =class{constructor(t,r){;_class9.prototype.__init18.call(this);this.schema=t;this.#e=r,this.resourceType=t.type==="sampler_comparison"?"sampler-comparison":"sampler",_chunkTRE7NUKEcjs.k.call(void 0, this,r.key)}__init18() {this[_chunkTRE7NUKEcjs.a]={unwrap:void 0}}#e;[_chunkTRE7NUKEcjs.f](t){let r=t.getUniqueName(this),n=t.allocateLayoutEntry(this.#e.layout);return t.addDeclaration(`@group(${n}) @binding(${this.#e.idx}) var ${r}: ${t.resolve(this.schema).value};`),_chunkTRE7NUKEcjs.aa.call(void 0, r,this.schema)}get[_chunkTRE7NUKEcjs.b](){let t=this.schema;return new Proxy({[_chunkTRE7NUKEcjs.a]:!0,get[_chunkTRE7NUKEcjs.e](){return _chunkTRE7NUKEcjs.aa.call(void 0, this,t)},[_chunkTRE7NUKEcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},_chunkZYGTVBDHcjs.r)}get $(){if(_chunkTRE7NUKEcjs.Da.call(void 0, ))return this[_chunkTRE7NUKEcjs.b];throw new Error("Direct access to sampler values is possible only as part of a compute dispatch or draw call.")}get value(){return this.$}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}}, _class9),Kt=class{constructor(t,r,n){this.schema=t;this.#t=r,this.#n=n,this.resourceType=t.type==="sampler_comparison"?"sampler-comparison":"sampler",this[_chunkTRE7NUKEcjs.a]={unwrap:()=>(this.#r||(this.#r=this.#n.device.createSampler({...this.#t,label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))})),this.#r)},this.#e=r.minFilter==="linear"||r.magFilter==="linear"||r.mipmapFilter==="linear"}#e;#r=null;#t;#n;[_chunkTRE7NUKEcjs.f](t){let r=t.getUniqueName(this),{group:n,binding:a}=t.allocateFixedEntry(this.schema.type==="sampler_comparison"?{sampler:"comparison"}:{sampler:this.#e?"filtering":"non-filtering"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${t.resolve(this.schema).value};`),_chunkTRE7NUKEcjs.aa.call(void 0, r,this.schema)}get[_chunkTRE7NUKEcjs.b](){let t=this.schema;return new Proxy({[_chunkTRE7NUKEcjs.a]:!0,get[_chunkTRE7NUKEcjs.e](){return _chunkTRE7NUKEcjs.aa.call(void 0, this,t)},[_chunkTRE7NUKEcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},_chunkZYGTVBDHcjs.r)}get $(){if(_chunkTRE7NUKEcjs.Da.call(void 0, ))return this[_chunkTRE7NUKEcjs.b];throw new Error("Direct access to sampler values is possible only as part of a compute dispatch or draw call.")}get value(){return this.$}$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}};var Yt= (_class10 =class{constructor(t,r){;_class10.prototype.__init19.call(this);_class10.prototype.__init20.call(this);this.schema=t;this.#e=r,_chunkTRE7NUKEcjs.k.call(void 0, this,r.key)}__init19() {this.resourceType="external-texture"}__init20() {this[_chunkTRE7NUKEcjs.a]=!0}#e;[_chunkTRE7NUKEcjs.f](t){let r=t.getUniqueName(this),n=t.allocateLayoutEntry(this.#e.layout);return t.addDeclaration(`@group(${n}) @binding(${this.#e.idx}) var ${r}: ${t.resolve(this.schema).value};`),_chunkTRE7NUKEcjs.aa.call(void 0, r,_chunkZYGTVBDHcjs.Q.call(void 0, ))}get[_chunkTRE7NUKEcjs.b](){let t=this.schema;return new Proxy({[_chunkTRE7NUKEcjs.a]:!0,get[_chunkTRE7NUKEcjs.e](){return _chunkTRE7NUKEcjs.aa.call(void 0, this,t)},[_chunkTRE7NUKEcjs.f]:r=>r.resolve(this),toString:()=>`textureExternal:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},_chunkZYGTVBDHcjs.r)}get $(){if(_chunkTRE7NUKEcjs.Da.call(void 0, ))return this[_chunkTRE7NUKEcjs.b];throw new Error("Direct access to texture views values is possible only as part of a compute dispatch or draw call. Try .read() or .write() instead")}get value(){return this.$}toString(){return`textureExternal:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}}, _class10);function Jt(e){return"displayWidth"in e&&"displayHeight"in e?{width:e.displayWidth,height:e.displayHeight}:{width:e.width,height:e.height}}var $r=new WeakMap;function ca(e){let t=$r.get(e);return t||(t=new Map,$r.set(e,t)),t}function ga(e){let t=$r.get(e);t&&t.clear()}function ya(e,t,r=0,n){if(t.dimension!=="2d")throw new Error("Cannot generate mipmaps for non-2D textures: only 2D textures are currently supported.");let a=_nullishCoalesce(n, () => (t.mipLevelCount-r)),o=_chunk3246CM7Ccjs.b.call(void 0, t.format,e);if(![...o.sampleTypes].some(i=>i==="float"||i==="unfilterable-float"))throw new Error(`Cannot generate mipmaps for format '${t.format}': only float and unfilterable-float formats are currently supported.`);if(!o.canRenderAttachment)throw new Error(`Cannot generate mipmaps for format '${t.format}': format does not support render attachments.`);for(let i=0;i<t.depthOrArrayLayers;i++)for(let u=r;u<r+a-1;u++){let l=u,m=u+1;go(e,t,l,m,i)}}function Ta(e,t,r,n){if(t.dimension==="3d")throw new Error("Cannot resample to 3D textures: only 2D textures are currently supported.");let a=_chunk3246CM7Ccjs.a[t.format];if(![...a.sampleTypes].some(s=>s==="float"||s==="unfilterable-float"))throw new Error(`Cannot resample to format '${t.format}': only float and unfilterable-float formats are currently supported.`);if(!a.canRenderAttachment)throw new Error(`Cannot resample to format '${t.format}': format does not support render attachments.`);return co(e,t,r,n)}function co(e,t,r,n=0){let o=[..._chunk3246CM7Ccjs.a[t.format].sampleTypes].includes("float"),s=`${o?"filterable":"unfilterable"}`,i=ca(e),u=i.get(s);if(!u){let F=e.createShaderModule({code:`
|
|
17
17
|
struct VertexOutput {
|
|
18
18
|
@builtin(position) pos: vec4f,
|
|
19
19
|
@location(0) uv: vec2f,
|
|
@@ -29,7 +29,7 @@ fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
|
29
29
|
output.uv = uv[vertexIndex];
|
|
30
30
|
return output;
|
|
31
31
|
}
|
|
32
|
-
`}),
|
|
32
|
+
`}),R=e.createSampler({magFilter:o?"linear":"nearest",minFilter:o?"linear":"nearest"}),ke=e.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:o?"filtering":"non-filtering"}}]}),lr=e.createPipelineLayout({bindGroupLayouts:[ke]}),za=e.createShaderModule({code:`
|
|
33
33
|
@group(0) @binding(0) var inputTexture: texture_2d<f32>;
|
|
34
34
|
@group(0) @binding(1) var inputSampler: sampler;
|
|
35
35
|
|
|
@@ -38,7 +38,7 @@ fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
|
38
38
|
${o?"return textureSample(inputTexture, inputSampler, uv);":`let texelCoord = vec2u(uv * vec2f(textureDimensions(inputTexture)));
|
|
39
39
|
return textureLoad(inputTexture, texelCoord, 0);`}
|
|
40
40
|
}
|
|
41
|
-
`});u={vertexShader:F,fragmentShader:
|
|
41
|
+
`});u={vertexShader:F,fragmentShader:za,bindGroupLayout:ke,pipelineLayout:lr,sampler:R},i.set(s,u)}let l=e.createTexture({size:[...Object.values(Jt(r))],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_DST}),{width:m,height:y}=Jt(r);e.queue.copyExternalImageToTexture({source:r},{texture:l},[m,y,1]);let f=e.createTexture({size:[t.width,t.height,1],format:t.format,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),T=e.createRenderPipeline({layout:u.pipelineLayout,vertex:{module:u.vertexShader},fragment:{module:u.fragmentShader,targets:[{format:t.format}]},primitive:{topology:"triangle-list"}}),w=e.createBindGroup({layout:u.bindGroupLayout,entries:[{binding:0,resource:l.createView()},{binding:1,resource:u.sampler}]}),x=e.createCommandEncoder(),P=x.beginRenderPass({colorAttachments:[{view:f.createView(),loadOp:"clear",storeOp:"store"}]});P.setPipeline(T),P.setBindGroup(0,w),P.draw(3),P.end(),x.copyTextureToTexture({texture:f},{texture:t,origin:{x:0,y:0,z:n}},{width:t.width,height:t.height,depthOrArrayLayers:1}),e.queue.submit([x.finish()]),l.destroy(),f.destroy()}function go(e,t,r,n,a){let s=[..._chunk3246CM7Ccjs.b.call(void 0, t.format,e).sampleTypes].includes("float"),i=`${s?"filterable":"unfilterable"}`,u=ca(e),l=u.get(i);if(!l){let P=e.createShaderModule({code:`
|
|
42
42
|
struct VertexOutput {
|
|
43
43
|
@builtin(position) pos: vec4f,
|
|
44
44
|
@location(0) uv: vec2f,
|
|
@@ -54,7 +54,7 @@ fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
|
54
54
|
output.uv = uv[vertexIndex];
|
|
55
55
|
return output;
|
|
56
56
|
}
|
|
57
|
-
`}),F=
|
|
57
|
+
`}),F=e.createShaderModule({code:`
|
|
58
58
|
@group(0) @binding(0) var inputTexture: texture_2d<f32>;
|
|
59
59
|
@group(0) @binding(1) var inputSampler: sampler;
|
|
60
60
|
|
|
@@ -62,82 +62,82 @@ fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
|
62
62
|
fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
63
63
|
return textureSample(inputTexture, inputSampler, uv);
|
|
64
64
|
}
|
|
65
|
-
`}),_e=t.createSampler({magFilter:s?"linear":"nearest",minFilter:s?"linear":"nearest"}),We=t.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:s?"float":"unfilterable-float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:s?"filtering":"non-filtering"}}]}),lr=t.createPipelineLayout({bindGroupLayouts:[We]});l={vertexShader:P,fragmentShader:F,bindGroupLayout:We,pipelineLayout:lr,sampler:_e},u.set(i,l)}let f=t.createRenderPipeline({layout:l.pipelineLayout,vertex:{module:l.vertexShader},fragment:{module:l.fragmentShader,targets:[{format:e.format}]},primitive:{topology:"triangle-list"}}),c=e.createView({baseMipLevel:r,dimension:"2d",mipLevelCount:1,...a!==void 0&&{baseArrayLayer:a,arrayLayerCount:1}}),y=e.createView({baseMipLevel:n,dimension:"2d",mipLevelCount:1,...a!==void 0&&{baseArrayLayer:a,arrayLayerCount:1}}),h=t.createBindGroup({layout:l.bindGroupLayout,entries:[{binding:0,resource:c},{binding:1,resource:l.sampler}]}),v=t.createCommandEncoder(),x=v.beginRenderPass({colorAttachments:[{view:y,loadOp:"clear",storeOp:"store"}]});x.setPipeline(f),x.setBindGroup(0,h),x.draw(3),x.end(),t.queue.submit([v.finish()])}function ho(t){return{dimension:_nullishCoalesce(t.dimension, () => ("2d")),sampleType:_chunkCODEFPMDcjs.a[t.format].channelType,multisampled:(_nullishCoalesce(t.sampleCount, () => (1)))!==1}}function xo(t){return t==="depth24plus-stencil8"||t==="depth32float-stencil8"?["depth","stencil"]:t==="depth16unorm"||t==="depth24plus"||t==="depth32float"?["depth"]:t==="stencil8"?["stencil"]:["color"]}function Sa(t,e){return new Lr(t,e)}function ee(t){return _optionalChain([t, 'optionalAccess', _32 => _32.resourceType])==="texture"&&!!t[_chunk44LAYHPRcjs.a]}function nt(t){return _optionalChain([t, 'optionalAccess', _33 => _33.resourceType])==="texture-view"&&!!t[_chunk44LAYHPRcjs.a]}var Lr= (_class12 =class{constructor(e,r){;_class12.prototype.__init22.call(this);_class12.prototype.__init23.call(this);_class12.prototype.__init24.call(this);_class12.prototype.__init25.call(this);this.props=e;let n=e.format;this.#o=r,this.#e=_chunkCODEFPMDcjs.a[n],this.#r=e.size[0]*(_nullishCoalesce(e.size[1], () => (1)))*(_nullishCoalesce(e.size[2], () => (1)))*this.#e.texelSize,this.aspects=xo(n),this[_chunk44LAYHPRcjs.a]={unwrap:()=>{if(this.#t)throw new Error("This texture has been destroyed");return this.#a||(this.#a=r.device.createTexture({label:_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>")),format:e.format,size:e.size,usage:this.#n,dimension:_nullishCoalesce(e.dimension, () => ("2d")),viewFormats:_nullishCoalesce(e.viewFormats, () => ([])),mipLevelCount:_nullishCoalesce(e.mipLevelCount, () => (1)),sampleCount:_nullishCoalesce(e.sampleCount, () => (1))})),this.#a}}}__init22() {this.resourceType="texture"}__init23() {this.usableAsSampled=!1}__init24() {this.usableAsStorage=!1}__init25() {this.usableAsRender=!1}#e;#r;#t=!1;#n=GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;#a=null;#o;$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this,e),this}$usage(...e){let r=e.includes("storage"),n=e.includes("sampled"),a=e.includes("render");return this.#n|=n?GPUTextureUsage.TEXTURE_BINDING:0,this.#n|=r?GPUTextureUsage.STORAGE_BINDING:0,this.#n|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||=r,this.usableAsSampled||=n,this.usableAsRender||=a,this}createView(e,r){return new Cr(_nullishCoalesce(e, () => (_chunkHLB6TY7Icjs.w.call(void 0, ho(this.props)))),this,r)}#s(e=0){let r=2**e,[n,a,o]=[Math.max(1,Math.floor((_nullishCoalesce(this.props.size[0], () => (1)))/r)),Math.max(1,Math.floor((_nullishCoalesce(this.props.size[1], () => (1)))/r)),Math.max(1,Math.floor((_nullishCoalesce(this.props.size[2], () => (1)))/r))];this.#o.device.queue.writeTexture({texture:this[_chunk44LAYHPRcjs.a].unwrap(),mipLevel:e},new Uint8Array(n*a*o*this.#e.texelSize),{bytesPerRow:this.#e.texelSize*n,rowsPerImage:a},[n,a,o])}clear(e="all"){if(e==="all"){let r=_nullishCoalesce(this.props.mipLevelCount, () => (1));for(let n=0;n<r;n++)this.#s(n)}else this.#s(e)}generateMipmaps(e=0,r){if(this.usableAsRender===!1)throw new Error("generateMipmaps called without specifying 'render' usage. Add it via the $usage('render') method.");let n=_nullishCoalesce(r, () => ((_nullishCoalesce(this.props.mipLevelCount, () => (1)))-e));if(n<=1){console.warn(`generateMipmaps is a no-op: would generate ${n} mip levels (base: ${e}, total: ${_nullishCoalesce(this.props.mipLevelCount, () => (1))})`);return}if(e>=(_nullishCoalesce(this.props.mipLevelCount, () => (1))))throw new Error(`Base mip level ${e} is out of range. Texture has ${_nullishCoalesce(this.props.mipLevelCount, () => (1))} mip levels.`);wa(this.#o.device,this[_chunk44LAYHPRcjs.a].unwrap(),e,n)}write(e,r=0){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){this.#u(e,r);return}let n=_nullishCoalesce(this.props.dimension, () => ("2d"));if(!Array.isArray(e)){this.#i(e,n==="3d"?0:void 0);return}let o=_nullishCoalesce(this.props.size[2], () => (1));e.length>o&&console.warn(`Too many image sources provided. Expected ${o} layers, got ${e.length}. Extra sources will be ignored.`);for(let s=0;s<Math.min(e.length,o);s++){let i=e[s];i&&this.#i(i,s)}}#u(e,r){let n=Math.max(1,this.props.size[0]>>r),a=Math.max(1,(_nullishCoalesce(this.props.size[1], () => (1)))>>r),o=Math.max(1,(_nullishCoalesce(this.props.size[2], () => (1)))>>r),s=n*a*o*this.#e.texelSize,i=_nullishCoalesce(e.byteLength, () => (e.byteLength));if(i!==s)throw new Error(`Buffer size mismatch. Expected ${s} bytes for mip level ${r}, got ${i} bytes.`);this.#o.device.queue.writeTexture({texture:this[_chunk44LAYHPRcjs.a].unwrap(),mipLevel:r},e,{bytesPerRow:this.#e.texelSize*n,rowsPerImage:a},[n,a,o])}#i(e,r){let n=this.props.size[0],a=_nullishCoalesce(this.props.size[1], () => (1)),{width:o,height:s}=Jt(e);if(o!==n||s!==a){ba(this.#o.device,this[_chunk44LAYHPRcjs.a].unwrap(),e,r);return}this.#o.device.queue.copyExternalImageToTexture({source:e},{texture:this[_chunk44LAYHPRcjs.a].unwrap(),...r!==void 0&&{origin:{x:0,y:0,z:r}}},r!==void 0?[n,a,1]:this.props.size)}copyFrom(e){if(e.props.format!==this.props.format)throw new Error(`Texture format mismatch. Source texture has format ${e.props.format}, target texture has format ${this.props.format}`);if(e.props.size[0]!==this.props.size[0]||(_nullishCoalesce(e.props.size[1], () => (1)))!==(_nullishCoalesce(this.props.size[1], () => (1)))||(_nullishCoalesce(e.props.size[2], () => (1)))!==(_nullishCoalesce(this.props.size[2], () => (1))))throw new Error(`Texture size mismatch. Source texture has size ${e.props.size.join("x")}, target texture has size ${this.props.size.join("x")}`);let r=this.#o.device.createCommandEncoder();r.copyTextureToTexture({texture:e[_chunk44LAYHPRcjs.a].unwrap()},{texture:this[_chunk44LAYHPRcjs.a].unwrap()},e.props.size),this.#o.device.queue.submit([r.finish()])}get destroyed(){return this.#t}destroy(){this.#t||(this.#t=!0,_optionalChain([this, 'access', _34 => _34.#a, 'optionalAccess', _35 => _35.destroy, 'call', _36 => _36()]))}}, _class12),Cr= (_class13 =class{constructor(e,r,n){;_class13.prototype.__init26.call(this);this.schema=e;this.#e=r,this.#t=n,this[_chunk44LAYHPRcjs.a]={unwrap:()=>{if(!this.#r){let a=this.schema,o;_chunkHLB6TY7Icjs.Q.call(void 0, a)?o={label:_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>")),format:_nullishCoalesce(_optionalChain([this, 'access', _37 => _37.#t, 'optionalAccess', _38 => _38.format]), () => (a.format)),dimension:a.dimension}:o={label:_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>")),format:_nullishCoalesce(_optionalChain([this, 'access', _39 => _39.#t, 'optionalAccess', _40 => _40.format]), () => (this.#e.props.format)),dimension:a.dimension},_optionalChain([this, 'access', _41 => _41.#t, 'optionalAccess', _42 => _42.mipLevelCount])!==void 0&&(o.mipLevelCount=this.#t.mipLevelCount),_optionalChain([this, 'access', _43 => _43.#t, 'optionalAccess', _44 => _44.arrayLayerCount])!==void 0&&(o.arrayLayerCount=this.#t.arrayLayerCount),this.#r=this.#e[_chunk44LAYHPRcjs.a].unwrap().createView(o)}return this.#r}}}__init26() {this.resourceType="texture-view"}#e;#r;#t;$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this,e),this.#r&&(this.#r.label=e),this}get[_chunk44LAYHPRcjs.b](){let e=this.schema;return new Proxy({[_chunk44LAYHPRcjs.a]:!0,get[_chunk44LAYHPRcjs.e](){return _chunk44LAYHPRcjs.aa.call(void 0, this,e)},[_chunk44LAYHPRcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},R)}get $(){if(_chunk44LAYHPRcjs.Da.call(void 0, ))return this[_chunk44LAYHPRcjs.b];throw new Error("Direct access to texture view values is possible only as part of a compute dispatch or draw call. Try .read() or .write() instead")}get value(){return this.$}toString(){return`textureView:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}[_chunk44LAYHPRcjs.f](e){let r=e.getUniqueName(this),{group:n,binding:a}=e.allocateFixedEntry(_chunkHLB6TY7Icjs.Q.call(void 0, this.schema)?{storageTexture:this.schema}:{texture:this.schema,sampleType:_nullishCoalesce(_optionalChain([this, 'access', _45 => _45.#t, 'optionalAccess', _46 => _46.sampleType]), () => (this.schema.bindingSampleType[0]))},this);return e.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${e.resolve(this.schema).value};`),_chunk44LAYHPRcjs.aa.call(void 0, r,this.schema)}}, _class13),rt= (_class14 =class{constructor(e,r){;_class14.prototype.__init27.call(this);_class14.prototype.__init28.call(this);this.schema=e;this.#e=r,_chunk44LAYHPRcjs.k.call(void 0, this,r.key)}__init27() {this[_chunk44LAYHPRcjs.a]={unwrap:void 0}}__init28() {this.resourceType="texture-view"}#e;toString(){return`textureView:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}[_chunk44LAYHPRcjs.f](e){let r=e.getUniqueName(this),n=e.allocateLayoutEntry(this.#e.layout);return e.addDeclaration(`@group(${n}) @binding(${this.#e.idx}) var ${r}: ${e.resolve(this.schema).value};`),_chunk44LAYHPRcjs.aa.call(void 0, r,this.schema)}get[_chunk44LAYHPRcjs.b](){let e=this.schema;return new Proxy({[_chunk44LAYHPRcjs.a]:!0,get[_chunk44LAYHPRcjs.e](){return _chunk44LAYHPRcjs.aa.call(void 0, this,e)},[_chunk44LAYHPRcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},R)}get $(){if(_chunk44LAYHPRcjs.Da.call(void 0, ))return this[_chunk44LAYHPRcjs.b];throw new Error("Direct access to texture views values is possible only as part of a compute dispatch or draw call. Try .read() or .write() instead")}get value(){return this.$}}, _class14);function Er(t){return!!_optionalChain([t, 'optionalAccess', _47 => _47.usableAsSampled])}function wo(t){return!!_optionalChain([t, 'optionalAccess', _48 => _48.usableAsRender])}var Xt=class t extends Error{constructor(e){super(`Resource '${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, e), () => ("<unnamed>"))}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,t.prototype)}};function bo(t){let e={};for(let[r,n]of Object.entries(t)){if(n===null){e[r]=null;continue}if("texture"in n&&typeof n.texture=="string"){let a=n.texture;e[r]={...n,texture:_chunkHLB6TY7Icjs.w.call(void 0, {dimension:_nullishCoalesce(n.viewDimension, () => ("2d")),sampleType:a==="sint"?_chunk44LAYHPRcjs.Ua:a==="uint"?_chunk44LAYHPRcjs.Sa:_chunk44LAYHPRcjs.Va,multisampled:_nullishCoalesce(n.multisampled, () => (!1))})}}else if("storageTexture"in n&&typeof n.storageTexture=="string"){let a={readonly:"read-only",writeonly:"write-only",mutable:"read-write"};e[r]={...n,storageTexture:_chunkHLB6TY7Icjs.w.call(void 0, {access:a[_nullishCoalesce(n.access, () => ("writeonly"))],format:n.storageTexture,dimension:_nullishCoalesce(n.viewDimension, () => ("2d"))})}}else"externalTexture"in n&&Object.keys(n.externalTexture).length===0?e[r]={...n,externalTexture:{type:"texture_external",dimension:"2d"}}:e[r]=n}return e}function Zt(t){let e=bo(t);return new _r(e)}function er(t){return!!t&&t.resourceType==="bind-group-layout"}function Te(t){return!!t&&t.resourceType==="bind-group"}var Vr=class t extends Error{constructor(e,r){super(`Bind group '${_nullishCoalesce(e, () => ("<unnamed>"))}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,t.prototype)}},va=["compute","fragment"],at=["compute","vertex","fragment"],_r= (_class15 =class{constructor(e){;_class15.prototype.__init29.call(this);_class15.prototype.__init30.call(this);_class15.prototype.__init31.call(this);_class15.prototype.__init32.call(this);_class15.prototype.__init33.call(this);this.entries=e;let r=0;for(let[n,a]of Object.entries(e)){if(a===null){r++;continue}let o={layout:this,key:n,idx:r};if("uniform"in a&&(this.bound[n]=new Xe("uniform",a.uniform,o)),"storage"in a){let s="type"in a.storage?a.storage:a.storage(0);this.bound[n]=new Xe(_nullishCoalesce(a.access, () => ("readonly")),s,o)}"texture"in a&&(this.bound[n]=new rt(a.texture,o)),"storageTexture"in a&&(this.bound[n]=new rt(a.storageTexture,o)),"externalTexture"in a&&(this.bound[n]=new Yt(a.externalTexture,o)),"sampler"in a&&(this.bound[n]=new Ht(a.sampler==="comparison"?_chunkHLB6TY7Icjs.t.call(void 0, ):_chunkHLB6TY7Icjs.s.call(void 0, ),o)),Object.defineProperty(this.value,n,{get:()=>this.bound[n].value}),r++}}__init29() {this[_chunk44LAYHPRcjs.a]=!0}__init30() {this.resourceType="bind-group-layout"}__init31() {this.bound={}}__init32() {this.value={}}__init33() {this.$=this.value}get[_chunk44LAYHPRcjs.b](){return this.$}toString(){return`bindGroupLayout:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get index(){return this._index}$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this,e),this}$idx(e){return this._index=e,this}unwrap(e){return e.device.createBindGroupLayout({label:_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>")),entries:Object.values(this.entries).map((n,a)=>{if(n===null)return null;let o=n.visibility,s={binding:a,visibility:0};if("uniform"in n)o=_nullishCoalesce(o, () => (at)),s.buffer={type:"uniform"};else if("storage"in n)o=_nullishCoalesce(o, () => ((n.access==="mutable"?va:at))),s.buffer={type:n.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in n)o=_nullishCoalesce(o, () => (at)),s.sampler={type:n.sampler};else if("texture"in n){o=_nullishCoalesce(o, () => (at));let{multisampled:i,dimension:u,bindingSampleType:l}=n.texture;s.texture={sampleType:_nullishCoalesce(n.sampleType, () => (l[0])),viewDimension:u,multisampled:i}}else if("storageTexture"in n){o=_nullishCoalesce(o, () => (va));let{dimension:i,access:u,format:l}=n.storageTexture;s.storageTexture={access:u,format:l,viewDimension:i}}else"externalTexture"in n&&(o=_nullishCoalesce(o, () => (at)),s.externalTexture={});return _optionalChain([o, 'optionalAccess', _49 => _49.includes, 'call', _50 => _50("compute")])&&(s.visibility|=GPUShaderStage.COMPUTE),_optionalChain([o, 'optionalAccess', _51 => _51.includes, 'call', _52 => _52("vertex")])&&(s.visibility|=GPUShaderStage.VERTEX),_optionalChain([o, 'optionalAccess', _53 => _53.includes, 'call', _54 => _54("fragment")])&&(s.visibility|=GPUShaderStage.FRAGMENT),s}).filter(n=>n!==null)})}}, _class15),Ce= (_class16 =class{constructor(e,r){;_class16.prototype.__init34.call(this);this.layout=e;this.entries=r;for(let n of Object.keys(e.entries))if(e.entries[n]!==null&&!(n in r))throw new Vr(_chunk44LAYHPRcjs.j.call(void 0, e),n)}__init34() {this.resourceType="bind-group"}unwrap(e){return e.device.createBindGroup({label:_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this.layout), () => ("<unnamed>")),layout:e.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([n,a],o)=>{if(a===null)return null;let s=this.entries[n];if(s===void 0)throw new Error(`'${n}' is a resource required to populate bind group layout '${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this.layout), () => ("<unnamed>"))}'.`);if("uniform"in a){let i;if(pe(s)){if(!jt(s))throw new (0, _chunk44LAYHPRcjs.fa)(s);i={buffer:e.unwrap(s)}}else i={buffer:s};return{binding:o,resource:i}}if("storage"in a){let i;if(pe(s)){if(!ye(s))throw new Ye(s);i={buffer:e.unwrap(s)}}else i={buffer:s};return{binding:o,resource:i}}if("texture"in a){let i;if(ee(s)){if(!Er(s))throw new Xt(s);i=e.unwrap(s.createView(a.texture))}else nt(s)?i=e.unwrap(s):i=s;return{binding:o,resource:i}}if("storageTexture"in a){let i;if(ee(s)){if(!ye(s))throw new Ye(s);i=e.unwrap(s.createView(a.storageTexture))}else nt(s)?i=e.unwrap(s):i=s;return{binding:o,resource:i}}if("sampler"in a)return tt(s)||et(s)?{binding:o,resource:e.unwrap(s)}:{binding:o,resource:s};if("externalTexture"in a)return{binding:o,resource:s};throw new Error(`Malformed bind group entry: ${_chunk44LAYHPRcjs.mb.call(void 0, s)}`)}).filter(n=>n!==null)})}}, _class16);function he(t){return new Wr(t)}var Wr= (_class17 =class{constructor(e=void 0){;_class17.prototype.__init35.call(this);_class17.prototype.__init36.call(this);this.defaultValue=e}__init35() {this[_chunk44LAYHPRcjs.a]=!0}__init36() {this.resourceType="slot"}$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this,e),this}areEqual(e,r){return Object.is(e,r)}toString(){return`slot:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunk44LAYHPRcjs.b](){let e=_chunk44LAYHPRcjs.Aa.call(void 0, );if(!e)throw new Error("Cannot access tgpu.slot's value outside of resolution.");return ge(e.unwrap(this))}get value(){return this[_chunk44LAYHPRcjs.b]}get $(){return this.value}}, _class17);function Ee(t,e){return new ot("private",t,e)}function kr(t){return new ot("workgroup",t)}function So(t){return t instanceof ot}var ot= (_class18 =class{__init37() {this[_chunk44LAYHPRcjs.a]={}}#e;#r;#t;constructor(e,r,n){;_class18.prototype.__init37.call(this);this.#e=e,this.#r=r,this.#t=n}[_chunk44LAYHPRcjs.f](e){let r=e.getUniqueName(this),n=`var<${this.#e}> ${r}: ${e.resolve(this.#r).value}`;return this.#t?e.addDeclaration(`${n} = ${e.resolve(this.#t,this.#r).value};`):e.addDeclaration(`${n};`),_chunk44LAYHPRcjs.aa.call(void 0, r,this.#r)}$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this,e),this}toString(){return`var:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunk44LAYHPRcjs.b](){let e=this.#r;return new Proxy({[_chunk44LAYHPRcjs.a]:!0,get[_chunk44LAYHPRcjs.e](){return _chunk44LAYHPRcjs.aa.call(void 0, this,e)},[_chunk44LAYHPRcjs.f]:r=>r.resolve(this),toString:()=>`var:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},R)}get $(){let e=_chunk44LAYHPRcjs.Ca.call(void 0, ),r=_chunk44LAYHPRcjs.ya.call(void 0, );if(e.type==="normal")throw new (0, _chunk44LAYHPRcjs.ja)(r?`Cannot access variable '${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}'. TypeGPU functions that depends on GPU resources need to be part of a compute dispatch, draw call or simulation`:"TypeGPU variables are inaccessible during normal JS execution. If you wanted to simulate GPU behavior, try `tgpu.simulate()`");return e.type==="codegen"?this[_chunk44LAYHPRcjs.b]:e.type==="simulate"?(e.vars[this.#e].has(this)||e.vars[this.#e].set(this,this.#t),e.vars[this.#e].get(this)):_chunk44LAYHPRcjs.Ga.call(void 0, e,"tgpuVariable.ts#TgpuVarImpl/$")}set $(e){let r=_chunk44LAYHPRcjs.Ca.call(void 0, ),n=_chunk44LAYHPRcjs.ya.call(void 0, );if(r.type==="normal")throw new (0, _chunk44LAYHPRcjs.ja)(n?`Cannot access ${String(this)}. TypeGPU functions that depends on GPU resources need to be part of a compute dispatch, draw call or simulation`:"TypeGPU variables are inaccessible during normal JS execution. If you wanted to simulate GPU behavior, try `tgpu.simulate()`");if(r.type==="codegen")throw new Error("Unreachable tgpuVariable.ts#TgpuVarImpl/$");if(r.type==="simulate"){r.vars[this.#e].set(this,e);return}_chunk44LAYHPRcjs.Ga.call(void 0, r,"tgpuVariable.ts#TgpuVarImpl/$")}get value(){return this.$}set value(e){this.$=e}}, _class18);var Ia=Ee(_chunk44LAYHPRcjs.Sa,0).$name("dataBlockIndex"),Ua=Ee(_chunk44LAYHPRcjs.Sa,0).$name("dataByteIndex"),Fa=he().$name("dataBuffer"),vo=U([],_chunk44LAYHPRcjs.Sa)`() {
|
|
65
|
+
`}),R=e.createSampler({magFilter:s?"linear":"nearest",minFilter:s?"linear":"nearest"}),ke=e.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:s?"float":"unfilterable-float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:s?"filtering":"non-filtering"}}]}),lr=e.createPipelineLayout({bindGroupLayouts:[ke]});l={vertexShader:P,fragmentShader:F,bindGroupLayout:ke,pipelineLayout:lr,sampler:R},u.set(i,l)}let m=e.createRenderPipeline({layout:l.pipelineLayout,vertex:{module:l.vertexShader},fragment:{module:l.fragmentShader,targets:[{format:t.format}]},primitive:{topology:"triangle-list"}}),y=t.createView({baseMipLevel:r,dimension:"2d",mipLevelCount:1,...a!==void 0&&{baseArrayLayer:a,arrayLayerCount:1}}),f=t.createView({baseMipLevel:n,dimension:"2d",mipLevelCount:1,...a!==void 0&&{baseArrayLayer:a,arrayLayerCount:1}}),T=e.createBindGroup({layout:l.bindGroupLayout,entries:[{binding:0,resource:y},{binding:1,resource:l.sampler}]}),w=e.createCommandEncoder(),x=w.beginRenderPass({colorAttachments:[{view:f,loadOp:"clear",storeOp:"store"}]});x.setPipeline(m),x.setBindGroup(0,T),x.draw(3),x.end(),e.queue.submit([w.finish()])}function yo(e){return{dimension:_nullishCoalesce(e.dimension, () => ("2d")),sampleType:_chunk3246CM7Ccjs.a[e.format].channelType,multisampled:(_nullishCoalesce(e.sampleCount, () => (1)))!==1}}function To(e){return e==="depth24plus-stencil8"||e==="depth32float-stencil8"?["depth","stencil"]:e==="depth16unorm"||e==="depth24plus"||e==="depth32float"?["depth"]:e==="stencil8"?["stencil"]:["color"]}function ha(e,t){return new Lr(e,t)}function ee(e){return _optionalChain([e, 'optionalAccess', _31 => _31.resourceType])==="texture"&&!!e[_chunkTRE7NUKEcjs.a]}function he(e){return _optionalChain([e, 'optionalAccess', _32 => _32.resourceType])==="texture-view"&&!!e[_chunkTRE7NUKEcjs.a]}var Lr= (_class11 =class{constructor(t,r){;_class11.prototype.__init21.call(this);_class11.prototype.__init22.call(this);_class11.prototype.__init23.call(this);_class11.prototype.__init24.call(this);this.props=t;let n=t.format;this.#o=r,this.#e=_chunk3246CM7Ccjs.a[n],this.#r=t.size[0]*(_nullishCoalesce(t.size[1], () => (1)))*(_nullishCoalesce(t.size[2], () => (1)))*this.#e.texelSize,this.aspects=To(n),this[_chunkTRE7NUKEcjs.a]={unwrap:()=>{if(this.#t)throw new Error("This texture has been destroyed");return this.#a||(this.#a=r.device.createTexture({label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>")),format:t.format,size:t.size,usage:this.#n,dimension:_nullishCoalesce(t.dimension, () => ("2d")),viewFormats:_nullishCoalesce(t.viewFormats, () => ([])),mipLevelCount:_nullishCoalesce(t.mipLevelCount, () => (1)),sampleCount:_nullishCoalesce(t.sampleCount, () => (1))})),this.#a}}}__init21() {this.resourceType="texture"}__init22() {this.usableAsSampled=!1}__init23() {this.usableAsStorage=!1}__init24() {this.usableAsRender=!1}#e;#r;#t=!1;#n=GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;#a=null;#o;$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this}$usage(...t){let r=t.includes("storage"),n=t.includes("sampled"),a=t.includes("render");return this.#n|=n?GPUTextureUsage.TEXTURE_BINDING:0,this.#n|=r?GPUTextureUsage.STORAGE_BINDING:0,this.#n|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||=r,this.usableAsSampled||=n,this.usableAsRender||=a,this}createView(t,r){return new Rr(_nullishCoalesce(t, () => (_chunkZYGTVBDHcjs.y.call(void 0, yo(this.props)))),this,r)}#s(t=0){let r=2**t,[n,a,o]=[Math.max(1,Math.floor((_nullishCoalesce(this.props.size[0], () => (1)))/r)),Math.max(1,Math.floor((_nullishCoalesce(this.props.size[1], () => (1)))/r)),Math.max(1,Math.floor((_nullishCoalesce(this.props.size[2], () => (1)))/r))];this.#o.device.queue.writeTexture({texture:this[_chunkTRE7NUKEcjs.a].unwrap(),mipLevel:t},new Uint8Array(n*a*o*this.#e.texelSize),{bytesPerRow:this.#e.texelSize*n,rowsPerImage:a},[n,a,o])}clear(t="all"){if(t==="all"){let r=_nullishCoalesce(this.props.mipLevelCount, () => (1));for(let n=0;n<r;n++)this.#s(n)}else this.#s(t)}generateMipmaps(t=0,r){if(this.usableAsRender===!1)throw new Error("generateMipmaps called without specifying 'render' usage. Add it via the $usage('render') method.");let n=_nullishCoalesce(r, () => ((_nullishCoalesce(this.props.mipLevelCount, () => (1)))-t));if(n<=1){console.warn(`generateMipmaps is a no-op: would generate ${n} mip levels (base: ${t}, total: ${_nullishCoalesce(this.props.mipLevelCount, () => (1))})`);return}if(t>=(_nullishCoalesce(this.props.mipLevelCount, () => (1))))throw new Error(`Base mip level ${t} is out of range. Texture has ${_nullishCoalesce(this.props.mipLevelCount, () => (1))} mip levels.`);ya(this.#o.device,this[_chunkTRE7NUKEcjs.a].unwrap(),t,n)}write(t,r=0){if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){this.#u(t,r);return}let n=_nullishCoalesce(this.props.dimension, () => ("2d"));if(!Array.isArray(t)){this.#i(t,n==="3d"?0:void 0);return}let o=_nullishCoalesce(this.props.size[2], () => (1));t.length>o&&console.warn(`Too many image sources provided. Expected ${o} layers, got ${t.length}. Extra sources will be ignored.`);for(let s=0;s<Math.min(t.length,o);s++){let i=t[s];i&&this.#i(i,s)}}#u(t,r){let n=Math.max(1,this.props.size[0]>>r),a=Math.max(1,(_nullishCoalesce(this.props.size[1], () => (1)))>>r),o=Math.max(1,(_nullishCoalesce(this.props.size[2], () => (1)))>>r),s=n*a*o*this.#e.texelSize,i=_nullishCoalesce(t.byteLength, () => (t.byteLength));if(i!==s)throw new Error(`Buffer size mismatch. Expected ${s} bytes for mip level ${r}, got ${i} bytes.`);this.#o.device.queue.writeTexture({texture:this[_chunkTRE7NUKEcjs.a].unwrap(),mipLevel:r},t,{bytesPerRow:this.#e.texelSize*n,rowsPerImage:a},[n,a,o])}#i(t,r){let n=this.props.size[0],a=_nullishCoalesce(this.props.size[1], () => (1)),{width:o,height:s}=Jt(t);if(o!==n||s!==a){Ta(this.#o.device,this[_chunkTRE7NUKEcjs.a].unwrap(),t,r);return}this.#o.device.queue.copyExternalImageToTexture({source:t},{texture:this[_chunkTRE7NUKEcjs.a].unwrap(),...r!==void 0&&{origin:{x:0,y:0,z:r}}},r!==void 0?[n,a,1]:this.props.size)}copyFrom(t){if(t.props.format!==this.props.format)throw new Error(`Texture format mismatch. Source texture has format ${t.props.format}, target texture has format ${this.props.format}`);if(t.props.size[0]!==this.props.size[0]||(_nullishCoalesce(t.props.size[1], () => (1)))!==(_nullishCoalesce(this.props.size[1], () => (1)))||(_nullishCoalesce(t.props.size[2], () => (1)))!==(_nullishCoalesce(this.props.size[2], () => (1))))throw new Error(`Texture size mismatch. Source texture has size ${t.props.size.join("x")}, target texture has size ${this.props.size.join("x")}`);let r=this.#o.device.createCommandEncoder();r.copyTextureToTexture({texture:t[_chunkTRE7NUKEcjs.a].unwrap()},{texture:this[_chunkTRE7NUKEcjs.a].unwrap()},t.props.size),this.#o.device.queue.submit([r.finish()])}get destroyed(){return this.#t}destroy(){this.#t||(this.#t=!0,_optionalChain([this, 'access', _33 => _33.#a, 'optionalAccess', _34 => _34.destroy, 'call', _35 => _35()]))}}, _class11),Rr= (_class12 =class{constructor(t,r,n){;_class12.prototype.__init25.call(this);this.schema=t;this.#e=r,this.#t=n,this[_chunkTRE7NUKEcjs.a]={unwrap:()=>{if(!this.#r){let a=this.schema,o;_chunkZYGTVBDHcjs.S.call(void 0, a)?o={label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>")),format:_nullishCoalesce(_optionalChain([this, 'access', _36 => _36.#t, 'optionalAccess', _37 => _37.format]), () => (a.format)),dimension:a.dimension}:o={label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>")),format:_nullishCoalesce(_optionalChain([this, 'access', _38 => _38.#t, 'optionalAccess', _39 => _39.format]), () => (this.#e.props.format)),dimension:a.dimension},_optionalChain([this, 'access', _40 => _40.#t, 'optionalAccess', _41 => _41.mipLevelCount])!==void 0&&(o.mipLevelCount=this.#t.mipLevelCount),_optionalChain([this, 'access', _42 => _42.#t, 'optionalAccess', _43 => _43.arrayLayerCount])!==void 0&&(o.arrayLayerCount=this.#t.arrayLayerCount),this.#r=this.#e[_chunkTRE7NUKEcjs.a].unwrap().createView(o)}return this.#r}}}__init25() {this.resourceType="texture-view"}#e;#r;#t;$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this.#r&&(this.#r.label=t),this}get[_chunkTRE7NUKEcjs.b](){let t=this.schema;return new Proxy({[_chunkTRE7NUKEcjs.a]:!0,get[_chunkTRE7NUKEcjs.e](){return _chunkTRE7NUKEcjs.aa.call(void 0, this,t)},[_chunkTRE7NUKEcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},_chunkZYGTVBDHcjs.r)}get $(){if(_chunkTRE7NUKEcjs.Da.call(void 0, ))return this[_chunkTRE7NUKEcjs.b];throw new Error("Direct access to texture view values is possible only as part of a compute dispatch or draw call. Try .read() or .write() instead")}get value(){return this.$}toString(){return`textureView:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}[_chunkTRE7NUKEcjs.f](t){let r=t.getUniqueName(this),{group:n,binding:a}=t.allocateFixedEntry(_chunkZYGTVBDHcjs.S.call(void 0, this.schema)?{storageTexture:this.schema}:{texture:this.schema,sampleType:_nullishCoalesce(_optionalChain([this, 'access', _44 => _44.#t, 'optionalAccess', _45 => _45.sampleType]), () => (this.schema.bindingSampleType[0]))},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${t.resolve(this.schema).value};`),_chunkTRE7NUKEcjs.aa.call(void 0, r,this.schema)}}, _class12),nt= (_class13 =class{constructor(t,r){;_class13.prototype.__init26.call(this);_class13.prototype.__init27.call(this);this.schema=t;this.#e=r,_chunkTRE7NUKEcjs.k.call(void 0, this,r.key)}__init26() {this[_chunkTRE7NUKEcjs.a]={unwrap:void 0}}__init27() {this.resourceType="texture-view"}#e;toString(){return`textureView:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}[_chunkTRE7NUKEcjs.f](t){let r=t.getUniqueName(this),n=t.allocateLayoutEntry(this.#e.layout);return t.addDeclaration(`@group(${n}) @binding(${this.#e.idx}) var ${r}: ${t.resolve(this.schema).value};`),_chunkTRE7NUKEcjs.aa.call(void 0, r,this.schema)}get[_chunkTRE7NUKEcjs.b](){let t=this.schema;return new Proxy({[_chunkTRE7NUKEcjs.a]:!0,get[_chunkTRE7NUKEcjs.e](){return _chunkTRE7NUKEcjs.aa.call(void 0, this,t)},[_chunkTRE7NUKEcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},_chunkZYGTVBDHcjs.r)}get $(){if(_chunkTRE7NUKEcjs.Da.call(void 0, ))return this[_chunkTRE7NUKEcjs.b];throw new Error("Direct access to texture views values is possible only as part of a compute dispatch or draw call. Try .read() or .write() instead")}get value(){return this.$}}, _class13);function Gr(e){return!!_optionalChain([e, 'optionalAccess', _46 => _46.usableAsSampled])}function ho(e){return!!_optionalChain([e, 'optionalAccess', _47 => _47.usableAsRender])}var Xt=class e extends Error{constructor(t){super(`Resource '${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, t), () => ("<unnamed>"))}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function xo(e){let t={};for(let[r,n]of Object.entries(e)){if(n===null){t[r]=null;continue}if("texture"in n&&typeof n.texture=="string"){let a=n.texture;t[r]={...n,texture:_chunkZYGTVBDHcjs.y.call(void 0, {dimension:_nullishCoalesce(n.viewDimension, () => ("2d")),sampleType:a==="sint"?_chunkTRE7NUKEcjs.Ta:a==="uint"?_chunkTRE7NUKEcjs.Ra:_chunkTRE7NUKEcjs.Ua,multisampled:_nullishCoalesce(n.multisampled, () => (!1))})}}else if("storageTexture"in n&&typeof n.storageTexture=="string"){let a={readonly:"read-only",writeonly:"write-only",mutable:"read-write"};t[r]={...n,storageTexture:_chunkZYGTVBDHcjs.y.call(void 0, {access:a[_nullishCoalesce(n.access, () => ("writeonly"))],format:n.storageTexture,dimension:_nullishCoalesce(n.viewDimension, () => ("2d"))})}}else"externalTexture"in n&&Object.keys(n.externalTexture).length===0?t[r]={...n,externalTexture:{type:"texture_external",dimension:"2d"}}:t[r]=n}return t}function Zt(e){let t=xo(e);return new Er(t)}function er(e){return!!e&&e.resourceType==="bind-group-layout"}function xe(e){return!!e&&e.resourceType==="bind-group"}var Cr=class e extends Error{constructor(t,r){super(`Bind group '${_nullishCoalesce(t, () => ("<unnamed>"))}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},xa=["compute","fragment"],at=["compute","vertex","fragment"],Er= (_class14 =class{constructor(t){;_class14.prototype.__init28.call(this);_class14.prototype.__init29.call(this);_class14.prototype.__init30.call(this);_class14.prototype.__init31.call(this);_class14.prototype.__init32.call(this);this.entries=t;let r=0;for(let[n,a]of Object.entries(t)){if(a===null){r++;continue}let o={layout:this,key:n,idx:r};if("uniform"in a&&(this.bound[n]=new Ze("uniform",a.uniform,o)),"storage"in a){let s="type"in a.storage?a.storage:a.storage(0);this.bound[n]=new Ze(_nullishCoalesce(a.access, () => ("readonly")),s,o)}"texture"in a&&(this.bound[n]=new nt(a.texture,o)),"storageTexture"in a&&(this.bound[n]=new nt(a.storageTexture,o)),"externalTexture"in a&&(this.bound[n]=new Yt(a.externalTexture,o)),"sampler"in a&&(this.bound[n]=new Ht(a.sampler==="comparison"?_chunkZYGTVBDHcjs.v.call(void 0, ):_chunkZYGTVBDHcjs.u.call(void 0, ),o)),Object.defineProperty(this.value,n,{get:()=>this.bound[n].value}),r++}}__init28() {this[_chunkTRE7NUKEcjs.a]=!0}__init29() {this.resourceType="bind-group-layout"}__init30() {this.bound={}}__init31() {this.value={}}__init32() {this.$=this.value}get[_chunkTRE7NUKEcjs.b](){return this.$}toString(){return`bindGroupLayout:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get index(){return this._index}$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this}$idx(t){return this._index=t,this}unwrap(t){return t.device.createBindGroupLayout({label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>")),entries:Object.values(this.entries).map((n,a)=>{if(n===null)return null;let o=n.visibility,s={binding:a,visibility:0};if("uniform"in n)o=_nullishCoalesce(o, () => (at)),s.buffer={type:"uniform"};else if("storage"in n)o=_nullishCoalesce(o, () => ((n.access==="mutable"?xa:at))),s.buffer={type:n.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in n)o=_nullishCoalesce(o, () => (at)),s.sampler={type:n.sampler};else if("texture"in n){o=_nullishCoalesce(o, () => (at));let{multisampled:i,dimension:u,bindingSampleType:l}=n.texture;s.texture={sampleType:_nullishCoalesce(n.sampleType, () => (l[0])),viewDimension:u,multisampled:i}}else if("storageTexture"in n){o=_nullishCoalesce(o, () => (xa));let{dimension:i,access:u,format:l}=n.storageTexture;s.storageTexture={access:u,format:l,viewDimension:i}}else"externalTexture"in n&&(o=_nullishCoalesce(o, () => (at)),s.externalTexture={});return _optionalChain([o, 'optionalAccess', _48 => _48.includes, 'call', _49 => _49("compute")])&&(s.visibility|=GPUShaderStage.COMPUTE),_optionalChain([o, 'optionalAccess', _50 => _50.includes, 'call', _51 => _51("vertex")])&&(s.visibility|=GPUShaderStage.VERTEX),_optionalChain([o, 'optionalAccess', _52 => _52.includes, 'call', _53 => _53("fragment")])&&(s.visibility|=GPUShaderStage.FRAGMENT),s}).filter(n=>n!==null)})}}, _class14),Ve= (_class15 =class{constructor(t,r){;_class15.prototype.__init33.call(this);this.layout=t;this.entries=r;for(let n of Object.keys(t.entries))if(t.entries[n]!==null&&!(n in r))throw new Cr(_chunkTRE7NUKEcjs.j.call(void 0, t),n)}__init33() {this.resourceType="bind-group"}unwrap(t){return t.device.createBindGroup({label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this.layout), () => ("<unnamed>")),layout:t.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([n,a],o)=>{if(a===null)return null;let s=this.entries[n];if(s===void 0)throw new Error(`'${n}' is a resource required to populate bind group layout '${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this.layout), () => ("<unnamed>"))}'.`);if("uniform"in a){let i;if(le(s)){if(!jt(s))throw new (0, _chunkTRE7NUKEcjs.fa)(s);i={buffer:t.unwrap(s)}}else i={buffer:s};return{binding:o,resource:i}}if("storage"in a){let i;if(le(s)){if(!Te(s))throw new Je(s);i={buffer:t.unwrap(s)}}else i={buffer:s};return{binding:o,resource:i}}if("texture"in a){let i;if(ee(s)){if(!Gr(s))throw new Xt(s);i=t.unwrap(s.createView(a.texture))}else he(s)?i=t.unwrap(s):i=s;return{binding:o,resource:i}}if("storageTexture"in a){let i;if(ee(s)){if(!Te(s))throw new Je(s);i=t.unwrap(s.createView(a.storageTexture))}else he(s)?i=t.unwrap(s):i=s;return{binding:o,resource:i}}if("sampler"in a)return rt(s)||tt(s)?{binding:o,resource:t.unwrap(s)}:{binding:o,resource:s};if("externalTexture"in a)return{binding:o,resource:s};throw new Error(`Malformed bind group entry: ${_chunkTRE7NUKEcjs.lb.call(void 0, s)}`)}).filter(n=>n!==null)})}}, _class15);function we(e){return new Vr(e)}var Vr= (_class16 =class{constructor(t=void 0){;_class16.prototype.__init34.call(this);_class16.prototype.__init35.call(this);this.defaultValue=t}__init34() {this[_chunkTRE7NUKEcjs.a]=!0}__init35() {this.resourceType="slot"}$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this}areEqual(t,r){return Object.is(t,r)}toString(){return`slot:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunkTRE7NUKEcjs.b](){let t=_chunkTRE7NUKEcjs.Aa.call(void 0, );if(!t)throw new Error("Cannot access tgpu.slot's value outside of resolution.");return _chunkZYGTVBDHcjs.s.call(void 0, t.unwrap(this))}get value(){return this[_chunkTRE7NUKEcjs.b]}get $(){return this.value}}, _class16);function _e(e,t){return new ot("private",e,t)}function _r(e){return new ot("workgroup",e)}function wo(e){return e instanceof ot}var ot= (_class17 =class{__init36() {this[_chunkTRE7NUKEcjs.a]={}}#e;#r;#t;constructor(t,r,n){;_class17.prototype.__init36.call(this);this.#e=t,this.#r=r,this.#t=n}[_chunkTRE7NUKEcjs.f](t){let r=t.getUniqueName(this),n=`var<${this.#e}> ${r}: ${t.resolve(this.#r).value}`;return this.#t?t.addDeclaration(`${n} = ${t.resolve(this.#t,this.#r).value};`):t.addDeclaration(`${n};`),_chunkTRE7NUKEcjs.aa.call(void 0, r,this.#r)}$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this}toString(){return`var:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunkTRE7NUKEcjs.b](){let t=this.#r;return new Proxy({[_chunkTRE7NUKEcjs.a]:!0,get[_chunkTRE7NUKEcjs.e](){return _chunkTRE7NUKEcjs.aa.call(void 0, this,t)},[_chunkTRE7NUKEcjs.f]:r=>r.resolve(this),toString:()=>`var:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},_chunkZYGTVBDHcjs.r)}get $(){let t=_chunkTRE7NUKEcjs.Ca.call(void 0, ),r=_chunkTRE7NUKEcjs.ya.call(void 0, );if(t.type==="normal")throw new (0, _chunkTRE7NUKEcjs.ja)(r?`Cannot access variable '${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}'. TypeGPU functions that depends on GPU resources need to be part of a compute dispatch, draw call or simulation`:"TypeGPU variables are inaccessible during normal JS execution. If you wanted to simulate GPU behavior, try `tgpu.simulate()`");return t.type==="codegen"?this[_chunkTRE7NUKEcjs.b]:t.type==="simulate"?(t.vars[this.#e].has(this)||t.vars[this.#e].set(this,this.#t),t.vars[this.#e].get(this)):_chunkTRE7NUKEcjs.Fa.call(void 0, t,"tgpuVariable.ts#TgpuVarImpl/$")}set $(t){let r=_chunkTRE7NUKEcjs.Ca.call(void 0, ),n=_chunkTRE7NUKEcjs.ya.call(void 0, );if(r.type==="normal")throw new (0, _chunkTRE7NUKEcjs.ja)(n?`Cannot access ${String(this)}. TypeGPU functions that depends on GPU resources need to be part of a compute dispatch, draw call or simulation`:"TypeGPU variables are inaccessible during normal JS execution. If you wanted to simulate GPU behavior, try `tgpu.simulate()`");if(r.type==="codegen")throw new Error("Unreachable tgpuVariable.ts#TgpuVarImpl/$");if(r.type==="simulate"){r.vars[this.#e].set(this,t);return}_chunkTRE7NUKEcjs.Fa.call(void 0, r,"tgpuVariable.ts#TgpuVarImpl/$")}get value(){return this.$}set value(t){this.$=t}}, _class17);var wa=_e(_chunkTRE7NUKEcjs.Ra,0).$name("dataBlockIndex"),ba=_e(_chunkTRE7NUKEcjs.Ra,0).$name("dataByteIndex"),Sa=we().$name("dataBuffer"),bo=U([],_chunkTRE7NUKEcjs.Ra)`() {
|
|
66
66
|
let i = dataByteIndex;
|
|
67
67
|
dataByteIndex = dataByteIndex + 1u;
|
|
68
68
|
return i;
|
|
69
|
-
}`.$uses({dataByteIndex:
|
|
69
|
+
}`.$uses({dataByteIndex:ba}).$name("nextByteIndex"),d="dataBuffer[dataBlockIndex].serializedData[nextByteIndex()]",va={f32:U([_chunkTRE7NUKEcjs.Ua])`(n) => {
|
|
70
70
|
${d} = bitcast<u32>(n);
|
|
71
|
-
}`,f16:U([
|
|
71
|
+
}`,f16:U([_chunkTRE7NUKEcjs.Va])`(n) => {
|
|
72
72
|
${d} = pack2x16float(vec2f(f32(n), 0.0));
|
|
73
|
-
}`,i32:U([
|
|
73
|
+
}`,i32:U([_chunkTRE7NUKEcjs.Ta])`(n) => {
|
|
74
74
|
${d} = bitcast<u32>(n);
|
|
75
|
-
}`,u32:U([
|
|
75
|
+
}`,u32:U([_chunkTRE7NUKEcjs.Ra])`(n) => {
|
|
76
76
|
${d} = n;
|
|
77
|
-
}`,bool:U([
|
|
77
|
+
}`,bool:U([_chunkTRE7NUKEcjs.Qa])`(b) => {
|
|
78
78
|
${d} = u32(b);
|
|
79
|
-
}`,vec2f:U([
|
|
79
|
+
}`,vec2f:U([_chunkTRE7NUKEcjs.Xa])`(v) => {
|
|
80
80
|
${d} = bitcast<u32>(v.x);
|
|
81
81
|
${d} = bitcast<u32>(v.y);
|
|
82
|
-
}`,vec3f:U([
|
|
82
|
+
}`,vec3f:U([_chunkTRE7NUKEcjs.ab])`(v) => {
|
|
83
83
|
${d} = bitcast<u32>(v.x);
|
|
84
84
|
${d} = bitcast<u32>(v.y);
|
|
85
85
|
${d} = bitcast<u32>(v.z);
|
|
86
|
-
}`,vec4f:U([
|
|
86
|
+
}`,vec4f:U([_chunkTRE7NUKEcjs.fb])`(v) => {
|
|
87
87
|
${d} = bitcast<u32>(v.x);
|
|
88
88
|
${d} = bitcast<u32>(v.y);
|
|
89
89
|
${d} = bitcast<u32>(v.z);
|
|
90
90
|
${d} = bitcast<u32>(v.w);
|
|
91
|
-
}`,vec2h:U([
|
|
91
|
+
}`,vec2h:U([_chunkTRE7NUKEcjs.Ya])`(v) => {
|
|
92
92
|
${d} = pack2x16float(vec2f(f32(v.x), f32(v.y)));
|
|
93
|
-
}`,vec3h:U([
|
|
93
|
+
}`,vec3h:U([_chunkTRE7NUKEcjs.bb])`(v) => {
|
|
94
94
|
${d} = pack2x16float(vec2f(f32(v.x), f32(v.y)));
|
|
95
95
|
${d} = pack2x16float(vec2f(f32(v.z), 0.0));
|
|
96
|
-
}`,vec4h:U([
|
|
96
|
+
}`,vec4h:U([_chunkTRE7NUKEcjs.gb])`(v) => {
|
|
97
97
|
${d} = pack2x16float(vec2f(f32(v.x), f32(v.y)));
|
|
98
98
|
${d} = pack2x16float(vec2f(f32(v.z), f32(v.w)));
|
|
99
|
-
}`,vec2i:U([
|
|
99
|
+
}`,vec2i:U([_chunkTRE7NUKEcjs.Za])`(v) => {
|
|
100
100
|
${d} = bitcast<u32>(v.x);
|
|
101
101
|
${d} = bitcast<u32>(v.y);
|
|
102
|
-
}`,vec3i:U([
|
|
102
|
+
}`,vec3i:U([_chunkTRE7NUKEcjs.cb])`(v) => {
|
|
103
103
|
${d} = bitcast<u32>(v.x);
|
|
104
104
|
${d} = bitcast<u32>(v.y);
|
|
105
105
|
${d} = bitcast<u32>(v.z);
|
|
106
|
-
}`,vec4i:U([
|
|
106
|
+
}`,vec4i:U([_chunkTRE7NUKEcjs.hb])`(v) => {
|
|
107
107
|
${d} = bitcast<u32>(v.x);
|
|
108
108
|
${d} = bitcast<u32>(v.y);
|
|
109
109
|
${d} = bitcast<u32>(v.z);
|
|
110
110
|
${d} = bitcast<u32>(v.w);
|
|
111
|
-
}`,vec2u:U([
|
|
111
|
+
}`,vec2u:U([_chunkTRE7NUKEcjs._a])`(v) => {
|
|
112
112
|
${d} = v.x;
|
|
113
113
|
${d} = v.y;
|
|
114
|
-
}`,vec3u:U([
|
|
114
|
+
}`,vec3u:U([_chunkTRE7NUKEcjs.db])`(v) => {
|
|
115
115
|
${d} = v.x;
|
|
116
116
|
${d} = v.y;
|
|
117
117
|
${d} = v.z;
|
|
118
|
-
}`,vec4u:U([
|
|
118
|
+
}`,vec4u:U([_chunkTRE7NUKEcjs.ib])`(v) => {
|
|
119
119
|
${d} = v.x;
|
|
120
120
|
${d} = v.y;
|
|
121
121
|
${d} = v.z;
|
|
122
122
|
${d} = v.w;
|
|
123
|
-
}`,"vec2<bool>":U([
|
|
123
|
+
}`,"vec2<bool>":U([_chunkTRE7NUKEcjs.$a])`(v) => {
|
|
124
124
|
${d} = u32(v.x);
|
|
125
125
|
${d} = u32(v.y);
|
|
126
|
-
}`,"vec3<bool>":U([
|
|
126
|
+
}`,"vec3<bool>":U([_chunkTRE7NUKEcjs.eb])`(v) => {
|
|
127
127
|
${d} = u32(v.x);
|
|
128
128
|
${d} = u32(v.y);
|
|
129
129
|
${d} = u32(v.z);
|
|
130
|
-
}`,"vec4<bool>":U([
|
|
130
|
+
}`,"vec4<bool>":U([_chunkTRE7NUKEcjs.jb])`(v) => {
|
|
131
131
|
${d} = u32(v.x);
|
|
132
132
|
${d} = u32(v.y);
|
|
133
133
|
${d} = u32(v.z);
|
|
134
134
|
${d} = u32(v.w);
|
|
135
|
-
}`,mat2x2f:U([
|
|
135
|
+
}`,mat2x2f:U([_chunkZYGTVBDHcjs.j])`(m) => {
|
|
136
136
|
${d} = bitcast<u32>(m[0][0]);
|
|
137
137
|
${d} = bitcast<u32>(m[0][1]);
|
|
138
138
|
${d} = bitcast<u32>(m[1][0]);
|
|
139
139
|
${d} = bitcast<u32>(m[1][1]);
|
|
140
|
-
}`,mat3x3f:U([
|
|
140
|
+
}`,mat3x3f:U([_chunkZYGTVBDHcjs.k])`(m) => {
|
|
141
141
|
${d} = bitcast<u32>(m[0][0]);
|
|
142
142
|
${d} = bitcast<u32>(m[0][1]);
|
|
143
143
|
${d} = bitcast<u32>(m[0][2]);
|
|
@@ -150,7 +150,7 @@ fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
|
150
150
|
${d} = bitcast<u32>(m[2][1]);
|
|
151
151
|
${d} = bitcast<u32>(m[2][2]);
|
|
152
152
|
${d} = 0u;
|
|
153
|
-
}`,mat4x4f:U([
|
|
153
|
+
}`,mat4x4f:U([_chunkZYGTVBDHcjs.l])`(m) => {
|
|
154
154
|
${d} = bitcast<u32>(m[0][0]);
|
|
155
155
|
${d} = bitcast<u32>(m[0][1]);
|
|
156
156
|
${d} = bitcast<u32>(m[0][2]);
|
|
@@ -167,26 +167,26 @@ fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
|
167
167
|
${d} = bitcast<u32>(m[3][1]);
|
|
168
168
|
${d} = bitcast<u32>(m[3][2]);
|
|
169
169
|
${d} = bitcast<u32>(m[3][3]);
|
|
170
|
-
}`};for(let[t
|
|
171
|
-
`)}\n}`.$uses({elementSerializer:o}).$name("arraySerializer")}throw new Error(`Cannot serialize data of type ${
|
|
172
|
-
`);return n`${a} {\n${o}\n}`.$uses(r).$name("compoundSerializer")}function
|
|
170
|
+
}`};for(let[e,t]of Object.entries(va))t.$name(`serialize${e[0].toLocaleUpperCase()}${e.slice(1)}`).$uses({dataBlockIndex:wa,nextByteIndex:bo,dataBuffer:Sa});function Ia(e){return`(${e.map((t,r)=>`_arg_${r}`).join(", ")})`}function Ua(e,t){let r=va[e.type];if(r)return r.with(Sa,t);if(_chunkTRE7NUKEcjs.D.call(void 0, e)){let n=Object.keys(e.propTypes),a=Object.values(e.propTypes),o=Fa(a,t);return U([e])`(arg) {\n propsSerializer(${n.map(s=>`arg.${s}`).join(", ")});\n}`.$uses({propsSerializer:o}).$name(`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, e), () => ("struct"))}Serializer`)}if(_chunkTRE7NUKEcjs.C.call(void 0, e)){let n=e.elementType,a=e.elementCount,o=Ua(n,t);return U([e])`(arg) {\n${Array.from({length:a},(s,i)=>` elementSerializer(arg[${i}]);`).join(`
|
|
171
|
+
`)}\n}`.$uses({elementSerializer:o}).$name("arraySerializer")}throw new Error(`Cannot serialize data of type ${e.type}`)}function Fa(e,t){let r={},n=U(e),a=Ia(e),o=e.map((s,i)=>(r[`serializer${i}`]=Ua(s,t),` serializer${i}(_arg_${i});`)).join(`
|
|
172
|
+
`);return n`${a} {\n${o}\n}`.$uses(r).$name("compoundSerializer")}function Pa(e,t,r,n,a){let o=t.map(_chunkTRE7NUKEcjs.hc).reduce((u,l)=>u+l,0);if(o>a.logSizeLimit)throw new Error(`Logged data needs to fit in ${a.logSizeLimit} bytes (one of the logs requires ${o} bytes). Consider increasing the limit by passing appropriate options to tgpu.init().`);let s=Fa(t,r).$name(`log${e}serializer`),i=Ia(t);return U(t)`${i} {
|
|
173
173
|
dataBlockIndex = atomicAdd(&indexBuffer, 1);
|
|
174
174
|
if (dataBlockIndex >= ${a.logCountLimit}) {
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
|
-
dataBuffer[dataBlockIndex].id = ${
|
|
177
|
+
dataBuffer[dataBlockIndex].id = ${e};
|
|
178
178
|
dataByteIndex = 0;
|
|
179
179
|
|
|
180
180
|
compoundSerializer${i};
|
|
181
|
-
}`.$uses({indexBuffer:n,dataBuffer:r,dataBlockIndex:Ia,dataByteIndex:Ua,compoundSerializer:s}).$name(`log${t}`)}var Io={logCountLimit:64,logSizeLimit:252,messagePrefix:"%c GPU %c "},tr=class{get logResources(){}generateLog(){return console.warn("'console.log' is currently only supported in compute pipelines."),_chunk44LAYHPRcjs.aa.call(void 0, "/* console.log() */",_chunk44LAYHPRcjs.q)}},rr=class{#e;#r;#t=1;#n;#a;constructor(e){this.#e={...Io,...e[_chunk44LAYHPRcjs.a].logOptions},this.#r=new Map;let r=_chunk44LAYHPRcjs.sc.call(void 0, {id:_chunk44LAYHPRcjs.Sa,serializedData:_chunk44LAYHPRcjs.uc.call(void 0, _chunk44LAYHPRcjs.Sa,Math.ceil(this.#e.logSizeLimit/4))}).$name("SerializedLogData");this.#a=e.createMutable(_chunk44LAYHPRcjs.uc.call(void 0, r,this.#e.logCountLimit)).$name("dataBuffer"),this.#n=e.createMutable(_chunkHLB6TY7Icjs.R.call(void 0, _chunk44LAYHPRcjs.Sa)).$name("indexBuffer")}generateLog(e,r){let n=_chunkHLB6TY7Icjs.q.call(void 0, r),a=this.#t++,o=n.filter(i=>i.dataType!==_chunk44LAYHPRcjs.W),s=Aa(a,o.map(i=>i.dataType),this.#a,this.#n,this.#e);return this.#r.set(a,n.map(i=>i.dataType===_chunk44LAYHPRcjs.W?i.value:i.dataType)),_chunk44LAYHPRcjs.aa.call(void 0, _chunk44LAYHPRcjs.Ea`${e.resolve(s).value}(${o})`,_chunk44LAYHPRcjs.q)}get logResources(){return this.#t===1?void 0:{dataBuffer:this.#a,indexBuffer:this.#n,options:this.#e,logIdToArgTypes:this.#r}}};var Ga="#CATCHALL#",Mr= (_class19 =class{constructor() { _class19.prototype.__init38.call(this);_class19.prototype.__init39.call(this); }__init38() {this._stack=[]}__init39() {this._itemDepth=0}get itemDepth(){return this._itemDepth}get topItem(){let e=this._stack[this._stack.length-1];if(!e||e.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return e}get topFunctionScope(){return this._stack.findLast(e=>e.type==="functionScope")}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}popItem(){this.pop("item")}pushSlotBindings(e){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(e)})}popSlotBindings(){this.pop("slotBinding")}pushFunctionScope(e,r,n,a){let o={type:"functionScope",args:e,argAliases:r,returnType:n,externalMap:a,reportedReturnTypes:new Set};return this._stack.push(o),o}popFunctionScope(){this.pop("functionScope")}pushBlockScope(){this._stack.push({type:"blockScope",declarations:new Map})}popBlockScope(){this.pop("blockScope")}pop(e){let r=this._stack[this._stack.length-1];if(!r||e&&r.type!==e)throw new Error(`Internal error, expected a ${e} layer to be on top.`);this._stack.pop(),e==="item"&&this._itemDepth--}readSlot(e){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _55 => _55.type])==="item")n.usedSlots.add(e);else if(_optionalChain([n, 'optionalAccess', _56 => _56.type])==="slotBinding"){let a=n.bindingMap.get(e);if(a!==void 0)return a}else if(!(_optionalChain([n, 'optionalAccess', _57 => _57.type])==="functionScope"||_optionalChain([n, 'optionalAccess', _58 => _58.type])==="blockScope"))throw new Error("Unknown layer type.")}return e.defaultValue}getSnippetById(e){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _59 => _59.type])==="functionScope"){let a=n.args.find(s=>s.value===e);if(a!==void 0)return a;if(n.argAliases[e])return n.argAliases[e];let o=n.externalMap[e];return o!=null?_chunkHLB6TY7Icjs.r.call(void 0, o):void 0}if(_optionalChain([n, 'optionalAccess', _60 => _60.type])==="blockScope"){let a=n.declarations.get(e);if(a!==void 0)return a}}}defineBlockVariable(e,r){if(r.dataType.type==="unknown")throw Error(`Tried to define variable '${e}' of unknown type`);for(let n=this._stack.length-1;n>=0;--n){let a=this._stack[n];if(_optionalChain([a, 'optionalAccess', _61 => _61.type])==="blockScope"){a.declarations.set(e,r);return}}throw new Error("No block scope found to define a variable in.")}}, _class19),nr=[""," "," "," "," "," "," "," "," "],Or=nr.length-1,zr= (_class20 =class{constructor() { _class20.prototype.__init40.call(this); }__init40() {this.identLevel=0}get pre(){return _nullishCoalesce(nr[this.identLevel], () => (nr[Or].repeat(this.identLevel/Or)+nr[this.identLevel%Or]))}indent(){let e=this.pre;return this.identLevel++,e}dedent(){return this.identLevel--,this.pre}withResetLevel(e){let r=this.identLevel;this.identLevel=0;try{return e()}finally{this.identLevel=r}}}, _class20),st= (_class21 =class{#e;#r;__init41() {this._indentController=new zr}__init42() {this._itemStateStack=new Mr}#t=[];__init43() {this._declarations=[]}#n=new WeakSet;#a;get varyingLocations(){return this._varyingLocations}__init44() {this[_chunk44LAYHPRcjs.a]={itemStateStack:this._itemStateStack}}__init45() {this.bindGroupLayoutsToPlaceholderMap=new Map}__init46() {this._nextFreeLayoutPlaceholderIdx=0}__init47() {this.fixedBindings=[]}constructor(e){;_class21.prototype.__init41.call(this);_class21.prototype.__init42.call(this);_class21.prototype.__init43.call(this);_class21.prototype.__init44.call(this);_class21.prototype.__init45.call(this);_class21.prototype.__init46.call(this);_class21.prototype.__init47.call(this);this.enableExtensions=e.enableExtensions,this.#r=_nullishCoalesce(e.shaderGenerator, () => (_chunkHLB6TY7Icjs.hb)),this.#a=e.root?new rr(e.root):new tr,this.#e=e.namespace[_chunk44LAYHPRcjs.a]}getUniqueName(e){return na(this.#e,e)}makeNameValid(e){return this.#e.nameRegistry.makeValid(e)}get pre(){return this._indentController.pre}get topFunctionReturnType(){let e=this._itemStateStack.topFunctionScope;return _chunk44LAYHPRcjs.ba.call(void 0, e,"Internal error, expected function scope to be present."),e.returnType}get shelllessRepo(){return this.#e.shelllessRepo}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}withResetIndentLevel(e){return this._indentController.withResetLevel(e)}getById(e){let r=this._itemStateStack.getSnippetById(e);return r===void 0?null:r}defineVariable(e,r){this._itemStateStack.defineBlockVariable(e,r)}reportReturnType(e){let r=this._itemStateStack.topFunctionScope;_chunk44LAYHPRcjs.ba.call(void 0, r,"Internal error, expected function scope to be present."),r.reportedReturnTypes.add(e)}pushBlockScope(){this._itemStateStack.pushBlockScope()}popBlockScope(){this._itemStateStack.popBlockScope()}generateLog(e){return this.#a.generateLog(this,e)}get logResources(){return this.#a.logResources}fnToWgsl(e){let r=this._itemStateStack.pushFunctionScope(e.args,e.argAliases,e.returnType,e.externalMap);try{this.#r.initGenerator(this);let n=this.#r.functionDefinition(e.body),a=e.returnType;if(!a){let o=[...r.reportedReturnTypes];if(o.length===0)a=_chunk44LAYHPRcjs.q;else{let s=_chunk44LAYHPRcjs.Ha.call(void 0, o);s&&!s.hasImplicitConversions&&(a=s.targetType)}if(!a)throw new Error(`Expected function to have a single return type, got [${o.join(", ")}]. Cast explicitly to the desired type.`);a=_chunkHLB6TY7Icjs.p.call(void 0, a)}return{head:Uo(this,e.args,a),body:n,returnType:a}}finally{this._itemStateStack.popFunctionScope()}}addDeclaration(e){this._declarations.push(e)}allocateLayoutEntry(e){let r=this.bindGroupLayoutsToPlaceholderMap,n=r.get(e);return n||(n=`#BIND_GROUP_LAYOUT_${this._nextFreeLayoutPlaceholderIdx++}#`,r.set(e,n)),n}allocateFixedEntry(e,r){let n=this.fixedBindings.length;return this.fixedBindings.push({layoutEntry:e,resource:r}),{group:Ga,binding:n}}readSlot(e){let r=this._itemStateStack.readSlot(e);if(r===void 0)throw new (0, _chunk44LAYHPRcjs.ea)(e);return r}withSlots(e,r){this._itemStateStack.pushSlotBindings(e);try{return r()}finally{this._itemStateStack.popSlotBindings()}}withVaryingLocations(e,r){this._varyingLocations=e;try{return r()}finally{this._varyingLocations=void 0}}unwrap(e){if(_chunk44LAYHPRcjs.oa.call(void 0, e))return this.withSlots(e[_chunk44LAYHPRcjs.d].pairs,()=>this.unwrap(e[_chunk44LAYHPRcjs.d].inner));let r=e;for(;;)if(_chunk44LAYHPRcjs.ma.call(void 0, r))r=this.readSlot(r);else if(_chunk44LAYHPRcjs.na.call(void 0, r))r=this._getOrCompute(r);else break;return r}_getOrCompute(e){let r=_nullishCoalesce(this.#e.memoizedDerived.get(e), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([i,u])=>i.areEqual(this._itemStateStack.readSlot(i),u)))return o.result;this.pushMode(new _chunk44LAYHPRcjs.qa);let n;try{n=e["~compute"]()}finally{this.popMode("normal")}let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this.#e.memoizedDerived.set(e,r),n}catch(n){throw n instanceof _chunk44LAYHPRcjs.ca?n.appendToTrace(e):new (0, _chunk44LAYHPRcjs.ca)(n,[e])}finally{this._itemStateStack.popItem()}}_getOrInstantiate(e){let r=_nullishCoalesce(this.#e.memoizedResolves.get(e), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([i,u])=>i.areEqual(this._itemStateStack.readSlot(i),u)))return o.result;let n;if(_chunk44LAYHPRcjs.V.call(void 0, e))n=_chunk44LAYHPRcjs.aa.call(void 0, Br(this,e),_chunk44LAYHPRcjs.q);else if(_chunk44LAYHPRcjs.na.call(void 0, e)||_chunk44LAYHPRcjs.ma.call(void 0, e))n=this.resolve(this.unwrap(e));else if(_chunk44LAYHPRcjs.ta.call(void 0, e))n=e[_chunk44LAYHPRcjs.f](this);else if(_chunk44LAYHPRcjs.m.call(void 0, e)){let o=this.#e.shelllessRepo.get(e,void 0);if(!o)throw new Error(`Couldn't resolve ${e.name}. Make sure it's a function that accepts no arguments, or call it from another TypeGPU function.`);return this.withResetIndentLevel(()=>this.resolve(o))}else throw new TypeError(`Unresolvable internal value: ${_chunk44LAYHPRcjs.mb.call(void 0, e)}`);let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this.#e.memoizedResolves.set(e,r),n}catch(n){throw n instanceof _chunk44LAYHPRcjs.ca?n.appendToTrace(e):new (0, _chunk44LAYHPRcjs.ca)(n,[e])}finally{this._itemStateStack.popItem()}}resolve(e,r,n=!1){if(He(e)||_chunk44LAYHPRcjs.m.call(void 0, e)){if(this.#n.has(e)&&!this.#e.memoizedResolves.has(e))throw new Error(`Recursive function ${e} detected. Recursion is not allowed on the GPU.`);this.#n.add(e)}if(_chunk44LAYHPRcjs.oa.call(void 0, e))return this.withSlots(e[_chunk44LAYHPRcjs.d].pairs,()=>this.resolve(e[_chunk44LAYHPRcjs.d].inner,r,n));if(_chunk44LAYHPRcjs.h.call(void 0, e)||_chunk44LAYHPRcjs.m.call(void 0, e)){if(this._itemStateStack.itemDepth===0)try{this.pushMode(new _chunk44LAYHPRcjs.ra);let a=_chunk44LAYHPRcjs.za.call(void 0, this,()=>this._getOrInstantiate(e));return _chunk44LAYHPRcjs.aa.call(void 0, `${[...this._declarations].join(`
|
|
181
|
+
}`.$uses({indexBuffer:n,dataBuffer:r,dataBlockIndex:wa,dataByteIndex:ba,compoundSerializer:s}).$name(`log${e}`)}var Da=["log","debug","info","warn","error","clear"];var So={logCountLimit:64,logSizeLimit:252,messagePrefix:" GPU "},Ba=_chunkTRE7NUKEcjs.aa.call(void 0, "/* console.log() */",_chunkTRE7NUKEcjs.q),tr=class{get logResources(){}generateLog(){return console.warn("'console.log' is currently only supported in compute pipelines."),Ba}},rr=class{#e;#r;#t=1;#n;#a;constructor(t){this.#e={...So,...t[_chunkTRE7NUKEcjs.a].logOptions},this.#r=new Map;let r=_chunkTRE7NUKEcjs.rc.call(void 0, {id:_chunkTRE7NUKEcjs.Ra,serializedData:_chunkTRE7NUKEcjs.tc.call(void 0, _chunkTRE7NUKEcjs.Ra,Math.ceil(this.#e.logSizeLimit/4))}).$name("SerializedLogData");this.#a=t.createMutable(_chunkTRE7NUKEcjs.tc.call(void 0, r,this.#e.logCountLimit)).$name("dataBuffer"),this.#n=t.createMutable(_chunkZYGTVBDHcjs.T.call(void 0, _chunkTRE7NUKEcjs.Ra)).$name("indexBuffer")}generateLog(t,r,n){if(!Da.includes(r))return console.warn(`Unsupported log method '${r}' was used in TGSL.`),Ba;let a=_chunkZYGTVBDHcjs.p.call(void 0, n),o=this.#t++,s=a.filter(l=>l.dataType!==_chunkTRE7NUKEcjs.W),i=Pa(o,s.map(l=>l.dataType),this.#a,this.#n,this.#e),u=a.map(l=>l.dataType===_chunkTRE7NUKEcjs.W?l.value:l.dataType);return this.#r.set(o,{op:r,argTypes:u}),_chunkTRE7NUKEcjs.aa.call(void 0, _chunkTRE7NUKEcjs.Ea`${t.resolve(i).value}(${s})`,_chunkTRE7NUKEcjs.q)}get logResources(){return this.#t===1?void 0:{dataBuffer:this.#a,indexBuffer:this.#n,options:this.#e,logIdToMeta:this.#r}}};var Aa="#CATCHALL#",kr= (_class18 =class{constructor() { _class18.prototype.__init37.call(this);_class18.prototype.__init38.call(this); }__init37() {this._stack=[]}__init38() {this._itemDepth=0}get itemDepth(){return this._itemDepth}get topItem(){let t=this._stack[this._stack.length-1];if(!t||t.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return t}get topFunctionScope(){return this._stack.findLast(t=>t.type==="functionScope")}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}popItem(){this.pop("item")}pushSlotBindings(t){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(t)})}popSlotBindings(){this.pop("slotBinding")}pushFunctionScope(t,r,n,a){let o={type:"functionScope",args:t,argAliases:r,returnType:n,externalMap:a,reportedReturnTypes:new Set};return this._stack.push(o),o}popFunctionScope(){this.pop("functionScope")}pushBlockScope(){this._stack.push({type:"blockScope",declarations:new Map})}popBlockScope(){this.pop("blockScope")}pop(t){let r=this._stack[this._stack.length-1];if(!r||t&&r.type!==t)throw new Error(`Internal error, expected a ${t} layer to be on top.`);this._stack.pop(),t==="item"&&this._itemDepth--}readSlot(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _54 => _54.type])==="item")n.usedSlots.add(t);else if(_optionalChain([n, 'optionalAccess', _55 => _55.type])==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!(_optionalChain([n, 'optionalAccess', _56 => _56.type])==="functionScope"||_optionalChain([n, 'optionalAccess', _57 => _57.type])==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getSnippetById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _58 => _58.type])==="functionScope"){let a=n.args.find(s=>s.value===t);if(a!==void 0)return a;if(n.argAliases[t])return n.argAliases[t];let o=n.externalMap[t];return o!=null?_chunkZYGTVBDHcjs.q.call(void 0, o):void 0}if(_optionalChain([n, 'optionalAccess', _59 => _59.type])==="blockScope"){let a=n.declarations.get(t);if(a!==void 0)return a}}}defineBlockVariable(t,r){if(r.dataType.type==="unknown")throw Error(`Tried to define variable '${t}' of unknown type`);for(let n=this._stack.length-1;n>=0;--n){let a=this._stack[n];if(_optionalChain([a, 'optionalAccess', _60 => _60.type])==="blockScope"){a.declarations.set(t,r);return}}throw new Error("No block scope found to define a variable in.")}}, _class18),nr=[""," "," "," "," "," "," "," "," "],Wr=nr.length-1,Mr= (_class19 =class{constructor() { _class19.prototype.__init39.call(this); }__init39() {this.identLevel=0}get pre(){return _nullishCoalesce(nr[this.identLevel], () => (nr[Wr].repeat(this.identLevel/Wr)+nr[this.identLevel%Wr]))}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}withResetLevel(t){let r=this.identLevel;this.identLevel=0;try{return t()}finally{this.identLevel=r}}}, _class19),st= (_class20 =class{#e;#r;__init40() {this._indentController=new Mr}__init41() {this._itemStateStack=new kr}#t=[];__init42() {this._declarations=[]}#n=new WeakSet;#a;get varyingLocations(){return this._varyingLocations}__init43() {this[_chunkTRE7NUKEcjs.a]={itemStateStack:this._itemStateStack}}__init44() {this.bindGroupLayoutsToPlaceholderMap=new Map}__init45() {this._nextFreeLayoutPlaceholderIdx=0}__init46() {this.fixedBindings=[]}constructor(t){;_class20.prototype.__init40.call(this);_class20.prototype.__init41.call(this);_class20.prototype.__init42.call(this);_class20.prototype.__init43.call(this);_class20.prototype.__init44.call(this);_class20.prototype.__init45.call(this);_class20.prototype.__init46.call(this);this.enableExtensions=t.enableExtensions,this.#r=_nullishCoalesce(t.shaderGenerator, () => (_chunkZYGTVBDHcjs.jb)),this.#a=t.root?new rr(t.root):new tr,this.#e=t.namespace[_chunkTRE7NUKEcjs.a]}getUniqueName(t){return Zn(this.#e,t)}makeNameValid(t){return this.#e.nameRegistry.makeValid(t)}get pre(){return this._indentController.pre}get topFunctionReturnType(){let t=this._itemStateStack.topFunctionScope;return _chunkTRE7NUKEcjs.ba.call(void 0, t,"Internal error, expected function scope to be present."),t.returnType}get shelllessRepo(){return this.#e.shelllessRepo}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}withResetIndentLevel(t){return this._indentController.withResetLevel(t)}getById(t){let r=this._itemStateStack.getSnippetById(t);return r===void 0?null:r}defineVariable(t,r){this._itemStateStack.defineBlockVariable(t,r)}reportReturnType(t){let r=this._itemStateStack.topFunctionScope;_chunkTRE7NUKEcjs.ba.call(void 0, r,"Internal error, expected function scope to be present."),r.reportedReturnTypes.add(t)}pushBlockScope(){this._itemStateStack.pushBlockScope()}popBlockScope(){this._itemStateStack.popBlockScope()}generateLog(t,r){return this.#a.generateLog(this,t,r)}get logResources(){return this.#a.logResources}fnToWgsl(t){let r=this._itemStateStack.pushFunctionScope(t.args,t.argAliases,t.returnType,t.externalMap);try{this.#r.initGenerator(this);let n=this.#r.functionDefinition(t.body),a=t.returnType;if(!a){let o=[...r.reportedReturnTypes];if(o.length===0)a=_chunkTRE7NUKEcjs.q;else{let s=_chunkTRE7NUKEcjs.Ga.call(void 0, o);s&&!s.hasImplicitConversions&&(a=s.targetType)}if(!a)throw new Error(`Expected function to have a single return type, got [${o.join(", ")}]. Cast explicitly to the desired type.`);a=_chunkZYGTVBDHcjs.o.call(void 0, a)}return{head:vo(this,t.args,a),body:n,returnType:a}}finally{this._itemStateStack.popFunctionScope()}}addDeclaration(t){this._declarations.push(t)}allocateLayoutEntry(t){let r=this.bindGroupLayoutsToPlaceholderMap,n=r.get(t);return n||(n=`#BIND_GROUP_LAYOUT_${this._nextFreeLayoutPlaceholderIdx++}#`,r.set(t,n)),n}allocateFixedEntry(t,r){let n=this.fixedBindings.length;return this.fixedBindings.push({layoutEntry:t,resource:r}),{group:Aa,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new (0, _chunkTRE7NUKEcjs.ea)(t);return r}withSlots(t,r){this._itemStateStack.pushSlotBindings(t);try{return r()}finally{this._itemStateStack.popSlotBindings()}}withVaryingLocations(t,r){this._varyingLocations=t;try{return r()}finally{this._varyingLocations=void 0}}unwrap(t){if(_chunkTRE7NUKEcjs.oa.call(void 0, t))return this.withSlots(t[_chunkTRE7NUKEcjs.d].pairs,()=>this.unwrap(t[_chunkTRE7NUKEcjs.d].inner));let r=t;for(;;)if(_chunkTRE7NUKEcjs.ma.call(void 0, r))r=this.readSlot(r);else if(_chunkTRE7NUKEcjs.na.call(void 0, r))r=this._getOrCompute(r);else break;return r}_getOrCompute(t){let r=_nullishCoalesce(this.#e.memoizedDerived.get(t), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([i,u])=>i.areEqual(this._itemStateStack.readSlot(i),u)))return o.result;this.pushMode(new _chunkTRE7NUKEcjs.qa);let n;try{n=t["~compute"]()}finally{this.popMode("normal")}let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this.#e.memoizedDerived.set(t,r),n}catch(n){throw n instanceof _chunkTRE7NUKEcjs.ca?n.appendToTrace(t):new (0, _chunkTRE7NUKEcjs.ca)(n,[t])}finally{this._itemStateStack.popItem()}}_getOrInstantiate(t){let r=_nullishCoalesce(this.#e.memoizedResolves.get(t), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([i,u])=>i.areEqual(this._itemStateStack.readSlot(i),u)))return o.result;let n;if(_chunkTRE7NUKEcjs.V.call(void 0, t))n=_chunkTRE7NUKEcjs.aa.call(void 0, Pr(this,t),_chunkTRE7NUKEcjs.q);else if(_chunkTRE7NUKEcjs.na.call(void 0, t)||_chunkTRE7NUKEcjs.ma.call(void 0, t))n=this.resolve(this.unwrap(t));else if(_chunkTRE7NUKEcjs.ta.call(void 0, t))n=t[_chunkTRE7NUKEcjs.f](this);else if(_chunkTRE7NUKEcjs.m.call(void 0, t)){let o=this.#e.shelllessRepo.get(t,void 0);if(!o)throw new Error(`Couldn't resolve ${t.name}. Make sure it's a function that accepts no arguments, or call it from another TypeGPU function.`);return this.withResetIndentLevel(()=>this.resolve(o))}else throw new TypeError(`Unresolvable internal value: ${_chunkTRE7NUKEcjs.lb.call(void 0, t)}`);let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this.#e.memoizedResolves.set(t,r),n}catch(n){throw n instanceof _chunkTRE7NUKEcjs.ca?n.appendToTrace(t):new (0, _chunkTRE7NUKEcjs.ca)(n,[t])}finally{this._itemStateStack.popItem()}}resolve(t,r){if(Ke(t)||_chunkTRE7NUKEcjs.m.call(void 0, t)){if(this.#n.has(t)&&!this.#e.memoizedResolves.has(t))throw new Error(`Recursive function ${t} detected. Recursion is not allowed on the GPU.`);this.#n.add(t)}if(_chunkTRE7NUKEcjs.oa.call(void 0, t))return this.withSlots(t[_chunkTRE7NUKEcjs.d].pairs,()=>this.resolve(t[_chunkTRE7NUKEcjs.d].inner,r));if(_chunkTRE7NUKEcjs.h.call(void 0, t)||_chunkTRE7NUKEcjs.m.call(void 0, t)){if(this._itemStateStack.itemDepth===0)try{this.pushMode(new _chunkTRE7NUKEcjs.ra);let n=_chunkTRE7NUKEcjs.za.call(void 0, this,()=>this._getOrInstantiate(t));return _chunkTRE7NUKEcjs.aa.call(void 0, `${[...this._declarations].join(`
|
|
182
182
|
|
|
183
|
-
`)}${
|
|
183
|
+
`)}${n.value}`,_chunkTRE7NUKEcjs.q)}finally{this.popMode("codegen")}return this._getOrInstantiate(t)}if(typeof t=="number"){let n=_nullishCoalesce(r, () => (_chunkZYGTVBDHcjs.n.call(void 0, t).dataType));if(_chunkTRE7NUKEcjs.ba.call(void 0, n.type!=="unknown","Schema has to be known for resolving numbers"),n.type==="abstractInt")return _chunkTRE7NUKEcjs.aa.call(void 0, `${t}`,n);if(n.type==="u32")return _chunkTRE7NUKEcjs.aa.call(void 0, `${t}u`,n);if(n.type==="i32")return _chunkTRE7NUKEcjs.aa.call(void 0, `${t}i`,n);let a=t.toExponential(),o=n.type==="abstractFloat"&&Number.isInteger(t)?`${t}.`:`${t}`,s=a.length<o.length?a:o;return n.type==="f32"?_chunkTRE7NUKEcjs.aa.call(void 0, `${s}f`,n):n.type==="f16"?_chunkTRE7NUKEcjs.aa.call(void 0, `${s}h`,n):_chunkTRE7NUKEcjs.aa.call(void 0, s,n)}if(typeof t=="boolean")return _chunkTRE7NUKEcjs.aa.call(void 0, t?"true":"false",_chunkTRE7NUKEcjs.Qa);if(typeof t=="string")return _chunkTRE7NUKEcjs.aa.call(void 0, t,_chunkTRE7NUKEcjs.q);if(r&&_chunkTRE7NUKEcjs.C.call(void 0, r)){if(!Array.isArray(t))throw new (0, _chunkTRE7NUKEcjs.la)(`Cannot coerce ${t} into value of type '${r}'`);if(r.elementCount!==t.length)throw new (0, _chunkTRE7NUKEcjs.la)(`Cannot create value of type '${r}' from an array of length: ${t.length}`);let n=this.resolve(r.elementType);return _chunkTRE7NUKEcjs.aa.call(void 0, _chunkTRE7NUKEcjs.Ea`array<${n}, ${r.elementCount}>(${t.map(a=>_chunkTRE7NUKEcjs.aa.call(void 0, a,r.elementType))})`,r)}if(Array.isArray(t))return _chunkTRE7NUKEcjs.aa.call(void 0, _chunkTRE7NUKEcjs.Ea`array(${t.map(n=>this.resolve(n))})`,_chunkTRE7NUKEcjs.W);if(r&&_chunkTRE7NUKEcjs.D.call(void 0, r))return _chunkTRE7NUKEcjs.aa.call(void 0, _chunkTRE7NUKEcjs.Ea`${this.resolve(r)}(${Object.entries(r.propTypes).map(([n,a])=>_chunkTRE7NUKEcjs.aa.call(void 0, t[n],a))})`,r);throw new (0, _chunkTRE7NUKEcjs.la)(`Value ${t} (as json: ${_chunkTRE7NUKEcjs.lb.call(void 0, t)}) is not resolvable${r?` to type ${r.type}`:""}`)}pushMode(t){this.#t.push(t)}popMode(t){let r=this.#t.pop();t!==void 0&&_chunkTRE7NUKEcjs.ba.call(void 0, _optionalChain([r, 'optionalAccess', _61 => _61.type])===t,"Unexpected mode")}get mode(){return _nullishCoalesce(this.#t[this.#t.length-1], () => (_chunkTRE7NUKEcjs.Ba))}}, _class20);function me(e,t){let r=new st(t),a=(t.config?r.withSlots(t.config(new Ge([])).bindings,()=>r.resolve(e)):r.resolve(e)).value,o=r.bindGroupLayoutsToPlaceholderMap,s=[],i=new Set([...o.keys()].map(f=>f.index).filter(f=>f!==void 0)),u=ta(i),l=r.fixedBindings.map((f,T)=>[String(T),f.layoutEntry]),m=()=>{let f=u.next().value,T=Zt(Object.fromEntries(l));return s[f]=T,a=a.replaceAll(Aa,String(f)),[f,new Ve(T,Object.fromEntries(r.fixedBindings.map((w,x)=>[String(x),w.resource])))]},y=l.length>0?m():void 0;for(let[f,T]of o.entries()){let w=_nullishCoalesce(f.index, () => (u.next().value));s[w]=f,a=a.replaceAll(T,String(w))}return t.enableExtensions&&t.enableExtensions.length>0&&(a=`${t.enableExtensions.map(T=>`enable ${T};`).join(`
|
|
184
184
|
`)}
|
|
185
185
|
|
|
186
|
-
${a}`),{code:a,usedBindGroupLayouts:s,catchall:c,logResources:r.logResources}}function Uo(t,e,r){let n=e.map(a=>`${a.value}: ${t.resolve(a.dataType).value}`).join(", ");return r.type!=="void"?`(${n}) -> ${_chunk44LAYHPRcjs.qc.call(void 0, r)}${t.resolve(r).value} `:`(${n}) `}function Nr(t){let e=t;return _optionalChain([e, 'optionalAccess', _63 => _63.resourceType])==="compute-pipeline"&&!!e[_chunk44LAYHPRcjs.a]}function qr(t){let e=t;return _optionalChain([e, 'optionalAccess', _64 => _64.resourceType])==="render-pipeline"&&!!e[_chunk44LAYHPRcjs.a]}function Ra(t){return qr(t)||Nr(t)}function jr(t){let{externals:e,shaderGenerator:r,template:n,names:a="random",config:o,enableExtensions:s}=t,i={};_chunkESIHND6Wcjs.a.call(void 0, i,_nullishCoalesce(e, () => ({})));let u={[_chunk44LAYHPRcjs.a]:!0,[_chunk44LAYHPRcjs.f](f){return _chunk44LAYHPRcjs.aa.call(void 0, _chunkESIHND6Wcjs.d.call(void 0, f,i,_nullishCoalesce(n, () => (""))),_chunk44LAYHPRcjs.q)},toString:()=>"<root>"},l=Object.values(e).filter(Ra);if(l.length>1)throw new Error(`Found ${l.length} pipelines but can only resolve one at a time.`);return le(u,{namespace:typeof a=="string"?j({names:a}):a,enableExtensions:s,shaderGenerator:r,config:o,root:_optionalChain([l, 'access', _65 => _65[0], 'optionalAccess', _66 => _66[_chunk44LAYHPRcjs.a], 'access', _67 => _67.branch])})}function La(t){return jr(t).code}function Ca(t){let e=_nullishCoalesce(_chunk44LAYHPRcjs.Aa.call(void 0, ), () => (new st({namespace:j(),shaderGenerator:_chunkHLB6TY7Icjs.hb}))),r=[1,1,1],n=[1,1,1],a=[r[0]*n[0],r[1]*n[1],r[2]*n[2]],o=new Map,s=Array.from({length:r[0]},()=>Array.from({length:r[1]},()=>Array.from({length:r[2]},()=>new Map))),i=Array.from({length:a[0]},()=>Array.from({length:a[1]},()=>Array.from({length:a[2]},()=>new Map))),u=Array.from({length:a[0]},(l,f)=>Array.from({length:a[1]},(c,y)=>Array.from({length:a[2]},(h,v)=>{let x=Math.floor(f/n[0]),P=Math.floor(y/n[1]),F=Math.floor(v/n[2]);return new (0, _chunk44LAYHPRcjs.sa)(o,{private:i[f][y][v],workgroup:s[x][P][F]})})));e.pushMode(u[0][0][0]);try{return{value:_chunk44LAYHPRcjs.za.call(void 0, e,t),buffers:o,privateVars:i,workgroupVars:s}}finally{e.popMode("simulate")}}function Ea(t,e,r,n){return new Qr(t,e,r,n)}function it(t){let e=t;return _optionalChain([e, 'optionalAccess', _68 => _68.resourceType])==="query-set"&&!!e[_chunk44LAYHPRcjs.a]}var Qr= (_class22 =class{constructor(e,r,n,a){;_class22.prototype.__init48.call(this);_class22.prototype.__init49.call(this);_class22.prototype.__init50.call(this);_class22.prototype.__init51.call(this);_class22.prototype.__init52.call(this);_class22.prototype.__init53.call(this);this._group=e;this.type=r;this.count=n;this.rawQuerySet=a;this._ownQuerySet=!a,this._querySet=a||null}__init48() {this.resourceType="query-set"}__init49() {this._querySet=null}__init50() {this._destroyed=!1}__init51() {this._available=!0}__init52() {this._readBuffer=null}__init53() {this._resolveBuffer=null}get querySet(){if(this._destroyed)throw new Error("This QuerySet has been destroyed.");return this.rawQuerySet?this.rawQuerySet:this._querySet?this._querySet:(this._querySet=this._group.device.createQuerySet({type:this.type,count:this.count}),this._querySet)}get destroyed(){return this._destroyed}get available(){return this._available}get[_chunk44LAYHPRcjs.a](){let e=this;return{get readBuffer(){return e._readBuffer||(e._readBuffer=e._group.device.createBuffer({size:e.count*BigUint64Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})),e._readBuffer},get resolveBuffer(){return e._resolveBuffer||(e._resolveBuffer=e._group.device.createBuffer({size:e.count*BigUint64Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC})),e._resolveBuffer}}}$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this,e),this._querySet&&(this._querySet.label=e),this}resolve(){if(this._destroyed)throw new Error("This QuerySet has been destroyed.");if(!this._available)throw new Error("This QuerySet is busy resolving or reading.");let e=this._group.device.createCommandEncoder();e.resolveQuerySet(this.querySet,0,this.count,this[_chunk44LAYHPRcjs.a].resolveBuffer,0),this._group.device.queue.submit([e.finish()])}async read(){if(this._group.flush(),!this._resolveBuffer)throw new Error("QuerySet must be resolved before reading.");this._available=!1;try{let e=this._group.device.createCommandEncoder();e.copyBufferToBuffer(this[_chunk44LAYHPRcjs.a].resolveBuffer,0,this[_chunk44LAYHPRcjs.a].readBuffer,0,this.count*BigUint64Array.BYTES_PER_ELEMENT),this._group.device.queue.submit([e.finish()]),await this._group.device.queue.onSubmittedWorkDone();let r=this[_chunk44LAYHPRcjs.a].readBuffer;await r.mapAsync(GPUMapMode.READ);let n=new BigUint64Array(r.getMappedRange().slice());return r.unmap(),Array.from(n)}finally{this._available=!0}}destroy(){this._destroyed||(this._destroyed=!0,this._querySet&&this._ownQuerySet&&this._querySet.destroy(),_optionalChain([this, 'access', _69 => _69._readBuffer, 'optionalAccess', _70 => _70.destroy, 'call', _71 => _71()]),_optionalChain([this, 'access', _72 => _72._resolveBuffer, 'optionalAccess', _73 => _73.destroy, 'call', _74 => _74()]),this._readBuffer=this._resolveBuffer=null)}}, _class22);var ut= (_class23 =class{constructor(e){;_class23.prototype.__init54.call(this);this._make=e}__init54() {this._map=new WeakMap}getOrMake(e,...r){if(this._map.has(e))return this._map.get(e);let n=this._make(e,...r);return this._map.set(e,n),n}}, _class23);function Fo(t){return t instanceof xe}var xe= (_class24 =class{constructor(e,r){;_class24.prototype.__init55.call(this);this.resourceType=e;this.buffer=r;this[_chunk44LAYHPRcjs.c]=r,this.#e=this.buffer.as(this.resourceType)}__init55() {this[_chunk44LAYHPRcjs.a]=!0}#e;$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this[_chunk44LAYHPRcjs.c],e),this}write(e){this.buffer.write(e)}writePartial(e){this.buffer.writePartial(e)}read(){return this.buffer.read()}get[_chunk44LAYHPRcjs.b](){return this.#e.$}get $(){return this.#e.$}get value(){return this.$}[_chunk44LAYHPRcjs.f](e){return e.resolve(this.#e)}}, _class24);var b=t=>_chunkCODEFPMDcjs.c.call(void 0, _nullishCoalesce(t, () => (0))),Q=t=>_chunkCODEFPMDcjs.d.call(void 0, _nullishCoalesce(t, () => (0))),Ve=t=>_chunkCODEFPMDcjs.e.call(void 0, _nullishCoalesce(t, () => (0))),Po={f32:t=>b(t[0]),f16:t=>Ve(t[0]).x,i32:t=>Q(t[0]),u32:t=>_nullishCoalesce(t[0], () => (0)),bool:t=>!!t[0],vec2f:t=>_chunk44LAYHPRcjs.Ya.call(void 0, b(t[0]),b(t[1])),vec3f:t=>_chunk44LAYHPRcjs.bb.call(void 0, b(t[0]),b(t[1]),b(t[2])),vec4f:t=>_chunk44LAYHPRcjs.gb.call(void 0, b(t[0]),b(t[1]),b(t[2]),b(t[3])),vec2h(t){let e=Ve(t[0]);return _chunk44LAYHPRcjs.Za.call(void 0, e.x,e.y)},vec3h(t){let e=Ve(t[0]),r=Ve(t[1]);return _chunk44LAYHPRcjs.cb.call(void 0, e.x,e.y,r.x)},vec4h(t){let e=Ve(t[0]),r=Ve(t[1]);return _chunk44LAYHPRcjs.hb.call(void 0, e.x,e.y,r.x,r.y)},vec2i:t=>_chunk44LAYHPRcjs._a.call(void 0, Q(t[0]),Q(t[1])),vec3i:t=>_chunk44LAYHPRcjs.db.call(void 0, Q(t[0]),Q(t[1]),Q(t[2])),vec4i:t=>_chunk44LAYHPRcjs.ib.call(void 0, Q(t[0]),Q(t[1]),Q(t[2]),Q(t[3])),vec2u:t=>_chunk44LAYHPRcjs.$a.call(void 0, _nullishCoalesce(t[0], () => (0)),_nullishCoalesce(t[1], () => (0))),vec3u:t=>_chunk44LAYHPRcjs.eb.call(void 0, _nullishCoalesce(t[0], () => (0)),_nullishCoalesce(t[1], () => (0)),_nullishCoalesce(t[2], () => (0))),vec4u:t=>_chunk44LAYHPRcjs.jb.call(void 0, _nullishCoalesce(t[0], () => (0)),_nullishCoalesce(t[1], () => (0)),_nullishCoalesce(t[2], () => (0)),_nullishCoalesce(t[3], () => (0))),"vec2<bool>":t=>_chunk44LAYHPRcjs.ab.call(void 0, !!t[0],!!t[1]),"vec3<bool>":t=>_chunk44LAYHPRcjs.fb.call(void 0, !!t[0],!!t[1],!!t[2]),"vec4<bool>":t=>_chunk44LAYHPRcjs.kb.call(void 0, !!t[0],!!t[1],!!t[2],!!t[3]),mat2x2f:t=>_chunkHLB6TY7Icjs.j.call(void 0, b(t[0]),b(t[1]),b(t[2]),b(t[3])),mat3x3f:t=>_chunkHLB6TY7Icjs.k.call(void 0, b(t[0]),b(t[1]),b(t[2]),b(t[4]),b(t[5]),b(t[6]),b(t[8]),b(t[9]),b(t[10])),mat4x4f:t=>_chunkHLB6TY7Icjs.l.call(void 0, b(t[0]),b(t[1]),b(t[2]),b(t[3]),b(t[4]),b(t[5]),b(t[6]),b(t[7]),b(t[8]),b(t[9]),b(t[10]),b(t[11]),b(t[12]),b(t[13]),b(t[14]),b(t[15]))};function Do(t,e){let r=Po[e.type];if(r)return r(t);if(_chunk44LAYHPRcjs.D.call(void 0, e)){let n=Object.keys(e.propTypes),a=Object.values(e.propTypes),o=Hr(t,a);return Object.fromEntries(n.map((s,i)=>[s,o[i]]))}if(_chunk44LAYHPRcjs.C.call(void 0, e)){let n=e.elementType,a=e.elementCount;return Hr(t,Array.from({length:a},()=>n))}throw new Error(`Cannot deserialize data of type ${e.type}`)}function Hr(t,e){let r=0;return e.map(n=>{if(!_chunk44LAYHPRcjs.B.call(void 0, n))return n;let a=Math.ceil(_chunk44LAYHPRcjs.ic.call(void 0, n)/4),o=Do(t.subarray(r,r+a),n);return r+=a,o})}function Bo(t,e){return Hr(t,e).map(_chunk44LAYHPRcjs.nb).join(" ")}function pt(t){let{indexBuffer:e,dataBuffer:r,logIdToArgTypes:n,options:a}=t;r.read().then(o=>{o.filter(s=>s.id).forEach(({id:s,serializedData:i})=>{let u=n.get(s),l=Bo(new Uint32Array(i),u);console.log(`${a.messagePrefix}${l}`,"background: #936ff5; color: white;","")})}),e.read().then(o=>{o>a.logCountLimit&&console.warn(`Log count limit per dispatch (${a.logCountLimit}) exceeded by ${o-a.logCountLimit} calls. Consider increasing the limit by passing appropriate options to tgpu.init().`)}),r.buffer.clear(),e.buffer.clear()}function ar(t,e,r){if(!r.enabledFeatures.has("timestamp-query"))throw new Error('Performance callback requires the "timestamp-query" feature to be enabled on GPU device.');return t.timestampWrites?{...t,performanceCallback:e}:{...t,performanceCallback:e,hasAutoQuerySet:!0,timestampWrites:{querySet:r.createQuerySet("timestamp",2),beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}}function or(t,e,r){if(!r.enabledFeatures.has("timestamp-query"))throw new Error('Timestamp writes require the "timestamp-query" feature to be enabled on GPU device.');t.hasAutoQuerySet&&t.timestampWrites&&t.timestampWrites.querySet.destroy();let n={querySet:e.querySet};return e.beginningOfPassWriteIndex!==void 0&&(n.beginningOfPassWriteIndex=e.beginningOfPassWriteIndex),e.endOfPassWriteIndex!==void 0&&(n.endOfPassWriteIndex=e.endOfPassWriteIndex),{...t,hasAutoQuerySet:!1,timestampWrites:n}}function sr(t,e){if(!t.timestampWrites)return{};let{querySet:r,beginningOfPassWriteIndex:n,endOfPassWriteIndex:a}=t.timestampWrites,o={querySet:it(r)?e.unwrap(r):r};return n!==void 0&&(o.beginningOfPassWriteIndex=n),a!==void 0&&(o.endOfPassWriteIndex=a),{timestampWrites:o}}function lt({root:t,priors:e}){let r=_optionalChain([e, 'access', _75 => _75.timestampWrites, 'optionalAccess', _76 => _76.querySet]),n=e.performanceCallback;if(!r)throw new Error("Cannot dispatch workgroups with performance callback without a query set.");if(!it(r))throw new Error("Performance callback with raw GPUQuerySet is not supported. Use TgpuQuerySet instead.");t.commandEncoder.resolveQuerySet(t.unwrap(r),0,r.count,r[_chunk44LAYHPRcjs.a].resolveBuffer,0),t.flush(),t.device.queue.onSubmittedWorkDone().then(async()=>{if(!r.available)return;let a=await r.read(),o=a[_nullishCoalesce(_optionalChain([e, 'access', _77 => _77.timestampWrites, 'optionalAccess', _78 => _78.beginningOfPassWriteIndex]), () => (0))],s=a[_nullishCoalesce(_optionalChain([e, 'access', _79 => _79.timestampWrites, 'optionalAccess', _80 => _80.endOfPassWriteIndex]), () => (1))];if(o===void 0||s===void 0)throw new Error("QuerySet did not return valid timestamps.");await n(o,s)})}function Va(t,e,r){return new Kr(new Yr(t,e,r),{})}var Kr= (_class25 =class t{constructor(e,r){;_class25.prototype.__init56.call(this);this._core=e;this._priors=r;this[_chunk44LAYHPRcjs.a]={get rawPipeline(){return e.unwrap().pipeline},get priors(){return r},get branch(){return e.branch}},this[_chunk44LAYHPRcjs.c]=e}__init56() {this.resourceType="compute-pipeline"}[_chunk44LAYHPRcjs.f](e){return e.resolve(this._core)}toString(){return`computePipeline:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get rawPipeline(){return this._core.unwrap().pipeline}with(e,r){return Te(e)?new t(this._core,{...this._priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(this._priors.bindGroupLayoutMap, () => ([])),[e.layout,e]])}):new t(this._core,{...this._priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(this._priors.bindGroupLayoutMap, () => ([])),[e,r]])})}withPerformanceCallback(e){let r=ar(this._priors,e,this._core.branch);return new t(this._core,r)}withTimestampWrites(e){let r=or(this._priors,e,this._core.branch);return new t(this._core,r)}dispatchWorkgroups(e,r,n){let a=this._core.unwrap(),{branch:o}=this._core,s={label:_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this._core), () => ("<unnamed>")),...sr(this._priors,o)},i=o.commandEncoder.beginComputePass(s);i.setPipeline(a.pipeline);let u=new Set(a.usedBindGroupLayouts);if(a.usedBindGroupLayouts.forEach((l,f)=>{if(a.catchall&&f===a.catchall[0])i.setBindGroup(f,o.unwrap(a.catchall[1])),u.delete(l);else{let c=_optionalChain([this, 'access', _81 => _81._priors, 'access', _82 => _82.bindGroupLayoutMap, 'optionalAccess', _83 => _83.get, 'call', _84 => _84(l)]);c!==void 0&&(u.delete(l),i.setBindGroup(f,o.unwrap(c)))}}),u.size>0)throw new (0, _chunk44LAYHPRcjs.ha)(u);i.dispatchWorkgroups(e,r,n),i.end(),a.logResources&&pt(a.logResources),this._priors.performanceCallback&<({root:o,priors:this._priors})}$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this._core,e),this}}, _class25),Yr= (_class26 =class{constructor(e,r,n){;_class26.prototype.__init57.call(this);this.branch=e;this._slotBindings=r;this._entryFn=n}__init57() {this[_chunk44LAYHPRcjs.a]=!0}[_chunk44LAYHPRcjs.f](e){return e.withSlots(this._slotBindings,()=>(e.resolve(this._entryFn),_chunk44LAYHPRcjs.aa.call(void 0, "",_chunk44LAYHPRcjs.q)))}toString(){return"computePipelineCore"}unwrap(){if(this._memo===void 0){let e=this.branch.device,r=_chunkCODEFPMDcjs.i.filter(c=>this.branch.enabledFeatures.has(_chunkCODEFPMDcjs.j[c])),n,a,o=j({names:this.branch.nameRegistrySetting});if(_optionalChain([_chunk44LAYHPRcjs.i, 'optionalAccess', _85 => _85.enabled])){let c=performance.mark("typegpu:resolution:start");n=le(this,{namespace:o,enableExtensions:r,shaderGenerator:this.branch.shaderGenerator,root:this.branch}),a=performance.measure("typegpu:resolution",{start:c.name})}else n=le(this,{namespace:o,enableExtensions:r,shaderGenerator:this.branch.shaderGenerator,root:this.branch});let{code:s,usedBindGroupLayouts:i,catchall:u,logResources:l}=n;u!==void 0&&_optionalChain([i, 'access', _86 => _86[u[0]], 'optionalAccess', _87 => _87.$name, 'call', _88 => _88(`${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let f=e.createShaderModule({label:`${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:s});this._memo={pipeline:e.createComputePipeline({label:_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>")),layout:e.createPipelineLayout({label:`${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:i.map(c=>this.branch.unwrap(c))}),compute:{module:f}}),usedBindGroupLayouts:i,catchall:u,logResources:l},_optionalChain([_chunk44LAYHPRcjs.i, 'optionalAccess', _89 => _89.enabled])&&(async()=>{let c=performance.mark("typegpu:compile-start");await e.queue.onSubmittedWorkDone();let y=performance.measure("typegpu:compiled",{start:c.name});_optionalChain([_chunk44LAYHPRcjs.i, 'optionalAccess', _90 => _90.record, 'call', _91 => _91("resolution",{resolveDuration:_optionalChain([a, 'optionalAccess', _92 => _92.duration]),compileDuration:y.duration,wgslSize:s.length})])})()}return this._memo}}, _class26);function Zr(t,e="vertex"){return new Xr(t,e)}function ur(t){return _optionalChain([t, 'optionalAccess', _93 => _93.resourceType])==="vertex-layout"}var Jr=Symbol("defaultAttribEntry");function ir(t,e,r,n,a){if(_chunk44LAYHPRcjs.L.call(void 0, e)||_chunk44LAYHPRcjs.T.call(void 0, e)){let o=_chunk44LAYHPRcjs.U.call(void 0, e);return o!==void 0&&(n[_nullishCoalesce(a, () => (Jr))]=o),ir(t,e.inner,_chunk44LAYHPRcjs.hc.call(void 0, r,_chunk44LAYHPRcjs.fc.call(void 0, e)),n)}if(_chunk44LAYHPRcjs.D.call(void 0, e)){let o=r,s=e.propTypes;return Object.fromEntries(Object.entries(s).map(([i,u])=>{o=_chunk44LAYHPRcjs.hc.call(void 0, o,_chunk44LAYHPRcjs.ec.call(void 0, u));let l=[i,ir(t,u,o,n,i)];return o+=_chunk44LAYHPRcjs.ic.call(void 0, u),l}))}if(_chunk44LAYHPRcjs.S.call(void 0, e)){let o=r,s=e.propTypes;return Object.fromEntries(Object.entries(s).map(([i,u])=>{o=_chunk44LAYHPRcjs.hc.call(void 0, o,_chunk44LAYHPRcjs.fc.call(void 0, u));let l=[i,ir(t,u,o,n,i)];return o+=_chunk44LAYHPRcjs.ic.call(void 0, u),l}))}if("type"in e&&typeof e.type=="string"){if(_chunk44LAYHPRcjs.o.includes(e.type))return{_layout:t,format:e.type,offset:r};let o=_chunk44LAYHPRcjs.p[e.type];if(o)return{_layout:t,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(e)}`)}var Xr= (_class27 =class{constructor(e,r){;_class27.prototype.__init58.call(this);_class27.prototype.__init59.call(this);_class27.prototype.__init60.call(this);this.schemaForCount=e;this.stepMode=r;let n=e(0);this.stride=_chunk44LAYHPRcjs.hc.call(void 0, _chunk44LAYHPRcjs.ic.call(void 0, n.elementType),_chunk44LAYHPRcjs.ec.call(void 0, n)),this.attrib=ir(this,n.elementType,0,this._customLocationMap)}__init58() {this[_chunk44LAYHPRcjs.a]=!0}__init59() {this.resourceType="vertex-layout"}__init60() {this._customLocationMap={}}get vertexLayout(){if(this._customLocationMap[Jr]!==void 0){if(typeof this.attrib.format!="string"||typeof this.attrib.offset!="number")throw new Error("Single attribute vertex layouts must have a format and offset.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[{format:this.attrib.format,offset:this.attrib.offset,shaderLocation:this._customLocationMap[Jr]}]}}if(!Object.keys(this.attrib).every(r=>this._customLocationMap[r]!==void 0))throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[...Object.entries(this.attrib).map(([r,n])=>({format:n.format,offset:n.offset,shaderLocation:this._customLocationMap[r]}))]}}$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this,e),this}}, _class27);function $o(t){return typeof _optionalChain([t, 'optionalAccess', _94 => _94.loadOp])=="string"}function _a(t,e){if(_chunk44LAYHPRcjs.V.call(void 0, t)){if(!$o(e))throw new Error("Expected a single color attachment, not a record.");return[e]}let r=[];for(let n of Object.keys(t)){let a=t[n];if(_chunk44LAYHPRcjs.pc.call(void 0, a))continue;let o=e[n];if(!o)throw new Error(`A color attachment by the name of '${n}' was not provided to the shader.`);r.push(o)}return r}function Ao(t){return typeof _optionalChain([t, 'optionalAccess', _95 => _95.format])=="string"}function Wa(t,e){if(_chunk44LAYHPRcjs.V.call(void 0, t)){if(_chunk44LAYHPRcjs.M.call(void 0, t))return[];if(!Ao(e))throw new Error("Expected a single color target configuration, not a record.");return[e]}let r=[];for(let n of Object.keys(t)){let a=t[n];if(_chunk44LAYHPRcjs.pc.call(void 0, a))continue;let o=e[n];if(!o)throw new Error(`A color target by the name of '${n}' was not provided to the shader.`);r.push(o)}return r}function rn(t){return new en(new tn(t),{})}var en= (_class28 =class t{__init61() {this.resourceType="render-pipeline"}__init62() {this.hasIndexBuffer=!1}constructor(e,r){;_class28.prototype.__init61.call(this);_class28.prototype.__init62.call(this);this[_chunk44LAYHPRcjs.a]={core:e,priors:r,branch:e.options.branch},this[_chunk44LAYHPRcjs.c]=e}[_chunk44LAYHPRcjs.f](e){return e.resolve(this[_chunk44LAYHPRcjs.a].core)}toString(){return`renderPipeline:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}$name(e){return _chunk44LAYHPRcjs.k.call(void 0, this[_chunk44LAYHPRcjs.a].core,e),this}with(e,r){let n=this[_chunk44LAYHPRcjs.a];if(Te(e))return new t(n.core,{...n.priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(n.priors.bindGroupLayoutMap, () => ([])),[e.layout,e]])});if(er(e))return new t(n.core,{...n.priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(n.priors.bindGroupLayoutMap, () => ([])),[e,r]])});if(ur(e))return new t(n.core,{...n.priors,vertexLayoutMap:new Map([..._nullishCoalesce(n.priors.vertexLayoutMap, () => ([])),[e,r]])});throw new Error("Unsupported value passed into .with()")}withPerformanceCallback(e){let r=this[_chunk44LAYHPRcjs.a],n=ar(r.priors,e,r.core.options.branch);return new t(r.core,n)}withTimestampWrites(e){let r=this[_chunk44LAYHPRcjs.a],n=or(r.priors,e,r.core.options.branch);return new t(r.core,n)}withColorAttachment(e){let r=this[_chunk44LAYHPRcjs.a];return new t(r.core,{...r.priors,colorAttachment:e})}withDepthStencilAttachment(e){let r=this[_chunk44LAYHPRcjs.a];return new t(r.core,{...r.priors,depthStencilAttachment:e})}withIndexBuffer(e,r,n,a){let o=this[_chunk44LAYHPRcjs.a];if(_chunk44LAYHPRcjs.wa.call(void 0, e)){if(typeof r!="string")throw new Error("If a GPUBuffer is passed, indexFormat must be provided.");return new t(o.core,{...o.priors,indexBuffer:{buffer:e,indexFormat:r,offsetBytes:n,sizeBytes:a}})}let s={u32:"uint32",u16:"uint16"},i=e.dataType.elementType;return new t(o.core,{...o.priors,indexBuffer:{buffer:e,indexFormat:s[i.type],offsetBytes:r!==void 0?r*_chunk44LAYHPRcjs.ic.call(void 0, i):void 0,sizeBytes:a!==void 0?a*_chunk44LAYHPRcjs.ic.call(void 0, i):void 0}})}setupRenderPass(){let e=this[_chunk44LAYHPRcjs.a],r=e.core.unwrap(),{branch:n,fragmentFn:a}=e.core.options,o=a?_a(a.shell.out,_nullishCoalesce(e.priors.colorAttachment, () => ({}))).map(c=>ee(c.view)?{...c,view:n.unwrap(c.view).createView()}:c):[null],s={label:_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, e.core), () => ("<unnamed>")),colorAttachments:o,...sr(e.priors,n)};if(e.priors.depthStencilAttachment!==void 0){let c=e.priors.depthStencilAttachment;ee(c.view)?s.depthStencilAttachment={...c,view:n.unwrap(c.view).createView()}:s.depthStencilAttachment=c}let i=n.commandEncoder.beginRenderPass(s);i.setPipeline(r.pipeline);let u=new Set(r.usedBindGroupLayouts);r.usedBindGroupLayouts.forEach((c,y)=>{if(r.catchall&&y===r.catchall[0])i.setBindGroup(y,n.unwrap(r.catchall[1])),u.delete(c);else{let h=_optionalChain([e, 'access', _96 => _96.priors, 'access', _97 => _97.bindGroupLayoutMap, 'optionalAccess', _98 => _98.get, 'call', _99 => _99(c)]);h!==void 0&&(u.delete(c),i.setBindGroup(y,n.unwrap(h)))}});let l=new Set(e.core.usedVertexLayouts);if(e.core.usedVertexLayouts.forEach((c,y)=>{let h=_optionalChain([e, 'access', _100 => _100.priors, 'access', _101 => _101.vertexLayoutMap, 'optionalAccess', _102 => _102.get, 'call', _103 => _103(c)]);h&&(l.delete(c),i.setVertexBuffer(y,n.unwrap(h)))}),u.size>0)throw new (0, _chunk44LAYHPRcjs.ha)(u);if(l.size>0)throw new (0, _chunk44LAYHPRcjs.ia)(l);return i}draw(e,r,n,a){let o=this[_chunk44LAYHPRcjs.a],s=this.setupRenderPass(),{logResources:i}=o.core.unwrap(),{branch:u}=o.core.options;s.draw(e,r,n,a),s.end(),i&&pt(i),o.priors.performanceCallback?lt({root:u,priors:o.priors}):u.flush()}drawIndexed(e,r,n,a,o){let s=this[_chunk44LAYHPRcjs.a];if(!s.priors.indexBuffer)throw new Error("No index buffer set for this render pipeline.");let{buffer:i,indexFormat:u,offsetBytes:l,sizeBytes:f}=s.priors.indexBuffer,c=this.setupRenderPass(),{logResources:y}=s.core.unwrap(),{branch:h}=s.core.options;_chunk44LAYHPRcjs.wa.call(void 0, i)?c.setIndexBuffer(i,u,l,f):c.setIndexBuffer(h.unwrap(i),u,l,f),c.drawIndexed(e,r,n,a,o),c.end(),y&&pt(y),s.priors.performanceCallback?lt({root:h,priors:s.priors}):h.flush()}}, _class28),tn= (_class29 =class{constructor(e){;_class29.prototype.__init63.call(this);this.options=e;let r=aa(_nullishCoalesce(e.vertexFn.shell.in, () => ({})),e.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=e.fragmentFn&&e.targets?Wa(e.fragmentFn.shell.out,e.targets):[null]}__init63() {this[_chunk44LAYHPRcjs.a]=!0}[_chunk44LAYHPRcjs.f](e){let{vertexFn:r,fragmentFn:n,slotBindings:a}=this.options,o=Go(r.shell.out,_optionalChain([n, 'optionalAccess', _104 => _104.shell, 'access', _105 => _105.in]),_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, r), () => ("<unnamed>")),_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, n), () => ("<unnamed>")));return e.withVaryingLocations(o,()=>e.withSlots(a,()=>(e.resolve(r),n&&e.resolve(n),_chunk44LAYHPRcjs.aa.call(void 0, "",_chunk44LAYHPRcjs.q))))}toString(){return"renderPipelineCore"}unwrap(){if(this._memo===void 0){let{branch:e,primitiveState:r,depthStencilState:n,multisampleState:a}=this.options,o=e.device,s=_chunkCODEFPMDcjs.i.filter(F=>e.enabledFeatures.has(_chunkCODEFPMDcjs.j[F])),i,u,l=j({names:e.nameRegistrySetting});if(_optionalChain([_chunk44LAYHPRcjs.i, 'optionalAccess', _106 => _106.enabled])){let F=performance.mark("typegpu:resolution:start");i=le(this,{namespace:l,enableExtensions:s,shaderGenerator:e.shaderGenerator,root:e}),u=performance.measure("typegpu:resolution",{start:F.name})}else i=le(this,{namespace:l,enableExtensions:s,shaderGenerator:e.shaderGenerator,root:e});let{code:f,usedBindGroupLayouts:c,catchall:y,logResources:h}=i;y!==void 0&&_optionalChain([c, 'access', _107 => _107[y[0]], 'optionalAccess', _108 => _108.$name, 'call', _109 => _109(`${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let v=o.createShaderModule({label:`${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:f}),x={layout:o.createPipelineLayout({label:`${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:c.map(F=>e.unwrap(F))}),vertex:{module:v,buffers:this._vertexBufferLayouts}},P=_chunk44LAYHPRcjs.j.call(void 0, this);P!==void 0&&(x.label=P),this.options.fragmentFn&&(x.fragment={module:v,targets:this._targets}),r&&(_chunk44LAYHPRcjs.B.call(void 0, r.stripIndexFormat)?x.primitive={...r,stripIndexFormat:{u32:"uint32",u16:"uint16"}[r.stripIndexFormat.type]}:x.primitive=r),n&&(x.depthStencil=n),a&&(x.multisample=a),this._memo={pipeline:o.createRenderPipeline(x),usedBindGroupLayouts:c,catchall:y,logResources:h},_optionalChain([_chunk44LAYHPRcjs.i, 'optionalAccess', _110 => _110.enabled])&&(async()=>{let F=performance.mark("typegpu:compile-start");await o.queue.onSubmittedWorkDone();let _e=performance.measure("typegpu:compiled",{start:F.name});_optionalChain([_chunk44LAYHPRcjs.i, 'optionalAccess', _111 => _111.record, 'call', _112 => _112("resolution",{resolveDuration:_optionalChain([u, 'optionalAccess', _113 => _113.duration]),compileDuration:_e.duration,wgslSize:f.length})])})()}return this._memo}}, _class29);function Go(t,e,r,n){let a={},o=new Set;function s(u,l){a[u]=l,o.add(l)}for(let[u,l]of Object.entries(t)){let f=_chunk44LAYHPRcjs.U.call(void 0, l);f!==void 0&&s(u,f)}for(let[u,l]of Object.entries(_nullishCoalesce(e, () => ({})))){let f=_chunk44LAYHPRcjs.U.call(void 0, l);f!==void 0&&(a[u]===void 0?s(u,f):a[u]!==f&&console.warn(`Mismatched location between vertexFn (${r}) output (${a[u]}) and fragmentFn (${n}) input (${f}) for the key "${u}", using the location set on vertex output.`))}let i=0;for(let u of Object.keys(_nullishCoalesce(t, () => ({}))))if(!(_chunk44LAYHPRcjs.pc.call(void 0, t[u])||a[u]!==void 0)){for(;o.has(i);)i++;s(u,i)}return a}function Ro(t){if(t.includes(0))throw new Error("Size and workgroupSize cannot contain zeroes.");return _chunk44LAYHPRcjs.eb.call(void 0, _nullishCoalesce(t[0], () => (1)),_nullishCoalesce(t[1], () => (1)),_nullishCoalesce(t[2], () => (1)))}var Lo=[_chunk44LAYHPRcjs.eb.call(void 0, 1,1,1),_chunk44LAYHPRcjs.eb.call(void 0, 256,1,1),_chunk44LAYHPRcjs.eb.call(void 0, 16,16,1),_chunk44LAYHPRcjs.eb.call(void 0, 8,8,4)],nn=class t{#e;#r;#t;#n;#a;constructor(e,r,n,a){this.#e=e,this.#r=r,this.#t=n,this.#n=a,this.#a=_chunk44LAYHPRcjs.eb.call(void 0, )}with(e){return new t(this.#e,this.#r.with(e),this.#t,this.#n)}dispatchThreads(...e){let r=Ro(e),n=_chunkHLB6TY7Icjs.ha.call(void 0, _chunk44LAYHPRcjs.bb.call(void 0, r).div(_chunk44LAYHPRcjs.bb.call(void 0, this.#n)));_chunkCODEFPMDcjs.k.call(void 0, r,this.#a)||(this.#a=r,this.#t.write(r)),this.#r.dispatchWorkgroups(n.x,n.y,n.z),this.#e.flush()}},an=class t{constructor(e,r){this._getRoot=e;this._slotBindings=r}with(e,r){return new t(this._getRoot,[...this._slotBindings,[_chunk44LAYHPRcjs.pa.call(void 0, e)?e.slot:e,r]])}withCompute(e){return new on(this._getRoot(),this._slotBindings,e)}createGuardedComputePipeline(e){let r=this._getRoot();if(e.length>=4)throw new Error("Guarded compute callback only supports up to three dimensions.");let n=Lo[e.length],a=U([_chunk44LAYHPRcjs.Sa,_chunk44LAYHPRcjs.Sa,_chunk44LAYHPRcjs.Sa])(e),o=r.createUniform(_chunk44LAYHPRcjs.eb),s=Et({workgroupSize:n,in:{id:_chunk44LAYHPRcjs.vc.globalInvocationId}})`{
|
|
186
|
+
${a}`),{code:a,usedBindGroupLayouts:s,catchall:y,logResources:r.logResources}}function vo(e,t,r){let n=t.map(a=>`${a.value}: ${e.resolve(a.dataType).value}`).join(", ");return r.type!=="void"?`(${n}) -> ${_chunkTRE7NUKEcjs.pc.call(void 0, r)}${e.resolve(r).value} `:`(${n}) `}function Or(e){let t=e;return _optionalChain([t, 'optionalAccess', _62 => _62.resourceType])==="compute-pipeline"&&!!t[_chunkTRE7NUKEcjs.a]}function zr(e){let t=e;return _optionalChain([t, 'optionalAccess', _63 => _63.resourceType])==="render-pipeline"&&!!t[_chunkTRE7NUKEcjs.a]}function $a(e){return zr(e)||Or(e)}function Nr(e){let{externals:t,shaderGenerator:r,template:n,names:a="random",config:o,enableExtensions:s}=e,i={};_chunk5Y6GTBWRcjs.a.call(void 0, i,_nullishCoalesce(t, () => ({})));let u={[_chunkTRE7NUKEcjs.a]:!0,[_chunkTRE7NUKEcjs.f](m){return _chunkTRE7NUKEcjs.aa.call(void 0, _chunk5Y6GTBWRcjs.d.call(void 0, m,i,_nullishCoalesce(n, () => (""))),_chunkTRE7NUKEcjs.q)},toString:()=>"<root>"},l=Object.values(t).filter($a);if(l.length>1)throw new Error(`Found ${l.length} pipelines but can only resolve one at a time.`);return me(u,{namespace:typeof a=="string"?Q({names:a}):a,enableExtensions:s,shaderGenerator:r,config:o,root:_optionalChain([l, 'access', _64 => _64[0], 'optionalAccess', _65 => _65[_chunkTRE7NUKEcjs.a], 'access', _66 => _66.branch])})}function La(e){return Nr(e).code}function Ra(e){let t=_nullishCoalesce(_chunkTRE7NUKEcjs.Aa.call(void 0, ), () => (new st({namespace:Q(),shaderGenerator:_chunkZYGTVBDHcjs.jb}))),r=[1,1,1],n=[1,1,1],a=[r[0]*n[0],r[1]*n[1],r[2]*n[2]],o=new Map,s=Array.from({length:r[0]},()=>Array.from({length:r[1]},()=>Array.from({length:r[2]},()=>new Map))),i=Array.from({length:a[0]},()=>Array.from({length:a[1]},()=>Array.from({length:a[2]},()=>new Map))),u=Array.from({length:a[0]},(l,m)=>Array.from({length:a[1]},(y,f)=>Array.from({length:a[2]},(T,w)=>{let x=Math.floor(m/n[0]),P=Math.floor(f/n[1]),F=Math.floor(w/n[2]);return new (0, _chunkTRE7NUKEcjs.sa)(o,{private:i[m][f][w],workgroup:s[x][P][F]})})));t.pushMode(u[0][0][0]);try{return{value:_chunkTRE7NUKEcjs.za.call(void 0, t,e),buffers:o,privateVars:i,workgroupVars:s}}finally{t.popMode("simulate")}}function Ga(e,t,r,n){return new qr(e,t,r,n)}function it(e){let t=e;return _optionalChain([t, 'optionalAccess', _67 => _67.resourceType])==="query-set"&&!!t[_chunkTRE7NUKEcjs.a]}var qr= (_class21 =class{constructor(t,r,n,a){;_class21.prototype.__init47.call(this);_class21.prototype.__init48.call(this);_class21.prototype.__init49.call(this);_class21.prototype.__init50.call(this);_class21.prototype.__init51.call(this);_class21.prototype.__init52.call(this);this.type=r;this.count=n;this.rawQuerySet=a;this.#e=t.device,this._ownQuerySet=!a,this._querySet=a||null}__init47() {this.resourceType="query-set"}#e;__init48() {this._querySet=null}__init49() {this._destroyed=!1}__init50() {this._available=!0}__init51() {this._readBuffer=null}__init52() {this._resolveBuffer=null}get querySet(){if(this._destroyed)throw new Error("This QuerySet has been destroyed.");return this.rawQuerySet?this.rawQuerySet:this._querySet?this._querySet:(this._querySet=this.#e.createQuerySet({type:this.type,count:this.count}),this._querySet)}get destroyed(){return this._destroyed}get available(){return this._available}get[_chunkTRE7NUKEcjs.a](){let t=this;return{get readBuffer(){return t._readBuffer||(t._readBuffer=t.#e.createBuffer({size:t.count*BigUint64Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})),t._readBuffer},get resolveBuffer(){return t._resolveBuffer||(t._resolveBuffer=t.#e.createBuffer({size:t.count*BigUint64Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC})),t._resolveBuffer}}}$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this._querySet&&(this._querySet.label=t),this}resolve(){if(this._destroyed)throw new Error("This QuerySet has been destroyed.");if(!this._available)throw new Error("This QuerySet is busy resolving or reading.");let t=this.#e.createCommandEncoder();t.resolveQuerySet(this.querySet,0,this.count,this[_chunkTRE7NUKEcjs.a].resolveBuffer,0),this.#e.queue.submit([t.finish()])}async read(){if(!this._resolveBuffer)throw new Error("QuerySet must be resolved before reading.");this._available=!1;try{let t=this.#e.createCommandEncoder();t.copyBufferToBuffer(this[_chunkTRE7NUKEcjs.a].resolveBuffer,0,this[_chunkTRE7NUKEcjs.a].readBuffer,0,this.count*BigUint64Array.BYTES_PER_ELEMENT),this.#e.queue.submit([t.finish()]);let r=this[_chunkTRE7NUKEcjs.a].readBuffer;await r.mapAsync(GPUMapMode.READ);let n=new BigUint64Array(r.getMappedRange().slice());return r.unmap(),Array.from(n)}finally{this._available=!0}}destroy(){this._destroyed||(this._destroyed=!0,this._querySet&&this._ownQuerySet&&this._querySet.destroy(),_optionalChain([this, 'access', _68 => _68._readBuffer, 'optionalAccess', _69 => _69.destroy, 'call', _70 => _70()]),_optionalChain([this, 'access', _71 => _71._resolveBuffer, 'optionalAccess', _72 => _72.destroy, 'call', _73 => _73()]),this._readBuffer=this._resolveBuffer=null)}}, _class21);var ut= (_class22 =class{constructor(t){;_class22.prototype.__init53.call(this);this._make=t}__init53() {this._map=new WeakMap}getOrMake(t,...r){if(this._map.has(t))return this._map.get(t);let n=this._make(t,...r);return this._map.set(t,n),n}}, _class22);function Io(e){return e instanceof be}var be= (_class23 =class{constructor(t,r){;_class23.prototype.__init54.call(this);this.resourceType=t;this.buffer=r;this[_chunkTRE7NUKEcjs.c]=r,this.#e=this.buffer.as(this.resourceType)}__init54() {this[_chunkTRE7NUKEcjs.a]=!0}#e;$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this[_chunkTRE7NUKEcjs.c],t),this}write(t){this.buffer.write(t)}writePartial(t){this.buffer.writePartial(t)}read(){return this.buffer.read()}get[_chunkTRE7NUKEcjs.b](){return this.#e.$}get $(){return this.#e.$}get value(){return this.$}[_chunkTRE7NUKEcjs.f](t){return t.resolve(this.#e)}}, _class23);var b=e=>_chunk3246CM7Ccjs.c.call(void 0, _nullishCoalesce(e, () => (0))),H=e=>_chunk3246CM7Ccjs.d.call(void 0, _nullishCoalesce(e, () => (0))),We=e=>_chunk3246CM7Ccjs.e.call(void 0, _nullishCoalesce(e, () => (0))),Uo={f32:e=>b(e[0]),f16:e=>We(e[0]).x,i32:e=>H(e[0]),u32:e=>_nullishCoalesce(e[0], () => (0)),bool:e=>!!e[0],vec2f:e=>_chunkTRE7NUKEcjs.Xa.call(void 0, b(e[0]),b(e[1])),vec3f:e=>_chunkTRE7NUKEcjs.ab.call(void 0, b(e[0]),b(e[1]),b(e[2])),vec4f:e=>_chunkTRE7NUKEcjs.fb.call(void 0, b(e[0]),b(e[1]),b(e[2]),b(e[3])),vec2h(e){let t=We(e[0]);return _chunkTRE7NUKEcjs.Ya.call(void 0, t.x,t.y)},vec3h(e){let t=We(e[0]),r=We(e[1]);return _chunkTRE7NUKEcjs.bb.call(void 0, t.x,t.y,r.x)},vec4h(e){let t=We(e[0]),r=We(e[1]);return _chunkTRE7NUKEcjs.gb.call(void 0, t.x,t.y,r.x,r.y)},vec2i:e=>_chunkTRE7NUKEcjs.Za.call(void 0, H(e[0]),H(e[1])),vec3i:e=>_chunkTRE7NUKEcjs.cb.call(void 0, H(e[0]),H(e[1]),H(e[2])),vec4i:e=>_chunkTRE7NUKEcjs.hb.call(void 0, H(e[0]),H(e[1]),H(e[2]),H(e[3])),vec2u:e=>_chunkTRE7NUKEcjs._a.call(void 0, _nullishCoalesce(e[0], () => (0)),_nullishCoalesce(e[1], () => (0))),vec3u:e=>_chunkTRE7NUKEcjs.db.call(void 0, _nullishCoalesce(e[0], () => (0)),_nullishCoalesce(e[1], () => (0)),_nullishCoalesce(e[2], () => (0))),vec4u:e=>_chunkTRE7NUKEcjs.ib.call(void 0, _nullishCoalesce(e[0], () => (0)),_nullishCoalesce(e[1], () => (0)),_nullishCoalesce(e[2], () => (0)),_nullishCoalesce(e[3], () => (0))),"vec2<bool>":e=>_chunkTRE7NUKEcjs.$a.call(void 0, !!e[0],!!e[1]),"vec3<bool>":e=>_chunkTRE7NUKEcjs.eb.call(void 0, !!e[0],!!e[1],!!e[2]),"vec4<bool>":e=>_chunkTRE7NUKEcjs.jb.call(void 0, !!e[0],!!e[1],!!e[2],!!e[3]),mat2x2f:e=>_chunkZYGTVBDHcjs.j.call(void 0, b(e[0]),b(e[1]),b(e[2]),b(e[3])),mat3x3f:e=>_chunkZYGTVBDHcjs.k.call(void 0, b(e[0]),b(e[1]),b(e[2]),b(e[4]),b(e[5]),b(e[6]),b(e[8]),b(e[9]),b(e[10])),mat4x4f:e=>_chunkZYGTVBDHcjs.l.call(void 0, b(e[0]),b(e[1]),b(e[2]),b(e[3]),b(e[4]),b(e[5]),b(e[6]),b(e[7]),b(e[8]),b(e[9]),b(e[10]),b(e[11]),b(e[12]),b(e[13]),b(e[14]),b(e[15]))};function Fo(e,t){let r=Uo[t.type];if(r)return r(e);if(_chunkTRE7NUKEcjs.D.call(void 0, t)){let n=Object.keys(t.propTypes),a=Object.values(t.propTypes),o=jr(e,a);return Object.fromEntries(n.map((s,i)=>[s,o[i]]))}if(_chunkTRE7NUKEcjs.C.call(void 0, t)){let n=t.elementType,a=t.elementCount;return jr(e,Array.from({length:a},()=>n))}throw new Error(`Cannot deserialize data of type ${t.type}`)}function jr(e,t){let r=0;return t.map(n=>{if(!_chunkTRE7NUKEcjs.B.call(void 0, n))return n;let a=Math.ceil(_chunkTRE7NUKEcjs.hc.call(void 0, n)/4),o=Fo(e.subarray(r,r+a),n);return r+=a,o})}function Po(e,t){return jr(e,t).map(_chunkTRE7NUKEcjs.mb)}function pt(e){let{indexBuffer:t,dataBuffer:r,logIdToMeta:n,options:a}=e;r.read().then(o=>{o.filter(s=>s.id).forEach(({id:s,serializedData:i})=>{let{argTypes:u,op:l}=n.get(s),m=Po(new Uint32Array(i),u);m.length===0&&m.push(""),console[l](`%c${a.messagePrefix}%c ${m[0]}`,"background: #936ff5; color: white;","color: inherit; background: none",...m.slice(1))})}),t.read().then(o=>{o>a.logCountLimit&&console.warn(`Log count limit per dispatch (${a.logCountLimit}) exceeded by ${o-a.logCountLimit} calls. Consider increasing the limit by passing appropriate options to tgpu.init().`)}),r.buffer.clear(),t.buffer.clear()}function ar(e,t,r){if(!r.enabledFeatures.has("timestamp-query"))throw new Error('Performance callback requires the "timestamp-query" feature to be enabled on GPU device.');return e.timestampWrites?{...e,performanceCallback:t}:{...e,performanceCallback:t,hasAutoQuerySet:!0,timestampWrites:{querySet:r.createQuerySet("timestamp",2),beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}}function or(e,t,r){if(!r.enabledFeatures.has("timestamp-query"))throw new Error('Timestamp writes require the "timestamp-query" feature to be enabled on GPU device.');e.hasAutoQuerySet&&e.timestampWrites&&e.timestampWrites.querySet.destroy();let n={querySet:t.querySet};return t.beginningOfPassWriteIndex!==void 0&&(n.beginningOfPassWriteIndex=t.beginningOfPassWriteIndex),t.endOfPassWriteIndex!==void 0&&(n.endOfPassWriteIndex=t.endOfPassWriteIndex),{...e,hasAutoQuerySet:!1,timestampWrites:n}}function sr(e,t){if(!e.timestampWrites)return{};let{querySet:r,beginningOfPassWriteIndex:n,endOfPassWriteIndex:a}=e.timestampWrites,o={querySet:it(r)?t.unwrap(r):r};return n!==void 0&&(o.beginningOfPassWriteIndex=n),a!==void 0&&(o.endOfPassWriteIndex=a),{timestampWrites:o}}function lt({root:e,priors:t}){let r=_optionalChain([t, 'access', _74 => _74.timestampWrites, 'optionalAccess', _75 => _75.querySet]),n=t.performanceCallback;if(!r)throw new Error("Cannot dispatch workgroups with performance callback without a query set.");if(!it(r))throw new Error("Performance callback with raw GPUQuerySet is not supported. Use TgpuQuerySet instead.");let a=e.device.createCommandEncoder();a.resolveQuerySet(e.unwrap(r),0,r.count,r[_chunkTRE7NUKEcjs.a].resolveBuffer,0),e.device.queue.submit([a.finish()]),e.device.queue.onSubmittedWorkDone().then(async()=>{if(!r.available)return;let o=await r.read(),s=o[_nullishCoalesce(_optionalChain([t, 'access', _76 => _76.timestampWrites, 'optionalAccess', _77 => _77.beginningOfPassWriteIndex]), () => (0))],i=o[_nullishCoalesce(_optionalChain([t, 'access', _78 => _78.timestampWrites, 'optionalAccess', _79 => _79.endOfPassWriteIndex]), () => (1))];if(s===void 0||i===void 0)throw new Error("QuerySet did not return valid timestamps.");await n(s,i)})}function Ca(e,t,r){return new Qr(new Hr(e,t,r),{})}var Qr= (_class24 =class e{constructor(t,r){;_class24.prototype.__init55.call(this);this._core=t;this._priors=r;this[_chunkTRE7NUKEcjs.a]={get rawPipeline(){return t.unwrap().pipeline},get priors(){return r},get branch(){return t.branch}},this[_chunkTRE7NUKEcjs.c]=t}__init55() {this.resourceType="compute-pipeline"}[_chunkTRE7NUKEcjs.f](t){return t.resolve(this._core)}toString(){return`computePipeline:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get rawPipeline(){return this._core.unwrap().pipeline}with(t,r){return xe(t)?new e(this._core,{...this._priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(this._priors.bindGroupLayoutMap, () => ([])),[t.layout,t]])}):new e(this._core,{...this._priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(this._priors.bindGroupLayoutMap, () => ([])),[t,r]])})}withPerformanceCallback(t){let r=ar(this._priors,t,this._core.branch);return new e(this._core,r)}withTimestampWrites(t){let r=or(this._priors,t,this._core.branch);return new e(this._core,r)}dispatchWorkgroups(t,r,n){let a=this._core.unwrap(),{branch:o}=this._core,s={label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this._core), () => ("<unnamed>")),...sr(this._priors,o)},i=o.device.createCommandEncoder(),u=i.beginComputePass(s);u.setPipeline(a.pipeline);let l=new Set(a.usedBindGroupLayouts);if(a.usedBindGroupLayouts.forEach((m,y)=>{if(a.catchall&&y===a.catchall[0])u.setBindGroup(y,o.unwrap(a.catchall[1])),l.delete(m);else{let f=_optionalChain([this, 'access', _80 => _80._priors, 'access', _81 => _81.bindGroupLayoutMap, 'optionalAccess', _82 => _82.get, 'call', _83 => _83(m)]);f!==void 0&&(l.delete(m),u.setBindGroup(y,o.unwrap(f)))}}),l.size>0)throw new (0, _chunkTRE7NUKEcjs.ha)(l);u.dispatchWorkgroups(t,r,n),u.end(),o.device.queue.submit([i.finish()]),a.logResources&&pt(a.logResources),this._priors.performanceCallback&<({root:o,priors:this._priors})}$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this._core,t),this}}, _class24),Hr= (_class25 =class{constructor(t,r,n){;_class25.prototype.__init56.call(this);this.branch=t;this._slotBindings=r;this._entryFn=n}__init56() {this[_chunkTRE7NUKEcjs.a]=!0}[_chunkTRE7NUKEcjs.f](t){return t.withSlots(this._slotBindings,()=>(t.resolve(this._entryFn),_chunkTRE7NUKEcjs.aa.call(void 0, "",_chunkTRE7NUKEcjs.q)))}toString(){return"computePipelineCore"}unwrap(){if(this._memo===void 0){let t=this.branch.device,r=_chunk3246CM7Ccjs.i.filter(y=>this.branch.enabledFeatures.has(_chunk3246CM7Ccjs.j[y])),n,a,o=Q({names:this.branch.nameRegistrySetting});if(_optionalChain([_chunkTRE7NUKEcjs.i, 'optionalAccess', _84 => _84.enabled])){let y=performance.mark("typegpu:resolution:start");n=me(this,{namespace:o,enableExtensions:r,shaderGenerator:this.branch.shaderGenerator,root:this.branch}),a=performance.measure("typegpu:resolution",{start:y.name})}else n=me(this,{namespace:o,enableExtensions:r,shaderGenerator:this.branch.shaderGenerator,root:this.branch});let{code:s,usedBindGroupLayouts:i,catchall:u,logResources:l}=n;u!==void 0&&_optionalChain([i, 'access', _85 => _85[u[0]], 'optionalAccess', _86 => _86.$name, 'call', _87 => _87(`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let m=t.createShaderModule({label:`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:s});this._memo={pipeline:t.createComputePipeline({label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>")),layout:t.createPipelineLayout({label:`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:i.map(y=>this.branch.unwrap(y))}),compute:{module:m}}),usedBindGroupLayouts:i,catchall:u,logResources:l},_optionalChain([_chunkTRE7NUKEcjs.i, 'optionalAccess', _88 => _88.enabled])&&(async()=>{let y=performance.mark("typegpu:compile-start");await t.queue.onSubmittedWorkDone();let f=performance.measure("typegpu:compiled",{start:y.name});_optionalChain([_chunkTRE7NUKEcjs.i, 'optionalAccess', _89 => _89.record, 'call', _90 => _90("resolution",{resolveDuration:_optionalChain([a, 'optionalAccess', _91 => _91.duration]),compileDuration:f.duration,wgslSize:s.length})])})()}return this._memo}}, _class25);function Jr(e,t="vertex"){return new Yr(e,t)}function ur(e){return _optionalChain([e, 'optionalAccess', _92 => _92.resourceType])==="vertex-layout"}var Kr=Symbol("defaultAttribEntry");function ir(e,t,r,n,a){if(_chunkTRE7NUKEcjs.L.call(void 0, t)||_chunkTRE7NUKEcjs.T.call(void 0, t)){let o=_chunkTRE7NUKEcjs.U.call(void 0, t);return o!==void 0&&(n[_nullishCoalesce(a, () => (Kr))]=o),ir(e,t.inner,_chunkTRE7NUKEcjs.gc.call(void 0, r,_chunkTRE7NUKEcjs.ec.call(void 0, t)),n)}if(_chunkTRE7NUKEcjs.D.call(void 0, t)){let o=r,s=t.propTypes;return Object.fromEntries(Object.entries(s).map(([i,u])=>{o=_chunkTRE7NUKEcjs.gc.call(void 0, o,_chunkTRE7NUKEcjs.dc.call(void 0, u));let l=[i,ir(e,u,o,n,i)];return o+=_chunkTRE7NUKEcjs.hc.call(void 0, u),l}))}if(_chunkTRE7NUKEcjs.S.call(void 0, t)){let o=r,s=t.propTypes;return Object.fromEntries(Object.entries(s).map(([i,u])=>{o=_chunkTRE7NUKEcjs.gc.call(void 0, o,_chunkTRE7NUKEcjs.ec.call(void 0, u));let l=[i,ir(e,u,o,n,i)];return o+=_chunkTRE7NUKEcjs.hc.call(void 0, u),l}))}if("type"in t&&typeof t.type=="string"){if(_chunkTRE7NUKEcjs.o.includes(t.type))return{_layout:e,format:t.type,offset:r};let o=_chunkTRE7NUKEcjs.p[t.type];if(o)return{_layout:e,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(t)}`)}var Yr= (_class26 =class{constructor(t,r){;_class26.prototype.__init57.call(this);_class26.prototype.__init58.call(this);_class26.prototype.__init59.call(this);this.schemaForCount=t;this.stepMode=r;let n=t(0);this.stride=_chunkTRE7NUKEcjs.gc.call(void 0, _chunkTRE7NUKEcjs.hc.call(void 0, n.elementType),_chunkTRE7NUKEcjs.dc.call(void 0, n)),this.attrib=ir(this,n.elementType,0,this._customLocationMap)}__init57() {this[_chunkTRE7NUKEcjs.a]=!0}__init58() {this.resourceType="vertex-layout"}__init59() {this._customLocationMap={}}get vertexLayout(){if(this._customLocationMap[Kr]!==void 0){if(typeof this.attrib.format!="string"||typeof this.attrib.offset!="number")throw new Error("Single attribute vertex layouts must have a format and offset.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[{format:this.attrib.format,offset:this.attrib.offset,shaderLocation:this._customLocationMap[Kr]}]}}if(!Object.keys(this.attrib).every(r=>this._customLocationMap[r]!==void 0))throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[...Object.entries(this.attrib).map(([r,n])=>({format:n.format,offset:n.offset,shaderLocation:this._customLocationMap[r]}))]}}$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this}}, _class26);function Do(e){return typeof _optionalChain([e, 'optionalAccess', _93 => _93.loadOp])=="string"}function Ea(e,t){if(_chunkTRE7NUKEcjs.V.call(void 0, e)){if(!Do(t))throw new Error("Expected a single color attachment, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=e[n];if(_chunkTRE7NUKEcjs.oc.call(void 0, a))continue;let o=t[n];if(!o)throw new Error(`A color attachment by the name of '${n}' was not provided to the shader.`);r.push(o)}return r}function Bo(e){return typeof _optionalChain([e, 'optionalAccess', _94 => _94.format])=="string"}function Va(e,t){if(_chunkTRE7NUKEcjs.V.call(void 0, e)){if(_chunkTRE7NUKEcjs.M.call(void 0, e))return[];if(!Bo(t))throw new Error("Expected a single color target configuration, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=e[n];if(_chunkTRE7NUKEcjs.oc.call(void 0, a))continue;let o=t[n];if(!o)throw new Error(`A color target by the name of '${n}' was not provided to the shader.`);r.push(o)}return r}function en(e){return new Xr(new Zr(e),{})}var Xr= (_class27 =class e{__init60() {this.resourceType="render-pipeline"}__init61() {this.hasIndexBuffer=!1}constructor(t,r){;_class27.prototype.__init60.call(this);_class27.prototype.__init61.call(this);this[_chunkTRE7NUKEcjs.a]={core:t,priors:r,branch:t.options.branch},this[_chunkTRE7NUKEcjs.c]=t}[_chunkTRE7NUKEcjs.f](t){return t.resolve(this[_chunkTRE7NUKEcjs.a].core)}toString(){return`renderPipeline:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this[_chunkTRE7NUKEcjs.a].core,t),this}with(t,r){let n=this[_chunkTRE7NUKEcjs.a];if(xe(t))return new e(n.core,{...n.priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(n.priors.bindGroupLayoutMap, () => ([])),[t.layout,t]])});if(er(t))return new e(n.core,{...n.priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(n.priors.bindGroupLayoutMap, () => ([])),[t,r]])});if(ur(t))return new e(n.core,{...n.priors,vertexLayoutMap:new Map([..._nullishCoalesce(n.priors.vertexLayoutMap, () => ([])),[t,r]])});throw new Error("Unsupported value passed into .with()")}withPerformanceCallback(t){let r=this[_chunkTRE7NUKEcjs.a],n=ar(r.priors,t,r.core.options.branch);return new e(r.core,n)}withTimestampWrites(t){let r=this[_chunkTRE7NUKEcjs.a],n=or(r.priors,t,r.core.options.branch);return new e(r.core,n)}withColorAttachment(t){let r=this[_chunkTRE7NUKEcjs.a];return new e(r.core,{...r.priors,colorAttachment:t})}withDepthStencilAttachment(t){let r=this[_chunkTRE7NUKEcjs.a];return new e(r.core,{...r.priors,depthStencilAttachment:t})}withIndexBuffer(t,r,n,a){let o=this[_chunkTRE7NUKEcjs.a];if(_chunkTRE7NUKEcjs.wa.call(void 0, t)){if(typeof r!="string")throw new Error("If a GPUBuffer is passed, indexFormat must be provided.");return new e(o.core,{...o.priors,indexBuffer:{buffer:t,indexFormat:r,offsetBytes:n,sizeBytes:a}})}let s={u32:"uint32",u16:"uint16"},i=t.dataType.elementType;return new e(o.core,{...o.priors,indexBuffer:{buffer:t,indexFormat:s[i.type],offsetBytes:r!==void 0?r*_chunkTRE7NUKEcjs.hc.call(void 0, i):void 0,sizeBytes:a!==void 0?a*_chunkTRE7NUKEcjs.hc.call(void 0, i):void 0}})}setupRenderPass(t){let r=this[_chunkTRE7NUKEcjs.a],n=r.core.unwrap(),{branch:a,fragmentFn:o}=r.core.options,s=o?Ea(o.shell.out,_nullishCoalesce(r.priors.colorAttachment, () => ({}))).map(f=>ee(f.view)?{...f,view:a.unwrap(f.view).createView()}:he(f.view)?{...f,view:a.unwrap(f.view)}:f):[null],i={label:_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, r.core), () => ("<unnamed>")),colorAttachments:s,...sr(r.priors,a)};if(r.priors.depthStencilAttachment!==void 0){let f=r.priors.depthStencilAttachment;ee(f.view)?i.depthStencilAttachment={...f,view:a.unwrap(f.view).createView()}:i.depthStencilAttachment=f}let u=t.beginRenderPass(i);u.setPipeline(n.pipeline);let l=new Set(n.usedBindGroupLayouts);n.usedBindGroupLayouts.forEach((f,T)=>{if(n.catchall&&T===n.catchall[0])u.setBindGroup(T,a.unwrap(n.catchall[1])),l.delete(f);else{let w=_optionalChain([r, 'access', _95 => _95.priors, 'access', _96 => _96.bindGroupLayoutMap, 'optionalAccess', _97 => _97.get, 'call', _98 => _98(f)]);w!==void 0&&(l.delete(f),u.setBindGroup(T,a.unwrap(w)))}});let m=new Set(r.core.usedVertexLayouts);if(r.core.usedVertexLayouts.forEach((f,T)=>{let w=_optionalChain([r, 'access', _99 => _99.priors, 'access', _100 => _100.vertexLayoutMap, 'optionalAccess', _101 => _101.get, 'call', _102 => _102(f)]);w&&(m.delete(f),u.setVertexBuffer(T,a.unwrap(w)))}),l.size>0)throw new (0, _chunkTRE7NUKEcjs.ha)(l);if(m.size>0)throw new (0, _chunkTRE7NUKEcjs.ia)(m);return u}draw(t,r,n,a){let o=this[_chunkTRE7NUKEcjs.a],{branch:s}=o.core.options,{logResources:i}=o.core.unwrap(),u=s.device.createCommandEncoder(),l=this.setupRenderPass(u);l.draw(t,r,n,a),l.end(),s.device.queue.submit([u.finish()]),i&&pt(i),o.priors.performanceCallback&<({root:s,priors:o.priors})}drawIndexed(t,r,n,a,o){let s=this[_chunkTRE7NUKEcjs.a];if(!s.priors.indexBuffer)throw new Error("No index buffer set for this render pipeline.");let{logResources:i}=s.core.unwrap(),{branch:u}=s.core.options,{buffer:l,indexFormat:m,offsetBytes:y,sizeBytes:f}=s.priors.indexBuffer,T=u.device.createCommandEncoder(),w=this.setupRenderPass(T);_chunkTRE7NUKEcjs.wa.call(void 0, l)?w.setIndexBuffer(l,m,y,f):w.setIndexBuffer(u.unwrap(l),m,y,f),w.drawIndexed(t,r,n,a,o),w.end(),u.device.queue.submit([T.finish()]),i&&pt(i),s.priors.performanceCallback&<({root:u,priors:s.priors})}}, _class27),Zr= (_class28 =class{constructor(t){;_class28.prototype.__init62.call(this);this.options=t;let r=ea(_nullishCoalesce(t.vertexFn.shell.in, () => ({})),t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=t.fragmentFn&&t.targets?Va(t.fragmentFn.shell.out,t.targets):[null]}__init62() {this[_chunkTRE7NUKEcjs.a]=!0}[_chunkTRE7NUKEcjs.f](t){let{vertexFn:r,fragmentFn:n,slotBindings:a}=this.options,o=Ao(r.shell.out,_optionalChain([n, 'optionalAccess', _103 => _103.shell, 'access', _104 => _104.in]),_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, r), () => ("<unnamed>")),_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, n), () => ("<unnamed>")));return t.withVaryingLocations(o,()=>t.withSlots(a,()=>(t.resolve(r),n&&t.resolve(n),_chunkTRE7NUKEcjs.aa.call(void 0, "",_chunkTRE7NUKEcjs.q))))}toString(){return"renderPipelineCore"}unwrap(){if(this._memo===void 0){let{branch:t,primitiveState:r,depthStencilState:n,multisampleState:a}=this.options,o=t.device,s=_chunk3246CM7Ccjs.i.filter(F=>t.enabledFeatures.has(_chunk3246CM7Ccjs.j[F])),i,u,l=Q({names:t.nameRegistrySetting});if(_optionalChain([_chunkTRE7NUKEcjs.i, 'optionalAccess', _105 => _105.enabled])){let F=performance.mark("typegpu:resolution:start");i=me(this,{namespace:l,enableExtensions:s,shaderGenerator:t.shaderGenerator,root:t}),u=performance.measure("typegpu:resolution",{start:F.name})}else i=me(this,{namespace:l,enableExtensions:s,shaderGenerator:t.shaderGenerator,root:t});let{code:m,usedBindGroupLayouts:y,catchall:f,logResources:T}=i;f!==void 0&&_optionalChain([y, 'access', _106 => _106[f[0]], 'optionalAccess', _107 => _107.$name, 'call', _108 => _108(`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let w=o.createShaderModule({label:`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:m}),x={layout:o.createPipelineLayout({label:`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:y.map(F=>t.unwrap(F))}),vertex:{module:w,buffers:this._vertexBufferLayouts}},P=_chunkTRE7NUKEcjs.j.call(void 0, this);P!==void 0&&(x.label=P),this.options.fragmentFn&&(x.fragment={module:w,targets:this._targets}),r&&(_chunkTRE7NUKEcjs.B.call(void 0, r.stripIndexFormat)?x.primitive={...r,stripIndexFormat:{u32:"uint32",u16:"uint16"}[r.stripIndexFormat.type]}:x.primitive=r),n&&(x.depthStencil=n),a&&(x.multisample=a),this._memo={pipeline:o.createRenderPipeline(x),usedBindGroupLayouts:y,catchall:f,logResources:T},_optionalChain([_chunkTRE7NUKEcjs.i, 'optionalAccess', _109 => _109.enabled])&&(async()=>{let F=performance.mark("typegpu:compile-start");await o.queue.onSubmittedWorkDone();let R=performance.measure("typegpu:compiled",{start:F.name});_optionalChain([_chunkTRE7NUKEcjs.i, 'optionalAccess', _110 => _110.record, 'call', _111 => _111("resolution",{resolveDuration:_optionalChain([u, 'optionalAccess', _112 => _112.duration]),compileDuration:R.duration,wgslSize:m.length})])})()}return this._memo}}, _class28);function Ao(e,t,r,n){let a={},o=new Set;function s(u,l){a[u]=l,o.add(l)}for(let[u,l]of Object.entries(e)){let m=_chunkTRE7NUKEcjs.U.call(void 0, l);m!==void 0&&s(u,m)}for(let[u,l]of Object.entries(_nullishCoalesce(t, () => ({})))){let m=_chunkTRE7NUKEcjs.U.call(void 0, l);m!==void 0&&(a[u]===void 0?s(u,m):a[u]!==m&&console.warn(`Mismatched location between vertexFn (${r}) output (${a[u]}) and fragmentFn (${n}) input (${m}) for the key "${u}", using the location set on vertex output.`))}let i=0;for(let u of Object.keys(_nullishCoalesce(e, () => ({}))))if(!(_chunkTRE7NUKEcjs.oc.call(void 0, e[u])||a[u]!==void 0)){for(;o.has(i);)i++;s(u,i)}return a}function $o(e){if(e.includes(0))throw new Error("Size and workgroupSize cannot contain zeroes.");return _chunkTRE7NUKEcjs.db.call(void 0, _nullishCoalesce(e[0], () => (1)),_nullishCoalesce(e[1], () => (1)),_nullishCoalesce(e[2], () => (1)))}var Lo=[_chunkTRE7NUKEcjs.db.call(void 0, 1,1,1),_chunkTRE7NUKEcjs.db.call(void 0, 256,1,1),_chunkTRE7NUKEcjs.db.call(void 0, 16,16,1),_chunkTRE7NUKEcjs.db.call(void 0, 8,8,4)],tn=class e{#e;#r;#t;#n;#a;constructor(t,r,n,a){this.#e=t,this.#r=r,this.#t=n,this.#n=a,this.#a=_chunkTRE7NUKEcjs.db.call(void 0, )}with(t){return new e(this.#e,this.#r.with(t),this.#t,this.#n)}dispatchThreads(...t){let r=$o(t),n=_chunkZYGTVBDHcjs.ja.call(void 0, _chunkTRE7NUKEcjs.ab.call(void 0, r).div(_chunkTRE7NUKEcjs.ab.call(void 0, this.#n)));_chunk3246CM7Ccjs.k.call(void 0, r,this.#a)||(this.#a=r,this.#t.write(r)),this.#r.dispatchWorkgroups(n.x,n.y,n.z)}},rn=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[_chunkTRE7NUKEcjs.pa.call(void 0, t)?t.slot:t,r]])}withCompute(t){return new nn(this._getRoot(),this._slotBindings,t)}createGuardedComputePipeline(t){let r=this._getRoot();if(t.length>=4)throw new Error("Guarded compute callback only supports up to three dimensions.");let n=Lo[t.length],a=U([_chunkTRE7NUKEcjs.Ra,_chunkTRE7NUKEcjs.Ra,_chunkTRE7NUKEcjs.Ra])(t),o=r.createUniform(_chunkTRE7NUKEcjs.db),s=Et({workgroupSize:n,in:{id:_chunkTRE7NUKEcjs.uc.globalInvocationId}})`{
|
|
187
187
|
if (any(in.id >= sizeUniform)) {
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
190
|
wrappedCallback(in.id.x, in.id.y, in.id.z);
|
|
191
|
-
}`.$uses({sizeUniform:o,wrappedCallback:a}),i=this.withCompute(s).createPipeline();return new nn(r,i,o,n)}withVertex(e,r){return new sn({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:e,vertexAttribs:r,multisampleState:void 0})}pipe(e){let r=e(new Ge([]));return new t(this._getRoot,[...this._slotBindings,...r.bindings])}},on=class{constructor(e,r,n){this._root=e;this._slotBindings=r;this._entryFn=n}createPipeline(){return Va(this._root,this._slotBindings,this._entryFn)}},sn=class t{constructor(e){this._options=e}withFragment(e,r,n){return _chunk44LAYHPRcjs.ba.call(void 0, typeof e!="string","Just type mismatch validation"),_chunk44LAYHPRcjs.ba.call(void 0, typeof r!="string","Just type mismatch validation"),new un({...this._options,fragmentFn:e,targets:r})}withPrimitive(e){return new t({...this._options,primitiveState:e})}withDepthStencil(e){return new t({...this._options,depthStencilState:e})}withMultisample(e){return new t({...this._options,multisampleState:e})}createPipeline(){return rn({...this._options,fragmentFn:null,targets:null})}},un=class t{constructor(e){this._options=e}withPrimitive(e){return new t({...this._options,primitiveState:e})}withDepthStencil(e){return new t({...this._options,depthStencilState:e})}withMultisample(e){return new t({...this._options,multisampleState:e})}createPipeline(){return rn(this._options)}},pr= (_class30 =class extends an{constructor(r,n,a,o,s){super(()=>this,[]);_class30.prototype.__init64.call(this);_class30.prototype.__init65.call(this);_class30.prototype.__init66.call(this);;this.device=r;this.nameRegistrySetting=n;this._ownDevice=a;this.shaderGenerator=s;this["~unstable"]=this,this[_chunk44LAYHPRcjs.a]={logOptions:o}}__init64() {this._unwrappedBindGroupLayouts=new ut(r=>r.unwrap(this))}__init65() {this._unwrappedBindGroups=new ut(r=>r.unwrap(this))}__init66() {this._commandEncoder=null}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}get enabledFeatures(){return new Set(this.device.features)}createBuffer(r,n){return Ze(this,r,n)}createUniform(r,n){let a=Ze(this,r,n).$usage("uniform");return new xe("uniform",a)}createMutable(r,n){let a=Ze(this,r,n).$usage("storage");return new xe("mutable",a)}createReadonly(r,n){let a=Ze(this,r,n).$usage("storage");return new xe("readonly",a)}createQuerySet(r,n,a){return Ea(this,r,n,a)}createBindGroup(r,n){return new Ce(r,n)}destroy(){xa(this.device),this._ownDevice&&this.device.destroy()}createTexture(r){return Sa(r,this)}createSampler(r){return ya(r,this)}createComparisonSampler(r){return Ta(r,this)}unwrap(r){if(Nr(r))return r[_chunk44LAYHPRcjs.a].rawPipeline;if(qr(r))return r[_chunk44LAYHPRcjs.a].core.unwrap().pipeline;if(er(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(Te(r))return this._unwrappedBindGroups.getOrMake(r);if(pe(r))return r.buffer;if(ee(r))return r[_chunk44LAYHPRcjs.a].unwrap();if(nt(r)){if(!r[_chunk44LAYHPRcjs.a].unwrap)throw new Error("Cannot unwrap laid-out texture view as it has no underlying resource.");return r[_chunk44LAYHPRcjs.a].unwrap()}if(ur(r))return r.vertexLayout;if(et(r)||tt(r)){if(r[_chunk44LAYHPRcjs.a].unwrap)return r[_chunk44LAYHPRcjs.a].unwrap();throw new Error("Cannot unwrap laid-out sampler.")}if(it(r))return r.querySet;throw new Error(`Unknown resource type: ${r}`)}beginRenderPass(r,n){let a=this.commandEncoder.beginRenderPass(r),o=new Map,s=new Map,i,u=()=>{if(!i)throw new Error("Cannot draw without a call to pass.setPipeline");let{core:l,priors:f}=i[_chunk44LAYHPRcjs.a],c=l.unwrap();a.setPipeline(c.pipeline);let y=new Set(c.usedBindGroupLayouts);c.usedBindGroupLayouts.forEach((v,x)=>{if(c.catchall&&x===c.catchall[0])a.setBindGroup(x,this.unwrap(c.catchall[1])),y.delete(v);else{let P=_nullishCoalesce(_optionalChain([f, 'access', _114 => _114.bindGroupLayoutMap, 'optionalAccess', _115 => _115.get, 'call', _116 => _116(v)]), () => (o.get(v)));P!==void 0&&(y.delete(v),Te(P)?a.setBindGroup(x,this.unwrap(P)):a.setBindGroup(x,P))}});let h=new Set;if(l.usedVertexLayouts.forEach((v,x)=>{let P=_optionalChain([f, 'access', _117 => _117.vertexLayoutMap, 'optionalAccess', _118 => _118.get, 'call', _119 => _119(v)]),F=P?{buffer:P,offset:void 0,size:void 0}:s.get(v);!F||!F.buffer?h.add(v):pe(F.buffer)?a.setVertexBuffer(x,this.unwrap(F.buffer),F.offset,F.size):a.setVertexBuffer(x,F.buffer,F.offset,F.size)}),y.size>0)throw new (0, _chunk44LAYHPRcjs.ha)(y);if(h.size>0)throw new (0, _chunk44LAYHPRcjs.ia)(h)};n({setViewport(...l){a.setViewport(...l)},setScissorRect(...l){a.setScissorRect(...l)},setBlendConstant(...l){a.setBlendConstant(...l)},setStencilReference(...l){a.setStencilReference(...l)},beginOcclusionQuery(...l){a.beginOcclusionQuery(...l)},endOcclusionQuery(...l){a.endOcclusionQuery(...l)},executeBundles(...l){a.executeBundles(...l)},setPipeline(l){i=l},setIndexBuffer:(l,f,c,y)=>{pe(l)?a.setIndexBuffer(this.unwrap(l),f,c,y):a.setIndexBuffer(l,f,c,y)},setVertexBuffer(l,f,c,y){s.set(l,{buffer:f,offset:c,size:y})},setBindGroup(l,f){o.set(l,f)},draw(l,f,c,y){u(),a.draw(l,f,c,y)},drawIndexed(...l){u(),a.drawIndexed(...l)},drawIndirect(...l){u(),a.drawIndirect(...l)},drawIndexedIndirect(...l){u(),a.drawIndexedIndirect(...l)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}}, _class30);async function ka(t){let{adapter:e,device:r,unstable_names:n="random",unstable_logOptions:a}=_nullishCoalesce(t, () => ({}));if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let o=await navigator.gpu.requestAdapter(e);if(!o)throw new Error("Could not find a compatible GPU");let s=[];for(let u of _nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.requiredFeatures]), () => ([]))){if(!o.features.has(u))throw new Error(`Requested feature "${u}" is not supported by the adapter.`);s.push(u)}for(let u of _nullishCoalesce(_optionalChain([r, 'optionalAccess', _121 => _121.optionalFeatures]), () => ([])))o.features.has(u)?s.push(u):console.warn(`Optional feature "${u}" is not supported by the adapter.`);let i=await o.requestDevice({...r,requiredFeatures:s});return new pr(i,n,!0,_nullishCoalesce(a, () => ({})),_optionalChain([t, 'optionalAccess', _122 => _122.shaderGenerator]))}function Oa(t){let{device:e,unstable_names:r="random",unstable_logOptions:n}=_nullishCoalesce(t, () => ({}));return new pr(e,r,!1,_nullishCoalesce(n, () => ({})),_optionalChain([t, 'optionalAccess', _123 => _123.shaderGenerator]))}function Ma(t,e){return new pn(t,e)}var pn= (_class31 =class{constructor(e,r=void 0){;_class31.prototype.__init67.call(this);_class31.prototype.__init68.call(this);this.schema=e;this.defaultValue=r;this.slot=he(r),this[_chunk44LAYHPRcjs.c]=this.slot}__init67() {this[_chunk44LAYHPRcjs.a]=!0}__init68() {this.resourceType="accessor"}get[_chunk44LAYHPRcjs.b](){return new Proxy({[_chunk44LAYHPRcjs.a]:!0,[_chunk44LAYHPRcjs.e]:this.#e(),[_chunk44LAYHPRcjs.f]:e=>e.resolve(this),toString:()=>`accessor:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},R)}#e(){let e=_chunk44LAYHPRcjs.Aa.call(void 0, ),r=ge(e.unwrap(this.slot));return He(r)?r[_chunk44LAYHPRcjs.a].gpuImpl():_chunk44LAYHPRcjs.aa.call(void 0, r,this.schema)}$name(e){return this.slot.$name(e),this}toString(){return`accessor:${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get value(){if(_chunk44LAYHPRcjs.Da.call(void 0, ))return this[_chunk44LAYHPRcjs.b];throw new Error("`tgpu.accessor` relies on GPU resources and cannot be accessed outside of a compute dispatch or draw call")}get $(){return this.value}[_chunk44LAYHPRcjs.f](e){let r=this.#e();return _chunk44LAYHPRcjs.aa.call(void 0, e.resolve(r.value,r.dataType).value,r.dataType)}}, _class31);function za(t){return Eo(t)}function Co([t,e]){return`${_nullishCoalesce(_chunk44LAYHPRcjs.j.call(void 0, t), () => ("<unnamed>"))}=${e}`}function Eo(t){if(_chunk44LAYHPRcjs.Aa.call(void 0, ))throw new Error("Cannot create tgpu.derived objects at the resolution stage.");return{[_chunk44LAYHPRcjs.a]:!0,resourceType:"derived","~compute":t,get[_chunk44LAYHPRcjs.b](){let r=_chunk44LAYHPRcjs.Aa.call(void 0, );if(!r)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return ge(r.unwrap(this))},get value(){return this[_chunk44LAYHPRcjs.b]},get $(){return this.value},with(r,n){return Na(this,[[r,n]])},toString(){return"derived"}}}function Na(t,e){return{[_chunk44LAYHPRcjs.a]:!0,resourceType:"derived","~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},[_chunk44LAYHPRcjs.d]:{inner:t,pairs:e},get[_chunk44LAYHPRcjs.b](){let n=_chunk44LAYHPRcjs.Aa.call(void 0, );if(!n)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return ge(n.unwrap(this))},get value(){return this[_chunk44LAYHPRcjs.b]},get $(){return this.value},with(n,a){return Na(t,[...e,[n,a]])},toString(){return`derived[${e.map(Co).join(", ")}]`}}}var Vo={fn:U,bindGroupLayout:Zt,vertexLayout:Zr,slot:he,init:ka,initFromDevice:Oa,resolve:La,resolveWithContext:jr,privateVar:Ee,workgroupVar:kr,const:Ir,"~unstable":{fn:U,fragmentFn:ea,vertexFn:_chunkESIHND6Wcjs.h,computeFn:Et,vertexLayout:Zr,namespace:j,derived:za,slot:he,accessor:Ma,privateVar:Ee,workgroupVar:kr,const:Ir,declare:Xn,simulate:Ca}},Cf= exports.default =Vo;exports.MissingBindGroupsError = _chunk44LAYHPRcjs.ha; exports.MissingLinksError = _chunk44LAYHPRcjs.ga; exports.MissingSlotValueError = _chunk44LAYHPRcjs.ea; exports.MissingVertexBuffersError = _chunk44LAYHPRcjs.ia; exports.NotUniformError = _chunk44LAYHPRcjs.fa; exports.ResolutionError = _chunk44LAYHPRcjs.ca; exports.default = Cf; exports.isBuffer = pe; exports.isBufferShorthand = Fo; exports.isComparisonSampler = tt; exports.isDerived = _chunk44LAYHPRcjs.na; exports.isSampler = et; exports.isSlot = _chunk44LAYHPRcjs.ma; exports.isTexture = ee; exports.isTgpuFn = He; exports.isUsableAsRender = wo; exports.isUsableAsSampled = Er; exports.isUsableAsStorage = ye; exports.isUsableAsUniform = jt; exports.isUsableAsVertex = co; exports.isVariable = So; exports.tgpu = Vo;
|
|
191
|
+
}`.$uses({sizeUniform:o,wrappedCallback:a}),i=this.withCompute(s).createPipeline();return new tn(r,i,o,n)}withVertex(t,r){return new an({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r,multisampleState:void 0})}pipe(t){let r=t(new Ge([]));return new e(this._getRoot,[...this._slotBindings,...r.bindings])}},nn=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return Ca(this._root,this._slotBindings,this._entryFn)}},an=class e{constructor(t){this._options=t}withFragment(t,r,n){return _chunkTRE7NUKEcjs.ba.call(void 0, typeof t!="string","Just type mismatch validation"),_chunkTRE7NUKEcjs.ba.call(void 0, typeof r!="string","Just type mismatch validation"),new on({...this._options,fragmentFn:t,targets:r})}withPrimitive(t){return new e({...this._options,primitiveState:t})}withDepthStencil(t){return new e({...this._options,depthStencilState:t})}withMultisample(t){return new e({...this._options,multisampleState:t})}createPipeline(){return en({...this._options,fragmentFn:null,targets:null})}},on=class e{constructor(t){this._options=t}withPrimitive(t){return new e({...this._options,primitiveState:t})}withDepthStencil(t){return new e({...this._options,depthStencilState:t})}withMultisample(t){return new e({...this._options,multisampleState:t})}createPipeline(){return en(this._options)}},pr= (_class29 =class extends rn{constructor(r,n,a,o,s){super(()=>this,[]);_class29.prototype.__init63.call(this);_class29.prototype.__init64.call(this);;this.device=r;this.nameRegistrySetting=n;this._ownDevice=a;this.shaderGenerator=s;this["~unstable"]=this,this[_chunkTRE7NUKEcjs.a]={logOptions:o}}__init63() {this._unwrappedBindGroupLayouts=new ut(r=>r.unwrap(this))}__init64() {this._unwrappedBindGroups=new ut(r=>r.unwrap(this))}get enabledFeatures(){return new Set(this.device.features)}createBuffer(r,n){return et(this,r,n)}createUniform(r,n){let a=et(this,r,n).$usage("uniform");return new be("uniform",a)}createMutable(r,n){let a=et(this,r,n).$usage("storage");return new be("mutable",a)}createReadonly(r,n){let a=et(this,r,n).$usage("storage");return new be("readonly",a)}createQuerySet(r,n,a){return Ga(this,r,n,a)}createBindGroup(r,n){return new Ve(r,n)}destroy(){ga(this.device),this._ownDevice&&this.device.destroy()}createTexture(r){return ha(r,this)}createSampler(r){return fa(r,this)}createComparisonSampler(r){return da(r,this)}unwrap(r){if(Or(r))return r[_chunkTRE7NUKEcjs.a].rawPipeline;if(zr(r))return r[_chunkTRE7NUKEcjs.a].core.unwrap().pipeline;if(er(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(xe(r))return this._unwrappedBindGroups.getOrMake(r);if(le(r))return r.buffer;if(ee(r))return r[_chunkTRE7NUKEcjs.a].unwrap();if(he(r)){if(!r[_chunkTRE7NUKEcjs.a].unwrap)throw new Error("Cannot unwrap laid-out texture view as it has no underlying resource.");return r[_chunkTRE7NUKEcjs.a].unwrap()}if(ur(r))return r.vertexLayout;if(tt(r)||rt(r)){if(r[_chunkTRE7NUKEcjs.a].unwrap)return r[_chunkTRE7NUKEcjs.a].unwrap();throw new Error("Cannot unwrap laid-out sampler.")}if(it(r))return r.querySet;throw new Error(`Unknown resource type: ${r}`)}beginRenderPass(r,n){let a=this.device.createCommandEncoder(),o=a.beginRenderPass(r),s=new Map,i=new Map,u,l=()=>{if(!u)throw new Error("Cannot draw without a call to pass.setPipeline");let{core:m,priors:y}=u[_chunkTRE7NUKEcjs.a],f=m.unwrap();o.setPipeline(f.pipeline);let T=new Set(f.usedBindGroupLayouts);f.usedBindGroupLayouts.forEach((x,P)=>{if(f.catchall&&P===f.catchall[0])o.setBindGroup(P,this.unwrap(f.catchall[1])),T.delete(x);else{let F=_nullishCoalesce(_optionalChain([y, 'access', _113 => _113.bindGroupLayoutMap, 'optionalAccess', _114 => _114.get, 'call', _115 => _115(x)]), () => (s.get(x)));F!==void 0&&(T.delete(x),xe(F)?o.setBindGroup(P,this.unwrap(F)):o.setBindGroup(P,F))}});let w=new Set;if(m.usedVertexLayouts.forEach((x,P)=>{let F=_optionalChain([y, 'access', _116 => _116.vertexLayoutMap, 'optionalAccess', _117 => _117.get, 'call', _118 => _118(x)]),R=F?{buffer:F,offset:void 0,size:void 0}:i.get(x);!R||!R.buffer?w.add(x):le(R.buffer)?o.setVertexBuffer(P,this.unwrap(R.buffer),R.offset,R.size):o.setVertexBuffer(P,R.buffer,R.offset,R.size)}),T.size>0)throw new (0, _chunkTRE7NUKEcjs.ha)(T);if(w.size>0)throw new (0, _chunkTRE7NUKEcjs.ia)(w)};n({setViewport(...m){o.setViewport(...m)},setScissorRect(...m){o.setScissorRect(...m)},setBlendConstant(...m){o.setBlendConstant(...m)},setStencilReference(...m){o.setStencilReference(...m)},beginOcclusionQuery(...m){o.beginOcclusionQuery(...m)},endOcclusionQuery(...m){o.endOcclusionQuery(...m)},executeBundles(...m){o.executeBundles(...m)},setPipeline(m){u=m},setIndexBuffer:(m,y,f,T)=>{le(m)?o.setIndexBuffer(this.unwrap(m),y,f,T):o.setIndexBuffer(m,y,f,T)},setVertexBuffer(m,y,f,T){i.set(m,{buffer:y,offset:f,size:T})},setBindGroup(m,y){s.set(m,y)},draw(m,y,f,T){l(),o.draw(m,y,f,T)},drawIndexed(...m){l(),o.drawIndexed(...m)},drawIndirect(...m){l(),o.drawIndirect(...m)},drawIndexedIndirect(...m){l(),o.drawIndexedIndirect(...m)}}),o.end(),this.device.queue.submit([a.finish()])}flush(){console.warn("flush() has been deprecated, and has no effect.")}}, _class29);async function _a(e){let{adapter:t,device:r,unstable_names:n="random",unstable_logOptions:a}=_nullishCoalesce(e, () => ({}));if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let o=await navigator.gpu.requestAdapter(t);if(!o)throw new Error("Could not find a compatible GPU");let s=[];for(let u of _nullishCoalesce(_optionalChain([r, 'optionalAccess', _119 => _119.requiredFeatures]), () => ([]))){if(!o.features.has(u))throw new Error(`Requested feature "${u}" is not supported by the adapter.`);s.push(u)}for(let u of _nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.optionalFeatures]), () => ([])))o.features.has(u)?s.push(u):console.warn(`Optional feature "${u}" is not supported by the adapter.`);let i=await o.requestDevice({...r,requiredFeatures:s});return new pr(i,n,!0,_nullishCoalesce(a, () => ({})),_optionalChain([e, 'optionalAccess', _121 => _121.shaderGenerator]))}function Wa(e){let{device:t,unstable_names:r="random",unstable_logOptions:n}=_nullishCoalesce(e, () => ({}));return new pr(t,r,!1,_nullishCoalesce(n, () => ({})),_optionalChain([e, 'optionalAccess', _122 => _122.shaderGenerator]))}function ka(e,t){return new sn(e,t)}var sn= (_class30 =class{constructor(t,r=void 0){;_class30.prototype.__init65.call(this);_class30.prototype.__init66.call(this);this.schema=t;this.defaultValue=r;this.slot=we(r),this[_chunkTRE7NUKEcjs.c]=this.slot}__init65() {this[_chunkTRE7NUKEcjs.a]=!0}__init66() {this.resourceType="accessor"}get[_chunkTRE7NUKEcjs.b](){return new Proxy({[_chunkTRE7NUKEcjs.a]:!0,[_chunkTRE7NUKEcjs.e]:this.#e(),[_chunkTRE7NUKEcjs.f]:t=>t.resolve(this),toString:()=>`accessor:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},_chunkZYGTVBDHcjs.r)}#e(){let t=_chunkTRE7NUKEcjs.Aa.call(void 0, ),r=_chunkZYGTVBDHcjs.s.call(void 0, t.unwrap(this.slot));return Ke(r)?r[_chunkTRE7NUKEcjs.a].gpuImpl():_chunkTRE7NUKEcjs.aa.call(void 0, r,this.schema)}$name(t){return this.slot.$name(t),this}toString(){return`accessor:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get value(){if(_chunkTRE7NUKEcjs.Da.call(void 0, ))return this[_chunkTRE7NUKEcjs.b];throw new Error("`tgpu.accessor` relies on GPU resources and cannot be accessed outside of a compute dispatch or draw call")}get $(){return this.value}[_chunkTRE7NUKEcjs.f](t){let r=this.#e();return _chunkTRE7NUKEcjs.aa.call(void 0, t.resolve(r.value,r.dataType).value,r.dataType)}}, _class30);function Ma(e){return Go(e)}function Ro([e,t]){return`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, e), () => ("<unnamed>"))}=${t}`}function Go(e){if(_chunkTRE7NUKEcjs.Aa.call(void 0, ))throw new Error("Cannot create tgpu.derived objects at the resolution stage.");return{[_chunkTRE7NUKEcjs.a]:!0,resourceType:"derived","~compute":e,get[_chunkTRE7NUKEcjs.b](){let r=_chunkTRE7NUKEcjs.Aa.call(void 0, );if(!r)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return _chunkZYGTVBDHcjs.s.call(void 0, r.unwrap(this))},get value(){return this[_chunkTRE7NUKEcjs.b]},get $(){return this.value},with(r,n){return Oa(this,[[r,n]])},toString(){return"derived"}}}function Oa(e,t){return{[_chunkTRE7NUKEcjs.a]:!0,resourceType:"derived","~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},[_chunkTRE7NUKEcjs.d]:{inner:e,pairs:t},get[_chunkTRE7NUKEcjs.b](){let n=_chunkTRE7NUKEcjs.Aa.call(void 0, );if(!n)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return _chunkZYGTVBDHcjs.s.call(void 0, n.unwrap(this))},get value(){return this[_chunkTRE7NUKEcjs.b]},get $(){return this.value},with(n,a){return Oa(e,[...t,[n,a]])},toString(){return`derived[${t.map(Ro).join(", ")}]`}}}var Co={fn:U,bindGroupLayout:Zt,vertexLayout:Jr,slot:we,init:_a,initFromDevice:Wa,resolve:La,resolveWithContext:Nr,privateVar:_e,workgroupVar:_r,const:_chunkZYGTVBDHcjs.t,"~unstable":{fn:U,fragmentFn:Yn,vertexFn:_chunk5Y6GTBWRcjs.h,computeFn:Et,vertexLayout:Jr,namespace:Q,derived:Ma,slot:we,accessor:ka,privateVar:_e,workgroupVar:_r,const:_chunkZYGTVBDHcjs.t,declare:Hn,simulate:Ra}},bf= exports.default =Co;exports.MissingBindGroupsError = _chunkTRE7NUKEcjs.ha; exports.MissingLinksError = _chunkTRE7NUKEcjs.ga; exports.MissingSlotValueError = _chunkTRE7NUKEcjs.ea; exports.MissingVertexBuffersError = _chunkTRE7NUKEcjs.ia; exports.NotUniformError = _chunkTRE7NUKEcjs.fa; exports.ResolutionError = _chunkTRE7NUKEcjs.ca; exports.default = bf; exports.isBuffer = le; exports.isBufferShorthand = Io; exports.isComparisonSampler = rt; exports.isDerived = _chunkTRE7NUKEcjs.na; exports.isSampler = tt; exports.isSlot = _chunkTRE7NUKEcjs.ma; exports.isTexture = ee; exports.isTgpuFn = Ke; exports.isUsableAsRender = ho; exports.isUsableAsSampled = Gr; exports.isUsableAsStorage = Te; exports.isUsableAsUniform = jt; exports.isUsableAsVertex = mo; exports.isVariable = wo; exports.tgpu = Co;
|
|
192
192
|
//# sourceMappingURL=index.cjs.map
|