From 444bbc61a8c2e370b9d0beebb16bd7d1bd45670b Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Thu, 16 Nov 2023 00:41:51 +0000 Subject: [PATCH] steamcompmgr: Handle dummy overlay plane scale for external displays Fixes that stutter on external displays. --- src/rendervulkan.cpp | 10 +++++++--- src/rendervulkan.hpp | 4 ++-- src/steamcompmgr.cpp | 10 ++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp index e3b4130de6..c1bb9efe0d 100644 --- a/src/rendervulkan.cpp +++ b/src/rendervulkan.cpp @@ -2738,11 +2738,15 @@ std::shared_ptr vulkan_create_debug_blank_texture() flags.bSampled = true; flags.bTransferDst = true; + // To match Steam's scaling, which is capped at 1080p + int width = std::min( g_nOutputWidth, 1920 ); + int height = std::min( g_nOutputHeight, 1080 ); + auto texture = std::make_shared(); - assert( texture->BInit( g_nOutputWidth, g_nOutputHeight, 1u, VulkanFormatToDRM( VK_FORMAT_B8G8R8A8_UNORM ), flags ) ); + assert( texture->BInit( width, height, 1u, VulkanFormatToDRM( VK_FORMAT_B8G8R8A8_UNORM ), flags ) ); - void* dst = g_device.uploadBufferData( g_nOutputWidth * g_nOutputHeight * 4 ); - memset( dst, 0x0, g_nOutputWidth * g_nOutputHeight * 4 ); + void* dst = g_device.uploadBufferData( width * height * 4 ); + memset( dst, 0x0, width * height * 4 ); auto cmdBuffer = g_device.commandBuffer(); cmdBuffer->copyBufferToImage(g_device.uploadBuffer(), 0, 0, texture); diff --git a/src/rendervulkan.hpp b/src/rendervulkan.hpp index 8cd9d89dbe..3e33bdce87 100644 --- a/src/rendervulkan.hpp +++ b/src/rendervulkan.hpp @@ -717,7 +717,7 @@ class CVulkanDevice return ret; } - static const uint32_t upload_buffer_size = 1024 * 1024 * 4; + static const uint32_t upload_buffer_size = 1920 * 1080 * 4; inline VkDevice device() { return m_device; } inline VkPhysicalDevice physDev() {return m_physDev; } @@ -738,7 +738,7 @@ class CVulkanDevice inline void *uploadBufferData(uint32_t size) { - assert(size < upload_buffer_size); + assert(size <= upload_buffer_size); m_uploadBufferOffset = align(m_uploadBufferOffset, 16); if (m_uploadBufferOffset + size > upload_buffer_size) diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 617ab7ef7c..1c19178d6c 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -2548,8 +2548,10 @@ paint_all(bool async) FrameInfo_t::Layer_t *layer = &frameInfo.layers[ curLayer ]; - layer->scale.x = 1.0f; - layer->scale.y = 1.0f; + auto tex = vulkan_get_hacky_blank_texture(); + + layer->scale.x = g_nOutputWidth == tex->width() ? 1.0f : tex->width() / (float)g_nOutputWidth; + layer->scale.y = g_nOutputHeight == tex->height() ? 1.0f : tex->height() / (float)g_nOutputHeight; layer->offset.x = 0.0f; layer->offset.y = 0.0f; layer->opacity = 1.0f; // BLAH @@ -2558,8 +2560,8 @@ paint_all(bool async) layer->colorspace = GAMESCOPE_APP_TEXTURE_COLORSPACE_LINEAR; layer->ctm = nullptr; - layer->tex = vulkan_get_hacky_blank_texture(); - layer->fbid = layer->tex->fbid(); + layer->tex = tex; + layer->fbid = tex->fbid(); layer->filter = GamescopeUpscaleFilter::NEAREST; layer->blackBorder = true;