From 96b1071b50cbb71dc917d0a0cafd317e550b9c31 Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Thu, 29 Sep 2022 17:38:20 +0200 Subject: [PATCH] Add super sampling configuration and 120hz refresh rate --- .../app/src/main/cpp/code/q3_ui/ui_video.c | 82 ++++++++++++++++++- android/app/src/main/cpp/code/vr/vr_base.c | 2 + .../app/src/main/cpp/code/vr/vr_clientinfo.h | 1 + .../app/src/main/cpp/code/vr/vr_renderer.c | 35 ++++++-- .../app/src/main/pakQ3Q/ui/ingame_system.menu | 36 +++++--- android/app/src/main/pakQ3Q/ui/system.menu | 36 +++++--- 6 files changed, 164 insertions(+), 28 deletions(-) diff --git a/android/app/src/main/cpp/code/q3_ui/ui_video.c b/android/app/src/main/cpp/code/q3_ui/ui_video.c index cf8b3cd7..a1d803b9 100644 --- a/android/app/src/main/cpp/code/q3_ui/ui_video.c +++ b/android/app/src/main/cpp/code/q3_ui/ui_video.c @@ -249,10 +249,12 @@ GRAPHICS OPTIONS MENU #define ID_PLAYERSHADOW 109 #define ID_GAMMA 110 #define ID_HIGHQUALITYSKY 111 +#define ID_SUPERSAMPLING 112 -#define NUM_REFRESHRATE 4 +#define NUM_REFRESHRATE 5 #define NUM_SHADOWS 3 #define NUM_RAILGUN 2 +#define NUM_SUPERSAMPLING 5 typedef struct { menuframework_s menu; @@ -276,6 +278,7 @@ typedef struct { menulist_s playershadow; menuslider_s gamma; menuradiobutton_s highqualitysky; + menulist_s supersampling; menubitmap_s apply; menubitmap_s back; @@ -292,6 +295,7 @@ typedef struct int playershadow; float gamma; int highqualitysky; + float supersampling; } InitialVideoOptions_s; static InitialVideoOptions_s s_ivo; @@ -313,6 +317,7 @@ static void GraphicsOptions_GetInitialVideo( void ) s_ivo.playershadow = s_graphicsoptions.playershadow.curvalue; s_ivo.gamma = s_graphicsoptions.gamma.curvalue; s_ivo.highqualitysky = s_graphicsoptions.highqualitysky.curvalue; + s_ivo.supersampling = s_graphicsoptions.supersampling.curvalue; } /* @@ -401,6 +406,9 @@ static void GraphicsOptions_Event( void* ptr, int event ) { case 3: refresh = 90; break; + case 4: + refresh = 120; + break; } trap_Cvar_SetValue("vr_refreshrate", refresh); } @@ -452,6 +460,29 @@ static void GraphicsOptions_Event( void* ptr, int event ) { trap_Cvar_SetValue( "r_fastsky", !s_graphicsoptions.highqualitysky.curvalue ); break; + case ID_SUPERSAMPLING: { + float supersampling; + switch (s_graphicsoptions.supersampling.curvalue) { + case 0: + supersampling = 0.8; + break; + case 1: + supersampling = 0.9; + break; + case 2: + supersampling = 1.0; + break; + case 3: + supersampling = 1.1; + break; + case 4: + supersampling = 1.2; + break; + } + trap_Cvar_SetValue("vr_superSampling", supersampling); + } + break; + case ID_DRIVERINFO: UI_DriverInfo_Menu(); break; @@ -542,6 +573,12 @@ static void GraphicsOptions_SetMenuItems( void ) case 90: s_graphicsoptions.refreshrate.curvalue = 3; break; + case 120: + s_graphicsoptions.refreshrate.curvalue = 4; + break; + default: + s_graphicsoptions.refreshrate.curvalue = 1; + break; } switch ( (int) trap_Cvar_VariableValue( "cg_shadows" ) ) @@ -570,6 +607,21 @@ static void GraphicsOptions_SetMenuItems( void ) break; } + float superSampling = trap_Cvar_VariableValue( "vr_superSampling" ); + if (superSampling == 0.8f) { + s_graphicsoptions.supersampling.curvalue = 0; + } else if (superSampling == 0.9f) { + s_graphicsoptions.supersampling.curvalue = 1; + } else if (superSampling == 1.0f) { + s_graphicsoptions.supersampling.curvalue = 2; + } else if (superSampling == 1.1f) { + s_graphicsoptions.supersampling.curvalue = 3; + } else if (superSampling == 1.2f) { + s_graphicsoptions.supersampling.curvalue = 4; + } else { + s_graphicsoptions.supersampling.curvalue = 3; + } + s_graphicsoptions.lighting.curvalue = trap_Cvar_VariableValue( "r_vertexLight" ) != 0; s_graphicsoptions.railgun.curvalue = trap_Cvar_VariableValue( "cg_oldRail" ); s_graphicsoptions.gamma.curvalue = trap_Cvar_VariableValue( "r_gamma" ); @@ -602,9 +654,10 @@ void GraphicsOptions_MenuInit( void ) static const char *s_refreshrate[] = { "60", - "72 (Recommended)", + "72", "80", "90", + "120", NULL }; @@ -623,6 +676,16 @@ void GraphicsOptions_MenuInit( void ) NULL }; + static const char *s_supersampling[] = + { + "0.8", + "0.9", + "1.0", + "1.1", + "1.2", + NULL + }; + int y; // zero set all our globals @@ -687,7 +750,7 @@ void GraphicsOptions_MenuInit( void ) s_graphicsoptions.network.style = UI_RIGHT; s_graphicsoptions.network.color = color_red; - y = 254 - 5 * (BIGCHAR_HEIGHT + 2); + y = 254 - 6 * (BIGCHAR_HEIGHT + 2); // references "vr_refreshrate" s_graphicsoptions.refreshrate.generic.type = MTYPE_SPINCONTROL; @@ -701,6 +764,18 @@ void GraphicsOptions_MenuInit( void ) s_graphicsoptions.refreshrate.numitems = NUM_REFRESHRATE; y += BIGCHAR_HEIGHT+2; + // references "vr_superSampling" + s_graphicsoptions.supersampling.generic.type = MTYPE_SPINCONTROL; + s_graphicsoptions.supersampling.generic.name = "Supersampling:"; + s_graphicsoptions.supersampling.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; + s_graphicsoptions.supersampling.generic.x = 400; + s_graphicsoptions.supersampling.generic.y = y; + s_graphicsoptions.supersampling.itemnames = s_supersampling; + s_graphicsoptions.supersampling.generic.callback = GraphicsOptions_Event; + s_graphicsoptions.supersampling.generic.id = ID_SUPERSAMPLING; + s_graphicsoptions.supersampling.numitems = NUM_SUPERSAMPLING; + y += BIGCHAR_HEIGHT+2; + // references "r_gamma" s_graphicsoptions.gamma.generic.type = MTYPE_SLIDER; s_graphicsoptions.gamma.generic.name = "Brightness:"; @@ -828,6 +903,7 @@ void GraphicsOptions_MenuInit( void ) Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.network ); Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.refreshrate ); + Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.supersampling ); Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.railgun ); Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.gamma ); Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.lighting ); diff --git a/android/app/src/main/cpp/code/vr/vr_base.c b/android/app/src/main/cpp/code/vr/vr_base.c index 4fb606dd..0f15fd67 100644 --- a/android/app/src/main/cpp/code/vr/vr_base.c +++ b/android/app/src/main/cpp/code/vr/vr_base.c @@ -35,6 +35,7 @@ cvar_t *vr_weaponPitch = NULL; cvar_t *vr_twoHandedWeapons = NULL; cvar_t *vr_showItemInHand = NULL; cvar_t *vr_refreshrate = NULL; +cvar_t *vr_superSampling = NULL; cvar_t *vr_weaponScope = NULL; cvar_t *vr_rollWhenHit = NULL; cvar_t *vr_hudYOffset = NULL; @@ -154,6 +155,7 @@ void VR_InitCvars( void ) vr_twoHandedWeapons = Cvar_Get ("vr_twoHandedWeapons", "1", CVAR_ARCHIVE); vr_showItemInHand = Cvar_Get ("vr_showItemInHand", "1", CVAR_ARCHIVE); vr_refreshrate = Cvar_Get ("vr_refreshrate", "72", CVAR_ARCHIVE); + vr_superSampling = Cvar_Get ("vr_superSampling", "1.1", CVAR_ARCHIVE); vr_weaponScope = Cvar_Get ("vr_weaponScope", "1", CVAR_ARCHIVE); vr_rollWhenHit = Cvar_Get ("vr_rollWhenHit", "0", CVAR_ARCHIVE); vr_hudYOffset = Cvar_Get ("vr_hudYOffset", "0", CVAR_ARCHIVE); diff --git a/android/app/src/main/cpp/code/vr/vr_clientinfo.h b/android/app/src/main/cpp/code/vr/vr_clientinfo.h index 620293cc..19cb2514 100644 --- a/android/app/src/main/cpp/code/vr/vr_clientinfo.h +++ b/android/app/src/main/cpp/code/vr/vr_clientinfo.h @@ -65,6 +65,7 @@ typedef struct { qboolean menuLeftHanded; float recenterYaw; + float superSampling; } vr_clientinfo_t; #endif //vr_clientinfo_h \ No newline at end of file diff --git a/android/app/src/main/cpp/code/vr/vr_renderer.c b/android/app/src/main/cpp/code/vr/vr_renderer.c index 0b0a58a9..d90d1b1c 100644 --- a/android/app/src/main/cpp/code/vr/vr_renderer.c +++ b/android/app/src/main/cpp/code/vr/vr_renderer.c @@ -19,11 +19,14 @@ #include #endif +#define DEFAULT_SUPER_SAMPLING 1.1f + extern vr_clientinfo_t vr; extern cvar_t *vr_heightAdjust; XrView* projections; GLboolean stageSupported = GL_FALSE; +qboolean fullscreenMode = qfalse; void VR_UpdateStageBounds(ovrApp* pappState) { XrExtent2Df stageBounds = {}; @@ -77,7 +80,22 @@ void VR_GetResolution(engine_t* engine, int *pWidth, int *pHeight) { static int width = 0; static int height = 0; - + float superSampling = 0.0f; + + float configuredSuperSampling = Cvar_VariableValue("vr_superSampling"); + if (vr.superSampling == 0.0f || configuredSuperSampling != vr.superSampling) { + vr.superSampling = configuredSuperSampling; + if (vr.superSampling != 0.0f) { + Cbuf_AddText( "vid_restart\n" ); + } + } + + if (vr.superSampling == 0.0f) { + superSampling = DEFAULT_SUPER_SAMPLING; + } else { + superSampling = vr.superSampling; + } + if (engine) { // Enumerate the viewport configurations. @@ -151,8 +169,8 @@ void VR_GetResolution(engine_t* engine, int *pWidth, int *pHeight) free(viewportConfigurationTypes); - *pWidth = width = engine->appState.ViewConfigurationView[0].recommendedImageRectWidth; - *pHeight = height = engine->appState.ViewConfigurationView[0].recommendedImageRectHeight; + *pWidth = width = engine->appState.ViewConfigurationView[0].recommendedImageRectWidth * superSampling; + *pHeight = height = engine->appState.ViewConfigurationView[0].recommendedImageRectHeight * superSampling; } else { @@ -294,8 +312,8 @@ void VR_InitRenderer( engine_t* engine ) { ovrRenderer_Create( engine->appState.Session, &engine->appState.Renderer, - engine->appState.ViewConfigurationView[0].recommendedImageRectWidth, - engine->appState.ViewConfigurationView[0].recommendedImageRectHeight); + eyeW, + eyeH); } void VR_DestroyRenderer( engine_t* engine ) @@ -460,6 +478,11 @@ void VR_DrawFrame( engine_t* engine ) { if (!VR_useScreenLayer() && !(cl.snap.ps.pm_flags & PMF_FOLLOW && vr.follow_mode == VRFM_FIRSTPERSON)) { vr.menuYaw = vr.hmdorientation[YAW]; + if (fullscreenMode) { + VR_ReInitRenderer(); + fullscreenMode = qfalse; + } + for (int eye = 0; eye < ovrMaxNumEyes; eye++) { ovrFramebuffer* frameBuffer = &engine->appState.Renderer.FrameBuffer; @@ -488,6 +511,8 @@ void VR_DrawFrame( engine_t* engine ) { engine->appState.Layers[engine->appState.LayerCount++].Projection = projection_layer; } else { + fullscreenMode = qtrue; + // Build the cylinder layer int width = engine->appState.Renderer.FrameBuffer.ColorSwapChain.Width; int height = engine->appState.Renderer.FrameBuffer.ColorSwapChain.Height; diff --git a/android/app/src/main/pakQ3Q/ui/ingame_system.menu b/android/app/src/main/pakQ3Q/ui/ingame_system.menu index 3456949b..05750b18 100644 --- a/android/app/src/main/pakQ3Q/ui/ingame_system.menu +++ b/android/app/src/main/pakQ3Q/ui/ingame_system.menu @@ -184,7 +184,7 @@ itemDef { type ITEM_TYPE_MULTI text "Refresh Rate:" cvar "vr_refreshrate" - cvarFloatList { "60" 60 "72 (Recommended)" 72 "80" 80 "90" 90 } + cvarFloatList { "60" 60 "72" 72 "80" 80 "90" 90 "120" 120 } rect 0 50 306 20 textalign ITEM_ALIGN_RIGHT textalignx 133 @@ -194,13 +194,29 @@ itemDef { visible 0 } + itemDef { + name graphics + group grpSystem + type ITEM_TYPE_MULTI + text "Supersampling:" + cvar "vr_superSampling" + cvarFloatList { "0.8" 0.8 "0.9" 0.9 "1.0" 1.0 "1.1" 1.1 "1.2" 1.2 } + rect 0 70 256 20 + textalign ITEM_ALIGN_RIGHT + textalignx 133 + textaligny 17 + textscale .25 + forecolor 1 1 1 1 + visible 0 + } + itemDef { name graphics group grpSystem type ITEM_TYPE_SLIDER text "Brightness:" cvarfloat "r_gamma" 0.05 0.6 1.0 - rect 0 70 256 20 + rect 0 90 256 20 textalign ITEM_ALIGN_RIGHT textalignx 133 textaligny 17 @@ -216,7 +232,7 @@ itemDef { text "Railgun Effect:" cvar "cg_oldRail" cvarFloatList { "Q2 Style" 0 "Q3 Style" 1 } - rect 0 90 256 20 + rect 0 110 256 20 textalign ITEM_ALIGN_RIGHT textalignx 133 textaligny 17 @@ -232,7 +248,7 @@ itemDef { text "Lighting:" cvar "r_vertexlight" cvarFloatList { "Lightmap (High)" 0 "Vertex (Low)" 1 } - rect 0 110 256 20 + rect 0 130 256 20 textalign ITEM_ALIGN_RIGHT textalignx 133 textaligny 17 @@ -249,7 +265,7 @@ itemDef { text "Opponent Shadows:" cvar "cg_shadows" cvarFloatList { "None" 0 "Low" 1 "High" 3 } - rect 0 130 306 20 + rect 0 150 306 20 textalign ITEM_ALIGN_RIGHT textalignx 133 textaligny 17 @@ -265,7 +281,7 @@ itemDef { text "Player Shadow:" cvar "cg_playerShadow" cvarFloatList { "None" 0 "Low" 1 "High" 3 } - rect 0 150 306 20 + rect 0 170 306 20 textalign ITEM_ALIGN_RIGHT textalignx 133 textaligny 17 @@ -281,7 +297,7 @@ itemDef { text "Geometric Detail:" cvar "r_lodbias" cvarFloatList { "High" -1 "Medium" 1 "Low" 2 } - rect 0 170 256 20 + rect 0 190 256 20 textalign ITEM_ALIGN_RIGHT textalignx 133 textaligny 17 @@ -298,7 +314,7 @@ itemDef { text "Texture Detail:" cvar "r_picmip" cvarFloatList { "Low" 2 "Normal" 1 "High" 0 } - rect 0 190 256 20 + rect 0 210 256 20 textalign ITEM_ALIGN_RIGHT textalignx 133 textaligny 17 @@ -314,7 +330,7 @@ itemDef { type ITEM_TYPE_YESNO text "Compress Textures:" cvar "r_ext_compressed_textures" - rect 0 210 256 20 + rect 0 230 256 20 textalign ITEM_ALIGN_RIGHT textalignx 133 textaligny 17 @@ -330,7 +346,7 @@ itemDef { type ITEM_TYPE_YESNO text "Low Quality Sky:" cvar "r_fastsky" - rect 0 230 256 20 + rect 0 250 256 20 textalign ITEM_ALIGN_RIGHT textalignx 133 textaligny 17 diff --git a/android/app/src/main/pakQ3Q/ui/system.menu b/android/app/src/main/pakQ3Q/ui/system.menu index 644d7c43..c27c0935 100755 --- a/android/app/src/main/pakQ3Q/ui/system.menu +++ b/android/app/src/main/pakQ3Q/ui/system.menu @@ -87,7 +87,7 @@ itemDef { type ITEM_TYPE_MULTI text "Refresh Rate:" cvar "vr_refreshrate" - cvarFloatList { "60" 60 "72 (Recommended)" 72 "80" 80 "90" 90 } + cvarFloatList { "60" 60 "72" 72 "80" 80 "90" 90 "120" 120 } rect 99 42 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 @@ -97,13 +97,29 @@ itemDef { visible 0 } + itemDef { + name graphics + group grpSystem + type ITEM_TYPE_MULTI + text "Supersampling:" + cvar "vr_superSampling" + cvarFloatList { "0.8" 0.8 "0.9" 0.9 "1.0" 1.0 "1.1" 1.1 "1.2" 1.2 } + rect 99 67 256 20 + textalign ITEM_ALIGN_RIGHT + textalignx 128 + textaligny 20 + textscale .333 + forecolor 1 1 1 1 + visible 0 + } + itemDef { name graphics group grpSystem type ITEM_TYPE_SLIDER text "Brightness:" cvarfloat "r_gamma" 0.05 0.6 1.0 - rect 99 67 256 20 + rect 99 92 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 textaligny 20 @@ -119,7 +135,7 @@ itemDef { text "Railgun Effect:" cvar "cg_oldRail" cvarFloatList { "Q2 Style" 0 "Q3 Style" 1 } - rect 99 92 256 20 + rect 99 117 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 textaligny 20 @@ -135,7 +151,7 @@ itemDef { text "Lighting:" cvar "r_vertexlight" cvarFloatList { "Lightmap (High)" 0 "Vertex (Low)" 1 } - rect 99 117 256 20 + rect 99 142 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 textaligny 20 @@ -152,7 +168,7 @@ itemDef { text "Opponent Shadows:" cvar "cg_shadows" cvarFloatList { "None" 0 "Low" 1 "High" 3 } - rect 99 142 256 20 + rect 99 167 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 textaligny 20 @@ -168,7 +184,7 @@ itemDef { text "Player Shadow:" cvar "cg_playerShadow" cvarFloatList { "None" 0 "Low" 1 "High" 3 } - rect 99 167 256 20 + rect 99 192 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 textaligny 20 @@ -184,7 +200,7 @@ itemDef { text "Geometric Detail:" cvar "r_lodbias" cvarFloatList { "High" -1 "Medium" 1 "Low" 2 } - rect 99 192 256 20 + rect 99 217 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 textaligny 20 @@ -201,7 +217,7 @@ itemDef { text "Texture Detail:" cvar "r_picmip" cvarFloatList { "Low" 2 "Normal" 1 "High" 0 } - rect 99 217 256 20 + rect 99 242 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 textaligny 20 @@ -217,7 +233,7 @@ itemDef { type ITEM_TYPE_YESNO text "Compress Textures:" cvar "r_ext_compressed_textures" - rect 99 242 256 20 + rect 99 267 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 textaligny 20 @@ -233,7 +249,7 @@ itemDef { type ITEM_TYPE_YESNO text "Low Quality Sky:" cvar "r_fastsky" - rect 99 267 256 20 + rect 99 292 256 20 textalign ITEM_ALIGN_RIGHT textalignx 128 textaligny 20