gsdx ogl: Extend uniform buffer with channel parameter

Instead to use the standard ps ubo which is used every draw call.
I reused a barely used buffer to reduce the extra cost of the upload
This commit is contained in:
Gregory Hainaut 2016-05-29 10:03:26 +02:00
parent 6f19d928f6
commit f7ddd488e1
5 changed files with 21 additions and 12 deletions

View File

@ -49,14 +49,6 @@ enum ShaderConvert {
#pragma pack(push, 1)
class ConvertConstantBuffer
{
public:
GSVector4i ScalingFactor;
ConvertConstantBuffer() {memset(this, 0, sizeof(*this));}
};
class MergeConstantBuffer
{
public:

View File

@ -256,11 +256,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
{
GL_PUSH("GSDeviceOGL::Convert");
m_convert.cb = new GSUniformBufferOGL(g_convert_index, sizeof(ConvertConstantBuffer));
m_convert.cb = new GSUniformBufferOGL(g_convert_index, sizeof(MiscConstantBuffer));
// Upload once and forget about it
ConvertConstantBuffer cb;
cb.ScalingFactor = GSVector4i(theApp.GetConfigI("upscale_multiplier"));
m_convert.cb->cache_upload(&cb);
m_misc_cb_cache.ScalingFactor = GSVector4i(theApp.GetConfigI("upscale_multiplier"));
m_convert.cb->cache_upload(&m_misc_cb_cache);
vs = m_shader->Compile("convert.glsl", "vs_main", GL_VERTEX_SHADER, convert_glsl);
@ -1567,6 +1566,12 @@ void GSDeviceOGL::SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer*
}
}
void GSDeviceOGL::SetupCBMisc(const GSVector4i& channel)
{
m_misc_cb_cache.ChannelShuffle = channel;
m_convert.cb->cache_upload(&m_misc_cb_cache);
}
void GSDeviceOGL::SetupPipeline(const VSSelector& vsel, const GSSelector& gsel, const PSSelector& psel)
{
// *************************************************************

View File

@ -380,6 +380,14 @@ public:
OMColorMaskSelector(uint32 c) { wrgba = c; }
};
struct alignas(32) MiscConstantBuffer
{
GSVector4i ScalingFactor;
GSVector4i ChannelShuffle;
MiscConstantBuffer() {memset(this, 0, sizeof(*this));}
};
struct OGLBlend {uint16 bogus, op, src, dst;};
static const OGLBlend m_blendMapOGL[3*3*3*3 + 1];
static const int m_NO_BLEND;
@ -453,6 +461,7 @@ public:
VSConstantBuffer m_vs_cb_cache;
PSConstantBuffer m_ps_cb_cache;
MiscConstantBuffer m_misc_cb_cache;
GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format);
GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format);
@ -546,6 +555,7 @@ public:
void SetupIA(const void* vertex, int vertex_count, const uint32* index, int index_count, int prim);
void SetupPipeline(const VSSelector& vsel, const GSSelector& gsel, const PSSelector& psel);
void SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb);
void SetupCBMisc(const GSVector4i& channel);
void SetupSampler(PSSamplerSelector ssel);
void SetupOM(OMDepthStencilSelector dssel);
GLuint GetSamplerID(PSSamplerSelector ssel);

View File

@ -61,6 +61,7 @@ layout(std140, binding = 14) uniform cb14
layout(std140, binding = 15) uniform cb15
{
ivec4 ScalingFactor;
ivec4 ChannelShuffle;
};
layout(std140, binding = 20) uniform cb20

View File

@ -86,6 +86,7 @@ static const char* const common_header_glsl =
"layout(std140, binding = 15) uniform cb15\n"
"{\n"
" ivec4 ScalingFactor;\n"
" ivec4 ChannelShuffle;\n"
"};\n"
"\n"
"layout(std140, binding = 20) uniform cb20\n"