rhodonite 0.25.0 → 0.26.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/README.md +93 -19
- package/VERSION-FILE +1 -1
- package/dist/esm/foundation/components/BlendShape/BlendShapeComponent.d.ts +54 -0
- package/dist/esm/foundation/components/BlendShape/BlendShapeComponent.js +1 -1
- package/dist/esm/foundation/components/Camera/CameraComponent.d.ts +34 -0
- package/dist/esm/foundation/components/Camera/CameraComponent.js +1 -1
- package/dist/esm/foundation/components/Light/LightComponent.d.ts +3 -1
- package/dist/esm/foundation/components/Light/LightComponent.js +1 -1
- package/dist/esm/foundation/components/Mesh/MeshComponent.js +1 -1
- package/dist/esm/foundation/components/MeshRenderer/MeshRendererComponent.js +1 -1
- package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.d.ts +16 -0
- package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.js +1 -1
- package/dist/esm/foundation/components/Shape/ShapeComponent.js +1 -1
- package/dist/esm/foundation/components/Skeletal/AnimationRetarget/AbsoluteAnimation.js +1 -1
- package/dist/esm/foundation/components/Skeletal/AnimationRetarget/GlobalRetarget.js +1 -1
- package/dist/esm/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +1 -1
- package/dist/esm/foundation/components/Skeletal/SkeletalComponent.d.ts +48 -0
- package/dist/esm/foundation/components/Skeletal/SkeletalComponent.js +1 -1
- package/dist/esm/foundation/components/Transform/TransformComponent.js +1 -1
- package/dist/esm/foundation/components/Trigger/TriggerComponent.js +1 -1
- package/dist/esm/foundation/components/Vrm/VrmComponent.js +1 -1
- package/dist/esm/foundation/constraints/VrmAimConstraint.js +1 -1
- package/dist/esm/foundation/constraints/VrmRollConstraint.js +1 -1
- package/dist/esm/foundation/constraints/VrmRotationConstraint.js +1 -1
- package/dist/esm/foundation/core/Component.js +1 -1
- package/dist/esm/foundation/core/ComponentRepository.js +1 -1
- package/dist/esm/foundation/core/Entity.js +1 -1
- package/dist/esm/foundation/core/EntityRepository.js +1 -1
- package/dist/esm/foundation/geometry/ComplexVertexAttribute.js +1 -1
- package/dist/esm/foundation/geometry/Mesh.js +1 -1
- package/dist/esm/foundation/geometry/Primitive.js +1 -1
- package/dist/esm/foundation/gizmos/AABBGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/CapsuleColliderGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/Gizmo.d.ts +13 -0
- package/dist/esm/foundation/gizmos/Gizmo.js +1 -1
- package/dist/esm/foundation/gizmos/JointGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/LightGizmo.d.ts +0 -1
- package/dist/esm/foundation/gizmos/LightGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/LocatorGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/RotationGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/ScaleGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/ShapeGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/SphereColliderGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/TranslationGizmo.js +1 -1
- package/dist/esm/foundation/helpers/BloomHelper.js +1 -1
- package/dist/esm/foundation/helpers/GaussianBlurHelper.js +1 -1
- package/dist/esm/foundation/helpers/Shadow/PointShadowMap.js +1 -1
- package/dist/esm/foundation/helpers/Shadow/ShadowMap.js +1 -1
- package/dist/esm/foundation/helpers/Shadow/ShadowSystem.js +1 -1
- package/dist/esm/foundation/helpers/materials/createMotionVectorMaterial.d.ts +25 -0
- package/dist/esm/foundation/helpers/materials/createMotionVectorMaterial.js +1 -0
- package/dist/esm/foundation/helpers/materials/createTemporalAAResolveMaterial.d.ts +33 -0
- package/dist/esm/foundation/helpers/materials/createTemporalAAResolveMaterial.js +1 -0
- package/dist/esm/foundation/importer/AnimationAssigner.js +1 -1
- package/dist/esm/foundation/importer/DrcPointCloudImporter.js +1 -1
- package/dist/esm/foundation/importer/Gltf2Importer.js +1 -1
- package/dist/esm/foundation/importer/GltfImporter.js +1 -1
- package/dist/esm/foundation/importer/ModelConverter.js +1 -1
- package/dist/esm/foundation/importer/RhodoniteImportExtension.js +1 -1
- package/dist/esm/foundation/importer/Vrm0xImporter.js +1 -1
- package/dist/esm/foundation/importer/VrmImporter.js +1 -1
- package/dist/esm/foundation/materials/contents/CustomMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/MToon0xMaterialContent.js +18 -18
- package/dist/esm/foundation/materials/contents/MToon1MaterialContent.js +6 -6
- package/dist/esm/foundation/materials/core/AbstractMaterialContent.d.ts +11 -0
- package/dist/esm/foundation/materials/core/AbstractMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/core/ShaderityUtilityWebGL.js +2 -2
- package/dist/esm/foundation/materials/core/ShaderityUtilityWebGPU.js +2 -2
- package/dist/esm/foundation/materials/nodes/CastToFloatShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/MergeVectorShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/Random_HashPRNGShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/Random_SinHashShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/SplitVectorShaderNode.js +1 -1
- package/dist/esm/foundation/math/MathClassUtil.js +1 -1
- package/dist/esm/foundation/math/Quaternion.js +1 -1
- package/dist/esm/foundation/math/Transform3D.js +1 -1
- package/dist/esm/foundation/math/shapes/MathSphere.js +1 -1
- package/dist/esm/foundation/memory/Accessor.js +6 -6
- package/dist/esm/foundation/memory/BufferView.js +1 -1
- package/dist/esm/foundation/misc/cache/Cache.js +1 -1
- package/dist/esm/foundation/physics/VRMSpring/CapsuleCollider.js +1 -1
- package/dist/esm/foundation/physics/VRMSpring/SphereCollider.js +1 -1
- package/dist/esm/foundation/physics/VRMSpring/VRMSpringBone.js +1 -1
- package/dist/esm/foundation/renderer/Frame.js +1 -1
- package/dist/esm/foundation/renderer/RenderPass.js +1 -1
- package/dist/esm/foundation/renderer/TemporalAA/PreviousFrameDataTracker.d.ts +33 -0
- package/dist/esm/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +1 -0
- package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.d.ts +135 -0
- package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.js +1 -0
- package/dist/esm/foundation/renderer/pipelines/DeferredRenderPipeline.js +1 -1
- package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +62 -16
- package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.js +1 -1
- package/dist/esm/foundation/system/Engine.d.ts +37 -3
- package/dist/esm/foundation/system/Engine.js +1 -1
- package/dist/esm/foundation/textures/AbstractTexture.js +1 -1
- package/dist/esm/foundation/textures/CubeTexture.js +1 -1
- package/dist/esm/foundation/textures/RenderTargetTexture.js +1 -1
- package/dist/esm/foundation/textures/RenderTargetTexture2DArray.js +1 -1
- package/dist/esm/foundation/textures/RenderTargetTextureCube.js +1 -1
- package/dist/esm/foundation/textures/Texture.js +1 -1
- package/dist/esm/foundation/textures/TextureDataFloat.js +1 -1
- package/dist/esm/foundation/textures/VideoTexture.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/webgl/MultiDraw.js +1 -1
- package/dist/esm/webgl/MultiDrawRepository.js +1 -1
- package/dist/esm/webgl/WebGLStereoUtil.js +1 -1
- package/dist/esm/webgl/WebGLStrategyWebGL2.d.ts +8 -0
- package/dist/esm/webgl/WebGLStrategyWebGL2.js +47 -28
- package/dist/esm/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +0 -3
- package/dist/esm/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.js +35 -0
- package/dist/esm/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +140 -0
- package/dist/esm/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.js +175 -0
- package/dist/esm/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.js +18 -0
- package/dist/esm/webgl/shaders/StandardShaderPart.js +3 -3
- package/dist/esm/webgl/shaders/nodes/ConstantVariableShader.js +5 -5
- package/dist/esm/webgl/shaders/nodes/UniformDataShader.js +9 -9
- package/dist/esm/webgpu/GpuCullingRegistry.js +1 -1
- package/dist/esm/webgpu/GpuDeformRegistry.js +1 -1
- package/dist/esm/webgpu/WebGpuGpuCulling.js +1 -1
- package/dist/esm/webgpu/WebGpuGpuTimer.js +1 -1
- package/dist/esm/webgpu/WebGpuLightClusterBuilder.js +1 -1
- package/dist/esm/webgpu/WebGpuResourceRepository.js +3 -3
- package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +8 -0
- package/dist/esm/webgpu/WebGpuStrategyBasic.js +78 -59
- package/dist/esm/webgpu/WebGpuVertexDeformer.js +1 -1
- package/dist/esm/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.wgsl.js +30 -0
- package/dist/esm/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.wgsl.js +133 -0
- package/dist/esm/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.wgsl.js +169 -0
- package/dist/esm/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.wgsl.js +19 -0
- package/dist/esmdev/foundation/components/BlendShape/BlendShapeComponent.d.ts +54 -0
- package/dist/esmdev/foundation/components/BlendShape/BlendShapeComponent.js +107 -1
- package/dist/esmdev/foundation/components/Camera/CameraComponent.d.ts +34 -0
- package/dist/esmdev/foundation/components/Camera/CameraComponent.js +118 -46
- package/dist/esmdev/foundation/components/CameraController/CameraControllerComponent.js +8 -8
- package/dist/esmdev/foundation/components/CharacterController/CharacterAnimationController.js +74 -74
- package/dist/esmdev/foundation/components/CharacterController/CharacterControllerComponent.js +39 -39
- package/dist/esmdev/foundation/components/Constraint/ConstraintComponent.js +4 -4
- package/dist/esmdev/foundation/components/Light/LightComponent.d.ts +3 -1
- package/dist/esmdev/foundation/components/Light/LightComponent.js +126 -121
- package/dist/esmdev/foundation/components/Mesh/MeshComponent.js +50 -50
- package/dist/esmdev/foundation/components/MeshRenderer/MeshRendererComponent.js +96 -92
- package/dist/esmdev/foundation/components/Physics/PhysicsComponent.js +73 -73
- package/dist/esmdev/foundation/components/Raymarching/RaymarchingComponent.js +54 -54
- package/dist/esmdev/foundation/components/Raymarching/RaymarchingSdfEvaluator.js +251 -251
- package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.d.ts +16 -0
- package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.js +375 -343
- package/dist/esmdev/foundation/components/Shape/ShapeComponent.js +31 -31
- package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/AbsoluteAnimation.js +5 -5
- package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetarget.js +5 -5
- package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +9 -9
- package/dist/esmdev/foundation/components/Skeletal/SkeletalComponent.d.ts +48 -0
- package/dist/esmdev/foundation/components/Skeletal/SkeletalComponent.js +337 -205
- package/dist/esmdev/foundation/components/Transform/TransformComponent.js +93 -93
- package/dist/esmdev/foundation/components/Trigger/TriggerComponent.js +61 -61
- package/dist/esmdev/foundation/components/Vrm/VrmComponent.js +44 -44
- package/dist/esmdev/foundation/constraints/VrmAimConstraint.js +11 -11
- package/dist/esmdev/foundation/constraints/VrmRollConstraint.js +16 -16
- package/dist/esmdev/foundation/constraints/VrmRotationConstraint.js +10 -10
- package/dist/esmdev/foundation/core/Component.js +32 -32
- package/dist/esmdev/foundation/core/ComponentMemoryRegistry.js +42 -42
- package/dist/esmdev/foundation/core/ComponentRepository.js +37 -37
- package/dist/esmdev/foundation/core/Config.js +9 -9
- package/dist/esmdev/foundation/core/Entity.js +9 -9
- package/dist/esmdev/foundation/core/EntityRepository.js +19 -19
- package/dist/esmdev/foundation/core/GlobalDataRepository.js +17 -17
- package/dist/esmdev/foundation/core/MemoryManager.js +25 -25
- package/dist/esmdev/foundation/core/RnObject.js +37 -37
- package/dist/esmdev/foundation/definitions/Blend.js +3 -3
- package/dist/esmdev/foundation/definitions/ComponentType.js +7 -7
- package/dist/esmdev/foundation/definitions/CompositionType.js +50 -50
- package/dist/esmdev/foundation/definitions/CompressionTextureType.js +6 -6
- package/dist/esmdev/foundation/definitions/ShaderSemantics.js +6 -6
- package/dist/esmdev/foundation/definitions/TextureFormat.js +3 -3
- package/dist/esmdev/foundation/definitions/TextureParameter.js +3 -3
- package/dist/esmdev/foundation/definitions/VertexAttribute.js +30 -30
- package/dist/esmdev/foundation/enhanced_js_objects/Array.js +2 -2
- package/dist/esmdev/foundation/exporter/Gltf2Exporter.js +112 -112
- package/dist/esmdev/foundation/geometry/ComplexVertexAttribute.js +24 -24
- package/dist/esmdev/foundation/geometry/Frustum.js +41 -41
- package/dist/esmdev/foundation/geometry/Mesh.js +218 -218
- package/dist/esmdev/foundation/geometry/Primitive.js +133 -133
- package/dist/esmdev/foundation/geometry/SimpleVertexAttribute.js +7 -7
- package/dist/esmdev/foundation/geometry/shapes/Cylinder.js +3 -3
- package/dist/esmdev/foundation/geometry/shapes/Joint.js +33 -33
- package/dist/esmdev/foundation/gizmos/AABBGizmo.js +17 -20
- package/dist/esmdev/foundation/gizmos/CapsuleColliderGizmo.js +24 -26
- package/dist/esmdev/foundation/gizmos/Gizmo.d.ts +13 -0
- package/dist/esmdev/foundation/gizmos/Gizmo.js +43 -21
- package/dist/esmdev/foundation/gizmos/JointGizmo.js +38 -40
- package/dist/esmdev/foundation/gizmos/LightGizmo.d.ts +0 -1
- package/dist/esmdev/foundation/gizmos/LightGizmo.js +26 -30
- package/dist/esmdev/foundation/gizmos/LocatorGizmo.js +26 -29
- package/dist/esmdev/foundation/gizmos/RotationGizmo.js +217 -219
- package/dist/esmdev/foundation/gizmos/ScaleGizmo.js +135 -137
- package/dist/esmdev/foundation/gizmos/ShapeGizmo.js +44 -47
- package/dist/esmdev/foundation/gizmos/SphereColliderGizmo.js +25 -27
- package/dist/esmdev/foundation/gizmos/TranslationGizmo.js +132 -134
- package/dist/esmdev/foundation/helpers/BloomHelper.js +34 -34
- package/dist/esmdev/foundation/helpers/GaussianBlurHelper.js +18 -18
- package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.js +12 -12
- package/dist/esmdev/foundation/helpers/Shadow/ShadowMap.js +5 -5
- package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.js +119 -119
- package/dist/esmdev/foundation/helpers/materials/createMotionVectorMaterial.d.ts +25 -0
- package/dist/esmdev/foundation/helpers/materials/createMotionVectorMaterial.js +61 -0
- package/dist/esmdev/foundation/helpers/materials/createTemporalAAResolveMaterial.d.ts +33 -0
- package/dist/esmdev/foundation/helpers/materials/createTemporalAAResolveMaterial.js +127 -0
- package/dist/esmdev/foundation/importer/AnimationAssigner.js +44 -44
- package/dist/esmdev/foundation/importer/DrcPointCloudImporter.js +33 -33
- package/dist/esmdev/foundation/importer/Gltf2Importer.js +14 -14
- package/dist/esmdev/foundation/importer/GltfImporter.js +22 -22
- package/dist/esmdev/foundation/importer/ModelConverter.js +131 -131
- package/dist/esmdev/foundation/importer/RhodoniteImportExtension.js +6 -6
- package/dist/esmdev/foundation/importer/Vrm0xImporter.js +48 -48
- package/dist/esmdev/foundation/importer/VrmImporter.js +10 -10
- package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.js +27 -27
- package/dist/esmdev/foundation/materials/contents/DepthEncodeMaterialContent.js +2 -2
- package/dist/esmdev/foundation/materials/contents/MToon0xMaterialContent.js +138 -138
- package/dist/esmdev/foundation/materials/contents/MToon1MaterialContent.js +19 -19
- package/dist/esmdev/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +5 -5
- package/dist/esmdev/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +5 -5
- package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.d.ts +11 -0
- package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.js +68 -53
- package/dist/esmdev/foundation/materials/core/AbstractShaderNode.js +26 -26
- package/dist/esmdev/foundation/materials/core/DummyTextures.js +3 -3
- package/dist/esmdev/foundation/materials/core/Material.js +115 -115
- package/dist/esmdev/foundation/materials/core/MaterialRepository.js +65 -65
- package/dist/esmdev/foundation/materials/core/ShaderGraphResolver.js +38 -38
- package/dist/esmdev/foundation/materials/core/ShaderHandler.js +4 -4
- package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGL.js +16 -17
- package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGPU.js +17 -18
- package/dist/esmdev/foundation/materials/nodes/AbsShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/AcosShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/AddShaderNode.js +18 -18
- package/dist/esmdev/foundation/materials/nodes/AlphaTestShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/AndShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/Atan2ShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/AttributeColorShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeInstanceIdsShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeJointShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeNormalShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributePositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/AttributeTangentShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeTexcoordShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/AttributeWeightShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/BlockBeginShaderNode.js +11 -11
- package/dist/esmdev/foundation/materials/nodes/BlockEndShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/BranchShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/CalcBitangentShaderNode.js +7 -7
- package/dist/esmdev/foundation/materials/nodes/CastToFloatShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/ClampShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/ClassicShaderNode.js +11 -11
- package/dist/esmdev/foundation/materials/nodes/ConstantScalarVariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/ConstantVariableShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/ConstantVector2VariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/ConstantVector3VariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/ConstantVector4VariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/CosShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/DiscardShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/DotProductShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/EqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/FlatShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/GreaterOrEqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/GreaterShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/GreaterThanShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/LengthShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/LessOrEqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/LessThanShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/MergeVectorShaderNode.js +19 -19
- package/dist/esmdev/foundation/materials/nodes/MinShaderNode.js +18 -18
- package/dist/esmdev/foundation/materials/nodes/MultiplyShaderNode.js +21 -21
- package/dist/esmdev/foundation/materials/nodes/NormalMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/NormalizeShaderNode.js +9 -9
- package/dist/esmdev/foundation/materials/nodes/NotEqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/OrShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/OutColorShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/OutPositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyPropsShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyRotationShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/PbrBaseColorPropsShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/PbrClearcoatPropsShaderNode.js +7 -7
- package/dist/esmdev/foundation/materials/nodes/PbrDiffuseTransmissionPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrEmissivePropsShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/PbrIridescencePropsShaderNode.js +8 -8
- package/dist/esmdev/foundation/materials/nodes/PbrMetallicRoughnessPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrNormalPropsShaderNode.js +11 -11
- package/dist/esmdev/foundation/materials/nodes/PbrOcclusionPropsShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/PbrShaderShaderNode.js +21 -21
- package/dist/esmdev/foundation/materials/nodes/PbrSheenPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrSpecularPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrTransmissionPropsShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/PbrVolumePropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/ProcessGeometryShaderNode.js +22 -22
- package/dist/esmdev/foundation/materials/nodes/ProjectionMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/Random_HashPRNGShaderNode.js +12 -12
- package/dist/esmdev/foundation/materials/nodes/Random_SinHashShaderNode.js +12 -12
- package/dist/esmdev/foundation/materials/nodes/RemapShaderNode.js +17 -17
- package/dist/esmdev/foundation/materials/nodes/SinShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/SmoothStepShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/SplitVectorShaderNode.js +17 -17
- package/dist/esmdev/foundation/materials/nodes/StepShaderNode.js +14 -14
- package/dist/esmdev/foundation/materials/nodes/TanShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/Texture2DShaderNode.js +16 -16
- package/dist/esmdev/foundation/materials/nodes/TimeShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/TransformShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/UniformDataShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/ViewMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/WireframeMaterialNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/WorldMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendXYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendXZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendYXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendYZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendZXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendZYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/InitialPositionShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothIntersectionShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothSubtractionShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothUnionShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSubtractionShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpUnionShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/raymarching/OutDistanceShaderNode.js +16 -16
- package/dist/esmdev/foundation/materials/nodes/raymarching/OutShadingColorShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/OutUnionShaderNode.js +16 -16
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchCameraPositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitDistanceShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitNormalShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitPositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdUniformShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchRayDirectionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchTBNShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchViewDirectionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyTransformShaderNode.js +9 -9
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyWorldMatrixShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarXShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarYShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarZShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBoxShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdCapsuleShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRoundBoxShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdSphereShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTorusShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeXShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeYShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeZShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/TwistXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/TwistYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/TwistZShaderNode.js +4 -4
- package/dist/esmdev/foundation/math/AABB.js +132 -132
- package/dist/esmdev/foundation/math/AnimatedQuaternion.js +54 -54
- package/dist/esmdev/foundation/math/AnimatedScalar.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedValueEvaluationState.js +20 -20
- package/dist/esmdev/foundation/math/AnimatedVector2.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedVector3.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedVector4.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedVectorN.js +55 -55
- package/dist/esmdev/foundation/math/IdentityMatrix33.js +2 -2
- package/dist/esmdev/foundation/math/IdentityMatrix44.js +2 -2
- package/dist/esmdev/foundation/math/MathClassUtil.js +4 -4
- package/dist/esmdev/foundation/math/Quaternion.js +20 -20
- package/dist/esmdev/foundation/math/Transform3D.js +83 -83
- package/dist/esmdev/foundation/math/shapes/MathSphere.js +9 -9
- package/dist/esmdev/foundation/memory/Accessor.js +370 -370
- package/dist/esmdev/foundation/memory/Buffer.js +40 -40
- package/dist/esmdev/foundation/memory/BufferView.js +33 -33
- package/dist/esmdev/foundation/misc/DataUtil.js +2 -2
- package/dist/esmdev/foundation/misc/EnumIO.js +10 -10
- package/dist/esmdev/foundation/misc/Logger.js +14 -14
- package/dist/esmdev/foundation/misc/RnPromise.js +14 -14
- package/dist/esmdev/foundation/misc/Time.js +27 -27
- package/dist/esmdev/foundation/misc/WeakOption.js +14 -14
- package/dist/esmdev/foundation/misc/cache/Cache.js +2 -2
- package/dist/esmdev/foundation/misc/cache/SymbolWeakMap.js +8 -8
- package/dist/esmdev/foundation/physics/PhysicsWorldQuery.js +13 -13
- package/dist/esmdev/foundation/physics/Rapier/RapierCharacterControllerStrategy.js +203 -203
- package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsStrategy.js +241 -241
- package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsWorldQueryStrategy.js +3 -3
- package/dist/esmdev/foundation/physics/VRMSpring/CapsuleCollider.js +42 -42
- package/dist/esmdev/foundation/physics/VRMSpring/SphereCollider.js +27 -27
- package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBone.js +10 -10
- package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBonePhysicsStrategy.js +51 -51
- package/dist/esmdev/foundation/renderer/Expression.js +6 -6
- package/dist/esmdev/foundation/renderer/Frame.js +12 -12
- package/dist/esmdev/foundation/renderer/FrameBuffer.js +25 -25
- package/dist/esmdev/foundation/renderer/RenderPass.js +102 -99
- package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.d.ts +33 -0
- package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +66 -0
- package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.d.ts +135 -0
- package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.js +275 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.js +153 -153
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystemStub.js +3 -3
- package/dist/esmdev/foundation/renderer/pipelines/DeferredRenderPipeline.js +6 -6
- package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +62 -16
- package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.js +535 -428
- package/dist/esmdev/foundation/system/Engine.d.ts +37 -3
- package/dist/esmdev/foundation/system/Engine.js +266 -224
- package/dist/esmdev/foundation/system/EventPubSub.js +8 -8
- package/dist/esmdev/foundation/system/InputManager.js +56 -56
- package/dist/esmdev/foundation/system/ModuleManager.js +6 -6
- package/dist/esmdev/foundation/textures/AbstractTexture.js +50 -50
- package/dist/esmdev/foundation/textures/CubeTexture.js +32 -32
- package/dist/esmdev/foundation/textures/RenderBuffer.js +11 -11
- package/dist/esmdev/foundation/textures/RenderTargetTexture.js +25 -25
- package/dist/esmdev/foundation/textures/RenderTargetTexture2DArray.js +37 -37
- package/dist/esmdev/foundation/textures/RenderTargetTextureCube.js +19 -19
- package/dist/esmdev/foundation/textures/Sampler.js +24 -24
- package/dist/esmdev/foundation/textures/Texture.js +83 -83
- package/dist/esmdev/foundation/textures/TextureArray.js +8 -8
- package/dist/esmdev/foundation/textures/TextureDataFloat.js +26 -26
- package/dist/esmdev/foundation/textures/VideoTexture.js +24 -24
- package/dist/esmdev/version.js +2 -2
- package/dist/esmdev/webgl/InstanceSidTable.js +62 -62
- package/dist/esmdev/webgl/MultiDraw.js +2 -2
- package/dist/esmdev/webgl/MultiDrawRepository.js +30 -30
- package/dist/esmdev/webgl/WebGLContextWrapper.js +164 -164
- package/dist/esmdev/webgl/WebGLGpuTimer.js +32 -32
- package/dist/esmdev/webgl/WebGLResourceRepository.js +306 -306
- package/dist/esmdev/webgl/WebGLStereoUtil.js +42 -42
- package/dist/esmdev/webgl/WebGLStrategyWebGL2.d.ts +8 -0
- package/dist/esmdev/webgl/WebGLStrategyWebGL2.js +296 -261
- package/dist/esmdev/webgl/debug/ShaderParameterDebugger.js +4 -4
- package/dist/esmdev/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.js +12 -0
- package/dist/esmdev/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +12 -0
- package/dist/esmdev/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.js +12 -0
- package/dist/esmdev/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.js +12 -0
- package/dist/esmdev/webgl/shaders/RaymarchingShaderPart.js +4 -4
- package/dist/esmdev/webgl/shaders/RaymarchingShadowShaderPart.js +14 -14
- package/dist/esmdev/webgl/shaders/StandardShaderPart.js +3 -3
- package/dist/esmdev/webgl/shaders/nodes/BlockBeginShader.js +10 -10
- package/dist/esmdev/webgl/shaders/nodes/BlockEndShader.js +10 -10
- package/dist/esmdev/webgl/shaders/nodes/ConstantVariableShader.js +21 -21
- package/dist/esmdev/webgl/shaders/nodes/DiscardShader.js +3 -3
- package/dist/esmdev/webgl/shaders/nodes/EndShader.js +3 -3
- package/dist/esmdev/webgl/shaders/nodes/OutDistance.js +12 -12
- package/dist/esmdev/webgl/shaders/nodes/OutUnion.js +9 -9
- package/dist/esmdev/webgl/shaders/nodes/RaymarchObjectIdUniform.js +8 -8
- package/dist/esmdev/webgl/shaders/nodes/SdApplyTransform.js +9 -9
- package/dist/esmdev/webgl/shaders/nodes/SdApplyWorldMatrix.js +8 -8
- package/dist/esmdev/webgl/shaders/nodes/Texture2DShader.js +23 -23
- package/dist/esmdev/webgl/shaders/nodes/UniformDataShader.js +23 -23
- package/dist/esmdev/webgl/textureLoader/KTX2TextureLoader.js +27 -27
- package/dist/esmdev/webgpu/GpuCullingRegistry.js +94 -94
- package/dist/esmdev/webgpu/GpuDeformRegistry.js +53 -53
- package/dist/esmdev/webgpu/RangeAllocator.js +16 -16
- package/dist/esmdev/webgpu/WebGpuBufferArena.js +21 -21
- package/dist/esmdev/webgpu/WebGpuDeviceWrapper.js +7 -7
- package/dist/esmdev/webgpu/WebGpuGpuCulling.js +198 -198
- package/dist/esmdev/webgpu/WebGpuGpuTimer.js +52 -52
- package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.js +37 -37
- package/dist/esmdev/webgpu/WebGpuResourceRepository.js +597 -597
- package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +8 -0
- package/dist/esmdev/webgpu/WebGpuStrategyBasic.js +170 -133
- package/dist/esmdev/webgpu/WebGpuVertexDeformer.js +128 -128
- package/dist/esmdev/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.wgsl.js +12 -0
- package/dist/esmdev/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.wgsl.js +12 -0
- package/dist/esmdev/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.wgsl.js +12 -0
- package/dist/esmdev/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.wgsl.js +12 -0
- package/dist/esmdev/xr/WebARSystem.js +69 -69
- package/dist/esmdev/xr/WebXRSystem.js +153 -153
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import K from"../_deps/vendor__hdrpng.js";import{CameraComponent as z}from"../foundation/components/Camera/CameraComponent.js";import{MeshRendererComponent as I}from"../foundation/components/MeshRenderer/MeshRendererComponent.js";import{EntityRepository as X}from"../foundation/core/EntityRepository.js";import{AlphaMode as j}from"../foundation/definitions/AlphaMode.js";import{BasisCompressionType as W}from"../foundation/definitions/BasisCompressionType.js";import{ComponentType as H}from"../foundation/definitions/ComponentType.js";import{CompositionType as Z}from"../foundation/definitions/CompositionType.js";import{HdriFormat as S}from"../foundation/definitions/HdriFormat.js";import{PixelFormat as J}from"../foundation/definitions/PixelFormat.js";import{ShaderSemantics as M}from"../foundation/definitions/ShaderSemantics.js";import{TextureFormat as Q}from"../foundation/definitions/TextureFormat.js";import{TextureParameter as V}from"../foundation/definitions/TextureParameter.js";import{VertexAttribute as F}from"../foundation/definitions/VertexAttribute.js";import{Primitive as k}from"../foundation/geometry/Primitive.js";import{Is as E}from"../foundation/misc/Is.js";import{Logger as L}from"../foundation/misc/Logger.js";import{MiscUtil as ee}from"../foundation/misc/MiscUtil.js";import{CGAPIResourceRepository as Y}from"../foundation/renderer/CGAPIResourceRepository.js";import{subtractByteRanges as te}from"../foundation/renderer/lightCluster/LightClusterLayout.js";import{CubeTexture as re}from"../foundation/textures/CubeTexture.js";import{RenderTargetTexture2DArray as ne}from"../foundation/textures/RenderTargetTexture2DArray.js";import{RenderTargetTextureCube as ie}from"../foundation/textures/RenderTargetTextureCube.js";import{Sampler as se}from"../foundation/textures/Sampler.js";import{TextureArray as ae}from"../foundation/textures/TextureArray.js";import{packRgbaRowsForUpload as oe}from"./packRgbaRowsForUpload.js";import{WebGpuBufferArena as ue}from"./WebGpuBufferArena.js";import{WebGpuGpuCulling as ce}from"./WebGpuGpuCulling.js";import{WebGpuGpuTimer as le}from"./WebGpuGpuTimer.js";var N="depth32float",_=0,de=1,fe=2,$=3,y=class y extends Y{constructor(){super();this.tU=new Map;this.zA=Y.InvalidCGAPIResourceUid;this.AP="";this.LU=[];this.OU=new Map;this.WU=new Map;this.AU=new Map;this.SP=new Map;this.NU=new Map;this.zU=new Map;this.VP=new Map;this.XU=[];this.kU=0;this.MP=[0,0,0,0];this._P=new WeakMap;this.IP=new WeakMap;this.
|
|
1
|
+
import K from"../_deps/vendor__hdrpng.js";import{CameraComponent as z}from"../foundation/components/Camera/CameraComponent.js";import{MeshRendererComponent as I}from"../foundation/components/MeshRenderer/MeshRendererComponent.js";import{EntityRepository as X}from"../foundation/core/EntityRepository.js";import{AlphaMode as j}from"../foundation/definitions/AlphaMode.js";import{BasisCompressionType as W}from"../foundation/definitions/BasisCompressionType.js";import{ComponentType as H}from"../foundation/definitions/ComponentType.js";import{CompositionType as Z}from"../foundation/definitions/CompositionType.js";import{HdriFormat as S}from"../foundation/definitions/HdriFormat.js";import{PixelFormat as J}from"../foundation/definitions/PixelFormat.js";import{ShaderSemantics as M}from"../foundation/definitions/ShaderSemantics.js";import{TextureFormat as Q}from"../foundation/definitions/TextureFormat.js";import{TextureParameter as V}from"../foundation/definitions/TextureParameter.js";import{VertexAttribute as F}from"../foundation/definitions/VertexAttribute.js";import{Primitive as k}from"../foundation/geometry/Primitive.js";import{Is as E}from"../foundation/misc/Is.js";import{Logger as L}from"../foundation/misc/Logger.js";import{MiscUtil as ee}from"../foundation/misc/MiscUtil.js";import{CGAPIResourceRepository as Y}from"../foundation/renderer/CGAPIResourceRepository.js";import{subtractByteRanges as te}from"../foundation/renderer/lightCluster/LightClusterLayout.js";import{CubeTexture as re}from"../foundation/textures/CubeTexture.js";import{RenderTargetTexture2DArray as ne}from"../foundation/textures/RenderTargetTexture2DArray.js";import{RenderTargetTextureCube as ie}from"../foundation/textures/RenderTargetTextureCube.js";import{Sampler as se}from"../foundation/textures/Sampler.js";import{TextureArray as ae}from"../foundation/textures/TextureArray.js";import{packRgbaRowsForUpload as oe}from"./packRgbaRowsForUpload.js";import{WebGpuBufferArena as ue}from"./WebGpuBufferArena.js";import{WebGpuGpuCulling as ce}from"./WebGpuGpuCulling.js";import{WebGpuGpuTimer as le}from"./WebGpuGpuTimer.js";var N="depth32float",_=0,de=1,fe=2,$=3,y=class y extends Y{constructor(){super();this.tU=new Map;this.zA=Y.InvalidCGAPIResourceUid;this.AP="";this.LU=[];this.OU=new Map;this.WU=new Map;this.AU=new Map;this.SP=new Map;this.NU=new Map;this.zU=new Map;this.VP=new Map;this.XU=[];this.kU=0;this.MP=[0,0,0,0];this._P=new WeakMap;this.IP=new WeakMap;this.Nw=0;this.PU={count:0,slots:[],dimensions:[],visibilities:[],views:[],samplers:[]};this.LP=[];this.OP=[];this.fU=new Map;this.DU=new Map;this.ZU=!1;this.vU=-1;this.uP=_;this.dP=[];this.EU=[];this.kP=[];this.pU={active:!1,engine:void 0,renderPass:void 0,displayIdx:0,targetKind:_,targetViews:[],isColorClear:!1,clearColor:{r:0,g:0,b:0,a:0},isDepthClear:!1,clearDepth:1};this.xP=-1;this.$P=-1;this.qP=-1;this.KP=-1;this.jP=-1;this.ZP=-1;this.wU=new Map;this.hU=new Map;this.mU=new Map}static cU(e){if(!(e.buffer instanceof ArrayBuffer))throw new Error("SharedArrayBuffer is not supported in this code path.")}clearCache(){this.OU.clear(),this.WU.clear(),this.NU.clear(),this.zU.clear(),this.Gw=void 0,this.LU.length=0,this.sU()}addWebGpuDeviceWrapper(e){this.eU=e,this.WP=e.gpuDevice.queue,this.aU=this.eU.gpuDevice.createCommandEncoder()}getWebGpuDeviceWrapper(){return this.eU}static init(){return new y}getResourceNumber(){return++this.zA}_A(e){let t=this.getResourceNumber();return e._resourceUid=t,this.tU.set(t,e),t}getCanvasSize(){let e=this.eU.canvas;return[e.width,e.height]}async createTextureFromImageBitmapData(e,{internalFormat:t,width:r,height:n,generateMipmap:s}){return await this.JP(r,n,t,s,e)}async createTextureFromDataUri(e,{internalFormat:t,generateMipmap:r}){return new Promise(n=>{let s=new Image;e.match(/^data:/)||(s.crossOrigin="Anonymous"),s.onload=async()=>{let i=s.width,a=s.height,u=await this.createTextureFromHTMLImageElement(s,{internalFormat:t,width:i,height:a,generateMipmap:r});n(u)},s.src=e})}generateMipmaps2d(e,t,r){let n=this.tU.get(e),s={size:[t,r,1],format:n.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:Math.floor(Math.log2(Math.max(t,r)))+1};this.generateMipmaps(n,s)}generateMipmapsCube(e,t,r){let n=this.tU.get(e),s={size:[t,r,6],format:n.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:Math.floor(Math.log2(Math.max(t,r)))+1};this.generateMipmaps(n,s)}async getTexturePixelData(e,t,r,n,s){let i=this.tU.get(e),a=new Uint8Array(t*r*4),u=this.eU.gpuDevice,o=u.createCommandEncoder(),c=u.createBuffer({size:t*r*4,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});o.copyTextureToBuffer({texture:i},{buffer:c,bytesPerRow:t*4},{width:t,height:r,depthOrArrayLayers:1}),u.queue.submit([o.finish()]),await c.mapAsync(GPUMapMode.READ);let l=c.getMappedRange();return a.set(new Uint8Array(l)),c.unmap(),a}getPixelDataFromTexture(e,t,r,n,s){throw new Error("WebGPU does not support synchronous texture readback. Use getPixelDataFromTextureAsync instead.")}async getPixelDataFromTextureAsync(e,t,r,n,s){let i=this.tU.get(e);if(!i)return new Uint8Array(0);let a=this.eU.gpuDevice,u=a.createShaderModule({code:`
|
|
2
2
|
struct VertexOutput {
|
|
3
3
|
@builtin(position) position: vec4f,
|
|
4
4
|
@location(0) texCoord: vec2f,
|
|
@@ -111,6 +111,6 @@ import K from"../_deps/vendor__hdrpng.js";import{CameraComponent as z}from"../fo
|
|
|
111
111
|
fn fragmentMain(@location(0) texCoord : vec2f) -> @location(0) vec4f {
|
|
112
112
|
return textureSample(img, imgSampler, texCoord);
|
|
113
113
|
}
|
|
114
|
-
`})),this.RU!=null&&t.format!==this.YP&&(this.RU=void 0),this.RU==null){this.UP=r.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{viewDimension:"2d"}}]});let i=r.createPipelineLayout({bindGroupLayouts:[this.UP]});this.RU=r.createRenderPipeline({layout:i,vertex:{module:this.VU,entryPoint:"vertexMain"},fragment:{module:this.VU,entryPoint:"fragmentMain",targets:[{format:t.format}]},primitive:{topology:"triangle-strip",stripIndexFormat:"uint32"}}),this.YP=t.format}this.bP==null&&(this.bP=r.createSampler({minFilter:"linear"})),this.UU();let s=e.dimension==="2d"&&e.depthOrArrayLayers===6?6:1;for(let i=0;i<s;++i){let a=this.wU.get(e);if(a==null||a[i]==null){let o=e.createView({dimension:"2d",baseMipLevel:0,mipLevelCount:1,baseArrayLayer:i,arrayLayerCount:1});a==null&&this.wU.set(e,[]),this.wU.get(e)[i]=o}let u=this.wU.get(e)[i];for(let o=1;o<t.mipLevelCount;++o){let c=this.hU.get(e);if(c==null||c[i]==null||c[i][o]==null){let g=e.createView({dimension:"2d",baseMipLevel:o,mipLevelCount:1,baseArrayLayer:i,arrayLayerCount:1});c==null&&this.hU.set(e,[]),this.hU.get(e)[i]==null&&(this.hU.get(e)[i]=[]),this.hU.get(e)[i][o]=g}let l=this.hU.get(e)[i][o],p=this.aU.beginRenderPass({colorAttachments:[{view:l,loadOp:"load",storeOp:"store"}]}),f=this.mU.get(e);if(f==null||f[i]==null||f[i][o]==null){let g=r.createBindGroup({layout:this.UP,entries:[{binding:0,resource:this.bP},{binding:1,resource:u}]});f==null&&this.mU.set(e,[]),this.mU.get(e)[i]==null&&(this.mU.get(e)[i]=[]),this.mU.get(e)[i][o]=g}let h=this.mU.get(e)[i][o];p.setPipeline(this.RU),p.setBindGroup(0,h),p.draw(4),p.end(),u=l}}}createTextureSampler({magFilter:e,minFilter:t,wrapS:r,wrapT:n,wrapR:s,anisotropy:i}){let a=this.eU.gpuDevice,u=i?4:1,o={magFilter:e.webgpu,minFilter:t.webgpu,mipmapFilter:t===V.LinearMipmapLinear||t===V.NearestMipmapLinear?"linear":"nearest",addressModeU:r.webgpu,addressModeV:n.webgpu,addressModeW:s.webgpu,maxAnisotropy:u};(o.magFilter==="nearest"||o.minFilter==="nearest"||o.mipmapFilter==="nearest")&&(o.maxAnisotropy=1);let c=a.createSampler(o);return this._A(c)}createVertexBuffer(e){return this.TP(e.getUint8Array())}createVertexBufferFromTypedArray(e){return this.TP(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}static QP(e){let t=e.componentType,r=e.compositionType;if(e.normalized){let n="";t===H.UnsignedByte?n="unorm8":t===H.Byte?n="snorm8":t===H.UnsignedShort?n="unorm16":t===H.Short&&(n="snorm16");let s=n+r.webgpu;if(n!==""&&y.Ww.has(s))return s}return t.webgpu+r.webgpu}createIndexBuffer(e){return this.TP(y.JG(e))}static JG(e){if(e.componentType!==H.UnsignedByte)return e.getUint8Array();let t=e.getTypedArray(),r=new Uint16Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n];return new Uint8Array(r.buffer)}Nw(){return this.xU==null&&(this.xU=new ue(this.eU.gpuDevice,GPUBufferUsage.VERTEX|GPUBufferUsage.INDEX)),this.xU}TP(e){let t=this.Nw().allocate(e),r=this.getResourceNumber();return this.fU.set(r,t),r}_getVertexBufferRange(e){return this.fU.get(e)}PP(e){let t=this.fU.get(e);return t==null?!1:(this.xU.release(t),this.fU.delete(e),this.sU(),!0)}updateVertexBuffer(e,t){let r=this.fU.get(t);if(E.not.exist(r))throw new Error("Not found VBO.");this.xU.write(r,e.getUint8Array())}updateIndexBuffer(e,t){let r=this.fU.get(t);if(E.not.exist(r))throw new Error("Not found IBO.");this.xU.write(r,y.JG(e))}deleteVertexBuffer(e){if(!this.PP(e))throw new Error("Not found VBO.")}createVertexBufferAndIndexBuffer(e){let t;e.hasIndices()&&(t=this.createIndexBuffer(e.indicesAccessor));let r=[];for(let s=0;s<F.AttributeTypeNumber;s++)r[s]=!1;let n=[];return e.attributeAccessors.forEach((s,i)=>{let a=this.createVertexBuffer(s),u=F.toAttributeSlotFromJoinedString(e.attributeSemantics[i]);r[u]=!0,n.push(a)}),{vaoHandle:-1,iboHandle:t,vboHandles:n,attributesFlags:r,setComplete:!1}}updateVertexBufferAndIndexBuffer(e,t){t.iboHandle&&this.updateIndexBuffer(e.indicesAccessor,t.iboHandle);let r=e.attributeAccessors;for(let n=0;n<r.length;n++)this.updateVertexBuffer(r[n],t.vboHandles[n])}deleteVertexDataResources(e){E.exist(e.iboHandle)&&this.PP(e.iboHandle);for(let t of e.vboHandles)this.PP(t)}setVertexDataToPipeline({vboHandles:e},t){let r=[],n=[];for(let s=0;s<e.length;s++){let i=F.toAttributeSlotFromJoinedString(t.attributeSemantics[s]),a=y.QP(t.attributeAccessors[s]);n.push({shaderLocation:i,offset:t.attributeAccessors[s].byteOffsetInBufferView,format:a})}r[0]={stepMode:"vertex",attributes:n,arrayStride:t.attributeAccessors[0].byteStride},r[1]={stepMode:"instance",attributes:[{shaderLocation:F.Instance.getAttributeSlot(),offset:0,format:"uint32x4"}],arrayStride:16}}XA(e,t,r,n){e.logger.info(`MaterialTypeName: ${t}`);let s=ee.addLineNumberToCode(r);e.logger.info(s);let i=!0;for(let a=0;a<n.messages.length;a++)e.logger.info(n.messages[a].message),i=!1;return i}createShaderProgram({config:e,engine:t,material:r,vertexShaderStr:n,fragmentShaderStr:s}){let i=this.eU.gpuDevice,a=i.createShaderModule({code:n,label:`${r.materialTypeName} vertex shader`});e.cgApiDebugConsoleOutput&&a.getCompilationInfo().then(l=>{l.messages.length>0&&this.XA(t,r.materialTypeName,n,l)});let u=i.createShaderModule({code:s,label:`${r.materialTypeName} fragment shader`});e.cgApiDebugConsoleOutput&&u.getCompilationInfo().then(l=>{l.messages.length>0&&this.XA(t,r.materialTypeName,s,l)});let o={vsModule:a,fsModule:u};return this._A(o)}clearFrameBuffer(e,t,r){if(t.entities.length>0||!t.toClearColorBuffer&&!t.toClearDepthBuffer)return;let n=e._webXRSystemIfEnabled,s=t.getFramebuffer()==null&&(n==null?void 0:n.isWebXRMode)&&t.isOutputForVr;if(t.getResolveFramebuffer()==null&&!s){let l=this.EU,p=this.QG(e,t,l),f=this.pU;if(f.active&&(p!==f.targetKind||!y.GP(l,f.targetViews))&&this.yP(),f.active||(f.active=!0,f.engine=e,f.renderPass=t,f.displayIdx=r,f.targetKind=p,this.EU=f.targetViews,f.targetViews=l),t.toClearColorBuffer){let h=t.clearColor;f.isColorClear=!0,f.clearColor.r=h.x,f.clearColor.g=h.y,f.clearColor.b=h.z,f.clearColor.a=h.w}t.toClearDepthBuffer&&(f.isDepthClear=!0,f.clearDepth=t.clearDepth);return}this.UU();let i=[],a,u=e._webXRSystemIfEnabled;if(t.toClearColorBuffer){let l=t.getFramebuffer();if(l!=null)for(let p of l.colorAttachments){let f=this.tU.get(p._textureViewAsRenderTargetResourceUid);i.push({view:f,clearValue:{r:t.clearColor.x,g:t.clearColor.y,b:t.clearColor.z,a:t.clearColor.w},loadOp:"clear",storeOp:"store"})}else if(u!=null&&u.isWebXRMode&&t.isOutputForVr){let p=e.engineState.xrPoseWebGPU.views[r],f=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,p);i.push({view:f.colorTexture.createView(f.getViewDescriptor()),clearValue:{r:t.clearColor.x,g:t.clearColor.y,b:t.clearColor.z,a:t.clearColor.w},loadOp:"clear",storeOp:"store"})}else i.push({view:this.FU(),clearValue:{r:t.clearColor.x,g:t.clearColor.y,b:t.clearColor.z,a:t.clearColor.w},loadOp:"clear",storeOp:"store"})}if(t.toClearDepthBuffer){let l=t.getFramebuffer();if(l!=null&&l.depthAttachment!=null)a={view:this.tU.get(l.depthAttachment._textureViewAsRenderTargetResourceUid),depthClearValue:t.clearDepth,depthLoadOp:"clear",depthStoreOp:"store"};else if(u!=null&&u.isWebXRMode&&t.isOutputForVr){let p=e.engineState.xrPoseWebGPU.views[r],f=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,p);a={view:f.depthStencilTexture.createView(f.getViewDescriptor()),depthClearValue:t.clearDepth,depthLoadOp:"clear",depthStoreOp:"store"}}else a={view:this.dU,depthClearValue:t.clearDepth,depthLoadOp:"clear",depthStoreOp:"store"}}let o={colorAttachments:i,depthStencilAttachment:a,label:t.uniqueName};this.BU(o).end()}draw(e,t,r,n,s,i,a,u={}){var G;let o=n.isBufferLessRenderingMode(),c=t._vertexHandles;if(!o&&c==null)return;let l="",p,f,h;if(o){let R=r.getTextureParameter(M.DiffuseEnvTexture.str);R!=null&&(p=R[1]);let w=r.getTextureParameter(M.SpecularEnvTexture.str);w!=null&&(f=w[1]);let B=r.getTextureParameter(M.SheenEnvTexture.str);B!=null&&(h=B[1])}else{let w=t.mesh.meshEntitiesInner[0],B=w.getMeshRenderer();r._setInternalSettingParametersToGpuWebGpu({engine:e,material:r,args:{cameraComponentSid:s,entity:w,specularCube:B.specularCubeMap}}),p=B.diffuseCubeMap,f=B.specularCubeMap,h=B.sheenCubeMap,l=B.getFingerPrint()}let g=`${t._getFingerPrint()} ${r._getFingerPrint()} ${r.og} ${n.renderPassUID} ${l} ${i} `,d=this.Xw(e,r,p,f,h),[m,T]=this.getOrCreateRenderPipeline(g,d.pipelineLayoutKey,d.pipelineLayout,t,r,n,i,u),x=this.iU,U=this.LP;U[0]!==d.storage&&(x.setBindGroup(0,d.storage),U[0]=d.storage),this.qU!==m&&(x.setPipeline(m),this.qU=m),U[1]!==d.texture&&(x.setBindGroup(1,d.texture),U[1]=d.texture),U[2]!==d.sampler&&(x.setBindGroup(2,d.sampler),U[2]=d.sampler);let b=o?void 0:this.kw(e,t,t.mesh,n,s);(b==null?void 0:b.deformedVertexOffset)!==void 0&&this.Yw(b.deformedVertexOffset);let P=this.FP;if(U[3]!==P&&(x.setBindGroup(3,P),U[3]=P),o)x.draw(n._drawVertexNumberForBufferLessRendering);else{let R=t.mesh,w=this.fU,B=this.OP,A=(G=b==null?void 0:b.instanceVertexBuffer)!=null?G:w.get(R._variationVBOUid);B[0]!==A&&(x.setVertexBuffer(0,A.buffer,A.offset,A.size),B[0]=A);let D=c.vboHandles;for(let v=0;v<D.length;v++){let C=w.get(D[v]);B[v+1]!==C&&(x.setVertexBuffer(v+1,C.buffer,C.offset,C.size),B[v+1]=C)}if(t.hasIndices()){let v=w.get(c.iboHandle),C=t.getIndexBitSize();if((this.KU!==v||this.jU!==C)&&(x.setIndexBuffer(v.buffer,C,v.offset,v.size),this.KU=v,this.jU=C),b!=null)x.drawIndexedIndirect(b.indirectBuffer,b.indirectOffset);else{let O=t.indicesAccessor;x.drawIndexed(O.elementCount,R.meshEntitiesInner.length)}}else if(b!=null)x.drawIndirect(b.indirectBuffer,b.indirectOffset);else{let v=t.attributeAccessors[0].elementCount;x.draw(v,R.meshEntitiesInner.length)}}}kw(e,t,r,n,s){let i=this.nU;if(i==null||!i.isRecording||!r._isGpuCullable||!I._isGpuCullingActive(e,n))return;let a=t.hasIndices()?t.indicesAccessor.elementCount:t.attributeAccessors[0].elementCount;return i.registerDraw(e,r,t,s,a)}_markGpuCullingInputsDirty(){var e;(e=this.nU)==null||e.markInputsDirty()}_getGpuCulling(){return this.nU}_destroyGpuCulling(){this.nU!=null&&(this.sU(),this.nU.destroy(),this.nU=void 0)}$w(e,t,r){let n=t.getFramebuffer(),s=t.getResolveFramebuffer(),i=[],a,u=1,o=e._webXRSystemIfEnabled;if(n!=null){for(let l of n.colorAttachments){if(l==null)continue;let p=l._textureResourceUid;if(p==null||p<0)continue;let f=this.tU.get(p);f!=null&&i.push(f.format)}if(s!=null&&n.colorAttachments.length>0){let l=n.colorAttachments[0],p=l==null?void 0:l.sampleCount;typeof p=="number"&&p>0&&(u=p)}if(n.depthAttachment!=null){let l=n.depthAttachment._textureResourceUid;if(l!=null&&l>=0){let p=this.tU.get(l);a=p==null?void 0:p.format}else a=void 0}else a=void 0}else if(o!=null&&o.isWebXRMode&&t.isOutputForVr){let l=e.engineState.xrPoseWebGPU.views[r],p=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,l);i=[p.colorTexture.format],a=p.depthStencilTexture.format}else i=[navigator.gpu.getPreferredCanvasFormat()],a=this.bU!=null?this.bU.format:N;return i.length===0&&(i=[navigator.gpu.getPreferredCanvasFormat()]),{colorFormats:i,depthStencilFormat:a,sampleCount:u}}getEffekseerRenderPassOptions(e,t,r=0){var u;if(t==null)return{colorFormat:navigator.gpu.getPreferredCanvasFormat(),depthFormat:void 0};let n=t.getFramebuffer(),s=t.getResolveFramebuffer(),i;if(s!=null&&s.colorAttachments.length>0){let o=s.colorAttachments[0]._textureResourceUid,c=o!=null?this.tU.get(o):void 0;i=c==null?void 0:c.format}else if(n!=null&&n.colorAttachments.length>0){let o=n.colorAttachments[0]._textureResourceUid,c=o!=null?this.tU.get(o):void 0;i=c==null?void 0:c.format}else if((u=e._webXRSystemIfEnabled)!=null&&u.isWebXRMode&&t.isOutputForVr){let o=e.engineState.xrPoseWebGPU.views[r];i=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,o).colorTexture.format}else i=navigator.gpu.getPreferredCanvasFormat();return{colorFormat:i,depthFormat:void 0}}getOrCreateRenderPassEncoderForEffekseerExternalRendering(e,t,r){this.UU(),this.iU!=null&&this.TU();let n=t.getFramebuffer(),s=t.getResolveFramebuffer(),i=e._webXRSystemIfEnabled,a=[];if(s!=null)for(let o of s.colorAttachments){let c=this.tU.get(o._textureViewAsRenderTargetResourceUid);a.push({view:c,loadOp:"load",storeOp:"store"})}else if(n!=null)for(let o of n.colorAttachments){let c=this.tU.get(o._textureViewAsRenderTargetResourceUid);a.push({view:c,loadOp:"load",storeOp:"store"})}else if(i!=null&&i.isWebXRMode&&t.isOutputForVr){let o=e.engineState.xrPoseWebGPU.views[r],c=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,o);a.push({view:c.colorTexture.createView(c.getViewDescriptor()),loadOp:"load",storeOp:"store"})}else a.push({view:this.FU(),loadOp:"load",storeOp:"store"});if(a.length===0)return;let u={colorAttachments:a,label:`${t.uniqueName}_EffekseerExternal`};return this.Tw(u),this.rU=this.aU.beginRenderPass(u),this.rU}createRenderBundleEncoder(e,t,r){var a,u,o,c;let n=this.eU.gpuDevice,s=this.$w(e,t,r),i=JSON.stringify({colorFormats:s.colorFormats,depthStencilFormat:(a=s.depthStencilFormat)!=null?a:null,sampleCount:s.sampleCount});this.fP=t,this.xP=r,!(this.iU!=null&&this.QU===i)&&(this.iU=n.createRenderBundleEncoder(s),this.QU=i,this.Aw(),e.config.isGpuCullingEnabled&&((o=this[u="nU"])!=null||(this[u]=new ce(n))),(c=this.nU)==null||c.beginRecording())}Aw(){this.qU=void 0,this.LP.length=0,this.OP.length=0,this.KU=void 0,this.jU=void 0}createRenderPassEncoder(e,t,r){if(this.rU!=null&&this.yU===t&&this.vU===r&&!this.pU.active)return;let n=this.EU,s=this.QG(e,t,n),i=!1,a=this.pU;if(a.active&&(s!==_&&s===a.targetKind&&y.GP(n,a.targetViews)?i=!0:this.yP()),this.rU!=null){if(!i&&s!==_&&s===this.uP&&!t.toClearColorBuffer&&!t.toClearDepthBuffer&&y.GP(n,this.dP)){this.yU=t,this.vU=r;return}this._U()}this.Ew(e,t,r,i),i&&this.RP(),this.rU!=null&&(this.yU=t,this.vU=r,this.uP=s,this.EU=this.dP,this.dP=n)}QG(e,t,r){var a;r.length=0;let n=t.getFramebuffer(),s=t.getResolveFramebuffer(),i=this.tU;if(s!=null&&n!=null){for(let c=0;c<s.colorAttachments.length;c++){let l=n.colorAttachments[c],p=s.colorAttachments[c];r.push(i.get(l._textureViewAsRenderTargetResourceUid)),r.push(i.get(p._textureViewAsRenderTargetResourceUid))}let u=this.dU,o=n.depthAttachment;return o!=null&&i.get(o._textureResourceUid)!=null&&(u=i.get(o._textureViewResourceUid)),r.push(u),de}if(n!=null){for(let c of n.colorAttachments)r.push(i.get(c._textureViewAsRenderTargetResourceUid));let u,o=n.depthAttachment;return o!=null&&i.get(o._textureResourceUid)!=null&&(u=i.get(o._textureViewAsRenderTargetResourceUid)),r.push(u),fe}return(a=e._webXRSystemIfEnabled)!=null&&a.isWebXRMode&&t.isOutputForVr?_:(r.push(this.FU()),r.push(this.dU),$)}FU(){let e=this.MU;if(e==null){let t=this.eU.context.getCurrentTexture();e=y.qw(this.eU.gpuDevice)?t:t.createView(),this.MU=e}return e}static qw(e){let t=y.Sw;if(t!==void 0)return t;let r;try{r=e.createTexture({size:[1,1],format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT}),e.createCommandEncoder().beginRenderPass({colorAttachments:[{view:r,loadOp:"clear",storeOp:"store"}]}).end(),t=!0}catch{t=!1}finally{r==null||r.destroy()}return y.Sw=t,t}BU(e){let t=this.SU;if(t!==void 0){let r=e.depthStencilAttachment;r!=null&&r.view===this.dU&&(r.depthLoadOp==="load"&&(r.depthLoadOp="clear",r.depthClearValue=t),this.SU=void 0)}return this.Tw(e),this.aU.beginRenderPass(e)}Tw(e){var n;let t=this.GU;if(t==null||e.timestampWrites!=null)return;let r=t.getTimestampWrites((n=e.label)!=null?n:"renderPass");r!=null&&(e.timestampWrites=r)}_getGpuTimer(){return this.GU==null&&(this.GU=new le(this.eU.gpuDevice)),this.GU}yP(){var t;let e=this.pU;e.active&&(this._U(),this.Ew(e.engine,e.renderPass,e.displayIdx,!0,!1),this.RP(),(t=this.rU)==null||t.end(),this.rU=void 0)}RP(){let e=this.pU;e.active=!1,e.engine=void 0,e.renderPass=void 0,e.targetViews.length=0,e.isColorClear=!1,e.isDepthClear=!1}UU(){this.yP(),this._U()}IU(e){this.kP.push(e)}CU(){let e=this.kP;e.length===0||this.rU==null||(this.rU.executeBundles(e),e.length=0)}static GP(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}_U(){let e=this.rU;e!=null&&(this.CU(),this.iU!=null&&this.fP===this.yU&&this.xP===this.vU&&(e.executeBundles([this.iU.finish()]),this.TU()),e.end(),this.rU=void 0,this.yU=void 0,this.vU=-1,this.uP=_)}TU(){var e;(e=this.nU)==null||e.abortRecording(),this.iU=void 0,this.Aw(),this.QU=void 0,this.fP=void 0,this.xP=-1}Ew(e,t,r,n,s=!0){let i=t.getFramebuffer(),a=t.getResolveFramebuffer(),u=n?this.pU:void 0,o;if(s&&t.toClearColorBuffer)o={r:t.clearColor.x,g:t.clearColor.y,b:t.clearColor.z,a:t.clearColor.w};else if(u!=null&&u.isColorClear){let h=u.clearColor;o={r:h.r,g:h.g,b:h.b,a:h.a}}let c;s&&t.toClearDepthBuffer?c=t.clearDepth:u!=null&&u.isDepthClear&&(c=u.clearDepth);let l=o!=null?"clear":"load",p=c!=null?"clear":"load",f=e._webXRSystemIfEnabled;if(a!=null&&i!=null){let h=this.dU;i.depthAttachment!=null&&this.tU.get(i.depthAttachment._textureResourceUid)!=null&&(h=this.tU.get(i.depthAttachment._textureViewResourceUid));let g={colorAttachments:[],depthStencilAttachment:{view:h,depthClearValue:c,depthLoadOp:p,depthStoreOp:"store"},label:t.uniqueName},d=[];for(let m=0;m<a.colorAttachments.length;m++){let T=i.colorAttachments[m],x=a.colorAttachments[m],U=this.tU.get(T._textureViewAsRenderTargetResourceUid),b=this.tU.get(x._textureViewAsRenderTargetResourceUid);d.push({view:U,resolveTarget:b,clearValue:o,loadOp:l,storeOp:"store"})}g.colorAttachments=d,this.rU=this.BU(g)}else if(i!=null){let h;i.depthAttachment!=null&&this.tU.get(i.depthAttachment._textureResourceUid)!=null&&(h=this.tU.get(i.depthAttachment._textureViewAsRenderTargetResourceUid));let g;h!=null&&(g={view:h,depthClearValue:c,depthLoadOp:p,depthStoreOp:"store"});let d={colorAttachments:[],depthStencilAttachment:g,label:t.uniqueName},m=[];for(let T of i.colorAttachments){let x=this.tU.get(T._textureViewAsRenderTargetResourceUid);m.push({view:x,clearValue:o,loadOp:l,storeOp:"store"})}d.colorAttachments=m,this.rU=this.BU(d)}else if(f!=null&&f.isWebXRMode&&t.isOutputForVr){let h=[],g=e.engineState.xrPoseWebGPU.views[r],d=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,g);h.push({view:d.colorTexture.createView(d.getViewDescriptor()),clearValue:o,loadOp:l,storeOp:"store"});let m={view:d.depthStencilTexture.createView(d.getViewDescriptor()),depthClearValue:c,depthLoadOp:p,depthStoreOp:"store"},T={colorAttachments:h,depthStencilAttachment:m};this.rU=this.BU(T)}else{let h={colorAttachments:[{view:this.FU(),clearValue:o,loadOp:l,storeOp:"store"}],depthStencilAttachment:{view:this.dU,depthClearValue:c,depthLoadOp:p,depthStoreOp:"store"},label:t.uniqueName};this.rU=this.BU(h)}}sU(){var e;this.DU.clear(),(e=this.nU)==null||e.retireAllBundles()}Vw(e,t,r){var n,s;e.config.cacheWebGpuRenderBundles?((n=this.nU)==null||n.finishRecording(t),this.DU.set(t,r)):((s=this.nU)==null||s.finishRecording(void 0),this.sU())}Mw(e){(this.ZU||e.config.isGpuCullingEnabled!==this.NP||e.config.isComputeSkinningEnabled!==this.zP||I._isFrustumCullingEnabled!==this.XP)&&(this.sU(),e.engineState.webgpuRenderBundleMode=!1,this.ZU=!1,this.NP=e.config.isGpuCullingEnabled,this.zP=e.config.isComputeSkinningEnabled,this.XP=I._isFrustumCullingEnabled);let t=this.LU;this.Gw!=null&&(t[0]!==this.lU||t[1]!==this.gU||t[2]!==this.oU||t[3]!==this.uU||t[4]!==this.wP())&&(this.sU(),e.engineState.webgpuRenderBundleMode=!1),(e.materialRepository.bindingStateVersion!==this.$P||z.getCurrent(e)!==this.qP||X.updateCount!==this.KP||k.variantUpdateCount!==this.jP||I.updateCount!==this.ZP)&&(this.sU(),e.engineState.webgpuRenderBundleMode=!1,this.qP=z.getCurrent(e),this.$P=e.materialRepository.bindingStateVersion,this.KP=X.updateCount,this.jP=k.variantUpdateCount,this.ZP=I.updateCount)}renderWithRenderBundle(e,t,r){this.Mw(e),(t._isChangedSortRenderResult||!e.config.cacheWebGpuRenderBundles)&&this.sU();let n=`${t.renderPassUID}-${r}`,s=this.DU.get(n);return s!=null&&(this.createRenderPassEncoder(e,t,r),this.rU!=null)?(this.IU(s),!0):!1}renderWithRenderBundleAndKeepRenderPass(e,t,r){this.Mw(e),(t._isChangedSortRenderResult||!e.config.cacheWebGpuRenderBundles)&&this.sU();let n=`${t.renderPassUID}-${r}`,s=this.DU.get(n);if(s!=null&&(this.createRenderPassEncoder(e,t,r),this.rU!=null))return this.IU(s),this.CU(),this.TU(),this.rU}finishRenderBundleEncoder(e,t,r){if(this.createRenderPassEncoder(e,t,r),this.rU!=null&&this.iU!=null){let n=this.iU.finish();this.Vw(e,`${t.renderPassUID}-${r}`,n),this.IU(n),this.TU()}else console.log("renderPassEncoder is null")}finishRenderBundleEncoderAndKeepRenderPass(e,t,r){if(this.createRenderPassEncoder(e,t,r),this.rU!=null&&this.iU!=null){let n=this.iU.finish();this.Vw(e,`${t.renderPassUID}-${r}`,n),this.IU(n),this.TU()}return this.CU(),this.rU}getOrCreateRenderPassEncoderForExternalRendering(e,t,r){return this.createRenderPassEncoder(e,t,r),this.CU(),this.rU}endRenderPassEncoderForExternalRendering(){this.rU!=null&&(this.CU(),this.iU!=null&&(this.rU.executeBundles([this.iU.finish()]),this.TU()),this._U())}Kw(){return this.JU==null&&(this.JU=this.eU.gpuDevice.createShaderModule({label:"DepthPrepass",code:`@fragment
|
|
114
|
+
`})),this.RU!=null&&t.format!==this.YP&&(this.RU=void 0),this.RU==null){this.UP=r.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{viewDimension:"2d"}}]});let i=r.createPipelineLayout({bindGroupLayouts:[this.UP]});this.RU=r.createRenderPipeline({layout:i,vertex:{module:this.VU,entryPoint:"vertexMain"},fragment:{module:this.VU,entryPoint:"fragmentMain",targets:[{format:t.format}]},primitive:{topology:"triangle-strip",stripIndexFormat:"uint32"}}),this.YP=t.format}this.bP==null&&(this.bP=r.createSampler({minFilter:"linear"})),this.UU();let s=e.dimension==="2d"&&e.depthOrArrayLayers===6?6:1;for(let i=0;i<s;++i){let a=this.wU.get(e);if(a==null||a[i]==null){let o=e.createView({dimension:"2d",baseMipLevel:0,mipLevelCount:1,baseArrayLayer:i,arrayLayerCount:1});a==null&&this.wU.set(e,[]),this.wU.get(e)[i]=o}let u=this.wU.get(e)[i];for(let o=1;o<t.mipLevelCount;++o){let c=this.hU.get(e);if(c==null||c[i]==null||c[i][o]==null){let g=e.createView({dimension:"2d",baseMipLevel:o,mipLevelCount:1,baseArrayLayer:i,arrayLayerCount:1});c==null&&this.hU.set(e,[]),this.hU.get(e)[i]==null&&(this.hU.get(e)[i]=[]),this.hU.get(e)[i][o]=g}let l=this.hU.get(e)[i][o],p=this.aU.beginRenderPass({colorAttachments:[{view:l,loadOp:"load",storeOp:"store"}]}),f=this.mU.get(e);if(f==null||f[i]==null||f[i][o]==null){let g=r.createBindGroup({layout:this.UP,entries:[{binding:0,resource:this.bP},{binding:1,resource:u}]});f==null&&this.mU.set(e,[]),this.mU.get(e)[i]==null&&(this.mU.get(e)[i]=[]),this.mU.get(e)[i][o]=g}let h=this.mU.get(e)[i][o];p.setPipeline(this.RU),p.setBindGroup(0,h),p.draw(4),p.end(),u=l}}}createTextureSampler({magFilter:e,minFilter:t,wrapS:r,wrapT:n,wrapR:s,anisotropy:i}){let a=this.eU.gpuDevice,u=i?4:1,o={magFilter:e.webgpu,minFilter:t.webgpu,mipmapFilter:t===V.LinearMipmapLinear||t===V.NearestMipmapLinear?"linear":"nearest",addressModeU:r.webgpu,addressModeV:n.webgpu,addressModeW:s.webgpu,maxAnisotropy:u};(o.magFilter==="nearest"||o.minFilter==="nearest"||o.mipmapFilter==="nearest")&&(o.maxAnisotropy=1);let c=a.createSampler(o);return this._A(c)}createVertexBuffer(e){return this.TP(e.getUint8Array())}createVertexBufferFromTypedArray(e){return this.TP(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}static QP(e){let t=e.componentType,r=e.compositionType;if(e.normalized){let n="";t===H.UnsignedByte?n="unorm8":t===H.Byte?n="snorm8":t===H.UnsignedShort?n="unorm16":t===H.Short&&(n="snorm16");let s=n+r.webgpu;if(n!==""&&y.Xw.has(s))return s}return t.webgpu+r.webgpu}createIndexBuffer(e){return this.TP(y.Tw(e))}static Tw(e){if(e.componentType!==H.UnsignedByte)return e.getUint8Array();let t=e.getTypedArray(),r=new Uint16Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n];return new Uint8Array(r.buffer)}kw(){return this.xU==null&&(this.xU=new ue(this.eU.gpuDevice,GPUBufferUsage.VERTEX|GPUBufferUsage.INDEX)),this.xU}TP(e){let t=this.kw().allocate(e),r=this.getResourceNumber();return this.fU.set(r,t),r}_getVertexBufferRange(e){return this.fU.get(e)}PP(e){let t=this.fU.get(e);return t==null?!1:(this.xU.release(t),this.fU.delete(e),this.sU(),!0)}updateVertexBuffer(e,t){let r=this.fU.get(t);if(E.not.exist(r))throw new Error("Not found VBO.");this.xU.write(r,e.getUint8Array())}updateIndexBuffer(e,t){let r=this.fU.get(t);if(E.not.exist(r))throw new Error("Not found IBO.");this.xU.write(r,y.Tw(e))}deleteVertexBuffer(e){if(!this.PP(e))throw new Error("Not found VBO.")}createVertexBufferAndIndexBuffer(e){let t;e.hasIndices()&&(t=this.createIndexBuffer(e.indicesAccessor));let r=[];for(let s=0;s<F.AttributeTypeNumber;s++)r[s]=!1;let n=[];return e.attributeAccessors.forEach((s,i)=>{let a=this.createVertexBuffer(s),u=F.toAttributeSlotFromJoinedString(e.attributeSemantics[i]);r[u]=!0,n.push(a)}),{vaoHandle:-1,iboHandle:t,vboHandles:n,attributesFlags:r,setComplete:!1}}updateVertexBufferAndIndexBuffer(e,t){t.iboHandle&&this.updateIndexBuffer(e.indicesAccessor,t.iboHandle);let r=e.attributeAccessors;for(let n=0;n<r.length;n++)this.updateVertexBuffer(r[n],t.vboHandles[n])}deleteVertexDataResources(e){E.exist(e.iboHandle)&&this.PP(e.iboHandle);for(let t of e.vboHandles)this.PP(t)}setVertexDataToPipeline({vboHandles:e},t){let r=[],n=[];for(let s=0;s<e.length;s++){let i=F.toAttributeSlotFromJoinedString(t.attributeSemantics[s]),a=y.QP(t.attributeAccessors[s]);n.push({shaderLocation:i,offset:t.attributeAccessors[s].byteOffsetInBufferView,format:a})}r[0]={stepMode:"vertex",attributes:n,arrayStride:t.attributeAccessors[0].byteStride},r[1]={stepMode:"instance",attributes:[{shaderLocation:F.Instance.getAttributeSlot(),offset:0,format:"uint32x4"}],arrayStride:16}}XA(e,t,r,n){e.logger.info(`MaterialTypeName: ${t}`);let s=ee.addLineNumberToCode(r);e.logger.info(s);let i=!0;for(let a=0;a<n.messages.length;a++)e.logger.info(n.messages[a].message),i=!1;return i}createShaderProgram({config:e,engine:t,material:r,vertexShaderStr:n,fragmentShaderStr:s}){let i=this.eU.gpuDevice,a=i.createShaderModule({code:n,label:`${r.materialTypeName} vertex shader`});e.cgApiDebugConsoleOutput&&a.getCompilationInfo().then(l=>{l.messages.length>0&&this.XA(t,r.materialTypeName,n,l)});let u=i.createShaderModule({code:s,label:`${r.materialTypeName} fragment shader`});e.cgApiDebugConsoleOutput&&u.getCompilationInfo().then(l=>{l.messages.length>0&&this.XA(t,r.materialTypeName,s,l)});let o={vsModule:a,fsModule:u};return this._A(o)}clearFrameBuffer(e,t,r){if(t.entities.length>0||!t.toClearColorBuffer&&!t.toClearDepthBuffer)return;let n=e._webXRSystemIfEnabled,s=t.getFramebuffer()==null&&(n==null?void 0:n.isWebXRMode)&&t.isOutputForVr;if(t.getResolveFramebuffer()==null&&!s){let l=this.EU,p=this.Aw(e,t,l),f=this.pU;if(f.active&&(p!==f.targetKind||!y.GP(l,f.targetViews))&&this.yP(),f.active||(f.active=!0,f.engine=e,f.renderPass=t,f.displayIdx=r,f.targetKind=p,this.EU=f.targetViews,f.targetViews=l),t.toClearColorBuffer){let h=t.clearColor;f.isColorClear=!0,f.clearColor.r=h.x,f.clearColor.g=h.y,f.clearColor.b=h.z,f.clearColor.a=h.w}t.toClearDepthBuffer&&(f.isDepthClear=!0,f.clearDepth=t.clearDepth);return}this.UU();let i=[],a,u=e._webXRSystemIfEnabled;if(t.toClearColorBuffer){let l=t.getFramebuffer();if(l!=null)for(let p of l.colorAttachments){let f=this.tU.get(p._textureViewAsRenderTargetResourceUid);i.push({view:f,clearValue:{r:t.clearColor.x,g:t.clearColor.y,b:t.clearColor.z,a:t.clearColor.w},loadOp:"clear",storeOp:"store"})}else if(u!=null&&u.isWebXRMode&&t.isOutputForVr){let p=e.engineState.xrPoseWebGPU.views[r],f=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,p);i.push({view:f.colorTexture.createView(f.getViewDescriptor()),clearValue:{r:t.clearColor.x,g:t.clearColor.y,b:t.clearColor.z,a:t.clearColor.w},loadOp:"clear",storeOp:"store"})}else i.push({view:this.FU(),clearValue:{r:t.clearColor.x,g:t.clearColor.y,b:t.clearColor.z,a:t.clearColor.w},loadOp:"clear",storeOp:"store"})}if(t.toClearDepthBuffer){let l=t.getFramebuffer();if(l!=null&&l.depthAttachment!=null)a={view:this.tU.get(l.depthAttachment._textureViewAsRenderTargetResourceUid),depthClearValue:t.clearDepth,depthLoadOp:"clear",depthStoreOp:"store"};else if(u!=null&&u.isWebXRMode&&t.isOutputForVr){let p=e.engineState.xrPoseWebGPU.views[r],f=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,p);a={view:f.depthStencilTexture.createView(f.getViewDescriptor()),depthClearValue:t.clearDepth,depthLoadOp:"clear",depthStoreOp:"store"}}else a={view:this.dU,depthClearValue:t.clearDepth,depthLoadOp:"clear",depthStoreOp:"store"}}let o={colorAttachments:i,depthStencilAttachment:a,label:t.uniqueName};this.BU(o).end()}draw(e,t,r,n,s,i,a,u={}){var G;let o=n.isBufferLessRenderingMode(),c=t._vertexHandles;if(!o&&c==null)return;let l="",p,f,h;if(o){let R=r.getTextureParameter(M.DiffuseEnvTexture.str);R!=null&&(p=R[1]);let w=r.getTextureParameter(M.SpecularEnvTexture.str);w!=null&&(f=w[1]);let B=r.getTextureParameter(M.SheenEnvTexture.str);B!=null&&(h=B[1])}else{let w=t.mesh.meshEntitiesInner[0],B=w.getMeshRenderer();r._setInternalSettingParametersToGpuWebGpu({engine:e,material:r,args:{cameraComponentSid:s,entity:w,specularCube:B.specularCubeMap}}),p=B.diffuseCubeMap,f=B.specularCubeMap,h=B.sheenCubeMap,l=B.getFingerPrint()}let g=`${t._getFingerPrint()} ${r._getFingerPrint()} ${r.og} ${n.renderPassUID} ${l} ${i} `,d=this.Yw(e,r,p,f,h),[m,T]=this.getOrCreateRenderPipeline(g,d.pipelineLayoutKey,d.pipelineLayout,t,r,n,i,u),x=this.iU,U=this.LP;U[0]!==d.storage&&(x.setBindGroup(0,d.storage),U[0]=d.storage),this.qU!==m&&(x.setPipeline(m),this.qU=m),U[1]!==d.texture&&(x.setBindGroup(1,d.texture),U[1]=d.texture),U[2]!==d.sampler&&(x.setBindGroup(2,d.sampler),U[2]=d.sampler);let b=o?void 0:this.$w(e,t,t.mesh,n,s);(b==null?void 0:b.deformedVertexOffset)!==void 0&&this.qw(b.deformedVertexOffset);let P=this.FP;if(U[3]!==P&&(x.setBindGroup(3,P),U[3]=P),o)x.draw(n._drawVertexNumberForBufferLessRendering);else{let R=t.mesh,w=this.fU,B=this.OP,A=(G=b==null?void 0:b.instanceVertexBuffer)!=null?G:w.get(R._variationVBOUid);B[0]!==A&&(x.setVertexBuffer(0,A.buffer,A.offset,A.size),B[0]=A);let D=c.vboHandles;for(let v=0;v<D.length;v++){let C=w.get(D[v]);B[v+1]!==C&&(x.setVertexBuffer(v+1,C.buffer,C.offset,C.size),B[v+1]=C)}if(t.hasIndices()){let v=w.get(c.iboHandle),C=t.getIndexBitSize();if((this.KU!==v||this.jU!==C)&&(x.setIndexBuffer(v.buffer,C,v.offset,v.size),this.KU=v,this.jU=C),b!=null)x.drawIndexedIndirect(b.indirectBuffer,b.indirectOffset);else{let O=t.indicesAccessor;x.drawIndexed(O.elementCount,R.meshEntitiesInner.length)}}else if(b!=null)x.drawIndirect(b.indirectBuffer,b.indirectOffset);else{let v=t.attributeAccessors[0].elementCount;x.draw(v,R.meshEntitiesInner.length)}}}$w(e,t,r,n,s){let i=this.nU;if(i==null||!i.isRecording||!r._isGpuCullable||!I._isGpuCullingActive(e,n))return;let a=t.hasIndices()?t.indicesAccessor.elementCount:t.attributeAccessors[0].elementCount;return i.registerDraw(e,r,t,s,a)}_markGpuCullingInputsDirty(){var e;(e=this.nU)==null||e.markInputsDirty()}_getGpuCulling(){return this.nU}_destroyGpuCulling(){this.nU!=null&&(this.sU(),this.nU.destroy(),this.nU=void 0)}Kw(e,t,r){let n=t.getFramebuffer(),s=t.getResolveFramebuffer(),i=[],a,u=1,o=e._webXRSystemIfEnabled;if(n!=null){for(let l of n.colorAttachments){if(l==null)continue;let p=l._textureResourceUid;if(p==null||p<0)continue;let f=this.tU.get(p);f!=null&&i.push(f.format)}if(s!=null&&n.colorAttachments.length>0){let l=n.colorAttachments[0],p=l==null?void 0:l.sampleCount;typeof p=="number"&&p>0&&(u=p)}if(n.depthAttachment!=null){let l=n.depthAttachment._textureResourceUid;if(l!=null&&l>=0){let p=this.tU.get(l);a=p==null?void 0:p.format}else a=void 0}else a=void 0}else if(o!=null&&o.isWebXRMode&&t.isOutputForVr){let l=e.engineState.xrPoseWebGPU.views[r],p=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,l);i=[p.colorTexture.format],a=p.depthStencilTexture.format}else i=[navigator.gpu.getPreferredCanvasFormat()],a=this.bU!=null?this.bU.format:N;return i.length===0&&(i=[navigator.gpu.getPreferredCanvasFormat()]),{colorFormats:i,depthStencilFormat:a,sampleCount:u}}getEffekseerRenderPassOptions(e,t,r=0){var u;if(t==null)return{colorFormat:navigator.gpu.getPreferredCanvasFormat(),depthFormat:void 0};let n=t.getFramebuffer(),s=t.getResolveFramebuffer(),i;if(s!=null&&s.colorAttachments.length>0){let o=s.colorAttachments[0]._textureResourceUid,c=o!=null?this.tU.get(o):void 0;i=c==null?void 0:c.format}else if(n!=null&&n.colorAttachments.length>0){let o=n.colorAttachments[0]._textureResourceUid,c=o!=null?this.tU.get(o):void 0;i=c==null?void 0:c.format}else if((u=e._webXRSystemIfEnabled)!=null&&u.isWebXRMode&&t.isOutputForVr){let o=e.engineState.xrPoseWebGPU.views[r];i=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,o).colorTexture.format}else i=navigator.gpu.getPreferredCanvasFormat();return{colorFormat:i,depthFormat:void 0}}getOrCreateRenderPassEncoderForEffekseerExternalRendering(e,t,r){this.UU(),this.iU!=null&&this.TU();let n=t.getFramebuffer(),s=t.getResolveFramebuffer(),i=e._webXRSystemIfEnabled,a=[];if(s!=null)for(let o of s.colorAttachments){let c=this.tU.get(o._textureViewAsRenderTargetResourceUid);a.push({view:c,loadOp:"load",storeOp:"store"})}else if(n!=null)for(let o of n.colorAttachments){let c=this.tU.get(o._textureViewAsRenderTargetResourceUid);a.push({view:c,loadOp:"load",storeOp:"store"})}else if(i!=null&&i.isWebXRMode&&t.isOutputForVr){let o=e.engineState.xrPoseWebGPU.views[r],c=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,o);a.push({view:c.colorTexture.createView(c.getViewDescriptor()),loadOp:"load",storeOp:"store"})}else a.push({view:this.FU(),loadOp:"load",storeOp:"store"});if(a.length===0)return;let u={colorAttachments:a,label:`${t.uniqueName}_EffekseerExternal`};return this.Ew(u),this.rU=this.aU.beginRenderPass(u),this.rU}createRenderBundleEncoder(e,t,r){var a,u,o,c;let n=this.eU.gpuDevice,s=this.Kw(e,t,r),i=JSON.stringify({colorFormats:s.colorFormats,depthStencilFormat:(a=s.depthStencilFormat)!=null?a:null,sampleCount:s.sampleCount});this.fP=t,this.xP=r,!(this.iU!=null&&this.QU===i)&&(this.iU=n.createRenderBundleEncoder(s),this.QU=i,this.Sw(),e.config.isGpuCullingEnabled&&((o=this[u="nU"])!=null||(this[u]=new ce(n))),(c=this.nU)==null||c.beginRecording())}Sw(){this.qU=void 0,this.LP.length=0,this.OP.length=0,this.KU=void 0,this.jU=void 0}createRenderPassEncoder(e,t,r){if(this.rU!=null&&this.yU===t&&this.vU===r&&!this.pU.active)return;let n=this.EU,s=this.Aw(e,t,n),i=!1,a=this.pU;if(a.active&&(s!==_&&s===a.targetKind&&y.GP(n,a.targetViews)?i=!0:this.yP()),this.rU!=null){if(!i&&s!==_&&s===this.uP&&!t.toClearColorBuffer&&!t.toClearDepthBuffer&&y.GP(n,this.dP)){this.yU=t,this.vU=r;return}this._U()}this.Vw(e,t,r,i),i&&this.RP(),this.rU!=null&&(this.yU=t,this.vU=r,this.uP=s,this.EU=this.dP,this.dP=n)}Aw(e,t,r){var a;r.length=0;let n=t.getFramebuffer(),s=t.getResolveFramebuffer(),i=this.tU;if(s!=null&&n!=null){for(let c=0;c<s.colorAttachments.length;c++){let l=n.colorAttachments[c],p=s.colorAttachments[c];r.push(i.get(l._textureViewAsRenderTargetResourceUid)),r.push(i.get(p._textureViewAsRenderTargetResourceUid))}let u=this.dU,o=n.depthAttachment;return o!=null&&i.get(o._textureResourceUid)!=null&&(u=i.get(o._textureViewResourceUid)),r.push(u),de}if(n!=null){for(let c of n.colorAttachments)r.push(i.get(c._textureViewAsRenderTargetResourceUid));let u,o=n.depthAttachment;return o!=null&&i.get(o._textureResourceUid)!=null&&(u=i.get(o._textureViewAsRenderTargetResourceUid)),r.push(u),fe}return(a=e._webXRSystemIfEnabled)!=null&&a.isWebXRMode&&t.isOutputForVr?_:(r.push(this.FU()),r.push(this.dU),$)}FU(){let e=this.MU;if(e==null){let t=this.eU.context.getCurrentTexture();e=y.jw(this.eU.gpuDevice)?t:t.createView(),this.MU=e}return e}static jw(e){let t=y.Mw;if(t!==void 0)return t;let r;try{r=e.createTexture({size:[1,1],format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT}),e.createCommandEncoder().beginRenderPass({colorAttachments:[{view:r,loadOp:"clear",storeOp:"store"}]}).end(),t=!0}catch{t=!1}finally{r==null||r.destroy()}return y.Mw=t,t}BU(e){let t=this.SU;if(t!==void 0){let r=e.depthStencilAttachment;r!=null&&r.view===this.dU&&(r.depthLoadOp==="load"&&(r.depthLoadOp="clear",r.depthClearValue=t),this.SU=void 0)}return this.Ew(e),this.aU.beginRenderPass(e)}Ew(e){var n;let t=this.GU;if(t==null||e.timestampWrites!=null)return;let r=t.getTimestampWrites((n=e.label)!=null?n:"renderPass");r!=null&&(e.timestampWrites=r)}_getGpuTimer(){return this.GU==null&&(this.GU=new le(this.eU.gpuDevice)),this.GU}yP(){var t;let e=this.pU;e.active&&(this._U(),this.Vw(e.engine,e.renderPass,e.displayIdx,!0,!1),this.RP(),(t=this.rU)==null||t.end(),this.rU=void 0)}RP(){let e=this.pU;e.active=!1,e.engine=void 0,e.renderPass=void 0,e.targetViews.length=0,e.isColorClear=!1,e.isDepthClear=!1}UU(){this.yP(),this._U()}IU(e){this.kP.push(e)}CU(){let e=this.kP;e.length===0||this.rU==null||(this.rU.executeBundles(e),e.length=0)}static GP(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}_U(){let e=this.rU;e!=null&&(this.CU(),this.iU!=null&&this.fP===this.yU&&this.xP===this.vU&&(e.executeBundles([this.iU.finish()]),this.TU()),e.end(),this.rU=void 0,this.yU=void 0,this.vU=-1,this.uP=_)}TU(){var e;(e=this.nU)==null||e.abortRecording(),this.iU=void 0,this.Sw(),this.QU=void 0,this.fP=void 0,this.xP=-1}Vw(e,t,r,n,s=!0){let i=t.getFramebuffer(),a=t.getResolveFramebuffer(),u=n?this.pU:void 0,o;if(s&&t.toClearColorBuffer)o={r:t.clearColor.x,g:t.clearColor.y,b:t.clearColor.z,a:t.clearColor.w};else if(u!=null&&u.isColorClear){let h=u.clearColor;o={r:h.r,g:h.g,b:h.b,a:h.a}}let c;s&&t.toClearDepthBuffer?c=t.clearDepth:u!=null&&u.isDepthClear&&(c=u.clearDepth);let l=o!=null?"clear":"load",p=c!=null?"clear":"load",f=e._webXRSystemIfEnabled;if(a!=null&&i!=null){let h=this.dU;i.depthAttachment!=null&&this.tU.get(i.depthAttachment._textureResourceUid)!=null&&(h=this.tU.get(i.depthAttachment._textureViewResourceUid));let g={colorAttachments:[],depthStencilAttachment:{view:h,depthClearValue:c,depthLoadOp:p,depthStoreOp:"store"},label:t.uniqueName},d=[];for(let m=0;m<a.colorAttachments.length;m++){let T=i.colorAttachments[m],x=a.colorAttachments[m],U=this.tU.get(T._textureViewAsRenderTargetResourceUid),b=this.tU.get(x._textureViewAsRenderTargetResourceUid);d.push({view:U,resolveTarget:b,clearValue:o,loadOp:l,storeOp:"store"})}g.colorAttachments=d,this.rU=this.BU(g)}else if(i!=null){let h;i.depthAttachment!=null&&this.tU.get(i.depthAttachment._textureResourceUid)!=null&&(h=this.tU.get(i.depthAttachment._textureViewAsRenderTargetResourceUid));let g;h!=null&&(g={view:h,depthClearValue:c,depthLoadOp:p,depthStoreOp:"store"});let d={colorAttachments:[],depthStencilAttachment:g,label:t.uniqueName},m=[];for(let T of i.colorAttachments){let x=this.tU.get(T._textureViewAsRenderTargetResourceUid);m.push({view:x,clearValue:o,loadOp:l,storeOp:"store"})}d.colorAttachments=m,this.rU=this.BU(d)}else if(f!=null&&f.isWebXRMode&&t.isOutputForVr){let h=[],g=e.engineState.xrPoseWebGPU.views[r],d=e.engineState.xrGpuBinding.getViewSubImage(e.engineState.xrProjectionLayerWebGPU,g);h.push({view:d.colorTexture.createView(d.getViewDescriptor()),clearValue:o,loadOp:l,storeOp:"store"});let m={view:d.depthStencilTexture.createView(d.getViewDescriptor()),depthClearValue:c,depthLoadOp:p,depthStoreOp:"store"},T={colorAttachments:h,depthStencilAttachment:m};this.rU=this.BU(T)}else{let h={colorAttachments:[{view:this.FU(),clearValue:o,loadOp:l,storeOp:"store"}],depthStencilAttachment:{view:this.dU,depthClearValue:c,depthLoadOp:p,depthStoreOp:"store"},label:t.uniqueName};this.rU=this.BU(h)}}sU(){var e;this.DU.clear(),(e=this.nU)==null||e.retireAllBundles()}Fw(e,t,r){var n,s;e.config.cacheWebGpuRenderBundles?((n=this.nU)==null||n.finishRecording(t),this.DU.set(t,r)):((s=this.nU)==null||s.finishRecording(void 0),this.sU())}Iw(e){(this.ZU||e.config.isGpuCullingEnabled!==this.NP||e.config.isComputeSkinningEnabled!==this.zP||I._isFrustumCullingEnabled!==this.XP)&&(this.sU(),e.engineState.webgpuRenderBundleMode=!1,this.ZU=!1,this.NP=e.config.isGpuCullingEnabled,this.zP=e.config.isComputeSkinningEnabled,this.XP=I._isFrustumCullingEnabled);let t=this.LU;this.Gw!=null&&(t[0]!==this.lU||t[1]!==this.gU||t[2]!==this.oU||t[3]!==this.uU||t[4]!==this.wP())&&(this.sU(),e.engineState.webgpuRenderBundleMode=!1),(e.materialRepository.bindingStateVersion!==this.$P||z.getCurrent(e)!==this.qP||X.updateCount!==this.KP||k.variantUpdateCount!==this.jP||I.updateCount!==this.ZP)&&(this.sU(),e.engineState.webgpuRenderBundleMode=!1,this.qP=z.getCurrent(e),this.$P=e.materialRepository.bindingStateVersion,this.KP=X.updateCount,this.jP=k.variantUpdateCount,this.ZP=I.updateCount)}renderWithRenderBundle(e,t,r){this.Iw(e),(t._isChangedSortRenderResult||!e.config.cacheWebGpuRenderBundles)&&this.sU();let n=`${t.renderPassUID}-${r}`,s=this.DU.get(n);return s!=null&&(this.createRenderPassEncoder(e,t,r),this.rU!=null)?(this.IU(s),!0):!1}renderWithRenderBundleAndKeepRenderPass(e,t,r){this.Iw(e),(t._isChangedSortRenderResult||!e.config.cacheWebGpuRenderBundles)&&this.sU();let n=`${t.renderPassUID}-${r}`,s=this.DU.get(n);if(s!=null&&(this.createRenderPassEncoder(e,t,r),this.rU!=null))return this.IU(s),this.CU(),this.TU(),this.rU}finishRenderBundleEncoder(e,t,r){if(this.createRenderPassEncoder(e,t,r),this.rU!=null&&this.iU!=null){let n=this.iU.finish();this.Fw(e,`${t.renderPassUID}-${r}`,n),this.IU(n),this.TU()}else console.log("renderPassEncoder is null")}finishRenderBundleEncoderAndKeepRenderPass(e,t,r){if(this.createRenderPassEncoder(e,t,r),this.rU!=null&&this.iU!=null){let n=this.iU.finish();this.Fw(e,`${t.renderPassUID}-${r}`,n),this.IU(n),this.TU()}return this.CU(),this.rU}getOrCreateRenderPassEncoderForExternalRendering(e,t,r){return this.createRenderPassEncoder(e,t,r),this.CU(),this.rU}endRenderPassEncoderForExternalRendering(){this.rU!=null&&(this.CU(),this.iU!=null&&(this.rU.executeBundles([this.iU.finish()]),this.TU()),this._U())}Zw(){return this.JU==null&&(this.JU=this.eU.gpuDevice.createShaderModule({label:"DepthPrepass",code:`@fragment
|
|
115
115
|
fn main() {}
|
|
116
|
-
`})),this.JU}getOrCreateRenderPipeline(e,t,r,n,s,i,a,u={}){var w,B;let o=(w=u.depthOnly)!=null?w:!1,c=(B=u.allowEqualDepth)!=null?B:!1,l=`${e}|${t}|${o?"depthOnly":"color"}|${c?"equal":"less"}`,p=this.OU.get(l);if(p!=null&&this.WU.get(l)===s.pipelineStateVersion)return[p,!1];let f=this.eU.gpuDevice,h=navigator.gpu.getPreferredCanvasFormat(),g=this.tU.get(s.getShaderProgramUid(n));g!=null&&new Error("Shader Modules is not found");let d=[];i.isBufferLessRenderingMode()||d.push({stepMode:"instance",attributes:[{shaderLocation:F.Instance.getAttributeSlot(),offset:0,format:"uint32x4"}],arrayStride:16}),n.attributeAccessors.forEach((A,D)=>{let C={shaderLocation:F.toAttributeSlotFromJoinedString(n.attributeSemantics[D]),offset:0,format:y.QP(A)};d.push({stepMode:"vertex",arrayStride:n.attributeAccessors[D].actualByteStride,attributes:[C]})});let m;s.isBlend()&&s.alphaMode===j.Blend&&(m={color:{srcFactor:s.blendFuncSrcFactor.webgpu,dstFactor:s.blendFuncDstFactor.webgpu,operation:s.blendEquationMode.webgpu},alpha:{srcFactor:s.blendFuncAlphaSrcFactor.webgpu,dstFactor:s.blendFuncAlphaDstFactor.webgpu,operation:s.blendEquationModeAlpha.webgpu}});let x=(i.isBufferLessRenderingMode()?i._primitiveModeForBufferLessRendering:n.primitiveMode).getWebGPUTypeStr(),U;n.hasIndices()&&(x==="triangle-strip"||x==="line-strip")&&(U=n.getIndexBitSize());let b=i.getFramebuffer(),P=[{format:h,blend:m}],G=N;if(b!=null){P=[];for(let A of b.colorAttachments){let D=this.tU.get(A._textureResourceUid);P.push({format:D.format,blend:m,writeMask:this.setColorWriteMask(s)})}b.depthAttachment!=null?G=this.tU.get(b.depthAttachment._textureResourceUid).format:G=void 0}let R=f.createRenderPipeline({layout:r,vertex:{module:g.vsModule,entryPoint:"main",buffers:d},fragment:{module:o?this.Kw():g.fsModule,entryPoint:"main",targets:o?P.map(A=>({format:A.format,writeMask:0})):P},primitive:{topology:x,stripIndexFormat:U,frontFace:s.cullFrontFaceCCW?"ccw":"cw",cullMode:s.cullFace?s.cullFaceBack?"back":"front":"none"},depthStencil:G==null?void 0:{depthWriteEnabled:o?!0:a,depthCompare:o||c?"less-equal":i.isDepthTest?"less":"always",format:G},multisample:{count:i.getResolveFramebuffer()!=null?i.getFramebuffer().colorAttachments[0].sampleCount:1}});return this.OU.set(l,R),this.WU.set(l,s.pipelineStateVersion),[R,!0]}flush(){let e=this.eU.gpuDevice,t=this.pU;t.active&&!t.isColorClear&&t.targetKind===$&&t.targetViews[t.targetViews.length-1]===this.dU&&(this.SU=t.clearDepth,this.RP()),this.UU();let r=this.GU,n=this.nU,s=n==null?void 0:n.encode(this.lU,r,{blendShapeData:this.gU,morphOffsets:this.oU,morphWeights:this.uU});r==null||r.encodeResolve(this.aU);let i=this.aU.finish();this.WP.submit(s!=null?[s,i]:[i]),r==null||r.afterSubmit(),this.aU=e.createCommandEncoder(),n!=null&&n.afterSubmit()&&(this.sU(),this.ZU=!0),this.MU!=null&&(this.MU=void 0)}setColorWriteMask(e){let t=0;return e.colorWriteMask[0]&&(t|=1),e.colorWriteMask[1]&&(t|=2),e.colorWriteMask[2]&&(t|=4),e.colorWriteMask[3]&&(t|=8),t}async createCubeTextureFromFiles(e,t,r,n,s){let i=[],a=0,u=0;for(let l=0;l<r;l++){let p=()=>new Promise((d,m)=>{let T=0,x=[],U=".jpg";s===S.HDR_LINEAR?U=".hdr":s===S.RGBE_PNG&&(U=".RGBE.PNG");let b="_right_",P="_left_",G="_top_",R="_bottom_",w="_front_",B="_back_";n&&(b="_posx_",P="_negx_",G="_posy_",R="_negy_",w="_posz_",B="_negz_");let A=[[t+b+l+U,"posX"],[t+P+l+U,"negX"],[t+G+l+U,"posY"],[t+R+l+U,"negY"],[t+w+l+U,"posZ"],[t+B+l+U,"negZ"]];for(let D=0;D<A.length;D++){let v=A[D][1],C;s===S.HDR_LINEAR||s===S.RGB9_E5_PNG?C=new K:C=new Image,C.hdriFormat=s,C.side=v,C.uri=A[D][0],C.crossOrigin="Anonymous",C.onload=()=>{T++,x.push(C),T===6&&d(x)},C.onerror=()=>{m(C.uri)},C.src=A[D][0]}}),f;try{f=await p()}catch{try{f=await p()}catch(m){L.default.error(`failed to load ${m}`)}}let h=[];for(let d of f)if(d.hdriFormat===S.HDR_LINEAR)h.push(d);else{await d.decode();let m=await createImageBitmap(d);h.push(m),m.side=d.side}let g={};for(let d of h){switch(d.side){case"posX":g.posX=d;break;case"posY":g.posY=d;break;case"posZ":g.posZ=d;break;case"negX":g.negX=d;break;case"negY":g.negY=d;break;case"negZ":g.negZ=d;break}l===0&&(a=d.width,u=d.height)}i.push(g)}let[o,c]=this.createCubeTexture(e,r,i,a,u);return[o,c,a,u]}createCubeTexture(e,t,r,n,s){var m;let i=[];for(let T=0;T<t;T++){let x=[];(r[T].posX instanceof ImageBitmap||r[0].posX instanceof HTMLCanvasElement)&&(x.push(r[T].posX),x.push(r[T].negX),x.push(r[T].posY),x.push(r[T].negY),x.push(r[T].posZ),x.push(r[T].negZ)),i.push(x)}let a=this.eU.gpuDevice,o=((m=i[0][0])==null?void 0:m.hdriFormat)===S.HDR_LINEAR?a.features.has("float32-filterable")?"rgba32float":"rgba16float":"rgba8unorm",c=a.createTexture({dimension:"2d",size:[n,s,6],format:o,mipLevelCount:t,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});for(let T=0;T<t;T++)for(let x=0;x<i[T].length;x++){let U=i[T][x];if(U.hdriFormat===S.HDR_LINEAR){let b=new Float32Array(U.width*U.height*4),P=U.dataFloat,G=U.width*U.height;for(let v=0;v<G;v++)b[v*4]=P[v*3],b[v*4+1]=P[v*3+1],b[v*4+2]=P[v*3+2],b[v*4+3]=1;let R=o==="rgba16float",w=oe(b,U.width,U.height,R),B=a.createBuffer({size:w.data.byteLength,usage:GPUBufferUsage.COPY_SRC,mappedAtCreation:!0});R?new Uint16Array(B.getMappedRange()).set(w.data):new Float32Array(B.getMappedRange()).set(w.data),B.unmap();let A=a.createCommandEncoder();A.copyBufferToTexture({buffer:B,bytesPerRow:w.bytesPerRow,rowsPerImage:U.height},{texture:c,origin:[0,0,x],mipLevel:T},[U.width,U.height,1]);let D=A.finish();a.queue.submit([D])}else a.queue.copyExternalImageToTexture({source:U},{texture:c,origin:[0,0,x],mipLevel:T},[U.width,U.height,1])}let l=this._A(c),p=V.Repeat,f=V.Repeat,h=t===1?V.Linear:V.LinearMipmapLinear,g=V.Linear,d=new se(e,{wrapS:p,wrapT:f,minFilter:h,magFilter:g,anisotropy:!1});return d.create(),[l,d]}createTextureArray(e,t,r,n,s,i,a,u){let o=this.eU.gpuDevice,c={size:[e,t,r],format:s.webgpu,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT,dimension:"2d",mipLevelCount:n},l=o.createTexture(c);if(!(u.buffer instanceof ArrayBuffer))throw new Error("SharedArrayBuffer is not supported in this code path.");let p=u instanceof Uint8ClampedArray?u:new Uint8ClampedArray(u.buffer,u.byteOffset,u.byteLength/Uint8ClampedArray.BYTES_PER_ELEMENT),f=e*4,h=p,g=f;if(t>1&&f%256!==0){g=Math.ceil(f/256)*256,h=new Uint8ClampedArray(g*t);for(let m=0;m<t;m++)h.set(p.subarray(m*f,(m+1)*f),m*g)}for(let m=0;m<r;m++)o.queue.writeTexture({texture:l,origin:[0,0,m]},h,{bytesPerRow:g,rowsPerImage:t},[e,t,1]);return this._A(l)}createStorageBuffer(e){let t=this.eU.gpuDevice,r=t.createBuffer({size:e.reduce((i,a)=>i+a.byteLength,0),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC}),n=0;for(let i=0;i<e.length;i++){let a=e[i],u=new Float32Array(a.getArrayBuffer());y.cU(u);let o=i===e.length-1?a.takenSizeInByte:a.byteLength;t.queue.writeBuffer(r,n,u,0,o/4),n+=o}return this.lU=r,this._A(r)}updateStorageBuffer(e,t,r=[]){let n=this.eU.gpuDevice,s=this.tU.get(e),i=0;for(let a=0;a<t.length;a++){let u=t[a],o=new Float32Array(u.getArrayBuffer());y.cU(o);let c=a===t.length-1?u.takenSizeInByte:u.byteLength;for(let[l,p]of te(i,i+c,r))n.queue.writeBuffer(s,l,o,(l-i)/4,(p-l)/4);i+=u.byteLength}}updateStorageBufferRanges(e,t,r){let n=this.eU.gpuDevice,s=this.tU.get(e);for(let[i,a]of r){let u=0;for(let o of t){let c=u+o.byteLength;if(i>=u&&a<=c){let l=new Float32Array(o.getArrayBuffer());n.queue.writeBuffer(s,i,l,(i-u)/4,(a-i)/4);break}u=c}}}_getStorageBuffer(){return this.lU}destroyStorageBuffer(e){let t=this.tU.get(e);t!=null&&(t.destroy(),this.tU.delete(e))}updateStorageBufferPartially(e,t,r,n,s){let i=this.eU.gpuDevice,a=this.tU.get(e);y.cU(t),i.queue.writeBuffer(a,r,t,n,s)}createStorageBlendShapeBuffer(e){let t=this.eU.gpuDevice,r=t.createBuffer({size:e.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE});return y.cU(e),t.queue.writeBuffer(r,0,e),this.gU=r,this._A(r)}deleteStorageBlendShapeBuffer(e){let t=this.tU.get(e);t!=null&&(t.destroy(),this.tU.delete(e))}updateStorageBlendShapeBuffer(e,t,r){let n=this.eU.gpuDevice,s=this.tU.get(e);y.cU(t),n.queue.writeBuffer(s,0,t,0,r)}createBindGroupLayoutForDrawParameters(){let e=this.eU.gpuDevice;{let t={entries:[{binding:0,buffer:{type:"uniform"},visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT}]},r=e.createBindGroupLayout(t);this.$U=r}}setDrawParameters(e,t,r,n,s=0){let i=this.MP;i[0]=e,i[1]=t,i[2]=r,i[3]=n;let a=`${e},${t},${r},${n},${s}`,u=this.VP.get(a);if(u==null){let o=this.eU.gpuDevice,c=y.Iw,l=Math.max(o.limits.minUniformBufferOffsetAlignment,y.YU),p=this.XU[this.XU.length-1];(p==null||this.kU>=c)&&(p=o.createBuffer({size:l*c,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM}),this.XU.push(p),this.kU=0);let f=l*this.kU++,h=y.Hw;h[0]=e,h[1]=t,h[2]=r,h[3]=n,h[4]=s,o.queue.writeBuffer(p,f,h),u=o.createBindGroup({layout:this.$U,entries:[{binding:0,resource:{buffer:p,offset:f,size:y.YU}}]}),this.VP.set(a,u)}this.FP=u}Yw(e){let t=this.MP;this.setDrawParameters(t[0],t[1],t[2],t[3],e)}createUniformMorphOffsetsBuffer(e){let r=this.eU.gpuDevice.createBuffer({size:e,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE});return this.oU=r,this._A(r)}updateUniformMorphOffsetsBuffer(e,t){let r=this.eU.gpuDevice;if(this.oU==null)throw new Error("Not found uniform morph buffer.");y.cU(e),r.queue.writeBuffer(this.oU,0,e,0,t)}createUniformMorphWeightsBuffer(e){let r=this.eU.gpuDevice.createBuffer({size:e,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE});return this.uU=r,this._A(r)}updateUniformMorphWeightsBuffer(e,t){let r=this.eU.gpuDevice;if(this.uU==null)throw new Error("Not found uniform morph buffer.");y.cU(e),r.queue.writeBuffer(this.uU,0,e,0,t)}deleteUniformBuffer(e){let t=this.tU.get(e);t!=null&&(t.destroy(),this.tU.delete(e))}Fw(e){let t=this.IP.get(e);return t===void 0&&(t=++this.Ow,this.IP.set(e,t)),t}BP(e,t){let r=this.AU.get(e);return r==null&&(r=this.eU.gpuDevice.createBindGroupLayout({entries:t}),this.AU.set(e,r)),r}jw(e,t){let r=this._P.get(e);r==null&&(r=new Map,this._P.set(e,r));let n=r.get(t);return n==null&&(n=t==="2d"?e.createView():e.createView({dimension:t}),r.set(t,n)),n}wP(){var t,r,n;let e=(t=this.nU)==null?void 0:t.deformedVerticesBuffer;return e!=null?e:((n=this[r="EP"])!=null||(this[r]=this.eU.gpuDevice.createBuffer({size:32,usage:GPUBufferUsage.STORAGE})),this.EP)}Zw(){var o,c;let e=this.LU;if(this.Gw!=null&&e[0]===this.lU&&e[1]===this.gU&&e[2]===this.oU&&e[3]===this.uU&&e[4]===this.wP())return this.Gw;e[0]=this.lU,e[1]=this.gU,e[2]=this.oU,e[3]=this.uU,e[4]=this.wP();let t=this.eU.gpuDevice,r=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,n=[],s=[],i="";this.lU!=null&&(n.push({binding:0,resource:{buffer:this.lU}}),s.push({binding:0,buffer:{type:"read-only-storage"},visibility:r}),i+="s");let a=this.gU;a==null&&((c=this[o="DP"])!=null||(this[o]=t.createBuffer({size:16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE})),a=this.DP),n.push({binding:1,resource:{buffer:a}}),s.push({binding:1,buffer:{type:"read-only-storage"},visibility:r}),i+="b",this.oU!=null&&(n.push({binding:2,resource:{buffer:this.oU}}),s.push({binding:2,buffer:{type:"uniform"},visibility:r}),i+="o"),this.uU!=null&&(n.push({binding:3,resource:{buffer:this.uU}}),s.push({binding:3,buffer:{type:"uniform"},visibility:r}),i+="w"),n.push({binding:4,resource:{buffer:e[4]}}),s.push({binding:4,buffer:{type:"read-only-storage"},visibility:GPUShaderStage.VERTEX}),i+="d",i=`storage:${i}`;let u=this.BP(i,s);return this.Gw=t.createBindGroup({layout:u,entries:n}),this.CP=u,this.AP=i,this.sU(),this.Gw}HU(e,t,r,n,s){let i=this.PU,a=i.count++;i.slots[a]=e,i.dimensions[a]=t,i.visibilities[a]=r,i.views[a]=n,i.samplers[a]=s}Jw(e,t,r,n,s){this.PU.count=0;let i=this.tU,a=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,u=e.dummyTextures;for(let g of t._autoTextureFieldVariablesOnly.values()){let d=g.info;if(d.semantic==="diffuseEnvTexture"||d.semantic==="specularEnvTexture"||d.semantic==="sheenEnvTexture"||!Z.isTexture(d.compositionType))continue;let m=g.value[0],T=g.value[1],x=g.value[2],U="2d";T instanceof re||T instanceof ie?U="cube":(T instanceof ae||T instanceof ne)&&(U="2d-array");let b=i.get(T._textureViewResourceUid);if(b==null){let G=U==="cube"?u.dummyBlackCubeTexture:u.dummyWhiteTexture,R=i.get(G._textureResourceUid);b=this.jw(R,U)}x.created||x.create();let P=i.get(x._samplerResourceUid);this.HU(m,U,a,b,P)}let o=u.dummyBlackCubeTexture,c=()=>i.get(o._textureViewResourceUid),l=()=>i.get(o._samplerResourceUid),p=t.getTextureParameter(M.DiffuseEnvTexture.str);if(E.exist(p)){let g=i.get(E.exist(r)?r._textureViewResourceUid:-1),d=i.get(E.exist(r)?r._samplerResourceUid:-1);this.HU(p[0],"cube",a,g!=null?g:c(),d!=null?d:l())}let f=t.getTextureParameter(M.SpecularEnvTexture.str);if(E.exist(f)){let g=i.get(E.exist(n)?n._textureViewResourceUid:-1),d=i.get(E.exist(n)?n._samplerResourceUid:-1);this.HU(f[0],"cube",a,g!=null?g:c(),d!=null?d:l())}let h=t.getTextureParameter(M.SheenEnvTexture.str);if(E.exist(h)){let g=E.exist(s)?s:n,d=E.exist(g)?i.get(g._textureViewResourceUid):void 0,m=E.exist(g)?i.get(g._samplerResourceUid):void 0;this.HU(h[0],"cube",GPUShaderStage.FRAGMENT,d!=null?d:c(),m!=null?m:l())}}Xw(e,t,r,n,s){let i=this.Zw();this.Jw(e,t,r,n,s);let a=this.PU,u="texture:",o="sampler:",c="",l="";for(let b=0;b<a.count;b++)u+=`${a.slots[b]}/${a.dimensions[b]}/${a.visibilities[b]},`,o+=`${a.slots[b]}/${a.visibilities[b]},`,c+=`${this.Fw(a.views[b])},`,l+=`${this.Fw(a.samplers[b])},`;let p=`${u}|${c}`,f=this.NU.get(p),h=this.Qw(u);if(f==null){let b=[];for(let P=0;P<a.count;P++)b.push({binding:a.slots[P],resource:a.views[P]});f=this.eU.gpuDevice.createBindGroup({layout:h,entries:b}),this.NU.set(p,f)}let g=`${o}|${l}`,d=this.zU.get(g),m=this.dB(o);if(d==null){let b=[];for(let P=0;P<a.count;P++)b.push({binding:a.slots[P],resource:a.samplers[P]});d=this.eU.gpuDevice.createBindGroup({layout:m,entries:b}),this.zU.set(g,d)}let T=`${this.AP}#${u}#${o}`,x=this.SP.get(T);x==null&&(x=this.eU.gpuDevice.createPipelineLayout({bindGroupLayouts:[this.CP,h,m,this.$U]}),this.SP.set(T,x));let U=this.HP;return U==null?(U={storage:i,texture:f,sampler:d,pipelineLayout:x,pipelineLayoutKey:T},this.HP=U):(U.storage=i,U.texture=f,U.sampler=d,U.pipelineLayout=x,U.pipelineLayoutKey=T),U}Qw(e){let t=this.AU.get(e);if(t!=null)return t;let r=this.PU,n=[];for(let s=0;s<r.count;s++)n.push({binding:r.slots[s],texture:{viewDimension:r.dimensions[s]},visibility:r.visibilities[s]});return this.BP(e,n)}dB(e){let t=this.AU.get(e);if(t!=null)return t;let r=this.PU,n=[];for(let s=0;s<r.count;s++)n.push({binding:r.slots[s],sampler:{type:"filtering"},visibility:r.visibilities[s]});return this.BP(e,n)}async createTextureFromHTMLImageElement(e,{internalFormat:t,width:r,height:n,generateMipmap:s}){e.crossOrigin="Anonymous",(!e.complete||e.naturalWidth===0)&&await new Promise((u,o)=>{e.onload=()=>u(),e.onerror=()=>o(new Error("Failed to load image"))}),await e.decode();let i=await createImageBitmap(e);return await this.JP(r,n,t,s,i)}createCompressedTextureFromBasis(e){let t,r,n=e.getNumLevels(0),s=e.getImageWidth(0,0),i=e.getImageHeight(0,0),a=this.eU.gpuDevice,u=this.eU.gpuAdapter,o=u.features.has("texture-compression-bc"),c=u.features.has("texture-compression-etc2"),l=u.features.has("texture-compression-astc");if(o?(t=W.BC3,r="bc3-rgba-unorm"):c?(t=W.ETC2,r="etc2-rgba8unorm"):l&&(t=W.ASTC,r="astc-4x4-unorm"),!r)throw console.warn("No supported compression format found, falling back to uncompressed"),new Error("No supported compression format found");let p={size:[s,i,1],format:r,mipLevelCount:n,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST},f=a.createTexture(p),h={byteSize:16,width:4,height:4};r==="bc1-rgba-unorm"?h={byteSize:8,width:4,height:4}:r==="bc3-rgba-unorm"||r==="astc-4x4-unorm"?h={byteSize:16,width:4,height:4}:r==="etc2-rgba8unorm"?h={byteSize:16,width:4,height:4}:r==="etc2-rgb8unorm"&&(h={byteSize:8,width:4,height:4});for(let d=0;d<n;d++){let m=e.getImageWidth(0,d),T=e.getImageHeight(0,d),x=this.decodeBasisImage(e,t,0,d),U=Math.max(1,Math.ceil(m/h.width)),b=Math.max(1,Math.ceil(T/h.height)),P=U*h.byteSize,G=Math.ceil(P/256)*256,R,w=G*b;if(G!==P||x.length<w){let B=new Uint8Array(w);if(x.length>0){let A=Math.floor(x.length/P);for(let D=0;D<Math.min(b,A);D++){let v=D*P,C=D*G,O=Math.min(P,x.length-v);O>0&&B.set(x.subarray(v,v+O),C)}}R=B}else R=x;y.cU(R),a.queue.writeTexture({texture:f,mipLevel:d},R,{offset:0,bytesPerRow:G,rowsPerImage:b},{width:Math.ceil(m/h.width)*h.width,height:Math.ceil(T/h.height)*h.height})}return this._A(f)}decodeBasisImage(e,t,r,n){let s=e.getImageTranscodedSizeInBytes(r,n,t.index),i=new Uint8Array(s);return e.transcodeImage(i,r,n,t.index,0,0)||L.default.error("failed to transcode the image."),i}async createCompressedTexture(e,t){let r=this.eU.gpuDevice,n=t.blockInfo||{byteSize:4,width:1,height:1},s=e[0],i={size:[Math.ceil(s.width/n.width)*n.width,Math.ceil(s.height/n.height)*n.height,1],format:t.webgpu,mipLevelCount:e.length,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST},a=r.createTexture(i);for(let o=0;o<e.length;o++){let c=e[o],l=c.width,p=c.height,f=Math.max(1,Math.ceil(l/n.width)),h=Math.max(1,Math.ceil(p/n.height)),g=f*n.byteSize,d=Math.ceil(g/256)*256,m=c.buffer instanceof Uint8Array?c.buffer:new Uint8Array(c.buffer.buffer,c.buffer.byteOffset,c.buffer.byteLength),T,x=d*h;if(d!==g||m.length<x){let U=new Uint8Array(x);if(m.length>0){let b=Math.floor(m.length/g);for(let P=0;P<Math.min(h,b);P++){let G=P*g,R=P*d,w=Math.min(g,m.length-G);w>0&&U.set(m.subarray(G,G+w),R)}}T=U}else T=m;y.cU(T),r.queue.writeTexture({texture:a,mipLevel:o},T,{offset:0,bytesPerRow:d,rowsPerImage:h},{width:Math.ceil(l/n.width)*n.width,height:Math.ceil(p/n.height)*n.height})}return await r.queue.onSubmittedWorkDone(),this._A(a)}allocateTexture({format:e,width:t,height:r,mipLevelCount:n}){let s=this.eU.gpuDevice,i={size:[t,r,1],mipLevelCount:n,format:e.webgpu,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=s.createTexture(i);return this._A(a)}async loadImageToMipLevelOfTexture2D({mipLevel:e,textureUid:t,format:r,type:n,xOffset:s,yOffset:i,width:a,height:u,rowSizeByPixel:o,data:c}){let l=this.eU.gpuDevice,p=this.tU.get(t),f=Q.getPixelFormatFromTextureFormat(r),h=J.getCompositionNumFromPixelFormat(f),g=o*h*n.getSizeInBytes(),d=Math.ceil(g/256)*256,m=new Uint8Array(d*u);for(let b=0;b<u;b++){let P=b*g,G=b*d;m.set(new Uint8Array(c.buffer,P,g),G)}let T=l.createBuffer({size:m.byteLength,usage:GPUBufferUsage.COPY_SRC,mappedAtCreation:!0});new Uint8Array(T.getMappedRange()).set(m),T.unmap();let x=l.createCommandEncoder();x.copyBufferToTexture({buffer:T,offset:0,bytesPerRow:d,rowsPerImage:u},{texture:p,mipLevel:e,origin:{x:s,y:i,z:0}},{width:a,height:u,depthOrArrayLayers:1});let U=x.finish();l.queue.submit([U]);try{await l.queue.onSubmittedWorkDone()}catch(b){L.default.error(b)}}async JP(e,t,r,n,s){let i=this.eU.gpuDevice,a={size:[e,t,1],format:r.webgpu,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT};n&&(a.mipLevelCount=Math.floor(Math.log2(Math.max(e,t)))+1);let u=i.createTexture(a);return i.queue.copyExternalImageToTexture({source:s},{texture:u},[e,t]),n&&this.generateMipmaps(u,a),await i.queue.onSubmittedWorkDone(),this._A(u)}createRenderTargetTexture({width:e,height:t,mipLevelCount:r,format:n}){let s=this.eU.gpuDevice,i={size:[e,t,1],format:n.webgpu,mipLevelCount:r,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=s.createTexture(i);return this._A(a)}createRenderTargetTextureArray({width:e,height:t,internalFormat:r,arrayLength:n}){let s=this.eU.gpuDevice,i={dimension:"2d",size:[e,t,n],format:r.webgpu,mipLevelCount:1,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=s.createTexture(i);return this._A(a)}createRenderTargetTextureCube({width:e,height:t,mipLevelCount:r,format:n}){let s=this.eU.gpuDevice,i={dimension:"2d",size:[e,t,6],format:n.webgpu,mipLevelCount:r,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=s.createTexture(i);return this._A(a)}createRenderBuffer(e,t,r,n,s){let i=this.eU.gpuDevice,a={size:[e,t,1],format:r.webgpu,sampleCount:n?s:1,usage:GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT},u=i.createTexture(a);return this._A(u)}deleteRenderBuffer(e){this.flush(),this.clearCache();let t=this.tU.get(e);t!=null&&(t.destroy(),this.tU.delete(e))}copyTextureData(e,t){let r=this.tU.get(e),n=this.tU.get(t);this.UU(),this.aU.copyTextureToTexture({texture:r},{texture:n},[n.width,n.height,1])}isMippmappedTexture(e){return this.tU.get(e).mipLevelCount>1}duplicateTextureAsMipmapped(e){let t=this.eU.gpuDevice,r=this.tU.get(e),n={size:{width:r.width,height:r.height,depthOrArrayLayers:r.depthOrArrayLayers},mipLevelCount:Math.floor(Math.log2(Math.max(r.width,r.height)))+1,format:r.format,usage:r.usage},s=t.createTexture(n);this.UU(),this.aU.copyTextureToTexture({texture:r},{texture:s},{width:r.width,height:r.height,depthOrArrayLayers:1});let i=this._A(s),a=this._A(s.createView());return[i,a]}attachDepthBufferToFrameBufferObject(e,t){}attachStencilBufferToFrameBufferObject(e,t){}attachDepthStencilBufferToFrameBufferObject(e,t){}createFrameBufferObject(){return-1}deleteFrameBufferObject(e){}attachColorBufferToFrameBufferObject(e,t,r){}attachColorBufferLayerToFrameBufferObject(e,t,r,n,s){}attachColorBufferCubeToFrameBufferObject(e,t,r,n,s){}createTextureView2d(e){let r=this.tU.get(e).createView();return this._A(r)}createTextureViewAsRenderTarget(e){let r=this.tU.get(e).createView({baseMipLevel:0,mipLevelCount:1,arrayLayerCount:1});return this._A(r)}createTextureViewCube(e){let r=this.tU.get(e).createView({dimension:"cube"});return this._A(r)}createTextureView2dArray(e,t){let n=this.tU.get(e).createView({dimension:"2d-array",baseArrayLayer:0,arrayLayerCount:t});return this._A(n)}createTextureView2dArrayAsRenderTarget(e,t,r){let s=this.tU.get(e).createView({dimension:"2d",arrayLayerCount:1,baseArrayLayer:t,baseMipLevel:r,mipLevelCount:1,aspect:"all"});return this._A(s)}createCubeTextureViewAsRenderTarget(e,t,r){let s=this.tU.get(e).createView({dimension:"2d",arrayLayerCount:1,baseArrayLayer:t,baseMipLevel:r,mipLevelCount:1,aspect:"all"});return this._A(s)}deleteTexture(e){this.flush(),this.clearCache();let t=this.tU.get(e);t!=null&&(this.wU.delete(t),this.hU.delete(t),this.mU.delete(t),t.destroy(),this.tU.delete(e))}recreateSystemDepthTexture(){let e=this.eU.gpuDevice,t=this.eU.canvas;if(this.bU!=null&&this.bU.destroy(),this.SU=void 0,t.width<=0||t.height<=0){L.default.warn("Skip recreating system depth texture because the canvas size is zero.");return}this.bU=e.createTexture({size:[t.width,t.height],format:N,usage:GPUTextureUsage.RENDER_ATTACHMENT}),this.dU=this.bU.createView()}resizeCanvas(e,t){if(e<=0||t<=0){L.default.warn("Skip resizing WebGPU canvas because width or height is zero.");return}let r=this.eU.canvas;r.width=e,r.height=t,this.recreateSystemDepthTexture()}setViewport(e,t){}isSupportMultiViewVRRendering(){return!1}};y.Iw=1024,y.YU=32,y.Hw=new Uint32Array(y.YU/4),y.Ww=new Set(["unorm8x2","unorm8x4","snorm8x2","snorm8x4","unorm16x2","unorm16x4","snorm16x2","snorm16x4"]);var q=y;export{q as WebGpuResourceRepository};
|
|
116
|
+
`})),this.JU}getOrCreateRenderPipeline(e,t,r,n,s,i,a,u={}){var w,B;let o=(w=u.depthOnly)!=null?w:!1,c=(B=u.allowEqualDepth)!=null?B:!1,l=`${e}|${t}|${o?"depthOnly":"color"}|${c?"equal":"less"}`,p=this.OU.get(l);if(p!=null&&this.WU.get(l)===s.pipelineStateVersion)return[p,!1];let f=this.eU.gpuDevice,h=navigator.gpu.getPreferredCanvasFormat(),g=this.tU.get(s.getShaderProgramUid(n));g!=null&&new Error("Shader Modules is not found");let d=[];i.isBufferLessRenderingMode()||d.push({stepMode:"instance",attributes:[{shaderLocation:F.Instance.getAttributeSlot(),offset:0,format:"uint32x4"}],arrayStride:16}),n.attributeAccessors.forEach((A,D)=>{let C={shaderLocation:F.toAttributeSlotFromJoinedString(n.attributeSemantics[D]),offset:0,format:y.QP(A)};d.push({stepMode:"vertex",arrayStride:n.attributeAccessors[D].actualByteStride,attributes:[C]})});let m;s.isBlend()&&s.alphaMode===j.Blend&&(m={color:{srcFactor:s.blendFuncSrcFactor.webgpu,dstFactor:s.blendFuncDstFactor.webgpu,operation:s.blendEquationMode.webgpu},alpha:{srcFactor:s.blendFuncAlphaSrcFactor.webgpu,dstFactor:s.blendFuncAlphaDstFactor.webgpu,operation:s.blendEquationModeAlpha.webgpu}});let x=(i.isBufferLessRenderingMode()?i._primitiveModeForBufferLessRendering:n.primitiveMode).getWebGPUTypeStr(),U;n.hasIndices()&&(x==="triangle-strip"||x==="line-strip")&&(U=n.getIndexBitSize());let b=i.getFramebuffer(),P=[{format:h,blend:m}],G=N;if(b!=null){P=[];for(let A of b.colorAttachments){let D=this.tU.get(A._textureResourceUid);P.push({format:D.format,blend:m,writeMask:this.setColorWriteMask(s)})}b.depthAttachment!=null?G=this.tU.get(b.depthAttachment._textureResourceUid).format:G=void 0}let R=f.createRenderPipeline({layout:r,vertex:{module:g.vsModule,entryPoint:"main",buffers:d},fragment:{module:o?this.Zw():g.fsModule,entryPoint:"main",targets:o?P.map(A=>({format:A.format,writeMask:0})):P},primitive:{topology:x,stripIndexFormat:U,frontFace:s.cullFrontFaceCCW?"ccw":"cw",cullMode:s.cullFace?s.cullFaceBack?"back":"front":"none"},depthStencil:G==null?void 0:{depthWriteEnabled:o?!0:a,depthCompare:o||c?"less-equal":i.isDepthTest?"less":"always",format:G},multisample:{count:i.getResolveFramebuffer()!=null?i.getFramebuffer().colorAttachments[0].sampleCount:1}});return this.OU.set(l,R),this.WU.set(l,s.pipelineStateVersion),[R,!0]}flush(){let e=this.eU.gpuDevice,t=this.pU;t.active&&!t.isColorClear&&t.targetKind===$&&t.targetViews[t.targetViews.length-1]===this.dU&&(this.SU=t.clearDepth,this.RP()),this.UU();let r=this.GU,n=this.nU,s=n==null?void 0:n.encode(this.lU,r,{blendShapeData:this.gU,morphOffsets:this.oU,morphWeights:this.uU});r==null||r.encodeResolve(this.aU);let i=this.aU.finish();this.WP.submit(s!=null?[s,i]:[i]),r==null||r.afterSubmit(),this.aU=e.createCommandEncoder(),n!=null&&n.afterSubmit()&&(this.sU(),this.ZU=!0),this.MU!=null&&(this.MU=void 0)}setColorWriteMask(e){let t=0;return e.colorWriteMask[0]&&(t|=1),e.colorWriteMask[1]&&(t|=2),e.colorWriteMask[2]&&(t|=4),e.colorWriteMask[3]&&(t|=8),t}async createCubeTextureFromFiles(e,t,r,n,s){let i=[],a=0,u=0;for(let l=0;l<r;l++){let p=()=>new Promise((d,m)=>{let T=0,x=[],U=".jpg";s===S.HDR_LINEAR?U=".hdr":s===S.RGBE_PNG&&(U=".RGBE.PNG");let b="_right_",P="_left_",G="_top_",R="_bottom_",w="_front_",B="_back_";n&&(b="_posx_",P="_negx_",G="_posy_",R="_negy_",w="_posz_",B="_negz_");let A=[[t+b+l+U,"posX"],[t+P+l+U,"negX"],[t+G+l+U,"posY"],[t+R+l+U,"negY"],[t+w+l+U,"posZ"],[t+B+l+U,"negZ"]];for(let D=0;D<A.length;D++){let v=A[D][1],C;s===S.HDR_LINEAR||s===S.RGB9_E5_PNG?C=new K:C=new Image,C.hdriFormat=s,C.side=v,C.uri=A[D][0],C.crossOrigin="Anonymous",C.onload=()=>{T++,x.push(C),T===6&&d(x)},C.onerror=()=>{m(C.uri)},C.src=A[D][0]}}),f;try{f=await p()}catch{try{f=await p()}catch(m){L.default.error(`failed to load ${m}`)}}let h=[];for(let d of f)if(d.hdriFormat===S.HDR_LINEAR)h.push(d);else{await d.decode();let m=await createImageBitmap(d);h.push(m),m.side=d.side}let g={};for(let d of h){switch(d.side){case"posX":g.posX=d;break;case"posY":g.posY=d;break;case"posZ":g.posZ=d;break;case"negX":g.negX=d;break;case"negY":g.negY=d;break;case"negZ":g.negZ=d;break}l===0&&(a=d.width,u=d.height)}i.push(g)}let[o,c]=this.createCubeTexture(e,r,i,a,u);return[o,c,a,u]}createCubeTexture(e,t,r,n,s){var m;let i=[];for(let T=0;T<t;T++){let x=[];(r[T].posX instanceof ImageBitmap||r[0].posX instanceof HTMLCanvasElement)&&(x.push(r[T].posX),x.push(r[T].negX),x.push(r[T].posY),x.push(r[T].negY),x.push(r[T].posZ),x.push(r[T].negZ)),i.push(x)}let a=this.eU.gpuDevice,o=((m=i[0][0])==null?void 0:m.hdriFormat)===S.HDR_LINEAR?a.features.has("float32-filterable")?"rgba32float":"rgba16float":"rgba8unorm",c=a.createTexture({dimension:"2d",size:[n,s,6],format:o,mipLevelCount:t,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});for(let T=0;T<t;T++)for(let x=0;x<i[T].length;x++){let U=i[T][x];if(U.hdriFormat===S.HDR_LINEAR){let b=new Float32Array(U.width*U.height*4),P=U.dataFloat,G=U.width*U.height;for(let v=0;v<G;v++)b[v*4]=P[v*3],b[v*4+1]=P[v*3+1],b[v*4+2]=P[v*3+2],b[v*4+3]=1;let R=o==="rgba16float",w=oe(b,U.width,U.height,R),B=a.createBuffer({size:w.data.byteLength,usage:GPUBufferUsage.COPY_SRC,mappedAtCreation:!0});R?new Uint16Array(B.getMappedRange()).set(w.data):new Float32Array(B.getMappedRange()).set(w.data),B.unmap();let A=a.createCommandEncoder();A.copyBufferToTexture({buffer:B,bytesPerRow:w.bytesPerRow,rowsPerImage:U.height},{texture:c,origin:[0,0,x],mipLevel:T},[U.width,U.height,1]);let D=A.finish();a.queue.submit([D])}else a.queue.copyExternalImageToTexture({source:U},{texture:c,origin:[0,0,x],mipLevel:T},[U.width,U.height,1])}let l=this._A(c),p=V.Repeat,f=V.Repeat,h=t===1?V.Linear:V.LinearMipmapLinear,g=V.Linear,d=new se(e,{wrapS:p,wrapT:f,minFilter:h,magFilter:g,anisotropy:!1});return d.create(),[l,d]}createTextureArray(e,t,r,n,s,i,a,u){let o=this.eU.gpuDevice,c={size:[e,t,r],format:s.webgpu,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT,dimension:"2d",mipLevelCount:n},l=o.createTexture(c);if(!(u.buffer instanceof ArrayBuffer))throw new Error("SharedArrayBuffer is not supported in this code path.");let p=u instanceof Uint8ClampedArray?u:new Uint8ClampedArray(u.buffer,u.byteOffset,u.byteLength/Uint8ClampedArray.BYTES_PER_ELEMENT),f=e*4,h=p,g=f;if(t>1&&f%256!==0){g=Math.ceil(f/256)*256,h=new Uint8ClampedArray(g*t);for(let m=0;m<t;m++)h.set(p.subarray(m*f,(m+1)*f),m*g)}for(let m=0;m<r;m++)o.queue.writeTexture({texture:l,origin:[0,0,m]},h,{bytesPerRow:g,rowsPerImage:t},[e,t,1]);return this._A(l)}createStorageBuffer(e){let t=this.eU.gpuDevice,r=t.createBuffer({size:e.reduce((i,a)=>i+a.byteLength,0),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC}),n=0;for(let i=0;i<e.length;i++){let a=e[i],u=new Float32Array(a.getArrayBuffer());y.cU(u);let o=i===e.length-1?a.takenSizeInByte:a.byteLength;t.queue.writeBuffer(r,n,u,0,o/4),n+=o}return this.lU=r,this._A(r)}updateStorageBuffer(e,t,r=[]){let n=this.eU.gpuDevice,s=this.tU.get(e),i=0;for(let a=0;a<t.length;a++){let u=t[a],o=new Float32Array(u.getArrayBuffer());y.cU(o);let c=a===t.length-1?u.takenSizeInByte:u.byteLength;for(let[l,p]of te(i,i+c,r))n.queue.writeBuffer(s,l,o,(l-i)/4,(p-l)/4);i+=u.byteLength}}updateStorageBufferRanges(e,t,r){let n=this.eU.gpuDevice,s=this.tU.get(e);for(let[i,a]of r){let u=0;for(let o of t){let c=u+o.byteLength;if(i>=u&&a<=c){let l=new Float32Array(o.getArrayBuffer());n.queue.writeBuffer(s,i,l,(i-u)/4,(a-i)/4);break}u=c}}}_getStorageBuffer(){return this.lU}destroyStorageBuffer(e){let t=this.tU.get(e);t!=null&&(t.destroy(),this.tU.delete(e))}updateStorageBufferPartially(e,t,r,n,s){let i=this.eU.gpuDevice,a=this.tU.get(e);y.cU(t),i.queue.writeBuffer(a,r,t,n,s)}createStorageBlendShapeBuffer(e){let t=this.eU.gpuDevice,r=t.createBuffer({size:e.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE});return y.cU(e),t.queue.writeBuffer(r,0,e),this.gU=r,this._A(r)}deleteStorageBlendShapeBuffer(e){let t=this.tU.get(e);t!=null&&(t.destroy(),this.tU.delete(e))}updateStorageBlendShapeBuffer(e,t,r){let n=this.eU.gpuDevice,s=this.tU.get(e);y.cU(t),n.queue.writeBuffer(s,0,t,0,r)}createBindGroupLayoutForDrawParameters(){let e=this.eU.gpuDevice;{let t={entries:[{binding:0,buffer:{type:"uniform"},visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT}]},r=e.createBindGroupLayout(t);this.$U=r}}setDrawParameters(e,t,r,n,s=0){let i=this.MP;i[0]=e,i[1]=t,i[2]=r,i[3]=n;let a=`${e},${t},${r},${n},${s}`,u=this.VP.get(a);if(u==null){let o=this.eU.gpuDevice,c=y.Ow,l=Math.max(o.limits.minUniformBufferOffsetAlignment,y.YU),p=this.XU[this.XU.length-1];(p==null||this.kU>=c)&&(p=o.createBuffer({size:l*c,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM}),this.XU.push(p),this.kU=0);let f=l*this.kU++,h=y.Ww;h[0]=e,h[1]=t,h[2]=r,h[3]=n,h[4]=s,o.queue.writeBuffer(p,f,h),u=o.createBindGroup({layout:this.$U,entries:[{binding:0,resource:{buffer:p,offset:f,size:y.YU}}]}),this.VP.set(a,u)}this.FP=u}qw(e){let t=this.MP;this.setDrawParameters(t[0],t[1],t[2],t[3],e)}createUniformMorphOffsetsBuffer(e){let r=this.eU.gpuDevice.createBuffer({size:e,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE});return this.oU=r,this._A(r)}updateUniformMorphOffsetsBuffer(e,t){let r=this.eU.gpuDevice;if(this.oU==null)throw new Error("Not found uniform morph buffer.");y.cU(e),r.queue.writeBuffer(this.oU,0,e,0,t)}createUniformMorphWeightsBuffer(e){let r=this.eU.gpuDevice.createBuffer({size:e,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE});return this.uU=r,this._A(r)}updateUniformMorphWeightsBuffer(e,t){let r=this.eU.gpuDevice;if(this.uU==null)throw new Error("Not found uniform morph buffer.");y.cU(e),r.queue.writeBuffer(this.uU,0,e,0,t)}deleteUniformBuffer(e){let t=this.tU.get(e);t!=null&&(t.destroy(),this.tU.delete(e))}Hw(e){let t=this.IP.get(e);return t===void 0&&(t=++this.Nw,this.IP.set(e,t)),t}BP(e,t){let r=this.AU.get(e);return r==null&&(r=this.eU.gpuDevice.createBindGroupLayout({entries:t}),this.AU.set(e,r)),r}Jw(e,t){let r=this._P.get(e);r==null&&(r=new Map,this._P.set(e,r));let n=r.get(t);return n==null&&(n=t==="2d"?e.createView():e.createView({dimension:t}),r.set(t,n)),n}wP(){var t,r,n;let e=(t=this.nU)==null?void 0:t.deformedVerticesBuffer;return e!=null?e:((n=this[r="EP"])!=null||(this[r]=this.eU.gpuDevice.createBuffer({size:32,usage:GPUBufferUsage.STORAGE})),this.EP)}Qw(){var o,c;let e=this.LU;if(this.Gw!=null&&e[0]===this.lU&&e[1]===this.gU&&e[2]===this.oU&&e[3]===this.uU&&e[4]===this.wP())return this.Gw;e[0]=this.lU,e[1]=this.gU,e[2]=this.oU,e[3]=this.uU,e[4]=this.wP();let t=this.eU.gpuDevice,r=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,n=[],s=[],i="";this.lU!=null&&(n.push({binding:0,resource:{buffer:this.lU}}),s.push({binding:0,buffer:{type:"read-only-storage"},visibility:r}),i+="s");let a=this.gU;a==null&&((c=this[o="DP"])!=null||(this[o]=t.createBuffer({size:16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE})),a=this.DP),n.push({binding:1,resource:{buffer:a}}),s.push({binding:1,buffer:{type:"read-only-storage"},visibility:r}),i+="b",this.oU!=null&&(n.push({binding:2,resource:{buffer:this.oU}}),s.push({binding:2,buffer:{type:"uniform"},visibility:r}),i+="o"),this.uU!=null&&(n.push({binding:3,resource:{buffer:this.uU}}),s.push({binding:3,buffer:{type:"uniform"},visibility:r}),i+="w"),n.push({binding:4,resource:{buffer:e[4]}}),s.push({binding:4,buffer:{type:"read-only-storage"},visibility:GPUShaderStage.VERTEX}),i+="d",i=`storage:${i}`;let u=this.BP(i,s);return this.Gw=t.createBindGroup({layout:u,entries:n}),this.CP=u,this.AP=i,this.sU(),this.Gw}HU(e,t,r,n,s){let i=this.PU,a=i.count++;i.slots[a]=e,i.dimensions[a]=t,i.visibilities[a]=r,i.views[a]=n,i.samplers[a]=s}UB(e,t,r,n,s){this.PU.count=0;let i=this.tU,a=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,u=e.dummyTextures;for(let g of t._autoTextureFieldVariablesOnly.values()){let d=g.info;if(d.semantic==="diffuseEnvTexture"||d.semantic==="specularEnvTexture"||d.semantic==="sheenEnvTexture"||!Z.isTexture(d.compositionType))continue;let m=g.value[0],T=g.value[1],x=g.value[2],U="2d";T instanceof re||T instanceof ie?U="cube":(T instanceof ae||T instanceof ne)&&(U="2d-array");let b=i.get(T._textureViewResourceUid);if(b==null){let G=U==="cube"?u.dummyBlackCubeTexture:u.dummyWhiteTexture,R=i.get(G._textureResourceUid);b=this.Jw(R,U)}x.created||x.create();let P=i.get(x._samplerResourceUid);this.HU(m,U,a,b,P)}let o=u.dummyBlackCubeTexture,c=()=>i.get(o._textureViewResourceUid),l=()=>i.get(o._samplerResourceUid),p=t.getTextureParameter(M.DiffuseEnvTexture.str);if(E.exist(p)){let g=i.get(E.exist(r)?r._textureViewResourceUid:-1),d=i.get(E.exist(r)?r._samplerResourceUid:-1);this.HU(p[0],"cube",a,g!=null?g:c(),d!=null?d:l())}let f=t.getTextureParameter(M.SpecularEnvTexture.str);if(E.exist(f)){let g=i.get(E.exist(n)?n._textureViewResourceUid:-1),d=i.get(E.exist(n)?n._samplerResourceUid:-1);this.HU(f[0],"cube",a,g!=null?g:c(),d!=null?d:l())}let h=t.getTextureParameter(M.SheenEnvTexture.str);if(E.exist(h)){let g=E.exist(s)?s:n,d=E.exist(g)?i.get(g._textureViewResourceUid):void 0,m=E.exist(g)?i.get(g._samplerResourceUid):void 0;this.HU(h[0],"cube",GPUShaderStage.FRAGMENT,d!=null?d:c(),m!=null?m:l())}}Yw(e,t,r,n,s){let i=this.Qw();this.UB(e,t,r,n,s);let a=this.PU,u="texture:",o="sampler:",c="",l="";for(let b=0;b<a.count;b++)u+=`${a.slots[b]}/${a.dimensions[b]}/${a.visibilities[b]},`,o+=`${a.slots[b]}/${a.visibilities[b]},`,c+=`${this.Hw(a.views[b])},`,l+=`${this.Hw(a.samplers[b])},`;let p=`${u}|${c}`,f=this.NU.get(p),h=this.PB(u);if(f==null){let b=[];for(let P=0;P<a.count;P++)b.push({binding:a.slots[P],resource:a.views[P]});f=this.eU.gpuDevice.createBindGroup({layout:h,entries:b}),this.NU.set(p,f)}let g=`${o}|${l}`,d=this.zU.get(g),m=this.yB(o);if(d==null){let b=[];for(let P=0;P<a.count;P++)b.push({binding:a.slots[P],resource:a.samplers[P]});d=this.eU.gpuDevice.createBindGroup({layout:m,entries:b}),this.zU.set(g,d)}let T=`${this.AP}#${u}#${o}`,x=this.SP.get(T);x==null&&(x=this.eU.gpuDevice.createPipelineLayout({bindGroupLayouts:[this.CP,h,m,this.$U]}),this.SP.set(T,x));let U=this.HP;return U==null?(U={storage:i,texture:f,sampler:d,pipelineLayout:x,pipelineLayoutKey:T},this.HP=U):(U.storage=i,U.texture=f,U.sampler=d,U.pipelineLayout=x,U.pipelineLayoutKey=T),U}PB(e){let t=this.AU.get(e);if(t!=null)return t;let r=this.PU,n=[];for(let s=0;s<r.count;s++)n.push({binding:r.slots[s],texture:{viewDimension:r.dimensions[s]},visibility:r.visibilities[s]});return this.BP(e,n)}yB(e){let t=this.AU.get(e);if(t!=null)return t;let r=this.PU,n=[];for(let s=0;s<r.count;s++)n.push({binding:r.slots[s],sampler:{type:"filtering"},visibility:r.visibilities[s]});return this.BP(e,n)}async createTextureFromHTMLImageElement(e,{internalFormat:t,width:r,height:n,generateMipmap:s}){e.crossOrigin="Anonymous",(!e.complete||e.naturalWidth===0)&&await new Promise((u,o)=>{e.onload=()=>u(),e.onerror=()=>o(new Error("Failed to load image"))}),await e.decode();let i=await createImageBitmap(e);return await this.JP(r,n,t,s,i)}createCompressedTextureFromBasis(e){let t,r,n=e.getNumLevels(0),s=e.getImageWidth(0,0),i=e.getImageHeight(0,0),a=this.eU.gpuDevice,u=this.eU.gpuAdapter,o=u.features.has("texture-compression-bc"),c=u.features.has("texture-compression-etc2"),l=u.features.has("texture-compression-astc");if(o?(t=W.BC3,r="bc3-rgba-unorm"):c?(t=W.ETC2,r="etc2-rgba8unorm"):l&&(t=W.ASTC,r="astc-4x4-unorm"),!r)throw console.warn("No supported compression format found, falling back to uncompressed"),new Error("No supported compression format found");let p={size:[s,i,1],format:r,mipLevelCount:n,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST},f=a.createTexture(p),h={byteSize:16,width:4,height:4};r==="bc1-rgba-unorm"?h={byteSize:8,width:4,height:4}:r==="bc3-rgba-unorm"||r==="astc-4x4-unorm"?h={byteSize:16,width:4,height:4}:r==="etc2-rgba8unorm"?h={byteSize:16,width:4,height:4}:r==="etc2-rgb8unorm"&&(h={byteSize:8,width:4,height:4});for(let d=0;d<n;d++){let m=e.getImageWidth(0,d),T=e.getImageHeight(0,d),x=this.decodeBasisImage(e,t,0,d),U=Math.max(1,Math.ceil(m/h.width)),b=Math.max(1,Math.ceil(T/h.height)),P=U*h.byteSize,G=Math.ceil(P/256)*256,R,w=G*b;if(G!==P||x.length<w){let B=new Uint8Array(w);if(x.length>0){let A=Math.floor(x.length/P);for(let D=0;D<Math.min(b,A);D++){let v=D*P,C=D*G,O=Math.min(P,x.length-v);O>0&&B.set(x.subarray(v,v+O),C)}}R=B}else R=x;y.cU(R),a.queue.writeTexture({texture:f,mipLevel:d},R,{offset:0,bytesPerRow:G,rowsPerImage:b},{width:Math.ceil(m/h.width)*h.width,height:Math.ceil(T/h.height)*h.height})}return this._A(f)}decodeBasisImage(e,t,r,n){let s=e.getImageTranscodedSizeInBytes(r,n,t.index),i=new Uint8Array(s);return e.transcodeImage(i,r,n,t.index,0,0)||L.default.error("failed to transcode the image."),i}async createCompressedTexture(e,t){let r=this.eU.gpuDevice,n=t.blockInfo||{byteSize:4,width:1,height:1},s=e[0],i={size:[Math.ceil(s.width/n.width)*n.width,Math.ceil(s.height/n.height)*n.height,1],format:t.webgpu,mipLevelCount:e.length,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST},a=r.createTexture(i);for(let o=0;o<e.length;o++){let c=e[o],l=c.width,p=c.height,f=Math.max(1,Math.ceil(l/n.width)),h=Math.max(1,Math.ceil(p/n.height)),g=f*n.byteSize,d=Math.ceil(g/256)*256,m=c.buffer instanceof Uint8Array?c.buffer:new Uint8Array(c.buffer.buffer,c.buffer.byteOffset,c.buffer.byteLength),T,x=d*h;if(d!==g||m.length<x){let U=new Uint8Array(x);if(m.length>0){let b=Math.floor(m.length/g);for(let P=0;P<Math.min(h,b);P++){let G=P*g,R=P*d,w=Math.min(g,m.length-G);w>0&&U.set(m.subarray(G,G+w),R)}}T=U}else T=m;y.cU(T),r.queue.writeTexture({texture:a,mipLevel:o},T,{offset:0,bytesPerRow:d,rowsPerImage:h},{width:Math.ceil(l/n.width)*n.width,height:Math.ceil(p/n.height)*n.height})}return await r.queue.onSubmittedWorkDone(),this._A(a)}allocateTexture({format:e,width:t,height:r,mipLevelCount:n}){let s=this.eU.gpuDevice,i={size:[t,r,1],mipLevelCount:n,format:e.webgpu,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=s.createTexture(i);return this._A(a)}async loadImageToMipLevelOfTexture2D({mipLevel:e,textureUid:t,format:r,type:n,xOffset:s,yOffset:i,width:a,height:u,rowSizeByPixel:o,data:c}){let l=this.eU.gpuDevice,p=this.tU.get(t),f=Q.getPixelFormatFromTextureFormat(r),h=J.getCompositionNumFromPixelFormat(f),g=o*h*n.getSizeInBytes(),d=Math.ceil(g/256)*256,m=new Uint8Array(d*u);for(let b=0;b<u;b++){let P=b*g,G=b*d;m.set(new Uint8Array(c.buffer,P,g),G)}let T=l.createBuffer({size:m.byteLength,usage:GPUBufferUsage.COPY_SRC,mappedAtCreation:!0});new Uint8Array(T.getMappedRange()).set(m),T.unmap();let x=l.createCommandEncoder();x.copyBufferToTexture({buffer:T,offset:0,bytesPerRow:d,rowsPerImage:u},{texture:p,mipLevel:e,origin:{x:s,y:i,z:0}},{width:a,height:u,depthOrArrayLayers:1});let U=x.finish();l.queue.submit([U]);try{await l.queue.onSubmittedWorkDone()}catch(b){L.default.error(b)}}async JP(e,t,r,n,s){let i=this.eU.gpuDevice,a={size:[e,t,1],format:r.webgpu,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT};n&&(a.mipLevelCount=Math.floor(Math.log2(Math.max(e,t)))+1);let u=i.createTexture(a);return i.queue.copyExternalImageToTexture({source:s},{texture:u},[e,t]),n&&this.generateMipmaps(u,a),await i.queue.onSubmittedWorkDone(),this._A(u)}createRenderTargetTexture({width:e,height:t,mipLevelCount:r,format:n}){let s=this.eU.gpuDevice,i={size:[e,t,1],format:n.webgpu,mipLevelCount:r,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=s.createTexture(i);return this._A(a)}createRenderTargetTextureArray({width:e,height:t,internalFormat:r,arrayLength:n}){let s=this.eU.gpuDevice,i={dimension:"2d",size:[e,t,n],format:r.webgpu,mipLevelCount:1,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=s.createTexture(i);return this._A(a)}createRenderTargetTextureCube({width:e,height:t,mipLevelCount:r,format:n}){let s=this.eU.gpuDevice,i={dimension:"2d",size:[e,t,6],format:n.webgpu,mipLevelCount:r,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=s.createTexture(i);return this._A(a)}createRenderBuffer(e,t,r,n,s){let i=this.eU.gpuDevice,a={size:[e,t,1],format:r.webgpu,sampleCount:n?s:1,usage:GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT},u=i.createTexture(a);return this._A(u)}deleteRenderBuffer(e){this.flush(),this.clearCache();let t=this.tU.get(e);t!=null&&(t.destroy(),this.tU.delete(e))}copyTextureData(e,t){let r=this.tU.get(e),n=this.tU.get(t);this.UU(),this.aU.copyTextureToTexture({texture:r},{texture:n},[n.width,n.height,1])}isMippmappedTexture(e){return this.tU.get(e).mipLevelCount>1}duplicateTextureAsMipmapped(e){let t=this.eU.gpuDevice,r=this.tU.get(e),n={size:{width:r.width,height:r.height,depthOrArrayLayers:r.depthOrArrayLayers},mipLevelCount:Math.floor(Math.log2(Math.max(r.width,r.height)))+1,format:r.format,usage:r.usage},s=t.createTexture(n);this.UU(),this.aU.copyTextureToTexture({texture:r},{texture:s},{width:r.width,height:r.height,depthOrArrayLayers:1});let i=this._A(s),a=this._A(s.createView());return[i,a]}attachDepthBufferToFrameBufferObject(e,t){}attachStencilBufferToFrameBufferObject(e,t){}attachDepthStencilBufferToFrameBufferObject(e,t){}createFrameBufferObject(){return-1}deleteFrameBufferObject(e){}attachColorBufferToFrameBufferObject(e,t,r){}attachColorBufferLayerToFrameBufferObject(e,t,r,n,s){}attachColorBufferCubeToFrameBufferObject(e,t,r,n,s){}createTextureView2d(e){let r=this.tU.get(e).createView();return this._A(r)}createTextureViewAsRenderTarget(e){let r=this.tU.get(e).createView({baseMipLevel:0,mipLevelCount:1,arrayLayerCount:1});return this._A(r)}createTextureViewCube(e){let r=this.tU.get(e).createView({dimension:"cube"});return this._A(r)}createTextureView2dArray(e,t){let n=this.tU.get(e).createView({dimension:"2d-array",baseArrayLayer:0,arrayLayerCount:t});return this._A(n)}createTextureView2dArrayAsRenderTarget(e,t,r){let s=this.tU.get(e).createView({dimension:"2d",arrayLayerCount:1,baseArrayLayer:t,baseMipLevel:r,mipLevelCount:1,aspect:"all"});return this._A(s)}createCubeTextureViewAsRenderTarget(e,t,r){let s=this.tU.get(e).createView({dimension:"2d",arrayLayerCount:1,baseArrayLayer:t,baseMipLevel:r,mipLevelCount:1,aspect:"all"});return this._A(s)}deleteTexture(e){this.flush(),this.clearCache();let t=this.tU.get(e);t!=null&&(this.wU.delete(t),this.hU.delete(t),this.mU.delete(t),t.destroy(),this.tU.delete(e))}recreateSystemDepthTexture(){let e=this.eU.gpuDevice,t=this.eU.canvas;if(this.bU!=null&&this.bU.destroy(),this.SU=void 0,t.width<=0||t.height<=0){L.default.warn("Skip recreating system depth texture because the canvas size is zero.");return}this.bU=e.createTexture({size:[t.width,t.height],format:N,usage:GPUTextureUsage.RENDER_ATTACHMENT}),this.dU=this.bU.createView()}resizeCanvas(e,t){if(e<=0||t<=0){L.default.warn("Skip resizing WebGPU canvas because width or height is zero.");return}let r=this.eU.canvas;r.width=e,r.height=t,this.recreateSystemDepthTexture()}setViewport(e,t){}isSupportMultiViewVRRendering(){return!1}};y.Ow=1024,y.YU=32,y.Ww=new Uint32Array(y.YU/4),y.Xw=new Set(["unorm8x2","unorm8x4","snorm8x2","snorm8x4","unorm16x2","unorm16x4","snorm16x2","snorm16x4"]);var q=y;export{q as WebGpuResourceRepository};
|
|
@@ -31,9 +31,11 @@ export declare class WebGpuStrategyBasic implements CGAPIStrategy {
|
|
|
31
31
|
private __storageBlendShapeBufferUid;
|
|
32
32
|
private __uniformMorphOffsetsTypedArray?;
|
|
33
33
|
private __uniformMorphWeightsTypedArray?;
|
|
34
|
+
private __isPreviousMorphWeightsSettled;
|
|
34
35
|
private __lastMaterialsUpdateCount;
|
|
35
36
|
private __lastLightClusterDataVersion;
|
|
36
37
|
private __lastLightComponentsUpdateCount;
|
|
38
|
+
private __lastGpuInstanceDataVersion;
|
|
37
39
|
private __lightClusterBuilder?;
|
|
38
40
|
private __lastLightClusterBuildDataVersion;
|
|
39
41
|
private __lastTransformComponentsUpdateCount;
|
|
@@ -202,6 +204,12 @@ export declare class WebGpuStrategyBasic implements CGAPIStrategy {
|
|
|
202
204
|
* Copies weight values from blend shape components to GPU-accessible uniform buffers.
|
|
203
205
|
*/
|
|
204
206
|
private __updateMorphWeightsUniformBuffer;
|
|
207
|
+
private __uploadMorphWeights;
|
|
208
|
+
/**
|
|
209
|
+
* Makes the weights of the previous frame in the morph weights uniform buffer equal to the current weights once
|
|
210
|
+
* the weights stopped changing (temporal anti-aliasing only).
|
|
211
|
+
*/
|
|
212
|
+
private __settlePreviousMorphWeights;
|
|
205
213
|
/**
|
|
206
214
|
* Determines the appropriate camera component SID for the current rendering context.
|
|
207
215
|
* Handles both VR and non-VR rendering scenarios, including multi-view stereo rendering.
|
|
@@ -1,42 +1,60 @@
|
|
|
1
|
-
import{AnimationComponent as E}from"../foundation/components/Animation/AnimationComponent.js";import{BlendShapeComponent as
|
|
1
|
+
import{AnimationComponent as E}from"../foundation/components/Animation/AnimationComponent.js";import{BlendShapeComponent as B}from"../foundation/components/BlendShape/BlendShapeComponent.js";import{CameraComponent as $}from"../foundation/components/Camera/CameraComponent.js";import{_getCameraControllerUpdateCount as T}from"../foundation/components/CameraController/CameraControllerUpdateCount.js";import{LightComponent as U}from"../foundation/components/Light/LightComponent.js";import{MeshComponent as W}from"../foundation/components/Mesh/MeshComponent.js";import{SceneGraphComponent as V}from"../foundation/components/SceneGraph/SceneGraphComponent.js";import{TransformComponent as D}from"../foundation/components/Transform/TransformComponent.js";import{Component as M}from"../foundation/core/Component.js";import{AlphaMode as N}from"../foundation/definitions/AlphaMode.js";import{BufferUse as C}from"../foundation/definitions/BufferUse.js";import{ComponentType as I}from"../foundation/definitions/ComponentType.js";import{CompositionType as o}from"../foundation/definitions/CompositionType.js";import{ShaderType as R}from"../foundation/definitions/ShaderType.js";import{VertexAttribute as L}from"../foundation/definitions/VertexAttribute.js";import{Primitive as b}from"../foundation/geometry/Primitive.js";import{getTextureAndSamplerNames as w}from"../foundation/helpers/ShaderHelper.js";import{Logger as G}from"../foundation/misc/Logger.js";import{CGAPIResourceRepository as d}from"../foundation/renderer/CGAPIResourceRepository.js";import{isSkipDrawing as F}from"../foundation/renderer/RenderingCommonMethods.js";import{WebGpuLightClusterBuilder as z}from"./WebGpuLightClusterBuilder.js";var k=class g{constructor(t){this.IB=d.InvalidCGAPIResourceUid;this.SB=d.InvalidCGAPIResourceUid;this.OI=!0;this.jI=-1;this.XI=-1;this.or=-1;this.YI=-1;this.MB=-1;this.nr=-1;this.KI=-1;this.dC=-1;this.sr=-1;this.zI=-1;this.HI=-1;this.qI=-1;this.VI=-1;this.JI=-1;this.gI=-1;this.yI=-1;this.OB=-1;this.QI=-1;this.i=t}static init(t){return new g(t)}static getVertexShaderMethodDefinitions_storageBuffer(t,e){let r="";return M.getMemberInfo(t).forEach((n,s)=>{n.forEach((l,p)=>{var f;if(l.shaderType!==e&&l.shaderType!==R.VertexAndPixelShader)return;let h=(f=M.getComponentCountPerBufferView(t).get(s))!=null?f:1;o.isArray(l.compositionType)?a(l,s,p,h):c(l,s,p,h)})}),r;function a(n,s,l,p){var O,_;let h="",f="";switch(n.compositionType){case o.Vec4Array:h="vec4<f32>",f="fetchVec4";break;case o.Mat4Array:h="mat4x4<f32>",f="fetchMat4";break;case o.Mat4x3Array:h="mat4x3<f32>",f="fetchMat4x3";break;default:throw new Error(`Unsupported composition type: ${n.compositionType.str}`)}let m=n.compositionType.getVec4SizeOfProperty();if(n.isVariableLength===!0){let P=M._variableLengthLocationRadix;r+=`
|
|
2
2
|
fn get_${l}(instanceId: u32, idxOfArray: u32) -> ${h} {
|
|
3
3
|
let location = get_${M._getVariableLengthLocationMemberName(l)}(instanceId);
|
|
4
|
-
let index: u32 = u32(location.x) * ${
|
|
4
|
+
let index: u32 = u32(location.x) * ${P}u + u32(location.y) + ${m}u * idxOfArray;
|
|
5
5
|
let value = ${f}(index);
|
|
6
6
|
return value;
|
|
7
7
|
}
|
|
8
|
-
`;return}let y=M.getLocationOffsetOfMemberOfComponent(t,
|
|
9
|
-
const ${x}: array<u32, ${y.length}> = array<u32, ${y.length}>(${y.map(
|
|
10
|
-
fn get_${l}(instanceId: u32, idxOfArray: u32) -> ${
|
|
8
|
+
`;return}let y=M.getLocationOffsetOfMemberOfComponent(t,s,l),u=`let arrayLength: u32 = ${(_=(O=M.getArrayLengthOfMember(t).get(s))==null?void 0:O.get(l))!=null?_:0}u;`,x=`rnIndices_${l}`,A=`${x}[instanceIdOfBufferViews] + instanceIdInBufferView * ${m}u * arrayLength + ${m}u * idxOfArray;`,S="";n.convertToBool&&(S="if (value > 0.5) { return true; } else { return false; }"),r+=`
|
|
9
|
+
const ${x}: array<u32, ${y.length}> = array<u32, ${y.length}>(${y.map(P=>`${P}u`).join(", ")});
|
|
10
|
+
fn get_${l}(instanceId: u32, idxOfArray: u32) -> ${n.convertToBool?"bool":h} {
|
|
11
11
|
let instanceIdOfBufferViews = instanceId / ${p};
|
|
12
12
|
let instanceIdInBufferView = instanceId % ${p};
|
|
13
13
|
${u}
|
|
14
14
|
let index: u32 = ${A};
|
|
15
15
|
let value = ${f}(index);
|
|
16
|
-
${
|
|
16
|
+
${n.convertToBool?S:"return value;"}
|
|
17
17
|
}
|
|
18
|
-
`}function n
|
|
18
|
+
`}function c(n,s,l,p){let h="",f="";switch(n.compositionType){case o.Mat4:h="mat4x4<f32>",f="fetchMat4";break;case o.Mat3:h="mat3x3<f32>",f="fetchMat3No16BytesAligned";break;case o.Vec4:h="vec4<f32>",f="fetchVec4";break;case o.Vec3:h="vec3<f32>",f="fetchVec3No16BytesAligned";break;case o.Scalar:h="f32",f="fetchScalarNo16BytesAligned";break;default:throw new Error(`Unsupported composition type: ${n.compositionType.str}`)}let m=M.getLocationOffsetOfMemberOfComponent(t,s,l),y=`rnIndices_${l}`,v="";switch(n.compositionType){case o.Mat4:v=`${y}[instanceIdOfBufferViews] + 4u * instanceIdInBufferView;`;break;case o.Mat3:v=`${y}[instanceIdOfBufferViews] * 4u + 9u * instanceIdInBufferView;`;break;case o.Vec4:v=`${y}[instanceIdOfBufferViews] + 1u * instanceIdInBufferView;`;break;case o.Vec3:v=`${y}[instanceIdOfBufferViews] * 4u + 3u * instanceIdInBufferView;`;break;case o.Scalar:v=`${y}[instanceIdOfBufferViews] * 4u + 1u * instanceIdInBufferView;`;break;default:throw new Error(`Unsupported composition type: ${n.compositionType.str}`)}let u="";n.convertToBool&&(u="if (value > 0.5) { return true; } else { return false; }"),r+=`
|
|
19
19
|
const ${y}: array<u32, ${m.length}> = array<u32, ${m.length}>(${m.map(x=>`${x}u`).join(", ")});
|
|
20
|
-
fn get_${l}(instanceId: u32) -> ${
|
|
20
|
+
fn get_${l}(instanceId: u32) -> ${n.convertToBool?"bool":h} {
|
|
21
21
|
let instanceIdOfBufferViews = instanceId / ${p};
|
|
22
22
|
let instanceIdInBufferView = instanceId % ${p};
|
|
23
23
|
let index: u32 = ${v};
|
|
24
24
|
let value = ${f}(index);
|
|
25
|
-
${
|
|
25
|
+
${n.convertToBool?u:"return value;"}
|
|
26
26
|
}
|
|
27
|
-
`}}static
|
|
28
|
-
const rnMorphUniformDataTargetNumbers: array<u32, ${e.length}> = array<u32, ${e.length}>(${e.map(
|
|
29
|
-
`,
|
|
30
|
-
const rnMorphUniformDataOffsets: array<u32, ${
|
|
31
|
-
`,
|
|
32
|
-
const rnBlendShapeUniformDataOffsets: array<u32, ${
|
|
33
|
-
|
|
27
|
+
`}}static C_(t){let e=b.getMorphUniformDataTargetNumbers(),r=`
|
|
28
|
+
const rnMorphUniformDataTargetNumbers: array<u32, ${e.length}> = array<u32, ${e.length}>(${e.map(p=>`${p}u`).join(", ")});
|
|
29
|
+
`,i=b.getMorphUniformDataOffsets(),a=`
|
|
30
|
+
const rnMorphUniformDataOffsets: array<u32, ${i.length}> = array<u32, ${i.length}>(${i.map(p=>`${p}u`).join(", ")});
|
|
31
|
+
`,c=B.getOffsetsInUniform(t),n=`
|
|
32
|
+
const rnBlendShapeUniformDataOffsets: array<u32, ${c.length}> = array<u32, ${c.length}>(${c.map(p=>`${p}u`).join(", ")});
|
|
33
|
+
`,s=t._isPreviousMorphWeightsEnabled?`
|
|
34
|
+
fn get_previousMorphedPosition(vertexId: u32, basePosition: vec3<f32>, blendShapeComponentSID: u32) -> vec3<f32> {
|
|
35
|
+
let currentPrimitiveIdx = uniformDrawParameters.currentPrimitiveIdx;
|
|
36
|
+
let offsetInUniform = rnMorphUniformDataOffsets[currentPrimitiveIdx];
|
|
37
|
+
let offsetInUniform2 = rnBlendShapeUniformDataOffsets[blendShapeComponentSID] + ${B._getPreviousMorphWeightsOffset(t)}u;
|
|
38
|
+
var position = basePosition;
|
|
39
|
+
let scalar_idx = 3u * vertexId;
|
|
40
|
+
for (var i=0u; i<rnMorphUniformDataTargetNumbers[currentPrimitiveIdx]; i++) {
|
|
41
|
+
let idx = offsetInUniform + i;
|
|
42
|
+
let offsets = uniformMorphOffsets.data[ idx / 4u];
|
|
43
|
+
let offsetPosition = offsets[idx % 4u];
|
|
44
|
+
let basePosIn4bytes = offsetPosition * 4u + scalar_idx;
|
|
45
|
+
let addPos = fetchVec3No16BytesAlignedFromBlendShapeBuffer(basePosIn4bytes);
|
|
46
|
+
let idx2 = offsetInUniform2 + i;
|
|
47
|
+
let morphWeights: vec4f = uniformMorphWeights.data[ idx2 / 4u];
|
|
48
|
+
position += addPos * morphWeights[idx2 % 4u];
|
|
49
|
+
}
|
|
50
|
+
return position;
|
|
51
|
+
}`:"";return`
|
|
34
52
|
|
|
35
53
|
#ifdef RN_IS_VERTEX_SHADER
|
|
36
54
|
#ifdef RN_IS_MORPHING
|
|
37
55
|
${r}
|
|
38
|
-
${
|
|
39
|
-
${
|
|
56
|
+
${a}
|
|
57
|
+
${n}
|
|
40
58
|
fn get_position(vertexId: u32, basePosition: vec3<f32>, blendShapeComponentSID: u32) -> vec3<f32> {
|
|
41
59
|
let currentPrimitiveIdx = uniformDrawParameters.currentPrimitiveIdx;
|
|
42
60
|
let offsetInUniform = rnMorphUniformDataOffsets[currentPrimitiveIdx];
|
|
@@ -60,61 +78,62 @@ import{AnimationComponent as E}from"../foundation/components/Animation/Animation
|
|
|
60
78
|
|
|
61
79
|
return position;
|
|
62
80
|
}
|
|
81
|
+
${s}
|
|
63
82
|
#endif
|
|
64
83
|
#endif
|
|
65
|
-
`}static
|
|
84
|
+
`}static A_(t,e){var m,y;let r=e.compositionType.toWGSLType(e.componentType),i=e.semantic.replace(".","_");if(o.isTexture(e.compositionType)){let v="texture_2d<f32>";e.compositionType===o.TextureCube?v="texture_cube<f32>":e.compositionType===o.Texture2DArray&&(v="texture_2d_array<f32>");let{textureName:u,samplerName:x}=w(i);return`
|
|
66
85
|
@group(1) @binding(${e.initialValue[0]}) var ${u}: ${v};
|
|
67
86
|
@group(2) @binding(${e.initialValue[0]}) var ${x}: sampler;
|
|
68
|
-
`}let
|
|
69
|
-
`,
|
|
70
|
-
`,l+=` let scalar_idx: u32 = ${
|
|
87
|
+
`}let c=e.compositionType.getVec4SizeOfProperty(),n=e.compositionType.getNumberOfComponents(),s=g.getOffsetOfPropertyOfGlobalDataRepository(t,e.semantic);s===-1&&G.default.error("Could not get the location offset of the property.");let l,p=c;if(l=` let vec4_idx: u32 = ${s}u + ${p}u * instanceId;
|
|
88
|
+
`,o.isArray(e.compositionType)){p=c*((m=e.arrayLength)!=null?m:1);let u=Math.ceil(n/4)*4*((y=e.arrayLength)!=null?y:1);l=` let vec4_idx: u32 = ${s}u + ${p} * instanceId + ${c}u * idxOfArray;
|
|
89
|
+
`,l+=` let scalar_idx: u32 = ${s*4} + ${u} * instanceId + ${n}u * idxOfArray;
|
|
71
90
|
`}let f=`${`
|
|
72
|
-
fn get_${
|
|
91
|
+
fn get_${i}(instanceId: u32, idxOfArray: u32) -> ${r} {
|
|
73
92
|
${l}
|
|
74
|
-
`}`;switch(e.compositionType){case
|
|
75
|
-
`;break;case
|
|
76
|
-
`,f+=` let val = ${r}(col0.xyz);`;break;case
|
|
77
|
-
`;break;case
|
|
78
|
-
`,f+=` let val = ${r}(col0.xy);`;break;case
|
|
79
|
-
`;break;case
|
|
80
|
-
`,e.componentType===I.Int?f+=" let val = i32(col0.x);":e.componentType===I.UnsignedInt?f+=" let val = u32(col0.x);":e.componentType===I.Bool?f+=" let val = col0.x >= 0.5;":f+=" let val = col0.x;";break;case
|
|
81
|
-
`,e.componentType===I.Int?f+=" let val = i32(col0);":e.componentType===I.UnsignedInt?f+=" let val = u32(col0);":e.componentType===I.Bool?f+=" let val = col0 >= 0.5;":f+=" let val = col0;";break;case
|
|
82
|
-
`;break;case
|
|
83
|
-
`;break;case
|
|
84
|
-
`;break;case
|
|
85
|
-
`;break;case
|
|
86
|
-
`;break;case
|
|
87
|
-
`;break;case
|
|
93
|
+
`}`;switch(e.compositionType){case o.Vec4:case o.Vec4Array:f+=` let val = fetchElement(vec4_idx);
|
|
94
|
+
`;break;case o.Vec3:f+=` let col0 = fetchElement(vec4_idx);
|
|
95
|
+
`,f+=` let val = ${r}(col0.xyz);`;break;case o.Vec3Array:f+=` let val = fetchVec3No16BytesAligned(scalar_idx);
|
|
96
|
+
`;break;case o.Vec2:f+=` let col0 = fetchElement(vec4_idx);
|
|
97
|
+
`,f+=` let val = ${r}(col0.xy);`;break;case o.Vec2Array:f+=` let val = fetchVec2No16BytesAligned(scalar_idx);
|
|
98
|
+
`;break;case o.Scalar:f+=` let col0 = fetchElement(vec4_idx);
|
|
99
|
+
`,e.componentType===I.Int?f+=" let val = i32(col0.x);":e.componentType===I.UnsignedInt?f+=" let val = u32(col0.x);":e.componentType===I.Bool?f+=" let val = col0.x >= 0.5;":f+=" let val = col0.x;";break;case o.ScalarArray:f+=` let col0 = fetchScalarNo16BytesAligned(scalar_idx);
|
|
100
|
+
`,e.componentType===I.Int?f+=" let val = i32(col0);":e.componentType===I.UnsignedInt?f+=" let val = u32(col0);":e.componentType===I.Bool?f+=" let val = col0 >= 0.5;":f+=" let val = col0;";break;case o.Mat4:f+=` let val = fetchMat4(vec4_idx);
|
|
101
|
+
`;break;case o.Mat4Array:f+=` let val = fetchMat4(vec4_idx);
|
|
102
|
+
`;break;case o.Mat3:f+=` let val = fetchMat3(vec4_idx);
|
|
103
|
+
`;break;case o.Mat3Array:f+=` let val = fetchMat3No16BytesAligned(scalar_idx);
|
|
104
|
+
`;break;case o.Mat2:f+=` let val = fetchMat2(vec4_idx);
|
|
105
|
+
`;break;case o.Mat2Array:f+=` let val = fetchMat2No16BytesAligned(scalar_idx);
|
|
106
|
+
`;break;case o.Mat4x3Array:f+=` let val = fetchMat4x3(vec4_idx);
|
|
88
107
|
`;break;default:f+=""}return f+=`
|
|
89
108
|
return val;
|
|
90
109
|
}
|
|
91
|
-
`,f}static
|
|
92
|
-
@group(1) @binding(${r.initialValue[0]}) var ${
|
|
93
|
-
@group(2) @binding(${r.initialValue[0]}) var ${
|
|
94
|
-
`}let
|
|
95
|
-
`,
|
|
96
|
-
`,m+=` let scalar_idx: u32 = ${h}[instanceIdOfBufferViews] * 4 + ${
|
|
110
|
+
`,f}static B_(t,e,r){var x,A;let i=r.compositionType.toWGSLType(r.componentType),a=r.semantic.replace(".","_");if(o.isTexture(r.compositionType)){let S="texture_2d<f32>";r.compositionType===o.TextureCube?S="texture_cube<f32>":r.compositionType===o.Texture2DArray&&(S="texture_2d_array<f32>");let{textureName:O,samplerName:_}=w(a);return`
|
|
111
|
+
@group(1) @binding(${r.initialValue[0]}) var ${O}: ${S};
|
|
112
|
+
@group(2) @binding(${r.initialValue[0]}) var ${_}: sampler;
|
|
113
|
+
`}let n=r.compositionType.getVec4SizeOfProperty(),s=r.compositionType.getNumberOfComponents(),l=g.getOffsetOfPropertyOfMaterial(t,r.semantic,e),p=t.materialRepository._getMaterialCountPerBufferView(e),h=`rnOffsets_${a}`,f=`const ${h}: array<u32, ${l.length}> = array<u32, ${l.length}>(${l.map(S=>`${S}u`).join(", ")});`,m,y=n;if(m=` let vec4_idx: u32 = ${h}[instanceIdOfBufferViews] + ${y}u * instanceIdInBufferView;
|
|
114
|
+
`,o.isArray(r.compositionType)){y=n*((x=r.arrayLength)!=null?x:1);let O=Math.ceil(s/4)*4*((A=r.arrayLength)!=null?A:1);m=` let vec4_idx: u32 = ${h}[instanceIdOfBufferViews] + ${y} * instanceIdInBufferView + ${n}u * idxOfArray;
|
|
115
|
+
`,m+=` let scalar_idx: u32 = ${h}[instanceIdOfBufferViews] * 4 + ${O} * instanceIdInBufferView + ${s}u * idxOfArray;
|
|
97
116
|
`}let u=`${`
|
|
98
117
|
${f}
|
|
99
|
-
fn get_${
|
|
118
|
+
fn get_${a}(instanceId: u32, idxOfArray: u32) -> ${i} {
|
|
100
119
|
let instanceIdOfBufferViews = instanceId / ${p};
|
|
101
120
|
let instanceIdInBufferView = instanceId % ${p};
|
|
102
121
|
${m}
|
|
103
|
-
`}`;switch(r.compositionType){case
|
|
104
|
-
`;break;case
|
|
105
|
-
`,u+=` let val = ${
|
|
106
|
-
`;break;case
|
|
107
|
-
`,u+=` let val = ${
|
|
108
|
-
`;break;case
|
|
109
|
-
`,r.componentType===I.Int?u+=" let val = i32(col0.x);":r.componentType===I.UnsignedInt?u+=" let val = u32(col0.x);":r.componentType===I.Bool?u+=" let val = col0.x >= 0.5;":u+=" let val = col0.x;";break;case
|
|
110
|
-
`,r.componentType===I.Int?u+=" let val = i32(col0);":r.componentType===I.UnsignedInt?u+=" let val = u32(col0);":r.componentType===I.Bool?u+=" let val = col0 >= 0.5;":u+=" let val = col0;";break;case
|
|
111
|
-
`;break;case
|
|
112
|
-
`;break;case
|
|
113
|
-
`;break;case
|
|
114
|
-
`;break;case
|
|
115
|
-
`;break;case
|
|
116
|
-
`;break;case
|
|
122
|
+
`}`;switch(r.compositionType){case o.Vec4:case o.Vec4Array:u+=` let val = fetchElement(vec4_idx);
|
|
123
|
+
`;break;case o.Vec3:u+=` let col0 = fetchElement(vec4_idx);
|
|
124
|
+
`,u+=` let val = ${i}(col0.xyz);`;break;case o.Vec3Array:u+=` let val = fetchVec3No16BytesAligned(scalar_idx);
|
|
125
|
+
`;break;case o.Vec2:u+=` let col0 = fetchElement(vec4_idx);
|
|
126
|
+
`,u+=` let val = ${i}(col0.xy);`;break;case o.Vec2Array:u+=` let val = fetchVec2No16BytesAligned(scalar_idx);
|
|
127
|
+
`;break;case o.Scalar:u+=` let col0 = fetchElement(vec4_idx);
|
|
128
|
+
`,r.componentType===I.Int?u+=" let val = i32(col0.x);":r.componentType===I.UnsignedInt?u+=" let val = u32(col0.x);":r.componentType===I.Bool?u+=" let val = col0.x >= 0.5;":u+=" let val = col0.x;";break;case o.ScalarArray:u+=` let col0 = fetchScalarNo16BytesAligned(scalar_idx);
|
|
129
|
+
`,r.componentType===I.Int?u+=" let val = i32(col0);":r.componentType===I.UnsignedInt?u+=" let val = u32(col0);":r.componentType===I.Bool?u+=" let val = col0 >= 0.5;":u+=" let val = col0;";break;case o.Mat4:u+=` let val = fetchMat4(vec4_idx);
|
|
130
|
+
`;break;case o.Mat4Array:u+=` let val = fetchMat4(vec4_idx);
|
|
131
|
+
`;break;case o.Mat3:u+=` let val = fetchMat3(vec4_idx);
|
|
132
|
+
`;break;case o.Mat3Array:u+=` let val = fetchMat3No16BytesAligned(scalar_idx);
|
|
133
|
+
`;break;case o.Mat2:u+=` let val = fetchMat2(vec4_idx);
|
|
134
|
+
`;break;case o.Mat2Array:u+=` let val = fetchMat2No16BytesAligned(scalar_idx);
|
|
135
|
+
`;break;case o.Mat4x3Array:u+=` let val = fetchMat4x3(vec4_idx);
|
|
117
136
|
`;break;default:u+=""}return u+=`
|
|
118
137
|
return val;
|
|
119
138
|
}
|
|
120
|
-
`,u}static getOffsetOfPropertyOfMaterial(t,e,r){return t.materialRepository.getLocationOffsetOfMemberOfMaterial(t,r,e)}static getOffsetOfPropertyOfGlobalDataRepository(t,e){return t.globalDataRepository.getLocationOffsetOfProperty(e)}$load(t){let e=t.mesh;return e==null?!1:(e.isSetUpDone()||e._updateVBOAndVAO(),!0)}common_$load(){this.
|
|
139
|
+
`,u}static getOffsetOfPropertyOfMaterial(t,e,r){return t.materialRepository.getLocationOffsetOfMemberOfMaterial(t,r,e)}static getOffsetOfPropertyOfGlobalDataRepository(t,e){return t.globalDataRepository.getLocationOffsetOfProperty(e)}$load(t){let e=t.mesh;return e==null?!1:(e.isSetUpDone()||e._updateVBOAndVAO(),!0)}common_$load(){this.U_()}U_(){let t=b.getMorphUniformDataOffsets(),e=Math.max(Math.ceil(t[t.length-1]/4)*4*4,4);if(e!==this.VI){let i=this.i.webGpuResourceRepository;if(this.gI!==d.InvalidCGAPIResourceUid&&(i.flush(),i.clearCache(),i.deleteUniformBuffer(this.gI),this.gI=d.InvalidCGAPIResourceUid),this.VI=e,this.gI===d.InvalidCGAPIResourceUid){let a=new Uint32Array(e);this.wI=a,this.gI=i.createUniformMorphOffsetsBuffer(e*4),this.RB()}this.VI=e}let r=B._getMorphWeightsUniformBufferFloatCount(this.i);if(r!==this.JI){let i=this.i.webGpuResourceRepository;if(this.yI!==d.InvalidCGAPIResourceUid&&(i.flush(),i.clearCache(),i.deleteUniformBuffer(this.yI),this.yI=d.InvalidCGAPIResourceUid),this.yI===d.InvalidCGAPIResourceUid){let a=new Float32Array(r);this.II=a,this.yI=i.createUniformMorphWeightsBuffer(r*4),this.HS(!0)}this.JI=r}}wB(t){if(t.mesh==null){W.alertNoMeshSet(t);return}let e=t.mesh.getPrimitiveNumber();for(let r=0;r<e;r++){let i=t.mesh.getPrimitiveAt(r),a=i.material;this._setupShaderProgram(a,i)}}_setupShaderProgram(t,e){if(t!=null&&!t.isShaderProgramReady(e))try{this.setupShaderForMaterial(t,e,g.getVertexShaderMethodDefinitions_storageBuffer(this.i,R.VertexShader),g.getVertexShaderMethodDefinitions_storageBuffer(this.i,R.PixelShader),g.A_,g.B_,g.C_(this.i)),e._backupMaterial()}catch(r){G.default.error(r),e._restoreMaterial(),this.setupShaderForMaterial(e.material,e,g.getVertexShaderMethodDefinitions_storageBuffer(this.i,R.VertexShader),g.getVertexShaderMethodDefinitions_storageBuffer(this.i,R.PixelShader),g.A_,g.B_,g.C_(this.i))}}setupShaderForMaterial(t,e,r,i,a,c,n){t._createProgramWebGpu(this.i,e,r,i,a,c,n)}prerender(){if(E.getIsAnimating(this.i)||D.getUpdateCount(this.i)!==this.nr||V.getUpdateCount(this.i)!==this.KI||$.getCurrentCameraUpdateCount(this.i)!==this.dC||T(this.i)!==this.sr||this.i.materialRepository.stateVersion!==this.jI||this.i.lightClusterSystem.dataVersion!==this.XI||U.getUpdateCount(this.i)!==this.or||this.i._gpuInstanceDataVersion!==this.YI){let e=this._B();this.i.webGpuResourceRepository._markGpuCullingInputsDirty();let r=this.i.lightClusterSystem.dataVersion;(e||r!==this.MB)&&(this.$B(),this.MB=r),this.nr=D.getUpdateCount(this.i),this.KI=V.getUpdateCount(this.i),this.dC=$.getCurrentCameraUpdateCount(this.i),this.sr=T(this.i),this.jI=this.i.materialRepository.stateVersion,this.XI=this.i.lightClusterSystem.dataVersion,this.or=U.getUpdateCount(this.i),this.YI=this.i._gpuInstanceDataVersion}let t=b.getPrimitiveCountHasMorph();t!==this.HI&&(this.VB(),this.HI=t,this.i.webGpuResourceRepository._markGpuCullingInputsDirty()),B.updateCount!==this.zI||B.getCountOfBlendShapeComponents(this.i)!==this.QI?(this.HS(),this.i.webGpuResourceRepository._markGpuCullingInputsDirty(),this.zI=B.updateCount,this.QI=B.getCountOfBlendShapeComponents(this.i),this.i.materialRepository._makeShaderInvalidateToMorphMaterials()):this.O_()}common_$render(t,e,r,i){if(e.isBufferLessRenderingMode())return this.L_(e),!0;let a=!1,c=e.isDepthTest&&e.depthWriteMask,n=this.DB(e);if(n)for(let s=e._lastOpaqueIndex;s>=0;s--)this.renderInner(t[s],e,!0,i,{depthOnly:!0});if(e._toRenderOpaquePrimitives)for(let s=e._lastOpaqueIndex;s>=0;s--){let l=t[s],p=this.renderInner(l,e,c,i,{allowEqualDepth:n});a||(a=p)}if(e._toRenderTranslucentPrimitives)for(let s=e._lastOpaqueIndex+1;s<=e._lastTranslucentIndex;s++){let l=t[s],p=this.renderInner(l,e,c,i);a||(a=p)}if(e._toRenderBlendWithZWritePrimitives)for(let s=e._lastTranslucentIndex+1;s<=e._lastBlendWithZWriteIndex;s++){let l=t[s],p=this.renderInner(l,e,c,i);a||(a=p)}if(e._toRenderBlendWithoutZWritePrimitives)for(let s=e._lastBlendWithZWriteIndex+1;s<=e._lastBlendWithoutZWriteIndex;s++){let l=t[s],p=this.renderInner(l,e,!1,i);a||(a=p)}return a}L_(t){let e=t.material,r=t._dummyPrimitiveForBufferLessRendering;this._setupShaderProgram(e,r);let i=this.i.webGpuResourceRepository,a=this.AB(t,0,!1);i.setDrawParameters(e.materialSID,a,0,0);let c=t.isDepthTest&&t.depthWriteMask;i.draw(this.i,r,e,t,a,c,0)}DB(t){let e=t.getFramebuffer();return this.i.config.isDepthPrepassEnabled&&t.material==null&&t.isDepthTest&&t.depthWriteMask&&(e==null||e.depthAttachment!=null)&&t._toRenderOpaquePrimitives&&t._lastOpaqueIndex>=0}renderInner(t,e,r,i,a={}){var f,m;if(t===-1)return!1;let c=b.getPrimitive(t);if(c==null)return!1;let n=e.getAppropriateMaterial(c);if(this._setupShaderProgram(n,c),F(n,c)||a.depthOnly&&(n.alphaMode===N.Mask||n.alphaToCoverage||n.isShaderDefine("RN_USE_WIREFRAME")))return!1;let s=this.i.webGpuResourceRepository,l=this.i._webXRSystemIfEnabled,p=this.AB(e,i,((f=l==null?void 0:l.isWebXRMode)!=null?f:!1)&&e.isVrRendering),h=(m=b.getPrimitiveIdxHasMorph(c.primitiveUid))!=null?m:0;return s.setDrawParameters(n.materialSID,p,h,c.targets.length),s.draw(this.i,c,n,e,p,r,i,a),!0}_B(){let e=this.i.memoryManager.getBuffers(C.GPUInstanceData),r=e.length,i=this.i.webGpuResourceRepository;if(r!==this.qI&&(this.qI=r,i.destroyStorageBuffer(this.IB),this.IB=d.InvalidCGAPIResourceUid),this.IB!==d.InvalidCGAPIResourceUid){let a=this.i.lightClusterSystem;i.updateStorageBuffer(this.IB,e,a._getExcludedByteRanges());let c=a._takeDirtyByteRanges();return c.length>0&&i.updateStorageBufferRanges(this.IB,e,c),!1}return this.IB=i.createStorageBuffer(e),this.i.lightClusterSystem._takeDirtyByteRanges(),!0}$B(){var a,c;let t=this.i.lightClusterSystem._getGpuBuildParams();if(t==null)return;let e=this.i.webGpuResourceRepository,r=e._getStorageBuffer();if(r==null)return;(c=this[a="BB"])!=null||(this[a]=new z(e.getWebGpuDeviceWrapper().gpuDevice));let i=this.i.gpuTimerEnabled?e._getGpuTimer():void 0;this.BB.build(r,t,i)}VB(){let e=this.i.memoryManager.getBuffers(C.GPUVertexData);if(e.length===0)return;let r=e.reduce((n,s)=>n+s.byteLength,0);r!==this.OB&&(this.i.webGpuResourceRepository.deleteStorageBlendShapeBuffer(this.SB),this.SB=d.InvalidCGAPIResourceUid,this.OB=r);let i=this.i.webGpuResourceRepository,a=new Float32Array(r/4),c=0;for(let n=0;n<e.length;n++){let s=e[n];a.set(new Float32Array(s.getArrayBuffer()),c),c+=s.byteLength/4}if(this.SB!==d.InvalidCGAPIResourceUid){let n=r/4;i.updateStorageBlendShapeBuffer(this.SB,a,n)}else this.SB=i.createStorageBlendShapeBuffer(a);this.RB()}RB(){let t=this.i.webGpuResourceRepository,e=b.getMorphUniformDataOffsets();for(let i=0;i<b.getPrimitiveCountHasMorph();i++){let a=b.getPrimitiveHasMorph(i);if(a!=null)for(let c=0;c<a.targets.length;c++){let s=a.targets[c].get(L.Position.XYZ),l=this.i.memoryManager.getByteOffsetOfExistingBuffers(C.GPUVertexData,s.bufferView.buffer.indexOfTheBufferUsage);this.wI[e[i]+c]=(l+s.byteOffsetInBuffer)/4/4}else break}let r=e[e.length-1];t.updateUniformMorphOffsetsBuffer(this.wI,r)}HS(t=!1){let r=this.i.memoryManager.getBuffer(C.GPUVertexData);if(r==null||r.takenSizeInByte===0)return;let i=B._writeMorphWeightsUniformArray(this.i,this.II,t);this.OI=!1,i>0&&this.YS(i)}YS(t){this.i.webGpuResourceRepository.updateUniformMorphWeightsBuffer(this.II,t)}O_(){if(this.OI||this.II==null)return;this.OI=!0;let t=B._settlePreviousMorphWeights(this.i,this.II);t>0&&this.YS(t)}AB(t,e,r){if(r){let a=this.i._webXRSystemIfEnabled,c=-1;return a!=null&&a.isWebXRMode&&(a.isMultiView()?c=a._getCameraComponentSIDAt(0):c=a._getCameraComponentSIDAt(e)),c}let i=t.cameraComponent;return i==null&&(i=this.i.componentRepository.getComponent($,$.getCurrent(this.i))),i?i.componentSID:-1}destroy(){var e;let t=this.i.webGpuResourceRepository;(e=this.BB)==null||e.destroy(),this.BB=void 0,t._destroyGpuCulling(),this.IB!==d.InvalidCGAPIResourceUid&&(t.destroyStorageBuffer(this.IB),this.IB=d.InvalidCGAPIResourceUid),this.SB!==d.InvalidCGAPIResourceUid&&(t.deleteStorageBlendShapeBuffer(this.SB),this.SB=d.InvalidCGAPIResourceUid),this.gI!==d.InvalidCGAPIResourceUid&&(t.deleteUniformBuffer(this.gI),this.gI=d.InvalidCGAPIResourceUid),this.yI!==d.InvalidCGAPIResourceUid&&(t.deleteUniformBuffer(this.yI),this.yI=d.InvalidCGAPIResourceUid)}};export{k as WebGpuStrategyBasic};
|