@luma.gl/webgl 9.0.0-beta.3 → 9.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/adapter/converters/device-parameters.js +240 -158
  2. package/dist/adapter/converters/sampler-parameters.d.ts +0 -4
  3. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  4. package/dist/adapter/converters/sampler-parameters.js +73 -68
  5. package/dist/adapter/converters/shader-formats.js +33 -46
  6. package/dist/adapter/converters/texture-formats.d.ts +9 -18
  7. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  8. package/dist/adapter/converters/texture-formats.js +454 -871
  9. package/dist/adapter/converters/vertex-formats.js +52 -61
  10. package/dist/adapter/device-helpers/device-features.d.ts +2 -5
  11. package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
  12. package/dist/adapter/device-helpers/device-features.js +56 -87
  13. package/dist/adapter/device-helpers/device-limits.d.ts +2 -4
  14. package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
  15. package/dist/adapter/device-helpers/device-limits.js +88 -83
  16. package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
  17. package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
  18. package/dist/adapter/device-helpers/get-device-info.js +79 -63
  19. package/dist/adapter/device-helpers/webgl-device-features.d.ts +6 -0
  20. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
  21. package/dist/adapter/device-helpers/webgl-device-features.js +52 -0
  22. package/dist/adapter/device-helpers/webgl-device-info.d.ts +4 -0
  23. package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
  24. package/dist/adapter/device-helpers/webgl-device-info.js +87 -0
  25. package/dist/adapter/device-helpers/webgl-device-limits.d.ts +50 -0
  26. package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
  27. package/dist/adapter/device-helpers/webgl-device-limits.js +92 -0
  28. package/dist/adapter/helpers/decode-webgl-types.js +87 -76
  29. package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
  30. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  31. package/dist/adapter/helpers/get-shader-layout.js +261 -226
  32. package/dist/adapter/helpers/parse-shader-compiler-log.js +46 -37
  33. package/dist/adapter/helpers/set-uniform.d.ts +1 -1
  34. package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
  35. package/dist/adapter/helpers/set-uniform.js +67 -82
  36. package/dist/adapter/helpers/webgl-topology-utils.js +77 -93
  37. package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
  38. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  39. package/dist/adapter/objects/constants-to-keys.js +18 -12
  40. package/dist/adapter/objects/webgl-renderbuffer.js +76 -80
  41. package/dist/adapter/objects/webgl-resource.d.ts +1 -1
  42. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  43. package/dist/adapter/objects/webgl-resource.js +204 -154
  44. package/dist/adapter/resources/webgl-buffer.d.ts +2 -3
  45. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  46. package/dist/adapter/resources/webgl-buffer.js +160 -119
  47. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  48. package/dist/adapter/resources/webgl-command-buffer.js +268 -171
  49. package/dist/adapter/resources/webgl-command-encoder.js +32 -40
  50. package/dist/adapter/resources/webgl-external-texture.js +92 -1
  51. package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -2
  52. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  53. package/dist/adapter/resources/webgl-framebuffer.js +167 -139
  54. package/dist/adapter/resources/webgl-render-pass.js +121 -95
  55. package/dist/adapter/resources/webgl-render-pipeline.d.ts +11 -1
  56. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgl-render-pipeline.js +378 -228
  58. package/dist/adapter/resources/webgl-sampler.d.ts +0 -2
  59. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  60. package/dist/adapter/resources/webgl-sampler.js +43 -34
  61. package/dist/adapter/resources/webgl-shader.d.ts +10 -1
  62. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  63. package/dist/adapter/resources/webgl-shader.js +106 -45
  64. package/dist/adapter/resources/webgl-texture.d.ts +2 -6
  65. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  66. package/dist/adapter/resources/webgl-texture.js +614 -699
  67. package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
  68. package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
  69. package/dist/adapter/resources/webgl-transform-feedback.js +143 -145
  70. package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
  71. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  72. package/dist/adapter/resources/webgl-vertex-array.js +229 -158
  73. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  74. package/dist/adapter/webgl-canvas-context.js +58 -37
  75. package/dist/adapter/webgl-device.d.ts +7 -15
  76. package/dist/adapter/webgl-device.d.ts.map +1 -1
  77. package/dist/adapter/webgl-device.js +440 -381
  78. package/dist/classic/accessor.js +132 -102
  79. package/dist/classic/clear.d.ts +2 -2
  80. package/dist/classic/clear.d.ts.map +1 -1
  81. package/dist/classic/clear.js +73 -73
  82. package/dist/classic/copy-and-blit.d.ts.map +1 -1
  83. package/dist/classic/copy-and-blit.js +176 -177
  84. package/dist/classic/format-utils.d.ts +2 -2
  85. package/dist/classic/format-utils.js +38 -32
  86. package/dist/classic/typed-array-utils.js +95 -81
  87. package/dist/context/{polyfill → context}/context-data.d.ts +2 -1
  88. package/dist/context/context/context-data.d.ts.map +1 -0
  89. package/dist/context/context/context-data.js +33 -0
  90. package/dist/context/context/create-browser-context.d.ts +1 -6
  91. package/dist/context/context/create-browser-context.d.ts.map +1 -1
  92. package/dist/context/context/create-browser-context.js +62 -49
  93. package/dist/context/debug/spector.js +54 -50
  94. package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
  95. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  96. package/dist/context/debug/webgl-developer-tools.js +102 -76
  97. package/dist/context/parameters/unified-parameter-api.d.ts +3 -3
  98. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  99. package/dist/context/parameters/unified-parameter-api.js +95 -46
  100. package/dist/context/parameters/webgl-parameter-tables.d.ts +110 -99
  101. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  102. package/dist/context/parameters/webgl-parameter-tables.js +456 -404
  103. package/dist/context/state-tracker/deep-array-equal.js +18 -14
  104. package/dist/context/state-tracker/track-context-state.d.ts +4 -4
  105. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  106. package/dist/context/state-tracker/track-context-state.js +190 -126
  107. package/dist/context/state-tracker/with-parameters.d.ts +1 -1
  108. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  109. package/dist/context/state-tracker/with-parameters.js +45 -29
  110. package/dist/dist.dev.js +2568 -3786
  111. package/dist/index.cjs +1346 -2464
  112. package/dist/index.cjs.map +7 -0
  113. package/dist/index.d.ts +2 -5
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +36 -26
  116. package/dist/types.js +2 -1
  117. package/dist.min.js +9 -42
  118. package/package.json +11 -15
  119. package/src/adapter/converters/device-parameters.ts +0 -1
  120. package/src/adapter/converters/sampler-parameters.ts +0 -17
  121. package/src/adapter/converters/texture-formats.ts +86 -154
  122. package/src/adapter/device-helpers/webgl-device-features.ts +69 -0
  123. package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +3 -4
  124. package/src/adapter/device-helpers/{device-limits.ts → webgl-device-limits.ts} +25 -23
  125. package/src/adapter/helpers/get-shader-layout.ts +17 -28
  126. package/src/adapter/helpers/set-uniform.ts +1 -3
  127. package/src/adapter/objects/constants-to-keys.ts +1 -1
  128. package/src/adapter/objects/webgl-renderbuffer.ts +4 -4
  129. package/src/adapter/objects/webgl-resource.ts +3 -18
  130. package/src/adapter/resources/webgl-buffer.ts +6 -11
  131. package/src/adapter/resources/webgl-command-buffer.ts +20 -30
  132. package/src/adapter/resources/webgl-external-texture.ts +2 -3
  133. package/src/adapter/resources/webgl-framebuffer.ts +4 -5
  134. package/src/adapter/resources/webgl-render-pass.ts +7 -7
  135. package/src/adapter/resources/webgl-render-pipeline.ts +106 -31
  136. package/src/adapter/resources/webgl-sampler.ts +5 -9
  137. package/src/adapter/resources/webgl-shader.ts +57 -10
  138. package/src/adapter/resources/webgl-texture.ts +29 -103
  139. package/src/adapter/resources/webgl-transform-feedback.ts +14 -15
  140. package/src/adapter/resources/webgl-vertex-array.ts +16 -18
  141. package/src/adapter/webgl-canvas-context.ts +1 -7
  142. package/src/adapter/webgl-device.ts +18 -67
  143. package/src/classic/clear.ts +13 -14
  144. package/src/classic/copy-and-blit.ts +1 -2
  145. package/src/context/context/context-data.ts +44 -0
  146. package/src/context/context/create-browser-context.ts +7 -32
  147. package/src/context/debug/webgl-developer-tools.ts +6 -8
  148. package/src/context/parameters/unified-parameter-api.ts +3 -3
  149. package/src/context/parameters/webgl-parameter-tables.ts +66 -75
  150. package/src/context/state-tracker/track-context-state.ts +18 -17
  151. package/src/context/state-tracker/with-parameters.ts +1 -1
  152. package/src/index.ts +2 -17
  153. package/dist/adapter/converters/device-parameters.js.map +0 -1
  154. package/dist/adapter/converters/sampler-parameters.js.map +0 -1
  155. package/dist/adapter/converters/shader-formats.js.map +0 -1
  156. package/dist/adapter/converters/texture-formats.js.map +0 -1
  157. package/dist/adapter/converters/vertex-formats.js.map +0 -1
  158. package/dist/adapter/device-helpers/device-features.js.map +0 -1
  159. package/dist/adapter/device-helpers/device-limits.js.map +0 -1
  160. package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
  161. package/dist/adapter/device-helpers/is-old-ie.d.ts +0 -2
  162. package/dist/adapter/device-helpers/is-old-ie.d.ts.map +0 -1
  163. package/dist/adapter/device-helpers/is-old-ie.js +0 -9
  164. package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
  165. package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
  166. package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
  167. package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
  168. package/dist/adapter/helpers/set-uniform.js.map +0 -1
  169. package/dist/adapter/helpers/webgl-topology-utils.js.map +0 -1
  170. package/dist/adapter/objects/constants-to-keys.js.map +0 -1
  171. package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
  172. package/dist/adapter/objects/webgl-resource.js.map +0 -1
  173. package/dist/adapter/resources/webgl-buffer.js.map +0 -1
  174. package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
  175. package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
  176. package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
  177. package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
  178. package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
  179. package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
  180. package/dist/adapter/resources/webgl-sampler.js.map +0 -1
  181. package/dist/adapter/resources/webgl-shader.js.map +0 -1
  182. package/dist/adapter/resources/webgl-texture.js.map +0 -1
  183. package/dist/adapter/resources/webgl-transform-feedback.js.map +0 -1
  184. package/dist/adapter/resources/webgl-vertex-array.js.map +0 -1
  185. package/dist/adapter/webgl-canvas-context.js.map +0 -1
  186. package/dist/adapter/webgl-device.js.map +0 -1
  187. package/dist/classic/accessor.js.map +0 -1
  188. package/dist/classic/clear.js.map +0 -1
  189. package/dist/classic/copy-and-blit.js.map +0 -1
  190. package/dist/classic/format-utils.js.map +0 -1
  191. package/dist/classic/typed-array-utils.js.map +0 -1
  192. package/dist/context/context/create-browser-context.js.map +0 -1
  193. package/dist/context/context/create-headless-context.d.ts +0 -9
  194. package/dist/context/context/create-headless-context.d.ts.map +0 -1
  195. package/dist/context/context/create-headless-context.js +0 -42
  196. package/dist/context/context/create-headless-context.js.map +0 -1
  197. package/dist/context/context/webgl-checks.d.ts +0 -13
  198. package/dist/context/context/webgl-checks.d.ts.map +0 -1
  199. package/dist/context/context/webgl-checks.js +0 -31
  200. package/dist/context/context/webgl-checks.js.map +0 -1
  201. package/dist/context/debug/spector.js.map +0 -1
  202. package/dist/context/debug/webgl-developer-tools.js.map +0 -1
  203. package/dist/context/parameters/unified-parameter-api.js.map +0 -1
  204. package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
  205. package/dist/context/polyfill/context-data.d.ts.map +0 -1
  206. package/dist/context/polyfill/context-data.js +0 -12
  207. package/dist/context/polyfill/context-data.js.map +0 -1
  208. package/dist/context/polyfill/get-parameter-polyfill.d.ts +0 -2
  209. package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +0 -1
  210. package/dist/context/polyfill/get-parameter-polyfill.js +0 -85
  211. package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
  212. package/dist/context/polyfill/polyfill-context.d.ts +0 -5
  213. package/dist/context/polyfill/polyfill-context.d.ts.map +0 -1
  214. package/dist/context/polyfill/polyfill-context.js +0 -87
  215. package/dist/context/polyfill/polyfill-context.js.map +0 -1
  216. package/dist/context/polyfill/polyfill-table.d.ts +0 -48
  217. package/dist/context/polyfill/polyfill-table.d.ts.map +0 -1
  218. package/dist/context/polyfill/polyfill-table.js +0 -137
  219. package/dist/context/polyfill/polyfill-table.js.map +0 -1
  220. package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +0 -2
  221. package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +0 -1
  222. package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -265
  223. package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
  224. package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
  225. package/dist/context/state-tracker/track-context-state.js.map +0 -1
  226. package/dist/context/state-tracker/with-parameters.js.map +0 -1
  227. package/dist/index.js.map +0 -1
  228. package/dist/types.js.map +0 -1
  229. package/src/adapter/device-helpers/device-features.ts +0 -161
  230. package/src/adapter/device-helpers/is-old-ie.ts +0 -14
  231. package/src/context/context/create-headless-context.ts +0 -51
  232. package/src/context/context/webgl-checks.ts +0 -51
  233. package/src/context/polyfill/context-data.ts +0 -30
  234. package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
  235. package/src/context/polyfill/polyfill-context.ts +0 -104
  236. package/src/context/polyfill/polyfill-table.ts +0 -167
  237. package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
