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 #include "GrVkCaps.h" | 8 #include "GrVkCaps.h" |
9 | 9 |
10 #include "GrVkUtil.h" | 10 #include "GrVkUtil.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 * GrVkCaps fields | 43 * GrVkCaps fields |
44 **************************************************************************/ | 44 **************************************************************************/ |
45 fMaxSampledTextures = 16; // Spec requires a minimum of 16 sampled textures
per stage | 45 fMaxSampledTextures = 16; // Spec requires a minimum of 16 sampled textures
per stage |
46 | 46 |
47 this->init(contextOptions, vkInterface, physDev); | 47 this->init(contextOptions, vkInterface, physDev); |
48 } | 48 } |
49 | 49 |
50 void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface*
vkInterface, | 50 void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface*
vkInterface, |
51 VkPhysicalDevice physDev) { | 51 VkPhysicalDevice physDev) { |
52 | 52 |
53 this->initGLSLCaps(vkInterface, physDev); | 53 VkPhysicalDeviceProperties properties; |
| 54 GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties)); |
| 55 |
| 56 VkPhysicalDeviceFeatures features; |
| 57 GR_VK_CALL(vkInterface, GetPhysicalDeviceFeatures(physDev, &features)); |
| 58 |
| 59 VkPhysicalDeviceMemoryProperties memoryProperties; |
| 60 GR_VK_CALL(vkInterface, GetPhysicalDeviceMemoryProperties(physDev, &memoryPr
operties)); |
| 61 |
| 62 this->initGrCaps(properties, features, memoryProperties); |
| 63 this->initGLSLCaps(features); |
54 this->initConfigTexturableTable(vkInterface, physDev); | 64 this->initConfigTexturableTable(vkInterface, physDev); |
55 this->initConfigRenderableTable(vkInterface, physDev); | 65 this->initConfigRenderableTable(vkInterface, physDev); |
56 this->initStencilFormats(vkInterface, physDev); | 66 this->initStencilFormats(vkInterface, physDev); |
57 | 67 |
58 VkPhysicalDeviceProperties properties; | |
59 GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties)); | |
60 | 68 |
61 // We could actually querey and get a max size for each config, however maxI
mageDimension2D will | |
62 // give the minimum max size across all configs. So for simplicity we will u
se that for now. | |
63 fMaxRenderTargetSize = properties.limits.maxImageDimension2D; | |
64 fMaxTextureSize = properties.limits.maxImageDimension2D; | |
65 | |
66 this->initSampleCount(properties); | |
67 | |
68 fMaxSampledTextures = SkTMin(properties.limits.maxPerStageDescriptorSampledI
mages, | |
69 properties.limits.maxPerStageDescriptorSamplers
); | |
70 | 69 |
71 this->applyOptionsOverrides(contextOptions); | 70 this->applyOptionsOverrides(contextOptions); |
72 // need to friend GrVkCaps in GrGLSLCaps.h | 71 // need to friend GrVkCaps in GrGLSLCaps.h |
73 // GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); | 72 // GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); |
74 // glslCaps->applyOptionsOverrides(contextOptions); | 73 // glslCaps->applyOptionsOverrides(contextOptions); |
75 } | 74 } |
76 | 75 |
77 int get_max_sample_count(VkSampleCountFlags flags) { | 76 int get_max_sample_count(VkSampleCountFlags flags) { |
78 SkASSERT(flags & VK_SAMPLE_COUNT_1_BIT); | 77 SkASSERT(flags & VK_SAMPLE_COUNT_1_BIT); |
79 if (!(flags & VK_SAMPLE_COUNT_2_BIT)) { | 78 if (!(flags & VK_SAMPLE_COUNT_2_BIT)) { |
(...skipping 18 matching lines...) Expand all Loading... |
98 } | 97 } |
99 | 98 |
100 void GrVkCaps::initSampleCount(const VkPhysicalDeviceProperties& properties) { | 99 void GrVkCaps::initSampleCount(const VkPhysicalDeviceProperties& properties) { |
101 VkSampleCountFlags colorSamples = properties.limits.framebufferColorSampleCo
unts; | 100 VkSampleCountFlags colorSamples = properties.limits.framebufferColorSampleCo
unts; |
102 VkSampleCountFlags stencilSamples = properties.limits.framebufferStencilSamp
leCounts; | 101 VkSampleCountFlags stencilSamples = properties.limits.framebufferStencilSamp
leCounts; |
103 | 102 |
104 fMaxColorSampleCount = get_max_sample_count(colorSamples); | 103 fMaxColorSampleCount = get_max_sample_count(colorSamples); |
105 fMaxStencilSampleCount = get_max_sample_count(stencilSamples); | 104 fMaxStencilSampleCount = get_max_sample_count(stencilSamples); |
106 } | 105 } |
107 | 106 |
108 void GrVkCaps::initGLSLCaps(const GrVkInterface* interface, VkPhysicalDevice phy
sDev) { | 107 void GrVkCaps::initGrCaps(const VkPhysicalDeviceProperties& properties, |
| 108 const VkPhysicalDeviceFeatures& features, |
| 109 const VkPhysicalDeviceMemoryProperties& memoryProperit
es) { |
| 110 // We could actually query and get a max size for each config, however maxIm
ageDimension2D will |
| 111 // give the minimum max size across all configs. So for simplicity we will u
se that for now. |
| 112 fMaxRenderTargetSize = properties.limits.maxImageDimension2D; |
| 113 fMaxTextureSize = properties.limits.maxImageDimension2D; |
| 114 |
| 115 this->initSampleCount(properties); |
| 116 |
| 117 fMaxSampledTextures = SkTMin(properties.limits.maxPerStageDescriptorSampledI
mages, |
| 118 properties.limits.maxPerStageDescriptorSamplers
); |
| 119 |
| 120 // Assuming since we will always map in the end to upload the data we might
as well just map |
| 121 // from the get go. There is no hard data to suggest this is faster or slowe
r. |
| 122 fGeometryBufferMapThreshold = 0; |
| 123 |
| 124 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |
| 125 |
| 126 fStencilWrapOpsSupport = true; |
| 127 fOversizedStencilSupport = true; |
| 128 } |
| 129 |
| 130 void GrVkCaps::initGLSLCaps(const VkPhysicalDeviceFeatures& features) { |
109 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); | 131 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); |
110 // TODO: actually figure out a correct version here | 132 glslCaps->fVersionDeclString = "#version 310 es\n"; |
111 glslCaps->fVersionDeclString = "#version 140\n"; | |
112 | 133 |
113 // fConfigOutputSwizzle will default to RGBA so we only need to set it for a
lpha only config. | 134 // fConfigOutputSwizzle will default to RGBA so we only need to set it for a
lpha only config. |
114 for (int i = 0; i < kGrPixelConfigCnt; ++i) { | 135 for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
115 GrPixelConfig config = static_cast<GrPixelConfig>(i); | 136 GrPixelConfig config = static_cast<GrPixelConfig>(i); |
116 if (GrPixelConfigIsAlphaOnly(config)) { | 137 if (GrPixelConfigIsAlphaOnly(config)) { |
117 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); | 138 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); |
118 glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); | 139 glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); |
119 } else { | 140 } else { |
120 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); | 141 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); |
121 } | 142 } |
122 } | 143 } |
123 | 144 |
| 145 // Vulkan is based off ES 3.0 so the following should all be supported |
| 146 glslCaps->fUsesPrecisionModifiers = true; |
| 147 glslCaps->fFlatInterpolationSupport = true; |
| 148 |
| 149 // GrShaderCaps |
| 150 |
124 glslCaps->fShaderDerivativeSupport = true; | 151 glslCaps->fShaderDerivativeSupport = true; |
| 152 glslCaps->fGeometryShaderSupport = features.geometryShader == VK_TRUE; |
| 153 #if 0 |
| 154 // For now disabling dual source blending till we get it hooked up in the re
st of system |
| 155 glslCaps->fDualSourceBlendingSupport = features.dualSrcBlend; |
| 156 #endif |
| 157 glslCaps->fIntegerSupport = true; |
125 } | 158 } |
126 | 159 |
127 static void format_supported_for_feature(const GrVkInterface* interface, | 160 static void format_supported_for_feature(const GrVkInterface* interface, |
128 VkPhysicalDevice physDev, | 161 VkPhysicalDevice physDev, |
129 VkFormat format, | 162 VkFormat format, |
130 VkFormatFeatureFlagBits featureBit, | 163 VkFormatFeatureFlagBits featureBit, |
131 bool* linearSupport, | 164 bool* linearSupport, |
132 bool* optimalSupport) { | 165 bool* optimalSupport) { |
133 VkFormatProperties props; | 166 VkFormatProperties props; |
134 memset(&props, 0, sizeof(VkFormatProperties)); | 167 memset(&props, 0, sizeof(VkFormatProperties)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // internal Format stencil bits total bits
packed? | 270 // internal Format stencil bits total bits
packed? |
238 gS8 = { VK_FORMAT_S8_UINT, 8, 8,
false }, | 271 gS8 = { VK_FORMAT_S8_UINT, 8, 8,
false }, |
239 gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8, 32,
true }; | 272 gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8, 32,
true }; |
240 | 273 |
241 // I'm simply assuming that these two will be supported since they are used
in example code. | 274 // I'm simply assuming that these two will be supported since they are used
in example code. |
242 // TODO: Actaully figure this out | 275 // TODO: Actaully figure this out |
243 SET_CONFIG_CAN_STENCIL(gS8); | 276 SET_CONFIG_CAN_STENCIL(gS8); |
244 SET_CONFIG_CAN_STENCIL(gD24S8); | 277 SET_CONFIG_CAN_STENCIL(gD24S8); |
245 } | 278 } |
246 | 279 |
OLD | NEW |