Skip to content

Commit

Permalink
OpenXR - HUD is enabled based on gstate
Browse files Browse the repository at this point in the history
  • Loading branch information
lvonasek committed Aug 5, 2022
1 parent 2d88a82 commit 92d3ed6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
10 changes: 0 additions & 10 deletions Common/VR/VRTweaks.cpp
Expand Up @@ -24,16 +24,6 @@ bool VR_TweakIs2D(float* projMatrix) {
return identity || oneTranslation || ortho;
}

bool VR_TweakIsHUD(bool is2D, bool isOrtho, bool isProjection) {
bool flatScreen = VR_GetConfig(VR_CONFIG_MODE) == VR_MODE_FLAT_SCREEN;
if (isProjection) {
vrIsHUD = is2D && !flatScreen;
} else if (isOrtho) {
vrIsHUD = !flatScreen;
}
return vrIsHUD;
}

void VR_TweakMirroring(float* projMatrix) {
VR_SetConfig(VR_CONFIG_MIRROR_AXIS_X, projMatrix[0] < 0);
VR_SetConfig(VR_CONFIG_MIRROR_AXIS_Y, projMatrix[5] < 0);
Expand Down
1 change: 0 additions & 1 deletion Common/VR/VRTweaks.h
Expand Up @@ -3,7 +3,6 @@
#include "VRRenderer.h"

bool VR_TweakIs2D(float* projMatrix);
bool VR_TweakIsHUD(bool is2D, bool isOrtho, bool isProjection);
void VR_TweakMirroring(float* projMatrix);
void VR_TweakProjection(float* src, float* dst, VRMatrix matrix);
void VR_TweakView(float* view, float* projMatrix, VRMatrix matrix);
12 changes: 9 additions & 3 deletions GPU/GLES/ShaderManagerGLES.cpp
Expand Up @@ -329,7 +329,13 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu
}

// Set HUD mode
if (VR_TweakIsHUD(is2D, dirty & DIRTY_PROJTHROUGHMATRIX, dirty & DIRTY_PROJMATRIX)) {
bool flatScreen = VR_GetConfig(VR_CONFIG_MODE) == VR_MODE_FLAT_SCREEN;
bool hud = is2D && !flatScreen &&
gstate.isModeThrough() && //2D content requires orthographic projection
gstate.isAlphaBlendEnabled() && //2D content has to be blended
!gstate.isLightingEnabled() && //2D content cannot be rendered with lights on
!gstate.isFogEnabled(); //2D content cannot be rendered with fog on
if (hud) {
float scale = 0.5f;
render_->SetUniformF1(&u_scaleX, scale);
render_->SetUniformF1(&u_scaleY, scale / 16.0f * 9.0f);
Expand All @@ -343,7 +349,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu
if (dirty & DIRTY_PROJMATRIX) {
Matrix4x4 flippedMatrix;
#ifdef OPENXR
if ((VR_GetConfig(VR_CONFIG_MODE) == VR_MODE_FLAT_SCREEN) || is2D) {
if (flatScreen || is2D) {
memcpy(&flippedMatrix, gstate.projMatrix, 16 * sizeof(float));
} else {
VR_TweakProjection(gstate.projMatrix, flippedMatrix.m, VR_PROJECTION_MATRIX_LEFT_EYE);
Expand Down Expand Up @@ -509,7 +515,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu
}
if (dirty & DIRTY_VIEWMATRIX) {
#ifdef OPENXR
if ((VR_GetConfig(VR_CONFIG_MODE) == VR_MODE_FLAT_SCREEN) || is2D) {
if (flatScreen || is2D) {
SetMatrix4x3(render_, &u_view, gstate.viewMatrix);
} else {
float m4x4[16];
Expand Down

0 comments on commit 92d3ed6

Please sign in to comment.