1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2016 The Khronos Group Inc.
6 *
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
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 *
19 *//*
20 * \file vktPipelineMultisampleBase.cpp
21 * \brief Multisample Tests Base Classes
22 *//*--------------------------------------------------------------------*/
23
24 #include "vktPipelineMultisampleBase.hpp"
25 #include "vkQueryUtil.hpp"
26
27 namespace vkt
28 {
29 namespace pipeline
30 {
31 namespace multisample
32 {
33
34 using namespace vk;
35
validateImageSize(const InstanceInterface & instance,const VkPhysicalDevice physicalDevice,const ImageType imageType,const tcu::UVec3 & imageSize) const36 void MultisampleInstanceBase::validateImageSize (const InstanceInterface& instance,
37 const VkPhysicalDevice physicalDevice,
38 const ImageType imageType,
39 const tcu::UVec3& imageSize) const
40 {
41 const VkPhysicalDeviceProperties deviceProperties = getPhysicalDeviceProperties(instance, physicalDevice);
42
43 bool isImageSizeValid = true;
44
45 switch (imageType)
46 {
47 case IMAGE_TYPE_1D:
48 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension1D;
49 break;
50 case IMAGE_TYPE_1D_ARRAY:
51 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension1D &&
52 imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
53 break;
54 case IMAGE_TYPE_2D:
55 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension2D &&
56 imageSize.y() <= deviceProperties.limits.maxImageDimension2D;
57 break;
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;
62 break;
63 case IMAGE_TYPE_CUBE:
64 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimensionCube &&
65 imageSize.y() <= deviceProperties.limits.maxImageDimensionCube;
66 break;
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;
71 break;
72 case IMAGE_TYPE_3D:
73 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension3D &&
74 imageSize.y() <= deviceProperties.limits.maxImageDimension3D &&
75 imageSize.z() <= deviceProperties.limits.maxImageDimension3D;
76 break;
77 default:
78 DE_FATAL("Unknown image type");
79 }
80
81 if (!isImageSizeValid)
82 {
83 std::ostringstream notSupportedStream;
84
85 notSupportedStream << "Image type (" << getImageTypeName(imageType) << ") with size (" << imageSize.x() << ", " << imageSize.y() << ", " << imageSize.z() << ") not supported by device" << std::endl;
86
87 const std::string notSupportedString = notSupportedStream.str();
88
89 TCU_THROW(NotSupportedError, notSupportedString.c_str());
90 }
91 }
92
validateImageFeatureFlags(const InstanceInterface & instance,const VkPhysicalDevice physicalDevice,const VkFormat format,const VkFormatFeatureFlags featureFlags) const93 void MultisampleInstanceBase::validateImageFeatureFlags (const InstanceInterface& instance,
94 const VkPhysicalDevice physicalDevice,
95 const VkFormat format,
96 const VkFormatFeatureFlags featureFlags) const
97 {
98 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(instance, physicalDevice, format);
99
100 if ((formatProperties.optimalTilingFeatures & featureFlags) != featureFlags)
101 {
102 std::ostringstream notSupportedStream;
103
104 notSupportedStream << "Device does not support image format " << format << " for feature flags " << featureFlags << std::endl;
105
106 const std::string notSupportedString = notSupportedStream.str();
107
108 TCU_THROW(NotSupportedError, notSupportedString.c_str());
109 }
110 }
111
validateImageInfo(const InstanceInterface & instance,const VkPhysicalDevice physicalDevice,const VkImageCreateInfo & imageInfo) const112 void MultisampleInstanceBase::validateImageInfo (const InstanceInterface& instance,
113 const VkPhysicalDevice physicalDevice,
114 const VkImageCreateInfo& imageInfo) const
115 {
116 VkImageFormatProperties imageFormatProps;
117 instance.getPhysicalDeviceImageFormatProperties(physicalDevice, imageInfo.format, imageInfo.imageType, imageInfo.tiling, imageInfo.usage, imageInfo.flags, &imageFormatProps);
118
119 if (imageFormatProps.maxExtent.width < imageInfo.extent.width ||
120 imageFormatProps.maxExtent.height < imageInfo.extent.height ||
121 imageFormatProps.maxExtent.depth < imageInfo.extent.depth)
122 {
123 std::ostringstream notSupportedStream;
124
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
133 << ")";
134
135 const std::string notSupportedString = notSupportedStream.str();
136
137 TCU_THROW(NotSupportedError, notSupportedString.c_str());
138 }
139
140 if (imageFormatProps.maxArrayLayers < imageInfo.arrayLayers)
141 {
142 std::ostringstream notSupportedStream;
143
144 notSupportedStream << "Image layers count of " << imageInfo.arrayLayers << " exceeds allowed maximum which is " << imageFormatProps.maxArrayLayers;
145
146 const std::string notSupportedString = notSupportedStream.str();
147
148 TCU_THROW(NotSupportedError, notSupportedString.c_str());
149 }
150
151 if (!(imageFormatProps.sampleCounts & imageInfo.samples))
152 {
153 std::ostringstream notSupportedStream;
154
155 notSupportedStream << "Samples count of " << imageInfo.samples << " not supported for image";
156
157 const std::string notSupportedString = notSupportedStream.str();
158
159 TCU_THROW(NotSupportedError, notSupportedString.c_str());
160 }
161 }
162
163 } // multisample
164 } // pipeline
165 } // vkt
166