super-three 0.181.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/LICENSE +1 -1
- package/README.md +3 -4
- package/build/three.cjs +21332 -19201
- package/build/three.core.js +20908 -19853
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +1947 -862
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +37 -16
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +33628 -25197
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +33394 -25000
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +14 -3
- package/examples/jsm/animation/CCDIKSolver.js +7 -3
- package/examples/jsm/controls/ArcballControls.js +13 -6
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +127 -86
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +111 -8
- package/examples/jsm/controls/TrackballControls.js +8 -8
- package/examples/jsm/controls/TransformControls.js +102 -17
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/csm/CSMFrustum.js +31 -6
- package/examples/jsm/csm/CSMShadowNode.js +10 -3
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/effects/AsciiEffect.js +14 -1
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +3 -0
- package/examples/jsm/exporters/DRACOExporter.js +27 -6
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +266 -21
- package/examples/jsm/exporters/PLYExporter.js +286 -73
- package/examples/jsm/exporters/USDZExporter.js +353 -99
- 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/DecalGeometry.js +1 -1
- package/examples/jsm/geometries/LoftGeometry.js +355 -0
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/helpers/LightProbeHelper.js +5 -4
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +83 -14
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +244 -91
- package/examples/jsm/inspector/RendererInspector.js +165 -39
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Console.js +241 -25
- package/examples/jsm/inspector/tabs/Memory.js +136 -0
- package/examples/jsm/inspector/tabs/Parameters.js +115 -7
- package/examples/jsm/inspector/tabs/Performance.js +24 -9
- package/examples/jsm/inspector/tabs/Settings.js +306 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1696 -0
- package/examples/jsm/inspector/tabs/Viewer.js +723 -9
- 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 +2 -2
- package/examples/jsm/inspector/ui/Profiler.js +1991 -44
- package/examples/jsm/inspector/ui/Style.js +1943 -543
- package/examples/jsm/inspector/ui/Tab.js +226 -5
- package/examples/jsm/inspector/ui/Values.js +126 -8
- package/examples/jsm/inspector/ui/utils.js +143 -10
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- 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_decoder.module.js +9 -8
- 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/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +681 -0
- package/examples/jsm/lines/LineMaterial.js +45 -16
- package/examples/jsm/lines/LineSegments2.js +8 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +8 -0
- package/examples/jsm/loaders/3DMLoader.js +6 -5
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/DRACOLoader.js +51 -18
- package/examples/jsm/loaders/EXRLoader.js +701 -90
- package/examples/jsm/loaders/FBXLoader.js +235 -37
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +146 -178
- package/examples/jsm/loaders/HDRLoader.js +7 -30
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +58 -17
- package/examples/jsm/loaders/LDrawLoader.js +49 -58
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +2 -2
- package/examples/jsm/loaders/LWOLoader.js +11 -39
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +31 -9
- package/examples/jsm/loaders/NRRDLoader.js +5 -5
- package/examples/jsm/loaders/PCDLoader.js +11 -9
- package/examples/jsm/loaders/PLYLoader.js +218 -55
- package/examples/jsm/loaders/SVGLoader.js +549 -497
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/TTFLoader.js +1 -1
- package/examples/jsm/loaders/USDLoader.js +127 -43
- package/examples/jsm/loaders/UltraHDRLoader.js +285 -160
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +80 -3
- package/examples/jsm/loaders/VTKLoader.js +42 -25
- package/examples/jsm/loaders/collada/ColladaComposer.js +3044 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1977 -0
- package/examples/jsm/loaders/usd/USDAParser.js +504 -344
- package/examples/jsm/loaders/usd/USDCParser.js +1867 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4627 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/misc/TileCreasedNormalsPlugin.js +270 -0
- package/examples/jsm/misc/Volume.js +2 -3
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/GroundedSkybox.js +1 -1
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Reflector.js +72 -25
- package/examples/jsm/objects/Sky.js +90 -6
- package/examples/jsm/objects/SkyMesh.js +150 -16
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +1 -1
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/AmmoPhysics.js +27 -15
- package/examples/jsm/physics/JoltPhysics.js +10 -6
- package/examples/jsm/physics/RapierPhysics.js +36 -7
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/Projector.js +246 -28
- package/examples/jsm/renderers/SVGRenderer.js +174 -60
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/shaders/VolumeShader.js +31 -44
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +65 -8
- package/examples/jsm/transpiler/Linker.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +11 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +458 -16
- package/examples/jsm/tsl/display/BilateralBlurNode.js +374 -0
- package/examples/jsm/tsl/display/BloomNode.js +75 -25
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +3 -3
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/FXAANode.js +13 -14
- package/examples/jsm/tsl/display/GTAONode.js +40 -17
- package/examples/jsm/tsl/display/GaussianBlurNode.js +21 -2
- package/examples/jsm/tsl/display/GodraysNode.js +615 -0
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +560 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +69 -19
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +9 -8
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +912 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +15 -27
- package/examples/jsm/tsl/display/SSGINode.js +96 -62
- package/examples/jsm/tsl/display/SSRNode.js +831 -134
- package/examples/jsm/tsl/display/SSSNode.js +8 -6
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +315 -126
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +1023 -0
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +622 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +53 -3
- 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 +128 -62
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/GeometryCompressionUtils.js +1 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/examples/jsm/utils/SceneOptimizer.js +1 -1
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/utils/WebGPUTextureUtils.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/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +28 -34
- package/src/Three.Core.js +3 -1
- package/src/Three.TSL.js +35 -14
- package/src/Three.WebGPU.Nodes.js +5 -0
- package/src/Three.WebGPU.js +13 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +18 -4
- package/src/animation/AnimationClip.js +0 -139
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +47 -8
- package/src/animation/PropertyBinding.js +2 -2
- package/src/animation/PropertyMixer.js +4 -4
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +34 -4
- package/src/cameras/CubeCamera.js +20 -0
- package/src/cameras/StereoCamera.js +5 -2
- package/src/constants.js +90 -5
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/BufferGeometry.js +43 -9
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +69 -11
- package/src/core/Raycaster.js +3 -3
- package/src/core/RenderTarget.js +19 -6
- package/src/extras/PMREMGenerator.js +13 -22
- package/src/extras/TextureUtils.js +6 -2
- package/src/extras/core/ShapePath.js +149 -160
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/SphereGeometry.js +8 -3
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +6 -1
- package/src/helpers/HemisphereLightHelper.js +5 -0
- package/src/helpers/PointLightHelper.js +3 -25
- package/src/helpers/SpotLightHelper.js +4 -1
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +15 -6
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/DataTextureLoader.js +75 -42
- package/src/loaders/FileLoader.js +2 -3
- package/src/loaders/ImageBitmapLoader.js +12 -9
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/LoadingManager.js +5 -0
- package/src/loaders/MaterialLoader.js +37 -266
- package/src/loaders/ObjectLoader.js +48 -6
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +198 -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 +49 -1
- package/src/materials/MeshMatcapMaterial.js +25 -1
- package/src/materials/MeshNormalMaterial.js +9 -1
- package/src/materials/MeshPhongMaterial.js +49 -1
- package/src/materials/MeshPhysicalMaterial.js +38 -0
- package/src/materials/MeshStandardMaterial.js +42 -1
- package/src/materials/MeshToonMaterial.js +35 -2
- package/src/materials/PointsMaterial.js +7 -0
- package/src/materials/ShaderMaterial.js +106 -1
- package/src/materials/SpriteMaterial.js +7 -0
- package/src/materials/nodes/Line2NodeMaterial.js +380 -297
- 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 +3 -30
- package/src/materials/nodes/MeshSSSNodeMaterial.js +0 -13
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -15
- package/src/materials/nodes/NodeMaterial.js +153 -89
- package/src/materials/nodes/SpriteNodeMaterial.js +0 -10
- package/src/materials/nodes/manager/NodeMaterialObserver.js +234 -100
- package/src/math/Box3.js +5 -0
- package/src/math/FrustumArray.js +103 -133
- package/src/math/Interpolant.js +1 -1
- package/src/math/Line3.js +6 -5
- package/src/math/MathUtils.js +12 -12
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +24 -9
- package/src/math/Matrix4.js +112 -74
- package/src/math/Plane.js +4 -3
- package/src/math/Quaternion.js +3 -29
- package/src/math/Sphere.js +1 -1
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +13 -9
- package/src/math/Vector3.js +17 -15
- package/src/math/Vector4.js +15 -11
- package/src/math/interpolants/BezierInterpolant.js +106 -0
- package/src/nodes/Nodes.js +86 -71
- package/src/nodes/TSL.js +15 -13
- package/src/nodes/accessors/Arrays.js +5 -5
- package/src/nodes/accessors/Batch.js +108 -0
- package/src/nodes/accessors/Bitangent.js +7 -7
- package/src/nodes/accessors/BufferAttributeNode.js +120 -17
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/ClippingNode.js +5 -5
- package/src/nodes/accessors/CubeTextureNode.js +27 -2
- package/src/nodes/accessors/Instance.js +264 -0
- package/src/nodes/accessors/MaterialNode.js +27 -3
- package/src/nodes/accessors/MaterialProperties.js +6 -8
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/{MorphNode.js → Morph.js} +99 -112
- package/src/nodes/accessors/Normal.js +24 -24
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +39 -3
- package/src/nodes/accessors/ReferenceBaseNode.js +6 -6
- package/src/nodes/accessors/ReferenceNode.js +9 -8
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SceneProperties.js +47 -0
- package/src/nodes/accessors/Skinning.js +263 -0
- package/src/nodes/accessors/StorageBufferNode.js +16 -27
- package/src/nodes/accessors/StorageTexture3DNode.js +100 -0
- package/src/nodes/accessors/StorageTextureNode.js +74 -11
- package/src/nodes/accessors/Tangent.js +8 -18
- package/src/nodes/accessors/Texture3DNode.js +32 -35
- package/src/nodes/accessors/TextureNode.js +124 -25
- package/src/nodes/accessors/UniformArrayNode.js +6 -4
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +4 -19
- package/src/nodes/core/ArrayNode.js +21 -2
- package/src/nodes/core/AssignNode.js +3 -3
- package/src/nodes/core/AttributeNode.js +3 -3
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +104 -5
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/MRTNode.js +55 -4
- package/src/nodes/core/Node.js +151 -17
- package/src/nodes/core/NodeBuilder.js +479 -101
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +20 -18
- package/src/nodes/core/OutputStructNode.js +13 -11
- package/src/nodes/core/OverrideContextNode.js +153 -0
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +66 -4
- package/src/nodes/core/StackNode.js +91 -20
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +20 -8
- package/src/nodes/core/StructTypeNode.js +17 -23
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/UniformNode.js +21 -5
- package/src/nodes/core/VarNode.js +56 -23
- package/src/nodes/core/VaryingNode.js +14 -21
- package/src/nodes/display/BlendModes.js +1 -105
- package/src/nodes/display/BumpMapNode.js +6 -1
- package/src/nodes/display/ColorAdjustment.js +27 -9
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/FrontFacingNode.js +38 -9
- package/src/nodes/display/NormalMapNode.js +41 -6
- package/src/nodes/display/PassNode.js +157 -56
- package/src/nodes/display/PremultiplyAlphaFunctions.js +39 -0
- package/src/nodes/display/RenderOutputNode.js +19 -10
- package/src/nodes/display/ScreenNode.js +4 -2
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +39 -11
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/PhysicalLightingModel.js +126 -45
- package/src/nodes/functions/VolumetricLightingModel.js +40 -7
- package/src/nodes/geometry/RangeNode.js +5 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -3
- package/src/nodes/gpgpu/ComputeNode.js +74 -48
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +2 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +5 -5
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/EnvironmentNode.js +30 -5
- package/src/nodes/lighting/IESSpotLightNode.js +40 -2
- package/src/nodes/lighting/LightingContextNode.js +10 -2
- package/src/nodes/lighting/LightsNode.js +97 -65
- package/src/nodes/lighting/PointShadowNode.js +166 -148
- package/src/nodes/lighting/ShadowFilterNode.js +74 -117
- package/src/nodes/lighting/ShadowNode.js +149 -51
- package/src/nodes/materialx/lib/mx_noise.js +2 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +6 -6
- package/src/nodes/math/MathNode.js +115 -52
- package/src/nodes/math/OperatorNode.js +24 -23
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +34 -3
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +99 -33
- package/src/nodes/utils/ArrayElementNode.js +14 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +12 -12
- package/src/nodes/utils/EquirectUV.js +30 -5
- package/src/nodes/utils/EventNode.js +31 -2
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +2 -2
- package/src/nodes/utils/JoinNode.js +3 -3
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +2 -2
- package/src/nodes/utils/Packing.js +48 -5
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/RTTNode.js +41 -25
- package/src/nodes/utils/ReflectorNode.js +4 -4
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/StorageArrayElementNode.js +1 -1
- package/src/nodes/utils/UVUtils.js +28 -0
- package/src/objects/BatchedMesh.js +66 -30
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +344 -156
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +78 -13
- package/src/renderers/common/Background.js +26 -13
- package/src/renderers/common/BindGroup.js +1 -16
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +141 -57
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +49 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/ClippingContext.js +10 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +51 -7
- package/src/renderers/common/Geometries.js +29 -3
- package/src/renderers/common/Info.js +374 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Lighting.js +51 -19
- package/src/renderers/common/Pipelines.js +40 -7
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +7 -3
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -49
- package/src/renderers/common/RenderList.js +41 -4
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +88 -16
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +21 -5
- package/src/renderers/common/RenderPipeline.js +232 -17
- package/src/renderers/common/Renderer.js +700 -163
- package/src/renderers/common/Sampler.js +16 -48
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +121 -9
- package/src/renderers/common/TimestampQueryPool.js +6 -4
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +84 -1
- package/src/renderers/common/XRManager.js +377 -51
- package/src/renderers/common/extras/PMREMGenerator.js +40 -61
- package/src/renderers/common/nodes/NodeBuilderState.js +10 -2
- package/src/renderers/common/nodes/NodeLibrary.js +4 -4
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +298 -106
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +65 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- 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_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +9 -13
- 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/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +13 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +3 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +112 -53
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +225 -186
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk.js +5 -3
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +2 -3
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -6
- package/src/renderers/shaders/UniformsLib.js +7 -5
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +15 -15
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +9 -4
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +24 -13
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +271 -0
- package/src/renderers/webgl/WebGLProgram.js +54 -113
- package/src/renderers/webgl/WebGLPrograms.js +74 -55
- package/src/renderers/webgl/WebGLRenderLists.js +24 -1
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLShaderCache.js +5 -11
- package/src/renderers/webgl/WebGLShadowMap.js +188 -24
- package/src/renderers/webgl/WebGLState.js +75 -37
- package/src/renderers/webgl/WebGLTextures.js +230 -56
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +82 -35
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +322 -92
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +295 -66
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +223 -6
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +118 -73
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +10 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +9 -3
- package/src/renderers/webgpu/WebGPUBackend.js +733 -302
- package/src/renderers/webgpu/WebGPURenderer.js +2 -1
- 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 +526 -93
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +194 -61
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +395 -234
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +10 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +224 -91
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +228 -213
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +428 -175
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +40 -25
- package/src/renderers/webgpu/utils/WebGPUUtils.js +70 -13
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/renderers/webxr/WebXRManager.js +4 -2
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/DepthTexture.js +1 -1
- package/src/textures/ExternalTexture.js +0 -3
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +16 -5
- package/src/utils.js +280 -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/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/materials/MeshGouraudMaterial.js +0 -434
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/examples/jsm/tsl/display/AnamorphicNode.js +0 -282
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +0 -442
- package/src/nodes/accessors/BatchNode.js +0 -163
- package/src/nodes/accessors/InstanceNode.js +0 -244
- package/src/nodes/accessors/InstancedMeshNode.js +0 -50
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/accessors/SkinningNode.js +0 -327
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
- package/src/nodes/utils/RemapNode.js +0 -125
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -1,21 +1,46 @@
|
|
|
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';
|
|
12
|
+
import WebGPUCapabilities from './utils/WebGPUCapabilities.js';
|
|
13
13
|
import WebGPUPipelineUtils from './utils/WebGPUPipelineUtils.js';
|
|
14
14
|
import WebGPUTextureUtils from './utils/WebGPUTextureUtils.js';
|
|
15
15
|
|
|
16
|
-
import { WebGPUCoordinateSystem, TimestampQuery, REVISION, HalfFloatType } from '../../constants.js';
|
|
16
|
+
import { WebGPUCoordinateSystem, TimestampQuery, REVISION, HalfFloatType, Compatibility } from '../../constants.js';
|
|
17
17
|
import WebGPUTimestampQueryPool from './utils/WebGPUTimestampQueryPool.js';
|
|
18
|
-
import {
|
|
18
|
+
import { error } from '../../utils.js';
|
|
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
|
+
|
|
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();
|
|
19
44
|
|
|
20
45
|
/**
|
|
21
46
|
* A backend implementation targeting WebGPU.
|
|
@@ -30,8 +55,8 @@ class WebGPUBackend extends Backend {
|
|
|
30
55
|
*
|
|
31
56
|
* @typedef {Object} WebGPUBackend~Options
|
|
32
57
|
* @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
|
|
58
|
+
* @property {boolean} [reversedDepthBuffer=false] - Whether reversed depth buffer is enabled or not.
|
|
33
59
|
* @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
|
|
34
|
-
* @property {boolean} [compatibilityMode=false] - Whether the backend should be in compatibility mode or not.
|
|
35
60
|
* @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not.
|
|
36
61
|
* @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
|
|
37
62
|
* @property {boolean} [antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
|
|
@@ -64,16 +89,18 @@ class WebGPUBackend extends Backend {
|
|
|
64
89
|
|
|
65
90
|
// some parameters require default values other than "undefined"
|
|
66
91
|
this.parameters.alpha = ( parameters.alpha === undefined ) ? true : parameters.alpha;
|
|
67
|
-
this.parameters.compatibilityMode = ( parameters.compatibilityMode === undefined ) ? false : parameters.compatibilityMode;
|
|
68
92
|
|
|
69
93
|
this.parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits;
|
|
70
94
|
|
|
71
95
|
/**
|
|
72
|
-
* Indicates whether the backend is in compatibility mode or not.
|
|
73
|
-
*
|
|
74
|
-
*
|
|
96
|
+
* Indicates whether the backend is in WebGPU compatibility mode or not.
|
|
97
|
+
* The backend must be initialized before the property can be evaluated.
|
|
98
|
+
*
|
|
99
|
+
* @type {?boolean}
|
|
100
|
+
* @readonly
|
|
101
|
+
* @default null
|
|
75
102
|
*/
|
|
76
|
-
this.compatibilityMode =
|
|
103
|
+
this.compatibilityMode = null;
|
|
77
104
|
|
|
78
105
|
/**
|
|
79
106
|
* A reference to the device.
|
|
@@ -114,6 +141,14 @@ class WebGPUBackend extends Backend {
|
|
|
114
141
|
*/
|
|
115
142
|
this.bindingUtils = new WebGPUBindingUtils( this );
|
|
116
143
|
|
|
144
|
+
/**
|
|
145
|
+
* A reference to a backend module holding device capability related
|
|
146
|
+
* utility functions.
|
|
147
|
+
*
|
|
148
|
+
* @type {WebGPUCapabilities}
|
|
149
|
+
*/
|
|
150
|
+
this.capabilities = new WebGPUCapabilities( this );
|
|
151
|
+
|
|
117
152
|
/**
|
|
118
153
|
* A reference to a backend module holding shader pipeline-related
|
|
119
154
|
* utility functions.
|
|
@@ -137,6 +172,19 @@ class WebGPUBackend extends Backend {
|
|
|
137
172
|
*/
|
|
138
173
|
this.occludedResolveCache = new Map();
|
|
139
174
|
|
|
175
|
+
// compatibility checks
|
|
176
|
+
|
|
177
|
+
const compatibilityTextureCompare = typeof navigator === 'undefined' ? true : /Android/.test( navigator.userAgent ) === false;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* A map of compatibility checks.
|
|
181
|
+
*
|
|
182
|
+
* @type {Object}
|
|
183
|
+
*/
|
|
184
|
+
this._compatibility = {
|
|
185
|
+
[ Compatibility.TEXTURE_COMPARE ]: compatibilityTextureCompare
|
|
186
|
+
};
|
|
187
|
+
|
|
140
188
|
}
|
|
141
189
|
|
|
142
190
|
/**
|
|
@@ -162,14 +210,15 @@ class WebGPUBackend extends Backend {
|
|
|
162
210
|
|
|
163
211
|
const adapterOptions = {
|
|
164
212
|
powerPreference: parameters.powerPreference,
|
|
165
|
-
featureLevel:
|
|
213
|
+
featureLevel: 'compatibility',
|
|
214
|
+
xrCompatible: renderer.xr.enabled
|
|
166
215
|
};
|
|
167
216
|
|
|
168
217
|
const adapter = ( typeof navigator !== 'undefined' ) ? await navigator.gpu.requestAdapter( adapterOptions ) : null;
|
|
169
218
|
|
|
170
219
|
if ( adapter === null ) {
|
|
171
220
|
|
|
172
|
-
throw new Error( 'WebGPUBackend: Unable to create WebGPU adapter.' );
|
|
221
|
+
throw new Error( 'THREE.WebGPUBackend: Unable to create WebGPU adapter.' );
|
|
173
222
|
|
|
174
223
|
}
|
|
175
224
|
|
|
@@ -202,8 +251,18 @@ class WebGPUBackend extends Backend {
|
|
|
202
251
|
|
|
203
252
|
}
|
|
204
253
|
|
|
254
|
+
this.compatibilityMode = ! device.features.has( 'core-features-and-limits' );
|
|
255
|
+
|
|
256
|
+
if ( this.compatibilityMode ) {
|
|
257
|
+
|
|
258
|
+
renderer._samples = 0;
|
|
259
|
+
|
|
260
|
+
}
|
|
261
|
+
|
|
205
262
|
device.lost.then( ( info ) => {
|
|
206
263
|
|
|
264
|
+
if ( info.reason === 'destroyed' ) return;
|
|
265
|
+
|
|
207
266
|
const deviceLossInfo = {
|
|
208
267
|
api: 'WebGPU',
|
|
209
268
|
message: info.message || 'Unknown reason',
|
|
@@ -215,6 +274,21 @@ class WebGPUBackend extends Backend {
|
|
|
215
274
|
|
|
216
275
|
} );
|
|
217
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
|
+
|
|
218
292
|
this.device = device;
|
|
219
293
|
|
|
220
294
|
this.trackTimestamp = this.trackTimestamp && this.hasFeature( GPUFeatureName.TimestampQuery );
|
|
@@ -223,6 +297,25 @@ class WebGPUBackend extends Backend {
|
|
|
223
297
|
|
|
224
298
|
}
|
|
225
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
|
+
|
|
226
319
|
/**
|
|
227
320
|
* A reference to the context.
|
|
228
321
|
*
|
|
@@ -287,17 +380,34 @@ class WebGPUBackend extends Backend {
|
|
|
287
380
|
|
|
288
381
|
}
|
|
289
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
|
+
|
|
290
395
|
/**
|
|
291
396
|
* This method performs a readback operation by moving buffer data from
|
|
292
|
-
* a storage buffer attribute from the GPU to the CPU.
|
|
397
|
+
* a storage buffer attribute from the GPU to the CPU. ReadbackBuffer can
|
|
398
|
+
* be used to retain and reuse handles to the intermediate buffers and prevent
|
|
399
|
+
* new allocation.
|
|
293
400
|
*
|
|
294
401
|
* @async
|
|
295
|
-
* @param {
|
|
296
|
-
* @
|
|
402
|
+
* @param {BufferAttribute} attribute - The storage buffer attribute to read frm.
|
|
403
|
+
* @param {number} count - The offset from which to start reading the
|
|
404
|
+
* @param {number} offset - The storage buffer attribute.
|
|
405
|
+
* @param {ReadbackBuffer|ArrayBuffer} target - The storage buffer attribute.
|
|
406
|
+
* @return {Promise<ArrayBuffer|ReadbackBuffer>} A promise that resolves with the buffer data when the data are ready.
|
|
297
407
|
*/
|
|
298
|
-
async getArrayBufferAsync( attribute ) {
|
|
408
|
+
async getArrayBufferAsync( attribute, target = null, offset = 0, count = - 1 ) {
|
|
299
409
|
|
|
300
|
-
return await this.attributeUtils.getArrayBufferAsync( attribute );
|
|
410
|
+
return await this.attributeUtils.getArrayBufferAsync( attribute, target, offset, count );
|
|
301
411
|
|
|
302
412
|
}
|
|
303
413
|
|
|
@@ -333,17 +443,14 @@ class WebGPUBackend extends Backend {
|
|
|
333
443
|
|
|
334
444
|
if ( descriptor === undefined || canvasData.samples !== samples ) {
|
|
335
445
|
|
|
336
|
-
descriptor =
|
|
337
|
-
|
|
338
|
-
view: null
|
|
339
|
-
} ]
|
|
340
|
-
};
|
|
446
|
+
descriptor = new GPURenderPassDescriptor();
|
|
447
|
+
descriptor.colorAttachments.push( new GPURenderPassColorAttachment() );
|
|
341
448
|
|
|
342
449
|
if ( renderer.depth === true || renderer.stencil === true ) {
|
|
343
450
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
451
|
+
const depthStencilAttachment = new GPURenderPassDepthStencilAttachment();
|
|
452
|
+
depthStencilAttachment.view = this.textureUtils.getDepthBuffer( renderer.depth, renderer.stencil ).createView();
|
|
453
|
+
descriptor.depthStencilAttachment = depthStencilAttachment;
|
|
347
454
|
|
|
348
455
|
}
|
|
349
456
|
|
|
@@ -381,7 +488,7 @@ class WebGPUBackend extends Backend {
|
|
|
381
488
|
}
|
|
382
489
|
|
|
383
490
|
/**
|
|
384
|
-
*
|
|
491
|
+
* Returns whether the render target is a render target array with depth 2D array texture.
|
|
385
492
|
*
|
|
386
493
|
* @param {RenderContext} renderContext - The render context.
|
|
387
494
|
* @return {boolean} Whether the render target is a render target array with depth 2D array texture.
|
|
@@ -390,7 +497,77 @@ class WebGPUBackend extends Backend {
|
|
|
390
497
|
*/
|
|
391
498
|
_isRenderCameraDepthArray( renderContext ) {
|
|
392
499
|
|
|
393
|
-
|
|
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;
|
|
394
571
|
|
|
395
572
|
}
|
|
396
573
|
|
|
@@ -406,13 +583,15 @@ class WebGPUBackend extends Backend {
|
|
|
406
583
|
|
|
407
584
|
const renderTarget = renderContext.renderTarget;
|
|
408
585
|
const renderTargetData = this.get( renderTarget );
|
|
586
|
+
const hasExternalTexture = this._hasExternalTexture( renderContext );
|
|
409
587
|
|
|
410
588
|
let descriptors = renderTargetData.descriptors;
|
|
411
589
|
|
|
412
590
|
if ( descriptors === undefined ||
|
|
413
591
|
renderTargetData.width !== renderTarget.width ||
|
|
414
592
|
renderTargetData.height !== renderTarget.height ||
|
|
415
|
-
renderTargetData.samples !== renderTarget.samples
|
|
593
|
+
renderTargetData.samples !== renderTarget.samples ||
|
|
594
|
+
hasExternalTexture
|
|
416
595
|
) {
|
|
417
596
|
|
|
418
597
|
descriptors = {};
|
|
@@ -424,7 +603,7 @@ class WebGPUBackend extends Backend {
|
|
|
424
603
|
const cacheKey = renderContext.getCacheKey();
|
|
425
604
|
let descriptorBase = descriptors[ cacheKey ];
|
|
426
605
|
|
|
427
|
-
if ( descriptorBase === undefined ) {
|
|
606
|
+
if ( descriptorBase === undefined || hasExternalTexture ) {
|
|
428
607
|
|
|
429
608
|
const textures = renderContext.textures;
|
|
430
609
|
const textureViews = [];
|
|
@@ -437,22 +616,26 @@ class WebGPUBackend extends Backend {
|
|
|
437
616
|
|
|
438
617
|
const textureData = this.get( textures[ i ] );
|
|
439
618
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
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;
|
|
448
632
|
|
|
449
633
|
if ( renderTarget.isRenderTarget3D ) {
|
|
450
634
|
|
|
451
635
|
sliceIndex = renderContext.activeCubeFace;
|
|
452
636
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
|
|
637
|
+
_viewDescriptor.baseArrayLayer = 0;
|
|
638
|
+
_viewDescriptor.dimension = GPUTextureViewDimension.ThreeD;
|
|
456
639
|
|
|
457
640
|
} else if ( renderTarget.isRenderTarget && textures[ i ].image.depth > 1 ) {
|
|
458
641
|
|
|
@@ -461,13 +644,11 @@ class WebGPUBackend extends Backend {
|
|
|
461
644
|
const cameras = renderContext.camera.cameras;
|
|
462
645
|
for ( let layer = 0; layer < cameras.length; layer ++ ) {
|
|
463
646
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
};
|
|
470
|
-
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 );
|
|
471
652
|
textureViews.push( {
|
|
472
653
|
view: textureView,
|
|
473
654
|
resolveTarget: undefined,
|
|
@@ -478,8 +659,7 @@ class WebGPUBackend extends Backend {
|
|
|
478
659
|
|
|
479
660
|
} else {
|
|
480
661
|
|
|
481
|
-
|
|
482
|
-
viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
|
|
662
|
+
_viewDescriptor.dimension = GPUTextureViewDimension.TwoDArray;
|
|
483
663
|
|
|
484
664
|
}
|
|
485
665
|
|
|
@@ -487,7 +667,7 @@ class WebGPUBackend extends Backend {
|
|
|
487
667
|
|
|
488
668
|
if ( isRenderCameraDepthArray !== true ) {
|
|
489
669
|
|
|
490
|
-
const textureView = textureData.texture.createView(
|
|
670
|
+
const textureView = textureData.texture.createView( _viewDescriptor );
|
|
491
671
|
|
|
492
672
|
let view, resolveTarget;
|
|
493
673
|
|
|
@@ -511,23 +691,46 @@ class WebGPUBackend extends Backend {
|
|
|
511
691
|
|
|
512
692
|
}
|
|
513
693
|
|
|
694
|
+
_viewDescriptor.reset();
|
|
695
|
+
|
|
514
696
|
}
|
|
515
697
|
|
|
516
|
-
|
|
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
|
+
};
|
|
517
716
|
|
|
518
717
|
if ( renderContext.depth ) {
|
|
519
718
|
|
|
520
719
|
const depthTextureData = this.get( renderContext.depthTexture );
|
|
521
|
-
const options = {};
|
|
522
|
-
if ( renderContext.depthTexture.isArrayTexture ) {
|
|
523
720
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
721
|
+
if ( renderContext.depthTexture.isArrayTexture || renderContext.depthTexture.isCubeTexture ) {
|
|
722
|
+
|
|
723
|
+
_viewDescriptor.dimension = GPUTextureViewDimension.TwoD;
|
|
724
|
+
_viewDescriptor.arrayLayerCount = 1;
|
|
725
|
+
_viewDescriptor.baseArrayLayer = renderContext.activeCubeFace;
|
|
527
726
|
|
|
528
727
|
}
|
|
529
728
|
|
|
530
|
-
|
|
729
|
+
const depthStencilAttachment = new GPURenderPassDepthStencilAttachment();
|
|
730
|
+
depthStencilAttachment.view = depthTextureData.texture.createView( _viewDescriptor );
|
|
731
|
+
descriptorBase.depthStencilAttachment = depthStencilAttachment;
|
|
732
|
+
|
|
733
|
+
_viewDescriptor.reset();
|
|
531
734
|
|
|
532
735
|
}
|
|
533
736
|
|
|
@@ -541,14 +744,14 @@ class WebGPUBackend extends Backend {
|
|
|
541
744
|
|
|
542
745
|
}
|
|
543
746
|
|
|
544
|
-
const descriptor =
|
|
545
|
-
|
|
546
|
-
|
|
747
|
+
const descriptor = descriptorBase.descriptor;
|
|
748
|
+
|
|
749
|
+
descriptor.reset();
|
|
547
750
|
|
|
548
|
-
// Apply dynamic properties to cached
|
|
549
|
-
for ( let i = 0; i < descriptorBase.
|
|
751
|
+
// Apply dynamic properties to cached attachments
|
|
752
|
+
for ( let i = 0; i < descriptorBase.colorAttachments.length; i ++ ) {
|
|
550
753
|
|
|
551
|
-
const
|
|
754
|
+
const attachment = descriptorBase.colorAttachments[ i ];
|
|
552
755
|
|
|
553
756
|
let clearValue = { r: 0, g: 0, b: 0, a: 1 };
|
|
554
757
|
if ( i === 0 && colorAttachmentsConfig.clearValue ) {
|
|
@@ -557,22 +760,17 @@ class WebGPUBackend extends Backend {
|
|
|
557
760
|
|
|
558
761
|
}
|
|
559
762
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
storeOp: colorAttachmentsConfig.storeOp || GPUStoreOp.Store,
|
|
566
|
-
clearValue: clearValue
|
|
567
|
-
} );
|
|
763
|
+
attachment.loadOp = colorAttachmentsConfig.loadOp || GPULoadOp.Load;
|
|
764
|
+
attachment.storeOp = colorAttachmentsConfig.storeOp || GPUStoreOp.Store;
|
|
765
|
+
attachment.clearValue = clearValue;
|
|
766
|
+
|
|
767
|
+
descriptor.colorAttachments.push( attachment );
|
|
568
768
|
|
|
569
769
|
}
|
|
570
770
|
|
|
571
|
-
if ( descriptorBase.
|
|
771
|
+
if ( descriptorBase.depthStencilAttachment ) {
|
|
572
772
|
|
|
573
|
-
descriptor.depthStencilAttachment =
|
|
574
|
-
view: descriptorBase.depthStencilView
|
|
575
|
-
};
|
|
773
|
+
descriptor.depthStencilAttachment = descriptorBase.depthStencilAttachment;
|
|
576
774
|
|
|
577
775
|
}
|
|
578
776
|
|
|
@@ -610,7 +808,13 @@ class WebGPUBackend extends Backend {
|
|
|
610
808
|
|
|
611
809
|
//
|
|
612
810
|
|
|
613
|
-
|
|
811
|
+
_querySetDescriptor.label = `occlusionQuerySet_${ renderContext.id }`;
|
|
812
|
+
_querySetDescriptor.type = 'occlusion';
|
|
813
|
+
_querySetDescriptor.count = occlusionQueryCount;
|
|
814
|
+
|
|
815
|
+
occlusionQuerySet = device.createQuerySet( _querySetDescriptor );
|
|
816
|
+
|
|
817
|
+
_querySetDescriptor.reset();
|
|
614
818
|
|
|
615
819
|
renderContextData.occlusionQuerySet = occlusionQuerySet;
|
|
616
820
|
renderContextData.occlusionQueryIndex = 0;
|
|
@@ -648,7 +852,21 @@ class WebGPUBackend extends Backend {
|
|
|
648
852
|
|
|
649
853
|
if ( renderContext.clearColor ) {
|
|
650
854
|
|
|
651
|
-
|
|
855
|
+
if ( i === 0 ) {
|
|
856
|
+
|
|
857
|
+
colorAttachment.clearValue = renderContext.clearColorValue;
|
|
858
|
+
|
|
859
|
+
} else {
|
|
860
|
+
|
|
861
|
+
_clearValue.r = 0;
|
|
862
|
+
_clearValue.g = 0;
|
|
863
|
+
_clearValue.b = 0;
|
|
864
|
+
_clearValue.a = 1;
|
|
865
|
+
|
|
866
|
+
colorAttachment.clearValue = _clearValue;
|
|
867
|
+
|
|
868
|
+
}
|
|
869
|
+
|
|
652
870
|
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
653
871
|
|
|
654
872
|
} else {
|
|
@@ -695,7 +913,7 @@ class WebGPUBackend extends Backend {
|
|
|
695
913
|
|
|
696
914
|
}
|
|
697
915
|
|
|
698
|
-
|
|
916
|
+
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
699
917
|
|
|
700
918
|
}
|
|
701
919
|
|
|
@@ -712,15 +930,17 @@ class WebGPUBackend extends Backend {
|
|
|
712
930
|
|
|
713
931
|
}
|
|
714
932
|
|
|
715
|
-
|
|
933
|
+
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
716
934
|
|
|
717
935
|
}
|
|
718
936
|
|
|
719
937
|
//
|
|
720
938
|
|
|
721
|
-
|
|
939
|
+
_commandEncoderDescriptor.label = 'renderContext_' + renderContext.id;
|
|
940
|
+
const encoder = device.createCommandEncoder( _commandEncoderDescriptor );
|
|
941
|
+
_commandEncoderDescriptor.reset();
|
|
722
942
|
|
|
723
|
-
//
|
|
943
|
+
// Layered render targets: prepare bundle encoders for each camera in the array camera.
|
|
724
944
|
|
|
725
945
|
if ( this._isRenderCameraDepthArray( renderContext ) === true ) {
|
|
726
946
|
|
|
@@ -728,11 +948,11 @@ class WebGPUBackend extends Backend {
|
|
|
728
948
|
|
|
729
949
|
if ( ! renderContextData.layerDescriptors || renderContextData.layerDescriptors.length !== cameras.length ) {
|
|
730
950
|
|
|
731
|
-
this.
|
|
951
|
+
this._createArrayCameraLayerDescriptors( renderContext, renderContextData, descriptor, cameras );
|
|
732
952
|
|
|
733
953
|
} else {
|
|
734
954
|
|
|
735
|
-
this.
|
|
955
|
+
this._updateArrayCameraLayerDescriptors( renderContext, renderContextData, cameras );
|
|
736
956
|
|
|
737
957
|
}
|
|
738
958
|
|
|
@@ -793,8 +1013,7 @@ class WebGPUBackend extends Backend {
|
|
|
793
1013
|
}
|
|
794
1014
|
|
|
795
1015
|
/**
|
|
796
|
-
*
|
|
797
|
-
* to prepare for rendering to a depth array texture.
|
|
1016
|
+
* Creates render pass descriptors for each camera in an array camera.
|
|
798
1017
|
*
|
|
799
1018
|
* @param {RenderContext} renderContext - The render context.
|
|
800
1019
|
* @param {Object} renderContextData - The render context data.
|
|
@@ -803,7 +1022,7 @@ class WebGPUBackend extends Backend {
|
|
|
803
1022
|
*
|
|
804
1023
|
* @private
|
|
805
1024
|
*/
|
|
806
|
-
|
|
1025
|
+
_createArrayCameraLayerDescriptors( renderContext, renderContextData, descriptor, cameras ) {
|
|
807
1026
|
|
|
808
1027
|
const depthStencilAttachment = descriptor.depthStencilAttachment;
|
|
809
1028
|
renderContextData.layerDescriptors = [];
|
|
@@ -817,13 +1036,21 @@ class WebGPUBackend extends Backend {
|
|
|
817
1036
|
|
|
818
1037
|
for ( let i = 0; i < cameras.length; i ++ ) {
|
|
819
1038
|
|
|
820
|
-
const
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
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 );
|
|
827
1054
|
|
|
828
1055
|
if ( descriptor.depthStencilAttachment ) {
|
|
829
1056
|
|
|
@@ -831,32 +1058,45 @@ class WebGPUBackend extends Backend {
|
|
|
831
1058
|
|
|
832
1059
|
if ( ! depthTextureData.viewCache[ layerIndex ] ) {
|
|
833
1060
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
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();
|
|
839
1068
|
|
|
840
1069
|
}
|
|
841
1070
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
};
|
|
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;
|
|
848
1076
|
|
|
849
1077
|
if ( renderContext.stencil ) {
|
|
850
1078
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
1079
|
+
layerDepthStencilAttachment.stencilLoadOp = depthStencilAttachment.stencilLoadOp;
|
|
1080
|
+
layerDepthStencilAttachment.stencilStoreOp = depthStencilAttachment.stencilStoreOp;
|
|
1081
|
+
layerDepthStencilAttachment.stencilClearValue = depthStencilAttachment.stencilClearValue;
|
|
854
1082
|
|
|
855
1083
|
}
|
|
856
1084
|
|
|
1085
|
+
layerDescriptor.depthStencilAttachment = layerDepthStencilAttachment;
|
|
1086
|
+
|
|
857
1087
|
} else {
|
|
858
1088
|
|
|
859
|
-
|
|
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;
|
|
860
1100
|
|
|
861
1101
|
}
|
|
862
1102
|
|
|
@@ -867,15 +1107,14 @@ class WebGPUBackend extends Backend {
|
|
|
867
1107
|
}
|
|
868
1108
|
|
|
869
1109
|
/**
|
|
870
|
-
*
|
|
871
|
-
* to prepare for rendering to a depth array texture.
|
|
1110
|
+
* Updates render pass descriptors for each camera in an array camera.
|
|
872
1111
|
*
|
|
873
1112
|
* @param {RenderContext} renderContext - The render context.
|
|
874
1113
|
* @param {Object} renderContextData - The render context data.
|
|
875
1114
|
* @param {ArrayCamera} cameras - The array camera.
|
|
876
1115
|
*
|
|
877
1116
|
*/
|
|
878
|
-
|
|
1117
|
+
_updateArrayCameraLayerDescriptors( renderContext, renderContextData, cameras ) {
|
|
879
1118
|
|
|
880
1119
|
for ( let i = 0; i < cameras.length; i ++ ) {
|
|
881
1120
|
|
|
@@ -944,7 +1183,7 @@ class WebGPUBackend extends Backend {
|
|
|
944
1183
|
|
|
945
1184
|
}
|
|
946
1185
|
|
|
947
|
-
//
|
|
1186
|
+
// Layered render targets: execute the bundle for each layer.
|
|
948
1187
|
|
|
949
1188
|
const encoder = renderContextData.encoder;
|
|
950
1189
|
|
|
@@ -1004,12 +1243,12 @@ class WebGPUBackend extends Backend {
|
|
|
1004
1243
|
|
|
1005
1244
|
if ( queryResolveBuffer === undefined ) {
|
|
1006
1245
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
);
|
|
1246
|
+
_bufferDescriptor.size = bufferSize;
|
|
1247
|
+
_bufferDescriptor.usage = GPUBufferUsage.QUERY_RESOLVE | GPUBufferUsage.COPY_SRC;
|
|
1248
|
+
|
|
1249
|
+
queryResolveBuffer = this.device.createBuffer( _bufferDescriptor );
|
|
1250
|
+
|
|
1251
|
+
_bufferDescriptor.reset();
|
|
1013
1252
|
|
|
1014
1253
|
this.occludedResolveCache.set( bufferSize, queryResolveBuffer );
|
|
1015
1254
|
|
|
@@ -1017,12 +1256,12 @@ class WebGPUBackend extends Backend {
|
|
|
1017
1256
|
|
|
1018
1257
|
//
|
|
1019
1258
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
);
|
|
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();
|
|
1026
1265
|
|
|
1027
1266
|
// two buffers required here - WebGPU doesn't allow usage of QUERY_RESOLVE & MAP_READ to be combined
|
|
1028
1267
|
renderContextData.encoder.resolveQuerySet( renderContextData.occlusionQuerySet, 0, occlusionQueryCount, queryResolveBuffer, 0 );
|
|
@@ -1036,7 +1275,7 @@ class WebGPUBackend extends Backend {
|
|
|
1036
1275
|
|
|
1037
1276
|
}
|
|
1038
1277
|
|
|
1039
|
-
this.device
|
|
1278
|
+
submit( this.device, renderContextData.encoder.finish() );
|
|
1040
1279
|
|
|
1041
1280
|
|
|
1042
1281
|
//
|
|
@@ -1190,7 +1429,6 @@ class WebGPUBackend extends Backend {
|
|
|
1190
1429
|
|
|
1191
1430
|
let colorAttachments = [];
|
|
1192
1431
|
let depthStencilAttachment;
|
|
1193
|
-
let clearValue;
|
|
1194
1432
|
|
|
1195
1433
|
let supportsDepth;
|
|
1196
1434
|
let supportsStencil;
|
|
@@ -1198,7 +1436,11 @@ class WebGPUBackend extends Backend {
|
|
|
1198
1436
|
if ( color ) {
|
|
1199
1437
|
|
|
1200
1438
|
const clearColor = this.getClearColor();
|
|
1201
|
-
|
|
1439
|
+
|
|
1440
|
+
_clearValue.r = clearColor.r;
|
|
1441
|
+
_clearValue.g = clearColor.g;
|
|
1442
|
+
_clearValue.b = clearColor.b;
|
|
1443
|
+
_clearValue.a = clearColor.a;
|
|
1202
1444
|
|
|
1203
1445
|
}
|
|
1204
1446
|
|
|
@@ -1215,7 +1457,7 @@ class WebGPUBackend extends Backend {
|
|
|
1215
1457
|
|
|
1216
1458
|
const colorAttachment = colorAttachments[ 0 ];
|
|
1217
1459
|
|
|
1218
|
-
colorAttachment.clearValue =
|
|
1460
|
+
colorAttachment.clearValue = _clearValue;
|
|
1219
1461
|
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
1220
1462
|
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
1221
1463
|
|
|
@@ -1234,7 +1476,7 @@ class WebGPUBackend extends Backend {
|
|
|
1234
1476
|
|
|
1235
1477
|
const clearConfig = {
|
|
1236
1478
|
loadOp: color ? GPULoadOp.Clear : GPULoadOp.Load,
|
|
1237
|
-
clearValue: color ?
|
|
1479
|
+
clearValue: color ? _clearValue : undefined
|
|
1238
1480
|
};
|
|
1239
1481
|
|
|
1240
1482
|
if ( supportsDepth ) {
|
|
@@ -1298,7 +1540,10 @@ class WebGPUBackend extends Backend {
|
|
|
1298
1540
|
|
|
1299
1541
|
//
|
|
1300
1542
|
|
|
1301
|
-
|
|
1543
|
+
_commandEncoderDescriptor.label = 'clear';
|
|
1544
|
+
const encoder = device.createCommandEncoder( _commandEncoderDescriptor );
|
|
1545
|
+
_commandEncoderDescriptor.reset();
|
|
1546
|
+
|
|
1302
1547
|
const currentPass = encoder.beginRenderPass( {
|
|
1303
1548
|
colorAttachments,
|
|
1304
1549
|
depthStencilAttachment
|
|
@@ -1306,7 +1551,7 @@ class WebGPUBackend extends Backend {
|
|
|
1306
1551
|
|
|
1307
1552
|
currentPass.end();
|
|
1308
1553
|
|
|
1309
|
-
|
|
1554
|
+
submit( device, encoder.finish() );
|
|
1310
1555
|
|
|
1311
1556
|
}
|
|
1312
1557
|
|
|
@@ -1324,15 +1569,19 @@ class WebGPUBackend extends Backend {
|
|
|
1324
1569
|
|
|
1325
1570
|
//
|
|
1326
1571
|
|
|
1327
|
-
const
|
|
1328
|
-
label: 'computeGroup_' + computeGroup.id
|
|
1329
|
-
};
|
|
1572
|
+
const label = 'computeGroup_' + computeGroup.id;
|
|
1330
1573
|
|
|
1331
|
-
|
|
1574
|
+
_computePassDescriptor.label = label;
|
|
1575
|
+
_commandEncoderDescriptor.label = label;
|
|
1332
1576
|
|
|
1333
|
-
|
|
1577
|
+
this.initTimestampQuery( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ), _computePassDescriptor );
|
|
1334
1578
|
|
|
1335
|
-
groupGPU.
|
|
1579
|
+
groupGPU.cmdEncoderGPU = this.device.createCommandEncoder( _commandEncoderDescriptor );
|
|
1580
|
+
groupGPU.passEncoderGPU = groupGPU.cmdEncoderGPU.beginComputePass( _computePassDescriptor );
|
|
1581
|
+
groupGPU.currentPipeline = null;
|
|
1582
|
+
|
|
1583
|
+
_commandEncoderDescriptor.reset();
|
|
1584
|
+
_computePassDescriptor.reset();
|
|
1336
1585
|
|
|
1337
1586
|
}
|
|
1338
1587
|
|
|
@@ -1351,13 +1600,19 @@ class WebGPUBackend extends Backend {
|
|
|
1351
1600
|
compute( computeGroup, computeNode, bindings, pipeline, dispatchSize = null ) {
|
|
1352
1601
|
|
|
1353
1602
|
const computeNodeData = this.get( computeNode );
|
|
1354
|
-
const
|
|
1603
|
+
const groupGPU = this.get( computeGroup );
|
|
1604
|
+
const { passEncoderGPU } = groupGPU;
|
|
1355
1605
|
|
|
1356
1606
|
// pipeline
|
|
1357
1607
|
|
|
1358
1608
|
const pipelineGPU = this.get( pipeline ).pipeline;
|
|
1359
1609
|
|
|
1360
|
-
|
|
1610
|
+
if ( groupGPU.currentPipeline !== pipelineGPU ) {
|
|
1611
|
+
|
|
1612
|
+
passEncoderGPU.setPipeline( pipelineGPU );
|
|
1613
|
+
groupGPU.currentPipeline = pipelineGPU;
|
|
1614
|
+
|
|
1615
|
+
}
|
|
1361
1616
|
|
|
1362
1617
|
// bind groups
|
|
1363
1618
|
|
|
@@ -1372,13 +1627,13 @@ class WebGPUBackend extends Backend {
|
|
|
1372
1627
|
|
|
1373
1628
|
if ( dispatchSize === null ) {
|
|
1374
1629
|
|
|
1375
|
-
dispatchSize = computeNode.count;
|
|
1630
|
+
dispatchSize = computeNode.dispatchSize || computeNode.count;
|
|
1376
1631
|
|
|
1377
1632
|
}
|
|
1378
1633
|
|
|
1379
1634
|
// When the dispatchSize is set with a StorageBuffer from the GPU.
|
|
1380
1635
|
|
|
1381
|
-
if ( dispatchSize &&
|
|
1636
|
+
if ( dispatchSize && dispatchSize.isIndirectStorageBufferAttribute ) {
|
|
1382
1637
|
|
|
1383
1638
|
const dispatchBuffer = this.get( dispatchSize ).buffer;
|
|
1384
1639
|
|
|
@@ -1453,187 +1708,214 @@ class WebGPUBackend extends Backend {
|
|
|
1453
1708
|
|
|
1454
1709
|
groupData.passEncoderGPU.end();
|
|
1455
1710
|
|
|
1456
|
-
this.device
|
|
1711
|
+
submit( this.device, groupData.cmdEncoderGPU.finish() );
|
|
1457
1712
|
|
|
1458
1713
|
}
|
|
1459
1714
|
|
|
1460
|
-
// render object
|
|
1461
|
-
|
|
1462
1715
|
/**
|
|
1463
|
-
*
|
|
1716
|
+
* Internal draw function that performs the draw with the given pass encoder.
|
|
1464
1717
|
*
|
|
1465
|
-
* @
|
|
1718
|
+
* @private
|
|
1719
|
+
* @param {RenderObject} renderObject - The render object.
|
|
1466
1720
|
* @param {Info} info - Holds a series of statistical information about the GPU memory and the rendering process.
|
|
1721
|
+
* @param {Object} renderContextData - The render context data object, holding current pass state and occlusion query tracking.
|
|
1722
|
+
* @param {GPURenderPipeline} pipelineGPU - The GPU render pipeline.
|
|
1723
|
+
* @param {Array<BindGroup>} bindings - The bind groups.
|
|
1724
|
+
* @param {Array<BufferAttribute>} vertexBuffers - The vertex buffers.
|
|
1725
|
+
* @param {{vertexCount: number, firstVertex: number, instanceCount: number, firstInstance: number}} drawParams - The draw parameters.
|
|
1726
|
+
* @param {GPURenderPassEncoder|GPURenderBundleEncoder} passEncoderGPU - The GPU pass encoder used for recording draw commands.
|
|
1727
|
+
* @param {Object} currentSets - Tracking object for currently set pipeline, attributes, bind groups, and index state.
|
|
1467
1728
|
*/
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
const { object, material, context, pipeline } = renderObject;
|
|
1471
|
-
const bindings = renderObject.getBindings();
|
|
1472
|
-
const renderContextData = this.get( context );
|
|
1473
|
-
const pipelineData = this.get( pipeline );
|
|
1474
|
-
const pipelineGPU = pipelineData.pipeline;
|
|
1729
|
+
_draw( renderObject, info, renderContextData, pipelineGPU, bindings, vertexBuffers, drawParams, passEncoderGPU, currentSets ) {
|
|
1475
1730
|
|
|
1476
|
-
|
|
1731
|
+
const { object, material, context } = renderObject;
|
|
1477
1732
|
|
|
1478
1733
|
const index = renderObject.getIndex();
|
|
1479
1734
|
const hasIndex = ( index !== null );
|
|
1480
1735
|
|
|
1481
|
-
|
|
1482
|
-
const drawParams = renderObject.getDrawParameters();
|
|
1483
|
-
if ( drawParams === null ) return;
|
|
1484
|
-
|
|
1485
1736
|
// pipeline
|
|
1486
1737
|
|
|
1487
|
-
|
|
1738
|
+
if ( currentSets.pipeline !== pipelineGPU ) {
|
|
1488
1739
|
|
|
1489
|
-
|
|
1490
|
-
this.pipelineUtils.setPipeline( passEncoderGPU, pipelineGPU );
|
|
1740
|
+
passEncoderGPU.setPipeline( pipelineGPU );
|
|
1491
1741
|
currentSets.pipeline = pipelineGPU;
|
|
1492
1742
|
|
|
1493
|
-
|
|
1494
|
-
const currentBindingGroups = currentSets.bindingGroups;
|
|
1495
|
-
for ( let i = 0, l = bindings.length; i < l; i ++ ) {
|
|
1743
|
+
}
|
|
1496
1744
|
|
|
1497
|
-
|
|
1498
|
-
const bindingsData = this.get( bindGroup );
|
|
1499
|
-
if ( currentBindingGroups[ bindGroup.index ] !== bindGroup.id ) {
|
|
1745
|
+
// bind groups
|
|
1500
1746
|
|
|
1501
|
-
|
|
1502
|
-
currentBindingGroups[ bindGroup.index ] = bindGroup.id;
|
|
1747
|
+
const currentBindingGroups = currentSets.bindingGroups;
|
|
1503
1748
|
|
|
1504
|
-
|
|
1749
|
+
for ( let i = 0, l = bindings.length; i < l; i ++ ) {
|
|
1750
|
+
|
|
1751
|
+
const bindGroup = bindings[ i ];
|
|
1752
|
+
|
|
1753
|
+
if ( currentBindingGroups[ i ] !== bindGroup.id ) {
|
|
1754
|
+
|
|
1755
|
+
const bindingsData = this.get( bindGroup );
|
|
1756
|
+
|
|
1757
|
+
passEncoderGPU.setBindGroup( i, bindingsData.group );
|
|
1758
|
+
currentBindingGroups[ i ] = bindGroup.id;
|
|
1505
1759
|
|
|
1506
1760
|
}
|
|
1507
1761
|
|
|
1508
|
-
|
|
1762
|
+
}
|
|
1509
1763
|
|
|
1510
|
-
|
|
1764
|
+
// attributes
|
|
1511
1765
|
|
|
1512
|
-
|
|
1766
|
+
// index
|
|
1513
1767
|
|
|
1514
|
-
|
|
1768
|
+
if ( hasIndex === true ) {
|
|
1515
1769
|
|
|
1516
|
-
|
|
1517
|
-
const indexFormat = ( index.array instanceof Uint16Array ) ? GPUIndexFormat.Uint16 : GPUIndexFormat.Uint32;
|
|
1770
|
+
if ( currentSets.index !== index ) {
|
|
1518
1771
|
|
|
1519
|
-
|
|
1772
|
+
const buffer = this.get( index ).buffer;
|
|
1773
|
+
const indexFormat = ( index.array instanceof Uint16Array ) ? GPUIndexFormat.Uint16 : GPUIndexFormat.Uint32;
|
|
1520
1774
|
|
|
1521
|
-
|
|
1775
|
+
passEncoderGPU.setIndexBuffer( buffer, indexFormat );
|
|
1522
1776
|
|
|
1523
|
-
|
|
1777
|
+
currentSets.index = index;
|
|
1524
1778
|
|
|
1525
1779
|
}
|
|
1526
|
-
// vertex buffers
|
|
1527
|
-
|
|
1528
|
-
const vertexBuffers = renderObject.getVertexBuffers();
|
|
1529
1780
|
|
|
1530
|
-
|
|
1781
|
+
}
|
|
1531
1782
|
|
|
1532
|
-
|
|
1783
|
+
for ( let i = 0, l = vertexBuffers.length; i < l; i ++ ) {
|
|
1533
1784
|
|
|
1534
|
-
|
|
1785
|
+
const vertexBuffer = vertexBuffers[ i ];
|
|
1535
1786
|
|
|
1536
|
-
|
|
1537
|
-
passEncoderGPU.setVertexBuffer( i, buffer );
|
|
1787
|
+
if ( currentSets.attributes[ i ] !== vertexBuffer ) {
|
|
1538
1788
|
|
|
1539
|
-
|
|
1789
|
+
const buffer = this.get( vertexBuffer ).buffer;
|
|
1790
|
+
passEncoderGPU.setVertexBuffer( i, buffer );
|
|
1540
1791
|
|
|
1541
|
-
|
|
1792
|
+
currentSets.attributes[ i ] = vertexBuffer;
|
|
1542
1793
|
|
|
1543
1794
|
}
|
|
1544
|
-
// stencil
|
|
1545
1795
|
|
|
1546
|
-
|
|
1796
|
+
}
|
|
1797
|
+
// stencil
|
|
1547
1798
|
|
|
1548
|
-
|
|
1549
|
-
renderContextData.currentStencilRef = material.stencilRef;
|
|
1799
|
+
if ( context.stencil === true && material.stencilWrite === true && renderContextData.currentStencilRef !== material.stencilRef ) {
|
|
1550
1800
|
|
|
1551
|
-
|
|
1801
|
+
passEncoderGPU.setStencilReference( material.stencilRef );
|
|
1802
|
+
renderContextData.currentStencilRef = material.stencilRef;
|
|
1552
1803
|
|
|
1804
|
+
}
|
|
1553
1805
|
|
|
1554
|
-
|
|
1806
|
+
if ( object.isBatchedMesh === true ) {
|
|
1807
|
+
|
|
1808
|
+
const starts = object._multiDrawStarts;
|
|
1809
|
+
const counts = object._multiDrawCounts;
|
|
1810
|
+
const drawCount = object._multiDrawCount;
|
|
1811
|
+
|
|
1812
|
+
let bytesPerElement = ( hasIndex === true ) ? index.array.BYTES_PER_ELEMENT : 1;
|
|
1813
|
+
|
|
1814
|
+
if ( material.wireframe ) {
|
|
1815
|
+
|
|
1816
|
+
bytesPerElement = object.geometry.attributes.position.count > 65535 ? 4 : 2;
|
|
1555
1817
|
|
|
1556
|
-
|
|
1557
|
-
const draw = ( passEncoderGPU, currentSets ) => {
|
|
1818
|
+
}
|
|
1558
1819
|
|
|
1559
|
-
|
|
1820
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
1560
1821
|
|
|
1561
|
-
|
|
1822
|
+
if ( hasIndex === true ) {
|
|
1562
1823
|
|
|
1563
|
-
|
|
1564
|
-
const counts = object._multiDrawCounts;
|
|
1565
|
-
const drawCount = object._multiDrawCount;
|
|
1566
|
-
const drawInstances = object._multiDrawInstances;
|
|
1824
|
+
passEncoderGPU.drawIndexed( counts[ i ], 1, starts[ i ] / bytesPerElement, 0, i );
|
|
1567
1825
|
|
|
1568
|
-
|
|
1826
|
+
} else {
|
|
1569
1827
|
|
|
1570
|
-
|
|
1571
|
-
warnOnce( 'WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.' );
|
|
1828
|
+
passEncoderGPU.draw( counts[ i ], 1, starts[ i ], i );
|
|
1572
1829
|
|
|
1573
1830
|
}
|
|
1574
1831
|
|
|
1575
|
-
|
|
1832
|
+
info.update( object, counts[ i ], 1 );
|
|
1576
1833
|
|
|
1577
|
-
|
|
1578
|
-
const firstInstance = count > 1 ? 0 : i;
|
|
1834
|
+
}
|
|
1579
1835
|
|
|
1580
|
-
|
|
1836
|
+
} else if ( hasIndex === true ) {
|
|
1581
1837
|
|
|
1582
|
-
|
|
1838
|
+
const { vertexCount: indexCount, instanceCount, firstVertex: firstIndex } = drawParams;
|
|
1583
1839
|
|
|
1584
|
-
|
|
1840
|
+
const indirect = renderObject.getIndirect();
|
|
1585
1841
|
|
|
1586
|
-
|
|
1842
|
+
if ( indirect !== null ) {
|
|
1587
1843
|
|
|
1588
|
-
|
|
1844
|
+
const buffer = this.get( indirect ).buffer;
|
|
1845
|
+
const indirectOffset = renderObject.getIndirectOffset();
|
|
1846
|
+
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1589
1847
|
|
|
1590
|
-
|
|
1848
|
+
for ( let i = 0; i < indirectOffsets.length; i ++ ) {
|
|
1849
|
+
|
|
1850
|
+
passEncoderGPU.drawIndexedIndirect( buffer, indirectOffsets[ i ] );
|
|
1591
1851
|
|
|
1592
1852
|
}
|
|
1593
1853
|
|
|
1594
|
-
} else
|
|
1854
|
+
} else {
|
|
1595
1855
|
|
|
1596
|
-
|
|
1856
|
+
passEncoderGPU.drawIndexed( indexCount, instanceCount, firstIndex, 0, 0 );
|
|
1597
1857
|
|
|
1598
|
-
|
|
1858
|
+
}
|
|
1599
1859
|
|
|
1600
|
-
|
|
1860
|
+
info.update( object, indexCount, instanceCount );
|
|
1601
1861
|
|
|
1602
|
-
|
|
1862
|
+
} else {
|
|
1603
1863
|
|
|
1604
|
-
|
|
1864
|
+
const { vertexCount, instanceCount, firstVertex } = drawParams;
|
|
1605
1865
|
|
|
1606
|
-
|
|
1866
|
+
const indirect = renderObject.getIndirect();
|
|
1607
1867
|
|
|
1608
|
-
|
|
1868
|
+
if ( indirect !== null ) {
|
|
1869
|
+
|
|
1870
|
+
const buffer = this.get( indirect ).buffer;
|
|
1871
|
+
const indirectOffset = renderObject.getIndirectOffset();
|
|
1872
|
+
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1873
|
+
|
|
1874
|
+
for ( let i = 0; i < indirectOffsets.length; i ++ ) {
|
|
1875
|
+
|
|
1876
|
+
passEncoderGPU.drawIndirect( buffer, indirectOffsets[ i ] );
|
|
1609
1877
|
|
|
1610
1878
|
}
|
|
1611
1879
|
|
|
1612
|
-
info.update( object, indexCount, instanceCount );
|
|
1613
1880
|
|
|
1614
1881
|
} else {
|
|
1615
1882
|
|
|
1616
|
-
|
|
1883
|
+
passEncoderGPU.draw( vertexCount, instanceCount, firstVertex, 0 );
|
|
1884
|
+
|
|
1885
|
+
}
|
|
1617
1886
|
|
|
1618
|
-
|
|
1887
|
+
info.update( object, vertexCount, instanceCount );
|
|
1619
1888
|
|
|
1620
|
-
|
|
1889
|
+
}
|
|
1621
1890
|
|
|
1622
|
-
|
|
1891
|
+
}
|
|
1623
1892
|
|
|
1624
|
-
|
|
1893
|
+
// render object
|
|
1625
1894
|
|
|
1626
|
-
|
|
1895
|
+
/**
|
|
1896
|
+
* Executes a draw command for the given render object.
|
|
1897
|
+
*
|
|
1898
|
+
* @param {RenderObject} renderObject - The render object to draw.
|
|
1899
|
+
* @param {Info} info - Holds a series of statistical information about the GPU memory and the rendering process.
|
|
1900
|
+
*/
|
|
1901
|
+
draw( renderObject, info ) {
|
|
1627
1902
|
|
|
1628
|
-
|
|
1903
|
+
const { object, context, pipeline } = renderObject;
|
|
1904
|
+
const renderContextData = this.get( context );
|
|
1905
|
+
const pipelineData = this.get( pipeline );
|
|
1906
|
+
const pipelineGPU = pipelineData.pipeline;
|
|
1629
1907
|
|
|
1630
|
-
|
|
1908
|
+
// Skip if pipeline has error
|
|
1909
|
+
if ( pipelineData.error === true ) return;
|
|
1631
1910
|
|
|
1632
|
-
|
|
1911
|
+
const drawParams = renderObject.getDrawParameters();
|
|
1912
|
+
if ( drawParams === null ) return;
|
|
1633
1913
|
|
|
1634
|
-
|
|
1914
|
+
const bindings = renderObject.getBindings();
|
|
1635
1915
|
|
|
1636
|
-
|
|
1916
|
+
// vertex buffers
|
|
1917
|
+
|
|
1918
|
+
const vertexBuffers = renderObject.getVertexBuffers();
|
|
1637
1919
|
|
|
1638
1920
|
if ( renderObject.camera.isArrayCamera && renderObject.camera.cameras.length > 0 ) {
|
|
1639
1921
|
|
|
@@ -1652,7 +1934,9 @@ class WebGPUBackend extends Backend {
|
|
|
1652
1934
|
|
|
1653
1935
|
data[ 0 ] = i;
|
|
1654
1936
|
|
|
1655
|
-
const
|
|
1937
|
+
const { layoutGPU } = bindingsData.layout;
|
|
1938
|
+
|
|
1939
|
+
const bindGroupIndex = this.bindingUtils.createBindGroupIndex( data, layoutGPU );
|
|
1656
1940
|
|
|
1657
1941
|
indexesGPU.push( bindGroupIndex );
|
|
1658
1942
|
|
|
@@ -1672,11 +1956,11 @@ class WebGPUBackend extends Backend {
|
|
|
1672
1956
|
|
|
1673
1957
|
const vp = subCamera.viewport;
|
|
1674
1958
|
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
1959
|
let pass = renderContextData.currentPass;
|
|
1678
1960
|
let sets = renderContextData.currentSets;
|
|
1679
|
-
|
|
1961
|
+
const isBundleEncoder = renderContextData.bundleEncoders !== undefined;
|
|
1962
|
+
|
|
1963
|
+
if ( isBundleEncoder ) {
|
|
1680
1964
|
|
|
1681
1965
|
const bundleEncoder = renderContextData.bundleEncoders[ i ];
|
|
1682
1966
|
const bundleSets = renderContextData.bundleSets[ i ];
|
|
@@ -1684,10 +1968,9 @@ class WebGPUBackend extends Backend {
|
|
|
1684
1968
|
sets = bundleSets;
|
|
1685
1969
|
|
|
1686
1970
|
}
|
|
1971
|
+
// GPURenderBundleEncoder does not support setViewport, only GPURenderPassEncoder does
|
|
1687
1972
|
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
if ( vp ) {
|
|
1973
|
+
if ( vp && ! isBundleEncoder ) {
|
|
1691
1974
|
|
|
1692
1975
|
pass.setViewport(
|
|
1693
1976
|
Math.floor( vp.x * pixelRatio ),
|
|
@@ -1700,17 +1983,16 @@ class WebGPUBackend extends Backend {
|
|
|
1700
1983
|
|
|
1701
1984
|
}
|
|
1702
1985
|
|
|
1703
|
-
|
|
1704
1986
|
// Set camera index binding for this layer
|
|
1705
1987
|
if ( cameraIndex && cameraData.indexesGPU ) {
|
|
1706
1988
|
|
|
1707
|
-
|
|
1708
|
-
|
|
1989
|
+
const indexPos = bindings.indexOf( cameraIndex );
|
|
1990
|
+
pass.setBindGroup( indexPos, cameraData.indexesGPU[ i ] );
|
|
1991
|
+
sets.bindingGroups[ indexPos ] = cameraIndex.id;
|
|
1709
1992
|
|
|
1710
1993
|
}
|
|
1711
1994
|
|
|
1712
|
-
|
|
1713
|
-
|
|
1995
|
+
this._draw( renderObject, info, renderContextData, pipelineGPU, bindings, vertexBuffers, drawParams, pass, sets );
|
|
1714
1996
|
|
|
1715
1997
|
}
|
|
1716
1998
|
|
|
@@ -1747,7 +2029,7 @@ class WebGPUBackend extends Backend {
|
|
|
1747
2029
|
|
|
1748
2030
|
}
|
|
1749
2031
|
|
|
1750
|
-
|
|
2032
|
+
this._draw( renderObject, info, renderContextData, pipelineGPU, bindings, vertexBuffers, drawParams, renderContextData.currentPass, renderContextData.currentSets );
|
|
1751
2033
|
|
|
1752
2034
|
}
|
|
1753
2035
|
|
|
@@ -1776,6 +2058,7 @@ class WebGPUBackend extends Backend {
|
|
|
1776
2058
|
const colorFormat = utils.getCurrentColorFormat( renderObject.context );
|
|
1777
2059
|
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
|
|
1778
2060
|
const primitiveTopology = utils.getPrimitiveTopology( object, material );
|
|
2061
|
+
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinantAffine() < 0 );
|
|
1779
2062
|
|
|
1780
2063
|
let needsUpdate = false;
|
|
1781
2064
|
|
|
@@ -1791,6 +2074,7 @@ class WebGPUBackend extends Backend {
|
|
|
1791
2074
|
data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
|
|
1792
2075
|
data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
|
|
1793
2076
|
data.primitiveTopology !== primitiveTopology ||
|
|
2077
|
+
data.frontFaceCW !== frontFaceCW ||
|
|
1794
2078
|
data.clippingContextCacheKey !== renderObject.clippingContextCacheKey
|
|
1795
2079
|
) {
|
|
1796
2080
|
|
|
@@ -1809,6 +2093,7 @@ class WebGPUBackend extends Backend {
|
|
|
1809
2093
|
data.colorFormat = colorFormat;
|
|
1810
2094
|
data.depthStencilFormat = depthStencilFormat;
|
|
1811
2095
|
data.primitiveTopology = primitiveTopology;
|
|
2096
|
+
data.frontFaceCW = frontFaceCW;
|
|
1812
2097
|
data.clippingContextCacheKey = renderObject.clippingContextCacheKey;
|
|
1813
2098
|
|
|
1814
2099
|
needsUpdate = true;
|
|
@@ -1835,7 +2120,7 @@ class WebGPUBackend extends Backend {
|
|
|
1835
2120
|
// meshes with negative scale have a different frontFace render pipeline
|
|
1836
2121
|
// descriptor value so the following must be honored in the cache key
|
|
1837
2122
|
|
|
1838
|
-
const frontFaceCW = ( object.isMesh && object.matrixWorld.
|
|
2123
|
+
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinantAffine() < 0 );
|
|
1839
2124
|
|
|
1840
2125
|
return [
|
|
1841
2126
|
material.transparent, material.blending, material.premultipliedAlpha,
|
|
@@ -1862,12 +2147,23 @@ class WebGPUBackend extends Backend {
|
|
|
1862
2147
|
/**
|
|
1863
2148
|
* Updates a GPU sampler for the given texture.
|
|
1864
2149
|
*
|
|
1865
|
-
* @param {
|
|
2150
|
+
* @param {Sampler} binding - The sampler binding to update.
|
|
1866
2151
|
* @return {string} The current sampler key.
|
|
1867
2152
|
*/
|
|
1868
|
-
updateSampler(
|
|
2153
|
+
updateSampler( binding ) {
|
|
1869
2154
|
|
|
1870
|
-
return this.textureUtils.updateSampler(
|
|
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 ) {
|
|
2165
|
+
|
|
2166
|
+
this.textureUtils.destroySampler( binding );
|
|
1871
2167
|
|
|
1872
2168
|
}
|
|
1873
2169
|
|
|
@@ -1971,11 +2267,11 @@ class WebGPUBackend extends Backend {
|
|
|
1971
2267
|
|
|
1972
2268
|
const baseOffset = timestampQueryPool.allocateQueriesForContext( uid );
|
|
1973
2269
|
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
2270
|
+
_renderPassTimestampWrites.querySet = timestampQueryPool.querySet;
|
|
2271
|
+
_renderPassTimestampWrites.beginningOfPassWriteIndex = baseOffset;
|
|
2272
|
+
_renderPassTimestampWrites.endOfPassWriteIndex = baseOffset + 1;
|
|
2273
|
+
|
|
2274
|
+
descriptor.timestampWrites = _renderPassTimestampWrites;
|
|
1979
2275
|
|
|
1980
2276
|
}
|
|
1981
2277
|
|
|
@@ -2006,11 +2302,16 @@ class WebGPUBackend extends Backend {
|
|
|
2006
2302
|
|
|
2007
2303
|
const programGPU = this.get( program );
|
|
2008
2304
|
|
|
2305
|
+
_shaderModuleDescriptor.label = program.stage + ( program.name !== '' ? `_${ program.name }` : '' );
|
|
2306
|
+
_shaderModuleDescriptor.code = program.code;
|
|
2307
|
+
|
|
2009
2308
|
programGPU.module = {
|
|
2010
|
-
module: this.device.createShaderModule(
|
|
2309
|
+
module: this.device.createShaderModule( _shaderModuleDescriptor ),
|
|
2011
2310
|
entryPoint: 'main'
|
|
2012
2311
|
};
|
|
2013
2312
|
|
|
2313
|
+
_shaderModuleDescriptor.reset();
|
|
2314
|
+
|
|
2014
2315
|
}
|
|
2015
2316
|
|
|
2016
2317
|
/**
|
|
@@ -2105,6 +2406,72 @@ class WebGPUBackend extends Backend {
|
|
|
2105
2406
|
|
|
2106
2407
|
// bindings
|
|
2107
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
|
+
|
|
2108
2475
|
/**
|
|
2109
2476
|
* Creates bindings from the given bind group definition.
|
|
2110
2477
|
*
|
|
@@ -2144,6 +2511,17 @@ class WebGPUBackend extends Backend {
|
|
|
2144
2511
|
|
|
2145
2512
|
}
|
|
2146
2513
|
|
|
2514
|
+
/**
|
|
2515
|
+
* Delete data associated with the current bind group.
|
|
2516
|
+
*
|
|
2517
|
+
* @param {BindGroup} bindGroup - The bind group.
|
|
2518
|
+
*/
|
|
2519
|
+
deleteBindGroupData( bindGroup ) {
|
|
2520
|
+
|
|
2521
|
+
this.bindingUtils.deleteBindGroupData( bindGroup );
|
|
2522
|
+
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2147
2525
|
// attributes
|
|
2148
2526
|
|
|
2149
2527
|
/**
|
|
@@ -2233,17 +2611,6 @@ class WebGPUBackend extends Backend {
|
|
|
2233
2611
|
|
|
2234
2612
|
// utils public
|
|
2235
2613
|
|
|
2236
|
-
/**
|
|
2237
|
-
* Returns the maximum anisotropy texture filtering value.
|
|
2238
|
-
*
|
|
2239
|
-
* @return {number} The maximum anisotropy texture filtering value.
|
|
2240
|
-
*/
|
|
2241
|
-
getMaxAnisotropy() {
|
|
2242
|
-
|
|
2243
|
-
return 16;
|
|
2244
|
-
|
|
2245
|
-
}
|
|
2246
|
-
|
|
2247
2614
|
/**
|
|
2248
2615
|
* Checks if the given feature is supported by the backend.
|
|
2249
2616
|
*
|
|
@@ -2316,30 +2683,40 @@ class WebGPUBackend extends Backend {
|
|
|
2316
2683
|
|
|
2317
2684
|
}
|
|
2318
2685
|
|
|
2319
|
-
|
|
2686
|
+
_commandEncoderDescriptor.label = 'copyTextureToTexture_' + srcTexture.id + '_' + dstTexture.id;
|
|
2687
|
+
const encoder = this.device.createCommandEncoder( _commandEncoderDescriptor );
|
|
2688
|
+
_commandEncoderDescriptor.reset();
|
|
2320
2689
|
|
|
2321
2690
|
const sourceGPU = this.get( srcTexture ).texture;
|
|
2322
2691
|
const destinationGPU = this.get( dstTexture ).texture;
|
|
2323
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
|
+
|
|
2324
2709
|
encoder.copyTextureToTexture(
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
origin: { x: srcX, y: srcY, z: srcZ }
|
|
2329
|
-
},
|
|
2330
|
-
{
|
|
2331
|
-
texture: destinationGPU,
|
|
2332
|
-
mipLevel: dstLevel,
|
|
2333
|
-
origin: { x: dstX, y: dstY, z: dstZ }
|
|
2334
|
-
},
|
|
2335
|
-
[
|
|
2336
|
-
srcWidth,
|
|
2337
|
-
srcHeight,
|
|
2338
|
-
srcDepth
|
|
2339
|
-
]
|
|
2710
|
+
_texelCopyTextureInfoSrc,
|
|
2711
|
+
_texelCopyTextureInfoDst,
|
|
2712
|
+
_extent3D
|
|
2340
2713
|
);
|
|
2341
2714
|
|
|
2342
|
-
|
|
2715
|
+
_texelCopyTextureInfoSrc.reset();
|
|
2716
|
+
_texelCopyTextureInfoDst.reset();
|
|
2717
|
+
_extent3D.reset();
|
|
2718
|
+
|
|
2719
|
+
submit( this.device, encoder.finish() );
|
|
2343
2720
|
|
|
2344
2721
|
if ( dstLevel === 0 && dstTexture.generateMipmaps ) {
|
|
2345
2722
|
|
|
@@ -2408,24 +2785,31 @@ class WebGPUBackend extends Backend {
|
|
|
2408
2785
|
|
|
2409
2786
|
} else {
|
|
2410
2787
|
|
|
2411
|
-
|
|
2788
|
+
_commandEncoderDescriptor.label = 'copyFramebufferToTexture_' + texture.id;
|
|
2789
|
+
encoder = this.device.createCommandEncoder( _commandEncoderDescriptor );
|
|
2790
|
+
_commandEncoderDescriptor.reset();
|
|
2412
2791
|
|
|
2413
2792
|
}
|
|
2414
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
|
+
|
|
2415
2803
|
encoder.copyTextureToTexture(
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
},
|
|
2420
|
-
{
|
|
2421
|
-
texture: destinationGPU
|
|
2422
|
-
},
|
|
2423
|
-
[
|
|
2424
|
-
rectangle.z,
|
|
2425
|
-
rectangle.w
|
|
2426
|
-
]
|
|
2804
|
+
_texelCopyTextureInfoSrc,
|
|
2805
|
+
_texelCopyTextureInfoDst,
|
|
2806
|
+
_extent3D
|
|
2427
2807
|
);
|
|
2428
2808
|
|
|
2809
|
+
_texelCopyTextureInfoSrc.reset();
|
|
2810
|
+
_texelCopyTextureInfoDst.reset();
|
|
2811
|
+
_extent3D.reset();
|
|
2812
|
+
|
|
2429
2813
|
// mipmaps must be genereated with the same encoder otherwise the copied texture data
|
|
2430
2814
|
// might be out-of-sync, see #31768
|
|
2431
2815
|
|
|
@@ -2465,16 +2849,63 @@ class WebGPUBackend extends Backend {
|
|
|
2465
2849
|
|
|
2466
2850
|
} else {
|
|
2467
2851
|
|
|
2468
|
-
this.device
|
|
2852
|
+
submit( this.device, encoder.finish() );
|
|
2469
2853
|
|
|
2470
2854
|
}
|
|
2471
2855
|
|
|
2472
2856
|
}
|
|
2473
2857
|
|
|
2858
|
+
/**
|
|
2859
|
+
* Checks if the given compatibility is supported by the backend.
|
|
2860
|
+
*
|
|
2861
|
+
* @param {string} name - The compatibility name.
|
|
2862
|
+
* @return {boolean} Whether the compatibility is supported or not.
|
|
2863
|
+
*/
|
|
2864
|
+
hasCompatibility( name ) {
|
|
2865
|
+
|
|
2866
|
+
if ( this._compatibility[ name ] !== undefined ) {
|
|
2867
|
+
|
|
2868
|
+
return this._compatibility[ name ];
|
|
2869
|
+
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
return super.hasCompatibility( name );
|
|
2873
|
+
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2474
2876
|
dispose() {
|
|
2475
2877
|
|
|
2878
|
+
this.bindingUtils.dispose();
|
|
2476
2879
|
this.textureUtils.dispose();
|
|
2477
2880
|
|
|
2881
|
+
if ( this.occludedResolveCache ) {
|
|
2882
|
+
|
|
2883
|
+
for ( const buffer of this.occludedResolveCache.values() ) {
|
|
2884
|
+
|
|
2885
|
+
buffer.destroy();
|
|
2886
|
+
|
|
2887
|
+
}
|
|
2888
|
+
|
|
2889
|
+
this.occludedResolveCache.clear();
|
|
2890
|
+
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
if ( this.timestampQueryPool ) {
|
|
2894
|
+
|
|
2895
|
+
for ( const queryPool of Object.values( this.timestampQueryPool ) ) {
|
|
2896
|
+
|
|
2897
|
+
if ( queryPool !== null ) queryPool.dispose();
|
|
2898
|
+
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
if ( this.parameters.device === undefined && this.device !== null ) {
|
|
2904
|
+
|
|
2905
|
+
this.device.destroy();
|
|
2906
|
+
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2478
2909
|
}
|
|
2479
2910
|
|
|
2480
2911
|
}
|