2013-04-18 03:29:41 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "Globals.h"
|
2009-09-13 09:23:30 +00:00
|
|
|
#include "VideoConfig.h"
|
2009-02-23 06:15:48 +00:00
|
|
|
#include "Statistics.h"
|
|
|
|
|
|
|
|
#include "GLUtil.h"
|
|
|
|
|
|
|
|
#include "Render.h"
|
|
|
|
#include "VertexShaderGen.h"
|
|
|
|
#include "VertexShaderManager.h"
|
2011-12-01 03:00:21 +00:00
|
|
|
#include "ProgramShaderCache.h"
|
2009-02-23 06:15:48 +00:00
|
|
|
#include "VertexManager.h"
|
|
|
|
#include "VertexLoader.h"
|
|
|
|
#include "XFMemory.h"
|
|
|
|
#include "ImageWrite.h"
|
2010-02-02 21:56:29 +00:00
|
|
|
#include "FileUtil.h"
|
2010-12-05 14:15:36 +00:00
|
|
|
#include "Debugger.h"
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2011-01-29 20:16:51 +00:00
|
|
|
namespace OGL
|
|
|
|
{
|
|
|
|
|
2011-12-01 03:00:21 +00:00
|
|
|
void SetVSConstant4fvByName(const char * name, unsigned int offset, const float *f, const unsigned int count = 1)
|
|
|
|
{
|
2011-12-26 07:58:52 +00:00
|
|
|
ProgramShaderCache::PCacheEntry tmp = ProgramShaderCache::GetShaderProgram();
|
2011-12-26 05:15:54 +00:00
|
|
|
for (int a = 0; a < NUM_UNIFORMS; ++a)
|
2011-12-11 10:08:18 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
if (!strcmp(name, UniformNames[a]))
|
|
|
|
{
|
2013-02-13 12:12:19 +00:00
|
|
|
if (tmp.shader.UniformLocations[a] == -1)
|
2011-12-26 05:15:54 +00:00
|
|
|
return;
|
|
|
|
else
|
|
|
|
{
|
2013-02-13 12:12:19 +00:00
|
|
|
glUniform4fv(tmp.shader.UniformLocations[a] + offset, count, f);
|
2011-12-26 05:15:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-12-11 10:08:18 +00:00
|
|
|
}
|
2011-12-01 03:00:21 +00:00
|
|
|
}
|
2011-12-26 05:15:54 +00:00
|
|
|
|
2012-12-24 17:09:52 +00:00
|
|
|
void Renderer::SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
2011-12-01 03:00:21 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
float const buf[4] = {f1, f2, f3, f4};
|
|
|
|
|
2011-12-09 23:30:05 +00:00
|
|
|
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
|
|
|
{
|
2011-12-11 10:11:57 +00:00
|
|
|
ProgramShaderCache::SetMultiVSConstant4fv(const_number, buf, 1);
|
2011-12-10 14:07:13 +00:00
|
|
|
return;
|
2011-12-09 23:30:05 +00:00
|
|
|
}
|
2011-12-26 05:15:54 +00:00
|
|
|
for (unsigned int a = 0; a < 9; ++a)
|
2011-12-11 10:08:18 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
if (const_number >= VSVar_Loc[a].reg && const_number < ( VSVar_Loc[a].reg + VSVar_Loc[a].size))
|
|
|
|
{
|
|
|
|
unsigned int offset = const_number - VSVar_Loc[a].reg;
|
|
|
|
SetVSConstant4fvByName(VSVar_Loc[a].name, offset, buf);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-11 10:08:18 +00:00
|
|
|
}
|
2010-07-22 07:55:35 +00:00
|
|
|
}
|
2011-01-29 20:16:51 +00:00
|
|
|
|
2012-12-24 17:09:52 +00:00
|
|
|
void Renderer::SetVSConstant4fv(unsigned int const_number, const float *f)
|
2011-01-29 20:16:51 +00:00
|
|
|
{
|
2011-12-09 23:30:05 +00:00
|
|
|
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
|
|
|
{
|
2011-12-11 10:11:57 +00:00
|
|
|
ProgramShaderCache::SetMultiVSConstant4fv(const_number, f, 1);
|
2011-12-10 14:07:13 +00:00
|
|
|
return;
|
2011-12-09 23:30:05 +00:00
|
|
|
}
|
2011-12-26 05:15:54 +00:00
|
|
|
for (unsigned int a = 0; a < 9; ++a)
|
2011-12-11 10:08:18 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
if (const_number >= VSVar_Loc[a].reg && const_number < ( VSVar_Loc[a].reg + VSVar_Loc[a].size))
|
|
|
|
{
|
|
|
|
unsigned int offset = const_number - VSVar_Loc[a].reg;
|
|
|
|
SetVSConstant4fvByName(VSVar_Loc[a].name, offset, f);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-11 10:08:18 +00:00
|
|
|
}
|
2011-01-29 20:16:51 +00:00
|
|
|
}
|
|
|
|
|
2012-12-24 17:09:52 +00:00
|
|
|
void Renderer::SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
|
2011-01-29 20:16:51 +00:00
|
|
|
{
|
2011-12-09 23:30:05 +00:00
|
|
|
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
|
|
|
{
|
2011-12-11 10:11:57 +00:00
|
|
|
ProgramShaderCache::SetMultiVSConstant4fv(const_number, f, count);
|
2011-12-10 14:07:13 +00:00
|
|
|
return;
|
2011-12-09 23:30:05 +00:00
|
|
|
}
|
2011-12-26 05:15:54 +00:00
|
|
|
for (unsigned int a = 0; a < 9; ++a)
|
2011-12-11 10:08:18 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
if (const_number >= VSVar_Loc[a].reg && const_number < ( VSVar_Loc[a].reg + VSVar_Loc[a].size))
|
|
|
|
{
|
|
|
|
unsigned int offset = const_number - VSVar_Loc[a].reg;
|
|
|
|
SetVSConstant4fvByName(VSVar_Loc[a].name, offset, f, count);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-11 10:08:18 +00:00
|
|
|
}
|
2011-01-29 20:16:51 +00:00
|
|
|
}
|
|
|
|
|
2012-12-24 17:09:52 +00:00
|
|
|
void Renderer::SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f)
|
2011-12-01 03:00:21 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
float buf[4 * C_VENVCONST_END];
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
buf[4*i ] = *f++;
|
|
|
|
buf[4*i+1] = *f++;
|
|
|
|
buf[4*i+2] = *f++;
|
|
|
|
buf[4*i+3] = 0.f;
|
|
|
|
}
|
2011-12-09 23:30:05 +00:00
|
|
|
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
|
|
|
{
|
2011-12-11 10:11:57 +00:00
|
|
|
ProgramShaderCache::SetMultiVSConstant4fv(const_number, buf, count);
|
2011-12-10 14:07:13 +00:00
|
|
|
return;
|
2011-12-09 23:30:05 +00:00
|
|
|
}
|
2011-12-26 05:15:54 +00:00
|
|
|
for (unsigned int a = 0; a < 9; ++a)
|
2011-12-11 10:08:18 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
if (const_number >= VSVar_Loc[a].reg && const_number < ( VSVar_Loc[a].reg + VSVar_Loc[a].size))
|
|
|
|
{
|
|
|
|
unsigned int offset = const_number - VSVar_Loc[a].reg;
|
|
|
|
SetVSConstant4fvByName(VSVar_Loc[a].name, offset, buf, count);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-11 10:08:18 +00:00
|
|
|
}
|
2011-12-01 03:00:21 +00:00
|
|
|
}
|
|
|
|
|
2011-01-31 01:28:32 +00:00
|
|
|
} // namespace OGL
|