@luma.gl/core 9.0.0-beta.6 → 9.0.0-beta.7

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.
Files changed (46) hide show
  1. package/dist/adapter/device.d.ts +22 -12
  2. package/dist/adapter/device.d.ts.map +1 -1
  3. package/dist/adapter/device.js +18 -7
  4. package/dist/adapter/resources/buffer.d.ts +3 -1
  5. package/dist/adapter/resources/buffer.d.ts.map +1 -1
  6. package/dist/adapter/resources/buffer.js +4 -0
  7. package/dist/adapter/resources/compute-pipeline.d.ts +14 -5
  8. package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
  9. package/dist/adapter/resources/compute-pipeline.js +4 -4
  10. package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
  11. package/dist/adapter/resources/framebuffer.js +4 -1
  12. package/dist/adapter/resources/render-pipeline.d.ts +8 -8
  13. package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
  14. package/dist/adapter/resources/render-pipeline.js +2 -2
  15. package/dist/adapter/resources/shader.d.ts +3 -3
  16. package/dist/adapter/resources/shader.d.ts.map +1 -1
  17. package/dist/adapter/resources/shader.js +1 -1
  18. package/dist/adapter/resources/texture.d.ts +5 -0
  19. package/dist/adapter/resources/texture.d.ts.map +1 -1
  20. package/dist/adapter/resources/texture.js +5 -0
  21. package/dist/adapter/types/shader-layout.d.ts +8 -4
  22. package/dist/adapter/types/shader-layout.d.ts.map +1 -1
  23. package/dist/adapter/types/texture-formats.d.ts.map +1 -1
  24. package/dist/dist.dev.js +114 -137
  25. package/dist/index.cjs +38 -19
  26. package/dist/index.cjs.map +2 -2
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/init.js +1 -1
  30. package/dist/lib/luma.d.ts +6 -2
  31. package/dist/lib/luma.d.ts.map +1 -1
  32. package/dist/lib/uniforms/uniform-store.js +1 -1
  33. package/dist.min.js +2 -2
  34. package/package.json +2 -2
  35. package/src/adapter/device.ts +45 -23
  36. package/src/adapter/resources/buffer.ts +5 -1
  37. package/src/adapter/resources/compute-pipeline.ts +19 -9
  38. package/src/adapter/resources/framebuffer.ts +5 -1
  39. package/src/adapter/resources/render-pipeline.ts +10 -10
  40. package/src/adapter/resources/shader.ts +3 -3
  41. package/src/adapter/resources/texture.ts +10 -0
  42. package/src/adapter/types/shader-layout.ts +9 -4
  43. package/src/adapter/types/texture-formats.ts +3 -4
  44. package/src/index.ts +1 -0
  45. package/src/lib/luma.ts +7 -2
  46. package/src/lib/uniforms/uniform-store.ts +1 -1
