Changeset 242972 in webkit


Ignore:
Timestamp:
Mar 14, 2019 3:26:52 PM (5 years ago)
Author:
Justin Fan
Message:

[Web GPU] Enum cleanup
https://bugs.webkit.org/show_bug.cgi?id=195766

Reviewed by Myles C. Maxfield.

Clean up enum implementations in Web GPU. Enums referenced by only one class now share implementation files with that class to reduce clutter.

No change in behavior.

  • DerivedSources.make:
  • Modules/webgpu/GPUBindGroupLayoutBinding.h:
  • Modules/webgpu/GPUBindGroupLayoutBinding.idl:
  • Modules/webgpu/GPUInputStateDescriptor.idl:
  • Modules/webgpu/GPURequestAdapterOptions.idl:
  • Modules/webgpu/GPUSamplerDescriptor.idl:
  • Modules/webgpu/GPUTextureDescriptor.idl:
  • Modules/webgpu/GPUTextureDimension.idl: Removed.
  • Modules/webgpu/GPUVertexAttributeDescriptor.idl:
  • Modules/webgpu/GPUVertexInputDescriptor.idl:
  • Modules/webgpu/WebGPUBindGroupDescriptor.cpp:

(WebCore::validateBufferBindingType):

  • Modules/webgpu/WebGPURenderPipelineDescriptor.h:
  • Modules/webgpu/WebGPURenderPipelineDescriptor.idl:
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/gpu/GPUInputStateDescriptor.h:
  • platform/graphics/gpu/GPURequestAdapterOptions.h:
  • platform/graphics/gpu/GPUSamplerDescriptor.h:
  • platform/graphics/gpu/GPUTextureDescriptor.h:
  • platform/graphics/gpu/GPUTextureDimension.h: Removed.
  • platform/graphics/gpu/GPUVertexAttributeDescriptor.h:
  • platform/graphics/gpu/GPUVertexInputDescriptor.h:
  • platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm:

(WebCore::MTLDataTypeForBindingType):

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

(WebCore::GPUBindGroup::tryCreate):

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

(WebCore::GPUDevice::create):

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

(WebCore::mtlAddressModeForAddressMode):
(WebCore::mtlMinMagFilterForFilterMode):
(WebCore::mtlMipFilterForFilterMode):

