···3838};
39394040/*!
4141- * Window type to use.
4242- *
4343- * @ingroup comp_main
4444- */
4545-enum window_type
4646-{
4747- WINDOW_NONE = 0,
4848- WINDOW_AUTO,
4949- WINDOW_XCB,
5050- WINDOW_WAYLAND,
5151- WINDOW_DIRECT_WAYLAND,
5252- WINDOW_DIRECT_RANDR,
5353- WINDOW_DIRECT_NVIDIA,
5454- WINDOW_ANDROID,
5555- WINDOW_MSWIN,
5656- WINDOW_VK_DISPLAY,
5757-};
5858-5959-6060-/*!
6141 * Settings for the compositor.
6242 *
6343 * @ingroup comp_main
···7252 VkColorSpaceKHR color_space;
7353 VkPresentModeKHR present_mode;
74547575- //! Window type to use.
7676- enum window_type window_type;
5555+ //! Preferred window type to use, not actual used.
5656+ const char *target_identifier;
77577858 //! display string forced by user or NULL
7959 const char *nvidia_display;
+75
src/xrt/compositor/main/comp_target.h
···519519 *ct_ptr = NULL;
520520}
521521522522+/*!
523523+ * A factory of targets.
524524+ *
525525+ * @ingroup comp_main
526526+ */
527527+struct comp_target_factory
528528+{
529529+ //! Pretty loggable name of target type.
530530+ const char *name;
531531+532532+ //! Short all lowercaps identifier for target type.
533533+ const char *identifier;
534534+535535+ //! Does this factory require Vulkan to have been initialized.
536536+ bool requires_vulkan_for_create;
537537+538538+ /*!
539539+ * Is this a deferred target that can have it's creation
540540+ * delayed even further then after Vulkan initialization.
541541+ */
542542+ bool is_deferred;
543543+544544+ //! Required instance extensions.
545545+ const char **required_instance_extensions;
546546+547547+ //! Required instance extension count.
548548+ size_t required_instance_extension_count;
549549+550550+ /*!
551551+ * Checks if this target can be detected, is the preferred target or
552552+ * some other special considiration that this target should be used over
553553+ * all other targets.
554554+ *
555555+ * This is needed for NVIDIA direct mode which window must be created
556556+ * after vulkan has initialized.
557557+ */
558558+ bool (*detect)(struct comp_target_factory *ctf, struct comp_compositor *c);
559559+560560+ /*!
561561+ * Create a target from this factory, some targets requires Vulkan to
562562+ * have been initialised, see @ref requires_vulkan_for_create.
563563+ */
564564+ bool (*create_target)(struct comp_target_factory *ctf, struct comp_compositor *c, struct comp_target **out_ct);
565565+};
566566+567567+/*!
568568+ * @copydoc comp_target_factory::detect
569569+ *
570570+ * @public @memberof comp_target_factory
571571+ * @ingroup comp_main
572572+ */
573573+static inline bool
574574+comp_target_factory_detect(struct comp_target_factory *ctf, struct comp_compositor *c)
575575+{
576576+ COMP_TRACE_MARKER();
577577+578578+ return ctf->detect(ctf, c);
579579+}
580580+581581+/*!
582582+ * @copydoc comp_target_factory::create_target
583583+ *
584584+ * @public @memberof comp_target_factory
585585+ * @ingroup comp_main
586586+ */
587587+static inline bool
588588+comp_target_factory_create_target(struct comp_target_factory *ctf,
589589+ struct comp_compositor *c,
590590+ struct comp_target **out_ct)
591591+{
592592+ COMP_TRACE_MARKER();
593593+594594+ return ctf->create_target(ctf, c, out_ct);
595595+}
596596+522597523598#ifdef __cplusplus
524599}
+22-4
src/xrt/compositor/main/comp_window.h
···2727 */
28282929#ifdef VK_USE_PLATFORM_XCB_KHR
3030+3031/*!
3132 * Create a xcb window.
3233 *
···3536 */
3637struct comp_target *
3738comp_window_xcb_create(struct comp_compositor *c);
3838-#endif
3939+4040+extern struct comp_target_factory comp_target_factory_xcb;
4141+4242+#endif // VK_USE_PLATFORM_XCB_KHR
39434044#ifdef VK_USE_PLATFORM_WAYLAND_KHR
4545+4146/*!
4247 * Create a wayland window.
4348 *
···4752struct comp_target *
4853comp_window_wayland_create(struct comp_compositor *c);
49545555+extern struct comp_target_factory comp_target_factory_wayland;
5656+5057/*!
5158 * Create a direct surface to a HMD using Wayland.
5259 *
···5562struct comp_target *
5663comp_window_direct_wayland_create(struct comp_compositor *c);
57645858-#endif
6565+extern struct comp_target_factory comp_target_factory_direct_wayland;
6666+6767+#endif // VK_USE_PLATFORM_WAYLAND_KHR
59686069#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
6170/*!
···6776struct comp_target *
6877comp_window_direct_randr_create(struct comp_compositor *c);
69787979+extern struct comp_target_factory comp_target_factory_direct_randr;
8080+7081/*!
7182 * Create a direct surface to an HMD on NVIDIA.
7283 *
···7586 */
7687struct comp_target *
7788comp_window_direct_nvidia_create(struct comp_compositor *c);
7878-#endif
8989+9090+extern struct comp_target_factory comp_target_factory_direct_nvidia;
9191+#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT
79929393+#if 1
8094/*!
8195 * Create a direct surface to an HMD on VkDisplay.
8296 *
···86100struct comp_target *
87101comp_window_vk_display_create(struct comp_compositor *c);
881028989-#ifdef XRT_OS_ANDROID
103103+extern struct comp_target_factory comp_target_factory_vk_display;
104104+#endif // 1
90105106106+#ifdef XRT_OS_ANDROID
91107/*!
92108 * Create a surface to an HMD on Android.
93109 *
···97113struct comp_target *
98114comp_window_android_create(struct comp_compositor *c);
99115116116+extern struct comp_target_factory comp_target_factory_android;
100117#endif // XRT_OS_ANDROID
101118102119#ifdef XRT_OS_WINDOWS
···110127struct comp_target *
111128comp_window_mswin_create(struct comp_compositor *c);
112129130130+extern struct comp_target_factory comp_target_factory_mswin;
113131#endif // XRT_OS_WINDOWS
114132115133#ifdef __cplusplus
···234234 if (ret != VK_SUCCESS) {
235235 COMP_ERROR(cts->base.c, "vkAcquireXlibDisplayEXT: %s (0x%016" PRIx64 ")", vk_result_string(ret),
236236 (uint64_t)display);
237237- if (cts->base.c->settings.window_type == WINDOW_DIRECT_NVIDIA &&
238238- ret == VK_ERROR_INITIALIZATION_FAILED) {
239239- COMP_ERROR(cts->base.c,
240240- "This can be caused by the AllowHMD "
241241- "xorg.conf option. Please make sure that "
242242- "AllowHMD is not set (like in '99-HMD.conf' "
243243- "from OpenHMD) and that the desktop is not "
244244- "currently extended to this display.");
245245- }
237237+ }
238238+ if (ret == VK_ERROR_INITIALIZATION_FAILED) {
239239+ COMP_ERROR(
240240+ cts->base.c,
241241+ "If you are using the NVIDIA proprietary driver the above error can be caused by the AllowHMD "
242242+ "xorg.conf option. Please make sure that AllowHMD is not set (like in '99-HMD.conf' from OpenHMD) "
243243+ "and that the desktop is not currently extended to this display.");
246244 }
247245 return ret;
248246}