1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2017 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
21 * \brief Vulkan coverage tests for extensions VK_KHR_display,
22 * VK_KHR_get_display_properties2
23 *//*--------------------------------------------------------------------*/
24
25 #include "vktWsiDisplayTests.hpp"
26
27 #include "vktTestCase.hpp"
28 #include "vkStrUtil.hpp"
29 #include "vkPrograms.hpp"
30 #include "vkRef.hpp"
31
32 #include "tcuDefs.hpp"
33 #include "tcuTestLog.hpp"
34 #include "tcuResultCollector.hpp"
35
36 #include "deMemory.h"
37 #include "deSTLUtil.hpp"
38 #include "deStringUtil.hpp"
39
40 #include <set>
41 #include <map>
42 #include <limits>
43
44 namespace vkt
45 {
46 namespace wsi
47 {
48 using namespace vk;
49 using std::vector;
50 using std::map;
51 using std::set;
52 using std::string;
53
54 #ifndef TCU_FAIL_STR
55 #define TCU_FAIL_STR(MSG) TCU_FAIL(string(MSG).c_str())
56 #endif
57
58 enum DisplayIndexTest
59 {
60 DISPLAY_TEST_INDEX_START,
61 DISPLAY_TEST_INDEX_GET_DISPLAY_PROPERTIES,
62 DISPLAY_TEST_INDEX_GET_DISPLAY_PLANES,
63 DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_SUPPORTED_DISPLAY,
64 DISPLAY_TEST_INDEX_GET_DISPLAY_MODE,
65 DISPLAY_TEST_INDEX_CREATE_DISPLAY_MODE,
66 DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_CAPABILITIES,
67 DISPLAY_TEST_INDEX_CREATE_DISPLAY_PLANE_SURFACE,
68 DISPLAY_TEST_INDEX_GET_DISPLAY_PROPERTIES2,
69 DISPLAY_TEST_INDEX_GET_DISPLAY_PLANES2,
70 DISPLAY_TEST_INDEX_GET_DISPLAY_MODE2,
71 DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_CAPABILITIES2,
72 DISPLAY_TEST_INDEX_LAST
73 };
74
75 template <typename Type>
76 class BinaryCompare
77 {
78 public:
operator ()(const Type & a,const Type & b) const79 bool operator() (const Type& a, const Type& b) const
80 {
81 return deMemCmp(&a, &b, sizeof(Type)) < 0;
82 }
83 };
84
85 typedef std::set<vk::VkDisplayKHR, BinaryCompare<vk::VkDisplayKHR> > DisplaySet;
86 typedef std::vector<vk::VkDisplayKHR> DisplayVector;
87 typedef std::vector<vk::VkDisplayModePropertiesKHR> DisplayModePropertiesVector;
88 typedef std::vector<vk::VkDisplayModeProperties2KHR> DisplayModeProperties2Vector;
89
90 const deUint32 DEUINT32_MAX = std::numeric_limits<deUint32>::max();
91
92 const deUint32 RECOGNIZED_SURFACE_TRANSFORM_FLAGS =
93 vk::VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR
94 | vk::VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR
95 | vk::VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR
96 | vk::VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR
97 | vk::VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR
98 | vk::VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR
99 | vk::VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR
100 | vk::VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR
101 | vk::VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR;
102
103 const deUint32 RECOGNIZED_DISPLAY_PLANE_ALPHA_FLAGS =
104 VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR
105 | VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR
106 | VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR
107 | VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR;
108 enum DisplayMaxTestedConsts
109 {
110 MAX_TESTED_DISPLAY_COUNT = 16,
111 MAX_TESTED_PLANE_COUNT = 16,
112 };
113
114 /*--------------------------------------------------------------------*//*!
115 * \brief Return Vulkan result name or code as std::string.
116 *
117 * \param result Vulkan code to convert to string
118 * \return Vulkun result code name or code number as std::string
119 *//*--------------------------------------------------------------------*/
getResultAsString(vk::VkResult result)120 std::string getResultAsString (vk::VkResult result)
121 {
122 const char* resultAsChar = vk::getResultName(result);
123
124 if (resultAsChar != DE_NULL)
125 return std::string(resultAsChar);
126 else
127 return de::toString(result);
128 }
129
130 /*--------------------------------------------------------------------*//*!
131 * \brief Moves test index to next test skipping middle tests.
132 *
133 * Gets first 3 tests and last 3 tests on long sequences.
134 * After test number 2 moves index value to endIndex - 3.
135 * Shortens the number of tests executed by skipping middle tests.
136 *
137 * Example:
138 * for (i=0; i<endIndex; nextTestNumber(i, endIndex))
139 * with endIndex = 4 generates 0,1,2,3
140 * with endIndex = 9 generates 0,1,2,6,7,8
141 *
142 * \param index Current iterator value
143 * \param endIndex First number out of iteration sequence
144 * \return new iterator value
145 *//*--------------------------------------------------------------------*/
nextTestNumber(deUint32 index,deUint32 endIndex)146 deUint32 nextTestNumber (deUint32 index, deUint32 endIndex)
147 {
148 deUint32 result;
149
150 if (endIndex > 6 && index == 2)
151 result = endIndex - 3;
152 else
153 result = index + 1;
154
155 return result;
156 }
157
158 /*--------------------------------------------------------------------*//*!
159 * \brief Vulkan VK_KHR_display extensions coverage tests
160 *//*--------------------------------------------------------------------*/
161 class DisplayCoverageTestInstance : public TestInstance
162 {
163 public:
164 DisplayCoverageTestInstance (Context& context, const DisplayIndexTest testId);
165 private:
166 typedef void (DisplayCoverageTestInstance::*EachSurfaceFunctionPtr)
167 (VkSurfaceKHR& surface, VkDisplayModePropertiesKHR& modeProperties);
168
169 bool getDisplays (DisplayVector& displays);
170 bool getDisplaysForPlane (deUint32 plane, DisplayVector& displays);
171 bool getDisplayModeProperties (VkDisplayKHR display, DisplayModePropertiesVector& modeProperties);
172
173 bool getDisplays2 (DisplayVector& displays);
174 bool getDisplayModeProperties2 (VkDisplayKHR display, DisplayModeProperties2Vector& modeProperties);
175
176 void validateDisplayProperties ( tcu::ResultCollector& results,
177 const VkDisplayPropertiesKHR& toValidate,
178 const VkDisplayPropertiesKHR& nonUpdated);
179
180 void validateDisplayPlaneProperties ( tcu::ResultCollector& results,
181 const VkDisplayPlanePropertiesKHR& toValidate,
182 const VkDisplayPlanePropertiesKHR& nonUpdated,
183 DisplaySet& displaySet);
184
185 void validateDisplayPlaneCapabilities ( tcu::ResultCollector& results,
186 const VkDisplayPlaneCapabilitiesKHR& toValidate,
187 const VkDisplayPlaneCapabilitiesKHR& nonUpdated);
188
189 void validateDisplayModeProperties ( tcu::ResultCollector& results,
190 const VkDisplayModePropertiesKHR& toValidate,
191 const VkDisplayModePropertiesKHR& nonUpdated);
192
193 // VK_KHR_display extension tests
194 tcu::TestStatus testGetPhysicalDeviceDisplayPropertiesKHR (void);
195 tcu::TestStatus testGetPhysicalDeviceDisplayPlanePropertiesKHR (void);
196 tcu::TestStatus testGetDisplayPlaneSupportedDisplaysKHR (void);
197 tcu::TestStatus testGetDisplayModePropertiesKHR (void);
198 tcu::TestStatus testCreateDisplayModeKHR (void);
199 tcu::TestStatus testGetDisplayPlaneCapabilitiesKHR (void);
200 tcu::TestStatus testCreateDisplayPlaneSurfaceKHR (void);
201
202 // VK_KHR_get_display_properties2 extension tests
203 tcu::TestStatus testGetPhysicalDeviceDisplayProperties2KHR (void);
204 tcu::TestStatus testGetPhysicalDeviceDisplayPlaneProperties2KHR (void);
205 tcu::TestStatus testGetDisplayModeProperties2KHR (void);
206 tcu::TestStatus testGetDisplayPlaneCapabilities2KHR (void);
207
208 tcu::TestStatus iterate (void);
209
210 void testCreateSharedSwapchainsKHRforSurface (VkSurfaceKHR& surface, VkDisplayModePropertiesKHR& modeProperties);
211
212 const InstanceInterface& m_vki;
213 const DeviceInterface& m_vkd;
214 tcu::TestLog& m_log;
215 const VkPhysicalDevice m_physicalDevice;
216 const DisplayIndexTest m_testId;
217 };
218
219
220 /*--------------------------------------------------------------------*//*!
221 * \brief DisplayCoverageTestInstance constructor
222 *
223 * Initializes DisplayCoverageTestInstance object
224 *
225 * \param context Context object
226 * \param parameters Test parameters structure
227 *//*--------------------------------------------------------------------*/
DisplayCoverageTestInstance(Context & context,const DisplayIndexTest testId)228 DisplayCoverageTestInstance::DisplayCoverageTestInstance (Context& context, const DisplayIndexTest testId)
229 : TestInstance (context)
230 , m_vki (m_context.getInstanceInterface())
231 , m_vkd (m_context.getDeviceInterface())
232 , m_log (m_context.getTestContext().getLog())
233 , m_physicalDevice (m_context.getPhysicalDevice())
234 , m_testId (testId)
235 {
236 const std::string extensionName("VK_KHR_display");
237
238 if(!de::contains(context.getInstanceExtensions().begin(), context.getInstanceExtensions().end(), extensionName))
239 TCU_THROW(NotSupportedError, std::string(extensionName + " is not supported").c_str());
240
241 switch (m_testId)
242 {
243 case DISPLAY_TEST_INDEX_GET_DISPLAY_PROPERTIES2:
244 case DISPLAY_TEST_INDEX_GET_DISPLAY_PLANES2:
245 case DISPLAY_TEST_INDEX_GET_DISPLAY_MODE2:
246 case DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_CAPABILITIES2:
247 {
248 const std::string extensionNameAddition("VK_KHR_get_display_properties2");
249
250 if(!de::contains(context.getInstanceExtensions().begin(), context.getInstanceExtensions().end(), extensionNameAddition))
251 TCU_THROW(NotSupportedError, std::string(extensionNameAddition + " is not supported").c_str());
252
253 break;
254 }
255
256 default:
257 {
258 break;
259 }
260 }
261 }
262
263 /*--------------------------------------------------------------------*//*!
264 * \brief Step forward test execution
265 *
266 * \return true if application should call iterate() again and false
267 * if test execution session is complete.
268 *//*--------------------------------------------------------------------*/
iterate(void)269 tcu::TestStatus DisplayCoverageTestInstance::iterate (void)
270 {
271 switch (m_testId)
272 {
273 case DISPLAY_TEST_INDEX_GET_DISPLAY_PROPERTIES: return testGetPhysicalDeviceDisplayPropertiesKHR(); break;
274 case DISPLAY_TEST_INDEX_GET_DISPLAY_PLANES: return testGetPhysicalDeviceDisplayPlanePropertiesKHR(); break;
275 case DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_SUPPORTED_DISPLAY: return testGetDisplayPlaneSupportedDisplaysKHR(); break;
276 case DISPLAY_TEST_INDEX_GET_DISPLAY_MODE: return testGetDisplayModePropertiesKHR(); break;
277 case DISPLAY_TEST_INDEX_CREATE_DISPLAY_MODE: return testCreateDisplayModeKHR(); break;
278 case DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_CAPABILITIES: return testGetDisplayPlaneCapabilitiesKHR(); break;
279 case DISPLAY_TEST_INDEX_CREATE_DISPLAY_PLANE_SURFACE: return testCreateDisplayPlaneSurfaceKHR(); break;
280 case DISPLAY_TEST_INDEX_GET_DISPLAY_PROPERTIES2: return testGetPhysicalDeviceDisplayProperties2KHR(); break;
281 case DISPLAY_TEST_INDEX_GET_DISPLAY_PLANES2: return testGetPhysicalDeviceDisplayPlaneProperties2KHR(); break;
282 case DISPLAY_TEST_INDEX_GET_DISPLAY_MODE2: return testGetDisplayModeProperties2KHR(); break;
283 case DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_CAPABILITIES2: return testGetDisplayPlaneCapabilities2KHR(); break;
284 default:
285 {
286 DE_FATAL("Impossible");
287 }
288 }
289
290 TCU_FAIL("Invalid test identifier");
291 }
292
293 /*--------------------------------------------------------------------*//*!
294 * \brief Fills vector with available displays. Clears passed vector at start.
295 *
296 * \param displays The vector filled with display handles
297 * \return true on success, false on error
298 *//*--------------------------------------------------------------------*/
getDisplays(DisplayVector & displays)299 bool DisplayCoverageTestInstance::getDisplays (DisplayVector& displays)
300 {
301 deUint32 countReported = 0u;
302 deUint32 countRetrieved = 0u;
303 std::vector<VkDisplayPropertiesKHR> displaysProps;
304 VkResult result;
305
306 displays.clear();
307
308 result = m_vki.getPhysicalDeviceDisplayPropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
309 &countReported, // uint32_t* pPropertyCount
310 DE_NULL); // VkDisplayPropertiesKHR* pProperties
311
312 if (result != VK_SUCCESS)
313 {
314 m_log << tcu::TestLog::Message
315 << "vkGetPhysicalDeviceDisplayPropertiesKHR failed with " << getResultAsString(result)
316 << " reported items count " << countReported
317 << tcu::TestLog::EndMessage;
318
319 return false;
320 }
321
322 displaysProps.resize(countReported);
323
324 countRetrieved = countReported;
325
326 result = m_vki.getPhysicalDeviceDisplayPropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
327 &countRetrieved, // uint32_t* pPropertyCount
328 &displaysProps[0]); // VkDisplayPropertiesKHR* pProperties
329
330 if (result != VK_SUCCESS || countRetrieved > countReported)
331 {
332 m_log << tcu::TestLog::Message
333 << "vkGetPhysicalDeviceDisplayPropertiesKHR failed with " << getResultAsString(result)
334 << " reported items count " << countReported
335 << " retrieved items count " << countRetrieved
336 << tcu::TestLog::EndMessage;
337
338 return false;
339 }
340
341 displays.reserve(countRetrieved);
342
343 for (deUint32 displayIndex = 0;
344 displayIndex < countRetrieved;
345 displayIndex++)
346 {
347 const VkDisplayKHR display = displaysProps[displayIndex].display;
348
349 if (display == DE_NULL)
350 {
351 displays.clear();
352
353 return false;
354 }
355
356 displays.push_back(display);
357 }
358
359 return true;
360 }
361
362 /*--------------------------------------------------------------------*//*!
363 * \brief Fills vector with available displays for plane specified.
364 *
365 * Clears passed vector at start and on error.
366 *
367 * \param plane The plane to get displays for
368 * \param displays The vector filled with display handles
369 * \return true on success, false on error
370 *//*--------------------------------------------------------------------*/
getDisplaysForPlane(deUint32 plane,DisplayVector & displays)371 bool DisplayCoverageTestInstance::getDisplaysForPlane(deUint32 plane, DisplayVector& displays)
372 {
373 deUint32 countReported = 0u;
374 deUint32 countRetrieved = 0u;
375 VkResult result;
376
377 displays.clear();
378
379 result = m_vki.getDisplayPlaneSupportedDisplaysKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
380 plane, // uint32_t planeIndex
381 &countReported, // uint32_t* pDisplayCount
382 DE_NULL); // VkDisplayKHR* pDisplays
383
384 if (result != VK_SUCCESS)
385 {
386 m_log << tcu::TestLog::Message
387 << "vkGetDisplayPlaneSupportedDisplaysKHR failed with " << getResultAsString(result)
388 << " for plane " << plane
389 << " reported items count " << countReported
390 << tcu::TestLog::EndMessage;
391
392 return false;
393 }
394
395 displays.resize(countReported);
396
397 countRetrieved = countReported;
398
399 result = m_vki.getDisplayPlaneSupportedDisplaysKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
400 plane, // uint32_t planeIndex
401 &countRetrieved, // uint32_t* pDisplayCount
402 &displays[0]); // VkDisplayKHR* pDisplays
403
404 if (result != VK_SUCCESS || countRetrieved > countReported)
405 {
406 m_log << tcu::TestLog::Message
407 << "vkGetDisplayPlaneSupportedDisplaysKHR failed with " << getResultAsString(result)
408 << " for plane " << plane
409 << " reported items count " << countReported
410 << " retrieved items count " << countRetrieved
411 << tcu::TestLog::EndMessage;
412
413 displays.clear();
414
415 return false;
416 }
417
418 if (countRetrieved < countReported)
419 displays.resize(countRetrieved);
420
421 return true;
422 }
423
424 /*--------------------------------------------------------------------*//*!
425 * \brief Fills vector with available modes properties for display specified.
426 *
427 * Clears passed vector at start and on error.
428 *
429 * \param display The display to get modes for
430 * \param modes The vector filled with display mode properties structures
431 * \return true on success, false on error
432 *//*--------------------------------------------------------------------*/
getDisplayModeProperties(VkDisplayKHR display,DisplayModePropertiesVector & modeProperties)433 bool DisplayCoverageTestInstance::getDisplayModeProperties(VkDisplayKHR display, DisplayModePropertiesVector& modeProperties)
434 {
435 deUint32 countReported = 0u;
436 deUint32 countRetrieved = 0u;
437 VkResult result;
438
439 modeProperties.clear();
440
441 result = m_vki.getDisplayModePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
442 display, // VkDisplayKHR display
443 &countReported, // uint32_t* pPropertyCount
444 DE_NULL); // VkDisplayModePropertiesKHR* pProperties
445
446 if (result != VK_SUCCESS)
447 {
448 m_log << tcu::TestLog::Message
449 << "vkGetDisplayModePropertiesKHR failed with " << getResultAsString(result)
450 << " for display " << display
451 << " reported items count " << countReported
452 << tcu::TestLog::EndMessage;
453
454 return false;
455 }
456
457 modeProperties.resize(countReported);
458
459 countRetrieved = countReported;
460
461 result = m_vki.getDisplayModePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
462 display, // VkDisplayKHR display
463 &countRetrieved, // uint32_t* pPropertyCount
464 &modeProperties[0]); // VkDisplayModePropertiesKHR* pProperties
465
466 if (result != VK_SUCCESS || countRetrieved > countReported)
467 {
468 m_log << tcu::TestLog::Message
469 << "vkGetDisplayModePropertiesKHR failed with " << getResultAsString(result)
470 << " for display " << display
471 << " reported items count " << countReported
472 << " retrieved items count " << countReported
473 << tcu::TestLog::EndMessage;
474
475 modeProperties.clear();
476
477 return false;
478 }
479
480 if (countRetrieved < countReported)
481 modeProperties.resize(countRetrieved);
482
483 return true;
484 }
485
486 /*--------------------------------------------------------------------*//*!
487 * \brief Fills vector with available displays. Clears passed vector at start.
488 *
489 * Uses VK_KHR_get_display_properties2 extension API.
490 * Clears passed vector at start.
491 *
492 * \param displays The vector filled with display handles
493 * \return true on success, false on error
494 *//*--------------------------------------------------------------------*/
getDisplays2(DisplayVector & displays)495 bool DisplayCoverageTestInstance::getDisplays2 (DisplayVector& displays)
496 {
497 deUint32 countReported = 0u;
498 deUint32 countRetrieved = 0u;
499 const VkDisplayPropertiesKHR displayProperties = {
500 DE_NULL, // VkDisplayKHR display
501 DE_NULL, // const char* displayName
502 {0, 0}, // VkExtent2D physicalDimensions
503 {0, 0}, // VkExtent2D physicalResolution
504 0, // VkSurfaceTransformFlagsKHR supportedTransforms
505 VK_FALSE, // VkBool32 planeReorderPossible
506 VK_FALSE // VkBool32 persistentContent
507 };
508 const VkDisplayProperties2KHR displayProperties2 = {
509 VK_STRUCTURE_TYPE_DISPLAY_PROPERTIES_2_KHR, // VkStructureType sType
510 DE_NULL, // void* pNext
511 displayProperties // VkDisplayPropertiesKHR displayProperties
512 };
513
514 std::vector<VkDisplayProperties2KHR> displaysProps;
515 VkResult result;
516
517 displays.clear();
518
519 result = m_vki.getPhysicalDeviceDisplayProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
520 &countReported, // uint32_t* pPropertyCount
521 DE_NULL); // VkDisplayProperties2KHR* pProperties
522
523 if (result != VK_SUCCESS)
524 {
525 m_log << tcu::TestLog::Message
526 << "vkGetPhysicalDeviceDisplayProperties2KHR failed with " << getResultAsString(result)
527 << " reported items count " << countReported
528 << tcu::TestLog::EndMessage;
529
530 return false;
531 }
532
533 displaysProps.resize(countReported, displayProperties2);
534
535 countRetrieved = countReported;
536
537 result = m_vki.getPhysicalDeviceDisplayProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
538 &countRetrieved, // uint32_t* pPropertyCount
539 &displaysProps[0]); // VkDisplayPropertiesKHR* pProperties
540
541 if (result != VK_SUCCESS || countRetrieved > countReported)
542 {
543 m_log << tcu::TestLog::Message
544 << "vkGetPhysicalDeviceDisplayProperties2KHR failed with " << getResultAsString(result)
545 << " reported items count " << countReported
546 << " retrieved items count " << countRetrieved
547 << tcu::TestLog::EndMessage;
548
549 return false;
550 }
551
552 displays.reserve(countRetrieved);
553
554 for (deUint32 displayIndex = 0;
555 displayIndex < countRetrieved;
556 displayIndex++)
557 {
558 const VkDisplayKHR display = displaysProps[displayIndex].displayProperties.display;
559
560 if (display == DE_NULL)
561 {
562 displays.clear();
563
564 return false;
565 }
566
567 displays.push_back(display);
568 }
569
570 return true;
571 }
572
573 /*--------------------------------------------------------------------*//*!
574 * \brief Fills vector with available modes properties for display specified.
575 *
576 * Uses VK_KHR_get_display_properties2 extension API.
577 * Clears passed vector at start and on error.
578 *
579 * \param display The display to get modes for
580 * \param modes The vector filled with display mode properties structures
581 * \return true on success, false on error
582 *//*--------------------------------------------------------------------*/
getDisplayModeProperties2(VkDisplayKHR display,DisplayModeProperties2Vector & modeProperties)583 bool DisplayCoverageTestInstance::getDisplayModeProperties2 (VkDisplayKHR display, DisplayModeProperties2Vector& modeProperties)
584 {
585 deUint32 countReported = 0u;
586 deUint32 countRetrieved = 0u;
587 const VkDisplayModePropertiesKHR displayModeProperties = {
588 DE_NULL, // VkDisplayModeKHR displayMode
589 { // VkDisplayModeParametersKHR parameters
590 {0, 0}, // VkExtent2D visibleRegion
591 0 // uint32_t refreshRate
592 }
593 };
594 const VkDisplayModeProperties2KHR displayModeProperties2 = {
595 VK_STRUCTURE_TYPE_DISPLAY_MODE_PROPERTIES_2_KHR, // VkStructureType sType
596 DE_NULL, // void* pNext
597 displayModeProperties // VkDisplayModePropertiesKHR displayModeProperties
598 };
599 VkResult result;
600
601 modeProperties.clear();
602
603 result = m_vki.getDisplayModeProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
604 display, // VkDisplayKHR display
605 &countReported, // uint32_t* pPropertyCount
606 DE_NULL); // VkDisplayModeProperties2KHR* pProperties
607
608 if (result != VK_SUCCESS)
609 {
610 m_log << tcu::TestLog::Message
611 << "vkGetDisplayModeProperties2KHR failed with " << getResultAsString(result)
612 << " for display " << display
613 << " reported items count " << countReported
614 << tcu::TestLog::EndMessage;
615
616 return false;
617 }
618
619 modeProperties.resize(countReported, displayModeProperties2);
620
621 countRetrieved = countReported;
622
623 result = m_vki.getDisplayModeProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
624 display, // VkDisplayKHR display
625 &countRetrieved, // uint32_t* pPropertyCount
626 &modeProperties[0]); // VkDisplayModeProperties2KHR* pProperties
627
628 if (result != VK_SUCCESS || countRetrieved > countReported)
629 {
630 m_log << tcu::TestLog::Message
631 << "vkGetDisplayModeProperties2KHR failed with " << getResultAsString(result)
632 << " for display " << display
633 << " reported items count " << countReported
634 << " retrieved items count " << countReported
635 << tcu::TestLog::EndMessage;
636
637 modeProperties.clear();
638
639 return false;
640 }
641
642 if (countRetrieved < countReported)
643 modeProperties.resize(countRetrieved);
644
645 return true;
646 }
647
648 /*--------------------------------------------------------------------*//*!
649 * \brief Validate display properties and report failures
650 * into results collector
651 *
652 * \param results Results collector
653 * \param toValidate Display properties to validate
654 * \param nonUpdated Display properties to compare with
655 *//*--------------------------------------------------------------------*/
validateDisplayProperties(tcu::ResultCollector & results,const VkDisplayPropertiesKHR & toValidate,const VkDisplayPropertiesKHR & nonUpdated)656 void DisplayCoverageTestInstance::validateDisplayProperties ( tcu::ResultCollector& results,
657 const VkDisplayPropertiesKHR& toValidate,
658 const VkDisplayPropertiesKHR& nonUpdated)
659 {
660 results.check( toValidate.display != nonUpdated.display,
661 "Invalid display handle");
662
663 results.check( toValidate.planeReorderPossible == VK_TRUE || toValidate.planeReorderPossible == VK_FALSE,
664 "planeReorderPossible neither VK_TRUE, nor VK_FALSE");
665
666 results.check( toValidate.persistentContent == VK_TRUE || toValidate.persistentContent == VK_FALSE,
667 "persistentContent neither VK_TRUE, nor VK_FALSE");
668
669 results.check( (toValidate.supportedTransforms & nonUpdated.supportedTransforms) == 0,
670 "supportedTransforms contains unrecognized flags");
671
672 // Outside specification, but resolution 0x0 pixels will break many applications
673 results.check( toValidate.physicalResolution.height != 0,
674 "physicalResolution.height cannot be zero");
675
676 // Outside specification, but resolution 0x0 pixels will break many applications
677 results.check( toValidate.physicalResolution.width != 0,
678 "physicalResolution.width cannot be zero");
679 }
680
681 /*--------------------------------------------------------------------*//*!
682 * \brief Validates display plane properties and report failures
683 * into results collector
684 *
685 * \param results Results collector
686 * \param toValidate Display plane properties to validate
687 * \param nonUpdated Display plane properties to compare with
688 * \param displaySet Set of valid display handles
689 *//*--------------------------------------------------------------------*/
validateDisplayPlaneProperties(tcu::ResultCollector & results,const VkDisplayPlanePropertiesKHR & toValidate,const VkDisplayPlanePropertiesKHR & nonUpdated,DisplaySet & displaySet)690 void DisplayCoverageTestInstance::validateDisplayPlaneProperties ( tcu::ResultCollector& results,
691 const VkDisplayPlanePropertiesKHR& toValidate,
692 const VkDisplayPlanePropertiesKHR& nonUpdated,
693 DisplaySet& displaySet)
694 {
695 const VkDisplayKHR currentDisplay = toValidate.currentDisplay;
696
697 results.check( toValidate.currentStackIndex < nonUpdated.currentStackIndex,
698 "CurrentStackIndex must be less than the number of planes reported " + de::toString(nonUpdated.currentStackIndex));
699
700 results.check( currentDisplay == DE_NULL || de::contains(displaySet, currentDisplay),
701 "Plane bound to invalid handle " + de::toString(toValidate.currentDisplay));
702 }
703
704 /*--------------------------------------------------------------------*//*!
705 * \brief Validate display plane capabilities and report failures
706 * into results collector
707 *
708 * \param results Results collector
709 * \param toValidate Display plane capabilities to validate
710 * \param nonUpdated Display plane capabilities to compare with
711 *//*--------------------------------------------------------------------*/
validateDisplayPlaneCapabilities(tcu::ResultCollector & results,const VkDisplayPlaneCapabilitiesKHR & toValidate,const VkDisplayPlaneCapabilitiesKHR & nonUpdated)712 void DisplayCoverageTestInstance::validateDisplayPlaneCapabilities ( tcu::ResultCollector& results,
713 const VkDisplayPlaneCapabilitiesKHR& toValidate,
714 const VkDisplayPlaneCapabilitiesKHR& nonUpdated)
715 {
716 results.check( (toValidate.supportedAlpha & nonUpdated.supportedAlpha) == 0,
717 "supportedAlpha contains unrecognized value");
718
719 results.check( toValidate.minSrcPosition.x >= 0,
720 "minSrcPosition.x >= 0");
721
722 results.check( toValidate.minSrcPosition.y >= 0,
723 "minSrcPosition.y >= 0");
724
725 results.check( toValidate.maxSrcPosition.x >= 0,
726 "maxSrcPosition.x >= 0");
727
728 results.check( toValidate.maxSrcPosition.y >= 0,
729 "maxSrcPosition.y >= 0");
730
731 results.check( toValidate.minSrcPosition.x <= toValidate.maxSrcPosition.x,
732 "minSrcPosition.x <= maxSrcPosition.x");
733
734 results.check( toValidate.minSrcPosition.y <= toValidate.maxSrcPosition.y,
735 "minSrcPosition.y <= maxSrcPosition.y");
736
737 results.check( toValidate.minDstPosition.x <= toValidate.maxDstPosition.x,
738 "minDstPosition.x <= maxDstPosition.x");
739
740 results.check( toValidate.minDstPosition.y <= toValidate.maxDstPosition.y,
741 "minDstPosition.y <= maxDstPosition.y");
742
743 results.check( toValidate.minSrcExtent.width <= toValidate.maxSrcExtent.width,
744 "minSrcExtent.width <= maxSrcExtent.width");
745
746 results.check( toValidate.minSrcExtent.height <= toValidate.maxSrcExtent.height,
747 "minSrcExtent.height <= maxSrcExtent.height");
748
749 results.check( toValidate.minDstExtent.width <= toValidate.maxDstExtent.width,
750 "minDstExtent.width <= maxDstExtent.width");
751
752 results.check( toValidate.minDstExtent.height <= toValidate.maxDstExtent.height,
753 "minDstExtent.height <= maxDstExtent.height");
754 }
755
756 /*--------------------------------------------------------------------*//*!
757 * \brief Validate display mode properties and report failures
758 * into results collector
759 *
760 * \param results Results collector
761 * \param toValidate Display mode properties to validate
762 * \param nonUpdated Display mode properties to compare with
763 *//*--------------------------------------------------------------------*/
validateDisplayModeProperties(tcu::ResultCollector & results,const VkDisplayModePropertiesKHR & toValidate,const VkDisplayModePropertiesKHR & nonUpdated)764 void DisplayCoverageTestInstance::validateDisplayModeProperties ( tcu::ResultCollector& results,
765 const VkDisplayModePropertiesKHR& toValidate,
766 const VkDisplayModePropertiesKHR& nonUpdated)
767 {
768 results.check( toValidate.displayMode != nonUpdated.displayMode,
769 "Invalid mode display handle reported");
770 }
771
772 /*--------------------------------------------------------------------*//*!
773 * \brief Display enumeration coverage test
774 *
775 * Throws ResourceError exception in case no displays available.
776 * Throws an exception on fail.
777 *
778 * \return tcu::TestStatus::pass on success
779 *//*--------------------------------------------------------------------*/
testGetPhysicalDeviceDisplayPropertiesKHR(void)780 tcu::TestStatus DisplayCoverageTestInstance::testGetPhysicalDeviceDisplayPropertiesKHR (void)
781 {
782 deUint32 displayCountReported = 0u;
783 deUint32 displayCountToTest = 0u;
784 tcu::ResultCollector results (m_log);
785 VkResult result;
786
787 result = m_vki.getPhysicalDeviceDisplayPropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
788 &displayCountReported, // uint32_t* pPropertyCount
789 DE_NULL); // VkDisplayPropertiesKHR* pProperties
790
791 if ( result != VK_SUCCESS
792 && result != VK_INCOMPLETE
793 && result != VK_ERROR_OUT_OF_HOST_MEMORY
794 && result != VK_ERROR_OUT_OF_DEVICE_MEMORY
795 )
796 {
797 TCU_FAIL_STR(string("Invalid result ") + getResultAsString(result));
798 }
799
800 if (result != VK_SUCCESS)
801 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
802
803 if (displayCountReported == 0)
804 TCU_THROW(NotSupportedError, std::string("Cannot perform test: no displays found").c_str());
805
806 displayCountToTest = displayCountReported;
807 if (displayCountReported > MAX_TESTED_DISPLAY_COUNT)
808 {
809 m_log << tcu::TestLog::Message
810 << "Number of displays reported is too high " << displayCountReported
811 << ". Test is limited to " << MAX_TESTED_DISPLAY_COUNT
812 << tcu::TestLog::EndMessage;
813
814 displayCountToTest = MAX_TESTED_DISPLAY_COUNT;
815 }
816
817 // Test the call correctly writes data in various size arrays
818 for (deUint32 displayCountRequested = 0;
819 displayCountRequested < displayCountToTest + 2;
820 displayCountRequested++)
821 {
822 const deUint32 displayCountExpected = std::min(displayCountRequested, displayCountReported);
823 const VkDisplayPropertiesKHR invalidDisplayProps = { // Most values are set to fail the test to make sure driver updates these
824 DE_NULL, // VkDisplayKHR display;
825 DE_NULL, // const char* displayName;
826 {0, 0}, // VkExtent2D physicalDimensions;
827 {0, 0}, // VkExtent2D physicalResolution;
828 ~RECOGNIZED_SURFACE_TRANSFORM_FLAGS, // VkSurfaceTransformFlagsKHR supportedTransforms;
829 (vk::VkBool32)(VK_TRUE + 1), // VkBool32 planeReorderPossible;
830 (vk::VkBool32)(VK_TRUE + 1) // VkBool32 persistentContent;
831 };
832 const VkDisplayKHR canaryDisplay = static_cast<VkDisplayKHR>(0xABCDEF11);
833 const deUint32 canaryItemCount = 1;
834 std::vector<VkDisplayPropertiesKHR> displaysProps (displayCountRequested + canaryItemCount, invalidDisplayProps);
835 deUint32 displayCountRetrieved = displayCountRequested;
836 DisplaySet displaySet;
837
838 displaysProps[displayCountExpected].display = canaryDisplay;
839
840 result = m_vki.getPhysicalDeviceDisplayPropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
841 &displayCountRetrieved, // uint32_t* pPropertyCount
842 &displaysProps[0]); // VkDisplayPropertiesKHR* pProperties
843
844 // Check amount of data written equals to expected
845 if (displayCountRetrieved != displayCountExpected)
846 TCU_FAIL_STR( string("displayCountRetrieved != displayCountExpected, ") +
847 de::toString(displayCountRetrieved) + " != " + de::toString(displayCountExpected));
848
849 if (displayCountRequested >= displayCountReported)
850 {
851 if (result != VK_SUCCESS)
852 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
853 }
854 else
855 {
856 if (result != VK_INCOMPLETE)
857 TCU_FAIL_STR(string("Expected VK_INCOMPLETE. Have ") + getResultAsString(result));
858 }
859
860 // Check the driver has written something
861 for (deUint32 displayIndex = 0;
862 displayIndex < displayCountRetrieved;
863 displayIndex++)
864 {
865 displaySet.insert(displaysProps[displayIndex].display);
866
867 results.check( displaysProps[displayIndex].display != invalidDisplayProps.display,
868 "Invalid display handle for display number " + de::toString(displayIndex));
869
870 results.check( displaysProps[displayIndex].planeReorderPossible == VK_TRUE || displaysProps[displayIndex].planeReorderPossible == VK_FALSE,
871 "planeReorderPossible neither VK_TRUE, nor VK_FALSE");
872
873 results.check( displaysProps[displayIndex].persistentContent == VK_TRUE || displaysProps[displayIndex].persistentContent == VK_FALSE,
874 "persistentContent neither VK_TRUE, nor VK_FALSE");
875
876 results.check( (displaysProps[displayIndex].supportedTransforms & invalidDisplayProps.supportedTransforms) == 0,
877 "supportedTransforms contains unrecognized flags");
878
879 // Outside specification, but resolution 0x0 pixels will break many applications
880 results.check( displaysProps[displayIndex].physicalResolution.height != 0,
881 "physicalResolution.height cannot be zero");
882
883 // Outside specification, but resolution 0x0 pixels will break many applications
884 results.check( displaysProps[displayIndex].physicalResolution.width != 0,
885 "physicalResolution.width cannot be zero");
886
887 if (results.getResult() != QP_TEST_RESULT_PASS)
888 {
889 m_log << tcu::TestLog::Message
890 << "Error detected " << results.getMessage()
891 << " for display " << displayIndex << " with properties " << displaysProps[displayIndex]
892 << " invalid display properties are " << invalidDisplayProps
893 << tcu::TestLog::EndMessage;
894
895 TCU_FAIL_STR(results.getMessage());
896 }
897 }
898
899 // Check the driver has not written more than requested
900 if (displaysProps[displayCountExpected].display != canaryDisplay)
901 TCU_FAIL("Memory damage detected: driver has written more than expected");
902
903 // Check display handle uniqueness
904 if (displaySet.size() != displayCountRetrieved)
905 TCU_FAIL("Display handle duplication detected");
906 }
907
908 return tcu::TestStatus::pass("pass");
909 }
910
911 /*--------------------------------------------------------------------*//*!
912 * \brief Plane enumeration coverage test
913 *
914 * Throws an exception on fail.
915 *
916 * \return tcu::TestStatus::pass on success
917 *//*--------------------------------------------------------------------*/
testGetPhysicalDeviceDisplayPlanePropertiesKHR(void)918 tcu::TestStatus DisplayCoverageTestInstance::testGetPhysicalDeviceDisplayPlanePropertiesKHR (void)
919 {
920 DisplayVector displaysVector;
921 DisplaySet displaySet;
922 deUint32 planeCountReported = 0u;
923 deUint32 planeCountTested = 0u;
924 tcu::ResultCollector results (m_log);
925 VkResult result;
926
927 // Create a list of displays available
928 if (!getDisplays(displaysVector))
929 TCU_FAIL("Failed to retrieve displays");
930
931 if (displaysVector.empty())
932 TCU_THROW(NotSupportedError, "No displays reported");
933
934 displaySet = DisplaySet(displaysVector.begin(), displaysVector.end());
935
936 // Get planes to test
937 result = m_vki.getPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
938 &planeCountReported, // uint32_t* pPropertyCount
939 DE_NULL); // VkDisplayPlanePropertiesKHR* pProperties
940
941 if ( result != VK_SUCCESS
942 && result != VK_INCOMPLETE
943 && result != VK_ERROR_OUT_OF_HOST_MEMORY
944 && result != VK_ERROR_OUT_OF_DEVICE_MEMORY
945 )
946 {
947 TCU_FAIL_STR(string("Invalid result ") + getResultAsString(result));
948 }
949
950 if (result != VK_SUCCESS)
951 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
952
953 if (planeCountReported == 0)
954 TCU_THROW(ResourceError, "Cannot perform test: no planes found");
955
956 planeCountTested = planeCountReported;
957 if (planeCountReported > MAX_TESTED_PLANE_COUNT)
958 {
959 m_log << tcu::TestLog::Message
960 << "Number of planes reported is too high " << planeCountReported
961 << ". Test is limited to " << MAX_TESTED_PLANE_COUNT
962 << tcu::TestLog::EndMessage;
963
964 planeCountTested = MAX_TESTED_PLANE_COUNT;
965 }
966
967 // Test the call correctly writes data in various size arrays
968 for (deUint32 planeCountRequested = 0;
969 planeCountRequested < planeCountTested + 2;
970 planeCountRequested++)
971 {
972 const deUint32 planeCountExpected = std::min(planeCountRequested, planeCountReported);
973 const VkDisplayPlanePropertiesKHR invalidPlaneProps = { // Most values are set to fail the test to make sure driver updates these
974 DE_NULL, // VkDisplayKHR currentDisplay
975 DEUINT32_MAX // deUint32 currentStackIndex
976 };
977 const VkDisplayKHR canaryDisplay = static_cast<VkDisplayKHR>(0xABCDEF11);
978 const deUint32 canaryItemCount = 1;
979 std::vector<VkDisplayPlanePropertiesKHR> planeProps (planeCountRequested + canaryItemCount, invalidPlaneProps);
980 deUint32 planeCountRetrieved = planeCountRequested;
981
982 planeProps[planeCountExpected].currentDisplay = canaryDisplay;
983
984 result = m_vki.getPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
985 &planeCountRetrieved, // uint32_t* pPropertyCount
986 &planeProps[0]); // VkDisplayPlanePropertiesKHR* pProperties
987
988 // Check amount of data written equals to expected
989 if (planeCountRetrieved != planeCountExpected)
990 TCU_FAIL_STR( string("planeCountRetrieved != planeCountExpected, ") +
991 de::toString(planeCountRetrieved) + " != " + de::toString(planeCountExpected));
992
993 if (planeCountRequested >= planeCountReported)
994 {
995 if (result != VK_SUCCESS)
996 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
997 }
998 else
999 {
1000 if (result != VK_INCOMPLETE)
1001 TCU_FAIL_STR(string("Expected VK_INCOMPLETE. Have ") + getResultAsString(result));
1002 }
1003
1004 // Check the driver has written something
1005 for (deUint32 planeIndex = 0;
1006 planeIndex < planeCountRetrieved;
1007 planeIndex++)
1008 {
1009 const VkDisplayKHR currentDisplay = planeProps[planeIndex].currentDisplay;
1010
1011 results.check( planeProps[planeIndex].currentStackIndex < planeCountReported,
1012 "CurrentStackIndex must be less than the number of planes reported " + de::toString(planeCountReported));
1013
1014 results.check( currentDisplay == DE_NULL || de::contains(displaySet, currentDisplay),
1015 "Plane bound to invalid handle " + de::toString(currentDisplay));
1016
1017 if (results.getResult() != QP_TEST_RESULT_PASS)
1018 {
1019 m_log << tcu::TestLog::Message
1020 << "Error detected " << results.getMessage()
1021 << " for plane " << planeIndex << " with properties " << planeProps[planeIndex]
1022 << tcu::TestLog::EndMessage;
1023
1024 TCU_FAIL_STR(results.getMessage());
1025 }
1026 }
1027
1028 // Check the driver has not written more than requested
1029 if (planeProps[planeCountExpected].currentDisplay != canaryDisplay)
1030 TCU_FAIL("Memory damage detected: driver has written more than expected");
1031 }
1032
1033 return tcu::TestStatus::pass("pass");
1034 }
1035
1036 /*--------------------------------------------------------------------*//*!
1037 * \brief Display plane support coverage test
1038 *
1039 * Throws an exception on fail.
1040 *
1041 * \return tcu::TestStatus::pass on success
1042 *//*--------------------------------------------------------------------*/
testGetDisplayPlaneSupportedDisplaysKHR(void)1043 tcu::TestStatus DisplayCoverageTestInstance::testGetDisplayPlaneSupportedDisplaysKHR (void)
1044 {
1045 deUint32 planeCountReported = 0u;
1046 deUint32 planeCountTested = 0u;
1047 VkResult result;
1048 DisplayVector displaysVector;
1049 DisplaySet displaySet;
1050
1051 if (!getDisplays(displaysVector))
1052 TCU_FAIL("Failed to retrieve displays");
1053
1054 if (displaysVector.empty())
1055 TCU_THROW(NotSupportedError, "No displays reported");
1056
1057 displaySet = DisplaySet(displaysVector.begin(), displaysVector.end());
1058
1059 result = m_vki.getPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1060 &planeCountReported, // uint32_t* pPropertyCount
1061 DE_NULL); // VkDisplayPlanePropertiesKHR* pProperties
1062
1063 if ( result != VK_SUCCESS
1064 && result != VK_INCOMPLETE
1065 && result != VK_ERROR_OUT_OF_HOST_MEMORY
1066 && result != VK_ERROR_OUT_OF_DEVICE_MEMORY
1067 )
1068 {
1069 TCU_FAIL_STR(string("Invalid result ") + getResultAsString(result));
1070 }
1071
1072 if (result != VK_SUCCESS)
1073 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1074
1075 if (planeCountReported == 0)
1076 TCU_THROW(ResourceError, "Cannot perform test: no planes supported");
1077
1078 planeCountTested = planeCountReported;
1079 if (planeCountReported > MAX_TESTED_PLANE_COUNT)
1080 {
1081 m_log << tcu::TestLog::Message
1082 << "Number of planes reported is too high " << planeCountReported
1083 << ". Test is limited to " << MAX_TESTED_PLANE_COUNT
1084 << tcu::TestLog::EndMessage;
1085
1086 planeCountTested = MAX_TESTED_PLANE_COUNT;
1087 }
1088
1089 for (deUint32 planeIndex = 0;
1090 planeIndex < planeCountTested;
1091 planeIndex++)
1092 {
1093 deUint32 displayCountReported = 0u;
1094
1095 result = m_vki.getDisplayPlaneSupportedDisplaysKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1096 planeIndex, // uint32_t planeIndex
1097 &displayCountReported, // uint32_t* pDisplayCount
1098 DE_NULL); // VkDisplayKHR* pDisplays
1099
1100 if (result != VK_SUCCESS)
1101 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1102
1103 // Test the call correctly writes data in various size arrays
1104 for (deUint32 displayCountRequested = 0;
1105 displayCountRequested < displayCountReported + 2;
1106 displayCountRequested++)
1107 {
1108 const deUint32 displayCountExpected = std::min(displayCountRequested, displayCountReported);
1109 const VkDisplayKHR nullDisplay = DE_NULL;
1110 const VkDisplayKHR canaryDisplay = static_cast<VkDisplayKHR>(0xABCDEF11);
1111 const deUint32 canaryItemCount = 1;
1112 std::vector<VkDisplayKHR> displaysForPlane (displayCountRequested + canaryItemCount, nullDisplay);
1113 deUint32 displayCountRetrieved = displayCountRequested;
1114
1115 displaysForPlane[displayCountExpected] = canaryDisplay;
1116
1117 result = m_vki.getDisplayPlaneSupportedDisplaysKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1118 planeIndex, // uint32_t planeIndex
1119 &displayCountRetrieved, // uint32_t* pDisplayCount
1120 &displaysForPlane[0]); // VkDisplayKHR* pDisplays
1121
1122 // Check amount of data written equals to expected
1123 if (displayCountRetrieved != displayCountExpected)
1124 TCU_FAIL_STR( string("displayCountRetrieved != displayCountExpected, ") +
1125 de::toString(displayCountRetrieved) + " != " + de::toString(displayCountExpected));
1126
1127 if (displayCountRequested >= displayCountReported)
1128 {
1129 if (result != VK_SUCCESS)
1130 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1131 }
1132 else
1133 {
1134 if (result != VK_INCOMPLETE)
1135 TCU_FAIL_STR(string("Expected VK_INCOMPLETE. Have ") + getResultAsString(result));
1136 }
1137
1138 // Check the driver has written something
1139 for (deUint32 displayIndex = 0;
1140 displayIndex < displayCountExpected;
1141 displayIndex++)
1142 {
1143 const VkDisplayKHR display = displaysForPlane[displayIndex];
1144
1145 if (display != nullDisplay)
1146 {
1147 if (!de::contains(displaySet, display))
1148 {
1149 TCU_FAIL_STR("Invalid display handle " + de::toString(display));
1150 }
1151 }
1152 }
1153
1154 // Check the driver has not written more than requested
1155 if (displaysForPlane[displayCountExpected] != canaryDisplay)
1156 TCU_FAIL("Memory damage detected: driver has written more than expected");
1157 }
1158 }
1159
1160 return tcu::TestStatus::pass("pass");
1161 }
1162
1163 /*--------------------------------------------------------------------*//*!
1164 * \brief Display mode properties coverage test
1165 *
1166 * Throws an exception on fail.
1167 *
1168 * \return tcu::TestStatus::pass on success
1169 *//*--------------------------------------------------------------------*/
testGetDisplayModePropertiesKHR(void)1170 tcu::TestStatus DisplayCoverageTestInstance::testGetDisplayModePropertiesKHR (void)
1171 {
1172 VkResult result;
1173 DisplayVector displaysVector;
1174
1175 if (!getDisplays(displaysVector))
1176 TCU_FAIL("Failed to retrieve displays list");
1177
1178 if (displaysVector.empty())
1179 TCU_THROW(NotSupportedError, "No displays reported");
1180
1181 for (DisplayVector::iterator it = displaysVector.begin();
1182 it != displaysVector.end();
1183 it++)
1184 {
1185 VkDisplayKHR display = *it;
1186 deUint32 modesCountReported = 0u;
1187
1188 result = m_vki.getDisplayModePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1189 display, // VkDisplayKHR display
1190 &modesCountReported, // uint32_t* pPropertyCount
1191 DE_NULL); // VkDisplayModePropertiesKHR* pProperties
1192
1193 // Test the call correctly writes data in various size arrays
1194 for (deUint32 modesCountRequested = 0;
1195 modesCountRequested < modesCountReported + 2;
1196 modesCountRequested = nextTestNumber(modesCountRequested, modesCountReported + 2))
1197 {
1198 const deUint32 modesCountExpected = std::min(modesCountRequested, modesCountReported);
1199 const VkDisplayModeKHR nullDisplayMode = DE_NULL;
1200 const VkDisplayModePropertiesKHR nullMode = {
1201 nullDisplayMode, // VkDisplayModeKHR displayMode
1202 { // VkDisplayModeParametersKHR parameters
1203 {0, 0}, // VkExtent2D visibleRegion
1204 0 // uint32_t refreshRate
1205 }
1206 };
1207 const VkDisplayModeKHR canaryDisplayMode = static_cast<VkDisplayModeKHR>(0xABCDEF11);
1208 const deUint32 canaryItemCount = 1;
1209 std::vector<VkDisplayModePropertiesKHR> modesForDisplay (modesCountRequested + canaryItemCount, nullMode);
1210 deUint32 modesCountRetrieved = modesCountRequested;
1211
1212 modesForDisplay[modesCountExpected].displayMode = canaryDisplayMode;
1213
1214 result = m_vki.getDisplayModePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1215 display, // VkDisplayKHR display
1216 &modesCountRetrieved, // uint32_t* pPropertyCount
1217 &modesForDisplay[0]); // VkDisplayModePropertiesKHR* pProperties
1218
1219 // Check amount of data written equals to expected
1220 if (modesCountRetrieved != modesCountExpected)
1221 TCU_FAIL_STR( string("modesCountRetrieved != modesCountExpected, ") +
1222 de::toString(modesCountRetrieved) + " != " + de::toString(modesCountExpected));
1223
1224 if (modesCountRequested >= modesCountReported)
1225 {
1226 if (result != VK_SUCCESS)
1227 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1228 }
1229 else
1230 {
1231 if (result != VK_INCOMPLETE)
1232 TCU_FAIL_STR(string("Expected VK_INCOMPLETE. Have ") + getResultAsString(result));
1233 }
1234
1235 // Check the driver has written something
1236 for (deUint32 modeIndex = 0;
1237 modeIndex < modesCountExpected;
1238 modeIndex++)
1239 {
1240 const VkDisplayModePropertiesKHR theModeProperties = modesForDisplay[modeIndex];
1241
1242 if (theModeProperties.displayMode == nullMode.displayMode)
1243 TCU_FAIL_STR("Invalid mode display handle reported for display " + de::toString(display));
1244 }
1245
1246 // Check the driver has not written more than requested
1247 if (modesForDisplay[modesCountExpected].displayMode != canaryDisplayMode)
1248 TCU_FAIL("Memory damage detected: driver has written more than expected");
1249 }
1250 }
1251
1252 return tcu::TestStatus::pass("pass");
1253 }
1254
1255 /*--------------------------------------------------------------------*//*!
1256 * \brief Create display mode coverage test
1257 *
1258 * Throws an exception on fail.
1259 *
1260 * \return tcu::TestStatus::pass on success
1261 *//*--------------------------------------------------------------------*/
testCreateDisplayModeKHR(void)1262 tcu::TestStatus DisplayCoverageTestInstance::testCreateDisplayModeKHR (void)
1263 {
1264 DisplayVector displaysVector;
1265 VkResult result;
1266
1267 if (!getDisplays(displaysVector))
1268 TCU_FAIL("Failed to retrieve displays");
1269
1270 if (displaysVector.empty())
1271 TCU_THROW(NotSupportedError, "No displays reported");
1272
1273 for (DisplayVector::iterator it = displaysVector.begin();
1274 it != displaysVector.end();
1275 it++)
1276 {
1277 const VkDisplayKHR display = *it;
1278 DisplayModePropertiesVector::size_type builtinModesCount = 0u;
1279 VkDisplayModePropertiesKHR validModeProperties;
1280 VkDisplayModeKHR mode = DE_NULL;
1281 DisplayModePropertiesVector modes;
1282 VkDisplayModeCreateInfoKHR createInfo = {
1283 VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR, // VkStructureType sType
1284 DE_NULL, // const void* pNext
1285 0, // VkDisplayModeCreateFlagsKHR flags
1286 { // VkDisplayModeParametersKHR parameters
1287 {0, 0}, // VkExtent2D visibleRegion
1288 0 // uint32_t refreshRate
1289 }
1290 };
1291
1292 if (!getDisplayModeProperties(display, modes))
1293 TCU_FAIL("Failed to retrieve display mode properties");
1294
1295 if (modes.size() < 1)
1296 TCU_FAIL("At least one mode expected to be returned");
1297
1298 // Builtin mode count should not be updated with a new mode. Get initial builtin mode count
1299 builtinModesCount = modes.size();
1300
1301 // Assume first available builtin mode as a valid mode sample
1302 validModeProperties = modes[0];
1303
1304 // Do negative test by making one of parameters unacceptable
1305 for (deUint32 testIndex = 0;
1306 testIndex < 3;
1307 testIndex++)
1308 {
1309 VkDisplayModeCreateInfoKHR createInfoFail (createInfo);
1310 VkDisplayModeKHR modeFail = DE_NULL;
1311
1312 createInfoFail.parameters = validModeProperties.parameters;
1313
1314 switch (testIndex)
1315 {
1316 case 0: createInfoFail.parameters.refreshRate = 0; break;
1317 case 1: createInfoFail.parameters.visibleRegion.width = 0; break;
1318 case 2: createInfoFail.parameters.visibleRegion.height = 0; break;
1319 default: DE_FATAL("Impossible"); break;
1320 }
1321
1322 result = m_vki.createDisplayModeKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1323 display, // VkDisplayKHR display
1324 &createInfoFail, // const VkDisplayModeCreateInfoKHR* pCreateInfo
1325 DE_NULL, // const VkAllocationCallbacks* pAllocator
1326 &modeFail); // VkDisplayModeKHR* pMode
1327
1328 if (result != VK_ERROR_INITIALIZATION_FAILED)
1329 TCU_FAIL_STR(string("Expected VK_ERROR_INITIALIZATION_FAILED. Have ") + getResultAsString(result));
1330
1331 if (modeFail != DE_NULL)
1332 TCU_FAIL("Mode should be kept invalid on fail");
1333 }
1334
1335 // At last create valid display mode
1336 createInfo.parameters = validModeProperties.parameters;
1337
1338 result = m_vki.createDisplayModeKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1339 display, // VkDisplayKHR display
1340 &createInfo, // const VkDisplayModeCreateInfoKHR* pCreateInfo
1341 DE_NULL, // const VkAllocationCallbacks* pAllocator
1342 &mode); // VkDisplayModeKHR* pMode
1343
1344 if (result != VK_SUCCESS)
1345 TCU_FAIL_STR("Expected VK_SUCCESS. Have " + getResultAsString(result));
1346
1347 if (mode == DE_NULL)
1348 TCU_FAIL("Valid handle expected");
1349
1350 // Builtin mode count should not be updated with a new mode
1351 modes.clear();
1352
1353 if (!getDisplayModeProperties(display, modes))
1354 TCU_FAIL("Failed to retrieve display mode properties");
1355
1356 if (builtinModesCount != modes.size())
1357 TCU_FAIL_STR( string("Mode count has changed from ") + de::toString(builtinModesCount) +
1358 string(" to ") + de::toString(modes.size()));
1359 }
1360
1361 return tcu::TestStatus::pass("pass");
1362 }
1363
1364 /*--------------------------------------------------------------------*//*!
1365 * \brief Display-plane capabilities coverage test
1366 *
1367 * Throws an exception on fail.
1368 *
1369 * \return tcu::TestStatus::pass on success
1370 *//*--------------------------------------------------------------------*/
testGetDisplayPlaneCapabilitiesKHR(void)1371 tcu::TestStatus DisplayCoverageTestInstance::testGetDisplayPlaneCapabilitiesKHR (void)
1372 {
1373 deUint32 planeCountReported = 0u;
1374 VkResult result;
1375
1376 result = m_vki.getPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1377 &planeCountReported, // uint32_t* pPropertyCount
1378 DE_NULL); // VkDisplayPlanePropertiesKHR* pProperties
1379
1380 if (result != VK_SUCCESS)
1381 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1382
1383 if (planeCountReported == 0)
1384 {
1385 DisplayVector displaysVector;
1386
1387 // If we don't have any displays then it's alright to have no planes, as
1388 // per the Vulkan Spec:
1389 // Devices must support at least one plane on each display
1390 if (!getDisplays(displaysVector))
1391 TCU_FAIL("Failed to retrieve displays");
1392
1393 if (displaysVector.empty())
1394 TCU_THROW(NotSupportedError, "No display planes reported");
1395
1396 TCU_FAIL("No planes defined");
1397 }
1398
1399 if (planeCountReported > MAX_TESTED_PLANE_COUNT)
1400 {
1401 m_log << tcu::TestLog::Message
1402 << "Number of planes reported is too high " << planeCountReported
1403 << ". Test is limited to " << MAX_TESTED_PLANE_COUNT
1404 << tcu::TestLog::EndMessage;
1405
1406 planeCountReported = MAX_TESTED_PLANE_COUNT;
1407 }
1408
1409 for (deUint32 planeIndex = 0;
1410 planeIndex < planeCountReported;
1411 planeIndex++)
1412 {
1413 std::vector<VkDisplayKHR> displaysForPlane;
1414
1415 if (!getDisplaysForPlane(planeIndex, displaysForPlane))
1416 TCU_FAIL_STR("Failed to retrieve displays list for plane " + de::toString(planeIndex));
1417
1418 if (displaysForPlane.empty())
1419 continue;
1420
1421 // Check the driver has written something
1422 for (deUint32 displayIndex = 0;
1423 displayIndex < displaysForPlane.size();
1424 displayIndex++)
1425 {
1426 const VkDisplayKHR display = displaysForPlane[displayIndex];
1427 std::vector<VkDisplayModePropertiesKHR> modesPropertiesForDisplay;
1428
1429 if (!getDisplayModeProperties(display, modesPropertiesForDisplay))
1430 TCU_FAIL("Failed to retrieve display mode properties");
1431
1432 for (deUint32 modeIndex = 0;
1433 modeIndex < modesPropertiesForDisplay.size();
1434 modeIndex++)
1435 {
1436 const VkDisplayModeKHR theDisplayMode = modesPropertiesForDisplay[modeIndex].displayMode;
1437 const deUint32 unrecognizedAlphaFlags = ~RECOGNIZED_DISPLAY_PLANE_ALPHA_FLAGS;
1438 VkDisplayPlaneCapabilitiesKHR planeCapabilities = {
1439 unrecognizedAlphaFlags, // VkDisplayPlaneAlphaFlagsKHR supportedAlpha;
1440 { -1, -1 }, // VkOffset2D minSrcPosition;
1441 { -1, -1 }, // VkOffset2D maxSrcPosition;
1442 { 1, 1 }, // VkExtent2D minSrcExtent;
1443 { 0, 0 }, // VkExtent2D maxSrcExtent;
1444 { 1, 1 }, // VkOffset2D minDstPosition;
1445 { 0, 0 }, // VkOffset2D maxDstPosition;
1446 { 1, 1 }, // VkExtent2D minDstExtent;
1447 { 0, 0 }, // VkExtent2D maxDstExtent;
1448 };
1449 tcu::ResultCollector results (m_log);
1450
1451 result = m_vki.getDisplayPlaneCapabilitiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1452 theDisplayMode, // VkDisplayModeKHR mode
1453 planeIndex, // uint32_t planeIndex
1454 &planeCapabilities); // VkDisplayPlaneCapabilitiesKHR* pCapabilities
1455
1456 results.check( result == VK_SUCCESS,
1457 string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1458
1459 results.check( (planeCapabilities.supportedAlpha & unrecognizedAlphaFlags) == 0,
1460 "supportedAlpha contains unrecognized value");
1461
1462 results.check( planeCapabilities.minSrcPosition.x >= 0,
1463 "minSrcPosition.x >= 0");
1464
1465 results.check( planeCapabilities.minSrcPosition.y >= 0,
1466 "minSrcPosition.y >= 0");
1467
1468 results.check( planeCapabilities.maxSrcPosition.x >= 0,
1469 "maxSrcPosition.x >= 0");
1470
1471 results.check( planeCapabilities.maxSrcPosition.y >= 0,
1472 "maxSrcPosition.y >= 0");
1473
1474 results.check( planeCapabilities.minSrcPosition.x <= planeCapabilities.maxSrcPosition.x,
1475 "minSrcPosition.x <= maxSrcPosition.x");
1476
1477 results.check( planeCapabilities.minSrcPosition.y <= planeCapabilities.maxSrcPosition.y,
1478 "minSrcPosition.y <= maxSrcPosition.y");
1479
1480 results.check( planeCapabilities.minDstPosition.x <= planeCapabilities.maxDstPosition.x,
1481 "minDstPosition.x <= maxDstPosition.x");
1482
1483 results.check( planeCapabilities.minDstPosition.y <= planeCapabilities.maxDstPosition.y,
1484 "minDstPosition.y <= maxDstPosition.y");
1485
1486 results.check( planeCapabilities.minSrcExtent.width <= planeCapabilities.maxSrcExtent.width,
1487 "minSrcExtent.width <= maxSrcExtent.width");
1488
1489 results.check( planeCapabilities.minSrcExtent.height <= planeCapabilities.maxSrcExtent.height,
1490 "minSrcExtent.height <= maxSrcExtent.height");
1491
1492 results.check( planeCapabilities.minDstExtent.width <= planeCapabilities.maxDstExtent.width,
1493 "minDstExtent.width <= maxDstExtent.width");
1494
1495 results.check( planeCapabilities.minDstExtent.height <= planeCapabilities.maxDstExtent.height,
1496 "minDstExtent.height <= maxDstExtent.height");
1497
1498 if (results.getResult() != QP_TEST_RESULT_PASS)
1499 {
1500 m_log << tcu::TestLog::Message
1501 << "Error detected " << results.getMessage()
1502 << " for plane's " << planeIndex
1503 << " display " << displayIndex
1504 << " and mode " << modeIndex
1505 << " with capabilities " << planeCapabilities
1506 << tcu::TestLog::EndMessage;
1507
1508 TCU_FAIL_STR(results.getMessage());
1509 }
1510
1511 }
1512 }
1513 }
1514
1515 return tcu::TestStatus::pass("pass");
1516 }
1517
1518 /*--------------------------------------------------------------------*//*!
1519 * \brief Create display plane surface coverage test
1520 *
1521 * Throws an exception on fail.
1522 *
1523 * \return tcu::TestStatus::pass on success
1524 *//*--------------------------------------------------------------------*/
testCreateDisplayPlaneSurfaceKHR(void)1525 tcu::TestStatus DisplayCoverageTestInstance::testCreateDisplayPlaneSurfaceKHR (void)
1526 {
1527 deUint32 planeCountReported = 0u;
1528 deUint32 planeCountTested = 0u;
1529 deUint32 planeCountRetrieved = 0u;
1530 std::vector<VkDisplayPlanePropertiesKHR> planeProperties;
1531 bool testPerformed = false;
1532 DisplayVector displaysVector;
1533 VkResult result;
1534
1535 // Get displays
1536 if (!getDisplays(displaysVector))
1537 TCU_FAIL("Failed to retrieve displays");
1538
1539 if (displaysVector.empty())
1540 TCU_THROW(NotSupportedError, "No displays reported");
1541
1542 // Get planes
1543 result = m_vki.getPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1544 &planeCountReported, // uint32_t* pPropertyCount
1545 DE_NULL); // VkDisplayPlanePropertiesKHR* pProperties
1546
1547 if (result != VK_SUCCESS)
1548 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1549
1550 if (planeCountReported == 0)
1551 TCU_FAIL("No planes defined");
1552
1553 planeCountTested = planeCountReported;
1554 if (planeCountReported > MAX_TESTED_PLANE_COUNT)
1555 {
1556 m_log << tcu::TestLog::Message
1557 << "Number of planes reported is too high " << planeCountReported
1558 << ". Test is limited to " << MAX_TESTED_PLANE_COUNT
1559 << tcu::TestLog::EndMessage;
1560
1561 planeCountTested = MAX_TESTED_PLANE_COUNT;
1562 }
1563
1564 planeProperties.resize(planeCountTested);
1565 planeCountRetrieved = planeCountTested;
1566
1567 result = m_vki.getPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1568 &planeCountRetrieved, // uint32_t* pPropertyCount
1569 &planeProperties[0]); // VkDisplayPlanePropertiesKHR* pProperties
1570
1571 if (result != VK_SUCCESS && result != VK_INCOMPLETE )
1572 TCU_FAIL_STR(string("Expected VK_SUCCESS or VK_INCOMPLETE expected. Have ") + getResultAsString(result));
1573
1574 if (planeCountRetrieved != planeCountTested)
1575 TCU_FAIL_STR( string("Number of planes requested (") + de::toString(planeCountTested) +
1576 ") does not match retrieved (" + de::toString(planeCountRetrieved) + ")");
1577
1578 // Iterate through displays-modes
1579 for (DisplayVector::iterator it = displaysVector.begin();
1580 it != displaysVector.end();
1581 it++)
1582 {
1583 const VkDisplayKHR display = *it;
1584 std::vector<VkDisplayModePropertiesKHR> modesPropertiesForDisplay;
1585
1586 if (!getDisplayModeProperties(display, modesPropertiesForDisplay))
1587 TCU_FAIL("Failed to retrieve display mode properties");
1588
1589 for (deUint32 modeIndex = 0;
1590 modeIndex < modesPropertiesForDisplay.size();
1591 modeIndex++)
1592 {
1593 const VkDisplayModeKHR displayMode = modesPropertiesForDisplay[modeIndex].displayMode;
1594 const VkDisplayModePropertiesKHR& modeProperties = modesPropertiesForDisplay[modeIndex];
1595
1596 for (deUint32 planeIndex = 0;
1597 planeIndex < planeCountTested;
1598 planeIndex++)
1599 {
1600 std::vector<VkDisplayKHR> displaysForPlane;
1601
1602 if (!getDisplaysForPlane(planeIndex, displaysForPlane))
1603 TCU_FAIL_STR("Failed to retrieve displays list for plane " + de::toString(planeIndex));
1604
1605 if (displaysForPlane.empty())
1606 continue;
1607
1608 // Iterate through displays supported by the plane
1609 for (deUint32 displayIndex = 0;
1610 displayIndex < displaysForPlane.size();
1611 displayIndex++)
1612 {
1613 const VkDisplayKHR planeDisplay = displaysForPlane[displayIndex];
1614 VkDisplayPlaneCapabilitiesKHR planeCapabilities;
1615 bool fullDisplayPlane;
1616
1617 if (display == planeDisplay)
1618 {
1619 deMemset(&planeCapabilities, 0, sizeof(planeCapabilities));
1620
1621 result = m_vki.getDisplayPlaneCapabilitiesKHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1622 displayMode, // VkDisplayModeKHR mode
1623 planeIndex, // uint32_t planeIndex
1624 &planeCapabilities); // VkDisplayPlaneCapabilitiesKHR* pCapabilities
1625
1626 if (result != VK_SUCCESS)
1627 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1628
1629 fullDisplayPlane = planeCapabilities.minDstExtent.height == modeProperties.parameters.visibleRegion.height
1630 && planeCapabilities.minDstExtent.width == modeProperties.parameters.visibleRegion.width;
1631
1632 if (fullDisplayPlane && (planeCapabilities.supportedAlpha & VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR) != 0)
1633 {
1634 const VkDisplayPlaneAlphaFlagBitsKHR alphaMode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR;
1635 const VkInstance instance = m_context.getInstance();
1636 const VkDisplaySurfaceCreateInfoKHR createInfo = {
1637 VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR, // VkStructureType sType
1638 DE_NULL, // const void* pNext
1639 0, // VkDisplaySurfaceCreateFlagsKHR flags
1640 displayMode, // VkDisplayModeKHR displayMode
1641 planeIndex, // uint32_t planeIndex
1642 planeProperties[planeIndex].currentStackIndex, // uint32_t planeStackIndex
1643 VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR, // VkSurfaceTransformFlagBitsKHR transform
1644 1.0f, // float globalAlpha
1645 alphaMode, // VkDisplayPlaneAlphaFlagBitsKHR alphaMode
1646 { // VkExtent2D imageExtent
1647 planeCapabilities.minDstExtent.width,
1648 planeCapabilities.minDstExtent.height
1649 }
1650 };
1651 VkSurfaceKHR surface = DE_NULL;
1652
1653 result = m_vki.createDisplayPlaneSurfaceKHR( instance, // VkInstance instance
1654 &createInfo, // const VkDisplaySurfaceCreateInfoKHR* pCreateInfo
1655 DE_NULL, // const VkAllocationCallbacks* pAllocator
1656 &surface); // VkSurfaceKHR* pSurface
1657
1658 if (result != VK_SUCCESS)
1659 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1660
1661 if (surface == DE_NULL)
1662 TCU_FAIL("Invalid surface handle returned");
1663
1664 m_vki.destroySurfaceKHR( instance, // VkInstance instance
1665 surface, // VkSurfaceKHR* pSurface
1666 DE_NULL); // const VkAllocationCallbacks* pAllocator
1667
1668 testPerformed = true;
1669 }
1670 }
1671 }
1672 }
1673 }
1674 }
1675
1676 if (!testPerformed)
1677 TCU_THROW(NotSupportedError, "Cannot find suitable parameters for the test");
1678
1679 return tcu::TestStatus::pass("pass");
1680 }
1681
1682 /*--------------------------------------------------------------------*//*!
1683 * \brief Display enumeration coverage test using VK_KHR_get_display_properties2
1684 *
1685 * Throws an exception on fail.
1686 *
1687 * \return tcu::TestStatus::pass on success
1688 *//*--------------------------------------------------------------------*/
testGetPhysicalDeviceDisplayProperties2KHR(void)1689 tcu::TestStatus DisplayCoverageTestInstance::testGetPhysicalDeviceDisplayProperties2KHR (void)
1690 {
1691 deUint32 displayCountReported = 0u;
1692 deUint32 displayCountToTest = 0u;
1693 tcu::ResultCollector results (m_log);
1694 VkResult result;
1695
1696 result = m_vki.getPhysicalDeviceDisplayProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1697 &displayCountReported, // uint32_t* pPropertyCount
1698 DE_NULL); // VkDisplayProperties2KHR* pProperties
1699
1700 if ( result != VK_SUCCESS
1701 && result != VK_INCOMPLETE
1702 && result != VK_ERROR_OUT_OF_HOST_MEMORY
1703 && result != VK_ERROR_OUT_OF_DEVICE_MEMORY
1704 )
1705 {
1706 TCU_FAIL_STR(string("Invalid result ") + getResultAsString(result));
1707 }
1708
1709 if (result != VK_SUCCESS)
1710 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1711
1712 if (displayCountReported == 0)
1713 TCU_THROW(NotSupportedError, std::string("Cannot perform test: no displays found").c_str());
1714
1715 displayCountToTest = displayCountReported;
1716 if (displayCountReported > MAX_TESTED_DISPLAY_COUNT)
1717 {
1718 m_log << tcu::TestLog::Message
1719 << "Number of displays reported is too high " << displayCountReported
1720 << ". Test is limited to " << MAX_TESTED_DISPLAY_COUNT
1721 << tcu::TestLog::EndMessage;
1722
1723 displayCountToTest = MAX_TESTED_DISPLAY_COUNT;
1724 }
1725
1726 // Test the call correctly writes data in various size arrays
1727 for (deUint32 displayCountRequested = 0;
1728 displayCountRequested < displayCountToTest + 2;
1729 displayCountRequested++)
1730 {
1731 const deUint32 displayCountExpected = std::min(displayCountRequested, displayCountReported);
1732 const VkDisplayPropertiesKHR nonUpdatedDisplayProperties = { // Most values are set to fail the test to make sure driver updates them
1733 DE_NULL, // VkDisplayKHR display
1734 DE_NULL, // const char* displayName
1735 {0, 0}, // VkExtent2D physicalDimensions
1736 {0, 0}, // VkExtent2D physicalResolution
1737 ~RECOGNIZED_SURFACE_TRANSFORM_FLAGS, // VkSurfaceTransformFlagsKHR supportedTransforms
1738 (vk::VkBool32)(VK_TRUE + 1), // VkBool32 planeReorderPossible
1739 (vk::VkBool32)(VK_TRUE + 1) // VkBool32 persistentContent
1740 };
1741 const VkStructureType queryStructureType = VK_STRUCTURE_TYPE_DISPLAY_PROPERTIES_2_KHR;
1742 const VkDisplayProperties2KHR nonUpdatedDisplayProperties2 = {
1743 queryStructureType, // VkStructureType sType
1744 DE_NULL, // void* pNext
1745 nonUpdatedDisplayProperties // VkDisplayPropertiesKHR displayProperties
1746 };
1747 const VkDisplayKHR canaryDisplay = static_cast<VkDisplayKHR>(0xABCDEF11);
1748 const deUint32 canaryItemCount = 1;
1749 std::vector<VkDisplayProperties2KHR> displaysProps2 (displayCountRequested + canaryItemCount, nonUpdatedDisplayProperties2);
1750 deUint32 displayCountRetrieved = displayCountRequested;
1751 DisplaySet displaySet;
1752
1753 displaysProps2[displayCountExpected].displayProperties.display = canaryDisplay;
1754
1755 result = m_vki.getPhysicalDeviceDisplayProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1756 &displayCountRetrieved, // uint32_t* pPropertyCount
1757 &displaysProps2[0]); // VkDisplayProperties2KHR* pProperties
1758
1759 // Check amount of data written equals to expected
1760 if (displayCountRetrieved != displayCountExpected)
1761 TCU_FAIL_STR( string("displayCountRetrieved != displayCountExpected, ") +
1762 de::toString(displayCountRetrieved) + " != " + de::toString(displayCountExpected));
1763
1764 if (displayCountRequested >= displayCountReported)
1765 {
1766 if (result != VK_SUCCESS)
1767 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1768 }
1769 else
1770 {
1771 if (result != VK_INCOMPLETE)
1772 TCU_FAIL_STR(string("Expected VK_INCOMPLETE. Have ") + getResultAsString(result));
1773 }
1774
1775 // Check the driver has written something
1776 for (deUint32 displayIndex = 0;
1777 displayIndex < displayCountRetrieved;
1778 displayIndex++)
1779 {
1780 const VkDisplayProperties2KHR& properties2 = displaysProps2[displayIndex];
1781 const VkDisplayPropertiesKHR& properties = properties2.displayProperties;
1782
1783 displaySet.insert(properties.display);
1784
1785 results.check( properties2.sType == queryStructureType,
1786 "sType has changed to " + de::toString(properties2.sType));
1787
1788 results.check( properties2.pNext == DE_NULL,
1789 "pNext has changed to " + de::toString(properties2.pNext));
1790
1791 validateDisplayProperties(results, properties, nonUpdatedDisplayProperties);
1792
1793 if (results.getResult() != QP_TEST_RESULT_PASS)
1794 {
1795 m_log << tcu::TestLog::Message
1796 << "Error detected " << results.getMessage()
1797 << " for display " << displayIndex << " with properties " << properties2
1798 << " non updated display properties are " << nonUpdatedDisplayProperties2
1799 << tcu::TestLog::EndMessage;
1800
1801 TCU_FAIL_STR(results.getMessage());
1802 }
1803 }
1804
1805 // Check the driver has not written more than requested
1806 if (displaysProps2[displayCountExpected].displayProperties.display != canaryDisplay)
1807 TCU_FAIL("Memory damage detected: driver has written more than expected");
1808
1809 // Check display handle uniqueness
1810 if (displaySet.size() != displayCountRetrieved)
1811 TCU_FAIL("Display handle duplication detected");
1812 }
1813
1814 return tcu::TestStatus::pass("pass");
1815 }
1816
1817 /*--------------------------------------------------------------------*//*!
1818 * \brief Plane enumeration coverage test using VK_KHR_get_display_properties2
1819 *
1820 * Throws an exception on fail.
1821 *
1822 * \return tcu::TestStatus::pass on success
1823 *//*--------------------------------------------------------------------*/
testGetPhysicalDeviceDisplayPlaneProperties2KHR(void)1824 tcu::TestStatus DisplayCoverageTestInstance::testGetPhysicalDeviceDisplayPlaneProperties2KHR (void)
1825 {
1826 DisplayVector displaysVector;
1827 DisplaySet displaySet;
1828 deUint32 planeCountReported = 0u;
1829 deUint32 planeCountTested = 0u;
1830 tcu::ResultCollector results (m_log);
1831 VkResult result;
1832
1833 // Create a list of displays available
1834 if (!getDisplays2(displaysVector))
1835 TCU_FAIL("Failed to retrieve displays");
1836
1837 if (displaysVector.empty())
1838 TCU_THROW(NotSupportedError, "No displays reported");
1839
1840 displaySet = DisplaySet(displaysVector.begin(), displaysVector.end());
1841
1842 // Get planes to test
1843 result = m_vki.getPhysicalDeviceDisplayPlaneProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1844 &planeCountReported, // uint32_t* pPropertyCount
1845 DE_NULL); // VkDisplayPlaneProperties2KHR* pProperties
1846
1847 if ( result != VK_SUCCESS
1848 && result != VK_INCOMPLETE
1849 && result != VK_ERROR_OUT_OF_HOST_MEMORY
1850 && result != VK_ERROR_OUT_OF_DEVICE_MEMORY
1851 )
1852 {
1853 TCU_FAIL_STR(string("Invalid result ") + getResultAsString(result));
1854 }
1855
1856 if (result != VK_SUCCESS)
1857 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1858
1859 if (planeCountReported == 0)
1860 TCU_THROW(ResourceError, "Cannot perform test: no planes found");
1861
1862 planeCountTested = planeCountReported;
1863 if (planeCountReported > MAX_TESTED_PLANE_COUNT)
1864 {
1865 m_log << tcu::TestLog::Message
1866 << "Number of planes reported is too high " << planeCountReported
1867 << ". Test is limited to " << MAX_TESTED_PLANE_COUNT
1868 << tcu::TestLog::EndMessage;
1869
1870 planeCountTested = MAX_TESTED_PLANE_COUNT;
1871 }
1872
1873 // Test the call correctly writes data in various size arrays
1874 for (deUint32 planeCountRequested = 0;
1875 planeCountRequested < planeCountTested + 2;
1876 planeCountRequested++)
1877 {
1878 const deUint32 planeCountExpected = std::min(planeCountRequested, planeCountReported);
1879 const VkDisplayPlanePropertiesKHR nonUpdatedPlaneProperties = { // Most values are set to fail the test to make sure driver updates them
1880 DE_NULL, // VkDisplayKHR currentDisplay
1881 planeCountReported // deUint32 currentStackIndex
1882 };
1883 const VkStructureType queryStructureType = VK_STRUCTURE_TYPE_DISPLAY_PLANE_PROPERTIES_2_KHR;
1884 const VkDisplayPlaneProperties2KHR nonUpdatedPlaneProperties2 = {
1885 queryStructureType, // VkStructureType sType
1886 DE_NULL, // void* pNext
1887 nonUpdatedPlaneProperties // VkDisplayPlanePropertiesKHR displayPlaneProperties
1888 };
1889 const VkDisplayKHR canaryDisplay = static_cast<VkDisplayKHR>(0xABCDEF11);
1890 const deUint32 canaryItemCount = 1;
1891 std::vector<VkDisplayPlaneProperties2KHR> planeProps2 (planeCountRequested + canaryItemCount, nonUpdatedPlaneProperties2);
1892 deUint32 planeCountRetrieved = planeCountRequested;
1893
1894 planeProps2[planeCountExpected].displayPlaneProperties.currentDisplay = canaryDisplay;
1895
1896 result = m_vki.getPhysicalDeviceDisplayPlaneProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1897 &planeCountRetrieved, // uint32_t* pPropertyCount
1898 &planeProps2[0]); // VkDisplayPlaneProperties2KHR* pProperties
1899
1900 // Check amount of data written equals to expected
1901 if (planeCountRetrieved != planeCountExpected)
1902 TCU_FAIL_STR( string("planeCountRetrieved != planeCountExpected, ") +
1903 de::toString(planeCountRetrieved) + " != " + de::toString(planeCountExpected));
1904
1905 if (planeCountRequested >= planeCountReported)
1906 {
1907 if (result != VK_SUCCESS)
1908 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1909 }
1910 else
1911 {
1912 if (result != VK_INCOMPLETE)
1913 TCU_FAIL_STR(string("Expected VK_INCOMPLETE. Have ") + getResultAsString(result));
1914 }
1915
1916 // Check the driver has written something
1917 for (deUint32 planeIndex = 0;
1918 planeIndex < planeCountRetrieved;
1919 planeIndex++)
1920 {
1921 const VkDisplayPlaneProperties2KHR& properties2 = planeProps2[planeIndex];
1922 const VkDisplayPlanePropertiesKHR& properties = properties2.displayPlaneProperties;
1923
1924 results.check( properties2.sType == queryStructureType,
1925 "sType has changed to " + de::toString(properties2.sType));
1926
1927 results.check( properties2.pNext == DE_NULL,
1928 "pNext has changed to " + de::toString(properties2.pNext));
1929
1930 validateDisplayPlaneProperties(results, properties, nonUpdatedPlaneProperties, displaySet);
1931
1932 if (results.getResult() != QP_TEST_RESULT_PASS)
1933 {
1934 m_log << tcu::TestLog::Message
1935 << "Error detected " << results.getMessage()
1936 << " for plane " << planeIndex << " with properties " << properties2
1937 << tcu::TestLog::EndMessage;
1938
1939 TCU_FAIL_STR(results.getMessage());
1940 }
1941 }
1942
1943 // Check the driver has not written more than requested
1944 if (planeProps2[planeCountExpected].displayPlaneProperties.currentDisplay != canaryDisplay)
1945 TCU_FAIL("Memory damage detected: driver has written more than expected");
1946 }
1947
1948 return tcu::TestStatus::pass("pass");
1949 }
1950
1951 /*--------------------------------------------------------------------*//*!
1952 * \brief Display-plane capabilities coverage test using VK_KHR_get_display_properties2
1953 *
1954 * Throws an exception on fail.
1955 *
1956 * \return tcu::TestStatus::pass on success
1957 *//*--------------------------------------------------------------------*/
testGetDisplayPlaneCapabilities2KHR(void)1958 tcu::TestStatus DisplayCoverageTestInstance::testGetDisplayPlaneCapabilities2KHR (void)
1959 {
1960 deUint32 planeCountReported = 0u;
1961 VkResult result;
1962
1963 result = m_vki.getPhysicalDeviceDisplayPlaneProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
1964 &planeCountReported, // uint32_t* pPropertyCount
1965 DE_NULL); // VkDisplayPlaneProperties2KHR* pProperties
1966
1967 if (result != VK_SUCCESS)
1968 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
1969
1970 if (planeCountReported == 0)
1971 TCU_FAIL("No planes defined");
1972
1973 if (planeCountReported > MAX_TESTED_PLANE_COUNT)
1974 {
1975 m_log << tcu::TestLog::Message
1976 << "Number of planes reported is too high " << planeCountReported
1977 << ". Test is limited to " << MAX_TESTED_PLANE_COUNT
1978 << tcu::TestLog::EndMessage;
1979
1980 planeCountReported = MAX_TESTED_PLANE_COUNT;
1981 }
1982
1983 for (deUint32 planeIndex = 0;
1984 planeIndex < planeCountReported;
1985 planeIndex++)
1986 {
1987 std::vector<VkDisplayKHR> displaysForPlane;
1988
1989 if (!getDisplaysForPlane(planeIndex, displaysForPlane))
1990 TCU_FAIL_STR("Failed to retrieve displays list for plane " + de::toString(planeIndex));
1991
1992 if (displaysForPlane.empty())
1993 continue;
1994
1995 // Check the driver has written something
1996 for (deUint32 displayIndex = 0;
1997 displayIndex < displaysForPlane.size();
1998 displayIndex++)
1999 {
2000 const VkDisplayKHR display = displaysForPlane[displayIndex];
2001 std::vector<VkDisplayModeProperties2KHR> modesPropertiesForDisplay;
2002
2003 if (!getDisplayModeProperties2(display, modesPropertiesForDisplay))
2004 TCU_FAIL("Failed to retrieve display mode properties");
2005
2006 for (deUint32 modeIndex = 0;
2007 modeIndex < modesPropertiesForDisplay.size();
2008 modeIndex++)
2009 {
2010 const VkDisplayModeKHR displayMode = modesPropertiesForDisplay[modeIndex].displayModeProperties.displayMode;
2011 const deUint32 unrecognizedAlphaFlags = ~RECOGNIZED_DISPLAY_PLANE_ALPHA_FLAGS;
2012 const VkDisplayPlaneInfo2KHR planeInfo2 = {
2013 VK_STRUCTURE_TYPE_DISPLAY_PLANE_INFO_2_KHR, // VkStructureType sType
2014 DE_NULL, // const void* pNext
2015 displayMode, // VkDisplayModeKHR mode
2016 planeIndex // uint32_t planeIndex
2017 };
2018 VkDisplayPlaneCapabilitiesKHR planeCapabilities = {
2019 unrecognizedAlphaFlags, // VkDisplayPlaneAlphaFlagsKHR supportedAlpha
2020 { -1, -1 }, // VkOffset2D minSrcPosition
2021 { -1, -1 }, // VkOffset2D maxSrcPosition
2022 { 1, 1 }, // VkExtent2D minSrcExtent
2023 { 0, 0 }, // VkExtent2D maxSrcExtent
2024 { 1, 1 }, // VkOffset2D minDstPosition
2025 { 0, 0 }, // VkOffset2D maxDstPosition
2026 { 1, 1 }, // VkExtent2D minDstExtent
2027 { 0, 0 }, // VkExtent2D maxDstExtent
2028 };
2029 const VkStructureType queryStructureType = VK_STRUCTURE_TYPE_DISPLAY_PLANE_CAPABILITIES_2_KHR;
2030 VkDisplayPlaneCapabilities2KHR planeCapabilities2 = {
2031 queryStructureType, // VkStructureType sType
2032 DE_NULL, // void* pNext
2033 planeCapabilities // VkDisplayPlaneCapabilitiesKHR capabilities
2034 };
2035 tcu::ResultCollector results (m_log);
2036
2037 result = m_vki.getDisplayPlaneCapabilities2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
2038 &planeInfo2, // const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo
2039 &planeCapabilities2); // VkDisplayPlaneCapabilities2KHR* pCapabilities
2040
2041 results.check( result == VK_SUCCESS,
2042 string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
2043
2044 results.check( planeCapabilities2.sType == queryStructureType,
2045 "sType has changed to " + de::toString(planeCapabilities2.sType));
2046
2047 results.check( planeCapabilities2.pNext == DE_NULL,
2048 "pNext has changed to " + de::toString(planeCapabilities2.pNext));
2049
2050 // Validate results returned by driver in planeCapabilities2 using non-updated planeCapabilities
2051 validateDisplayPlaneCapabilities(results, planeCapabilities2.capabilities, planeCapabilities);
2052
2053 if (results.getResult() != QP_TEST_RESULT_PASS)
2054 {
2055 m_log << tcu::TestLog::Message
2056 << "Error detected " << results.getMessage()
2057 << " for plane's " << planeIndex
2058 << " display " << displayIndex
2059 << " and mode " << modeIndex
2060 << " with capabilities " << planeCapabilities2
2061 << tcu::TestLog::EndMessage;
2062
2063 TCU_FAIL_STR(results.getMessage());
2064 }
2065 }
2066 }
2067 }
2068
2069 return tcu::TestStatus::pass("pass");
2070 }
2071
2072 /*--------------------------------------------------------------------*//*!
2073 * \brief Display mode properties coverage test using VK_KHR_get_display_properties2
2074 *
2075 * Throws an exception on fail.
2076 *
2077 * \return tcu::TestStatus::pass on success
2078 *//*--------------------------------------------------------------------*/
testGetDisplayModeProperties2KHR(void)2079 tcu::TestStatus DisplayCoverageTestInstance::testGetDisplayModeProperties2KHR (void)
2080 {
2081 VkResult result;
2082 tcu::ResultCollector results (m_log);
2083 DisplayVector displaysVector;
2084
2085 if (!getDisplays2(displaysVector))
2086 TCU_FAIL("Failed to retrieve displays list");
2087
2088 if (displaysVector.empty())
2089 TCU_THROW(NotSupportedError, "No displays reported");
2090
2091 for (DisplayVector::iterator it = displaysVector.begin();
2092 it != displaysVector.end();
2093 it++)
2094 {
2095 VkDisplayKHR display = *it;
2096 deUint32 modesCountReported = 0u;
2097
2098 result = m_vki.getDisplayModeProperties2KHR( m_physicalDevice, // VkPhysicalDevice physicalDevice
2099 display, // VkDisplayKHR display
2100 &modesCountReported, // uint32_t* pPropertyCount
2101 DE_NULL); // VkDisplayModeProperties2KHR* pProperties
2102
2103 // Test the call correctly writes data in various size arrays
2104 for (deUint32 modesCountRequested = 0;
2105 modesCountRequested < modesCountReported + 2;
2106 modesCountRequested = nextTestNumber(modesCountRequested, modesCountReported + 2))
2107 {
2108 const deUint32 modesCountExpected = std::min(modesCountRequested, modesCountReported);
2109 const VkDisplayModeKHR nullDisplayMode = DE_NULL;
2110 const VkDisplayModePropertiesKHR nonUpdatedModeProperties = {
2111 nullDisplayMode, // VkDisplayModeKHR displayMode
2112 { // VkDisplayModeParametersKHR parameters
2113 {0, 0}, // VkExtent2D visibleRegion
2114 0 // uint32_t refreshRate
2115 }
2116 };
2117 const VkStructureType queryStructureType = VK_STRUCTURE_TYPE_DISPLAY_MODE_PROPERTIES_2_KHR;
2118 const VkDisplayModeProperties2KHR nonUpdatedModeProperties2 = {
2119 queryStructureType, // VkStructureType sType
2120 DE_NULL, // void* pNext
2121 nonUpdatedModeProperties // VkDisplayModePropertiesKHR displayModeProperties
2122 };
2123 const VkDisplayModeKHR canaryDisplayMode = static_cast<VkDisplayModeKHR>(0xABCDEF11);
2124 const deUint32 canaryItemCount = 1;
2125 std::vector<VkDisplayModeProperties2KHR> modesProperties2 (modesCountRequested + canaryItemCount, nonUpdatedModeProperties2);
2126 deUint32 modesCountRetrieved = modesCountRequested;
2127
2128 modesProperties2[modesCountExpected].displayModeProperties.displayMode = canaryDisplayMode;
2129
2130 result = m_vki.getDisplayModeProperties2KHR(m_physicalDevice, // VkPhysicalDevice physicalDevice
2131 display, // VkDisplayKHR display
2132 &modesCountRetrieved, // uint32_t* pPropertyCount
2133 &modesProperties2[0]); // VkDisplayModeProperties2KHR* pProperties
2134
2135 // Check amount of data written equals to expected
2136 if (modesCountRetrieved != modesCountExpected)
2137 TCU_FAIL_STR( string("modesCountRetrieved != modesCountExpected, ") +
2138 de::toString(modesCountRetrieved) + " != " + de::toString(modesCountExpected));
2139
2140 if (modesCountRequested >= modesCountReported)
2141 {
2142 if (result != VK_SUCCESS)
2143 TCU_FAIL_STR(string("Expected VK_SUCCESS. Have ") + getResultAsString(result));
2144 }
2145 else
2146 {
2147 if (result != VK_INCOMPLETE)
2148 TCU_FAIL_STR(string("Expected VK_INCOMPLETE. Have ") + getResultAsString(result));
2149 }
2150
2151 // Check the driver has written something
2152 for (deUint32 modeIndex = 0;
2153 modeIndex < modesCountExpected;
2154 modeIndex++)
2155 {
2156 const VkDisplayModeProperties2KHR& properties2 = modesProperties2[modeIndex];
2157 const VkDisplayModePropertiesKHR& properties = properties2.displayModeProperties;
2158
2159 results.check( properties2.sType == queryStructureType,
2160 "sType has changed to " + de::toString(properties2.sType));
2161
2162 results.check( properties2.pNext == DE_NULL,
2163 "pNext has changed to " + de::toString(properties2.pNext));
2164
2165 validateDisplayModeProperties(results, properties, nonUpdatedModeProperties);
2166
2167 if (results.getResult() != QP_TEST_RESULT_PASS)
2168 {
2169 m_log << tcu::TestLog::Message
2170 << "Error detected " << results.getMessage()
2171 << " for mode " << modeIndex << " with properties " << properties2
2172 << " non updated mode properties are " << nonUpdatedModeProperties2
2173 << tcu::TestLog::EndMessage;
2174
2175 TCU_FAIL_STR(results.getMessage());
2176 }
2177 }
2178
2179 // Check the driver has not written more than requested
2180 if (modesProperties2[modesCountExpected].displayModeProperties.displayMode != canaryDisplayMode)
2181 TCU_FAIL("Memory damage detected: driver has written more than expected");
2182 }
2183 }
2184
2185 return tcu::TestStatus::pass("pass");
2186 }
2187
2188
2189 /*--------------------------------------------------------------------*//*!
2190 * \brief Display coverage tests case class
2191 *//*--------------------------------------------------------------------*/
2192 class DisplayCoverageTestsCase : public vkt::TestCase
2193 {
2194 public:
DisplayCoverageTestsCase(tcu::TestContext & context,const char * name,const char * description,const DisplayIndexTest testId)2195 DisplayCoverageTestsCase (tcu::TestContext &context, const char *name, const char *description, const DisplayIndexTest testId)
2196 : TestCase (context, name, description)
2197 , m_testId (testId)
2198 {
2199 }
2200 private:
2201 const DisplayIndexTest m_testId;
2202
createInstance(vkt::Context & context) const2203 vkt::TestInstance* createInstance (vkt::Context& context) const
2204 {
2205 return new DisplayCoverageTestInstance(context, m_testId);
2206 }
2207 };
2208
2209
2210 /*--------------------------------------------------------------------*//*!
2211 * \brief Adds a test into group
2212 *//*--------------------------------------------------------------------*/
addTest(tcu::TestCaseGroup * group,const DisplayIndexTest testId,const char * name,const char * description)2213 static void addTest (tcu::TestCaseGroup* group, const DisplayIndexTest testId, const char* name, const char* description)
2214 {
2215 tcu::TestContext& testCtx = group->getTestContext();
2216
2217 group->addChild(new DisplayCoverageTestsCase(testCtx, name, description, testId));
2218 }
2219
2220 /*--------------------------------------------------------------------*//*!
2221 * \brief Adds VK_KHR_display and VK_KHR_display_swapchain extension tests into group
2222 *//*--------------------------------------------------------------------*/
createDisplayCoverageTests(tcu::TestCaseGroup * group)2223 void createDisplayCoverageTests (tcu::TestCaseGroup* group)
2224 {
2225 // VK_KHR_display extension tests
2226 addTest(group, DISPLAY_TEST_INDEX_GET_DISPLAY_PROPERTIES, "get_display_properties", "Display enumeration coverage test");
2227 addTest(group, DISPLAY_TEST_INDEX_GET_DISPLAY_PLANES, "get_display_plane_properties", "Planes enumeration coverage test");
2228 addTest(group, DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_SUPPORTED_DISPLAY, "get_display_plane_supported_displays", "Display plane support coverage test");
2229 addTest(group, DISPLAY_TEST_INDEX_GET_DISPLAY_MODE, "get_display_mode_properties", "Display mode properties coverage test");
2230 addTest(group, DISPLAY_TEST_INDEX_CREATE_DISPLAY_MODE, "create_display_mode", "Create display mode coverage test");
2231 addTest(group, DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_CAPABILITIES, "get_display_plane_capabilities", "Display-plane capabilities coverage test");
2232 addTest(group, DISPLAY_TEST_INDEX_CREATE_DISPLAY_PLANE_SURFACE, "create_display_plane_surface", "Create display plane surface coverage test");
2233
2234 // VK_KHR_get_display_properties2 extension tests
2235 addTest(group, DISPLAY_TEST_INDEX_GET_DISPLAY_PROPERTIES2, "get_display_properties2", "Display enumeration coverage test using VK_KHR_get_display_properties2");
2236 addTest(group, DISPLAY_TEST_INDEX_GET_DISPLAY_PLANES2, "get_display_plane_properties2", "Planes enumeration coverage test using VK_KHR_get_display_properties2");
2237 addTest(group, DISPLAY_TEST_INDEX_GET_DISPLAY_MODE2, "get_display_mode_properties2", "Display mode properties coverage test using VK_KHR_get_display_properties2");
2238 addTest(group, DISPLAY_TEST_INDEX_GET_DISPLAY_PLANE_CAPABILITIES2, "get_display_plane_capabilities2", "Display-plane capabilities coverage test using VK_KHR_get_display_properties2");
2239 }
2240
2241 } //wsi
2242 } //vkt
2243
2244