From 11f6fee8caf484ce20d9a8a3d9403eea355a3cf4 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 1 Sep 2022 16:55:12 +0600 Subject: [PATCH 1/7] qt_hardwarerenderer: Don't update the entire texture on blits --- src/qt/qt_hardwarerenderer.cpp | 4 +++- src/qt/qt_hardwarerenderer.hpp | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index 3577234ee..a7af8bb4c 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -21,6 +21,8 @@ #include "qt_hardwarerenderer.hpp" #include #include +#include + #include #include @@ -196,7 +198,7 @@ void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) { return; } m_context->makeCurrent(this); - m_texture->setData(QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)imagebufs[buf_idx].get()); + m_texture->setData(0, 0, 0, w + x, h + y, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)imagebufs[buf_idx].get(), &m_transferOptions); buf_usage[buf_idx].clear(); source.setRect(x, y, w, h); if (origSource != source) onResize(this->width(), this->height()); diff --git a/src/qt/qt_hardwarerenderer.hpp b/src/qt/qt_hardwarerenderer.hpp index b9b7895e0..6bf0d3276 100644 --- a/src/qt/qt_hardwarerenderer.hpp +++ b/src/qt/qt_hardwarerenderer.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,8 @@ private: QOpenGLTextureBlitter* m_blt{nullptr}; QOpenGLBuffer m_vbo[2]; QOpenGLVertexArrayObject m_vao; + QOpenGLPixelTransferOptions m_transferOptions; + public: enum class RenderType { OpenGL, @@ -67,6 +70,8 @@ public: parentWidget = parent; setRenderType(rtype); + m_transferOptions.setRowLength(2048); + m_context = new QOpenGLContext(); m_context->setFormat(format()); m_context->create(); From 72628669024f07289dfe7a08021e01317675877f Mon Sep 17 00:00:00 2001 From: cold-brewed Date: Thu, 1 Sep 2022 13:49:35 -0400 Subject: [PATCH 2/7] qt: Fix discord update timer to run at one second interval --- src/qt/qt_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index de2fef1bd..6f471dc53 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -293,7 +293,7 @@ int main(int argc, char* argv[]) { QObject::connect(&discordupdate, &QTimer::timeout, &app, [] { discord_run_callbacks(); }); - discordupdate.start(0); + discordupdate.start(1000); } /* Initialize the rendering window, or fullscreen. */ From d32cd981c889edf1bd349a5bda8746a79887c555 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 2 Sep 2022 00:32:04 +0600 Subject: [PATCH 3/7] qt_hardwarerenderer: Don't blit black, hidden portions of images --- src/qt/qt_hardwarerenderer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index a7af8bb4c..c7a6b0811 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -24,6 +24,7 @@ #include #include +#include #include extern "C" { @@ -198,7 +199,7 @@ void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) { return; } m_context->makeCurrent(this); - m_texture->setData(0, 0, 0, w + x, h + y, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)imagebufs[buf_idx].get(), &m_transferOptions); + m_texture->setData(x, y, 0, w, h, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)((uintptr_t)imagebufs[buf_idx].get() + (uintptr_t)(2048 * 4 * y + x * 4)), &m_transferOptions); buf_usage[buf_idx].clear(); source.setRect(x, y, w, h); if (origSource != source) onResize(this->width(), this->height()); From a84a8615c5bacdf264f6b968856f0a358380ed42 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 2 Sep 2022 13:45:48 +0600 Subject: [PATCH 4/7] qt_hardwarerenderer: Fix compilation with Qt 5.12 --- src/qt/qt_hardwarerenderer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index c7a6b0811..809777f37 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -199,7 +199,10 @@ void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) { return; } m_context->makeCurrent(this); - m_texture->setData(x, y, 0, w, h, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)((uintptr_t)imagebufs[buf_idx].get() + (uintptr_t)(2048 * 4 * y + x * 4)), &m_transferOptions); + m_texture->bind(); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 2048); + glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)((uintptr_t)imagebufs[buf_idx].get() + (uintptr_t)(2048 * 4 * y + x * 4))); + m_texture->release(); buf_usage[buf_idx].clear(); source.setRect(x, y, w, h); if (origSource != source) onResize(this->width(), this->height()); From 0cca0d98315e7fca0cb255f796ddd11af618140a Mon Sep 17 00:00:00 2001 From: GH Cao Date: Fri, 2 Sep 2022 16:53:53 +0800 Subject: [PATCH 5/7] win_joystick_rawinput: Fix wchar/char mismatch --- src/include/86box/win.h | 2 ++ src/qt/win_joystick_rawinput.c | 10 +++++----- src/win/win_joystick_rawinput.c | 10 +++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/include/86box/win.h b/src/include/86box/win.h index ccd6e0f19..4122bb684 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -23,7 +23,9 @@ #ifndef PLAT_WIN_H #define PLAT_WIN_H +#ifndef UNICODE #define UNICODE +#endif #define BITMAP WINDOWS_BITMAP #if 0 # ifdef _WIN32_WINNT diff --git a/src/qt/win_joystick_rawinput.c b/src/qt/win_joystick_rawinput.c index d1fca0491..dd95f40c9 100644 --- a/src/qt/win_joystick_rawinput.c +++ b/src/qt/win_joystick_rawinput.c @@ -205,15 +205,15 @@ void joystick_get_capabilities(raw_joystick_t* rawjoy, plat_joystick_t* joy) { void joystick_get_device_name(raw_joystick_t* rawjoy, plat_joystick_t* joy, PRID_DEVICE_INFO info) { UINT size = 0; - char *device_name = NULL; + WCHAR *device_name = NULL; WCHAR device_desc_wide[200] = {0}; - GetRawInputDeviceInfoA(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size); - device_name = calloc(size, sizeof(char)); - if (GetRawInputDeviceInfoA(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size) <= 0) + GetRawInputDeviceInfoW(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size); + device_name = calloc(size, sizeof(WCHAR)); + if (GetRawInputDeviceInfoW(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size) <= 0) fatal("joystick_get_capabilities: Failed to get device name.\n"); - HANDLE hDevObj = CreateFile(device_name, GENERIC_READ | GENERIC_WRITE, + HANDLE hDevObj = CreateFileW(device_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hDevObj) { HidD_GetProductString(hDevObj, device_desc_wide, sizeof(WCHAR) * 200); diff --git a/src/win/win_joystick_rawinput.c b/src/win/win_joystick_rawinput.c index 47441f8cf..86c4bfa87 100644 --- a/src/win/win_joystick_rawinput.c +++ b/src/win/win_joystick_rawinput.c @@ -220,15 +220,15 @@ void joystick_get_device_name(raw_joystick_t *rawjoy, plat_joystick_t *joy, PRID_DEVICE_INFO info) { UINT size = 0; - char *device_name = NULL; + WCHAR *device_name = NULL; WCHAR device_desc_wide[200] = { 0 }; - GetRawInputDeviceInfoA(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size); - device_name = calloc(size, sizeof(char)); - if (GetRawInputDeviceInfoA(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size) <= 0) + GetRawInputDeviceInfoW(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size); + device_name = calloc(size, sizeof(WCHAR)); + if (GetRawInputDeviceInfoW(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size) <= 0) fatal("joystick_get_capabilities: Failed to get device name.\n"); - HANDLE hDevObj = CreateFile(device_name, GENERIC_READ | GENERIC_WRITE, + HANDLE hDevObj = CreateFileW(device_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hDevObj) { HidD_GetProductString(hDevObj, device_desc_wide, sizeof(WCHAR) * 200); From 06cfd4dcaec8bf3a4254b7eb11d0e56998724927 Mon Sep 17 00:00:00 2001 From: GH Cao Date: Fri, 2 Sep 2022 16:54:38 +0800 Subject: [PATCH 6/7] net_slirp: Fix building with clang --- src/network/net_slirp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index 46b913416..24b75e208 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -329,9 +329,11 @@ net_slirp_thread(void *priv) break; case NET_EVENT_TX: - int packets = network_tx_popv(slirp->card, slirp->pkt_tx_v, SLIRP_PKT_BATCH); - for (int i = 0; i < packets; i++) { - net_slirp_in(slirp, slirp->pkt_tx_v[i].data, slirp->pkt_tx_v[i].len); + { + int packets = network_tx_popv(slirp->card, slirp->pkt_tx_v, SLIRP_PKT_BATCH); + for (int i = 0; i < packets; i++) { + net_slirp_in(slirp, slirp->pkt_tx_v[i].data, slirp->pkt_tx_v[i].len); + } } break; From d47bd06f25233a29a882ac95b0ce10fc5cb3db1a Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sat, 3 Sep 2022 13:13:07 +0600 Subject: [PATCH 7/7] qt_hardwarerenderer: Use setData on Qt 5.14 and later --- src/qt/qt_hardwarerenderer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index 809777f37..29b3613ea 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -199,10 +199,14 @@ void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) { return; } m_context->makeCurrent(this); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + m_texture->setData(x, y, 0, w, h, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)((uintptr_t)imagebufs[buf_idx].get() + (uintptr_t)(2048 * 4 * y + x * 4)), &m_transferOptions); +#else m_texture->bind(); glPixelStorei(GL_UNPACK_ROW_LENGTH, 2048); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)((uintptr_t)imagebufs[buf_idx].get() + (uintptr_t)(2048 * 4 * y + x * 4))); m_texture->release(); +#endif buf_usage[buf_idx].clear(); source.setRect(x, y, w, h); if (origSource != source) onResize(this->width(), this->height());