@lightningjs/renderer 0.3.1 → 0.3.2
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/NOTICE +1 -2
- package/dist/exports/core-api.js +1 -1
- package/dist/exports/main-api.js +1 -1
- package/dist/exports/utils.js +1 -1
- package/dist/src/common/CommonTypes.js +1 -1
- package/dist/src/common/EventEmitter.js +1 -1
- package/dist/src/common/IAnimationController.js +1 -1
- package/dist/src/core/CoreExtension.js +1 -1
- package/dist/src/core/CoreNode.js +1 -1
- package/dist/src/core/CoreTextNode.js +1 -1
- package/dist/src/core/CoreTextureManager.js +1 -1
- package/dist/src/core/Matrix2DContext.js +1 -1
- package/dist/src/core/Stage.js +1 -1
- package/dist/src/core/animations/AnimationManager.js +1 -1
- package/dist/src/core/animations/CoreAnimation.js +1 -1
- package/dist/src/core/animations/CoreAnimationController.js +1 -1
- package/dist/src/core/lib/glm/common.js +1 -1
- package/dist/src/core/lib/glm/index.js +1 -1
- package/dist/src/core/lib/glm/mat2.js +1 -1
- package/dist/src/core/lib/glm/mat2d.js +1 -1
- package/dist/src/core/lib/glm/mat3.js +1 -1
- package/dist/src/core/lib/glm/mat4.js +1 -1
- package/dist/src/core/lib/glm/quat.js +1 -1
- package/dist/src/core/lib/glm/quat2.js +1 -1
- package/dist/src/core/lib/glm/vec2.js +1 -1
- package/dist/src/core/lib/glm/vec3.js +1 -1
- package/dist/src/core/lib/glm/vec4.js +1 -1
- package/dist/src/core/lib/utils.js +1 -1
- package/dist/src/core/platform.js +1 -1
- package/dist/src/core/renderers/CoreContextTexture.js +1 -1
- package/dist/src/core/renderers/CoreRenderOp.js +1 -1
- package/dist/src/core/renderers/CoreRenderer.js +1 -1
- package/dist/src/core/renderers/CoreShader.js +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.d.ts +2 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js +4 -2
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +6 -6
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +10 -0
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js +8 -1
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/internal/BufferCollection.js +1 -1
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js +1 -1
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.js +1 -1
- package/dist/src/core/renderers/webgl/internal/WebGlUtils.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.d.ts +4 -2
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +6 -1
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +2 -2
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.d.ts +38 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +116 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +1 -1
- package/dist/src/core/scene/Scene.js +1 -1
- package/dist/src/core/text-rendering/TextTextureRendererUtils.js +1 -1
- package/dist/src/core/text-rendering/TrFontManager.js +1 -1
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js +1 -1
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.js +1 -1
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.js +1 -1
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.js +1 -1
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.js +1 -1
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js +1 -1
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +2 -2
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.js +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.js +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.js +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.js +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js +1 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.js +1 -1
- package/dist/src/core/text-rendering/renderers/TextRenderer.js +1 -1
- package/dist/src/core/textures/ColorTexture.js +1 -1
- package/dist/src/core/textures/ImageTexture.js +1 -1
- package/dist/src/core/textures/NoiseTexture.js +1 -1
- package/dist/src/core/textures/SubTexture.js +1 -1
- package/dist/src/core/textures/Texture.js +1 -1
- package/dist/src/core/utils.js +1 -1
- package/dist/src/main-api/INode.js +1 -1
- package/dist/src/main-api/IRenderDriver.js +1 -1
- package/dist/src/main-api/RendererMain.js +1 -1
- package/dist/src/main-api/TextureRegistry.d.ts +33 -0
- package/dist/src/main-api/TextureRegistry.js +97 -0
- package/dist/src/main-api/TextureRegistry.js.map +1 -0
- package/dist/src/main-api/TextureUsageRegistry/TextureRegistry.d.ts +33 -0
- package/dist/src/main-api/TextureUsageRegistry/TextureRegistry.js +97 -0
- package/dist/src/main-api/TextureUsageRegistry/TextureRegistry.js.map +1 -0
- package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.d.ts +9 -0
- package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.js +38 -0
- package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.js.map +1 -0
- package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.d.ts +56 -0
- package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.js +101 -0
- package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.js.map +1 -0
- package/dist/src/main-api/texture-usage-trackers/TextureUsageTracker.d.ts +32 -0
- package/dist/src/main-api/texture-usage-trackers/TextureUsageTracker.js +28 -0
- package/dist/src/main-api/texture-usage-trackers/TextureUsageTracker.js.map +1 -0
- package/dist/src/render-drivers/main/MainOnlyNode.js +1 -1
- package/dist/src/render-drivers/main/MainOnlyTextNode.js +1 -1
- package/dist/src/render-drivers/main/MainRenderDriver.js +1 -1
- package/dist/src/render-drivers/threadx/NodeStruct.js +1 -1
- package/dist/src/render-drivers/threadx/SharedNode.js +1 -1
- package/dist/src/render-drivers/threadx/TextNodeStruct.js +1 -1
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js +1 -1
- package/dist/src/render-drivers/threadx/ThreadXMainNode.js +1 -1
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js +1 -1
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js +1 -1
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js +1 -1
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js +1 -1
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js +1 -1
- package/dist/src/render-drivers/threadx/worker/renderer.js +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/common/CommonTypes.ts +70 -0
- package/src/common/EventEmitter.ts +77 -0
- package/src/common/IAnimationController.ts +29 -0
- package/src/core/CoreExtension.ts +32 -0
- package/src/core/CoreNode.ts +700 -0
- package/src/core/CoreShaderManager.ts +111 -0
- package/src/core/CoreTextNode.ts +342 -0
- package/src/core/CoreTextureManager.ts +323 -0
- package/src/core/Matrix2DContext.ts +52 -0
- package/src/core/Stage.ts +280 -0
- package/src/core/animations/AnimationManager.ts +38 -0
- package/src/core/animations/CoreAnimation.ts +139 -0
- package/src/core/animations/CoreAnimationController.ts +117 -0
- package/src/core/lib/glm/common.ts +231 -0
- package/src/core/lib/glm/index.ts +31 -0
- package/src/core/lib/glm/mat2.ts +499 -0
- package/src/core/lib/glm/mat2d.ts +547 -0
- package/src/core/lib/glm/mat3.ts +849 -0
- package/src/core/lib/glm/mat4.ts +2169 -0
- package/src/core/lib/glm/quat.ts +828 -0
- package/src/core/lib/glm/quat2.ts +951 -0
- package/src/core/lib/glm/vec2.ts +671 -0
- package/src/core/lib/glm/vec3.ts +859 -0
- package/src/core/lib/glm/vec4.ts +708 -0
- package/src/core/lib/utils.ts +144 -0
- package/src/core/platform.ts +40 -0
- package/src/core/renderers/CoreContextTexture.ts +30 -0
- package/src/core/renderers/CoreRenderOp.ts +22 -0
- package/src/core/renderers/CoreRenderer.ts +66 -0
- package/src/core/renderers/CoreShader.ts +41 -0
- package/src/core/renderers/webgl/WebGlCoreCtxSubTexture.ts +36 -0
- package/src/core/renderers/webgl/WebGlCoreCtxTexture.ts +208 -0
- package/src/core/renderers/webgl/WebGlCoreRenderOp.ts +111 -0
- package/src/core/renderers/webgl/WebGlCoreRenderer.ts +567 -0
- package/src/core/renderers/webgl/WebGlCoreShader.ts +328 -0
- package/src/core/renderers/webgl/internal/BufferCollection.ts +54 -0
- package/src/core/renderers/webgl/internal/RendererUtils.ts +134 -0
- package/src/core/renderers/webgl/internal/ShaderUtils.ts +135 -0
- package/src/core/renderers/webgl/internal/WebGlUtils.ts +35 -0
- package/src/core/renderers/webgl/shaders/DefaultShader.ts +95 -0
- package/src/core/renderers/webgl/shaders/DefaultShaderBatched.ts +132 -0
- package/src/core/renderers/webgl/shaders/DynamicShader.ts +430 -0
- package/src/core/renderers/webgl/shaders/RoundedRectangle.ts +168 -0
- package/src/core/renderers/webgl/shaders/SdfShader.ts +165 -0
- package/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.ts +101 -0
- package/src/core/renderers/webgl/shaders/effects/BorderEffect.ts +86 -0
- package/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.ts +101 -0
- package/src/core/renderers/webgl/shaders/effects/BorderRightEffect.ts +101 -0
- package/src/core/renderers/webgl/shaders/effects/BorderTopEffect.ts +101 -0
- package/src/core/renderers/webgl/shaders/effects/EffectUtils.ts +33 -0
- package/src/core/renderers/webgl/shaders/effects/FadeOutEffect.ts +111 -0
- package/src/core/renderers/webgl/shaders/effects/GlitchEffect.ts +145 -0
- package/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.ts +37 -0
- package/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.ts +182 -0
- package/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.ts +159 -0
- package/src/core/renderers/webgl/shaders/effects/RadiusEffect.ts +106 -0
- package/src/core/renderers/webgl/shaders/effects/ShaderEffect.ts +114 -0
- package/src/core/scene/Scene.ts +120 -0
- package/src/core/text-rendering/TextTextureRendererUtils.ts +189 -0
- package/src/core/text-rendering/TrFontManager.ts +96 -0
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.ts +128 -0
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.ts +139 -0
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.test.ts +159 -0
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.ts +164 -0
- package/src/core/text-rendering/font-face-types/TrFontFace.ts +105 -0
- package/src/core/text-rendering/font-face-types/WebTrFontFace.ts +77 -0
- package/src/core/text-rendering/renderers/CanvasTextRenderer.ts +634 -0
- package/src/core/text-rendering/renderers/LightningTextTextureRenderer.ts +705 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.ts +647 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.test.ts +48 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.ts +66 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.ts +52 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.ts +32 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.ts +76 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.test.ts +133 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.ts +38 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.ts +381 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.test.ts +136 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.ts +64 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.test.ts +41 -0
- package/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.ts +51 -0
- package/src/core/text-rendering/renderers/TextRenderer.ts +371 -0
- package/src/core/textures/ColorTexture.ts +85 -0
- package/src/core/textures/ImageTexture.ts +113 -0
- package/src/core/textures/NoiseTexture.ts +96 -0
- package/src/core/textures/SubTexture.ts +140 -0
- package/src/core/textures/Texture.ts +162 -0
- package/src/core/utils.ts +222 -0
- package/src/main-api/INode.ts +443 -0
- package/src/main-api/IRenderDriver.ts +58 -0
- package/src/main-api/RendererMain.ts +451 -0
- package/src/render-drivers/main/MainOnlyNode.ts +429 -0
- package/src/render-drivers/main/MainOnlyTextNode.ts +220 -0
- package/src/render-drivers/main/MainRenderDriver.ts +117 -0
- package/src/render-drivers/threadx/NodeStruct.ts +290 -0
- package/src/render-drivers/threadx/SharedNode.ts +95 -0
- package/src/render-drivers/threadx/TextNodeStruct.ts +166 -0
- package/src/render-drivers/threadx/ThreadXMainAnimationController.ts +99 -0
- package/src/render-drivers/threadx/ThreadXMainNode.ts +151 -0
- package/src/render-drivers/threadx/ThreadXMainTextNode.ts +75 -0
- package/src/render-drivers/threadx/ThreadXRenderDriver.ts +247 -0
- package/src/render-drivers/threadx/ThreadXRendererMessage.ts +82 -0
- package/src/render-drivers/threadx/worker/ThreadXRendererNode.ts +232 -0
- package/src/render-drivers/threadx/worker/ThreadXRendererTextNode.ts +146 -0
- package/src/render-drivers/threadx/worker/renderer.ts +138 -0
- package/src/render-drivers/utils.ts +57 -0
- package/src/utils.ts +202 -0
package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
package/dist/src/core/utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
3
|
* following copyright and licenses apply:
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2023 Comcast
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TextureDesc } from "./RendererMain.js";
|
|
2
|
+
interface TextureRefInfo {
|
|
3
|
+
/**
|
|
4
|
+
* Texture Reference ID
|
|
5
|
+
*/
|
|
6
|
+
id: number;
|
|
7
|
+
/**
|
|
8
|
+
* The number of references to this texture that are currently assigned to
|
|
9
|
+
* Nodes.
|
|
10
|
+
*/
|
|
11
|
+
nodeRefCount: number;
|
|
12
|
+
/**
|
|
13
|
+
* The last time the texture reference count was updated.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This is used to determine when a texture is no longer referenced by any
|
|
17
|
+
* Nodes and can be removed from the GPU.
|
|
18
|
+
*/
|
|
19
|
+
lastUpdate: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Usage-based Texture Garbage Collection Registry
|
|
23
|
+
*/
|
|
24
|
+
export declare class TextureRegistry {
|
|
25
|
+
protected releaseCallback: (textureDescId: number) => void;
|
|
26
|
+
textureMap: Map<number, TextureRefInfo>;
|
|
27
|
+
zeroReferenceTextureSet: Set<TextureRefInfo>;
|
|
28
|
+
constructor(releaseCallback: (textureDescId: number) => void);
|
|
29
|
+
registerTexture(texture: TextureDesc): void;
|
|
30
|
+
incrementTextureRefCount(texture: TextureDesc): void;
|
|
31
|
+
decrementTextureRefCount(texture: TextureDesc): void;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { assertTruthy } from "../utils.js";
|
|
20
|
+
const TEXTURE_CLEANUP_INTERVAL_MS = 1000;
|
|
21
|
+
const TEXTURE_CLEANUP_AGE_THREADHOLD_MS = 5000;
|
|
22
|
+
/**
|
|
23
|
+
* Usage-based Texture Garbage Collection Registry
|
|
24
|
+
*/
|
|
25
|
+
export class TextureRegistry {
|
|
26
|
+
releaseCallback;
|
|
27
|
+
textureMap = new Map();
|
|
28
|
+
zeroReferenceTextureSet = new Set();
|
|
29
|
+
constructor(releaseCallback) {
|
|
30
|
+
this.releaseCallback = releaseCallback;
|
|
31
|
+
// Periodically check for textures that are no longer referenced by any
|
|
32
|
+
// Nodes and notify RendererMain to release them.
|
|
33
|
+
setInterval(() => {
|
|
34
|
+
const now = Date.now();
|
|
35
|
+
for (const textureRefInfo of this.zeroReferenceTextureSet) {
|
|
36
|
+
if (now - textureRefInfo.lastUpdate > TEXTURE_CLEANUP_AGE_THREADHOLD_MS) {
|
|
37
|
+
this.releaseCallback(textureRefInfo.id);
|
|
38
|
+
this.textureMap.delete(textureRefInfo.id);
|
|
39
|
+
this.zeroReferenceTextureSet.delete(textureRefInfo);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, TEXTURE_CLEANUP_INTERVAL_MS);
|
|
43
|
+
}
|
|
44
|
+
registerTexture(texture) {
|
|
45
|
+
const textureId = texture.options?.id;
|
|
46
|
+
assertTruthy(textureId, 'Texture must have an id to be registered');
|
|
47
|
+
if (!this.textureMap.has(textureId)) {
|
|
48
|
+
const textureRefInfo = {
|
|
49
|
+
id: textureId,
|
|
50
|
+
nodeRefCount: 0,
|
|
51
|
+
lastUpdate: Date.now()
|
|
52
|
+
};
|
|
53
|
+
this.textureMap.set(textureId, textureRefInfo);
|
|
54
|
+
this.zeroReferenceTextureSet.add(textureRefInfo);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
incrementTextureRefCount(texture) {
|
|
58
|
+
const textureId = texture.options?.id;
|
|
59
|
+
assertTruthy(textureId, 'Texture must have an id to be registered');
|
|
60
|
+
let textureRefInfo = this.textureMap.get(textureId);
|
|
61
|
+
if (!textureRefInfo) {
|
|
62
|
+
// Texture has not been registered yet, so register it now.
|
|
63
|
+
// This may happen if the TextureDesc was cleaned up from the registry
|
|
64
|
+
// but was still alive in memory and eventually re-used.
|
|
65
|
+
this.registerTexture(texture);
|
|
66
|
+
textureRefInfo = this.textureMap.get(textureId);
|
|
67
|
+
}
|
|
68
|
+
assertTruthy(textureRefInfo, 'Texture must have been registered');
|
|
69
|
+
if (texture.txType === 'SubTexture') {
|
|
70
|
+
// If this is a SubTexture, then increment the reference count of the
|
|
71
|
+
// parent texture as well.
|
|
72
|
+
this.incrementTextureRefCount(texture.props.texture);
|
|
73
|
+
}
|
|
74
|
+
textureRefInfo.nodeRefCount++;
|
|
75
|
+
textureRefInfo.lastUpdate = Date.now();
|
|
76
|
+
if (this.zeroReferenceTextureSet.has(textureRefInfo)) {
|
|
77
|
+
this.zeroReferenceTextureSet.delete(textureRefInfo);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
decrementTextureRefCount(texture) {
|
|
81
|
+
const textureId = texture.options?.id;
|
|
82
|
+
assertTruthy(textureId, 'Texture must have an id to be registered');
|
|
83
|
+
const textureRefInfo = this.textureMap.get(textureId);
|
|
84
|
+
assertTruthy(textureRefInfo, 'Texture must have been registered');
|
|
85
|
+
textureRefInfo.nodeRefCount--;
|
|
86
|
+
textureRefInfo.lastUpdate = Date.now();
|
|
87
|
+
if (textureRefInfo.nodeRefCount === 0) {
|
|
88
|
+
this.zeroReferenceTextureSet.add(textureRefInfo);
|
|
89
|
+
}
|
|
90
|
+
if (texture.txType === 'SubTexture') {
|
|
91
|
+
// If this is a SubTexture, then decrement the reference count of the
|
|
92
|
+
// parent texture as well.
|
|
93
|
+
this.decrementTextureRefCount(texture.props.texture);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=TextureRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextureRegistry.js","sourceRoot":"","sources":["../../../src/main-api/TextureRegistry.ts"],"names":[],"m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AC,CAAC;QAClE,cAAc,CAAC,YAAY,EAAE,CAAC;QAC9B,cAAc,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvC,IAAI,cAAc,CAAC,YAAY,KAAK,CAAC,EAAE;YACrC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;SAClD;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,EAAE;YACnC,qEAAqE;YACrE,0BAA0B;YAC1B,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACtD;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TextureDesc } from "../RendererMain.js";
|
|
2
|
+
interface TextureRefInfo {
|
|
3
|
+
/**
|
|
4
|
+
* Texture Reference ID
|
|
5
|
+
*/
|
|
6
|
+
id: number;
|
|
7
|
+
/**
|
|
8
|
+
* The number of references to this texture that are currently assigned to
|
|
9
|
+
* Nodes.
|
|
10
|
+
*/
|
|
11
|
+
nodeRefCount: number;
|
|
12
|
+
/**
|
|
13
|
+
* The last time the texture reference count was updated.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This is used to determine when a texture is no longer referenced by any
|
|
17
|
+
* Nodes and can be removed from the GPU.
|
|
18
|
+
*/
|
|
19
|
+
lastUpdate: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Usage-based Texture Garbage Collection Registry
|
|
23
|
+
*/
|
|
24
|
+
export declare class TextureRegistry {
|
|
25
|
+
protected releaseCallback: (textureDescId: number) => void;
|
|
26
|
+
textureMap: Map<number, TextureRefInfo>;
|
|
27
|
+
zeroReferenceTextureSet: Set<TextureRefInfo>;
|
|
28
|
+
constructor(releaseCallback: (textureDescId: number) => void);
|
|
29
|
+
registerTexture(texture: TextureDesc): void;
|
|
30
|
+
incrementTextureRefCount(texture: TextureDesc): void;
|
|
31
|
+
decrementTextureRefCount(texture: TextureDesc): void;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { assertTruthy } from "../../utils.js";
|
|
20
|
+
const TEXTURE_CLEANUP_INTERVAL_MS = 1000;
|
|
21
|
+
const TEXTURE_CLEANUP_AGE_THREADHOLD_MS = 5000;
|
|
22
|
+
/**
|
|
23
|
+
* Usage-based Texture Garbage Collection Registry
|
|
24
|
+
*/
|
|
25
|
+
export class TextureRegistry {
|
|
26
|
+
releaseCallback;
|
|
27
|
+
textureMap = new Map();
|
|
28
|
+
zeroReferenceTextureSet = new Set();
|
|
29
|
+
constructor(releaseCallback) {
|
|
30
|
+
this.releaseCallback = releaseCallback;
|
|
31
|
+
// Periodically check for textures that are no longer referenced by any
|
|
32
|
+
// Nodes and notify RendererMain to release them.
|
|
33
|
+
setInterval(() => {
|
|
34
|
+
const now = Date.now();
|
|
35
|
+
for (const textureRefInfo of this.zeroReferenceTextureSet) {
|
|
36
|
+
if (now - textureRefInfo.lastUpdate > TEXTURE_CLEANUP_AGE_THREADHOLD_MS) {
|
|
37
|
+
this.releaseCallback(textureRefInfo.id);
|
|
38
|
+
this.textureMap.delete(textureRefInfo.id);
|
|
39
|
+
this.zeroReferenceTextureSet.delete(textureRefInfo);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, TEXTURE_CLEANUP_INTERVAL_MS);
|
|
43
|
+
}
|
|
44
|
+
registerTexture(texture) {
|
|
45
|
+
const textureId = texture.options?.id;
|
|
46
|
+
assertTruthy(textureId, 'Texture must have an id to be registered');
|
|
47
|
+
if (!this.textureMap.has(textureId)) {
|
|
48
|
+
const textureRefInfo = {
|
|
49
|
+
id: textureId,
|
|
50
|
+
nodeRefCount: 0,
|
|
51
|
+
lastUpdate: Date.now()
|
|
52
|
+
};
|
|
53
|
+
this.textureMap.set(textureId, textureRefInfo);
|
|
54
|
+
this.zeroReferenceTextureSet.add(textureRefInfo);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
incrementTextureRefCount(texture) {
|
|
58
|
+
const textureId = texture.options?.id;
|
|
59
|
+
assertTruthy(textureId, 'Texture must have an id to be registered');
|
|
60
|
+
let textureRefInfo = this.textureMap.get(textureId);
|
|
61
|
+
if (!textureRefInfo) {
|
|
62
|
+
// Texture has not been registered yet, so register it now.
|
|
63
|
+
// This may happen if the TextureDesc was cleaned up from the registry
|
|
64
|
+
// but was still alive in memory and eventually re-used.
|
|
65
|
+
this.registerTexture(texture);
|
|
66
|
+
textureRefInfo = this.textureMap.get(textureId);
|
|
67
|
+
}
|
|
68
|
+
assertTruthy(textureRefInfo, 'Texture must have been registered');
|
|
69
|
+
if (texture.txType === 'SubTexture') {
|
|
70
|
+
// If this is a SubTexture, then increment the reference count of the
|
|
71
|
+
// parent texture as well.
|
|
72
|
+
this.incrementTextureRefCount(texture.props.texture);
|
|
73
|
+
}
|
|
74
|
+
textureRefInfo.nodeRefCount++;
|
|
75
|
+
textureRefInfo.lastUpdate = Date.now();
|
|
76
|
+
if (this.zeroReferenceTextureSet.has(textureRefInfo)) {
|
|
77
|
+
this.zeroReferenceTextureSet.delete(textureRefInfo);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
decrementTextureRefCount(texture) {
|
|
81
|
+
const textureId = texture.options?.id;
|
|
82
|
+
assertTruthy(textureId, 'Texture must have an id to be registered');
|
|
83
|
+
const textureRefInfo = this.textureMap.get(textureId);
|
|
84
|
+
assertTruthy(textureRefInfo, 'Texture must have been registered');
|
|
85
|
+
textureRefInfo.nodeRefCount--;
|
|
86
|
+
textureRefInfo.lastUpdate = Date.now();
|
|
87
|
+
if (textureRefInfo.nodeRefCount === 0) {
|
|
88
|
+
this.zeroReferenceTextureSet.add(textureRefInfo);
|
|
89
|
+
}
|
|
90
|
+
if (texture.txType === 'SubTexture') {
|
|
91
|
+
// If this is a SubTexture, then decrement the reference count of the
|
|
92
|
+
// parent texture as well.
|
|
93
|
+
this.decrementTextureRefCount(texture.props.texture);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=TextureRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextureRegistry.js","sourceRoot":"","sources":["../../../../src/main-api/TextureUsageRegistry/TextureRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,2BAA2B,GAAG,IAAI,CAAC;AACzC,MAAM,iCAAiC,GAAG,IAAI,CAAC;AAsB/C;;GAEG;AACH,MAAM,OAAO,eAAe;IAIJ;IAHtB,UAAU,GAAgC,IAAI,GAAG,EAAE,CAAC;IACpD,uBAAuB,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEzD,YAAsB,eAAgD;QAAhD,oBAAe,GAAf,eAAe,CAAiC;QACpE,uEAAuE;QACvE,iDAAiD;QACjD,WAAW,CAAC,GAAG,EAAE;YACf,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,K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
import { TextureUsageTracker } from './TextureUsageTracker.js';
|
|
3
|
+
export declare class FinalizationRegistryTextureUsageTracker extends TextureUsageTracker {
|
|
4
|
+
private registry;
|
|
5
|
+
constructor(releaseCallback: (textureDescId: number) => void);
|
|
6
|
+
registerTexture(texture: TextureRef): void;
|
|
7
|
+
incrementTextureRefCount(): void;
|
|
8
|
+
decrementTextureRefCount(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { assertTruthy } from '../../utils.js';
|
|
20
|
+
import { TextureUsageTracker } from './TextureUsageTracker.js';
|
|
21
|
+
export class FinalizationRegistryTextureUsageTracker extends TextureUsageTracker {
|
|
22
|
+
registry;
|
|
23
|
+
constructor(releaseCallback) {
|
|
24
|
+
super(releaseCallback);
|
|
25
|
+
this.registry = new FinalizationRegistry(releaseCallback);
|
|
26
|
+
}
|
|
27
|
+
registerTexture(texture) {
|
|
28
|
+
assertTruthy(texture.options?.id, 'Texture must have an ID to be registered');
|
|
29
|
+
this.registry.register(texture, texture.options?.id);
|
|
30
|
+
}
|
|
31
|
+
incrementTextureRefCount() {
|
|
32
|
+
// No-op for FinalizationRegistry
|
|
33
|
+
}
|
|
34
|
+
decrementTextureRefCount() {
|
|
35
|
+
// No-op for FinalizationRegistry
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=FinalizationRegistryTextureUsageTracker.js.map
|
package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FinalizationRegistryTextureUsageTracker.js","sourceRoot":"","sources":["../../../../src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,OAAO,uCAAwC,SAAQ,mBAAmB;IACtE,QAAQ,CAA+B;IAE/C,YAAY,eAAgD;QAC1D,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAoB,CAAC,eAAe,CAAC,CAAC;IAC5D,CAAC;IAEQ,eAAe,CAAC,OAAmB;QAC1C,YAAY,CACV,OAAO,CAAC,OAAO,EAAE,EAAE,EACnB,0CAA0C,CAC3C,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACvD,CAAC;IACQ,wBAAwB;QAC/B,iCAAiC;IACnC,CAAC;IACQ,wBAAwB;QAC/B,iCAAiC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { TextureRef } from '../RendererMain.js';
|
|
2
|
+
import { TextureUsageTracker } from './TextureUsageTracker.js';
|
|
3
|
+
interface TextureRefInfo {
|
|
4
|
+
/**
|
|
5
|
+
* Texture Reference ID
|
|
6
|
+
*/
|
|
7
|
+
id: number;
|
|
8
|
+
/**
|
|
9
|
+
* The number of references to this texture that are currently assigned to
|
|
10
|
+
* Nodes.
|
|
11
|
+
*/
|
|
12
|
+
nodeRefCount: number;
|
|
13
|
+
/**
|
|
14
|
+
* The last time the texture reference count was updated.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* This is used to determine when a texture is no longer referenced by any
|
|
18
|
+
* Nodes and can be removed from the GPU.
|
|
19
|
+
*/
|
|
20
|
+
lastUpdate: number;
|
|
21
|
+
}
|
|
22
|
+
export interface ManualCountTextureUsageTrackerOptions {
|
|
23
|
+
/**
|
|
24
|
+
* The interval at which to check if textures that are no longer referenced
|
|
25
|
+
* by any Nodes can be released from the Core Space Texture Usage Cache.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Only valid when the {@link ManualCountTextureUsageTracker} is used.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue 10000 (10 seconds)
|
|
31
|
+
*/
|
|
32
|
+
textureCleanupIntervalMs?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The age at which a texture is considered to be no longer referenced by any
|
|
35
|
+
* Nodes and can be released from the Core Space Texture Usage Cache.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* Only valid when the {@link ManualCountTextureUsageTracker} is used.
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue 60000 (1 minute)
|
|
41
|
+
*/
|
|
42
|
+
textureCleanupAgeThreadholdMs?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Usage-based Texture Garbage Collection Registry
|
|
46
|
+
*/
|
|
47
|
+
export declare class ManualCountTextureUsageTracker extends TextureUsageTracker {
|
|
48
|
+
textureMap: Map<number, TextureRefInfo>;
|
|
49
|
+
zeroReferenceTextureSet: Set<TextureRefInfo>;
|
|
50
|
+
options: Required<ManualCountTextureUsageTrackerOptions>;
|
|
51
|
+
constructor(releaseCallback: (textureDescId: number) => void, options: ManualCountTextureUsageTrackerOptions);
|
|
52
|
+
registerTexture(texture: TextureRef): void;
|
|
53
|
+
incrementTextureRefCount(texture: TextureRef): void;
|
|
54
|
+
decrementTextureRefCount(texture: TextureRef): void;
|
|
55
|
+
}
|
|
56
|
+
export {};
|