@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.
Files changed (97) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +81 -84
  3. package/dist/adapter/converters/sampler-parameters.js +17 -17
  4. package/dist/adapter/converters/shader-formats.js +12 -12
  5. package/dist/adapter/converters/texture-formats.d.ts +10 -8
  6. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  7. package/dist/adapter/converters/texture-formats.js +175 -168
  8. package/dist/adapter/converters/vertex-formats.js +20 -20
  9. package/dist/adapter/device-helpers/webgl-device-features.d.ts +2 -1
  10. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
  11. package/dist/adapter/device-helpers/webgl-device-features.js +14 -2
  12. package/dist/adapter/device-helpers/webgl-device-info.js +5 -5
  13. package/dist/adapter/device-helpers/webgl-device-limits.js +10 -10
  14. package/dist/adapter/helpers/decode-webgl-types.js +45 -45
  15. package/dist/adapter/helpers/get-shader-layout.js +29 -29
  16. package/dist/adapter/helpers/set-uniform.js +40 -40
  17. package/dist/adapter/helpers/webgl-topology-utils.js +38 -38
  18. package/dist/adapter/objects/webgl-renderbuffer.js +6 -6
  19. package/dist/adapter/objects/webgl-resource.js +1 -2
  20. package/dist/adapter/resources/webgl-buffer.js +14 -14
  21. package/dist/adapter/resources/webgl-command-buffer.js +25 -25
  22. package/dist/adapter/resources/webgl-external-texture.js +3 -3
  23. package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -4
  24. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  25. package/dist/adapter/resources/webgl-framebuffer.js +41 -36
  26. package/dist/adapter/resources/webgl-query-set.js +6 -6
  27. package/dist/adapter/resources/webgl-render-pass.js +5 -5
  28. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  29. package/dist/adapter/resources/webgl-render-pipeline.js +19 -13
  30. package/dist/adapter/resources/webgl-sampler.js +2 -2
  31. package/dist/adapter/resources/webgl-shader.js +4 -4
  32. package/dist/adapter/resources/webgl-texture.d.ts +2 -1
  33. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  34. package/dist/adapter/resources/webgl-texture.js +29 -27
  35. package/dist/adapter/resources/webgl-transform-feedback.js +8 -8
  36. package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
  37. package/dist/adapter/resources/webgl-vertex-array.js +5 -5
  38. package/dist/adapter/webgl-device.d.ts +6 -3
  39. package/dist/adapter/webgl-device.d.ts.map +1 -1
  40. package/dist/adapter/webgl-device.js +22 -17
  41. package/dist/classic/accessor.js +4 -4
  42. package/dist/classic/clear.js +2 -2
  43. package/dist/classic/copy-and-blit.js +15 -16
  44. package/dist/classic/format-utils.d.ts +2 -2
  45. package/dist/classic/format-utils.js +14 -14
  46. package/dist/classic/typed-array-utils.js +18 -18
  47. package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
  48. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  49. package/dist/context/parameters/unified-parameter-api.js +4 -9
  50. package/dist/context/parameters/webgl-parameter-tables.d.ts +2 -13
  51. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  52. package/dist/context/parameters/webgl-parameter-tables.js +292 -298
  53. package/dist/context/state-tracker/with-parameters.d.ts +1 -2
  54. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  55. package/dist/context/state-tracker/with-parameters.js +2 -5
  56. package/dist/dist.dev.js +3796 -5522
  57. package/dist/dist.min.js +10 -0
  58. package/dist/index.cjs +1253 -1188
  59. package/dist/index.cjs.map +4 -4
  60. package/dist/index.d.ts +2 -2
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +1 -1
  63. package/package.json +6 -7
  64. package/src/.DS_Store +0 -0
  65. package/src/adapter/.DS_Store +0 -0
  66. package/src/adapter/converters/device-parameters.ts +9 -11
  67. package/src/adapter/converters/texture-formats.ts +64 -61
  68. package/src/adapter/device-helpers/webgl-device-features.ts +22 -2
  69. package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
  70. package/src/adapter/objects/webgl-resource.ts +1 -1
  71. package/src/adapter/resources/webgl-external-texture.ts +3 -3
  72. package/src/adapter/resources/webgl-framebuffer.ts +29 -26
  73. package/src/adapter/resources/webgl-render-pass.ts +3 -3
  74. package/src/adapter/resources/webgl-render-pipeline.ts +13 -6
  75. package/src/adapter/resources/webgl-texture.ts +7 -3
  76. package/src/adapter/webgl-device.ts +24 -19
  77. package/src/classic/clear.ts +2 -2
  78. package/src/context/.DS_Store +0 -0
  79. package/src/context/parameters/unified-parameter-api.ts +4 -16
  80. package/src/context/state-tracker/with-parameters.ts +2 -7
  81. package/src/index.ts +4 -4
  82. package/dist/adapter/device-helpers/device-features.d.ts +0 -6
  83. package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
  84. package/dist/adapter/device-helpers/device-features.js +0 -65
  85. package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
  86. package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
  87. package/dist/adapter/device-helpers/device-limits.js +0 -92
  88. package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
  89. package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
  90. package/dist/adapter/device-helpers/get-device-info.js +0 -87
  91. package/dist/context/context/context-data.d.ts +0 -14
  92. package/dist/context/context/context-data.d.ts.map +0 -1
  93. package/dist/context/context/context-data.js +0 -33
  94. package/dist/context/context/create-browser-context.d.ts +0 -35
  95. package/dist/context/context/create-browser-context.d.ts.map +0 -1
  96. package/dist/context/context/create-browser-context.js +0 -66
  97. 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(GL.MAX_TEXTURE_SIZE); }
