Commit graph

176 commits

Author SHA1 Message Date
Lubosz Sarnecki 7186bddf60 c/comp+ipc: Use array indices again.
This fixes a regression introduced by the IPC and layer rendering
patchsets and passes the array_index to the correct places, so the
correct VkImageView is used instead of the one with index 0.
2020-06-02 12:42:42 +02:00
Jakob Bornecrantz 77c2b9cb5d c/main: Include <math.h> in comp_layer_renderer.c 2020-05-29 23:37:22 +01:00
Lubosz Sarnecki 1e8106c974 c/compositor: Render multiple layers without IPC.
Hook up layer rendering when XRT_FEATURE_SERVICE is not set.
2020-05-28 22:16:57 +00:00
Jakob Bornecrantz 066009c0c5 c/layer_renderer: Enable blending. 2020-05-28 22:16:57 +00:00
Lubosz Sarnecki d0539161dc c/renderer+ipc: Use layer renderer.
Make the renderer and IPC aware of multiple projection and quad layers
using the layer renderer.

Remove redundant code related to idle images and imported buffers and
command buffer rebuild, since we now always just display the layer
renderer's frame buffer.

Get view and projection properties from xrt_device.
2020-05-28 22:16:57 +00:00
Lubosz Sarnecki aedd4d9ff8 c/layers: Implement layer renderer.
Implements a layer renderer capable of handling multiple quad
and projection layers rendered in it's own Vulkan pipeline.
2020-05-28 22:16:57 +00:00
Jakob Bornecrantz aa0523e535 c/main: Only allocate one image for static swapchains 2020-05-27 21:57:48 +01:00
Ryan Pavlik 5383944f85 comp/main: Fix warning 2020-05-26 11:25:03 -05:00
Jakob Bornecrantz 129d76687e c/main: Idle VkDevice after presenting VkSwapchain 2020-05-26 11:33:58 +01:00
Jakob Bornecrantz 7ab48b691c c/main&ipc: Adopt to flip y in layers change
Client side changes by Lubosz Sarnecki.
2020-05-26 11:33:58 +01:00
Jakob Bornecrantz 83ace60132 c/main: Add simple support for new layer interface 2020-05-26 11:33:58 +01:00
Lubosz Sarnecki 136794ab63 c/distortion: Idle before running destructor. 2020-05-11 20:22:51 +01:00
Lubosz Sarnecki 3e88a850ff c/renderer: Use vk_submit_cmd_buffer from vk_helpers. 2020-05-11 20:22:51 +01:00
Lubosz Sarnecki dc45605c84 c/renderer: Use vk_init_cmd_buffer from vk_helpers. 2020-05-11 20:22:51 +01:00
Lubosz Sarnecki f131739c00 aux/vk: Take VkExtent2D and VkImageUsageFlags in vk_create_image_simple. 2020-05-11 20:21:58 +01:00
Lubosz Sarnecki 0e5d10ca39 c/renderer: Rename comment. 2020-05-11 20:21:58 +01:00
Lubosz Sarnecki 501d8dadd4 c/main: Split nvidia test to function. 2020-05-11 20:21:58 +01:00
Christoph Haag d95c77ad54 comp: Also enable vk debug print with XRT_COMPOSITOR_PRINT_DEBUG
This is useful because it prints which GPU the compositor runs on.
2020-05-05 15:12:08 +02:00
Ryan Pavlik 457d411016 comp: Remaining 32-bit warning fixes 2020-04-29 17:47:32 -05:00
Ryan Pavlik 233c63a773 comp: Fix Wint-to-pointer-cast warnings on 32-bit.
Culprit is a Vulkan non-dispatchable handle:
Fix is simpler than for OpenXR because we aren't a Vulkan
implementation so they're all opaque to us.
2020-04-29 17:44:07 -05:00
Lubosz Sarnecki 5ba751a239 c/renderer: Expose idle image control. 2020-04-29 09:58:52 +01:00
Pete Black 8082e8dbca c/renderer: Add new reset rendering function 2020-04-29 09:58:52 +01:00
Ryan Pavlik 128abac9e8 comp: Codespell fixes. 2020-04-24 15:30:46 -05:00
Lubosz Sarnecki ba3b220ad2 c/renderer: Use gray as idle image color. 2020-04-22 22:00:13 +01:00
Pete Black ccb1b911f6 c/client: Get the supported formats from the fd compositor 2020-04-22 22:00:13 +01:00
Jakob Bornecrantz c8b4a00482 comp: Delay swapchain destruction until a safe time, like end frame. 2020-04-15 19:57:46 +01:00
Lubosz Sarnecki 916d7708c2 c/renderer: Don't wait for device idle every frame.
Do wait on device idle when destroying the swap chain.
Don't wait on device idle multiple times in resize.

Validation on NVIDA and AMD is happy when only keeping
the two idles when resizing and destroying the swapchain.
2020-04-15 18:07:17 +02:00
Lubosz Sarnecki e477452ac6 c/renderer: Add fences for each command buffer.
Wait for fences on vkQueueSubmit.
2020-04-15 18:07:17 +02:00
Lubosz Sarnecki bda1cdaee1 c/renderer: Use only one buffer counter cache.
Use the same counter for frame and command buffers, as their number is
equal, which is retrieved from swapchain.image_count.
Use the struct member num_buffers in favor of passing it as parameter.
Reuse some command buffer functions.
2020-04-15 16:43:57 +02:00
Lubosz Sarnecki ddc7ceb214 c/renderer: Don't wait on device idle after acquiring swapchain image.
vkAcquireNextImageKHR is synchronized with the present_complete
semaphore.
2020-04-15 16:43:57 +02:00
Lubosz Sarnecki a34ad629f7 c/renderer: Don't wait idle queue after present.
This is not nesseccary as the vkQueuePresentKHR is synchronized by the
render_complete semaphore.
2020-04-15 16:38:54 +02:00
Lubosz Sarnecki 6cb99ea8bf c/renderer: Return false when vkEndCommandBuffer fails. 2020-04-15 14:00:35 +02:00
Pete Black c02f89dc18 comp: Spell check 2020-04-09 17:34:27 +01:00
Lubosz Sarnecki bf49a421ba c/direct: Use common init swapchain function.
Simplify and add error messages.
2020-04-09 16:15:17 +00:00
Lubosz Sarnecki 77207ed585 c/direct: Shorten displays member names. 2020-04-09 16:15:17 +00:00
Lubosz Sarnecki 29b771818e c/direct: Move common direct mode code to comp_window_direct.
Create code file for common direct mode code.

Make common functions take generic parameters.

Use common code in randr and nvidia back ends.

Remove redunant includes.
2020-04-09 16:15:17 +00:00
Lubosz Sarnecki 94bc4cba28 c/direct: Split NVIDIA and RandR backends.
Rename functions and structs.

Define unused function overrides separatelty.

c/window: Define new backend init methods.
2020-04-09 16:15:17 +00:00
Lubosz Sarnecki 4ddcca7abd w/direct_mode: Use same num_displays variable for NVIDIA and RandR. 2020-04-09 16:15:17 +00:00
Pete Black 80d1d29cb5 comp: Tidy and spell check 2020-04-09 14:50:35 +01:00
Lubosz Sarnecki 6b05c216ce c/settings: Add a bunch of display strings to NVIDIA whitelist.
Whitelist Oculus DK1, DK2 and CV1.
Whitelist Vive Pro and Valve Index.
2020-04-07 13:45:11 +00:00
Lubosz Sarnecki 56a8e80844 c/direct_mode: Print meaningful error if no display matches NVIDIA whitelist. 2020-04-07 13:45:11 +00:00
Lubosz Sarnecki 7da70568be c/direct_mode: Use VkDisplayModeParametersKHR.
In favor of own struct to determine best available mode.
The loop now also starts as one, as we do not need compare the 0th mode
it itself and returns if there is only one mode.
2020-04-07 15:38:11 +02:00
Lubosz Sarnecki 7afb012544 c/direct_mode: Check if NVIDIA path found any displays.
This helps failing earlier with an NVIDIA Optimus setup, which currently
is not supported.
2020-04-07 15:00:16 +02:00
Lubosz Sarnecki 6158a23dd9 c/direct_mode: Port to plain C. 2020-04-07 15:00:16 +02:00
Lubosz Sarnecki 16d6500923 c/direct_mode: Don't cache enumerated modes in a std:map. 2020-04-07 15:00:16 +02:00
Lubosz Sarnecki 015d9457fe c/direct_mode: Extract append_randr_display function
Don't allocate string when it's not needed.
2020-04-07 15:00:16 +02:00
Lubosz Sarnecki b399960f67 c/direct_mode: Cast display int only for comparision with size().
It is clearer to leave `int display` from settings as signed integer and
cast only for the comparision with the unsigned vector size.
2020-04-07 15:00:16 +02:00
Lubosz Sarnecki a449ed174a c/direct_mode: Create append_nvidia_entry_on_match function. 2020-04-07 15:00:16 +02:00
Lubosz Sarnecki f8c99b0230 c/direct_mode: Use ARRAY_SIZE macro. 2020-04-07 15:00:16 +02:00
Lubosz Sarnecki c0ae309415 c/direct_mode: Remove unused nv_modes map. 2020-04-07 15:00:16 +02:00
Lubosz Sarnecki 865b668ee7 c/xcb: Port to plain C.
The code was already essentialy C, just needed to replace the pairs with
structs and the vector with an array, it was fixed length anyway.

