Skip to content

Commit 4498f37

Browse files
committed
Revert "WebGPURenderer: CubeTexture support"
This reverts commit 6c62b26.
1 parent cefd269 commit 4498f37

File tree

3 files changed

+22
-61
lines changed

3 files changed

+22
-61
lines changed

examples/jsm/renderers/webgpu/WebGPUTextureUtils.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
123123

124124
}
125125

126-
generateMipmaps( textureGPU, textureGPUDescriptor, baseArrayLayer = 1, mipLevelOffset = 1 ) {
126+
generateMipmaps( textureGPU, textureGPUDescriptor ) {
127127

128128
const pipeline = this.getMipmapPipeline( textureGPUDescriptor.format );
129129

@@ -135,12 +135,11 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
135135
mipLevelCount: 1
136136
} );
137137

138-
for ( let i = mipLevelOffset; i < textureGPUDescriptor.mipLevelCount; i ++ ) {
138+
for ( let i = 1; i < textureGPUDescriptor.mipLevelCount; i ++ ) {
139139

140140
const dstView = textureGPU.createView( {
141141
baseMipLevel: i,
142-
mipLevelCount: 1,
143-
baseArrayLayer
142+
mipLevelCount: 1
144143
} );
145144

146145
const passEncoder = commandEncoder.beginRenderPass( {

examples/jsm/renderers/webgpu/WebGPUTextures.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,7 @@ class WebGPUTextures {
361361

362362
} else if ( texture.isCubeTexture ) {
363363

364-
if ( image.length === 6 ) {
365-
366-
this._copyCubeMapToTexture( image, texture, textureGPU, textureGPUDescriptor, needsMipmaps );
367-
368-
}
364+
this._copyCubeMapToTexture( image, texture, textureGPU );
369365

370366
} else {
371367

@@ -419,17 +415,15 @@ class WebGPUTextures {
419415

420416
}
421417

422-
_copyCubeMapToTexture( images, texture, textureGPU, textureGPUDescriptor, needsMipmaps ) {
418+
_copyCubeMapToTexture( images, texture, textureGPU ) {
423419

424-
for ( let i = 5; i >= 0; i -- ) {
420+
for ( let i = 0; i < images.length; i ++ ) {
425421

426422
const image = images[ i ];
427423

428424
this._getImageBitmap( image, texture ).then( imageBitmap => {
429425

430-
this._copyExternalImageToTexture( imageBitmap, textureGPU );
431-
432-
if ( needsMipmaps === true ) this._generateMipmaps( textureGPU, textureGPUDescriptor, i, i > 0 ? 0 : 1 );
426+
this._copyExternalImageToTexture( imageBitmap, textureGPU, { x: 0, y: 0, z: i } );
433427

434428
} );
435429

@@ -445,7 +439,7 @@ class WebGPUTextures {
445439
}, {
446440
texture: textureGPU,
447441
mipLevel: 0,
448-
origin
442+
origin: origin
449443
}, {
450444
width: image.width,
451445
height: image.height,
@@ -483,22 +477,22 @@ class WebGPUTextures {
483477
{
484478
width: Math.ceil( width / blockData.width ) * blockData.width,
485479
height: Math.ceil( height / blockData.width ) * blockData.width,
486-
depthOrArrayLayers: 1
480+
depthOrArrayLayers: 1,
487481
} );
488482

489483
}
490484

491485
}
492486

493-
_generateMipmaps( textureGPU, textureGPUDescriptor, baseArrayLayer, mipLevelOffset ) {
487+
_generateMipmaps( textureGPU, textureGPUDescriptor ) {
494488

495489
if ( this.utils === null ) {
496490

497491
this.utils = new WebGPUTextureUtils( this.device ); // only create this helper if necessary
498492

499493
}
500494

501-
this.utils.generateMipmaps( textureGPU, textureGPUDescriptor, baseArrayLayer, mipLevelOffset );
495+
this.utils.generateMipmaps( textureGPU, textureGPUDescriptor );
502496

503497
}
504498

examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ColorNodeUniform, Matrix3NodeUniform, Matrix4NodeUniform
77
} from './WebGPUNodeUniform.js';
88
import WebGPUNodeSampler from './WebGPUNodeSampler.js';
9-
import { WebGPUNodeSampledTexture, WebGPUNodeSampledCubeTexture } from './WebGPUNodeSampledTexture.js';
9+
import { WebGPUNodeSampledTexture } from './WebGPUNodeSampledTexture.js';
1010

1111
import WebGPUUniformBuffer from '../WebGPUUniformBuffer.js';
1212
import { getVectorLength, getStrideLength } from '../WebGPUBufferUtils.js';
@@ -33,27 +33,27 @@ const wgslTypeLib = {
3333
int: 'i32',
3434
uint: 'u32',
3535
bool: 'bool',
36-
36+
3737
vec2: 'vec2<f32>',
3838
ivec2: 'vec2<i32>',
3939
uvec2: 'vec2<u32>',
4040
bvec2: 'vec2<bool>',
41-
41+
4242
vec3: 'vec3<f32>',
4343
ivec3: 'vec3<i32>',
4444
uvec3: 'vec3<u32>',
4545
bvec3: 'vec3<bool>',
46-
46+
4747
vec4: 'vec4<f32>',
4848
ivec4: 'vec4<i32>',
4949
uvec4: 'vec4<u32>',
5050
bvec4: 'vec4<bool>',
51-
51+
5252
mat3: 'mat3x3<f32>',
5353
imat3: 'mat3x3<i32>',
5454
umat3: 'mat3x3<u32>',
5555
bmat3: 'mat3x3<bool>',
56-
56+
5757
mat4: 'mat4x4<f32>',
5858
imat4: 'mat4x4<i32>',
5959
umat4: 'mat4x4<u32>',
@@ -362,7 +362,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
362362

363363
}
364364

365-
getSampler( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
365+
getTexture( textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
366366

367367
if ( shaderStage === 'fragment' ) {
368368

@@ -380,18 +380,6 @@ class WebGPUNodeBuilder extends NodeBuilder {
380380

381381
}
382382

383-
getTexture( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
384-
385-
return this.getSampler( textureProperty, uvSnippet, shaderStage );
386-
387-
}
388-
389-
getCubeTexture( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
390-
391-
return this.getSampler( textureProperty, uvSnippet, shaderStage );
392-
393-
}
394-
395383
getPropertyName( node, shaderStage = this.shaderStage ) {
396384

397385
if ( node.isNodeVary === true ) {
@@ -407,7 +395,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
407395
const name = node.name;
408396
const type = node.type;
409397

410-
if ( type === 'texture' || type === 'cubeTexture' ) {
398+
if ( type === 'texture' ) {
411399

412400
return name;
413401

@@ -446,21 +434,10 @@ class WebGPUNodeBuilder extends NodeBuilder {
446434

447435
const bindings = this.bindings[ shaderStage ];
448436

449-
if ( type === 'texture' || type === 'cubeTexture' ) {
437+
if ( type === 'texture' ) {
450438

451439
const sampler = new WebGPUNodeSampler( `${uniformNode.name}_sampler`, uniformNode.node );
452-
453-
let texture = null;
454-
455-
if ( type === 'texture' ) {
456-
457-
texture = new WebGPUNodeSampledTexture( uniformNode.name, uniformNode.node );
458-
459-
} else if ( type === 'cubeTexture' ) {
460-
461-
texture = new WebGPUNodeSampledCubeTexture( uniformNode.name, uniformNode.node );
462-
463-
}
440+
const texture = new WebGPUNodeSampledTexture( uniformNode.name, uniformNode.node );
464441

465442
// add first textures in sequence and group for last
466443
const lastBinding = bindings[ bindings.length - 1 ];
@@ -478,6 +455,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
478455

479456
uniformGPU = [ texture ];
480457

458+
481459
}
482460

483461

@@ -674,16 +652,6 @@ class WebGPUNodeBuilder extends NodeBuilder {
674652

675653
snippet += `@group( 0 ) @binding( ${index ++} ) var ${uniform.name} : texture_2d<f32>; `;
676654

677-
} else if ( uniform.type === 'cubeTexture' ) {
678-
679-
if ( shaderStage === 'fragment' ) {
680-
681-
snippet += `@group( 0 ) @binding( ${index ++} ) var ${uniform.name}_sampler : sampler; `;
682-
683-
}
684-
685-
snippet += `@group( 0 ) @binding( ${index ++} ) var ${uniform.name} : texture_cube<f32>; `;
686-
687655
} else if ( uniform.type === 'buffer' ) {
688656

689657
const bufferNode = uniform.node;

0 commit comments

Comments
 (0)