Skip to content
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

VR: Add the VR code to all builds. Remove IsVRBuild calls from the renderer. #16246

Merged
merged 9 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ add_definitions(-DASSETS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/ppsspp/assets/")
if(OPENXR)
add_definitions(-DOPENXR)
add_library(openxr SHARED IMPORTED)
include_directories(ext/openxr)
if(OPENXR_PLATFORM_PICO)
add_definitions(-DOPENXR_PLATFORM_PICO)
set_property(TARGET openxr PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/ext/openxr/libs/pico/arm64-v8a/libopenxr_loader.so")
Expand Down Expand Up @@ -507,13 +506,30 @@ if(WIN32)
)
endif()

set(CommonVR
Common/VR/PPSSPPVR.cpp
Common/VR/PPSSPPVR.h
Common/VR/VRBase.cpp
Common/VR/VRBase.h
Common/VR/VRFramebuffer.cpp
Common/VR/VRFramebuffer.h
Common/VR/VRInput.cpp
Common/VR/VRInput.h
Common/VR/VRMath.cpp
Common/VR/VRMath.h
Common/VR/VRRenderer.cpp
Common/VR/VRRenderer.h
)
include_directories(ext/openxr)

add_library(Common STATIC
${CommonX86}
${CommonARM}
${CommonARM64}
${CommonMIPS}
${CommonRISCV64}
${CommonD3D}
${CommonVR}
Common/Serialize/Serializer.cpp
Common/Serialize/Serializer.h
Common/Serialize/SerializeDeque.h
Expand Down Expand Up @@ -1091,22 +1107,7 @@ if(ANDROID)
android/jni/OpenSLContext.cpp
android/jni/OpenSLContext.h
)

if (OPENXR)
set(nativeExtra ${nativeExtra}
Common/VR/PPSSPPVR.cpp
Common/VR/PPSSPPVR.h
Common/VR/VRBase.cpp
Common/VR/VRBase.h
Common/VR/VRFramebuffer.cpp
Common/VR/VRFramebuffer.h
Common/VR/VRInput.cpp
Common/VR/VRInput.h
Common/VR/VRMath.cpp
Common/VR/VRMath.h
Common/VR/VRRenderer.cpp
Common/VR/VRRenderer.h
)
set(nativeExtraLibs ${nativeExtraLibs} openxr)
endif()
# No target
Expand Down
30 changes: 21 additions & 9 deletions Common/Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
Expand All @@ -162,7 +162,7 @@
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<OmitFramePointers>false</OmitFramePointers>
Expand All @@ -189,7 +189,7 @@
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<OmitFramePointers>false</OmitFramePointers>
Expand Down Expand Up @@ -217,7 +217,7 @@
</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<OmitFramePointers>false</OmitFramePointers>
Expand Down Expand Up @@ -250,7 +250,7 @@
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
Expand Down Expand Up @@ -280,7 +280,7 @@
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
Expand Down Expand Up @@ -315,7 +315,7 @@
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
Expand Down Expand Up @@ -350,7 +350,7 @@
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
Expand Down Expand Up @@ -557,6 +557,12 @@
<ClInclude Include="UI\UIScreen.h" />
<ClInclude Include="UI\View.h" />
<ClInclude Include="UI\ViewGroup.h" />
<ClInclude Include="VR\PPSSPPVR.h" />
<ClInclude Include="VR\VRBase.h" />
<ClInclude Include="VR\VRFramebuffer.h" />
<ClInclude Include="VR\VRInput.h" />
<ClInclude Include="VR\VRMath.h" />
<ClInclude Include="VR\VRRenderer.h" />
<ClInclude Include="x64Analyzer.h" />
<ClInclude Include="x64Emitter.h" />
</ItemGroup>
Expand Down Expand Up @@ -989,6 +995,12 @@
<ClCompile Include="UI\UIScreen.cpp" />
<ClCompile Include="UI\View.cpp" />
<ClCompile Include="UI\ViewGroup.cpp" />
<ClCompile Include="VR\PPSSPPVR.cpp" />
<ClCompile Include="VR\VRBase.cpp" />
<ClCompile Include="VR\VRFramebuffer.cpp" />
<ClCompile Include="VR\VRInput.cpp" />
<ClCompile Include="VR\VRMath.cpp" />
<ClCompile Include="VR\VRRenderer.cpp" />
<ClCompile Include="x64Analyzer.cpp" />
<ClCompile Include="x64Emitter.cpp" />
</ItemGroup>
Expand All @@ -1003,4 +1015,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
41 changes: 40 additions & 1 deletion Common/Common.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,24 @@
<ClInclude Include="Math\Statistics.h">
<Filter>Math</Filter>
</ClInclude>
<ClInclude Include="VR\PPSSPPVR.h">
<Filter>VR</Filter>
</ClInclude>
<ClInclude Include="VR\VRBase.h">
<Filter>VR</Filter>
</ClInclude>
<ClInclude Include="VR\VRFramebuffer.h">
<Filter>VR</Filter>
</ClInclude>
<ClInclude Include="VR\VRInput.h">
<Filter>VR</Filter>
</ClInclude>
<ClInclude Include="VR\VRMath.h">
<Filter>VR</Filter>
</ClInclude>
<ClInclude Include="VR\VRRenderer.h">
<Filter>VR</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ABI.cpp" />
Expand Down Expand Up @@ -803,6 +821,24 @@
<ClCompile Include="Math\Statistics.cpp">
<Filter>Math</Filter>
</ClCompile>
<ClCompile Include="VR\PPSSPPVR.cpp">
<Filter>VR</Filter>
</ClCompile>
<ClCompile Include="VR\VRBase.cpp">
<Filter>VR</Filter>
</ClCompile>
<ClCompile Include="VR\VRFramebuffer.cpp">
<Filter>VR</Filter>
</ClCompile>
<ClCompile Include="VR\VRInput.cpp">
<Filter>VR</Filter>
</ClCompile>
<ClCompile Include="VR\VRMath.cpp">
<Filter>VR</Filter>
</ClCompile>
<ClCompile Include="VR\VRRenderer.cpp">
<Filter>VR</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Crypto">
Expand Down Expand Up @@ -907,10 +943,13 @@
<Filter Include="ext\vma">
<UniqueIdentifier>{7b17065c-729c-47c3-a02d-66dc383529dd}</UniqueIdentifier>
</Filter>
<Filter Include="VR">
<UniqueIdentifier>{9d1c29fd-8ac7-4475-8ea6-c8c759b695fe}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="..\ext\libpng17\CMakeLists.txt">
<Filter>ext\libpng17</Filter>
</Text>
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion Common/File/DirListing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ std::vector<std::string> GetWindowsDrives()
{
if (logicaldrives & (1 << i))
{
CHAR driveName[] = { TEXT('A') + i, TEXT(':'), TEXT('\\'), TEXT('\0') };
CHAR driveName[] = { (CHAR)(TEXT('A') + i), TEXT(':'), TEXT('\\'), TEXT('\0') };
std::string str(driveName);
drives.push_back(driveName);
}
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/OpenGL/GLQueueRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void GLQueueRunner::InitCreateFramebuffer(const GLRInitStep &step) {
currentReadHandle_ = fbo->handle;
}

void GLQueueRunner::RunSteps(const std::vector<GLRStep *> &steps, bool skipGLCalls, bool keepSteps) {
void GLQueueRunner::RunSteps(const std::vector<GLRStep *> &steps, bool skipGLCalls, bool keepSteps, bool useVR) {
if (skipGLCalls) {
if (keepSteps) {
return;
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/OpenGL/GLQueueRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class GLQueueRunner {

void RunInitSteps(const std::vector<GLRInitStep> &steps, bool skipGLCalls);

void RunSteps(const std::vector<GLRStep *> &steps, bool skipGLCalls, bool keepSteps = false);
void RunSteps(const std::vector<GLRStep *> &steps, bool skipGLCalls, bool keepSteps, bool useVR);
void LogSteps(const std::vector<GLRStep *> &steps);

void CreateDeviceObjects();
Expand Down
4 changes: 2 additions & 2 deletions Common/GPU/OpenGL/GLRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,11 @@ void GLRenderManager::Run(int frame) {
int passes = GetVRPassesCount();
for (int i = 0; i < passes; i++) {
PreVRFrameRender(i);
queueRunner_.RunSteps(stepsOnThread, skipGLCalls_, i < passes - 1);
queueRunner_.RunSteps(stepsOnThread, skipGLCalls_, i < passes - 1, true);
PostVRFrameRender();
}
} else {
queueRunner_.RunSteps(stepsOnThread, skipGLCalls_);
queueRunner_.RunSteps(stepsOnThread, skipGLCalls_, false, false);
}
stepsOnThread.clear();

Expand Down
3 changes: 1 addition & 2 deletions Common/GPU/Vulkan/VulkanLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ void VulkanSetAvailable(bool available) {
}

bool VulkanMayBeAvailable() {

//unsupported in VR at the moment
// Unsupported in VR at the moment
if (IsVRBuild()) {
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions Common/VR/PPSSPPVR.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef OPENXR

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

Expand Down Expand Up @@ -99,6 +101,7 @@ bool IsVRBuild() {
return true;
}

#if PPSSPP_PLATFORM(ANDROID)
void InitVROnAndroid(void* vm, void* activity, int version, const char* name) {
bool useVulkan = (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN;

Expand All @@ -111,6 +114,7 @@ void InitVROnAndroid(void* vm, void* activity, int version, const char* name) {

__DisplaySetFramerate(72);
}
#endif

void EnterVR(bool firstStart, void* vulkanContext) {
if (firstStart) {
Expand Down Expand Up @@ -456,3 +460,5 @@ void UpdateVRView(float* leftEye, float* rightEye) {
memcpy(dst[index], renderView.M, 16 * sizeof(float));
}
}

#endif
9 changes: 7 additions & 2 deletions Common/VR/VRBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <vector>

#if defined(ANDROID) && defined(OPENXR)

#include <unistd.h>

#ifdef OPENXR_PLATFORM_PICO
enum ConfigsSetEXT {
UNREAL_VERSION = 0,
Expand Down Expand Up @@ -58,7 +61,7 @@ void VR_Init( ovrJava java, bool useVulkan ) {
xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfoAndroid);
}

std::vector<char*> extensions;
std::vector<const char *> extensions;
if (useVulkan) {
extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME);
} else {
Expand Down Expand Up @@ -248,3 +251,5 @@ void VR_LeaveVR( engine_t* engine ) {
engine_t* VR_GetEngine( void ) {
return &vr_engine;
}

#endif
Loading