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

Changeset 286124 in webkit


Ignore:
Timestamp:
Nov 22, 2021, 5:46:52 PM (5 years ago)
Author:
mmaxfield@apple.com
Message:

[WebGPU] Use OptionSet where it makes sense to
https://bugs.webkit.org/show_bug.cgi?id=233434

Reviewed by Wenson Hsieh.

Source/WebCore:

The fact that the IDL has a bunch of hardcoded const variables doesn't mean we have to.

No new tests because there is no behavior change.

  • Modules/WebGPU/GPUBufferUsage.h:

(WebCore::convertBufferUsageFlagsToBacking):

  • Modules/WebGPU/GPUColorWrite.h:

(WebCore::convertColorWriteFlagsToBacking):

  • Modules/WebGPU/GPUMapMode.h:

(WebCore::convertMapModeFlagsToBacking):

  • Modules/WebGPU/GPUShaderStage.h:

(WebCore::convertShaderStageFlagsToBacking):

  • Modules/WebGPU/GPUTextureUsage.h:

(WebCore::convertTextureUsageFlagsToBacking):

Source/WebCore/PAL:

  • pal/graphics/WebGPU/Impl/WebGPUConvertToBackingContext.cpp:

(PAL::WebGPU::ConvertToBackingContext::convertBufferUsageFlagsToBacking):
(PAL::WebGPU::ConvertToBackingContext::convertColorWriteFlagsToBacking):
(PAL::WebGPU::ConvertToBackingContext::convertMapModeFlagsToBacking):
(PAL::WebGPU::ConvertToBackingContext::convertShaderStageFlagsToBacking):
(PAL::WebGPU::ConvertToBackingContext::convertTextureUsageFlagsToBacking):

  • pal/graphics/WebGPU/WebGPUBufferUsage.h:
  • pal/graphics/WebGPU/WebGPUColorWrite.h:
  • pal/graphics/WebGPU/WebGPUMapMode.h:
  • pal/graphics/WebGPU/WebGPUShaderStage.h:
  • pal/graphics/WebGPU/WebGPUTextureUsage.h:
