mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-15 21:15:45 -04:00
Settings: Add option for creating a debug GPU device
This commit is contained in:
@ -192,10 +192,8 @@ void D3D11DisplayWindow::onWindowResized(int width, int height)
|
||||
Panic("Failed to recreate swap chain RTV after resize");
|
||||
}
|
||||
|
||||
bool D3D11DisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
bool D3D11DisplayWindow::createDeviceContext(QThread* worker_thread, bool debug_device)
|
||||
{
|
||||
const bool debug = false;
|
||||
|
||||
ComPtr<IDXGIFactory> dxgi_factory;
|
||||
HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
@ -217,7 +215,7 @@ bool D3D11DisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
}
|
||||
|
||||
UINT create_flags = 0;
|
||||
if (debug)
|
||||
if (debug_device)
|
||||
create_flags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
|
||||
hr = D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, create_flags, nullptr, 0, D3D11_SDK_VERSION,
|
||||
@ -259,7 +257,7 @@ bool D3D11DisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
if (debug_device)
|
||||
{
|
||||
ComPtr<ID3D11InfoQueue> info;
|
||||
hr = m_device.As(&info);
|
||||
@ -270,7 +268,7 @@ bool D3D11DisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
}
|
||||
}
|
||||
|
||||
if (!QtDisplayWindow::createDeviceContext(worker_thread))
|
||||
if (!QtDisplayWindow::createDeviceContext(worker_thread, debug_device))
|
||||
{
|
||||
m_swap_chain.Reset();
|
||||
m_context.Reset();
|
||||
@ -280,12 +278,12 @@ bool D3D11DisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool D3D11DisplayWindow::initializeDeviceContext()
|
||||
bool D3D11DisplayWindow::initializeDeviceContext(bool debug_device)
|
||||
{
|
||||
if (!createSwapChainRTV())
|
||||
return false;
|
||||
|
||||
if (!QtDisplayWindow::initializeDeviceContext())
|
||||
if (!QtDisplayWindow::initializeDeviceContext(debug_device))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -21,8 +21,8 @@ public:
|
||||
|
||||
HostDisplay* getHostDisplayInterface() override;
|
||||
|
||||
bool createDeviceContext(QThread* worker_thread) override;
|
||||
bool initializeDeviceContext() override;
|
||||
bool createDeviceContext(QThread* worker_thread, bool debug_device) override;
|
||||
bool initializeDeviceContext(bool debug_device) override;
|
||||
void destroyDeviceContext() override;
|
||||
|
||||
RenderAPI GetRenderAPI() const override;
|
||||
|
@ -234,7 +234,7 @@ static void APIENTRY GLDebugCallback(GLenum source, GLenum type, GLuint id, GLen
|
||||
}
|
||||
}
|
||||
|
||||
bool OpenGLDisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
bool OpenGLDisplayWindow::createDeviceContext(QThread* worker_thread, bool debug_device)
|
||||
{
|
||||
m_gl_context = std::make_unique<QOpenGLContext>();
|
||||
|
||||
@ -249,9 +249,8 @@ bool OpenGLDisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
surface_format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
surface_format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
|
||||
#ifdef _DEBUG
|
||||
surface_format.setOption(QSurfaceFormat::DebugContext);
|
||||
#endif
|
||||
if (debug_device)
|
||||
surface_format.setOption(QSurfaceFormat::DebugContext);
|
||||
|
||||
for (const auto [major, minor] : desktop_versions_to_try)
|
||||
{
|
||||
@ -269,9 +268,8 @@ bool OpenGLDisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
// try es
|
||||
surface_format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||
surface_format.setProfile(QSurfaceFormat::NoProfile);
|
||||
#ifdef _DEBUG
|
||||
surface_format.setOption(QSurfaceFormat::DebugContext, false);
|
||||
#endif
|
||||
if (debug_device)
|
||||
surface_format.setOption(QSurfaceFormat::DebugContext, false);
|
||||
|
||||
for (const auto [major, minor] : es_versions_to_try)
|
||||
{
|
||||
@ -300,7 +298,7 @@ bool OpenGLDisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!QtDisplayWindow::createDeviceContext(worker_thread))
|
||||
if (!QtDisplayWindow::createDeviceContext(worker_thread, debug_device))
|
||||
{
|
||||
m_gl_context->doneCurrent();
|
||||
m_gl_context.reset();
|
||||
@ -312,7 +310,7 @@ bool OpenGLDisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenGLDisplayWindow::initializeDeviceContext()
|
||||
bool OpenGLDisplayWindow::initializeDeviceContext(bool debug_device)
|
||||
{
|
||||
if (!m_gl_context->makeCurrent(this))
|
||||
return false;
|
||||
@ -330,16 +328,14 @@ bool OpenGLDisplayWindow::initializeDeviceContext()
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (GLAD_GL_KHR_debug)
|
||||
if (debug_device && GLAD_GL_KHR_debug)
|
||||
{
|
||||
glad_glDebugMessageCallbackKHR(GLDebugCallback, nullptr);
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!QtDisplayWindow::initializeDeviceContext())
|
||||
if (!QtDisplayWindow::initializeDeviceContext(debug_device))
|
||||
{
|
||||
s_thread_gl_context = nullptr;
|
||||
m_gl_context->doneCurrent();
|
||||
|
@ -20,8 +20,8 @@ public:
|
||||
|
||||
HostDisplay* getHostDisplayInterface() override;
|
||||
|
||||
bool createDeviceContext(QThread* worker_thread) override;
|
||||
bool initializeDeviceContext() override;
|
||||
bool createDeviceContext(QThread* worker_thread, bool debug_device) override;
|
||||
bool initializeDeviceContext(bool debug_device) override;
|
||||
void destroyDeviceContext() override;
|
||||
|
||||
RenderAPI GetRenderAPI() const override;
|
||||
|
@ -18,12 +18,12 @@ HostDisplay* QtDisplayWindow::getHostDisplayInterface()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool QtDisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
bool QtDisplayWindow::createDeviceContext(QThread* worker_thread, bool debug_device)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QtDisplayWindow::initializeDeviceContext()
|
||||
bool QtDisplayWindow::initializeDeviceContext(bool debug_device)
|
||||
{
|
||||
if (!createImGuiContext() || !createDeviceResources())
|
||||
return false;
|
||||
|
@ -18,8 +18,8 @@ public:
|
||||
|
||||
virtual HostDisplay* getHostDisplayInterface();
|
||||
|
||||
virtual bool createDeviceContext(QThread* worker_thread);
|
||||
virtual bool initializeDeviceContext();
|
||||
virtual bool createDeviceContext(QThread* worker_thread, bool debug_device);
|
||||
virtual bool initializeDeviceContext(bool debug_device);
|
||||
virtual void destroyDeviceContext();
|
||||
|
||||
virtual void Render();
|
||||
|
@ -150,7 +150,7 @@ void QtHostInterface::bootSystem(QString initial_filename, QString initial_save_
|
||||
Assert(!isOnWorkerThread());
|
||||
emit emulationStarting();
|
||||
|
||||
if (!m_display_window->createDeviceContext(m_worker_thread))
|
||||
if (!m_display_window->createDeviceContext(m_worker_thread, m_settings.gpu_use_debug_device))
|
||||
{
|
||||
emit emulationStopped();
|
||||
return;
|
||||
@ -420,7 +420,7 @@ QByteArray QtHostInterface::saveStateToMemory()
|
||||
|
||||
void QtHostInterface::doBootSystem(QString initial_filename, QString initial_save_state_filename)
|
||||
{
|
||||
if (!m_display_window->initializeDeviceContext())
|
||||
if (!m_display_window->initializeDeviceContext(m_settings.gpu_use_debug_device))
|
||||
{
|
||||
emit emulationStopped();
|
||||
return;
|
||||
|
Reference in New Issue
Block a user