Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot copy from depth texture to depth texture array even if entire texture is copied #5699

Closed
EriKWDev opened this issue May 13, 2024 · 4 comments · Fixed by #5705
Closed
Labels
area: validation Issues related to validation, diagnostics, and error handling type: bug Something isn't working

Comments

@EriKWDev
Copy link

EriKWDev commented May 13, 2024

Description
When I'm calling encoder.copy_texture_to_texture from a depth texture to a texture2darray of depth texture I get validation error:

wgpu error: Validation Error

Caused by:
    In CommandEncoder::copy_texture_to_texture
    Copy error
    The entire texture must be copied when copying from depth texture

even though the entire depth texture is being copied.

I happen to have differing sample_counts when I discovered this, but further testing keeps giving me the same error even if the textures have the same sample_count.

let multisampled_depth_texture = device.create_texture(&TextureDescriptor {
    label: None,
    size: Extent3d {
        width: 512,
        height: 512,
        depth_or_array_layers: 1,
    },
    mip_level_count: 1,
    sample_count: 4, // NOTE: Sample count > 1
    dimension: TextureDimension::D2,
    format: TextureFormat::Depth24Plus,
    usage: TextureUsages::TEXTURE_BINDING
        | TextureUsages::RENDER_ATTACHMENT
        | TextureUsages::COPY_SRC,
    view_formats: &[TextureFormat::Depth24Plus],
});


let non_multisampled_depth_2d_array = device.create_texture(&TextureDescriptor {
      label: None,
      size: Extent3d {
          width: 512,
          height: 512,
          depth_or_array_layers: 10,
      },
      mip_level_count: 1,
      sample_count: 1, // NOTE: This array has sample_count = 1
      dimension: TextureDimension::D2,
      format: TextureFormat::Depth24Plus,
      usage: TextureUsages::TEXTURE_BINDING
          | TextureUsages::RENDER_ATTACHMENT
          | TextureUsages::COPY_DST,
      view_formats: &[TextureFormat::Depth24Plus],
  });

// .. LATER ..
encoder.copy_texture_to_texture(
    multisampled_depth_texture.as_image_copy(),
    ImageCopyTexture {
        texture: &non_multisampled_depth_2d_array,
        mip_level: 0,
        origin: Origin3d {
            x: 0,
            y: 0,
            z: array_index,
        },
        aspect: TextureAspect::All,
    },
    Extent3d {
        width: multisampled_depth_texture.width(),
        height: multisampled_depth_texture.height(),
        depth_or_array_layers: 1,
    },
);

Expected vs observed behavior
I would like to copy a depth texture with sample_count > 1 into the texture2d array of depth textures with sample_count = 1

I don't know whether this is an issue in the reported error, the validator or whether this is not permitted by the spec.

Platform

Os: Linux 6.1.0-20, Debian 12 bookworm
Backend: Vulkan
wgpu: 0.19.4
rust: 1.78
CPU: AMD Ryzen 7 1700X (16) @ 3.400GHz
GPU: AMD ATI Radeon RX 6600/6600 XT/6600M
@EriKWDev
Copy link
Author

Update: Multisampled or not has no effect, still same issue if both textures have multisample_count: 1

@teoxoy teoxoy added type: bug Something isn't working area: validation Issues related to validation, diagnostics, and error handling labels May 14, 2024
@teoxoy
Copy link
Member

teoxoy commented May 14, 2024

Note that sample_count must match but 2d <-> 2d_array copies should work.

@EriKWDev could you give #5705 a try?

@EriKWDev
Copy link
Author

EriKWDev commented May 14, 2024

Sadly our application is blocked by this issue #5693 on latest version so cannot verify immediately in our app, but your fix seems relevant.

@EriKWDev
Copy link
Author

EriKWDev commented May 14, 2024

After merging #5681 and your #5705 into a fork of wgpu, I can confirm that I can now copy the depth textures successfully in our application :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: validation Issues related to validation, diagnostics, and error handling type: bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants