@flighthq/render-wgpu 0.5.1-next.973.788d3d7 → 0.6.0

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 (407) hide show
  1. package/README.md +2 -2
  2. package/dist/.tsbuildinfo.compressed-texture-decoder-contract +1 -0
  3. package/dist/.tsbuildinfo.contract +1 -0
  4. package/dist/.tsbuildinfo.runtime +1 -0
  5. package/dist/compressed-texture-decoder-contract/WgpuCompressedTextureDecoder.d.ts +3 -0
  6. package/dist/compressed-texture-decoder-contract/WgpuCompressedTextureDecoder.d.ts.map +1 -0
  7. package/dist/compressed-texture-decoder-contract/WgpuCompressedTextureDecoder.js +2 -0
  8. package/dist/compressed-texture-decoder-contract/WgpuCompressedTextureDecoder.js.map +1 -0
  9. package/dist/compressed-texture-decoder-contract/compressedTextureDecoderContract.d.ts +2 -0
  10. package/dist/compressed-texture-decoder-contract/compressedTextureDecoderContract.d.ts.map +1 -0
  11. package/dist/compressed-texture-decoder-contract/compressedTextureDecoderContract.js +2 -0
  12. package/dist/compressed-texture-decoder-contract/compressedTextureDecoderContract.js.map +1 -0
  13. package/dist/contract.d.ts +32 -34
  14. package/dist/contract.d.ts.map +1 -1
  15. package/dist/contract.js +32 -34
  16. package/dist/contract.js.map +1 -1
  17. package/dist/contract.render-wgpu-types.d.ts +55 -0
  18. package/dist/contract.render-wgpu-types.d.ts.map +1 -0
  19. package/dist/contract.render-wgpu-types.js +5 -0
  20. package/dist/contract.render-wgpu-types.js.map +1 -0
  21. package/dist/enableWgpuTextureResolverGuards.d.ts +3 -2
  22. package/dist/enableWgpuTextureResolverGuards.d.ts.map +1 -1
  23. package/dist/enableWgpuTextureResolverGuards.js +12 -9
  24. package/dist/enableWgpuTextureResolverGuards.js.map +1 -1
  25. package/dist/explainWgpuTextureResolution.d.ts +2 -1
  26. package/dist/explainWgpuTextureResolution.d.ts.map +1 -1
  27. package/dist/explainWgpuTextureResolution.js +2 -5
  28. package/dist/explainWgpuTextureResolution.js.map +1 -1
  29. package/dist/explainWgpuUniformEndianness.d.ts +3 -0
  30. package/dist/explainWgpuUniformEndianness.d.ts.map +1 -0
  31. package/dist/explainWgpuUniformEndianness.js +25 -0
  32. package/dist/explainWgpuUniformEndianness.js.map +1 -0
  33. package/dist/index.d.ts +20 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +20 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/types/Host.d.ts +5 -0
  38. package/dist/types/Host.d.ts.map +1 -0
  39. package/dist/types/Host.js +2 -0
  40. package/dist/types/Host.js.map +1 -0
  41. package/dist/types/WgpuAdapter.d.ts +14 -0
  42. package/dist/types/WgpuAdapter.d.ts.map +1 -0
  43. package/dist/types/WgpuAdapter.js +2 -0
  44. package/dist/types/WgpuAdapter.js.map +1 -0
  45. package/dist/types/WgpuAdapterCapabilities.d.ts +7 -0
  46. package/dist/types/WgpuAdapterCapabilities.d.ts.map +1 -0
  47. package/dist/types/WgpuAdapterCapabilities.js +2 -0
  48. package/dist/types/WgpuAdapterCapabilities.js.map +1 -0
  49. package/dist/types/WgpuBindGroup.d.ts +23 -0
  50. package/dist/types/WgpuBindGroup.d.ts.map +1 -0
  51. package/dist/types/WgpuBindGroup.js +2 -0
  52. package/dist/types/WgpuBindGroup.js.map +1 -0
  53. package/dist/types/WgpuBindGroupLayout.d.ts +45 -0
  54. package/dist/types/WgpuBindGroupLayout.d.ts.map +1 -0
  55. package/dist/types/WgpuBindGroupLayout.js +7 -0
  56. package/dist/types/WgpuBindGroupLayout.js.map +1 -0
  57. package/dist/types/WgpuBuffer.d.ts +34 -0
  58. package/dist/types/WgpuBuffer.d.ts.map +1 -0
  59. package/dist/types/WgpuBuffer.js +19 -0
  60. package/dist/types/WgpuBuffer.js.map +1 -0
  61. package/dist/types/WgpuCanvasContext.d.ts +17 -0
  62. package/dist/types/WgpuCanvasContext.d.ts.map +1 -0
  63. package/dist/types/WgpuCanvasContext.js +2 -0
  64. package/dist/types/WgpuCanvasContext.js.map +1 -0
  65. package/dist/types/WgpuColorAdjustmentMaterialFeature.d.ts +14 -0
  66. package/dist/types/WgpuColorAdjustmentMaterialFeature.d.ts.map +1 -0
  67. package/dist/types/WgpuColorAdjustmentMaterialFeature.js +2 -0
  68. package/dist/types/WgpuColorAdjustmentMaterialFeature.js.map +1 -0
  69. package/dist/types/WgpuCommandBuffer.d.ts +5 -0
  70. package/dist/types/WgpuCommandBuffer.d.ts.map +1 -0
  71. package/dist/types/WgpuCommandBuffer.js +2 -0
  72. package/dist/types/WgpuCommandBuffer.js.map +1 -0
  73. package/dist/types/WgpuCommandEncoder.d.ts +12 -0
  74. package/dist/types/WgpuCommandEncoder.d.ts.map +1 -0
  75. package/dist/types/WgpuCommandEncoder.js +2 -0
  76. package/dist/types/WgpuCommandEncoder.js.map +1 -0
  77. package/dist/types/WgpuCompressedTextureSupport.d.ts +6 -0
  78. package/dist/types/WgpuCompressedTextureSupport.d.ts.map +1 -0
  79. package/dist/types/WgpuCompressedTextureSupport.js +2 -0
  80. package/dist/types/WgpuCompressedTextureSupport.js.map +1 -0
  81. package/dist/types/WgpuCompressedTextureUploader.d.ts +6 -0
  82. package/dist/types/WgpuCompressedTextureUploader.d.ts.map +1 -0
  83. package/dist/types/WgpuCompressedTextureUploader.js +2 -0
  84. package/dist/types/WgpuCompressedTextureUploader.js.map +1 -0
  85. package/dist/types/WgpuCustomMaterialShaderSource.d.ts +2 -0
  86. package/dist/types/WgpuCustomMaterialShaderSource.d.ts.map +1 -0
  87. package/dist/types/WgpuCustomMaterialShaderSource.js +2 -0
  88. package/dist/types/WgpuCustomMaterialShaderSource.js.map +1 -0
  89. package/dist/types/WgpuDevice.d.ts +76 -0
  90. package/dist/types/WgpuDevice.d.ts.map +1 -0
  91. package/dist/types/WgpuDevice.js +2 -0
  92. package/dist/types/WgpuDevice.js.map +1 -0
  93. package/dist/types/WgpuDeviceRuntime.d.ts +53 -0
  94. package/dist/types/WgpuDeviceRuntime.d.ts.map +1 -0
  95. package/dist/types/WgpuDeviceRuntime.js +2 -0
  96. package/dist/types/WgpuDeviceRuntime.js.map +1 -0
  97. package/dist/types/WgpuDeviceSignals.d.ts +6 -0
  98. package/dist/types/WgpuDeviceSignals.d.ts.map +1 -0
  99. package/dist/types/WgpuDeviceSignals.js +2 -0
  100. package/dist/types/WgpuDeviceSignals.js.map +1 -0
  101. package/dist/types/WgpuDeviceState.d.ts +7 -0
  102. package/dist/types/WgpuDeviceState.d.ts.map +1 -0
  103. package/dist/types/WgpuDeviceState.js +2 -0
  104. package/dist/types/WgpuDeviceState.js.map +1 -0
  105. package/dist/types/WgpuEffectState.d.ts +19 -0
  106. package/dist/types/WgpuEffectState.d.ts.map +1 -0
  107. package/dist/types/WgpuEffectState.js +2 -0
  108. package/dist/types/WgpuEffectState.js.map +1 -0
  109. package/dist/types/WgpuExternalImageSource.d.ts +18 -0
  110. package/dist/types/WgpuExternalImageSource.d.ts.map +1 -0
  111. package/dist/types/WgpuExternalImageSource.js +2 -0
  112. package/dist/types/WgpuExternalImageSource.js.map +1 -0
  113. package/dist/types/WgpuFullscreenPipeline.d.ts +14 -0
  114. package/dist/types/WgpuFullscreenPipeline.d.ts.map +1 -0
  115. package/dist/types/WgpuFullscreenPipeline.js +2 -0
  116. package/dist/types/WgpuFullscreenPipeline.js.map +1 -0
  117. package/dist/types/WgpuGpu.d.ts +7 -0
  118. package/dist/types/WgpuGpu.d.ts.map +1 -0
  119. package/dist/types/WgpuGpu.js +2 -0
  120. package/dist/types/WgpuGpu.js.map +1 -0
  121. package/dist/types/WgpuHost.d.ts +44 -0
  122. package/dist/types/WgpuHost.d.ts.map +1 -0
  123. package/dist/types/WgpuHost.js +2 -0
  124. package/dist/types/WgpuHost.js.map +1 -0
  125. package/dist/types/WgpuMeshMaterialRenderer.d.ts +11 -0
  126. package/dist/types/WgpuMeshMaterialRenderer.d.ts.map +1 -0
  127. package/dist/types/WgpuMeshMaterialRenderer.js +2 -0
  128. package/dist/types/WgpuMeshMaterialRenderer.js.map +1 -0
  129. package/dist/types/WgpuModifierSnippet.d.ts +16 -0
  130. package/dist/types/WgpuModifierSnippet.d.ts.map +1 -0
  131. package/dist/types/WgpuModifierSnippet.js +2 -0
  132. package/dist/types/WgpuModifierSnippet.js.map +1 -0
  133. package/dist/types/WgpuParticleResources.d.ts +12 -0
  134. package/dist/types/WgpuParticleResources.d.ts.map +1 -0
  135. package/dist/types/WgpuParticleResources.js +2 -0
  136. package/dist/types/WgpuParticleResources.js.map +1 -0
  137. package/dist/types/WgpuPipelineLayout.d.ts +8 -0
  138. package/dist/types/WgpuPipelineLayout.d.ts.map +1 -0
  139. package/dist/types/WgpuPipelineLayout.js +2 -0
  140. package/dist/types/WgpuPipelineLayout.js.map +1 -0
  141. package/dist/types/WgpuQuadBatchResources.d.ts +12 -0
  142. package/dist/types/WgpuQuadBatchResources.d.ts.map +1 -0
  143. package/dist/types/WgpuQuadBatchResources.js +2 -0
  144. package/dist/types/WgpuQuadBatchResources.js.map +1 -0
  145. package/dist/types/WgpuQuadMaterialRenderer.d.ts +9 -0
  146. package/dist/types/WgpuQuadMaterialRenderer.d.ts.map +1 -0
  147. package/dist/types/WgpuQuadMaterialRenderer.js +2 -0
  148. package/dist/types/WgpuQuadMaterialRenderer.js.map +1 -0
  149. package/dist/types/WgpuQueue.d.ts +12 -0
  150. package/dist/types/WgpuQueue.d.ts.map +1 -0
  151. package/dist/types/WgpuQueue.js +2 -0
  152. package/dist/types/WgpuQueue.js.map +1 -0
  153. package/dist/types/WgpuRenderOptions.d.ts +14 -0
  154. package/dist/types/WgpuRenderOptions.d.ts.map +1 -0
  155. package/dist/types/WgpuRenderOptions.js +2 -0
  156. package/dist/types/WgpuRenderOptions.js.map +1 -0
  157. package/dist/types/WgpuRenderPass.d.ts +31 -0
  158. package/dist/types/WgpuRenderPass.d.ts.map +1 -0
  159. package/dist/types/WgpuRenderPass.js +2 -0
  160. package/dist/types/WgpuRenderPass.js.map +1 -0
  161. package/dist/types/WgpuRenderPassEncoder.d.ts +52 -0
  162. package/dist/types/WgpuRenderPassEncoder.d.ts.map +1 -0
  163. package/dist/types/WgpuRenderPassEncoder.js +2 -0
  164. package/dist/types/WgpuRenderPassEncoder.js.map +1 -0
  165. package/dist/types/WgpuRenderPipeline.d.ts +96 -0
  166. package/dist/types/WgpuRenderPipeline.d.ts.map +1 -0
  167. package/dist/types/WgpuRenderPipeline.js +9 -0
  168. package/dist/types/WgpuRenderPipeline.js.map +1 -0
  169. package/dist/types/WgpuRenderState.d.ts +249 -0
  170. package/dist/types/WgpuRenderState.d.ts.map +1 -0
  171. package/dist/types/WgpuRenderState.js +2 -0
  172. package/dist/types/WgpuRenderState.js.map +1 -0
  173. package/dist/types/WgpuRenderStateOptions.d.ts +31 -0
  174. package/dist/types/WgpuRenderStateOptions.d.ts.map +1 -0
  175. package/dist/types/WgpuRenderStateOptions.js +2 -0
  176. package/dist/types/WgpuRenderStateOptions.js.map +1 -0
  177. package/dist/types/WgpuRenderTarget.d.ts +62 -0
  178. package/dist/types/WgpuRenderTarget.d.ts.map +1 -0
  179. package/dist/types/WgpuRenderTarget.js +2 -0
  180. package/dist/types/WgpuRenderTarget.js.map +1 -0
  181. package/dist/types/WgpuRenderTexture.d.ts +25 -0
  182. package/dist/types/WgpuRenderTexture.d.ts.map +1 -0
  183. package/dist/types/WgpuRenderTexture.js +2 -0
  184. package/dist/types/WgpuRenderTexture.js.map +1 -0
  185. package/dist/types/WgpuSampler.d.ts +19 -0
  186. package/dist/types/WgpuSampler.d.ts.map +1 -0
  187. package/dist/types/WgpuSampler.js +2 -0
  188. package/dist/types/WgpuSampler.js.map +1 -0
  189. package/dist/types/WgpuScene3DRuntime.d.ts +6 -0
  190. package/dist/types/WgpuScene3DRuntime.d.ts.map +1 -0
  191. package/dist/types/WgpuScene3DRuntime.js +2 -0
  192. package/dist/types/WgpuScene3DRuntime.js.map +1 -0
  193. package/dist/types/WgpuShaderModule.d.ts +6 -0
  194. package/dist/types/WgpuShaderModule.d.ts.map +1 -0
  195. package/dist/types/WgpuShaderModule.js +2 -0
  196. package/dist/types/WgpuShaderModule.js.map +1 -0
  197. package/dist/types/WgpuShapeMesh.d.ts +7 -0
  198. package/dist/types/WgpuShapeMesh.d.ts.map +1 -0
  199. package/dist/types/WgpuShapeMesh.js +2 -0
  200. package/dist/types/WgpuShapeMesh.js.map +1 -0
  201. package/dist/types/WgpuSkinningAdapter.d.ts +18 -0
  202. package/dist/types/WgpuSkinningAdapter.d.ts.map +1 -0
  203. package/dist/types/WgpuSkinningAdapter.js +2 -0
  204. package/dist/types/WgpuSkinningAdapter.js.map +1 -0
  205. package/dist/types/WgpuSurface.d.ts +5 -0
  206. package/dist/types/WgpuSurface.d.ts.map +1 -0
  207. package/dist/types/WgpuSurface.js +2 -0
  208. package/dist/types/WgpuSurface.js.map +1 -0
  209. package/dist/types/WgpuTexture.d.ts +58 -0
  210. package/dist/types/WgpuTexture.d.ts.map +1 -0
  211. package/dist/types/WgpuTexture.js +9 -0
  212. package/dist/types/WgpuTexture.js.map +1 -0
  213. package/dist/types/WgpuTextureFormat.d.ts +2 -0
  214. package/dist/types/WgpuTextureFormat.d.ts.map +1 -0
  215. package/dist/types/WgpuTextureFormat.js +2 -0
  216. package/dist/types/WgpuTextureFormat.js.map +1 -0
  217. package/dist/types/WgpuTextureResolver.d.ts +4 -0
  218. package/dist/types/WgpuTextureResolver.d.ts.map +1 -0
  219. package/dist/types/WgpuTextureResolver.js +2 -0
  220. package/dist/types/WgpuTextureResolver.js.map +1 -0
  221. package/dist/types/WgpuTextureView.d.ts +16 -0
  222. package/dist/types/WgpuTextureView.d.ts.map +1 -0
  223. package/dist/types/WgpuTextureView.js +2 -0
  224. package/dist/types/WgpuTextureView.js.map +1 -0
  225. package/dist/types/WgpuUniformEndianness.d.ts +7 -0
  226. package/dist/types/WgpuUniformEndianness.d.ts.map +1 -0
  227. package/dist/types/WgpuUniformEndianness.js +2 -0
  228. package/dist/types/WgpuUniformEndianness.js.map +1 -0
  229. package/dist/types/WgpuVelocityWriter.d.ts +11 -0
  230. package/dist/types/WgpuVelocityWriter.d.ts.map +1 -0
  231. package/dist/types/WgpuVelocityWriter.js +2 -0
  232. package/dist/types/WgpuVelocityWriter.js.map +1 -0
  233. package/dist/wgpuAdapterCapabilities.d.ts +2 -2
  234. package/dist/wgpuAdapterCapabilities.d.ts.map +1 -1
  235. package/dist/wgpuAdapterCapabilities.js.map +1 -1
  236. package/dist/wgpuCompressedTexture.d.ts +7 -5
  237. package/dist/wgpuCompressedTexture.d.ts.map +1 -1
  238. package/dist/wgpuCompressedTexture.js +10 -18
  239. package/dist/wgpuCompressedTexture.js.map +1 -1
  240. package/dist/wgpuDeviceLoss.d.ts +2 -2
  241. package/dist/wgpuDeviceLoss.d.ts.map +1 -1
  242. package/dist/wgpuDeviceLoss.js +1 -1
  243. package/dist/wgpuDeviceLoss.js.map +1 -1
  244. package/dist/wgpuDraw.d.ts +11 -5
  245. package/dist/wgpuDraw.d.ts.map +1 -1
  246. package/dist/wgpuDraw.js +21 -20
  247. package/dist/wgpuDraw.js.map +1 -1
  248. package/dist/wgpuExternalImageSource.d.ts +3 -2
  249. package/dist/wgpuExternalImageSource.d.ts.map +1 -1
  250. package/dist/wgpuExternalImageSource.js.map +1 -1
  251. package/dist/wgpuExternalTexture.d.ts +7 -3
  252. package/dist/wgpuExternalTexture.d.ts.map +1 -1
  253. package/dist/wgpuExternalTexture.js +5 -5
  254. package/dist/wgpuExternalTexture.js.map +1 -1
  255. package/dist/wgpuFrame.d.ts +23 -0
  256. package/dist/wgpuFrame.d.ts.map +1 -0
  257. package/dist/{wgpuBackground.js → wgpuFrame.js} +67 -122
  258. package/dist/wgpuFrame.js.map +1 -0
  259. package/dist/wgpuFullscreenPass.d.ts +5 -4
  260. package/dist/wgpuFullscreenPass.d.ts.map +1 -1
  261. package/dist/wgpuFullscreenPass.js +22 -8
  262. package/dist/wgpuFullscreenPass.js.map +1 -1
  263. package/dist/wgpuHost.d.ts +4 -7
  264. package/dist/wgpuHost.d.ts.map +1 -1
  265. package/dist/wgpuHost.js +81 -70
  266. package/dist/wgpuHost.js.map +1 -1
  267. package/dist/wgpuMipmap.d.ts +2 -2
  268. package/dist/wgpuMipmap.d.ts.map +1 -1
  269. package/dist/wgpuMipmap.js +4 -3
  270. package/dist/wgpuMipmap.js.map +1 -1
  271. package/dist/wgpuQuadMaterialRegistry.d.ts +7 -0
  272. package/dist/wgpuQuadMaterialRegistry.d.ts.map +1 -0
  273. package/dist/wgpuQuadMaterialRegistry.js +33 -0
  274. package/dist/wgpuQuadMaterialRegistry.js.map +1 -0
  275. package/dist/wgpuRenderPass.d.ts +9 -0
  276. package/dist/wgpuRenderPass.d.ts.map +1 -0
  277. package/dist/wgpuRenderPass.js +210 -0
  278. package/dist/wgpuRenderPass.js.map +1 -0
  279. package/dist/wgpuRenderState.d.ts +16 -12
  280. package/dist/wgpuRenderState.d.ts.map +1 -1
  281. package/dist/wgpuRenderState.js +104 -149
  282. package/dist/wgpuRenderState.js.map +1 -1
  283. package/dist/wgpuRenderTarget.d.ts +13 -29
  284. package/dist/wgpuRenderTarget.d.ts.map +1 -1
  285. package/dist/wgpuRenderTarget.js +20 -253
  286. package/dist/wgpuRenderTarget.js.map +1 -1
  287. package/dist/wgpuRenderTargetPool.d.ts +8 -6
  288. package/dist/wgpuRenderTargetPool.d.ts.map +1 -1
  289. package/dist/wgpuRenderTargetPool.js +9 -9
  290. package/dist/wgpuRenderTargetPool.js.map +1 -1
  291. package/dist/wgpuRenderTexture.d.ts +7 -4
  292. package/dist/wgpuRenderTexture.d.ts.map +1 -1
  293. package/dist/wgpuRenderTexture.js +15 -17
  294. package/dist/wgpuRenderTexture.js.map +1 -1
  295. package/dist/wgpuRenderTexturePool.d.ts +3 -1
  296. package/dist/wgpuRenderTexturePool.d.ts.map +1 -1
  297. package/dist/wgpuRenderTexturePool.js +5 -7
  298. package/dist/wgpuRenderTexturePool.js.map +1 -1
  299. package/dist/wgpuScissor.d.ts +3 -3
  300. package/dist/wgpuScissor.d.ts.map +1 -1
  301. package/dist/wgpuScissor.js +8 -5
  302. package/dist/wgpuScissor.js.map +1 -1
  303. package/dist/wgpuScreenAntialias.d.ts +3 -0
  304. package/dist/wgpuScreenAntialias.d.ts.map +1 -0
  305. package/dist/wgpuScreenAntialias.js +120 -0
  306. package/dist/wgpuScreenAntialias.js.map +1 -0
  307. package/dist/wgpuScreenCapture.d.ts +6 -0
  308. package/dist/wgpuScreenCapture.d.ts.map +1 -0
  309. package/dist/wgpuScreenCapture.js +138 -0
  310. package/dist/wgpuScreenCapture.js.map +1 -0
  311. package/dist/wgpuScreenRenderTarget.d.ts +11 -0
  312. package/dist/wgpuScreenRenderTarget.d.ts.map +1 -0
  313. package/dist/wgpuScreenRenderTarget.js +121 -0
  314. package/dist/wgpuScreenRenderTarget.js.map +1 -0
  315. package/dist/wgpuShader.d.ts +11 -8
  316. package/dist/wgpuShader.d.ts.map +1 -1
  317. package/dist/wgpuShader.js +11 -10
  318. package/dist/wgpuShader.js.map +1 -1
  319. package/dist/wgpuShaderBinding.d.ts +3 -1
  320. package/dist/wgpuShaderBinding.d.ts.map +1 -1
  321. package/dist/wgpuShaderBinding.js +1 -1
  322. package/dist/wgpuShaderBinding.js.map +1 -1
  323. package/dist/wgpuShaderRegistry.d.ts +1 -1
  324. package/dist/wgpuShaderRegistry.d.ts.map +1 -1
  325. package/dist/wgpuShaderRegistry.js +1 -1
  326. package/dist/wgpuShaderRegistry.js.map +1 -1
  327. package/dist/wgpuTestHelper.d.ts +11 -2
  328. package/dist/wgpuTestHelper.d.ts.map +1 -1
  329. package/dist/wgpuTestHelper.js +50 -38
  330. package/dist/wgpuTestHelper.js.map +1 -1
  331. package/dist/wgpuTextureRenderTarget.d.ts +22 -0
  332. package/dist/wgpuTextureRenderTarget.d.ts.map +1 -0
  333. package/dist/wgpuTextureRenderTarget.js +123 -0
  334. package/dist/wgpuTextureRenderTarget.js.map +1 -0
  335. package/dist/wgpuTextureResolver.d.ts +5 -1
  336. package/dist/wgpuTextureResolver.d.ts.map +1 -1
  337. package/dist/wgpuTextureResolver.js +13 -12
  338. package/dist/wgpuTextureResolver.js.map +1 -1
  339. package/dist/wgpuTextureUpload.d.ts +5 -4
  340. package/dist/wgpuTextureUpload.d.ts.map +1 -1
  341. package/dist/wgpuTextureUpload.js +1 -1
  342. package/dist/wgpuTextureUpload.js.map +1 -1
  343. package/package.json +33 -13
  344. package/src/enableWgpuTextureResolverGuards.test.ts +40 -19
  345. package/src/explainWgpuTextureResolution.test.ts +6 -6
  346. package/src/explainWgpuUniformEndianness.test.ts +11 -0
  347. package/src/types/WgpuBindGroupLayout.test.ts +9 -0
  348. package/src/types/WgpuBuffer.test.ts +26 -0
  349. package/src/types/WgpuGpu.test.ts +56 -0
  350. package/src/types/WgpuRenderPipeline.test.ts +12 -0
  351. package/src/types/WgpuTexture.test.ts +15 -0
  352. package/src/wgpuAdapterCapabilities.test.ts +5 -4
  353. package/src/wgpuCompressedTexture.test.ts +31 -37
  354. package/src/wgpuDeviceLoss.test.ts +31 -24
  355. package/src/wgpuDraw.test.ts +21 -24
  356. package/src/wgpuExternalImageSource.test.ts +12 -11
  357. package/src/wgpuExternalTexture.test.ts +7 -6
  358. package/src/{wgpuBackground.test.ts → wgpuFrame.test.ts} +47 -29
  359. package/src/wgpuFullscreenPass.test.ts +8 -8
  360. package/src/wgpuHost.test.ts +57 -186
  361. package/src/wgpuMipmap.test.ts +15 -9
  362. package/src/wgpuQuadMaterialRegistry.test.ts +132 -0
  363. package/src/wgpuRenderPass.test.ts +239 -0
  364. package/src/wgpuRenderState.test.ts +215 -550
  365. package/src/wgpuRenderTarget.test.ts +44 -220
  366. package/src/wgpuRenderTargetPool.test.ts +23 -23
  367. package/src/wgpuRenderTexture.test.ts +21 -18
  368. package/src/wgpuRenderTexturePool.test.ts +3 -3
  369. package/src/wgpuScissor.test.ts +50 -19
  370. package/src/wgpuScreenAntialias.test.ts +65 -0
  371. package/src/wgpuScreenCapture.test.ts +165 -0
  372. package/src/wgpuScreenRenderTarget.test.ts +172 -0
  373. package/src/wgpuShader.test.ts +12 -11
  374. package/src/wgpuShaderBinding.test.ts +4 -4
  375. package/src/wgpuShaderRegistry.test.ts +4 -5
  376. package/src/wgpuTestHelper.test.ts +8 -7
  377. package/src/wgpuTextureRenderTarget.test.ts +129 -0
  378. package/src/wgpuTextureResolver.test.ts +25 -14
  379. package/src/wgpuTextureUpload.test.ts +15 -10
  380. package/dist/wgpuAntialias.d.ts +0 -14
  381. package/dist/wgpuAntialias.d.ts.map +0 -1
  382. package/dist/wgpuAntialias.js +0 -155
  383. package/dist/wgpuAntialias.js.map +0 -1
  384. package/dist/wgpuBackground.d.ts +0 -20
  385. package/dist/wgpuBackground.d.ts.map +0 -1
  386. package/dist/wgpuBackground.js.map +0 -1
  387. package/dist/wgpuElement.d.ts +0 -7
  388. package/dist/wgpuElement.d.ts.map +0 -1
  389. package/dist/wgpuElement.js +0 -20
  390. package/dist/wgpuElement.js.map +0 -1
  391. package/dist/wgpuMaterialRegistry.d.ts +0 -5
  392. package/dist/wgpuMaterialRegistry.d.ts.map +0 -1
  393. package/dist/wgpuMaterialRegistry.js +0 -32
  394. package/dist/wgpuMaterialRegistry.js.map +0 -1
  395. package/dist/wgpuPipeline.d.ts +0 -6
  396. package/dist/wgpuPipeline.d.ts.map +0 -1
  397. package/dist/wgpuPipeline.js +0 -33
  398. package/dist/wgpuPipeline.js.map +0 -1
  399. package/dist/wgpuSurface.d.ts +0 -6
  400. package/dist/wgpuSurface.d.ts.map +0 -1
  401. package/dist/wgpuSurface.js +0 -155
  402. package/dist/wgpuSurface.js.map +0 -1
  403. package/src/wgpuAntialias.test.ts +0 -239
  404. package/src/wgpuElement.test.ts +0 -145
  405. package/src/wgpuMaterialRegistry.test.ts +0 -100
  406. package/src/wgpuPipeline.test.ts +0 -62
  407. package/src/wgpuSurface.test.ts +0 -141
