diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 5ea49d7606..8aa2dda64b 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -95,7 +95,6 @@ set(GSdxSources GSTextureCache.cpp GSTextureCacheSW.cpp GSTextureCacheOGL.cpp - GSTextureFXOGL.cpp GSTextureOGL.cpp GSTextureNull.cpp GSTextureSW.cpp diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index eacac4728e..c9bbc32465 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2014 Gregory hainaut + * Copyright (C) 2011-2016 Gregory hainaut * Copyright (C) 2007-2009 Gabest * * This Program is free software; you can redistribute it and/or modify @@ -40,6 +40,9 @@ static const uint32 g_interlace_cb_index = 11; static const uint32 g_shadeboost_cb_index = 12; static const uint32 g_fx_cb_index = 14; static const uint32 g_convert_index = 15; +static const uint32 g_vs_cb_index = 20; +static const uint32 g_ps_cb_index = 21; +static const uint32 g_gs_cb_index = 22; bool GSDeviceOGL::m_debug_gl_call = false; int GSDeviceOGL::s_n = 0; @@ -415,6 +418,50 @@ bool GSDeviceOGL::Create(GSWnd* wnd) return true; } +void GSDeviceOGL::CreateTextureFX() +{ + m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer)); + m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer)); + + // warning 1 sampler by image unit. So you cannot reuse m_ps_ss... + m_palette_ss = CreateSampler(false, false, false); + glBindSampler(1, m_palette_ss); + + // Pre compile all Geometry & Vertex Shader + // It might cost a seconds at startup but it would reduce benchmark pollution + GL_PUSH("Compile GS"); + + for (uint32 key = 0; key < countof(m_gs); key++) { + GSSelector sel(key); + if (sel.point == sel.sprite) + m_gs[key] = 0; + else + m_gs[key] = CompileGS(GSSelector(key)); + } + + GL_POP(); + + GL_PUSH("Compile VS"); + + for (uint32 key = 0; key < countof(m_vs); key++) { + VSSelector sel(key); + m_vs[key] = CompileVS(sel); + } + + GL_POP(); + + // Enable all bits for stencil operations. Technically 1 bit is + // enough but buffer is polluted with noise. Clear will be limited + // to the mask. + glStencilMask(0xFF); + 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()); +} + bool GSDeviceOGL::Reset(int w, int h) { if(!GSDevice::Reset(w, h)) @@ -646,6 +693,37 @@ GLuint GSDeviceOGL::CreateSampler(bool bilinear, bool tau, bool tav, bool aniso) return sampler; } +GLuint GSDeviceOGL::GetSamplerID(PSSamplerSelector ssel) +{ + return m_ps_ss[ssel]; +} + +GSDepthStencilOGL* GSDeviceOGL::CreateDepthStencil(OMDepthStencilSelector dssel) +{ + GSDepthStencilOGL* dss = new GSDepthStencilOGL(); + + if (dssel.date) + { + dss->EnableStencil(); + dss->SetStencil(GL_EQUAL, GL_KEEP); + } + + if(dssel.ztst != ZTST_ALWAYS || dssel.zwe) + { + static const GLenum ztst[] = + { + GL_NEVER, + GL_ALWAYS, + GL_GEQUAL, + GL_GREATER + }; + dss->EnableDepth(); + dss->SetDepth(ztst[dssel.ztst], dssel.zwe); + } + + return dss; +} + void GSDeviceOGL::InitPrimDateTexture(GSTexture* rt) { const GSVector2i& rtsize = rt->GetSize(); @@ -1473,6 +1551,55 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto } } +void GSDeviceOGL::SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb) +{ + GL_PUSH("UBO"); + if(m_vs_cb_cache.Update(vs_cb)) { + m_vs_cb->upload(vs_cb); + } + + if(m_ps_cb_cache.Update(ps_cb)) { + m_ps_cb->upload(ps_cb); + } + GL_POP(); +} + +void GSDeviceOGL::SetupPipeline(const VSSelector& vsel, const GSSelector& gsel, const PSSelector& psel) +{ + // ************************************************************* + // Static + // ************************************************************* + GLuint ps; + auto i = m_ps.find(psel); + + if (i == m_ps.end()) { + ps = CompilePS(psel); + m_ps[psel] = ps; + } else { + ps = i->second; + } + + // ************************************************************* + // Dynamic + // ************************************************************* + m_shader->BindPipeline(m_vs[vsel], m_gs[gsel], ps); +} + +void GSDeviceOGL::SetupSampler(PSSamplerSelector ssel) +{ + PSSetSamplerState(m_ps_ss[ssel]); +} + +GLuint GSDeviceOGL::GetPaletteSamplerID() +{ + return m_palette_ss; +} + +void GSDeviceOGL::SetupOM(OMDepthStencilSelector dssel) +{ + OMSetDepthStencilState(m_om_dss[dssel]); +} + void GSDeviceOGL::CheckDebugLog() { if (!m_debug_gl_call) return; diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp deleted file mode 100644 index 755cb762ee..0000000000 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2011-2011 Gregory hainaut - * Copyright (C) 2007-2009 Gabest - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "stdafx.h" -#include "GSDeviceOGL.h" -#include "GSTables.h" - -static const uint32 g_vs_cb_index = 20; -static const uint32 g_ps_cb_index = 21; -static const uint32 g_gs_cb_index = 22; - -void GSDeviceOGL::CreateTextureFX() -{ - m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer)); - m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer)); - - // warning 1 sampler by image unit. So you cannot reuse m_ps_ss... - m_palette_ss = CreateSampler(false, false, false); - glBindSampler(1, m_palette_ss); - - // Pre compile all Geometry & Vertex Shader - // It might cost a seconds at startup but it would reduce benchmark pollution - GL_PUSH("Compile GS"); - - for (uint32 key = 0; key < countof(m_gs); key++) { - GSSelector sel(key); - if (sel.point == sel.sprite) - m_gs[key] = 0; - else - m_gs[key] = CompileGS(GSSelector(key)); - } - - GL_POP(); - - GL_PUSH("Compile VS"); - - for (uint32 key = 0; key < countof(m_vs); key++) { - VSSelector sel(key); - m_vs[key] = CompileVS(sel); - } - - GL_POP(); - - // Enable all bits for stencil operations. Technically 1 bit is - // enough but buffer is polluted with noise. Clear will be limited - // to the mask. - glStencilMask(0xFF); - 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()); -} - -GSDepthStencilOGL* GSDeviceOGL::CreateDepthStencil(OMDepthStencilSelector dssel) -{ - GSDepthStencilOGL* dss = new GSDepthStencilOGL(); - - if (dssel.date) - { - dss->EnableStencil(); - dss->SetStencil(GL_EQUAL, GL_KEEP); - } - - if(dssel.ztst != ZTST_ALWAYS || dssel.zwe) - { - static const GLenum ztst[] = - { - GL_NEVER, - GL_ALWAYS, - GL_GEQUAL, - GL_GREATER - }; - dss->EnableDepth(); - dss->SetDepth(ztst[dssel.ztst], dssel.zwe); - } - - return dss; -} - -void GSDeviceOGL::SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb) -{ - GL_PUSH("UBO"); - if(m_vs_cb_cache.Update(vs_cb)) { - m_vs_cb->upload(vs_cb); - } - - if(m_ps_cb_cache.Update(ps_cb)) { - m_ps_cb->upload(ps_cb); - } - GL_POP(); -} - -void GSDeviceOGL::SetupPipeline(const VSSelector& vsel, const GSSelector& gsel, const PSSelector& psel) -{ - // ************************************************************* - // Static - // ************************************************************* - GLuint ps; - auto i = m_ps.find(psel); - - if (i == m_ps.end()) { - ps = CompilePS(psel); - m_ps[psel] = ps; - } else { - ps = i->second; - } - - // ************************************************************* - // Dynamic - // ************************************************************* - m_shader->BindPipeline(m_vs[vsel], m_gs[gsel], ps); -} - -void GSDeviceOGL::SetupSampler(PSSamplerSelector ssel) -{ - PSSetSamplerState(m_ps_ss[ssel]); -} - -GLuint GSDeviceOGL::GetSamplerID(PSSamplerSelector ssel) -{ - return m_ps_ss[ssel]; -} - -GLuint GSDeviceOGL::GetPaletteSamplerID() -{ - return m_palette_ss; -} - -void GSDeviceOGL::SetupOM(OMDepthStencilSelector dssel) -{ - OMSetDepthStencilState(m_om_dss[dssel]); -} diff --git a/plugins/GSdx/GSdx.vcxproj b/plugins/GSdx/GSdx.vcxproj index 0a11d17df0..4fbcb44e25 100644 --- a/plugins/GSdx/GSdx.vcxproj +++ b/plugins/GSdx/GSdx.vcxproj @@ -794,7 +794,6 @@ - @@ -969,4 +968,4 @@ - \ No newline at end of file + diff --git a/plugins/GSdx/GSdx.vcxproj.filters b/plugins/GSdx/GSdx.vcxproj.filters index 67d7f9f691..a1c3594482 100644 --- a/plugins/GSdx/GSdx.vcxproj.filters +++ b/plugins/GSdx/GSdx.vcxproj.filters @@ -165,9 +165,6 @@ Source Files - - Source Files - Source Files @@ -610,4 +607,4 @@ Resource Files - \ No newline at end of file +