The code feels more natural in C.
2020-04-07 15:00:16 +02:00
Lubosz Sarnecki 1b7b8c163f comp: Further remove unused struct field initializers. 2020-04-01 12:50:10 +00:00
Lubosz Sarnecki b6d8d4b458 comp: Don't initialize unused fields in Vulkan structs.
In order to save redundancy with initializing empty fields with NULL / 0
values and improve readability of the Vulkan code.

This patch also uses struct initializers where possible.

This essentially reverts 1eae45212e.
2020-04-01 12:50:10 +00:00
Lubosz Sarnecki 4d0c49096d comp/window_direct_mode: Use XCB/Xlib interop.
Since there currently is no Vulkan extension that takes XCB handles to
aqcuire the display Xlib interop needs to be used.

Before this patch Monado was opening connections for both APIs, which
introduced overhead.

Even though all XCB handles can be casted to Xlib ones, this cannot be
done with the main xcb_connection_t / Display. In it's design the
interop between both APIs can create a xcb_connection_t from a XCB
handle, but not the other way round. So in an interop case the Xlib
connection is the main one, since it's on a higher level.
More information on this can be found here:
https://xcb.freedesktop.org/MixingCalls/

Unfortunately the clean solution for this would be to specify a Vulkan
extension that takes XCB handles. This would make sense since Vulkan
is aware of XCB in other parts of the API as well. In Mesa the Xlib
structs will be ultimately casted to XCB.
2020-03-31 17:47:17 +02:00
Lubosz Sarnecki 20f281631b comp: Don't leak xcb replies.
According the XCB documentation the reply structs must be freed. I found
this when running a minimal example related to the direct mode code in
valgrind.
2020-03-31 17:47:01 +02:00
Jakob Bornecrantz a54b92162e comp: Fix accidental code change from commit 9b662596
Spotted by @mpiatka.
2020-03-09 14:40:10 +00:00
Christoph Haag e8ccb07db7 st/gui: Add compositor frame timing graph to debug ui 2020-03-09 12:59:12 +01:00
Ryan Pavlik f3eac87504 xrt: Correct usage of XRT_MAYBE_UNUSED on functions.
It shouldn't be used on a function marked "static inline" - that's
sufficient to avoid the warning. So, it should almost never be in
a header.
2020-03-04 11:15:35 +00:00
Ryan Pavlik b1b451eb96 comp: Fix 32-bit warnings 2020-03-03 10:50:41 +00:00
Ryan Pavlik 5af6182810 comp: Fix 32-bit porting issues. 2020-03-03 10:33:14 +00:00
Jakob Bornecrantz 0619190d2b build: Refactor how config defines are handled
With loads of changes from Ryan.
2020-03-03 10:33:14 +00:00
Jakob Bornecrantz a925af90e7 xrt: Do not pass in timestate into compositor 2020-03-02 20:18:49 +00:00
Jakob Bornecrantz 8c06787d93 comp: Refactor documentation 2020-03-02 12:00:22 +00:00
Jakob Bornecrantz b308facf90 comp: Move all glue code into client folder 2020-03-02 12:00:22 +00:00
Jakob Bornecrantz 3ca7fbf2f0 comp: Remove common directory 2020-03-02 12:00:22 +00:00
Jakob Bornecrantz aeef692e08 xrt: Refactor out main compositor creating into own interface 2020-03-02 12:00:22 +00:00
Christoph Haag 1cf742a3dc comp: Add XRT_COMPOSITOR_DESIRED_MODE env var to choose mode for direct mode.
The variable should be set to the index in the enumeration of a modes according to VK_KHR_display.

