mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
OpenXR - Remove non-functional Vulkan implementation (#19766)
* OpenXR - Remove non-functional Vulkan implementation * Forgotten to commit
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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__)
|
||||
@@ -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:
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+2
-19
@@ -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"
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
+17
-37
@@ -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)) {
|
||||
@@ -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)));
|
||||
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));
|
||||
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();
|
||||
@@ -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");
|
||||
@@ -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;
|
||||
|
||||
+1
-6
@@ -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 {
|
||||
@@ -115,7 +112,6 @@ typedef struct {
|
||||
uint64_t frameIndex;
|
||||
ovrApp appState;
|
||||
XrTime predictedDisplayTime;
|
||||
XrGraphicsBindingVulkanKHR graphicsBindingVulkan;
|
||||
} engine_t;
|
||||
|
||||
enum VRPlatformFlag {
|
||||
@@ -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 );
|
||||
|
||||
+25
-137
@@ -153,105 +153,13 @@ static bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuff
|
||||
|
||||
#endif
|
||||
|
||||
#if XR_USE_GRAPHICS_API_VULKAN
|
||||
|
||||
static bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int width, int height,
|
||||
void* context) {
|
||||
|
||||
frameBuffer->Width = width;
|
||||
frameBuffer->Height = height;
|
||||
frameBuffer->VKContext = (XrGraphicsBindingVulkanKHR*)context;
|
||||
|
||||
XrSwapchainCreateInfo swapChainCreateInfo;
|
||||
memset(&swapChainCreateInfo, 0, sizeof(swapChainCreateInfo));
|
||||
swapChainCreateInfo.type = XR_TYPE_SWAPCHAIN_CREATE_INFO;
|
||||
swapChainCreateInfo.sampleCount = 1;
|
||||
swapChainCreateInfo.width = width;
|
||||
swapChainCreateInfo.height = height;
|
||||
swapChainCreateInfo.faceCount = 1;
|
||||
swapChainCreateInfo.mipCount = 1;
|
||||
swapChainCreateInfo.arraySize = 1;
|
||||
|
||||
frameBuffer->ColorSwapChain.Width = swapChainCreateInfo.width;
|
||||
frameBuffer->ColorSwapChain.Height = swapChainCreateInfo.height;
|
||||
|
||||
// Create the color swapchain.
|
||||
swapChainCreateInfo.format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
swapChainCreateInfo.usageFlags = XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
OXR(xrCreateSwapchain(session, &swapChainCreateInfo, &frameBuffer->ColorSwapChain.Handle));
|
||||
OXR(xrEnumerateSwapchainImages(frameBuffer->ColorSwapChain.Handle, 0, &frameBuffer->TextureSwapChainLength, NULL));
|
||||
frameBuffer->ColorSwapChainImage = malloc(frameBuffer->TextureSwapChainLength * sizeof(XrSwapchainImageVulkanKHR));
|
||||
|
||||
// Populate the swapchain image array.
|
||||
for (uint32_t i = 0; i < frameBuffer->TextureSwapChainLength; i++) {
|
||||
((XrSwapchainImageVulkanKHR*)frameBuffer->ColorSwapChainImage)[i].type = XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR;
|
||||
((XrSwapchainImageVulkanKHR*)frameBuffer->ColorSwapChainImage)[i].next = NULL;
|
||||
}
|
||||
OXR(xrEnumerateSwapchainImages(
|
||||
frameBuffer->ColorSwapChain.Handle,
|
||||
frameBuffer->TextureSwapChainLength,
|
||||
&frameBuffer->TextureSwapChainLength,
|
||||
(XrSwapchainImageBaseHeader*)frameBuffer->ColorSwapChainImage));
|
||||
|
||||
frameBuffer->VKColorImages = new VkImageView[frameBuffer->TextureSwapChainLength];
|
||||
frameBuffer->VKFrameBuffers = new VkFramebuffer[frameBuffer->TextureSwapChainLength];
|
||||
for (uint32_t i = 0; i < frameBuffer->TextureSwapChainLength; i++) {
|
||||
VkImageViewCreateInfo createInfo{};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
createInfo.image = ((XrSwapchainImageVulkanKHR*)frameBuffer->ColorSwapChainImage)[i].image;
|
||||
createInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||
createInfo.format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
createInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
createInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
createInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
createInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
createInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
createInfo.subresourceRange.baseMipLevel = 0;
|
||||
createInfo.subresourceRange.levelCount = 1;
|
||||
createInfo.subresourceRange.baseArrayLayer = 0;
|
||||
createInfo.subresourceRange.layerCount = swapChainCreateInfo.arraySize;
|
||||
if (vkCreateImageView(frameBuffer->VKContext->device, &createInfo, nullptr, &frameBuffer->VKColorImages[i]) != VK_SUCCESS) {
|
||||
ALOGE("failed to create color image view!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the frame buffer.
|
||||
VkImageView attachments[] = { frameBuffer->VKColorImages[i] };
|
||||
VkFramebufferCreateInfo framebufferInfo{};
|
||||
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||
framebufferInfo.renderPass = VK_NULL_HANDLE; //TODO:This is probably wrong
|
||||
framebufferInfo.attachmentCount = 2;
|
||||
framebufferInfo.pAttachments = attachments;
|
||||
framebufferInfo.width = width;
|
||||
framebufferInfo.height = height;
|
||||
framebufferInfo.layers = swapChainCreateInfo.arraySize;
|
||||
if (vkCreateFramebuffer(frameBuffer->VKContext->device, &framebufferInfo, nullptr, &frameBuffer->VKFrameBuffers[i]) != VK_SUCCESS) {
|
||||
ALOGE("failed to create framebuffer!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) {
|
||||
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||
for (int i = 0; i < (int)frameBuffer->TextureSwapChainLength; i++) {
|
||||
vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKColorImages[i], nullptr);
|
||||
vkDestroyFramebuffer(frameBuffer->VKContext->device, frameBuffer->VKFrameBuffers[i], nullptr);
|
||||
}
|
||||
delete[] frameBuffer->VKColorImages;
|
||||
delete[] frameBuffer->VKFrameBuffers;
|
||||
} else {
|
||||
#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL
|
||||
GL(glDeleteRenderbuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLDepthBuffers));
|
||||
GL(glDeleteFramebuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLFrameBuffers));
|
||||
free(frameBuffer->GLDepthBuffers);
|
||||
free(frameBuffer->GLFrameBuffers);
|
||||
GL(glDeleteRenderbuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLDepthBuffers));
|
||||
GL(glDeleteFramebuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLFrameBuffers));
|
||||
free(frameBuffer->GLDepthBuffers);
|
||||
free(frameBuffer->GLFrameBuffers);
|
||||
#endif
|
||||
}
|
||||
OXR(xrDestroySwapchain(frameBuffer->ColorSwapChain.Handle));
|
||||
free(frameBuffer->ColorSwapChainImage);
|
||||
|
||||
@@ -259,14 +167,10 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) {
|
||||
}
|
||||
|
||||
void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) {
|
||||
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||
return (void *)frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex];
|
||||
} else {
|
||||
#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL
|
||||
GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[frameBuffer->TextureSwapChainIndex]));
|
||||
GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[frameBuffer->TextureSwapChainIndex]));
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) {
|
||||
@@ -282,19 +186,15 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) {
|
||||
|
||||
ovrFramebuffer_SetCurrent(frameBuffer);
|
||||
|
||||
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||
//TODO:implement
|
||||
} else {
|
||||
#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL
|
||||
GL(glEnable( GL_SCISSOR_TEST ));
|
||||
GL(glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height ));
|
||||
GL(glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ));
|
||||
GL(glScissor( 0, 0, frameBuffer->Width, frameBuffer->Height ));
|
||||
GL(glClear( GL_COLOR_BUFFER_BIT ));
|
||||
GL(glScissor( 0, 0, 0, 0 ));
|
||||
GL(glDisable( GL_SCISSOR_TEST ));
|
||||
GL(glEnable( GL_SCISSOR_TEST ));
|
||||
GL(glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height ));
|
||||
GL(glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ));
|
||||
GL(glScissor( 0, 0, frameBuffer->Width, frameBuffer->Height ));
|
||||
GL(glClear( GL_COLOR_BUFFER_BIT ));
|
||||
GL(glScissor( 0, 0, 0, 0 ));
|
||||
GL(glDisable( GL_SCISSOR_TEST ));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) {
|
||||
@@ -304,16 +204,12 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) {
|
||||
frameBuffer->Acquired = false;
|
||||
|
||||
// Clear the alpha channel, other way OpenXR would not transfer the framebuffer fully
|
||||
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||
//TODO:implement
|
||||
} else {
|
||||
#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL
|
||||
GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE));
|
||||
GL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
GL(glClear(GL_COLOR_BUFFER_BIT));
|
||||
GL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE));
|
||||
GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE));
|
||||
GL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
GL(glClear(GL_COLOR_BUFFER_BIT));
|
||||
GL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,15 +227,11 @@ void ovrRenderer_Clear(ovrRenderer* renderer) {
|
||||
}
|
||||
}
|
||||
|
||||
void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height, void* vulkanContext) {
|
||||
void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height) {
|
||||
for (int i = 0; i < ovrMaxNumEyes; i++) {
|
||||
if (vulkanContext) {
|
||||
ovrFramebuffer_CreateVK(session, &renderer->FrameBuffer[i], width, height, vulkanContext);
|
||||
} else {
|
||||
#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL
|
||||
ovrFramebuffer_CreateGL(session, &renderer->FrameBuffer[i], width, height);
|
||||
ovrFramebuffer_CreateGL(session, &renderer->FrameBuffer[i], width, height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,18 +242,14 @@ void ovrRenderer_Destroy(ovrRenderer* renderer) {
|
||||
}
|
||||
|
||||
void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int sx, int sy) {
|
||||
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||
//TODO:implement
|
||||
} else {
|
||||
#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL
|
||||
GL(glEnable(GL_SCISSOR_TEST));
|
||||
GL(glScissor(x, y, sx, sy));
|
||||
GL(glViewport(x, y, sx, sy));
|
||||
GL(glClearColor(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
GL(glClear(GL_COLOR_BUFFER_BIT));
|
||||
GL(glDisable(GL_SCISSOR_TEST));
|
||||
GL(glEnable(GL_SCISSOR_TEST));
|
||||
GL(glScissor(x, y, sx, sy));
|
||||
GL(glViewport(x, y, sx, sy));
|
||||
GL(glClearColor(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
GL(glClear(GL_COLOR_BUFFER_BIT));
|
||||
GL(glDisable(GL_SCISSOR_TEST));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,6 +10,6 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer);
|
||||
void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer);
|
||||
void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer);
|
||||
|
||||
void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height, void* vulkanContext);
|
||||
void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height);
|
||||
void ovrRenderer_Destroy(ovrRenderer* renderer);
|
||||
void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int sx, int sy);
|
||||
|
||||
@@ -237,11 +237,7 @@ void VR_InitRenderer( engine_t* engine ) {
|
||||
projections[eye].type = XR_TYPE_VIEW;
|
||||
}
|
||||
|
||||
void* vulkanContext = nullptr;
|
||||
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||
vulkanContext = &engine->graphicsBindingVulkan;
|
||||
}
|
||||
ovrRenderer_Create(engine->appState.Session, &engine->appState.Renderer, eyeW, eyeH, vulkanContext);
|
||||
ovrRenderer_Create(engine->appState.Session, &engine->appState.Renderer, eyeW, eyeH);
|
||||
|
||||
if (VR_GetPlatformFlag(VRPlatformFlag::VR_PLATFORM_EXTENSION_PASSTHROUGH)) {
|
||||
XrPassthroughCreateInfoFB ptci = {XR_TYPE_PASSTHROUGH_CREATE_INFO_FB};
|
||||
|
||||
@@ -993,7 +993,7 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e
|
||||
System_PostUIMessage(UIMessage::RECREATE_VIEWS);
|
||||
|
||||
if (IsVREnabled()) {
|
||||
EnterVR(firstStart, graphicsContext->GetAPIContext());
|
||||
EnterVR(firstStart);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user