summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-05-17 22:57:37 -0700
committerKeith Packard <keithp@keithp.com>2017-05-17 22:57:37 -0700
commitc7ec1f439b79a49f25067a52cdc15c6540a6f5b0 (patch)
treec2cabcf59c4975ba6a0ee9b597f0c9b9ca8a5290
parent0bbc015828bdb99e85e6731ce92428557902701f (diff)
Add VK_KEITHP_kms_display extension
This allows the application to provide an existing DRM device file descriptor into the vulkan drivers instead of having the driver open the device itself. There is additional information provided about the desired mode to set on the device; that will be used to apply a mode set on the first presentation request and to restore the mode after a VT switch has occurred. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--CMakeLists.txt6
-rw-r--r--common/vulkan_wrapper.cpp1
-rw-r--r--common/vulkan_wrapper.h4
-rw-r--r--include/vulkan/vulkan.h27
-rw-r--r--layers/CMakeLists.txt5
-rw-r--r--loader/CMakeLists.txt5
-rw-r--r--loader/extension_manual.c2
-rw-r--r--loader/loader.c3
-rw-r--r--loader/wsi.c23
-rw-r--r--loader/wsi.h5
-rw-r--r--scripts/loader_extension_generator.py3
-rw-r--r--scripts/vk.xml28
-rw-r--r--tests/CMakeLists.txt5
13 files changed, 114 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ccfa3e7..2c5cff17 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,8 +24,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
include(FindPkgConfig)
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
- option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON)
+ option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" OFF)
option(BUILD_WSI_MIR_SUPPORT "Build Mir WSI support" OFF)
+ option(BUILD_KMS_SUPPORT "Build KMS support" ON)
set(DEMOS_WSI_SELECTION "XCB" CACHE STRING "Select WSI target for demos (XCB, XLIB, WAYLAND, MIR, DISPLAY)")
if (BUILD_WSI_XCB_SUPPORT)
@@ -40,6 +41,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(Wayland REQUIRED)
endif()
+ if (BUILD_KMS_SUPPORT)
+ find_package(KMS REQUIRED)
+ endif()
if (BUILD_WSI_MIR_SUPPORT)
find_package(Mir REQUIRED)
endif()
diff --git a/common/vulkan_wrapper.cpp b/common/vulkan_wrapper.cpp
index 2f7d8068..6ba61da1 100644
--- a/common/vulkan_wrapper.cpp
+++ b/common/vulkan_wrapper.cpp
@@ -246,6 +246,7 @@ int InitVulkan(void) {
vkGetPhysicalDeviceWin32PresentationSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR>(
dlsym(libvulkan, "vkGetPhysicalDeviceWin32PresentationSupportKHR"));
#endif
+
return 1;
}
diff --git a/common/vulkan_wrapper.h b/common/vulkan_wrapper.h
index 679278fc..b854115a 100644
--- a/common/vulkan_wrapper.h
+++ b/common/vulkan_wrapper.h
@@ -229,6 +229,10 @@ extern PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
extern PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR;
#endif
+#ifdef VK_USE_PLATFORM_KMS_KEITHP
+extern PFN_vkSetKmsDisplayInfoKEITHP vkSetKmsDisplayInfoKEITHP;
+#endif
+
// VK_KHR_sampler_mirror_clamp_to_edge
#ifdef __cplusplus
diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h
index 265100dc..e54aa049 100644
--- a/include/vulkan/vulkan.h
+++ b/include/vulkan/vulkan.h
@@ -214,6 +214,7 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR = 1000007000,
VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000,
VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
+ VK_STRUCTURE_TYPE_KMS_DISPLAY_INFO_KEITHP = 1000010000,
VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000,
VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD = 1000018000,
VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000,
@@ -3844,6 +3845,32 @@ VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
#endif
#endif /* VK_USE_PLATFORM_WIN32_KHR */
+#ifdef VK_USE_PLATFORM_KMS_KEITHP
+
+#include <xf86drmMode.h>
+#include <xf86drm.h>
+
+typedef struct VkKmsDisplayInfoKEITHP {
+ int fd;
+ uint32_t crtc_id;
+ uint32_t *connector_ids;
+ int connector_count;
+ drmModeModeInfoPtr mode;
+} VkKmsDisplayInfoKEITHP;
+
+#define VK_KEITHP_KMS_DISPLAY_SPEC_VERSION 1
+#define VK_KEITHP_KMS_DISPLAY_EXTENSION_NAME "VK_KEITHP_kms_display"
+
+typedef VkResult (VKAPI_PTR *PFN_vkSetKmsDisplayInfoKEITHP)(VkInstance instance, const VkKmsDisplayInfoKEITHP *pKmsInfo);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkSetKmsDisplayInfoKEITHP(
+ VkInstance instance,
+ const VkKmsDisplayInfoKEITHP *pKmsInfo);
+#endif
+
+#endif /* VK_USE_PLATFORM_KMS_KEITHP */
+
#define VK_KHR_sampler_mirror_clamp_to_edge 1
#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION 1
#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME "VK_KHR_sampler_mirror_clamp_to_edge"
diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt
index 7a35df7e..c4f8c1b4 100644
--- a/layers/CMakeLists.txt
+++ b/layers/CMakeLists.txt
@@ -9,6 +9,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_definitions(-DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XCB_KHX)
endif()
+ if (BUILD_KMS_SUPPORT)
+ add_definitions(-DVK_USE_PLATFORM_KMS_KEITHP)
+ include_directories(${KMS_INCLUDE_DIR})
+ endif()
+
if (BUILD_WSI_XLIB_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR -DVK_USE_PLATFORM_XLIB_KHX -DVK_USE_PLATFORM_XLIB_XRANDR_EXT)
endif()
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index d15f09cc..c8966ea3 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -30,6 +30,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
endif()
+ if (BUILD_KMS_SUPPORT)
+ add_definitions(-DVK_USE_PLATFORM_KMS_KEITHP)
+ include_directories(${KMS_INCLUDE_DIR})
+ endif()
+
if (BUILD_WSI_XLIB_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR -DVK_USE_PLATFORM_XLIB_XRANDR_EXT)
endif()
diff --git a/loader/extension_manual.c b/loader/extension_manual.c
index 6ddb9b09..209afd16 100644
--- a/loader/extension_manual.c
+++ b/loader/extension_manual.c
@@ -583,4 +583,4 @@ out:
}
return res;
-} \ No newline at end of file
+}
diff --git a/loader/loader.c b/loader/loader.c
index 48e90647..aa83ce2d 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -4811,6 +4811,9 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) {
// For each ICD, query the number of physical devices, and then get an
// internal value for those physical devices.
for (uint32_t icd_idx = 0; NULL != icd_term; icd_term = icd_term->next, icd_idx++) {
+ extern const VkKmsDisplayInfoKEITHP *globalDisplayInfo;
+ if (icd_term->dispatch.SetKmsDisplayInfoKEITHP)
+ res = icd_term->dispatch.SetKmsDisplayInfoKEITHP(icd_term->instance, globalDisplayInfo);
res = icd_term->dispatch.EnumeratePhysicalDevices(icd_term->instance, &icd_phys_dev_array[icd_idx].count, NULL);
if (VK_SUCCESS != res) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
diff --git a/loader/wsi.c b/loader/wsi.c
index 131ca518..93e9cd6f 100644
--- a/loader/wsi.c
+++ b/loader/wsi.c
@@ -1031,6 +1031,29 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXlibPresentationSuppo
}
#endif // VK_USE_PLATFORM_XLIB_KHR
+#if VK_USE_PLATFORM_KMS_KEITHP
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkSetKmsDisplayInfoKEITHP(VkInstance instance,
+ const VkKmsDisplayInfoKEITHP *pDisplayInfo)
+{
+ const VkLayerInstanceDispatchTable *disp;
+ disp = loader_get_instance_layer_dispatch(instance);
+ VkResult res;
+
+ res = disp->SetKmsDisplayInfoKEITHP(instance, pDisplayInfo);
+ return res;
+}
+
+const VkKmsDisplayInfoKEITHP *globalDisplayInfo;
+
+VKAPI_ATTR VkResult VKAPI_CALL terminator_SetKmsDisplayInfoKEITHP(VkInstance instance,
+ const VkKmsDisplayInfoKEITHP *pDisplayInfo)
+{
+ printf ("SetKmsDisplayInfoKEITHP\n");
+ globalDisplayInfo = pDisplayInfo;
+ return VK_SUCCESS;
+}
+#endif // VK_USE_PLATFORM_KMS_KEITHP
+
#ifdef VK_USE_PLATFORM_ANDROID_KHR
// Functions for the VK_KHR_android_surface extension:
diff --git a/loader/wsi.h b/loader/wsi.h
index 519a7aac..e681ae47 100644
--- a/loader/wsi.h
+++ b/loader/wsi.h
@@ -142,4 +142,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSharedSwapchainsKHR(VkDevice dev
const VkAllocationCallbacks *pAllocator,
VkSwapchainKHR *pSwapchains);
+#ifdef VK_USE_PLATFORM_KMS_KEITHP
+VKAPI_ATTR VkResult VKAPI_CALL terminator_SetKmsDisplayInfoKEITHP(VkInstance instance,
+ const VkKmsDisplayInfoKEITHP *pDisplayInfo);
+#endif
+
#endif // WSI_H
diff --git a/scripts/loader_extension_generator.py b/scripts/loader_extension_generator.py
index 8a8586f2..c71e9fca 100644
--- a/scripts/loader_extension_generator.py
+++ b/scripts/loader_extension_generator.py
@@ -33,7 +33,8 @@ WSI_EXT_NAMES = ['VK_KHR_surface',
'VK_KHR_win32_surface',
'VK_KHR_android_surface',
'VK_KHR_swapchain',
- 'VK_KHR_display_swapchain']
+ 'VK_KHR_display_swapchain',
+ 'VK_KEITHP_kms_display']
AVOID_EXT_NAMES = ['VK_EXT_debug_report']
diff --git a/scripts/vk.xml b/scripts/vk.xml
index b8db2ab4..3759a2ec 100644
--- a/scripts/vk.xml
+++ b/scripts/vk.xml
@@ -67,6 +67,7 @@ maintained in the master branch of the Khronos Vulkan GitHub project.
<tag name="KHR" author="Khronos" contact="Tom Olson @tom.olson"/>
<tag name="EXT" author="Multivendor" contact="Jon Leech @oddhack"/>
<tag name="MESA" author="Mesa open source project" contact="Chad Versace @chadversary, Daniel Stone @fooishbar, David Airlie @airlied, Jason Ekstrand @jekstrand"/>
+ <tag name="KEITHP" author="keithp.com" contact="keithp @keithp.com"/>
</tags>
<!-- SECTION: Vulkan type definitions -->
@@ -81,6 +82,8 @@ maintained in the master branch of the Khronos Vulkan GitHub project.
<type category="include">#include &lt;<name>wayland-client.h</name>&gt;</type>
<type category="include">#include &lt;<name>windows.h</name>&gt;</type>
<type category="include">#include &lt;<name>xcb/xcb.h</name>&gt;</type>
+ <type catagory="include">#include &lt;<name>xf86drmMode.h</name>&gt;</type>
+ <type catagory="include">#include &lt;<name>xf86drm.h</name>&gt;</type>
<type requires="X11/Xlib.h" name="Display"/>
<type requires="X11/Xlib.h" name="VisualID"/>
@@ -100,6 +103,7 @@ maintained in the master branch of the Khronos Vulkan GitHub project.
<type requires="xcb/xcb.h" name="xcb_connection_t"/>
<type requires="xcb/xcb.h" name="xcb_visualid_t"/>
<type requires="xcb/xcb.h" name="xcb_window_t"/>
+ <type requires="xf86drmMode.h" name="drmModeModeInfoPtr"/>
<type category="define">#define <name>VK_MAKE_VERSION</name>(major, minor, patch) \
(((major) &lt;&lt; 22) | ((minor) &lt;&lt; 12) | (patch))</type>
@@ -1538,6 +1542,14 @@ maintained in the master branch of the Khronos Vulkan GitHub project.
<member noautovalidity="true"><type>xcb_connection_t</type>* <name>connection</name></member>
<member><type>xcb_window_t</type> <name>window</name></member>
</type>
+ <type catagory="struct" name="VkKmsDisplayInfoKEITHP">
+ <member values="VK_STRUCTURE_TYPE_KMS_DISPLAY_INFO_KEITHP"><type>VkStructureType</type> <name>sType</name></member>
+ <member><type>int</type> <name>fd</name></member>
+ <member><type>uint32_t</type> <name>crtc_id</name></member>
+ <member><type>uint32_t</type>* <name>connector_ids</name></member>
+ <member><type>int</type> <name>connector_count</name></member>
+ <member><type>drmModeModeInfoPtr</type> <name>mode</name></member>
+ </type>
<type category="struct" name="VkSurfaceFormatKHR" returnedonly="true">
<member><type>VkFormat</type> <name>format</name></member> <!-- Supported pair of rendering format -->
<member><type>VkColorSpaceKHR</type> <name>colorSpace</name></member> <!-- and color space for the surface -->
@@ -4334,6 +4346,13 @@ maintained in the master branch of the Khronos Vulkan GitHub project.
<param optional="true">const <type>VkAllocationCallbacks</type>* <name>pAllocator</name></param>
<param><type>VkSurfaceKHR</type>* <name>pSurface</name></param>
</command>
+
+ <command successcodes="VK_SUCCESS" errorcodes="VK_ERROR_OUT_OF_HOST_MEMORY,VK_ERROR_OUT_OF_DEVICE_MEMORY">
+ <proto><type>VkResult</type> <name>vkSetKmsDisplayInfoKEITHP</name></proto>
+ <param><type>VkInstance</type> <name>instance</name></param>
+ <param>const <type>VkKmsDisplayInfoKEITHP</type>* <name>pDisplayInfo</name></param>
+ </command>
+
<command>
<proto><type>VkBool32</type> <name>vkGetPhysicalDeviceXcbPresentationSupportKHR</name></proto>
<param><type>VkPhysicalDevice</type> <name>physicalDevice</name></param>
@@ -5117,6 +5136,15 @@ maintained in the master branch of the Khronos Vulkan GitHub project.
<command name="vkGetPhysicalDeviceXcbPresentationSupportKHR"/>
</require>
</extension>
+ <extension name="VK_KEITHP_kms_display" number="1" type="instance" requires="VK_KHR_surface" protect="VK_USE_PLATFORM_KMS_KEITHP" supported="vulkan">
+ <require>
+ <enum value="1" name="VK_KEITHP_KMS_DISPLAY_SPEC_VERSION"/>
+ <enum value="&quot;VK_KEITHP_kms_display&quot;" name="VK_KEITHP_KMS_DISPLAY_EXTENSION_NAME"/>
+ <enum offset="0" extends="VkStructureType" name="VK_STRUCTURE_TYPE_KMS_DISPLAY_INFO_KEITHP"/>
+ <type name="VkKmsDisplayInfoKEITHP"/>
+ <command name="vkSetKmsDisplayInfoKEITHP"/>
+ </require>
+ </extension>
<extension name="VK_KHR_wayland_surface" number="7" type="instance" requires="VK_KHR_surface" protect="VK_USE_PLATFORM_WAYLAND_KHR" supported="vulkan">
<require>
<enum value="6" name="VK_KHR_WAYLAND_SURFACE_SPEC_VERSION"/>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index df41931d..fddc0363 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -10,6 +10,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
endif()
+ if (BUILD_KMS_SUPPORT)
+ add_definitions(-DVK_USE_PLATFORM_KMS_KEITHP)
+ include_directories(${KMS_INCLUDE_DIR})
+ endif()
+
if (BUILD_WSI_XLIB_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
endif()