@zephyr3d/device 0.2.2 → 0.2.4

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 CHANGED
@@ -1,4 +1,4 @@
1
- # @zephyr3d
1
+ # @zephyr3d/device
2
2
 
3
3
  Zephyr3d is a set of API for 3D rendering within the browser.
4
4
 
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1275,6 +1275,15 @@ function unbracket(e) {
1275
1275
  /** @internal */ type;
1276
1276
  constructor(condition, first, second){
1277
1277
  super();
1278
+ if (condition instanceof ASTCallFunction) {
1279
+ condition.isStatement = false;
1280
+ }
1281
+ if (first instanceof ASTCallFunction) {
1282
+ first.isStatement = false;
1283
+ }
1284
+ if (second instanceof ASTCallFunction) {
1285
+ second.isStatement = false;
1286
+ }
1278
1287
  this.condition = condition instanceof ASTExpression ? condition : new ASTScalar(condition, typeBool);
1279
1288
  let firstType = null;
1280
1289
  let secondType = null;
@@ -1 +1 @@
1
- {"version":3,"file":"ast.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -188,6 +188,12 @@ let uidExp = 0;
188
188
  * @returns self
189
189
  */ storage(group) {
190
190
  if (!this.$typeinfo.isHostSharable()) {
191
+ if (this.$typeinfo.isTextureType()) {
192
+ if (!this.$typeinfo.isStorageTexture()) {
193
+ throw new PBASTError(this.$ast, 'type cannot be declared as storage texture');
194
+ }
195
+ return this.uniform(group);
196
+ }
191
197
  throw new PBASTError(this.$ast, 'type cannot be declared in storage address space');
192
198
  }
193
199
  this.$declareType = DeclareType.DECLARE_TYPE_STORAGE;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2896,15 +2896,28 @@ const builtinFunctionsAll = {
2896
2896
  ])
2897
2897
  ],
2898
2898
  normalizeFunc (pb, name, ...args) {
2899
+ if (args.length === 0) {
2900
+ throw new PBParamLengthError('textureArrayLoad');
2901
+ }
2902
+ const tex = args[0];
2903
+ if (!(tex instanceof PBShaderExp)) {
2904
+ throw new PBParamValueError('textureArrayLoad', 'tex');
2905
+ }
2906
+ const texType = tex.$ast.getType();
2907
+ if (!texType.isTextureType()) {
2908
+ throw new PBParamTypeError('textureArrayLoad', 'tex');
2909
+ }
2899
2910
  if (pb.getDevice().type === 'webgl2') {
2900
2911
  if (args.length !== 4) {
2901
2912
  throw new PBParamLengthError('textureArrayLoad');
2902
2913
  }
2903
- const tex = args[0];
2904
2914
  const coords = pb.ivec3(args[1], args[2]);
2905
2915
  const level = args[3];
2906
2916
  return callBuiltin(pb, name, tex, coords, level);
2907
2917
  } else {
2918
+ if (texType.isStorageTexture()) {
2919
+ texType.readable = true;
2920
+ }
2908
2921
  return callBuiltin(pb, name, ...args);
2909
2922
  }
2910
2923
  }
@@ -3176,101 +3189,113 @@ const builtinFunctionsAll = {
3176
3189
  overloads: [
3177
3190
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3178
3191
  typeTexStorage2DArray_rgba8unorm,
3179
- typeI32Vec2,
3192
+ typeU32Vec2,
3180
3193
  typeI32,
3181
3194
  typeF32Vec4
3182
3195
  ]),
3183
3196
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3184
3197
  typeTexStorage2DArray_rgba8snorm,
3185
- typeI32Vec2,
3198
+ typeU32Vec2,
3186
3199
  typeI32,
3187
3200
  typeF32Vec4
3188
3201
  ]),
3189
3202
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3190
3203
  typeTexStorage2DArray_rgba8uint,
3191
- typeI32Vec2,
3204
+ typeU32Vec2,
3192
3205
  typeI32,
3193
3206
  typeU32Vec4
3194
3207
  ]),
3195
3208
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3196
3209
  typeTexStorage2DArray_rgba8sint,
3197
- typeI32Vec2,
3210
+ typeU32Vec2,
3198
3211
  typeI32,
3199
3212
  typeI32Vec4
3200
3213
  ]),
