-
Notifications
You must be signed in to change notification settings - Fork 335
Add GPUShaderModuleDescriptor/sourceMap. #645
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for putting this together @jdashg . This does seem like it should meet our goals for allowing a rich debugging experience where WGSL is used as an intermediate language.
TL;DR The combination of these two PRs #645 and #646 make source maps normative and I want to make sure we are aware of it when we make decisions on them. While I very much agree with the sentiment in this issue that this is a good thing, I believe it will be the first time that source maps are added in an application-visible way to the Web platform. AFAIK previous usages only interact with the devtools and are not observable programmatically. The addition of sourcemaps here and the |
If we don't make them normative then I wonder what would prevent them becoming vendor-specified opaque blobs? |
There's already a cross-browser spec for this, and the way I referenced it here does make it normative. |
spec/index.bs
Outdated
}; | ||
</script> | ||
|
||
{{GPUShaderModuleDescriptor/sourceMap}}, if defined, is interpreted as a source-map-v3 format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if there's a sourcemap v4? Should there be another field that specifies the version of the sourcemap? Or would you require a new GPUShaerModuleDescriptor when that time comes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[from meeting] Source map spec has a version field at the top level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will s/is interpreted as/MAY be interpreted as/
Discussed at the 2020-04-21 meeting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just chatted with our team about this. We are comfortable with this pull request.
We're a little concerned about future-proofing this API; in particular, source maps are a big space with lots of work being done for WebAssembly. It's unlikely that the "source-map-v3" will stand the test of time, so we need to have a good story for future evolution of this API.
One possible story is "the type of sourceMap
is just an object
, so browsers can support whatever format they want in there and authors can migrate to better formats as they are supported." This is an okay start, but could possibly lead to fragmentation because this format doesn't actually affect behavior, so browsers are less incentivized to match each other. Developer tools for WebGPU are very important to us. Perhaps there is a better solution out there.
As I was talking about on the call, I think the solution used by source maps for JavaScript is a good one: there's no breakable API surface that cares about what the format of the source map is. The browsers need only to support it in their dev tools. If the application wants to apply source mapping to errors, it can do so with a userspace source map library. They ship their source maps along with that library so there's no possibility of breakage. Taking that approach is compatible with this PR as-is, but requires mappedLine et al to be removed from #646. Did you happen to get feedback from your team on that approach? |
The case we’re worried about is browser A switches to some proprietary source map format, an author develops a page in that browser using this proprietary format, someone else opens that page in Safari’s Web Inspector, sees unreadable shader contents in the relevant panel, and thinks that Safai’s dev tools are worse than browser A's. |
But that's exactly the situation with JavaScript source maps. What makes WGSL special? I also assume each browser would probably reuse the implementation it uses for JS for WGSL, so I really don't think WGSL source maps would diverge faster than JS source maps. Unless we are talking about some format that's somehow conceptually far better than source maps, in which case a browser's dev tools would actually be concretely better for supporting that new format. |
Our representatives to ECMA are concerned about this too. |
@jdashg do you think this should be discussed again at the WebGPU meeting or the WGSL meeting? |
For topics that straddle the API/shader boundary, I think the main group is best. In my mind the language meetings are like a sub-group that reports up to the main group, so topics that concern everyone would default to the full main CG meeting. |
One idea that came up in a discussion with @jdashg is making this an extension. That would allow us to still test this with the CTS, and yet allow to iterate on that later. For example, if sourcemap v4 standard comes out, we can just release a new extension. |
* Add GPUShaderModuleDescriptor/sourceMap. * Dictionary members are optional unless required, s/non-null/defined/. * `sourceMap` MAY be a source-map-v3 format, but it's not required.
* Add GPUShaderModuleDescriptor/sourceMap. * Dictionary members are optional unless required, s/non-null/defined/. * `sourceMap` MAY be a source-map-v3 format, but it's not required.
'clear' has been renamed to 'discard' in the spec.
Preview | Diff