mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl: clean a bit selector code
Use countof macro (avoid to duplicate the size) Fix the size of array Remove useless alpha_stencil case
This commit is contained in:
parent
e026f1bac6
commit
83dfc6b633
|
@ -133,15 +133,15 @@ GSDeviceOGL::~GSDeviceOGL()
|
|||
gl_DeleteSamplers(1, &m_palette_ss);
|
||||
m_shader->Delete(m_apitrace);
|
||||
|
||||
for (uint32 key = 0; key < VSSelector::size(); key++) m_shader->Delete(m_vs[key]);
|
||||
for (uint32 key = 0; key < GSSelector::size(); key++) m_shader->Delete(m_gs[key]);
|
||||
for (uint32 key = 0; key < countof(m_vs); key++) m_shader->Delete(m_vs[key]);
|
||||
for (uint32 key = 0; key < countof(m_gs); key++) m_shader->Delete(m_gs[key]);
|
||||
for (auto it = m_ps.begin(); it != m_ps.end() ; it++) m_shader->Delete(it->second);
|
||||
|
||||
m_ps.clear();
|
||||
|
||||
gl_DeleteSamplers(PSSamplerSelector::size(), m_ps_ss);
|
||||
gl_DeleteSamplers(countof(m_ps_ss), m_ps_ss);
|
||||
|
||||
for (uint32 key = 0; key < OMDepthStencilSelector::size(); key++) delete m_om_dss[key];
|
||||
for (uint32 key = 0; key < countof(m_om_dss); key++) delete m_om_dss[key];
|
||||
|
||||
for (auto it = m_om_bs.begin(); it != m_om_bs.end(); it++) delete it->second;
|
||||
m_om_bs.clear();
|
||||
|
@ -238,8 +238,9 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
|||
// ****************************************************************
|
||||
// Pre Generate the different sampler object
|
||||
// ****************************************************************
|
||||
for (uint32 key = 0; key < PSSamplerSelector::size(); key++)
|
||||
for (uint32 key = 0; key < countof(m_ps_ss); key++) {
|
||||
m_ps_ss[key] = CreateSampler(PSSamplerSelector(key));
|
||||
}
|
||||
|
||||
// ****************************************************************
|
||||
// convert
|
||||
|
|
|
@ -238,13 +238,10 @@ class GSDeviceOGL : public GSDevice
|
|||
uint32 key;
|
||||
};
|
||||
|
||||
// FIXME is the & useful ?
|
||||
operator uint32() {return key & 0x3f;}
|
||||
operator uint32() {return key;}
|
||||
|
||||
VSSelector() : key(0) {}
|
||||
VSSelector(uint32 k) : key(k) {}
|
||||
|
||||
static uint32 size() { return 1 << 5; }
|
||||
};
|
||||
|
||||
struct GSSelector
|
||||
|
@ -266,8 +263,6 @@ class GSDeviceOGL : public GSDevice
|
|||
|
||||
GSSelector() : key(0) {}
|
||||
GSSelector(uint32 k) : key(k) {}
|
||||
|
||||
static uint32 size() { return 1 << 2; }
|
||||
};
|
||||
|
||||
__aligned(struct, 32) PSConstantBuffer
|
||||
|
@ -386,13 +381,10 @@ class GSDeviceOGL : public GSDevice
|
|||
uint32 key;
|
||||
};
|
||||
|
||||
// FIXME is the & useful ?
|
||||
operator uint32() {return key & 0x7;}
|
||||
operator uint32() {return key;}
|
||||
|
||||
PSSamplerSelector() : key(0) {}
|
||||
PSSamplerSelector(uint32 k) : key(k) {}
|
||||
|
||||
static uint32 size() { return 1 << 3; }
|
||||
};
|
||||
|
||||
struct OMDepthStencilSelector
|
||||
|
@ -404,21 +396,18 @@ class GSDeviceOGL : public GSDevice
|
|||
uint32 ztst:2;
|
||||
uint32 zwe:1;
|
||||
uint32 date:1;
|
||||
uint32 alpha_stencil:1;
|
||||
|
||||
uint32 _free:27;
|
||||
uint32 _free:28;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
// FIXME is the & useful ?
|
||||
operator uint32() {return key & 0x1f;}
|
||||
operator uint32() {return key;}
|
||||
|
||||
OMDepthStencilSelector() : key(0) {}
|
||||
OMDepthStencilSelector(uint32 k) : key(k) {}
|
||||
|
||||
static uint32 size() { return 1 << 5; }
|
||||
};
|
||||
|
||||
struct OMColorMaskSelector
|
||||
|
@ -560,10 +549,10 @@ class GSDeviceOGL : public GSDevice
|
|||
float bf; // blend factor
|
||||
} m_state;
|
||||
|
||||
GLuint m_vs[1<<6];
|
||||
GLuint m_vs[1<<5];
|
||||
GLuint m_gs[1<<2];
|
||||
GLuint m_ps_ss[1<<3];
|
||||
GSDepthStencilOGL* m_om_dss[1<<6];
|
||||
GSDepthStencilOGL* m_om_dss[1<<4];
|
||||
hash_map<uint64, GLuint > m_ps;
|
||||
hash_map<uint32, GSBlendStateOGL* > m_om_bs;
|
||||
GLuint m_apitrace;
|
||||
|
|
|
@ -40,7 +40,7 @@ void GSDeviceOGL::CreateTextureFX()
|
|||
|
||||
// Pre compile all Geometry & Vertex Shader
|
||||
// It might cost a seconds at startup but it would reduce benchmark pollution
|
||||
for (uint32 key = 0; key < GSSelector::size(); key++) {
|
||||
for (uint32 key = 0; key < countof(m_gs); key++) {
|
||||
GSSelector sel(key);
|
||||
if (sel.point == sel.sprite)
|
||||
m_gs[key] = 0;
|
||||
|
@ -48,7 +48,7 @@ void GSDeviceOGL::CreateTextureFX()
|
|||
m_gs[key] = CompileGS(GSSelector(key));
|
||||
}
|
||||
|
||||
for (uint32 key = 0; key < VSSelector::size(); key++) {
|
||||
for (uint32 key = 0; key < countof(m_vs); key++) {
|
||||
// wildhack is only useful if both TME and FST are enabled.
|
||||
VSSelector sel(key);
|
||||
if (sel.wildhack && (!sel.tme || !sel.fst))
|
||||
|
@ -61,8 +61,9 @@ void GSDeviceOGL::CreateTextureFX()
|
|||
// enough but buffer is polluted with noise. Clear will be limited
|
||||
// to the mask.
|
||||
glStencilMask(0xFF);
|
||||
for (uint32 key = 0; key < OMDepthStencilSelector::size(); key++)
|
||||
for (uint32 key = 0; key < countof(m_om_dss); key++) {
|
||||
m_om_dss[key] = CreateDepthStencil(OMDepthStencilSelector(key));
|
||||
}
|
||||
|
||||
// Help to debug FS in apitrace
|
||||
m_apitrace = CompilePS(PSSelector());
|
||||
|
@ -77,7 +78,7 @@ GSDepthStencilOGL* GSDeviceOGL::CreateDepthStencil(OMDepthStencilSelector dssel)
|
|||
if (dssel.date)
|
||||
{
|
||||
dss->EnableStencil();
|
||||
dss->SetStencil(GL_EQUAL, dssel.alpha_stencil ? GL_ZERO : GL_KEEP);
|
||||
dss->SetStencil(GL_EQUAL, GL_KEEP);
|
||||
}
|
||||
|
||||
if(dssel.ztst != ZTST_ALWAYS || dssel.zwe)
|
||||
|
|
Loading…
Reference in New Issue