[KMS/DRM] Add Vulkan suport to the KMSDRM_LEGACY backend.Minor text spacing tweaks for better readability. Comment out unused function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
diff --git a/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c b/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c
index 501117f..5a9993d 100644
--- a/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c
+++ b/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c
@@ -42,6 +42,7 @@
#include "SDL_kmsdrm_legacy_opengles.h"
#include "SDL_kmsdrm_legacy_mouse.h"
#include "SDL_kmsdrm_legacy_dyn.h"
+#include "SDL_kmsdrm_legacy_vulkan.h"
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
@@ -62,6 +63,49 @@
#endif
#if 0
+/**************************************************************************************/
+/* UNUSED function because any plane compatible with the CRTC we chose is good enough */
+/* for us, whatever it's type is. Keep it here for documentation purposes. */
+/* It cold be needed sometime in the future, too. */
+/**************************************************************************************/
+
+SDL_bool KMSDRM_IsPlanePrimary (_THIS, drmModePlane *plane) {
+
+ SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
+ SDL_bool ret = SDL_FALSE;
+ int j;
+
+ /* Find out if it's a primary plane. */
+ drmModeObjectProperties *plane_props =
+ KMSDRM_LEGACY_drmModeObjectGetProperties(viddata->drm_fd,
+ plane->plane_id, DRM_MODE_OBJECT_ANY);
+
+ for (j = 0; (j < plane_props->count_props); j++) {
+
+ drmModePropertyRes *prop = KMSDRM_LEGACY_drmModeGetProperty(viddata->drm_fd,
+ plane_props->props[j]);
+
+ if ((strcmp(prop->name, "type") == 0) &&
+ (plane_props->prop_values[j] == DRM_PLANE_TYPE_PRIMARY))
+ {
+ ret = SDL_TRUE;
+ }
+
+ KMSDRM_LEGACY_drmModeFreeProperty(prop);
+
+ }
+
+ KMSDRM_LEGACY_drmModeFreeObjectProperties(plane_props);
+
+ return ret;
+}
+#endif
+
+#if 0
+/***********************************************/
+/* Use these functions if you ever need info */
+/* about the available planes on your machine. */
+/***********************************************/
void print_plane_info(_THIS, drmModePlanePtr plane)
{
@@ -155,12 +199,8 @@ void get_planes_info(_THIS)
KMSDRM_LEGACY_drmModeFreePlaneResources(plane_resources);
}
-
#endif
-
-
-
static int
check_modestting(int devindex)
{
@@ -175,11 +215,17 @@ check_modestting(int devindex)
if (SDL_KMSDRM_LEGACY_LoadSymbols()) {
drmModeRes *resources = KMSDRM_LEGACY_drmModeGetResources(drm_fd);
if (resources) {
- SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, KMSDRM_LEGACY_DRI_DEVFMT " connector, encoder and CRTC counts are: %d %d %d",
- KMSDRM_LEGACY_DRI_PATH, devindex,
- resources->count_connectors, resources->count_encoders, resources->count_crtcs);
-
- if (resources->count_connectors > 0 && resources->count_encoders > 0 && resources->count_crtcs > 0) {
+ SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO,
+ KMSDRM_LEGACY_DRI_DEVFMT
+ " connector, encoder and CRTC counts are: %d %d %d",
+ KMSDRM_LEGACY_DRI_PATH, devindex,
+ resources->count_connectors, resources->count_encoders,
+ resources->count_crtcs);
+
+ if (resources->count_connectors > 0
+ && resources->count_encoders > 0
+ && resources->count_crtcs > 0)
+ {
available = SDL_TRUE;
}
KMSDRM_LEGACY_drmModeFreeResources(resources);
@@ -216,7 +262,8 @@ static int get_dricount(void)
if (folder) {
while ((res = readdir(folder))) {
int len = SDL_strlen(res->d_name);
- if (len > KMSDRM_LEGACY_DRI_DEVNAMESIZE && SDL_strncmp(res->d_name, KMSDRM_LEGACY_DRI_DEVNAME, KMSDRM_LEGACY_DRI_DEVNAMESIZE) == 0) {
+ if (len > KMSDRM_LEGACY_DRI_DEVNAMESIZE && SDL_strncmp(res->d_name,
+ KMSDRM_LEGACY_DRI_DEVNAME, KMSDRM_LEGACY_DRI_DEVNAMESIZE) == 0) {
devcount++;
}
}
@@ -337,6 +384,14 @@ KMSDRM_LEGACY_CreateDevice(int devindex)
device->GL_SwapWindow = KMSDRM_LEGACY_GLES_SwapWindow;
device->GL_DeleteContext = KMSDRM_LEGACY_GLES_DeleteContext;
+#if SDL_VIDEO_VULKAN
+ device->Vulkan_LoadLibrary = KMSDRM_LEGACY_Vulkan_LoadLibrary;
+ device->Vulkan_UnloadLibrary = KMSDRM_LEGACY_Vulkan_UnloadLibrary;
+ device->Vulkan_GetInstanceExtensions = KMSDRM_LEGACY_Vulkan_GetInstanceExtensions;
+ device->Vulkan_CreateSurface = KMSDRM_LEGACY_Vulkan_CreateSurface;
+ device->Vulkan_GetDrawableSize = KMSDRM_LEGACY_Vulkan_GetDrawableSize;
+#endif
+
device->PumpEvents = KMSDRM_LEGACY_PumpEvents;
device->free = KMSDRM_LEGACY_DeleteDevice;
@@ -713,38 +768,6 @@ cleanup:
return ret;
}
-/*UNUSED function. Keep for documentation purposes. */
-SDL_bool KMSDRM_IsPlanePrimary (_THIS, drmModePlane *plane) {
-
- SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
- SDL_bool ret = SDL_FALSE;
- int j;
-
- /* Find out if it's a primary plane. */
- drmModeObjectProperties *plane_props =
- KMSDRM_LEGACY_drmModeObjectGetProperties(viddata->drm_fd,
- plane->plane_id, DRM_MODE_OBJECT_ANY);
-
- for (j = 0; (j < plane_props->count_props); j++) {
-
- drmModePropertyRes *prop = KMSDRM_LEGACY_drmModeGetProperty(viddata->drm_fd,
- plane_props->props[j]);
-
- if ((strcmp(prop->name, "type") == 0) &&
- (plane_props->prop_values[j] == DRM_PLANE_TYPE_PRIMARY))
- {
- ret = SDL_TRUE;
- }
-
- KMSDRM_LEGACY_drmModeFreeProperty(prop);
-
- }
-
- KMSDRM_LEGACY_drmModeFreeObjectProperties(plane_props);
-
- return ret;
-}
-
/* Init the Vulkan-INCOMPATIBLE stuff:
Reopen FD, create gbm dev, create dumb buffer and setup display plane.
This is to be called late, in WindowCreate(), and ONLY if this is not