From bea607b454fbe94ddc06ee64daef89499f0db27a Mon Sep 17 00:00:00 2001 From: DrChat Date: Wed, 9 Aug 2017 00:48:28 -0500 Subject: [PATCH] Vulkan: Apply a half-pixel offset where necessary. --- src/xenia/gpu/vulkan/vulkan_command_processor.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/xenia/gpu/vulkan/vulkan_command_processor.cc b/src/xenia/gpu/vulkan/vulkan_command_processor.cc index 09e03637a..a13513004 100644 --- a/src/xenia/gpu/vulkan/vulkan_command_processor.cc +++ b/src/xenia/gpu/vulkan/vulkan_command_processor.cc @@ -957,13 +957,15 @@ bool VulkanCommandProcessor::IssueCopy() { const uint8_t* vertex_addr = memory_->TranslatePhysical(fetch->address << 2); trace_writer_.WriteMemoryRead(fetch->address << 2, fetch->size * 4); + // Most vertices have a negative half pixel offset applied, which we reverse. + auto& vtx_cntl = *(reg::PA_SU_VTX_CNTL*)®s[XE_GPU_REG_PA_SU_VTX_CNTL].u32; + float vtx_offset = vtx_cntl.pix_center == 0 ? 0.5f : 0.f; + float dest_points[6]; for (int i = 0; i < 6; i++) { - // TODO(DrChat): I believe there is a register dictating whether this - // half-pixel offset needs to be applied. dest_points[i] = GpuSwap(xe::load(vertex_addr + i * 4), Endian(fetch->endian)) + - 0.5f; + vtx_offset; } // Note: The xenos only supports rectangle copies (luckily)