1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2016 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 * \file vktPipelineMultisampleBase.cpp
21 * \brief Multisample Tests Base Classes
22 *//*--------------------------------------------------------------------*/
24 #include "vktPipelineMultisampleBase.hpp"
25 #include "vkQueryUtil.hpp"
36 void MultisampleInstanceBase::validateImageSize (const InstanceInterface& instance,
37 const VkPhysicalDevice physicalDevice,
38 const ImageType imageType,
39 const tcu::UVec3& imageSize) const
41 const VkPhysicalDeviceProperties deviceProperties = getPhysicalDeviceProperties(instance, physicalDevice);
43 bool isImageSizeValid = true;
48 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension1D;
50 case IMAGE_TYPE_1D_ARRAY:
51 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension1D &&
52 imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
55 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension2D &&
56 imageSize.y() <= deviceProperties.limits.maxImageDimension2D;
58 case IMAGE_TYPE_2D_ARRAY:
59 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension2D &&
60 imageSize.y() <= deviceProperties.limits.maxImageDimension2D &&
61 imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
64 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimensionCube &&
65 imageSize.y() <= deviceProperties.limits.maxImageDimensionCube;
67 case IMAGE_TYPE_CUBE_ARRAY:
68 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimensionCube &&
69 imageSize.y() <= deviceProperties.limits.maxImageDimensionCube &&
70 imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
73 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension3D &&
74 imageSize.y() <= deviceProperties.limits.maxImageDimension3D &&
75 imageSize.z() <= deviceProperties.limits.maxImageDimension3D;
78 DE_FATAL("Unknown image type");
81 if (!isImageSizeValid)
83 std::ostringstream notSupportedStream;
85 notSupportedStream << "Image type (" << getImageTypeName(imageType) << ") with size (" << imageSize.x() << ", " << imageSize.y() << ", " << imageSize.z() << ") not supported by device" << std::endl;
87 const std::string notSupportedString = notSupportedStream.str();
89 TCU_THROW(NotSupportedError, notSupportedString.c_str());
93 void MultisampleInstanceBase::validateImageFeatureFlags (const InstanceInterface& instance,
94 const VkPhysicalDevice physicalDevice,
95 const VkFormat format,
96 const VkFormatFeatureFlags featureFlags) const
98 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(instance, physicalDevice, format);
100 if ((formatProperties.optimalTilingFeatures & featureFlags) != featureFlags)
102 std::ostringstream notSupportedStream;
104 notSupportedStream << "Device does not support image format " << format << " for feature flags " << featureFlags << std::endl;
106 const std::string notSupportedString = notSupportedStream.str();
108 TCU_THROW(NotSupportedError, notSupportedString.c_str());
112 void MultisampleInstanceBase::validateImageInfo (const InstanceInterface& instance,
113 const VkPhysicalDevice physicalDevice,
114 const VkImageCreateInfo& imageInfo) const
116 VkImageFormatProperties imageFormatProps;
117 instance.getPhysicalDeviceImageFormatProperties(physicalDevice, imageInfo.format, imageInfo.imageType, imageInfo.tiling, imageInfo.usage, imageInfo.flags, &imageFormatProps);
119 if (imageFormatProps.maxExtent.width < imageInfo.extent.width ||
120 imageFormatProps.maxExtent.height < imageInfo.extent.height ||
121 imageFormatProps.maxExtent.depth < imageInfo.extent.depth)
123 std::ostringstream notSupportedStream;
125 notSupportedStream << "Image extent ("
126 << imageInfo.extent.width << ", "
127 << imageInfo.extent.height << ", "
128 << imageInfo.extent.depth
129 << ") exceeds allowed maximum ("
130 << imageFormatProps.maxExtent.width << ", "
131 << imageFormatProps.maxExtent.height << ", "
132 << imageFormatProps.maxExtent.depth
136 const std::string notSupportedString = notSupportedStream.str();
138 TCU_THROW(NotSupportedError, notSupportedString.c_str());
141 if (imageFormatProps.maxArrayLayers < imageInfo.arrayLayers)
143 std::ostringstream notSupportedStream;
145 notSupportedStream << "Image layers count of " << imageInfo.arrayLayers << " exceeds allowed maximum which is " << imageFormatProps.maxArrayLayers << std::endl;
147 const std::string notSupportedString = notSupportedStream.str();
149 TCU_THROW(NotSupportedError, notSupportedString.c_str());
152 if (!(imageFormatProps.sampleCounts & imageInfo.samples))
154 std::ostringstream notSupportedStream;
156 notSupportedStream << "Samples count of " << imageInfo.samples << " not supported for image" << std::endl;
158 const std::string notSupportedString = notSupportedStream.str();
160 TCU_THROW(NotSupportedError, notSupportedString.c_str());