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

Creating a TextureDimension::D1 texture with more than one miplevel does not fail #2057

Closed
Wumpf opened this issue Oct 11, 2021 · 3 comments
Closed
Labels
area: validation Issues related to validation, diagnostics, and error handling help required We need community help to make this happen.

Comments

@Wumpf
Copy link
Member

Wumpf commented Oct 11, 2021

... but isn't supported in Metal which gives a very clear error about this

-[MTLTextureDescriptorInternal validateWithDevice:]:1248: failed assertion `Texture Descriptor Validation
MTLTextureDescriptor requests a mipmapLevelCount of 3 but the texture type MTLTextureType1D requires that mipmapLevelCount is 1
'

Similar to #2045

@Wumpf
Copy link
Member Author

Wumpf commented Oct 11, 2021

haven't checked what the webgpu spec actually says about this :)

@kvark kvark added area: validation Issues related to validation, diagnostics, and error handling help required We need community help to make this happen. labels Oct 12, 2021
@CatCode79
Copy link
Contributor

The webgpu specs are "pretty vague" about mipmap level concepts: here
But on texture creation are more informative: here

What I found of interest is:

  • descriptor.mipLevelCount must be greater than zero.

  • If descriptor.sampleCount > 1:
    descriptor.mipLevelCount must be 1.
    descriptor.size.depthOrArrayLayers must be 1.
    descriptor.usage must not include the STORAGE_BINDING bit.
    descriptor.format must be a renderable format.

  • descriptor.mipLevelCount must be less than or equal to maximum mipLevel count(descriptor.dimension, descriptor.size).

About mipmapLevelCount on apple developer docs:
https://developer.apple.com/documentation/metal/mtltexturedescriptor/1516300-mipmaplevelcount

Perhaps the part of the code with the necessary validation is the same one touched by this fix:
#2001

And in particular this line attracts me a lot:

if mips == 0 || mips > hal::MAX_MIP_LEVELS || mips > desc.size.max_mips() {

Hope this helps.

@jinleili
Copy link
Contributor

Verified on master branch of wgpu, this issue has been fixed

Patryk27 pushed a commit to Patryk27/wgpu that referenced this issue Nov 23, 2022
Whitespace and formatting changes only.

It turns out that if `cargo fmt` comes across a single line it can't
make fit within the margins, then it sort of gives up on the
surrounding construct. So breaking up the error message for
`Error::UnknownScalarType` in `Error::as_parse_error` and then
re-running `cargo fmt` cleans up lots of other stuff in the file.

cargo fmt issue:
rust-lang/rustfmt#3863
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 help required We need community help to make this happen.
Projects
None yet
Development

No branches or pull requests

5 participants