typegpu 0.8.0 → 0.8.2
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/{chunk-6WF2EZIT.js → chunk-6U5HPHCJ.js} +2 -2
- package/{chunk-B254XDWG.js → chunk-CGQB3SER.js} +2 -2
- package/{chunk-XEUNEHAZ.js → chunk-CRZWTZM2.js} +6 -6
- package/chunk-CRZWTZM2.js.map +1 -0
- package/chunk-ECR2EGZX.js +7 -0
- package/chunk-ECR2EGZX.js.map +1 -0
- package/chunk-PWBIFP67.js +2 -0
- package/chunk-PWBIFP67.js.map +1 -0
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/data/index.d.ts +3 -3
- package/data/index.js +1 -1
- package/index.d.ts +2 -2
- package/index.js +40 -40
- package/index.js.map +1 -1
- package/{matrix-C6mMH7pB.d.ts → matrix-DIfOiRyz.d.ts} +1 -1
- package/package.json +5 -13
- package/std/index.d.ts +2 -2
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/{tgpuConstant-DzGgwe0I.d.ts → tgpuConstant-BTQFNlQH.d.ts} +13 -8
- package/chunk-A5APHF7K.cjs +0 -10
- package/chunk-A5APHF7K.cjs.map +0 -1
- package/chunk-LL6NPRFE.cjs +0 -7
- package/chunk-LL6NPRFE.cjs.map +0 -1
- package/chunk-M2P3FJT7.cjs +0 -2
- package/chunk-M2P3FJT7.cjs.map +0 -1
- package/chunk-PO6SIMTQ.js +0 -2
- package/chunk-PO6SIMTQ.js.map +0 -1
- package/chunk-T2GBOTUH.js +0 -7
- package/chunk-T2GBOTUH.js.map +0 -1
- package/chunk-TRAG63HY.cjs +0 -3
- package/chunk-TRAG63HY.cjs.map +0 -1
- package/chunk-U3CXOCRG.cjs +0 -2
- package/chunk-U3CXOCRG.cjs.map +0 -1
- package/chunk-XEUNEHAZ.js.map +0 -1
- package/common/index.cjs +0 -7
- package/common/index.cjs.map +0 -1
- package/common/index.d.cts +0 -24
- package/data/index.cjs +0 -2
- package/data/index.cjs.map +0 -1
- package/data/index.d.cts +0 -402
- package/index.cjs +0 -192
- package/index.cjs.map +0 -1
- package/index.d.cts +0 -369
- package/matrix-Cn2jQILV.d.cts +0 -122
- package/std/index.cjs +0 -2
- package/std/index.cjs.map +0 -1
- package/std/index.d.cts +0 -639
- package/tgpuConstant-DzGgwe0I.d.cts +0 -5196
- /package/{chunk-6WF2EZIT.js.map → chunk-6U5HPHCJ.js.map} +0 -0
- /package/{chunk-B254XDWG.js.map → chunk-CGQB3SER.js.map} +0 -0
package/index.cjs
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
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 _chunkTRAG63HYcjs = require('./chunk-TRAG63HY.cjs');var _chunkU3CXOCRGcjs = require('./chunk-U3CXOCRG.cjs');var _chunkLL6NPRFEcjs = require('./chunk-LL6NPRFE.cjs');var _chunkA5APHF7Kcjs = require('./chunk-A5APHF7K.cjs');function Jn(t){return _optionalChain([t, 'optionalAccess', _2 => _2[_chunkA5APHF7Kcjs.b]])}var G={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=_chunkA5APHF7Kcjs.ua.call(void 0, t).dataType,a=_chunkLL6NPRFEcjs.n.call(void 0, n,String(e));if(a.type!=="unknown")return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,[_chunkA5APHF7Kcjs.f]:o=>_chunkA5APHF7Kcjs.aa.call(void 0, `${o.resolve(t).value}.${String(e)}`,a),get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,a)},toString:()=>`${String(t)}.${e}`},G)}};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[_chunkA5APHF7Kcjs.a]={}}#e;$name(e){return _chunkA5APHF7Kcjs.k.call(void 0, this,e),this}[_chunkA5APHF7Kcjs.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};`),_chunkA5APHF7Kcjs.aa.call(void 0, r,this.dataType)}toString(){return`const:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunkA5APHF7Kcjs.b](){let e=this.dataType;return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,e)},[_chunkA5APHF7Kcjs.f]:r=>r.resolve(this),toString:()=>`const:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},G)}get value(){return _chunkA5APHF7Kcjs.Da.call(void 0, )?this[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a]=!0}__init3() {this.externalsToApply=[]}$uses(e){return this.externalsToApply.push(e),this}[_chunkA5APHF7Kcjs.f](e){let r={};for(let a of this.externalsToApply)_chunkTRAG63HYcjs.a.call(void 0, r,a);let n=_chunkTRAG63HYcjs.d.call(void 0, e,r,this.declaration);return e.addDeclaration(n),_chunkA5APHF7Kcjs.aa.call(void 0, "",_chunkA5APHF7Kcjs.q)}toString(){return`declare: ${this.declaration}`}}, _class2);function Et(t){let e={argTypes:t.in&&Object.keys(t.in).length!==0?[_chunkTRAG63HYcjs.f.call(void 0, t.in)]:[],returnType:_chunkA5APHF7Kcjs.q,workgroupSize:[_nullishCoalesce(t.workgroupSize[0], () => (1)),_nullishCoalesce(t.workgroupSize[1], () => (1)),_nullishCoalesce(t.workgroupSize[2], () => (1))],isEntry:!0},r=(n,...a)=>Ka(e,t.workgroupSize,_chunkTRAG63HYcjs.g.call(void 0, n,...a));return Object.assign(Object.assign(r,e),{does:r})}function Ka(t,e,r){let n=_chunkTRAG63HYcjs.e.call(void 0, r,`@compute @workgroup_size(${e.join(", ")}) `),a=t.argTypes[0];return{shell:t,$uses(s){return n.applyExternals(s),this},[_chunkA5APHF7Kcjs.a]:!0,[_chunkA5APHF7Kcjs.c]:n,$name(s){return _chunkA5APHF7Kcjs.k.call(void 0, n,s),_chunkA5APHF7Kcjs.l.call(void 0, a)&&a.$name(`${s}_Input`),this},[_chunkA5APHF7Kcjs.f](s){return n.resolve(s,t.argTypes,t.returnType)},toString(){return`computeFn:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, n), () => ("<unnamed>"))}`}}}function U(t,e){let r={[_chunkA5APHF7Kcjs.a]:!0,argTypes:t,returnType:_nullishCoalesce(e, () => (_chunkA5APHF7Kcjs.q)),isEntry:!1};return Object.assign((a,...o)=>Ja(r,_chunkTRAG63HYcjs.g.call(void 0, a,...o)),r)}function He(t){return _chunkA5APHF7Kcjs.h.call(void 0, t)&&_optionalChain([t, 'optionalAccess', _3 => _3.resourceType])==="function"}function Ya([t,e]){return`${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, t), () => ("<unnamed>"))}=${e}`}function Ja(t,e){let r=_chunkTRAG63HYcjs.e.call(void 0, e,""),n={shell:t,resourceType:"function",$uses(s){return r.applyExternals(s),this},[_chunkA5APHF7Kcjs.c]:r,$name(s){return _chunkA5APHF7Kcjs.k.call(void 0, r,s),this},with(s,i){return Zn(o,[[_chunkA5APHF7Kcjs.pa.call(void 0, s)?s.slot:s,i]])},[_chunkA5APHF7Kcjs.f](s){return typeof e=="string"&&(_chunkTRAG63HYcjs.b.call(void 0, e,t.argTypes,r.applyExternals),_chunkTRAG63HYcjs.c.call(void 0, e,t.returnType,r.applyExternals)),r.resolve(s,t.argTypes,t.returnType)}},a=_chunkA5APHF7Kcjs.Ma.call(void 0, (...s)=>_chunkA5APHF7Kcjs.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((p,m)=>_chunkA5APHF7Kcjs.rc.call(void 0, t.argTypes[m],p)),u=e(...i);return _chunkA5APHF7Kcjs.rc.call(void 0, t.returnType,u)}catch(i){throw i instanceof _chunkA5APHF7Kcjs.da?i.appendToTrace(o):new (0, _chunkA5APHF7Kcjs.da)(i,[o])}}),(...s)=>_chunkA5APHF7Kcjs.aa.call(void 0, new Vt(o,s),t.returnType),"tgpuFnCall",t.argTypes),o=Object.assign(a,n);return o[_chunkA5APHF7Kcjs.a].implementation=e,Object.defineProperty(o,"toString",{value(){return`fn:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, r), () => ("<unnamed>"))}`}}),o}function Zn(t,e){let r={resourceType:"function",shell:t.shell,[_chunkA5APHF7Kcjs.d]:{inner:t,pairs:e},$uses(o){return t.$uses(o),this},[_chunkA5APHF7Kcjs.c]:t,$name(o){return t.$name(o),this},with(o,s){return Zn(a,[...e,[_chunkA5APHF7Kcjs.pa.call(void 0, o)?o.slot:o,s]])}},n=_chunkA5APHF7Kcjs.Ma.call(void 0, (...o)=>t(...o),(...o)=>_chunkA5APHF7Kcjs.aa.call(void 0, new Vt(a,o),t.shell.returnType),"tgpuFnCall",t.shell.argTypes),a=Object.assign(n,r);return a[_chunkA5APHF7Kcjs.a].implementation=t[_chunkA5APHF7Kcjs.a].implementation,Object.defineProperty(a,"toString",{value(){return`fn:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, t), () => ("<unnamed>"))}[${e.map(Ya).join(", ")}]`}}),a[_chunkA5APHF7Kcjs.a].implementation=t[_chunkA5APHF7Kcjs.a].implementation,a}var Vt= (_class3 =class{__init4() {this[_chunkA5APHF7Kcjs.a]=!0}#e;#r;constructor(e,r){;_class3.prototype.__init4.call(this);this.#e=e,this.#r=r,this[_chunkA5APHF7Kcjs.c]=e,this[_chunkA5APHF7Kcjs.e]=_chunkA5APHF7Kcjs.aa.call(void 0, this,this.#e.shell.returnType)}[_chunkA5APHF7Kcjs.f](e){return e.withResetIndentLevel(()=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`${e.resolve(this.#e).value}(${this.#r})`,this.#e.shell.returnType))}toString(){return`call:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}}, _class3);function ea(t){let e={in:t.in,out:t.out,returnType:_chunkTRAG63HYcjs.f.call(void 0, t.out),isEntry:!0},r=(n,...a)=>Xa(e,_chunkTRAG63HYcjs.g.call(void 0, n,...a));return Object.assign(Object.assign(r,e),{does:r})}function Xa(t,e){let r=_chunkTRAG63HYcjs.e.call(void 0, e,"@fragment "),n=t.returnType;return typeof e=="string"&&_chunkTRAG63HYcjs.c.call(void 0, e,n,o=>r.applyExternals(o)),{shell:t,outputType:n,$uses(o){return r.applyExternals(o),this},[_chunkA5APHF7Kcjs.a]:!0,[_chunkA5APHF7Kcjs.c]:r,$name(o){return _chunkA5APHF7Kcjs.k.call(void 0, r,o),_chunkA5APHF7Kcjs.l.call(void 0, n)&&n.$name(`${o}_Output`),this},[_chunkA5APHF7Kcjs.f](o){let s=t.in?_chunkTRAG63HYcjs.f.call(void 0, t.in,o.varyingLocations).$name(`${_nullishCoalesce(_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.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=_chunkTRAG63HYcjs.e.call(void 0, e,"");return{[_chunkA5APHF7Kcjs.a]:!0,[_chunkA5APHF7Kcjs.c]:r,resourceType:"shellless-impl",[_chunkA5APHF7Kcjs.f](n){return r.resolve(n,t,void 0)},toString(){return`fn*:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, r), () => ("<unnamed>"))}`}}}var Mt= (_class6 =class{constructor() { _class6.prototype.__init7.call(this); }__init7() {this.cache=new Map}get(e,r){let n=_chunkA5APHF7Kcjs.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 '${_chunkA5APHF7Kcjs.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=>_chunkLL6NPRFEcjs.p.call(void 0, i.dataType)),o=this.cache.get(e);if(o){let i=o.find(u=>u.argTypes.every((p,m)=>p===a[m]));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[_chunkA5APHF7Kcjs.a]={nameRegistry:e,shelllessRepo:new Mt,memoizedResolves:new WeakMap,memoizedDerived:new WeakMap,listeners:{name:new Set}}}on(e,r){if(e==="name"){let n=this[_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.U.call(void 0, t), () => (0))}]}]}}let n=[],a=new WeakMap,o=0;for(let[s,i]of Object.entries(t)){if(_chunkA5APHF7Kcjs.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 p=u._layout,m=a.get(p);m||(r.push(p),m=[],n.push({arrayStride:p.stride,stepMode:p.stepMode,attributes:m}),a.set(p,m)),o=_nullishCoalesce(_chunkA5APHF7Kcjs.U.call(void 0, i), () => (o)),m.push({format:u.format,offset:u.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var Za=["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 eo(t){return Za.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` ${_chunkA5APHF7Kcjs.qc.call(void 0, r)}${e}: ${t.resolve(r).value},
|
|
2
|
-
`}function to(t,e){if(e[_chunkA5APHF7Kcjs.a].isAbstruct)throw new Error("Cannot resolve abstract struct types to WGSL.");let r=t.getUniqueName(e);return t.addDeclaration(`struct ${r} {
|
|
3
|
-
${Object.entries(e.propTypes).map(n=>Dr(t,n)).join("")}}`),r}function ro(t,e){let r=t.getUniqueName(e);return t.addDeclaration(`struct ${r} {
|
|
4
|
-
${Object.entries(e.propTypes).map(n=>Ke(n[1])?Dr(t,[n[0],_chunkA5APHF7Kcjs.ob[n[1].format]]):Dr(t,n)).join("")}
|
|
5
|
-
}`),r}function no(t,e){let r=t.resolve(e.elementType).value;return e.elementCount===0?`array<${r}>`:`array<${r}, ${e.elementCount}>`}function ao(t,e){let r=t.resolve(Ke(e.elementType)?_chunkA5APHF7Kcjs.ob[e.elementType.format]:e.elementType).value;return e.elementCount===0?`array<${r}>`:`array<${r}, ${e.elementCount}>`}function Br(t,e){if(_chunkA5APHF7Kcjs.Q.call(void 0, e))return e.type==="unstruct"?ro(t,e):e.type==="disarray"?ao(t,e):e.type==="loose-decorated"?t.resolve(Ke(e.inner)?_chunkA5APHF7Kcjs.ob[e.inner.format]:e.inner).value:t.resolve(_chunkA5APHF7Kcjs.ob[e.type]).value;if(eo(e))return e.type;if(e.type==="struct")return to(t,e);if(e.type==="array")return no(t,e);if(e.type==="atomic")return`atomic<${Br(t,e.inner)}>`;if(e.type==="decorated")return t.resolve(e.inner).value;if(e.type==="ptr")return e.addressSpace==="storage"?`ptr<storage, ${t.resolve(e.inner).value}, ${e.access==="read-write"?"read_write":e.access}>`:`ptr<${e.addressSpace}, ${t.resolve(e.inner).value}>`;if(e.type==="abstractInt"||e.type==="abstractFloat"||e.type==="void"||e.type==="u16")throw new Error(`${e.type} has no representation in WGSL`);if(_chunkLL6NPRFEcjs.Q.call(void 0, e))return`${e.type}<${e.format}, ${_chunkLL6NPRFEcjs.x[e.access]}>`;if(_chunkLL6NPRFEcjs.P.call(void 0, e))return e.type.startsWith("texture_depth")?e.type:`${e.type}<${e.sampleType.type}>`;if(_chunkLL6NPRFEcjs.v.call(void 0, e)||_chunkLL6NPRFEcjs.u.call(void 0, e))return e.type;_chunkA5APHF7Kcjs.Ga.call(void 0, e,"resolveData")}var Le=class t{constructor(e){this.bindings=e}with(e,r){return new t([...this.bindings,[_chunkA5APHF7Kcjs.pa.call(void 0, e)?e.slot:e,r]])}pipe(e){let r=e(this);return new t([...this.bindings,...r.bindings])}};function*oa(t){let e=0;for(;;)t.has(e)||(yield e),e++}var _typedbinary = require('typed-binary');function oo(t,e){let r="size"in t?t.size:t.currentByteOffset,n=e-1,a=r&n;"skipBytes"in t?t.skipBytes(e-a&n):t.add(e-a&n)}var $=oo;var sa=new WeakMap;function Ot(t){let e=sa.get(t);if(e)return e;let r=new _typedbinary.Measurer,n={},a;for(let o in t.propTypes){let s=t.propTypes[o];if(s===void 0)throw new Error(`Property ${o} is undefined in struct`);let i=r.size;$(r,_chunkA5APHF7Kcjs.S.call(void 0, t)?_chunkA5APHF7Kcjs.fc.call(void 0, s):_chunkA5APHF7Kcjs.ec.call(void 0, s)),a&&(a.padding=r.size-i);let u=_chunkA5APHF7Kcjs.ic.call(void 0, s);n[o]={offset:r.size,size:u},a=n[o],r.add(u)}return a&&(a.padding=_chunkA5APHF7Kcjs.hc.call(void 0, _chunkA5APHF7Kcjs.ic.call(void 0, t),_chunkA5APHF7Kcjs.ec.call(void 0, t))-r.size),sa.set(t,n),n}var io=(()=>{try{return new Function("return true"),!0}catch (e2){return!1}})(),$r=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"},uo={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"},po={unorm8:t=>`Math.round(${t} * 255)`,unorm8x2:t=>`Math.round(${t} * 255)`,unorm8x4:t=>`Math.round(${t} * 255)`,snorm8:t=>`Math.round(${t} * 127)`,snorm8x2:t=>`Math.round(${t} * 127)`,snorm8x4:t=>`Math.round(${t} * 127)`,unorm16:t=>`Math.round(${t} * 65535)`,unorm16x2:t=>`Math.round(${t} * 65535)`,unorm16x4:t=>`Math.round(${t} * 65535)`,snorm16:t=>`Math.round(${t} * 32767)`,snorm16x2:t=>`Math.round(${t} * 32767)`,snorm16x4:t=>`Math.round(${t} * 32767)`},ia={"unorm10-10-10-2":{writeFunction:"setUint32",generator:(t,e)=>`output.setUint32(${t}, ((${e}.x*1023&0x3FF)<<22)|((${e}.y*1023&0x3FF)<<12)|((${e}.z*1023&0x3FF)<<2)|(${e}.w*3&3), littleEndian);
|
|
6
|
-
`},"unorm8x4-bgra":{writeFunction:"setUint8",generator:(t,e)=>{let r=["z","y","x","w"],n="";for(let a=0;a<4;a++)n+=`output.setUint8((${t} + ${a}), Math.round(${e}.${r[a]} * 255), littleEndian);
|
|
7
|
-
`;return n}}};function qt(t,e,r,n=0){let a=["i","j","k"][n]||`i${n}`;if(_chunkA5APHF7Kcjs.F.call(void 0, t)||_chunkA5APHF7Kcjs.L.call(void 0, t))return qt(t.inner,e,r,n);if(_chunkA5APHF7Kcjs.D.call(void 0, t)||_chunkA5APHF7Kcjs.S.call(void 0, t)){let s=Ot(t),i="";for(let[u,p]of Object.entries(s)){let m=t.propTypes[u];m&&(i+=qt(m,`(${e} + ${p.offset})`,`${r}.${u}`,n))}return i}if(_chunkA5APHF7Kcjs.C.call(void 0, t)||_chunkA5APHF7Kcjs.R.call(void 0, t)){let s=_chunkA5APHF7Kcjs.hc.call(void 0, _chunkA5APHF7Kcjs.ic.call(void 0, t.elementType),_chunkA5APHF7Kcjs.ec.call(void 0, t)),i="";return i+=`for (let ${a} = 0; ${a} < ${t.elementCount}; ${a}++) {
|
|
8
|
-
`,i+=qt(t.elementType,`(${e} + ${a} * ${s})`,`${r}[${a}]`,n+1),i+=`}
|
|
9
|
-
`,i}if(_chunkA5APHF7Kcjs.v.call(void 0, t)){let s=zt[t.type],i="",u=Nt[s],p=["x","y","z","w"],m=_chunkA5APHF7Kcjs.s.call(void 0, t)?2:_chunkA5APHF7Kcjs.t.call(void 0, t)?3:4;for(let c=0;c<m;c++)i+=`output.${u}((${e} + ${c*4}), ${r}.${p[c]}, littleEndian);
|
|
10
|
-
`;return i}if(_chunkA5APHF7Kcjs.z.call(void 0, t)){let s=zt[t.type],i=Nt[s],u=_chunkA5APHF7Kcjs.x.call(void 0, t)?2:_chunkA5APHF7Kcjs.y.call(void 0, t)?3:4,p=u*u,m=_chunkA5APHF7Kcjs.hc.call(void 0, u*4,8),c="";for(let y=0;y<p;y++){let h=Math.floor(y/u),v=y%u,x=h*m+v*4;c+=`output.${i}((${e} + ${x}), ${r}.columns[${h}].${["x","y","z","w"][v]}, littleEndian);
|
|
11
|
-
`}return c}if(_chunkA5APHF7Kcjs.dc.call(void 0, t)){let s=t.type;if(s in ia)return ia[s].generator(e,r);let i=uo[s],u=Nt[i],p=_chunkA5APHF7Kcjs.ob[s],m=_chunkA5APHF7Kcjs.u.call(void 0, p)?4:_chunkA5APHF7Kcjs.t.call(void 0, p)?3:_chunkA5APHF7Kcjs.s.call(void 0, p)?2:1,c=i==="u8"||i==="i8"?1:i==="u16"||i==="i16"||i==="f16"?2:4,y=["x","y","z","w"],h=po[s],v="";for(let x=0;x<m;x++){let P=m===1?r:`${r}.${y[x]}`,F=h?h(P):P;v+=`output.${u}((${e} + ${x*c}), ${F}, littleEndian);
|
|
12
|
-
`}return v}if(!Object.hasOwn(zt,t.type))throw new Error(`Primitive ${t.type} is unsupported by compiled writer`);let o=zt[t.type];return`output.${Nt[o]}(${e}, ${r}, littleEndian);
|
|
13
|
-
`}function Ar(t){if(!io){console.warn("This environment does not allow eval - using default writer as fallback");return}if($r.has(t))return $r.get(t);try{let e=qt(t,"offset","value",0),r=new Function("output","offset","value","littleEndian=true",e);return $r.set(t,r),r}catch(e){console.warn(`Failed to compile writer for schema: ${t}
|
|
14
|
-
Reason: ${e instanceof Error?e.message:String(e)}
|
|
15
|
-
Falling back to default writer`)}}var Ge={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=_chunkA5APHF7Kcjs.ec.call(void 0, e);$(t,n);for(let[a,o]of Object.entries(e.propTypes))$(t,_chunkA5APHF7Kcjs.ec.call(void 0, o)),Re(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=_chunkA5APHF7Kcjs.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),Re(t,e.elementType,r[o]);t.seekTo(a+_chunkA5APHF7Kcjs.ic.call(void 0, e))},ptr(){throw new Error("Pointers are not host-shareable")},atomic(t,e,r){_optionalChain([Ge, 'access', _6 => _6[e.inner.type], 'optionalCall', _7 => _7(t,e,r)])},decorated(t,e,r){let n=_chunkA5APHF7Kcjs.fc.call(void 0, e);$(t,n);let a=t.currentByteOffset;_optionalChain([Ge, 'access', _8 => _8[_optionalChain([e, 'access', _9 => _9.inner, 'optionalAccess', _10 => _10.type])], 'optionalCall', _11 => _11(t,e.inner,r)]),t.seekTo(a+_chunkA5APHF7Kcjs.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=_chunkA5APHF7Kcjs.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([Ge, 'access', _12 => _12[_optionalChain([e, 'access', _13 => _13.elementType, 'optionalAccess', _14 => _14.type])], 'optionalCall', _15 => _15(t,e.elementType,r[o])]);t.seekTo(a+_chunkA5APHF7Kcjs.ic.call(void 0, e))},unstruct(t,e,r){let n=e.propTypes;for(let[a,o]of Object.entries(n))_optionalChain([Ge, 'access', _16 => _16[o.type], 'optionalCall', _17 => _17(t,o,r[a])])},"loose-decorated"(t,e,r){let n=_chunkA5APHF7Kcjs.fc.call(void 0, e);$(t,n);let a=t.currentByteOffset,o=Ge[_optionalChain([e, 'access', _18 => _18.inner, 'optionalAccess', _19 => _19.type])];return _optionalChain([o, 'optionalCall', _20 => _20(t,e.inner,r)]),t.seekTo(a+_chunkA5APHF7Kcjs.ic.call(void 0, e)),r}};function Re(t,e,r){let n=Ge[e.type];if(!n)throw new Error(`Cannot write data of type '${e.type}'.`);n(t,e,r)}var lo={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 _chunkA5APHF7Kcjs.Ya.call(void 0, t.readFloat32(),t.readFloat32())},vec3f(t){return _chunkA5APHF7Kcjs.bb.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32())},vec4f(t){return _chunkA5APHF7Kcjs.gb.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32())},vec2h(t){return _chunkA5APHF7Kcjs.Za.call(void 0, t.readFloat16(),t.readFloat16())},vec3h(t){return _chunkA5APHF7Kcjs.cb.call(void 0, t.readFloat16(),t.readFloat16(),t.readFloat16())},vec4h(t){return _chunkA5APHF7Kcjs.hb.call(void 0, t.readFloat16(),t.readFloat16(),t.readFloat16(),t.readFloat16())},vec2i(t){return _chunkA5APHF7Kcjs._a.call(void 0, t.readInt32(),t.readInt32())},vec3i(t){return _chunkA5APHF7Kcjs.db.call(void 0, t.readInt32(),t.readInt32(),t.readInt32())},vec4i(t){return _chunkA5APHF7Kcjs.ib.call(void 0, t.readInt32(),t.readInt32(),t.readInt32(),t.readInt32())},vec2u(t){return _chunkA5APHF7Kcjs.$a.call(void 0, t.readUint32(),t.readUint32())},vec3u(t){return _chunkA5APHF7Kcjs.eb.call(void 0, t.readUint32(),t.readUint32(),t.readUint32())},vec4u(t){return _chunkA5APHF7Kcjs.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 _chunkLL6NPRFEcjs.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 _chunkLL6NPRFEcjs.k.call(void 0, t.readFloat32(),t.readFloat32(),e(),t.readFloat32(),t.readFloat32(),e(),t.readFloat32(),t.readFloat32(),e())},mat4x4f(t){return _chunkLL6NPRFEcjs.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=_chunkA5APHF7Kcjs.ec.call(void 0, e);$(t,r);let n={},a=e.propTypes;for(let[o,s]of Object.entries(a))$(t,_chunkA5APHF7Kcjs.ec.call(void 0, s)),n[o]=M(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=_chunkA5APHF7Kcjs.ec.call(void 0, e),n=[];for(let a=0;a<e.elementCount;a++){$(t,r);let o=e.elementType,s=M(t,o);n.push(s)}return $(t,r),n},ptr(){throw new Error("Pointers are not host-shareable")},atomic(t,e){return M(t,e.inner)},decorated(t,e){let r=_chunkA5APHF7Kcjs.fc.call(void 0, e);$(t,r);let n=t.currentByteOffset,a=M(t,e.inner);return t.seekTo(n+_chunkA5APHF7Kcjs.ic.call(void 0, e)),a},uint8:t=>t.readUint8(),uint8x2:t=>_chunkA5APHF7Kcjs.$a.call(void 0, t.readUint8(),t.readUint8()),uint8x4:t=>_chunkA5APHF7Kcjs.jb.call(void 0, t.readUint8(),t.readUint8(),t.readUint8(),t.readUint8()),sint8:t=>t.readInt8(),sint8x2:t=>_chunkA5APHF7Kcjs._a.call(void 0, t.readInt8(),t.readInt8()),sint8x4:t=>_chunkA5APHF7Kcjs.ib.call(void 0, t.readInt8(),t.readInt8(),t.readInt8(),t.readInt8()),unorm8:t=>t.readUint8()/255,unorm8x2:t=>_chunkA5APHF7Kcjs.Ya.call(void 0, t.readUint8()/255,t.readUint8()/255),unorm8x4:t=>_chunkA5APHF7Kcjs.gb.call(void 0, t.readUint8()/255,t.readUint8()/255,t.readUint8()/255,t.readUint8()/255),snorm8:t=>t.readInt8()/127,snorm8x2:t=>_chunkA5APHF7Kcjs.Ya.call(void 0, t.readInt8()/127,t.readInt8()/127),snorm8x4:t=>_chunkA5APHF7Kcjs.gb.call(void 0, t.readInt8()/127,t.readInt8()/127,t.readInt8()/127,t.readInt8()/127),uint16:t=>t.readUint16(),uint16x2:t=>_chunkA5APHF7Kcjs.$a.call(void 0, t.readUint16(),t.readUint16()),uint16x4:t=>_chunkA5APHF7Kcjs.jb.call(void 0, t.readUint16(),t.readUint16(),t.readUint16(),t.readUint16()),sint16:t=>t.readInt16(),sint16x2:t=>_chunkA5APHF7Kcjs._a.call(void 0, t.readInt16(),t.readInt16()),sint16x4:t=>_chunkA5APHF7Kcjs.ib.call(void 0, t.readInt16(),t.readInt16(),t.readInt16(),t.readInt16()),unorm16:t=>t.readUint16()/65535,unorm16x2:t=>_chunkA5APHF7Kcjs.Ya.call(void 0, t.readUint16()/65535,t.readUint16()/65535),unorm16x4:t=>_chunkA5APHF7Kcjs.gb.call(void 0, t.readUint16()/65535,t.readUint16()/65535,t.readUint16()/65535,t.readUint16()/65535),snorm16:t=>t.readInt16()/32767,snorm16x2:t=>_chunkA5APHF7Kcjs.Ya.call(void 0, t.readInt16()/32767,t.readInt16()/32767),snorm16x4:t=>_chunkA5APHF7Kcjs.gb.call(void 0, t.readInt16()/32767,t.readInt16()/32767,t.readInt16()/32767,t.readInt16()/32767),float16(t){return t.readFloat16()},float16x2:t=>_chunkA5APHF7Kcjs.Ya.call(void 0, t.readFloat16(),t.readFloat16()),float16x4:t=>_chunkA5APHF7Kcjs.gb.call(void 0, t.readFloat16(),t.readFloat16(),t.readFloat16(),t.readFloat16()),float32:t=>t.readFloat32(),float32x2:t=>_chunkA5APHF7Kcjs.Ya.call(void 0, t.readFloat32(),t.readFloat32()),float32x3:t=>_chunkA5APHF7Kcjs.bb.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32()),float32x4:t=>_chunkA5APHF7Kcjs.gb.call(void 0, t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32()),uint32:t=>t.readUint32(),uint32x2:t=>_chunkA5APHF7Kcjs.$a.call(void 0, t.readUint32(),t.readUint32()),uint32x3:t=>_chunkA5APHF7Kcjs.eb.call(void 0, t.readUint32(),t.readUint32(),t.readUint32()),uint32x4:t=>_chunkA5APHF7Kcjs.jb.call(void 0, t.readUint32(),t.readUint32(),t.readUint32(),t.readUint32()),sint32:t=>t.readInt32(),sint32x2:t=>_chunkA5APHF7Kcjs._a.call(void 0, t.readInt32(),t.readInt32()),sint32x3:t=>_chunkA5APHF7Kcjs.db.call(void 0, t.readInt32(),t.readInt32(),t.readInt32()),sint32x4:t=>_chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.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]=M(t,o);return r},disarray(t,e){let r=_chunkA5APHF7Kcjs.ec.call(void 0, e),n=[];for(let a=0;a<e.elementCount;a++)$(t,r),n.push(M(t,e.elementType));return $(t,r),n},"loose-decorated"(t,e){$(t,_chunkA5APHF7Kcjs.fc.call(void 0, e));let r=t.currentByteOffset,n=M(t,e.inner);return t.seekTo(r+_chunkA5APHF7Kcjs.ic.call(void 0, e)),n}};function M(t,e){let r=lo[e.type];if(!r)throw new Error(`Cannot read data of type '${e.type}'.`);return r(t,e)}function ua(t,e){let r=_chunkA5APHF7Kcjs.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(p,m,c,y){if(m!=null){if(_chunkA5APHF7Kcjs.D.call(void 0, p)||_chunkA5APHF7Kcjs.S.call(void 0, p)){let h=Ot(p);for(let[v,x]of Object.entries(h)){let P=p.propTypes[v];if(!P)continue;let F=m[v];F!==void 0&&s(P,F,c+x.offset,_nullishCoalesce(x.padding, () => (y)))}return}if(_chunkA5APHF7Kcjs.C.call(void 0, p)||_chunkA5APHF7Kcjs.R.call(void 0, p)){let h=p,v=_chunkA5APHF7Kcjs.hc.call(void 0, _chunkA5APHF7Kcjs.ic.call(void 0, h.elementType),_chunkA5APHF7Kcjs.ec.call(void 0, h.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(h.elementType,F,c+P*v,v-_chunkA5APHF7Kcjs.ic.call(void 0, h.elementType))}else{let h=_chunkA5APHF7Kcjs.ic.call(void 0, p);a.seekTo(c),Re(a,p,m),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 p=1;p<o.length;p++){let m=o[p];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 ye(t){return!!_optionalChain([t, 'optionalAccess', _21 => _21.usableAsStorage])}var Ye=class t extends Error{constructor(e){super(`Resource '${_nullishCoalesce(_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a]={dataType:r.dataType},this[_chunkA5APHF7Kcjs.c]=r}__init8() {this.resourceType="buffer-usage"}$name(e){return this.buffer.$name(e),this}[_chunkA5APHF7Kcjs.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};`),_chunkA5APHF7Kcjs.aa.call(void 0, n,r)}toString(){return`${this.usage}:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunkA5APHF7Kcjs.b](){let e=this.buffer.dataType;return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,e)},[_chunkA5APHF7Kcjs.f]:r=>r.resolve(this),toString:()=>`${this.usage}:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},G)}get $(){let e=_chunkA5APHF7Kcjs.Ca.call(void 0, ),r=_chunkA5APHF7Kcjs.ya.call(void 0, );if(e.type==="normal")throw new (0, _chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.b]:e.type==="simulate"?(e.buffers.has(this.buffer)||e.buffers.set(this.buffer,_chunkA5APHF7Kcjs.rc.call(void 0, this.buffer.dataType,this.buffer.initial)),e.buffers.get(this.buffer)):_chunkA5APHF7Kcjs.Ga.call(void 0, e,"bufferUsage.ts#TgpuFixedBufferImpl/$")}get value(){return this.$}set $(e){let r=_chunkA5APHF7Kcjs.Ca.call(void 0, ),n=_chunkA5APHF7Kcjs.ya.call(void 0, );if(r.type==="normal")throw new (0, _chunkA5APHF7Kcjs.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}_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a]={dataType:r},this.#e=n,_chunkA5APHF7Kcjs.k.call(void 0, this,n.key)}__init9() {this.resourceType="buffer-usage"}#e;[_chunkA5APHF7Kcjs.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};`),_chunkA5APHF7Kcjs.aa.call(void 0, n,r)}toString(){return`${this.usage}:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunkA5APHF7Kcjs.b](){let e=this.dataType;return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,e)},[_chunkA5APHF7Kcjs.f]:r=>r.resolve(this),toString:()=>`${this.usage}:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},G)}get $(){if(_chunkA5APHF7Kcjs.Da.call(void 0, ))return this[_chunkA5APHF7Kcjs.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 go={uniform:ga,mutable:da,readonly:ca};function Ze(t,e,r){return _chunkA5APHF7Kcjs.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 yo(t){return!!t.usableAsVertex}var To=_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;_chunkA5APHF7Kcjs.wa.call(void 0, n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}__init10() {this[_chunkA5APHF7Kcjs.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:_chunkA5APHF7Kcjs.ic.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:_nullishCoalesce(_chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.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,To==="little");return}catch(a){console.error(`Error when using compiled writer for buffer ${_nullishCoalesce(_chunkA5APHF7Kcjs.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)}Re(new (0, _typedbinary.BufferWriter)(e),this.dataType,r)}write(e){let r=this.buffer,n=this._group.device;if(r.mapState==="mapped"){let o=r.getMappedRange();this._writeToTarget(o,e);return}let a=_chunkA5APHF7Kcjs.ic.call(void 0, this.dataType);this._hostBuffer||(this._hostBuffer=new ArrayBuffer(a)),this._group.flush(),this._writeToTarget(this._hostBuffer,e),n.queue.writeBuffer(r,0,this._hostBuffer,0,a)}writePartial(e){let r=this.buffer,n=this._group.device,a=ua(this.dataType,e);if(r.mapState==="mapped"){let o=r.getMappedRange(),s=new Uint8Array(o);for(let i of a)s.set(i.data,i.data.byteOffset)}else for(let o of a)n.queue.writeBuffer(r,o.data.byteOffset,o.data,0,o.data.byteLength)}clear(){let e=this.buffer,r=this._group.device;if(e.mapState==="mapped"){new Uint8Array(e.getMappedRange()).fill(0);return}this._group.flush();let n=r.createCommandEncoder();n.clearBuffer(e),r.queue.submit([n.finish()])}copyFrom(e){if(this.buffer.mapState==="mapped")throw new Error("Cannot copy to a mapped buffer.");let r=_chunkA5APHF7Kcjs.ic.call(void 0, this.dataType);this._group.commandEncoder.copyBufferToBuffer(e.buffer,0,this.buffer,0,r)}async read(){this._group.flush();let e=this.buffer,r=this._group.device;if(e.mapState==="mapped"){let s=e.getMappedRange();return M(new (0, _typedbinary.BufferReader)(s),this.dataType)}if(e.usage&GPUBufferUsage.MAP_READ){await e.mapAsync(GPUMapMode.READ);let s=e.getMappedRange(),i=M(new (0, _typedbinary.BufferReader)(s),this.dataType);return e.unmap(),i}let n=r.createBuffer({size:_chunkA5APHF7Kcjs.ic.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(e,0,n,0,_chunkA5APHF7Kcjs.ic.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunkA5APHF7Kcjs.ic.call(void 0, this.dataType));let o=M(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}as(e){return _optionalChain([go, 'access', _25 => _25[e], 'optionalCall', _26 => _26(this)])}destroy(){this._destroyed||(this._destroyed=!0,this._ownBuffer&&_optionalChain([this, 'access', _27 => _27._buffer, 'optionalAccess', _28 => _28.destroy, 'call', _29 => _29()]))}toString(){return`buffer:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}}, _class9);function ya(t,e){return new Kt(_chunkLL6NPRFEcjs.s.call(void 0, ),t,e)}function Ta(t,e){return new Kt(_chunkLL6NPRFEcjs.t.call(void 0, ),t,e)}function et(t){let e=t;return _optionalChain([e, 'optionalAccess', _30 => _30.resourceType])==="sampler"&&!!e[_chunkA5APHF7Kcjs.a]}function tt(t){let e=t;return _optionalChain([e, 'optionalAccess', _31 => _31.resourceType])==="sampler-comparison"&&!!e[_chunkA5APHF7Kcjs.a]}var Ht= (_class10 =class{constructor(e,r){;_class10.prototype.__init19.call(this);this.schema=e;this.#e=r,this.resourceType=e.type==="sampler_comparison"?"sampler-comparison":"sampler",_chunkA5APHF7Kcjs.k.call(void 0, this,r.key)}__init19() {this[_chunkA5APHF7Kcjs.a]={unwrap:void 0}}#e;[_chunkA5APHF7Kcjs.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};`),_chunkA5APHF7Kcjs.aa.call(void 0, r,this.schema)}get[_chunkA5APHF7Kcjs.b](){let e=this.schema;return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,e)},[_chunkA5APHF7Kcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},G)}get $(){if(_chunkA5APHF7Kcjs.Da.call(void 0, ))return this[_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}}, _class10),Kt=class{constructor(e,r,n){this.schema=e;this.#t=r,this.#n=n,this.resourceType=e.type==="sampler_comparison"?"sampler-comparison":"sampler",this[_chunkA5APHF7Kcjs.a]={unwrap:()=>(this.#r||(this.#r=this.#n.device.createSampler({...this.#t,label:_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))})),this.#r)},this.#e=r.minFilter==="linear"||r.magFilter==="linear"||r.mipmapFilter==="linear"}#e;#r=null;#t;#n;[_chunkA5APHF7Kcjs.f](e){let r=e.getUniqueName(this),{group:n,binding:a}=e.allocateFixedEntry(this.schema.type==="sampler_comparison"?{sampler:"comparison"}:{sampler:this.#e?"filtering":"non-filtering"},this);return e.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${e.resolve(this.schema).value};`),_chunkA5APHF7Kcjs.aa.call(void 0, r,this.schema)}get[_chunkA5APHF7Kcjs.b](){let e=this.schema;return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,e)},[_chunkA5APHF7Kcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},G)}get $(){if(_chunkA5APHF7Kcjs.Da.call(void 0, ))return this[_chunkA5APHF7Kcjs.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(e){return _chunkA5APHF7Kcjs.k.call(void 0, this,e),this}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}};var Yt= (_class11 =class{constructor(e,r){;_class11.prototype.__init20.call(this);_class11.prototype.__init21.call(this);this.schema=e;this.#e=r,_chunkA5APHF7Kcjs.k.call(void 0, this,r.key)}__init20() {this.resourceType="external-texture"}__init21() {this[_chunkA5APHF7Kcjs.a]=!0}#e;[_chunkA5APHF7Kcjs.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};`),_chunkA5APHF7Kcjs.aa.call(void 0, r,_chunkLL6NPRFEcjs.O.call(void 0, ))}get[_chunkA5APHF7Kcjs.b](){let e=this.schema;return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,e)},[_chunkA5APHF7Kcjs.f]:r=>r.resolve(this),toString:()=>`textureExternal:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},G)}get $(){if(_chunkA5APHF7Kcjs.Da.call(void 0, ))return this[_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}}, _class11);function Jt(t){return"displayWidth"in t&&"displayHeight"in t?{width:t.displayWidth,height:t.displayHeight}:{width:t.width,height:t.height}}var Gr=new WeakMap;function ha(t){let e=Gr.get(t);return e||(e=new Map,Gr.set(t,e)),e}function xa(t){let e=Gr.get(t);e&&e.clear()}function wa(t,e,r=0,n){if(e.dimension!=="2d")throw new Error("Cannot generate mipmaps for non-2D textures: only 2D textures are currently supported.");let a=_nullishCoalesce(n, () => (e.mipLevelCount-r)),o=_chunkU3CXOCRGcjs.b.call(void 0, e.format,t);if(![...o.sampleTypes].some(i=>i==="float"||i==="unfilterable-float"))throw new Error(`Cannot generate mipmaps for format '${e.format}': only float and unfilterable-float formats are currently supported.`);if(!o.canRenderAttachment)throw new Error(`Cannot generate mipmaps for format '${e.format}': format does not support render attachments.`);for(let i=0;i<e.depthOrArrayLayers;i++)for(let u=r;u<r+a-1;u++){let p=u,m=u+1;xo(t,e,p,m,i)}}function ba(t,e,r,n){if(e.dimension==="3d")throw new Error("Cannot resample to 3D textures: only 2D textures are currently supported.");let a=_chunkU3CXOCRGcjs.a[e.format];if(![...a.sampleTypes].some(s=>s==="float"||s==="unfilterable-float"))throw new Error(`Cannot resample to format '${e.format}': only float and unfilterable-float formats are currently supported.`);if(!a.canRenderAttachment)throw new Error(`Cannot resample to format '${e.format}': format does not support render attachments.`);return ho(t,e,r,n)}function ho(t,e,r,n=0){let o=[..._chunkU3CXOCRGcjs.a[e.format].sampleTypes].includes("float"),s=`${o?"filterable":"unfilterable"}`,i=ha(t),u=i.get(s);if(!u){let F=t.createShaderModule({code:`
|
|
17
|
-
struct VertexOutput {
|
|
18
|
-
@builtin(position) pos: vec4f,
|
|
19
|
-
@location(0) uv: vec2f,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@vertex
|
|
23
|
-
fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
24
|
-
let pos = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));
|
|
25
|
-
let uv = array<vec2f, 3>(vec2f(0, 1), vec2f(2, 1), vec2f(0, -1));
|
|
26
|
-
|
|
27
|
-
var output: VertexOutput;
|
|
28
|
-
output.pos = vec4f(pos[vertexIndex], 0, 1);
|
|
29
|
-
output.uv = uv[vertexIndex];
|
|
30
|
-
return output;
|
|
31
|
-
}
|
|
32
|
-
`}),_e=t.createSampler({magFilter:o?"linear":"nearest",minFilter:o?"linear":"nearest"}),We=t.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:o?"filtering":"non-filtering"}}]}),lr=t.createPipelineLayout({bindGroupLayouts:[We]}),Qa=t.createShaderModule({code:`
|
|
33
|
-
@group(0) @binding(0) var inputTexture: texture_2d<f32>;
|
|
34
|
-
@group(0) @binding(1) var inputSampler: sampler;
|
|
35
|
-
|
|
36
|
-
@fragment
|
|
37
|
-
fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
38
|
-
${o?"return textureSample(inputTexture, inputSampler, uv);":`let texelCoord = vec2u(uv * vec2f(textureDimensions(inputTexture)));
|
|
39
|
-
return textureLoad(inputTexture, texelCoord, 0);`}
|
|
40
|
-
}
|
|
41
|
-
`});u={vertexShader:F,fragmentShader:Qa,bindGroupLayout:We,pipelineLayout:lr,sampler:_e},i.set(s,u)}let p=t.createTexture({size:[...Object.values(Jt(r))],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_DST}),{width:m,height:c}=Jt(r);t.queue.copyExternalImageToTexture({source:r},{texture:p},[m,c,1]);let y=t.createTexture({size:[e.width,e.height,1],format:e.format,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),h=t.createRenderPipeline({layout:u.pipelineLayout,vertex:{module:u.vertexShader},fragment:{module:u.fragmentShader,targets:[{format:e.format}]},primitive:{topology:"triangle-list"}}),v=t.createBindGroup({layout:u.bindGroupLayout,entries:[{binding:0,resource:p.createView()},{binding:1,resource:u.sampler}]}),x=t.createCommandEncoder(),P=x.beginRenderPass({colorAttachments:[{view:y.createView(),loadOp:"clear",storeOp:"store"}]});P.setPipeline(h),P.setBindGroup(0,v),P.draw(3),P.end(),x.copyTextureToTexture({texture:y},{texture:e,origin:{x:0,y:0,z:n}},{width:e.width,height:e.height,depthOrArrayLayers:1}),t.queue.submit([x.finish()]),p.destroy(),y.destroy()}function xo(t,e,r,n,a){let s=[..._chunkU3CXOCRGcjs.b.call(void 0, e.format,t).sampleTypes].includes("float"),i=`${s?"filterable":"unfilterable"}`,u=ha(t),p=u.get(i);if(!p){let P=t.createShaderModule({code:`
|
|
42
|
-
struct VertexOutput {
|
|
43
|
-
@builtin(position) pos: vec4f,
|
|
44
|
-
@location(0) uv: vec2f,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@vertex
|
|
48
|
-
fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
49
|
-
let pos = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));
|
|
50
|
-
let uv = array<vec2f, 3>(vec2f(0, 1), vec2f(2, 1), vec2f(0, -1));
|
|
51
|
-
|
|
52
|
-
var output: VertexOutput;
|
|
53
|
-
output.pos = vec4f(pos[vertexIndex], 0, 1);
|
|
54
|
-
output.uv = uv[vertexIndex];
|
|
55
|
-
return output;
|
|
56
|
-
}
|
|
57
|
-
`}),F=t.createShaderModule({code:`
|
|
58
|
-
@group(0) @binding(0) var inputTexture: texture_2d<f32>;
|
|
59
|
-
@group(0) @binding(1) var inputSampler: sampler;
|
|
60
|
-
|
|
61
|
-
@fragment
|
|
62
|
-
fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
63
|
-
return textureSample(inputTexture, inputSampler, uv);
|
|
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]});p={vertexShader:P,fragmentShader:F,bindGroupLayout:We,pipelineLayout:lr,sampler:_e},u.set(i,p)}let m=t.createRenderPipeline({layout:p.pipelineLayout,vertex:{module:p.vertexShader},fragment:{module:p.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:p.bindGroupLayout,entries:[{binding:0,resource:c},{binding:1,resource:p.sampler}]}),v=t.createCommandEncoder(),x=v.beginRenderPass({colorAttachments:[{view:y,loadOp:"clear",storeOp:"store"}]});x.setPipeline(m),x.setBindGroup(0,h),x.draw(3),x.end(),t.queue.submit([v.finish()])}function wo(t){return{dimension:_nullishCoalesce(t.dimension, () => ("2d")),sampleType:_chunkU3CXOCRGcjs.a[t.format].channelType,multisampled:(_nullishCoalesce(t.sampleCount, () => (1)))!==1}}function bo(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 Rr(t,e)}function ee(t){return _optionalChain([t, 'optionalAccess', _32 => _32.resourceType])==="texture"&&!!t[_chunkA5APHF7Kcjs.a]}function nt(t){return _optionalChain([t, 'optionalAccess', _33 => _33.resourceType])==="texture-view"&&!!t[_chunkA5APHF7Kcjs.a]}var Rr= (_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=_chunkU3CXOCRGcjs.a[n],this.#r=e.size[0]*(_nullishCoalesce(e.size[1], () => (1)))*(_nullishCoalesce(e.size[2], () => (1)))*this.#e.texelSize,this.aspects=bo(n),this[_chunkA5APHF7Kcjs.a]={unwrap:()=>{if(this.#t)throw new Error("This texture has been destroyed");return this.#a||(this.#a=r.device.createTexture({label:_nullishCoalesce(_chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.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, () => (_chunkLL6NPRFEcjs.w.call(void 0, wo(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[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a].unwrap(),e,r);return}this.#o.device.queue.copyExternalImageToTexture({source:e},{texture:this[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a].unwrap()},{texture:this[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a]={unwrap:()=>{if(!this.#r){let a=this.schema,o;_chunkLL6NPRFEcjs.Q.call(void 0, a)?o={label:_nullishCoalesce(_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a].unwrap().createView(o)}return this.#r}}}__init26() {this.resourceType="texture-view"}#e;#r;#t;$name(e){return _chunkA5APHF7Kcjs.k.call(void 0, this,e),this.#r&&(this.#r.label=e),this}get[_chunkA5APHF7Kcjs.b](){let e=this.schema;return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,e)},[_chunkA5APHF7Kcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},G)}get $(){if(_chunkA5APHF7Kcjs.Da.call(void 0, ))return this[_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}[_chunkA5APHF7Kcjs.f](e){let r=e.getUniqueName(this),{group:n,binding:a}=e.allocateFixedEntry(_chunkLL6NPRFEcjs.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};`),_chunkA5APHF7Kcjs.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,_chunkA5APHF7Kcjs.k.call(void 0, this,r.key)}__init27() {this[_chunkA5APHF7Kcjs.a]={unwrap:void 0}}__init28() {this.resourceType="texture-view"}#e;toString(){return`textureView:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}[_chunkA5APHF7Kcjs.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};`),_chunkA5APHF7Kcjs.aa.call(void 0, r,this.schema)}get[_chunkA5APHF7Kcjs.b](){let e=this.schema;return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,e)},[_chunkA5APHF7Kcjs.f]:r=>r.resolve(this),toString:()=>`${this.toString()}.$`},G)}get $(){if(_chunkA5APHF7Kcjs.Da.call(void 0, ))return this[_chunkA5APHF7Kcjs.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 So(t){return!!_optionalChain([t, 'optionalAccess', _48 => _48.usableAsRender])}var Xt=class t extends Error{constructor(e){super(`Resource '${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, e), () => ("<unnamed>"))}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,t.prototype)}};function vo(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:_chunkLL6NPRFEcjs.w.call(void 0, {dimension:_nullishCoalesce(n.viewDimension, () => ("2d")),sampleType:a==="sint"?_chunkA5APHF7Kcjs.Ua:a==="uint"?_chunkA5APHF7Kcjs.Sa:_chunkA5APHF7Kcjs.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:_chunkLL6NPRFEcjs.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=vo(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"?_chunkLL6NPRFEcjs.t.call(void 0, ):_chunkLL6NPRFEcjs.s.call(void 0, ),o)),Object.defineProperty(this.value,n,{get:()=>this.bound[n].value}),r++}}__init29() {this[_chunkA5APHF7Kcjs.a]=!0}__init30() {this.resourceType="bind-group-layout"}__init31() {this.bound={}}__init32() {this.value={}}__init33() {this.$=this.value}get[_chunkA5APHF7Kcjs.b](){return this.$}toString(){return`bindGroupLayout:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get index(){return this._index}$name(e){return _chunkA5APHF7Kcjs.k.call(void 0, this,e),this}$idx(e){return this._index=e,this}unwrap(e){return e.device.createBindGroupLayout({label:_nullishCoalesce(_chunkA5APHF7Kcjs.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:p}=n.texture;s.texture={sampleType:_nullishCoalesce(n.sampleType, () => (p[0])),viewDimension:u,multisampled:i}}else if("storageTexture"in n){o=_nullishCoalesce(o, () => (va));let{dimension:i,access:u,format:p}=n.storageTexture;s.storageTexture={access:u,format:p,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(_chunkA5APHF7Kcjs.j.call(void 0, e),n)}__init34() {this.resourceType="bind-group"}unwrap(e){return e.device.createBindGroup({label:_nullishCoalesce(_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.j.call(void 0, this.layout), () => ("<unnamed>"))}'.`);if("uniform"in a){let i;if(pe(s)){if(!jt(s))throw new (0, _chunkA5APHF7Kcjs.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: ${_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a]=!0}__init36() {this.resourceType="slot"}$name(e){return _chunkA5APHF7Kcjs.k.call(void 0, this,e),this}areEqual(e,r){return Object.is(e,r)}toString(){return`slot:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunkA5APHF7Kcjs.b](){let e=_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.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 Io(t){return t instanceof ot}var ot= (_class18 =class{__init37() {this[_chunkA5APHF7Kcjs.a]={}}#e;#r;#t;constructor(e,r,n){;_class18.prototype.__init37.call(this);this.#e=e,this.#r=r,this.#t=n}[_chunkA5APHF7Kcjs.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};`),_chunkA5APHF7Kcjs.aa.call(void 0, r,this.#r)}$name(e){return _chunkA5APHF7Kcjs.k.call(void 0, this,e),this}toString(){return`var:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get[_chunkA5APHF7Kcjs.b](){let e=this.#r;return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,get[_chunkA5APHF7Kcjs.e](){return _chunkA5APHF7Kcjs.aa.call(void 0, this,e)},[_chunkA5APHF7Kcjs.f]:r=>r.resolve(this),toString:()=>`var:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},G)}get $(){let e=_chunkA5APHF7Kcjs.Ca.call(void 0, ),r=_chunkA5APHF7Kcjs.ya.call(void 0, );if(e.type==="normal")throw new (0, _chunkA5APHF7Kcjs.ja)(r?`Cannot access variable '${_nullishCoalesce(_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.b]:e.type==="simulate"?(e.vars[this.#e].has(this)||e.vars[this.#e].set(this,this.#t),e.vars[this.#e].get(this)):_chunkA5APHF7Kcjs.Ga.call(void 0, e,"tgpuVariable.ts#TgpuVarImpl/$")}set $(e){let r=_chunkA5APHF7Kcjs.Ca.call(void 0, ),n=_chunkA5APHF7Kcjs.ya.call(void 0, );if(r.type==="normal")throw new (0, _chunkA5APHF7Kcjs.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}_chunkA5APHF7Kcjs.Ga.call(void 0, r,"tgpuVariable.ts#TgpuVarImpl/$")}get value(){return this.$}set value(e){this.$=e}}, _class18);var Ia=Ee(_chunkA5APHF7Kcjs.Sa,0).$name("dataBlockIndex"),Ua=Ee(_chunkA5APHF7Kcjs.Sa,0).$name("dataByteIndex"),Fa=he().$name("dataBuffer"),Uo=U([],_chunkA5APHF7Kcjs.Sa)`() {
|
|
66
|
-
let i = dataByteIndex;
|
|
67
|
-
dataByteIndex = dataByteIndex + 1u;
|
|
68
|
-
return i;
|
|
69
|
-
}`.$uses({dataByteIndex:Ua}).$name("nextByteIndex"),d="dataBuffer[dataBlockIndex].serializedData[nextByteIndex()]",Pa={f32:U([_chunkA5APHF7Kcjs.Va])`(n) => {
|
|
70
|
-
${d} = bitcast<u32>(n);
|
|
71
|
-
}`,f16:U([_chunkA5APHF7Kcjs.Wa])`(n) => {
|
|
72
|
-
${d} = pack2x16float(vec2f(f32(n), 0.0));
|
|
73
|
-
}`,i32:U([_chunkA5APHF7Kcjs.Ua])`(n) => {
|
|
74
|
-
${d} = bitcast<u32>(n);
|
|
75
|
-
}`,u32:U([_chunkA5APHF7Kcjs.Sa])`(n) => {
|
|
76
|
-
${d} = n;
|
|
77
|
-
}`,bool:U([_chunkA5APHF7Kcjs.Ra])`(b) => {
|
|
78
|
-
${d} = u32(b);
|
|
79
|
-
}`,vec2f:U([_chunkA5APHF7Kcjs.Ya])`(v) => {
|
|
80
|
-
${d} = bitcast<u32>(v.x);
|
|
81
|
-
${d} = bitcast<u32>(v.y);
|
|
82
|
-
}`,vec3f:U([_chunkA5APHF7Kcjs.bb])`(v) => {
|
|
83
|
-
${d} = bitcast<u32>(v.x);
|
|
84
|
-
${d} = bitcast<u32>(v.y);
|
|
85
|
-
${d} = bitcast<u32>(v.z);
|
|
86
|
-
}`,vec4f:U([_chunkA5APHF7Kcjs.gb])`(v) => {
|
|
87
|
-
${d} = bitcast<u32>(v.x);
|
|
88
|
-
${d} = bitcast<u32>(v.y);
|
|
89
|
-
${d} = bitcast<u32>(v.z);
|
|
90
|
-
${d} = bitcast<u32>(v.w);
|
|
91
|
-
}`,vec2h:U([_chunkA5APHF7Kcjs.Za])`(v) => {
|
|
92
|
-
${d} = pack2x16float(vec2f(f32(v.x), f32(v.y)));
|
|
93
|
-
}`,vec3h:U([_chunkA5APHF7Kcjs.cb])`(v) => {
|
|
94
|
-
${d} = pack2x16float(vec2f(f32(v.x), f32(v.y)));
|
|
95
|
-
${d} = pack2x16float(vec2f(f32(v.z), 0.0));
|
|
96
|
-
}`,vec4h:U([_chunkA5APHF7Kcjs.hb])`(v) => {
|
|
97
|
-
${d} = pack2x16float(vec2f(f32(v.x), f32(v.y)));
|
|
98
|
-
${d} = pack2x16float(vec2f(f32(v.z), f32(v.w)));
|
|
99
|
-
}`,vec2i:U([_chunkA5APHF7Kcjs._a])`(v) => {
|
|
100
|
-
${d} = bitcast<u32>(v.x);
|
|
101
|
-
${d} = bitcast<u32>(v.y);
|
|
102
|
-
}`,vec3i:U([_chunkA5APHF7Kcjs.db])`(v) => {
|
|
103
|
-
${d} = bitcast<u32>(v.x);
|
|
104
|
-
${d} = bitcast<u32>(v.y);
|
|
105
|
-
${d} = bitcast<u32>(v.z);
|
|
106
|
-
}`,vec4i:U([_chunkA5APHF7Kcjs.ib])`(v) => {
|
|
107
|
-
${d} = bitcast<u32>(v.x);
|
|
108
|
-
${d} = bitcast<u32>(v.y);
|
|
109
|
-
${d} = bitcast<u32>(v.z);
|
|
110
|
-
${d} = bitcast<u32>(v.w);
|
|
111
|
-
}`,vec2u:U([_chunkA5APHF7Kcjs.$a])`(v) => {
|
|
112
|
-
${d} = v.x;
|
|
113
|
-
${d} = v.y;
|
|
114
|
-
}`,vec3u:U([_chunkA5APHF7Kcjs.eb])`(v) => {
|
|
115
|
-
${d} = v.x;
|
|
116
|
-
${d} = v.y;
|
|
117
|
-
${d} = v.z;
|
|
118
|
-
}`,vec4u:U([_chunkA5APHF7Kcjs.jb])`(v) => {
|
|
119
|
-
${d} = v.x;
|
|
120
|
-
${d} = v.y;
|
|
121
|
-
${d} = v.z;
|
|
122
|
-
${d} = v.w;
|
|
123
|
-
}`,"vec2<bool>":U([_chunkA5APHF7Kcjs.ab])`(v) => {
|
|
124
|
-
${d} = u32(v.x);
|
|
125
|
-
${d} = u32(v.y);
|
|
126
|
-
}`,"vec3<bool>":U([_chunkA5APHF7Kcjs.fb])`(v) => {
|
|
127
|
-
${d} = u32(v.x);
|
|
128
|
-
${d} = u32(v.y);
|
|
129
|
-
${d} = u32(v.z);
|
|
130
|
-
}`,"vec4<bool>":U([_chunkA5APHF7Kcjs.kb])`(v) => {
|
|
131
|
-
${d} = u32(v.x);
|
|
132
|
-
${d} = u32(v.y);
|
|
133
|
-
${d} = u32(v.z);
|
|
134
|
-
${d} = u32(v.w);
|
|
135
|
-
}`,mat2x2f:U([_chunkLL6NPRFEcjs.j])`(m) => {
|
|
136
|
-
${d} = bitcast<u32>(m[0][0]);
|
|
137
|
-
${d} = bitcast<u32>(m[0][1]);
|
|
138
|
-
${d} = bitcast<u32>(m[1][0]);
|
|
139
|
-
${d} = bitcast<u32>(m[1][1]);
|
|
140
|
-
}`,mat3x3f:U([_chunkLL6NPRFEcjs.k])`(m) => {
|
|
141
|
-
${d} = bitcast<u32>(m[0][0]);
|
|
142
|
-
${d} = bitcast<u32>(m[0][1]);
|
|
143
|
-
${d} = bitcast<u32>(m[0][2]);
|
|
144
|
-
${d} = 0u;
|
|
145
|
-
${d} = bitcast<u32>(m[1][0]);
|
|
146
|
-
${d} = bitcast<u32>(m[1][1]);
|
|
147
|
-
${d} = bitcast<u32>(m[1][2]);
|
|
148
|
-
${d} = 0u;
|
|
149
|
-
${d} = bitcast<u32>(m[2][0]);
|
|
150
|
-
${d} = bitcast<u32>(m[2][1]);
|
|
151
|
-
${d} = bitcast<u32>(m[2][2]);
|
|
152
|
-
${d} = 0u;
|
|
153
|
-
}`,mat4x4f:U([_chunkLL6NPRFEcjs.l])`(m) => {
|
|
154
|
-
${d} = bitcast<u32>(m[0][0]);
|
|
155
|
-
${d} = bitcast<u32>(m[0][1]);
|
|
156
|
-
${d} = bitcast<u32>(m[0][2]);
|
|
157
|
-
${d} = bitcast<u32>(m[0][3]);
|
|
158
|
-
${d} = bitcast<u32>(m[1][0]);
|
|
159
|
-
${d} = bitcast<u32>(m[1][1]);
|
|
160
|
-
${d} = bitcast<u32>(m[1][2]);
|
|
161
|
-
${d} = bitcast<u32>(m[1][3]);
|
|
162
|
-
${d} = bitcast<u32>(m[2][0]);
|
|
163
|
-
${d} = bitcast<u32>(m[2][1]);
|
|
164
|
-
${d} = bitcast<u32>(m[2][2]);
|
|
165
|
-
${d} = bitcast<u32>(m[2][3]);
|
|
166
|
-
${d} = bitcast<u32>(m[3][0]);
|
|
167
|
-
${d} = bitcast<u32>(m[3][1]);
|
|
168
|
-
${d} = bitcast<u32>(m[3][2]);
|
|
169
|
-
${d} = bitcast<u32>(m[3][3]);
|
|
170
|
-
}`};for(let[t,e]of Object.entries(Pa))e.$name(`serialize${t[0].toLocaleUpperCase()}${t.slice(1)}`).$uses({dataBlockIndex:Ia,nextByteIndex:Uo,dataBuffer:Fa});function Da(t){return`(${t.map((e,r)=>`_arg_${r}`).join(", ")})`}function Ba(t,e){let r=Pa[t.type];if(r)return r.with(Fa,e);if(_chunkA5APHF7Kcjs.D.call(void 0, t)){let n=Object.keys(t.propTypes),a=Object.values(t.propTypes),o=$a(a,e);return U([t])`(arg) {\n propsSerializer(${n.map(s=>`arg.${s}`).join(", ")});\n}`.$uses({propsSerializer:o}).$name(`${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, t), () => ("struct"))}Serializer`)}if(_chunkA5APHF7Kcjs.C.call(void 0, t)){let n=t.elementType,a=t.elementCount,o=Ba(n,e);return U([t])`(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 ${t.type}`)}function $a(t,e){let r={},n=U(t),a=Da(t),o=t.map((s,i)=>(r[`serializer${i}`]=Ba(s,e),` serializer${i}(_arg_${i});`)).join(`
|
|
172
|
-
`);return n`${a} {\n${o}\n}`.$uses(r).$name("compoundSerializer")}function Aa(t,e,r,n,a){let o=e.map(_chunkA5APHF7Kcjs.ic).reduce((u,p)=>u+p,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=$a(e,r).$name(`log${t}serializer`),i=Da(e);return U(e)`${i} {
|
|
173
|
-
dataBlockIndex = atomicAdd(&indexBuffer, 1);
|
|
174
|
-
if (dataBlockIndex >= ${a.logCountLimit}) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
dataBuffer[dataBlockIndex].id = ${t};
|
|
178
|
-
dataByteIndex = 0;
|
|
179
|
-
|
|
180
|
-
compoundSerializer${i};
|
|
181
|
-
}`.$uses({indexBuffer:n,dataBuffer:r,dataBlockIndex:Ia,dataByteIndex:Ua,compoundSerializer:s}).$name(`log${t}`)}var La=["log","debug","info","warn","error","clear"];var Fo={logCountLimit:64,logSizeLimit:252,messagePrefix:" GPU "},Ga=_chunkA5APHF7Kcjs.aa.call(void 0, "/* console.log() */",_chunkA5APHF7Kcjs.q),tr=class{get logResources(){}generateLog(){return console.warn("'console.log' is currently only supported in compute pipelines."),Ga}},rr=class{#e;#r;#t=1;#n;#a;constructor(e){this.#e={...Fo,...e[_chunkA5APHF7Kcjs.a].logOptions},this.#r=new Map;let r=_chunkA5APHF7Kcjs.sc.call(void 0, {id:_chunkA5APHF7Kcjs.Sa,serializedData:_chunkA5APHF7Kcjs.uc.call(void 0, _chunkA5APHF7Kcjs.Sa,Math.ceil(this.#e.logSizeLimit/4))}).$name("SerializedLogData");this.#a=e.createMutable(_chunkA5APHF7Kcjs.uc.call(void 0, r,this.#e.logCountLimit)).$name("dataBuffer"),this.#n=e.createMutable(_chunkLL6NPRFEcjs.R.call(void 0, _chunkA5APHF7Kcjs.Sa)).$name("indexBuffer")}generateLog(e,r,n){if(!La.includes(r))return console.warn(`Unsupported log method '${r}' was used in TGSL.`),Ga;let a=_chunkLL6NPRFEcjs.q.call(void 0, n),o=this.#t++,s=a.filter(p=>p.dataType!==_chunkA5APHF7Kcjs.W),i=Aa(o,s.map(p=>p.dataType),this.#a,this.#n,this.#e),u=a.map(p=>p.dataType===_chunkA5APHF7Kcjs.W?p.value:p.dataType);return this.#r.set(o,{op:r,argTypes:u}),_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`${e.resolve(i).value}(${s})`,_chunkA5APHF7Kcjs.q)}get logResources(){return this.#t===1?void 0:{dataBuffer:this.#a,indexBuffer:this.#n,options:this.#e,logIdToMeta:this.#r}}};var Ra="#CATCHALL#",Or= (_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?_chunkLL6NPRFEcjs.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=[""," "," "," "," "," "," "," "," "],Mr=nr.length-1,zr= (_class20 =class{constructor() { _class20.prototype.__init40.call(this); }__init40() {this.identLevel=0}get pre(){return _nullishCoalesce(nr[this.identLevel], () => (nr[Mr].repeat(this.identLevel/Mr)+nr[this.identLevel%Mr]))}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 Or}#t=[];__init43() {this._declarations=[]}#n=new WeakSet;#a;get varyingLocations(){return this._varyingLocations}__init44() {this[_chunkA5APHF7Kcjs.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, () => (_chunkLL6NPRFEcjs.hb)),this.#a=e.root?new rr(e.root):new tr,this.#e=e.namespace[_chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.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;_chunkA5APHF7Kcjs.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,r){return this.#a.generateLog(this,e,r)}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=_chunkA5APHF7Kcjs.q;else{let s=_chunkA5APHF7Kcjs.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=_chunkLL6NPRFEcjs.p.call(void 0, a)}return{head:Po(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:Ra,binding:n}}readSlot(e){let r=this._itemStateStack.readSlot(e);if(r===void 0)throw new (0, _chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.oa.call(void 0, e))return this.withSlots(e[_chunkA5APHF7Kcjs.d].pairs,()=>this.unwrap(e[_chunkA5APHF7Kcjs.d].inner));let r=e;for(;;)if(_chunkA5APHF7Kcjs.ma.call(void 0, r))r=this.readSlot(r);else if(_chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.ca?n.appendToTrace(e):new (0, _chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.V.call(void 0, e))n=_chunkA5APHF7Kcjs.aa.call(void 0, Br(this,e),_chunkA5APHF7Kcjs.q);else if(_chunkA5APHF7Kcjs.na.call(void 0, e)||_chunkA5APHF7Kcjs.ma.call(void 0, e))n=this.resolve(this.unwrap(e));else if(_chunkA5APHF7Kcjs.ta.call(void 0, e))n=e[_chunkA5APHF7Kcjs.f](this);else if(_chunkA5APHF7Kcjs.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: ${_chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.ca?n.appendToTrace(e):new (0, _chunkA5APHF7Kcjs.ca)(n,[e])}finally{this._itemStateStack.popItem()}}resolve(e,r,n=!1){if(He(e)||_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.oa.call(void 0, e))return this.withSlots(e[_chunkA5APHF7Kcjs.d].pairs,()=>this.resolve(e[_chunkA5APHF7Kcjs.d].inner,r,n));if(_chunkA5APHF7Kcjs.h.call(void 0, e)||_chunkA5APHF7Kcjs.m.call(void 0, e)){if(this._itemStateStack.itemDepth===0)try{this.pushMode(new _chunkA5APHF7Kcjs.ra);let a=_chunkA5APHF7Kcjs.za.call(void 0, this,()=>this._getOrInstantiate(e));return _chunkA5APHF7Kcjs.aa.call(void 0, `${[...this._declarations].join(`
|
|
182
|
-
|
|
183
|
-
`)}${a.value}`,_chunkA5APHF7Kcjs.q)}finally{this.popMode("codegen")}return this._getOrInstantiate(e)}if(typeof e=="number"){let a=n?r:_chunkLL6NPRFEcjs.o.call(void 0, e).dataType,o=_nullishCoalesce(r, () => (_chunkLL6NPRFEcjs.o.call(void 0, e).dataType));if(_chunkA5APHF7Kcjs.ba.call(void 0, a,"Schema has to be defined for resolving numbers"),_chunkA5APHF7Kcjs.ba.call(void 0, o.type!=="unknown","Schema has to be known for resolving numbers"),a.type==="abstractInt")return _chunkA5APHF7Kcjs.aa.call(void 0, `${e}`,o);if(a.type==="u32")return _chunkA5APHF7Kcjs.aa.call(void 0, `${e}u`,o);if(a.type==="i32")return _chunkA5APHF7Kcjs.aa.call(void 0, `${e}i`,o);let s=e.toExponential(),i=a.type==="abstractFloat"&&Number.isInteger(e)?`${e}.`:`${e}`,u=s.length<i.length?s:i;return a.type==="f32"?_chunkA5APHF7Kcjs.aa.call(void 0, `${u}f`,o):a.type==="f16"?_chunkA5APHF7Kcjs.aa.call(void 0, `${u}h`,o):_chunkA5APHF7Kcjs.aa.call(void 0, u,o)}if(typeof e=="boolean")return _chunkA5APHF7Kcjs.aa.call(void 0, e?"true":"false",_chunkA5APHF7Kcjs.Ra);if(typeof e=="string")return _chunkA5APHF7Kcjs.aa.call(void 0, e,_chunkA5APHF7Kcjs.q);if(r&&_chunkA5APHF7Kcjs.C.call(void 0, r)){if(!Array.isArray(e))throw new (0, _chunkA5APHF7Kcjs.la)(`Cannot coerce ${e} into value of type '${r}'`);if(r.elementCount!==e.length)throw new (0, _chunkA5APHF7Kcjs.la)(`Cannot create value of type '${r}' from an array of length: ${e.length}`);let a=this.resolve(r.elementType);return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`array<${a}, ${r.elementCount}>(${e.map(o=>_chunkA5APHF7Kcjs.aa.call(void 0, o,r.elementType))})`,r)}if(Array.isArray(e))return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`array(${e.map(a=>this.resolve(a))})`,_chunkA5APHF7Kcjs.W);if(r&&_chunkA5APHF7Kcjs.D.call(void 0, r))return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`${this.resolve(r)}(${Object.entries(r.propTypes).map(([a,o])=>_chunkA5APHF7Kcjs.aa.call(void 0, e[a],o))})`,r);throw new (0, _chunkA5APHF7Kcjs.la)(`Value ${e} (as json: ${_chunkA5APHF7Kcjs.mb.call(void 0, e)}) is not resolvable${r?` to type ${r.type}`:""}`)}pushMode(e){this.#t.push(e)}popMode(e){let r=this.#t.pop();e!==void 0&&_chunkA5APHF7Kcjs.ba.call(void 0, _optionalChain([r, 'optionalAccess', _62 => _62.type])===e,"Unexpected mode")}get mode(){return _nullishCoalesce(this.#t[this.#t.length-1], () => (_chunkA5APHF7Kcjs.Ba))}}, _class21);function le(t,e){let r=new st(e),a=(e.config?r.withSlots(e.config(new Le([])).bindings,()=>r.resolve(t)):r.resolve(t)).value,o=r.bindGroupLayoutsToPlaceholderMap,s=[],i=new Set([...o.keys()].map(y=>y.index).filter(y=>y!==void 0)),u=oa(i),p=r.fixedBindings.map((y,h)=>[String(h),y.layoutEntry]),m=()=>{let y=u.next().value,h=Zt(Object.fromEntries(p));return s[y]=h,a=a.replaceAll(Ra,String(y)),[y,new Ce(h,Object.fromEntries(r.fixedBindings.map((v,x)=>[String(x),v.resource])))]},c=p.length>0?m():void 0;for(let[y,h]of o.entries()){let v=_nullishCoalesce(y.index, () => (u.next().value));s[v]=y,a=a.replaceAll(h,String(v))}return e.enableExtensions&&e.enableExtensions.length>0&&(a=`${e.enableExtensions.map(h=>`enable ${h};`).join(`
|
|
184
|
-
`)}
|
|
185
|
-
|
|
186
|
-
${a}`),{code:a,usedBindGroupLayouts:s,catchall:c,logResources:r.logResources}}function Po(t,e,r){let n=e.map(a=>`${a.value}: ${t.resolve(a.dataType).value}`).join(", ");return r.type!=="void"?`(${n}) -> ${_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a]}function qr(t){let e=t;return _optionalChain([e, 'optionalAccess', _64 => _64.resourceType])==="render-pipeline"&&!!e[_chunkA5APHF7Kcjs.a]}function Ca(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={};_chunkTRAG63HYcjs.a.call(void 0, i,_nullishCoalesce(e, () => ({})));let u={[_chunkA5APHF7Kcjs.a]:!0,[_chunkA5APHF7Kcjs.f](m){return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkTRAG63HYcjs.d.call(void 0, m,i,_nullishCoalesce(n, () => (""))),_chunkA5APHF7Kcjs.q)},toString:()=>"<root>"},p=Object.values(e).filter(Ca);if(p.length>1)throw new Error(`Found ${p.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([p, 'access', _65 => _65[0], 'optionalAccess', _66 => _66[_chunkA5APHF7Kcjs.a], 'access', _67 => _67.branch])})}function Ea(t){return jr(t).code}function Va(t){let e=_nullishCoalesce(_chunkA5APHF7Kcjs.Aa.call(void 0, ), () => (new st({namespace:j(),shaderGenerator:_chunkLL6NPRFEcjs.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]},(p,m)=>Array.from({length:a[1]},(c,y)=>Array.from({length:a[2]},(h,v)=>{let x=Math.floor(m/n[0]),P=Math.floor(y/n[1]),F=Math.floor(v/n[2]);return new (0, _chunkA5APHF7Kcjs.sa)(o,{private:i[m][y][v],workgroup:s[x][P][F]})})));e.pushMode(u[0][0][0]);try{return{value:_chunkA5APHF7Kcjs.za.call(void 0, e,t),buffers:o,privateVars:i,workgroupVars:s}}finally{e.popMode("simulate")}}function _a(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[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a].resolveBuffer,0,this[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.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 Do(t){return t instanceof xe}var xe= (_class24 =class{constructor(e,r){;_class24.prototype.__init55.call(this);this.resourceType=e;this.buffer=r;this[_chunkA5APHF7Kcjs.c]=r,this.#e=this.buffer.as(this.resourceType)}__init55() {this[_chunkA5APHF7Kcjs.a]=!0}#e;$name(e){return _chunkA5APHF7Kcjs.k.call(void 0, this[_chunkA5APHF7Kcjs.c],e),this}write(e){this.buffer.write(e)}writePartial(e){this.buffer.writePartial(e)}read(){return this.buffer.read()}get[_chunkA5APHF7Kcjs.b](){return this.#e.$}get $(){return this.#e.$}get value(){return this.$}[_chunkA5APHF7Kcjs.f](e){return e.resolve(this.#e)}}, _class24);var b=t=>_chunkU3CXOCRGcjs.c.call(void 0, _nullishCoalesce(t, () => (0))),Q=t=>_chunkU3CXOCRGcjs.d.call(void 0, _nullishCoalesce(t, () => (0))),Ve=t=>_chunkU3CXOCRGcjs.e.call(void 0, _nullishCoalesce(t, () => (0))),Bo={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=>_chunkA5APHF7Kcjs.Ya.call(void 0, b(t[0]),b(t[1])),vec3f:t=>_chunkA5APHF7Kcjs.bb.call(void 0, b(t[0]),b(t[1]),b(t[2])),vec4f:t=>_chunkA5APHF7Kcjs.gb.call(void 0, b(t[0]),b(t[1]),b(t[2]),b(t[3])),vec2h(t){let e=Ve(t[0]);return _chunkA5APHF7Kcjs.Za.call(void 0, e.x,e.y)},vec3h(t){let e=Ve(t[0]),r=Ve(t[1]);return _chunkA5APHF7Kcjs.cb.call(void 0, e.x,e.y,r.x)},vec4h(t){let e=Ve(t[0]),r=Ve(t[1]);return _chunkA5APHF7Kcjs.hb.call(void 0, e.x,e.y,r.x,r.y)},vec2i:t=>_chunkA5APHF7Kcjs._a.call(void 0, Q(t[0]),Q(t[1])),vec3i:t=>_chunkA5APHF7Kcjs.db.call(void 0, Q(t[0]),Q(t[1]),Q(t[2])),vec4i:t=>_chunkA5APHF7Kcjs.ib.call(void 0, Q(t[0]),Q(t[1]),Q(t[2]),Q(t[3])),vec2u:t=>_chunkA5APHF7Kcjs.$a.call(void 0, _nullishCoalesce(t[0], () => (0)),_nullishCoalesce(t[1], () => (0))),vec3u:t=>_chunkA5APHF7Kcjs.eb.call(void 0, _nullishCoalesce(t[0], () => (0)),_nullishCoalesce(t[1], () => (0)),_nullishCoalesce(t[2], () => (0))),vec4u:t=>_chunkA5APHF7Kcjs.jb.call(void 0, _nullishCoalesce(t[0], () => (0)),_nullishCoalesce(t[1], () => (0)),_nullishCoalesce(t[2], () => (0)),_nullishCoalesce(t[3], () => (0))),"vec2<bool>":t=>_chunkA5APHF7Kcjs.ab.call(void 0, !!t[0],!!t[1]),"vec3<bool>":t=>_chunkA5APHF7Kcjs.fb.call(void 0, !!t[0],!!t[1],!!t[2]),"vec4<bool>":t=>_chunkA5APHF7Kcjs.kb.call(void 0, !!t[0],!!t[1],!!t[2],!!t[3]),mat2x2f:t=>_chunkLL6NPRFEcjs.j.call(void 0, b(t[0]),b(t[1]),b(t[2]),b(t[3])),mat3x3f:t=>_chunkLL6NPRFEcjs.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=>_chunkLL6NPRFEcjs.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 $o(t,e){let r=Bo[e.type];if(r)return r(t);if(_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.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(!_chunkA5APHF7Kcjs.B.call(void 0, n))return n;let a=Math.ceil(_chunkA5APHF7Kcjs.ic.call(void 0, n)/4),o=$o(t.subarray(r,r+a),n);return r+=a,o})}function Ao(t,e){return Hr(t,e).map(_chunkA5APHF7Kcjs.nb)}function pt(t){let{indexBuffer:e,dataBuffer:r,logIdToMeta:n,options:a}=t;r.read().then(o=>{o.filter(s=>s.id).forEach(({id:s,serializedData:i})=>{let{argTypes:u,op:p}=n.get(s),m=Ao(new Uint32Array(i),u);m.length===0&&m.push(""),console[p](`%c${a.messagePrefix}%c ${m[0]}`,"background: #936ff5; color: white;","color: inherit; background: none",...m.slice(1))})}),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[_chunkA5APHF7Kcjs.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 Wa(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[_chunkA5APHF7Kcjs.a]={get rawPipeline(){return e.unwrap().pipeline},get priors(){return r},get branch(){return e.branch}},this[_chunkA5APHF7Kcjs.c]=e}__init56() {this.resourceType="compute-pipeline"}[_chunkA5APHF7Kcjs.f](e){return e.resolve(this._core)}toString(){return`computePipeline:${_nullishCoalesce(_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.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((p,m)=>{if(a.catchall&&m===a.catchall[0])i.setBindGroup(m,o.unwrap(a.catchall[1])),u.delete(p);else{let c=_optionalChain([this, 'access', _81 => _81._priors, 'access', _82 => _82.bindGroupLayoutMap, 'optionalAccess', _83 => _83.get, 'call', _84 => _84(p)]);c!==void 0&&(u.delete(p),i.setBindGroup(m,o.unwrap(c)))}}),u.size>0)throw new (0, _chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a]=!0}[_chunkA5APHF7Kcjs.f](e){return e.withSlots(this._slotBindings,()=>(e.resolve(this._entryFn),_chunkA5APHF7Kcjs.aa.call(void 0, "",_chunkA5APHF7Kcjs.q)))}toString(){return"computePipelineCore"}unwrap(){if(this._memo===void 0){let e=this.branch.device,r=_chunkU3CXOCRGcjs.i.filter(c=>this.branch.enabledFeatures.has(_chunkU3CXOCRGcjs.j[c])),n,a,o=j({names:this.branch.nameRegistrySetting});if(_optionalChain([_chunkA5APHF7Kcjs.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:p}=n;u!==void 0&&_optionalChain([i, 'access', _86 => _86[u[0]], 'optionalAccess', _87 => _87.$name, 'call', _88 => _88(`${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let m=e.createShaderModule({label:`${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:s});this._memo={pipeline:e.createComputePipeline({label:_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>")),layout:e.createPipelineLayout({label:`${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:i.map(c=>this.branch.unwrap(c))}),compute:{module:m}}),usedBindGroupLayouts:i,catchall:u,logResources:p},_optionalChain([_chunkA5APHF7Kcjs.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([_chunkA5APHF7Kcjs.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(_chunkA5APHF7Kcjs.L.call(void 0, e)||_chunkA5APHF7Kcjs.T.call(void 0, e)){let o=_chunkA5APHF7Kcjs.U.call(void 0, e);return o!==void 0&&(n[_nullishCoalesce(a, () => (Jr))]=o),ir(t,e.inner,_chunkA5APHF7Kcjs.hc.call(void 0, r,_chunkA5APHF7Kcjs.fc.call(void 0, e)),n)}if(_chunkA5APHF7Kcjs.D.call(void 0, e)){let o=r,s=e.propTypes;return Object.fromEntries(Object.entries(s).map(([i,u])=>{o=_chunkA5APHF7Kcjs.hc.call(void 0, o,_chunkA5APHF7Kcjs.ec.call(void 0, u));let p=[i,ir(t,u,o,n,i)];return o+=_chunkA5APHF7Kcjs.ic.call(void 0, u),p}))}if(_chunkA5APHF7Kcjs.S.call(void 0, e)){let o=r,s=e.propTypes;return Object.fromEntries(Object.entries(s).map(([i,u])=>{o=_chunkA5APHF7Kcjs.hc.call(void 0, o,_chunkA5APHF7Kcjs.fc.call(void 0, u));let p=[i,ir(t,u,o,n,i)];return o+=_chunkA5APHF7Kcjs.ic.call(void 0, u),p}))}if("type"in e&&typeof e.type=="string"){if(_chunkA5APHF7Kcjs.o.includes(e.type))return{_layout:t,format:e.type,offset:r};let o=_chunkA5APHF7Kcjs.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=_chunkA5APHF7Kcjs.hc.call(void 0, _chunkA5APHF7Kcjs.ic.call(void 0, n.elementType),_chunkA5APHF7Kcjs.ec.call(void 0, n)),this.attrib=ir(this,n.elementType,0,this._customLocationMap)}__init58() {this[_chunkA5APHF7Kcjs.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 _chunkA5APHF7Kcjs.k.call(void 0, this,e),this}}, _class27);function Lo(t){return typeof _optionalChain([t, 'optionalAccess', _94 => _94.loadOp])=="string"}function ka(t,e){if(_chunkA5APHF7Kcjs.V.call(void 0, t)){if(!Lo(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(_chunkA5APHF7Kcjs.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 Go(t){return typeof _optionalChain([t, 'optionalAccess', _95 => _95.format])=="string"}function Ma(t,e){if(_chunkA5APHF7Kcjs.V.call(void 0, t)){if(_chunkA5APHF7Kcjs.M.call(void 0, t))return[];if(!Go(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(_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a]={core:e,priors:r,branch:e.options.branch},this[_chunkA5APHF7Kcjs.c]=e}[_chunkA5APHF7Kcjs.f](e){return e.resolve(this[_chunkA5APHF7Kcjs.a].core)}toString(){return`renderPipeline:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}$name(e){return _chunkA5APHF7Kcjs.k.call(void 0, this[_chunkA5APHF7Kcjs.a].core,e),this}with(e,r){let n=this[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a],n=ar(r.priors,e,r.core.options.branch);return new t(r.core,n)}withTimestampWrites(e){let r=this[_chunkA5APHF7Kcjs.a],n=or(r.priors,e,r.core.options.branch);return new t(r.core,n)}withColorAttachment(e){let r=this[_chunkA5APHF7Kcjs.a];return new t(r.core,{...r.priors,colorAttachment:e})}withDepthStencilAttachment(e){let r=this[_chunkA5APHF7Kcjs.a];return new t(r.core,{...r.priors,depthStencilAttachment:e})}withIndexBuffer(e,r,n,a){let o=this[_chunkA5APHF7Kcjs.a];if(_chunkA5APHF7Kcjs.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*_chunkA5APHF7Kcjs.ic.call(void 0, i):void 0,sizeBytes:a!==void 0?a*_chunkA5APHF7Kcjs.ic.call(void 0, i):void 0}})}setupRenderPass(){let e=this[_chunkA5APHF7Kcjs.a],r=e.core.unwrap(),{branch:n,fragmentFn:a}=e.core.options,o=a?ka(a.shell.out,_nullishCoalesce(e.priors.colorAttachment, () => ({}))).map(c=>ee(c.view)?{...c,view:n.unwrap(c.view).createView()}:c):[null],s={label:_nullishCoalesce(_chunkA5APHF7Kcjs.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 p=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&&(p.delete(c),i.setVertexBuffer(y,n.unwrap(h)))}),u.size>0)throw new (0, _chunkA5APHF7Kcjs.ha)(u);if(p.size>0)throw new (0, _chunkA5APHF7Kcjs.ia)(p);return i}draw(e,r,n,a){let o=this[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a];if(!s.priors.indexBuffer)throw new Error("No index buffer set for this render pipeline.");let{buffer:i,indexFormat:u,offsetBytes:p,sizeBytes:m}=s.priors.indexBuffer,c=this.setupRenderPass(),{logResources:y}=s.core.unwrap(),{branch:h}=s.core.options;_chunkA5APHF7Kcjs.wa.call(void 0, i)?c.setIndexBuffer(i,u,p,m):c.setIndexBuffer(h.unwrap(i),u,p,m),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?Ma(e.fragmentFn.shell.out,e.targets):[null]}__init63() {this[_chunkA5APHF7Kcjs.a]=!0}[_chunkA5APHF7Kcjs.f](e){let{vertexFn:r,fragmentFn:n,slotBindings:a}=this.options,o=Ro(r.shell.out,_optionalChain([n, 'optionalAccess', _104 => _104.shell, 'access', _105 => _105.in]),_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, r), () => ("<unnamed>")),_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, n), () => ("<unnamed>")));return e.withVaryingLocations(o,()=>e.withSlots(a,()=>(e.resolve(r),n&&e.resolve(n),_chunkA5APHF7Kcjs.aa.call(void 0, "",_chunkA5APHF7Kcjs.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=_chunkU3CXOCRGcjs.i.filter(F=>e.enabledFeatures.has(_chunkU3CXOCRGcjs.j[F])),i,u,p=j({names:e.nameRegistrySetting});if(_optionalChain([_chunkA5APHF7Kcjs.i, 'optionalAccess', _106 => _106.enabled])){let F=performance.mark("typegpu:resolution:start");i=le(this,{namespace:p,enableExtensions:s,shaderGenerator:e.shaderGenerator,root:e}),u=performance.measure("typegpu:resolution",{start:F.name})}else i=le(this,{namespace:p,enableExtensions:s,shaderGenerator:e.shaderGenerator,root:e});let{code:m,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(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let v=o.createShaderModule({label:`${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:m}),x={layout:o.createPipelineLayout({label:`${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:c.map(F=>e.unwrap(F))}),vertex:{module:v,buffers:this._vertexBufferLayouts}},P=_chunkA5APHF7Kcjs.j.call(void 0, this);P!==void 0&&(x.label=P),this.options.fragmentFn&&(x.fragment={module:v,targets:this._targets}),r&&(_chunkA5APHF7Kcjs.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([_chunkA5APHF7Kcjs.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([_chunkA5APHF7Kcjs.i, 'optionalAccess', _111 => _111.record, 'call', _112 => _112("resolution",{resolveDuration:_optionalChain([u, 'optionalAccess', _113 => _113.duration]),compileDuration:_e.duration,wgslSize:m.length})])})()}return this._memo}}, _class29);function Ro(t,e,r,n){let a={},o=new Set;function s(u,p){a[u]=p,o.add(p)}for(let[u,p]of Object.entries(t)){let m=_chunkA5APHF7Kcjs.U.call(void 0, p);m!==void 0&&s(u,m)}for(let[u,p]of Object.entries(_nullishCoalesce(e, () => ({})))){let m=_chunkA5APHF7Kcjs.U.call(void 0, p);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(t, () => ({}))))if(!(_chunkA5APHF7Kcjs.pc.call(void 0, t[u])||a[u]!==void 0)){for(;o.has(i);)i++;s(u,i)}return a}function Co(t){if(t.includes(0))throw new Error("Size and workgroupSize cannot contain zeroes.");return _chunkA5APHF7Kcjs.eb.call(void 0, _nullishCoalesce(t[0], () => (1)),_nullishCoalesce(t[1], () => (1)),_nullishCoalesce(t[2], () => (1)))}var Eo=[_chunkA5APHF7Kcjs.eb.call(void 0, 1,1,1),_chunkA5APHF7Kcjs.eb.call(void 0, 256,1,1),_chunkA5APHF7Kcjs.eb.call(void 0, 16,16,1),_chunkA5APHF7Kcjs.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=_chunkA5APHF7Kcjs.eb.call(void 0, )}with(e){return new t(this.#e,this.#r.with(e),this.#t,this.#n)}dispatchThreads(...e){let r=Co(e),n=_chunkLL6NPRFEcjs.ha.call(void 0, _chunkA5APHF7Kcjs.bb.call(void 0, r).div(_chunkA5APHF7Kcjs.bb.call(void 0, this.#n)));_chunkU3CXOCRGcjs.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,[_chunkA5APHF7Kcjs.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=Eo[e.length],a=U([_chunkA5APHF7Kcjs.Sa,_chunkA5APHF7Kcjs.Sa,_chunkA5APHF7Kcjs.Sa])(e),o=r.createUniform(_chunkA5APHF7Kcjs.eb),s=Et({workgroupSize:n,in:{id:_chunkA5APHF7Kcjs.vc.globalInvocationId}})`{
|
|
187
|
-
if (any(in.id >= sizeUniform)) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
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 Le([]));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 Wa(this._root,this._slotBindings,this._entryFn)}},sn=class t{constructor(e){this._options=e}withFragment(e,r,n){return _chunkA5APHF7Kcjs.ba.call(void 0, typeof e!="string","Just type mismatch validation"),_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.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 _a(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[_chunkA5APHF7Kcjs.a].rawPipeline;if(qr(r))return r[_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.a].unwrap();if(nt(r)){if(!r[_chunkA5APHF7Kcjs.a].unwrap)throw new Error("Cannot unwrap laid-out texture view as it has no underlying resource.");return r[_chunkA5APHF7Kcjs.a].unwrap()}if(ur(r))return r.vertexLayout;if(et(r)||tt(r)){if(r[_chunkA5APHF7Kcjs.a].unwrap)return r[_chunkA5APHF7Kcjs.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:p,priors:m}=i[_chunkA5APHF7Kcjs.a],c=p.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([m, '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(p.usedVertexLayouts.forEach((v,x)=>{let P=_optionalChain([m, '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, _chunkA5APHF7Kcjs.ha)(y);if(h.size>0)throw new (0, _chunkA5APHF7Kcjs.ia)(h)};n({setViewport(...p){a.setViewport(...p)},setScissorRect(...p){a.setScissorRect(...p)},setBlendConstant(...p){a.setBlendConstant(...p)},setStencilReference(...p){a.setStencilReference(...p)},beginOcclusionQuery(...p){a.beginOcclusionQuery(...p)},endOcclusionQuery(...p){a.endOcclusionQuery(...p)},executeBundles(...p){a.executeBundles(...p)},setPipeline(p){i=p},setIndexBuffer:(p,m,c,y)=>{pe(p)?a.setIndexBuffer(this.unwrap(p),m,c,y):a.setIndexBuffer(p,m,c,y)},setVertexBuffer(p,m,c,y){s.set(p,{buffer:m,offset:c,size:y})},setBindGroup(p,m){o.set(p,m)},draw(p,m,c,y){u(),a.draw(p,m,c,y)},drawIndexed(...p){u(),a.drawIndexed(...p)},drawIndirect(...p){u(),a.drawIndirect(...p)},drawIndexedIndirect(...p){u(),a.drawIndexedIndirect(...p)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}}, _class30);async function Oa(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 za(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 Na(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[_chunkA5APHF7Kcjs.c]=this.slot}__init67() {this[_chunkA5APHF7Kcjs.a]=!0}__init68() {this.resourceType="accessor"}get[_chunkA5APHF7Kcjs.b](){return new Proxy({[_chunkA5APHF7Kcjs.a]:!0,[_chunkA5APHF7Kcjs.e]:this.#e(),[_chunkA5APHF7Kcjs.f]:e=>e.resolve(this),toString:()=>`accessor:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}.$`},G)}#e(){let e=_chunkA5APHF7Kcjs.Aa.call(void 0, ),r=ge(e.unwrap(this.slot));return He(r)?r[_chunkA5APHF7Kcjs.a].gpuImpl():_chunkA5APHF7Kcjs.aa.call(void 0, r,this.schema)}$name(e){return this.slot.$name(e),this}toString(){return`accessor:${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, this), () => ("<unnamed>"))}`}get value(){if(_chunkA5APHF7Kcjs.Da.call(void 0, ))return this[_chunkA5APHF7Kcjs.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}[_chunkA5APHF7Kcjs.f](e){let r=this.#e();return _chunkA5APHF7Kcjs.aa.call(void 0, e.resolve(r.value,r.dataType).value,r.dataType)}}, _class31);function qa(t){return _o(t)}function Vo([t,e]){return`${_nullishCoalesce(_chunkA5APHF7Kcjs.j.call(void 0, t), () => ("<unnamed>"))}=${e}`}function _o(t){if(_chunkA5APHF7Kcjs.Aa.call(void 0, ))throw new Error("Cannot create tgpu.derived objects at the resolution stage.");return{[_chunkA5APHF7Kcjs.a]:!0,resourceType:"derived","~compute":t,get[_chunkA5APHF7Kcjs.b](){let r=_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.b]},get $(){return this.value},with(r,n){return ja(this,[[r,n]])},toString(){return"derived"}}}function ja(t,e){return{[_chunkA5APHF7Kcjs.a]:!0,resourceType:"derived","~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},[_chunkA5APHF7Kcjs.d]:{inner:t,pairs:e},get[_chunkA5APHF7Kcjs.b](){let n=_chunkA5APHF7Kcjs.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[_chunkA5APHF7Kcjs.b]},get $(){return this.value},with(n,a){return ja(t,[...e,[n,a]])},toString(){return`derived[${e.map(Vo).join(", ")}]`}}}var Wo={fn:U,bindGroupLayout:Zt,vertexLayout:Zr,slot:he,init:Oa,initFromDevice:za,resolve:Ea,resolveWithContext:jr,privateVar:Ee,workgroupVar:kr,const:Ir,"~unstable":{fn:U,fragmentFn:ea,vertexFn:_chunkTRAG63HYcjs.h,computeFn:Et,vertexLayout:Zr,namespace:j,derived:qa,slot:he,accessor:Na,privateVar:Ee,workgroupVar:kr,const:Ir,declare:Xn,simulate:Va}},Wf= exports.default =Wo;exports.MissingBindGroupsError = _chunkA5APHF7Kcjs.ha; exports.MissingLinksError = _chunkA5APHF7Kcjs.ga; exports.MissingSlotValueError = _chunkA5APHF7Kcjs.ea; exports.MissingVertexBuffersError = _chunkA5APHF7Kcjs.ia; exports.NotUniformError = _chunkA5APHF7Kcjs.fa; exports.ResolutionError = _chunkA5APHF7Kcjs.ca; exports.default = Wf; exports.isBuffer = pe; exports.isBufferShorthand = Do; exports.isComparisonSampler = tt; exports.isDerived = _chunkA5APHF7Kcjs.na; exports.isSampler = et; exports.isSlot = _chunkA5APHF7Kcjs.ma; exports.isTexture = ee; exports.isTgpuFn = He; exports.isUsableAsRender = So; exports.isUsableAsSampled = Er; exports.isUsableAsStorage = ye; exports.isUsableAsUniform = jt; exports.isUsableAsVertex = yo; exports.isVariable = Io; exports.tgpu = Wo;
|
|
192
|
-
//# sourceMappingURL=index.cjs.map
|