From fc8966496d9e78fbac2dacc88517cfaa77d0ec8f Mon Sep 17 00:00:00 2001 From: Pawel Ksiezopolski Date: Thu, 4 Jun 2020 16:20:21 +0200 Subject: [PATCH] Add tests for VK_EXT_full_screen_exclusive extension New tests: dEQP-VK.wsi.*.full_screen_exclusive.* Components: Vulkan VK-GL-CTS issue: 1685 Change-Id: Ife5394dcb2f207eedd8ac55da6a06d1fb31202f8 --- AndroidGen.mk | 1 + android/cts/master/vk-master-2020-03-01.txt | 8 + android/cts/master/vk-master.txt | 8 + .../vulkancts/framework/vulkan/vkWsiPlatform.cpp | 6 + .../vulkancts/framework/vulkan/vkWsiPlatform.hpp | 1 + external/vulkancts/framework/vulkan/vkWsiUtil.cpp | 82 +++ external/vulkancts/framework/vulkan/vkWsiUtil.hpp | 4 + .../vulkancts/modules/vulkan/wsi/CMakeLists.txt | 2 + .../vulkan/wsi/vktWsiFullScreenExclusiveTests.cpp | 604 +++++++++++++++++++++ .../vulkan/wsi/vktWsiFullScreenExclusiveTests.hpp | 41 ++ .../vulkancts/modules/vulkan/wsi/vktWsiTests.cpp | 2 + external/vulkancts/mustpass/master/vk-default.txt | 24 + framework/platform/android/tcuAndroidPlatform.cpp | 10 + framework/platform/lnx/tcuLnxVulkanPlatform.cpp | 15 + framework/platform/lnx/tcuLnxVulkanPlatform.hpp | 2 +- framework/platform/osx/tcuOSXVulkanPlatform.cpp | 4 + .../platform/win32/tcuWin32VulkanPlatform.cpp | 5 + 17 files changed, 818 insertions(+), 1 deletion(-) create mode 100644 external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.cpp create mode 100644 external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.hpp diff --git a/AndroidGen.mk b/AndroidGen.mk index fd41702..b4ac1de 100644 --- a/AndroidGen.mk +++ b/AndroidGen.mk @@ -444,6 +444,7 @@ LOCAL_SRC_FILES := \ external/vulkancts/modules/vulkan/wsi/vktWsiDisplayControlTests.cpp \ external/vulkancts/modules/vulkan/wsi/vktWsiDisplayTests.cpp \ external/vulkancts/modules/vulkan/wsi/vktWsiDisplayTimingTests.cpp \ + external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.cpp \ external/vulkancts/modules/vulkan/wsi/vktWsiIncrementalPresentTests.cpp \ external/vulkancts/modules/vulkan/wsi/vktWsiSharedPresentableImageTests.cpp \ external/vulkancts/modules/vulkan/wsi/vktWsiSurfaceTests.cpp \ diff --git a/android/cts/master/vk-master-2020-03-01.txt b/android/cts/master/vk-master-2020-03-01.txt index 107de13..8d3ffc1 100644 --- a/android/cts/master/vk-master-2020-03-01.txt +++ b/android/cts/master/vk-master-2020-03-01.txt @@ -160480,6 +160480,10 @@ dEQP-VK.wsi.android.swapchain.private_data.pre_transform dEQP-VK.wsi.android.swapchain.private_data.composite_alpha dEQP-VK.wsi.android.swapchain.private_data.present_mode dEQP-VK.wsi.android.swapchain.private_data.clipped +dEQP-VK.wsi.android.full_screen_exclusive.default +dEQP-VK.wsi.android.full_screen_exclusive.allowed +dEQP-VK.wsi.android.full_screen_exclusive.disallowed +dEQP-VK.wsi.android.full_screen_exclusive.application_controlled dEQP-VK.wsi.macos.surface.query_presentation_support dEQP-VK.wsi.macos.surface.query_surface_counters dEQP-VK.wsi.macos.swapchain.create.image_swapchain_create_info @@ -160502,6 +160506,10 @@ dEQP-VK.wsi.macos.swapchain.private_data.pre_transform dEQP-VK.wsi.macos.swapchain.private_data.composite_alpha dEQP-VK.wsi.macos.swapchain.private_data.present_mode dEQP-VK.wsi.macos.swapchain.private_data.clipped +dEQP-VK.wsi.macos.full_screen_exclusive.default +dEQP-VK.wsi.macos.full_screen_exclusive.allowed +dEQP-VK.wsi.macos.full_screen_exclusive.disallowed +dEQP-VK.wsi.macos.full_screen_exclusive.application_controlled dEQP-VK.wsi.display.surface_counters dEQP-VK.wsi.display_control.swapchain_counter dEQP-VK.wsi.display_control.display_power_control diff --git a/android/cts/master/vk-master.txt b/android/cts/master/vk-master.txt index e877fd2..1e6df23 100644 --- a/android/cts/master/vk-master.txt +++ b/android/cts/master/vk-master.txt @@ -498520,6 +498520,10 @@ dEQP-VK.wsi.android.shared_presentable_image.scale_up.inherit.inherit.continuous dEQP-VK.wsi.android.colorspace.extensions dEQP-VK.wsi.android.colorspace.basic dEQP-VK.wsi.android.colorspace.hdr +dEQP-VK.wsi.android.full_screen_exclusive.default +dEQP-VK.wsi.android.full_screen_exclusive.allowed +dEQP-VK.wsi.android.full_screen_exclusive.disallowed +dEQP-VK.wsi.android.full_screen_exclusive.application_controlled dEQP-VK.wsi.macos.surface.create dEQP-VK.wsi.macos.surface.create_custom_allocator dEQP-VK.wsi.macos.surface.create_simulate_oom @@ -498952,6 +498956,10 @@ dEQP-VK.wsi.macos.shared_presentable_image.scale_none.inherit.inherit.continuous dEQP-VK.wsi.macos.colorspace.extensions dEQP-VK.wsi.macos.colorspace.basic dEQP-VK.wsi.macos.colorspace.hdr +dEQP-VK.wsi.macos.full_screen_exclusive.default +dEQP-VK.wsi.macos.full_screen_exclusive.allowed +dEQP-VK.wsi.macos.full_screen_exclusive.disallowed +dEQP-VK.wsi.macos.full_screen_exclusive.application_controlled dEQP-VK.wsi.display.get_display_properties dEQP-VK.wsi.display.get_display_plane_properties dEQP-VK.wsi.display.get_display_plane_supported_displays diff --git a/external/vulkancts/framework/vulkan/vkWsiPlatform.cpp b/external/vulkancts/framework/vulkan/vkWsiPlatform.cpp index 0fbed0f..5cf0edf 100644 --- a/external/vulkancts/framework/vulkan/vkWsiPlatform.cpp +++ b/external/vulkancts/framework/vulkan/vkWsiPlatform.cpp @@ -28,6 +28,12 @@ namespace vk namespace wsi { +void Window::setVisible (bool visible) +{ + DE_UNREF(visible); + TCU_THROW(InternalError, "setVisible() called on window not supporting it"); +} + void Window::resize (const tcu::UVec2&) { TCU_THROW(InternalError, "resize() called on window not supporting it"); diff --git a/external/vulkancts/framework/vulkan/vkWsiPlatform.hpp b/external/vulkancts/framework/vulkan/vkWsiPlatform.hpp index 4f51abe..f37087b 100644 --- a/external/vulkancts/framework/vulkan/vkWsiPlatform.hpp +++ b/external/vulkancts/framework/vulkan/vkWsiPlatform.hpp @@ -37,6 +37,7 @@ class Window public: virtual ~Window (void) {} + virtual void setVisible (bool visible); virtual void resize (const tcu::UVec2& newSize); protected: diff --git a/external/vulkancts/framework/vulkan/vkWsiUtil.cpp b/external/vulkancts/framework/vulkan/vkWsiUtil.cpp index 3dbffb2..ac5dafd 100644 --- a/external/vulkancts/framework/vulkan/vkWsiUtil.cpp +++ b/external/vulkancts/framework/vulkan/vkWsiUtil.cpp @@ -44,6 +44,17 @@ using std::vector; # endif // DEQP_SUPPORT_XCB #endif // DEQP_SUPPORT_X11 +#if defined (DEQP_SUPPORT_WAYLAND) +# include "tcuLnxWayland.hpp" +# define WAYLAND_DISPLAY DE_NULL +#endif // DEQP_SUPPORT_WAYLAND + +#if ( DE_OS == DE_OS_WIN32 ) + #define NOMINMAX + #define WIN32_LEAN_AND_MEAN + #include +#endif + namespace vk { namespace wsi @@ -491,6 +502,77 @@ std::vector getCompatibleQueueFamilyIndices (const InstanceInterface& return indices; } +tcu::UVec2 getFullScreenSize (const vk::wsi::Type wsiType, const vk::wsi::Display& display, const tcu::UVec2& fallbackSize) +{ + tcu::UVec2 result = fallbackSize; + + switch (wsiType) + { + case TYPE_XLIB: + { +#if defined (DEQP_SUPPORT_X11) + const XlibDisplayInterface& xlibDisplay = dynamic_cast(display); + ::Display* displayPtr = (::Display*)(xlibDisplay.getNative().internal); + const Screen* screen = ScreenOfDisplay(displayPtr, 0); + result.x() = deUint32(screen->width); + result.y() = deUint32(screen->height); +#endif + break; + } + case TYPE_XCB: + { +#if defined (DEQP_SUPPORT_XCB) +// const XcbDisplayInterface& xcbDisplay = dynamic_cast(display); +// xcb_connection_t* connPtr = (xcb_connection_t*)(xcbDisplay.getNative().internal); +// xcb_screen_t* screen = xcb_setup_roots_iterator(xcb_get_setup(connPtr)).data; +// result.x() = deUint32(screen->width_in_pixels); +// result.y() = deUint32(screen->height_in_pixels); +#endif + break; + } + case TYPE_WAYLAND: + { +#if defined (DEQP_SUPPORT_WAYLAND) +#endif + break; + } + case TYPE_ANDROID: + { +#if ( DE_OS == DE_OS_ANDROID ) +#endif + break; + } + case TYPE_WIN32: + { +#if ( DE_OS == DE_OS_WIN32 ) + de::MovePtr nullWindow (display.createWindow(tcu::nothing())); + const Win32WindowInterface& win32Window = dynamic_cast(*nullWindow); + HMONITOR hMonitor = (HMONITOR)MonitorFromWindow((HWND)win32Window.getNative().internal, MONITOR_DEFAULTTONEAREST); + MONITORINFO monitorInfo; + monitorInfo.cbSize = sizeof(MONITORINFO); + GetMonitorInfo(hMonitor, &monitorInfo); + result.x() = deUint32(abs(monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left)); + result.y() = deUint32(abs(monitorInfo.rcMonitor.top - monitorInfo.rcMonitor.bottom)); +#endif + break; + } + + case TYPE_MACOS: + { +#if ( DE_OS == DE_OS_OSX ) +#endif + break; + } + + default: + DE_FATAL("Unknown WSI type"); + break; + } + + DE_UNREF(display); + return result; +} + Move WsiTriangleRenderer::createRenderPass (const DeviceInterface& vkd, const VkDevice device, const VkFormat colorAttachmentFormat, diff --git a/external/vulkancts/framework/vulkan/vkWsiUtil.hpp b/external/vulkancts/framework/vulkan/vkWsiUtil.hpp index 9cdc08d..6e3bf0c 100644 --- a/external/vulkancts/framework/vulkan/vkWsiUtil.hpp +++ b/external/vulkancts/framework/vulkan/vkWsiUtil.hpp @@ -125,6 +125,10 @@ std::vector getCompatibleQueueFamilyIndices (const InstanceInterfa VkPhysicalDevice physicalDevice, const std::vector& surface); +tcu::UVec2 getFullScreenSize (const vk::wsi::Type wsiType, + const vk::wsi::Display& display, + const tcu::UVec2& fallbackSize); + class WsiTriangleRenderer { public: diff --git a/external/vulkancts/modules/vulkan/wsi/CMakeLists.txt b/external/vulkancts/modules/vulkan/wsi/CMakeLists.txt index 11bab22..c884157 100644 --- a/external/vulkancts/modules/vulkan/wsi/CMakeLists.txt +++ b/external/vulkancts/modules/vulkan/wsi/CMakeLists.txt @@ -21,6 +21,8 @@ set(DEQP_VK_WSI_SRCS vktWsiDisplayTests.cpp vktWsiColorSpaceTests.cpp vktWsiColorSpaceTests.hpp + vktWsiFullScreenExclusiveTests.cpp + vktWsiFullScreenExclusiveTests.hpp ) set(DEQP_VK_WSI_LIBS diff --git a/external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.cpp b/external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.cpp new file mode 100644 index 0000000..ab58de1 --- /dev/null +++ b/external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.cpp @@ -0,0 +1,604 @@ +/*------------------------------------------------------------------------- + * Vulkan Conformance Tests + * ------------------------ + * + * Copyright (c) 2017 Google Inc. + * Copyright (c) 2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *//*! + * \file + * \brief VK_EXT_full_screen_exclusive extension Tests + *//*--------------------------------------------------------------------*/ + +#include "vktWsiFullScreenExclusiveTests.hpp" + +#include "vktTestCaseUtil.hpp" +#include "vktCustomInstancesDevices.hpp" + +#include "vkRefUtil.hpp" +#include "vkQueryUtil.hpp" +#include "vkDeviceUtil.hpp" +#include "vkTypeUtil.hpp" +#include "vkCmdUtil.hpp" +#include "vkWsiPlatform.hpp" +#include "vkWsiUtil.hpp" + +#include "tcuTestLog.hpp" +#include "tcuPlatform.hpp" +#include "tcuCommandLine.hpp" + +#if ( DE_OS == DE_OS_WIN32 ) + #define NOMINMAX + #define WIN32_LEAN_AND_MEAN + #include +#endif + +namespace vkt +{ +namespace wsi +{ + +namespace +{ + +using namespace vk; +using namespace vk::wsi; + +typedef std::vector Extensions; + +struct TestParams +{ + vk::wsi::Type wsiType; + VkFullScreenExclusiveEXT fseType; +}; + +void checkAllSupported (const Extensions& supportedExtensions, + const std::vector& requiredExtensions) +{ + for (std::vector::const_iterator requiredExtName = requiredExtensions.begin(); + requiredExtName != requiredExtensions.end(); + ++requiredExtName) + { + if (!isExtensionSupported(supportedExtensions, RequiredExtension(*requiredExtName))) + TCU_THROW(NotSupportedError, (*requiredExtName + " is not supported").c_str()); + } +} + +CustomInstance createInstanceWithWsi (Context& context, + const Extensions& supportedExtensions, + Type wsiType, + const VkAllocationCallbacks* pAllocator = DE_NULL) +{ + std::vector extensions; + + extensions.push_back("VK_KHR_surface"); + extensions.push_back(getExtensionName(wsiType)); + + if (isExtensionSupported(supportedExtensions, RequiredExtension("VK_KHR_get_surface_capabilities2"))) + extensions.push_back("VK_KHR_get_surface_capabilities2"); + + checkAllSupported(supportedExtensions, extensions); + + return createCustomInstanceWithExtensions(context, extensions, pAllocator); +} + +VkPhysicalDeviceFeatures getDeviceFeaturesForWsi (void) +{ + VkPhysicalDeviceFeatures features; + deMemset(&features, 0, sizeof(features)); + return features; +} + +Move createDeviceWithWsi (const vk::PlatformInterface& vkp, + vk::VkInstance instance, + const InstanceInterface& vki, + VkPhysicalDevice physicalDevice, + const Extensions& supportedExtensions, + const deUint32 queueFamilyIndex, + const VkAllocationCallbacks* pAllocator, + bool validationEnabled) +{ + const float queuePriorities[] = { 1.0f }; + const VkDeviceQueueCreateInfo queueInfos[] = + { + { + VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, + DE_NULL, + (VkDeviceQueueCreateFlags)0, + queueFamilyIndex, + DE_LENGTH_OF_ARRAY(queuePriorities), + &queuePriorities[0] + } + }; + const VkPhysicalDeviceFeatures features = getDeviceFeaturesForWsi(); + std::vector extensions; + + if (!isExtensionSupported(supportedExtensions, RequiredExtension("VK_KHR_swapchain"))) + TCU_THROW(NotSupportedError, (std::string(extensions[0]) + " is not supported").c_str()); + extensions.push_back("VK_KHR_swapchain"); + + if (isExtensionSupported(supportedExtensions, RequiredExtension("VK_EXT_full_screen_exclusive"))) + { + extensions.push_back("VK_EXT_full_screen_exclusive"); + } + + VkDeviceCreateInfo deviceParams = + { + VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, + DE_NULL, + (VkDeviceCreateFlags)0, + DE_LENGTH_OF_ARRAY(queueInfos), + &queueInfos[0], + 0u, // enabledLayerCount + DE_NULL, // ppEnabledLayerNames + (deUint32)extensions.size(), + extensions.empty() ? DE_NULL : &extensions[0], + &features + }; + + return createCustomDevice(validationEnabled, vkp, instance, vki, physicalDevice, &deviceParams, pAllocator); +} + +struct InstanceHelper +{ + const std::vector supportedExtensions; + const CustomInstance instance; + const InstanceDriver& vki; + + InstanceHelper (Context& context, + Type wsiType, + const VkAllocationCallbacks* pAllocator = DE_NULL) + : supportedExtensions (enumerateInstanceExtensionProperties(context.getPlatformInterface(), + DE_NULL)) + , instance (createInstanceWithWsi(context, + supportedExtensions, + wsiType, + pAllocator)) + , vki (instance.getDriver()) + {} +}; + +struct DeviceHelper +{ + const VkPhysicalDevice physicalDevice; + const deUint32 queueFamilyIndex; + const Unique device; + const DeviceDriver vkd; + const VkQueue queue; + + DeviceHelper (Context& context, + const InstanceInterface& vki, + VkInstance instance, + VkSurfaceKHR surface, + const VkAllocationCallbacks* pAllocator = DE_NULL) + : physicalDevice (chooseDevice(vki, instance, context.getTestContext().getCommandLine())) + , queueFamilyIndex (chooseQueueFamilyIndex(vki, physicalDevice, surface)) + , device (createDeviceWithWsi(context.getPlatformInterface(), + instance, + vki, + physicalDevice, + enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL), + queueFamilyIndex, + pAllocator, + context.getTestContext().getCommandLine().isValidationEnabled())) + , vkd (context.getPlatformInterface(), instance, *device) + , queue (getDeviceQueue(vkd, *device, queueFamilyIndex, 0)) + { + } +}; + +de::MovePtr createDisplay (const vk::Platform& platform, + const Extensions& supportedExtensions, + Type wsiType) +{ + try + { + return de::MovePtr(platform.createWsiDisplay(wsiType)); + } + catch (const tcu::NotSupportedError& e) + { + if (isExtensionSupported(supportedExtensions, RequiredExtension(getExtensionName(wsiType))) && + platform.hasDisplay(wsiType)) + { + // If VK_KHR_{platform}_surface was supported, vk::Platform implementation + // must support creating native display & window for that WSI type. + throw tcu::TestError(e.getMessage()); + } + else + throw; + } +} + +de::MovePtr createWindow (const Display& display, + const tcu::Maybe& initialSize) +{ + try + { + return de::MovePtr(display.createWindow(initialSize)); + } + catch (const tcu::NotSupportedError& e) + { + // See createDisplay - assuming that wsi::Display was supported platform port + // should also support creating a window. + throw tcu::TestError(e.getMessage()); + } +} + +struct NativeObjects +{ + const de::UniquePtr display; + tcu::UVec2 windowSize; + const de::UniquePtr window; + + NativeObjects (Context& context, + const Extensions& supportedExtensions, + Type wsiType) + : display (createDisplay(context.getTestContext().getPlatform().getVulkanPlatform(), supportedExtensions, wsiType)) + , windowSize (getFullScreenSize(wsiType, *display.get(), tcu::UVec2(256U, 256U))) + , window (createWindow(*display, windowSize)) + {} +}; + +VkSwapchainCreateInfoKHR getBasicSwapchainParameters (Type wsiType, + const InstanceInterface& vki, + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + VkSurfaceFormatKHR surfaceFormat, + const tcu::UVec2& desiredSize, + deUint32 desiredImageCount) +{ + const VkSurfaceCapabilitiesKHR capabilities = getPhysicalDeviceSurfaceCapabilities(vki, + physicalDevice, + surface); + const PlatformProperties& platformProperties = getPlatformProperties(wsiType); + const VkSurfaceTransformFlagBitsKHR transform = (capabilities.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) ? VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR : capabilities.currentTransform; + const VkSwapchainCreateInfoKHR parameters = + { + VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, + DE_NULL, + (VkSwapchainCreateFlagsKHR)0, + surface, + de::clamp(desiredImageCount, capabilities.minImageCount, capabilities.maxImageCount > 0 ? capabilities.maxImageCount : capabilities.minImageCount + desiredImageCount), + surfaceFormat.format, + surfaceFormat.colorSpace, + (platformProperties.swapchainExtent == PlatformProperties::SWAPCHAIN_EXTENT_MUST_MATCH_WINDOW_SIZE + ? capabilities.currentExtent : vk::makeExtent2D(desiredSize.x(), desiredSize.y())), + 1u, // imageArrayLayers + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + VK_SHARING_MODE_EXCLUSIVE, + 0u, + (const deUint32*)DE_NULL, + transform, + VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, + VK_PRESENT_MODE_FIFO_KHR, + VK_FALSE, // clipped + (VkSwapchainKHR)0 // oldSwapchain + }; + + return parameters; +} + +typedef de::SharedPtr > CommandBufferSp; +typedef de::SharedPtr > FenceSp; +typedef de::SharedPtr > SemaphoreSp; + +std::vector createFences (const DeviceInterface& vkd, + const VkDevice device, + size_t numFences) +{ + std::vector fences(numFences); + + for (size_t ndx = 0; ndx < numFences; ++ndx) + fences[ndx] = FenceSp(new Unique(createFence(vkd, device))); + + return fences; +} + +std::vector createSemaphores (const DeviceInterface& vkd, + const VkDevice device, + size_t numSemaphores) +{ + std::vector semaphores(numSemaphores); + + for (size_t ndx = 0; ndx < numSemaphores; ++ndx) + semaphores[ndx] = SemaphoreSp(new Unique(createSemaphore(vkd, device))); + + return semaphores; +} + +std::vector allocateCommandBuffers (const DeviceInterface& vkd, + const VkDevice device, + const VkCommandPool commandPool, + const VkCommandBufferLevel level, + const size_t numCommandBuffers) +{ + std::vector buffers (numCommandBuffers); + + for (size_t ndx = 0; ndx < numCommandBuffers; ++ndx) + buffers[ndx] = CommandBufferSp(new Unique(allocateCommandBuffer(vkd, device, commandPool, level))); + + return buffers; +} + +tcu::TestStatus fullScreenExclusiveTest (Context& context, + TestParams testParams) +{ + if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_EXT_full_screen_exclusive")) + TCU_THROW(NotSupportedError, "Extension VK_EXT_full_screen_exclusive not supported"); + + const InstanceHelper instHelper (context, testParams.wsiType); + const NativeObjects native (context, instHelper.supportedExtensions, testParams.wsiType); + const Unique surface (createSurface(instHelper.vki, instHelper.instance, testParams.wsiType, *native.display, *native.window)); + const DeviceHelper devHelper (context, instHelper.vki, instHelper.instance, *surface); + const std::vector deviceExtensions (enumerateDeviceExtensionProperties(instHelper.vki, devHelper.physicalDevice, DE_NULL)); + if (!isExtensionSupported(deviceExtensions, RequiredExtension("VK_EXT_full_screen_exclusive"))) + TCU_THROW(NotSupportedError, "Extension VK_EXT_full_screen_exclusive not supported"); + + native.window->setVisible(true); + + // for Win32 - create structure containing HMONITOR value +#if ( DE_OS == DE_OS_WIN32 ) + VkSurfaceFullScreenExclusiveWin32InfoEXT fseWin32Info = { + VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT, // VkStructureType sType; + DE_NULL, // const void* pNext; + pt::Win32MonitorHandle(0) // HMONITOR hmonitor; + }; + if (testParams.wsiType == TYPE_WIN32) + { + Win32WindowInterface* windowInterface = dynamic_cast(native.window.get()); + fseWin32Info.hmonitor = (pt::Win32MonitorHandle)MonitorFromWindow((HWND)windowInterface->getNative().internal, MONITOR_DEFAULTTONEAREST); + } +#endif + + // check surface capabilities + VkSurfaceCapabilitiesFullScreenExclusiveEXT surfaceCapabilitiesFSE = { + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_FULL_SCREEN_EXCLUSIVE_EXT, // VkStructureType sType; + DE_NULL, // void* pNext; + DE_FALSE // VkBool32 fullScreenExclusiveSupported; + }; + VkSurfaceCapabilities2KHR surfaceCapabilities2 = { + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR, // VkStructureType sType; + &surfaceCapabilitiesFSE, // void* pNext; + VkSurfaceCapabilitiesKHR {} // VkSurfaceCapabilitiesKHR surfaceCapabilities; + }; + VkPhysicalDeviceSurfaceInfo2KHR surfaceInfo = { + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, // VkStructureType sType; + DE_NULL, // const void* pNext; + *surface // VkSurfaceKHR surface; + }; +#if ( DE_OS == DE_OS_WIN32 ) + if (testParams.wsiType == TYPE_WIN32) + { + surfaceInfo.pNext = &fseWin32Info; + } +#endif + + instHelper.vki.getPhysicalDeviceSurfaceCapabilities2KHR(devHelper.physicalDevice, &surfaceInfo, &surfaceCapabilities2); + if (surfaceCapabilitiesFSE.fullScreenExclusiveSupported == DE_FALSE) + TCU_THROW(NotSupportedError, "VkSurfaceCapabilitiesFullScreenExclusiveEXT::fullScreenExclusiveSupported is set to false"); + + const DeviceInterface& vkd = devHelper.vkd; + const VkDevice device = *devHelper.device; + SimpleAllocator allocator (vkd, device, getPhysicalDeviceMemoryProperties(instHelper.vki, devHelper.physicalDevice)); + + std::vector surfaceFormats = vk::wsi::getPhysicalDeviceSurfaceFormats(instHelper.vki, devHelper.physicalDevice, *surface); + if(surfaceFormats.empty()) + return tcu::TestStatus::fail("No VkSurfaceFormatKHR defined"); + + VkSwapchainCreateInfoKHR swapchainInfo = getBasicSwapchainParameters(testParams.wsiType, instHelper.vki, devHelper.physicalDevice, *surface, surfaceFormats[0], native.windowSize, 2); + + // add information about full screen exclusive to VkSwapchainCreateInfoKHR + VkSurfaceFullScreenExclusiveInfoEXT fseInfo = + { + VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, // VkStructureType sType; + DE_NULL, // void* pNext; + testParams.fseType // VkFullScreenExclusiveEXT fullScreenExclusive; + }; + swapchainInfo.pNext = &fseInfo; + +#if ( DE_OS == DE_OS_WIN32 ) + if (testParams.wsiType == TYPE_WIN32) + { + fseInfo.pNext = &fseWin32Info; + } +#endif + + const Unique swapchain (createSwapchainKHR(vkd, device, &swapchainInfo)); + const std::vector swapchainImages = getSwapchainImages(vkd, device, *swapchain); + + const WsiTriangleRenderer renderer (vkd, + device, + allocator, + context.getBinaryCollection(), + true, + swapchainImages, + swapchainImages, + swapchainInfo.imageFormat, + tcu::UVec2(swapchainInfo.imageExtent.width, swapchainInfo.imageExtent.height)); + + const Unique commandPool (createCommandPool(vkd, device, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, devHelper.queueFamilyIndex)); + + const size_t maxQueuedFrames = swapchainImages.size()*2; + + // We need to keep hold of fences from vkAcquireNextImageKHR to actually + // limit number of frames we allow to be queued. + const std::vector imageReadyFences (createFences(vkd, device, maxQueuedFrames)); + + // We need maxQueuedFrames+1 for imageReadySemaphores pool as we need to pass + // the semaphore in same time as the fence we use to meter rendering. + const std::vector imageReadySemaphores (createSemaphores(vkd, device, maxQueuedFrames+1)); + + // For rest we simply need maxQueuedFrames as we will wait for image + // from frameNdx-maxQueuedFrames to become available to us, guaranteeing that + // previous uses must have completed. + const std::vector renderingCompleteSemaphores (createSemaphores(vkd, device, maxQueuedFrames)); + const std::vector commandBuffers (allocateCommandBuffers(vkd, device, *commandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY, maxQueuedFrames)); + + bool fullScreenAcquired = (testParams.fseType != VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT); + + try + { + const deUint32 numFramesToRender = 60; + + for (deUint32 frameNdx = 0; frameNdx < numFramesToRender; ++frameNdx) + { + const VkFence imageReadyFence = **imageReadyFences[frameNdx%imageReadyFences.size()]; + const VkSemaphore imageReadySemaphore = **imageReadySemaphores[frameNdx%imageReadySemaphores.size()]; + deUint32 imageNdx = ~0u; + + if (!fullScreenAcquired) + { + const VkResult acquireResult = vkd.acquireFullScreenExclusiveModeEXT(device, *swapchain); + + switch (acquireResult) + { + case VK_SUCCESS: + { + fullScreenAcquired = true; + break; + } + case VK_ERROR_INITIALIZATION_FAILED: + { + if (frameNdx > 3) + throw tcu::TestError("vkAcquireFullScreenExclusiveModeEXT was not able to succeed in first 3 draw frames"); + break; + } + case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT: + { + context.getTestContext().getLog() << tcu::TestLog::Message << "Got VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT at vkAcquireFullScreenExclusiveModeEXT. Frame " << frameNdx << tcu::TestLog::EndMessage; + VK_CHECK(acquireResult); + break; + } + default: + { + VK_CHECK(acquireResult); + break; + } + } + } + + if (frameNdx >= maxQueuedFrames) + VK_CHECK(vkd.waitForFences(device, 1u, &imageReadyFence, VK_TRUE, std::numeric_limits::max())); + + VK_CHECK(vkd.resetFences(device, 1, &imageReadyFence)); + + { + const VkResult acquireResult = vkd.acquireNextImageKHR(device, + *swapchain, + std::numeric_limits::max(), + imageReadySemaphore, + (vk::VkFence)0, + &imageNdx); + if (acquireResult == VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT) + context.getTestContext().getLog() << tcu::TestLog::Message << "Got VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT at vkAcquireNextImageKHR" << tcu::TestLog::EndMessage; + VK_CHECK(acquireResult); + } + + TCU_CHECK((size_t)imageNdx < swapchainImages.size()); + + { + const VkSemaphore renderingCompleteSemaphore = **renderingCompleteSemaphores[frameNdx%renderingCompleteSemaphores.size()]; + const VkCommandBuffer commandBuffer = **commandBuffers[frameNdx%commandBuffers.size()]; + const VkPipelineStageFlags waitDstStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + const VkSubmitInfo submitInfo = + { + VK_STRUCTURE_TYPE_SUBMIT_INFO, + DE_NULL, + 1u, + &imageReadySemaphore, + &waitDstStage, + 1u, + &commandBuffer, + 1u, + &renderingCompleteSemaphore + }; + const VkPresentInfoKHR presentInfo = + { + VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, + DE_NULL, + 1u, + &renderingCompleteSemaphore, + 1u, + &*swapchain, + &imageNdx, + (VkResult*)DE_NULL + }; + + renderer.recordFrame(commandBuffer, imageNdx, frameNdx); + VK_CHECK(vkd.queueSubmit(devHelper.queue, 1u, &submitInfo, imageReadyFence)); + const VkResult presentResult = vkd.queuePresentKHR(devHelper.queue, &presentInfo); + if (presentResult == VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT) + context.getTestContext().getLog() << tcu::TestLog::Message << "Got VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT at vkQueuePresentKHR" << tcu::TestLog::EndMessage; + VK_CHECK_WSI(presentResult); + } + } + + VK_CHECK(vkd.deviceWaitIdle(device)); + } + catch (...) + { + // Make sure device is idle before destroying resources + vkd.deviceWaitIdle(device); + throw; + } + + if (fullScreenAcquired && testParams.fseType == VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT) + { + const VkResult releaseResult = vkd.releaseFullScreenExclusiveModeEXT(device, *swapchain); + if (releaseResult == VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT) + context.getTestContext().getLog() << tcu::TestLog::Message << "Got VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT at vkReleaseFullScreenExclusiveModeEXT" << tcu::TestLog::EndMessage; + VK_CHECK(releaseResult); + } + + native.window->setVisible(false); + + return tcu::TestStatus::pass("Rendering tests succeeded"); +} + +void getBasicRenderPrograms (SourceCollections& dst, TestParams) +{ + WsiTriangleRenderer::getPrograms(dst); +} + +} // anonymous + +void createFullScreenExclusiveTests (tcu::TestCaseGroup* testGroup, vk::wsi::Type wsiType) +{ + struct + { + VkFullScreenExclusiveEXT testType; + const char* name; + } fullScreenTestTypes[] = + { + { VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT, "default" }, + { VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT, "allowed" }, + { VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT, "disallowed" }, + { VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT, "application_controlled" }, + }; + + for (size_t fseNdx = 0; fseNdx < DE_LENGTH_OF_ARRAY(fullScreenTestTypes); ++fseNdx) + { + TestParams testParams + { + wsiType, + fullScreenTestTypes[fseNdx].testType + }; + addFunctionCaseWithPrograms(testGroup, fullScreenTestTypes[fseNdx].name, "", getBasicRenderPrograms, fullScreenExclusiveTest, testParams); + } +} + +} // wsi + +} // vkt diff --git a/external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.hpp b/external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.hpp new file mode 100644 index 0000000..68bd46d --- /dev/null +++ b/external/vulkancts/modules/vulkan/wsi/vktWsiFullScreenExclusiveTests.hpp @@ -0,0 +1,41 @@ +#ifndef _VKTWSIFULLSCREENEXCLUSIVETESTS_HPP +#define _VKTWSIFULLSCREENEXCLUSIVETESTS_HPP +/*------------------------------------------------------------------------- + * Vulkan Conformance Tests + * ------------------------ + * + * Copyright (c) 2017 Google Inc. + * Copyright (c) 2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *//*! + * \file + * \brief VK_EXT_full_screen_exclusive extension Tests + *//*--------------------------------------------------------------------*/ + +#include "tcuDefs.hpp" +#include "tcuTestCase.hpp" +#include "vkDefs.hpp" + +namespace vkt +{ +namespace wsi +{ + +void createFullScreenExclusiveTests (tcu::TestCaseGroup* testGroup, vk::wsi::Type wsiType); + +} // wsi +} // vkt + +#endif // _VKTWSIFULLSCREENEXCLUSIVETESTS_HPP diff --git a/external/vulkancts/modules/vulkan/wsi/vktWsiTests.cpp b/external/vulkancts/modules/vulkan/wsi/vktWsiTests.cpp index 2829c0a..167dc3d 100644 --- a/external/vulkancts/modules/vulkan/wsi/vktWsiTests.cpp +++ b/external/vulkancts/modules/vulkan/wsi/vktWsiTests.cpp @@ -33,6 +33,7 @@ #include "vktWsiDisplayTimingTests.hpp" #include "vktWsiSharedPresentableImageTests.hpp" #include "vktWsiColorSpaceTests.hpp" +#include "vktWsiFullScreenExclusiveTests.hpp" namespace vkt { @@ -50,6 +51,7 @@ void createTypeSpecificTests (tcu::TestCaseGroup* testGroup, vk::wsi::Type wsiTy addTestGroup(testGroup, "display_timing", "Display Timing Tests", createDisplayTimingTests, wsiType); addTestGroup(testGroup, "shared_presentable_image", "VK_KHR_shared_presentable_image tests", createSharedPresentableImageTests, wsiType); addTestGroup(testGroup, "colorspace", "ColorSpace tests", createColorSpaceTests, wsiType); + addTestGroup(testGroup, "full_screen_exclusive", "VK_EXT_full_screen_exclusive tests", createFullScreenExclusiveTests, wsiType); } void createWsiTests (tcu::TestCaseGroup* apiTests) diff --git a/external/vulkancts/mustpass/master/vk-default.txt b/external/vulkancts/mustpass/master/vk-default.txt index 217536d..eff9ba1 100644 --- a/external/vulkancts/mustpass/master/vk-default.txt +++ b/external/vulkancts/mustpass/master/vk-default.txt @@ -498077,6 +498077,10 @@ dEQP-VK.wsi.xlib.shared_presentable_image.scale_none.inherit.inherit.continuous dEQP-VK.wsi.xlib.colorspace.extensions dEQP-VK.wsi.xlib.colorspace.basic dEQP-VK.wsi.xlib.colorspace.hdr +dEQP-VK.wsi.xlib.full_screen_exclusive.default +dEQP-VK.wsi.xlib.full_screen_exclusive.allowed +dEQP-VK.wsi.xlib.full_screen_exclusive.disallowed +dEQP-VK.wsi.xlib.full_screen_exclusive.application_controlled dEQP-VK.wsi.xcb.surface.create dEQP-VK.wsi.xcb.surface.create_custom_allocator dEQP-VK.wsi.xcb.surface.create_simulate_oom @@ -498509,6 +498513,10 @@ dEQP-VK.wsi.xcb.shared_presentable_image.scale_none.inherit.inherit.continuous dEQP-VK.wsi.xcb.colorspace.extensions dEQP-VK.wsi.xcb.colorspace.basic dEQP-VK.wsi.xcb.colorspace.hdr +dEQP-VK.wsi.xcb.full_screen_exclusive.default +dEQP-VK.wsi.xcb.full_screen_exclusive.allowed +dEQP-VK.wsi.xcb.full_screen_exclusive.disallowed +dEQP-VK.wsi.xcb.full_screen_exclusive.application_controlled dEQP-VK.wsi.wayland.surface.create dEQP-VK.wsi.wayland.surface.create_custom_allocator dEQP-VK.wsi.wayland.surface.create_simulate_oom @@ -498940,6 +498948,10 @@ dEQP-VK.wsi.wayland.shared_presentable_image.scale_none.inherit.inherit.continuo dEQP-VK.wsi.wayland.colorspace.extensions dEQP-VK.wsi.wayland.colorspace.basic dEQP-VK.wsi.wayland.colorspace.hdr +dEQP-VK.wsi.wayland.full_screen_exclusive.default +dEQP-VK.wsi.wayland.full_screen_exclusive.allowed +dEQP-VK.wsi.wayland.full_screen_exclusive.disallowed +dEQP-VK.wsi.wayland.full_screen_exclusive.application_controlled dEQP-VK.wsi.android.surface.create dEQP-VK.wsi.android.surface.create_custom_allocator dEQP-VK.wsi.android.surface.create_simulate_oom @@ -500092,6 +500104,10 @@ dEQP-VK.wsi.android.shared_presentable_image.scale_down.inherit.inherit.continuo dEQP-VK.wsi.android.colorspace.extensions dEQP-VK.wsi.android.colorspace.basic dEQP-VK.wsi.android.colorspace.hdr +dEQP-VK.wsi.android.full_screen_exclusive.default +dEQP-VK.wsi.android.full_screen_exclusive.allowed +dEQP-VK.wsi.android.full_screen_exclusive.disallowed +dEQP-VK.wsi.android.full_screen_exclusive.application_controlled dEQP-VK.wsi.win32.surface.create dEQP-VK.wsi.win32.surface.create_custom_allocator dEQP-VK.wsi.win32.surface.create_simulate_oom @@ -500524,6 +500540,10 @@ dEQP-VK.wsi.win32.shared_presentable_image.scale_none.inherit.inherit.continuous dEQP-VK.wsi.win32.colorspace.extensions dEQP-VK.wsi.win32.colorspace.basic dEQP-VK.wsi.win32.colorspace.hdr +dEQP-VK.wsi.win32.full_screen_exclusive.default +dEQP-VK.wsi.win32.full_screen_exclusive.allowed +dEQP-VK.wsi.win32.full_screen_exclusive.disallowed +dEQP-VK.wsi.win32.full_screen_exclusive.application_controlled dEQP-VK.wsi.macos.surface.create dEQP-VK.wsi.macos.surface.create_custom_allocator dEQP-VK.wsi.macos.surface.create_simulate_oom @@ -500956,6 +500976,10 @@ dEQP-VK.wsi.macos.shared_presentable_image.scale_none.inherit.inherit.continuous dEQP-VK.wsi.macos.colorspace.extensions dEQP-VK.wsi.macos.colorspace.basic dEQP-VK.wsi.macos.colorspace.hdr +dEQP-VK.wsi.macos.full_screen_exclusive.default +dEQP-VK.wsi.macos.full_screen_exclusive.allowed +dEQP-VK.wsi.macos.full_screen_exclusive.disallowed +dEQP-VK.wsi.macos.full_screen_exclusive.application_controlled dEQP-VK.wsi.display.get_display_properties dEQP-VK.wsi.display.get_display_plane_properties dEQP-VK.wsi.display.get_display_plane_supported_displays diff --git a/framework/platform/android/tcuAndroidPlatform.cpp b/framework/platform/android/tcuAndroidPlatform.cpp index c892e54..b9a4c71 100644 --- a/framework/platform/android/tcuAndroidPlatform.cpp +++ b/framework/platform/android/tcuAndroidPlatform.cpp @@ -226,6 +226,16 @@ public: { } + void setVisible(bool visible) + { + DE_UNREF(visible); + } + + void resize(const UVec2& newSize) + { + DE_UNREF(newSize); + } + ~VulkanWindow (void) { m_window.release(); diff --git a/framework/platform/lnx/tcuLnxVulkanPlatform.cpp b/framework/platform/lnx/tcuLnxVulkanPlatform.cpp index 6f0e554..2c44fdb 100644 --- a/framework/platform/lnx/tcuLnxVulkanPlatform.cpp +++ b/framework/platform/lnx/tcuLnxVulkanPlatform.cpp @@ -64,6 +64,11 @@ public: { } + void setVisible(bool visible) + { + m_window->setVisibility(visible); + } + void resize (const UVec2& newSize) { m_window->setDimensions((int)newSize.x(), (int)newSize.y()); @@ -107,6 +112,11 @@ public: { } + void setVisible(bool visible) + { + m_window->setVisibility(visible); + } + void resize (const UVec2& newSize) { m_window->setDimensions((int)newSize.x(), (int)newSize.y()); @@ -148,6 +158,11 @@ public: { } + void setVisible(bool visible) + { + m_window->setVisibility(visible); + } + void resize (const UVec2& newSize) { m_window->setDimensions((int)newSize.x(), (int)newSize.y()); diff --git a/framework/platform/lnx/tcuLnxVulkanPlatform.hpp b/framework/platform/lnx/tcuLnxVulkanPlatform.hpp index 6d4c2e9..e19d501 100644 --- a/framework/platform/lnx/tcuLnxVulkanPlatform.hpp +++ b/framework/platform/lnx/tcuLnxVulkanPlatform.hpp @@ -39,7 +39,7 @@ public: VulkanPlatform (EventState& eventState); vk::wsi::Display* createWsiDisplay (vk::wsi::Type wsiType) const; vk::Library* createLibrary (void) const; - bool hasDisplay (vk::wsi::Type wsiType) const; + bool hasDisplay (vk::wsi::Type wsiType) const; void describePlatform (std::ostream& dst) const; void getMemoryLimits (vk::PlatformMemoryLimits& limits) const; diff --git a/framework/platform/osx/tcuOSXVulkanPlatform.cpp b/framework/platform/osx/tcuOSXVulkanPlatform.cpp index 61822dd..6f591a1 100644 --- a/framework/platform/osx/tcuOSXVulkanPlatform.cpp +++ b/framework/platform/osx/tcuOSXVulkanPlatform.cpp @@ -49,6 +49,10 @@ public: { } + void setVisible(bool visible) + { + } + void resize (const UVec2& newSize) { m_view->setSize(newSize.x(), newSize.y()); } diff --git a/framework/platform/win32/tcuWin32VulkanPlatform.cpp b/framework/platform/win32/tcuWin32VulkanPlatform.cpp index a72a36e..7edefb5 100644 --- a/framework/platform/win32/tcuWin32VulkanPlatform.cpp +++ b/framework/platform/win32/tcuWin32VulkanPlatform.cpp @@ -55,6 +55,11 @@ public: { } + void setVisible(bool visible) + { + m_window->setVisible(visible); + } + void resize (const UVec2& newSize) { m_window->setSize((int)newSize.x(), (int)newSize.y()); -- 2.7.4