@@ -3,39 +3,37 @@
3
3
 
4
4
  import type {DeviceLimits} from '@luma.gl/core';
5
5
  import {GL} from '@luma.gl/constants';
6
- import {getWebGL2Context} from '../../context/context/webgl-checks';
7
6
 
8
7
  /** Populate a WebGPU style device limits */
9
- export function getDeviceLimits(gl: WebGLRenderingContext): DeviceLimits {
10
- const gl2: WebGL2RenderingContext | null = getWebGL2Context(gl);
8
+ export function getDeviceLimits(gl: WebGL2RenderingContext): DeviceLimits {
11
9
  return {
12
10
  maxTextureDimension1D: 0, // WebGL does not support 1D textures
13
11
  maxTextureDimension2D: gl.getParameter(GL.MAX_TEXTURE_SIZE),
14
- maxTextureDimension3D: gl2 ? gl2.getParameter(GL.MAX_3D_TEXTURE_SIZE) : 0,
15
- maxTextureArrayLayers: gl2 ? gl2.getParameter(GL.MAX_ARRAY_TEXTURE_LAYERS) : 0,
16
- maxBindGroups: 1, // TBD
12
+ maxTextureDimension3D: gl.getParameter(GL.MAX_3D_TEXTURE_SIZE),
13
+ maxTextureArrayLayers: gl.getParameter(GL.MAX_ARRAY_TEXTURE_LAYERS),
14
+ maxBindGroups: 1, // TBD - if we emulate bind groups we could support any number...
17
15
  maxDynamicUniformBuffersPerPipelineLayout: 0, // TBD
18
16
  maxDynamicStorageBuffersPerPipelineLayout: 0, // TBD
19
17
  maxSampledTexturesPerShaderStage: gl.getParameter(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS), // TBD
20
18
  maxSamplersPerShaderStage: gl.getParameter(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
21
19
  maxStorageBuffersPerShaderStage: 0, // TBD
22
20
  maxStorageTexturesPerShaderStage: 0, // TBD
23
- maxUniformBuffersPerShaderStage: gl2 ? gl2.getParameter(GL.MAX_UNIFORM_BUFFER_BINDINGS) : 0,
24
- maxUniformBufferBindingSize: gl2 ? gl2.getParameter(GL.MAX_UNIFORM_BLOCK_SIZE) : 0,
21
+ maxUniformBuffersPerShaderStage: gl.getParameter(GL.MAX_UNIFORM_BUFFER_BINDINGS),
22
+ maxUniformBufferBindingSize: gl.getParameter(GL.MAX_UNIFORM_BLOCK_SIZE),
25
23
  maxStorageBufferBindingSize: 0,
26
- minUniformBufferOffsetAlignment: gl2 ? gl2.getParameter(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT) : 0,
24
+ minUniformBufferOffsetAlignment: gl.getParameter(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT),
27
25
  minStorageBufferOffsetAlignment: 0, // TBD
28
26
  maxVertexBuffers: 0,
29
27
  maxVertexAttributes: gl.getParameter(GL.MAX_VERTEX_ATTRIBS),
30
28
  maxVertexBufferArrayStride: 2048, // TBD, this is just the default value from WebGPU
31
- maxInterStageShaderComponents: gl2 ? gl2.getParameter(GL.MAX_VARYING_COMPONENTS) : 0,
29
+ maxInterStageShaderComponents: gl.getParameter(GL.MAX_VARYING_COMPONENTS),
32
30
  maxComputeWorkgroupStorageSize: 0, // WebGL does not support compute shaders
33
31
  maxComputeInvocationsPerWorkgroup: 0, // WebGL does not support compute shaders
34
32
  maxComputeWorkgroupSizeX: 0, // WebGL does not support compute shaders
35
33
  maxComputeWorkgroupSizeY: 0, // WebGL does not support compute shaders
36
34
  maxComputeWorkgroupSizeZ: 0, // WebGL does not support compute shaders
37
- maxComputeWorkgroupsPerDimension: 0, // WebGL does not support compute shaders
38
- }
35
+ maxComputeWorkgroupsPerDimension: 0 // WebGL does not support compute shaders
36
+ };
39
37
  }
40
38
 
41
39
  /** WebGL context limits */
@@ -60,7 +58,7 @@ export type WebGLLimits = {
60
58
  // WebGL2 Limits
61
59
  [GL.MAX_3D_TEXTURE_SIZE]: number;
62
60
  [GL.MAX_ARRAY_TEXTURE_LAYERS]: number;
63
- [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: number;
61
+ // [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: number;
64
62
  [GL.MAX_COLOR_ATTACHMENTS]: number;
65
63
  [GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: number;
66
64
  [GL.MAX_COMBINED_UNIFORM_BLOCKS]: number;
@@ -73,7 +71,7 @@ export type WebGLLimits = {
73
71
  [GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: number;
74
72
  [GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: number;
75
73
  [GL.MAX_SAMPLES]: number;
76
- [GL.MAX_SERVER_WAIT_TIMEOUT]: number;
74
+ // [GL.MAX_SERVER_WAIT_TIMEOUT]: number;
77
75
  [GL.MAX_TEXTURE_LOD_BIAS]: number;
78
76
  [GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: number;
79
77
  [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: number;
@@ -89,16 +87,14 @@ export type WebGLLimits = {
89
87
  [GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: number;
90
88
  };
91
89
 
92
-
93
- export function getWebGLLimits(gl: WebGLRenderingContext): WebGLLimits {
94
- const gl2 = getWebGL2Context(gl);
90
+ export function getWebGLLimits(gl: WebGL2RenderingContext): WebGLLimits {
95
91
  function get<T = number>(pname: number): T {
96
92
  return gl.getParameter(pname) as T;
97
93
  }
98
94
  function get2(pname: number, defaultValue?: number): number;
99
95
  function get2<T>(pname: number, defaultValue: T): T;
100
96
  function get2<T>(pname: number, defaultValue: T): T {
101
- return gl2 ? gl2.getParameter(pname) as T : (defaultValue || 0) as T;
97
+ return (gl.getParameter(pname) as T) || defaultValue;
102
98
  }
103
99
  // function getMaxAnistropy() {
104
100
  // const extension = gl.getExtension('EXT_texture_filter_anisotropic');
@@ -124,9 +120,11 @@ export function getWebGLLimits(gl: WebGLRenderingContext): WebGLLimits {
124
120
  // WebGL2 Limits
125
121
  [GL.MAX_3D_TEXTURE_SIZE]: get2(GL.MAX_3D_TEXTURE_SIZE), // GLint
126
122
  [GL.MAX_ARRAY_TEXTURE_LAYERS]: get2(GL.MAX_ARRAY_TEXTURE_LAYERS), // GLint
127
- [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: get2(GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL), // GLint64
123
+ // [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: get2(GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL), // GLint64
128
124
  [GL.MAX_COLOR_ATTACHMENTS]: get2(GL.MAX_COLOR_ATTACHMENTS), // GLint
129
- [GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: get2(GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS), // GLint64
125
+ [GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: get2(
126
+ GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS
127
+ ), // GLint64
130
128
  [GL.MAX_COMBINED_UNIFORM_BLOCKS]: get2(GL.MAX_COMBINED_UNIFORM_BLOCKS), // GLint
131
129
  [GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: get2(GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS), // GLint64
132
130
  [GL.MAX_DRAW_BUFFERS]: get2(GL.MAX_DRAW_BUFFERS), // GLint
@@ -137,11 +135,15 @@ export function getWebGLLimits(gl: WebGLRenderingContext): WebGLLimits {
137
135
  [GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: get2(GL.MAX_FRAGMENT_UNIFORM_BLOCKS), // GLint
138
136
  [GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: get2(GL.MAX_FRAGMENT_UNIFORM_COMPONENTS), // GLint
139
137
  [GL.MAX_SAMPLES]: get2(GL.MAX_SAMPLES), // GLint
140
- [GL.MAX_SERVER_WAIT_TIMEOUT]: get2(GL.MAX_SERVER_WAIT_TIMEOUT), // GLint64
138
+ // [GL.MAX_SERVER_WAIT_TIMEOUT]: get2(GL.MAX_SERVER_WAIT_TIMEOUT), // GLint64
141
139
  [GL.MAX_TEXTURE_LOD_BIAS]: get2(GL.MAX_TEXTURE_LOD_BIAS), // GLfloat
142
- [GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: get2(GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS), // GLint
140
+ [GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: get2(
141
+ GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS
142
+ ), // GLint
143
143
  [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: get2(GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS), // GLint
144
- [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: get2(GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS), // GLint
144
+ [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: get2(
145
+ GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS
146
+ ), // GLint
145
147
  [GL.MAX_UNIFORM_BLOCK_SIZE]: get2(GL.MAX_UNIFORM_BLOCK_SIZE), // GLint64
146
148
  [GL.MAX_UNIFORM_BUFFER_BINDINGS]: get2(GL.MAX_UNIFORM_BUFFER_BINDINGS), // GLint
147
149
  [GL.MAX_VARYING_COMPONENTS]: get2(GL.MAX_VARYING_COMPONENTS), // GLint
@@ -10,7 +10,6 @@ import type {
10
10
  } from '@luma.gl/core';
11
11
 
12
12
  import {GL} from '@luma.gl/constants';
13
- import {isWebGL2} from '../../context/context/webgl-checks';
14
13
  import {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API
15
14
  import {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './decode-webgl-types';
16
15
 
@@ -19,7 +18,7 @@ import {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './de
19
18
  * Note: `linkProgram()` needs to have been called
20
19
  * (although linking does not need to have been successful).
21
20
  */
22
- export function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram): ShaderLayout {
21
+ export function getShaderLayout(gl: WebGL2RenderingContext, program: WebGLProgram): ShaderLayout {
23
22
  const shaderLayout: ShaderLayout = {
24
23
  attributes: [],
25
24
  bindings: []
@@ -88,7 +87,7 @@ export function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram
88
87
  * linkProgram needs to have been called, although linking does not need to have been successful
89
88
  */
90
89
  function readAttributeDeclarations(
91
- gl: WebGLRenderingContext,
90
+ gl: WebGL2RenderingContext,
92
91
  program: WebGLProgram
93
92
  ): AttributeDeclaration[] {
94
93
  const attributes: AttributeDeclaration[] = [];
@@ -132,17 +131,12 @@ function readAttributeDeclarations(
132
131
  *
133
132
  * linkProgram needs to have been called, although linking does not need to have been successful
134
133
  */
135
- function readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): VaryingBinding[] {
136
- if (!isWebGL2(gl)) {
137
- return [];
138
- }
139
- const gl2 = gl as WebGL2RenderingContext;
140
-
134
+ function readVaryings(gl: WebGL2RenderingContext, program: WebGLProgram): VaryingBinding[] {
141
135
  const varyings: VaryingBinding[] = [];
142
136
 
143
137
  const count = gl.getProgramParameter(program, GL.TRANSFORM_FEEDBACK_VARYINGS);
144
138
  for (let location = 0; location < count; location++) {
145
- const activeInfo = gl2.getTransformFeedbackVarying(program, location);
139
+ const activeInfo = gl.getTransformFeedbackVarying(program, location);
146
140
  if (!activeInfo) {
147
141
  throw new Error('activeInfo');
148
142
  }
@@ -162,7 +156,7 @@ function readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): Varying
162
156
  *
163
157
  * Query uniform locations and build name to setter map.
164
158
  */
165
- function readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram): UniformBinding[] {
159
+ function readUniformBindings(gl: WebGL2RenderingContext, program: WebGLProgram): UniformBinding[] {
166
160
  const uniforms: UniformBinding[] = [];
167
161
 
168
162
  const uniformCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORMS);
@@ -209,23 +203,18 @@ function readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram):
209
203
  * @note In WebGL, "active" just means that unused (inactive) blocks may have been optimized away during linking)
210
204
  */
211
205
  function readUniformBlocks(
212
- gl: WebGLRenderingContext,
206
+ gl: WebGL2RenderingContext,
213
207
  program: WebGLProgram
214
208
  ): UniformBlockBinding[] {
215
- if (!isWebGL2(gl)) {
216
- return [];
217
- }
218
- const gl2 = gl as WebGL2RenderingContext;
219
-
220
209
  const getBlockParameter = (blockIndex: number, pname: GL): any =>
221
- gl2.getActiveUniformBlockParameter(program, blockIndex, pname);
210
+ gl.getActiveUniformBlockParameter(program, blockIndex, pname);
222
211
 
223
212
  const uniformBlocks: UniformBlockBinding[] = [];
224
213
 
225
- const blockCount = gl2.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);
214
+ const blockCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);
226
215
  for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
227
216
  const blockInfo: UniformBlockBinding = {
228
- name: gl2.getActiveUniformBlockName(program, blockIndex) || '',
217
+ name: gl.getActiveUniformBlockName(program, blockIndex) || '',
229
218
  location: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_BINDING),
230
219
  byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),
231
220
  vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),
@@ -237,23 +226,23 @@ function readUniformBlocks(
237
226
  const uniformIndices =
238
227
  (getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) as number[]) || [];
239
228
 
240
- const uniformType = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.
241
- const uniformArrayLength = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.
242
- // const uniformBlockIndex = gl2.getActiveUniforms(
229
+ const uniformType = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.
230
+ const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.
231
+ // const uniformBlockIndex = gl.getActiveUniforms(
243
232
  // program,
244
233
  // uniformIndices,
245
234
  // GL.UNIFORM_BLOCK_INDEX
246
235
  // ); // Array of GLint indicating the block indices of the uniforms.
247
- const uniformOffset = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.
248
- const uniformStride = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.
249
- // const uniformMatrixStride = gl2.getActiveUniforms(
236
+ const uniformOffset = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.
237
+ const uniformStride = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.
238
+ // const uniformMatrixStride = gl.getActiveUniforms(
250
239
  // program,
251
240
  // uniformIndices,
252
241
  // GL.UNIFORM_MATRIX_STRIDE
253
242
  // ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.
254
- // const uniformRowMajor = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
243
+ // const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
255
244
  for (let i = 0; i < blockInfo.uniformCount; ++i) {
256
- const activeInfo = gl2.getActiveUniform(program, uniformIndices[i]);
245
+ const activeInfo = gl.getActiveUniform(program, uniformIndices[i]);
257
246
  if (!activeInfo) {
258
247
  throw new Error('activeInfo');
259
248
  }
@@ -10,7 +10,7 @@ import {GL, GLCompositeType, GLSamplerType} from '@luma.gl/constants';
10
10
  /** Set a raw uniform (without type conversion and caching) */
11
11
  /* eslint-disable max-len */
12
12
  export function setUniform(
13
- gl: WebGLRenderingContext,
13
+ gl: WebGL2RenderingContext,
14
14
  location: WebGLUniformLocation,
15
15
  type: GLCompositeType | GLSamplerType,
16
16
  value: UniformValue
@@ -29,10 +29,8 @@ export function setUniform(
29
29
 
30
30
  // prettier-ignore
31
31
  switch (type) {
32
- // WebGL1 samplers
33
32
  case GL.SAMPLER_2D:
34
33
  case GL.SAMPLER_CUBE:
35
- // WebGL2 samplers
36
34
  case GL.SAMPLER_3D:
37
35
  case GL.SAMPLER_2D_SHADOW:
38
36
  case GL.SAMPLER_2D_ARRAY:
@@ -5,7 +5,7 @@ import {assert} from '@luma.gl/core';
5
5
  import {GL} from '@luma.gl/constants';
6
6
 
7
7
  // Resolve a WebGL enumeration name (returns itself if already a number)
8
- export function getKeyValue(gl: WebGLRenderingContext, name: string | GL): GL {
8
+ export function getKeyValue(gl: WebGL2RenderingContext, name: string | GL): GL {
9
9
  // If not a string, return (assume number)
10
10
  if (typeof name !== 'string') {
11
11
  return name;
@@ -57,7 +57,7 @@ export class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {
57
57
  throw new Error('Renderbuffer');
58
58
  }
59
59
  super(device, props, WEBGLRenderbuffer.defaultProps);
60
- this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);
60
+ this.glFormat = convertTextureFormatToGL(this.props.format);
61
61
  this._initialize(this.props);
62
62
  }
63
63
 
@@ -80,8 +80,8 @@ export class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {
80
80
 
81
81
  this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);
82
82
 
83
- if (samples !== 0 && this.device.isWebGL2) {
84
- this.gl2.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);
83
+ if (samples !== 0) {
84
+ this.gl.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);
85
85
  } else {
86
86
  this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);
87
87
  }
@@ -89,7 +89,7 @@ export class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {
89
89
  this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);
90
90
 
91
91
  this.trackAllocatedMemory(
92
- width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2)
92
+ width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat)
93
93
  );
94
94
  }
95
95
 
@@ -4,7 +4,6 @@
4
4
  import {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/core';
5
5
  import type {Device, ResourceProps} from '@luma.gl/core';
6
6
  import {GL} from '@luma.gl/constants';
7
- import {isWebGL2, assertWebGLContext} from '../../context/context/webgl-checks';
8
7
  import {WebGLDevice} from '../webgl-device';
9
8
 
10
9
  // Requires full GL enum to be bundled... Make these bindings dependent on dynamic import (debug)?
@@ -17,7 +16,7 @@ const ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual met
17
16
  */
18
17
  export abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {
19
18
  readonly device: WebGLDevice;
20
- readonly gl: WebGLRenderingContext;
19
+ readonly gl: WebGL2RenderingContext;
21
20
  readonly gl2: WebGL2RenderingContext;
22
21
  private _handle: any;
23
22
 
@@ -31,12 +30,10 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
31
30
  this.device = WebGLDevice.attach(device);
32
31
  const gl = this.device.gl;
33
32
 
34
- assertWebGLContext(gl);
35
-
36
33
  // extends
37
34
  const {id} = props || {};
38
35
  this.gl = gl;
39
- this.gl2 = gl as WebGL2RenderingContext;
36
+ this.gl2 = gl ;
40
37
  this.id = id || uid(this.constructor.name);
41
38
 
42
39
  // Set the handle
@@ -133,18 +130,12 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
133
130
  // Use parameter definitions to handle unsupported parameters
134
131
  const parameter = parameters[pname];
135
132
  if (parameter) {
136
- const isWebgl2 = isWebGL2(this.gl);
137
-
138
133
  // Check if we can query for this parameter
139
134
  const parameterAvailable =
140
- (!('webgl2' in parameter) || isWebgl2) &&
141
135
  (!('extension' in parameter) || this.gl.getExtension(parameter.extension));
142
136
 
143
137
  if (!parameterAvailable) {
144
- const webgl1Default = parameter.webgl1;
145
- const webgl2Default = 'webgl2' in parameter ? parameter.webgl2 : parameter.webgl1;
146
- const defaultValue = isWebgl2 ? webgl2Default : webgl1Default;
147
- return defaultValue;
138
+ return parameter.webgl2;
148
139
  }
149
140
  }
150
141
 
@@ -163,8 +154,6 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
163
154
  // @ts-expect-error
164
155
  const PARAMETERS = this.constructor.PARAMETERS || {};
165
156
 
166
- const isWebgl2 = isWebGL2(this.gl);
167
-
168
157
  const values: Record<string, any> = {};
169
158
 
170
159
  // Query all parameters if no list provided
@@ -177,7 +166,6 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
177
166
  // Check if this parameter is available on this platform
178
167
  const parameterAvailable =
179
168
  parameter &&
180
- (!('webgl2' in parameter) || isWebgl2) &&
181
169
  (!('extension' in parameter) || this.gl.getExtension(parameter.extension));
182
170
 
183
171
  if (parameterAvailable) {
@@ -210,11 +198,8 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
210
198
 
211
199
  const parameter = parameters[pname];
212
200
  if (parameter) {
213
- const isWebgl2 = isWebGL2(this.gl);
214
-
215
201
  // Check if this parameter is available on this platform
216
202
  const parameterAvailable =
217
- (!('webgl2' in parameter) || isWebgl2) &&
218
203
  (!('extension' in parameter) || this.gl.getExtension(parameter.extension));
219
204
 
220
205
  if (!parameterAvailable) {
@@ -9,8 +9,7 @@ import {WebGLDevice} from '../webgl-device';
9
9
  /** WebGL Buffer interface */
10
10
  export class WEBGLBuffer extends Buffer {
11
11
  readonly device: WebGLDevice;
12
- readonly gl: WebGLRenderingContext;
13
- readonly gl2: WebGL2RenderingContext | null;
12
+ readonly gl: WebGL2RenderingContext;
14
13
  readonly handle: WebGLBuffer;
15
14
 
16
15
  /** Target in OpenGL defines the type of buffer */
@@ -30,7 +29,6 @@ export class WEBGLBuffer extends Buffer {
30
29
 
31
30
  this.device = device;
32
31
  this.gl = this.device.gl;
33
- this.gl2 = this.device.gl2;
34
32
 
35
33
  const handle = typeof props === 'object' ? props.handle : undefined;
36
34
  this.handle = handle || this.gl.createBuffer();
@@ -118,12 +116,11 @@ export class WEBGLBuffer extends Buffer {
118
116
 
119
117
  // Create the buffer - binding it here for the first time locks the type
120
118
  // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type
121
- const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;
119
+ const glTarget = GL.COPY_WRITE_BUFFER;
122
120
  this.gl.bindBuffer(glTarget, this.handle);
123
121
  // WebGL2: subData supports additional srcOffset and length parameters
124
122
  if (srcOffset !== 0 || byteLength !== undefined) {
125
- this.device.assertWebGL2();
126
- this.gl2.bufferSubData(glTarget, byteOffset, data, srcOffset, byteLength);
123
+ this.gl.bufferSubData(glTarget, byteOffset, data, srcOffset, byteLength);
127
124
  } else {
128
125
  this.gl.bufferSubData(glTarget, byteOffset, data);
129
126
  }
@@ -134,20 +131,18 @@ export class WEBGLBuffer extends Buffer {
134
131
 
135
132
  /** Asynchronously read data from the buffer */
136
133
  override async readAsync(byteOffset = 0, byteLength?: number): Promise<Uint8Array> {
137
- return this.readSyncWebGL2(byteOffset, byteLength);
134
+ return this.readSyncWebGL(byteOffset, byteLength);
138
135
  }
139
136
 
140
137
  /** Synchronously read data from the buffer. WebGL only. */
141
- override readSyncWebGL2(byteOffset = 0, byteLength?: number): Uint8Array {
142
- this.device.assertWebGL2();
143
-
138
+ override readSyncWebGL(byteOffset = 0, byteLength?: number): Uint8Array {
144
139
  byteLength = byteLength ?? this.byteLength - byteOffset;
145
140
  const data = new Uint8Array(byteLength);
146
141
  const dstOffset = 0;
147
142
 
148
143
  // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type
149
144
  this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);
150
- this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);
145
+ this.gl.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);
151
146
  this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);
152
147
 
153
148
  // Update local `data` if offsets are 0
@@ -79,26 +79,19 @@ function _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOpt
79
79
  const source = cast<WEBGLBuffer>(options.source);
80
80
  const destination = cast<WEBGLBuffer>(options.destination);
81
81
 
82
- const gl2 = device.assertWebGL2();
83
- if (gl2) {
84
- // In WebGL2 we can perform the copy on the GPU
85
- // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type
86
- gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);
87
- gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);
88
- gl2.copyBufferSubData(
89
- GL.COPY_READ_BUFFER,
90
- GL.COPY_WRITE_BUFFER,
91
- options.sourceOffset ?? 0,
92
- options.destinationOffset ?? 0,
93
- options.size
94
- );
95
- gl2.bindBuffer(GL.COPY_READ_BUFFER, null);
96
- gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);
97
- } else {
98
- // TODO - in WebGL1 we would have to read back to CPU
99
- // read / write buffer from / to CPU
100
- throw new Error('copyBufferToBuffer not implemented in WebGL1');
101
- }
82
+ // {In WebGL2 we can p}erform the copy on the GPU
83
+ // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type
84
+ device.gl.bindBuffer(GL.COPY_READ_BUFFER, source.handle);
85
+ device.gl.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);
86
+ device.gl.copyBufferSubData(
87
+ GL.COPY_READ_BUFFER,
88
+ GL.COPY_WRITE_BUFFER,
89
+ options.sourceOffset ?? 0,
90
+ options.destinationOffset ?? 0,
91
+ options.size
92
+ );
93
+ device.gl.bindBuffer(GL.COPY_READ_BUFFER, null);
94
+ device.gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);
102
95
  }
103
96
 
104
97
  /**
@@ -158,14 +151,12 @@ function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferO
158
151
  }
159
152
 
160
153
  // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature
161
- const gl2 = device.assertWebGL2();
162
-
163
154
  const {framebuffer, destroyFramebuffer} = getFramebuffer(source);
164
155
  try {
165
156
  const webglBuffer = destination as WEBGLBuffer;
166
157
  const sourceWidth = width || framebuffer.width;
167
158
  const sourceHeight = height || framebuffer.height;
168
- const sourceParams = getWebGLTextureParameters(framebuffer.texture.format, true);
159
+ const sourceParams = getWebGLTextureParameters(framebuffer.texture.format);
169
160
  const sourceFormat = sourceParams.dataFormat;
170
161
  const sourceType = sourceParams.type;
171
162
 
@@ -177,10 +168,10 @@ function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferO
177
168
  // target = device.createBuffer({byteLength});
178
169
  // }
179
170
 
180
- gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);
181
- gl2.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
171
+ device.gl.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);
172
+ device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
182
173
 
183
- gl2.readPixels(
174
+ device.gl.readPixels(
184
175
  origin[0],
185
176
  origin[1],
186
177
  sourceWidth,
@@ -190,8 +181,8 @@ function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferO
190
181
  byteOffset
191
182
  );
192
183
  } finally {
193
- gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, null);
194
- gl2.bindFramebuffer(GL.FRAMEBUFFER, null);
184
+ device.gl.bindBuffer(GL.PIXEL_PACK_BUFFER, null);
185
+ device.gl.bindFramebuffer(GL.FRAMEBUFFER, null);
195
186
 
196
187
  if (destroyFramebuffer) {
197
188
  framebuffer.destroy();
@@ -309,8 +300,7 @@ function _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextur
309
300
  // break;
310
301
  // case GL.TEXTURE_2D_ARRAY:
311
302
  // case GL.TEXTURE_3D:
312
- // const gl2 = device.assertWebGL2();
313
- // gl2.copyTexSubImage3D(
303
+ // device.gl.copyTexSubImage3D(
314
304
  // textureTarget,
315
305
  // destinationMipmaplevel,
316
306
  // destinationX,
@@ -4,8 +4,7 @@
4
4
  /*
5
5
  export class WEBGLExternalTexture extends WEBGLTexture {
6
6
  readonly device: WebGLDevice;
7
- readonly gl: WebGLRenderingContext;
8
- readonly gl2: WebGL2RenderingContext | null;
7
+ readonly gl: WebGL2RenderingContext;
9
8
  readonly handle: WebGLTexture;
10
9
 
11
10
  data;
@@ -53,7 +52,7 @@ export class WEBGLExternalTexture extends WEBGLTexture {
53
52
  }
54
53
 
55
54
  // eslint-disable-next-line max-statements
56
- constructor(device: Device | WebGLRenderingContext, props: TextureProps) {
55
+ constructor(device: Device | WebGL2RenderingContext, props: TextureProps) {
57
56
  super(WebGLDevice.attach(device), {id: uid('texture'), ...props});
58
57
 
59
58
  this.glTarget = getWebGLTextureTarget(props);
@@ -15,7 +15,7 @@ export type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;
15
15
  /** luma.gl Framebuffer, WebGL implementation */
16
16
  export class WEBGLFramebuffer extends Framebuffer {
17
17
  device: WebGLDevice;
18
- gl: WebGLRenderingContext;
18
+ gl: WebGL2RenderingContext;
19
19
  handle: WebGLFramebuffer;
20
20
 
21
21
  get texture() {
@@ -165,7 +165,7 @@ export class WEBGLFramebuffer extends Framebuffer {
165
165
  * @param attachment
166
166
  * @param texture
167
167
  * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`
168
- * @param level = 0 - mipmapLevel (must be 0 in WebGL1)
168
+ * @param level = 0 - mipmapLevel
169
169
  */
170
170
  protected _attachTexture(
171
171
  attachment: GL,
@@ -173,14 +173,13 @@ export class WEBGLFramebuffer extends Framebuffer {
173
173
  layer: number,
174
174
  level: number
175
175
  ): void {
176
- const {gl, gl2} = this.device;
176
+ const {gl} = this.device;
177
177
  gl.bindTexture(texture.target, texture.handle);
178
178
 
179
179
  switch (texture.target) {
180
180
  case GL.TEXTURE_2D_ARRAY:
181
181
  case GL.TEXTURE_3D:
182
- this.device.assertWebGL2();
183
- gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);
182
+ gl.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);
184
183
  break;
185
184
 
186
185
  case GL.TEXTURE_CUBE_MAP:
@@ -142,18 +142,18 @@ export class WEBGLRenderPass extends RenderPass {
142
142
  * WebGL2 - clear a specific color buffer
143
143
  */
144
144
  protected clearColorBuffer(drawBuffer: number = 0, value: NumberArray = [0, 0, 0, 0]) {
145
- withGLParameters(this.device.gl2, {framebuffer: this.props.framebuffer}, () => {
145
+ withGLParameters(this.device.gl, {framebuffer: this.props.framebuffer}, () => {
146
146
  // Method selection per OpenGL ES 3 docs
147
147
  switch (value.constructor) {
148
148
  case Int32Array:
149
- this.device.gl2.clearBufferiv(GL_COLOR, drawBuffer, value);
149
+ this.device.gl.clearBufferiv(GL_COLOR, drawBuffer, value);
150
150
  break;
151
151
  case Uint32Array:
152
- this.device.gl2.clearBufferuiv(GL_COLOR, drawBuffer, value);
152
+ this.device.gl.clearBufferuiv(GL_COLOR, drawBuffer, value);
153
153
  break;
154
154
  case Float32Array:
155
155
  default:
156
- this.device.gl2.clearBufferfv(GL_COLOR, drawBuffer, value);
156
+ this.device.gl.clearBufferfv(GL_COLOR, drawBuffer, value);
157
157
  break;
158
158
  }
159
159
  });
@@ -165,16 +165,16 @@ export class WEBGLRenderPass extends RenderPass {
165
165
  // const GL_DEPTH_STENCIL = 0x84f9;
166
166
 
167
167
  // case GL_DEPTH:
168
- // this.device.gl2.clearBufferfv(GL_DEPTH, 0, [value]);
168
+ // this.device.gl.clearBufferfv(GL_DEPTH, 0, [value]);
169
169
  // break;
170
170
 
171
171
  // case GL_STENCIL:
172
- // this.device.gl2.clearBufferiv(GL_STENCIL, 0, [value]);
172
+ // this.device.gl.clearBufferiv(GL_STENCIL, 0, [value]);
173
173
  // break;
174
174
 
175
175
  // case GL_DEPTH_STENCIL:
176
176
  // const [depth, stencil] = value;
177
- // this.device.gl2.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);
177
+ // this.device.gl.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);
178
178
  // break;
179
179
 
180
180
  // default: