Fix initial OpenXR world shader setup
This commit is contained in:
parent
f47d1c0331
commit
56b5e8c38e
4 changed files with 39 additions and 5 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#ifdef HWRENDER
|
||||
#include "hw_glob.h"
|
||||
#include "hw_batching.h"
|
||||
#include "hw_main.h"
|
||||
#include "../i_system.h"
|
||||
#include "../qs22j.h"
|
||||
|
||||
|
|
@ -387,14 +388,14 @@ static unsigned int HWR_MarkStateChanges(DrawCallInfo *current, DrawCallInfo *ne
|
|||
|
||||
// check if a state change is required and flag it to stateChanges
|
||||
|
||||
if (current->shader != next->shader && cv_glshaders.value && gl_shadersavailable)
|
||||
if (current->shader != next->shader && HWR_UseShader())
|
||||
stateChanges |= SHADER_CHANGED;
|
||||
if (HWR_GetDrawCallTexture(current) != HWR_GetDrawCallTexture(next)
|
||||
|| HWR_GetDrawCallBrightmap(current) != HWR_GetDrawCallBrightmap(next))
|
||||
stateChanges |= TEXTURE_CHANGED;
|
||||
if (current->polyFlags != next->polyFlags)
|
||||
stateChanges |= POLYFLAGS_CHANGED;
|
||||
if (cv_glshaders.value && gl_shadersavailable)
|
||||
if (HWR_UseShader())
|
||||
{
|
||||
if (currentSI->PolyColor.rgba != nextSI->PolyColor.rgba ||
|
||||
currentSI->TintColor.rgba != nextSI->TintColor.rgba ||
|
||||
|
|
@ -418,7 +419,7 @@ static unsigned int HWR_MarkStateChanges(DrawCallInfo *current, DrawCallInfo *ne
|
|||
|
||||
static void HWR_ExecuteStateChanges(unsigned int stateChanges, DrawCallInfo *dc)
|
||||
{
|
||||
if ((stateChanges & SHADER_CHANGED) && cv_glshaders.value && gl_shadersavailable)
|
||||
if ((stateChanges & SHADER_CHANGED) && HWR_UseShader())
|
||||
{
|
||||
GL_SetShader(dc->shader);
|
||||
ps_hw_numshaders++;
|
||||
|
|
@ -477,7 +478,7 @@ void HWR_RenderBatches(void)
|
|||
|
||||
// sort the draw calls
|
||||
ps_hw_batchsorttime = I_GetPreciseTime();
|
||||
if (cv_glshaders.value && gl_shadersavailable)
|
||||
if (HWR_UseShader())
|
||||
qs22j(drawCallOrder, cst->drawCallsSize, sizeof(UINT32), compareDrawCalls);
|
||||
else
|
||||
qs22j(drawCallOrder, cst->drawCallsSize, sizeof(UINT32), compareDrawCallsNoShaders);
|
||||
|
|
|
|||
|
|
@ -122,6 +122,10 @@ static angle_t gl_aimingangle;
|
|||
// Returns true if shaders can be used.
|
||||
boolean HWR_UseShader(void)
|
||||
{
|
||||
#ifdef HAVE_VR
|
||||
if (vr_started)
|
||||
return gl_shadersavailable;
|
||||
#endif
|
||||
return (cv_glshaders.value && gl_shadersavailable);
|
||||
}
|
||||
|
||||
|
|
@ -775,7 +779,7 @@ void HWR_RenderPlayerView(void)
|
|||
ClearColor.blue = 0.0f;
|
||||
ClearColor.alpha = 1.0f;
|
||||
|
||||
if (cv_glshaders.value)
|
||||
if (HWR_UseShader())
|
||||
{
|
||||
GL_SetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime.
|
||||
|
||||
|
|
|
|||
15
src/p_user.c
15
src/p_user.c
|
|
@ -3129,6 +3129,21 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
camrotate = cv_cam_rotate[num].value;
|
||||
camdist = FixedMul(cv_cam_dist[num].value, mapobjectscale);
|
||||
camheight = FixedMul(cv_cam_height[num].value, mapobjectscale);
|
||||
#ifdef HAVE_VR
|
||||
if (vr_started)
|
||||
{
|
||||
const fixed_t vr_camdist = FixedMul(160*FRACUNIT, mapobjectscale);
|
||||
const fixed_t vr_camheight = FixedMul(50*FRACUNIT, mapobjectscale);
|
||||
|
||||
// Match kart-public-vr's chase camera defaults in VR. Blankart's
|
||||
// normal camera is higher and farther back, which makes the headset
|
||||
// view start too high and pitched down.
|
||||
if (camdist > vr_camdist)
|
||||
camdist = vr_camdist;
|
||||
if (camheight > vr_camheight)
|
||||
camheight = vr_camheight;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (leveltime > introtime)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@
|
|||
#include "../i_video.h"
|
||||
#include "../r_fps.h"
|
||||
#include "../v_video.h"
|
||||
#ifdef HWRENDER
|
||||
#include "../hardware/hw_glob.h"
|
||||
#include "../hardware/hw_main.h"
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include "../sdl/sdlmain.h"
|
||||
|
|
@ -519,6 +523,12 @@ boolean VR_Init(void)
|
|||
|
||||
vr_started = true;
|
||||
vr_enabled = true;
|
||||
#ifdef HWRENDER
|
||||
if (gl_shadersavailable) {
|
||||
CONS_Printf("VR: Recompiling hardware shaders with OpenXR view uniforms.\n");
|
||||
HWR_CompileShaders();
|
||||
}
|
||||
#endif
|
||||
CV_StealthSet(&cv_vidwait, "Off");
|
||||
CV_StealthSetValue(&cv_fpscap, -1);
|
||||
CV_StealthSet(&cv_ticrate, "Compact");
|
||||
|
|
@ -550,6 +560,10 @@ void VR_Shutdown(void)
|
|||
vr_started = false;
|
||||
vr_enabled = false;
|
||||
vr_drawing_ui = false;
|
||||
#ifdef HWRENDER
|
||||
if (gl_shadersavailable)
|
||||
HWR_CompileShaders();
|
||||
#endif
|
||||
displayRefreshRateExtensionEnabled = false;
|
||||
pfnEnumerateDisplayRefreshRatesFB = NULL;
|
||||
pfnGetDisplayRefreshRateFB = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue