@luma.gl/webgl 9.0.0-beta.3 → 9.0.0-beta.5
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 +240 -158
- package/dist/adapter/converters/sampler-parameters.d.ts +0 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +73 -68
- package/dist/adapter/converters/shader-formats.js +33 -46
- package/dist/adapter/converters/texture-formats.d.ts +9 -18
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +454 -871
- package/dist/adapter/converters/vertex-formats.js +52 -61
- package/dist/adapter/device-helpers/device-features.d.ts +2 -5
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +56 -87
- package/dist/adapter/device-helpers/device-limits.d.ts +2 -4
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +88 -83
- package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +79 -63
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +6 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.js +52 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +4 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +87 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +50 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +92 -0
- package/dist/adapter/helpers/decode-webgl-types.js +87 -76
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +261 -226
- package/dist/adapter/helpers/parse-shader-compiler-log.js +46 -37
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +67 -82
- package/dist/adapter/helpers/webgl-topology-utils.js +77 -93
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +18 -12
- package/dist/adapter/objects/webgl-renderbuffer.js +76 -80
- package/dist/adapter/objects/webgl-resource.d.ts +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +204 -154
- package/dist/adapter/resources/webgl-buffer.d.ts +2 -3
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +160 -119
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +268 -171
- package/dist/adapter/resources/webgl-command-encoder.js +32 -40
- package/dist/adapter/resources/webgl-external-texture.js +92 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +167 -139
- package/dist/adapter/resources/webgl-render-pass.js +121 -95
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +11 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +378 -228
- package/dist/adapter/resources/webgl-sampler.d.ts +0 -2
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +43 -34
- package/dist/adapter/resources/webgl-shader.d.ts +10 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +106 -45
- package/dist/adapter/resources/webgl-texture.d.ts +2 -6
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +614 -699
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +143 -145
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +229 -158
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +58 -37
- package/dist/adapter/webgl-device.d.ts +7 -15
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +440 -381
- package/dist/classic/accessor.js +132 -102
- package/dist/classic/clear.d.ts +2 -2
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +73 -73
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +176 -177
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.js +38 -32
- package/dist/classic/typed-array-utils.js +95 -81
- package/dist/context/{polyfill → context}/context-data.d.ts +2 -1
- package/dist/context/context/context-data.d.ts.map +1 -0
- package/dist/context/context/context-data.js +33 -0
- package/dist/context/context/create-browser-context.d.ts +1 -6
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +62 -49
- package/dist/context/debug/spector.js +54 -50
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +102 -76
- package/dist/context/parameters/unified-parameter-api.d.ts +3 -3
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +95 -46
- package/dist/context/parameters/webgl-parameter-tables.d.ts +110 -99
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +456 -404
- package/dist/context/state-tracker/deep-array-equal.js +18 -14
- package/dist/context/state-tracker/track-context-state.d.ts +4 -4
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +190 -126
- package/dist/context/state-tracker/with-parameters.d.ts +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +45 -29
- package/dist/dist.dev.js +2568 -3786
- package/dist/index.cjs +1346 -2464
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -26
- package/dist/types.js +2 -1
- package/dist.min.js +9 -42
- package/package.json +11 -15
- package/src/adapter/converters/device-parameters.ts +0 -1
- package/src/adapter/converters/sampler-parameters.ts +0 -17
- package/src/adapter/converters/texture-formats.ts +86 -154
- package/src/adapter/device-helpers/webgl-device-features.ts +69 -0
- package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +3 -4
- package/src/adapter/device-helpers/{device-limits.ts → webgl-device-limits.ts} +25 -23
- package/src/adapter/helpers/get-shader-layout.ts +17 -28
- package/src/adapter/helpers/set-uniform.ts +1 -3
- package/src/adapter/objects/constants-to-keys.ts +1 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +4 -4
- package/src/adapter/objects/webgl-resource.ts +3 -18
- package/src/adapter/resources/webgl-buffer.ts +6 -11
- package/src/adapter/resources/webgl-command-buffer.ts +20 -30
- package/src/adapter/resources/webgl-external-texture.ts +2 -3
- package/src/adapter/resources/webgl-framebuffer.ts +4 -5
- package/src/adapter/resources/webgl-render-pass.ts +7 -7
- package/src/adapter/resources/webgl-render-pipeline.ts +106 -31
- package/src/adapter/resources/webgl-sampler.ts +5 -9
- package/src/adapter/resources/webgl-shader.ts +57 -10
- package/src/adapter/resources/webgl-texture.ts +29 -103
- package/src/adapter/resources/webgl-transform-feedback.ts +14 -15
- package/src/adapter/resources/webgl-vertex-array.ts +16 -18
- package/src/adapter/webgl-canvas-context.ts +1 -7
- package/src/adapter/webgl-device.ts +18 -67
- package/src/classic/clear.ts +13 -14
- package/src/classic/copy-and-blit.ts +1 -2
- package/src/context/context/context-data.ts +44 -0
- package/src/context/context/create-browser-context.ts +7 -32
- package/src/context/debug/webgl-developer-tools.ts +6 -8
- package/src/context/parameters/unified-parameter-api.ts +3 -3
- package/src/context/parameters/webgl-parameter-tables.ts +66 -75
- package/src/context/state-tracker/track-context-state.ts +18 -17
- package/src/context/state-tracker/with-parameters.ts +1 -1
- package/src/index.ts +2 -17
- package/dist/adapter/converters/device-parameters.js.map +0 -1
- package/dist/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/adapter/converters/shader-formats.js.map +0 -1
- package/dist/adapter/converters/texture-formats.js.map +0 -1
- package/dist/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.d.ts +0 -2
- package/dist/adapter/device-helpers/is-old-ie.d.ts.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.js +0 -9
- package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +0 -1
- package/dist/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-transform-feedback.js.map +0 -1
- package/dist/adapter/resources/webgl-vertex-array.js.map +0 -1
- package/dist/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/adapter/webgl-device.js.map +0 -1
- package/dist/classic/accessor.js.map +0 -1
- package/dist/classic/clear.js.map +0 -1
- package/dist/classic/copy-and-blit.js.map +0 -1
- package/dist/classic/format-utils.js.map +0 -1
- package/dist/classic/typed-array-utils.js.map +0 -1
- package/dist/context/context/create-browser-context.js.map +0 -1
- package/dist/context/context/create-headless-context.d.ts +0 -9
- package/dist/context/context/create-headless-context.d.ts.map +0 -1
- package/dist/context/context/create-headless-context.js +0 -42
- package/dist/context/context/create-headless-context.js.map +0 -1
- package/dist/context/context/webgl-checks.d.ts +0 -13
- package/dist/context/context/webgl-checks.d.ts.map +0 -1
- package/dist/context/context/webgl-checks.js +0 -31
- package/dist/context/context/webgl-checks.js.map +0 -1
- package/dist/context/debug/spector.js.map +0 -1
- package/dist/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/context/polyfill/context-data.d.ts.map +0 -1
- package/dist/context/polyfill/context-data.js +0 -12
- package/dist/context/polyfill/context-data.js.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +0 -2
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +0 -85
- package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/context/polyfill/polyfill-context.d.ts +0 -5
- package/dist/context/polyfill/polyfill-context.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-context.js +0 -87
- package/dist/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/context/polyfill/polyfill-table.d.ts +0 -48
- package/dist/context/polyfill/polyfill-table.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-table.js +0 -137
- package/dist/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +0 -2
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -265
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/adapter/device-helpers/device-features.ts +0 -161
- package/src/adapter/device-helpers/is-old-ie.ts +0 -14
- package/src/context/context/create-headless-context.ts +0 -51
- package/src/context/context/webgl-checks.ts +0 -51
- package/src/context/polyfill/context-data.ts +0 -30
- package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
- package/src/context/polyfill/polyfill-context.ts +0 -104
- package/src/context/polyfill/polyfill-table.ts +0 -167
- package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
|
@@ -1,183 +1,265 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
1
3
|
import { log, isObjectEmpty } from '@luma.gl/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { GL } from '@luma.gl/constants';
|
|
5
|
+
import { pushContextState, popContextState } from '../../context/state-tracker/track-context-state';
|
|
6
|
+
import { setGLParameters } from '../../context/parameters/unified-parameter-api';
|
|
7
|
+
import { WebGLDevice } from '../webgl-device';
|
|
8
|
+
/* eslint-disable no-unused-expressions */ // For expression ? gl.enable() : gl.disable()
|
|
9
|
+
/**
|
|
10
|
+
* Execute a function with a set of temporary WebGL parameter overrides
|
|
11
|
+
* - Saves current "global" WebGL context settings
|
|
12
|
+
* - Sets the supplies WebGL context parameters,
|
|
13
|
+
* - Executes supplied function
|
|
14
|
+
* - Restores parameters
|
|
15
|
+
* - Returns the return value of the supplied function
|
|
16
|
+
*/
|
|
5
17
|
export function withDeviceAndGLParameters(device, parameters, glParameters, func) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
if (isObjectEmpty(parameters)) {
|
|
19
|
+
// Avoid setting state if no parameters provided. Just call and return
|
|
20
|
+
return func(device);
|
|
21
|
+
}
|
|
22
|
+
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
pushContextState(device.gl);
|
|
25
|
+
try {
|
|
26
|
+
setDeviceParameters(device, parameters);
|
|
27
|
+
setGLParameters(device, glParameters);
|
|
28
|
+
return func(device);
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
popContextState(device.gl);
|
|
33
|
+
}
|
|
17
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Execute a function with a set of temporary WebGL parameter overrides
|
|
37
|
+
* - Saves current "global" WebGL context settings
|
|
38
|
+
* - Sets the supplies WebGL context parameters,
|
|
39
|
+
* - Executes supplied function
|
|
40
|
+
* - Restores parameters
|
|
41
|
+
* - Returns the return value of the supplied function
|
|
42
|
+
* @deprecated use withDeviceParameters instead
|
|
43
|
+
*/
|
|
18
44
|
export function withGLParameters(device, parameters, func) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
if (isObjectEmpty(parameters)) {
|
|
46
|
+
// Avoid setting state if no parameters provided. Just call and return
|
|
47
|
+
return func(device);
|
|
48
|
+
}
|
|
49
|
+
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
50
|
+
// @ts-expect-error
|
|
51
|
+
pushContextState(device.gl);
|
|
52
|
+
try {
|
|
53
|
+
setGLParameters(device, parameters);
|
|
54
|
+
return func(device);
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
popContextState(device.gl);
|
|
59
|
+
}
|
|
29
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Execute a function with a set of temporary WebGL parameter overrides
|
|
63
|
+
* - Saves current "global" WebGL context settings
|
|
64
|
+
* - Sets the supplies WebGL context parameters,
|
|
65
|
+
* - Executes supplied function
|
|
66
|
+
* - Restores parameters
|
|
67
|
+
* - Returns the return value of the supplied function
|
|
68
|
+
*/
|
|
30
69
|
export function withDeviceParameters(device, parameters, func) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
70
|
+
if (isObjectEmpty(parameters)) {
|
|
71
|
+
// Avoid setting state if no parameters provided. Just call and return
|
|
72
|
+
return func(device);
|
|
73
|
+
}
|
|
74
|
+
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
75
|
+
// @ts-expect-error
|
|
76
|
+
pushContextState(device.gl);
|
|
77
|
+
try {
|
|
78
|
+
setDeviceParameters(device, parameters);
|
|
79
|
+
return func(device);
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
// @ts-expect-error
|
|
83
|
+
popContextState(device.gl);
|
|
84
|
+
}
|
|
41
85
|
}
|
|
86
|
+
/** Set WebGPU Style Parameters */
|
|
42
87
|
export function setDeviceParameters(device, parameters) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
88
|
+
const webglDevice = WebGLDevice.attach(device);
|
|
89
|
+
const { gl } = webglDevice;
|
|
90
|
+
// RASTERIZATION SETTINGS
|
|
91
|
+
if (parameters.cullMode) {
|
|
92
|
+
switch (parameters.cullMode) {
|
|
93
|
+
case 'none':
|
|
94
|
+
gl.disable(GL.CULL_FACE);
|
|
95
|
+
break;
|
|
96
|
+
case 'front':
|
|
97
|
+
gl.enable(GL.CULL_FACE);
|
|
98
|
+
gl.cullFace(GL.FRONT);
|
|
99
|
+
break;
|
|
100
|
+
case 'back':
|
|
101
|
+
gl.enable(GL.CULL_FACE);
|
|
102
|
+
gl.cullFace(GL.BACK);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (parameters.frontFace) {
|
|
107
|
+
gl.frontFace(map('frontFace', parameters.frontFace, {
|
|
108
|
+
ccw: GL.CCW,
|
|
109
|
+
cw: GL.CW
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
if (parameters.depthBias !== undefined) {
|
|
113
|
+
gl.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);
|
|
114
|
+
}
|
|
115
|
+
// depthBiasSlopeScale: {
|
|
116
|
+
// // Handled by depthBias
|
|
117
|
+
// },
|
|
118
|
+
// DEPTH STENCIL
|
|
119
|
+
if (parameters.depthWriteEnabled !== undefined) {
|
|
120
|
+
gl.depthMask(mapBoolean('depthWriteEnabled', parameters.depthWriteEnabled));
|
|
121
|
+
}
|
|
122
|
+
if (parameters.depthCompare) {
|
|
123
|
+
parameters.depthCompare !== 'always' ? gl.enable(GL.DEPTH_TEST) : gl.disable(GL.DEPTH_TEST);
|
|
124
|
+
gl.depthFunc(convertCompareFunction('depthCompare', parameters.depthCompare));
|
|
125
|
+
}
|
|
126
|
+
if (parameters.stencilWriteMask) {
|
|
127
|
+
const mask = parameters.stencilWriteMask;
|
|
128
|
+
gl.stencilMaskSeparate(GL.FRONT, mask);
|
|
129
|
+
gl.stencilMaskSeparate(GL.BACK, mask);
|
|
130
|
+
}
|
|
131
|
+
if (parameters.stencilReadMask) {
|
|
132
|
+
// stencilReadMask is handle inside stencil***Compare.
|
|
133
|
+
log.warn('stencilReadMask not supported under WebGL');
|
|
134
|
+
}
|
|
135
|
+
if (parameters.stencilCompare) {
|
|
136
|
+
const mask = parameters.stencilReadMask || 0xffffffff;
|
|
137
|
+
const glValue = convertCompareFunction('depthCompare', parameters.stencilCompare);
|
|
138
|
+
// TODO - ensure back doesn't overwrite
|
|
139
|
+
parameters.stencilCompare !== 'always'
|
|
140
|
+
? gl.enable(GL.STENCIL_TEST)
|
|
141
|
+
: gl.disable(GL.STENCIL_TEST);
|
|
142
|
+
gl.stencilFuncSeparate(GL.FRONT, glValue, 0, mask);
|
|
143
|
+
gl.stencilFuncSeparate(GL.BACK, glValue, 0, mask);
|
|
144
|
+
}
|
|
145
|
+
if (parameters.stencilPassOperation &&
|
|
146
|
+
parameters.stencilFailOperation &&
|
|
147
|
+
parameters.stencilDepthFailOperation) {
|
|
148
|
+
const dppass = convertStencilOperation('stencilPassOperation', parameters.stencilPassOperation);
|
|
149
|
+
const sfail = convertStencilOperation('stencilFailOperation', parameters.stencilFailOperation);
|
|
150
|
+
const dpfail = convertStencilOperation('stencilDepthFailOperation', parameters.stencilDepthFailOperation);
|
|
151
|
+
gl.stencilOpSeparate(GL.FRONT, sfail, dpfail, dppass);
|
|
152
|
+
gl.stencilOpSeparate(GL.BACK, sfail, dpfail, dppass);
|
|
153
|
+
}
|
|
154
|
+
// stencilDepthFailOperation() {
|
|
155
|
+
// // handled by stencilPassOperation
|
|
156
|
+
// },
|
|
157
|
+
// stencilFailOperation() {
|
|
158
|
+
// // handled by stencilPassOperation
|
|
159
|
+
// },
|
|
160
|
+
// COLOR STATE
|
|
161
|
+
if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
|
|
162
|
+
gl.enable(GL.BLEND);
|
|
163
|
+
const colorEquation = convertBlendOperationToEquation('blendColorOperation', parameters.blendColorOperation || 'add');
|
|
164
|
+
const alphaEquation = convertBlendOperationToEquation('blendAlphaOperation', parameters.blendAlphaOperation || 'add');
|
|
165
|
+
gl.blendEquationSeparate(colorEquation, alphaEquation);
|
|
166
|
+
const colorSrcFactor = convertBlendFactorToFunction('blendColorSrcFactor', parameters.blendColorSrcFactor || 'one');
|
|
167
|
+
const colorDstFactor = convertBlendFactorToFunction('blendColorDstFactor', parameters.blendColorDstFactor || 'zero');
|
|
168
|
+
const alphaSrcFactor = convertBlendFactorToFunction('blendAlphaSrcFactor', parameters.blendAlphaSrcFactor || 'one');
|
|
169
|
+
const alphaDstFactor = convertBlendFactorToFunction('blendAlphaDstFactor', parameters.blendAlphaDstFactor || 'zero');
|
|
170
|
+
gl.blendFuncSeparate(colorSrcFactor, colorDstFactor, alphaSrcFactor, alphaDstFactor);
|
|
171
|
+
}
|
|
111
172
|
}
|
|
173
|
+
/*
|
|
174
|
+
rasterizationState: {
|
|
175
|
+
cullMode: "back",
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
depthStencilState: {
|
|
179
|
+
depthWriteEnabled: true,
|
|
180
|
+
depthCompare: "less",
|
|
181
|
+
format: "depth24plus-stencil8",
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
colorStates: [
|
|
185
|
+
{
|
|
186
|
+
format: "bgra8unorm",
|
|
187
|
+
// colorBlend.srcFactor = wgpu::BlendFactor::SrcAlpha;
|
|
188
|
+
// colorBlend.dstFactor = wgpu::BlendFactor::OneMinusSrcAlpha;
|
|
189
|
+
// alphaBlend.srcFactor = wgpu::BlendFactor::SrcAlpha;
|
|
190
|
+
// alphaBlend.dstFactor = wgpu::BlendFactor::OneMinusSrcAlpha;
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
});
|
|
194
|
+
*/
|
|
112
195
|
export function convertCompareFunction(parameter, value) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
196
|
+
return map(parameter, value, {
|
|
197
|
+
never: GL.NEVER,
|
|
198
|
+
less: GL.LESS,
|
|
199
|
+
equal: GL.EQUAL,
|
|
200
|
+
'less-equal': GL.LEQUAL,
|
|
201
|
+
greater: GL.GREATER,
|
|
202
|
+
'not-equal': GL.NOTEQUAL,
|
|
203
|
+
'greater-equal': GL.GEQUAL,
|
|
204
|
+
always: GL.ALWAYS
|
|
205
|
+
});
|
|
123
206
|
}
|
|
124
207
|
export function convertToCompareFunction(parameter, value) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
208
|
+
return map(parameter, value, {
|
|
209
|
+
[GL.NEVER]: 'never',
|
|
210
|
+
[GL.LESS]: 'less',
|
|
211
|
+
[GL.EQUAL]: 'equal',
|
|
212
|
+
[GL.LEQUAL]: 'less-equal',
|
|
213
|
+
[GL.GREATER]: 'greater',
|
|
214
|
+
[GL.NOTEQUAL]: 'not-equal',
|
|
215
|
+
[GL.GEQUAL]: 'greater-equal',
|
|
216
|
+
[GL.ALWAYS]: 'always'
|
|
217
|
+
});
|
|
135
218
|
}
|
|
136
219
|
function convertStencilOperation(parameter, value) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
220
|
+
return map(parameter, value, {
|
|
221
|
+
keep: GL.KEEP,
|
|
222
|
+
zero: GL.ZERO,
|
|
223
|
+
replace: GL.REPLACE,
|
|
224
|
+
invert: GL.INVERT,
|
|
225
|
+
'increment-clamp': GL.INCR,
|
|
226
|
+
'decrement-clamp': GL.DECR,
|
|
227
|
+
'increment-wrap': GL.INCR_WRAP,
|
|
228
|
+
'decrement-wrap': GL.DECR_WRAP
|
|
229
|
+
});
|
|
147
230
|
}
|
|
148
231
|
function convertBlendOperationToEquation(parameter, value) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
232
|
+
return map(parameter, value, {
|
|
233
|
+
'add': GL.FUNC_ADD,
|
|
234
|
+
'subtract': GL.FUNC_SUBTRACT,
|
|
235
|
+
'reverse-subtract': GL.FUNC_REVERSE_SUBTRACT,
|
|
236
|
+
'min': GL.MIN,
|
|
237
|
+
'max': GL.MAX
|
|
238
|
+
});
|
|
156
239
|
}
|
|
157
240
|
function convertBlendFactorToFunction(parameter, value) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
241
|
+
return map(parameter, value, {
|
|
242
|
+
'one': GL.ONE,
|
|
243
|
+
'zero': GL.ZERO,
|
|
244
|
+
'src-color': GL.SRC_COLOR,
|
|
245
|
+
'one-minus-src-color': GL.ONE_MINUS_SRC_COLOR,
|
|
246
|
+
'dst-color': GL.DST_COLOR,
|
|
247
|
+
'one-minus-dst-color': GL.ONE_MINUS_DST_COLOR,
|
|
248
|
+
'src-alpha': GL.SRC_ALPHA,
|
|
249
|
+
'one-minus-src-alpha': GL.ONE_MINUS_SRC_ALPHA,
|
|
250
|
+
'dst-alpha': GL.DST_ALPHA,
|
|
251
|
+
'one-minus-dst-alpha': GL.ONE_MINUS_DST_ALPHA,
|
|
252
|
+
});
|
|
170
253
|
}
|
|
171
254
|
function message(parameter, value) {
|
|
172
|
-
|
|
255
|
+
return `Illegal parameter ${value} for ${parameter}`;
|
|
173
256
|
}
|
|
174
257
|
function map(parameter, value, valueMap) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
258
|
+
if (!(value in valueMap)) {
|
|
259
|
+
throw new Error(message(parameter, value));
|
|
260
|
+
}
|
|
261
|
+
return valueMap[value];
|
|
179
262
|
}
|
|
180
263
|
function mapBoolean(parameter, value) {
|
|
181
|
-
|
|
264
|
+
return value;
|
|
182
265
|
}
|
|
183
|
-
//# sourceMappingURL=device-parameters.js.map
|
|
@@ -6,8 +6,4 @@ import { GLSamplerParameters } from '@luma.gl/constants';
|
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
8
|
export declare function convertSamplerParametersToWebGL(props: SamplerProps): GLSamplerParameters;
|
|
9
|
-
/**
|
|
10
|
-
* Override sampler settings that are not supported by Non-Power-of-Two textures in WebGL1.
|
|
11
|
-
*/
|
|
12
|
-
export declare function updateSamplerParametersForNPOT(parameters: GLSamplerParameters): GLSamplerParameters;
|
|
13
9
|
//# sourceMappingURL=sampler-parameters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampler-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/sampler-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAK,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAG3D;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,YAAY,GAAG,mBAAmB,CAuCxF
|
|
1
|
+
{"version":3,"file":"sampler-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/sampler-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAK,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAG3D;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,YAAY,GAAG,mBAAmB,CAuCxF"}
|
|
@@ -1,76 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
|
+
import { convertCompareFunction } from './device-parameters';
|
|
5
|
+
/**
|
|
6
|
+
* Convert WebGPU-style sampler props to WebGL
|
|
7
|
+
* @param props
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
2
10
|
export function convertSamplerParametersToWebGL(props) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
...parameters
|
|
39
|
-
};
|
|
40
|
-
if (parameters[10241] !== 9728) {
|
|
41
|
-
newParameters[10241] = 9729;
|
|
42
|
-
}
|
|
43
|
-
newParameters[10242] = 33071;
|
|
44
|
-
newParameters[10243] = 33071;
|
|
45
|
-
return newParameters;
|
|
11
|
+
const params = {};
|
|
12
|
+
if (props.addressModeU) {
|
|
13
|
+
params[GL.TEXTURE_WRAP_S] = convertAddressMode(props.addressModeU);
|
|
14
|
+
}
|
|
15
|
+
if (props.addressModeV) {
|
|
16
|
+
params[GL.TEXTURE_WRAP_T] = convertAddressMode(props.addressModeV);
|
|
17
|
+
}
|
|
18
|
+
if (props.addressModeW) {
|
|
19
|
+
params[GL.TEXTURE_WRAP_R] = convertAddressMode(props.addressModeW);
|
|
20
|
+
}
|
|
21
|
+
if (props.magFilter) {
|
|
22
|
+
params[GL.TEXTURE_MAG_FILTER] = convertMaxFilterMode(props.magFilter);
|
|
23
|
+
}
|
|
24
|
+
if (props.minFilter || props.mipmapFilter) {
|
|
25
|
+
// TODO - arbitrary choice of linear?
|
|
26
|
+
params[GL.TEXTURE_MIN_FILTER] = convertMinFilterMode(props.minFilter || 'linear', props.mipmapFilter);
|
|
27
|
+
}
|
|
28
|
+
if (props.lodMinClamp !== undefined) {
|
|
29
|
+
params[GL.TEXTURE_MIN_LOD] = props.lodMinClamp;
|
|
30
|
+
}
|
|
31
|
+
if (props.lodMaxClamp !== undefined) {
|
|
32
|
+
params[GL.TEXTURE_MAX_LOD] = props.lodMaxClamp;
|
|
33
|
+
}
|
|
34
|
+
if (props.type === 'comparison-sampler') {
|
|
35
|
+
// Setting prop.compare turns this into a comparison sampler
|
|
36
|
+
params[GL.TEXTURE_COMPARE_MODE] = GL.COMPARE_REF_TO_TEXTURE;
|
|
37
|
+
}
|
|
38
|
+
if (props.compare) {
|
|
39
|
+
params[GL.TEXTURE_COMPARE_FUNC] = convertCompareFunction('compare', props.compare);
|
|
40
|
+
}
|
|
41
|
+
// Note depends on WebGL extension
|
|
42
|
+
if (props.maxAnisotropy) {
|
|
43
|
+
params[GL.TEXTURE_MAX_ANISOTROPY_EXT] = props.maxAnisotropy;
|
|
44
|
+
}
|
|
45
|
+
return params;
|
|
46
46
|
}
|
|
47
|
+
// HELPERS
|
|
48
|
+
/** Convert address more */
|
|
47
49
|
function convertAddressMode(addressMode) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
switch (addressMode) {
|
|
51
|
+
case 'clamp-to-edge':
|
|
52
|
+
return GL.CLAMP_TO_EDGE;
|
|
53
|
+
case 'repeat':
|
|
54
|
+
return GL.REPEAT;
|
|
55
|
+
case 'mirror-repeat':
|
|
56
|
+
return GL.MIRRORED_REPEAT;
|
|
57
|
+
}
|
|
56
58
|
}
|
|
57
59
|
function convertMaxFilterMode(maxFilter) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
switch (maxFilter) {
|
|
61
|
+
case 'nearest':
|
|
62
|
+
return GL.NEAREST;
|
|
63
|
+
case 'linear':
|
|
64
|
+
return GL.LINEAR;
|
|
65
|
+
}
|
|
64
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* WebGPU has separate min filter and mipmap filter,
|
|
69
|
+
* WebGL is combined and effectively offers 6 options
|
|
70
|
+
*/
|
|
65
71
|
function convertMinFilterMode(minFilter, mipmapFilter) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
if (!mipmapFilter) {
|
|
73
|
+
return convertMaxFilterMode(minFilter);
|
|
74
|
+
}
|
|
75
|
+
switch (minFilter) {
|
|
76
|
+
case 'nearest':
|
|
77
|
+
return mipmapFilter === 'nearest' ? GL.NEAREST_MIPMAP_NEAREST : GL.NEAREST_MIPMAP_LINEAR;
|
|
78
|
+
case 'linear':
|
|
79
|
+
return mipmapFilter === 'nearest' ? GL.LINEAR_MIPMAP_NEAREST : GL.LINEAR_MIPMAP_LINEAR;
|
|
80
|
+
}
|
|
75
81
|
}
|
|
76
|
-
//# sourceMappingURL=sampler-parameters.js.map
|