@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
@@ -1,84 +1,69 @@
1
+ // luma.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+ import { GL } from '@luma.gl/constants';
4
+ /** Set a raw uniform (without type conversion and caching) */
5
+ /* eslint-disable max-len */
1
6
  export function setUniform(gl, location, type, value) {
2
- const gl2 = gl;
3
- let uniformValue = value;
4
- if (uniformValue === true) {
5
- uniformValue = 1;
6
- }
7
- if (uniformValue === false) {
8
- uniformValue = 0;
9
- }
10
- const arrayValue = typeof uniformValue === 'number' ? [uniformValue] : uniformValue;
11
- switch (type) {
12
- case 35678:
13
- case 35680:
14
- case 35679:
15
- case 35682:
16
- case 36289:
17
- case 36292:
18
- case 36293:
19
- case 36298:
20
- case 36299:
21
- case 36300:
22
- case 36303:
23
- case 36306:
24
- case 36307:
25
- case 36308:
26
- case 36311:
27
- if (typeof value !== 'number') {
28
- throw new Error('samplers must be set to integers');
29
- }
30
- return gl.uniform1i(location, value);
31
- case 5126:
32
- return gl.uniform1fv(location, arrayValue);
33
- case 35664:
34
- return gl.uniform2fv(location, arrayValue);
35
- case 35665:
36
- return gl.uniform3fv(location, arrayValue);
37
- case 35666:
38
- return gl.uniform4fv(location, arrayValue);
39
- case 5124:
40
- return gl.uniform1iv(location, arrayValue);
41
- case 35667:
42
- return gl.uniform2iv(location, arrayValue);
43
- case 35668:
44
- return gl.uniform3iv(location, arrayValue);
45
- case 35669:
46
- return gl.uniform4iv(location, arrayValue);
47
- case 35670:
48
- return gl.uniform1iv(location, arrayValue);
49
- case 35671:
50
- return gl.uniform2iv(location, arrayValue);
51
- case 35672:
52
- return gl.uniform3iv(location, arrayValue);
53
- case 35673:
54
- return gl.uniform4iv(location, arrayValue);
55
- case 5125:
56
- return gl2.uniform1uiv(location, arrayValue, 1);
57
- case 36294:
58
- return gl2.uniform2uiv(location, arrayValue, 2);
59
- case 36295:
60
- return gl2.uniform3uiv(location, arrayValue, 3);
61
- case 36296:
62
- return gl2.uniform4uiv(location, arrayValue, 4);
63
- case 35674:
64
- return gl.uniformMatrix2fv(location, false, arrayValue);
65
- case 35675:
66
- return gl.uniformMatrix3fv(location, false, arrayValue);
67
- case 35676:
68
- return gl.uniformMatrix4fv(location, false, arrayValue);
69
- case 35685:
70
- return gl2.uniformMatrix2x3fv(location, false, arrayValue);
71
- case 35686:
72
- return gl2.uniformMatrix2x4fv(location, false, arrayValue);
73
- case 35687:
74
- return gl2.uniformMatrix3x2fv(location, false, arrayValue);
75
- case 35688:
76
- return gl2.uniformMatrix3x4fv(location, false, arrayValue);
77
- case 35689:
78
- return gl2.uniformMatrix4x2fv(location, false, arrayValue);
79
- case 35690:
80
- return gl2.uniformMatrix4x3fv(location, false, arrayValue);
81
- }
82
- throw new Error('Illegal uniform');
7
+ const gl2 = gl;
8
+ // Prepare the value for WebGL setters
9
+ let uniformValue = value;
10
+ if (uniformValue === true) {
11
+ uniformValue = 1;
12
+ }
13
+ if (uniformValue === false) {
14
+ uniformValue = 0;
15
+ }
16
+ const arrayValue = typeof uniformValue === 'number' ? [uniformValue] : uniformValue;
17
+ // prettier-ignore
18
+ switch (type) {
19
+ case GL.SAMPLER_2D:
20
+ case GL.SAMPLER_CUBE:
21
+ case GL.SAMPLER_3D:
22
+ case GL.SAMPLER_2D_SHADOW:
23
+ case GL.SAMPLER_2D_ARRAY:
24
+ case GL.SAMPLER_2D_ARRAY_SHADOW:
25
+ case GL.SAMPLER_CUBE_SHADOW:
26
+ case GL.INT_SAMPLER_2D:
27
+ case GL.INT_SAMPLER_3D:
28
+ case GL.INT_SAMPLER_CUBE:
29
+ case GL.INT_SAMPLER_2D_ARRAY:
30
+ case GL.UNSIGNED_INT_SAMPLER_2D:
31
+ case GL.UNSIGNED_INT_SAMPLER_3D:
32
+ case GL.UNSIGNED_INT_SAMPLER_CUBE:
33
+ case GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
34
+ if (typeof value !== 'number') {
35
+ throw new Error('samplers must be set to integers');
36
+ }
37
+ return gl.uniform1i(location, value);
38
+ case GL.FLOAT: return gl.uniform1fv(location, arrayValue);
39
+ case GL.FLOAT_VEC2: return gl.uniform2fv(location, arrayValue);
40
+ case GL.FLOAT_VEC3: return gl.uniform3fv(location, arrayValue);
41
+ case GL.FLOAT_VEC4: return gl.uniform4fv(location, arrayValue);
42
+ case GL.INT: return gl.uniform1iv(location, arrayValue);
43
+ case GL.INT_VEC2: return gl.uniform2iv(location, arrayValue);
44
+ case GL.INT_VEC3: return gl.uniform3iv(location, arrayValue);
45
+ case GL.INT_VEC4: return gl.uniform4iv(location, arrayValue);
46
+ case GL.BOOL: return gl.uniform1iv(location, arrayValue);
47
+ case GL.BOOL_VEC2: return gl.uniform2iv(location, arrayValue);
48
+ case GL.BOOL_VEC3: return gl.uniform3iv(location, arrayValue);
49
+ case GL.BOOL_VEC4: return gl.uniform4iv(location, arrayValue);
50
+ // WEBGL2 - unsigned integers
51
+ case GL.UNSIGNED_INT: return gl2.uniform1uiv(location, arrayValue, 1);
52
+ case GL.UNSIGNED_INT_VEC2: return gl2.uniform2uiv(location, arrayValue, 2);
53
+ case GL.UNSIGNED_INT_VEC3: return gl2.uniform3uiv(location, arrayValue, 3);
54
+ case GL.UNSIGNED_INT_VEC4: return gl2.uniform4uiv(location, arrayValue, 4);
55
+ // WebGL2 - quadratic matrices
56
+ // false: don't transpose the matrix
57
+ case GL.FLOAT_MAT2: return gl.uniformMatrix2fv(location, false, arrayValue);
58
+ case GL.FLOAT_MAT3: return gl.uniformMatrix3fv(location, false, arrayValue);
59
+ case GL.FLOAT_MAT4: return gl.uniformMatrix4fv(location, false, arrayValue);
60
+ // WebGL2 - rectangular matrices
61
+ case GL.FLOAT_MAT2x3: return gl2.uniformMatrix2x3fv(location, false, arrayValue);
62
+ case GL.FLOAT_MAT2x4: return gl2.uniformMatrix2x4fv(location, false, arrayValue);
63
+ case GL.FLOAT_MAT3x2: return gl2.uniformMatrix3x2fv(location, false, arrayValue);
64
+ case GL.FLOAT_MAT3x4: return gl2.uniformMatrix3x4fv(location, false, arrayValue);
65
+ case GL.FLOAT_MAT4x2: return gl2.uniformMatrix4x2fv(location, false, arrayValue);
66
+ case GL.FLOAT_MAT4x3: return gl2.uniformMatrix4x3fv(location, false, arrayValue);
67
+ }
68
+ throw new Error('Illegal uniform');
83
69
  }
