@zephyr3d/device 0.2.3 → 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 +1 -1
- package/dist/builder/ast.js +9 -0
- package/dist/builder/ast.js.map +1 -1
- package/dist/builder/base.js +6 -0
- package/dist/builder/base.js.map +1 -1
- package/dist/builder/builtinfunc.js +43 -18
- package/dist/builder/builtinfunc.js.map +1 -1
- package/dist/builder/programbuilder.js +20 -2
- package/dist/builder/programbuilder.js.map +1 -1
- package/dist/builder/types.js +4 -4
- package/dist/index.d.ts +70 -54
- package/dist/pool.js +48 -20
- package/dist/pool.js.map +1 -1
- package/package.json +4 -7
package/README.md
CHANGED
package/dist/builder/ast.js
CHANGED
|
@@ -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;
|
package/dist/builder/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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builder/base.js
CHANGED
|
@@ -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;
|
package/dist/builder/base.js.map
CHANGED
|
@@ -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
|
-
|
|
3192
|
+
typeU32Vec2,
|
|
3180
3193
|
typeI32,
|
|
3181
3194
|
typeF32Vec4
|
|
3182
3195
|
]),
|
|
3183
3196
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3184
3197
|
typeTexStorage2DArray_rgba8snorm,
|
|
3185
|
-
|
|
3198
|
+
typeU32Vec2,
|
|
3186
3199
|
typeI32,
|
|
3187
3200
|
typeF32Vec4
|
|
3188
3201
|
]),
|
|
3189
3202
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3190
3203
|
typeTexStorage2DArray_rgba8uint,
|
|
3191
|
-
|
|
3204
|
+
typeU32Vec2,
|
|
3192
3205
|
typeI32,
|
|
3193
3206
|
typeU32Vec4
|
|
3194
3207
|
]),
|
|
3195
3208
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3196
3209
|
typeTexStorage2DArray_rgba8sint,
|
|
3197
|
-
|
|
3210
|
+
typeU32Vec2,
|
|
3198
3211
|
typeI32,
|
|
3199
3212
|
typeI32Vec4
|
|
3200
3213
|
]),
|
|
3201
3214
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3202
3215
|
typeTexStorage2DArray_rgba16uint,
|
|
3203
|
-
|
|
3216
|
+
typeU32Vec2,
|
|
3204
3217
|
typeI32,
|
|
3205
3218
|
typeU32Vec4
|
|
3206
3219
|
]),
|
|
3207
3220
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3208
3221
|
typeTexStorage2DArray_rgba16sint,
|
|
3209
|
-
|
|
3222
|
+
typeU32Vec2,
|
|
3210
3223
|
typeI32,
|
|
3211
3224
|
typeI32Vec4
|
|
3212
3225
|
]),
|
|
3213
3226
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3214
3227
|
typeTexStorage2DArray_rgba16float,
|
|
3215
|
-
|
|
3228
|
+
typeU32Vec2,
|
|
3216
3229
|
typeI32,
|
|
3217
3230
|
typeF32Vec4
|
|
3218
3231
|
]),
|
|
3219
3232
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3220
3233
|
typeTexStorage2DArray_rgba32uint,
|
|
3221
|
-
|
|
3234
|
+
typeU32Vec2,
|
|
3222
3235
|
typeI32,
|
|
3223
3236
|
typeU32Vec4
|
|
3224
3237
|
]),
|
|
3225
3238
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3226
3239
|
typeTexStorage2DArray_rgba32sint,
|
|
3227
|
-
|
|
3240
|
+
typeU32Vec2,
|
|
3228
3241
|
typeI32,
|
|
3229
3242
|
typeI32Vec4
|
|
3230
3243
|
]),
|
|
3231
3244
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3232
3245
|
typeTexStorage2DArray_rgba32float,
|
|
3233
|
-
|
|
3246
|
+
typeU32Vec2,
|
|
3234
3247
|
typeI32,
|
|
3235
3248
|
typeF32Vec4
|
|
3236
3249
|
]),
|
|
3237
3250
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3238
3251
|
typeTexStorage2DArray_rg32uint,
|
|
3239
|
-
|
|
3252
|
+
typeU32Vec2,
|
|
3240
3253
|
typeI32,
|
|
3241
3254
|
typeU32Vec4
|
|
3242
3255
|
]),
|
|
3243
3256
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3244
3257
|
typeTexStorage2DArray_rg32sint,
|
|
3245
|
-
|
|
3258
|
+
typeU32Vec2,
|
|
3246
3259
|
typeI32,
|
|
3247
3260
|
typeI32Vec4
|
|
3248
3261
|
]),
|
|
3249
3262
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3250
3263
|
typeTexStorage2DArray_rg32float,
|
|
3251
|
-
|
|
3264
|
+
typeU32Vec2,
|
|
3252
3265
|
typeI32,
|
|
3253
3266
|
typeF32Vec4
|
|
3254
3267
|
]),
|
|
3255
3268
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3256
3269
|
typeTexStorage2DArray_r32uint,
|
|
3257
|
-
|
|
3270
|
+
typeU32Vec2,
|
|
3258
3271
|
typeI32,
|
|
3259
3272
|
typeU32Vec4
|
|
3260
3273
|
]),
|
|
3261
3274
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3262
3275
|
typeTexStorage2DArray_r32sint,
|
|
3263
|
-
|
|
3276
|
+
typeU32Vec2,
|
|
3264
3277
|
typeI32,
|
|
3265
3278
|
typeI32Vec4
|
|
3266
3279
|
]),
|
|
3267
3280
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3268
3281
|
typeTexStorage2DArray_r32float,
|
|
3269
|
-
|
|
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":"
|
|
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:
|
|
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":"
|
|
1
|
+
{"version":3,"file":"programbuilder.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/builder/types.js
CHANGED
|
@@ -462,7 +462,7 @@ var PBTypeClass;
|
|
|
462
462
|
/** {@inheritDoc PBTypeInfo.isVoidType} */ isVoidType() {
|
|
463
463
|
return true;
|
|
464
464
|
}
|
|
465
|
-
/** @internal */ toTypeName(
|
|
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(
|
|
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(
|
|
1372
|
+
/** @internal */ toTypeName() {
|
|
1373
1373
|
throw new Error('not supported');
|
|
1374
1374
|
}
|
|
1375
1375
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TypedArray, IEventTarget, CubeFace, VectorBase, Vector4 } from '@zephyr3d/base';
|
|
1
|
+
import { TypedArray, IEventTarget, CubeFace, VectorBase, MaybeArray, Vector4 } from '@zephyr3d/base';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Struct layout types
|
|
@@ -909,7 +909,7 @@ interface StorageTextureBindingLayout {
|
|
|
909
909
|
/** The texture format */
|
|
910
910
|
format: TextureFormat;
|
|
911
911
|
/** View dimension */
|
|
912
|
-
viewDimension: '1d' | '2d';
|
|
912
|
+
viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
|
|
913
913
|
}
|
|
914
914
|
/**
|
|
915
915
|
* Binding layout of an external texture
|
|
@@ -1156,11 +1156,17 @@ interface FrameBuffer<T = unknown> extends GPUObject<T> {
|
|
|
1156
1156
|
getSampleCount(): number;
|
|
1157
1157
|
getHash(): string;
|
|
1158
1158
|
setColorAttachmentCubeFace(index: number, face: CubeFace): void;
|
|
1159
|
+
getColorAttachmentCubeFace(index: number): CubeFace;
|
|
1159
1160
|
setColorAttachmentMipLevel(index: number, level: number): void;
|
|
1161
|
+
getColorAttachmentMipLevel(index: number): number;
|
|
1160
1162
|
setColorAttachmentLayer(index: number, layer: number): void;
|
|
1163
|
+
getColorAttachmentLayer(index: number): number;
|
|
1161
1164
|
setColorAttachmentGenerateMipmaps(index: number, generateMipmaps: boolean): void;
|
|
1165
|
+
getColorAttachmentGenerateMipmaps(index: number): boolean;
|
|
1162
1166
|
setDepthAttachmentCubeFace(face: CubeFace): void;
|
|
1167
|
+
getDepthAttachmentCubeFace(): CubeFace;
|
|
1163
1168
|
setDepthAttachmentLayer(layer: number): void;
|
|
1169
|
+
getDepthAttachmentLayer(): number;
|
|
1164
1170
|
getColorAttachments(): BaseTexture[];
|
|
1165
1171
|
getDepthAttachment(): BaseTexture;
|
|
1166
1172
|
bind(): boolean;
|
|
@@ -2729,7 +2735,7 @@ declare class Pool {
|
|
|
2729
2735
|
* @param mipmapping - Whether this texture support mipmapping
|
|
2730
2736
|
* @returns The fetched Texture2D object.
|
|
2731
2737
|
*/
|
|
2732
|
-
fetchTemporalTexture2D(autoRelease: boolean, format: TextureFormat, width: number, height: number, mipmapping
|
|
2738
|
+
fetchTemporalTexture2D(autoRelease: boolean, format: TextureFormat, width: number, height: number, mipmapping?: boolean): Texture2D;
|
|
2733
2739
|
/**
|
|
2734
2740
|
* Fetch a temporal 2D array texture from the object pool.
|
|
2735
2741
|
* @param autoRelease - Whether the texture should be automatically released at the next frame.
|
|
@@ -2740,7 +2746,7 @@ declare class Pool {
|
|
|
2740
2746
|
* @param mipmapping - Whether this texture support mipmapping
|
|
2741
2747
|
* @returns The fetched Texture2DArray object.
|
|
2742
2748
|
*/
|
|
2743
|
-
fetchTemporalTexture2DArray(autoRelease: boolean, format: TextureFormat, width: number, height: number, numLayers: number, mipmapping
|
|
2749
|
+
fetchTemporalTexture2DArray(autoRelease: boolean, format: TextureFormat, width: number, height: number, numLayers: number, mipmapping?: boolean): Texture2DArray;
|
|
2744
2750
|
/**
|
|
2745
2751
|
* Fetch a temporal Cube texture from the object pool.
|
|
2746
2752
|
* @param autoRelease - Whether the texture should be automatically released at the next frame.
|
|
@@ -2749,67 +2755,36 @@ declare class Pool {
|
|
|
2749
2755
|
* @param mipmapping - Whether this texture support mipmapping
|
|
2750
2756
|
* @returns The fetched TextureCube object.
|
|
2751
2757
|
*/
|
|
2752
|
-
fetchTemporalTextureCube(autoRelease: boolean, format: TextureFormat, size: number, mipmapping
|
|
2753
|
-
/**
|
|
2754
|
-
* Fetch a temporal framebuffer from the object pool.
|
|
2755
|
-
* @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
|
|
2756
|
-
* @param colorFormat - Texture format for color attachment.
|
|
2757
|
-
* @param depthFormat - Texture format for depth attachment.
|
|
2758
|
-
* @param sampleCount - The sample count for the framebuffer.
|
|
2759
|
-
* @param ignoreDepthStencil - Whether to ignore depth stencil.
|
|
2760
|
-
* @returns The fetched FrameBuffer object.
|
|
2761
|
-
*/
|
|
2762
|
-
fetchTemporalFramebuffer(autoRelease: boolean, width: number, height: number, colorFormat: TextureFormat, depthFormat?: TextureFormat, mipmapping?: boolean, sampleCount?: number, ignoreDepthStencil?: boolean): FrameBuffer;
|
|
2763
|
-
/**
|
|
2764
|
-
* Fetch a temporal framebuffer from the object pool.
|
|
2765
|
-
* @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
|
|
2766
|
-
* @param colorFormat - Texture format for color attachment.
|
|
2767
|
-
* @param depthTex - depth attachment.
|
|
2768
|
-
* @param sampleCount - The sample count for the framebuffer.
|
|
2769
|
-
* @param ignoreDepthStencil - Whether to ignore depth stencil.
|
|
2770
|
-
* @returns The fetched FrameBuffer object.
|
|
2771
|
-
*/
|
|
2772
|
-
fetchTemporalFramebuffer<T extends BaseTexture<unknown>>(autoRelease: boolean, width: number, height: number, colorFormat: TextureFormat, depthTex?: T, mipmapping?: boolean, sampleCount?: number, ignoreDepthStencil?: boolean): FrameBuffer;
|
|
2773
|
-
/**
|
|
2774
|
-
* Fetch a temporal framebuffer from the object pool.
|
|
2775
|
-
* @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
|
|
2776
|
-
* @param colorTex - color attachment.
|
|
2777
|
-
* @param depthFormat - Texture format for depth attachment.
|
|
2778
|
-
* @param sampleCount - The sample count for the framebuffer.
|
|
2779
|
-
* @param ignoreDepthStencil - Whether to ignore depth stencil.
|
|
2780
|
-
* @returns The fetched FrameBuffer object.
|
|
2781
|
-
*/
|
|
2782
|
-
fetchTemporalFramebuffer<T extends BaseTexture<unknown>>(autoRelease: boolean, width: number, height: number, colorTex: T, depthFormat?: TextureFormat, mipmapping?: boolean, sampleCount?: number, ignoreDepthStencil?: boolean): FrameBuffer;
|
|
2783
|
-
/**
|
|
2784
|
-
* Fetch a temporal framebuffer from the object pool.
|
|
2785
|
-
* @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
|
|
2786
|
-
* @param colorTex - color attachment.
|
|
2787
|
-
* @param depthTex - depth attachment.
|
|
2788
|
-
* @param sampleCount - The sample count for the framebuffer.
|
|
2789
|
-
* @param ignoreDepthStencil - Whether to ignore depth stencil.
|
|
2790
|
-
* @returns The fetched FrameBuffer object.
|
|
2791
|
-
*/
|
|
2792
|
-
fetchTemporalFramebuffer<T extends BaseTexture<unknown>>(autoRelease: boolean, width: number, height: number, colorTex: T, depthTex?: T, mipmapping?: boolean, sampleCount?: number, ignoreDepthStencil?: boolean): FrameBuffer;
|
|
2758
|
+
fetchTemporalTextureCube(autoRelease: boolean, format: TextureFormat, size: number, mipmapping?: boolean): TextureCube;
|
|
2793
2759
|
/**
|
|
2794
|
-
*
|
|
2760
|
+
* Creates a temporal framebuffer from the object pool.
|
|
2795
2761
|
* @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
|
|
2796
|
-
* @param
|
|
2797
|
-
* @param
|
|
2798
|
-
* @param
|
|
2799
|
-
* @param
|
|
2762
|
+
* @param width - Width of the framebuffer
|
|
2763
|
+
* @param height - Height of the framebuffer
|
|
2764
|
+
* @param colorAttachments - Array of color attachments or texture format of the framebuffer.
|
|
2765
|
+
* @param depthAttachment - Depth attachment or texture format of the framebuffer.
|
|
2766
|
+
* @param mipmapping - Whether mipmapping should be enabled when creating color attachment textures, default is false.
|
|
2767
|
+
* @param sampleCount - The sample count for the framebuffer, default is 1.
|
|
2768
|
+
* @param ignoreDepthStencil - Whether to ignore depth stencil when resolving msaa framebuffer, default is true.
|
|
2769
|
+
* @param attachmentMipLevel - The mipmap level to which the color attachment will render, default is 0
|
|
2770
|
+
* @param attachmentCubeface - The cubemap face to which the color attachment will render, default is 0
|
|
2771
|
+
* @param attachmentLayer - The texture layer to which the color attachment will render, default is 0
|
|
2800
2772
|
* @returns The fetched FrameBuffer object.
|
|
2801
2773
|
*/
|
|
2802
|
-
fetchTemporalFramebuffer<T extends BaseTexture<unknown>>(autoRelease: boolean, width: number, height: number, colorTexOrFormat: TextureFormat | T
|
|
2774
|
+
fetchTemporalFramebuffer<T extends BaseTexture<unknown>>(autoRelease: boolean, width: number, height: number, colorTexOrFormat: MaybeArray<TextureFormat | T>, depthTexOrFormat?: TextureFormat | T, mipmapping?: boolean, sampleCount?: number, ignoreDepthStencil?: boolean, attachmentMipLevel?: number, attachmentCubeface?: number, attachmentLayer?: number): FrameBuffer;
|
|
2803
2775
|
/**
|
|
2804
2776
|
* Creates a temporal framebuffer from the object pool.
|
|
2805
2777
|
* @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
|
|
2806
2778
|
* @param colorAttachments - Array of color attachments for the framebuffer.
|
|
2807
2779
|
* @param depthAttachment - Depth attachment for the framebuffer.
|
|
2808
|
-
* @param sampleCount - The sample count for the framebuffer.
|
|
2809
|
-
* @param ignoreDepthStencil - Whether to ignore depth stencil.
|
|
2780
|
+
* @param sampleCount - The sample count for the framebuffer, default is 1.
|
|
2781
|
+
* @param ignoreDepthStencil - Whether to ignore depth stencil when resolving msaa framebuffer, default is true.
|
|
2782
|
+
* @param attachmentMipLevel - The mipmap level to which the color attachment will render, default is 0.
|
|
2783
|
+
* @param attachmentCubeface - The cubemap face to which the color attachment will render, default is 0.
|
|
2784
|
+
* @param attachmentLayer - The texture layer to which the color attachment will render, default is 0.
|
|
2810
2785
|
* @returns The fetched FrameBuffer object.
|
|
2811
2786
|
*/
|
|
2812
|
-
createTemporalFramebuffer(autoRelease: boolean, colorAttachments: BaseTexture[], depthAttachment?: BaseTexture, sampleCount?: number, ignoreDepthStencil?: boolean): FrameBuffer<unknown>;
|
|
2787
|
+
createTemporalFramebuffer(autoRelease: boolean, colorAttachments: BaseTexture[], depthAttachment?: BaseTexture, sampleCount?: number, ignoreDepthStencil?: boolean, attachmentMipLevel?: number, attachmentCubeface?: number, attachmentLayer?: number): FrameBuffer<unknown>;
|
|
2813
2788
|
/**
|
|
2814
2789
|
* Dispose a texture that is allocated from the object pool.
|
|
2815
2790
|
* @param texture - The texture to dispose.
|
|
@@ -3367,6 +3342,16 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3367
3342
|
clearFrameBuffer(clearColor: Vector4, clearDepth: number, clearStencil: number): any;
|
|
3368
3343
|
/** Creates a render state set object */
|
|
3369
3344
|
createRenderStateSet(): RenderStateSet;
|
|
3345
|
+
/** Creates a blending state object */
|
|
3346
|
+
createBlendingState(): BlendingState;
|
|
3347
|
+
/** Creates a color state object */
|
|
3348
|
+
createColorState(): ColorState;
|
|
3349
|
+
/** Creates a rasterizer state object */
|
|
3350
|
+
createRasterizerState(): RasterizerState;
|
|
3351
|
+
/** Creates a depth state object */
|
|
3352
|
+
createDepthState(): DepthState;
|
|
3353
|
+
/** Creates a stencil state object */
|
|
3354
|
+
createStencilState(): StencilState;
|
|
3370
3355
|
/**
|
|
3371
3356
|
* Creates a texture sampler object
|
|
3372
3357
|
* @param options - The creation options
|
|
@@ -3449,6 +3434,30 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3449
3434
|
* @param el - The video element
|
|
3450
3435
|
*/
|
|
3451
3436
|
createTextureVideo(el: HTMLVideoElement, samplerOptions?: SamplerOptions): TextureVideo;
|
|
3437
|
+
/**
|
|
3438
|
+
* Copies a 2d texture to another texture.
|
|
3439
|
+
*
|
|
3440
|
+
* @remarks
|
|
3441
|
+
* The two textures must have the same size and format
|
|
3442
|
+
*
|
|
3443
|
+
* @param src - Texture that will be copied from.
|
|
3444
|
+
* @param srcLevel - Which mipmap level to be copied from.
|
|
3445
|
+
* @param dst - Texture that will be copied to.
|
|
3446
|
+
* @param dstLevel - Which mipmap level to be copied to.
|
|
3447
|
+
*/
|
|
3448
|
+
copyTexture2D(src: Texture2D, srcLevel: number, dst: Texture2D, dstLevel: number): any;
|
|
3449
|
+
/**
|
|
3450
|
+
* Copies a color attachment of a framebuffer to a mipmap level of a texture.
|
|
3451
|
+
*
|
|
3452
|
+
* @remarks
|
|
3453
|
+
* The color attachment and the mipmap level must have the same size and format
|
|
3454
|
+
*
|
|
3455
|
+
* @param src - Framebuffer that will be copied from.
|
|
3456
|
+
* @param index - Color attachment index of the framebuffer.
|
|
3457
|
+
* @param dst - Texture that will be copied to.
|
|
3458
|
+
* @param level - Which mipmap level should be copied to.
|
|
3459
|
+
*/
|
|
3460
|
+
copyFramebufferToTexture2D(src: FrameBuffer, index: number, dst: Texture2D, level: number): any;
|
|
3452
3461
|
/**
|
|
3453
3462
|
* Set wether to reverse the winding order
|
|
3454
3463
|
*
|
|
@@ -3838,6 +3847,11 @@ declare abstract class BaseDevice {
|
|
|
3838
3847
|
abstract clearFrameBuffer(clearColor: Vector4, clearDepth: number, clearStencil: number): any;
|
|
3839
3848
|
abstract createGPUTimer(): ITimer;
|
|
3840
3849
|
abstract createRenderStateSet(): RenderStateSet;
|
|
3850
|
+
abstract createBlendingState(): BlendingState;
|
|
3851
|
+
abstract createColorState(): ColorState;
|
|
3852
|
+
abstract createRasterizerState(): RasterizerState;
|
|
3853
|
+
abstract createDepthState(): DepthState;
|
|
3854
|
+
abstract createStencilState(): StencilState;
|
|
3841
3855
|
abstract createSampler(options: SamplerOptions): TextureSampler;
|
|
3842
3856
|
abstract createTextureFromMipmapData<T extends BaseTexture>(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): T;
|
|
3843
3857
|
abstract createTexture2D(format: TextureFormat, width: number, height: number, options?: TextureCreationOptions): Texture2D;
|
|
@@ -3852,6 +3866,8 @@ declare abstract class BaseDevice {
|
|
|
3852
3866
|
abstract createTextureVideo(el: HTMLVideoElement, samplerOptions?: SamplerOptions): TextureVideo;
|
|
3853
3867
|
abstract reverseVertexWindingOrder(reverse: boolean): void;
|
|
3854
3868
|
abstract isWindingOrderReversed(): boolean;
|
|
3869
|
+
abstract copyTexture2D(src: Texture2D, srcLevel: number, dst: Texture2D, dstLevel: number): any;
|
|
3870
|
+
abstract copyFramebufferToTexture2D(src: FrameBuffer, index: number, dst: Texture2D, level: number): any;
|
|
3855
3871
|
abstract createGPUProgram(params: GPUProgramConstructParams): GPUProgram;
|
|
3856
3872
|
abstract createBindGroup(layout: BindGroupLayout): BindGroup;
|
|
3857
3873
|
abstract createBuffer(sizeInBytes: number, options: BufferCreationOptions): GPUDataBuffer;
|
package/dist/pool.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
* @param height - The height of the texture.
|
|
50
50
|
* @param mipmapping - Whether this texture support mipmapping
|
|
51
51
|
* @returns The fetched Texture2D object.
|
|
52
|
-
*/ fetchTemporalTexture2D(autoRelease, format, width, height, mipmapping) {
|
|
52
|
+
*/ fetchTemporalTexture2D(autoRelease, format, width, height, mipmapping = false) {
|
|
53
53
|
const hash = `2d:${format}:${width}:${height}:${mipmapping ? 1 : 0}`;
|
|
54
54
|
let texture = null;
|
|
55
55
|
const list = this._freeTextures[hash];
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
} else {
|
|
64
64
|
texture = list.pop();
|
|
65
65
|
if (list.length === 0) {
|
|
66
|
-
|
|
66
|
+
this._freeTextures[hash] = undefined;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
this._allocatedTextures.set(texture, {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
* @param numLayers - Layer count of the texture
|
|
86
86
|
* @param mipmapping - Whether this texture support mipmapping
|
|
87
87
|
* @returns The fetched Texture2DArray object.
|
|
88
|
-
*/ fetchTemporalTexture2DArray(autoRelease, format, width, height, numLayers, mipmapping) {
|
|
88
|
+
*/ fetchTemporalTexture2DArray(autoRelease, format, width, height, numLayers, mipmapping = false) {
|
|
89
89
|
const hash = `2darray:${format}:${width}:${height}:${numLayers}:${mipmapping ? 1 : 0}`;
|
|
90
90
|
let texture = null;
|
|
91
91
|
const list = this._freeTextures[hash];
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
} else {
|
|
100
100
|
texture = list.pop();
|
|
101
101
|
if (list.length === 0) {
|
|
102
|
-
|
|
102
|
+
this._freeTextures[hash] = undefined;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
this._allocatedTextures.set(texture, {
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
* @param size - size of the texture.
|
|
120
120
|
* @param mipmapping - Whether this texture support mipmapping
|
|
121
121
|
* @returns The fetched TextureCube object.
|
|
122
|
-
*/ fetchTemporalTextureCube(autoRelease, format, size, mipmapping) {
|
|
122
|
+
*/ fetchTemporalTextureCube(autoRelease, format, size, mipmapping = false) {
|
|
123
123
|
const hash = `cube:${format}:${size}:${mipmapping ? 1 : 0}`;
|
|
124
124
|
let texture = null;
|
|
125
125
|
const list = this._freeTextures[hash];
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
} else {
|
|
134
134
|
texture = list.pop();
|
|
135
135
|
if (list.length === 0) {
|
|
136
|
-
|
|
136
|
+
this._freeTextures[hash] = undefined;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
this._allocatedTextures.set(texture, {
|
|
@@ -146,16 +146,33 @@
|
|
|
146
146
|
}
|
|
147
147
|
return texture;
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Creates a temporal framebuffer from the object pool.
|
|
151
|
+
* @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
|
|
152
|
+
* @param width - Width of the framebuffer
|
|
153
|
+
* @param height - Height of the framebuffer
|
|
154
|
+
* @param colorAttachments - Array of color attachments or texture format of the framebuffer.
|
|
155
|
+
* @param depthAttachment - Depth attachment or texture format of the framebuffer.
|
|
156
|
+
* @param mipmapping - Whether mipmapping should be enabled when creating color attachment textures, default is false.
|
|
157
|
+
* @param sampleCount - The sample count for the framebuffer, default is 1.
|
|
158
|
+
* @param ignoreDepthStencil - Whether to ignore depth stencil when resolving msaa framebuffer, default is true.
|
|
159
|
+
* @param attachmentMipLevel - The mipmap level to which the color attachment will render, default is 0
|
|
160
|
+
* @param attachmentCubeface - The cubemap face to which the color attachment will render, default is 0
|
|
161
|
+
* @param attachmentLayer - The texture layer to which the color attachment will render, default is 0
|
|
162
|
+
* @returns The fetched FrameBuffer object.
|
|
163
|
+
*/ fetchTemporalFramebuffer(autoRelease, width, height, colorTexOrFormat, depthTexOrFormat = null, mipmapping = false, sampleCount = 1, ignoreDepthStencil = true, attachmentMipLevel = 0, attachmentCubeface = 0, attachmentLayer = 0) {
|
|
164
|
+
const colors = Array.isArray(colorTexOrFormat) ? colorTexOrFormat : colorTexOrFormat ? [
|
|
153
165
|
colorTexOrFormat
|
|
154
|
-
] :
|
|
166
|
+
] : [];
|
|
167
|
+
const colorAttachments = colors.map((val)=>{
|
|
168
|
+
return typeof val === 'string' ? this.fetchTemporalTexture2D(false, val, width, height, mipmapping) : val;
|
|
169
|
+
});
|
|
155
170
|
const depthAttachment = typeof depthTexOrFormat === 'string' ? this.fetchTemporalTexture2D(false, depthTexOrFormat, width, height, false) : depthTexOrFormat;
|
|
156
|
-
const fb = this.createTemporalFramebuffer(autoRelease, colorAttachments, depthAttachment, sampleCount, ignoreDepthStencil);
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
const fb = this.createTemporalFramebuffer(autoRelease, colorAttachments, depthAttachment, sampleCount, ignoreDepthStencil, attachmentMipLevel, attachmentCubeface, attachmentLayer);
|
|
172
|
+
for(let i = 0; i < colors.length; i++){
|
|
173
|
+
if (typeof colors[i] === 'string') {
|
|
174
|
+
this.releaseTexture(colorAttachments[i]);
|
|
175
|
+
}
|
|
159
176
|
}
|
|
160
177
|
if (typeof depthTexOrFormat === 'string') {
|
|
161
178
|
this.releaseTexture(depthAttachment);
|
|
@@ -167,14 +184,20 @@
|
|
|
167
184
|
* @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
|
|
168
185
|
* @param colorAttachments - Array of color attachments for the framebuffer.
|
|
169
186
|
* @param depthAttachment - Depth attachment for the framebuffer.
|
|
170
|
-
* @param sampleCount - The sample count for the framebuffer.
|
|
171
|
-
* @param ignoreDepthStencil - Whether to ignore depth stencil.
|
|
187
|
+
* @param sampleCount - The sample count for the framebuffer, default is 1.
|
|
188
|
+
* @param ignoreDepthStencil - Whether to ignore depth stencil when resolving msaa framebuffer, default is true.
|
|
189
|
+
* @param attachmentMipLevel - The mipmap level to which the color attachment will render, default is 0.
|
|
190
|
+
* @param attachmentCubeface - The cubemap face to which the color attachment will render, default is 0.
|
|
191
|
+
* @param attachmentLayer - The texture layer to which the color attachment will render, default is 0.
|
|
172
192
|
* @returns The fetched FrameBuffer object.
|
|
173
|
-
*/ createTemporalFramebuffer(autoRelease, colorAttachments, depthAttachment, sampleCount, ignoreDepthStencil) {
|
|
193
|
+
*/ createTemporalFramebuffer(autoRelease, colorAttachments, depthAttachment = null, sampleCount = 1, ignoreDepthStencil = true, attachmentMipLevel = 0, attachmentCubeface = 0, attachmentLayer = 0) {
|
|
174
194
|
colorAttachments = colorAttachments ?? [];
|
|
175
195
|
let hash = `${depthAttachment?.uid ?? 0}:${sampleCount ?? 1}:${ignoreDepthStencil ? 1 : 0}`;
|
|
176
|
-
|
|
177
|
-
hash += `:${
|
|
196
|
+
if (colorAttachments.length > 0) {
|
|
197
|
+
hash += `:${attachmentMipLevel}:${attachmentCubeface}:${attachmentLayer}`;
|
|
198
|
+
for (const tex of colorAttachments){
|
|
199
|
+
hash += `:${tex.uid}`;
|
|
200
|
+
}
|
|
178
201
|
}
|
|
179
202
|
let fb = null;
|
|
180
203
|
const list = this._freeFramebuffers[hash];
|
|
@@ -183,10 +206,15 @@
|
|
|
183
206
|
ignoreDepthStencil,
|
|
184
207
|
sampleCount
|
|
185
208
|
});
|
|
209
|
+
for(let i = 0; i < fb.getColorAttachments().length; i++){
|
|
210
|
+
fb.setColorAttachmentMipLevel(i, attachmentMipLevel);
|
|
211
|
+
fb.setColorAttachmentCubeFace(i, attachmentCubeface);
|
|
212
|
+
fb.setColorAttachmentLayer(i, attachmentLayer);
|
|
213
|
+
}
|
|
186
214
|
} else {
|
|
187
215
|
fb = list.pop();
|
|
188
216
|
if (list.length === 0) {
|
|
189
|
-
|
|
217
|
+
this._freeFramebuffers[hash] = undefined;
|
|
190
218
|
}
|
|
191
219
|
}
|
|
192
220
|
// Mark referenced textures
|
package/dist/pool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pool.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zephyr3d/device",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Device API for zephyr3d",
|
|
5
5
|
"homepage": "https://github.com/gavinyork/zephyr3d#readme",
|
|
6
6
|
"type": "module",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@rollup/plugin-terser": "^0.4.0",
|
|
45
45
|
"@rollup/pluginutils": "^5.0.2",
|
|
46
46
|
"@swc/core": "^1.3.62",
|
|
47
|
-
"@zephyr3d/base": "^0.1.4",
|
|
48
47
|
"cross-env": "^7.0.3",
|
|
49
48
|
"rollup": "^3.15.0",
|
|
50
49
|
"rollup-plugin-copy": "^3.4.0",
|
|
@@ -54,12 +53,10 @@
|
|
|
54
53
|
"shx": "^0.3.4",
|
|
55
54
|
"typescript": "^5.1.3"
|
|
56
55
|
},
|
|
57
|
-
"peerDependencies": {
|
|
58
|
-
"@zephyr3d/base": "^0.1.4"
|
|
59
|
-
},
|
|
60
56
|
"dependencies": {
|
|
61
|
-
"@
|
|
62
|
-
"@webgpu/types": "^0.1.40"
|
|
57
|
+
"@zephyr3d/base": "^0.1.5",
|
|
58
|
+
"@webgpu/types": "^0.1.40",
|
|
59
|
+
"@types/node": "^18.13.0"
|
|
63
60
|
},
|
|
64
61
|
"scripts": {
|
|
65
62
|
"clean": "shx rm -rf ./dist .tsbuildinfo",
|