@@ -1,6 +1,6 @@
1
- import type { WgpuRenderState, WgpuScissorRect } from '@flighthq/types/contract';
2
- export declare function applyWgpuScissorRect(state: WgpuRenderState, pass: GPURenderPassEncoder): void;
1
+ import type { WgpuRenderPassEncoder, WgpuRenderState, WgpuScissorRect } from './contract.render-wgpu-types.ts';
2
+ export declare function applyWgpuScissorRect(state: WgpuRenderState, pass: WgpuRenderPassEncoder): void;
3
3
  export declare function popWgpuScissorRect(state: WgpuRenderState): void;
4
4
  export declare function pushWgpuScissorRect(state: WgpuRenderState, rect: Readonly<WgpuScissorRect>): void;
5
- export declare function setWgpuRenderPassScissorRect(state: Readonly<WgpuRenderState>, pass: GPURenderPassEncoder, x: number, y: number, width: number, height: number): void;
5
+ export declare function setWgpuRenderPassScissorRect(state: WgpuRenderState, pass: WgpuRenderPassEncoder, x: number, y: number, width: number, height: number): void;
6
6
  //# sourceMappingURL=wgpuScissor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wgpuScissor.d.ts","sourceRoot":"","sources":["../src/wgpuScissor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAQjF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAW7F;AAKD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAI/D;AAMD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,IAAI,CAMjG;AAID,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,EAChC,IAAI,EAAE,oBAAoB,EAC1B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,IAAI,CAGN"}
