-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
GPU: OpenXR integration #11601
Open
Beyley
wants to merge
21
commits into
libsdl-org:main
Choose a base branch
from
Beyley:openxr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
GPU: OpenXR integration #11601
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
81908c9
gpu + openxr: Implement initial OpenXR support
Beyley 0f1b4b1
openxr: Fix docs syntax
Beyley 06165bf
gpu: Clean up XR func return values
Beyley a8666e1
gpu + openxr: Add SDL_XRGPUSupportsProperties
Beyley a7d323a
openxr: Put structure base header for typedefs
Beyley eb27beb
gpu: Attempt to fix d3d12 and metal GPU backends
Beyley 736ed52
gpu: Fix d3d12 compilation, and probably metal compilation
Beyley 766e400
gpu: Wait for idle in VULKAN_DestroyXRSwapchain
Beyley 626808e
gpu + openxr: Turn XR device creation into property
Beyley be446ad
gpu: fix d3d12+metal PrepareDriver func defs
Beyley 6756be5
openxr: Add OpenXR sdk headers to repo
Beyley 7a7f103
cmake: Make DXVK and OpenXR depend on SDL_GPU
Beyley 42fdc34
cmake: Escape SDL_GPU_OPENXR_DYNAMIC in cmake script
Beyley c32ac6e
gpu: Fix uninitialized variable usage in OpenXR physical device init
Beyley 8121640
gpu: Fix uninitialized memory usage when checking OpenXR vulkan devic…
Beyley c2448ad
gpu: Add property to specify form factor
Beyley ef03a30
gpu: Fix warning on GCC
Beyley 6dbcd49
cmake: Make HAVE_GPU_OPENXR match rest of build config
Beyley 98b2343
gpu/vulkan: Use props OpenXR version in PrepareDriver
Beyley c08ef2d
gpu/d3d12: Implement OpenXR session creation
Beyley ade4830
gpu+d3d12: Initial buggy OpenXR swapchain support
Beyley 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
Simple DirectMedia Layer | ||
Copyright (C) 1997-2024 Sam Lantinga <[email protected]> | ||
|
||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
arising from the use of this software. | ||
|
||
Permission is granted to anyone to use this software for any purpose, | ||
including commercial applications, and to alter it and redistribute it | ||
freely, subject to the following restrictions: | ||
|
||
1. The origin of this software must not be misrepresented; you must not | ||
claim that you wrote the original software. If you use this software | ||
in a product, an acknowledgment in the product documentation would be | ||
appreciated but is not required. | ||
2. Altered source versions must be plainly marked as such, and must not be | ||
misrepresented as being the original software. | ||
3. This notice may not be removed or altered from any source distribution. | ||
*/ | ||
|
||
/** | ||
* # CategoryOpenXR | ||
* | ||
* Functions for creating OpenXR handles for SDL_gpu contexts. | ||
* | ||
* For the most part, OpenXR operates independent of SDL, but | ||
* the graphics initialization depends on direct support from SDL_gpu. | ||
* | ||
*/ | ||
|
||
#ifndef SDL_openxr_h_ | ||
#define SDL_openxr_h_ | ||
|
||
#include <SDL3/SDL_stdinc.h> | ||
#include <SDL3/SDL_gpu.h> | ||
|
||
#include <SDL3/SDL_begin_code.h> | ||
/* Set up for C function definitions, even when using C++ */ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#if defined(OPENXR_H_) | ||
#define NO_SDL_OPENXR_TYPEDEFS 1 | ||
#endif /* OPENXR_H_ */ | ||
|
||
#if !defined(NO_SDL_OPENXR_TYPEDEFS) | ||
#define XR_NULL_HANDLE 0 | ||
|
||
#if !defined(XR_DEFINE_HANDLE) | ||
#define XR_DEFINE_HANDLE(object) typedef Uint64 object; | ||
#endif /* XR_DEFINE_HANDLE */ | ||
|
||
typedef enum XrStructureType { | ||
XR_TYPE_SESSION_CREATE_INFO = 8, | ||
XR_TYPE_SWAPCHAIN_CREATE_INFO = 9, | ||
} XrStructureType; | ||
|
||
XR_DEFINE_HANDLE(XrInstance) | ||
XR_DEFINE_HANDLE(XrSystemId) | ||
XR_DEFINE_HANDLE(XrSession) | ||
XR_DEFINE_HANDLE(XrSwapchain) | ||
|
||
typedef struct { | ||
XrStructureType type; | ||
const void* next; | ||
} XrSessionCreateInfo; | ||
typedef struct { | ||
XrStructureType type; | ||
const void* next; | ||
} XrSwapchainCreateInfo; | ||
|
||
typedef enum XrResult { | ||
XR_ERROR_FUNCTION_UNSUPPORTED = -7, | ||
XR_ERROR_HANDLE_INVALID = -12, | ||
} XrResult; | ||
#endif /* NO_SDL_OPENXR_TYPEDEFS */ | ||
|
||
extern SDL_DECLSPEC XrResult SDLCALL SDL_CreateGPUXRSession( | ||
SDL_GPUDevice *device, | ||
const XrSessionCreateInfo *createinfo, | ||
XrSession *session); | ||
|
||
/* TODO: document this. tl;dr: SDL_gpu picks the format, | ||
and validates the usageFlags are supported by SDL_gpu, | ||
but all other fields are fair game */ | ||
/* TODO: figure out then document what usageFlags are actually possible to be supported by SDL_gpu */ | ||
extern SDL_DECLSPEC XrResult SDLCALL SDL_CreateGPUXRSwapchain( | ||
SDL_GPUDevice *device, | ||
XrSession session, | ||
const XrSwapchainCreateInfo *createinfo, /**< The swapchain create info. */ | ||
SDL_GPUTextureFormat *textureFormat, /**< The texture format that SDL picked. */ | ||
XrSwapchain *swapchain, /**< The created OpenXR swapchain. */ | ||
SDL_GPUTexture ***textures /**< A pointer to where to store the swapchain texture array. */); | ||
|
||
extern SDL_DECLSPEC XrResult SDLCALL SDL_DestroyGPUXRSwapchain(SDL_GPUDevice *device, XrSwapchain swapchain, SDL_GPUTexture **swapchainImages); | ||
|
||
/* Ends C function definitions when using C++ */ | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#include <SDL3/SDL_close_code.h> | ||
|
||
#endif /* SDL_openxr_h_ */ |
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
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
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.
Looks like only Linux has a versioned library. This is probably an oversight.
Reminder for me to create a PR to the oxr repo.