@luma.gl/core 9.0.17 → 9.1.0-alpha.10
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/adapter/adapter.d.ts +11 -0
- package/dist/adapter/adapter.d.ts.map +1 -0
- package/dist/adapter/adapter.js +8 -0
- package/dist/adapter/canvas-context.d.ts +5 -0
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/device.d.ts +23 -11
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +22 -20
- package/dist/adapter/luma.d.ts +70 -0
- package/dist/adapter/luma.d.ts.map +1 -0
- package/dist/adapter/luma.js +159 -0
- package/dist/adapter/resources/buffer.js +5 -5
- package/dist/adapter/resources/compute-pipeline.d.ts +2 -0
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/compute-pipeline.js +3 -0
- package/dist/adapter/resources/external-texture.d.ts +1 -1
- package/dist/adapter/resources/external-texture.d.ts.map +1 -1
- package/dist/adapter/resources/external-texture.js +1 -1
- package/dist/adapter/resources/framebuffer.d.ts +3 -3
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +2 -83
- package/dist/adapter/resources/render-pass.d.ts +2 -2
- package/dist/adapter/resources/render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +2 -5
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/resource.d.ts +3 -3
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js +1 -1
- package/dist/adapter/resources/shader.d.ts +5 -2
- package/dist/adapter/resources/shader.d.ts.map +1 -1
- package/dist/adapter/resources/shader.js +15 -9
- package/dist/adapter/resources/texture-view.d.ts +1 -1
- package/dist/adapter/resources/texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/texture.d.ts +144 -47
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +120 -12
- package/dist/adapter/resources/transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/vertex-array.d.ts +1 -1
- package/dist/adapter/resources/vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/vertex-array.js +6 -2
- package/dist/adapter/types/{types.d.ts → attachments.d.ts} +7 -17
- package/dist/adapter/types/attachments.d.ts.map +1 -0
- package/dist/adapter/types/buffer-layout.d.ts +1 -1
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
- package/dist/adapter/types/compiler-message.d.ts.map +1 -0
- package/dist/adapter/types/parameters.d.ts +4 -6
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/parameters.js +1 -0
- package/dist/adapter/types/shader-layout.d.ts +23 -3
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter/types/uniforms.d.ts +4 -0
- package/dist/adapter/types/uniforms.d.ts.map +1 -0
- package/dist/{lib/compiler-log → adapter-utils}/format-compiler-log.d.ts +1 -1
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -0
- package/dist/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.d.ts +4 -11
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -0
- package/dist/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.js +10 -30
- package/dist/adapter-utils/is-uniform-value.d.ts +3 -0
- package/dist/adapter-utils/is-uniform-value.d.ts.map +1 -0
- package/dist/adapter-utils/is-uniform-value.js +7 -0
- package/dist/dist.dev.js +635 -821
- package/dist/dist.min.js +6 -6
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.d.ts +3 -3
- package/dist/gpu-type-utils/decode-attribute-type.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-data-type.d.ts +1 -1
- package/dist/gpu-type-utils/decode-data-type.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-shader-types.d.ts +1 -1
- package/dist/gpu-type-utils/decode-shader-types.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-shader-types.js +0 -2
- package/dist/gpu-type-utils/decode-texture-format.d.ts +43 -0
- package/dist/gpu-type-utils/decode-texture-format.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-texture-format.js +67 -31
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.d.ts +1 -1
- package/dist/gpu-type-utils/decode-vertex-format.d.ts.map +1 -0
- package/dist/gpu-type-utils/shader-types.d.ts.map +1 -0
- package/dist/{adapter/types → gpu-type-utils}/texture-formats.d.ts +3 -5
- package/dist/gpu-type-utils/texture-formats.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.d.ts +2 -2
- package/dist/gpu-type-utils/vertex-format-from-attribute.d.ts.map +1 -0
- package/dist/gpu-type-utils/vertex-formats.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/wgsl-utils.d.ts +1 -1
- package/dist/gpu-type-utils/wgsl-utils.d.ts.map +1 -0
- package/dist/index.cjs +396 -567
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +28 -44
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -37
- package/dist/{lib/uniforms → portable}/uniform-block.d.ts +3 -3
- package/dist/portable/uniform-block.d.ts.map +1 -0
- package/dist/{lib/uniforms → portable}/uniform-block.js +2 -2
- package/dist/{lib/uniforms → portable}/uniform-buffer-layout.d.ts +2 -2
- package/dist/portable/uniform-buffer-layout.d.ts.map +1 -0
- package/dist/{lib/uniforms → portable}/uniform-buffer-layout.js +6 -7
- package/dist/{lib/uniforms → portable}/uniform-store.d.ts +9 -4
- package/dist/portable/uniform-store.d.ts.map +1 -0
- package/dist/{lib/uniforms → portable}/uniform-store.js +11 -9
- package/dist/types.d.ts +0 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/array-equal.d.ts.map +1 -1
- package/dist/utils/array-equal.js +6 -7
- package/dist/utils/array-utils-flat.d.ts +1 -7
- package/dist/utils/array-utils-flat.d.ts.map +1 -1
- package/dist/utils/array-utils-flat.js +0 -23
- package/dist/utils/is-array.d.ts +3 -3
- package/dist/utils/is-array.d.ts.map +1 -1
- package/dist/utils/is-array.js +2 -2
- package/dist/utils/uid.d.ts +7 -0
- package/dist/utils/uid.d.ts.map +1 -0
- package/dist/utils/{utils.js → uid.js} +0 -11
- package/package.json +5 -5
- package/src/adapter/adapter.ts +16 -0
- package/src/adapter/canvas-context.ts +6 -0
- package/src/adapter/device.ts +52 -36
- package/src/adapter/luma.ts +219 -0
- package/src/adapter/resources/buffer.ts +5 -5
- package/src/adapter/resources/command-encoder.ts +1 -1
- package/src/adapter/resources/compute-pass.ts +3 -3
- package/src/adapter/resources/compute-pipeline.ts +6 -3
- package/src/adapter/resources/external-texture.ts +2 -2
- package/src/adapter/resources/framebuffer.ts +5 -92
- package/src/adapter/resources/query-set.ts +2 -2
- package/src/adapter/resources/render-pass.ts +11 -7
- package/src/adapter/resources/render-pipeline.ts +3 -6
- package/src/adapter/resources/resource.ts +7 -7
- package/src/adapter/resources/shader.ts +18 -11
- package/src/adapter/resources/texture-view.ts +5 -5
- package/src/adapter/resources/texture.ts +285 -76
- package/src/adapter/resources/transform-feedback.ts +1 -1
- package/src/adapter/resources/vertex-array.ts +7 -3
- package/src/adapter/types/{types.ts → attachments.ts} +10 -18
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +14 -14
- package/src/adapter/types/shader-layout.ts +31 -29
- package/src/adapter/types/uniforms.ts +10 -0
- package/src/{lib/compiler-log → adapter-utils}/format-compiler-log.ts +1 -1
- package/src/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.ts +18 -42
- package/src/adapter-utils/is-uniform-value.ts +10 -0
- package/src/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.ts +3 -3
- package/src/{adapter/type-utils → gpu-type-utils}/decode-data-type.ts +1 -1
- package/src/{adapter/type-utils → gpu-type-utils}/decode-shader-types.ts +1 -3
- package/src/{adapter/type-utils → gpu-type-utils}/decode-texture-format.ts +99 -39
- package/src/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.ts +1 -1
- package/src/{adapter/types → gpu-type-utils}/texture-formats.ts +3 -14
- package/src/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.ts +2 -2
- package/src/{adapter/type-utils → gpu-type-utils}/wgsl-utils.ts +1 -1
- package/src/index.ts +67 -83
- package/src/{lib/uniforms → portable}/uniform-block.ts +5 -5
- package/src/{lib/uniforms → portable}/uniform-buffer-layout.ts +9 -9
- package/src/{lib/uniforms → portable}/uniform-store.ts +20 -12
- package/src/types.ts +0 -12
- package/src/utils/array-equal.ts +6 -7
- package/src/utils/array-utils-flat.ts +1 -31
- package/src/utils/is-array.ts +5 -5
- package/src/utils/{utils.ts → uid.ts} +0 -12
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-attribute-type.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-data-type.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-shader-types.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-texture-format.d.ts +0 -23
- package/dist/adapter/type-utils/decode-texture-format.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-vertex-format.d.ts.map +0 -1
- package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts.map +0 -1
- package/dist/adapter/type-utils/wgsl-utils.d.ts.map +0 -1
- package/dist/adapter/types/accessor.d.ts +0 -23
- package/dist/adapter/types/accessor.d.ts.map +0 -1
- package/dist/adapter/types/shader-types.d.ts.map +0 -1
- package/dist/adapter/types/texture-formats.d.ts.map +0 -1
- package/dist/adapter/types/types.d.ts.map +0 -1
- package/dist/adapter/types/vertex-formats.d.ts.map +0 -1
- package/dist/init.d.ts +0 -5
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -37
- package/dist/lib/compiler-log/compiler-message.d.ts.map +0 -1
- package/dist/lib/compiler-log/format-compiler-log.d.ts.map +0 -1
- package/dist/lib/compiler-log/get-shader-info.d.ts +0 -9
- package/dist/lib/compiler-log/get-shader-info.d.ts.map +0 -1
- package/dist/lib/compiler-log/get-shader-info.js +0 -29
- package/dist/lib/luma.d.ts +0 -38
- package/dist/lib/luma.d.ts.map +0 -1
- package/dist/lib/luma.js +0 -141
- package/dist/lib/uniforms/uniform-block.d.ts.map +0 -1
- package/dist/lib/uniforms/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/lib/uniforms/uniform-store.d.ts.map +0 -1
- package/dist/lib/uniforms/uniform.d.ts +0 -10
- package/dist/lib/uniforms/uniform.d.ts.map +0 -1
- package/dist/lib/uniforms/uniform.js +0 -20
- package/dist/utils/assert.d.ts +0 -2
- package/dist/utils/assert.d.ts.map +0 -1
- package/dist/utils/assert.js +0 -10
- package/dist/utils/cast.d.ts +0 -3
- package/dist/utils/cast.d.ts.map +0 -1
- package/dist/utils/cast.js +0 -7
- package/dist/utils/check-props.d.ts +0 -7
- package/dist/utils/check-props.d.ts.map +0 -1
- package/dist/utils/check-props.js +0 -36
- package/dist/utils/deep-equal.d.ts +0 -9
- package/dist/utils/deep-equal.d.ts.map +0 -1
- package/dist/utils/deep-equal.js +0 -50
- package/dist/utils/format-value.d.ts +0 -7
- package/dist/utils/format-value.d.ts.map +0 -1
- package/dist/utils/format-value.js +0 -39
- package/dist/utils/load-file.d.ts +0 -35
- package/dist/utils/load-file.d.ts.map +0 -1
- package/dist/utils/load-file.js +0 -74
- package/dist/utils/random.d.ts +0 -5
- package/dist/utils/random.d.ts.map +0 -1
- package/dist/utils/random.js +0 -18
- package/dist/utils/request-animation-frame.d.ts +0 -3
- package/dist/utils/request-animation-frame.d.ts.map +0 -1
- package/dist/utils/request-animation-frame.js +0 -16
- package/dist/utils/stub-methods.d.ts +0 -2
- package/dist/utils/stub-methods.d.ts.map +0 -1
- package/dist/utils/stub-methods.js +0 -19
- package/dist/utils/utils.d.ts +0 -9
- package/dist/utils/utils.d.ts.map +0 -1
- package/src/adapter/types/accessor.ts +0 -37
- package/src/init.ts +0 -53
- package/src/lib/compiler-log/get-shader-info.ts +0 -42
- package/src/lib/luma.ts +0 -190
- package/src/lib/uniforms/uniform.ts +0 -31
- package/src/utils/assert.ts +0 -11
- package/src/utils/cast.ts +0 -8
- package/src/utils/check-props.ts +0 -82
- package/src/utils/deep-equal.ts +0 -51
- package/src/utils/format-value.ts +0 -47
- package/src/utils/load-file.ts +0 -91
- package/src/utils/random.ts +0 -21
- package/src/utils/request-animation-frame.ts +0 -19
- package/src/utils/stub-methods.ts +0 -29
- /package/dist/adapter/types/{accessor.js → attachments.js} +0 -0
- /package/dist/{lib/compiler-log → adapter/types}/compiler-message.d.ts +0 -0
- /package/dist/{lib/compiler-log → adapter/types}/compiler-message.js +0 -0
- /package/dist/adapter/types/{shader-types.js → uniforms.js} +0 -0
- /package/dist/{lib/compiler-log → adapter-utils}/format-compiler-log.js +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.js +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/decode-data-type.js +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.js +0 -0
- /package/dist/{adapter/types → gpu-type-utils}/shader-types.d.ts +0 -0
- /package/dist/{adapter/types/texture-formats.js → gpu-type-utils/shader-types.js} +0 -0
- /package/dist/{adapter/types/types.js → gpu-type-utils/texture-formats.js} +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.js +0 -0
- /package/dist/{adapter/types → gpu-type-utils}/vertex-formats.d.ts +0 -0
- /package/dist/{adapter/types → gpu-type-utils}/vertex-formats.js +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/wgsl-utils.js +0 -0
- /package/src/{lib/compiler-log → adapter/types}/compiler-message.ts +0 -0
- /package/src/{adapter/types → gpu-type-utils}/shader-types.ts +0 -0
- /package/src/{adapter/types → gpu-type-utils}/vertex-formats.ts +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Device} from '../device';
|
|
6
|
-
import type {UniformValue} from '../types/
|
|
6
|
+
import type {UniformValue} from '../types/uniforms';
|
|
7
7
|
import type {PrimitiveTopology, RenderPipelineParameters} from '../types/parameters';
|
|
8
8
|
import type {ShaderLayout, Binding} from '../types/shader-layout';
|
|
9
9
|
import type {BufferLayout} from '../types/buffer-layout';
|
|
@@ -32,10 +32,7 @@ export type RenderPipelineProps = ResourceProps & {
|
|
|
32
32
|
|
|
33
33
|
/** Describes the attributes and bindings exposed by the pipeline shader(s). */
|
|
34
34
|
shaderLayout?: ShaderLayout | null;
|
|
35
|
-
/**
|
|
36
|
-
* Describes the buffers accepted by this pipeline and how they are mapped to shader attributes.
|
|
37
|
-
* A default mapping of one buffer per attribute is always created.
|
|
38
|
-
*/
|
|
35
|
+
/** Describes the buffers accepted by this pipeline and how they are mapped to shader attributes. */
|
|
39
36
|
bufferLayout?: BufferLayout[]; // Record<string, Omit<BufferLayout, 'name'>
|
|
40
37
|
|
|
41
38
|
/** Determines how vertices are read from the 'vertex' attributes */
|
|
@@ -102,7 +99,7 @@ export abstract class RenderPipeline extends Resource<RenderPipelineProps> {
|
|
|
102
99
|
|
|
103
100
|
constructor(device: Device, props: RenderPipelineProps) {
|
|
104
101
|
super(device, props, RenderPipeline.defaultProps);
|
|
105
|
-
this.shaderLayout = this.props.shaderLayout
|
|
102
|
+
this.shaderLayout = this.props.shaderLayout!;
|
|
106
103
|
this.bufferLayout = this.props.bufferLayout || [];
|
|
107
104
|
}
|
|
108
105
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Device} from '../device';
|
|
6
|
-
import {uid} from '../../utils/
|
|
6
|
+
import {uid} from '../../utils/uid';
|
|
7
7
|
|
|
8
8
|
export type ResourceProps = {
|
|
9
9
|
/** Name of resource, mainly for debugging purposes. A unique name will be assigned if not provided */
|
|
@@ -22,7 +22,7 @@ export abstract class Resource<Props extends ResourceProps> {
|
|
|
22
22
|
static defaultProps: Required<ResourceProps> = {
|
|
23
23
|
id: 'undefined',
|
|
24
24
|
handle: undefined,
|
|
25
|
-
userData: undefined
|
|
25
|
+
userData: undefined!
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
abstract get [Symbol.toStringTag](): string;
|
|
@@ -39,7 +39,7 @@ export abstract class Resource<Props extends ResourceProps> {
|
|
|
39
39
|
/** For resources that allocate GPU memory */
|
|
40
40
|
private allocatedBytes: number = 0;
|
|
41
41
|
/** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
|
|
42
|
-
private _attachedResources = new Set<Resource<
|
|
42
|
+
private _attachedResources = new Set<Resource<ResourceProps>>();
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Create a new Resource. Called from Subclass
|
|
@@ -91,21 +91,21 @@ export abstract class Resource<Props extends ResourceProps> {
|
|
|
91
91
|
* Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
|
|
92
92
|
* Called automatically when sub resources are auto created but can be called by application
|
|
93
93
|
*/
|
|
94
|
-
attachResource(resource: Resource<
|
|
94
|
+
attachResource(resource: Resource<ResourceProps>): void {
|
|
95
95
|
this._attachedResources.add(resource);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
|
|
100
100
|
*/
|
|
101
|
-
detachResource(resource: Resource<
|
|
101
|
+
detachResource(resource: Resource<ResourceProps>): void {
|
|
102
102
|
this._attachedResources.delete(resource);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
|
|
107
107
|
*/
|
|
108
|
-
destroyAttachedResource(resource: Resource<
|
|
108
|
+
destroyAttachedResource(resource: Resource<ResourceProps>): void {
|
|
109
109
|
if (this._attachedResources.delete(resource)) {
|
|
110
110
|
resource.destroy();
|
|
111
111
|
}
|
|
@@ -117,7 +117,7 @@ export abstract class Resource<Props extends ResourceProps> {
|
|
|
117
117
|
resource.destroy();
|
|
118
118
|
}
|
|
119
119
|
// don't remove while we are iterating
|
|
120
|
-
this._attachedResources = new Set<Resource<
|
|
120
|
+
this._attachedResources = new Set<Resource<ResourceProps>>();
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// PROTECTED METHODS
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
import type {Device} from '../device';
|
|
6
6
|
import {Resource, ResourceProps} from './resource';
|
|
7
7
|
// import { log } from '../../utils/log';
|
|
8
|
-
import {uid} from '../../utils/
|
|
9
|
-
import {CompilerMessage} from '
|
|
10
|
-
import {formatCompilerLog} from '../../
|
|
11
|
-
import {getShaderInfo} from '../../lib/compiler-log/get-shader-info';
|
|
8
|
+
import {uid} from '../../utils/uid';
|
|
9
|
+
import {CompilerMessage} from '../types/compiler-message';
|
|
10
|
+
import {formatCompilerLog} from '../../adapter-utils/format-compiler-log';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Properties for a Shader
|
|
@@ -36,7 +35,7 @@ export abstract class Shader extends Resource<ShaderProps> {
|
|
|
36
35
|
static override defaultProps: Required<ShaderProps> = {
|
|
37
36
|
...Resource.defaultProps,
|
|
38
37
|
language: 'auto',
|
|
39
|
-
stage: undefined
|
|
38
|
+
stage: undefined!,
|
|
40
39
|
source: '',
|
|
41
40
|
sourceMap: null,
|
|
42
41
|
entryPoint: 'main',
|
|
@@ -101,14 +100,17 @@ export abstract class Shader extends Resource<ShaderProps> {
|
|
|
101
100
|
|
|
102
101
|
// PRIVATE
|
|
103
102
|
|
|
104
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* In-browser UI logging of errors
|
|
105
|
+
* TODO - this HTML formatting code should not be in Device, should be pluggable
|
|
106
|
+
*/
|
|
105
107
|
protected _displayShaderLog(messages: readonly CompilerMessage[]): void {
|
|
106
108
|
// Return if under Node.js / incomplete `document` polyfills
|
|
107
109
|
if (typeof document === 'undefined' || !document?.createElement) {
|
|
108
110
|
return;
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
const shaderName: string =
|
|
113
|
+
const shaderName: string = getShaderName(this.source);
|
|
112
114
|
const shaderTitle: string = `${this.stage} ${shaderName}`;
|
|
113
115
|
let htmlLog = formatCompilerLog(messages, this.source, {showSourceCode: 'all', html: true});
|
|
114
116
|
// Show translated source if available
|
|
@@ -132,9 +134,7 @@ ${htmlLog}
|
|
|
132
134
|
document.body.appendChild(button);
|
|
133
135
|
|
|
134
136
|
const errors = document.getElementsByClassName('luma-compiler-log-error');
|
|
135
|
-
|
|
136
|
-
errors[0].scrollIntoView();
|
|
137
|
-
}
|
|
137
|
+
errors[0]?.scrollIntoView();
|
|
138
138
|
|
|
139
139
|
// TODO - add a small embedded copy button (instead of main button)
|
|
140
140
|
button.onclick = () => {
|
|
@@ -151,5 +151,12 @@ ${htmlLog}
|
|
|
151
151
|
|
|
152
152
|
/** Deduce an id, from shader source, or supplied id, or shader type */
|
|
153
153
|
function getShaderIdFromProps(props: ShaderProps): string {
|
|
154
|
-
return
|
|
154
|
+
return getShaderName(props.source) || props.id || uid(`unnamed ${props.stage}-shader`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Extracts GLSLIFY style naming of shaders: `#define SHADER_NAME ...` */
|
|
158
|
+
function getShaderName(shader: string, defaultName: string = 'unnamed'): string {
|
|
159
|
+
const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
|
|
160
|
+
const match = SHADER_NAME_REGEXP.exec(shader);
|
|
161
|
+
return match ? match[1] : defaultName;
|
|
155
162
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {Device} from '../device';
|
|
6
6
|
import type {Texture} from './texture';
|
|
7
|
-
import type {TextureFormat} from '
|
|
7
|
+
import type {TextureFormat} from '../../gpu-type-utils/texture-formats';
|
|
8
8
|
import {Resource, ResourceProps} from './resource';
|
|
9
9
|
|
|
10
10
|
/** Properties for initializing a texture view */
|
|
@@ -29,13 +29,13 @@ export type TextureViewProps = ResourceProps & {
|
|
|
29
29
|
export abstract class TextureView extends Resource<TextureViewProps> {
|
|
30
30
|
static override defaultProps: Required<TextureViewProps> = {
|
|
31
31
|
...Resource.defaultProps,
|
|
32
|
-
format: undefined
|
|
33
|
-
dimension: undefined
|
|
32
|
+
format: undefined!,
|
|
33
|
+
dimension: undefined!,
|
|
34
34
|
aspect: 'all',
|
|
35
35
|
baseMipLevel: 0,
|
|
36
|
-
mipLevelCount: undefined
|
|
36
|
+
mipLevelCount: undefined!,
|
|
37
37
|
baseArrayLayer: 0,
|
|
38
|
-
arrayLayerCount: undefined
|
|
38
|
+
arrayLayerCount: undefined!
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
abstract texture: Texture;
|
|
@@ -4,73 +4,154 @@
|
|
|
4
4
|
|
|
5
5
|
import type {Device} from '../device';
|
|
6
6
|
import type {TypedArray} from '../../types';
|
|
7
|
-
import type {TextureFormat} from '
|
|
7
|
+
import type {TextureFormat} from '../../gpu-type-utils/texture-formats';
|
|
8
|
+
import type {TextureView, TextureViewProps} from './texture-view';
|
|
8
9
|
import {Resource, ResourceProps} from './resource';
|
|
9
10
|
import {Sampler, SamplerProps} from './sampler';
|
|
10
|
-
import {TextureView, TextureViewProps} from './texture-view';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
/**
|
|
13
|
+
* These represent the main compressed texture formats
|
|
14
|
+
* Each format typically has a number of more specific subformats
|
|
15
|
+
*/
|
|
16
|
+
export type TextureCompressionFormat =
|
|
17
|
+
| 'dxt'
|
|
18
|
+
| 'dxt-srgb'
|
|
19
|
+
| 'etc1'
|
|
20
|
+
| 'etc2'
|
|
21
|
+
| 'pvrtc'
|
|
22
|
+
| 'atc'
|
|
23
|
+
| 'astc'
|
|
24
|
+
| 'rgtc';
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
/** Names of cube texture faces */
|
|
27
|
+
export type TextureCubeFace = '+X' | '-X' | '+Y' | '-Y' | '+Z' | '-Z';
|
|
25
28
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
29
|
+
/**
|
|
30
|
+
* One mip level
|
|
31
|
+
* Basic data structure is similar to `ImageData`
|
|
32
|
+
* additional optional fields can describe compressed texture data.
|
|
33
|
+
*/
|
|
34
|
+
export type TextureLevelData = {
|
|
35
|
+
/** WebGPU style format string. Defaults to 'rgba8unorm' */
|
|
28
36
|
format?: TextureFormat;
|
|
29
|
-
|
|
30
|
-
width?: number | undefined;
|
|
31
|
-
height?: number | undefined;
|
|
32
|
-
depth?: number;
|
|
33
|
-
usage?: number;
|
|
34
|
-
|
|
35
|
-
data?: TextureData | Promise<TextureData> | CubeTextureData | string | HTMLVideoElement | null;
|
|
36
|
-
mipmaps?: boolean;
|
|
37
|
-
|
|
38
|
-
mipLevels?: number;
|
|
39
|
-
samples?: number;
|
|
40
|
-
type?: number;
|
|
41
|
-
compressed?: boolean;
|
|
42
|
-
|
|
43
|
-
sampler?: Sampler | SamplerProps;
|
|
44
|
-
view?: TextureViewProps;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type WebGPUTextureProps = ResourceProps & {
|
|
37
|
+
data: TypedArray;
|
|
48
38
|
width: number;
|
|
49
39
|
height: number;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
|
|
41
|
+
compressed?: boolean;
|
|
42
|
+
byteLength?: number;
|
|
43
|
+
hasAlpha?: boolean;
|
|
53
44
|
};
|
|
54
45
|
|
|
55
46
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
47
|
+
* Built-in data types that can be used to initialize textures
|
|
48
|
+
* @note ImageData can be used for 8 bit data via Uint8ClampedArray
|
|
58
49
|
*/
|
|
59
|
-
export type
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
50
|
+
export type ExternalImage =
|
|
51
|
+
| ImageBitmap
|
|
52
|
+
| ImageData
|
|
53
|
+
| HTMLImageElement
|
|
54
|
+
| HTMLVideoElement
|
|
55
|
+
| VideoFrame
|
|
56
|
+
| HTMLCanvasElement
|
|
57
|
+
| OffscreenCanvas;
|
|
58
|
+
|
|
59
|
+
export type TextureLevelSource = TextureLevelData | ExternalImage;
|
|
60
|
+
|
|
61
|
+
/** Texture data can be one or more mip levels */
|
|
62
|
+
export type TextureData = TextureLevelData | ExternalImage | (TextureLevelData | ExternalImage)[];
|
|
63
|
+
|
|
64
|
+
/** @todo - define what data type is supported for 1D textures */
|
|
65
|
+
export type Texture1DData = TypedArray | TextureLevelData;
|
|
66
|
+
|
|
67
|
+
/** Texture data can be one or more mip levels */
|
|
68
|
+
export type Texture2DData =
|
|
69
|
+
| TypedArray
|
|
70
|
+
| TextureLevelData
|
|
71
|
+
| ExternalImage
|
|
72
|
+
| (TextureLevelData | ExternalImage)[];
|
|
73
|
+
|
|
74
|
+
/** Array of textures */
|
|
75
|
+
export type Texture3DData = TypedArray | TextureData[];
|
|
76
|
+
|
|
77
|
+
/** 6 face textures */
|
|
78
|
+
export type TextureCubeData = Record<TextureCubeFace, Texture2DData>;
|
|
79
|
+
|
|
80
|
+
/** Array of textures */
|
|
81
|
+
export type TextureArrayData = TextureData[];
|
|
82
|
+
|
|
83
|
+
/** Array of 6 face textures */
|
|
84
|
+
export type TextureCubeArrayData = Record<TextureCubeFace, TextureData>[];
|
|
85
|
+
|
|
86
|
+
export type TextureDataProps =
|
|
87
|
+
| Texture1DProps
|
|
88
|
+
| Texture2DProps
|
|
89
|
+
| Texture3DProps
|
|
90
|
+
| TextureArrayProps
|
|
91
|
+
| TextureCubeProps
|
|
92
|
+
| TextureCubeArrayProps;
|
|
93
|
+
|
|
94
|
+
export type Texture1DProps = {dimension: '1d'; data?: Texture1DData | null};
|
|
95
|
+
export type Texture2DProps = {dimension?: '2d'; data?: Texture2DData | null};
|
|
96
|
+
export type Texture3DProps = {dimension: '3d'; data?: Texture3DData | null};
|
|
97
|
+
export type TextureArrayProps = {dimension: '2d-array'; data?: TextureArrayData | null};
|
|
98
|
+
export type TextureCubeProps = {dimension: 'cube'; data?: TextureCubeData | null};
|
|
99
|
+
export type TextureCubeArrayProps = {dimension: 'cube-array'; data: TextureCubeArrayData | null};
|
|
100
|
+
|
|
101
|
+
/** Texture properties */
|
|
102
|
+
export type TextureProps = ResourceProps &
|
|
103
|
+
TextureDataProps & {
|
|
104
|
+
format?: TextureFormat;
|
|
105
|
+
width?: number | undefined;
|
|
106
|
+
height?: number | undefined;
|
|
107
|
+
depth?: number;
|
|
108
|
+
usage?: number;
|
|
109
|
+
|
|
110
|
+
/** How many mip levels */
|
|
111
|
+
mipLevels?: number | 'pyramid';
|
|
112
|
+
/** Multi sampling */
|
|
113
|
+
samples?: number;
|
|
114
|
+
|
|
115
|
+
/** Specifying mipmaps will default mipLevels to 'pyramid' and attempt to generate mipmaps */
|
|
116
|
+
mipmaps?: boolean;
|
|
117
|
+
|
|
118
|
+
/** Sampler (or SamplerProps) for the default sampler for this texture. Used if no sampler provided. Note that other samplers can still be used. */
|
|
119
|
+
sampler?: Sampler | SamplerProps;
|
|
120
|
+
/** Props for the default TextureView for this texture. Note that other views can still be created and used. */
|
|
121
|
+
view?: TextureViewProps;
|
|
122
|
+
|
|
123
|
+
/** @deprecated - this is implicit from format */
|
|
124
|
+
compressed?: boolean;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** Options for Texture.copyExternalImage */
|
|
128
|
+
export type CopyExternalImageOptions = {
|
|
129
|
+
/** Image */
|
|
130
|
+
image: ExternalImage;
|
|
131
|
+
/** Copy from image x offset (default 0) */
|
|
132
|
+
sourceX?: number;
|
|
133
|
+
/** Copy from image y offset (default 0) */
|
|
134
|
+
sourceY?: number;
|
|
135
|
+
/** Copy area width (default 1) */
|
|
136
|
+
width?: number;
|
|
137
|
+
/** Copy area height (default 1) */
|
|
138
|
+
height?: number;
|
|
139
|
+
/** Copy depth (default 1) */
|
|
140
|
+
depth?: number;
|
|
141
|
+
/** Which mip-level to copy into (default 0) */
|
|
142
|
+
mipLevel?: number;
|
|
143
|
+
/** Start copying into offset x (default 0) */
|
|
144
|
+
x?: number;
|
|
145
|
+
/** Start copying into offset y (default 0) */
|
|
146
|
+
y?: number;
|
|
147
|
+
/** Start copying from depth layer z (default 0) */
|
|
148
|
+
z?: number;
|
|
149
|
+
/** When copying into depth stencil textures (default 'all') */
|
|
150
|
+
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
151
|
+
/** Specific color space of image data */
|
|
152
|
+
colorSpace?: 'srgb';
|
|
153
|
+
/** premultiplied */
|
|
154
|
+
premultipliedAlpha?: boolean;
|
|
74
155
|
};
|
|
75
156
|
|
|
76
157
|
/**
|
|
@@ -78,7 +159,15 @@ export type DeprecatedWebGLTextureProps = {
|
|
|
78
159
|
* Texture Object
|
|
79
160
|
* https://gpuweb.github.io/gpuweb/#gputexture
|
|
80
161
|
*/
|
|
81
|
-
export abstract class Texture
|
|
162
|
+
export abstract class Texture extends Resource<TextureProps> {
|
|
163
|
+
static COPY_SRC = 0x01;
|
|
164
|
+
static COPY_DST = 0x02;
|
|
165
|
+
static TEXTURE = 0x04;
|
|
166
|
+
static STORAGE = 0x08;
|
|
167
|
+
static RENDER_ATTACHMENT = 0x10;
|
|
168
|
+
|
|
169
|
+
static CubeFaces: TextureCubeFace[] = ['+X', '-X', '+Y', '-Y', '+Z', '-Z'];
|
|
170
|
+
|
|
82
171
|
static override defaultProps: Required<TextureProps> = {
|
|
83
172
|
...Resource.defaultProps,
|
|
84
173
|
data: null,
|
|
@@ -87,25 +176,15 @@ export abstract class Texture<Props extends TextureProps = TextureProps> extends
|
|
|
87
176
|
width: undefined!,
|
|
88
177
|
height: undefined!,
|
|
89
178
|
depth: 1,
|
|
90
|
-
mipmaps:
|
|
91
|
-
// type: undefined,
|
|
179
|
+
mipmaps: false,
|
|
92
180
|
compressed: false,
|
|
93
|
-
// mipLevels: 1,
|
|
94
181
|
usage: 0,
|
|
95
|
-
// usage: GPUTextureUsage.COPY_DST
|
|
96
182
|
mipLevels: undefined!,
|
|
97
183
|
samples: undefined!,
|
|
98
|
-
type: undefined!,
|
|
99
184
|
sampler: {},
|
|
100
185
|
view: undefined!
|
|
101
186
|
};
|
|
102
187
|
|
|
103
|
-
static COPY_SRC = 0x01;
|
|
104
|
-
static COPY_DST = 0x02;
|
|
105
|
-
static TEXTURE_BINDING = 0x04;
|
|
106
|
-
static STORAGE_BINDING = 0x08;
|
|
107
|
-
static RENDER_ATTACHMENT = 0x10;
|
|
108
|
-
|
|
109
188
|
override get [Symbol.toStringTag](): string {
|
|
110
189
|
return 'Texture';
|
|
111
190
|
}
|
|
@@ -119,34 +198,164 @@ export abstract class Texture<Props extends TextureProps = TextureProps> extends
|
|
|
119
198
|
/** height in pixels of this texture */
|
|
120
199
|
height: number;
|
|
121
200
|
/** depth of this texture */
|
|
122
|
-
|
|
201
|
+
depth: number;
|
|
202
|
+
/** mip levels in this texture */
|
|
203
|
+
mipLevels: number;
|
|
123
204
|
|
|
124
205
|
/** Default sampler for this texture */
|
|
125
206
|
abstract sampler: Sampler;
|
|
126
|
-
|
|
127
207
|
/** Default view for this texture */
|
|
128
208
|
abstract view: TextureView;
|
|
129
209
|
|
|
130
210
|
/** "Time" of last update. Monotonically increasing timestamp */
|
|
131
211
|
updateTimestamp: number;
|
|
132
212
|
|
|
213
|
+
/** Check if data is an external image */
|
|
214
|
+
static isExternalImage(data: unknown): data is ExternalImage {
|
|
215
|
+
return (
|
|
216
|
+
(typeof ImageData !== 'undefined' && data instanceof ImageData) ||
|
|
217
|
+
(typeof ImageBitmap !== 'undefined' && data instanceof ImageBitmap) ||
|
|
218
|
+
(typeof HTMLImageElement !== 'undefined' && data instanceof HTMLImageElement) ||
|
|
219
|
+
(typeof HTMLVideoElement !== 'undefined' && data instanceof HTMLVideoElement) ||
|
|
220
|
+
(typeof VideoFrame !== 'undefined' && data instanceof VideoFrame) ||
|
|
221
|
+
(typeof HTMLCanvasElement !== 'undefined' && data instanceof HTMLCanvasElement) ||
|
|
222
|
+
(typeof OffscreenCanvas !== 'undefined' && data instanceof OffscreenCanvas)
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Determine size (width and height) of provided image data */
|
|
227
|
+
static getExternalImageSize(data: ExternalImage): {width: number; height: number} {
|
|
228
|
+
if (
|
|
229
|
+
(typeof ImageData !== 'undefined' && data instanceof ImageData) ||
|
|
230
|
+
(typeof ImageBitmap !== 'undefined' && data instanceof ImageBitmap) ||
|
|
231
|
+
(typeof HTMLCanvasElement !== 'undefined' && data instanceof HTMLCanvasElement) ||
|
|
232
|
+
(typeof OffscreenCanvas !== 'undefined' && data instanceof OffscreenCanvas)
|
|
233
|
+
) {
|
|
234
|
+
return {width: data.width, height: data.height};
|
|
235
|
+
}
|
|
236
|
+
if (typeof HTMLImageElement !== 'undefined' && data instanceof HTMLImageElement) {
|
|
237
|
+
return {width: data.naturalWidth, height: data.naturalHeight};
|
|
238
|
+
}
|
|
239
|
+
if (typeof HTMLVideoElement !== 'undefined' && data instanceof HTMLVideoElement) {
|
|
240
|
+
return {width: data.videoWidth, height: data.videoHeight};
|
|
241
|
+
}
|
|
242
|
+
if (typeof VideoFrame !== 'undefined' && data instanceof VideoFrame) {
|
|
243
|
+
// TODO: is this the right choice for width and height?
|
|
244
|
+
return {width: data.displayWidth, height: data.displayHeight};
|
|
245
|
+
}
|
|
246
|
+
throw new Error('Unknown image type');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Check if texture data is a typed array */
|
|
250
|
+
static isTextureLevelData(data: TextureData): data is TextureLevelData {
|
|
251
|
+
const typedArray = (data as TextureLevelData)?.data;
|
|
252
|
+
return ArrayBuffer.isView(typedArray);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Get the size of the texture described by the provided TextureData */
|
|
256
|
+
static getTextureDataSize(
|
|
257
|
+
data: TextureData | TextureCubeData | TextureArrayData | TextureCubeArrayData | TypedArray
|
|
258
|
+
): {width: number; height: number} | null {
|
|
259
|
+
if (!data) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
if (ArrayBuffer.isView(data)) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
// Recurse into arrays (array of miplevels)
|
|
266
|
+
if (Array.isArray(data)) {
|
|
267
|
+
return Texture.getTextureDataSize(data[0]);
|
|
268
|
+
}
|
|
269
|
+
if (Texture.isExternalImage(data)) {
|
|
270
|
+
return Texture.getExternalImageSize(data);
|
|
271
|
+
}
|
|
272
|
+
if (data && typeof data === 'object' && data.constructor === Object) {
|
|
273
|
+
const textureDataArray = Object.values(data) as Texture2DData[];
|
|
274
|
+
const untypedData = textureDataArray[0] as any;
|
|
275
|
+
return {width: untypedData.width, height: untypedData.height};
|
|
276
|
+
}
|
|
277
|
+
throw new Error('texture size deduction failed');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Calculate the number of mip levels for a texture of width and height */
|
|
281
|
+
static getMipLevelCount(width: number, height: number): number {
|
|
282
|
+
return Math.floor(Math.log2(Math.max(width, height))) + 1;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Convert luma.gl cubemap face constants to depth index */
|
|
286
|
+
static getCubeFaceDepth(face: TextureCubeFace): number {
|
|
287
|
+
// prettier-ignore
|
|
288
|
+
switch (face) {
|
|
289
|
+
case '+X': return 0;
|
|
290
|
+
case '-X': return 1;
|
|
291
|
+
case '+Y': return 2;
|
|
292
|
+
case '-Y': return 3;
|
|
293
|
+
case '+Z': return 4;
|
|
294
|
+
case '-Z': return 5;
|
|
295
|
+
default: throw new Error(face);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
133
299
|
/** Do not use directly. Create with device.createTexture() */
|
|
134
|
-
constructor(
|
|
135
|
-
device
|
|
136
|
-
props: Props,
|
|
137
|
-
defaultProps = Texture.defaultProps as Required<Props>
|
|
138
|
-
) {
|
|
139
|
-
super(device, props, defaultProps);
|
|
300
|
+
constructor(device: Device, props: TextureProps) {
|
|
301
|
+
super(device, props, Texture.defaultProps);
|
|
140
302
|
this.dimension = this.props.dimension;
|
|
141
303
|
this.format = this.props.format;
|
|
304
|
+
|
|
305
|
+
// Size
|
|
142
306
|
this.width = this.props.width;
|
|
143
307
|
this.height = this.props.height;
|
|
144
308
|
this.depth = this.props.depth;
|
|
145
309
|
|
|
310
|
+
// Calculate size, if not provided
|
|
311
|
+
if (this.props.width === undefined || this.props.height === undefined) {
|
|
312
|
+
// @ts-ignore
|
|
313
|
+
const size = Texture.getTextureDataSize(this.props.data);
|
|
314
|
+
this.width = size?.width || 1;
|
|
315
|
+
this.height = size?.height || 1;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// mipLevels
|
|
319
|
+
|
|
320
|
+
// If mipmap generation is requested and mipLevels is not provided, initialize a full pyramid
|
|
321
|
+
if (this.props.mipmaps && this.props.mipLevels === undefined) {
|
|
322
|
+
this.props.mipLevels = 'pyramid';
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Auto-calculate the number of mip levels as a convenience
|
|
326
|
+
// TODO - Should we clamp to 1-getMipLevelCount?
|
|
327
|
+
this.mipLevels =
|
|
328
|
+
this.props.mipLevels === 'pyramid'
|
|
329
|
+
? Texture.getMipLevelCount(this.width, this.height)
|
|
330
|
+
: this.props.mipLevels || 1;
|
|
331
|
+
|
|
146
332
|
// TODO - perhaps this should be set on async write completion?
|
|
147
333
|
this.updateTimestamp = device.incrementTimestamp();
|
|
148
334
|
}
|
|
149
335
|
|
|
150
336
|
/** Create a texture view for this texture */
|
|
151
|
-
abstract createView(props
|
|
337
|
+
abstract createView(props: TextureViewProps): TextureView;
|
|
338
|
+
|
|
339
|
+
/** Set sampler props associated with this texture */
|
|
340
|
+
abstract setSampler(sampler?: Sampler | SamplerProps): void;
|
|
341
|
+
|
|
342
|
+
/** Copy external image data into the texture */
|
|
343
|
+
abstract copyExternalImage(options: CopyExternalImageOptions): {width: number; height: number};
|
|
344
|
+
|
|
345
|
+
/** Default options */
|
|
346
|
+
protected static defaultCopyExternalImageOptions: Required<CopyExternalImageOptions> = {
|
|
347
|
+
image: undefined!,
|
|
348
|
+
sourceX: 0,
|
|
349
|
+
sourceY: 0,
|
|
350
|
+
width: undefined!,
|
|
351
|
+
height: undefined!,
|
|
352
|
+
depth: 1,
|
|
353
|
+
mipLevel: 0,
|
|
354
|
+
x: 0,
|
|
355
|
+
y: 0,
|
|
356
|
+
z: 0,
|
|
357
|
+
aspect: 'all',
|
|
358
|
+
colorSpace: 'srgb',
|
|
359
|
+
premultipliedAlpha: false
|
|
360
|
+
};
|
|
152
361
|
}
|
|
@@ -35,7 +35,7 @@ export abstract class TransformFeedback extends Resource<TransformFeedbackProps>
|
|
|
35
35
|
return 'TransformFeedback';
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
constructor(device: Device, props
|
|
38
|
+
constructor(device: Device, props: TransformFeedbackProps) {
|
|
39
39
|
super(device, props, TransformFeedback.defaultProps);
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -6,7 +6,7 @@ import type {TypedArray} from '../../types';
|
|
|
6
6
|
import {
|
|
7
7
|
AttributeInfo,
|
|
8
8
|
getAttributeInfosByLocation
|
|
9
|
-
} from '
|
|
9
|
+
} from '../../adapter-utils/get-attribute-from-layouts';
|
|
10
10
|
import type {Device} from '../device';
|
|
11
11
|
import type {Buffer} from './buffer';
|
|
12
12
|
import type {RenderPass} from './render-pass';
|
|
@@ -49,9 +49,13 @@ export abstract class VertexArray extends Resource<VertexArrayProps> {
|
|
|
49
49
|
super(device, props, VertexArray.defaultProps);
|
|
50
50
|
this.maxVertexAttributes = device.limits.maxVertexAttributes;
|
|
51
51
|
this.attributes = new Array(this.maxVertexAttributes).fill(null);
|
|
52
|
+
const {shaderLayout, bufferLayout} = props.renderPipeline || {};
|
|
53
|
+
if (!shaderLayout || !bufferLayout) {
|
|
54
|
+
throw new Error('VertexArray');
|
|
55
|
+
}
|
|
52
56
|
this.attributeInfos = getAttributeInfosByLocation(
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
shaderLayout,
|
|
58
|
+
bufferLayout,
|
|
55
59
|
this.maxVertexAttributes
|
|
56
60
|
);
|
|
57
61
|
}
|