|
|
@@ -234,37 +234,46 @@ class WebGPUBindingUtils {
|
|
|
|
|
|
const textureData = backend.get( binding.texture );
|
|
|
|
|
|
- let dimensionViewGPU;
|
|
|
+ let resourceGPU;
|
|
|
|
|
|
- if ( binding.isSampledCubeTexture ) {
|
|
|
+ if ( textureData.externalTexture !== undefined ) {
|
|
|
|
|
|
- dimensionViewGPU = GPUTextureViewDimension.Cube;
|
|
|
+ resourceGPU = device.importExternalTexture( { source: textureData.externalTexture } );
|
|
|
|
|
|
- } else if ( binding.isSampledTexture3D ) {
|
|
|
+ } else {
|
|
|
|
|
|
- dimensionViewGPU = GPUTextureViewDimension.ThreeD;
|
|
|
+ const mipLevelCount = binding.store ? 1 : textureData.texture.mipLevelCount;
|
|
|
+ const propertyName = `view-${ mipLevelCount }`;
|
|
|
|
|
|
- } else if ( binding.texture.isDataArrayTexture || binding.texture.isCompressedArrayTexture ) {
|
|
|
+ resourceGPU = textureData[ propertyName ];
|
|
|
|
|
|
- dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
|
|
|
+ if ( resourceGPU === undefined ) {
|
|
|
|
|
|
- } else {
|
|
|
+ const aspectGPU = GPUTextureAspect.All;
|
|
|
|
|
|
- dimensionViewGPU = GPUTextureViewDimension.TwoD;
|
|
|
+ let dimensionViewGPU;
|
|
|
|
|
|
- }
|
|
|
+ if ( binding.isSampledCubeTexture ) {
|
|
|
|
|
|
- let resourceGPU;
|
|
|
+ dimensionViewGPU = GPUTextureViewDimension.Cube;
|
|
|
|
|
|
- if ( textureData.externalTexture !== undefined ) {
|
|
|
+ } else if ( binding.isSampledTexture3D ) {
|
|
|
|
|
|
- resourceGPU = device.importExternalTexture( { source: textureData.externalTexture } );
|
|
|
+ dimensionViewGPU = GPUTextureViewDimension.ThreeD;
|
|
|
|
|
|
- } else {
|
|
|
+ } else if ( binding.texture.isDataArrayTexture || binding.texture.isCompressedArrayTexture ) {
|
|
|
+
|
|
|
+ dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ dimensionViewGPU = GPUTextureViewDimension.TwoD;
|
|
|
|
|
|
- const aspectGPU = GPUTextureAspect.All;
|
|
|
+ }
|
|
|
|
|
|
- resourceGPU = textureData.texture.createView( { aspect: aspectGPU, dimension: dimensionViewGPU, mipLevelCount: binding.store ? 1 : textureData.mipLevelCount } );
|
|
|
+ resourceGPU = textureData[ propertyName ] = textureData.texture.createView( { aspect: aspectGPU, dimension: dimensionViewGPU, mipLevelCount } );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|