10
- get maxTextureDimension3D() { return this.getParameter(GL.MAX_3D_TEXTURE_SIZE); }
11
- get maxTextureArrayLayers() { return this.getParameter(GL.MAX_ARRAY_TEXTURE_LAYERS); }
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(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS); } // ) TBD
16
- get maxSamplersPerShaderStage() { return this.getParameter(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS); }
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(GL.MAX_UNIFORM_BUFFER_BINDINGS); }
20
- get maxUniformBufferBindingSize() { return this.getParameter(GL.MAX_UNIFORM_BLOCK_SIZE); }
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(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT); }
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(GL.MAX_VERTEX_ATTRIBS); }
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(GL.MAX_VARYING_COMPONENTS); }
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
- GL.SAMPLER_2D,
11
- GL.SAMPLER_CUBE,
12
- GL.SAMPLER_3D,
13
- GL.SAMPLER_2D_SHADOW,
14
- GL.SAMPLER_2D_ARRAY,
15
- GL.SAMPLER_2D_ARRAY_SHADOW,
16
- GL.SAMPLER_CUBE_SHADOW,
17
- GL.INT_SAMPLER_2D,
18
- GL.INT_SAMPLER_3D,
19
- GL.INT_SAMPLER_CUBE,
20
- GL.INT_SAMPLER_2D_ARRAY,
21
- GL.UNSIGNED_INT_SAMPLER_2D,
22
- GL.UNSIGNED_INT_SAMPLER_3D,
23
- GL.UNSIGNED_INT_SAMPLER_CUBE,
24
- GL.UNSIGNED_INT_SAMPLER_2D_ARRAY
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
- [GL.FLOAT]: [GL.FLOAT, 1, 'float', 'f32', 'float32'],
29
- [GL.FLOAT_VEC2]: [GL.FLOAT, 2, 'vec2', 'vec2<f32>', 'float32x2'],
30
- [GL.FLOAT_VEC3]: [GL.FLOAT, 3, 'vec3', 'vec3<f32>', 'float32x3'],
31
- [GL.FLOAT_VEC4]: [GL.FLOAT, 4, 'vec4', 'vec4<f32>', 'float32x4'],
32
- [GL.INT]: [GL.INT, 1, 'int', 'i32', 'sint32'],
33
- [GL.INT_VEC2]: [GL.INT, 2, 'ivec2', 'vec2<i32>', 'sint32x2'],
34
- [GL.INT_VEC3]: [GL.INT, 3, 'ivec3', 'vec3<i32>', 'sint32x3'],
35
- [GL.INT_VEC4]: [GL.INT, 4, 'ivec4', 'vec4<i32>', 'sint32x4'],
36
- [GL.UNSIGNED_INT]: [GL.UNSIGNED_INT, 1, 'uint', 'u32', 'uint32'],
37
- [GL.UNSIGNED_INT_VEC2]: [GL.UNSIGNED_INT, 2, 'uvec2', 'vec2<u32>', 'uint32x2'],
38
- [GL.UNSIGNED_INT_VEC3]: [GL.UNSIGNED_INT, 3, 'uvec3', 'vec3<u32>', 'uint32x3'],
39
- [GL.UNSIGNED_INT_VEC4]: [GL.UNSIGNED_INT, 4, 'uvec4', 'vec4<u32>', 'uint32x4'],
40
- [GL.BOOL]: [GL.FLOAT, 1, 'bool', 'f32', 'float32'],
41
- [GL.BOOL_VEC2]: [GL.FLOAT, 2, 'bvec2', 'vec2<f32>', 'float32x2'],
42
- [GL.BOOL_VEC3]: [GL.FLOAT, 3, 'bvec3', 'vec3<f32>', 'float32x3'],
43
- [GL.BOOL_VEC4]: [GL.FLOAT, 4, 'bvec4', 'vec4<f32>', 'float32x4'],
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
- [GL.FLOAT_MAT2]: [GL.FLOAT, 8, 'mat2', 'mat2x2<f32>'], // 4
46
- [GL.FLOAT_MAT2x3]: [GL.FLOAT, 8, 'mat2x3', 'mat2x3<f32>'], // 6
47
- [GL.FLOAT_MAT2x4]: [GL.FLOAT, 8, 'mat2x4', 'mat2x4<f32>'], // 8
48
- [GL.FLOAT_MAT3x2]: [GL.FLOAT, 12, 'mat3x2', 'mat3x2<f32>'], // 6
49
- [GL.FLOAT_MAT3]: [GL.FLOAT, 12, 'mat3', 'mat3x3<f32>'], // 9
50
- [GL.FLOAT_MAT3x4]: [GL.FLOAT, 12, 'mat3x4', 'mat3x4<f32>'], // 12
51
- [GL.FLOAT_MAT4x2]: [GL.FLOAT, 16, 'mat4x2', 'mat4x2<f32>'], // 8
52
- [GL.FLOAT_MAT4x3]: [GL.FLOAT, 16, 'mat4x3', 'mat4x3<f32>'], // 12
53
- [GL.FLOAT_MAT4]: [GL.FLOAT, 16, 'mat4', 'mat4x4<f32>'] // 16
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 GL.BYTE:
87
- case GL.UNSIGNED_BYTE:
88
- case GL.SHORT:
89
- case GL.UNSIGNED_SHORT:
90
- type = GL.FLOAT;
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, gl.ACTIVE_ATTRIBUTES);
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, GL.TRANSFORM_FEEDBACK_VARYINGS);
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, GL.ACTIVE_UNIFORMS);
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, GL.ACTIVE_UNIFORM_BLOCKS);
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, GL.UNIFORM_BLOCK_BINDING),
177
- byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),
178
- vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),
179
- fragment: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),
180
- uniformCount: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),
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, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) || [];
184
- const uniformType = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.
185
- const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.
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, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.
192
- const uniformStride = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.
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
- [GL.SAMPLER_2D]: ['2d', 'float'],
242
- [GL.SAMPLER_CUBE]: ['cube', 'float'],
243
- [GL.SAMPLER_3D]: ['3d', 'float'],
244
- [GL.SAMPLER_2D_SHADOW]: ['3d', 'depth'],
245
- [GL.SAMPLER_2D_ARRAY]: ['2d-array', 'float'],
246
- [GL.SAMPLER_2D_ARRAY_SHADOW]: ['2d-array', 'depth'],
247
- [GL.SAMPLER_CUBE_SHADOW]: ['cube', 'float'],
248
- [GL.INT_SAMPLER_2D]: ['2d', 'sint'],
249
- [GL.INT_SAMPLER_3D]: ['3d', 'sint'],
250
- [GL.INT_SAMPLER_CUBE]: ['cube', 'sint'],
251
- [GL.INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint'],
252
- [GL.UNSIGNED_INT_SAMPLER_2D]: ['2d', 'uint'],
253
- [GL.UNSIGNED_INT_SAMPLER_3D]: ['3d', 'uint'],
254
- [GL.UNSIGNED_INT_SAMPLER_CUBE]: ['cube', 'uint'],
255
- [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint']
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 GL.SAMPLER_2D:
21
- case GL.SAMPLER_CUBE:
22
- case GL.SAMPLER_3D:
23
- case GL.SAMPLER_2D_SHADOW:
24
- case GL.SAMPLER_2D_ARRAY:
25
- case GL.SAMPLER_2D_ARRAY_SHADOW:
26
- case GL.SAMPLER_CUBE_SHADOW:
27
- case GL.INT_SAMPLER_2D:
28
- case GL.INT_SAMPLER_3D:
29
- case GL.INT_SAMPLER_CUBE:
30
- case GL.INT_SAMPLER_2D_ARRAY:
31
- case GL.UNSIGNED_INT_SAMPLER_2D:
32
- case GL.UNSIGNED_INT_SAMPLER_3D:
33
- case GL.UNSIGNED_INT_SAMPLER_CUBE:
34
- case GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
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 GL.FLOAT: return gl.uniform1fv(location, arrayValue);
40
- case GL.FLOAT_VEC2: return gl.uniform2fv(location, arrayValue);
41
- case GL.FLOAT_VEC3: return gl.uniform3fv(location, arrayValue);
42
- case GL.FLOAT_VEC4: return gl.uniform4fv(location, arrayValue);
43
- case GL.INT: return gl.uniform1iv(location, arrayValue);
44
- case GL.INT_VEC2: return gl.uniform2iv(location, arrayValue);
45
- case GL.INT_VEC3: return gl.uniform3iv(location, arrayValue);
46
- case GL.INT_VEC4: return gl.uniform4iv(location, arrayValue);
47
- case GL.BOOL: return gl.uniform1iv(location, arrayValue);
48
- case GL.BOOL_VEC2: return gl.uniform2iv(location, arrayValue);
49
- case GL.BOOL_VEC3: return gl.uniform3iv(location, arrayValue);
50
- case GL.BOOL_VEC4: return gl.uniform4iv(location, arrayValue);
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 GL.UNSIGNED_INT: return gl2.uniform1uiv(location, arrayValue, 1);
53
- case GL.UNSIGNED_INT_VEC2: return gl2.uniform2uiv(location, arrayValue, 2);
54
- case GL.UNSIGNED_INT_VEC3: return gl2.uniform3uiv(location, arrayValue, 3);
55
- case GL.UNSIGNED_INT_VEC4: return gl2.uniform4uiv(location, arrayValue, 4);
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 GL.FLOAT_MAT2: return gl.uniformMatrix2fv(location, false, arrayValue);
59
- case GL.FLOAT_MAT3: return gl.uniformMatrix3fv(location, false, arrayValue);
60
- case GL.FLOAT_MAT4: return gl.uniformMatrix4fv(location, false, arrayValue);
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 GL.FLOAT_MAT2x3: return gl2.uniformMatrix2x3fv(location, false, arrayValue);
63
- case GL.FLOAT_MAT2x4: return gl2.uniformMatrix2x4fv(location, false, arrayValue);
64
- case GL.FLOAT_MAT3x2: return gl2.uniformMatrix3x2fv(location, false, arrayValue);
65
- case GL.FLOAT_MAT3x4: return gl2.uniformMatrix3x4fv(location, false, arrayValue);
66
- case GL.FLOAT_MAT4x2: return gl2.uniformMatrix4x2fv(location, false, arrayValue);
67
- case GL.FLOAT_MAT4x3: return gl2.uniformMatrix4x3fv(location, false, arrayValue);
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 GL.POINTS:
9
- return GL.POINTS;
10
- case GL.LINES:
11
- return GL.LINES;
12
- case GL.LINE_STRIP:
13
- return GL.LINES;
14
- case GL.LINE_LOOP:
15
- return GL.LINES;
16
- case GL.TRIANGLES:
17
- return GL.TRIANGLES;
18
- case GL.TRIANGLE_STRIP:
19
- return GL.TRIANGLES;
20
- case GL.TRIANGLE_FAN:
21
- return GL.TRIANGLES;
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 GL.POINTS:
31
- case GL.LINE_LOOP:
30
+ case 0:
31
+ case 2:
32
32
  return vertexCount;
33
- case GL.LINES:
33
+ case 1:
34
34
  return vertexCount / 2;
35
- case GL.LINE_STRIP:
35
+ case 3:
36
36
  return vertexCount - 1;
37
- case GL.TRIANGLES:
37
+ case 4:
38
38
  return vertexCount / 3;
39
- case GL.TRIANGLE_STRIP:
40
- case GL.TRIANGLE_FAN:
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 GL.POINTS:
51
+ case 0:
52
52
  return primitiveCount;
53
- case GL.LINES:
53
+ case 1:
54
54
  return primitiveCount * 2;
55
- case GL.TRIANGLES:
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 GL.POINTS;
66
- case 'line-list': return GL.LINES;
67
- case 'line-strip': return GL.LINE_STRIP;
68
- case 'line-loop-webgl': return GL.LINE_LOOP;
69
- case 'triangle-list': return GL.TRIANGLES;
70
- case 'triangle-strip': return GL.TRIANGLE_STRIP;
71
- case 'triangle-fan-webgl': return GL.TRIANGLE_FAN;
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 GL.POINTS;
80
- case 'line-list': return GL.LINES;
81
- case 'line-strip': return GL.LINES;
82
- case 'line-loop-webgl': return GL.LINES;
83
- case 'triangle-list': return GL.TRIANGLES;
84
- case 'triangle-strip': return GL.TRIANGLES;
85
- case 'triangle-fan-webgl': return GL.TRIANGLES;
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(GL.RENDERBUFFER, this.handle);
74
+ this.gl.bindRenderbuffer(36161, this.handle);
75
75
  if (samples !== 0) {
76
- this.gl.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);
76
+ this.gl.renderbufferStorageMultisample(36161, samples, this.glFormat, width, height);
77
77
  }
78
78
  else {
79
- this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);
79
+ this.gl.renderbufferStorage(36161, this.glFormat, width, height);
80
80
  }
