Skip to content

Commit

Permalink
steamcompmgr: Handle dummy overlay plane scale for external displays
Browse files Browse the repository at this point in the history
Fixes that stutter on external displays.
  • Loading branch information
misyltoad committed Nov 16, 2023
1 parent fe3dbc6 commit 444bbc6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/rendervulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2738,11 +2738,15 @@ std::shared_ptr<CVulkanTexture> 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<int>( g_nOutputWidth, 1920 );
int height = std::min<int>( g_nOutputHeight, 1080 );

auto texture = std::make_shared<CVulkanTexture>();
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);
Expand Down
4 changes: 2 additions & 2 deletions src/rendervulkan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 444bbc6

Please sign in to comment.