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
Rename getBindGroupLayout()
to createBindGroupLayout()
#3804
Conversation
Every time it's called, it returns a new object. This is observable from Javascript like so: let bgl = pipeline.createBindGroupLayout(); bgl.foo = "bar"; let bgl2 = pipeline.createBindGroupLayout(); assert(bgl2.foo == undefined); Because it returns a new object each time, naming it "create" makes it more clear.
getBindGroupLayout()
to createBindGroupLayout()
Previews, as seen when this build job started (020879e): |
I'm unsure if this is less confusing. It's a new object handle, with a new label, yes, but bind group layouts are otherwise by-value objects. If you getBindGroupLayout() twice there's almost no difference between the two objects. I will note the semantics of the C API have been questioned before (and not litigated in webgpu-headers): "get" makes it seem it returns the same object handle with the same label field (which in Dawn it does) but also like it does not increment the refcount (which in Dawn it does) (if there ends up being a refcount in the API). |
Yes, we are struggling with this rn. We are jumping through some moderately-herculean hoops to make sure:
But I think this rename is valuable even ignoring WebGPU.h. The function returns a new thing. We could have designed it differently, to not return a new thing (where the web process would internally retain the thing it returns, for future calls). But we didn't. Bind group layouts are immutable, so the semantics of getBindGroupLayout really are "it creates a new object," even if an implementation chooses to have multiple wrappers pointing to the same object under the hood. |
…emantics https://bugs.webkit.org/show_bug.cgi?id=251732 rdar://105030025 Reviewed by Dean Jackson. This is a partial revert of 259609@main. You would think that, because the name of "getBindGroupLayout()" starts with the word "get," that it would have "get" semantics. However, the spec actually explicitly describes that it has "create" semantics. This patch updates the implementation to have those semantics. The spec specifically says "A new GPUBindGroupLayout wrapper is returned each time." gpuweb/gpuweb#3804 is a PR to the spec to rename the functions, to be more clear about their behavior. * Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUComputePipelineImpl.cpp: (PAL::WebGPU::ComputePipelineImpl::getBindGroupLayout): * Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUComputePipelineImpl.h: * Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPURenderPipelineImpl.cpp: (PAL::WebGPU::RenderPipelineImpl::getBindGroupLayout): * Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPURenderPipelineImpl.h: * Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUComputePipeline.h: * Source/WebCore/PAL/pal/graphics/WebGPU/WebGPURenderPipeline.h: * Source/WebGPU/WebGPU/APIConversions.h: (WebGPU::releaseToAPI): * Source/WebGPU/WebGPU/ComputePipeline.h: * Source/WebGPU/WebGPU/ComputePipeline.mm: (WebGPU::ComputePipeline::getBindGroupLayout): (wgpuComputePipelineGetBindGroupLayout): * Source/WebGPU/WebGPU/RenderPipeline.h: * Source/WebGPU/WebGPU/RenderPipeline.mm: (WebGPU::RenderPipeline::getBindGroupLayout): (wgpuRenderPipelineGetBindGroupLayout): * Source/WebKit/GPUProcess/graphics/WebGPU/RemoteComputePipeline.cpp: (WebKit::RemoteComputePipeline::getBindGroupLayout): * Source/WebKit/GPUProcess/graphics/WebGPU/RemoteRenderPipeline.cpp: (WebKit::RemoteRenderPipeline::getBindGroupLayout): * Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteComputePipelineProxy.cpp: (WebKit::WebGPU::RemoteComputePipelineProxy::getBindGroupLayout): * Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteComputePipelineProxy.h: * Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteRenderPipelineProxy.cpp: (WebKit::WebGPU::RemoteRenderPipelineProxy::getBindGroupLayout): * Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteRenderPipelineProxy.h: * Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.cpp: (WebKit::WebGPU::RemoteShaderModuleProxy::compilationInfo): Canonical link: https://commits.webkit.org/259866@main
While I agree that |
To try to put down some thoughts from yesterday's editor meeting, and others, into text:
Well, I've upset myself with the number of words I wrote about the choice of a single word, but here we are. |
Consensus from the F2F: Don't change this function, but rename |
GPU Web F2F 2023-02-16/17Bikeshedding names #3804 #3805 [Myles/Brandon/Kai?]
|
Every time it's called, it returns a new object. This is observable from Javascript like so:
Because it returns a new object each time, naming it "create" makes it more clear.