@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.
- package/README.md +2 -2
- package/dist/.tsbuildinfo.compressed-texture-decoder-contract +1 -0
- package/dist/.tsbuildinfo.contract +1 -0
- package/dist/.tsbuildinfo.runtime +1 -0
- package/dist/compressed-texture-decoder-contract/WgpuCompressedTextureDecoder.d.ts +3 -0
- package/dist/compressed-texture-decoder-contract/WgpuCompressedTextureDecoder.d.ts.map +1 -0
- package/dist/compressed-texture-decoder-contract/WgpuCompressedTextureDecoder.js +2 -0
- package/dist/compressed-texture-decoder-contract/WgpuCompressedTextureDecoder.js.map +1 -0
- package/dist/compressed-texture-decoder-contract/compressedTextureDecoderContract.d.ts +2 -0
- package/dist/compressed-texture-decoder-contract/compressedTextureDecoderContract.d.ts.map +1 -0
- package/dist/compressed-texture-decoder-contract/compressedTextureDecoderContract.js +2 -0
- package/dist/compressed-texture-decoder-contract/compressedTextureDecoderContract.js.map +1 -0
- package/dist/contract.d.ts +32 -34
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +32 -34
- package/dist/contract.js.map +1 -1
- package/dist/contract.render-wgpu-types.d.ts +55 -0
- package/dist/contract.render-wgpu-types.d.ts.map +1 -0
- package/dist/contract.render-wgpu-types.js +5 -0
- package/dist/contract.render-wgpu-types.js.map +1 -0
- package/dist/enableWgpuTextureResolverGuards.d.ts +3 -2
- package/dist/enableWgpuTextureResolverGuards.d.ts.map +1 -1
- package/dist/enableWgpuTextureResolverGuards.js +12 -9
- package/dist/enableWgpuTextureResolverGuards.js.map +1 -1
- package/dist/explainWgpuTextureResolution.d.ts +2 -1
- package/dist/explainWgpuTextureResolution.d.ts.map +1 -1
- package/dist/explainWgpuTextureResolution.js +2 -5
- package/dist/explainWgpuTextureResolution.js.map +1 -1
- package/dist/explainWgpuUniformEndianness.d.ts +3 -0
- package/dist/explainWgpuUniformEndianness.d.ts.map +1 -0
- package/dist/explainWgpuUniformEndianness.js +25 -0
- package/dist/explainWgpuUniformEndianness.js.map +1 -0
- package/dist/index.d.ts +20 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/dist/types/Host.d.ts +5 -0
- package/dist/types/Host.d.ts.map +1 -0
- package/dist/types/Host.js +2 -0
- package/dist/types/Host.js.map +1 -0
- package/dist/types/WgpuAdapter.d.ts +14 -0
- package/dist/types/WgpuAdapter.d.ts.map +1 -0
- package/dist/types/WgpuAdapter.js +2 -0
- package/dist/types/WgpuAdapter.js.map +1 -0
- package/dist/types/WgpuAdapterCapabilities.d.ts +7 -0
- package/dist/types/WgpuAdapterCapabilities.d.ts.map +1 -0
- package/dist/types/WgpuAdapterCapabilities.js +2 -0
- package/dist/types/WgpuAdapterCapabilities.js.map +1 -0
- package/dist/types/WgpuBindGroup.d.ts +23 -0
- package/dist/types/WgpuBindGroup.d.ts.map +1 -0
- package/dist/types/WgpuBindGroup.js +2 -0
- package/dist/types/WgpuBindGroup.js.map +1 -0
- package/dist/types/WgpuBindGroupLayout.d.ts +45 -0
- package/dist/types/WgpuBindGroupLayout.d.ts.map +1 -0
- package/dist/types/WgpuBindGroupLayout.js +7 -0
- package/dist/types/WgpuBindGroupLayout.js.map +1 -0
- package/dist/types/WgpuBuffer.d.ts +34 -0
- package/dist/types/WgpuBuffer.d.ts.map +1 -0
- package/dist/types/WgpuBuffer.js +19 -0
- package/dist/types/WgpuBuffer.js.map +1 -0
- package/dist/types/WgpuCanvasContext.d.ts +17 -0
- package/dist/types/WgpuCanvasContext.d.ts.map +1 -0
- package/dist/types/WgpuCanvasContext.js +2 -0
- package/dist/types/WgpuCanvasContext.js.map +1 -0
- package/dist/types/WgpuColorAdjustmentMaterialFeature.d.ts +14 -0
- package/dist/types/WgpuColorAdjustmentMaterialFeature.d.ts.map +1 -0
- package/dist/types/WgpuColorAdjustmentMaterialFeature.js +2 -0
- package/dist/types/WgpuColorAdjustmentMaterialFeature.js.map +1 -0
- package/dist/types/WgpuCommandBuffer.d.ts +5 -0
- package/dist/types/WgpuCommandBuffer.d.ts.map +1 -0
- package/dist/types/WgpuCommandBuffer.js +2 -0
- package/dist/types/WgpuCommandBuffer.js.map +1 -0
- package/dist/types/WgpuCommandEncoder.d.ts +12 -0
- package/dist/types/WgpuCommandEncoder.d.ts.map +1 -0
- package/dist/types/WgpuCommandEncoder.js +2 -0
- package/dist/types/WgpuCommandEncoder.js.map +1 -0
- package/dist/types/WgpuCompressedTextureSupport.d.ts +6 -0
- package/dist/types/WgpuCompressedTextureSupport.d.ts.map +1 -0
- package/dist/types/WgpuCompressedTextureSupport.js +2 -0
- package/dist/types/WgpuCompressedTextureSupport.js.map +1 -0
- package/dist/types/WgpuCompressedTextureUploader.d.ts +6 -0
- package/dist/types/WgpuCompressedTextureUploader.d.ts.map +1 -0
- package/dist/types/WgpuCompressedTextureUploader.js +2 -0
- package/dist/types/WgpuCompressedTextureUploader.js.map +1 -0
- package/dist/types/WgpuCustomMaterialShaderSource.d.ts +2 -0
- package/dist/types/WgpuCustomMaterialShaderSource.d.ts.map +1 -0
- package/dist/types/WgpuCustomMaterialShaderSource.js +2 -0
- package/dist/types/WgpuCustomMaterialShaderSource.js.map +1 -0
- package/dist/types/WgpuDevice.d.ts +76 -0
- package/dist/types/WgpuDevice.d.ts.map +1 -0
- package/dist/types/WgpuDevice.js +2 -0
- package/dist/types/WgpuDevice.js.map +1 -0
- package/dist/types/WgpuDeviceRuntime.d.ts +53 -0
- package/dist/types/WgpuDeviceRuntime.d.ts.map +1 -0
- package/dist/types/WgpuDeviceRuntime.js +2 -0
- package/dist/types/WgpuDeviceRuntime.js.map +1 -0
- package/dist/types/WgpuDeviceSignals.d.ts +6 -0
- package/dist/types/WgpuDeviceSignals.d.ts.map +1 -0
- package/dist/types/WgpuDeviceSignals.js +2 -0
- package/dist/types/WgpuDeviceSignals.js.map +1 -0
- package/dist/types/WgpuDeviceState.d.ts +7 -0
- package/dist/types/WgpuDeviceState.d.ts.map +1 -0
- package/dist/types/WgpuDeviceState.js +2 -0
- package/dist/types/WgpuDeviceState.js.map +1 -0
- package/dist/types/WgpuEffectState.d.ts +19 -0
- package/dist/types/WgpuEffectState.d.ts.map +1 -0
- package/dist/types/WgpuEffectState.js +2 -0
- package/dist/types/WgpuEffectState.js.map +1 -0
- package/dist/types/WgpuExternalImageSource.d.ts +18 -0
- package/dist/types/WgpuExternalImageSource.d.ts.map +1 -0
- package/dist/types/WgpuExternalImageSource.js +2 -0
- package/dist/types/WgpuExternalImageSource.js.map +1 -0
- package/dist/types/WgpuFullscreenPipeline.d.ts +14 -0
- package/dist/types/WgpuFullscreenPipeline.d.ts.map +1 -0
- package/dist/types/WgpuFullscreenPipeline.js +2 -0
- package/dist/types/WgpuFullscreenPipeline.js.map +1 -0
- package/dist/types/WgpuGpu.d.ts +7 -0
- package/dist/types/WgpuGpu.d.ts.map +1 -0
- package/dist/types/WgpuGpu.js +2 -0
- package/dist/types/WgpuGpu.js.map +1 -0
- package/dist/types/WgpuHost.d.ts +44 -0
- package/dist/types/WgpuHost.d.ts.map +1 -0
- package/dist/types/WgpuHost.js +2 -0
- package/dist/types/WgpuHost.js.map +1 -0
- package/dist/types/WgpuMeshMaterialRenderer.d.ts +11 -0
- package/dist/types/WgpuMeshMaterialRenderer.d.ts.map +1 -0
- package/dist/types/WgpuMeshMaterialRenderer.js +2 -0
- package/dist/types/WgpuMeshMaterialRenderer.js.map +1 -0
- package/dist/types/WgpuModifierSnippet.d.ts +16 -0
- package/dist/types/WgpuModifierSnippet.d.ts.map +1 -0
- package/dist/types/WgpuModifierSnippet.js +2 -0
- package/dist/types/WgpuModifierSnippet.js.map +1 -0
- package/dist/types/WgpuParticleResources.d.ts +12 -0
- package/dist/types/WgpuParticleResources.d.ts.map +1 -0
- package/dist/types/WgpuParticleResources.js +2 -0
- package/dist/types/WgpuParticleResources.js.map +1 -0
- package/dist/types/WgpuPipelineLayout.d.ts +8 -0
- package/dist/types/WgpuPipelineLayout.d.ts.map +1 -0
- package/dist/types/WgpuPipelineLayout.js +2 -0
- package/dist/types/WgpuPipelineLayout.js.map +1 -0
- package/dist/types/WgpuQuadBatchResources.d.ts +12 -0
- package/dist/types/WgpuQuadBatchResources.d.ts.map +1 -0
- package/dist/types/WgpuQuadBatchResources.js +2 -0
- package/dist/types/WgpuQuadBatchResources.js.map +1 -0
- package/dist/types/WgpuQuadMaterialRenderer.d.ts +9 -0
- package/dist/types/WgpuQuadMaterialRenderer.d.ts.map +1 -0
- package/dist/types/WgpuQuadMaterialRenderer.js +2 -0
- package/dist/types/WgpuQuadMaterialRenderer.js.map +1 -0
- package/dist/types/WgpuQueue.d.ts +12 -0
- package/dist/types/WgpuQueue.d.ts.map +1 -0
- package/dist/types/WgpuQueue.js +2 -0
- package/dist/types/WgpuQueue.js.map +1 -0
- package/dist/types/WgpuRenderOptions.d.ts +14 -0
- package/dist/types/WgpuRenderOptions.d.ts.map +1 -0
- package/dist/types/WgpuRenderOptions.js +2 -0
- package/dist/types/WgpuRenderOptions.js.map +1 -0
- package/dist/types/WgpuRenderPass.d.ts +31 -0
- package/dist/types/WgpuRenderPass.d.ts.map +1 -0
- package/dist/types/WgpuRenderPass.js +2 -0
- package/dist/types/WgpuRenderPass.js.map +1 -0
- package/dist/types/WgpuRenderPassEncoder.d.ts +52 -0
- package/dist/types/WgpuRenderPassEncoder.d.ts.map +1 -0
- package/dist/types/WgpuRenderPassEncoder.js +2 -0
- package/dist/types/WgpuRenderPassEncoder.js.map +1 -0
- package/dist/types/WgpuRenderPipeline.d.ts +96 -0
- package/dist/types/WgpuRenderPipeline.d.ts.map +1 -0
- package/dist/types/WgpuRenderPipeline.js +9 -0
- package/dist/types/WgpuRenderPipeline.js.map +1 -0
- package/dist/types/WgpuRenderState.d.ts +249 -0
- package/dist/types/WgpuRenderState.d.ts.map +1 -0
- package/dist/types/WgpuRenderState.js +2 -0
- package/dist/types/WgpuRenderState.js.map +1 -0
- package/dist/types/WgpuRenderStateOptions.d.ts +31 -0
- package/dist/types/WgpuRenderStateOptions.d.ts.map +1 -0
- package/dist/types/WgpuRenderStateOptions.js +2 -0
- package/dist/types/WgpuRenderStateOptions.js.map +1 -0
- package/dist/types/WgpuRenderTarget.d.ts +62 -0
- package/dist/types/WgpuRenderTarget.d.ts.map +1 -0
- package/dist/types/WgpuRenderTarget.js +2 -0
- package/dist/types/WgpuRenderTarget.js.map +1 -0
- package/dist/types/WgpuRenderTexture.d.ts +25 -0
- package/dist/types/WgpuRenderTexture.d.ts.map +1 -0
- package/dist/types/WgpuRenderTexture.js +2 -0
- package/dist/types/WgpuRenderTexture.js.map +1 -0
- package/dist/types/WgpuSampler.d.ts +19 -0
- package/dist/types/WgpuSampler.d.ts.map +1 -0
- package/dist/types/WgpuSampler.js +2 -0
- package/dist/types/WgpuSampler.js.map +1 -0
- package/dist/types/WgpuScene3DRuntime.d.ts +6 -0
- package/dist/types/WgpuScene3DRuntime.d.ts.map +1 -0
- package/dist/types/WgpuScene3DRuntime.js +2 -0
- package/dist/types/WgpuScene3DRuntime.js.map +1 -0
- package/dist/types/WgpuShaderModule.d.ts +6 -0
- package/dist/types/WgpuShaderModule.d.ts.map +1 -0
- package/dist/types/WgpuShaderModule.js +2 -0
- package/dist/types/WgpuShaderModule.js.map +1 -0
- package/dist/types/WgpuShapeMesh.d.ts +7 -0
- package/dist/types/WgpuShapeMesh.d.ts.map +1 -0
- package/dist/types/WgpuShapeMesh.js +2 -0
- package/dist/types/WgpuShapeMesh.js.map +1 -0
- package/dist/types/WgpuSkinningAdapter.d.ts +18 -0
- package/dist/types/WgpuSkinningAdapter.d.ts.map +1 -0
- package/dist/types/WgpuSkinningAdapter.js +2 -0
- package/dist/types/WgpuSkinningAdapter.js.map +1 -0
- package/dist/types/WgpuSurface.d.ts +5 -0
- package/dist/types/WgpuSurface.d.ts.map +1 -0
- package/dist/types/WgpuSurface.js +2 -0
- package/dist/types/WgpuSurface.js.map +1 -0
- package/dist/types/WgpuTexture.d.ts +58 -0
- package/dist/types/WgpuTexture.d.ts.map +1 -0
- package/dist/types/WgpuTexture.js +9 -0
- package/dist/types/WgpuTexture.js.map +1 -0
- package/dist/types/WgpuTextureFormat.d.ts +2 -0
- package/dist/types/WgpuTextureFormat.d.ts.map +1 -0
- package/dist/types/WgpuTextureFormat.js +2 -0
- package/dist/types/WgpuTextureFormat.js.map +1 -0
- package/dist/types/WgpuTextureResolver.d.ts +4 -0
- package/dist/types/WgpuTextureResolver.d.ts.map +1 -0
- package/dist/types/WgpuTextureResolver.js +2 -0
- package/dist/types/WgpuTextureResolver.js.map +1 -0
- package/dist/types/WgpuTextureView.d.ts +16 -0
- package/dist/types/WgpuTextureView.d.ts.map +1 -0
- package/dist/types/WgpuTextureView.js +2 -0
- package/dist/types/WgpuTextureView.js.map +1 -0
- package/dist/types/WgpuUniformEndianness.d.ts +7 -0
- package/dist/types/WgpuUniformEndianness.d.ts.map +1 -0
- package/dist/types/WgpuUniformEndianness.js +2 -0
- package/dist/types/WgpuUniformEndianness.js.map +1 -0
- package/dist/types/WgpuVelocityWriter.d.ts +11 -0
- package/dist/types/WgpuVelocityWriter.d.ts.map +1 -0
- package/dist/types/WgpuVelocityWriter.js +2 -0
- package/dist/types/WgpuVelocityWriter.js.map +1 -0
- package/dist/wgpuAdapterCapabilities.d.ts +2 -2
- package/dist/wgpuAdapterCapabilities.d.ts.map +1 -1
- package/dist/wgpuAdapterCapabilities.js.map +1 -1
- package/dist/wgpuCompressedTexture.d.ts +7 -5
- package/dist/wgpuCompressedTexture.d.ts.map +1 -1
- package/dist/wgpuCompressedTexture.js +10 -18
- package/dist/wgpuCompressedTexture.js.map +1 -1
- package/dist/wgpuDeviceLoss.d.ts +2 -2
- package/dist/wgpuDeviceLoss.d.ts.map +1 -1
- package/dist/wgpuDeviceLoss.js +1 -1
- package/dist/wgpuDeviceLoss.js.map +1 -1
- package/dist/wgpuDraw.d.ts +11 -5
- package/dist/wgpuDraw.d.ts.map +1 -1
- package/dist/wgpuDraw.js +21 -20
- package/dist/wgpuDraw.js.map +1 -1
- package/dist/wgpuExternalImageSource.d.ts +3 -2
- package/dist/wgpuExternalImageSource.d.ts.map +1 -1
- package/dist/wgpuExternalImageSource.js.map +1 -1
- package/dist/wgpuExternalTexture.d.ts +7 -3
- package/dist/wgpuExternalTexture.d.ts.map +1 -1
- package/dist/wgpuExternalTexture.js +5 -5
- package/dist/wgpuExternalTexture.js.map +1 -1
- package/dist/wgpuFrame.d.ts +23 -0
- package/dist/wgpuFrame.d.ts.map +1 -0
- package/dist/{wgpuBackground.js → wgpuFrame.js} +67 -122
- package/dist/wgpuFrame.js.map +1 -0
- package/dist/wgpuFullscreenPass.d.ts +5 -4
- package/dist/wgpuFullscreenPass.d.ts.map +1 -1
- package/dist/wgpuFullscreenPass.js +22 -8
- package/dist/wgpuFullscreenPass.js.map +1 -1
- package/dist/wgpuHost.d.ts +4 -7
- package/dist/wgpuHost.d.ts.map +1 -1
- package/dist/wgpuHost.js +81 -70
- package/dist/wgpuHost.js.map +1 -1
- package/dist/wgpuMipmap.d.ts +2 -2
- package/dist/wgpuMipmap.d.ts.map +1 -1
- package/dist/wgpuMipmap.js +4 -3
- package/dist/wgpuMipmap.js.map +1 -1
- package/dist/wgpuQuadMaterialRegistry.d.ts +7 -0
- package/dist/wgpuQuadMaterialRegistry.d.ts.map +1 -0
- package/dist/wgpuQuadMaterialRegistry.js +33 -0
- package/dist/wgpuQuadMaterialRegistry.js.map +1 -0
- package/dist/wgpuRenderPass.d.ts +9 -0
- package/dist/wgpuRenderPass.d.ts.map +1 -0
- package/dist/wgpuRenderPass.js +210 -0
- package/dist/wgpuRenderPass.js.map +1 -0
- package/dist/wgpuRenderState.d.ts +16 -12
- package/dist/wgpuRenderState.d.ts.map +1 -1
- package/dist/wgpuRenderState.js +104 -149
- package/dist/wgpuRenderState.js.map +1 -1
- package/dist/wgpuRenderTarget.d.ts +13 -29
- package/dist/wgpuRenderTarget.d.ts.map +1 -1
- package/dist/wgpuRenderTarget.js +20 -253
- package/dist/wgpuRenderTarget.js.map +1 -1
- package/dist/wgpuRenderTargetPool.d.ts +8 -6
- package/dist/wgpuRenderTargetPool.d.ts.map +1 -1
- package/dist/wgpuRenderTargetPool.js +9 -9
- package/dist/wgpuRenderTargetPool.js.map +1 -1
- package/dist/wgpuRenderTexture.d.ts +7 -4
- package/dist/wgpuRenderTexture.d.ts.map +1 -1
- package/dist/wgpuRenderTexture.js +15 -17
- package/dist/wgpuRenderTexture.js.map +1 -1
- package/dist/wgpuRenderTexturePool.d.ts +3 -1
- package/dist/wgpuRenderTexturePool.d.ts.map +1 -1
- package/dist/wgpuRenderTexturePool.js +5 -7
- package/dist/wgpuRenderTexturePool.js.map +1 -1
- package/dist/wgpuScissor.d.ts +3 -3
- package/dist/wgpuScissor.d.ts.map +1 -1
- package/dist/wgpuScissor.js +8 -5
- package/dist/wgpuScissor.js.map +1 -1
- package/dist/wgpuScreenAntialias.d.ts +3 -0
- package/dist/wgpuScreenAntialias.d.ts.map +1 -0
- package/dist/wgpuScreenAntialias.js +120 -0
- package/dist/wgpuScreenAntialias.js.map +1 -0
- package/dist/wgpuScreenCapture.d.ts +6 -0
- package/dist/wgpuScreenCapture.d.ts.map +1 -0
- package/dist/wgpuScreenCapture.js +138 -0
- package/dist/wgpuScreenCapture.js.map +1 -0
- package/dist/wgpuScreenRenderTarget.d.ts +11 -0
- package/dist/wgpuScreenRenderTarget.d.ts.map +1 -0
- package/dist/wgpuScreenRenderTarget.js +121 -0
- package/dist/wgpuScreenRenderTarget.js.map +1 -0
- package/dist/wgpuShader.d.ts +11 -8
- package/dist/wgpuShader.d.ts.map +1 -1
- package/dist/wgpuShader.js +11 -10
- package/dist/wgpuShader.js.map +1 -1
- package/dist/wgpuShaderBinding.d.ts +3 -1
- package/dist/wgpuShaderBinding.d.ts.map +1 -1
- package/dist/wgpuShaderBinding.js +1 -1
- package/dist/wgpuShaderBinding.js.map +1 -1
- package/dist/wgpuShaderRegistry.d.ts +1 -1
- package/dist/wgpuShaderRegistry.d.ts.map +1 -1
- package/dist/wgpuShaderRegistry.js +1 -1
- package/dist/wgpuShaderRegistry.js.map +1 -1
- package/dist/wgpuTestHelper.d.ts +11 -2
- package/dist/wgpuTestHelper.d.ts.map +1 -1
- package/dist/wgpuTestHelper.js +50 -38
- package/dist/wgpuTestHelper.js.map +1 -1
- package/dist/wgpuTextureRenderTarget.d.ts +22 -0
- package/dist/wgpuTextureRenderTarget.d.ts.map +1 -0
- package/dist/wgpuTextureRenderTarget.js +123 -0
- package/dist/wgpuTextureRenderTarget.js.map +1 -0
- package/dist/wgpuTextureResolver.d.ts +5 -1
- package/dist/wgpuTextureResolver.d.ts.map +1 -1
- package/dist/wgpuTextureResolver.js +13 -12
- package/dist/wgpuTextureResolver.js.map +1 -1
- package/dist/wgpuTextureUpload.d.ts +5 -4
- package/dist/wgpuTextureUpload.d.ts.map +1 -1
- package/dist/wgpuTextureUpload.js +1 -1
- package/dist/wgpuTextureUpload.js.map +1 -1
- package/package.json +33 -13
- package/src/enableWgpuTextureResolverGuards.test.ts +40 -19
- package/src/explainWgpuTextureResolution.test.ts +6 -6
- package/src/explainWgpuUniformEndianness.test.ts +11 -0
- package/src/types/WgpuBindGroupLayout.test.ts +9 -0
- package/src/types/WgpuBuffer.test.ts +26 -0
- package/src/types/WgpuGpu.test.ts +56 -0
- package/src/types/WgpuRenderPipeline.test.ts +12 -0
- package/src/types/WgpuTexture.test.ts +15 -0
- package/src/wgpuAdapterCapabilities.test.ts +5 -4
- package/src/wgpuCompressedTexture.test.ts +31 -37
- package/src/wgpuDeviceLoss.test.ts +31 -24
- package/src/wgpuDraw.test.ts +21 -24
- package/src/wgpuExternalImageSource.test.ts +12 -11
- package/src/wgpuExternalTexture.test.ts +7 -6
- package/src/{wgpuBackground.test.ts → wgpuFrame.test.ts} +47 -29
- package/src/wgpuFullscreenPass.test.ts +8 -8
- package/src/wgpuHost.test.ts +57 -186
- package/src/wgpuMipmap.test.ts +15 -9
- package/src/wgpuQuadMaterialRegistry.test.ts +132 -0
- package/src/wgpuRenderPass.test.ts +239 -0
- package/src/wgpuRenderState.test.ts +215 -550
- package/src/wgpuRenderTarget.test.ts +44 -220
- package/src/wgpuRenderTargetPool.test.ts +23 -23
- package/src/wgpuRenderTexture.test.ts +21 -18
- package/src/wgpuRenderTexturePool.test.ts +3 -3
- package/src/wgpuScissor.test.ts +50 -19
- package/src/wgpuScreenAntialias.test.ts +65 -0
- package/src/wgpuScreenCapture.test.ts +165 -0
- package/src/wgpuScreenRenderTarget.test.ts +172 -0
- package/src/wgpuShader.test.ts +12 -11
- package/src/wgpuShaderBinding.test.ts +4 -4
- package/src/wgpuShaderRegistry.test.ts +4 -5
- package/src/wgpuTestHelper.test.ts +8 -7
- package/src/wgpuTextureRenderTarget.test.ts +129 -0
- package/src/wgpuTextureResolver.test.ts +25 -14
- package/src/wgpuTextureUpload.test.ts +15 -10
- package/dist/wgpuAntialias.d.ts +0 -14
- package/dist/wgpuAntialias.d.ts.map +0 -1
- package/dist/wgpuAntialias.js +0 -155
- package/dist/wgpuAntialias.js.map +0 -1
- package/dist/wgpuBackground.d.ts +0 -20
- package/dist/wgpuBackground.d.ts.map +0 -1
- package/dist/wgpuBackground.js.map +0 -1
- package/dist/wgpuElement.d.ts +0 -7
- package/dist/wgpuElement.d.ts.map +0 -1
- package/dist/wgpuElement.js +0 -20
- package/dist/wgpuElement.js.map +0 -1
- package/dist/wgpuMaterialRegistry.d.ts +0 -5
- package/dist/wgpuMaterialRegistry.d.ts.map +0 -1
- package/dist/wgpuMaterialRegistry.js +0 -32
- package/dist/wgpuMaterialRegistry.js.map +0 -1
- package/dist/wgpuPipeline.d.ts +0 -6
- package/dist/wgpuPipeline.d.ts.map +0 -1
- package/dist/wgpuPipeline.js +0 -33
- package/dist/wgpuPipeline.js.map +0 -1
- package/dist/wgpuSurface.d.ts +0 -6
- package/dist/wgpuSurface.d.ts.map +0 -1
- package/dist/wgpuSurface.js +0 -155
- package/dist/wgpuSurface.js.map +0 -1
- package/src/wgpuAntialias.test.ts +0 -239
- package/src/wgpuElement.test.ts +0 -145
- package/src/wgpuMaterialRegistry.test.ts +0 -100
- package/src/wgpuPipeline.test.ts +0 -62
- package/src/wgpuSurface.test.ts +0 -141
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuMaterialRegistry.js","sourceRoot":"","sources":["../src/wgpuMaterialRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,UAAU,uBAAuB,CAAC,KAAsB,EAAE,IAAU;IACxE,MAAM,KAAK,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9F,OAAO,KAAK,EAAE,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,KAAsB,EAAE,IAAU,EAAE,QAA8B;IAC7G,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,OAAO,CAAC,UAAU,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AACtH,CAAC;AAED,mGAAmG;AACnG,sGAAsG;AACtG,+FAA+F;AAC/F,wFAAwF;AACxF,MAAM,UAAU,2BAA2B,CACzC,KAAsB,EACtB,QAAyB;IAEzB,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC;IAC7D,MAAM,IAAI,GAAG,QAAQ,EAAE,IAAI,IAAI,oBAAoB,CAAC;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,KAAK,EAAE,KAAK,KAAK,kBAAkB,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC;IAElE,qGAAqG;IACrG,oGAAoG;IACpG,oFAAoF;IACpF,OAAO,CAAC,YAAY,EAAE,CAAC,cAAc,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAC9D,IAAI,IAAI,KAAK,oBAAoB;QAAE,OAAO,IAAI,CAAC;IAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACnD,OAAO,QAAQ,EAAE,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9E,CAAC"}
|
package/dist/wgpuPipeline.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { WgpuPipeline, WgpuRenderRegistries, EntityConstruction } from '@flighthq/types/contract';
|
|
2
|
-
export declare function createEmptyWgpuRegistries(): WgpuRenderRegistries;
|
|
3
|
-
export declare function createWgpuPipeline(registries: Readonly<WgpuRenderRegistries>): WgpuPipeline;
|
|
4
|
-
export declare function getWgpuPipelineRegistries(pipeline: Readonly<WgpuPipeline>): Readonly<WgpuRenderRegistries>;
|
|
5
|
-
export declare function initializeEmptyWgpuRegistries(out: EntityConstruction<WgpuRenderRegistries>): void;
|
|
6
|
-
//# sourceMappingURL=wgpuPipeline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuPipeline.d.ts","sourceRoot":"","sources":["../src/wgpuPipeline.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGvG,wBAAgB,yBAAyB,IAAI,oBAAoB,CAIhE;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,YAAY,CAK3F;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,oBAAoB,CAAC,CAE1G;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAcjG"}
|
package/dist/wgpuPipeline.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
import { createKeyedTable, createSlotTable } from '@flighthq/registry/contract';
|
|
3
|
-
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
4
|
-
export function createEmptyWgpuRegistries() {
|
|
5
|
-
const out = allocateEntity();
|
|
6
|
-
initializeEmptyWgpuRegistries(out);
|
|
7
|
-
return finishEntity(out);
|
|
8
|
-
}
|
|
9
|
-
export function createWgpuPipeline(registries) {
|
|
10
|
-
const pipeline = allocateEntity();
|
|
11
|
-
pipeline.registries = registries;
|
|
12
|
-
pipeline[EntityRuntimeKey] = { binding: null };
|
|
13
|
-
return pipeline;
|
|
14
|
-
}
|
|
15
|
-
export function getWgpuPipelineRegistries(pipeline) {
|
|
16
|
-
return pipeline.registries;
|
|
17
|
-
}
|
|
18
|
-
export function initializeEmptyWgpuRegistries(out) {
|
|
19
|
-
out.compressedTextureDecoder = createSlotTable('WgpuCompressedTextureDecoder', 'Unregistered');
|
|
20
|
-
out.compressedTextureUpload = createSlotTable('WgpuCompressedTextureUpload', 'Unregistered');
|
|
21
|
-
out.customMaterialShaders = createKeyedTable('WgpuCustomMaterialShader', 'Unregistered');
|
|
22
|
-
out.materialRenderers = createKeyedTable('WgpuMaterialRenderer', 'StandardMaterial');
|
|
23
|
-
out.meshMaterialRenderers = createKeyedTable('WgpuMeshMaterialRenderer', 'StandardMaterial');
|
|
24
|
-
out.modifierSnippets = createKeyedTable('WgpuModifierSnippet', 'Unregistered');
|
|
25
|
-
out.modifierSnippetRevision = 0;
|
|
26
|
-
out.renderEffects = createKeyedTable('WgpuRenderEffect', 'Unregistered');
|
|
27
|
-
out.renderers = createKeyedTable('NodeRenderer', 'Unregistered');
|
|
28
|
-
out.shapeRasterizer = createSlotTable('WgpuShapeRasterizer', 'Unregistered');
|
|
29
|
-
out.strokeTessellator = createSlotTable('StrokeTessellator', 'Rasterize');
|
|
30
|
-
out.textureResolvers = createKeyedTable('WgpuTextureResolver', 'Unregistered');
|
|
31
|
-
out.velocityWriters = createKeyedTable('WgpuVelocityWriter', 'Unregistered');
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=wgpuPipeline.js.map
|
package/dist/wgpuPipeline.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuPipeline.js","sourceRoot":"","sources":["../src/wgpuPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEhF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,UAAU,yBAAyB;IACvC,MAAM,GAAG,GAAG,cAAc,EAAwB,CAAC;IACnD,6BAA6B,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,UAA0C;IAC3E,MAAM,QAAQ,GAAG,cAAc,EAAgB,CAAC;IAChD,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,QAAQ,C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|
package/dist/wgpuSurface.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Bitmap, WgpuPresentationRenderState } from '@flighthq/types/contract';
|
|
2
|
-
export declare function acquireWgpuFrameCaptureTexture(state: Readonly<WgpuPresentationRenderState>): GPUTexture | null;
|
|
3
|
-
export declare function createBitmapFromWgpuRenderState(state: Readonly<WgpuPresentationRenderState>, timeoutMs?: number): Promise<Bitmap>;
|
|
4
|
-
export declare function enableWgpuFrameCapture(state: Readonly<WgpuPresentationRenderState>): void;
|
|
5
|
-
export declare function encodeWgpuFrameCapture(state: Readonly<WgpuPresentationRenderState>, encoder: GPUCommandEncoder): void;
|
|
6
|
-
//# sourceMappingURL=wgpuSurface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuSurface.d.ts","sourceRoot":"","sources":["../src/wgpuSurface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAmBpF,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,QAAQ,CAAC,2BAA2B,CAAC,GAAG,UAAU,GAAG,IAAI,CAmB9G;AAWD,wBAAsB,+BAA+B,CACnD,KAAK,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EAC5C,SAAS,SAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,CA0CjB;AAMD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,2BAA2B,CAAC,GAAG,IAAI,CAEzF;AAKD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAsCrH"}
|
package/dist/wgpuSurface.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { createBitmap } from '@flighthq/bitmap/contract';
|
|
2
|
-
import { getWgpuRenderStateRuntime } from './wgpuRenderState';
|
|
3
|
-
// Opt-in capture of the rendered frame to a CPU Bitmap. Two environment facts drive the design:
|
|
4
|
-
// (1) headless/software adapters never present the swapchain, and its texture reads back as zeros, so
|
|
5
|
-
// the frame is redirected into an offscreen COPY_SRC texture (acquireWgpuFrameCaptureTexture, used by
|
|
6
|
-
// renderWgpuBackground); (2) GPU work queued in a later task than the frame is dropped on these
|
|
7
|
-
// adapters, so submitWgpuRenderPass copies the capture texture into the retained capture buffer in the
|
|
8
|
-
// same frame (encodeWgpuFrameCapture), and createBitmapFromWgpuRenderState only maps that buffer.
|
|
9
|
-
//
|
|
10
|
-
// One buffer serves both sides, so they take turns: the writer skips its copy while the reader holds a
|
|
11
|
-
// map (or has one in flight), and resumes on the next frame. Without that turn-taking a continuously
|
|
12
|
-
// animating scene re-enqueues a copy every frame into the buffer a readback is waiting on — which the
|
|
13
|
-
// queue may not touch while it is mapped, and which pushes the pending map behind ever more GPU work.
|
|
14
|
-
// Returns the offscreen texture the frame should render into when capture is enabled, creating/resizing
|
|
15
|
-
// it to the canvas on demand, or null when capture is off (the caller then renders to the swapchain).
|
|
16
|
-
// Internal: called by renderWgpuBackground to redirect the frame so its pixels stay readable.
|
|
17
|
-
export function acquireWgpuFrameCaptureTexture(state) {
|
|
18
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
19
|
-
if (!runtime.frameCaptureEnabled)
|
|
20
|
-
return null;
|
|
21
|
-
const width = Math.max(1, state.surface.width);
|
|
22
|
-
const height = Math.max(1, state.surface.height);
|
|
23
|
-
const existing = runtime.frameCaptureTexture;
|
|
24
|
-
if (existing !== null && existing !== undefined && existing.width === width && existing.height === height) {
|
|
25
|
-
return existing;
|
|
26
|
-
}
|
|
27
|
-
existing?.destroy();
|
|
28
|
-
const texture = state.device.createTexture({
|
|
29
|
-
size: [width, height, 1],
|
|
30
|
-
format: state.format,
|
|
31
|
-
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC,
|
|
32
|
-
});
|
|
33
|
-
runtime.frameCaptureTexture = texture;
|
|
34
|
-
return texture;
|
|
35
|
-
}
|
|
36
|
-
// Reads the most recently captured frame into a CPU Bitmap. Requires enableWgpuFrameCapture(state)
|
|
37
|
-
// before rendering and at least one submitWgpuRenderPass since (which fills the capture buffer);
|
|
38
|
-
// throws otherwise (calling it without enabling capture is API misuse). Only maps the retained buffer —
|
|
39
|
-
// no GPU work is queued here, since later-task GPU work is unreliable on the adapters this exists for.
|
|
40
|
-
// Allocates the returned Bitmap; the capture buffer is retained and reused across frames.
|
|
41
|
-
//
|
|
42
|
-
// `timeoutMs` bounds the buffer map (pass 0 to wait indefinitely, the pre-bound behaviour). The default
|
|
43
|
-
// is deliberately generous: a readback that takes seconds is a loaded machine, while one that never
|
|
44
|
-
// settles is the failure this bounds, and only the caller knows which budget it is working inside.
|
|
45
|
-
export async function createBitmapFromWgpuRenderState(state, timeoutMs = DEFAULT_MAP_TIMEOUT_MS) {
|
|
46
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
47
|
-
const buffer = runtime.frameCaptureBuffer;
|
|
48
|
-
if (buffer === null || buffer === undefined) {
|
|
49
|
-
throw new Error('createBitmapFromWgpuRenderState requires enableWgpuFrameCapture(state) before rendering, then a submitWgpuRenderPass.');
|
|
50
|
-
}
|
|
51
|
-
const width = runtime.frameCaptureWidth;
|
|
52
|
-
const height = runtime.frameCaptureHeight;
|
|
53
|
-
const bytesPerRow = runtime.frameCaptureBytesPerRow;
|
|
54
|
-
await mapWgpuCaptureBuffer(buffer, timeoutMs);
|
|
55
|
-
const mapped = new Uint8Array(buffer.getMappedRange());
|
|
56
|
-
const bitmap = createBitmap(width, height);
|
|
57
|
-
const out = bitmap.data;
|
|
58
|
-
// The preferred canvas format is BGRA on most platforms and RGBA on software adapters; normalize to
|
|
59
|
-
// the Bitmap's RGBA byte order so coverage/fingerprint and saved pixels read correctly either way.
|
|
60
|
-
// Pixels are left premultiplied (the texture's stored form): functional content renders over an opaque
|
|
61
|
-
// background, so alpha is 255 and premultiplied == straight; do NOT un-premultiply here — dividing RGB
|
|
62
|
-
// by an 8-bit alpha amplifies quantization and clamps, blowing out exactly the semi-transparent pixels
|
|
63
|
-
// a colour comparison cares about. If straight-alpha output is ever needed, convert at the consumer in
|
|
64
|
-
// higher precision, or compare in premultiplied space on both sides.
|
|
65
|
-
const swizzleBGRA = state.format === 'bgra8unorm' || state.format === 'bgra8unorm-srgb';
|
|
66
|
-
for (let y = 0; y < height; y++) {
|
|
67
|
-
const srcRow = y * bytesPerRow;
|
|
68
|
-
const dstRow = y * width * 4;
|
|
69
|
-
for (let x = 0; x < width; x++) {
|
|
70
|
-
const s = srcRow + x * 4;
|
|
71
|
-
const d = dstRow + x * 4;
|
|
72
|
-
out[d] = swizzleBGRA ? mapped[s + 2] : mapped[s];
|
|
73
|
-
out[d + 1] = mapped[s + 1];
|
|
74
|
-
out[d + 2] = swizzleBGRA ? mapped[s] : mapped[s + 2];
|
|
75
|
-
out[d + 3] = mapped[s + 3];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// Unmap (not destroy) so the next frame's submit can copy into the retained buffer again.
|
|
79
|
-
buffer.unmap();
|
|
80
|
-
return bitmap;
|
|
81
|
-
}
|
|
82
|
-
// Enables opt-in frame capture on a render state so createBitmapFromWgpuRenderState can read it back.
|
|
83
|
-
// The frame is then drawn into an offscreen texture instead of the swapchain (the only reliably
|
|
84
|
-
// readable path on headless/software adapters); the canvas is not presented while capture is on. Leave
|
|
85
|
-
// it off for normal on-screen rendering. The capture texture and buffer are allocated lazily.
|
|
86
|
-
export function enableWgpuFrameCapture(state) {
|
|
87
|
-
getWgpuRenderStateRuntime(state).frameCaptureEnabled = true;
|
|
88
|
-
}
|
|
89
|
-
// Encodes the capture-texture → capture-buffer copy into the frame's command encoder, sizing/reallocating
|
|
90
|
-
// the retained buffer to the canvas on demand. No-op unless capture is enabled. Internal: called by
|
|
91
|
-
// submitWgpuRenderPass so the copy is queued in the render frame, not a later (dropped) task.
|
|
92
|
-
export function encodeWgpuFrameCapture(state, encoder) {
|
|
93
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
94
|
-
const texture = runtime.frameCaptureTexture;
|
|
95
|
-
if (!runtime.frameCaptureEnabled || texture === null || texture === undefined)
|
|
96
|
-
return;
|
|
97
|
-
// The reader owns the buffer while it holds a map. One retained buffer serves both sides, and the
|
|
98
|
-
// queue may not touch a buffer that is mapped or has a map in flight — so a frame encoded during a
|
|
99
|
-
// readback both invalidates the copy and stacks more GPU work in front of the map it is waiting on.
|
|
100
|
-
// Skipping the frame is the handshake: the reader is already taking a snapshot, and the next frame
|
|
101
|
-
// resumes copying once it lets go.
|
|
102
|
-
//
|
|
103
|
-
// Deliberately written as "is it busy" rather than "is it not unmapped": an implementation without
|
|
104
|
-
// `mapState` reports undefined, and the inverted test would then skip every copy for the whole run
|
|
105
|
-
// and capture nothing. Unknown state falls through to the copy, which is the pre-existing behaviour.
|
|
106
|
-
const mapState = runtime.frameCaptureBuffer?.mapState;
|
|
107
|
-
if (mapState === 'pending' || mapState === 'mapped')
|
|
108
|
-
return;
|
|
109
|
-
const width = texture.width;
|
|
110
|
-
const height = texture.height;
|
|
111
|
-
// Wgpu requires copyTextureToBuffer rows to be 256-byte aligned; the buffer is padded per row.
|
|
112
|
-
const bytesPerRow = Math.ceil((width * 4) / 256) * 256;
|
|
113
|
-
if (runtime.frameCaptureBuffer === null ||
|
|
114
|
-
runtime.frameCaptureBuffer === undefined ||
|
|
115
|
-
runtime.frameCaptureWidth !== width ||
|
|
116
|
-
runtime.frameCaptureHeight !== height) {
|
|
117
|
-
runtime.frameCaptureBuffer?.destroy();
|
|
118
|
-
runtime.frameCaptureBuffer = state.device.createBuffer({
|
|
119
|
-
size: bytesPerRow * height,
|
|
120
|
-
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
121
|
-
});
|
|
122
|
-
runtime.frameCaptureBytesPerRow = bytesPerRow;
|
|
123
|
-
runtime.frameCaptureWidth = width;
|
|
124
|
-
runtime.frameCaptureHeight = height;
|
|
125
|
-
}
|
|
126
|
-
encoder.copyTextureToBuffer({ texture }, { buffer: runtime.frameCaptureBuffer, bytesPerRow }, [width, height, 1]);
|
|
127
|
-
}
|
|
128
|
-
// Maps the retained capture buffer, giving up by name after `timeoutMs` (0 waits indefinitely).
|
|
129
|
-
// `mapAsync` carries no timeout and no reject path of its own: on the contended software adapters this
|
|
130
|
-
// capture path exists for, the promise can simply never settle, and an unbounded await is indistinguishable
|
|
131
|
-
// from a caller that stopped running. A late resolution after the deadline leaves the buffer mapped, which
|
|
132
|
-
// is why the timeout is a hard end for this capture and not something to retry against the same buffer.
|
|
133
|
-
async function mapWgpuCaptureBuffer(buffer, timeoutMs) {
|
|
134
|
-
const mapping = buffer.mapAsync(GPUMapMode.READ);
|
|
135
|
-
if (timeoutMs <= 0)
|
|
136
|
-
return mapping;
|
|
137
|
-
// The race abandons `mapping` on timeout; adopt its eventual rejection here so it is never unhandled.
|
|
138
|
-
mapping.catch(() => { });
|
|
139
|
-
let timer;
|
|
140
|
-
const expiry = new Promise((_resolve, reject) => {
|
|
141
|
-
timer = setTimeout(() => {
|
|
142
|
-
reject(new Error(`createBitmapFromWgpuRenderState: frame capture buffer did not map within ${timeoutMs}ms`));
|
|
143
|
-
}, timeoutMs);
|
|
144
|
-
});
|
|
145
|
-
try {
|
|
146
|
-
await Promise.race([mapping, expiry]);
|
|
147
|
-
}
|
|
148
|
-
finally {
|
|
149
|
-
clearTimeout(timer);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// Generous by design: this bounds a driver that has stopped answering, not a slow one. Callers working
|
|
153
|
-
// inside a tighter budget (the capture harness) pass their own.
|
|
154
|
-
const DEFAULT_MAP_TIMEOUT_MS = 10_000;
|
|
155
|
-
//# sourceMappingURL=wgpuSurface.js.map
|
package/dist/wgpuSurface.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuSur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faceAntialiasResolve,
|
|
7
|
-
getWgpuSurfaceLogicalExtent,
|
|
8
|
-
getWgpuSurfaceRenderExtent,
|
|
9
|
-
getWgpuSurfaceRenderScale,
|
|
10
|
-
} from './wgpuAntialias';
|
|
11
|
-
import { renderWgpuBackground, submitWgpuRenderPass } from './wgpuBackground';
|
|
12
|
-
import { createEmptyWgpuRegistries, createWgpuPipeline } from './wgpuPipeline';
|
|
13
|
-
import { createWgpuRenderStateFromCanvasElement, getWgpuRenderStateRuntime } from './wgpuRenderState';
|
|
14
|
-
import { setWgpuRenderPassScissorRect } from './wgpuScissor';
|
|
15
|
-
import { enableWgpuFrameCapture } from './wgpuSurface';
|
|
16
|
-
import { createWgpuRenderStateForTest, installWgpuMock } from './wgpuTestHelper';
|
|
17
|
-
|
|
18
|
-
beforeAll(() => {
|
|
19
|
-
installWgpuMock();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const _pipeline = createWgpuPipeline(createEmptyWgpuRegistries());
|
|
23
|
-
|
|
24
|
-
describe('acquireWgpuSurfaceAntialiasView', () => {
|
|
25
|
-
it('returns and retains a 2x render view when the option is enabled', async () => {
|
|
26
|
-
const state = await createWgpuRenderStateForTest({ antialias: true });
|
|
27
|
-
const presentationView = state.context.getCurrentTexture().createView();
|
|
28
|
-
|
|
29
|
-
const view = acquireWgpuSurfaceAntialiasView(state, presentationView);
|
|
30
|
-
|
|
31
|
-
expect(view).toBe(getWgpuRenderStateRuntime(state).surfaceAntialiasView);
|
|
32
|
-
expect(getWgpuRenderStateRuntime(state).surfacePresentationView).toBe(presentationView);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('clearWgpuSurfacePresentation', () => {
|
|
37
|
-
it('drops the per-frame presentation view without destroying reusable resolve resources', async () => {
|
|
38
|
-
const state = await createWgpuRenderStateForTest({ antialias: true });
|
|
39
|
-
acquireWgpuSurfaceAntialiasView(state, state.context.getCurrentTexture().createView());
|
|
40
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
41
|
-
const texture = runtime.surfaceAntialiasTexture;
|
|
42
|
-
|
|
43
|
-
clearWgpuSurfacePresentation(state);
|
|
44
|
-
|
|
45
|
-
expect(runtime.surfacePresentationView).toBeNull();
|
|
46
|
-
expect(runtime.surfaceAntialiasTexture).toBe(texture);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('encodeWgpuSurfaceAntialiasResolve', () => {
|
|
51
|
-
it('draws one fullscreen triangle into the retained presentation view', async () => {
|
|
52
|
-
const state = await createWgpuRenderStateForTest({ antialias: true });
|
|
53
|
-
acquireWgpuSurfaceAntialiasView(state, state.context.getCurrentTexture().createView());
|
|
54
|
-
const draw = vi.fn();
|
|
55
|
-
const beginRenderPass = vi.fn(() => ({
|
|
56
|
-
draw,
|
|
57
|
-
end: () => {},
|
|
58
|
-
setBindGroup: () => {},
|
|
59
|
-
setPipeline: () => {},
|
|
60
|
-
}));
|
|
61
|
-
|
|
62
|
-
encodeWgpuSurfaceAntialiasResolve(state, { beginRenderPass } as unknown as GPUCommandEncoder);
|
|
63
|
-
|
|
64
|
-
expect(beginRenderPass).toHaveBeenCalledOnce();
|
|
65
|
-
expect(draw).toHaveBeenCalledWith(3);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('getWgpuSurfaceLogicalExtent', () => {
|
|
70
|
-
it('keeps presentation coordinates logical while the render extent is supersampled', async () => {
|
|
71
|
-
const state = await createWgpuRenderStateForTest({ antialias: true });
|
|
72
|
-
acquireWgpuSurfaceAntialiasView(state, state.context.getCurrentTexture().createView());
|
|
73
|
-
|
|
74
|
-
expect(getWgpuSurfaceLogicalExtent(state)).toEqual({ height: 600, width: 800 });
|
|
75
|
-
expect(getWgpuSurfaceRenderExtent(state)).toEqual({ height: 1200, width: 1600 });
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('getWgpuSurfaceRenderExtent', () => {
|
|
80
|
-
it('switches from the logical canvas extent to the acquired supersample extent', async () => {
|
|
81
|
-
const state = await createWgpuRenderStateForTest({ antialias: true });
|
|
82
|
-
expect(getWgpuSurfaceRenderExtent(state)).toEqual({ width: 800, height: 600 });
|
|
83
|
-
|
|
84
|
-
acquireWgpuSurfaceAntialiasView(state, state.context.getCurrentTexture().createView());
|
|
85
|
-
|
|
86
|
-
expect(getWgpuSurfaceRenderExtent(state)).toEqual({ width: 1600, height: 1200 });
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe('getWgpuSurfaceRenderScale', () => {
|
|
91
|
-
it('scales only the acquired main surface', async () => {
|
|
92
|
-
const state = await createWgpuRenderStateForTest({ antialias: true });
|
|
93
|
-
acquireWgpuSurfaceAntialiasView(state, state.context.getCurrentTexture().createView());
|
|
94
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
95
|
-
|
|
96
|
-
expect(getWgpuSurfaceRenderScale(state)).toBe(2);
|
|
97
|
-
runtime.currentRenderTarget = {} as WgpuRenderTarget;
|
|
98
|
-
expect(getWgpuSurfaceRenderScale(state)).toBe(1);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe('WgpuRenderOptions.antialias', () => {
|
|
103
|
-
it('leaves the direct presentation path and all resolve resources off by default', async () => {
|
|
104
|
-
const state = await createWgpuRenderStateForTest();
|
|
105
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
106
|
-
const { encoder, setViewport } = installRecordingEncoder(state);
|
|
107
|
-
|
|
108
|
-
renderWgpuBackground(state);
|
|
109
|
-
|
|
110
|
-
expect(runtime.surfaceAntialiasEnabled).toBe(false);
|
|
111
|
-
expect(runtime.surfaceAntialiasTexture).toBeNull();
|
|
112
|
-
expect(runtime.surfaceAntialiasResolvePipeline).toBeNull();
|
|
113
|
-
expect(runtime.surfacePresentationView).toBeNull();
|
|
114
|
-
expect(setViewport).toHaveBeenCalledWith(0, 0, 800, 600, 0, 1);
|
|
115
|
-
expect(encoder.beginRenderPass).toHaveBeenCalledTimes(1);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('renders the main pass into a 2x surface while preserving logical canvas coordinates', async () => {
|
|
119
|
-
const state = await createWgpuRenderStateForTest({ antialias: true });
|
|
120
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
121
|
-
const { setViewport } = installRecordingEncoder(state);
|
|
122
|
-
|
|
123
|
-
renderWgpuBackground(state);
|
|
124
|
-
|
|
125
|
-
expect(runtime.surfaceAntialiasTexture?.width).toBe(1600);
|
|
126
|
-
expect(runtime.surfaceAntialiasTexture?.height).toBe(1200);
|
|
127
|
-
expect(runtime.depthStencilWidth).toBe(1600);
|
|
128
|
-
expect(runtime.depthStencilHeight).toBe(1200);
|
|
129
|
-
expect(runtime.renderTargetViewport).toBeNull();
|
|
130
|
-
expect(runtime.surfacePresentationView).not.toBeNull();
|
|
131
|
-
expect(setViewport).toHaveBeenCalledWith(0, 0, 1600, 1200, 0, 1);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('encodes one fullscreen resolve before frame-capture readback', async () => {
|
|
135
|
-
const state = await createWgpuRenderStateForTest({ antialias: true });
|
|
136
|
-
const events: string[] = [];
|
|
137
|
-
let passIndex = 0;
|
|
138
|
-
const encoder = {
|
|
139
|
-
beginRenderPass: vi.fn(() => {
|
|
140
|
-
const name = passIndex++ === 0 ? 'main' : 'resolve';
|
|
141
|
-
events.push(`${name}:begin`);
|
|
142
|
-
return {
|
|
143
|
-
draw: (vertices: number) => events.push(`${name}:draw:${vertices}`),
|
|
144
|
-
end: () => events.push(`${name}:end`),
|
|
145
|
-
setBindGroup: () => {},
|
|
146
|
-
setPipeline: () => {},
|
|
147
|
-
setScissorRect: () => {},
|
|
148
|
-
setStencilReference: () => {},
|
|
149
|
-
setViewport: () => {},
|
|
150
|
-
} as unknown as GPURenderPassEncoder;
|
|
151
|
-
}),
|
|
152
|
-
copyTextureToBuffer: () => events.push('capture:copy'),
|
|
153
|
-
finish: () => {
|
|
154
|
-
events.push('encoder:finish');
|
|
155
|
-
return {} as GPUCommandBuffer;
|
|
156
|
-
},
|
|
157
|
-
} as unknown as GPUCommandEncoder;
|
|
158
|
-
vi.spyOn(state.device, 'createCommandEncoder').mockReturnValue(encoder);
|
|
159
|
-
enableWgpuFrameCapture(state);
|
|
160
|
-
|
|
161
|
-
renderWgpuBackground(state);
|
|
162
|
-
submitWgpuRenderPass(state);
|
|
163
|
-
|
|
164
|
-
expect(events).toEqual([
|
|
165
|
-
'main:begin',
|
|
166
|
-
'main:end',
|
|
167
|
-
'resolve:begin',
|
|
168
|
-
'resolve:draw:3',
|
|
169
|
-
'resolve:end',
|
|
170
|
-
'capture:copy',
|
|
171
|
-
'encoder:finish',
|
|
172
|
-
]);
|
|
173
|
-
expect(getWgpuRenderStateRuntime(state).surfacePresentationView).toBeNull();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// C1b: the size is LIVE. The state's `surface` is readonly to the consumer, so the resize happens on the
|
|
177
|
-
// PROVIDER — the canvas — and the state must observe the new value. A provider that snapshotted its size
|
|
178
|
-
// at acquisition would leave this reading 800x600 forever and still pass every test that never resizes.
|
|
179
|
-
it('reallocates the supersample surface when the canvas size changes', async () => {
|
|
180
|
-
const canvas = document.createElement('canvas');
|
|
181
|
-
canvas.width = 800;
|
|
182
|
-
canvas.height = 600;
|
|
183
|
-
const state = await createWgpuRenderStateFromCanvasElement(canvas, _pipeline, { antialias: true });
|
|
184
|
-
renderWgpuBackground(state);
|
|
185
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
186
|
-
const first = runtime.surfaceAntialiasTexture!;
|
|
187
|
-
const destroy = vi.spyOn(first, 'destroy');
|
|
188
|
-
submitWgpuRenderPass(state);
|
|
189
|
-
|
|
190
|
-
canvas.width = 400;
|
|
191
|
-
canvas.height = 300;
|
|
192
|
-
expect(state.surface.width).toBe(400);
|
|
193
|
-
expect(state.surface.height).toBe(300);
|
|
194
|
-
renderWgpuBackground(state);
|
|
195
|
-
|
|
196
|
-
expect(destroy).toHaveBeenCalledOnce();
|
|
197
|
-
expect(runtime.surfaceAntialiasTexture).not.toBe(first);
|
|
198
|
-
expect(runtime.surfaceAntialiasTexture?.width).toBe(800);
|
|
199
|
-
expect(runtime.surfaceAntialiasTexture?.height).toBe(600);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('scales main-surface scissors but leaves offscreen-target scissors unchanged', async () => {
|
|
203
|
-
const state = await createWgpuRenderStateForTest({ antialias: true });
|
|
204
|
-
renderWgpuBackground(state);
|
|
205
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
206
|
-
const setScissorRect = vi.fn();
|
|
207
|
-
const pass = { setScissorRect } as unknown as GPURenderPassEncoder;
|
|
208
|
-
|
|
209
|
-
setWgpuRenderPassScissorRect(state, pass, 3, 5, 7, 11);
|
|
210
|
-
expect(setScissorRect).toHaveBeenLastCalledWith(6, 10, 14, 22);
|
|
211
|
-
|
|
212
|
-
runtime.currentRenderTarget = {} as WgpuRenderTarget;
|
|
213
|
-
setWgpuRenderPassScissorRect(state, pass, 3, 5, 7, 11);
|
|
214
|
-
expect(setScissorRect).toHaveBeenLastCalledWith(3, 5, 7, 11);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
function installRecordingEncoder(state: { device: GPUDevice }): {
|
|
219
|
-
encoder: GPUCommandEncoder & { beginRenderPass: ReturnType<typeof vi.fn> };
|
|
220
|
-
setViewport: ReturnType<typeof vi.fn>;
|
|
221
|
-
} {
|
|
222
|
-
const setViewport = vi.fn();
|
|
223
|
-
const pass = {
|
|
224
|
-
draw: () => {},
|
|
225
|
-
end: () => {},
|
|
226
|
-
setBindGroup: () => {},
|
|
227
|
-
setPipeline: () => {},
|
|
228
|
-
setScissorRect: () => {},
|
|
229
|
-
setStencilReference: () => {},
|
|
230
|
-
setViewport,
|
|
231
|
-
} as unknown as GPURenderPassEncoder;
|
|
232
|
-
const beginRenderPass = vi.fn(() => pass);
|
|
233
|
-
const encoder = {
|
|
234
|
-
beginRenderPass,
|
|
235
|
-
finish: () => ({}) as GPUCommandBuffer,
|
|
236
|
-
} as unknown as GPUCommandEncoder & { beginRenderPass: ReturnType<typeof vi.fn> };
|
|
237
|
-
vi.spyOn(state.device, 'createCommandEncoder').mockReturnValue(encoder);
|
|
238
|
-
return { encoder, setViewport };
|
|
239
|
-
}
|
package/src/wgpuElement.test.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createWgpuCanvasElement,
|
|
3
|
-
createWgpuRenderSurface,
|
|
4
|
-
getWgpuRenderSurfaceProvider,
|
|
5
|
-
resetWgpuRenderSurfaceProviderForTest,
|
|
6
|
-
setWgpuRenderSurfaceProvider,
|
|
7
|
-
} from './wgpuElement';
|
|
8
|
-
|
|
9
|
-
function entityProvider(fields: Omit<WgpuRenderSurfaceProvider, keyof Entity>): WgpuRenderSurfaceProvider {
|
|
10
|
-
return (() => {
|
|
11
|
-
const out = allocateEntity<any>();
|
|
12
|
-
Object.assign(out, fields);
|
|
13
|
-
return finishEntity(out);
|
|
14
|
-
})();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
describe('createWgpuCanvasElement', () => {
|
|
18
|
-
afterEach(() => resetWgpuRenderSurfaceProviderForTest());
|
|
19
|
-
|
|
20
|
-
it('preserves the canonical provider result identity', () => {
|
|
21
|
-
const surface = {} as HTMLCanvasElement;
|
|
22
|
-
setWgpuRenderSurfaceProvider(entityProvider({ createRenderSurface: () => surface }));
|
|
23
|
-
expect(createWgpuCanvasElement(100, 200, 2)).toBe(surface);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('throws an actionable Web-only setup error when the provider is absent', () => {
|
|
27
|
-
expect(() => createWgpuCanvasElement(100, 200)).toThrowError(
|
|
28
|
-
/enableHostWebWgpuRenderSurface\(\).*inject a WgpuRenderSurfaceProvider/,
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('throws the same setup error when the provider refuses', () => {
|
|
33
|
-
setWgpuRenderSurfaceProvider(entityProvider({ createRenderSurface: () => null }));
|
|
34
|
-
expect(() => createWgpuCanvasElement(100, 200)).toThrowError(/enableHostWebWgpuRenderSurface\(\)/);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('createWgpuRenderSurface', () => {
|
|
39
|
-
afterEach(() => resetWgpuRenderSurfaceProviderForTest());
|
|
40
|
-
|
|
41
|
-
it('returns null when no provider is selected', () => {
|
|
42
|
-
expect(createWgpuRenderSurface(100, 200)).toBeNull();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('passes exact dimensions and the default pixel ratio to the selected provider', () => {
|
|
46
|
-
const surface = {} as HTMLCanvasElement;
|
|
47
|
-
const createRenderSurface = vi.fn(() => surface);
|
|
48
|
-
setWgpuRenderSurfaceProvider(entityProvider({ createRenderSurface }));
|
|
49
|
-
expect(createWgpuRenderSurface(100, 200)).toBe(surface);
|
|
50
|
-
expect(createRenderSurface).toHaveBeenCalledOnce();
|
|
51
|
-
expect(createRenderSurface).toHaveBeenCalledWith(100, 200, 1);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('passes an explicit pixel ratio and preserves the provider result identity', () => {
|
|
55
|
-
const surface = {} as HTMLCanvasElement;
|
|
56
|
-
const createRenderSurface = vi.fn(() => surface);
|
|
57
|
-
setWgpuRenderSurfaceProvider(entityProvider({ createRenderSurface }));
|
|
58
|
-
expect(createWgpuRenderSurface(300, 150, 2.5)).toBe(surface);
|
|
59
|
-
expect(createRenderSurface).toHaveBeenCalledWith(300, 150, 2.5);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('selects replacements and reset restores omission', () => {
|
|
63
|
-
const first = {} as HTMLCanvasElement;
|
|
64
|
-
const second = {} as HTMLCanvasElement;
|
|
65
|
-
const firstProvider = entityProvider({ createRenderSurface: vi.fn(() => first) });
|
|
66
|
-
const secondProvider = entityProvider({ createRenderSurface: vi.fn(() => second) });
|
|
67
|
-
setWgpuRenderSurfaceProvider(firstProvider);
|
|
68
|
-
expect(getWgpuRenderSurfaceProvider()).toBe(firstProvider);
|
|
69
|
-
expect(createWgpuRenderSurface(1, 2)).toBe(first);
|
|
70
|
-
setWgpuRenderSurfaceProvider(secondProvider);
|
|
71
|
-
expect(getWgpuRenderSurfaceProvider()).toBe(secondProvider);
|
|
72
|
-
expect(createWgpuRenderSurface(3, 4)).toBe(second);
|
|
73
|
-
resetWgpuRenderSurfaceProviderForTest();
|
|
74
|
-
expect(getWgpuRenderSurfaceProvider()).toBeNull();
|
|
75
|
-
expect(createWgpuRenderSurface(5, 6)).toBeNull();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('preserves provider refusal as null', () => {
|
|
79
|
-
setWgpuRenderSurfaceProvider(entityProvider({ createRenderSurface: () => null }));
|
|
80
|
-
expect(createWgpuRenderSurface(100, 200)).toBeNull();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('lets a native host provide a surface without reading document', () => {
|
|
84
|
-
const surface = {} as HTMLCanvasElement;
|
|
85
|
-
setWgpuRenderSurfaceProvider(entityProvider({ createRenderSurface: () => surface }));
|
|
86
|
-
withThrowingDocument(() => expect(createWgpuRenderSurface(100, 200)).toBe(surface));
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('returns null for omission and refusal without reading document', () => {
|
|
90
|
-
withThrowingDocument(() => {
|
|
91
|
-
expect(createWgpuRenderSurface(100, 200)).toBeNull();
|
|
92
|
-
setWgpuRenderSurfaceProvider(entityProvider({ createRenderSurface: () => null }));
|
|
93
|
-
expect(createWgpuRenderSurface(100, 200)).toBeNull();
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('getWgpuRenderSurfaceProvider', () => {
|
|
99
|
-
afterEach(() => resetWgpuRenderSurfaceProviderForTest());
|
|
100
|
-
|
|
101
|
-
it('returns the exact selected provider', () => {
|
|
102
|
-
const provider = entityProvider({ createRenderSurface: () => ({}) as HTMLCanvasElement });
|
|
103
|
-
setWgpuRenderSurfaceProvider(provider);
|
|
104
|
-
expect(getWgpuRenderSurfaceProvider()).toBe(provider);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe('resetWgpuRenderSurfaceProviderForTest', () => {
|
|
109
|
-
it('restores provider omission', () => {
|
|
110
|
-
setWgpuRenderSurfaceProvider(entityProvider({ createRenderSurface: () => ({}) as HTMLCanvasElement }));
|
|
111
|
-
resetWgpuRenderSurfaceProviderForTest();
|
|
112
|
-
expect(getWgpuRenderSurfaceProvider()).toBeNull();
|
|
113
|
-
expect(createWgpuRenderSurface(1, 1)).toBeNull();
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe('setWgpuRenderSurfaceProvider', () => {
|
|
118
|
-
afterEach(() => resetWgpuRenderSurfaceProviderForTest());
|
|
119
|
-
|
|
120
|
-
it('replaces the selected provider', () => {
|
|
121
|
-
const first = entityProvider({ createRenderSurface: () => ({}) as HTMLCanvasElement });
|
|
122
|
-
const second = entityProvider({ createRenderSurface: () => ({}) as HTMLCanvasElement });
|
|
123
|
-
setWgpuRenderSurfaceProvider(first);
|
|
124
|
-
setWgpuRenderSurfaceProvider(second);
|
|
125
|
-
expect(getWgpuRenderSurfaceProvider()).toBe(second);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
function withThrowingDocument(run: () => void): void {
|
|
130
|
-
const descriptor = Object.getOwnPropertyDescriptor(globalThis, 'document');
|
|
131
|
-
Object.defineProperty(globalThis, 'document', {
|
|
132
|
-
configurable: true,
|
|
133
|
-
get(): never {
|
|
134
|
-
throw new Error('portable WGPU code read document');
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
try {
|
|
138
|
-
run();
|
|
139
|
-
} finally {
|
|
140
|
-
if (descriptor === undefined) delete (globalThis as { document?: Document }).document;
|
|
141
|
-
else Object.defineProperty(globalThis, 'document', descriptor);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
145
|
-
import type { Entity, WgpuRenderSurfaceProvider } from '@flighthq/types/contract';
|