Location:
trunk/Source
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286123 r286124  
     12021-11-22  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [WebGPU] Use OptionSet where it makes sense to
     4        https://bugs.webkit.org/show_bug.cgi?id=233434
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        The fact that the IDL has a bunch of hardcoded const variables doesn't mean we have to.
     9
     10        No new tests because there is no behavior change.
     11
     12        * Modules/WebGPU/GPUBufferUsage.h:
     13        (WebCore::convertBufferUsageFlagsToBacking):
     14        * Modules/WebGPU/GPUColorWrite.h:
     15        (WebCore::convertColorWriteFlagsToBacking):
     16        * Modules/WebGPU/GPUMapMode.h:
     17        (WebCore::convertMapModeFlagsToBacking):
     18        * Modules/WebGPU/GPUShaderStage.h:
     19        (WebCore::convertShaderStageFlagsToBacking):
     20        * Modules/WebGPU/GPUTextureUsage.h:
     21        (WebCore::convertTextureUsageFlagsToBacking):
     22
    1232021-11-22  Myles C. Maxfield  <mmaxfield@apple.com>
    224
  • trunk/Source/WebCore/Modules/WebGPU/GPUBufferUsage.h

    r285429 r286124  
    5151inline PAL::WebGPU::BufferUsageFlags convertBufferUsageFlagsToBacking(GPUBufferUsageFlags bufferUsageFlags)
    5252{
    53     PAL::WebGPU::BufferUsageFlags result = 0;
     53    PAL::WebGPU::BufferUsageFlags result;
    5454    if (bufferUsageFlags & GPUBufferUsage::MAP_READ)
    55         result |= PAL::WebGPU::BufferUsage::MAP_READ;
     55        result.add(PAL::WebGPU::BufferUsage::MapRead);
    5656    if (bufferUsageFlags & GPUBufferUsage::MAP_WRITE)
    57         result |= PAL::WebGPU::BufferUsage::MAP_WRITE;
     57        result.add(PAL::WebGPU::BufferUsage::MapWrite);
    5858    if (bufferUsageFlags & GPUBufferUsage::COPY_SRC)
    59         result |= PAL::WebGPU::BufferUsage::COPY_SRC;
     59        result.add(PAL::WebGPU::BufferUsage::CopySource);
    6060    if (bufferUsageFlags & GPUBufferUsage::COPY_DST)
    61         result |= PAL::WebGPU::BufferUsage::COPY_DST;
     61        result.add(PAL::WebGPU::BufferUsage::CopyDestination);
    6262    if (bufferUsageFlags & GPUBufferUsage::INDEX)
    63         result |= PAL::WebGPU::BufferUsage::INDEX;
     63        result.add(PAL::WebGPU::BufferUsage::Index);
    6464    if (bufferUsageFlags & GPUBufferUsage::VERTEX)
    65         result |= PAL::WebGPU::BufferUsage::VERTEX;
     65        result.add(PAL::WebGPU::BufferUsage::Vertex);
    6666    if (bufferUsageFlags & GPUBufferUsage::UNIFORM)
    67         result |= PAL::WebGPU::BufferUsage::UNIFORM;
     67        result.add(PAL::WebGPU::BufferUsage::Uniform);
    6868    if (bufferUsageFlags & GPUBufferUsage::STORAGE)
    69         result |= PAL::WebGPU::BufferUsage::STORAGE;
     69        result.add(PAL::WebGPU::BufferUsage::Storage);
    7070    if (bufferUsageFlags & GPUBufferUsage::INDIRECT)
    71         result |= PAL::WebGPU::BufferUsage::INDIRECT;
     71        result.add(PAL::WebGPU::BufferUsage::Indirect);
    7272    if (bufferUsageFlags & GPUBufferUsage::QUERY_RESOLVE)
    73         result |= PAL::WebGPU::BufferUsage::QUERY_RESOLVE;
     73        result.add(PAL::WebGPU::BufferUsage::QueryResolve);
    7474    return result;
    7575}
  • trunk/Source/WebCore/Modules/WebGPU/GPUColorWrite.h

    r285654 r286124  
    4646inline PAL::WebGPU::ColorWriteFlags convertColorWriteFlagsToBacking(GPUColorWriteFlags colorWriteFlags)
    4747{
    48     PAL::WebGPU::ColorWriteFlags result = 0;
     48    PAL::WebGPU::ColorWriteFlags result;
    4949    if (colorWriteFlags & GPUColorWrite::RED)
    50         result |= PAL::WebGPU::ColorWrite::RED;
     50        result.add(PAL::WebGPU::ColorWrite::Red);
    5151    if (colorWriteFlags & GPUColorWrite::GREEN)
    52         result |= PAL::WebGPU::ColorWrite::GREEN;
     52        result.add(PAL::WebGPU::ColorWrite::Green);
    5353    if (colorWriteFlags & GPUColorWrite::BLUE)
    54         result |= PAL::WebGPU::ColorWrite::BLUE;
     54        result.add(PAL::WebGPU::ColorWrite::Blue);
    5555    if (colorWriteFlags & GPUColorWrite::ALPHA)
    56         result |= PAL::WebGPU::ColorWrite::ALPHA;
     56        result.add(PAL::WebGPU::ColorWrite::Alpha);
    5757    return result;
    5858}
  • trunk/Source/WebCore/Modules/WebGPU/GPUMapMode.h

    r285429 r286124  
    4343inline PAL::WebGPU::MapModeFlags convertMapModeFlagsToBacking(GPUMapModeFlags mapModeFlags)
    4444{
    45     PAL::WebGPU::MapModeFlags result = 0;
     45    PAL::WebGPU::MapModeFlags result;
    4646    if (mapModeFlags & GPUMapMode::READ)
    47         result |= PAL::WebGPU::MapMode::READ;
     47        result.add(PAL::WebGPU::MapMode::Read);
    4848    if (mapModeFlags & GPUMapMode::WRITE)
    49         result |= PAL::WebGPU::MapMode::WRITE;
     49        result.add(PAL::WebGPU::MapMode::Write);
    5050    return result;
    5151}
  • trunk/Source/WebCore/Modules/WebGPU/GPUShaderStage.h

    r285429 r286124  
    4343inline PAL::WebGPU::ShaderStageFlags convertShaderStageFlagsToBacking(GPUShaderStageFlags shaderStageFlags)
    4444{
    45     PAL::WebGPU::ShaderStageFlags result = 0;
     45    PAL::WebGPU::ShaderStageFlags result;
    4646    if (shaderStageFlags & GPUShaderStage::VERTEX)
    47         result |= PAL::WebGPU::ShaderStage::VERTEX;
     47        result.add(PAL::WebGPU::ShaderStage::Vertex);
    4848    if (shaderStageFlags & GPUShaderStage::FRAGMENT)
    49         result |= PAL::WebGPU::ShaderStage::FRAGMENT;
     49        result.add(PAL::WebGPU::ShaderStage::Fragment);
    5050    if (shaderStageFlags & GPUShaderStage::COMPUTE)
    51         result |= PAL::WebGPU::ShaderStage::COMPUTE;
     51        result.add(PAL::WebGPU::ShaderStage::Compute);
    5252    return result;
    5353}
  • trunk/Source/WebCore/Modules/WebGPU/GPUTextureUsage.h

    r285429 r286124  
    4545inline PAL::WebGPU::TextureUsageFlags convertTextureUsageFlagsToBacking(GPUTextureUsageFlags textureUsageFlags)
    4646{
    47     PAL::WebGPU::TextureUsageFlags result = 0;
     47    PAL::WebGPU::TextureUsageFlags result;
    4848    if (textureUsageFlags & GPUTextureUsage::COPY_SRC)
    49         result |= PAL::WebGPU::TextureUsage::COPY_SRC;
     49        result.add(PAL::WebGPU::TextureUsage::CopySource);
    5050    if (textureUsageFlags & GPUTextureUsage::COPY_DST)
    51         result |= PAL::WebGPU::TextureUsage::COPY_DST;
     51        result.add(PAL::WebGPU::TextureUsage::CopyDestination);
    5252    if (textureUsageFlags & GPUTextureUsage::TEXTURE_BINDING)
    53         result |= PAL::WebGPU::TextureUsage::TEXTURE_BINDING;
     53        result.add(PAL::WebGPU::TextureUsage::TextureBinding);
    5454    if (textureUsageFlags & GPUTextureUsage::STORAGE_BINDING)
    55         result |= PAL::WebGPU::TextureUsage::STORAGE_BINDING;
     55        result.add(PAL::WebGPU::TextureUsage::StorageBinding);
    5656    if (textureUsageFlags & GPUTextureUsage::RENDER_ATTACHMENT)
    57         result |= PAL::WebGPU::TextureUsage::RENDER_ATTACHMENT;
     57        result.add(PAL::WebGPU::TextureUsage::RenderAttachment);
    5858    return result;
    5959}
  • trunk/Source/WebCore/PAL/ChangeLog

    r286077 r286124  
     12021-11-22  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [WebGPU] Use OptionSet where it makes sense to
     4        https://bugs.webkit.org/show_bug.cgi?id=233434
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * pal/graphics/WebGPU/Impl/WebGPUConvertToBackingContext.cpp:
     9        (PAL::WebGPU::ConvertToBackingContext::convertBufferUsageFlagsToBacking):
     10        (PAL::WebGPU::ConvertToBackingContext::convertColorWriteFlagsToBacking):
     11        (PAL::WebGPU::ConvertToBackingContext::convertMapModeFlagsToBacking):
     12        (PAL::WebGPU::ConvertToBackingContext::convertShaderStageFlagsToBacking):
     13        (PAL::WebGPU::ConvertToBackingContext::convertTextureUsageFlagsToBacking):
     14        * pal/graphics/WebGPU/WebGPUBufferUsage.h:
     15        * pal/graphics/WebGPU/WebGPUColorWrite.h:
     16        * pal/graphics/WebGPU/WebGPUMapMode.h:
     17        * pal/graphics/WebGPU/WebGPUShaderStage.h:
     18        * pal/graphics/WebGPU/WebGPUTextureUsage.h:
     19
    1202021-11-19  Myles C. Maxfield  <mmaxfield@apple.com>
    221
  • trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUConvertToBackingContext.cpp

    r285879 r286124  
    690690{
    691691    WGPUBufferUsageFlags result = 0;
    692     if (bufferUsageFlags & BufferUsage::MAP_READ)
     692    if (bufferUsageFlags.contains(BufferUsage::MapRead))
    693693        result |= WGPUBufferUsage_MapRead;
    694     if (bufferUsageFlags & BufferUsage::MAP_WRITE)
     694    if (bufferUsageFlags.contains(BufferUsage::MapWrite))
    695695        result |= WGPUBufferUsage_MapWrite;
    696     if (bufferUsageFlags & BufferUsage::COPY_SRC)
     696    if (bufferUsageFlags.contains(BufferUsage::CopySource))
    697697        result |= WGPUBufferUsage_CopySrc;
    698     if (bufferUsageFlags & BufferUsage::COPY_DST)
     698    if (bufferUsageFlags.contains(BufferUsage::CopyDestination))
    699699        result |= WGPUBufferUsage_CopyDst;
    700     if (bufferUsageFlags & BufferUsage::INDEX)
     700    if (bufferUsageFlags.contains(BufferUsage::Index))
    701701        result |= WGPUBufferUsage_Index;
    702     if (bufferUsageFlags & BufferUsage::VERTEX)
     702    if (bufferUsageFlags.contains(BufferUsage::Vertex))
    703703        result |= WGPUBufferUsage_Vertex;
    704     if (bufferUsageFlags & BufferUsage::UNIFORM)
     704    if (bufferUsageFlags.contains(BufferUsage::Uniform))
    705705        result |= WGPUBufferUsage_Uniform;
    706     if (bufferUsageFlags & BufferUsage::STORAGE)
     706    if (bufferUsageFlags.contains(BufferUsage::Storage))
    707707        result |= WGPUBufferUsage_Storage;
    708     if (bufferUsageFlags & BufferUsage::INDIRECT)
     708    if (bufferUsageFlags.contains(BufferUsage::Indirect))
    709709        result |= WGPUBufferUsage_Indirect;
    710     if (bufferUsageFlags & BufferUsage::QUERY_RESOLVE)
     710    if (bufferUsageFlags.contains(BufferUsage::QueryResolve))
    711711        result |= WGPUBufferUsage_QueryResolve;
    712712    return result;
     
    716716{
    717717    WGPUColorWriteMaskFlags result = 0;
    718     if (colorWriteFlags & ColorWrite::RED)
     718    if (colorWriteFlags.contains(ColorWrite::Red))
    719719        result |= WGPUColorWriteMask_Red;
    720     if (colorWriteFlags & ColorWrite::GREEN)
     720    if (colorWriteFlags.contains(ColorWrite::Green))
    721721        result |= WGPUColorWriteMask_Green;
    722     if (colorWriteFlags & ColorWrite::BLUE)
     722    if (colorWriteFlags.contains(ColorWrite::Blue))
    723723        result |= WGPUColorWriteMask_Blue;
    724     if (colorWriteFlags & ColorWrite::ALPHA)
     724    if (colorWriteFlags.contains(ColorWrite::Alpha))
    725725        result |= WGPUColorWriteMask_Alpha;
    726726    return result;
     
    730730{
    731731    WGPUMapModeFlags result = 0;
    732     if (mapModeFlags & MapMode::READ)
     732    if (mapModeFlags.contains(MapMode::Read))
    733733        result |= WGPUMapMode_Read;
    734     if (mapModeFlags & MapMode::WRITE)
     734    if (mapModeFlags.contains(MapMode::Write))
    735735        result |= WGPUMapMode_Write;
    736736    return result;
     
    740740{
    741741    WGPUShaderStageFlags result = 0;
    742     if (shaderStageFlags & ShaderStage::VERTEX)
     742    if (shaderStageFlags.contains(ShaderStage::Vertex))
    743743        result |= WGPUShaderStage_Vertex;
    744     if (shaderStageFlags & ShaderStage::FRAGMENT)
     744    if (shaderStageFlags.contains(ShaderStage::Fragment))
    745745        result |= WGPUShaderStage_Fragment;
    746     if (shaderStageFlags & ShaderStage::COMPUTE)
     746    if (shaderStageFlags.contains(ShaderStage::Compute))
    747747        result |= WGPUShaderStage_Compute;
    748748    return result;
     
    752752{
    753753    WGPUTextureUsageFlags result = 0;
    754     if (textureUsageFlags & TextureUsage::COPY_SRC)
     754    if (textureUsageFlags.contains(TextureUsage::CopySource))
    755755        result |= WGPUTextureUsage_CopySrc;
    756     if (textureUsageFlags & TextureUsage::COPY_DST)
     756    if (textureUsageFlags.contains(TextureUsage::CopyDestination))
    757757        result |= WGPUTextureUsage_CopyDst;
    758     if (textureUsageFlags & TextureUsage::TEXTURE_BINDING)
     758    if (textureUsageFlags.contains(TextureUsage::TextureBinding))
    759759        result |= WGPUTextureUsage_TextureBinding;
    760     if (textureUsageFlags & TextureUsage::STORAGE_BINDING)
     760    if (textureUsageFlags.contains(TextureUsage::StorageBinding))
    761761        result |= WGPUTextureUsage_StorageBinding;
    762     if (textureUsageFlags & TextureUsage::RENDER_ATTACHMENT)
     762    if (textureUsageFlags.contains(TextureUsage::RenderAttachment))
    763763        result |= WGPUTextureUsage_RenderAttachment;
    764764    return result;
  • trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUBufferUsage.h

    r285981 r286124  
    2626#pragma once
    2727
    28 #include "WebGPUIntegralTypes.h"
    2928#include <cstdint>
    30 #include <wtf/RefCounted.h>
     29#include <wtf/EnumTraits.h>
     30#include <wtf/OptionSet.h>
    3131
    3232namespace PAL::WebGPU {
    3333
    34 using BufferUsageFlags = uint32_t;
    35 class BufferUsage : public RefCounted<BufferUsage> {
    36 public:
    37     static constexpr FlagsConstant MAP_READ      = 0x0001;
    38     static constexpr FlagsConstant MAP_WRITE     = 0x0002;
    39     static constexpr FlagsConstant COPY_SRC      = 0x0004;
    40     static constexpr FlagsConstant COPY_DST      = 0x0008;
    41     static constexpr FlagsConstant INDEX         = 0x0010;
    42     static constexpr FlagsConstant VERTEX        = 0x0020;
    43     static constexpr FlagsConstant UNIFORM       = 0x0040;
    44     static constexpr FlagsConstant STORAGE       = 0x0080;
    45     static constexpr FlagsConstant INDIRECT      = 0x0100;
    46     static constexpr FlagsConstant QUERY_RESOLVE = 0x0200;
     34enum class BufferUsage : uint16_t {
     35    MapRead         = 1 << 0,
     36    MapWrite        = 1 << 1,
     37    CopySource      = 1 << 2,
     38    CopyDestination = 1 << 3,
     39    Index           = 1 << 4,
     40    Vertex          = 1 << 5,
     41    Uniform         = 1 << 6,
     42    Storage         = 1 << 7,
     43    Indirect        = 1 << 8,
     44    QueryResolve    = 1 << 9,
     45};
     46using BufferUsageFlags = OptionSet<BufferUsage>;
     47
     48} // namespace PAL::WebGPU
     49
     50namespace WTF {
     51
     52template<> struct EnumTraits<PAL::WebGPU::BufferUsage> {
     53    using values = EnumValues<
     54        PAL::WebGPU::BufferUsage,
     55        PAL::WebGPU::BufferUsage::MapRead,
     56        PAL::WebGPU::BufferUsage::MapWrite,
     57        PAL::WebGPU::BufferUsage::CopySource,
     58        PAL::WebGPU::BufferUsage::CopyDestination,
     59        PAL::WebGPU::BufferUsage::Index,
     60        PAL::WebGPU::BufferUsage::Vertex,
     61        PAL::WebGPU::BufferUsage::Uniform,
     62        PAL::WebGPU::BufferUsage::Storage,
     63        PAL::WebGPU::BufferUsage::Indirect,
     64        PAL::WebGPU::BufferUsage::QueryResolve
     65
     66    >;
    4767};
    4868
    49 } // namespace PAL::WebGPU
     69} // namespace WTF
  • trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUCanvasConfiguration.h

    r285879 r286124  
    3030#include "WebGPUPredefinedColorSpace.h"
    3131#include "WebGPUTextureFormat.h"
     32#include "WebGPUTextureUsage.h"
    3233#include <cstdint>
    3334#include <optional>
     
    3738
    3839class Device;
    39 
    40 using TextureUsageFlags = uint32_t; // FIXME: This doesn't need to be here.
    4140
    4241struct CanvasConfiguration {
  • trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUColorWrite.h

    r285879 r286124  
    3030#include "WebGPUIntegralTypes.h"
    3131#include <cstdint>
    32 #include <wtf/RefCounted.h>
     32#include <wtf/EnumTraits.h>
     33#include <wtf/OptionSet.h>
    3334
    3435namespace PAL::WebGPU {
    3536
    36 using ColorWriteFlags = uint32_t;
    37 class ColorWrite : public RefCounted<ColorWrite> {
    38 public:
    39     static constexpr FlagsConstant RED   = 0x1;
    40     static constexpr FlagsConstant GREEN = 0x2;
    41     static constexpr FlagsConstant BLUE  = 0x4;
    42     static constexpr FlagsConstant ALPHA = 0x8;
    43     static constexpr FlagsConstant ALL   = 0xF;
     37enum class ColorWrite : uint8_t {
     38    Red   = 1 << 0,
     39    Green = 1 << 1,
     40    Blue  = 1 << 2,
     41    Alpha = 1 << 3,
     42    All   = Red | Green | Blue | Alpha,
     43};
     44using ColorWriteFlags = OptionSet<ColorWrite>;
     45
     46} // namespace PAL::WebGPU
     47
     48namespace WTF {
     49
     50template<> struct EnumTraits<PAL::WebGPU::ColorWrite> {
     51    using values = EnumValues<
     52        PAL::WebGPU::ColorWrite,
     53        PAL::WebGPU::ColorWrite::Red,
     54        PAL::WebGPU::ColorWrite::Green,
     55        PAL::WebGPU::ColorWrite::Blue,
     56        PAL::WebGPU::ColorWrite::Alpha
     57    >;
    4458};
    4559
    46 } // namespace PAL::WebGPU
     60} // namespace WTF
  • trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUMapMode.h

    r285981 r286124  
    2828#include "WebGPUIntegralTypes.h"
    2929#include <cstdint>
    30 #include <wtf/RefCounted.h>
     30#include <wtf/EnumTraits.h>
     31#include <wtf/OptionSet.h>
    3132
    3233namespace PAL::WebGPU {
    3334
    34 using MapModeFlags = uint32_t;
    35 class MapMode : public RefCounted<MapMode> {
    36 public:
    37     static constexpr FlagsConstant READ  = 0x0001;
    38     static constexpr FlagsConstant WRITE = 0x0002;
     35enum class MapMode : uint8_t {
     36    Read  = 1 << 0,
     37    Write = 1 << 1,
     38};
     39using MapModeFlags = OptionSet<MapMode>;
     40
     41} // namespace PAL::WebGPU
     42
     43namespace WTF {
     44
     45template<> struct EnumTraits<PAL::WebGPU::MapMode> {
     46    using values = EnumValues<
     47        PAL::WebGPU::MapMode,
     48        PAL::WebGPU::MapMode::Read,
     49        PAL::WebGPU::MapMode::Write
     50    >;
    3951};
    4052
    41 } // namespace PAL::WebGPU
     53} // namespace WTF
     54
  • trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUShaderStage.h

    r285879 r286124  
    2828#include "WebGPUIntegralTypes.h"
    2929#include <cstdint>
    30 #include <wtf/RefCounted.h>
     30#include <wtf/EnumTraits.h>
     31#include <wtf/OptionSet.h>
    3132
    3233namespace PAL::WebGPU {
    3334
    34 using ShaderStageFlags = uint32_t;
    35 class ShaderStage : public RefCounted<ShaderStage> {
    36 public:
    37     static constexpr FlagsConstant VERTEX   = 0x1;
    38     static constexpr FlagsConstant FRAGMENT = 0x2;
    39     static constexpr FlagsConstant COMPUTE  = 0x4;
     35enum class ShaderStage : uint8_t {
     36    Vertex   = 1 << 0,
     37    Fragment = 1 << 1,
     38    Compute  = 1 << 2,
     39};
     40using ShaderStageFlags = OptionSet<ShaderStage>;
     41
     42} // namespace PAL::WebGPU
     43
     44namespace WTF {
     45
     46template<> struct EnumTraits<PAL::WebGPU::ShaderStage> {
     47    using values = EnumValues<
     48        PAL::WebGPU::ShaderStage,
     49        PAL::WebGPU::ShaderStage::Vertex,
     50        PAL::WebGPU::ShaderStage::Fragment,
     51        PAL::WebGPU::ShaderStage::Compute
     52    >;
    4053};
    4154
    42 } // namespace PAL::WebGPU
     55} // namespace WTF
  • trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUTextureUsage.h

    r285879 r286124  
    2828#include "WebGPUIntegralTypes.h"
    2929#include <cstdint>
    30 #include <wtf/RefCounted.h>
     30#include <wtf/EnumTraits.h>
     31#include <wtf/OptionSet.h>
    3132
    3233namespace PAL::WebGPU {
    3334
    34 using TextureUsageFlags = uint32_t;
    35 class TextureUsage : public RefCounted<TextureUsage> {
    36 public:
    37     static constexpr FlagsConstant COPY_SRC          = 0x01;
    38     static constexpr FlagsConstant COPY_DST          = 0x02;
    39     static constexpr FlagsConstant TEXTURE_BINDING   = 0x04;
    40     static constexpr FlagsConstant STORAGE_BINDING   = 0x08;
    41     static constexpr FlagsConstant RENDER_ATTACHMENT = 0x10;
     35enum class TextureUsage : uint8_t {
     36    CopySource       = 1 << 0,
     37    CopyDestination  = 1 << 1,
     38    TextureBinding   = 1 << 2,
     39    StorageBinding   = 1 << 3,
     40    RenderAttachment = 1 << 4,
     41};
     42using TextureUsageFlags = OptionSet<TextureUsage>;
     43
     44} // namespace PAL::WebGPU
     45
     46namespace WTF {
     47
     48template<> struct EnumTraits<PAL::WebGPU::TextureUsage> {
     49    using values = EnumValues<
     50        PAL::WebGPU::TextureUsage,
     51        PAL::WebGPU::TextureUsage::CopySource,
     52        PAL::WebGPU::TextureUsage::CopyDestination,
     53        PAL::WebGPU::TextureUsage::TextureBinding,
     54        PAL::WebGPU::TextureUsage::StorageBinding,
     55        PAL::WebGPU::TextureUsage::RenderAttachment
     56    >;
    4257};
    4358
    44 } // namespace PAL::WebGPU
     59} // namespace WTF
     60
  • trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.cpp

    r286087 r286124  
    6060        auto mappedRange = strongThis->m_backing->getMappedRange(offset, size);
    6161        strongThis->m_mappedRange = mappedRange;
    62         if (mapModeFlags & PAL::WebGPU::MapMode::READ)
     62        if (mapModeFlags.contains(PAL::WebGPU::MapMode::Read))
    6363            callback(Vector<uint8_t>(static_cast<const uint8_t*>(mappedRange.source), mappedRange.byteLength));
    6464        else
     
    7373    ASSERT(m_isMapped);
    7474
    75     if (m_mapModeFlags & PAL::WebGPU::MapMode::WRITE)
     75    if (m_mapModeFlags.contains(PAL::WebGPU::MapMode::Write))
    7676        memcpy(m_mappedRange->source, data.data(), data.size());
    7777
    7878    m_isMapped = false;
    7979    m_mappedRange = std::nullopt;
    80     m_mapModeFlags = 0;
     80    m_mapModeFlags = { };
    8181}
    8282
  • trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.h

    r286087 r286124  
    8383    bool m_isMapped { false };
    8484    std::optional<PAL::WebGPU::Buffer::MappedRange> m_mappedRange;
    85     PAL::WebGPU::MapModeFlags m_mapModeFlags { 0 };
     85    PAL::WebGPU::MapModeFlags m_mapModeFlags;
    8686};
    8787
  • trunk/Source/WebKit/Shared/WebGPU/WebGPUCanvasConfiguration.h

    r286077 r286124  
    3535#include <pal/graphics/WebGPU/WebGPUPredefinedColorSpace.h>
    3636#include <pal/graphics/WebGPU/WebGPUTextureFormat.h>
     37#include <pal/graphics/WebGPU/WebGPUTextureUsage.h>
    3738#include <wtf/Ref.h>
    3839
     
    4142class Device;
    4243
    43 using TextureUsageFlags = uint32_t; // FIXME: This doesn't need to be here.
    44 
    4544struct CanvasConfiguration {
    4645    WebGPUIdentifier device;
    4746    PAL::WebGPU::TextureFormat format;
    48     TextureUsageFlags usage; // TextureUsage.RENDER_ATTACHMENT
     47    PAL::WebGPU::TextureUsageFlags usage; // TextureUsage.RENDER_ATTACHMENT
    4948    PAL::WebGPU::PredefinedColorSpace colorSpace;
    5049    PAL::WebGPU::CanvasCompositingAlphaMode compositingAlphaMode;
     
    7372            return std::nullopt;
    7473
    75         std::optional<TextureUsageFlags> usage;
     74        std::optional<PAL::WebGPU::TextureUsageFlags> usage;
    7675        decoder >> usage;
    7776        if (!usage)
  • trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp

    r286098 r286124  
    7777
    7878    Vector<uint8_t> data;
    79     if (m_mapModeFlags & PAL::WebGPU::MapMode::WRITE)
     79    if (m_mapModeFlags.contains(PAL::WebGPU::MapMode::Write))
    8080        data = WTFMove(*m_data);
    8181    auto sendResult = send(Messages::RemoteBuffer::Unmap(WTFMove(data)));
     
    8383
    8484    m_data = std::nullopt;
    85     m_mapModeFlags = 0;
     85    m_mapModeFlags = { };
    8686}
    8787
  • trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h

    r286098 r286124  
    8787    Ref<RemoteDeviceProxy> m_parent;
    8888    std::optional<Vector<uint8_t>> m_data;
    89     PAL::WebGPU::MapModeFlags m_mapModeFlags { 0 };
     89    PAL::WebGPU::MapModeFlags m_mapModeFlags;
    9090};
    9191
Note: See TracChangeset for help on using the changeset viewer.