84
- //# sourceMappingURL=set-uniform.js.map
@@ -1,103 +1,87 @@
1
+ // luma.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+ import { GL } from '@luma.gl/constants';
4
+ // Counts the number of complete primitives given a number of vertices and a drawMode
1
5
  export function getPrimitiveDrawMode(drawMode) {
2
- switch (drawMode) {
3
- case 0:
4
- return 0;
5
- case 1:
6
- return 1;
7
- case 3:
8
- return 1;
9
- case 2:
10
- return 1;
11
- case 4:
12
- return 4;
13
- case 5:
14
- return 4;
15
- case 6:
16
- return 4;
17
- default:
18
- throw new Error('drawMode');
19
- }
6
+ switch (drawMode) {
7
+ case GL.POINTS:
8
+ return GL.POINTS;
9
+ case GL.LINES:
10
+ return GL.LINES;
11
+ case GL.LINE_STRIP:
12
+ return GL.LINES;
13
+ case GL.LINE_LOOP:
14
+ return GL.LINES;
15
+ case GL.TRIANGLES:
16
+ return GL.TRIANGLES;
17
+ case GL.TRIANGLE_STRIP:
18
+ return GL.TRIANGLES;
19
+ case GL.TRIANGLE_FAN:
20
+ return GL.TRIANGLES;
21
+ default:
22
+ throw new Error('drawMode');
23
+ }
20
24
  }
