Skip to content

Commit

Permalink
OpenXR - Remove non-functional Vulkan implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lvonasek committed Dec 25, 2024
1 parent 5def50c commit ec0cba7
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 236 deletions.
8 changes: 1 addition & 7 deletions Common/GPU/Vulkan/VulkanQueueRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "Common/GPU/DataFormat.h"
#include "Common/GPU/Vulkan/VulkanQueueRunner.h"
#include "Common/GPU/Vulkan/VulkanRenderManager.h"
#include "Common/VR/PPSSPPVR.h"
#include "Common/Log.h"
#include "Common/TimeUtil.h"

Expand Down Expand Up @@ -1327,12 +1326,7 @@ VKRRenderPass *VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKR
VKRRenderPassStoreAction::STORE, VKRRenderPassStoreAction::DONT_CARE, VKRRenderPassStoreAction::DONT_CARE,
};
renderPass = GetRenderPass(key);

if (IsVREnabled()) {
framebuf = (VkFramebuffer)BindVRFramebuffer();
} else {
framebuf = backbuffer_;
}
framebuf = backbuffer_;

// Raw, rotated backbuffer size.
w = vulkan_->GetBackbufferWidth();
Expand Down
12 changes: 1 addition & 11 deletions Common/GPU/Vulkan/VulkanRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include "Common/LogReporting.h"
#include "Common/Thread/ThreadUtil.h"
#include "Common/VR/PPSSPPVR.h"

#if 0 // def _DEBUG
#define VLOG(...) NOTICE_LOG(Log::G3D, __VA_ARGS__)
Expand Down Expand Up @@ -1534,16 +1533,7 @@ void VulkanRenderManager::Run(VKRRenderThreadTask &task) {
if (task.steps.empty() && !frameData.hasAcquired)
frameData.skipSwap = true;
//queueRunner_.LogSteps(stepsOnThread, false);
if (IsVREnabled()) {
int passes = GetVRPassesCount();
for (int i = 0; i < passes; i++) {
PreVRFrameRender(i);
queueRunner_.RunSteps(task.steps, task.frame, frameData, frameDataShared_, i < passes - 1);
PostVRFrameRender();
}
} else {
queueRunner_.RunSteps(task.steps, task.frame, frameData, frameDataShared_);
}
queueRunner_.RunSteps(task.steps, task.frame, frameData, frameDataShared_);

switch (task.runType) {
case VKRRunType::SUBMIT:
Expand Down
11 changes: 0 additions & 11 deletions Common/VR/OpenXRLoader.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#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
#include <jni.h>
#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>

Expand All @@ -34,12 +25,10 @@ using namespace PPSSPP_VK;
#define XR_USE_PLATFORM_WIN32 1
#endif
#endif
#define XR_USE_GRAPHICS_API_VULKAN 1
#include "Common/VR/OpenXRLoader.h"
#include <unknwn.h>
#define XR_NO_PROTOTYPES 1
#else
#define XR_USE_GRAPHICS_API_VULKAN 1
#define XR_NO_PROTOTYPES 1
#endif

Expand Down
21 changes: 2 additions & 19 deletions Common/VR/PPSSPPVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "Common/Input/InputState.h"
#include "Common/Input/KeyCodes.h"

#include "Common/GPU/Vulkan/VulkanContext.h"

#include "Common/Math/lin/matrix4x4.h"

#include "Common/Input/InputState.h"
Expand Down Expand Up @@ -162,7 +160,6 @@ void InitVROnAndroid(void* vm, void* activity, const char* system, int version,
VR_SetPlatformFLag(VR_PLATFORM_EXTENSION_PERFORMANCE, true);
VR_SetConfigFloat(VR_CONFIG_VIEWPORT_SUPERSAMPLING, 1.3f);
}
VR_SetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN, (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN);

//Init VR
ovrJava java;
Expand All @@ -172,24 +169,10 @@ void InitVROnAndroid(void* vm, void* activity, const char* system, int version,
}
#endif

void EnterVR(bool firstStart, void* vulkanContext) {
void EnterVR(bool firstStart) {
if (firstStart) {
engine_t* engine = VR_GetEngine();
bool useVulkan = (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN;
if (useVulkan) {
auto* context = (VulkanContext*)vulkanContext;
engine->graphicsBindingVulkan = {};
engine->graphicsBindingVulkan.type = XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR;
engine->graphicsBindingVulkan.next = NULL;
engine->graphicsBindingVulkan.device = context->GetDevice();
engine->graphicsBindingVulkan.instance = context->GetInstance();
engine->graphicsBindingVulkan.physicalDevice = context->GetCurrentPhysicalDevice();
engine->graphicsBindingVulkan.queueFamilyIndex = context->GetGraphicsQueueFamilyIndex();
engine->graphicsBindingVulkan.queueIndex = 0;
VR_EnterVR(engine, &engine->graphicsBindingVulkan);
} else {
VR_EnterVR(engine, nullptr);
}
VR_EnterVR(engine);
IN_VRInit(engine);
}
VR_SetConfig(VR_CONFIG_VIEWPORT_VALID, false);
Expand Down
2 changes: 1 addition & 1 deletion Common/VR/PPSSPPVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ enum VRAppMode {
// VR app flow integration
bool IsVREnabled();
void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name);
void EnterVR(bool firstStart, void* vulkanContext);
void EnterVR(bool firstStart);
void GetVRResolutionPerEye(int* width, int* height);
void SetVRCallbacks(void(*axis)(const AxisInput *axis, size_t count), bool(*key)(const KeyInput &key), void(*touch)(const TouchInput &touch));

Expand Down
56 changes: 18 additions & 38 deletions Common/VR/VRBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ void VR_Init( void* system, const char* name, int version ) {
#endif

std::vector<const char *> extensions;
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME);
} else {
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
extensions.push_back(XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME);
extensions.push_back(XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME);
#endif
}
extensions.push_back(XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME);
#ifdef ANDROID
if (VR_GetPlatformFlag(VR_PLATFORM_EXTENSION_INSTANCE)) {
Expand Down Expand Up @@ -125,29 +121,17 @@ void VR_Init( void* system, const char* name, int version ) {
}

// Get the graphics requirements.
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
PFN_xrGetVulkanGraphicsRequirementsKHR pfnGetVulkanGraphicsRequirementsKHR = NULL;
OXR(xrGetInstanceProcAddr(
vr_engine.appState.Instance,
"xrGetVulkanGraphicsRequirementsKHR",
(PFN_xrVoidFunction*)(&pfnGetVulkanGraphicsRequirementsKHR)));

XrGraphicsRequirementsVulkanKHR graphicsRequirements = {};
graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR;
OXR(pfnGetVulkanGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements));
} else {
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL;
OXR(xrGetInstanceProcAddr(
vr_engine.appState.Instance,
"xrGetOpenGLESGraphicsRequirementsKHR",
(PFN_xrVoidFunction*)(&pfnGetOpenGLESGraphicsRequirementsKHR)));

XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {};
graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR;
OXR(pfnGetOpenGLESGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements));
PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL;
OXR(xrGetInstanceProcAddr(
vr_engine.appState.Instance,
"xrGetOpenGLESGraphicsRequirementsKHR",
(PFN_xrVoidFunction*)(&pfnGetOpenGLESGraphicsRequirementsKHR)));

XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {};
graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR;
OXR(pfnGetOpenGLESGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements));
#endif
}

#ifdef ANDROID
vr_engine.appState.MainThreadTid = gettid();
Expand All @@ -163,7 +147,7 @@ void VR_Destroy( engine_t* engine ) {
}
}

void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan ) {
void VR_EnterVR( engine_t* engine ) {

if (engine->appState.Session) {
ALOGE("VR_EnterVR called with existing session");
Expand All @@ -178,20 +162,16 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu
XrGraphicsBindingOpenGLWin32KHR graphicsBindingGL = {};
#endif
memset(&sessionCreateInfo, 0, sizeof(sessionCreateInfo));
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
sessionCreateInfo.next = graphicsBindingVulkan;
} else {
#ifdef ANDROID
graphicsBindingGL.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR;
graphicsBindingGL.next = NULL;
graphicsBindingGL.display = eglGetCurrentDisplay();
graphicsBindingGL.config = NULL;
graphicsBindingGL.context = eglGetCurrentContext();
sessionCreateInfo.next = &graphicsBindingGL;
graphicsBindingGL.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR;
graphicsBindingGL.next = NULL;
graphicsBindingGL.display = eglGetCurrentDisplay();
graphicsBindingGL.config = NULL;
graphicsBindingGL.context = eglGetCurrentContext();
sessionCreateInfo.next = &graphicsBindingGL;
#else
//TODO:PCVR definition
//TODO:PCVR definition
#endif
}
sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO;
sessionCreateInfo.createFlags = 0;
sessionCreateInfo.systemId = engine->appState.SystemId;
Expand Down
7 changes: 1 addition & 6 deletions Common/VR/VRBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ typedef struct {
void* ColorSwapChainImage;
unsigned int* GLDepthBuffers;
unsigned int* GLFrameBuffers;
VkFramebuffer* VKFrameBuffers;
VkImageView* VKColorImages;

bool Acquired;
XrGraphicsBindingVulkanKHR* VKContext;
} ovrFramebuffer;

typedef struct {
Expand Down Expand Up @@ -115,7 +112,6 @@ typedef struct {
uint64_t frameIndex;
ovrApp appState;
XrTime predictedDisplayTime;
XrGraphicsBindingVulkanKHR graphicsBindingVulkan;
} engine_t;

enum VRPlatformFlag {
Expand All @@ -124,14 +120,13 @@ enum VRPlatformFlag {
VR_PLATFORM_EXTENSION_INSTANCE,
VR_PLATFORM_EXTENSION_PASSTHROUGH,
VR_PLATFORM_EXTENSION_PERFORMANCE,
VR_PLATFORM_RENDERER_VULKAN,
VR_PLATFORM_TRACKING_FLOOR,
VR_PLATFORM_MAX
};

void VR_Init( void* system, const char* name, int version );
void VR_Destroy( engine_t* engine );
void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan );
void VR_EnterVR( engine_t* engine );
void VR_LeaveVR( engine_t* engine );

engine_t* VR_GetEngine( void );
Expand Down
Loading

0 comments on commit ec0cba7

Please sign in to comment.