#define LIMIT(_X_) DE_OFFSET_OF(VkPhysicalDeviceLimits, _X_), (const char*)(#_X_)
#define FEATURE(_X_) DE_OFFSET_OF(VkPhysicalDeviceFeatures, _X_)
+inline bool isExtensionSupported (const vector<string>& extensionStrings, const string& extensionName)
+{
+ return de::contains(extensionStrings.begin(), extensionStrings.end(), extensionName);
+}
+
bool validateFeatureLimits(VkPhysicalDeviceProperties* properties, VkPhysicalDeviceFeatures* features, TestLog& log)
{
bool limitsOk = true;
for (vector<string>::const_iterator extIter = extensions.begin(); extIter != extensions.end(); ++extIter)
{
// Only Khronos-controlled extensions are checked
- if ((de::beginsWith(*extIter, "VK_KHR_") || de::beginsWith(*extIter, "VK_KHX_")) &&
+ if (de::beginsWith(*extIter, "VK_KHR_") &&
!de::contains(allowedExtSet, *extIter))
{
results.fail("Unknown KHR extension " + *extIter);
void checkDeviceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
{
- static const char* s_allowedInstanceKhrExtensions[] =
+ static const char* s_allowedDeviceKhrExtensions[] =
{
"VK_KHR_swapchain",
"VK_KHR_display_swapchain",
"VK_KHR_sampler_mirror_clamp_to_edge",
"VK_KHR_shader_draw_parameters",
+ "VK_KHR_maintenance1",
};
- checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedInstanceKhrExtensions), s_allowedInstanceKhrExtensions);
+ checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedDeviceKhrExtensions), s_allowedDeviceKhrExtensions);
checkDuplicateExtensions(results, extensions);
}
addFunctionCase(testGroup, "compressed_formats", "", testCompressedFormatsSupported);
}
-VkImageUsageFlags getValidImageUsageFlags (VkFormat, VkFormatFeatureFlags supportedFeatures)
+VkImageUsageFlags getValidImageUsageFlags (const VkFormatFeatureFlags supportedFeatures, const bool useKhrMaintenance1Semantics)
{
VkImageUsageFlags flags = (VkImageUsageFlags)0;
- // If format is supported at all, it must be valid transfer src+dst
- if (supportedFeatures != 0)
- flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+ if (useKhrMaintenance1Semantics)
+ {
+ if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR) != 0)
+ flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
+
+ if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR) != 0)
+ flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+ }
+ else
+ {
+ // If format is supported at all, it must be valid transfer src+dst
+ if (supportedFeatures != 0)
+ flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+ }
if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
DE_ASSERT(deviceFeatures.sparseBinding || (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) == 0);
DE_ASSERT(deviceFeatures.sparseResidencyAliased || (createFlags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) == 0);
+ if (createFlags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)
+ {
+ if (isCompressedFormat(format))
+ return false;
+
+ if (isDepthStencilFormat(format))
+ return false;
+
+ if (!deIsPowerOfTwo32(mapVkFormat(format).getPixelSize()))
+ return false;
+
+ switch (imageType)
+ {
+ case VK_IMAGE_TYPE_2D:
+ return (deviceFeatures.sparseResidencyImage2D == VK_TRUE);
+ case VK_IMAGE_TYPE_3D:
+ return (deviceFeatures.sparseResidencyImage3D == VK_TRUE);
+ default:
+ return false;
+ }
+ }
+
return true;
}
const VkPhysicalDeviceFeatures& deviceFeatures = context.getDeviceFeatures();
const VkPhysicalDeviceLimits& deviceLimits = context.getDeviceProperties().limits;
const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
+ const bool hasKhrMaintenance1 = isExtensionSupported(context.getDeviceExtensions(), "VK_KHR_maintenance1");
const VkFormatFeatureFlags supportedFeatures = tiling == VK_IMAGE_TILING_LINEAR ? formatProperties.linearTilingFeatures : formatProperties.optimalTilingFeatures;
- const VkImageUsageFlags usageFlagSet = getValidImageUsageFlags(format, supportedFeatures);
+ const VkImageUsageFlags usageFlagSet = getValidImageUsageFlags(supportedFeatures, hasKhrMaintenance1);
tcu::ResultCollector results (log, "ERROR: ");
+ if (hasKhrMaintenance1 && (supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
+ {
+ results.check((supportedFeatures & (VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR | VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR)) != 0,
+ "A sampled image format must have VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR and VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR format feature flags set");
+ }
+
for (VkImageUsageFlags curUsageFlags = 0; curUsageFlags <= usageFlagSet; curUsageFlags++)
{
if ((curUsageFlags & ~usageFlagSet) != 0 ||
results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth >= 1), "Invalid dimensions for 3D image");
results.check(imageType != VK_IMAGE_TYPE_3D || properties.maxArrayLayers == 1, "Invalid maxArrayLayers for 3D image");
- if (tiling == VK_IMAGE_TILING_OPTIMAL && imageType == VK_IMAGE_TYPE_2D && !(curCreateFlags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
- ((supportedFeatures & (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) ||
- ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) && deviceFeatures.shaderStorageImageMultisample)))
+ if (tiling == VK_IMAGE_TILING_OPTIMAL)
{
- const VkSampleCountFlags requiredSampleCounts = getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags);
- results.check((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts, "Required sample counts not supported");
+ // Vulkan API specification has changed since initial Android Nougat release.
+ // For NYC CTS we need to tolerate old behavior as well and issue compatibility
+ // warning instead.
+ //
+ // See spec issues 272, 282, 302, 445 and CTS issues 369, 440.
+ const bool requiredByNewSpec = (imageType == VK_IMAGE_TYPE_2D && !(curCreateFlags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
+ ((supportedFeatures & (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) ||
+ ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) && deviceFeatures.shaderStorageImageMultisample)));
+
+ if (requiredByNewSpec)
+ {
+ const VkSampleCountFlags requiredSampleCounts = getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags);
+
+ results.check((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts, "Required sample counts not supported");
+ }
+ else if (properties.sampleCounts != VK_SAMPLE_COUNT_1_BIT)
+ {
+ results.addResult(QP_TEST_RESULT_COMPATIBILITY_WARNING,
+ "Implementation supports more sample counts than allowed by the spec");
+ }
}
else
results.check(properties.sampleCounts == VK_SAMPLE_COUNT_1_BIT, "sampleCounts != VK_SAMPLE_COUNT_1_BIT");