OGL: update ubo workaround

This commit is contained in:
degasus 2013-10-08 14:34:42 +02:00
parent cc6c454898
commit 5de7ac4791
5 changed files with 35 additions and 38 deletions

View File

@ -63,34 +63,30 @@ const char *UniformNames[NUM_UNIFORMS] =
I_DEPTHPARAMS, I_DEPTHPARAMS,
}; };
struct s_svar const static int PSVar_Loc[] = {
{ offsetof(PixelShaderConstants, colors)/16,
const unsigned int reg; offsetof(PixelShaderConstants, kcolors)/16,
const unsigned int size; offsetof(PixelShaderConstants, alpha)/16,
offsetof(PixelShaderConstants, texdims)/16,
offsetof(PixelShaderConstants, zbias)/16,
offsetof(PixelShaderConstants, indtexscale)/16,
offsetof(PixelShaderConstants, indtexmtx)/16,
offsetof(PixelShaderConstants, fog)/16,
offsetof(PixelShaderConstants, plights)/16,
offsetof(PixelShaderConstants, pmaterials)/16,
}; };
const s_svar PSVar_Loc[] = { {C_COLORS, 4 }, const static int VSVar_Loc[] = {
{C_KCOLORS, 4 }, offsetof(VertexShaderConstants, posnormalmatrix)/16,
{C_ALPHA, 1 }, offsetof(VertexShaderConstants, projection)/16,
{C_TEXDIMS, 8 }, offsetof(VertexShaderConstants, materials)/16,
{C_ZBIAS, 2 }, offsetof(VertexShaderConstants, lights)/16,
{C_INDTEXSCALE, 2 }, offsetof(VertexShaderConstants, texmatrices)/16,
{C_INDTEXMTX, 6 }, offsetof(VertexShaderConstants, transformmatrices)/16,
{C_FOG, 3 }, offsetof(VertexShaderConstants, normalmatrices)/16,
{C_PLIGHTS, 40 }, offsetof(VertexShaderConstants, posttransformmatrices)/16,
{C_PMATERIALS, 4 }, offsetof(VertexShaderConstants, depthparams)/16,
}; };
const s_svar VSVar_Loc[] = { {C_POSNORMALMATRIX, 6 },
{C_PROJECTION, 4 },
{C_MATERIALS, 4 },
{C_LIGHTS, 40 },
{C_TEXMATRICES, 24 },
{C_TRANSFORMMATRICES, 64 },
{C_NORMALMATRICES, 32 },
{C_POSTTRANSFORMMATRICES, 64 },
{C_DEPTHPARAMS, 1 },
};
// End of UBO workaround // End of UBO workaround
@ -221,12 +217,12 @@ void ProgramShaderCache::UploadConstants()
for (unsigned int a = 0; a < 10; ++a) for (unsigned int a = 0; a < 10; ++a)
{ {
if(last_entry->shader.UniformSize[a] > 0) if(last_entry->shader.UniformSize[a] > 0)
glUniform4fv(last_entry->shader.UniformLocations[a], last_entry->shader.UniformSize[a], (float*) &PixelShaderManager::constants + 4*PSVar_Loc[a].reg); glUniform4fv(last_entry->shader.UniformLocations[a], last_entry->shader.UniformSize[a], (float*) &PixelShaderManager::constants + 4*PSVar_Loc[a]);
} }
for (unsigned int a = 0; a < 9; ++a) for (unsigned int a = 0; a < 9; ++a)
{ {
if(last_entry->shader.UniformSize[a+10] > 0) if(last_entry->shader.UniformSize[a+10] > 0)
glUniform4fv(last_entry->shader.UniformLocations[a+10], last_entry->shader.UniformSize[a+10], (float*) &VertexShaderManager::constants + 4*VSVar_Loc[a].reg); glUniform4fv(last_entry->shader.UniformLocations[a+10], last_entry->shader.UniformSize[a+10], (float*) &VertexShaderManager::constants + 4*VSVar_Loc[a]);
} }
ADDSTAT(stats.thisFrame.bytesUniformStreamed, s_ubo_buffer_size); ADDSTAT(stats.thisFrame.bytesUniformStreamed, s_ubo_buffer_size);

