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 "Globals.h"
|
|
|
|
|
|
|
|
#include "GLUtil.h"
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include "Statistics.h"
|
2009-09-13 09:23:30 +00:00
|
|
|
#include "VideoConfig.h"
|
2009-02-23 06:15:48 +00:00
|
|
|
#include "ImageWrite.h"
|
|
|
|
#include "Common.h"
|
|
|
|
#include "Render.h"
|
|
|
|
#include "VertexShaderGen.h"
|
2011-12-01 03:00:21 +00:00
|
|
|
#include "ProgramShaderCache.h"
|
2009-02-23 06:15:48 +00:00
|
|
|
#include "PixelShaderManager.h"
|
2011-12-11 11:15:08 +00:00
|
|
|
#include "OnScreenDisplay.h"
|
|
|
|
#include "StringUtil.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 SetPSConstant4fvByName(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;
|
2013-08-23 15:52:47 +00:00
|
|
|
else if (tmp.shader.UniformSize[a] <= offset)
|
|
|
|
return;
|
2011-12-26 05:15:54 +00:00
|
|
|
else
|
|
|
|
{
|
2013-08-23 15:52:47 +00:00
|
|
|
unsigned int maxcount= tmp.shader.UniformSize[a]-offset;
|
|
|
|
glUniform4fv(tmp.shader.UniformLocations[a] + offset, std::min(count, maxcount), 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-10 13:38:30 +00:00
|
|
|
|
2012-12-24 17:09:52 +00:00
|
|
|
// Renderer functions
|
|
|
|
void Renderer::SetPSConstant4f(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 f[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::SetMultiPSConstant4fv(const_number, f, 1);
|
|
|
|
return;
|
2011-12-09 23:30:05 +00:00
|
|
|
}
|
2011-12-26 05:15:54 +00:00
|
|
|
for (unsigned int a = 0; a < 10; ++a)
|
2011-12-11 10:08:18 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
if (const_number >= PSVar_Loc[a].reg && const_number < (PSVar_Loc[a].reg + PSVar_Loc[a].size))
|
|
|
|
{
|
|
|
|
unsigned int offset = const_number - PSVar_Loc[a].reg;
|
|
|
|
SetPSConstant4fvByName(PSVar_Loc[a].name, offset, f);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-11 10:08:18 +00:00
|
|
|
}
|
2011-12-01 03:00:21 +00:00
|
|
|
}
|
|
|
|
|
2012-12-24 17:09:52 +00:00
|
|
|
void Renderer::SetPSConstant4fv(unsigned int const_number, const float *f)
|
2011-12-01 03:00:21 +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::SetMultiPSConstant4fv(const_number, f, 1);
|
|
|
|
return;
|
2011-12-09 23:30:05 +00:00
|
|
|
}
|
2011-12-26 05:15:54 +00:00
|
|
|
for (unsigned int a = 0; a < 10; ++a)
|
2011-12-11 10:08:18 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
if (const_number >= PSVar_Loc[a].reg && const_number < (PSVar_Loc[a].reg + PSVar_Loc[a].size))
|
|
|
|
{
|
|
|
|
unsigned int offset = const_number - PSVar_Loc[a].reg;
|
|
|
|
SetPSConstant4fvByName(PSVar_Loc[a].name, offset, f);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-11 10:08:18 +00:00
|
|
|
}
|
2011-12-01 03:00:21 +00:00
|
|
|
}
|
|
|
|
|
2012-12-24 17:09:52 +00:00
|
|
|
void Renderer::SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
|
2011-12-01 03:00:21 +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::SetMultiPSConstant4fv(const_number, f, count);
|
|
|
|
return;
|
2011-12-09 23:30:05 +00:00
|
|
|
}
|
2011-12-26 05:15:54 +00:00
|
|
|
for (unsigned int a = 0; a < 10; ++a)
|
2011-12-11 10:08:18 +00:00
|
|
|
{
|
2011-12-26 05:15:54 +00:00
|
|
|
if (const_number >= PSVar_Loc[a].reg && const_number < (PSVar_Loc[a].reg + PSVar_Loc[a].size))
|
|
|
|
{
|
|
|
|
unsigned int offset = const_number - PSVar_Loc[a].reg;
|
|
|
|
SetPSConstant4fvByName(PSVar_Loc[a].name, offset, f, 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
|