ris-framework 0.1.0 → 0.2.0-dev.12
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/CHANGELOG.md +42 -1
- package/README.md +27 -4
- package/dist/Framework.d.ts +34 -10
- package/dist/Framework.d.ts.map +1 -1
- package/dist/api/IFramework.d.ts +50 -6
- package/dist/api/IFramework.d.ts.map +1 -1
- package/dist/api/_export.d.ts +3 -1
- package/dist/api/_export.d.ts.map +1 -1
- package/dist/api/camera/CameraFactory.d.ts +3 -2
- package/dist/api/camera/CameraFactory.d.ts.map +1 -1
- package/dist/api/camera/ICamera.d.ts +5 -0
- package/dist/api/camera/ICamera.d.ts.map +1 -1
- package/dist/api/camera/ICameraFactory.d.ts +5 -6
- package/dist/api/camera/ICameraFactory.d.ts.map +1 -1
- package/dist/api/camera/OrthographicCamera.d.ts +7 -0
- package/dist/api/camera/OrthographicCamera.d.ts.map +1 -1
- package/dist/api/camera/PerspectiveCamera.d.ts +30 -6
- package/dist/api/camera/PerspectiveCamera.d.ts.map +1 -1
- package/dist/api/content/ContentManager.d.ts +15 -2
- package/dist/api/content/ContentManager.d.ts.map +1 -1
- package/dist/api/content/IContentManager.d.ts +35 -1
- package/dist/api/content/IContentManager.d.ts.map +1 -1
- package/dist/api/content/ShaderModuleContent.d.ts.map +1 -1
- package/dist/api/data/Color.d.ts +5 -0
- package/dist/api/data/Color.d.ts.map +1 -1
- package/dist/api/geometry/BaseGeometry.d.ts +9 -0
- package/dist/api/geometry/BaseGeometry.d.ts.map +1 -1
- package/dist/api/geometry/GeometryBuilder.d.ts +3 -1
- package/dist/api/geometry/GeometryBuilder.d.ts.map +1 -1
- package/dist/api/geometry/IGeometryBuilder.d.ts +24 -0
- package/dist/api/geometry/IGeometryBuilder.d.ts.map +1 -1
- package/dist/api/geometry/_export-geometry.d.ts +1 -0
- package/dist/api/geometry/_export-geometry.d.ts.map +1 -1
- package/dist/api/input/InputManager.d.ts +4 -0
- package/dist/api/input/InputManager.d.ts.map +1 -1
- package/dist/api/lights/AmbientLight.d.ts +35 -0
- package/dist/api/lights/AmbientLight.d.ts.map +1 -0
- package/dist/api/lights/DirectionalLight.d.ts +40 -0
- package/dist/api/lights/DirectionalLight.d.ts.map +1 -0
- package/dist/api/lights/LightFactory.d.ts +18 -0
- package/dist/api/lights/LightFactory.d.ts.map +1 -0
- package/dist/api/lights/LightId.d.ts +6 -0
- package/dist/api/lights/LightId.d.ts.map +1 -0
- package/dist/api/lights/LightsBuffer.d.ts +77 -0
- package/dist/api/lights/LightsBuffer.d.ts.map +1 -0
- package/dist/api/lights/PointLight.d.ts +59 -0
- package/dist/api/lights/PointLight.d.ts.map +1 -0
- package/dist/api/lights/_export.d.ts +6 -0
- package/dist/api/lights/_export.d.ts.map +1 -0
- package/dist/api/loaders/ObjGeometryMapper.d.ts +19 -0
- package/dist/api/loaders/ObjGeometryMapper.d.ts.map +1 -0
- package/dist/api/loaders/ObjLoader.d.ts +61 -0
- package/dist/api/loaders/ObjLoader.d.ts.map +1 -0
- package/dist/api/loaders/_export.d.ts +2 -0
- package/dist/api/loaders/_export.d.ts.map +1 -1
- package/dist/api/loaders/obj/ObjParser.d.ts +44 -0
- package/dist/api/loaders/obj/ObjParser.d.ts.map +1 -0
- package/dist/api/loaders/obj/ObjTypes.d.ts +119 -0
- package/dist/api/loaders/obj/ObjTypes.d.ts.map +1 -0
- package/dist/api/loaders/obj/index.d.ts +3 -0
- package/dist/api/loaders/obj/index.d.ts.map +1 -0
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts +138 -0
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts.map +1 -0
- package/dist/api/material/ICameraMaterial.d.ts +18 -0
- package/dist/api/material/ICameraMaterial.d.ts.map +1 -0
- package/dist/api/material/ILightsMaterial.d.ts +26 -0
- package/dist/api/material/ILightsMaterial.d.ts.map +1 -0
- package/dist/api/material/IMaterial.d.ts +13 -10
- package/dist/api/material/IMaterial.d.ts.map +1 -1
- package/dist/api/material/IMaterialFactory.d.ts +17 -2
- package/dist/api/material/IMaterialFactory.d.ts.map +1 -1
- package/dist/api/material/InspectTextureMipsMaterial.d.ts +18 -9
- package/dist/api/material/InspectTextureMipsMaterial.d.ts.map +1 -1
- package/dist/api/material/MaterialFactory.d.ts +6 -0
- package/dist/api/material/MaterialFactory.d.ts.map +1 -1
- package/dist/api/material/SpriteMaterial.d.ts +51 -0
- package/dist/api/material/SpriteMaterial.d.ts.map +1 -0
- package/dist/api/material/UnlitMaterial.d.ts +32 -13
- package/dist/api/material/UnlitMaterial.d.ts.map +1 -1
- package/dist/api/material/_export.d.ts +4 -0
- package/dist/api/material/_export.d.ts.map +1 -1
- package/dist/api/meshes/IMesh.d.ts +31 -6
- package/dist/api/meshes/IMesh.d.ts.map +1 -1
- package/dist/api/meshes/IMeshFactory.d.ts +30 -4
- package/dist/api/meshes/IMeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/IRenderableMesh.d.ts +47 -0
- package/dist/api/meshes/IRenderableMesh.d.ts.map +1 -0
- package/dist/api/meshes/Mesh.d.ts +14 -8
- package/dist/api/meshes/Mesh.d.ts.map +1 -1
- package/dist/api/meshes/MeshFactory.d.ts +10 -3
- package/dist/api/meshes/MeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/QuadMesh.d.ts +5 -3
- package/dist/api/meshes/QuadMesh.d.ts.map +1 -1
- package/dist/api/meshes/RenderableMesh.d.ts +95 -0
- package/dist/api/meshes/RenderableMesh.d.ts.map +1 -0
- package/dist/api/meshes/_export.d.ts +2 -0
- package/dist/api/meshes/_export.d.ts.map +1 -1
- package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts +8 -2
- package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts.map +1 -1
- package/dist/api/rendering/IRenderer.d.ts +28 -1
- package/dist/api/rendering/IRenderer.d.ts.map +1 -1
- package/dist/api/rendering/enums.d.ts +7 -0
- package/dist/api/rendering/enums.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.d.ts +56 -0
- package/dist/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.d.ts.map +1 -0
- package/dist/api/rendering/render-pipelines/IRenderPipeline.d.ts +3 -0
- package/dist/api/rendering/render-pipelines/IRenderPipeline.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IRenderPipelineFactory.d.ts +29 -0
- package/dist/api/rendering/render-pipelines/IRenderPipelineFactory.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/_export-render-pipelines.d.ts +1 -0
- package/dist/api/rendering/render-pipelines/_export-render-pipelines.d.ts.map +1 -1
- package/dist/api/rendering/renderer-interface.d.ts +1 -31
- package/dist/api/rendering/renderer-interface.d.ts.map +1 -1
- package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts +2 -6
- package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts.map +1 -1
- package/dist/api/rendering/swapchain/ISwapChain.d.ts +1 -3
- package/dist/api/rendering/swapchain/ISwapChain.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureFormat.d.ts +88 -14
- package/dist/api/rendering/texture/TextureFormat.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureUtilities.d.ts +23 -0
- package/dist/api/rendering/texture/TextureUtilities.d.ts.map +1 -1
- package/dist/api/scene/Scene.d.ts +113 -0
- package/dist/api/scene/Scene.d.ts.map +1 -0
- package/dist/api/scene/SceneMesh.d.ts +27 -0
- package/dist/api/scene/SceneMesh.d.ts.map +1 -0
- package/dist/api/shader/IShaderModuleLoader.d.ts +4 -1
- package/dist/api/shader/IShaderModuleLoader.d.ts.map +1 -1
- package/dist/api/shader/{shader-loader.d.ts → ShaderLoader.d.ts} +1 -1
- package/dist/api/shader/ShaderLoader.d.ts.map +1 -0
- package/dist/api/sprites/SpriteBatchDrawable.d.ts +1 -1
- package/dist/api/sprites/SpriteBatchDrawable.d.ts.map +1 -1
- package/dist/api/sprites/SpriteBatchMesh.d.ts +14 -1
- package/dist/api/sprites/SpriteBatchMesh.d.ts.map +1 -1
- package/dist/api/utilities/AlignUtilities.d.ts.map +1 -1
- package/dist/api/utilities/GeometryUtilities.d.ts.map +1 -1
- package/dist/api/window/WindowManager.d.ts +4 -0
- package/dist/api/window/WindowManager.d.ts.map +1 -1
- package/dist/core/rendering/ARenderer.d.ts +5 -5
- package/dist/core/rendering/ARenderer.d.ts.map +1 -1
- package/dist/core/rendering/vertex-buffer-layout.d.ts +1 -0
- package/dist/core/rendering/vertex-buffer-layout.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9238 -4595
- package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts +4 -0
- package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts.map +1 -1
- package/dist/webgl/WebGlGraphicsDevice.d.ts.map +1 -1
- package/dist/webgl/WebGlRenderer.d.ts +1 -3
- package/dist/webgl/WebGlRenderer.d.ts.map +1 -1
- package/dist/webgl/lights/WebGlAmbientLightFactory.d.ts +17 -0
- package/dist/webgl/lights/WebGlAmbientLightFactory.d.ts.map +1 -0
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts +59 -0
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts.map +1 -0
- package/dist/webgl/render-pipelines/AWebGlRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/AWebGlRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts +5 -0
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlRenderPipelineFactory.d.ts +3 -1
- package/dist/webgl/render-pipelines/WebGlRenderPipelineFactory.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.d.ts +88 -0
- package/dist/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.d.ts.map +1 -0
- package/dist/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/shader/WebGlShaderModule.d.ts +4 -1
- package/dist/webgl/shader/WebGlShaderModule.d.ts.map +1 -1
- package/dist/webgl/shader/WebGlShaderModuleLoader.d.ts +16 -5
- package/dist/webgl/shader/WebGlShaderModuleLoader.d.ts.map +1 -1
- package/dist/webgl/swap-chain/WebGlSwapChain.d.ts +3 -2
- package/dist/webgl/swap-chain/WebGlSwapChain.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTexture2D.d.ts +8 -1
- package/dist/webgl/texture/WebGlTexture2D.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTextureFactory.d.ts +7 -0
- package/dist/webgl/texture/WebGlTextureFactory.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlConstants.d.ts +91 -0
- package/dist/webgl/utilities/WebGlConstants.d.ts.map +1 -0
- package/dist/webgl/utilities/WebGlConverter.d.ts +0 -7
- package/dist/webgl/utilities/WebGlConverter.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts +10 -0
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts.map +1 -0
- package/dist/webgl/utilities/WebGlTextureUtilities.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlUtilities.d.ts +3 -0
- package/dist/webgl/utilities/WebGlUtilities.d.ts.map +1 -1
- package/dist/webgl/utilities/webgl-filter-anisotropic-utilities.d.ts +0 -1
- package/dist/webgl/utilities/webgl-filter-anisotropic-utilities.d.ts.map +1 -1
- package/dist/webgpu/WebGpuGpuInfo.d.ts +28 -0
- package/dist/webgpu/WebGpuGpuInfo.d.ts.map +1 -0
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts +80 -0
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts.map +1 -0
- package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts +26 -0
- package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts.map +1 -0
- package/dist/webgpu/WebGpuRenderer.d.ts +26 -0
- package/dist/webgpu/WebGpuRenderer.d.ts.map +1 -0
- package/dist/webgpu/WebGpuTypes.d.ts +355 -0
- package/dist/webgpu/WebGpuTypes.d.ts.map +1 -0
- package/dist/webgpu/blending/WebGpuBlendState.d.ts +30 -0
- package/dist/webgpu/blending/WebGpuBlendState.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts +20 -0
- package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts +46 -0
- package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts +43 -0
- package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts +49 -0
- package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts.map +1 -0
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts +32 -0
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts.map +1 -0
- package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts +28 -0
- package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts +50 -0
- package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts +34 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts +26 -0
- package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts +72 -0
- package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts +40 -0
- package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/sampler/WebGpuSampler.d.ts +39 -0
- package/dist/webgpu/sampler/WebGpuSampler.d.ts.map +1 -0
- package/dist/webgpu/shader/WebGpuShaderModule.d.ts +29 -0
- package/dist/webgpu/shader/WebGpuShaderModule.d.ts.map +1 -0
- package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts +21 -0
- package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts.map +1 -0
- package/dist/webgpu/shader/WgslShaderContent.d.ts +9 -0
- package/dist/webgpu/shader/WgslShaderContent.d.ts.map +1 -0
- package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts +41 -0
- package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts +47 -0
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts +21 -0
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTextureView.d.ts +25 -0
- package/dist/webgpu/texture/WebGpuTextureView.d.ts.map +1 -0
- package/dist/webgpu/utilities/WebGpuConverter.d.ts +45 -0
- package/dist/webgpu/utilities/WebGpuConverter.d.ts.map +1 -0
- package/package.json +4 -4
- package/shaders/glsl/forward_blinn_phong_material_fs.glsl +110 -0
- package/shaders/glsl/forward_blinn_phong_material_vs.glsl +32 -0
- package/shaders/glsl/main_render_target_flip_y_fs.glsl +35 -1
- package/shaders/glsl/sprite_fs.glsl +1 -1
- package/shaders/glsl/unlit_material_fs.glsl +1 -1
- package/shaders/wgsl/forward_blinn_phong_material.wgsl +150 -0
- package/shaders/wgsl/inspect_texture_mips.wgsl +51 -0
- package/shaders/wgsl/main_frame_buffer.wgsl +35 -0
- package/shaders/wgsl/main_render_target_flip_y.wgsl +35 -0
- package/shaders/wgsl/sprite.wgsl +40 -0
- package/shaders/wgsl/unlit_material.wgsl +49 -0
- package/src/Framework.ts +156 -48
- package/src/api/IFramework.ts +63 -6
- package/src/api/_export.ts +3 -1
- package/src/api/camera/CameraFactory.ts +6 -6
- package/src/api/camera/ICamera.ts +6 -0
- package/src/api/camera/ICameraFactory.ts +5 -10
- package/src/api/camera/OrthographicCamera.ts +23 -1
- package/src/api/camera/PerspectiveCamera.ts +60 -15
- package/src/api/content/ContentManager.ts +78 -16
- package/src/api/content/IContentManager.ts +37 -1
- package/src/api/content/ShaderModuleContent.ts +9 -0
- package/src/api/data/Color.ts +7 -1
- package/src/api/geometry/BaseGeometry.ts +23 -0
- package/src/api/geometry/GeometryBuilder.ts +14 -2
- package/src/api/geometry/IGeometryBuilder.ts +31 -1
- package/src/api/geometry/_export-geometry.ts +2 -1
- package/src/api/input/InputManager.ts +14 -5
- package/src/api/lights/AmbientLight.ts +53 -0
- package/src/api/lights/DirectionalLight.ts +60 -0
- package/src/api/lights/LightFactory.ts +21 -0
- package/src/api/lights/LightId.ts +9 -0
- package/src/api/lights/LightsBuffer.ts +94 -0
- package/src/api/lights/PointLight.ts +91 -0
- package/src/api/lights/_export.ts +5 -0
- package/src/api/loaders/ObjGeometryMapper.ts +28 -0
- package/src/api/loaders/ObjLoader.ts +126 -0
- package/src/api/loaders/_export.ts +3 -1
- package/src/api/loaders/obj/ObjParser.ts +301 -0
- package/src/api/loaders/obj/ObjTypes.ts +142 -0
- package/src/api/loaders/obj/index.ts +5 -0
- package/src/api/material/ForwardBlinnPhongMaterial.ts +328 -0
- package/src/api/material/ICameraMaterial.ts +22 -0
- package/src/api/material/ILightsMaterial.ts +32 -0
- package/src/api/material/IMaterial.ts +13 -10
- package/src/api/material/IMaterialFactory.ts +19 -2
- package/src/api/material/InspectTextureMipsMaterial.ts +65 -26
- package/src/api/material/MaterialFactory.ts +12 -0
- package/src/api/material/SpriteMaterial.ts +83 -0
- package/src/api/material/UnlitMaterial.ts +105 -32
- package/src/api/material/_export.ts +5 -1
- package/src/api/meshes/IMesh.ts +40 -6
- package/src/api/meshes/IMeshFactory.ts +33 -4
- package/src/api/meshes/IRenderableMesh.ts +58 -0
- package/src/api/meshes/Mesh.ts +50 -43
- package/src/api/meshes/MeshFactory.ts +37 -4
- package/src/api/meshes/QuadMesh.ts +6 -4
- package/src/api/meshes/RenderableMesh.ts +207 -0
- package/src/api/meshes/_export.ts +6 -4
- package/src/api/rendering/IGraphicsDeviceFeatures.ts +28 -21
- package/src/api/rendering/IRenderer.ts +34 -1
- package/src/api/rendering/enums.ts +10 -0
- package/src/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.ts +66 -0
- package/src/api/rendering/render-pipelines/IRenderPipeline.ts +4 -0
- package/src/api/rendering/render-pipelines/IRenderPipelineFactory.ts +39 -0
- package/src/api/rendering/render-pipelines/_export-render-pipelines.ts +2 -1
- package/src/api/rendering/renderer-interface.ts +1 -36
- package/src/api/rendering/renderpass/RenderPassDescriptor.ts +10 -14
- package/src/api/rendering/swapchain/ISwapChain.ts +1 -3
- package/src/api/rendering/texture/TextureFormat.ts +128 -14
- package/src/api/rendering/texture/TextureUtilities.ts +225 -10
- package/src/api/scene/Scene.ts +297 -0
- package/src/api/scene/SceneMesh.ts +61 -0
- package/src/api/shader/IShaderModuleLoader.ts +2 -1
- package/src/api/sprites/SpriteBatchDrawable.ts +12 -16
- package/src/api/sprites/SpriteBatchMesh.ts +22 -3
- package/src/api/utilities/AlignUtilities.ts +2 -1
- package/src/api/utilities/GeometryUtilities.ts +2 -0
- package/src/api/window/WindowManager.ts +23 -3
- package/src/core/rendering/ARenderer.ts +24 -15
- package/src/core/rendering/vertex-buffer-layout.ts +32 -1
- package/src/index.ts +0 -1
- package/src/main.ts +2 -4
- package/src/webgl/WebGLGraphicsDeviceFeatures.ts +12 -2
- package/src/webgl/WebGlGpuInfo.ts +1 -1
- package/src/webgl/WebGlGraphicsDevice.ts +0 -1
- package/src/webgl/WebGlRenderer.ts +2 -5
- package/src/webgl/lights/WebGlAmbientLightFactory.ts +35 -0
- package/src/webgl/lights/WebGlLightsBuffer.ts +225 -0
- package/src/webgl/render-pipelines/AWebGlRenderPipeline.ts +7 -1
- package/src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts +21 -1
- package/src/webgl/render-pipelines/WebGlRenderPipelineFactory.ts +24 -2
- package/src/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.ts +16 -6
- package/src/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.ts +300 -0
- package/src/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.ts +16 -6
- package/src/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.ts +11 -7
- package/src/webgl/shader/WebGlShaderModule.ts +11 -4
- package/src/webgl/shader/WebGlShaderModuleLoader.ts +29 -10
- package/src/webgl/swap-chain/WebGlSwapChain.ts +7 -6
- package/src/webgl/texture/WebGlTexture2D.ts +19 -5
- package/src/webgl/texture/WebGlTextureFactory.ts +49 -7
- package/src/webgl/utilities/WebGlConstants.ts +136 -0
- package/src/webgl/utilities/WebGlConverter.ts +91 -22
- package/src/webgl/utilities/WebGlErrorUtilities.ts +15 -0
- package/src/webgl/utilities/WebGlTextureUtilities.ts +5 -2
- package/src/webgl/utilities/WebGlUtilities.ts +4 -0
- package/src/webgl/utilities/webgl-filter-anisotropic-utilities.ts +9 -6
- package/src/webgpu/WebGpuGpuInfo.ts +61 -0
- package/src/webgpu/WebGpuGraphicsDevice.ts +199 -0
- package/src/webgpu/WebGpuGraphicsDeviceFeatures.ts +41 -0
- package/src/webgpu/WebGpuRenderer.ts +49 -0
- package/src/webgpu/WebGpuTypes.ts +288 -0
- package/src/webgpu/blending/WebGpuBlendState.ts +53 -0
- package/src/webgpu/buffers/WebGpuBuffersFactory.ts +46 -0
- package/src/webgpu/buffers/WebGpuIndexBuffer.ts +118 -0
- package/src/webgpu/buffers/WebGpuUniformBuffer.ts +102 -0
- package/src/webgpu/buffers/WebGpuVertexBuffer.ts +119 -0
- package/src/webgpu/primitive/WebGpuPrimitiveState.ts +52 -0
- package/src/webgpu/render-pass/WebGpuRenderPass.ts +131 -0
- package/src/webgpu/render-pipelines/AWebGpuRenderPipeline.ts +123 -0
- package/src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts +119 -0
- package/src/webgpu/render-pipelines/WebGpuRenderPipelineFactory.ts +66 -0
- package/src/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.ts +249 -0
- package/src/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.ts +101 -0
- package/src/webgpu/sampler/WebGpuSampler.ts +84 -0
- package/src/webgpu/shader/WebGpuShaderModule.ts +65 -0
- package/src/webgpu/shader/WebGpuShaderModuleLoader.ts +38 -0
- package/src/webgpu/shader/WgslShaderContent.ts +20 -0
- package/src/webgpu/swap-chain/WebGpuSwapChain.ts +93 -0
- package/src/webgpu/texture/WebGpuTexture2D.ts +197 -0
- package/src/webgpu/texture/WebGpuTextureFactory.ts +118 -0
- package/src/webgpu/texture/WebGpuTextureView.ts +43 -0
- package/src/webgpu/utilities/WebGpuConverter.ts +299 -0
- package/src/wgsl-raw.d.ts +4 -0
- package/dist/api/FrameworkConfiguration.d.ts +0 -23
- package/dist/api/FrameworkConfiguration.d.ts.map +0 -1
- package/dist/api/IFrameworkConfiguration.d.ts +0 -25
- package/dist/api/IFrameworkConfiguration.d.ts.map +0 -1
- package/dist/api/shader/shader-loader.d.ts.map +0 -1
- package/src/api/FrameworkConfiguration.ts +0 -29
- package/src/api/IFrameworkConfiguration.ts +0 -30
- /package/src/api/shader/{shader-loader.ts → ShaderLoader.ts} +0 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type IFramework,
|
|
3
|
+
State,
|
|
4
|
+
TextureDescriptor,
|
|
5
|
+
TextureUsage,
|
|
6
|
+
TextureUtilities,
|
|
7
|
+
type ITextureView,
|
|
8
|
+
TextureViewDescriptor,
|
|
9
|
+
TextureViewDimension,
|
|
10
|
+
} from "../../api/index.ts";
|
|
11
|
+
import {ATexture2D} from "../../core/rendering/texture/texture.ts";
|
|
12
|
+
import type {WebGpuGraphicsDevice} from "../WebGpuGraphicsDevice.ts";
|
|
13
|
+
import {GpuTextureUsage, type GpuTexture, type GpuTextureView} from "../WebGpuTypes.ts";
|
|
14
|
+
import {WebGpuConverter} from "../utilities/WebGpuConverter.ts";
|
|
15
|
+
import {WebGpuTextureView} from "./WebGpuTextureView.ts";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The WebGPU 2D texture.
|
|
19
|
+
*
|
|
20
|
+
* Supports uncompressed formats with `Uint8Array` mip levels or an `HTMLImageElement`.
|
|
21
|
+
* Mipmap generation and compressed (KTX2) formats are not implemented for WebGPU yet.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export class WebGpuTexture2D extends ATexture2D {
|
|
25
|
+
|
|
26
|
+
private readonly _graphicsDevice: WebGpuGraphicsDevice;
|
|
27
|
+
private readonly _image?: HTMLImageElement;
|
|
28
|
+
private _gpuTexture: GpuTexture | null = null;
|
|
29
|
+
private _gpuDefaultView: GpuTextureView | null = null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The constructor.
|
|
33
|
+
* @param framework The framework.
|
|
34
|
+
* @param descriptor The texture descriptor.
|
|
35
|
+
* @param image An optional image to upload instead of `descriptor.data`.
|
|
36
|
+
*/
|
|
37
|
+
public constructor(framework: IFramework, descriptor: TextureDescriptor, image?: HTMLImageElement) {
|
|
38
|
+
super(descriptor);
|
|
39
|
+
this._graphicsDevice = framework.renderer.graphicsDevice as WebGpuGraphicsDevice;
|
|
40
|
+
this._image = image;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The WebGPU texture. */
|
|
44
|
+
public get gpuTexture(): GpuTexture {
|
|
45
|
+
if (!this._gpuTexture) {
|
|
46
|
+
throw new Error("WebGpuTexture2D: the texture is not initialized or is disposed.");
|
|
47
|
+
}
|
|
48
|
+
return this._gpuTexture;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The default WebGPU view of the whole texture. */
|
|
52
|
+
public get gpuDefaultView(): GpuTextureView {
|
|
53
|
+
if (!this._gpuDefaultView) {
|
|
54
|
+
throw new Error("WebGpuTexture2D: the texture is not initialized or is disposed.");
|
|
55
|
+
}
|
|
56
|
+
return this._gpuDefaultView;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** @inheritDoc */
|
|
60
|
+
public initialize(): void {
|
|
61
|
+
if (this._state == State.INITIALIZED) {
|
|
62
|
+
throw new Error("Texture is already initialized.");
|
|
63
|
+
} else if (this._state == State.DISPOSED) {
|
|
64
|
+
throw new Error("Texture is already disposed.");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (TextureUtilities.isCompressedTextureFormat(this.textureFormat)) {
|
|
68
|
+
throw new Error("Compressed textures are not implemented for WebGPU.");
|
|
69
|
+
}
|
|
70
|
+
if (this._generateMipMaps) {
|
|
71
|
+
console.warn("WebGpuTexture2D: mipmap generation is not implemented for WebGPU; only the base level is used.");
|
|
72
|
+
this._generateMipMaps = false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const hasData = !!this._data && this._data.length > 0;
|
|
76
|
+
let usage = WebGpuConverter.convertTextureUsage(this.textureUsage);
|
|
77
|
+
// Uploading needs COPY_DST; copyExternalImageToTexture also needs RENDER_ATTACHMENT.
|
|
78
|
+
if (hasData || this._image) {
|
|
79
|
+
usage |= GpuTextureUsage.COPY_DST;
|
|
80
|
+
}
|
|
81
|
+
if (this._image) {
|
|
82
|
+
usage |= GpuTextureUsage.RENDER_ATTACHMENT;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const device = this._graphicsDevice.device;
|
|
86
|
+
this._gpuTexture = device.createTexture({
|
|
87
|
+
label: this.label ?? `WebGpuTexture2D ${this.id}`,
|
|
88
|
+
size: {width: this.width, height: this.height, depthOrArrayLayers: 1},
|
|
89
|
+
mipLevelCount: this._mipLevels,
|
|
90
|
+
format: WebGpuConverter.convertTextureFormat(this.textureFormat),
|
|
91
|
+
usage,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
if (this._image) {
|
|
95
|
+
device.queue.copyExternalImageToTexture(
|
|
96
|
+
{source: this._image},
|
|
97
|
+
{texture: this._gpuTexture},
|
|
98
|
+
{width: this.width, height: this.height});
|
|
99
|
+
} else if (hasData) {
|
|
100
|
+
let width = this.width;
|
|
101
|
+
let height = this.height;
|
|
102
|
+
for (let level = 0; level < this._data!.length; level++) {
|
|
103
|
+
const levelData = this._data![level];
|
|
104
|
+
const bytesPerPixel = TextureUtilities.getVRamSize(this.textureFormat, 1, 1);
|
|
105
|
+
device.queue.writeTexture(
|
|
106
|
+
{texture: this._gpuTexture, mipLevel: level},
|
|
107
|
+
levelData,
|
|
108
|
+
{bytesPerRow: width * bytesPerPixel, rowsPerImage: height},
|
|
109
|
+
{width, height});
|
|
110
|
+
width = Math.max(1, Math.floor(width / 2));
|
|
111
|
+
height = Math.max(1, Math.floor(height / 2));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this._gpuDefaultView = this._gpuTexture.createView({label: `${this.label ?? "WebGpuTexture2D"} default view`});
|
|
116
|
+
// ATexture2D declares the default view readonly and sets it to null; fill it in here.
|
|
117
|
+
(this as { defaultTextureView: ITextureView }).defaultTextureView =
|
|
118
|
+
new WebGpuTextureView(this._gpuDefaultView, this.textureFormat);
|
|
119
|
+
this._handle = this._gpuTexture;
|
|
120
|
+
|
|
121
|
+
this._state = State.INITIALIZED;
|
|
122
|
+
|
|
123
|
+
let width = this.width;
|
|
124
|
+
let height = this.height;
|
|
125
|
+
this._size = 0;
|
|
126
|
+
for (let i = 0; i < this.mipLevels; i++) {
|
|
127
|
+
this._size += TextureUtilities.getVRamSize(this.textureFormat, width, height);
|
|
128
|
+
width = Math.max(1, Math.floor(width / 2));
|
|
129
|
+
height = Math.max(1, Math.floor(height / 2));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** @inheritDoc */
|
|
134
|
+
public createView(descriptor?: TextureViewDescriptor): ITextureView {
|
|
135
|
+
descriptor = descriptor ?? new TextureViewDescriptor();
|
|
136
|
+
if (descriptor.dimension !== TextureViewDimension.DIMENSION_2D) {
|
|
137
|
+
throw new Error("Only 2D texture views are implemented for WebGPU.");
|
|
138
|
+
}
|
|
139
|
+
const view = this.gpuTexture.createView({
|
|
140
|
+
label: descriptor.label,
|
|
141
|
+
format: WebGpuConverter.convertTextureFormat(descriptor.textureFormat),
|
|
142
|
+
dimension: "2d",
|
|
143
|
+
});
|
|
144
|
+
return new WebGpuTextureView(view, descriptor.textureFormat, descriptor.dimension);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** @inheritDoc */
|
|
148
|
+
public dispose(): void {
|
|
149
|
+
if (this._state == State.DISPOSING || this._state == State.DISPOSED) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
this._gpuTexture?.destroy();
|
|
153
|
+
this._gpuTexture = null;
|
|
154
|
+
this._gpuDefaultView = null;
|
|
155
|
+
this.defaultTextureView?.dispose();
|
|
156
|
+
this._state = State.DISPOSED;
|
|
157
|
+
|
|
158
|
+
for (const listener of this._disposedListeners.slice()) {
|
|
159
|
+
listener(this);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** One default texture per framework. */
|
|
164
|
+
private static readonly _defaultFilled = new WeakMap<IFramework, WebGpuTexture2D>();
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Returns the framework's 1x1 white texture, creating it on first use.
|
|
168
|
+
* Used when a pipeline has no texture set.
|
|
169
|
+
* @param framework The framework.
|
|
170
|
+
*/
|
|
171
|
+
public static getOrCreateDefault(framework: IFramework): WebGpuTexture2D {
|
|
172
|
+
let texture = WebGpuTexture2D._defaultFilled.get(framework);
|
|
173
|
+
if (!texture || texture.state === State.DISPOSED) {
|
|
174
|
+
const desc = new TextureDescriptor();
|
|
175
|
+
desc.width = 1;
|
|
176
|
+
desc.height = 1;
|
|
177
|
+
desc.data = [new Uint8Array([255, 255, 255, 255])];
|
|
178
|
+
desc.textureFormat = framework.renderer.preferredTextureFormat;
|
|
179
|
+
desc.textureUsage = TextureUsage.TEXTURE_BINDING | TextureUsage.COPY_DST;
|
|
180
|
+
desc.label = "RisDefaultFilledTexture";
|
|
181
|
+
texture = new WebGpuTexture2D(framework, desc);
|
|
182
|
+
texture.initialize();
|
|
183
|
+
WebGpuTexture2D._defaultFilled.set(framework, texture);
|
|
184
|
+
}
|
|
185
|
+
return texture;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Disposes and forgets the framework's default texture. Called from `Framework.dispose()`.
|
|
190
|
+
* @param framework The framework.
|
|
191
|
+
*/
|
|
192
|
+
public static disposeDefault(framework: IFramework): void {
|
|
193
|
+
const texture = WebGpuTexture2D._defaultFilled.get(framework);
|
|
194
|
+
WebGpuTexture2D._defaultFilled.delete(framework);
|
|
195
|
+
texture?.dispose();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Color,
|
|
3
|
+
type IFramework,
|
|
4
|
+
type ITexture2D,
|
|
5
|
+
type ITextureFactory,
|
|
6
|
+
TextureDescriptor,
|
|
7
|
+
TextureFormat,
|
|
8
|
+
TextureUsage,
|
|
9
|
+
} from "../../api/index.ts";
|
|
10
|
+
import type {IKtx2Texture} from "ris-ktx2";
|
|
11
|
+
import {WebGpuTexture2D} from "./WebGpuTexture2D.ts";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The WebGPU texture factory.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export class WebGpuTextureFactory implements ITextureFactory {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The constructor.
|
|
21
|
+
* @param _framework The framework.
|
|
22
|
+
*/
|
|
23
|
+
public constructor(private readonly _framework: IFramework) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @inheritDoc */
|
|
27
|
+
public createFromKtx2(_ktxTexture: IKtx2Texture, _descriptor?: TextureDescriptor): ITexture2D {
|
|
28
|
+
throw new Error("createFromKtx2 is not implemented for WebGPU.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @inheritDoc */
|
|
32
|
+
public create(
|
|
33
|
+
width: number, height: number,
|
|
34
|
+
data?: number[] | HTMLImageElement | ArrayBufferView,
|
|
35
|
+
channels: number = 4,
|
|
36
|
+
label: string | null | undefined = null,
|
|
37
|
+
textureUsage = TextureUsage.COPY_DST | TextureUsage.TEXTURE_BINDING,
|
|
38
|
+
textureFormat = TextureFormat.RGBA_8_UNORM,
|
|
39
|
+
useMipMaps = false): ITexture2D {
|
|
40
|
+
|
|
41
|
+
if (!data) {
|
|
42
|
+
throw new Error("Data must not be null.");
|
|
43
|
+
}
|
|
44
|
+
if (width == 0 || height == 0) {
|
|
45
|
+
throw new Error("width and height must be greater than 0.");
|
|
46
|
+
}
|
|
47
|
+
if (channels == 0) {
|
|
48
|
+
throw new Error("channels must be greater than 0.");
|
|
49
|
+
}
|
|
50
|
+
if (textureFormat == TextureFormat.UNDEFINED) {
|
|
51
|
+
textureFormat = this._framework.renderer.preferredTextureFormat;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const desc = new TextureDescriptor();
|
|
55
|
+
desc.width = width;
|
|
56
|
+
desc.height = height;
|
|
57
|
+
desc.textureFormat = textureFormat;
|
|
58
|
+
desc.textureUsage = textureUsage;
|
|
59
|
+
desc.generateMipmaps = useMipMaps;
|
|
60
|
+
desc.label = label ?? null;
|
|
61
|
+
|
|
62
|
+
let image: HTMLImageElement | undefined;
|
|
63
|
+
if (typeof HTMLImageElement !== "undefined" && data instanceof HTMLImageElement) {
|
|
64
|
+
image = data;
|
|
65
|
+
} else if (Array.isArray(data)) {
|
|
66
|
+
desc.data = [new Uint8Array(data)];
|
|
67
|
+
} else {
|
|
68
|
+
const view = data as ArrayBufferView;
|
|
69
|
+
desc.data = [new Uint8Array(view.buffer, view.byteOffset, view.byteLength)];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const texture = new WebGpuTexture2D(this._framework, desc, image);
|
|
73
|
+
texture.initialize();
|
|
74
|
+
return texture;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** @inheritDoc */
|
|
78
|
+
public createEmpty(
|
|
79
|
+
width: number, height: number,
|
|
80
|
+
color: Color | null = null,
|
|
81
|
+
textureUsage = TextureUsage.COPY_DST | TextureUsage.TEXTURE_BINDING,
|
|
82
|
+
textureFormat = TextureFormat.UNDEFINED,
|
|
83
|
+
label: string | null = null,
|
|
84
|
+
useMipmap = false): ITexture2D {
|
|
85
|
+
|
|
86
|
+
if (width == 0 || height == 0) {
|
|
87
|
+
throw new Error("Width and height must be greater than 0.");
|
|
88
|
+
}
|
|
89
|
+
if (textureFormat == TextureFormat.UNDEFINED) {
|
|
90
|
+
textureFormat = this._framework.renderer.preferredTextureFormat;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const desc = new TextureDescriptor();
|
|
94
|
+
desc.width = width;
|
|
95
|
+
desc.height = height;
|
|
96
|
+
desc.textureUsage = textureUsage;
|
|
97
|
+
desc.textureFormat = textureFormat;
|
|
98
|
+
desc.label = label;
|
|
99
|
+
desc.generateMipmaps = useMipmap;
|
|
100
|
+
|
|
101
|
+
// WebGPU zero-initializes textures, so transparent black needs no upload; neither do depth textures.
|
|
102
|
+
if (!color || (color.r === 0 && color.g === 0 && color.b === 0 && color.a === 0)) {
|
|
103
|
+
const texture = new WebGpuTexture2D(this._framework, desc);
|
|
104
|
+
texture.initialize();
|
|
105
|
+
return texture;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const byteSize = width * height * 4;
|
|
109
|
+
const bytes = new Uint8Array(byteSize);
|
|
110
|
+
for (let i = 0; i < byteSize; i += 4) {
|
|
111
|
+
bytes[i] = color.r * 255;
|
|
112
|
+
bytes[i + 1] = color.g * 255;
|
|
113
|
+
bytes[i + 2] = color.b * 255;
|
|
114
|
+
bytes[i + 3] = color.a * 255;
|
|
115
|
+
}
|
|
116
|
+
return this.create(width, height, bytes, 4, label, textureUsage, textureFormat, useMipmap);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {type ITextureView, TextureFormat, TextureViewDimension} from "../../api/index.ts";
|
|
2
|
+
import type {GpuTextureView} from "../WebGpuTypes.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The WebGPU texture view.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export class WebGpuTextureView implements ITextureView {
|
|
9
|
+
|
|
10
|
+
private _gpuTextureView: GpuTextureView | null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The constructor.
|
|
14
|
+
* @param gpuTextureView The WebGPU view.
|
|
15
|
+
* @param textureFormat The view format.
|
|
16
|
+
* @param dimension The view dimension.
|
|
17
|
+
*/
|
|
18
|
+
public constructor(gpuTextureView: GpuTextureView, textureFormat: TextureFormat, dimension = TextureViewDimension.DIMENSION_2D) {
|
|
19
|
+
this._gpuTextureView = gpuTextureView;
|
|
20
|
+
this.textureFormat = textureFormat;
|
|
21
|
+
this.dimension = dimension;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** @inheritDoc */
|
|
25
|
+
public readonly textureFormat: TextureFormat;
|
|
26
|
+
|
|
27
|
+
/** @inheritDoc */
|
|
28
|
+
public readonly dimension: TextureViewDimension;
|
|
29
|
+
|
|
30
|
+
/** The WebGPU view. */
|
|
31
|
+
public get gpuTextureView(): GpuTextureView {
|
|
32
|
+
if (!this._gpuTextureView) {
|
|
33
|
+
throw new Error("WebGpuTextureView: the view is disposed.");
|
|
34
|
+
}
|
|
35
|
+
return this._gpuTextureView;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @inheritDoc */
|
|
39
|
+
public dispose(): void {
|
|
40
|
+
// Views have no destroy() in WebGPU; dropping the reference is enough.
|
|
41
|
+
this._gpuTextureView = null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BufferUsage,
|
|
3
|
+
CullMode,
|
|
4
|
+
FrontFace,
|
|
5
|
+
LoadAction,
|
|
6
|
+
MipMapSamplerFilter,
|
|
7
|
+
PrimitiveTopology,
|
|
8
|
+
SamplerAddressMode,
|
|
9
|
+
SamplerFilter,
|
|
10
|
+
StoreAction,
|
|
11
|
+
TextureFormat,
|
|
12
|
+
TextureUsage,
|
|
13
|
+
VertexStepMode,
|
|
14
|
+
type IVertexBufferLayout,
|
|
15
|
+
} from "../../api/index.ts";
|
|
16
|
+
import {VertexFormat} from "../../api/geometry/VertexFormat.ts";
|
|
17
|
+
import {BlendFactor, BlendOperation} from "../../core/rendering/blending/enums.ts";
|
|
18
|
+
import {
|
|
19
|
+
GpuBufferUsage,
|
|
20
|
+
GpuTextureUsage,
|
|
21
|
+
type GpuAddressMode,
|
|
22
|
+
type GpuBlendFactor,
|
|
23
|
+
type GpuBlendOperation,
|
|
24
|
+
type GpuCullMode,
|
|
25
|
+
type GpuFilterMode,
|
|
26
|
+
type GpuFrontFace,
|
|
27
|
+
type GpuLoadOp,
|
|
28
|
+
type GpuPrimitiveTopology,
|
|
29
|
+
type GpuStoreOp,
|
|
30
|
+
type GpuTextureFormat,
|
|
31
|
+
type GpuVertexBufferLayout,
|
|
32
|
+
type GpuVertexFormat,
|
|
33
|
+
} from "../WebGpuTypes.ts";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Converts framework enums to WebGPU values.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export class WebGpuConverter {
|
|
40
|
+
|
|
41
|
+
/** Converts buffer usage flags. */
|
|
42
|
+
public static convertBufferUsage(usage: BufferUsage): number {
|
|
43
|
+
let result = 0;
|
|
44
|
+
if (usage & BufferUsage.VERTEX) result |= GpuBufferUsage.VERTEX;
|
|
45
|
+
if (usage & BufferUsage.INDEX) result |= GpuBufferUsage.INDEX;
|
|
46
|
+
if (usage & BufferUsage.UNIFORM) result |= GpuBufferUsage.UNIFORM;
|
|
47
|
+
if (usage & BufferUsage.STORAGE) result |= GpuBufferUsage.STORAGE;
|
|
48
|
+
if (usage & BufferUsage.MAP_READ) result |= GpuBufferUsage.MAP_READ;
|
|
49
|
+
if (usage & BufferUsage.COPY_DST) result |= GpuBufferUsage.COPY_DST;
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Converts texture usage flags. `TextureUsage.NONE` maps to 0. */
|
|
54
|
+
public static convertTextureUsage(usage: TextureUsage): number {
|
|
55
|
+
let result = 0;
|
|
56
|
+
if (usage & TextureUsage.COPY_SRC) result |= GpuTextureUsage.COPY_SRC;
|
|
57
|
+
if (usage & TextureUsage.COPY_DST) result |= GpuTextureUsage.COPY_DST;
|
|
58
|
+
if (usage & TextureUsage.TEXTURE_BINDING) result |= GpuTextureUsage.TEXTURE_BINDING;
|
|
59
|
+
if (usage & TextureUsage.STORAGE_BINDING) result |= GpuTextureUsage.STORAGE_BINDING;
|
|
60
|
+
if (usage & TextureUsage.RENDER_ATTACHMENT) result |= GpuTextureUsage.RENDER_ATTACHMENT;
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Converts a texture format. Throws for formats the WebGPU backend does not support yet. */
|
|
65
|
+
public static convertTextureFormat(format: TextureFormat): GpuTextureFormat {
|
|
66
|
+
switch (format) {
|
|
67
|
+
case TextureFormat.RGBA_8_UNORM:
|
|
68
|
+
return "rgba8unorm";
|
|
69
|
+
case TextureFormat.RGBA_8_UNORM_SRGB:
|
|
70
|
+
return "rgba8unorm-srgb";
|
|
71
|
+
case TextureFormat.DEPTH_24_STENCIL_8:
|
|
72
|
+
return "depth24plus-stencil8";
|
|
73
|
+
case TextureFormat.DEPTH_32_FLOAT:
|
|
74
|
+
return "depth32float";
|
|
75
|
+
case TextureFormat.RED_32_FLOAT:
|
|
76
|
+
return "r32float";
|
|
77
|
+
|
|
78
|
+
// BC (texture-compression-bc). WebGPU has no BC1 RGB, the RGBA variant decodes the same blocks.
|
|
79
|
+
case TextureFormat.BC1_RGB_UNORM:
|
|
80
|
+
return "bc1-rgba-unorm";
|
|
81
|
+
case TextureFormat.BC1_RGB_SRGB:
|
|
82
|
+
return "bc1-rgba-unorm-srgb";
|
|
83
|
+
case TextureFormat.BC3_RGBA_UNORM:
|
|
84
|
+
return "bc3-rgba-unorm";
|
|
85
|
+
case TextureFormat.BC3_RGBA_SRGB:
|
|
86
|
+
return "bc3-rgba-unorm-srgb";
|
|
87
|
+
case TextureFormat.BC7_RGBA_UNORM:
|
|
88
|
+
return "bc7-rgba-unorm";
|
|
89
|
+
case TextureFormat.BC7_RGBA_SRGB:
|
|
90
|
+
return "bc7-rgba-unorm-srgb";
|
|
91
|
+
|
|
92
|
+
// ETC2 (texture-compression-etc2)
|
|
93
|
+
case TextureFormat.ETC2_RGB8_UNORM:
|
|
94
|
+
return "etc2-rgb8unorm";
|
|
95
|
+
case TextureFormat.ETC2_RGB8_SRGB:
|
|
96
|
+
return "etc2-rgb8unorm-srgb";
|
|
97
|
+
case TextureFormat.ETC2_RGBA8_UNORM:
|
|
98
|
+
return "etc2-rgba8unorm";
|
|
99
|
+
case TextureFormat.ETC2_RGBA8_SRGB:
|
|
100
|
+
return "etc2-rgba8unorm-srgb";
|
|
101
|
+
|
|
102
|
+
// ASTC (texture-compression-astc)
|
|
103
|
+
case TextureFormat.ASTC_4X4_RGBA_UNORM:
|
|
104
|
+
return "astc-4x4-unorm";
|
|
105
|
+
case TextureFormat.ASTC_4X4_RGBA_SRGB:
|
|
106
|
+
return "astc-4x4-unorm-srgb";
|
|
107
|
+
case TextureFormat.ASTC_5X4_RGBA_UNORM:
|
|
108
|
+
return "astc-5x4-unorm";
|
|
109
|
+
case TextureFormat.ASTC_5X4_RGBA_SRGB:
|
|
110
|
+
return "astc-5x4-unorm-srgb";
|
|
111
|
+
case TextureFormat.ASTC_5X5_RGBA_UNORM:
|
|
112
|
+
return "astc-5x5-unorm";
|
|
113
|
+
case TextureFormat.ASTC_5X5_RGBA_SRGB:
|
|
114
|
+
return "astc-5x5-unorm-srgb";
|
|
115
|
+
case TextureFormat.ASTC_6X5_RGBA_UNORM:
|
|
116
|
+
return "astc-6x5-unorm";
|
|
117
|
+
case TextureFormat.ASTC_6X5_RGBA_SRGB:
|
|
118
|
+
return "astc-6x5-unorm-srgb";
|
|
119
|
+
case TextureFormat.ASTC_6X6_RGBA_UNORM:
|
|
120
|
+
return "astc-6x6-unorm";
|
|
121
|
+
case TextureFormat.ASTC_6X6_RGBA_SRGB:
|
|
122
|
+
return "astc-6x6-unorm-srgb";
|
|
123
|
+
case TextureFormat.ASTC_8X5_RGBA_UNORM:
|
|
124
|
+
return "astc-8x5-unorm";
|
|
125
|
+
case TextureFormat.ASTC_8X5_RGBA_SRGB:
|
|
126
|
+
return "astc-8x5-unorm-srgb";
|
|
127
|
+
case TextureFormat.ASTC_8X6_RGBA_UNORM:
|
|
128
|
+
return "astc-8x6-unorm";
|
|
129
|
+
case TextureFormat.ASTC_8X6_RGBA_SRGB:
|
|
130
|
+
return "astc-8x6-unorm-srgb";
|
|
131
|
+
case TextureFormat.ASTC_8X8_RGBA_UNORM:
|
|
132
|
+
return "astc-8x8-unorm";
|
|
133
|
+
case TextureFormat.ASTC_8X8_RGBA_SRGB:
|
|
134
|
+
return "astc-8x8-unorm-srgb";
|
|
135
|
+
case TextureFormat.ASTC_10X5_RGBA_UNORM:
|
|
136
|
+
return "astc-10x5-unorm";
|
|
137
|
+
case TextureFormat.ASTC_10X5_RGBA_SRGB:
|
|
138
|
+
return "astc-10x5-unorm-srgb";
|
|
139
|
+
case TextureFormat.ASTC_10X6_RGBA_UNORM:
|
|
140
|
+
return "astc-10x6-unorm";
|
|
141
|
+
case TextureFormat.ASTC_10X6_RGBA_SRGB:
|
|
142
|
+
return "astc-10x6-unorm-srgb";
|
|
143
|
+
case TextureFormat.ASTC_10X8_RGBA_UNORM:
|
|
144
|
+
return "astc-10x8-unorm";
|
|
145
|
+
case TextureFormat.ASTC_10X8_RGBA_SRGB:
|
|
146
|
+
return "astc-10x8-unorm-srgb";
|
|
147
|
+
case TextureFormat.ASTC_10X10_RGBA_UNORM:
|
|
148
|
+
return "astc-10x10-unorm";
|
|
149
|
+
case TextureFormat.ASTC_10X10_RGBA_SRGB:
|
|
150
|
+
return "astc-10x10-unorm-srgb";
|
|
151
|
+
case TextureFormat.ASTC_12X10_RGBA_UNORM:
|
|
152
|
+
return "astc-12x10-unorm";
|
|
153
|
+
case TextureFormat.ASTC_12X10_RGBA_SRGB:
|
|
154
|
+
return "astc-12x10-unorm-srgb";
|
|
155
|
+
case TextureFormat.ASTC_12X12_RGBA_UNORM:
|
|
156
|
+
return "astc-12x12-unorm";
|
|
157
|
+
case TextureFormat.ASTC_12X12_RGBA_SRGB:
|
|
158
|
+
return "astc-12x12-unorm-srgb";
|
|
159
|
+
default:
|
|
160
|
+
throw new Error(`Texture format ${format} is not implemented for WebGPU.`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Whether the format has a stencil aspect. */
|
|
165
|
+
public static hasStencil(format: TextureFormat): boolean {
|
|
166
|
+
return format === TextureFormat.DEPTH_24_STENCIL_8;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Whether the format is a depth (or depth-stencil) format. */
|
|
170
|
+
public static isDepthFormat(format: TextureFormat): boolean {
|
|
171
|
+
return format === TextureFormat.DEPTH_24_STENCIL_8 || format === TextureFormat.DEPTH_32_FLOAT;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Converts a load action. WebGPU has no "don't care", so `UNDEFINED` clears. */
|
|
175
|
+
public static convertLoadAction(action: LoadAction): GpuLoadOp {
|
|
176
|
+
return action === LoadAction.LOAD ? "load" : "clear";
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Converts a store action. */
|
|
180
|
+
public static convertStoreAction(action: StoreAction): GpuStoreOp {
|
|
181
|
+
return action === StoreAction.DISCARD ? "discard" : "store";
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Converts a sampler address mode. WebGPU has no border clamp, so it falls back to clamp to edge. */
|
|
185
|
+
public static convertAddressMode(mode: SamplerAddressMode): GpuAddressMode {
|
|
186
|
+
switch (mode) {
|
|
187
|
+
case SamplerAddressMode.REPEAT:
|
|
188
|
+
return "repeat";
|
|
189
|
+
case SamplerAddressMode.MIRROR_REPEAT:
|
|
190
|
+
return "mirror-repeat";
|
|
191
|
+
default:
|
|
192
|
+
return "clamp-to-edge";
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Converts a sampler filter. */
|
|
197
|
+
public static convertFilter(filter: SamplerFilter): GpuFilterMode {
|
|
198
|
+
return filter === SamplerFilter.LINEAR ? "linear" : "nearest";
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Converts a mip map filter. `NONE` maps to nearest; the sampler then clamps to mip 0. */
|
|
202
|
+
public static convertMipMapFilter(filter: MipMapSamplerFilter): GpuFilterMode {
|
|
203
|
+
return filter === MipMapSamplerFilter.LINEAR ? "linear" : "nearest";
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Converts a blend factor. */
|
|
207
|
+
public static convertBlendFactor(factor: BlendFactor): GpuBlendFactor {
|
|
208
|
+
switch (factor) {
|
|
209
|
+
case BlendFactor.ONE:
|
|
210
|
+
return "one";
|
|
211
|
+
case BlendFactor.SRC_ALPHA:
|
|
212
|
+
return "src-alpha";
|
|
213
|
+
case BlendFactor.ONE_MINUS_SRC_ALPHA:
|
|
214
|
+
return "one-minus-src-alpha";
|
|
215
|
+
default:
|
|
216
|
+
throw new Error(`Blend factor ${factor} is not implemented for WebGPU.`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Converts a blend operation. */
|
|
221
|
+
public static convertBlendOperation(operation: BlendOperation): GpuBlendOperation {
|
|
222
|
+
switch (operation) {
|
|
223
|
+
case BlendOperation.ADD:
|
|
224
|
+
return "add";
|
|
225
|
+
case BlendOperation.SUBTRACT:
|
|
226
|
+
return "subtract";
|
|
227
|
+
case BlendOperation.REVERSE_SUBTRACT:
|
|
228
|
+
return "reverse-subtract";
|
|
229
|
+
case BlendOperation.MIN:
|
|
230
|
+
return "min";
|
|
231
|
+
case BlendOperation.MAX:
|
|
232
|
+
return "max";
|
|
233
|
+
default:
|
|
234
|
+
throw new Error(`Blend operation ${operation} is not implemented for WebGPU.`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Converts a primitive topology. */
|
|
239
|
+
public static convertTopology(topology: PrimitiveTopology): GpuPrimitiveTopology {
|
|
240
|
+
switch (topology) {
|
|
241
|
+
case PrimitiveTopology.LINE_LIST:
|
|
242
|
+
return "line-list";
|
|
243
|
+
case PrimitiveTopology.LINE_STRIP:
|
|
244
|
+
return "line-strip";
|
|
245
|
+
case PrimitiveTopology.POINT_LIST:
|
|
246
|
+
return "point-list";
|
|
247
|
+
case PrimitiveTopology.TRIANGLE_STRIP:
|
|
248
|
+
return "triangle-strip";
|
|
249
|
+
default:
|
|
250
|
+
return "triangle-list";
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Converts a cull mode. */
|
|
255
|
+
public static convertCullMode(mode: CullMode): GpuCullMode {
|
|
256
|
+
switch (mode) {
|
|
257
|
+
case CullMode.BACK:
|
|
258
|
+
return "back";
|
|
259
|
+
case CullMode.FRONT:
|
|
260
|
+
return "front";
|
|
261
|
+
default:
|
|
262
|
+
return "none";
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** Converts a front face. */
|
|
267
|
+
public static convertFrontFace(face: FrontFace): GpuFrontFace {
|
|
268
|
+
return face === FrontFace.CW ? "cw" : "ccw";
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Converts a vertex format. */
|
|
272
|
+
public static convertVertexFormat(format: VertexFormat): GpuVertexFormat {
|
|
273
|
+
switch (format) {
|
|
274
|
+
case VertexFormat.FLOAT_32:
|
|
275
|
+
return "float32";
|
|
276
|
+
case VertexFormat.FLOAT_32X2:
|
|
277
|
+
return "float32x2";
|
|
278
|
+
case VertexFormat.FLOAT_32X3:
|
|
279
|
+
return "float32x3";
|
|
280
|
+
case VertexFormat.FLOAT_32X4:
|
|
281
|
+
return "float32x4";
|
|
282
|
+
default:
|
|
283
|
+
throw new Error(`Vertex format ${VertexFormat[format]} is not implemented for WebGPU.`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** Converts a vertex buffer layout. */
|
|
288
|
+
public static convertVertexBufferLayout(layout: IVertexBufferLayout): GpuVertexBufferLayout {
|
|
289
|
+
return {
|
|
290
|
+
arrayStride: layout.arrayStride,
|
|
291
|
+
stepMode: layout.stepMode === VertexStepMode.INSTANCE ? "instance" : "vertex",
|
|
292
|
+
attributes: layout.attributes.map(attribute => ({
|
|
293
|
+
format: WebGpuConverter.convertVertexFormat(attribute.format),
|
|
294
|
+
offset: attribute.offset,
|
|
295
|
+
shaderLocation: attribute.shaderLocation,
|
|
296
|
+
})),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { TextureSamplerFilteringPreset } from "../core/rendering/enums.js";
|
|
2
|
-
import { vec2 } from "gl-matrix";
|
|
3
|
-
import type { IFrameworkConfiguration } from "./IFrameworkConfiguration.js";
|
|
4
|
-
import { PowerPreferenceType } from "./rendering/PowerPreference.js";
|
|
5
|
-
/**
|
|
6
|
-
* The options for configuring the Framework.
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export declare class FrameworkConfiguration implements IFrameworkConfiguration {
|
|
10
|
-
/** @inheritDoc */
|
|
11
|
-
useKtx2: boolean;
|
|
12
|
-
/** @inheritDoc */
|
|
13
|
-
canvas?: HTMLCanvasElement;
|
|
14
|
-
/** @inheritDoc */
|
|
15
|
-
backBufferSize?: vec2;
|
|
16
|
-
/** @inheritDoc */
|
|
17
|
-
textureFiltering?: TextureSamplerFilteringPreset | undefined;
|
|
18
|
-
/** @inheritDoc */
|
|
19
|
-
alpha: boolean;
|
|
20
|
-
/** @inheritDoc */
|
|
21
|
-
powerPreference: PowerPreferenceType;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=FrameworkConfiguration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FrameworkConfiguration.d.ts","sourceRoot":"","sources":["../../src/api/FrameworkConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAC/B,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AAEnE;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,uBAAuB;IAElE,kBAAkB;IAClB,OAAO,UAAS;IAEhB,kBAAkB;IAClB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAE3B,kBAAkB;IAClB,cAAc,CAAC,EAAE,IAAI,CAAC;IAEtB,kBAAkB;IAClB,gBAAgB,CAAC,4CAA0C;IAE3D,kBAAkB;IAClB,KAAK,UAAS;IAEd,kBAAkB;IAClB,eAAe,sBAA+B;CACjD"}
|