@predy-js/render-interface 0.1.52-beta.3 → 0.1.52-beta.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/statistic.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Name: @predy-js/render-interface
3
3
  * Description: undefined
4
4
  * Author: undefined
5
- * Version: v0.1.52-beta.3
5
+ * Version: v0.1.52-beta.5
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -8,11 +8,12 @@ import type { GPURenderer } from './Renderer';
8
8
  * stride:used for interleaved attributes, 2 vec4 stride is 4 * 2 * Float32Array.BYTES_PER_ELEMENTS
9
9
  * offset: offset for interleaved attributes, 1 vec4 offset is 4 * Float32Array.BYTES_PER_ELEMENTS
10
10
  * normalize: attributed should be normalized
11
+ * location: attribute location
11
12
  * Attribute的绑定信息
12
13
  * size:向量的大小,vec4|vec3|vec2的大小分别为 4|3|2
13
14
  * stride:如果使用交错存储顶点,2个vec4的stride为 2 * 4 * Float32Array.BYTES_PER_ELEMENTS
14
15
  * offset:交错顶点的数据偏移,1个vec4的偏移为 4*Float32Array.BYTES_PER_ELEMENTS
15
- * bufferIndex: 用于metal提交bufferIndex
16
+ * location: attribute location 可以通过GL反射获得,Metal必须填写
16
17
  */
