Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrVkCaps.h" |
| 9 | |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 10 | #include "GrShaderCaps.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 11 | #include "GrVkUtil.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 12 | #include "vk/GrVkInterface.h" |
jvanverth | fd7bd45 | 2016-03-25 06:29:52 -0700 | [diff] [blame] | 13 | #include "vk/GrVkBackendContext.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 14 | |
| 15 | GrVkCaps::GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* vkInterface, |
egdaniel | c5ec140 | 2016-03-28 12:14:42 -0700 | [diff] [blame] | 16 | VkPhysicalDevice physDev, uint32_t featureFlags, uint32_t extensionFlags) |
| 17 | : INHERITED(contextOptions) { |
| 18 | fCanUseGLSLForShaderModule = false; |
egdaniel | 6fa0a91 | 2016-09-12 11:51:29 -0700 | [diff] [blame] | 19 | fMustDoCopiesFromOrigin = false; |
egdaniel | bc9b296 | 2016-09-27 08:00:53 -0700 | [diff] [blame] | 20 | fSupportsCopiesAsDraws = false; |
egdaniel | fd016d7 | 2016-09-27 12:13:05 -0700 | [diff] [blame] | 21 | fMustSubmitCommandsBeforeCopyOp = false; |
egdaniel | c5ec140 | 2016-03-28 12:14:42 -0700 | [diff] [blame] | 22 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 23 | /************************************************************************** |
| 24 | * GrDrawTargetCaps fields |
| 25 | **************************************************************************/ |
jvanverth | 6234006 | 2016-04-26 08:01:44 -0700 | [diff] [blame] | 26 | fMipMapSupport = true; // always available in Vulkan |
brianosman | f05ab1b | 2016-05-12 11:01:10 -0700 | [diff] [blame] | 27 | fSRGBSupport = true; // always available in Vulkan |
brianosman | 8879186 | 2016-05-23 10:15:27 -0700 | [diff] [blame] | 28 | fNPOTTextureTileSupport = true; // always available in Vulkan |
jvanverth | c8ef053 | 2016-05-03 10:45:48 -0700 | [diff] [blame] | 29 | fTwoSidedStencilSupport = true; // always available in Vulkan |
egdaniel | 50134cc | 2016-05-23 12:34:38 -0700 | [diff] [blame] | 30 | fStencilWrapOpsSupport = true; // always available in Vulkan |
egdaniel | 37535c9 | 2016-06-30 08:23:30 -0700 | [diff] [blame] | 31 | fDiscardRenderTargetSupport = true; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 32 | fReuseScratchTextures = true; //TODO: figure this out |
| 33 | fGpuTracingSupport = false; //TODO: figure this out |
| 34 | fCompressedTexSubImageSupport = false; //TODO: figure this out |
| 35 | fOversizedStencilSupport = false; //TODO: figure this out |
| 36 | |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 37 | fUseDrawInsteadOfClear = false; |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 38 | fFenceSyncSupport = true; // always available in Vulkan |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 39 | |
| 40 | fMapBufferFlags = kNone_MapFlags; //TODO: figure this out |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 41 | fBufferMapThreshold = SK_MaxS32; //TODO: figure this out |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 42 | |
| 43 | fMaxRenderTargetSize = 4096; // minimum required by spec |
| 44 | fMaxTextureSize = 4096; // minimum required by spec |
| 45 | fMaxColorSampleCount = 4; // minimum required by spec |
| 46 | fMaxStencilSampleCount = 4; // minimum required by spec |
| 47 | |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 48 | fShaderCaps.reset(new GrShaderCaps(contextOptions)); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 49 | |
egdaniel | c5ec140 | 2016-03-28 12:14:42 -0700 | [diff] [blame] | 50 | this->init(contextOptions, vkInterface, physDev, featureFlags, extensionFlags); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface* vkInterface, |
egdaniel | c5ec140 | 2016-03-28 12:14:42 -0700 | [diff] [blame] | 54 | VkPhysicalDevice physDev, uint32_t featureFlags, uint32_t extensionFlags) { |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 55 | |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 56 | VkPhysicalDeviceProperties properties; |
| 57 | GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties)); |
| 58 | |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 59 | VkPhysicalDeviceMemoryProperties memoryProperties; |
| 60 | GR_VK_CALL(vkInterface, GetPhysicalDeviceMemoryProperties(physDev, &memoryProperties)); |
| 61 | |
jvanverth | fd7bd45 | 2016-03-25 06:29:52 -0700 | [diff] [blame] | 62 | this->initGrCaps(properties, memoryProperties, featureFlags); |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 63 | this->initShaderCaps(properties, featureFlags); |
egdaniel | 8f1dcaa | 2016-04-01 10:10:45 -0700 | [diff] [blame] | 64 | this->initConfigTable(vkInterface, physDev); |
| 65 | this->initStencilFormat(vkInterface, physDev); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 66 | |
egdaniel | c5ec140 | 2016-03-28 12:14:42 -0700 | [diff] [blame] | 67 | if (SkToBool(extensionFlags & kNV_glsl_shader_GrVkExtensionFlag)) { |
egdaniel | d632bb4 | 2016-03-30 12:06:48 -0700 | [diff] [blame] | 68 | // Currently disabling this feature since it does not play well with validation layers which |
| 69 | // expect a SPIR-V shader |
| 70 | // fCanUseGLSLForShaderModule = true; |
egdaniel | c5ec140 | 2016-03-28 12:14:42 -0700 | [diff] [blame] | 71 | } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 72 | |
egdaniel | 6fa0a91 | 2016-09-12 11:51:29 -0700 | [diff] [blame] | 73 | if (kQualcomm_VkVendor == properties.vendorID) { |
| 74 | fMustDoCopiesFromOrigin = true; |
| 75 | } |
| 76 | |
egdaniel | fd016d7 | 2016-09-27 12:13:05 -0700 | [diff] [blame] | 77 | if (kNvidia_VkVendor == properties.vendorID) { |
| 78 | fSupportsCopiesAsDraws = true; |
| 79 | fMustSubmitCommandsBeforeCopyOp = true; |
| 80 | } |
| 81 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 82 | this->applyOptionsOverrides(contextOptions); |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 83 | fShaderCaps->applyOptionsOverrides(contextOptions); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | int get_max_sample_count(VkSampleCountFlags flags) { |
| 87 | SkASSERT(flags & VK_SAMPLE_COUNT_1_BIT); |
| 88 | if (!(flags & VK_SAMPLE_COUNT_2_BIT)) { |
| 89 | return 0; |
| 90 | } |
| 91 | if (!(flags & VK_SAMPLE_COUNT_4_BIT)) { |
| 92 | return 2; |
| 93 | } |
| 94 | if (!(flags & VK_SAMPLE_COUNT_8_BIT)) { |
| 95 | return 4; |
| 96 | } |
| 97 | if (!(flags & VK_SAMPLE_COUNT_16_BIT)) { |
| 98 | return 8; |
| 99 | } |
| 100 | if (!(flags & VK_SAMPLE_COUNT_32_BIT)) { |
| 101 | return 16; |
| 102 | } |
| 103 | if (!(flags & VK_SAMPLE_COUNT_64_BIT)) { |
| 104 | return 32; |
| 105 | } |
| 106 | return 64; |
| 107 | } |
| 108 | |
| 109 | void GrVkCaps::initSampleCount(const VkPhysicalDeviceProperties& properties) { |
| 110 | VkSampleCountFlags colorSamples = properties.limits.framebufferColorSampleCounts; |
| 111 | VkSampleCountFlags stencilSamples = properties.limits.framebufferStencilSampleCounts; |
| 112 | |
| 113 | fMaxColorSampleCount = get_max_sample_count(colorSamples); |
| 114 | fMaxStencilSampleCount = get_max_sample_count(stencilSamples); |
| 115 | } |
| 116 | |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 117 | void GrVkCaps::initGrCaps(const VkPhysicalDeviceProperties& properties, |
jvanverth | fd7bd45 | 2016-03-25 06:29:52 -0700 | [diff] [blame] | 118 | const VkPhysicalDeviceMemoryProperties& memoryProperties, |
| 119 | uint32_t featureFlags) { |
jvanverth | e78d487 | 2016-09-27 03:33:05 -0700 | [diff] [blame] | 120 | fMaxVertexAttributes = SkTMin(properties.limits.maxVertexInputAttributes, (uint32_t)INT_MAX); |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 121 | // We could actually query and get a max size for each config, however maxImageDimension2D will |
| 122 | // give the minimum max size across all configs. So for simplicity we will use that for now. |
jvanverth | e78d487 | 2016-09-27 03:33:05 -0700 | [diff] [blame] | 123 | fMaxRenderTargetSize = SkTMin(properties.limits.maxImageDimension2D, (uint32_t)INT_MAX); |
| 124 | fMaxTextureSize = SkTMin(properties.limits.maxImageDimension2D, (uint32_t)INT_MAX); |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 125 | |
| 126 | this->initSampleCount(properties); |
| 127 | |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 128 | // Assuming since we will always map in the end to upload the data we might as well just map |
| 129 | // from the get go. There is no hard data to suggest this is faster or slower. |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 130 | fBufferMapThreshold = 0; |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 131 | |
| 132 | fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |
| 133 | |
| 134 | fStencilWrapOpsSupport = true; |
| 135 | fOversizedStencilSupport = true; |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 136 | fSampleShadingSupport = SkToBool(featureFlags & kSampleRateShading_GrVkFeatureFlag); |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 137 | } |
| 138 | |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 139 | void GrVkCaps::initShaderCaps(const VkPhysicalDeviceProperties& properties, uint32_t featureFlags) { |
| 140 | GrShaderCaps* shaderCaps = fShaderCaps.get(); |
| 141 | shaderCaps->fVersionDeclString = "#version 330\n"; |
egdaniel | 3a15fd4 | 2016-04-05 11:00:29 -0700 | [diff] [blame] | 142 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 143 | |
| 144 | // fConfigOutputSwizzle will default to RGBA so we only need to set it for alpha only config. |
| 145 | for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
| 146 | GrPixelConfig config = static_cast<GrPixelConfig>(i); |
| 147 | if (GrPixelConfigIsAlphaOnly(config)) { |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 148 | shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); |
| 149 | shaderCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 150 | } else { |
egdaniel | 3fe0327 | 2016-08-15 10:59:17 -0700 | [diff] [blame] | 151 | if (kRGBA_4444_GrPixelConfig == config) { |
| 152 | // The vulkan spec does not require R4G4B4A4 to be supported for texturing so we |
| 153 | // store the data in a B4G4R4A4 texture and then swizzle it when doing texture reads |
| 154 | // or writing to outputs. Since we're not actually changing the data at all, the |
| 155 | // only extra work is the swizzle in the shader for all operations. |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 156 | shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::BGRA(); |
| 157 | shaderCaps->fConfigOutputSwizzle[i] = GrSwizzle::BGRA(); |
egdaniel | 3fe0327 | 2016-08-15 10:59:17 -0700 | [diff] [blame] | 158 | } else { |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 159 | shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); |
egdaniel | 3fe0327 | 2016-08-15 10:59:17 -0700 | [diff] [blame] | 160 | } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 161 | } |
| 162 | } |
egdaniel | 67acb83 | 2016-02-26 08:32:20 -0800 | [diff] [blame] | 163 | |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 164 | // Vulkan is based off ES 3.0 so the following should all be supported |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 165 | shaderCaps->fUsesPrecisionModifiers = true; |
| 166 | shaderCaps->fFlatInterpolationSupport = true; |
egdaniel | d5e3b9e | 2016-03-08 12:19:54 -0800 | [diff] [blame] | 167 | |
| 168 | // GrShaderCaps |
| 169 | |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 170 | shaderCaps->fShaderDerivativeSupport = true; |
| 171 | shaderCaps->fGeometryShaderSupport = SkToBool(featureFlags & kGeometryShader_GrVkFeatureFlag); |
egdaniel | d632bb4 | 2016-03-30 12:06:48 -0700 | [diff] [blame] | 172 | |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 173 | shaderCaps->fDualSourceBlendingSupport = SkToBool(featureFlags & kDualSrcBlend_GrVkFeatureFlag); |
egdaniel | d632bb4 | 2016-03-30 12:06:48 -0700 | [diff] [blame] | 174 | |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 175 | shaderCaps->fIntegerSupport = true; |
cdalton | 9c3f143 | 2016-03-11 10:07:37 -0800 | [diff] [blame] | 176 | |
cdalton | a6b92ad | 2016-04-11 12:03:08 -0700 | [diff] [blame] | 177 | // Assume the minimum precisions mandated by the SPIR-V spec. |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 178 | shaderCaps->fShaderPrecisionVaries = true; |
cdalton | a6b92ad | 2016-04-11 12:03:08 -0700 | [diff] [blame] | 179 | for (int s = 0; s < kGrShaderTypeCount; ++s) { |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 180 | auto& highp = shaderCaps->fFloatPrecisions[s][kHigh_GrSLPrecision]; |
cdalton | a6b92ad | 2016-04-11 12:03:08 -0700 | [diff] [blame] | 181 | highp.fLogRangeLow = highp.fLogRangeHigh = 127; |
| 182 | highp.fBits = 23; |
| 183 | |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 184 | auto& mediump = shaderCaps->fFloatPrecisions[s][kMedium_GrSLPrecision]; |
cdalton | a6b92ad | 2016-04-11 12:03:08 -0700 | [diff] [blame] | 185 | mediump.fLogRangeLow = mediump.fLogRangeHigh = 14; |
| 186 | mediump.fBits = 10; |
| 187 | |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 188 | shaderCaps->fFloatPrecisions[s][kLow_GrSLPrecision] = mediump; |
cdalton | a6b92ad | 2016-04-11 12:03:08 -0700 | [diff] [blame] | 189 | } |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 190 | shaderCaps->initSamplerPrecisionTable(); |
cdalton | a6b92ad | 2016-04-11 12:03:08 -0700 | [diff] [blame] | 191 | |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame^] | 192 | shaderCaps->fMaxVertexSamplers = |
| 193 | shaderCaps->fMaxGeometrySamplers = |
| 194 | shaderCaps->fMaxFragmentSamplers = SkTMin( |
| 195 | SkTMin(properties.limits.maxPerStageDescriptorSampledImages, |
| 196 | properties.limits.maxPerStageDescriptorSamplers), |
| 197 | (uint32_t)INT_MAX); |
| 198 | shaderCaps->fMaxCombinedSamplers = SkTMin( |
| 199 | SkTMin(properties.limits.maxDescriptorSetSampledImages, |
| 200 | properties.limits.maxDescriptorSetSamplers), |
| 201 | (uint32_t)INT_MAX); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 202 | } |
| 203 | |
egdaniel | 8f1dcaa | 2016-04-01 10:10:45 -0700 | [diff] [blame] | 204 | bool stencil_format_supported(const GrVkInterface* interface, |
| 205 | VkPhysicalDevice physDev, |
| 206 | VkFormat format) { |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 207 | VkFormatProperties props; |
| 208 | memset(&props, 0, sizeof(VkFormatProperties)); |
| 209 | GR_VK_CALL(interface, GetPhysicalDeviceFormatProperties(physDev, format, &props)); |
egdaniel | 8f1dcaa | 2016-04-01 10:10:45 -0700 | [diff] [blame] | 210 | return SkToBool(VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT & props.optimalTilingFeatures); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 211 | } |
| 212 | |
egdaniel | 8f1dcaa | 2016-04-01 10:10:45 -0700 | [diff] [blame] | 213 | void GrVkCaps::initStencilFormat(const GrVkInterface* interface, VkPhysicalDevice physDev) { |
| 214 | // List of legal stencil formats (though perhaps not supported on |
| 215 | // the particular gpu/driver) from most preferred to least. We are guaranteed to have either |
jvanverth | a4b0fed | 2016-04-27 11:42:21 -0700 | [diff] [blame] | 216 | // VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT. VK_FORMAT_D32_SFLOAT_S8_UINT |
egdaniel | 8f1dcaa | 2016-04-01 10:10:45 -0700 | [diff] [blame] | 217 | // can optionally have 24 unused bits at the end so we assume the total bits is 64. |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 218 | static const StencilFormat |
| 219 | // internal Format stencil bits total bits packed? |
| 220 | gS8 = { VK_FORMAT_S8_UINT, 8, 8, false }, |
egdaniel | 8f1dcaa | 2016-04-01 10:10:45 -0700 | [diff] [blame] | 221 | gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8, 32, true }, |
| 222 | gD32S8 = { VK_FORMAT_D32_SFLOAT_S8_UINT, 8, 64, true }; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 223 | |
egdaniel | 8f1dcaa | 2016-04-01 10:10:45 -0700 | [diff] [blame] | 224 | if (stencil_format_supported(interface, physDev, VK_FORMAT_S8_UINT)) { |
| 225 | fPreferedStencilFormat = gS8; |
| 226 | } else if (stencil_format_supported(interface, physDev, VK_FORMAT_D24_UNORM_S8_UINT)) { |
| 227 | fPreferedStencilFormat = gD24S8; |
| 228 | } else { |
| 229 | SkASSERT(stencil_format_supported(interface, physDev, VK_FORMAT_D32_SFLOAT_S8_UINT)); |
| 230 | fPreferedStencilFormat = gD32S8; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | void GrVkCaps::initConfigTable(const GrVkInterface* interface, VkPhysicalDevice physDev) { |
| 235 | for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
| 236 | VkFormat format; |
| 237 | if (GrPixelConfigToVkFormat(static_cast<GrPixelConfig>(i), &format)) { |
| 238 | fConfigTable[i].init(interface, physDev, format); |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | void GrVkCaps::ConfigInfo::InitConfigFlags(VkFormatFeatureFlags vkFlags, uint16_t* flags) { |
| 244 | if (SkToBool(VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT & vkFlags) && |
| 245 | SkToBool(VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT & vkFlags)) { |
| 246 | *flags = *flags | kTextureable_Flag; |
| 247 | } |
| 248 | |
| 249 | if (SkToBool(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT & vkFlags)) { |
| 250 | *flags = *flags | kRenderable_Flag; |
| 251 | } |
| 252 | |
| 253 | if (SkToBool(VK_FORMAT_FEATURE_BLIT_SRC_BIT & vkFlags)) { |
| 254 | *flags = *flags | kBlitSrc_Flag; |
| 255 | } |
| 256 | |
| 257 | if (SkToBool(VK_FORMAT_FEATURE_BLIT_DST_BIT & vkFlags)) { |
| 258 | *flags = *flags | kBlitDst_Flag; |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | void GrVkCaps::ConfigInfo::init(const GrVkInterface* interface, |
| 263 | VkPhysicalDevice physDev, |
| 264 | VkFormat format) { |
| 265 | VkFormatProperties props; |
| 266 | memset(&props, 0, sizeof(VkFormatProperties)); |
| 267 | GR_VK_CALL(interface, GetPhysicalDeviceFormatProperties(physDev, format, &props)); |
| 268 | InitConfigFlags(props.linearTilingFeatures, &fLinearFlags); |
| 269 | InitConfigFlags(props.optimalTilingFeatures, &fOptimalFlags); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 270 | } |