2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2009-02-23 06:15:48 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#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;
|
|
|
|
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-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
|