⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 294373 in webkit


Ignore:
Timestamp:
May 17, 2022, 6:09:07 PM (4 years ago)
Author:
mmaxfield@apple.com
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

Location:
trunk/Source/WebCore/Modules/WebGPU
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.cpp

    r289978 r294373  
    3939}
    4040
    41 void GPUBuffer::mapAsync(GPUMapModeFlags mode, GPUSize64 offset, std::optional<GPUSize64> size, MapAsyncPromise&& promise)
     41void GPUBuffer::mapAsync(GPUMapModeFlags mode, std::optional<GPUSize64> offset, std::optional<GPUSize64> size, MapAsyncPromise&& promise)
    4242{
    43     m_backing->mapAsync(convertMapModeFlagsToBacking(mode), offset, size, [promise = WTFMove(promise)] () mutable {
     43    m_backing->mapAsync(convertMapModeFlagsToBacking(mode), offset.value_or(0), size, [promise = WTFMove(promise)] () mutable {
    4444        promise.resolve(nullptr);
    4545    });
    4646}
    4747
    48 Ref<JSC::ArrayBuffer> GPUBuffer::getMappedRange(GPUSize64 offset, std::optional<GPUSize64> size)
     48Ref<JSC::ArrayBuffer> GPUBuffer::getMappedRange(std::optional<GPUSize64> offset, std::optional<GPUSize64> size)
    4949{
    50     auto mappedRange = m_backing->getMappedRange(offset, size);
     50    auto mappedRange = m_backing->getMappedRange(offset.value_or(0), size);
    5151    return ArrayBuffer::create(mappedRange.source, mappedRange.byteLength);
    5252}
  • trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.h

    r289978 r294373  
    5050
    5151    using MapAsyncPromise = DOMPromiseDeferred<IDLNull>;
    52     void mapAsync(GPUMapModeFlags, GPUSize64 offset, std::optional<GPUSize64> sizeForMap, MapAsyncPromise&&);
    53     Ref<JSC::ArrayBuffer> getMappedRange(GPUSize64 offset, std::optional<GPUSize64> rangeSize);
     52    void mapAsync(GPUMapModeFlags, std::optional<GPUSize64> offset, std::optional<GPUSize64> sizeForMap, MapAsyncPromise&&);
     53    Ref<JSC::ArrayBuffer> getMappedRange(std::optional<GPUSize64> offset, std::optional<GPUSize64> rangeSize);
    5454    void unmap();
    5555
  • trunk/Source/WebCore/Modules/WebGPU/GPUBuffer.idl

    r288118 r294373  
    3636]
    3737interface GPUBuffer {
    38     Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
    39     ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
     38    // 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".
     39    Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset, optional GPUSize64 size);
     40    ArrayBuffer getMappedRange(optional GPUSize64 offset, optional GPUSize64 size);
    4041    undefined unmap();
    4142
Note: See TracChangeset for help on using the changeset viewer.