summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoader.cpp
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2014-08-26 23:17:51 -0400
committercomex <comexk@gmail.com>2014-09-28 21:23:28 -0400
commitf8452ff50103a503546e57ec8c6fc7fd5fa92a29 (patch)
treedcf4d8fb599431c76160f06f4f0907aeb2a26c2e /Source/Core/VideoCommon/VertexLoader.cpp
parent63c62b277d6850279bd2a982535d5abde824e6e2 (diff)
Fix threading issue with vertex loader JIT.
VertexLoader::VertexLoader was setting loop_counter, a *static* variable, to 0. This was nonsensical, but harmless until I started to run it on a separate thread, where it had a chance of interfering with a running vertex translator. Switch to just using a register for the loop counter.
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoader.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoader.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp
index 7876e050c2..ebc57d8577 100644
--- a/Source/Core/VideoCommon/VertexLoader.cpp
+++ b/Source/Core/VideoCommon/VertexLoader.cpp
@@ -38,9 +38,6 @@ static u8 s_curtexmtx[8];
static int s_texmtxwrite = 0;
static int s_texmtxread = 0;
-static int loop_counter;
-
-
// Vertex loaders read these. Although the scale ones should be baked into the shader.
int tcIndex;
int colIndex;
@@ -549,7 +546,6 @@ VertexLoader::VertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr)
m_numLoadedVertices = 0;
m_VertexSize = 0;
m_native_vertex_format = nullptr;
- loop_counter = 0;
VertexLoader_Normal::Init();
VertexLoader_Position::Init();
VertexLoader_TextCoord::Init();
@@ -585,8 +581,11 @@ void VertexLoader::CompileVertexTranslator()
PanicAlert("Trying to recompile a vertex translator");
m_compiledCode = GetCodePtr();
- // We don't use any callee saved registers or anything but RAX.
- ABI_PushRegistersAndAdjustStack(0, 8);
+ // We only use RAX (caller saved) and RBX (callee saved).
+ ABI_PushRegistersAndAdjustStack(1 << RBX, 8);
+
+ // save count
+ MOV(64, R(RBX), R(ABI_PARAM1));
// Start loop here
const u8 *loop_start = GetCodePtr();
@@ -843,11 +842,10 @@ void VertexLoader::CompileVertexTranslator()
#ifdef USE_VERTEX_LOADER_JIT
// End loop here
- MOV(64, R(RAX), Imm64((u64)&loop_counter));
- SUB(32, MatR(RAX), Imm8(1));
+ SUB(64, R(RBX), Imm8(1));
J_CC(CC_NZ, loop_start);
- ABI_PopRegistersAndAdjustStack(0, 8);
+ ABI_PopRegistersAndAdjustStack(1 << RBX, 8);
RET();
#endif
}
@@ -913,8 +911,7 @@ void VertexLoader::ConvertVertices ( int count )
#ifdef USE_VERTEX_LOADER_JIT
if (count > 0)
{
- loop_counter = count;
- ((void (*)())(void*)m_compiledCode)();
+ ((void (*)(int))(void*)m_compiledCode)(count);
}
#else
for (int s = 0; s < count; s++)