@luma.gl/webgl 8.6.0-alpha.2 → 8.6.0-alpha.3

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 (280) hide show
  1. package/LICENSE +8 -1
  2. package/dist/adapter/converters/set-device-parameters.d.ts +5 -0
  3. package/dist/adapter/converters/set-device-parameters.d.ts.map +1 -0
  4. package/dist/adapter/converters/set-device-parameters.js +124 -0
  5. package/dist/adapter/converters/set-device-parameters.js.map +1 -0
  6. package/dist/adapter/converters/webgpu-texture-formats.d.ts +281 -0
  7. package/dist/adapter/converters/webgpu-texture-formats.d.ts.map +1 -0
  8. package/dist/adapter/converters/webgpu-texture-formats.js +285 -0
  9. package/dist/adapter/converters/webgpu-texture-formats.js.map +1 -0
  10. package/dist/{device → adapter/device-helpers}/device-features.d.ts +0 -0
  11. package/dist/adapter/device-helpers/device-features.d.ts.map +1 -0
  12. package/dist/{esm/device → adapter/device-helpers}/device-features.js +2 -2
  13. package/dist/adapter/device-helpers/device-features.js.map +1 -0
  14. package/dist/{device → adapter/device-helpers}/device-limits.d.ts +0 -0
  15. package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -0
  16. package/dist/{esm/device → adapter/device-helpers}/device-limits.js +1 -1
  17. package/dist/adapter/device-helpers/device-limits.js.map +1 -0
  18. package/dist/{device → adapter/device-helpers}/get-device-info.d.ts +0 -0
  19. package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -0
  20. package/dist/{device → adapter/device-helpers}/get-device-info.js +1 -1
  21. package/dist/adapter/device-helpers/get-device-info.js.map +1 -0
  22. package/dist/{webgl-utils → adapter/device-helpers}/is-old-ie.d.ts +0 -0
  23. package/dist/adapter/device-helpers/is-old-ie.d.ts.map +1 -0
  24. package/dist/{esm/webgl-utils → adapter/device-helpers}/is-old-ie.js +0 -0
  25. package/dist/adapter/device-helpers/is-old-ie.js.map +1 -0
  26. package/dist/{device → adapter}/webgl-device.d.ts +3 -3
  27. package/dist/adapter/webgl-device.d.ts.map +1 -0
  28. package/dist/{esm/device → adapter}/webgl-device.js +6 -6
  29. package/dist/adapter/webgl-device.js.map +1 -0
  30. package/dist/adapter/webgl-shader.d.ts +18 -0
  31. package/dist/adapter/webgl-shader.d.ts.map +1 -0
  32. package/dist/adapter/webgl-shader.js +82 -0
  33. package/dist/adapter/webgl-shader.js.map +1 -0
  34. package/dist/classes/framebuffer.js +1 -1
  35. package/dist/classes/framebuffer.js.map +1 -1
  36. package/dist/classes/program-configuration.d.ts +14 -17
  37. package/dist/classes/program-configuration.d.ts.map +1 -1
  38. package/dist/classes/program-configuration.js +10 -97
  39. package/dist/classes/program-configuration.js.map +1 -1
  40. package/dist/classes/program.d.ts +20 -15
  41. package/dist/classes/program.d.ts.map +1 -1
  42. package/dist/classes/program.js +31 -22
  43. package/dist/classes/program.js.map +1 -1
  44. package/dist/classes/query.js +1 -1
  45. package/dist/classes/query.js.map +1 -1
  46. package/dist/classes/renderbuffer.js +1 -1
  47. package/dist/classes/renderbuffer.js.map +1 -1
  48. package/dist/classes/{webgl-shader.d.ts → shader.d.ts} +4 -15
  49. package/dist/classes/shader.d.ts.map +1 -0
  50. package/dist/{esm/classes/webgl-shader.js → classes/shader.js} +6 -81
  51. package/dist/classes/shader.js.map +1 -0
  52. package/dist/classes/texture-3d.js +1 -1
  53. package/dist/classes/texture-3d.js.map +1 -1
  54. package/dist/classes/texture-cube.js.map +1 -1
  55. package/dist/classes/texture.d.ts +1 -1
  56. package/dist/classes/texture.d.ts.map +1 -1
  57. package/dist/classes/texture.js +1 -1
  58. package/dist/classes/texture.js.map +1 -1
  59. package/dist/classes/transform-feedback.js +1 -1
  60. package/dist/classes/transform-feedback.js.map +1 -1
  61. package/dist/classes/vertex-array-object.d.ts +6 -5
  62. package/dist/classes/vertex-array-object.d.ts.map +1 -1
  63. package/dist/classes/vertex-array-object.js +5 -5
  64. package/dist/classes/vertex-array-object.js.map +1 -1
  65. package/dist/classes/vertex-array.d.ts +13 -13
  66. package/dist/classes/vertex-array.d.ts.map +1 -1
  67. package/dist/classes/vertex-array.js +2 -2
  68. package/dist/classes/vertex-array.js.map +1 -1
  69. package/dist/classes/webgl-buffer.d.ts +1 -1
  70. package/dist/classes/webgl-buffer.d.ts.map +1 -1
  71. package/dist/classes/webgl-buffer.js +1 -1
  72. package/dist/classes/webgl-buffer.js.map +1 -1
  73. package/dist/classes/webgl-resource.d.ts +1 -1
  74. package/dist/classes/webgl-resource.d.ts.map +1 -1
  75. package/dist/classes/webgl-resource.js +1 -1
  76. package/dist/classes/webgl-resource.js.map +1 -1
  77. package/dist/context/parameters/unified-parameter-api.d.ts +2 -1
  78. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  79. package/dist/context/parameters/unified-parameter-api.js.map +1 -1
  80. package/dist/context/parameters/webgl-parameters.d.ts.map +1 -1
  81. package/dist/context/parameters/webgl-parameters.js.map +1 -1
  82. package/dist/es5/adapter/converters/set-device-parameters.js +138 -0
  83. package/dist/es5/adapter/converters/set-device-parameters.js.map +1 -0
  84. package/dist/es5/adapter/converters/webgpu-texture-formats.js +296 -0
  85. package/dist/es5/adapter/converters/webgpu-texture-formats.js.map +1 -0
  86. package/dist/es5/{device → adapter/device-helpers}/device-features.js +2 -2
  87. package/dist/es5/adapter/device-helpers/device-features.js.map +1 -0
  88. package/dist/es5/{device → adapter/device-helpers}/device-limits.js +1 -1
  89. package/dist/es5/adapter/device-helpers/device-limits.js.map +1 -0
  90. package/dist/es5/{device → adapter/device-helpers}/get-device-info.js +1 -1
  91. package/dist/es5/adapter/device-helpers/get-device-info.js.map +1 -0
  92. package/dist/es5/{webgl-utils → adapter/device-helpers}/is-old-ie.js +0 -0
  93. package/dist/es5/adapter/device-helpers/is-old-ie.js.map +1 -0
  94. package/dist/es5/{device → adapter}/webgl-device.js +6 -6
  95. package/dist/es5/adapter/webgl-device.js.map +1 -0
  96. package/dist/es5/adapter/webgl-shader.js +155 -0
  97. package/dist/es5/adapter/webgl-shader.js.map +1 -0
  98. package/dist/es5/classes/framebuffer.js +1 -1
  99. package/dist/es5/classes/framebuffer.js.map +1 -1
  100. package/dist/es5/classes/program-configuration.js +34 -101
  101. package/dist/es5/classes/program-configuration.js.map +1 -1
  102. package/dist/es5/classes/program.js +38 -27
  103. package/dist/es5/classes/program.js.map +1 -1
  104. package/dist/es5/classes/query.js +1 -1
  105. package/dist/es5/classes/query.js.map +1 -1
  106. package/dist/es5/classes/renderbuffer.js +1 -1
  107. package/dist/es5/classes/renderbuffer.js.map +1 -1
  108. package/dist/es5/classes/{webgl-shader.js → shader.js} +18 -132
  109. package/dist/es5/classes/shader.js.map +1 -0
  110. package/dist/es5/classes/texture-3d.js +1 -1
  111. package/dist/es5/classes/texture-3d.js.map +1 -1
  112. package/dist/es5/classes/texture-cube.js.map +1 -1
  113. package/dist/es5/classes/texture.js +1 -1
  114. package/dist/es5/classes/texture.js.map +1 -1
  115. package/dist/es5/classes/transform-feedback.js +1 -1
  116. package/dist/es5/classes/transform-feedback.js.map +1 -1
  117. package/dist/es5/classes/vertex-array-object.js +5 -5
  118. package/dist/es5/classes/vertex-array-object.js.map +1 -1
  119. package/dist/es5/classes/vertex-array.js +5 -5
  120. package/dist/es5/classes/vertex-array.js.map +1 -1
  121. package/dist/es5/classes/webgl-buffer.js +1 -1
  122. package/dist/es5/classes/webgl-buffer.js.map +1 -1
  123. package/dist/es5/classes/webgl-resource.js +1 -1
  124. package/dist/es5/classes/webgl-resource.js.map +1 -1
  125. package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
  126. package/dist/es5/context/parameters/webgl-parameters.js.map +1 -1
  127. package/dist/es5/helpers/get-program-bindings.js +274 -0
  128. package/dist/es5/helpers/get-program-bindings.js.map +1 -0
  129. package/dist/es5/helpers/program-bindings.js +2 -0
  130. package/dist/es5/helpers/program-bindings.js.map +1 -0
  131. package/dist/es5/index.js +31 -15
  132. package/dist/es5/index.js.map +1 -1
  133. package/dist/es5/init.js +1 -1
  134. package/dist/es5/init.js.map +1 -1
  135. package/dist/es5/types/accessor.d.ts +29 -0
  136. package/dist/esm/adapter/converters/set-device-parameters.js +124 -0
  137. package/dist/esm/adapter/converters/set-device-parameters.js.map +1 -0
  138. package/dist/esm/adapter/converters/webgpu-texture-formats.js +285 -0
  139. package/dist/esm/adapter/converters/webgpu-texture-formats.js.map +1 -0
  140. package/dist/{device → esm/adapter/device-helpers}/device-features.js +2 -2
  141. package/dist/esm/adapter/device-helpers/device-features.js.map +1 -0
  142. package/dist/{device → esm/adapter/device-helpers}/device-limits.js +1 -1
  143. package/dist/esm/adapter/device-helpers/device-limits.js.map +1 -0
  144. package/dist/esm/{device → adapter/device-helpers}/get-device-info.js +1 -1
  145. package/dist/esm/adapter/device-helpers/get-device-info.js.map +1 -0
  146. package/dist/{webgl-utils → esm/adapter/device-helpers}/is-old-ie.js +0 -0
  147. package/dist/esm/adapter/device-helpers/is-old-ie.js.map +1 -0
  148. package/dist/{device → esm/adapter}/webgl-device.js +6 -6
  149. package/dist/esm/adapter/webgl-device.js.map +1 -0
  150. package/dist/esm/adapter/webgl-shader.js +82 -0
  151. package/dist/esm/adapter/webgl-shader.js.map +1 -0
  152. package/dist/esm/classes/framebuffer.js +1 -1
  153. package/dist/esm/classes/framebuffer.js.map +1 -1
  154. package/dist/esm/classes/program-configuration.js +10 -97
  155. package/dist/esm/classes/program-configuration.js.map +1 -1
  156. package/dist/esm/classes/program.js +31 -22
  157. package/dist/esm/classes/program.js.map +1 -1
  158. package/dist/esm/classes/query.js +1 -1
  159. package/dist/esm/classes/query.js.map +1 -1
  160. package/dist/esm/classes/renderbuffer.js +1 -1
  161. package/dist/esm/classes/renderbuffer.js.map +1 -1
  162. package/dist/{classes/webgl-shader.js → esm/classes/shader.js} +6 -81
  163. package/dist/esm/classes/shader.js.map +1 -0
  164. package/dist/esm/classes/texture-3d.js +1 -1
  165. package/dist/esm/classes/texture-3d.js.map +1 -1
  166. package/dist/esm/classes/texture-cube.js.map +1 -1
  167. package/dist/esm/classes/texture.js +1 -1
  168. package/dist/esm/classes/texture.js.map +1 -1
  169. package/dist/esm/classes/transform-feedback.js +1 -1
  170. package/dist/esm/classes/transform-feedback.js.map +1 -1
  171. package/dist/esm/classes/vertex-array-object.js +5 -5
  172. package/dist/esm/classes/vertex-array-object.js.map +1 -1
  173. package/dist/esm/classes/vertex-array.js +2 -2
  174. package/dist/esm/classes/vertex-array.js.map +1 -1
  175. package/dist/esm/classes/webgl-buffer.js +1 -1
  176. package/dist/esm/classes/webgl-buffer.js.map +1 -1
  177. package/dist/esm/classes/webgl-resource.js +1 -1
  178. package/dist/esm/classes/webgl-resource.js.map +1 -1
  179. package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
  180. package/dist/esm/context/parameters/webgl-parameters.js.map +1 -1
  181. package/dist/esm/helpers/get-program-bindings.js +228 -0
  182. package/dist/esm/helpers/get-program-bindings.js.map +1 -0
  183. package/dist/esm/helpers/program-bindings.js +2 -0
  184. package/dist/esm/helpers/program-bindings.js.map +1 -0
  185. package/dist/esm/index.js +4 -2
  186. package/dist/esm/index.js.map +1 -1
  187. package/dist/esm/init.js +1 -1
  188. package/dist/esm/init.js.map +1 -1
  189. package/dist/esm/types/accessor.d.ts +29 -0
  190. package/dist/helpers/get-program-bindings.d.ts +8 -0
  191. package/dist/helpers/get-program-bindings.d.ts.map +1 -0
  192. package/dist/helpers/get-program-bindings.js +228 -0
  193. package/dist/helpers/get-program-bindings.js.map +1 -0
  194. package/dist/helpers/program-bindings.d.ts +41 -0
  195. package/dist/helpers/program-bindings.d.ts.map +1 -0
  196. package/dist/helpers/program-bindings.js +2 -0
  197. package/dist/helpers/program-bindings.js.map +1 -0
  198. package/dist/index.d.ts +6 -4
  199. package/dist/index.d.ts.map +1 -1
  200. package/dist/index.js +4 -2
  201. package/dist/index.js.map +1 -1
  202. package/dist/init.js +1 -1
  203. package/dist/init.js.map +1 -1
  204. package/dist/types/accessor.d.ts +29 -0
  205. package/package.json +5 -5
  206. package/src/adapter/converters/set-device-parameters.ts +182 -0
  207. package/src/adapter/converters/webgpu-texture-formats.ts +167 -0
  208. package/src/{device → adapter/device-helpers}/device-features.ts +4 -4
  209. package/src/{device → adapter/device-helpers}/device-limits.ts +1 -1
  210. package/src/{device → adapter/device-helpers}/get-device-info.ts +2 -2
  211. package/src/{webgl-utils → adapter/device-helpers}/is-old-ie.ts +0 -0
  212. package/src/{device → adapter}/webgl-device.ts +9 -9
  213. package/src/adapter/webgl-shader.ts +84 -0
  214. package/src/classes/framebuffer.ts +1 -1
  215. package/src/classes/program-configuration.ts +28 -81
  216. package/src/classes/program.ts +70 -62
  217. package/src/classes/query.ts +1 -1
  218. package/src/classes/renderbuffer.ts +1 -1
  219. package/src/classes/{webgl-shader.ts → shader.ts} +6 -79
  220. package/src/classes/texture-3d.ts +1 -1
  221. package/src/classes/texture-cube.ts +1 -1
  222. package/src/classes/texture.ts +1 -1
  223. package/src/classes/transform-feedback.ts +1 -1
  224. package/src/classes/vertex-array-object.ts +9 -8
  225. package/src/classes/vertex-array.ts +14 -8
  226. package/src/classes/webgl-buffer.ts +1 -1
  227. package/src/classes/webgl-resource.ts +1 -1
  228. package/src/context/parameters/unified-parameter-api.ts +3 -2
  229. package/src/context/parameters/webgl-parameters.ts +115 -115
  230. package/src/helpers/get-program-bindings.ts +244 -0
  231. package/src/helpers/program-bindings.ts +46 -0
  232. package/src/index.ts +12 -6
  233. package/src/init.ts +1 -1
  234. package/src/types/accessor.d.ts +29 -0
  235. package/dist/api/device2.d.ts +0 -52
  236. package/dist/api/device2.d.ts.map +0 -1
  237. package/dist/api/device2.js +0 -23
  238. package/dist/api/device2.js.map +0 -1
  239. package/dist/classes/webgl-shader.d.ts.map +0 -1
  240. package/dist/classes/webgl-shader.js.map +0 -1
  241. package/dist/device/check-glsl-extension.d.ts +0 -4
  242. package/dist/device/check-glsl-extension.d.ts.map +0 -1
  243. package/dist/device/check-glsl-extension.js +0 -22
  244. package/dist/device/check-glsl-extension.js.map +0 -1
  245. package/dist/device/device-features.d.ts.map +0 -1
  246. package/dist/device/device-features.js.map +0 -1
  247. package/dist/device/device-limits.d.ts.map +0 -1
  248. package/dist/device/device-limits.js.map +0 -1
  249. package/dist/device/get-device-info.d.ts.map +0 -1
  250. package/dist/device/get-device-info.js.map +0 -1
  251. package/dist/device/webgl-device.d.ts.map +0 -1
  252. package/dist/device/webgl-device.js.map +0 -1
  253. package/dist/es5/api/device2.js +0 -42
  254. package/dist/es5/api/device2.js.map +0 -1
  255. package/dist/es5/classes/webgl-shader.js.map +0 -1
  256. package/dist/es5/device/check-glsl-extension.js +0 -33
  257. package/dist/es5/device/check-glsl-extension.js.map +0 -1
  258. package/dist/es5/device/device-features.js.map +0 -1
  259. package/dist/es5/device/device-limits.js.map +0 -1
  260. package/dist/es5/device/get-device-info.js.map +0 -1
  261. package/dist/es5/device/webgl-device.js.map +0 -1
  262. package/dist/es5/webgl-utils/is-old-ie.js.map +0 -1
  263. package/dist/es5/webgl-utils/webgl-info.ts.disabled +0 -135
  264. package/dist/esm/api/device2.js +0 -23
  265. package/dist/esm/api/device2.js.map +0 -1
  266. package/dist/esm/classes/webgl-shader.js.map +0 -1
  267. package/dist/esm/device/check-glsl-extension.js +0 -22
  268. package/dist/esm/device/check-glsl-extension.js.map +0 -1
  269. package/dist/esm/device/device-features.js.map +0 -1
  270. package/dist/esm/device/device-limits.js.map +0 -1
  271. package/dist/esm/device/get-device-info.js.map +0 -1
  272. package/dist/esm/device/webgl-device.js.map +0 -1
  273. package/dist/esm/webgl-utils/is-old-ie.js.map +0 -1
  274. package/dist/esm/webgl-utils/webgl-info.ts.disabled +0 -135
  275. package/dist/webgl-utils/is-old-ie.d.ts.map +0 -1
  276. package/dist/webgl-utils/is-old-ie.js.map +0 -1
  277. package/dist/webgl-utils/webgl-info.ts.disabled +0 -135
  278. package/src/api/device2.ts +0 -71
  279. package/src/device/check-glsl-extension.ts +0 -44
  280. package/src/webgl-utils/webgl-info.ts.disabled +0 -135
