@zephyr3d/device 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base_types.js +7 -66
- package/dist/base_types.js.map +1 -1
- package/dist/builder/ast.js +112 -118
- package/dist/builder/ast.js.map +1 -1
- package/dist/builder/base.js +23 -25
- package/dist/builder/base.js.map +1 -1
- package/dist/builder/builtinfunc.js +19 -1
- package/dist/builder/builtinfunc.js.map +1 -1
- package/dist/builder/constructors.js +1 -1
- package/dist/builder/constructors.js.map +1 -1
- package/dist/builder/errors.js +7 -7
- package/dist/builder/errors.js.map +1 -1
- package/dist/builder/misc.js +10 -0
- package/dist/builder/misc.js.map +1 -0
- package/dist/builder/programbuilder.js +45 -32
- package/dist/builder/programbuilder.js.map +1 -1
- package/dist/builder/reflection.js.map +1 -1
- package/dist/builder/types.js +70 -70
- package/dist/builder/types.js.map +1 -1
- package/dist/device.js +72 -43
- package/dist/device.js.map +1 -1
- package/dist/gpuobject.js +82 -24
- package/dist/gpuobject.js.map +1 -1
- package/dist/helpers/drawtext.js +1 -0
- package/dist/helpers/drawtext.js.map +1 -1
- package/dist/helpers/font.js +1 -0
- package/dist/helpers/font.js.map +1 -1
- package/dist/helpers/glyphmanager.js +7 -7
- package/dist/helpers/glyphmanager.js.map +1 -1
- package/dist/helpers/textureatlas.js +3 -5
- package/dist/helpers/textureatlas.js.map +1 -1
- package/dist/index.d.ts +199 -152
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/pool.js +54 -25
- package/dist/pool.js.map +1 -1
- package/dist/timer.js.map +1 -1
- package/dist/uniformdata.js +2 -2
- package/dist/uniformdata.js.map +1 -1
- package/dist/vertexdata.js +27 -1
- package/dist/vertexdata.js.map +1 -1
- package/package.json +31 -16
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TypedArray,
|
|
1
|
+
import { TypedArray, IDisposable, CubeFace, VectorBase, MaybeArray, IEventTarget, Vector4, Observable } from '@zephyr3d/base';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Struct layout types
|
|
@@ -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): UniformBufferLayout;
|
|
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): UniformBufferLayout;
|
|
306
306
|
/** {@inheritDoc PBTypeInfo.isCompatibleType} */
|
|
307
|
-
isCompatibleType(
|
|
307
|
+
isCompatibleType(_other: PBTypeInfo<TypeDetailInfo>): boolean;
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* The primitive type info
|
|
@@ -342,7 +342,7 @@ 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): UniformBufferLayout;
|
|
346
346
|
}
|
|
347
347
|
/**
|
|
348
348
|
* The struct type info
|
|
@@ -363,7 +363,7 @@ declare class PBStructTypeInfo extends PBTypeInfo<StructTypeDetail> {
|
|
|
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 */
|
|
@@ -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): UniformBufferLayout;
|
|
409
409
|
isCompatibleType(other: PBTypeInfo<TypeDetailInfo>): boolean;
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
@@ -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): UniformBufferLayout;
|
|
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): UniformBufferLayout;
|
|
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): UniformBufferLayout;
|
|
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): UniformBufferLayout;
|
|
461
461
|
}
|
|
462
462
|
/**
|
|
463
463
|
* The texture type info
|
|
@@ -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): UniformBufferLayout;
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
502
502
|
* The function type info
|
|
@@ -519,7 +519,7 @@ declare class PBFunctionTypeInfo extends PBTypeInfo<FunctionTypeDetail> {
|
|
|
519
519
|
/** Get hash for parameter types */
|
|
520
520
|
get argHash(): string;
|
|
521
521
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
522
|
-
toBufferLayout(
|
|
522
|
+
toBufferLayout(_offset: number): UniformBufferLayout;
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
/**
|
|
@@ -548,7 +548,9 @@ declare class VertexData {
|
|
|
548
548
|
/** Vertex buffer information list */
|
|
549
549
|
get vertexBuffers(): VertexBufferInfo[];
|
|
550
550
|
/** Index buffer */
|
|
551
|
-
get indexBuffer(): IndexBuffer
|
|
551
|
+
get indexBuffer(): IndexBuffer;
|
|
552
|
+
/** Number of vertices */
|
|
553
|
+
get numVertices(): number;
|
|
552
554
|
/** Draw offset */
|
|
553
555
|
getDrawOffset(): number;
|
|
554
556
|
setDrawOffset(offset: number): void;
|
|
@@ -595,6 +597,40 @@ declare class VertexData {
|
|
|
595
597
|
* @public
|
|
596
598
|
*/
|
|
597
599
|
type TextureImageElement = ImageBitmap | HTMLCanvasElement;
|
|
600
|
+
/** @public */
|
|
601
|
+
declare const MAX_VERTEX_ATTRIBUTES = 16;
|
|
602
|
+
/** @public */
|
|
603
|
+
declare const MAX_BINDING_GROUPS = 4;
|
|
604
|
+
/** @public */
|
|
605
|
+
declare const MAX_TEXCOORD_INDEX_COUNT = 8;
|
|
606
|
+
/** @public */
|
|
607
|
+
declare const VERTEX_ATTRIB_POSITION = 0;
|
|
608
|
+
/** @public */
|
|
609
|
+
declare const VERTEX_ATTRIB_NORMAL = 1;
|
|
610
|
+
/** @public */
|
|
611
|
+
declare const VERTEX_ATTRIB_DIFFUSE = 2;
|
|
612
|
+
/** @public */
|
|
613
|
+
declare const VERTEX_ATTRIB_TANGENT = 3;
|
|
614
|
+
/** @public */
|
|
615
|
+
declare const VERTEX_ATTRIB_TEXCOORD0 = 4;
|
|
616
|
+
/** @public */
|
|
617
|
+
declare const VERTEX_ATTRIB_TEXCOORD1 = 5;
|
|
618
|
+
/** @public */
|
|
619
|
+
declare const VERTEX_ATTRIB_TEXCOORD2 = 6;
|
|
620
|
+
/** @public */
|
|
621
|
+
declare const VERTEX_ATTRIB_TEXCOORD3 = 7;
|
|
622
|
+
/** @public */
|
|
623
|
+
declare const VERTEX_ATTRIB_TEXCOORD4 = 8;
|
|
624
|
+
/** @public */
|
|
625
|
+
declare const VERTEX_ATTRIB_TEXCOORD5 = 9;
|
|
626
|
+
/** @public */
|
|
627
|
+
declare const VERTEX_ATTRIB_TEXCOORD6 = 10;
|
|
628
|
+
/** @public */
|
|
629
|
+
declare const VERTEX_ATTRIB_TEXCOORD7 = 11;
|
|
630
|
+
/** @public */
|
|
631
|
+
declare const VERTEX_ATTRIB_BLEND_WEIGHT = 12;
|
|
632
|
+
/** @public */
|
|
633
|
+
declare const VERTEX_ATTRIB_BLEND_INDICES = 13;
|
|
598
634
|
/**
|
|
599
635
|
* The vertex format types
|
|
600
636
|
* @public
|
|
@@ -614,14 +650,7 @@ type VertexLayoutOptions = {
|
|
|
614
650
|
* vertex buffers in this vertex layout
|
|
615
651
|
*/
|
|
616
652
|
vertexBuffers: {
|
|
617
|
-
/**
|
|
618
|
-
* vertex buffer object created by device
|
|
619
|
-
*/
|
|
620
653
|
buffer: StructuredBuffer;
|
|
621
|
-
/**
|
|
622
|
-
* the vertex buffer step mode,
|
|
623
|
-
* value can be 'vertex' or 'instance', default is 'vertex'
|
|
624
|
-
*/
|
|
625
654
|
stepMode?: VertexStepMode;
|
|
626
655
|
}[];
|
|
627
656
|
/**
|
|
@@ -638,7 +667,7 @@ type TextureColorSpace = 'srgb' | 'linear';
|
|
|
638
667
|
* Buffer usage type
|
|
639
668
|
* @public
|
|
640
669
|
*/
|
|
641
|
-
type BufferUsage = 'vertex' | 'index' | 'uniform' | 'read' | 'write';
|
|
670
|
+
type BufferUsage = 'vertex' | 'index' | 'uniform' | 'read' | 'write' | 'pack-pixel' | 'unpack-pixel';
|
|
642
671
|
/**
|
|
643
672
|
* Common options for createing texture or buffer
|
|
644
673
|
* @public
|
|
@@ -656,6 +685,7 @@ interface BaseCreationOptions {
|
|
|
656
685
|
interface TextureCreationOptions extends BaseCreationOptions {
|
|
657
686
|
writable?: boolean;
|
|
658
687
|
texture?: BaseTexture;
|
|
688
|
+
mipmapping?: boolean;
|
|
659
689
|
samplerOptions?: SamplerOptions;
|
|
660
690
|
}
|
|
661
691
|
/**
|
|
@@ -685,8 +715,10 @@ declare enum GPUResourceUsageFlags {
|
|
|
685
715
|
BF_WRITE = 256,
|
|
686
716
|
BF_UNIFORM = 512,
|
|
687
717
|
BF_STORAGE = 1024,
|
|
688
|
-
|
|
689
|
-
|
|
718
|
+
BF_PACK_PIXEL = 2048,
|
|
719
|
+
BF_UNPACK_PIXEL = 4096,
|
|
720
|
+
DYNAMIC = 8192,
|
|
721
|
+
MANAGED = 16384
|
|
690
722
|
}
|
|
691
723
|
/**
|
|
692
724
|
* Get vertex attribute index by semantic
|
|
@@ -698,13 +730,40 @@ declare function getVertexAttribByName(name: VertexSemantic): number;
|
|
|
698
730
|
* @public
|
|
699
731
|
*/
|
|
700
732
|
declare function getVertexAttribName(attrib: number): VertexSemantic;
|
|
733
|
+
/**
|
|
734
|
+
* Test whether a vertex buffer matches given semantic
|
|
735
|
+
* @param buffer - Vertex buffer
|
|
736
|
+
* @param name - Semantic to test
|
|
737
|
+
* @returns true if the vertex buffer matches given semantic, otherwise false
|
|
738
|
+
*
|
|
739
|
+
* @public
|
|
740
|
+
*/
|
|
741
|
+
declare function matchVertexBuffer(buffer: StructuredBuffer, name: VertexSemantic): boolean;
|
|
742
|
+
/**
|
|
743
|
+
* Get vertex attribute type of specified vertex format
|
|
744
|
+
* @param fmt - The vertex format
|
|
745
|
+
* @returns Vertex attribute type, possible values are 'f32', 'f16', 'i32', 'u32', 'i16', 'u16', 'i8norm', 'u8norm', 'i16norm', 'u16norm'
|
|
746
|
+
*
|
|
747
|
+
* @public
|
|
748
|
+
*/
|
|
749
|
+
declare function getVertexAttributeFormat(fmt: VertexAttribFormat): "f32" | "i32" | "u32" | "u8norm" | "i8norm" | "u16" | "i16" | "u16norm" | "i16norm" | "f16";
|
|
750
|
+
/**
|
|
751
|
+
* Get vertex attribute index of specified vertex format
|
|
752
|
+
* @param fmt - The vertex format
|
|
753
|
+
* @returns Vertex attribute index
|
|
754
|
+
*
|
|
755
|
+
* @public
|
|
756
|
+
*/
|
|
757
|
+
declare function getVertexAttributeIndex(fmt: VertexAttribFormat): number;
|
|
701
758
|
/**
|
|
702
759
|
* Get byte size of specified vertex format
|
|
760
|
+
*
|
|
703
761
|
* @public
|
|
704
762
|
*/
|
|
705
763
|
declare function getVertexFormatSize(fmt: VertexAttribFormat): number;
|
|
706
764
|
/**
|
|
707
765
|
* Get number of components of specified vertex format
|
|
766
|
+
*
|
|
708
767
|
* @public
|
|
709
768
|
*/
|
|
710
769
|
declare function getVertexFormatComponentCount(fmt: VertexAttribFormat): number;
|
|
@@ -714,6 +773,7 @@ declare function getVertexFormatComponentCount(fmt: VertexAttribFormat): number;
|
|
|
714
773
|
* @param type - Data type of vertex component
|
|
715
774
|
* @param count - The count of vertex components
|
|
716
775
|
* @returns Vertex format
|
|
776
|
+
*
|
|
717
777
|
* @public
|
|
718
778
|
*/
|
|
719
779
|
declare function getVertexAttribFormat(semantic: VertexSemantic, type: DataType, count: number): VertexAttribFormat;
|
|
@@ -721,6 +781,7 @@ declare function getVertexAttribFormat(semantic: VertexSemantic, type: DataType,
|
|
|
721
781
|
* Get the length of a vertex buffer by specified structure type of the vertex buffer
|
|
722
782
|
* @param vertexBufferType - The structure type of the vertex buffer
|
|
723
783
|
* @returns The length of the vertex buffer
|
|
784
|
+
*
|
|
724
785
|
* @public
|
|
725
786
|
*/
|
|
726
787
|
declare function getVertexBufferLength(vertexBufferType: PBStructTypeInfo): number;
|
|
@@ -728,6 +789,7 @@ declare function getVertexBufferLength(vertexBufferType: PBStructTypeInfo): numb
|
|
|
728
789
|
* Get byte stride of a vertex buffer by specified structure type of the vertex buffer
|
|
729
790
|
* @param vertexBufferType - The structure type of the vertex buffer
|
|
730
791
|
* @returns The byte stride of the vertex buffer
|
|
792
|
+
*
|
|
731
793
|
* @public
|
|
732
794
|
*/
|
|
733
795
|
declare function getVertexBufferStride(vertexBufferType: PBStructTypeInfo): number;
|
|
@@ -736,6 +798,7 @@ declare function getVertexBufferStride(vertexBufferType: PBStructTypeInfo): numb
|
|
|
736
798
|
* @param vertexBufferType - The structure type of the vertex buffer
|
|
737
799
|
* @param semantic - The vertex semantic
|
|
738
800
|
* @returns - The primitive type of the vertex attribute
|
|
801
|
+
*
|
|
739
802
|
* @public
|
|
740
803
|
*/
|
|
741
804
|
declare function getVertexBufferAttribTypeBySemantic(vertexBufferType: PBStructTypeInfo, semantic: VertexSemantic): PBPrimitiveTypeInfo;
|
|
@@ -744,6 +807,7 @@ declare function getVertexBufferAttribTypeBySemantic(vertexBufferType: PBStructT
|
|
|
744
807
|
* @param vertexBufferType - The structure type of the vertex buffer
|
|
745
808
|
* @param semantic - The vertex attribute index
|
|
746
809
|
* @returns - The primitive type of the vertex attribute
|
|
810
|
+
*
|
|
747
811
|
* @public
|
|
748
812
|
*/
|
|
749
813
|
declare function getVertexBufferAttribType(vertexBufferType: PBStructTypeInfo, attrib: number): PBPrimitiveTypeInfo;
|
|
@@ -752,16 +816,19 @@ declare function getVertexBufferAttribType(vertexBufferType: PBStructTypeInfo, a
|
|
|
752
816
|
* @param length - The length of the vertex buffer
|
|
753
817
|
* @param attributes - The vertex attributes
|
|
754
818
|
* @returns The structure type of the vertex buffer
|
|
819
|
+
*
|
|
755
820
|
* @public
|
|
756
821
|
*/
|
|
757
822
|
declare function makeVertexBufferType(length: number, ...attributes: VertexAttribFormat[]): PBStructTypeInfo;
|
|
758
823
|
/**
|
|
759
824
|
* Vertex step mode.
|
|
825
|
+
*
|
|
760
826
|
* @public
|
|
761
827
|
*/
|
|
762
828
|
type VertexStepMode = 'vertex' | 'instance';
|
|
763
829
|
/**
|
|
764
830
|
* Vertex semantic list
|
|
831
|
+
*
|
|
765
832
|
* @public
|
|
766
833
|
*/
|
|
767
834
|
declare const semanticList: string[];
|
|
@@ -984,9 +1051,7 @@ interface SamplerOptions {
|
|
|
984
1051
|
* Base class for a GPU object
|
|
985
1052
|
* @public
|
|
986
1053
|
*/
|
|
987
|
-
interface GPUObject<T = unknown> extends
|
|
988
|
-
disposed: null;
|
|
989
|
-
}> {
|
|
1054
|
+
interface GPUObject<T = unknown> extends IDisposable {
|
|
990
1055
|
/** The object was created by which device */
|
|
991
1056
|
readonly device: AbstractDevice;
|
|
992
1057
|
/** The internal GPU object */
|
|
@@ -996,7 +1061,7 @@ interface GPUObject<T = unknown> extends IEventTarget<{
|
|
|
996
1061
|
readonly cid: number;
|
|
997
1062
|
readonly disposed: boolean;
|
|
998
1063
|
name: string;
|
|
999
|
-
restoreHandler: (tex: GPUObject) =>
|
|
1064
|
+
restoreHandler: (tex: GPUObject) => void;
|
|
1000
1065
|
isVertexLayout(): this is VertexLayout;
|
|
1001
1066
|
isFramebuffer(): this is FrameBuffer;
|
|
1002
1067
|
isSampler(): this is TextureSampler;
|
|
@@ -1010,9 +1075,9 @@ interface GPUObject<T = unknown> extends IEventTarget<{
|
|
|
1010
1075
|
isBuffer(): this is GPUDataBuffer;
|
|
1011
1076
|
isBindGroup(): this is BindGroup;
|
|
1012
1077
|
dispose(): void;
|
|
1013
|
-
reload():
|
|
1078
|
+
reload(): void;
|
|
1014
1079
|
destroy(): void;
|
|
1015
|
-
restore():
|
|
1080
|
+
restore(): void;
|
|
1016
1081
|
}
|
|
1017
1082
|
/**
|
|
1018
1083
|
* Abstract interface for texture sampler
|
|
@@ -1108,7 +1173,7 @@ interface GPUDataBuffer<T = unknown> extends GPUObject<T> {
|
|
|
1108
1173
|
readonly byteLength: number;
|
|
1109
1174
|
readonly usage: number;
|
|
1110
1175
|
bufferSubData(dstByteOffset: number, data: TypedArray, srcOffset?: number, srcLength?: number): void;
|
|
1111
|
-
getBufferSubData(dstBuffer?: Uint8Array
|
|
1176
|
+
getBufferSubData(dstBuffer?: Uint8Array<ArrayBuffer>, offsetInBytes?: number, sizeInBytes?: number): Promise<Uint8Array<ArrayBuffer>>;
|
|
1112
1177
|
}
|
|
1113
1178
|
/**
|
|
1114
1179
|
* Abstract interface for index buffer
|
|
@@ -1169,6 +1234,7 @@ interface FrameBuffer<T = unknown> extends GPUObject<T> {
|
|
|
1169
1234
|
getDepthAttachmentLayer(): number;
|
|
1170
1235
|
getColorAttachments(): BaseTexture[];
|
|
1171
1236
|
getDepthAttachment(): BaseTexture;
|
|
1237
|
+
getColorAttachment<T extends BaseTexture = BaseTexture>(index: number): T;
|
|
1172
1238
|
bind(): boolean;
|
|
1173
1239
|
unbind(): void;
|
|
1174
1240
|
}
|
|
@@ -1200,7 +1266,7 @@ interface BindGroup extends GPUObject<unknown> {
|
|
|
1200
1266
|
getLayout(): BindGroupLayout;
|
|
1201
1267
|
getDynamicOffsets(): number[];
|
|
1202
1268
|
getGPUId(): string;
|
|
1203
|
-
getBuffer(name: string): GPUDataBuffer;
|
|
1269
|
+
getBuffer(name: string, nocreate?: boolean): GPUDataBuffer;
|
|
1204
1270
|
getTexture(name: string): BaseTexture;
|
|
1205
1271
|
setBuffer(name: string, buffer: GPUDataBuffer, offset?: number, bindOffset?: number, bindSize?: number): void;
|
|
1206
1272
|
setValue(name: string, value: StructuredValue): any;
|
|
@@ -1486,7 +1552,7 @@ interface ProgramBuilder {
|
|
|
1486
1552
|
/** Gets the global scope */
|
|
1487
1553
|
getGlobalScope(): PBGlobalScope;
|
|
1488
1554
|
/** Gets the current scope */
|
|
1489
|
-
getCurrentScope():
|
|
1555
|
+
getCurrentScope<T extends PBScope = PBScope>(): T;
|
|
1490
1556
|
/**
|
|
1491
1557
|
* Query the global variable by the name
|
|
1492
1558
|
* @param name - Name of the variable
|
|
@@ -1957,6 +2023,8 @@ interface ProgramBuilder {
|
|
|
1957
2023
|
max(x: number | PBShaderExp, y: number | PBShaderExp): PBShaderExp;
|
|
1958
2024
|
/** Same as clamp builtin function in GLSL and WGSL */
|
|
1959
2025
|
clamp(x: number | PBShaderExp, y: number | PBShaderExp, z: number | PBShaderExp): PBShaderExp;
|
|
2026
|
+
/** Clamp to [0, 1] */
|
|
2027
|
+
saturate(x: PBShaderExp): PBShaderExp;
|
|
1960
2028
|
/** Same as mix builtin function in GLSL and WGSL */
|
|
1961
2029
|
mix(x: number | PBShaderExp, y: number | PBShaderExp, z: number | PBShaderExp): PBShaderExp;
|
|
1962
2030
|
/** Same as step builtin function in GLSL and WGSL */
|
|
@@ -1970,13 +2038,13 @@ interface ProgramBuilder {
|
|
|
1970
2038
|
/** add two values */
|
|
1971
2039
|
add_2(x: number | PBShaderExp, y: number | PBShaderExp): any;
|
|
1972
2040
|
/** add a couple of values togeter */
|
|
1973
|
-
add(x: number | PBShaderExp, ...rest: (number | PBShaderExp)[]): any;
|
|
2041
|
+
add(x: number | PBShaderExp, y: number | PBShaderExp, ...rest: (number | PBShaderExp)[]): any;
|
|
1974
2042
|
/** subtract two values */
|
|
1975
2043
|
sub(x: number | PBShaderExp, y: number | PBShaderExp): any;
|
|
1976
2044
|
/** multiply two values */
|
|
1977
2045
|
mul_2(x: number | PBShaderExp, y: number | PBShaderExp): any;
|
|
1978
2046
|
/** multiply a couple of values togeter */
|
|
1979
|
-
mul(x: number | PBShaderExp, ...rest: (number | PBShaderExp)[]): any;
|
|
2047
|
+
mul(x: number | PBShaderExp, y: number | PBShaderExp, ...rest: (number | PBShaderExp)[]): any;
|
|
1980
2048
|
/** divide the first number by the second number */
|
|
1981
2049
|
div(x: number | PBShaderExp, y: number | PBShaderExp): any;
|
|
1982
2050
|
/** Same as length builtin function in GLSL and WGSL */
|
|
@@ -2245,7 +2313,7 @@ declare class PBLocalScope extends PBScope {
|
|
|
2245
2313
|
interface PBBuiltinScope {
|
|
2246
2314
|
position: PBShaderExp;
|
|
2247
2315
|
pointSize: PBShaderExp | number;
|
|
2248
|
-
fragDepth: PBShaderExp;
|
|
2316
|
+
fragDepth: PBShaderExp | number;
|
|
2249
2317
|
readonly fragCoord: PBShaderExp;
|
|
2250
2318
|
readonly frontFacing: PBShaderExp;
|
|
2251
2319
|
readonly vertexIndex: PBShaderExp;
|
|
@@ -2327,7 +2395,7 @@ declare class PBInsideFunctionScope extends PBScope {
|
|
|
2327
2395
|
* @param end - end value of the counter exclusive
|
|
2328
2396
|
* @param body - Generator function for the scope that inside the for statement
|
|
2329
2397
|
*/
|
|
2330
|
-
$for(counter: PBShaderExp, init: number | PBShaderExp, end: number | PBShaderExp,
|
|
2398
|
+
$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
2399
|
/**
|
|
2332
2400
|
* Creates a 'do..while' statement
|
|
2333
2401
|
* @param body - Generator function for the scope that inside the do..while statment
|
|
@@ -2340,6 +2408,8 @@ declare class PBInsideFunctionScope extends PBScope {
|
|
|
2340
2408
|
* @param body - Generator function for the scope that inside the while statement
|
|
2341
2409
|
*/
|
|
2342
2410
|
$while(condition: ExpValueNonArrayType, body: (this: PBWhileScope) => void): void;
|
|
2411
|
+
/** Gets main function scope */
|
|
2412
|
+
$getMainScope(): PBFunctionScope;
|
|
2343
2413
|
}
|
|
2344
2414
|
/**
|
|
2345
2415
|
* Scope that insides a function
|
|
@@ -2536,6 +2606,10 @@ interface DepthState {
|
|
|
2536
2606
|
writeEnabled: boolean;
|
|
2537
2607
|
/** The comparison function for depth testing */
|
|
2538
2608
|
compareFunc: CompareFunc;
|
|
2609
|
+
/** Depth bias */
|
|
2610
|
+
depthBias: number;
|
|
2611
|
+
/** Slope scaled depth bias */
|
|
2612
|
+
depthBiasSlopeScale: number;
|
|
2539
2613
|
/**
|
|
2540
2614
|
* Enable or disable depth testing
|
|
2541
2615
|
* @param b - true if enable
|
|
@@ -2554,6 +2628,16 @@ interface DepthState {
|
|
|
2554
2628
|
* @returns self
|
|
2555
2629
|
*/
|
|
2556
2630
|
setCompareFunc(func: CompareFunc): this;
|
|
2631
|
+
/**
|
|
2632
|
+
* Sets the depth bias
|
|
2633
|
+
* @param value - Value of the depth bias
|
|
2634
|
+
*/
|
|
2635
|
+
setDepthBias(value: number): this;
|
|
2636
|
+
/**
|
|
2637
|
+
* Sets the slope scaled depth bias
|
|
2638
|
+
* @param value - Value of the slope scaled depth bias
|
|
2639
|
+
*/
|
|
2640
|
+
setDepthBiasSlopeScale(value: number): this;
|
|
2557
2641
|
}
|
|
2558
2642
|
/**
|
|
2559
2643
|
* Stencil operations
|
|
@@ -2724,7 +2808,11 @@ declare class Pool {
|
|
|
2724
2808
|
* Creates an instance of Pool class
|
|
2725
2809
|
* @param device - Rendering device
|
|
2726
2810
|
*/
|
|
2727
|
-
constructor(device: AbstractDevice, memCostThreshold?: number);
|
|
2811
|
+
constructor(device: AbstractDevice, id: string | symbol, memCostThreshold?: number);
|
|
2812
|
+
/**
|
|
2813
|
+
* Id for this pool
|
|
2814
|
+
*/
|
|
2815
|
+
get id(): string | symbol;
|
|
2728
2816
|
autoRelease(): void;
|
|
2729
2817
|
/**
|
|
2730
2818
|
* Fetch a temporal 2D texture from the object pool.
|
|
@@ -2784,7 +2872,7 @@ declare class Pool {
|
|
|
2784
2872
|
* @param attachmentLayer - The texture layer to which the color attachment will render, default is 0.
|
|
2785
2873
|
* @returns The fetched FrameBuffer object.
|
|
2786
2874
|
*/
|
|
2787
|
-
createTemporalFramebuffer(autoRelease: boolean, colorAttachments: BaseTexture[], depthAttachment?: BaseTexture, sampleCount?: number, ignoreDepthStencil?: boolean, attachmentMipLevel?: number, attachmentCubeface?: number, attachmentLayer?: number): FrameBuffer
|
|
2875
|
+
createTemporalFramebuffer(autoRelease: boolean, colorAttachments: BaseTexture[], depthAttachment?: BaseTexture, sampleCount?: number, ignoreDepthStencil?: boolean, attachmentMipLevel?: number, attachmentCubeface?: number, attachmentLayer?: number): FrameBuffer;
|
|
2788
2876
|
/**
|
|
2789
2877
|
* Dispose a texture that is allocated from the object pool.
|
|
2790
2878
|
* @param texture - The texture to dispose.
|
|
@@ -2795,6 +2883,11 @@ declare class Pool {
|
|
|
2795
2883
|
* @param texture - The texture to release.
|
|
2796
2884
|
*/
|
|
2797
2885
|
releaseTexture(texture: BaseTexture): void;
|
|
2886
|
+
/**
|
|
2887
|
+
* Increment reference counter for given texture
|
|
2888
|
+
* @param texture - The texture to retain
|
|
2889
|
+
*/
|
|
2890
|
+
retainTexture(texture: BaseTexture): void;
|
|
2798
2891
|
/**
|
|
2799
2892
|
* Dispose a framebuffer that is allocated from the object pool.
|
|
2800
2893
|
* @param fb - The framebuffer to dispose.
|
|
@@ -2805,6 +2898,11 @@ declare class Pool {
|
|
|
2805
2898
|
* @param fb - The framebuffer to release.
|
|
2806
2899
|
*/
|
|
2807
2900
|
releaseFrameBuffer(fb: FrameBuffer): void;
|
|
2901
|
+
/**
|
|
2902
|
+
* Increment reference counter for given framebuffer
|
|
2903
|
+
* @param fb - The framebuffer to retain
|
|
2904
|
+
*/
|
|
2905
|
+
retainFrameBuffer(fb: FrameBuffer): void;
|
|
2808
2906
|
/**
|
|
2809
2907
|
* Purge the object pool by disposing all free framebuffers and textures.
|
|
2810
2908
|
*/
|
|
@@ -3035,6 +3133,8 @@ interface DeviceCaps {
|
|
|
3035
3133
|
interface FramebufferCaps {
|
|
3036
3134
|
/** The maximum number of framebuffer color attachment points */
|
|
3037
3135
|
maxDrawBuffers: number;
|
|
3136
|
+
/** True if device supports rendering to mipmap */
|
|
3137
|
+
supportRenderMipmap: boolean;
|
|
3038
3138
|
/** True if device supports multisampled frame buffer */
|
|
3039
3139
|
supportMultisampledFramebuffer: boolean;
|
|
3040
3140
|
/** True if device supports blending on float point frame buffer */
|
|
@@ -3097,6 +3197,12 @@ interface TextureFormatInfo {
|
|
|
3097
3197
|
renderable: boolean;
|
|
3098
3198
|
/** True if the texture format is a compressed format */
|
|
3099
3199
|
compressed: boolean;
|
|
3200
|
+
/** Number of bytes per-block */
|
|
3201
|
+
size: number;
|
|
3202
|
+
/** Block width */
|
|
3203
|
+
blockWidth: number;
|
|
3204
|
+
/** Block height */
|
|
3205
|
+
blockHeight: number;
|
|
3100
3206
|
}
|
|
3101
3207
|
/**
|
|
3102
3208
|
* Texture related capabilities of the device'
|
|
@@ -3186,70 +3292,6 @@ interface GPUProgramConstructParams {
|
|
|
3186
3292
|
/** The creation options */
|
|
3187
3293
|
params: RenderProgramConstructParams | ComputeProgramConstructParams;
|
|
3188
3294
|
}
|
|
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
3295
|
/**
|
|
3254
3296
|
* Creation options for device
|
|
3255
3297
|
* @public
|
|
@@ -3265,12 +3307,12 @@ interface DeviceOptions {
|
|
|
3265
3307
|
* @public
|
|
3266
3308
|
*/
|
|
3267
3309
|
type DeviceEventMap = {
|
|
3268
|
-
[
|
|
3269
|
-
[
|
|
3270
|
-
[
|
|
3271
|
-
[
|
|
3272
|
-
[
|
|
3273
|
-
[
|
|
3310
|
+
resize: [width: number, height: number];
|
|
3311
|
+
devicelost: [];
|
|
3312
|
+
devicerestored: [];
|
|
3313
|
+
gpuobject_added: [obj: GPUObject];
|
|
3314
|
+
gpuobject_removed: [obj: GPUObject];
|
|
3315
|
+
gpuobject_rename: [obj: GPUObject, lastName: string];
|
|
3274
3316
|
};
|
|
3275
3317
|
/**
|
|
3276
3318
|
* Structure that contains the device viewport information
|
|
@@ -3301,6 +3343,10 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3301
3343
|
pool: Pool;
|
|
3302
3344
|
/** vSync */
|
|
3303
3345
|
vSync: boolean;
|
|
3346
|
+
/** Check if a pool with given key exists */
|
|
3347
|
+
poolExists(key: string | symbol): boolean;
|
|
3348
|
+
/** Get the pool with given key, or create a new one if not exists */
|
|
3349
|
+
getPool(key: string | symbol): Pool;
|
|
3304
3350
|
/** Get adapter information */
|
|
3305
3351
|
getAdapterInfo(): any;
|
|
3306
3352
|
/** Get sample count of current frame buffer */
|
|
@@ -3355,6 +3401,7 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3355
3401
|
/**
|
|
3356
3402
|
* Creates a texture sampler object
|
|
3357
3403
|
* @param options - The creation options
|
|
3404
|
+
* @returns The created texture sampler
|
|
3358
3405
|
*/
|
|
3359
3406
|
createSampler(options: SamplerOptions): TextureSampler;
|
|
3360
3407
|
/**
|
|
@@ -3370,18 +3417,14 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3370
3417
|
* @param width - Pixel width of the texture
|
|
3371
3418
|
* @param height - Pixel height of the texture
|
|
3372
3419
|
* @param options - The creation options
|
|
3420
|
+
* @returns The created 2D texture
|
|
3373
3421
|
*/
|
|
3374
3422
|
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;
|
|
3381
3423
|
/**
|
|
3382
3424
|
* Creates a 2d texture from a image element
|
|
3383
3425
|
* @param element - The image element
|
|
3384
3426
|
* @param options - The creation options
|
|
3427
|
+
* @returns The created 2D texture.
|
|
3385
3428
|
*/
|
|
3386
3429
|
createTexture2DFromImage(element: TextureImageElement, sRGB: boolean, options?: TextureCreationOptions): Texture2D;
|
|
3387
3430
|
/**
|
|
@@ -3391,29 +3434,25 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3391
3434
|
* @param height - Pixel height of the texture
|
|
3392
3435
|
* @param depth - Array length of the texture
|
|
3393
3436
|
* @param options - The creation options
|
|
3437
|
+
* @returns The created 2D array texture.
|
|
3394
3438
|
*/
|
|
3395
3439
|
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;
|
|
3403
3440
|
/**
|
|
3404
3441
|
* Creates a 2d array texture from a seris of image elements
|
|
3405
3442
|
* @remarks image elements must have the same size.
|
|
3406
3443
|
* @param elements - image elements
|
|
3407
3444
|
* @param options - The creation options
|
|
3445
|
+
* @returns The created 2D array texture.
|
|
3408
3446
|
*/
|
|
3409
3447
|
createTexture2DArrayFromImages(elements: TextureImageElement[], sRGB: boolean, options?: TextureCreationOptions): Texture2DArray;
|
|
3410
3448
|
/**
|
|
3411
|
-
* Creates a
|
|
3449
|
+
* Creates a 3D texture
|
|
3412
3450
|
* @param format - The texture format
|
|
3413
3451
|
* @param width - Pixel width of the texture
|
|
3414
3452
|
* @param height - Pixel height of the texture
|
|
3415
3453
|
* @param depth - Pixel depth of the texture
|
|
3416
3454
|
* @param options - The creation options
|
|
3455
|
+
* @returns The created 3D texture.
|
|
3417
3456
|
*/
|
|
3418
3457
|
createTexture3D(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Texture3D;
|
|
3419
3458
|
/**
|
|
@@ -3421,17 +3460,13 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3421
3460
|
* @param format - The texture format
|
|
3422
3461
|
* @param size - Pixel width of the texture
|
|
3423
3462
|
* @param options - The creation options
|
|
3463
|
+
* @returns The created cube texture.
|
|
3424
3464
|
*/
|
|
3425
3465
|
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;
|
|
3432
3466
|
/**
|
|
3433
3467
|
* Creates a video texture from a video element
|
|
3434
3468
|
* @param el - The video element
|
|
3469
|
+
* @returns The created video texture.
|
|
3435
3470
|
*/
|
|
3436
3471
|
createTextureVideo(el: HTMLVideoElement, samplerOptions?: SamplerOptions): TextureVideo;
|
|
3437
3472
|
/**
|
|
@@ -3474,17 +3509,20 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3474
3509
|
/**
|
|
3475
3510
|
* Creates a gpu program
|
|
3476
3511
|
* @param params - The creation options
|
|
3512
|
+
* @returns The created program.
|
|
3477
3513
|
*/
|
|
3478
3514
|
createGPUProgram(params: GPUProgramConstructParams): GPUProgram;
|
|
3479
3515
|
/**
|
|
3480
3516
|
* Creates a bind group
|
|
3481
3517
|
* @param layout - Layout of the bind group
|
|
3518
|
+
* @returns The created bind group.
|
|
3482
3519
|
*/
|
|
3483
3520
|
createBindGroup(layout: BindGroupLayout): BindGroup;
|
|
3484
3521
|
/**
|
|
3485
3522
|
* Creates a gpu buffer
|
|
3486
3523
|
* @param sizeInBytes - Size of the buffer in bytes
|
|
3487
3524
|
* @param options - The creation options
|
|
3525
|
+
* @returns The created buffer.
|
|
3488
3526
|
*/
|
|
3489
3527
|
createBuffer(sizeInBytes: number, options: BufferCreationOptions): GPUDataBuffer;
|
|
3490
3528
|
/**
|
|
@@ -3500,23 +3538,27 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3500
3538
|
* Creates an index buffer
|
|
3501
3539
|
* @param data - Data of the index buffer
|
|
3502
3540
|
* @param options - The creation options
|
|
3541
|
+
* @returns The created index buffer.
|
|
3503
3542
|
*/
|
|
3504
|
-
createIndexBuffer(data: Uint16Array | Uint32Array
|
|
3543
|
+
createIndexBuffer(data: Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer>, options?: BufferCreationOptions): IndexBuffer;
|
|
3505
3544
|
/**
|
|
3506
3545
|
* Creates a structured buffer
|
|
3507
3546
|
* @param structureType - The structure type
|
|
3508
3547
|
* @param options - The creation options
|
|
3509
3548
|
* @param data - Data to be filled with
|
|
3549
|
+
* @returns The created structured buffer.
|
|
3510
3550
|
*/
|
|
3511
3551
|
createStructuredBuffer(structureType: PBStructTypeInfo, options: BufferCreationOptions, data?: TypedArray): StructuredBuffer;
|
|
3512
3552
|
/**
|
|
3513
|
-
* Creates a vertex layout
|
|
3553
|
+
* Creates a vertex layout object.
|
|
3514
3554
|
* @param options - The creation options
|
|
3555
|
+
* @returns The created vertex layout object.
|
|
3515
3556
|
*/
|
|
3516
3557
|
createVertexLayout(options: VertexLayoutOptions): VertexLayout;
|
|
3517
3558
|
/**
|
|
3518
3559
|
* Creates a frame buffer
|
|
3519
3560
|
* @param options - The creation options
|
|
3561
|
+
* @returns The created framebuffer.
|
|
3520
3562
|
*/
|
|
3521
3563
|
createFrameBuffer(colorAttachments: BaseTexture[], depthAttachment: BaseTexture, options?: FrameBufferOptions): FrameBuffer;
|
|
3522
3564
|
/**
|
|
@@ -3663,14 +3705,14 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3663
3705
|
* Begins a frame for rendering
|
|
3664
3706
|
*
|
|
3665
3707
|
* @remarks
|
|
3666
|
-
* All rendering call must occur between the
|
|
3708
|
+
* All rendering call must occur between the @see AbstractDevice.beginFrame and @see AbstractDevice.endFrame methods
|
|
3667
3709
|
*/
|
|
3668
3710
|
beginFrame(): boolean;
|
|
3669
3711
|
/**
|
|
3670
3712
|
* Ends a frame for rendering
|
|
3671
3713
|
*
|
|
3672
3714
|
* @remarks
|
|
3673
|
-
* All rendering call must occur between the
|
|
3715
|
+
* All rendering call must occur between the @see AbstractDevice.beginFrame and @see AbstractDevice.endFrame methods
|
|
3674
3716
|
*/
|
|
3675
3717
|
endFrame(): void;
|
|
3676
3718
|
/**
|
|
@@ -3687,6 +3729,7 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3687
3729
|
* @param attribFormats - The vertex attribute formats for each vertex stream in the vertex buffer
|
|
3688
3730
|
* @param data - Data to be filled with
|
|
3689
3731
|
* @param options - The creation options
|
|
3732
|
+
* @returns The created vertex buffer.
|
|
3690
3733
|
*/
|
|
3691
3734
|
createInterleavedVertexBuffer(attribFormats: VertexAttribFormat[], data: TypedArray, options?: BufferCreationOptions): StructuredBuffer;
|
|
3692
3735
|
/**
|
|
@@ -3695,6 +3738,7 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3695
3738
|
* @param attribFormat - The vertex attribute format
|
|
3696
3739
|
* @param data - Data to be filled with
|
|
3697
3740
|
* @param options - The creation options
|
|
3741
|
+
* @returns The created vertex buffer
|
|
3698
3742
|
*/
|
|
3699
3743
|
createVertexBuffer(attribFormat: VertexAttribFormat, data: TypedArray, options?: BufferCreationOptions): StructuredBuffer;
|
|
3700
3744
|
/**
|
|
@@ -3728,6 +3772,12 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3728
3772
|
* @param f - The function to be scheduled
|
|
3729
3773
|
*/
|
|
3730
3774
|
runNextFrame(f: () => void): void;
|
|
3775
|
+
/**
|
|
3776
|
+
* Asyncronized version of scheduling a function to be executed at the beginning of the next frame
|
|
3777
|
+
*
|
|
3778
|
+
* @param f - The function to be scheduled
|
|
3779
|
+
*/
|
|
3780
|
+
runNextFrameAsync(f: () => void): Promise<void>;
|
|
3731
3781
|
/** Exits from current rendering loop */
|
|
3732
3782
|
exitLoop(): void;
|
|
3733
3783
|
/**
|
|
@@ -3808,7 +3858,7 @@ interface DeviceBackend {
|
|
|
3808
3858
|
* Base class for rendering device
|
|
3809
3859
|
* @public
|
|
3810
3860
|
*/
|
|
3811
|
-
declare abstract class BaseDevice {
|
|
3861
|
+
declare abstract class BaseDevice extends Observable<DeviceEventMap> {
|
|
3812
3862
|
protected _canvas: HTMLCanvasElement;
|
|
3813
3863
|
protected _canvasClientWidth: number;
|
|
3814
3864
|
protected _canvasClientHeight: number;
|
|
@@ -3829,10 +3879,11 @@ declare abstract class BaseDevice {
|
|
|
3829
3879
|
protected _backend: DeviceBackend;
|
|
3830
3880
|
protected _beginFrameCounter: number;
|
|
3831
3881
|
protected _programBuilder: ProgramBuilder;
|
|
3832
|
-
protected
|
|
3882
|
+
protected _poolMap: Map<string | symbol, Pool>;
|
|
3883
|
+
protected _defaultPoolKey: symbol;
|
|
3833
3884
|
protected _temporalFramebuffer: boolean;
|
|
3834
3885
|
protected _vSync: boolean;
|
|
3835
|
-
private _stateStack;
|
|
3886
|
+
private readonly _stateStack;
|
|
3836
3887
|
constructor(cvs: HTMLCanvasElement, backend: DeviceBackend);
|
|
3837
3888
|
abstract getAdapterInfo(): any;
|
|
3838
3889
|
abstract getFrameBufferSampleCount(): number;
|
|
@@ -3855,14 +3906,11 @@ declare abstract class BaseDevice {
|
|
|
3855
3906
|
abstract createSampler(options: SamplerOptions): TextureSampler;
|
|
3856
3907
|
abstract createTextureFromMipmapData<T extends BaseTexture>(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): T;
|
|
3857
3908
|
abstract createTexture2D(format: TextureFormat, width: number, height: number, options?: TextureCreationOptions): Texture2D;
|
|
3858
|
-
abstract createTexture2DFromMipmapData(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): Texture2D;
|
|
3859
3909
|
abstract createTexture2DFromImage(element: TextureImageElement, sRGB: boolean, options?: TextureCreationOptions): Texture2D;
|
|
3860
3910
|
abstract createTexture2DArray(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Texture2DArray;
|
|
3861
|
-
abstract createTexture2DArrayFromMipmapData(data: TextureMipmapData, options?: TextureCreationOptions): Texture2DArray;
|
|
3862
3911
|
abstract createTexture2DArrayFromImages(elements: TextureImageElement[], sRGB: boolean, options?: TextureCreationOptions): Texture2DArray;
|
|
3863
3912
|
abstract createTexture3D(format: TextureFormat, width: number, height: number, depth: number, options?: TextureCreationOptions): Texture3D;
|
|
3864
3913
|
abstract createCubeTexture(format: TextureFormat, size: number, options?: TextureCreationOptions): TextureCube;
|
|
3865
|
-
abstract createCubeTextureFromMipmapData(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): TextureCube;
|
|
3866
3914
|
abstract createTextureVideo(el: HTMLVideoElement, samplerOptions?: SamplerOptions): TextureVideo;
|
|
3867
3915
|
abstract reverseVertexWindingOrder(reverse: boolean): void;
|
|
3868
3916
|
abstract isWindingOrderReversed(): boolean;
|
|
@@ -3872,7 +3920,7 @@ declare abstract class BaseDevice {
|
|
|
3872
3920
|
abstract createBindGroup(layout: BindGroupLayout): BindGroup;
|
|
3873
3921
|
abstract createBuffer(sizeInBytes: number, options: BufferCreationOptions): GPUDataBuffer;
|
|
3874
3922
|
abstract copyBuffer(sourceBuffer: GPUDataBuffer, destBuffer: GPUDataBuffer, srcOffset: number, dstOffset: number, bytes: number): any;
|
|
3875
|
-
abstract createIndexBuffer(data: Uint16Array | Uint32Array
|
|
3923
|
+
abstract createIndexBuffer(data: Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer>, options?: BufferCreationOptions): IndexBuffer;
|
|
3876
3924
|
abstract createStructuredBuffer(structureType: PBStructTypeInfo, options: BufferCreationOptions, data?: TypedArray): StructuredBuffer;
|
|
3877
3925
|
abstract createVertexLayout(options: VertexLayoutOptions): VertexLayout;
|
|
3878
3926
|
abstract createFrameBuffer(colorAttachments: BaseTexture[], depthAttachment: BaseTexture, options?: FrameBufferOptions): FrameBuffer;
|
|
@@ -3896,9 +3944,9 @@ declare abstract class BaseDevice {
|
|
|
3896
3944
|
abstract readPixelsToBuffer(index: number, x: number, y: number, w: number, h: number, buffer: GPUDataBuffer): void;
|
|
3897
3945
|
abstract beginCapture(): void;
|
|
3898
3946
|
abstract endCapture(): RenderBundle;
|
|
3899
|
-
abstract executeRenderBundle(renderBundle: RenderBundle): any;
|
|
3900
3947
|
abstract looseContext(): void;
|
|
3901
3948
|
abstract restoreContext(): void;
|
|
3949
|
+
protected abstract _executeRenderBundle(renderBundle: RenderBundle): number;
|
|
3902
3950
|
protected abstract _draw(primitiveType: PrimitiveType, first: number, count: number): void;
|
|
3903
3951
|
protected abstract _drawInstanced(primitiveType: PrimitiveType, first: number, count: number, numInstances: number): void;
|
|
3904
3952
|
protected abstract _compute(workgroupCountX: number, workgroupCountY: number, workgroupCountZ: number): void;
|
|
@@ -3913,17 +3961,14 @@ declare abstract class BaseDevice {
|
|
|
3913
3961
|
get pool(): Pool;
|
|
3914
3962
|
get runLoopFunction(): (device: AbstractDevice) => void;
|
|
3915
3963
|
get programBuilder(): ProgramBuilder;
|
|
3964
|
+
poolExists(key: string | symbol): boolean;
|
|
3965
|
+
getPool(key: string | symbol): Pool;
|
|
3916
3966
|
setFont(fontName: string): void;
|
|
3917
3967
|
drawText(text: string, x: number, y: number, color: string): void;
|
|
3918
3968
|
setFramebuffer(rt: FrameBuffer): any;
|
|
3919
|
-
setFramebuffer(color:
|
|
3920
|
-
texture: BaseTexture;
|
|
3921
|
-
miplevel?: number;
|
|
3922
|
-
face?: number;
|
|
3923
|
-
layer?: number;
|
|
3924
|
-
})[], depth?: BaseTexture, sampleCount?: number): any;
|
|
3969
|
+
setFramebuffer(color: BaseTexture[], depth?: BaseTexture, sampleCount?: number): any;
|
|
3925
3970
|
disposeObject(obj: GPUObject, remove?: boolean): void;
|
|
3926
|
-
restoreObject(obj: GPUObject):
|
|
3971
|
+
restoreObject(obj: GPUObject): void;
|
|
3927
3972
|
enableGPUTimeRecording(enable: boolean): void;
|
|
3928
3973
|
beginFrame(): boolean;
|
|
3929
3974
|
endFrame(): void;
|
|
@@ -3932,8 +3977,10 @@ declare abstract class BaseDevice {
|
|
|
3932
3977
|
createVertexBuffer(attribFormat: VertexAttribFormat, data: TypedArray, options?: BufferCreationOptions): StructuredBuffer;
|
|
3933
3978
|
draw(primitiveType: PrimitiveType, first: number, count: number): void;
|
|
3934
3979
|
drawInstanced(primitiveType: PrimitiveType, first: number, count: number, numInstances: number): void;
|
|
3980
|
+
executeRenderBundle(renderBundle: RenderBundle): void;
|
|
3935
3981
|
compute(workgroupCountX: any, workgroupCountY: any, workgroupCountZ: any): void;
|
|
3936
3982
|
runNextFrame(f: () => void): void;
|
|
3983
|
+
runNextFrameAsync(f: () => void | Promise<void>): Promise<void>;
|
|
3937
3984
|
exitLoop(): void;
|
|
3938
3985
|
runLoop(func: (device: AbstractDevice) => void): void;
|
|
3939
3986
|
pushDeviceStates(): void;
|
|
@@ -3955,7 +4002,7 @@ declare abstract class BaseDevice {
|
|
|
3955
4002
|
private updateFrameInfo;
|
|
3956
4003
|
private getGPUObjectList;
|
|
3957
4004
|
protected invalidateAll(): void;
|
|
3958
|
-
protected reloadAll():
|
|
4005
|
+
protected reloadAll(): void;
|
|
3959
4006
|
protected parseTextureOptions(options?: TextureCreationOptions): number;
|
|
3960
4007
|
protected parseBufferOptions(options: BufferCreationOptions, defaultUsage?: BufferUsage): number;
|
|
3961
4008
|
}
|
|
@@ -3997,8 +4044,8 @@ declare class TextureAtlasManager {
|
|
|
3997
4044
|
* The texture restore handler callback function
|
|
3998
4045
|
* This callback function will be called whenever the device has been restored
|
|
3999
4046
|
*/
|
|
4000
|
-
get atlasTextureRestoreHandler(): (tex: BaseTexture) =>
|
|
4001
|
-
set atlasTextureRestoreHandler(f: (tex: BaseTexture) =>
|
|
4047
|
+
get atlasTextureRestoreHandler(): (tex: BaseTexture) => void;
|
|
4048
|
+
set atlasTextureRestoreHandler(f: (tex: BaseTexture) => void);
|
|
4002
4049
|
/**
|
|
4003
4050
|
* Gets the atlas texture of a given index
|
|
4004
4051
|
* @param index - Index of the atlas bin
|
|
@@ -4177,4 +4224,4 @@ declare class StructuredBufferData {
|
|
|
4177
4224
|
set(name: string, value: StructuredValue): void;
|
|
4178
4225
|
}
|
|
4179
4226
|
|
|
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,
|
|
4227
|
+
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 };
|