| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2015 Google Inc. | 2  * Copyright 2015 Google Inc. | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 | 7 | 
| 8 #ifndef GrVkCaps_DEFINED | 8 #ifndef GrVkCaps_DEFINED | 
| 9 #define GrVkCaps_DEFINED | 9 #define GrVkCaps_DEFINED | 
| 10 | 10 | 
| 11 #include "GrCaps.h" | 11 #include "GrCaps.h" | 
| 12 #include "GrVkStencilAttachment.h" | 12 #include "GrVkStencilAttachment.h" | 
| 13 #include "vulkan/vulkan.h" | 13 #include "vulkan/vulkan.h" | 
| 14 | 14 | 
| 15 struct GrVkInterface; | 15 struct GrVkInterface; | 
| 16 class GrGLSLCaps; | 16 class GrGLSLCaps; | 
| 17 | 17 | 
| 18 /** | 18 /** | 
| 19  * Stores some capabilities of a Vk backend. | 19  * Stores some capabilities of a Vk backend. | 
| 20  */ | 20  */ | 
| 21 class GrVkCaps : public GrCaps { | 21 class GrVkCaps : public GrCaps { | 
| 22 public: | 22 public: | 
| 23     typedef GrVkStencilAttachment::Format StencilFormat; | 23     typedef GrVkStencilAttachment::Format StencilFormat; | 
| 24 | 24 | 
| 25     /** | 25     /** | 
| 26      * Creates a GrVkCaps that is set such that nothing is supported. The init f
     unction should | 26      * Creates a GrVkCaps that is set such that nothing is supported. The init f
     unction should | 
| 27      * be called to fill out the caps. | 27      * be called to fill out the caps. | 
| 28      */ | 28      */ | 
| 29     GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* vkInte
     rface, | 29     GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* vkInte
     rface, | 
| 30              VkPhysicalDevice device, uint32_t featureFlags); | 30              VkPhysicalDevice device, uint32_t featureFlags, uint32_t extensionF
     lags); | 
| 31 | 31 | 
| 32     bool isConfigTexturable(GrPixelConfig config) const override { | 32     bool isConfigTexturable(GrPixelConfig config) const override { | 
| 33         SkASSERT(kGrPixelConfigCnt > config); | 33         SkASSERT(kGrPixelConfigCnt > config); | 
| 34         return fConfigTextureSupport[config]; | 34         return fConfigTextureSupport[config]; | 
| 35     } | 35     } | 
| 36 | 36 | 
| 37     bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override 
     { | 37     bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override 
     { | 
| 38         SkASSERT(kGrPixelConfigCnt > config); | 38         SkASSERT(kGrPixelConfigCnt > config); | 
| 39         return fConfigRenderSupport[config][withMSAA]; | 39         return fConfigRenderSupport[config][withMSAA]; | 
| 40     } | 40     } | 
| 41 | 41 | 
| 42     bool isConfigRenderableLinearly(GrPixelConfig config, bool withMSAA) const { | 42     bool isConfigRenderableLinearly(GrPixelConfig config, bool withMSAA) const { | 
| 43         SkASSERT(kGrPixelConfigCnt > config); | 43         SkASSERT(kGrPixelConfigCnt > config); | 
| 44         return fConfigLinearRenderSupport[config][withMSAA]; | 44         return fConfigLinearRenderSupport[config][withMSAA]; | 
| 45     } | 45     } | 
| 46 | 46 | 
| 47     bool isConfigTexurableLinearly(GrPixelConfig config) const { | 47     bool isConfigTexurableLinearly(GrPixelConfig config) const { | 
| 48         SkASSERT(kGrPixelConfigCnt > config); | 48         SkASSERT(kGrPixelConfigCnt > config); | 
| 49         return fConfigLinearTextureSupport[config]; | 49         return fConfigLinearTextureSupport[config]; | 
| 50     } | 50     } | 
| 51 | 51 | 
|  | 52     bool canUseGLSLForShaderModule() const { | 
|  | 53         return fCanUseGLSLForShaderModule; | 
|  | 54     } | 
|  | 55 | 
| 52     /** | 56     /** | 
| 53      * Gets an array of legal stencil formats. These formats are not guaranteed 
     to be supported by | 57      * Gets an array of legal stencil formats. These formats are not guaranteed 
     to be supported by | 
| 54      * the driver but are legal VK_TEXTURE_FORMATs. | 58      * the driver but are legal VK_TEXTURE_FORMATs. | 
| 55      */ | 59      */ | 
| 56     const SkTArray<StencilFormat, true>& stencilFormats() const { | 60     const SkTArray<StencilFormat, true>& stencilFormats() const { | 
| 57         return fStencilFormats; | 61         return fStencilFormats; | 
| 58     } | 62     } | 
| 59 | 63 | 
| 60     /** | 64     /** | 
| 61      * Gets an array of legal stencil formats. These formats are not guaranteed 
     to be supported by | 65      * Gets an array of legal stencil formats. These formats are not guaranteed 
     to be supported by | 
| 62      * the driver but are legal VK_TEXTURE_FORMATs. | 66      * the driver but are legal VK_TEXTURE_FORMATs. | 
| 63      */ | 67      */ | 
| 64     const SkTArray<StencilFormat, true>& linearStencilFormats() const { | 68     const SkTArray<StencilFormat, true>& linearStencilFormats() const { | 
| 65         return fLinearStencilFormats; | 69         return fLinearStencilFormats; | 
| 66     } | 70     } | 
| 67 | 71 | 
| 68     GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderC
     aps.get()); } | 72     GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderC
     aps.get()); } | 
| 69 | 73 | 
| 70 private: | 74 private: | 
| 71     void init(const GrContextOptions& contextOptions, const GrVkInterface* vkInt
     erface, | 75     void init(const GrContextOptions& contextOptions, const GrVkInterface* vkInt
     erface, | 
| 72               VkPhysicalDevice device, uint32_t featureFlags); | 76               VkPhysicalDevice device, uint32_t featureFlags, uint32_t extension
     Flags); | 
| 73     void initGrCaps(const VkPhysicalDeviceProperties&, | 77     void initGrCaps(const VkPhysicalDeviceProperties&, | 
| 74                     const VkPhysicalDeviceMemoryProperties&, | 78                     const VkPhysicalDeviceMemoryProperties&, | 
| 75                     uint32_t featureFlags); | 79                     uint32_t featureFlags); | 
| 76     void initGLSLCaps(const VkPhysicalDeviceProperties&, uint32_t featureFlags); | 80     void initGLSLCaps(const VkPhysicalDeviceProperties&, uint32_t featureFlags); | 
| 77     void initSampleCount(const VkPhysicalDeviceProperties& properties); | 81     void initSampleCount(const VkPhysicalDeviceProperties& properties); | 
| 78     void initConfigRenderableTable(const GrVkInterface* interface, VkPhysicalDev
     ice physDev); | 82     void initConfigRenderableTable(const GrVkInterface* interface, VkPhysicalDev
     ice physDev); | 
| 79     void initConfigTexturableTable(const GrVkInterface* interface, VkPhysicalDev
     ice physDev); | 83     void initConfigTexturableTable(const GrVkInterface* interface, VkPhysicalDev
     ice physDev); | 
| 80     void initStencilFormats(const GrVkInterface* interface, VkPhysicalDevice phy
     sDev); | 84     void initStencilFormats(const GrVkInterface* interface, VkPhysicalDevice phy
     sDev); | 
| 81 | 85 | 
| 82 | 86 | 
| 83     bool fConfigTextureSupport[kGrPixelConfigCnt]; | 87     bool fConfigTextureSupport[kGrPixelConfigCnt]; | 
| 84     // For Vulkan we track whether a config is supported linearly (without need 
     for swizzling) | 88     // For Vulkan we track whether a config is supported linearly (without need 
     for swizzling) | 
| 85     bool fConfigLinearTextureSupport[kGrPixelConfigCnt]; | 89     bool fConfigLinearTextureSupport[kGrPixelConfigCnt]; | 
| 86 | 90 | 
| 87     // The first entry for each config is without msaa and the second is with. | 91     // The first entry for each config is without msaa and the second is with. | 
| 88     bool fConfigRenderSupport[kGrPixelConfigCnt][2]; | 92     bool fConfigRenderSupport[kGrPixelConfigCnt][2]; | 
| 89     // The first entry for each config is without msaa and the second is with. | 93     // The first entry for each config is without msaa and the second is with. | 
| 90     bool fConfigLinearRenderSupport[kGrPixelConfigCnt][2]; | 94     bool fConfigLinearRenderSupport[kGrPixelConfigCnt][2]; | 
| 91 | 95 | 
| 92     SkTArray<StencilFormat, true> fLinearStencilFormats; | 96     SkTArray<StencilFormat, true> fLinearStencilFormats; | 
| 93     SkTArray<StencilFormat, true> fStencilFormats; | 97     SkTArray<StencilFormat, true> fStencilFormats; | 
| 94 | 98 | 
|  | 99     // Tells of if we can pass in straight GLSL string into vkCreateShaderModule | 
|  | 100     bool fCanUseGLSLForShaderModule; | 
|  | 101 | 
| 95     typedef GrCaps INHERITED; | 102     typedef GrCaps INHERITED; | 
| 96 }; | 103 }; | 
| 97 | 104 | 
| 98 #endif | 105 #endif | 
| OLD | NEW | 
|---|