Skip to content

Commit a253882

Browse files
committed
Don't Copy Textures to remove RENDER_ATTACHMENT usage
This was added as RENDER_ATTACHMENT usage is compatible with swizzle under the current spec. Unfortunately, copying a texture fails for depth textures on Mac Intel (because there is no test). It turns out the current spec only requires the texture view's usage not to have RENDER_ATTACHMENT, not the textures's, so this copy step is not needed. Removing should let tests run on devices where copy is broken.
1 parent 76292d3 commit a253882

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,34 +3256,12 @@ function createTextureFromTexelViewsLocal(
32563256
const modifiedDescriptor = { ...desc };
32573257
// If it's a depth or stencil texture we need to render to it to fill it with data.
32583258
if (isDepthOrStencilTextureFormat(desc.format) || desc.sampleCount! > 1) {
3259-
modifiedDescriptor.usage =
3260-
desc.usage | GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC;
3259+
modifiedDescriptor.usage = desc.usage | GPUTextureUsage.RENDER_ATTACHMENT;
32613260
}
3262-
let texture = createTextureFromTexelViews(t, texelViews[0], modifiedDescriptor);
3261+
const texture = createTextureFromTexelViews(t, texelViews[0], modifiedDescriptor);
32633262
if (texelViews.length > 1) {
32643263
copyTexelViewsToTexture(t, texture, 'stencil-only', texelViews[1]);
32653264
}
3266-
3267-
// If we had to add RENDER_ATTACHMENT, make a copy that doesn't have RENDER_ATTACHMENT
3268-
const textureHasRenderAttachment = (texture.usage & GPUTextureUsage.RENDER_ATTACHMENT) !== 0;
3269-
const wantRenderAttachment = (desc.usage & GPUTextureUsage.RENDER_ATTACHMENT) !== 0;
3270-
if (textureHasRenderAttachment && !wantRenderAttachment) {
3271-
const copy = t.createTextureTracked({
3272-
...desc,
3273-
usage: desc.usage | GPUTextureUsage.COPY_DST,
3274-
});
3275-
const encoder = t.device.createCommandEncoder();
3276-
for (let mipLevel = 0; mipLevel < texture.mipLevelCount; ++mipLevel) {
3277-
encoder.copyTextureToTexture(
3278-
{ texture, mipLevel },
3279-
{ texture: copy, mipLevel },
3280-
physicalMipSizeFromTexture(texture, mipLevel)
3281-
);
3282-
}
3283-
t.device.queue.submit([encoder.finish()]);
3284-
texture.destroy();
3285-
texture = copy;
3286-
}
32873265
return texture;
32883266
}
32893267

0 commit comments

Comments
 (0)