Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/webgpu_loader_gltf.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
} );


renderer = new THREE.WebGPURenderer( { antialias: true } );
renderer = new THREE.WebGPURenderer( { antialias: true/*, compatibilityMode: true*/ } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.toneMapping = THREE.ACESFilmicToneMapping;
Expand Down
18 changes: 2 additions & 16 deletions src/renderers/common/Textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import DataMap from './DataMap.js';

import { Vector3 } from '../../math/Vector3.js';
import { DepthTexture } from '../../textures/DepthTexture.js';
import { DepthStencilFormat, DepthFormat, UnsignedIntType, UnsignedInt248Type, EquirectangularReflectionMapping, EquirectangularRefractionMapping, CubeReflectionMapping, CubeRefractionMapping, UnsignedByteType } from '../../constants.js';
import { DepthStencilFormat, DepthFormat, UnsignedIntType, UnsignedInt248Type, UnsignedByteType } from '../../constants.js';

const _size = /*@__PURE__*/ new Vector3();

Expand Down Expand Up @@ -420,21 +420,7 @@ class Textures extends DataMap {
*/
needsMipmaps( texture ) {

return this.isEnvironmentTexture( texture ) || texture.isCompressedTexture === true || texture.generateMipmaps;

}

/**
* Returns `true` if the given texture is an environment map.
*
* @param {Texture} texture - The texture.
* @return {boolean} Whether the given texture is an environment map or not.
*/
isEnvironmentTexture( texture ) {

const mapping = texture.mapping;

return ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ) || ( mapping === CubeReflectionMapping || mapping === CubeRefractionMapping );
return texture.isCompressedTexture === true || texture.generateMipmaps;

}

Expand Down
11 changes: 10 additions & 1 deletion src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@ class WebGPUBackend extends Backend {

// some parameters require default values other than "undefined"
this.parameters.alpha = ( parameters.alpha === undefined ) ? true : parameters.alpha;
this.parameters.compatibilityMode = ( parameters.compatibilityMode === undefined ) ? false : parameters.compatibilityMode;

this.parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits;

/**
* Indicates whether the backend is in compatibility mode or not.
* @type {boolean}
* @default false
*/
this.compatibilityMode = this.parameters.compatibilityMode;

/**
* A reference to the device.
*
Expand Down Expand Up @@ -168,7 +176,8 @@ class WebGPUBackend extends Backend {
if ( parameters.device === undefined ) {

const adapterOptions = {
powerPreference: parameters.powerPreference
powerPreference: parameters.powerPreference,
featureLevel: parameters.compatibilityMode ? 'compatibility' : undefined
};

const adapter = ( typeof navigator !== 'undefined' ) ? await navigator.gpu.requestAdapter( adapterOptions ) : null;
Expand Down
8 changes: 7 additions & 1 deletion src/renderers/webgpu/utils/WebGPUTextureUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension, GPUFeatureName
GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension, GPUFeatureName, GPUTextureViewDimension
} from './WebGPUConstants.js';

import WebGPUTexturePassUtils from './WebGPUTexturePassUtils.js';
Expand Down Expand Up @@ -270,6 +270,12 @@ class WebGPUTextureUtils {

}

if ( texture.isCubeTexture ) {

textureDescriptorGPU.textureBindingViewDimension = GPUTextureViewDimension.Cube;

}

textureData.texture = backend.device.createTexture( textureDescriptorGPU );

}
Expand Down