From 83dfc6b633b5c0e16a56ea99dbd51d798b0adfbd Mon Sep 17 00:00:00 2001 From: Gregory Hainaut <gregory.hainaut@gmail.com> Date: Sat, 25 Jul 2015 10:14:53 +0200 Subject: [PATCH] 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 --- plugins/GSdx/GSDeviceOGL.cpp | 11 ++++++----- plugins/GSdx/GSDeviceOGL.h | 23 ++++++----------------- plugins/GSdx/GSTextureFXOGL.cpp | 9 +++++---- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index ef8215cfd6..b70a23771f 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -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 diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index d09465dc0c..71fb0cc771 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -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; diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index 488ad6e0c2..2715e0d431 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -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)