@predy-js/render-interface 0.1.68 → 0.1.70

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.
@@ -1,17 +1 @@
1
- export * from '../types/constants';
2
- export * from '../types/RenderPass';
3
- export * from '../types/Texture';
4
- export * from '../types/GPUBuffer';
5
- export { constants } from './webgl/constants';
6
- export * from '../types/ShaderLibrary';
7
- export { MarsRenderFrame as RenderFrame } from './render/MarsRenderFrame';
8
- export { MarsRenderer as Renderer } from './render/MarsRenderer';
9
- export { MarsMesh as Mesh, MarsInstancedMesh as InstancedMesh } from './render/MarsMesh';
10
- export { MarsGeometry as Geometry } from './render/MarsGeometry';
11
- export { MarsRenderPass as RenderPass } from './render/MarsRenderPass';
12
- export { MarsTexture as Texture } from './render/MarsTexture';
13
- export { MarsMaterial as Material } from './render/MarsMaterial';
14
- export { MarsMaterialDataBlock as MaterialDataBlock } from './render/MarsMaterialDataBlock';
15
- export { MarsSharedGeometry as SharedGeometry } from './render/MarsSharedGeometry';
16
- export { getDefaultGPUCapability } from './render/MarsGPUCapability';
17
- export { getDefaultTextureFactory, setDefaultTextureFactory, MarsTextureFactory } from './render/MarsTextureFactory';
1
+ export * from './module';
@@ -0,0 +1,18 @@
1
+ export * from '../types/constants';
2
+ export * from '../types/RenderPass';
3
+ export * from '../types/Texture';
4
+ export * from '../types/GPUBuffer';
5
+ export { constants } from './webgl/constants';
6
+ export * from '../types/ShaderLibrary';
7
+ export { MarsRenderFrame as RenderFrame } from './render/MarsRenderFrame';
8
+ export { MarsRenderer as Renderer } from './render/MarsRenderer';
9
+ export { MarsMesh as Mesh, MarsInstancedMesh as InstancedMesh } from './render/MarsMesh';
10
+ export { MarsGeometry as Geometry } from './render/MarsGeometry';
11
+ export { MarsRenderPass as RenderPass } from './render/MarsRenderPass';
12
+ export { MarsTexture as Texture } from './render/MarsTexture';
13
+ export { MarsMaterial as Material } from './render/MarsMaterial';
14
+ export { MarsMaterialDataBlock as MaterialDataBlock } from './render/MarsMaterialDataBlock';
15
+ export { MarsSharedGeometry as SharedGeometry } from './render/MarsSharedGeometry';
16
+ export { getDefaultGPUCapability } from './render/MarsGPUCapability';
17
+ export { getDefaultTextureFactory, setDefaultTextureFactory, MarsTextureFactory } from './render/MarsTextureFactory';
18
+ export declare const ModuleMsg = "RI Package: @predy-js/render-interface";
@@ -36,7 +36,7 @@ export declare class GLProgram {
36
36
  constructor(renderer: GLGPURenderer, program: WebGLProgram, shared: boolean, id: string);
37
37
  init(renderer: GLGPURenderer, program: WebGLProgram): void;
38
38
  bind(): void;
39
- getSemanticValue(state: RenderState, semanticName: string): UniformValue | import("../../types").GPUBuffer | null | undefined;
39
+ getSemanticValue(state: RenderState, semanticName: string): import("../../types").GPUBuffer | UniformValue | null | undefined;
40
40
  setupUniforms(state: RenderState): void;
41
41
  setGLUniformValue(name: string, value: any, info: ProgramUniformInfo, gl: WebGL2RenderingContext | WebGLRenderingContext): void;
42
42
  setupAttributes(geometry: GLGeometry): GLVertexArrayObject;
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.68
5
+ * Version: v0.1.70
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -7,6 +7,7 @@ export interface Canvas {
7
7
  export declare class CanvasEmpty implements Canvas {
8
8
  width: number;
9
9
  height: number;
10
+ style: {};
10
11
  addEventListener(name: string, handler: Function): void;
11
12
  removeEventListener(name: string, handler: Function): void;
12
13
  }
@@ -24,14 +24,15 @@ export interface GPUCapabilityDetail {
24
24
  readableDepthStencilTextures?: boolean;
25
25
  writableFragDepth?: boolean;
26
26
  }
27
+ export type GPUFramework = 'webgl' | 'webgl2' | 'opengles3' | 'opengles2' | 'node-gl' | 'metal' | 'none';
27
28
  export interface GPUCapability {
28
- type: 'webgl' | 'webgl2' | 'native-gl' | 'node-gl' | 'metal' | 'none';
29
+ type: GPUFramework;
29
30
  level: number;
30
31
  capability: Immutable<GPUCapabilityDetail>;
31
32
  setup(gl: WebGLRenderingContext): void;
32
33
  }
33
34
  export declare class GPUCapabilityEmpty implements GPUCapability {
34
- type: 'webgl' | 'webgl2' | 'native-gl' | 'node-gl' | 'metal' | 'none';
35
+ type: GPUFramework;
35
36
  level: number;
36
37
  capability: {
37
38
  maxSample: number;
@@ -21,6 +21,10 @@ export interface GeometryBufferLayout {
21
21
  */
22
22
  export interface AttributeBase {
23
23
  size: number;
24
+ /**
25
+ * default is float
26
+ */
27
+ type?: WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'];
24
28
  stride?: number;
25
29
  offset?: number;
26
30
  instanceDivisor?: number;
@@ -39,25 +43,14 @@ export interface AttributeBase {
39
43
  export interface AttributeWithData extends AttributeBase {
40
44
  data?: TypedArray;
41
45
  releasable?: boolean;
42
- type?: WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'];
43
46
  }
44
47
  export interface AttributeWithType extends AttributeBase {
45
48
  /**
46
49
  * 如果使用interleaved attribute,此字段表示数据共享的attribute
47
50
  */
48
51
  dataSource: string;
49
- type: WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'];
50
- }
51
- export interface AttributeWithDataSource extends AttributeBase {
52
- /**
53
- * 如果使用interleaved attribute,此字段表示数据共享的attribute
54
- */
55
- dataSource: string;
56
- /**
57
- * use FLOAT by default
58
- */
59
- type?: WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'];
60
52
  }
53
+ export type AttributeWithDataSource = AttributeWithType;
61
54
  export type Attribute = AttributeWithData | AttributeWithType | AttributeWithDataSource;
62
55
  export type GeometryDrawMode = WebGLRenderingContext['POINTS'] | WebGLRenderingContext['TRIANGLES'] | WebGLRenderingContext['TRIANGLE_STRIP'] | WebGLRenderingContext['TRIANGLE_FAN'] | WebGLRenderingContext['LINES'] | WebGLRenderingContext['LINE_STRIP'] | WebGLRenderingContext['LINE_LOOP'];
63
56
  export interface GeometryOptions {
@@ -126,7 +126,19 @@ export declare class MaterialDataBlock implements IGPUResource {
126
126
  constructor(options: MaterialDataBlockOptions);
127
127
  hasUniformValue(name: string): boolean;
128
128
  setUniformSemantic(name: string, semantic: string | undefined): void;
129
+ /**
130
+ * 多次调用次函数只会更新JS层的数据,不会直接更新GPU数据
131
+ * 在下一次渲染前,会将JS层的数据更新到GPU
132
+ * @param name
133
+ * @param value
134
+ */
129
135
  setUniformValue(name: string, value: UniformValue): boolean;
136
+ /**
137
+ * 在JS层维持一份uniform数据,当JS数据发生变化时,数据并不会直接反应到GPU
138
+ * 需要调用setUniformValue更新数据到GPU
139
+ * 多次调用getUniformValue返回同一个Value对象
140
+ * @param name
141
+ */
130
142
  getUniformValue(name: string): UniformValue;
131
143
  getUniformValues(): {
132
144
  [key: string]: UniformValue;
@@ -136,16 +148,6 @@ export declare class MaterialDataBlock implements IGPUResource {
136
148
  }): void;
137
149
  setUniformTexture(uniformName: string, texture: Texture | Texture[] | undefined): void;
138
150
  getUniformTexture<T extends Texture[] | Texture = Texture>(uniformName: string): T | undefined;
139
- /**
140
- * indicate uniform data should be resent to GPU, but not the full range,
141
- * only works for ubo,if not an ubo, this method has no side effect
142
- * offset and count are counted by typed entry, not the number elements
143
- * entry means matrix or vector in shader
144
- * @param name uniform name
145
- * @param offset entry offset,first entry to send to gpu, default 0
146
- * @param count entry count,entry count to send to gpu,default to end
147
- */
148
- updateUniformSubData(name: string, offset: number, count: number): void;
149
151
  destroy(options?: MaterialDataBlockDestroyOptions): void;
150
152
  assignRenderer(renderer: GPURenderer): MaterialDataBlock;
151
153
  clone(name: string): MaterialDataBlock;
@@ -6,8 +6,10 @@ import type { IGPURenderer } from './IGPURenderer';
6
6
  import type { Canvas } from './Canvas';
7
7
  import type { Texture } from './Texture';
8
8
  import type { RenderPass } from './RenderPass';
9
+ import type { RendererInternal } from './native';
9
10
  export interface RendererOptions {
10
11
  gl?: WebGLRenderingContext | WebGL2RenderingContext;
12
+ internal?: RendererInternal;
11
13
  canvas?: HTMLCanvasElement;
12
14
  frameworks?: Array<'webgl' | 'webgl2'>;
13
15
  willCaptureImage?: boolean;
@@ -1,12 +1,29 @@
1
+ import type { AttributeBase, GeometryBufferLayout } from './Geometry';
1
2
  export type Shader = ShaderWithSource | ShaderUseCacheId;
2
3
  export type ShaderWithSource = InstancedShaderWithSource | SharedShaderWithSource;
3
- export interface MetaShaderSpec {
4
+ interface MetalVertexAttribute extends Omit<AttributeBase, 'instanceDivisor'> {
5
+ location: number;
6
+ stride: number;
7
+ offset: number;
8
+ dataSource: string;
9
+ }
10
+ export interface MetalShaderSpec {
4
11
  mtlBinary?: ArrayBuffer | string;
5
12
  mtlSource?: string;
6
13
  mtlVertex?: string;
7
14
  mtlFragment?: string;
15
+ /**
16
+ * 用于提前计算pipeline,如果没有传递,则需要在mesh被assignRenderer的时候才会计算pipeline
17
+ * 当mesh被添加到renderPass的时候,会根据renderPass和mesh的vertexLayout寻找对应的pipeline
18
+ * 如果没有找到,则需要创建,创建后会被缓存
19
+ * 为了避免渲染卡顿,最好在编译shader的时候就进行pipeline缓存
20
+ */
21
+ mtlVertexLayout?: {
22
+ bufferLayouts: GeometryBufferLayout[];
23
+ attributes: MetalVertexAttribute[];
24
+ };
8
25
  }
9
- export interface ShaderSourceBase extends MetaShaderSpec {
26
+ export interface ShaderSourceBase extends MetalShaderSpec {
10
27
  fragment: string;
11
28
  vertex: string;
12
29
  name?: string;
@@ -81,3 +98,4 @@ export declare class ShaderLibraryEmpty implements ShaderLibrary {
81
98
  compileShader(shaderCacheId: string): ShaderCompileResult;
82
99
  destroy(): void;
83
100
  }
101
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { RenderPassAttachmentStorageType } from '../RenderPass';
2
+ type MetalRenderPassColorFormat = WebGL2RenderingContext['RGBA8'] | WebGL2RenderingContext['RGBA16F'] | WebGL2RenderingContext['RGBA32F'] | WebGL2RenderingContext['R16F'] | WebGL2RenderingContext['R32F'];
3
+ interface MetalRenderPassAttachmentFormat {
4
+ colors: MetalRenderPassColorFormat[];
5
+ depth: RenderPassAttachmentStorageType;
6
+ stencil: RenderPassAttachmentStorageType;
7
+ id?: string;
8
+ }
9
+ export interface MetalInternal {
10
+ addRenderPassAttachmentFormat(format: MetalRenderPassAttachmentFormat): string;
11
+ }
12
+ export {};
@@ -1,6 +1,26 @@
1
1
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
2
2
  import type { TypedArray } from '../type';
3
+ import type { GPUCapability } from '../GPUCapability';
4
+ export interface PredyRequestOptions {
5
+ url: string;
6
+ disableCache?: boolean;
7
+ timeout?: number;
8
+ responseType?: 'text' | 'arraybuffer';
9
+ }
10
+ export declare enum PredyResourceCacheStatus {
11
+ noCache = 0,
12
+ cached = 1,
13
+ preloaded = 2
14
+ }
15
+ export interface PredyRequestResponse {
16
+ data: ArrayBuffer | string;
17
+ cacheStatus: PredyResourceCacheStatus;
18
+ time: number;
19
+ }
20
+ export type PredyRequestCallback = (err: string | undefined, res: PredyRequestResponse) => void;
3
21
  export declare abstract class PredyNativeInternal {
4
22
  abstract createImageBitmap(data: TypedArray | string, //图片文件的数据
5
23
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
24
+ abstract getDefaultGPUCapability(): GPUCapability;
25
+ abstract requestWithCache(options: PredyRequestOptions, callback: PredyRequestCallback): void;
6
26
  }
@@ -12,6 +12,7 @@ import type { TextureInternal, TextureInternalConstructOptions } from './Texture
12
12
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
13
13
  import type { AndGLContext } from './AndGLContext';
14
14
  import type { TypedArray } from '../type';
15
+ import type { MetalInternal } from './MetalInternal';
15
16
  /**
16
17
  * renderer 内部创建的对象,用来统计信息,排查资源泄漏的问题
17
18
  */
@@ -41,6 +42,10 @@ export declare abstract class RendererInternal implements ResourceInternal {
41
42
  * 用于Android的GL上下文, 用于测试, 不会在RI中使用
42
43
  */
43
44
  readonly gl?: AndGLContext;
45
+ /**
46
+ * metal相关设置
47
+ */
48
+ readonly metal?: MetalInternal;
44
49
  abstract destroy(): void;
45
50
  /**
46
51
  * 需要进行重新渲染
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.1.68",
3
+ "version": "0.1.70",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
package/types/Canvas.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export interface Canvas {
2
2
  width: number,
3
3
  height: number,
4
-
5
4
  addEventListener(name: string, handler: Function): void,
6
5
 
7
6
  removeEventListener(name: string, handler: Function): void,
@@ -11,7 +10,7 @@ export interface Canvas {
11
10
  export class CanvasEmpty implements Canvas {
12
11
  width = 0;
13
12
  height = 0;
14
-
13
+ style = {};
15
14
  addEventListener (name: string, handler: Function) {
16
15
  }
17
16
 
@@ -1,5 +1,4 @@
1
1
  import type { Immutable } from './type';
2
-
3
2
  export const COMPRESSED_TEXTURE_NONE = 0;
4
3
  export const COMPRESSED_TEXTURE_PVRTC = 1;
5
4
  export const COMPRESSED_TEXTURE_ASTC = 2;
@@ -32,8 +31,10 @@ export interface GPUCapabilityDetail {
32
31
  writableFragDepth?: boolean,
33
32
  }
34
33
 
34
+ export type GPUFramework = 'webgl' | 'webgl2' | 'opengles3' | 'opengles2' | 'node-gl' | 'metal' | 'none';
35
+
35
36
  export interface GPUCapability {
36
- type: 'webgl' | 'webgl2' | 'native-gl' | 'node-gl' | 'metal' | 'none',
37
+ type: GPUFramework,
37
38
  level: number,
38
39
  capability: Immutable<GPUCapabilityDetail>,
39
40
 
@@ -41,7 +42,7 @@ export interface GPUCapability {
41
42
  }
42
43
 
43
44
  export class GPUCapabilityEmpty implements GPUCapability {
44
- type: 'webgl' | 'webgl2' | 'native-gl' | 'node-gl' | 'metal' | 'none';
45
+ type: GPUFramework;
45
46
  level = 0;
46
47
  capability = {
47
48
  maxSample: 0,
package/types/Geometry.ts CHANGED
@@ -25,6 +25,11 @@ export interface AttributeBase {
25
25
 
26
26
  size: number,
27
27
 
28
+ /**
29
+ * default is float
30
+ */
31
+ type?: WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'],
32
+
28
33
  stride?: number,
29
34
 
30
35
  offset?: number,
@@ -48,7 +53,6 @@ export interface AttributeBase {
48
53
  export interface AttributeWithData extends AttributeBase {
49
54
  data?: TypedArray,
50
55
  releasable?: boolean,
51
- type?: WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'],
52
56
  }
53
57
 
54
58
  export interface AttributeWithType extends AttributeBase {
@@ -56,19 +60,9 @@ export interface AttributeWithType extends AttributeBase {
56
60
  * 如果使用interleaved attribute,此字段表示数据共享的attribute
57
61
  */
58
62
  dataSource: string,
59
- type: WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'],
60
63
  }
61
64
 
62
- export interface AttributeWithDataSource extends AttributeBase {
63
- /**
64
- * 如果使用interleaved attribute,此字段表示数据共享的attribute
65
- */
66
- dataSource: string,
67
- /**
68
- * use FLOAT by default
69
- */
70
- type?: WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'],
71
- }
65
+ export type AttributeWithDataSource = AttributeWithType;
72
66
 
73
67
  export type Attribute = AttributeWithData | AttributeWithType | AttributeWithDataSource;
74
68
 
package/types/Material.ts CHANGED
@@ -165,8 +165,19 @@ export declare class MaterialDataBlock implements IGPUResource {
165
165
 
166
166
  setUniformSemantic (name: string, semantic: string | undefined): void;
167
167
 
168
+ /**
169
+ * 多次调用次函数只会更新JS层的数据,不会直接更新GPU数据
170
+ * 在下一次渲染前,会将JS层的数据更新到GPU
171
+ * @param name
172
+ * @param value
173
+ */
168
174
  setUniformValue (name: string, value: UniformValue): boolean;
169
-
175
+ /**
176
+ * 在JS层维持一份uniform数据,当JS数据发生变化时,数据并不会直接反应到GPU
177
+ * 需要调用setUniformValue更新数据到GPU
178
+ * 多次调用getUniformValue返回同一个Value对象
179
+ * @param name
180
+ */
170
181
  getUniformValue (name: string): UniformValue;
171
182
 
172
183
  getUniformValues (): { [key: string]: UniformValue };
@@ -177,16 +188,8 @@ export declare class MaterialDataBlock implements IGPUResource {
177
188
 
178
189
  getUniformTexture<T extends Texture[] | Texture = Texture>(uniformName: string): T | undefined;
179
190
 
180
- /**
181
- * indicate uniform data should be resent to GPU, but not the full range,
182
- * only works for ubo,if not an ubo, this method has no side effect
183
- * offset and count are counted by typed entry, not the number elements
184
- * entry means matrix or vector in shader
185
- * @param name uniform name
186
- * @param offset entry offset,first entry to send to gpu, default 0
187
- * @param count entry count,entry count to send to gpu,default to end
188
- */
189
- updateUniformSubData (name: string, offset: number, count: number): void;
191
+ //todo
192
+ // setUniformSubValue (name: string, value: TypedArray, byteOffset: number): void;
190
193
 
191
194
  destroy (options?: MaterialDataBlockDestroyOptions): void;
192
195
 
package/types/Renderer.ts CHANGED
@@ -6,9 +6,11 @@ import type { IGPURenderer } from './IGPURenderer';
6
6
  import type { Canvas } from './Canvas';
7
7
  import type { Texture } from './Texture';
8
8
  import type { RenderPass } from './RenderPass';
9
+ import type { RendererInternal } from './native';
9
10
 
10
11
  export interface RendererOptions {
11
12
  gl?: WebGLRenderingContext | WebGL2RenderingContext,
13
+ internal?: RendererInternal,
12
14
  canvas?: HTMLCanvasElement,
13
15
  // if use frameworks [ 'webgl2', 'webgl' ], renderer will choose webgl if webgl2 is not supported
14
16
  frameworks?: Array<'webgl' | 'webgl2'>,
@@ -1,15 +1,33 @@
1
+ import type { AttributeBase, GeometryBufferLayout } from './Geometry';
2
+
1
3
  export type Shader = ShaderWithSource | ShaderUseCacheId;
2
4
  export type ShaderWithSource = InstancedShaderWithSource | SharedShaderWithSource;
3
5
 
4
- export interface MetaShaderSpec {
6
+ interface MetalVertexAttribute extends Omit<AttributeBase, 'instanceDivisor'> {
7
+ location: number,
8
+ stride: number,
9
+ offset: number,
10
+ dataSource: string,
11
+ }
12
+ export interface MetalShaderSpec {
5
13
  mtlBinary?: ArrayBuffer | string,
6
14
  mtlSource?: string,
7
-
8
15
  mtlVertex?: string,
9
16
  mtlFragment?: string,
17
+ //todo lilong
18
+ /**
19
+ * 用于提前计算pipeline,如果没有传递,则需要在mesh被assignRenderer的时候才会计算pipeline
20
+ * 当mesh被添加到renderPass的时候,会根据renderPass和mesh的vertexLayout寻找对应的pipeline
21
+ * 如果没有找到,则需要创建,创建后会被缓存
22
+ * 为了避免渲染卡顿,最好在编译shader的时候就进行pipeline缓存
23
+ */
24
+ mtlVertexLayout?: {
25
+ bufferLayouts: GeometryBufferLayout[],
26
+ attributes: MetalVertexAttribute[],
27
+ },
10
28
  }
11
29
 
12
- export interface ShaderSourceBase extends MetaShaderSpec {
30
+ export interface ShaderSourceBase extends MetalShaderSpec {
13
31
  fragment: string,
14
32
  vertex: string,
15
33
  name?: string,
@@ -0,0 +1,22 @@
1
+ import type { RenderPassAttachmentStorageType } from '../RenderPass';
2
+
3
+ type MetalRenderPassColorFormat = WebGL2RenderingContext['RGBA8'] |
4
+ WebGL2RenderingContext['RGBA16F'] |
5
+ WebGL2RenderingContext['RGBA32F'] |
6
+ WebGL2RenderingContext['R16F'] |
7
+ WebGL2RenderingContext['R32F'];
8
+ interface MetalRenderPassAttachmentFormat {
9
+ colors: MetalRenderPassColorFormat[],
10
+ depth: RenderPassAttachmentStorageType,
11
+ stencil: RenderPassAttachmentStorageType,
12
+ id?: string,
13
+ }
14
+ export interface MetalInternal {
15
+ //通过RenderPass(RP) attachment具体数据算出id,并且返回
16
+ //添加后,此attachment会在shader编译阶段提前创建出pipeline
17
+ //对于添加到RP的Mesh,寻找此RP对应的pipeline,如果没有则创建
18
+ //RP销毁时,不会销毁对应的pipeline,需要调用shaderLib删除shader的时候才会销毁
19
+ //renderer启动时,会自动创建一个RPFormat,数据源于直接绘制到view的RP
20
+ addRenderPassAttachmentFormat(format: MetalRenderPassAttachmentFormat): string,
21
+
22
+ }
@@ -1,7 +1,35 @@
1
1
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
2
2
  import type { TypedArray } from '../type';
3
+ import type { GPUCapability } from '../GPUCapability';
4
+
5
+ export interface PredyRequestOptions {
6
+ url: string,
7
+ //用于测试缓存,生产中不要使用
8
+ disableCache?: boolean,
9
+ //默认5S
10
+ timeout?: number,
11
+
12
+ responseType?: 'text' | 'arraybuffer',
13
+ }
14
+ export enum PredyResourceCacheStatus {
15
+ noCache = 0, // 没有缓存,走网络请求
16
+ cached = 1, // 命中缓存,如果请求同一个url,在关闭APP之前,一定会命中缓存,关闭APP后,清理时间由系统决定
17
+ preloaded = 2, // 命中预推
18
+ }
19
+
20
+ export interface PredyRequestResponse {
21
+ data: ArrayBuffer | string,
22
+ cacheStatus: PredyResourceCacheStatus,
23
+ time: number,
24
+ }
25
+
26
+ export type PredyRequestCallback = (err: string | undefined, res: PredyRequestResponse) => void;
3
27
 
4
28
  export declare abstract class PredyNativeInternal {
5
29
  abstract createImageBitmap (data: TypedArray | string, //图片文件的数据
6
30
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
31
+
32
+ abstract getDefaultGPUCapability (): GPUCapability;
33
+
34
+ abstract requestWithCache (options: PredyRequestOptions, callback: PredyRequestCallback): void;
7
35
  }
@@ -12,6 +12,7 @@ import type { TextureInternal, TextureInternalConstructOptions } from './Texture
12
12
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
13
13
  import type { AndGLContext } from './AndGLContext';
14
14
  import type { TypedArray } from '../type';
15
+ import type { MetalInternal } from './MetalInternal';
15
16
 
16
17
  /**
17
18
  * renderer 内部创建的对象,用来统计信息,排查资源泄漏的问题
@@ -48,6 +49,12 @@ export abstract class RendererInternal implements ResourceInternal {
48
49
  */
49
50
  readonly gl?: AndGLContext;
50
51
 
52
+ //todo lilong
53
+ /**
54
+ * metal相关设置
55
+ */
56
+ readonly metal?: MetalInternal;
57
+
51
58
  abstract destroy (): void;
52
59
 
53
60
  /**