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>
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
// Adapted from the vrdashboard template (FrameAssistant commit 4a5b090),
|
|
// verified on the Steam Frame. See docs/steamframe/DESIGN.md, section 3.
|
|
|
|
#pragma once
|
|
|
|
#include <QOffscreenSurface>
|
|
#include <QOpenGLContext>
|
|
|
|
#include "RenderBackend.h"
|
|
|
|
class OpenGLRenderBackend final : public RenderBackend
|
|
{
|
|
public:
|
|
OpenGLRenderBackend() = default;
|
|
~OpenGLRenderBackend() override;
|
|
|
|
QString name() const override
|
|
{
|
|
return QStringLiteral( "OpenGL" );
|
|
}
|
|
QSGRendererInterface::GraphicsApi graphicsApi() const override
|
|
{
|
|
return QSGRendererInterface::OpenGL;
|
|
}
|
|
|
|
bool initialize( const RenderInterop& interop, QString* error ) override;
|
|
void configureWindow( QQuickWindow* window ) override;
|
|
bool attachWindow( QQuickWindow* window, QString* error ) override;
|
|
void detachWindow() override
|
|
{
|
|
releaseRenderTarget();
|
|
}
|
|
QString deviceName() const override
|
|
{
|
|
return m_deviceName;
|
|
}
|
|
|
|
bool makeCurrent() override;
|
|
void doneCurrent() override;
|
|
|
|
QQuickRenderTarget createRenderTarget( QSize size ) override;
|
|
void releaseRenderTarget() override;
|
|
void beginFrame() override {}
|
|
void finishFrame() override;
|
|
void waitForGpu() override;
|
|
|
|
vr::Texture_t vrTexture() override;
|
|
vr::VRTextureBounds_t vrTextureBounds() const override;
|
|
QImage readback() override;
|
|
|
|
private:
|
|
std::unique_ptr<QOpenGLContext> m_context;
|
|
std::unique_ptr<QOffscreenSurface> m_surface;
|
|
unsigned int m_texture = 0; // GLuint
|
|
QSize m_size;
|
|
QString m_deviceName;
|
|
};
|