-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Mostly remove the use of the OPENXR ifdef #16344
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5d3ec6c
Fix type of predictedDisplayTime
hrydgard b4507cd
Make a lot more code VR build for all platforms
hrydgard c44afcf
Typo fix
hrydgard 0ef39d1
Add a dynamic loader for OpenXR so the VR code can link. Make it all …
hrydgard 1622901
UWP build fix. Had to reshuffle some stuff and compile some Vulkan fi…
hrydgard 44106ff
Linking fix for normal Android devices
hrydgard 09c0ebd
Windows ARM/ARM64 buildfix
hrydgard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
#include "Common/VR/OpenXRLoader.h" | ||
#ifdef _WIN32 | ||
#include "Common/CommonWindows.h" | ||
#endif | ||
|
||
#ifdef XR_NO_PROTOTYPES | ||
|
||
PFN_xrGetInstanceProcAddr xrGetInstanceProcAddr; | ||
PFN_xrEnumerateApiLayerProperties xrEnumerateApiLayerProperties; | ||
PFN_xrEnumerateInstanceExtensionProperties xrEnumerateInstanceExtensionProperties; | ||
PFN_xrCreateInstance xrCreateInstance; | ||
PFN_xrDestroyInstance xrDestroyInstance; | ||
PFN_xrGetInstanceProperties xrGetInstanceProperties; | ||
PFN_xrPollEvent xrPollEvent; | ||
PFN_xrResultToString xrResultToString; | ||
PFN_xrStructureTypeToString xrStructureTypeToString; | ||
PFN_xrGetSystem xrGetSystem; | ||
PFN_xrGetSystemProperties xrGetSystemProperties; | ||
PFN_xrEnumerateEnvironmentBlendModes xrEnumerateEnvironmentBlendModes; | ||
PFN_xrCreateSession xrCreateSession; | ||
PFN_xrDestroySession xrDestroySession; | ||
PFN_xrEnumerateReferenceSpaces xrEnumerateReferenceSpaces; | ||
PFN_xrCreateReferenceSpace xrCreateReferenceSpace; | ||
PFN_xrGetReferenceSpaceBoundsRect xrGetReferenceSpaceBoundsRect; | ||
PFN_xrCreateActionSpace xrCreateActionSpace; | ||
PFN_xrLocateSpace xrLocateSpace; | ||
PFN_xrDestroySpace xrDestroySpace; | ||
PFN_xrEnumerateViewConfigurations xrEnumerateViewConfigurations; | ||
PFN_xrGetViewConfigurationProperties xrGetViewConfigurationProperties; | ||
PFN_xrEnumerateViewConfigurationViews xrEnumerateViewConfigurationViews; | ||
PFN_xrEnumerateSwapchainFormats xrEnumerateSwapchainFormats; | ||
PFN_xrCreateSwapchain xrCreateSwapchain; | ||
PFN_xrDestroySwapchain xrDestroySwapchain; | ||
PFN_xrEnumerateSwapchainImages xrEnumerateSwapchainImages; | ||
PFN_xrAcquireSwapchainImage xrAcquireSwapchainImage; | ||
PFN_xrWaitSwapchainImage xrWaitSwapchainImage; | ||
PFN_xrReleaseSwapchainImage xrReleaseSwapchainImage; | ||
PFN_xrBeginSession xrBeginSession; | ||
PFN_xrEndSession xrEndSession; | ||
PFN_xrRequestExitSession xrRequestExitSession; | ||
PFN_xrWaitFrame xrWaitFrame; | ||
PFN_xrBeginFrame xrBeginFrame; | ||
PFN_xrEndFrame xrEndFrame; | ||
PFN_xrLocateViews xrLocateViews; | ||
PFN_xrStringToPath xrStringToPath; | ||
PFN_xrPathToString xrPathToString; | ||
PFN_xrCreateActionSet xrCreateActionSet; | ||
PFN_xrDestroyActionSet xrDestroyActionSet; | ||
PFN_xrCreateAction xrCreateAction; | ||
PFN_xrDestroyAction xrDestroyAction; | ||
PFN_xrSuggestInteractionProfileBindings xrSuggestInteractionProfileBindings; | ||
PFN_xrAttachSessionActionSets xrAttachSessionActionSets; | ||
PFN_xrGetCurrentInteractionProfile xrGetCurrentInteractionProfile; | ||
PFN_xrGetActionStateBoolean xrGetActionStateBoolean; | ||
PFN_xrGetActionStateFloat xrGetActionStateFloat; | ||
PFN_xrGetActionStateVector2f xrGetActionStateVector2f; | ||
PFN_xrGetActionStatePose xrGetActionStatePose; | ||
PFN_xrSyncActions xrSyncActions; | ||
PFN_xrEnumerateBoundSourcesForAction xrEnumerateBoundSourcesForAction; | ||
PFN_xrGetInputSourceLocalizedName xrGetInputSourceLocalizedName; | ||
PFN_xrApplyHapticFeedback xrApplyHapticFeedback; | ||
PFN_xrStopHapticFeedback xrStopHapticFeedback; | ||
|
||
#ifdef _WIN32 | ||
#define dlsym(x, y) GetProcAddress(x, y) | ||
static HMODULE g_xrLibrary; | ||
#else | ||
#define dlsym(x, y) nullptr | ||
void *xrLibrary; | ||
#endif | ||
|
||
#define LOAD_INSTANCE_FUNC(name) (PFN_ ## name)xrGetInstanceProcAddr(instance, #name, (PFN_xrVoidFunction *)(&name)) | ||
|
||
|
||
bool XRLoad() { | ||
if (g_xrLibrary) { | ||
// Already loaded. That's OK. | ||
return true; | ||
} | ||
|
||
#ifdef _WIN32 | ||
g_xrLibrary = LoadLibrary(L"openxr_loader.dll"); | ||
if (!g_xrLibrary) { | ||
return false; | ||
} | ||
#else | ||
void *library = nullptr; | ||
#endif | ||
|
||
// Load the three basic functions. | ||
xrGetInstanceProcAddr = (PFN_xrGetInstanceProcAddr)dlsym(g_xrLibrary, "xrGetInstanceProcAddr"); | ||
xrEnumerateApiLayerProperties = (PFN_xrEnumerateApiLayerProperties)dlsym(g_xrLibrary, "xrEnumerateApiLayerProperties"); | ||
xrEnumerateInstanceExtensionProperties = (PFN_xrEnumerateInstanceExtensionProperties)dlsym(g_xrLibrary, "xrEnumerateInstanceExtensionProperties"); | ||
|
||
// Load the rest. | ||
return true; | ||
} | ||
|
||
void XRLoadInstanceFunctions(XrInstance instance) { | ||
LOAD_INSTANCE_FUNC(xrCreateInstance); | ||
LOAD_INSTANCE_FUNC(xrGetInstanceProcAddr); | ||
LOAD_INSTANCE_FUNC(xrEnumerateApiLayerProperties); | ||
LOAD_INSTANCE_FUNC(xrEnumerateInstanceExtensionProperties); | ||
LOAD_INSTANCE_FUNC(xrCreateInstance); | ||
LOAD_INSTANCE_FUNC(xrDestroyInstance); | ||
LOAD_INSTANCE_FUNC(xrGetInstanceProperties); | ||
LOAD_INSTANCE_FUNC(xrPollEvent); | ||
LOAD_INSTANCE_FUNC(xrResultToString); | ||
LOAD_INSTANCE_FUNC(xrStructureTypeToString); | ||
LOAD_INSTANCE_FUNC(xrGetSystem); | ||
LOAD_INSTANCE_FUNC(xrGetSystemProperties); | ||
LOAD_INSTANCE_FUNC(xrEnumerateEnvironmentBlendModes); | ||
LOAD_INSTANCE_FUNC(xrCreateSession); | ||
LOAD_INSTANCE_FUNC(xrDestroySession); | ||
LOAD_INSTANCE_FUNC(xrEnumerateReferenceSpaces); | ||
LOAD_INSTANCE_FUNC(xrCreateReferenceSpace); | ||
LOAD_INSTANCE_FUNC(xrGetReferenceSpaceBoundsRect); | ||
LOAD_INSTANCE_FUNC(xrCreateActionSpace); | ||
LOAD_INSTANCE_FUNC(xrLocateSpace); | ||
LOAD_INSTANCE_FUNC(xrDestroySpace); | ||
LOAD_INSTANCE_FUNC(xrEnumerateViewConfigurations); | ||
LOAD_INSTANCE_FUNC(xrGetViewConfigurationProperties); | ||
LOAD_INSTANCE_FUNC(xrEnumerateViewConfigurationViews); | ||
LOAD_INSTANCE_FUNC(xrEnumerateSwapchainFormats); | ||
LOAD_INSTANCE_FUNC(xrCreateSwapchain); | ||
LOAD_INSTANCE_FUNC(xrDestroySwapchain); | ||
LOAD_INSTANCE_FUNC(xrEnumerateSwapchainImages); | ||
LOAD_INSTANCE_FUNC(xrAcquireSwapchainImage); | ||
LOAD_INSTANCE_FUNC(xrWaitSwapchainImage); | ||
LOAD_INSTANCE_FUNC(xrReleaseSwapchainImage); | ||
LOAD_INSTANCE_FUNC(xrBeginSession); | ||
LOAD_INSTANCE_FUNC(xrEndSession); | ||
LOAD_INSTANCE_FUNC(xrRequestExitSession); | ||
LOAD_INSTANCE_FUNC(xrWaitFrame); | ||
LOAD_INSTANCE_FUNC(xrBeginFrame); | ||
LOAD_INSTANCE_FUNC(xrEndFrame); | ||
LOAD_INSTANCE_FUNC(xrLocateViews); | ||
LOAD_INSTANCE_FUNC(xrStringToPath); | ||
LOAD_INSTANCE_FUNC(xrPathToString); | ||
LOAD_INSTANCE_FUNC(xrCreateActionSet); | ||
LOAD_INSTANCE_FUNC(xrDestroyActionSet); | ||
LOAD_INSTANCE_FUNC(xrCreateAction); | ||
LOAD_INSTANCE_FUNC(xrDestroyAction); | ||
LOAD_INSTANCE_FUNC(xrSuggestInteractionProfileBindings); | ||
LOAD_INSTANCE_FUNC(xrAttachSessionActionSets); | ||
LOAD_INSTANCE_FUNC(xrGetCurrentInteractionProfile); | ||
LOAD_INSTANCE_FUNC(xrGetActionStateBoolean); | ||
LOAD_INSTANCE_FUNC(xrGetActionStateFloat); | ||
LOAD_INSTANCE_FUNC(xrGetActionStateVector2f); | ||
LOAD_INSTANCE_FUNC(xrGetActionStatePose); | ||
LOAD_INSTANCE_FUNC(xrSyncActions); | ||
LOAD_INSTANCE_FUNC(xrEnumerateBoundSourcesForAction); | ||
LOAD_INSTANCE_FUNC(xrGetInputSourceLocalizedName); | ||
LOAD_INSTANCE_FUNC(xrApplyHapticFeedback); | ||
LOAD_INSTANCE_FUNC(xrStopHapticFeedback); | ||
|
||
// TODO: Load any extensions we need, too. | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#pragma once | ||
|
||
//Vulkan | ||
#ifdef VK_USE_NATIVE_LIB | ||
#include <vulkan/vulkan.h> | ||
#else | ||
#include "Common/GPU/Vulkan/VulkanLoader.h" | ||
using namespace PPSSPP_VK; | ||
#endif | ||
|
||
#ifdef ANDROID | ||
//OpenXR | ||
#define XR_USE_PLATFORM_ANDROID 1 | ||
#define XR_USE_GRAPHICS_API_OPENGL_ES 1 | ||
#define XR_USE_GRAPHICS_API_VULKAN 1 | ||
#include <EGL/egl.h> | ||
#include <EGL/eglext.h> | ||
#include <jni.h> | ||
#elif defined(_WIN32) | ||
#include "Common/CommonWindows.h" | ||
#include "Common/GPU/OpenGL/GLCommon.h" | ||
#include "Common/VR/OpenXRLoader.h" | ||
#include <unknwn.h> | ||
#define XR_USE_PLATFORM_WIN32 1 | ||
#define XR_USE_GRAPHICS_API_OPENGL 1 | ||
#define XR_USE_GRAPHICS_API_VULKAN 1 | ||
#define XR_NO_PROTOTYPES 1 | ||
#else | ||
#define XR_USE_GRAPHICS_API_VULKAN 1 | ||
#define XR_NO_PROTOTYPES 1 | ||
#endif | ||
|
||
#include <openxr.h> | ||
#include <openxr_platform.h> | ||
|
||
#ifdef XR_NO_PROTOTYPES | ||
|
||
extern PFN_xrGetInstanceProcAddr xrGetInstanceProcAddr; | ||
extern PFN_xrEnumerateApiLayerProperties xrEnumerateApiLayerProperties; | ||
extern PFN_xrEnumerateInstanceExtensionProperties xrEnumerateInstanceExtensionProperties; | ||
extern PFN_xrCreateInstance xrCreateInstance; | ||
extern PFN_xrDestroyInstance xrDestroyInstance; | ||
extern PFN_xrGetInstanceProperties xrGetInstanceProperties; | ||
extern PFN_xrPollEvent xrPollEvent; | ||
extern PFN_xrResultToString xrResultToString; | ||
extern PFN_xrStructureTypeToString xrStructureTypeToString; | ||
extern PFN_xrGetSystem xrGetSystem; | ||
extern PFN_xrGetSystemProperties xrGetSystemProperties; | ||
extern PFN_xrEnumerateEnvironmentBlendModes xrEnumerateEnvironmentBlendModes; | ||
extern PFN_xrCreateSession xrCreateSession; | ||
extern PFN_xrDestroySession xrDestroySession; | ||
extern PFN_xrEnumerateReferenceSpaces xrEnumerateReferenceSpaces; | ||
extern PFN_xrCreateReferenceSpace xrCreateReferenceSpace; | ||
extern PFN_xrGetReferenceSpaceBoundsRect xrGetReferenceSpaceBoundsRect; | ||
extern PFN_xrCreateActionSpace xrCreateActionSpace; | ||
extern PFN_xrLocateSpace xrLocateSpace; | ||
extern PFN_xrDestroySpace xrDestroySpace; | ||
extern PFN_xrEnumerateViewConfigurations xrEnumerateViewConfigurations; | ||
extern PFN_xrGetViewConfigurationProperties xrGetViewConfigurationProperties; | ||
extern PFN_xrEnumerateViewConfigurationViews xrEnumerateViewConfigurationViews; | ||
extern PFN_xrEnumerateSwapchainFormats xrEnumerateSwapchainFormats; | ||
extern PFN_xrCreateSwapchain xrCreateSwapchain; | ||
extern PFN_xrDestroySwapchain xrDestroySwapchain; | ||
extern PFN_xrEnumerateSwapchainImages xrEnumerateSwapchainImages; | ||
extern PFN_xrAcquireSwapchainImage xrAcquireSwapchainImage; | ||
extern PFN_xrWaitSwapchainImage xrWaitSwapchainImage; | ||
extern PFN_xrReleaseSwapchainImage xrReleaseSwapchainImage; | ||
extern PFN_xrBeginSession xrBeginSession; | ||
extern PFN_xrEndSession xrEndSession; | ||
extern PFN_xrRequestExitSession xrRequestExitSession; | ||
extern PFN_xrWaitFrame xrWaitFrame; | ||
extern PFN_xrBeginFrame xrBeginFrame; | ||
extern PFN_xrEndFrame xrEndFrame; | ||
extern PFN_xrLocateViews xrLocateViews; | ||
extern PFN_xrStringToPath xrStringToPath; | ||
extern PFN_xrPathToString xrPathToString; | ||
extern PFN_xrCreateActionSet xrCreateActionSet; | ||
extern PFN_xrDestroyActionSet xrDestroyActionSet; | ||
extern PFN_xrCreateAction xrCreateAction; | ||
extern PFN_xrDestroyAction xrDestroyAction; | ||
extern PFN_xrSuggestInteractionProfileBindings xrSuggestInteractionProfileBindings; | ||
extern PFN_xrAttachSessionActionSets xrAttachSessionActionSets; | ||
extern PFN_xrGetCurrentInteractionProfile xrGetCurrentInteractionProfile; | ||
extern PFN_xrGetActionStateBoolean xrGetActionStateBoolean; | ||
extern PFN_xrGetActionStateFloat xrGetActionStateFloat; | ||
extern PFN_xrGetActionStateVector2f xrGetActionStateVector2f; | ||
extern PFN_xrGetActionStatePose xrGetActionStatePose; | ||
extern PFN_xrSyncActions xrSyncActions; | ||
extern PFN_xrEnumerateBoundSourcesForAction xrEnumerateBoundSourcesForAction; | ||
extern PFN_xrGetInputSourceLocalizedName xrGetInputSourceLocalizedName; | ||
extern PFN_xrApplyHapticFeedback xrApplyHapticFeedback; | ||
extern PFN_xrStopHapticFeedback xrStopHapticFeedback; | ||
|
||
// Dynamic loader for OpenXR on desktop platforms. | ||
// On Quest/Pico, we use statically linked loaders provided by the platform owners. | ||
// On Windows (and Linux etc), we're not so lucky - we could link to static libraries, but we really | ||
// don't want to as we still want to function when one is not present. | ||
// | ||
// Similar to our dynamic Vulkan loader. | ||
|
||
bool XRLoad(); | ||
void XRLoadInstanceFunctions(XrInstance instance); | ||
|
||
#else | ||
|
||
inline bool XRLoad() { return true; } | ||
inline void XRLoadInstanceFunctions(XrInstance instance) {} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Prefer spaces for alignment, h too...?
-[Unknown]