@@ -0,0 +1,167 @@
1
+ import GL from '@luma.gl/constants';
2
+
3
+ // Define local extension strings to optimize minification
4
+ const SRGB = 'EXT_sRGB';
5
+ const EXT_FLOAT_WEBGL1 = 'WEBGL.color_buffer_float';
6
+ const EXT_FLOAT_WEBGL2 = 'EXT_color_buffer_float';
7
+ const EXT_HALF_FLOAT_WEBGL1 = 'EXT_color_buffer_half_float';
8
+
9
+ // const S3TC = 'WEBGL_compressed_texture_s3tc';
10
+ // const PVRTC = 'WEBGL_compressed_texture_pvrtc';
11
+ // const ES3 = 'WEBGL_compressed_texture_es3';
12
+ // const ETC1 = 'WEBGL_compressed_texture_etc1';
13
+ // const SRGB = 'EXT_sRGB';
14
+ // const DEPTH = 'WEBGL_depth_texture';
15
+
16
+ // NOTES:
17
+ // - gl2: format requires WebGL2, when using a WebGL 1 context, color renderbuffer formats are limited
18
+ // - b (bytes per pixel), for memory usage calculations.
19
+ // - c (channels)
20
+ // - p (packed)
21
+
22
+ export const TEXTURE_FORMAT_DEFINITIONS = {
23
+ // 8-bit formats
24
+ 'r8unorm': {b: 1, c: 1, gl: GL.R8, gl2: true},
25
+ 'r8snorm': {b: 1, c: 1},
26
+ 'r8uint': {b: 1, c: 1, gl: GL.R8UI, gl2: true},
27
+ 'r8sint': {b: 1, c: 1, gl: GL.R8I, gl2: true},
28
+
29
+ // 16-bit formats
30
+ 'r16uint': {b: 2, c: 1, gl: GL.R16UI, gl2: true},
31
+ 'r16sint': {b: 2, c: 1, gl: GL.R16I, gl2: true},
32
+ 'r16float': {b: 2, c: 1, gl: GL.R16F, gl2: EXT_FLOAT_WEBGL2},
33
+ 'rg8unorm': {b: 2, c: 2, gl: GL.RG8, gl2: true},
34
+ 'rg8snorm': {b: 2, c: 2},
35
+ 'rg8uint': {b: 2, c: 2, gl: GL.RG8UI, gl2: true},
36
+ 'rg8sint': {b: 2, c: 2, gl: GL.RG8I, gl2: true},
37
+
38
+ // Packed 16-bit formats
39
+ // 'rgba4norm?': {b: 2, c: 4, gl: GL.RGBA4, wgpu: false},
40
+ // 'rgb565norm?': {b: 2, c: 4, gl: GL.RGB565, wgpu: false},
41
+ // 'rgb5a1norm?': {b: 2, c: 4, gl: GL.RGB5_A1, wgpu: false},
42
+
43
+ // 24-bit formats
44
+ // 'rbg8norm?': {b: 3, c: 3, gl: GL.RGB8, gl2: true, wgpu: false},
45
+
46
+ // 32-bit formats
47
+ 'r32uint': {b: 4, c: 1, gl: GL.R32UI, gl2: true, bpp: 4},
48
+ 'r32sint': {b: 4, c: 1, gl: GL.R32I, gl2: true, bpp: 4},
49
+ 'r32float': {b: 4, c: 1, gl: GL.R32F, gl2: EXT_FLOAT_WEBGL2, bpp: 4},
50
+ 'rg16uint': {b: 4, c: 1, gl: GL.RG16UI, gl2: true, bpp: 4},
51
+ 'rg16sint': {b: 4, c: 2, gl: GL.RG16I, gl2: true, bpp: 4},
52
+ // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
53
+ 'rg16float': {b: 4, c: 2, gl: GL.RG16F, gl2: EXT_FLOAT_WEBGL2, bpp: 4},
54
+ 'rgba8unorm': {b: 4, c: 2, gl: GL.RGBA8, gl2: true, bpp: 4},
55
+
56
+ 'rgba8unorm-srgb': {b: 4, c: 4, gl: GL.SRGB8_ALPHA8, gl2: true, gl1: SRGB, bpp: 4},
57
+ 'rgba8snorm': {b: 4, c: 4},
58
+ 'rgba8uint': {b: 4, c: 4, gl: GL.RGBA8UI, gl2: true, bpp: 4},
59
+ 'rgba8sint': {b: 4, c: 4, gl: GL.RGBA8I, gl2: true, bpp: 4},
60
+ 'bgra8unorm': {b: 4, c: 4},
61
+ 'bgra8unorm-srgb': {b: 4, c: 4},
62
+
63
+ // Packed 32-bit formats
64
+ 'rgb9e5ufloat': {b: 4, c: 3, p: 1, gl: GL.RGB9_E5, gl2: true, gl1: 'WEBGL_color_buffer_half_float'},
65
+ 'rg11b10ufloat': {b: 4, c: 3, p: 1, gl: GL.R11F_G11F_B10F, gl2: EXT_FLOAT_WEBGL2},
66
+ 'rgb10a2unorm': {b: 4, c: 4, p: 1, gl: GL.RGB10_A2, gl2: true},
67
+ // webgl2 only
68
+ // '?rgb10a2unorm?': {b: 4, c: 4, p: 1, webgpu: false, gl: GL.RGB10_A2UI, gl2: true, bpp: 4},
69
+
70
+ // 64-bit formats
71
+ 'rg32uint': {b: 8, c: 2, gl: GL.RG32UI, gl2: true},
72
+ 'rg32sint': {b: 8, c: 2, gl: GL.RG32I, gl2: true},
73
+ 'rg32float': {b: 8, c: 2, gl: GL.RG32F, gl2: EXT_FLOAT_WEBGL2},
74
+ 'rgba16uint': {b: 8, c: 4, gl: GL.RGBA16UI, gl2: true},
75
+ 'rgba16sint': {b: 8, c: 4, gl: GL.RGBA16I, gl2: true},
76
+ 'rgba16float': {b: 8, c: 4, gl: GL.RGBA16F, gl2: EXT_FLOAT_WEBGL2},
77
+
78
+ // 96-bit formats
79
+ // {gl: GL.RGB32F, dataFormat: GL.RGB, types: [GL.FLOAT], gl2: true},
80
+
81
+ // 128-bit formats
82
+ 'rgba32uint': {b: 16, c: 4, gl: GL.RGBA32UI, gl2: true},
83
+ 'rgba32sint': {b: 16, c: 4, gl: GL.RGBA32I, gl2: true},
84
+ 'rgba32float': {b: 16, c: 4, gl: GL.RGBA32F, gl2: EXT_FLOAT_WEBGL2}, // gl1: EXT_FLOAT_WEBGL1
85
+
86
+ // Depth and stencil formats
87
+ 'stencil8': {b: 1, c: 1, gl: GL.STENCIL_INDEX8}, // 8 stencil bits
88
+ 'depth16unorm': {b: 2, c: 1, gl: GL.DEPTH_COMPONENT16}, // 16 depth bits
89
+ 'depth24plus': {b: 3, c: 1, gl: GL.DEPTH_COMPONENT24, gl2: true},
90
+ 'depth24plus-stencil8': {b: 4, c: 2, p: 1, gl: GL.DEPTH24_STENCIL8, gl2: true},
91
+ 'depth32float': {b: 4, c: 1, gl: GL.DEPTH_COMPONENT32F, gl2: true},
92
+
93
+ // "depth24unorm-stencil8" feature
94
+ 'depth24unorm-stencil8': {b: 4, c: 2, p: 1, gl: GL.DEPTH_STENCIL},
95
+
96
+ // "depth32float-stencil8" feature
97
+ "depth32float-stencil8": {b: 5, c: 2, p: 1, gl: GL.DEPTH32F_STENCIL8, gl2: true},
98
+
99
+ // BC compressed formats usable if "texture-compression-bc" is both
100
+ // supported by the device/user agent and enabled in requestDevice.
101
+ 'bc1-rgba-unorm': {},
102
+ 'bc1-rgba-unorm-srgb': {},
103
+ 'bc2-rgba-unorm': {},
104
+ 'bc2-rgba-unorm-srgb': {},
105
+ 'bc3-rgba-unorm': {},
106
+ 'bc3-rgba-unorm-srgb': {},
107
+ 'bc4-r-unorm': {},
108
+ 'bc4-r-snorm': {},
109
+ 'bc5-rg-unorm': {},
110
+ 'bc5-rg-snorm': {},
111
+ 'bc6h-rgb-ufloat': {},
112
+ 'bc6h-rgb-float': {},
113
+ 'bc7-rgba-unorm': {},
114
+ 'bc7-rgba-unorm-srgb': {}
115
+ };
116
+
117
+ ////////////////////////////////////////////////////
118
+ // Compressed formats
119
+
120
+ // WEBGL_compressed_texture_s3tc
121
+
122
+ // {gl: GL.COMPRESSED_RGB_S3TC_DXT1_EXT, compressed: true, gl1: S3TC},
123
+ // {gl: GL.COMPRESSED_RGBA_S3TC_DXT1_EXT, compressed: true, gl1: S3TC},
124
+ // {gl: GL.COMPRESSED_RGBA_S3TC_DXT3_EXT, compressed: true, gl1: S3TC},
125
+ // {gl: GL.COMPRESSED_RGBA_S3TC_DXT5_EXT, compressed: true, gl1: S3TC},
126
+
127
+ // WEBGL_compressed_texture_es3
128
+
129
+ // {gl: GL.COMPRESSED_R11_EAC, compressed: true, gl1: ES3}, // RED
130
+ // {gl: GL.COMPRESSED_SIGNED_R11_EAC, compressed: true, gl1: ES3}, // RED
131
+ // {gl: GL.COMPRESSED_RG11_EAC, compressed: true, gl1: ES3}, // RG
132
+ // {gl: GL.COMPRESSED_SIGNED_RG11_EAC, compressed: true, gl1: ES3}, // RG
133
+ // {gl: GL.COMPRESSED_RGB8_ETC2, compressed: true, gl1: ES3}, // RGB
134
+ // {gl: GL.COMPRESSED_RGBA8_ETC2_EAC, compressed: true, gl1: ES3}, // RBG
135
+ // {gl: GL.COMPRESSED_SRGB8_ETC2, compressed: true, gl1: ES3}, // RGB
136
+ // {gl: GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, compressed: true, gl1: ES3}, // RGBA
137
+ // {gl: GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, compressed: true, gl1: ES3}, // RGBA
138
+ // {gl: GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, compressed: true, gl1: ES3}, // RGBA
139
+ /* WebGL2 guaranteed availability compressed formats?
140
+ COMPRESSED_R11_EAC RED
141
+ COMPRESSED_SIGNED_R11_EAC RED
142
+ COMPRESSED_RG11_EAC RG
143
+ COMPRESSED_SIGNED_RG11_EAC RG
144
+ COMPRESSED_RGB8_ETC2 RGB
145
+ COMPRESSED_SRGB8_ETC2 RGB
146
+ COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 RGBA
147
+ COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 RGBA
148
+ COMPRESSED_RGBA8_ETC2_EAC RGBA
149
+ COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
150
+ */
151
+
152
+ // WEBGL_compressed_texture_pvrtc
153
+
154
+ // {gl: GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG, compressed: true, gl1: PVRTC},
155
+ // {gl: GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, compressed: true, gl1: PVRTC},
156
+ // {gl: GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG, compressed: true, gl1: PVRTC},
157
+ // {gl: GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, compressed: true, gl1: PVRTC},
158
+
159
+ // WEBGL_compressed_texture_etc1
160
+
161
+ // {gl: GL.COMPRESSED_RGB_ETC1_WEBGL, compressed: true, gl1: ETC1},
162
+
163
+ // WEBGL_compressed_texture_atc
164
+
165
+ // {gl: GL.COMPRESSED_RGB_ATC_WEBGL, compressed: true, gl1: ETC1},
166
+ // {gl: GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, compressed: true, gl1: ETC1},
167
+ // {gl: GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, compressed: true, gl1: ETC1}
@@ -3,10 +3,10 @@
3
3
  // available in an WebGL1 or WebGL2 environment.
