← 输入框|github.com|刷新
Skip to content

Add WebGPUDebugLabel mixin and label to relevant dictionaries - #126

Merged
grorg merged 3 commits into
gpuweb:masterfrom
grorg:queue-label
Nov 22, 2018
Merged

grorg merged 3 commits into
gpuweb:masterfrom
grorg:queue-label

Conversation

@grorg

@grorg grorg commented Nov 21, 2018

Copy link
Copy Markdown
Contributor

To make debugging in Metal easier, we've found it helpful to add a label or name to MTLCommandQueue, so that you can identify in tools what commands are being executed when. We think this would also be useful in WebGPU.

However (and this is totally my fault for not paying attention) it's not clear to me how you'd create multiple WebGPUQueues, since we only expose a getter. Maybe the label should be on the command buffers?

@grorg

grorg commented Nov 21, 2018

Copy link
Copy Markdown
Contributor Author

Note this doesn't change any behaviour. It's just for exposure in tooling.

@kainino0x

Copy link
Copy Markdown
Contributor

We were just discussing how this should be exposed for all objects on #121. See my comment there about the timing - does setting the attribute "enqueue" an operation? Or is it somehow instantaneous?

@grorg

grorg commented Nov 21, 2018

Copy link
Copy Markdown
Contributor Author

Yeah, each object should have a label - so ignore this pull request until I update it.

does setting the attribute "enqueue" an operation? Or is it somehow instantaneous?

I don't see any reason why it needs to enqueue an operation. In our implementation we'll probably label everything with a unique id, and map that back to what the API exposes.

@kainino0x

Copy link
Copy Markdown
Contributor

Setting the name in JS can't instantaneously set the Metal label without a synchronous IPC round-trip in Chrome.

If you label everything with a unique id purely on the backend, Xcode would show the unique id, rather than the user's custom label; how would it get mapped back?

@grorg

grorg commented Nov 21, 2018

Copy link
Copy Markdown
Contributor Author

I'm talking about the browser-side tools.

But yes, if you use the platform tools, then you'll need to know the mapping somehow. I'd probably expose this also from browser developer tools, or some kind of internal logging.

It seems worth having it this way to avoid touching the platform label.

@kainino0x

Copy link
Copy Markdown
Contributor

For browser side tools, I'd be fine with having it be instantaneous.

Sorry, I got confused and thought you were going to propagate the debug labels down to the Metal level. That is also something I think we ought to do.

@grorg grorg changed the title Add a label attribute to WebGPUQueue Add WebGPUDebugLabel mixin and label to relevant dictionaries Nov 21, 2018
@grorg

grorg commented Nov 21, 2018

Copy link
Copy Markdown
Contributor Author

OK. Updated the pull request and changed the title. I believe this addresses #121, with the exception of the resource naming. Metal doesn't support this directly, but I'm not against including it.

I was tempted to have the relevant dictionaries inherit from a base dictionary with a label field, but I think it was nicer to have all the debugging stuff in one place at the end of the document.

@kainino0x kainino0x left a comment

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.

LGTM with one phrasing nit!

Comment thread design/sketch.webidl Outdated
partial WebGPUProgrammablePassEncoder {
void pushDebugGroup(DOMString groupName);
void popDebugGroup(DOMString groupName);
void insertDebugMarker(DOMString markerName);

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.

The term "name" is used here, but "label" is used later; I think they should match (label seems good to me)

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.

Thanks @kainino0x!

@grorg
grorg merged commit f6b5b25 into gpuweb:master Nov 22, 2018
@grorg
grorg deleted the queue-label branch November 22, 2018 23:34
@Kangz

Kangz commented Nov 27, 2018

Copy link
Copy Markdown
Contributor

This pull request made it so you can modify the object label after it has been created. Is it on purpose? The alternative of putting a name in the descriptors used to create objects seems simpler.

@magcius

magcius commented Nov 28, 2018

Copy link
Copy Markdown

@Kangz every tiny little divergence that WebGPU makes from native platforms is going to really annoy platform developers. Since every platform already allows changing modifying object label after it is created (and shipping game engines definitely already rely on this), making this immutable probably makes the implementation simpler but at the huge cost of annoying porting developers.

The debugging layer is where you would most want to fight for platform developer convenience over API purity. In my own engine, built from scratch in JavaScript designed for WebGPU, it would be a pain to thread that name all the way through to the creation-time descriptor, given the amount of code in the way. Developers will be adding in those resource name sets everywhere in debugging code. Allowing them to debug quickly and efficiently is very much worth the slight implementer inconvenience.

@Kangz

Kangz commented Nov 28, 2018

Copy link
Copy Markdown
Contributor

@magcius I very much agree with you and if naming after creation is what engine do today, they should still be able to do it on the Web. However WebGPU has a chance to be opinionated and push people to do things a certain way. It'd be nice to have both ways to set the name but say that setting it at creation time "is the better way". Maybe by having the post-creation way be a universally implemented extension?

Note that the implementation cost is almost zero for both solutions.

@magcius

magcius commented Nov 28, 2018 •

Copy link
Copy Markdown

I, personally, would save my opinions for things that have high implementation costs. I'm all for being opinionated in cases where it matters (e.g. everyone is aware that OpenGL code is difficult to properly write because it is not very opinionated and you can easily get put on a slow path), but debugging is one of those cases where the user needs all the flexibility and help they can get.

@Kangz

Kangz commented Nov 28, 2018

Copy link
Copy Markdown
Contributor

(to be clear, I meant the implementation cost on the browser side)

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.

4 participants