Sitelet https://github.com/gpuweb/gpuweb/pull/1309
Skip to content

Remove GPUDevice.{adapter,features,limits} - #1309

Closed
kainino0x wants to merge 1 commit into
gpuweb:mainfrom
kainino0x:no-device-capabilities
Closed

kainino0x wants to merge 1 commit into
gpuweb:mainfrom
kainino0x:no-device-capabilities

Conversation

@kainino0x

@kainino0x kainino0x commented Dec 15, 2020 •

Copy link
Copy Markdown
Contributor

We don't normally include reflection info (e.g. texture dimensions) on objects. Removing them on GPUDevice as well is consistent and makes specification and implementation simpler.

For internal usage, GPUDevice.[[device]].{[[adapter]],[[features]],[[limits]]} still exist.


Preview | Diff

We don't normally include reflection info (e.g. texture dimensions) on
objects. Removing them on GPUDevice as well is consistent and makes
specification simpler.

For internal usage, GPUDevice.[[device]].{[[adapter]],[[features]],[[limits]]}
still exist.
@github-actions

Copy link
Copy Markdown
Contributor

Previews, as seen at the time of posting this comment:
WebGPU | IDL
WGSL
4ade04a

Comment thread spec/index.bs
interface GPUDevice : EventTarget {
[SameObject] readonly attribute GPUAdapter adapter;
readonly attribute FrozenArray<GPUFeatureName> features;
readonly attribute object limits;

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.

This was a way to know the default limits from WebGPU by looking at what's in device.limits. How do we envision applications should do this?

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.

Good question. Perhaps a default constructor to GPUAdapterFeatures? Or a member on navigator.gpu? It would also tell you what limits are understood by the browser without having to request adapters.

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.

well, we have the default limits in the spec, wouldn't this make the other means of discovery unnecessary?

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.

Other than feature detection, I think so. It would be handy for certain architectures and middlewares but so would a lot of other things we don't provide (like texture size).

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.

I guess we could the default limits for all the things in a utility library, it just seems slightly unnecessary.

@kdashg

kdashg commented Dec 18, 2020

Copy link
Copy Markdown
Contributor

I actually would love to see us go the other way on offering reflection of e.g. parent objects. It's such a great quality-of-life thing, and I use it all the time e.g. WebGLRenderingContext.canvas.width = N. We already have this info internally, and I think it makes life better if we just expose it. Every shim library I've written ends up injecting parent references, but has to go through extra function hooking shenanigans to make it happen, so this would make things simpler and more robust for that usage too.

Worth noting that having this sort of reflection (e.g. GetDesc) is something that generally makes D3D nicer to work with than other less "reflective" APIs.

It seems like having this reflection shouldn't make specification any harder than having them be hidden, other than the boilerplate specification of "here's a readonly accessor".

@kainino0x

Copy link
Copy Markdown
Contributor Author

Honestly I might be fine with adding reflection of the provided parent object (e.g. texture.device or view.texture) and descriptor (though unfortunately it adds some unavoidable client side memory cost). All of our descriptor info is immutable so it makes it relatively tractable to do so. It also technically provides a (very late) feature detection for what members of a descriptor were recognized by the browser (but we're trying hard to never introduce something where this would be a problem).

@kainino0x

Copy link
Copy Markdown
Contributor Author
  • Do we want parent pointers?

@kvark

kvark commented Jan 11, 2021

Copy link
Copy Markdown
Contributor

I'd love us to have a solid and consistent approach here. If we want to expose the parents, and do it for all objects, that seems fine, since it's self-contained. But if we expose the BufferDescriptor but not BindGroupDescriptor, that begs a question "why". And sooner or later SpectreJs comes to us and asks for the latter after getting the former.

Another aspect to keep in mind is what the effect of this is on webgpu-native. Keeping an extra link or two per object may have a stronger effect than it does on the Web.

@kainino0x

Copy link
Copy Markdown
Contributor Author

I think webgpu-native can make this decision independently. But as long as we have weakrefs then we still avoid cycles.

@litherum

litherum commented Feb 8, 2021 •

Copy link
Copy Markdown
Contributor

Honestly I might be fine with adding reflection of the ... descriptor

One thing to keep in mind: descriptors are dictionaries, and any unknown keys are ignored. If we're going to retain these descriptors, we'll have to decide whether we want to retain the unknown keys or not.

Also, any version of retaining the descriptors has to do a deep copy instead of a shallow copy, because we don't want JS modifying a dictionary after the fact to change the object's reported characteristics. Therefore, if we want to retain those objects, we might have to say like "we'll only do a deep copy of the object if its shallowclonable (or whatever) and if it's not we'll do a shallow copy." But this is getting into a world of hurt. I wish we could just ignore unknown keys (and misparsed values)

(Also, the CSS Font Loading API discards unknown keys.)

There's also another benefit to returning the parsed values - web authors can figure out what the browser accepts and what it doesn't, in order to have fallback logic. I'm not sure how much value this would have in WebGPU specifically, where I think we're encouraging authors to do this fallback at the extension level and not at the individual function call level... but this approach of "round-trip stuff through the browser to see what it understands" is at least idiomatic JavaScript.

@kainino0x

Copy link
Copy Markdown
Contributor Author

I agree we would not retain unknown keys. Since the create methods take dictionaries, the original object and extra keys are invisible to us. This applies recursively to dictionary and sequence types. Reference types (interface, object, any) would need to keep pointing to the same JS wrapper, but we don't have many of those. (And I would imagine not doing reflection for e.g. bind group internals.)

@kainino0x

Copy link
Copy Markdown
Contributor Author

Editors discussed and decided that GPUDevice.features and .limits are useful for a lot of stuff, and we should keep them. I'll open a separate PR to remove .adapter.

@kainino0x kainino0x closed this Mar 1, 2021
@kainino0x
kainino0x deleted the no-device-capabilities branch March 8, 2021 22:01
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
This PR adds unimplemented specs for the `asin` builtin.

Issue: gpuweb#1213
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.

5 participants