Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick fixes #22

Merged
merged 10 commits into from
Nov 30, 2022
Prev Previous commit
Next Next commit
Cleanups
geefr committed Nov 30, 2022
commit 07d84cc8e152c2b6fe0531e1d01b19266ac684f9
14 changes: 2 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,12 +2,7 @@ cmake_minimum_required(VERSION 3.14)

project(VSGVR)

option(BUILD_SHARED_LIBS "Build shared libraries" OFF)

include(GNUInstallDirs)

include(FetchContent)

option( BUILD_SHARED_LIBS "Build shared libraries" OFF )
option( VSGVR_BUILD_EXAMPLES "Whether to build VSGVR examples or not" ON )

if( NOT CMAKE_BUILD_TYPE AND NOT MSVC )
@@ -22,7 +17,7 @@ endif()

# Compiler/Tool requirements
set( CMAKE_CXX_STANDARD 17 )
set(OpenGL_GL_PREFERENCE GLVND)
set( OpenGL_GL_PREFERENCE GLVND )

# Package/System requirements
if(ANDROID)
@@ -54,12 +49,7 @@ endif()

add_subdirectory( vsgvr )


if( VSGVR_BUILD_EXAMPLES )
add_subdirectory( examples )
endif()

# Copy models into the build dir
configure_file(models/world/world.vsgt ${CMAKE_CURRENT_BINARY_DIR}/world.vsgt COPYONLY)
configure_file(models/controller/controller.vsgt ${CMAKE_CURRENT_BINARY_DIR}/controller.vsgt COPYONLY)
configure_file(models/controller/controller2.vsgt ${CMAKE_CURRENT_BINARY_DIR}/controller2.vsgt COPYONLY)
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ if(ANDROID)
else()
add_subdirectory( generic )
endif()

1 change: 1 addition & 0 deletions examples/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

add_executable( vsgvr_example_generic main.cpp )
target_link_libraries( vsgvr_example_generic vsg::vsg vsgvr )

24 changes: 11 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
@@ -34,16 +34,16 @@ Feature | Status
-----------------------------|--------
Linux Build | Done
Windows Build | Done
Android Build | Bugs in controller position/tracking, otherwise done
Android Build (Oculus) | Done
Android Build (Gneeric) | Done, untested
Code quality / API | Messy, but in roughly the right structure for now
OpenXR Rendering | Working, could do with a cleanup and better vsg integration at some point
OpenXR Input | Not Implemented Yet
OpenXR Input | Not Implemented (But OpenXR API directly accessible)
Controller tracking | Working
Controller models in scene | Working
HMD tracking | Working
Desktop view | Working


## Setup

If you don't have a VR headset there's a couple of options.
@@ -71,18 +71,18 @@ monado-service

### Android Phone / Tablet

TODO: Once the Android build is functional, it should be possible to use most phones/tablets as an XR display.
These don't directly match how a VR setup works, but should provide basic hardware for rotation/positional tracking (ARCore).

TODO: Currently vsgvr can be built for Android against the generic OpenXR loader - In theory this means it will work against Monado running on a phone/tablet.
This is however unverified, if you know how to install Monado on a phone, or otherwise have a functional OpenXR runtime on your phone please get in touch.

## Compilation

Required:
* cmake > 3.14
* vulkan sdk
* VulkanSceneGraph
* The OpenXR loader - Included as a git submodule in deps/openxr
* (For model creation) vsgXchange
* The OpenXR loader - From a variety of sources
* OPENXR\_GENERIC - The generic OpenXR loader, included as a git submodule at deps/openxr
* OPENXR\_OCULUS\_MOBILE - The Oculus mobile SDK, available from https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/

```sh
# Ensure submodules are available
@@ -99,23 +99,21 @@ make
## Models

Models created in Blender
* Controller 'top' is at 0,0 (or just below)
* Controller 'up' is [0,0,-1] in blender space
* Should face 'forward' as normal

Export from blender to gltf:
* Include custom properties
* Include punctual lights
* +Y up

Convert to vsg via `vsgconv model.glb model.vsgt`
* Ensure vsgXchange is built with assimp support (For assimp itself I used vcpkg)
* Ensure a recent build is used for correct lighting (fd35cc2 or newer)#
* Ensure vsgXchange is built with assimp support

## Development Tips


Validation layers from the OpenXR SDK
```
set XR_API_LAYER_PATH="C:/dev/OpenXR-SDK-Source/build/src/api_layers/"
set XR_ENABLE_API_LAYERS=XR_APILAYER_LUNARG_core_validation
```

41 changes: 21 additions & 20 deletions vsgvr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@

file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/vsgvr/*.h )

set( SOURCES
include/vsgvr/actions/OpenXRAction.h
include/vsgvr/actions/OpenXRActionPoseBinding.h
include/vsgvr/actions/OpenXRActionSet.h
include/vsgvr/app/OpenXRViewer.h
include/vsgvr/xr/OpenXRCommon.h
include/vsgvr/xr/OpenXRInstance.h
src/vsgvr/xr/OpenXRInstance.cpp
include/vsgvr/xr/OpenXREventHandler.h
src/vsgvr/xr/OpenXREventHandler.cpp
include/vsgvr/xr/OpenXRTraits.h
src/vsgvr/xr/OpenXRTraits.cpp
include/vsgvr/app/OpenXRViewer.h
src/vsgvr/app/OpenXRViewer.cpp
include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h
src/vsgvr/xr/OpenXRGraphicsBindingVulkan.cpp
include/vsgvr/xr/OpenXRInstance.h
include/vsgvr/xr/OpenXRProjectionMatrix.h
include/vsgvr/xr/OpenXRSession.h
src/vsgvr/xr/OpenXRSession.cpp
include/vsgvr/xr/OpenXRSwapchain.h
src/vsgvr/xr/OpenXRSwapchain.cpp
include/vsgvr/xr/OpenXRTraits.h
include/vsgvr/xr/OpenXRViewMatrix.h
include/vsgvr/xr/OpenXRProjectionMatrix.h

include/vsgvr/actions/OpenXRAction.h
src/vsgvr/actions/OpenXRAction.cpp
include/vsgvr/actions/OpenXRActionSet.h
src/vsgvr/actions/OpenXRActionSet.cpp
include/vsgvr/actions/OpenXRActionPoseBinding.h
src/vsgvr/actions/OpenXRActionPoseBinding.cpp
src/vsgvr/actions/OpenXRActionSet.cpp
src/vsgvr/app/OpenXRViewer.cpp
src/vsgvr/xr/OpenXREventHandler.cpp
src/vsgvr/xr/OpenXRGraphicsBindingVulkan.cpp
src/vsgvr/xr/OpenXRInstance.cpp
src/vsgvr/xr/OpenXRMacros.cpp
src/vsgvr/xr/OpenXRSession.cpp
src/vsgvr/xr/OpenXRSwapchain.cpp
src/vsgvr/xr/OpenXRTraits.cpp
)

if( ANDROID )
@@ -43,9 +42,11 @@ target_include_directories(
)
target_link_libraries( vsgvr PUBLIC vsg::vsg )
target_link_libraries( vsgvr PUBLIC openxr_loader )

if(WIN32 AND BUILD_SHARED_LIBS)
target_compile_options(vsgvr PRIVATE "-DVSGVR_DECLSPEC=__declspec(dllexport)")
target_compile_options(vsgvr INTERFACE "-DVSGVR_DECLSPEC=__declspec(dllimport)")
target_compile_definitions(vsgvr PRIVATE VSGVR_DECLSPEC="__declspec(dllexport)")
target_compile_definitions(vsgvr INTERFACE VSGVR_DECLSPEC="__declspec(dllimport)")
else()
target_compile_options(vsgvr PUBLIC -DVSGVR_DECLSPEC=)
target_compile_definitions( vsgvr PUBLIC VSGVR_DECLSPEC )
endif()

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/actions/OpenXRAction.h
Original file line number Diff line number Diff line change
@@ -49,3 +49,4 @@ namespace vsgvr {
XrAction _action;
};
}

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/actions/OpenXRActionPoseBinding.h
Original file line number Diff line number Diff line change
@@ -55,3 +55,4 @@ namespace vsgvr {
vsg::mat4 _transform;
};
}

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/actions/OpenXRActionSet.h
Original file line number Diff line number Diff line change
@@ -61,3 +61,4 @@ namespace vsgvr {
XrActionSet _actionSet;
};
}

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/app/OpenXRViewer.h
Original file line number Diff line number Diff line change
@@ -175,3 +175,4 @@ namespace vsgvr {
std::vector<XrCompositionLayerProjectionView> _layerProjectionViews;
};
}

3 changes: 2 additions & 1 deletion vsgvr/include/vsgvr/xr/OpenXRAndroidTraits.h
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <jni.h>

namespace vsgvr {
class VSG_DECLSPEC OpenXrAndroidTraits : public vsg::Inherit<vsgvr::OpenXrTraits, OpenXrAndroidTraits> {
class VSGVR_DECLSPEC OpenXrAndroidTraits : public vsg::Inherit<vsgvr::OpenXrTraits, OpenXrAndroidTraits> {
public:
OpenXrAndroidTraits();

@@ -36,3 +36,4 @@ namespace vsgvr {
virtual ~OpenXrAndroidTraits();
};
}

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/xr/OpenXRCommon.h
Original file line number Diff line number Diff line change
@@ -33,3 +33,4 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# include <jni.h>
#endif
#include <openxr/openxr_platform.h>

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/xr/OpenXREventHandler.h
Original file line number Diff line number Diff line change
@@ -37,3 +37,4 @@ namespace vsgvr {
void pollEvents(OpenXRInstance* instance, OpenXRSession* session);
};
}

5 changes: 3 additions & 2 deletions vsgvr/include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>

namespace vsgvr {
struct VulkanRequirements
struct VSGVR_DECLSPEC VulkanRequirements
{
uint32_t minVersion;
uint32_t maxVersion;
@@ -44,7 +44,7 @@ namespace vsgvr {
std::set<std::string> deviceExtensions;
};

struct VulkanGraphicsRequirements
struct VSGVR_DECLSPEC VulkanGraphicsRequirements
{
VkPhysicalDevice* physicalDevice;
};
@@ -73,3 +73,4 @@ namespace vsgvr {
XrGraphicsBindingVulkanKHR _binding;
};
}

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/xr/OpenXRInstance.h
Original file line number Diff line number Diff line change
@@ -64,3 +64,4 @@ namespace vsgvr {
XrSystemProperties _systemProperties;
};
}

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/xr/OpenXRProjectionMatrix.h
Original file line number Diff line number Diff line change
@@ -68,3 +68,4 @@ namespace vsgvr
vsg::dmat4 mat;
};
}

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/xr/OpenXRSession.h
Original file line number Diff line number Diff line change
@@ -92,3 +92,4 @@ namespace vsgvr {
std::vector<PerViewData> _viewData;
};
}

3 changes: 2 additions & 1 deletion vsgvr/include/vsgvr/xr/OpenXRSwapchain.h
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace vsgvr
{

class SwapchainImage : public vsg::Inherit<vsg::Image, SwapchainImage>
class VSGVR_DECLSPEC SwapchainImage : public vsg::Inherit<vsg::Image, SwapchainImage>
{
public:
SwapchainImage(VkImage image, vsg::Device *device);
@@ -70,3 +70,4 @@ namespace vsgvr
vsg::ImageViews _imageViews;
};
}

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/xr/OpenXRTraits.h
Original file line number Diff line number Diff line change
@@ -60,3 +60,4 @@ namespace vsgvr {
virtual ~OpenXrTraits();
};
}

1 change: 1 addition & 0 deletions vsgvr/include/vsgvr/xr/OpenXRViewMatrix.h
Original file line number Diff line number Diff line change
@@ -81,3 +81,4 @@ namespace vsgvr {
vsg::dmat4 matrix;
};
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/actions/OpenXRAction.cpp
Original file line number Diff line number Diff line change
@@ -62,3 +62,4 @@ namespace vsgvr
xr_check(xrDestroyAction(_action));
}
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp
Original file line number Diff line number Diff line change
@@ -104,3 +104,4 @@ namespace vsgvr
}
}
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/actions/OpenXRActionSet.cpp
Original file line number Diff line number Diff line change
@@ -95,3 +95,4 @@ namespace vsgvr
}
}
}

10 changes: 1 addition & 9 deletions vsgvr/src/vsgvr/app/OpenXRViewer.cpp
Original file line number Diff line number Diff line change
@@ -45,7 +45,6 @@ namespace vsgvr
: _instance(xrInstance)
, _xrTraits(xrTraits)
, _graphicsBinding(graphicsBinding)
// , updateOperations(UpdateOperations::create())
{
getViewConfiguration();
createSession();
@@ -58,8 +57,6 @@ namespace vsgvr

void OpenXRViewer::shutdownAll()
{
// TODO: May need to wait - Can't destroy swapchain in session until idle
// vkDeviceWaitIdle(_graphicsBinding->getVkDevice()->getDevice());
if (_session) destroySession();
}

@@ -665,10 +662,5 @@ namespace vsgvr
destroyActionSpaces();
_session = 0;
}
/*
void updateXRViewer(OpenXRViewer& viewer, const vsg::CompileResult& compileResult)
{
updateTasks(viewer.recordAndSubmitTasks, viewer.compileManager, compileResult);
}
*/
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/xr/OpenXRAndroidTraits.cpp
Original file line number Diff line number Diff line change
@@ -27,3 +27,4 @@ namespace vsgvr

OpenXrAndroidTraits::~OpenXrAndroidTraits() {}
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/xr/OpenXREventHandler.cpp
Original file line number Diff line number Diff line change
@@ -81,3 +81,4 @@ namespace vsgvr {
}
}
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/xr/OpenXRGraphicsBindingVulkan.cpp
Original file line number Diff line number Diff line change
@@ -125,3 +125,4 @@ namespace vsgvr {
return vkPhysicalDevice;
}
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/xr/OpenXRInstance.cpp
Original file line number Diff line number Diff line change
@@ -194,3 +194,4 @@ namespace vsgvr
}
}
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/xr/OpenXRMacros.cpp
Original file line number Diff line number Diff line change
@@ -55,3 +55,4 @@ namespace {
else return nullptr;
}
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/xr/OpenXRSession.cpp
Original file line number Diff line number Diff line change
@@ -294,3 +294,4 @@ namespace vsgvr {
_sessionState = event.state;
}
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/xr/OpenXRSwapchain.cpp
Original file line number Diff line number Diff line change
@@ -160,3 +160,4 @@ namespace vsgvr {
xr_check(xrDestroySwapchain(_swapchain));
}
}

1 change: 1 addition & 0 deletions vsgvr/src/vsgvr/xr/OpenXRTraits.cpp
Original file line number Diff line number Diff line change
@@ -36,3 +36,4 @@ namespace vsgvr
engineVersion = XR_MAKE_VERSION(maj, min, patch);
}
}