@luma.gl/webgl 9.0.0-alpha.5 → 9.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.d.ts +11 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +15 -2
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +4 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +21 -2
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.js +3 -3
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +12 -2
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +40 -16
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/uniforms.d.ts +1 -1
- package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
- package/dist/adapter/helpers/uniforms.js +4 -4
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -2
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +5 -3
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +2 -0
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +40 -24
- 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.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +4 -3
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +19 -19
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +14 -13
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +1 -1
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +13 -4
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/buffer.js +14 -6
- package/dist/classic/buffer.js.map +1 -1
- package/dist/classic/typed-array-utils.d.ts +1 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/{create-context.d.ts → create-browser-context.d.ts} +1 -1
- package/dist/context/context/create-browser-context.d.ts.map +1 -0
- package/dist/context/context/{create-context.js → create-browser-context.js} +9 -3
- package/dist/context/context/create-browser-context.js.map +1 -0
- package/dist/context/context/create-headless-context.d.ts +9 -0
- package/dist/context/context/create-headless-context.d.ts.map +1 -0
- package/dist/context/context/create-headless-context.js +43 -0
- package/dist/context/context/create-headless-context.js.map +1 -0
- package/dist/context/context/device-pixels.d.ts.map +1 -1
- package/dist/context/context/device-pixels.js +13 -8
- package/dist/context/context/device-pixels.js.map +1 -1
- package/dist/context/debug/spector.js +1 -1
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +1 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +5 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +1 -3
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +1 -1
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +1 -1
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/es5/adapter/converters/device-parameters.js +17 -2
- package/dist/es5/adapter/converters/device-parameters.js.map +1 -1
- package/dist/es5/adapter/converters/sampler-parameters.js +21 -2
- package/dist/es5/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/es5/adapter/converters/texture-formats.js +3 -3
- package/dist/es5/adapter/converters/texture-formats.js.map +1 -1
- package/dist/es5/adapter/device-helpers/device-features.js +15 -4
- package/dist/es5/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/es5/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/es5/adapter/helpers/get-shader-layout.js +48 -28
- package/dist/es5/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/es5/adapter/helpers/uniforms.js +4 -4
- package/dist/es5/adapter/helpers/uniforms.js.map +1 -1
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-buffer.js +2 -2
- package/dist/es5/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-framebuffer.js +4 -3
- package/dist/es5/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-render-pass.js +1 -0
- package/dist/es5/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-render-pipeline.js +43 -30
- package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-shader.js +4 -3
- package/dist/es5/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-texture.js +16 -16
- package/dist/es5/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/es5/adapter/webgl-canvas-context.js +1 -1
- package/dist/es5/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/es5/adapter/webgl-device.js +14 -4
- package/dist/es5/adapter/webgl-device.js.map +1 -1
- package/dist/es5/classic/buffer.js +14 -6
- package/dist/es5/classic/buffer.js.map +1 -1
- package/dist/es5/classic/typed-array-utils.js.map +1 -1
- package/dist/es5/context/context/{create-context.js → create-browser-context.js} +9 -3
- package/dist/es5/context/context/create-browser-context.js.map +1 -0
- package/dist/es5/context/context/create-headless-context.js +60 -0
- package/dist/es5/context/context/create-headless-context.js.map +1 -0
- package/dist/es5/context/context/device-pixels.js +14 -8
- package/dist/es5/context/context/device-pixels.js.map +1 -1
- package/dist/es5/context/debug/spector.js +1 -1
- package/dist/es5/context/debug/spector.js.map +1 -1
- package/dist/es5/context/debug/webgl-developer-tools.js +1 -1
- package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/es5/context/parameters/unified-parameter-api.js +2 -2
- package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-table.js +1 -1
- package/dist/es5/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/es5/context/state-tracker/track-context-state.js +1 -1
- package/dist/es5/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/es5/index.js +30 -16
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/types/webgl.js.map +1 -1
- package/dist/esm/adapter/converters/device-parameters.js +15 -2
- package/dist/esm/adapter/converters/device-parameters.js.map +1 -1
- package/dist/esm/adapter/converters/sampler-parameters.js +21 -2
- package/dist/esm/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/esm/adapter/converters/texture-formats.js +3 -3
- package/dist/esm/adapter/converters/texture-formats.js.map +1 -1
- package/dist/esm/adapter/device-helpers/device-features.js +12 -2
- package/dist/esm/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/esm/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/esm/adapter/helpers/get-shader-layout.js +40 -16
- package/dist/esm/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/esm/adapter/helpers/uniforms.js +4 -4
- package/dist/esm/adapter/helpers/uniforms.js.map +1 -1
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-buffer.js +2 -2
- package/dist/esm/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-framebuffer.js +5 -3
- package/dist/esm/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-render-pass.js +2 -0
- package/dist/esm/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-render-pipeline.js +40 -24
- package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-shader.js +4 -3
- package/dist/esm/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-texture.js +14 -13
- package/dist/esm/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/esm/adapter/webgl-canvas-context.js +1 -1
- package/dist/esm/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/esm/adapter/webgl-device.js +13 -4
- package/dist/esm/adapter/webgl-device.js.map +1 -1
- package/dist/esm/classic/buffer.js +14 -6
- package/dist/esm/classic/buffer.js.map +1 -1
- package/dist/esm/classic/typed-array-utils.js.map +1 -1
- package/dist/esm/context/context/{create-context.js → create-browser-context.js} +9 -3
- package/dist/esm/context/context/create-browser-context.js.map +1 -0
- package/dist/esm/context/context/create-headless-context.js +43 -0
- package/dist/esm/context/context/create-headless-context.js.map +1 -0
- package/dist/esm/context/context/device-pixels.js +13 -8
- package/dist/esm/context/context/device-pixels.js.map +1 -1
- package/dist/esm/context/debug/spector.js +1 -1
- package/dist/esm/context/debug/spector.js.map +1 -1
- package/dist/esm/context/debug/webgl-developer-tools.js +1 -1
- package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/esm/context/parameters/unified-parameter-api.js +1 -3
- package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-table.js +1 -1
- package/dist/esm/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/esm/context/state-tracker/track-context-state.js +1 -1
- package/dist/esm/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/webgl.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/types/webgl.d.ts +3 -3
- package/dist/types/webgl.d.ts.map +1 -1
- package/dist/types/webgl.js.map +1 -1
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +28 -2
- package/src/adapter/converters/sampler-parameters.ts +16 -7
- package/src/adapter/converters/texture-formats.ts +3 -3
- package/src/adapter/device-helpers/device-features.ts +9 -1
- package/src/adapter/device-helpers/device-limits.ts +1 -1
- package/src/adapter/helpers/get-shader-layout.ts +40 -21
- package/src/adapter/helpers/uniforms.ts +21 -10
- package/src/adapter/objects/webgl-vertex-array-object.ts +1 -1
- package/src/adapter/resources/webgl-buffer.ts +3 -3
- package/src/adapter/resources/webgl-framebuffer.ts +6 -3
- package/src/adapter/resources/webgl-render-pass.ts +1 -0
- package/src/adapter/resources/webgl-render-pipeline.ts +43 -35
- package/src/adapter/resources/webgl-sampler.ts +5 -3
- package/src/adapter/resources/webgl-shader.ts +5 -4
- package/src/adapter/resources/webgl-texture.ts +37 -25
- package/src/adapter/webgl-canvas-context.ts +1 -1
- package/src/adapter/webgl-device.ts +16 -4
- package/src/classic/buffer.ts +7 -7
- package/src/classic/typed-array-utils.ts +3 -1
- package/src/context/context/{create-context.ts → create-browser-context.ts} +9 -5
- package/src/context/context/create-headless-context.ts +48 -0
- package/src/context/context/device-pixels.ts +15 -9
- package/src/context/debug/spector.ts +1 -1
- package/src/context/debug/webgl-developer-tools.ts +1 -1
- package/src/context/parameters/unified-parameter-api.ts +12 -9
- package/src/context/polyfill/polyfill-context.ts +1 -1
- package/src/context/polyfill/polyfill-table.ts +1 -1
- package/src/context/state-tracker/track-context-state.ts +1 -1
- package/src/index.ts +13 -5
- package/src/types/webgl.ts +3 -3
- package/dist/context/context/create-context.d.ts.map +0 -1
- package/dist/context/context/create-context.js.map +0 -1
- package/dist/es5/context/context/create-context.js.map +0 -1
- package/dist/esm/context/context/create-context.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SAMPLER FILTERS
|
|
2
2
|
import {SamplerParameters} from '@luma.gl/api';
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
|
-
import {
|
|
4
|
+
import {GLSamplerParameters} from '../../types/webgl';
|
|
5
5
|
import {convertCompareFunction, convertToCompareFunction} from './device-parameters';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,7 +9,7 @@ import {convertCompareFunction, convertToCompareFunction} from './device-paramet
|
|
|
9
9
|
* @param props
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
|
-
export function convertSamplerParametersToWebGL(props: SamplerParameters):
|
|
12
|
+
export function convertSamplerParametersToWebGL(props: SamplerParameters): GLSamplerParameters {
|
|
13
13
|
const params: Record<number, number> = {};
|
|
14
14
|
if (props.addressModeU) {
|
|
15
15
|
params[GL.TEXTURE_WRAP_S] = convertAddressMode(props.addressModeU);
|
|
@@ -33,10 +33,12 @@ export function convertSamplerParametersToWebGL(props: SamplerParameters): WebGL
|
|
|
33
33
|
if (props.lodMaxClamp !== undefined) {
|
|
34
34
|
params[GL.TEXTURE_MAX_LOD] = props.lodMaxClamp;
|
|
35
35
|
}
|
|
36
|
-
if (props.
|
|
36
|
+
if (props.type === 'comparison-sampler') {
|
|
37
37
|
// Setting prop.compare turns this into a comparison sampler
|
|
38
38
|
params[GL.TEXTURE_COMPARE_MODE] = GL.COMPARE_REF_TO_TEXTURE;
|
|
39
|
-
|
|
39
|
+
}
|
|
40
|
+
if (props.compare) {
|
|
41
|
+
params[GL.TEXTURE_COMPARE_FUNC] = convertCompareFunction('compare', props.compare);
|
|
40
42
|
}
|
|
41
43
|
// Note depends on WebGL extension
|
|
42
44
|
if (props.maxAnisotropy) {
|
|
@@ -82,7 +84,7 @@ function convertMinFilterMode(minFilter: 'nearest' | 'linear', mipmapFilter?: 'n
|
|
|
82
84
|
* @param props
|
|
83
85
|
* @returns
|
|
84
86
|
*/
|
|
85
|
-
export function convertToSamplerParameters(params:
|
|
87
|
+
export function convertToSamplerParameters(params: GLSamplerParameters): SamplerParameters {
|
|
86
88
|
const props: SamplerParameters = {};
|
|
87
89
|
if (params[GL.TEXTURE_WRAP_S]) {
|
|
88
90
|
props.addressModeU = convertToAddressMode(params[GL.TEXTURE_WRAP_S]);
|
|
@@ -108,7 +110,10 @@ function convertMinFilterMode(minFilter: 'nearest' | 'linear', mipmapFilter?: 'n
|
|
|
108
110
|
if (params[GL.TEXTURE_MAX_LOD]) {
|
|
109
111
|
props.lodMaxClamp = params[GL.TEXTURE_MAX_LOD];
|
|
110
112
|
}
|
|
111
|
-
if (params[GL.TEXTURE_COMPARE_MODE]
|
|
113
|
+
if (params[GL.TEXTURE_COMPARE_MODE]) {
|
|
114
|
+
props.type = params[GL.TEXTURE_COMPARE_MODE] === GL.COMPARE_REF_TO_TEXTURE ? 'comparison-sampler' : 'color-sampler';
|
|
115
|
+
}
|
|
116
|
+
if (params[GL.TEXTURE_COMPARE_FUNC]) {
|
|
112
117
|
props.compare = convertToCompareFunction('compare', params[GL.TEXTURE_COMPARE_FUNC]);
|
|
113
118
|
}
|
|
114
119
|
// NOTE depends on extension (very common)
|
|
@@ -124,6 +129,7 @@ function convertToAddressMode(addressMode: number): 'clamp-to-edge' | 'repeat' |
|
|
|
124
129
|
case GL.CLAMP_TO_EDGE: return 'clamp-to-edge';
|
|
125
130
|
case GL.REPEAT: return 'repeat';
|
|
126
131
|
case GL.MIRRORED_REPEAT: return 'mirror-repeat';
|
|
132
|
+
default: throw new Error('address');
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
135
|
|
|
@@ -131,6 +137,7 @@ function convertToMaxFilterMode(filterMode: number): 'nearest' | 'linear' {
|
|
|
131
137
|
switch (filterMode) {
|
|
132
138
|
case GL.NEAREST: return 'nearest';
|
|
133
139
|
case GL.LINEAR: return 'linear';
|
|
140
|
+
default: throw new Error('maxfilter');
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
143
|
|
|
@@ -144,6 +151,7 @@ function convertToMinFilterMode(filterMode: number): 'nearest' | 'linear' {
|
|
|
144
151
|
case GL.LINEAR_MIPMAP_NEAREST: return 'linear';
|
|
145
152
|
case GL.NEAREST_MIPMAP_LINEAR: return 'nearest';
|
|
146
153
|
case GL.LINEAR_MIPMAP_LINEAR: return 'linear';
|
|
154
|
+
default: throw new Error('minfilter');
|
|
147
155
|
}
|
|
148
156
|
}
|
|
149
157
|
|
|
@@ -156,13 +164,14 @@ function convertToMipmapFilterMode(filterMode: number): 'nearest' | 'linear' {
|
|
|
156
164
|
case GL.LINEAR_MIPMAP_NEAREST: return 'nearest';
|
|
157
165
|
case GL.NEAREST_MIPMAP_LINEAR: return 'linear';
|
|
158
166
|
case GL.LINEAR_MIPMAP_LINEAR: return 'linear';
|
|
167
|
+
default: throw new Error('mipmap');
|
|
159
168
|
}
|
|
160
169
|
}
|
|
161
170
|
|
|
162
171
|
/**
|
|
163
172
|
* Override sampler settings that are not supported by Non-Power-of-Two textures in WebGL1.
|
|
164
173
|
*/
|
|
165
|
-
export function updateSamplerParametersForNPOT(parameters:
|
|
174
|
+
export function updateSamplerParametersForNPOT(parameters: GLSamplerParameters): GLSamplerParameters {
|
|
166
175
|
const newParameters = {...parameters};
|
|
167
176
|
if (parameters[GL.TEXTURE_MIN_FILTER] !== GL.NEAREST) {
|
|
168
177
|
// log.warn(`texture: ${this} is Non-Power-Of-Two, forcing TEXTURE_MIN_FILTER to LINEAR`)();
|
|
@@ -64,7 +64,7 @@ const TEXTURE_FEATURE_CHECKS: Partial<Record<DeviceFeature, (gl: WebGLRenderingC
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
export function checkTextureFeature(gl: WebGLRenderingContext, feature: DeviceFeature): boolean {
|
|
67
|
-
return TEXTURE_FEATURE_CHECKS[feature]?.(gl);
|
|
67
|
+
return TEXTURE_FEATURE_CHECKS[feature]?.(gl) || false;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
const checkTextureFeatures = (gl: WebGLRenderingContext, features: DeviceFeature[]): boolean =>
|
|
@@ -520,8 +520,8 @@ export function _checkFloat32ColorAttachment(
|
|
|
520
520
|
srcFormat = GL.RGBA,
|
|
521
521
|
srcType = GL.UNSIGNED_BYTE
|
|
522
522
|
) {
|
|
523
|
-
let texture: WebGLTexture;
|
|
524
|
-
let framebuffer: WebGLFramebuffer;
|
|
523
|
+
let texture: WebGLTexture | null = null;
|
|
524
|
+
let framebuffer: WebGLFramebuffer | null = null;
|
|
525
525
|
try {
|
|
526
526
|
texture = gl.createTexture();
|
|
527
527
|
gl.bindTexture(GL.TEXTURE_2D, texture);
|
|
@@ -47,7 +47,12 @@ export function getWebGLFeatures(gl: WebGLRenderingContext): Set<DeviceFeature>
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function isFeatureSupported(gl: WebGLRenderingContext, feature: DeviceFeature): boolean {
|
|
50
|
-
const
|
|
50
|
+
const featureInfo = WEBGL_FEATURES[feature];
|
|
51
|
+
if (!featureInfo) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const [webgl1Feature, webgl2Feature] = featureInfo || [];
|
|
51
56
|
|
|
52
57
|
// Get extension name from table
|
|
53
58
|
const featureDefinition = isWebGL2(gl) ? webgl2Feature : webgl1Feature;
|
|
@@ -100,6 +105,9 @@ export function canCompileGLSLExtension(gl: WebGLRenderingContext, extensionName
|
|
|
100
105
|
const source = `#extension GL_${extensionName} : ${behavior}\nvoid main(void) {}`;
|
|
101
106
|
|
|
102
107
|
const shader = gl.createShader(gl.VERTEX_SHADER);
|
|
108
|
+
if (!shader) {
|
|
109
|
+
throw new Error('shader');
|
|
110
|
+
}
|
|
103
111
|
gl.shaderSource(shader, source);
|
|
104
112
|
gl.compileShader(shader);
|
|
105
113
|
const canCompile = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
|
|
@@ -5,7 +5,7 @@ import {getWebGL2Context} from '../../context/context/webgl-checks';
|
|
|
5
5
|
|
|
6
6
|
/** Populate a WebGPU style device limits */
|
|
7
7
|
export function getDeviceLimits(gl: WebGLRenderingContext): DeviceLimits {
|
|
8
|
-
const gl2: WebGL2RenderingContext = getWebGL2Context(gl);
|
|
8
|
+
const gl2: WebGL2RenderingContext | null = getWebGL2Context(gl);
|
|
9
9
|
return {
|
|
10
10
|
maxTextureDimension1D: 0, // WebGL does not support 1D textures
|
|
11
11
|
maxTextureDimension2D: gl.getParameter(GL.MAX_TEXTURE_SIZE),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
ShaderLayout,
|
|
3
5
|
BindingLayout,
|
|
@@ -123,12 +125,16 @@ function readAttributeBindings(
|
|
|
123
125
|
const count = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
|
|
124
126
|
|
|
125
127
|
for (let index = 0; index < count; index++) {
|
|
126
|
-
const
|
|
128
|
+
const activeInfo = gl.getActiveAttrib(program, index);
|
|
129
|
+
if (!activeInfo) {
|
|
130
|
+
throw new Error('activeInfo');
|
|
131
|
+
}
|
|
132
|
+
const {name, type: compositeType, size} = activeInfo;
|
|
127
133
|
const location = gl.getAttribLocation(program, name);
|
|
128
134
|
// Add only user provided attributes, for built-in attributes like
|
|
129
135
|
// `gl_InstanceID` locaiton will be < 0
|
|
130
136
|
if (location >= 0) {
|
|
131
|
-
const {glType, components} = decodeAttributeType(compositeType)
|
|
137
|
+
const {glType, components} = decodeAttributeType(compositeType);;
|
|
132
138
|
const accessor: AccessorObject = {type: glType, size: size * components};
|
|
133
139
|
// Any attribute name containing the word "instance" will be assumed to be instanced
|
|
134
140
|
if (/instance/i.test(name)) {
|
|
@@ -158,8 +164,12 @@ function readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): Varying
|
|
|
158
164
|
|
|
159
165
|
const count = gl.getProgramParameter(program, GL.TRANSFORM_FEEDBACK_VARYINGS);
|
|
160
166
|
for (let location = 0; location < count; location++) {
|
|
161
|
-
const
|
|
162
|
-
|
|
167
|
+
const activeInfo = gl2.getTransformFeedbackVarying(program, location);
|
|
168
|
+
if (!activeInfo) {
|
|
169
|
+
throw new Error('activeInfo');
|
|
170
|
+
}
|
|
171
|
+
const {name, type: compositeType, size} = activeInfo;
|
|
172
|
+
const {glType, components} = decodeUniformType(compositeType);;
|
|
163
173
|
const accessor = new Accessor({type: glType, size: size * components});
|
|
164
174
|
const varying = {location, name, accessor}; // Base values
|
|
165
175
|
varyings.push(varying);
|
|
@@ -179,7 +189,11 @@ function readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram):
|
|
|
179
189
|
|
|
180
190
|
const uniformCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORMS);
|
|
181
191
|
for (let i = 0; i < uniformCount; i++) {
|
|
182
|
-
const
|
|
192
|
+
const activeInfo = gl.getActiveUniform(program, i);
|
|
193
|
+
if (!activeInfo) {
|
|
194
|
+
throw new Error('activeInfo');
|
|
195
|
+
}
|
|
196
|
+
const {name: rawName, size, type} = activeInfo;
|
|
183
197
|
const {name, isArray} = parseUniformName(rawName);
|
|
184
198
|
let webglLocation = gl.getUniformLocation(program, name);
|
|
185
199
|
const uniformInfo = {
|
|
@@ -234,8 +248,8 @@ function readUniformBlocks(
|
|
|
234
248
|
|
|
235
249
|
const blockCount = gl2.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);
|
|
236
250
|
for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
|
|
237
|
-
const blockInfo = {
|
|
238
|
-
name: gl2.getActiveUniformBlockName(program, blockIndex),
|
|
251
|
+
const blockInfo: UniformBlockBinding = {
|
|
252
|
+
name: gl2.getActiveUniformBlockName(program, blockIndex) || '',
|
|
239
253
|
location: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_BINDING),
|
|
240
254
|
byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),
|
|
241
255
|
vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),
|
|
@@ -244,7 +258,7 @@ function readUniformBlocks(
|
|
|
244
258
|
uniforms: [] as any[]
|
|
245
259
|
};
|
|
246
260
|
|
|
247
|
-
const uniformIndices = getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES);
|
|
261
|
+
const uniformIndices = getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) as number[] || [];
|
|
248
262
|
|
|
249
263
|
const uniformType = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.
|
|
250
264
|
const uniformArrayLength = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.
|
|
@@ -262,15 +276,20 @@ function readUniformBlocks(
|
|
|
262
276
|
); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.
|
|
263
277
|
const uniformRowMajor = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
|
|
264
278
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
279
|
+
const activeInfo = gl2.getActiveUniform(program, uniformIndices[i]);
|
|
280
|
+
if (!activeInfo) {
|
|
281
|
+
throw new Error('activeInfo');
|
|
282
|
+
}
|
|
283
|
+
|
|
265
284
|
blockInfo.uniforms.push({
|
|
266
|
-
name:
|
|
285
|
+
name: activeInfo.name,
|
|
267
286
|
format: decodeUniformType(uniformType[i]).format,
|
|
268
287
|
type: uniformType[i],
|
|
269
288
|
arrayLength: uniformArrayLength[i],
|
|
270
289
|
byteOffset: uniformOffset[i],
|
|
271
290
|
byteStride: uniformStride[i],
|
|
272
|
-
matrixStride: uniformStride[i],
|
|
273
|
-
rowMajor: uniformRowMajor[i]
|
|
291
|
+
// matrixStride: uniformStride[i],
|
|
292
|
+
// rowMajor: uniformRowMajor[i]
|
|
274
293
|
});
|
|
275
294
|
}
|
|
276
295
|
|
|
@@ -305,18 +324,18 @@ const SAMPLER_UNIFORMS_GL_TO_GPU: Record<
|
|
|
305
324
|
[GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint']
|
|
306
325
|
};
|
|
307
326
|
|
|
308
|
-
|
|
309
|
-
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
327
|
+
type SamplerInfo = | {
|
|
328
|
+
viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
|
|
329
|
+
sampleType: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
function getSamplerInfo(type: GL): SamplerInfo {
|
|
314
333
|
let sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];
|
|
315
|
-
if (sampler) {
|
|
316
|
-
|
|
317
|
-
return {viewDimension, sampleType};
|
|
334
|
+
if (!sampler) {
|
|
335
|
+
throw new Error('sampler');
|
|
318
336
|
}
|
|
319
|
-
|
|
337
|
+
const [viewDimension, sampleType] = sampler;
|
|
338
|
+
return {viewDimension, sampleType};
|
|
320
339
|
}
|
|
321
340
|
|
|
322
341
|
// HELPERS
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {UniformFormat, VertexFormat} from '@luma.gl/api';
|
|
2
2
|
import GL from '@luma.gl/constants';
|
|
3
|
-
import {GLUniformType, GLSamplerType, GLCompositeType, GLType} from '../../types/webgl'
|
|
3
|
+
import {GLUniformType, GLSamplerType, GLCompositeType, GLType} from '../../types/webgl';
|
|
4
4
|
|
|
5
5
|
/** Check is uniform is of sampler type */
|
|
6
6
|
export function isSamplerUniform(type: GLUniformType): boolean {
|
|
@@ -25,8 +25,11 @@ const SAMPLER_TYPES: GLSamplerType[] = [
|
|
|
25
25
|
GL.UNSIGNED_INT_SAMPLER_2D_ARRAY
|
|
26
26
|
];
|
|
27
27
|
|
|
28
|
-
// Composite types table
|
|
29
|
-
const COMPOSITE_GL_TYPES: Record<
|
|
28
|
+
// Composite types table
|
|
29
|
+
const COMPOSITE_GL_TYPES: Record<
|
|
30
|
+
GLCompositeType,
|
|
31
|
+
[GLType, number, string, UniformFormat, VertexFormat?]
|
|
32
|
+
> = {
|
|
30
33
|
[GL.FLOAT]: [GL.FLOAT, 1, 'float', 'f32', 'float32'],
|
|
31
34
|
[GL.FLOAT_VEC2]: [GL.FLOAT, 2, 'vec2', 'vec2<f32>', 'float32x2'],
|
|
32
35
|
[GL.FLOAT_VEC3]: [GL.FLOAT, 3, 'vec3', 'vec3<f32>', 'float32x3'],
|
|
@@ -61,26 +64,34 @@ const COMPOSITE_GL_TYPES: Record<GLCompositeType, [GLType, number, string, Unifo
|
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
/** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */
|
|
64
|
-
export function decodeUniformType(
|
|
67
|
+
export function decodeUniformType(
|
|
68
|
+
uniformType: GL
|
|
69
|
+
): {format: UniformFormat; components: number; glType: GLType} {
|
|
65
70
|
const typeAndSize = COMPOSITE_GL_TYPES[uniformType];
|
|
66
71
|
if (!typeAndSize) {
|
|
67
|
-
|
|
72
|
+
throw new Error('uniform');
|
|
68
73
|
}
|
|
69
74
|
const [glType, components, , format] = typeAndSize;
|
|
70
75
|
return {format, components, glType};
|
|
71
76
|
}
|
|
72
77
|
|
|
73
|
-
export function decodeAttributeType(
|
|
74
|
-
|
|
78
|
+
export function decodeAttributeType(attributeType: GL): {
|
|
79
|
+
format: VertexFormat;
|
|
80
|
+
components: number;
|
|
81
|
+
glType: GLType;
|
|
82
|
+
} {
|
|
83
|
+
const typeAndSize = COMPOSITE_GL_TYPES[attributeType];
|
|
75
84
|
if (!typeAndSize) {
|
|
76
|
-
|
|
85
|
+
throw new Error('attribute')
|
|
77
86
|
}
|
|
78
87
|
const [glType, components, , , format] = typeAndSize;
|
|
79
88
|
return {format, components, glType};
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
/** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */
|
|
83
|
-
export function decomposeCompositeGLType(
|
|
92
|
+
export function decomposeCompositeGLType(
|
|
93
|
+
compositeGLType: GLCompositeType
|
|
94
|
+
): {type: GLType; components: number} | null {
|
|
84
95
|
const typeAndSize = COMPOSITE_GL_TYPES[compositeGLType];
|
|
85
96
|
if (!typeAndSize) {
|
|
86
97
|
return null;
|
|
@@ -89,7 +100,7 @@ export function decomposeCompositeGLType(compositeGLType: GLCompositeType): {typ
|
|
|
89
100
|
return {type, components};
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
export function getCompositeGLType(type: GL, components): {glType: GLType
|
|
103
|
+
export function getCompositeGLType(type: GL, components): {glType: GLType; name: string} | null {
|
|
93
104
|
switch (type) {
|
|
94
105
|
case GL.BYTE:
|
|
95
106
|
case GL.UNSIGNED_BYTE:
|
|
@@ -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: Buffer = null, opts = {}) {
|
|
46
|
+
setElementBuffer(elementBuffer: Buffer | 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...
|
|
@@ -15,7 +15,7 @@ export default class WEBGLBuffer extends Buffer {
|
|
|
15
15
|
|
|
16
16
|
byteLength: number;
|
|
17
17
|
bytesUsed: number;
|
|
18
|
-
debugData: ArrayBuffer;
|
|
18
|
+
debugData: ArrayBuffer | null = null;
|
|
19
19
|
|
|
20
20
|
webglUsage: number;
|
|
21
21
|
|
|
@@ -106,8 +106,8 @@ export default class WEBGLBuffer extends Buffer {
|
|
|
106
106
|
this.removeStats();
|
|
107
107
|
this.trackDeallocatedMemory();
|
|
108
108
|
this.gl.deleteBuffer(this.handle);
|
|
109
|
-
//
|
|
110
|
-
this.
|
|
109
|
+
// this.handle = null;
|
|
110
|
+
this.destroyed = true;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
|
|
1
3
|
import type {FramebufferProps, DepthStencilTextureFormat, ColorTextureFormat} from '@luma.gl/api';
|
|
2
4
|
import {Framebuffer, Texture, log, assert} from '@luma.gl/api';
|
|
3
5
|
import GL from '@luma.gl/constants';
|
|
@@ -17,7 +19,7 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
17
19
|
|
|
18
20
|
get texture() { return this.colorAttachments[0]; }
|
|
19
21
|
readonly colorAttachments: WebGLTexture[] = [];
|
|
20
|
-
readonly depthStencilAttachment: WebGLTexture |
|
|
22
|
+
readonly depthStencilAttachment: WebGLTexture | null = null; d
|
|
21
23
|
protected _ownResources: (WebGLTexture | Renderbuffer)[] = [];
|
|
22
24
|
|
|
23
25
|
constructor(device: WebGLDevice, props: FramebufferProps) {
|
|
@@ -66,7 +68,8 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
66
68
|
resource.destroy();
|
|
67
69
|
}
|
|
68
70
|
this.gl.deleteFramebuffer(this.handle);
|
|
69
|
-
this.handle = null;
|
|
71
|
+
// this.handle = null;
|
|
72
|
+
this.destroyed = true;
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
|
|
@@ -224,7 +227,7 @@ export default class WEBGLFramebuffer extends Framebuffer {
|
|
|
224
227
|
case GL.TEXTURE_2D_ARRAY:
|
|
225
228
|
case GL.TEXTURE_3D:
|
|
226
229
|
this.device.assertWebGL2();
|
|
227
|
-
gl2
|
|
230
|
+
gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);
|
|
228
231
|
break;
|
|
229
232
|
|
|
230
233
|
case GL.TEXTURE_CUBE_MAP:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
RenderPipelineProps,
|
|
3
|
-
RenderPipelineParameters,
|
|
4
3
|
RenderPass,
|
|
5
4
|
Buffer,
|
|
6
5
|
Binding,
|
|
@@ -11,9 +10,11 @@ import type {
|
|
|
11
10
|
} from '@luma.gl/api';
|
|
12
11
|
import {RenderPipeline, cast, log, decodeVertexFormat} from '@luma.gl/api';
|
|
13
12
|
import GL from '@luma.gl/constants';
|
|
13
|
+
|
|
14
|
+
import type {GLParameters} from '../../types/webgl';
|
|
14
15
|
import {getWebGLDataType} from '../converters/texture-formats';
|
|
15
16
|
import {getShaderLayout} from '../helpers/get-shader-layout';
|
|
16
|
-
import {withDeviceParameters} from '../converters/device-parameters';
|
|
17
|
+
import {withDeviceParameters, withGLParameters} from '../converters/device-parameters';
|
|
17
18
|
import {setUniform} from '../helpers/set-uniform';
|
|
18
19
|
// import {copyUniform, checkUniformValues} from '../../classes/uniforms';
|
|
19
20
|
|
|
@@ -35,7 +36,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
35
36
|
|
|
36
37
|
// configuration: ProgramConfiguration;
|
|
37
38
|
// Experimental flag to avoid deleting Program object while it is cached
|
|
38
|
-
varyings: string[];
|
|
39
|
+
varyings: string[] | null = null;
|
|
39
40
|
vertexArrayObject: WEBGLVertexArrayObject;
|
|
40
41
|
_indexBuffer?: Buffer;
|
|
41
42
|
uniforms: Record<string, any> = {};
|
|
@@ -43,7 +44,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
43
44
|
_textureUniforms: Record<string, any> = {};
|
|
44
45
|
_textureIndexCounter: number = 0;
|
|
45
46
|
_uniformCount: number = 0;
|
|
46
|
-
_uniformSetters: Record<string, Function
|
|
47
|
+
_uniformSetters: Record<string, Function> = {}; // TODO are these used?
|
|
47
48
|
|
|
48
49
|
constructor(device: WebGLDevice, props: RenderPipelineProps) {
|
|
49
50
|
super(device, props);
|
|
@@ -64,7 +65,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
64
65
|
if (varyings && varyings.length > 0) {
|
|
65
66
|
this.device.assertWebGL2();
|
|
66
67
|
this.varyings = varyings;
|
|
67
|
-
this.device.gl2
|
|
68
|
+
this.device.gl2?.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
this._compileAndLink();
|
|
@@ -76,7 +77,8 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
76
77
|
destroy(): void {
|
|
77
78
|
if (this.handle) {
|
|
78
79
|
this.device.gl.deleteProgram(this.handle);
|
|
79
|
-
this.handle = null;
|
|
80
|
+
// this.handle = null;
|
|
81
|
+
this.destroyed = true;
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -121,6 +123,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
121
123
|
const binding = this.layout.bindings.find((binding) => binding.name === name);
|
|
122
124
|
if (!binding) {
|
|
123
125
|
log.warn(`Unknown binding ${name} in render pipeline ${this.id}`)();
|
|
126
|
+
continue;
|
|
124
127
|
}
|
|
125
128
|
if (!value) {
|
|
126
129
|
log.warn(`Unsetting binding ${name} in render pipeline ${this.id}`)();
|
|
@@ -181,7 +184,7 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
181
184
|
const drawMode = getDrawMode(this.props.topology);
|
|
182
185
|
const isIndexed: boolean = Boolean(this._indexBuffer);
|
|
183
186
|
const indexType = this._indexBuffer?.props.indexType === 'uint16' ? GL.UNSIGNED_SHORT : GL.UNSIGNED_INT;
|
|
184
|
-
const isInstanced: boolean = options.instanceCount > 0;
|
|
187
|
+
const isInstanced: boolean = Number(options.instanceCount) > 0;
|
|
185
188
|
|
|
186
189
|
// Avoid WebGL draw call when not rendering any data or values are incomplete
|
|
187
190
|
// Note: async textures set as uniforms might still be loading.
|
|
@@ -195,8 +198,6 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
195
198
|
this.device.gl.useProgram(this.handle);
|
|
196
199
|
|
|
197
200
|
this.vertexArrayObject.bind(() => {
|
|
198
|
-
const parameters = {...this.props.parameters, framebuffer: renderPass.props.framebuffer};
|
|
199
|
-
|
|
200
201
|
const primitiveMode = getGLPrimitive(this.props.topology);
|
|
201
202
|
const transformFeedback: any = null;
|
|
202
203
|
if (transformFeedback) {
|
|
@@ -208,31 +209,33 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
208
209
|
this._applyUniforms();
|
|
209
210
|
|
|
210
211
|
// TODO - double context push/pop
|
|
211
|
-
withDeviceParameters(this.device, parameters, () => {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
212
|
+
withDeviceParameters(this.device, this.props.parameters, () => {
|
|
213
|
+
withGLParameters(this.device, {framebuffer: renderPass.props.framebuffer}, () => {
|
|
214
|
+
// TODO - Use polyfilled WebGL2RenderingContext instead of ANGLE extension
|
|
215
|
+
if (isIndexed && isInstanced) {
|
|
216
|
+
// ANGLE_instanced_arrays extension
|
|
217
|
+
this.device.gl2?.drawElementsInstanced(
|
|
218
|
+
drawMode,
|
|
219
|
+
vertexCount || 0, // indexCount?
|
|
220
|
+
indexType,
|
|
221
|
+
firstVertex,
|
|
222
|
+
instanceCount || 0
|
|
223
|
+
);
|
|
224
|
+
// } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {
|
|
225
|
+
// this.device.gl2.drawRangeElements(drawMode, start, end, vertexCount, indexType, offset);
|
|
226
|
+
} else if (isIndexed) {
|
|
227
|
+
this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount?
|
|
228
|
+
} else if (isInstanced) {
|
|
229
|
+
this.device.gl2?.drawArraysInstanced(drawMode, firstVertex, vertexCount || 0, instanceCount || 0);
|
|
230
|
+
} else {
|
|
231
|
+
this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
if (transformFeedback) {
|
|
236
|
+
transformFeedback.end();
|
|
230
237
|
}
|
|
231
238
|
});
|
|
232
|
-
|
|
233
|
-
if (transformFeedback) {
|
|
234
|
-
transformFeedback.end();
|
|
235
|
-
}
|
|
236
239
|
});
|
|
237
240
|
|
|
238
241
|
return true;
|
|
@@ -295,6 +298,9 @@ export default class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
295
298
|
this.device.gl.useProgram(this.handle);
|
|
296
299
|
|
|
297
300
|
const {gl2} = this.device;
|
|
301
|
+
if (!gl2) {
|
|
302
|
+
throw new Error('bindings');
|
|
303
|
+
}
|
|
298
304
|
|
|
299
305
|
let textureUnit = 0;
|
|
300
306
|
let uniformBufferIndex = 0;
|
|
@@ -395,13 +401,15 @@ function getAttributesByLocation(
|
|
|
395
401
|
const byLocation: Record<number, Buffer> = {};
|
|
396
402
|
for (const [name, buffer] of Object.entries(attributes)) {
|
|
397
403
|
const attribute = getAttributeLayout(layout, name);
|
|
398
|
-
|
|
404
|
+
if (attribute) {
|
|
405
|
+
byLocation[attribute.location] = buffer;
|
|
406
|
+
}
|
|
399
407
|
}
|
|
400
408
|
return byLocation;
|
|
401
409
|
}
|
|
402
410
|
|
|
403
|
-
function getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout |
|
|
404
|
-
return layout.attributes.find((binding) => binding.name === name);
|
|
411
|
+
function getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout | null {
|
|
412
|
+
return layout.attributes.find((binding) => binding.name === name) || null;
|
|
405
413
|
}
|
|
406
414
|
|
|
407
415
|
function getBindingLayout(layout: ShaderLayout, name: string): BindingLayout {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
|
|
1
3
|
import {Sampler, SamplerProps} from '@luma.gl/api';
|
|
2
4
|
import GL from '@luma.gl/constants';
|
|
3
|
-
import type {
|
|
5
|
+
import type {GLSamplerParameters} from '../../types/webgl';
|
|
4
6
|
import {convertSamplerParametersToWebGL} from '../converters/sampler-parameters';
|
|
5
7
|
import type WebGLDevice from '../webgl-device';
|
|
6
8
|
|
|
@@ -14,7 +16,7 @@ import type WebGLDevice from '../webgl-device';
|
|
|
14
16
|
export default class WEBGLSampler extends Sampler {
|
|
15
17
|
readonly device: WebGLDevice;
|
|
16
18
|
readonly handle: WebGLSampler;
|
|
17
|
-
readonly parameters:
|
|
19
|
+
readonly parameters: GLSamplerParameters;
|
|
18
20
|
|
|
19
21
|
constructor(device: WebGLDevice, props: SamplerProps) {
|
|
20
22
|
super(device, props);
|
|
@@ -35,7 +37,7 @@ export default class WEBGLSampler extends Sampler {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/** Set sampler parameters on the sampler */
|
|
38
|
-
private _setSamplerParameters(parameters:
|
|
40
|
+
private _setSamplerParameters(parameters: GLSamplerParameters): void {
|
|
39
41
|
for (const [pname, value] of Object.entries(parameters)) {
|
|
40
42
|
// Apparently there are integer/float conversion issues requires two parameter setting functions in JavaScript.
|
|
41
43
|
// For now, pick the float version for parameters specified as GLfloat.
|
|
@@ -32,14 +32,14 @@ import WebGLDevice from '../webgl-device';
|
|
|
32
32
|
if (this.handle) {
|
|
33
33
|
this.removeStats();
|
|
34
34
|
this.device.gl.deleteShader(this.handle);
|
|
35
|
-
//
|
|
36
|
-
this.
|
|
35
|
+
// this.handle = null;
|
|
36
|
+
this.destroyed = true;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
async compilationInfo(): Promise<readonly CompilerMessage[]> {
|
|
41
41
|
const log = this.device.gl.getShaderInfoLog(this.handle);
|
|
42
|
-
return parseShaderCompilerLog(log);
|
|
42
|
+
return log ? parseShaderCompilerLog(log) : [];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// PRIVATE METHODS
|
|
@@ -58,7 +58,8 @@ import WebGLDevice from '../webgl-device';
|
|
|
58
58
|
const compileStatus = gl.getShaderParameter(this.handle, GL.COMPILE_STATUS);
|
|
59
59
|
if (!compileStatus) {
|
|
60
60
|
const shaderLog = gl.getShaderInfoLog(this.handle);
|
|
61
|
-
const
|
|
61
|
+
const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];
|
|
62
|
+
const messages = parsedLog.filter(message => message.type === 'error');
|
|
62
63
|
const formattedLog = formatCompilerLog(messages, source);
|
|
63
64
|
const shaderName: string = getShaderInfo(source).name;
|
|
64
65
|
const shaderDescription = `${this.stage} shader ${shaderName}`;
|