3201
3214
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3202
3215
  typeTexStorage2DArray_rgba16uint,
3203
- typeI32Vec2,
3216
+ typeU32Vec2,
3204
3217
  typeI32,
3205
3218
  typeU32Vec4
3206
3219
  ]),
3207
3220
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3208
3221
  typeTexStorage2DArray_rgba16sint,
3209
- typeI32Vec2,
3222
+ typeU32Vec2,
3210
3223
  typeI32,
3211
3224
  typeI32Vec4
3212
3225
  ]),
3213
3226
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3214
3227
  typeTexStorage2DArray_rgba16float,
3215
- typeI32Vec2,
3228
+ typeU32Vec2,
3216
3229
  typeI32,
3217
3230
  typeF32Vec4
3218
3231
  ]),
3219
3232
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3220
3233
  typeTexStorage2DArray_rgba32uint,
3221
- typeI32Vec2,
3234
+ typeU32Vec2,
3222
3235
  typeI32,
3223
3236
  typeU32Vec4
3224
3237
  ]),
3225
3238
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3226
3239
  typeTexStorage2DArray_rgba32sint,
3227
- typeI32Vec2,
3240
+ typeU32Vec2,
3228
3241
  typeI32,
3229
3242
  typeI32Vec4
3230
3243
  ]),
3231
3244
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3232
3245
  typeTexStorage2DArray_rgba32float,
3233
- typeI32Vec2,
3246
+ typeU32Vec2,
3234
3247
  typeI32,
3235
3248
  typeF32Vec4
3236
3249
  ]),
3237
3250
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3238
3251
  typeTexStorage2DArray_rg32uint,
3239
- typeI32Vec2,
3252
+ typeU32Vec2,
3240
3253
  typeI32,
3241
3254
  typeU32Vec4
3242
3255
  ]),
3243
3256
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3244
3257
  typeTexStorage2DArray_rg32sint,
3245
- typeI32Vec2,
3258
+ typeU32Vec2,
3246
3259
  typeI32,
3247
3260
  typeI32Vec4
3248
3261
  ]),
3249
3262
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3250
3263
  typeTexStorage2DArray_rg32float,
3251
- typeI32Vec2,
3264
+ typeU32Vec2,
3252
3265
  typeI32,
3253
3266
  typeF32Vec4
3254
3267
  ]),
3255
3268
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3256
3269
  typeTexStorage2DArray_r32uint,
3257
- typeI32Vec2,
3270
+ typeU32Vec2,
3258
3271
  typeI32,
3259
3272
  typeU32Vec4
3260
3273
  ]),
3261
3274
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3262
3275
  typeTexStorage2DArray_r32sint,
3263
- typeI32Vec2,
3276
+ typeU32Vec2,
3264
3277
  typeI32,
3265
3278
  typeI32Vec4
3266
3279
  ]),
3267
3280
  ...genType('textureStore', MASK_WEBGPU, typeVoid, [
3268
3281
  typeTexStorage2DArray_r32float,
3269
- typeI32Vec2,
3282
+ typeU32Vec2,
3270
3283
  typeI32,
3271
3284
  typeF32Vec4
3272
3285
  ])
3273
- ]
3286
+ ],
3287
+ normalizeFunc (pb, name, ...args) {
3288
+ if (pb.getDevice().type === 'webgpu') {
3289
+ const tex = args[0];
3290
+ if (tex instanceof PBShaderExp) {
3291
+ const texType = tex.$ast.getType();
3292
+ if (texType?.isTextureType() && texType.isStorageTexture()) {
3293
+ texType.writable = true;
3294
+ }
3295
+ }
3296
+ }
3297
+ return callBuiltin(pb, name, ...args);
3298
+ }
3274
3299
  },
3275
3300
  // textureNumLayers(tex: PBShaderExp);
