@babylonjs/core 7.45.0 → 7.46.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/Buffers/bufferUtils.d.ts +28 -1
- package/Buffers/bufferUtils.js +104 -1
- package/Buffers/bufferUtils.js.map +1 -1
- package/Decorators/nodeDecorator.js +1 -1
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +2 -1
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.js +1 -1
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.js +2 -1
- package/Engines/thinEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +5 -0
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +7 -0
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +3 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +13 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +0 -3
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +0 -13
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js +3 -0
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +9 -5
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +1 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +11 -0
- package/FrameGraph/Passes/renderPass.js +40 -0
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.js +3 -2
- package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Layers/highlightLayerTask.js +1 -1
- package/FrameGraph/Tasks/Layers/highlightLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +2 -2
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +1 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +2 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js +1 -0
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +5 -5
- package/FrameGraph/frameGraph.js +31 -21
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +8 -2
- package/FrameGraph/frameGraphTask.js +12 -12
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +33 -2
- package/FrameGraph/frameGraphTextureManager.js +368 -27
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/Lights/LTC/ltcTextureTool.d.ts +20 -0
- package/Lights/LTC/ltcTextureTool.js +24 -0
- package/Lights/LTC/ltcTextureTool.js.map +1 -0
- package/Lights/Shadows/shadowGenerator.d.ts +10 -0
- package/Lights/Shadows/shadowGenerator.js +5 -0
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGeneratorSceneComponent.js +6 -0
- package/Lights/Shadows/shadowGeneratorSceneComponent.js.map +1 -1
- package/Lights/areaLight.d.ts +39 -0
- package/Lights/areaLight.js +81 -0
- package/Lights/areaLight.js.map +1 -0
- package/Lights/index.d.ts +2 -0
- package/Lights/index.js +2 -0
- package/Lights/index.js.map +1 -1
- package/Lights/light.d.ts +8 -0
- package/Lights/light.js +10 -0
- package/Lights/light.js.map +1 -1
- package/Lights/lightConstants.d.ts +4 -0
- package/Lights/lightConstants.js +4 -0
- package/Lights/lightConstants.js.map +1 -1
- package/Lights/rectAreaLight.d.ts +61 -0
- package/Lights/rectAreaLight.js +127 -0
- package/Lights/rectAreaLight.js.map +1 -0
- package/Loading/loadingScreen.d.ts +21 -1
- package/Loading/loadingScreen.js +125 -52
- package/Loading/loadingScreen.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +2 -0
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +2 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/debugBlock.d.ts +38 -0
- package/Materials/Node/Blocks/debugBlock.js +92 -0
- package/Materials/Node/Blocks/debugBlock.js.map +1 -0
- package/Materials/Node/Blocks/index.d.ts +1 -0
- package/Materials/Node/Blocks/index.js +1 -0
- package/Materials/Node/Blocks/index.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -0
- package/Materials/Node/nodeMaterial.js +20 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.d.ts +8 -1
- package/Materials/Node/nodeMaterialBlock.js +13 -1
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/PBR/index.d.ts +1 -0
- package/Materials/PBR/index.js +1 -0
- package/Materials/PBR/index.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +13 -0
- package/Materials/PBR/pbrBaseMaterial.js +60 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +8 -0
- package/Materials/PBR/pbrMaterial.js +12 -0
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +0 -18
- package/Materials/Textures/internalTexture.js +0 -46
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/rawTexture.d.ts +6 -2
- package/Materials/Textures/rawTexture.js +10 -3
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/textureHelper.functions.d.ts +18 -0
- package/Materials/Textures/textureHelper.functions.js +47 -0
- package/Materials/Textures/textureHelper.functions.js.map +1 -0
- package/Materials/materialFlags.d.ts +6 -0
- package/Materials/materialFlags.js +14 -0
- package/Materials/materialFlags.js.map +1 -1
- package/Materials/materialHelper.functions.js +3 -1
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.d.ts +1 -0
- package/Materials/standardMaterial.js +14 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Compression/dracoCompressionWorker.js +0 -1
- package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
- package/Misc/timingTools.d.ts +2 -2
- package/Misc/timingTools.js +15 -10
- package/Misc/timingTools.js.map +1 -1
- package/Particles/gpuParticleSystem.js +8 -2
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.d.ts +4 -0
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +66 -16
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +8 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +16 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +9 -0
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +28 -11
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js +1 -1
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +19 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightUboDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +14 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/ltcHelperFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/ltcHelperFunctions.js +31 -0
- package/Shaders/ShadersInclude/ltcHelperFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +11 -2
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +6 -0
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.d.ts +1 -0
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js +18 -1
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +6 -3
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +4 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +5 -2
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/iblShadowAccumulation.fragment.js +6 -5
- package/Shaders/iblShadowAccumulation.fragment.js.map +1 -1
- package/Shaders/iblShadowSpatialBlur.fragment.js +3 -3
- package/Shaders/iblShadowSpatialBlur.fragment.js.map +1 -1
- package/Shaders/iblShadowVoxelTracing.fragment.js +26 -8
- package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/Shaders/pbr.fragment.js +11 -3
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +19 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +4 -0
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +4 -0
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +12 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.js +35 -0
- package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.js +10 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +4 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +18 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +4 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/iblShadowAccumulation.fragment.js +4 -3
- package/ShadersWGSL/iblShadowAccumulation.fragment.js.map +1 -1
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js +3 -3
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js.map +1 -1
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +26 -8
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +10 -2
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +2 -0
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/Sprites/spriteRenderer.js +1 -0
- package/Sprites/spriteRenderer.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,8 +2,10 @@ import { getDimensionsFromTextureSize, textureSizeIsObject } from "../Materials/
|
|
|
2
2
|
import { Texture } from "../Materials/Textures/texture.js";
|
|
3
3
|
import { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from "./frameGraphTypes.js";
|
|
4
4
|
|
|
5
|
-
import { GetTypeForDepthTexture, IsDepthTexture, HasStencilAspect } from "../Materials/Textures/internalTexture.js";
|
|
6
5
|
import { FrameGraphRenderTarget } from "./frameGraphRenderTarget.js";
|
|
6
|
+
import { FrameGraphRenderPass } from "./Passes/renderPass.js";
|
|
7
|
+
import { Logger } from "../Misc/logger.js";
|
|
8
|
+
import { GetTypeForDepthTexture, IsDepthTexture, HasStencilAspect } from "../Materials/Textures/textureHelper.functions.js";
|
|
7
9
|
var FrameGraphTextureNamespace;
|
|
8
10
|
(function (FrameGraphTextureNamespace) {
|
|
9
11
|
FrameGraphTextureNamespace[FrameGraphTextureNamespace["Task"] = 0] = "Task";
|
|
@@ -31,6 +33,10 @@ export class FrameGraphTextureManager {
|
|
|
31
33
|
this._historyTextures = new Map();
|
|
32
34
|
/** @internal */
|
|
33
35
|
this._isRecordingTask = false;
|
|
36
|
+
/**
|
|
37
|
+
* Gets or sets a boolean indicating if debug logs should be shown when applying texture allocation optimization (default: false)
|
|
38
|
+
*/
|
|
39
|
+
this.showDebugLogsForTextureAllcationOptimization = false;
|
|
34
40
|
this._addSystemTextures();
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
@@ -276,12 +282,48 @@ export class FrameGraphTextureManager {
|
|
|
276
282
|
height: Math.floor((height * screenHeight) / 100),
|
|
277
283
|
};
|
|
278
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Calculates the total byte size of all textures used by the frame graph texture manager (including external textures)
|
|
287
|
+
* @param optimizedSize True if the calculation should not factor in aliased textures
|
|
288
|
+
* @param outputWidth The output width of the frame graph. Will be used to calculate the size of percentage-based textures
|
|
289
|
+
* @param outputHeight The output height of the frame graph. Will be used to calculate the size of percentage-based textures
|
|
290
|
+
* @returns The total size of all textures
|
|
291
|
+
*/
|
|
292
|
+
computeTotalTextureSize(optimizedSize, outputWidth, outputHeight) {
|
|
293
|
+
let totalSize = 0;
|
|
294
|
+
this._textures.forEach((entry, handle) => {
|
|
295
|
+
if (handle === backbufferColorTextureHandle || handle === backbufferDepthStencilTextureHandle || entry.refHandle !== undefined) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (optimizedSize && entry.aliasHandle !== undefined) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const options = entry.creationOptions;
|
|
302
|
+
const textureIndex = entry.textureIndex || 0;
|
|
303
|
+
const dimensions = options.sizeIsPercentage ? this.getAbsoluteDimensions(options.size, outputWidth, outputHeight) : getDimensionsFromTextureSize(options.size);
|
|
304
|
+
const blockInfo = FrameGraphTextureManager._GetTextureBlockInformation(options.options.types?.[textureIndex] ?? 0, options.options.formats[textureIndex]);
|
|
305
|
+
const textureByteSize = Math.ceil(dimensions.width / blockInfo.width) * Math.ceil(dimensions.height / blockInfo.height) * blockInfo.length;
|
|
306
|
+
let byteSize = textureByteSize;
|
|
307
|
+
if (options.options.createMipMaps) {
|
|
308
|
+
byteSize = Math.floor((byteSize * 4) / 3);
|
|
309
|
+
}
|
|
310
|
+
if ((options.options.samples || 1) > 1) {
|
|
311
|
+
// We need an additional texture in the case of MSAA
|
|
312
|
+
byteSize += textureByteSize;
|
|
313
|
+
}
|
|
314
|
+
totalSize += byteSize;
|
|
315
|
+
});
|
|
316
|
+
return totalSize;
|
|
317
|
+
}
|
|
279
318
|
/** @internal */
|
|
280
319
|
_dispose() {
|
|
281
320
|
this._releaseTextures();
|
|
282
321
|
}
|
|
283
322
|
/** @internal */
|
|
284
|
-
_allocateTextures() {
|
|
323
|
+
_allocateTextures(tasks) {
|
|
324
|
+
if (tasks) {
|
|
325
|
+
this._optimizeTextureAllocation(tasks);
|
|
326
|
+
}
|
|
285
327
|
this._textures.forEach((entry) => {
|
|
286
328
|
if (!entry.texture) {
|
|
287
329
|
if (entry.refHandle !== undefined) {
|
|
@@ -297,32 +339,39 @@ export class FrameGraphTextureManager {
|
|
|
297
339
|
}
|
|
298
340
|
}
|
|
299
341
|
else if (entry.namespace !== FrameGraphTextureNamespace.External) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
342
|
+
if (entry.aliasHandle !== undefined) {
|
|
343
|
+
const aliasEntry = this._textures.get(entry.aliasHandle);
|
|
344
|
+
entry.texture = aliasEntry.texture;
|
|
345
|
+
entry.texture.incrementReferences();
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
const creationOptions = entry.creationOptions;
|
|
349
|
+
const size = creationOptions.sizeIsPercentage ? this.getAbsoluteDimensions(creationOptions.size) : creationOptions.size;
|
|
350
|
+
const textureIndex = entry.textureIndex || 0;
|
|
351
|
+
const internalTextureCreationOptions = {
|
|
352
|
+
createMipMaps: creationOptions.options.createMipMaps,
|
|
353
|
+
samples: creationOptions.options.samples,
|
|
354
|
+
type: creationOptions.options.types?.[textureIndex],
|
|
355
|
+
format: creationOptions.options.formats?.[textureIndex],
|
|
356
|
+
useSRGBBuffer: creationOptions.options.useSRGBBuffers?.[textureIndex],
|
|
357
|
+
creationFlags: creationOptions.options.creationFlags?.[textureIndex],
|
|
358
|
+
label: creationOptions.options.labels?.[textureIndex] ?? `${entry.name}${textureIndex > 0 ? "#" + textureIndex : ""}`,
|
|
359
|
+
samplingMode: 1,
|
|
360
|
+
createMSAATexture: creationOptions.options.samples > 1,
|
|
361
|
+
};
|
|
362
|
+
const isDepthTexture = IsDepthTexture(internalTextureCreationOptions.format);
|
|
363
|
+
const hasStencil = HasStencilAspect(internalTextureCreationOptions.format);
|
|
364
|
+
const source = isDepthTexture && hasStencil
|
|
365
|
+
? 12 /* InternalTextureSource.DepthStencil */
|
|
366
|
+
: isDepthTexture || hasStencil
|
|
367
|
+
? 14 /* InternalTextureSource.Depth */
|
|
368
|
+
: 5 /* InternalTextureSource.RenderTarget */;
|
|
369
|
+
const internalTexture = this.engine._createInternalTexture(size, internalTextureCreationOptions, false, source);
|
|
370
|
+
if (isDepthTexture) {
|
|
371
|
+
internalTexture.type = GetTypeForDepthTexture(internalTexture.format);
|
|
372
|
+
}
|
|
373
|
+
entry.texture = internalTexture;
|
|
324
374
|
}
|
|
325
|
-
entry.texture = internalTexture;
|
|
326
375
|
}
|
|
327
376
|
}
|
|
328
377
|
if (entry.texture && entry.refHandle === undefined) {
|
|
@@ -339,6 +388,11 @@ export class FrameGraphTextureManager {
|
|
|
339
388
|
/** @internal */
|
|
340
389
|
_releaseTextures(releaseAll = true) {
|
|
341
390
|
this._textures.forEach((entry, handle) => {
|
|
391
|
+
if (entry.lifespan) {
|
|
392
|
+
entry.lifespan.firstTask = Number.MAX_VALUE;
|
|
393
|
+
entry.lifespan.lastTask = 0;
|
|
394
|
+
}
|
|
395
|
+
entry.aliasHandle = undefined;
|
|
342
396
|
if (releaseAll || entry.namespace !== FrameGraphTextureNamespace.External) {
|
|
343
397
|
entry.debug?.dispose();
|
|
344
398
|
entry.debug = undefined;
|
|
@@ -450,6 +504,11 @@ export class FrameGraphTextureManager {
|
|
|
450
504
|
},
|
|
451
505
|
namespace,
|
|
452
506
|
textureIndex,
|
|
507
|
+
textureDescriptionHash: this._createTextureDescriptionHash(creationOptions),
|
|
508
|
+
lifespan: {
|
|
509
|
+
firstTask: Number.MAX_VALUE,
|
|
510
|
+
lastTask: 0,
|
|
511
|
+
},
|
|
453
512
|
};
|
|
454
513
|
this._textures.set(handle, textureEntry);
|
|
455
514
|
if (namespace === FrameGraphTextureNamespace.External) {
|
|
@@ -480,6 +539,138 @@ export class FrameGraphTextureManager {
|
|
|
480
539
|
}
|
|
481
540
|
return handle;
|
|
482
541
|
}
|
|
542
|
+
_createTextureDescriptionHash(options) {
|
|
543
|
+
const hash = [];
|
|
544
|
+
hash.push(textureSizeIsObject(options.size) ? `${options.size.width}_${options.size.height}` : `${options.size}`);
|
|
545
|
+
hash.push(options.sizeIsPercentage ? "%" : "A");
|
|
546
|
+
hash.push(options.options.createMipMaps ? "M" : "N");
|
|
547
|
+
hash.push(options.options.samples ? `${options.options.samples}` : "S1");
|
|
548
|
+
hash.push(options.options.types ? options.options.types.join("_") : `${0}`);
|
|
549
|
+
hash.push(options.options.formats ? options.options.formats.join("_") : `${5}`);
|
|
550
|
+
hash.push(options.options.useSRGBBuffers ? options.options.useSRGBBuffers.join("_") : "false");
|
|
551
|
+
hash.push(options.options.creationFlags ? options.options.creationFlags.join("_") : "0");
|
|
552
|
+
return hash.join("_");
|
|
553
|
+
}
|
|
554
|
+
_optimizeTextureAllocation(tasks) {
|
|
555
|
+
this._computeTextureLifespan(tasks);
|
|
556
|
+
if (this.showDebugLogsForTextureAllcationOptimization) {
|
|
557
|
+
Logger.Log(`================== Optimization of texture allocation ==================`);
|
|
558
|
+
}
|
|
559
|
+
const cache = new Map();
|
|
560
|
+
const iterator = this._textures.keys();
|
|
561
|
+
for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
|
|
562
|
+
const textureHandle = key.value;
|
|
563
|
+
const textureEntry = this._textures.get(textureHandle);
|
|
564
|
+
if (textureEntry.refHandle !== undefined || textureEntry.namespace === FrameGraphTextureNamespace.External || this._historyTextures.has(textureHandle)) {
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
const textureHash = textureEntry.textureDescriptionHash;
|
|
568
|
+
const textureLifespan = textureEntry.lifespan;
|
|
569
|
+
const cacheEntries = cache.get(textureHash);
|
|
570
|
+
if (cacheEntries) {
|
|
571
|
+
let cacheEntryFound = false;
|
|
572
|
+
for (const cacheEntry of cacheEntries) {
|
|
573
|
+
const [sourceHandle, lifespanArray] = cacheEntry;
|
|
574
|
+
let overlapped = false;
|
|
575
|
+
for (const lifespan of lifespanArray) {
|
|
576
|
+
if (lifespan.firstTask <= textureLifespan.lastTask && lifespan.lastTask >= textureLifespan.firstTask) {
|
|
577
|
+
overlapped = true;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (!overlapped) {
|
|
582
|
+
// No overlap between texture lifespan and all lifespans in the array, this texture can reuse the same entry cache
|
|
583
|
+
if (this.showDebugLogsForTextureAllcationOptimization) {
|
|
584
|
+
Logger.Log(`Texture ${textureHandle} (${textureEntry.name}) reuses cache entry ${sourceHandle}`);
|
|
585
|
+
}
|
|
586
|
+
lifespanArray.push(textureLifespan);
|
|
587
|
+
textureEntry.aliasHandle = sourceHandle;
|
|
588
|
+
cacheEntryFound = true;
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (!cacheEntryFound) {
|
|
593
|
+
cacheEntries.push([textureHandle, [textureLifespan]]);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
cache.set(textureHash, [[textureHandle, [textureLifespan]]]);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
// Loop through all task/pass dependencies and compute the lifespan of each texture (that is, the first task/pass that uses it and the last task/pass that uses it)
|
|
602
|
+
_computeTextureLifespan(tasks) {
|
|
603
|
+
if (this.showDebugLogsForTextureAllcationOptimization) {
|
|
604
|
+
Logger.Log(`================== Dump of texture dependencies for all tasks/passes ==================`);
|
|
605
|
+
}
|
|
606
|
+
for (let t = 0; t < tasks.length; ++t) {
|
|
607
|
+
const task = tasks[t];
|
|
608
|
+
if (task.passes.length > 0) {
|
|
609
|
+
this._computeTextureLifespanForPasses(task, t, task.passes);
|
|
610
|
+
}
|
|
611
|
+
if (task.passesDisabled.length > 0) {
|
|
612
|
+
this._computeTextureLifespanForPasses(task, t, task.passesDisabled);
|
|
613
|
+
}
|
|
614
|
+
if (task.dependencies) {
|
|
615
|
+
if (this.showDebugLogsForTextureAllcationOptimization) {
|
|
616
|
+
Logger.Log(`task#${t} (${task.name}), global dependencies`);
|
|
617
|
+
}
|
|
618
|
+
this._updateLifespan(t * 100 + 99, task.dependencies);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
if (this.showDebugLogsForTextureAllcationOptimization) {
|
|
622
|
+
Logger.Log(`================== Texture lifespans ==================`);
|
|
623
|
+
const iterator = this._textures.keys();
|
|
624
|
+
for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
|
|
625
|
+
const textureHandle = key.value;
|
|
626
|
+
const textureEntry = this._textures.get(textureHandle);
|
|
627
|
+
if (textureEntry.refHandle !== undefined || textureEntry.namespace === FrameGraphTextureNamespace.External || this._historyTextures.has(textureHandle)) {
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
Logger.Log(`${textureHandle} (${textureEntry.name}): ${textureEntry.lifespan.firstTask} - ${textureEntry.lifespan.lastTask}`);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
_computeTextureLifespanForPasses(task, taskIndex, passes) {
|
|
635
|
+
for (let p = 0; p < passes.length; ++p) {
|
|
636
|
+
const dependencies = new Set();
|
|
637
|
+
const pass = passes[p];
|
|
638
|
+
if (!FrameGraphRenderPass.IsRenderPass(pass)) {
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
pass.collectDependencies(dependencies);
|
|
642
|
+
if (this.showDebugLogsForTextureAllcationOptimization) {
|
|
643
|
+
Logger.Log(`task#${taskIndex} (${task.name}), pass#${p} (${pass.name})`);
|
|
644
|
+
}
|
|
645
|
+
this._updateLifespan(taskIndex * 100 + p, dependencies);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
_updateLifespan(passOrderNum, dependencies) {
|
|
649
|
+
const iterator = dependencies.keys();
|
|
650
|
+
for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
|
|
651
|
+
const textureHandle = key.value;
|
|
652
|
+
let textureEntry = this._textures.get(textureHandle);
|
|
653
|
+
if (!textureEntry) {
|
|
654
|
+
throw new Error(`FrameGraph._computeTextureLifespan: Texture handle "${textureHandle}" not found in the texture manager.`);
|
|
655
|
+
}
|
|
656
|
+
let handle = textureHandle;
|
|
657
|
+
while (textureEntry.refHandle !== undefined) {
|
|
658
|
+
handle = textureEntry.refHandle;
|
|
659
|
+
textureEntry = this._textures.get(handle);
|
|
660
|
+
if (!textureEntry) {
|
|
661
|
+
throw new Error(`FrameGraph._computeTextureLifespan: Texture handle "${handle}" not found in the texture manager (source handle="${textureHandle}").`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (textureEntry.namespace === FrameGraphTextureNamespace.External || this._historyTextures.has(handle)) {
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
if (this.showDebugLogsForTextureAllcationOptimization) {
|
|
668
|
+
Logger.Log(` ${handle} (${textureEntry.name})`);
|
|
669
|
+
}
|
|
670
|
+
textureEntry.lifespan.firstTask = Math.min(textureEntry.lifespan.firstTask, passOrderNum);
|
|
671
|
+
textureEntry.lifespan.lastTask = Math.max(textureEntry.lifespan.lastTask, passOrderNum);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
483
674
|
/**
|
|
484
675
|
* Clones a texture options
|
|
485
676
|
* @param options The options to clone
|
|
@@ -507,6 +698,156 @@ export class FrameGraphTextureManager {
|
|
|
507
698
|
labels: options.labels ? [...options.labels] : undefined,
|
|
508
699
|
};
|
|
509
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* Gets the texture block information.
|
|
703
|
+
* @param type Type of the texture.
|
|
704
|
+
* @param format Format of the texture.
|
|
705
|
+
* @returns The texture block information. You can calculate the byte size of the texture by doing: Math.ceil(width / blockInfo.width) * Math.ceil(height / blockInfo.height) * blockInfo.length
|
|
706
|
+
*/
|
|
707
|
+
static _GetTextureBlockInformation(type, format) {
|
|
708
|
+
switch (format) {
|
|
709
|
+
case 15:
|
|
710
|
+
return { width: 1, height: 1, length: 2 };
|
|
711
|
+
case 16:
|
|
712
|
+
return { width: 1, height: 1, length: 3 };
|
|
713
|
+
case 13:
|
|
714
|
+
return { width: 1, height: 1, length: 4 };
|
|
715
|
+
case 14:
|
|
716
|
+
return { width: 1, height: 1, length: 4 };
|
|
717
|
+
case 18:
|
|
718
|
+
return { width: 1, height: 1, length: 5 };
|
|
719
|
+
case 19:
|
|
720
|
+
return { width: 1, height: 1, length: 1 };
|
|
721
|
+
case 36492:
|
|
722
|
+
return { width: 4, height: 4, length: 16 };
|
|
723
|
+
case 36495:
|
|
724
|
+
return { width: 4, height: 4, length: 16 };
|
|
725
|
+
case 36494:
|
|
726
|
+
return { width: 4, height: 4, length: 16 };
|
|
727
|
+
case 33779:
|
|
728
|
+
return { width: 4, height: 4, length: 16 };
|
|
729
|
+
case 33778:
|
|
730
|
+
return { width: 4, height: 4, length: 16 };
|
|
731
|
+
case 33777:
|
|
732
|
+
case 33776:
|
|
733
|
+
return { width: 4, height: 4, length: 8 };
|
|
734
|
+
case 37808:
|
|
735
|
+
return { width: 4, height: 4, length: 16 };
|
|
736
|
+
case 36196:
|
|
737
|
+
case 37492:
|
|
738
|
+
return { width: 4, height: 4, length: 8 };
|
|
739
|
+
case 37496:
|
|
740
|
+
return { width: 4, height: 4, length: 16 };
|
|
741
|
+
}
|
|
742
|
+
switch (type) {
|
|
743
|
+
case 3:
|
|
744
|
+
case 0:
|
|
745
|
+
switch (format) {
|
|
746
|
+
case 6:
|
|
747
|
+
case 8:
|
|
748
|
+
case 0:
|
|
749
|
+
case 1:
|
|
750
|
+
case 2:
|
|
751
|
+
return { width: 1, height: 1, length: 1 };
|
|
752
|
+
case 7:
|
|
753
|
+
case 9:
|
|
754
|
+
return { width: 1, height: 1, length: 2 };
|
|
755
|
+
case 4:
|
|
756
|
+
case 10:
|
|
757
|
+
return { width: 1, height: 1, length: 3 };
|
|
758
|
+
case 11:
|
|
759
|
+
return { width: 1, height: 1, length: 4 };
|
|
760
|
+
default:
|
|
761
|
+
return { width: 1, height: 1, length: 4 };
|
|
762
|
+
}
|
|
763
|
+
case 4:
|
|
764
|
+
case 5:
|
|
765
|
+
switch (format) {
|
|
766
|
+
case 8:
|
|
767
|
+
return { width: 1, height: 1, length: 2 };
|
|
768
|
+
case 9:
|
|
769
|
+
return { width: 1, height: 1, length: 4 };
|
|
770
|
+
case 10:
|
|
771
|
+
return { width: 1, height: 1, length: 6 };
|
|
772
|
+
case 11:
|
|
773
|
+
return { width: 1, height: 1, length: 8 };
|
|
774
|
+
default:
|
|
775
|
+
return { width: 1, height: 1, length: 8 };
|
|
776
|
+
}
|
|
777
|
+
case 6:
|
|
778
|
+
case 7: // Refers to UNSIGNED_INT
|
|
779
|
+
switch (format) {
|
|
780
|
+
case 8:
|
|
781
|
+
return { width: 1, height: 1, length: 4 };
|
|
782
|
+
case 9:
|
|
783
|
+
return { width: 1, height: 1, length: 8 };
|
|
784
|
+
case 10:
|
|
785
|
+
return { width: 1, height: 1, length: 12 };
|
|
786
|
+
case 11:
|
|
787
|
+
return { width: 1, height: 1, length: 16 };
|
|
788
|
+
default:
|
|
789
|
+
return { width: 1, height: 1, length: 16 };
|
|
790
|
+
}
|
|
791
|
+
case 1:
|
|
792
|
+
switch (format) {
|
|
793
|
+
case 6:
|
|
794
|
+
return { width: 1, height: 1, length: 4 };
|
|
795
|
+
case 7:
|
|
796
|
+
return { width: 1, height: 1, length: 8 };
|
|
797
|
+
case 4:
|
|
798
|
+
return { width: 1, height: 1, length: 12 };
|
|
799
|
+
case 5:
|
|
800
|
+
return { width: 1, height: 1, length: 16 };
|
|
801
|
+
default:
|
|
802
|
+
return { width: 1, height: 1, length: 16 };
|
|
803
|
+
}
|
|
804
|
+
case 2:
|
|
805
|
+
switch (format) {
|
|
806
|
+
case 6:
|
|
807
|
+
return { width: 1, height: 1, length: 2 };
|
|
808
|
+
case 7:
|
|
809
|
+
return { width: 1, height: 1, length: 4 };
|
|
810
|
+
case 4:
|
|
811
|
+
return { width: 1, height: 1, length: 6 };
|
|
812
|
+
case 5:
|
|
813
|
+
return { width: 1, height: 1, length: 8 };
|
|
814
|
+
default:
|
|
815
|
+
return { width: 1, height: 1, length: 8 };
|
|
816
|
+
}
|
|
817
|
+
case 10:
|
|
818
|
+
return { width: 1, height: 1, length: 2 };
|
|
819
|
+
case 13:
|
|
820
|
+
switch (format) {
|
|
821
|
+
case 5:
|
|
822
|
+
case 11:
|
|
823
|
+
return { width: 1, height: 1, length: 4 };
|
|
824
|
+
default:
|
|
825
|
+
return { width: 1, height: 1, length: 4 };
|
|
826
|
+
}
|
|
827
|
+
case 14:
|
|
828
|
+
switch (format) {
|
|
829
|
+
case 5:
|
|
830
|
+
case 11:
|
|
831
|
+
return { width: 1, height: 1, length: 4 };
|
|
832
|
+
default:
|
|
833
|
+
return { width: 1, height: 1, length: 4 };
|
|
834
|
+
}
|
|
835
|
+
case 8:
|
|
836
|
+
return { width: 1, height: 1, length: 2 };
|
|
837
|
+
case 9:
|
|
838
|
+
return { width: 1, height: 1, length: 2 };
|
|
839
|
+
case 11:
|
|
840
|
+
switch (format) {
|
|
841
|
+
case 5:
|
|
842
|
+
return { width: 1, height: 1, length: 4 };
|
|
843
|
+
case 11:
|
|
844
|
+
return { width: 1, height: 1, length: 4 };
|
|
845
|
+
default:
|
|
846
|
+
return { width: 1, height: 1, length: 4 };
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return { width: 1, height: 1, length: 4 };
|
|
850
|
+
}
|
|
510
851
|
}
|
|
511
852
|
FrameGraphTextureManager._Counter = 2; // 0 and 1 are reserved for backbuffer textures
|
|
512
853
|
//# sourceMappingURL=frameGraphTextureManager.js.map
|