1
+ {"version":3,"file":"wgpuScissor.d.ts","sourceRoot":"","sources":["../src/wgpuScissor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAO/G,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAW9F;AAKD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAI/D;AAMD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,IAAI,CAMjG;AAMD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,qBAAqB,EAC3B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,IAAI,CAIN"}
@@ -1,5 +1,5 @@
1
- import { getWgpuSurfaceRenderScale } from './wgpuAntialias';
2
- import { getWgpuRenderStateRuntime } from './wgpuRenderState';
1
+ import { getWgpuRenderStateRuntime } from './wgpuRenderState.js';
2
+ import { getWgpuRenderTargetSupersampleScale } from './wgpuRenderTarget.js';
3
3
  // Applies the current scissor rectangle to the active render pass. No-op when there is no active
4
4
  // scissor or no open render pass. Call after each draw call or once per pass when the active
5
5
  // scissor changes.
@@ -35,10 +35,13 @@ export function pushWgpuScissorRect(state, rect) {
35
35
  }
36
36
  runtime.currentScissorRect = { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
37
37
  }
38
- // Converts a logical main-surface scissor to the physical supersample surface. Offscreen render-target
39
- // scissors pass through unchanged because their viewport and texture already share one coordinate space.
38
+ // Converts a logical scissor rect to the target's physical extent. Logical is the space every 2D
39
+ // coordinate is in — the pass viewport, the projection, and these rects — so a supersampled target
40
+ // (a screen with antialias, or an effect target at sampleCount 4) scales them by the same factor its
41
+ // storage was grown by, and a target with no supersample scales by 1.
40
42
  export function setWgpuRenderPassScissorRect(state, pass, x, y, width, height) {
41
- const scale = getWgpuSurfaceRenderScale(state);
43
+ const target = getWgpuRenderStateRuntime(state).currentRenderTarget;
44
+ const scale = target === null ? 1 : getWgpuRenderTargetSupersampleScale(target);
42
45
  pass.setScissorRect(x * scale, y * scale, width * scale, height * scale);
43
46
  }
44
47
  //# sourceMappingURL=wgpuScissor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wgpuScissor.js","sourceRoot":"","sources":["../src/wgpuScissor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,iGAAiG;AACjG,6FAA6F;AAC7F,mBAAmB;AACnB,MAAM,UAAU,oBAAoB,CAAC,KAAsB,EAAE,IAA0B;IACrF,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC;IACxC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO;IAC1B,kGAAkG;IAClG,yEAAyE;IACzE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,4BAA4B,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,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G,IAAI,IAAI,IAAI,CAAC;AAC5C,CAAC;AAED,2FAA2F;AAC3F,kGAAkG;AAClG,gGAAgG;AAChG,qEAAqE;AACrE,MAAM,UAAU,mBAAmB,CAAC,KAAsB,EAAE,IAA+B;IACzF,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,IAAI,OAAO,CAAC,kBAAkB,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,CAAC,kBAAkB,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AAChG,CAAC;AAED,iGAAiG;AACjG,mGAAmG;AACnG,qGAAqG;AACrG,sEAAsE;AACtE,MAAM,UAAU,4BAA4B,CAC1C,KAAsB,EACtB,IAA2B,EAC3B,CAAS,EACT,CAAS,EACT,KAAa,EACb,MAAc;IAEd,MAAM,MAAM,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC,mBAAmB,CAAC;IACpE,MAAM,KAAK,GAAG,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC,CAAC,MAAM,CAAC,CAAC;IAChF,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { WgpuScreenRenderTarget } from './contract.render-wgpu-types.ts';
2
+ export declare function enableWgpuScreenRenderTargetAntialias(target: WgpuScreenRenderTarget): void;
3
+ //# sourceMappingURL=wgpuScreenAntialias.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuScreenAntialias.d.ts","sourceRoot":"","sources":["../src/wgpuScreenAntialias.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,sBAAsB,EAEvB,MAAM,iCAAiC,CAAC;AAazC,wBAAgB,qCAAqC,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAO1F"}
@@ -0,0 +1,120 @@
1
+ import { WgpuShaderStage, WgpuTextureUsage } from './contract.render-wgpu-types.js';
2
+ import { getWgpuRenderStateDeviceResources, getWgpuRenderStateRuntime } from './wgpuRenderState.js';
3
+ import { syncWgpuScreenRenderTargetExtent } from './wgpuScreenRenderTarget.js';
4
+ // Turns on 2x-per-axis supersampling for a screen target: the frame draws into a 2x texture and one
5
+ // fullscreen linear-sampling pass resolves it into the swap chain immediately before submit. Each
6
+ // destination pixel center averages the corresponding 2x2 source texels, so this is a real resolve and
7
+ // not a post-hoc image filter, and every scene pipeline stays single-sampled — the seam is the surface,
8
+ // not the pipeline.
9
+ //
10
+ // Separately importable on purpose: a frame loop that never calls this pulls in neither the resolve
11
+ // pipeline nor its shader, which is most of what a screen target would otherwise cost.
12
+ export function enableWgpuScreenRenderTargetAntialias(target) {
13
+ target.antialias = true;
14
+ target.acquireAntialiasView = acquireWgpuScreenRenderTargetAntialiasView;
15
+ target.encodeAntialiasResolve = encodeWgpuScreenRenderTargetResolve;
16
+ // The extent is physical storage, and the factor it is measured in just changed: re-sync now rather
17
+ // than leaving width/height a frame behind the flag that scales them.
18
+ syncWgpuScreenRenderTargetExtent(target);
19
+ }
20
+ function acquireWgpuScreenRenderTargetAntialiasView(state, target) {
21
+ const width = target.width;
22
+ const height = target.height;
23
+ const maxDimension = target.device.limits.maxTextureDimension2D;
24
+ if (width > maxDimension || height > maxDimension) {
25
+ throw new Error(`enableWgpuScreenRenderTargetAntialias requires a ${width}x${height} supersample surface, exceeding maxTextureDimension2D ${maxDimension}.`);
26
+ }
27
+ const existing = target.antialiasTexture;
28
+ if (existing !== null && existing.width === width && existing.height === height)
29
+ return target.antialiasView;
30
+ existing?.destroy();
31
+ const texture = target.device.createTexture({
32
+ size: [width, height, 1],
33
+ format: target.format,
34
+ usage: WgpuTextureUsage.RENDER_ATTACHMENT | WgpuTextureUsage.TEXTURE_BINDING,
35
+ });
36
+ target.antialiasTexture = texture;
37
+ target.antialiasView = texture.createView();
38
+ target.antialiasResolveBindGroup = target.device.createBindGroup({
39
+ layout: ensureWgpuScreenAntialiasPipeline(state, target),
40
+ entries: [
41
+ { binding: 0, resource: target.antialiasView },
42
+ { binding: 1, resource: getWgpuRenderStateDeviceResources(state).linearSampler },
43
+ ],
44
+ });
45
+ return target.antialiasView;
46
+ }
47
+ function encodeWgpuScreenRenderTargetResolve(state, target, encoder) {
48
+ const presentationView = target.presentationView;
49
+ const bindGroup = target.antialiasResolveBindGroup;
50
+ const pipeline = getWgpuRenderStateRuntime(state).surfaceAntialiasResolvePipeline;
51
+ if (presentationView === null || pipeline === null || bindGroup === null)
52
+ return;
53
+ const pass = encoder.beginRenderPass({
54
+ colorAttachments: [
55
+ {
56
+ view: presentationView,
57
+ loadOp: 'clear',
58
+ storeOp: 'store',
59
+ clearValue: { r: 0, g: 0, b: 0, a: 0 },
60
+ },
61
+ ],
62
+ });
63
+ pass.setPipeline(pipeline);
64
+ pass.setBindGroup(0, bindGroup);
65
+ pass.draw(3);
66
+ pass.end();
67
+ }
68
+ // The resolve pipeline is device-tier: every screen target on one device compiles it once and shares it.
69
+ // Returns the bind-group layout the caller's per-target bind group is built against.
70
+ function ensureWgpuScreenAntialiasPipeline(state, target) {
71
+ const runtime = getWgpuRenderStateRuntime(state);
72
+ const existing = runtime.surfaceAntialiasResolveBindGroupLayout;
73
+ if (existing !== null && runtime.surfaceAntialiasResolvePipeline !== null)
74
+ return existing;
75
+ const bindGroupLayout = target.device.createBindGroupLayout({
76
+ entries: [
77
+ { binding: 0, visibility: WgpuShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
78
+ { binding: 1, visibility: WgpuShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
79
+ ],
80
+ });
81
+ const layout = target.device.createPipelineLayout({ bindGroupLayouts: [bindGroupLayout] });
82
+ const module = target.device.createShaderModule({ code: SCREEN_ANTIALIAS_WGSL });
83
+ runtime.surfaceAntialiasResolveBindGroupLayout = bindGroupLayout;
84
+ runtime.surfaceAntialiasResolvePipeline = target.device.createRenderPipeline({
85
+ layout,
86
+ vertex: { module, entryPoint: 'vs_main' },
87
+ fragment: { module, entryPoint: 'fs_main', targets: [{ format: target.format }] },
88
+ primitive: { topology: 'triangle-list' },
89
+ });
90
+ return bindGroupLayout;
91
+ }
92
+ const SCREEN_ANTIALIAS_WGSL = /* wgsl */ `
93
+ struct VertexOutput {
94
+ @builtin(position) position: vec4f,
95
+ @location(0) uv: vec2f,
96
+ };
97
+
98
+ @vertex
99
+ fn vs_main(@builtin(vertex_index) index: u32) -> VertexOutput {
100
+ let positions = array<vec2f, 3>(
101
+ vec2f(-1.0, -1.0),
102
+ vec2f(3.0, -1.0),
103
+ vec2f(-1.0, 3.0),
104
+ );
105
+ let position = positions[index];
106
+ var output: VertexOutput;
107
+ output.position = vec4f(position, 0.0, 1.0);
108
+ output.uv = position * vec2f(0.5, -0.5) + vec2f(0.5);
109
+ return output;
110
+ }
111
+
112
+ @group(0) @binding(0) var source_texture: texture_2d<f32>;
113
+ @group(0) @binding(1) var source_sampler: sampler;
114
+
115
+ @fragment
116
+ fn fs_main(input: VertexOutput) -> @location(0) vec4f {
117
+ return textureSample(source_texture, source_sampler, input.uv);
118
+ }
119
+ `;
120
+ //# sourceMappingURL=wgpuScreenAntialias.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuScreenAntialias.js","sourceRoot":"","sources":["../src/wgpuScreenAntialias.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,iCAAiC,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,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EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE;QACjF,SAAS,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE;KACzC,CAAC,CAAC;IACH,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,MAAM,qBAAqB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BxC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Bitmap } from '@flighthq/bitmap/contract';
2
+ import type { WgpuCommandEncoder, WgpuScreenRenderTarget } from './contract.render-wgpu-types.ts';
3
+ export declare function createBitmapFromWgpuScreenRenderTarget(target: Readonly<WgpuScreenRenderTarget>, timeoutMs?: number): Promise<Bitmap>;
4
+ export declare function enableWgpuScreenRenderTargetCapture(target: WgpuScreenRenderTarget): void;
5
+ export declare function encodeWgpuScreenRenderTargetCapture(target: WgpuScreenRenderTarget, encoder: WgpuCommandEncoder): void;
6
+ //# sourceMappingURL=wgpuScreenCapture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuScreenCapture.d.ts","sourceRoot":"","sources":["../src/wgpuScreenCapture.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,KAAK,EAEV,kBAAkB,EAClB,sBAAsB,EAEvB,MAAM,iCAAiC,CAAC;AAczC,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,QAAQ,CAAC,sBAAsB,CAAC,EACxC,SAAS,SAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,CAyCjB;AAMD,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAIxF;AAwBD,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAgCrH"}
@@ -0,0 +1,138 @@
1
+ import { createBitmap } from '@flighthq/bitmap/contract';
2
+ import { WgpuBufferUsage, WgpuMapMode, WgpuTextureUsage } from './contract.render-wgpu-types.js';
3
+ // Opt-in capture of a screen target's frame to a CPU Bitmap. Two environment facts drive the design:
4
+ // (1) headless/software adapters never present the swap chain, and its texture reads back as zeros, so
5
+ // the frame is redirected into an offscreen COPY_SRC texture the screen target owns; (2) GPU work queued
6
+ // in a later task than the frame is dropped on these adapters, so the frame's own submit copies that
7
+ // texture into the retained capture buffer, and the readback below only maps the buffer.
8
+ //
9
+ // One buffer serves both sides, so they take turns: the writer skips its copy while the reader holds a
10
+ // map (or has one in flight), and resumes on the next frame. Without that turn-taking a continuously
11
+ // animating scene re-enqueues a copy every frame into the buffer a readback is waiting on — which the
12
+ // queue may not touch while it is mapped, and which pushes the pending map behind ever more GPU work.
13
+ export async function createBitmapFromWgpuScreenRenderTarget(target, timeoutMs = DEFAULT_MAP_TIMEOUT_MS) {
14
+ const buffer = target.captureBuffer;
15
+ if (buffer === null) {
16
+ throw new Error('createBitmapFromWgpuScreenRenderTarget requires enableWgpuScreenRenderTargetCapture(target) before rendering, then a submitted frame.');
17
+ }
18
+ const width = target.captureWidth;
19
+ const height = target.captureHeight;
20
+ const bytesPerRow = target.captureBytesPerRow;
21
+ await mapWgpuCaptureBuffer(buffer, timeoutMs);
22
+ const mapped = new Uint8Array(buffer.getMappedRange());
23
+ const bitmap = createBitmap(width, height);
24
+ const out = bitmap.data;
25
+ // The preferred canvas format is BGRA on most platforms and RGBA on software adapters; normalize to
26
+ // the Bitmap's RGBA byte order so coverage/fingerprint and saved pixels read correctly either way.
27
+ // Pixels are left premultiplied (the texture's stored form): functional content renders over an opaque
28
+ // background, so alpha is 255 and premultiplied == straight; do NOT un-premultiply here — dividing RGB
29
+ // by an 8-bit alpha amplifies quantization and clamps, blowing out exactly the semi-transparent pixels
30
+ // a colour comparison cares about. If straight-alpha output is ever needed, convert at the consumer in
31
+ // higher precision, or compare in premultiplied space on both sides.
32
+ const swizzleBGRA = target.format === 'bgra8unorm' || target.format === 'bgra8unorm-srgb';
33
+ for (let y = 0; y < height; y++) {
34
+ const srcRow = y * bytesPerRow;
35
+ const dstRow = y * width * 4;
36
+ for (let x = 0; x < width; x++) {
37
+ const s = srcRow + x * 4;
38
+ const d = dstRow + x * 4;
39
+ out[d] = swizzleBGRA ? mapped[s + 2] : mapped[s];
40
+ out[d + 1] = mapped[s + 1];
41
+ out[d + 2] = swizzleBGRA ? mapped[s] : mapped[s + 2];
42
+ out[d + 3] = mapped[s + 3];
43
+ }
44
+ }
45
+ // Unmap (not destroy) so the next frame's submit can copy into the retained buffer again.
46
+ buffer.unmap();
47
+ return bitmap;
48
+ }
49
+ // Enables opt-in capture on a screen target so createBitmapFromWgpuScreenRenderTarget can read it back.
50
+ // The frame is then drawn into an offscreen texture instead of the swap chain (the only reliably readable
51
+ // path on headless/software adapters); the canvas is not presented while capture is on. Leave it off for
52
+ // normal on-screen rendering. The capture texture and buffer are allocated lazily.
53
+ export function enableWgpuScreenRenderTargetCapture(target) {
54
+ target.captureEnabled = true;
55
+ target.acquireCaptureTexture = acquireWgpuScreenRenderTargetCaptureTexture;
56
+ target.encodeCapture = encodeWgpuScreenRenderTargetCapture;
57
+ }
58
+ // The offscreen texture a captured frame renders into, sized to the surface's logical extent (a
59
+ // supersampled frame resolves down into it). Installed as the target's capture slot by the enable above.
60
+ function acquireWgpuScreenRenderTargetCaptureTexture(target) {
61
+ const scale = target.antialias ? 2 : 1;
62
+ const width = Math.max(1, Math.floor(target.width / scale));
63
+ const height = Math.max(1, Math.floor(target.height / scale));
64
+ const existing = target.captureTexture;
65
+ if (existing !== null && existing.width === width && existing.height === height)
66
+ return existing;
67
+ existing?.destroy();
68
+ const texture = target.device.createTexture({
69
+ size: [width, height, 1],
70
+ format: target.format,
71
+ usage: WgpuTextureUsage.RENDER_ATTACHMENT | WgpuTextureUsage.TEXTURE_BINDING | WgpuTextureUsage.COPY_SRC,
72
+ });
73
+ target.captureTexture = texture;
74
+ return texture;
75
+ }
76
+ // Encodes the capture-texture → capture-buffer copy into the frame's command encoder, sizing and
77
+ // reallocating the retained buffer to the surface on demand. No-op unless capture is enabled. Internal:
78
+ // called by submitWgpuFrame so the copy is queued in the render frame, not a later (dropped) task.
79
+ export function encodeWgpuScreenRenderTargetCapture(target, encoder) {
80
+ const texture = target.captureTexture;
81
+ if (!target.captureEnabled || texture === null)
82
+ return;
83
+ // The reader owns the buffer while it holds a map. One retained buffer serves both sides, and the
84
+ // queue may not touch a buffer that is mapped or has a map in flight — so a frame encoded during a
85
+ // readback both invalidates the copy and stacks more GPU work in front of the map it is waiting on.
86
+ // Skipping the frame is the handshake: the reader is already taking a snapshot, and the next frame
87
+ // resumes copying once it lets go.
88
+ //
89
+ // Deliberately written as "is it busy" rather than "is it not unmapped": an implementation without
90
+ // `mapState` reports undefined, and the inverted test would then skip every copy for the whole run
91
+ // and capture nothing. Unknown state falls through to the copy, which is the pre-existing behaviour.
92
+ const mapState = target.captureBuffer?.mapState;
93
+ if (mapState === 'pending' || mapState === 'mapped')
94
+ return;
95
+ const width = texture.width;
96
+ const height = texture.height;
97
+ // Wgpu requires copyTextureToBuffer rows to be 256-byte aligned; the buffer is padded per row.
98
+ const bytesPerRow = Math.ceil((width * 4) / 256) * 256;
99
+ if (target.captureBuffer === null || target.captureWidth !== width || target.captureHeight !== height) {
100
+ target.captureBuffer?.destroy();
101
+ target.captureBuffer = target.device.createBuffer({
102
+ size: bytesPerRow * height,
103
+ usage: WgpuBufferUsage.COPY_DST | WgpuBufferUsage.MAP_READ,
104
+ });
105
+ target.captureBytesPerRow = bytesPerRow;
106
+ target.captureWidth = width;
107
+ target.captureHeight = height;
108
+ }
109
+ encoder.copyTextureToBuffer({ texture }, { buffer: target.captureBuffer, bytesPerRow }, [width, height, 1]);
110
+ }
111
+ // Maps the retained capture buffer, giving up by name after `timeoutMs` (0 waits indefinitely).
112
+ // `mapAsync` carries no timeout and no reject path of its own: on the contended software adapters this
113
+ // capture path exists for, the promise can simply never settle, and an unbounded await is indistinguishable
114
+ // from a caller that stopped running. A late resolution after the deadline leaves the buffer mapped, which
115
+ // is why the timeout is a hard end for this capture and not something to retry against the same buffer.
116
+ async function mapWgpuCaptureBuffer(buffer, timeoutMs) {
117
+ const mapping = buffer.mapAsync(WgpuMapMode.READ);
118
+ if (timeoutMs <= 0)
119
+ return mapping;
120
+ // The race abandons `mapping` on timeout; adopt its eventual rejection here so it is never unhandled.
121
+ mapping.catch(() => { });
122
+ let timer;
123
+ const expiry = new Promise((_resolve, reject) => {
124
+ timer = setTimeout(() => {
125
+ reject(new Error(`createBitmapFromWgpuScreenRenderTarget: capture buffer did not map within ${timeoutMs}ms`));
126
+ }, timeoutMs);
127
+ });
128
+ try {
129
+ await Promise.race([mapping, expiry]);
130
+ }
131
+ finally {
132
+ clearTimeout(timer);
133
+ }
134
+ }
135
+ // Generous by design: this bounds a driver that has stopped answering, not a slow one. Callers working
136
+ // inside a tighter budget (the capture harness) pass their own.
137
+ const DEFAULT_MAP_TIMEOUT_MS = 10_000;
138
+ //# sourceMappingURL=wgpuScreenCapture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuScreenCapture.js","sourceRoot":"","sources":["../src/wgpuScreenCapture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AASzD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEjG,qGAAqG;AACrG,uGAAuG;AACvG,yGAAyG;AACzG,qGAAqG;AACrG,yFAAyF;AACzF,EAAE;AACF,uGAAuG;AACvG,qGAAqG;AACrG,sGAAsG;AACtG,sGAAsG;AAEtG,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC1D,MAAwC,EACxC,SAAS,GAAG,sBAAsB;IAElC,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;IACpC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,C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CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IACxC,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC;AAED,uGAAuG;AACvG,gEAAgE;AAChE,MAAM,sBAAsB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { EntityConstruction } from '@flighthq/entity/contract';
2
+ import type { Surface } from '@flighthq/surface/contract';
3
+ import type { HostWgpuCapability, WgpuDevice, WgpuRenderState, WgpuRenderTarget, WgpuScreenRenderTarget, WgpuScreenRenderTargetOptions, WgpuTextureView } from './contract.render-wgpu-types.ts';
4
+ export declare function bindWgpuScreenRenderTarget(state: WgpuRenderState, target: WgpuScreenRenderTarget): WgpuTextureView;
5
+ export declare function createWgpuScreenRenderTarget(wgpuHost: Readonly<HostWgpuCapability>, device: WgpuDevice, drawable: Readonly<Surface>, options?: Readonly<WgpuScreenRenderTargetOptions>): WgpuScreenRenderTarget;
6
+ export declare function destroyWgpuScreenRenderTarget(target: WgpuScreenRenderTarget): void;
7
+ export declare function endWgpuScreenRenderTargetFrame(target: WgpuScreenRenderTarget): void;
8
+ export declare function initializeWgpuScreenRenderTarget(out: EntityConstruction<WgpuScreenRenderTarget>, wgpuHost: Readonly<HostWgpuCapability>, device: WgpuDevice, drawable: Readonly<Surface>, options?: Readonly<WgpuScreenRenderTargetOptions>): void;
9
+ export declare function isWgpuScreenRenderTarget(target: Readonly<WgpuRenderTarget>): target is WgpuScreenRenderTarget;
10
+ export declare function syncWgpuScreenRenderTargetExtent(target: WgpuScreenRenderTarget): void;
11
+ //# sourceMappingURL=wgpuScreenRenderTarget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuScreenRenderTarget.d.ts","sourceRoot":"","sources":["../src/wgpuScreenRenderTarget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,6BAA6B,EAE7B,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAOzC,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,sBAAsB,GAAG,eAAe,CAYlH;AAID,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACtC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC3B,OAAO,GAAE,QAAQ,CAAC,6BAA6B,CAAM,GACpD,sBAAsB,CAIxB;AAKD,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAYlF;AAID,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAEnF;AAED,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,EAC/C,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACtC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC3B,OAAO,GAAE,QAAQ,CAAC,6BAA6B,CAAM,GACpD,IAAI,CAwCN;AAKD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,MAAM,IAAI,sBAAsB,CAE7G;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAIrF"}
@@ -0,0 +1,121 @@
1
+ import { allocateEntity } from '@flighthq/entity/contract';
2
+ import { WgpuTextureUsage } from './contract.render-wgpu-types.js';
3
+ // Acquires the color view a screen pass attaches to, sizing the target's storage to the surface first.
4
+ // The returned view is the supersample texture when antialiasing is enabled and the presentation view
5
+ // otherwise; either way `presentationView` names where the frame ultimately lands, so the submit can
6
+ // resolve and capture it. Internal: called by beginWgpuRenderPass.
7
+ export function bindWgpuScreenRenderTarget(state, target) {
8
+ syncWgpuScreenRenderTargetExtent(target);
9
+ ensureWgpuScreenRenderTargetDepthStencil(target);
10
+ if (target.presentationView === null) {
11
+ // With capture on, render into an offscreen COPY_SRC texture instead of the swap chain: software and
12
+ // headless adapters never present the swap chain and its texture reads back as zeros, so the readable
13
+ // copy must be the render target itself.
14
+ const presentationTexture = target.acquireCaptureTexture?.(target) ?? target.context.getCurrentTexture();
15
+ target.presentationView = presentationTexture.createView();
16
+ }
17
+ return target.acquireAntialiasView?.(state, target) ?? target.presentationView;
18
+ }
19
+ // A screen target's whole point is that it presents; a texture target's is that it can be sampled. Both
20
+ // creations are Entity allocations, so a factory is the only place either capability is decided.
21
+ export function createWgpuScreenRenderTarget(wgpuHost, device, drawable, options = {}) {
22
+ const out = allocateEntity();
23
+ initializeWgpuScreenRenderTarget(out, wgpuHost, device, drawable, options);
24
+ return out;
25
+ }
26
+ // Frees the GPU storage this target owns — depth-stencil, supersample, and capture — and unconfigures
27
+ // its canvas context. The target is invalid afterward. The storage is freed here even though the code
28
+ // that filled it lives in the opt-in modules: a target owns its allocations whoever wrote to them.
29
+ export function destroyWgpuScreenRenderTarget(target) {
30
+ target.depthStencilTexture.destroy();
31
+ target.antialiasTexture?.destroy();
32
+ target.antialiasTexture = null;
33
+ target.antialiasView = null;
34
+ target.antialiasResolveBindGroup = null;
35
+ target.captureTexture?.destroy();
36
+ target.captureTexture = null;
37
+ target.captureBuffer?.destroy();
38
+ target.captureBuffer = null;
39
+ target.presentationView = null;
40
+ target.context.unconfigure();
41
+ }
42
+ // Releases the per-frame swap-chain view. The next frame acquires a fresh one, which is the whole reason
43
+ // a screen target is not sampleable: nothing may hold this across frames.
44
+ export function endWgpuScreenRenderTargetFrame(target) {
45
+ target.presentationView = null;
46
+ }
47
+ export function initializeWgpuScreenRenderTarget(out, wgpuHost, device, drawable, options = {}) {
48
+ const format = options.format ?? 'bgra8unorm';
49
+ const result = wgpuHost.attachSurface(drawable, {
50
+ alphaMode: options.alphaMode ?? 'premultiplied',
51
+ device,
52
+ format,
53
+ });
54
+ if (result === null)
55
+ throw new Error('createWgpuScreenRenderTarget: the target cannot present WebGPU.');
56
+ const { context, surface } = result;
57
+ const width = Math.max(1, surface.width);
58
+ const height = Math.max(1, surface.height);
59
+ const depthStencilTexture = createWgpuScreenDepthStencilTexture(device, width, height);
60
+ out.acquireAntialiasView = null;
61
+ out.acquireCaptureTexture = null;
62
+ out.antialias = false;
63
+ out.antialiasResolveBindGroup = null;
64
+ out.antialiasTexture = null;
65
+ out.antialiasView = null;
66
+ out.captureBuffer = null;
67
+ out.captureBytesPerRow = 0;
68
+ out.captureEnabled = false;
69
+ out.captureHeight = 0;
70
+ out.captureTexture = null;
71
+ out.captureWidth = 0;
72
+ out.colorAttachments = 1;
73
+ out.colorSpace = options.colorSpace ?? 'srgb';
74
+ out.context = context;
75
+ out.depthStencilTexture = depthStencilTexture;
76
+ out.depthStencilView = depthStencilTexture.createView();
77
+ out.device = device;
78
+ out.encodeAntialiasResolve = null;
79
+ out.encodeCapture = null;
80
+ out.format = format;
81
+ out.height = height;
82
+ out.presentationView = null;
83
+ out.sampleCount = 1;
84
+ out.surface = surface;
85
+ out.width = width;
86
+ }
87
+ // The base type says which storage a target names through `context`; this is the narrowing that reads it.
88
+ // Sampling, present, and effect-input APIs take WgpuTextureRenderTarget precisely so they never have to
89
+ // ask — the swap chain has no sampleable texture handle to give them.
90
+ export function isWgpuScreenRenderTarget(target) {
91
+ return target.context !== null;
92
+ }
93
+ export function syncWgpuScreenRenderTargetExtent(target) {
94
+ const scale = target.antialias ? WGPU_SCREEN_SUPERSAMPLE_SCALE : 1;
95
+ target.width = Math.max(1, target.surface.width) * scale;
96
+ target.height = Math.max(1, target.surface.height) * scale;
97
+ }
98
+ function createWgpuScreenDepthStencilTexture(device, width, height) {
99
+ return device.createTexture({
100
+ size: [Math.max(1, width), Math.max(1, height), 1],
101
+ format: 'depth24plus-stencil8',
102
+ usage: WgpuTextureUsage.RENDER_ATTACHMENT,
103
+ });
104
+ }
105
+ function ensureWgpuScreenRenderTargetDepthStencil(target) {
106
+ const texture = target.depthStencilTexture;
107
+ if (texture.width === target.width && texture.height === target.height)
108
+ return;
109
+ texture.destroy();
110
+ const replacement = createWgpuScreenDepthStencilTexture(target.device, target.width, target.height);
111
+ target.depthStencilTexture = replacement;
112
+ target.depthStencilView = replacement.createView();
113
+ }
114
+ // Brings the target's extent back in line with its surface — the surface is the authority on its own
115
+ // size, and it can be resized between any two frames. Every pass calls this, so a caller never has to
116
+ // announce a resize; enabling supersampling calls it too, because the factor it multiplies by changed.
117
+ // One place decides how much bigger a supersampled surface is than its logical extent.
118
+ // wgpuTextureRenderTarget.ts carries the same number for offscreen storage; they are the same concept
119
+ // applied to two surfaces.
120
+ const WGPU_SCREEN_SUPERSAMPLE_SCALE = 2;
121
+ //# sourceMappingURL=wgpuScreenRenderTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuScreenRenderTarget.js","sourceRoot":"","sources":["../src/wgpuScreenRenderTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAc3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,uGAAuG;AACvG,sGAAsG;AACtG,qGAAqG;AACrG,mEAAmE;AACnE,MAAM,UAAU,0BAA0B,CAAC,KAAsB,EAAE,MAA8B;IAC/F,gCAAgC,CAAC,MAAM,CAAC,CAAC;IACzC,wCAAwC,CAAC,MAAM,CAAC,CAAC;IAEjD,IAAI,MAAM,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;QACrC,qGAAqG;QACrG,sGAAsG;QACtG,yCAAyC;QACzC,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,IAAI,M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C7D,CAAC;AAED,SAAS,mCAAmC,CAAC,MAAkB,EAAE,KAAa,EAAE,MAAc;IAC5F,OAAO,MAAM,CAAC,aAAa,CAAC;QAC1B,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QAClD,MAAM,EAAE,sBAAsB;QAC9B,KAAK,EAAE,gBAAgB,CAAC,iBAAiB;KAC1C,CAAC,CAAC;AACL,CAAC;AAED,SAAS,wCAAwC,CAAC,MAA8B;IAC9E,MAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,CAAC;IAC3C,IAAI,OAAO,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;QAAE,OAAO;IAE/E,OAAO,CAAC,OAAO,EAAE,CAAC;IAClB,MAAM,WAAW,GAAG,mCAAmC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACpG,MAAM,CAAC,mBAAmB,GAAG,WAAW,CAAC;IACzC,MAAM,CAAC,gBAAgB,GAAG,WAAW,CAAC,UAAU,EAAE,CAAC;AACrD,CAAC;AAED,qGAAqG;AACrG,sGAAsG;AACtG,uGAAuG;AACvG,uFAAuF;AACvF,sGAAsG;AACtG,2BAA2B;AAC3B,MAAM,6BAA6B,GAAG,CAAC,CAAC"}
@@ -1,13 +1,16 @@
1
- import type { ColorScaleBias, EntityConstruction, RenderProxy, WgpuBindGroupLayouts, WgpuRenderState } from '@flighthq/types/contract';
2
- import { BlendMode } from '@flighthq/types/contract';
1
+ import type { ColorScaleBias } from '@flighthq/adjustments/contract';
2
+ import type { EntityConstruction } from '@flighthq/entity/contract';
3
+ import { BlendMode } from '@flighthq/materials/contract';
4
+ import type { RenderProxy } from '@flighthq/render/contract';
5
+ import type { WgpuBindGroupLayout, WgpuBindGroupLayouts, WgpuBlendState, WgpuDevice, WgpuPipelineLayout, WgpuRenderPipeline, WgpuRenderState } from './contract.render-wgpu-types.ts';
3
6
  export declare const UNIFORM_BYTE_SIZE = 128;
4
7
  type StencilMode = 'normal' | 'masked' | 'maskwrite';
5
- export declare function createWgpuBindGroupLayouts(device: GPUDevice): WgpuBindGroupLayouts;
6
- export declare function createWgpuPipelineLayout(device: GPUDevice, uniformBindGroupLayout: GPUBindGroupLayout, textureBindGroupLayout: GPUBindGroupLayout): GPUPipelineLayout;
7
- export declare function getActiveWgpuPipeline(state: WgpuRenderState): GPURenderPipeline;
8
- export declare function getWgpuBlendState(blendMode: BlendMode | null): GPUBlendState;
9
- export declare function getWgpuPipeline(state: WgpuRenderState, blendMode: BlendMode | null, stencilMode: StencilMode): GPURenderPipeline;
10
- export declare function initializeWgpuBindGroupLayouts(out: EntityConstruction<WgpuBindGroupLayouts>, device: GPUDevice): void;
8
+ export declare function createWgpuBindGroupLayouts(device: WgpuDevice): WgpuBindGroupLayouts;
9
+ export declare function createWgpuPipelineLayout(device: WgpuDevice, uniformBindGroupLayout: WgpuBindGroupLayout, textureBindGroupLayout: WgpuBindGroupLayout): WgpuPipelineLayout;
10
+ export declare function getActiveWgpuPipeline(state: WgpuRenderState): WgpuRenderPipeline;
11
+ export declare function getWgpuBlendState(blendMode: BlendMode | null): WgpuBlendState;
12
+ export declare function getWgpuPipeline(state: WgpuRenderState, blendMode: BlendMode | null, stencilMode: StencilMode): WgpuRenderPipeline;
13
+ export declare function initializeWgpuBindGroupLayouts(out: EntityConstruction<WgpuBindGroupLayouts>, device: WgpuDevice): void;
11
14
  export declare function setWgpuMatrixFromTransform(matrixArray: Float32Array, t: {
12
15
  a: number;
13
16
  b: number;
@@ -1 +1 @@
1
- {"version":3,"file":"wgpuShader.d.ts","sourceRoot":"","sources":["../src/wgpuShader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EA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ID,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EACjF,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT,MAAM,CAcR;AAKD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACrF,EACD,cAAc,EAAE,cAAc,GAAG,IAAI,EACrC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,oBAAoB,UAAQ,GAC3B,MAAM,CAsDR"}
@@ -1,7 +1,8 @@
1
- import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
2
- import { BlendMode } from '@flighthq/types/contract';
3
- import { getWgpuSurfaceRenderExtent } from './wgpuAntialias';
4
- import { getWgpuRenderStateDeviceResources, getWgpuRenderStateRuntime } from './wgpuRenderState';
1
+ import { allocateEntity } from '@flighthq/entity/contract';
2
+ import { BlendMode } from '@flighthq/materials/contract';
3
+ import { WgpuColorWrite, WgpuShaderStage } from './contract.render-wgpu-types.js';
4
+ import { getWgpuRenderPassViewport } from './wgpuRenderPass.js';
5
+ import { getWgpuRenderStateDeviceResources, getWgpuRenderStateRuntime } from './wgpuRenderState.js';
5
6
  // ---- WGSL source ----
6
7
  // Uniform buffer layout (per-draw slot in the ring, 256-byte aligned):
7
8
  // offset 0–47 : mat3x3f matrix (3 columns × 16 bytes each due to vec3 padding)
@@ -146,7 +147,7 @@ const BLEND_MODES = {
146
147
  export function createWgpuBindGroupLayouts(device) {
147
148
  const out = allocateEntity();
148
149
  initializeWgpuBindGroupLayouts(out, device);
149
- return finishEntity(out);
150
+ return out;
150
151
  }
151
152
  export function createWgpuPipelineLayout(device, uniformBindGroupLayout, textureBindGroupLayout) {
152
153
  return device.createPipelineLayout({
@@ -206,7 +207,7 @@ export function getWgpuPipeline(state, blendMode, stencilMode) {
206
207
  {
207
208
  format,
208
209
  blend: isMaskWrite ? undefined : blend,
209
- writeMask: isMaskWrite ? 0 : GPUColorWrite.ALL,
210
+ writeMask: isMaskWrite ? 0 : WgpuColorWrite.ALL,
210
211
  },
211
212
  ],
212
213
  },
@@ -229,15 +230,15 @@ export function initializeWgpuBindGroupLayouts(out, device) {
229
230
  entries: [
230
231
  {
231
232
  binding: 0,
232
- visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
233
+ visibility: WgpuShaderStage.VERTEX | WgpuShaderStage.FRAGMENT,
233
234
  buffer: { type: 'uniform', hasDynamicOffset: true, minBindingSize: UNIFORM_BYTE_SIZE },
234
235
  },
235
236
  ],
236
237
  });
237
238
  const textureBindGroupLayout = device.createBindGroupLayout({
238
239
  entries: [
239
- { binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
240
- { binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
240
+ { binding: 0, visibility: WgpuShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
241
+ { binding: 1, visibility: WgpuShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
241
242
  ],
242
243
  });
243
244
  out.uniformBindGroupLayout = uniformBindGroupLayout;
@@ -273,7 +274,7 @@ export function writeWgpuQuadUniforms(state, renderProxy, colorScaleBias, x0, y0
273
274
  const byteOffset = runtime.uniformOffset;
274
275
  const floatBase = byteOffset >> 2; // divide by 4
275
276
  const { uniformData, uniformDataU32, matrixArray } = runtime;
276
- const viewport = runtime.renderTargetViewport ?? getWgpuSurfaceRenderExtent(state);
277
+ const viewport = getWgpuRenderPassViewport(state);
277
278
  setWgpuMatrixFromTransform(matrixArray, renderProxy.transform2D, viewport);
278
279
  // mat3x3 columns with per-column padding (4 floats each = 16 bytes):
279
280
  uniformData[floatBase + 0] = matrixArray[0];