4
4
 
5
5
  import GL from '@luma.gl/constants';
6
- import {isWebGL2} from '../context/context/webgl-checks';
7
- import {isOldIE} from '../webgl-utils/is-old-ie';
6
+ import {isWebGL2} from '../../context/context/webgl-checks';
7
+ import {isOldIE} from './is-old-ie';
8
8
 
9
- export type DeviceFeature =
9
+ export type DeviceFeature =
10
10
  'depth-clamping' |
11
11
  'depth24unorm-stencil8' |
12
12
  'depth32float-stencil8' |
@@ -15,7 +15,7 @@ export type DeviceFeature =
15
15
  'texture-compression-bc';
16
16
 
17
17
  // TODO - this should be the default export, test cases need updating
18
- export type WebGLFeature =
18
+ export type WebGLFeature =
19
19
  'webgl2' |
20
20
 
21
21
  // api support (unify with WebGPU timestamp-query?)
@@ -1,7 +1,7 @@
1
1
  // luma.gl, MIT license
2
2
  import type {DeviceLimits} from '@luma.gl/api';
3
3
  import GL from '@luma.gl/constants';
4
- import {getWebGL2Context} from '../context/context/webgl-checks';
4
+ import {getWebGL2Context} from '../../context/context/webgl-checks';
5
5
 
