Skip to content
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

attribute USVString WebGLObject.label, application-provided. #3637

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

kdashg
Copy link
Contributor

@kdashg kdashg commented Apr 8, 2024

This is similar to WebGPU's GPUObjectBase.label.

@kdashg kdashg requested a review from kenrussell April 8, 2024 21:43
@kdashg
Copy link
Contributor Author

kdashg commented Apr 8, 2024

https://www.w3.org/TR/webgpu/#gpuobjectbase

interface mixin GPUObjectBase {
    attribute USVString label;
};

@greggman
Copy link
Contributor

greggman commented Apr 8, 2024

The difference between WebGPU's label and WebGL is that, AFAIK, WebGPU always returns an object. WebGL does not

// on lost context
const b = gl.createBuffer();
b.label = "verts";              // crash!, can't set property label of `null`

WebGPU doesn't have this issue

More in the spirit of WebGL would be gl.setLabel(obj?: WebGLObject, label: UVString) because then it could handle null.

Sure, the user can check for null though.

@kdashg
Copy link
Contributor Author

kdashg commented Apr 8, 2024

I strongly prefer the ergonomics of .label, and would rather champion infallible allocations instead of reduced ergonomics.

@greggman
Copy link
Contributor

greggman commented Apr 8, 2024

In the spirit of the fact that WebGL is supposed to make porting OpenGLES code easier, isn't WEBGL_debug the more WebGL-ish thing to support?

Of course it's doesn't have to be either/or but still.

@kdashg
Copy link
Contributor Author

kdashg commented Apr 8, 2024

I believe my proposal is the best way forward for the most users.

Copy link
Contributor

@kkinnunen-apple kkinnunen-apple 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, thanks.

Copy link
Member

@kenrussell kenrussell left a comment

Choose a reason for hiding this comment

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

This direction sounds good. While it's a different API style than other WebGL extensions, it's expected that this would be implementable/supportable at the native level pretty much ubiquitously.

@kdashg kdashg merged commit a49331a into KhronosGroup:main Apr 20, 2024
2 checks passed
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