From fd4c64d43dbbfe29aace92bb9abb787ba6b6d5c9 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 10 May 2017 17:38:38 -0700 Subject: [PATCH] SoftGPU: Refactor out texture format logic. This could actually be shared, nothing x86 specific... --- GPU/Software/Sampler.h | 1 + GPU/Software/SamplerX86.cpp | 40 ++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/GPU/Software/Sampler.h b/GPU/Software/Sampler.h index dc1f4f6a85..911625bf37 100644 --- a/GPU/Software/Sampler.h +++ b/GPU/Software/Sampler.h @@ -100,6 +100,7 @@ public: private: NearestFunc Compile(const SamplerID &id); + bool Jit_ReadTextureFormat(const SamplerID &id); bool Jit_GetTexData(const SamplerID &id, int bitsPerTexel); bool Jit_Decode5650(); bool Jit_Decode5551(); diff --git a/GPU/Software/SamplerX86.cpp b/GPU/Software/SamplerX86.cpp index b325ad5ef2..e91debdd93 100644 --- a/GPU/Software/SamplerX86.cpp +++ b/GPU/Software/SamplerX86.cpp @@ -64,6 +64,27 @@ NearestFunc SamplerJitCache::Compile(const SamplerID &id) { FixupBranch zeroSrc = J(true); SetJumpTarget(nonZeroSrc); + if (!Jit_ReadTextureFormat(id)) { + EndWrite(); + SetCodePtr(const_cast(start)); + return nullptr; + } + + SetJumpTarget(zeroSrc); + + MOVUPS(XMM4, MDisp(ESP, 0)); + MOVUPS(XMM5, MDisp(ESP, 16)); + MOVUPS(XMM6, MDisp(ESP, 32)); + MOVUPS(XMM7, MDisp(ESP, 48)); + ADD(PTRBITS, R(ESP), Imm8(64)); + + RET(); + + EndWrite(); + return (NearestFunc)start; +} + +bool SamplerJitCache::Jit_ReadTextureFormat(const SamplerID &id) { GETextureFormat fmt = (GETextureFormat)id.texfmt; bool success = true; switch (fmt) { @@ -125,24 +146,7 @@ NearestFunc SamplerJitCache::Compile(const SamplerID &id) { success = false; } - if (!success) { - EndWrite(); - SetCodePtr(const_cast(start)); - return nullptr; - } - - SetJumpTarget(zeroSrc); - - MOVUPS(XMM4, MDisp(ESP, 0)); - MOVUPS(XMM5, MDisp(ESP, 16)); - MOVUPS(XMM6, MDisp(ESP, 32)); - MOVUPS(XMM7, MDisp(ESP, 48)); - ADD(PTRBITS, R(ESP), Imm8(64)); - - RET(); - - EndWrite(); - return (NearestFunc)start; + return success; } bool SamplerJitCache::Jit_GetTexData(const SamplerID &id, int bitsPerTexel) {