6
6
  /** Populate a WebGPU style device limits */
7
7
  export function getDeviceLimits(gl: WebGLRenderingContext): DeviceLimits {
@@ -1,7 +1,7 @@
1
1
  import {DeviceInfo} from '@luma.gl/api';
2
2
  import GL from '@luma.gl/constants';
3
- import {isWebGL2} from '../context/context/webgl-checks';
4
-
3
+ import {isWebGL2} from '../../context/context/webgl-checks';
4
+
5
5
  /** @returns strings identifying the GPU vendor and driver. */
6
6
  export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
7
7
  const vendorMasked = gl.getParameter(GL.VENDOR);
@@ -7,14 +7,14 @@ import {getDevicePixelRatio, setDevicePixelRatio} from '../context/context/devic
7
7
  import {createBrowserContext} from '../context/context/create-context';
8
8
  import {getCanvas} from '../context/context/get-canvas';
9
9
  import {isWebGL, isWebGL2} from '../context/context/webgl-checks';
10
- import {getDeviceInfo} from './get-device-info';
11
- import {getDeviceFeatures, Feature} from './device-features';
12
- import {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-limits';
10
+ import {getDeviceInfo} from './device-helpers/get-device-info';
11
+ import {getDeviceFeatures, Feature} from './device-helpers/device-features';
12
+ import {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';
13
13
 
14
14
  // WebGL classes
15
15
  import type {BufferProps, ShaderProps} from '@luma.gl/api';
16
16
  import WEBGLBuffer from '../classes/webgl-buffer';
17
- import {WEBGLShader} from '../classes/webgl-shader';
17
+ import {WEBGLShader} from '../adapter/webgl-shader';
18
18
  import Texture2D, {Texture2DProps} from '../classes/texture-2d';
19
19
  import type {default as Framebuffer} from '../classes/framebuffer';
20
20
  import type {default as VertexArrayObject} from '../classes/vertex-array-object';
@@ -111,7 +111,7 @@ export default class WebGLDevice extends Device implements ContextState {
111
111
  _polyfilled: boolean = false;
112
112
 
113
113
  /**
114
- *
114
+ *
115
115
  */
116
116
  static fromContext(gl: WebGLRenderingContext): WebGLDevice {
117
117
  // @ts-expect-error
@@ -130,7 +130,7 @@ export default class WebGLDevice extends Device implements ContextState {
130
130
  ): WebGLDevice {
131
131
  if (gl instanceof WebGLDevice) {
132
132
  return gl;
133
- }
133
+ }
134
134
  if (!isWebGL(gl)) {
135
135
  throw new Error('Invalid WebGLRenderingContext');
136
136
  }
@@ -140,7 +140,7 @@ export default class WebGLDevice extends Device implements ContextState {
140
140
 
141
141
  constructor(props: WebGLDeviceProps) {
142
142
  super();
143
-
143
+
144
144
  this.props = {...DEFAULT_DEVICE_PROPS, ...props};
145
145
 
146
146
  // If attaching to an already attached context, return the attached device
@@ -275,11 +275,11 @@ export default class WebGLDevice extends Device implements ContextState {
275
275
  }
276
276
 
277
277
  createTexture(props: Texture2DProps): Texture2D {
278
- return new Texture2D(this.gl, props);
278
+ return new Texture2D(this, props);
279
279
  }
280
280
 
281
281
  createShader(props: ShaderProps): WEBGLShader {
282
- return new WEBGLShader(this.gl, props);
282
+ return new WEBGLShader(this, props);
283
283
  }
284
284
 
285
285
  /**
@@ -0,0 +1,84 @@
1
+ // luma.gl, MIT license
2
+ import {log, uid, Shader, ShaderProps} from '@luma.gl/api';
3
+ import GL from '@luma.gl/constants';
4
+ import {getShaderInfo, CompilerMessage, formatCompilerLog} from '@luma.gl/shadertools';
5
+ import {parseShaderCompilerLog} from '../webgl-utils/parse-shader-compiler-log';
6
+ import WebGLDevice from '../adapter/webgl-device';
7
+
8
+ /**
9
+ * An immutable compiled shader program that execute portions of the GPU Pipeline
10
+ */
11
+ export class WEBGLShader extends Shader {
12
+ readonly device: WebGLDevice;
13
+ readonly gl: WebGLRenderingContext;
14
+ readonly handle: WebGLShader;
15
+
16
+ readonly stage: 'vertex' | 'fragment';
17
+ readonly source: string;
18
+
19
+ constructor(device: WebGLDevice, props: ShaderProps) {
20
+ super(device, {id: getShaderIdFromProps(props), ...props});
21
+ this.device = device;
22
+ this.gl = device.gl;
23
+ switch (this.props.stage) {
24
+ case 'vertex':
25
+ this.handle = this.props.handle || this.gl.createShader(GL.VERTEX_SHADER);
26
+ break;
27
+ case 'fragment':
28
+ this.handle = this.props.handle || this.gl.createShader(GL.FRAGMENT_SHADER);
29
+ break;
30
+ default:
31
+ throw new Error(this.props.stage);
32
+ }
33
+ this.stage = this.props.stage;
34
+ this.source = this.props.source;
35
+ this._compile(this.source);
36
+ }
37
+
38
+ destroy(): void {
39
+ if (this.handle) {
40
+ this.removeStats();
41
+ this.gl.deleteShader(this.handle);
42
+ // @ts-expect-error
43
+ this.handle = null;
44
+ }
45
+ }
46
+
47
+ async compilationInfo(): Promise<readonly CompilerMessage[]> {
48
+ const log = this.gl.getShaderInfoLog(this.handle);
49
+ return parseShaderCompilerLog(log);
50
+ }
51
+
52
+ // PRIVATE METHODS
53
+
54
+ _compile(source) {
55
+ const addGLSLVersion = source => source.startsWith('#version ') ? source : `#version 100\n${source}`;
56
+ source = addGLSLVersion(source);
57
+
58
+ this.gl.shaderSource(this.handle, source);
59
+ this.gl.compileShader(this.handle);
60
+
61
+ // TODO - For performance reasons, avoid checking shader compilation errors on production?
62
+ // TODO - Load log even when no error reported, to catch warnings?
63
+ // https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
64
+ const compileStatus = this.gl.getShaderParameter(this.handle, GL.COMPILE_STATUS);
65
+ if (!compileStatus) {
66
+ const shaderLog = this.gl.getShaderInfoLog(this.handle);
67
+ const messages = parseShaderCompilerLog(shaderLog).filter(message => message.type === 'error');
68
+ const formattedLog = formatCompilerLog(messages, source);
69
+ const shaderName: string = getShaderInfo(source).name;
70
+ const shaderDescription = `${this.stage} shader ${shaderName}`;
71
+ log.error(`GLSL compilation errors in ${shaderDescription}\n${formattedLog}`)();
72
+ throw new Error(`GLSL compilation errors in ${shaderName}`);
73
+ }
74
+ }
75
+ }
76
+
77
+ // HELPERS
78
+
79
+ /** Deduce an id, from shader source, or supplied id, or shader type */
80
+ function getShaderIdFromProps(props: ShaderProps): string {
81
+ return getShaderInfo(props.source).name ||
82
+ props.id ||
83
+ uid(`unnamed ${props.stage}-shader`);
84
+ }
@@ -1,6 +1,6 @@
1
1
  import {log, assert} from '@luma.gl/api';
2
2
  import GL from '@luma.gl/constants';
3
- import WebGLDevice from '../device/webgl-device';
3
+ import WebGLDevice from '../adapter/webgl-device';
4
4
  import {getWebGL2Context, assertWebGL2Context} from '../context/context/webgl-checks';
5
5
  import {getKey} from '../webgl-utils/constants-to-keys';
6
6
  import Resource, {ResourceProps} from './webgl-resource';
@@ -1,8 +1,9 @@
1
1
  // Contains metadata describing attribute configurations for a program's shaders
2
2
  // Much of this is automatically extracted from shaders after program linking
3
- import Accessor from './accessor';
4
- import {isWebGL2} from '../context/context/webgl-checks';
5
- import {decomposeCompositeGLType} from '../webgl-utils/attribute-utils';
3
+ // import Accessor from './accessor';
4
+ import type Program from './program';
5
+ import type {AttributeBinding, VaryingBinding} from '../helpers/program-bindings';
6
+ import {getProgramBindings} from '../helpers/get-program-bindings';
6
7
 
7
8
  /**
8
9
  * is a mechanism for taking a program object and querying information
@@ -12,22 +13,32 @@ import {decomposeCompositeGLType} from '../webgl-utils/attribute-utils';
12
13
  */
13
14
  export default class ProgramConfiguration {
14
15
  id: string;
15
- attributeInfos: any[] = [];
16
- attributeInfosByName: Record<string, any> = {};
16
+ attributeInfos: AttributeBinding[] = [];
17
+ attributeInfosByName: Record<string, AttributeBinding> = {};
17
18
  // Locations may not be contiguous the case of matrix attributes
18
19
  // so keep a separate location->attribute map.
19
- attributeInfosByLocation: any[] = [];
20
- varyingInfos: any[] = [];
21
- varyingInfosByName: Record<string, any> = {};
20
+ attributeInfosByLocation: AttributeBinding[] = [];
21
+ varyingInfos: VaryingBinding[] = [];
22
+ varyingInfosByName: Record<string, VaryingBinding> = {};
22
23
 
23
- constructor(program) {
24
+ constructor(program: Program) {
24
25
  this.id = program.id;
25
26
  Object.seal(this);
26
- this._readAttributesFromProgram(program);
27
- this._readVaryingsFromProgram(program);
27
+
28
+ const bindings = getProgramBindings(program.gl2, program.handle);
29
+
30
+ this.attributeInfos = bindings.attributes;
31
+ for (const attributeInfo of bindings.attributes) {
32
+ this.attributeInfosByName[attributeInfo.name] = attributeInfo;
33
+ this.attributeInfosByLocation[attributeInfo.location] = attributeInfo;
34
+ }
35
+
36
+ for (const varyingInfo of bindings.varyings) {
37
+ this.varyingInfosByName[varyingInfo.name] = varyingInfo;
38
+ }
28
39
  }
29
40
 
30
- getAttributeInfo(locationOrName) {
41
+ getAttributeInfo(locationOrName: number | string): AttributeBinding {
31
42
  const location = Number(locationOrName);
32
43
  if (Number.isFinite(location)) {
33
44
  return this.attributeInfosByLocation[location];
@@ -36,17 +47,17 @@ import {decomposeCompositeGLType} from '../webgl-utils/attribute-utils';
36
47
  }
37
48
 
38
49
  // Resolves an attribute name or index to an index
39
- getAttributeLocation(locationOrName) {
50
+ getAttributeLocation(locationOrName: number | string): number {
40
51
  const attributeInfo = this.getAttributeInfo(locationOrName);
41
52
  return attributeInfo ? attributeInfo.location : -1;
42
53
  }
43
54
 
44
- getAttributeAccessor(locationOrName) {
55
+ getAttributeAccessor(locationOrName: number | string) {
45
56
  const attributeInfo = this.getAttributeInfo(locationOrName);
46
57
  return attributeInfo ? attributeInfo.accessor : null;
47
58
  }
48
59
 
49
- getVaryingInfo(locationOrName) {
60
+ getVaryingInfo(locationOrName: number | string): VaryingBinding {
50
61
  const location = Number(locationOrName);
51
62
  if (Number.isFinite(location)) {
52
63
  return this.varyingInfos[location];
@@ -54,77 +65,13 @@ import {decomposeCompositeGLType} from '../webgl-utils/attribute-utils';
54
65
  return this.varyingInfosByName[locationOrName] || null;
55
66
  }
56
67
 
57
- getVaryingIndex(locationOrName) {
68
+ getVaryingIndex(locationOrName: number | string): number {
58
69
  const varying = this.getVaryingInfo(locationOrName);
59
70
  return varying ? varying.location : -1;
60
71
  }
61
72
 
62
- getVaryingAccessor(locationOrName) {
73
+ getVaryingAccessor(locationOrName: number | string) {
63
74
  const varying = this.getVaryingInfo(locationOrName);
64
75
  return varying ? varying.accessor : null;
65
76
  }
66
-
67
- // PRIVATE METHODS
68
-
69
- // linkProgram needs to have been called, although linking does not need to have been successful
70
- _readAttributesFromProgram(program) {
71
- const {gl} = program;
72
- const count = gl.getProgramParameter(program.handle, gl.ACTIVE_ATTRIBUTES);
73
-
74
- for (let index = 0; index < count; index++) {
75
- const {name, type, size} = gl.getActiveAttrib(program.handle, index);
76
- const location = gl.getAttribLocation(program.handle, name);
77
- // Add only user provided attributes, for built-in attributes like
78
- // `gl_InstanceID` locaiton will be < 0
79
- if (location >= 0) {
80
- this._addAttribute(location, name, type, size);
81
- }
82
- }
83
-
84
- this.attributeInfos.sort((a, b) => a.location - b.location);
85
- }
86
-
87
- // linkProgram needs to have been called, although linking does not need to have been successful
88
- _readVaryingsFromProgram(program) {
89
- const {gl} = program;
90
- if (!isWebGL2(gl)) {
91
- return;
92
- }
93
-
94
- const count = gl.getProgramParameter(program.handle, gl.TRANSFORM_FEEDBACK_VARYINGS);
95
- for (let location = 0; location < count; location++) {
96
- const {name, type, size} = gl.getTransformFeedbackVarying(program.handle, location);
97
- this._addVarying(location, name, type, size);
98
- }
99
-
100
- this.varyingInfos.sort((a, b) => a.location - b.location);
101
- }
102
-
103
- _addAttribute(location, name, compositeType, size) {
104
- const {type, components} = decomposeCompositeGLType(compositeType);
105
- const accessor = {type, size: size * components};
106
- this._inferProperties(location, name, accessor);
107
-
108
- const attributeInfo = {location, name, accessor: new Accessor(accessor)}; // Base values
109
- this.attributeInfos.push(attributeInfo);
110
- this.attributeInfosByLocation[location] = attributeInfo; // For quick location based lookup
111
- this.attributeInfosByName[attributeInfo.name] = attributeInfo; // For quick name based lookup
112
- }
113
-
114
- // Extract additional attribute metadata from shader names (based on attribute naming conventions)
115
- _inferProperties(location, name, accessor) {
116
- if (/instance/i.test(name)) {
117
- // Any attribute containing the word "instance" will be assumed to be instanced
118
- accessor.divisor = 1;
119
- }
120
- }
121
-
122
- _addVarying(location, name, compositeType, size) {
123
- const {type, components} = decomposeCompositeGLType(compositeType);
124
- const accessor = new Accessor({type, size: size * components});
125
-
126
- const varying = {location, name, accessor}; // Base values
127
- this.varyingInfos.push(varying);
128
- this.varyingInfosByName[varying.name] = varying; // For quick name based lookup
129
- }
130
77
  }