Skip to content

Commit 3c2dc9d

Browse files
WGSLNodeBuilder: Improve StorageTexture3D support (#32150)
* Examples: Fix compute_texture_pingpong example * WGSLNodeBuilder: Improve StorageTexture3D support
1 parent 71349ad commit 3c2dc9d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/renderers/webgpu/nodes/WGSLNodeBuilder.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class WGSLNodeBuilder extends NodeBuilder {
286286
*/
287287
generateWrapFunction( texture ) {
288288

289-
const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${ texture.isData3DTexture ? '3d' : '2d' }T`;
289+
const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${ texture.is3DTexture || texture.isData3DTexture ? '3d' : '2d' }T`;
290290

291291
let nodeCode = wgslCodeCache[ functionName ];
292292

@@ -295,7 +295,7 @@ class WGSLNodeBuilder extends NodeBuilder {
295295
const includes = [];
296296

297297
// For 3D textures, use vec3f; for texture arrays, keep vec2f since array index is separate
298-
const coordType = texture.isData3DTexture ? 'vec3f' : 'vec2f';
298+
const coordType = texture.is3DTexture || texture.isData3DTexture ? 'vec3f' : 'vec2f';
299299
let code = `fn ${ functionName }( coord : ${ coordType } ) -> ${ coordType } {\n\n\treturn ${ coordType }(\n`;
300300

301301
const addWrapSnippet = ( wrap, axis ) => {
@@ -334,7 +334,7 @@ class WGSLNodeBuilder extends NodeBuilder {
334334

335335
addWrapSnippet( texture.wrapT, 'y' );
336336

337-
if ( texture.isData3DTexture ) {
337+
if ( texture.is3DTexture || texture.isData3DTexture ) {
338338

339339
code += ',\n';
340340
addWrapSnippet( texture.wrapR, 'z' );
@@ -392,7 +392,7 @@ class WGSLNodeBuilder extends NodeBuilder {
392392
const { primarySamples } = this.renderer.backend.utils.getTextureSampleData( texture );
393393
const isMultisampled = primarySamples > 1;
394394

395-
if ( texture.isData3DTexture ) {
395+
if ( texture.is3DTexture || texture.isData3DTexture ) {
396396

397397
dimensionType = 'vec3<u32>';
398398

@@ -418,7 +418,7 @@ class WGSLNodeBuilder extends NodeBuilder {
418418

419419
textureData.dimensionsSnippet[ levelSnippet ] = textureDimensionNode;
420420

421-
if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
421+
if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.is3DTexture || texture.isData3DTexture ) {
422422

423423
textureData.arrayLayerCount = new VarNode(
424424
new ExpressionNode(
@@ -488,7 +488,7 @@ class WGSLNodeBuilder extends NodeBuilder {
488488
const wrapFunction = this.generateWrapFunction( texture );
489489
const textureDimension = this.generateTextureDimension( texture, textureProperty, levelSnippet );
490490

491-
const vecType = texture.isData3DTexture ? 'vec3' : 'vec2';
491+
const vecType = texture.is3DTexture || texture.isData3DTexture ? 'vec3' : 'vec2';
492492

493493
if ( offsetSnippet ) {
494494

0 commit comments

Comments
 (0)