17
18
  export interface AttributeBase {
18
19
  size: number;
@@ -20,7 +21,7 @@ export interface AttributeBase {
20
21
  offset?: number;
21
22
  instanceDivisor?: number;
22
23
  normalize?: boolean;
23
- bufferIndex?: number;
24
+ location?: number;
24
25
  }
25
26
  /**
26
27
  * if data provided, type can be inferred from its data
@@ -34,8 +34,8 @@ export interface ShaderCompileResult {
34
34
  status: ShaderCompileResultStatus;
35
35
  cacheId?: string;
36
36
  error?: string | null;
37
- shared?: boolean;
38
37
  compileTime?: number;
38
+ shared?: boolean;
39
39
  }
40
40
  /**
41
41
  * @example
@@ -50,6 +50,10 @@ export interface ShaderCompileResult {
50
50
  export interface ShaderLibrary {
51
51
  readonly cacheIds: string[];
52
52
  getShaderResult(cacheId: string): ShaderCompileResult | undefined;
53
+ /**
54
+ * 添加shader
55
+ * @param shader
56
+ */
53
57
  addShader(shader: Shader): string;
54
58
  /**
55
59
  * @param cacheId
@@ -203,6 +203,7 @@ export interface TextureFormatOptions {
203
203
  type?: GLenum;
204
204
  }
205
205
  export interface TextureOptionsBase extends TextureConfigOptions, TextureFormatOptions {
206
+ sourceType?: TextureSourceType;
206
207
  }
207
208
  export type TextureCubeSourceOptions = TextureCubeSourceOptionsImage | TextureCubeSourceOptionsImageMipmaps;
208
209
  export type Texture2DSourceOptions = Texture2DSourceOptionsImage | Texture2DSourceOptionsData | Texture2DSourceOptionsVideo | Texture2DSourceOptionsImageMipmaps | Texture2DSourceOptionsCompressed | Texture2DSourceOptionsFrameBuffer;
@@ -5,6 +5,10 @@ export interface DataBlockInternalOptions {
5
5
  }
6
6
  export declare abstract class DataBlockInternal implements ResourceInternal {
7
7
  readonly isDestroyed: boolean;
8
+ /**
9
+ * UBO的name,如果没有找到对应的UBO就用setUniform
10
+ * UBO的Layout只有一种,如果不同shader中使用同名UBO,请创建不同的DataBlock对象
11
+ */
8
12
  readonly name: string;
9
13
  protected constructor(options: DataBlockInternalOptions);
10
14
  abstract destroy(): void;
@@ -1,9 +1,14 @@
1
1
  import type { AttributeWithType, GeometryOptions } from '../Geometry';
2
2
  import type { ResourceInternal } from './ResourceInternal';
3
3
  import type { GPUBufferInternal } from './GPUBufferInternal';
4
+ interface GeometryBufferLayout {
5
+ index: number;
6
+ name: string;
7
+ }
4
8
  export interface GeometryInternalOptions extends Omit<GeometryOptions, 'attributes' | 'index'> {
5
9
  attributes: Record<string, AttributeWithType>;
6
10
  buffers: Record<string, GPUBufferInternal>;
11
+ bufferLayouts: GeometryBufferLayout[];
7
12
  indexBuffer?: GPUBufferInternal;
8
13
  indexBufferType?: IndexBufferType;
9
14
  }
@@ -33,3 +38,4 @@ export declare abstract class GeometryInternal implements ResourceInternal {
33
38
  */
34
39
  abstract destroy(): void;
35
40
  }
41
+ export {};
@@ -5,14 +5,13 @@ import type { TextureInternal } from './TextureInternal';
5
5
  export interface MaterialInternalOptions {
6
6
  states: MaterialRenderStates;
7
7
  dataBlocks: DataBlockInternal[];
8
- shaderCacheId?: string;
9
- _mtlFrag?: string;
10
- _mtlVert?: string;
8
+ shaderCacheId: string;
11
9
  name: string;
12
10
  }
13
11
  export declare abstract class MaterialInternal implements ResourceInternal {
14
12
  readonly isDestroyed: boolean;
15
13
  readonly name: string;
14
+ readonly shaderCacheId: string;
16
15
  dataBlocks: DataBlockInternal[];
17
16
  protected constructor(options: MaterialInternalOptions);
18
17
  abstract destroy(): void;
@@ -4,7 +4,6 @@ import type { RenderPassClearAction, RenderPassStoreAction } from '../RenderPass
4
4
  import type { TextureInternal } from './TextureInternal';
5
5
  import type { RenderPassStorageObject } from '../RenderPass';
6
6
  import type { RenderPassAttachmentStorageType } from '../RenderPass';
7
- import type { Mesh } from '../Mesh';
8
7
  export interface RenderPassColorAttachmentInternal {
9
8
  readonly storageType: RenderPassAttachmentStorageType.color;
10
9
  readonly texture: TextureInternal;
@@ -29,12 +28,12 @@ export interface RenderPassDepthStencilAttachmentOptionsInternal {
29
28
  }
30
29
  export interface RenderPassOptionsInternal {
31
30
  clearAction: RenderPassClearAction;
32
- storeAction: RenderPassStoreAction;
33
31
  attachments: RenderPassColorAttachmentInternal[];
34
- depthStencilAttachment: RenderPassDepthStencilAttachmentOptionsInternal;
35
32
  name: string;
36
- meshes: Mesh[];
37
- multiSample: number;
33
+ meshes: MeshInternal[];
34
+ multiSample?: number;
35
+ storeAction?: RenderPassStoreAction;
36
+ depthStencilAttachment?: RenderPassDepthStencilAttachmentOptionsInternal;
38
37
  viewport?: [x: number, y: number, width: number, height: number];
39
38
  }
40
39
  export declare abstract class RenderPassInternal implements ResourceInternal {
@@ -16,6 +16,12 @@ import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapI
16
16
  export interface InternalResInfo {
17
17
  buffer: number;
18
18
  geometry: number;
19
+ material: number;
20
+ texture: number;
21
+ dataBlock: number;
22
+ mesh: number;
23
+ renderPass: number;
24
+ frame: number;
19
25
  }
20
26
  export declare abstract class RendererInternal implements ResourceInternal {
21
27
  readonly isDestroyed: boolean;
@@ -4,22 +4,29 @@ import type { TypedArray } from '../type';
4
4
  import type { ImageBitmapInternal } from './ImageBitmapInternal';
5
5
  export interface TextureInternalOptions extends TextureFormatOptions, Omit<TextureConfigOptionsBase, 'keepImageSource'> {
6
6
  target: WebGLRenderingContext['TEXTURE_CUBE_MAP'] | WebGLRenderingContext['TEXTURE_2D'];
7
+ }
8
+ export interface TextureInternalConstructOptions extends TextureInternalOptions {
7
9
  width: number;
8
10
  height: number;
11
+ image?: ImageBitmapInternal;
9
12
  }
10
13
  export declare abstract class TextureInternal implements ResourceInternal {
11
14
  readonly isDestroyed: boolean;
12
15
  readonly width: number;
13
16
  readonly height: number;
14
17
  readonly name: string;
15
- readonly options: Omit<TextureInternalOptions, 'cube' | 'image'>;
18
+ readonly options: TextureInternalOptions;
16
19
  protected constructor(options: TextureInternalOptions);
17
- abstract reset(options: TextureInternalOptions): boolean;
20
+ abstract resize(width: number, height: number): boolean;
18
21
  abstract destroy(): void;
19
22
  /**
20
- * 上传整张图片数据,数据尺寸必须和Texture尺寸定义相同
23
+ * 上传整张解码后图片数据,数据尺寸必须和Texture尺寸定义相同
24
+ */
25
+ abstract update2DImageData(data: TypedArray, mipmapLevel?: number): void;
26
+ /**
27
+ * 上传压缩纹理数据
21
28
  */
22
- abstract update2DData(data: TypedArray, mipmapLevel?: number): void;
29
+ abstract update2DCompressedImage(data: TypedArray, mipmapLevel?: number): void;
23
30
  /**
24
31
  * imageBitmap的尺寸也必须和Texture相同
25
32
  * @param image
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.1.52-beta.3",
3
+ "version": "0.1.52-beta.5",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",