super-three 0.167.0 → 0.168.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +165 -44
- package/build/three.module.js +165 -45
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +23600 -21931
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/Addons.js +3 -1
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +453 -452
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +11 -4
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +2 -1
- package/src/Three.WebGPU.js +6 -0
- package/src/Three.js +1 -0
- package/src/constants.js +1 -1
- package/src/extras/Controls.js +32 -0
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
- package/src/materials/Material.js +4 -7
- package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +176 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +48 -20
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +5 -5
- package/src/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
- package/src/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +5 -7
- package/src/nodes/accessors/InstanceNode.js +17 -13
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
- package/src/nodes/accessors/MaterialNode.js +52 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +11 -11
- package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/src/nodes/accessors/MorphNode.js +12 -12
- package/src/nodes/accessors/Normal.js +62 -0
- package/src/nodes/accessors/Object3DNode.js +10 -10
- package/src/nodes/accessors/PointUVNode.js +4 -4
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/src/nodes/accessors/ReferenceNode.js +13 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +6 -6
- package/src/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +84 -21
- package/src/nodes/accessors/StorageBufferNode.js +4 -5
- package/src/nodes/accessors/StorageTextureNode.js +5 -5
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +11 -11
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +16 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -6
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
- package/src/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +5 -5
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +5 -5
- package/src/nodes/code/FunctionNode.js +5 -23
- package/src/nodes/code/ScriptableNode.js +4 -6
- package/src/nodes/code/ScriptableValueNode.js +4 -6
- package/src/nodes/core/AssignNode.js +5 -5
- package/src/nodes/core/AttributeNode.js +7 -20
- package/src/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +5 -5
- package/src/nodes/core/ConstNode.js +2 -2
- package/src/nodes/core/ContextNode.js +17 -11
- package/src/nodes/core/IndexNode.js +12 -7
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/MRTNode.js +12 -6
- package/src/nodes/core/Node.js +39 -19
- package/src/nodes/core/NodeBuilder.js +46 -33
- package/src/nodes/core/NodeUtils.js +1 -0
- package/src/nodes/core/OutputStructNode.js +4 -4
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +32 -32
- package/src/nodes/core/StackNode.js +26 -10
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/TempNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +8 -9
- package/src/nodes/core/UniformNode.js +4 -4
- package/src/nodes/core/VarNode.js +6 -6
- package/src/nodes/core/VaryingNode.js +5 -5
- package/src/nodes/display/AfterImageNode.js +9 -9
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/src/nodes/display/AnamorphicNode.js +11 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +21 -19
- package/src/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +40 -63
- package/src/nodes/display/DenoiseNode.js +20 -17
- package/src/nodes/display/DepthOfFieldNode.js +8 -6
- package/src/nodes/display/DotScreenNode.js +10 -22
- package/src/nodes/display/FXAANode.js +17 -15
- package/src/nodes/display/FilmNode.js +7 -6
- package/src/nodes/display/FrontFacingNode.js +5 -5
- package/src/nodes/display/GTAONode.js +19 -15
- package/src/nodes/display/GaussianBlurNode.js +11 -8
- package/src/nodes/display/Lut3DNode.js +6 -5
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +8 -10
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +84 -8
- package/src/nodes/display/PixelationPassNode.js +12 -7
- package/src/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +8 -7
- package/src/nodes/display/RenderOutputNode.js +9 -9
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +9 -7
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +12 -173
- package/src/nodes/display/TransitionNode.js +9 -8
- package/src/nodes/display/ViewportDepthNode.js +30 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
- package/src/nodes/display/ViewportNode.js +26 -25
- package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
- package/src/nodes/display/ViewportTextureNode.js +7 -10
- package/src/nodes/fog/FogExp2Node.js +4 -6
- package/src/nodes/fog/FogNode.js +5 -7
- package/src/nodes/fog/FogRangeNode.js +4 -6
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +32 -31
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/geometry/RangeNode.js +4 -4
- package/src/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +2 -2
- package/src/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +34 -13
- package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
- package/src/nodes/lighting/BasicLightMapNode.js +3 -3
- package/src/nodes/lighting/DirectionalLightNode.js +2 -7
- package/src/nodes/lighting/EnvironmentNode.js +20 -19
- package/src/nodes/lighting/HemisphereLightNode.js +3 -7
- package/src/nodes/lighting/IESSpotLightNode.js +3 -8
- package/src/nodes/lighting/IrradianceNode.js +2 -2
- package/src/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +15 -17
- package/src/nodes/lighting/LightingNode.js +2 -2
- package/src/nodes/lighting/LightsNode.js +94 -76
- package/src/nodes/lighting/PointLightNode.js +3 -8
- package/src/nodes/lighting/RectAreaLightNode.js +2 -6
- package/src/nodes/lighting/SpotLightNode.js +3 -8
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +124 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +94 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +58 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +2 -2
- package/src/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +12 -6
- package/src/nodes/utils/MatcapUVNode.js +6 -6
- package/src/nodes/utils/MaxMipLevelNode.js +4 -4
- package/src/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +8 -8
- package/src/nodes/utils/ReflectorNode.js +8 -3
- package/src/nodes/utils/RemapNode.js +7 -7
- package/src/nodes/utils/RotateNode.js +4 -12
- package/src/nodes/utils/SetNode.js +2 -2
- package/src/nodes/utils/SplitNode.js +2 -2
- package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +4 -6
- package/src/nodes/utils/TimerNode.js +5 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/renderers/WebGLRenderer.js +24 -0
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/ClippingContext.js +14 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +24 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/Renderer.js +75 -49
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +12 -13
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +36 -9
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +61 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
- package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
- package/src/renderers/webgpu/WebGPUBackend.js +86 -68
- package/src/renderers/webgpu/WebGPURenderer.js +8 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -79,11 +79,11 @@ class WebGLTextureUtils {
|
|
|
79
79
|
|
|
80
80
|
glTextureType = gl.TEXTURE_CUBE_MAP;
|
|
81
81
|
|
|
82
|
-
} else if ( texture.isDataArrayTexture === true ) {
|
|
82
|
+
} else if ( texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
83
83
|
|
|
84
84
|
glTextureType = gl.TEXTURE_2D_ARRAY;
|
|
85
85
|
|
|
86
|
-
} else if ( texture.isData3DTexture === true ) {
|
|
86
|
+
} else if ( texture.isData3DTexture === true ) { // TODO: isCompressed3DTexture, wait for #26642
|
|
87
87
|
|
|
88
88
|
glTextureType = gl.TEXTURE_3D;
|
|
89
89
|
|
|
@@ -245,7 +245,11 @@ class WebGLTextureUtils {
|
|
|
245
245
|
|
|
246
246
|
const { gl, extensions, backend } = this;
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
|
|
249
|
+
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
250
|
+
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
251
|
+
gl.pixelStorei( gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
252
|
+
gl.pixelStorei( gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE );
|
|
249
253
|
|
|
250
254
|
gl.texParameteri( textureType, gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
251
255
|
gl.texParameteri( textureType, gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
@@ -259,8 +263,10 @@ class WebGLTextureUtils {
|
|
|
259
263
|
gl.texParameteri( textureType, gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
260
264
|
|
|
261
265
|
|
|
266
|
+
const hasMipmaps = texture.mipmaps !== undefined && texture.mipmaps.length > 0;
|
|
267
|
+
|
|
262
268
|
// follow WebGPU backend mapping for texture filtering
|
|
263
|
-
const minFilter =
|
|
269
|
+
const minFilter = texture.minFilter === LinearFilter && hasMipmaps ? LinearMipmapLinearFilter : texture.minFilter;
|
|
264
270
|
|
|
265
271
|
gl.texParameteri( textureType, gl.TEXTURE_MIN_FILTER, filterToGL[ minFilter ] );
|
|
266
272
|
|
|
@@ -277,11 +283,10 @@ class WebGLTextureUtils {
|
|
|
277
283
|
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
|
|
278
284
|
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
|
|
279
285
|
|
|
280
|
-
if ( texture.anisotropy > 1
|
|
286
|
+
if ( texture.anisotropy > 1 ) {
|
|
281
287
|
|
|
282
288
|
const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
283
289
|
gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, backend.getMaxAnisotropy() ) );
|
|
284
|
-
backend.get( texture ).currentAnisotropy = texture.anisotropy;
|
|
285
290
|
|
|
286
291
|
}
|
|
287
292
|
|
|
@@ -334,14 +339,9 @@ class WebGLTextureUtils {
|
|
|
334
339
|
|
|
335
340
|
backend.state.bindTexture( glTextureType, textureGPU );
|
|
336
341
|
|
|
337
|
-
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
338
|
-
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
339
|
-
gl.pixelStorei( gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
340
|
-
gl.pixelStorei( gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE );
|
|
341
|
-
|
|
342
342
|
this.setTextureParameters( glTextureType, texture );
|
|
343
343
|
|
|
344
|
-
if ( texture.isDataArrayTexture ) {
|
|
344
|
+
if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
|
|
345
345
|
|
|
346
346
|
gl.texStorage3D( gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, width, height, depth );
|
|
347
347
|
|
|
@@ -427,9 +427,12 @@ class WebGLTextureUtils {
|
|
|
427
427
|
|
|
428
428
|
this.backend.state.bindTexture( glTextureType, textureGPU );
|
|
429
429
|
|
|
430
|
+
this.setTextureParameters( glTextureType, texture );
|
|
431
|
+
|
|
430
432
|
if ( texture.isCompressedTexture ) {
|
|
431
433
|
|
|
432
434
|
const mipmaps = texture.mipmaps;
|
|
435
|
+
const image = options.image;
|
|
433
436
|
|
|
434
437
|
for ( let i = 0; i < mipmaps.length; i ++ ) {
|
|
435
438
|
|
|
@@ -437,7 +440,6 @@ class WebGLTextureUtils {
|
|
|
437
440
|
|
|
438
441
|
if ( texture.isCompressedArrayTexture ) {
|
|
439
442
|
|
|
440
|
-
const image = options.image;
|
|
441
443
|
|
|
442
444
|
if ( texture.format !== gl.RGBA ) {
|
|
443
445
|
|
|
@@ -474,6 +476,7 @@ class WebGLTextureUtils {
|
|
|
474
476
|
|
|
475
477
|
}
|
|
476
478
|
|
|
479
|
+
|
|
477
480
|
} else if ( texture.isCubeTexture ) {
|
|
478
481
|
|
|
479
482
|
const images = options.images;
|
|
@@ -527,7 +530,6 @@ class WebGLTextureUtils {
|
|
|
527
530
|
|
|
528
531
|
deallocateRenderBuffers( renderTarget ) {
|
|
529
532
|
|
|
530
|
-
|
|
531
533
|
const { gl, backend } = this;
|
|
532
534
|
|
|
533
535
|
// remove framebuffer reference
|
|
@@ -537,31 +539,36 @@ class WebGLTextureUtils {
|
|
|
537
539
|
|
|
538
540
|
renderContextData.renderBufferStorageSetup = undefined;
|
|
539
541
|
|
|
540
|
-
if ( renderContextData.
|
|
542
|
+
if ( renderContextData.framebuffers ) {
|
|
543
|
+
|
|
544
|
+
for ( const cacheKey in renderContextData.framebuffers ) {
|
|
545
|
+
|
|
546
|
+
gl.deleteFramebuffer( renderContextData.framebuffers[ cacheKey ] );
|
|
547
|
+
|
|
548
|
+
}
|
|
541
549
|
|
|
542
|
-
|
|
543
|
-
renderContextData.framebuffer = undefined;
|
|
550
|
+
delete renderContextData.framebuffers;
|
|
544
551
|
|
|
545
552
|
}
|
|
546
553
|
|
|
547
554
|
if ( renderContextData.depthRenderbuffer ) {
|
|
548
555
|
|
|
549
556
|
gl.deleteRenderbuffer( renderContextData.depthRenderbuffer );
|
|
550
|
-
renderContextData.depthRenderbuffer
|
|
557
|
+
delete renderContextData.depthRenderbuffer;
|
|
551
558
|
|
|
552
559
|
}
|
|
553
560
|
|
|
554
561
|
if ( renderContextData.stencilRenderbuffer ) {
|
|
555
562
|
|
|
556
563
|
gl.deleteRenderbuffer( renderContextData.stencilRenderbuffer );
|
|
557
|
-
renderContextData.stencilRenderbuffer
|
|
564
|
+
delete renderContextData.stencilRenderbuffer;
|
|
558
565
|
|
|
559
566
|
}
|
|
560
567
|
|
|
561
568
|
if ( renderContextData.msaaFrameBuffer ) {
|
|
562
569
|
|
|
563
570
|
gl.deleteFramebuffer( renderContextData.msaaFrameBuffer );
|
|
564
|
-
renderContextData.msaaFrameBuffer
|
|
571
|
+
delete renderContextData.msaaFrameBuffer;
|
|
565
572
|
|
|
566
573
|
}
|
|
567
574
|
|
|
@@ -573,7 +580,7 @@ class WebGLTextureUtils {
|
|
|
573
580
|
|
|
574
581
|
}
|
|
575
582
|
|
|
576
|
-
renderContextData.msaaRenderbuffers
|
|
583
|
+
delete renderContextData.msaaRenderbuffers;
|
|
577
584
|
|
|
578
585
|
}
|
|
579
586
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import 'https://greggman.github.io/webgpu-avoid-redundant-state-setting/webgpu-check-redundant-state-setting.js';
|
|
3
3
|
//*/
|
|
4
4
|
|
|
5
|
-
import { GPUFeatureName,
|
|
5
|
+
import { GPUFeatureName, GPULoadOp, GPUStoreOp, GPUIndexFormat, GPUTextureViewDimension } from './utils/WebGPUConstants.js';
|
|
6
6
|
|
|
7
7
|
import WGSLNodeBuilder from './nodes/WGSLNodeBuilder.js';
|
|
8
8
|
import Backend from '../common/Backend.js';
|
|
@@ -108,9 +108,11 @@ class WebGPUBackend extends Backend {
|
|
|
108
108
|
|
|
109
109
|
const alphaMode = parameters.alpha ? 'premultiplied' : 'opaque';
|
|
110
110
|
|
|
111
|
+
this.trackTimestamp = this.trackTimestamp && this.hasFeature( GPUFeatureName.TimestampQuery );
|
|
112
|
+
|
|
111
113
|
this.context.configure( {
|
|
112
114
|
device: this.device,
|
|
113
|
-
format:
|
|
115
|
+
format: this.utils.getPreferredCanvasFormat(),
|
|
114
116
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
|
|
115
117
|
alphaMode: alphaMode
|
|
116
118
|
} );
|
|
@@ -193,22 +195,16 @@ class WebGPUBackend extends Backend {
|
|
|
193
195
|
|
|
194
196
|
let descriptors = renderTargetData.descriptors;
|
|
195
197
|
|
|
196
|
-
if ( descriptors === undefined
|
|
197
|
-
|
|
198
|
-
descriptors = [];
|
|
199
|
-
|
|
200
|
-
renderTargetData.descriptors = descriptors;
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if ( renderTargetData.width !== renderTarget.width ||
|
|
198
|
+
if ( descriptors === undefined ||
|
|
199
|
+
renderTargetData.width !== renderTarget.width ||
|
|
205
200
|
renderTargetData.height !== renderTarget.height ||
|
|
206
201
|
renderTargetData.activeMipmapLevel !== renderTarget.activeMipmapLevel ||
|
|
207
|
-
renderTargetData.samples !== renderTarget.samples
|
|
208
|
-
descriptors.length !== renderTarget.textures.length
|
|
202
|
+
renderTargetData.samples !== renderTarget.samples
|
|
209
203
|
) {
|
|
210
204
|
|
|
211
|
-
descriptors
|
|
205
|
+
descriptors = {};
|
|
206
|
+
|
|
207
|
+
renderTargetData.descriptors = descriptors;
|
|
212
208
|
|
|
213
209
|
// dispose
|
|
214
210
|
|
|
@@ -224,7 +220,9 @@ class WebGPUBackend extends Backend {
|
|
|
224
220
|
|
|
225
221
|
}
|
|
226
222
|
|
|
227
|
-
|
|
223
|
+
const cacheKey = renderContext.getCacheKey();
|
|
224
|
+
|
|
225
|
+
let descriptor = descriptors[ cacheKey ];
|
|
228
226
|
|
|
229
227
|
if ( descriptor === undefined ) {
|
|
230
228
|
|
|
@@ -276,7 +274,7 @@ class WebGPUBackend extends Backend {
|
|
|
276
274
|
depthStencilAttachment
|
|
277
275
|
};
|
|
278
276
|
|
|
279
|
-
descriptors[
|
|
277
|
+
descriptors[ cacheKey ] = descriptor;
|
|
280
278
|
|
|
281
279
|
renderTargetData.width = renderTarget.width;
|
|
282
280
|
renderTargetData.height = renderTarget.height;
|
|
@@ -349,7 +347,7 @@ class WebGPUBackend extends Backend {
|
|
|
349
347
|
|
|
350
348
|
if ( renderContext.clearColor ) {
|
|
351
349
|
|
|
352
|
-
colorAttachment.clearValue = renderContext.clearColorValue;
|
|
350
|
+
colorAttachment.clearValue = i === 0 ? renderContext.clearColorValue : { r: 0, g: 0, b: 0, a: 1 };
|
|
353
351
|
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
354
352
|
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
355
353
|
|
|
@@ -427,7 +425,8 @@ class WebGPUBackend extends Backend {
|
|
|
427
425
|
renderContextData.descriptor = descriptor;
|
|
428
426
|
renderContextData.encoder = encoder;
|
|
429
427
|
renderContextData.currentPass = currentPass;
|
|
430
|
-
renderContextData.currentSets = { attributes: {} };
|
|
428
|
+
renderContextData.currentSets = { attributes: {}, pipeline: null, index: null };
|
|
429
|
+
renderContextData.renderBundles = [];
|
|
431
430
|
|
|
432
431
|
//
|
|
433
432
|
|
|
@@ -441,7 +440,7 @@ class WebGPUBackend extends Backend {
|
|
|
441
440
|
|
|
442
441
|
const { x, y, width, height } = renderContext.scissorValue;
|
|
443
442
|
|
|
444
|
-
currentPass.setScissorRect( x,
|
|
443
|
+
currentPass.setScissorRect( x, y, width, height );
|
|
445
444
|
|
|
446
445
|
}
|
|
447
446
|
|
|
@@ -452,9 +451,8 @@ class WebGPUBackend extends Backend {
|
|
|
452
451
|
const renderContextData = this.get( renderContext );
|
|
453
452
|
const occlusionQueryCount = renderContext.occlusionQueryCount;
|
|
454
453
|
|
|
455
|
-
if ( renderContextData.renderBundles
|
|
454
|
+
if ( renderContextData.renderBundles.length > 0 ) {
|
|
456
455
|
|
|
457
|
-
renderContextData.registerBundlesPhase = false;
|
|
458
456
|
renderContextData.currentPass.executeBundles( renderContextData.renderBundles );
|
|
459
457
|
|
|
460
458
|
}
|
|
@@ -587,7 +585,7 @@ class WebGPUBackend extends Backend {
|
|
|
587
585
|
const { currentPass } = this.get( renderContext );
|
|
588
586
|
const { x, y, width, height, minDepth, maxDepth } = renderContext.viewportValue;
|
|
589
587
|
|
|
590
|
-
currentPass.setViewport( x,
|
|
588
|
+
currentPass.setViewport( x, y, width, height, minDepth, maxDepth );
|
|
591
589
|
|
|
592
590
|
}
|
|
593
591
|
|
|
@@ -608,7 +606,19 @@ class WebGPUBackend extends Backend {
|
|
|
608
606
|
|
|
609
607
|
const clearColor = this.getClearColor();
|
|
610
608
|
|
|
611
|
-
|
|
609
|
+
if ( this.renderer.alpha === true ) {
|
|
610
|
+
|
|
611
|
+
// premultiply alpha
|
|
612
|
+
|
|
613
|
+
const a = clearColor.a;
|
|
614
|
+
|
|
615
|
+
clearValue = { r: clearColor.r * a, g: clearColor.g * a, b: clearColor.b * a, a: a };
|
|
616
|
+
|
|
617
|
+
} else {
|
|
618
|
+
|
|
619
|
+
clearValue = { r: clearColor.r, g: clearColor.g, b: clearColor.b, a: clearColor.a };
|
|
620
|
+
|
|
621
|
+
}
|
|
612
622
|
|
|
613
623
|
}
|
|
614
624
|
|
|
@@ -820,26 +830,11 @@ class WebGPUBackend extends Backend {
|
|
|
820
830
|
draw( renderObject, info ) {
|
|
821
831
|
|
|
822
832
|
const { object, geometry, context, pipeline } = renderObject;
|
|
823
|
-
|
|
824
833
|
const bindings = renderObject.getBindings();
|
|
825
|
-
const contextData = this.get( context );
|
|
826
|
-
const pipelineGPU = this.get( pipeline ).pipeline;
|
|
827
|
-
const currentSets = contextData.currentSets;
|
|
828
|
-
|
|
829
|
-
const renderObjectData = this.get( renderObject );
|
|
830
|
-
|
|
831
|
-
const { bundleEncoder, renderBundle, lastPipelineGPU } = renderObjectData;
|
|
832
|
-
|
|
833
834
|
const renderContextData = this.get( context );
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
renderContextData.renderBundles.push( renderBundle );
|
|
838
|
-
return;
|
|
839
|
-
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
const passEncoderGPU = this.renderer._currentRenderBundle ? this.createBundleEncoder( context, renderObject ) : contextData.currentPass;
|
|
835
|
+
const pipelineGPU = this.get( pipeline ).pipeline;
|
|
836
|
+
const currentSets = renderContextData.currentSets;
|
|
837
|
+
const passEncoderGPU = renderContextData.currentPass;
|
|
843
838
|
|
|
844
839
|
// pipeline
|
|
845
840
|
|
|
@@ -858,7 +853,7 @@ class WebGPUBackend extends Backend {
|
|
|
858
853
|
const bindGroup = bindings[ i ];
|
|
859
854
|
const bindingsData = this.get( bindGroup );
|
|
860
855
|
|
|
861
|
-
passEncoderGPU.setBindGroup(
|
|
856
|
+
passEncoderGPU.setBindGroup( bindGroup.index, bindingsData.group );
|
|
862
857
|
|
|
863
858
|
}
|
|
864
859
|
|
|
@@ -906,27 +901,27 @@ class WebGPUBackend extends Backend {
|
|
|
906
901
|
|
|
907
902
|
// occlusion queries - handle multiple consecutive draw calls for an object
|
|
908
903
|
|
|
909
|
-
if (
|
|
904
|
+
if ( renderContextData.occlusionQuerySet !== undefined ) {
|
|
910
905
|
|
|
911
|
-
const lastObject =
|
|
906
|
+
const lastObject = renderContextData.lastOcclusionObject;
|
|
912
907
|
|
|
913
908
|
if ( lastObject !== object ) {
|
|
914
909
|
|
|
915
910
|
if ( lastObject !== null && lastObject.occlusionTest === true ) {
|
|
916
911
|
|
|
917
912
|
passEncoderGPU.endOcclusionQuery();
|
|
918
|
-
|
|
913
|
+
renderContextData.occlusionQueryIndex ++;
|
|
919
914
|
|
|
920
915
|
}
|
|
921
916
|
|
|
922
917
|
if ( object.occlusionTest === true ) {
|
|
923
918
|
|
|
924
|
-
passEncoderGPU.beginOcclusionQuery(
|
|
925
|
-
|
|
919
|
+
passEncoderGPU.beginOcclusionQuery( renderContextData.occlusionQueryIndex );
|
|
920
|
+
renderContextData.occlusionQueryObjects[ renderContextData.occlusionQueryIndex ] = object;
|
|
926
921
|
|
|
927
922
|
}
|
|
928
923
|
|
|
929
|
-
|
|
924
|
+
renderContextData.lastOcclusionObject = object;
|
|
930
925
|
|
|
931
926
|
}
|
|
932
927
|
|
|
@@ -947,14 +942,14 @@ class WebGPUBackend extends Backend {
|
|
|
947
942
|
const drawCount = object._multiDrawCount;
|
|
948
943
|
const drawInstances = object._multiDrawInstances;
|
|
949
944
|
|
|
950
|
-
const bytesPerElement = index.
|
|
945
|
+
const bytesPerElement = hasIndex ? index.array.BYTES_PER_ELEMENT : 1;
|
|
951
946
|
|
|
952
947
|
for ( let i = 0; i < drawCount; i ++ ) {
|
|
953
948
|
|
|
954
949
|
const count = drawInstances ? drawInstances[ i ] : 1;
|
|
955
950
|
const firstInstance = count > 1 ? 0 : i;
|
|
956
951
|
|
|
957
|
-
passEncoderGPU.drawIndexed( counts[ i ]
|
|
952
|
+
passEncoderGPU.drawIndexed( counts[ i ], count, starts[ i ] / bytesPerElement, 0, firstInstance );
|
|
958
953
|
|
|
959
954
|
}
|
|
960
955
|
|
|
@@ -977,15 +972,6 @@ class WebGPUBackend extends Backend {
|
|
|
977
972
|
|
|
978
973
|
}
|
|
979
974
|
|
|
980
|
-
if ( this.renderer._currentRenderBundle ) {
|
|
981
|
-
|
|
982
|
-
const renderBundle = passEncoderGPU.finish();
|
|
983
|
-
renderObjectData.lastPipelineGPU = pipelineGPU;
|
|
984
|
-
renderObjectData.renderBundle = renderBundle;
|
|
985
|
-
renderObjectData.bundleEncoder = passEncoderGPU;
|
|
986
|
-
|
|
987
|
-
}
|
|
988
|
-
|
|
989
975
|
}
|
|
990
976
|
|
|
991
977
|
// cache key
|
|
@@ -1018,7 +1004,7 @@ class WebGPUBackend extends Backend {
|
|
|
1018
1004
|
data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
|
|
1019
1005
|
data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
|
|
1020
1006
|
data.primitiveTopology !== primitiveTopology ||
|
|
1021
|
-
data.
|
|
1007
|
+
data.clippingContextCacheKey !== renderObject.clippingContext.cacheKey
|
|
1022
1008
|
) {
|
|
1023
1009
|
|
|
1024
1010
|
data.material = material; data.materialVersion = material.version;
|
|
@@ -1036,7 +1022,7 @@ class WebGPUBackend extends Backend {
|
|
|
1036
1022
|
data.colorFormat = colorFormat;
|
|
1037
1023
|
data.depthStencilFormat = depthStencilFormat;
|
|
1038
1024
|
data.primitiveTopology = primitiveTopology;
|
|
1039
|
-
data.
|
|
1025
|
+
data.clippingContextCacheKey = renderObject.clippingContext.cacheKey;
|
|
1040
1026
|
|
|
1041
1027
|
needsUpdate = true;
|
|
1042
1028
|
|
|
@@ -1066,11 +1052,12 @@ class WebGPUBackend extends Backend {
|
|
|
1066
1052
|
utils.getSampleCountRenderContext( renderContext ),
|
|
1067
1053
|
utils.getCurrentColorSpace( renderContext ), utils.getCurrentColorFormat( renderContext ), utils.getCurrentDepthStencilFormat( renderContext ),
|
|
1068
1054
|
utils.getPrimitiveTopology( object, material ),
|
|
1069
|
-
renderObject.
|
|
1055
|
+
renderObject.clippingContext.cacheKey
|
|
1070
1056
|
].join();
|
|
1071
1057
|
|
|
1072
1058
|
}
|
|
1073
1059
|
|
|
1060
|
+
|
|
1074
1061
|
// textures
|
|
1075
1062
|
|
|
1076
1063
|
createSampler( texture ) {
|
|
@@ -1124,7 +1111,7 @@ class WebGPUBackend extends Backend {
|
|
|
1124
1111
|
|
|
1125
1112
|
initTimestampQuery( renderContext, descriptor ) {
|
|
1126
1113
|
|
|
1127
|
-
if ( ! this.
|
|
1114
|
+
if ( ! this.trackTimestamp ) return;
|
|
1128
1115
|
|
|
1129
1116
|
const renderContextData = this.get( renderContext );
|
|
1130
1117
|
|
|
@@ -1154,10 +1141,11 @@ class WebGPUBackend extends Backend {
|
|
|
1154
1141
|
|
|
1155
1142
|
prepareTimestampBuffer( renderContext, encoder ) {
|
|
1156
1143
|
|
|
1157
|
-
if ( ! this.
|
|
1144
|
+
if ( ! this.trackTimestamp ) return;
|
|
1158
1145
|
|
|
1159
1146
|
const renderContextData = this.get( renderContext );
|
|
1160
1147
|
|
|
1148
|
+
|
|
1161
1149
|
const size = 2 * BigInt64Array.BYTES_PER_ELEMENT;
|
|
1162
1150
|
|
|
1163
1151
|
if ( renderContextData.currentTimestampQueryBuffers === undefined ) {
|
|
@@ -1189,7 +1177,7 @@ class WebGPUBackend extends Backend {
|
|
|
1189
1177
|
|
|
1190
1178
|
async resolveTimestampAsync( renderContext, type = 'render' ) {
|
|
1191
1179
|
|
|
1192
|
-
if ( ! this.
|
|
1180
|
+
if ( ! this.trackTimestamp ) return;
|
|
1193
1181
|
|
|
1194
1182
|
const renderContextData = this.get( renderContext );
|
|
1195
1183
|
|
|
@@ -1258,9 +1246,39 @@ class WebGPUBackend extends Backend {
|
|
|
1258
1246
|
|
|
1259
1247
|
}
|
|
1260
1248
|
|
|
1261
|
-
|
|
1249
|
+
beginBundle( renderContext ) {
|
|
1250
|
+
|
|
1251
|
+
const renderContextData = this.get( renderContext );
|
|
1252
|
+
|
|
1253
|
+
renderContextData._currentPass = renderContextData.currentPass;
|
|
1254
|
+
renderContextData._currentSets = renderContextData.currentSets;
|
|
1255
|
+
|
|
1256
|
+
renderContextData.currentSets = { attributes: {}, pipeline: null, index: null };
|
|
1257
|
+
renderContextData.currentPass = this.pipelineUtils.createBundleEncoder( renderContext );
|
|
1258
|
+
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
finishBundle( renderContext, bundle ) {
|
|
1262
|
+
|
|
1263
|
+
const renderContextData = this.get( renderContext );
|
|
1264
|
+
|
|
1265
|
+
const bundleEncoder = renderContextData.currentPass;
|
|
1266
|
+
const bundleGPU = bundleEncoder.finish();
|
|
1267
|
+
|
|
1268
|
+
this.get( bundle ).bundleGPU = bundleGPU;
|
|
1269
|
+
|
|
1270
|
+
// restore render pass state
|
|
1271
|
+
|
|
1272
|
+
renderContextData.currentSets = renderContextData._currentSets;
|
|
1273
|
+
renderContextData.currentPass = renderContextData._currentPass;
|
|
1274
|
+
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
addBundle( renderContext, bundle ) {
|
|
1278
|
+
|
|
1279
|
+
const renderContextData = this.get( renderContext );
|
|
1262
1280
|
|
|
1263
|
-
|
|
1281
|
+
renderContextData.renderBundles.push( this.get( bundle ).bundleGPU );
|
|
1264
1282
|
|
|
1265
1283
|
}
|
|
1266
1284
|
|
|
@@ -1464,7 +1482,7 @@ class WebGPUBackend extends Backend {
|
|
|
1464
1482
|
if ( renderContext.stencil ) descriptor.depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
1465
1483
|
|
|
1466
1484
|
renderContextData.currentPass = encoder.beginRenderPass( descriptor );
|
|
1467
|
-
renderContextData.currentSets = { attributes: {} };
|
|
1485
|
+
renderContextData.currentSets = { attributes: {}, pipeline: null, index: null };
|
|
1468
1486
|
|
|
1469
1487
|
}
|
|
1470
1488
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import Renderer from '../common/Renderer.js';
|
|
1
|
+
import StandardRenderer from '../common/StandardRenderer.js';
|
|
4
2
|
import WebGLBackend from '../webgl-fallback/WebGLBackend.js';
|
|
5
3
|
import WebGPUBackend from './WebGPUBackend.js';
|
|
6
4
|
/*
|
|
@@ -17,7 +15,7 @@ const debugHandler = {
|
|
|
17
15
|
|
|
18
16
|
};
|
|
19
17
|
*/
|
|
20
|
-
class WebGPURenderer extends
|
|
18
|
+
class WebGPURenderer extends StandardRenderer {
|
|
21
19
|
|
|
22
20
|
constructor( parameters = {} ) {
|
|
23
21
|
|
|
@@ -27,15 +25,17 @@ class WebGPURenderer extends Renderer {
|
|
|
27
25
|
|
|
28
26
|
BackendClass = WebGLBackend;
|
|
29
27
|
|
|
30
|
-
} else
|
|
28
|
+
} else {
|
|
31
29
|
|
|
32
30
|
BackendClass = WebGPUBackend;
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
parameters.getFallback = () => {
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
console.warn( 'THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.' );
|
|
35
|
+
|
|
36
|
+
return new WebGLBackend( parameters );
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
};
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
|