Skip to content

Commit 6a5d6de

Browse files
authored
StorageTexture: Adds support for other formats. (mrdoob#26842)
* TimeNode: Define `frameId` as integer * Renderer: Set `info` as public * StorageTexture: Adds support for other formats. * Update example to `temporal blur` * fix device in getFormat()
1 parent 9fe5ed2 commit 6a5d6de

File tree

5 files changed

+219
-179
lines changed

5 files changed

+219
-179
lines changed

Diff for: examples/jsm/nodes/utils/TimerNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ export default TimerNode;
8989
export const timerLocal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.LOCAL, timeScale, value ) );
9090
export const timerGlobal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.GLOBAL, timeScale, value ) );
9191
export const timerDelta = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.DELTA, timeScale, value ) );
92-
export const frameId = nodeImmutable( TimerNode, TimerNode.FRAME );
92+
export const frameId = nodeImmutable( TimerNode, TimerNode.FRAME ).uint();
9393

9494
addNodeClass( TimerNode );

Diff for: examples/jsm/renderers/common/Renderer.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class Renderer {
4646
this.depth = true;
4747
this.stencil = true;
4848

49+
this.info = new Info();
50+
4951
// internals
5052

5153
this._pixelRatio = 1;
@@ -56,7 +58,6 @@ class Renderer {
5658
this._scissor = new Vector4( 0, 0, this._width, this._height );
5759
this._scissorTest = false;
5860

59-
this._info = null;
6061
this._properties = null;
6162
this._attributes = null;
6263
this._geometries = null;
@@ -131,15 +132,14 @@ class Renderer {
131132

132133
}
133134

134-
this._info = new Info();
135135
this._nodes = new Nodes( this, backend );
136136
this._attributes = new Attributes( backend );
137137
this._background = new Background( this, this._nodes );
138-
this._geometries = new Geometries( this._attributes, this._info );
139-
this._textures = new Textures( backend, this._info );
138+
this._geometries = new Geometries( this._attributes, this.info );
139+
this._textures = new Textures( backend, this.info );
140140
this._pipelines = new Pipelines( backend, this._nodes );
141-
this._bindings = new Bindings( backend, this._nodes, this._textures, this._attributes, this._pipelines, this._info );
142-
this._objects = new RenderObjects( this, this._nodes, this._geometries, this._pipelines, this._bindings, this._info );
141+
this._bindings = new Bindings( backend, this._nodes, this._textures, this._attributes, this._pipelines, this.info );
142+
this._objects = new RenderObjects( this, this._nodes, this._geometries, this._pipelines, this._bindings, this.info );
143143
this._renderLists = new RenderLists();
144144
this._renderContexts = new RenderContexts();
145145

@@ -214,9 +214,9 @@ class Renderer {
214214

215215
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
216216

217-
if ( this._info.autoReset === true ) this._info.reset();
217+
if ( this.info.autoReset === true ) this.info.reset();
218218

219-
this._info.render.frame ++;
219+
this.info.render.frame ++;
220220

221221
//
222222

@@ -612,12 +612,13 @@ class Renderer {
612612

613613
dispose() {
614614

615+
this.info.dispose();
616+
615617
this._objects.dispose();
616618
this._properties.dispose();
617619
this._pipelines.dispose();
618620
this._nodes.dispose();
619621
this._bindings.dispose();
620-
this._info.dispose();
621622
this._renderLists.dispose();
622623
this._renderContexts.dispose();
623624
this._textures.dispose();
@@ -921,7 +922,7 @@ class Renderer {
921922

922923
//
923924

924-
this.backend.draw( renderObject, this._info );
925+
this.backend.draw( renderObject, this.info );
925926

926927
}
927928

Diff for: examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { getVectorLength, getStrideLength } from '../../common/BufferUtils.js';
1111

1212
import { NodeBuilder, CodeNode, NodeMaterial } from '../../../nodes/Nodes.js';
1313

14+
import { getFormat } from '../utils/WebGPUTextureUtils.js';
15+
1416
import WGSLNodeParser from './WGSLNodeParser.js';
1517

1618
const gpuShaderStageLib = {
@@ -659,8 +661,9 @@ class WGSLNodeBuilder extends NodeBuilder {
659661

660662
} else if ( uniform.node.isStoreTextureNode === true ) {
661663

662-
// @TODO: Add support for other formats
663-
textureType = 'texture_storage_2d<rgba8unorm, write>';
664+
const format = getFormat( texture );
665+
666+
textureType = 'texture_storage_2d<' + format + ', write>';
664667

665668
} else {
666669

0 commit comments

Comments
 (0)