@@ -19,15 +19,15 @@ export type RenderPipelineProps = ResourceProps & {
19
19
 
20
20
  /** Compiled vertex shader */
21
21
  vs?: Shader | null;
22
- /** Vertex shader entry point (defaults to 'main'). WGSL only */
23
- vsEntryPoint?: string; //
24
- /** Constants to apply to compiled vertex shader (WGSL only) */
22
+ /** Name of vertex shader stage main function (defaults to 'main'). WGSL only */
23
+ vertexEntryPoint?: string; //
24
+ /** Constant values to apply to compiled vertex shader. Do not require re-compilation. (WGSL only) */
25
25
  vsConstants?: Record<string, number>; // WGSL only
26
26
  /** Compiled fragment shader */
27
27
  fs?: Shader | null;
28
- /** Fragment shader entry point (defaults to 'main'). WGSL only */
29
- fsEntryPoint?: string; // WGSL only
30
- /** Constants to apply to compiled fragment shader (WGSL only) */
28
+ /** Name of fragment shader stage main function (defaults to 'main'). WGSL only */
29
+ fragmentEntryPoint?: string; // WGSL only
30
+ /** Constant values to apply to compiled fragment shader. Do not require re-compilation. (WGSL only) */
31
31
  fsConstants?: Record<string, number>;
32
32
 
33
33
  /** Describes the attributes and bindings exposed by the pipeline shader(s). */
@@ -65,11 +65,11 @@ export abstract class RenderPipeline extends Resource<RenderPipelineProps> {
65
65
  ...Resource.defaultProps,
66
66
 
67
67
  vs: null,
68
- vsEntryPoint: '', // main
68
+ vertexEntryPoint: 'vertexMain',
69
69
  vsConstants: {},
70
70
 
71
71
  fs: null,
72
- fsEntryPoint: '', // main
72
+ fragmentEntryPoint: 'fragmentMain',
73
73
  fsConstants: {},
74
74
 
75
75
  shaderLayout: null,
@@ -109,7 +109,7 @@ export abstract class RenderPipeline extends Resource<RenderPipelineProps> {
109
109
  /** Set bindings (stored on pipeline and set before each call) */
110
110
  abstract setBindings(bindings: Record<string, Binding>): void;
111
111
 
112
- /** Draw call */
112
+ /** Draw call. Returns false if the draw call was aborted (due to resources still initializing) */
113
113
  abstract draw(options: {
114
114
  /** Render pass to draw into (targeting screen or framebuffer) */
115
115
  renderPass?: RenderPass;
@@ -130,7 +130,7 @@ export abstract class RenderPipeline extends Resource<RenderPipelineProps> {
130
130
  baseVertex?: number;
131
131
  /** Transform feedback. WebGL only. */
132
132
  transformFeedback?: TransformFeedback;
133
- }): void;
133
+ }): boolean;
134
134
 
135
135
  // DEPRECATED METHODS
136
136
 
@@ -16,8 +16,8 @@ import {getShaderInfo} from '../../lib/compiler-log/get-shader-info';
16
16
  export type ShaderProps = ResourceProps & {
17
17
  /** Shader language (defaults to auto) */
18
18
  language?: 'glsl' | 'wgsl' | 'auto';
19
- /** Which stage are we compiling? Required by WebGL and GLSL transpiler */
20
- stage: 'vertex' | 'fragment' | 'compute';
19
+ /** Which stage are we compiling? Required for GLSL. Ignored for WGSL. */
20
+ stage?: 'vertex' | 'fragment' | 'compute';
21
21
  /** Shader source code */
22
22
  source: string;
23
23
  /** Optional shader source map (WebGPU only) */
@@ -36,7 +36,7 @@ export abstract class Shader extends Resource<ShaderProps> {
36
36
  static override defaultProps: Required<ShaderProps> = {
37
37
  ...Resource.defaultProps,
38
38
  language: 'auto',
39
- stage: 'vertex',
39
+ stage: undefined,
40
40
  source: '',
41
41
  sourceMap: null,
42
42
  entryPoint: 'main',
@@ -127,6 +127,10 @@ export abstract class Texture<Props extends TextureProps = TextureProps> extends
127
127
  /** Default view for this texture */
128
128
  abstract view: TextureView;
129
129
 
130
+ /** "Time" of last update. Monotonically increasing timestamp */
131
+ updateTimestamp: number;
132
+
133
+ /** Do not use directly. Create with device.createTexture() */
130
134
  constructor(
131
135
  device: Device,
132
136
  props: Props,
@@ -138,5 +142,11 @@ export abstract class Texture<Props extends TextureProps = TextureProps> extends
138
142
  this.width = this.props.width;
139
143
  this.height = this.props.height;
140
144
  this.depth = this.props.depth;
145
+
146
+ // TODO - perhaps this should be set on async write completion?
147
+ this.updateTimestamp = device.incrementTimestamp();
141
148
  }
149
+
150
+ /** Create a texture view for this texture */
151
+ abstract createView(props?: TextureViewProps): TextureView;
142
152
  }
@@ -35,7 +35,7 @@ import type {TextureView} from '../resources/texture-view';
35
35
  export type ShaderLayout = {
36
36
  /** All attributes, their locations, and basic type information. Also an auto-deduced step mode */
37
37
  attributes: AttributeDeclaration[];
38
- /** All bidning points (textures, samplers, uniform buffers) with their locations and type */
38
+ /** All binding points (textures, samplers, uniform buffers) with their locations and type */
39
39
  bindings: BindingDeclaration[];
40
40
  /** WebGL only (WebGPU use bindings and uniform buffers) */
41
41
  uniforms?: any[];
@@ -43,6 +43,11 @@ export type ShaderLayout = {
43
43
  varyings?: VaryingBinding[];
44
44
  };
45
45
 
46
+ export type ComputeShaderLayout = {
47
+ /** All binding points (textures, samplers, uniform buffers) with their locations and type */
48
+ bindings: BindingDeclaration[];
49
+ };
50
+
46
51
  /**
47
52
  * Declares one for attributes
48
53
  */
@@ -88,7 +93,7 @@ type Binding = {
88
93
  /** ShaderLayout for bindings */
89
94
  export type BindingDeclaration =
90
95
  | UniformBufferBindingLayout
91
- | BufferBindingLayout
96
+ | StorageBufferBindingLayout
92
97
  | TextureBindingLayout
93
98
  | SamplerBindingLayout
94
99
  | StorageTextureBindingLayout;
@@ -112,8 +117,8 @@ export type UniformInfo = {
112
117
  byteStride: number;
113
118
  };
114
119
 
115
- export type BufferBindingLayout = {
116
- type: 'uniform' | 'storage' | 'read-only-storage';
120
+ export type StorageBufferBindingLayout = {
121
+ type: 'storage' | 'read-only-storage';
117
122
  name: string;
118
123
  location: number;
119
124
  visibility?: number;
@@ -133,10 +133,9 @@ export type WebGPUColorTextureFormat =
133
133
  | 'astc-12x12-unorm-srgb';
134
134
 
135
135
  /** Unsized texture formats (the only formats supported by WebGL1) */
136
- export type UnsizedColorTextureFormat =
137
- // 'r8unorm-unsized' |
138
- // 'ra8unorm-unsized' |
139
- 'rgb8unorm-unsized' | 'rgba8unorm-unsized';
136
+ export type UnsizedColorTextureFormat = 'rgb8unorm-unsized' | 'rgba8unorm-unsized';
137
+ // 'r8unorm-unsized' |
138
+ // 'ra8unorm-unsized' |
140
139
  // 'rgb8unorm-srgb-unsized' |
141
140
  // 'rgba8unorm-srgb-unsized'
142
141
 
package/src/index.ts CHANGED
@@ -109,6 +109,7 @@ export type {ColorAttachment, DepthStencilAttachment} from './adapter/types/type
109
109
 
110
110
  export type {
111
111
  ShaderLayout,
112
+ ComputeShaderLayout,
112
113
  AttributeDeclaration,
113
114
  BindingDeclaration,
114
115
  Binding
package/src/lib/luma.ts CHANGED
@@ -12,6 +12,11 @@ import {assert} from '../utils/assert';
12
12
 
13
13
  const deviceList = new Map<string, typeof Device>();
14
14
 
15
+ export type CreateDeviceProps = DeviceProps & {
16
+ /** Select type of device */
17
+ type?: 'webgl' | 'webgpu' | 'best-available';
18
+ };
19
+
15
20
  /**
16
21
  * Entry point to the luma.gl GPU abstraction
17
22
  * Register WebGPU and/or WebGL devices (controls application bundle size)
@@ -46,12 +51,12 @@ export class luma {
46
51
  );
47
52
  }
48
53
 
49
- static setDefaultDeviceProps(props: DeviceProps): void {
54
+ static setDefaultDeviceProps(props: CreateDeviceProps): void {
50
55
  Object.assign(Device.defaultProps, props);
51
56
  }
52
57
 
53
58
  /** Creates a device. Asynchronously. */
54
- static async createDevice(props: DeviceProps = {}): Promise<Device> {
59
+ static async createDevice(props: CreateDeviceProps = {}): Promise<Device> {
55
60
  props = {...Device.defaultProps, ...props};
56
61
  if (props.gl) {
57
62
  props.type = 'webgl';
@@ -66,7 +66,7 @@ export class UniformStore<
66
66
 
67
67
  /** Destroy any managed uniform buffers */
68
68
  destroy(): void {
69
- for (const uniformBuffer of Object.values(this.uniformBuffers)) {
69
+ for (const uniformBuffer of this.uniformBuffers.values()) {
70
70
  uniformBuffer.destroy();
71
71
  }
72
72
  }