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

Changeset 243658 in webkit


Ignore:
Timestamp:
Mar 29, 2019, 1:18:38 PM (7 years ago)
Author:
Justin Fan
Message:

[Web GPU] Replace unsigned longs in WebGPU with uint64_t
https://bugs.webkit.org/show_bug.cgi?id=196401

Reviewed by Myles C. Maxfield.

Unsigned long is not guaranteed to be 64 bits on all platforms. In addition, rowPitch is updated
to u32 in the API and the implementation to match.

No new tests. No new behavior.

  • Modules/webgpu/WebGPUBuffer.cpp:

(WebCore::WebGPUBuffer::setSubData):

  • Modules/webgpu/WebGPUBuffer.h:
  • Modules/webgpu/WebGPUBufferBinding.h:
  • Modules/webgpu/WebGPUCommandEncoder.cpp:

(WebCore::WebGPUCommandEncoder::copyBufferToBuffer):

  • Modules/webgpu/WebGPUCommandEncoder.h:
  • Modules/webgpu/WebGPUCommandEncoder.idl:
  • Modules/webgpu/WebGPURenderPassEncoder.cpp:

(WebCore::WebGPURenderPassEncoder::setVertexBuffers):

  • Modules/webgpu/WebGPURenderPassEncoder.h:
  • platform/graphics/gpu/GPUBindGroupLayout.h:
  • platform/graphics/gpu/GPUBuffer.h:

(WebCore::GPUBuffer::byteLength const):

  • platform/graphics/gpu/GPUBufferBinding.h:
  • platform/graphics/gpu/GPUBufferDescriptor.h:
  • platform/graphics/gpu/GPUCommandBuffer.h:
  • platform/graphics/gpu/GPURenderPassEncoder.h:
  • platform/graphics/gpu/GPUVertexAttributeDescriptor.h:
  • platform/graphics/gpu/GPUVertexInputDescriptor.h:
  • platform/graphics/gpu/cocoa/GPUBufferMetal.mm:

(WebCore::GPUBuffer::GPUBuffer):
(WebCore::GPUBuffer::setSubData):

  • platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm:

(WebCore::GPUCommandBuffer::copyBufferToBuffer):

  • platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:

(WebCore::GPURenderPassEncoder::setVertexBuffers):

