From 0e58a043acbc9c8bb84e80d378e127233689c9fc Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Wed, 13 Dec 2023 19:25:06 +0100 Subject: [PATCH] Configurable super sampling for PCVR (untested\!) --- .../OpenJK/JKXR/windows/JKXR_SurfaceView.cpp | 1 + .../jni/OpenJK/JKXR/windows/TBXR_Common.cpp | 42 +++++++++++++++++-- z_vr_assets_jka/ui/ingamesetup.menu | 2 - z_vr_assets_jka/ui/setup.menu | 2 - z_vr_assets_jko/ui/ingamesetup.menu | 2 - z_vr_assets_jko/ui/setup.menu | 2 - 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp b/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp index f835129..0219f37 100644 --- a/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp +++ b/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp @@ -280,6 +280,7 @@ void VR_Init() vr_use_gesture_boundary = Cvar_Get ("vr_use_gesture_boundary", "0.35", CVAR_ARCHIVE); vr_align_weapons = Cvar_Get ("vr_align_weapons", "0", CVAR_ARCHIVE); vr_refresh = Cvar_Get ("vr_refresh", "72", CVAR_ARCHIVE); + vr_super_sampling = Cvar_Get ("vr_super_sampling", "1.0", CVAR_ARCHIVE); cvar_t *expanded_menu_enabled = Cvar_Get ("expanded_menu_enabled", "0", CVAR_ARCHIVE); if (FS_FileExists("expanded_menu.pk3") || FS_BaseFileExists("expanded_menu.pk3")) { diff --git a/Projects/Android/jni/OpenJK/JKXR/windows/TBXR_Common.cpp b/Projects/Android/jni/OpenJK/JKXR/windows/TBXR_Common.cpp index 4ba2310..db6ca97 100644 --- a/Projects/Android/jni/OpenJK/JKXR/windows/TBXR_Common.cpp +++ b/Projects/Android/jni/OpenJK/JKXR/windows/TBXR_Common.cpp @@ -17,6 +17,10 @@ const float ZOOM_FOV_ADJUST = 1.1f; +float superSampling = 1.0f; +qboolean usingScreenLayer = qtrue; +qboolean resetScreenLayerRenderer = qfalse; + const char* const requiredExtensionNames[] = { XR_KHR_OPENGL_ENABLE_EXTENSION_NAME}; @@ -671,8 +675,15 @@ bool destroyed = qfalse; void TBXR_GetScreenRes(int *width, int *height) { - *width = gAppState.Width; - *height = gAppState.Height; + float configuredSuperSampling = Cvar_VariableValue("vr_super_sampling"); + if (configuredSuperSampling != 0.0f && configuredSuperSampling != superSampling) { + superSampling = configuredSuperSampling; + resetScreenLayerRenderer = qtrue; + Cbuf_AddText( "vid_restart\n" ); + } + + *width = gAppState.Width * superSampling; + *height = gAppState.Height * superSampling; } XrInstance TBXR_GetXrInstance() { @@ -831,11 +842,14 @@ void TBXR_InitRenderer( ) { gAppState.Views[eye].type = XR_TYPE_VIEW; } + int eyeW, eyeH; + TBXR_GetScreenRes(&eyeW, &eyeH); + ovrRenderer_Create( gAppState.Session, &gAppState.Renderer, - gAppState.ViewConfigurationView[0].recommendedImageRectWidth, - gAppState.ViewConfigurationView[0].recommendedImageRectHeight); + eyeW, + eyeH); } void VR_DestroyRenderer( ) @@ -844,6 +858,13 @@ void VR_DestroyRenderer( ) free(gAppState.Views); } +void VR_ResetRenderer() +{ + VR_DestroyRenderer(); + TBXR_InitialiseResolution(); + TBXR_InitRenderer(); +} + void TBXR_InitialiseOpenXR() { // Create the OpenXR instance. @@ -1170,6 +1191,12 @@ void TBXR_submitFrame() if (!VR_UseScreenLayer()) { + + if (usingScreenLayer) { + usingScreenLayer = qfalse; + VR_ResetRenderer(); + } + memset(&projection_layer, 0, sizeof(XrCompositionLayerProjection)); projection_layer.type = XR_TYPE_COMPOSITION_LAYER_PROJECTION; projection_layer.layerFlags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT; @@ -1203,6 +1230,13 @@ void TBXR_submitFrame() } else { + + usingScreenLayer = qtrue; + if (resetScreenLayerRenderer) { + resetScreenLayerRenderer = qfalse; + VR_ResetRenderer(); + } + //Empty black projection for now memset(&projection_layer, 0, sizeof(XrCompositionLayerProjection)); projection_layer.type = XR_TYPE_COMPOSITION_LAYER_PROJECTION; diff --git a/z_vr_assets_jka/ui/ingamesetup.menu b/z_vr_assets_jka/ui/ingamesetup.menu index 142c166..f70d206 100644 --- a/z_vr_assets_jka/ui/ingamesetup.menu +++ b/z_vr_assets_jka/ui/ingamesetup.menu @@ -1089,8 +1089,6 @@ cvarFloatList { "0.8" 0.8 "0.9" 0.9 "1.0" 1.0 "1.1" 1.1 "1.2" 1.2 "1.3" 1.3 } descText @MENUS_VR_SUPER_SAMPLING_DESC cvar "vr_super_sampling" - cvarTest openXRHMD - showCvar { meta } visible 0 diff --git a/z_vr_assets_jka/ui/setup.menu b/z_vr_assets_jka/ui/setup.menu index 9f97d51..30972f4 100644 --- a/z_vr_assets_jka/ui/setup.menu +++ b/z_vr_assets_jka/ui/setup.menu @@ -1096,8 +1096,6 @@ cvarFloatList { "0.8" 0.8 "0.9" 0.9 "1.0" 1.0 "1.1" 1.1 "1.2" 1.2 "1.3" 1.3 } descText @MENUS_VR_SUPER_SAMPLING_DESC cvar "vr_super_sampling" - cvarTest openXRHMD - showCvar { meta } visible 0 diff --git a/z_vr_assets_jko/ui/ingamesetup.menu b/z_vr_assets_jko/ui/ingamesetup.menu index 554b3d3..a7641e1 100644 --- a/z_vr_assets_jko/ui/ingamesetup.menu +++ b/z_vr_assets_jko/ui/ingamesetup.menu @@ -1293,8 +1293,6 @@ cvarFloatList { "0.8" 0.8 "0.9" 0.9 "1.0" 1.0 "1.1" 1.1 "1.2" 1.2 "1.3" 1.3 } descText @MENUS_VR_SUPER_SAMPLING_DESC cvar "vr_super_sampling" - cvarTest openXRHMD - showCvar { meta } visible 0 diff --git a/z_vr_assets_jko/ui/setup.menu b/z_vr_assets_jko/ui/setup.menu index 0b91a20..4c93e1f 100644 --- a/z_vr_assets_jko/ui/setup.menu +++ b/z_vr_assets_jko/ui/setup.menu @@ -1392,8 +1392,6 @@ cvarFloatList { "0.8" 0.8 "0.9" 0.9 "1.0" 1.0 "1.1" 1.1 "1.2" 1.2 "1.3" 1.3 } descText @MENUS_VR_SUPER_SAMPLING_DESC cvar "vr_super_sampling" - cvarTest openXRHMD - showCvar { meta } visible 0