@zephyr3d/device 0.2.4 → 0.2.6
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/dist/base_types.js +19 -79
- package/dist/base_types.js.map +1 -1
- package/dist/builder/ast.js +142 -162
- package/dist/builder/ast.js.map +1 -1
- package/dist/builder/base.js +29 -27
- package/dist/builder/base.js.map +1 -1
- package/dist/builder/builtinfunc.js +61 -7
- package/dist/builder/builtinfunc.js.map +1 -1
- package/dist/builder/constructors.js +3 -1
- package/dist/builder/constructors.js.map +1 -1
- package/dist/builder/errors.js +11 -11
- 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 +62 -58
- package/dist/builder/programbuilder.js.map +1 -1
- package/dist/builder/reflection.js +1 -1
- package/dist/builder/reflection.js.map +1 -1
- package/dist/builder/types.js +76 -75
- package/dist/builder/types.js.map +1 -1
- package/dist/device.js +220 -80
- package/dist/device.js.map +1 -1
- package/dist/gpuobject.js +84 -25
- package/dist/gpuobject.js.map +1 -1
- package/dist/helpers/drawtext.js +30 -25
- 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 +33 -15
- package/dist/helpers/glyphmanager.js.map +1 -1
- package/dist/helpers/textureatlas.js +10 -8
- package/dist/helpers/textureatlas.js.map +1 -1
- package/dist/index.d.ts +465 -394
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/pool.js +69 -31
- package/dist/pool.js.map +1 -1
- package/dist/timer.js +3 -2
- package/dist/timer.js.map +1 -1
- package/dist/uniformdata.js +3 -3
- package/dist/uniformdata.js.map +1 -1
- package/dist/vertexdata.js +29 -3
- package/dist/vertexdata.js.map +1 -1
- package/package.json +80 -65
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TypedArray,
|
|
1
|
+
import { Nullable, Immutable, TypedArray, IDisposable, CubeFace, VectorBase, MaybeArray, IEventTarget, Vector4, Observable } from '@zephyr3d/base';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Struct layout types
|
|
@@ -149,7 +149,7 @@ type TypeDetailInfo = PrimitiveTypeDetail | StructTypeDetail | ArrayTypeDetail |
|
|
|
149
149
|
* @public
|
|
150
150
|
*/
|
|
151
151
|
interface PrimitiveTypeDetail {
|
|
152
|
-
primitiveType
|
|
152
|
+
primitiveType: PBPrimitiveType;
|
|
153
153
|
}
|
|
154
154
|
/**
|
|
155
155
|
* Detail informations for struct type
|
|
@@ -159,9 +159,9 @@ interface StructTypeDetail {
|
|
|
159
159
|
/** Layout of the struct type */
|
|
160
160
|
layout: PBStructLayout;
|
|
161
161
|
/** Name of the struct type */
|
|
162
|
-
structName
|
|
162
|
+
structName: Nullable<string>;
|
|
163
163
|
/** Members of the struct type */
|
|
164
|
-
structMembers
|
|
164
|
+
structMembers: {
|
|
165
165
|
/** Name of the struct member */
|
|
166
166
|
name: string;
|
|
167
167
|
/** Type of the struct member */
|
|
@@ -216,7 +216,7 @@ interface TextureTypeDetail {
|
|
|
216
216
|
/** type of the texture */
|
|
217
217
|
textureType: PBTextureType;
|
|
218
218
|
/** texture format if this is a storage texture */
|
|
219
|
-
storageTexelFormat: TextureFormat
|
|
219
|
+
storageTexelFormat: Nullable<TextureFormat>;
|
|
220
220
|
/** true if this is a readable storage texture type */
|
|
221
221
|
readable: boolean;
|
|
222
222
|
/** true if this is a writable storage texture type */
|
|
@@ -280,7 +280,7 @@ declare abstract class PBTypeInfo<DetailType extends TypeDetailInfo = TypeDetail
|
|
|
280
280
|
* @param layout - Type of the layout
|
|
281
281
|
* @returns The created buffer layout
|
|
282
282
|
*/
|
|
283
|
-
abstract toBufferLayout(offset: number, layout: PBStructLayout): UniformBufferLayout
|
|
283
|
+
abstract toBufferLayout(offset: number, layout: PBStructLayout): Nullable<UniformBufferLayout>;
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
286
|
* The void type info
|
|
@@ -291,7 +291,7 @@ declare class PBVoidTypeInfo extends PBTypeInfo<null> {
|
|
|
291
291
|
/** {@inheritDoc PBTypeInfo.isVoidType} */
|
|
292
292
|
isVoidType(): this is PBVoidTypeInfo;
|
|
293
293
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
294
|
-
toBufferLayout(
|
|
294
|
+
toBufferLayout(_offset: number): null;
|
|
295
295
|
}
|
|
296
296
|
/**
|
|
297
297
|
* The void type info
|
|
@@ -302,9 +302,9 @@ declare class PBAnyTypeInfo extends PBTypeInfo<null> {
|
|
|
302
302
|
/** {@inheritDoc PBTypeInfo.isAnyType} */
|
|
303
303
|
isAnyType(): this is PBAnyTypeInfo;
|
|
304
304
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
305
|
-
toBufferLayout(
|
|
305
|
+
toBufferLayout(_offset: number): null;
|
|
306
306
|
/** {@inheritDoc PBTypeInfo.isCompatibleType} */
|
|
307
|
-
isCompatibleType(
|
|
307
|
+
isCompatibleType(_other: PBTypeInfo<TypeDetailInfo>): boolean;
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* The primitive type info
|
|
@@ -342,28 +342,28 @@ declare class PBPrimitiveTypeInfo extends PBTypeInfo<PrimitiveTypeDetail> {
|
|
|
342
342
|
/** {@inheritDoc PBTypeInfo.isPrimitiveType} */
|
|
343
343
|
isPrimitiveType(): this is PBPrimitiveTypeInfo;
|
|
344
344
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
345
|
-
toBufferLayout(
|
|
345
|
+
toBufferLayout(_offset: number): null;
|
|
346
346
|
}
|
|
347
347
|
/**
|
|
348
348
|
* The struct type info
|
|
349
349
|
* @public
|
|
350
350
|
*/
|
|
351
351
|
declare class PBStructTypeInfo extends PBTypeInfo<StructTypeDetail> {
|
|
352
|
-
constructor(name: string
|
|
352
|
+
constructor(name: Nullable<string>, layout: PBStructLayout, members: {
|
|
353
353
|
name: string;
|
|
354
354
|
type: PBPrimitiveTypeInfo | PBArrayTypeInfo | PBAtomicI32TypeInfo | PBAtomicU32TypeInfo | PBStructTypeInfo;
|
|
355
355
|
}[]);
|
|
356
356
|
/** Get the layout type */
|
|
357
357
|
get layout(): PBStructLayout;
|
|
358
358
|
/** Get name of the struct type */
|
|
359
|
-
get structName(): string
|
|
360
|
-
set structName(val: string);
|
|
359
|
+
get structName(): Nullable<string>;
|
|
360
|
+
set structName(val: Nullable<string>);
|
|
361
361
|
/** Get member types of the struct type */
|
|
362
362
|
get structMembers(): {
|
|
363
363
|
/** Name of the struct member */
|
|
364
364
|
name: string;
|
|
365
365
|
/** Type of the struct member */
|
|
366
|
-
type: PBPrimitiveTypeInfo | PBArrayTypeInfo |
|
|
366
|
+
type: PBPrimitiveTypeInfo | PBArrayTypeInfo | PBAtomicI32TypeInfo | PBAtomicU32TypeInfo | PBStructTypeInfo;
|
|
367
367
|
/** Alignment of the struct member */
|
|
368
368
|
alignment: number;
|
|
369
369
|
/** Byte size of the struct member */
|
|
@@ -397,7 +397,7 @@ declare class PBStructTypeInfo extends PBTypeInfo<StructTypeDetail> {
|
|
|
397
397
|
declare class PBArrayTypeInfo extends PBTypeInfo<ArrayTypeDetail> {
|
|
398
398
|
constructor(elementType: PBPrimitiveTypeInfo | PBArrayTypeInfo | PBStructTypeInfo | PBAnyTypeInfo | PBAtomicI32TypeInfo | PBAtomicU32TypeInfo, dimension?: number);
|
|
399
399
|
/** Get the element type */
|
|
400
|
-
get elementType(): PBPrimitiveTypeInfo | PBArrayTypeInfo | PBStructTypeInfo |
|
|
400
|
+
get elementType(): PBPrimitiveTypeInfo | PBArrayTypeInfo | PBStructTypeInfo | PBAtomicI32TypeInfo | PBAtomicU32TypeInfo | PBAnyTypeInfo;
|
|
401
401
|
/** Get dimension of the array type */
|
|
402
402
|
get dimension(): number;
|
|
403
403
|
/** Wether array have atomic members */
|
|
@@ -405,7 +405,7 @@ declare class PBArrayTypeInfo extends PBTypeInfo<ArrayTypeDetail> {
|
|
|
405
405
|
/** {@inheritDoc PBTypeInfo.isArrayType} */
|
|
406
406
|
isArrayType(): this is PBArrayTypeInfo;
|
|
407
407
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
408
|
-
toBufferLayout(
|
|
408
|
+
toBufferLayout(_offset: number): null;
|
|
409
409
|
isCompatibleType(other: PBTypeInfo<TypeDetailInfo>): boolean;
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
@@ -415,7 +415,7 @@ declare class PBArrayTypeInfo extends PBTypeInfo<ArrayTypeDetail> {
|
|
|
415
415
|
declare class PBPointerTypeInfo extends PBTypeInfo<PointerTypeDetail> {
|
|
416
416
|
constructor(pointerType: PBTypeInfo, addressSpace: PBAddressSpace);
|
|
417
417
|
/** Get type of the pointer */
|
|
418
|
-
get pointerType(): PBTypeInfo
|
|
418
|
+
get pointerType(): PBTypeInfo<TypeDetailInfo>;
|
|
419
419
|
/** Get address space of the pointer */
|
|
420
420
|
get addressSpace(): PBAddressSpace;
|
|
421
421
|
set addressSpace(val: PBAddressSpace);
|
|
@@ -424,7 +424,7 @@ declare class PBPointerTypeInfo extends PBTypeInfo<PointerTypeDetail> {
|
|
|
424
424
|
/** {@inheritDoc PBTypeInfo.isPointerType} */
|
|
425
425
|
isPointerType(): this is PBPointerTypeInfo;
|
|
426
426
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
427
|
-
toBufferLayout(
|
|
427
|
+
toBufferLayout(_offset: number): null;
|
|
428
428
|
}
|
|
429
429
|
/**
|
|
430
430
|
* The atomic int type info
|
|
@@ -435,7 +435,7 @@ declare class PBAtomicI32TypeInfo extends PBTypeInfo<null> {
|
|
|
435
435
|
/** {@inheritDoc PBTypeInfo.isPointerType} */
|
|
436
436
|
haveAtomicMembers(): boolean;
|
|
437
437
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
438
|
-
toBufferLayout(
|
|
438
|
+
toBufferLayout(_offset: number): null;
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
441
441
|
* The atomic int type info
|
|
@@ -446,7 +446,7 @@ declare class PBAtomicU32TypeInfo extends PBTypeInfo<null> {
|
|
|
446
446
|
/** {@inheritDoc PBTypeInfo.isPointerType} */
|
|
447
447
|
haveAtomicMembers(): boolean;
|
|
448
448
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
449
|
-
toBufferLayout(
|
|
449
|
+
toBufferLayout(_offset: number): null;
|
|
450
450
|
}
|
|
451
451
|
/**
|
|
452
452
|
* The sampler type info
|
|
@@ -457,7 +457,7 @@ declare class PBSamplerTypeInfo extends PBTypeInfo<SamplerTypeDetail> {
|
|
|
457
457
|
/** Get the access mode */
|
|
458
458
|
get accessMode(): PBSamplerAccessMode;
|
|
459
459
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
460
|
-
toBufferLayout(
|
|
460
|
+
toBufferLayout(_offset: number): null;
|
|
461
461
|
}
|
|
462
462
|
/**
|
|
463
463
|
* The texture type info
|
|
@@ -468,7 +468,7 @@ declare class PBTextureTypeInfo extends PBTypeInfo<TextureTypeDetail> {
|
|
|
468
468
|
/** Get the texture type */
|
|
469
469
|
get textureType(): PBTextureType;
|
|
470
470
|
/** Get texture format if this is a storage texture */
|
|
471
|
-
get storageTexelFormat(): TextureFormat
|
|
471
|
+
get storageTexelFormat(): Nullable<TextureFormat>;
|
|
472
472
|
/** Returns true if this is a readable storage texture type */
|
|
473
473
|
get readable(): boolean;
|
|
474
474
|
set readable(val: boolean);
|
|
@@ -496,7 +496,7 @@ declare class PBTextureTypeInfo extends PBTypeInfo<TextureTypeDetail> {
|
|
|
496
496
|
/** Returns true if the texture format is of type unsigned integer */
|
|
497
497
|
isUIntTexture(): boolean;
|
|
498
498
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
499
|
-
toBufferLayout(
|
|
499
|
+
toBufferLayout(_offset: number): null;
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
502
502
|
* The function type info
|
|
@@ -510,16 +510,18 @@ declare class PBFunctionTypeInfo extends PBTypeInfo<FunctionTypeDetail> {
|
|
|
510
510
|
/** Get name of the function */
|
|
511
511
|
get name(): string;
|
|
512
512
|
/** Get return type of the function */
|
|
513
|
-
get returnType(): PBTypeInfo
|
|
513
|
+
get returnType(): PBTypeInfo<TypeDetailInfo>;
|
|
514
514
|
/** Get all the argument types for this function */
|
|
515
515
|
get argTypes(): {
|
|
516
|
+
/** Type of the argument */
|
|
516
517
|
type: PBTypeInfo;
|
|
518
|
+
/** true if this argument will be passed by reference */
|
|
517
519
|
byRef?: boolean;
|
|
518
520
|
}[];
|
|
519
521
|
/** Get hash for parameter types */
|
|
520
522
|
get argHash(): string;
|
|
521
523
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
522
|
-
toBufferLayout(
|
|
524
|
+
toBufferLayout(_offset: number): null;
|
|
523
525
|
}
|
|
524
526
|
|
|
525
527
|
/**
|
|
@@ -546,9 +548,11 @@ declare class VertexData {
|
|
|
546
548
|
*/
|
|
547
549
|
clone(): VertexData;
|
|
548
550
|
/** Vertex buffer information list */
|
|
549
|
-
get vertexBuffers(): VertexBufferInfo[];
|
|
551
|
+
get vertexBuffers(): Nullable<VertexBufferInfo>[];
|
|
550
552
|
/** Index buffer */
|
|
551
|
-
get indexBuffer(): IndexBuffer<unknown
|
|
553
|
+
get indexBuffer(): Nullable<IndexBuffer<unknown>>;
|
|
554
|
+
/** Number of vertices */
|
|
555
|
+
get numVertices(): number;
|
|
552
556
|
/** Draw offset */
|
|
553
557
|
getDrawOffset(): number;
|
|
554
558
|
setDrawOffset(offset: number): void;
|
|
@@ -557,25 +561,25 @@ declare class VertexData {
|
|
|
557
561
|
* @param semantic - The vertex semantic
|
|
558
562
|
* @returns Vertex buffer of the given semantic
|
|
559
563
|
*/
|
|
560
|
-
getVertexBuffer(semantic: VertexSemantic): StructuredBuffer;
|
|
564
|
+
getVertexBuffer(semantic: VertexSemantic): StructuredBuffer<unknown> | null;
|
|
561
565
|
/**
|
|
562
566
|
* Gets the vertex buffer information by specific vertex semantic
|
|
563
567
|
* @param semantic - The vertex semantic
|
|
564
568
|
* @returns Vertex buffer information of the given semantic
|
|
565
569
|
*/
|
|
566
|
-
getVertexBufferInfo(semantic: VertexSemantic): VertexBufferInfo;
|
|
570
|
+
getVertexBufferInfo(semantic: VertexSemantic): VertexBufferInfo | null;
|
|
567
571
|
/**
|
|
568
572
|
* Gets the index buffer
|
|
569
573
|
* @returns The index buffer
|
|
570
574
|
*/
|
|
571
|
-
getIndexBuffer(): IndexBuffer
|
|
575
|
+
getIndexBuffer(): Nullable<IndexBuffer<unknown>>;
|
|
572
576
|
/**
|
|
573
577
|
* Sets a vertex buffer
|
|
574
578
|
* @param buffer - The vertex buffer object
|
|
575
579
|
* @param stepMode - Step mode of the buffer
|
|
576
580
|
* @returns The buffer that was set
|
|
577
581
|
*/
|
|
578
|
-
setVertexBuffer(buffer: StructuredBuffer, stepMode?: VertexStepMode): StructuredBuffer;
|
|
582
|
+
setVertexBuffer(buffer: StructuredBuffer, stepMode?: VertexStepMode): StructuredBuffer<unknown> | null;
|
|
579
583
|
/**
|
|
580
584
|
* Removes a vertex buffer
|
|
581
585
|
* @param buffer - Vertex buffer to be removed
|
|
@@ -587,7 +591,7 @@ declare class VertexData {
|
|
|
587
591
|
* @param buffer - Index buffer to be set
|
|
588
592
|
* @returns The index buffer that was set
|
|
589
593
|
*/
|
|
590
|
-
setIndexBuffer(buffer: IndexBuffer): IndexBuffer
|
|
594
|
+
setIndexBuffer(buffer: Nullable<IndexBuffer>): Nullable<IndexBuffer<unknown>>;
|
|
591
595
|
}
|
|
592
596
|
|
|
593
597
|
/**
|
|
@@ -595,6 +599,40 @@ declare class VertexData {
|
|
|
595
599
|
* @public
|
|
596
600
|
*/
|
|
597
601
|
type TextureImageElement = ImageBitmap | HTMLCanvasElement;
|
|
602
|
+
/** @public */
|
|
603
|
+
declare const MAX_VERTEX_ATTRIBUTES = 16;
|
|
604
|
+
/** @public */
|
|
605
|
+
declare const MAX_BINDING_GROUPS = 4;
|
|
606
|
+
/** @public */
|
|
607
|
+
declare const MAX_TEXCOORD_INDEX_COUNT = 8;
|
|
608
|
+
/** @public */
|
|
609
|
+
declare const VERTEX_ATTRIB_POSITION = 0;
|
|
610
|
+
/** @public */
|
|
611
|
+
declare const VERTEX_ATTRIB_NORMAL = 1;
|
|
612
|
+
/** @public */
|
|
613
|
+
declare const VERTEX_ATTRIB_DIFFUSE = 2;
|
|
614
|
+
/** @public */
|
|
615
|
+
declare const VERTEX_ATTRIB_TANGENT = 3;
|
|
616
|
+
/** @public */
|
|
617
|
+
declare const VERTEX_ATTRIB_TEXCOORD0 = 4;
|
|
618
|
+
/** @public */
|
|
619
|
+
declare const VERTEX_ATTRIB_TEXCOORD1 = 5;
|
|
620
|
+
/** @public */
|
|
621
|
+
declare const VERTEX_ATTRIB_TEXCOORD2 = 6;
|
|
622
|
+
/** @public */
|
|
623
|
+
declare const VERTEX_ATTRIB_TEXCOORD3 = 7;
|
|
624
|
+
/** @public */
|
|
625
|
+
declare const VERTEX_ATTRIB_TEXCOORD4 = 8;
|
|
626
|
+
/** @public */
|
|
627
|
+
declare const VERTEX_ATTRIB_TEXCOORD5 = 9;
|
|
628
|
+
/** @public */
|
|
629
|
+
declare const VERTEX_ATTRIB_TEXCOORD6 = 10;
|
|
630
|
+
/** @public */
|
|
631
|
+
declare const VERTEX_ATTRIB_TEXCOORD7 = 11;
|
|
632
|
+
/** @public */
|
|
633
|
+
declare const VERTEX_ATTRIB_BLEND_WEIGHT = 12;
|
|
634
|
+
/** @public */
|
|
635
|
+
declare const VERTEX_ATTRIB_BLEND_INDICES = 13;
|
|
598
636
|
/**
|
|
599
637
|
* The vertex format types
|
|
600
638
|
* @public
|
|
@@ -614,20 +652,13 @@ type VertexLayoutOptions = {
|
|
|
614
652
|
* vertex buffers in this vertex layout
|
|
615
653
|
*/
|
|
616
654
|
vertexBuffers: {
|
|
617
|
-
/**
|
|
618
|
-
* vertex buffer object created by device
|
|
619
|
-
*/
|
|
620
655
|
buffer: StructuredBuffer;
|
|
621
|
-
/**
|
|
622
|
-
* the vertex buffer step mode,
|
|
623
|
-
* value can be 'vertex' or 'instance', default is 'vertex'
|
|
624
|
-
*/
|
|
625
656
|
stepMode?: VertexStepMode;
|
|
626
657
|
}[];
|
|
627
658
|
/**
|
|
628
659
|
* optional index buffer in this vertex layout
|
|
629
660
|
*/
|
|
630
|
-
indexBuffer?: IndexBuffer
|
|
661
|
+
indexBuffer?: Nullable<IndexBuffer>;
|
|
631
662
|
};
|
|
632
663
|
/**
|
|
633
664
|
* Supported colorspace types for texture
|
|
@@ -638,7 +669,7 @@ type TextureColorSpace = 'srgb' | 'linear';
|
|
|
638
669
|
* Buffer usage type
|
|
639
670
|
* @public
|
|
640
671
|
*/
|
|
641
|
-
type BufferUsage = 'vertex' | 'index' | 'uniform' | 'read' | 'write';
|
|
672
|
+
type BufferUsage = 'vertex' | 'index' | 'uniform' | 'read' | 'write' | 'pack-pixel' | 'unpack-pixel';
|
|
642
673
|
/**
|
|
643
674
|
* Common options for createing texture or buffer
|
|
644
675
|
* @public
|
|
@@ -655,8 +686,9 @@ interface BaseCreationOptions {
|
|
|
655
686
|
*/
|
|
656
687
|
interface TextureCreationOptions extends BaseCreationOptions {
|
|
657
688
|
writable?: boolean;
|
|
658
|
-
texture?: BaseTexture
|
|
659
|
-
|
|
689
|
+
texture?: Nullable<BaseTexture>;
|
|
690
|
+
mipmapping?: boolean;
|
|
691
|
+
samplerOptions?: Nullable<SamplerOptions>;
|
|
660
692
|
}
|
|
661
693
|
/**
|
|
662
694
|
* Options for creating gpu buffer
|
|
@@ -685,42 +717,73 @@ declare enum GPUResourceUsageFlags {
|
|
|
685
717
|
BF_WRITE = 256,
|
|
686
718
|
BF_UNIFORM = 512,
|
|
687
719
|
BF_STORAGE = 1024,
|
|
688
|
-
|
|
689
|
-
|
|
720
|
+
BF_PACK_PIXEL = 2048,
|
|
721
|
+
BF_UNPACK_PIXEL = 4096,
|
|
722
|
+
DYNAMIC = 8192,
|
|
723
|
+
MANAGED = 16384
|
|
690
724
|
}
|
|
691
725
|
/**
|
|
692
726
|
* Get vertex attribute index by semantic
|
|
693
727
|
* @public
|
|
694
728
|
*/
|
|
695
|
-
declare function getVertexAttribByName(name: VertexSemantic):
|
|
729
|
+
declare function getVertexAttribByName(name: Nullable<VertexSemantic>): 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 12 | undefined;
|
|
696
730
|
/**
|
|
697
731
|
* Get vertex semantic by attribute index
|
|
698
732
|
* @public
|
|
699
733
|
*/
|
|
700
734
|
declare function getVertexAttribName(attrib: number): VertexSemantic;
|
|
735
|
+
/**
|
|
736
|
+
* Test whether a vertex buffer matches given semantic
|
|
737
|
+
* @param buffer - Vertex buffer
|
|
738
|
+
* @param name - Semantic to test
|
|
739
|
+
* @returns true if the vertex buffer matches given semantic, otherwise false
|
|
740
|
+
*
|
|
741
|
+
* @public
|
|
742
|
+
*/
|
|
743
|
+
declare function matchVertexBuffer(buffer: StructuredBuffer, name: VertexSemantic): boolean;
|
|
744
|
+
/**
|
|
745
|
+
* Get vertex attribute type of specified vertex format
|
|
746
|
+
* @param fmt - The vertex format
|
|
747
|
+
* @returns Vertex attribute type, possible values are 'f32', 'f16', 'i32', 'u32', 'i16', 'u16', 'i8norm', 'u8norm', 'i16norm', 'u16norm'
|
|
748
|
+
*
|
|
749
|
+
* @public
|
|
750
|
+
*/
|
|
751
|
+
declare function getVertexAttributeFormat(fmt: VertexAttribFormat): "f32" | "i32" | "u32" | "u8norm" | "i8norm" | "u16" | "i16" | "u16norm" | "i16norm" | "f16";
|
|
752
|
+
/**
|
|
753
|
+
* Get vertex attribute index of specified vertex format
|
|
754
|
+
* @param fmt - The vertex format
|
|
755
|
+
* @returns Vertex attribute index
|
|
756
|
+
*
|
|
757
|
+
* @public
|
|
758
|
+
*/
|
|
759
|
+
declare function getVertexAttributeIndex(fmt: VertexAttribFormat): 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 12;
|
|
701
760
|
/**
|
|
702
761
|
* Get byte size of specified vertex format
|
|
762
|
+
*
|
|
703
763
|
* @public
|
|
704
764
|
*/
|
|
705
|
-
declare function getVertexFormatSize(fmt: VertexAttribFormat):
|
|
765
|
+
declare function getVertexFormatSize(fmt: VertexAttribFormat): 2 | 4 | 6 | 8 | 16 | 12;
|
|
706
766
|
/**
|
|
707
767
|
* Get number of components of specified vertex format
|
|
768
|
+
*
|
|
708
769
|
* @public
|
|
709
770
|
*/
|
|
710
|
-
declare function getVertexFormatComponentCount(fmt: VertexAttribFormat):
|
|
771
|
+
declare function getVertexFormatComponentCount(fmt: VertexAttribFormat): 1 | 2 | 3 | 4;
|
|
711
772
|
/**
|
|
712
773
|
* Get vertex format by semantic and component type and component count
|
|
713
774
|
* @param semantic - The vertex semantic
|
|
714
775
|
* @param type - Data type of vertex component
|
|
715
776
|
* @param count - The count of vertex components
|
|
716
777
|
* @returns Vertex format
|
|
778
|
+
*
|
|
717
779
|
* @public
|
|
718
780
|
*/
|
|
719
|
-
declare function getVertexAttribFormat(semantic: VertexSemantic, type: DataType, count: number): VertexAttribFormat;
|
|
781
|
+
declare function getVertexAttribFormat(semantic: VertexSemantic, type: DataType, count: number): VertexAttribFormat | null;
|
|
720
782
|
/**
|
|
721
783
|
* Get the length of a vertex buffer by specified structure type of the vertex buffer
|
|
722
784
|
* @param vertexBufferType - The structure type of the vertex buffer
|
|
723
785
|
* @returns The length of the vertex buffer
|
|
786
|
+
*
|
|
724
787
|
* @public
|
|
725
788
|
*/
|
|
726
789
|
declare function getVertexBufferLength(vertexBufferType: PBStructTypeInfo): number;
|
|
@@ -728,40 +791,46 @@ declare function getVertexBufferLength(vertexBufferType: PBStructTypeInfo): numb
|
|
|
728
791
|
* Get byte stride of a vertex buffer by specified structure type of the vertex buffer
|
|
729
792
|
* @param vertexBufferType - The structure type of the vertex buffer
|
|
730
793
|
* @returns The byte stride of the vertex buffer
|
|
794
|
+
*
|
|
731
795
|
* @public
|
|
732
796
|
*/
|
|
733
|
-
declare function getVertexBufferStride(vertexBufferType: PBStructTypeInfo): number;
|
|
797
|
+
declare function getVertexBufferStride(vertexBufferType: Immutable<PBStructTypeInfo>): number;
|
|
734
798
|
/**
|
|
735
799
|
* Get primitive type of a vertex attribute by specified vertex semantic
|
|
736
800
|
* @param vertexBufferType - The structure type of the vertex buffer
|
|
737
801
|
* @param semantic - The vertex semantic
|
|
738
802
|
* @returns - The primitive type of the vertex attribute
|
|
803
|
+
*
|
|
739
804
|
* @public
|
|
740
805
|
*/
|
|
741
|
-
declare function getVertexBufferAttribTypeBySemantic(vertexBufferType: PBStructTypeInfo
|
|
806
|
+
declare function getVertexBufferAttribTypeBySemantic(vertexBufferType: Immutable<PBStructTypeInfo>, semantic: VertexSemantic): PBPrimitiveTypeInfo | null;
|
|
742
807
|
/**
|
|
743
808
|
* Get primitive type of a vertex attribute by specified vertex attribute index
|
|
744
809
|
* @param vertexBufferType - The structure type of the vertex buffer
|
|
745
810
|
* @param semantic - The vertex attribute index
|
|
746
811
|
* @returns - The primitive type of the vertex attribute
|
|
812
|
+
*
|
|
747
813
|
* @public
|
|
748
814
|
*/
|
|
749
|
-
declare function getVertexBufferAttribType(vertexBufferType: PBStructTypeInfo
|
|
815
|
+
declare function getVertexBufferAttribType(vertexBufferType: Immutable<PBStructTypeInfo>, attrib: number): PBPrimitiveTypeInfo | null;
|
|
750
816
|
/**
|
|
751
817
|
* Get the structure type of a vertex buffer by specified vertex attribute formats and the length of the vertex buffer
|
|
752
818
|
* @param length - The length of the vertex buffer
|
|
753
819
|
* @param attributes - The vertex attributes
|
|
754
820
|
* @returns The structure type of the vertex buffer
|
|
821
|
+
*
|
|
755
822
|
* @public
|
|
756
823
|
*/
|
|
757
|
-
declare function makeVertexBufferType(length: number, ...attributes: VertexAttribFormat[]): PBStructTypeInfo;
|
|
824
|
+
declare function makeVertexBufferType(length: number, ...attributes: Immutable<VertexAttribFormat[]>): PBStructTypeInfo | null;
|
|
758
825
|
/**
|
|
759
826
|
* Vertex step mode.
|
|
827
|
+
*
|
|
760
828
|
* @public
|
|
761
829
|
*/
|
|
762
830
|
type VertexStepMode = 'vertex' | 'instance';
|
|
763
831
|
/**
|
|
764
832
|
* Vertex semantic list
|
|
833
|
+
*
|
|
765
834
|
* @public
|
|
766
835
|
*/
|
|
767
836
|
declare const semanticList: string[];
|
|
@@ -857,7 +926,7 @@ interface UniformLayout {
|
|
|
857
926
|
/** The primitive type of the uniform */
|
|
858
927
|
type: PBPrimitiveType;
|
|
859
928
|
/** Layout of the members if the uniform is struct type */
|
|
860
|
-
subLayout: UniformBufferLayout
|
|
929
|
+
subLayout: Nullable<UniformBufferLayout>;
|
|
861
930
|
}
|
|
862
931
|
/**
|
|
863
932
|
* Binding layout of a uniform buffer or storage buffer
|
|
@@ -895,9 +964,9 @@ interface TextureBindingLayout {
|
|
|
895
964
|
/** Whether the textur is a multisampled texture */
|
|
896
965
|
multisampled: boolean;
|
|
897
966
|
/** name of the default sampler uniform when using WebGPU device */
|
|
898
|
-
autoBindSampler: string
|
|
967
|
+
autoBindSampler: Nullable<string>;
|
|
899
968
|
/** name of the default comparison sampler uniform when using WebGPU device */
|
|
900
|
-
autoBindSamplerComparison: string
|
|
969
|
+
autoBindSamplerComparison: Nullable<string>;
|
|
901
970
|
}
|
|
902
971
|
/**
|
|
903
972
|
* Binding layout of a storage texture
|
|
@@ -917,7 +986,7 @@ interface StorageTextureBindingLayout {
|
|
|
917
986
|
*/
|
|
918
987
|
interface ExternalTextureBindingLayout {
|
|
919
988
|
/** name of the default sampler uniform when using WebGPU device */
|
|
920
|
-
autoBindSampler: string
|
|
989
|
+
autoBindSampler: Nullable<string>;
|
|
921
990
|
}
|
|
922
991
|
/**
|
|
923
992
|
* Information of bind group entries
|
|
@@ -977,26 +1046,24 @@ interface SamplerOptions {
|
|
|
977
1046
|
mipFilter?: TextureFilterMode;
|
|
978
1047
|
lodMin?: number;
|
|
979
1048
|
lodMax?: number;
|
|
980
|
-
compare?: CompareFunc
|
|
1049
|
+
compare?: Nullable<CompareFunc>;
|
|
981
1050
|
maxAnisotropy?: number;
|
|
982
1051
|
}
|
|
983
1052
|
/**
|
|
984
1053
|
* Base class for a GPU object
|
|
985
1054
|
* @public
|
|
986
1055
|
*/
|
|
987
|
-
interface GPUObject<T = unknown> extends
|
|
988
|
-
disposed: null;
|
|
989
|
-
}> {
|
|
1056
|
+
interface GPUObject<T = unknown> extends IDisposable {
|
|
990
1057
|
/** The object was created by which device */
|
|
991
1058
|
readonly device: AbstractDevice;
|
|
992
1059
|
/** The internal GPU object */
|
|
993
|
-
readonly object: T
|
|
1060
|
+
readonly object: Nullable<T>;
|
|
994
1061
|
/** unique id */
|
|
995
1062
|
readonly uid: number;
|
|
996
1063
|
readonly cid: number;
|
|
997
1064
|
readonly disposed: boolean;
|
|
998
1065
|
name: string;
|
|
999
|
-
restoreHandler: (tex: GPUObject) =>
|
|
1066
|
+
restoreHandler: Nullable<(tex: GPUObject) => void>;
|
|
1000
1067
|
isVertexLayout(): this is VertexLayout;
|
|
1001
1068
|
isFramebuffer(): this is FrameBuffer;
|
|
1002
1069
|
isSampler(): this is TextureSampler;
|
|
@@ -1010,9 +1077,9 @@ interface GPUObject<T = unknown> extends IEventTarget<{
|
|
|
1010
1077
|
isBuffer(): this is GPUDataBuffer;
|
|
1011
1078
|
isBindGroup(): this is BindGroup;
|
|
1012
1079
|
dispose(): void;
|
|
1013
|
-
reload():
|
|
1080
|
+
reload(): void;
|
|
1014
1081
|
destroy(): void;
|
|
1015
|
-
restore():
|
|
1082
|
+
restore(): void;
|
|
1016
1083
|
}
|
|
1017
1084
|
/**
|
|
1018
1085
|
* Abstract interface for texture sampler
|
|
@@ -1027,7 +1094,7 @@ interface TextureSampler<T = unknown> extends GPUObject<T> {
|
|
|
1027
1094
|
readonly mipFilter: TextureFilterMode;
|
|
1028
1095
|
readonly lodMin: number;
|
|
1029
1096
|
readonly lodMax: number;
|
|
1030
|
-
readonly compare: CompareFunc
|
|
1097
|
+
readonly compare: Nullable<CompareFunc>;
|
|
1031
1098
|
readonly maxAnisotropy: number;
|
|
1032
1099
|
}
|
|
1033
1100
|
/**
|
|
@@ -1042,7 +1109,7 @@ interface BaseTexture<T = unknown> extends GPUObject<T> {
|
|
|
1042
1109
|
readonly format: TextureFormat;
|
|
1043
1110
|
readonly mipLevelCount: number;
|
|
1044
1111
|
readonly memCost: number;
|
|
1045
|
-
samplerOptions: SamplerOptions
|
|
1112
|
+
samplerOptions: Nullable<Immutable<SamplerOptions>>;
|
|
1046
1113
|
init(): void;
|
|
1047
1114
|
generateMipmaps(): void;
|
|
1048
1115
|
isSRGBFormat(): boolean;
|
|
@@ -1108,7 +1175,7 @@ interface GPUDataBuffer<T = unknown> extends GPUObject<T> {
|
|
|
1108
1175
|
readonly byteLength: number;
|
|
1109
1176
|
readonly usage: number;
|
|
1110
1177
|
bufferSubData(dstByteOffset: number, data: TypedArray, srcOffset?: number, srcLength?: number): void;
|
|
1111
|
-
getBufferSubData(dstBuffer?: Uint8Array
|
|
1178
|
+
getBufferSubData(dstBuffer?: Nullable<Uint8Array<ArrayBuffer>>, offsetInBytes?: number, sizeInBytes?: number): Promise<Uint8Array<ArrayBuffer>>;
|
|
1112
1179
|
}
|
|
1113
1180
|
/**
|
|
1114
1181
|
* Abstract interface for index buffer
|
|
@@ -1123,8 +1190,8 @@ interface IndexBuffer<T = unknown> extends GPUDataBuffer<T> {
|
|
|
1123
1190
|
* @public
|
|
1124
1191
|
*/
|
|
1125
1192
|
interface StructuredBuffer<T = unknown> extends GPUDataBuffer<T> {
|
|
1126
|
-
structure: PBStructTypeInfo
|
|
1127
|
-
set(name: string, value: StructuredValue):
|
|
1193
|
+
structure: Immutable<PBStructTypeInfo>;
|
|
1194
|
+
set(name: string, value: StructuredValue): void;
|
|
1128
1195
|
}
|
|
1129
1196
|
/**
|
|
1130
1197
|
* Abstract interface for vertex layout
|
|
@@ -1132,19 +1199,19 @@ interface StructuredBuffer<T = unknown> extends GPUDataBuffer<T> {
|
|
|
1132
1199
|
*/
|
|
1133
1200
|
interface VertexLayout<T = unknown> extends GPUObject<T> {
|
|
1134
1201
|
readonly vertexBuffers: {
|
|
1135
|
-
[semantic: number]: {
|
|
1202
|
+
[semantic: number]: Nullable<{
|
|
1136
1203
|
buffer: StructuredBuffer;
|
|
1137
1204
|
offset: number;
|
|
1138
|
-
}
|
|
1205
|
+
}>;
|
|
1139
1206
|
};
|
|
1140
|
-
readonly indexBuffer: IndexBuffer
|
|
1207
|
+
readonly indexBuffer: Nullable<IndexBuffer>;
|
|
1141
1208
|
setDrawOffset(buffer: StructuredBuffer, byteOffset: number): void;
|
|
1142
|
-
getVertexBuffer(semantic: VertexSemantic): StructuredBuffer
|
|
1143
|
-
getVertexBufferInfo(semantic: VertexSemantic): VertexBufferInfo
|
|
1144
|
-
getIndexBuffer(): IndexBuffer
|
|
1209
|
+
getVertexBuffer(semantic: VertexSemantic): Nullable<StructuredBuffer>;
|
|
1210
|
+
getVertexBufferInfo(semantic: VertexSemantic): Nullable<VertexBufferInfo>;
|
|
1211
|
+
getIndexBuffer(): Nullable<IndexBuffer>;
|
|
1145
1212
|
bind(): void;
|
|
1146
1213
|
draw(primitiveType: PrimitiveType, first: number, count: number): void;
|
|
1147
|
-
drawInstanced(primitiveType: PrimitiveType, first: number, count: number, numInstances: number):
|
|
1214
|
+
drawInstanced(primitiveType: PrimitiveType, first: number, count: number, numInstances: number): void;
|
|
1148
1215
|
}
|
|
1149
1216
|
/**
|
|
1150
1217
|
* Abstract interface for frame buffer
|
|
@@ -1168,7 +1235,8 @@ interface FrameBuffer<T = unknown> extends GPUObject<T> {
|
|
|
1168
1235
|
setDepthAttachmentLayer(layer: number): void;
|
|
1169
1236
|
getDepthAttachmentLayer(): number;
|
|
1170
1237
|
getColorAttachments(): BaseTexture[];
|
|
1171
|
-
getDepthAttachment(): BaseTexture
|
|
1238
|
+
getDepthAttachment(): Nullable<BaseTexture>;
|
|
1239
|
+
getColorAttachment<T extends BaseTexture = BaseTexture>(index: number): T;
|
|
1172
1240
|
bind(): boolean;
|
|
1173
1241
|
unbind(): void;
|
|
1174
1242
|
}
|
|
@@ -1177,12 +1245,12 @@ interface FrameBuffer<T = unknown> extends GPUObject<T> {
|
|
|
1177
1245
|
* @public
|
|
1178
1246
|
*/
|
|
1179
1247
|
interface GPUProgram<T = unknown> extends GPUObject<T> {
|
|
1180
|
-
readonly bindGroupLayouts: BindGroupLayout[]
|
|
1248
|
+
readonly bindGroupLayouts: Immutable<BindGroupLayout[]>;
|
|
1181
1249
|
readonly type: 'render' | 'compute';
|
|
1182
|
-
getShaderSource(kind: ShaderKind): string
|
|
1183
|
-
getCompileError(): string
|
|
1184
|
-
getBindingInfo(name: string): BindPointInfo
|
|
1185
|
-
createUniformBuffer(uniform: string): StructuredBuffer
|
|
1250
|
+
getShaderSource(kind: ShaderKind): Nullable<string>;
|
|
1251
|
+
getCompileError(): Nullable<string>;
|
|
1252
|
+
getBindingInfo(name: string): Nullable<BindPointInfo>;
|
|
1253
|
+
createUniformBuffer(uniform: string): Nullable<StructuredBuffer>;
|
|
1186
1254
|
use(): void;
|
|
1187
1255
|
}
|
|
1188
1256
|
/**
|
|
@@ -1197,17 +1265,17 @@ type StructuredValue = number | TypedArray | VectorBase | {
|
|
|
1197
1265
|
* @public
|
|
1198
1266
|
*/
|
|
1199
1267
|
interface BindGroup extends GPUObject<unknown> {
|
|
1200
|
-
getLayout(): BindGroupLayout
|
|
1201
|
-
getDynamicOffsets(): number[]
|
|
1268
|
+
getLayout(): Immutable<BindGroupLayout>;
|
|
1269
|
+
getDynamicOffsets(): Nullable<Immutable<number[]>>;
|
|
1202
1270
|
getGPUId(): string;
|
|
1203
|
-
getBuffer(name: string): GPUDataBuffer
|
|
1204
|
-
getTexture(name: string): BaseTexture
|
|
1271
|
+
getBuffer(name: string, nocreate?: boolean): Nullable<GPUDataBuffer>;
|
|
1272
|
+
getTexture(name: string): Nullable<BaseTexture>;
|
|
1205
1273
|
setBuffer(name: string, buffer: GPUDataBuffer, offset?: number, bindOffset?: number, bindSize?: number): void;
|
|
1206
|
-
setValue(name: string, value: StructuredValue):
|
|
1207
|
-
setRawData(name: string, byteOffset: number, data: TypedArray, srcPos?: number, srcLength?: number):
|
|
1208
|
-
setTexture(name: string, texture: BaseTexture, sampler?: TextureSampler):
|
|
1209
|
-
setTextureView(name: string, value: BaseTexture, level?: number, face?: number, mipCount?: number, sampler?: TextureSampler):
|
|
1210
|
-
setSampler(name: string, sampler: TextureSampler):
|
|
1274
|
+
setValue(name: string, value: StructuredValue): void;
|
|
1275
|
+
setRawData(name: string, byteOffset: number, data: TypedArray, srcPos?: number, srcLength?: number): void;
|
|
1276
|
+
setTexture(name: string, texture: BaseTexture, sampler?: Nullable<TextureSampler>): void;
|
|
1277
|
+
setTextureView(name: string, value: BaseTexture, level?: number, face?: number, mipCount?: number, sampler?: Nullable<TextureSampler>): void;
|
|
1278
|
+
setSampler(name: string, sampler: TextureSampler): void;
|
|
1211
1279
|
}
|
|
1212
1280
|
/**
|
|
1213
1281
|
* Render bundle
|
|
@@ -1251,20 +1319,20 @@ declare abstract class Proxiable<T> {
|
|
|
1251
1319
|
*/
|
|
1252
1320
|
declare class PBShaderExp extends Proxiable<PBShaderExp> {
|
|
1253
1321
|
[name: string]: any;
|
|
1254
|
-
get $group(): number
|
|
1255
|
-
set $group(val: number);
|
|
1322
|
+
get $group(): Nullable<number>;
|
|
1323
|
+
set $group(val: Nullable<number>);
|
|
1256
1324
|
/**
|
|
1257
1325
|
* Point out that the variable should be in uniform address space
|
|
1258
1326
|
* @param group - The bind group index
|
|
1259
1327
|
* @returns self
|
|
1260
1328
|
*/
|
|
1261
|
-
uniform(group: number):
|
|
1329
|
+
uniform(group: number): this;
|
|
1262
1330
|
/**
|
|
1263
1331
|
* Point out that the variable should be an uniform buffer
|
|
1264
1332
|
* @param group - The bind group index
|
|
1265
1333
|
* @returns self
|
|
1266
1334
|
*/
|
|
1267
|
-
uniformBuffer(group: number, bindingSize?: number):
|
|
1335
|
+
uniformBuffer(group: number, bindingSize?: number): this;
|
|
1268
1336
|
/**
|
|
1269
1337
|
* Point out that the variable should be in workgroup address space
|
|
1270
1338
|
*
|
|
@@ -1273,51 +1341,51 @@ declare class PBShaderExp extends Proxiable<PBShaderExp> {
|
|
|
1273
1341
|
*
|
|
1274
1342
|
* @returns self
|
|
1275
1343
|
*/
|
|
1276
|
-
workgroup():
|
|
1344
|
+
workgroup(): this;
|
|
1277
1345
|
/**
|
|
1278
1346
|
* Point out that the variable should be in storage address space
|
|
1279
1347
|
* @param group - The bind group index
|
|
1280
1348
|
* @returns self
|
|
1281
1349
|
*/
|
|
1282
|
-
storage(group: number):
|
|
1350
|
+
storage(group: number): this;
|
|
1283
1351
|
/**
|
|
1284
1352
|
* Point out that the variable is read-only and should be in storage address space
|
|
1285
1353
|
* @param group - The bind group index
|
|
1286
1354
|
* @returns self
|
|
1287
1355
|
*/
|
|
1288
|
-
storageReadonly(group: number):
|
|
1356
|
+
storageReadonly(group: number): this;
|
|
1289
1357
|
/**
|
|
1290
1358
|
* Point out that the variable should be a storage buffer
|
|
1291
1359
|
* @param group - The bind group index
|
|
1292
1360
|
* @returns self
|
|
1293
1361
|
*/
|
|
1294
|
-
storageBuffer(group: number, bindingSize?: number):
|
|
1362
|
+
storageBuffer(group: number, bindingSize?: number): this;
|
|
1295
1363
|
/**
|
|
1296
1364
|
* Point out that the variable is read-only and should be a storage buffer
|
|
1297
1365
|
* @param group - The bind group index
|
|
1298
1366
|
* @returns self
|
|
1299
1367
|
*/
|
|
1300
|
-
storageBufferReadonly(group: number, bindingSize?: number):
|
|
1301
|
-
inout():
|
|
1302
|
-
out():
|
|
1368
|
+
storageBufferReadonly(group: number, bindingSize?: number): this;
|
|
1369
|
+
inout(): this;
|
|
1370
|
+
out(): this;
|
|
1303
1371
|
/**
|
|
1304
1372
|
* Point out that the variable is a input vertex attribute
|
|
1305
1373
|
* @param attr - The vertex semantic
|
|
1306
1374
|
* @returns self
|
|
1307
1375
|
*/
|
|
1308
|
-
attrib(attr: VertexSemantic):
|
|
1376
|
+
attrib(attr: VertexSemantic): this;
|
|
1309
1377
|
/**
|
|
1310
1378
|
* Create tags for the variable
|
|
1311
1379
|
* @param args - tags
|
|
1312
1380
|
* @returns self
|
|
1313
1381
|
*/
|
|
1314
|
-
tag(...args: ShaderExpTagValue[]):
|
|
1382
|
+
tag(...args: ShaderExpTagValue[]): this;
|
|
1315
1383
|
/**
|
|
1316
1384
|
* Set sample type for the variable if the variable is of type texture
|
|
1317
1385
|
* @param type - sample type
|
|
1318
1386
|
* @returns self
|
|
1319
1387
|
*/
|
|
1320
|
-
sampleType(type: 'float' | 'unfilterable-float' | 'sint' | 'uint' | 'depth'):
|
|
1388
|
+
sampleType(type: 'float' | 'unfilterable-float' | 'sint' | 'uint' | 'depth'): this;
|
|
1321
1389
|
/**
|
|
1322
1390
|
* Get element in the array by index
|
|
1323
1391
|
* @param index - index of the element
|
|
@@ -1334,17 +1402,17 @@ declare class PBShaderExp extends Proxiable<PBShaderExp> {
|
|
|
1334
1402
|
* Point out that the variable should be in high precision
|
|
1335
1403
|
* @returns self
|
|
1336
1404
|
*/
|
|
1337
|
-
highp():
|
|
1405
|
+
highp(): this;
|
|
1338
1406
|
/**
|
|
1339
1407
|
* Points out that the variable should be in medium precision
|
|
1340
1408
|
* @returns self
|
|
1341
1409
|
*/
|
|
1342
|
-
mediump():
|
|
1410
|
+
mediump(): this;
|
|
1343
1411
|
/**
|
|
1344
1412
|
* Points out that the variable should be in low precision
|
|
1345
1413
|
* @returns self
|
|
1346
1414
|
*/
|
|
1347
|
-
lowp():
|
|
1415
|
+
lowp(): this;
|
|
1348
1416
|
/**
|
|
1349
1417
|
* Whether this is a constructor
|
|
1350
1418
|
* @returns true if this is a constructor
|
|
@@ -1409,7 +1477,7 @@ declare class PBReflection {
|
|
|
1409
1477
|
* Gets the variable which is the vertex attribute of specified semantic
|
|
1410
1478
|
* @param attrib - The vertex semantic
|
|
1411
1479
|
*/
|
|
1412
|
-
attribute(attrib: VertexSemantic): PBShaderExp;
|
|
1480
|
+
attribute(attrib: VertexSemantic): PBShaderExp | null;
|
|
1413
1481
|
}
|
|
1414
1482
|
|
|
1415
1483
|
declare const StorageTextureFormatMap: {
|
|
@@ -1456,13 +1524,13 @@ interface PBRenderOptions {
|
|
|
1456
1524
|
* @param this - Global scope object of the vertex shader
|
|
1457
1525
|
* @param pb - The program builder instance
|
|
1458
1526
|
*/
|
|
1459
|
-
vertex(this: PBGlobalScope, pb: ProgramBuilder):
|
|
1527
|
+
vertex(this: PBGlobalScope, pb: ProgramBuilder): void;
|
|
1460
1528
|
/**
|
|
1461
1529
|
* Fragment shader generator.
|
|
1462
1530
|
* @param this - Global scope object of the fragment shader
|
|
1463
1531
|
* @param pb - The program builder instance
|
|
1464
1532
|
*/
|
|
1465
|
-
fragment(this: PBGlobalScope, pb: ProgramBuilder):
|
|
1533
|
+
fragment(this: PBGlobalScope, pb: ProgramBuilder): void;
|
|
1466
1534
|
}
|
|
1467
1535
|
/**
|
|
1468
1536
|
* Compute program build options
|
|
@@ -1474,7 +1542,7 @@ interface PBComputeOptions {
|
|
|
1474
1542
|
/** workgroup size */
|
|
1475
1543
|
workgroupSize: [number, number, number];
|
|
1476
1544
|
/** compute shader */
|
|
1477
|
-
compute(this: PBGlobalScope, pb: ProgramBuilder):
|
|
1545
|
+
compute(this: PBGlobalScope, pb: ProgramBuilder): void;
|
|
1478
1546
|
}
|
|
1479
1547
|
/**
|
|
1480
1548
|
* The program builder interface
|
|
@@ -1486,7 +1554,7 @@ interface ProgramBuilder {
|
|
|
1486
1554
|
/** Gets the global scope */
|
|
1487
1555
|
getGlobalScope(): PBGlobalScope;
|
|
1488
1556
|
/** Gets the current scope */
|
|
1489
|
-
getCurrentScope():
|
|
1557
|
+
getCurrentScope<T extends PBScope = PBScope>(): T;
|
|
1490
1558
|
/**
|
|
1491
1559
|
* Query the global variable by the name
|
|
1492
1560
|
* @param name - Name of the variable
|
|
@@ -1957,6 +2025,8 @@ interface ProgramBuilder {
|
|
|
1957
2025
|
max(x: number | PBShaderExp, y: number | PBShaderExp): PBShaderExp;
|
|
1958
2026
|
/** Same as clamp builtin function in GLSL and WGSL */
|
|
1959
2027
|
clamp(x: number | PBShaderExp, y: number | PBShaderExp, z: number | PBShaderExp): PBShaderExp;
|
|
2028
|
+
/** Clamp to [0, 1] */
|
|
2029
|
+
saturate(x: PBShaderExp): PBShaderExp;
|
|
1960
2030
|
/** Same as mix builtin function in GLSL and WGSL */
|
|
1961
2031
|
mix(x: number | PBShaderExp, y: number | PBShaderExp, z: number | PBShaderExp): PBShaderExp;
|
|
1962
2032
|
/** Same as step builtin function in GLSL and WGSL */
|
|
@@ -1968,17 +2038,17 @@ interface ProgramBuilder {
|
|
|
1968
2038
|
/** Same as isinf builtin function in GLSL, only valid for WebGL2 device */
|
|
1969
2039
|
isinf(x: number | PBShaderExp): PBShaderExp;
|
|
1970
2040
|
/** add two values */
|
|
1971
|
-
add_2(x: number | PBShaderExp, y: number | PBShaderExp):
|
|
2041
|
+
add_2(x: number | PBShaderExp, y: number | PBShaderExp): PBShaderExp;
|
|
1972
2042
|
/** add a couple of values togeter */
|
|
1973
|
-
add(x: number | PBShaderExp, ...rest: (number | PBShaderExp)[]):
|
|
2043
|
+
add(x: number | PBShaderExp, y: number | PBShaderExp, ...rest: (number | PBShaderExp)[]): PBShaderExp;
|
|
1974
2044
|
/** subtract two values */
|
|
1975
|
-
sub(x: number | PBShaderExp, y: number | PBShaderExp):
|
|
2045
|
+
sub(x: number | PBShaderExp, y: number | PBShaderExp): PBShaderExp;
|
|
1976
2046
|
/** multiply two values */
|
|
1977
|
-
mul_2(x: number | PBShaderExp, y: number | PBShaderExp):
|
|
2047
|
+
mul_2(x: number | PBShaderExp, y: number | PBShaderExp): PBShaderExp;
|
|
1978
2048
|
/** multiply a couple of values togeter */
|
|
1979
|
-
mul(x: number | PBShaderExp, ...rest: (number | PBShaderExp)[]):
|
|
2049
|
+
mul(x: number | PBShaderExp, y: number | PBShaderExp, ...rest: (number | PBShaderExp)[]): PBShaderExp;
|
|
1980
2050
|
/** divide the first number by the second number */
|
|
1981
|
-
div(x: number | PBShaderExp, y: number | PBShaderExp):
|
|
2051
|
+
div(x: number | PBShaderExp, y: number | PBShaderExp): PBShaderExp;
|
|
1982
2052
|
/** Same as length builtin function in GLSL and WGSL */
|
|
1983
2053
|
length(x: number | PBShaderExp): PBShaderExp;
|
|
1984
2054
|
/** Same as distance builtin function in GLSL and WGSL */
|
|
@@ -2024,7 +2094,7 @@ interface ProgramBuilder {
|
|
|
2024
2094
|
/** return x && y */
|
|
2025
2095
|
and_2(x: PBShaderExp | number | boolean, y: PBShaderExp | number | boolean): PBShaderExp;
|
|
2026
2096
|
/** return x && y && ... */
|
|
2027
|
-
and(x: PBShaderExp | number | boolean, y: PBShaderExp | number | boolean, ...rest: (PBShaderExp | number | boolean)[]):
|
|
2097
|
+
and(x: PBShaderExp | number | boolean, y: PBShaderExp | number | boolean, ...rest: (PBShaderExp | number | boolean)[]): PBShaderExp;
|
|
2028
2098
|
/** return x & y, per component */
|
|
2029
2099
|
compAnd(x: PBShaderExp | number, y: PBShaderExp | number): PBShaderExp;
|
|
2030
2100
|
/** return x ^ y, per component */
|
|
@@ -2044,9 +2114,9 @@ interface ProgramBuilder {
|
|
|
2044
2114
|
/** return the negate of the given value */
|
|
2045
2115
|
neg(x: number | PBShaderExp): PBShaderExp;
|
|
2046
2116
|
/** shift arithmetic left, not valid for WebGL1 device */
|
|
2047
|
-
sal(a: number | PBShaderExp, b: number | PBShaderExp):
|
|
2117
|
+
sal(a: number | PBShaderExp, b: number | PBShaderExp): PBShaderExp;
|
|
2048
2118
|
/** shift arithmetic right, not valid for WebGL1 device */
|
|
2049
|
-
sar(a: number | PBShaderExp, b: number | PBShaderExp):
|
|
2119
|
+
sar(a: number | PBShaderExp, b: number | PBShaderExp): PBShaderExp;
|
|
2050
2120
|
/** Same as the arrayLength builtin function in WGSL, only valid for WebGPU device */
|
|
2051
2121
|
arrayLength(x: PBShaderExp): PBShaderExp;
|
|
2052
2122
|
/** Same as the select builtin function in WGSL, only valid for WebGPU device */
|
|
@@ -2154,9 +2224,9 @@ interface ProgramBuilder {
|
|
|
2154
2224
|
/** Same as workgroupBarrier builtin function in WebGPU, only valid for WebGPU device */
|
|
2155
2225
|
workgroupBarrier(): void;
|
|
2156
2226
|
/** atomicLoad, only valid for WebGPU device */
|
|
2157
|
-
atomicLoad(ptr: PBShaderExp):
|
|
2227
|
+
atomicLoad(ptr: PBShaderExp): PBShaderExp;
|
|
2158
2228
|
/** atomicStore, only valid for WebGPU device */
|
|
2159
|
-
atomicStore(ptr: PBShaderExp, value: number | PBShaderExp):
|
|
2229
|
+
atomicStore(ptr: PBShaderExp, value: number | PBShaderExp): void;
|
|
2160
2230
|
/** atomicAdd, only valid for WebGPU device */
|
|
2161
2231
|
atomicAdd(ptr: PBShaderExp, value: number | PBShaderExp): PBShaderExp;
|
|
2162
2232
|
/** atomicSub, only valid for WebGPU device */
|
|
@@ -2185,9 +2255,9 @@ declare class ProgramBuilder {
|
|
|
2185
2255
|
*/
|
|
2186
2256
|
constructor(device: AbstractDevice);
|
|
2187
2257
|
/** Get last error */
|
|
2188
|
-
get lastError(): string
|
|
2258
|
+
get lastError(): Nullable<string>;
|
|
2189
2259
|
/** Current shader kind */
|
|
2190
|
-
get shaderKind(): ShaderKind
|
|
2260
|
+
get shaderKind(): Nullable<ShaderKind>;
|
|
2191
2261
|
get emulateDepthClamp(): boolean;
|
|
2192
2262
|
set emulateDepthClamp(val: boolean);
|
|
2193
2263
|
/** Get the shader code reflection interface */
|
|
@@ -2218,7 +2288,7 @@ declare class PBScope extends Proxiable<PBScope> {
|
|
|
2218
2288
|
* @param semantic - The vertex semantic
|
|
2219
2289
|
* @returns The input vertex attribute or null if not exists
|
|
2220
2290
|
*/
|
|
2221
|
-
$getVertexAttrib(semantic: VertexSemantic): PBShaderExp
|
|
2291
|
+
$getVertexAttrib(semantic: VertexSemantic): Nullable<PBShaderExp>;
|
|
2222
2292
|
/** Get the current local scope */
|
|
2223
2293
|
get $l(): PBLocalScope;
|
|
2224
2294
|
/** Get the global scope */
|
|
@@ -2245,7 +2315,7 @@ declare class PBLocalScope extends PBScope {
|
|
|
2245
2315
|
interface PBBuiltinScope {
|
|
2246
2316
|
position: PBShaderExp;
|
|
2247
2317
|
pointSize: PBShaderExp | number;
|
|
2248
|
-
fragDepth: PBShaderExp;
|
|
2318
|
+
fragDepth: PBShaderExp | number;
|
|
2249
2319
|
readonly fragCoord: PBShaderExp;
|
|
2250
2320
|
readonly frontFacing: PBShaderExp;
|
|
2251
2321
|
readonly vertexIndex: PBShaderExp;
|
|
@@ -2327,7 +2397,7 @@ declare class PBInsideFunctionScope extends PBScope {
|
|
|
2327
2397
|
* @param end - end value of the counter exclusive
|
|
2328
2398
|
* @param body - Generator function for the scope that inside the for statement
|
|
2329
2399
|
*/
|
|
2330
|
-
$for(counter: PBShaderExp, init: number | PBShaderExp, end: number | PBShaderExp,
|
|
2400
|
+
$for(counter: PBShaderExp, init: number | PBShaderExp, end: number | PBShaderExp, open?: boolean | ((this: PBForScope) => void), reverse?: boolean | ((this: PBForScope) => void), body?: (this: PBForScope) => void): void;
|
|
2331
2401
|
/**
|
|
2332
2402
|
* Creates a 'do..while' statement
|
|
2333
2403
|
* @param body - Generator function for the scope that inside the do..while statment
|
|
@@ -2340,6 +2410,8 @@ declare class PBInsideFunctionScope extends PBScope {
|
|
|
2340
2410
|
* @param body - Generator function for the scope that inside the while statement
|
|
2341
2411
|
*/
|
|
2342
2412
|
$while(condition: ExpValueNonArrayType, body: (this: PBWhileScope) => void): void;
|
|
2413
|
+
/** Gets main function scope */
|
|
2414
|
+
$getMainScope(): Nullable<PBFunctionScope>;
|
|
2343
2415
|
}
|
|
2344
2416
|
/**
|
|
2345
2417
|
* Scope that insides a function
|
|
@@ -2536,6 +2608,10 @@ interface DepthState {
|
|
|
2536
2608
|
writeEnabled: boolean;
|
|
2537
2609
|
/** The comparison function for depth testing */
|
|
2538
2610
|
compareFunc: CompareFunc;
|
|
2611
|
+
/** Depth bias */
|
|
2612
|
+
depthBias: number;
|
|
2613
|
+
/** Slope scaled depth bias */
|
|
2614
|
+
depthBiasSlopeScale: number;
|
|
2539
2615
|
/**
|
|
2540
2616
|
* Enable or disable depth testing
|
|
2541
2617
|
* @param b - true if enable
|
|
@@ -2554,6 +2630,16 @@ interface DepthState {
|
|
|
2554
2630
|
* @returns self
|
|
2555
2631
|
*/
|
|
2556
2632
|
setCompareFunc(func: CompareFunc): this;
|
|
2633
|
+
/**
|
|
2634
|
+
* Sets the depth bias
|
|
2635
|
+
* @param value - Value of the depth bias
|
|
2636
|
+
*/
|
|
2637
|
+
setDepthBias(value: number): this;
|
|
2638
|
+
/**
|
|
2639
|
+
* Sets the slope scaled depth bias
|
|
2640
|
+
* @param value - Value of the slope scaled depth bias
|
|
2641
|
+
*/
|
|
2642
|
+
setDepthBiasSlopeScale(value: number): this;
|
|
2557
2643
|
}
|
|
2558
2644
|
/**
|
|
2559
2645
|
* Stencil operations
|
|
@@ -2654,15 +2740,15 @@ interface RenderStateSet {
|
|
|
2654
2740
|
/** Shallow copy existing RenderStateSet object to this */
|
|
2655
2741
|
copyFrom(stateSet: RenderStateSet): void;
|
|
2656
2742
|
/** Fragment output related render statements or null if the default values should be used */
|
|
2657
|
-
readonly colorState: ColorState
|
|
2743
|
+
readonly colorState: Nullable<ColorState>;
|
|
2658
2744
|
/** Alpha blending related render statements or null if the default values should be used */
|
|
2659
|
-
readonly blendingState: BlendingState
|
|
2745
|
+
readonly blendingState: Nullable<BlendingState>;
|
|
2660
2746
|
/** Rasterization related render statements or null if the default values should be used */
|
|
2661
|
-
readonly rasterizerState: RasterizerState
|
|
2747
|
+
readonly rasterizerState: Nullable<RasterizerState>;
|
|
2662
2748
|
/** Depth buffer related render statements or null if the default values should be used */
|
|
2663
|
-
readonly depthState: DepthState
|
|
2749
|
+
readonly depthState: Nullable<DepthState>;
|
|
2664
2750
|
/** Stencil buffer related render statements or null if the default values should be used */
|
|
2665
|
-
readonly stencilState: StencilState
|
|
2751
|
+
readonly stencilState: Nullable<StencilState>;
|
|
2666
2752
|
/**
|
|
2667
2753
|
* Allocates a ColorState
|
|
2668
2754
|
* @returns The created ColorState
|
|
@@ -2724,7 +2810,11 @@ declare class Pool {
|
|
|
2724
2810
|
* Creates an instance of Pool class
|
|
2725
2811
|
* @param device - Rendering device
|
|
2726
2812
|
*/
|
|
2727
|
-
constructor(device: AbstractDevice, memCostThreshold?: number);
|
|
2813
|
+
constructor(device: AbstractDevice, id: string | symbol, memCostThreshold?: number);
|
|
2814
|
+
/**
|
|
2815
|
+
* Id for this pool
|
|
2816
|
+
*/
|
|
2817
|
+
get id(): string | symbol;
|
|
2728
2818
|
autoRelease(): void;
|
|
2729
2819
|
/**
|
|
2730
2820
|
* Fetch a temporal 2D texture from the object pool.
|
|
@@ -2771,7 +2861,7 @@ declare class Pool {
|
|
|
2771
2861
|
* @param attachmentLayer - The texture layer to which the color attachment will render, default is 0
|
|
2772
2862
|
* @returns The fetched FrameBuffer object.
|
|
2773
2863
|
*/
|
|
2774
|
-
fetchTemporalFramebuffer<T extends BaseTexture<unknown>>(autoRelease: boolean, width: number, height: number, colorTexOrFormat: MaybeArray<TextureFormat | T>, depthTexOrFormat?: TextureFormat | T
|
|
2864
|
+
fetchTemporalFramebuffer<T extends BaseTexture<unknown>>(autoRelease: boolean, width: number, height: number, colorTexOrFormat: MaybeArray<TextureFormat | T>, depthTexOrFormat?: Nullable<TextureFormat | T>, mipmapping?: boolean, sampleCount?: number, ignoreDepthStencil?: boolean, attachmentMipLevel?: number, attachmentCubeface?: number, attachmentLayer?: number): FrameBuffer<unknown>;
|
|
2775
2865
|
/**
|
|
2776
2866
|
* Creates a temporal framebuffer from the object pool.
|
|
2777
2867
|
* @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
|
|
@@ -2784,7 +2874,7 @@ declare class Pool {
|
|
|
2784
2874
|
* @param attachmentLayer - The texture layer to which the color attachment will render, default is 0.
|
|
2785
2875
|
* @returns The fetched FrameBuffer object.
|
|
2786
2876
|
*/
|
|
2787
|
-
createTemporalFramebuffer(autoRelease: boolean, colorAttachments: BaseTexture[], depthAttachment?: BaseTexture
|
|
2877
|
+
createTemporalFramebuffer(autoRelease: boolean, colorAttachments: BaseTexture[], depthAttachment?: Nullable<BaseTexture>, sampleCount?: number, ignoreDepthStencil?: boolean, attachmentMipLevel?: number, attachmentCubeface?: number, attachmentLayer?: number): FrameBuffer<unknown>;
|
|
2788
2878
|
/**
|
|
2789
2879
|
* Dispose a texture that is allocated from the object pool.
|
|
2790
2880
|
* @param texture - The texture to dispose.
|
|
@@ -2795,6 +2885,11 @@ declare class Pool {
|
|
|
2795
2885
|
* @param texture - The texture to release.
|
|
2796
2886
|
*/
|
|
2797
2887
|
releaseTexture(texture: BaseTexture): void;
|
|
2888
|
+
/**
|
|
2889
|
+
* Increment reference counter for given texture
|
|
2890
|
+
* @param texture - The texture to retain
|
|
2891
|
+
*/
|
|
2892
|
+
retainTexture(texture: BaseTexture): void;
|
|
2798
2893
|
/**
|
|
2799
2894
|
* Dispose a framebuffer that is allocated from the object pool.
|
|
2800
2895
|
* @param fb - The framebuffer to dispose.
|
|
@@ -2805,12 +2900,40 @@ declare class Pool {
|
|
|
2805
2900
|
* @param fb - The framebuffer to release.
|
|
2806
2901
|
*/
|
|
2807
2902
|
releaseFrameBuffer(fb: FrameBuffer): void;
|
|
2903
|
+
/**
|
|
2904
|
+
* Increment reference counter for given framebuffer
|
|
2905
|
+
* @param fb - The framebuffer to retain
|
|
2906
|
+
*/
|
|
2907
|
+
retainFrameBuffer(fb: FrameBuffer): void;
|
|
2808
2908
|
/**
|
|
2809
2909
|
* Purge the object pool by disposing all free framebuffers and textures.
|
|
2810
2910
|
*/
|
|
2811
2911
|
purge(): void;
|
|
2812
2912
|
}
|
|
2813
2913
|
|
|
2914
|
+
/**
|
|
2915
|
+
* Abstract timer interface
|
|
2916
|
+
* @public
|
|
2917
|
+
*/
|
|
2918
|
+
interface ITimer {
|
|
2919
|
+
begin(): void;
|
|
2920
|
+
end(): void;
|
|
2921
|
+
ended(): boolean;
|
|
2922
|
+
elapsed(): number;
|
|
2923
|
+
}
|
|
2924
|
+
/**
|
|
2925
|
+
* CPU timer class
|
|
2926
|
+
* @public
|
|
2927
|
+
*/
|
|
2928
|
+
declare class CPUTimer implements ITimer {
|
|
2929
|
+
constructor();
|
|
2930
|
+
now(): number;
|
|
2931
|
+
begin(): void;
|
|
2932
|
+
end(): void;
|
|
2933
|
+
ended(): boolean;
|
|
2934
|
+
elapsed(): number;
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2814
2937
|
/**
|
|
2815
2938
|
* The webgl context type
|
|
2816
2939
|
* @public
|
|
@@ -2845,14 +2968,14 @@ type DataType = 'u8' | 'u8norm' | 'i8' | 'i8norm' | 'u16' | 'u16norm' | 'i16' |
|
|
|
2845
2968
|
* Texture format type
|
|
2846
2969
|
* @public
|
|
2847
2970
|
*/
|
|
2848
|
-
type TextureFormat = '
|
|
2971
|
+
type TextureFormat = 'r8unorm' | 'r8snorm' | 'r16f' | 'r32f' | 'r8ui' | 'r8i' | 'r16ui' | 'r16i' | 'r32ui' | 'r32i' | 'rg8unorm' | 'rg8snorm' | 'rg16f' | 'rg32f' | 'rg8ui' | 'rg8i' | 'rg16ui' | 'rg16i' | 'rg32ui' | 'rg32i' | 'rgba8unorm' | 'rgba8unorm-srgb' | 'rgba8snorm' | 'bgra8unorm' | 'bgra8unorm-srgb' | 'rgba16f' | 'rgba32f' | 'rgba8ui' | 'rgba8i' | 'rgba16ui' | 'rgba16i' | 'rgba32ui' | 'rgba32i' | 'rg11b10uf' | 'd16' | 'd24' | 'd32f' | 'd24s8' | 'd32fs8' | 'dxt1' | 'dxt1-srgb' | 'dxt3' | 'dxt3-srgb' | 'dxt5' | 'dxt5-srgb' | 'bc4' | 'bc4-signed' | 'bc5' | 'bc5-signed' | 'bc7' | 'bc7-srgb' | 'bc6h' | 'bc6h-signed' | 'astc-4x4' | 'astc-4x4-srgb' | 'astc-5x4' | 'astc-5x4-srgb' | 'astc-5x5' | 'astc-5x5-srgb' | 'astc-6x5' | 'astc-6x5-srgb' | 'astc-6x6' | 'astc-6x6-srgb' | 'astc-8x5' | 'astc-8x5-srgb' | 'astc-8x6' | 'astc-8x6-srgb' | 'astc-8x8' | 'astc-8x8-srgb' | 'astc-10x5' | 'astc-10x5-srgb' | 'astc-10x6' | 'astc-10x6-srgb' | 'astc-10x8' | 'astc-10x8-srgb' | 'astc-10x10' | 'astc-10x10-srgb' | 'astc-12x10' | 'astc-12x10-srgb' | 'astc-12x12' | 'astc-12x12-srgb';
|
|
2849
2972
|
/**
|
|
2850
2973
|
* Converts a non-sRGB texture format to the corresponding sRGB texture format
|
|
2851
2974
|
* @param format - The texture format to be converted
|
|
2852
2975
|
* @returns The sRGB texture format
|
|
2853
2976
|
* @public
|
|
2854
2977
|
*/
|
|
2855
|
-
declare function linearTextureFormatToSRGB(format: TextureFormat):
|
|
2978
|
+
declare function linearTextureFormatToSRGB(format: TextureFormat): "rgba8snorm" | "r8unorm" | "r8snorm" | "r16f" | "r32f" | "r8ui" | "r8i" | "r16ui" | "r16i" | "r32ui" | "r32i" | "rg8unorm" | "rg8snorm" | "rg16f" | "rg32f" | "rg8ui" | "rg8i" | "rg16ui" | "rg16i" | "rg32ui" | "rg32i" | "rgba8unorm-srgb" | "bgra8unorm-srgb" | "rgba16f" | "rgba32f" | "rgba8ui" | "rgba8i" | "rgba16ui" | "rgba16i" | "rgba32ui" | "rgba32i" | "rg11b10uf" | "d16" | "d24" | "d32f" | "d24s8" | "d32fs8" | "dxt1-srgb" | "dxt3-srgb" | "dxt5-srgb" | "bc4" | "bc4-signed" | "bc5" | "bc5-signed" | "bc7-srgb" | "bc6h" | "bc6h-signed" | "astc-4x4-srgb" | "astc-5x4-srgb" | "astc-5x5-srgb" | "astc-6x5-srgb" | "astc-6x6-srgb" | "astc-8x5-srgb" | "astc-8x6-srgb" | "astc-8x8-srgb" | "astc-10x5-srgb" | "astc-10x6-srgb" | "astc-10x8-srgb" | "astc-10x10-srgb" | "astc-12x10-srgb" | "astc-12x12-srgb";
|
|
2856
2979
|
/**
|
|
2857
2980
|
* Check if a given texture format contains an alpha channel.
|
|
2858
2981
|
* @param format - The texture format to be checked.
|
|
@@ -3035,6 +3158,8 @@ interface DeviceCaps {
|
|
|
3035
3158
|
interface FramebufferCaps {
|
|
3036
3159
|
/** The maximum number of framebuffer color attachment points */
|
|
3037
3160
|
maxDrawBuffers: number;
|
|
3161
|
+
/** True if device supports rendering to mipmap */
|
|
3162
|
+
supportRenderMipmap: boolean;
|
|
3038
3163
|
/** True if device supports multisampled frame buffer */
|
|
3039
3164
|
supportMultisampledFramebuffer: boolean;
|
|
3040
3165
|
/** True if device supports blending on float point frame buffer */
|
|
@@ -3075,8 +3200,6 @@ interface ShaderCaps {
|
|
|
3075
3200
|
supportShaderTextureLod: boolean;
|
|
3076
3201
|
/** True if the device supports high precison float number for shader programs */
|
|
3077
3202
|
supportHighPrecisionFloat: boolean;
|
|
3078
|
-
/** True if the device supports high precison integer number for shader programs */
|
|
3079
|
-
supportHighPrecisionInt: boolean;
|
|
3080
3203
|
/** The maximum number of bytes of uniform buffer */
|
|
3081
3204
|
maxUniformBufferSize: number;
|
|
3082
3205
|
/** The uniform buffer offset alignment */
|
|
@@ -3097,6 +3220,12 @@ interface TextureFormatInfo {
|
|
|
3097
3220
|
renderable: boolean;
|
|
3098
3221
|
/** True if the texture format is a compressed format */
|
|
3099
3222
|
compressed: boolean;
|
|
3223
|
+
/** Number of bytes per-block */
|
|
3224
|
+
size: number;
|
|
3225
|
+
/** Block width */
|
|
3226
|
+
blockWidth: number;
|
|
3227
|
+
/** Block height */
|
|
3228
|
+
blockHeight: number;
|
|
3100
3229
|
}
|
|
3101
3230
|
/**
|
|
3102
3231
|
* Texture related capabilities of the device'
|
|
@@ -3148,7 +3277,7 @@ interface TextureCaps {
|
|
|
3148
3277
|
* @param format - The texture format
|
|
3149
3278
|
* @returns the texture format infomation
|
|
3150
3279
|
*/
|
|
3151
|
-
getTextureFormatInfo(format: TextureFormat): TextureFormatInfo
|
|
3280
|
+
getTextureFormatInfo(format: TextureFormat): Immutable<TextureFormatInfo>;
|
|
3152
3281
|
}
|
|
3153
3282
|
/**
|
|
3154
3283
|
* Creation options of rendering shader program
|
|
@@ -3186,70 +3315,6 @@ interface GPUProgramConstructParams {
|
|
|
3186
3315
|
/** The creation options */
|
|
3187
3316
|
params: RenderProgramConstructParams | ComputeProgramConstructParams;
|
|
3188
3317
|
}
|
|
3189
|
-
/**
|
|
3190
|
-
* Event that will be fired when device is lost
|
|
3191
|
-
* @public
|
|
3192
|
-
*/
|
|
3193
|
-
declare class DeviceLostEvent {
|
|
3194
|
-
/** The event name */
|
|
3195
|
-
static readonly NAME: "devicelost";
|
|
3196
|
-
type: "devicelost";
|
|
3197
|
-
}
|
|
3198
|
-
/**
|
|
3199
|
-
* Event that will be fired when device has just been restored
|
|
3200
|
-
* @public
|
|
3201
|
-
*/
|
|
3202
|
-
declare class DeviceRestoreEvent {
|
|
3203
|
-
/** The event name */
|
|
3204
|
-
static readonly NAME: "devicerestored";
|
|
3205
|
-
type: "devicerestored";
|
|
3206
|
-
}
|
|
3207
|
-
/**
|
|
3208
|
-
* Event that will be fired when size of back buffer has changed
|
|
3209
|
-
* @public
|
|
3210
|
-
*/
|
|
3211
|
-
declare class DeviceResizeEvent {
|
|
3212
|
-
/** The event name */
|
|
3213
|
-
static readonly NAME: "resize";
|
|
3214
|
-
width: number;
|
|
3215
|
-
height: number;
|
|
3216
|
-
type: "resize";
|
|
3217
|
-
constructor(width: number, height: number);
|
|
3218
|
-
}
|
|
3219
|
-
/**
|
|
3220
|
-
* Event that will be fired when any gpu object is created
|
|
3221
|
-
* @public
|
|
3222
|
-
*/
|
|
3223
|
-
declare class DeviceGPUObjectAddedEvent {
|
|
3224
|
-
/** the event name */
|
|
3225
|
-
static readonly NAME: "gpuobject_added";
|
|
3226
|
-
object: GPUObject;
|
|
3227
|
-
type: "gpuobject_added";
|
|
3228
|
-
constructor(obj: GPUObject);
|
|
3229
|
-
}
|
|
3230
|
-
/**
|
|
3231
|
-
* Event that will be fired when any gpu object is disposed
|
|
3232
|
-
* @public
|
|
3233
|
-
*/
|
|
3234
|
-
declare class DeviceGPUObjectRemovedEvent {
|
|
3235
|
-
/** The event name */
|
|
3236
|
-
static readonly NAME: 'gpuobject_removed';
|
|
3237
|
-
object: GPUObject;
|
|
3238
|
-
type: "gpuobject_removed";
|
|
3239
|
-
constructor(obj: GPUObject);
|
|
3240
|
-
}
|
|
3241
|
-
/**
|
|
3242
|
-
* Event that will be fired when any gpu object name is changed
|
|
3243
|
-
* @public
|
|
3244
|
-
*/
|
|
3245
|
-
declare class DeviceGPUObjectRenameEvent {
|
|
3246
|
-
/** The event name */
|
|
3247
|
-
static readonly NAME: 'gpuobject_rename';
|
|
3248
|
-
object: GPUObject;
|
|
3249
|
-
lastName: string;
|
|
3250
|
-
type: "gpuobject_rename";
|
|
3251
|
-
constructor(obj: GPUObject, lastName: string);
|
|
3252
|
-
}
|
|
3253
3318
|
/**
|
|
3254
3319
|
* Creation options for device
|
|
3255
3320
|
* @public
|
|
@@ -3265,12 +3330,12 @@ interface DeviceOptions {
|
|
|
3265
3330
|
* @public
|
|
3266
3331
|
*/
|
|
3267
3332
|
type DeviceEventMap = {
|
|
3268
|
-
[
|
|
3269
|
-
[
|
|
3270
|
-
[
|
|
3271
|
-
[
|
|
3272
|
-
[
|
|
3273
|
-
[
|
|
3333
|
+
resize: [cssWidth: number, cssHeight: number, deviceWidth: number, deviceHeight: number];
|
|
3334
|
+
devicelost: [];
|
|
3335
|
+
devicerestored: [];
|
|
3336
|
+
gpuobject_added: [obj: GPUObject];
|
|
3337
|
+
gpuobject_removed: [obj: GPUObject];
|
|
3338
|
+
gpuobject_rename: [obj: GPUObject, lastName: string];
|
|
3274
3339
|
};
|
|
3275
3340
|
/**
|
|
3276
3341
|
* Structure that contains the device viewport information
|
|
@@ -3301,14 +3366,20 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3301
3366
|
pool: Pool;
|
|
3302
3367
|
/** vSync */
|
|
3303
3368
|
vSync: boolean;
|
|
3369
|
+
/** Check if a pool with given key exists */
|
|
3370
|
+
poolExists(key: string | symbol): boolean;
|
|
3371
|
+
/** Get the pool with given key, or create a new one if not exists */
|
|
3372
|
+
getPool(key: string | symbol): Pool;
|
|
3304
3373
|
/** Get adapter information */
|
|
3305
3374
|
getAdapterInfo(): any;
|
|
3306
3375
|
/** Get sample count of current frame buffer */
|
|
3307
3376
|
getFrameBufferSampleCount(): number;
|
|
3308
3377
|
/** Returns true if device context is lost. */
|
|
3309
3378
|
isContextLost(): boolean;
|
|
3310
|
-
/** Get the value of device pixel ratio */
|
|
3311
|
-
|
|
3379
|
+
/** Get the value of device pixel ratio in X axis */
|
|
3380
|
+
getScaleX(): number;
|
|
3381
|
+
/** Get the value of device pixel ratio in Y axis */
|
|
3382
|
+
getScaleY(): number;
|
|
3312
3383
|
/** Get the width of current frame buffer */
|
|
3313
3384
|
getDrawingBufferWidth(): number;
|
|
3314
3385
|
/** Get the height of current frame buffer */
|
|
@@ -3318,13 +3389,13 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3318
3389
|
/** Get the height of back buffer */
|
|
3319
3390
|
getBackBufferHeight(): number;
|
|
3320
3391
|
/** Get the device capabilities */
|
|
3321
|
-
getDeviceCaps(): DeviceCaps
|
|
3392
|
+
getDeviceCaps(): Immutable<DeviceCaps>;
|
|
3322
3393
|
/** Schedule next frame */
|
|
3323
3394
|
nextFrame(callback: () => void): number;
|
|
3324
3395
|
/** Cancel schedule next frame */
|
|
3325
|
-
cancelNextFrame(handle: number):
|
|
3396
|
+
cancelNextFrame(handle: number): void;
|
|
3326
3397
|
/** Set font for drawText function */
|
|
3327
|
-
setFont(fontName: string):
|
|
3398
|
+
setFont(fontName: string): void;
|
|
3328
3399
|
/**
|
|
3329
3400
|
* Draw a string
|
|
3330
3401
|
* @param text - The string that will be drawn
|
|
@@ -3332,14 +3403,16 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3332
3403
|
* @param y - y coordinate in pixels related to the viewport origin
|
|
3333
3404
|
* @param color - A CSS color value
|
|
3334
3405
|
*/
|
|
3335
|
-
drawText(text: string, x: number, y: number, color: string):
|
|
3406
|
+
drawText(text: string, x: number, y: number, color: string, viewport?: Immutable<number[]>): void;
|
|
3336
3407
|
/**
|
|
3337
3408
|
* Clears the current frame buffer
|
|
3338
3409
|
* @param clearColor - If not null, the color buffer will be cleared to this value.
|
|
3339
3410
|
* @param clearDepth - If not null, the depth buffer will be cleared to this value.
|
|
3340
3411
|
* @param clearStencil - If not null, the stencil buffer will be cleared to this value.
|
|
3341
3412
|
*/
|
|
3342
|
-
clearFrameBuffer(clearColor: Vector4
|
|
3413
|
+
clearFrameBuffer(clearColor: Nullable<Vector4>, clearDepth: Nullable<number>, clearStencil: Nullable<number>): void;
|
|
3414
|
+
/** Creates a GPU timer */
|
|
3415
|
+
createGPUTimer(): Nullable<ITimer>;
|
|
3343
3416
|
/** Creates a render state set object */
|
|
3344
3417
|
createRenderStateSet(): RenderStateSet;
|
|
3345
3418
|
/** Creates a blending state object */
|
|
@@ -3355,6 +3428,7 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3355
3428
|
/**
|
|
3356
3429
|
* Creates a texture sampler object
|
|
3357
3430
|
* @param options - The creation options
|
|
3431
|
+
* @returns The created texture sampler
|
|
3358
3432
|
*/
|
|
3359
3433
|
createSampler(options: SamplerOptions): TextureSampler;
|
|
3360
3434
|
/**
|
|
@@ -3363,27 +3437,23 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3363
3437
|
* @param options - Texture creation options
|
|
3364
3438
|
* @returns The created texture
|
|
3365
3439
|
*/
|
|
3366
|
-
createTextureFromMipmapData<T extends BaseTexture = BaseTexture>(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): T
|
|
3440
|
+
createTextureFromMipmapData<T extends BaseTexture = BaseTexture>(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): Nullable<T>;
|
|
3367
3441
|
/**
|
|
3368
3442
|
* Creates a 2d texture
|
|
3369
3443
|
* @param format - The texture format
|
|
3370
3444
|
* @param width - Pixel width of the texture
|
|
3371
3445
|
* @param height - Pixel height of the texture
|
|
3372
3446
|
* @param options - The creation options
|
|
3447
|
+
* @returns The created 2D texture
|
|
3373
3448
|
*/
|
|
3374
|
-
createTexture2D(format: TextureFormat, width: number, height: number, options?: TextureCreationOptions): Texture2D
|
|
3375
|
-
/**
|
|
3376
|
-
* Creates a 2d texture from given mipmap data
|
|
3377
|
-
* @param data - The mipmap data
|
|
3378
|
-
* @param options - The creation options
|
|
3379
|
-
*/
|
|
3380
|
-
createTexture2DFromMipmapData(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): Texture2D;
|
|
3449
|
+
createTexture2D(format: TextureFormat, width: number, height: number, options?: TextureCreationOptions): Nullable<Texture2D>;
|
|
3381
3450
|
/**
|
|
3382
3451
|
* Creates a 2d texture from a image element
|
|
3383
3452
|
* @param element - The image element
|
|
3384
3453
|
* @param options - The creation options
|
|
3454
|
+
* @returns The created 2D texture.
|
|
3385
3455
|
*/
|
|
3386
|
-
createTexture2DFromImage(element: TextureImageElement, sRGB: boolean, options?: TextureCreationOptions): Texture2D
|
|
3456
|
+
createTexture2DFromImage(element: TextureImageElement, sRGB: boolean, options?: TextureCreationOptions): Nullable<Texture2D>;
|
|
3387
3457
|
/**
|
|
3388
3458
|
* Creates a 2d array texture
|
|
3389
3459
|
* @param format - The texture format
|
|
@@ -3391,47 +3461,39 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3391
3461
|
* @param height - Pixel height of the texture
|
|
3392
3462
|
* @param depth - Array length of the texture
|
|
3393
3463
|
* @param options - The creation options
|
|
3464
|
+
* @returns The created 2D array texture.
|
|
3394
3465
|
*/
|
|
3395
|
-
createTexture2DArray(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Texture2DArray
|
|
3396
|
-
/**
|
|
3397
|
-
* Creates a 2d array texture from mipmap data
|
|
3398
|
-
* @param data - mipmap data
|
|
3399
|
-
* @param sRGB - whether texture should have sRGB texture format
|
|
3400
|
-
* @param options - The creation options
|
|
3401
|
-
*/
|
|
3402
|
-
createTexture2DArrayFromMipmapData(data: TextureMipmapData, options?: TextureCreationOptions): Texture2DArray;
|
|
3466
|
+
createTexture2DArray(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Nullable<Texture2DArray>;
|
|
3403
3467
|
/**
|
|
3404
3468
|
* Creates a 2d array texture from a seris of image elements
|
|
3405
3469
|
* @remarks image elements must have the same size.
|
|
3406
3470
|
* @param elements - image elements
|
|
3407
3471
|
* @param options - The creation options
|
|
3472
|
+
* @returns The created 2D array texture.
|
|
3408
3473
|
*/
|
|
3409
|
-
createTexture2DArrayFromImages(elements: TextureImageElement[], sRGB: boolean, options?: TextureCreationOptions): Texture2DArray
|
|
3474
|
+
createTexture2DArrayFromImages(elements: TextureImageElement[], sRGB: boolean, options?: TextureCreationOptions): Nullable<Texture2DArray>;
|
|
3410
3475
|
/**
|
|
3411
|
-
* Creates a
|
|
3476
|
+
* Creates a 3D texture
|
|
3412
3477
|
* @param format - The texture format
|
|
3413
3478
|
* @param width - Pixel width of the texture
|
|
3414
3479
|
* @param height - Pixel height of the texture
|
|
3415
3480
|
* @param depth - Pixel depth of the texture
|
|
3416
3481
|
* @param options - The creation options
|
|
3482
|
+
* @returns The created 3D texture.
|
|
3417
3483
|
*/
|
|
3418
|
-
createTexture3D(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Texture3D
|
|
3484
|
+
createTexture3D(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Nullable<Texture3D>;
|
|
3419
3485
|
/**
|
|
3420
3486
|
* Creates a cube texture
|
|
3421
3487
|
* @param format - The texture format
|
|
3422
3488
|
* @param size - Pixel width of the texture
|
|
3423
3489
|
* @param options - The creation options
|
|
3490
|
+
* @returns The created cube texture.
|
|
3424
3491
|
*/
|
|
3425
|
-
createCubeTexture(format: TextureFormat, size: number, options?: TextureCreationOptions): TextureCube
|
|
3426
|
-
/**
|
|
3427
|
-
* Creates a cube texture from given mipmap data
|
|
3428
|
-
* @param data - The mipmap data
|
|
3429
|
-
* @param options - The creation options
|
|
3430
|
-
*/
|
|
3431
|
-
createCubeTextureFromMipmapData(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): TextureCube;
|
|
3492
|
+
createCubeTexture(format: TextureFormat, size: number, options?: TextureCreationOptions): Nullable<TextureCube>;
|
|
3432
3493
|
/**
|
|
3433
3494
|
* Creates a video texture from a video element
|
|
3434
3495
|
* @param el - The video element
|
|
3496
|
+
* @returns The created video texture.
|
|
3435
3497
|
*/
|
|
3436
3498
|
createTextureVideo(el: HTMLVideoElement, samplerOptions?: SamplerOptions): TextureVideo;
|
|
3437
3499
|
/**
|
|
@@ -3445,7 +3507,7 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3445
3507
|
* @param dst - Texture that will be copied to.
|
|
3446
3508
|
* @param dstLevel - Which mipmap level to be copied to.
|
|
3447
3509
|
*/
|
|
3448
|
-
copyTexture2D(src: Texture2D, srcLevel: number, dst: Texture2D, dstLevel: number):
|
|
3510
|
+
copyTexture2D(src: Texture2D, srcLevel: number, dst: Texture2D, dstLevel: number): void;
|
|
3449
3511
|
/**
|
|
3450
3512
|
* Copies a color attachment of a framebuffer to a mipmap level of a texture.
|
|
3451
3513
|
*
|
|
@@ -3457,7 +3519,7 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3457
3519
|
* @param dst - Texture that will be copied to.
|
|
3458
3520
|
* @param level - Which mipmap level should be copied to.
|
|
3459
3521
|
*/
|
|
3460
|
-
copyFramebufferToTexture2D(src: FrameBuffer, index: number, dst: Texture2D, level: number):
|
|
3522
|
+
copyFramebufferToTexture2D(src: FrameBuffer, index: number, dst: Texture2D, level: number): void;
|
|
3461
3523
|
/**
|
|
3462
3524
|
* Set wether to reverse the winding order
|
|
3463
3525
|
*
|
|
@@ -3474,17 +3536,20 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3474
3536
|
/**
|
|
3475
3537
|
* Creates a gpu program
|
|
3476
3538
|
* @param params - The creation options
|
|
3539
|
+
* @returns The created program.
|
|
3477
3540
|
*/
|
|
3478
3541
|
createGPUProgram(params: GPUProgramConstructParams): GPUProgram;
|
|
3479
3542
|
/**
|
|
3480
3543
|
* Creates a bind group
|
|
3481
3544
|
* @param layout - Layout of the bind group
|
|
3545
|
+
* @returns The created bind group.
|
|
3482
3546
|
*/
|
|
3483
|
-
createBindGroup(layout: BindGroupLayout): BindGroup;
|
|
3547
|
+
createBindGroup(layout: Immutable<BindGroupLayout>): BindGroup;
|
|
3484
3548
|
/**
|
|
3485
3549
|
* Creates a gpu buffer
|
|
3486
3550
|
* @param sizeInBytes - Size of the buffer in bytes
|
|
3487
3551
|
* @param options - The creation options
|
|
3552
|
+
* @returns The created buffer.
|
|
3488
3553
|
*/
|
|
3489
3554
|
createBuffer(sizeInBytes: number, options: BufferCreationOptions): GPUDataBuffer;
|
|
3490
3555
|
/**
|
|
@@ -3495,78 +3560,82 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3495
3560
|
* @param dstOffset - Destination offset in bytes
|
|
3496
3561
|
* @param bytes - How many bytes to be copy
|
|
3497
3562
|
*/
|
|
3498
|
-
copyBuffer(sourceBuffer: GPUDataBuffer, destBuffer: GPUDataBuffer, srcOffset: number, dstOffset: number, bytes: number):
|
|
3563
|
+
copyBuffer(sourceBuffer: GPUDataBuffer, destBuffer: GPUDataBuffer, srcOffset: number, dstOffset: number, bytes: number): void;
|
|
3499
3564
|
/**
|
|
3500
3565
|
* Creates an index buffer
|
|
3501
3566
|
* @param data - Data of the index buffer
|
|
3502
3567
|
* @param options - The creation options
|
|
3568
|
+
* @returns The created index buffer.
|
|
3503
3569
|
*/
|
|
3504
|
-
createIndexBuffer(data: Uint16Array | Uint32Array
|
|
3570
|
+
createIndexBuffer(data: Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer>, options?: BufferCreationOptions): IndexBuffer;
|
|
3505
3571
|
/**
|
|
3506
3572
|
* Creates a structured buffer
|
|
3507
3573
|
* @param structureType - The structure type
|
|
3508
3574
|
* @param options - The creation options
|
|
3509
3575
|
* @param data - Data to be filled with
|
|
3576
|
+
* @returns The created structured buffer.
|
|
3510
3577
|
*/
|
|
3511
3578
|
createStructuredBuffer(structureType: PBStructTypeInfo, options: BufferCreationOptions, data?: TypedArray): StructuredBuffer;
|
|
3512
3579
|
/**
|
|
3513
|
-
* Creates a vertex layout
|
|
3580
|
+
* Creates a vertex layout object.
|
|
3514
3581
|
* @param options - The creation options
|
|
3582
|
+
* @returns The created vertex layout object.
|
|
3515
3583
|
*/
|
|
3516
3584
|
createVertexLayout(options: VertexLayoutOptions): VertexLayout;
|
|
3517
3585
|
/**
|
|
3518
3586
|
* Creates a frame buffer
|
|
3519
3587
|
* @param options - The creation options
|
|
3588
|
+
* @returns The created framebuffer.
|
|
3520
3589
|
*/
|
|
3521
|
-
createFrameBuffer(colorAttachments: BaseTexture[], depthAttachment: BaseTexture
|
|
3590
|
+
createFrameBuffer(colorAttachments: BaseTexture[], depthAttachment: Nullable<BaseTexture>, options?: Nullable<FrameBufferOptions>): FrameBuffer;
|
|
3522
3591
|
/**
|
|
3523
3592
|
* Set viewport from an array that contains the position and size
|
|
3524
3593
|
*
|
|
3525
3594
|
* @param vp - The viewport position and size, if not specified, the viewport will be set to [0, 0, drawingBufferWidth, drawingBufferHeight]
|
|
3526
3595
|
*/
|
|
3527
|
-
setViewport(vp
|
|
3596
|
+
setViewport(vp: Nullable<Immutable<DeviceViewport | number[]>>): void;
|
|
3528
3597
|
/** Get current viewport as [x, y, width, height] */
|
|
3529
|
-
getViewport(): DeviceViewport
|
|
3598
|
+
getViewport(): Immutable<DeviceViewport>;
|
|
3530
3599
|
/**
|
|
3531
3600
|
* Set scissor rectangle from an array that contains the position and size
|
|
3532
3601
|
* @param scissor - The scissor rectangle position and size, if not specified, the scissor rectangle will be set to [0, 0, drawingBufferWidth,drawingBufferHeight]
|
|
3533
3602
|
*/
|
|
3534
|
-
setScissor(scissor
|
|
3603
|
+
setScissor(scissor: Nullable<Immutable<DeviceViewport | number[]>>): void;
|
|
3535
3604
|
/**
|
|
3536
3605
|
* Get current scissor rectangle
|
|
3537
3606
|
*/
|
|
3538
|
-
getScissor(): DeviceViewport
|
|
3607
|
+
getScissor(): Immutable<DeviceViewport>;
|
|
3539
3608
|
/**
|
|
3540
3609
|
* Set current GPU program
|
|
3541
3610
|
* @param program - The GPU program to be set
|
|
3542
3611
|
*/
|
|
3543
|
-
setProgram(program: GPUProgram): void;
|
|
3612
|
+
setProgram(program: Nullable<GPUProgram>): void;
|
|
3544
3613
|
/**
|
|
3545
3614
|
* Get current GPU program
|
|
3546
3615
|
*/
|
|
3547
|
-
getProgram(): GPUProgram
|
|
3616
|
+
getProgram(): Nullable<GPUProgram>;
|
|
3548
3617
|
/**
|
|
3549
3618
|
* Set current vertex layout
|
|
3550
3619
|
*
|
|
3551
3620
|
* @param vertexData - The vertex layout to be set
|
|
3552
3621
|
*/
|
|
3553
|
-
setVertexLayout(vertexData: VertexLayout): void;
|
|
3622
|
+
setVertexLayout(vertexData: Nullable<VertexLayout>): void;
|
|
3554
3623
|
/** Get current vertex layout */
|
|
3555
|
-
getVertexLayout(): VertexLayout
|
|
3624
|
+
getVertexLayout(): Nullable<VertexLayout>;
|
|
3556
3625
|
/**
|
|
3557
3626
|
* Set current render states
|
|
3558
3627
|
*
|
|
3559
3628
|
* @param renderStates - The render state set
|
|
3560
3629
|
*/
|
|
3561
|
-
setRenderStates(renderStates: RenderStateSet): void;
|
|
3630
|
+
setRenderStates(renderStates: Nullable<RenderStateSet>): void;
|
|
3562
3631
|
/** Get current render states */
|
|
3563
|
-
getRenderStates(): RenderStateSet
|
|
3632
|
+
getRenderStates(): Nullable<RenderStateSet>;
|
|
3564
3633
|
/**
|
|
3565
3634
|
* Sets the current framebuffer to the specified FrameBuffer object.
|
|
3566
3635
|
*
|
|
3567
3636
|
* @param rt - The FrameBuffer object to set as the current framebuffer.
|
|
3568
3637
|
*/
|
|
3569
|
-
setFramebuffer(rt: FrameBuffer):
|
|
3638
|
+
setFramebuffer(rt: Nullable<FrameBuffer>): void;
|
|
3570
3639
|
/**
|
|
3571
3640
|
* Sets the current framebuffer specifying complex color attachments, an optional depth attachment, MIP level, face, and sample count.
|
|
3572
3641
|
*
|
|
@@ -3579,14 +3648,10 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3579
3648
|
* @param depth - Optional BaseTexture to serve as the depth attachment.
|
|
3580
3649
|
* @param sampleCount - Optional sample count defining the number of samples for multisampling.
|
|
3581
3650
|
*/
|
|
3582
|
-
setFramebuffer(color:
|
|
3583
|
-
|
|
3584
|
-
miplevel?: number;
|
|
3585
|
-
face?: number;
|
|
3586
|
-
layer?: number;
|
|
3587
|
-
})[], depth?: BaseTexture, miplevel?: number, face?: number, sampleCount?: number): any;
|
|
3651
|
+
setFramebuffer(color: BaseTexture[], depth?: BaseTexture, sampleCount?: number): void;
|
|
3652
|
+
setFramebuffer(colorOrRT: BaseTexture[] | Nullable<FrameBuffer>, depth?: BaseTexture, sampleCount?: number): void;
|
|
3588
3653
|
/** Get current frame buffer */
|
|
3589
|
-
getFramebuffer(): FrameBuffer
|
|
3654
|
+
getFramebuffer(): Nullable<FrameBuffer>;
|
|
3590
3655
|
/**
|
|
3591
3656
|
* Set current bind group
|
|
3592
3657
|
*
|
|
@@ -3594,12 +3659,12 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3594
3659
|
* @param bindGroup - The bind group to be set
|
|
3595
3660
|
* @param dynamicOffsets - dynamic uniform buffer offsets of the bind group or null
|
|
3596
3661
|
*/
|
|
3597
|
-
setBindGroup(index: number, bindGroup: BindGroup, dynamicOffsets?: Iterable<number
|
|
3662
|
+
setBindGroup(index: number, bindGroup: BindGroup, dynamicOffsets?: Nullable<Iterable<number>>): void;
|
|
3598
3663
|
/**
|
|
3599
3664
|
* Get current bind group
|
|
3600
3665
|
* @param index - index of the bind group to get
|
|
3601
3666
|
*/
|
|
3602
|
-
getBindGroup(index: number): [BindGroup, Iterable<number
|
|
3667
|
+
getBindGroup(index: number): [BindGroup, Nullable<Iterable<number>>];
|
|
3603
3668
|
/** Flush the gpu command buffer */
|
|
3604
3669
|
flush(): void;
|
|
3605
3670
|
/**
|
|
@@ -3639,7 +3704,7 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3639
3704
|
* Executes render bundle
|
|
3640
3705
|
* @param renderBundle - RenderBundle to be execute
|
|
3641
3706
|
*/
|
|
3642
|
-
executeRenderBundle(renderBundle: RenderBundle):
|
|
3707
|
+
executeRenderBundle(renderBundle: RenderBundle): void;
|
|
3643
3708
|
/**
|
|
3644
3709
|
* End capture draw commands
|
|
3645
3710
|
* @returns A RenderBundle that holds the captured draw commands
|
|
@@ -3658,19 +3723,19 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3658
3723
|
/** Get the program builder */
|
|
3659
3724
|
programBuilder: ProgramBuilder;
|
|
3660
3725
|
/** Get the run loop callback function */
|
|
3661
|
-
runLoopFunction: (device: AbstractDevice) => void
|
|
3726
|
+
runLoopFunction: Nullable<(device: AbstractDevice) => void>;
|
|
3662
3727
|
/**
|
|
3663
3728
|
* Begins a frame for rendering
|
|
3664
3729
|
*
|
|
3665
3730
|
* @remarks
|
|
3666
|
-
* All rendering call must occur between the
|
|
3731
|
+
* All rendering call must occur between the @see AbstractDevice.beginFrame and @see AbstractDevice.endFrame methods
|
|
3667
3732
|
*/
|
|
3668
3733
|
beginFrame(): boolean;
|
|
3669
3734
|
/**
|
|
3670
3735
|
* Ends a frame for rendering
|
|
3671
3736
|
*
|
|
3672
3737
|
* @remarks
|
|
3673
|
-
* All rendering call must occur between the
|
|
3738
|
+
* All rendering call must occur between the @see AbstractDevice.beginFrame and @see AbstractDevice.endFrame methods
|
|
3674
3739
|
*/
|
|
3675
3740
|
endFrame(): void;
|
|
3676
3741
|
/**
|
|
@@ -3680,23 +3745,25 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3680
3745
|
* @param dataType - The data type
|
|
3681
3746
|
* @param componentCount - The component count
|
|
3682
3747
|
*/
|
|
3683
|
-
getVertexAttribFormat(semantic: VertexSemantic, dataType: DataType, componentCount: number): VertexAttribFormat
|
|
3748
|
+
getVertexAttribFormat(semantic: VertexSemantic, dataType: DataType, componentCount: number): Nullable<VertexAttribFormat>;
|
|
3684
3749
|
/**
|
|
3685
3750
|
* Creates an interleaved vertex buffer
|
|
3686
3751
|
*
|
|
3687
3752
|
* @param attribFormats - The vertex attribute formats for each vertex stream in the vertex buffer
|
|
3688
3753
|
* @param data - Data to be filled with
|
|
3689
3754
|
* @param options - The creation options
|
|
3755
|
+
* @returns The created vertex buffer.
|
|
3690
3756
|
*/
|
|
3691
|
-
createInterleavedVertexBuffer(attribFormats: VertexAttribFormat[], data: TypedArray, options?: BufferCreationOptions): StructuredBuffer
|
|
3757
|
+
createInterleavedVertexBuffer(attribFormats: VertexAttribFormat[], data: TypedArray, options?: BufferCreationOptions): Nullable<StructuredBuffer>;
|
|
3692
3758
|
/**
|
|
3693
3759
|
* Creates a non-interleaved vertex buffer
|
|
3694
3760
|
*
|
|
3695
3761
|
* @param attribFormat - The vertex attribute format
|
|
3696
3762
|
* @param data - Data to be filled with
|
|
3697
3763
|
* @param options - The creation options
|
|
3764
|
+
* @returns The created vertex buffer
|
|
3698
3765
|
*/
|
|
3699
|
-
createVertexBuffer(attribFormat: VertexAttribFormat, data: TypedArray, options?: BufferCreationOptions): StructuredBuffer
|
|
3766
|
+
createVertexBuffer(attribFormat: VertexAttribFormat, data: TypedArray, options?: BufferCreationOptions): Nullable<StructuredBuffer>;
|
|
3700
3767
|
/**
|
|
3701
3768
|
* Draw primitives
|
|
3702
3769
|
*
|
|
@@ -3728,6 +3795,12 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3728
3795
|
* @param f - The function to be scheduled
|
|
3729
3796
|
*/
|
|
3730
3797
|
runNextFrame(f: () => void): void;
|
|
3798
|
+
/**
|
|
3799
|
+
* Asyncronized version of scheduling a function to be executed at the beginning of the next frame
|
|
3800
|
+
*
|
|
3801
|
+
* @param f - The function to be scheduled
|
|
3802
|
+
*/
|
|
3803
|
+
runNextFrameAsync(f: () => void): Promise<void>;
|
|
3731
3804
|
/** Exits from current rendering loop */
|
|
3732
3805
|
exitLoop(): void;
|
|
3733
3806
|
/**
|
|
@@ -3743,56 +3816,51 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3743
3816
|
*
|
|
3744
3817
|
* @param uid - id of the GPU object
|
|
3745
3818
|
*/
|
|
3746
|
-
getGPUObjectById(uid: number): GPUObject
|
|
3819
|
+
getGPUObjectById(uid: number): Nullable<GPUObject>;
|
|
3747
3820
|
/**
|
|
3748
|
-
* Calculates the actual position of current frame buffer from screen position.
|
|
3821
|
+
* Calculates the actual position of current frame buffer from screen position in X axis.
|
|
3749
3822
|
*
|
|
3750
3823
|
* @remarks
|
|
3751
3824
|
* If current frame buffer is the back buffer, the value will be scaled by the device pixel ratio.
|
|
3752
3825
|
*
|
|
3753
3826
|
* @param val - The screen position in pixels
|
|
3754
3827
|
*/
|
|
3755
|
-
|
|
3828
|
+
screenXToDevice(val: number): number;
|
|
3756
3829
|
/**
|
|
3757
|
-
* Calculates the screen position from position of current frame buffer.
|
|
3830
|
+
* Calculates the screen position from position of current frame buffer in X axis.
|
|
3758
3831
|
*
|
|
3759
3832
|
* @remarks
|
|
3760
3833
|
* If current frame buffer is the back buffer, the value will be divided by the device pixel ratio.
|
|
3761
3834
|
*
|
|
3762
3835
|
* @param val - The position of current frame buffer in pixels
|
|
3763
3836
|
*/
|
|
3764
|
-
|
|
3837
|
+
deviceXToScreen(val: number): number;
|
|
3838
|
+
/**
|
|
3839
|
+
* Calculates the actual position of current frame buffer from screen position in Y axis.
|
|
3840
|
+
*
|
|
3841
|
+
* @remarks
|
|
3842
|
+
* If current frame buffer is the back buffer, the value will be scaled by the device pixel ratio.
|
|
3843
|
+
*
|
|
3844
|
+
* @param val - The screen position in pixels
|
|
3845
|
+
*/
|
|
3846
|
+
screenYToDevice(val: number): number;
|
|
3847
|
+
/**
|
|
3848
|
+
* Calculates the screen position from position of current frame buffer in Y axis.
|
|
3849
|
+
*
|
|
3850
|
+
* @remarks
|
|
3851
|
+
* If current frame buffer is the back buffer, the value will be divided by the device pixel ratio.
|
|
3852
|
+
*
|
|
3853
|
+
* @param val - The position of current frame buffer in pixels
|
|
3854
|
+
*/
|
|
3855
|
+
deviceYToScreen(val: number): number;
|
|
3765
3856
|
/** Builds render program */
|
|
3766
|
-
buildRenderProgram(options: PBRenderOptions): GPUProgram
|
|
3857
|
+
buildRenderProgram(options: PBRenderOptions): Nullable<GPUProgram>;
|
|
3767
3858
|
/** Builds compute program */
|
|
3768
|
-
buildComputeProgram(options: PBComputeOptions): GPUProgram
|
|
3859
|
+
buildComputeProgram(options: PBComputeOptions): Nullable<GPUProgram>;
|
|
3769
3860
|
/** Pushes current FrameBuffer state */
|
|
3770
|
-
pushDeviceStates():
|
|
3861
|
+
pushDeviceStates(): void;
|
|
3771
3862
|
/** Pops last FrameBuffer state */
|
|
3772
|
-
popDeviceStates():
|
|
3773
|
-
}
|
|
3774
|
-
|
|
3775
|
-
/**
|
|
3776
|
-
* Abstract timer interface
|
|
3777
|
-
* @public
|
|
3778
|
-
*/
|
|
3779
|
-
interface ITimer {
|
|
3780
|
-
begin(): void;
|
|
3781
|
-
end(): void;
|
|
3782
|
-
ended(): boolean;
|
|
3783
|
-
elapsed(): number;
|
|
3784
|
-
}
|
|
3785
|
-
/**
|
|
3786
|
-
* CPU timer class
|
|
3787
|
-
* @public
|
|
3788
|
-
*/
|
|
3789
|
-
declare class CPUTimer implements ITimer {
|
|
3790
|
-
constructor();
|
|
3791
|
-
now(): number;
|
|
3792
|
-
begin(): void;
|
|
3793
|
-
end(): void;
|
|
3794
|
-
ended(): boolean;
|
|
3795
|
-
elapsed(): number;
|
|
3863
|
+
popDeviceStates(): void;
|
|
3796
3864
|
}
|
|
3797
3865
|
|
|
3798
3866
|
/**
|
|
@@ -3801,14 +3869,15 @@ declare class CPUTimer implements ITimer {
|
|
|
3801
3869
|
*/
|
|
3802
3870
|
interface DeviceBackend {
|
|
3803
3871
|
typeName(): string;
|
|
3804
|
-
supported(): boolean
|
|
3805
|
-
createDevice(cvs: HTMLCanvasElement, options?: DeviceOptions): Promise<AbstractDevice
|
|
3872
|
+
supported(): Promise<boolean>;
|
|
3873
|
+
createDevice(cvs: HTMLCanvasElement, options?: DeviceOptions): Promise<Nullable<AbstractDevice>>;
|
|
3806
3874
|
}
|
|
3807
3875
|
/**
|
|
3808
3876
|
* Base class for rendering device
|
|
3809
3877
|
* @public
|
|
3810
3878
|
*/
|
|
3811
|
-
declare abstract class BaseDevice {
|
|
3879
|
+
declare abstract class BaseDevice extends Observable<DeviceEventMap> {
|
|
3880
|
+
protected _dpr: number;
|
|
3812
3881
|
protected _canvas: HTMLCanvasElement;
|
|
3813
3882
|
protected _canvasClientWidth: number;
|
|
3814
3883
|
protected _canvasClientHeight: number;
|
|
@@ -3819,33 +3888,36 @@ declare abstract class BaseDevice {
|
|
|
3819
3888
|
protected _endFrameTime: number;
|
|
3820
3889
|
protected _frameInfo: FrameInfo;
|
|
3821
3890
|
protected _cpuTimer: CPUTimer;
|
|
3822
|
-
protected _gpuTimer: ITimer
|
|
3823
|
-
protected _runningLoop: number
|
|
3891
|
+
protected _gpuTimer: Nullable<ITimer>;
|
|
3892
|
+
protected _runningLoop: Nullable<number>;
|
|
3824
3893
|
protected _fpsCounter: {
|
|
3825
3894
|
time: number;
|
|
3826
3895
|
frame: number;
|
|
3827
3896
|
};
|
|
3828
|
-
protected _runLoopFunc: (device: AbstractDevice) => void
|
|
3897
|
+
protected _runLoopFunc: Nullable<(device: AbstractDevice) => void>;
|
|
3829
3898
|
protected _backend: DeviceBackend;
|
|
3830
3899
|
protected _beginFrameCounter: number;
|
|
3831
3900
|
protected _programBuilder: ProgramBuilder;
|
|
3832
|
-
protected
|
|
3901
|
+
protected _poolMap: Map<string | symbol, Pool>;
|
|
3902
|
+
protected _defaultPoolKey: symbol;
|
|
3833
3903
|
protected _temporalFramebuffer: boolean;
|
|
3834
3904
|
protected _vSync: boolean;
|
|
3835
|
-
private
|
|
3836
|
-
|
|
3905
|
+
private readonly _resizer;
|
|
3906
|
+
private readonly _stateStack;
|
|
3907
|
+
constructor(cvs: HTMLCanvasElement, backend: DeviceBackend, dpr?: number);
|
|
3908
|
+
getScaleX(): number;
|
|
3909
|
+
getScaleY(): number;
|
|
3837
3910
|
abstract getAdapterInfo(): any;
|
|
3838
3911
|
abstract getFrameBufferSampleCount(): number;
|
|
3839
3912
|
abstract isContextLost(): boolean;
|
|
3840
|
-
abstract getScale(): number;
|
|
3841
3913
|
abstract getDrawingBufferWidth(): number;
|
|
3842
3914
|
abstract getDrawingBufferHeight(): number;
|
|
3843
3915
|
abstract getBackBufferWidth(): number;
|
|
3844
3916
|
abstract getBackBufferHeight(): number;
|
|
3845
|
-
abstract getDeviceCaps(): DeviceCaps
|
|
3917
|
+
abstract getDeviceCaps(): Immutable<DeviceCaps>;
|
|
3846
3918
|
abstract initContext(): Promise<void>;
|
|
3847
|
-
abstract clearFrameBuffer(clearColor: Vector4
|
|
3848
|
-
abstract createGPUTimer(): ITimer
|
|
3919
|
+
abstract clearFrameBuffer(clearColor: Nullable<Vector4>, clearDepth: Nullable<number>, clearStencil: Nullable<number>): void;
|
|
3920
|
+
abstract createGPUTimer(): Nullable<ITimer>;
|
|
3849
3921
|
abstract createRenderStateSet(): RenderStateSet;
|
|
3850
3922
|
abstract createBlendingState(): BlendingState;
|
|
3851
3923
|
abstract createColorState(): ColorState;
|
|
@@ -3853,52 +3925,49 @@ declare abstract class BaseDevice {
|
|
|
3853
3925
|
abstract createDepthState(): DepthState;
|
|
3854
3926
|
abstract createStencilState(): StencilState;
|
|
3855
3927
|
abstract createSampler(options: SamplerOptions): TextureSampler;
|
|
3856
|
-
abstract createTextureFromMipmapData<T extends BaseTexture>(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): T
|
|
3857
|
-
abstract createTexture2D(format: TextureFormat, width: number, height: number, options?: TextureCreationOptions): Texture2D
|
|
3858
|
-
abstract
|
|
3859
|
-
abstract
|
|
3860
|
-
abstract
|
|
3861
|
-
abstract
|
|
3862
|
-
abstract
|
|
3863
|
-
abstract createTexture3D(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Texture3D;
|
|
3864
|
-
abstract createCubeTexture(format: TextureFormat, size: number, options?: TextureCreationOptions): TextureCube;
|
|
3865
|
-
abstract createCubeTextureFromMipmapData(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): TextureCube;
|
|
3928
|
+
abstract createTextureFromMipmapData<T extends BaseTexture>(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): Nullable<T>;
|
|
3929
|
+
abstract createTexture2D(format: TextureFormat, width: number, height: number, options?: TextureCreationOptions): Nullable<Texture2D>;
|
|
3930
|
+
abstract createTexture2DFromImage(element: TextureImageElement, sRGB: boolean, options?: TextureCreationOptions): Nullable<Texture2D>;
|
|
3931
|
+
abstract createTexture2DArray(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Nullable<Texture2DArray>;
|
|
3932
|
+
abstract createTexture2DArrayFromImages(elements: TextureImageElement[], sRGB: boolean, options?: TextureCreationOptions): Nullable<Texture2DArray>;
|
|
3933
|
+
abstract createTexture3D(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Nullable<Texture3D>;
|
|
3934
|
+
abstract createCubeTexture(format: TextureFormat, size: number, options?: TextureCreationOptions): Nullable<TextureCube>;
|
|
3866
3935
|
abstract createTextureVideo(el: HTMLVideoElement, samplerOptions?: SamplerOptions): TextureVideo;
|
|
3867
3936
|
abstract reverseVertexWindingOrder(reverse: boolean): void;
|
|
3868
3937
|
abstract isWindingOrderReversed(): boolean;
|
|
3869
|
-
abstract copyTexture2D(src: Texture2D, srcLevel: number, dst: Texture2D, dstLevel: number):
|
|
3870
|
-
abstract copyFramebufferToTexture2D(src: FrameBuffer, index: number, dst: Texture2D, level: number):
|
|
3938
|
+
abstract copyTexture2D(src: Texture2D, srcLevel: number, dst: Texture2D, dstLevel: number): void;
|
|
3939
|
+
abstract copyFramebufferToTexture2D(src: FrameBuffer, index: number, dst: Texture2D, level: number): void;
|
|
3871
3940
|
abstract createGPUProgram(params: GPUProgramConstructParams): GPUProgram;
|
|
3872
|
-
abstract createBindGroup(layout: BindGroupLayout): BindGroup;
|
|
3941
|
+
abstract createBindGroup(layout: Immutable<BindGroupLayout>): BindGroup;
|
|
3873
3942
|
abstract createBuffer(sizeInBytes: number, options: BufferCreationOptions): GPUDataBuffer;
|
|
3874
|
-
abstract copyBuffer(sourceBuffer: GPUDataBuffer, destBuffer: GPUDataBuffer, srcOffset: number, dstOffset: number, bytes: number):
|
|
3875
|
-
abstract createIndexBuffer(data: Uint16Array | Uint32Array
|
|
3943
|
+
abstract copyBuffer(sourceBuffer: GPUDataBuffer, destBuffer: GPUDataBuffer, srcOffset: number, dstOffset: number, bytes: number): void;
|
|
3944
|
+
abstract createIndexBuffer(data: Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer>, options?: BufferCreationOptions): IndexBuffer;
|
|
3876
3945
|
abstract createStructuredBuffer(structureType: PBStructTypeInfo, options: BufferCreationOptions, data?: TypedArray): StructuredBuffer;
|
|
3877
3946
|
abstract createVertexLayout(options: VertexLayoutOptions): VertexLayout;
|
|
3878
|
-
abstract createFrameBuffer(colorAttachments: BaseTexture[], depthAttachment: BaseTexture
|
|
3879
|
-
abstract setViewport(vp
|
|
3880
|
-
abstract getViewport(): DeviceViewport
|
|
3881
|
-
abstract setScissor(scissor
|
|
3882
|
-
abstract getScissor(): DeviceViewport
|
|
3883
|
-
abstract setProgram(program: GPUProgram): void;
|
|
3884
|
-
abstract getProgram(): GPUProgram
|
|
3885
|
-
abstract setVertexLayout(vertexData: VertexLayout): void;
|
|
3886
|
-
abstract getVertexLayout(): VertexLayout
|
|
3887
|
-
abstract setRenderStates(renderStates: RenderStateSet): void;
|
|
3888
|
-
abstract getRenderStates(): RenderStateSet
|
|
3889
|
-
abstract getFramebuffer(): FrameBuffer
|
|
3890
|
-
abstract setBindGroup(index: number, bindGroup: BindGroup, dynamicOffsets?: Iterable<number
|
|
3891
|
-
abstract getBindGroup(index: number): [BindGroup, Iterable<number
|
|
3947
|
+
abstract createFrameBuffer(colorAttachments: BaseTexture[], depthAttachment: Nullable<BaseTexture>, options?: Nullable<FrameBufferOptions>): FrameBuffer;
|
|
3948
|
+
abstract setViewport(vp: Nullable<Immutable<number[] | DeviceViewport>>): void;
|
|
3949
|
+
abstract getViewport(): Immutable<DeviceViewport>;
|
|
3950
|
+
abstract setScissor(scissor: Nullable<Immutable<number[] | DeviceViewport>>): void;
|
|
3951
|
+
abstract getScissor(): Immutable<DeviceViewport>;
|
|
3952
|
+
abstract setProgram(program: Nullable<GPUProgram>): void;
|
|
3953
|
+
abstract getProgram(): Nullable<GPUProgram>;
|
|
3954
|
+
abstract setVertexLayout(vertexData: Nullable<VertexLayout>): void;
|
|
3955
|
+
abstract getVertexLayout(): Nullable<VertexLayout>;
|
|
3956
|
+
abstract setRenderStates(renderStates: Nullable<RenderStateSet>): void;
|
|
3957
|
+
abstract getRenderStates(): Nullable<RenderStateSet>;
|
|
3958
|
+
abstract getFramebuffer(): Nullable<FrameBuffer>;
|
|
3959
|
+
abstract setBindGroup(index: number, bindGroup: BindGroup, dynamicOffsets?: Nullable<Iterable<number>>): void;
|
|
3960
|
+
abstract getBindGroup(index: number): [BindGroup, Nullable<Iterable<number>>];
|
|
3892
3961
|
abstract flush(): void;
|
|
3893
3962
|
abstract nextFrame(callback: () => void): number;
|
|
3894
|
-
abstract cancelNextFrame(handle: number):
|
|
3963
|
+
abstract cancelNextFrame(handle: number): void;
|
|
3895
3964
|
abstract readPixels(index: number, x: number, y: number, w: number, h: number, buffer: TypedArray): Promise<void>;
|
|
3896
3965
|
abstract readPixelsToBuffer(index: number, x: number, y: number, w: number, h: number, buffer: GPUDataBuffer): void;
|
|
3897
3966
|
abstract beginCapture(): void;
|
|
3898
3967
|
abstract endCapture(): RenderBundle;
|
|
3899
|
-
abstract executeRenderBundle(renderBundle: RenderBundle): any;
|
|
3900
3968
|
abstract looseContext(): void;
|
|
3901
3969
|
abstract restoreContext(): void;
|
|
3970
|
+
protected abstract _executeRenderBundle(renderBundle: RenderBundle): number;
|
|
3902
3971
|
protected abstract _draw(primitiveType: PrimitiveType, first: number, count: number): void;
|
|
3903
3972
|
protected abstract _drawInstanced(primitiveType: PrimitiveType, first: number, count: number, numInstances: number): void;
|
|
3904
3973
|
protected abstract _compute(workgroupCountX: number, workgroupCountY: number, workgroupCountZ: number): void;
|
|
@@ -3911,53 +3980,54 @@ declare abstract class BaseDevice {
|
|
|
3911
3980
|
get vSync(): boolean;
|
|
3912
3981
|
set vSync(val: boolean);
|
|
3913
3982
|
get pool(): Pool;
|
|
3914
|
-
get runLoopFunction(): (device: AbstractDevice) => void
|
|
3983
|
+
get runLoopFunction(): Nullable<(device: AbstractDevice) => void>;
|
|
3915
3984
|
get programBuilder(): ProgramBuilder;
|
|
3985
|
+
poolExists(key: string | symbol): boolean;
|
|
3986
|
+
getPool(key: string | symbol): Pool;
|
|
3916
3987
|
setFont(fontName: string): void;
|
|
3917
|
-
drawText(text: string, x: number, y: number, color: string): void;
|
|
3918
|
-
setFramebuffer(rt: FrameBuffer):
|
|
3919
|
-
setFramebuffer(color:
|
|
3920
|
-
texture: BaseTexture;
|
|
3921
|
-
miplevel?: number;
|
|
3922
|
-
face?: number;
|
|
3923
|
-
layer?: number;
|
|
3924
|
-
})[], depth?: BaseTexture, sampleCount?: number): any;
|
|
3988
|
+
drawText(text: string, x: number, y: number, color: string, viewport?: Immutable<number[]>): void;
|
|
3989
|
+
setFramebuffer(rt: Nullable<FrameBuffer>): void;
|
|
3990
|
+
setFramebuffer(color: BaseTexture[], depth?: BaseTexture, sampleCount?: number): void;
|
|
3925
3991
|
disposeObject(obj: GPUObject, remove?: boolean): void;
|
|
3926
|
-
restoreObject(obj: GPUObject):
|
|
3992
|
+
restoreObject(obj: GPUObject): void;
|
|
3927
3993
|
enableGPUTimeRecording(enable: boolean): void;
|
|
3928
3994
|
beginFrame(): boolean;
|
|
3929
3995
|
endFrame(): void;
|
|
3930
|
-
getVertexAttribFormat(semantic: VertexSemantic, dataType: DataType, componentCount: number): VertexAttribFormat;
|
|
3931
|
-
createInterleavedVertexBuffer(attribFormats: VertexAttribFormat[], data: TypedArray, options?: BufferCreationOptions): StructuredBuffer;
|
|
3932
|
-
createVertexBuffer(attribFormat: VertexAttribFormat, data: TypedArray, options?: BufferCreationOptions): StructuredBuffer;
|
|
3996
|
+
getVertexAttribFormat(semantic: VertexSemantic, dataType: DataType, componentCount: number): VertexAttribFormat | null;
|
|
3997
|
+
createInterleavedVertexBuffer(attribFormats: VertexAttribFormat[], data: TypedArray, options?: BufferCreationOptions): StructuredBuffer<unknown> | null;
|
|
3998
|
+
createVertexBuffer(attribFormat: VertexAttribFormat, data: TypedArray, options?: BufferCreationOptions): StructuredBuffer<unknown> | null;
|
|
3933
3999
|
draw(primitiveType: PrimitiveType, first: number, count: number): void;
|
|
3934
4000
|
drawInstanced(primitiveType: PrimitiveType, first: number, count: number, numInstances: number): void;
|
|
3935
|
-
|
|
4001
|
+
executeRenderBundle(renderBundle: RenderBundle): void;
|
|
4002
|
+
compute(workgroupCountX: number, workgroupCountY: number, workgroupCountZ: number): void;
|
|
3936
4003
|
runNextFrame(f: () => void): void;
|
|
4004
|
+
runNextFrameAsync(f: () => void | Promise<void>): Promise<void>;
|
|
3937
4005
|
exitLoop(): void;
|
|
3938
4006
|
runLoop(func: (device: AbstractDevice) => void): void;
|
|
3939
4007
|
pushDeviceStates(): void;
|
|
3940
4008
|
popDeviceStates(): void;
|
|
3941
4009
|
getGPUObjects(): GPUObjectList;
|
|
3942
|
-
getGPUObjectById(uid: number):
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
4010
|
+
getGPUObjectById(uid: number): GPUDataBuffer<unknown> | BaseTexture<unknown> | VertexLayout<unknown> | FrameBuffer<unknown> | TextureSampler<unknown> | GPUProgram<unknown> | null;
|
|
4011
|
+
screenXToDevice(val: number): number;
|
|
4012
|
+
deviceXToScreen(val: number): number;
|
|
4013
|
+
screenYToDevice(val: number): number;
|
|
4014
|
+
deviceYToScreen(val: number): number;
|
|
4015
|
+
buildRenderProgram(options: PBRenderOptions): Nullable<GPUProgram<unknown>>;
|
|
4016
|
+
buildComputeProgram(options: PBComputeOptions): Nullable<GPUProgram<unknown>>;
|
|
3947
4017
|
addGPUObject(obj: GPUObject): void;
|
|
3948
4018
|
removeGPUObject(obj: GPUObject): void;
|
|
3949
4019
|
updateVideoMemoryCost(delta: number): void;
|
|
3950
4020
|
protected abstract onBeginFrame(): boolean;
|
|
3951
4021
|
protected abstract onEndFrame(): void;
|
|
3952
|
-
protected abstract _setFramebuffer(fb: FrameBuffer):
|
|
3953
|
-
|
|
3954
|
-
|
|
4022
|
+
protected abstract _setFramebuffer(fb: Nullable<FrameBuffer>): void;
|
|
4023
|
+
protected abstract _handleResize(cssWidth: number, cssHeight: number, deviceWidth: number, deviceHeight: number): void;
|
|
4024
|
+
protected initResizer(): Promise<void>;
|
|
3955
4025
|
private updateFrameInfo;
|
|
3956
4026
|
private getGPUObjectList;
|
|
3957
4027
|
protected invalidateAll(): void;
|
|
3958
|
-
protected reloadAll():
|
|
4028
|
+
protected reloadAll(): void;
|
|
3959
4029
|
protected parseTextureOptions(options?: TextureCreationOptions): number;
|
|
3960
|
-
protected parseBufferOptions(options
|
|
4030
|
+
protected parseBufferOptions(options?: BufferCreationOptions, defaultUsage?: BufferUsage): number;
|
|
3961
4031
|
}
|
|
3962
4032
|
/**
|
|
3963
4033
|
* Merge event target interface
|
|
@@ -3997,20 +4067,20 @@ declare class TextureAtlasManager {
|
|
|
3997
4067
|
* The texture restore handler callback function
|
|
3998
4068
|
* This callback function will be called whenever the device has been restored
|
|
3999
4069
|
*/
|
|
4000
|
-
get atlasTextureRestoreHandler(): (tex: BaseTexture) =>
|
|
4001
|
-
set atlasTextureRestoreHandler(f: (tex: BaseTexture) =>
|
|
4070
|
+
get atlasTextureRestoreHandler(): Nullable<(tex: BaseTexture) => void>;
|
|
4071
|
+
set atlasTextureRestoreHandler(f: Nullable<(tex: BaseTexture) => void>);
|
|
4002
4072
|
/**
|
|
4003
4073
|
* Gets the atlas texture of a given index
|
|
4004
4074
|
* @param index - Index of the atlas bin
|
|
4005
4075
|
* @returns Atlas texture for given index
|
|
4006
4076
|
*/
|
|
4007
|
-
getAtlasTexture(index: number): Texture2D;
|
|
4077
|
+
getAtlasTexture(index: number): Texture2D<unknown> | undefined;
|
|
4008
4078
|
/**
|
|
4009
4079
|
* Gets the information about specified atlas
|
|
4010
4080
|
* @param key - Key of the atlas
|
|
4011
4081
|
* @returns Information of the atlas
|
|
4012
4082
|
*/
|
|
4013
|
-
getAtlasInfo(key: string): AtlasInfo;
|
|
4083
|
+
getAtlasInfo(key: string): AtlasInfo | null;
|
|
4014
4084
|
/**
|
|
4015
4085
|
* Check if no atlas has been created
|
|
4016
4086
|
* @returns true if no atlas has been created
|
|
@@ -4030,14 +4100,14 @@ declare class TextureAtlasManager {
|
|
|
4030
4100
|
* @param h - height of the rectangle
|
|
4031
4101
|
* @returns The atals info or null if insert failed
|
|
4032
4102
|
*/
|
|
4033
|
-
pushCanvas(key: string, ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number): AtlasInfo;
|
|
4103
|
+
pushCanvas(key: string, ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number): AtlasInfo | null;
|
|
4034
4104
|
/**
|
|
4035
4105
|
* Inserts a bitmap to the atlas texture
|
|
4036
4106
|
* @param key - Key of the atlas
|
|
4037
4107
|
* @param bitmap - The bitmap object
|
|
4038
4108
|
* @returns The atals info or null if insert failed
|
|
4039
4109
|
*/
|
|
4040
|
-
pushBitmap(key: string, bitmap: ImageData | ImageBitmap): AtlasInfo;
|
|
4110
|
+
pushBitmap(key: string, bitmap: ImageData | ImageBitmap): AtlasInfo | null;
|
|
4041
4111
|
}
|
|
4042
4112
|
|
|
4043
4113
|
/**
|
|
@@ -4097,12 +4167,13 @@ declare class GlyphManager extends TextureAtlasManager {
|
|
|
4097
4167
|
*/
|
|
4098
4168
|
constructor(device: AbstractDevice, binWidth: number, binHeight: number, border: number);
|
|
4099
4169
|
/**
|
|
4100
|
-
* Gets the
|
|
4170
|
+
* Gets the size for given character
|
|
4101
4171
|
* @param char - The character
|
|
4102
4172
|
* @param font - Font of the character
|
|
4103
|
-
* @returns
|
|
4173
|
+
* @returns [width, height]
|
|
4104
4174
|
*/
|
|
4105
|
-
|
|
4175
|
+
getGlyphSize(char: string, font: Font): number[] | null;
|
|
4176
|
+
getGlyphInfo(char: string, font: Font): AtlasInfo | null;
|
|
4106
4177
|
/**
|
|
4107
4178
|
* Measuring the width of a string
|
|
4108
4179
|
* @param str - The string to be measured
|
|
@@ -4149,7 +4220,7 @@ declare class DrawText {
|
|
|
4149
4220
|
* @param x - X coordinate of the text
|
|
4150
4221
|
* @param y - Y coordinate of the text
|
|
4151
4222
|
*/
|
|
4152
|
-
static drawText(device: AbstractDevice, text: string, color: string, x: number, y: number): void;
|
|
4223
|
+
static drawText(device: AbstractDevice, text: string, color: string, x: number, y: number, viewport?: Immutable<number[]>): void;
|
|
4153
4224
|
}
|
|
4154
4225
|
|
|
4155
4226
|
/**
|
|
@@ -4162,11 +4233,11 @@ declare class StructuredBufferData {
|
|
|
4162
4233
|
* @param layout - Layout of the structure
|
|
4163
4234
|
* @param buffer - Buffer that holds the data
|
|
4164
4235
|
*/
|
|
4165
|
-
constructor(layout: UniformBufferLayout, buffer?: StructuredBuffer | ArrayBuffer);
|
|
4236
|
+
constructor(layout: UniformBufferLayout, buffer?: Nullable<StructuredBuffer | ArrayBuffer>);
|
|
4166
4237
|
/** The buffer size in bytes */
|
|
4167
4238
|
get byteLength(): number;
|
|
4168
4239
|
/** Get the data cache buffer */
|
|
4169
|
-
get buffer(): ArrayBuffer
|
|
4240
|
+
get buffer(): Nullable<ArrayBuffer>;
|
|
4170
4241
|
/** Get all the uniform datas */
|
|
4171
4242
|
get uniforms(): Record<string, TypedArray>;
|
|
4172
4243
|
/**
|
|
@@ -4177,4 +4248,4 @@ declare class StructuredBufferData {
|
|
|
4177
4248
|
set(name: string, value: StructuredValue): void;
|
|
4178
4249
|
}
|
|
4179
4250
|
|
|
4180
|
-
export { AbstractDevice, ArrayTypeDetail, AtlasInfo, AtomicTypeInfoDetail, BaseCreationOptions, BaseDevice, BaseTexture, BindGroup, BindGroupLayout, BindGroupLayoutEntry, BindPointInfo, BlendEquation, BlendFunc, BlendingState, BufferBindingLayout, BufferCreationOptions, BufferUsage, CPUTimer, ColorState, CompareFunc, ComputeProgramConstructParams, DataType, DepthState, DeviceBackend, DeviceCaps, DeviceEventMap,
|
|
4251
|
+
export { type AbstractDevice, type ArrayTypeDetail, type AtlasInfo, type AtomicTypeInfoDetail, type BaseCreationOptions, BaseDevice, type BaseTexture, type BindGroup, type BindGroupLayout, type BindGroupLayoutEntry, type BindPointInfo, type BlendEquation, type BlendFunc, type BlendingState, type BufferBindingLayout, type BufferCreationOptions, type BufferUsage, CPUTimer, type ColorState, type CompareFunc, type ComputeProgramConstructParams, type DataType, type DepthState, type DeviceBackend, type DeviceCaps, type DeviceEventMap, type DeviceOptions, type DeviceViewport, DrawText, type ExpValueNonArrayType, type ExpValueType, type ExternalTextureBindingLayout, type FaceMode, type FaceWinding, Font, type FrameBuffer, type FrameBufferOptions, type FrameBufferTextureAttachment, type FrameInfo, type FramebufferCaps, type FunctionTypeDetail, type GPUDataBuffer, type GPUObject, type GPUObjectList, type GPUProgram, type GPUProgramConstructParams, GPUResourceUsageFlags, GlyphManager, type ITimer, type IndexBuffer, MAX_BINDING_GROUPS, MAX_TEXCOORD_INDEX_COUNT, MAX_VERTEX_ATTRIBUTES, type MiscCaps, PBAddressSpace, PBAnyTypeInfo, PBArrayTypeInfo, PBAtomicI32TypeInfo, PBAtomicU32TypeInfo, PBBuiltinScope, type PBComputeOptions, PBDoWhileScope, PBForScope, PBFunctionScope, PBFunctionTypeInfo, PBGlobalScope, PBIfScope, PBInputScope, PBInsideFunctionScope, PBLocalScope, PBNakedScope, PBOutputScope, PBPointerTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, PBReflection, type PBReflectionTagGetter, type PBRenderOptions, PBSamplerAccessMode, PBSamplerTypeInfo, PBScope, PBShaderExp, type PBStructLayout, PBStructTypeInfo, PBTextureType, PBTextureTypeInfo, PBTypeInfo, PBVoidTypeInfo, PBWhileScope, type PointerTypeDetail, Pool, type PrimitiveType, type PrimitiveTypeDetail, ProgramBuilder, Proxiable, type RasterizerState, type RenderBundle, type RenderProgramConstructParams, type RenderStateSet, type SamplerBindingLayout, type SamplerOptions, type SamplerTypeDetail, type ShaderCaps, type ShaderExpTagRecord, type ShaderExpTagValue, type ShaderKind, ShaderType, type ShaderTypeFunc, type StencilOp, type StencilState, type StorageTextureBindingLayout, type StructTypeDetail, type StructuredBuffer, StructuredBufferData, type StructuredValue, type Texture2D, type Texture2DArray, type Texture3D, type TextureAddressMode, TextureAtlasManager, type TextureBindingLayout, type TextureCaps, type TextureColorSpace, type TextureCreationOptions, type TextureCube, type TextureFilterMode, type TextureFormat, type TextureFormatInfo, type TextureImageElement, type TextureMipmapData, type TextureMipmapLevelData, type TextureSampler, type TextureType, type TextureTypeDetail, type TextureVideo, type TypeDetailInfo, type UniformBufferLayout, type UniformLayout, VERTEX_ATTRIB_BLEND_INDICES, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_DIFFUSE, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TANGENT, VERTEX_ATTRIB_TEXCOORD0, VERTEX_ATTRIB_TEXCOORD1, VERTEX_ATTRIB_TEXCOORD2, VERTEX_ATTRIB_TEXCOORD3, VERTEX_ATTRIB_TEXCOORD4, VERTEX_ATTRIB_TEXCOORD5, VERTEX_ATTRIB_TEXCOORD6, VERTEX_ATTRIB_TEXCOORD7, type VertexAttribFormat, type VertexBufferInfo, VertexData, type VertexLayout, type VertexLayoutOptions, type VertexSemantic, type VertexStepMode, type WebGLContext, genDefaultName, getTextureFormatBlockHeight, getTextureFormatBlockSize, getTextureFormatBlockWidth, getVertexAttribByName, getVertexAttribFormat, getVertexAttribName, getVertexAttributeFormat, getVertexAttributeIndex, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, getVertexFormatComponentCount, getVertexFormatSize, hasAlphaChannel, hasBlueChannel, hasDepthChannel, hasGreenChannel, hasRedChannel, hasStencilChannel, isCompressedTextureFormat, isFloatTextureFormat, isIntegerTextureFormat, isSRGBTextureFormat, isSignedTextureFormat, linearTextureFormatToSRGB, makeVertexBufferType, matchVertexBuffer, semanticList };
|