vertexjit: Simplify CPU core check.

This also avoids allocating the memory we won't use if it's off.
This commit is contained in:
Unknown W. Brackets 2023-02-28 07:03:12 -08:00
parent f199a0fee3
commit 9c21184352
4 changed files with 9 additions and 7 deletions

View File

@ -36,7 +36,9 @@ enum {
};
DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) {
if (g_Config.bVertexDecoderJit && g_Config.iCpuCore == (int)CPUCore::JIT) {
decJitCache_ = new VertexDecoderJitCache();
}
transformed = (TransformedVertex *)AllocateMemoryPages(TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
transformedExpanded = (TransformedVertex *)AllocateMemoryPages(3 * TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
}
@ -169,6 +171,7 @@ static Vec3f ScreenToDrawing(const Vec3f& coords) {
}
void DrawEngineCommon::NotifyConfigChanged() {
if (decJitCache_)
decJitCache_->Clear();
lastVType_ = -1;
dec_ = nullptr;

View File

@ -117,7 +117,9 @@ public:
}
bool IsCodePtrVertexDecoder(const u8 *ptr) const {
if (decJitCache_)
return decJitCache_->IsInSpace(ptr);
return false;
}
int GetNumDrawCalls() const {
return numDrawCalls;

View File

@ -1274,7 +1274,7 @@ void VertexDecoder::SetVertexType(u32 fmt, const VertexDecoderOptions &options,
// Attempt to JIT as well. But only do that if the main CPU JIT is enabled, in order to aid
// debugging attempts - if the main JIT doesn't work, this one won't do any better, probably.
if (jitCache && g_Config.bVertexDecoderJit && g_Config.iCpuCore == (int)CPUCore::JIT) {
if (jitCache) {
jitted_ = jitCache->Compile(*this, &jittedSize_);
if (!jitted_) {
WARN_LOG(G3D, "Vertex decoder JIT failed! fmt = %08x (%s)", fmt_, GetString(SHADER_STRING_SHORT_DESC).c_str());

View File

@ -38,9 +38,6 @@ public:
dst_ = new u8[BUFFER_SIZE];
cache_ = new VertexDecoderJitCache();
g_Config.bVertexDecoderJit = true;
// Required for jit to be enabled.
g_Config.iCpuCore = (int)CPUCore::JIT;
gstate_c.uv.uScale = 1.0f;
gstate_c.uv.vScale = 1.0f;
}