Files
thejerf--baijiSteamVR/Source/Core/VideoCommon/GeometryShaderManager.h
T

95 lines
3.7 KiB
C++

// Copyright 2014 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <array>
#include <cmath>
#include <limits>
#include <string>
#include "Common/CommonTypes.h"
#include "VideoCommon/ConstantManager.h"
class PointerWrap;
enum class PrimitiveType : u32;
// The non-API dependent parts.
class GeometryShaderManager
{
public:
void Init();
void Dirty();
void DoState(PointerWrap& p);
void SetConstants(PrimitiveType prim);
void SetViewportChanged();
void SetProjectionChanged();
void SetLinePtWidthChanged();
void SetTexCoordChanged(u8 texmapid);
// VR head-pose cache: marks the cached eye projection as stale so the next
// SetConstants() call re-fetches it from OpenXR. Called from BPStructs at the
// XFB-copy boundary so a single game frame's draws all see one consistent pose.
void InvalidateVRHeadPose();
GeometryShaderConstants constants{};
bool dirty = false;
// Per-draw VR stereo mode override (set before RenderDrawCall, consumed in SetConstants).
// NaN = no override; -3.0 = force headlocked perspective HUD; -2.0 = force headlocked screen;
// -1.0 = force screen; 0.0 = force fullscreen; 1.0 = force perspective.
float vr_stereo_override = std::numeric_limits<float>::quiet_NaN();
// Per-draw element depth override from shader overrides (-1 = use global setting).
float vr_element_depth_override = -1.0f;
// Per-draw UPM override from shader overrides (-1 = use global setting).
float vr_units_per_meter_override = -1.0f;
// Per-draw headlocked projection tuning for Hydra-style HUD layers.
float vr_headlocked_projection_scale_x = 1.0f;
float vr_headlocked_projection_scale_y = 1.0f;
float vr_headlocked_projection_offset_x = 0.0f;
float vr_headlocked_projection_offset_y = 0.0f;
// Set by VertexManagerBase for the current -3 (perspective HUD) draw: true for radar/minimap
// layers that must self-centre on their own origin depth instead of the shared per-frame
// reference (see SetConstants).
bool vr_metroid_hud_self_center = false;
// Set by VertexManagerBase for stable Metroid perspective-HUD body layers. Transient combat
// reticle/menu pieces can move during free-aim and must not become the shared depth anchor.
bool vr_metroid_hud_anchor_candidate = false;
int vr_metroid_hud_reference_context = 0;
private:
void SetVSExpand(VSExpand expand);
bool m_projection_changed = false;
bool m_viewport_changed = false;
// Cached OpenXR head pose data — refreshed only at frame boundaries (XFB copy)
// while the head-pose lock is in effect (VideoConfig::VRLockHeadPosePerFrame),
// otherwise refreshed every SetConstants call.
std::array<std::array<float, 4>, 4> m_cached_eye_projection{};
std::array<std::array<float, 4>, 2> m_cached_eye_z_row{};
std::array<std::array<float, 4>, 4> m_cached_head_projection{};
float m_cached_units_per_meter = 0.0f;
bool m_vr_pose_needs_refresh = true;
// Shared reference depth for the headlocked perspective HUD (-3) path. Stable body layers choose
// the next frame's anchor; all coherent draws in a frame reuse one anchor so they share ONE
// coherent transform and keep their relative scene depth. Per-draw centring instead collapsed
// every origin to scale.z - distance and inverted it (because scale.z ~ size_ref/(-refZ)).
float m_vr_hud_shared_reference_z = 0.0f;
bool m_vr_hud_shared_reference_valid = false;
int m_vr_hud_shared_reference_context = 0;
float m_vr_hud_stable_reference_z = 0.0f;
bool m_vr_hud_stable_reference_valid = false;
int m_vr_hud_stable_reference_context = 0;
float m_vr_hud_frame_anchor_candidate_z = 0.0f;
bool m_vr_hud_frame_anchor_candidate_valid = false;
int m_vr_hud_frame_anchor_candidate_context = 0;
};