diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 6cca51c454..255998c25e 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -134,7 +134,7 @@ GSDeviceOGL::~GSDeviceOGL() m_shader->Delete(m_apitrace); for (uint32 key = 0; key < VSSelector::size(); key++) m_shader->Delete(m_vs[key]); - m_shader->Delete(m_gs); + for (uint32 key = 0; key < GSSelector::size(); 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(); @@ -630,9 +630,11 @@ GLuint GSDeviceOGL::CompileVS(VSSelector sel, int logz) } /* Note: must be here because tfx_glsl is static */ -GLuint GSDeviceOGL::CompileGS() +GLuint GSDeviceOGL::CompileGS(GSSelector sel) { - return m_shader->Compile("tfx_vgs.glsl", "gs_main", GL_GEOMETRY_SHADER, tfx_vgs_glsl, ""); + std::string macro = format("#define GS_POINT %d\n", sel.point); + + return m_shader->Compile("tfx_vgs.glsl", "gs_main", GL_GEOMETRY_SHADER, tfx_vgs_glsl, macro); } /* Note: must be here because tfx_glsl is static */ diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 46611072e3..62e72e2662 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -248,6 +248,29 @@ class GSDeviceOGL : public GSDevice static uint32 size() { return 1 << 5; } }; + struct GSSelector + { + union + { + struct + { + uint32 sprite:1; + uint32 point:1; + + uint32 _free:30; + }; + + uint32 key; + }; + + operator uint32() {return key;} + + GSSelector() : key(0) {} + GSSelector(uint32 k) : key(k) {} + + static uint32 size() { return 1 << 2; } + }; + __aligned(struct, 32) PSConstantBuffer { GSVector4 FogColor_AREF; @@ -535,7 +558,7 @@ class GSDeviceOGL : public GSDevice } m_state; GLuint m_vs[1<<6]; - GLuint m_gs; + GLuint m_gs[1<<2]; GLuint m_ps_ss[1<<3]; GSDepthStencilOGL* m_om_dss[1<<6]; hash_map m_ps; @@ -628,7 +651,7 @@ class GSDeviceOGL : public GSDevice void CreateTextureFX(); GLuint CompileVS(VSSelector sel, int logz); - GLuint CompileGS(); + GLuint CompileGS(GSSelector sel); GLuint CompilePS(PSSelector sel); GLuint CreateSampler(bool bilinear, bool tau, bool tav); GLuint CreateSampler(PSSamplerSelector sel); @@ -638,7 +661,7 @@ class GSDeviceOGL : public GSDevice void SetupIA(const void* vertex, int vertex_count, const uint32* index, int index_count, int prim); void SetupVS(VSSelector sel); - void SetupGS(bool enable); + void SetupGS(GSSelector sel); void SetupPS(PSSelector sel); void SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb); void SetupSampler(PSSamplerSelector ssel); diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index 3bae20f817..60f484db9a 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -240,6 +240,8 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour GSDeviceOGL::VSSelector vs_sel; GSDeviceOGL::VSConstantBuffer vs_cb; + GSDeviceOGL::GSSelector gs_sel; + GSDeviceOGL::PSSelector ps_sel; GSDeviceOGL::PSConstantBuffer ps_cb; GSDeviceOGL::PSSamplerSelector ps_ssel; @@ -778,6 +780,8 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour #endif } + // SW Blending + // Compute the blending equation to detect special case int blend_sel = ((om_bsel.a * 3 + om_bsel.b) * 3 + om_bsel.c) * 3 + om_bsel.d; int bogus_blend = GSDeviceOGL::m_blendMapD3D9[blend_sel].bogus; @@ -808,12 +812,17 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour ps_sel.clr1 = om_bsel.IsCLR1(); } + // GS + + gs_sel.sprite = m_vt.m_primclass == GS_SPRITE_CLASS; + //gs_sel.point = m_vt.m_primclass == GS_POINT_CLASS; + // WARNING: setup of the program must be done first. So you can setup // 1/ subroutine uniform // 2/ bindless texture uniform // 3/ others uniform? dev->SetupVS(vs_sel); - dev->SetupGS(m_vt.m_primclass == GS_SPRITE_CLASS); + dev->SetupGS(gs_sel); dev->SetupPS(ps_sel); // rs diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index 7599d28cdb..03942e397d 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -40,7 +40,13 @@ void GSDeviceOGL::CreateTextureFX() // Pre compile all Geometry & Vertex Shader // It might cost a seconds at startup but it would reduce benchmark pollution - m_gs = CompileGS(); + for (uint32 key = 0; key < GSSelector::size(); key++) { + GSSelector sel(key); + if (sel.point == sel.sprite) + m_gs[key] = 0; + else + m_gs[key] = CompileGS(GSSelector(key)); + } for (uint32 key = 0; key < VSSelector::size(); key++) { // wildhack is only useful if both TME and FST are enabled. @@ -149,12 +155,9 @@ void GSDeviceOGL::SetupVS(VSSelector sel) m_shader->VS(m_vs[sel], 1); } -void GSDeviceOGL::SetupGS(bool enable) +void GSDeviceOGL::SetupGS(GSSelector sel) { - if (enable) - m_shader->GS(m_gs); - else - m_shader->GS(0); + m_shader->GS(m_gs[sel]); } void GSDeviceOGL::SetupPS(PSSelector sel)