Diff
Modified: trunk/Source/WebCore/ChangeLog (286123 => 286124)
--- trunk/Source/WebCore/ChangeLog 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/ChangeLog 2021-11-23 01:46:52 UTC (rev 286124)
@@ -1,5 +1,27 @@
2021-11-22 Myles C. Maxfield <[email protected]>
+ [WebGPU] Use OptionSet where it makes sense to
+ https://bugs.webkit.org/show_bug.cgi?id=233434
+
+ Reviewed by Wenson Hsieh.
+
+ 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):
+
+2021-11-22 Myles C. Maxfield <[email protected]>
+
rem in media queries should be calculated using font-size:initial, not root element font-size
https://bugs.webkit.org/show_bug.cgi?id=156684
<rdar://problem/25778616>
Modified: trunk/Source/WebCore/Modules/WebGPU/GPUBufferUsage.h (286123 => 286124)
--- trunk/Source/WebCore/Modules/WebGPU/GPUBufferUsage.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/Modules/WebGPU/GPUBufferUsage.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -50,27 +50,27 @@
inline PAL::WebGPU::BufferUsageFlags convertBufferUsageFlagsToBacking(GPUBufferUsageFlags bufferUsageFlags)
{
- PAL::WebGPU::BufferUsageFlags result = 0;
+ PAL::WebGPU::BufferUsageFlags result;
if (bufferUsageFlags & GPUBufferUsage::MAP_READ)
- result |= PAL::WebGPU::BufferUsage::MAP_READ;
+ result.add(PAL::WebGPU::BufferUsage::MapRead);
if (bufferUsageFlags & GPUBufferUsage::MAP_WRITE)
- result |= PAL::WebGPU::BufferUsage::MAP_WRITE;
+ result.add(PAL::WebGPU::BufferUsage::MapWrite);
if (bufferUsageFlags & GPUBufferUsage::COPY_SRC)
- result |= PAL::WebGPU::BufferUsage::COPY_SRC;
+ result.add(PAL::WebGPU::BufferUsage::CopySource);
if (bufferUsageFlags & GPUBufferUsage::COPY_DST)
- result |= PAL::WebGPU::BufferUsage::COPY_DST;
+ result.add(PAL::WebGPU::BufferUsage::CopyDestination);
if (bufferUsageFlags & GPUBufferUsage::INDEX)
- result |= PAL::WebGPU::BufferUsage::INDEX;
+ result.add(PAL::WebGPU::BufferUsage::Index);
if (bufferUsageFlags & GPUBufferUsage::VERTEX)
- result |= PAL::WebGPU::BufferUsage::VERTEX;
+ result.add(PAL::WebGPU::BufferUsage::Vertex);
if (bufferUsageFlags & GPUBufferUsage::UNIFORM)
- result |= PAL::WebGPU::BufferUsage::UNIFORM;
+ result.add(PAL::WebGPU::BufferUsage::Uniform);
if (bufferUsageFlags & GPUBufferUsage::STORAGE)
- result |= PAL::WebGPU::BufferUsage::STORAGE;
+ result.add(PAL::WebGPU::BufferUsage::Storage);
if (bufferUsageFlags & GPUBufferUsage::INDIRECT)
- result |= PAL::WebGPU::BufferUsage::INDIRECT;
+ result.add(PAL::WebGPU::BufferUsage::Indirect);
if (bufferUsageFlags & GPUBufferUsage::QUERY_RESOLVE)
- result |= PAL::WebGPU::BufferUsage::QUERY_RESOLVE;
+ result.add(PAL::WebGPU::BufferUsage::QueryResolve);
return result;
}
Modified: trunk/Source/WebCore/Modules/WebGPU/GPUColorWrite.h (286123 => 286124)
--- trunk/Source/WebCore/Modules/WebGPU/GPUColorWrite.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/Modules/WebGPU/GPUColorWrite.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -45,15 +45,15 @@
inline PAL::WebGPU::ColorWriteFlags convertColorWriteFlagsToBacking(GPUColorWriteFlags colorWriteFlags)
{
- PAL::WebGPU::ColorWriteFlags result = 0;
+ PAL::WebGPU::ColorWriteFlags result;
if (colorWriteFlags & GPUColorWrite::RED)
- result |= PAL::WebGPU::ColorWrite::RED;
+ result.add(PAL::WebGPU::ColorWrite::Red);
if (colorWriteFlags & GPUColorWrite::GREEN)
- result |= PAL::WebGPU::ColorWrite::GREEN;
+ result.add(PAL::WebGPU::ColorWrite::Green);
if (colorWriteFlags & GPUColorWrite::BLUE)
- result |= PAL::WebGPU::ColorWrite::BLUE;
+ result.add(PAL::WebGPU::ColorWrite::Blue);
if (colorWriteFlags & GPUColorWrite::ALPHA)
- result |= PAL::WebGPU::ColorWrite::ALPHA;
+ result.add(PAL::WebGPU::ColorWrite::Alpha);
return result;
}
Modified: trunk/Source/WebCore/Modules/WebGPU/GPUMapMode.h (286123 => 286124)
--- trunk/Source/WebCore/Modules/WebGPU/GPUMapMode.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/Modules/WebGPU/GPUMapMode.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -42,11 +42,11 @@
inline PAL::WebGPU::MapModeFlags convertMapModeFlagsToBacking(GPUMapModeFlags mapModeFlags)
{
- PAL::WebGPU::MapModeFlags result = 0;
+ PAL::WebGPU::MapModeFlags result;
if (mapModeFlags & GPUMapMode::READ)
- result |= PAL::WebGPU::MapMode::READ;
+ result.add(PAL::WebGPU::MapMode::Read);
if (mapModeFlags & GPUMapMode::WRITE)
- result |= PAL::WebGPU::MapMode::WRITE;
+ result.add(PAL::WebGPU::MapMode::Write);
return result;
}
Modified: trunk/Source/WebCore/Modules/WebGPU/GPUShaderStage.h (286123 => 286124)
--- trunk/Source/WebCore/Modules/WebGPU/GPUShaderStage.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/Modules/WebGPU/GPUShaderStage.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -42,13 +42,13 @@
inline PAL::WebGPU::ShaderStageFlags convertShaderStageFlagsToBacking(GPUShaderStageFlags shaderStageFlags)
{
- PAL::WebGPU::ShaderStageFlags result = 0;
+ PAL::WebGPU::ShaderStageFlags result;
if (shaderStageFlags & GPUShaderStage::VERTEX)
- result |= PAL::WebGPU::ShaderStage::VERTEX;
+ result.add(PAL::WebGPU::ShaderStage::Vertex);
if (shaderStageFlags & GPUShaderStage::FRAGMENT)
- result |= PAL::WebGPU::ShaderStage::FRAGMENT;
+ result.add(PAL::WebGPU::ShaderStage::Fragment);
if (shaderStageFlags & GPUShaderStage::COMPUTE)
- result |= PAL::WebGPU::ShaderStage::COMPUTE;
+ result.add(PAL::WebGPU::ShaderStage::Compute);
return result;
}
Modified: trunk/Source/WebCore/Modules/WebGPU/GPUTextureUsage.h (286123 => 286124)
--- trunk/Source/WebCore/Modules/WebGPU/GPUTextureUsage.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/Modules/WebGPU/GPUTextureUsage.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -44,17 +44,17 @@
inline PAL::WebGPU::TextureUsageFlags convertTextureUsageFlagsToBacking(GPUTextureUsageFlags textureUsageFlags)
{
- PAL::WebGPU::TextureUsageFlags result = 0;
+ PAL::WebGPU::TextureUsageFlags result;
if (textureUsageFlags & GPUTextureUsage::COPY_SRC)
- result |= PAL::WebGPU::TextureUsage::COPY_SRC;
+ result.add(PAL::WebGPU::TextureUsage::CopySource);
if (textureUsageFlags & GPUTextureUsage::COPY_DST)
- result |= PAL::WebGPU::TextureUsage::COPY_DST;
+ result.add(PAL::WebGPU::TextureUsage::CopyDestination);
if (textureUsageFlags & GPUTextureUsage::TEXTURE_BINDING)
- result |= PAL::WebGPU::TextureUsage::TEXTURE_BINDING;
+ result.add(PAL::WebGPU::TextureUsage::TextureBinding);
if (textureUsageFlags & GPUTextureUsage::STORAGE_BINDING)
- result |= PAL::WebGPU::TextureUsage::STORAGE_BINDING;
+ result.add(PAL::WebGPU::TextureUsage::StorageBinding);
if (textureUsageFlags & GPUTextureUsage::RENDER_ATTACHMENT)
- result |= PAL::WebGPU::TextureUsage::RENDER_ATTACHMENT;
+ result.add(PAL::WebGPU::TextureUsage::RenderAttachment);
return result;
}
Modified: trunk/Source/WebCore/PAL/ChangeLog (286123 => 286124)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-11-23 01:46:52 UTC (rev 286124)
@@ -1,3 +1,22 @@
+2021-11-22 Myles C. Maxfield <[email protected]>
+
+ [WebGPU] Use OptionSet where it makes sense to
+ https://bugs.webkit.org/show_bug.cgi?id=233434
+
+ Reviewed by Wenson Hsieh.
+
+ * 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:
+
2021-11-19 Myles C. Maxfield <[email protected]>
[WebGPU] Add converters from serializable descriptors to interface descriptors
Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUConvertToBackingContext.cpp (286123 => 286124)
--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUConvertToBackingContext.cpp 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUConvertToBackingContext.cpp 2021-11-23 01:46:52 UTC (rev 286124)
@@ -689,25 +689,25 @@
WGPUBufferUsageFlags ConvertToBackingContext::convertBufferUsageFlagsToBacking(BufferUsageFlags bufferUsageFlags)
{
WGPUBufferUsageFlags result = 0;
- if (bufferUsageFlags & BufferUsage::MAP_READ)
+ if (bufferUsageFlags.contains(BufferUsage::MapRead))
result |= WGPUBufferUsage_MapRead;
- if (bufferUsageFlags & BufferUsage::MAP_WRITE)
+ if (bufferUsageFlags.contains(BufferUsage::MapWrite))
result |= WGPUBufferUsage_MapWrite;
- if (bufferUsageFlags & BufferUsage::COPY_SRC)
+ if (bufferUsageFlags.contains(BufferUsage::CopySource))
result |= WGPUBufferUsage_CopySrc;
- if (bufferUsageFlags & BufferUsage::COPY_DST)
+ if (bufferUsageFlags.contains(BufferUsage::CopyDestination))
result |= WGPUBufferUsage_CopyDst;
- if (bufferUsageFlags & BufferUsage::INDEX)
+ if (bufferUsageFlags.contains(BufferUsage::Index))
result |= WGPUBufferUsage_Index;
- if (bufferUsageFlags & BufferUsage::VERTEX)
+ if (bufferUsageFlags.contains(BufferUsage::Vertex))
result |= WGPUBufferUsage_Vertex;
- if (bufferUsageFlags & BufferUsage::UNIFORM)
+ if (bufferUsageFlags.contains(BufferUsage::Uniform))
result |= WGPUBufferUsage_Uniform;
- if (bufferUsageFlags & BufferUsage::STORAGE)
+ if (bufferUsageFlags.contains(BufferUsage::Storage))
result |= WGPUBufferUsage_Storage;
- if (bufferUsageFlags & BufferUsage::INDIRECT)
+ if (bufferUsageFlags.contains(BufferUsage::Indirect))
result |= WGPUBufferUsage_Indirect;
- if (bufferUsageFlags & BufferUsage::QUERY_RESOLVE)
+ if (bufferUsageFlags.contains(BufferUsage::QueryResolve))
result |= WGPUBufferUsage_QueryResolve;
return result;
}
@@ -715,13 +715,13 @@
WGPUColorWriteMaskFlags ConvertToBackingContext::convertColorWriteFlagsToBacking(ColorWriteFlags colorWriteFlags)
{
WGPUColorWriteMaskFlags result = 0;
- if (colorWriteFlags & ColorWrite::RED)
+ if (colorWriteFlags.contains(ColorWrite::Red))
result |= WGPUColorWriteMask_Red;
- if (colorWriteFlags & ColorWrite::GREEN)
+ if (colorWriteFlags.contains(ColorWrite::Green))
result |= WGPUColorWriteMask_Green;
- if (colorWriteFlags & ColorWrite::BLUE)
+ if (colorWriteFlags.contains(ColorWrite::Blue))
result |= WGPUColorWriteMask_Blue;
- if (colorWriteFlags & ColorWrite::ALPHA)
+ if (colorWriteFlags.contains(ColorWrite::Alpha))
result |= WGPUColorWriteMask_Alpha;
return result;
}
@@ -729,9 +729,9 @@
WGPUMapModeFlags ConvertToBackingContext::convertMapModeFlagsToBacking(MapModeFlags mapModeFlags)
{
WGPUMapModeFlags result = 0;
- if (mapModeFlags & MapMode::READ)
+ if (mapModeFlags.contains(MapMode::Read))
result |= WGPUMapMode_Read;
- if (mapModeFlags & MapMode::WRITE)
+ if (mapModeFlags.contains(MapMode::Write))
result |= WGPUMapMode_Write;
return result;
}
@@ -739,11 +739,11 @@
WGPUShaderStageFlags ConvertToBackingContext::convertShaderStageFlagsToBacking(ShaderStageFlags shaderStageFlags)
{
WGPUShaderStageFlags result = 0;
- if (shaderStageFlags & ShaderStage::VERTEX)
+ if (shaderStageFlags.contains(ShaderStage::Vertex))
result |= WGPUShaderStage_Vertex;
- if (shaderStageFlags & ShaderStage::FRAGMENT)
+ if (shaderStageFlags.contains(ShaderStage::Fragment))
result |= WGPUShaderStage_Fragment;
- if (shaderStageFlags & ShaderStage::COMPUTE)
+ if (shaderStageFlags.contains(ShaderStage::Compute))
result |= WGPUShaderStage_Compute;
return result;
}
@@ -751,15 +751,15 @@
WGPUTextureUsageFlags ConvertToBackingContext::convertTextureUsageFlagsToBacking(TextureUsageFlags textureUsageFlags)
{
WGPUTextureUsageFlags result = 0;
- if (textureUsageFlags & TextureUsage::COPY_SRC)
+ if (textureUsageFlags.contains(TextureUsage::CopySource))
result |= WGPUTextureUsage_CopySrc;
- if (textureUsageFlags & TextureUsage::COPY_DST)
+ if (textureUsageFlags.contains(TextureUsage::CopyDestination))
result |= WGPUTextureUsage_CopyDst;
- if (textureUsageFlags & TextureUsage::TEXTURE_BINDING)
+ if (textureUsageFlags.contains(TextureUsage::TextureBinding))
result |= WGPUTextureUsage_TextureBinding;
- if (textureUsageFlags & TextureUsage::STORAGE_BINDING)
+ if (textureUsageFlags.contains(TextureUsage::StorageBinding))
result |= WGPUTextureUsage_StorageBinding;
- if (textureUsageFlags & TextureUsage::RENDER_ATTACHMENT)
+ if (textureUsageFlags.contains(TextureUsage::RenderAttachment))
result |= WGPUTextureUsage_RenderAttachment;
return result;
}
Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUBufferUsage.h (286123 => 286124)
--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUBufferUsage.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUBufferUsage.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -25,25 +25,45 @@
#pragma once
-#include "WebGPUIntegralTypes.h"
#include <cstdint>
-#include <wtf/RefCounted.h>
+#include <wtf/EnumTraits.h>
+#include <wtf/OptionSet.h>
namespace PAL::WebGPU {
-using BufferUsageFlags = uint32_t;
-class BufferUsage : public RefCounted<BufferUsage> {
-public:
- static constexpr FlagsConstant MAP_READ = 0x0001;
- static constexpr FlagsConstant MAP_WRITE = 0x0002;
- static constexpr FlagsConstant COPY_SRC = 0x0004;
- static constexpr FlagsConstant COPY_DST = 0x0008;
- static constexpr FlagsConstant INDEX = 0x0010;
- static constexpr FlagsConstant VERTEX = 0x0020;
- static constexpr FlagsConstant UNIFORM = 0x0040;
- static constexpr FlagsConstant STORAGE = 0x0080;
- static constexpr FlagsConstant INDIRECT = 0x0100;
- static constexpr FlagsConstant QUERY_RESOLVE = 0x0200;
+enum class BufferUsage : uint16_t {
+ MapRead = 1 << 0,
+ MapWrite = 1 << 1,
+ CopySource = 1 << 2,
+ CopyDestination = 1 << 3,
+ Index = 1 << 4,
+ Vertex = 1 << 5,
+ Uniform = 1 << 6,
+ Storage = 1 << 7,
+ Indirect = 1 << 8,
+ QueryResolve = 1 << 9,
};
+using BufferUsageFlags = OptionSet<BufferUsage>;
} // namespace PAL::WebGPU
+
+namespace WTF {
+
+template<> struct EnumTraits<PAL::WebGPU::BufferUsage> {
+ using values = EnumValues<
+ PAL::WebGPU::BufferUsage,
+ PAL::WebGPU::BufferUsage::MapRead,
+ PAL::WebGPU::BufferUsage::MapWrite,
+ PAL::WebGPU::BufferUsage::CopySource,
+ PAL::WebGPU::BufferUsage::CopyDestination,
+ PAL::WebGPU::BufferUsage::Index,
+ PAL::WebGPU::BufferUsage::Vertex,
+ PAL::WebGPU::BufferUsage::Uniform,
+ PAL::WebGPU::BufferUsage::Storage,
+ PAL::WebGPU::BufferUsage::Indirect,
+ PAL::WebGPU::BufferUsage::QueryResolve
+
+ >;
+};
+
+} // namespace WTF
Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUCanvasConfiguration.h (286123 => 286124)
--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUCanvasConfiguration.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUCanvasConfiguration.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -29,6 +29,7 @@
#include "WebGPUExtent3D.h"
#include "WebGPUPredefinedColorSpace.h"
#include "WebGPUTextureFormat.h"
+#include "WebGPUTextureUsage.h"
#include <cstdint>
#include <optional>
#include <wtf/Ref.h>
@@ -37,8 +38,6 @@
class Device;
-using TextureUsageFlags = uint32_t; // FIXME: This doesn't need to be here.
-
struct CanvasConfiguration {
Device& device;
TextureFormat format;
Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUColorWrite.h (286123 => 286124)
--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUColorWrite.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUColorWrite.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -29,18 +29,32 @@
#include "WebGPUBlendOperation.h"
#include "WebGPUIntegralTypes.h"
#include <cstdint>
-#include <wtf/RefCounted.h>
+#include <wtf/EnumTraits.h>
+#include <wtf/OptionSet.h>
namespace PAL::WebGPU {
-using ColorWriteFlags = uint32_t;
-class ColorWrite : public RefCounted<ColorWrite> {
-public:
- static constexpr FlagsConstant RED = 0x1;
- static constexpr FlagsConstant GREEN = 0x2;
- static constexpr FlagsConstant BLUE = 0x4;
- static constexpr FlagsConstant ALPHA = 0x8;
- static constexpr FlagsConstant ALL = 0xF;
+enum class ColorWrite : uint8_t {
+ Red = 1 << 0,
+ Green = 1 << 1,
+ Blue = 1 << 2,
+ Alpha = 1 << 3,
+ All = Red | Green | Blue | Alpha,
};
+using ColorWriteFlags = OptionSet<ColorWrite>;
} // namespace PAL::WebGPU
+
+namespace WTF {
+
+template<> struct EnumTraits<PAL::WebGPU::ColorWrite> {
+ using values = EnumValues<
+ PAL::WebGPU::ColorWrite,
+ PAL::WebGPU::ColorWrite::Red,
+ PAL::WebGPU::ColorWrite::Green,
+ PAL::WebGPU::ColorWrite::Blue,
+ PAL::WebGPU::ColorWrite::Alpha
+ >;
+};
+
+} // namespace WTF
Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUMapMode.h (286123 => 286124)
--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUMapMode.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUMapMode.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -27,15 +27,28 @@
#include "WebGPUIntegralTypes.h"
#include <cstdint>
-#include <wtf/RefCounted.h>
+#include <wtf/EnumTraits.h>
+#include <wtf/OptionSet.h>
namespace PAL::WebGPU {
-using MapModeFlags = uint32_t;
-class MapMode : public RefCounted<MapMode> {
-public:
- static constexpr FlagsConstant READ = 0x0001;
- static constexpr FlagsConstant WRITE = 0x0002;
+enum class MapMode : uint8_t {
+ Read = 1 << 0,
+ Write = 1 << 1,
};
+using MapModeFlags = OptionSet<MapMode>;
} // namespace PAL::WebGPU
+
+namespace WTF {
+
+template<> struct EnumTraits<PAL::WebGPU::MapMode> {
+ using values = EnumValues<
+ PAL::WebGPU::MapMode,
+ PAL::WebGPU::MapMode::Read,
+ PAL::WebGPU::MapMode::Write
+ >;
+};
+
+} // namespace WTF
+
Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUShaderStage.h (286123 => 286124)
--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUShaderStage.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUShaderStage.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -27,16 +27,29 @@
#include "WebGPUIntegralTypes.h"
#include <cstdint>
-#include <wtf/RefCounted.h>
+#include <wtf/EnumTraits.h>
+#include <wtf/OptionSet.h>
namespace PAL::WebGPU {
-using ShaderStageFlags = uint32_t;
-class ShaderStage : public RefCounted<ShaderStage> {
-public:
- static constexpr FlagsConstant VERTEX = 0x1;
- static constexpr FlagsConstant FRAGMENT = 0x2;
- static constexpr FlagsConstant COMPUTE = 0x4;
+enum class ShaderStage : uint8_t {
+ Vertex = 1 << 0,
+ Fragment = 1 << 1,
+ Compute = 1 << 2,
};
+using ShaderStageFlags = OptionSet<ShaderStage>;
} // namespace PAL::WebGPU
+
+namespace WTF {
+
+template<> struct EnumTraits<PAL::WebGPU::ShaderStage> {
+ using values = EnumValues<
+ PAL::WebGPU::ShaderStage,
+ PAL::WebGPU::ShaderStage::Vertex,
+ PAL::WebGPU::ShaderStage::Fragment,
+ PAL::WebGPU::ShaderStage::Compute
+ >;
+};
+
+} // namespace WTF
Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUTextureUsage.h (286123 => 286124)
--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUTextureUsage.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUTextureUsage.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -27,18 +27,34 @@
#include "WebGPUIntegralTypes.h"
#include <cstdint>
-#include <wtf/RefCounted.h>
+#include <wtf/EnumTraits.h>
+#include <wtf/OptionSet.h>
namespace PAL::WebGPU {
-using TextureUsageFlags = uint32_t;
-class TextureUsage : public RefCounted<TextureUsage> {
-public:
- static constexpr FlagsConstant COPY_SRC = 0x01;
- static constexpr FlagsConstant COPY_DST = 0x02;
- static constexpr FlagsConstant TEXTURE_BINDING = 0x04;
- static constexpr FlagsConstant STORAGE_BINDING = 0x08;
- static constexpr FlagsConstant RENDER_ATTACHMENT = 0x10;
+enum class TextureUsage : uint8_t {
+ CopySource = 1 << 0,
+ CopyDestination = 1 << 1,
+ TextureBinding = 1 << 2,
+ StorageBinding = 1 << 3,
+ RenderAttachment = 1 << 4,
};
+using TextureUsageFlags = OptionSet<TextureUsage>;
} // namespace PAL::WebGPU
+
+namespace WTF {
+
+template<> struct EnumTraits<PAL::WebGPU::TextureUsage> {
+ using values = EnumValues<
+ PAL::WebGPU::TextureUsage,
+ PAL::WebGPU::TextureUsage::CopySource,
+ PAL::WebGPU::TextureUsage::CopyDestination,
+ PAL::WebGPU::TextureUsage::TextureBinding,
+ PAL::WebGPU::TextureUsage::StorageBinding,
+ PAL::WebGPU::TextureUsage::RenderAttachment
+ >;
+};
+
+} // namespace WTF
+
Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.cpp (286123 => 286124)
--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.cpp 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.cpp 2021-11-23 01:46:52 UTC (rev 286124)
@@ -59,7 +59,7 @@
m_backing->mapAsync(mapModeFlags, offset, size, [mapModeFlags, offset, size, strongThis = Ref<RemoteBuffer>(*this), callback = WTFMove(callback)] () mutable {
auto mappedRange = strongThis->m_backing->getMappedRange(offset, size);
strongThis->m_mappedRange = mappedRange;
- if (mapModeFlags & PAL::WebGPU::MapMode::READ)
+ if (mapModeFlags.contains(PAL::WebGPU::MapMode::Read))
callback(Vector<uint8_t>(static_cast<const uint8_t*>(mappedRange.source), mappedRange.byteLength));
else
callback({ { } });
@@ -72,12 +72,12 @@
return;
ASSERT(m_isMapped);
- if (m_mapModeFlags & PAL::WebGPU::MapMode::WRITE)
+ if (m_mapModeFlags.contains(PAL::WebGPU::MapMode::Write))
memcpy(m_mappedRange->source, data.data(), data.size());
m_isMapped = false;
m_mappedRange = std::nullopt;
- m_mapModeFlags = 0;
+ m_mapModeFlags = { };
}
void RemoteBuffer::destroy()
Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.h (286123 => 286124)
--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -82,7 +82,7 @@
WebGPUIdentifier m_identifier;
bool m_isMapped { false };
std::optional<PAL::WebGPU::Buffer::MappedRange> m_mappedRange;
- PAL::WebGPU::MapModeFlags m_mapModeFlags { 0 };
+ PAL::WebGPU::MapModeFlags m_mapModeFlags;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/Shared/WebGPU/WebGPUCanvasConfiguration.h (286123 => 286124)
--- trunk/Source/WebKit/Shared/WebGPU/WebGPUCanvasConfiguration.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebKit/Shared/WebGPU/WebGPUCanvasConfiguration.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -34,6 +34,7 @@
#include <pal/graphics/WebGPU/WebGPUCanvasCompositingAlphaMode.h>
#include <pal/graphics/WebGPU/WebGPUPredefinedColorSpace.h>
#include <pal/graphics/WebGPU/WebGPUTextureFormat.h>
+#include <pal/graphics/WebGPU/WebGPUTextureUsage.h>
#include <wtf/Ref.h>
namespace WebKit::WebGPU {
@@ -40,12 +41,10 @@
class Device;
-using TextureUsageFlags = uint32_t; // FIXME: This doesn't need to be here.
-
struct CanvasConfiguration {
WebGPUIdentifier device;
PAL::WebGPU::TextureFormat format;
- TextureUsageFlags usage; // TextureUsage.RENDER_ATTACHMENT
+ PAL::WebGPU::TextureUsageFlags usage; // TextureUsage.RENDER_ATTACHMENT
PAL::WebGPU::PredefinedColorSpace colorSpace;
PAL::WebGPU::CanvasCompositingAlphaMode compositingAlphaMode;
std::optional<Extent3D> size;
@@ -72,7 +71,7 @@
if (!format)
return std::nullopt;
- std::optional<TextureUsageFlags> usage;
+ std::optional<PAL::WebGPU::TextureUsageFlags> usage;
decoder >> usage;
if (!usage)
return std::nullopt;
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp (286123 => 286124)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp 2021-11-23 01:46:52 UTC (rev 286124)
@@ -76,13 +76,13 @@
return;
Vector<uint8_t> data;
- if (m_mapModeFlags & PAL::WebGPU::MapMode::WRITE)
+ if (m_mapModeFlags.contains(PAL::WebGPU::MapMode::Write))
data = ""
auto sendResult = send(Messages::RemoteBuffer::Unmap(WTFMove(data)));
UNUSED_VARIABLE(sendResult);
m_data = std::nullopt;
- m_mapModeFlags = 0;
+ m_mapModeFlags = { };
}
void RemoteBufferProxy::destroy()
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h (286123 => 286124)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h 2021-11-23 01:46:15 UTC (rev 286123)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h 2021-11-23 01:46:52 UTC (rev 286124)
@@ -86,7 +86,7 @@
Ref<ConvertToBackingContext> m_convertToBackingContext;
Ref<RemoteDeviceProxy> m_parent;
std::optional<Vector<uint8_t>> m_data;
- PAL::WebGPU::MapModeFlags m_mapModeFlags { 0 };
+ PAL::WebGPU::MapModeFlags m_mapModeFlags;
};
} // namespace WebKit::WebGPU