typegpu 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.md +1 -1
- package/chunk-2CMWQRQC.cjs +2 -0
- package/chunk-2CMWQRQC.cjs.map +1 -0
- package/chunk-2ZAQFPSX.js +1266 -0
- package/chunk-2ZAQFPSX.js.map +1 -0
- package/chunk-35UVS2JJ.cjs +591 -0
- package/chunk-35UVS2JJ.cjs.map +1 -0
- package/chunk-A2QB4MSZ.js +4 -0
- package/{chunk-47YH5LQ7.cjs.map → chunk-A2QB4MSZ.js.map} +1 -1
- package/chunk-CMYXKKUP.cjs +1266 -0
- package/chunk-CMYXKKUP.cjs.map +1 -0
- package/chunk-DDEF2Y4S.js +591 -0
- package/chunk-DDEF2Y4S.js.map +1 -0
- package/chunk-KYBPSQX5.js +2 -0
- package/chunk-KYBPSQX5.js.map +1 -0
- package/chunk-VRYGOFCW.cjs +4 -0
- package/chunk-VRYGOFCW.cjs.map +1 -0
- package/data/index.cjs +192 -1
- package/data/index.d.cts +2 -2
- package/data/index.d.ts +2 -2
- package/data/index.js +192 -1
- package/{index-CopjPGJg.d.cts → index-CuzbyKXg.d.cts} +5 -3
- package/{index-BM7ZTN7E.d.ts → index-FHKuURMs.d.ts} +5 -3
- package/index.cjs +4269 -14
- package/index.cjs.map +1 -1
- package/index.d.cts +80 -11
- package/index.d.ts +80 -11
- package/index.js +4269 -14
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/std/index.cjs +490 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +1 -1
- package/std/index.d.ts +1 -1
- package/std/index.js +490 -1
- package/std/index.js.map +1 -1
- package/{vector-BSez01sn.d.cts → vector-CDD2FV2v.d.cts} +19 -3
- package/{vector-BSez01sn.d.ts → vector-CDD2FV2v.d.ts} +19 -3
- package/chunk-47YH5LQ7.cjs +0 -4
- package/chunk-BGPVBIFN.js +0 -4
- package/chunk-BGPVBIFN.js.map +0 -1
- package/chunk-MCUGRE3S.js +0 -2
- package/chunk-MCUGRE3S.js.map +0 -1
- package/chunk-OHFPIYFY.cjs +0 -2
- package/chunk-OHFPIYFY.cjs.map +0 -1
package/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2025 Software Mansion <swmansion.com>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkVRYGOFCWcjs = require('./chunk-VRYGOFCW.cjs');var _typedbinary = require('typed-binary'); var _typedbinary2 = _interopRequireDefault(_typedbinary);var xe={type:"bool"},ye=e=>_chunkVRYGOFCWcjs.m.call(void 0, )?`u32(${e})`:typeof e=="boolean"?e?1:0:Number.isInteger(e)?((e<0||e>4294967295)&&console.warn(`u32 value ${e} overflowed`),(e&4294967295)>>>0):Math.max(0,Math.min(4294967295,Math.floor(e))),u= exports.m =Object.assign(ye,{type:"u32"}),ue=e=>{if(_chunkVRYGOFCWcjs.m.call(void 0, ))return`i32(${e})`;if(typeof e=="boolean")return e?1:0;if(Number.isInteger(e))return(e<-2147483648||e>2147483647)&&console.warn(`i32 value ${e} overflowed`),(e|0)&4294967295;let t=e<0?Math.ceil(e):Math.floor(e);return Math.max(-2147483648,Math.min(2147483647,t))},k= exports.n =Object.assign(ue,{type:"i32"}),pe=e=>{if(_chunkVRYGOFCWcjs.m.call(void 0, ))return`f32(${e})`;if(typeof e=="boolean")return e?1:0;let t=new Float32Array(1);return t[0]=e,t[0]},p= exports.o =Object.assign(pe,{type:"f32"}),me=e=>{if(_chunkVRYGOFCWcjs.m.call(void 0, ))return`f16(${e})`;if(typeof e=="boolean")return e?1:0;let t=new ArrayBuffer(2);return _typedbinary2.default.f16.write(new _typedbinary2.default.BufferWriter(t),e),_typedbinary2.default.f16.read(new _typedbinary2.default.BufferReader(t))},ce= exports.p =Object.assign(me,{type:"f16"});var de=["bool","f32","f16","i32","u32","vec2f","vec2h","vec2i","vec2u","vec3f","vec3h","vec3i","vec3u","vec4f","vec4h","vec4i","vec4u","mat2x2f","mat3x3f","mat4x4f","struct","array","ptrFn","atomic","decorated"];function C(e){return de.includes(e==null?void 0:e.type)}function W(e){return(e==null?void 0:e.type)==="array"}function S(e){return(e==null?void 0:e.type)==="struct"}function Te(e){return(e==null?void 0:e.type)==="ptrFn"}function fe(e){return(e==null?void 0:e.type)==="atomic"}function L(e){return(e==null?void 0:e.type)==="@align"}function E(e){return(e==null?void 0:e.type)==="@size"}function $(e){return(e==null?void 0:e.type)==="@location"}function be(e){return(e==null?void 0:e.type)==="@interpolate"}function R(e){return(e==null?void 0:e.type)==="@builtin"}function f(e){return(e==null?void 0:e.type)==="decorated"}var ge=e=>{let t=n=>n;return Object.setPrototypeOf(t,ze),t.propTypes=e,t},ze={type:"struct",_label:void 0,get label(){return this._label},$name(e){return this._label=e,this},toString(){var e;return`struct:${(e=this.label)!=null?e:"<unnamed>"}`}};var g=(e,t)=>{let n=t-1,o=~n;return e&n?(e&o)+t:e};var re=["uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10-10-10-2","unorm8x4-bgra"],Ze= exports.t ={f32:"float32",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",f16:"float16",vec2h:"float16x2",vec4h:"float16x4",u32:"uint32",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",i32:"sint32",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4"};var ve=["unstruct","disarray","loose-decorated",...re];function N(e){return ve.includes(e==null?void 0:e.type)}function z(e){return(e==null?void 0:e.type)==="disarray"}function v(e){return(e==null?void 0:e.type)==="unstruct"}function T(e){return(e==null?void 0:e.type)==="loose-decorated"}function D(e){var t,n;return(n=(t=e.attribs)==null?void 0:t.find(L))==null?void 0:n.value}function oe(e){var t,n;return(n=(t=e.attribs)==null?void 0:t.find(E))==null?void 0:n.value}function nt(e){var t,n;return(n=(t=e.attribs)==null?void 0:t.find($))==null?void 0:n.value}function De(e){return C(e)||N(e)}var r=class{constructor(t){this.type=t;_chunkVRYGOFCWcjs.c.call(void 0, this,"~repr")}},Ae={uint8:u,uint8x2:_chunkVRYGOFCWcjs.q,uint8x4:_chunkVRYGOFCWcjs.y,sint8:k,sint8x2:_chunkVRYGOFCWcjs.p,sint8x4:_chunkVRYGOFCWcjs.x,unorm8:p,unorm8x2:_chunkVRYGOFCWcjs.n,unorm8x4:_chunkVRYGOFCWcjs.v,snorm8:p,snorm8x2:_chunkVRYGOFCWcjs.n,snorm8x4:_chunkVRYGOFCWcjs.v,uint16:u,uint16x2:_chunkVRYGOFCWcjs.q,uint16x4:_chunkVRYGOFCWcjs.y,sint16:k,sint16x2:_chunkVRYGOFCWcjs.p,sint16x4:_chunkVRYGOFCWcjs.x,unorm16:p,unorm16x2:_chunkVRYGOFCWcjs.n,unorm16x4:_chunkVRYGOFCWcjs.v,snorm16:p,snorm16x2:_chunkVRYGOFCWcjs.n,snorm16x4:_chunkVRYGOFCWcjs.v,float16:p,float16x2:_chunkVRYGOFCWcjs.n,float16x4:_chunkVRYGOFCWcjs.v,float32:p,float32x2:_chunkVRYGOFCWcjs.n,float32x3:_chunkVRYGOFCWcjs.r,float32x4:_chunkVRYGOFCWcjs.v,uint32:u,uint32x2:_chunkVRYGOFCWcjs.q,uint32x3:_chunkVRYGOFCWcjs.u,uint32x4:_chunkVRYGOFCWcjs.y,sint32:k,sint32x2:_chunkVRYGOFCWcjs.p,sint32x3:_chunkVRYGOFCWcjs.t,sint32x4:_chunkVRYGOFCWcjs.x,"unorm10-10-10-2":_chunkVRYGOFCWcjs.v,"unorm8x4-bgra":_chunkVRYGOFCWcjs.v},ae= exports.A =Object.keys(Ae),it= exports.B =new r("uint8"),st= exports.C =new r("uint8x2"),lt= exports.D =new r("uint8x4"),xt= exports.E =new r("sint8"),yt= exports.F =new r("sint8x2"),ut= exports.G =new r("sint8x4"),pt= exports.H =new r("unorm8"),mt= exports.I =new r("unorm8x2"),ct= exports.J =new r("unorm8x4"),dt= exports.K =new r("snorm8"),Tt= exports.L =new r("snorm8x2"),ft= exports.M =new r("snorm8x4"),bt= exports.N =new r("uint16"),wt= exports.O =new r("uint16x2"),gt= exports.P =new r("uint16x4"),zt= exports.Q =new r("sint16"),vt= exports.R =new r("sint16x2"),Dt= exports.S =new r("sint16x4"),At= exports.T =new r("unorm16"),ht= exports.U =new r("unorm16x2"),Vt= exports.V =new r("unorm16x4"),Ft= exports.W =new r("snorm16"),It= exports.X =new r("snorm16x2"),Bt= exports.Y =new r("snorm16x4"),kt= exports.Z =new r("float16"),Ct= exports._ =new r("float16x2"),Wt= exports.$ =new r("float16x4"),St= exports.aa =new r("float32"),Lt= exports.ba =new r("float32x2"),Et= exports.ca =new r("float32x3"),_t= exports.da =new r("float32x4"),Nt= exports.ea =new r("uint32"),Pt= exports.fa =new r("uint32x2"),Mt= exports.ga =new r("uint32x3"),Ut= exports.ha =new r("uint32x4"),Ot= exports.ia =new r("sint32"),$t= exports.ja =new r("sint32x2"),Rt= exports.ka =new r("sint32x3"),jt= exports.la =new r("sint32x4"),Gt= exports.ma =new r("unorm10-10-10-2"),Kt= exports.na =new r("unorm8x4-bgra");var he={bool:4,f32:4,f16:2,i32:4,u32:4,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec3f:16,vec3h:8,vec3i:16,vec3u:16,vec4f:16,vec4h:8,vec4i:16,vec4u:16,mat2x2f:8,mat3x3f:16,mat4x4f:16};function Ve(e){var o,i,l;let t=e==null?void 0:e.type,n=he[t];if(n!==void 0)return n;if(S(e))return Object.values(e.propTypes).map(m).reduce((y,ne)=>y>ne?y:ne);if(W(e))return m(e.elementType);if(v(e)){let y=Object.values(e.propTypes)[0];return y&&(o=D(y))!=null?o:1}if(z(e))return(i=D(e.elementType))!=null?i:1;if(f(e)||T(e))return(l=D(e))!=null?l:m(e.inner);if(ae.includes(t))return 1;throw new Error(`Cannot determine alignment of data: ${JSON.stringify(e)}`)}function Fe(e){var t,n;if(v(e)){let o=Object.values(e.propTypes)[0];return o?A(o):1}return z(e)?A(e.elementType):T(e)?(t=D(e))!=null?t:A(e.inner):(n=D(e))!=null?n:1}var ie=new WeakMap,se=new WeakMap;function m(e){let t=ie.get(e);return t===void 0&&(t=Ve(e),ie.set(e,t)),t}function A(e){let t=se.get(e);return t===void 0&&(t=Fe(e),se.set(e,t)),t}function Ie(e){return m(e)}var Be={bool:4,f32:4,f16:2,i32:4,u32:4,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec3f:12,vec3h:6,vec3i:12,vec3u:12,vec4f:16,vec4h:8,vec4i:16,vec4u:16,mat2x2f:16,mat3x3f:48,mat4x4f:64,uint8:1,uint8x2:2,uint8x4:4,sint8:1,sint8x2:2,sint8x4:4,unorm8:1,unorm8x2:2,unorm8x4:4,snorm8:1,snorm8x2:2,snorm8x4:4,uint16:2,uint16x2:4,uint16x4:8,sint16:2,sint16x2:4,sint16x4:8,unorm16:2,unorm16x2:4,unorm16x4:8,snorm16:2,snorm16x2:4,snorm16x4:8,float16:2,float16x2:4,float16x4:8,float32:4,float32x2:8,float32x3:12,float32x4:16,uint32:4,uint32x2:8,uint32x3:12,uint32x4:16,sint32:4,sint32x2:8,sint32x3:12,sint32x4:16,"unorm10-10-10-2":4,"unorm8x4-bgra":4};function ke(e){let t=0;for(let n of Object.values(e.propTypes)){if(Number.isNaN(t))throw new Error("Only the last property of a struct can be unbounded");if(t=g(t,m(n)),t+=c(n),Number.isNaN(t)&&n.type!=="array")throw new Error("Cannot nest unbounded struct within another struct")}return g(t,m(e))}function Ce(e){let t=0;for(let n of Object.values(e.propTypes)){let o=A(n);t=g(t,o),t+=c(n)}return t}function We(e){var n;let t=Be[e==null?void 0:e.type];if(t!==void 0)return t;if(S(e))return ke(e);if(v(e))return Ce(e);if(W(e)){if(e.elementCount===0)return Number.NaN;let o=m(e.elementType);return g(c(e.elementType),o)*e.elementCount}if(z(e)){let o=A(e.elementType);return g(c(e.elementType),o)*e.elementCount}if(f(e)||T(e))return(n=oe(e))!=null?n:c(e.inner);throw new Error(`Cannot determine size of data: ${e}`)}var le=new WeakMap;function c(e){let t=le.get(e);return t===void 0&&(t=We(e),le.set(e,t)),t}function Se(e){return c(e)}var G=(e,t)=>new j(e,t),j=class{constructor(t,n){this.elementType=t;this.elementCount=n;_chunkVRYGOFCWcjs.c.call(void 0, this,"type","array");_chunkVRYGOFCWcjs.c.call(void 0, this,"~repr");_chunkVRYGOFCWcjs.c.call(void 0, this,"~exotic");if(Number.isNaN(c(t)))throw new Error("Cannot nest runtime sized arrays.")}toString(){return`arrayOf(${this.elementType})`}};function Le(e){return{type:"ptrFn",inner:e}}var Ee=(e,t)=>new K(e,t),K=class{constructor(t,n){this.elementType=t;this.elementCount=n;_chunkVRYGOFCWcjs.c.call(void 0, this,"type","disarray");_chunkVRYGOFCWcjs.c.call(void 0, this,"~repr")}};var _e=e=>new H(e),H=class{constructor(t){this.propTypes=t;_chunkVRYGOFCWcjs.c.call(void 0, this,"type","unstruct");_chunkVRYGOFCWcjs.c.call(void 0, this,"~repr")}};function ee(e){let t={"~repr":void 0,type:e.type,label:e.type};return Object.assign((...o)=>{if(_chunkVRYGOFCWcjs.m.call(void 0, ))return`${t.type}(${o.join(", ")})`;let i=[];for(let l of o)if(typeof l=="number")i.push(l);else for(let y=0;y<l.length;++y)i.push(l[y]);for(let l=i.length;l<e.columns*e.rows;++l)i.push(0);return e.makeFromElements(...i)},t)}var J=class{constructor(...t){_chunkVRYGOFCWcjs.c.call(void 0, this,"columns");_chunkVRYGOFCWcjs.c.call(void 0, this,"length",4);this.columns=[this.makeColumn(t[0],t[1]),this.makeColumn(t[2],t[3])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[1].x}get 3(){return this.columns[1].y}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[1].x=t}set 3(t){this.columns[1].y=t}"~resolve"(){return`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`}},q=class extends J{constructor(){super(...arguments);_chunkVRYGOFCWcjs.c.call(void 0, this,"kind","mat2x2f")}makeColumn(n,o){return _chunkVRYGOFCWcjs.n.call(void 0, n,o)}},Q=class{constructor(...t){_chunkVRYGOFCWcjs.c.call(void 0, this,"columns");_chunkVRYGOFCWcjs.c.call(void 0, this,"length",12);this.columns=[this.makeColumn(t[0],t[1],t[2]),this.makeColumn(t[3],t[4],t[5]),this.makeColumn(t[6],t[7],t[8])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return 0}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return 0}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return 0}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){}"~resolve"(){return`${this.kind}(${this[0]}, ${this[1]}, ${this[2]}, ${this[4]}, ${this[5]}, ${this[6]}, ${this[8]}, ${this[9]}, ${this[10]})`}},X=class extends Q{constructor(){super(...arguments);_chunkVRYGOFCWcjs.c.call(void 0, this,"kind","mat3x3f")}makeColumn(n,o,i){return _chunkVRYGOFCWcjs.r.call(void 0, n,o,i)}},Y=class{constructor(...t){_chunkVRYGOFCWcjs.c.call(void 0, this,"columns");_chunkVRYGOFCWcjs.c.call(void 0, this,"length",16);this.columns=[this.makeColumn(t[0],t[1],t[2],t[3]),this.makeColumn(t[4],t[5],t[6],t[7]),this.makeColumn(t[8],t[9],t[10],t[11]),this.makeColumn(t[12],t[13],t[14],t[15])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return this.columns[0].w}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return this.columns[1].w}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return this.columns[2].w}get 12(){return this.columns[3].x}get 13(){return this.columns[3].y}get 14(){return this.columns[3].z}get 15(){return this.columns[3].w}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){this.columns[0].w=t}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){this.columns[1].w=t}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){this.columns[2].w=t}set 12(t){this.columns[3].x=t}set 13(t){this.columns[3].y=t}set 14(t){this.columns[3].z=t}set 15(t){this.columns[3].w=t}"~resolve"(){return`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`}},Z=class extends Y{constructor(){super(...arguments);_chunkVRYGOFCWcjs.c.call(void 0, this,"kind","mat4x4f")}makeColumn(n,o,i,l){return _chunkVRYGOFCWcjs.v.call(void 0, n,o,i,l)}},Ne= exports.xa =ee({type:"mat2x2f",rows:2,columns:2,makeFromElements:(...e)=>new q(...e)}),Pe= exports.ya =ee({type:"mat3x3f",rows:3,columns:3,makeFromElements:(...e)=>new X(...e)}),Me= exports.za =ee({type:"mat4x4f",rows:4,columns:4,makeFromElements:(...e)=>new Z(...e)});function Ue(e){return e.kind==="mat3x3f"?[e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]]:Array.from({length:e.length}).map((t,n)=>e[n])}function Oe(e){return new te(e)}var te=class{constructor(t){this.inner=t;_chunkVRYGOFCWcjs.c.call(void 0, this,"type","atomic");_chunkVRYGOFCWcjs.c.call(void 0, this,"~repr")}};function s(e,t){return f(e)?new M(e.inner,[t,...e.attribs]):T(e)?new U(e.inner,[t,...e.attribs]):N(e)?new U(e,[t]):new M(e,[t])}function $e(e,t){return s(t,{type:"@align",value:e})}function Re(e,t){return s(t,{type:"@size",value:e})}function je(e,t){return s(t,{type:"@location",value:e})}function Ge(e,t){return s(t,{type:"@interpolate",value:e})}function Ke(e){return(f(e)||T(e))&&e.attribs.find(R)!==void 0}function Dn(e){return!f(e)&&!T(e)?"":e.attribs.map(t=>`${t.type}(${t.value}) `).join("")}var P=class{constructor(t,n){this.inner=t;this.attribs=n;_chunkVRYGOFCWcjs.c.call(void 0, this,"~repr");var l,y;let o=(l=n.find(L))==null?void 0:l.value,i=(y=n.find(E))==null?void 0:y.value;if(o!==void 0){if(o<=0)throw new Error(`Custom data alignment must be a positive number, got: ${o}.`);if(Math.log2(o)%1!==0)throw new Error(`Alignment has to be a power of 2, got: ${o}.`);if(C(this.inner)&&o%m(this.inner)!==0)throw new Error(`Custom alignment has to be a multiple of the standard data alignment. Got: ${o}, expected multiple of: ${m(this.inner)}.`)}if(i!==void 0){if(i<c(this.inner))throw new Error(`Custom data size cannot be smaller then the standard data size. Got: ${i}, expected at least: ${c(this.inner)}.`);if(i<=0)throw new Error(`Custom data size must be a positive number. Got: ${i}.`)}}},M=class extends P{constructor(){super(...arguments);_chunkVRYGOFCWcjs.c.call(void 0, this,"type","decorated")}},U=class extends P{constructor(){super(...arguments);_chunkVRYGOFCWcjs.c.call(void 0, this,"type","loose-decorated")}};var He={vertexIndex:s(u,{type:"@builtin",value:"vertex_index"}),instanceIndex:s(u,{type:"@builtin",value:"instance_index"}),position:s(_chunkVRYGOFCWcjs.v,{type:"@builtin",value:"position"}),clipDistances:s(G(u,8),{type:"@builtin",value:"clip_distances"}),frontFacing:s(p,{type:"@builtin",value:"front_facing"}),fragDepth:s(p,{type:"@builtin",value:"frag_depth"}),sampleIndex:s(u,{type:"@builtin",value:"sample_index"}),sampleMask:s(u,{type:"@builtin",value:"sample_mask"}),localInvocationId:s(_chunkVRYGOFCWcjs.u,{type:"@builtin",value:"local_invocation_id"}),localInvocationIndex:s(u,{type:"@builtin",value:"local_invocation_index"}),globalInvocationId:s(_chunkVRYGOFCWcjs.u,{type:"@builtin",value:"global_invocation_id"}),workgroupId:s(_chunkVRYGOFCWcjs.u,{type:"@builtin",value:"workgroup_id"}),numWorkgroups:s(_chunkVRYGOFCWcjs.u,{type:"@builtin",value:"num_workgroups"})};exports.a = C; exports.b = W; exports.c = S; exports.d = Te; exports.e = fe; exports.f = L; exports.g = E; exports.h = $; exports.i = be; exports.j = R; exports.k = f; exports.l = xe; exports.m = u; exports.n = k; exports.o = p; exports.p = ce; exports.q = ge; exports.r = g; exports.s = re; exports.t = Ze; exports.u = N; exports.v = z; exports.w = v; exports.x = T; exports.y = nt; exports.z = De; exports.A = ae; exports.B = it; exports.C = st; exports.D = lt; exports.E = xt; exports.F = yt; exports.G = ut; exports.H = pt; exports.I = mt; exports.J = ct; exports.K = dt; exports.L = Tt; exports.M = ft; exports.N = bt; exports.O = wt; exports.P = gt; exports.Q = zt; exports.R = vt; exports.S = Dt; exports.T = At; exports.U = ht; exports.V = Vt; exports.W = Ft; exports.X = It; exports.Y = Bt; exports.Z = kt; exports._ = Ct; exports.$ = Wt; exports.aa = St; exports.ba = Lt; exports.ca = Et; exports.da = _t; exports.ea = Nt; exports.fa = Pt; exports.ga = Mt; exports.ha = Ut; exports.ia = Ot; exports.ja = $t; exports.ka = Rt; exports.la = jt; exports.ma = Gt; exports.na = Kt; exports.oa = m; exports.pa = A; exports.qa = Ie; exports.ra = c; exports.sa = Se; exports.ta = G; exports.ua = Le; exports.va = Ee; exports.wa = _e; exports.xa = Ne; exports.ya = Pe; exports.za = Me; exports.Aa = Ue; exports.Ba = Oe; exports.Ca = s; exports.Da = $e; exports.Ea = Re; exports.Fa = je; exports.Ga = Ge; exports.Ha = Ke; exports.Ia = Dn; exports.Ja = He;
|
2
|
+
//# sourceMappingURL=chunk-2CMWQRQC.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/data/numeric.ts","../src/data/wgslTypes.ts","../src/data/struct.ts","../src/mathUtils.ts","../src/shared/vertexFormat.ts","../src/data/dataTypes.ts","../src/data/vertexFormatData.ts","../src/data/alignmentOf.ts","../src/data/sizeOf.ts","../src/data/array.ts","../src/data/ptr.ts","../src/data/disarray.ts","../src/data/unstruct.ts","../src/data/matrix.ts","../src/data/atomic.ts","../src/data/attributes.ts","../src/builtin.ts"],"names":["bin","bool","u32Cast","v","inGPUMode","u32","i32Cast","value","i32","f32Cast","arr","f32","f16Cast","f16","wgslTypeLiterals","isWgslData","isWgslArray","schema","isWgslStruct","isPtrFn","isAtomic","isAlignAttrib","isSizeAttrib","isLocationAttrib","isInterpolateAttrib","isBuiltinAttrib","isDecorated","struct","props","TgpuStructImpl","label","_a","roundUp","modulo","bitMask","invBitMask","vertexFormats","kindToDefaultFormatMap","looseTypeLiterals","isLooseData","data","isDisarray","isUnstruct","isLooseDecorated","getCustomAlignment","_b","getCustomSize","getCustomLocation","isData","TgpuVertexFormatDataImpl","type","__publicField","formatToWGSLType","vec2u","vec4u","vec2i","vec4i","vec2f","vec4f","vec3f","vec3u","vec3i","packedFormats","uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10_10_10_2","unorm8x4_bgra","knownAlignmentMap","computeAlignment","_c","dataType","knownAlignment","alignmentOf","a","b","firstProp","computeCustomAlignment","customAlignmentOf","cachedAlignments","cachedCustomAlignments","alignment","PUBLIC_alignmentOf","knownSizesMap","sizeOfStruct","size","property","sizeOf","sizeOfUnstruct","computeSize","knownSize","cachedSizes","PUBLIC_sizeOf","arrayOf","elementType","elementCount","TgpuArrayImpl","ptrFn","inner","disarrayOf","count","DisarrayImpl","unstruct","properties","UnstructImpl","propTypes","createMatSchema","options","MatSchema","args","elements","arg","i","mat2x2Impl","_","mat2x2fImpl","e0","e1","mat3x3Impl","mat3x3fImpl","x","y","z","mat4x4Impl","mat4x4fImpl","w","mat2x2f","mat3x3f","mat4x4f","matToArray","mat","idx","atomic","AtomicImpl","attribute","attrib","DecoratedImpl","LooseDecoratedImpl","align","location","interpolate","interpolationType","isBuiltin","getAttributesString","field","BaseDecoratedImpl","attribs","alignAttrib","sizeAttrib","builtin"],"mappings":"+GAAA,OAAOA,MAAS,eAOT,IAAMC,GAAa,CACxB,KAAM,MACR,EASMC,GAAWC,GACXC,EAAU,EACL,OAAOD,CAAC,IAGb,OAAOA,GAAM,UACRA,EAAI,EAAI,EAEb,OAAO,UAAUA,CAAC,IAChBA,EAAI,GAAKA,EAAI,aACf,QAAQ,KAAK,aAAaA,CAAC,aAAa,GAE5BA,EAAI,cACD,GAEZ,KAAK,IAAI,EAAG,KAAK,IAAI,WAAY,KAAK,MAAMA,CAAC,CAAC,CAAC,EAe3CE,EAAiB,OAAO,OAAOH,GAAS,CACnD,KAAM,KACR,CAAC,EASKI,GAAWH,GAAwB,CACvC,GAAIC,EAAU,EACZ,MAAO,OAAOD,CAAC,IAGjB,GAAI,OAAOA,GAAM,UACf,OAAOA,EAAI,EAAI,EAEjB,GAAI,OAAO,UAAUA,CAAC,EACpB,OAAIA,EAAI,aAAeA,EAAI,aACzB,QAAQ,KAA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,EAAG,CACxC,KAAM,WACN,MAAO,gBACT,CAAC,EACD,YAAaqK,EAAU/J,EAAK,CAC1B,KAAM,WACN,MAAO,cACT,CAAC,EACD,UAAW+J,EAAU/J,EAAK,CACxB,KAAM,WACN,MAAO,YACT,CAAC,EACD,YAAa+J,EAAUrK,EAAK,CAC1B,KAAM,WACN,MAAO,cACT,CAAC,EACD,WAAYqK,EAAUrK,EAAK,CACzB,KAAM,WACN,MAAO,aACT,CAAC,EACD,kBAAmBqK,EAAU9G,EAAO,CAClC,KAAM,WACN,MAAO,qBACT,CAAC,EACD,qBAAsB8G,EAAUrK,EAAK,CACnC,KAAM,WACN,MAAO,wBACT,CAAC,EACD,mBAAoBqK,EAAU9G,EAAO,CACnC,KAAM,WACN,MAAO,sBACT,CAAC,EACD,YAAa8G,EAAU9G,EAAO,CAC5B,KAAM,WACN,MAAO,cACT,CAAC,EACD,cAAe8G,EAAU9G,EAAO,CAC9B,KAAM,WACN,MAAO,gBACT,CAAC,CACH","sourcesContent":["import bin from 'typed-binary';\nimport { inGPUMode } from '../gpuMode';\nimport type { Bool, F16, F32, I32, U32 } from './wgslTypes';\n\n/**\n * A schema that represents a boolean value. (equivalent to `bool` in WGSL)\n */\nexport const bool: Bool = {\n type: 'bool',\n} as Bool;\n\n/**\n * Unsigned 32-bit integer schema representing a single WGSL u32 value.\n */\nexport type NativeU32 = U32 & { '~exotic': U32 } & ((\n v: number | boolean,\n ) => number);\n\nconst u32Cast = (v: number | boolean) => {\n if (inGPUMode()) {\n return `u32(${v})` as unknown as number;\n }\n\n if (typeof v === 'boolean') {\n return v ? 1 : 0;\n }\n if (Number.isInteger(v)) {\n if (v < 0 || v > 0xffffffff) {\n console.warn(`u32 value ${v} overflowed`);\n }\n const value = v & 0xffffffff;\n return value >>> 0;\n }\n return Math.max(0, Math.min(0xffffffff, Math.floor(v)));\n};\n\n/**\n * A schema that represents an unsigned 32-bit integer value. (equivalent to `u32` in WGSL)\n *\n * Can also be called to cast a value to an u32 in accordance with WGSL casting rules.\n *\n * @example\n * const value = u32(3.14); // 3\n * @example\n * const value = u32(-1); // 4294967295\n * @example\n * const value = u32(-3.1); // 0\n */\nexport const u32: NativeU32 = Object.assign(u32Cast, {\n type: 'u32',\n}) as NativeU32;\n\n/**\n * Signed 32-bit integer schema representing a single WGSL i32 value.\n */\nexport type NativeI32 = I32 & { '~exotic': I32 } & ((\n v: number | boolean,\n ) => number);\n\nconst i32Cast = (v: number | boolean) => {\n if (inGPUMode()) {\n return `i32(${v})` as unknown as number;\n }\n\n if (typeof v === 'boolean') {\n return v ? 1 : 0;\n }\n if (Number.isInteger(v)) {\n if (v < -0x80000000 || v > 0x7fffffff) {\n console.warn(`i32 value ${v} overflowed`);\n }\n const value = v | 0;\n return value & 0xffffffff;\n }\n // round towards zero\n const value = v < 0 ? Math.ceil(v) : Math.floor(v);\n return Math.max(-0x80000000, Math.min(0x7fffffff, value));\n};\n\n/**\n * A schema that represents a signed 32-bit integer value. (equivalent to `i32` in WGSL)\n *\n * Can also be called to cast a value to an i32 in accordance with WGSL casting rules.\n *\n * @example\n * const value = i32(3.14); // 3\n * @example\n * const value = i32(-3.9); // -3\n * @example\n * const value = i32(10000000000) // 1410065408\n */\nexport const i32: NativeI32 = Object.assign(i32Cast, {\n type: 'i32',\n}) as NativeI32;\n\n/**\n * 32-bit float schema representing a single WGSL f32 value.\n */\nexport type NativeF32 = F32 & { '~exotic': F32 } & ((\n v: number | boolean,\n ) => number);\n\nconst f32Cast = (v: number | boolean) => {\n if (inGPUMode()) {\n return `f32(${v})` as unknown as number;\n }\n if (typeof v === 'boolean') {\n return v ? 1 : 0;\n }\n const arr = new Float32Array(1);\n arr[0] = v;\n return arr[0];\n};\n\n/**\n * A schema that represents a 32-bit float value. (equivalent to `f32` in WGSL)\n *\n * Can also be called to cast a value to an f32.\n *\n * @example\n * const value = f32(true); // 1\n */\nexport const f32: NativeF32 = Object.assign(f32Cast, {\n type: 'f32',\n}) as NativeF32;\n\n/**\n * 16-bit float schema representing a single WGSL f16 value.\n */\nexport type NativeF16 = F16 & { '~exotic': F16 } & ((\n v: number | boolean,\n ) => number);\n\nconst f16Cast = (v: number | boolean) => {\n if (inGPUMode()) {\n // TODO: make usage of f16() in GPU mode check for feature availability and throw if not available\n return `f16(${v})` as unknown as number;\n }\n if (typeof v === 'boolean') {\n return v ? 1 : 0;\n }\n const arr = new ArrayBuffer(2);\n bin.f16.write(new bin.BufferWriter(arr), v);\n return bin.f16.read(new bin.BufferReader(arr));\n};\n\n/**\n * A schema that represents a 16-bit float value. (equivalent to `f16` in WGSL)\n *\n * Can also be called to cast a value to an f16.\n *\n * @example\n * const value = f16(true); // 1\n * @example\n * const value = f16(21877.5); // 21872\n */\nexport const f16: NativeF16 = Object.assign(f16Cast, {\n type: 'f16',\n}) as NativeF16;\n","import type { Infer, InferRecord } from '../shared/repr';\n\nexport interface NumberArrayView {\n readonly length: number;\n [n: number]: number;\n}\n\nexport interface BaseWgslData {\n type: string;\n /** Type-token, not available at runtime */\n readonly '~repr': unknown;\n}\n\n// #region Instance Types\n\ninterface Swizzle2<T2, T3, T4> {\n readonly xx: T2;\n readonly xy: T2;\n readonly yx: T2;\n readonly yy: T2;\n\n readonly xxx: T3;\n readonly xxy: T3;\n readonly xyx: T3;\n readonly xyy: T3;\n readonly yxx: T3;\n readonly yxy: T3;\n readonly yyx: T3;\n readonly yyy: T3;\n\n readonly xxxx: T4;\n readonly xxxy: T4;\n readonly xxyx: T4;\n readonly xxyy: T4;\n readonly xyxx: T4;\n readonly xyxy: T4;\n readonly xyyx: T4;\n readonly xyyy: T4;\n readonly yxxx: T4;\n readonly yxxy: T4;\n readonly yxyx: T4;\n readonly yxyy: T4;\n readonly yyxx: T4;\n readonly yyxy: T4;\n readonly yyyx: T4;\n readonly yyyy: T4;\n}\n\ninterface Swizzle3<T2, T3, T4> extends Swizzle2<T2, T3, T4> {\n readonly xz: T2;\n readonly yz: T2;\n readonly zx: T2;\n readonly zy: T2;\n readonly zz: T2;\n\n readonly xxz: T3;\n readonly xyz: T3;\n readonly xzx: T3;\n readonly xzy: T3;\n readonly xzz: T3;\n readonly yxz: T3;\n readonly yyz: T3;\n readonly yzx: T3;\n readonly yzy: T3;\n readonly yzz: T3;\n readonly zxx: T3;\n readonly zxy: T3;\n readonly zxz: T3;\n readonly zyx: T3;\n readonly zyy: T3;\n readonly zyz: T3;\n readonly zzx: T3;\n readonly zzy: T3;\n readonly zzz: T3;\n\n readonly xxxz: T4;\n readonly xxyz: T4;\n readonly xxzx: T4;\n readonly xxzy: T4;\n readonly xxzz: T4;\n readonly xyxz: T4;\n readonly xyyz: T4;\n readonly xyzx: T4;\n readonly xyzy: T4;\n readonly xyzz: T4;\n readonly xzxx: T4;\n readonly xzxy: T4;\n readonly xzxz: T4;\n readonly xzyx: T4;\n readonly xzyy: T4;\n readonly xzyz: T4;\n readonly xzzx: T4;\n readonly xzzy: T4;\n readonly xzzz: T4;\n readonly yxxz: T4;\n readonly yxyz: T4;\n readonly yxzx: T4;\n readonly yxzy: T4;\n readonly yxzz: T4;\n readonly yyxz: T4;\n readonly yyyz: T4;\n readonly yyzx: T4;\n readonly yyzy: T4;\n readonly yyzz: T4;\n readonly yzxx: T4;\n readonly yzxy: T4;\n readonly yzxz: T4;\n readonly yzyx: T4;\n readonly yzyy: T4;\n readonly yzyz: T4;\n readonly yzzx: T4;\n readonly yzzy: T4;\n readonly yzzz: T4;\n readonly zxxx: T4;\n readonly zxxy: T4;\n readonly zxxz: T4;\n readonly zxyx: T4;\n readonly zxyy: T4;\n readonly zxyz: T4;\n readonly zxzx: T4;\n readonly zxzy: T4;\n readonly zxzz: T4;\n readonly zyxx: T4;\n readonly zyxy: T4;\n readonly zyxz: T4;\n readonly zyyx: T4;\n readonly zyyy: T4;\n readonly zyyz: T4;\n readonly zyzx: T4;\n readonly zyzy: T4;\n readonly zyzz: T4;\n readonly zzxx: T4;\n readonly zzxy: T4;\n readonly zzxz: T4;\n readonly zzyx: T4;\n readonly zzyy: T4;\n readonly zzyz: T4;\n readonly zzzx: T4;\n readonly zzzy: T4;\n readonly zzzz: T4;\n}\n\ninterface Swizzle4<T2, T3, T4> extends Swizzle3<T2, T3, T4> {\n readonly yw: T2;\n readonly zw: T2;\n readonly wx: T2;\n readonly wy: T2;\n readonly wz: T2;\n readonly ww: T2;\n\n readonly xxw: T3;\n readonly xyw: T3;\n readonly xzw: T3;\n readonly xwx: T3;\n readonly xwy: T3;\n readonly xwz: T3;\n readonly xww: T3;\n readonly yxw: T3;\n readonly yyw: T3;\n readonly yzw: T3;\n readonly ywx: T3;\n readonly ywy: T3;\n readonly ywz: T3;\n readonly yww: T3;\n readonly zxw: T3;\n readonly zyw: T3;\n readonly zzw: T3;\n readonly zwx: T3;\n readonly zwy: T3;\n readonly zwz: T3;\n readonly zww: T3;\n readonly wxx: T3;\n readonly wxz: T3;\n readonly wxy: T3;\n readonly wyy: T3;\n readonly wyz: T3;\n readonly wzz: T3;\n readonly wwx: T3;\n readonly wwy: T3;\n readonly wwz: T3;\n readonly www: T3;\n\n readonly xxxw: T4;\n readonly xxyw: T4;\n readonly xxzw: T4;\n readonly xxwx: T4;\n readonly xxwy: T4;\n readonly xxwz: T4;\n readonly xxww: T4;\n readonly xyxw: T4;\n readonly xyyw: T4;\n readonly xyzw: T4;\n readonly xywx: T4;\n readonly xywy: T4;\n readonly xywz: T4;\n readonly xyww: T4;\n readonly xzxw: T4;\n readonly xzyw: T4;\n readonly xzzw: T4;\n readonly xzwx: T4;\n readonly xzwy: T4;\n readonly xzwz: T4;\n readonly xzww: T4;\n readonly xwxx: T4;\n readonly xwxy: T4;\n readonly xwxz: T4;\n readonly xwyy: T4;\n readonly xwyz: T4;\n readonly xwzz: T4;\n readonly xwwx: T4;\n readonly xwwy: T4;\n readonly xwwz: T4;\n readonly xwww: T4;\n readonly yxxw: T4;\n readonly yxyw: T4;\n readonly yxzw: T4;\n readonly yxwx: T4;\n readonly yxwy: T4;\n readonly yxwz: T4;\n readonly yxww: T4;\n readonly yyxw: T4;\n readonly yyyw: T4;\n readonly yyzw: T4;\n readonly yywx: T4;\n readonly yywy: T4;\n readonly yywz: T4;\n readonly yyww: T4;\n readonly yzxw: T4;\n readonly yzyw: T4;\n readonly yzzw: T4;\n readonly yzwx: T4;\n readonly yzwy: T4;\n readonly yzwz: T4;\n readonly yzww: T4;\n readonly ywxx: T4;\n readonly ywxy: T4;\n readonly ywxz: T4;\n readonly ywxw: T4;\n readonly ywyy: T4;\n readonly ywyz: T4;\n readonly ywzz: T4;\n readonly ywwx: T4;\n readonly ywwy: T4;\n readonly ywwz: T4;\n readonly ywww: T4;\n readonly zxxw: T4;\n readonly zxyw: T4;\n readonly zxzw: T4;\n readonly zxwx: T4;\n readonly zxwy: T4;\n readonly zxwz: T4;\n readonly zxww: T4;\n readonly zyxw: T4;\n readonly zyyw: T4;\n readonly zyzw: T4;\n readonly zywx: T4;\n readonly zywy: T4;\n readonly zywz: T4;\n readonly zyww: T4;\n readonly zzxw: T4;\n readonly zzyw: T4;\n readonly zzzw: T4;\n readonly zzwx: T4;\n readonly zzwy: T4;\n readonly zzwz: T4;\n readonly zzww: T4;\n readonly zwxx: T4;\n readonly zwxy: T4;\n readonly zwxz: T4;\n readonly zwxw: T4;\n readonly zwyy: T4;\n readonly zwyz: T4;\n readonly zwzz: T4;\n readonly zwwx: T4;\n readonly zwwy: T4;\n readonly zwwz: T4;\n readonly zwww: T4;\n readonly wxxx: T4;\n readonly wxxy: T4;\n readonly wxxz: T4;\n readonly wxxw: T4;\n readonly wxyx: T4;\n readonly wxyy: T4;\n readonly wxyz: T4;\n readonly wxyw: T4;\n readonly wxzx: T4;\n readonly wxzy: T4;\n readonly wxzz: T4;\n readonly wxzw: T4;\n readonly wxwx: T4;\n readonly wxwy: T4;\n readonly wxwz: T4;\n readonly wxww: T4;\n readonly wyxx: T4;\n readonly wyxy: T4;\n readonly wyxz: T4;\n readonly wyxw: T4;\n readonly wyyy: T4;\n readonly wyyz: T4;\n readonly wyzw: T4;\n readonly wywx: T4;\n readonly wywy: T4;\n readonly wywz: T4;\n readonly wyww: T4;\n readonly wzxx: T4;\n readonly wzxy: T4;\n readonly wzxz: T4;\n readonly wzxw: T4;\n readonly wzyy: T4;\n readonly wzyz: T4;\n readonly wzzy: T4;\n readonly wzzw: T4;\n readonly wzwx: T4;\n readonly wzwy: T4;\n readonly wzwz: T4;\n readonly wzww: T4;\n readonly wwxx: T4;\n readonly wwxy: T4;\n readonly wwxz: T4;\n readonly wwxw: T4;\n readonly wwyy: T4;\n readonly wwyz: T4;\n readonly wwzz: T4;\n readonly wwwx: T4;\n readonly wwwy: T4;\n readonly wwwz: T4;\n readonly wwww: T4;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec2f or vec2<f32>.\n * A vector with 2 elements of type f32\n */\nexport interface v2f extends NumberArrayView, Swizzle2<v2f, v3f, v4f> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec2f';\n x: number;\n y: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec2h or vec2<f16>.\n * A vector with 2 elements of type f16\n */\nexport interface v2h extends NumberArrayView, Swizzle2<v2h, v3h, v4h> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec2h';\n x: number;\n y: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec2i or vec2<i32>.\n * A vector with 2 elements of type i32\n */\nexport interface v2i extends NumberArrayView, Swizzle2<v2i, v3i, v4i> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec2i';\n x: number;\n y: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec2u or vec2<u32>.\n * A vector with 2 elements of type u32\n */\nexport interface v2u extends NumberArrayView, Swizzle2<v2u, v3u, v4u> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec2u';\n x: number;\n y: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec3f or vec3<f32>.\n * A vector with 3 elements of type f32\n */\nexport interface v3f extends NumberArrayView, Swizzle3<v2f, v3f, v4f> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec3f';\n x: number;\n y: number;\n z: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec3h or vec3<f16>.\n * A vector with 3 elements of type f16\n */\nexport interface v3h extends NumberArrayView, Swizzle3<v2h, v3h, v4h> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec3h';\n x: number;\n y: number;\n z: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec3i or vec3<i32>.\n * A vector with 3 elements of type i32\n */\nexport interface v3i extends NumberArrayView, Swizzle3<v2i, v3i, v4i> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec3i';\n x: number;\n y: number;\n z: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec3u or vec3<u32>.\n * A vector with 3 elements of type u32\n */\nexport interface v3u extends NumberArrayView, Swizzle3<v2u, v3u, v4u> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec3u';\n x: number;\n y: number;\n z: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec4f or vec4<f32>.\n * A vector with 4 elements of type f32\n */\nexport interface v4f extends NumberArrayView, Swizzle4<v2f, v3f, v4f> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec4f';\n x: number;\n y: number;\n z: number;\n w: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec4h or vec4<f16>.\n * A vector with 4 elements of type f16\n */\nexport interface v4h extends NumberArrayView, Swizzle4<v2h, v3h, v4h> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec4h';\n x: number;\n y: number;\n z: number;\n w: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec4i or vec4<i32>.\n * A vector with 4 elements of type i32\n */\nexport interface v4i extends NumberArrayView, Swizzle4<v2i, v3i, v4i> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec4i';\n x: number;\n y: number;\n z: number;\n w: number;\n}\n\n/**\n * Interface representing its WGSL vector type counterpart: vec4u or vec4<u32>.\n * A vector with 4 elements of type u32\n */\nexport interface v4u extends NumberArrayView, Swizzle4<v2u, v3u, v4u> {\n /** use to distinguish between vectors of the same size on the type level */\n readonly kind: 'vec4u';\n x: number;\n y: number;\n z: number;\n w: number;\n}\n\nexport type AnyVecInstance =\n | v2f\n | v2h\n | v2i\n | v2u\n | v3f\n | v3h\n | v3i\n | v3u\n | v4f\n | v4h\n | v4i\n | v4u;\n\nexport interface matBase<TColumn> extends NumberArrayView {\n readonly columns: readonly TColumn[];\n}\n\n/**\n * Interface representing its WGSL matrix type counterpart: mat2x2\n * A matrix with 2 rows and 2 columns, with elements of type `TColumn`\n */\nexport interface mat2x2<TColumn> extends matBase<TColumn> {\n readonly length: 4;\n readonly kind: string;\n [n: number]: number;\n}\n\n/**\n * Interface representing its WGSL matrix type counterpart: mat2x2f or mat2x2<f32>\n * A matrix with 2 rows and 2 columns, with elements of type d.f32\n */\nexport interface m2x2f extends mat2x2<v2f> {\n readonly kind: 'mat2x2f';\n}\n\n/**\n * Interface representing its WGSL matrix type counterpart: mat3x3\n * A matrix with 3 rows and 3 columns, with elements of type `TColumn`\n */\nexport interface mat3x3<TColumn> extends matBase<TColumn> {\n readonly length: 12;\n readonly kind: string;\n [n: number]: number;\n}\n\n/**\n * Interface representing its WGSL matrix type counterpart: mat3x3f or mat3x3<f32>\n * A matrix with 3 rows and 3 columns, with elements of type d.f32\n */\nexport interface m3x3f extends mat3x3<v3f> {\n readonly kind: 'mat3x3f';\n}\n\n/**\n * Interface representing its WGSL matrix type counterpart: mat4x4\n * A matrix with 4 rows and 4 columns, with elements of type `TColumn`\n */\nexport interface mat4x4<TColumn> extends matBase<TColumn> {\n readonly length: 16;\n readonly kind: string;\n [n: number]: number;\n}\n\n/**\n * Interface representing its WGSL matrix type counterpart: mat4x4f or mat4x4<f32>\n * A matrix with 4 rows and 4 columns, with elements of type d.f32\n */\nexport interface m4x4f extends mat4x4<v4f> {\n readonly kind: 'mat4x4f';\n}\n\nexport type AnyMatInstance = m2x2f | m3x3f | m4x4f;\n\n// #endregion\n\n// #region WGSL Schema Types\n\n/**\n * Boolean schema representing a single WGSL bool value.\n * Cannot be used inside buffers as it is not host-shareable.\n */\nexport interface Bool {\n readonly type: 'bool';\n readonly '~repr': boolean;\n}\n\nexport interface F32 {\n readonly type: 'f32';\n /** Type-token, not available at runtime */\n readonly '~repr': number;\n}\n\nexport interface F16 {\n readonly type: 'f16';\n /** Type-token, not available at runtime */\n readonly '~repr': number;\n}\n\nexport interface I32 {\n readonly type: 'i32';\n /** Type-token, not available at runtime */\n readonly '~repr': number;\n}\n\nexport interface U32 {\n readonly type: 'u32';\n /** Type-token, not available at runtime */\n readonly '~repr': number;\n}\n\nexport interface Vec2f {\n readonly type: 'vec2f';\n /** Type-token, not available at runtime */\n readonly '~repr': v2f;\n}\n\nexport interface Vec2h {\n readonly type: 'vec2h';\n /** Type-token, not available at runtime */\n readonly '~repr': v2h;\n}\n\nexport interface Vec2i {\n readonly type: 'vec2i';\n /** Type-token, not available at runtime */\n readonly '~repr': v2i;\n}\n\nexport interface Vec2u {\n readonly type: 'vec2u';\n /** Type-token, not available at runtime */\n readonly '~repr': v2u;\n}\n\nexport interface Vec3f {\n readonly type: 'vec3f';\n /** Type-token, not available at runtime */\n readonly '~repr': v3f;\n}\n\nexport interface Vec3h {\n readonly type: 'vec3h';\n /** Type-token, not available at runtime */\n readonly '~repr': v3h;\n}\n\nexport interface Vec3i {\n readonly type: 'vec3i';\n /** Type-token, not available at runtime */\n readonly '~repr': v3i;\n}\n\nexport interface Vec3u {\n readonly type: 'vec3u';\n /** Type-token, not available at runtime */\n readonly '~repr': v3u;\n}\n\nexport interface Vec4f {\n readonly type: 'vec4f';\n /** Type-token, not available at runtime */\n readonly '~repr': v4f;\n}\n\nexport interface Vec4h {\n readonly type: 'vec4h';\n /** Type-token, not available at runtime */\n readonly '~repr': v4h;\n}\n\nexport interface Vec4i {\n readonly type: 'vec4i';\n /** Type-token, not available at runtime */\n readonly '~repr': v4i;\n}\n\nexport interface Vec4u {\n readonly type: 'vec4u';\n /** Type-token, not available at runtime */\n readonly '~repr': v4u;\n}\n\nexport interface Mat2x2f {\n readonly type: 'mat2x2f';\n /** Type-token, not available at runtime */\n readonly '~repr': m2x2f;\n}\n\nexport interface Mat3x3f {\n readonly type: 'mat3x3f';\n /** Type-token, not available at runtime */\n readonly '~repr': m3x3f;\n}\n\nexport interface Mat4x4f {\n readonly type: 'mat4x4f';\n /** Type-token, not available at runtime */\n readonly '~repr': m4x4f;\n}\n\nexport interface WgslStruct<\n TProps extends Record<string, BaseWgslData> = Record<string, BaseWgslData>,\n> {\n (props: InferRecord<TProps>): InferRecord<TProps>;\n readonly type: 'struct';\n readonly label?: string | undefined;\n readonly propTypes: TProps;\n /** Type-token, not available at runtime */\n readonly '~repr': InferRecord<TProps>;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: <we need the type to be broader than WgslStruct<Record<string, BaseWgslData>>\nexport type AnyWgslStruct = WgslStruct<any>;\n\nexport interface WgslArray<TElement = BaseWgslData> {\n readonly type: 'array';\n readonly elementCount: number;\n readonly elementType: TElement;\n /** Type-token, not available at runtime */\n readonly '~repr': Infer<TElement>[];\n}\n\nexport interface PtrFn<TInner = BaseWgslData> {\n readonly type: 'ptrFn';\n readonly inner: TInner;\n /** Type-token, not available at runtime */\n readonly '~repr': Infer<TInner>;\n}\n\n/**\n * Schema representing the `atomic<...>` WGSL data type.\n */\nexport interface Atomic<TInner extends U32 | I32 = U32 | I32> {\n readonly type: 'atomic';\n readonly inner: TInner;\n /** Type-token, not available at runtime */\n readonly '~repr': Infer<TInner>;\n}\n\nexport interface Align<T extends number> {\n readonly type: '@align';\n readonly value: T;\n}\n\nexport interface Size<T extends number> {\n readonly type: '@size';\n readonly value: T;\n}\n\nexport interface Location<T extends number> {\n readonly type: '@location';\n readonly value: T;\n}\n\nexport type PerspectiveOrLinearInterpolationType =\n `${'perspective' | 'linear'}${'' | ', center' | ', centroid' | ', sample'}`;\nexport type FlatInterpolationType = `flat${'' | ', first' | ', either'}`;\nexport type InterpolationType =\n | PerspectiveOrLinearInterpolationType\n | FlatInterpolationType;\n\nexport interface Interpolate<T extends InterpolationType> {\n readonly type: '@interpolate';\n readonly value: T;\n}\n\nexport interface Builtin<T extends string> {\n readonly type: '@builtin';\n readonly value: T;\n}\n\nexport interface Decorated<\n TInner extends BaseWgslData = BaseWgslData,\n TAttribs extends unknown[] = unknown[],\n> {\n readonly type: 'decorated';\n readonly inner: TInner;\n readonly attribs: TAttribs;\n /** Type-token, not available at runtime */\n readonly '~repr': Infer<TInner>;\n}\n\nexport const wgslTypeLiterals = [\n 'bool',\n 'f32',\n 'f16',\n 'i32',\n 'u32',\n 'vec2f',\n 'vec2h',\n 'vec2i',\n 'vec2u',\n 'vec3f',\n 'vec3h',\n 'vec3i',\n 'vec3u',\n 'vec4f',\n 'vec4h',\n 'vec4i',\n 'vec4u',\n 'mat2x2f',\n 'mat3x3f',\n 'mat4x4f',\n 'struct',\n 'array',\n 'ptrFn',\n 'atomic',\n 'decorated',\n] as const;\n\nexport type WgslTypeLiteral = (typeof wgslTypeLiterals)[number];\n\nexport type PerspectiveOrLinearInterpolatableData =\n | F32\n | F16\n | Vec2f\n | Vec2h\n | Vec3f\n | Vec3h\n | Vec4f\n | Vec4h;\n\nexport type FlatInterpolatableData =\n | PerspectiveOrLinearInterpolatableData\n | I32\n | U32\n | Vec2i\n | Vec2u\n | Vec3i\n | Vec3u\n | Vec4i\n | Vec4u;\n\nexport type AnyWgslData =\n | Bool\n | F32\n | F16\n | I32\n | U32\n | Vec2f\n | Vec2h\n | Vec2i\n | Vec2u\n | Vec3f\n | Vec3h\n | Vec3i\n | Vec3u\n | Vec4f\n | Vec4h\n | Vec4i\n | Vec4u\n | Mat2x2f\n | Mat3x3f\n | Mat4x4f\n | AnyWgslStruct\n | WgslArray\n | PtrFn\n | Atomic\n | Decorated;\n\n// #endregion\n\nexport function isWgslData(value: unknown): value is AnyWgslData {\n return wgslTypeLiterals.includes((value as AnyWgslData)?.type);\n}\n\n/**\n * Checks whether passed in value is an array schema,\n * as opposed to, e.g., a disarray schema.\n *\n * Array schemas can be used to describe uniform and storage buffers,\n * whereas disarray schemas cannot.\n *\n * @example\n * isWgslArray(d.arrayOf(d.u32, 4)) // true\n * isWgslArray(d.disarray(d.u32, 4)) // false\n * isWgslArray(d.vec3f) // false\n */\nexport function isWgslArray<T extends WgslArray>(\n schema: T | unknown,\n): schema is T {\n return (schema as T)?.type === 'array';\n}\n\n/**\n * Checks whether passed in value is a struct schema,\n * as opposed to, e.g., an unstruct schema.\n *\n * Struct schemas can be used to describe uniform and storage buffers,\n * whereas unstruct schemas cannot.\n *\n * @example\n * isWgslStruct(d.struct({ a: d.u32 })) // true\n * isWgslStruct(d.unstruct({ a: d.u32 })) // false\n * isWgslStruct(d.vec3f) // false\n */\nexport function isWgslStruct<T extends WgslStruct>(\n schema: T | unknown,\n): schema is T {\n return (schema as T)?.type === 'struct';\n}\n\n/**\n * Checks whether passed in value is a pointer ('function' scope) schema.\n *\n * @example\n * isPtrFn(d.ptrFn(d.f32)) // true\n * isPtrFn(d.f32) // false\n */\nexport function isPtrFn<T extends PtrFn>(schema: T | unknown): schema is T {\n return (schema as T)?.type === 'ptrFn';\n}\n\n/**\n * Checks whether the passed in value is an atomic schema.\n *\n * @example\n * isAtomic(d.atomic(d.u32)) // true\n * isAtomic(d.u32) // false\n */\nexport function isAtomic<T extends Atomic<U32 | I32>>(\n schema: T | unknown,\n): schema is T {\n return (schema as T)?.type === 'atomic';\n}\n\nexport function isAlignAttrib<T extends Align<number>>(\n value: unknown | T,\n): value is T {\n return (value as T)?.type === '@align';\n}\n\nexport function isSizeAttrib<T extends Size<number>>(\n value: unknown | T,\n): value is T {\n return (value as T)?.type === '@size';\n}\n\nexport function isLocationAttrib<T extends Location<number>>(\n value: unknown | T,\n): value is T {\n return (value as T)?.type === '@location';\n}\n\nexport function isInterpolateAttrib<T extends Interpolate<InterpolationType>>(\n value: unknown | T,\n): value is T {\n return (value as T)?.type === '@interpolate';\n}\n\nexport function isBuiltinAttrib<T extends Builtin<string>>(\n value: unknown | T,\n): value is T {\n return (value as T)?.type === '@builtin';\n}\n\nexport function isDecorated<T extends Decorated>(\n value: unknown | T,\n): value is T {\n return (value as T)?.type === 'decorated';\n}\n","import type { TgpuNamable } from '../namable';\nimport type { Prettify } from '../shared/utilityTypes';\nimport type { ExoticRecord } from './exotic';\nimport type { AnyWgslData, BaseWgslData, WgslStruct } from './wgslTypes';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Struct schema constructed via `d.struct` function.\n *\n * Responsible for handling reading and writing struct values\n * between binary and JS representation. Takes into account\n * the `byteAlignment` requirement of its members.\n */\nexport interface TgpuStruct<TProps extends Record<string, BaseWgslData>>\n extends WgslStruct<TProps>,\n TgpuNamable {\n readonly '~exotic': WgslStruct<TProps>;\n}\n\n/**\n * Creates a struct schema that can be used to construct GPU buffers.\n * Ensures proper alignment and padding of properties (as opposed to a `d.unstruct` schema).\n * The order of members matches the passed in properties object.\n *\n * @example\n * const CircleStruct = d.struct({ radius: d.f32, pos: d.vec3f });\n *\n * @param props Record with `string` keys and `TgpuData` values,\n * each entry describing one struct member.\n */\nexport const struct = <TProps extends Record<string, AnyWgslData>>(\n props: TProps,\n): TgpuStruct<Prettify<ExoticRecord<TProps>>> => {\n const struct = <T>(props: T) => props;\n Object.setPrototypeOf(struct, TgpuStructImpl);\n struct.propTypes = props as ExoticRecord<TProps>;\n\n return struct as unknown as TgpuStruct<Prettify<ExoticRecord<TProps>>>;\n};\n\n// --------------\n// Implementation\n// --------------\n\nconst TgpuStructImpl = {\n type: 'struct',\n _label: undefined as string | undefined,\n\n get label(): string | undefined {\n return this._label;\n },\n\n $name(label: string) {\n this._label = label;\n return this;\n },\n\n toString(): string {\n return `struct:${this.label ?? '<unnamed>'}`;\n },\n};\n","/**\n * @param value\n * @param modulo has to be power of 2\n */\nexport const roundUp = (value: number, modulo: number) => {\n const bitMask = modulo - 1;\n const invBitMask = ~bitMask;\n return (value & bitMask) === 0 ? value : (value & invBitMask) + modulo;\n};\n","export const vertexFormats = [\n 'uint8',\n 'uint8x2',\n 'uint8x4',\n 'sint8',\n 'sint8x2',\n 'sint8x4',\n 'unorm8',\n 'unorm8x2',\n 'unorm8x4',\n 'snorm8',\n 'snorm8x2',\n 'snorm8x4',\n 'uint16',\n 'uint16x2',\n 'uint16x4',\n 'sint16',\n 'sint16x2',\n 'sint16x4',\n 'unorm16',\n 'unorm16x2',\n 'unorm16x4',\n 'snorm16',\n 'snorm16x2',\n 'snorm16x4',\n 'float16',\n 'float16x2',\n 'float16x4',\n 'float32',\n 'float32x2',\n 'float32x3',\n 'float32x4',\n 'uint32',\n 'uint32x2',\n 'uint32x3',\n 'uint32x4',\n 'sint32',\n 'sint32x2',\n 'sint32x3',\n 'sint32x4',\n 'unorm10-10-10-2',\n 'unorm8x4-bgra',\n] as const;\n\nexport type VertexFormat = (typeof vertexFormats)[number];\n\nexport const kindToDefaultFormatMap = {\n f32: 'float32',\n vec2f: 'float32x2',\n vec3f: 'float32x3',\n vec4f: 'float32x4',\n f16: 'float16',\n vec2h: 'float16x2',\n // vec3h has no direct equivalent in the spec\n vec4h: 'float16x4',\n u32: 'uint32',\n vec2u: 'uint32x2',\n vec3u: 'uint32x3',\n vec4u: 'uint32x4',\n i32: 'sint32',\n vec2i: 'sint32x2',\n vec3i: 'sint32x3',\n vec4i: 'sint32x4',\n} as const;\n\nexport type KindToDefaultFormatMap = typeof kindToDefaultFormatMap;\n\nexport interface TgpuVertexAttrib<TFormat extends VertexFormat = VertexFormat> {\n readonly format: TFormat;\n readonly offset: number;\n}\n\nexport type AnyVertexAttribs =\n | Record<string, TgpuVertexAttrib>\n | TgpuVertexAttrib;\n\n/**\n * All vertex attribute formats that can be interpreted as\n * an single or multi component u32 in a shader.\n * https://www.w3.org/TR/webgpu/#vertex-formats\n */\ntype U32CompatibleFormats =\n | TgpuVertexAttrib<'uint8'>\n | TgpuVertexAttrib<'uint8x2'>\n | TgpuVertexAttrib<'uint8x4'>\n | TgpuVertexAttrib<'uint16'>\n | TgpuVertexAttrib<'uint16x2'>\n | TgpuVertexAttrib<'uint16x4'>\n | TgpuVertexAttrib<'uint32'>\n | TgpuVertexAttrib<'uint32x2'>\n | TgpuVertexAttrib<'uint32x3'>\n | TgpuVertexAttrib<'uint32x4'>;\n\n/**\n * All vertex attribute formats that can be interpreted as\n * an single or multi component i32 in a shader.\n * https://www.w3.org/TR/webgpu/#vertex-formats\n */\ntype I32CompatibleFormats =\n | TgpuVertexAttrib<'sint8'>\n | TgpuVertexAttrib<'sint8x2'>\n | TgpuVertexAttrib<'sint8x4'>\n | TgpuVertexAttrib<'sint16'>\n | TgpuVertexAttrib<'sint16x2'>\n | TgpuVertexAttrib<'sint16x4'>\n | TgpuVertexAttrib<'sint32'>\n | TgpuVertexAttrib<'sint32x2'>\n | TgpuVertexAttrib<'sint32x3'>\n | TgpuVertexAttrib<'sint32x4'>;\n\n/**\n * All vertex attribute formats that can be interpreted as\n * an single or multi component f32 in a shader.\n * https://www.w3.org/TR/webgpu/#vertex-formats\n */\ntype F32CompatibleFormats =\n | TgpuVertexAttrib<'unorm8'>\n | TgpuVertexAttrib<'unorm8x2'>\n | TgpuVertexAttrib<'unorm8x4'>\n | TgpuVertexAttrib<'snorm8'>\n | TgpuVertexAttrib<'snorm8x2'>\n | TgpuVertexAttrib<'snorm8x4'>\n | TgpuVertexAttrib<'unorm16'>\n | TgpuVertexAttrib<'unorm16x2'>\n | TgpuVertexAttrib<'unorm16x4'>\n | TgpuVertexAttrib<'snorm16'>\n | TgpuVertexAttrib<'snorm16x2'>\n | TgpuVertexAttrib<'snorm16x4'>\n | TgpuVertexAttrib<'float16'>\n | TgpuVertexAttrib<'float16x2'>\n | TgpuVertexAttrib<'float16x4'>\n | TgpuVertexAttrib<'float32'>\n | TgpuVertexAttrib<'float32x2'>\n | TgpuVertexAttrib<'float32x3'>\n | TgpuVertexAttrib<'float32x4'>\n | TgpuVertexAttrib<'unorm10-10-10-2'>\n | TgpuVertexAttrib<'unorm8x4-bgra'>;\n\n/**\n * All vertex attribute formats that can be interpreted as\n * a single or multi component f16 in a shader. (same as f32 on the shader side)\n * https://www.w3.org/TR/webgpu/#vertex-formats\n */\ntype F16CompatibleFormats = F32CompatibleFormats;\n\nexport type KindToAcceptedAttribMap = {\n u32: U32CompatibleFormats;\n vec2u: U32CompatibleFormats;\n vec3u: U32CompatibleFormats;\n vec4u: U32CompatibleFormats;\n\n i32: I32CompatibleFormats;\n vec2i: I32CompatibleFormats;\n vec3i: I32CompatibleFormats;\n vec4i: I32CompatibleFormats;\n\n f16: F16CompatibleFormats;\n vec2h: F16CompatibleFormats;\n vec3h: F16CompatibleFormats;\n vec4h: F16CompatibleFormats;\n\n f32: F32CompatibleFormats;\n vec2f: F32CompatibleFormats;\n vec3f: F32CompatibleFormats;\n vec4f: F32CompatibleFormats;\n};\n","import type { Infer, InferRecord } from '../shared/repr';\nimport { vertexFormats } from '../shared/vertexFormat';\nimport type { PackedData } from './vertexFormatData';\nimport * as wgsl from './wgslTypes';\n\n/**\n * Array schema constructed via `d.disarrayOf` function.\n *\n * Useful for defining vertex buffers.\n * Elements in the schema are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n */\nexport interface Disarray<\n TElement extends wgsl.BaseWgslData = wgsl.BaseWgslData,\n> {\n readonly type: 'disarray';\n readonly elementCount: number;\n readonly elementType: TElement;\n readonly '~repr': Infer<TElement>[];\n}\n\n/**\n * Struct schema constructed via `d.unstruct` function.\n *\n * Useful for defining vertex buffers, as the standard layout restrictions do not apply.\n * Members are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n */\nexport interface Unstruct<\n TProps extends Record<string, wgsl.BaseWgslData> = Record<\n string,\n wgsl.BaseWgslData\n >,\n> {\n readonly type: 'unstruct';\n readonly propTypes: TProps;\n readonly '~repr': InferRecord<TProps>;\n}\n\nexport interface LooseDecorated<\n TInner extends wgsl.BaseWgslData = wgsl.BaseWgslData,\n TAttribs extends unknown[] = unknown[],\n> {\n readonly type: 'loose-decorated';\n readonly inner: TInner;\n readonly attribs: TAttribs;\n readonly '~repr': Infer<TInner>;\n}\n\nconst looseTypeLiterals = [\n 'unstruct',\n 'disarray',\n 'loose-decorated',\n ...vertexFormats,\n] as const;\n\nexport type LooseTypeLiteral = (typeof looseTypeLiterals)[number];\n\nexport type AnyLooseData = Disarray | Unstruct | LooseDecorated | PackedData;\n\nexport function isLooseData(data: unknown): data is AnyLooseData {\n return looseTypeLiterals.includes((data as AnyLooseData)?.type);\n}\n\n/**\n * Checks whether the passed in value is a disarray schema,\n * as opposed to, e.g., a regular array schema.\n *\n * Array schemas can be used to describe uniform and storage buffers,\n * whereas disarray schemas cannot. Disarrays are useful for\n * defining vertex buffers instead.\n *\n * @example\n * isDisarray(d.arrayOf(d.u32, 4)) // false\n * isDisarray(d.disarrayOf(d.u32, 4)) // true\n * isDisarray(d.vec3f) // false\n */\nexport function isDisarray<T extends Disarray>(\n schema: T | unknown,\n): schema is T {\n return (schema as Disarray)?.type === 'disarray';\n}\n\n/**\n * Checks whether passed in value is a unstruct schema,\n * as opposed to, e.g., a struct schema.\n *\n * Struct schemas can be used to describe uniform and storage buffers,\n * whereas unstruct schemas cannot. Unstructs are useful for\n * defining vertex buffers instead.\n *\n * @example\n * isUnstruct(d.struct({ a: d.u32 })) // false\n * isUnstruct(d.unstruct({ a: d.u32 })) // true\n * isUnstruct(d.vec3f) // false\n */\nexport function isUnstruct<T extends Unstruct>(\n schema: T | unknown,\n): schema is T {\n return (schema as T)?.type === 'unstruct';\n}\n\nexport function isLooseDecorated<T extends LooseDecorated>(\n value: T | unknown,\n): value is T {\n return (value as T)?.type === 'loose-decorated';\n}\n\nexport function getCustomAlignment(\n data: wgsl.BaseWgslData,\n): number | undefined {\n return (data as unknown as wgsl.Decorated | LooseDecorated).attribs?.find(\n wgsl.isAlignAttrib,\n )?.value;\n}\n\nexport function getCustomSize(data: wgsl.BaseWgslData): number | undefined {\n return (data as unknown as wgsl.Decorated | LooseDecorated).attribs?.find(\n wgsl.isSizeAttrib,\n )?.value;\n}\n\nexport function getCustomLocation(data: wgsl.BaseWgslData): number | undefined {\n return (data as unknown as wgsl.Decorated | LooseDecorated).attribs?.find(\n wgsl.isLocationAttrib,\n )?.value;\n}\n\nexport function isData(value: unknown): value is AnyData {\n return wgsl.isWgslData(value) || isLooseData(value);\n}\n\nexport type AnyData = wgsl.AnyWgslData | AnyLooseData;\n","import type { Infer } from '../shared/repr';\nimport type { VertexFormat } from '../shared/vertexFormat';\nimport { f32, i32, u32 } from './numeric';\nimport {\n vec2f,\n vec2i,\n vec2u,\n vec3f,\n vec3i,\n vec3u,\n vec4f,\n vec4i,\n vec4u,\n} from './vector';\n\nexport type FormatToWGSLType<T extends VertexFormat> =\n (typeof formatToWGSLType)[T];\n\nexport interface TgpuVertexFormatData<T extends VertexFormat> {\n readonly '~repr': Infer<FormatToWGSLType<T>>;\n readonly type: T;\n}\n\nclass TgpuVertexFormatDataImpl<T extends VertexFormat>\n implements TgpuVertexFormatData<T>\n{\n /** Used as a type-token for the `Infer<T>` functionality. */\n public readonly '~repr'!: Infer<FormatToWGSLType<T>>;\n\n constructor(public readonly type: T) {}\n}\n\nconst formatToWGSLType = {\n uint8: u32,\n uint8x2: vec2u,\n uint8x4: vec4u,\n sint8: i32,\n sint8x2: vec2i,\n sint8x4: vec4i,\n unorm8: f32,\n unorm8x2: vec2f,\n unorm8x4: vec4f,\n snorm8: f32,\n snorm8x2: vec2f,\n snorm8x4: vec4f,\n uint16: u32,\n uint16x2: vec2u,\n uint16x4: vec4u,\n sint16: i32,\n sint16x2: vec2i,\n sint16x4: vec4i,\n unorm16: f32,\n unorm16x2: vec2f,\n unorm16x4: vec4f,\n snorm16: f32,\n snorm16x2: vec2f,\n snorm16x4: vec4f,\n float16: f32,\n float16x2: vec2f,\n float16x4: vec4f,\n float32: f32,\n float32x2: vec2f,\n float32x3: vec3f,\n float32x4: vec4f,\n uint32: u32,\n uint32x2: vec2u,\n uint32x3: vec3u,\n uint32x4: vec4u,\n sint32: i32,\n sint32x2: vec2i,\n sint32x3: vec3i,\n sint32x4: vec4i,\n 'unorm10-10-10-2': vec4f,\n 'unorm8x4-bgra': vec4f,\n} as const;\n\nexport const packedFormats = Object.keys(formatToWGSLType);\n\nexport type uint8 = TgpuVertexFormatData<'uint8'>;\nexport const uint8 = new TgpuVertexFormatDataImpl('uint8') as uint8;\n\nexport type uint8x2 = TgpuVertexFormatData<'uint8x2'>;\nexport const uint8x2 = new TgpuVertexFormatDataImpl('uint8x2') as uint8x2;\n\nexport type uint8x4 = TgpuVertexFormatData<'uint8x4'>;\nexport const uint8x4 = new TgpuVertexFormatDataImpl('uint8x4') as uint8x4;\n\nexport type sint8 = TgpuVertexFormatData<'sint8'>;\nexport const sint8 = new TgpuVertexFormatDataImpl('sint8') as sint8;\n\nexport type sint8x2 = TgpuVertexFormatData<'sint8x2'>;\nexport const sint8x2 = new TgpuVertexFormatDataImpl('sint8x2') as sint8x2;\n\nexport type sint8x4 = TgpuVertexFormatData<'sint8x4'>;\nexport const sint8x4 = new TgpuVertexFormatDataImpl('sint8x4') as sint8x4;\n\nexport type unorm8 = TgpuVertexFormatData<'unorm8'>;\nexport const unorm8 = new TgpuVertexFormatDataImpl('unorm8') as unorm8;\n\nexport type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;\nexport const unorm8x2 = new TgpuVertexFormatDataImpl('unorm8x2') as unorm8x2;\n\nexport type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;\nexport const unorm8x4 = new TgpuVertexFormatDataImpl('unorm8x4') as unorm8x4;\n\nexport type snorm8 = TgpuVertexFormatData<'snorm8'>;\nexport const snorm8 = new TgpuVertexFormatDataImpl('snorm8') as snorm8;\n\nexport type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;\nexport const snorm8x2 = new TgpuVertexFormatDataImpl('snorm8x2') as snorm8x2;\n\nexport type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;\nexport const snorm8x4 = new TgpuVertexFormatDataImpl('snorm8x4') as snorm8x4;\n\nexport type uint16 = TgpuVertexFormatData<'uint16'>;\nexport const uint16 = new TgpuVertexFormatDataImpl('uint16') as uint16;\n\nexport type uint16x2 = TgpuVertexFormatData<'uint16x2'>;\nexport const uint16x2 = new TgpuVertexFormatDataImpl('uint16x2') as uint16x2;\n\nexport type uint16x4 = TgpuVertexFormatData<'uint16x4'>;\nexport const uint16x4 = new TgpuVertexFormatDataImpl('uint16x4') as uint16x4;\n\nexport type sint16 = TgpuVertexFormatData<'sint16'>;\nexport const sint16 = new TgpuVertexFormatDataImpl('sint16') as sint16;\n\nexport type sint16x2 = TgpuVertexFormatData<'sint16x2'>;\nexport const sint16x2 = new TgpuVertexFormatDataImpl('sint16x2') as sint16x2;\n\nexport type sint16x4 = TgpuVertexFormatData<'sint16x4'>;\nexport const sint16x4 = new TgpuVertexFormatDataImpl('sint16x4') as sint16x4;\n\nexport type unorm16 = TgpuVertexFormatData<'unorm16'>;\nexport const unorm16 = new TgpuVertexFormatDataImpl('unorm16') as unorm16;\n\nexport type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;\nexport const unorm16x2 = new TgpuVertexFormatDataImpl('unorm16x2') as unorm16x2;\n\nexport type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;\nexport const unorm16x4 = new TgpuVertexFormatDataImpl('unorm16x4') as unorm16x4;\n\nexport type snorm16 = TgpuVertexFormatData<'snorm16'>;\nexport const snorm16 = new TgpuVertexFormatDataImpl('snorm16') as snorm16;\n\nexport type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;\nexport const snorm16x2 = new TgpuVertexFormatDataImpl('snorm16x2') as snorm16x2;\n\nexport type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;\nexport const snorm16x4 = new TgpuVertexFormatDataImpl('snorm16x4') as snorm16x4;\n\nexport type float16 = TgpuVertexFormatData<'float16'>;\nexport const float16 = new TgpuVertexFormatDataImpl('float16') as float16;\n\nexport type float16x2 = TgpuVertexFormatData<'float16x2'>;\nexport const float16x2 = new TgpuVertexFormatDataImpl('float16x2') as float16x2;\n\nexport type float16x4 = TgpuVertexFormatData<'float16x4'>;\nexport const float16x4 = new TgpuVertexFormatDataImpl('float16x4') as float16x4;\n\nexport type float32 = TgpuVertexFormatData<'float32'>;\nexport const float32 = new TgpuVertexFormatDataImpl('float32') as float32;\n\nexport type float32x2 = TgpuVertexFormatData<'float32x2'>;\nexport const float32x2 = new TgpuVertexFormatDataImpl('float32x2') as float32x2;\n\nexport type float32x3 = TgpuVertexFormatData<'float32x3'>;\nexport const float32x3 = new TgpuVertexFormatDataImpl('float32x3') as float32x3;\n\nexport type float32x4 = TgpuVertexFormatData<'float32x4'>;\nexport const float32x4 = new TgpuVertexFormatDataImpl('float32x4') as float32x4;\n\nexport type uint32 = TgpuVertexFormatData<'uint32'>;\nexport const uint32 = new TgpuVertexFormatDataImpl('uint32') as uint32;\n\nexport type uint32x2 = TgpuVertexFormatData<'uint32x2'>;\nexport const uint32x2 = new TgpuVertexFormatDataImpl('uint32x2') as uint32x2;\n\nexport type uint32x3 = TgpuVertexFormatData<'uint32x3'>;\nexport const uint32x3 = new TgpuVertexFormatDataImpl('uint32x3') as uint32x3;\n\nexport type uint32x4 = TgpuVertexFormatData<'uint32x4'>;\nexport const uint32x4 = new TgpuVertexFormatDataImpl('uint32x4') as uint32x4;\n\nexport type sint32 = TgpuVertexFormatData<'sint32'>;\nexport const sint32 = new TgpuVertexFormatDataImpl('sint32') as sint32;\n\nexport type sint32x2 = TgpuVertexFormatData<'sint32x2'>;\nexport const sint32x2 = new TgpuVertexFormatDataImpl('sint32x2') as sint32x2;\n\nexport type sint32x3 = TgpuVertexFormatData<'sint32x3'>;\nexport const sint32x3 = new TgpuVertexFormatDataImpl('sint32x3') as sint32x3;\n\nexport type sint32x4 = TgpuVertexFormatData<'sint32x4'>;\nexport const sint32x4 = new TgpuVertexFormatDataImpl('sint32x4') as sint32x4;\n\nexport type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;\nexport const unorm10_10_10_2 = new TgpuVertexFormatDataImpl(\n 'unorm10-10-10-2',\n) as unorm10_10_10_2;\n\nexport type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;\nexport const unorm8x4_bgra = new TgpuVertexFormatDataImpl(\n 'unorm8x4-bgra',\n) as unorm8x4_bgra;\n\nexport type PackedData =\n | uint8\n | uint8x2\n | uint8x4\n | sint8\n | sint8x2\n | sint8x4\n | unorm8\n | unorm8x2\n | unorm8x4\n | snorm8\n | snorm8x2\n | snorm8x4\n | uint16\n | uint16x2\n | uint16x4\n | sint16\n | sint16x2\n | sint16x4\n | unorm16\n | unorm16x2\n | unorm16x4\n | snorm16\n | snorm16x2\n | snorm16x4\n | float16\n | float16x2\n | float16x4\n | float32\n | float32x2\n | float32x3\n | float32x4\n | uint32\n | uint32x2\n | uint32x3\n | uint32x4\n | sint32\n | sint32x2\n | sint32x3\n | sint32x4\n | unorm10_10_10_2\n | unorm8x4_bgra;\n","import {\n type AnyData,\n getCustomAlignment,\n isDisarray,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes';\nimport { packedFormats } from './vertexFormatData';\nimport {\n type BaseWgslData,\n isDecorated,\n isWgslArray,\n isWgslStruct,\n} from './wgslTypes';\n\nconst knownAlignmentMap: Record<string, number> = {\n bool: 4,\n f32: 4,\n f16: 2,\n i32: 4,\n u32: 4,\n vec2f: 8,\n vec2h: 4,\n vec2i: 8,\n vec2u: 8,\n vec3f: 16,\n vec3h: 8,\n vec3i: 16,\n vec3u: 16,\n vec4f: 16,\n vec4h: 8,\n vec4i: 16,\n vec4u: 16,\n mat2x2f: 8,\n mat3x3f: 16,\n mat4x4f: 16,\n};\n\nfunction computeAlignment(data: object): number {\n const dataType = (data as BaseWgslData)?.type;\n const knownAlignment = knownAlignmentMap[dataType];\n if (knownAlignment !== undefined) {\n return knownAlignment;\n }\n\n if (isWgslStruct(data)) {\n return Object.values(data.propTypes)\n .map(alignmentOf)\n .reduce((a, b) => (a > b ? a : b));\n }\n\n if (isWgslArray(data)) {\n return alignmentOf(data.elementType);\n }\n\n if (isUnstruct(data)) {\n // A loose struct is aligned to its first property.\n const firstProp = Object.values(data.propTypes)[0];\n return firstProp ? getCustomAlignment(firstProp) ?? 1 : 1;\n }\n\n if (isDisarray(data)) {\n return getCustomAlignment(data.elementType) ?? 1;\n }\n\n if (isDecorated(data) || isLooseDecorated(data)) {\n return getCustomAlignment(data) ?? alignmentOf(data.inner);\n }\n\n if (packedFormats.includes(dataType)) {\n return 1;\n }\n\n throw new Error(\n `Cannot determine alignment of data: ${JSON.stringify(data)}`,\n );\n}\n\nfunction computeCustomAlignment(data: BaseWgslData): number {\n if (isUnstruct(data)) {\n // A loose struct is aligned to its first property.\n const firstProp = Object.values(data.propTypes)[0];\n return firstProp ? customAlignmentOf(firstProp) : 1;\n }\n\n if (isDisarray(data)) {\n return customAlignmentOf(data.elementType);\n }\n\n if (isLooseDecorated(data)) {\n return getCustomAlignment(data) ?? customAlignmentOf(data.inner);\n }\n\n return getCustomAlignment(data) ?? 1;\n}\n\n/**\n * Since alignments can be inferred from exotic/native data types, they are\n * not stored on them. Instead, this weak map acts as an extended property\n * of those data types.\n */\nconst cachedAlignments = new WeakMap<object, number>();\n\nconst cachedCustomAlignments = new WeakMap<object, number>();\n\nexport function alignmentOf(data: BaseWgslData): number {\n let alignment = cachedAlignments.get(data);\n if (alignment === undefined) {\n alignment = computeAlignment(data);\n cachedAlignments.set(data, alignment);\n }\n\n return alignment;\n}\n\nexport function customAlignmentOf(data: BaseWgslData): number {\n let alignment = cachedCustomAlignments.get(data);\n if (alignment === undefined) {\n alignment = computeCustomAlignment(data);\n cachedCustomAlignments.set(data, alignment);\n }\n\n return alignment;\n}\n\n/**\n * Returns the alignment (in bytes) of data represented by the `schema`.\n */\nexport function PUBLIC_alignmentOf(schema: AnyData): number {\n return alignmentOf(schema);\n}\n","import { roundUp } from '../mathUtils';\nimport { alignmentOf, customAlignmentOf } from './alignmentOf';\nimport type { AnyData, LooseTypeLiteral, Unstruct } from './dataTypes';\nimport {\n getCustomSize,\n isDisarray,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes';\nimport type { BaseWgslData, WgslStruct, WgslTypeLiteral } from './wgslTypes';\nimport { isDecorated, isWgslArray, isWgslStruct } from './wgslTypes';\n\nconst knownSizesMap: Record<string, number> = {\n bool: 4,\n f32: 4,\n f16: 2,\n i32: 4,\n u32: 4,\n vec2f: 8,\n vec2h: 4,\n vec2i: 8,\n vec2u: 8,\n vec3f: 12,\n vec3h: 6,\n vec3i: 12,\n vec3u: 12,\n vec4f: 16,\n vec4h: 8,\n vec4i: 16,\n vec4u: 16,\n mat2x2f: 16,\n mat3x3f: 48,\n mat4x4f: 64,\n uint8: 1,\n uint8x2: 2,\n uint8x4: 4,\n sint8: 1,\n sint8x2: 2,\n sint8x4: 4,\n unorm8: 1,\n unorm8x2: 2,\n unorm8x4: 4,\n snorm8: 1,\n snorm8x2: 2,\n snorm8x4: 4,\n uint16: 2,\n uint16x2: 4,\n uint16x4: 8,\n sint16: 2,\n sint16x2: 4,\n sint16x4: 8,\n unorm16: 2,\n unorm16x2: 4,\n unorm16x4: 8,\n snorm16: 2,\n snorm16x2: 4,\n snorm16x4: 8,\n float16: 2,\n float16x2: 4,\n float16x4: 8,\n float32: 4,\n float32x2: 8,\n float32x3: 12,\n float32x4: 16,\n uint32: 4,\n uint32x2: 8,\n uint32x3: 12,\n uint32x4: 16,\n sint32: 4,\n sint32x2: 8,\n sint32x3: 12,\n sint32x4: 16,\n 'unorm10-10-10-2': 4,\n 'unorm8x4-bgra': 4,\n} satisfies Partial<Record<WgslTypeLiteral | LooseTypeLiteral, number>>;\n\nfunction sizeOfStruct(struct: WgslStruct) {\n let size = 0;\n for (const property of Object.values(struct.propTypes)) {\n if (Number.isNaN(size)) {\n throw new Error('Only the last property of a struct can be unbounded');\n }\n\n size = roundUp(size, alignmentOf(property));\n size += sizeOf(property);\n\n if (Number.isNaN(size) && property.type !== 'array') {\n throw new Error('Cannot nest unbounded struct within another struct');\n }\n }\n\n return roundUp(size, alignmentOf(struct));\n}\n\nfunction sizeOfUnstruct(data: Unstruct) {\n let size = 0;\n\n for (const property of Object.values(data.propTypes)) {\n const alignment = customAlignmentOf(property);\n size = roundUp(size, alignment);\n size += sizeOf(property);\n }\n\n return size;\n}\n\nfunction computeSize(data: object): number {\n const knownSize = knownSizesMap[(data as BaseWgslData)?.type];\n\n if (knownSize !== undefined) {\n return knownSize;\n }\n\n if (isWgslStruct(data)) {\n return sizeOfStruct(data);\n }\n\n if (isUnstruct(data)) {\n return sizeOfUnstruct(data);\n }\n\n if (isWgslArray(data)) {\n if (data.elementCount === 0) {\n return Number.NaN;\n }\n\n const alignment = alignmentOf(data.elementType);\n const stride = roundUp(sizeOf(data.elementType), alignment);\n return stride * data.elementCount;\n }\n\n if (isDisarray(data)) {\n const alignment = customAlignmentOf(data.elementType);\n const stride = roundUp(sizeOf(data.elementType), alignment);\n return stride * data.elementCount;\n }\n\n if (isDecorated(data) || isLooseDecorated(data)) {\n return getCustomSize(data) ?? sizeOf(data.inner);\n }\n\n throw new Error(`Cannot determine size of data: ${data}`);\n}\n\n/**\n * Since sizes can be inferred from exotic/native data types, they are\n * not stored on them. Instead, this weak map acts as an extended property\n * of those data types.\n */\nconst cachedSizes = new WeakMap<BaseWgslData, number>();\n\nexport function sizeOf(schema: BaseWgslData): number {\n let size = cachedSizes.get(schema);\n\n if (size === undefined) {\n size = computeSize(schema);\n cachedSizes.set(schema, size);\n }\n\n return size;\n}\n\n/**\n * Returns the size (in bytes) of data represented by the `schema`.\n */\nexport function PUBLIC_sizeOf(schema: AnyData): number {\n return sizeOf(schema);\n}\n","import type { Infer } from '../shared/repr';\nimport type { Exotic } from './exotic';\nimport { sizeOf } from './sizeOf';\nimport type { AnyWgslData, WgslArray } from './wgslTypes';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Array schema constructed via `d.arrayOf` function.\n *\n * Responsible for handling reading and writing array values\n * between binary and JS representation. Takes into account\n * the `byteAlignment` requirement of its elementType.\n */\nexport interface TgpuArray<TElement extends AnyWgslData>\n extends WgslArray<TElement> {\n readonly '~exotic': WgslArray<Exotic<TElement>>;\n}\n\n/**\n * Creates an array schema that can be used to construct gpu buffers.\n * Describes arrays with fixed-size length, storing elements of the same type.\n *\n * @example\n * const LENGTH = 3;\n * const array = d.arrayOf(d.u32, LENGTH);\n *\n * @param elementType The type of elements in the array.\n * @param elementCount The number of elements in the array.\n */\nexport const arrayOf = <TElement extends AnyWgslData>(\n elementType: TElement,\n elementCount: number,\n): TgpuArray<Exotic<TElement>> =>\n new TgpuArrayImpl(elementType as Exotic<TElement>, elementCount);\n\n// --------------\n// Implementation\n// --------------\n\nclass TgpuArrayImpl<TElement extends AnyWgslData>\n implements TgpuArray<TElement>\n{\n public readonly type = 'array';\n /** Type-token, not available at runtime */\n public readonly '~repr'!: Infer<TElement>[];\n /** Type-token, not available at runtime */\n public readonly '~exotic'!: WgslArray<Exotic<TElement>>;\n\n constructor(\n public readonly elementType: TElement,\n public readonly elementCount: number,\n ) {\n if (Number.isNaN(sizeOf(elementType))) {\n throw new Error('Cannot nest runtime sized arrays.');\n }\n }\n\n toString() {\n return `arrayOf(${this.elementType})`;\n }\n}\n","import type { AnyData } from './dataTypes';\nimport type { Exotic } from './exotic';\nimport type { PtrFn } from './wgslTypes';\n\nexport function ptrFn<T extends AnyData>(inner: T): PtrFn<Exotic<T>> {\n return {\n type: 'ptrFn',\n inner: inner as Exotic<T>,\n } as PtrFn<Exotic<T>>;\n}\n","import type { Infer } from '../shared/repr';\nimport type { AnyData, Disarray } from './dataTypes';\nimport type { Exotic } from './exotic';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Creates an array schema that can be used to construct vertex buffers.\n * Describes arrays with fixed-size length, storing elements of the same type.\n *\n * Elements in the schema are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const disarray = d.disarrayOf(d.vec3f, 3); // packed array of vec3f\n *\n * @example\n * const disarray = d.disarrayOf(d.align(16, d.vec3f), 3);\n *\n * @param elementType The type of elements in the array.\n * @param count The number of elements in the array.\n */\nexport const disarrayOf = <TElement extends AnyData>(\n elementType: TElement,\n count: number,\n): Disarray<Exotic<TElement>> =>\n new DisarrayImpl(elementType as Exotic<TElement>, count);\n\n// --------------\n// Implementation\n// --------------\n\nclass DisarrayImpl<TElement extends AnyData> implements Disarray<TElement> {\n public readonly type = 'disarray';\n /** Type-token, not available at runtime */\n public readonly '~repr'!: Infer<TElement>[];\n\n constructor(\n public readonly elementType: TElement,\n public readonly elementCount: number,\n ) {}\n}\n","import type { InferRecord } from '../shared/repr';\nimport type { Unstruct } from './dataTypes';\nimport type { ExoticRecord } from './exotic';\nimport type { BaseWgslData } from './wgslTypes';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Creates a loose struct schema that can be used to construct vertex buffers.\n * Describes structs with members of both loose and non-loose types.\n *\n * The order of members matches the passed in properties object.\n * Members are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.vec3f }); // packed struct with no padding\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.align(16, d.vec3f) });\n *\n * @param properties Record with `string` keys and `TgpuData` or `TgpuLooseData` values,\n * each entry describing one struct member.\n */\nexport const unstruct = <TProps extends Record<string, BaseWgslData>>(\n properties: TProps,\n): Unstruct<ExoticRecord<TProps>> =>\n new UnstructImpl(properties as ExoticRecord<TProps>);\n\n// --------------\n// Implementation\n// --------------\n\nclass UnstructImpl<TProps extends Record<string, BaseWgslData>>\n implements Unstruct<TProps>\n{\n public readonly type = 'unstruct';\n /** Type-token, not available at runtime */\n public readonly '~repr'!: InferRecord<TProps>;\n\n constructor(public readonly propTypes: TProps) {}\n}\n","import { inGPUMode } from '../gpuMode';\nimport type { SelfResolvable } from '../types';\nimport { type VecKind, vec2f, vec3f, vec4f } from './vector';\nimport type {\n Mat2x2f,\n Mat3x3f,\n Mat4x4f,\n m2x2f,\n m3x3f,\n m4x4f,\n mat2x2,\n mat3x3,\n mat4x4,\n matBase,\n v2f,\n v3f,\n v4f,\n} from './wgslTypes';\n\n// --------------\n// Implementation\n// --------------\n\ntype vBase = {\n kind: VecKind;\n length: number;\n [n: number]: number;\n};\n\ninterface MatSchemaOptions<TType extends string, ValueType> {\n type: TType;\n rows: number;\n columns: number;\n makeFromElements(...elements: number[]): ValueType;\n}\n\ntype MatConstructor<\n ValueType extends matBase<ColumnType>,\n ColumnType extends vBase,\n> = (...args: (number | ColumnType)[]) => ValueType;\n\nfunction createMatSchema<\n TType extends string,\n ValueType extends matBase<ColumnType>,\n ColumnType extends vBase,\n>(\n options: MatSchemaOptions<TType, ValueType>,\n): { type: TType; '~repr': ValueType } & MatConstructor<ValueType, ColumnType> {\n const MatSchema = {\n /** Type-token, not available at runtime */\n '~repr': undefined as unknown as ValueType,\n type: options.type,\n label: options.type,\n };\n\n const construct = (...args: (number | ColumnType)[]): ValueType => {\n if (inGPUMode()) {\n return `${MatSchema.type}(${args.join(', ')})` as unknown as ValueType;\n }\n\n const elements: number[] = [];\n\n for (const arg of args) {\n if (typeof arg === 'number') {\n elements.push(arg);\n } else {\n for (let i = 0; i < arg.length; ++i) {\n elements.push(arg[i] as number);\n }\n }\n }\n\n // Fill the rest with zeros\n for (let i = elements.length; i < options.columns * options.rows; ++i) {\n elements.push(0);\n }\n\n return options.makeFromElements(...elements);\n };\n\n return Object.assign(construct, MatSchema) as unknown as {\n type: TType;\n '~repr': ValueType;\n } & MatConstructor<ValueType, ColumnType>;\n}\n\nabstract class mat2x2Impl<TColumn extends v2f>\n implements mat2x2<TColumn>, SelfResolvable\n{\n public readonly columns: readonly [TColumn, TColumn];\n public readonly length = 4;\n public abstract readonly kind: string;\n [n: number]: number;\n\n constructor(...elements: number[]) {\n this.columns = [\n this.makeColumn(elements[0] as number, elements[1] as number),\n this.makeColumn(elements[2] as number, elements[3] as number),\n ];\n }\n\n abstract makeColumn(e0: number, e1: number): TColumn;\n\n get [0]() {\n return this.columns[0].x;\n }\n\n get [1]() {\n return this.columns[0].y;\n }\n\n get [2]() {\n return this.columns[1].x;\n }\n\n get [3]() {\n return this.columns[1].y;\n }\n\n set [0](value: number) {\n this.columns[0].x = value;\n }\n\n set [1](value: number) {\n this.columns[0].y = value;\n }\n\n set [2](value: number) {\n this.columns[1].x = value;\n }\n\n set [3](value: number) {\n this.columns[1].y = value;\n }\n\n '~resolve'(): string {\n return `${this.kind}(${Array.from({ length: this.length })\n .map((_, i) => this[i])\n .join(', ')})`;\n }\n}\n\nclass mat2x2fImpl extends mat2x2Impl<v2f> implements m2x2f {\n public readonly kind = 'mat2x2f';\n\n makeColumn(e0: number, e1: number): v2f {\n return vec2f(e0, e1);\n }\n}\n\nabstract class mat3x3Impl<TColumn extends v3f>\n implements mat3x3<TColumn>, SelfResolvable\n{\n public readonly columns: readonly [TColumn, TColumn, TColumn];\n public readonly length = 12;\n public abstract readonly kind: string;\n [n: number]: number;\n\n constructor(...elements: number[]) {\n this.columns = [\n this.makeColumn(\n elements[0] as number,\n elements[1] as number,\n elements[2] as number,\n ),\n this.makeColumn(\n elements[3] as number,\n elements[4] as number,\n elements[5] as number,\n ),\n this.makeColumn(\n elements[6] as number,\n elements[7] as number,\n elements[8] as number,\n ),\n ];\n }\n\n abstract makeColumn(x: number, y: number, z: number): TColumn;\n\n get [0]() {\n return this.columns[0].x;\n }\n\n get [1]() {\n return this.columns[0].y;\n }\n\n get [2]() {\n return this.columns[0].z;\n }\n\n get [3]() {\n return 0;\n }\n\n get [4]() {\n return this.columns[1].x;\n }\n\n get [5]() {\n return this.columns[1].y;\n }\n\n get [6]() {\n return this.columns[1].z;\n }\n\n get [7]() {\n return 0;\n }\n\n get [8]() {\n return this.columns[2].x;\n }\n\n get [9]() {\n return this.columns[2].y;\n }\n\n get [10]() {\n return this.columns[2].z;\n }\n\n get [11]() {\n return 0;\n }\n\n set [0](value: number) {\n this.columns[0].x = value;\n }\n\n set [1](value: number) {\n this.columns[0].y = value;\n }\n\n set [2](value: number) {\n this.columns[0].z = value;\n }\n\n set [3](_: number) {}\n\n set [4](value: number) {\n this.columns[1].x = value;\n }\n\n set [5](value: number) {\n this.columns[1].y = value;\n }\n\n set [6](value: number) {\n this.columns[1].z = value;\n }\n\n set [7](_: number) {}\n\n set [8](value: number) {\n this.columns[2].x = value;\n }\n\n set [9](value: number) {\n this.columns[2].y = value;\n }\n\n set [10](value: number) {\n this.columns[2].z = value;\n }\n\n set [11](_: number) {}\n\n '~resolve'(): string {\n return `${this.kind}(${this[0]}, ${this[1]}, ${this[2]}, ${this[4]}, ${this[5]}, ${this[6]}, ${this[8]}, ${this[9]}, ${this[10]})`;\n }\n}\n\nclass mat3x3fImpl extends mat3x3Impl<v3f> implements m3x3f {\n public readonly kind = 'mat3x3f';\n makeColumn(x: number, y: number, z: number): v3f {\n return vec3f(x, y, z);\n }\n}\n\nabstract class mat4x4Impl<TColumn extends v4f>\n implements mat4x4<TColumn>, SelfResolvable\n{\n public readonly columns: readonly [TColumn, TColumn, TColumn, TColumn];\n public abstract readonly kind: string;\n\n constructor(...elements: number[]) {\n this.columns = [\n this.makeColumn(\n elements[0] as number,\n elements[1] as number,\n elements[2] as number,\n elements[3] as number,\n ),\n this.makeColumn(\n elements[4] as number,\n elements[5] as number,\n elements[6] as number,\n elements[7] as number,\n ),\n this.makeColumn(\n elements[8] as number,\n elements[9] as number,\n elements[10] as number,\n elements[11] as number,\n ),\n this.makeColumn(\n elements[12] as number,\n elements[13] as number,\n elements[14] as number,\n elements[15] as number,\n ),\n ];\n }\n\n abstract makeColumn(x: number, y: number, z: number, w: number): TColumn;\n\n public readonly length = 16;\n [n: number]: number;\n\n get [0]() {\n return this.columns[0].x;\n }\n\n get [1]() {\n return this.columns[0].y;\n }\n\n get [2]() {\n return this.columns[0].z;\n }\n\n get [3]() {\n return this.columns[0].w;\n }\n\n get [4]() {\n return this.columns[1].x;\n }\n\n get [5]() {\n return this.columns[1].y;\n }\n\n get [6]() {\n return this.columns[1].z;\n }\n\n get [7]() {\n return this.columns[1].w;\n }\n\n get [8]() {\n return this.columns[2].x;\n }\n\n get [9]() {\n return this.columns[2].y;\n }\n\n get [10]() {\n return this.columns[2].z;\n }\n\n get [11]() {\n return this.columns[2].w;\n }\n\n get [12]() {\n return this.columns[3].x;\n }\n\n get [13]() {\n return this.columns[3].y;\n }\n\n get [14]() {\n return this.columns[3].z;\n }\n\n get [15]() {\n return this.columns[3].w;\n }\n\n set [0](value: number) {\n this.columns[0].x = value;\n }\n\n set [1](value: number) {\n this.columns[0].y = value;\n }\n\n set [2](value: number) {\n this.columns[0].z = value;\n }\n\n set [3](value: number) {\n this.columns[0].w = value;\n }\n\n set [4](value: number) {\n this.columns[1].x = value;\n }\n\n set [5](value: number) {\n this.columns[1].y = value;\n }\n\n set [6](value: number) {\n this.columns[1].z = value;\n }\n\n set [7](value: number) {\n this.columns[1].w = value;\n }\n\n set [8](value: number) {\n this.columns[2].x = value;\n }\n\n set [9](value: number) {\n this.columns[2].y = value;\n }\n\n set [10](value: number) {\n this.columns[2].z = value;\n }\n\n set [11](value: number) {\n this.columns[2].w = value;\n }\n\n set [12](value: number) {\n this.columns[3].x = value;\n }\n\n set [13](value: number) {\n this.columns[3].y = value;\n }\n\n set [14](value: number) {\n this.columns[3].z = value;\n }\n\n set [15](value: number) {\n this.columns[3].w = value;\n }\n\n '~resolve'(): string {\n return `${this.kind}(${Array.from({ length: this.length })\n .map((_, i) => this[i])\n .join(', ')})`;\n }\n}\n\nclass mat4x4fImpl extends mat4x4Impl<v4f> implements m4x4f {\n public readonly kind = 'mat4x4f';\n\n makeColumn(x: number, y: number, z: number, w: number): v4f {\n return vec4f(x, y, z, w);\n }\n}\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Type of the `d.mat2x2f` object/function: matrix data type schema/constructor\n */\nexport type NativeMat2x2f = Mat2x2f & { '~exotic': Mat2x2f } & ((\n ...elements: number[]\n ) => m2x2f) &\n ((...columns: v2f[]) => m2x2f) &\n (() => m2x2f);\n\n/**\n *\n * Schema representing mat2x2f - a matrix with 2 rows and 2 columns, with elements of type f32.\n * Also a constructor function for this matrix type.\n *\n * @example\n * const zero2x2 = mat2x2f(); // filled with zeros\n *\n * @example\n * const mat = mat2x2f(0, 1, 2, 3);\n * mat[0] // vec2f(0, 1)\n * mat[1] // vec2f(2, 3)\n *\n * @example\n * const mat = mat2x2f(\n * vec2f(0, 1), // column 0\n * vec2f(1, 2), // column 1\n * );\n *\n * @example\n * const buffer = root.createBuffer(d.mat2x2f, d.mat2x2f(0, 1, 2, 3)); // buffer holding a d.mat2x2f value, with an initial value of ((0, 1), (2, 3))\n */\nexport const mat2x2f = createMatSchema<'mat2x2f', m2x2f, v2f>({\n type: 'mat2x2f',\n rows: 2,\n columns: 2,\n makeFromElements: (...elements: number[]) => new mat2x2fImpl(...elements),\n}) as NativeMat2x2f;\n\n/**\n * Type of the `d.mat3x3f` object/function: matrix data type schema/constructor\n */\nexport type NativeMat3x3f = Mat3x3f & { '~exotic': Mat3x3f } & ((\n ...elements: number[]\n ) => m3x3f) &\n ((...columns: v3f[]) => m3x3f) &\n (() => m3x3f);\n\n/**\n *\n * Schema representing mat3x3f - a matrix with 3 rows and 3 columns, with elements of type f32.\n * Also a constructor function for this matrix type.\n *\n * @example\n * const zero3x3 = mat3x3f(); // filled with zeros\n *\n * @example\n * const mat = mat3x3f(0, 1, 2, 3, 4, 5, 6, 7, 8);\n * mat[0] // vec3f(0, 1, 2)\n * mat[1] // vec3f(3, 4, 5)\n * mat[2] // vec3f(6, 7, 8)\n *\n * @example\n * const mat = mat3x3f(\n * vec3f(0, 1, 2), // column 0\n * vec3f(2, 3, 4), // column 1\n * vec3f(5, 6, 7), // column 2\n * );\n *\n * @example\n * const buffer = root.createBuffer(d.mat3x3f, d.mat3x3f()); // buffer holding a d.mat3x3f value, with an initial value of mat3x3f filled with zeros\n */\nexport const mat3x3f = createMatSchema<'mat3x3f', m3x3f, v3f>({\n type: 'mat3x3f',\n rows: 3,\n columns: 3,\n makeFromElements: (...elements: number[]) => new mat3x3fImpl(...elements),\n}) as NativeMat3x3f;\n\n/**\n * Type of the `d.mat4x4f` object/function: matrix data type schema/constructor\n */\nexport type NativeMat4x4f = Mat4x4f & { '~exotic': Mat4x4f } & ((\n ...elements: number[]\n ) => m4x4f) &\n ((...columns: v4f[]) => m4x4f) &\n (() => m4x4f);\n\n/**\n *\n * Schema representing mat4x4f - a matrix with 4 rows and 4 columns, with elements of type f32.\n * Also a constructor function for this matrix type.\n *\n * @example\n * const zero4x4 = mat4x4f(); // filled with zeros\n *\n * @example\n * const mat = mat3x3f(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n * mat[0] // vec4f(0, 1, 2, 3)\n * mat[1] // vec4f(4, 5, 6, 7)\n * mat[2] // vec4f(8, 9, 10, 11)\n * mat[3] // vec4f(12, 13, 14, 15)\n *\n * @example\n * const mat = mat3x3f(\n * vec4f(0, 1, 2, 3), // column 0\n * vec4f(4, 5, 6, 7), // column 1\n * vec4f(8, 9, 10, 11), // column 2\n * vec4f(12, 13, 14, 15), // column 3\n * );\n *\n * @example\n * const buffer = root.createBuffer(d.mat4x4f, d.mat4x4f()); // buffer holding a d.mat4x4f value, with an initial value of mat4x4f filled with zeros\n */\nexport const mat4x4f = createMatSchema<'mat4x4f', m4x4f, v4f>({\n type: 'mat4x4f',\n rows: 4,\n columns: 4,\n makeFromElements: (...elements: number[]) => new mat4x4fImpl(...elements),\n}) as NativeMat4x4f;\n\nexport function matToArray(mat: m2x2f | m3x3f | m4x4f): number[] {\n if (mat.kind === 'mat3x3f') {\n return [\n mat[0],\n mat[1],\n mat[2],\n mat[4],\n mat[5],\n mat[6],\n mat[8],\n mat[9],\n mat[10],\n ] as number[];\n }\n\n return Array.from({ length: mat.length }).map((_, idx) => mat[idx] as number);\n}\n","import type { Infer } from '../shared/repr';\nimport type { Exotic } from './exotic';\nimport type { Atomic, I32, U32 } from './wgslTypes';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Marks a concrete integer scalar type schema (u32 or i32) as a WGSL atomic.\n *\n * @example\n * const atomicU32 = d.atomic(d.u32);\n * const atomicI32 = d.atomic(d.i32);\n *\n * @param data Underlying type schema.\n */\nexport function atomic<TSchema extends U32 | I32>(\n data: TSchema,\n): Atomic<Exotic<TSchema>> {\n return new AtomicImpl(data as Exotic<TSchema>);\n}\n\n// --------------\n// Implementation\n// --------------\n\nclass AtomicImpl<TSchema extends U32 | I32> implements Atomic<TSchema> {\n public readonly type = 'atomic';\n /** Type-token, not available at runtime */\n public readonly '~repr'!: Infer<TSchema>;\n\n constructor(public readonly inner: TSchema) {}\n}\n","import type { Infer } from '../shared/repr';\nimport { alignmentOf } from './alignmentOf';\nimport {\n type AnyData,\n type AnyLooseData,\n type LooseDecorated,\n type LooseTypeLiteral,\n isLooseData,\n isLooseDecorated,\n} from './dataTypes';\nimport type { Exotic } from './exotic';\nimport { sizeOf } from './sizeOf';\nimport {\n type Align,\n type AnyWgslData,\n type BaseWgslData,\n type Builtin,\n type Decorated,\n type FlatInterpolatableData,\n type FlatInterpolationType,\n type Interpolate,\n type InterpolationType,\n type Location,\n type PerspectiveOrLinearInterpolatableData,\n type PerspectiveOrLinearInterpolationType,\n type Size,\n type WgslTypeLiteral,\n isAlignAttrib,\n isBuiltinAttrib,\n isDecorated,\n isSizeAttrib,\n isWgslData,\n} from './wgslTypes';\n\n// ----------\n// Public API\n// ----------\n\nexport const builtinNames = [\n 'vertex_index',\n 'instance_index',\n 'position',\n 'clip_distances',\n 'front_facing',\n 'frag_depth',\n 'sample_index',\n 'sample_mask',\n 'fragment',\n 'local_invocation_id',\n 'local_invocation_index',\n 'global_invocation_id',\n 'workgroup_id',\n 'num_workgroups',\n] as const;\n\nexport type BuiltinName = (typeof builtinNames)[number];\n\nexport type AnyAttribute =\n | Align<number>\n | Size<number>\n | Location<number>\n | Builtin<BuiltinName>\n | Interpolate<InterpolationType>;\n\nexport type ExtractAttributes<T> = T extends {\n readonly attribs: unknown[];\n}\n ? T['attribs']\n : [];\n\ntype Undecorate<T> = T extends { readonly inner: infer TInner } ? TInner : T;\n\n/**\n * Decorates a data-type `TData` with an attribute `TAttrib`.\n *\n * - if `TData` is loose\n * - if `TData` is already `LooseDecorated`\n * - Prepend `TAttrib` to the existing attribute tuple.\n * - else\n * - Wrap `TData` with `LooseDecorated` and a single attribute `[TAttrib]`\n * - else\n * - if `TData` is already `Decorated`\n * - Prepend `TAttrib` to the existing attribute tuple.\n * - else\n * - Wrap `TData` with `Decorated` and a single attribute `[TAttrib]`\n */\nexport type Decorate<\n TData extends BaseWgslData,\n TAttrib extends AnyAttribute,\n> = TData['type'] extends WgslTypeLiteral\n ? Decorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]>\n : TData['type'] extends LooseTypeLiteral\n ? LooseDecorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]>\n : never;\n\nexport type IsBuiltin<T> = ExtractAttributes<T>[number] extends []\n ? false\n : ExtractAttributes<T>[number] extends Builtin<BuiltinName>\n ? true\n : false;\n\nexport type HasCustomLocation<T> = ExtractAttributes<T>[number] extends []\n ? false\n : ExtractAttributes<T>[number] extends Location<number>\n ? true\n : false;\n\nexport function attribute<\n TData extends BaseWgslData,\n TAttrib extends AnyAttribute,\n>(data: TData, attrib: TAttrib): Decorated | LooseDecorated {\n if (isDecorated(data)) {\n return new DecoratedImpl(data.inner, [\n attrib,\n ...data.attribs,\n ]) as Decorated;\n }\n\n if (isLooseDecorated(data)) {\n return new LooseDecoratedImpl(data.inner, [\n attrib,\n ...data.attribs,\n ]) as LooseDecorated;\n }\n\n if (isLooseData(data)) {\n return new LooseDecoratedImpl(data, [attrib]) as unknown as LooseDecorated;\n }\n\n return new DecoratedImpl(data, [attrib]) as unknown as Decorated;\n}\n\n/**\n * Gives the wrapped data-type a custom byte alignment. Useful in order to\n * fulfill uniform alignment requirements.\n *\n * @example\n * const Data = d.struct({\n * a: u32, // takes up 4 bytes\n * // 12 bytes of padding, because `b` is custom aligned to multiples of 16 bytes\n * b: d.align(16, u32),\n * });\n *\n * @param alignment The multiple of bytes this data should align itself to.\n * @param data The data-type to align.\n */\nexport function align<TAlign extends number, TData extends AnyData>(\n alignment: TAlign,\n data: TData,\n): Decorate<Exotic<TData>, Align<TAlign>> {\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n return attribute(data, { type: '@align', value: alignment }) as any;\n}\n\n/**\n * Adds padding bytes after the wrapped data-type, until the whole value takes up `size` bytes.\n *\n * @example\n * const Data = d.struct({\n * a: d.size(16, u32), // takes up 16 bytes, instead of 4\n * b: u32, // starts at byte 16, because `a` has a custom size\n * });\n *\n * @param size The amount of bytes that should be reserved for this data-type.\n * @param data The data-type to wrap.\n */\nexport function size<TSize extends number, TData extends AnyData>(\n size: TSize,\n data: TData,\n): Decorate<Exotic<TData>, Size<TSize>> {\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n return attribute(data, { type: '@size', value: size }) as any;\n}\n\n/**\n * Assigns an explicit numeric location to a struct member or a parameter that has this type.\n *\n * @example\n * const VertexOutput = {\n * a: d.u32, // has implicit location 0\n * b: d.location(5, d.u32),\n * c: d.u32, // has implicit location 6\n * };\n *\n * @param location The explicit numeric location.\n * @param data The data-type to wrap.\n */\nexport function location<TLocation extends number, TData extends AnyData>(\n location: TLocation,\n data: TData,\n): Decorate<Exotic<TData>, Location<TLocation>> {\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n return attribute(data, { type: '@location', value: location }) as any;\n}\n\n/**\n * Specifies how user-defined vertex shader output (fragment shader input)\n * must be interpolated.\n *\n * Tip: Integer outputs cannot be interpolated.\n *\n * @example\n * const VertexOutput = {\n * a: d.f32, // has implicit 'perspective, center' interpolation\n * b: d.interpolate('linear, sample', d.f32),\n * };\n *\n * @param interpolationType How data should be interpolated.\n * @param data The data-type to wrap.\n */\nexport function interpolate<\n TInterpolation extends PerspectiveOrLinearInterpolationType,\n TData extends PerspectiveOrLinearInterpolatableData,\n>(\n interpolationType: TInterpolation,\n data: TData,\n): Decorate<Exotic<TData>, Interpolate<TInterpolation>>;\n\n/**\n * Specifies how user-defined vertex shader output (fragment shader input)\n * must be interpolated.\n *\n * Tip: Default sampling method of `flat` is `first`. Unless you specifically\n * need deterministic behavior provided by `'flat, first'`, prefer explicit\n * `'flat, either'` as it could be slightly faster in hardware.\n *\n * @example\n * const VertexOutput = {\n * a: d.f32, // has implicit 'perspective, center' interpolation\n * b: d.interpolate('flat, either', d.u32), // integer outputs cannot interpolate\n * };\n *\n * @param interpolationType How data should be interpolated.\n * @param data The data-type to wrap.\n */\nexport function interpolate<\n TInterpolation extends FlatInterpolationType,\n TData extends FlatInterpolatableData,\n>(\n interpolationType: TInterpolation,\n data: TData,\n): Decorate<Exotic<TData>, Interpolate<TInterpolation>>;\n\nexport function interpolate<\n TInterpolation extends InterpolationType,\n TData extends AnyData,\n>(\n interpolationType: TInterpolation,\n data: TData,\n): Decorate<Exotic<TData>, Interpolate<TInterpolation>> {\n return attribute(data, {\n type: '@interpolate',\n value: interpolationType,\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\nexport function isBuiltin<\n T extends\n | Decorated<AnyWgslData, AnyAttribute[]>\n | LooseDecorated<AnyLooseData, AnyAttribute[]>,\n>(value: T | unknown): value is T {\n return (\n (isDecorated(value) || isLooseDecorated(value)) &&\n value.attribs.find(isBuiltinAttrib) !== undefined\n );\n}\n\nexport function getAttributesString<T extends BaseWgslData>(field: T): string {\n if (!isDecorated(field) && !isLooseDecorated(field)) {\n return '';\n }\n\n return (field.attribs as AnyAttribute[])\n .map((attrib) => `${attrib.type}(${attrib.value}) `)\n .join('');\n}\n\n// --------------\n// Implementation\n// --------------\n\nclass BaseDecoratedImpl<\n TInner extends BaseWgslData,\n TAttribs extends unknown[],\n> {\n // Type-token, not available at runtime\n public readonly '~repr'!: Infer<TInner>;\n\n constructor(\n public readonly inner: TInner,\n public readonly attribs: TAttribs,\n ) {\n const alignAttrib = attribs.find(isAlignAttrib)?.value;\n const sizeAttrib = attribs.find(isSizeAttrib)?.value;\n\n if (alignAttrib !== undefined) {\n if (alignAttrib <= 0) {\n throw new Error(\n `Custom data alignment must be a positive number, got: ${alignAttrib}.`,\n );\n }\n\n if (Math.log2(alignAttrib) % 1 !== 0) {\n throw new Error(\n `Alignment has to be a power of 2, got: ${alignAttrib}.`,\n );\n }\n\n if (isWgslData(this.inner)) {\n if (alignAttrib % alignmentOf(this.inner) !== 0) {\n throw new Error(\n `Custom alignment has to be a multiple of the standard data alignment. Got: ${alignAttrib}, expected multiple of: ${alignmentOf(this.inner)}.`,\n );\n }\n }\n }\n\n if (sizeAttrib !== undefined) {\n if (sizeAttrib < sizeOf(this.inner)) {\n throw new Error(\n `Custom data size cannot be smaller then the standard data size. Got: ${sizeAttrib}, expected at least: ${sizeOf(this.inner)}.`,\n );\n }\n\n if (sizeAttrib <= 0) {\n throw new Error(\n `Custom data size must be a positive number. Got: ${sizeAttrib}.`,\n );\n }\n }\n }\n}\n\nclass DecoratedImpl<TInner extends BaseWgslData, TAttribs extends unknown[]>\n extends BaseDecoratedImpl<TInner, TAttribs>\n implements Decorated<TInner, TAttribs>\n{\n public readonly type = 'decorated';\n}\n\nclass LooseDecoratedImpl<\n TInner extends BaseWgslData,\n TAttribs extends unknown[],\n >\n extends BaseDecoratedImpl<TInner, TAttribs>\n implements LooseDecorated<TInner, TAttribs>\n{\n public readonly type = 'loose-decorated';\n}\n","import { arrayOf } from './data/array';\nimport { attribute } from './data/attributes';\nimport { f32, u32 } from './data/numeric';\nimport { vec3u, vec4f } from './data/vector';\nimport type {\n BaseWgslData,\n Builtin,\n Decorated,\n F32,\n U32,\n Vec3u,\n Vec4f,\n WgslArray,\n} from './data/wgslTypes';\n\n// ----------\n// Public API\n// ----------\n\nexport type BuiltinVertexIndex = Decorated<U32, [Builtin<'vertex_index'>]>;\nexport type BuiltinInstanceIndex = Decorated<U32, [Builtin<'instance_index'>]>;\nexport type BuiltinPosition = Decorated<Vec4f, [Builtin<'position'>]>;\nexport type BuiltinClipDistances = Decorated<\n WgslArray<U32>,\n [Builtin<'clip_distances'>]\n>;\nexport type BuiltinFrontFacing = Decorated<F32, [Builtin<'front_facing'>]>;\nexport type BuiltinFragDepth = Decorated<F32, [Builtin<'frag_depth'>]>;\nexport type BuiltinSampleIndex = Decorated<U32, [Builtin<'sample_index'>]>;\nexport type BuiltinSampleMask = Decorated<U32, [Builtin<'sample_mask'>]>;\nexport type BuiltinFragment = Decorated<Vec4f, [Builtin<'fragment'>]>;\nexport type BuiltinLocalInvocationId = Decorated<\n Vec3u,\n [Builtin<'local_invocation_id'>]\n>;\nexport type BuiltinLocalInvocationIndex = Decorated<\n U32,\n [Builtin<'local_invocation_index'>]\n>;\nexport type BuiltinGlobalInvocationId = Decorated<\n Vec3u,\n [Builtin<'global_invocation_id'>]\n>;\nexport type BuiltinWorkgroupId = Decorated<Vec3u, [Builtin<'workgroup_id'>]>;\nexport type BuiltinNumWorkgroups = Decorated<\n Vec3u,\n [Builtin<'num_workgroups'>]\n>;\n\nexport const builtin = {\n vertexIndex: attribute(u32, {\n type: '@builtin',\n value: 'vertex_index',\n }) as BuiltinVertexIndex,\n instanceIndex: attribute(u32, {\n type: '@builtin',\n value: 'instance_index',\n }) as BuiltinInstanceIndex,\n position: attribute(vec4f, {\n type: '@builtin',\n value: 'position',\n }) as BuiltinPosition,\n clipDistances: attribute(arrayOf(u32, 8), {\n type: '@builtin',\n value: 'clip_distances',\n }) as BuiltinClipDistances,\n frontFacing: attribute(f32, {\n type: '@builtin',\n value: 'front_facing',\n }) as BuiltinFrontFacing,\n fragDepth: attribute(f32, {\n type: '@builtin',\n value: 'frag_depth',\n }) as BuiltinFragDepth,\n sampleIndex: attribute(u32, {\n type: '@builtin',\n value: 'sample_index',\n }) as BuiltinSampleIndex,\n sampleMask: attribute(u32, {\n type: '@builtin',\n value: 'sample_mask',\n }) as BuiltinSampleMask,\n localInvocationId: attribute(vec3u, {\n type: '@builtin',\n value: 'local_invocation_id',\n }) as BuiltinLocalInvocationId,\n localInvocationIndex: attribute(u32, {\n type: '@builtin',\n value: 'local_invocation_index',\n }) as BuiltinLocalInvocationIndex,\n globalInvocationId: attribute(vec3u, {\n type: '@builtin',\n value: 'global_invocation_id',\n }) as BuiltinGlobalInvocationId,\n workgroupId: attribute(vec3u, {\n type: '@builtin',\n value: 'workgroup_id',\n }) as BuiltinWorkgroupId,\n numWorkgroups: attribute(vec3u, {\n type: '@builtin',\n value: 'num_workgroups',\n }) as BuiltinNumWorkgroups,\n} as const;\n\nexport type AnyBuiltin = (typeof builtin)[keyof typeof builtin];\n\nexport type OmitBuiltins<S> = S extends AnyBuiltin\n ? never\n : S extends BaseWgslData\n ? S\n : {\n [Key in keyof S as S[Key] extends AnyBuiltin ? never : Key]: S[Key];\n };\n"]}
|