25
+ // Counts the number of complete "primitives" given a number of vertices and a drawMode
21
26
  export function getPrimitiveCount(options) {
22
- const {
23
- drawMode,
24
- vertexCount
25
- } = options;
26
- switch (drawMode) {
27
- case 0:
28
- case 2:
29
- return vertexCount;
30
- case 1:
31
- return vertexCount / 2;
32
- case 3:
33
- return vertexCount - 1;
34
- case 4:
35
- return vertexCount / 3;
36
- case 5:
37
- case 6:
38
- return vertexCount - 2;
39
- default:
40
- throw new Error('drawMode');
41
- }
27
+ const { drawMode, vertexCount } = options;
28
+ switch (drawMode) {
29
+ case GL.POINTS:
30
+ case GL.LINE_LOOP:
31
+ return vertexCount;
32
+ case GL.LINES:
33
+ return vertexCount / 2;
34
+ case GL.LINE_STRIP:
35
+ return vertexCount - 1;
36
+ case GL.TRIANGLES:
37
+ return vertexCount / 3;
38
+ case GL.TRIANGLE_STRIP:
39
+ case GL.TRIANGLE_FAN:
40
+ return vertexCount - 2;
41
+ default:
42
+ throw new Error('drawMode');
43
+ }
42
44
  }
45
+ // Counts the number of vertices after splitting the vertex stream into separate "primitives"
43
46
  export function getVertexCount(options) {
44
- const {
45
- drawMode,
46
- vertexCount
47
- } = options;
48
- const primitiveCount = getPrimitiveCount({
49
- drawMode,
50
- vertexCount
51
- });
52
- switch (getPrimitiveDrawMode(drawMode)) {
53
- case 0:
54
- return primitiveCount;
55
- case 1:
56
- return primitiveCount * 2;
57
- case 4:
58
- return primitiveCount * 3;
59
- default:
60
- throw new Error('drawMode');
61
- }
47
+ const { drawMode, vertexCount } = options;
48
+ const primitiveCount = getPrimitiveCount({ drawMode, vertexCount });
49
+ switch (getPrimitiveDrawMode(drawMode)) {
50
+ case GL.POINTS:
51
+ return primitiveCount;
52
+ case GL.LINES:
53
+ return primitiveCount * 2;
54
+ case GL.TRIANGLES:
55
+ return primitiveCount * 3;
56
+ default:
57
+ throw new Error('drawMode');
58
+ }
62
59
  }
60
+ /** Get the primitive type for draw */
63
61
  export function getGLDrawMode(topology) {
64
- switch (topology) {
65
- case 'point-list':
66
- return 0;
67
- case 'line-list':
68
- return 1;
69
- case 'line-strip':
70
- return 3;
71
- case 'line-loop-webgl':
72
- return 2;
73
- case 'triangle-list':
74
- return 4;
75
- case 'triangle-strip':
76
- return 5;
77
- case 'triangle-fan-webgl':
78
- return 6;
79
- default:
80
- throw new Error(topology);
81
- }
62
+ // prettier-ignore
63
+ switch (topology) {
64
+ case 'point-list': return GL.POINTS;
65
+ case 'line-list': return GL.LINES;
66
+ case 'line-strip': return GL.LINE_STRIP;
67
+ case 'line-loop-webgl': return GL.LINE_LOOP;
68
+ case 'triangle-list': return GL.TRIANGLES;
69
+ case 'triangle-strip': return GL.TRIANGLE_STRIP;
70
+ case 'triangle-fan-webgl': return GL.TRIANGLE_FAN;
71
+ default: throw new Error(topology);
72
+ }
82
73
  }
74
+ /** Get the primitive type for transform feedback */
83
75
  export function getGLPrimitive(topology) {
84
- switch (topology) {
85
- case 'point-list':
86
- return 0;
87
- case 'line-list':
88
- return 1;
89
- case 'line-strip':
90
- return 1;
91
- case 'line-loop-webgl':
92
- return 1;
93
- case 'triangle-list':
94
- return 4;
95
- case 'triangle-strip':
96
- return 4;
97
- case 'triangle-fan-webgl':
98
- return 4;
99
- default:
100
- throw new Error(topology);
101
- }
76
+ // prettier-ignore
77
+ switch (topology) {
78
+ case 'point-list': return GL.POINTS;
79
+ case 'line-list': return GL.LINES;
80
+ case 'line-strip': return GL.LINES;
81
+ case 'line-loop-webgl': return GL.LINES;
82
+ case 'triangle-list': return GL.TRIANGLES;
83
+ case 'triangle-strip': return GL.TRIANGLES;
84
+ case 'triangle-fan-webgl': return GL.TRIANGLES;
85
+ default: throw new Error(topology);
86
+ }
102
87
  }