Location:
trunk/Source/WebCore
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243656 r243658  
     12019-03-29  Justin Fan  <justin_fan@apple.com>
     2
     3        [Web GPU] Replace unsigned longs in WebGPU with uint64_t
     4        https://bugs.webkit.org/show_bug.cgi?id=196401
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Unsigned long is not guaranteed to be 64 bits on all platforms. In addition, rowPitch is updated
     9        to u32 in the API and the implementation to match.
     10
     11        No new tests. No new behavior.
     12
     13        * Modules/webgpu/WebGPUBuffer.cpp:
     14        (WebCore::WebGPUBuffer::setSubData):
     15        * Modules/webgpu/WebGPUBuffer.h:
     16        * Modules/webgpu/WebGPUBufferBinding.h:
     17        * Modules/webgpu/WebGPUCommandEncoder.cpp:
     18        (WebCore::WebGPUCommandEncoder::copyBufferToBuffer):
     19        * Modules/webgpu/WebGPUCommandEncoder.h:
     20        * Modules/webgpu/WebGPUCommandEncoder.idl:
     21        * Modules/webgpu/WebGPURenderPassEncoder.cpp:
     22        (WebCore::WebGPURenderPassEncoder::setVertexBuffers):
     23        * Modules/webgpu/WebGPURenderPassEncoder.h:
     24        * platform/graphics/gpu/GPUBindGroupLayout.h:
     25        * platform/graphics/gpu/GPUBuffer.h:
     26        (WebCore::GPUBuffer::byteLength const):
     27        * platform/graphics/gpu/GPUBufferBinding.h:
     28        * platform/graphics/gpu/GPUBufferDescriptor.h:
     29        * platform/graphics/gpu/GPUCommandBuffer.h:
     30        * platform/graphics/gpu/GPURenderPassEncoder.h:
     31        * platform/graphics/gpu/GPUVertexAttributeDescriptor.h:
     32        * platform/graphics/gpu/GPUVertexInputDescriptor.h:
     33        * platform/graphics/gpu/cocoa/GPUBufferMetal.mm:
     34        (WebCore::GPUBuffer::GPUBuffer):
     35        (WebCore::GPUBuffer::setSubData):
     36        * platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm:
     37        (WebCore::GPUCommandBuffer::copyBufferToBuffer):
     38        * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
     39        (WebCore::GPURenderPassEncoder::setVertexBuffers):
     40
    1412019-03-29  Wenson Hsieh  <wenson_hsieh@apple.com>
    242
  • trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.cpp

    r243636 r243658  
    4343}
    4444
    45 void WebGPUBuffer::setSubData(unsigned long offset, const JSC::ArrayBuffer& data)
     45void WebGPUBuffer::setSubData(uint64_t offset, const JSC::ArrayBuffer& data)
    4646{
    4747    if (!m_buffer)
  • trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.h

    r243636 r243658  
    4949    const GPUBuffer* buffer() const { return m_buffer.get(); }
    5050
    51     void setSubData(unsigned long, const JSC::ArrayBuffer&);
     51    void setSubData(uint64_t, const JSC::ArrayBuffer&);
    5252    using BufferMappingPromise = DOMPromiseDeferred<IDLInterface<JSC::ArrayBuffer>>;
    5353    void mapReadAsync(BufferMappingPromise&&);
  • trunk/Source/WebCore/Modules/webgpu/WebGPUBufferBinding.h

    r243636 r243658  
    3535struct WebGPUBufferBinding {
    3636    RefPtr<WebGPUBuffer> buffer;
    37     unsigned long offset;
    38     unsigned long size;
     37    uint64_t offset;
     38    uint64_t size;
    3939};
    4040
  • trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.cpp

    r243627 r243658  
    9999}
    100100
    101 void WebGPUCommandEncoder::copyBufferToBuffer(WebGPUBuffer& src, unsigned long srcOffset, WebGPUBuffer& dst, unsigned long dstOffset, unsigned long size)
     101void WebGPUCommandEncoder::copyBufferToBuffer(WebGPUBuffer& src, uint64_t srcOffset, WebGPUBuffer& dst, uint64_t dstOffset, uint64_t size)
    102102{
    103103    if (!m_commandBuffer) {
  • trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.h

    r243627 r243658  
    6161    Ref<WebGPURenderPassEncoder> beginRenderPass(const WebGPURenderPassDescriptor&);
    6262    Ref<WebGPUComputePassEncoder> beginComputePass();
    63     void copyBufferToBuffer(WebGPUBuffer&, unsigned long srcOffset, WebGPUBuffer&, unsigned long dstOffset, unsigned long size);
     63    void copyBufferToBuffer(WebGPUBuffer&, uint64_t srcOffset, WebGPUBuffer&, uint64_t dstOffset, uint64_t size);
    6464    void copyBufferToTexture(const WebGPUBufferCopyView&, const WebGPUTextureCopyView&, const GPUExtent3D&);
    6565    void copyTextureToBuffer(const WebGPUTextureCopyView&, const WebGPUBufferCopyView&, const GPUExtent3D&);
  • trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.idl

    r243627 r243658  
    3535    WebGPUBuffer buffer;
    3636    u64 offset;
    37     u64 rowPitch;
     37    u32 rowPitch;
    3838    u32 imageHeight;
    3939};
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp

    r243636 r243658  
    6161}
    6262
    63 void WebGPURenderPassEncoder::setVertexBuffers(unsigned startSlot, Vector<RefPtr<WebGPUBuffer>>&& buffers, Vector<unsigned long long>&& offsets)
     63void WebGPURenderPassEncoder::setVertexBuffers(unsigned startSlot, Vector<RefPtr<WebGPUBuffer>>&& buffers, Vector<uint64_t>&& offsets)
    6464{
    6565#if !LOG_DISABLED
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h

    r243636 r243658  
    4444
    4545    void setPipeline(const WebGPURenderPipeline&);
    46     void setVertexBuffers(unsigned, Vector<RefPtr<WebGPUBuffer>>&&, Vector<unsigned long long>&&);
     46    void setVertexBuffers(unsigned, Vector<RefPtr<WebGPUBuffer>>&&, Vector<uint64_t>&&);
    4747    void draw(unsigned vertexCount, unsigned instanceCount, unsigned firstVertex, unsigned firstInstance);
    4848
  • trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.h

    r243636 r243658  
    4848    static RefPtr<GPUBindGroupLayout> tryCreate(const GPUDevice&, const GPUBindGroupLayoutDescriptor&);
    4949
    50     using BindingsMapType = HashMap<unsigned long, GPUBindGroupLayoutBinding, WTF::IntHash<unsigned long>, WTF::UnsignedWithZeroKeyHashTraits<unsigned long>>;
     50    using BindingsMapType = HashMap<uint64_t, GPUBindGroupLayoutBinding, WTF::IntHash<uint64_t>, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>>;
    5151    const BindingsMapType& bindingsMap() const { return m_bindingsMap; }
    5252#if USE(METAL)
  • trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h

    r243563 r243658  
    7272
    7373    PlatformBuffer *platformBuffer() const { return m_platformBuffer.get(); }
    74     unsigned long byteLength() const { return m_byteLength; }
     74    uint64_t byteLength() const { return m_byteLength; }
    7575    bool isTransferSource() const { return m_usage.contains(GPUBufferUsage::Flags::TransferSource); }
    7676    bool isTransferDestination() const { return m_usage.contains(GPUBufferUsage::Flags::TransferDestination); }
     
    8989#endif
    9090
    91     void setSubData(unsigned long, const JSC::ArrayBuffer&);
     91    void setSubData(uint64_t, const JSC::ArrayBuffer&);
    9292    using MappingCallback = WTF::Function<void(JSC::ArrayBuffer*)>;
    9393    void registerMappingCallback(MappingCallback&&, bool);
     
    110110    static bool validateBufferUsage(const GPUDevice&, OptionSet<GPUBufferUsage::Flags>);
    111111
    112     GPUBuffer(PlatformBufferSmartPtr&&, unsigned long, OptionSet<GPUBufferUsage::Flags>, Ref<GPUDevice>&&);
     112    GPUBuffer(PlatformBufferSmartPtr&&, uint64_t, OptionSet<GPUBufferUsage::Flags>, Ref<GPUDevice>&&);
    113113
    114114    JSC::ArrayBuffer* stagingBufferForRead();
     
    132132    DeferrableTask<Timer> m_mappingCallbackTask;
    133133
    134     unsigned long m_byteLength;
     134    uint64_t m_byteLength;
    135135    OptionSet<GPUBufferUsage::Flags> m_usage;
    136136    unsigned m_numScheduledCommandBuffers { 0 };
  • trunk/Source/WebCore/platform/graphics/gpu/GPUBufferBinding.h

    r243636 r243658  
    3535struct GPUBufferBinding {
    3636    Ref<GPUBuffer> buffer;
    37     unsigned long offset;
    38     unsigned long size;
     37    uint64_t offset;
     38    uint64_t size;
    3939};
    4040
  • trunk/Source/WebCore/platform/graphics/gpu/GPUBufferDescriptor.h

    r241328 r243658  
    3333
    3434struct GPUBufferDescriptor {
    35     unsigned long size;
     35    uint64_t size;
    3636    GPUBufferUsageFlags usage;
    3737};
  • trunk/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.h

    r242974 r243658  
    4949
    5050struct GPUBufferCopyViewBase {
    51     unsigned long offset;
    52     unsigned long rowPitch;
     51    uint64_t offset;
     52    unsigned rowPitch;
    5353    unsigned imageHeight;
    5454};
     
    9595#endif
    9696
    97     void copyBufferToBuffer(Ref<GPUBuffer>&&, unsigned long srcOffset, Ref<GPUBuffer>&&, unsigned long dstOffset, unsigned long size);
     97    void copyBufferToBuffer(Ref<GPUBuffer>&&, uint64_t srcOffset, Ref<GPUBuffer>&&, uint64_t dstOffset, uint64_t size);
    9898    void copyBufferToTexture(GPUBufferCopyView&&, GPUTextureCopyView&&, const GPUExtent3D&);
    9999    void copyTextureToBuffer(GPUTextureCopyView&&, GPUBufferCopyView&&, const GPUExtent3D&);
  • trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h

    r243636 r243658  
    5353
    5454    void setPipeline(Ref<const GPURenderPipeline>&&);
    55     void setVertexBuffers(unsigned, Vector<Ref<GPUBuffer>>&&, Vector<unsigned long long>&&);
     55    void setVertexBuffers(unsigned, Vector<Ref<GPUBuffer>>&&, Vector<uint64_t>&&);
    5656    void draw(unsigned vertexCount, unsigned instanceCount, unsigned firstVertex, unsigned firstInstance);
    5757
  • trunk/Source/WebCore/platform/graphics/gpu/GPUVertexAttributeDescriptor.h

    r242972 r243658  
    4242    unsigned shaderLocation;
    4343    unsigned inputSlot;
    44     unsigned long offset;
     44    uint64_t offset;
    4545    GPUVertexFormat format;
    4646};
  • trunk/Source/WebCore/platform/graphics/gpu/GPUVertexInputDescriptor.h

    r242972 r243658  
    3737struct GPUVertexInputDescriptor {
    3838    unsigned inputSlot;
    39     unsigned long stride;
     39    uint64_t stride;
    4040    GPUInputStepMode stepMode;
    4141};
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm

    r243563 r243658  
    9292}
    9393
    94 GPUBuffer::GPUBuffer(RetainPtr<MTLBuffer>&& buffer, unsigned long size, OptionSet<GPUBufferUsage::Flags> usage, Ref<GPUDevice>&& device)
     94GPUBuffer::GPUBuffer(RetainPtr<MTLBuffer>&& buffer, uint64_t size, OptionSet<GPUBufferUsage::Flags> usage, Ref<GPUDevice>&& device)
    9595    : m_platformBuffer(WTFMove(buffer))
    9696    , m_device(WTFMove(device))
     
    120120}
    121121
    122 void GPUBuffer::setSubData(unsigned long offset, const JSC::ArrayBuffer& data)
     122void GPUBuffer::setSubData(uint64_t offset, const JSC::ArrayBuffer& data)
    123123{
    124124    MTLCommandQueue *queue;
     
    138138#endif
    139139
    140     auto subDataLength = checkedSum<unsigned long>(data.byteLength(), offset);
     140    auto subDataLength = checkedSum<uint64_t>(data.byteLength(), offset);
    141141    if (subDataLength.hasOverflowed() || subDataLength.unsafeGet() > m_byteLength) {
    142142        LOG(WebGPU, "GPUBuffer::setSubData(): Invalid offset or data size!");
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm

    r243563 r243658  
    9494}
    9595
    96 void GPUCommandBuffer::copyBufferToBuffer(Ref<GPUBuffer>&& src, unsigned long srcOffset, Ref<GPUBuffer>&& dst, unsigned long dstOffset, unsigned long size)
     96void GPUCommandBuffer::copyBufferToBuffer(Ref<GPUBuffer>&& src, uint64_t srcOffset, Ref<GPUBuffer>&& dst, uint64_t dstOffset, uint64_t size)
    9797{
    9898    if (!src->isTransferSource() || !dst->isTransferDestination()) {
     
    108108#endif
    109109
    110     auto srcLength = checkedSum<unsigned long>(size, srcOffset);
    111     auto dstLength = checkedSum<unsigned long>(size, dstOffset);
     110    auto srcLength = checkedSum<uint64_t>(size, srcOffset);
     111    auto dstLength = checkedSum<uint64_t>(size, dstOffset);
    112112    if (srcLength.hasOverflowed() || dstLength.hasOverflowed()
    113113        || srcLength.unsafeGet() > src->byteLength() || dstLength.unsafeGet() > dst->byteLength()) {
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm

    r243636 r243658  
    205205}
    206206
    207 void GPURenderPassEncoder::setVertexBuffers(unsigned index, Vector<Ref<GPUBuffer>>&& buffers, Vector<unsigned long long>&& offsets)
     207void GPURenderPassEncoder::setVertexBuffers(unsigned index, Vector<Ref<GPUBuffer>>&& buffers, Vector<uint64_t>&& offsets)
    208208{
    209209    if (!m_platformRenderPassEncoder) {
Note: See TracChangeset for help on using the changeset viewer.