@luma.gl/webgl 9.0.0-alpha.20 → 9.0.0-alpha.21
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/converters/device-parameters.js +1 -1
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/renderbuffer-formats.d.ts +2 -2
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +1 -1
- package/dist/adapter/converters/renderbuffer-formats.js +1 -2
- package/dist/adapter/converters/renderbuffer-formats.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +1 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +3 -3
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +2 -2
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +2 -2
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +6 -6
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +2 -2
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +1 -1
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +3 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +2 -2
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +16 -16
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +10 -10
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +2 -2
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +1 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -4
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +4 -4
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +2 -2
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts +2 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +3 -3
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +3 -3
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +3 -3
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +2 -2
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +9 -9
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +9 -9
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -1
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/buffer.d.ts +3 -3
- package/dist/classic/buffer.d.ts.map +1 -1
- package/dist/classic/buffer.js +4 -4
- package/dist/classic/buffer.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +1 -1
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +1 -1
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/dist.dev.js +5 -6
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +15 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist.min.js +21 -21
- package/package.json +4 -4
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
- package/src/adapter/converters/device-parameters.ts +1 -1
- package/src/adapter/converters/renderbuffer-formats.ts +1 -3
- package/src/adapter/helpers/get-shader-layout.ts +1 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +3 -3
- package/src/adapter/objects/webgl-resource.ts +2 -2
- package/src/adapter/objects/webgl-vertex-array-object.ts +6 -6
- package/src/adapter/resources/webgl-buffer.ts +2 -2
- package/src/adapter/resources/webgl-command-buffer.ts +3 -3
- package/src/adapter/resources/webgl-command-encoder.ts +3 -3
- package/src/adapter/resources/webgl-external-texture.ts +1 -1
- package/src/adapter/resources/webgl-framebuffer.ts +24 -24
- package/src/adapter/resources/webgl-render-pass.ts +2 -2
- package/src/adapter/resources/webgl-render-pipeline.ts +6 -6
- package/src/adapter/resources/webgl-sampler.ts +2 -2
- package/src/adapter/resources/webgl-shader.ts +2 -2
- package/src/adapter/resources/webgl-texture.ts +4 -4
- package/src/adapter/webgl-canvas-context.ts +3 -3
- package/src/adapter/webgl-device.ts +10 -10
- package/src/classic/accessor.ts +1 -1
- package/src/classic/buffer.ts +4 -4
- package/src/context/.DS_Store +0 -0
- package/src/context/parameters/unified-parameter-api.ts +1 -1
- package/src/context/state-tracker/with-parameters.ts +1 -1
- package/src/index.ts +18 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.21",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
|
-
"@luma.gl/api": "9.0.0-alpha.
|
|
48
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
47
|
+
"@luma.gl/api": "9.0.0-alpha.21",
|
|
48
|
+
"@luma.gl/constants": "9.0.0-alpha.21",
|
|
49
49
|
"@probe.gl/env": "^4.0.2"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "7ee95470a6a2f62753201beb0c36b00e37c70455"
|
|
52
52
|
}
|
package/src/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
@@ -3,7 +3,7 @@ import GL from '@luma.gl/constants';
|
|
|
3
3
|
import type { GLParameters } from '../../types/webgl';
|
|
4
4
|
import {pushContextState, popContextState} from '../../context/state-tracker/track-context-state';
|
|
5
5
|
import {setParameters} from '../../context/parameters/unified-parameter-api';
|
|
6
|
-
import WebGLDevice from '../webgl-device';
|
|
6
|
+
import {WebGLDevice} from '../webgl-device';
|
|
7
7
|
|
|
8
8
|
/* eslint-disable no-unused-expressions */ // For expression ? gl.enable() : gl.disable()
|
|
9
9
|
|
|
@@ -34,7 +34,7 @@ type RenderbufferFormat = {
|
|
|
34
34
|
ext?: string;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
|
|
37
|
+
export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
|
|
38
38
|
[GL.DEPTH_COMPONENT16]: {bpp: 2}, // 16 depth bits.
|
|
39
39
|
[GL.DEPTH_COMPONENT24]: {gl2: true, bpp: 3},
|
|
40
40
|
[GL.DEPTH_COMPONENT32F]: {gl2: true, bpp: 4},
|
|
@@ -88,5 +88,3 @@ const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
|
|
|
88
88
|
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, gl1: EXT_FLOAT_WEBGL1},
|
|
89
89
|
[GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4}
|
|
90
90
|
};
|
|
91
|
-
|
|
92
|
-
export default RENDERBUFFER_FORMATS;
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from '@luma.gl/api';
|
|
14
14
|
import GL from '@luma.gl/constants';
|
|
15
15
|
import {isWebGL2} from '../../context/context/webgl-checks';
|
|
16
|
-
import Accessor from '../../classic/accessor'; // TODO - should NOT depend on classic API
|
|
16
|
+
import {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API
|
|
17
17
|
import {decodeUniformType, decodeAttributeType} from './uniforms';
|
|
18
18
|
import {getVertexFormat} from '../converters/vertex-formats';
|
|
19
19
|
import {isSamplerUniform} from './uniforms';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-inline-comments */
|
|
2
2
|
import {assert, ResourceProps} from '@luma.gl/api';
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
|
-
import WebGLDevice from '../webgl-device';
|
|
5
|
-
import WebGLResource from './webgl-resource';
|
|
4
|
+
import {WebGLDevice} from '../webgl-device';
|
|
5
|
+
import {WebGLResource} from './webgl-resource';
|
|
6
6
|
import {
|
|
7
7
|
isRenderbufferFormatSupported, getRenderbufferFormatBytesPerPixel
|
|
8
8
|
} from '../converters/renderbuffer-formats';
|
|
@@ -34,7 +34,7 @@ const DEFAULT_RENDERBUFFER_PROPS: Required<RenderbufferProps> = {
|
|
|
34
34
|
* use Textures instead.
|
|
35
35
|
* Renderbuffer objects also natively accommodate Multisampling (MSAA).
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {
|
|
38
38
|
override get [Symbol.toStringTag](): string { return 'Renderbuffer'; }
|
|
39
39
|
|
|
40
40
|
get width(): number { return this.props.width; }
|
|
@@ -3,7 +3,7 @@ import {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/api';
|
|
|
3
3
|
import type {Device, ResourceProps} from '@luma.gl/api';
|
|
4
4
|
import GL from '@luma.gl/constants';
|
|
5
5
|
import {isWebGL2, assertWebGLContext} from '../../context/context/webgl-checks';
|
|
6
|
-
import WebGLDevice from '../webgl-device';
|
|
6
|
+
import {WebGLDevice} from '../webgl-device';
|
|
7
7
|
|
|
8
8
|
// Requires full GL enum to be bundled... Make these bindings dependent on dynamic import (debug)?
|
|
9
9
|
import {getKey, getKeyValue} from './constants-to-keys';
|
|
@@ -13,7 +13,7 @@ const ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual met
|
|
|
13
13
|
/**
|
|
14
14
|
* Base class for WebGL object wrappers
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {
|
|
17
17
|
readonly device: WebGLDevice;
|
|
18
18
|
readonly gl: WebGLRenderingContext;
|
|
19
19
|
readonly gl2: WebGL2RenderingContext;
|
|
@@ -2,10 +2,10 @@ import {assert, ResourceProps} from '@luma.gl/api';
|
|
|
2
2
|
import GL from '@luma.gl/constants';
|
|
3
3
|
import {getBrowser} from '@probe.gl/env';
|
|
4
4
|
|
|
5
|
-
import WebGLDevice from '../webgl-device';
|
|
6
|
-
import WebGLResource from './webgl-resource';
|
|
5
|
+
import {WebGLDevice} from '../webgl-device';
|
|
6
|
+
import {WebGLResource} from './webgl-resource';
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import {WEBGLBuffer} from '../resources/webgl-buffer';
|
|
9
9
|
|
|
10
10
|
const ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ export type VertexArrayObjectProps = ResourceProps & {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/** VertexArrayObject wrapper */
|
|
19
|
-
export
|
|
19
|
+
export class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {
|
|
20
20
|
override get [Symbol.toStringTag](): string {
|
|
21
21
|
return 'BaseVertexArrayObject';
|
|
22
22
|
}
|
|
@@ -43,7 +43,7 @@ export default class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObj
|
|
|
43
43
|
|
|
44
44
|
// Set (bind) an elements buffer, for indexed rendering.
|
|
45
45
|
// Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported
|
|
46
|
-
setElementBuffer(elementBuffer:
|
|
46
|
+
setElementBuffer(elementBuffer: WEBGLBuffer | null = null, opts = {}) {
|
|
47
47
|
assert(!elementBuffer || elementBuffer.target === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);
|
|
48
48
|
|
|
49
49
|
// The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...
|
|
@@ -55,7 +55,7 @@ export default class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObj
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
58
|
-
setBuffer(location: number, buffer:
|
|
58
|
+
setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): this {
|
|
59
59
|
// Check target
|
|
60
60
|
if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {
|
|
61
61
|
return this.setElementBuffer(buffer, accessor);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type {BufferProps} from '@luma.gl/api';
|
|
2
2
|
import {Buffer, assert} from '@luma.gl/api';
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
|
-
import WebGLDevice from '../webgl-device';
|
|
4
|
+
import {WebGLDevice} from '../webgl-device';
|
|
5
5
|
|
|
6
6
|
const DEBUG_DATA_LENGTH = 10;
|
|
7
7
|
|
|
8
8
|
/** WebGL Buffer interface */
|
|
9
|
-
export
|
|
9
|
+
export class WEBGLBuffer extends Buffer {
|
|
10
10
|
readonly device: WebGLDevice;
|
|
11
11
|
readonly gl: WebGLRenderingContext;
|
|
12
12
|
readonly gl2: WebGL2RenderingContext | null;
|
|
@@ -5,8 +5,8 @@ import type {
|
|
|
5
5
|
CopyTextureToTextureOptions
|
|
6
6
|
} from '@luma.gl/api';
|
|
7
7
|
import GL from '@luma.gl/constants';
|
|
8
|
-
import WebGLDevice from '../webgl-device';
|
|
9
|
-
import WEBGLBuffer from './webgl-buffer';
|
|
8
|
+
import {WebGLDevice} from '../webgl-device';
|
|
9
|
+
import {WEBGLBuffer} from './webgl-buffer';
|
|
10
10
|
|
|
11
11
|
function cast<T>(value: unknown): T {
|
|
12
12
|
return value as T;
|
|
@@ -38,7 +38,7 @@ type Command =
|
|
|
38
38
|
| CopyTextureToBufferCommand
|
|
39
39
|
| CopyTextureToTextureCommand;
|
|
40
40
|
|
|
41
|
-
export
|
|
41
|
+
export class CommandBuffer {
|
|
42
42
|
commands: Command[] = [];
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -6,10 +6,10 @@ import type {
|
|
|
6
6
|
CopyTextureToTextureOptions
|
|
7
7
|
} from '@luma.gl/api';
|
|
8
8
|
|
|
9
|
-
import CommandBuffer from './webgl-command-buffer';
|
|
10
|
-
import WebGLDevice from '../webgl-device';
|
|
9
|
+
import {CommandBuffer} from './webgl-command-buffer';
|
|
10
|
+
import {WebGLDevice} from '../webgl-device';
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export class WEBGLCommandEncoder extends CommandEncoder {
|
|
13
13
|
readonly device: WebGLDevice;
|
|
14
14
|
|
|
15
15
|
readonly commandBuffer = new CommandBuffer();
|
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
import type {FramebufferProps, ColorTextureFormat} from '@luma.gl/api';
|
|
4
4
|
import {Framebuffer, Texture, log, assert} from '@luma.gl/api';
|
|
5
5
|
import GL from '@luma.gl/constants';
|
|
6
|
-
import WebGLDevice from '../webgl-device';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import {WebGLDevice} from '../webgl-device';
|
|
7
|
+
import {WEBGLTexture} from './webgl-texture';
|
|
8
|
+
import {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';
|
|
9
9
|
import {getWebGLTextureFormat, getWebGLDepthStencilAttachment} from '../converters/texture-formats';
|
|
10
10
|
|
|
11
11
|
export type TextureAttachment = [Texture, number?, number?];
|
|
12
|
-
export type Attachment =
|
|
12
|
+
export type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;
|
|
13
13
|
|
|
14
14
|
/** luma.gl Framebuffer, WebGL implementation */
|
|
15
|
-
export
|
|
15
|
+
export class WEBGLFramebuffer extends Framebuffer {
|
|
16
16
|
device: WebGLDevice;
|
|
17
17
|
gl: WebGLRenderingContext;
|
|
18
18
|
handle: WebGLFramebuffer;
|
|
19
19
|
|
|
20
20
|
get texture() { return this.colorAttachments[0]; }
|
|
21
|
-
readonly colorAttachments:
|
|
22
|
-
readonly depthStencilAttachment:
|
|
23
|
-
protected _ownResources: (
|
|
21
|
+
readonly colorAttachments: WEBGLTexture[] = [];
|
|
22
|
+
readonly depthStencilAttachment: WEBGLTexture | null = null;
|
|
23
|
+
protected _ownResources: (WEBGLTexture | WEBGLRenderbuffer)[] = [];
|
|
24
24
|
|
|
25
25
|
constructor(device: WebGLDevice, props: FramebufferProps) {
|
|
26
26
|
super(device, props);
|
|
@@ -86,12 +86,12 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
_createColorAttachments():
|
|
89
|
+
_createColorAttachments(): WEBGLTexture[] {
|
|
90
90
|
return this.props.colorAttachments.map(colorAttachment => {
|
|
91
91
|
if (!colorAttachment) {
|
|
92
92
|
return undefined;
|
|
93
93
|
}
|
|
94
|
-
if (colorAttachment instanceof
|
|
94
|
+
if (colorAttachment instanceof WEBGLTexture) {
|
|
95
95
|
return colorAttachment;
|
|
96
96
|
}
|
|
97
97
|
// if (typeof colorAttachment === 'default') {
|
|
@@ -103,7 +103,7 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/** Create a color attachment */
|
|
106
|
-
protected _createColorAttachment(format: ColorTextureFormat, width: number, height: number):
|
|
106
|
+
protected _createColorAttachment(format: ColorTextureFormat, width: number, height: number): WEBGLTexture {
|
|
107
107
|
const texture = this.device._createTexture({
|
|
108
108
|
id: `${this.id}-color`,
|
|
109
109
|
data: null, // reserves texture memory, but texels are undefined
|
|
@@ -136,20 +136,20 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/** Create a depth stencil attachment GL.DEPTH24_STENCIL8 */
|
|
139
|
-
protected _createDepthStencilAttachment():
|
|
139
|
+
protected _createDepthStencilAttachment(): WEBGLRenderbuffer | WEBGLTexture {
|
|
140
140
|
if (!this.props.depthStencilAttachment) {
|
|
141
141
|
return undefined;
|
|
142
142
|
}
|
|
143
|
-
if (this.props.depthStencilAttachment instanceof
|
|
143
|
+
if (this.props.depthStencilAttachment instanceof WEBGLRenderbuffer) {
|
|
144
144
|
return this.props.depthStencilAttachment;
|
|
145
145
|
}
|
|
146
146
|
if (this.props.depthStencilAttachment instanceof Texture) {
|
|
147
|
-
return this.props.depthStencilAttachment as unknown as
|
|
147
|
+
return this.props.depthStencilAttachment as unknown as WEBGLTexture;
|
|
148
148
|
}
|
|
149
149
|
const format = this.props.depthStencilAttachment;
|
|
150
150
|
const webglFormat = getWebGLTextureFormat(this.gl, format);
|
|
151
151
|
|
|
152
|
-
const texture = new
|
|
152
|
+
const texture = new WEBGLRenderbuffer(this.device, {
|
|
153
153
|
id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?
|
|
154
154
|
format: webglFormat,
|
|
155
155
|
// dataFormat: GL.DEPTH_STENCIL,
|
|
@@ -189,22 +189,22 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/** Attach one attachment */
|
|
192
|
-
protected _attachOne(attachmentPoint: GL, attachment: Attachment):
|
|
193
|
-
if (attachment instanceof
|
|
194
|
-
this.
|
|
192
|
+
protected _attachOne(attachmentPoint: GL, attachment: Attachment): WEBGLTexture | WEBGLRenderbuffer {
|
|
193
|
+
if (attachment instanceof WEBGLRenderbuffer) {
|
|
194
|
+
this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
|
|
195
195
|
return attachment;
|
|
196
196
|
} else if (Array.isArray(attachment)) {
|
|
197
197
|
const [texture, layer = 0, level = 0] = attachment;
|
|
198
|
-
this._attachTexture(attachmentPoint, texture as unknown as
|
|
199
|
-
return texture as unknown as
|
|
200
|
-
} else if (attachment instanceof
|
|
198
|
+
this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);
|
|
199
|
+
return texture as unknown as WEBGLTexture;
|
|
200
|
+
} else if (attachment instanceof WEBGLTexture) {
|
|
201
201
|
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
202
202
|
return attachment;
|
|
203
203
|
}
|
|
204
204
|
throw new Error('attach');
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
protected
|
|
207
|
+
protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {
|
|
208
208
|
this.gl.framebufferRenderbuffer(
|
|
209
209
|
GL.FRAMEBUFFER,
|
|
210
210
|
attachment,
|
|
@@ -216,10 +216,10 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
216
216
|
/**
|
|
217
217
|
* @param attachment
|
|
218
218
|
* @param texture
|
|
219
|
-
* @param layer = 0 - index into
|
|
219
|
+
* @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`
|
|
220
220
|
* @param level = 0 - mipmapLevel (must be 0 in WebGL1)
|
|
221
221
|
*/
|
|
222
|
-
protected _attachTexture(attachment: GL, texture:
|
|
222
|
+
protected _attachTexture(attachment: GL, texture: WEBGLTexture, layer: number, level: number): void {
|
|
223
223
|
const {gl, gl2} = this.device;
|
|
224
224
|
gl.bindTexture(texture.target, texture.handle);
|
|
225
225
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {RenderPass, RenderPassProps} from '@luma.gl/api';
|
|
2
|
-
import WebGLDevice from '../webgl-device';
|
|
2
|
+
import {WebGLDevice} from '../webgl-device';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export class WEBGLRenderPass extends RenderPass {
|
|
5
5
|
readonly device: WebGLDevice;
|
|
6
6
|
|
|
7
7
|
constructor(device: WebGLDevice, props: RenderPassProps) {
|
|
@@ -17,16 +17,16 @@ import {withDeviceParameters, withGLParameters} from '../converters/device-param
|
|
|
17
17
|
import {setUniform} from '../helpers/set-uniform';
|
|
18
18
|
// import {copyUniform, checkUniformValues} from '../../classes/uniforms';
|
|
19
19
|
|
|
20
|
-
import WebGLDevice from '../webgl-device';
|
|
21
|
-
import WEBGLBuffer from './webgl-buffer';
|
|
22
|
-
import WEBGLShader from './webgl-shader';
|
|
23
|
-
import WEBGLTexture from './webgl-texture';
|
|
24
|
-
import WEBGLVertexArrayObject from '../objects/webgl-vertex-array-object';
|
|
20
|
+
import {WebGLDevice} from '../webgl-device';
|
|
21
|
+
import {WEBGLBuffer} from './webgl-buffer';
|
|
22
|
+
import {WEBGLShader} from './webgl-shader';
|
|
23
|
+
import {WEBGLTexture} from './webgl-texture';
|
|
24
|
+
import {WEBGLVertexArrayObject} from '../objects/webgl-vertex-array-object';
|
|
25
25
|
|
|
26
26
|
const LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
27
27
|
|
|
28
28
|
/** Creates a new render pipeline */
|
|
29
|
-
export
|
|
29
|
+
export class WEBGLRenderPipeline extends RenderPipeline {
|
|
30
30
|
device: WebGLDevice;
|
|
31
31
|
handle: WebGLProgram;
|
|
32
32
|
vs: WEBGLShader;
|
|
@@ -4,7 +4,7 @@ import {Sampler, SamplerProps} from '@luma.gl/api';
|
|
|
4
4
|
import GL from '@luma.gl/constants';
|
|
5
5
|
import type {GLSamplerParameters} from '../../types/webgl';
|
|
6
6
|
import {convertSamplerParametersToWebGL} from '../converters/sampler-parameters';
|
|
7
|
-
import type WebGLDevice from '../webgl-device';
|
|
7
|
+
import type {WebGLDevice} from '../webgl-device';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Sampler object -
|
|
@@ -13,7 +13,7 @@ import type WebGLDevice from '../webgl-device';
|
|
|
13
13
|
* so that they can be set directly on the texture
|
|
14
14
|
* https://github.com/WebGLSamples/WebGL2Samples/blob/master/samples/sampler_object.html
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export class WEBGLSampler extends Sampler {
|
|
17
17
|
readonly device: WebGLDevice;
|
|
18
18
|
readonly handle: WebGLSampler;
|
|
19
19
|
readonly parameters: GLSamplerParameters;
|
|
@@ -3,12 +3,12 @@ import {log, uid, Shader, ShaderProps, CompilerMessage, formatCompilerLog} from
|
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
4
|
import {getShaderInfo} from '../helpers/get-shader-info';
|
|
5
5
|
import {parseShaderCompilerLog} from '../helpers/parse-shader-compiler-log';
|
|
6
|
-
import WebGLDevice from '../webgl-device';
|
|
6
|
+
import {WebGLDevice} from '../webgl-device';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* An immutable compiled shader program that execute portions of the GPU Pipeline
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export class WEBGLShader extends Shader {
|
|
12
12
|
readonly device: WebGLDevice;
|
|
13
13
|
readonly handle: WebGLShader;
|
|
14
14
|
|
|
@@ -26,9 +26,9 @@ import {
|
|
|
26
26
|
convertSamplerParametersToWebGL,
|
|
27
27
|
updateSamplerParametersForNPOT
|
|
28
28
|
} from '../converters/sampler-parameters';
|
|
29
|
-
import WebGLDevice from '../webgl-device';
|
|
30
|
-
import WEBGLBuffer from './webgl-buffer';
|
|
31
|
-
import WEBGLSampler from './webgl-sampler';
|
|
29
|
+
import {WebGLDevice} from '../webgl-device';
|
|
30
|
+
import {WEBGLBuffer} from './webgl-buffer';
|
|
31
|
+
import {WEBGLSampler} from './webgl-sampler';
|
|
32
32
|
|
|
33
33
|
export type {TextureProps};
|
|
34
34
|
|
|
@@ -114,7 +114,7 @@ type SetImageData3DOptions = {
|
|
|
114
114
|
|
|
115
115
|
|
|
116
116
|
// Polyfill
|
|
117
|
-
export
|
|
117
|
+
export class WEBGLTexture extends Texture {
|
|
118
118
|
// TODO - remove?
|
|
119
119
|
static FACES: number[] = [
|
|
120
120
|
GL.TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// luma.gl, MIT license
|
|
2
2
|
import type {CanvasContextProps} from '@luma.gl/api';
|
|
3
3
|
import {CanvasContext} from '@luma.gl/api';
|
|
4
|
-
import WebGLDevice from './webgl-device';
|
|
5
|
-
import WEBGLFramebuffer from './resources/webgl-framebuffer';
|
|
4
|
+
import {WebGLDevice} from './webgl-device';
|
|
5
|
+
import {WEBGLFramebuffer} from './resources/webgl-framebuffer';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Holds a WebGL Canvas Context which will handle drawing buffer resizing etc
|
|
9
9
|
* @todo This class is WIP, intended to replace the old gltools-based context size tracking
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export class WebGLCanvasContext extends CanvasContext {
|
|
12
12
|
readonly device: WebGLDevice;
|
|
13
13
|
presentationSize: [number, number];
|
|
14
14
|
private _framebuffer: WEBGLFramebuffer | null = null;
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import {getDeviceInfo} from './device-helpers/get-device-info';
|
|
20
20
|
import {getDeviceFeatures} from './device-helpers/device-features';
|
|
21
21
|
import {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';
|
|
22
|
-
import WebGLCanvasContext from './webgl-canvas-context';
|
|
22
|
+
import {WebGLCanvasContext} from './webgl-canvas-context';
|
|
23
23
|
import {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';
|
|
24
24
|
import {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';
|
|
25
25
|
import {
|
|
@@ -48,19 +48,19 @@ import type {
|
|
|
48
48
|
ComputePassProps
|
|
49
49
|
} from '@luma.gl/api';
|
|
50
50
|
|
|
51
|
-
import ClassicBuffer from '../classic/buffer';
|
|
52
|
-
import WEBGLBuffer from './resources/webgl-buffer';
|
|
53
|
-
import WEBGLShader from './resources/webgl-shader';
|
|
54
|
-
import WEBGLSampler from './resources/webgl-sampler';
|
|
55
|
-
import WEBGLTexture from './resources/webgl-texture';
|
|
56
|
-
import WEBGLFramebuffer from './resources/webgl-framebuffer';
|
|
57
|
-
import WEBGLRenderPass from './resources/webgl-render-pass';
|
|
58
|
-
import WEBGLRenderPipeline from './resources/webgl-render-pipeline';
|
|
51
|
+
import {ClassicBuffer} from '../classic/buffer';
|
|
52
|
+
import {WEBGLBuffer} from './resources/webgl-buffer';
|
|
53
|
+
import {WEBGLShader} from './resources/webgl-shader';
|
|
54
|
+
import {WEBGLSampler} from './resources/webgl-sampler';
|
|
55
|
+
import {WEBGLTexture} from './resources/webgl-texture';
|
|
56
|
+
import {WEBGLFramebuffer} from './resources/webgl-framebuffer';
|
|
57
|
+
import {WEBGLRenderPass} from './resources/webgl-render-pass';
|
|
58
|
+
import {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';
|
|
59
59
|
|
|
60
60
|
const LOG_LEVEL = 1;
|
|
61
61
|
|
|
62
62
|
/** WebGPU style Device API for a WebGL context */
|
|
63
|
-
export
|
|
63
|
+
export class WebGLDevice extends Device {
|
|
64
64
|
//
|
|
65
65
|
// Public `Device` API
|
|
66
66
|
//
|
package/src/classic/accessor.ts
CHANGED
package/src/classic/buffer.ts
CHANGED
|
@@ -5,11 +5,11 @@ import {assert, checkProps} from '@luma.gl/api';
|
|
|
5
5
|
import GL from '@luma.gl/constants';
|
|
6
6
|
import {assertWebGL2Context} from '../context/context/webgl-checks';
|
|
7
7
|
import {AccessorObject} from '../types';
|
|
8
|
-
import Accessor from './accessor';
|
|
8
|
+
import {Accessor} from './accessor';
|
|
9
9
|
import {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';
|
|
10
10
|
|
|
11
|
-
import WebGLDevice from '../adapter/webgl-device';
|
|
12
|
-
import WEBGLBuffer from '../adapter/resources/webgl-buffer';
|
|
11
|
+
import {WebGLDevice} from '../adapter/webgl-device';
|
|
12
|
+
import {WEBGLBuffer} from '../adapter/resources/webgl-buffer';
|
|
13
13
|
|
|
14
14
|
const DEBUG_DATA_LENGTH = 10;
|
|
15
15
|
|
|
@@ -81,7 +81,7 @@ export type ClassicBufferProps = BufferProps & {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/** WebGL Buffer interface */
|
|
84
|
-
export
|
|
84
|
+
export class ClassicBuffer extends WEBGLBuffer {
|
|
85
85
|
usage: number;
|
|
86
86
|
accessor: Accessor;
|
|
87
87
|
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {Device} from '@luma.gl/api';
|
|
2
|
-
import {
|
|
2
|
+
import {WebGLDevice} from '../../adapter/webgl-device';
|
|
3
3
|
import {GLParameters, setParameters} from '../parameters/unified-parameter-api';
|
|
4
4
|
import {pushContextState, popContextState} from './track-context-state';
|
|
5
5
|
|
package/src/index.ts
CHANGED
|
@@ -10,34 +10,34 @@ export type {WebGLLimits} from './adapter/device-helpers/device-limits';
|
|
|
10
10
|
export {registerHeadlessGL} from './context/context/create-headless-context';
|
|
11
11
|
|
|
12
12
|
// WebGL adapter classes
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
13
|
+
export {WebGLDevice} from './adapter/webgl-device';
|
|
14
|
+
export {WebGLCanvasContext} from './adapter/webgl-canvas-context';
|
|
15
15
|
|
|
16
16
|
// WebGL Resource classes
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
// export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
17
|
+
export {WebGLResource, WebGLResource as WEBGLResource} from './adapter/objects/webgl-resource';
|
|
18
|
+
export {WEBGLBuffer} from './adapter/resources/webgl-buffer';
|
|
19
|
+
export {WEBGLTexture} from './adapter/resources/webgl-texture';
|
|
20
|
+
// export {WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';
|
|
21
|
+
export {WEBGLShader} from './adapter/resources/webgl-shader';
|
|
22
|
+
export {WEBGLSampler} from './adapter/resources/webgl-sampler';
|
|
23
|
+
export {WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';
|
|
24
24
|
|
|
25
|
-
export {
|
|
26
|
-
// export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
// export {
|
|
25
|
+
export {WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';
|
|
26
|
+
// export {WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';
|
|
27
|
+
export {WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';
|
|
28
|
+
export {WEBGLRenderPass} from './adapter/resources/webgl-render-pass';
|
|
29
|
+
// export {WEBGLComputePass} from './adapter/resources/webgl-compute-pass';
|
|
30
30
|
|
|
31
31
|
// non-api resources
|
|
32
32
|
export type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
33
|
+
export {WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';
|
|
34
|
+
export {WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';
|
|
35
35
|
|
|
36
36
|
// WebGL adapter classes (Legacy, will be moved to gltools)
|
|
37
|
-
export {
|
|
37
|
+
export {Accessor} from './classic/accessor';
|
|
38
38
|
export type {AccessorObject} from './types';
|
|
39
39
|
export type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';
|
|
40
|
-
export {
|
|
40
|
+
export {ClassicBuffer, ClassicBuffer as Buffer} from './classic/buffer';
|
|
41
41
|
|
|
42
42
|
export {
|
|
43
43
|
isWebGL,
|