Monado can print a list of available modes with their indices with the env var XRT_COMPOSITOR_PRINT_MODES=1.
2020-02-19 13:51:00 +00:00
Christoph Haag c2250e5af0 comp: print available modes with XRT_COMPOSITOR_PRINT_MODES=1
To not clutter the user's output with debug info, add a variable to print only the available modes.
2020-02-19 13:51:00 +00:00
Christoph Haag 6b8103f31b comp: Update nominal frame interval to match chosen mode in direct mdoe
This value is used in xrWaitFrame() to throttle the application's rendering
down to the refresh rate of the HMD.
2020-02-19 13:51:00 +00:00
Christoph Haag 36d6b71e8a comp: Choose best mode for direct mode by default
Best mode means: first maximize the rendered pixels, then maximize the refresh rate.
2020-02-19 13:51:00 +00:00
Jakob Bornecrantz 2114fc877d comp: Add option to draw wireframe 2020-01-25 20:19:13 +00:00
Ryan Pavlik 682f41a37c comp: Fix build when VK_USE_PLATFORM_XLIB_XRANDR_EXT is not defined 2020-01-14 11:51:12 -06:00
Ryan Pavlik 6d60227e06 comp: More renaming for clarity 2019-12-07 18:25:37 +00:00
Ryan Pavlik 9668437c78 comp: Rename comp_xlib_client to indicate it's also GL related 2019-12-07 18:25:37 +00:00
Ryan Pavlik a6d9eea394 comp: Port memory allocation to the helper macros 2019-12-07 18:24:56 +00:00
Ryan Pavlik 90e57a4e8a xrt: Fix types related to EGL.
Fixes #46
2019-12-03 09:30:31 -06:00
Simon Ser 5eacb6f309
xrt: add support for OpenGL ES
This commit advertises the extension and adds support for
xrGetOpenGLESGraphicsRequirementsKHR
2019-11-18 15:16:15 +01:00
Julian Eisel 05b069b0a0 Fix two use-after-free's and multiple memory leaks 2019-11-13 21:53:16 +01:00
Drew DeVault e5a9cbb2f9
Implement XR_MND_egl_enable
This extension introduces a more robust way of creating an XrSession for
OpenGL. It also lays the groundwork for future OpenGL ES support.

https://github.com/KhronosGroup/OpenXR-Docs/pull/40

Signed-off-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Drew DeVault <sir@cmpwn.com>
2019-11-06 10:07:21 +01:00
Simon Ser 36102bfa1e
comp: make Wayland window unresizable
This prevents the compositor from issuing resize requests. We ignore
those anyway.
2019-10-31 16:42:26 +01:00
Christoph Haag 7d9ef2f371 comp: Add setting to force a vulkan gpu index 2019-10-25 21:05:06 +02:00
Jakob Bornecrantz 9b6625961a comp: Implement new mesh shader 2019-10-25 13:05:54 +00:00
Ryan Pavlik e90ea99aa8 comp: Adjust frame waiting logic to behave correctly.
Some sub-calculations are still slightly hacky,
but now the overall structure is correct.
2019-10-23 17:18:46 +02:00
pblack e32902843c comp: Add chromatic aberration correction to mesh 2019-10-22 14:44:26 +01:00
Jakob Bornecrantz 315d3b65f1 comp: Do not destry VK_NULL_HANDLE buffers and memory 2019-10-10 22:11:09 +01:00
Jakob Bornecrantz 2db8138e8e comp: Hack in a flip of the right eye 2019-10-10 13:28:01 +01:00
pblack 898c1b4a9f comp: Add mesh distortion shader 2019-10-10 13:28:01 +01:00
Jakob Bornecrantz 0108207b3d comp: Use VK_NULL_HANDLE 2019-10-07 23:27:09 +01:00
Jakob Bornecrantz 1d9009a461 comp: Set array_size 2019-10-07 23:26:43 +01:00
Benjamin Saunders 3d5872f346 comp: Fix missing usages on Vulkan client swapchains 2019-10-07 22:08:56 +01:00
Jakob Bornecrantz 5cd4d272a2 comp: Code style, pointer star location 2019-09-29 11:45:23 +01:00
Drew DeVault b4f0c79abd comp_compositor.c: prefer Wayland over XCB 2019-09-26 12:15:27 -04:00
Drew DeVault 9bcfa56f2f compositor: overhaul Wayland backend
This simplifies the Wayland backend, fixes the build configuration for
it, ports it to xdg-shell stable, and reworks some false assumptions
from the original port.
2019-09-26 12:15:27 -04:00
Drew DeVault c6586cfd1e comp_compositor: use nanosleep instead of usleep
Improves portability
2019-09-26 15:05:22 +00:00
Jakob Bornecrantz 5de401ea58 comp: Tidy wait frame 2019-08-31 14:17:41 +01:00
Jakob Bornecrantz cfb1ca3052 comp: Ensure nominal_frame_interval_ns is a sane value 2019-08-31 14:17:41 +01:00
Christoph Haag d9736ba3b7 comp: wait for next frame in xrWaitFrame
fixes 6e396ed

It was unnecessary to move the wait to xrEndFrame.
It does not matter if the compositor renders the frame immediately because the
frame physically can not be displayed before the next HMD refresh.

On the other hand, leaving too short of a time for the compositor to render
may delay the frame past its predicted time.
2019-08-20 10:10:10 +00:00
Ryan Pavlik e21b495f90 comp: Comment a resource and memory leak 2019-08-16 17:25:19 -05:00
Ryan Pavlik 2aca9821fa comp: Clang-tidy 2019-08-16 17:20:01 -05:00
Ryan Pavlik dbf0bdd014 comp: Factor out some shared functionality.
Simplifies error handling as well.
2019-08-16 17:12:35 -05:00