1
0
forked from Rowland/EG

vr高帧率版本修复

This commit is contained in:
Rowland 2025-09-28 10:54:19 +08:00
parent 1c356ed6dc
commit fa8353c86b
2 changed files with 63 additions and 6 deletions

View File

@ -137,9 +137,9 @@ class VRManager(DirectObject):
self.left_eye_last_render_frame = -1
self.right_eye_last_render_frame = -1
# 高级性能监控
self.performance_monitoring = True # 是否启用性能监控
self.debug_output_enabled = True # 是否启用调试输出
# 高级性能监控(默认关闭,手动开启)
self.performance_monitoring = False # 是否启用性能监控
self.debug_output_enabled = False # 是否启用调试输出
self.debug_mode = 'detailed' # 'brief' 或 'detailed'
self.cpu_usage = 0.0
self.memory_usage = 0.0
@ -171,7 +171,7 @@ class VRManager(DirectObject):
self.pipeline_history_size = 30
# GPU渲染时间监控OpenVR Frame Timing
self.enable_gpu_timing = True # 是否启用GPU时间监控
self.enable_gpu_timing = False # 是否启用GPU时间监控默认关闭
self.gpu_scene_render_ms = 0.0 # GPU场景渲染时间
self.gpu_pre_submit_ms = 0.0 # 提交前GPU时间
self.gpu_post_submit_ms = 0.0 # 提交后GPU时间
@ -2918,6 +2918,16 @@ class VRManager(DirectObject):
self.performance_monitoring = False
print("✓ VR性能监控已禁用")
def enable_gpu_timing_monitoring(self):
"""启用GPU时间监控"""
self.enable_gpu_timing = True
print("✓ VR GPU时间监控已启用")
def disable_gpu_timing_monitoring(self):
"""禁用GPU时间监控"""
self.enable_gpu_timing = False
print("✓ VR GPU时间监控已禁用")
def set_performance_check_interval(self, interval):
"""设置性能检查间隔

View File

@ -451,7 +451,7 @@ class MainWindow(QMainWindow):
self.vrDebugMenu = self.vrMenu.addMenu('VR调试')
self.vrDebugToggleAction = self.vrDebugMenu.addAction('启用调试输出')
self.vrDebugToggleAction.setCheckable(True)
self.vrDebugToggleAction.setChecked(True) # 默认启用
self.vrDebugToggleAction.setChecked(False) # 默认关闭(节省资源)
self.vrShowPerformanceAction = self.vrDebugMenu.addAction('立即显示性能报告')
@ -473,10 +473,19 @@ class MainWindow(QMainWindow):
self.vrDebugMenu.addSeparator()
# 性能监控选项
self.vrPerformanceMonitorAction = self.vrDebugMenu.addAction('启用性能监控')
self.vrPerformanceMonitorAction.setCheckable(True)
self.vrPerformanceMonitorAction.setChecked(False) # 默认关闭(节省资源)
self.vrGpuTimingAction = self.vrDebugMenu.addAction('启用GPU时间监控')
self.vrGpuTimingAction.setCheckable(True)
self.vrGpuTimingAction.setChecked(False) # 默认关闭(节省资源)
# 管线监控选项
self.vrPipelineMonitorAction = self.vrDebugMenu.addAction('启用管线监控')
self.vrPipelineMonitorAction.setCheckable(True)
self.vrPipelineMonitorAction.setChecked(True) # 默认启用
self.vrPipelineMonitorAction.setChecked(False) # 默认关闭(节省资源)
self.vrDebugMenu.addSeparator()
@ -999,6 +1008,8 @@ class MainWindow(QMainWindow):
self.vrShowPerformanceAction.triggered.connect(self.onShowVRPerformance)
self.vrDebugBriefAction.triggered.connect(lambda: self.onSetVRDebugMode('brief'))
self.vrDebugDetailedAction.triggered.connect(lambda: self.onSetVRDebugMode('detailed'))
self.vrPerformanceMonitorAction.triggered.connect(self.onToggleVRPerformanceMonitor)
self.vrGpuTimingAction.triggered.connect(self.onToggleVRGpuTiming)
self.vrPipelineMonitorAction.triggered.connect(self.onToggleVRPipelineMonitor)
self.vrPoseRenderCallbackAction.triggered.connect(lambda: self.onSetVRPoseStrategy('render_callback'))
self.vrPoseUpdateTaskAction.triggered.connect(lambda: self.onSetVRPoseStrategy('update_task'))
@ -2341,6 +2352,42 @@ class MainWindow(QMainWindow):
except Exception as e:
QMessageBox.critical(self, "错误", f"设置VR调试模式时发生错误\n{str(e)}")
def onToggleVRPerformanceMonitor(self):
"""切换VR性能监控"""
try:
if hasattr(self.world, 'vr_manager') and self.world.vr_manager:
enabled = self.vrPerformanceMonitorAction.isChecked()
if enabled:
self.world.vr_manager.enable_performance_monitoring()
else:
self.world.vr_manager.disable_performance_monitoring()
status = "启用" if enabled else "禁用"
QMessageBox.information(self, "VR性能监控", f"VR性能监控已{status}")
else:
QMessageBox.warning(self, "错误", "VR管理器不可用")
self.vrPerformanceMonitorAction.setChecked(False)
except Exception as e:
QMessageBox.critical(self, "错误", f"切换VR性能监控时发生错误\n{str(e)}")
def onToggleVRGpuTiming(self):
"""切换VR GPU时间监控"""
try:
if hasattr(self.world, 'vr_manager') and self.world.vr_manager:
enabled = self.vrGpuTimingAction.isChecked()
if enabled:
self.world.vr_manager.enable_gpu_timing_monitoring()
else:
self.world.vr_manager.disable_gpu_timing_monitoring()
status = "启用" if enabled else "禁用"
QMessageBox.information(self, "VR GPU监控", f"VR GPU时间监控已{status}")
else:
QMessageBox.warning(self, "错误", "VR管理器不可用")
self.vrGpuTimingAction.setChecked(False)
except Exception as e:
QMessageBox.critical(self, "错误", f"切换VR GPU时间监控时发生错误\n{str(e)}")
def onToggleVRPipelineMonitor(self):
"""切换VR管线监控"""
try: