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