View File

@ -324,7 +324,7 @@ int EncodeToRamFromTexture(u32 address,GLuint source_texture, bool bFromZBuffer,
}; };
texconv_shader.Bind(); texconv_shader.Bind();
glUniform4fv(texconv_shader.UniformLocations[C_COLORS], 2, params); glUniform4fv(texconv_shader.UniformLocations[0], 2, params);
TargetRectangle scaledSource; TargetRectangle scaledSource;
scaledSource.top = 0; scaledSource.top = 0;

View File

@ -18,7 +18,7 @@ struct PixelShaderConstants
float4 texdims[8]; float4 texdims[8];
float4 zbias[2]; float4 zbias[2];
float4 indtexscale[2]; float4 indtexscale[2];
float4 indtexmts[6]; float4 indtexmtx[6];
float4 fog[3]; float4 fog[3];
// For pixel lighting // For pixel lighting

View File

@ -21,6 +21,7 @@
#define I_PLIGHTS "cPLights" #define I_PLIGHTS "cPLights"
#define I_PMATERIALS "cPmtrl" #define I_PMATERIALS "cPmtrl"
// TODO: get rid of them as they aren't used
#define C_COLORMATRIX 0 // 0 #define C_COLORMATRIX 0 // 0
#define C_COLORS 0 // 0 #define C_COLORS 0 // 0
#define C_KCOLORS (C_COLORS + 4) // 4 #define C_KCOLORS (C_COLORS + 4) // 4

View File

@ -188,14 +188,14 @@ void PixelShaderManager::SetIndMatrixChanged(int matrixidx)
// xyz - static matrix // xyz - static matrix
// TODO w - dynamic matrix scale / 256...... somehow / 4 works better // TODO w - dynamic matrix scale / 256...... somehow / 4 works better
// rev 2972 - now using / 256.... verify that this works // rev 2972 - now using / 256.... verify that this works
constants.indtexmts[2*matrixidx][0] = bpmem.indmtx[matrixidx].col0.ma * fscale; constants.indtexmtx[2*matrixidx][0] = bpmem.indmtx[matrixidx].col0.ma * fscale;
constants.indtexmts[2*matrixidx][1] = bpmem.indmtx[matrixidx].col1.mc * fscale; constants.indtexmtx[2*matrixidx][1] = bpmem.indmtx[matrixidx].col1.mc * fscale;
constants.indtexmts[2*matrixidx][2] = bpmem.indmtx[matrixidx].col2.me * fscale; constants.indtexmtx[2*matrixidx][2] = bpmem.indmtx[matrixidx].col2.me * fscale;
constants.indtexmts[2*matrixidx][3] = fscale * 4.0f; constants.indtexmtx[2*matrixidx][3] = fscale * 4.0f;
constants.indtexmts[2*matrixidx+1][0] = bpmem.indmtx[matrixidx].col0.mb * fscale; constants.indtexmtx[2*matrixidx+1][0] = bpmem.indmtx[matrixidx].col0.mb * fscale;
constants.indtexmts[2*matrixidx+1][1] = bpmem.indmtx[matrixidx].col1.md * fscale; constants.indtexmtx[2*matrixidx+1][1] = bpmem.indmtx[matrixidx].col1.md * fscale;
constants.indtexmts[2*matrixidx+1][2] = bpmem.indmtx[matrixidx].col2.mf * fscale; constants.indtexmtx[2*matrixidx+1][2] = bpmem.indmtx[matrixidx].col2.mf * fscale;
constants.indtexmts[2*matrixidx+1][3] = fscale * 4.0f; constants.indtexmtx[2*matrixidx+1][3] = fscale * 4.0f;
dirty = true; dirty = true;
PRIM_LOG("indmtx%d: scale=%f, mat=(%f %f %f; %f %f %f)\n", PRIM_LOG("indmtx%d: scale=%f, mat=(%f %f %f; %f %f %f)\n",