@luma.gl/webgl 9.0.0-beta.6 → 9.0.0-beta.8
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.map +1 -1
- package/dist/adapter/converters/device-parameters.js +81 -84
- package/dist/adapter/converters/sampler-parameters.js +17 -17
- package/dist/adapter/converters/shader-formats.js +12 -12
- package/dist/adapter/converters/texture-formats.d.ts +10 -8
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +175 -168
- package/dist/adapter/converters/vertex-formats.js +20 -20
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +14 -2
- package/dist/adapter/device-helpers/webgl-device-info.js +5 -5
- package/dist/adapter/device-helpers/webgl-device-limits.js +10 -10
- package/dist/adapter/helpers/decode-webgl-types.js +45 -45
- package/dist/adapter/helpers/get-shader-layout.js +29 -29
- package/dist/adapter/helpers/set-uniform.js +40 -40
- package/dist/adapter/helpers/webgl-topology-utils.js +38 -38
- package/dist/adapter/objects/webgl-renderbuffer.js +6 -6
- package/dist/adapter/objects/webgl-resource.js +1 -2
- package/dist/adapter/resources/webgl-buffer.js +14 -14
- package/dist/adapter/resources/webgl-command-buffer.js +25 -25
- package/dist/adapter/resources/webgl-external-texture.js +3 -3
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -4
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +41 -36
- package/dist/adapter/resources/webgl-query-set.js +6 -6
- package/dist/adapter/resources/webgl-render-pass.js +5 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +19 -13
- package/dist/adapter/resources/webgl-sampler.js +2 -2
- package/dist/adapter/resources/webgl-shader.js +4 -4
- package/dist/adapter/resources/webgl-texture.d.ts +2 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +29 -27
- package/dist/adapter/resources/webgl-transform-feedback.js +8 -8
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -5
- package/dist/adapter/webgl-device.d.ts +6 -3
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +22 -17
- package/dist/classic/accessor.js +4 -4
- package/dist/classic/clear.js +2 -2
- package/dist/classic/copy-and-blit.js +15 -16
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.js +14 -14
- package/dist/classic/typed-array-utils.js +18 -18
- package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +4 -9
- package/dist/context/parameters/webgl-parameter-tables.d.ts +2 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +292 -298
- package/dist/context/state-tracker/with-parameters.d.ts +1 -2
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +2 -5
- package/dist/dist.dev.js +3796 -5522
- package/dist/dist.min.js +10 -0
- package/dist/index.cjs +1253 -1188
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -7
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
- package/src/adapter/converters/device-parameters.ts +9 -11
- package/src/adapter/converters/texture-formats.ts +64 -61
- package/src/adapter/device-helpers/webgl-device-features.ts +22 -2
- package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
- package/src/adapter/objects/webgl-resource.ts +1 -1
- package/src/adapter/resources/webgl-external-texture.ts +3 -3
- package/src/adapter/resources/webgl-framebuffer.ts +29 -26
- package/src/adapter/resources/webgl-render-pass.ts +3 -3
- package/src/adapter/resources/webgl-render-pipeline.ts +13 -6
- package/src/adapter/resources/webgl-texture.ts +7 -3
- package/src/adapter/webgl-device.ts +24 -19
- package/src/classic/clear.ts +2 -2
- package/src/context/.DS_Store +0 -0
- package/src/context/parameters/unified-parameter-api.ts +4 -16
- package/src/context/state-tracker/with-parameters.ts +2 -7
- package/src/index.ts +4 -4
- package/dist/adapter/device-helpers/device-features.d.ts +0 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-features.js +0 -65
- package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
- package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js +0 -92
- package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js +0 -87
- package/dist/context/context/context-data.d.ts +0 -14
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/dist/context/context/create-browser-context.d.ts +0 -35
- package/dist/context/context/create-browser-context.d.ts.map +0 -1
- package/dist/context/context/create-browser-context.js +0 -66
- package/dist.min.js +0 -19
|
@@ -6,25 +6,25 @@ import { GL } from '@luma.gl/constants';
|
|
|
6
6
|
// prettier-ignore
|
|
7
7
|
export class WebGLDeviceLimits extends DeviceLimits {
|
|
8
8
|
get maxTextureDimension1D() { return 0; } // WebGL does not support 1D textures
|
|
9
|
-
get maxTextureDimension2D() { return this.getParameter(
|
|
10
|
-
get maxTextureDimension3D() { return this.getParameter(
|
|
11
|
-
get maxTextureArrayLayers() { return this.getParameter(
|
|
9
|
+
get maxTextureDimension2D() { return this.getParameter(3379); }
|
|
10
|
+
get maxTextureDimension3D() { return this.getParameter(32883); }
|
|
11
|
+
get maxTextureArrayLayers() { return this.getParameter(35071); }
|
|
12
12
|
get maxBindGroups() { return 0; }
|
|
13
13
|
get maxDynamicUniformBuffersPerPipelineLayout() { return 0; } // TBD
|
|
14
14
|
get maxDynamicStorageBuffersPerPipelineLayout() { return 0; } // TBD
|
|
15
|
-
get maxSampledTexturesPerShaderStage() { return this.getParameter(
|
|
16
|
-
get maxSamplersPerShaderStage() { return this.getParameter(
|
|
15
|
+
get maxSampledTexturesPerShaderStage() { return this.getParameter(35660); } // ) TBD
|
|
16
|
+
get maxSamplersPerShaderStage() { return this.getParameter(35661); }
|
|
17
17
|
get maxStorageBuffersPerShaderStage() { return 0; } // TBD
|
|
18
18
|
get maxStorageTexturesPerShaderStage() { return 0; } // TBD
|
|
19
|
-
get maxUniformBuffersPerShaderStage() { return this.getParameter(
|
|
20
|
-
get maxUniformBufferBindingSize() { return this.getParameter(
|
|
19
|
+
get maxUniformBuffersPerShaderStage() { return this.getParameter(35375); }
|
|
20
|
+
get maxUniformBufferBindingSize() { return this.getParameter(35376); }
|
|
21
21
|
get maxStorageBufferBindingSize() { return 0; }
|
|
22
|
-
get minUniformBufferOffsetAlignment() { return this.getParameter(
|
|
22
|
+
get minUniformBufferOffsetAlignment() { return this.getParameter(35380); }
|
|
23
23
|
get minStorageBufferOffsetAlignment() { return 0; }
|
|
24
24
|
get maxVertexBuffers() { return 16; } // WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284
|
|
25
|
-
get maxVertexAttributes() { return this.getParameter(
|
|
25
|
+
get maxVertexAttributes() { return this.getParameter(34921); }
|
|
26
26
|
get maxVertexBufferArrayStride() { return 2048; } // TBD, this is just the default value from WebGPU
|
|
27
|
-
get maxInterStageShaderComponents() { return this.getParameter(
|
|
27
|
+
get maxInterStageShaderComponents() { return this.getParameter(35659); }
|
|
28
28
|
get maxComputeWorkgroupStorageSize() { return 0; } // WebGL does not support compute shaders
|
|
29
29
|
get maxComputeInvocationsPerWorkgroup() { return 0; } // WebGL does not support compute shaders
|
|
30
30
|
get maxComputeWorkgroupSizeX() { return 0; } // WebGL does not support compute shaders
|
|
@@ -7,50 +7,50 @@ export function isSamplerUniform(type) {
|
|
|
7
7
|
return SAMPLER_TYPES.includes(type);
|
|
8
8
|
}
|
|
9
9
|
const SAMPLER_TYPES = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
35678,
|
|
11
|
+
35680,
|
|
12
|
+
35679,
|
|
13
|
+
35682,
|
|
14
|
+
36289,
|
|
15
|
+
36292,
|
|
16
|
+
36293,
|
|
17
|
+
36298,
|
|
18
|
+
36299,
|
|
19
|
+
36300,
|
|
20
|
+
36303,
|
|
21
|
+
36306,
|
|
22
|
+
36307,
|
|
23
|
+
36308,
|
|
24
|
+
36311
|
|
25
25
|
];
|
|
26
26
|
// Composite types table
|
|
27
27
|
const COMPOSITE_GL_TYPES = {
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
28
|
+
[5126]: [5126, 1, 'float', 'f32', 'float32'],
|
|
29
|
+
[35664]: [5126, 2, 'vec2', 'vec2<f32>', 'float32x2'],
|
|
30
|
+
[35665]: [5126, 3, 'vec3', 'vec3<f32>', 'float32x3'],
|
|
31
|
+
[35666]: [5126, 4, 'vec4', 'vec4<f32>', 'float32x4'],
|
|
32
|
+
[5124]: [5124, 1, 'int', 'i32', 'sint32'],
|
|
33
|
+
[35667]: [5124, 2, 'ivec2', 'vec2<i32>', 'sint32x2'],
|
|
34
|
+
[35668]: [5124, 3, 'ivec3', 'vec3<i32>', 'sint32x3'],
|
|
35
|
+
[35669]: [5124, 4, 'ivec4', 'vec4<i32>', 'sint32x4'],
|
|
36
|
+
[5125]: [5125, 1, 'uint', 'u32', 'uint32'],
|
|
37
|
+
[36294]: [5125, 2, 'uvec2', 'vec2<u32>', 'uint32x2'],
|
|
38
|
+
[36295]: [5125, 3, 'uvec3', 'vec3<u32>', 'uint32x3'],
|
|
39
|
+
[36296]: [5125, 4, 'uvec4', 'vec4<u32>', 'uint32x4'],
|
|
40
|
+
[35670]: [5126, 1, 'bool', 'f32', 'float32'],
|
|
41
|
+
[35671]: [5126, 2, 'bvec2', 'vec2<f32>', 'float32x2'],
|
|
42
|
+
[35672]: [5126, 3, 'bvec3', 'vec3<f32>', 'float32x3'],
|
|
43
|
+
[35673]: [5126, 4, 'bvec4', 'vec4<f32>', 'float32x4'],
|
|
44
44
|
// TODO - are sizes/components below correct?
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
[
|
|
53
|
-
[
|
|
45
|
+
[35674]: [5126, 8, 'mat2', 'mat2x2<f32>'], // 4
|
|
46
|
+
[35685]: [5126, 8, 'mat2x3', 'mat2x3<f32>'], // 6
|
|
47
|
+
[35686]: [5126, 8, 'mat2x4', 'mat2x4<f32>'], // 8
|
|
48
|
+
[35687]: [5126, 12, 'mat3x2', 'mat3x2<f32>'], // 6
|
|
49
|
+
[35675]: [5126, 12, 'mat3', 'mat3x3<f32>'], // 9
|
|
50
|
+
[35688]: [5126, 12, 'mat3x4', 'mat3x4<f32>'], // 12
|
|
51
|
+
[35689]: [5126, 16, 'mat4x2', 'mat4x2<f32>'], // 8
|
|
52
|
+
[35690]: [5126, 16, 'mat4x3', 'mat4x3<f32>'], // 12
|
|
53
|
+
[35676]: [5126, 16, 'mat4', 'mat4x4<f32>'] // 16
|
|
54
54
|
};
|
|
55
55
|
/** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
|
|
56
56
|
export function decodeGLUniformType(glUniformType) {
|
|
@@ -83,11 +83,11 @@ export function decomposeCompositeGLDataType(compositeGLDataType) {
|
|
|
83
83
|
}
|
|
84
84
|
export function getCompositeGLDataType(type, components) {
|
|
85
85
|
switch (type) {
|
|
86
|
-
case
|
|
87
|
-
case
|
|
88
|
-
case
|
|
89
|
-
case
|
|
90
|
-
type =
|
|
86
|
+
case 5120:
|
|
87
|
+
case 5121:
|
|
88
|
+
case 5122:
|
|
89
|
+
case 5123:
|
|
90
|
+
type = 5126;
|
|
91
91
|
break;
|
|
92
92
|
default:
|
|
93
93
|
}
|
|
@@ -70,7 +70,7 @@ export function getShaderLayout(gl, program) {
|
|
|
70
70
|
*/
|
|
71
71
|
function readAttributeDeclarations(gl, program) {
|
|
72
72
|
const attributes = [];
|
|
73
|
-
const count = gl.getProgramParameter(program,
|
|
73
|
+
const count = gl.getProgramParameter(program, 35721);
|
|
74
74
|
for (let index = 0; index < count; index++) {
|
|
75
75
|
const activeInfo = gl.getActiveAttrib(program, index);
|
|
76
76
|
if (!activeInfo) {
|
|
@@ -106,7 +106,7 @@ function readAttributeDeclarations(gl, program) {
|
|
|
106
106
|
*/
|
|
107
107
|
function readVaryings(gl, program) {
|
|
108
108
|
const varyings = [];
|
|
109
|
-
const count = gl.getProgramParameter(program,
|
|
109
|
+
const count = gl.getProgramParameter(program, 35971);
|
|
110
110
|
for (let location = 0; location < count; location++) {
|
|
111
111
|
const activeInfo = gl.getTransformFeedbackVarying(program, location);
|
|
112
112
|
if (!activeInfo) {
|
|
@@ -128,7 +128,7 @@ function readVaryings(gl, program) {
|
|
|
128
128
|
*/
|
|
129
129
|
function readUniformBindings(gl, program) {
|
|
130
130
|
const uniforms = [];
|
|
131
|
-
const uniformCount = gl.getProgramParameter(program,
|
|
131
|
+
const uniformCount = gl.getProgramParameter(program, 35718);
|
|
132
132
|
for (let i = 0; i < uniformCount; i++) {
|
|
133
133
|
const activeInfo = gl.getActiveUniform(program, i);
|
|
134
134
|
if (!activeInfo) {
|
|
@@ -169,27 +169,27 @@ function readUniformBindings(gl, program) {
|
|
|
169
169
|
function readUniformBlocks(gl, program) {
|
|
170
170
|
const getBlockParameter = (blockIndex, pname) => gl.getActiveUniformBlockParameter(program, blockIndex, pname);
|
|
171
171
|
const uniformBlocks = [];
|
|
172
|
-
const blockCount = gl.getProgramParameter(program,
|
|
172
|
+
const blockCount = gl.getProgramParameter(program, 35382);
|
|
173
173
|
for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
|
|
174
174
|
const blockInfo = {
|
|
175
175
|
name: gl.getActiveUniformBlockName(program, blockIndex) || '',
|
|
176
|
-
location: getBlockParameter(blockIndex,
|
|
177
|
-
byteLength: getBlockParameter(blockIndex,
|
|
178
|
-
vertex: getBlockParameter(blockIndex,
|
|
179
|
-
fragment: getBlockParameter(blockIndex,
|
|
180
|
-
uniformCount: getBlockParameter(blockIndex,
|
|
176
|
+
location: getBlockParameter(blockIndex, 35391),
|
|
177
|
+
byteLength: getBlockParameter(blockIndex, 35392),
|
|
178
|
+
vertex: getBlockParameter(blockIndex, 35396),
|
|
179
|
+
fragment: getBlockParameter(blockIndex, 35398),
|
|
180
|
+
uniformCount: getBlockParameter(blockIndex, 35394),
|
|
181
181
|
uniforms: []
|
|
182
182
|
};
|
|
183
|
-
const uniformIndices = getBlockParameter(blockIndex,
|
|
184
|
-
const uniformType = gl.getActiveUniforms(program, uniformIndices,
|
|
185
|
-
const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices,
|
|
183
|
+
const uniformIndices = getBlockParameter(blockIndex, 35395) || [];
|
|
184
|
+
const uniformType = gl.getActiveUniforms(program, uniformIndices, 35383); // Array of GLenum indicating the types of the uniforms.
|
|
185
|
+
const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, 35384); // Array of GLuint indicating the sizes of the uniforms.
|
|
186
186
|
// const uniformBlockIndex = gl.getActiveUniforms(
|
|
187
187
|
// program,
|
|
188
188
|
// uniformIndices,
|
|
189
189
|
// GL.UNIFORM_BLOCK_INDEX
|
|
190
190
|
// ); // Array of GLint indicating the block indices of the uniforms.
|
|
191
|
-
const uniformOffset = gl.getActiveUniforms(program, uniformIndices,
|
|
192
|
-
const uniformStride = gl.getActiveUniforms(program, uniformIndices,
|
|
191
|
+
const uniformOffset = gl.getActiveUniforms(program, uniformIndices, 35387); // Array of GLint indicating the uniform buffer offsets.
|
|
192
|
+
const uniformStride = gl.getActiveUniforms(program, uniformIndices, 35388); // Array of GLint indicating the strides between the elements.
|
|
193
193
|
// const uniformMatrixStride = gl.getActiveUniforms(
|
|
194
194
|
// program,
|
|
195
195
|
// uniformIndices,
|
|
@@ -238,21 +238,21 @@ function readUniformBlocks(gl, program) {
|
|
|
238
238
|
}
|
|
239
239
|
*/
|
|
240
240
|
const SAMPLER_UNIFORMS_GL_TO_GPU = {
|
|
241
|
-
[
|
|
242
|
-
[
|
|
243
|
-
[
|
|
244
|
-
[
|
|
245
|
-
[
|
|
246
|
-
[
|
|
247
|
-
[
|
|
248
|
-
[
|
|
249
|
-
[
|
|
250
|
-
[
|
|
251
|
-
[
|
|
252
|
-
[
|
|
253
|
-
[
|
|
254
|
-
[
|
|
255
|
-
[
|
|
241
|
+
[35678]: ['2d', 'float'],
|
|
242
|
+
[35680]: ['cube', 'float'],
|
|
243
|
+
[35679]: ['3d', 'float'],
|
|
244
|
+
[35682]: ['3d', 'depth'],
|
|
245
|
+
[36289]: ['2d-array', 'float'],
|
|
246
|
+
[36292]: ['2d-array', 'depth'],
|
|
247
|
+
[36293]: ['cube', 'float'],
|
|
248
|
+
[36298]: ['2d', 'sint'],
|
|
249
|
+
[36299]: ['3d', 'sint'],
|
|
250
|
+
[36300]: ['cube', 'sint'],
|
|
251
|
+
[36303]: ['2d-array', 'uint'],
|
|
252
|
+
[36306]: ['2d', 'uint'],
|
|
253
|
+
[36307]: ['3d', 'uint'],
|
|
254
|
+
[36308]: ['cube', 'uint'],
|
|
255
|
+
[36311]: ['2d-array', 'uint']
|
|
256
256
|
};
|
|
257
257
|
function getSamplerInfo(type) {
|
|
258
258
|
const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];
|
|
@@ -17,54 +17,54 @@ export function setUniform(gl, location, type, value) {
|
|
|
17
17
|
const arrayValue = typeof uniformValue === 'number' ? [uniformValue] : uniformValue;
|
|
18
18
|
// prettier-ignore
|
|
19
19
|
switch (type) {
|
|
20
|
-
case
|
|
21
|
-
case
|
|
22
|
-
case
|
|
23
|
-
case
|
|
24
|
-
case
|
|
25
|
-
case
|
|
26
|
-
case
|
|
27
|
-
case
|
|
28
|
-
case
|
|
29
|
-
case
|
|
30
|
-
case
|
|
31
|
-
case
|
|
32
|
-
case
|
|
33
|
-
case
|
|
34
|
-
case
|
|
20
|
+
case 35678:
|
|
21
|
+
case 35680:
|
|
22
|
+
case 35679:
|
|
23
|
+
case 35682:
|
|
24
|
+
case 36289:
|
|
25
|
+
case 36292:
|
|
26
|
+
case 36293:
|
|
27
|
+
case 36298:
|
|
28
|
+
case 36299:
|
|
29
|
+
case 36300:
|
|
30
|
+
case 36303:
|
|
31
|
+
case 36306:
|
|
32
|
+
case 36307:
|
|
33
|
+
case 36308:
|
|
34
|
+
case 36311:
|
|
35
35
|
if (typeof value !== 'number') {
|
|
36
36
|
throw new Error('samplers must be set to integers');
|
|
37
37
|
}
|
|
38
38
|
return gl.uniform1i(location, value);
|
|
39
|
-
case
|
|
40
|
-
case
|
|
41
|
-
case
|
|
42
|
-
case
|
|
43
|
-
case
|
|
44
|
-
case
|
|
45
|
-
case
|
|
46
|
-
case
|
|
47
|
-
case
|
|
48
|
-
case
|
|
49
|
-
case
|
|
50
|
-
case
|
|
39
|
+
case 5126: return gl.uniform1fv(location, arrayValue);
|
|
40
|
+
case 35664: return gl.uniform2fv(location, arrayValue);
|
|
41
|
+
case 35665: return gl.uniform3fv(location, arrayValue);
|
|
42
|
+
case 35666: return gl.uniform4fv(location, arrayValue);
|
|
43
|
+
case 5124: return gl.uniform1iv(location, arrayValue);
|
|
44
|
+
case 35667: return gl.uniform2iv(location, arrayValue);
|
|
45
|
+
case 35668: return gl.uniform3iv(location, arrayValue);
|
|
46
|
+
case 35669: return gl.uniform4iv(location, arrayValue);
|
|
47
|
+
case 35670: return gl.uniform1iv(location, arrayValue);
|
|
48
|
+
case 35671: return gl.uniform2iv(location, arrayValue);
|
|
49
|
+
case 35672: return gl.uniform3iv(location, arrayValue);
|
|
50
|
+
case 35673: return gl.uniform4iv(location, arrayValue);
|
|
51
51
|
// WEBGL2 - unsigned integers
|
|
52
|
-
case
|
|
53
|
-
case
|
|
54
|
-
case
|
|
55
|
-
case
|
|
52
|
+
case 5125: return gl2.uniform1uiv(location, arrayValue, 1);
|
|
53
|
+
case 36294: return gl2.uniform2uiv(location, arrayValue, 2);
|
|
54
|
+
case 36295: return gl2.uniform3uiv(location, arrayValue, 3);
|
|
55
|
+
case 36296: return gl2.uniform4uiv(location, arrayValue, 4);
|
|
56
56
|
// WebGL2 - quadratic matrices
|
|
57
57
|
// false: don't transpose the matrix
|
|
58
|
-
case
|
|
59
|
-
case
|
|
60
|
-
case
|
|
58
|
+
case 35674: return gl.uniformMatrix2fv(location, false, arrayValue);
|
|
59
|
+
case 35675: return gl.uniformMatrix3fv(location, false, arrayValue);
|
|
60
|
+
case 35676: return gl.uniformMatrix4fv(location, false, arrayValue);
|
|
61
61
|
// WebGL2 - rectangular matrices
|
|
62
|
-
case
|
|
63
|
-
case
|
|
64
|
-
case
|
|
65
|
-
case
|
|
66
|
-
case
|
|
67
|
-
case
|
|
62
|
+
case 35685: return gl2.uniformMatrix2x3fv(location, false, arrayValue);
|
|
63
|
+
case 35686: return gl2.uniformMatrix2x4fv(location, false, arrayValue);
|
|
64
|
+
case 35687: return gl2.uniformMatrix3x2fv(location, false, arrayValue);
|
|
65
|
+
case 35688: return gl2.uniformMatrix3x4fv(location, false, arrayValue);
|
|
66
|
+
case 35689: return gl2.uniformMatrix4x2fv(location, false, arrayValue);
|
|
67
|
+
case 35690: return gl2.uniformMatrix4x3fv(location, false, arrayValue);
|
|
68
68
|
}
|
|
69
69
|
throw new Error('Illegal uniform');
|
|
70
70
|
}
|
|
@@ -5,20 +5,20 @@ import { GL } from '@luma.gl/constants';
|
|
|
5
5
|
// Counts the number of complete primitives given a number of vertices and a drawMode
|
|
6
6
|
export function getPrimitiveDrawMode(drawMode) {
|
|
7
7
|
switch (drawMode) {
|
|
8
|
-
case
|
|
9
|
-
return
|
|
10
|
-
case
|
|
11
|
-
return
|
|
12
|
-
case
|
|
13
|
-
return
|
|
14
|
-
case
|
|
15
|
-
return
|
|
16
|
-
case
|
|
17
|
-
return
|
|
18
|
-
case
|
|
19
|
-
return
|
|
20
|
-
case
|
|
21
|
-
return
|
|
8
|
+
case 0:
|
|
9
|
+
return 0;
|
|
10
|
+
case 1:
|
|
11
|
+
return 1;
|
|
12
|
+
case 3:
|
|
13
|
+
return 1;
|
|
14
|
+
case 2:
|
|
15
|
+
return 1;
|
|
16
|
+
case 4:
|
|
17
|
+
return 4;
|
|
18
|
+
case 5:
|
|
19
|
+
return 4;
|
|
20
|
+
case 6:
|
|
21
|
+
return 4;
|
|
22
22
|
default:
|
|
23
23
|
throw new Error('drawMode');
|
|
24
24
|
}
|
|
@@ -27,17 +27,17 @@ export function getPrimitiveDrawMode(drawMode) {
|
|
|
27
27
|
export function getPrimitiveCount(options) {
|
|
28
28
|
const { drawMode, vertexCount } = options;
|
|
29
29
|
switch (drawMode) {
|
|
30
|
-
case
|
|
31
|
-
case
|
|
30
|
+
case 0:
|
|
31
|
+
case 2:
|
|
32
32
|
return vertexCount;
|
|
33
|
-
case
|
|
33
|
+
case 1:
|
|
34
34
|
return vertexCount / 2;
|
|
35
|
-
case
|
|
35
|
+
case 3:
|
|
36
36
|
return vertexCount - 1;
|
|
37
|
-
case
|
|
37
|
+
case 4:
|
|
38
38
|
return vertexCount / 3;
|
|
39
|
-
case
|
|
40
|
-
case
|
|
39
|
+
case 5:
|
|
40
|
+
case 6:
|
|
41
41
|
return vertexCount - 2;
|
|
42
42
|
default:
|
|
43
43
|
throw new Error('drawMode');
|
|
@@ -48,11 +48,11 @@ export function getVertexCount(options) {
|
|
|
48
48
|
const { drawMode, vertexCount } = options;
|
|
49
49
|
const primitiveCount = getPrimitiveCount({ drawMode, vertexCount });
|
|
50
50
|
switch (getPrimitiveDrawMode(drawMode)) {
|
|
51
|
-
case
|
|
51
|
+
case 0:
|
|
52
52
|
return primitiveCount;
|
|
53
|
-
case
|
|
53
|
+
case 1:
|
|
54
54
|
return primitiveCount * 2;
|
|
55
|
-
case
|
|
55
|
+
case 4:
|
|
56
56
|
return primitiveCount * 3;
|
|
57
57
|
default:
|
|
58
58
|
throw new Error('drawMode');
|
|
@@ -62,13 +62,13 @@ export function getVertexCount(options) {
|
|
|
62
62
|
export function getGLDrawMode(topology) {
|
|
63
63
|
// prettier-ignore
|
|
64
64
|
switch (topology) {
|
|
65
|
-
case 'point-list': return
|
|
66
|
-
case 'line-list': return
|
|
67
|
-
case 'line-strip': return
|
|
68
|
-
case 'line-loop-webgl': return
|
|
69
|
-
case 'triangle-list': return
|
|
70
|
-
case 'triangle-strip': return
|
|
71
|
-
case 'triangle-fan-webgl': return
|
|
65
|
+
case 'point-list': return 0;
|
|
66
|
+
case 'line-list': return 1;
|
|
67
|
+
case 'line-strip': return 3;
|
|
68
|
+
case 'line-loop-webgl': return 2;
|
|
69
|
+
case 'triangle-list': return 4;
|
|
70
|
+
case 'triangle-strip': return 5;
|
|
71
|
+
case 'triangle-fan-webgl': return 6;
|
|
72
72
|
default: throw new Error(topology);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -76,13 +76,13 @@ export function getGLDrawMode(topology) {
|
|
|
76
76
|
export function getGLPrimitive(topology) {
|
|
77
77
|
// prettier-ignore
|
|
78
78
|
switch (topology) {
|
|
79
|
-
case 'point-list': return
|
|
80
|
-
case 'line-list': return
|
|
81
|
-
case 'line-strip': return
|
|
82
|
-
case 'line-loop-webgl': return
|
|
83
|
-
case 'triangle-list': return
|
|
84
|
-
case 'triangle-strip': return
|
|
85
|
-
case 'triangle-fan-webgl': return
|
|
79
|
+
case 'point-list': return 0;
|
|
80
|
+
case 'line-list': return 1;
|
|
81
|
+
case 'line-strip': return 1;
|
|
82
|
+
case 'line-loop-webgl': return 1;
|
|
83
|
+
case 'triangle-list': return 4;
|
|
84
|
+
case 'triangle-strip': return 4;
|
|
85
|
+
case 'triangle-fan-webgl': return 4;
|
|
86
86
|
default: throw new Error(topology);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -71,15 +71,15 @@ export class WEBGLRenderbuffer extends WebGLResource {
|
|
|
71
71
|
const { format, width, height, samples } = props;
|
|
72
72
|
assert(format, 'Needs format');
|
|
73
73
|
this.trackDeallocatedMemory();
|
|
74
|
-
this.gl.bindRenderbuffer(
|
|
74
|
+
this.gl.bindRenderbuffer(36161, this.handle);
|
|
75
75
|
if (samples !== 0) {
|
|
76
|
-
this.gl.renderbufferStorageMultisample(
|
|
76
|
+
this.gl.renderbufferStorageMultisample(36161, samples, this.glFormat, width, height);
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
|
-
this.gl.renderbufferStorage(
|
|
79
|
+
this.gl.renderbufferStorage(36161, this.glFormat, width, height);
|
|
80
80
|
}
|
|
81
|
-
this.gl.bindRenderbuffer(
|
|
82
|
-
this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.
|
|
81
|
+
this.gl.bindRenderbuffer(36161, null);
|
|
82
|
+
this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.format));
|
|
83
83
|
}
|
|
84
84
|
// RESOURCE IMPLEMENTATION
|
|
85
85
|
_createHandle() {
|
|
@@ -90,6 +90,6 @@ export class WEBGLRenderbuffer extends WebGLResource {
|
|
|
90
90
|
this.trackDeallocatedMemory();
|
|
91
91
|
}
|
|
92
92
|
_bindHandle(handle) {
|
|
93
|
-
this.gl.bindRenderbuffer(
|
|
93
|
+
this.gl.bindRenderbuffer(36161, handle);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { Resource, uid, stubRemovedMethods } from '@luma.gl/core';
|
|
5
|
-
import { WebGLDevice } from "../webgl-device.js";
|
|
6
5
|
const ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';
|
|
7
6
|
/**
|
|
8
7
|
* Base class for WebGL object wrappers
|
|
@@ -17,7 +16,7 @@ export class WebGLResource extends Resource {
|
|
|
17
16
|
byteLength = 0;
|
|
18
17
|
constructor(device, props, defaultProps) {
|
|
19
18
|
super(device, props, defaultProps);
|
|
20
|
-
this.device =
|
|
19
|
+
this.device = device;
|
|
21
20
|
const gl = this.device.gl;
|
|
22
21
|
// extends
|
|
23
22
|
const { id } = props || {};
|
|
@@ -13,7 +13,7 @@ export class WEBGLBuffer extends Buffer {
|
|
|
13
13
|
/** Usage is a hint on how frequently the buffer will be updates */
|
|
14
14
|
glUsage;
|
|
15
15
|
/** Index type is needed when issuing draw calls, so we pre-compute it */
|
|
16
|
-
glIndexType =
|
|
16
|
+
glIndexType = 5123;
|
|
17
17
|
/** Number of bytes allocated on the GPU for this buffer */
|
|
18
18
|
byteLength;
|
|
19
19
|
/** Number of bytes used */
|
|
@@ -30,7 +30,7 @@ export class WEBGLBuffer extends Buffer {
|
|
|
30
30
|
// - In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here
|
|
31
31
|
this.glTarget = getWebGLTarget(this.props.usage);
|
|
32
32
|
this.glUsage = getWebGLUsage(this.props.usage);
|
|
33
|
-
this.glIndexType = this.props.indexType === 'uint32' ?
|
|
33
|
+
this.glIndexType = this.props.indexType === 'uint32' ? 5125 : 5123;
|
|
34
34
|
// Set data: (re)initializes the buffer
|
|
35
35
|
if (props.data) {
|
|
36
36
|
this._initWithData(props.data, props.byteOffset, props.byteLength);
|
|
@@ -89,7 +89,7 @@ export class WEBGLBuffer extends Buffer {
|
|
|
89
89
|
const byteLength = undefined; // data.byteLength;
|
|
90
90
|
// Create the buffer - binding it here for the first time locks the type
|
|
91
91
|
// In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type
|
|
92
|
-
const glTarget =
|
|
92
|
+
const glTarget = 36663;
|
|
93
93
|
this.gl.bindBuffer(glTarget, this.handle);
|
|
94
94
|
// WebGL2: subData supports additional srcOffset and length parameters
|
|
95
95
|
if (srcOffset !== 0 || byteLength !== undefined) {
|
|
@@ -111,9 +111,9 @@ export class WEBGLBuffer extends Buffer {
|
|
|
111
111
|
const data = new Uint8Array(byteLength);
|
|
112
112
|
const dstOffset = 0;
|
|
113
113
|
// Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type
|
|
114
|
-
this.gl.bindBuffer(
|
|
115
|
-
this.gl.getBufferSubData(
|
|
116
|
-
this.gl.bindBuffer(
|
|
114
|
+
this.gl.bindBuffer(36662, this.handle);
|
|
115
|
+
this.gl.getBufferSubData(36662, byteOffset, data, dstOffset, byteLength);
|
|
116
|
+
this.gl.bindBuffer(36662, null);
|
|
117
117
|
// Update local `data` if offsets are 0
|
|
118
118
|
this._setDebugData(data, byteOffset, byteLength);
|
|
119
119
|
return data;
|
|
@@ -145,28 +145,28 @@ export class WEBGLBuffer extends Buffer {
|
|
|
145
145
|
*/
|
|
146
146
|
function getWebGLTarget(usage) {
|
|
147
147
|
if (usage & Buffer.INDEX) {
|
|
148
|
-
return
|
|
148
|
+
return 34963;
|
|
149
149
|
}
|
|
150
150
|
if (usage & Buffer.VERTEX) {
|
|
151
|
-
return
|
|
151
|
+
return 34962;
|
|
152
152
|
}
|
|
153
153
|
if (usage & Buffer.UNIFORM) {
|
|
154
|
-
return
|
|
154
|
+
return 35345;
|
|
155
155
|
}
|
|
156
156
|
// Binding a buffer for the first time locks the type
|
|
157
157
|
// In WebGL2, we can use GL.COPY_WRITE_BUFFER to avoid locking the type
|
|
158
|
-
return
|
|
158
|
+
return 34962;
|
|
159
159
|
}
|
|
160
160
|
/** @todo usage is not passed correctly */
|
|
161
161
|
function getWebGLUsage(usage) {
|
|
162
162
|
if (usage & Buffer.INDEX) {
|
|
163
|
-
return
|
|
163
|
+
return 35044;
|
|
164
164
|
}
|
|
165
165
|
if (usage & Buffer.VERTEX) {
|
|
166
|
-
return
|
|
166
|
+
return 35044;
|
|
167
167
|
}
|
|
168
168
|
if (usage & Buffer.UNIFORM) {
|
|
169
|
-
return
|
|
169
|
+
return 35048;
|
|
170
170
|
}
|
|
171
|
-
return
|
|
171
|
+
return 35044;
|
|
172
172
|
}
|