Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: cff04f81eb10bd7f7b8fad6204252122612c94e6
https://github.com/WebKit/WebKit/commit/cff04f81eb10bd7f7b8fad6204252122612c94e6
Author: Cameron McCormack <[email protected]>
Date: 2025-03-06 (Thu, 06 Mar 2025)
Changed paths:
M Source/WebCore/Modules/WebGPU/Implementation/WebGPUAdapterImpl.cpp
M Source/WebCore/Modules/WebGPU/Implementation/WebGPUCommandEncoderImpl.cpp
M Source/WebCore/Modules/WebGPU/Implementation/WebGPUDeviceImpl.cpp
M Source/WebGPU/WebGPU/PipelineLayout.mm
M Source/WebGPU/WebGPU/RenderBundle.h
M Source/WebGPU/WebGPU/RenderBundle.mm
M Source/WebGPU/WebGPU/RenderBundleEncoder.h
M Source/WebGPU/WebGPU/RenderBundleEncoder.mm
Log Message:
-----------
[WebGPU] Make descriptor count / pointer initialization more consistent
rdar://146352901
https://bugs.webkit.org/show_bug.cgi?id=289215
Reviewed by Mike Wyrzykowski.
In a number of the descriptor structs in WebGPU.h (and a couple of our
own descriptor structs), lists of objects are described with a count
variable and a pointer. We are not consistent about how we initialize
these.
1. In https://bugs.webkit.org/show_bug.cgi?id=261511 we updated the
WebGPU.h API header, and that updated the count member variables to
be size_t. Adjust call sites so we no longer static_cast any counts
down to uint32_t.
2. We sometimes look at whether the span or vector we're initializing
from is empty, and if so store nullptr, and in other cases store
whatever is returned from span::data() / Vector::data(). Always check
and use nullptr when we're initializing from an empty list.
3. The RenderBundle and RenderBundleEncoder constructors initialize
their m_descriptor members by copying the descriptor object passed
in. This uses a copy constructor, and so causes the object to begin
with a pointer to data held elsewhere. In the constructor body, we
overwrite the pointer, but only if the size is non-zero. Change this
to initialize to nullptr of the size is zero, so we don't keep around
a stale pointer to someone else's memory (even if we wouldn't
currently use it).
4. While here, make the Vector member variables on RenderBundle and
RenderBundleEncoder that we keep a pointer into const, to make it
less likely we modify it. (Another option would be to use a fixed
allocation that cannot be modified, like UniqueArray, but UniqueArray
does not have all the nice API that Vector has, nor its bounds
checking operator[].)
5. Device::createPipelineLayout checks that
descriptor.bindGroupLayoutsSpan() has a non-null based pointer, but
semantically we want to check if the span is empty. If we have a span
formed by a non-null base pointer and a zero count, we'd still
proceed to create optionalBindGroupLayouts, which is wasteful. Change
this to check the span's emptiness.
* Source/WebCore/Modules/WebGPU/Implementation/WebGPUAdapterImpl.cpp:
(WebCore::WebGPU::AdapterImpl::requestDevice):
* Source/WebCore/Modules/WebGPU/Implementation/WebGPUCommandEncoderImpl.cpp:
(WebCore::WebGPU::CommandEncoderImpl::beginRenderPass):
* Source/WebCore/Modules/WebGPU/Implementation/WebGPUDeviceImpl.cpp:
(WebCore::WebGPU::DeviceImpl::createTexture):
(WebCore::WebGPU::DeviceImpl::createBindGroupLayout):
(WebCore::WebGPU::DeviceImpl::createPipelineLayout):
(WebCore::WebGPU::DeviceImpl::createBindGroup):
(WebCore::WebGPU::DeviceImpl::createShaderModule):
(WebCore::WebGPU::convertToBacking):
(WebCore::WebGPU::DeviceImpl::createRenderBundleEncoder):
* Source/WebGPU/WebGPU/PipelineLayout.mm:
(WebGPU::Device::createPipelineLayout):
* Source/WebGPU/WebGPU/RenderBundle.h:
* Source/WebGPU/WebGPU/RenderBundle.mm:
(WebGPU::RenderBundle::RenderBundle):
* Source/WebGPU/WebGPU/RenderBundleEncoder.h:
* Source/WebGPU/WebGPU/RenderBundleEncoder.mm:
Canonical link: https://commits.webkit.org/291688@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes