From 872ab3900df9c3e39909c9fd26a02930698a73f8 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 7 Jan 2018 01:25:30 -0800 Subject: [PATCH] Linux build fixes --- lib/x11/ApplicationUnix.cpp | 6 ++++-- lib/x11/ApplicationWayland.hpp | 4 +++- lib/x11/ApplicationXlib.hpp | 14 ++++++++++---- lib/x11/WindowXlib.cpp | 27 ++++++++++++++------------- test/main.cpp | 2 +- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/lib/x11/ApplicationUnix.cpp b/lib/x11/ApplicationUnix.cpp index 25152e5..9b58735 100644 --- a/lib/x11/ApplicationUnix.cpp +++ b/lib/x11/ApplicationUnix.cpp @@ -58,6 +58,8 @@ int ApplicationRun(IApplication::EPlatformType platform, std::string_view friendlyName, std::string_view pname, const std::vector& args, + uint32_t samples, + uint32_t anisotropy, bool singleInstance) { std::string thrName = std::string(friendlyName) + " Main Thread"; @@ -65,10 +67,10 @@ int ApplicationRun(IApplication::EPlatformType platform, if (APP) return 1; if (platform == IApplication::EPlatformType::Wayland) - APP = new ApplicationWayland(cb, uniqueName, friendlyName, pname, args, singleInstance); + APP = new ApplicationWayland(cb, uniqueName, friendlyName, pname, args, samples, anisotropy, singleInstance); else if (platform == IApplication::EPlatformType::Xlib || platform == IApplication::EPlatformType::Auto) - APP = new ApplicationXlib(cb, uniqueName, friendlyName, pname, args, singleInstance); + APP = new ApplicationXlib(cb, uniqueName, friendlyName, pname, args, samples, anisotropy, singleInstance); else return 1; return APP->run(); diff --git a/lib/x11/ApplicationWayland.hpp b/lib/x11/ApplicationWayland.hpp index 6d44b4b..281d607 100644 --- a/lib/x11/ApplicationWayland.hpp +++ b/lib/x11/ApplicationWayland.hpp @@ -32,6 +32,8 @@ public: std::string_view friendlyName, std::string_view pname, const std::vector& args, + uint32_t samples, + uint32_t anisotropy, bool singleInstance) : m_callback(callback), m_uniqueName(uniqueName), @@ -71,7 +73,7 @@ public: return m_args; } - std::shared_ptr newWindow(std::string_view title, uint32_t drawSamples) + std::shared_ptr newWindow(std::string_view title) { return _WindowWaylandNew(title); } diff --git a/lib/x11/ApplicationXlib.hpp b/lib/x11/ApplicationXlib.hpp index 688938c..b5d95e2 100644 --- a/lib/x11/ApplicationXlib.hpp +++ b/lib/x11/ApplicationXlib.hpp @@ -3,6 +3,7 @@ #endif #include "boo/IApplication.hpp" +#include "boo/graphicsdev/GL.hpp" #include #include @@ -117,7 +118,7 @@ static Window GetWindowOfEvent(XEvent* event, bool& windowEvent) std::shared_ptr _WindowXlibNew(std::string_view title, Display* display, void* xcbConn, int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset, - GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples); + GLXContext lastCtx, void* vulkanHandle, GLContext* glCtx); static XIMStyle ChooseBetterStyle(XIMStyle style1, XIMStyle style2) { @@ -162,6 +163,7 @@ class ApplicationXlib final : public IApplication const std::string m_friendlyName; const std::string m_pname; const std::vector m_args; + GLContext m_glContext; /* DBus single-instance */ bool m_singleInstance; @@ -223,6 +225,8 @@ public: std::string_view friendlyName, std::string_view pname, const std::vector& args, + uint32_t samples, + uint32_t anisotropy, bool singleInstance) : m_callback(callback), m_uniqueName(uniqueName), @@ -231,6 +235,8 @@ public: m_args(args), m_singleInstance(singleInstance) { + m_glContext.m_sampleCount = samples; + m_glContext.m_anisotropy = anisotropy; #if BOO_HAS_VULKAN /* Check for Vulkan presence and preference */ bool tryVulkan = true; @@ -527,14 +533,14 @@ public: return m_args; } - std::shared_ptr newWindow(std::string_view title, uint32_t drawSamples) + std::shared_ptr newWindow(std::string_view title) { #if BOO_HAS_VULKAN std::shared_ptr newWindow = _WindowXlibNew(title, m_xDisp, m_xcbConn, m_xDefaultScreen, m_xIM, - m_bestStyle, m_fontset, m_lastGlxCtx, (void*)m_getVkProc, drawSamples); + m_bestStyle, m_fontset, m_lastGlxCtx, (void*)m_getVkProc, &m_glContext); #else std::shared_ptr newWindow = _WindowXlibNew(title, m_xDisp, nullptr, m_xDefaultScreen, m_xIM, - m_bestStyle, m_fontset, m_lastGlxCtx, nullptr, drawSamples); + m_bestStyle, m_fontset, m_lastGlxCtx, nullptr, &m_glCtx); #endif m_windows[(Window)newWindow->getPlatformHandle()] = newWindow; return newWindow; diff --git a/lib/x11/WindowXlib.cpp b/lib/x11/WindowXlib.cpp index bb087de..06830f6 100644 --- a/lib/x11/WindowXlib.cpp +++ b/lib/x11/WindowXlib.cpp @@ -295,16 +295,17 @@ struct GraphicsContextXlib : IGraphicsContext EPixelFormat m_pf; uint32_t m_drawSamples; IWindow* m_parentWindow; + GLContext* m_glCtx; Display* m_xDisp; std::mutex m_vsyncmt; std::condition_variable m_vsynccv; - GraphicsContextXlib(EGraphicsAPI api, EPixelFormat pf, IWindow* parentWindow, Display* disp, uint32_t drawSamples) + GraphicsContextXlib(EGraphicsAPI api, EPixelFormat pf, IWindow* parentWindow, Display* disp, GLContext* glCtx) : m_api(api), m_pf(pf), - m_drawSamples(drawSamples), m_parentWindow(parentWindow), + m_glCtx(glCtx), m_xDisp(disp) {} virtual void destroy()=0; virtual void resized(const SWindowRect& rect)=0; @@ -333,11 +334,11 @@ public: GraphicsContextXlibGLX(EGraphicsAPI api, IWindow* parentWindow, Display* display, int defaultScreen, - GLXContext lastCtx, uint32_t& visualIdOut, uint32_t drawSamples) - : GraphicsContextXlib(api, EPixelFormat::RGBA8, parentWindow, display, drawSamples), + GLXContext lastCtx, uint32_t& visualIdOut, GLContext* glCtx) + : GraphicsContextXlib(api, EPixelFormat::RGBA8, parentWindow, display, glCtx), m_lastCtx(lastCtx) { - m_dataFactory = _NewGLDataFactory(this, drawSamples); + m_dataFactory = _NewGLDataFactory(this, m_glCtx); /* Query framebuffer configurations */ GLXFBConfig* fbConfigs = nullptr; @@ -531,7 +532,7 @@ public: initcv.wait(outerLk); XUnlockDisplay(m_xDisp); - m_commandQueue = _NewGLCommandQueue(this); + m_commandQueue = _NewGLCommandQueue(this, m_glCtx); XLockDisplay(m_xDisp); return true; @@ -633,8 +634,8 @@ public: GraphicsContextXlibVulkan(IWindow* parentWindow, Display* display, xcb_connection_t* xcbConn, int defaultScreen, - VulkanContext* ctx, uint32_t& visualIdOut, uint32_t drawSamples) - : GraphicsContextXlib(EGraphicsAPI::Vulkan, EPixelFormat::RGBA8, parentWindow, display, drawSamples), + VulkanContext* ctx, uint32_t& visualIdOut, GLContext* glCtx) + : GraphicsContextXlib(EGraphicsAPI::Vulkan, EPixelFormat::RGBA8, parentWindow, display, glCtx), m_xcbConn(xcbConn), m_ctx(ctx) { Screen* screen = ScreenOfDisplay(display, defaultScreen); @@ -935,7 +936,7 @@ public: WindowXlib(std::string_view title, Display* display, void* xcbConn, int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset, - GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples) + GLXContext lastCtx, void* vulkanHandle, GLContext* glCtx) : m_xDisp(display), m_callback(nullptr), m_bestStyle(bestInputStyle) { @@ -948,14 +949,14 @@ public: if (vulkanHandle && i == 1) { m_gfxCtx.reset(new GraphicsContextXlibVulkan(this, display, (xcb_connection_t*)xcbConn, defaultScreen, - &g_VulkanContext, m_visualId, drawSamples)); + &g_VulkanContext, m_visualId, glCtx)); } else #endif { i = 0; m_gfxCtx.reset(new GraphicsContextXlibGLX(IGraphicsContext::EGraphicsAPI::OpenGL3_3, - this, display, defaultScreen, lastCtx, m_visualId, drawSamples)); + this, display, defaultScreen, lastCtx, m_visualId, glCtx)); m_openGL = true; } @@ -2010,12 +2011,12 @@ public: std::shared_ptr _WindowXlibNew(std::string_view title, Display* display, void* xcbConn, int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset, - GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples) + GLXContext lastCtx, void* vulkanHandle, GLContext* glCtx) { XLockDisplay(display); std::shared_ptr ret = std::make_shared(title, display, xcbConn, defaultScreen, xIM, bestInputStyle, fontset, lastCtx, - vulkanHandle, drawSamples); + vulkanHandle, glCtx); XUnlockDisplay(display); return ret; } diff --git a/test/main.cpp b/test/main.cpp index 3b4b90c..b24c216 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -497,7 +497,7 @@ struct TestApplicationCallback : IApplicationCallback int appMain(IApplication* app) { - mainWindow = app->newWindow(_S("YAY!"), 1); + mainWindow = app->newWindow(_S("YAY!")); mainWindow->setCallback(&windowCallback); mainWindow->showWindow(); windowCallback.m_lastRect = mainWindow->getWindowFrame();