Vulkan: Apply a half-pixel offset where necessary.

This commit is contained in:
DrChat 2017-08-09 00:48:28 -05:00
parent 082c767fba
commit bea607b454
1 changed files with 5 additions and 3 deletions

View File

@ -957,13 +957,15 @@ bool VulkanCommandProcessor::IssueCopy() {
const uint8_t* vertex_addr = memory_->TranslatePhysical(fetch->address << 2); const uint8_t* vertex_addr = memory_->TranslatePhysical(fetch->address << 2);
trace_writer_.WriteMemoryRead(fetch->address << 2, fetch->size * 4); 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*)&regs[XE_GPU_REG_PA_SU_VTX_CNTL].u32;
float vtx_offset = vtx_cntl.pix_center == 0 ? 0.5f : 0.f;
float dest_points[6]; float dest_points[6];
for (int i = 0; i < 6; i++) { 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] = dest_points[i] =
GpuSwap(xe::load<float>(vertex_addr + i * 4), Endian(fetch->endian)) + GpuSwap(xe::load<float>(vertex_addr + i * 4), Endian(fetch->endian)) +
0.5f; vtx_offset;
} }
// Note: The xenos only supports rectangle copies (luckily) // Note: The xenos only supports rectangle copies (luckily)