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

added downlevel restriction error message for InvalidFormatUsages error #2886

Merged

Conversation

Seamooo
Copy link
Contributor

@Seamooo Seamooo commented Jul 15, 2022

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
link to issue

Description
As mentioned in the issue, texture format usages that are not possible due to downlevel incompatibility have the same error message as if a usage incompatible with the WebGPU specification is specified. This PR adds a third parameter to the InvalidFormatUsages error, specifying if the error was due to a downlevel incompatibility. Additionally this third parameter is populated by checking against the webgpu allowed usages for the texture format in question.

Testing
This PR was tested by running

device.create_texture(&wgpu::TextureDescriptor {
    label: None,
    size: wgpu::Extent3d {
        width: 1,
        height: 1,
        depth_or_array_layers: 1,
    },
    mip_level_count: 1,
    sample_count: 1,
    dimension: wgpu::TextureDimension::D2,
    format: wgpu::TextureFormat::Rg32Uint,
    usage: wgpu::TextureUsages::STORAGE_BINDING,
});

where device is of type wgpu::Device.
This is within the specification, and within the format features table, however unsupported by the hardware I'm running.
The observed error message is

thread 'tests::test_create_texture' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_texture
    Texture usages STORAGE_BINDING are not allowed on a texture of type Rg32Uint due to downlevel restrictions

', wgpu/wgpu/src/backend/direct.rs:2391:5

Additionally to assert that the original error message without downlevel restrictions is behaving correctly the below snippet was run

device.create_texture(&wgpu::TextureDescriptor {
    label: None,
    size: wgpu::Extent3d {
        width: 1,
        height: 1,
        depth_or_array_layers: 1,
    },
    mip_level_count: 1,
    sample_count: 1,
    dimension: wgpu::TextureDimension::D2,
    format: wgpu::TextureFormat::R16Uint,
    usage: wgpu::TextureUsages::STORAGE_BINDING,
});

This is both outside the specification and the table referenced. The error observed in this case is

thread 'tests::test_create_texture' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_texture
    Texture usages STORAGE_BINDING are not allowed on a texture of type R16Uint

', wgpu/wgpu/src/backend/direct.rs:2391:5

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Thanks for this! Please just add to the changelog that the error was improved and we should be g2g

@cwfitzgerald
Copy link
Member

Failures on nightly are unrelated.

Seamooo added a commit to Seamooo/wgpu that referenced this pull request Jul 15, 2022
@Seamooo Seamooo force-pushed the fix/validation-create-texture-downlevel-msg branch from 48e5aae to f77cbe5 Compare July 15, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants