super-three 0.184.0 → 0.185.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/build/three.cjs +1260 -927
- package/build/three.core.js +1104 -829
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +156 -98
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +11 -4
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +7538 -3367
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +7538 -3366
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -0
- package/examples/jsm/controls/ArcballControls.js +6 -2
- package/examples/jsm/controls/FirstPersonControls.js +79 -42
- package/examples/jsm/controls/TransformControls.js +68 -15
- package/examples/jsm/csm/CSMFrustum.js +31 -6
- package/examples/jsm/csm/CSMShadowNode.js +4 -1
- package/examples/jsm/effects/AsciiEffect.js +14 -1
- package/examples/jsm/exporters/DRACOExporter.js +27 -6
- package/examples/jsm/exporters/GLTFExporter.js +114 -12
- package/examples/jsm/exporters/PLYExporter.js +286 -73
- package/examples/jsm/exporters/USDZExporter.js +347 -112
- package/examples/jsm/generators/CityGenerator.js +346 -0
- package/examples/jsm/generators/ForestGenerator.js +347 -0
- package/examples/jsm/generators/TerrainGenerator.js +504 -0
- package/examples/jsm/generators/TreeGenerator.js +377 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +253 -0
- package/examples/jsm/generators/city/SkyscraperGenerator.js +1357 -0
- package/examples/jsm/geometries/LoftGeometry.js +355 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +5 -4
- package/examples/jsm/helpers/ViewHelper.js +16 -6
- package/examples/jsm/inspector/Inspector.js +53 -15
- package/examples/jsm/inspector/RendererInspector.js +152 -36
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +1 -1
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -1
- package/examples/jsm/inspector/tabs/Console.js +200 -18
- package/examples/jsm/inspector/tabs/Memory.js +8 -0
- package/examples/jsm/inspector/tabs/Parameters.js +64 -4
- package/examples/jsm/inspector/tabs/Performance.js +21 -6
- package/examples/jsm/inspector/tabs/Settings.js +51 -9
- package/examples/jsm/inspector/tabs/Timeline.js +178 -93
- package/examples/jsm/inspector/tabs/Viewer.js +628 -16
- package/examples/jsm/inspector/ui/Graph.js +162 -25
- package/examples/jsm/inspector/ui/Item.js +92 -13
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +90 -45
- package/examples/jsm/inspector/ui/Style.js +1788 -1401
- package/examples/jsm/inspector/ui/Tab.js +5 -3
- package/examples/jsm/inspector/ui/Values.js +71 -6
- package/examples/jsm/inspector/ui/utils.js +130 -10
- package/examples/jsm/libs/basis/README.md +0 -1
- package/examples/jsm/libs/demuxer_mp4.js +3 -3
- package/examples/jsm/libs/draco/README.md +0 -1
- package/examples/jsm/libs/meshopt_clusterizer.module.js +421 -0
- package/examples/jsm/libs/meshopt_simplifier.module.js +627 -0
- package/examples/jsm/libs/mikktspace.module.js +34 -9
- package/examples/jsm/lighting/ClusteredLighting.js +55 -0
- package/examples/jsm/lighting/LightProbeGrid.js +106 -76
- package/examples/jsm/lines/LineMaterial.js +38 -15
- package/examples/jsm/lines/LineSegments2.js +8 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +8 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +46 -13
- package/examples/jsm/loaders/EXRLoader.js +27 -55
- package/examples/jsm/loaders/HDRLoader.js +6 -28
- package/examples/jsm/loaders/KTX2Loader.js +31 -12
- package/examples/jsm/loaders/LDrawLoader.js +8 -8
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +2 -2
- package/examples/jsm/loaders/LWOLoader.js +4 -0
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +31 -9
- package/examples/jsm/loaders/NRRDLoader.js +3 -3
- package/examples/jsm/loaders/PCDLoader.js +7 -7
- package/examples/jsm/loaders/PLYLoader.js +218 -55
- package/examples/jsm/loaders/SVGLoader.js +547 -495
- package/examples/jsm/loaders/TTFLoader.js +1 -1
- package/examples/jsm/loaders/USDLoader.js +33 -9
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +93 -20
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/loaders/usd/USDComposer.js +52 -19
- package/examples/jsm/misc/TileCreasedNormalsPlugin.js +270 -0
- package/examples/jsm/misc/Volume.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +1 -1
- package/examples/jsm/objects/Reflector.js +2 -3
- package/examples/jsm/objects/Water2Mesh.js +1 -1
- package/examples/jsm/physics/AmmoPhysics.js +15 -8
- package/examples/jsm/physics/RapierPhysics.js +27 -2
- package/examples/jsm/shaders/VolumeShader.js +31 -44
- package/examples/jsm/transpiler/GLSLDecoder.js +6 -6
- package/examples/jsm/transpiler/Linker.js +1 -1
- package/examples/jsm/tsl/display/BloomNode.js +59 -19
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +2 -2
- package/examples/jsm/tsl/display/FXAANode.js +11 -12
- package/examples/jsm/tsl/display/GTAONode.js +34 -13
- package/examples/jsm/tsl/display/GodraysNode.js +1 -1
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +560 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -2
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +912 -0
- package/examples/jsm/tsl/display/SSAAPassNode.js +13 -25
- package/examples/jsm/tsl/display/SSGINode.js +89 -39
- package/examples/jsm/tsl/display/SSRNode.js +829 -132
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +1023 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +622 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +1 -1
- package/examples/jsm/tsl/math/curlNoise.js +107 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +1 -1
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +3 -3
- package/examples/jsm/tsl/utils/GroundedSkybox.js +62 -0
- package/examples/jsm/tsl/utils/RNoise.js +51 -0
- package/examples/jsm/tsl/utils/SpecularHelpers.js +325 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +126 -59
- package/examples/jsm/utils/GeometryCompressionUtils.js +1 -1
- package/examples/jsm/utils/SceneOptimizer.js +1 -1
- package/examples/jsm/webxr/ARButton.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +89 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +2 -2
- package/package.json +7 -7
- package/src/Three.TSL.js +10 -3
- package/src/Three.WebGPU.js +4 -0
- package/src/animation/AnimationAction.js +15 -11
- package/src/animation/AnimationClip.js +0 -139
- package/src/animation/KeyframeTrack.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/Camera.js +2 -2
- package/src/cameras/StereoCamera.js +5 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +29 -7
- package/src/core/Object3D.js +17 -7
- package/src/core/Raycaster.js +1 -1
- package/src/core/RenderTarget.js +15 -2
- package/src/extras/PMREMGenerator.js +6 -4
- package/src/extras/TextureUtils.js +1 -1
- package/src/extras/core/ShapePath.js +149 -160
- package/src/geometries/SphereGeometry.js +8 -3
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +1 -1
- package/src/loaders/DataTextureLoader.js +69 -38
- package/src/loaders/LoadingManager.js +5 -0
- package/src/loaders/MaterialLoader.js +36 -266
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +196 -1
- package/src/materials/MeshBasicMaterial.js +24 -0
- package/src/materials/MeshDepthMaterial.js +10 -0
- package/src/materials/MeshDistanceMaterial.js +10 -0
- package/src/materials/MeshLambertMaterial.js +40 -1
- package/src/materials/MeshMatcapMaterial.js +25 -1
- package/src/materials/MeshNormalMaterial.js +9 -1
- package/src/materials/MeshPhongMaterial.js +40 -1
- package/src/materials/MeshPhysicalMaterial.js +38 -0
- package/src/materials/MeshStandardMaterial.js +42 -1
- package/src/materials/MeshToonMaterial.js +34 -1
- package/src/materials/PointsMaterial.js +7 -0
- package/src/materials/ShaderMaterial.js +86 -0
- package/src/materials/SpriteMaterial.js +7 -0
- package/src/materials/nodes/Line2NodeMaterial.js +378 -322
- package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +0 -9
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +0 -30
- package/src/materials/nodes/MeshSSSNodeMaterial.js +0 -13
- package/src/materials/nodes/MeshStandardNodeMaterial.js +0 -11
- package/src/materials/nodes/NodeMaterial.js +115 -71
- package/src/materials/nodes/SpriteNodeMaterial.js +0 -10
- package/src/materials/nodes/manager/NodeMaterialObserver.js +49 -20
- package/src/math/Box3.js +5 -0
- package/src/math/FrustumArray.js +103 -133
- package/src/math/Interpolant.js +1 -1
- package/src/math/MathUtils.js +2 -2
- package/src/math/Matrix3.js +11 -0
- package/src/math/Matrix4.js +28 -3
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +2 -2
- package/src/math/interpolants/BezierInterpolant.js +4 -6
- package/src/nodes/Nodes.js +2 -5
- package/src/nodes/TSL.js +8 -6
- package/src/nodes/accessors/Arrays.js +4 -4
- package/src/nodes/accessors/Batch.js +108 -0
- package/src/nodes/accessors/Bitangent.js +2 -2
- package/src/nodes/accessors/BufferAttributeNode.js +13 -2
- package/src/nodes/accessors/Camera.js +7 -7
- package/src/nodes/accessors/ClippingNode.js +1 -1
- package/src/nodes/accessors/Instance.js +264 -0
- package/src/nodes/accessors/MaterialNode.js +18 -2
- package/src/nodes/accessors/MaterialProperties.js +4 -3
- package/src/nodes/accessors/{MorphNode.js → Morph.js} +99 -112
- package/src/nodes/accessors/Normal.js +13 -13
- package/src/nodes/accessors/Position.js +5 -1
- package/src/nodes/accessors/ReferenceNode.js +1 -0
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneProperties.js +1 -1
- package/src/nodes/accessors/Skinning.js +263 -0
- package/src/nodes/accessors/StorageBufferNode.js +2 -2
- package/src/nodes/accessors/StorageTexture3DNode.js +100 -0
- package/src/nodes/accessors/StorageTextureNode.js +39 -7
- package/src/nodes/accessors/Tangent.js +4 -4
- package/src/nodes/accessors/TextureNode.js +60 -5
- package/src/nodes/code/FunctionNode.js +2 -16
- package/src/nodes/core/MRTNode.js +7 -2
- package/src/nodes/core/Node.js +39 -2
- package/src/nodes/core/NodeBuilder.js +201 -41
- package/src/nodes/core/NodeUtils.js +13 -13
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/OverrideContextNode.js +153 -0
- package/src/nodes/core/PropertyNode.js +51 -5
- package/src/nodes/core/StackNode.js +56 -34
- package/src/nodes/core/StructNode.js +4 -6
- package/src/nodes/core/StructTypeNode.js +6 -6
- package/src/nodes/core/VarNode.js +8 -0
- package/src/nodes/core/VaryingNode.js +12 -2
- package/src/nodes/display/BlendModes.js +1 -41
- package/src/nodes/display/BumpMapNode.js +6 -1
- package/src/nodes/display/ColorAdjustment.js +10 -9
- package/src/nodes/display/FrontFacingNode.js +38 -9
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +35 -43
- package/src/nodes/display/PremultiplyAlphaFunctions.js +39 -0
- package/src/nodes/display/RenderOutputNode.js +12 -3
- package/src/nodes/functions/VolumetricLightingModel.js +40 -7
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
- package/src/nodes/lighting/EnvironmentNode.js +2 -2
- package/src/nodes/lighting/IESSpotLightNode.js +40 -2
- package/src/nodes/lighting/LightingContextNode.js +10 -2
- package/src/nodes/lighting/LightsNode.js +90 -37
- package/src/nodes/lighting/PointShadowNode.js +6 -1
- package/src/nodes/lighting/ShadowFilterNode.js +21 -52
- package/src/nodes/lighting/ShadowNode.js +34 -14
- package/src/nodes/materialx/lib/mx_noise.js +2 -2
- package/src/nodes/math/ConditionalNode.js +3 -3
- package/src/nodes/math/MathNode.js +39 -11
- package/src/nodes/math/OperatorNode.js +23 -23
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +33 -2
- package/src/nodes/tsl/TSLCore.js +63 -18
- package/src/nodes/utils/EquirectUV.js +30 -5
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/Packing.js +35 -4
- package/src/nodes/utils/RTTNode.js +40 -24
- package/src/nodes/utils/ReflectorNode.js +1 -0
- package/src/nodes/utils/StorageArrayElementNode.js +1 -1
- package/src/objects/BatchedMesh.js +22 -14
- package/src/objects/InstancedMesh.js +0 -11
- package/src/objects/Skeleton.js +0 -9
- package/src/renderers/WebGLRenderer.js +19 -15
- package/src/renderers/common/Backend.js +49 -5
- package/src/renderers/common/Bindings.js +114 -45
- package/src/renderers/common/Buffer.js +9 -0
- package/src/renderers/common/ClippingContext.js +10 -2
- package/src/renderers/common/Info.js +63 -22
- package/src/renderers/common/Lighting.js +53 -5
- package/src/renderers/common/RenderList.js +41 -4
- package/src/renderers/common/RenderObject.js +73 -13
- package/src/renderers/common/Renderer.js +281 -108
- package/src/renderers/common/Sampler.js +16 -48
- package/src/renderers/common/Textures.js +32 -5
- package/src/renderers/common/TimestampQueryPool.js +1 -1
- package/src/renderers/common/UniformsGroup.js +31 -9
- package/src/renderers/common/XRManager.js +340 -22
- package/src/renderers/common/extras/PMREMGenerator.js +15 -38
- package/src/renderers/common/nodes/NodeBuilderState.js +9 -1
- package/src/renderers/common/nodes/NodeLibrary.js +4 -4
- package/src/renderers/common/nodes/NodeManager.js +63 -14
- package/src/renderers/common/nodes/NodeUniformBuffer.js +13 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +13 -4
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +0 -6
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/distance.glsl.js +1 -1
- package/src/renderers/webgl/WebGLOutput.js +2 -1
- package/src/renderers/webgl/WebGLProgram.js +5 -4
- package/src/renderers/webgl/WebGLPrograms.js +12 -5
- package/src/renderers/webgl/WebGLRenderLists.js +9 -1
- package/src/renderers/webgl/WebGLShaderCache.js +5 -11
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUniformsGroups.js +66 -38
- package/src/renderers/webgl-fallback/WebGLBackend.js +84 -25
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +138 -8
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +4 -2
- package/src/renderers/webgpu/WebGPUBackend.js +480 -169
- package/src/renderers/webgpu/descriptors/GPUBindGroupDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUBufferDescriptor.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js +30 -0
- package/src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js +38 -0
- package/src/renderers/webgpu/descriptors/GPUComputePipelineDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js +47 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js +50 -0
- package/src/renderers/webgpu/descriptors/GPUExtent3D.js +51 -0
- package/src/renderers/webgpu/descriptors/GPUPipelineLayoutDescriptor.js +39 -0
- package/src/renderers/webgpu/descriptors/GPUQuerySetDescriptor.js +47 -0
- package/src/renderers/webgpu/descriptors/GPURenderBundleEncoderDescriptor.js +74 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDepthStencilAttachment.js +99 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDescriptor.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassTimestampWrites.js +49 -0
- package/src/renderers/webgpu/descriptors/GPURenderPipelineDescriptor.js +130 -0
- package/src/renderers/webgpu/descriptors/GPUSamplerDescriptor.js +119 -0
- package/src/renderers/webgpu/descriptors/GPUShaderModuleDescriptor.js +46 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferInfo.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferLayout.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyTextureInfo.js +61 -0
- package/src/renderers/webgpu/descriptors/GPUTextureDescriptor.js +99 -0
- package/src/renderers/webgpu/descriptors/GPUTextureViewDescriptor.js +108 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +164 -7
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +98 -38
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -68
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +164 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +158 -95
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +297 -141
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +33 -18
- package/src/renderers/webgpu/utils/WebGPUUtils.js +38 -3
- package/src/textures/DepthTexture.js +1 -1
- package/src/textures/ExternalTexture.js +0 -3
- package/examples/fonts/LICENSE +0 -13
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +0 -91
- package/examples/fonts/README.md +0 -11
- package/examples/fonts/droid/NOTICE +0 -190
- package/examples/fonts/droid/README.txt +0 -18
- package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
- package/examples/fonts/gentilis_bold.typeface.json +0 -1
- package/examples/fonts/gentilis_regular.typeface.json +0 -1
- package/examples/fonts/helvetiker_bold.typeface.json +0 -1
- package/examples/fonts/helvetiker_regular.typeface.json +0 -1
- package/examples/fonts/optimer_bold.typeface.json +0 -1
- package/examples/fonts/optimer_regular.typeface.json +0 -1
- package/examples/fonts/ttf/README.md +0 -9
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/inspector/extensions/extensions.json +0 -6
- package/examples/jsm/libs/ammo.wasm.js +0 -822
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
- package/examples/jsm/libs/lottie_canvas.module.js +0 -14849
- package/examples/jsm/libs/opentype.module.js +0 -14506
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lighting/TiledLighting.js +0 -42
- package/examples/jsm/tsl/display/AnamorphicNode.js +0 -293
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +0 -442
- package/src/nodes/accessors/BatchNode.js +0 -163
- package/src/nodes/accessors/InstanceNode.js +0 -349
- package/src/nodes/accessors/InstancedMeshNode.js +0 -50
- package/src/nodes/accessors/SkinningNode.js +0 -328
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import 'https://greggman.github.io/webgpu-avoid-redundant-state-setting/webgpu-check-redundant-state-setting.js';
|
|
3
|
-
//*/
|
|
1
|
+
// debugger tools
|
|
2
|
+
// import 'https://greggman.github.io/webgpu-avoid-redundant-state-setting/webgpu-check-redundant-state-setting.js';
|
|
4
3
|
|
|
5
|
-
import { GPUFeatureName, GPULoadOp, GPUStoreOp, GPUIndexFormat, GPUTextureViewDimension, GPUFeatureMap } from './utils/WebGPUConstants.js';
|
|
4
|
+
import { GPUFeatureName, GPULoadOp, GPUStoreOp, GPUIndexFormat, GPUTextureViewDimension, GPUFeatureMap, GPUShaderStage } from './utils/WebGPUConstants.js';
|
|
6
5
|
|
|
7
6
|
import WGSLNodeBuilder from './nodes/WGSLNodeBuilder.js';
|
|
8
7
|
import Backend from '../common/Backend.js';
|
|
9
8
|
|
|
10
|
-
import WebGPUUtils from './utils/WebGPUUtils.js';
|
|
9
|
+
import WebGPUUtils, { submit } from './utils/WebGPUUtils.js';
|
|
11
10
|
import WebGPUAttributeUtils from './utils/WebGPUAttributeUtils.js';
|
|
12
11
|
import WebGPUBindingUtils from './utils/WebGPUBindingUtils.js';
|
|
13
12
|
import WebGPUCapabilities from './utils/WebGPUCapabilities.js';
|
|
@@ -18,7 +17,30 @@ import { WebGPUCoordinateSystem, TimestampQuery, REVISION, HalfFloatType, Compat
|
|
|
18
17
|
import WebGPUTimestampQueryPool from './utils/WebGPUTimestampQueryPool.js';
|
|
19
18
|
import { error } from '../../utils.js';
|
|
20
19
|
|
|
20
|
+
import GPUBufferDescriptor from './descriptors/GPUBufferDescriptor.js';
|
|
21
|
+
import GPUCommandEncoderDescriptor from './descriptors/GPUCommandEncoderDescriptor.js';
|
|
22
|
+
import GPUComputePassDescriptor from './descriptors/GPUComputePassDescriptor.js';
|
|
23
|
+
import GPUQuerySetDescriptor from './descriptors/GPUQuerySetDescriptor.js';
|
|
24
|
+
import GPUShaderModuleDescriptor from './descriptors/GPUShaderModuleDescriptor.js';
|
|
25
|
+
import GPURenderPassColorAttachment from './descriptors/GPURenderPassColorAttachment.js';
|
|
26
|
+
import GPURenderPassDepthStencilAttachment from './descriptors/GPURenderPassDepthStencilAttachment.js';
|
|
27
|
+
import GPURenderPassDescriptor from './descriptors/GPURenderPassDescriptor.js';
|
|
28
|
+
import GPURenderPassTimestampWrites from './descriptors/GPURenderPassTimestampWrites.js';
|
|
29
|
+
import GPUTexelCopyTextureInfo from './descriptors/GPUTexelCopyTextureInfo.js';
|
|
30
|
+
import GPUTextureViewDescriptor from './descriptors/GPUTextureViewDescriptor.js';
|
|
31
|
+
import GPUExtent3D from './descriptors/GPUExtent3D.js';
|
|
32
|
+
|
|
21
33
|
const _clearValue = { r: 0, g: 0, b: 0, a: 1 };
|
|
34
|
+
const _bufferDescriptor = new GPUBufferDescriptor();
|
|
35
|
+
const _commandEncoderDescriptor = new GPUCommandEncoderDescriptor();
|
|
36
|
+
const _computePassDescriptor = new GPUComputePassDescriptor();
|
|
37
|
+
const _querySetDescriptor = new GPUQuerySetDescriptor();
|
|
38
|
+
const _shaderModuleDescriptor = new GPUShaderModuleDescriptor();
|
|
39
|
+
const _renderPassTimestampWrites = new GPURenderPassTimestampWrites();
|
|
40
|
+
const _texelCopyTextureInfoSrc = new GPUTexelCopyTextureInfo();
|
|
41
|
+
const _texelCopyTextureInfoDst = new GPUTexelCopyTextureInfo();
|
|
42
|
+
const _viewDescriptor = new GPUTextureViewDescriptor();
|
|
43
|
+
const _extent3D = new GPUExtent3D();
|
|
22
44
|
|
|
23
45
|
/**
|
|
24
46
|
* A backend implementation targeting WebGPU.
|
|
@@ -188,14 +210,15 @@ class WebGPUBackend extends Backend {
|
|
|
188
210
|
|
|
189
211
|
const adapterOptions = {
|
|
190
212
|
powerPreference: parameters.powerPreference,
|
|
191
|
-
featureLevel: 'compatibility'
|
|
213
|
+
featureLevel: 'compatibility',
|
|
214
|
+
xrCompatible: renderer.xr.enabled
|
|
192
215
|
};
|
|
193
216
|
|
|
194
217
|
const adapter = ( typeof navigator !== 'undefined' ) ? await navigator.gpu.requestAdapter( adapterOptions ) : null;
|
|
195
218
|
|
|
196
219
|
if ( adapter === null ) {
|
|
197
220
|
|
|
198
|
-
throw new Error( 'WebGPUBackend: Unable to create WebGPU adapter.' );
|
|
221
|
+
throw new Error( 'THREE.WebGPUBackend: Unable to create WebGPU adapter.' );
|
|
199
222
|
|
|
200
223
|
}
|
|
201
224
|
|
|
@@ -251,6 +274,21 @@ class WebGPUBackend extends Backend {
|
|
|
251
274
|
|
|
252
275
|
} );
|
|
253
276
|
|
|
277
|
+
device.onuncapturederror = ( event ) => {
|
|
278
|
+
|
|
279
|
+
const gpuError = event.error;
|
|
280
|
+
const type = gpuError && gpuError.constructor ? gpuError.constructor.name : 'GPUError';
|
|
281
|
+
const message = ( gpuError && gpuError.message ) || 'Unknown uncaptured GPU error';
|
|
282
|
+
|
|
283
|
+
renderer.onError( {
|
|
284
|
+
api: 'WebGPU',
|
|
285
|
+
type,
|
|
286
|
+
message,
|
|
287
|
+
originalEvent: event
|
|
288
|
+
} );
|
|
289
|
+
|
|
290
|
+
};
|
|
291
|
+
|
|
254
292
|
this.device = device;
|
|
255
293
|
|
|
256
294
|
this.trackTimestamp = this.trackTimestamp && this.hasFeature( GPUFeatureName.TimestampQuery );
|
|
@@ -259,6 +297,25 @@ class WebGPUBackend extends Backend {
|
|
|
259
297
|
|
|
260
298
|
}
|
|
261
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Registers external GPU textures from `XRGPUBinding` for use in rendering.
|
|
302
|
+
*
|
|
303
|
+
* @param {RenderTarget} renderTarget - The render target to register the textures for.
|
|
304
|
+
* @param {GPUTexture} colorTexture - The shared XR color GPUTexture.
|
|
305
|
+
* @param {?Array<Object>} [viewDescriptors=null] - Optional view descriptors, one per XR view.
|
|
306
|
+
*/
|
|
307
|
+
setXRRenderTargetTextures( renderTarget, colorTexture, viewDescriptors = null ) {
|
|
308
|
+
|
|
309
|
+
this.set( renderTarget.texture, {
|
|
310
|
+
texture: colorTexture,
|
|
311
|
+
format: colorTexture.format,
|
|
312
|
+
externalTexture: true,
|
|
313
|
+
xrViewDescriptors: viewDescriptors,
|
|
314
|
+
initialized: true
|
|
315
|
+
} );
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
262
319
|
/**
|
|
263
320
|
* A reference to the context.
|
|
264
321
|
*
|
|
@@ -323,6 +380,18 @@ class WebGPUBackend extends Backend {
|
|
|
323
380
|
|
|
324
381
|
}
|
|
325
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Whether the backend supports query timestamps or not.
|
|
385
|
+
*
|
|
386
|
+
* @type {boolean}
|
|
387
|
+
* @readonly
|
|
388
|
+
*/
|
|
389
|
+
get hasTimestamp() {
|
|
390
|
+
|
|
391
|
+
return true;
|
|
392
|
+
|
|
393
|
+
}
|
|
394
|
+
|
|
326
395
|
/**
|
|
327
396
|
* This method performs a readback operation by moving buffer data from
|
|
328
397
|
* a storage buffer attribute from the GPU to the CPU. ReadbackBuffer can
|
|
@@ -374,17 +443,14 @@ class WebGPUBackend extends Backend {
|
|
|
374
443
|
|
|
375
444
|
if ( descriptor === undefined || canvasData.samples !== samples ) {
|
|
376
445
|
|
|
377
|
-
descriptor =
|
|
378
|
-
|
|
379
|
-
view: null
|
|
380
|
-
} ]
|
|
381
|
-
};
|
|
446
|
+
descriptor = new GPURenderPassDescriptor();
|
|
447
|
+
descriptor.colorAttachments.push( new GPURenderPassColorAttachment() );
|
|
382
448
|
|
|
383
449
|
if ( renderer.depth === true || renderer.stencil === true ) {
|
|
384
450
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
451
|
+
const depthStencilAttachment = new GPURenderPassDepthStencilAttachment();
|
|
452
|
+
depthStencilAttachment.view = this.textureUtils.getDepthBuffer( renderer.depth, renderer.stencil ).createView();
|
|
453
|
+
descriptor.depthStencilAttachment = depthStencilAttachment;
|
|
388
454
|
|
|
389
455
|
}
|
|
390
456
|
|
|
@@ -422,7 +488,7 @@ class WebGPUBackend extends Backend {
|
|
|
422
488
|
}
|
|
423
489
|
|
|
424
490
|
/**
|
|
425
|
-
*
|
|
491
|
+
* Returns whether the render target is a render target array with depth 2D array texture.
|
|
426
492
|
*
|
|
427
493
|
* @param {RenderContext} renderContext - The render context.
|
|
428
494
|
* @return {boolean} Whether the render target is a render target array with depth 2D array texture.
|
|
@@ -431,7 +497,77 @@ class WebGPUBackend extends Backend {
|
|
|
431
497
|
*/
|
|
432
498
|
_isRenderCameraDepthArray( renderContext ) {
|
|
433
499
|
|
|
434
|
-
|
|
500
|
+
const camera = renderContext.camera;
|
|
501
|
+
|
|
502
|
+
return renderContext.depthTexture && renderContext.depthTexture.isArrayTexture === true && camera !== null && camera.isArrayCamera === true;
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Returns whether the current render context references external textures.
|
|
508
|
+
*
|
|
509
|
+
* External textures can change every frame, so their descriptors must not be cached.
|
|
510
|
+
*
|
|
511
|
+
* @private
|
|
512
|
+
* @param {RenderContext} renderContext - The render context.
|
|
513
|
+
* @return {boolean} Whether the render context uses external textures.
|
|
514
|
+
*/
|
|
515
|
+
_hasExternalTexture( renderContext ) {
|
|
516
|
+
|
|
517
|
+
const textures = renderContext.textures;
|
|
518
|
+
|
|
519
|
+
if ( textures === null ) return false;
|
|
520
|
+
|
|
521
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
522
|
+
|
|
523
|
+
if ( this.get( textures[ i ] ).externalTexture === true ) return true;
|
|
524
|
+
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return false;
|
|
528
|
+
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Creates attachment views for an external texture render target.
|
|
533
|
+
*
|
|
534
|
+
* @private
|
|
535
|
+
* @param {RenderContext} renderContext - The render context.
|
|
536
|
+
* @param {Object} textureData - The backend data for the texture.
|
|
537
|
+
* @return {Array<Object>} The attachment view descriptors.
|
|
538
|
+
*/
|
|
539
|
+
_createExternalTextureViews( renderContext, textureData ) {
|
|
540
|
+
|
|
541
|
+
const textureViews = [];
|
|
542
|
+
const camera = renderContext.camera;
|
|
543
|
+
|
|
544
|
+
if ( textureData.xrViewDescriptors && camera !== null && camera.isArrayCamera === true ) {
|
|
545
|
+
|
|
546
|
+
for ( let i = 0; i < textureData.xrViewDescriptors.length; i ++ ) {
|
|
547
|
+
|
|
548
|
+
textureViews.push( {
|
|
549
|
+
view: textureData.texture.createView( textureData.xrViewDescriptors[ i ] ),
|
|
550
|
+
resolveTarget: undefined,
|
|
551
|
+
depthSlice: undefined
|
|
552
|
+
} );
|
|
553
|
+
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
} else {
|
|
557
|
+
|
|
558
|
+
textureViews.push( {
|
|
559
|
+
view: textureData.texture.createView( {
|
|
560
|
+
dimension: GPUTextureViewDimension.TwoD,
|
|
561
|
+
baseArrayLayer: renderContext.activeCubeFace,
|
|
562
|
+
arrayLayerCount: 1
|
|
563
|
+
} ),
|
|
564
|
+
resolveTarget: undefined,
|
|
565
|
+
depthSlice: undefined
|
|
566
|
+
} );
|
|
567
|
+
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
return textureViews;
|
|
435
571
|
|
|
436
572
|
}
|
|
437
573
|
|
|
@@ -447,13 +583,15 @@ class WebGPUBackend extends Backend {
|
|
|
447
583
|
|
|
448
584
|
const renderTarget = renderContext.renderTarget;
|
|
449
585
|
const renderTargetData = this.get( renderTarget );
|
|
586
|
+
const hasExternalTexture = this._hasExternalTexture( renderContext );
|
|
450
587
|
|
|
451
588
|
let descriptors = renderTargetData.descriptors;
|
|
452
589
|
|
|
453
590
|
if ( descriptors === undefined ||
|
|
454
591
|
renderTargetData.width !== renderTarget.width ||
|
|
455
592
|
renderTargetData.height !== renderTarget.height ||
|
|
456
|
-
renderTargetData.samples !== renderTarget.samples
|
|
593
|
+
renderTargetData.samples !== renderTarget.samples ||
|
|
594
|
+
hasExternalTexture
|
|
457
595
|
) {
|
|
458
596
|
|
|
459
597
|
descriptors = {};
|
|
@@ -465,7 +603,7 @@ class WebGPUBackend extends Backend {
|
|
|
465
603
|
const cacheKey = renderContext.getCacheKey();
|
|
466
604
|
let descriptorBase = descriptors[ cacheKey ];
|
|
467
605
|
|
|
468
|
-
if ( descriptorBase === undefined ) {
|
|
606
|
+
if ( descriptorBase === undefined || hasExternalTexture ) {
|
|
469
607
|
|
|
470
608
|
const textures = renderContext.textures;
|
|
471
609
|
const textureViews = [];
|
|
@@ -478,22 +616,26 @@ class WebGPUBackend extends Backend {
|
|
|
478
616
|
|
|
479
617
|
const textureData = this.get( textures[ i ] );
|
|
480
618
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
619
|
+
if ( textureData.externalTexture === true ) {
|
|
620
|
+
|
|
621
|
+
textureViews.push( ...this._createExternalTextureViews( renderContext, textureData ) );
|
|
622
|
+
continue;
|
|
623
|
+
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
_viewDescriptor.label = `colorAttachment_${ i }`;
|
|
627
|
+
_viewDescriptor.baseMipLevel = renderContext.activeMipmapLevel;
|
|
628
|
+
_viewDescriptor.mipLevelCount = 1;
|
|
629
|
+
_viewDescriptor.baseArrayLayer = renderContext.activeCubeFace;
|
|
630
|
+
_viewDescriptor.arrayLayerCount = 1;
|
|
631
|
+
_viewDescriptor.dimension = GPUTextureViewDimension.TwoD;
|
|
489
632
|
|
|
490
633
|
if ( renderTarget.isRenderTarget3D ) {
|
|
491
634
|
|
|
492
635
|
sliceIndex = renderContext.activeCubeFace;
|
|
493
636
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
|
|
637
|
+
_viewDescriptor.baseArrayLayer = 0;
|
|
638
|
+
_viewDescriptor.dimension = GPUTextureViewDimension.ThreeD;
|
|
497
639
|
|
|
498
640
|
} else if ( renderTarget.isRenderTarget && textures[ i ].image.depth > 1 ) {
|
|
499
641
|
|
|
@@ -502,13 +644,11 @@ class WebGPUBackend extends Backend {
|
|
|
502
644
|
const cameras = renderContext.camera.cameras;
|
|
503
645
|
for ( let layer = 0; layer < cameras.length; layer ++ ) {
|
|
504
646
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
};
|
|
511
|
-
const textureView = textureData.texture.createView( layerViewDescriptor );
|
|
647
|
+
_viewDescriptor.baseArrayLayer = layer;
|
|
648
|
+
_viewDescriptor.arrayLayerCount = 1;
|
|
649
|
+
_viewDescriptor.dimension = GPUTextureViewDimension.TwoD;
|
|
650
|
+
|
|
651
|
+
const textureView = textureData.texture.createView( _viewDescriptor );
|
|
512
652
|
textureViews.push( {
|
|
513
653
|
view: textureView,
|
|
514
654
|
resolveTarget: undefined,
|
|
@@ -519,8 +659,7 @@ class WebGPUBackend extends Backend {
|
|
|
519
659
|
|
|
520
660
|
} else {
|
|
521
661
|
|
|
522
|
-
|
|
523
|
-
viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
|
|
662
|
+
_viewDescriptor.dimension = GPUTextureViewDimension.TwoDArray;
|
|
524
663
|
|
|
525
664
|
}
|
|
526
665
|
|
|
@@ -528,7 +667,7 @@ class WebGPUBackend extends Backend {
|
|
|
528
667
|
|
|
529
668
|
if ( isRenderCameraDepthArray !== true ) {
|
|
530
669
|
|
|
531
|
-
const textureView = textureData.texture.createView(
|
|
670
|
+
const textureView = textureData.texture.createView( _viewDescriptor );
|
|
532
671
|
|
|
533
672
|
let view, resolveTarget;
|
|
534
673
|
|
|
@@ -552,23 +691,46 @@ class WebGPUBackend extends Backend {
|
|
|
552
691
|
|
|
553
692
|
}
|
|
554
693
|
|
|
694
|
+
_viewDescriptor.reset();
|
|
695
|
+
|
|
555
696
|
}
|
|
556
697
|
|
|
557
|
-
|
|
698
|
+
const colorAttachments = [];
|
|
699
|
+
|
|
700
|
+
for ( let i = 0; i < textureViews.length; i ++ ) {
|
|
701
|
+
|
|
702
|
+
const viewInfo = textureViews[ i ];
|
|
703
|
+
const attachment = new GPURenderPassColorAttachment();
|
|
704
|
+
attachment.view = viewInfo.view;
|
|
705
|
+
attachment.depthSlice = viewInfo.depthSlice;
|
|
706
|
+
attachment.resolveTarget = viewInfo.resolveTarget;
|
|
707
|
+
colorAttachments.push( attachment );
|
|
708
|
+
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
descriptorBase = {
|
|
712
|
+
textureViews,
|
|
713
|
+
colorAttachments,
|
|
714
|
+
descriptor: new GPURenderPassDescriptor()
|
|
715
|
+
};
|
|
558
716
|
|
|
559
717
|
if ( renderContext.depth ) {
|
|
560
718
|
|
|
561
719
|
const depthTextureData = this.get( renderContext.depthTexture );
|
|
562
|
-
|
|
720
|
+
|
|
563
721
|
if ( renderContext.depthTexture.isArrayTexture || renderContext.depthTexture.isCubeTexture ) {
|
|
564
722
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
723
|
+
_viewDescriptor.dimension = GPUTextureViewDimension.TwoD;
|
|
724
|
+
_viewDescriptor.arrayLayerCount = 1;
|
|
725
|
+
_viewDescriptor.baseArrayLayer = renderContext.activeCubeFace;
|
|
568
726
|
|
|
569
727
|
}
|
|
570
728
|
|
|
571
|
-
|
|
729
|
+
const depthStencilAttachment = new GPURenderPassDepthStencilAttachment();
|
|
730
|
+
depthStencilAttachment.view = depthTextureData.texture.createView( _viewDescriptor );
|
|
731
|
+
descriptorBase.depthStencilAttachment = depthStencilAttachment;
|
|
732
|
+
|
|
733
|
+
_viewDescriptor.reset();
|
|
572
734
|
|
|
573
735
|
}
|
|
574
736
|
|
|
@@ -582,14 +744,14 @@ class WebGPUBackend extends Backend {
|
|
|
582
744
|
|
|
583
745
|
}
|
|
584
746
|
|
|
585
|
-
const descriptor =
|
|
586
|
-
colorAttachments: []
|
|
587
|
-
};
|
|
747
|
+
const descriptor = descriptorBase.descriptor;
|
|
588
748
|
|
|
589
|
-
|
|
590
|
-
for ( let i = 0; i < descriptorBase.textureViews.length; i ++ ) {
|
|
749
|
+
descriptor.reset();
|
|
591
750
|
|
|
592
|
-
|
|
751
|
+
// Apply dynamic properties to cached attachments
|
|
752
|
+
for ( let i = 0; i < descriptorBase.colorAttachments.length; i ++ ) {
|
|
753
|
+
|
|
754
|
+
const attachment = descriptorBase.colorAttachments[ i ];
|
|
593
755
|
|
|
594
756
|
let clearValue = { r: 0, g: 0, b: 0, a: 1 };
|
|
595
757
|
if ( i === 0 && colorAttachmentsConfig.clearValue ) {
|
|
@@ -598,22 +760,17 @@ class WebGPUBackend extends Backend {
|
|
|
598
760
|
|
|
599
761
|
}
|
|
600
762
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
storeOp: colorAttachmentsConfig.storeOp || GPUStoreOp.Store,
|
|
607
|
-
clearValue: clearValue
|
|
608
|
-
} );
|
|
763
|
+
attachment.loadOp = colorAttachmentsConfig.loadOp || GPULoadOp.Load;
|
|
764
|
+
attachment.storeOp = colorAttachmentsConfig.storeOp || GPUStoreOp.Store;
|
|
765
|
+
attachment.clearValue = clearValue;
|
|
766
|
+
|
|
767
|
+
descriptor.colorAttachments.push( attachment );
|
|
609
768
|
|
|
610
769
|
}
|
|
611
770
|
|
|
612
|
-
if ( descriptorBase.
|
|
771
|
+
if ( descriptorBase.depthStencilAttachment ) {
|
|
613
772
|
|
|
614
|
-
descriptor.depthStencilAttachment =
|
|
615
|
-
view: descriptorBase.depthStencilView
|
|
616
|
-
};
|
|
773
|
+
descriptor.depthStencilAttachment = descriptorBase.depthStencilAttachment;
|
|
617
774
|
|
|
618
775
|
}
|
|
619
776
|
|
|
@@ -651,7 +808,13 @@ class WebGPUBackend extends Backend {
|
|
|
651
808
|
|
|
652
809
|
//
|
|
653
810
|
|
|
654
|
-
|
|
811
|
+
_querySetDescriptor.label = `occlusionQuerySet_${ renderContext.id }`;
|
|
812
|
+
_querySetDescriptor.type = 'occlusion';
|
|
813
|
+
_querySetDescriptor.count = occlusionQueryCount;
|
|
814
|
+
|
|
815
|
+
occlusionQuerySet = device.createQuerySet( _querySetDescriptor );
|
|
816
|
+
|
|
817
|
+
_querySetDescriptor.reset();
|
|
655
818
|
|
|
656
819
|
renderContextData.occlusionQuerySet = occlusionQuerySet;
|
|
657
820
|
renderContextData.occlusionQueryIndex = 0;
|
|
@@ -750,7 +913,7 @@ class WebGPUBackend extends Backend {
|
|
|
750
913
|
|
|
751
914
|
}
|
|
752
915
|
|
|
753
|
-
|
|
916
|
+
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
754
917
|
|
|
755
918
|
}
|
|
756
919
|
|
|
@@ -767,15 +930,17 @@ class WebGPUBackend extends Backend {
|
|
|
767
930
|
|
|
768
931
|
}
|
|
769
932
|
|
|
770
|
-
|
|
933
|
+
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
771
934
|
|
|
772
935
|
}
|
|
773
936
|
|
|
774
937
|
//
|
|
775
938
|
|
|
776
|
-
|
|
939
|
+
_commandEncoderDescriptor.label = 'renderContext_' + renderContext.id;
|
|
940
|
+
const encoder = device.createCommandEncoder( _commandEncoderDescriptor );
|
|
941
|
+
_commandEncoderDescriptor.reset();
|
|
777
942
|
|
|
778
|
-
//
|
|
943
|
+
// Layered render targets: prepare bundle encoders for each camera in the array camera.
|
|
779
944
|
|
|
780
945
|
if ( this._isRenderCameraDepthArray( renderContext ) === true ) {
|
|
781
946
|
|
|
@@ -783,11 +948,11 @@ class WebGPUBackend extends Backend {
|
|
|
783
948
|
|
|
784
949
|
if ( ! renderContextData.layerDescriptors || renderContextData.layerDescriptors.length !== cameras.length ) {
|
|
785
950
|
|
|
786
|
-
this.
|
|
951
|
+
this._createArrayCameraLayerDescriptors( renderContext, renderContextData, descriptor, cameras );
|
|
787
952
|
|
|
788
953
|
} else {
|
|
789
954
|
|
|
790
|
-
this.
|
|
955
|
+
this._updateArrayCameraLayerDescriptors( renderContext, renderContextData, cameras );
|
|
791
956
|
|
|
792
957
|
}
|
|
793
958
|
|
|
@@ -848,8 +1013,7 @@ class WebGPUBackend extends Backend {
|
|
|
848
1013
|
}
|
|
849
1014
|
|
|
850
1015
|
/**
|
|
851
|
-
*
|
|
852
|
-
* to prepare for rendering to a depth array texture.
|
|
1016
|
+
* Creates render pass descriptors for each camera in an array camera.
|
|
853
1017
|
*
|
|
854
1018
|
* @param {RenderContext} renderContext - The render context.
|
|
855
1019
|
* @param {Object} renderContextData - The render context data.
|
|
@@ -858,7 +1022,7 @@ class WebGPUBackend extends Backend {
|
|
|
858
1022
|
*
|
|
859
1023
|
* @private
|
|
860
1024
|
*/
|
|
861
|
-
|
|
1025
|
+
_createArrayCameraLayerDescriptors( renderContext, renderContextData, descriptor, cameras ) {
|
|
862
1026
|
|
|
863
1027
|
const depthStencilAttachment = descriptor.depthStencilAttachment;
|
|
864
1028
|
renderContextData.layerDescriptors = [];
|
|
@@ -872,13 +1036,21 @@ class WebGPUBackend extends Backend {
|
|
|
872
1036
|
|
|
873
1037
|
for ( let i = 0; i < cameras.length; i ++ ) {
|
|
874
1038
|
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1039
|
+
const sourceAttachment = descriptor.colorAttachments[ 0 ];
|
|
1040
|
+
|
|
1041
|
+
const layerColorAttachment = new GPURenderPassColorAttachment();
|
|
1042
|
+
layerColorAttachment.view = descriptor.colorAttachments[ i ].view;
|
|
1043
|
+
layerColorAttachment.depthSlice = sourceAttachment.depthSlice;
|
|
1044
|
+
layerColorAttachment.resolveTarget = sourceAttachment.resolveTarget;
|
|
1045
|
+
layerColorAttachment.loadOp = sourceAttachment.loadOp;
|
|
1046
|
+
layerColorAttachment.storeOp = sourceAttachment.storeOp;
|
|
1047
|
+
layerColorAttachment.clearValue = sourceAttachment.clearValue;
|
|
1048
|
+
|
|
1049
|
+
const layerDescriptor = new GPURenderPassDescriptor();
|
|
1050
|
+
layerDescriptor.label = descriptor.label;
|
|
1051
|
+
layerDescriptor.occlusionQuerySet = descriptor.occlusionQuerySet;
|
|
1052
|
+
layerDescriptor.timestampWrites = descriptor.timestampWrites;
|
|
1053
|
+
layerDescriptor.colorAttachments.push( layerColorAttachment );
|
|
882
1054
|
|
|
883
1055
|
if ( descriptor.depthStencilAttachment ) {
|
|
884
1056
|
|
|
@@ -886,32 +1058,45 @@ class WebGPUBackend extends Backend {
|
|
|
886
1058
|
|
|
887
1059
|
if ( ! depthTextureData.viewCache[ layerIndex ] ) {
|
|
888
1060
|
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1061
|
+
_viewDescriptor.dimension = GPUTextureViewDimension.TwoD;
|
|
1062
|
+
_viewDescriptor.baseArrayLayer = i;
|
|
1063
|
+
_viewDescriptor.arrayLayerCount = 1;
|
|
1064
|
+
|
|
1065
|
+
depthTextureData.viewCache[ layerIndex ] = depthTextureData.texture.createView( _viewDescriptor );
|
|
1066
|
+
|
|
1067
|
+
_viewDescriptor.reset();
|
|
894
1068
|
|
|
895
1069
|
}
|
|
896
1070
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
};
|
|
1071
|
+
const layerDepthStencilAttachment = new GPURenderPassDepthStencilAttachment();
|
|
1072
|
+
layerDepthStencilAttachment.view = depthTextureData.viewCache[ layerIndex ];
|
|
1073
|
+
layerDepthStencilAttachment.depthLoadOp = depthStencilAttachment.depthLoadOp || GPULoadOp.Clear;
|
|
1074
|
+
layerDepthStencilAttachment.depthStoreOp = depthStencilAttachment.depthStoreOp || GPUStoreOp.Store;
|
|
1075
|
+
layerDepthStencilAttachment.depthClearValue = depthStencilAttachment.depthClearValue || 1.0;
|
|
903
1076
|
|
|
904
1077
|
if ( renderContext.stencil ) {
|
|
905
1078
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
1079
|
+
layerDepthStencilAttachment.stencilLoadOp = depthStencilAttachment.stencilLoadOp;
|
|
1080
|
+
layerDepthStencilAttachment.stencilStoreOp = depthStencilAttachment.stencilStoreOp;
|
|
1081
|
+
layerDepthStencilAttachment.stencilClearValue = depthStencilAttachment.stencilClearValue;
|
|
909
1082
|
|
|
910
1083
|
}
|
|
911
1084
|
|
|
1085
|
+
layerDescriptor.depthStencilAttachment = layerDepthStencilAttachment;
|
|
1086
|
+
|
|
912
1087
|
} else {
|
|
913
1088
|
|
|
914
|
-
|
|
1089
|
+
const layerDepthStencilAttachment = new GPURenderPassDepthStencilAttachment();
|
|
1090
|
+
layerDepthStencilAttachment.view = depthStencilAttachment.view;
|
|
1091
|
+
layerDepthStencilAttachment.depthLoadOp = depthStencilAttachment.depthLoadOp;
|
|
1092
|
+
layerDepthStencilAttachment.depthStoreOp = depthStencilAttachment.depthStoreOp;
|
|
1093
|
+
layerDepthStencilAttachment.depthClearValue = depthStencilAttachment.depthClearValue;
|
|
1094
|
+
layerDepthStencilAttachment.depthReadOnly = depthStencilAttachment.depthReadOnly;
|
|
1095
|
+
layerDepthStencilAttachment.stencilLoadOp = depthStencilAttachment.stencilLoadOp;
|
|
1096
|
+
layerDepthStencilAttachment.stencilStoreOp = depthStencilAttachment.stencilStoreOp;
|
|
1097
|
+
layerDepthStencilAttachment.stencilClearValue = depthStencilAttachment.stencilClearValue;
|
|
1098
|
+
layerDepthStencilAttachment.stencilReadOnly = depthStencilAttachment.stencilReadOnly;
|
|
1099
|
+
layerDescriptor.depthStencilAttachment = layerDepthStencilAttachment;
|
|
915
1100
|
|
|
916
1101
|
}
|
|
917
1102
|
|
|
@@ -922,15 +1107,14 @@ class WebGPUBackend extends Backend {
|
|
|
922
1107
|
}
|
|
923
1108
|
|
|
924
1109
|
/**
|
|
925
|
-
*
|
|
926
|
-
* to prepare for rendering to a depth array texture.
|
|
1110
|
+
* Updates render pass descriptors for each camera in an array camera.
|
|
927
1111
|
*
|
|
928
1112
|
* @param {RenderContext} renderContext - The render context.
|
|
929
1113
|
* @param {Object} renderContextData - The render context data.
|
|
930
1114
|
* @param {ArrayCamera} cameras - The array camera.
|
|
931
1115
|
*
|
|
932
1116
|
*/
|
|
933
|
-
|
|
1117
|
+
_updateArrayCameraLayerDescriptors( renderContext, renderContextData, cameras ) {
|
|
934
1118
|
|
|
935
1119
|
for ( let i = 0; i < cameras.length; i ++ ) {
|
|
936
1120
|
|
|
@@ -999,7 +1183,7 @@ class WebGPUBackend extends Backend {
|
|
|
999
1183
|
|
|
1000
1184
|
}
|
|
1001
1185
|
|
|
1002
|
-
//
|
|
1186
|
+
// Layered render targets: execute the bundle for each layer.
|
|
1003
1187
|
|
|
1004
1188
|
const encoder = renderContextData.encoder;
|
|
1005
1189
|
|
|
@@ -1059,12 +1243,12 @@ class WebGPUBackend extends Backend {
|
|
|
1059
1243
|
|
|
1060
1244
|
if ( queryResolveBuffer === undefined ) {
|
|
1061
1245
|
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
);
|
|
1246
|
+
_bufferDescriptor.size = bufferSize;
|
|
1247
|
+
_bufferDescriptor.usage = GPUBufferUsage.QUERY_RESOLVE | GPUBufferUsage.COPY_SRC;
|
|
1248
|
+
|
|
1249
|
+
queryResolveBuffer = this.device.createBuffer( _bufferDescriptor );
|
|
1250
|
+
|
|
1251
|
+
_bufferDescriptor.reset();
|
|
1068
1252
|
|
|
1069
1253
|
this.occludedResolveCache.set( bufferSize, queryResolveBuffer );
|
|
1070
1254
|
|
|
@@ -1072,12 +1256,12 @@ class WebGPUBackend extends Backend {
|
|
|
1072
1256
|
|
|
1073
1257
|
//
|
|
1074
1258
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
);
|
|
1259
|
+
_bufferDescriptor.size = bufferSize;
|
|
1260
|
+
_bufferDescriptor.usage = GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ;
|
|
1261
|
+
|
|
1262
|
+
const readBuffer = this.device.createBuffer( _bufferDescriptor );
|
|
1263
|
+
|
|
1264
|
+
_bufferDescriptor.reset();
|
|
1081
1265
|
|
|
1082
1266
|
// two buffers required here - WebGPU doesn't allow usage of QUERY_RESOLVE & MAP_READ to be combined
|
|
1083
1267
|
renderContextData.encoder.resolveQuerySet( renderContextData.occlusionQuerySet, 0, occlusionQueryCount, queryResolveBuffer, 0 );
|
|
@@ -1091,7 +1275,7 @@ class WebGPUBackend extends Backend {
|
|
|
1091
1275
|
|
|
1092
1276
|
}
|
|
1093
1277
|
|
|
1094
|
-
this.device
|
|
1278
|
+
submit( this.device, renderContextData.encoder.finish() );
|
|
1095
1279
|
|
|
1096
1280
|
|
|
1097
1281
|
//
|
|
@@ -1356,7 +1540,10 @@ class WebGPUBackend extends Backend {
|
|
|
1356
1540
|
|
|
1357
1541
|
//
|
|
1358
1542
|
|
|
1359
|
-
|
|
1543
|
+
_commandEncoderDescriptor.label = 'clear';
|
|
1544
|
+
const encoder = device.createCommandEncoder( _commandEncoderDescriptor );
|
|
1545
|
+
_commandEncoderDescriptor.reset();
|
|
1546
|
+
|
|
1360
1547
|
const currentPass = encoder.beginRenderPass( {
|
|
1361
1548
|
colorAttachments,
|
|
1362
1549
|
depthStencilAttachment
|
|
@@ -1364,7 +1551,7 @@ class WebGPUBackend extends Backend {
|
|
|
1364
1551
|
|
|
1365
1552
|
currentPass.end();
|
|
1366
1553
|
|
|
1367
|
-
|
|
1554
|
+
submit( device, encoder.finish() );
|
|
1368
1555
|
|
|
1369
1556
|
}
|
|
1370
1557
|
|
|
@@ -1382,15 +1569,19 @@ class WebGPUBackend extends Backend {
|
|
|
1382
1569
|
|
|
1383
1570
|
//
|
|
1384
1571
|
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1387
|
-
|
|
1572
|
+
const label = 'computeGroup_' + computeGroup.id;
|
|
1573
|
+
|
|
1574
|
+
_computePassDescriptor.label = label;
|
|
1575
|
+
_commandEncoderDescriptor.label = label;
|
|
1388
1576
|
|
|
1389
|
-
this.initTimestampQuery( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ),
|
|
1577
|
+
this.initTimestampQuery( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ), _computePassDescriptor );
|
|
1390
1578
|
|
|
1391
|
-
groupGPU.cmdEncoderGPU = this.device.createCommandEncoder(
|
|
1579
|
+
groupGPU.cmdEncoderGPU = this.device.createCommandEncoder( _commandEncoderDescriptor );
|
|
1580
|
+
groupGPU.passEncoderGPU = groupGPU.cmdEncoderGPU.beginComputePass( _computePassDescriptor );
|
|
1581
|
+
groupGPU.currentPipeline = null;
|
|
1392
1582
|
|
|
1393
|
-
|
|
1583
|
+
_commandEncoderDescriptor.reset();
|
|
1584
|
+
_computePassDescriptor.reset();
|
|
1394
1585
|
|
|
1395
1586
|
}
|
|
1396
1587
|
|
|
@@ -1409,13 +1600,19 @@ class WebGPUBackend extends Backend {
|
|
|
1409
1600
|
compute( computeGroup, computeNode, bindings, pipeline, dispatchSize = null ) {
|
|
1410
1601
|
|
|
1411
1602
|
const computeNodeData = this.get( computeNode );
|
|
1412
|
-
const
|
|
1603
|
+
const groupGPU = this.get( computeGroup );
|
|
1604
|
+
const { passEncoderGPU } = groupGPU;
|
|
1413
1605
|
|
|
1414
1606
|
// pipeline
|
|
1415
1607
|
|
|
1416
1608
|
const pipelineGPU = this.get( pipeline ).pipeline;
|
|
1417
1609
|
|
|
1418
|
-
|
|
1610
|
+
if ( groupGPU.currentPipeline !== pipelineGPU ) {
|
|
1611
|
+
|
|
1612
|
+
passEncoderGPU.setPipeline( pipelineGPU );
|
|
1613
|
+
groupGPU.currentPipeline = pipelineGPU;
|
|
1614
|
+
|
|
1615
|
+
}
|
|
1419
1616
|
|
|
1420
1617
|
// bind groups
|
|
1421
1618
|
|
|
@@ -1511,7 +1708,7 @@ class WebGPUBackend extends Backend {
|
|
|
1511
1708
|
|
|
1512
1709
|
groupData.passEncoderGPU.end();
|
|
1513
1710
|
|
|
1514
|
-
this.device
|
|
1711
|
+
submit( this.device, groupData.cmdEncoderGPU.finish() );
|
|
1515
1712
|
|
|
1516
1713
|
}
|
|
1517
1714
|
|
|
@@ -1537,17 +1734,26 @@ class WebGPUBackend extends Backend {
|
|
|
1537
1734
|
const hasIndex = ( index !== null );
|
|
1538
1735
|
|
|
1539
1736
|
// pipeline
|
|
1540
|
-
|
|
1541
|
-
currentSets.pipeline
|
|
1737
|
+
|
|
1738
|
+
if ( currentSets.pipeline !== pipelineGPU ) {
|
|
1739
|
+
|
|
1740
|
+
passEncoderGPU.setPipeline( pipelineGPU );
|
|
1741
|
+
currentSets.pipeline = pipelineGPU;
|
|
1742
|
+
|
|
1743
|
+
}
|
|
1542
1744
|
|
|
1543
1745
|
// bind groups
|
|
1746
|
+
|
|
1544
1747
|
const currentBindingGroups = currentSets.bindingGroups;
|
|
1748
|
+
|
|
1545
1749
|
for ( let i = 0, l = bindings.length; i < l; i ++ ) {
|
|
1546
1750
|
|
|
1547
1751
|
const bindGroup = bindings[ i ];
|
|
1548
|
-
|
|
1752
|
+
|
|
1549
1753
|
if ( currentBindingGroups[ i ] !== bindGroup.id ) {
|
|
1550
1754
|
|
|
1755
|
+
const bindingsData = this.get( bindGroup );
|
|
1756
|
+
|
|
1551
1757
|
passEncoderGPU.setBindGroup( i, bindingsData.group );
|
|
1552
1758
|
currentBindingGroups[ i ] = bindGroup.id;
|
|
1553
1759
|
|
|
@@ -1752,7 +1958,9 @@ class WebGPUBackend extends Backend {
|
|
|
1752
1958
|
|
|
1753
1959
|
let pass = renderContextData.currentPass;
|
|
1754
1960
|
let sets = renderContextData.currentSets;
|
|
1755
|
-
|
|
1961
|
+
const isBundleEncoder = renderContextData.bundleEncoders !== undefined;
|
|
1962
|
+
|
|
1963
|
+
if ( isBundleEncoder ) {
|
|
1756
1964
|
|
|
1757
1965
|
const bundleEncoder = renderContextData.bundleEncoders[ i ];
|
|
1758
1966
|
const bundleSets = renderContextData.bundleSets[ i ];
|
|
@@ -1760,8 +1968,9 @@ class WebGPUBackend extends Backend {
|
|
|
1760
1968
|
sets = bundleSets;
|
|
1761
1969
|
|
|
1762
1970
|
}
|
|
1971
|
+
// GPURenderBundleEncoder does not support setViewport, only GPURenderPassEncoder does
|
|
1763
1972
|
|
|
1764
|
-
if ( vp ) {
|
|
1973
|
+
if ( vp && ! isBundleEncoder ) {
|
|
1765
1974
|
|
|
1766
1975
|
pass.setViewport(
|
|
1767
1976
|
Math.floor( vp.x * pixelRatio ),
|
|
@@ -1849,6 +2058,7 @@ class WebGPUBackend extends Backend {
|
|
|
1849
2058
|
const colorFormat = utils.getCurrentColorFormat( renderObject.context );
|
|
1850
2059
|
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
|
|
1851
2060
|
const primitiveTopology = utils.getPrimitiveTopology( object, material );
|
|
2061
|
+
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinantAffine() < 0 );
|
|
1852
2062
|
|
|
1853
2063
|
let needsUpdate = false;
|
|
1854
2064
|
|
|
@@ -1864,6 +2074,7 @@ class WebGPUBackend extends Backend {
|
|
|
1864
2074
|
data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
|
|
1865
2075
|
data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
|
|
1866
2076
|
data.primitiveTopology !== primitiveTopology ||
|
|
2077
|
+
data.frontFaceCW !== frontFaceCW ||
|
|
1867
2078
|
data.clippingContextCacheKey !== renderObject.clippingContextCacheKey
|
|
1868
2079
|
) {
|
|
1869
2080
|
|
|
@@ -1882,6 +2093,7 @@ class WebGPUBackend extends Backend {
|
|
|
1882
2093
|
data.colorFormat = colorFormat;
|
|
1883
2094
|
data.depthStencilFormat = depthStencilFormat;
|
|
1884
2095
|
data.primitiveTopology = primitiveTopology;
|
|
2096
|
+
data.frontFaceCW = frontFaceCW;
|
|
1885
2097
|
data.clippingContextCacheKey = renderObject.clippingContextCacheKey;
|
|
1886
2098
|
|
|
1887
2099
|
needsUpdate = true;
|
|
@@ -1908,7 +2120,7 @@ class WebGPUBackend extends Backend {
|
|
|
1908
2120
|
// meshes with negative scale have a different frontFace render pipeline
|
|
1909
2121
|
// descriptor value so the following must be honored in the cache key
|
|
1910
2122
|
|
|
1911
|
-
const frontFaceCW = ( object.isMesh && object.matrixWorld.
|
|
2123
|
+
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinantAffine() < 0 );
|
|
1912
2124
|
|
|
1913
2125
|
return [
|
|
1914
2126
|
material.transparent, material.blending, material.premultipliedAlpha,
|
|
@@ -1935,12 +2147,23 @@ class WebGPUBackend extends Backend {
|
|
|
1935
2147
|
/**
|
|
1936
2148
|
* Updates a GPU sampler for the given texture.
|
|
1937
2149
|
*
|
|
1938
|
-
* @param {
|
|
2150
|
+
* @param {Sampler} binding - The sampler binding to update.
|
|
1939
2151
|
* @return {string} The current sampler key.
|
|
1940
2152
|
*/
|
|
1941
|
-
updateSampler(
|
|
2153
|
+
updateSampler( binding ) {
|
|
2154
|
+
|
|
2155
|
+
return this.textureUtils.updateSampler( binding );
|
|
2156
|
+
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
/**
|
|
2160
|
+
* Frees the GPU sampler for the given sampler binding.
|
|
2161
|
+
*
|
|
2162
|
+
* @param {Sampler} binding - The sampler binding to free.
|
|
2163
|
+
*/
|
|
2164
|
+
destroySampler( binding ) {
|
|
1942
2165
|
|
|
1943
|
-
|
|
2166
|
+
this.textureUtils.destroySampler( binding );
|
|
1944
2167
|
|
|
1945
2168
|
}
|
|
1946
2169
|
|
|
@@ -2044,11 +2267,11 @@ class WebGPUBackend extends Backend {
|
|
|
2044
2267
|
|
|
2045
2268
|
const baseOffset = timestampQueryPool.allocateQueriesForContext( uid );
|
|
2046
2269
|
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2270
|
+
_renderPassTimestampWrites.querySet = timestampQueryPool.querySet;
|
|
2271
|
+
_renderPassTimestampWrites.beginningOfPassWriteIndex = baseOffset;
|
|
2272
|
+
_renderPassTimestampWrites.endOfPassWriteIndex = baseOffset + 1;
|
|
2273
|
+
|
|
2274
|
+
descriptor.timestampWrites = _renderPassTimestampWrites;
|
|
2052
2275
|
|
|
2053
2276
|
}
|
|
2054
2277
|
|
|
@@ -2079,11 +2302,16 @@ class WebGPUBackend extends Backend {
|
|
|
2079
2302
|
|
|
2080
2303
|
const programGPU = this.get( program );
|
|
2081
2304
|
|
|
2305
|
+
_shaderModuleDescriptor.label = program.stage + ( program.name !== '' ? `_${ program.name }` : '' );
|
|
2306
|
+
_shaderModuleDescriptor.code = program.code;
|
|
2307
|
+
|
|
2082
2308
|
programGPU.module = {
|
|
2083
|
-
module: this.device.createShaderModule(
|
|
2309
|
+
module: this.device.createShaderModule( _shaderModuleDescriptor ),
|
|
2084
2310
|
entryPoint: 'main'
|
|
2085
2311
|
};
|
|
2086
2312
|
|
|
2313
|
+
_shaderModuleDescriptor.reset();
|
|
2314
|
+
|
|
2087
2315
|
}
|
|
2088
2316
|
|
|
2089
2317
|
/**
|
|
@@ -2178,6 +2406,72 @@ class WebGPUBackend extends Backend {
|
|
|
2178
2406
|
|
|
2179
2407
|
// bindings
|
|
2180
2408
|
|
|
2409
|
+
/**
|
|
2410
|
+
* Creates a uniform buffer.
|
|
2411
|
+
*
|
|
2412
|
+
* @param {Buffer} uniformBuffer - The uniform buffer.
|
|
2413
|
+
*/
|
|
2414
|
+
createUniformBuffer( uniformBuffer ) {
|
|
2415
|
+
|
|
2416
|
+
const uniformBufferData = this.get( uniformBuffer );
|
|
2417
|
+
|
|
2418
|
+
if ( uniformBufferData.buffer === undefined ) {
|
|
2419
|
+
|
|
2420
|
+
const byteLength = uniformBuffer.byteLength;
|
|
2421
|
+
|
|
2422
|
+
const usage = GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST;
|
|
2423
|
+
|
|
2424
|
+
const visibilities = [];
|
|
2425
|
+
|
|
2426
|
+
if ( uniformBuffer.visibility & GPUShaderStage.VERTEX ) {
|
|
2427
|
+
|
|
2428
|
+
visibilities.push( 'vertex' );
|
|
2429
|
+
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
if ( uniformBuffer.visibility & GPUShaderStage.FRAGMENT ) {
|
|
2433
|
+
|
|
2434
|
+
visibilities.push( 'fragment' );
|
|
2435
|
+
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
if ( uniformBuffer.visibility & GPUShaderStage.COMPUTE ) {
|
|
2439
|
+
|
|
2440
|
+
visibilities.push( 'compute' );
|
|
2441
|
+
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
const bufferVisibility = `(${visibilities.join( ',' )})`;
|
|
2445
|
+
|
|
2446
|
+
_bufferDescriptor.label = `bindingBuffer${uniformBuffer.id}_${uniformBuffer.name}_${bufferVisibility}`;
|
|
2447
|
+
_bufferDescriptor.size = byteLength;
|
|
2448
|
+
_bufferDescriptor.usage = usage;
|
|
2449
|
+
|
|
2450
|
+
const bufferGPU = this.device.createBuffer( _bufferDescriptor );
|
|
2451
|
+
|
|
2452
|
+
_bufferDescriptor.reset();
|
|
2453
|
+
|
|
2454
|
+
uniformBufferData.buffer = bufferGPU;
|
|
2455
|
+
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
/**
|
|
2461
|
+
* Destroys the GPU data for the given uniform buffer.
|
|
2462
|
+
*
|
|
2463
|
+
* @param {Buffer} uniformBuffer - The uniform buffer.
|
|
2464
|
+
*/
|
|
2465
|
+
destroyUniformBuffer( uniformBuffer ) {
|
|
2466
|
+
|
|
2467
|
+
const uniformBufferData = this.get( uniformBuffer );
|
|
2468
|
+
|
|
2469
|
+
uniformBufferData.buffer.destroy();
|
|
2470
|
+
|
|
2471
|
+
this.delete( uniformBuffer );
|
|
2472
|
+
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2181
2475
|
/**
|
|
2182
2476
|
* Creates bindings from the given bind group definition.
|
|
2183
2477
|
*
|
|
@@ -2389,30 +2683,40 @@ class WebGPUBackend extends Backend {
|
|
|
2389
2683
|
|
|
2390
2684
|
}
|
|
2391
2685
|
|
|
2392
|
-
|
|
2686
|
+
_commandEncoderDescriptor.label = 'copyTextureToTexture_' + srcTexture.id + '_' + dstTexture.id;
|
|
2687
|
+
const encoder = this.device.createCommandEncoder( _commandEncoderDescriptor );
|
|
2688
|
+
_commandEncoderDescriptor.reset();
|
|
2393
2689
|
|
|
2394
2690
|
const sourceGPU = this.get( srcTexture ).texture;
|
|
2395
2691
|
const destinationGPU = this.get( dstTexture ).texture;
|
|
2396
2692
|
|
|
2693
|
+
_texelCopyTextureInfoSrc.texture = sourceGPU;
|
|
2694
|
+
_texelCopyTextureInfoSrc.mipLevel = srcLevel;
|
|
2695
|
+
_texelCopyTextureInfoSrc.origin.x = srcX;
|
|
2696
|
+
_texelCopyTextureInfoSrc.origin.y = srcY;
|
|
2697
|
+
_texelCopyTextureInfoSrc.origin.z = srcZ;
|
|
2698
|
+
|
|
2699
|
+
_texelCopyTextureInfoDst.texture = destinationGPU;
|
|
2700
|
+
_texelCopyTextureInfoDst.mipLevel = dstLevel;
|
|
2701
|
+
_texelCopyTextureInfoDst.origin.x = dstX;
|
|
2702
|
+
_texelCopyTextureInfoDst.origin.y = dstY;
|
|
2703
|
+
_texelCopyTextureInfoDst.origin.z = dstZ;
|
|
2704
|
+
|
|
2705
|
+
_extent3D.width = srcWidth;
|
|
2706
|
+
_extent3D.height = srcHeight;
|
|
2707
|
+
_extent3D.depthOrArrayLayers = srcDepth;
|
|
2708
|
+
|
|
2397
2709
|
encoder.copyTextureToTexture(
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
origin: { x: srcX, y: srcY, z: srcZ }
|
|
2402
|
-
},
|
|
2403
|
-
{
|
|
2404
|
-
texture: destinationGPU,
|
|
2405
|
-
mipLevel: dstLevel,
|
|
2406
|
-
origin: { x: dstX, y: dstY, z: dstZ }
|
|
2407
|
-
},
|
|
2408
|
-
[
|
|
2409
|
-
srcWidth,
|
|
2410
|
-
srcHeight,
|
|
2411
|
-
srcDepth
|
|
2412
|
-
]
|
|
2710
|
+
_texelCopyTextureInfoSrc,
|
|
2711
|
+
_texelCopyTextureInfoDst,
|
|
2712
|
+
_extent3D
|
|
2413
2713
|
);
|
|
2414
2714
|
|
|
2415
|
-
|
|
2715
|
+
_texelCopyTextureInfoSrc.reset();
|
|
2716
|
+
_texelCopyTextureInfoDst.reset();
|
|
2717
|
+
_extent3D.reset();
|
|
2718
|
+
|
|
2719
|
+
submit( this.device, encoder.finish() );
|
|
2416
2720
|
|
|
2417
2721
|
if ( dstLevel === 0 && dstTexture.generateMipmaps ) {
|
|
2418
2722
|
|
|
@@ -2481,24 +2785,31 @@ class WebGPUBackend extends Backend {
|
|
|
2481
2785
|
|
|
2482
2786
|
} else {
|
|
2483
2787
|
|
|
2484
|
-
|
|
2788
|
+
_commandEncoderDescriptor.label = 'copyFramebufferToTexture_' + texture.id;
|
|
2789
|
+
encoder = this.device.createCommandEncoder( _commandEncoderDescriptor );
|
|
2790
|
+
_commandEncoderDescriptor.reset();
|
|
2485
2791
|
|
|
2486
2792
|
}
|
|
2487
2793
|
|
|
2794
|
+
_texelCopyTextureInfoSrc.texture = sourceGPU;
|
|
2795
|
+
_texelCopyTextureInfoSrc.origin.x = rectangle.x;
|
|
2796
|
+
_texelCopyTextureInfoSrc.origin.y = rectangle.y;
|
|
2797
|
+
|
|
2798
|
+
_texelCopyTextureInfoDst.texture = destinationGPU;
|
|
2799
|
+
|
|
2800
|
+
_extent3D.width = rectangle.z;
|
|
2801
|
+
_extent3D.height = rectangle.w;
|
|
2802
|
+
|
|
2488
2803
|
encoder.copyTextureToTexture(
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
},
|
|
2493
|
-
{
|
|
2494
|
-
texture: destinationGPU
|
|
2495
|
-
},
|
|
2496
|
-
[
|
|
2497
|
-
rectangle.z,
|
|
2498
|
-
rectangle.w
|
|
2499
|
-
]
|
|
2804
|
+
_texelCopyTextureInfoSrc,
|
|
2805
|
+
_texelCopyTextureInfoDst,
|
|
2806
|
+
_extent3D
|
|
2500
2807
|
);
|
|
2501
2808
|
|
|
2809
|
+
_texelCopyTextureInfoSrc.reset();
|
|
2810
|
+
_texelCopyTextureInfoDst.reset();
|
|
2811
|
+
_extent3D.reset();
|
|
2812
|
+
|
|
2502
2813
|
// mipmaps must be genereated with the same encoder otherwise the copied texture data
|
|
2503
2814
|
// might be out-of-sync, see #31768
|
|
2504
2815
|
|
|
@@ -2538,7 +2849,7 @@ class WebGPUBackend extends Backend {
|
|
|
2538
2849
|
|
|
2539
2850
|
} else {
|
|
2540
2851
|
|
|
2541
|
-
this.device
|
|
2852
|
+
submit( this.device, encoder.finish() );
|
|
2542
2853
|
|
|
2543
2854
|
}
|
|
2544
2855
|
|