mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-13 14:30:27 +02:00
OpenXR - Remove non-functional Vulkan implementation (#19766)
* OpenXR - Remove non-functional Vulkan implementation * Forgotten to commit
This commit is contained in:
1 parent
5def50cca6
commit
d1f8b78bbb
11 files changed
+51
-236
No files matched your search
+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
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user