@zephyr3d/device 0.2.1 → 0.2.3

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.
@@ -21,11 +21,12 @@ const COMPRESSED_FORMAT_SHIFT = 24;
21
21
  const COMPRESSION_FORMAT_BC1 = 1 << COMPRESSED_FORMAT_SHIFT;
22
22
  const COMPRESSION_FORMAT_BC2 = 2 << COMPRESSED_FORMAT_SHIFT;
23
23
  const COMPRESSION_FORMAT_BC3 = 3 << COMPRESSED_FORMAT_SHIFT;
24
+ const COMPRESSION_FORMAT_BC4 = 4 << COMPRESSED_FORMAT_SHIFT;
25
+ const COMPRESSION_FORMAT_BC5 = 5 << COMPRESSED_FORMAT_SHIFT;
26
+ const COMPRESSION_FORMAT_BC6H = 6 << COMPRESSED_FORMAT_SHIFT;
27
+ const COMPRESSION_FORMAT_BC7 = 7 << COMPRESSED_FORMAT_SHIFT;
28
+ const COMPRESSION_FORMAT_ASTC = 8 << COMPRESSED_FORMAT_SHIFT;
24
29
  /*
25
- const COMPRESSION_FORMAT_BC4 = 4 << COMPRESSED_FORMAT_SHIFT;
26
- const COMPRESSION_FORMAT_BC5 = 5 << COMPRESSED_FORMAT_SHIFT;
27
- const COMPRESSION_FORMAT_BC6 = 6 << COMPRESSED_FORMAT_SHIFT;
28
- const COMPRESSION_FORMAT_BC7 = 7 << COMPRESSED_FORMAT_SHIFT;
29
30
  const COMPRESSION_FORMAT_ETC2_RGB8 = 8 << COMPRESSED_FORMAT_SHIFT;
30
31
  const COMPRESSION_FORMAT_ETC2_RGB8_A1 = 9 << COMPRESSED_FORMAT_SHIFT;
31
32
  const COMPRESSION_FORMAT_ETC2_RGBA8 = 10 << COMPRESSED_FORMAT_SHIFT;
@@ -114,7 +115,43 @@ const textureFormatMap = {
114
115
  dxt3: makeTextureFormat(COMPRESSION_FORMAT_BC2, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 16),
115
116
  'dxt3-srgb': makeTextureFormat(COMPRESSION_FORMAT_BC2, true, true, true, true, false, false, false, false, false, true, false, 4, 4, 16),
116
117
  dxt5: makeTextureFormat(COMPRESSION_FORMAT_BC3, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 16),
117
- 'dxt5-srgb': makeTextureFormat(COMPRESSION_FORMAT_BC3, true, true, true, true, false, false, false, false, false, true, false, 4, 4, 16)
118
+ 'dxt5-srgb': makeTextureFormat(COMPRESSION_FORMAT_BC3, true, true, true, true, false, false, false, false, false, true, false, 4, 4, 16),
119
+ bc4: makeTextureFormat(COMPRESSION_FORMAT_BC4, true, false, false, false, false, false, false, false, false, false, false, 4, 4, 8),
120
+ 'bc4-signed': makeTextureFormat(COMPRESSION_FORMAT_BC4, true, false, false, false, false, false, false, false, true, false, false, 4, 4, 8),
121
+ bc5: makeTextureFormat(COMPRESSION_FORMAT_BC5, true, true, false, false, false, false, false, false, false, false, false, 4, 4, 16),
122
+ 'bc5-signed': makeTextureFormat(COMPRESSION_FORMAT_BC5, true, true, false, false, false, false, false, false, true, false, false, 4, 4, 16),
123
+ bc6h: makeTextureFormat(COMPRESSION_FORMAT_BC6H, true, true, true, false, false, false, true, false, false, false, false, 4, 4, 16),
124
+ 'bc6h-signed': makeTextureFormat(COMPRESSION_FORMAT_BC6H, true, true, true, false, false, false, true, false, true, false, false, 4, 4, 16),
125
+ bc7: makeTextureFormat(COMPRESSION_FORMAT_BC7, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 16),
126
+ 'bc7-srgb': makeTextureFormat(COMPRESSION_FORMAT_BC7, true, true, true, true, false, false, false, false, false, true, false, 4, 4, 16),
127
+ 'astc-4x4': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 16),
128
+ 'astc-4x4-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 4, 4, 16),
129
+ 'astc-5x4': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 5, 4, 16),
130
+ 'astc-5x4-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 5, 4, 16),
131
+ 'astc-5x5': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 5, 5, 16),
132
+ 'astc-5x5-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 5, 5, 16),
133
+ 'astc-6x5': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 6, 5, 16),
134
+ 'astc-6x5-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 6, 5, 16),
135
+ 'astc-6x6': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 6, 6, 16),
136
+ 'astc-6x6-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 6, 6, 16),
137
+ 'astc-8x5': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 8, 5, 16),
138
+ 'astc-8x5-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 8, 5, 16),
139
+ 'astc-8x6': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 8, 6, 16),
140
+ 'astc-8x6-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 8, 6, 16),
141
+ 'astc-8x8': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 8, 8, 16),
142
+ 'astc-8x8-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 8, 8, 16),
143
+ 'astc-10x5': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 10, 5, 16),
144
+ 'astc-10x5-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 10, 5, 16),
145
+ 'astc-10x6': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 10, 6, 16),
146
+ 'astc-10x6-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 10, 6, 16),
147
+ 'astc-10x8': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 10, 8, 16),
148
+ 'astc-10x8-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 10, 8, 16),
149
+ 'astc-10x10': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 10, 10, 16),
150
+ 'astc-10x10-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 10, 10, 16),
151
+ 'astc-12x10': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 12, 10, 16),
152
+ 'astc-12x10-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 12, 10, 16),
153
+ 'astc-12x12': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, false, false, 12, 12, 16),
154
+ 'astc-12x12-srgb': makeTextureFormat(COMPRESSION_FORMAT_ASTC, true, true, true, true, false, false, false, false, false, true, false, 12, 12, 16)
118
155
  };
119
156
  /**
120
157
  * Converts a non-sRGB texture format to the corresponding sRGB texture format
@@ -133,6 +170,36 @@ const textureFormatMap = {
133
170
  return 'dxt3-srgb';
134
171
  case 'dxt5':
135
172
  return 'dxt5-srgb';
173
+ case 'bc7':
174
+ return 'bc7-srgb';
175
+ case 'astc-4x4':
176
+ return 'astc-4x4-srgb';
177
+ case 'astc-5x4':
178
+ return 'astc-5x4-srgb';
179
+ case 'astc-5x5':
180
+ return 'astc-5x5-srgb';
181
+ case 'astc-6x5':
182
+ return 'astc-6x5-srgb';
183
+ case 'astc-6x6':
184
+ return 'astc-6x6-srgb';
185
+ case 'astc-8x5':
186
+ return 'astc-8x5-srgb';
187
+ case 'astc-8x6':
188
+ return 'astc-8x6-srgb';
189
+ case 'astc-8x8':
190
+ return 'astc-8x8-srgb';
191
+ case 'astc-10x5':
192
+ return 'astc-10x5-srgb';
193
+ case 'astc-10x6':
194
+ return 'astc-10x6-srgb';
195
+ case 'astc-10x8':
196
+ return 'astc-10x8-srgb';
197
+ case 'astc-10x10':
198
+ return 'astc-10x10-srgb';
199
+ case 'astc-12x10':
200
+ return 'astc-12x10-srgb';
201
+ case 'astc-12x12':
202
+ return 'astc-12x12-srgb';
136
203
  default:
137
204
  return format;
138
205
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base_types.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base_types.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -532,7 +532,7 @@ function unbracket(e) {
532
532
  }
533
533
  isWritable() {
534
534
  const type = this.getType();
535
- return this.writable || type.isAtomicI32() || type.isAtomicU32() || type.isStructType() && type.isWritable();
535
+ return this.writable || type.isAtomicI32() || type.isAtomicU32() || type.isStructType() && type.haveAtomicMembers();
536
536
  }
537
537
  getAddressSpace() {
538
538
  switch(this.value.$declareType){
@@ -1759,13 +1759,11 @@ function unbracket(e) {
1759
1759
  // prefix = `@location(${this.value.value.$location}) var<out> `;
1760
1760
  throw new Error(`Internal error`);
1761
1761
  case DeclareType.DECLARE_TYPE_UNIFORM:
1762
- if (this.group === undefined) {
1763
- debugger;
1764
- }
1765
1762
  prefix = `@group(${this.group}) @binding(${this.binding}) var${isBlock ? '<uniform>' : ''} `;
1766
1763
  break;
1767
1764
  case DeclareType.DECLARE_TYPE_STORAGE:
1768
- prefix = `@group(${this.group}) @binding(${this.binding}) var<storage, ${this.value.isWritable() ? 'read_write' : 'read'}> `;
1765
+ prefix = `@group(${this.group}) @binding(${this.binding}) var<storage, ${this.value.value.$readonly ? 'read' : 'read_write' //this.value.isWritable() || this.value.getType().haveAtomicMembers() ? 'read_write' : 'read'
1766
+ }> `;
1769
1767
  break;
1770
1768
  case DeclareType.DECLARE_TYPE_WORKGROUP:
1771
1769
  prefix = `var<workgroup> `;
@@ -1 +1 @@
1
- {"version":3,"file":"ast.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -23,7 +23,7 @@ const constructorCache = new Map();
23
23
  }
24
24
  let ctor = entries[prop];
25
25
  if (!ctor) {
26
- if (elementType.isPrimitiveType() || elementType.isStructType() || elementType.isArrayType()) {
26
+ if (elementType.isPrimitiveType() || elementType.isStructType() || elementType.isArrayType() || elementType.isAtomicI32() || elementType.isAtomicU32()) {
27
27
  if (prop === 'ptr') {
28
28
  const pointerType = new PBPointerTypeInfo(elementType, PBAddressSpace.FUNCTION);
29
29
  ctor = function pointerCtor(...args) {
@@ -99,6 +99,8 @@ let uidExp = 0;
99
99
  /** @internal */ $_group;
100
100
  /** @internal */ $declareType;
101
101
  /** @internal */ $isBuffer;
102
+ /** @internal */ $readonly;
103
+ /** @internal */ $bindingSize;
102
104
  /** @internal */ constructor(str, typeInfo){
103
105
  super();
104
106
  if (!str && typeInfo.isPointerType()) {
@@ -119,6 +121,8 @@ let uidExp = 0;
119
121
  this.$_group = null;
120
122
  this.$declareType = DeclareType.DECLARE_TYPE_NONE;
121
123
  this.$isBuffer = false;
124
+ this.$bindingSize = 0;
125
+ this.$readonly = false;
122
126
  if (typeInfo.isTextureType()) {
123
127
  if (typeInfo.isDepthTexture()) {
124
128
  this.$sampleType = 'depth';
@@ -157,13 +161,14 @@ let uidExp = 0;
157
161
  * Point out that the variable should be an uniform buffer
158
162
  * @param group - The bind group index
159
163
  * @returns self
160
- */ uniformBuffer(group) {
164
+ */ uniformBuffer(group, bindingSize = 0) {
161
165
  if (!this.$typeinfo.isPrimitiveType() && !this.$typeinfo.isArrayType() && !this.$typeinfo.isStructType()) {
162
166
  throw new PBASTError(this.$ast, 'only primitive type, array type or structure type can be set as uniform buffer');
163
167
  }
164
168
  this.$declareType = DeclareType.DECLARE_TYPE_UNIFORM;
165
169
  this.$group = group;
166
170
  this.$isBuffer = true;
171
+ this.$bindingSize = bindingSize;
167
172
  return this;
168
173
  }
169
174
  /**
@@ -188,19 +193,40 @@ let uidExp = 0;
188
193
  this.$declareType = DeclareType.DECLARE_TYPE_STORAGE;
189
194
  this.$group = group;
190
195
  this.$isBuffer = false;
196
+ this.$readonly = false;
197
+ return this;
198
+ }
199
+ /**
200
+ * Point out that the variable is read-only and should be in storage address space
201
+ * @param group - The bind group index
202
+ * @returns self
203
+ */ storageReadonly(group) {
204
+ this.storage(group);
205
+ this.$readonly = true;
191
206
  return this;
192
207
  }
193
208
  /**
194
209
  * Point out that the variable should be a storage buffer
195
210
  * @param group - The bind group index
196
211
  * @returns self
197
- */ storageBuffer(group) {
198
- if (!this.$typeinfo.isPrimitiveType() && !this.$typeinfo.isArrayType() && !this.$typeinfo.isStructType()) {
212
+ */ storageBuffer(group, bindingSize = 0) {
213
+ if (!this.$typeinfo.isPrimitiveType() && !this.$typeinfo.isArrayType() && !this.$typeinfo.isStructType() && !this.$typeinfo.isAtomicI32() && !this.$typeinfo.isAtomicU32()) {
199
214
  throw new PBASTError(this.$ast, 'only primitive type, array type or structure type can be set as storage buffer');
200
215
  }
201
216
  this.$declareType = DeclareType.DECLARE_TYPE_STORAGE;
202
217
  this.$group = group;
203
218
  this.$isBuffer = true;
219
+ this.$bindingSize = bindingSize;
220
+ this.$readonly = false;
221
+ return this;
222
+ }
223
+ /**
224
+ * Point out that the variable is read-only and should be a storage buffer
225
+ * @param group - The bind group index
226
+ * @returns self
227
+ */ storageBufferReadonly(group, bindingSize = 0) {
228
+ this.storageBuffer(group, bindingSize);
229
+ this.$readonly = true;
204
230
  return this;
205
231
  }
206
232
  inout() {
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
- import { PBPrimitiveType, typeU32, typeF32, typeAtomicI32, typeI32, typeAtomicU32, typeVoid, PBFunctionTypeInfo, typeF32Vec2, typeF32Vec3, typeF32Vec4, typeI32Vec2, typeI32Vec3, typeI32Vec4, typeU32Vec2, typeU32Vec3, typeU32Vec4, typeMat2, typeMat3x2, typeMat4x2, typeMat2x3, typeMat3, typeMat4x3, typeMat2x4, typeMat3x4, typeMat4, typeFrexpResult, typeFrexpResultVec2, typeFrexpResultVec3, typeFrexpResultVec4, typeBool, typeTex1D, typeITex1D, typeUTex1D, typeTex2D, typeITex2D, typeUTex2D, typeTex2DArray, typeITex2DArray, typeUTex2DArray, typeTex3D, typeITex3D, typeUTex3D, typeTexCube, typeITexCube, typeUTexCube, typeTexCubeArray, typeITexCubeArray, typeUTexCubeArray, typeTexMultisampled2D, typeITexMultisampled2D, typeUTexMultisampled2D, typeTexDepth2D, typeTexDepth2DArray, typeTexDepthCube, typeTexDepthCubeArray, typeTexDepthMultisampled2D, typeTexStorage1D_rgba8unorm, typeTexStorage1D_rgba8snorm, typeTexStorage1D_rgba8uint, typeTexStorage1D_rgba8sint, typeTexStorage1D_rgba16uint, typeTexStorage1D_rgba16sint, typeTexStorage1D_rgba16float, typeTexStorage1D_rgba32uint, typeTexStorage1D_rgba32sint, typeTexStorage1D_rgba32float, typeTexStorage1D_rg32uint, typeTexStorage1D_rg32sint, typeTexStorage1D_rg32float, typeTexStorage1D_r32uint, typeTexStorage1D_r32sint, typeTexStorage1D_r32float, typeTexStorage2D_rgba8unorm, typeTexStorage2D_rgba8snorm, typeTexStorage2D_rgba8uint, typeTexStorage2D_rgba8sint, typeTexStorage2D_rgba16uint, typeTexStorage2D_rgba16sint, typeTexStorage2D_rgba16float, typeTexStorage2D_rgba32uint, typeTexStorage2D_rgba32sint, typeTexStorage2D_rgba32float, typeTexStorage2D_rg32uint, typeTexStorage2D_rg32sint, typeTexStorage2D_rg32float, typeTexStorage2D_r32uint, typeTexStorage2D_r32sint, typeTexStorage2D_r32float, typeTexStorage2DArray_rgba8unorm, typeTexStorage2DArray_rgba8snorm, typeTexStorage2DArray_rgba8uint, typeTexStorage2DArray_rgba8sint, typeTexStorage2DArray_rgba16uint, typeTexStorage2DArray_rgba16sint, typeTexStorage2DArray_rgba16float, typeTexStorage2DArray_rgba32uint, typeTexStorage2DArray_rgba32sint, typeTexStorage2DArray_rgba32float, typeTexStorage2DArray_rg32uint, typeTexStorage2DArray_rg32sint, typeTexStorage2DArray_rg32float, typeTexStorage2DArray_r32uint, typeTexStorage2DArray_r32sint, typeTexStorage2DArray_r32float, typeTexStorage3D_rgba8unorm, typeTexStorage3D_rgba8snorm, typeTexStorage3D_rgba8uint, typeTexStorage3D_rgba8sint, typeTexStorage3D_rgba16uint, typeTexStorage3D_rgba16sint, typeTexStorage3D_rgba16float, typeTexStorage3D_rgba32uint, typeTexStorage3D_rgba32sint, typeTexStorage3D_rgba32float, typeTexStorage3D_rg32uint, typeTexStorage3D_rg32sint, typeTexStorage3D_rg32float, typeTexStorage3D_r32uint, typeTexStorage3D_r32sint, typeTexStorage3D_r32float, typeSampler, typeSamplerComparison, typeTexExternal, typeBVec2, typeBVec3, typeBVec4 } from './types.js';
2
- import { ASTAddressOf, ASTScalar, ASTFunction, ASTUnaryFunc, ASTBinaryFunc } from './ast.js';
1
+ import { PBPrimitiveType, typeU32, typeF32, typeI32, typeAtomicI32, typeAtomicU32, typeVoid, PBFunctionTypeInfo, typeF32Vec2, typeF32Vec3, typeF32Vec4, typeI32Vec2, typeI32Vec3, typeI32Vec4, typeU32Vec2, typeU32Vec3, typeU32Vec4, typeMat2, typeMat3x2, typeMat4x2, typeMat2x3, typeMat3, typeMat4x3, typeMat2x4, typeMat3x4, typeMat4, typeFrexpResult, typeFrexpResultVec2, typeFrexpResultVec3, typeFrexpResultVec4, typeBool, typeTex1D, typeITex1D, typeUTex1D, typeTex2D, typeITex2D, typeUTex2D, typeTex2DArray, typeITex2DArray, typeUTex2DArray, typeTex3D, typeITex3D, typeUTex3D, typeTexCube, typeITexCube, typeUTexCube, typeTexCubeArray, typeITexCubeArray, typeUTexCubeArray, typeTexMultisampled2D, typeITexMultisampled2D, typeUTexMultisampled2D, typeTexDepth2D, typeTexDepth2DArray, typeTexDepthCube, typeTexDepthCubeArray, typeTexDepthMultisampled2D, typeTexStorage1D_rgba8unorm, typeTexStorage1D_rgba8snorm, typeTexStorage1D_rgba8uint, typeTexStorage1D_rgba8sint, typeTexStorage1D_rgba16uint, typeTexStorage1D_rgba16sint, typeTexStorage1D_rgba16float, typeTexStorage1D_rgba32uint, typeTexStorage1D_rgba32sint, typeTexStorage1D_rgba32float, typeTexStorage1D_rg32uint, typeTexStorage1D_rg32sint, typeTexStorage1D_rg32float, typeTexStorage1D_r32uint, typeTexStorage1D_r32sint, typeTexStorage1D_r32float, typeTexStorage2D_rgba8unorm, typeTexStorage2D_rgba8snorm, typeTexStorage2D_rgba8uint, typeTexStorage2D_rgba8sint, typeTexStorage2D_rgba16uint, typeTexStorage2D_rgba16sint, typeTexStorage2D_rgba16float, typeTexStorage2D_rgba32uint, typeTexStorage2D_rgba32sint, typeTexStorage2D_rgba32float, typeTexStorage2D_rg32uint, typeTexStorage2D_rg32sint, typeTexStorage2D_rg32float, typeTexStorage2D_r32uint, typeTexStorage2D_r32sint, typeTexStorage2D_r32float, typeTexStorage2DArray_rgba8unorm, typeTexStorage2DArray_rgba8snorm, typeTexStorage2DArray_rgba8uint, typeTexStorage2DArray_rgba8sint, typeTexStorage2DArray_rgba16uint, typeTexStorage2DArray_rgba16sint, typeTexStorage2DArray_rgba16float, typeTexStorage2DArray_rgba32uint, typeTexStorage2DArray_rgba32sint, typeTexStorage2DArray_rgba32float, typeTexStorage2DArray_rg32uint, typeTexStorage2DArray_rg32sint, typeTexStorage2DArray_rg32float, typeTexStorage2DArray_r32uint, typeTexStorage2DArray_r32sint, typeTexStorage2DArray_r32float, typeTexStorage3D_rgba8unorm, typeTexStorage3D_rgba8snorm, typeTexStorage3D_rgba8uint, typeTexStorage3D_rgba8sint, typeTexStorage3D_rgba16uint, typeTexStorage3D_rgba16sint, typeTexStorage3D_rgba16float, typeTexStorage3D_rgba32uint, typeTexStorage3D_rgba32sint, typeTexStorage3D_rgba32float, typeTexStorage3D_rg32uint, typeTexStorage3D_rg32sint, typeTexStorage3D_rg32float, typeTexStorage3D_r32uint, typeTexStorage3D_r32sint, typeTexStorage3D_r32float, typeSampler, typeSamplerComparison, typeTexStorage1D_bgra8unorm, typeTexStorage2D_bgra8unorm, typeTexStorage3D_bgra8unorm, typeTexExternal, typeBVec2, typeBVec3, typeBVec4 } from './types.js';
2
+ import { ASTScalar, ASTAddressOf, ASTFunction, ASTUnaryFunc, ASTBinaryFunc } from './ast.js';
3
3
  import { PBShaderExp } from './base.js';
4
4
  import { PBParamLengthError, PBDeviceNotSupport, PBParamValueError, PBParamTypeError, PBOverloadingMatchError } from './errors.js';
5
5
 
@@ -1682,22 +1682,110 @@ const builtinFunctionsAll = {
1682
1682
  floatBitsToInt: {
1683
1683
  overloads: genType('floatBitsToInt', MASK_WEBGL2, 1, [
1684
1684
  0
1685
- ])
1685
+ ]),
1686
+ normalizeFunc (pb, name, ...args) {
1687
+ if (args.length !== 1) {
1688
+ throw new PBParamLengthError('floatBitsToInt');
1689
+ }
1690
+ if (!(args[0] instanceof PBShaderExp)) {
1691
+ if (typeof args[0] !== 'number') {
1692
+ throw new PBParamValueError('floatBitsToInt', 'x');
1693
+ }
1694
+ } else {
1695
+ const type = args[0].$ast.getType();
1696
+ if (type.typeId !== typeF32.typeId) {
1697
+ throw new PBParamTypeError('floatBitsToInt', 'x');
1698
+ }
1699
+ }
1700
+ if (pb.getDevice().type === 'webgpu') {
1701
+ return pb.$callFunctionNoCheck('bitcast<i32>', [
1702
+ args[0] instanceof PBShaderExp ? args[0].$ast : new ASTScalar(args[0], typeF32)
1703
+ ], typeI32);
1704
+ } else {
1705
+ return callBuiltin(pb, name, ...args);
1706
+ }
1707
+ }
1686
1708
  },
1687
1709
  floatBitsToUint: {
1688
1710
  overloads: genType('floatBitsToUint', MASK_WEBGL2, 2, [
1689
1711
  0
1690
- ])
1712
+ ]),
1713
+ normalizeFunc (pb, name, ...args) {
1714
+ if (args.length !== 1) {
1715
+ throw new PBParamLengthError('floatBitsToUint');
1716
+ }
1717
+ if (!(args[0] instanceof PBShaderExp)) {
1718
+ if (typeof args[0] !== 'number') {
1719
+ throw new PBParamValueError('floatBitsToUint', 'x');
1720
+ }
1721
+ } else {
1722
+ const type = args[0].$ast.getType();
1723
+ if (type.typeId !== typeF32.typeId) {
1724
+ throw new PBParamTypeError('floatBitsToUint', 'x');
1725
+ }
1726
+ }
1727
+ if (pb.getDevice().type === 'webgpu') {
1728
+ return pb.$callFunctionNoCheck('bitcast<u32>', [
1729
+ args[0] instanceof PBShaderExp ? args[0].$ast : new ASTScalar(args[0], typeF32)
1730
+ ], typeU32);
1731
+ } else {
1732
+ return callBuiltin(pb, name, ...args);
1733
+ }
1734
+ }
1691
1735
  },
1692
1736
  intBitsToFloat: {
1693
1737
  overloads: genType('intBitsToFloat', MASK_WEBGL2, 0, [
1694
1738
  1
1695
- ])
1739
+ ]),
1740
+ normalizeFunc (pb, name, ...args) {
1741
+ if (args.length !== 1) {
1742
+ throw new PBParamLengthError('intBitsToFloat');
1743
+ }
1744
+ if (!(args[0] instanceof PBShaderExp)) {
1745
+ if (typeof args[0] !== 'number') {
1746
+ throw new PBParamValueError('intBitsToFloat', 'x');
1747
+ }
1748
+ } else {
1749
+ const type = args[0].$ast.getType();
1750
+ if (type.typeId !== typeI32.typeId) {
1751
+ throw new PBParamTypeError('intBitsToFloat', 'x');
1752
+ }
1753
+ }
1754
+ if (pb.getDevice().type === 'webgpu') {
1755
+ return pb.$callFunctionNoCheck('bitcast<f32>', [
1756
+ args[0] instanceof PBShaderExp ? args[0].$ast : new ASTScalar(args[0], typeI32)
1757
+ ], typeF32);
1758
+ } else {
1759
+ return callBuiltin(pb, name, ...args);
1760
+ }
1761
+ }
1696
1762
  },
1697
1763
  uintBitsToFloat: {
1698
1764
  overloads: genType('uintBitsToFloat', MASK_WEBGL2, 0, [
1699
1765
  2
1700
- ])
1766
+ ]),
1767
+ normalizeFunc (pb, name, ...args) {
1768
+ if (args.length !== 1) {
1769
+ throw new PBParamLengthError('uintBitsToFloat');
1770
+ }
1771
+ if (!(args[0] instanceof PBShaderExp)) {
1772
+ if (typeof args[0] !== 'number') {
1773
+ throw new PBParamValueError('uintBitsToFloat', 'x');
1774
+ }
1775
+ } else {
1776
+ const type = args[0].$ast.getType();
1777
+ if (type.typeId !== typeU32.typeId) {
1778
+ throw new PBParamTypeError('uintBitsToFloat', 'x');
1779
+ }
1780
+ }
1781
+ if (pb.getDevice().type === 'webgpu') {
1782
+ return pb.$callFunctionNoCheck('bitcast<f32>', [
1783
+ args[0] instanceof PBShaderExp ? args[0].$ast : new ASTScalar(args[0], typeU32)
1784
+ ], typeF32);
1785
+ } else {
1786
+ return callBuiltin(pb, name, ...args);
1787
+ }
1788
+ }
1701
1789
  },
1702
1790
  pack4x8snorm: {
1703
1791
  overloads: genType('pack4x8snorm', MASK_WEBGPU, typeU32, [
@@ -2409,6 +2497,74 @@ const builtinFunctionsAll = {
2409
2497
  typeI32,
2410
2498
  typeI32
2411
2499
  ]),
2500
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2501
+ typeTexStorage1D_bgra8unorm,
2502
+ typeI32
2503
+ ]),
2504
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2505
+ typeTexStorage1D_r32float,
2506
+ typeI32
2507
+ ]),
2508
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2509
+ typeTexStorage1D_r32sint,
2510
+ typeI32
2511
+ ]),
2512
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2513
+ typeTexStorage1D_r32uint,
2514
+ typeI32
2515
+ ]),
2516
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2517
+ typeTexStorage1D_rg32float,
2518
+ typeI32
2519
+ ]),
2520
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2521
+ typeTexStorage1D_rg32sint,
2522
+ typeI32
2523
+ ]),
2524
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2525
+ typeTexStorage1D_rg32uint,
2526
+ typeI32
2527
+ ]),
2528
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2529
+ typeTexStorage1D_rgba16float,
2530
+ typeI32
2531
+ ]),
2532
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2533
+ typeTexStorage1D_rgba16sint,
2534
+ typeI32
2535
+ ]),
2536
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2537
+ typeTexStorage1D_rgba16uint,
2538
+ typeI32
2539
+ ]),
2540
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2541
+ typeTexStorage1D_rgba32float,
2542
+ typeI32
2543
+ ]),
2544
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2545
+ typeTexStorage1D_rgba32sint,
2546
+ typeI32
2547
+ ]),
2548
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2549
+ typeTexStorage1D_rgba32uint,
2550
+ typeI32
2551
+ ]),
2552
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2553
+ typeTexStorage1D_rgba8sint,
2554
+ typeI32
2555
+ ]),
2556
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2557
+ typeTexStorage1D_rgba8uint,
2558
+ typeI32
2559
+ ]),
2560
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2561
+ typeTexStorage1D_rgba8snorm,
2562
+ typeI32
2563
+ ]),
2564
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2565
+ typeTexStorage1D_rgba8unorm,
2566
+ typeI32
2567
+ ]),
2412
2568
  ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2413
