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 21 matching lines...) Expand all Loading... |
32 fGeometryBufferMapThreshold = SK_MaxS32; //TODO: figure this out | 32 fGeometryBufferMapThreshold = SK_MaxS32; //TODO: figure this out |
33 | 33 |
34 fMaxRenderTargetSize = 4096; // minimum required by spec | 34 fMaxRenderTargetSize = 4096; // minimum required by spec |
35 fMaxTextureSize = 4096; // minimum required by spec | 35 fMaxTextureSize = 4096; // minimum required by spec |
36 fMaxColorSampleCount = 4; // minimum required by spec | 36 fMaxColorSampleCount = 4; // minimum required by spec |
37 fMaxStencilSampleCount = 4; // minimum required by spec | 37 fMaxStencilSampleCount = 4; // minimum required by spec |
38 | 38 |
39 | 39 |
40 fShaderCaps.reset(new GrGLSLCaps(contextOptions)); | 40 fShaderCaps.reset(new GrGLSLCaps(contextOptions)); |
41 | 41 |
42 /************************************************************************** | |
43 * GrVkCaps fields | |
44 **************************************************************************/ | |
45 fMaxSampledTextures = 16; // Spec requires a minimum of 16 sampled textures
per stage | |
46 | |
47 this->init(contextOptions, vkInterface, physDev); | 42 this->init(contextOptions, vkInterface, physDev); |
48 } | 43 } |
49 | 44 |
50 void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface*
vkInterface, | 45 void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface*
vkInterface, |
51 VkPhysicalDevice physDev) { | 46 VkPhysicalDevice physDev) { |
52 | 47 |
53 VkPhysicalDeviceProperties properties; | 48 VkPhysicalDeviceProperties properties; |
54 GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties)); | 49 GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties)); |
55 | 50 |
56 VkPhysicalDeviceFeatures features; | 51 VkPhysicalDeviceFeatures features; |
57 GR_VK_CALL(vkInterface, GetPhysicalDeviceFeatures(physDev, &features)); | 52 GR_VK_CALL(vkInterface, GetPhysicalDeviceFeatures(physDev, &features)); |
58 | 53 |
59 VkPhysicalDeviceMemoryProperties memoryProperties; | 54 VkPhysicalDeviceMemoryProperties memoryProperties; |
60 GR_VK_CALL(vkInterface, GetPhysicalDeviceMemoryProperties(physDev, &memoryPr
operties)); | 55 GR_VK_CALL(vkInterface, GetPhysicalDeviceMemoryProperties(physDev, &memoryPr
operties)); |
61 | 56 |
62 this->initGrCaps(properties, features, memoryProperties); | 57 this->initGrCaps(properties, features, memoryProperties); |
63 this->initGLSLCaps(features); | 58 this->initGLSLCaps(features, properties); |
64 this->initConfigTexturableTable(vkInterface, physDev); | 59 this->initConfigTexturableTable(vkInterface, physDev); |
65 this->initConfigRenderableTable(vkInterface, physDev); | 60 this->initConfigRenderableTable(vkInterface, physDev); |
66 this->initStencilFormats(vkInterface, physDev); | 61 this->initStencilFormats(vkInterface, physDev); |
67 | 62 |
68 | 63 |
69 | 64 |
70 this->applyOptionsOverrides(contextOptions); | 65 this->applyOptionsOverrides(contextOptions); |
71 // need to friend GrVkCaps in GrGLSLCaps.h | 66 // need to friend GrVkCaps in GrGLSLCaps.h |
72 // GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); | 67 // GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); |
73 // glslCaps->applyOptionsOverrides(contextOptions); | 68 // glslCaps->applyOptionsOverrides(contextOptions); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 void GrVkCaps::initGrCaps(const VkPhysicalDeviceProperties& properties, | 102 void GrVkCaps::initGrCaps(const VkPhysicalDeviceProperties& properties, |
108 const VkPhysicalDeviceFeatures& features, | 103 const VkPhysicalDeviceFeatures& features, |
109 const VkPhysicalDeviceMemoryProperties& memoryProperit
es) { | 104 const VkPhysicalDeviceMemoryProperties& memoryProperit
es) { |
110 // We could actually query and get a max size for each config, however maxIm
ageDimension2D will | 105 // 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. | 106 // give the minimum max size across all configs. So for simplicity we will u
se that for now. |
112 fMaxRenderTargetSize = properties.limits.maxImageDimension2D; | 107 fMaxRenderTargetSize = properties.limits.maxImageDimension2D; |
113 fMaxTextureSize = properties.limits.maxImageDimension2D; | 108 fMaxTextureSize = properties.limits.maxImageDimension2D; |
114 | 109 |
115 this->initSampleCount(properties); | 110 this->initSampleCount(properties); |
116 | 111 |
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 | 112 // 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. | 113 // from the get go. There is no hard data to suggest this is faster or slowe
r. |
122 fGeometryBufferMapThreshold = 0; | 114 fGeometryBufferMapThreshold = 0; |
123 | 115 |
124 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; | 116 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |
125 | 117 |
126 fStencilWrapOpsSupport = true; | 118 fStencilWrapOpsSupport = true; |
127 fOversizedStencilSupport = true; | 119 fOversizedStencilSupport = true; |
128 } | 120 } |
129 | 121 |
130 void GrVkCaps::initGLSLCaps(const VkPhysicalDeviceFeatures& features) { | 122 void GrVkCaps::initGLSLCaps(const VkPhysicalDeviceFeatures& features, |
| 123 const VkPhysicalDeviceProperties& properties) { |
131 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); | 124 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); |
132 glslCaps->fVersionDeclString = "#version 310 es\n"; | 125 glslCaps->fVersionDeclString = "#version 310 es\n"; |
133 | 126 |
134 // fConfigOutputSwizzle will default to RGBA so we only need to set it for a
lpha only config. | 127 // fConfigOutputSwizzle will default to RGBA so we only need to set it for a
lpha only config. |
135 for (int i = 0; i < kGrPixelConfigCnt; ++i) { | 128 for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
136 GrPixelConfig config = static_cast<GrPixelConfig>(i); | 129 GrPixelConfig config = static_cast<GrPixelConfig>(i); |
137 if (GrPixelConfigIsAlphaOnly(config)) { | 130 if (GrPixelConfigIsAlphaOnly(config)) { |
138 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); | 131 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); |
139 glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); | 132 glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); |
140 } else { | 133 } else { |
141 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); | 134 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); |
142 } | 135 } |
143 } | 136 } |
144 | 137 |
145 // Vulkan is based off ES 3.0 so the following should all be supported | 138 // Vulkan is based off ES 3.0 so the following should all be supported |
146 glslCaps->fUsesPrecisionModifiers = true; | 139 glslCaps->fUsesPrecisionModifiers = true; |
147 glslCaps->fFlatInterpolationSupport = true; | 140 glslCaps->fFlatInterpolationSupport = true; |
148 | 141 |
149 // GrShaderCaps | 142 // GrShaderCaps |
150 | 143 |
151 glslCaps->fShaderDerivativeSupport = true; | 144 glslCaps->fShaderDerivativeSupport = true; |
152 glslCaps->fGeometryShaderSupport = features.geometryShader == VK_TRUE; | 145 glslCaps->fGeometryShaderSupport = features.geometryShader == VK_TRUE; |
153 #if 0 | 146 #if 0 |
154 // For now disabling dual source blending till we get it hooked up in the re
st of system | 147 // For now disabling dual source blending till we get it hooked up in the re
st of system |
155 glslCaps->fDualSourceBlendingSupport = features.dualSrcBlend; | 148 glslCaps->fDualSourceBlendingSupport = features.dualSrcBlend; |
156 #endif | 149 #endif |
157 glslCaps->fIntegerSupport = true; | 150 glslCaps->fIntegerSupport = true; |
| 151 |
| 152 glslCaps->fMaxVertexSamplers = |
| 153 glslCaps->fMaxGeometrySamplers = |
| 154 glslCaps->fMaxFragmentSamplers = SkTMin(properties.limits.maxPerStageDescrip
torSampledImages, |
| 155 properties.limits.maxPerStageDescrip
torSamplers); |
| 156 glslCaps->fMaxCombinedSamplers = SkTMin(properties.limits.maxDescriptorSetSa
mpledImages, |
| 157 properties.limits.maxDescriptorSetSa
mplers); |
158 } | 158 } |
159 | 159 |
160 static void format_supported_for_feature(const GrVkInterface* interface, | 160 static void format_supported_for_feature(const GrVkInterface* interface, |
161 VkPhysicalDevice physDev, | 161 VkPhysicalDevice physDev, |
162 VkFormat format, | 162 VkFormat format, |
163 VkFormatFeatureFlagBits featureBit, | 163 VkFormatFeatureFlagBits featureBit, |
164 bool* linearSupport, | 164 bool* linearSupport, |
165 bool* optimalSupport) { | 165 bool* optimalSupport) { |
166 VkFormatProperties props; | 166 VkFormatProperties props; |
167 memset(&props, 0, sizeof(VkFormatProperties)); | 167 memset(&props, 0, sizeof(VkFormatProperties)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // internal Format stencil bits total bits
packed? | 270 // internal Format stencil bits total bits
packed? |
271 gS8 = { VK_FORMAT_S8_UINT, 8, 8,
false }, | 271 gS8 = { VK_FORMAT_S8_UINT, 8, 8,
false }, |
272 gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8, 32,
true }; | 272 gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8, 32,
true }; |
273 | 273 |
274 // 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. |
275 // TODO: Actaully figure this out | 275 // TODO: Actaully figure this out |
276 SET_CONFIG_CAN_STENCIL(gS8); | 276 SET_CONFIG_CAN_STENCIL(gS8); |
277 SET_CONFIG_CAN_STENCIL(gD24S8); | 277 SET_CONFIG_CAN_STENCIL(gD24S8); |
278 } | 278 } |
279 | 279 |
OLD | NEW |