Title: [294373] trunk/Source/WebCore/Modules/WebGPU
- Revision
- 294373
- Author
- mmaxfi...@apple.com
- Date
- 2022-05-17 18:09:07 -0700 (Tue, 17 May 2022)
Log Message
[WebGPU] Work around https://bugs.webkit.org/show_bug.cgi?id=240219
https://bugs.webkit.org/show_bug.cgi?id=240441
https://bugs.webkit.org/show_bug.cgi?id=240219 is about a bug where we can't
say "optional thingy = 0" in an IDL file. This patch works around that in WebGPU
by replacing it with "optional thingy" and then "thingy.value_or(0)" in the C++
code. This is temporary, until https://bugs.webkit.org/show_bug.cgi?id=240219 is
fixed.
No new tests because there is no behavior change.
* Modules/WebGPU/GPUBuffer.cpp:
(WebCore::GPUBuffer::mapAsync):
(WebCore::GPUBuffer::getMappedRange):
* Modules/WebGPU/GPUBuffer.h:
* Modules/WebGPU/GPUBuffer.idl:
Canonical link: https://commits.webkit.org/250668@main
Modified Paths
Diff
Modified: trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.cpp (294372 => 294373)
--- trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.cpp 2022-05-18 00:59:47 UTC (rev 294372)
+++ trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.cpp 2022-05-18 01:09:07 UTC (rev 294373)
@@ -38,16 +38,16 @@
m_backing->setLabel(WTFMove(label));
}
-void GPUBuffer::mapAsync(GPUMapModeFlags mode, GPUSize64 offset, std::optional<GPUSize64> size, MapAsyncPromise&& promise)
+void GPUBuffer::mapAsync(GPUMapModeFlags mode, std::optional<GPUSize64> offset, std::optional<GPUSize64> size, MapAsyncPromise&& promise)
{
- m_backing->mapAsync(convertMapModeFlagsToBacking(mode), offset, size, [promise = WTFMove(promise)] () mutable {
+ m_backing->mapAsync(convertMapModeFlagsToBacking(mode), offset.value_or(0), size, [promise = WTFMove(promise)] () mutable {
promise.resolve(nullptr);
});
}
-Ref<JSC::ArrayBuffer> GPUBuffer::getMappedRange(GPUSize64 offset, std::optional<GPUSize64> size)
+Ref<JSC::ArrayBuffer> GPUBuffer::getMappedRange(std::optional<GPUSize64> offset, std::optional<GPUSize64> size)
{
- auto mappedRange = m_backing->getMappedRange(offset, size);
+ auto mappedRange = m_backing->getMappedRange(offset.value_or(0), size);
return ArrayBuffer::create(mappedRange.source, mappedRange.byteLength);
}
Modified: trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.h (294372 => 294373)
--- trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.h 2022-05-18 00:59:47 UTC (rev 294372)
+++ trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.h 2022-05-18 01:09:07 UTC (rev 294373)
@@ -49,8 +49,8 @@
void setLabel(String&&);
using MapAsyncPromise = DOMPromiseDeferred<IDLNull>;
- void mapAsync(GPUMapModeFlags, GPUSize64 offset, std::optional<GPUSize64> sizeForMap, MapAsyncPromise&&);
- Ref<JSC::ArrayBuffer> getMappedRange(GPUSize64 offset, std::optional<GPUSize64> rangeSize);
+ void mapAsync(GPUMapModeFlags, std::optional<GPUSize64> offset, std::optional<GPUSize64> sizeForMap, MapAsyncPromise&&);
+ Ref<JSC::ArrayBuffer> getMappedRange(std::optional<GPUSize64> offset, std::optional<GPUSize64> rangeSize);
void unmap();
void destroy();
Modified: trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.idl (294372 => 294373)
--- trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.idl 2022-05-18 00:59:47 UTC (rev 294372)
+++ trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.idl 2022-05-18 01:09:07 UTC (rev 294373)
@@ -35,8 +35,9 @@
SecureContext
]
interface GPUBuffer {
- Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
- ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=240219 The next two lines should be able to say "optional thingy = 0" instead of just "optional thingy".
+ Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset, optional GPUSize64 size);
+ ArrayBuffer getMappedRange(optional GPUSize64 offset, optional GPUSize64 size);
undefined unmap();
undefined destroy();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes