From 128d3036564e99fd3c8d7e6ae45eb17e43d0c95f Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Fri, 16 Jan 2015 04:01:00 +1300 Subject: [PATCH] Reduce number of divisions in screenspace transform. This is closer to what the hardware does anyway. --- Source/Core/VideoCommon/VertexManagerBase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 23eb770c6d..c9f5e2c714 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -264,11 +264,11 @@ void VertexManager::CalculateZSlope(u32 stride) VertexShaderManager::TransformToClipSpace(&vtx[i * 3], &out[i * 4]); // Transform to Screenspace - float w = out[3 + i * 4]; + float inv_w = 1.0f / out[3 + i * 4]; - out[0 + i * 4] = out[0 + i * 4] / w * xfmem.viewport.wd + viewOffset[0]; - out[1 + i * 4] = out[1 + i * 4] / w * xfmem.viewport.ht + viewOffset[1]; - out[2 + i * 4] = out[2 + i * 4] / w * xfmem.viewport.zRange + xfmem.viewport.farZ; + out[0 + i * 4] = out[0 + i * 4] * inv_w * xfmem.viewport.wd + viewOffset[0]; + out[1 + i * 4] = out[1 + i * 4] * inv_w * xfmem.viewport.ht + viewOffset[1]; + out[2 + i * 4] = out[2 + i * 4] * inv_w * xfmem.viewport.zRange + xfmem.viewport.farZ; } float dx31 = out[8] - out[0];