Skip to content

Commit

Permalink
Software: Fix bad backbuffer size
Browse files Browse the repository at this point in the history
MAX_XFB_WIDTH/HEIGHT are the largest XFB sizes seen in practice, but do not make sense to use for the backbuffer size, which should be the size of the window.  The old code created screenshots with a size of 720x540 on NTSC games when "Dump Frames at Internal Resolution" is unchecked; now, the window size is used.
  • Loading branch information
Pokechu22 committed May 24, 2021
1 parent 5167192 commit 4a4244f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Source/Core/VideoBackends/Software/SWRenderer.cpp
Expand Up @@ -27,7 +27,8 @@
namespace SW
{
SWRenderer::SWRenderer(std::unique_ptr<SWOGLWindow> window)
: ::Renderer(static_cast<int>(MAX_XFB_WIDTH), static_cast<int>(MAX_XFB_HEIGHT), 1.0f,
: ::Renderer(static_cast<int>(std::max(window->GetContext()->GetBackBufferWidth(), 1u)),
static_cast<int>(std::max(window->GetContext()->GetBackBufferHeight(), 1u)), 1.0f,
AbstractTextureFormat::RGBA8),
m_window(std::move(window))
{
Expand Down Expand Up @@ -56,6 +57,18 @@ SWRenderer::CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture
static_cast<SWTexture*>(depth_attachment));
}

void SWRenderer::BindBackbuffer(const ClearColor& clear_color)
{
// Look for framebuffer resizes
if (!m_surface_resized.TestAndClear())
return;

GLContext* context = m_window->GetContext();
context->Update();
m_backbuffer_width = context->GetBackBufferWidth();
m_backbuffer_height = context->GetBackBufferHeight();
}

class SWShader final : public AbstractShader
{
public:
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/VideoBackends/Software/SWRenderer.h
Expand Up @@ -27,6 +27,8 @@ class SWRenderer final : public Renderer
std::unique_ptr<AbstractFramebuffer>
CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) override;

void BindBackbuffer(const ClearColor& clear_color = {}) override;

std::unique_ptr<AbstractShader> CreateShaderFromSource(ShaderStage stage,
std::string_view source) override;
std::unique_ptr<AbstractShader> CreateShaderFromBinary(ShaderStage stage, const void* data,
Expand Down

0 comments on commit 4a4244f

Please sign in to comment.