Skip to content

Use out-of-band messaging for the mipmap and array layer count#945

Merged
kvark merged 3 commits intomainfrom
kvark-texture-view-desc
Jul 27, 2020
Merged

Use out-of-band messaging for the mipmap and array layer count#945
kvark merged 3 commits intomainfrom
kvark-texture-view-desc

Conversation

@kvark
Copy link
Copy Markdown
Contributor

@kvark kvark commented Jul 22, 2020

This is in line with the changes we are doing for minBufferBindingSize and other sizes.

I don't like the "if xxx, defaults to yyy" scheme of things, since it's not clear how "defaults to" works in this case. This PR keeps this, but would be nice to refactor this later in follow-ups.


Preview | Diff

@kvark kvark requested review from kainino0x and litherum July 22, 2020 19:54
Copy link
Copy Markdown
Contributor

@kainino0x kainino0x left a comment

Choose a reason for hiding this comment

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

Nice, this one was on my todo list but I hadn't gotten to it yet.

spec/index.bs Outdated

* {{GPUTextureViewDescriptor/mipLevelCount}}:
If 0, defaults to |texture|.{{GPUTextureDescriptor/mipLevelCount}} − {{GPUTextureViewDescriptor/baseMipLevel}}.
If undefined or "null", defaults to |texture|.{{GPUTextureDescriptor/mipLevelCount}} − {{GPUTextureViewDescriptor/baseMipLevel}}.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is null actually allowed for optional dictionary fields? I haven't bothered to check....

I usually just say "unspecified" as a catch-all for whatever IDL does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just curious, what if it's specified as mipLevelCount: null?
It's technically specified, but we'd want to treat it as unspecified.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Depends on whether that's allowed by the IDL conversion rules (a quick test tells me it probably is).

We should find language from another spec and adopt it. here's a random one I found in the web audio spec:

https://www.w3.org/TR/webaudio/#ref-for-dom-audiocontextoptions-samplerate

If contextOptions.sampleRate is specified, set the sampleRate of this AudioContext to this value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here we are operating on the IDL representation rather than the ECMAScript representation. So this is after this algorithm has run:
https://heycam.github.io/webidl/#es-dictionary
but I'm having a hard time understanding this algorithm - it doesn't seem to say anything about how to handle optional members.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

More specifically, this:

  1. If esMemberValue is not undefined, then:
    • Let idlMemberValue be the result of converting esMemberValue to an IDL value whose type is the type member is declared to be of.

seems to say that null is NOT supposed to be treated as undefined for an optional member, and instead should fail conversion from null to GPUIntegerCoordinate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Resolved that it doesn't matter:

  • If IDL says this is an error, we don't see the null value.
  • If IDL says this is not an error, the IDL should convert JS null into IDL Undefined.

@kainino0x
Copy link
Copy Markdown
Contributor

putting this on the editors meeting agenda because I guess we want to figure out what's up with webidl

@kvark kvark merged commit 55e28d6 into main Jul 27, 2020
@kvark kvark deleted the kvark-texture-view-desc branch July 27, 2020 21:11
bors bot added a commit to gfx-rs/wgpu that referenced this pull request Jul 29, 2020
846: Make level and layer count for texture view optional r=cwfitzgerald a=kvark

**Connections**
implements gpuweb/gpuweb#945

**Description**
`NonZeroU32` is more idiomatic here

**Testing**
untested, but should work

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
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.

3 participants