Skip to content

Poor error message when creating a view with a disallowed format #8322

@Arne-Berner

Description

@Arne-Berner

Description
I would like to create a texture view that is RGB8UnormSrgb from an RGB8Unorm texture. But I get the following error:

wgpu error: Validation Error

Caused by:
  In Texture::create_view, label = 'in_texture'
    Unable to view texture Rgba8Unorm as Rgba8UnormSrgb

Repro steps

        let texture = device.create_texture(&wgpu::TextureDescriptor {
            label,
            size,
            mip_level_count: 1,
            sample_count: 1,
            dimension: wgpu::TextureDimension::D2,
            format,
            usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::STORAGE_BINDING,
            view_formats: &[],
        });


        let srgb_view = texture.create_view(&wgpu::TextureViewDescriptor{
            label,
            format: Some(wgpu::TextureFormat::Rgba8UnormSrgb),
            dimension: Some(wgpu::TextureViewDimension::D2),
            usage: Some(wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST),
            ..Default::default()
        });

Note: I did not add the right view formats in the texture.

Expected vs observed behavior
I would've expected that the error would point me to the view_formats.

Platform
Using wgpu 27.0.0, running on ubuntu 24.04 on a cheap laptop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: validationIssues related to validation, diagnostics, and error handlingkind: diagnosticsError message should be bettertype: enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions