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 |
(...skipping 13 matching lines...) Expand all Loading... |
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, uint32_t extensionF
lags); | 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 SkToBool(ConfigInfo::kTextureable_Flag & fConfigTable[config].fOp
timalFlags); |
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 SkToBool(ConfigInfo::kRenderable_Flag & fConfigTable[config].fOpt
imalFlags); |
| 40 } |
| 41 |
| 42 bool isConfigTexurableLinearly(GrPixelConfig config) const { |
| 43 SkASSERT(kGrPixelConfigCnt > config); |
| 44 return SkToBool(ConfigInfo::kTextureable_Flag & fConfigTable[config].fLi
nearFlags); |
40 } | 45 } |
41 | 46 |
42 bool isConfigRenderableLinearly(GrPixelConfig config, bool withMSAA) const { | 47 bool isConfigRenderableLinearly(GrPixelConfig config, bool withMSAA) const { |
43 SkASSERT(kGrPixelConfigCnt > config); | 48 SkASSERT(kGrPixelConfigCnt > config); |
44 return fConfigLinearRenderSupport[config][withMSAA]; | 49 return !withMSAA && SkToBool(ConfigInfo::kRenderable_Flag & |
| 50 fConfigTable[config].fLinearFlags); |
45 } | 51 } |
46 | 52 |
47 bool isConfigTexurableLinearly(GrPixelConfig config) const { | 53 bool configCanBeDstofBlit(GrPixelConfig config, bool linearTiled) const { |
48 SkASSERT(kGrPixelConfigCnt > config); | 54 SkASSERT(kGrPixelConfigCnt > config); |
49 return fConfigLinearTextureSupport[config]; | 55 const uint16_t& flags = linearTiled ? fConfigTable[config].fLinearFlags
: |
| 56 fConfigTable[config].fOptimalFlags
; |
| 57 return SkToBool(ConfigInfo::kBlitDst_Flag & flags); |
| 58 } |
| 59 |
| 60 bool configCanBeSrcofBlit(GrPixelConfig config, bool linearTiled) const { |
| 61 SkASSERT(kGrPixelConfigCnt > config); |
| 62 const uint16_t& flags = linearTiled ? fConfigTable[config].fLinearFlags
: |
| 63 fConfigTable[config].fOptimalFlags
; |
| 64 return SkToBool(ConfigInfo::kBlitSrc_Flag & flags); |
50 } | 65 } |
51 | 66 |
52 bool canUseGLSLForShaderModule() const { | 67 bool canUseGLSLForShaderModule() const { |
53 return fCanUseGLSLForShaderModule; | 68 return fCanUseGLSLForShaderModule; |
54 } | 69 } |
55 | 70 |
56 /** | 71 /** |
57 * Gets an array of legal stencil formats. These formats are not guaranteed
to be supported by | 72 * Returns both a supported and most prefered stencil format to use in draws
. |
58 * the driver but are legal VK_TEXTURE_FORMATs. | |
59 */ | 73 */ |
60 const SkTArray<StencilFormat, true>& stencilFormats() const { | 74 const StencilFormat& preferedStencilFormat() const { |
61 return fStencilFormats; | 75 return fPreferedStencilFormat; |
62 } | |
63 | |
64 /** | |
65 * Gets an array of legal stencil formats. These formats are not guaranteed
to be supported by | |
66 * the driver but are legal VK_TEXTURE_FORMATs. | |
67 */ | |
68 const SkTArray<StencilFormat, true>& linearStencilFormats() const { | |
69 return fLinearStencilFormats; | |
70 } | 76 } |
71 | 77 |
72 GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderC
aps.get()); } | 78 GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderC
aps.get()); } |
73 | 79 |
74 private: | 80 private: |
75 void init(const GrContextOptions& contextOptions, const GrVkInterface* vkInt
erface, | 81 void init(const GrContextOptions& contextOptions, const GrVkInterface* vkInt
erface, |
76 VkPhysicalDevice device, uint32_t featureFlags, uint32_t extension
Flags); | 82 VkPhysicalDevice device, uint32_t featureFlags, uint32_t extension
Flags); |
77 void initGrCaps(const VkPhysicalDeviceProperties&, | 83 void initGrCaps(const VkPhysicalDeviceProperties&, |
78 const VkPhysicalDeviceMemoryProperties&, | 84 const VkPhysicalDeviceMemoryProperties&, |
79 uint32_t featureFlags); | 85 uint32_t featureFlags); |
80 void initGLSLCaps(const VkPhysicalDeviceProperties&, uint32_t featureFlags); | 86 void initGLSLCaps(const VkPhysicalDeviceProperties&, uint32_t featureFlags); |
81 void initSampleCount(const VkPhysicalDeviceProperties& properties); | 87 void initSampleCount(const VkPhysicalDeviceProperties& properties); |
82 void initConfigRenderableTable(const GrVkInterface* iface, VkPhysicalDevice
physDev); | |
83 void initConfigTexturableTable(const GrVkInterface* iface, VkPhysicalDevice
physDev); | |
84 void initStencilFormats(const GrVkInterface* iface, VkPhysicalDevice physDev
); | |
85 | 88 |
86 | 89 |
87 bool fConfigTextureSupport[kGrPixelConfigCnt]; | 90 void initConfigTable(const GrVkInterface*, VkPhysicalDevice); |
88 // For Vulkan we track whether a config is supported linearly (without need
for swizzling) | 91 void initStencilFormat(const GrVkInterface* iface, VkPhysicalDevice physDev)
; |
89 bool fConfigLinearTextureSupport[kGrPixelConfigCnt]; | |
90 | 92 |
91 // The first entry for each config is without msaa and the second is with. | 93 struct ConfigInfo { |
92 bool fConfigRenderSupport[kGrPixelConfigCnt][2]; | 94 ConfigInfo() : fOptimalFlags(0), fLinearFlags(0) {} |
93 // The first entry for each config is without msaa and the second is with. | |
94 bool fConfigLinearRenderSupport[kGrPixelConfigCnt][2]; | |
95 | 95 |
96 SkTArray<StencilFormat, true> fLinearStencilFormats; | 96 void init(const GrVkInterface*, VkPhysicalDevice, VkFormat); |
97 SkTArray<StencilFormat, true> fStencilFormats; | 97 static void InitConfigFlags(VkFormatFeatureFlags, uint16_t* flags); |
| 98 |
| 99 enum { |
| 100 kTextureable_Flag = 0x1, |
| 101 kRenderable_Flag = 0x2, |
| 102 kBlitSrc_Flag = 0x4, |
| 103 kBlitDst_Flag = 0x8, |
| 104 }; |
| 105 |
| 106 uint16_t fOptimalFlags; |
| 107 uint16_t fLinearFlags; |
| 108 }; |
| 109 ConfigInfo fConfigTable[kGrPixelConfigCnt]; |
| 110 |
| 111 StencilFormat fPreferedStencilFormat; |
98 | 112 |
99 // Tells of if we can pass in straight GLSL string into vkCreateShaderModule | 113 // Tells of if we can pass in straight GLSL string into vkCreateShaderModule |
100 bool fCanUseGLSLForShaderModule; | 114 bool fCanUseGLSLForShaderModule; |
101 | 115 |
102 typedef GrCaps INHERITED; | 116 typedef GrCaps INHERITED; |
103 }; | 117 }; |
104 | 118 |
105 #endif | 119 #endif |
OLD | NEW |