| Index: src/gpu/vk/GrVkCaps.cpp
|
| diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
|
| index 88ff8ee3e060858256684533bc9766a974467e1e..680a3b2e8aa6fd44be0ac2d1e529073f301fff22 100644
|
| --- a/src/gpu/vk/GrVkCaps.cpp
|
| +++ b/src/gpu/vk/GrVkCaps.cpp
|
| @@ -57,9 +57,8 @@ void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface*
|
|
|
| this->initGrCaps(properties, memoryProperties, featureFlags);
|
| this->initGLSLCaps(properties, featureFlags);
|
| - this->initConfigTexturableTable(vkInterface, physDev);
|
| - this->initConfigRenderableTable(vkInterface, physDev);
|
| - this->initStencilFormats(vkInterface, physDev);
|
| + this->initConfigTable(vkInterface, physDev);
|
| + this->initStencilFormat(vkInterface, physDev);
|
|
|
| if (SkToBool(extensionFlags & kNV_glsl_shader_GrVkExtensionFlag)) {
|
| // Currently disabling this feature since it does not play well with validation layers which
|
| @@ -162,122 +161,70 @@ void GrVkCaps::initGLSLCaps(const VkPhysicalDeviceProperties& properties,
|
| properties.limits.maxDescriptorSetSamplers);
|
| }
|
|
|
| -static void format_supported_for_feature(const GrVkInterface* interface,
|
| - VkPhysicalDevice physDev,
|
| - VkFormat format,
|
| - VkFormatFeatureFlagBits featureBit,
|
| - bool* linearSupport,
|
| - bool* optimalSupport) {
|
| - VkFormatProperties props;
|
| +bool stencil_format_supported(const GrVkInterface* interface,
|
| + VkPhysicalDevice physDev,
|
| + VkFormat format) {
|
| + VkFormatProperties props;
|
| memset(&props, 0, sizeof(VkFormatProperties));
|
| GR_VK_CALL(interface, GetPhysicalDeviceFormatProperties(physDev, format, &props));
|
| - *linearSupport = SkToBool(props.linearTilingFeatures & featureBit);
|
| - *optimalSupport = SkToBool(props.optimalTilingFeatures & featureBit);
|
| + return SkToBool(VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT & props.optimalTilingFeatures);
|
| }
|
|
|
| -static void config_supported_for_feature(const GrVkInterface* interface,
|
| - VkPhysicalDevice physDev,
|
| - GrPixelConfig config,
|
| - VkFormatFeatureFlagBits featureBit,
|
| - bool* linearSupport,
|
| - bool* optimalSupport) {
|
| - VkFormat format;
|
| - if (!GrPixelConfigToVkFormat(config, &format)) {
|
| - *linearSupport = false;
|
| - *optimalSupport = false;
|
| - return;
|
| +void GrVkCaps::initStencilFormat(const GrVkInterface* interface, VkPhysicalDevice physDev) {
|
| + // List of legal stencil formats (though perhaps not supported on
|
| + // the particular gpu/driver) from most preferred to least. We are guaranteed to have either
|
| + // VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D24_SFLOAT_S8_UINT. VK_FORMAT_D32_SFLOAT_S8_UINT
|
| + // can optionally have 24 unused bits at the end so we assume the total bits is 64.
|
| + static const StencilFormat
|
| + // internal Format stencil bits total bits packed?
|
| + gS8 = { VK_FORMAT_S8_UINT, 8, 8, false },
|
| + gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8, 32, true },
|
| + gD32S8 = { VK_FORMAT_D32_SFLOAT_S8_UINT, 8, 64, true };
|
| +
|
| + if (stencil_format_supported(interface, physDev, VK_FORMAT_S8_UINT)) {
|
| + fPreferedStencilFormat = gS8;
|
| + } else if (stencil_format_supported(interface, physDev, VK_FORMAT_D24_UNORM_S8_UINT)) {
|
| + fPreferedStencilFormat = gD24S8;
|
| + } else {
|
| + SkASSERT(stencil_format_supported(interface, physDev, VK_FORMAT_D32_SFLOAT_S8_UINT));
|
| + fPreferedStencilFormat = gD32S8;
|
| }
|
| - format_supported_for_feature(interface, physDev, format, featureBit,
|
| - linearSupport, optimalSupport);
|
| }
|
|
|
| -// Currently just assumeing if something can be rendered to without MSAA it also works for MSAAA
|
| -#define SET_CONFIG_IS_RENDERABLE(config) \
|
| - config_supported_for_feature(interface, \
|
| - physDev, \
|
| - config, \
|
| - VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT, \
|
| - &fConfigLinearRenderSupport[config][kNo_MSAA], \
|
| - &fConfigRenderSupport[config][kNo_MSAA] ); \
|
| - fConfigRenderSupport[config][kYes_MSAA] = fConfigRenderSupport[config][kNo_MSAA]; \
|
| - fConfigLinearRenderSupport[config][kYes_MSAA] = fConfigLinearRenderSupport[config][kNo_MSAA];
|
| -
|
| -
|
| -void GrVkCaps::initConfigRenderableTable(const GrVkInterface* interface, VkPhysicalDevice physDev) {
|
| - enum {
|
| - kNo_MSAA = 0,
|
| - kYes_MSAA = 1,
|
| - };
|
| -
|
| - // Base render support
|
| - SET_CONFIG_IS_RENDERABLE(kAlpha_8_GrPixelConfig);
|
| - SET_CONFIG_IS_RENDERABLE(kRGB_565_GrPixelConfig);
|
| - SET_CONFIG_IS_RENDERABLE(kRGBA_4444_GrPixelConfig);
|
| - SET_CONFIG_IS_RENDERABLE(kRGBA_8888_GrPixelConfig);
|
| - SET_CONFIG_IS_RENDERABLE(kBGRA_8888_GrPixelConfig);
|
| -
|
| - SET_CONFIG_IS_RENDERABLE(kSRGBA_8888_GrPixelConfig);
|
| -
|
| - // Float render support
|
| - SET_CONFIG_IS_RENDERABLE(kRGBA_float_GrPixelConfig);
|
| - SET_CONFIG_IS_RENDERABLE(kRGBA_half_GrPixelConfig);
|
| - SET_CONFIG_IS_RENDERABLE(kAlpha_half_GrPixelConfig);
|
| +void GrVkCaps::initConfigTable(const GrVkInterface* interface, VkPhysicalDevice physDev) {
|
| + for (int i = 0; i < kGrPixelConfigCnt; ++i) {
|
| + VkFormat format;
|
| + if (GrPixelConfigToVkFormat(static_cast<GrPixelConfig>(i), &format)) {
|
| + fConfigTable[i].init(interface, physDev, format);
|
| + }
|
| + }
|
| }
|
|
|
| -#define SET_CONFIG_IS_TEXTURABLE(config) \
|
| - config_supported_for_feature(interface, \
|
| - physDev, \
|
| - config, \
|
| - VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT, \
|
| - &fConfigLinearTextureSupport[config], \
|
| - &fConfigTextureSupport[config]);
|
| -
|
| -void GrVkCaps::initConfigTexturableTable(const GrVkInterface* interface, VkPhysicalDevice physDev) {
|
| - // Base texture support
|
| - SET_CONFIG_IS_TEXTURABLE(kAlpha_8_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kRGB_565_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kRGBA_4444_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kRGBA_8888_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kBGRA_8888_GrPixelConfig);
|
| -
|
| - SET_CONFIG_IS_TEXTURABLE(kIndex_8_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kSRGBA_8888_GrPixelConfig);
|
| -
|
| - // Compressed texture support
|
| - SET_CONFIG_IS_TEXTURABLE(kETC1_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kLATC_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kR11_EAC_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kASTC_12x12_GrPixelConfig);
|
| -
|
| - // Float texture support
|
| - SET_CONFIG_IS_TEXTURABLE(kRGBA_float_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kRGBA_half_GrPixelConfig);
|
| - SET_CONFIG_IS_TEXTURABLE(kAlpha_half_GrPixelConfig);
|
| -}
|
| +void GrVkCaps::ConfigInfo::InitConfigFlags(VkFormatFeatureFlags vkFlags, uint16_t* flags) {
|
| + if (SkToBool(VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT & vkFlags) &&
|
| + SkToBool(VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT & vkFlags)) {
|
| + *flags = *flags | kTextureable_Flag;
|
| + }
|
|
|
| -#define SET_CONFIG_CAN_STENCIL(config) \
|
| - bool SK_MACRO_APPEND_LINE(linearSupported); \
|
| - bool SK_MACRO_APPEND_LINE(optimalSupported); \
|
| - format_supported_for_feature(interface, \
|
| - physDev, \
|
| - config.fInternalFormat, \
|
| - VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, \
|
| - &SK_MACRO_APPEND_LINE(linearSupported), \
|
| - &SK_MACRO_APPEND_LINE(optimalSupported)); \
|
| - if (SK_MACRO_APPEND_LINE(linearSupported)) fLinearStencilFormats.push_back(config); \
|
| - if (SK_MACRO_APPEND_LINE(optimalSupported)) fStencilFormats.push_back(config);
|
| -
|
| -void GrVkCaps::initStencilFormats(const GrVkInterface* interface, VkPhysicalDevice physDev) {
|
| - // Build up list of legal stencil formats (though perhaps not supported on
|
| - // the particular gpu/driver) from most preferred to least.
|
| + if (SkToBool(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT & vkFlags)) {
|
| + *flags = *flags | kRenderable_Flag;
|
| + }
|
|
|
| - static const StencilFormat
|
| - // internal Format stencil bits total bits packed?
|
| - gS8 = { VK_FORMAT_S8_UINT, 8, 8, false },
|
| - gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8, 32, true };
|
| + if (SkToBool(VK_FORMAT_FEATURE_BLIT_SRC_BIT & vkFlags)) {
|
| + *flags = *flags | kBlitSrc_Flag;
|
| + }
|
| +
|
| + if (SkToBool(VK_FORMAT_FEATURE_BLIT_DST_BIT & vkFlags)) {
|
| + *flags = *flags | kBlitDst_Flag;
|
| + }
|
| +}
|
|
|
| - // I'm simply assuming that these two will be supported since they are used in example code.
|
| - // TODO: Actaully figure this out
|
| - SET_CONFIG_CAN_STENCIL(gS8);
|
| - SET_CONFIG_CAN_STENCIL(gD24S8);
|
| +void GrVkCaps::ConfigInfo::init(const GrVkInterface* interface,
|
| + VkPhysicalDevice physDev,
|
| + VkFormat format) {
|
| + VkFormatProperties props;
|
| + memset(&props, 0, sizeof(VkFormatProperties));
|
| + GR_VK_CALL(interface, GetPhysicalDeviceFormatProperties(physDev, format, &props));
|
| + InitConfigFlags(props.linearTilingFeatures, &fLinearFlags);
|
| + InitConfigFlags(props.optimalTilingFeatures, &fOptimalFlags);
|
| }
|
|
|