@babylonjs/smart-filters 1.0.12 → 8.18.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/dist/blockFoundation/aggregateBlock.d.ts +3 -3
- package/dist/blockFoundation/aggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/aggregateBlock.js +1 -2
- package/dist/blockFoundation/aggregateBlock.js.map +1 -1
- package/dist/blockFoundation/baseBlock.d.ts +2 -2
- package/dist/blockFoundation/baseBlock.d.ts.map +1 -1
- package/dist/blockFoundation/baseBlock.js +5 -6
- package/dist/blockFoundation/baseBlock.js.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.js +2 -2
- package/dist/blockFoundation/customAggregateBlock.js.map +1 -1
- package/dist/blockFoundation/customShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customShaderBlock.js +4 -6
- package/dist/blockFoundation/customShaderBlock.js.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.js +4 -4
- package/dist/blockFoundation/disableableShaderBlock.js.map +1 -1
- package/dist/blockFoundation/index.js +0 -2
- package/dist/blockFoundation/index.js.map +1 -1
- package/dist/blockFoundation/inputBlock.d.ts +8 -8
- package/dist/blockFoundation/inputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js.map +1 -1
- package/dist/blockFoundation/inputBlock.js +7 -7
- package/dist/blockFoundation/inputBlock.js.map +1 -1
- package/dist/blockFoundation/inputBlock.serialization.types.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.serializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.serializer.js +26 -28
- package/dist/blockFoundation/inputBlock.serializer.js.map +1 -1
- package/dist/blockFoundation/outputBlock.d.ts +4 -9
- package/dist/blockFoundation/outputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/outputBlock.js +13 -14
- package/dist/blockFoundation/outputBlock.js.map +1 -1
- package/dist/blockFoundation/shaderBlock.d.ts +4 -4
- package/dist/blockFoundation/shaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/shaderBlock.js +13 -19
- package/dist/blockFoundation/shaderBlock.js.map +1 -1
- package/dist/blockFoundation/textureOptions.d.ts +1 -1
- package/dist/blockFoundation/textureOptions.js +1 -1
- package/dist/command/command.d.ts +1 -1
- package/dist/command/command.js +1 -1
- package/dist/command/commandBuffer.d.ts +1 -1
- package/dist/command/commandBuffer.d.ts.map +1 -1
- package/dist/command/commandBuffer.js +2 -2
- package/dist/command/commandBufferDebugger.d.ts +2 -2
- package/dist/command/commandBufferDebugger.d.ts.map +1 -1
- package/dist/command/commandBufferDebugger.js +1 -1
- package/dist/command/commandBufferDebugger.js.map +1 -1
- package/dist/command/index.d.ts +3 -1
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +5 -1
- package/dist/command/index.js.map +1 -1
- package/dist/connection/connectionPoint.d.ts +3 -3
- package/dist/connection/connectionPoint.d.ts.map +1 -1
- package/dist/connection/connectionPoint.js +2 -2
- package/dist/connection/connectionPoint.js.map +1 -1
- package/dist/connection/connectionPointCompatibilityState.d.ts +1 -1
- package/dist/connection/connectionPointCompatibilityState.js +1 -1
- package/dist/connection/connectionPointType.d.ts +3 -3
- package/dist/connection/connectionPointType.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.d.ts +3 -3
- package/dist/connection/connectionPointWithDefault.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.js.map +1 -1
- package/dist/connection/index.d.ts +2 -1
- package/dist/connection/index.d.ts.map +1 -1
- package/dist/connection/index.js +3 -3
- package/dist/connection/index.js.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.d.ts +2 -2
- package/dist/editorUtils/editableInPropertyPage.d.ts.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.js +2 -2
- package/dist/editorUtils/editableInPropertyPage.js.map +1 -1
- package/dist/editorUtils/index.d.ts +1 -0
- package/dist/editorUtils/index.d.ts.map +1 -1
- package/dist/editorUtils/index.js +2 -0
- package/dist/editorUtils/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/optimization/dependencyGraph.js.map +1 -1
- package/dist/optimization/optimizedShaderBlock.d.ts +4 -4
- package/dist/optimization/optimizedShaderBlock.d.ts.map +1 -1
- package/dist/optimization/optimizedShaderBlock.js.map +1 -1
- package/dist/optimization/smartFilterOptimizer.d.ts +2 -2
- package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -1
- package/dist/optimization/smartFilterOptimizer.js +34 -57
- package/dist/optimization/smartFilterOptimizer.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts.map +1 -1
- package/dist/runtime/renderTargetGenerator.js +5 -7
- package/dist/runtime/renderTargetGenerator.js.map +1 -1
- package/dist/runtime/shaderRuntime.d.ts +7 -7
- package/dist/runtime/shaderRuntime.d.ts.map +1 -1
- package/dist/runtime/shaderRuntime.js +7 -8
- package/dist/runtime/shaderRuntime.js.map +1 -1
- package/dist/runtime/smartFilterRuntime.d.ts +3 -3
- package/dist/runtime/smartFilterRuntime.d.ts.map +1 -1
- package/dist/runtime/smartFilterRuntime.js.map +1 -1
- package/dist/runtime/strongRef.d.ts +1 -1
- package/dist/runtime/strongRef.js +1 -1
- package/dist/serialization/importCustomBlockDefinition.d.ts +1 -1
- package/dist/serialization/importCustomBlockDefinition.js +8 -9
- package/dist/serialization/importCustomBlockDefinition.js.map +1 -1
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +3 -0
- package/dist/serialization/index.js.map +1 -1
- package/dist/serialization/serializedBlockDefinition.d.ts +2 -2
- package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.d.ts +6 -6
- package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.js +14 -12
- package/dist/serialization/smartFilterDeserializer.js.map +1 -1
- package/dist/serialization/smartFilterSerializer.d.ts +2 -2
- package/dist/serialization/smartFilterSerializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterSerializer.js +10 -13
- package/dist/serialization/smartFilterSerializer.js.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.d.ts +2 -2
- package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.js +3 -1
- package/dist/serialization/v1/defaultBlockSerializer.js.map +1 -1
- package/dist/serialization/v1/index.d.ts +1 -0
- package/dist/serialization/v1/index.d.ts.map +1 -1
- package/dist/serialization/v1/index.js +2 -0
- package/dist/serialization/v1/index.js.map +1 -1
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts +3 -3
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts.map +1 -1
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts +5 -2
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -1
- package/dist/smartFilter.d.ts +8 -8
- package/dist/smartFilter.d.ts.map +1 -1
- package/dist/smartFilter.js +6 -7
- package/dist/smartFilter.js.map +1 -1
- package/dist/utils/buildTools/buildShaders.d.ts +3 -2
- package/dist/utils/buildTools/buildShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/buildShaders.js +7 -6
- package/dist/utils/buildTools/buildShaders.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts +4 -2
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.js +136 -141
- package/dist/utils/buildTools/convertGlslIntoBlock.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts +4 -4
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js +55 -48
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js.map +1 -1
- package/dist/utils/buildTools/convertShaders.d.ts +8 -5
- package/dist/utils/buildTools/convertShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/convertShaders.js +38 -14
- package/dist/utils/buildTools/convertShaders.js.map +1 -1
- package/dist/utils/buildTools/shaderConverter.d.ts +4 -4
- package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -1
- package/dist/utils/buildTools/shaderConverter.js +17 -21
- package/dist/utils/buildTools/shaderConverter.js.map +1 -1
- package/dist/utils/buildTools/watchShaders.d.ts +3 -2
- package/dist/utils/buildTools/watchShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/watchShaders.js +10 -8
- package/dist/utils/buildTools/watchShaders.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/renderTargetUtils.d.ts +3 -3
- package/dist/utils/renderTargetUtils.d.ts.map +1 -1
- package/dist/utils/renderTargetUtils.js +4 -4
- package/dist/utils/renderTargetUtils.js.map +1 -1
- package/dist/utils/shaderCodeUtils.d.ts +8 -8
- package/dist/utils/shaderCodeUtils.d.ts.map +1 -1
- package/dist/utils/shaderCodeUtils.js +16 -28
- package/dist/utils/shaderCodeUtils.js.map +1 -1
- package/dist/utils/textureLoaders.d.ts +2 -2
- package/dist/utils/textureLoaders.d.ts.map +1 -1
- package/dist/utils/textureLoaders.js +2 -3
- package/dist/utils/textureLoaders.js.map +1 -1
- package/dist/utils/textureUtils.d.ts +5 -5
- package/dist/utils/textureUtils.d.ts.map +1 -1
- package/dist/utils/textureUtils.js +1 -1
- package/dist/utils/textureUtils.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/license.md +21 -21
- package/package.json +14 -9
- package/src/blockFoundation/aggregateBlock.ts +148 -151
- package/src/blockFoundation/baseBlock.ts +339 -364
- package/src/blockFoundation/customAggregateBlock.ts +88 -104
- package/src/blockFoundation/customShaderBlock.ts +312 -326
- package/src/blockFoundation/disableableShaderBlock.ts +91 -100
- package/src/blockFoundation/index.ts +9 -9
- package/src/blockFoundation/inputBlock.deserializer.ts +72 -97
- package/src/blockFoundation/inputBlock.serialization.types.ts +126 -132
- package/src/blockFoundation/inputBlock.serializer.ts +150 -150
- package/src/blockFoundation/inputBlock.ts +181 -192
- package/src/blockFoundation/outputBlock.ts +144 -151
- package/src/blockFoundation/shaderBlock.ts +156 -163
- package/src/blockFoundation/textureOptions.ts +57 -57
- package/src/command/command.ts +59 -59
- package/src/command/commandBuffer.ts +71 -71
- package/src/command/commandBufferDebugger.ts +14 -14
- package/src/command/index.ts +7 -3
- package/src/connection/connectionPoint.ts +205 -214
- package/src/connection/connectionPointCompatibilityState.ts +31 -31
- package/src/connection/connectionPointType.ts +45 -45
- package/src/connection/connectionPointWithDefault.ts +27 -35
- package/src/connection/index.ts +8 -9
- package/src/editorUtils/editableInPropertyPage.ts +106 -106
- package/src/editorUtils/index.ts +3 -1
- package/src/index.ts +16 -15
- package/src/optimization/dependencyGraph.ts +96 -96
- package/src/optimization/index.ts +1 -1
- package/src/optimization/optimizedShaderBlock.ts +131 -134
- package/src/optimization/smartFilterOptimizer.ts +757 -825
- package/src/runtime/index.ts +8 -6
- package/src/runtime/renderTargetGenerator.ts +222 -248
- package/src/runtime/shaderRuntime.ts +174 -173
- package/src/runtime/smartFilterRuntime.ts +112 -112
- package/src/runtime/strongRef.ts +18 -18
- package/src/serialization/importCustomBlockDefinition.ts +86 -86
- package/src/serialization/index.ts +10 -7
- package/src/serialization/serializedBlockDefinition.ts +12 -12
- package/src/serialization/serializedShaderBlockDefinition.ts +7 -7
- package/src/serialization/serializedSmartFilter.ts +6 -6
- package/src/serialization/smartFilterDeserializer.ts +190 -214
- package/src/serialization/smartFilterSerializer.ts +110 -121
- package/src/serialization/v1/defaultBlockSerializer.ts +21 -19
- package/src/serialization/v1/index.ts +4 -2
- package/src/serialization/v1/shaderBlockSerialization.types.ts +85 -85
- package/src/serialization/v1/smartFilterSerialization.types.ts +129 -129
- package/src/smartFilter.ts +255 -260
- package/src/utils/buildTools/buildShaders.ts +14 -13
- package/src/utils/buildTools/convertGlslIntoBlock.ts +370 -385
- package/src/utils/buildTools/convertGlslIntoShaderProgram.ts +173 -172
- package/src/utils/buildTools/convertShaders.ts +65 -43
- package/src/utils/buildTools/recordVersionNumber.js +17 -0
- package/src/utils/buildTools/shaderConverter.ts +466 -478
- package/src/utils/buildTools/watchShaders.ts +44 -42
- package/src/utils/index.ts +4 -2
- package/src/utils/renderTargetUtils.ts +30 -35
- package/src/utils/shaderCodeUtils.ts +192 -207
- package/src/utils/textureLoaders.ts +31 -43
- package/src/utils/textureUtils.ts +28 -32
- package/src/version.ts +2 -2
- package/dist/utils/buildTools/determineVersion.d.ts +0 -36
- package/dist/utils/buildTools/determineVersion.d.ts.map +0 -1
- package/dist/utils/buildTools/determineVersion.js +0 -109
- package/dist/utils/buildTools/determineVersion.js.map +0 -1
- package/dist/utils/buildTools/versionUp.d.ts +0 -2
- package/dist/utils/buildTools/versionUp.d.ts.map +0 -1
- package/dist/utils/buildTools/versionUp.js +0 -53
- package/dist/utils/buildTools/versionUp.js.map +0 -1
- package/src/utils/buildTools/determineVersion.ts +0 -128
- package/src/utils/buildTools/versionUp.ts +0 -61
package/src/runtime/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export { type StrongRef } from "./strongRef.js";
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
export { type StrongRef } from "./strongRef.js";
|
|
2
|
+
export { CreateStrongRef } from "./strongRef.js";
|
|
3
|
+
// Back compat for when camelCase was used
|
|
4
|
+
export { CreateStrongRef as createStrongRef } from "./strongRef.js";
|
|
5
|
+
export { DisableableShaderBinding, ShaderBinding, ShaderRuntime } from "./shaderRuntime.js";
|
|
6
|
+
export { type SmartFilterRuntime } from "./smartFilterRuntime.js";
|
|
7
|
+
export { InternalSmartFilterRuntime } from "./smartFilterRuntime.js";
|
|
8
|
+
export { RenderTargetGenerator } from "./renderTargetGenerator.js";
|
|
@@ -1,248 +1,222 @@
|
|
|
1
|
-
import type { ThinTexture } from "
|
|
2
|
-
import type { Nullable } from "
|
|
3
|
-
import { ThinRenderTargetTexture } from "
|
|
4
|
-
import type { RenderTargetCreationOptions } from "
|
|
5
|
-
|
|
6
|
-
import type { BaseBlock } from "../blockFoundation/baseBlock";
|
|
7
|
-
import type { InitializationData, SmartFilter } from "../smartFilter";
|
|
8
|
-
import type { InternalSmartFilterRuntime } from "./smartFilterRuntime";
|
|
9
|
-
import { ShaderBlock } from "../blockFoundation/shaderBlock.js";
|
|
10
|
-
import {
|
|
11
|
-
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
12
|
-
import type { OutputTextureOptions } from "../blockFoundation/textureOptions";
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
interface
|
|
19
|
-
/**
|
|
20
|
-
* The texture.
|
|
21
|
-
*/
|
|
22
|
-
texture: ThinTexture;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The reference count.
|
|
26
|
-
*/
|
|
27
|
-
refCount: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The render target generator is responsible for creating and assigning render targets to ShaderBlocks.
|
|
32
|
-
*/
|
|
33
|
-
export class RenderTargetGenerator {
|
|
34
|
-
private _optimize: boolean;
|
|
35
|
-
private _renderTargetPool: Map<string, Set<
|
|
36
|
-
private _textureOptionsHashCache = new Map<ShaderBlock, string>();
|
|
37
|
-
|
|
38
|
-
private _numTargetsCreated;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Creates a new render target generator.
|
|
42
|
-
* @param optimize - If true, the render target generator will try to reuse render targets as much as possible.
|
|
43
|
-
*/
|
|
44
|
-
constructor(optimize = true) {
|
|
45
|
-
this._optimize = optimize;
|
|
46
|
-
this._renderTargetPool = new Map();
|
|
47
|
-
this._numTargetsCreated = 0;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Returns the number of render targets created by the process
|
|
52
|
-
*/
|
|
53
|
-
public get numTargetsCreated() {
|
|
54
|
-
return this._numTargetsCreated;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Sets the output textures for the ShaderBlocks of the smart filter.
|
|
59
|
-
* @param smartFilter - The smart filter to generate the render targets for.
|
|
60
|
-
* @param initializationData - The initialization data to use.
|
|
61
|
-
*/
|
|
62
|
-
public setOutputTextures(smartFilter: SmartFilter, initializationData: InitializationData) {
|
|
63
|
-
smartFilter.output.ownerBlock.visit(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this._numTargetsCreated++;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const finalRenderTarget = new ThinRenderTargetTexture(engine, size, setup);
|
|
224
|
-
runtime.registerResource(finalRenderTarget);
|
|
225
|
-
|
|
226
|
-
// Babylon Constants.TEXTURE_CLAMP_ADDRESSMODE; NPOT Friendly
|
|
227
|
-
finalRenderTarget.wrapU = 0;
|
|
228
|
-
finalRenderTarget.wrapV = 0;
|
|
229
|
-
|
|
230
|
-
finalRenderTarget.anisotropicFilteringLevel = 1;
|
|
231
|
-
|
|
232
|
-
return finalRenderTarget;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Gets a textureOptionsHash for a block, using a cache to avoid recomputing it.
|
|
237
|
-
* @param block - The block to get the texture options hash for
|
|
238
|
-
* @returns The texture options hash for the block
|
|
239
|
-
*/
|
|
240
|
-
private _getTextureOptionsHash(block: ShaderBlock): string {
|
|
241
|
-
let textureOptionsHash = this._textureOptionsHashCache.get(block);
|
|
242
|
-
if (textureOptionsHash === undefined) {
|
|
243
|
-
textureOptionsHash = JSON.stringify(block.outputTextureOptions);
|
|
244
|
-
this._textureOptionsHashCache.set(block, textureOptionsHash);
|
|
245
|
-
}
|
|
246
|
-
return textureOptionsHash;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
1
|
+
import type { ThinTexture } from "core/Materials/Textures/thinTexture.js";
|
|
2
|
+
import type { Nullable } from "core/types.js";
|
|
3
|
+
import { ThinRenderTargetTexture } from "core/Materials/Textures/thinRenderTargetTexture.js";
|
|
4
|
+
import type { RenderTargetCreationOptions } from "core/Materials/Textures/textureCreationOptions.js";
|
|
5
|
+
|
|
6
|
+
import type { BaseBlock } from "../blockFoundation/baseBlock.js";
|
|
7
|
+
import type { InitializationData, SmartFilter } from "../smartFilter.js";
|
|
8
|
+
import type { InternalSmartFilterRuntime } from "./smartFilterRuntime.js";
|
|
9
|
+
import { ShaderBlock } from "../blockFoundation/shaderBlock.js";
|
|
10
|
+
import { CreateStrongRef } from "./strongRef.js";
|
|
11
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
12
|
+
import type { OutputTextureOptions } from "../blockFoundation/textureOptions.js";
|
|
13
|
+
import { GetBlockOutputTextureSize } from "../utils/textureUtils.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
interface IRefCountedTexture {
|
|
19
|
+
/**
|
|
20
|
+
* The texture.
|
|
21
|
+
*/
|
|
22
|
+
texture: ThinTexture;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The reference count.
|
|
26
|
+
*/
|
|
27
|
+
refCount: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The render target generator is responsible for creating and assigning render targets to ShaderBlocks.
|
|
32
|
+
*/
|
|
33
|
+
export class RenderTargetGenerator {
|
|
34
|
+
private _optimize: boolean;
|
|
35
|
+
private _renderTargetPool: Map<string, Set<IRefCountedTexture>>;
|
|
36
|
+
private _textureOptionsHashCache = new Map<ShaderBlock, string>();
|
|
37
|
+
|
|
38
|
+
private _numTargetsCreated;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new render target generator.
|
|
42
|
+
* @param optimize - If true, the render target generator will try to reuse render targets as much as possible.
|
|
43
|
+
*/
|
|
44
|
+
constructor(optimize = true) {
|
|
45
|
+
this._optimize = optimize;
|
|
46
|
+
this._renderTargetPool = new Map();
|
|
47
|
+
this._numTargetsCreated = 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns the number of render targets created by the process
|
|
52
|
+
*/
|
|
53
|
+
public get numTargetsCreated() {
|
|
54
|
+
return this._numTargetsCreated;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Sets the output textures for the ShaderBlocks of the smart filter.
|
|
59
|
+
* @param smartFilter - The smart filter to generate the render targets for.
|
|
60
|
+
* @param initializationData - The initialization data to use.
|
|
61
|
+
*/
|
|
62
|
+
public setOutputTextures(smartFilter: SmartFilter, initializationData: InitializationData) {
|
|
63
|
+
smartFilter.output.ownerBlock.visit(initializationData, (block: BaseBlock, initializationData: InitializationData) => {
|
|
64
|
+
if (!(block instanceof ShaderBlock)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let refCountedTexture: Nullable<IRefCountedTexture> = null;
|
|
69
|
+
const textureOptionsHash = this._getTextureOptionsHash(block);
|
|
70
|
+
|
|
71
|
+
// We assign a texture to the output of the block only if this is not the last block in the chain,
|
|
72
|
+
// i.e. not the block connected to the smart output block (in which case the output of the block is to the canvas and not a texture).
|
|
73
|
+
if (!block.output.endpoints.some((cp) => cp.ownerBlock === smartFilter.output.ownerBlock)) {
|
|
74
|
+
refCountedTexture = this._getTexture(initializationData.runtime, block.outputTextureOptions, textureOptionsHash, smartFilter);
|
|
75
|
+
|
|
76
|
+
if (!block.output.runtimeData) {
|
|
77
|
+
const runtimeOutput = CreateStrongRef(refCountedTexture.texture);
|
|
78
|
+
block.output.runtimeData = runtimeOutput;
|
|
79
|
+
} else {
|
|
80
|
+
block.output.runtimeData.value = refCountedTexture.texture;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (this._optimize) {
|
|
85
|
+
if (refCountedTexture !== null) {
|
|
86
|
+
for (const output of block.outputs) {
|
|
87
|
+
output.endpoints.forEach((endpoint) => {
|
|
88
|
+
if (endpoint.connectedTo) {
|
|
89
|
+
refCountedTexture!.refCount++;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
for (const input of block.inputs) {
|
|
96
|
+
if (!input.connectedTo || input.connectedTo.type !== ConnectionPointType.Texture) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const connectedBlock = input.connectedTo.ownerBlock;
|
|
100
|
+
if (connectedBlock instanceof ShaderBlock && connectedBlock.output.runtimeData && connectedBlock.output.runtimeData.value) {
|
|
101
|
+
this._releaseTexture(connectedBlock.output.runtimeData.value, this._getTextureOptionsHash(connectedBlock));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
this._renderTargetPool.clear();
|
|
107
|
+
this._textureOptionsHashCache.clear();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private _findAvailableTexture(textureOptionsHash: string): Nullable<IRefCountedTexture> {
|
|
111
|
+
const refCountedTextures = this._renderTargetPool.get(textureOptionsHash);
|
|
112
|
+
if (!refCountedTextures) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (const refCountedTexture of refCountedTextures) {
|
|
117
|
+
if (refCountedTexture.refCount === 0) {
|
|
118
|
+
return refCountedTexture;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private _getTexture(runtime: InternalSmartFilterRuntime, textureOptions: OutputTextureOptions, textureOptionsHash: string, smartFilter: SmartFilter): IRefCountedTexture {
|
|
126
|
+
if (!this._optimize) {
|
|
127
|
+
this._numTargetsCreated++;
|
|
128
|
+
return {
|
|
129
|
+
texture: this._createTexture(runtime, smartFilter, textureOptions),
|
|
130
|
+
refCount: 0,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
let refCountedTextures = this._renderTargetPool.get(textureOptionsHash);
|
|
135
|
+
if (!refCountedTextures) {
|
|
136
|
+
refCountedTextures = new Set();
|
|
137
|
+
this._renderTargetPool.set(textureOptionsHash, refCountedTextures);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let refCountedTexture = this._findAvailableTexture(textureOptionsHash);
|
|
141
|
+
if (!refCountedTexture) {
|
|
142
|
+
refCountedTexture = {
|
|
143
|
+
texture: this._createTexture(runtime, smartFilter, textureOptions),
|
|
144
|
+
refCount: 0,
|
|
145
|
+
};
|
|
146
|
+
refCountedTextures.add(refCountedTexture);
|
|
147
|
+
this._numTargetsCreated++;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return refCountedTexture;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private _releaseTexture(texture: ThinTexture, textureOptionsHash: string) {
|
|
154
|
+
if (!this._optimize) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const refCountedTextures = this._renderTargetPool.get(textureOptionsHash);
|
|
159
|
+
if (!refCountedTextures) {
|
|
160
|
+
throw new Error(`_releaseTexture: Trying to release a texture from a non existing pool ${textureOptionsHash}!`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
for (const refCountedTexture of refCountedTextures) {
|
|
164
|
+
if (refCountedTexture.texture === texture) {
|
|
165
|
+
refCountedTexture.refCount--;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
throw new Error(`_releaseTexture: Can't find the texture in the pool ${textureOptionsHash}!`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Creates an offscreen texture to hold on the result of the block rendering.
|
|
175
|
+
* @param runtime - The current runtime we create the texture for
|
|
176
|
+
* @param smartFilter - The smart filter the texture is created for
|
|
177
|
+
* @param textureOptions - The options to use to create the texture
|
|
178
|
+
* @returns The render target texture
|
|
179
|
+
*/
|
|
180
|
+
private _createTexture(runtime: InternalSmartFilterRuntime, smartFilter: SmartFilter, textureOptions: OutputTextureOptions): ThinRenderTargetTexture {
|
|
181
|
+
const engine = runtime.engine;
|
|
182
|
+
|
|
183
|
+
// We are only rendering full screen post process without depth or stencil information
|
|
184
|
+
const setup: RenderTargetCreationOptions = {
|
|
185
|
+
generateDepthBuffer: false,
|
|
186
|
+
generateStencilBuffer: false,
|
|
187
|
+
generateMipMaps: false,
|
|
188
|
+
samplingMode: 2, // Babylon Constants.TEXTURE_LINEAR_LINEAR,
|
|
189
|
+
format: textureOptions.format,
|
|
190
|
+
type: textureOptions.type,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// Get the smartFilter output size - either from the output block's renderTargetTexture or the engine's render size
|
|
194
|
+
const size = GetBlockOutputTextureSize(smartFilter, engine, textureOptions);
|
|
195
|
+
|
|
196
|
+
// Creates frame buffers for effects
|
|
197
|
+
const finalRenderTarget = new ThinRenderTargetTexture(engine, size, setup);
|
|
198
|
+
runtime.registerResource(finalRenderTarget);
|
|
199
|
+
|
|
200
|
+
// Babylon Constants.TEXTURE_CLAMP_ADDRESSMODE; NPOT Friendly
|
|
201
|
+
finalRenderTarget.wrapU = 0;
|
|
202
|
+
finalRenderTarget.wrapV = 0;
|
|
203
|
+
|
|
204
|
+
finalRenderTarget.anisotropicFilteringLevel = 1;
|
|
205
|
+
|
|
206
|
+
return finalRenderTarget;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Gets a textureOptionsHash for a block, using a cache to avoid recomputing it.
|
|
211
|
+
* @param block - The block to get the texture options hash for
|
|
212
|
+
* @returns The texture options hash for the block
|
|
213
|
+
*/
|
|
214
|
+
private _getTextureOptionsHash(block: ShaderBlock): string {
|
|
215
|
+
let textureOptionsHash = this._textureOptionsHashCache.get(block);
|
|
216
|
+
if (textureOptionsHash === undefined) {
|
|
217
|
+
textureOptionsHash = JSON.stringify(block.outputTextureOptions);
|
|
218
|
+
this._textureOptionsHashCache.set(block, textureOptionsHash);
|
|
219
|
+
}
|
|
220
|
+
return textureOptionsHash;
|
|
221
|
+
}
|
|
222
|
+
}
|