@plastic-software/three 0.180.0 → 0.181.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +943 -486
- package/build/three.core.js +506 -327
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +435 -163
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +8 -2
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3753 -1177
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3752 -1176
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/DragControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +1 -1
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +3 -3
- package/examples/jsm/exporters/USDZExporter.js +9 -2
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +6 -10
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +2 -2
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +5 -3
- package/examples/jsm/loaders/KTX2Loader.js +28 -21
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +22 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +1 -1
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +7 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +2 -1
- package/examples/jsm/tsl/display/BloomNode.js +4 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +7 -0
- package/examples/jsm/tsl/display/GTAONode.js +45 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +5 -3
- package/examples/jsm/tsl/display/OutlineNode.js +11 -0
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +2 -0
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +123 -6
- package/examples/jsm/tsl/display/boxBlur.js +1 -0
- package/examples/jsm/tsl/display/hashBlur.js +1 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +3 -2
- package/src/Three.TSL.js +7 -1
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/AnimationClip.js +3 -2
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +7 -6
- package/src/animation/PropertyBinding.js +12 -11
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +8 -8
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +3 -2
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +268 -55
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +7 -7
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +3 -2
- package/src/loaders/ImageBitmapLoader.js +5 -4
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/Loader.js +3 -3
- package/src/loaders/LoadingManager.js +25 -3
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +4 -3
- package/src/materials/MeshBasicMaterial.js +1 -0
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +62 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +2 -1
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +2 -2
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +7 -7
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +68 -66
- package/src/math/Spherical.js +1 -1
- package/src/nodes/Nodes.js +1 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/CubeTextureNode.js +3 -2
- package/src/nodes/accessors/InstanceNode.js +22 -4
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +5 -4
- package/src/nodes/accessors/Position.js +18 -2
- package/src/nodes/accessors/ReferenceNode.js +2 -1
- package/src/nodes/accessors/SceneNode.js +2 -1
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +61 -27
- package/src/nodes/code/FunctionCallNode.js +5 -4
- package/src/nodes/core/ArrayNode.js +1 -0
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +5 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +40 -7
- package/src/nodes/core/Node.js +137 -12
- package/src/nodes/core/NodeBuilder.js +135 -21
- package/src/nodes/core/NodeFrame.js +20 -20
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUtils.js +17 -90
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +16 -14
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +70 -12
- package/src/nodes/core/VaryingNode.js +3 -2
- package/src/nodes/display/BlendModes.js +5 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -1
- package/src/nodes/display/PassNode.js +51 -10
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhysicalLightingModel.js +3 -2
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +17 -5
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +25 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +6 -6
- package/src/nodes/lighting/LightsNode.js +2 -3
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ShadowFilterNode.js +2 -0
- package/src/nodes/lighting/ShadowNode.js +75 -8
- package/src/nodes/math/ConditionalNode.js +6 -5
- package/src/nodes/math/MathNode.js +22 -4
- package/src/nodes/math/OperatorNode.js +3 -2
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +5 -2
- package/src/nodes/tsl/TSLCore.js +36 -15
- package/src/nodes/utils/DebugNode.js +2 -1
- package/src/nodes/utils/EventNode.js +36 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +3 -2
- package/src/nodes/utils/LoopNode.js +20 -24
- package/src/nodes/utils/MemberNode.js +2 -1
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +12 -2
- package/src/nodes/utils/ReflectorNode.js +10 -3
- package/src/objects/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +2 -1
- package/src/renderers/WebGLRenderer.js +48 -32
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Backend.js +93 -30
- package/src/renderers/common/Background.js +2 -1
- package/src/renderers/common/Bindings.js +56 -2
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/PostProcessing.js +6 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +3 -1
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +436 -228
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +8 -0
- package/src/renderers/common/Sampler.js +37 -11
- package/src/renderers/common/StorageTexture.js +9 -1
- package/src/renderers/common/Textures.js +89 -35
- package/src/renderers/common/TimestampQueryPool.js +63 -1
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +7 -3
- package/src/renderers/common/extras/PMREMGenerator.js +160 -65
- package/src/renderers/common/nodes/NodeLibrary.js +4 -2
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLCapabilities.js +2 -1
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +11 -10
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +2 -1
- package/src/renderers/webgl/WebGLState.js +15 -14
- package/src/renderers/webgl/WebGLTextures.js +18 -14
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl-fallback/WebGLBackend.js +22 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +74 -11
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +6 -5
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +117 -16
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +42 -12
- package/src/renderers/webgpu/WebGPUBackend.js +134 -108
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +21 -19
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +5 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +44 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +146 -74
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +29 -6
- package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
- package/src/renderers/webxr/WebXRManager.js +3 -2
- package/src/textures/Source.js +2 -1
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +2 -0
- package/src/utils.js +67 -3
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
|
|
6
6
|
import { FloatType, IntType, UnsignedIntType } from '../../../constants.js';
|
|
7
7
|
import { NodeAccess } from '../../../nodes/core/constants.js';
|
|
8
|
+
import { error } from '../../../utils.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* A WebGPU backend utility module for managing bindings.
|
|
@@ -222,7 +223,7 @@ class WebGPUBindingUtils {
|
|
|
222
223
|
|
|
223
224
|
} else {
|
|
224
225
|
|
|
225
|
-
|
|
226
|
+
error( `WebGPUBindingUtils: Unsupported binding "${ binding }".` );
|
|
226
227
|
|
|
227
228
|
}
|
|
228
229
|
|
|
@@ -414,6 +415,7 @@ class WebGPUBindingUtils {
|
|
|
414
415
|
} else {
|
|
415
416
|
|
|
416
417
|
const mipLevelCount = binding.store ? 1 : textureData.texture.mipLevelCount;
|
|
418
|
+
const baseMipLevel = binding.store ? binding.mipLevel : 0;
|
|
417
419
|
let propertyName = `view-${ textureData.texture.width }-${ textureData.texture.height }`;
|
|
418
420
|
|
|
419
421
|
if ( textureData.texture.depthOrArrayLayers > 1 ) {
|
|
@@ -422,7 +424,7 @@ class WebGPUBindingUtils {
|
|
|
422
424
|
|
|
423
425
|
}
|
|
424
426
|
|
|
425
|
-
propertyName += `-${ mipLevelCount }`;
|
|
427
|
+
propertyName += `-${ mipLevelCount }-${ baseMipLevel }`;
|
|
426
428
|
|
|
427
429
|
resourceGPU = textureData[ propertyName ];
|
|
428
430
|
|
|
@@ -450,7 +452,7 @@ class WebGPUBindingUtils {
|
|
|
450
452
|
|
|
451
453
|
}
|
|
452
454
|
|
|
453
|
-
resourceGPU = textureData[ propertyName ] = textureData.texture.createView( { aspect: aspectGPU, dimension: dimensionViewGPU, mipLevelCount } );
|
|
455
|
+
resourceGPU = textureData[ propertyName ] = textureData.texture.createView( { aspect: aspectGPU, dimension: dimensionViewGPU, mipLevelCount, baseMipLevel } );
|
|
454
456
|
|
|
455
457
|
}
|
|
456
458
|
|
|
@@ -337,3 +337,8 @@ export const GPUFeatureName = {
|
|
|
337
337
|
TextureFormatsTier1: 'texture-formats-tier1',
|
|
338
338
|
TextureFormatsTier2: 'texture-formats-tier2'
|
|
339
339
|
};
|
|
340
|
+
|
|
341
|
+
export const GPUFeatureMap = {
|
|
342
|
+
'texture-compression-s3tc': 'texture-compression-bc',
|
|
343
|
+
'texture-compression-etc1': 'texture-compression-etc2'
|
|
344
|
+
};
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
NeverStencilFunc, AlwaysStencilFunc, LessStencilFunc, LessEqualStencilFunc, EqualStencilFunc, GreaterEqualStencilFunc, GreaterStencilFunc, NotEqualStencilFunc
|
|
16
16
|
} from '../../../constants.js';
|
|
17
17
|
|
|
18
|
+
import { error } from '../../../utils.js';
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* A WebGPU backend utility module for managing pipelines.
|
|
20
22
|
*
|
|
@@ -229,21 +231,47 @@ class WebGPUPipelineUtils {
|
|
|
229
231
|
|
|
230
232
|
}
|
|
231
233
|
|
|
234
|
+
// create pipeline
|
|
235
|
+
|
|
236
|
+
device.pushErrorScope( 'validation' );
|
|
232
237
|
|
|
233
238
|
if ( promises === null ) {
|
|
234
239
|
|
|
235
240
|
pipelineData.pipeline = device.createRenderPipeline( pipelineDescriptor );
|
|
236
241
|
|
|
242
|
+
device.popErrorScope().then( ( err ) => {
|
|
243
|
+
|
|
244
|
+
if ( err !== null ) {
|
|
245
|
+
|
|
246
|
+
pipelineData.error = true;
|
|
247
|
+
|
|
248
|
+
error( err.message );
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
} );
|
|
253
|
+
|
|
237
254
|
} else {
|
|
238
255
|
|
|
239
|
-
const p = new Promise( ( resolve /*, reject*/ ) => {
|
|
256
|
+
const p = new Promise( async ( resolve /*, reject*/ ) => {
|
|
240
257
|
|
|
241
|
-
|
|
258
|
+
try {
|
|
242
259
|
|
|
243
|
-
pipelineData.pipeline =
|
|
244
|
-
resolve();
|
|
260
|
+
pipelineData.pipeline = await device.createRenderPipelineAsync( pipelineDescriptor );
|
|
245
261
|
|
|
246
|
-
} )
|
|
262
|
+
} catch ( err ) { }
|
|
263
|
+
|
|
264
|
+
const errorScope = await device.popErrorScope();
|
|
265
|
+
|
|
266
|
+
if ( errorScope !== null ) {
|
|
267
|
+
|
|
268
|
+
pipelineData.error = true;
|
|
269
|
+
|
|
270
|
+
error( errorScope.message );
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
resolve();
|
|
247
275
|
|
|
248
276
|
} );
|
|
249
277
|
|
|
@@ -266,12 +294,12 @@ class WebGPUPipelineUtils {
|
|
|
266
294
|
const { utils, device } = backend;
|
|
267
295
|
|
|
268
296
|
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext );
|
|
269
|
-
const
|
|
297
|
+
const colorFormats = utils.getCurrentColorFormats( renderContext );
|
|
270
298
|
const sampleCount = this._getSampleCount( renderContext );
|
|
271
299
|
|
|
272
300
|
const descriptor = {
|
|
273
|
-
label
|
|
274
|
-
colorFormats
|
|
301
|
+
label,
|
|
302
|
+
colorFormats,
|
|
275
303
|
depthStencilFormat,
|
|
276
304
|
sampleCount
|
|
277
305
|
};
|
|
@@ -407,11 +435,11 @@ class WebGPUPipelineUtils {
|
|
|
407
435
|
break;
|
|
408
436
|
|
|
409
437
|
case SubtractiveBlending:
|
|
410
|
-
|
|
438
|
+
error( 'WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true' );
|
|
411
439
|
break;
|
|
412
440
|
|
|
413
441
|
case MultiplyBlending:
|
|
414
|
-
|
|
442
|
+
error( 'WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true' );
|
|
415
443
|
break;
|
|
416
444
|
|
|
417
445
|
}
|
|
@@ -426,7 +454,7 @@ class WebGPUPipelineUtils {
|
|
|
426
454
|
|
|
427
455
|
} else {
|
|
428
456
|
|
|
429
|
-
|
|
457
|
+
error( 'WebGPURenderer: Invalid blending: ', blending );
|
|
430
458
|
|
|
431
459
|
}
|
|
432
460
|
|
|
@@ -497,7 +525,7 @@ class WebGPUPipelineUtils {
|
|
|
497
525
|
break;
|
|
498
526
|
|
|
499
527
|
default:
|
|
500
|
-
|
|
528
|
+
error( 'WebGPURenderer: Blend factor not supported.', blend );
|
|
501
529
|
|
|
502
530
|
}
|
|
503
531
|
|
|
@@ -553,7 +581,7 @@ class WebGPUPipelineUtils {
|
|
|
553
581
|
break;
|
|
554
582
|
|
|
555
583
|
default:
|
|
556
|
-
|
|
584
|
+
error( 'WebGPURenderer: Invalid stencil function.', stencilFunc );
|
|
557
585
|
|
|
558
586
|
}
|
|
559
587
|
|
|
@@ -607,7 +635,7 @@ class WebGPUPipelineUtils {
|
|
|
607
635
|
break;
|
|
608
636
|
|
|
609
637
|
default:
|
|
610
|
-
|
|
638
|
+
error( 'WebGPURenderer: Invalid stencil operation.', stencilOperation );
|
|
611
639
|
|
|
612
640
|
}
|
|
613
641
|
|
|
@@ -649,7 +677,7 @@ class WebGPUPipelineUtils {
|
|
|
649
677
|
break;
|
|
650
678
|
|
|
651
679
|
default:
|
|
652
|
-
|
|
680
|
+
error( 'WebGPUPipelineUtils: Blend equation not supported.', blendEquation );
|
|
653
681
|
|
|
654
682
|
}
|
|
655
683
|
|
|
@@ -765,7 +793,7 @@ class WebGPUPipelineUtils {
|
|
|
765
793
|
break;
|
|
766
794
|
|
|
767
795
|
default:
|
|
768
|
-
|
|
796
|
+
error( 'WebGPUPipelineUtils: Invalid depth function.', depthFunc );
|
|
769
797
|
|
|
770
798
|
}
|
|
771
799
|
|
|
@@ -310,29 +310,27 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
310
310
|
* @param {GPUTexture} textureGPU - The GPU texture object.
|
|
311
311
|
* @param {Object} textureGPUDescriptor - The texture descriptor.
|
|
312
312
|
* @param {number} [baseArrayLayer=0] - The index of the first array layer accessible to the texture view.
|
|
313
|
+
* @param {?GPUCommandEncoder} [encoder=null] - An optional command encoder used to generate mipmaps.
|
|
313
314
|
*/
|
|
314
|
-
generateMipmaps( textureGPU, textureGPUDescriptor, baseArrayLayer = 0 ) {
|
|
315
|
+
generateMipmaps( textureGPU, textureGPUDescriptor, baseArrayLayer = 0, encoder = null ) {
|
|
315
316
|
|
|
316
317
|
const textureData = this.get( textureGPU );
|
|
317
318
|
|
|
318
|
-
if ( textureData.
|
|
319
|
+
if ( textureData.layers === undefined ) {
|
|
319
320
|
|
|
320
|
-
textureData.useCount = 0;
|
|
321
321
|
textureData.layers = [];
|
|
322
322
|
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
const passes = textureData.layers[ baseArrayLayer ] || this._mipmapCreateBundles( textureGPU, textureGPUDescriptor, baseArrayLayer );
|
|
326
326
|
|
|
327
|
-
const commandEncoder = this.device.createCommandEncoder( {} );
|
|
327
|
+
const commandEncoder = encoder || this.device.createCommandEncoder( { label: 'mipmapEncoder' } );
|
|
328
328
|
|
|
329
329
|
this._mipmapRunBundles( commandEncoder, passes );
|
|
330
330
|
|
|
331
|
-
this.device.queue.submit( [ commandEncoder.finish() ] );
|
|
332
|
-
|
|
333
|
-
if ( textureData.useCount !== 0 ) textureData.layers[ baseArrayLayer ] = passes;
|
|
331
|
+
if ( encoder === null ) this.device.queue.submit( [ commandEncoder.finish() ] );
|
|
334
332
|
|
|
335
|
-
textureData.
|
|
333
|
+
textureData.layers[ baseArrayLayer ] = passes;
|
|
336
334
|
|
|
337
335
|
}
|
|
338
336
|
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
UnsignedInt101111Type, RGBA_BPTC_Format, RGB_ETC1_Format, RGB_S3TC_DXT1_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format
|
|
18
18
|
} from '../../../constants.js';
|
|
19
19
|
import { CubeTexture } from '../../../textures/CubeTexture.js';
|
|
20
|
-
import { DepthTexture } from '../../../textures/DepthTexture.js';
|
|
21
20
|
import { Texture } from '../../../textures/Texture.js';
|
|
21
|
+
import { warn, error } from '../../../utils.js';
|
|
22
22
|
|
|
23
23
|
const _compareToWebGPU = {
|
|
24
24
|
[ NeverCompare ]: 'never',
|
|
@@ -87,20 +87,11 @@ class WebGPUTextureUtils {
|
|
|
87
87
|
this.defaultVideoFrame = null;
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
90
|
+
* A cache of shared texture samplers.
|
|
91
91
|
*
|
|
92
|
-
* @type {
|
|
93
|
-
* @default null
|
|
94
|
-
*/
|
|
95
|
-
this.colorBuffer = null;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Represents the depth attachment of the default framebuffer.
|
|
99
|
-
*
|
|
100
|
-
* @type {DepthTexture}
|
|
92
|
+
* @type {Map<string, Object>}
|
|
101
93
|
*/
|
|
102
|
-
this.
|
|
103
|
-
this.depthTexture.name = 'depthBuffer';
|
|
94
|
+
this._samplerCache = new Map();
|
|
104
95
|
|
|
105
96
|
}
|
|
106
97
|
|
|
@@ -108,39 +99,81 @@ class WebGPUTextureUtils {
|
|
|
108
99
|
* Creates a GPU sampler for the given texture.
|
|
109
100
|
*
|
|
110
101
|
* @param {Texture} texture - The texture to create the sampler for.
|
|
102
|
+
* @return {string} The current sampler key.
|
|
111
103
|
*/
|
|
112
|
-
|
|
104
|
+
updateSampler( texture ) {
|
|
113
105
|
|
|
114
106
|
const backend = this.backend;
|
|
115
|
-
const device = backend.device;
|
|
116
|
-
|
|
117
|
-
const textureGPU = backend.get( texture );
|
|
118
|
-
|
|
119
|
-
const samplerDescriptorGPU = {
|
|
120
|
-
addressModeU: this._convertAddressMode( texture.wrapS ),
|
|
121
|
-
addressModeV: this._convertAddressMode( texture.wrapT ),
|
|
122
|
-
addressModeW: this._convertAddressMode( texture.wrapR ),
|
|
123
|
-
magFilter: this._convertFilterMode( texture.magFilter ),
|
|
124
|
-
minFilter: this._convertFilterMode( texture.minFilter ),
|
|
125
|
-
mipmapFilter: this._convertFilterMode( texture.minFilter ),
|
|
126
|
-
maxAnisotropy: 1
|
|
127
|
-
};
|
|
128
107
|
|
|
129
|
-
|
|
108
|
+
const samplerKey = texture.minFilter + '-' + texture.magFilter + '-' +
|
|
109
|
+
texture.wrapS + '-' + texture.wrapT + '-' + ( texture.wrapR || '0' ) + '-' +
|
|
110
|
+
texture.anisotropy + '-' + ( texture.compareFunction || 0 );
|
|
111
|
+
|
|
112
|
+
let samplerData = this._samplerCache.get( samplerKey );
|
|
113
|
+
|
|
114
|
+
if ( samplerData === undefined ) {
|
|
115
|
+
|
|
116
|
+
const samplerDescriptorGPU = {
|
|
117
|
+
addressModeU: this._convertAddressMode( texture.wrapS ),
|
|
118
|
+
addressModeV: this._convertAddressMode( texture.wrapT ),
|
|
119
|
+
addressModeW: this._convertAddressMode( texture.wrapR ),
|
|
120
|
+
magFilter: this._convertFilterMode( texture.magFilter ),
|
|
121
|
+
minFilter: this._convertFilterMode( texture.minFilter ),
|
|
122
|
+
mipmapFilter: this._convertFilterMode( texture.minFilter ),
|
|
123
|
+
maxAnisotropy: 1
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// anisotropy can only be used when all filter modes are set to linear.
|
|
127
|
+
|
|
128
|
+
if ( samplerDescriptorGPU.magFilter === GPUFilterMode.Linear && samplerDescriptorGPU.minFilter === GPUFilterMode.Linear && samplerDescriptorGPU.mipmapFilter === GPUFilterMode.Linear ) {
|
|
129
|
+
|
|
130
|
+
samplerDescriptorGPU.maxAnisotropy = texture.anisotropy;
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if ( texture.isDepthTexture && texture.compareFunction !== null ) {
|
|
135
|
+
|
|
136
|
+
samplerDescriptorGPU.compare = _compareToWebGPU[ texture.compareFunction ];
|
|
137
|
+
|
|
138
|
+
}
|
|
130
139
|
|
|
131
|
-
|
|
140
|
+
const sampler = backend.device.createSampler( samplerDescriptorGPU );
|
|
132
141
|
|
|
133
|
-
|
|
142
|
+
samplerData = { sampler, usedTimes: 0 };
|
|
143
|
+
|
|
144
|
+
this._samplerCache.set( samplerKey, samplerData );
|
|
134
145
|
|
|
135
146
|
}
|
|
136
147
|
|
|
137
|
-
|
|
148
|
+
const textureData = backend.get( texture );
|
|
149
|
+
|
|
150
|
+
if ( textureData.sampler !== samplerData.sampler ) {
|
|
151
|
+
|
|
152
|
+
// check if previous sampler is unused so it can be deleted
|
|
153
|
+
|
|
154
|
+
if ( textureData.sampler !== undefined ) {
|
|
138
155
|
|
|
139
|
-
|
|
156
|
+
const oldSamplerData = this._samplerCache.get( textureData.samplerKey );
|
|
157
|
+
oldSamplerData.usedTimes --;
|
|
158
|
+
|
|
159
|
+
if ( oldSamplerData.usedTimes === 0 ) {
|
|
160
|
+
|
|
161
|
+
this._samplerCache.delete( textureData.samplerKey );
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// update to new sampler data
|
|
168
|
+
|
|
169
|
+
textureData.samplerKey = samplerKey;
|
|
170
|
+
textureData.sampler = samplerData.sampler;
|
|
171
|
+
|
|
172
|
+
samplerData.usedTimes ++;
|
|
140
173
|
|
|
141
174
|
}
|
|
142
175
|
|
|
143
|
-
|
|
176
|
+
return samplerKey;
|
|
144
177
|
|
|
145
178
|
}
|
|
146
179
|
|
|
@@ -255,7 +288,7 @@ class WebGPUTextureUtils {
|
|
|
255
288
|
|
|
256
289
|
if ( format === undefined ) {
|
|
257
290
|
|
|
258
|
-
|
|
291
|
+
warn( 'WebGPURenderer: Texture format not supported.' );
|
|
259
292
|
|
|
260
293
|
this.createDefaultTexture( texture );
|
|
261
294
|
return;
|
|
@@ -292,13 +325,14 @@ class WebGPUTextureUtils {
|
|
|
292
325
|
* Destroys the GPU data for the given texture object.
|
|
293
326
|
*
|
|
294
327
|
* @param {Texture} texture - The texture.
|
|
328
|
+
* @param {boolean} [isDefaultTexture=false] - Whether the texture uses a default GPU texture or not.
|
|
295
329
|
*/
|
|
296
|
-
destroyTexture( texture ) {
|
|
330
|
+
destroyTexture( texture, isDefaultTexture = false ) {
|
|
297
331
|
|
|
298
332
|
const backend = this.backend;
|
|
299
333
|
const textureData = backend.get( texture );
|
|
300
334
|
|
|
301
|
-
if ( textureData.texture !== undefined ) textureData.texture.destroy();
|
|
335
|
+
if ( textureData.texture !== undefined && isDefaultTexture === false ) textureData.texture.destroy();
|
|
302
336
|
|
|
303
337
|
if ( textureData.msaaTexture !== undefined ) textureData.msaaTexture.destroy();
|
|
304
338
|
|
|
@@ -306,26 +340,13 @@ class WebGPUTextureUtils {
|
|
|
306
340
|
|
|
307
341
|
}
|
|
308
342
|
|
|
309
|
-
/**
|
|
310
|
-
* Destroys the GPU sampler for the given texture.
|
|
311
|
-
*
|
|
312
|
-
* @param {Texture} texture - The texture to destroy the sampler for.
|
|
313
|
-
*/
|
|
314
|
-
destroySampler( texture ) {
|
|
315
|
-
|
|
316
|
-
const backend = this.backend;
|
|
317
|
-
const textureData = backend.get( texture );
|
|
318
|
-
|
|
319
|
-
delete textureData.sampler;
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
343
|
/**
|
|
324
344
|
* Generates mipmaps for the given texture.
|
|
325
345
|
*
|
|
326
346
|
* @param {Texture} texture - The texture.
|
|
347
|
+
* @param {?GPUCommandEncoder} [encoder=null] - An optional command encoder used to generate mipmaps.
|
|
327
348
|
*/
|
|
328
|
-
generateMipmaps( texture ) {
|
|
349
|
+
generateMipmaps( texture, encoder = null ) {
|
|
329
350
|
|
|
330
351
|
const textureData = this.backend.get( texture );
|
|
331
352
|
|
|
@@ -333,7 +354,7 @@ class WebGPUTextureUtils {
|
|
|
333
354
|
|
|
334
355
|
for ( let i = 0; i < 6; i ++ ) {
|
|
335
356
|
|
|
336
|
-
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i );
|
|
357
|
+
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i, encoder );
|
|
337
358
|
|
|
338
359
|
}
|
|
339
360
|
|
|
@@ -343,7 +364,7 @@ class WebGPUTextureUtils {
|
|
|
343
364
|
|
|
344
365
|
for ( let i = 0; i < depth; i ++ ) {
|
|
345
366
|
|
|
346
|
-
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i );
|
|
367
|
+
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i, encoder );
|
|
347
368
|
|
|
348
369
|
}
|
|
349
370
|
|
|
@@ -359,24 +380,47 @@ class WebGPUTextureUtils {
|
|
|
359
380
|
*/
|
|
360
381
|
getColorBuffer() {
|
|
361
382
|
|
|
362
|
-
if ( this.colorBuffer ) this.colorBuffer.destroy();
|
|
363
|
-
|
|
364
383
|
const backend = this.backend;
|
|
384
|
+
const canvasTarget = backend.renderer.getCanvasTarget();
|
|
365
385
|
const { width, height } = backend.getDrawingBufferSize();
|
|
386
|
+
const samples = backend.renderer.currentSamples;
|
|
387
|
+
|
|
388
|
+
const colorTexture = canvasTarget.colorTexture;
|
|
389
|
+
const colorTextureData = backend.get( colorTexture );
|
|
366
390
|
|
|
367
|
-
|
|
391
|
+
if ( colorTexture.width === width && colorTexture.height === height && colorTexture.samples === samples ) {
|
|
392
|
+
|
|
393
|
+
return colorTextureData.texture;
|
|
394
|
+
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// recreate
|
|
398
|
+
|
|
399
|
+
let colorBuffer = colorTextureData.texture;
|
|
400
|
+
|
|
401
|
+
if ( colorBuffer ) colorBuffer.destroy();
|
|
402
|
+
|
|
403
|
+
colorBuffer = backend.device.createTexture( {
|
|
368
404
|
label: 'colorBuffer',
|
|
369
405
|
size: {
|
|
370
406
|
width: width,
|
|
371
407
|
height: height,
|
|
372
408
|
depthOrArrayLayers: 1
|
|
373
409
|
},
|
|
374
|
-
sampleCount: backend.utils.getSampleCount( backend.renderer.
|
|
410
|
+
sampleCount: backend.utils.getSampleCount( backend.renderer.currentSamples ),
|
|
375
411
|
format: backend.utils.getPreferredCanvasFormat(),
|
|
376
412
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
|
|
377
413
|
} );
|
|
378
414
|
|
|
379
|
-
|
|
415
|
+
//
|
|
416
|
+
|
|
417
|
+
colorTexture.source.width = width;
|
|
418
|
+
colorTexture.source.height = height;
|
|
419
|
+
colorTexture.samples = samples;
|
|
420
|
+
|
|
421
|
+
colorTextureData.texture = colorBuffer;
|
|
422
|
+
|
|
423
|
+
return colorBuffer;
|
|
380
424
|
|
|
381
425
|
}
|
|
382
426
|
|
|
@@ -391,9 +435,24 @@ class WebGPUTextureUtils {
|
|
|
391
435
|
getDepthBuffer( depth = true, stencil = false ) {
|
|
392
436
|
|
|
393
437
|
const backend = this.backend;
|
|
438
|
+
const canvasTarget = backend.renderer.getCanvasTarget();
|
|
394
439
|
const { width, height } = backend.getDrawingBufferSize();
|
|
440
|
+
const samples = backend.renderer.currentSamples;
|
|
441
|
+
|
|
442
|
+
const depthTexture = canvasTarget.depthTexture;
|
|
443
|
+
|
|
444
|
+
if ( depthTexture.width === width &&
|
|
445
|
+
depthTexture.height === height &&
|
|
446
|
+
depthTexture.samples === samples &&
|
|
447
|
+
depthTexture.depth === depth &&
|
|
448
|
+
depthTexture.stencil === stencil ) {
|
|
449
|
+
|
|
450
|
+
return backend.get( depthTexture ).texture;
|
|
451
|
+
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
//
|
|
395
455
|
|
|
396
|
-
const depthTexture = this.depthTexture;
|
|
397
456
|
const depthTextureGPU = backend.get( depthTexture ).texture;
|
|
398
457
|
|
|
399
458
|
let format, type;
|
|
@@ -412,7 +471,7 @@ class WebGPUTextureUtils {
|
|
|
412
471
|
|
|
413
472
|
if ( depthTextureGPU !== undefined ) {
|
|
414
473
|
|
|
415
|
-
if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type ) {
|
|
474
|
+
if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type && depthTexture.samples === samples ) {
|
|
416
475
|
|
|
417
476
|
return depthTextureGPU;
|
|
418
477
|
|
|
@@ -422,11 +481,14 @@ class WebGPUTextureUtils {
|
|
|
422
481
|
|
|
423
482
|
}
|
|
424
483
|
|
|
484
|
+
// recreate
|
|
485
|
+
|
|
425
486
|
depthTexture.name = 'depthBuffer';
|
|
426
487
|
depthTexture.format = format;
|
|
427
488
|
depthTexture.type = type;
|
|
428
489
|
depthTexture.image.width = width;
|
|
429
490
|
depthTexture.image.height = height;
|
|
491
|
+
depthTexture.samples = samples;
|
|
430
492
|
|
|
431
493
|
this.createTexture( depthTexture, { width, height } );
|
|
432
494
|
|
|
@@ -575,6 +637,15 @@ class WebGPUTextureUtils {
|
|
|
575
637
|
|
|
576
638
|
}
|
|
577
639
|
|
|
640
|
+
/**
|
|
641
|
+
* Frees all internal resources.
|
|
642
|
+
*/
|
|
643
|
+
dispose() {
|
|
644
|
+
|
|
645
|
+
this._samplerCache.clear();
|
|
646
|
+
|
|
647
|
+
}
|
|
648
|
+
|
|
578
649
|
/**
|
|
579
650
|
* Returns the default GPU texture for the given format.
|
|
580
651
|
*
|
|
@@ -744,10 +815,11 @@ class WebGPUTextureUtils {
|
|
|
744
815
|
* @param {GPUTexture} textureGPU - The GPU texture object.
|
|
745
816
|
* @param {Object} textureDescriptorGPU - The texture descriptor.
|
|
746
817
|
* @param {number} [baseArrayLayer=0] - The index of the first array layer accessible to the texture view.
|
|
818
|
+
* @param {?GPUCommandEncoder} [encoder=null] - An optional command encoder used to generate mipmaps.
|
|
747
819
|
*/
|
|
748
|
-
_generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0 ) {
|
|
820
|
+
_generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0, encoder = null ) {
|
|
749
821
|
|
|
750
|
-
this._getPassUtils().generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer );
|
|
822
|
+
this._getPassUtils().generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer, encoder );
|
|
751
823
|
|
|
752
824
|
}
|
|
753
825
|
|
|
@@ -1228,7 +1300,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1228
1300
|
break;
|
|
1229
1301
|
|
|
1230
1302
|
default:
|
|
1231
|
-
|
|
1303
|
+
error( 'WebGPURenderer: Unsupported texture format.', format );
|
|
1232
1304
|
|
|
1233
1305
|
}
|
|
1234
1306
|
|
|
@@ -1272,7 +1344,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1272
1344
|
break;
|
|
1273
1345
|
|
|
1274
1346
|
default:
|
|
1275
|
-
|
|
1347
|
+
error( 'WebGPURenderer: Unsupported texture type with RGBAFormat.', type );
|
|
1276
1348
|
|
|
1277
1349
|
}
|
|
1278
1350
|
|
|
@@ -1291,7 +1363,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1291
1363
|
break;
|
|
1292
1364
|
|
|
1293
1365
|
default:
|
|
1294
|
-
|
|
1366
|
+
error( 'WebGPURenderer: Unsupported texture type with RGBFormat.', type );
|
|
1295
1367
|
|
|
1296
1368
|
}
|
|
1297
1369
|
|
|
@@ -1334,7 +1406,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1334
1406
|
break;
|
|
1335
1407
|
|
|
1336
1408
|
default:
|
|
1337
|
-
|
|
1409
|
+
error( 'WebGPURenderer: Unsupported texture type with RedFormat.', type );
|
|
1338
1410
|
|
|
1339
1411
|
}
|
|
1340
1412
|
|
|
@@ -1377,7 +1449,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1377
1449
|
break;
|
|
1378
1450
|
|
|
1379
1451
|
default:
|
|
1380
|
-
|
|
1452
|
+
error( 'WebGPURenderer: Unsupported texture type with RGFormat.', type );
|
|
1381
1453
|
|
|
1382
1454
|
}
|
|
1383
1455
|
|
|
@@ -1400,7 +1472,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1400
1472
|
break;
|
|
1401
1473
|
|
|
1402
1474
|
default:
|
|
1403
|
-
|
|
1475
|
+
error( 'WebGPURenderer: Unsupported texture type with DepthFormat.', type );
|
|
1404
1476
|
|
|
1405
1477
|
}
|
|
1406
1478
|
|
|
@@ -1418,7 +1490,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1418
1490
|
|
|
1419
1491
|
if ( device && device.features.has( GPUFeatureName.Depth32FloatStencil8 ) === false ) {
|
|
1420
1492
|
|
|
1421
|
-
|
|
1493
|
+
error( 'WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.' );
|
|
1422
1494
|
|
|
1423
1495
|
}
|
|
1424
1496
|
|
|
@@ -1427,7 +1499,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1427
1499
|
break;
|
|
1428
1500
|
|
|
1429
1501
|
default:
|
|
1430
|
-
|
|
1502
|
+
error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );
|
|
1431
1503
|
|
|
1432
1504
|
}
|
|
1433
1505
|
|
|
@@ -1446,7 +1518,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1446
1518
|
break;
|
|
1447
1519
|
|
|
1448
1520
|
default:
|
|
1449
|
-
|
|
1521
|
+
error( 'WebGPURenderer: Unsupported texture type with RedIntegerFormat.', type );
|
|
1450
1522
|
|
|
1451
1523
|
}
|
|
1452
1524
|
|
|
@@ -1465,7 +1537,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1465
1537
|
break;
|
|
1466
1538
|
|
|
1467
1539
|
default:
|
|
1468
|
-
|
|
1540
|
+
error( 'WebGPURenderer: Unsupported texture type with RGIntegerFormat.', type );
|
|
1469
1541
|
|
|
1470
1542
|
}
|
|
1471
1543
|
|
|
@@ -1484,14 +1556,14 @@ export function getFormat( texture, device = null ) {
|
|
|
1484
1556
|
break;
|
|
1485
1557
|
|
|
1486
1558
|
default:
|
|
1487
|
-
|
|
1559
|
+
error( 'WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.', type );
|
|
1488
1560
|
|
|
1489
1561
|
}
|
|
1490
1562
|
|
|
1491
1563
|
break;
|
|
1492
1564
|
|
|
1493
1565
|
default:
|
|
1494
|
-
|
|
1566
|
+
error( 'WebGPURenderer: Unsupported texture format.', format );
|
|
1495
1567
|
|
|
1496
1568
|
}
|
|
1497
1569
|
|