From ec5b52b3fb3e7f90fdd4360078518760e9552b9c Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 21 Apr 2020 22:07:53 +1000 Subject: [PATCH] GPU/HW: Tweak vertex shader offsets Fixes Doom/Dark Forces/etc in hardware renderer, but only at 1x resolution. Fixes missing lines in Castlevania SOTM, Ridge Racer Type 4, etc. --- src/core/gpu_hw.cpp | 2 +- src/core/gpu_hw_shadergen.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 0925503e3..1b9915a8a 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -199,7 +199,7 @@ void GPU_HW::LoadVertices() vertices[i].Set(m_drawing_offset.x + vp.x, m_drawing_offset.y + vp.y, color, texpage, packed_texcoord); } - if (rc.quad_polygon) + if (rc.quad_polygon && m_resolution_scale > 1) HandleFlippedQuadTextureCoordinates(vertices.data()); // Cull polygons which are too large. diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index 7addc05fc..f6ce7ffda 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -400,8 +400,10 @@ std::string GPU_HW_ShaderGen::GenerateBatchVertexShader(bool textured) ss << R"( { // 0..+1023 -> -1..1 - float pos_x = (float(a_pos.x) / 512.0) - 1.0; - float pos_y = (float(a_pos.y) / -256.0) + 1.0; + float pos_x = ((float(a_pos.x) + 0.5) / 1024.0); + float pos_y = ((float(a_pos.y) + 0.5) / 512.0); + pos_x = (pos_x * 2.0) - 1.0; + pos_y = ((1.0 - pos_y) * 2.0) - 1.0; v_pos = float4(pos_x, pos_y, 0.0, 1.0); v_col0 = a_col0;