2569
  typeTex2D,
2414
2570
  typeI32Vec2,
@@ -2424,6 +2580,74 @@ const builtinFunctionsAll = {
2424
2580
  typeI32Vec2,
2425
2581
  typeI32
2426
2582
  ]),
2583
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2584
+ typeTexStorage2D_bgra8unorm,
2585
+ typeI32Vec2
2586
+ ]),
2587
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2588
+ typeTexStorage2D_r32float,
2589
+ typeI32Vec2
2590
+ ]),
2591
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2592
+ typeTexStorage2D_r32sint,
2593
+ typeI32Vec2
2594
+ ]),
2595
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2596
+ typeTexStorage2D_r32uint,
2597
+ typeI32Vec2
2598
+ ]),
2599
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2600
+ typeTexStorage2D_rg32float,
2601
+ typeI32Vec2
2602
+ ]),
2603
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2604
+ typeTexStorage2D_rg32sint,
2605
+ typeI32Vec2
2606
+ ]),
2607
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2608
+ typeTexStorage2D_rg32uint,
2609
+ typeI32Vec2
2610
+ ]),
2611
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2612
+ typeTexStorage2D_rgba16float,
2613
+ typeI32Vec2
2614
+ ]),
2615
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2616
+ typeTexStorage2D_rgba16sint,
2617
+ typeI32Vec2
2618
+ ]),
2619
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2620
+ typeTexStorage2D_rgba16uint,
2621
+ typeI32Vec2
2622
+ ]),
2623
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2624
+ typeTexStorage2D_rgba32float,
2625
+ typeI32Vec2
2626
+ ]),
2627
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2628
+ typeTexStorage2D_rgba32sint,
2629
+ typeI32Vec2
2630
+ ]),
2631
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2632
+ typeTexStorage2D_rgba32uint,
2633
+ typeI32Vec2
2634
+ ]),
2635
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2636
+ typeTexStorage2D_rgba8sint,
2637
+ typeI32Vec2
2638
+ ]),
2639
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2640
+ typeTexStorage2D_rgba8uint,
2641
+ typeI32Vec2
2642
+ ]),
2643
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2644
+ typeTexStorage2D_rgba8snorm,
2645
+ typeI32Vec2
2646
+ ]),
2647
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2648
+ typeTexStorage2D_rgba8unorm,
2649
+ typeI32Vec2
2650
+ ]),
2427
2651
  ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2428