Location:
trunk/Source/WebCore
Files:
2 deleted
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r242956 r242972  
    481481    Modules/webgpu/GPUStoreOp.idl
    482482    Modules/webgpu/GPUTextureDescriptor.idl
    483     Modules/webgpu/GPUTextureDimension.idl
    484483    Modules/webgpu/GPUTextureFormat.idl
    485484    Modules/webgpu/GPUTextureUsage.idl
  • trunk/Source/WebCore/ChangeLog

    r242970 r242972  
     12019-03-14  Justin Fan  <justin_fan@apple.com>
     2
     3        [Web GPU] Enum cleanup
     4        https://bugs.webkit.org/show_bug.cgi?id=195766
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Clean up enum implementations in Web GPU. Enums referenced by only one class now share implementation files with that class to reduce clutter.
     9       
     10        No change in behavior.
     11
     12        * DerivedSources.make:
     13        * Modules/webgpu/GPUBindGroupLayoutBinding.h:
     14        * Modules/webgpu/GPUBindGroupLayoutBinding.idl:
     15        * Modules/webgpu/GPUInputStateDescriptor.idl:
     16        * Modules/webgpu/GPURequestAdapterOptions.idl:
     17        * Modules/webgpu/GPUSamplerDescriptor.idl:
     18        * Modules/webgpu/GPUTextureDescriptor.idl:
     19        * Modules/webgpu/GPUTextureDimension.idl: Removed.
     20        * Modules/webgpu/GPUVertexAttributeDescriptor.idl:
     21        * Modules/webgpu/GPUVertexInputDescriptor.idl:
     22        * Modules/webgpu/WebGPUBindGroupDescriptor.cpp:
     23        (WebCore::validateBufferBindingType):
     24        * Modules/webgpu/WebGPURenderPipelineDescriptor.h:
     25        * Modules/webgpu/WebGPURenderPipelineDescriptor.idl:
     26        * Sources.txt:
     27        * WebCore.xcodeproj/project.pbxproj:
     28        * platform/graphics/gpu/GPUInputStateDescriptor.h:
     29        * platform/graphics/gpu/GPURequestAdapterOptions.h:
     30        * platform/graphics/gpu/GPUSamplerDescriptor.h:
     31        * platform/graphics/gpu/GPUTextureDescriptor.h:
     32        * platform/graphics/gpu/GPUTextureDimension.h: Removed.
     33        * platform/graphics/gpu/GPUVertexAttributeDescriptor.h:
     34        * platform/graphics/gpu/GPUVertexInputDescriptor.h:
     35        * platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm:
     36        (WebCore::MTLDataTypeForBindingType):
     37        * platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm:
     38        (WebCore::GPUBindGroup::tryCreate):
     39        * platform/graphics/gpu/cocoa/GPUDeviceMetal.mm:
     40        (WebCore::GPUDevice::create):
     41        * platform/graphics/gpu/cocoa/GPUSamplerMetal.mm:
     42        (WebCore::mtlAddressModeForAddressMode):
     43        (WebCore::mtlMinMagFilterForFilterMode):
     44        (WebCore::mtlMipFilterForFilterMode):
     45
    1462019-03-14  Said Abou-Hallawa  <sabouhallawa@apple.com>
    247
  • trunk/Source/WebCore/DerivedSources.make

    r242956 r242972  
    391391    $(WebCore)/Modules/webgpu/GPUStoreOp.idl \
    392392    $(WebCore)/Modules/webgpu/GPUTextureDescriptor.idl \
    393     $(WebCore)/Modules/webgpu/GPUTextureDimension.idl \
    394393    $(WebCore)/Modules/webgpu/GPUTextureFormat.idl \
    395394    $(WebCore)/Modules/webgpu/GPUTextureUsage.idl \
  • trunk/Source/WebCore/Modules/webgpu/GPUBindGroupLayoutBinding.h

    r242575 r242972  
    3232namespace WebCore {
    3333
     34enum class GPUBindingType {
     35    UniformBuffer,
     36    DynamicUniformBuffer,
     37    Sampler,
     38    SampledTexture,
     39    StorageBuffer,
     40    DynamicStorageBuffer,
     41};
     42
    3443struct GPUBindGroupLayoutBinding {
    35     enum class BindingType {
    36         UniformBuffer,
    37         DynamicUniformBuffer,
    38         Sampler,
    39         SampledTexture,
    40         StorageBuffer,
    41         DynamicStorageBuffer
    42     };
    43 
    4444    unsigned long binding;
    4545    GPUShaderStageFlags visibility;
    46     BindingType type;
     46    GPUBindingType type;
    4747};
    4848
  • trunk/Source/WebCore/Modules/webgpu/GPUBindGroupLayoutBinding.idl

    r242575 r242972  
    2929
    3030[
    31     Conditional=WEBGPU,
    32     EnabledAtRuntime=WebGPU
     31    ImplementedAs=GPUBindingType
    3332] enum GPUBindingType {
    3433    "uniform-buffer",
  • trunk/Source/WebCore/Modules/webgpu/GPUInputStateDescriptor.idl

    r242839 r242972  
    2727typedef unsigned long u32;
    2828
    29 enum GPUIndexFormat {
     29[
     30    ImplementedAs=GPUIndexFormat
     31] enum GPUIndexFormat {
    3032    "uint16",
    3133    "uint32"
  • trunk/Source/WebCore/Modules/webgpu/GPURequestAdapterOptions.idl

    r240807 r242972  
    2525// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
    2626
    27 enum GPUPowerPreference {
     27[
     28    ImplementedAs=GPUPowerPreference
     29] enum GPUPowerPreference {
    2830    "low-power",
    2931    "high-performance"
  • trunk/Source/WebCore/Modules/webgpu/GPUSamplerDescriptor.idl

    r242619 r242972  
    2727typedef unsigned long u32;
    2828
    29 enum GPUAddressMode {
     29[
     30    ImplementedAs=GPUAddressMode
     31] enum GPUAddressMode {
    3032    "clamp-to-edge",
    3133    "repeat",
     
    3335};
    3436
    35 enum GPUFilterMode {
     37[
     38    ImplementedAs=GPUFilterMode
     39] enum GPUFilterMode {
    3640    "nearest",
    3741    "linear"
  • trunk/Source/WebCore/Modules/webgpu/GPUTextureDescriptor.idl

    r242759 r242972  
    2929
    3030[
     31    ImplementedAs=GPUTextureDimension
     32] enum GPUTextureDimension {
     33    "1d",
     34    "2d",
     35    "3d"
     36};
     37
     38[
    3139    Conditional=WEBGPU,
    3240    EnabledAtRuntime=WebGPU
  • trunk/Source/WebCore/Modules/webgpu/GPUVertexAttributeDescriptor.idl

    r242839 r242972  
    2828typedef unsigned long long u64;
    2929
    30 enum GPUVertexFormat {
     30[
     31    ImplementedAs=GPUVertexFormat
     32] enum GPUVertexFormat {
    3133    "float",
    3234    "float2",
  • trunk/Source/WebCore/Modules/webgpu/GPUVertexInputDescriptor.idl

    r242839 r242972  
    2828typedef unsigned long long u64;
    2929
    30 enum GPUInputStepMode {
     30[
     31    ImplementedAs=GPUInputStepMode
     32] enum GPUInputStepMode {
    3133    "vertex",
    3234    "instance"
  • trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupDescriptor.cpp

    r242839 r242972  
    4343
    4444    switch (binding.type) {
    45     case GPUBindGroupLayoutBinding::BindingType::UniformBuffer:
     45    case GPUBindingType::UniformBuffer:
    4646        if (!buffer->isUniform()) {
    4747            LOG(WebGPU, "%s: GPUBuffer resource for binding %lu does not have UNIFORM usage!", functionName, binding.binding);
     
    4949        }
    5050        return true;
    51     case GPUBindGroupLayoutBinding::BindingType::StorageBuffer:
     51    case GPUBindingType::StorageBuffer:
    5252        if (!buffer->isStorage()) {
    5353            LOG(WebGPU, "%s: GPUBuffer resource for binding %lu does not have STORAGE usage!", functionName, binding.binding);
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.h

    r242839 r242972  
    3636
    3737struct WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase, GPURenderPipelineDescriptorBase {
    38     using GPUPrimitiveTopology = GPUPrimitiveTopology;
    39     using GPUColorStateDescriptor = GPUColorStateDescriptor;
    40 
    4138    Optional<GPURenderPipelineDescriptor> tryCreateGPURenderPipelineDescriptor() const;
    4239
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.idl

    r242839 r242972  
    2525// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
    2626
    27 enum GPUPrimitiveTopology {
     27[
     28    ImplementedAs=GPUPrimitiveTopology
     29] enum GPUPrimitiveTopology {
    2830    "point-list",
    2931    "line-list",
  • trunk/Source/WebCore/Sources.txt

    r242956 r242972  
    27972797JSGPUStoreOp.cpp
    27982798JSGPUTextureDescriptor.cpp
    2799 JSGPUTextureDimension.cpp
    28002799JSGPUTextureFormat.cpp
    28012800JSGPUTextureUsage.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r242956 r242972  
    1400214002                D026F483220A472F00AC5F49 /* GPUTextureUsage.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUTextureUsage.idl; sourceTree = "<group>"; };
    1400314003                D026F485220A477200AC5F49 /* GPUTextureUsage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUTextureUsage.h; sourceTree = "<group>"; };
    14004                 D026F486220A505900AC5F49 /* GPUTextureDimension.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUTextureDimension.h; sourceTree = "<group>"; };
    14005                 D026F489220A539800AC5F49 /* GPUTextureDimension.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUTextureDimension.idl; sourceTree = "<group>"; };
    1400614004                D026F48B220A5B0B00AC5F49 /* GPUTextureDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUTextureDescriptor.idl; sourceTree = "<group>"; };
    1400714005                D026F48C220A5BAD00AC5F49 /* GPUTextureDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUTextureDescriptor.h; sourceTree = "<group>"; };
     
    1854818546                                312FF8C521A4C2F400EB199D /* GPUTexture.h */,
    1854918547                                D026F48C220A5BAD00AC5F49 /* GPUTextureDescriptor.h */,
    18550                                 D026F486220A505900AC5F49 /* GPUTextureDimension.h */,
    1855118548                                312FF8C321A4C2F300EB199D /* GPUTextureFormat.h */,
    1855218549                                D026F485220A477200AC5F49 /* GPUTextureUsage.h */,
     
    2615026147                                D0ADB27F2232F17300A22935 /* GPUSwapChainDescriptor.h */,
    2615126148                                D026F48B220A5B0B00AC5F49 /* GPUTextureDescriptor.idl */,
    26152                                 D026F489220A539800AC5F49 /* GPUTextureDimension.idl */,
    2615326149                                D0EACFAE219E30FD000FA75C /* GPUTextureFormat.idl */,
    2615426150                                D026F483220A472F00AC5F49 /* GPUTextureUsage.idl */,
  • trunk/Source/WebCore/platform/graphics/gpu/GPUInputStateDescriptor.h

    r242839 r242972  
    4040
    4141struct GPUInputStateDescriptor {
    42     using IndexFormat = GPUIndexFormat;
    43 
    44     IndexFormat indexFormat;
     42    GPUIndexFormat indexFormat;
    4543
    4644    Vector<GPUVertexAttributeDescriptor> attributes;
  • trunk/Source/WebCore/platform/graphics/gpu/GPURequestAdapterOptions.h

    r240807 r242972  
    3030namespace WebCore {
    3131
     32enum class GPUPowerPreference {
     33    LowPower,
     34    HighPerformance
     35};
     36
    3237struct GPURequestAdapterOptions {
    33     enum class PowerPreference {
    34         LowPower,
    35         HighPerformance
    36     };
    37    
    38     PowerPreference powerPreference;
     38    GPUPowerPreference powerPreference;
    3939};
    4040   
  • trunk/Source/WebCore/platform/graphics/gpu/GPUSamplerDescriptor.h

    r242619 r242972  
    3232namespace WebCore {
    3333
     34enum class GPUAddressMode {
     35    ClampToEdge,
     36    Repeat,
     37    MirrorRepeat,
     38};
     39
     40enum class GPUFilterMode {
     41    Nearest,
     42    Linear,
     43};
     44
    3445struct GPUSamplerDescriptor {
    35     enum class AddressMode {
    36         ClampToEdge,
    37         Repeat,
    38         MirrorRepeat,
    39     };
    40 
    41     enum class FilterMode {
    42         Nearest,
    43         Linear,
    44     };
    45 
    46     AddressMode addressModeU { AddressMode::ClampToEdge };
    47     AddressMode addressModeV { AddressMode::ClampToEdge };
    48     AddressMode addressModeW { AddressMode::ClampToEdge };
    49     FilterMode magFilter { FilterMode::Nearest };
    50     FilterMode minFilter { FilterMode::Nearest };
    51     FilterMode mipmapFilter { FilterMode::Nearest };
     46    GPUAddressMode addressModeU { GPUAddressMode::ClampToEdge };
     47    GPUAddressMode addressModeV { GPUAddressMode::ClampToEdge };
     48    GPUAddressMode addressModeW { GPUAddressMode::ClampToEdge };
     49    GPUFilterMode magFilter { GPUFilterMode::Nearest };
     50    GPUFilterMode minFilter { GPUFilterMode::Nearest };
     51    GPUFilterMode mipmapFilter { GPUFilterMode::Nearest };
    5252    float lodMinClamp { 0 };
    5353    float lodMaxClamp { 0xffffffff };
  • trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h

    r241048 r242972  
    2929
    3030#include "GPUExtent3D.h"
    31 #include "GPUTextureDimension.h"
    3231#include "GPUTextureFormat.h"
    3332#include "GPUTextureUsage.h"
    3433
    3534namespace WebCore {
     35
     36enum class GPUTextureDimension {
     37    _1d,
     38    _2d,
     39    _3d
     40};
    3641   
    3742struct GPUTextureDescriptor {
  • trunk/Source/WebCore/platform/graphics/gpu/GPUVertexAttributeDescriptor.h

    r242839 r242972  
    4040
    4141struct GPUVertexAttributeDescriptor {
    42     using Format = GPUVertexFormat;
    43 
    4442    unsigned shaderLocation;
    4543    unsigned inputSlot;
    4644    unsigned long offset;
    47     Format format;
     45    GPUVertexFormat format;
    4846};
    4947
  • trunk/Source/WebCore/platform/graphics/gpu/GPUVertexInputDescriptor.h

    r242839 r242972  
    3636
    3737struct GPUVertexInputDescriptor {
    38     using InputStepMode = GPUInputStepMode;
    39 
    4038    unsigned inputSlot;
    4139    unsigned long stride;
    42     InputStepMode stepMode;
     40    GPUInputStepMode stepMode;
    4341};
    4442
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm

    r242766 r242972  
    3838namespace WebCore {
    3939
    40 static MTLDataType MTLDataTypeForBindingType(GPUBindGroupLayoutBinding::BindingType type)
     40static MTLDataType MTLDataTypeForBindingType(GPUBindingType type)
    4141{
    4242    switch (type) {
    43     case GPUBindGroupLayoutBinding::BindingType::Sampler:
     43    case GPUBindingType::Sampler:
    4444        return MTLDataTypeSampler;
    45     case GPUBindGroupLayoutBinding::BindingType::SampledTexture:
     45    case GPUBindingType::SampledTexture:
    4646        return MTLDataTypeTexture;
    47     case GPUBindGroupLayoutBinding::BindingType::UniformBuffer:
    48     case GPUBindGroupLayoutBinding::BindingType::DynamicUniformBuffer:
    49     case GPUBindGroupLayoutBinding::BindingType::StorageBuffer:
    50     case GPUBindGroupLayoutBinding::BindingType::DynamicStorageBuffer:
     47    case GPUBindingType::UniformBuffer:
     48    case GPUBindingType::DynamicUniformBuffer:
     49    case GPUBindingType::StorageBuffer:
     50    case GPUBindingType::DynamicStorageBuffer:
    5151        return MTLDataTypePointer;
    5252    }
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm

    r242766 r242972  
    173173        switch (layoutBinding.type) {
    174174        // FIXME: Support more resource types.
    175         case GPUBindGroupLayoutBinding::BindingType::UniformBuffer:
    176         case GPUBindGroupLayoutBinding::BindingType::StorageBuffer: {
     175        case GPUBindingType::UniformBuffer:
     176        case GPUBindingType::StorageBuffer: {
    177177            auto bufferResource = tryGetResourceAsBufferBinding(resourceBinding.resource, functionName);
    178178            if (!bufferResource)
     
    185185            break;
    186186        }
    187         case GPUBindGroupLayoutBinding::BindingType::Sampler: {
     187        case GPUBindingType::Sampler: {
    188188            auto samplerResource = tryGetResourceAsSampler(resourceBinding.resource, functionName);
    189189            if (!samplerResource)
     
    195195            break;
    196196        }
    197         case GPUBindGroupLayoutBinding::BindingType::SampledTexture: {
     197        case GPUBindingType::SampledTexture: {
    198198            auto textureResource = tryGetResourceAsTexture(resourceBinding.resource, functionName);
    199199            if (!textureResource)
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm

    r242575 r242972  
    4444   
    4545#if PLATFORM(MAC)
    46     if (options && options->powerPreference == GPURequestAdapterOptions::PowerPreference::LowPower) {
     46    if (options && options->powerPreference == GPUPowerPreference::LowPower) {
    4747        auto devices = adoptNS(MTLCopyAllDevices());
    4848       
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUSamplerMetal.mm

    r242619 r242972  
    3838namespace WebCore {
    3939
    40 static MTLSamplerAddressMode mtlAddressModeForAddressMode(GPUSamplerDescriptor::AddressMode mode)
     40static MTLSamplerAddressMode mtlAddressModeForAddressMode(GPUAddressMode mode)
    4141{
    4242    switch (mode) {
    43     case GPUSamplerDescriptor::AddressMode::ClampToEdge:
     43    case GPUAddressMode::ClampToEdge:
    4444        return MTLSamplerAddressModeClampToEdge;
    45     case GPUSamplerDescriptor::AddressMode::Repeat:
     45    case GPUAddressMode::Repeat:
    4646        return MTLSamplerAddressModeRepeat;
    47     case GPUSamplerDescriptor::AddressMode::MirrorRepeat:
     47    case GPUAddressMode::MirrorRepeat:
    4848        return MTLSamplerAddressModeMirrorRepeat;
    4949    }
     
    5252}
    5353
    54 static MTLSamplerMinMagFilter mtlMinMagFilterForFilterMode(GPUSamplerDescriptor::FilterMode mode)
     54static MTLSamplerMinMagFilter mtlMinMagFilterForFilterMode(GPUFilterMode mode)
    5555{
    5656    switch (mode) {
    57     case GPUSamplerDescriptor::FilterMode::Nearest:
     57    case GPUFilterMode::Nearest:
    5858        return MTLSamplerMinMagFilterNearest;
    59     case GPUSamplerDescriptor::FilterMode::Linear:
     59    case GPUFilterMode::Linear:
    6060        return MTLSamplerMinMagFilterLinear;
    6161    }
     
    6464}
    6565
    66 static MTLSamplerMipFilter mtlMipFilterForFilterMode(GPUSamplerDescriptor::FilterMode mode)
     66static MTLSamplerMipFilter mtlMipFilterForFilterMode(GPUFilterMode mode)
    6767{
    6868    switch (mode) {
    69     case GPUSamplerDescriptor::FilterMode::Nearest:
     69    case GPUFilterMode::Nearest:
    7070        return MTLSamplerMipFilterNearest;
    71     case GPUSamplerDescriptor::FilterMode::Linear:
     71    case GPUFilterMode::Linear:
    7272        return MTLSamplerMipFilterLinear;
    7373    }
Note: See TracChangeset for help on using the changeset viewer.