Changeset 286124 in webkit
- Timestamp:
- Nov 22, 2021, 5:46:52 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 19 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Modules/WebGPU/GPUBufferUsage.h (modified) (1 diff)
-
WebCore/Modules/WebGPU/GPUColorWrite.h (modified) (1 diff)
-
WebCore/Modules/WebGPU/GPUMapMode.h (modified) (1 diff)
-
WebCore/Modules/WebGPU/GPUShaderStage.h (modified) (1 diff)
-
WebCore/Modules/WebGPU/GPUTextureUsage.h (modified) (1 diff)
-
WebCore/PAL/ChangeLog (modified) (1 diff)
-
WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUConvertToBackingContext.cpp (modified) (5 diffs)
-
WebCore/PAL/pal/graphics/WebGPU/WebGPUBufferUsage.h (modified) (1 diff)
-
WebCore/PAL/pal/graphics/WebGPU/WebGPUCanvasConfiguration.h (modified) (2 diffs)
-
WebCore/PAL/pal/graphics/WebGPU/WebGPUColorWrite.h (modified) (1 diff)
-
WebCore/PAL/pal/graphics/WebGPU/WebGPUMapMode.h (modified) (1 diff)
-
WebCore/PAL/pal/graphics/WebGPU/WebGPUShaderStage.h (modified) (1 diff)
-
WebCore/PAL/pal/graphics/WebGPU/WebGPUTextureUsage.h (modified) (1 diff)
-
WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.cpp (modified) (2 diffs)
-
WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.h (modified) (1 diff)
-
WebKit/Shared/WebGPU/WebGPUCanvasConfiguration.h (modified) (3 diffs)
-
WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp (modified) (2 diffs)
-
WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286123 r286124 1 2021-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 1 23 2021-11-22 Myles C. Maxfield <mmaxfield@apple.com> 2 24 -
trunk/Source/WebCore/Modules/WebGPU/GPUBufferUsage.h
r285429 r286124 51 51 inline PAL::WebGPU::BufferUsageFlags convertBufferUsageFlagsToBacking(GPUBufferUsageFlags bufferUsageFlags) 52 52 { 53 PAL::WebGPU::BufferUsageFlags result = 0;53 PAL::WebGPU::BufferUsageFlags result; 54 54 if (bufferUsageFlags & GPUBufferUsage::MAP_READ) 55 result |= PAL::WebGPU::BufferUsage::MAP_READ;55 result.add(PAL::WebGPU::BufferUsage::MapRead); 56 56 if (bufferUsageFlags & GPUBufferUsage::MAP_WRITE) 57 result |= PAL::WebGPU::BufferUsage::MAP_WRITE;57 result.add(PAL::WebGPU::BufferUsage::MapWrite); 58 58 if (bufferUsageFlags & GPUBufferUsage::COPY_SRC) 59 result |= PAL::WebGPU::BufferUsage::COPY_SRC;59 result.add(PAL::WebGPU::BufferUsage::CopySource); 60 60 if (bufferUsageFlags & GPUBufferUsage::COPY_DST) 61 result |= PAL::WebGPU::BufferUsage::COPY_DST;61 result.add(PAL::WebGPU::BufferUsage::CopyDestination); 62 62 if (bufferUsageFlags & GPUBufferUsage::INDEX) 63 result |= PAL::WebGPU::BufferUsage::INDEX;63 result.add(PAL::WebGPU::BufferUsage::Index); 64 64 if (bufferUsageFlags & GPUBufferUsage::VERTEX) 65 result |= PAL::WebGPU::BufferUsage::VERTEX;65 result.add(PAL::WebGPU::BufferUsage::Vertex); 66 66 if (bufferUsageFlags & GPUBufferUsage::UNIFORM) 67 result |= PAL::WebGPU::BufferUsage::UNIFORM;67 result.add(PAL::WebGPU::BufferUsage::Uniform); 68 68 if (bufferUsageFlags & GPUBufferUsage::STORAGE) 69 result |= PAL::WebGPU::BufferUsage::STORAGE;69 result.add(PAL::WebGPU::BufferUsage::Storage); 70 70 if (bufferUsageFlags & GPUBufferUsage::INDIRECT) 71 result |= PAL::WebGPU::BufferUsage::INDIRECT;71 result.add(PAL::WebGPU::BufferUsage::Indirect); 72 72 if (bufferUsageFlags & GPUBufferUsage::QUERY_RESOLVE) 73 result |= PAL::WebGPU::BufferUsage::QUERY_RESOLVE;73 result.add(PAL::WebGPU::BufferUsage::QueryResolve); 74 74 return result; 75 75 } -
trunk/Source/WebCore/Modules/WebGPU/GPUColorWrite.h
r285654 r286124 46 46 inline PAL::WebGPU::ColorWriteFlags convertColorWriteFlagsToBacking(GPUColorWriteFlags colorWriteFlags) 47 47 { 48 PAL::WebGPU::ColorWriteFlags result = 0;48 PAL::WebGPU::ColorWriteFlags result; 49 49 if (colorWriteFlags & GPUColorWrite::RED) 50 result |= PAL::WebGPU::ColorWrite::RED;50 result.add(PAL::WebGPU::ColorWrite::Red); 51 51 if (colorWriteFlags & GPUColorWrite::GREEN) 52 result |= PAL::WebGPU::ColorWrite::GREEN;52 result.add(PAL::WebGPU::ColorWrite::Green); 53 53 if (colorWriteFlags & GPUColorWrite::BLUE) 54 result |= PAL::WebGPU::ColorWrite::BLUE;54 result.add(PAL::WebGPU::ColorWrite::Blue); 55 55 if (colorWriteFlags & GPUColorWrite::ALPHA) 56 result |= PAL::WebGPU::ColorWrite::ALPHA;56 result.add(PAL::WebGPU::ColorWrite::Alpha); 57 57 return result; 58 58 } -
trunk/Source/WebCore/Modules/WebGPU/GPUMapMode.h
r285429 r286124 43 43 inline PAL::WebGPU::MapModeFlags convertMapModeFlagsToBacking(GPUMapModeFlags mapModeFlags) 44 44 { 45 PAL::WebGPU::MapModeFlags result = 0;45 PAL::WebGPU::MapModeFlags result; 46 46 if (mapModeFlags & GPUMapMode::READ) 47 result |= PAL::WebGPU::MapMode::READ;47 result.add(PAL::WebGPU::MapMode::Read); 48 48 if (mapModeFlags & GPUMapMode::WRITE) 49 result |= PAL::WebGPU::MapMode::WRITE;49 result.add(PAL::WebGPU::MapMode::Write); 50 50 return result; 51 51 } -
trunk/Source/WebCore/Modules/WebGPU/GPUShaderStage.h
r285429 r286124 43 43 inline PAL::WebGPU::ShaderStageFlags convertShaderStageFlagsToBacking(GPUShaderStageFlags shaderStageFlags) 44 44 { 45 PAL::WebGPU::ShaderStageFlags result = 0;45 PAL::WebGPU::ShaderStageFlags result; 46 46 if (shaderStageFlags & GPUShaderStage::VERTEX) 47 result |= PAL::WebGPU::ShaderStage::VERTEX;47 result.add(PAL::WebGPU::ShaderStage::Vertex); 48 48 if (shaderStageFlags & GPUShaderStage::FRAGMENT) 49 result |= PAL::WebGPU::ShaderStage::FRAGMENT;49 result.add(PAL::WebGPU::ShaderStage::Fragment); 50 50 if (shaderStageFlags & GPUShaderStage::COMPUTE) 51 result |= PAL::WebGPU::ShaderStage::COMPUTE;51 result.add(PAL::WebGPU::ShaderStage::Compute); 52 52 return result; 53 53 } -
trunk/Source/WebCore/Modules/WebGPU/GPUTextureUsage.h
r285429 r286124 45 45 inline PAL::WebGPU::TextureUsageFlags convertTextureUsageFlagsToBacking(GPUTextureUsageFlags textureUsageFlags) 46 46 { 47 PAL::WebGPU::TextureUsageFlags result = 0;47 PAL::WebGPU::TextureUsageFlags result; 48 48 if (textureUsageFlags & GPUTextureUsage::COPY_SRC) 49 result |= PAL::WebGPU::TextureUsage::COPY_SRC;49 result.add(PAL::WebGPU::TextureUsage::CopySource); 50 50 if (textureUsageFlags & GPUTextureUsage::COPY_DST) 51 result |= PAL::WebGPU::TextureUsage::COPY_DST;51 result.add(PAL::WebGPU::TextureUsage::CopyDestination); 52 52 if (textureUsageFlags & GPUTextureUsage::TEXTURE_BINDING) 53 result |= PAL::WebGPU::TextureUsage::TEXTURE_BINDING;53 result.add(PAL::WebGPU::TextureUsage::TextureBinding); 54 54 if (textureUsageFlags & GPUTextureUsage::STORAGE_BINDING) 55 result |= PAL::WebGPU::TextureUsage::STORAGE_BINDING;55 result.add(PAL::WebGPU::TextureUsage::StorageBinding); 56 56 if (textureUsageFlags & GPUTextureUsage::RENDER_ATTACHMENT) 57 result |= PAL::WebGPU::TextureUsage::RENDER_ATTACHMENT;57 result.add(PAL::WebGPU::TextureUsage::RenderAttachment); 58 58 return result; 59 59 } -
trunk/Source/WebCore/PAL/ChangeLog
r286077 r286124 1 2021-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 1 20 2021-11-19 Myles C. Maxfield <mmaxfield@apple.com> 2 21 -
trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUConvertToBackingContext.cpp
r285879 r286124 690 690 { 691 691 WGPUBufferUsageFlags result = 0; 692 if (bufferUsageFlags & BufferUsage::MAP_READ)692 if (bufferUsageFlags.contains(BufferUsage::MapRead)) 693 693 result |= WGPUBufferUsage_MapRead; 694 if (bufferUsageFlags & BufferUsage::MAP_WRITE)694 if (bufferUsageFlags.contains(BufferUsage::MapWrite)) 695 695 result |= WGPUBufferUsage_MapWrite; 696 if (bufferUsageFlags & BufferUsage::COPY_SRC)696 if (bufferUsageFlags.contains(BufferUsage::CopySource)) 697 697 result |= WGPUBufferUsage_CopySrc; 698 if (bufferUsageFlags & BufferUsage::COPY_DST)698 if (bufferUsageFlags.contains(BufferUsage::CopyDestination)) 699 699 result |= WGPUBufferUsage_CopyDst; 700 if (bufferUsageFlags & BufferUsage::INDEX)700 if (bufferUsageFlags.contains(BufferUsage::Index)) 701 701 result |= WGPUBufferUsage_Index; 702 if (bufferUsageFlags & BufferUsage::VERTEX)702 if (bufferUsageFlags.contains(BufferUsage::Vertex)) 703 703 result |= WGPUBufferUsage_Vertex; 704 if (bufferUsageFlags & BufferUsage::UNIFORM)704 if (bufferUsageFlags.contains(BufferUsage::Uniform)) 705 705 result |= WGPUBufferUsage_Uniform; 706 if (bufferUsageFlags & BufferUsage::STORAGE)706 if (bufferUsageFlags.contains(BufferUsage::Storage)) 707 707 result |= WGPUBufferUsage_Storage; 708 if (bufferUsageFlags & BufferUsage::INDIRECT)708 if (bufferUsageFlags.contains(BufferUsage::Indirect)) 709 709 result |= WGPUBufferUsage_Indirect; 710 if (bufferUsageFlags & BufferUsage::QUERY_RESOLVE)710 if (bufferUsageFlags.contains(BufferUsage::QueryResolve)) 711 711 result |= WGPUBufferUsage_QueryResolve; 712 712 return result; … … 716 716 { 717 717 WGPUColorWriteMaskFlags result = 0; 718 if (colorWriteFlags & ColorWrite::RED)718 if (colorWriteFlags.contains(ColorWrite::Red)) 719 719 result |= WGPUColorWriteMask_Red; 720 if (colorWriteFlags & ColorWrite::GREEN)720 if (colorWriteFlags.contains(ColorWrite::Green)) 721 721 result |= WGPUColorWriteMask_Green; 722 if (colorWriteFlags & ColorWrite::BLUE)722 if (colorWriteFlags.contains(ColorWrite::Blue)) 723 723 result |= WGPUColorWriteMask_Blue; 724 if (colorWriteFlags & ColorWrite::ALPHA)724 if (colorWriteFlags.contains(ColorWrite::Alpha)) 725 725 result |= WGPUColorWriteMask_Alpha; 726 726 return result; … … 730 730 { 731 731 WGPUMapModeFlags result = 0; 732 if (mapModeFlags & MapMode::READ)732 if (mapModeFlags.contains(MapMode::Read)) 733 733 result |= WGPUMapMode_Read; 734 if (mapModeFlags & MapMode::WRITE)734 if (mapModeFlags.contains(MapMode::Write)) 735 735 result |= WGPUMapMode_Write; 736 736 return result; … … 740 740 { 741 741 WGPUShaderStageFlags result = 0; 742 if (shaderStageFlags & ShaderStage::VERTEX)742 if (shaderStageFlags.contains(ShaderStage::Vertex)) 743 743 result |= WGPUShaderStage_Vertex; 744 if (shaderStageFlags & ShaderStage::FRAGMENT)744 if (shaderStageFlags.contains(ShaderStage::Fragment)) 745 745 result |= WGPUShaderStage_Fragment; 746 if (shaderStageFlags & ShaderStage::COMPUTE)746 if (shaderStageFlags.contains(ShaderStage::Compute)) 747 747 result |= WGPUShaderStage_Compute; 748 748 return result; … … 752 752 { 753 753 WGPUTextureUsageFlags result = 0; 754 if (textureUsageFlags & TextureUsage::COPY_SRC)754 if (textureUsageFlags.contains(TextureUsage::CopySource)) 755 755 result |= WGPUTextureUsage_CopySrc; 756 if (textureUsageFlags & TextureUsage::COPY_DST)756 if (textureUsageFlags.contains(TextureUsage::CopyDestination)) 757 757 result |= WGPUTextureUsage_CopyDst; 758 if (textureUsageFlags & TextureUsage::TEXTURE_BINDING)758 if (textureUsageFlags.contains(TextureUsage::TextureBinding)) 759 759 result |= WGPUTextureUsage_TextureBinding; 760 if (textureUsageFlags & TextureUsage::STORAGE_BINDING)760 if (textureUsageFlags.contains(TextureUsage::StorageBinding)) 761 761 result |= WGPUTextureUsage_StorageBinding; 762 if (textureUsageFlags & TextureUsage::RENDER_ATTACHMENT)762 if (textureUsageFlags.contains(TextureUsage::RenderAttachment)) 763 763 result |= WGPUTextureUsage_RenderAttachment; 764 764 return result; -
trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUBufferUsage.h
r285981 r286124 26 26 #pragma once 27 27 28 #include "WebGPUIntegralTypes.h"29 28 #include <cstdint> 30 #include <wtf/RefCounted.h> 29 #include <wtf/EnumTraits.h> 30 #include <wtf/OptionSet.h> 31 31 32 32 namespace PAL::WebGPU { 33 33 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; 34 enum 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 }; 46 using BufferUsageFlags = OptionSet<BufferUsage>; 47 48 } // namespace PAL::WebGPU 49 50 namespace WTF { 51 52 template<> 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 >; 47 67 }; 48 68 49 } // namespace PAL::WebGPU69 } // namespace WTF -
trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUCanvasConfiguration.h
r285879 r286124 30 30 #include "WebGPUPredefinedColorSpace.h" 31 31 #include "WebGPUTextureFormat.h" 32 #include "WebGPUTextureUsage.h" 32 33 #include <cstdint> 33 34 #include <optional> … … 37 38 38 39 class Device; 39 40 using TextureUsageFlags = uint32_t; // FIXME: This doesn't need to be here.41 40 42 41 struct CanvasConfiguration { -
trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUColorWrite.h
r285879 r286124 30 30 #include "WebGPUIntegralTypes.h" 31 31 #include <cstdint> 32 #include <wtf/RefCounted.h> 32 #include <wtf/EnumTraits.h> 33 #include <wtf/OptionSet.h> 33 34 34 35 namespace PAL::WebGPU { 35 36 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; 37 enum 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 }; 44 using ColorWriteFlags = OptionSet<ColorWrite>; 45 46 } // namespace PAL::WebGPU 47 48 namespace WTF { 49 50 template<> 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 >; 44 58 }; 45 59 46 } // namespace PAL::WebGPU60 } // namespace WTF -
trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUMapMode.h
r285981 r286124 28 28 #include "WebGPUIntegralTypes.h" 29 29 #include <cstdint> 30 #include <wtf/RefCounted.h> 30 #include <wtf/EnumTraits.h> 31 #include <wtf/OptionSet.h> 31 32 32 33 namespace PAL::WebGPU { 33 34 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; 35 enum class MapMode : uint8_t { 36 Read = 1 << 0, 37 Write = 1 << 1, 38 }; 39 using MapModeFlags = OptionSet<MapMode>; 40 41 } // namespace PAL::WebGPU 42 43 namespace WTF { 44 45 template<> struct EnumTraits<PAL::WebGPU::MapMode> { 46 using values = EnumValues< 47 PAL::WebGPU::MapMode, 48 PAL::WebGPU::MapMode::Read, 49 PAL::WebGPU::MapMode::Write 50 >; 39 51 }; 40 52 41 } // namespace PAL::WebGPU 53 } // namespace WTF 54 -
trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUShaderStage.h
r285879 r286124 28 28 #include "WebGPUIntegralTypes.h" 29 29 #include <cstdint> 30 #include <wtf/RefCounted.h> 30 #include <wtf/EnumTraits.h> 31 #include <wtf/OptionSet.h> 31 32 32 33 namespace PAL::WebGPU { 33 34 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; 35 enum class ShaderStage : uint8_t { 36 Vertex = 1 << 0, 37 Fragment = 1 << 1, 38 Compute = 1 << 2, 39 }; 40 using ShaderStageFlags = OptionSet<ShaderStage>; 41 42 } // namespace PAL::WebGPU 43 44 namespace WTF { 45 46 template<> 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 >; 40 53 }; 41 54 42 } // namespace PAL::WebGPU55 } // namespace WTF -
trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUTextureUsage.h
r285879 r286124 28 28 #include "WebGPUIntegralTypes.h" 29 29 #include <cstdint> 30 #include <wtf/RefCounted.h> 30 #include <wtf/EnumTraits.h> 31 #include <wtf/OptionSet.h> 31 32 32 33 namespace PAL::WebGPU { 33 34 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; 35 enum 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 }; 42 using TextureUsageFlags = OptionSet<TextureUsage>; 43 44 } // namespace PAL::WebGPU 45 46 namespace WTF { 47 48 template<> 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 >; 42 57 }; 43 58 44 } // namespace PAL::WebGPU 59 } // namespace WTF 60 -
trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.cpp
r286087 r286124 60 60 auto mappedRange = strongThis->m_backing->getMappedRange(offset, size); 61 61 strongThis->m_mappedRange = mappedRange; 62 if (mapModeFlags & PAL::WebGPU::MapMode::READ)62 if (mapModeFlags.contains(PAL::WebGPU::MapMode::Read)) 63 63 callback(Vector<uint8_t>(static_cast<const uint8_t*>(mappedRange.source), mappedRange.byteLength)); 64 64 else … … 73 73 ASSERT(m_isMapped); 74 74 75 if (m_mapModeFlags & PAL::WebGPU::MapMode::WRITE)75 if (m_mapModeFlags.contains(PAL::WebGPU::MapMode::Write)) 76 76 memcpy(m_mappedRange->source, data.data(), data.size()); 77 77 78 78 m_isMapped = false; 79 79 m_mappedRange = std::nullopt; 80 m_mapModeFlags = 0;80 m_mapModeFlags = { }; 81 81 } 82 82 -
trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.h
r286087 r286124 83 83 bool m_isMapped { false }; 84 84 std::optional<PAL::WebGPU::Buffer::MappedRange> m_mappedRange; 85 PAL::WebGPU::MapModeFlags m_mapModeFlags { 0 };85 PAL::WebGPU::MapModeFlags m_mapModeFlags; 86 86 }; 87 87 -
trunk/Source/WebKit/Shared/WebGPU/WebGPUCanvasConfiguration.h
r286077 r286124 35 35 #include <pal/graphics/WebGPU/WebGPUPredefinedColorSpace.h> 36 36 #include <pal/graphics/WebGPU/WebGPUTextureFormat.h> 37 #include <pal/graphics/WebGPU/WebGPUTextureUsage.h> 37 38 #include <wtf/Ref.h> 38 39 … … 41 42 class Device; 42 43 43 using TextureUsageFlags = uint32_t; // FIXME: This doesn't need to be here.44 45 44 struct CanvasConfiguration { 46 45 WebGPUIdentifier device; 47 46 PAL::WebGPU::TextureFormat format; 48 TextureUsageFlags usage; // TextureUsage.RENDER_ATTACHMENT47 PAL::WebGPU::TextureUsageFlags usage; // TextureUsage.RENDER_ATTACHMENT 49 48 PAL::WebGPU::PredefinedColorSpace colorSpace; 50 49 PAL::WebGPU::CanvasCompositingAlphaMode compositingAlphaMode; … … 73 72 return std::nullopt; 74 73 75 std::optional< TextureUsageFlags> usage;74 std::optional<PAL::WebGPU::TextureUsageFlags> usage; 76 75 decoder >> usage; 77 76 if (!usage) -
trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp
r286098 r286124 77 77 78 78 Vector<uint8_t> data; 79 if (m_mapModeFlags & PAL::WebGPU::MapMode::WRITE)79 if (m_mapModeFlags.contains(PAL::WebGPU::MapMode::Write)) 80 80 data = WTFMove(*m_data); 81 81 auto sendResult = send(Messages::RemoteBuffer::Unmap(WTFMove(data))); … … 83 83 84 84 m_data = std::nullopt; 85 m_mapModeFlags = 0;85 m_mapModeFlags = { }; 86 86 } 87 87 -
trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h
r286098 r286124 87 87 Ref<RemoteDeviceProxy> m_parent; 88 88 std::optional<Vector<uint8_t>> m_data; 89 PAL::WebGPU::MapModeFlags m_mapModeFlags { 0 };89 PAL::WebGPU::MapModeFlags m_mapModeFlags; 90 90 }; 91 91
Note:
See TracChangeset
for help on using the changeset viewer.