@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
package/dist/wgpuScissor.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { WgpuRenderState, WgpuScissorRect } from '
|
|
2
|
-
export declare function applyWgpuScissorRect(state: WgpuRenderState, pass:
|
|
1
|
+
import type { WgpuRenderPassEncoder, WgpuRenderState, WgpuScissorRect } from './contract.render-wgpu-types.ts';
|
|
2
|
+
export declare function applyWgpuScissorRect(state: WgpuRenderState, pass: WgpuRenderPassEncoder): void;
|
|
3
3
|
export declare function popWgpuScissorRect(state: WgpuRenderState): void;
|
|
4
4
|
export declare function pushWgpuScissorRect(state: WgpuRenderState, rect: Readonly<WgpuScissorRect>): void;
|
|
5
|
-
export declare function setWgpuRenderPassScissorRect(state:
|
|
5
|
+
export declare function setWgpuRenderPassScissorRect(state: WgpuRenderState, pass: WgpuRenderPassEncoder, x: number, y: number, width: number, height: number): void;
|
|
6
6
|
//# sourceMappingURL=wgpuScissor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuScissor.d.ts","sourceRoot":"","sources":["../src/wgpuScissor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"wgpuScissor.d.ts","sourceRoot":"","sources":["../src/wgpuScissor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAO/G,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAW9F;AAKD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAI/D;AAMD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,IAAI,CAMjG;AAMD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,qBAAqB,EAC3B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,IAAI,CAIN"}
|
package/dist/wgpuScissor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getWgpuRenderStateRuntime } from './wgpuRenderState.js';
|
|
2
|
+
import { getWgpuRenderTargetSupersampleScale } from './wgpuRenderTarget.js';
|
|
3
3
|
// Applies the current scissor rectangle to the active render pass. No-op when there is no active
|
|
4
4
|
// scissor or no open render pass. Call after each draw call or once per pass when the active
|
|
5
5
|
// scissor changes.
|
|
@@ -35,10 +35,13 @@ export function pushWgpuScissorRect(state, rect) {
|
|
|
35
35
|
}
|
|
36
36
|
runtime.currentScissorRect = { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
|
|
37
37
|
}
|
|
38
|
-
// Converts a logical
|
|
39
|
-
//
|
|
38
|
+
// Converts a logical scissor rect to the target's physical extent. Logical is the space every 2D
|
|
39
|
+
// coordinate is in — the pass viewport, the projection, and these rects — so a supersampled target
|
|
40
|
+
// (a screen with antialias, or an effect target at sampleCount 4) scales them by the same factor its
|
|
41
|
+
// storage was grown by, and a target with no supersample scales by 1.
|
|
40
42
|
export function setWgpuRenderPassScissorRect(state, pass, x, y, width, height) {
|
|
41
|
-
const
|
|
43
|
+
const target = getWgpuRenderStateRuntime(state).currentRenderTarget;
|
|
44
|
+
const scale = target === null ? 1 : getWgpuRenderTargetSupersampleScale(target);
|
|
42
45
|
pass.setScissorRect(x * scale, y * scale, width * scale, height * scale);
|
|
43
46
|
}
|
|
44
47
|
//# sourceMappingURL=wgpuScissor.js.map
|
package/dist/wgpuScissor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuScissor.js","sourceRoot":"","sources":["../src/wgpuScissor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wgpuScissor.js","sourceRoot":"","sources":["../src/wgpuScissor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAE5E,iGAAiG;AACjG,6FAA6F;AAC7F,mBAAmB;AACnB,MAAM,UAAU,oBAAoB,CAAC,KAAsB,EAAE,IAA2B;IACtF,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC;IACxC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO;IAC1B,kGAAkG;IAClG,yEAAyE;IACzE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,4BAA4B,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;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KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuScreenAntialias.d.ts","sourceRoot":"","sources":["../src/wgpuScreenAntialias.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,sBAAsB,EAEvB,MAAM,iCAAiC,CAAC;AAazC,wBAAgB,qCAAqC,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAO1F"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { WgpuShaderStage, WgpuTextureUsage } from './contract.render-wgpu-types.js';
|
|
2
|
+
import { getWgpuRenderStateDeviceResources, getWgpuRenderStateRuntime } from './wgpuRenderState.js';
|
|
3
|
+
import { syncWgpuScreenRenderTargetExtent } from './wgpuScreenRenderTarget.js';
|
|
4
|
+
// Turns on 2x-per-axis supersampling for a screen target: the frame draws into a 2x texture and one
|
|
5
|
+
// fullscreen linear-sampling pass resolves it into the swap chain immediately before submit. Each
|
|
6
|
+
// destination pixel center averages the corresponding 2x2 source texels, so this is a real resolve and
|
|
7
|
+
// not a post-hoc image filter, and every scene pipeline stays single-sampled — the seam is the surface,
|
|
8
|
+
// not the pipeline.
|
|
9
|
+
//
|
|
10
|
+
// Separately importable on purpose: a frame loop that never calls this pulls in neither the resolve
|
|
11
|
+
// pipeline nor its shader, which is most of what a screen target would otherwise cost.
|
|
12
|
+
export function enableWgpuScreenRenderTargetAntialias(target) {
|
|
13
|
+
target.antialias = true;
|
|
14
|
+
target.acquireAntialiasView = acquireWgpuScreenRenderTargetAntialiasView;
|
|
15
|
+
target.encodeAntialiasResolve = encodeWgpuScreenRenderTargetResolve;
|
|
16
|
+
// The extent is physical storage, and the factor it is measured in just changed: re-sync now rather
|
|
17
|
+
// than leaving width/height a frame behind the flag that scales them.
|
|
18
|
+
syncWgpuScreenRenderTargetExtent(target);
|
|
19
|
+
}
|
|
20
|
+
function acquireWgpuScreenRenderTargetAntialiasView(state, target) {
|
|
21
|
+
const width = target.width;
|
|
22
|
+
const height = target.height;
|
|
23
|
+
const maxDimension = target.device.limits.maxTextureDimension2D;
|
|
24
|
+
if (width > maxDimension || height > maxDimension) {
|
|
25
|
+
throw new Error(`enableWgpuScreenRenderTargetAntialias requires a ${width}x${height} supersample surface, exceeding maxTextureDimension2D ${maxDimension}.`);
|
|
26
|
+
}
|
|
27
|
+
const existing = target.antialiasTexture;
|
|
28
|
+
if (existing !== null && existing.width === width && existing.height === height)
|
|
29
|
+
return target.antialiasView;
|
|
30
|
+
existing?.destroy();
|
|
31
|
+
const texture = target.device.createTexture({
|
|
32
|
+
size: [width, height, 1],
|
|
33
|
+
format: target.format,
|
|
34
|
+
usage: WgpuTextureUsage.RENDER_ATTACHMENT | WgpuTextureUsage.TEXTURE_BINDING,
|
|
35
|
+
});
|
|
36
|
+
target.antialiasTexture = texture;
|
|
37
|
+
target.antialiasView = texture.createView();
|
|
38
|
+
target.antialiasResolveBindGroup = target.device.createBindGroup({
|
|
39
|
+
layout: ensureWgpuScreenAntialiasPipeline(state, target),
|
|
40
|
+
entries: [
|
|
41
|
+
{ binding: 0, resource: target.antialiasView },
|
|
42
|
+
{ binding: 1, resource: getWgpuRenderStateDeviceResources(state).linearSampler },
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
return target.antialiasView;
|
|
46
|
+
}
|
|
47
|
+
function encodeWgpuScreenRenderTargetResolve(state, target, encoder) {
|
|
48
|
+
const presentationView = target.presentationView;
|
|
49
|
+
const bindGroup = target.antialiasResolveBindGroup;
|
|
50
|
+
const pipeline = getWgpuRenderStateRuntime(state).surfaceAntialiasResolvePipeline;
|
|
51
|
+
if (presentationView === null || pipeline === null || bindGroup === null)
|
|
52
|
+
return;
|
|
53
|
+
const pass = encoder.beginRenderPass({
|
|
54
|
+
colorAttachments: [
|
|
55
|
+
{
|
|
56
|
+
view: presentationView,
|
|
57
|
+
loadOp: 'clear',
|
|
58
|
+
storeOp: 'store',
|
|
59
|
+
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
pass.setPipeline(pipeline);
|
|
64
|
+
pass.setBindGroup(0, bindGroup);
|
|
65
|
+
pass.draw(3);
|
|
66
|
+
pass.end();
|
|
67
|
+
}
|
|
68
|
+
// The resolve pipeline is device-tier: every screen target on one device compiles it once and shares it.
|
|
69
|
+
// Returns the bind-group layout the caller's per-target bind group is built against.
|
|
70
|
+
function ensureWgpuScreenAntialiasPipeline(state, target) {
|
|
71
|
+
const runtime = getWgpuRenderStateRuntime(state);
|
|
72
|
+
const existing = runtime.surfaceAntialiasResolveBindGroupLayout;
|
|
73
|
+
if (existing !== null && runtime.surfaceAntialiasResolvePipeline !== null)
|
|
74
|
+
return existing;
|
|
75
|
+
const bindGroupLayout = target.device.createBindGroupLayout({
|
|
76
|
+
entries: [
|
|
77
|
+
{ binding: 0, visibility: WgpuShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
|
|
78
|
+
{ binding: 1, visibility: WgpuShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
const layout = target.device.createPipelineLayout({ bindGroupLayouts: [bindGroupLayout] });
|
|
82
|
+
const module = target.device.createShaderModule({ code: SCREEN_ANTIALIAS_WGSL });
|
|
83
|
+
runtime.surfaceAntialiasResolveBindGroupLayout = bindGroupLayout;
|
|
84
|
+
runtime.surfaceAntialiasResolvePipeline = target.device.createRenderPipeline({
|
|
85
|
+
layout,
|
|
86
|
+
vertex: { module, entryPoint: 'vs_main' },
|
|
87
|
+
fragment: { module, entryPoint: 'fs_main', targets: [{ format: target.format }] },
|
|
88
|
+
primitive: { topology: 'triangle-list' },
|
|
89
|
+
});
|
|
90
|
+
return bindGroupLayout;
|
|
91
|
+
}
|
|
92
|
+
const SCREEN_ANTIALIAS_WGSL = /* wgsl */ `
|
|
93
|
+
struct VertexOutput {
|
|
94
|
+
@builtin(position) position: vec4f,
|
|
95
|
+
@location(0) uv: vec2f,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
@vertex
|
|
99
|
+
fn vs_main(@builtin(vertex_index) index: u32) -> VertexOutput {
|
|
100
|
+
let positions = array<vec2f, 3>(
|
|
101
|
+
vec2f(-1.0, -1.0),
|
|
102
|
+
vec2f(3.0, -1.0),
|
|
103
|
+
vec2f(-1.0, 3.0),
|
|
104
|
+
);
|
|
105
|
+
let position = positions[index];
|
|
106
|
+
var output: VertexOutput;
|
|
107
|
+
output.position = vec4f(position, 0.0, 1.0);
|
|
108
|
+
output.uv = position * vec2f(0.5, -0.5) + vec2f(0.5);
|
|
109
|
+
return output;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@group(0) @binding(0) var source_texture: texture_2d<f32>;
|
|
113
|
+
@group(0) @binding(1) var source_sampler: sampler;
|
|
114
|
+
|
|
115
|
+
@fragment
|
|
116
|
+
fn fs_main(input: VertexOutput) -> @location(0) vec4f {
|
|
117
|
+
return textureSample(source_texture, source_sampler, input.uv);
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
//# sourceMappingURL=wgpuScreenAntialias.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuScreenAntialias.js","sourceRoot":"","sources":["../src/wgpuScreenAntialias.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,iCAAiC,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAE/E,oGAAoG;AACpG,kGAAkG;AAClG,uGAAuG;AACvG,wGAAwG;AACxG,oBAAoB;AACpB,EAAE;AACF,oGAAoG;AACpG,uFAAuF;AACvF,MAAM,UAAU,qCAAqC,CAAC,MAA8B;IAClF,MAAM,CAAC,SAAS,GAAG,IA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;;;;;;;;;;;;;;CA2BxC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Bitmap } from '@flighthq/bitmap/contract';
|
|
2
|
+
import type { WgpuCommandEncoder, WgpuScreenRenderTarget } from './contract.render-wgpu-types.ts';
|
|
3
|
+
export declare function createBitmapFromWgpuScreenRenderTarget(target: Readonly<WgpuScreenRenderTarget>, timeoutMs?: number): Promise<Bitmap>;
|
|
4
|
+
export declare function enableWgpuScreenRenderTargetCapture(target: WgpuScreenRenderTarget): void;
|
|
5
|
+
export declare function encodeWgpuScreenRenderTargetCapture(target: WgpuScreenRenderTarget, encoder: WgpuCommandEncoder): void;
|
|
6
|
+
//# sourceMappingURL=wgpuScreenCapture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuScreenCapture.d.ts","sourceRoot":"","sources":["../src/wgpuScreenCapture.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,KAAK,EAEV,kBAAkB,EAClB,sBAAsB,EAEvB,MAAM,iCAAiC,CAAC;AAczC,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,QAAQ,CAAC,sBAAsB,CAAC,EACxC,SAAS,SAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,CAyCjB;AAMD,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAIxF;AAwBD,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAgCrH"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createBitmap } from '@flighthq/bitmap/contract';
|
|
2
|
+
import { WgpuBufferUsage, WgpuMapMode, WgpuTextureUsage } from './contract.render-wgpu-types.js';
|
|
3
|
+
// Opt-in capture of a screen target's frame to a CPU Bitmap. Two environment facts drive the design:
|
|
4
|
+
// (1) headless/software adapters never present the swap chain, and its texture reads back as zeros, so
|
|
5
|
+
// the frame is redirected into an offscreen COPY_SRC texture the screen target owns; (2) GPU work queued
|
|
6
|
+
// in a later task than the frame is dropped on these adapters, so the frame's own submit copies that
|
|
7
|
+
// texture into the retained capture buffer, and the readback below only maps the buffer.
|
|
8
|
+
//
|
|
9
|
+
// One buffer serves both sides, so they take turns: the writer skips its copy while the reader holds a
|
|
10
|
+
// map (or has one in flight), and resumes on the next frame. Without that turn-taking a continuously
|
|
11
|
+
// animating scene re-enqueues a copy every frame into the buffer a readback is waiting on — which the
|
|
12
|
+
// queue may not touch while it is mapped, and which pushes the pending map behind ever more GPU work.
|
|
13
|
+
export async function createBitmapFromWgpuScreenRenderTarget(target, timeoutMs = DEFAULT_MAP_TIMEOUT_MS) {
|
|
14
|
+
const buffer = target.captureBuffer;
|
|
15
|
+
if (buffer === null) {
|
|
16
|
+
throw new Error('createBitmapFromWgpuScreenRenderTarget requires enableWgpuScreenRenderTargetCapture(target) before rendering, then a submitted frame.');
|
|
17
|
+
}
|
|
18
|
+
const width = target.captureWidth;
|
|
19
|
+
const height = target.captureHeight;
|
|
20
|
+
const bytesPerRow = target.captureBytesPerRow;
|
|
21
|
+
await mapWgpuCaptureBuffer(buffer, timeoutMs);
|
|
22
|
+
const mapped = new Uint8Array(buffer.getMappedRange());
|
|
23
|
+
const bitmap = createBitmap(width, height);
|
|
24
|
+
const out = bitmap.data;
|
|
25
|
+
// The preferred canvas format is BGRA on most platforms and RGBA on software adapters; normalize to
|
|
26
|
+
// the Bitmap's RGBA byte order so coverage/fingerprint and saved pixels read correctly either way.
|
|
27
|
+
// Pixels are left premultiplied (the texture's stored form): functional content renders over an opaque
|
|
28
|
+
// background, so alpha is 255 and premultiplied == straight; do NOT un-premultiply here — dividing RGB
|
|
29
|
+
// by an 8-bit alpha amplifies quantization and clamps, blowing out exactly the semi-transparent pixels
|
|
30
|
+
// a colour comparison cares about. If straight-alpha output is ever needed, convert at the consumer in
|
|
31
|
+
// higher precision, or compare in premultiplied space on both sides.
|
|
32
|
+
const swizzleBGRA = target.format === 'bgra8unorm' || target.format === 'bgra8unorm-srgb';
|
|
33
|
+
for (let y = 0; y < height; y++) {
|
|
34
|
+
const srcRow = y * bytesPerRow;
|
|
35
|
+
const dstRow = y * width * 4;
|
|
36
|
+
for (let x = 0; x < width; x++) {
|
|
37
|
+
const s = srcRow + x * 4;
|
|
38
|
+
const d = dstRow + x * 4;
|
|
39
|
+
out[d] = swizzleBGRA ? mapped[s + 2] : mapped[s];
|
|
40
|
+
out[d + 1] = mapped[s + 1];
|
|
41
|
+
out[d + 2] = swizzleBGRA ? mapped[s] : mapped[s + 2];
|
|
42
|
+
out[d + 3] = mapped[s + 3];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Unmap (not destroy) so the next frame's submit can copy into the retained buffer again.
|
|
46
|
+
buffer.unmap();
|
|
47
|
+
return bitmap;
|
|
48
|
+
}
|
|
49
|
+
// Enables opt-in capture on a screen target so createBitmapFromWgpuScreenRenderTarget can read it back.
|
|
50
|
+
// The frame is then drawn into an offscreen texture instead of the swap chain (the only reliably readable
|
|
51
|
+
// path on headless/software adapters); the canvas is not presented while capture is on. Leave it off for
|
|
52
|
+
// normal on-screen rendering. The capture texture and buffer are allocated lazily.
|
|
53
|
+
export function enableWgpuScreenRenderTargetCapture(target) {
|
|
54
|
+
target.captureEnabled = true;
|
|
55
|
+
target.acquireCaptureTexture = acquireWgpuScreenRenderTargetCaptureTexture;
|
|
56
|
+
target.encodeCapture = encodeWgpuScreenRenderTargetCapture;
|
|
57
|
+
}
|
|
58
|
+
// The offscreen texture a captured frame renders into, sized to the surface's logical extent (a
|
|
59
|
+
// supersampled frame resolves down into it). Installed as the target's capture slot by the enable above.
|
|
60
|
+
function acquireWgpuScreenRenderTargetCaptureTexture(target) {
|
|
61
|
+
const scale = target.antialias ? 2 : 1;
|
|
62
|
+
const width = Math.max(1, Math.floor(target.width / scale));
|
|
63
|
+
const height = Math.max(1, Math.floor(target.height / scale));
|
|
64
|
+
const existing = target.captureTexture;
|
|
65
|
+
if (existing !== null && existing.width === width && existing.height === height)
|
|
66
|
+
return existing;
|
|
67
|
+
existing?.destroy();
|
|
68
|
+
const texture = target.device.createTexture({
|
|
69
|
+
size: [width, height, 1],
|
|
70
|
+
format: target.format,
|
|
71
|
+
usage: WgpuTextureUsage.RENDER_ATTACHMENT | WgpuTextureUsage.TEXTURE_BINDING | WgpuTextureUsage.COPY_SRC,
|
|
72
|
+
});
|
|
73
|
+
target.captureTexture = texture;
|
|
74
|
+
return texture;
|
|
75
|
+
}
|
|
76
|
+
// Encodes the capture-texture → capture-buffer copy into the frame's command encoder, sizing and
|
|
77
|
+
// reallocating the retained buffer to the surface on demand. No-op unless capture is enabled. Internal:
|
|
78
|
+
// called by submitWgpuFrame so the copy is queued in the render frame, not a later (dropped) task.
|
|
79
|
+
export function encodeWgpuScreenRenderTargetCapture(target, encoder) {
|
|
80
|
+
const texture = target.captureTexture;
|
|
81
|
+
if (!target.captureEnabled || texture === null)
|
|
82
|
+
return;
|
|
83
|
+
// The reader owns the buffer while it holds a map. One retained buffer serves both sides, and the
|
|
84
|
+
// queue may not touch a buffer that is mapped or has a map in flight — so a frame encoded during a
|
|
85
|
+
// readback both invalidates the copy and stacks more GPU work in front of the map it is waiting on.
|
|
86
|
+
// Skipping the frame is the handshake: the reader is already taking a snapshot, and the next frame
|
|
87
|
+
// resumes copying once it lets go.
|
|
88
|
+
//
|
|
89
|
+
// Deliberately written as "is it busy" rather than "is it not unmapped": an implementation without
|
|
90
|
+
// `mapState` reports undefined, and the inverted test would then skip every copy for the whole run
|
|
91
|
+
// and capture nothing. Unknown state falls through to the copy, which is the pre-existing behaviour.
|
|
92
|
+
const mapState = target.captureBuffer?.mapState;
|
|
93
|
+
if (mapState === 'pending' || mapState === 'mapped')
|
|
94
|
+
return;
|
|
95
|
+
const width = texture.width;
|
|
96
|
+
const height = texture.height;
|
|
97
|
+
// Wgpu requires copyTextureToBuffer rows to be 256-byte aligned; the buffer is padded per row.
|
|
98
|
+
const bytesPerRow = Math.ceil((width * 4) / 256) * 256;
|
|
99
|
+
if (target.captureBuffer === null || target.captureWidth !== width || target.captureHeight !== height) {
|
|
100
|
+
target.captureBuffer?.destroy();
|
|
101
|
+
target.captureBuffer = target.device.createBuffer({
|
|
102
|
+
size: bytesPerRow * height,
|
|
103
|
+
usage: WgpuBufferUsage.COPY_DST | WgpuBufferUsage.MAP_READ,
|
|
104
|
+
});
|
|
105
|
+
target.captureBytesPerRow = bytesPerRow;
|
|
106
|
+
target.captureWidth = width;
|
|
107
|
+
target.captureHeight = height;
|
|
108
|
+
}
|
|
109
|
+
encoder.copyTextureToBuffer({ texture }, { buffer: target.captureBuffer, bytesPerRow }, [width, height, 1]);
|
|
110
|
+
}
|
|
111
|
+
// Maps the retained capture buffer, giving up by name after `timeoutMs` (0 waits indefinitely).
|
|
112
|
+
// `mapAsync` carries no timeout and no reject path of its own: on the contended software adapters this
|
|
113
|
+
// capture path exists for, the promise can simply never settle, and an unbounded await is indistinguishable
|
|
114
|
+
// from a caller that stopped running. A late resolution after the deadline leaves the buffer mapped, which
|
|
115
|
+
// is why the timeout is a hard end for this capture and not something to retry against the same buffer.
|
|
116
|
+
async function mapWgpuCaptureBuffer(buffer, timeoutMs) {
|
|
117
|
+
const mapping = buffer.mapAsync(WgpuMapMode.READ);
|
|
118
|
+
if (timeoutMs <= 0)
|
|
119
|
+
return mapping;
|
|
120
|
+
// The race abandons `mapping` on timeout; adopt its eventual rejection here so it is never unhandled.
|
|
121
|
+
mapping.catch(() => { });
|
|
122
|
+
let timer;
|
|
123
|
+
const expiry = new Promise((_resolve, reject) => {
|
|
124
|
+
timer = setTimeout(() => {
|
|
125
|
+
reject(new Error(`createBitmapFromWgpuScreenRenderTarget: capture buffer did not map within ${timeoutMs}ms`));
|
|
126
|
+
}, timeoutMs);
|
|
127
|
+
});
|
|
128
|
+
try {
|
|
129
|
+
await Promise.race([mapping, expiry]);
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Generous by design: this bounds a driver that has stopped answering, not a slow one. Callers working
|
|
136
|
+
// inside a tighter budget (the capture harness) pass their own.
|
|
137
|
+
const DEFAULT_MAP_TIMEOUT_MS = 10_000;
|
|
138
|
+
//# sourceMappingURL=wgpuScreenCapture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuScreenCapture.js","sourceRoot":"","sources":["../src/wgpuScreenCapture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AASzD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEjG,qGAAqG;AACrG,uGAAuG;AACvG,yGAAyG;AACzG,qGAAqG;AACrG,yFAAyF;AACzF,EAAE;AACF,uGAAuG;AACvG,qGAAqG;AACrG,sGAAsG;AACtG,sGAAsG;AAEtG,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC1D,MAAwC,EACxC,SAAS,GAAG,sBAAsB;IAElC,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;IACpC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,uIAAuI,CACxI,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,CAAC,kBAAkB,CAAC;IAE9C,MAAM,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IAEvD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC3C,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,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,WAAW,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9G,CAAC;AAED,gGAAgG;AAChG,uGAAuG;AACvG,4GAA4G;AAC5G,2GAA2G;AAC3G,wGAAwG;AACxG,KAAK,UAAU,oBAAoB,CAAC,MAAkB,EAAE,SAAiB;IACvE,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IAEnC,sGAAsG;IACtG,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAExB,IAAI,KAAgD,CAAC;IACrD,MAAM,MAAM,GAAG,IAAI,OAAO,CAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;QACrD,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,MAAM,CAAC,IAAI,KAAK,CAAC,6EAA6E,SAAS,IAAI,CAAC,CAAC,CAAC;QAChH,CAAC,EAAE,SAAS,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IACxC,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC;AAED,uGAAuG;AACvG,gEAAgE;AAChE,MAAM,sBAAsB,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EntityConstruction } from '@flighthq/entity/contract';
|
|
2
|
+
import type { Surface } from '@flighthq/surface/contract';
|
|
3
|
+
import type { HostWgpuCapability, WgpuDevice, WgpuRenderState, WgpuRenderTarget, WgpuScreenRenderTarget, WgpuScreenRenderTargetOptions, WgpuTextureView } from './contract.render-wgpu-types.ts';
|
|
4
|
+
export declare function bindWgpuScreenRenderTarget(state: WgpuRenderState, target: WgpuScreenRenderTarget): WgpuTextureView;
|
|
5
|
+
export declare function createWgpuScreenRenderTarget(wgpuHost: Readonly<HostWgpuCapability>, device: WgpuDevice, drawable: Readonly<Surface>, options?: Readonly<WgpuScreenRenderTargetOptions>): WgpuScreenRenderTarget;
|
|
6
|
+
export declare function destroyWgpuScreenRenderTarget(target: WgpuScreenRenderTarget): void;
|
|
7
|
+
export declare function endWgpuScreenRenderTargetFrame(target: WgpuScreenRenderTarget): void;
|
|
8
|
+
export declare function initializeWgpuScreenRenderTarget(out: EntityConstruction<WgpuScreenRenderTarget>, wgpuHost: Readonly<HostWgpuCapability>, device: WgpuDevice, drawable: Readonly<Surface>, options?: Readonly<WgpuScreenRenderTargetOptions>): void;
|
|
9
|
+
export declare function isWgpuScreenRenderTarget(target: Readonly<WgpuRenderTarget>): target is WgpuScreenRenderTarget;
|
|
10
|
+
export declare function syncWgpuScreenRenderTargetExtent(target: WgpuScreenRenderTarget): void;
|
|
11
|
+
//# sourceMappingURL=wgpuScreenRenderTarget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuScreenRenderTarget.d.ts","sourceRoot":"","sources":["../src/wgpuScreenRenderTarget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,6BAA6B,EAE7B,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAOzC,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,sBAAsB,GAAG,eAAe,CAYlH;AAID,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACtC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC3B,OAAO,GAAE,QAAQ,CAAC,6BAA6B,CAAM,GACpD,sBAAsB,CAIxB;AAKD,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAYlF;AAID,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAEnF;AAED,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,EAC/C,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACtC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC3B,OAAO,GAAE,QAAQ,CAAC,6BAA6B,CAAM,GACpD,IAAI,CAwCN;AAKD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,MAAM,IAAI,sBAAsB,CAE7G;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAIrF"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
|
+
import { WgpuTextureUsage } from './contract.render-wgpu-types.js';
|
|
3
|
+
// Acquires the color view a screen pass attaches to, sizing the target's storage to the surface first.
|
|
4
|
+
// The returned view is the supersample texture when antialiasing is enabled and the presentation view
|
|
5
|
+
// otherwise; either way `presentationView` names where the frame ultimately lands, so the submit can
|
|
6
|
+
// resolve and capture it. Internal: called by beginWgpuRenderPass.
|
|
7
|
+
export function bindWgpuScreenRenderTarget(state, target) {
|
|
8
|
+
syncWgpuScreenRenderTargetExtent(target);
|
|
9
|
+
ensureWgpuScreenRenderTargetDepthStencil(target);
|
|
10
|
+
if (target.presentationView === null) {
|
|
11
|
+
// With capture on, render into an offscreen COPY_SRC texture instead of the swap chain: software and
|
|
12
|
+
// headless adapters never present the swap chain and its texture reads back as zeros, so the readable
|
|
13
|
+
// copy must be the render target itself.
|
|
14
|
+
const presentationTexture = target.acquireCaptureTexture?.(target) ?? target.context.getCurrentTexture();
|
|
15
|
+
target.presentationView = presentationTexture.createView();
|
|
16
|
+
}
|
|
17
|
+
return target.acquireAntialiasView?.(state, target) ?? target.presentationView;
|
|
18
|
+
}
|
|
19
|
+
// A screen target's whole point is that it presents; a texture target's is that it can be sampled. Both
|
|
20
|
+
// creations are Entity allocations, so a factory is the only place either capability is decided.
|
|
21
|
+
export function createWgpuScreenRenderTarget(wgpuHost, device, drawable, options = {}) {
|
|
22
|
+
const out = allocateEntity();
|
|
23
|
+
initializeWgpuScreenRenderTarget(out, wgpuHost, device, drawable, options);
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
// Frees the GPU storage this target owns — depth-stencil, supersample, and capture — and unconfigures
|
|
27
|
+
// its canvas context. The target is invalid afterward. The storage is freed here even though the code
|
|
28
|
+
// that filled it lives in the opt-in modules: a target owns its allocations whoever wrote to them.
|
|
29
|
+
export function destroyWgpuScreenRenderTarget(target) {
|
|
30
|
+
target.depthStencilTexture.destroy();
|
|
31
|
+
target.antialiasTexture?.destroy();
|
|
32
|
+
target.antialiasTexture = null;
|
|
33
|
+
target.antialiasView = null;
|
|
34
|
+
target.antialiasResolveBindGroup = null;
|
|
35
|
+
target.captureTexture?.destroy();
|
|
36
|
+
target.captureTexture = null;
|
|
37
|
+
target.captureBuffer?.destroy();
|
|
38
|
+
target.captureBuffer = null;
|
|
39
|
+
target.presentationView = null;
|
|
40
|
+
target.context.unconfigure();
|
|
41
|
+
}
|
|
42
|
+
// Releases the per-frame swap-chain view. The next frame acquires a fresh one, which is the whole reason
|
|
43
|
+
// a screen target is not sampleable: nothing may hold this across frames.
|
|
44
|
+
export function endWgpuScreenRenderTargetFrame(target) {
|
|
45
|
+
target.presentationView = null;
|
|
46
|
+
}
|
|
47
|
+
export function initializeWgpuScreenRenderTarget(out, wgpuHost, device, drawable, options = {}) {
|
|
48
|
+
const format = options.format ?? 'bgra8unorm';
|
|
49
|
+
const result = wgpuHost.attachSurface(drawable, {
|
|
50
|
+
alphaMode: options.alphaMode ?? 'premultiplied',
|
|
51
|
+
device,
|
|
52
|
+
format,
|
|
53
|
+
});
|
|
54
|
+
if (result === null)
|
|
55
|
+
throw new Error('createWgpuScreenRenderTarget: the target cannot present WebGPU.');
|
|
56
|
+
const { context, surface } = result;
|
|
57
|
+
const width = Math.max(1, surface.width);
|
|
58
|
+
const height = Math.max(1, surface.height);
|
|
59
|
+
const depthStencilTexture = createWgpuScreenDepthStencilTexture(device, width, height);
|
|
60
|
+
out.acquireAntialiasView = null;
|
|
61
|
+
out.acquireCaptureTexture = null;
|
|
62
|
+
out.antialias = false;
|
|
63
|
+
out.antialiasResolveBindGroup = null;
|
|
64
|
+
out.antialiasTexture = null;
|
|
65
|
+
out.antialiasView = null;
|
|
66
|
+
out.captureBuffer = null;
|
|
67
|
+
out.captureBytesPerRow = 0;
|
|
68
|
+
out.captureEnabled = false;
|
|
69
|
+
out.captureHeight = 0;
|
|
70
|
+
out.captureTexture = null;
|
|
71
|
+
out.captureWidth = 0;
|
|
72
|
+
out.colorAttachments = 1;
|
|
73
|
+
out.colorSpace = options.colorSpace ?? 'srgb';
|
|
74
|
+
out.context = context;
|
|
75
|
+
out.depthStencilTexture = depthStencilTexture;
|
|
76
|
+
out.depthStencilView = depthStencilTexture.createView();
|
|
77
|
+
out.device = device;
|
|
78
|
+
out.encodeAntialiasResolve = null;
|
|
79
|
+
out.encodeCapture = null;
|
|
80
|
+
out.format = format;
|
|
81
|
+
out.height = height;
|
|
82
|
+
out.presentationView = null;
|
|
83
|
+
out.sampleCount = 1;
|
|
84
|
+
out.surface = surface;
|
|
85
|
+
out.width = width;
|
|
86
|
+
}
|
|
87
|
+
// The base type says which storage a target names through `context`; this is the narrowing that reads it.
|
|
88
|
+
// Sampling, present, and effect-input APIs take WgpuTextureRenderTarget precisely so they never have to
|
|
89
|
+
// ask — the swap chain has no sampleable texture handle to give them.
|
|
90
|
+
export function isWgpuScreenRenderTarget(target) {
|
|
91
|
+
return target.context !== null;
|
|
92
|
+
}
|
|
93
|
+
export function syncWgpuScreenRenderTargetExtent(target) {
|
|
94
|
+
const scale = target.antialias ? WGPU_SCREEN_SUPERSAMPLE_SCALE : 1;
|
|
95
|
+
target.width = Math.max(1, target.surface.width) * scale;
|
|
96
|
+
target.height = Math.max(1, target.surface.height) * scale;
|
|
97
|
+
}
|
|
98
|
+
function createWgpuScreenDepthStencilTexture(device, width, height) {
|
|
99
|
+
return device.createTexture({
|
|
100
|
+
size: [Math.max(1, width), Math.max(1, height), 1],
|
|
101
|
+
format: 'depth24plus-stencil8',
|
|
102
|
+
usage: WgpuTextureUsage.RENDER_ATTACHMENT,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function ensureWgpuScreenRenderTargetDepthStencil(target) {
|
|
106
|
+
const texture = target.depthStencilTexture;
|
|
107
|
+
if (texture.width === target.width && texture.height === target.height)
|
|
108
|
+
return;
|
|
109
|
+
texture.destroy();
|
|
110
|
+
const replacement = createWgpuScreenDepthStencilTexture(target.device, target.width, target.height);
|
|
111
|
+
target.depthStencilTexture = replacement;
|
|
112
|
+
target.depthStencilView = replacement.createView();
|
|
113
|
+
}
|
|
114
|
+
// Brings the target's extent back in line with its surface — the surface is the authority on its own
|
|
115
|
+
// size, and it can be resized between any two frames. Every pass calls this, so a caller never has to
|
|
116
|
+
// announce a resize; enabling supersampling calls it too, because the factor it multiplies by changed.
|
|
117
|
+
// One place decides how much bigger a supersampled surface is than its logical extent.
|
|
118
|
+
// wgpuTextureRenderTarget.ts carries the same number for offscreen storage; they are the same concept
|
|
119
|
+
// applied to two surfaces.
|
|
120
|
+
const WGPU_SCREEN_SUPERSAMPLE_SCALE = 2;
|
|
121
|
+
//# sourceMappingURL=wgpuScreenRenderTar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,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACpG,MAAM,CAAC,mBAAmB,GAAG,WAAW,CAAC;IACzC,MAAM,CAAC,gBAAgB,GAAG,WAAW,CAAC,UAAU,EAAE,CAAC;AACrD,CAAC;AAED,qGAAqG;AACrG,sGAAsG;AACtG,uGAAuG;AACvG,uFAAuF;AACvF,sGAAsG;AACtG,2BAA2B;AAC3B,MAAM,6BAA6B,GAAG,CAAC,CAAC"}
|
package/dist/wgpuShader.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import type { ColorScaleBias
|
|
2
|
-
import {
|
|
1
|
+
import type { ColorScaleBias } from '@flighthq/adjustments/contract';
|
|
2
|
+
import type { EntityConstruction } from '@flighthq/entity/contract';
|
|
3
|
+
import { BlendMode } from '@flighthq/materials/contract';
|
|
4
|
+
import type { RenderProxy } from '@flighthq/render/contract';
|
|
5
|
+
import type { WgpuBindGroupLayout, WgpuBindGroupLayouts, WgpuBlendState, WgpuDevice, WgpuPipelineLayout, WgpuRenderPipeline, WgpuRenderState } from './contract.render-wgpu-types.ts';
|
|
3
6
|
export declare const UNIFORM_BYTE_SIZE = 128;
|
|
4
7
|
type StencilMode = 'normal' | 'masked' | 'maskwrite';
|
|
5
|
-
export declare function createWgpuBindGroupLayouts(device:
|
|
6
|
-
export declare function createWgpuPipelineLayout(device:
|
|
7
|
-
export declare function getActiveWgpuPipeline(state: WgpuRenderState):
|
|
8
|
-
export declare function getWgpuBlendState(blendMode: BlendMode | null):
|
|
9
|
-
export declare function getWgpuPipeline(state: WgpuRenderState, blendMode: BlendMode | null, stencilMode: StencilMode):
|
|
10
|
-
export declare function initializeWgpuBindGroupLayouts(out: EntityConstruction<WgpuBindGroupLayouts>, device:
|
|
8
|
+
export declare function createWgpuBindGroupLayouts(device: WgpuDevice): WgpuBindGroupLayouts;
|
|
9
|
+
export declare function createWgpuPipelineLayout(device: WgpuDevice, uniformBindGroupLayout: WgpuBindGroupLayout, textureBindGroupLayout: WgpuBindGroupLayout): WgpuPipelineLayout;
|
|
10
|
+
export declare function getActiveWgpuPipeline(state: WgpuRenderState): WgpuRenderPipeline;
|
|
11
|
+
export declare function getWgpuBlendState(blendMode: BlendMode | null): WgpuBlendState;
|
|
12
|
+
export declare function getWgpuPipeline(state: WgpuRenderState, blendMode: BlendMode | null, stencilMode: StencilMode): WgpuRenderPipeline;
|
|
13
|
+
export declare function initializeWgpuBindGroupLayouts(out: EntityConstruction<WgpuBindGroupLayouts>, device: WgpuDevice): void;
|
|
11
14
|
export declare function setWgpuMatrixFromTransform(matrixArray: Float32Array, t: {
|
|
12
15
|
a: number;
|
|
13
16
|
b: number;
|
package/dist/wgpuShader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuShader.d.ts","sourceRoot":"","sources":["../src/wgpuShader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wgpuShader.d.ts","sourceRoot":"","sources":["../src/wgpuShader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EAIpB,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EAEhB,MAAM,iCAAiC,CAAC;AAkBzC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAiHrC,KAAK,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAyBrD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,GAAG,oBAAoB,CAInF;AAED,wBAAgB,wBAAwB,CACtC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AAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT,MAAM,CAcR;AAKD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACrF,EACD,cAAc,EAAE,cAAc,GAAG,IAAI,EACrC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,oBAAoB,UAAQ,GAC3B,MAAM,CAsDR"}
|
package/dist/wgpuShader.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { allocateEntity
|
|
2
|
-
import { BlendMode } from '@flighthq/
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
|
+
import { BlendMode } from '@flighthq/materials/contract';
|
|
3
|
+
import { WgpuColorWrite, WgpuShaderStage } from './contract.render-wgpu-types.js';
|
|
4
|
+
import { getWgpuRenderPassViewport } from './wgpuRenderPass.js';
|
|
5
|
+
import { getWgpuRenderStateDeviceResources, getWgpuRenderStateRuntime } from './wgpuRenderState.js';
|
|
5
6
|
// ---- WGSL source ----
|
|
6
7
|
// Uniform buffer layout (per-draw slot in the ring, 256-byte aligned):
|
|
7
8
|
// offset 0–47 : mat3x3f matrix (3 columns × 16 bytes each due to vec3 padding)
|
|
@@ -146,7 +147,7 @@ const BLEND_MODES = {
|
|
|
146
147
|
export function createWgpuBindGroupLayouts(device) {
|
|
147
148
|
const out = allocateEntity();
|
|
148
149
|
initializeWgpuBindGroupLayouts(out, device);
|
|
149
|
-
return
|
|
150
|
+
return out;
|
|
150
151
|
}
|
|
151
152
|
export function createWgpuPipelineLayout(device, uniformBindGroupLayout, textureBindGroupLayout) {
|
|
152
153
|
return device.createPipelineLayout({
|
|
@@ -206,7 +207,7 @@ export function getWgpuPipeline(state, blendMode, stencilMode) {
|
|
|
206
207
|
{
|
|
207
208
|
format,
|
|
208
209
|
blend: isMaskWrite ? undefined : blend,
|
|
209
|
-
writeMask: isMaskWrite ? 0 :
|
|
210
|
+
writeMask: isMaskWrite ? 0 : WgpuColorWrite.ALL,
|
|
210
211
|
},
|
|
211
212
|
],
|
|
212
213
|
},
|
|
@@ -229,15 +230,15 @@ export function initializeWgpuBindGroupLayouts(out, device) {
|
|
|
229
230
|
entries: [
|
|
230
231
|
{
|
|
231
232
|
binding: 0,
|
|
232
|
-
visibility:
|
|
233
|
+
visibility: WgpuShaderStage.VERTEX | WgpuShaderStage.FRAGMENT,
|
|
233
234
|
buffer: { type: 'uniform', hasDynamicOffset: true, minBindingSize: UNIFORM_BYTE_SIZE },
|
|
234
235
|
},
|
|
235
236
|
],
|
|
236
237
|
});
|
|
237
238
|
const textureBindGroupLayout = device.createBindGroupLayout({
|
|
238
239
|
entries: [
|
|
239
|
-
{ binding: 0, visibility:
|
|
240
|
-
{ binding: 1, visibility:
|
|
240
|
+
{ binding: 0, visibility: WgpuShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
|
|
241
|
+
{ binding: 1, visibility: WgpuShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
|
|
241
242
|
],
|
|
242
243
|
});
|
|
243
244
|
out.uniformBindGroupLayout = uniformBindGroupLayout;
|
|
@@ -273,7 +274,7 @@ export function writeWgpuQuadUniforms(state, renderProxy, colorScaleBias, x0, y0
|
|
|
273
274
|
const byteOffset = runtime.uniformOffset;
|
|
274
275
|
const floatBase = byteOffset >> 2; // divide by 4
|
|
275
276
|
const { uniformData, uniformDataU32, matrixArray } = runtime;
|
|
276
|
-
const viewport =
|
|
277
|
+
const viewport = getWgpuRenderPassViewport(state);
|
|
277
278
|
setWgpuMatrixFromTransform(matrixArray, renderProxy.transform2D, viewport);
|
|
278
279
|
// mat3x3 columns with per-column padding (4 floats each = 16 bytes):
|
|
279
280
|
uniformData[floatBase + 0] = matrixArray[0];
|