81
- this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);
82
- this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat));
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(GL.RENDERBUFFER, handle);
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 = WebGLDevice.attach(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 = GL.UNSIGNED_SHORT;
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' ? GL.UNSIGNED_INT : GL.UNSIGNED_SHORT;
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 = GL.COPY_WRITE_BUFFER;
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(GL.COPY_READ_BUFFER, this.handle);
115
- this.gl.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);
116
- this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);
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 GL.ELEMENT_ARRAY_BUFFER;
148
+ return 34963;
149
149
  }
150
150
  if (usage & Buffer.VERTEX) {
151
- return GL.ARRAY_BUFFER;
151
+ return 34962;
152
152
  }
153
153
  if (usage & Buffer.UNIFORM) {
154
- return GL.UNIFORM_BUFFER;
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 GL.ARRAY_BUFFER;
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 GL.STATIC_DRAW;
163
+ return 35044;
164
164
  }
165
165
  if (usage & Buffer.VERTEX) {
166
- return GL.STATIC_DRAW;
166
+ return 35044;
167
167
  }
168
168
  if (usage & Buffer.UNIFORM) {
169
- return GL.DYNAMIC_DRAW;
169
+ return 35048;
170
170
  }
171
- return GL.STATIC_DRAW;
171
+ return 35044;
172
172
  }