103
- //# sourceMappingURL=webgl-topology-utils.js.map
@@ -1,3 +1,3 @@
1
1
  import { GL } from '@luma.gl/constants';
2
- export declare function getKeyValue(gl: WebGLRenderingContext, name: string | GL): GL;
2
+ export declare function getKeyValue(gl: WebGL2RenderingContext, name: string | GL): GL;
3
3
  //# sourceMappingURL=constants-to-keys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants-to-keys.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/constants-to-keys.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,wBAAgB,WAAW,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,GAAG,EAAE,CAkB5E"}
1
+ {"version":3,"file":"constants-to-keys.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/constants-to-keys.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,wBAAgB,WAAW,CAAC,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,GAAG,EAAE,CAkB7E"}
@@ -1,15 +1,21 @@
1
+ // luma.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
1
3
  import { assert } from '@luma.gl/core';
4
+ // Resolve a WebGL enumeration name (returns itself if already a number)
2
5
  export function getKeyValue(gl, name) {
3
- if (typeof name !== 'string') {
4
- return name;
5
- }
6
- const number = Number(name);
7
- if (!isNaN(number)) {
8
- return number;
9
- }
10
- name = name.replace(/^.*\./, '');
11
- const value = gl[name];
12
- assert(value !== undefined, `Accessing undefined constant GL.${name}`);
13
- return value;
6
+ // If not a string, return (assume number)
7
+ if (typeof name !== 'string') {
8
+ return name;
9
+ }
10
+ // If string converts to number, return number
11
+ const number = Number(name);
12
+ if (!isNaN(number)) {
13
+ return number;
14
+ }
15
+ // Look up string, after removing any 'GL.' or 'gl.' prefix
16
+ name = name.replace(/^.*\./, '');
17
+ // @ts-ignore expect-error depends on settings
18
+ const value = gl[name];
19
+ assert(value !== undefined, `Accessing undefined constant GL.${name}`);
20
+ return value;
14
21
  }
15
- //# sourceMappingURL=constants-to-keys.js.map
@@ -1,86 +1,82 @@
1
- let _Symbol$toStringTag;
1
+ // luma.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
2
3
  import { assert } from '@luma.gl/core';
