[Webkit-unassigned] [Bug 237921] New: See if we can get rid of all the WGPU stub structs
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Mar 15 14:30:33 PDT 2022
https://bugs.webkit.org/show_bug.cgi?id=237921
Bug ID: 237921
Summary: See if we can get rid of all the WGPU stub structs
Product: WebKit
Version: WebKit Nightly Build
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: WebGPU
Assignee: webkit-unassigned at lists.webkit.org
Reporter: mmaxfield at apple.com
The shared WebGPU.h header has:
typedef struct WGPUDeviceImpl* WGPUDevice;
However, it would be convenient if we could have our own names like this:
namespace WebGPU {
class Device {
...
id<MTLDevice> m_device;
...
}
}
I thought of 3 possible solutions:
1. Use reinterpret_cast<>() to freely convert between WGPUDeviceImpl* and WebGPU::Device*. This breaks C++'s type system, and is technically UB (I think) so I was hoping to avoid this option.
2. Don't have nice names, and don't use "namespace WebGPU":
struct WGPUDeviceImpl {
...
id<MTLDevice> m_device;
...
}
This is unfortunate because it foregoes C++'s built-in namespace support in favor of prefixes, and isn't the pattern we use for the rest of WebKit
3. Do a double-pointer-indirection:
struct WGPUDeviceImpl {
Ref<WebGPU::Device> device;
};
This isn't great for performance (though it's probably negligible) and has a somewhat bad smell about having two types which mean the same thing.
For the initial implementation, I chose option 3, under the assumption that it would be easy/mechanical to change later if a better option presents itself.
We should see if there is a better solution.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220315/0b1cff5e/attachment.htm>
More information about the webkit-unassigned
mailing list