GPU: Fix invalid rectangle passed to glScissor

This commit is contained in:
Connor McLaughlin 2019-10-05 14:36:48 +10:00
parent c2baa7e834
commit 431313156a
4 changed files with 26 additions and 16 deletions

View File

@ -141,10 +141,10 @@ void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices)
void GPU_HW::CalcScissorRect(int* left, int* top, int* right, int* bottom)
{
*left = m_drawing_area.left * s32(m_resolution_scale);
*right = (m_drawing_area.right + 1) * s32(m_resolution_scale);
*top = m_drawing_area.top * s32(m_resolution_scale);
*bottom = (m_drawing_area.bottom + 1) * s32(m_resolution_scale);
*left = m_drawing_area.left * m_resolution_scale;
*right = std::max<u32>((m_drawing_area.right + 1) * m_resolution_scale, *left + 1);
*top = m_drawing_area.top * m_resolution_scale;
*bottom = std::max<u32>((m_drawing_area.bottom + 1) * m_resolution_scale, *top + 1);
}
static void DefineMacro(std::stringstream& ss, const char* name, bool enabled)

View File

@ -396,20 +396,27 @@ void GPU_HW_OpenGL::SetDrawState()
glBlendFuncSeparate(GL_ONE, GL_SRC_ALPHA, GL_ONE, GL_ZERO);
}
}
if (m_drawing_area_changed)
{
m_drawing_area_changed = false;
int left, top, right, bottom;
CalcScissorRect(&left, &top, &right, &bottom);
const int width = right - left;
const int height = bottom - top;
const int x = left;
const int y = m_vram_texture->GetHeight() - bottom;
Log_DebugPrintf("SetScissor: (%d-%d, %d-%d)", x, x + width, y, y + height);
glScissor(x, y, width, height);
}
}
void GPU_HW_OpenGL::UpdateDrawingArea()
{
int left, top, right, bottom;
CalcScissorRect(&left, &top, &right, &bottom);
const int width = right - left;
const int height = bottom - top;
const int x = left;
const int y = m_vram_texture->GetHeight() - bottom;
Log_DebugPrintf("SetScissor: (%d-%d, %d-%d)", x, x + width, y, y + height);
glScissor(x, y, width, height);
m_drawing_area_changed = true;
}
void GPU_HW_OpenGL::UpdateDisplay()

View File

@ -73,6 +73,7 @@ private:
bool m_vram_read_texture_dirty = true;
bool m_last_transparency_enable = false;
TransparencyMode m_last_transparency_mode = TransparencyMode::BackgroundMinusForeground;
bool m_drawing_area_changed = true;
std::array<std::array<std::array<std::array<GL::Program, 2>, 3>, 2>, 2> m_render_programs;
GL::Program m_reinterpret_rgb8_program;

View File

@ -98,12 +98,14 @@ bool SDLInterface::CreateGLContext()
return false;
}
#if 0
if (GLAD_GL_KHR_debug)
{
glad_glDebugMessageCallbackKHR(GLDebugCallback, nullptr);
// glEnable(GL_DEBUG_OUTPUT);
// glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
}
#endif
SDL_GL_SetSwapInterval(0);
return true;