1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2016 The Khronos Group Inc.
6 * Copyright (c) 2023 LunarG, Inc.
7 * Copyright (c) 2023 Nintendo
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 *//*
22 * \file vktPipelineMultisampleBase.cpp
23 * \brief Multisample Tests Base Classes
24 *//*--------------------------------------------------------------------*/
25
26 #include "vktPipelineMultisampleBase.hpp"
27 #include "vkQueryUtil.hpp"
28
29 namespace vkt
30 {
31 namespace pipeline
32 {
33 namespace multisample
34 {
35
36 using namespace vk;
37
validateImageSize(const InstanceInterface& instance, const VkPhysicalDevice physicalDevice, const ImageType imageType, const tcu::UVec3& imageSize) const38 void MultisampleInstanceBase::validateImageSize (const InstanceInterface& instance,
39 const VkPhysicalDevice physicalDevice,
40 const ImageType imageType,
41 const tcu::UVec3& imageSize) const
42 {
43 const VkPhysicalDeviceProperties deviceProperties = getPhysicalDeviceProperties(instance, physicalDevice);
44
45 bool isImageSizeValid = true;
46
47 switch (imageType)
48 {
49 case IMAGE_TYPE_1D:
50 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension1D;
51 break;
52 case IMAGE_TYPE_1D_ARRAY:
53 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension1D &&
54 imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
55 break;
56 case IMAGE_TYPE_2D:
57 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension2D &&
58 imageSize.y() <= deviceProperties.limits.maxImageDimension2D;
59 break;
60 case IMAGE_TYPE_2D_ARRAY:
61 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension2D &&
62 imageSize.y() <= deviceProperties.limits.maxImageDimension2D &&
63 imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
64 break;
65 case IMAGE_TYPE_CUBE:
66 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimensionCube &&
67 imageSize.y() <= deviceProperties.limits.maxImageDimensionCube;
68 break;
69 case IMAGE_TYPE_CUBE_ARRAY:
70 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimensionCube &&
71 imageSize.y() <= deviceProperties.limits.maxImageDimensionCube &&
72 imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
73 break;
74 case IMAGE_TYPE_3D:
75 isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension3D &&
76 imageSize.y() <= deviceProperties.limits.maxImageDimension3D &&
77 imageSize.z() <= deviceProperties.limits.maxImageDimension3D;
78 break;
79 default:
80 DE_FATAL("Unknown image type");
81 }
82
83 if (!isImageSizeValid)
84 {
85 std::ostringstream notSupportedStream;
86
87 notSupportedStream << "Image type (" << getImageTypeName(imageType) << ") with size (" << imageSize.x() << ", " << imageSize.y() << ", " << imageSize.z() << ") not supported by device" << std::endl;
88
89 const std::string notSupportedString = notSupportedStream.str();
90
91 TCU_THROW(NotSupportedError, notSupportedString.c_str());
92 }
93 }
94
validateImageFeatureFlags(const InstanceInterface& instance, const VkPhysicalDevice physicalDevice, const VkFormat format, const VkFormatFeatureFlags featureFlags) const95 void MultisampleInstanceBase::validateImageFeatureFlags (const InstanceInterface& instance,
96 const VkPhysicalDevice physicalDevice,
97 const VkFormat format,
98 const VkFormatFeatureFlags featureFlags) const
99 {
100 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(instance, physicalDevice, format);
101
102 if ((formatProperties.optimalTilingFeatures & featureFlags) != featureFlags)
103 {
104 std::ostringstream notSupportedStream;
105
106 notSupportedStream << "Device does not support image format " << format << " for feature flags " << featureFlags << std::endl;
107
108 const std::string notSupportedString = notSupportedStream.str();
109
110 TCU_THROW(NotSupportedError, notSupportedString.c_str());
111 }
112 }
113
validateImageInfo(const InstanceInterface& instance, const VkPhysicalDevice physicalDevice, const VkImageCreateInfo& imageInfo) const114 void MultisampleInstanceBase::validateImageInfo (const InstanceInterface& instance,
115 const VkPhysicalDevice physicalDevice,
116 const VkImageCreateInfo& imageInfo) const
117 {
118 VkImageFormatProperties imageFormatProps;
119 instance.getPhysicalDeviceImageFormatProperties(physicalDevice, imageInfo.format, imageInfo.imageType, imageInfo.tiling, imageInfo.usage, imageInfo.flags, &imageFormatProps);
120
121 if (imageFormatProps.maxExtent.width < imageInfo.extent.width ||
122 imageFormatProps.maxExtent.height < imageInfo.extent.height ||
123 imageFormatProps.maxExtent.depth < imageInfo.extent.depth)
124 {
125 std::ostringstream notSupportedStream;
126
127 notSupportedStream << "Image extent ("
128 << imageInfo.extent.width << ", "
129 << imageInfo.extent.height << ", "
130 << imageInfo.extent.depth
131 << ") exceeds allowed maximum ("
132 << imageFormatProps.maxExtent.width << ", "
133 << imageFormatProps.maxExtent.height << ", "
134 << imageFormatProps.maxExtent.depth
135 << ")";
136
137 const std::string notSupportedString = notSupportedStream.str();
138
139 TCU_THROW(NotSupportedError, notSupportedString.c_str());
140 }
141
142 if (imageFormatProps.maxArrayLayers < imageInfo.arrayLayers)
143 {
144 std::ostringstream notSupportedStream;
145
146 notSupportedStream << "Image layers count of " << imageInfo.arrayLayers << " exceeds allowed maximum which is " << imageFormatProps.maxArrayLayers;
147
148 const std::string notSupportedString = notSupportedStream.str();
149
150 TCU_THROW(NotSupportedError, notSupportedString.c_str());
151 }
152
153 if (!(imageFormatProps.sampleCounts & imageInfo.samples))
154 {
155 std::ostringstream notSupportedStream;
156
157 notSupportedStream << "Samples count of " << imageInfo.samples << " not supported for image";
158
159 const std::string notSupportedString = notSupportedStream.str();
160
161 TCU_THROW(NotSupportedError, notSupportedString.c_str());
162 }
163 }
164
165 } // multisample
166 } // pipeline
167 } // vkt
168