3276
3301
  textureNumLayers: {
@@ -1 +1 @@
1
- {"version":3,"file":"builtinfunc.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1353,9 +1353,21 @@ const output_prefix_fs = 'zFSOutput_';
1353
1353
  throw new Error('internal error');
1354
1354
  }
1355
1355
  if (entry.type.isStorageTexture()) {
1356
+ let viewDimension;
1357
+ if (entry.type.isArrayTexture()) {
1358
+ viewDimension = entry.type.isCubeTexture() ? 'cube-array' : '2d-array';
1359
+ } else if (entry.type.is3DTexture()) {
1360
+ viewDimension = '3d';
1361
+ } else if (entry.type.isCubeTexture()) {
1362
+ viewDimension = 'cube';
1363
+ } else if (entry.type.is1DTexture()) {
1364
+ viewDimension = '1d';
1365
+ } else {
1366
+ viewDimension = '2d';
1367
+ }
1356
1368
  entry.storageTexture = {
1357
1369
  access: 'write-only',
1358
- viewDimension: entry.type.is1DTexture() ? '1d' : '2d',
1370
+ viewDimension: viewDimension,
1359
1371
  format: entry.type.storageTexelFormat
1360
1372
  };
1361
1373
  } else if (entry.type.isExternalTexture()) {
@@ -2188,7 +2200,13 @@ const output_prefix_fs = 'zFSOutput_';
2188
2200
  ] : args).map((val)=>pb.normalizeExpValue(val));
2189
2201
  const funcType = pb._getFunctionOverload(name, argsNonArray);
2190
2202
  if (!funcType) {
2191
- throw new Error(`ERROR: no matching overloads for function ${name}`);
2203
+ throw new Error(`ERROR: no matching overloads for function ${name}(${argsNonArray.map((val)=>{
2204
+ if (val instanceof PBShaderExp) {
2205
+ return val.$ast?.getType()?.toTypeName() ?? '?';
2206
+ } else {
2207
+ return typeof val;
2208
+ }
2209
+ }).join(', ')})`);
2192
2210
  }
2193
2211
  return getCurrentProgramBuilder().$callFunction(name, funcType[1], funcType[0]);
2194
2212
  };
