xref: /aosp_15_r20/external/deqp/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleBase.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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, const ImageType imageType,
40                                                 const tcu::UVec3 &imageSize) const
41 {
42     const VkPhysicalDeviceProperties deviceProperties = getPhysicalDeviceProperties(instance, physicalDevice);
43 
44     bool isImageSizeValid = true;
45 
46     switch (imageType)
47     {
48     case IMAGE_TYPE_1D:
49         isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension1D;
50         break;
51     case IMAGE_TYPE_1D_ARRAY:
52         isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension1D &&
53                            imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
54         break;
55     case IMAGE_TYPE_2D:
56         isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension2D &&
57                            imageSize.y() <= deviceProperties.limits.maxImageDimension2D;
58         break;
59     case IMAGE_TYPE_2D_ARRAY:
60         isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension2D &&
61                            imageSize.y() <= deviceProperties.limits.maxImageDimension2D &&
62                            imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
63         break;
64     case IMAGE_TYPE_CUBE:
65         isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimensionCube &&
66                            imageSize.y() <= deviceProperties.limits.maxImageDimensionCube;
67         break;
68     case IMAGE_TYPE_CUBE_ARRAY:
69         isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimensionCube &&
70                            imageSize.y() <= deviceProperties.limits.maxImageDimensionCube &&
71                            imageSize.z() <= deviceProperties.limits.maxImageArrayLayers;
72         break;
73     case IMAGE_TYPE_3D:
74         isImageSizeValid = imageSize.x() <= deviceProperties.limits.maxImageDimension3D &&
75                            imageSize.y() <= deviceProperties.limits.maxImageDimension3D &&
76                            imageSize.z() <= deviceProperties.limits.maxImageDimension3D;
77         break;
78     default:
79         DE_FATAL("Unknown image type");
80     }
81 
82     if (!isImageSizeValid)
83     {
84         std::ostringstream notSupportedStream;
85 
86         notSupportedStream << "Image type (" << getImageTypeName(imageType) << ") with size (" << imageSize.x() << ", "
87                            << 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, const VkFormat format,
97                                                         const VkFormatFeatureFlags featureFlags) const
98 {
99     const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(instance, physicalDevice, format);
100 
101     if ((formatProperties.optimalTilingFeatures & featureFlags) != featureFlags)
102     {
103         std::ostringstream notSupportedStream;
104 
105         notSupportedStream << "Device does not support image format " << format << " for feature flags " << featureFlags
106                            << 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,
120                                                     imageInfo.tiling, imageInfo.usage, imageInfo.flags,
121                                                     &imageFormatProps);
122 
123     if (imageFormatProps.maxExtent.width < imageInfo.extent.width ||
124         imageFormatProps.maxExtent.height < imageInfo.extent.height ||
125         imageFormatProps.maxExtent.depth < imageInfo.extent.depth)
126     {
127         std::ostringstream notSupportedStream;
128 
129         notSupportedStream << "Image extent (" << imageInfo.extent.width << ", " << imageInfo.extent.height << ", "
130                            << imageInfo.extent.depth << ") exceeds allowed maximum ("
131                            << imageFormatProps.maxExtent.width << ", " << imageFormatProps.maxExtent.height << ", "
132                            << imageFormatProps.maxExtent.depth << ")";
133 
134         const std::string notSupportedString = notSupportedStream.str();
135 
136         TCU_THROW(NotSupportedError, notSupportedString.c_str());
137     }
138 
139     if (imageFormatProps.maxArrayLayers < imageInfo.arrayLayers)
140     {
141         std::ostringstream notSupportedStream;
142 
143         notSupportedStream << "Image layers count of " << imageInfo.arrayLayers << " exceeds allowed maximum which is "
144                            << 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 } // namespace multisample
164 } // namespace pipeline
165 } // namespace vkt
166