HostDisplay: Adjust offsets for linear filtering

Fixes line on right of screen in South Park.
This commit is contained in:
Connor McLaughlin 2020-05-17 21:05:35 +10:00
parent 19cebd97da
commit 88cc695d0b
4 changed files with 15 additions and 13 deletions

View file

@ -455,8 +455,8 @@ void D3D11HostDisplay::renderDisplay()
0, 1, m_display_linear_filtering ? m_linear_sampler.GetAddressOf() : m_point_sampler.GetAddressOf());
const float uniforms[4] = {
(static_cast<float>(m_display_texture_view_x) + 0.25f) / static_cast<float>(m_display_texture_width),
(static_cast<float>(m_display_texture_view_y) + 0.25f) / static_cast<float>(m_display_texture_height),
static_cast<float>(m_display_texture_view_x) / static_cast<float>(m_display_texture_width),
static_cast<float>(m_display_texture_view_y) / static_cast<float>(m_display_texture_height),
(static_cast<float>(m_display_texture_view_width) - 0.5f) / static_cast<float>(m_display_texture_width),
(static_cast<float>(m_display_texture_view_height) - 0.5f) / static_cast<float>(m_display_texture_height)};
const auto map = m_display_uniform_buffer.Map(m_context.Get(), sizeof(uniforms), sizeof(uniforms));

View file

@ -4,10 +4,10 @@
#include "imgui.h"
#include "qtdisplaywidget.h"
#include "qthostinterface.h"
#include <QtCore/QDebug>
#include <QtGui/QGuiApplication>
#include <QtGui/QKeyEvent>
#include <QtGui/QWindow>
#include <QtCore/QDebug>
#include <array>
#include <imgui_impl_opengl3.h>
#include <tuple>
@ -63,7 +63,7 @@ static void SetSwapInterval(QOpenGLContext* context, int interval)
const QString platform_name(QGuiApplication::platformName());
if (platform_name == QStringLiteral("xcb"))
{
static void(*glx_swap_interval_ext)(Display*, GLXDrawable, int) = nullptr;
static void (*glx_swap_interval_ext)(Display*, GLXDrawable, int) = nullptr;
if (last_context != context)
{
@ -71,7 +71,7 @@ static void SetSwapInterval(QOpenGLContext* context, int interval)
last_context = context;
glx_swap_interval_ext = reinterpret_cast<decltype(glx_swap_interval_ext)>(
glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXSwapIntervalEXT")));
glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXSwapIntervalEXT")));
if (!glx_swap_interval_ext)
return;
}
@ -534,8 +534,8 @@ void OpenGLHostDisplay::renderDisplay()
glDepthMask(GL_FALSE);
m_display_program.Bind();
m_display_program.Uniform4f(
0, (static_cast<float>(m_display_texture_view_x) + 0.25f) / static_cast<float>(m_display_texture_width),
(static_cast<float>(m_display_texture_view_y) - 0.25f) / static_cast<float>(m_display_texture_height),
0, static_cast<float>(m_display_texture_view_x) / static_cast<float>(m_display_texture_width),
static_cast<float>(m_display_texture_view_y) / static_cast<float>(m_display_texture_height),
(static_cast<float>(m_display_texture_view_width) - 0.5f) / static_cast<float>(m_display_texture_width),
(static_cast<float>(m_display_texture_view_height) + 0.5f) / static_cast<float>(m_display_texture_height));
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(reinterpret_cast<uintptr_t>(m_display_texture_handle)));

View file

@ -409,7 +409,8 @@ void D3D11HostDisplay::RenderDisplay()
if (!m_display_texture_handle)
return;
const auto [vp_left, vp_top, vp_width, vp_height] = CalculateDrawRect(m_window_width, m_window_height, m_display_top_margin);
const auto [vp_left, vp_top, vp_width, vp_height] =
CalculateDrawRect(m_window_width, m_window_height, m_display_top_margin);
m_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
m_context->VSSetShader(m_display_vertex_shader.Get(), nullptr, 0);
@ -419,8 +420,8 @@ void D3D11HostDisplay::RenderDisplay()
0, 1, m_display_linear_filtering ? m_linear_sampler.GetAddressOf() : m_point_sampler.GetAddressOf());
const float uniforms[4] = {
(static_cast<float>(m_display_texture_view_x) + 0.25f) / static_cast<float>(m_display_texture_width),
(static_cast<float>(m_display_texture_view_y) + 0.25f) / static_cast<float>(m_display_texture_height),
static_cast<float>(m_display_texture_view_x) / static_cast<float>(m_display_texture_width),
static_cast<float>(m_display_texture_view_y) / static_cast<float>(m_display_texture_height),
(static_cast<float>(m_display_texture_view_width) - 0.5f) / static_cast<float>(m_display_texture_width),
(static_cast<float>(m_display_texture_view_height) - 0.5f) / static_cast<float>(m_display_texture_height)};
const auto map = m_display_uniform_buffer.Map(m_context.Get(), sizeof(uniforms), sizeof(uniforms));

View file

@ -391,7 +391,8 @@ void OpenGLHostDisplay::RenderDisplay()
if (!m_display_texture_handle)
return;
const auto [vp_left, vp_top, vp_width, vp_height] = CalculateDrawRect(m_window_width, m_window_height, m_display_top_margin);
const auto [vp_left, vp_top, vp_width, vp_height] =
CalculateDrawRect(m_window_width, m_window_height, m_display_top_margin);
glViewport(vp_left, m_window_height - vp_top - vp_height, vp_width, vp_height);
glDisable(GL_BLEND);
@ -401,8 +402,8 @@ void OpenGLHostDisplay::RenderDisplay()
glDepthMask(GL_FALSE);
m_display_program.Bind();
m_display_program.Uniform4f(
0, (static_cast<float>(m_display_texture_view_x) + 0.25f) / static_cast<float>(m_display_texture_width),
(static_cast<float>(m_display_texture_view_y) - 0.25f) / static_cast<float>(m_display_texture_height),
0, static_cast<float>(m_display_texture_view_x) / static_cast<float>(m_display_texture_width),
static_cast<float>(m_display_texture_view_y) / static_cast<float>(m_display_texture_height),
(static_cast<float>(m_display_texture_view_width) - 0.5f) / static_cast<float>(m_display_texture_width),
(static_cast<float>(m_display_texture_view_height) + 0.5f) / static_cast<float>(m_display_texture_height));
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(reinterpret_cast<uintptr_t>(m_display_texture_handle)));