@zephyr3d/device 0.2.3 → 0.2.5
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/base_types.js +7 -66
- package/dist/base_types.js.map +1 -1
- package/dist/builder/ast.js +121 -118
- package/dist/builder/ast.js.map +1 -1
- package/dist/builder/base.js +29 -25
- package/dist/builder/base.js.map +1 -1
- package/dist/builder/builtinfunc.js +62 -19
- package/dist/builder/builtinfunc.js.map +1 -1
- package/dist/builder/constructors.js +1 -1
- package/dist/builder/constructors.js.map +1 -1
- package/dist/builder/errors.js +7 -7
- package/dist/builder/errors.js.map +1 -1
- package/dist/builder/misc.js +10 -0
- package/dist/builder/misc.js.map +1 -0
- package/dist/builder/programbuilder.js +65 -34
- package/dist/builder/programbuilder.js.map +1 -1
- package/dist/builder/reflection.js.map +1 -1
- package/dist/builder/types.js +74 -74
- package/dist/builder/types.js.map +1 -1
- package/dist/device.js +72 -43
- package/dist/device.js.map +1 -1
- package/dist/gpuobject.js +82 -24
- package/dist/gpuobject.js.map +1 -1
- package/dist/helpers/drawtext.js +1 -0
- package/dist/helpers/drawtext.js.map +1 -1
- package/dist/helpers/font.js +1 -0
- package/dist/helpers/font.js.map +1 -1
- package/dist/helpers/glyphmanager.js +7 -7
- package/dist/helpers/glyphmanager.js.map +1 -1
- package/dist/helpers/textureatlas.js +3 -5
- package/dist/helpers/textureatlas.js.map +1 -1
- package/dist/index.d.ts +267 -204
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/pool.js +102 -45
- package/dist/pool.js.map +1 -1
- package/dist/timer.js.map +1 -1
- package/dist/uniformdata.js +2 -2
- package/dist/uniformdata.js.map +1 -1
- package/dist/vertexdata.js +27 -1
- package/dist/vertexdata.js.map +1 -1
- package/package.json +31 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflection.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reflection.js","sources":["../../src/builder/reflection.ts"],"sourcesContent":["import type { PBGlobalScope, ProgramBuilder } from './programbuilder';\r\nimport type { PBShaderExp } from './base';\r\nimport type { VertexSemantic } from '../gpuobject';\r\n\r\n/**\r\n * Shader variable getter function type\r\n * @public\r\n */\r\nexport type PBReflectionTagGetter = (scope: PBGlobalScope) => PBShaderExp;\r\n\r\n/**\r\n * Reflection interface for program builder\r\n * @public\r\n */\r\nexport class PBReflection {\r\n /** @internal */\r\n private readonly _builder: ProgramBuilder;\r\n /** @internal */\r\n private _tagList: Record<string, PBReflectionTagGetter>;\r\n /** @internal */\r\n private _attribList: Record<string, PBShaderExp>;\r\n constructor(builder: ProgramBuilder) {\r\n this._builder = builder;\r\n this._tagList = {};\r\n this._attribList = {};\r\n }\r\n /** Gets all the vertex attributes that was used by the program */\r\n get vertexAttributes(): number[] {\r\n return this._builder.getVertexAttributes();\r\n }\r\n /**\r\n * Check if specified vertex attribute was used by the program\r\n * @param attrib - The vertex attribute to check\r\n */\r\n hasVertexAttribute(attrib: number): boolean {\r\n return this.vertexAttributes.indexOf(attrib) >= 0;\r\n }\r\n /**\r\n * Clear all contents\r\n */\r\n clear(): void {\r\n this._tagList = {};\r\n this._attribList = {};\r\n }\r\n /**\r\n * Gets the variable that has tagged with given string\r\n * @param name - The tag string\r\n */\r\n tag(name: string): PBShaderExp;\r\n /**\r\n * Creates a new tag by specifying a function to get the tagged variable\r\n * @param name - The tag name\r\n * @param getter - The getter function\r\n */\r\n tag(name: string, getter: PBReflectionTagGetter): void;\r\n /**\r\n * Creates multiple tags from an object that contains the tag names and the getter functions\r\n * @param values - The object that contains the tag names and the getter functions\r\n */\r\n tag(values: Record<string, PBReflectionTagGetter>): void;\r\n tag(\r\n arg0: string | Record<string, PBReflectionTagGetter>,\r\n arg1?: PBReflectionTagGetter\r\n ): PBShaderExp | void {\r\n if (typeof arg0 === 'string') {\r\n if (arg1 === undefined) {\r\n return this.getTag(arg0);\r\n } else {\r\n this.addTag(arg0, arg1);\r\n }\r\n } else {\r\n for (const k of Object.keys(arg0)) {\r\n this.addTag(k, arg0[k]);\r\n }\r\n }\r\n }\r\n /**\r\n * Gets the variable which is the vertex attribute of specified semantic\r\n * @param attrib - The vertex semantic\r\n */\r\n attribute(attrib: VertexSemantic): PBShaderExp {\r\n return this._attribList[attrib] || null;\r\n }\r\n /** @internal */\r\n setAttrib(attrib: VertexSemantic, exp: PBShaderExp) {\r\n this._attribList[attrib] = exp;\r\n }\r\n /** @internal */\r\n private addTag(name: string, exp: PBReflectionTagGetter): void {\r\n this._tagList[name] = exp;\r\n }\r\n /** @internal */\r\n private getTag(name: string): PBShaderExp {\r\n const getter = this._tagList[name];\r\n return getter ? getter(this._builder.getGlobalScope()) : null;\r\n }\r\n}\r\n"],"names":["PBReflection","builder","_builder","_tagList","_attribList","vertexAttributes","getVertexAttributes","hasVertexAttribute","attrib","indexOf","clear","tag","arg0","arg1","undefined","getTag","addTag","k","Object","keys","attribute","setAttrib","exp","name","getter","getGlobalScope"],"mappings":"AAUA;;;AAGC,IACM,MAAMA,YAAAA,CAAAA;qBAEX,QAA0C;qBAE1C,QAAwD;qBAExD,WAAiD;AACjD,IAAA,WAAA,CAAYC,OAAuB,CAAE;QACnC,IAAI,CAACC,QAAQ,GAAGD,OAAAA;QAChB,IAAI,CAACE,QAAQ,GAAG,EAAC;QACjB,IAAI,CAACC,WAAW,GAAG,EAAC;AACtB;uEAEA,IAAIC,gBAA6B,GAAA;AAC/B,QAAA,OAAO,IAAI,CAACH,QAAQ,CAACI,mBAAmB,EAAA;AAC1C;AACA;;;MAIAC,kBAAAA,CAAmBC,MAAc,EAAW;AAC1C,QAAA,OAAO,IAAI,CAACH,gBAAgB,CAACI,OAAO,CAACD,MAAW,CAAA,IAAA,CAAA;AAClD;AACA;;AAEC,MACDE,KAAc,GAAA;QACZ,IAAI,CAACP,QAAQ,GAAG,EAAC;QACjB,IAAI,CAACC,WAAW,GAAG,EAAC;AACtB;IAiBAO,GACEC,CAAAA,IAAoD,EACpDC,IAA4B,EACR;QACpB,IAAI,OAAOD,SAAS,QAAU,EAAA;AAC5B,YAAA,IAAIC,SAASC,SAAW,EAAA;gBACtB,OAAO,IAAI,CAACC,MAAM,CAACH,IAAAA,CAAAA;aACd,MAAA;gBACL,IAAI,CAACI,MAAM,CAACJ,IAAMC,EAAAA,IAAAA,CAAAA;AACpB;SACK,MAAA;AACL,YAAA,KAAK,MAAMI,CAAAA,IAAKC,MAAOC,CAAAA,IAAI,CAACP,IAAO,CAAA,CAAA;AACjC,gBAAA,IAAI,CAACI,MAAM,CAACC,CAAGL,EAAAA,IAAI,CAACK,CAAE,CAAA,CAAA;AACxB;AACF;AACF;AACA;;;MAIAG,SAAAA,CAAUZ,MAAsB,EAAe;AAC7C,QAAA,OAAO,IAAI,CAACJ,WAAW,CAACI,OAAO,IAAI,IAAA;AACrC;AACA,qBACAa,SAAAA,CAAUb,MAAsB,EAAEc,GAAgB,EAAE;AAClD,QAAA,IAAI,CAAClB,WAAW,CAACI,MAAAA,CAAO,GAAGc,GAAAA;AAC7B;AACA,qBACA,MAAQN,CAAOO,IAAY,EAAED,GAA0B,EAAQ;AAC7D,QAAA,IAAI,CAACnB,QAAQ,CAACoB,IAAAA,CAAK,GAAGD,GAAAA;AACxB;AACA,qBACQP,MAAOQ,CAAAA,IAAY,EAAe;AACxC,QAAA,MAAMC,MAAS,GAAA,IAAI,CAACrB,QAAQ,CAACoB,IAAK,CAAA;AAClC,QAAA,OAAOC,SAASA,MAAO,CAAA,IAAI,CAACtB,QAAQ,CAACuB,cAAc,EAAM,CAAA,GAAA,IAAA;AAC3D;AACF;;;;"}
|
package/dist/builder/types.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ASSERT } from '@zephyr3d/base';
|
|
2
|
+
|
|
1
3
|
const F16_BITMASK = 1;
|
|
2
4
|
const F32_BITMASK = 2;
|
|
3
5
|
const BOOL_BITMASK = 3;
|
|
@@ -32,7 +34,7 @@ function getAlignment(type) {
|
|
|
32
34
|
return Math.max(alignment, 16);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
|
-
function getAlignmentPacked(
|
|
37
|
+
function getAlignmentPacked(_type) {
|
|
36
38
|
return 1;
|
|
37
39
|
}
|
|
38
40
|
function getSize(type) {
|
|
@@ -100,8 +102,10 @@ function typeToTypedArray(type) {
|
|
|
100
102
|
return PBPrimitiveType.U8;
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Primitive types
|
|
107
|
+
* @public
|
|
108
|
+
*/ var PBPrimitiveType = /*#__PURE__*/ function(PBPrimitiveType) {
|
|
105
109
|
PBPrimitiveType[PBPrimitiveType["NONE"] = 0] = "NONE";
|
|
106
110
|
PBPrimitiveType[PBPrimitiveType["F16"] = makePrimitiveType(F16_BITMASK, 1, 1, 0)] = "F16";
|
|
107
111
|
PBPrimitiveType[PBPrimitiveType["F16VEC2"] = makePrimitiveType(F16_BITMASK, 1, 2, 0)] = "F16VEC2";
|
|
@@ -172,7 +176,8 @@ var PBPrimitiveType;
|
|
|
172
176
|
PBPrimitiveType[PBPrimitiveType["MAT4x2"] = makePrimitiveType(F32_BITMASK, 4, 2, 0)] = "MAT4x2";
|
|
173
177
|
PBPrimitiveType[PBPrimitiveType["MAT4x3"] = makePrimitiveType(F32_BITMASK, 4, 3, 0)] = "MAT4x3";
|
|
174
178
|
PBPrimitiveType[PBPrimitiveType["MAT4"] = makePrimitiveType(F32_BITMASK, 4, 4, 0)] = "MAT4";
|
|
175
|
-
|
|
179
|
+
return PBPrimitiveType;
|
|
180
|
+
}({});
|
|
176
181
|
const primitiveTypeMapWebGL = {
|
|
177
182
|
[PBPrimitiveType.F32]: 'float',
|
|
178
183
|
[PBPrimitiveType.F32VEC2]: 'vec2',
|
|
@@ -239,8 +244,10 @@ const BITFLAG_FLOAT = 1 << 8;
|
|
|
239
244
|
const BITFLAG_INT = 1 << 9;
|
|
240
245
|
const BITFLAG_UINT = 1 << 10;
|
|
241
246
|
const BITFLAG_EXTERNAL = 1 << 11;
|
|
242
|
-
|
|
243
|
-
|
|
247
|
+
/**
|
|
248
|
+
* Texture types
|
|
249
|
+
* @public
|
|
250
|
+
*/ var PBTextureType = /*#__PURE__*/ function(PBTextureType) {
|
|
244
251
|
PBTextureType[PBTextureType["TEX_1D"] = BITFLAG_1D | BITFLAG_FLOAT] = "TEX_1D";
|
|
245
252
|
PBTextureType[PBTextureType["ITEX_1D"] = BITFLAG_1D | BITFLAG_INT] = "ITEX_1D";
|
|
246
253
|
PBTextureType[PBTextureType["UTEX_1D"] = BITFLAG_1D | BITFLAG_UINT] = "UTEX_1D";
|
|
@@ -272,7 +279,8 @@ var PBTextureType;
|
|
|
272
279
|
PBTextureType[PBTextureType["TEX_DEPTH_CUBE_ARRAY"] = BITFLAG_CUBE | BITFLAG_ARRAY | BITFLAG_DEPTH] = "TEX_DEPTH_CUBE_ARRAY";
|
|
273
280
|
PBTextureType[PBTextureType["TEX_DEPTH_MULTISAMPLED_2D"] = BITFLAG_2D | BITFLAG_MULTISAMPLED | BITFLAG_DEPTH] = "TEX_DEPTH_MULTISAMPLED_2D";
|
|
274
281
|
PBTextureType[PBTextureType["TEX_EXTERNAL"] = BITFLAG_EXTERNAL] = "TEX_EXTERNAL";
|
|
275
|
-
|
|
282
|
+
return PBTextureType;
|
|
283
|
+
}({});
|
|
276
284
|
const textureTypeMapWebGL = {
|
|
277
285
|
[PBTextureType.TEX_1D]: 'highp sampler2D',
|
|
278
286
|
[PBTextureType.TEX_2D]: 'highp sampler2D',
|
|
@@ -352,35 +360,27 @@ const storageTexelFormatMap = {
|
|
|
352
360
|
rgba32ui: 'rgba32uint',
|
|
353
361
|
rgba32i: 'rgba32sint'
|
|
354
362
|
};
|
|
355
|
-
|
|
356
|
-
|
|
363
|
+
/**
|
|
364
|
+
* Sampler access mode
|
|
365
|
+
* @public
|
|
366
|
+
*/ var PBSamplerAccessMode = /*#__PURE__*/ function(PBSamplerAccessMode) {
|
|
357
367
|
PBSamplerAccessMode[PBSamplerAccessMode["UNKNOWN"] = 0] = "UNKNOWN";
|
|
358
368
|
PBSamplerAccessMode[PBSamplerAccessMode["SAMPLE"] = 1] = "SAMPLE";
|
|
359
369
|
PBSamplerAccessMode[PBSamplerAccessMode["COMPARISON"] = 2] = "COMPARISON";
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
PBAddressSpace["
|
|
367
|
-
PBAddressSpace["
|
|
368
|
-
PBAddressSpace["
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
PBTypeClass[PBTypeClass["ARRAY"] = 2] = "ARRAY";
|
|
375
|
-
PBTypeClass[PBTypeClass["POINTER"] = 3] = "POINTER";
|
|
376
|
-
PBTypeClass[PBTypeClass["ATOMIC_I32"] = 4] = "ATOMIC_I32";
|
|
377
|
-
PBTypeClass[PBTypeClass["ATOMIC_U32"] = 5] = "ATOMIC_U32";
|
|
378
|
-
PBTypeClass[PBTypeClass["TEXTURE"] = 6] = "TEXTURE";
|
|
379
|
-
PBTypeClass[PBTypeClass["SAMPLER"] = 7] = "SAMPLER";
|
|
380
|
-
PBTypeClass[PBTypeClass["FUNCTION"] = 8] = "FUNCTION";
|
|
381
|
-
PBTypeClass[PBTypeClass["VOID"] = 9] = "VOID";
|
|
382
|
-
PBTypeClass[PBTypeClass["ANY"] = 10] = "ANY";
|
|
383
|
-
})(PBTypeClass || (PBTypeClass = {}));
|
|
370
|
+
return PBSamplerAccessMode;
|
|
371
|
+
}({});
|
|
372
|
+
/**
|
|
373
|
+
* Shader variable address space
|
|
374
|
+
* @public
|
|
375
|
+
*/ var PBAddressSpace = /*#__PURE__*/ function(PBAddressSpace) {
|
|
376
|
+
PBAddressSpace["UNKNOWN"] = "unknown";
|
|
377
|
+
PBAddressSpace["FUNCTION"] = "function";
|
|
378
|
+
PBAddressSpace["PRIVATE"] = "private";
|
|
379
|
+
PBAddressSpace["WORKGROUP"] = "workgroup";
|
|
380
|
+
PBAddressSpace["UNIFORM"] = "uniform";
|
|
381
|
+
PBAddressSpace["STORAGE"] = "storage";
|
|
382
|
+
return PBAddressSpace;
|
|
383
|
+
}({});
|
|
384
384
|
/**
|
|
385
385
|
* Abstract base class for any type
|
|
386
386
|
* @public
|
|
@@ -441,7 +441,7 @@ var PBTypeClass;
|
|
|
441
441
|
/** @internal */ isStorable() {
|
|
442
442
|
return false;
|
|
443
443
|
}
|
|
444
|
-
/** @internal */ getConstructorOverloads(
|
|
444
|
+
/** @internal */ getConstructorOverloads(_deviceType) {
|
|
445
445
|
return [];
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
@@ -457,18 +457,18 @@ var PBTypeClass;
|
|
|
457
457
|
* @public
|
|
458
458
|
*/ class PBVoidTypeInfo extends PBTypeInfo {
|
|
459
459
|
constructor(){
|
|
460
|
-
super(
|
|
460
|
+
super(9, null);
|
|
461
461
|
}
|
|
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() {
|
|
469
469
|
return 'void';
|
|
470
470
|
}
|
|
471
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
471
|
+
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(_offset) {
|
|
472
472
|
return null;
|
|
473
473
|
}
|
|
474
474
|
}
|
|
@@ -477,21 +477,21 @@ var PBTypeClass;
|
|
|
477
477
|
* @public
|
|
478
478
|
*/ class PBAnyTypeInfo extends PBTypeInfo {
|
|
479
479
|
constructor(){
|
|
480
|
-
super(
|
|
480
|
+
super(10, null);
|
|
481
481
|
}
|
|
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() {
|
|
489
489
|
return 'any';
|
|
490
490
|
}
|
|
491
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
491
|
+
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(_offset) {
|
|
492
492
|
return null;
|
|
493
493
|
}
|
|
494
|
-
/** {@inheritDoc PBTypeInfo.isCompatibleType} */ isCompatibleType(
|
|
494
|
+
/** {@inheritDoc PBTypeInfo.isCompatibleType} */ isCompatibleType(_other) {
|
|
495
495
|
return true;
|
|
496
496
|
}
|
|
497
497
|
}
|
|
@@ -502,7 +502,7 @@ var PBTypeClass;
|
|
|
502
502
|
/** @internal */ static cachedTypes = {};
|
|
503
503
|
/** @internal */ static cachedCtorOverloads = {};
|
|
504
504
|
constructor(type){
|
|
505
|
-
super(
|
|
505
|
+
super(1, {
|
|
506
506
|
primitiveType: type
|
|
507
507
|
});
|
|
508
508
|
}
|
|
@@ -785,7 +785,7 @@ var PBTypeClass;
|
|
|
785
785
|
return varName ? `${typename} ${varName}` : typename;
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
788
|
+
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(_offset) {
|
|
789
789
|
return null;
|
|
790
790
|
}
|
|
791
791
|
/** @internal */ genTypeId() {
|
|
@@ -797,7 +797,7 @@ var PBTypeClass;
|
|
|
797
797
|
* @public
|
|
798
798
|
*/ class PBStructTypeInfo extends PBTypeInfo {
|
|
799
799
|
constructor(name, layout, members){
|
|
800
|
-
super(
|
|
800
|
+
super(1, {
|
|
801
801
|
layout: layout || 'default',
|
|
802
802
|
structName: name,
|
|
803
803
|
structMembers: members.map((val)=>{
|
|
@@ -979,7 +979,7 @@ var PBTypeClass;
|
|
|
979
979
|
}
|
|
980
980
|
/** @internal */ calcAlignmentAndSizePacked() {
|
|
981
981
|
for (const member of this.structMembers){
|
|
982
|
-
member.alignment = getAlignmentPacked(
|
|
982
|
+
member.alignment = getAlignmentPacked();
|
|
983
983
|
member.size = getSizePacked(member.type);
|
|
984
984
|
}
|
|
985
985
|
}
|
|
@@ -989,7 +989,7 @@ var PBTypeClass;
|
|
|
989
989
|
* @public
|
|
990
990
|
*/ class PBArrayTypeInfo extends PBTypeInfo {
|
|
991
991
|
constructor(elementType, dimension){
|
|
992
|
-
super(
|
|
992
|
+
super(2, {
|
|
993
993
|
elementType: elementType,
|
|
994
994
|
dimension: Number(dimension) || 0
|
|
995
995
|
});
|
|
@@ -1039,8 +1039,8 @@ var PBTypeClass;
|
|
|
1039
1039
|
const typename = `array<${elementTypeName}${this.dimension ? ', ' + this.dimension : ''}>`;
|
|
1040
1040
|
return varName ? `${varName}: ${typename}` : typename;
|
|
1041
1041
|
} else {
|
|
1042
|
-
|
|
1043
|
-
|
|
1042
|
+
ASSERT(!!this.dimension, 'runtime-sized array not supported for webgl');
|
|
1043
|
+
ASSERT(!this.elementType.isArrayType(), 'multi-dimensional arrays not supported for webgl');
|
|
1044
1044
|
const elementTypeName = this.elementType.toTypeName(deviceType, varName);
|
|
1045
1045
|
return `${elementTypeName}[${this.dimension}]`;
|
|
1046
1046
|
}
|
|
@@ -1056,7 +1056,7 @@ var PBTypeClass;
|
|
|
1056
1056
|
}
|
|
1057
1057
|
return this.elementType.isAnyType() ? 0 : this.dimension * align(this.elementType.getLayoutSize(layout), elementAlignment);
|
|
1058
1058
|
}
|
|
1059
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
1059
|
+
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(_offset) {
|
|
1060
1060
|
return null;
|
|
1061
1061
|
}
|
|
1062
1062
|
isCompatibleType(other) {
|
|
@@ -1078,11 +1078,11 @@ var PBTypeClass;
|
|
|
1078
1078
|
*/ class PBPointerTypeInfo extends PBTypeInfo {
|
|
1079
1079
|
/** @internal */ writable;
|
|
1080
1080
|
constructor(pointerType, addressSpace){
|
|
1081
|
-
super(
|
|
1081
|
+
super(3, {
|
|
1082
1082
|
pointerType,
|
|
1083
1083
|
addressSpace
|
|
1084
1084
|
});
|
|
1085
|
-
|
|
1085
|
+
ASSERT(pointerType.isStorable(), 'the pointee type must be storable');
|
|
1086
1086
|
this.writable = false;
|
|
1087
1087
|
}
|
|
1088
1088
|
/** Get type of the pointer */ get pointerType() {
|
|
@@ -1105,7 +1105,7 @@ var PBTypeClass;
|
|
|
1105
1105
|
}
|
|
1106
1106
|
/** @internal */ toTypeName(device, varName) {
|
|
1107
1107
|
if (device === 'webgpu') {
|
|
1108
|
-
const addressSpace = this.addressSpace ===
|
|
1108
|
+
const addressSpace = this.addressSpace === "unknown" ? "function" : this.addressSpace;
|
|
1109
1109
|
/*
|
|
1110
1110
|
const mode = addressSpace === PBAddressSpace.UNIFORM || (addressSpace === PBAddressSpace.STORAGE && !this.writable) ? 'read' : 'read_write'
|
|
1111
1111
|
const typename = `ptr<${addressSpace}, ${this.pointerType.toTypeName(device)}, ${mode}>`;
|
|
@@ -1113,14 +1113,14 @@ var PBTypeClass;
|
|
|
1113
1113
|
When writing a variable declaration or a pointer type in WGSL source:
|
|
1114
1114
|
For the storage address space, the access mode is optional, and defaults to read.
|
|
1115
1115
|
For other address spaces, the access mode must not be written.
|
|
1116
|
-
*/ const mode = addressSpace ===
|
|
1116
|
+
*/ const mode = addressSpace === "storage" && this.writable ? ', read_write' : '';
|
|
1117
1117
|
const typename = `ptr<${addressSpace}, ${this.pointerType.toTypeName(device)} ${mode}>`;
|
|
1118
1118
|
return varName ? `${varName}: ${typename}` : typename;
|
|
1119
1119
|
} else {
|
|
1120
1120
|
throw new Error('pointer type not supported for webgl');
|
|
1121
1121
|
}
|
|
1122
1122
|
}
|
|
1123
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
1123
|
+
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(_offset) {
|
|
1124
1124
|
return null;
|
|
1125
1125
|
}
|
|
1126
1126
|
/** @internal */ genTypeId() {
|
|
@@ -1132,7 +1132,7 @@ var PBTypeClass;
|
|
|
1132
1132
|
* @public
|
|
1133
1133
|
*/ class PBAtomicI32TypeInfo extends PBTypeInfo {
|
|
1134
1134
|
constructor(){
|
|
1135
|
-
super(
|
|
1135
|
+
super(4, null);
|
|
1136
1136
|
}
|
|
1137
1137
|
/** {@inheritDoc PBTypeInfo.isPointerType} */ haveAtomicMembers() {
|
|
1138
1138
|
return true;
|
|
@@ -1154,10 +1154,10 @@ var PBTypeClass;
|
|
|
1154
1154
|
throw new Error('atomic type not supported for webgl');
|
|
1155
1155
|
}
|
|
1156
1156
|
}
|
|
1157
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
1157
|
+
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(_offset) {
|
|
1158
1158
|
return null;
|
|
1159
1159
|
}
|
|
1160
|
-
/** @internal */ getLayoutAlignment(
|
|
1160
|
+
/** @internal */ getLayoutAlignment(_layout) {
|
|
1161
1161
|
return 4;
|
|
1162
1162
|
}
|
|
1163
1163
|
/** @internal */ getLayoutSize() {
|
|
@@ -1175,7 +1175,7 @@ var PBTypeClass;
|
|
|
1175
1175
|
* @public
|
|
1176
1176
|
*/ class PBAtomicU32TypeInfo extends PBTypeInfo {
|
|
1177
1177
|
constructor(){
|
|
1178
|
-
super(
|
|
1178
|
+
super(5, null);
|
|
1179
1179
|
}
|
|
1180
1180
|
/** {@inheritDoc PBTypeInfo.isPointerType} */ haveAtomicMembers() {
|
|
1181
1181
|
return true;
|
|
@@ -1197,10 +1197,10 @@ var PBTypeClass;
|
|
|
1197
1197
|
throw new Error('atomic type not supported for webgl');
|
|
1198
1198
|
}
|
|
1199
1199
|
}
|
|
1200
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
1200
|
+
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(_offset) {
|
|
1201
1201
|
return null;
|
|
1202
1202
|
}
|
|
1203
|
-
/** @internal */ getLayoutAlignment(
|
|
1203
|
+
/** @internal */ getLayoutAlignment(_layout) {
|
|
1204
1204
|
return 4;
|
|
1205
1205
|
}
|
|
1206
1206
|
/** @internal */ getLayoutSize() {
|
|
@@ -1218,7 +1218,7 @@ var PBTypeClass;
|
|
|
1218
1218
|
* @public
|
|
1219
1219
|
*/ class PBSamplerTypeInfo extends PBTypeInfo {
|
|
1220
1220
|
constructor(accessMode){
|
|
1221
|
-
super(
|
|
1221
|
+
super(7, {
|
|
1222
1222
|
accessMode: accessMode
|
|
1223
1223
|
});
|
|
1224
1224
|
}
|
|
@@ -1233,13 +1233,13 @@ var PBTypeClass;
|
|
|
1233
1233
|
}
|
|
1234
1234
|
/** @internal */ toTypeName(deviceType, varName) {
|
|
1235
1235
|
if (deviceType === 'webgpu') {
|
|
1236
|
-
const typename = this.accessMode ===
|
|
1236
|
+
const typename = this.accessMode === 1 ? 'sampler' : 'sampler_comparison';
|
|
1237
1237
|
return varName ? `${varName}: ${typename}` : typename;
|
|
1238
1238
|
} else {
|
|
1239
1239
|
throw new Error('sampler type not supported for webgl');
|
|
1240
1240
|
}
|
|
1241
1241
|
}
|
|
1242
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
1242
|
+
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(_offset) {
|
|
1243
1243
|
return null;
|
|
1244
1244
|
}
|
|
1245
1245
|
/** @internal */ genTypeId() {
|
|
@@ -1251,14 +1251,14 @@ var PBTypeClass;
|
|
|
1251
1251
|
* @public
|
|
1252
1252
|
*/ class PBTextureTypeInfo extends PBTypeInfo {
|
|
1253
1253
|
constructor(textureType, texelFormat, readable, writable){
|
|
1254
|
-
super(
|
|
1254
|
+
super(6, {
|
|
1255
1255
|
textureType: textureType,
|
|
1256
1256
|
readable,
|
|
1257
1257
|
writable,
|
|
1258
1258
|
storageTexelFormat: texelFormat || null
|
|
1259
1259
|
});
|
|
1260
|
-
|
|
1261
|
-
|
|
1260
|
+
ASSERT(!!textureTypeMapWGSL[textureType], 'unsupported texture type');
|
|
1261
|
+
ASSERT(!(textureType & BITFLAG_STORAGE) || !!storageTexelFormatMap[texelFormat], 'invalid texel format for storage texture');
|
|
1262
1262
|
}
|
|
1263
1263
|
/** Get the texture type */ get textureType() {
|
|
1264
1264
|
return this.detail.textureType;
|
|
@@ -1329,15 +1329,15 @@ var PBTypeClass;
|
|
|
1329
1329
|
return varName ? `${varName}: ${typename}` : typename;
|
|
1330
1330
|
} else {
|
|
1331
1331
|
const typename = (deviceType === 'webgl' ? textureTypeMapWebGL : textureTypeMapWebGL2)[this.textureType];
|
|
1332
|
-
|
|
1332
|
+
ASSERT(!!typename, 'unsupported texture type');
|
|
1333
1333
|
return varName ? `${typename} ${varName}` : typename;
|
|
1334
1334
|
}
|
|
1335
1335
|
}
|
|
1336
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
1336
|
+
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(_offset) {
|
|
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
|
/**
|
|
@@ -1345,7 +1345,7 @@ var PBTypeClass;
|
|
|
1345
1345
|
* @public
|
|
1346
1346
|
*/ class PBFunctionTypeInfo extends PBTypeInfo {
|
|
1347
1347
|
constructor(name, returnType, argTypes){
|
|
1348
|
-
super(
|
|
1348
|
+
super(8, {
|
|
1349
1349
|
name,
|
|
1350
1350
|
returnType,
|
|
1351
1351
|
argTypes
|
|
@@ -1366,10 +1366,10 @@ var PBTypeClass;
|
|
|
1366
1366
|
/** @internal */ genTypeId() {
|
|
1367
1367
|
return `fn(${this.argHash}):${this.returnType.typeId}`;
|
|
1368
1368
|
}
|
|
1369
|
-
/** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(
|
|
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
|
}
|
|
@@ -1539,8 +1539,8 @@ var PBTypeClass;
|
|
|
1539
1539
|
/** @internal */ const typeTexDepthCube = new PBTextureTypeInfo(PBTextureType.TEX_DEPTH_CUBE);
|
|
1540
1540
|
/** @internal */ const typeTexDepthCubeArray = new PBTextureTypeInfo(PBTextureType.TEX_DEPTH_CUBE_ARRAY);
|
|
1541
1541
|
/** @internal */ const typeTexDepthMultisampled2D = new PBTextureTypeInfo(PBTextureType.TEX_DEPTH_MULTISAMPLED_2D);
|
|
1542
|
-
/** @internal */ const typeSampler = new PBSamplerTypeInfo(
|
|
1543
|
-
/** @internal */ const typeSamplerComparison = new PBSamplerTypeInfo(
|
|
1542
|
+
/** @internal */ const typeSampler = new PBSamplerTypeInfo(1);
|
|
1543
|
+
/** @internal */ const typeSamplerComparison = new PBSamplerTypeInfo(2);
|
|
1544
1544
|
/** @internal */ const typeVoid = new PBVoidTypeInfo();
|
|
1545
1545
|
/** @internal */ const typeAny = new PBAnyTypeInfo();
|
|
1546
1546
|
/** @internal */ const typeFrexpResult = new PBStructTypeInfo('FrexpResult', 'default', [
|