wgsl_reflect
Version:
WGSL Parser and Reflection library
1 lines • 278 kB
JavaScript
Object.defineProperty(exports,'__esModule',{value:!0});class e{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class t{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class n extends e{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class s extends e{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class r extends e{constructor(e,t,n){super(e,n),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class a extends e{constructor(e,t,n,s){super(e,n),this.format=t,this.access=s}get isTemplate(){return!0}getTypeName(){let e=this.name;if(null!==this.format){if('vec2'===e||'vec3'===e||'vec4'===e||'mat2x2'===e||'mat2x3'===e||'mat2x4'===e||'mat3x2'===e||'mat3x3'===e||'mat3x4'===e||'mat4x2'===e||'mat4x3'===e||'mat4x4'===e){if('f32'===this.format.name)return e+='f',e;if('i32'===this.format.name)return e+='i',e;if('u32'===this.format.name)return e+='u',e;if('bool'===this.format.name)return e+='b',e;if('f16'===this.format.name)return e+='h',e}e+=`<${this.format.name}>`}else if('vec2'===e||'vec3'===e||'vec4'===e)return e;return e}}var o;exports.ResourceType=void 0,(o=exports.ResourceType||(exports.ResourceType={}))[o.Uniform=0]='Uniform',o[o.Storage=1]='Storage',o[o.Immediate=2]='Immediate',o[o.Texture=3]='Texture',o[o.Sampler=4]='Sampler',o[o.StorageTexture=5]='StorageTexture';class i{constructor(e,t,n,s,r,a,o){this.relations=null,this.name=e,this.type=t,this.group=n,this.binding=s,this.attributes=r,this.resourceType=a,this.access=o}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class l{constructor(e,t){this.name=e,this.type=t}}class c{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s,this.interpolation=null}}class u{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s}}class h{constructor(e,t,n,s){this.name=e,this.type=t,this.attributes=n,this.id=s}}class f{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n}}class p{constructor(e,t=null,n){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=n}}class d{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function m(e){var t=(32768&e)>>15,n=(31744&e)>>10,s=1023&e;return 0==n?(t?-1:1)*Math.pow(2,-14)*(s/Math.pow(2,10)):31==n?s?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,n-15)*(1+s/Math.pow(2,10))}const g=new Float32Array(1),x=new Int32Array(g.buffer),_=new Uint16Array(1);function y(e){g[0]=e;const t=x[0],n=t>>31&1;let s=t>>23&255,r=8388607&t;if(255===s)return _[0]=n<<15|31744|(0!==r?512:0),_[0];if(0===s){if(0===r)return _[0]=n<<15,_[0];r|=8388608;let e=113;for(;!(8388608&r);)r<<=1,e--;return s=127-e,r&=8388607,s>0?(r=(r>>126-s)+(r>>127-s&1),_[0]=n<<15|s<<10|r>>13,_[0]):(_[0]=n<<15,_[0])}return s=s-127+15,s>=31?(_[0]=n<<15|31744,_[0]):s<=0?s<-10?(_[0]=n<<15,_[0]):(r=(8388608|r)>>1-s,_[0]=n<<15|r>>13,_[0]):(r>>=13,_[0]=n<<15|s<<10|r,_[0])}const v=new Uint32Array(1),b=new Float32Array(v.buffer,0,1);function k(e){const t=112+(e>>6&31)<<23|(63&e)<<17;return v[0]=t,b[0]}function w(e,t,n,s,r,a,o,i,l){const c=s*(o>>=r)*(a>>=r)+n*o+t*i;switch(l){case'r8unorm':return[I(e,c,'8unorm',1)[0]];case'r8snorm':return[I(e,c,'8snorm',1)[0]];case'r8uint':return[I(e,c,'8uint',1)[0]];case'r8sint':return[I(e,c,'8sint',1)[0]];case'rg8unorm':{const t=I(e,c,'8unorm',2);return[t[0],t[1]]}case'rg8snorm':{const t=I(e,c,'8snorm',2);return[t[0],t[1]]}case'rg8uint':{const t=I(e,c,'8uint',2);return[t[0],t[1]]}case'rg8sint':{const t=I(e,c,'8sint',2);return[t[0],t[1]]}case'rgba8unorm-srgb':case'rgba8unorm':{const t=I(e,c,'8unorm',4);return[t[0],t[1],t[2],t[3]]}case'rgba8snorm':{const t=I(e,c,'8snorm',4);return[t[0],t[1],t[2],t[3]]}case'rgba8uint':{const t=I(e,c,'8uint',4);return[t[0],t[1],t[2],t[3]]}case'rgba8sint':{const t=I(e,c,'8sint',4);return[t[0],t[1],t[2],t[3]]}case'bgra8unorm-srgb':case'bgra8unorm':{const t=I(e,c,'8unorm',4);return[t[2],t[1],t[0],t[3]]}case'r16uint':return[I(e,c,'16uint',1)[0]];case'r16sint':return[I(e,c,'16sint',1)[0]];case'r16float':return[I(e,c,'16float',1)[0]];case'rg16uint':{const t=I(e,c,'16uint',2);return[t[0],t[1]]}case'rg16sint':{const t=I(e,c,'16sint',2);return[t[0],t[1]]}case'rg16float':{const t=I(e,c,'16float',2);return[t[0],t[1]]}case'rgba16uint':{const t=I(e,c,'16uint',4);return[t[0],t[1],t[2],t[3]]}case'rgba16sint':{const t=I(e,c,'16sint',4);return[t[0],t[1],t[2],t[3]]}case'rgba16float':{const t=I(e,c,'16float',4);return[t[0],t[1],t[2],t[3]]}case'r32uint':return[I(e,c,'32uint',1)[0]];case'r32sint':return[I(e,c,'32sint',1)[0]];case'depth16unorm':case'depth24plus':case'depth24plus-stencil8':case'depth32float':case'depth32float-stencil8':case'r32float':return[I(e,c,'32float',1)[0]];case'rg32uint':{const t=I(e,c,'32uint',2);return[t[0],t[1]]}case'rg32sint':{const t=I(e,c,'32sint',2);return[t[0],t[1]]}case'rg32float':{const t=I(e,c,'32float',2);return[t[0],t[1]]}case'rgba32uint':{const t=I(e,c,'32uint',4);return[t[0],t[1],t[2],t[3]]}case'rgba32sint':{const t=I(e,c,'32sint',4);return[t[0],t[1],t[2],t[3]]}case'rgba32float':{const t=I(e,c,'32float',4);return[t[0],t[1],t[2],t[3]]}case'rg11b10ufloat':{const t=new Uint32Array(e.buffer,c,1)[0],n=(4192256&t)>>11,s=(4290772992&t)>>22;return[k(2047&t),k(n),function(e){const t=112+(e>>5&31)<<23|(31&e)<<18;return v[0]=t,b[0]}(s),1]}}return null}function I(e,t,n,s){const r=[0,0,0,0];for(let a=0;a<s;++a)switch(n){case'8unorm':r[a]=e[t]/255,t++;break;case'8snorm':r[a]=e[t]/255*2-1,t++;break;case'8uint':r[a]=e[t],t++;break;case'8sint':r[a]=e[t]-127,t++;break;case'16uint':r[a]=e[t]|e[t+1]<<8,t+=2;break;case'16sint':r[a]=(e[t]|e[t+1]<<8)-32768,t+=2;break;case'16float':r[a]=m(e[t]|e[t+1]<<8),t+=2;break;case'32uint':case'32sint':r[a]=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,t+=4;break;case'32float':r[a]=new Float32Array(e.buffer,t,1)[0],t+=4}return r}function T(e,t,n,s,r){for(let a=0;a<s;++a)switch(n){case'8unorm':e[t]=255*r[a],t++;break;case'8snorm':e[t]=.5*(r[a]+1)*255,t++;break;case'8uint':e[t]=r[a],t++;break;case'8sint':e[t]=r[a]+127,t++;break;case'16uint':new Uint16Array(e.buffer,t,1)[0]=r[a],t+=2;break;case'16sint':new Int16Array(e.buffer,t,1)[0]=r[a],t+=2;break;case'16float':{const n=y(r[a]);new Uint16Array(e.buffer,t,1)[0]=n,t+=2;break}case'32uint':new Uint32Array(e.buffer,t,1)[0]=r[a],t+=4;break;case'32sint':new Int32Array(e.buffer,t,1)[0]=r[a],t+=4;break;case'32float':new Float32Array(e.buffer,t,1)[0]=r[a],t+=4}return r}const S={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},'rgba8unorm-srgb':{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},'bgra8unorm-srgb':{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:'depth32float',channels:1},'depth24plus-stencil8':{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:'depth32float',channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},'depth32float-stencil8':{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:'depth32float',channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},'bc1-rgba-unorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc1-rgba-unorm-srgb':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc2-rgba-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc2-rgba-unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc3-rgba-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc3-rgba-unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc4-r-unorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},'bc4-r-snorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},'bc5-rg-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},'bc5-rg-snorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},'bc6h-rgb-ufloat':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc6h-rgb-float':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc7-rgba-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc7-rgba-unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgb8unorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgb8unorm-srgb':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgb8a1unorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgb8a1unorm-srgb':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgba8unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgba8unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'eac-r11unorm':{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},'eac-r11snorm':{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},'eac-rg11unorm':{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},'eac-rg11snorm':{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},'astc-4x4-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'astc-4x4-unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'astc-5x4-unorm':{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},'astc-5x4-unorm-srgb':{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},'astc-5x5-unorm':{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},'astc-5x5-unorm-srgb':{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},'astc-6x5-unorm':{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},'astc-6x5-unorm-srgb':{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},'astc-6x6-unorm':{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},'astc-6x6-unorm-srgb':{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},'astc-8x5-unorm':{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},'astc-8x5-unorm-srgb':{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},'astc-8x6-unorm':{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},'astc-8x6-unorm-srgb':{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},'astc-8x8-unorm':{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},'astc-8x8-unorm-srgb':{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},'astc-10x5-unorm':{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},'astc-10x5-unorm-srgb':{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},'astc-10x6-unorm':{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},'astc-10x6-unorm-srgb':{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},'astc-10x8-unorm':{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},'astc-10x8-unorm-srgb':{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},'astc-10x10-unorm':{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},'astc-10x10-unorm-srgb':{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},'astc-12x10-unorm':{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},'astc-12x10-unorm-srgb':{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},'astc-12x12-unorm':{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},'astc-12x12-unorm-srgb':{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}};class C{constructor(){this.id=C._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return''}search(e){e(this)}searchBlock(e,t){if(e){t(A.instance);for(const n of e)n instanceof Array?this.searchBlock(n,t):n.search(t);t(E.instance)}}constEvaluate(e,t){throw new Error('Cannot evaluate node')}constEvaluateString(e){var t,n;return null!==(n=null===(t=this.constEvaluate(e))||void 0===t?void 0:t.toString())&&void 0!==n?n:''}}C._id=0;class A extends C{}A.instance=new A;class E extends C{}E.instance=new E;const $=new Set(['all','any','select','arrayLength','abs','acos','acosh','asin','asinh','atan','atanh','atan2','ceil','clamp','cos','cosh','countLeadingZeros','countOneBits','countTrailingZeros','cross','degrees','determinant','distance','dot','dot4U8Packed','dot4I8Packed','exp','exp2','extractBits','faceForward','firstLeadingBit','firstTrailingBit','floor','fma','fract','frexp','insertBits','inverseSqrt','ldexp','length','log','log2','max','min','mix','modf','normalize','pow','quantizeToF16','radians','reflect','refract','reverseBits','round','saturate','sign','sin','sinh','smoothstep','sqrt','step','tan','tanh','transpose','trunc','dpdx','dpdxCoarse','dpdxFine','dpdy','dpdyCoarse','dpdyFine','fwidth','fwidthCoarse','fwidthFine','textureDimensions','textureGather','textureGatherCompare','textureLoad','textureNumLayers','textureNumLevels','textureNumSamples','textureSample','textureSampleBias','textureSampleCompare','textureSampleCompareLevel','textureSampleGrad','textureSampleLevel','textureSampleBaseClampToEdge','textureStore','atomicLoad','atomicStore','atomicAdd','atomicSub','atomicMax','atomicMin','atomicAnd','atomicOr','atomicXor','atomicExchange','atomicCompareExchangeWeak','pack4x8snorm','pack4x8unorm','pack4xI8','pack4xU8','pack4x8Clamp','pack4xU8Clamp','pack2x16snorm','pack2x16unorm','pack2x16float','unpack4x8snorm','unpack4x8unorm','unpack4xI8','unpack4xU8','unpack2x16snorm','unpack2x16unorm','unpack2x16float','storageBarrier','textureBarrier','workgroupBarrier','workgroupUniformLoad','subgroupAdd','subgroupExclusiveAdd','subgroupInclusiveAdd','subgroupAll','subgroupAnd','subgroupAny','subgroupBallot','subgroupBroadcast','subgroupBroadcastFirst','subgroupElect','subgroupMax','subgroupMin','subgroupMul','subgroupExclusiveMul','subgroupInclusiveMul','subgroupOr','subgroupShuffle','subgroupShuffleDown','subgroupShuffleUp','subgroupShuffleXor','subgroupXor','quadBroadcast','quadSwapDiagonal','quadSwapX','quadSwapY']);class L extends C{}class D extends L{constructor(e,t,n,s,r,a){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=n,this.body=s,this.startLine=r,this.endLine=a}get astNodeType(){return'function'}search(e){if(this.attributes)for(const t of this.attributes)e(t);e(this);for(const t of this.args)e(t);this.searchBlock(this.body,e)}}class N extends L{constructor(e){super(),this.expression=e}get astNodeType(){return'staticAssert'}search(e){this.expression.search(e)}}class V extends L{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return'while'}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class B extends L{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return'continuing'}search(e){this.searchBlock(this.body,e)}}class F extends L{constructor(e,t,n,s){super(),this.init=e,this.condition=t,this.increment=n,this.body=s}get astNodeType(){return'for'}search(e){var t,n,s;null===(t=this.init)||void 0===t||t.search(e),null===(n=this.condition)||void 0===n||n.search(e),null===(s=this.increment)||void 0===s||s.search(e),this.searchBlock(this.body,e)}}class M extends L{constructor(e,t,n,s,r){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=r}get astNodeType(){return'var'}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}class U extends L{constructor(e,t,n){super(),this.attributes=null,this.name=e,this.type=t,this.value=n}get astNodeType(){return'override'}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class P extends L{constructor(e,t,n,s,r){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=r}get astNodeType(){return'let'}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}class z extends L{constructor(e,t,n,s,r){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=r}get astNodeType(){return'const'}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}var W,O,R,q;exports.IncrementOperator=void 0,(W=exports.IncrementOperator||(exports.IncrementOperator={})).increment='++',W.decrement='--',(e=>{e.parse=function(t){const n=t;if('parse'===n)throw new Error('Invalid value for IncrementOperator');return e[n]}})(exports.IncrementOperator||(exports.IncrementOperator={}));class H extends L{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return'increment'}search(e){this.variable.search(e)}}exports.AssignOperator=void 0,(O=exports.AssignOperator||(exports.AssignOperator={})).assign='=',O.addAssign='+=',O.subtractAssign='-=',O.multiplyAssign='*=',O.divideAssign='/=',O.moduloAssign='%=',O.andAssign='&=',O.orAssign='|=',O.xorAssign='^=',O.shiftLeftAssign='<<=',O.shiftRightAssign='>>=',(exports.AssignOperator||(exports.AssignOperator={})).parse=e=>{const t=e;if('parse'===t)throw new Error('Invalid value for AssignOperator');return t};class G extends L{constructor(e,t,n){super(),this.operator=e,this.variable=t,this.value=n}get astNodeType(){return'assign'}search(e){this.variable.search(e),this.value.search(e)}}class X extends L{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return'call'}isBuiltin(){return $.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class Z extends L{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return'loop'}search(e){var t;this.searchBlock(this.body,e),null===(t=this.continuing)||void 0===t||t.search(e)}}class j extends L{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return'switch'}search(e){e(this);for(const t of this.cases)t.search(e)}}class Q extends L{constructor(e,t,n,s){super(),this.condition=e,this.body=t,this.elseif=n,this.else=s}get astNodeType(){return'if'}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class J extends L{constructor(e){super(),this.value=e}get astNodeType(){return'return'}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class Y extends L{constructor(e){super(),this.name=e}get astNodeType(){return'enable'}}class K extends L{constructor(e){super(),this.extensions=e}get astNodeType(){return'requires'}}class ee extends L{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return'diagnostic'}}class te extends L{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return'alias'}}class ne extends L{get astNodeType(){return'discard'}}class se extends L{constructor(){super(...arguments),this.condition=null,this.loopId=-1}get astNodeType(){return'break'}}class re extends L{constructor(){super(...arguments),this.loopId=-1}get astNodeType(){return'continue'}}class ae extends L{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return'type'}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if('f32'===t.name)return t;for(let n=1;n<e.length;++n){const s=ae._priority.get(t.name);ae._priority.get(e[n].name)<s&&(t=e[n])}return'x32'===t.name?ae.i32:t}getTypeName(){return this.name}}ae.x32=new ae('x32'),ae.f32=new ae('f32'),ae.i32=new ae('i32'),ae.u32=new ae('u32'),ae.f16=new ae('f16'),ae.bool=new ae('bool'),ae.void=new ae('void'),ae._priority=new Map([['f32',0],['f16',1],['u32',2],['i32',3],['x32',3]]);class oe extends ae{constructor(e){super(e)}}class ie extends ae{constructor(e,t,n,s){super(e),this.members=t,this.startLine=n,this.endLine=s}get astNodeType(){return'struct'}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name===e)return t;return-1}search(e){for(const t of this.members)e(t)}}class le extends ae{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return'template'}getTypeName(){let e=this.name;if(null!==this.format){if('vec2'===e||'vec3'===e||'vec4'===e||'mat2x2'===e||'mat2x3'===e||'mat2x4'===e||'mat3x2'===e||'mat3x3'===e||'mat3x4'===e||'mat4x2'===e||'mat4x3'===e||'mat4x4'===e){if('f32'===this.format.name)return e+='f',e;if('i32'===this.format.name)return e+='i',e;if('u32'===this.format.name)return e+='u',e;if('bool'===this.format.name)return e+='b',e;if('f16'===this.format.name)return e+='h',e}e+=`<${this.format.name}>`}else if('vec2'===e||'vec3'===e||'vec4'===e)return e;return e}}le.vec2f=new le('vec2',ae.f32,null),le.vec3f=new le('vec3',ae.f32,null),le.vec4f=new le('vec4',ae.f32,null),le.vec2i=new le('vec2',ae.i32,null),le.vec3i=new le('vec3',ae.i32,null),le.vec4i=new le('vec4',ae.i32,null),le.vec2u=new le('vec2',ae.u32,null),le.vec3u=new le('vec3',ae.u32,null),le.vec4u=new le('vec4',ae.u32,null),le.vec2h=new le('vec2',ae.f16,null),le.vec3h=new le('vec3',ae.f16,null),le.vec4h=new le('vec4',ae.f16,null),le.vec2b=new le('vec2',ae.bool,null),le.vec3b=new le('vec3',ae.bool,null),le.vec4b=new le('vec4',ae.bool,null),le.mat2x2f=new le('mat2x2',ae.f32,null),le.mat2x3f=new le('mat2x3',ae.f32,null),le.mat2x4f=new le('mat2x4',ae.f32,null),le.mat3x2f=new le('mat3x2',ae.f32,null),le.mat3x3f=new le('mat3x3',ae.f32,null),le.mat3x4f=new le('mat3x4',ae.f32,null),le.mat4x2f=new le('mat4x2',ae.f32,null),le.mat4x3f=new le('mat4x3',ae.f32,null),le.mat4x4f=new le('mat4x4',ae.f32,null),le.mat2x2h=new le('mat2x2',ae.f16,null),le.mat2x3h=new le('mat2x3',ae.f16,null),le.mat2x4h=new le('mat2x4',ae.f16,null),le.mat3x2h=new le('mat3x2',ae.f16,null),le.mat3x3h=new le('mat3x3',ae.f16,null),le.mat3x4h=new le('mat3x4',ae.f16,null),le.mat4x2h=new le('mat4x2',ae.f16,null),le.mat4x3h=new le('mat4x3',ae.f16,null),le.mat4x4h=new le('mat4x4',ae.f16,null),le.mat2x2i=new le('mat2x2',ae.i32,null),le.mat2x3i=new le('mat2x3',ae.i32,null),le.mat2x4i=new le('mat2x4',ae.i32,null),le.mat3x2i=new le('mat3x2',ae.i32,null),le.mat3x3i=new le('mat3x3',ae.i32,null),le.mat3x4i=new le('mat3x4',ae.i32,null),le.mat4x2i=new le('mat4x2',ae.i32,null),le.mat4x3i=new le('mat4x3',ae.i32,null),le.mat4x4i=new le('mat4x4',ae.i32,null),le.mat2x2u=new le('mat2x2',ae.u32,null),le.mat2x3u=new le('mat2x3',ae.u32,null),le.mat2x4u=new le('mat2x4',ae.u32,null),le.mat3x2u=new le('mat3x2',ae.u32,null),le.mat3x3u=new le('mat3x3',ae.u32,null),le.mat3x4u=new le('mat3x4',ae.u32,null),le.mat4x2u=new le('mat4x2',ae.u32,null),le.mat4x3u=new le('mat4x3',ae.u32,null),le.mat4x4u=new le('mat4x4',ae.u32,null);class ce extends ae{constructor(e,t,n,s){super(e),this.storage=t,this.type=n,this.access=s}get astNodeType(){return'pointer'}}class ue extends ae{constructor(e,t,n,s){super(e),this.attributes=t,this.format=n,this.count=s}get astNodeType(){return'array'}get isArray(){return!0}}class he extends ae{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return'sampler'}}class fe extends C{constructor(){super(),this.postfix=null,this.hasParen=!1}}class pe extends fe{constructor(e){super(),this.value=e}get astNodeType(){return'stringExpr'}toString(){return this.value}constEvaluateString(){return this.value}}class de extends fe{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return'createExpr'}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class me extends fe{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return'callExpr'}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return $.has(this.name)}constEvaluate(e,t){const n=e.evalExpression(this,e.context);return void 0!==t&&this._resolveReturnType(e,t),n}_resolveReturnType(e,t){const n=e.context.getFunction(this.name);if(null!==n)return void(null!==n.node.returnType&&(t[0]=n.node.returnType));const s=me._builtinFixedReturnType.get(this.name);if(void 0!==s)return void(t[0]=s);const r=me._builtinSameAsArg.get(this.name);if(void 0!==r&&this.args&&this.args[r])return void this.args[r].constEvaluate(e,t);const a=me._builtinComponentOfArg.get(this.name);if(void 0!==a&&this.args&&this.args[a]){const n=[ae.f32];return this.args[a].constEvaluate(e,n),void(n[0]instanceof le&&null!==n[0].format?t[0]=n[0].format:t[0]=n[0])}}search(e){for(const t of this.args)t.search(e);e(this)}}me._builtinFixedReturnType=new Map([['all',ae.bool],['any',ae.bool],['arrayLength',ae.u32],['dot4U8Packed',ae.u32],['dot4I8Packed',ae.i32],['pack4x8snorm',ae.u32],['pack4x8unorm',ae.u32],['pack4xI8',ae.u32],['pack4xU8',ae.u32],['pack4x8Clamp',ae.u32],['pack4xU8Clamp',ae.u32],['pack2x16snorm',ae.u32],['pack2x16unorm',ae.u32],['pack2x16float',ae.u32],['unpack4x8snorm',le.vec4f],['unpack4x8unorm',le.vec4f],['unpack4xI8',le.vec4i],['unpack4xU8',le.vec4u],['unpack2x16snorm',le.vec2f],['unpack2x16unorm',le.vec2f],['unpack2x16float',le.vec2f],['storageBarrier',ae.void],['textureBarrier',ae.void],['workgroupBarrier',ae.void],['atomicStore',ae.void]]),me._builtinSameAsArg=new Map([['abs',0],['acos',0],['acosh',0],['asin',0],['asinh',0],['atan',0],['atanh',0],['atan2',0],['ceil',0],['clamp',0],['cos',0],['cosh',0],['countLeadingZeros',0],['countOneBits',0],['countTrailingZeros',0],['cross',0],['degrees',0],['exp',0],['exp2',0],['extractBits',0],['faceForward',0],['firstLeadingBit',0],['firstTrailingBit',0],['floor',0],['fma',0],['fract',0],['insertBits',0],['inverseSqrt',0],['ldexp',0],['log',0],['log2',0],['max',0],['min',0],['mix',0],['normalize',0],['pow',0],['quantizeToF16',0],['radians',0],['reflect',0],['refract',0],['reverseBits',0],['round',0],['saturate',0],['sign',0],['sin',0],['sinh',0],['smoothstep',2],['sqrt',0],['step',1],['tan',0],['tanh',0],['trunc',0],['dpdx',0],['dpdxCoarse',0],['dpdxFine',0],['dpdy',0],['dpdyCoarse',0],['dpdyFine',0],['fwidth',0],['fwidthCoarse',0],['fwidthFine',0],['select',0],['workgroupUniformLoad',0],['atomicLoad',0],['atomicAdd',1],['atomicSub',1],['atomicMax',1],['atomicMin',1],['atomicAnd',1],['atomicOr',1],['atomicXor',1],['atomicExchange',1],['subgroupAdd',0],['subgroupExclusiveAdd',0],['subgroupInclusiveAdd',0],['subgroupAnd',0],['subgroupBroadcast',0],['subgroupBroadcastFirst',0],['subgroupMax',0],['subgroupMin',0],['subgroupMul',0],['subgroupExclusiveMul',0],['subgroupInclusiveMul',0],['subgroupOr',0],['subgroupShuffle',0],['subgroupShuffleDown',0],['subgroupShuffleUp',0],['subgroupShuffleXor',0],['subgroupXor',0],['quadBroadcast',0],['quadSwapDiagonal',0],['quadSwapX',0],['quadSwapY',0]]),me._builtinComponentOfArg=new Map([['length',0],['distance',0],['dot',0],['determinant',0]]);class ge extends fe{constructor(e){super(),this.name=e}get astNodeType(){return'varExpr'}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){const n=e.evalExpression(this,e.context);if(void 0!==t&&null===this.postfix){const n=e.context.getVariable(this.name);null!==n&&null!==n.node&&null!==n.node.type&&(t[0]=n.node.type)}return n}}class xe extends fe{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return'constExpr'}constEvaluate(e,t){const n=e.evalExpression(this.initializer,e.context);return void 0!==t&&this.initializer.constEvaluate(e,t),null!==n&&this.postfix?n.getSubData(e,this.postfix,e.context):n}search(e){this.initializer.search(e)}}class _e extends fe{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return'literalExpr'}constEvaluate(e,t){return void 0!==t&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof Me}get isVector(){return this.value instanceof Pe||this.value instanceof ze}get scalarValue(){return this.value instanceof Me?this.value.value:(console.error('Value is not scalar.'),0)}get vectorValue(){return this.value instanceof Pe||this.value instanceof ze?this.value.data:(console.error('Value is not a vector or matrix.'),new Float32Array(0))}}class ye extends fe{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return'bitcastExpr'}search(e){this.value.search(e)}}class ve extends fe{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return'typecastExpr'}constEvaluate(e,t){return void 0!==t&&null!==this.type&&(t[0]=this.type),e.evalExpression(this,e.context)}search(e){this.searchBlock(this.args,e)}}class be extends fe{constructor(t){super(),'number'==typeof t&&(t=new _e(new Me(new Uint32Array([t]),new e('u32',null)),ae.u32)),this.index=t}search(e){this.index.search(e)}}class ke extends fe{constructor(){super()}}class we extends ke{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return'unaryOp'}constEvaluate(e,t){const n=e.evalExpression(this,e.context);return void 0!==t&&('!'===this.operator?t[0]=ae.bool:this.right.constEvaluate(e,t)),n}search(e){this.right.search(e)}}class Ie extends ke{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}get astNodeType(){return'binaryOp'}_getPromotedType(e,t){return e.name===t.name?e:'f32'===e.name||'f32'===t.name?ae.f32:'u32'===e.name||'u32'===t.name?ae.u32:ae.i32}constEvaluate(e,t){const n=e.evalExpression(this,e.context);if(void 0!==t)switch(this.operator){case'==':case'!=':case'<':case'>':case'<=':case'>=':case'&&':case'||':t[0]=ae.bool;break;default:{const n=[ae.f32],s=[ae.f32];this.left.constEvaluate(e,n),this.right.constEvaluate(e,s),t[0]=this._getPromotedType(n[0],s[0]);break}}return n}search(e){this.left.search(e),this.right.search(e)}}class Te extends C{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class Se extends fe{get astNodeType(){return'default'}}class Ce extends Te{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return'case'}search(e){this.searchBlock(this.body,e)}}class Ae extends Te{constructor(e){super(e)}get astNodeType(){return'default'}search(e){this.searchBlock(this.body,e)}}class Ee extends C{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return'argument'}}class $e extends C{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return'elseif'}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Le extends C{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return'member'}}class De extends C{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return'attribute'}}class Ne{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Ne._id++}setDataValue(e,t,n,s){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,n){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}Ne._id=0;class Ve extends Ne{constructor(e,t){super(e,t)}clone(){return this}toString(){return this.typeInfo.name}}class Be extends Ne{constructor(){super(new e('void',null),null)}clone(){return this}toString(){return'void'}}Be.void=new Be;class Fe extends Ne{constructor(e){super(new r('pointer',e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,n,s){this.reference.setDataValue(e,t,n,s)}getSubData(e,t,n){return t?this.reference.getSubData(e,t,n):this}toString(){return`&${this.reference.toString()}`}}class Me extends Ne{constructor(e,t,n=null){super(t,n),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:'x32'===this.typeInfo.name?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):'i32'===this.typeInfo.name||'bool'===this.typeInfo.name?this.data=new Int32Array([e]):'u32'===this.typeInfo.name?this.data=new Uint32Array([e]):'f32'===this.typeInfo.name||'f16'===this.typeInfo.name?this.data=new Float32Array([e]):console.error('ScalarData2: Invalid type',t)}clone(){if(this.data instanceof Float32Array)return new Me(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Me(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Me(new Uint32Array(this.data),this.typeInfo,null);throw new Error('ScalarData: Invalid data type')}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,n,s){if(n)return void console.error('SetDataValue: Scalar data does not support postfix',n);if(!(t instanceof Me))return void console.error('SetDataValue: Invalid value',t);let r=t.data[0];'i32'===this.typeInfo.name||'u32'===this.typeInfo.name?r=Math.floor(r):'bool'===this.typeInfo.name&&(r=r?1:0),this.data[0]=r}getSubData(e,t,n){return t?(console.error('getSubData: Scalar data does not support postfix',t),null):this}toString(){return`${this.value}`}}function Ue(e,t,n){const s=t.length;return 2===s?'f32'===n?new Pe(new Float32Array(t),e.getTypeInfo('vec2f')):'i32'===n||'bool'===n?new Pe(new Int32Array(t),e.getTypeInfo('vec2i')):'u32'===n?new Pe(new Uint32Array(t),e.getTypeInfo('vec2u')):'f16'===n?new Pe(new Float32Array(t),e.getTypeInfo('vec2h')):(console.error(`getSubData: Unknown format ${n}`),null):3===s?'f32'===n?new Pe(new Float32Array(t),e.getTypeInfo('vec3f')):'i32'===n||'bool'===n?new Pe(new Int32Array(t),e.getTypeInfo('vec3i')):'u32'===n?new Pe(new Uint32Array(t),e.getTypeInfo('vec3u')):'f16'===n?new Pe(new Float32Array(t),e.getTypeInfo('vec3h')):(console.error(`getSubData: Unknown format ${n}`),null):4===s?'f32'===n?new Pe(new Float32Array(t),e.getTypeInfo('vec4f')):'i32'===n||'bool'===n?new Pe(new Int32Array(t),e.getTypeInfo('vec4i')):'u32'===n?new Pe(new Uint32Array(t),e.getTypeInfo('vec4u')):'f16'===n?new Pe(new Float32Array(t),e.getTypeInfo('vec4h')):(console.error(`getSubData: Unknown format ${n}`),null):(console.error(`getSubData: Invalid vector size ${t.length}`),null)}class Pe extends Ne{constructor(e,t,n=null){if(super(t,n),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const t=this.typeInfo.name;'vec2f'===t||'vec3f'===t||'vec4f'===t?this.data=new Float32Array(e):'vec2i'===t||'vec3i'===t||'vec4i'===t?this.data=new Int32Array(e):'vec2u'===t||'vec3u'===t||'vec4u'===t?this.data=new Uint32Array(e):'vec2h'===t||'vec3h'===t||'vec4h'===t?this.data=new Float32Array(e):'vec2b'===t||'vec3b'===t||'vec4b'===t?this.data=new Int32Array(e):'vec2'===t||'vec3'===t||'vec4'===t?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${t}`)}}clone(){if(this.data instanceof Float32Array)return new Pe(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Pe(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Pe(new Uint32Array(this.data),this.typeInfo,null);throw new Error('VectorData: Invalid data type')}setDataValue(e,t,n,s){n instanceof pe?console.error('TODO: Set vector postfix'):t instanceof Pe?this.data=t.data:console.error('SetDataValue: Invalid value',t)}getSubData(e,t,n){if(null===t)return this;let s=e.getTypeInfo('f32');if(this.typeInfo instanceof a)s=this.typeInfo.format||s;else{const t=this.typeInfo.name;'vec2f'===t||'vec3f'===t||'vec4f'===t?s=e.getTypeInfo('f32'):'vec2i'===t||'vec3i'===t||'vec4i'===t?s=e.getTypeInfo('i32'):'vec2b'===t||'vec3b'===t||'vec4b'===t?s=e.getTypeInfo('bool'):'vec2u'===t||'vec3u'===t||'vec4u'===t?s=e.getTypeInfo('u32'):'vec2h'===t||'vec3h'===t||'vec4h'===t?s=e.getTypeInfo('f16'):console.error(`GetSubData: Unknown type ${t}`)}let r=this;for(;null!==t&&null!==r;){if(t instanceof be){const a=t.index;let o=-1;if(a instanceof _e){if(!(a.value instanceof Me))return console.error(`GetSubData: Invalid array index ${a.value}`),null;o=a.value.value}else{const t=e.evalExpression(a,n);if(!(t instanceof Me))return console.error('GetSubData: Unknown index type',a),null;o=t.value}if(o<0||o>=r.data.length)return console.error('GetSubData: Index out of range',o),null;if(r.data instanceof Float32Array){const e=new Float32Array(r.data.buffer,r.data.byteOffset+4*o,1);return new Me(e,s)}if(r.data instanceof Int32Array){const e=new Int32Array(r.data.buffer,r.data.byteOffset+4*o,1);return new Me(e,s)}if(r.data instanceof Uint32Array){const e=new Uint32Array(r.data.buffer,r.data.byteOffset+4*o,1);return new Me(e,s)}throw new Error('GetSubData: Invalid data type')}if(!(t instanceof pe))return console.error('GetSubData: Unknown postfix',t),null;{const n=t.value.toLowerCase();if(1===n.length){let e=0;if('x'===n||'r'===n)e=0;else if('y'===n||'g'===n)e=1;else if('z'===n||'b'===n)e=2;else{if('w'!==n&&'a'!==n)return console.error(`GetSubData: Unknown member ${n}`),null;e=3}if(this.data instanceof Float32Array){let t=new Float32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Me(t,s,this)}if(this.data instanceof Int32Array){let t=new Int32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Me(t,s,this)}if(this.data instanceof Uint32Array){let t=new Uint32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Me(t,s,this)}}const a=[];for(const e of n)'x'===e||'r'===e?a.push(this.data[0]):'y'===e||'g'===e?a.push(this.data[1]):'z'===e||'b'===e?a.push(this.data[2]):'w'===e||'a'===e?a.push(this.data[3]):console.error(`GetDataValue: Unknown member ${e}`);r=Ue(e,a,s.name)}t=t.postfix}return r}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class ze extends Ne{constructor(e,t,n=null){super(t,n),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new ze(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,n,s){n instanceof pe?console.error('TODO: Set matrix postfix'):t instanceof ze?this.data=t.data:console.error('SetDataValue: Invalid value',t)}getSubData(e,t,n){if(null===t)return this;const s=this.typeInfo.name;if(e.getTypeInfo('f32'),this.typeInfo instanceof a)this.typeInfo.format;else if(s.endsWith('f'))e.getTypeInfo('f32');else if(s.endsWith('i'))e.getTypeInfo('i32');else if(s.endsWith('u'))e.getTypeInfo('u32');else{if(!s.endsWith('h'))return console.error(`GetDataValue: Unknown type ${s}`),null;e.getTypeInfo('f16')}if(t instanceof be){const r=t.index;let a=-1;if(r instanceof _e){if(!(r.value instanceof Me))return console.error(`GetDataValue: Invalid array index ${r.value}`),null;a=r.value.value}else{const t=e.evalExpression(r,n);if(!(t instanceof Me))return console.error('GetDataValue: Unknown index type',r),null;a=t.value}if(a<0||a>=this.data.length)return console.error('GetDataValue: Index out of range',a),null;const o=s.endsWith('h')?'h':'f';let i;if('mat2x2'===s||'mat2x2f'===s||'mat2x2h'===s||'mat3x2'===s||'mat3x2f'===s||'mat3x2h'===s||'mat4x2'===s||'mat4x2f'===s||'mat4x2h'===s)i=new Pe(new Float32Array(this.data.buffer,this.data.byteOffset+2*a*4,2),e.getTypeInfo(`vec2${o}`));else if('mat2x3'===s||'mat2x3f'===s||'mat2x3h'===s||'mat3x3'===s||'mat3x3f'===s||'mat3x3h'===s||'mat4x3'===s||'mat4x3f'===s||'mat4x3h'===s)i=new Pe(new Float32Array(this.data.buffer,this.data.byteOffset+3*a*4,3),e.getTypeInfo(`vec3${o}`));else{if('mat2x4'!==s&&'mat2x4f'!==s&&'mat2x4h'!==s&&'mat3x4'!==s&&'mat3x4f'!==s&&'mat3x4h'!==s&&'mat4x4'!==s&&'mat4x4f'!==s&&'mat4x4h'!==s)return console.error(`GetDataValue: Unknown type ${s}`),null;i=new Pe(new Float32Array(this.data.buffer,this.data.byteOffset+4*a*4,4),e.getTypeInfo(`vec4${o}`))}return t.postfix?i.getSubData(e,t.postfix,n):i}return console.error('GetDataValue: Invalid postfix',t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class We extends Ne{constructor(e,t,n=0,s=null){super(t,s),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=n}clone(){const e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new We(e.buffer,this.typeInfo,0,null)}setDataValue(t,r,a,o){if(null===r)return void console.log('setDataValue: NULL data.');let i=this.offset,l=this.typeInfo;for(;a;){if(a instanceof be)if(l instanceof s){const e=a.index;if(e instanceof _e){if(!(e.value instanceof Me))return void console.error(`SetDataValue: Invalid index type ${e.value}`);i+=e.value.value*l.stride}else{const n=t.evalExpression(e,o);if(!(n instanceof Me))return void console.error('SetDataValue: Unknown index type',e);i+=n.value*l.stride}l=l.format}else console.error(`SetDataValue: Type ${l.getTypeName()} is not an array`);else{if(!(a instanceof pe))return void console.error('SetDataValue: Unknown postfix type',a);{const t=a.value;if(l instanceof n){let e=!1;for(const n of l.members)if(n.name===t){i+=n.offset,l=n.type,e=!0;break}if(!e)return void console.error(`SetDataValue: Member ${t} not found`)}else if(l instanceof e){const e=l.getTypeName();let n=0;if('x'===t||'r'===t)n=0;else if('y'===t||'g'===t)n=1;else if('z'===t||'b'===t)n=2;else{if('w'!==t&&'a'!==t)return void console.error(`SetDataValue: Unknown member ${t}`);n=3}if(!(r instanceof Me))return void console.error('SetDataValue: Invalid value',r);const s=r.value;return'vec2f'===e?void(new Float32Array(this.buffer,i,2)[n]=s):'vec3f'===e?void(new Float32Array(this.buffer,i,3)[n]=s):'vec4f'===e?void(new Float32Array(this.buffer,i,4)[n]=s):'vec2i'===e?void(new Int32Array(this.buffer,i,2)[n]=s):'vec3i'===e?void(new Int32Array(this.buffer,i,3)[n]=s):'vec4i'===e?void(new Int32Array(this.buffer,i,4)[n]=s):'vec2u'===e?void(new Uint32Array(this.buffer,i,2)[n]=s):'vec3u'===e?void(new Uint32Array(this.buffer,i,3)[n]=s):'vec4u'===e?void(new Uint32Array(this.buffer,i,4)[n]=s):void console.error(`SetDataValue: Type ${e} is not a struct`)}}}a=a.postfix}this.setData(t,r,l,i,o)}setData(e,t,n,s,r){const a=n.getTypeName();if('f32'!==a&&'f16'!==a)if('i32'!==a&&'atomic<i32>'!==a&&'x32'!==a)if('u32'!==a&&'atomic<u32>'!==a)if('bool'!==a){if('vec2f'===a||'vec2h'===a){const e=new Float32Array(this.buffer,s,2);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if('vec3f'===a||'vec3h'===a){const e=new Float32Array(this.buffer,s,3);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if('vec4f'===a||'vec4h'===a){const e=new Float32Array(this.buffer,s,4);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if('vec2i'===a){const e=new Int32Array(this.buffer,s,2);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if('vec3i'===a){const e=new Int32Array(this.buffer,s,3);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if('vec4i'===a){const e=new Int32Array(this.buffer,s,4);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if('vec2u'===a){const e=new Uint32Array(this.buffer,s,2);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if('vec3u'===a){const e=new Uint32Array(this.buffer,s,3);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if('vec4u'===a){const e=new Uint32Array(this.buffer,s,4);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if('vec2b'===a){const e=new Uint32Array(this.buffer,s,2);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if('vec3b'===a){const e=new Uint32Array(this.buffer,s,3);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if('vec4b'===a){const e=new Uint32Array(this.buffer,s,4);return void(t instanceof Pe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if('mat2x2f'===a||'mat2x2h'===a){const e=new Float32Array(this.buffer,s,4);return void(t instanceof ze?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if('mat2x3f'===a||'mat2x3h'===a){const e=new Float32Array(this.buffer,s,6);return void(t instanceof ze?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if('mat2x4f'===a||'mat2x4h'===a){const e=new Float32Array(this.buffer,s,8);return void(t instanceof ze?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7]))}if('mat3x2f'===a||'mat3x2h'===a){const e=new Float32Array(this.buffer,s,6);return void(t instanceof ze?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if('mat3x3f'===a||'mat3x3h'===a){const e=new Float32Array(this.buffer,s,9);return void(t instanceof ze?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8]))}if('mat3x4f'===a||'mat3x4h'===a){const e=new Float32Array(this.buffer,s,12);return void(t instanceof ze?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.d