@gnsx/three 0.186.1 → 0.186.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.webgpu.js +610 -17
- package/build/three.webgpu.nodes.js +610 -17
- package/examples/jsm/inspector/Inspector.js +60 -1
- package/examples/jsm/inspector/tabs/Memory.js +60 -1
- package/examples/jsm/inspector/tabs/Settings.js +36 -0
- package/examples/jsm/inspector/ui/Profiler.js +6 -0
- package/examples/jsm/inspector/ui/Style.js +53 -1
- package/examples/jsm/inspector/ui/utils.js +121 -0
- package/package.json +1 -1
- package/src/materials/nodes/NodeMaterial.js +30 -0
- package/src/nodes/core/NodeBuilder.js +74 -0
- package/src/nodes/display/ComplexityDebug.js +278 -0
- package/src/nodes/lighting/LightsNode.js +71 -2
- package/src/nodes/lighting/PointLightNode.js +4 -1
- package/src/nodes/lighting/RectAreaLightNode.js +14 -0
- package/src/nodes/lighting/SpotLightNode.js +10 -2
- package/src/renderers/common/Background.js +17 -1
- package/src/renderers/common/RenderObject.js +5 -0
- package/src/renderers/common/Renderer.js +24 -1
- package/src/renderers/common/nodes/NodeManager.js +22 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +8 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +19 -3
- package/src/renderers/webgpu/WebGPUBackend.js +14 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +16 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +20 -0
- package/build/three.cjs +0 -17
|
@@ -8,7 +8,14 @@ import { Parameters } from './tabs/Parameters.js';
|
|
|
8
8
|
import { Settings } from './tabs/Settings.js';
|
|
9
9
|
import { Viewer } from './tabs/Viewer.js';
|
|
10
10
|
import { Timeline } from './tabs/Timeline.js';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
setText,
|
|
13
|
+
// WITH_GENESYS
|
|
14
|
+
getJSHeapBytes,
|
|
15
|
+
startJSHeapSampling,
|
|
16
|
+
stopJSHeapSampling
|
|
17
|
+
// !WITH_GENESYS
|
|
18
|
+
} from './ui/utils.js';
|
|
12
19
|
|
|
13
20
|
import { setConsoleFunction, getConsoleFunction, REVISION } from '@gnsx/three/webgpu';
|
|
14
21
|
|
|
@@ -24,6 +31,10 @@ class Inspector extends RendererInspector {
|
|
|
24
31
|
|
|
25
32
|
this.nonce = nonce;
|
|
26
33
|
|
|
34
|
+
// WITH_GENESYS
|
|
35
|
+
startJSHeapSampling();
|
|
36
|
+
// !WITH_GENESYS
|
|
37
|
+
|
|
27
38
|
// init profiler
|
|
28
39
|
|
|
29
40
|
const profiler = new Profiler( this, options );
|
|
@@ -589,6 +600,50 @@ class Inspector extends RendererInspector {
|
|
|
589
600
|
|
|
590
601
|
setText( this.profiler.toggleButton.querySelector( '.fps-counter' ), this.fps.toFixed() );
|
|
591
602
|
|
|
603
|
+
// WITH_GENESYS
|
|
604
|
+
const toggle = this.profiler.toggleButton;
|
|
605
|
+
const gpuCounter = toggle.querySelector( '.gpu-counter' );
|
|
606
|
+
const gpuLabel = toggle.querySelector( '.gpu-label' );
|
|
607
|
+
const heapCounter = toggle.querySelector( '.heap-counter' );
|
|
608
|
+
const heapLabel = toggle.querySelector( '.heap-label' );
|
|
609
|
+
const gpuBytes = this.getRenderer()?.info?.memory?.total;
|
|
610
|
+
const heap = getJSHeapBytes();
|
|
611
|
+
|
|
612
|
+
if ( gpuCounter ) {
|
|
613
|
+
|
|
614
|
+
if ( typeof gpuBytes === 'number' ) {
|
|
615
|
+
|
|
616
|
+
setText( gpuCounter, ( gpuBytes / ( 1024 * 1024 ) ).toFixed( 0 ) );
|
|
617
|
+
gpuCounter.style.display = '';
|
|
618
|
+
if ( gpuLabel ) gpuLabel.style.display = '';
|
|
619
|
+
|
|
620
|
+
} else {
|
|
621
|
+
|
|
622
|
+
gpuCounter.style.display = 'none';
|
|
623
|
+
if ( gpuLabel ) gpuLabel.style.display = 'none';
|
|
624
|
+
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
if ( heapCounter ) {
|
|
630
|
+
|
|
631
|
+
if ( heap ) {
|
|
632
|
+
|
|
633
|
+
setText( heapCounter, ( heap.used / ( 1024 * 1024 ) ).toFixed( 0 ) );
|
|
634
|
+
heapCounter.style.display = '';
|
|
635
|
+
if ( heapLabel ) heapLabel.style.display = '';
|
|
636
|
+
|
|
637
|
+
} else {
|
|
638
|
+
|
|
639
|
+
heapCounter.style.display = 'none';
|
|
640
|
+
if ( heapLabel ) heapLabel.style.display = 'none';
|
|
641
|
+
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
}
|
|
645
|
+
// !WITH_GENESYS
|
|
646
|
+
|
|
592
647
|
this.performance.updateText( this, frame );
|
|
593
648
|
this.memory.updateText( this );
|
|
594
649
|
|
|
@@ -633,6 +688,10 @@ class Inspector extends RendererInspector {
|
|
|
633
688
|
|
|
634
689
|
dispose() {
|
|
635
690
|
|
|
691
|
+
// WITH_GENESYS
|
|
692
|
+
stopJSHeapSampling();
|
|
693
|
+
// !WITH_GENESYS
|
|
694
|
+
|
|
636
695
|
super.dispose();
|
|
637
696
|
|
|
638
697
|
this.setRenderer( null );
|
|
@@ -2,7 +2,15 @@ import { Tab } from '../ui/Tab.js';
|
|
|
2
2
|
import { List } from '../ui/List.js';
|
|
3
3
|
import { Graph } from '../ui/Graph.js';
|
|
4
4
|
import { Item } from '../ui/Item.js';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createValueSpan,
|
|
7
|
+
setText,
|
|
8
|
+
formatBytes,
|
|
9
|
+
info,
|
|
10
|
+
// WITH_GENESYS
|
|
11
|
+
getJSHeapBytes
|
|
12
|
+
// !WITH_GENESYS
|
|
13
|
+
} from '../ui/utils.js';
|
|
6
14
|
|
|
7
15
|
class Memory extends Tab {
|
|
8
16
|
|
|
@@ -26,6 +34,9 @@ class Memory extends Tab {
|
|
|
26
34
|
|
|
27
35
|
const graph = new Graph();
|
|
28
36
|
graph.addLine( 'total', 'var( --color-yellow )' );
|
|
37
|
+
// WITH_GENESYS
|
|
38
|
+
graph.addLine( 'jsHeap', 'var( --color-accent )' );
|
|
39
|
+
// !WITH_GENESYS
|
|
29
40
|
graphContainer.append( graph.domElement );
|
|
30
41
|
|
|
31
42
|
// stats
|
|
@@ -37,6 +48,13 @@ class Memory extends Tab {
|
|
|
37
48
|
graphItem.itemRow.childNodes[ 0 ].style.gridColumn = '1 / -1';
|
|
38
49
|
graphStats.add( graphItem );
|
|
39
50
|
|
|
51
|
+
// WITH_GENESYS
|
|
52
|
+
const legend = document.createElement( 'div' );
|
|
53
|
+
legend.className = 'graph-caption graph-legend';
|
|
54
|
+
legend.innerHTML = '<span class="graph-legend-item graph-legend-gpu">GPU</span><span class="graph-legend-item graph-legend-heap">JS Heap</span>';
|
|
55
|
+
graphContainer.prepend( legend );
|
|
56
|
+
// !WITH_GENESYS
|
|
57
|
+
|
|
40
58
|
// info
|
|
41
59
|
|
|
42
60
|
this.memoryStats = new Item( 'Renderer Info', '', createValueSpan() );
|
|
@@ -73,6 +91,19 @@ class Memory extends Tab {
|
|
|
73
91
|
this.uniformBuffers = new Item( 'Uniform Buffers', createValueSpan(), createValueSpan() );
|
|
74
92
|
this.memoryStats.add( this.uniformBuffers );
|
|
75
93
|
|
|
94
|
+
// WITH_GENESYS
|
|
95
|
+
this.jsHeapStats = new Item( 'JS Heap', '', createValueSpan() );
|
|
96
|
+
this.jsHeapStats.domElement.firstChild.classList.add( 'no-hover' );
|
|
97
|
+
memoryList.add( this.jsHeapStats );
|
|
98
|
+
info( this.jsHeapStats.domElement.querySelector( '.list-item-cell' ), 'Chromium reports V8 heap via performance.memory (used / allocated / limit). Other browsers only report a page-memory estimate if performance.measureUserAgentSpecificMemory is available in a cross-origin isolated document. Safari and Firefox do not expose JS heap size to web pages.' );
|
|
99
|
+
|
|
100
|
+
this.jsHeapAllocated = new Item( 'Allocated', '', createValueSpan() );
|
|
101
|
+
this.jsHeapStats.add( this.jsHeapAllocated );
|
|
102
|
+
|
|
103
|
+
this.jsHeapLimit = new Item( 'Limit', '', createValueSpan() );
|
|
104
|
+
this.jsHeapStats.add( this.jsHeapLimit );
|
|
105
|
+
// !WITH_GENESYS
|
|
106
|
+
|
|
76
107
|
this.graph = graph;
|
|
77
108
|
|
|
78
109
|
}
|
|
@@ -85,6 +116,16 @@ class Memory extends Tab {
|
|
|
85
116
|
|
|
86
117
|
this.graph.addPoint( 'total', memory.total );
|
|
87
118
|
|
|
119
|
+
// WITH_GENESYS
|
|
120
|
+
const heap = getJSHeapBytes();
|
|
121
|
+
|
|
122
|
+
if ( heap ) {
|
|
123
|
+
|
|
124
|
+
this.graph.addPoint( 'jsHeap', heap.used );
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
// !WITH_GENESYS
|
|
128
|
+
|
|
88
129
|
if ( this.graph.limit === 0 ) this.graph.limit = 1;
|
|
89
130
|
|
|
90
131
|
this.graph.update();
|
|
@@ -127,6 +168,24 @@ class Memory extends Tab {
|
|
|
127
168
|
setText( this.uniformBuffers.data[ 1 ], memory.uniformBuffers.toString() );
|
|
128
169
|
setText( this.uniformBuffers.data[ 2 ], formatBytes( memory.uniformBuffersSize ) );
|
|
129
170
|
|
|
171
|
+
// WITH_GENESYS
|
|
172
|
+
const heap = getJSHeapBytes();
|
|
173
|
+
|
|
174
|
+
if ( heap ) {
|
|
175
|
+
|
|
176
|
+
setText( this.jsHeapStats.data[ 2 ], formatBytes( heap.used ) );
|
|
177
|
+
setText( this.jsHeapAllocated.data[ 2 ], heap.total !== undefined ? formatBytes( heap.total ) : 'N/A' );
|
|
178
|
+
setText( this.jsHeapLimit.data[ 2 ], heap.limit !== undefined ? formatBytes( heap.limit ) : 'N/A' );
|
|
179
|
+
|
|
180
|
+
} else {
|
|
181
|
+
|
|
182
|
+
setText( this.jsHeapStats.data[ 2 ], 'Unsupported' );
|
|
183
|
+
setText( this.jsHeapAllocated.data[ 2 ], 'N/A' );
|
|
184
|
+
setText( this.jsHeapLimit.data[ 2 ], 'N/A' );
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
// !WITH_GENESYS
|
|
188
|
+
|
|
130
189
|
}
|
|
131
190
|
|
|
132
191
|
}
|
|
@@ -134,10 +134,46 @@ class Settings extends Parameters {
|
|
|
134
134
|
|
|
135
135
|
} ).info( 'Shows how many times each pixel is shaded.' );
|
|
136
136
|
|
|
137
|
+
// WITH_GENESYS
|
|
138
|
+
// Values match Renderer.debug.view. Not stored with inspector settings.
|
|
139
|
+
const debugViewState = { view: 'none' };
|
|
140
|
+
|
|
141
|
+
this._debugViewState = debugViewState;
|
|
142
|
+
this._debugViewControl = modesGroup.add( debugViewState, 'view', {
|
|
143
|
+
'Shaded': 'none',
|
|
144
|
+
'Shader Complexity': 'shaderComplexity',
|
|
145
|
+
'Lighting Complexity': 'lightingComplexity'
|
|
146
|
+
} ).name( 'Debug View' ).onChange( ( view ) => {
|
|
147
|
+
|
|
148
|
+
const renderer = this.inspector.getRenderer();
|
|
149
|
+
|
|
150
|
+
if ( renderer === null || renderer.debug === undefined ) return;
|
|
151
|
+
|
|
152
|
+
renderer.debug.view = view;
|
|
153
|
+
window.dispatchEvent( new Event( 'genesys-debug-view' ) );
|
|
154
|
+
|
|
155
|
+
} ).info( 'Shaded color, a shader-cost heatmap, or a direct-light count. Overdraw draws on top when both are enabled.' );
|
|
156
|
+
// !WITH_GENESYS
|
|
157
|
+
|
|
137
158
|
}
|
|
138
159
|
|
|
139
160
|
init() {
|
|
140
161
|
|
|
162
|
+
// WITH_GENESYS
|
|
163
|
+
const renderer = this.inspector.getRenderer();
|
|
164
|
+
const view = renderer !== null && renderer.debug !== undefined ? renderer.debug.view : null;
|
|
165
|
+
|
|
166
|
+
if ( view === 'none' || view === 'shaderComplexity' || view === 'lightingComplexity' ) {
|
|
167
|
+
|
|
168
|
+
if ( this._debugViewState.view !== view ) {
|
|
169
|
+
|
|
170
|
+
this._debugViewControl.setValue( view );
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
// !WITH_GENESYS
|
|
176
|
+
|
|
141
177
|
const extensionsGroup = this.createGroup( 'Extensions' );
|
|
142
178
|
|
|
143
179
|
const storageGroup = this.createGroup( 'Storage' );
|
|
@@ -271,6 +271,12 @@ export class Profiler extends EventDispatcher {
|
|
|
271
271
|
<span class="toggle-text">
|
|
272
272
|
<span class="fps-counter">-</span>
|
|
273
273
|
<span class="fps-label">FPS</span>
|
|
274
|
+
<!-- WITH_GENESYS -->
|
|
275
|
+
<span class="gpu-counter" title="GPU memory (MB)">-</span>
|
|
276
|
+
<span class="gpu-label">GPU</span>
|
|
277
|
+
<span class="heap-counter" title="JS heap used (MB)">-</span>
|
|
278
|
+
<span class="heap-label">JS</span>
|
|
279
|
+
<!-- !WITH_GENESYS -->
|
|
274
280
|
</span>
|
|
275
281
|
<span class="toggle-icon">
|
|
276
282
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-device-ipad-horizontal-search"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M11.5 20h-6.5a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v5.5" /><path d="M9 17h2" /><path d="M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" /><path d="M20.2 20.2l1.8 1.8" /></svg>
|
|
@@ -179,7 +179,10 @@ export class Style {
|
|
|
179
179
|
display: flex;
|
|
180
180
|
align-items: baseline;
|
|
181
181
|
padding: 8px 14px;
|
|
182
|
-
|
|
182
|
+
/* WITH_GENESYS */
|
|
183
|
+
min-width: 196px;
|
|
184
|
+
/* !WITH_GENESYS */
|
|
185
|
+
/* min-width: 80px; */
|
|
183
186
|
justify-content: right;
|
|
184
187
|
}
|
|
185
188
|
|
|
@@ -189,6 +192,20 @@ export class Style {
|
|
|
189
192
|
color: #999;
|
|
190
193
|
}
|
|
191
194
|
|
|
195
|
+
/* WITH_GENESYS */
|
|
196
|
+
.toggle-text .gpu-counter,
|
|
197
|
+
.toggle-text .heap-counter {
|
|
198
|
+
margin-left: 12px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.toggle-text .gpu-label,
|
|
202
|
+
.toggle-text .heap-label {
|
|
203
|
+
font-size: 0.7em;
|
|
204
|
+
margin-left: 6px;
|
|
205
|
+
color: #999;
|
|
206
|
+
}
|
|
207
|
+
/* !WITH_GENESYS */
|
|
208
|
+
|
|
192
209
|
.builtin-tabs-container {
|
|
193
210
|
position: relative;
|
|
194
211
|
z-index: 1;
|
|
@@ -1251,6 +1268,41 @@ export class Style {
|
|
|
1251
1268
|
position: relative;
|
|
1252
1269
|
}
|
|
1253
1270
|
|
|
1271
|
+
/* WITH_GENESYS */
|
|
1272
|
+
.graph-caption {
|
|
1273
|
+
font-size: 11px;
|
|
1274
|
+
color: var(--text-secondary);
|
|
1275
|
+
margin-bottom: 4px;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
.graph-legend {
|
|
1279
|
+
display: flex;
|
|
1280
|
+
gap: 12px;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
.graph-legend-item {
|
|
1284
|
+
display: inline-flex;
|
|
1285
|
+
align-items: center;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
.graph-legend-item::before {
|
|
1289
|
+
content: '';
|
|
1290
|
+
display: inline-block;
|
|
1291
|
+
width: 8px;
|
|
1292
|
+
height: 8px;
|
|
1293
|
+
border-radius: 2px;
|
|
1294
|
+
margin-right: 6px;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
.graph-legend-gpu::before {
|
|
1298
|
+
background: var(--color-yellow);
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
.graph-legend-heap::before {
|
|
1302
|
+
background: var(--color-accent);
|
|
1303
|
+
}
|
|
1304
|
+
/* !WITH_GENESYS */
|
|
1305
|
+
|
|
1254
1306
|
.graph-svg, .graph-canvas {
|
|
1255
1307
|
width: 0;
|
|
1256
1308
|
min-width: 100%;
|
|
@@ -62,6 +62,127 @@ export function formatBytes( bytes, decimals = 2 ) {
|
|
|
62
62
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// WITH_GENESYS
|
|
66
|
+
/**
|
|
67
|
+
* Best-effort JS / page memory sample for the inspector.
|
|
68
|
+
*
|
|
69
|
+
* Chromium exposes a sync V8 heap via `performance.memory`. The spec method
|
|
70
|
+
* `performance.measureUserAgentSpecificMemory()` is async, may include more
|
|
71
|
+
* than JS heap, and requires a cross-origin isolated document. Firefox and
|
|
72
|
+
* Safari do not expose JS heap size to web content as of 2026.
|
|
73
|
+
*
|
|
74
|
+
* @returns {{ used: number, total?: number, limit?: number } | null}
|
|
75
|
+
*/
|
|
76
|
+
let _specMemoryBytes = null;
|
|
77
|
+
let _specMemoryTimer = 0;
|
|
78
|
+
let _specMemorySampling = false;
|
|
79
|
+
|
|
80
|
+
function readPerformanceMemory() {
|
|
81
|
+
|
|
82
|
+
const memory = performance.memory;
|
|
83
|
+
|
|
84
|
+
if ( memory === undefined || typeof memory.usedJSHeapSize !== 'number' ) {
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
used: memory.usedJSHeapSize,
|
|
92
|
+
total: memory.totalJSHeapSize,
|
|
93
|
+
limit: memory.jsHeapSizeLimit
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function sampleSpecMemory() {
|
|
99
|
+
|
|
100
|
+
const measure = performance.measureUserAgentSpecificMemory;
|
|
101
|
+
|
|
102
|
+
if ( typeof measure !== 'function' ) {
|
|
103
|
+
|
|
104
|
+
return;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
|
|
110
|
+
const result = await measure.call( performance );
|
|
111
|
+
|
|
112
|
+
if ( result && typeof result.bytes === 'number' ) {
|
|
113
|
+
|
|
114
|
+
_specMemoryBytes = result.bytes;
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
} catch {
|
|
119
|
+
|
|
120
|
+
// SecurityError when the document is not cross-origin isolated.
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function scheduleSpecMemorySample() {
|
|
127
|
+
|
|
128
|
+
if ( _specMemorySampling === false ) {
|
|
129
|
+
|
|
130
|
+
return;
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Spec guidance: poll on a randomized interval; the call may wait on GC.
|
|
135
|
+
_specMemoryTimer = setTimeout( () => {
|
|
136
|
+
|
|
137
|
+
sampleSpecMemory().finally( scheduleSpecMemorySample );
|
|
138
|
+
|
|
139
|
+
}, 8000 + Math.random() * 7000 );
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function startJSHeapSampling() {
|
|
144
|
+
|
|
145
|
+
if ( _specMemorySampling ) {
|
|
146
|
+
|
|
147
|
+
return;
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
_specMemorySampling = true;
|
|
152
|
+
sampleSpecMemory();
|
|
153
|
+
scheduleSpecMemorySample();
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function stopJSHeapSampling() {
|
|
158
|
+
|
|
159
|
+
_specMemorySampling = false;
|
|
160
|
+
clearTimeout( _specMemoryTimer );
|
|
161
|
+
_specMemoryTimer = 0;
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function getJSHeapBytes() {
|
|
166
|
+
|
|
167
|
+
const chromeHeap = readPerformanceMemory();
|
|
168
|
+
|
|
169
|
+
if ( chromeHeap ) {
|
|
170
|
+
|
|
171
|
+
return chromeHeap;
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if ( typeof _specMemoryBytes === 'number' ) {
|
|
176
|
+
|
|
177
|
+
return { used: _specMemoryBytes };
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return null;
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
// !WITH_GENESYS
|
|
185
|
+
|
|
65
186
|
export function info( parentNode, text ) {
|
|
66
187
|
|
|
67
188
|
let infoIcon = parentNode.querySelector( '.info-icon' );
|
package/package.json
CHANGED
|
@@ -25,6 +25,9 @@ import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
|
25
25
|
import { vertexColor } from '../../nodes/accessors/VertexColorNode.js';
|
|
26
26
|
import { premultiplyAlpha } from '../../nodes/display/PremultiplyAlphaFunctions.js';
|
|
27
27
|
import { subBuild } from '../../nodes/core/SubBuildNode.js';
|
|
28
|
+
// WITH_GENESYS
|
|
29
|
+
import { DEBUG_VIEW_LIGHTING_COMPLEXITY, DEBUG_VIEW_SHADER_COMPLEXITY, getShaderComplexityBase, shaderComplexityOutput } from '../../nodes/display/ComplexityDebug.js';
|
|
30
|
+
// !WITH_GENESYS
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
33
|
* Base class for all node materials.
|
|
@@ -597,6 +600,17 @@ class NodeMaterial extends Material {
|
|
|
597
600
|
|
|
598
601
|
}
|
|
599
602
|
|
|
603
|
+
// WITH_GENESYS
|
|
604
|
+
// The screen output pass colorizes the accumulated ratio. Wrapping that pass
|
|
605
|
+
// would replace the heatmap with this material's own constant cost.
|
|
606
|
+
if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY && this.isShadowPassMaterial !== true && renderer.isOutputTarget !== true ) {
|
|
607
|
+
|
|
608
|
+
builder.shaderComplexityBase = getShaderComplexityBase( this );
|
|
609
|
+
resultNode = shaderComplexityOutput( resultNode );
|
|
610
|
+
|
|
611
|
+
}
|
|
612
|
+
// !WITH_GENESYS
|
|
613
|
+
|
|
600
614
|
builder.stack.outputNode = resultNode;
|
|
601
615
|
|
|
602
616
|
builder.addFlow( 'fragment', builder.removeStack() );
|
|
@@ -1110,6 +1124,22 @@ class NodeMaterial extends Material {
|
|
|
1110
1124
|
|
|
1111
1125
|
}
|
|
1112
1126
|
|
|
1127
|
+
// WITH_GENESYS
|
|
1128
|
+
if ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_COMPLEXITY && this.isShadowPassMaterial !== true ) {
|
|
1129
|
+
|
|
1130
|
+
const hasLightLoop = lightsNode && ( materialLightings.length > 0 || lightsNode.getScope().hasLights );
|
|
1131
|
+
|
|
1132
|
+
if ( hasLightLoop !== true ) {
|
|
1133
|
+
|
|
1134
|
+
outgoingLightNode = vec3( 0 );
|
|
1135
|
+
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
return outgoingLightNode;
|
|
1139
|
+
|
|
1140
|
+
}
|
|
1141
|
+
// !WITH_GENESYS
|
|
1142
|
+
|
|
1113
1143
|
// EMISSIVE
|
|
1114
1144
|
|
|
1115
1145
|
if ( ( emissiveNode && emissiveNode.isNode === true ) || ( material.emissive && material.emissive.isColor === true ) ) {
|
|
@@ -24,6 +24,9 @@ import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
|
|
|
24
24
|
import BindGroup from '../../renderers/common/BindGroup.js';
|
|
25
25
|
|
|
26
26
|
import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter, NormalBlending } from '../../constants.js';
|
|
27
|
+
// WITH_GENESYS
|
|
28
|
+
import { SHADER_COMPLEXITY_TEXTURE_COST } from '../display/ComplexityDebug.js';
|
|
29
|
+
// !WITH_GENESYS
|
|
27
30
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
28
31
|
import { Color } from '../../math/Color.js';
|
|
29
32
|
import { Vector2 } from '../../math/Vector2.js';
|
|
@@ -268,6 +271,31 @@ class NodeBuilder {
|
|
|
268
271
|
*/
|
|
269
272
|
this.fragmentShader = null;
|
|
270
273
|
|
|
274
|
+
// WITH_GENESYS
|
|
275
|
+
/**
|
|
276
|
+
* Static material-feature cost for the shader-complexity debug view.
|
|
277
|
+
*
|
|
278
|
+
* @type {number}
|
|
279
|
+
* @default 0
|
|
280
|
+
*/
|
|
281
|
+
this.shaderComplexityBase = 0;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Fragment texture samples counted while generating the shader.
|
|
285
|
+
*
|
|
286
|
+
* @type {number}
|
|
287
|
+
* @default 0
|
|
288
|
+
*/
|
|
289
|
+
this.fragmentTextureSamples = 0;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Sample sites already counted, so a node that is generated twice is not double-counted.
|
|
293
|
+
*
|
|
294
|
+
* @type {Set<string>}
|
|
295
|
+
*/
|
|
296
|
+
this.shaderComplexitySampleKeys = new Set();
|
|
297
|
+
// !WITH_GENESYS
|
|
298
|
+
|
|
271
299
|
/**
|
|
272
300
|
* The generated compute shader.
|
|
273
301
|
*
|
|
@@ -1296,6 +1324,46 @@ class NodeBuilder {
|
|
|
1296
1324
|
|
|
1297
1325
|
}
|
|
1298
1326
|
|
|
1327
|
+
// WITH_GENESYS
|
|
1328
|
+
/**
|
|
1329
|
+
* Counts one fragment texture sample toward the shader-complexity proxy.
|
|
1330
|
+
* Depth and cube textures are shadow maps and environment maps, and rect-area
|
|
1331
|
+
* LTC tables belong to the light loop, so they are not material cost.
|
|
1332
|
+
*
|
|
1333
|
+
* @param {?Texture} texture - The texture being sampled.
|
|
1334
|
+
* @param {string} [shaderStage=this.shaderStage] - The stage the sample is emitted for.
|
|
1335
|
+
* @param {string} [key=''] - Stable id for this sample site. Repeated generation of the same site counts once.
|
|
1336
|
+
*/
|
|
1337
|
+
recordFragmentTextureSample( texture, shaderStage = this.shaderStage, key = '' ) {
|
|
1338
|
+
|
|
1339
|
+
if ( shaderStage !== 'fragment' ) return;
|
|
1340
|
+
|
|
1341
|
+
if ( texture && ( texture.isDepthTexture === true || texture.isCubeTexture === true || texture.isRectAreaLTC === true ) ) return;
|
|
1342
|
+
|
|
1343
|
+
if ( key !== '' ) {
|
|
1344
|
+
|
|
1345
|
+
if ( this.shaderComplexitySampleKeys.has( key ) ) return;
|
|
1346
|
+
|
|
1347
|
+
this.shaderComplexitySampleKeys.add( key );
|
|
1348
|
+
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
this.fragmentTextureSamples ++;
|
|
1352
|
+
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* Returns the shader-complexity proxy for the material currently being built.
|
|
1357
|
+
*
|
|
1358
|
+
* @return {number} Base feature cost plus weighted fragment texture samples.
|
|
1359
|
+
*/
|
|
1360
|
+
getShaderComplexityCost() {
|
|
1361
|
+
|
|
1362
|
+
return this.shaderComplexityBase + this.fragmentTextureSamples * SHADER_COMPLEXITY_TEXTURE_COST;
|
|
1363
|
+
|
|
1364
|
+
}
|
|
1365
|
+
// !WITH_GENESYS
|
|
1366
|
+
|
|
1299
1367
|
/**
|
|
1300
1368
|
* Generates a texture LOD shader string for the given texture data.
|
|
1301
1369
|
*
|
|
@@ -3119,6 +3187,12 @@ class NodeBuilder {
|
|
|
3119
3187
|
*/
|
|
3120
3188
|
prebuild() {
|
|
3121
3189
|
|
|
3190
|
+
// WITH_GENESYS
|
|
3191
|
+
this.shaderComplexityBase = 0;
|
|
3192
|
+
this.fragmentTextureSamples = 0;
|
|
3193
|
+
this.shaderComplexitySampleKeys.clear();
|
|
3194
|
+
// !WITH_GENESYS
|
|
3195
|
+
|
|
3122
3196
|
const { renderer, material } = this;
|
|
3123
3197
|
|
|
3124
3198
|
// < renderer.contextNode >
|