gsdx-ogl: update shader pipeline intertace to use vs/gs/ps triplet

Better to have 1 function calls with 3 parameters rather 3 functions call with 1 parameter.
This commit is contained in:
Gregory Hainaut 2016-04-10 14:14:30 +02:00
parent 53690cf9d0
commit 3f404c8edb
6 changed files with 27 additions and 55 deletions

View File

@ -1025,9 +1025,7 @@ void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture
GSVector2i ds = dTex->GetSize();
m_shader->VS(m_convert.vs);
m_shader->GS(0);
m_shader->PS(ps);
m_shader->Pipeline(m_convert.vs, 0, ps);
// ************************************
// om
@ -1265,9 +1263,7 @@ void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* ver
ClearStencil(ds, 0);
m_shader->VS(m_convert.vs);
m_shader->GS(0);
m_shader->PS(m_convert.ps[datm ? ShaderConvert_DATM_1 : ShaderConvert_DATM_0]);
m_shader->Pipeline(m_convert.vs, 0, m_convert.ps[datm ? ShaderConvert_DATM_1 : ShaderConvert_DATM_0]);
// om

View File

@ -160,7 +160,7 @@ class GSDeviceOGL final : public GSDevice
uint32 key;
};
operator uint32() {return key;}
operator uint32() const {return key;}
VSSelector() : key(0) {}
VSSelector(uint32 k) : key(k) {}
@ -181,7 +181,7 @@ class GSDeviceOGL final : public GSDevice
uint32 key;
};
operator uint32() {return key;}
operator uint32() const {return key;}
GSSelector() : key(0) {}
GSSelector(uint32 k) : key(k) {}
@ -293,7 +293,7 @@ class GSDeviceOGL final : public GSDevice
};
// FIXME is the & useful ?
operator uint64() {return key;}
operator uint64() const {return key;}
PSSelector() : key(0) {}
};
@ -538,9 +538,7 @@ class GSDeviceOGL final : public GSDevice
void SetupIA(const void* vertex, int vertex_count, const uint32* index, int index_count, int prim);
void SetupVS(VSSelector sel);
void SetupGS(GSSelector sel);
void SetupPS(PSSelector sel);
void SetupPipeline(const VSSelector& vsel, const GSSelector& gsel, const PSSelector& psel);
void SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb);
void SetupSampler(PSSamplerSelector ssel);
void SetupOM(OMDepthStencilSelector dssel);

View File

@ -1022,9 +1022,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
#endif
gs_sel.sprite = m_vt.m_primclass == GS_SPRITE_CLASS;
dev->SetupVS(vs_sel);
dev->SetupGS(gs_sel);
dev->SetupPS(ps_sel);
dev->SetupPipeline(vs_sel, gs_sel, ps_sel);
// rs
@ -1062,7 +1060,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
glDepthMask(GLState::depth_mask);
ps_sel.date = 3;
dev->SetupPS(ps_sel);
dev->SetupPipeline(vs_sel, gs_sel, ps_sel);
// Be sure that first pass is finished !
dev->Barrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
@ -1096,7 +1094,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
ps_sel.atst = 1;
}
dev->SetupPS(ps_sel);
dev->SetupPipeline(vs_sel, gs_sel, ps_sel);
bool z = om_dssel.zwe;
bool r = om_csel.wr;

View File

@ -40,35 +40,27 @@ GSShaderOGL::~GSShaderOGL()
m_single_prog.clear();
}
void GSShaderOGL::VS(GLuint s)
void GSShaderOGL::Pipeline(GLuint vs, GLuint gs, GLuint ps)
{
if (GLState::vs != s)
if (GLState::vs != vs)
{
GLState::vs = s;
glUseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, s);
GLState::vs = vs;
glUseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs);
}
if (GLState::gs != gs)
{
GLState::gs = gs;
glUseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs);
}
}
void GSShaderOGL::PS(GLuint s)
{
#ifdef _DEBUG
if (true)
#else
if (GLState::ps != s)
if (GLState::ps != ps)
#endif
{
// In debug always sets the program. It allow to replace the program in apitrace easily.
GLState::ps = s;
glUseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, s);
}
}
void GSShaderOGL::GS(GLuint s)
{
if (GLState::gs != s)
{
GLState::gs = s;
glUseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, s);
GLState::ps = ps;
glUseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps);
}
}

View File

@ -35,9 +35,7 @@ class GSShaderOGL {
GSShaderOGL(bool debug);
~GSShaderOGL();
void GS(GLuint s);
void PS(GLuint s);
void VS(GLuint s);
void Pipeline(GLuint vs, GLuint gs, GLuint ps);
GLuint Compile(const std::string& glsl_file, const std::string& entry, GLenum type, const char* glsl_h_code, const std::string& macro_sel = "");

View File

@ -110,27 +110,17 @@ void GSDeviceOGL::SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer*
GL_POP();
}
void GSDeviceOGL::SetupVS(VSSelector sel)
{
m_shader->VS(m_vs[sel]);
}
void GSDeviceOGL::SetupGS(GSSelector sel)
{
m_shader->GS(m_gs[sel]);
}
void GSDeviceOGL::SetupPS(PSSelector sel)
void GSDeviceOGL::SetupPipeline(const VSSelector& vsel, const GSSelector& gsel, const PSSelector& psel)
{
// *************************************************************
// Static
// *************************************************************
GLuint ps;
auto i = m_ps.find(sel);
auto i = m_ps.find(psel);
if (i == m_ps.end()) {
ps = CompilePS(sel);
m_ps[sel] = ps;
ps = CompilePS(psel);
m_ps[psel] = ps;
} else {
ps = i->second;
}
@ -138,7 +128,7 @@ void GSDeviceOGL::SetupPS(PSSelector sel)
// *************************************************************
// Dynamic
// *************************************************************
m_shader->PS(ps);
m_shader->Pipeline(m_vs[vsel], m_gs[gsel], ps);
}
void GSDeviceOGL::SetupSampler(PSSamplerSelector ssel)