3
- import { WebGLResource } from "./webgl-resource.js";
4
- import { isRenderbufferFormatSupported } from "../converters/texture-formats.js";
5
- import { convertTextureFormatToGL, getTextureFormatBytesPerPixel } from "../converters/texture-formats.js";
6
- _Symbol$toStringTag = Symbol.toStringTag;
4
+ import { GL } from '@luma.gl/constants';
5
+ import { WebGLResource } from './webgl-resource';
6
+ import { isRenderbufferFormatSupported } from '../converters/texture-formats';
7
+ import { convertTextureFormatToGL, getTextureFormatBytesPerPixel } from '../converters/texture-formats';
8
+ /**
9
+ * Renderbuffers are GPU objects that contain images.
10
+ * In contrast to Textures they are optimized for use as render targets, with Framebuffers.
11
+ * while Textures may not be, and are the logical choice when
12
+ * you do not need to sample (i.e. in a post-pass shader)
13
+ * from the produced image. If you need to resample
14
+ * (such as when reading depth back in a second shader pass),
15
+ * use Textures instead.
16
+ * Renderbuffer objects also natively accommodate Multisampling (MSAA).
17
+ */
7
18
  export class WEBGLRenderbuffer extends WebGLResource {
8
- get [_Symbol$toStringTag]() {
9
- return 'Renderbuffer';
10
- }
11
- get width() {
12
- return this.props.width;
13
- }
14
- get height() {
15
- return this.props.height;
16
- }
17
- get format() {
18
- return this.props.format;
19
- }
20
- get samples() {
21
- return this.props.samples;
22
- }
23
- get attachment() {
24
- return;
25
- }
26
- static isTextureFormatSupported(device, format) {
27
- return isRenderbufferFormatSupported(device.gl, format);
28
- }
29
- constructor(device, props) {
30
- if (typeof props.format === 'number') {
31
- throw new Error('Renderbuffer');
19
+ static defaultProps = {
20
+ id: undefined,
21
+ handle: undefined,
22
+ userData: undefined,
23
+ format: undefined, // 'depth16unorm'
24
+ width: 1,
25
+ height: 1,
26
+ samples: 0
27
+ };
28
+ get [Symbol.toStringTag]() { return 'Renderbuffer'; }
29
+ get width() { return this.props.width; }
30
+ get height() { return this.props.height; }
31
+ get format() { return this.props.format; }
32
+ get samples() { return this.props.samples; }
33
+ get attachment() { return; }
34
+ /** WebGL format constant */
35
+ glFormat;
36
+ static isTextureFormatSupported(device, format) {
37
+ return isRenderbufferFormatSupported(device.gl, format);
32
38
  }
33
- super(device, props, WEBGLRenderbuffer.defaultProps);
34
- this.glFormat = void 0;
35
- this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);
36
- this._initialize(this.props);
37
- }
38
- resize(size) {
39
- if (size.width !== this.width || size.height !== this.height) {
40
- Object.assign(this.props, {
41
- ...size,
42
- format: this.format,
43
- samples: this.samples
44
- });
45
- this._initialize(this.props);
39
+ constructor(device, props) {
40
+ // TODO - remove temporary sanity check
41
+ if (typeof props.format === 'number') {
42
+ throw new Error('Renderbuffer');
43
+ }
44
+ super(device, props, WEBGLRenderbuffer.defaultProps);
45
+ this.glFormat = convertTextureFormatToGL(this.props.format);
46
+ this._initialize(this.props);
46
47
  }
47
- }
48
- _initialize(props) {
49
- const {
50
- format,
51
- width,
52
- height,
53
- samples
54
- } = props;
55
- assert(format, 'Needs format');
56
- this.trackDeallocatedMemory();
57
- this.gl.bindRenderbuffer(36161, this.handle);
58
- if (samples !== 0 && this.device.isWebGL2) {
59
- this.gl2.renderbufferStorageMultisample(36161, samples, this.glFormat, width, height);
60
- } else {
61
- this.gl.renderbufferStorage(36161, this.glFormat, width, height);
48
+ resize(size) {
49
+ // Don't resize if width/height haven't changed
50
+ if (size.width !== this.width || size.height !== this.height) {
51
+ Object.assign(this.props, { ...size, format: this.format, samples: this.samples });
52
+ this._initialize(this.props);
53
+ }
54
+ }
55
+ // PRIVATE METHODS
56
+ /** Creates and initializes a renderbuffer object's data store */
57
+ _initialize(props) {
58
+ const { format, width, height, samples } = props;
59
+ assert(format, 'Needs format');
60
+ this.trackDeallocatedMemory();
61
+ this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);
62
+ if (samples !== 0) {
63
+ this.gl.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);
64
+ }
65
+ else {
66
+ this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);
67
+ }
68
+ this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);
69
+ this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat));
70
+ }
71
+ // RESOURCE IMPLEMENTATION
72
+ _createHandle() {
73
+ return this.gl.createRenderbuffer();
74
+ }
75
+ _deleteHandle() {
76
+ this.gl.deleteRenderbuffer(this.handle);
77
+ this.trackDeallocatedMemory();
78
+ }
79
+ _bindHandle(handle) {
80
+ this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);
62
81
  }
63
- this.gl.bindRenderbuffer(36161, null);
64
- this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2));
65
- }
66
- _createHandle() {
67
- return this.gl.createRenderbuffer();
68
- }
69
- _deleteHandle() {
70
- this.gl.deleteRenderbuffer(this.handle);
71
- this.trackDeallocatedMemory();
72
- }
73
- _bindHandle(handle) {
74
- this.gl.bindRenderbuffer(36161, handle);
75
- }
76
82
  }
77
- WEBGLRenderbuffer.defaultProps = {
78
- id: undefined,
79
- handle: undefined,
80
- userData: undefined,
81
- format: undefined,
82
- width: 1,
83
- height: 1,
84
- samples: 0
85
- };
86
- //# sourceMappingURL=webgl-renderbuffer.js.map
@@ -7,7 +7,7 @@ import { WebGLDevice } from '../webgl-device';
7
7
  */
8
8
  export declare abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {
9
9
  readonly device: WebGLDevice;
10
- readonly gl: WebGLRenderingContext;
10
+ readonly gl: WebGL2RenderingContext;
11
11
  readonly gl2: WebGL2RenderingContext;
12
12
  private _handle;
13
13
  private _bound;
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-resource.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-resource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAkC,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AACzD,OAAO,EAAC,EAAE,EAAC,MAAM,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