Support for changeable fresh rate

This commit is contained in:
Simon 2023-04-15 12:32:35 +01:00
parent 539bfa8956
commit 35b89acc87
4 changed files with 21 additions and 9 deletions

View file

@ -25,7 +25,6 @@ extern "C" {
//Let's go to the maximum! //Let's go to the maximum!
extern int NUM_MULTI_SAMPLES; extern int NUM_MULTI_SAMPLES;
extern int REFRESH ;
extern float SS_MULTIPLIER ; extern float SS_MULTIPLIER ;
@ -34,7 +33,6 @@ struct arg_dbl *ss;
struct arg_int *cpu; struct arg_int *cpu;
struct arg_int *gpu; struct arg_int *gpu;
struct arg_int *msaa; struct arg_int *msaa;
struct arg_int *refresh;
struct arg_end *end; struct arg_end *end;
char **argv; char **argv;
@ -311,6 +309,7 @@ void VR_Init()
vr_gesture_triggered_use = Cvar_Get ("vr_gesture_triggered_use", "1", CVAR_ARCHIVE); vr_gesture_triggered_use = Cvar_Get ("vr_gesture_triggered_use", "1", CVAR_ARCHIVE);
vr_use_gesture_boundary = Cvar_Get ("vr_use_gesture_boundary", "0.35", CVAR_ARCHIVE); 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_align_weapons = Cvar_Get ("vr_align_weapons", "0", CVAR_ARCHIVE);
vr_refresh = Cvar_Get ("vr_refresh", "72", CVAR_ARCHIVE);
cvar_t *expanded_menu_enabled = Cvar_Get ("expanded_menu_enabled", "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")) { if (FS_FileExists("expanded_menu.pk3") || FS_BaseFileExists("expanded_menu.pk3")) {
@ -371,9 +370,27 @@ void * AppThreadFunction(void * parm ) {
return NULL; return NULL;
} }
int VR_SetRefreshRate(int refreshRate)
{
if (strstr(gAppState.OpenXRHMD, "meta") != NULL)
{
OXR(gAppState.pfnRequestDisplayRefreshRate(gAppState.Session, (float) refreshRate));
return refreshRate;
}
return 0;
}
//All the stuff we want to do each frame specifically for this game //All the stuff we want to do each frame specifically for this game
void VR_FrameSetup() void VR_FrameSetup()
{ {
static float refresh = 0;
if (refresh != vr_refresh->value)
{
refresh = vr_refresh->value;
VR_SetRefreshRate(vr_refresh->value);
}
//get any cvar values required here //get any cvar values required here
vr.immersive_cinematics = (vr_immersive_cinematics->value != 0.0f); vr.immersive_cinematics = (vr_immersive_cinematics->value != 0.0f);
} }
@ -699,7 +716,6 @@ JNIEXPORT jlong JNICALL Java_com_drbeef_jkxr_GLES3JNILib_onCreate( JNIEnv * env,
cpu = arg_int0("c", "cpu", "<int>", "CPU perf index 1-4 (default: 2)"), cpu = arg_int0("c", "cpu", "<int>", "CPU perf index 1-4 (default: 2)"),
gpu = arg_int0("g", "gpu", "<int>", "GPU perf index 1-4 (default: 3)"), gpu = arg_int0("g", "gpu", "<int>", "GPU perf index 1-4 (default: 3)"),
msaa = arg_int0("m", "msaa", "<int>", "MSAA (default: 1)"), msaa = arg_int0("m", "msaa", "<int>", "MSAA (default: 1)"),
refresh = arg_int0("r", "refresh", "<int>", "Refresh Rate (default: Q1: 72, Q2: 72)"),
end = arg_end(20) end = arg_end(20)
}; };
@ -732,11 +748,6 @@ JNIEXPORT jlong JNICALL Java_com_drbeef_jkxr_GLES3JNILib_onCreate( JNIEnv * env,
{ {
NUM_MULTI_SAMPLES = msaa->ival[0]; NUM_MULTI_SAMPLES = msaa->ival[0];
} }
if (refresh->count > 0 && refresh->ival[0] > 0 && refresh->ival[0] <= 120)
{
REFRESH = refresh->ival[0];
}
} }
initialize_gl4es(); initialize_gl4es();

View file

@ -65,7 +65,6 @@ PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR;
//Let's go to the maximum! //Let's go to the maximum!
int NUM_MULTI_SAMPLES = 2; int NUM_MULTI_SAMPLES = 2;
int REFRESH = 0;
float SS_MULTIPLIER = 0.0f; float SS_MULTIPLIER = 0.0f;
GLboolean stageSupported = GL_FALSE; GLboolean stageSupported = GL_FALSE;

View file

@ -23,4 +23,5 @@ extern cvar_t *vr_saber_3rdperson_mode;
extern cvar_t *vr_gesture_triggered_use; extern cvar_t *vr_gesture_triggered_use;
extern cvar_t *vr_use_gesture_boundary; extern cvar_t *vr_use_gesture_boundary;
extern cvar_t *vr_align_weapons; // Only used for development extern cvar_t *vr_align_weapons; // Only used for development
extern cvar_t *vr_refresh;

View file

@ -36,6 +36,7 @@ cvar_t *vr_saber_3rdperson_mode;
cvar_t *vr_gesture_triggered_use; cvar_t *vr_gesture_triggered_use;
cvar_t *vr_use_gesture_boundary; cvar_t *vr_use_gesture_boundary;
cvar_t *vr_align_weapons; cvar_t *vr_align_weapons;
cvar_t *vr_refresh;
ovrInputStateTrackedRemote leftTrackedRemoteState_old; ovrInputStateTrackedRemote leftTrackedRemoteState_old;
ovrInputStateTrackedRemote leftTrackedRemoteState_new; ovrInputStateTrackedRemote leftTrackedRemoteState_new;