Commit 02893ccf authored by Jean-Philip Desjardins's avatar Jean-Philip Desjardins
Browse files

Prevent unnecessary CLUT updates.

parent 487f5b0f
......@@ -1848,6 +1848,7 @@ void CGSH_OpenGL::FlushVertexBuffer()
DoRenderPass();
m_vertexBuffer.clear();
m_lastClutKeyValid = false;
}
void CGSH_OpenGL::DoRenderPass()
......@@ -2210,6 +2211,7 @@ void CGSH_OpenGL::VertexKick(uint8 nRegister, uint64 nValue)
void CGSH_OpenGL::ProcessHostToLocalTransfer()
{
FlushVertexBuffer();
m_lastClutKeyValid = false;
m_renderState.isTextureStateValid = false;
m_renderState.isFramebufferStateValid = false;
......@@ -2438,11 +2440,23 @@ void CGSH_OpenGL::ProcessLocalToLocalTransfer()
void CGSH_OpenGL::ProcessClutTransfer(uint32 tex0RegLo, uint32 tex0RegHi)
{
auto tex0 = make_convertible<TEX0>(static_cast<uint64>(tex0RegLo) | static_cast<uint64>(tex0RegHi) << 32);
//Check if we've already updated the CLUT
CLUTPARAMS clutKey = {};
clutKey.cbp = tex0.nCBP;
clutKey.cpsm = tex0.nCPSM;
clutKey.csa = tex0.nCSA;
clutKey.csm = tex0.nCSM;
if(m_lastClutKeyValid && (m_lastClutKey == clutKey))
{
return;
}
FlushVertexBuffer();
m_renderState.isTextureStateValid = false;
auto tex0 = make_convertible<TEX0>(static_cast<uint64>(tex0RegLo) | static_cast<uint64>(tex0RegHi) << 32);
assert(CGsPixelFormats::IsPsmIDTEX(tex0.nPsm));
auto caps = make_convertible<CLUTLOADER_SHADERCAPS>(0);
......@@ -2498,6 +2512,9 @@ void CGSH_OpenGL::ProcessClutTransfer(uint32 tex0RegLo, uint32 tex0RegHi)
glDispatchCompute(1, 1, 1);
CHECKGLERROR();
m_lastClutKey = clutKey;
m_lastClutKeyValid = true;
#if 0
glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
......
......@@ -235,6 +235,20 @@ private:
uint8 nFog;
};
struct CLUTPARAMS : public convertible<uint64>
{
unsigned int cbp : 14;
unsigned int cbw : 6;
unsigned int cpsm : 4;
unsigned int csm : 1;
unsigned int padding : 7;
unsigned int csa : 5;
unsigned int cou : 6;
unsigned int cov : 10;
unsigned int reserved : 11;
};
static_assert(sizeof(CLUTPARAMS) == sizeof(uint64), "Size of CLUTPARAMS must be 8 bytes.");
enum
{
TEXTURE_SOURCE_MODE_NONE = 0,
......@@ -524,6 +538,9 @@ private:
unsigned int m_primitiveType;
bool m_drawingToDepth = false;
CLUTPARAMS m_lastClutKey;
bool m_lastClutKeyValid = false;
static const GLenum g_nativeClampModes[CGSHandler::CLAMP_MODE_MAX];
static const unsigned int g_shaderClampModes[CGSHandler::CLAMP_MODE_MAX];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment