xref: /aosp_15_r20/external/deqp/external/vulkancts/modules/vulkan/api/vktApiMaintenance6Check.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2017 Khronos Group
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
21 * \brief API Maintenance6 Check test - checks structs and function from VK_KHR_maintenance6
22 *//*--------------------------------------------------------------------*/
23 
24 #include "tcuTestLog.hpp"
25 
26 #include "vkQueryUtil.hpp"
27 
28 #include "vktApiMaintenance6Check.hpp"
29 #include "vktTestCase.hpp"
30 #include "vktTestCaseUtil.hpp"
31 
32 #include <sstream>
33 #include <limits>
34 #include <utility>
35 #include <algorithm>
36 #include <map>
37 #include <set>
38 
39 #ifndef CTS_USES_VULKANSC
40 
41 using namespace vk;
42 
43 namespace vkt
44 {
45 
46 namespace api
47 {
48 
49 namespace
50 {
51 
52 class Maintenance6MaxCombinedImageSamplerDescriptorCountTestInstance : public TestInstance
53 {
54 public:
Maintenance6MaxCombinedImageSamplerDescriptorCountTestInstance(Context & ctx)55     Maintenance6MaxCombinedImageSamplerDescriptorCountTestInstance(Context &ctx) : TestInstance(ctx)
56     {
57     }
iterate(void)58     virtual tcu::TestStatus iterate(void)
59     {
60         const InstanceInterface &vki(m_context.getInstanceInterface());
61         const VkPhysicalDevice physicalDevice(m_context.getPhysicalDevice());
62 
63         VkPhysicalDeviceMaintenance6PropertiesKHR maintProp6 = initVulkanStructure();
64         VkPhysicalDeviceProperties2 prop2                    = initVulkanStructure(&maintProp6);
65 
66         vki.getPhysicalDeviceProperties2(physicalDevice, &prop2);
67 
68         static const struct
69         {
70             VkFormat begin;
71             VkFormat end;
72         } s_formatRanges[] = {
73             // YCbCr formats
74             {VK_FORMAT_G8B8G8R8_422_UNORM, (VkFormat)(VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM + 1)},
75 
76             // YCbCr extended formats
77             {VK_FORMAT_G8_B8R8_2PLANE_444_UNORM, (VkFormat)(VK_FORMAT_G16_B16R16_2PLANE_444_UNORM + 1)},
78 
79             // VK_FORMAT_R16G16_S10_5_NV
80             {VK_FORMAT_R16G16_S10_5_NV, (VkFormat)(VK_FORMAT_R16G16_S10_5_NV + 1)},
81         };
82 
83         for (int rangeNdx = 0; rangeNdx < DE_LENGTH_OF_ARRAY(s_formatRanges); ++rangeNdx)
84         {
85             const VkFormat rangeBegin = s_formatRanges[rangeNdx].begin;
86             const VkFormat rangeEnd   = s_formatRanges[rangeNdx].end;
87 
88             for (VkFormat format = rangeBegin; format != rangeEnd; format = (VkFormat)(format + 1))
89             {
90                 VkSamplerYcbcrConversionImageFormatProperties conversionImageFormatProps = initVulkanStructure();
91                 VkImageFormatProperties2 formatProps       = initVulkanStructure(&conversionImageFormatProps);
92                 VkPhysicalDeviceImageFormatInfo2 imageInfo = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,
93                                                               nullptr,
94                                                               format,
95                                                               VK_IMAGE_TYPE_2D,
96                                                               VK_IMAGE_TILING_OPTIMAL,
97                                                               VK_IMAGE_USAGE_TRANSFER_DST_BIT,
98                                                               0U};
99                 vki.getPhysicalDeviceImageFormatProperties2(physicalDevice, &imageInfo, &formatProps);
100                 if (conversionImageFormatProps.combinedImageSamplerDescriptorCount >
101                     maintProp6.maxCombinedImageSamplerDescriptorCount)
102                 {
103                     return tcu::TestStatus::fail(
104                         "Fail: format " + std::string(getFormatName(format)) +
105                         " requires a larger combinedImageSamplerDescriptorCount=" +
106                         std::to_string(conversionImageFormatProps.combinedImageSamplerDescriptorCount) +
107                         " than maxCombinedImageSamplerDescriptorCount=" +
108                         std::to_string(maintProp6.maxCombinedImageSamplerDescriptorCount));
109                 }
110             }
111         }
112 
113         return tcu::TestStatus::pass("Pass");
114     }
115 };
116 
117 class Maintenance6MaxCombinedImageSamplerDescriptorCountTestCase : public TestCase
118 {
119 public:
Maintenance6MaxCombinedImageSamplerDescriptorCountTestCase(tcu::TestContext & testCtx)120     Maintenance6MaxCombinedImageSamplerDescriptorCountTestCase(tcu::TestContext &testCtx)
121         : TestCase(testCtx, "maintenance6_properties")
122     {
123     }
124 
~Maintenance6MaxCombinedImageSamplerDescriptorCountTestCase(void)125     virtual ~Maintenance6MaxCombinedImageSamplerDescriptorCountTestCase(void)
126     {
127     }
checkSupport(Context & ctx) const128     virtual void checkSupport(Context &ctx) const
129     {
130         ctx.requireDeviceFunctionality("VK_KHR_maintenance6");
131     }
createInstance(Context & ctx) const132     virtual TestInstance *createInstance(Context &ctx) const
133     {
134         return new Maintenance6MaxCombinedImageSamplerDescriptorCountTestInstance(ctx);
135     }
136 
137 private:
138 };
139 
140 } // namespace
141 
createMaintenance6Tests(tcu::TestContext & testCtx)142 tcu::TestCaseGroup *createMaintenance6Tests(tcu::TestContext &testCtx)
143 {
144     de::MovePtr<tcu::TestCaseGroup> main6Tests(
145         new tcu::TestCaseGroup(testCtx, "maintenance6_check", "Maintenance6 Tests"));
146     main6Tests->addChild(new Maintenance6MaxCombinedImageSamplerDescriptorCountTestCase(testCtx));
147 
148     return main6Tests.release();
149 }
150 
151 } // namespace api
152 } // namespace vkt
153 
154 #endif // CTS_USES_VULKANSC
155