@@ -1 +1 @@
1
- {"version":3,"file":"programbuilder.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -462,7 +462,7 @@ var PBTypeClass;
462
462
  /** {@inheritDoc PBTypeInfo.isVoidType} */ isVoidType() {
463
463
  return true;
464
464
  }
465
- /** @internal */ toTypeName(deviceType, varName) {
465
+ /** @internal */ toTypeName() {
466
466
  return 'void';
467
467
  }
468
468
  /** @internal */ genTypeId() {
@@ -482,7 +482,7 @@ var PBTypeClass;
482
482
  /** {@inheritDoc PBTypeInfo.isAnyType} */ isAnyType() {
483
483
  return true;
484
484
  }
485
- /** @internal */ toTypeName(deviceType, varName) {
485
+ /** @internal */ toTypeName() {
486
486
  return 'any';
487
487
  }
488
488
  /** @internal */ genTypeId() {
@@ -1337,7 +1337,7 @@ var PBTypeClass;
1337
1337
  return null;
1338
1338
  }
1339
1339
  /** @internal */ genTypeId() {
1340
- return `TEXTURE:${this.textureType}`;
1340
+ return `TEXTURE:${this.textureType}:${this.textureType & BITFLAG_STORAGE ? this.storageTexelFormat : ''}`;
1341
1341
  }
1342
1342
  }
1343
1343
  /**
@@ -1369,7 +1369,7 @@ var PBTypeClass;
1369
1369
  /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
1370
1370
  return null;
1371
1371
  }
1372
- /** @internal */ toTypeName(deviceType, varName) {
1372
+ /** @internal */ toTypeName() {
1373
1373
  throw new Error('not supported');
1374
1374
  }
1375
1375
  }
package/dist/device.js CHANGED
@@ -6,6 +6,7 @@ import { ProgramBuilder } from './builder/programbuilder.js';
6
6
  import { DeviceGPUObjectAddedEvent, DeviceGPUObjectRemovedEvent, DeviceResizeEvent } from './base_types.js';
7
7
  import '@zephyr3d/base';
8
8
  import { DrawText } from './helpers/drawtext.js';
9
+ import { Pool } from './pool.js';
9
10
 
10
11
  /**
11
12
  * Base class for rendering device
@@ -28,6 +29,9 @@ import { DrawText } from './helpers/drawtext.js';
28
29
  _backend;
29
30
  _beginFrameCounter;
30
31
  _programBuilder;
32
+ _pool;
33
+ _temporalFramebuffer;
34
+ _vSync;
31
35
  _stateStack;
32
36
  constructor(cvs, backend){
33
37
  this._backend = backend;
@@ -72,6 +76,9 @@ import { DrawText } from './helpers/drawtext.js';
72
76
  };
73
77
  this._stateStack = [];
74
78
  this._beginFrameCounter = 0;
79
+ this._pool = new Pool(this);
80
+ this._temporalFramebuffer = false;
81
+ this._vSync = true;
75
82
  this._registerEventHandlers();
76
83
  }
77
84
  get backend() {
@@ -92,6 +99,15 @@ import { DrawText } from './helpers/drawtext.js';
92
99
  get type() {
93
100
  return this._backend.typeName();
94
101
  }
102
+ get vSync() {
103
+ return this._vSync;
104
+ }
105
+ set vSync(val) {
106
+ this._vSync = !!val;
107
+ }
108
+ get pool() {
109
+ return this._pool;
110
+ }
95
111
  get runLoopFunction() {
96
112
  return this._runLoopFunc;
97
113
  }
@@ -104,6 +120,31 @@ import { DrawText } from './helpers/drawtext.js';
104
120
  drawText(text, x, y, color) {
105
121
  DrawText.drawText(this, text, color, x, y);
106
122
  }
123
+ setFramebuffer(colorOrRT, depth, sampleCount) {
124
+ let newRT = null;
125
+ let temporal = false;
126
+ if (!Array.isArray(colorOrRT)) {
127
+ newRT = colorOrRT ?? null;
128
+ } else {
129
+ const colorAttachments = colorOrRT.map((val)=>val.texture ?? val);
130
+ newRT = this._pool.createTemporalFramebuffer(false, colorAttachments, depth, sampleCount, true);
131
+ for(let i = 0; i < colorOrRT.length; i++){
132
+ const rt = colorOrRT[i];
133
+ newRT.setColorAttachmentMipLevel(i, rt.texture ? rt.miplevel ?? 0 : 0);
134
+ newRT.setColorAttachmentLayer(i, rt.texture ? rt.face ?? 0 : 0);
135
+ newRT.setColorAttachmentCubeFace(i, rt.texture ? rt.layer ?? 0 : 0);
136
+ }
137
+ temporal = true;
138
+ }
139
+ const currentRT = this.getFramebuffer();
140
+ if (currentRT !== newRT) {
141
+ if (this._temporalFramebuffer) {
142
+ this._pool.releaseFrameBuffer(currentRT);
143
+ }
144
+ this._temporalFramebuffer = temporal;
145
+ this._setFramebuffer(newRT);
146
+ }
147
+ }
107
148
  disposeObject(obj, remove = true) {
108
149
  if (obj) {
109
150
  if (remove) {
@@ -145,6 +186,7 @@ import { DrawText } from './helpers/drawtext.js';
145
186
  this._beginFrameCounter++;
146
187
  this._beginFrameTime = this._cpuTimer.now();
147
188
  this.updateFrameInfo();
189
+ this._pool.autoRelease();
148
190
  return this.onBeginFrame();
149
191
  }
150
192
  endFrame() {
@@ -224,8 +266,12 @@ import { DrawText } from './helpers/drawtext.js';
224
266
  }
225
267
  }
226
268
  exitLoop() {
227
- if (this._runningLoop) {
228
- cancelAnimationFrame(this._runningLoop);
269
+ if (this._runningLoop !== null) {
270
+ if (this._runningLoop !== 0) {
271
+ cancelAnimationFrame(this._runningLoop);
272
+ } else {
273
+ this.cancelNextFrame(this._runningLoop);
274
+ }
229
275
  this._runningLoop = null;
230
276
  }
231
277
  }
@@ -241,7 +287,15 @@ import { DrawText } from './helpers/drawtext.js';
241
287
  const that = this;
242
288
  that._runLoopFunc = func;
243
289
  (function entry() {
244
- that._runningLoop = requestAnimationFrame(entry);
290
+ if (that._vSync) {
291
+ that._runningLoop = requestAnimationFrame(entry);
292
+ } else {
293
+ that._runningLoop = that.nextFrame(()=>{
294
+ if (that._runningLoop !== null) {
295
+ entry();
296
+ }
297
+ });
298
+ }
245
299
  if (that.beginFrame()) {
246
300
  that._runLoopFunc(that);
247
301
  that.endFrame();
@@ -1 +1 @@
1
- {"version":3,"file":"device.js","sources":[],"s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