@luma.gl/engine 9.2.6 → 9.3.0-alpha.4
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/animation-loop/animation-loop.d.ts +3 -1
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +10 -4
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +3 -2
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.d.ts +2 -0
- package/dist/compute/swap.d.ts.map +1 -1
- package/dist/compute/swap.js +10 -5
- package/dist/compute/swap.js.map +1 -1
- package/dist/dist.dev.js +1251 -574
- package/dist/dist.min.js +216 -48
- package/dist/dynamic-texture/dynamic-texture.d.ts +95 -0
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -0
- package/dist/dynamic-texture/dynamic-texture.js +389 -0
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -0
- package/dist/dynamic-texture/mipmaps.d.ts +6 -0
- package/dist/dynamic-texture/mipmaps.d.ts.map +1 -0
- package/dist/dynamic-texture/mipmaps.js +441 -0
- package/dist/dynamic-texture/mipmaps.js.map +1 -0
- package/dist/dynamic-texture/texture-data.d.ts +137 -0
- package/dist/dynamic-texture/texture-data.d.ts.map +1 -0
- package/dist/dynamic-texture/texture-data.js +183 -0
- package/dist/dynamic-texture/texture-data.js.map +1 -0
- package/dist/factories/pipeline-factory.d.ts.map +1 -1
- package/dist/factories/pipeline-factory.js +3 -3
- package/dist/factories/pipeline-factory.js.map +1 -1
- package/dist/factories/shader-factory.d.ts.map +1 -1
- package/dist/factories/shader-factory.js +3 -2
- package/dist/factories/shader-factory.js.map +1 -1
- package/dist/index.cjs +1243 -583
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/model/model.d.ts +31 -10
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +34 -14
- package/dist/model/model.js.map +1 -1
- package/dist/models/billboard-texture-model.d.ts +8 -5
- package/dist/models/billboard-texture-model.d.ts.map +1 -1
- package/dist/models/billboard-texture-model.js +70 -18
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/passes/get-fragment-shader.js +15 -11
- package/dist/passes/get-fragment-shader.js.map +1 -1
- package/dist/passes/shader-pass-renderer.d.ts +5 -5
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +13 -12
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/buffer-layout-order.d.ts.map +1 -1
- package/dist/utils/buffer-layout-order.js +12 -2
- package/dist/utils/buffer-layout-order.js.map +1 -1
- package/package.json +6 -6
- package/src/animation-loop/animation-loop.ts +11 -4
- package/src/compute/computation.ts +3 -2
- package/src/compute/swap.ts +13 -7
- package/src/dynamic-texture/dynamic-texture.ts +499 -0
- package/src/dynamic-texture/mipmaps.ts +517 -0
- package/src/dynamic-texture/texture-data.ts +301 -0
- package/src/factories/pipeline-factory.ts +4 -3
- package/src/factories/shader-factory.ts +4 -2
- package/src/index.ts +9 -4
- package/src/model/model.ts +37 -18
- package/src/models/billboard-texture-model.ts +81 -22
- package/src/passes/get-fragment-shader.ts +15 -11
- package/src/passes/shader-pass-renderer.ts +22 -16
- package/src/types.ts +11 -0
- package/src/utils/buffer-layout-order.ts +18 -2
- package/dist/async-texture/async-texture.d.ts +0 -166
- package/dist/async-texture/async-texture.d.ts.map +0 -1
- package/dist/async-texture/async-texture.js +0 -386
- package/dist/async-texture/async-texture.js.map +0 -1
- package/src/async-texture/async-texture.ts +0 -551
- /package/src/{async-texture/texture-setters.ts.disabled → dynamic-texture/texture-data.ts.disabled} +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { TextureProps, SamplerProps, TextureView, Device } from '@luma.gl/core';
|
|
2
|
+
import { Texture, Sampler } from '@luma.gl/core';
|
|
3
|
+
import { type TextureCubeFace, type TextureDataAsyncProps, type Texture1DData, type Texture2DData, type Texture3DData, type TextureArrayData, type TextureCubeData } from "./texture-data.js";
|
|
4
|
+
/**
|
|
5
|
+
* Properties for a dynamic texture
|
|
6
|
+
*/
|
|
7
|
+
export type DynamicTextureProps = Omit<TextureProps, 'data' | 'mipLevels' | 'width' | 'height'> & TextureDataAsyncProps & {
|
|
8
|
+
/** Generate mipmaps after creating textures and setting data */
|
|
9
|
+
mipmaps?: boolean;
|
|
10
|
+
/** nipLevels can be set to 'auto' to generate max number of mipLevels */
|
|
11
|
+
mipLevels?: number | 'auto';
|
|
12
|
+
/** Width - can be auto-calculated when initializing from ExternalImage */
|
|
13
|
+
width?: number;
|
|
14
|
+
/** Height - can be auto-calculated when initializing from ExternalImage */
|
|
15
|
+
height?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Dynamic Textures
|
|
19
|
+
*
|
|
20
|
+
* - Mipmaps - DynamicTexture can generate mipmaps for textures (WebGPU does not provide built-in mipmap generation).
|
|
21
|
+
*
|
|
22
|
+
* - Texture initialization and updates - complex textures (2d array textures, cube textures, 3d textures) need multiple images
|
|
23
|
+
* `DynamicTexture` provides an API that makes it easy to provide the required data.
|
|
24
|
+
*
|
|
25
|
+
* - Texture resizing - Textures are immutable in WebGPU, meaning that they cannot be resized after creation.
|
|
26
|
+
* DynamicTexture provides a `resize()` method that internally creates a new texture with the same parameters
|
|
27
|
+
* but a different size.
|
|
28
|
+
*
|
|
29
|
+
* - Async image data initialization - It is often very convenient to be able to initialize textures with promises
|
|
30
|
+
* returned by image or data loading functions, as it allows a callback-free linear style of programming.
|
|
31
|
+
*
|
|
32
|
+
* @note GPU Textures are quite complex objects, with many subresources and modes of usage.
|
|
33
|
+
* The `DynamicTexture` class allows luma.gl to provide some support for working with textures
|
|
34
|
+
* without accumulating excessive complexity in the core Texture class which is designed as an immutable nature of GPU resource.
|
|
35
|
+
*/
|
|
36
|
+
export declare class DynamicTexture {
|
|
37
|
+
readonly device: Device;
|
|
38
|
+
readonly id: string;
|
|
39
|
+
/** Props with defaults resolved (except `data` which is processed separately) */
|
|
40
|
+
props: Readonly<Required<DynamicTextureProps>>;
|
|
41
|
+
/** Created resources */
|
|
42
|
+
private _texture;
|
|
43
|
+
private _sampler;
|
|
44
|
+
private _view;
|
|
45
|
+
/** Ready when GPU texture has been created and data (if any) uploaded */
|
|
46
|
+
readonly ready: Promise<Texture>;
|
|
47
|
+
isReady: boolean;
|
|
48
|
+
destroyed: boolean;
|
|
49
|
+
private resolveReady;
|
|
50
|
+
private rejectReady;
|
|
51
|
+
get texture(): Texture;
|
|
52
|
+
get sampler(): Sampler;
|
|
53
|
+
get view(): TextureView;
|
|
54
|
+
get [Symbol.toStringTag](): string;
|
|
55
|
+
toString(): string;
|
|
56
|
+
constructor(device: Device, props: DynamicTextureProps);
|
|
57
|
+
/** @note Fire and forget; caller can await `ready` */
|
|
58
|
+
initAsync(originalPropsWithAsyncData: TextureDataAsyncProps): Promise<void>;
|
|
59
|
+
destroy(): void;
|
|
60
|
+
generateMipmaps(): void;
|
|
61
|
+
/** Set sampler or create one from props */
|
|
62
|
+
setSampler(sampler?: Sampler | SamplerProps): void;
|
|
63
|
+
/**
|
|
64
|
+
* Resize by cloning the underlying immutable texture.
|
|
65
|
+
* Does not copy contents; caller may need to re-upload and/or regenerate mips.
|
|
66
|
+
*/
|
|
67
|
+
resize(size: {
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
}): boolean;
|
|
71
|
+
/** Convert cube face label to texture slice index. Index can be used with `setTexture2DData()`. */
|
|
72
|
+
getCubeFaceIndex(face: TextureCubeFace): number;
|
|
73
|
+
/** Convert cube face label to texture slice index. Index can be used with `setTexture2DData()`. */
|
|
74
|
+
getCubeArrayFaceIndex(cubeIndex: number, face: TextureCubeFace): number;
|
|
75
|
+
/** @note experimental: Set multiple mip levels (1D) */
|
|
76
|
+
setTexture1DData(data: Texture1DData): void;
|
|
77
|
+
/** @note experimental: Set multiple mip levels (2D), optionally at `z`, slice (depth/array level) index */
|
|
78
|
+
setTexture2DData(lodData: Texture2DData, z?: number): void;
|
|
79
|
+
/** 3D: multiple depth slices, each may carry multiple mip levels */
|
|
80
|
+
setTexture3DData(data: Texture3DData): void;
|
|
81
|
+
/** 2D array: multiple layers, each may carry multiple mip levels */
|
|
82
|
+
setTextureArrayData(data: TextureArrayData): void;
|
|
83
|
+
/** Cube: 6 faces, each may carry multiple mip levels */
|
|
84
|
+
setTextureCubeData(data: TextureCubeData): void;
|
|
85
|
+
/** Cube array: multiple cubes (faces×layers), each face may carry multiple mips */
|
|
86
|
+
private setTextureCubeArrayData;
|
|
87
|
+
/** Sets multiple mip levels on different `z` slices (depth/array index) */
|
|
88
|
+
private _setTextureSubresources;
|
|
89
|
+
/** Recursively resolve all promises in data structures */
|
|
90
|
+
private _loadAllData;
|
|
91
|
+
private _checkNotDestroyed;
|
|
92
|
+
private _checkReady;
|
|
93
|
+
static defaultProps: Required<DynamicTextureProps>;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=dynamic-texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-texture.d.ts","sourceRoot":"","sources":["../../src/dynamic-texture/dynamic-texture.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAEnF,OAAO,EAAC,OAAO,EAAE,OAAO,EAAM,MAAM,eAAe,CAAC;AAIpD,OAAO,EAEL,KAAK,eAAe,EAQpB,KAAK,qBAAqB,EAG1B,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAErB,KAAK,eA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,OAAO,IAAI,IAAI;IAUf,eAAe,IAAI,IAAI;IAUvB,2CAA2C;IAC3C,UAAU,CAAC,OAAO,GAAE,OAAO,GAAG,YAAiB,GAAG,IAAI;IAOtD;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO;IAgBtD,mGAAmG;IACnG,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM;IAM/C,mGAAmG;IACnG,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM;IAIvE,uDAAuD;IACvD,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAS3C,2GAA2G;IAC3G,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,CAAC,GAAE,MAAU,GAAG,IAAI;IAU7D,oEAAoE;IACpE,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAQ3C,oEAAoE;IACpE,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAQjD,wDAAwD;IACxD,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IAQ/C,mFAAmF;IACnF,OAAO,CAAC,uBAAuB;IAQ/B,2EAA2E;IAC3E,OAAO,CAAC,uBAAuB;IAqC/B,0DAA0D;YAC5C,YAAY;IAM1B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,WAAW;IAMnB,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAKhD;CACH"}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { Texture, Sampler, log } from '@luma.gl/core';
|
|
4
|
+
// import {loadImageBitmap} from '../application-utils/load-file';
|
|
5
|
+
import { uid } from "../utils/uid.js";
|
|
6
|
+
import { TEXTURE_CUBE_FACE_MAP,
|
|
7
|
+
// Helpers
|
|
8
|
+
getTextureSizeFromData, getTexture1DSubresources, getTexture2DSubresources, getTexture3DSubresources, getTextureCubeSubresources, getTextureArraySubresources, getTextureCubeArraySubresources } from "./texture-data.js";
|
|
9
|
+
import { generateMipmap } from "./mipmaps.js";
|
|
10
|
+
/**
|
|
11
|
+
* Dynamic Textures
|
|
12
|
+
*
|
|
13
|
+
* - Mipmaps - DynamicTexture can generate mipmaps for textures (WebGPU does not provide built-in mipmap generation).
|
|
14
|
+
*
|
|
15
|
+
* - Texture initialization and updates - complex textures (2d array textures, cube textures, 3d textures) need multiple images
|
|
16
|
+
* `DynamicTexture` provides an API that makes it easy to provide the required data.
|
|
17
|
+
*
|
|
18
|
+
* - Texture resizing - Textures are immutable in WebGPU, meaning that they cannot be resized after creation.
|
|
19
|
+
* DynamicTexture provides a `resize()` method that internally creates a new texture with the same parameters
|
|
20
|
+
* but a different size.
|
|
21
|
+
*
|
|
22
|
+
* - Async image data initialization - It is often very convenient to be able to initialize textures with promises
|
|
23
|
+
* returned by image or data loading functions, as it allows a callback-free linear style of programming.
|
|
24
|
+
*
|
|
25
|
+
* @note GPU Textures are quite complex objects, with many subresources and modes of usage.
|
|
26
|
+
* The `DynamicTexture` class allows luma.gl to provide some support for working with textures
|
|
27
|
+
* without accumulating excessive complexity in the core Texture class which is designed as an immutable nature of GPU resource.
|
|
28
|
+
*/
|
|
29
|
+
export class DynamicTexture {
|
|
30
|
+
device;
|
|
31
|
+
id;
|
|
32
|
+
/** Props with defaults resolved (except `data` which is processed separately) */
|
|
33
|
+
props;
|
|
34
|
+
/** Created resources */
|
|
35
|
+
_texture = null;
|
|
36
|
+
_sampler = null;
|
|
37
|
+
_view = null;
|
|
38
|
+
/** Ready when GPU texture has been created and data (if any) uploaded */
|
|
39
|
+
ready;
|
|
40
|
+
isReady = false;
|
|
41
|
+
destroyed = false;
|
|
42
|
+
resolveReady = () => { };
|
|
43
|
+
rejectReady = () => { };
|
|
44
|
+
get texture() {
|
|
45
|
+
if (!this._texture)
|
|
46
|
+
throw new Error('Texture not initialized yet');
|
|
47
|
+
return this._texture;
|
|
48
|
+
}
|
|
49
|
+
get sampler() {
|
|
50
|
+
if (!this._sampler)
|
|
51
|
+
throw new Error('Sampler not initialized yet');
|
|
52
|
+
return this._sampler;
|
|
53
|
+
}
|
|
54
|
+
get view() {
|
|
55
|
+
if (!this._view)
|
|
56
|
+
throw new Error('View not initialized yet');
|
|
57
|
+
return this._view;
|
|
58
|
+
}
|
|
59
|
+
get [Symbol.toStringTag]() {
|
|
60
|
+
return 'DynamicTexture';
|
|
61
|
+
}
|
|
62
|
+
toString() {
|
|
63
|
+
return `DynamicTexture:"${this.id}":${this.texture.width}x${this.texture.height}px:(${this.isReady ? 'ready' : 'loading...'})`;
|
|
64
|
+
}
|
|
65
|
+
constructor(device, props) {
|
|
66
|
+
this.device = device;
|
|
67
|
+
const id = uid('dynamic-texture');
|
|
68
|
+
// NOTE: We avoid holding on to data to make sure it can be garbage collected.
|
|
69
|
+
const originalPropsWithAsyncData = props;
|
|
70
|
+
this.props = { ...DynamicTexture.defaultProps, id, ...props, data: null };
|
|
71
|
+
this.id = this.props.id;
|
|
72
|
+
this.ready = new Promise((resolve, reject) => {
|
|
73
|
+
this.resolveReady = resolve;
|
|
74
|
+
this.rejectReady = reject;
|
|
75
|
+
});
|
|
76
|
+
this.initAsync(originalPropsWithAsyncData);
|
|
77
|
+
}
|
|
78
|
+
/** @note Fire and forget; caller can await `ready` */
|
|
79
|
+
async initAsync(originalPropsWithAsyncData) {
|
|
80
|
+
try {
|
|
81
|
+
// TODO - Accept URL string for 2D: turn into ExternalImage promise
|
|
82
|
+
// const dataProps =
|
|
83
|
+
// typeof props.data === 'string' && (props.dimension ?? '2d') === '2d'
|
|
84
|
+
// ? ({dimension: '2d', data: loadImageBitmap(props.data)} as const)
|
|
85
|
+
// : {};
|
|
86
|
+
const propsWithSyncData = await this._loadAllData(originalPropsWithAsyncData);
|
|
87
|
+
this._checkNotDestroyed();
|
|
88
|
+
// Deduce size when not explicitly provided
|
|
89
|
+
// TODO - what about depth?
|
|
90
|
+
const deduceSize = () => {
|
|
91
|
+
if (this.props.width && this.props.height) {
|
|
92
|
+
return { width: this.props.width, height: this.props.height };
|
|
93
|
+
}
|
|
94
|
+
const size = getTextureSizeFromData(propsWithSyncData);
|
|
95
|
+
if (size) {
|
|
96
|
+
return size;
|
|
97
|
+
}
|
|
98
|
+
return { width: this.props.width || 1, height: this.props.height || 1 };
|
|
99
|
+
};
|
|
100
|
+
const size = deduceSize();
|
|
101
|
+
if (!size || size.width <= 0 || size.height <= 0) {
|
|
102
|
+
throw new Error(`${this} size could not be determined or was zero`);
|
|
103
|
+
}
|
|
104
|
+
// Create a minimal TextureProps and validate via `satisfies`
|
|
105
|
+
const baseTextureProps = {
|
|
106
|
+
...this.props,
|
|
107
|
+
...size,
|
|
108
|
+
mipLevels: 1, // temporary; updated below
|
|
109
|
+
data: undefined
|
|
110
|
+
};
|
|
111
|
+
if (this.device.type === 'webgpu' && this.props.mipmaps) {
|
|
112
|
+
const requiredUsage = this.props.dimension === '3d'
|
|
113
|
+
? Texture.SAMPLE | Texture.STORAGE | Texture.COPY_DST | Texture.COPY_SRC
|
|
114
|
+
: Texture.SAMPLE | Texture.RENDER | Texture.COPY_DST | Texture.COPY_SRC;
|
|
115
|
+
baseTextureProps.usage |= requiredUsage;
|
|
116
|
+
}
|
|
117
|
+
// Compute mip levels (auto clamps to max)
|
|
118
|
+
const maxMips = this.device.getMipLevelCount(baseTextureProps.width, baseTextureProps.height);
|
|
119
|
+
const desired = this.props.mipLevels === 'auto'
|
|
120
|
+
? maxMips
|
|
121
|
+
: Math.max(1, Math.min(maxMips, this.props.mipLevels ?? 1));
|
|
122
|
+
const finalTextureProps = { ...baseTextureProps, mipLevels: desired };
|
|
123
|
+
this._texture = this.device.createTexture(finalTextureProps);
|
|
124
|
+
this._sampler = this.texture.sampler;
|
|
125
|
+
this._view = this.texture.view;
|
|
126
|
+
// Upload data if provided
|
|
127
|
+
if (propsWithSyncData.data) {
|
|
128
|
+
switch (propsWithSyncData.dimension) {
|
|
129
|
+
case '1d':
|
|
130
|
+
this.setTexture1DData(propsWithSyncData.data);
|
|
131
|
+
break;
|
|
132
|
+
case '2d':
|
|
133
|
+
this.setTexture2DData(propsWithSyncData.data);
|
|
134
|
+
break;
|
|
135
|
+
case '3d':
|
|
136
|
+
this.setTexture3DData(propsWithSyncData.data);
|
|
137
|
+
break;
|
|
138
|
+
case '2d-array':
|
|
139
|
+
this.setTextureArrayData(propsWithSyncData.data);
|
|
140
|
+
break;
|
|
141
|
+
case 'cube':
|
|
142
|
+
this.setTextureCubeData(propsWithSyncData.data);
|
|
143
|
+
break;
|
|
144
|
+
case 'cube-array':
|
|
145
|
+
this.setTextureCubeArrayData(propsWithSyncData.data);
|
|
146
|
+
break;
|
|
147
|
+
default: {
|
|
148
|
+
throw new Error(`Unhandled dimension ${propsWithSyncData.dimension}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (this.props.mipmaps) {
|
|
153
|
+
this.generateMipmaps();
|
|
154
|
+
}
|
|
155
|
+
this.isReady = true;
|
|
156
|
+
this.resolveReady(this.texture);
|
|
157
|
+
log.info(0, `${this} created`)();
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
const err = e instanceof Error ? e : new Error(String(e));
|
|
161
|
+
this.rejectReady(err);
|
|
162
|
+
throw err;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
destroy() {
|
|
166
|
+
if (this._texture) {
|
|
167
|
+
this._texture.destroy();
|
|
168
|
+
this._texture = null;
|
|
169
|
+
this._sampler = null;
|
|
170
|
+
this._view = null;
|
|
171
|
+
}
|
|
172
|
+
this.destroyed = true;
|
|
173
|
+
}
|
|
174
|
+
generateMipmaps() {
|
|
175
|
+
if (this.device.type === 'webgl') {
|
|
176
|
+
this.texture.generateMipmapsWebGL();
|
|
177
|
+
}
|
|
178
|
+
else if (this.device.type === 'webgpu') {
|
|
179
|
+
generateMipmap(this.device, this.texture);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
log.warn(`${this} mipmaps not supported on ${this.device.type}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/** Set sampler or create one from props */
|
|
186
|
+
setSampler(sampler = {}) {
|
|
187
|
+
this._checkReady();
|
|
188
|
+
const s = sampler instanceof Sampler ? sampler : this.device.createSampler(sampler);
|
|
189
|
+
this.texture.setSampler(s);
|
|
190
|
+
this._sampler = s;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Resize by cloning the underlying immutable texture.
|
|
194
|
+
* Does not copy contents; caller may need to re-upload and/or regenerate mips.
|
|
195
|
+
*/
|
|
196
|
+
resize(size) {
|
|
197
|
+
this._checkReady();
|
|
198
|
+
if (size.width === this.texture.width && size.height === this.texture.height) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
const prev = this.texture;
|
|
202
|
+
this._texture = prev.clone(size);
|
|
203
|
+
this._sampler = this.texture.sampler;
|
|
204
|
+
this._view = this.texture.view;
|
|
205
|
+
prev.destroy();
|
|
206
|
+
log.info(`${this} resized`);
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
/** Convert cube face label to texture slice index. Index can be used with `setTexture2DData()`. */
|
|
210
|
+
getCubeFaceIndex(face) {
|
|
211
|
+
const index = TEXTURE_CUBE_FACE_MAP[face];
|
|
212
|
+
if (index === undefined)
|
|
213
|
+
throw new Error(`Invalid cube face: ${face}`);
|
|
214
|
+
return index;
|
|
215
|
+
}
|
|
216
|
+
/** Convert cube face label to texture slice index. Index can be used with `setTexture2DData()`. */
|
|
217
|
+
getCubeArrayFaceIndex(cubeIndex, face) {
|
|
218
|
+
return 6 * cubeIndex + this.getCubeFaceIndex(face);
|
|
219
|
+
}
|
|
220
|
+
/** @note experimental: Set multiple mip levels (1D) */
|
|
221
|
+
setTexture1DData(data) {
|
|
222
|
+
this._checkReady();
|
|
223
|
+
if (this.texture.props.dimension !== '1d') {
|
|
224
|
+
throw new Error(`${this} is not 1d`);
|
|
225
|
+
}
|
|
226
|
+
const subresources = getTexture1DSubresources(data);
|
|
227
|
+
this._setTextureSubresources(subresources);
|
|
228
|
+
}
|
|
229
|
+
/** @note experimental: Set multiple mip levels (2D), optionally at `z`, slice (depth/array level) index */
|
|
230
|
+
setTexture2DData(lodData, z = 0) {
|
|
231
|
+
this._checkReady();
|
|
232
|
+
if (this.texture.props.dimension !== '2d') {
|
|
233
|
+
throw new Error(`${this} is not 2d`);
|
|
234
|
+
}
|
|
235
|
+
const subresources = getTexture2DSubresources(z, lodData);
|
|
236
|
+
this._setTextureSubresources(subresources);
|
|
237
|
+
}
|
|
238
|
+
/** 3D: multiple depth slices, each may carry multiple mip levels */
|
|
239
|
+
setTexture3DData(data) {
|
|
240
|
+
if (this.texture.props.dimension !== '3d') {
|
|
241
|
+
throw new Error(`${this} is not 3d`);
|
|
242
|
+
}
|
|
243
|
+
const subresources = getTexture3DSubresources(data);
|
|
244
|
+
this._setTextureSubresources(subresources);
|
|
245
|
+
}
|
|
246
|
+
/** 2D array: multiple layers, each may carry multiple mip levels */
|
|
247
|
+
setTextureArrayData(data) {
|
|
248
|
+
if (this.texture.props.dimension !== '2d-array') {
|
|
249
|
+
throw new Error(`${this} is not 2d-array`);
|
|
250
|
+
}
|
|
251
|
+
const subresources = getTextureArraySubresources(data);
|
|
252
|
+
this._setTextureSubresources(subresources);
|
|
253
|
+
}
|
|
254
|
+
/** Cube: 6 faces, each may carry multiple mip levels */
|
|
255
|
+
setTextureCubeData(data) {
|
|
256
|
+
if (this.texture.props.dimension !== 'cube') {
|
|
257
|
+
throw new Error(`${this} is not cube`);
|
|
258
|
+
}
|
|
259
|
+
const subresources = getTextureCubeSubresources(data);
|
|
260
|
+
this._setTextureSubresources(subresources);
|
|
261
|
+
}
|
|
262
|
+
/** Cube array: multiple cubes (faces×layers), each face may carry multiple mips */
|
|
263
|
+
setTextureCubeArrayData(data) {
|
|
264
|
+
if (this.texture.props.dimension !== 'cube-array') {
|
|
265
|
+
throw new Error(`${this} is not cube-array`);
|
|
266
|
+
}
|
|
267
|
+
const subresources = getTextureCubeArraySubresources(data);
|
|
268
|
+
this._setTextureSubresources(subresources);
|
|
269
|
+
}
|
|
270
|
+
/** Sets multiple mip levels on different `z` slices (depth/array index) */
|
|
271
|
+
_setTextureSubresources(subresources) {
|
|
272
|
+
// If user supplied multiple mip levels, warn if auto-mips also requested
|
|
273
|
+
// if (lodArray.length > 1 && this.props.mipmaps !== false) {
|
|
274
|
+
// log.warn(
|
|
275
|
+
// `Texture ${this.id}: provided multiple LODs and also requested mipmap generation.`
|
|
276
|
+
// )();
|
|
277
|
+
// }
|
|
278
|
+
for (const subresource of subresources) {
|
|
279
|
+
const { z, mipLevel } = subresource;
|
|
280
|
+
switch (subresource.type) {
|
|
281
|
+
case 'external-image':
|
|
282
|
+
const { image, flipY } = subresource;
|
|
283
|
+
this.texture.copyExternalImage({ image, z, mipLevel, flipY });
|
|
284
|
+
break;
|
|
285
|
+
case 'texture-data':
|
|
286
|
+
const { data } = subresource;
|
|
287
|
+
// TODO - we are throwing away some of the info in data.
|
|
288
|
+
// Did we not need it in the first place? Can we use it to validate?
|
|
289
|
+
this.texture.writeData(getAlignedUploadData(this.texture, data), {
|
|
290
|
+
x: 0,
|
|
291
|
+
y: 0,
|
|
292
|
+
z,
|
|
293
|
+
width: data.width,
|
|
294
|
+
height: data.height,
|
|
295
|
+
depthOrArrayLayers: 1,
|
|
296
|
+
mipLevel
|
|
297
|
+
});
|
|
298
|
+
break;
|
|
299
|
+
default:
|
|
300
|
+
throw new Error('Unsupported 2D mip-level payload');
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// ------------------ helpers ------------------
|
|
305
|
+
/** Recursively resolve all promises in data structures */
|
|
306
|
+
async _loadAllData(props) {
|
|
307
|
+
const syncData = await awaitAllPromises(props.data);
|
|
308
|
+
const dimension = (props.dimension ?? '2d');
|
|
309
|
+
return { dimension, data: syncData ?? null };
|
|
310
|
+
}
|
|
311
|
+
_checkNotDestroyed() {
|
|
312
|
+
if (this.destroyed) {
|
|
313
|
+
log.warn(`${this} already destroyed`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
_checkReady() {
|
|
317
|
+
if (!this.isReady) {
|
|
318
|
+
log.warn(`${this} Cannot perform this operation before ready`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
static defaultProps = {
|
|
322
|
+
...Texture.defaultProps,
|
|
323
|
+
dimension: '2d',
|
|
324
|
+
data: null,
|
|
325
|
+
mipmaps: false
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function getAlignedUploadData(texture, data) {
|
|
329
|
+
const { width, height, data: uploadData } = data;
|
|
330
|
+
const { bytesPerPixel } = texture.device.getTextureFormatInfo(texture.format);
|
|
331
|
+
const bytesPerRow = width * bytesPerPixel;
|
|
332
|
+
const alignedBytesPerRow = Math.ceil(bytesPerRow / texture.byteAlignment) * texture.byteAlignment;
|
|
333
|
+
if (alignedBytesPerRow === bytesPerRow) {
|
|
334
|
+
return uploadData;
|
|
335
|
+
}
|
|
336
|
+
const sourceBytes = new Uint8Array(uploadData.buffer, uploadData.byteOffset, uploadData.byteLength);
|
|
337
|
+
const paddedBytes = new Uint8Array(alignedBytesPerRow * height);
|
|
338
|
+
for (let row = 0; row < height; row++) {
|
|
339
|
+
const sourceOffset = row * bytesPerRow;
|
|
340
|
+
const destinationOffset = row * alignedBytesPerRow;
|
|
341
|
+
paddedBytes.set(sourceBytes.subarray(sourceOffset, sourceOffset + bytesPerRow), destinationOffset);
|
|
342
|
+
}
|
|
343
|
+
return paddedBytes;
|
|
344
|
+
}
|
|
345
|
+
// HELPERS
|
|
346
|
+
/** Resolve all promises in a nested data structure */
|
|
347
|
+
async function awaitAllPromises(x) {
|
|
348
|
+
x = await x;
|
|
349
|
+
if (Array.isArray(x)) {
|
|
350
|
+
return await Promise.all(x.map(awaitAllPromises));
|
|
351
|
+
}
|
|
352
|
+
if (x && typeof x === 'object' && x.constructor === Object) {
|
|
353
|
+
const object = x;
|
|
354
|
+
const values = await Promise.all(Object.values(object));
|
|
355
|
+
const keys = Object.keys(object);
|
|
356
|
+
const resolvedObject = {};
|
|
357
|
+
for (let i = 0; i < keys.length; i++) {
|
|
358
|
+
resolvedObject[keys[i]] = values[i];
|
|
359
|
+
}
|
|
360
|
+
return resolvedObject;
|
|
361
|
+
}
|
|
362
|
+
return x;
|
|
363
|
+
}
|
|
364
|
+
// /** @note experimental: Set multiple mip levels (2D), optionally at `z`, slice (depth/array level) index */
|
|
365
|
+
// setTexture2DData(lodData: Texture2DData, z: number = 0): void {
|
|
366
|
+
// this._checkReady();
|
|
367
|
+
// const lodArray = this._normalizeTexture2DData(lodData);
|
|
368
|
+
// // If user supplied multiple mip levels, warn if auto-mips also requested
|
|
369
|
+
// if (lodArray.length > 1 && this.props.mipmaps !== false) {
|
|
370
|
+
// log.warn(
|
|
371
|
+
// `Texture ${this.id}: provided multiple LODs and also requested mipmap generation.`
|
|
372
|
+
// )();
|
|
373
|
+
// }
|
|
374
|
+
// for (let mipLevel = 0; mipLevel < lodArray.length; mipLevel++) {
|
|
375
|
+
// const imageData = lodArray[mipLevel];
|
|
376
|
+
// if (this.device.isExternalImage(imageData)) {
|
|
377
|
+
// this.texture.copyExternalImage({image: imageData, z, mipLevel, flipY: true});
|
|
378
|
+
// } else if (this._isTextureImageData(imageData)) {
|
|
379
|
+
// this.texture.copyImageData({data: imageData.data, z, mipLevel});
|
|
380
|
+
// } else {
|
|
381
|
+
// throw new Error('Unsupported 2D mip-level payload');
|
|
382
|
+
// }
|
|
383
|
+
// }
|
|
384
|
+
// }
|
|
385
|
+
// /** Normalize 2D layer payload into an array of mip-level items */
|
|
386
|
+
// private _normalizeTexture2DData(data: Texture2DData): (TextureImageData | ExternalImage)[] {
|
|
387
|
+
// return Array.isArray(data) ? data : [data];
|
|
388
|
+
// }
|
|
389
|
+
//# sourceMappingURL=dynamic-texture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-texture.js","sourceRoot":"","sources":["../../src/dynamic-texture/dynamic-texture.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,oCAAoC;AAIpC,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,eAAe,CAAC;AAEpD,kEAAkE;AAClE,OAAO,EAAC,GAAG,EAAC,wBAAqB;AACjC,OAAO,EAGL,qBAAqB;AAkBrB,UAAU;AACV,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,EAChC,0BAAuB;AACxB,OAAO,EAAC,cAAc,EAAC,qBAAkB;AAiBzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,cAAc;IAChB,MAAM,CAAS;IACf,EAAE,CAAS;IAEpB,iFAAiF;IACjF,KAAK,CAA0C;IAE/C,wBAAwB;IAChB,QAAQ,GAAmB,IAAI,CAAC;IAChC,QAAQ,GAAmB,IAAI,CAAC;IAChC,KAAK,GAAuB,IAAI,CAAC;IAEzC,yEAAyE;IAChE,KAAK,CAAmB;IACjC,OAAO,GAAG,KAAK,CAAC;IAChB,SAAS,GAAG,KAAK,CAAC;IAEV,YAAY,GAAyB,GAAG,EAAE,GAAE,CAAC,CAAC;IAC9C,WAAW,GAA2B,GAAG,EAAE,GAAE,CAAC,CAAC;IAEvD,IAAI,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IACD,IAAI,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA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