2022-02-10 22:07:11 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
* Copyright 2001-2002 NaN Holding BV. All rights reserved. */
|
2018-02-26 18:10:15 +00:00
|
|
|
|
2019-02-17 21:08:12 +00:00
|
|
|
/** \file
|
|
|
|
* \ingroup GHOST
|
2018-02-26 18:10:15 +00:00
|
|
|
* Declaration of GHOST_IContext interface class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GHOST_Types.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for GHOST context.
|
|
|
|
*
|
2021-07-26 02:32:42 +00:00
|
|
|
* You can create a off-screen context (windowless) with the system's
|
|
|
|
* #GHOST_ISystem::createOffscreenContext method.
|
2018-02-26 18:10:15 +00:00
|
|
|
* \see GHOST_ISystem#createOffscreenContext
|
|
|
|
*/
|
|
|
|
class GHOST_IContext {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Destructor.
|
|
|
|
*/
|
|
|
|
virtual ~GHOST_IContext()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activates the drawing context.
|
2020-11-06 03:18:55 +00:00
|
|
|
* \return A boolean success indicator.
|
2018-02-26 18:10:15 +00:00
|
|
|
*/
|
|
|
|
virtual GHOST_TSuccess activateDrawingContext() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release the drawing context of the calling thread.
|
2020-11-06 03:18:55 +00:00
|
|
|
* \return A boolean success indicator.
|
2018-02-26 18:10:15 +00:00
|
|
|
*/
|
|
|
|
virtual GHOST_TSuccess releaseDrawingContext() = 0;
|
|
|
|
|
VR: Initial Virtual Reality support - Milestone 1, Scene Inspection
NOTE: While most of the milestone 1 goals are there, a few smaller features and
improvements are still to be done.
Big picture of this milestone: Initial, OpenXR-based virtual reality support
for users and foundation for advanced use cases.
Maniphest Task: https://developer.blender.org/T71347
The tasks contains more information about this milestone.
To be clear: This is not a feature rich VR implementation, it's focused on the
initial scene inspection use case. We intentionally focused on that, further
features like controller support are part of the next milestone.
- How to use?
Instructions on how to use this are here:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/How_to_Test
These will be updated and moved to a more official place (likely the manual) soon.
Currently Windows Mixed Reality and Oculus devices are usable. Valve/HTC
headsets don't support the OpenXR standard yet and hence, do not work with this
implementation.
---------------
This is the C-side implementation of the features added for initial VR
support as per milestone 1. A "VR Scene Inspection" Add-on will be
committed separately, to expose the VR functionality in the UI. It also
adds some further features for milestone 1, namely a landmarking system
(stored view locations in the VR space)
Main additions/features:
* Support for rendering viewports to an HMD, with good performance.
* Option to sync the VR view perspective with a fully interactive,
regular 3D View (VR-Mirror).
* Option to disable positional tracking. Keeps the current position (calculated
based on the VR eye center pose) when enabled while a VR session is running.
* Some regular viewport settings for the VR view
* RNA/Python-API to query and set VR session state information.
* WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data
* wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU
context)
* DNA/RNA for management of VR session settings
* `--debug-xr` and `--debug-xr-time` commandline options
* Utility batch & config file for using the Oculus runtime on Windows.
* Most VR data is runtime only. The exception is user settings which are saved
to files (`XrSessionSettings`).
* VR support can be disabled through the `WITH_XR_OPENXR` compiler flag.
For architecture and code documentation, see
https://wiki.blender.org/wiki/Source/Interface/XR.
---------------
A few thank you's:
* A huge shoutout to Ray Molenkamp for his help during the project - it would
have not been that successful without him!
* Sebastian Koenig and Simeon Conzendorf for testing and feedback!
* The reviewers, especially Brecht Van Lommel!
* Dalai Felinto for pushing and managing me to get this done ;)
* The OpenXR working group for providing an open standard. I think we're the
first bigger application to adopt OpenXR. Congratulations to them and
ourselves :)
This project started as a Google Summer of Code 2019 project - "Core Support of
Virtual Reality Headsets through OpenXR" (see
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).
Some further information, including ideas for further improvements can be found
in the final GSoC report:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/Final_Report
Differential Revisions: D6193, D7098
Reviewed by: Brecht Van Lommel, Jeroen Bakker
2020-03-17 19:20:55 +00:00
|
|
|
virtual unsigned int getDefaultFramebuffer() = 0;
|
|
|
|
|
2023-02-21 14:03:12 +00:00
|
|
|
/**
|
|
|
|
* Get Vulkan handles for the given context.
|
|
|
|
*
|
|
|
|
* These handles are the same for a given context.
|
|
|
|
* Should should only be called when using a Vulkan context.
|
|
|
|
* Other contexts will not return any handles and leave the
|
|
|
|
* handles where the parameters are referring to unmodified.
|
|
|
|
*
|
|
|
|
* \param r_instance: After calling this function the VkInstance
|
|
|
|
* referenced by this parameter will contain the VKInstance handle
|
|
|
|
* of the context associated with the `context` parameter.
|
|
|
|
* \param r_physical_device: After calling this function the VkPhysicalDevice
|
|
|
|
* referenced by this parameter will contain the VKPhysicalDevice handle
|
|
|
|
* of the context associated with the `context` parameter.
|
|
|
|
* \param r_device: After calling this function the VkDevice
|
|
|
|
* referenced by this parameter will contain the VKDevice handle
|
|
|
|
* of the context associated with the `context` parameter.
|
|
|
|
* \param r_graphic_queue_family: After calling this function the uint32_t
|
|
|
|
* referenced by this parameter will contain the graphic queue family id
|
|
|
|
* of the context associated with the `context` parameter.
|
|
|
|
* \param r_queue: After calling this function the VkQueue
|
|
|
|
* referenced by this parameter will contain the VKQueue handle
|
|
|
|
* of the context associated with the `context` parameter.
|
|
|
|
* \returns GHOST_kFailure when context isn't a Vulkan context.
|
|
|
|
* GHOST_kSuccess when the context is a Vulkan context and the
|
|
|
|
* handles have been set.
|
|
|
|
*/
|
|
|
|
virtual GHOST_TSuccess getVulkanHandles(void *r_instance,
|
|
|
|
void *r_physical_device,
|
|
|
|
void *r_device,
|
|
|
|
uint32_t *r_graphic_queue_family,
|
|
|
|
void *r_queue) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return Vulkan command buffer.
|
|
|
|
*
|
|
|
|
* Command buffers are different for each image in the swap chain.
|
|
|
|
* At the start of each frame the correct command buffer should be
|
|
|
|
* retrieved with this function.
|
|
|
|
*
|
|
|
|
* \param r_command_buffer: After calling this function the VkCommandBuffer
|
|
|
|
* referenced by this parameter will contain the VKCommandBuffer handle
|
|
|
|
* of the current back buffer (when swap chains are enabled) or
|
|
|
|
* it will contain a general VkCommandQueue.
|
|
|
|
* \returns GHOST_kFailure when context isn't a Vulkan context.
|
|
|
|
* GHOST_kSuccess when the context is a Vulkan context and the
|
|
|
|
* handles have been set.
|
|
|
|
*/
|
|
|
|
virtual GHOST_TSuccess getVulkanCommandBuffer(void *r_command_buffer) = 0;
|
2022-11-22 10:28:37 +00:00
|
|
|
|
|
|
|
/**
|
2023-02-27 09:54:27 +00:00
|
|
|
* Gets the Vulkan back-buffer related resource handles associated with the Vulkan context.
|
|
|
|
* Needs to be called after each swap event as the back-buffer will change.
|
2023-02-21 14:03:12 +00:00
|
|
|
*
|
|
|
|
* \param r_image: After calling this function the VkImage
|
|
|
|
* referenced by this parameter will contain the VKImage handle
|
|
|
|
* of the current back buffer.
|
|
|
|
* \param r_framebuffer: After calling this function the VkFramebuffer
|
|
|
|
* referenced by this parameter will contain the VKFramebuffer handle
|
|
|
|
* of the current back buffer.
|
|
|
|
* \param r_render_pass: After calling this function the VkRenderPass
|
|
|
|
* referenced by this parameter will contain the VKRenderPass handle
|
|
|
|
* of the current back buffer.
|
|
|
|
* \param r_extent: After calling this function the VkExtent2D
|
|
|
|
* referenced by this parameter will contain the size of the
|
|
|
|
* frame buffer and image in pixels.
|
|
|
|
* \param r_fb_id: After calling this function the uint32_t
|
|
|
|
* referenced by this parameter will contain the id of the
|
|
|
|
* framebuffer of the current back buffer.
|
|
|
|
* \returns GHOST_kFailure when context isn't a Vulkan context.
|
|
|
|
* GHOST_kSuccess when the context is a Vulkan context and the
|
|
|
|
* handles have been set.
|
2022-11-22 10:28:37 +00:00
|
|
|
*/
|
2023-02-21 14:03:12 +00:00
|
|
|
virtual GHOST_TSuccess getVulkanBackbuffer(void *r_image,
|
|
|
|
void *r_framebuffer,
|
|
|
|
void *r_render_pass,
|
|
|
|
void *r_extent,
|
|
|
|
uint32_t *r_fb_id) = 0;
|
2022-11-22 10:28:37 +00:00
|
|
|
|
VR: Initial Virtual Reality support - Milestone 1, Scene Inspection
NOTE: While most of the milestone 1 goals are there, a few smaller features and
improvements are still to be done.
Big picture of this milestone: Initial, OpenXR-based virtual reality support
for users and foundation for advanced use cases.
Maniphest Task: https://developer.blender.org/T71347
The tasks contains more information about this milestone.
To be clear: This is not a feature rich VR implementation, it's focused on the
initial scene inspection use case. We intentionally focused on that, further
features like controller support are part of the next milestone.
- How to use?
Instructions on how to use this are here:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/How_to_Test
These will be updated and moved to a more official place (likely the manual) soon.
Currently Windows Mixed Reality and Oculus devices are usable. Valve/HTC
headsets don't support the OpenXR standard yet and hence, do not work with this
implementation.
---------------
This is the C-side implementation of the features added for initial VR
support as per milestone 1. A "VR Scene Inspection" Add-on will be
committed separately, to expose the VR functionality in the UI. It also
adds some further features for milestone 1, namely a landmarking system
(stored view locations in the VR space)
Main additions/features:
* Support for rendering viewports to an HMD, with good performance.
* Option to sync the VR view perspective with a fully interactive,
regular 3D View (VR-Mirror).
* Option to disable positional tracking. Keeps the current position (calculated
based on the VR eye center pose) when enabled while a VR session is running.
* Some regular viewport settings for the VR view
* RNA/Python-API to query and set VR session state information.
* WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data
* wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU
context)
* DNA/RNA for management of VR session settings
* `--debug-xr` and `--debug-xr-time` commandline options
* Utility batch & config file for using the Oculus runtime on Windows.
* Most VR data is runtime only. The exception is user settings which are saved
to files (`XrSessionSettings`).
* VR support can be disabled through the `WITH_XR_OPENXR` compiler flag.
For architecture and code documentation, see
https://wiki.blender.org/wiki/Source/Interface/XR.
---------------
A few thank you's:
* A huge shoutout to Ray Molenkamp for his help during the project - it would
have not been that successful without him!
* Sebastian Koenig and Simeon Conzendorf for testing and feedback!
* The reviewers, especially Brecht Van Lommel!
* Dalai Felinto for pushing and managing me to get this done ;)
* The OpenXR working group for providing an open standard. I think we're the
first bigger application to adopt OpenXR. Congratulations to them and
ourselves :)
This project started as a Google Summer of Code 2019 project - "Core Support of
Virtual Reality Headsets through OpenXR" (see
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).
Some further information, including ideas for further improvements can be found
in the final GSoC report:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/Final_Report
Differential Revisions: D6193, D7098
Reviewed by: Brecht Van Lommel, Jeroen Bakker
2020-03-17 19:20:55 +00:00
|
|
|
virtual GHOST_TSuccess swapBuffers() = 0;
|
|
|
|
|
2018-02-26 18:10:15 +00:00
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IContext")
|
|
|
|
#endif
|
|
|
|
};
|