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
6 changes: 3 additions & 3 deletions examples/jsm/renderers/webgpu/WebGPUBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ class WebGPUBindings {

} else if ( binding.texture.isVideoTexture ) {

binding.textureGPU = this.textures.getVideoDefaultTexture();
binding.textureGPU = this.textures.getDefaultVideoTexture();

} else if ( binding.texture.isDepthTexture ) {

binding.textureGPU = this.textures.getDepthDefaultTexture();
binding.textureGPU = this.textures.getDefaultDepthTexture();

} else {

Expand All @@ -248,7 +248,7 @@ class WebGPUBindings {

}

const resource = binding.textureGPU instanceof GPUTexture ? binding.textureGPU.createView( { dimension: binding.dimension } ) : binding.textureGPU;
const resource = binding.textureGPU instanceof GPUTexture ? binding.textureGPU.createView( { aspect: binding.aspect, dimension: binding.dimension } ) : binding.textureGPU;

entries.push( { binding: bindingPoint, resource } );

Expand Down
4 changes: 3 additions & 1 deletion examples/jsm/renderers/webgpu/WebGPUSampledTexture.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import WebGPUBinding from './WebGPUBinding.js';
import { GPUBindingType, GPUTextureViewDimension } from './constants.js';
import { GPUBindingType, GPUTextureViewDimension, GPUTextureAspect } from './constants.js';

class WebGPUSampledTexture extends WebGPUBinding {

Expand All @@ -16,6 +16,8 @@ class WebGPUSampledTexture extends WebGPUBinding {
this.type = GPUBindingType.SampledTexture;
this.visibility = GPUShaderStage.FRAGMENT;

this.aspect = texture.isDepthTexture ? GPUTextureAspect.DepthOnly : GPUTextureAspect.All;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still an open point. I'm not sure how to setup the depth texture so the depth and stencil aspect are supported. Let's start with depth-only for now.


this.textureGPU = null; // set by the renderer

}
Expand Down
39 changes: 32 additions & 7 deletions examples/jsm/renderers/webgpu/WebGPUTextures.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension } from './constants.js';
import { GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension, GPUFeatureName } from './constants.js';
import { VideoTexture, CubeTexture, Texture, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter, RepeatWrapping, MirroredRepeatWrapping, RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthTexture,
RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthStencilFormat, DepthTexture,
RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format,
RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType
RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type
} from 'three';
import WebGPUTextureUtils from './WebGPUTextureUtils.js';

Expand Down Expand Up @@ -37,13 +37,11 @@ class WebGPUTextures {

}

getDepthDefaultTexture() {
getDefaultDepthTexture() {

if ( this.depthDefaultTexture === null ) {

const depthTexture = new DepthTexture();
depthTexture.minFilter = NearestFilter;
depthTexture.magFilter = NearestFilter;
depthTexture.image.width = 1;
depthTexture.image.height = 1;

Expand Down Expand Up @@ -75,7 +73,7 @@ class WebGPUTextures {

}

getVideoDefaultTexture() {
getDefaultVideoTexture() {

if ( this.defaultVideoTexture === null ) {

Expand Down Expand Up @@ -828,6 +826,33 @@ class WebGPUTextures {

break;

case DepthStencilFormat:

switch ( type ) {

case UnsignedInt248Type:
formatGPU = GPUTextureFormat.Depth24PlusStencil8;
break;

case FloatType:

if ( this.device.features.has( GPUFeatureName.Depth32FloatStencil8 ) === false ) {

console.error( 'WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.' );

}

formatGPU = GPUTextureFormat.Depth32FloatStencil8;

break;

default:
console.error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );

}

break;

default:
console.error( 'WebGPURenderer: Unsupported texture format.', format );

Expand Down
6 changes: 6 additions & 0 deletions examples/jsm/renderers/webgpu/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ export const GPUTextureViewDimension = {
ThreeD: '3d'
};

export const GPUTextureAspect = {
All: 'all',
StencilOnly: 'stencil-only',
DepthOnly: 'depth-only'
};

export const GPUInputStepMode = {
Vertex: 'vertex',
Instance: 'instance'
Expand Down