@flighthq/render-wgpu 0.5.1-next.920.da8f530 → 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 +29 -16
- 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 +10 -10
- 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,30 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { acquireWgpuFrameCaptureTexture, encodeWgpuFrameCapture } from './wgpuSurface';
|
|
4
|
-
function ensureWgpuDepthStencil(state, width, height) {
|
|
5
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
6
|
-
if (runtime.depthStencilTexture !== null &&
|
|
7
|
-
runtime.depthStencilWidth === width &&
|
|
8
|
-
runtime.depthStencilHeight === height) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
runtime.depthStencilTexture?.destroy();
|
|
12
|
-
const texture = state.device.createTexture({
|
|
13
|
-
size: [Math.max(1, width), Math.max(1, height), 1],
|
|
14
|
-
format: 'depth24plus-stencil8',
|
|
15
|
-
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
|
16
|
-
});
|
|
17
|
-
runtime.depthStencilTexture = texture;
|
|
18
|
-
runtime.depthStencilView = texture.createView();
|
|
19
|
-
runtime.depthStencilWidth = width;
|
|
20
|
-
runtime.depthStencilHeight = height;
|
|
21
|
-
}
|
|
1
|
+
import { getWgpuRenderStateRuntime } from './wgpuRenderState.js';
|
|
2
|
+
import { endWgpuScreenRenderTargetFrame } from './wgpuScreenRenderTarget.js';
|
|
22
3
|
/**
|
|
23
|
-
* Opens the command encoder
|
|
4
|
+
* Opens the command encoder a frame records into, without opening any render pass.
|
|
24
5
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
6
|
+
* beginWgpuRenderPass calls this itself, and the pass that opened the frame submits it at end — so an
|
|
7
|
+
* ordinary render loop never names either function. Call it explicitly when several passes must land in
|
|
8
|
+
* ONE submit (a shadow depth pass before the screen pass): the frame is then yours, and you finish it
|
|
9
|
+
* with submitWgpuFrame.
|
|
28
10
|
*/
|
|
29
11
|
export function beginWgpuFrame(state) {
|
|
30
12
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
@@ -37,64 +19,7 @@ export function beginWgpuFrame(state) {
|
|
|
37
19
|
runtime.quadBatchWriterBufferCursor = 0;
|
|
38
20
|
runtime.meshInstanceBufferCursor = 0;
|
|
39
21
|
runtime.currentBlendMode = null;
|
|
40
|
-
runtime.
|
|
41
|
-
runtime.currentMaskDepth = 0;
|
|
42
|
-
runtime.maskWriteMode = false;
|
|
43
|
-
runtime.currentScissorRect = null;
|
|
44
|
-
runtime.scissorStack = [];
|
|
45
|
-
}
|
|
46
|
-
export function renderWgpuBackground(state) {
|
|
47
|
-
const runtime = getWgpuRenderStateRuntime(state);
|
|
48
|
-
// End any previous open pass (safety guard).
|
|
49
|
-
if (runtime.renderPass !== null) {
|
|
50
|
-
runtime.renderPass.end();
|
|
51
|
-
runtime.renderPass = null;
|
|
52
|
-
}
|
|
53
|
-
// Preserve prerequisite work and its uniform-ring allocations when a recipe opened the frame
|
|
54
|
-
// explicitly. The common path still creates and resets the frame here.
|
|
55
|
-
beginWgpuFrame(state);
|
|
56
|
-
const surface = state.surface;
|
|
57
|
-
const context = state.context;
|
|
58
|
-
const width = surface.width;
|
|
59
|
-
const height = surface.height;
|
|
60
|
-
// With frame capture on, render into an offscreen COPY_SRC texture instead of the swapchain: software/
|
|
61
|
-
// headless adapters never present the swapchain and its texture reads back as zeros, so the readable
|
|
62
|
-
// copy must be the render target itself.
|
|
63
|
-
const presentationTexture = acquireWgpuFrameCaptureTexture(state) ?? context.getCurrentTexture();
|
|
64
|
-
const presentationView = presentationTexture.createView();
|
|
65
|
-
const antialiasView = acquireWgpuSurfaceAntialiasView(state, presentationView);
|
|
66
|
-
const renderWidth = antialiasView === null ? width : width * 2;
|
|
67
|
-
const renderHeight = antialiasView === null ? height : height * 2;
|
|
68
|
-
ensureWgpuDepthStencil(state, renderWidth, renderHeight);
|
|
69
|
-
const canvasView = antialiasView ?? presentationView;
|
|
70
|
-
runtime.canvasTextureView = canvasView;
|
|
71
|
-
runtime.canvasViewCleared = true;
|
|
72
|
-
// The canvas (and the capture texture, when capture is on) is the canvas format; scene pipelines key on this.
|
|
73
|
-
runtime.currentColorFormat = state.format;
|
|
74
|
-
runtime.renderTargetViewport = null;
|
|
75
|
-
const rgba = state.backgroundColorRgba;
|
|
76
|
-
const clearValue = rgba.length >= 4 && rgba[3] > 0 ? { r: rgba[0], g: rgba[1], b: rgba[2], a: rgba[3] } : { r: 0, g: 0, b: 0, a: 0 };
|
|
77
|
-
const renderPass = runtime.commandEncoder.beginRenderPass({
|
|
78
|
-
colorAttachments: [
|
|
79
|
-
{
|
|
80
|
-
view: canvasView,
|
|
81
|
-
clearValue,
|
|
82
|
-
loadOp: 'clear',
|
|
83
|
-
storeOp: 'store',
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
depthStencilAttachment: {
|
|
87
|
-
view: runtime.depthStencilView,
|
|
88
|
-
depthClearValue: 1.0,
|
|
89
|
-
depthLoadOp: 'clear',
|
|
90
|
-
depthStoreOp: 'discard',
|
|
91
|
-
stencilClearValue: 0,
|
|
92
|
-
stencilLoadOp: 'clear',
|
|
93
|
-
stencilStoreOp: 'discard',
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
renderPass.setViewport(0, 0, renderWidth, renderHeight, 0, 1);
|
|
97
|
-
runtime.renderPass = renderPass;
|
|
22
|
+
runtime.frameScreenTarget = null;
|
|
98
23
|
}
|
|
99
24
|
// Hands a buffer to the post-submit retirement list instead of destroying it now — the buffer sibling of
|
|
100
25
|
// retireWgpuTexture below, and subject to the same rule for the same reason: a frame records into one
|
|
@@ -112,34 +37,38 @@ export function retireWgpuBuffer(state, buffer) {
|
|
|
112
37
|
// submit, and the symptom is an ENTIRELY BLANK FRAME with a console warning naming a texture rather than
|
|
113
38
|
// a call site — a cost-to-diagnose far out of proportion to the one line that causes it. Callers that
|
|
114
39
|
// replace a texture during recording (a grown palette arena, a resized rasterization cache, a cache entry
|
|
115
|
-
// rewritten on a payload version bump) retire it here;
|
|
40
|
+
// rewritten on a payload version bump) retire it here; submitWgpuFrame frees it once the frame is
|
|
116
41
|
// safely on the queue.
|
|
117
42
|
export function retireWgpuTexture(state, texture) {
|
|
118
43
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
119
44
|
(runtime.retiredTextures ?? (runtime.retiredTextures = [])).push(texture);
|
|
120
45
|
}
|
|
121
|
-
|
|
46
|
+
// Finishes the frame: uploads the used part of the uniform ring, resolves a supersampled screen target,
|
|
47
|
+
// encodes its capture copy, and submits the command buffer. The pass that opened the frame calls this at
|
|
48
|
+
// its end, so an ordinary render loop never names it; a caller that opened the frame with beginWgpuFrame
|
|
49
|
+
// finishes it here.
|
|
50
|
+
export function submitWgpuFrame(state) {
|
|
122
51
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
123
|
-
const {
|
|
52
|
+
const { commandEncoder, uniformBuffer, uniformData, uniformOffset } = runtime;
|
|
124
53
|
const device = state.device;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
runtime.renderPass = null;
|
|
128
|
-
}
|
|
54
|
+
endWgpuFramePasses(state);
|
|
55
|
+
const screen = runtime.frameScreenTarget;
|
|
129
56
|
if (commandEncoder !== null) {
|
|
130
57
|
// Upload used portion of the uniform ring buffer before submission.
|
|
131
58
|
// writeBuffer is a queue operation that completes before the subsequent submit.
|
|
132
59
|
if (uniformOffset > 0) {
|
|
133
60
|
device.queue.writeBuffer(uniformBuffer, 0, uniformData.buffer, 0, uniformOffset);
|
|
134
61
|
}
|
|
135
|
-
//
|
|
136
|
-
encodeWgpuSurfaceAntialiasResolve(state, commandEncoder);
|
|
137
|
-
// Copy the offscreen capture texture into the readback buffer within this frame's encoder; on the
|
|
138
|
-
// adapters capture exists for, GPU work queued in a later task does not land.
|
|
139
|
-
// A standalone offscreen frame (for example a render-cache bake) has no canvas view and must not
|
|
62
|
+
// A frame that only drew into texture targets has no screen to resolve or capture, and must not
|
|
140
63
|
// overwrite the capture buffer with the previous visible frame's retained capture texture.
|
|
141
|
-
if (
|
|
142
|
-
|
|
64
|
+
if (screen !== null) {
|
|
65
|
+
// Resolve the optional 2x supersample into the presentation view before capture reads it back, then
|
|
66
|
+
// copy the capture texture into the readback buffer within this frame's encoder — on the adapters
|
|
67
|
+
// capture exists for, GPU work queued in a later task does not land. Both arrive as slots the
|
|
68
|
+
// opt-in modules install, so a frame that uses neither pulls in neither.
|
|
69
|
+
screen.encodeAntialiasResolve?.(state, screen, commandEncoder);
|
|
70
|
+
screen.encodeCapture?.(screen, commandEncoder);
|
|
71
|
+
}
|
|
143
72
|
device.queue.submit([commandEncoder.finish()]);
|
|
144
73
|
runtime.commandEncoder = null;
|
|
145
74
|
// Now that the frame is submitted, free the buffers retired mid-frame (clip pops, grown particle
|
|
@@ -157,14 +86,17 @@ export function submitWgpuRenderPass(state) {
|
|
|
157
86
|
retiredTextures.length = 0;
|
|
158
87
|
}
|
|
159
88
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
89
|
+
if (screen !== null)
|
|
90
|
+
endWgpuScreenRenderTargetFrame(screen);
|
|
91
|
+
runtime.frameScreenTarget = null;
|
|
163
92
|
}
|
|
164
93
|
/**
|
|
165
|
-
* Temporarily records an offscreen state's work into
|
|
94
|
+
* Temporarily records an offscreen state's work into another state's live command encoder.
|
|
166
95
|
* The borrower keeps its own uniform ring, batch buffers, traversal counters, and GPU resources; only
|
|
167
96
|
* the frame encoder/pass boundary is borrowed, and this callback bracket always returns it.
|
|
97
|
+
*
|
|
98
|
+
* The open pass stack is borrowed by reference, so a pass the borrower opens suspends and resumes the
|
|
99
|
+
* owner's innermost pass exactly as one opened on the owner would.
|
|
168
100
|
*/
|
|
169
101
|
export function withWgpuFrameBorrow(ownerState, borrowerState, callback) {
|
|
170
102
|
if (borrowerState.device !== ownerState.device) {
|
|
@@ -180,16 +112,12 @@ export function withWgpuFrameBorrow(ownerState, borrowerState, callback) {
|
|
|
180
112
|
const saved = captureBorrowerFrameState(borrower);
|
|
181
113
|
borrower.commandEncoder = owner.commandEncoder;
|
|
182
114
|
borrower.renderPass = owner.renderPass;
|
|
183
|
-
borrower.
|
|
184
|
-
borrower.
|
|
185
|
-
borrower.depthStencilTexture = owner.depthStencilTexture;
|
|
186
|
-
borrower.depthStencilView = owner.depthStencilView;
|
|
187
|
-
borrower.depthStencilWidth = owner.depthStencilWidth;
|
|
188
|
-
borrower.depthStencilHeight = owner.depthStencilHeight;
|
|
115
|
+
borrower.frameScreenTarget = owner.frameScreenTarget;
|
|
116
|
+
borrower.passStack = owner.passStack;
|
|
189
117
|
borrower.currentColorFormat = owner.currentColorFormat;
|
|
190
118
|
borrower.currentRenderTarget = owner.currentRenderTarget;
|
|
191
119
|
borrower.renderTargetViewport = owner.renderTargetViewport;
|
|
192
|
-
borrower.borrowedSurfaceExtent =
|
|
120
|
+
borrower.borrowedSurfaceExtent = owner.renderTargetViewport;
|
|
193
121
|
borrower.uniformOffset = 0;
|
|
194
122
|
borrower.quadBatchWriterBufferCursor = 0;
|
|
195
123
|
borrower.meshInstanceBufferCursor = 0;
|
|
@@ -202,33 +130,50 @@ export function withWgpuFrameBorrow(ownerState, borrowerState, callback) {
|
|
|
202
130
|
}
|
|
203
131
|
owner.commandEncoder = borrower.commandEncoder;
|
|
204
132
|
owner.renderPass = borrower.renderPass;
|
|
205
|
-
owner.
|
|
206
|
-
owner.canvasViewCleared = borrower.canvasViewCleared;
|
|
207
|
-
owner.depthStencilTexture = borrower.depthStencilTexture;
|
|
208
|
-
owner.depthStencilView = borrower.depthStencilView;
|
|
209
|
-
owner.depthStencilWidth = borrower.depthStencilWidth;
|
|
210
|
-
owner.depthStencilHeight = borrower.depthStencilHeight;
|
|
133
|
+
owner.frameScreenTarget = borrower.frameScreenTarget;
|
|
211
134
|
owner.currentColorFormat = borrower.currentColorFormat;
|
|
212
135
|
owner.currentRenderTarget = borrower.currentRenderTarget;
|
|
213
136
|
owner.renderTargetViewport = borrower.renderTargetViewport;
|
|
214
137
|
transferRetiredWgpuResources(borrower, owner);
|
|
215
138
|
restoreBorrowerFrameState(borrower, saved);
|
|
216
139
|
if (ownsFrame)
|
|
217
|
-
|
|
140
|
+
submitWgpuFrame(ownerState);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// A frame submit closes everything the frame recorded. A pass still open here is a caller that never
|
|
144
|
+
// ended its bracket — the encoder cannot survive into the next frame, so the stack is unwound to the
|
|
145
|
+
// state the outermost begin saved. Those handles are dropped rather than pooled: this is the abnormal
|
|
146
|
+
// path, and returning a handle the caller may still be holding is worse than letting one be collected.
|
|
147
|
+
function endWgpuFramePasses(state) {
|
|
148
|
+
const runtime = getWgpuRenderStateRuntime(state);
|
|
149
|
+
const stack = runtime.passStack;
|
|
150
|
+
if (runtime.renderPass !== null) {
|
|
151
|
+
runtime.renderPass.end();
|
|
152
|
+
runtime.renderPass = null;
|
|
218
153
|
}
|
|
154
|
+
if (stack.length === 0)
|
|
155
|
+
return;
|
|
156
|
+
for (let i = stack.length - 1; i >= 0; i--)
|
|
157
|
+
stack[i].encoder = null;
|
|
158
|
+
const saved = stack[0].saved;
|
|
159
|
+
runtime.currentRenderTarget = saved.renderTarget;
|
|
160
|
+
runtime.currentColorFormat = saved.colorFormat;
|
|
161
|
+
runtime.renderTargetViewport = saved.renderTargetViewport;
|
|
162
|
+
runtime.clipForms = saved.clipForms;
|
|
163
|
+
runtime.currentMaskDepth = saved.currentMaskDepth;
|
|
164
|
+
runtime.maskWriteMode = saved.maskWriteMode;
|
|
165
|
+
runtime.currentScissorRect = saved.currentScissorRect;
|
|
166
|
+
runtime.scissorStack = saved.scissorStack;
|
|
167
|
+
stack.length = 0;
|
|
219
168
|
}
|
|
220
169
|
function captureBorrowerFrameState(runtime) {
|
|
221
170
|
return {
|
|
222
|
-
canvasTextureView: runtime.canvasTextureView,
|
|
223
|
-
canvasViewCleared: runtime.canvasViewCleared,
|
|
224
171
|
borrowedSurfaceExtent: runtime.borrowedSurfaceExtent,
|
|
225
172
|
commandEncoder: runtime.commandEncoder,
|
|
226
173
|
currentColorFormat: runtime.currentColorFormat,
|
|
227
174
|
currentRenderTarget: runtime.currentRenderTarget,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
depthStencilView: runtime.depthStencilView,
|
|
231
|
-
depthStencilWidth: runtime.depthStencilWidth,
|
|
175
|
+
frameScreenTarget: runtime.frameScreenTarget,
|
|
176
|
+
passStack: runtime.passStack,
|
|
232
177
|
renderPass: runtime.renderPass,
|
|
233
178
|
renderTargetViewport: runtime.renderTargetViewport,
|
|
234
179
|
};
|
|
@@ -246,4 +191,4 @@ function transferRetiredWgpuResources(borrower, owner) {
|
|
|
246
191
|
borrower.retiredTextures.length = 0;
|
|
247
192
|
}
|
|
248
193
|
}
|
|
249
|
-
//# sourceMappingURL=
|
|
194
|
+
//# sourceMappingURL=wgpuFrame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuFrame.js","sourceRoot":"","sources":["../src/wgpuFrame.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,KAAsB;IACnD,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,IAAI,OAAO,CAAC,cAAc,KAAK,IAAI;QAAE,OAAO;IAE5C,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;IAC7D,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC;IAC1B,sGAAsG;IACtG,8CAA8C;IAC9C,OAAO,CAAC,2BAA2B,GAAG,CAAC,CAAC;IACxC,OAAO,CAAC,wB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AC5B,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;KACnD,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAAC,OAA+B,EAAE,KAAyB;IAC3F,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,4BAA4B,CAAC,QAAgC,EAAE,KAA6B;IACnG,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS,IAAI,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChF,CAAC,KAAK,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;QACvF,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,QAAQ,CAAC,eAAe,KAAK,SAAS,IAAI,QAAQ,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClF,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC1F,QAAQ,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { EntityConstruction
|
|
2
|
-
|
|
1
|
+
import type { EntityConstruction } from '@flighthq/entity/contract';
|
|
2
|
+
import type { WgpuBindGroup, WgpuBindGroupLayout, WgpuFullscreenPipeline, WgpuRenderState, WgpuTextureFormat, WgpuTextureRenderTarget } from './contract.render-wgpu-types.ts';
|
|
3
|
+
export declare function createWgpuFullscreenPipeline(state: WgpuRenderState, fragmentWgsl: string, textureInputCount?: number, format?: WgpuTextureFormat): WgpuFullscreenPipeline;
|
|
3
4
|
export declare function destroyWgpuFullscreenPipeline(_state: WgpuRenderState, _pipeline: WgpuFullscreenPipeline): void;
|
|
4
|
-
export declare function drawWgpuFullscreenPass(state: WgpuRenderState, wgpuPipeline: Readonly<WgpuFullscreenPipeline>, inputs: ReadonlyArray<Readonly<
|
|
5
|
-
export declare function initializeWgpuFullscreenPipeline(out: EntityConstruction<WgpuFullscreenPipeline>, state: WgpuRenderState, fragmentWgsl: string, textureInputCount?: number, format?:
|
|
5
|
+
export declare function drawWgpuFullscreenPass(state: WgpuRenderState, wgpuPipeline: Readonly<WgpuFullscreenPipeline>, inputs: ReadonlyArray<Readonly<WgpuTextureRenderTarget>>, setUniforms: ((state: WgpuRenderState, uniformBindGroupLayout: WgpuBindGroupLayout) => WgpuBindGroup) | null): void;
|
|
6
|
+
export declare function initializeWgpuFullscreenPipeline(out: EntityConstruction<WgpuFullscreenPipeline>, state: WgpuRenderState, fragmentWgsl: string, textureInputCount?: number, format?: WgpuTextureFormat): void;
|
|
6
7
|
//# sourceMappingURL=wgpuFullscreenPass.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuFullscreenPass.d.ts","sourceRoot":"","sources":["../src/wgpuFullscreenPass.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"wgpuFullscreenPass.d.ts","sourceRoot":"","sources":["../src/wgpuFullscreenPass.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,iCAAiC,CAAC;AAIzC,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,MAAM,EACpB,iBAAiB,SAAI,EACrB,MAAM,GAAE,iBAAgC,GACvC,sBAAsB,CAIxB;AAKD,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,sBAAsB,GAAG,IAAI,CAG9G;AAOD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,QAAQ,CAAC,sBAAsB,CAAC,EAC9C,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC,EACxD,WAAW,EAAE,CAAC,CAAC,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,mBAAmB,KAAK,aAAa,CAAC,GAAG,IAAI,GAC3G,IAAI,CA2BN;AAOD,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,EAC/C,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,MAAM,EACpB,iBAAiB,SAAI,EACrB,MAAM,GAAE,iBAAgC,GACvC,IAAI,CAoDN"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { allocateEntity
|
|
2
|
-
import {
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
|
+
import { WgpuBufferUsage, WgpuShaderStage } from './contract.render-wgpu-types.js';
|
|
3
|
+
import { getWgpuRenderStateRuntime } from './wgpuRenderState.js';
|
|
3
4
|
export function createWgpuFullscreenPipeline(state, fragmentWgsl, textureInputCount = 1, format = state.format) {
|
|
4
5
|
const out = allocateEntity();
|
|
5
6
|
initializeWgpuFullscreenPipeline(out, state, fragmentWgsl, textureInputCount, format);
|
|
6
|
-
return
|
|
7
|
+
return out;
|
|
7
8
|
}
|
|
8
9
|
// Destroys a fullscreen pipeline's GPU resources. The pipeline and layouts are GC-managed in
|
|
9
10
|
// WebGPU and have no explicit destroy(); this function is a no-op but kept for API symmetry with
|
|
@@ -12,24 +13,25 @@ export function destroyWgpuFullscreenPipeline(_state, _pipeline) {
|
|
|
12
13
|
// WebGPU pipelines and layouts have no destroy() — they are GC-managed. Drop the reference
|
|
13
14
|
// on the caller's side to allow collection.
|
|
14
15
|
}
|
|
15
|
-
// Draws a fullscreen pass into the current render target
|
|
16
|
-
//
|
|
17
|
-
//
|
|
16
|
+
// Draws a fullscreen pass into the current render target. Binds `inputs[i]` as texture
|
|
17
|
+
// @group(1+i) @binding(0), calls `setUniforms` for per-pass uploads (pass null if the shader
|
|
18
|
+
// declares no uniforms), then draws 3 vertices.
|
|
18
19
|
//
|
|
19
|
-
// Requires an open render pass
|
|
20
|
-
|
|
21
|
-
// provided, its bind group is set via the caller's render pass.
|
|
22
|
-
export function drawWgpuFullscreenPass(state, wgpuPipeline, inputs, dest, setUniforms) {
|
|
20
|
+
// Requires an open render pass: beginWgpuRenderPass fixes the destination, and this draws into it.
|
|
21
|
+
export function drawWgpuFullscreenPass(state, wgpuPipeline, inputs, setUniforms) {
|
|
23
22
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
24
|
-
const pass =
|
|
25
|
-
|
|
23
|
+
const pass = runtime.renderPass;
|
|
24
|
+
const resources = runtime.context.resources;
|
|
25
|
+
if (pass === null || resources === null)
|
|
26
26
|
return;
|
|
27
27
|
pass.setPipeline(wgpuPipeline.pipeline);
|
|
28
28
|
if (setUniforms !== null) {
|
|
29
29
|
const uniformBindGroup = setUniforms(state, wgpuPipeline.uniformBindGroupLayout);
|
|
30
30
|
pass.setBindGroup(0, uniformBindGroup);
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
else {
|
|
33
|
+
pass.setBindGroup(0, wgpuPipeline.emptyUniformBindGroup);
|
|
34
|
+
}
|
|
33
35
|
for (let i = 0; i < inputs.length; i++) {
|
|
34
36
|
const input = inputs[i];
|
|
35
37
|
const layout = wgpuPipeline.textureBindGroupLayouts[i];
|
|
@@ -58,7 +60,7 @@ export function initializeWgpuFullscreenPipeline(out, state, fragmentWgsl, textu
|
|
|
58
60
|
entries: [
|
|
59
61
|
{
|
|
60
62
|
binding: 0,
|
|
61
|
-
visibility:
|
|
63
|
+
visibility: WgpuShaderStage.FRAGMENT,
|
|
62
64
|
buffer: { type: 'uniform' },
|
|
63
65
|
},
|
|
64
66
|
],
|
|
@@ -67,8 +69,8 @@ export function initializeWgpuFullscreenPipeline(out, state, fragmentWgsl, textu
|
|
|
67
69
|
for (let i = 0; i < textureInputCount; i++) {
|
|
68
70
|
textureBindGroupLayouts.push(device.createBindGroupLayout({
|
|
69
71
|
entries: [
|
|
70
|
-
{ binding: 0, visibility:
|
|
71
|
-
{ binding: 1, visibility:
|
|
72
|
+
{ binding: 0, visibility: WgpuShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
|
|
73
|
+
{ binding: 1, visibility: WgpuShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
|
|
72
74
|
],
|
|
73
75
|
}));
|
|
74
76
|
}
|
|
@@ -86,11 +88,22 @@ export function initializeWgpuFullscreenPipeline(out, state, fragmentWgsl, textu
|
|
|
86
88
|
targets: [{ format }],
|
|
87
89
|
},
|
|
88
90
|
primitive: { topology: 'triangle-list' },
|
|
91
|
+
depthStencil: {
|
|
92
|
+
format: 'depth24plus-stencil8',
|
|
93
|
+
depthWriteEnabled: false,
|
|
94
|
+
depthCompare: 'always',
|
|
95
|
+
stencilWriteMask: 0,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
const emptyUniformBindGroup = device.createBindGroup({
|
|
99
|
+
layout: uniformBindGroupLayout,
|
|
100
|
+
entries: [{ binding: 0, resource: { buffer: device.createBuffer({ size: 16, usage: WgpuBufferUsage.UNIFORM }) } }],
|
|
89
101
|
});
|
|
90
102
|
out.pipeline = pipeline;
|
|
91
103
|
out.pipelineLayout = pipelineLayout;
|
|
92
104
|
out.uniformBindGroupLayout = uniformBindGroupLayout;
|
|
93
105
|
out.textureBindGroupLayouts = textureBindGroupLayouts;
|
|
106
|
+
out.emptyUniformBindGroup = emptyUniformBindGroup;
|
|
94
107
|
}
|
|
95
108
|
// The substrate-level WebGPU fullscreen-pass primitive. Filter and effect leaf packages draw
|
|
96
109
|
// through this; it is not filter-specific.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuFullscreenPass.js","sourceRoot":"","sources":["../src/wgpuFullscreenPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"wgpuFullscreenPass.js","sourceRoot":"","sources":["../src/wgpuFullscreenPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAW3D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,UAAU,4BAA4B,CAC1C,KAAsB,EACtB,YAAoB,EACpB,iBAAiB,GAAG,CAAC,EACrB,MAAM,GAAsB,KAAK,CAAC,MAAM;IAExC,MAAM,GAAG,GAAG,cAAc,EAA0B,CAAC;IACrD,gCAAgC,CAAC,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;IACtF,OAAO,GAAG,CAAC;AACb,CAAC;AAED,6FAA6F;AAC7F,iGAAiG;AACjG,wFAAwF;AACxF,MAAM,UAAU,6BAA6B,CAAC,MAAuB,EAAE,SAAiC;IACtG,2FAA2F;IAC3F,4CAA4C;AAC9C,CAAC;AAED,uFAAuF;AACvF,6FAA6F;AAC7F,gDAAgD;AAChD,EAAE;AACF,mGAAmG;AACnG,MAAM,UAAU,sBAAsB,CACpC,KAAsB,EACtB,YAA8C,EAC9C,MAAwD,EACxD,WAA4G;IAE5G,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC;IAChC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IAC5C,IAAI,IAAI,KAAK,IAAI,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO;IAChD,IAAI,CAAC,W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|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare
|
|
5
|
-
export declare function installWgpuHostBackend(backend: WgpuHostBackend): void;
|
|
6
|
-
export declare function resetWgpuHostBackendForTest(): void;
|
|
7
|
-
export declare function setWgpuHostBackend(backend: WgpuHostBackend | null): void;
|
|
1
|
+
import type { Surface } from '@flighthq/surface/contract';
|
|
2
|
+
import type { HostWgpuCapability } from './contract.render-wgpu-types.ts';
|
|
3
|
+
export declare function createTestWgpuSurface(canvas: HTMLCanvasElement): Surface;
|
|
4
|
+
export declare const testWgpuHost: HostWgpuCapability;
|
|
8
5
|
//# sourceMappingURL=wgpuHost.d.ts.map
|
package/dist/wgpuHost.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuHost.d.ts","sourceRoot":"","sources":["../src/wgpuHost.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wgpuHost.d.ts","sourceRoot":"","sources":["../src/wgpuHost.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuB,OAAO,EAAkB,MAAM,4BAA4B,CAAC;AAE/F,OAAO,KAAK,EACV,kBAAkB,EAOnB,MAAM,iCAAiC,CAAC;AAKzC,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAMxE;AAED,eAAO,MAAM,YAAY,EAAE,kBAA6C,CAAC"}
|
package/dist/wgpuHost.js
CHANGED
|
@@ -1,75 +1,89 @@
|
|
|
1
|
-
import { allocateEntity,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { allocateEntity, createEntityRuntime } from '@flighthq/entity/contract';
|
|
2
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
3
|
+
import { WgpuTextureUsage } from './contract.render-wgpu-types.js';
|
|
4
|
+
// Builds a Surface around an existing canvas, the way a host's create lane would. Reads the runtime slot
|
|
5
|
+
// directly rather than through @flighthq/surface so this test double adds no package dependency.
|
|
6
|
+
export function createTestWgpuSurface(canvas) {
|
|
7
|
+
const surface = allocateEntity();
|
|
8
|
+
const runtime = createEntityRuntime();
|
|
9
|
+
runtime.handle = canvas;
|
|
10
|
+
surface[EntityRuntimeKey] = runtime;
|
|
11
|
+
return surface;
|
|
8
12
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
descriptor
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
13
|
+
export const testWgpuHost = initializeTestWgpuHost();
|
|
14
|
+
function initializeTestWgpuHost() {
|
|
15
|
+
return {
|
|
16
|
+
create: (_window, width, height) => {
|
|
17
|
+
const canvas = document.createElement('canvas');
|
|
18
|
+
canvas.width = width;
|
|
19
|
+
canvas.height = height;
|
|
20
|
+
return canvas;
|
|
21
|
+
},
|
|
22
|
+
acquire: async (surface, options) => {
|
|
23
|
+
const canvas = testCanvas(surface);
|
|
24
|
+
if (canvas === null)
|
|
25
|
+
throw new Error('Test surface is not backed by a canvas.');
|
|
26
|
+
const gpu = getWebWgpu();
|
|
27
|
+
if (gpu === null)
|
|
28
|
+
throw new Error('WebGPU is not supported in this browser.');
|
|
29
|
+
const adapter = await gpu.requestAdapter(options.powerPreference !== undefined ? { powerPreference: options.powerPreference } : undefined);
|
|
30
|
+
if (adapter === null)
|
|
31
|
+
throw new Error('Failed to get WebGPU adapter.');
|
|
32
|
+
const requiredLimits = {};
|
|
33
|
+
if (adapter.limits.maxBindGroups >= 5)
|
|
34
|
+
requiredLimits.maxBindGroups = 5;
|
|
35
|
+
const requiredFeatures = ['texture-compression-bc', 'texture-compression-etc2', 'texture-compression-astc'].filter((feature) => adapter.features.has(feature));
|
|
36
|
+
const descriptor = {};
|
|
37
|
+
if (Object.keys(requiredLimits).length > 0)
|
|
38
|
+
descriptor.requiredLimits = requiredLimits;
|
|
39
|
+
if (requiredFeatures.length > 0)
|
|
40
|
+
descriptor.requiredFeatures = requiredFeatures;
|
|
41
|
+
const device = await adapter.requestDevice(descriptor);
|
|
42
|
+
try {
|
|
43
|
+
const format = options.format ?? gpu.getPreferredCanvasFormat();
|
|
44
|
+
const context = canvas.getContext('webgpu');
|
|
45
|
+
if (context === null)
|
|
46
|
+
throw new Error('Failed to get WebGPU canvas context.');
|
|
47
|
+
const acquisition = allocateEntity();
|
|
48
|
+
acquisition.context = context;
|
|
49
|
+
acquisition.device = device;
|
|
50
|
+
acquisition.format = format;
|
|
51
|
+
acquisition.ownership = 'flight';
|
|
52
|
+
acquisition.surface = canvas;
|
|
53
|
+
return acquisition;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
device.destroy();
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
attachSurface: (surface, attachment) => {
|
|
61
|
+
const canvas = testCanvas(surface);
|
|
62
|
+
if (canvas === null)
|
|
63
|
+
return null;
|
|
36
64
|
const context = canvas.getContext('webgpu');
|
|
37
65
|
if (context === null)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
out.release = (acquisition) => {
|
|
56
|
-
acquisition.context.unconfigure();
|
|
57
|
-
acquisition.device.destroy();
|
|
66
|
+
return null;
|
|
67
|
+
context.configure({
|
|
68
|
+
device: attachment.device,
|
|
69
|
+
format: attachment.format,
|
|
70
|
+
alphaMode: attachment.alphaMode,
|
|
71
|
+
usage: WgpuTextureUsage.RENDER_ATTACHMENT | WgpuTextureUsage.COPY_SRC,
|
|
72
|
+
});
|
|
73
|
+
return { context, surface: canvas };
|
|
74
|
+
},
|
|
75
|
+
isSupported: () => {
|
|
76
|
+
return getWebWgpu() !== null;
|
|
77
|
+
},
|
|
78
|
+
release: (acquisition) => {
|
|
79
|
+
acquisition.context.unconfigure();
|
|
80
|
+
acquisition.device.destroy();
|
|
81
|
+
},
|
|
58
82
|
};
|
|
59
83
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
_host = backend;
|
|
64
|
-
}
|
|
65
|
-
export function resetWgpuHostBackendForTest() {
|
|
66
|
-
_custom = null;
|
|
67
|
-
_host = null;
|
|
68
|
-
}
|
|
69
|
-
// Installs a process-wide custom backend. Clearing it reveals the first installed host, or the
|
|
70
|
-
// built-in explicit web adapter when no host has been installed.
|
|
71
|
-
export function setWgpuHostBackend(backend) {
|
|
72
|
-
_custom = backend;
|
|
84
|
+
function testCanvas(surface) {
|
|
85
|
+
const handle = surface[EntityRuntimeKey].handle;
|
|
86
|
+
return handle instanceof HTMLCanvasElement ? handle : null;
|
|
73
87
|
}
|
|
74
88
|
function getWebWgpu() {
|
|
75
89
|
if (typeof navigator === 'undefined')
|
|
@@ -81,7 +95,4 @@ function getWebWgpu() {
|
|
|
81
95
|
return null;
|
|
82
96
|
}
|
|
83
97
|
}
|
|
84
|
-
const _web = createWebWgpuHostBackend();
|
|
85
|
-
let _custom = null;
|
|
86
|
-
let _host = null;
|
|
87
98
|
//# sourceMappingURL=wgpuHost.js.map
|