typegpu 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/builtin-DdtWpk2t.js +818 -0
- package/builtin-DdtWpk2t.js.map +1 -0
- package/chunk-BYypO7fO.js +18 -0
- package/common/index.d.ts +8 -23
- package/common/index.d.ts.map +1 -0
- package/common/index.js +7 -5
- package/common/index.js.map +1 -1
- package/data/index.d.ts +7 -401
- package/data/index.d.ts.map +1 -0
- package/data/index.js +164 -1
- package/data/index.js.map +1 -1
- package/deepEqual-DQxK4vdp.js +413 -0
- package/deepEqual-DQxK4vdp.js.map +1 -0
- package/extensions-DIVuAfBM.js +2032 -0
- package/extensions-DIVuAfBM.js.map +1 -0
- package/fullScreenTriangle-CfFyQd_0.js +543 -0
- package/fullScreenTriangle-CfFyQd_0.js.map +1 -0
- package/index.d.ts +124 -310
- package/index.d.ts.map +1 -0
- package/index.js +6282 -153
- package/index.js.map +1 -1
- package/indexNamedExports-oL6tyaJ9.d.ts +5697 -0
- package/indexNamedExports-oL6tyaJ9.d.ts.map +1 -0
- package/operators-d-PMVTo7.js +4158 -0
- package/operators-d-PMVTo7.js.map +1 -0
- package/package.json +3 -2
- package/std/index.d.ts +7 -621
- package/std/index.d.ts.map +1 -0
- package/std/index.js +165 -1
- package/std/index.js.map +1 -1
- package/texture-BagDrrks.js +205 -0
- package/texture-BagDrrks.js.map +1 -0
- package/chunk-5ABKYSJD.js +0 -2
- package/chunk-5ABKYSJD.js.map +0 -1
- package/chunk-D5UYO3OX.js +0 -3
- package/chunk-D5UYO3OX.js.map +0 -1
- package/chunk-EHLRP4V2.js +0 -2
- package/chunk-EHLRP4V2.js.map +0 -1
- package/chunk-LMPPDGRD.js +0 -2
- package/chunk-LMPPDGRD.js.map +0 -1
- package/chunk-MBB2XFH6.js +0 -2
- package/chunk-MBB2XFH6.js.map +0 -1
- package/chunk-SHSILTWI.js +0 -10
- package/chunk-SHSILTWI.js.map +0 -1
- package/comptime-DKpw1IVu.d.ts +0 -28
- package/matrix-C4IFKU1R.d.ts +0 -123
- package/tgpuConstant-BOn7U_lv.d.ts +0 -4031
package/std/index.js
CHANGED
|
@@ -1,2 +1,166 @@
|
|
|
1
|
-
import{$ as Je,A as Ce,Aa as ht,B as Ae,Ba as St,C as $e,Ca as Ct,D as we,Da as At,E as De,Ea as $t,F as Ee,G as Le,H as Oe,I as Be,J as We,K as Fe,L as Ve,M as _e,N as Me,O as Ne,P as Ge,Q as Pe,R as Ue,S as Xe,T as ke,U as Re,V as Ze,W as Ye,X as je,Y as qe,Z as ze,_ as He,a as k,aa as Ke,ba as Qe,c as ee,ca as et,d as te,da as tt,e as re,ea as rt,f as oe,fa as ot,g as ne,ga as nt,h as ue,ha as ut,i as ae,ia as at,j as se,ja as st,k as pe,ka as pt,l as me,la as mt,m as ie,ma as it,n as le,na as lt,o as de,oa as dt,p as ce,pa as R,q as xe,r as fe,ra as ct,s as ge,sa as xt,t as Te,ta as ft,u as ye,ua as gt,v as be,va as Tt,w as ve,wa as yt,x as Ie,xa as bt,y as he,ya as vt,z as Se,za as It}from"../chunk-5ABKYSJD.js";import{Q as X,b as Y,c as j,d as q,e as S,f as C,g as A,h as $,i as w,l as c,r as z,s as H,t as O,u as J,v as K,w as Q}from"../chunk-EHLRP4V2.js";import{Ab as h,C as W,E,Ha as F,Hb as U,Ib as D,La as o,Ma as V,Va as _,_a as g,a,db as r,eb as M,gb as l,hb as u,jb as T,kb as d,q as p,qb as N,sb as L,vb as G,xb as y,zb as P}from"../chunk-SHSILTWI.js";var wt=r({name:"discard",normalImpl:"`discard` relies on GPU resources and cannot be executed outside of a draw call",signature:{argTypes:[],returnType:p},codegenImpl:()=>"discard;"});var I=O[a].jsImpl,Dt=S[a].jsImpl,Et=S[a].gpuImpl,Lt=C[a].jsImpl,Ot=C[a].gpuImpl,Bt=A[a].jsImpl,Wt=A[a].gpuImpl,Ft=$[a].jsImpl,Vt=$[a].gpuImpl,_t=w[a].jsImpl,Mt=w[a].gpuImpl,Nt=r({name:"translate4",normalImpl:(e,t)=>I(Dt(t),e),signature:{argTypes:[c,L],returnType:c},codegenImpl:(e,t)=>o`(${Et(t)} * ${e})`}),Gt=r({name:"scale4",normalImpl:(e,t)=>I(Lt(t),e),signature:{argTypes:[c,L],returnType:c},codegenImpl:(e,t)=>o`(${Ot(t)} * ${e})`}),B={argTypes:[c,d],returnType:c},Pt=r({name:"rotateX4",normalImpl:(e,t)=>I(Bt(t),e),signature:B,codegenImpl:(e,t)=>o`(${Wt(t)} * ${e})`}),Ut=r({name:"rotateY4",normalImpl:(e,t)=>I(Ft(t),e),signature:B,codegenImpl:(e,t)=>o`(${Vt(t)} * ${e})`}),Xt=r({name:"rotateZ4",normalImpl:(e,t)=>I(_t(t),e),signature:B,codegenImpl:(e,t)=>o`(${Mt(t)} * ${e})`});var kt=r({name:"workgroupBarrier",normalImpl:"workgroupBarrier is a no-op outside of CODEGEN mode.",signature:{argTypes:[],returnType:p},codegenImpl:()=>"workgroupBarrier()"}),Rt=r({name:"storageBarrier",normalImpl:"storageBarrier is a no-op outside of CODEGEN mode.",signature:{argTypes:[],returnType:p},codegenImpl:()=>"storageBarrier()"}),Zt=r({name:"textureBarrier",normalImpl:"textureBarrier is a no-op outside of CODEGEN mode.",signature:{argTypes:[],returnType:p},codegenImpl:()=>"textureBarrier()"}),m="Atomic operations are not supported outside of CODEGEN mode.",Yt=r({name:"atomicLoad",normalImpl:m,signature:e=>{if(e.type!=="atomic")throw new Error(`Invalid atomic type: ${D(e)}`);return{argTypes:[e],returnType:e.inner}},codegenImpl:e=>o`atomicLoad(&${e})`}),jt=(e,t)=>{if(e.type!=="atomic")throw new Error(`Invalid atomic type: ${D(e)}`);return{argTypes:[e,e.inner.type==="u32"?u:T],returnType:p}},x=(e,t)=>{if(e.type!=="atomic")throw new Error(`Invalid atomic type: ${D(e)}`);let s=e.inner.type==="u32"?u:T;return{argTypes:[e,s],returnType:s}},qt=r({name:"atomicStore",normalImpl:m,signature:jt,codegenImpl:(e,t)=>o`atomicStore(&${e}, ${t})`}),zt=r({name:"atomicAdd",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicAdd(&${e}, ${t})`}),Ht=r({name:"atomicSub",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicSub(&${e}, ${t})`}),Jt=r({name:"atomicMax",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicMax(&${e}, ${t})`}),Kt=r({name:"atomicMin",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicMin(&${e}, ${t})`}),Qt=r({name:"atomicAnd",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicAnd(&${e}, ${t})`}),er=r({name:"atomicOr",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicOr(&${e}, ${t})`}),tr=r({name:"atomicXor",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicXor(&${e}, ${t})`});var i="Derivative builtins are not allowed on the CPU",rr=r({name:"dpdx",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdx(${e})`}),or=r({name:"dpdxCoarse",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdxCoarse(${e})`}),nr=r({name:"dpdxFine",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdxFine(${e})`}),ur=r({name:"dpdy",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdy(${e})`}),ar=r({name:"dpdyCoarse",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdyCoarse(${e})`}),sr=r({name:"dpdyFine",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdyFine(${e})`}),pr=r({name:"fwidth",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`fwidth(${e})`}),mr=r({name:"fwidthCoarse",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`fwidthCoarse(${e})`}),ir=r({name:"fwidthFine",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`fwidthFine(${e})`});var Z=e=>E(e)&&W(e.inner)?e.inner.elementCount:0,lr=r({name:"arrayLength",signature:e=>{let t=E(e)?e:V(e);return{argTypes:[t],returnType:Z(t)>0?M:u}},normalImpl:e=>_(e)?e.$.length:e.length,codegenImpl(e){let t=Z(e.dataType);return t>0?String(t):o`arrayLength(${e})`}});function dr(e,t,s,f,b){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var cr=r({name:"textureSample",normalImpl:dr,codegenImpl:(...e)=>o`textureSample(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?d:y}}});function xr(e,t,s,f,b,v){throw new Error("Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call")}var fr=r({name:"textureSampleBias",normalImpl:xr,codegenImpl:(...e)=>o`textureSampleBias(${e})`,signature:(...e)=>({argTypes:e,returnType:y})});function gr(e,t,s,f,b,v){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var Tr=r({name:"textureSampleLevel",normalImpl:gr,codegenImpl:(...e)=>o`textureSampleLevel(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?d:y}}});function yr(e,t,s){throw new Error("`textureLoad` relies on GPU resources and cannot be executed outside of a draw call")}var br=r({name:"textureLoad",normalImpl:yr,codegenImpl:(...e)=>o`textureLoad(${e})`,signature:(...e)=>{let t=e[0];if(X(t)){let b=t.type.startsWith("texture_depth"),v=t.sampleType;return{argTypes:e,returnType:b?d:v.type==="f32"?y:v.type==="u32"?h:P}}let s=t.format,f=k(s).vectorType;return{argTypes:e,returnType:f}}});function vr(e,t,s,f){throw new Error("`textureStore` relies on GPU resources and cannot be executed outside of a draw call")}var Ir=r({name:"textureStore",normalImpl:vr,codegenImpl:(...e)=>o`textureStore(${e})`,signature:(...e)=>({argTypes:e,returnType:p})});function hr(e,t){throw new Error("`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call")}var Sr=r({name:"textureDimensions",normalImpl:hr,codegenImpl:(...e)=>o`textureDimensions(${e})`,signature:(...e)=>{let t=e[0].dimension;return t==="1d"?{argTypes:e,returnType:u}:t==="3d"?{argTypes:e,returnType:G}:{argTypes:e,returnType:N}}});function Cr(e,t,s,f,b,v){throw new Error("Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call")}var Ar=r({name:"textureSampleCompare",normalImpl:Cr,codegenImpl:(...e)=>o`textureSampleCompare(${e})`,signature:(...e)=>({argTypes:e,returnType:d})});function $r(e,t,s){throw new Error("Texture sampling with base clamp to edge is not supported outside of GPU mode.")}var wr=r({name:"textureSampleBaseClampToEdge",normalImpl:$r,codegenImpl:(...e)=>o`textureSampleBaseClampToEdge(${e})`,signature:(...e)=>({argTypes:e,returnType:y})});var n="Subgroup operations can only be used in the GPU context.",Dr=r({name:"subgroupAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupAdd(${e})`}),Er=r({name:"subgroupExclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupExclusiveAdd(${e})`}),Lr=r({name:"subgroupInclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupInclusiveAdd(${e})`}),Or=r({name:"subgroupAll",signature:{argTypes:[l],returnType:l},normalImpl:n,codegenImpl:e=>o`subgroupAll(${e})`}),Br=r({name:"subgroupAnd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupAnd(${e})`}),Wr=r({name:"subgroupAny",signature:{argTypes:[l],returnType:l},normalImpl:n,codegenImpl:e=>o`subgroupAny(${e})`}),Fr=r({name:"subgroupBallot",signature:{argTypes:[l],returnType:h},normalImpl:n,codegenImpl:e=>o`subgroupBallot(${e})`}),Vr=r({name:"subgroupBroadcast",signature:(...e)=>{let t=g([e[1]],[T,u]);if(!t)throw new Error(`subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupBroadcast(${e}, ${t})`}),_r=r({name:"subgroupBroadcastFirst",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupBroadcastFirst(${e})`}),Mr=r({name:"subgroupElect",signature:{argTypes:[],returnType:l},normalImpl:n,codegenImpl:()=>o`subgroupElect()`}),Nr=r({name:"subgroupMax",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupMax(${e})`}),Gr=r({name:"subgroupMin",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupMin(${e})`}),Pr=r({name:"subgroupMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupMul(${e})`}),Ur=r({name:"subgroupExclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupExclusiveMul(${e})`}),Xr=r({name:"subgroupInclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupInclusiveMul(${e})`}),kr=r({name:"subgroupOr",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupOr(${e})`}),Rr=r({name:"subgroupShuffle",signature:(...e)=>{let t=g([e[1]],[T,u]);if(!t)throw new Error(`subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffle(${e}, ${t})`}),Zr=r({name:"subgroupShuffleDown",signature:(...e)=>{let t=g([e[1]],[u]);if(!t)throw new Error(`subgroupShuffleDown's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffleDown(${e}, ${t})`}),Yr=r({name:"subgroupShuffleUp",signature:(...e)=>{let t=g([e[1]],[u]);if(!t)throw new Error(`subgroupShuffleUp's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffleUp(${e}, ${t})`}),jr=r({name:"subgroupShuffleXor",signature:(...e)=>{let t=g([e[1]],[u]);if(!t)throw new Error(`subgroupShuffleXor's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffleXor(${e}, ${t})`}),qr=r({name:"subgroupXor",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupXor(${e})`});var zr=U(e=>{let t=F();if(!t)throw new Error("Functions using `extensionEnabled` cannot be called directly. Either generate WGSL from them, or use tgpu['~unstable'].simulate(...)");if(typeof e!="string"||!R.includes(e))throw new Error(`extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: '${e}'`);return(t.enableExtensions??[]).includes(e)});export{ee as abs,te as acos,re as acosh,z as add,St as all,ct as allEq,ht as and,Ct as any,lr as arrayLength,oe as asin,ne as asinh,ue as atan,se as atan2,ae as atanh,zt as atomicAdd,Qt as atomicAnd,Yt as atomicLoad,Jt as atomicMax,Kt as atomicMin,er as atomicOr,qt as atomicStore,Ht as atomicSub,tr as atomicXor,st as bitcastU32toF32,pt as bitcastU32toI32,pe as ceil,me as clamp,ie as cos,le as cosh,de as countLeadingZeros,ce as countOneBits,xe as countTrailingZeros,fe as cross,ge as degrees,Te as determinant,wt as discard,ye as distance,J as div,be as dot,Ie as dot4I8Packed,ve as dot4U8Packed,rr as dpdx,or as dpdxCoarse,nr as dpdxFine,ur as dpdy,ar as dpdyCoarse,sr as dpdyFine,xt as eq,he as exp,Se as exp2,zr as extensionEnabled,Ce as extractBits,Ae as faceForward,$e as firstLeadingBit,we as firstTrailingBit,De as floor,Ee as fma,Le as fract,Oe as frexp,pr as fwidth,mr as fwidthCoarse,ir as fwidthFine,bt as ge,yt as gt,Y as identity2,j as identity3,q as identity4,Be as insertBits,We as inverseSqrt,At as isCloseTo,Fe as ldexp,Tt as le,Ve as length,_e as log,Me as log2,gt as lt,Ne as max,Ge as min,Pe as mix,K as mod,Ue as modf,O as mul,ft as ne,Q as neg,Xe as normalize,vt as not,It as or,it as pack2x16float,dt as pack4x8unorm,ke as pow,Re as quantizeToF16,Ze as radians,Ye as reflect,je as refract,qe as reverseBits,Pt as rotateX4,Ut as rotateY4,Xt as rotateZ4,A as rotationX4,$ as rotationY4,w as rotationZ4,ze as round,He as saturate,Gt as scale4,C as scaling4,$t as select,Je as sign,Ke as sin,Qe as sinh,et as smoothstep,tt as sqrt,rt as step,Rt as storageBarrier,H as sub,Dr as subgroupAdd,Or as subgroupAll,Br as subgroupAnd,Wr as subgroupAny,Fr as subgroupBallot,Vr as subgroupBroadcast,_r as subgroupBroadcastFirst,Mr as subgroupElect,Er as subgroupExclusiveAdd,Ur as subgroupExclusiveMul,Lr as subgroupInclusiveAdd,Xr as subgroupInclusiveMul,Nr as subgroupMax,Gr as subgroupMin,Pr as subgroupMul,kr as subgroupOr,Rr as subgroupShuffle,Zr as subgroupShuffleDown,Yr as subgroupShuffleUp,jr as subgroupShuffleXor,qr as subgroupXor,ot as tan,nt as tanh,Zt as textureBarrier,Sr as textureDimensions,br as textureLoad,cr as textureSample,wr as textureSampleBaseClampToEdge,fr as textureSampleBias,Ar as textureSampleCompare,Tr as textureSampleLevel,Ir as textureStore,Nt as translate4,S as translation4,ut as transpose,at as trunc,mt as unpack2x16float,lt as unpack4x8unorm,kt as workgroupBarrier};
|
|
1
|
+
import { t as __exportAll } from "../chunk-BYypO7fO.js";
|
|
2
|
+
import { C as translation4, S as scaling4, a as neg, b as rotationY4, f as identity2, i as mul, m as identity4, n as div, o as sub, p as identity3, r as mod, t as add, x as rotationZ4, y as rotationX4 } from "../operators-d-PMVTo7.js";
|
|
3
|
+
import { $ as workgroupBarrier, $t as extractBits, A as textureSampleCompareLevel, An as sqrt, At as acos, B as fwidthCoarse, Bt as cosh, C as textureDimensions, Cn as reverseBits, Ct as pack4x8unorm, D as textureSampleBaseClampToEdge, Dn as sin, Dt as bitcastU32toI32, E as textureSample, En as sign, Et as bitcastU32toF32, F as dpdxFine, Fn as trunc, Ft as atan2, G as atomicMax, Gt as degrees, H as atomicAdd, Ht as countOneBits, I as dpdy, It as atanh, J as atomicStore, Jt as dot, K as atomicMin, Kt as determinant, L as dpdyCoarse, Lt as ceil, M as textureStore, Mn as tan, Mt as asin, N as dpdx, Nn as tanh, Nt as asinh, O as textureSampleBias, On as sinh, Ot as arrayLength, P as dpdxCoarse, Pn as transpose, Pt as atan, Q as textureBarrier, Qt as exp2, R as dpdyFine, Rt as clamp, S as subgroupXor, Sn as refract, St as pack2x16float, T as textureLoad, Tn as saturate, Tt as unpack4x8unorm, U as atomicAnd, Ut as countTrailingZeros, V as fwidthFine, Vt as countLeadingZeros, W as atomicLoad, Wt as cross, X as atomicXor, Xt as dot4U8Packed, Y as atomicSub, Yt as dot4I8Packed, Z as storageBarrier, Zt as exp, _ as subgroupOr, _n as normalize, _t as not, a as subgroupAny, an as fract, at as discard, b as subgroupShuffleUp, bn as radians, c as subgroupBroadcastFirst, cn as inverseSqrt, ct as and, d as subgroupExclusiveMul, dn as log, dt as ge, en as faceForward, et as rotateX4, f as subgroupInclusiveAdd, fn as log2, ft as gt, g as subgroupMul, gn as modf, gt as ne, h as subgroupMin, hn as mix, ht as lt, i as subgroupAnd, in as fma, it as translate4, j as textureSampleLevel, jn as step, jt as acosh, k as textureSampleCompare, kn as smoothstep, kt as abs, l as subgroupElect, ln as ldexp, lt as any, m as subgroupMax, mn as min, mt as le, n as subgroupAdd, nn as firstTrailingBit, nt as rotateZ4, o as subgroupBallot, on as frexp, ot as all, p as subgroupInclusiveMul, pn as max, pt as isCloseTo, q as atomicOr, qt as distance, r as subgroupAll, rn as floor, rt as scale4, s as subgroupBroadcast, sn as insertBits, st as allEq, t as extensionEnabled, tn as firstLeadingBit, tt as rotateY4, u as subgroupExclusiveAdd, un as length, ut as eq, v as subgroupShuffle, vn as pow, vt as or, w as textureGather, wn as round, wt as unpack2x16float, x as subgroupShuffleXor, xn as reflect, y as subgroupShuffleDown, yn as quantizeToF16, yt as select, z as fwidth, zt as cos } from "../extensions-DIVuAfBM.js";
|
|
4
|
+
|
|
5
|
+
//#region src/std/index.ts
|
|
6
|
+
var std_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
abs: () => abs,
|
|
8
|
+
acos: () => acos,
|
|
9
|
+
acosh: () => acosh,
|
|
10
|
+
add: () => add,
|
|
11
|
+
all: () => all,
|
|
12
|
+
allEq: () => allEq,
|
|
13
|
+
and: () => and,
|
|
14
|
+
any: () => any,
|
|
15
|
+
arrayLength: () => arrayLength,
|
|
16
|
+
asin: () => asin,
|
|
17
|
+
asinh: () => asinh,
|
|
18
|
+
atan: () => atan,
|
|
19
|
+
atan2: () => atan2,
|
|
20
|
+
atanh: () => atanh,
|
|
21
|
+
atomicAdd: () => atomicAdd,
|
|
22
|
+
atomicAnd: () => atomicAnd,
|
|
23
|
+
atomicLoad: () => atomicLoad,
|
|
24
|
+
atomicMax: () => atomicMax,
|
|
25
|
+
atomicMin: () => atomicMin,
|
|
26
|
+
atomicOr: () => atomicOr,
|
|
27
|
+
atomicStore: () => atomicStore,
|
|
28
|
+
atomicSub: () => atomicSub,
|
|
29
|
+
atomicXor: () => atomicXor,
|
|
30
|
+
bitcastU32toF32: () => bitcastU32toF32,
|
|
31
|
+
bitcastU32toI32: () => bitcastU32toI32,
|
|
32
|
+
ceil: () => ceil,
|
|
33
|
+
clamp: () => clamp,
|
|
34
|
+
cos: () => cos,
|
|
35
|
+
cosh: () => cosh,
|
|
36
|
+
countLeadingZeros: () => countLeadingZeros,
|
|
37
|
+
countOneBits: () => countOneBits,
|
|
38
|
+
countTrailingZeros: () => countTrailingZeros,
|
|
39
|
+
cross: () => cross,
|
|
40
|
+
degrees: () => degrees,
|
|
41
|
+
determinant: () => determinant,
|
|
42
|
+
discard: () => discard,
|
|
43
|
+
distance: () => distance,
|
|
44
|
+
div: () => div,
|
|
45
|
+
dot: () => dot,
|
|
46
|
+
dot4I8Packed: () => dot4I8Packed,
|
|
47
|
+
dot4U8Packed: () => dot4U8Packed,
|
|
48
|
+
dpdx: () => dpdx,
|
|
49
|
+
dpdxCoarse: () => dpdxCoarse,
|
|
50
|
+
dpdxFine: () => dpdxFine,
|
|
51
|
+
dpdy: () => dpdy,
|
|
52
|
+
dpdyCoarse: () => dpdyCoarse,
|
|
53
|
+
dpdyFine: () => dpdyFine,
|
|
54
|
+
eq: () => eq,
|
|
55
|
+
exp: () => exp,
|
|
56
|
+
exp2: () => exp2,
|
|
57
|
+
extensionEnabled: () => extensionEnabled,
|
|
58
|
+
extractBits: () => extractBits,
|
|
59
|
+
faceForward: () => faceForward,
|
|
60
|
+
firstLeadingBit: () => firstLeadingBit,
|
|
61
|
+
firstTrailingBit: () => firstTrailingBit,
|
|
62
|
+
floor: () => floor,
|
|
63
|
+
fma: () => fma,
|
|
64
|
+
fract: () => fract,
|
|
65
|
+
frexp: () => frexp,
|
|
66
|
+
fwidth: () => fwidth,
|
|
67
|
+
fwidthCoarse: () => fwidthCoarse,
|
|
68
|
+
fwidthFine: () => fwidthFine,
|
|
69
|
+
ge: () => ge,
|
|
70
|
+
gt: () => gt,
|
|
71
|
+
identity2: () => identity2,
|
|
72
|
+
identity3: () => identity3,
|
|
73
|
+
identity4: () => identity4,
|
|
74
|
+
insertBits: () => insertBits,
|
|
75
|
+
inverseSqrt: () => inverseSqrt,
|
|
76
|
+
isCloseTo: () => isCloseTo,
|
|
77
|
+
ldexp: () => ldexp,
|
|
78
|
+
le: () => le,
|
|
79
|
+
length: () => length,
|
|
80
|
+
log: () => log,
|
|
81
|
+
log2: () => log2,
|
|
82
|
+
lt: () => lt,
|
|
83
|
+
max: () => max,
|
|
84
|
+
min: () => min,
|
|
85
|
+
mix: () => mix,
|
|
86
|
+
mod: () => mod,
|
|
87
|
+
modf: () => modf,
|
|
88
|
+
mul: () => mul,
|
|
89
|
+
ne: () => ne,
|
|
90
|
+
neg: () => neg,
|
|
91
|
+
normalize: () => normalize,
|
|
92
|
+
not: () => not,
|
|
93
|
+
or: () => or,
|
|
94
|
+
pack2x16float: () => pack2x16float,
|
|
95
|
+
pack4x8unorm: () => pack4x8unorm,
|
|
96
|
+
pow: () => pow,
|
|
97
|
+
quantizeToF16: () => quantizeToF16,
|
|
98
|
+
radians: () => radians,
|
|
99
|
+
reflect: () => reflect,
|
|
100
|
+
refract: () => refract,
|
|
101
|
+
reverseBits: () => reverseBits,
|
|
102
|
+
rotateX4: () => rotateX4,
|
|
103
|
+
rotateY4: () => rotateY4,
|
|
104
|
+
rotateZ4: () => rotateZ4,
|
|
105
|
+
rotationX4: () => rotationX4,
|
|
106
|
+
rotationY4: () => rotationY4,
|
|
107
|
+
rotationZ4: () => rotationZ4,
|
|
108
|
+
round: () => round,
|
|
109
|
+
saturate: () => saturate,
|
|
110
|
+
scale4: () => scale4,
|
|
111
|
+
scaling4: () => scaling4,
|
|
112
|
+
select: () => select,
|
|
113
|
+
sign: () => sign,
|
|
114
|
+
sin: () => sin,
|
|
115
|
+
sinh: () => sinh,
|
|
116
|
+
smoothstep: () => smoothstep,
|
|
117
|
+
sqrt: () => sqrt,
|
|
118
|
+
step: () => step,
|
|
119
|
+
storageBarrier: () => storageBarrier,
|
|
120
|
+
sub: () => sub,
|
|
121
|
+
subgroupAdd: () => subgroupAdd,
|
|
122
|
+
subgroupAll: () => subgroupAll,
|
|
123
|
+
subgroupAnd: () => subgroupAnd,
|
|
124
|
+
subgroupAny: () => subgroupAny,
|
|
125
|
+
subgroupBallot: () => subgroupBallot,
|
|
126
|
+
subgroupBroadcast: () => subgroupBroadcast,
|
|
127
|
+
subgroupBroadcastFirst: () => subgroupBroadcastFirst,
|
|
128
|
+
subgroupElect: () => subgroupElect,
|
|
129
|
+
subgroupExclusiveAdd: () => subgroupExclusiveAdd,
|
|
130
|
+
subgroupExclusiveMul: () => subgroupExclusiveMul,
|
|
131
|
+
subgroupInclusiveAdd: () => subgroupInclusiveAdd,
|
|
132
|
+
subgroupInclusiveMul: () => subgroupInclusiveMul,
|
|
133
|
+
subgroupMax: () => subgroupMax,
|
|
134
|
+
subgroupMin: () => subgroupMin,
|
|
135
|
+
subgroupMul: () => subgroupMul,
|
|
136
|
+
subgroupOr: () => subgroupOr,
|
|
137
|
+
subgroupShuffle: () => subgroupShuffle,
|
|
138
|
+
subgroupShuffleDown: () => subgroupShuffleDown,
|
|
139
|
+
subgroupShuffleUp: () => subgroupShuffleUp,
|
|
140
|
+
subgroupShuffleXor: () => subgroupShuffleXor,
|
|
141
|
+
subgroupXor: () => subgroupXor,
|
|
142
|
+
tan: () => tan,
|
|
143
|
+
tanh: () => tanh,
|
|
144
|
+
textureBarrier: () => textureBarrier,
|
|
145
|
+
textureDimensions: () => textureDimensions,
|
|
146
|
+
textureGather: () => textureGather,
|
|
147
|
+
textureLoad: () => textureLoad,
|
|
148
|
+
textureSample: () => textureSample,
|
|
149
|
+
textureSampleBaseClampToEdge: () => textureSampleBaseClampToEdge,
|
|
150
|
+
textureSampleBias: () => textureSampleBias,
|
|
151
|
+
textureSampleCompare: () => textureSampleCompare,
|
|
152
|
+
textureSampleCompareLevel: () => textureSampleCompareLevel,
|
|
153
|
+
textureSampleLevel: () => textureSampleLevel,
|
|
154
|
+
textureStore: () => textureStore,
|
|
155
|
+
translate4: () => translate4,
|
|
156
|
+
translation4: () => translation4,
|
|
157
|
+
transpose: () => transpose,
|
|
158
|
+
trunc: () => trunc,
|
|
159
|
+
unpack2x16float: () => unpack2x16float,
|
|
160
|
+
unpack4x8unorm: () => unpack4x8unorm,
|
|
161
|
+
workgroupBarrier: () => workgroupBarrier
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
export { abs, acos, acosh, add, all, allEq, and, any, arrayLength, asin, asinh, atan, atan2, atanh, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, bitcastU32toF32, bitcastU32toI32, ceil, clamp, cos, cosh, countLeadingZeros, countOneBits, countTrailingZeros, cross, degrees, determinant, discard, distance, div, dot, dot4I8Packed, dot4U8Packed, dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, eq, exp, exp2, extensionEnabled, extractBits, faceForward, firstLeadingBit, firstTrailingBit, floor, fma, fract, frexp, fwidth, fwidthCoarse, fwidthFine, ge, gt, identity2, identity3, identity4, insertBits, inverseSqrt, isCloseTo, ldexp, le, length, log, log2, lt, max, min, mix, mod, modf, mul, ne, neg, normalize, not, or, pack2x16float, pack4x8unorm, pow, quantizeToF16, radians, reflect, refract, reverseBits, rotateX4, rotateY4, rotateZ4, rotationX4, rotationY4, rotationZ4, round, saturate, scale4, scaling4, select, sign, sin, sinh, smoothstep, sqrt, step, storageBarrier, sub, subgroupAdd, subgroupAll, subgroupAnd, subgroupAny, subgroupBallot, subgroupBroadcast, subgroupBroadcastFirst, subgroupElect, subgroupExclusiveAdd, subgroupExclusiveMul, subgroupInclusiveAdd, subgroupInclusiveMul, subgroupMax, subgroupMin, subgroupMul, subgroupOr, subgroupShuffle, subgroupShuffleDown, subgroupShuffleUp, subgroupShuffleXor, subgroupXor, std_exports as t, tan, tanh, textureBarrier, textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleLevel, textureStore, translate4, translation4, transpose, trunc, unpack2x16float, unpack4x8unorm, workgroupBarrier };
|
|
2
166
|
//# sourceMappingURL=index.js.map
|
package/std/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/std/discard.ts","../../src/std/matrix.ts","../../src/std/atomic.ts","../../src/std/derivative.ts","../../src/std/array.ts","../../src/std/texture.ts","../../src/std/subgroup.ts","../../src/std/extensions.ts"],"sourcesContent":["import { dualImpl } from '../core/function/dualImpl.ts';\nimport { Void } from '../data/wgslTypes.ts';\n\nexport const discard = dualImpl<() => never>({\n name: 'discard',\n normalImpl:\n '`discard` relies on GPU resources and cannot be executed outside of a draw call',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'discard;',\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n mat4x4f,\n rotationX4,\n rotationY4,\n rotationZ4,\n scaling4,\n translation4,\n} from '../data/matrix.ts';\nimport type { m4x4f, v3f } from '../data/wgslTypes.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { mul } from './operators.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { vec3f } from '../data/vector.ts';\nimport { f32 } from '../data/numeric.ts';\n\nconst cpuMul = mul[$internal].jsImpl;\n\nconst cpuTranslation4 = translation4[$internal].jsImpl;\nconst gpuTranslation4 = translation4[$internal].gpuImpl;\n\nconst cpuScaling4 = scaling4[$internal].jsImpl;\nconst gpuScaling4 = scaling4[$internal].gpuImpl;\n\nconst cpuRotationX4 = rotationX4[$internal].jsImpl;\nconst gpuRotationX4 = rotationX4[$internal].gpuImpl;\n\nconst cpuRotationY4 = rotationY4[$internal].jsImpl;\nconst gpuRotationY4 = rotationY4[$internal].gpuImpl;\n\nconst cpuRotationZ4 = rotationZ4[$internal].jsImpl;\nconst gpuRotationZ4 = rotationZ4[$internal].gpuImpl;\n\n/**\n * Translates the given 4-by-4 matrix by the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - The vector by which to translate the matrix.\n * @returns {m4x4f} The translated matrix.\n */\nexport const translate4 = dualImpl({\n name: 'translate4',\n normalImpl: (matrix: m4x4f, vector: v3f) =>\n cpuMul(cpuTranslation4(vector), matrix),\n signature: { argTypes: [mat4x4f, vec3f], returnType: mat4x4f },\n codegenImpl: (matrix, vector) =>\n stitch`(${gpuTranslation4(vector)} * ${matrix})`,\n});\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.\n * @returns {m4x4f} The scaled matrix.\n */\nexport const scale4 = dualImpl({\n name: 'scale4',\n normalImpl: (matrix: m4x4f, vector: v3f) =>\n cpuMul(cpuScaling4(vector), matrix),\n signature: { argTypes: [mat4x4f, vec3f], returnType: mat4x4f },\n codegenImpl: (matrix, vector) =>\n stitch`(${(gpuScaling4(vector))} * ${matrix})`,\n});\n\nconst rotateSignature = { argTypes: [mat4x4f, f32], returnType: mat4x4f };\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateX4 = dualImpl({\n name: 'rotateX4',\n normalImpl: (matrix: m4x4f, angle: number) =>\n cpuMul(cpuRotationX4(angle), matrix),\n signature: rotateSignature,\n codegenImpl: (matrix, angle) =>\n stitch`(${(gpuRotationX4(angle))} * ${matrix})`,\n});\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateY4 = dualImpl({\n name: 'rotateY4',\n normalImpl: (matrix: m4x4f, angle: number) =>\n cpuMul(cpuRotationY4(angle), matrix),\n signature: rotateSignature,\n codegenImpl: (matrix, angle) =>\n stitch`(${(gpuRotationY4(angle))} * ${matrix})`,\n});\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateZ4 = dualImpl({\n name: 'rotateZ4',\n normalImpl: (matrix: m4x4f, angle: number) =>\n cpuMul(cpuRotationZ4(angle), matrix),\n signature: rotateSignature,\n codegenImpl: (matrix, angle) =>\n stitch`(${(gpuRotationZ4(angle))} * ${matrix})`,\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport type { AnyData } from '../data/dataTypes.ts';\nimport { i32, u32 } from '../data/numeric.ts';\nimport { type atomicI32, type atomicU32, Void } from '../data/wgslTypes.ts';\nimport { safeStringify } from '../shared/stringify.ts';\ntype AnyAtomic = atomicI32 | atomicU32;\n\nexport const workgroupBarrier = dualImpl({\n name: 'workgroupBarrier',\n normalImpl: 'workgroupBarrier is a no-op outside of CODEGEN mode.',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'workgroupBarrier()',\n});\n\nexport const storageBarrier = dualImpl({\n name: 'storageBarrier',\n normalImpl: 'storageBarrier is a no-op outside of CODEGEN mode.',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'storageBarrier()',\n});\n\nexport const textureBarrier = dualImpl({\n name: 'textureBarrier',\n normalImpl: 'textureBarrier is a no-op outside of CODEGEN mode.',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'textureBarrier()',\n});\n\nconst atomicNormalError =\n 'Atomic operations are not supported outside of CODEGEN mode.';\n\nexport const atomicLoad = dualImpl<<T extends AnyAtomic>(a: T) => number>({\n name: 'atomicLoad',\n normalImpl: atomicNormalError,\n signature: (a) => {\n if (a.type !== 'atomic') {\n throw new Error(`Invalid atomic type: ${safeStringify(a)}`);\n }\n return { argTypes: [a], returnType: a.inner };\n },\n codegenImpl: (a) => stitch`atomicLoad(&${a})`,\n});\n\nconst atomicActionSignature = (a: AnyData, param: AnyData) => {\n if (a.type !== 'atomic') {\n throw new Error(`Invalid atomic type: ${safeStringify(a)}`);\n }\n return {\n argTypes: [a, a.inner.type === 'u32' ? u32 : i32],\n returnType: Void,\n };\n};\n\nconst atomicOpSignature = (a: AnyData, param: AnyData) => {\n if (a.type !== 'atomic') {\n throw new Error(`Invalid atomic type: ${safeStringify(a)}`);\n }\n const paramType = a.inner.type === 'u32' ? u32 : i32;\n return {\n argTypes: [a, paramType],\n returnType: paramType,\n };\n};\n\nexport const atomicStore = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => void\n>({\n name: 'atomicStore',\n normalImpl: atomicNormalError,\n signature: atomicActionSignature,\n codegenImpl: (a, value) => stitch`atomicStore(&${a}, ${value})`,\n});\n\nexport const atomicAdd = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicAdd',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicAdd(&${a}, ${value})`,\n});\n\nexport const atomicSub = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicSub',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicSub(&${a}, ${value})`,\n});\n\nexport const atomicMax = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicMax',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicMax(&${a}, ${value})`,\n});\n\nexport const atomicMin = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicMin',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicMin(&${a}, ${value})`,\n});\n\nexport const atomicAnd = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicAnd',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicAnd(&${a}, ${value})`,\n});\n\nexport const atomicOr = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicOr',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicOr(&${a}, ${value})`,\n});\n\nexport const atomicXor = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicXor',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicXor(&${a}, ${value})`,\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport type { AnyFloat32VecInstance } from '../data/wgslTypes.ts';\n\ntype DerivativeSignature =\n & ((value: number) => number)\n & (<T extends AnyFloat32VecInstance>(value: T) => T);\n\nconst derivativeNormalError = 'Derivative builtins are not allowed on the CPU';\n\nexport const dpdx = dualImpl<DerivativeSignature>({\n name: 'dpdx',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdx(${value})`,\n});\n\nexport const dpdxCoarse = dualImpl<DerivativeSignature>({\n name: 'dpdxCoarse',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdxCoarse(${value})`,\n});\n\nexport const dpdxFine = dualImpl<DerivativeSignature>({\n name: 'dpdxFine',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdxFine(${value})`,\n});\n\nexport const dpdy = dualImpl<DerivativeSignature>({\n name: 'dpdy',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdy(${value})`,\n});\n\nexport const dpdyCoarse = dualImpl<DerivativeSignature>({\n name: 'dpdyCoarse',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdyCoarse(${value})`,\n});\n\nexport const dpdyFine = dualImpl<DerivativeSignature>({\n name: 'dpdyFine',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdyFine(${value})`,\n});\n\nexport const fwidth = dualImpl<DerivativeSignature>({\n name: 'fwidth',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`fwidth(${value})`,\n});\n\nexport const fwidthCoarse = dualImpl<DerivativeSignature>({\n name: 'fwidthCoarse',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`fwidthCoarse(${value})`,\n});\n\nexport const fwidthFine = dualImpl<DerivativeSignature>({\n name: 'fwidthFine',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`fwidthFine(${value})`,\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { abstractInt, u32 } from '../data/numeric.ts';\nimport { ptrFn } from '../data/ptr.ts';\nimport { isRef, type ref } from '../data/ref.ts';\nimport { isPtr, isWgslArray, type StorableData } from '../data/wgslTypes.ts';\n\nconst sizeOfPointedToArray = (dataType: unknown) =>\n isPtr(dataType) && isWgslArray(dataType.inner)\n ? dataType.inner.elementCount\n : 0;\n\nexport const arrayLength = dualImpl({\n name: 'arrayLength',\n signature: (arg) => {\n const ptrArg = isPtr(arg) ? arg : ptrFn(arg as StorableData);\n return ({\n argTypes: [ptrArg],\n returnType: sizeOfPointedToArray(ptrArg) > 0 ? abstractInt : u32,\n });\n },\n normalImpl: (a: unknown[] | ref<unknown[]>) =>\n isRef(a) ? a.$.length : a.length,\n codegenImpl(a) {\n const length = sizeOfPointedToArray(a.dataType);\n return length > 0 ? String(length) : stitch`arrayLength(${a})`;\n },\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n isWgslTexture,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslTexture,\n} from '../data/texture.ts';\nimport type { TexelData } from '../core/texture/texture.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { f32, u32 } from '../data/numeric.ts';\nimport { vec2u, vec3u, vec4f, vec4i, vec4u } from '../data/vector.ts';\nimport {\n type v2f,\n type v2i,\n type v2u,\n type v3f,\n type v3i,\n type v3u,\n type v4f,\n type v4i,\n type v4u,\n Void,\n} from '../data/wgslTypes.ts';\nimport {\n getTextureFormatInfo,\n type StorageTextureFormats,\n type TextureFormats,\n} from '../core/texture/textureFormats.ts';\nimport type { $internal, $repr } from '../shared/symbols.ts';\nimport type {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n} from '../data/texture.ts';\n\nimport type { AnyData } from '../data/dataTypes.ts';\nimport type { comparisonSampler, sampler } from '../data/sampler.ts';\n\nfunction sampleCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n): v4f;\nfunction sampleCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n): v4f;\nfunction sampleCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n offset: v3i,\n): v4f;\nfunction sampleCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n): v4f;\nfunction sampleCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex?: number,\n): number;\nfunction sampleCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSample = dualImpl({\n name: 'textureSample',\n normalImpl: sampleCpu,\n codegenImpl: (...args) => stitch`textureSample(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args as AnyData[],\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\nfunction sampleBiasCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n bias: number,\n offset?: v3i,\n): v4f;\nfunction sampleBiasCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _biasOrArrayIndex: number,\n _biasOrOffset?: number | v2i | v3i,\n _maybeOffset?: v2i | v3i,\n): v4f {\n throw new Error(\n 'Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleBias = dualImpl({\n name: 'textureSampleBias',\n normalImpl: sampleBiasCpu,\n codegenImpl: (...args) => stitch`textureSampleBias(${args})`,\n signature: (...args) => ({\n argTypes: args as AnyData[],\n returnType: vec4f,\n }),\n});\n\nfunction sampleLevelCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n offset: v3i,\n): v4f;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _level: number,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleLevel = dualImpl({\n name: 'textureSampleLevel',\n normalImpl: sampleLevelCpu,\n codegenImpl: (...args) => stitch`textureSampleLevel(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args,\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\ntype PrimitiveToLoadedType = {\n f32: v4f;\n i32: v4i;\n u32: v4u;\n};\n\ntype TexelFormatToInstanceType<T extends StorageTextureFormats> =\n TextureFormats[T]['vectorType'][typeof $repr];\n\nfunction textureLoadCpu<T extends texture1d>(\n texture: T,\n coords: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2d>(\n texture: T,\n coords: v2i | v2u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture3d>(\n texture: T,\n coords: v3i | v3u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureMultisampled2d>(\n texture: T,\n coords: v2i | v2u,\n sampleIndex: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu(\n _texture: WgslTexture | WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _levelOrArrayIndex?: number,\n): TexelData {\n throw new Error(\n '`textureLoad` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureLoad = dualImpl({\n name: 'textureLoad',\n normalImpl: textureLoadCpu,\n codegenImpl: (...args) => stitch`textureLoad(${args})`,\n signature: (...args) => {\n const texture = args[0] as WgslTexture | WgslStorageTexture;\n if (isWgslTexture(texture)) {\n const isDepth = texture.type.startsWith('texture_depth');\n const sampleType = texture.sampleType;\n return {\n argTypes: args,\n returnType: isDepth\n ? f32\n : sampleType.type === 'f32'\n ? vec4f\n : sampleType.type === 'u32'\n ? vec4u\n : vec4i,\n };\n }\n const format = texture.format;\n const dataType = getTextureFormatInfo(format).vectorType;\n return {\n argTypes: args,\n returnType: dataType,\n };\n },\n});\n\nfunction textureStoreCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu(\n _texture: WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _arrayIndexOrValue?: number | TexelData,\n _maybeValue?: TexelData,\n): void {\n throw new Error(\n '`textureStore` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureStore = dualImpl({\n name: 'textureStore',\n normalImpl: textureStoreCpu,\n codegenImpl: (...args) => stitch`textureStore(${args})`,\n signature: (...args) => ({ argTypes: args, returnType: Void }),\n});\n\nfunction textureDimensionsCpu<T extends texture1d | textureStorage1d>(\n texture: T,\n): number;\nfunction textureDimensionsCpu<T extends texture1d>(\n texture: T,\n level: number,\n): number;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray\n | textureStorage2d\n | textureStorage2dArray\n | textureExternal,\n>(texture: T): v2u;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray,\n>(texture: T, level: number): v2u;\nfunction textureDimensionsCpu<T extends texture3d | textureStorage3d>(\n texture: T,\n): v3u;\nfunction textureDimensionsCpu<T extends texture3d>(\n texture: T,\n level: number,\n): v3u;\nfunction textureDimensionsCpu(\n _texture: WgslTexture | WgslStorageTexture | WgslExternalTexture,\n _level?: number,\n): number | v2u | v3u {\n throw new Error(\n '`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureDimensions = dualImpl({\n name: 'textureDimensions',\n normalImpl: textureDimensionsCpu,\n codegenImpl: (...args) => stitch`textureDimensions(${args})`,\n signature: (...args) => {\n const dim = (\n args[0] as WgslTexture | WgslStorageTexture | WgslExternalTexture\n ).dimension;\n if (dim === '1d') {\n return {\n argTypes: args,\n returnType: u32,\n };\n }\n if (dim === '3d') {\n return {\n argTypes: args,\n returnType: vec3u,\n };\n }\n return {\n argTypes: args,\n returnType: vec2u,\n };\n },\n});\n\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepthCube>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureCubeArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu(\n _texture: WgslTexture,\n _sampler: comparisonSampler,\n _coords: v2f | v3f,\n _depthRefOrArrayIndex: number,\n _depthRefOrOffset?: number | v2i,\n _maybeOffset?: v2i,\n): number {\n throw new Error(\n 'Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleCompare = dualImpl({\n name: 'textureSampleCompare',\n normalImpl: textureSampleCompareCpu,\n codegenImpl: (...args) => stitch`textureSampleCompare(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: f32,\n }),\n});\n\nfunction textureSampleBaseClampToEdgeCpu<\n T extends texture2d | textureExternal,\n>(texture: T, sampler: sampler, coords: v2f): v4f {\n throw new Error(\n 'Texture sampling with base clamp to edge is not supported outside of GPU mode.',\n );\n}\n\nexport const textureSampleBaseClampToEdge = dualImpl({\n name: 'textureSampleBaseClampToEdge',\n normalImpl: textureSampleBaseClampToEdgeCpu,\n codegenImpl: (...args) => stitch`textureSampleBaseClampToEdge(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: vec4f,\n }),\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { bool, i32, u32 } from '../data/numeric.ts';\nimport { vec4u } from '../data/vector.ts';\nimport type {\n AnyIntegerVecInstance,\n AnyNumericVecInstance,\n AnyWgslData,\n v4u,\n} from '../data/wgslTypes.ts';\nimport { unify } from '../tgsl/conversion.ts';\n\ninterface IdentityNumOrVec {\n (e: number): number;\n <T extends AnyNumericVecInstance>(e: T): T;\n}\n\ninterface IdentityIntNumOrVec {\n (e: number): number;\n <T extends AnyIntegerVecInstance>(e: T): T;\n}\n\ninterface IdentityNumOrVecWithIdx {\n (e: number, index: number): number;\n <T extends AnyNumericVecInstance>(e: T, index: number): T;\n}\n\ninterface IdentityNumOrVecWithDelta {\n (e: number, delta: number): number;\n <T extends AnyNumericVecInstance>(e: T, delta: number): T;\n}\n\ninterface IdentityNumOrVecWithMask {\n (e: number, mask: number): number;\n <T extends AnyNumericVecInstance>(e: T, mask: number): T;\n}\n\nconst errorMessage = 'Subgroup operations can only be used in the GPU context.';\n\nexport const subgroupAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupAdd(${arg})`,\n});\n\nexport const subgroupExclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveAdd(${arg})`,\n});\n\nexport const subgroupInclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveAdd(${arg})`,\n});\n\nexport const subgroupAll = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAll',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAll(${e})`,\n});\n\nexport const subgroupAnd = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupAnd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAnd(${e})`,\n});\n\nexport const subgroupAny = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAny',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAny(${e})`,\n});\n\nexport const subgroupBallot = dualImpl<(e: boolean) => v4u>({\n name: 'subgroupBallot',\n signature: { argTypes: [bool], returnType: vec4u },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBallot(${e})`,\n});\n\nexport const subgroupBroadcast = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupBroadcast',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupBroadcast(${e}, ${index})`,\n});\n\nexport const subgroupBroadcastFirst = dualImpl<IdentityNumOrVec>({\n name: 'subgroupBroadcastFirst',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBroadcastFirst(${e})`,\n});\n\nexport const subgroupElect = dualImpl<() => boolean>({\n name: 'subgroupElect',\n signature: { argTypes: [], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: () => stitch`subgroupElect()`,\n});\n\nexport const subgroupMax = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMax',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMax(${arg})`,\n});\n\nexport const subgroupMin = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMin',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMin(${arg})`,\n});\n\nexport const subgroupMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMul(${arg})`,\n});\n\nexport const subgroupExclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveMul(${arg})`,\n});\n\nexport const subgroupInclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveMul(${arg})`,\n});\n\nexport const subgroupOr = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupOr',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupOr(${e})`,\n});\n\nexport const subgroupShuffle = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupShuffle',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupShuffle(${e}, ${index})`,\n});\n\nexport const subgroupShuffleDown = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleDown',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleDown's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleDown(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleUp = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleUp',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleUp's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleUp(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleXor = dualImpl<IdentityNumOrVecWithMask>({\n name: 'subgroupShuffleXor',\n signature: (...args) => {\n const mask = unify([args[1]] as [AnyWgslData], [u32]);\n if (!mask) {\n throw new Error(\n `subgroupShuffleXor's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], mask[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, mask) => stitch`subgroupShuffleXor(${e}, ${mask})`,\n});\n\nexport const subgroupXor = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupXor',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupXor(${e})`,\n});\n","import { comptime } from '../core/function/comptime.ts';\nimport { getResolutionCtx } from '../execMode.ts';\nimport { type WgslExtension, wgslExtensions } from '../wgslExtensions.ts';\n\nexport const extensionEnabled = comptime(\n (extensionName: WgslExtension): boolean => {\n const resolutionCtx = getResolutionCtx();\n if (!resolutionCtx) {\n throw new Error(\n \"Functions using `extensionEnabled` cannot be called directly. Either generate WGSL from them, or use tgpu['~unstable'].simulate(...)\",\n );\n }\n\n if (\n typeof extensionName !== 'string' ||\n !(wgslExtensions.includes(extensionName as WgslExtension))\n ) {\n throw new Error(\n `extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: '${extensionName}'`,\n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C,EAAGgB,EAAM,CAAC,CAAC,EAAG,WAAYhB,EAAK,CAAC,CAAE,CAC9D,EACA,WAAYd,EACZ,YAAa,CAAC,EAAG8B,IAAU1B,sBAA2B,CAAC,KAAK0B,CAAK,GACnE,CAAC,EAEYE,GAAqB9B,EAAmC,CACnE,KAAM,qBACN,UAAW,IAAIY,IAAS,CACtB,IAAMmB,EAAOjB,EAAM,CAACF,EAAK,CAAC,CAAC,EAAoB,CAACI,CAAG,CAAC,EACpD,GAAI,CAACe,EACH,MAAM,IAAI,MACR,4EACEnB,EAAK,CAAC,EAAE,IACV,EACF,EAEF,MAAO,CAAE,SAAU,CAACA,EAAK,CAAC,EAAGmB,EAAK,CAAC,CAAC,EAAG,WAAYnB,EAAK,CAAC,CAAE,CAC7D,EACA,WAAYd,EACZ,YAAa,CAAC,EAAGiC,IAAS7B,uBAA4B,CAAC,KAAK6B,CAAI,GAClE,CAAC,EAEYC,GAAchC,EAA8B,CACvD,KAAM,cACN,UAAYC,IAAS,CAAE,SAAU,CAACA,CAAG,EAAG,WAAYA,CAAI,GACxD,WAAYH,EACZ,YAAc,GAAMI,gBAAqB,CAAC,GAC5C,CAAC,ECtOM,IAAM+B,GAAmBC,EAC7BC,GAA0C,CACzC,IAAMC,EAAgBC,EAAiB,EACvC,GAAI,CAACD,EACH,MAAM,IAAI,MACR,sIACF,EAGF,GACE,OAAOD,GAAkB,UACzB,CAAEG,EAAe,SAASH,CAA8B,EAExD,MAAM,IAAI,MACR,2GAA2GA,CAAa,GAC1H,EAGF,OAAQC,EAAc,kBAAoB,CAAC,GAAG,SAASD,CAAa,CACtE,CACF","names":["discard","dualImpl","Void","cpuMul","mul","$internal","cpuTranslation4","translation4","gpuTranslation4","cpuScaling4","scaling4","gpuScaling4","cpuRotationX4","rotationX4","gpuRotationX4","cpuRotationY4","rotationY4","gpuRotationY4","cpuRotationZ4","rotationZ4","gpuRotationZ4","translate4","dualImpl","matrix","vector","mat4x4f","vec3f","stitch","scale4","rotateSignature","f32","rotateX4","angle","rotateY4","rotateZ4","workgroupBarrier","dualImpl","Void","storageBarrier","textureBarrier","atomicNormalError","atomicLoad","a","safeStringify","stitch","atomicActionSignature","param","u32","i32","atomicOpSignature","paramType","atomicStore","value","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","derivativeNormalError","dpdx","dualImpl","value","stitch","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","sizeOfPointedToArray","dataType","isPtr","isWgslArray","arrayLength","dualImpl","arg","ptrArg","ptrFn","abstractInt","u32","a","isRef","length","stitch","sampleCpu","_texture","_sampler","_coords","_offsetOrArrayIndex","_maybeOffset","textureSample","dualImpl","args","stitch","isDepth","f32","vec4f","sampleBiasCpu","_biasOrArrayIndex","_biasOrOffset","textureSampleBias","sampleLevelCpu","_level","textureSampleLevel","textureLoadCpu","_levelOrArrayIndex","textureLoad","texture","isWgslTexture","sampleType","vec4u","vec4i","format","dataType","getTextureFormatInfo","textureStoreCpu","_arrayIndexOrValue","_maybeValue","textureStore","Void","textureDimensionsCpu","textureDimensions","dim","u32","vec3u","vec2u","textureSampleCompareCpu","_depthRefOrArrayIndex","_depthRefOrOffset","textureSampleCompare","textureSampleBaseClampToEdgeCpu","sampler","coords","textureSampleBaseClampToEdge","errorMessage","subgroupAdd","dualImpl","arg","stitch","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","bool","subgroupAnd","subgroupAny","subgroupBallot","vec4u","subgroupBroadcast","args","id","unify","i32","u32","index","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","delta","subgroupShuffleUp","subgroupShuffleXor","mask","subgroupXor","extensionEnabled","comptime","extensionName","resolutionCtx","getResolutionCtx","wgslExtensions"]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/std/index.ts"],"sourcesContent":["/**\n * @module typegpu/std\n */\n\n// NOTE: This is a barrel file, internal files should not import things from this file\n\nexport { discard } from './discard.ts';\n\nexport {\n abs,\n acos,\n acosh,\n asin,\n asinh,\n atan,\n atan2,\n atanh,\n ceil,\n clamp,\n cos,\n cosh,\n countLeadingZeros,\n countOneBits,\n countTrailingZeros,\n cross,\n degrees,\n determinant,\n distance,\n dot,\n dot4I8Packed,\n dot4U8Packed,\n exp,\n exp2,\n extractBits,\n faceForward,\n firstLeadingBit,\n firstTrailingBit,\n floor,\n fma,\n fract,\n frexp,\n insertBits,\n inverseSqrt,\n ldexp,\n length,\n log,\n log2,\n max,\n min,\n mix,\n modf,\n normalize,\n pow,\n quantizeToF16,\n radians,\n reflect,\n refract,\n reverseBits,\n round,\n saturate,\n sign,\n sin,\n sinh,\n smoothstep,\n sqrt,\n step,\n tan,\n tanh,\n transpose,\n trunc,\n} from './numeric.ts';\n\nexport { add, div, mod, mul, neg, sub } from './operators.ts';\n\n// deno-fmt-ingore\nexport { rotateX4, rotateY4, rotateZ4, scale4, translate4 } from './matrix.ts';\n\n// deno-fmt-ingore\nexport {\n identity2,\n identity3,\n identity4,\n rotationX4,\n rotationY4,\n rotationZ4,\n scaling4,\n translation4,\n} from '../data/matrix.ts';\n\n// deno-fmt-ignore\nexport {\n // comparison\n allEq,\n eq,\n ne,\n lt,\n le,\n gt,\n ge,\n // logical ops\n not,\n or,\n and,\n // logical aggregation\n all,\n any,\n // other\n isCloseTo,\n select,\n} from './boolean.ts';\n\n// deno-fmt-ignore\nexport {\n atomicAdd,\n atomicAnd,\n atomicLoad,\n atomicMax,\n atomicMin,\n atomicOr,\n atomicStore,\n atomicSub,\n atomicXor,\n // synchronization\n workgroupBarrier,\n storageBarrier,\n textureBarrier,\n} from './atomic.ts';\n\nexport {\n dpdx,\n dpdxCoarse,\n dpdxFine,\n dpdy,\n dpdyCoarse,\n dpdyFine,\n fwidth,\n fwidthCoarse,\n fwidthFine,\n} from './derivative.ts';\n\nexport { arrayLength } from './array.ts';\n\n// deno-fmt-ignore\nexport {\n pack4x8unorm,\n pack2x16float,\n unpack4x8unorm,\n unpack2x16float,\n} from './packing.ts';\n\nexport {\n textureDimensions,\n textureGather,\n textureLoad,\n textureSample,\n textureSampleBaseClampToEdge,\n textureSampleBias,\n textureSampleCompare,\n textureSampleCompareLevel,\n textureSampleLevel,\n textureStore,\n} from './texture.ts';\n\nexport {\n subgroupAdd,\n subgroupAll,\n subgroupAnd,\n subgroupAny,\n subgroupBallot,\n subgroupBroadcast,\n subgroupBroadcastFirst,\n subgroupElect,\n subgroupExclusiveAdd,\n subgroupExclusiveMul,\n subgroupInclusiveAdd,\n subgroupInclusiveMul,\n subgroupMax,\n subgroupMin,\n subgroupMul,\n subgroupOr,\n subgroupShuffle,\n subgroupShuffleDown,\n subgroupShuffleUp,\n subgroupShuffleXor,\n subgroupXor,\n} from './subgroup.ts';\n\nexport { extensionEnabled } from './extensions.ts';\n\nexport { bitcastU32toF32, bitcastU32toI32 } from './bitcast.ts';\n"],"mappings":""}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { cr as $internal, dr as $repr, it as f32 } from "./operators-d-PMVTo7.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data/texture.ts
|
|
4
|
+
function textureDescriptorToSchema(desc) {
|
|
5
|
+
if ("multisampled" in desc) {
|
|
6
|
+
if (desc.multisampled) {
|
|
7
|
+
if (desc.dimension === "2d") return textureMultisampled2d(desc.sampleType);
|
|
8
|
+
throw new Error(`Multisampled textures only support '2d' dimension, got '${desc.dimension}'`);
|
|
9
|
+
}
|
|
10
|
+
switch (desc.dimension) {
|
|
11
|
+
case "1d": return texture1d(desc.sampleType);
|
|
12
|
+
case "2d": return texture2d(desc.sampleType);
|
|
13
|
+
case "2d-array": return texture2dArray(desc.sampleType);
|
|
14
|
+
case "3d": return texture3d(desc.sampleType);
|
|
15
|
+
case "cube": return textureCube(desc.sampleType);
|
|
16
|
+
case "cube-array": return textureCubeArray(desc.sampleType);
|
|
17
|
+
default: throw new Error(`Unsupported texture dimension: '${desc.dimension}'`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (!("access" in desc)) throw new Error("Descriptor is neither a sampled nor a storage texture");
|
|
21
|
+
switch (desc.dimension) {
|
|
22
|
+
case "1d": return textureStorage1d(desc.format, desc.access);
|
|
23
|
+
case "2d": return textureStorage2d(desc.format, desc.access);
|
|
24
|
+
case "2d-array": return textureStorage2dArray(desc.format, desc.access);
|
|
25
|
+
case "3d": return textureStorage3d(desc.format, desc.access);
|
|
26
|
+
default: throw new Error(`Unsupported storage texture dimension: '${desc.dimension}'`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function createTexture(type, props) {
|
|
30
|
+
const sampleTypes = type.startsWith("texture_depth") ? [
|
|
31
|
+
"depth",
|
|
32
|
+
"float",
|
|
33
|
+
"unfilterable-float"
|
|
34
|
+
] : props.sampleType.type === "i32" ? ["sint"] : props.sampleType.type === "u32" ? ["uint"] : ["float", "unfilterable-float"];
|
|
35
|
+
return {
|
|
36
|
+
[$internal]: {},
|
|
37
|
+
[$repr]: void 0,
|
|
38
|
+
type,
|
|
39
|
+
bindingSampleType: sampleTypes,
|
|
40
|
+
...props
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function createStorageTexture(type, props) {
|
|
44
|
+
return {
|
|
45
|
+
[$internal]: {},
|
|
46
|
+
[$repr]: void 0,
|
|
47
|
+
type,
|
|
48
|
+
...props
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const textureCache = /* @__PURE__ */ new Map();
|
|
52
|
+
const accessModeMap = {
|
|
53
|
+
"write-only": "write",
|
|
54
|
+
"read-only": "read",
|
|
55
|
+
"read-write": "read_write"
|
|
56
|
+
};
|
|
57
|
+
function getOrCreate(key, factory) {
|
|
58
|
+
let cached = textureCache.get(key);
|
|
59
|
+
if (!cached) {
|
|
60
|
+
cached = factory();
|
|
61
|
+
textureCache.set(key, cached);
|
|
62
|
+
}
|
|
63
|
+
return cached;
|
|
64
|
+
}
|
|
65
|
+
function texture1d(sampleType) {
|
|
66
|
+
const actualSampleType = sampleType || f32;
|
|
67
|
+
return getOrCreate(`texture_1d<${actualSampleType.type}>`, () => createTexture("texture_1d", {
|
|
68
|
+
dimension: "1d",
|
|
69
|
+
sampleType: actualSampleType,
|
|
70
|
+
multisampled: false
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
function texture2d(sampleType) {
|
|
74
|
+
const actualSampleType = sampleType || f32;
|
|
75
|
+
return getOrCreate(`texture_2d<${actualSampleType.type}>`, () => createTexture("texture_2d", {
|
|
76
|
+
dimension: "2d",
|
|
77
|
+
sampleType: actualSampleType,
|
|
78
|
+
multisampled: false
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
function textureMultisampled2d(sampleType) {
|
|
82
|
+
const actualSampleType = sampleType || f32;
|
|
83
|
+
return getOrCreate(`texture_multisampled_2d<${actualSampleType.type}>`, () => createTexture("texture_multisampled_2d", {
|
|
84
|
+
dimension: "2d",
|
|
85
|
+
sampleType: actualSampleType,
|
|
86
|
+
multisampled: true
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
function texture2dArray(sampleType) {
|
|
90
|
+
const actualSampleType = sampleType || f32;
|
|
91
|
+
return getOrCreate(`texture_2d_array<${actualSampleType.type}>`, () => createTexture("texture_2d_array", {
|
|
92
|
+
dimension: "2d-array",
|
|
93
|
+
sampleType: actualSampleType,
|
|
94
|
+
multisampled: false
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
function textureCube(sampleType) {
|
|
98
|
+
const actualSampleType = sampleType || f32;
|
|
99
|
+
return getOrCreate(`texture_cube<${actualSampleType.type}>`, () => createTexture("texture_cube", {
|
|
100
|
+
dimension: "cube",
|
|
101
|
+
sampleType: actualSampleType,
|
|
102
|
+
multisampled: false
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
function textureCubeArray(sampleType) {
|
|
106
|
+
const actualSampleType = sampleType || f32;
|
|
107
|
+
return getOrCreate(`texture_cube_array<${actualSampleType.type}>`, () => createTexture("texture_cube_array", {
|
|
108
|
+
dimension: "cube-array",
|
|
109
|
+
sampleType: actualSampleType,
|
|
110
|
+
multisampled: false
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
function texture3d(sampleType) {
|
|
114
|
+
const actualSampleType = sampleType || f32;
|
|
115
|
+
return getOrCreate(`texture_3d<${actualSampleType.type}>`, () => createTexture("texture_3d", {
|
|
116
|
+
dimension: "3d",
|
|
117
|
+
sampleType: actualSampleType,
|
|
118
|
+
multisampled: false
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
function textureStorage1d(format, access) {
|
|
122
|
+
const actualAccess = access || "write-only";
|
|
123
|
+
return getOrCreate(`texture_storage_1d<${format}, ${accessModeMap[actualAccess]}>`, () => createStorageTexture("texture_storage_1d", {
|
|
124
|
+
dimension: "1d",
|
|
125
|
+
format,
|
|
126
|
+
access: actualAccess
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
function textureStorage2d(format, access) {
|
|
130
|
+
const actualAccess = access || "write-only";
|
|
131
|
+
return getOrCreate(`texture_storage_2d<${format}, ${accessModeMap[actualAccess]}>`, () => createStorageTexture("texture_storage_2d", {
|
|
132
|
+
dimension: "2d",
|
|
133
|
+
format,
|
|
134
|
+
access: actualAccess
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
function textureStorage2dArray(format, access) {
|
|
138
|
+
const actualAccess = access || "write-only";
|
|
139
|
+
return getOrCreate(`texture_storage_2d_array<${format}, ${accessModeMap[actualAccess]}>`, () => createStorageTexture("texture_storage_2d_array", {
|
|
140
|
+
dimension: "2d-array",
|
|
141
|
+
format,
|
|
142
|
+
access: actualAccess
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
function textureStorage3d(format, access) {
|
|
146
|
+
const actualAccess = access || "write-only";
|
|
147
|
+
return getOrCreate(`texture_storage_3d<${format}, ${accessModeMap[actualAccess]}>`, () => createStorageTexture("texture_storage_3d", {
|
|
148
|
+
dimension: "3d",
|
|
149
|
+
format,
|
|
150
|
+
access: actualAccess
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
function textureDepth2d() {
|
|
154
|
+
return getOrCreate("texture_depth_2d", () => createTexture("texture_depth_2d", {
|
|
155
|
+
dimension: "2d",
|
|
156
|
+
sampleType: f32,
|
|
157
|
+
multisampled: false
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
function textureDepthMultisampled2d() {
|
|
161
|
+
return getOrCreate("texture_depth_multisampled_2d", () => createTexture("texture_depth_multisampled_2d", {
|
|
162
|
+
dimension: "2d",
|
|
163
|
+
sampleType: f32,
|
|
164
|
+
multisampled: true
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
function textureDepth2dArray() {
|
|
168
|
+
return getOrCreate("texture_depth_2d_array", () => createTexture("texture_depth_2d_array", {
|
|
169
|
+
dimension: "2d-array",
|
|
170
|
+
sampleType: f32,
|
|
171
|
+
multisampled: false
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
function textureDepthCube() {
|
|
175
|
+
return getOrCreate("texture_depth_cube", () => createTexture("texture_depth_cube", {
|
|
176
|
+
dimension: "cube",
|
|
177
|
+
sampleType: f32,
|
|
178
|
+
multisampled: false
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
function textureDepthCubeArray() {
|
|
182
|
+
return getOrCreate("texture_depth_cube_array", () => createTexture("texture_depth_cube_array", {
|
|
183
|
+
dimension: "cube-array",
|
|
184
|
+
sampleType: f32,
|
|
185
|
+
multisampled: false
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
function textureExternal() {
|
|
189
|
+
return getOrCreate("texture_external", () => ({
|
|
190
|
+
[$internal]: {},
|
|
191
|
+
[$repr]: void 0,
|
|
192
|
+
type: "texture_external",
|
|
193
|
+
dimension: "2d"
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
function isWgslTexture(value) {
|
|
197
|
+
return !!value[$internal] && typeof value.multisampled === "boolean";
|
|
198
|
+
}
|
|
199
|
+
function isWgslStorageTexture(value) {
|
|
200
|
+
return !!value[$internal] && typeof value.format === "string" && typeof value.access === "string";
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
export { textureMultisampled2d as _, texture2d as a, textureStorage2dArray as b, textureCube as c, textureDepth2dArray as d, textureDepthCube as f, textureExternal as g, textureDescriptorToSchema as h, texture1d as i, textureCubeArray as l, textureDepthMultisampled2d as m, isWgslStorageTexture as n, texture2dArray as o, textureDepthCubeArray as p, isWgslTexture as r, texture3d as s, accessModeMap as t, textureDepth2d as u, textureStorage1d as v, textureStorage3d as x, textureStorage2d as y };
|
|
205
|
+
//# sourceMappingURL=texture-BagDrrks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texture-BagDrrks.js","names":[],"sources":["../src/data/texture.ts"],"sourcesContent":["import type { StorageTextureFormats } from '../core/texture/textureFormats.ts';\nimport { $internal, $repr } from '../shared/symbols.ts';\nimport type { Default, WithDefaults } from '../shared/utilityTypes.ts';\nimport { f32 } from './numeric.ts';\nimport type { F32 } from './wgslTypes.ts';\nimport type { BaseData, TextureSampleTypes } from './wgslTypes.ts';\n\nexport type StorageTextureDimension = '1d' | '2d' | '2d-array' | '3d';\n\nexport type WgslTextureProps = {\n dimension: GPUTextureViewDimension;\n sampleType: TextureSampleTypes;\n multisampled: boolean;\n};\n\nexport type WgslStorageTextureProps = {\n dimension: StorageTextureDimension;\n format: StorageTextureFormats;\n access: GPUStorageTextureAccess;\n};\n\ntype ResolvedTextureProps<\n TProps extends Partial<WgslTextureProps>,\n> = WithDefaults<TProps, WgslTextureProps>;\n\ntype ResolvedStorageTextureProps<\n TProps extends Partial<WgslStorageTextureProps>,\n> = WithDefaults<TProps, WgslStorageTextureProps>;\n\ntype SampledTextureLiteral = `texture_${\n | '1d'\n | '2d'\n | '2d_array'\n | '3d'\n | 'cube'\n | 'cube_array'\n | 'multisampled_2d'\n | 'depth_multisampled_2d'\n | 'depth_2d'\n | 'depth_2d_array'\n | 'depth_cube'\n | 'depth_cube_array'}`;\ntype StorageTextureLiteral = `texture_storage_${\n | '1d'\n | '2d'\n | '2d_array'\n | '3d'}`;\n\nexport interface WgslTexture<\n TProps extends Partial<WgslTextureProps> = WgslTextureProps,\n> extends BaseData {\n readonly [$repr]: unknown;\n readonly type: SampledTextureLiteral;\n\n readonly sampleType: ResolvedTextureProps<TProps>['sampleType'];\n readonly dimension: ResolvedTextureProps<TProps>['dimension'];\n readonly multisampled: ResolvedTextureProps<TProps>['multisampled'];\n readonly bindingSampleType: [GPUTextureSampleType, ...GPUTextureSampleType[]];\n}\n\nexport interface WgslStorageTexture<\n TProps extends Partial<WgslStorageTextureProps> = WgslStorageTextureProps,\n> extends BaseData {\n readonly [$repr]: unknown;\n readonly type: StorageTextureLiteral;\n\n readonly format: ResolvedStorageTextureProps<TProps>['format'];\n readonly dimension: ResolvedStorageTextureProps<TProps>['dimension'];\n readonly access: ResolvedStorageTextureProps<TProps>['access'];\n}\n\nexport interface WgslExternalTexture extends BaseData {\n readonly [$repr]: textureExternal;\n readonly type: 'texture_external';\n\n readonly dimension: '2d';\n}\n\nexport interface WgslTexture1d<\n TSample extends TextureSampleTypes = TextureSampleTypes,\n> extends\n WgslTexture<{\n dimension: '1d';\n sampleType: TSample;\n multisampled: false;\n }> {\n readonly type: 'texture_1d';\n readonly [$repr]: texture1d<TSample>;\n}\n\nexport interface WgslTexture2d<\n TSample extends TextureSampleTypes = TextureSampleTypes,\n> extends\n WgslTexture<{\n dimension: '2d';\n sampleType: TSample;\n multisampled: false;\n }> {\n readonly type: 'texture_2d';\n readonly [$repr]: texture2d<TSample>;\n}\n\nexport interface WgslTextureMultisampled2d<\n TSample extends TextureSampleTypes = TextureSampleTypes,\n> extends\n WgslTexture<{\n dimension: '2d';\n sampleType: TSample;\n multisampled: true;\n }> {\n readonly type: 'texture_multisampled_2d';\n readonly [$repr]: textureMultisampled2d<TSample>;\n}\n\nexport interface WgslTexture2dArray<\n TSample extends TextureSampleTypes = TextureSampleTypes,\n> extends\n WgslTexture<{\n dimension: '2d-array';\n sampleType: TSample;\n multisampled: false;\n }> {\n readonly type: 'texture_2d_array';\n readonly [$repr]: texture2dArray<TSample>;\n}\n\nexport interface WgslTextureCube<\n TSample extends TextureSampleTypes = TextureSampleTypes,\n> extends\n WgslTexture<{\n dimension: 'cube';\n sampleType: TSample;\n multisampled: false;\n }> {\n readonly type: 'texture_cube';\n readonly [$repr]: textureCube<TSample>;\n}\n\nexport interface WgslTextureCubeArray<\n TSample extends TextureSampleTypes = TextureSampleTypes,\n> extends\n WgslTexture<{\n dimension: 'cube-array';\n sampleType: TSample;\n multisampled: false;\n }> {\n readonly type: 'texture_cube_array';\n readonly [$repr]: textureCubeArray<TSample>;\n}\n\nexport interface WgslTexture3d<\n TSample extends TextureSampleTypes = TextureSampleTypes,\n> extends\n WgslTexture<{\n dimension: '3d';\n sampleType: TSample;\n multisampled: false;\n }> {\n readonly type: 'texture_3d';\n readonly [$repr]: texture3d<TSample>;\n}\n\n// Depth textures (sample type is always f32)\nexport interface WgslTextureDepth2d extends\n WgslTexture<{\n dimension: '2d';\n sampleType: F32;\n multisampled: false;\n }> {\n readonly type: 'texture_depth_2d';\n readonly [$repr]: textureDepth2d;\n}\n\nexport interface WgslTextureDepthMultisampled2d extends\n WgslTexture<{\n dimension: '2d';\n sampleType: F32;\n multisampled: true;\n }> {\n readonly type: 'texture_depth_multisampled_2d';\n readonly [$repr]: textureDepthMultisampled2d;\n}\n\nexport interface WgslTextureDepth2dArray extends\n WgslTexture<{\n dimension: '2d-array';\n sampleType: F32;\n multisampled: false;\n }> {\n readonly type: 'texture_depth_2d_array';\n readonly [$repr]: textureDepth2dArray;\n}\n\nexport interface WgslTextureDepthCube extends\n WgslTexture<{\n dimension: 'cube';\n sampleType: F32;\n multisampled: false;\n }> {\n readonly type: 'texture_depth_cube';\n readonly [$repr]: textureDepthCube;\n}\n\nexport interface WgslTextureDepthCubeArray extends\n WgslTexture<{\n dimension: 'cube-array';\n sampleType: F32;\n multisampled: false;\n }> {\n readonly type: 'texture_depth_cube_array';\n readonly [$repr]: textureDepthCubeArray;\n}\n\n// Storage textures\nexport interface WgslStorageTexture1d<\n TFormat extends StorageTextureFormats = StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess,\n> extends\n WgslStorageTexture<{\n dimension: '1d';\n format: TFormat;\n access: TAccess;\n }> {\n readonly type: 'texture_storage_1d';\n readonly [$repr]: textureStorage1d<TFormat, TAccess>;\n}\n\nexport interface WgslStorageTexture2d<\n TFormat extends StorageTextureFormats = StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess,\n> extends\n WgslStorageTexture<{\n dimension: '2d';\n format: TFormat;\n access: TAccess;\n }> {\n readonly type: 'texture_storage_2d';\n readonly [$repr]: textureStorage2d<TFormat, TAccess>;\n}\n\nexport interface WgslStorageTexture2dArray<\n TFormat extends StorageTextureFormats = StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess,\n> extends\n WgslStorageTexture<{\n dimension: '2d-array';\n format: TFormat;\n access: TAccess;\n }> {\n readonly type: 'texture_storage_2d_array';\n readonly [$repr]: textureStorage2dArray<TFormat, TAccess>;\n}\n\nexport interface WgslStorageTexture3d<\n TFormat extends StorageTextureFormats = StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess,\n> extends\n WgslStorageTexture<{\n dimension: '3d';\n format: TFormat;\n access: TAccess;\n }> {\n readonly type: 'texture_storage_3d';\n readonly [$repr]: textureStorage3d<TFormat, TAccess>;\n}\n\ntype SampledTextureSchemaMap<T extends WgslTextureProps> = {\n multisampled: {\n '1d': never;\n '2d': WgslTextureMultisampled2d<T['sampleType']>;\n '2d-array': never;\n '3d': never;\n cube: never;\n 'cube-array': never;\n };\n sampled: {\n '1d': WgslTexture1d<T['sampleType']>;\n '2d': WgslTexture2d<T['sampleType']>;\n '2d-array': WgslTexture2dArray<T['sampleType']>;\n '3d': WgslTexture3d<T['sampleType']>;\n cube: WgslTextureCube<T['sampleType']>;\n 'cube-array': WgslTextureCubeArray<T['sampleType']>;\n };\n};\n\ntype StorageTextureSchemaMap<T extends WgslStorageTextureProps> = {\n '1d': WgslStorageTexture1d<T['format'], T['access']>;\n '2d': WgslStorageTexture2d<T['format'], T['access']>;\n '2d-array': WgslStorageTexture2dArray<T['format'], T['access']>;\n '3d': WgslStorageTexture3d<T['format'], T['access']>;\n};\n\nexport type TextureSchemaForDescriptor<\n T extends WgslTextureProps | WgslStorageTextureProps,\n> = T extends WgslTextureProps\n ? T['multisampled'] extends true\n ? SampledTextureSchemaMap<T>['multisampled'][T['dimension']]\n : SampledTextureSchemaMap<T>['sampled'][T['dimension']]\n : T extends WgslStorageTextureProps\n ? StorageTextureSchemaMap<T>[T['dimension']]\n : never;\n\nexport function textureDescriptorToSchema<\n T extends WgslTextureProps | WgslStorageTextureProps,\n>(desc: T): TextureSchemaForDescriptor<T> {\n if ('multisampled' in desc) {\n if (desc.multisampled) {\n if (desc.dimension === '2d') {\n return textureMultisampled2d(\n desc.sampleType,\n ) as TextureSchemaForDescriptor<T>;\n }\n throw new Error(\n `Multisampled textures only support '2d' dimension, got '${desc.dimension}'`,\n );\n }\n\n switch (desc.dimension) {\n case '1d':\n return texture1d(desc.sampleType) as TextureSchemaForDescriptor<T>;\n case '2d':\n return texture2d(desc.sampleType) as TextureSchemaForDescriptor<T>;\n case '2d-array':\n return texture2dArray(\n desc.sampleType,\n ) as TextureSchemaForDescriptor<T>;\n case '3d':\n return texture3d(desc.sampleType) as TextureSchemaForDescriptor<T>;\n case 'cube':\n return textureCube(\n desc.sampleType,\n ) as TextureSchemaForDescriptor<T>;\n case 'cube-array':\n return textureCubeArray(\n desc.sampleType,\n ) as TextureSchemaForDescriptor<T>;\n default:\n throw new Error(\n // @ts-expect-error\n `Unsupported texture dimension: '${desc.dimension}'`,\n );\n }\n }\n if (!('access' in desc)) {\n throw new Error('Descriptor is neither a sampled nor a storage texture');\n }\n\n switch (desc.dimension) {\n case '1d':\n return textureStorage1d(\n desc.format,\n desc.access,\n ) as TextureSchemaForDescriptor<T>;\n case '2d':\n return textureStorage2d(\n desc.format,\n desc.access,\n ) as TextureSchemaForDescriptor<T>;\n case '2d-array':\n return textureStorage2dArray(\n desc.format,\n desc.access,\n ) as TextureSchemaForDescriptor<T>;\n case '3d':\n return textureStorage3d(\n desc.format,\n desc.access,\n ) as TextureSchemaForDescriptor<T>;\n default:\n throw new Error(\n // @ts-expect-error\n `Unsupported storage texture dimension: '${desc.dimension}'`,\n );\n }\n}\n\nfunction createTexture<TProps extends WgslTextureProps>(\n type: SampledTextureLiteral,\n props: TProps,\n): WgslTexture<TProps> {\n const isDepth = type.startsWith('texture_depth');\n const sampleTypes: [GPUTextureSampleType, ...GPUTextureSampleType[]] = isDepth\n ? ['depth', 'float', 'unfilterable-float']\n : props.sampleType.type === 'i32'\n ? ['sint']\n : props.sampleType.type === 'u32'\n ? ['uint']\n : ['float', 'unfilterable-float'];\n\n return {\n [$internal]: {},\n [$repr]: undefined as unknown as WgslTexture<TProps>,\n type,\n bindingSampleType: sampleTypes,\n ...props,\n };\n}\n\nfunction createStorageTexture<TProps extends WgslStorageTextureProps>(\n type: StorageTextureLiteral,\n props: TProps,\n): WgslStorageTexture<TProps> {\n return {\n [$internal]: {},\n [$repr]: undefined as unknown as WgslStorageTexture<TProps>,\n type,\n ...props,\n };\n}\n\nconst textureCache = new Map<\n string,\n WgslTexture | WgslStorageTexture | WgslExternalTexture\n>();\n\nexport const accessModeMap: Record<GPUStorageTextureAccess, string> = {\n 'write-only': 'write',\n 'read-only': 'read',\n 'read-write': 'read_write',\n};\n\nfunction getOrCreate<\n T extends WgslTexture | WgslStorageTexture | WgslExternalTexture,\n>(key: string, factory: () => T): T {\n let cached = textureCache.get(key) as T | undefined;\n if (!cached) {\n cached = factory();\n textureCache.set(key, cached);\n }\n return cached;\n}\n\nexport interface texture1d<T extends TextureSampleTypes = TextureSampleTypes> {\n readonly kind: `texture_1d<${T['type']}>`;\n [$internal]: T;\n}\n\nexport function texture1d<T extends TextureSampleTypes>(\n sampleType: T,\n): WgslTexture1d<T>;\nexport function texture1d(): WgslTexture1d<F32>;\nexport function texture1d<T extends TextureSampleTypes>(sampleType?: T) {\n const actualSampleType = (sampleType || f32) as Default<T, F32>;\n const key = `texture_1d<${actualSampleType.type}>`;\n return getOrCreate(key, () =>\n createTexture('texture_1d', {\n dimension: '1d',\n sampleType: actualSampleType,\n multisampled: false,\n }));\n}\n\nexport interface texture2d<T extends TextureSampleTypes = TextureSampleTypes> {\n readonly kind: `texture_2d<${T['type']}>`;\n [$internal]: T;\n}\n\nexport function texture2d<T extends TextureSampleTypes>(\n sampleType: T,\n): WgslTexture2d<T>;\nexport function texture2d(): WgslTexture2d<F32>;\nexport function texture2d<T extends TextureSampleTypes>(sampleType?: T) {\n const actualSampleType = (sampleType || f32) as Default<T, F32>;\n const key = `texture_2d<${actualSampleType.type}>`;\n return getOrCreate(key, () =>\n createTexture('texture_2d', {\n dimension: '2d',\n sampleType: actualSampleType,\n multisampled: false,\n }));\n}\n\nexport interface textureMultisampled2d<\n T extends TextureSampleTypes = TextureSampleTypes,\n> {\n readonly kind: `texture_multisampled_2d<${T['type']}>`;\n [$internal]: T;\n}\n\nexport function textureMultisampled2d<T extends TextureSampleTypes>(\n sampleType: T,\n): WgslTextureMultisampled2d<T>;\nexport function textureMultisampled2d(): WgslTextureMultisampled2d<F32>;\nexport function textureMultisampled2d<T extends TextureSampleTypes>(\n sampleType?: T,\n) {\n const actualSampleType = (sampleType || f32) as Default<T, F32>;\n const key = `texture_multisampled_2d<${actualSampleType.type}>`;\n return getOrCreate(key, () =>\n createTexture('texture_multisampled_2d', {\n dimension: '2d',\n sampleType: actualSampleType,\n multisampled: true,\n }));\n}\n\nexport interface texture2dArray<\n T extends TextureSampleTypes = TextureSampleTypes,\n> {\n readonly kind: `texture_2d_array<${T['type']}>`;\n [$internal]: T;\n}\n\nexport function texture2dArray<T extends TextureSampleTypes>(\n sampleType: T,\n): WgslTexture2dArray<T>;\nexport function texture2dArray(): WgslTexture2dArray<F32>;\nexport function texture2dArray<T extends TextureSampleTypes>(sampleType?: T) {\n const actualSampleType = (sampleType || f32) as Default<T, F32>;\n const key = `texture_2d_array<${actualSampleType.type}>`;\n return getOrCreate(key, () =>\n createTexture('texture_2d_array', {\n dimension: '2d-array',\n sampleType: actualSampleType,\n multisampled: false,\n }));\n}\n\nexport interface textureCube<\n T extends TextureSampleTypes = TextureSampleTypes,\n> {\n readonly kind: `texture_cube<${T['type']}>`;\n [$internal]: T;\n}\n\nexport function textureCube<T extends TextureSampleTypes>(\n sampleType: T,\n): WgslTextureCube<T>;\nexport function textureCube(): WgslTextureCube<F32>;\nexport function textureCube<T extends TextureSampleTypes>(sampleType?: T) {\n const actualSampleType = (sampleType || f32) as Default<T, F32>;\n const key = `texture_cube<${actualSampleType.type}>`;\n return getOrCreate(key, () =>\n createTexture('texture_cube', {\n dimension: 'cube',\n sampleType: actualSampleType,\n multisampled: false,\n }));\n}\n\nexport interface textureCubeArray<\n T extends TextureSampleTypes = TextureSampleTypes,\n> {\n readonly kind: `texture_cube_array<${T['type']}>`;\n [$internal]: T;\n}\n\nexport function textureCubeArray<T extends TextureSampleTypes>(\n sampleType: T,\n): WgslTextureCubeArray<T>;\nexport function textureCubeArray(): WgslTextureCubeArray<F32>;\nexport function textureCubeArray<T extends TextureSampleTypes>(\n sampleType?: T,\n) {\n const actualSampleType = (sampleType || f32) as Default<T, F32>;\n const key = `texture_cube_array<${actualSampleType.type}>`;\n return getOrCreate(key, () =>\n createTexture('texture_cube_array', {\n dimension: 'cube-array',\n sampleType: actualSampleType,\n multisampled: false,\n }));\n}\n\nexport interface texture3d<T extends TextureSampleTypes = TextureSampleTypes> {\n readonly kind: `texture_3d<${T['type']}>`;\n [$internal]: T;\n}\n\nexport function texture3d<T extends TextureSampleTypes>(\n sampleType: T,\n): WgslTexture3d<T>;\nexport function texture3d(): WgslTexture3d<F32>;\nexport function texture3d<T extends TextureSampleTypes>(sampleType?: T) {\n const actualSampleType = (sampleType || f32) as Default<T, F32>;\n const key = `texture_3d<${actualSampleType.type}>`;\n return getOrCreate(key, () =>\n createTexture('texture_3d', {\n dimension: '3d',\n sampleType: actualSampleType,\n multisampled: false,\n }));\n}\n\nexport interface textureStorage1d<\n TFormat extends StorageTextureFormats = StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess,\n> {\n readonly kind: `texture_storage_1d<${TFormat}, ${TAccess}>`;\n [$internal]: [TFormat, TAccess];\n}\n\nexport function textureStorage1d<\n TFormat extends StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess,\n>(format: TFormat, access: TAccess): WgslStorageTexture1d<TFormat, TAccess>;\nexport function textureStorage1d<TFormat extends StorageTextureFormats>(\n format: TFormat,\n): WgslStorageTexture1d<TFormat, 'write-only'>;\nexport function textureStorage1d<\n TFormat extends StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess,\n>(format: TFormat, access?: TAccess) {\n const actualAccess = (access || 'write-only') as Default<\n TAccess,\n 'write-only'\n >;\n const key = `texture_storage_1d<${format}, ${accessModeMap[actualAccess]}>`;\n return getOrCreate(key, () =>\n createStorageTexture('texture_storage_1d', {\n dimension: '1d',\n format,\n access: actualAccess,\n }));\n}\n\nexport interface textureStorage2d<\n TFormat extends StorageTextureFormats = StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess,\n> {\n readonly kind: `texture_storage_2d<${TFormat}, ${TAccess}>`;\n [$internal]: [TFormat, TAccess];\n}\n\nexport function textureStorage2d<\n TFormat extends StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess,\n>(format: TFormat, access: TAccess): WgslStorageTexture2d<TFormat, TAccess>;\nexport function textureStorage2d<TFormat extends StorageTextureFormats>(\n format: TFormat,\n): WgslStorageTexture2d<TFormat, 'write-only'>;\nexport function textureStorage2d<\n TFormat extends StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess,\n>(format: TFormat, access?: TAccess) {\n const actualAccess = (access || 'write-only') as Default<\n TAccess,\n 'write-only'\n >;\n const key = `texture_storage_2d<${format}, ${accessModeMap[actualAccess]}>`;\n return getOrCreate(key, () =>\n createStorageTexture('texture_storage_2d', {\n dimension: '2d',\n format,\n access: actualAccess,\n }));\n}\n\nexport interface textureStorage2dArray<\n TFormat extends StorageTextureFormats = StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess,\n> {\n readonly kind: `texture_storage_2d_array<${TFormat}, ${TAccess}>`;\n [$internal]: [TFormat, TAccess];\n}\n\nexport function textureStorage2dArray<\n TFormat extends StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess,\n>(\n format: TFormat,\n access: TAccess,\n): WgslStorageTexture2dArray<TFormat, TAccess>;\nexport function textureStorage2dArray<TFormat extends StorageTextureFormats>(\n format: TFormat,\n): WgslStorageTexture2dArray<TFormat, 'write-only'>;\nexport function textureStorage2dArray<\n TFormat extends StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess,\n>(format: TFormat, access?: TAccess) {\n const actualAccess = (access || 'write-only') as Default<\n TAccess,\n 'write-only'\n >;\n const key = `texture_storage_2d_array<${format}, ${\n accessModeMap[actualAccess]\n }>`;\n return getOrCreate(\n key,\n () =>\n createStorageTexture('texture_storage_2d_array', {\n dimension: '2d-array',\n format,\n access: actualAccess,\n }),\n );\n}\n\nexport interface textureStorage3d<\n TFormat extends StorageTextureFormats = StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess,\n> {\n readonly kind: `texture_storage_3d<${TFormat}, ${TAccess}>`;\n [$internal]: [TFormat, TAccess];\n}\n\nexport function textureStorage3d<\n TFormat extends StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess,\n>(format: TFormat, access: TAccess): WgslStorageTexture3d<TFormat, TAccess>;\nexport function textureStorage3d<TFormat extends StorageTextureFormats>(\n format: TFormat,\n): WgslStorageTexture3d<TFormat, 'write-only'>;\nexport function textureStorage3d<\n TFormat extends StorageTextureFormats,\n TAccess extends GPUStorageTextureAccess,\n>(format: TFormat, access?: TAccess) {\n const actualAccess = (access || 'write-only') as Default<\n TAccess,\n 'write-only'\n >;\n const key = `texture_storage_3d<${format}, ${accessModeMap[actualAccess]}>`;\n return getOrCreate(key, () =>\n createStorageTexture('texture_storage_3d', {\n dimension: '3d',\n format,\n access: actualAccess,\n }));\n}\n\nexport interface textureDepth2d {\n readonly kind: 'texture_depth_2d';\n [$internal]: F32;\n}\n\nexport function textureDepth2d() {\n const key = 'texture_depth_2d';\n return getOrCreate(key, () =>\n createTexture('texture_depth_2d', {\n dimension: '2d',\n sampleType: f32,\n multisampled: false,\n })) as WgslTextureDepth2d;\n}\n\nexport interface textureDepthMultisampled2d {\n readonly kind: 'texture_depth_multisampled_2d';\n [$internal]: F32;\n}\n\nexport function textureDepthMultisampled2d() {\n const key = 'texture_depth_multisampled_2d';\n return getOrCreate(key, () =>\n createTexture('texture_depth_multisampled_2d', {\n dimension: '2d',\n sampleType: f32,\n multisampled: true,\n })) as WgslTextureDepthMultisampled2d;\n}\n\nexport interface textureDepth2dArray {\n readonly kind: 'texture_depth_2d_array';\n [$internal]: F32;\n}\n\nexport function textureDepth2dArray() {\n const key = 'texture_depth_2d_array';\n return getOrCreate(key, () =>\n createTexture('texture_depth_2d_array', {\n dimension: '2d-array',\n sampleType: f32,\n multisampled: false,\n })) as WgslTextureDepth2dArray;\n}\n\nexport interface textureDepthCube {\n readonly kind: 'texture_depth_cube';\n [$internal]: F32;\n}\n\nexport function textureDepthCube() {\n const key = 'texture_depth_cube';\n return getOrCreate(key, () =>\n createTexture('texture_depth_cube', {\n dimension: 'cube',\n sampleType: f32,\n multisampled: false,\n })) as WgslTextureDepthCube;\n}\n\nexport interface textureDepthCubeArray {\n readonly kind: 'texture_depth_cube_array';\n [$internal]: F32;\n}\n\nexport function textureDepthCubeArray() {\n const key = 'texture_depth_cube_array';\n return getOrCreate(key, () =>\n createTexture('texture_depth_cube_array', {\n dimension: 'cube-array',\n sampleType: f32,\n multisampled: false,\n })) as WgslTextureDepthCubeArray;\n}\n\nexport interface textureExternal {\n readonly kind: 'texture_external';\n [$internal]: true;\n}\n\nexport function textureExternal() {\n const key = 'texture_external';\n return getOrCreate(key, () => ({\n [$internal]: {},\n [$repr]: undefined as unknown as textureExternal,\n type: 'texture_external',\n dimension: '2d',\n })) as WgslExternalTexture;\n}\n\nexport function isWgslTexture(value: unknown): value is WgslTexture {\n return (\n !!(value as WgslTexture)[$internal] &&\n typeof (value as WgslTexture).multisampled === 'boolean'\n );\n}\n\nexport function isWgslStorageTexture(\n value: unknown,\n): value is WgslStorageTexture {\n return (\n !!(value as WgslStorageTexture)[$internal] &&\n typeof (value as WgslStorageTexture).format === 'string' &&\n typeof (value as WgslStorageTexture).access === 'string'\n );\n}\n\nexport function isWgslExternalTexture(\n value: unknown,\n): value is WgslExternalTexture {\n return (\n !!(value as WgslExternalTexture)[$internal] &&\n (value as WgslExternalTexture).type === 'texture_external'\n );\n}\n"],"mappings":";;;AA8SA,SAAgB,0BAEd,MAAwC;AACxC,KAAI,kBAAkB,MAAM;AAC1B,MAAI,KAAK,cAAc;AACrB,OAAI,KAAK,cAAc,KACrB,QAAO,sBACL,KAAK,WACN;AAEH,SAAM,IAAI,MACR,2DAA2D,KAAK,UAAU,GAC3E;;AAGH,UAAQ,KAAK,WAAb;GACE,KAAK,KACH,QAAO,UAAU,KAAK,WAAW;GACnC,KAAK,KACH,QAAO,UAAU,KAAK,WAAW;GACnC,KAAK,WACH,QAAO,eACL,KAAK,WACN;GACH,KAAK,KACH,QAAO,UAAU,KAAK,WAAW;GACnC,KAAK,OACH,QAAO,YACL,KAAK,WACN;GACH,KAAK,aACH,QAAO,iBACL,KAA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