Files
OpenVR-AdvancedSettings-frame/src/render/RenderBackend.cpp
T
Matthias JanetschekandClaude Opus 5.5 4826686a4d Render through public Qt API: OpenGL and Vulkan backends, --graphics-api
Replace the QRhi rendering in OverlayController (private Qt API) with the
render backends of the vrdashboard template (src/render/), which use public
Qt API only (QQuickRenderTarget::fromOpenGLTexture / fromVulkanImage). The
binary then runs on another Qt 6 patch release, e.g. the Steam Frame's system
Qt.

The Vulkan backend also does what SteamVR requires and the QRhi path lacked:
the required instance/device extensions and the HMD's GPU (via
openvr_init::renderInterop()), VK_FORMAT_R8G8B8A8_UNORM, and the transition to
TRANSFER_SRC_OPTIMAL after each frame.

- New option --graphics-api opengl|vulkan (default opengl, no fallback).
- Shutdown() calls VR_Shutdown before the render target and Qt's device go
  (crash on the Steam Frame with Vulkan otherwise); it runs only once.
- Mouse y is flipped on every platform: SteamVR reports it in GL convention.
- Render delay 5 -> 16 ms (about 60 fps).
- GuiPrivate is no longer needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 13:41:13 +02:00

39 lines
1.0 KiB
C++

// Adapted from the vrdashboard template (FrameAssistant commit 4a5b090),
// verified on the Steam Frame. See docs/steamframe/DESIGN.md, section 3.
#include "RenderBackend.h"
#include "OpenGLRenderBackend.h"
#if OVRAS_HAS_VULKAN
# include "VulkanRenderBackend.h"
#endif
std::unique_ptr<RenderBackend> createRenderBackend( GraphicsApi api )
{
switch ( api )
{
case GraphicsApi::OpenGL:
return std::make_unique<OpenGLRenderBackend>();
case GraphicsApi::Vulkan:
#if OVRAS_HAS_VULKAN
return std::make_unique<VulkanRenderBackend>();
#else
return nullptr; // built without Vulkan support
#endif
}
return nullptr;
}
bool parseGraphicsApi( const QString& name, GraphicsApi* api )
{
const QString lower = name.toLower();
if ( lower == QLatin1String( "opengl" ) || lower == QLatin1String( "gl" ) )
*api = GraphicsApi::OpenGL;
else if ( lower == QLatin1String( "vulkan" )
|| lower == QLatin1String( "vk" ) )
*api = GraphicsApi::Vulkan;
else
return false;
return true;
}