2652
  typeTex3D,
2429
2653
  typeI32Vec3,
@@ -2439,6 +2663,74 @@ const builtinFunctionsAll = {
2439
2663
  typeI32Vec3,
2440
2664
  typeI32
2441
2665
  ]),
2666
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2667
+ typeTexStorage3D_bgra8unorm,
2668
+ typeI32Vec3
2669
+ ]),
2670
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2671
+ typeTexStorage3D_r32float,
2672
+ typeI32Vec3
2673
+ ]),
2674
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2675
+ typeTexStorage3D_r32sint,
2676
+ typeI32Vec3
2677
+ ]),
2678
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2679
+ typeTexStorage3D_r32uint,
2680
+ typeI32Vec3
2681
+ ]),
2682
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2683
+ typeTexStorage3D_rg32float,
2684
+ typeI32Vec3
2685
+ ]),
2686
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2687
+ typeTexStorage3D_rg32sint,
2688
+ typeI32Vec3
2689
+ ]),
2690
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2691
+ typeTexStorage3D_rg32uint,
2692
+ typeI32Vec3
2693
+ ]),
2694
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2695
+ typeTexStorage3D_rgba16float,
2696
+ typeI32Vec3
2697
+ ]),
2698
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2699
+ typeTexStorage3D_rgba16sint,
2700
+ typeI32Vec3
2701
+ ]),
2702
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2703
+ typeTexStorage3D_rgba16uint,
2704
+ typeI32Vec3
2705
+ ]),
2706
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2707
+ typeTexStorage3D_rgba32float,
2708
+ typeI32Vec3
2709
+ ]),
2710
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2711
+ typeTexStorage3D_rgba32sint,
2712
+ typeI32Vec3
2713
+ ]),
2714
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2715
+ typeTexStorage3D_rgba32uint,
2716
+ typeI32Vec3
2717
+ ]),
2718
+ ...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
2719
+ typeTexStorage3D_rgba8sint,
2720
+ typeI32Vec3
2721
+ ]),
2722
+ ...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
2723
+ typeTexStorage3D_rgba8uint,
2724
+ typeI32Vec3
2725
+ ]),
2726
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2727
+ typeTexStorage3D_rgba8snorm,
2728
+ typeI32Vec3
2729
+ ]),
2730
+ ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2731
+ typeTexStorage3D_rgba8unorm,
2732
+ typeI32Vec3
2733
+ ]),
2442
2734
  ...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
2443
2735
  typeTexMultisampled2D,
2444
2736
  typeI32Vec2,
@@ -2549,8 +2841,13 @@ const builtinFunctionsAll = {
2549
2841
  }
2550
2842
  args[1] = pb.ivec2(args[1], 0);
2551
2843
  }
2552
- } else if (pb.getDevice().type === 'webgpu' && texType.isExternalTexture()) {
2553
- args = args.slice(0, 2);
2844
+ } else if (pb.getDevice().type === 'webgpu') {
2845
+ if (texType.isExternalTexture()) {
2846
+ args = args.slice(0, 2);
2847
+ }
2848
+ if (texType.isStorageTexture()) {
2849
+ texType.readable = true;
2850
+ }
2554
2851
  }
2555
2852
  return callBuiltin(pb, name, ...args);
2556
2853
  }
@@ -2765,6 +3062,11 @@ const builtinFunctionsAll = {
2765
3062
  typeU32Vec2,
2766
3063
  typeU32Vec4
2767
3064
  ]),
3065
+ ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3066
+ typeTexStorage2D_r32uint,
3067
+ typeI32Vec2,
3068
+ typeU32Vec4
3069
+ ]),
2768
3070
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
2769
3071
  typeTexStorage2D_r32sint,
2770
3072
  typeU32Vec2,
@@ -2855,7 +3157,19 @@ const builtinFunctionsAll = {
2855
3157
  typeU32Vec3,
2856
3158
  typeF32Vec4
2857
3159
  ])
2858
- ]
3160
+ ],
3161
+ normalizeFunc (pb, name, ...args) {
3162
+ if (pb.getDevice().type === 'webgpu') {
3163
+ const tex = args[0];
3164
+ if (tex instanceof PBShaderExp) {
3165
+ const texType = tex.$ast.getType();
3166
+ if (texType?.isTextureType() && texType.isStorageTexture()) {
3167
+ texType.writable = true;
3168
+ }
3169
+ }
3170
+ }
3171
+ return callBuiltin(pb, name, ...args);
3172
+ }
2859
3173
  },
2860
3174
  // textureArrayStore(tex: PBShaderExp, coords: PBShaderExp, arrayIndex: number|PBShaderExp, value: PBShaderExp);
2861
3175
  textureArrayStore: {
@@ -3227,6 +3541,9 @@ const builtinFunctionsAll = {
3227
3541
  throw new PBParamTypeError('textureSample', 'texture');
3228
3542
  }
3229
3543
  if (pb.getDevice().type === 'webgpu') {
3544
+ if (texType.isStorageTexture()) {
3545
+ throw new PBParamTypeError('textureSample', 'texture');
3546
+ }
3230
3547
  const sampler = pb.getDefaultSampler(tex, false);
3231
3548
  const coords = args[1];
3232
3549
  const ret = callBuiltin(pb, name, tex, sampler, coords);
@@ -4033,7 +4350,8 @@ for (const name of [
4033
4350
  'atomicMin',
4034
4351
  'atomicAnd',
4035
4352
  'atomicOr',
4036
- 'atomicXor'
4353
+ 'atomicXor',
4354
+ 'atomicExchange'
4037
4355
  ]){
4038
4356
  builtinFunctionsAll[name] = {
4039
4357
  overloades: [],