Skip to content

Commit ac9c39e

Browse files
authored
ConstNode: Optimize indexes (#30388)
* optimize indexes * Update webgpu_tsl_compute_attractors_particles.jpg * cleanup
1 parent 0d0a80a commit ac9c39e

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed
68.5 KB
Loading

src/nodes/accessors/BatchNode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ class BatchNode extends Node {
7676

7777
const getIndirectIndex = Fn( ( [ id ] ) => {
7878

79-
const size = textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 );
80-
const x = int( id ).modInt( int( size ) );
81-
const y = int( id ).div( int( size ) );
79+
const size = int( textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 ) );
80+
const x = int( id ).modInt( size );
81+
const y = int( id ).div( size );
8282
return textureLoad( this.batchMesh._indirectTexture, ivec2( x, y ) ).x;
8383

8484
} ).setLayout( {

src/nodes/core/ConstNode.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import InputNode from './InputNode.js';
22

3+
const _regNum = /float|u?int/;
4+
35
/**
46
* Class for representing a constant value in the shader.
57
*
@@ -50,6 +52,12 @@ class ConstNode extends InputNode {
5052

5153
const type = this.getNodeType( builder );
5254

55+
if ( _regNum.test( type ) && _regNum.test( output ) ) {
56+
57+
return builder.generateConst( output, this.value );
58+
59+
}
60+
5361
return builder.format( this.generateConst( builder ), type, output );
5462

5563
}

src/nodes/pmrem/PMREMUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export const blur = /*@__PURE__*/ Fn( ( { n, latitudinal, poleAxis, outputDirect
267267
axis.assign( normalize( axis ) );
268268

269269
const gl_FragColor = vec3().toVar();
270-
gl_FragColor.addAssign( weights.element( int( 0 ) ).mul( getSample( { theta: 0.0, axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
270+
gl_FragColor.addAssign( weights.element( 0 ).mul( getSample( { theta: 0.0, axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
271271

272272
Loop( { start: int( 1 ), end: n }, ( { i } ) => {
273273

0 commit comments

Comments
 (0)