Skip to content

Conversation

@kdashg
Copy link
Contributor

@kdashg kdashg commented Nov 19, 2020

Forbid zero-sized textures and views.
Resolves #1200.


Preview | Diff

Copy link
Contributor

@Kangz Kangz left a comment

Choose a reason for hiding this comment

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

I assume we'll want much more validation for texture creation but LGTM as an initial batch.

@kvark
Copy link
Contributor

kvark commented Nov 19, 2020

Any reason this isn't based on #799?

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Thank you for writing this down! Needs some work before landing

@kdashg
Copy link
Contributor Author

kdashg commented Nov 20, 2020

Any reason this isn't based on #799?

I didn't realize that was written!

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Looks good for the most part, thank you for updating!

- 1 ≤ {{GPUTextureDescriptor/size}}.height
- 1 ≤ {{GPUTextureDescriptor/size}}.depth
- Let |maxDim| = {{GPUTextureDescriptor/size}}.width
- if {{GPUTextureDescriptor/dimension}} == {{GPUTextureDimension/'2d'}}:
Copy link
Contributor

Choose a reason for hiding this comment

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

to editors: we'll probably turn this into a switch

<div class=validusage>
- 0 &le; {{GPUTextureViewDescriptor/baseMipLevel}} &lt; {{GPUTextureDescriptor/mipLevelCount}}
- 1 &le; {{GPUTextureViewDescriptor/mipLevelCount}} &le; {{GPUTextureDescriptor/mipLevelCount}} - {{GPUTextureViewDescriptor/baseMipLevel}}
- 0 &le; {{GPUTextureViewDescriptor/baseArrayLayer}} &lt; {{GPUTextureDescriptor/size}}.depth
Copy link
Contributor

Choose a reason for hiding this comment

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

the depth should only be related to the array layers for non-3D textures

- {{GPUTextureDescriptor/size}}.width == {{GPUTextureDescriptor/size}}.height
- {{GPUTextureViewDescriptor/arrayLayerCount}} % 6 == 0

- if |dimension| is {{GPUTextureViewDimension/"3d"}}:
Copy link
Contributor

Choose a reason for hiding this comment

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

to editors: similarly, we'll want to turn this into a switch

- 1 &le; {{GPUTextureDescriptor/size}}.depth
- Let |maxDim| = {{GPUTextureDescriptor/size}}.width
- if {{GPUTextureDescriptor/dimension}} == {{GPUTextureDimension/'2d'}}:
|maxDim| = max(|maxDim|, {{GPUTextureDescriptor/size}}.height)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe something like:

Suggested change
|maxDim| = max(|maxDim|, {{GPUTextureDescriptor/size}}.height)
Set |maxDim| = max(|maxDim|, {{GPUTextureDescriptor/size}}.height)

mainly because right now it kind of looks like a boolean condition

- 1 &le; {{GPUTextureDescriptor/size}}.width
- 1 &le; {{GPUTextureDescriptor/size}}.height
- 1 &le; {{GPUTextureDescriptor/size}}.depth
- Let |maxDim| = {{GPUTextureDescriptor/size}}.width
Copy link
Contributor

Choose a reason for hiding this comment

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

aside: One reason I've been contemplating using "must" on every line is that it fixes the awkwardness of mixing boolean expressions with imperative statements like "Let x = ...". I don't know what the right style is though.

  • 1 must ≤ size.width
  • 1 ≤ size.width must be true
  • ?

- 1 &le; {{GPUTextureDescriptor/size}}.height
- 1 &le; {{GPUTextureDescriptor/size}}.depth
- Let |maxDim| = {{GPUTextureDescriptor/size}}.width
- if {{GPUTextureDescriptor/dimension}} == {{GPUTextureDimension/'2d'}}:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: capitalize "If"
nit: slight preference for "is" over "=="

error and return an [=invalid=] {{GPUTextureView}}.
<div class=validusage>
- 0 &le; {{GPUTextureViewDescriptor/baseMipLevel}} &lt; {{GPUTextureDescriptor/mipLevelCount}}
- 1 &le; {{GPUTextureViewDescriptor/mipLevelCount}} &le; {{GPUTextureDescriptor/mipLevelCount}} - {{GPUTextureViewDescriptor/baseMipLevel}}
Copy link
Contributor

Choose a reason for hiding this comment

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

GPUTextureViewDescriptor/mipLevelCount and GPUTextureDescriptor/mipLevelCount are indistinguishable in the rendered text. Needs to be |something|.{{GPUTextureViewDescriptor/mipLevelCount}} and so on.

error and return an [=invalid=] {{GPUTextureView}}.
<div class=validusage>
- 0 &le; {{GPUTextureViewDescriptor/baseMipLevel}} &lt; {{GPUTextureDescriptor/mipLevelCount}}
- 1 &le; {{GPUTextureViewDescriptor/mipLevelCount}} &le; {{GPUTextureDescriptor/mipLevelCount}} - {{GPUTextureViewDescriptor/baseMipLevel}}
Copy link
Contributor

Choose a reason for hiding this comment

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

[1] IMO clearer as

  • view.baseMipLevel ≥ 0
  • view.mipLevelCount ≥ 1
  • view.baseMipLevel + view.mipLevelCount ≤ texture.mipLevelCount

(and note the third rule makes "view.baseMipLevel < texture.mipLevelCount" redundant)

We've done this in other places, with the assumption that numbers in the spec operate in the space of mathematical real numbers (or integers) and have no overflow behaviors.

- 0 &le; {{GPUTextureViewDescriptor/baseMipLevel}} &lt; {{GPUTextureDescriptor/mipLevelCount}}
- 1 &le; {{GPUTextureViewDescriptor/mipLevelCount}} &le; {{GPUTextureDescriptor/mipLevelCount}} - {{GPUTextureViewDescriptor/baseMipLevel}}
- 0 &le; {{GPUTextureViewDescriptor/baseArrayLayer}} &lt; {{GPUTextureDescriptor/size}}.depth
- 1 &le; {{GPUTextureViewDescriptor/arrayLayerCount}} &le; {{GPUTextureDescriptor/size}}.depth - {{GPUTextureViewDescriptor/baseArrayLayer}}
Copy link
Contributor

Choose a reason for hiding this comment

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

similar comment here to [1]

- if {{GPUTextureViewDescriptor/aspect)) == {{GPUTextureAspect/"depth-only"}}
- {{GPUTextureViewDescriptor/format}} must have a depth component
- if {{GPUTextureViewDescriptor/aspect)) == {{GPUTextureAspect/"stencil-only"}}
- {{GPUTextureViewDescriptor/format}} must have a stencil component
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- {{GPUTextureViewDescriptor/format}} must have a stencil component
- {{GPUTextureViewDescriptor/format}} must have a stencil component
Issue: create and link to algorithms for "have a {depth,stencil} component".

@Kangz
Copy link
Contributor

Kangz commented Feb 1, 2021

I opened #1397 not realizing this PR was still in flight. Can we move forward on it? Missing texture / view creation validation is a big hole.

@kainino0x
Copy link
Contributor

createView algorithm landed with #1406.

@kainino0x
Copy link
Contributor

I'll close this, we should do any remaining work from this PR in new PR(s).

@kainino0x kainino0x closed this Feb 3, 2021
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
This CL adds unimplemented stubs for the `sinh` builtin.

Issue: gpuweb#1237
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
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.

Texture dimensions should be required to be >=1 (forbid zero-sized textures)

4 participants