draft: upgrade codebase to qt6 and cmake (#657)
* update qt6 upgrade progress * add flawed addition for QRenderTarget and link needed libs * update to better logging format * move many assets and qml files into qrc * get rid of deprecation messages * remove additional deprecation notices * make Qt6 finally render on desktop with some progress on vr * initialize QRhi with QQuickRenderControl * use default values to stop SegFaults * fix compilation on windows * add windows files for aiding in running exe * fix formatting of testing qt.conf * first attempt on using textures instead of files in AudioTabController * Fix public/private access issue * use getter instead of directly accessing class members * use QImage as a base to set overlay textures * use native logging * add more QImage Overlays * implement faulty vulkan implementation --------- Co-authored-by: ykeara <ykeara1@gmail.com>
This commit is contained in:
+62
-51
@@ -11,6 +11,7 @@
|
||||
#include <QtWidgets/QGraphicsSceneMouseEvent>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QGraphicsEllipseItem>
|
||||
#include <QQuickGraphicsConfiguration>
|
||||
#include <QOpenGLExtraFunctions>
|
||||
#include <QCursor>
|
||||
#include <QProcess>
|
||||
@@ -20,6 +21,7 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <openvr.h>
|
||||
#include "openvr/ovr_overlay_wrapper.h"
|
||||
#include "utils/Matrix.h"
|
||||
#include "keyboard_input/input_sender.h"
|
||||
#include "settings/settings.h"
|
||||
@@ -387,18 +389,10 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
||||
vr::VROverlayFlags_SendVRSmoothScrollEvents,
|
||||
true );
|
||||
|
||||
constexpr auto thumbiconFilename = "res/img/icons/thumbicon.png";
|
||||
const auto thumbIconPath
|
||||
= paths::binaryDirectoryFindFile( thumbiconFilename );
|
||||
if ( thumbIconPath.has_value() )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile( m_ulOverlayThumbnailHandle,
|
||||
thumbIconPath->c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Could not find thumbnail icon \""
|
||||
<< thumbiconFilename << "\"";
|
||||
QImage thumbiconImg( QString( ":/icons/thumbicon.png" ) );
|
||||
ovr_overlay_wrapper::setOverlayFromQImage(
|
||||
m_ulOverlayThumbnailHandle, thumbiconImg );
|
||||
}
|
||||
|
||||
// Too many render calls in too short time overwhelm Qt and an
|
||||
@@ -413,10 +407,25 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
||||
this,
|
||||
SLOT( renderOverlay() ) );
|
||||
|
||||
#if QT_CONFIG( vulkan )
|
||||
if ( m_window.graphicsApi() == QSGRendererInterface::Vulkan )
|
||||
{
|
||||
m_vulkanInstance.reset( new QVulkanInstance );
|
||||
m_vulkanInstance->setExtensions(
|
||||
QQuickGraphicsConfiguration::preferredInstanceExtensions() );
|
||||
if ( !m_vulkanInstance->create() )
|
||||
throw std::runtime_error( "Cannot create vulkan instance" );
|
||||
|
||||
m_window.setVulkanInstance( m_vulkanInstance.get() );
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( !m_renderControl.initialize() )
|
||||
throw std::runtime_error( "could not initialize m_renderControl" );
|
||||
|
||||
QRhi* rhi = m_renderControl.rhi();
|
||||
QRhi* rhi = this->rhi();
|
||||
|
||||
qInfo() << "Started with" << rhi->backendName();
|
||||
|
||||
m_pFBTexture.reset( rhi->newTexture(
|
||||
QRhiTexture::RGBA8,
|
||||
@@ -444,7 +453,6 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
||||
0,
|
||||
static_cast<int>( quickItem->width() ),
|
||||
static_cast<int>( quickItem->height() ) );
|
||||
m_renderControl.initialize();
|
||||
|
||||
vr::HmdVector2_t vecWindowSize
|
||||
= { static_cast<float>( quickItem->width() ),
|
||||
@@ -511,40 +519,49 @@ void OverlayController::OnRenderRequest()
|
||||
}
|
||||
}
|
||||
|
||||
vr::ETextureType OverlayController::vrTextureTypeFromRhiBackend()
|
||||
void OverlayController::SetOverlayFromQRhiTexture( QRhiTexture& tex )
|
||||
{
|
||||
if ( !m_cached_vr_texture_type.has_value() )
|
||||
vr::Texture_t vrTex = {};
|
||||
QRhi* rhi = this->rhi();
|
||||
|
||||
switch ( rhi->backend() )
|
||||
{
|
||||
QRhi* rhi = m_renderControl.rhi();
|
||||
switch ( rhi->backend() )
|
||||
{
|
||||
case QRhi::Vulkan:
|
||||
m_cached_vr_texture_type = vr::TextureType_Vulkan;
|
||||
break;
|
||||
case QRhi::D3D12:
|
||||
m_cached_vr_texture_type = vr::TextureType_DirectX12;
|
||||
break;
|
||||
case QRhi::D3D11:
|
||||
m_cached_vr_texture_type = vr::TextureType_DirectX;
|
||||
break;
|
||||
case QRhi::OpenGLES2:
|
||||
m_cached_vr_texture_type = vr::TextureType_OpenGL;
|
||||
break;
|
||||
case QRhi::Metal:
|
||||
m_cached_vr_texture_type = vr::TextureType_Metal;
|
||||
break;
|
||||
default:
|
||||
qFatal() << "unknown RHI backend encountered:" << rhi->backend();
|
||||
throw std::runtime_error( "unsupported RHI backend encountered" );
|
||||
}
|
||||
case QRhi::OpenGLES2:
|
||||
{
|
||||
vrTex.handle = reinterpret_cast<void*>( tex.nativeTexture().object );
|
||||
vrTex.eType = vr::TextureType_OpenGL;
|
||||
vrTex.eColorSpace = vr::ColorSpace_Auto;
|
||||
}
|
||||
return m_cached_vr_texture_type.value();
|
||||
}
|
||||
vr::Texture_t OverlayController::vrTextureFromRhiTexture( QRhiTexture& tex )
|
||||
{
|
||||
return { reinterpret_cast<void*>( tex.nativeTexture().object ),
|
||||
vrTextureTypeFromRhiBackend(),
|
||||
vr::ColorSpace_Auto };
|
||||
break;
|
||||
#if QT_CONFIG( vulkan )
|
||||
case QRhi::Vulkan:
|
||||
{
|
||||
const QRhiVulkanNativeHandles* vulkan_handles
|
||||
= reinterpret_cast<const QRhiVulkanNativeHandles*>(
|
||||
rhi->nativeHandles() );
|
||||
vr::VRVulkanTextureData_t vulkan = {
|
||||
.m_nImage = tex.nativeTexture().object,
|
||||
.m_pDevice = vulkan_handles->dev,
|
||||
.m_pPhysicalDevice = vulkan_handles->physDev,
|
||||
.m_pInstance = vulkan_handles->inst->vkInstance(),
|
||||
.m_pQueue = vulkan_handles->gfxQueue,
|
||||
.m_nQueueFamilyIndex = vulkan_handles->gfxQueueIdx,
|
||||
.m_nWidth = static_cast<uint32_t>( tex.pixelSize().width() ),
|
||||
.m_nHeight = static_cast<uint32_t>( tex.pixelSize().height() ),
|
||||
.m_nFormat = tex.format(),
|
||||
.m_nSampleCount = static_cast<uint32_t>( tex.sampleCount() ),
|
||||
};
|
||||
vrTex.handle = &vulkan;
|
||||
vrTex.eType = vr::TextureType_Vulkan;
|
||||
vrTex.eColorSpace = vr::ColorSpace_Auto;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
qFatal() << "unimplemented backend:" << rhi->backend();
|
||||
throw std::runtime_error( "unimplemented backend" );
|
||||
}
|
||||
vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &vrTex );
|
||||
}
|
||||
|
||||
void OverlayController::renderOverlay()
|
||||
@@ -563,13 +580,7 @@ void OverlayController::renderOverlay()
|
||||
m_renderControl.render();
|
||||
m_renderControl.endFrame();
|
||||
|
||||
auto tex = vrTextureFromRhiTexture( *m_pFBTexture );
|
||||
vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &tex );
|
||||
|
||||
/*
|
||||
m_openGLContext.functions()->glFlush(); // We need to flush otherwise
|
||||
// the texture may be empty.
|
||||
*/
|
||||
SetOverlayFromQRhiTexture( *m_pFBTexture );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user