summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexManagerBase.cpp
diff options
context:
space:
mode:
authorTillmann Karras <tilkax@gmail.com>2015-06-01 19:58:27 +0200
committerTillmann Karras <tilkax@gmail.com>2015-06-07 12:13:00 +0200
commit5ddd2cef6c5cc8e5414636d73365691de726b3d0 (patch)
tree0fc5652023050ddcccd41598983a233487de8256 /Source/Core/VideoCommon/VertexManagerBase.cpp
parent9e2f4dd7da306a011d3f34bad7c1808186a9bbd0 (diff)
zfreeze: cache vertex positions
Suggested by degasus.
Diffstat (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index dcef793cec..e9e8ebf901 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -279,7 +279,6 @@ void VertexManager::DoState(PointerWrap& p)
void VertexManager::CalculateZSlope(NativeVertexFormat* format)
{
- float vtx[9];
float out[12];
float viewOffset[2] = { xfmem.viewport.xOrig - bpmem.scissorOffset.x * 2,
xfmem.viewport.yOrig - bpmem.scissorOffset.y * 2};
@@ -290,31 +289,24 @@ void VertexManager::CalculateZSlope(NativeVertexFormat* format)
// Global matrix ID.
u32 mtxIdx = g_main_cp_state.matrix_index_a.PosNormalMtxIdx;
const PortableVertexDeclaration vert_decl = format->GetVertexDeclaration();
- size_t posOff = vert_decl.position.offset;
- size_t mtxOff = vert_decl.posmtx.offset;
// Make sure the buffer contains at least 3 vertices.
if ((s_pCurBufferPointer - s_pBaseBufferPointer) < (vert_decl.stride * 3))
return;
// Lookup vertices of the last rendered triangle and software-transform them
- // This allows us to determine the depth slope, which will be used if z--freeze
+ // This allows us to determine the depth slope, which will be used if z-freeze
// is enabled in the following flush.
for (unsigned int i = 0; i < 3; ++i)
{
- u8* vtx_ptr = s_pCurBufferPointer - vert_decl.stride * (3 - i);
- vtx[0 + i * 3] = ((float*)(vtx_ptr + posOff))[0];
- vtx[1 + i * 3] = ((float*)(vtx_ptr + posOff))[1];
- if (vert_decl.position.components == 3)
- vtx[2 + i * 3] = ((float*)(vtx_ptr + posOff))[2];
- else
- vtx[2 + i * 3] = 0;
-
// If this vertex format has per-vertex position matrix IDs, look it up.
if (vert_decl.posmtx.enable)
- mtxIdx = *((u32*)(vtx_ptr + mtxOff));
+ mtxIdx = VertexLoaderManager::position_matrix_index[2 - i];
+
+ if (vert_decl.position.components == 2)
+ VertexLoaderManager::position_cache[2 - i][2] = 0;
- VertexShaderManager::TransformToClipSpace(&vtx[i * 3], &out[i * 4], mtxIdx);
+ VertexShaderManager::TransformToClipSpace(&VertexLoaderManager::position_cache[2 - i][0], &out[i * 4], mtxIdx);
// Transform to Screenspace
float inv_w = 1.0f / out[3 + i * 4];