mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-22 03:57:17 +01:00
fix formatting uglies introduced in glsl-master branch
This commit is contained in:
parent
4a4833e617
commit
31a8424bcc
@ -112,7 +112,7 @@ protected:
|
|||||||
void Event_ProgressiveScan(wxCommandEvent &ev)
|
void Event_ProgressiveScan(wxCommandEvent &ev)
|
||||||
{
|
{
|
||||||
SConfig::GetInstance().m_SYSCONF->SetData("IPL.PGS", ev.GetInt());
|
SConfig::GetInstance().m_SYSCONF->SetData("IPL.PGS", ev.GetInt());
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressive = ev.GetInt();
|
SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressive = !!ev.GetInt();
|
||||||
|
|
||||||
ev.Skip();
|
ev.Skip();
|
||||||
}
|
}
|
||||||
|
@ -517,6 +517,7 @@ const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
|
|||||||
sprintf(result, " : register(%s%d)", prefix, num);
|
sprintf(result, " : register(%s%d)", prefix, num);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* WriteBinding(API_TYPE ApiType, const u32 num)
|
const char* WriteBinding(API_TYPE ApiType, const u32 num)
|
||||||
{
|
{
|
||||||
if (ApiType != API_GLSL || !g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
if (ApiType != API_GLSL || !g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||||
@ -525,6 +526,7 @@ const char* WriteBinding(API_TYPE ApiType, const u32 num)
|
|||||||
sprintf(result, "layout(binding = %d) ", num);
|
sprintf(result, "layout(binding = %d) ", num);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *WriteLocation(API_TYPE ApiType)
|
const char *WriteLocation(API_TYPE ApiType)
|
||||||
{
|
{
|
||||||
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||||
@ -1386,6 +1388,7 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
|
|||||||
I_ALPHA"[0].g"
|
I_ALPHA"[0].g"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// using discard then return works the same in cg and dx9 but not in dx11
|
// using discard then return works the same in cg and dx9 but not in dx11
|
||||||
WRITE(p, "if(!( ");
|
WRITE(p, "if(!( ");
|
||||||
|
|
||||||
@ -1399,9 +1402,9 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
|
|||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
WRITE(p, ")) {\n");
|
WRITE(p, ")) {\n");
|
||||||
|
|
||||||
WRITE(p, "ocol0 = float4(0);\n");
|
WRITE(p, "ocol0 = float4(0.0f);\n");
|
||||||
if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
|
if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
|
||||||
WRITE(p, "ocol1 = 0;\n");
|
WRITE(p, "ocol1 = float4(0.0f);\n");
|
||||||
if (DepthTextureEnable)
|
if (DepthTextureEnable)
|
||||||
WRITE(p, "depth = 1.f;\n");
|
WRITE(p, "depth = 1.f;\n");
|
||||||
|
|
||||||
@ -1426,13 +1429,6 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
|
|||||||
|
|
||||||
WRITE(p, "}\n");
|
WRITE(p, "}\n");
|
||||||
|
|
||||||
=======
|
|
||||||
WRITE(p, ")){ocol0 = float4(0.0f);%s%s discard;%s}\n",
|
|
||||||
dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "ocol1 = vec4(0.0f);" : "",
|
|
||||||
DepthTextureEnable ? "depth = 1.f;" : "",
|
|
||||||
(ApiType != API_D3D11) ? "return;" : "");
|
|
||||||
return true;
|
|
||||||
>>>>>>> Few compiler errors that got exposed once I got Dual Source Blending working. Seems it isn't working quite 100% either. Good chance I missed something anyway.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *tevFogFuncsTable[] =
|
static const char *tevFogFuncsTable[] =
|
||||||
@ -1449,7 +1445,8 @@ static const char *tevFogFuncsTable[] =
|
|||||||
|
|
||||||
static void WriteFog(char *&p)
|
static void WriteFog(char *&p)
|
||||||
{
|
{
|
||||||
if(bpmem.fog.c_proj_fsel.fsel == 0)return;//no Fog
|
if (bpmem.fog.c_proj_fsel.fsel == 0)
|
||||||
|
return; // no Fog
|
||||||
|
|
||||||
if (bpmem.fog.c_proj_fsel.proj == 0)
|
if (bpmem.fog.c_proj_fsel.proj == 0)
|
||||||
{
|
{
|
||||||
@ -1487,6 +1484,4 @@ static void WriteFog(char *&p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WRITE(p, " prev.rgb = lerp(prev.rgb," I_FOG"[0].rgb,fog);\n");
|
WRITE(p, " prev.rgb = lerp(prev.rgb," I_FOG"[0].rgb,fog);\n");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ u16 GetEncodedSampleCount(u32 format)
|
|||||||
default: return 1;
|
default: return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
|
const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
|
||||||
{
|
{
|
||||||
if (ApiType == API_GLSL)
|
if (ApiType == API_GLSL)
|
||||||
@ -74,6 +75,7 @@ const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
|
|||||||
sprintf(result, " : register(%s%d)", prefix, num);
|
sprintf(result, " : register(%s%d)", prefix, num);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *WriteLocation(API_TYPE ApiType)
|
const char *WriteLocation(API_TYPE ApiType)
|
||||||
{
|
{
|
||||||
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||||
@ -250,7 +252,6 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
|
|||||||
WRITE(p, " float xib = x2 - (xl * %f);\n", blkW);
|
WRITE(p, " float xib = x2 - (xl * %f);\n", blkW);
|
||||||
WRITE(p, " float halfxb = floor(xb / 2);\n");
|
WRITE(p, " float halfxb = floor(xb / 2);\n");
|
||||||
|
|
||||||
|
|
||||||
WRITE(p, " sampleUv.x = xib + (halfxb * %f);\n", blkW);
|
WRITE(p, " sampleUv.x = xib + (halfxb * %f);\n", blkW);
|
||||||
WRITE(p, " sampleUv.y = yb + xoff;\n");
|
WRITE(p, " sampleUv.y = yb + xoff;\n");
|
||||||
WRITE(p, " sampleUv = sampleUv * "I_COLORS"[0].xy;\n");
|
WRITE(p, " sampleUv = sampleUv * "I_COLORS"[0].xy;\n");
|
||||||
|
@ -235,7 +235,6 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
|||||||
WRITE(p, "};\n");
|
WRITE(p, "};\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
p = GenerateVSOutputStruct(p, components, ApiType);
|
p = GenerateVSOutputStruct(p, components, ApiType);
|
||||||
|
|
||||||
if(ApiType == API_GLSL)
|
if(ApiType == API_GLSL)
|
||||||
@ -277,7 +276,6 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
WRITE(p, "VS_OUTPUT main(\n");
|
WRITE(p, "VS_OUTPUT main(\n");
|
||||||
|
|
||||||
// inputs
|
// inputs
|
||||||
@ -306,9 +304,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
|||||||
}
|
}
|
||||||
if (components & VB_HAS_POSMTXIDX) {
|
if (components & VB_HAS_POSMTXIDX) {
|
||||||
if (is_d3d)
|
if (is_d3d)
|
||||||
{
|
|
||||||
WRITE(p, " float4 blend_indices : BLENDINDICES,\n");
|
WRITE(p, " float4 blend_indices : BLENDINDICES,\n");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
WRITE(p, " float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB);
|
WRITE(p, " float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "GLUtil.h"
|
#include "GLUtil.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "Statistics.h"
|
#include "Statistics.h"
|
||||||
#include "VideoConfig.h"
|
#include "VideoConfig.h"
|
||||||
@ -65,6 +64,7 @@ GLuint PixelShaderCache::GetColorMatrixProgram()
|
|||||||
{
|
{
|
||||||
return s_ColorMatrixProgram.glprogid;
|
return s_ColorMatrixProgram.glprogid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelShaderCache::Init()
|
void PixelShaderCache::Init()
|
||||||
{
|
{
|
||||||
ShaderEnabled = true;
|
ShaderEnabled = true;
|
||||||
@ -355,8 +355,6 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
|
|||||||
// Disable Fragment programs and reset the selected Program
|
// Disable Fragment programs and reset the selected Program
|
||||||
void PixelShaderCache::DisableShader()
|
void PixelShaderCache::DisableShader()
|
||||||
{
|
{
|
||||||
if(g_ActiveConfig.bUseGLSL)
|
|
||||||
assert(true);
|
|
||||||
if (ShaderEnabled)
|
if (ShaderEnabled)
|
||||||
{
|
{
|
||||||
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
||||||
@ -364,11 +362,9 @@ void PixelShaderCache::DisableShader()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//bind a program if is diferent from the binded oone
|
// bind a program if is different from the binded oone
|
||||||
void PixelShaderCache::SetCurrentShader(GLuint Shader)
|
void PixelShaderCache::SetCurrentShader(GLuint Shader)
|
||||||
{
|
{
|
||||||
if(g_ActiveConfig.bUseGLSL)
|
|
||||||
assert(true);
|
|
||||||
if (!ShaderEnabled)
|
if (!ShaderEnabled)
|
||||||
{
|
{
|
||||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||||
@ -381,6 +377,7 @@ void PixelShaderCache::SetCurrentShader(GLuint Shader)
|
|||||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, CurrentShader);
|
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, CurrentShader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLSL Specific
|
// GLSL Specific
|
||||||
bool CompileGLSLPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
bool CompileGLSLPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
||||||
{
|
{
|
||||||
@ -422,10 +419,12 @@ bool CompileGLSLPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
|||||||
ps.bGLSL = true;
|
ps.bGLSL = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPSConstant4fvByName(const char * name, unsigned int offset, const float *f, const unsigned int count = 1)
|
void SetPSConstant4fvByName(const char * name, unsigned int offset, const float *f, const unsigned int count = 1)
|
||||||
{
|
{
|
||||||
PROGRAMSHADER tmp = ProgramShaderCache::GetShaderProgram();
|
PROGRAMSHADER tmp = ProgramShaderCache::GetShaderProgram();
|
||||||
for (int a = 0; a < NUM_UNIFORMS; ++a)
|
for (int a = 0; a < NUM_UNIFORMS; ++a)
|
||||||
|
{
|
||||||
if (!strcmp(name, UniformNames[a]))
|
if (!strcmp(name, UniformNames[a]))
|
||||||
{
|
{
|
||||||
if (tmp.UniformLocations[a] == -1)
|
if (tmp.UniformLocations[a] == -1)
|
||||||
@ -437,6 +436,7 @@ void SetPSConstant4fvByName(const char * name, unsigned int offset, const float
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SetGLSLPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
void SetGLSLPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
||||||
{
|
{
|
||||||
@ -493,8 +493,8 @@ void SetMultiGLSLPSConstant4fv(unsigned int const_number, unsigned int count, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CG Specific
|
|
||||||
|
|
||||||
|
// CG Specific
|
||||||
bool CompileCGPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
bool CompileCGPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
||||||
{
|
{
|
||||||
GLenum err = GL_REPORT_ERROR();
|
GLenum err = GL_REPORT_ERROR();
|
||||||
@ -576,6 +576,7 @@ bool CompileCGPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCGPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
void SetCGPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
||||||
{
|
{
|
||||||
float f[4] = { f1, f2, f3, f4 };
|
float f[4] = { f1, f2, f3, f4 };
|
||||||
@ -592,6 +593,7 @@ void SetMultiCGPSConstant4fv(unsigned int const_number, unsigned int count, cons
|
|||||||
for (unsigned int i = 0; i < count; i++,f+=4)
|
for (unsigned int i = 0; i < count; i++,f+=4)
|
||||||
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f);
|
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renderer functions
|
// Renderer functions
|
||||||
void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
||||||
{
|
{
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
#include "ProgramShaderCache.h"
|
#include "ProgramShaderCache.h"
|
||||||
#include "MathUtil.h"
|
#include "MathUtil.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
namespace OGL
|
namespace OGL
|
||||||
{
|
{
|
||||||
|
|
||||||
GLuint ProgramShaderCache::CurrentFShader = 0, ProgramShaderCache::CurrentVShader = 0, ProgramShaderCache::CurrentProgram = 0;
|
GLuint ProgramShaderCache::CurrentFShader = 0, ProgramShaderCache::CurrentVShader = 0, ProgramShaderCache::CurrentProgram = 0;
|
||||||
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
|
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
|
||||||
GLuint ProgramShaderCache::s_ps_vs_ubo;
|
GLuint ProgramShaderCache::s_ps_vs_ubo;
|
||||||
@ -30,7 +30,8 @@ namespace OGL
|
|||||||
GLenum ProgramFormat;
|
GLenum ProgramFormat;
|
||||||
|
|
||||||
std::pair<u32, u32> ProgramShaderCache::CurrentShaderProgram;
|
std::pair<u32, u32> ProgramShaderCache::CurrentShaderProgram;
|
||||||
const char *UniformNames[NUM_UNIFORMS] = {
|
const char *UniformNames[NUM_UNIFORMS] =
|
||||||
|
{
|
||||||
// SAMPLERS
|
// SAMPLERS
|
||||||
"samp0","samp1","samp2","samp3","samp4","samp5","samp6","samp7",
|
"samp0","samp1","samp2","samp3","samp4","samp5","samp6","samp7",
|
||||||
// PIXEL SHADER UNIFORMS
|
// PIXEL SHADER UNIFORMS
|
||||||
@ -65,7 +66,8 @@ namespace OGL
|
|||||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||||
{
|
{
|
||||||
glUniformBlockBinding(entry.program.glprogid, 0, 1);
|
glUniformBlockBinding(entry.program.glprogid, 0, 1);
|
||||||
if(uid.uid.vsid != 0) // Some things have no vertex shader
|
// Some things have no vertex shader
|
||||||
|
if (uid.uid.vsid != 0)
|
||||||
glUniformBlockBinding(entry.program.glprogid, 1, 2);
|
glUniformBlockBinding(entry.program.glprogid, 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,13 +75,15 @@ namespace OGL
|
|||||||
// Once we move up to a newer version of GLSL, ~1.30
|
// Once we move up to a newer version of GLSL, ~1.30
|
||||||
// We can remove this
|
// We can remove this
|
||||||
|
|
||||||
//For some reason this fails on my hardware
|
// (Sonicadvance): For some reason this fails on my hardware
|
||||||
//glGetUniformIndices(entry.program.glprogid, NUM_UNIFORMS, UniformNames, entry.program.UniformLocations);
|
//glGetUniformIndices(entry.program.glprogid, NUM_UNIFORMS, UniformNames, entry.program.UniformLocations);
|
||||||
// Got to do it this crappy way.
|
// Got to do it this crappy way.
|
||||||
if (!g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
if (!g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||||
for (int a = 8; a < NUM_UNIFORMS; ++a)
|
for (int a = 8; a < NUM_UNIFORMS; ++a)
|
||||||
entry.program.UniformLocations[a] = glGetUniformLocation(entry.program.glprogid, UniformNames[a]);
|
entry.program.UniformLocations[a] = glGetUniformLocation(entry.program.glprogid, UniformNames[a]);
|
||||||
|
|
||||||
if (!g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
if (!g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||||
|
{
|
||||||
for (int a = 0; a < 8; ++a)
|
for (int a = 0; a < 8; ++a)
|
||||||
{
|
{
|
||||||
// Still need to get sampler locations since we aren't binding them statically in the shaders
|
// Still need to get sampler locations since we aren't binding them statically in the shaders
|
||||||
@ -87,24 +91,24 @@ namespace OGL
|
|||||||
if (entry.program.UniformLocations[a] != -1)
|
if (entry.program.UniformLocations[a] != -1)
|
||||||
glUniform1i(entry.program.UniformLocations[a], a);
|
glUniform1i(entry.program.UniformLocations[a], a);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Need to get some attribute locations
|
// Need to get some attribute locations
|
||||||
if(uid.uid.vsid != 0 && !g_ActiveConfig.backend_info.bSupportsGLSLATTRBind) // We have no vertex Shader
|
if (uid.uid.vsid != 0 && !g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
|
||||||
{
|
{
|
||||||
|
// We have no vertex Shader
|
||||||
glBindAttribLocation(entry.program.glprogid, SHADER_NORM1_ATTRIB, "rawnorm1");
|
glBindAttribLocation(entry.program.glprogid, SHADER_NORM1_ATTRIB, "rawnorm1");
|
||||||
glBindAttribLocation(entry.program.glprogid, SHADER_NORM2_ATTRIB, "rawnorm2");
|
glBindAttribLocation(entry.program.glprogid, SHADER_NORM2_ATTRIB, "rawnorm2");
|
||||||
glBindAttribLocation(entry.program.glprogid, SHADER_POSMTX_ATTRIB, "fposmtx");
|
glBindAttribLocation(entry.program.glprogid, SHADER_POSMTX_ATTRIB, "fposmtx");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
|
void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
|
||||||
{
|
{
|
||||||
PROGRAMUID uid;
|
PROGRAMUID uid;
|
||||||
CurrentFShader = PS;
|
CurrentFShader = PS;
|
||||||
CurrentVShader = VS;
|
CurrentVShader = VS;
|
||||||
|
|
||||||
|
|
||||||
GetProgramShaderId(&uid, CurrentVShader, CurrentFShader);
|
GetProgramShaderId(&uid, CurrentVShader, CurrentFShader);
|
||||||
|
|
||||||
if (uid.uid.id == 0)
|
if (uid.uid.id == 0)
|
||||||
@ -126,6 +130,7 @@ namespace OGL
|
|||||||
CurrentProgram = entry.program.glprogid;
|
CurrentProgram = entry.program.glprogid;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PCacheEntry entry;
|
PCacheEntry entry;
|
||||||
entry.program.vsid = CurrentVShader;
|
entry.program.vsid = CurrentVShader;
|
||||||
entry.program.psid = CurrentFShader;
|
entry.program.psid = CurrentFShader;
|
||||||
@ -138,6 +143,7 @@ namespace OGL
|
|||||||
glAttachShader(entry.program.glprogid, entry.program.vsid);
|
glAttachShader(entry.program.glprogid, entry.program.vsid);
|
||||||
|
|
||||||
glAttachShader(entry.program.glprogid, entry.program.psid);
|
glAttachShader(entry.program.glprogid, entry.program.psid);
|
||||||
|
|
||||||
#ifdef GLEW_VERSION_4_0
|
#ifdef GLEW_VERSION_4_0
|
||||||
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
||||||
glProgramParameteri(entry.program.glprogid, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
|
glProgramParameteri(entry.program.glprogid, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
|
||||||
@ -166,12 +172,16 @@ namespace OGL
|
|||||||
count * sizeof(float) * 4, f);
|
count * sizeof(float) * 4, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; }
|
GLuint ProgramShaderCache::GetCurrentProgram(void)
|
||||||
|
{
|
||||||
|
return CurrentProgram;
|
||||||
|
}
|
||||||
|
|
||||||
PROGRAMSHADER ProgramShaderCache::GetShaderProgram(void)
|
PROGRAMSHADER ProgramShaderCache::GetShaderProgram(void)
|
||||||
{
|
{
|
||||||
return pshaders[CurrentShaderProgram].program;
|
return pshaders[CurrentShaderProgram].program;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramShaderCache::Init(void)
|
void ProgramShaderCache::Init(void)
|
||||||
{
|
{
|
||||||
// We have to get the UBO alignment here because
|
// We have to get the UBO alignment here because
|
||||||
@ -199,6 +209,7 @@ namespace OGL
|
|||||||
glBindBufferRange(GL_UNIFORM_BUFFER, 1, s_ps_vs_ubo, 0, ps_data_size);
|
glBindBufferRange(GL_UNIFORM_BUFFER, 1, s_ps_vs_ubo, 0, ps_data_size);
|
||||||
glBindBufferRange(GL_UNIFORM_BUFFER, 2, s_ps_vs_ubo, s_vs_data_offset, vs_data_size);
|
glBindBufferRange(GL_UNIFORM_BUFFER, 2, s_ps_vs_ubo, s_vs_data_offset, vs_data_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GLEW_VERSION_4_0
|
#ifdef GLEW_VERSION_4_0
|
||||||
// Read our shader cache, only if supported
|
// Read our shader cache, only if supported
|
||||||
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
||||||
@ -214,7 +225,8 @@ namespace OGL
|
|||||||
|
|
||||||
GLint *Formats = new GLint[Supported];
|
GLint *Formats = new GLint[Supported];
|
||||||
glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, Formats);
|
glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, Formats);
|
||||||
ProgramFormat = (GLenum)Formats[0]; // We don't really care about format
|
// We don't really care about format
|
||||||
|
ProgramFormat = (GLenum)Formats[0];
|
||||||
delete[] Formats;
|
delete[] Formats;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -244,7 +256,8 @@ namespace OGL
|
|||||||
s_ps_vs_ubo = 0;
|
s_ps_vs_ubo = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // namespace OGL
|
||||||
|
|
||||||
void GetProgramShaderId(PROGRAMUID *uid, GLuint _v, GLuint _p)
|
void GetProgramShaderId(PROGRAMUID *uid, GLuint _v, GLuint _p)
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#ifndef _ProgramShaderCache_H_
|
#pragma once
|
||||||
#define _ProgramShaderCache_H_
|
|
||||||
|
|
||||||
#include "GLUtil.h"
|
#include "GLUtil.h"
|
||||||
|
|
||||||
@ -30,7 +29,8 @@
|
|||||||
|
|
||||||
union PID
|
union PID
|
||||||
{
|
{
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
GLuint vsid, psid;
|
GLuint vsid, psid;
|
||||||
};
|
};
|
||||||
u64 id;
|
u64 id;
|
||||||
@ -39,7 +39,6 @@
|
|||||||
class PROGRAMUID
|
class PROGRAMUID
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PID uid;
|
PID uid;
|
||||||
|
|
||||||
PROGRAMUID()
|
PROGRAMUID()
|
||||||
@ -51,33 +50,39 @@ public:
|
|||||||
{
|
{
|
||||||
uid.id = r.uid.id;
|
uid.id = r.uid.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
PROGRAMUID(GLuint _v, GLuint _p)
|
PROGRAMUID(GLuint _v, GLuint _p)
|
||||||
{
|
{
|
||||||
uid.vsid = _v;
|
uid.vsid = _v;
|
||||||
uid.psid = _p;
|
uid.psid = _p;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetNumValues() const
|
u64 GetNumValues() const
|
||||||
{
|
{
|
||||||
return uid.id;
|
return uid.id;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void GetProgramShaderId(PROGRAMUID *uid, GLuint _v, GLuint _p);
|
void GetProgramShaderId(PROGRAMUID *uid, GLuint _v, GLuint _p);
|
||||||
|
|
||||||
namespace OGL
|
namespace OGL
|
||||||
{
|
{
|
||||||
#define NUM_UNIFORMS 27
|
|
||||||
|
const int NUM_UNIFORMS = 27;
|
||||||
extern const char *UniformNames[NUM_UNIFORMS];
|
extern const char *UniformNames[NUM_UNIFORMS];
|
||||||
extern GLenum ProgramFormat;
|
extern GLenum ProgramFormat;
|
||||||
|
|
||||||
struct PROGRAMSHADER
|
struct PROGRAMSHADER
|
||||||
{
|
{
|
||||||
PROGRAMSHADER() : glprogid(0), vsid(0), psid(0), binaryLength(0) {}
|
PROGRAMSHADER() : glprogid(0), vsid(0), psid(0), binaryLength(0) {}
|
||||||
GLuint glprogid; // opengl program id
|
// opengl program id
|
||||||
|
GLuint glprogid;
|
||||||
GLuint vsid, psid;
|
GLuint vsid, psid;
|
||||||
PROGRAMUID uid;
|
PROGRAMUID uid;
|
||||||
GLint UniformLocations[NUM_UNIFORMS];
|
GLint UniformLocations[NUM_UNIFORMS];
|
||||||
GLint binaryLength;
|
GLint binaryLength;
|
||||||
|
|
||||||
|
// TODO at first glance looks bad - malloc/no free/pointer not saved in instance...
|
||||||
u8 *Data()
|
u8 *Data()
|
||||||
{
|
{
|
||||||
#ifdef GLEW_VERSION_4_0
|
#ifdef GLEW_VERSION_4_0
|
||||||
@ -89,6 +94,7 @@ struct PROGRAMSHADER
|
|||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint Size()
|
GLint Size()
|
||||||
{
|
{
|
||||||
#ifdef GLEW_VERSION_4_0
|
#ifdef GLEW_VERSION_4_0
|
||||||
@ -101,7 +107,6 @@ struct PROGRAMSHADER
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ProgramShaderCache
|
class ProgramShaderCache
|
||||||
{
|
{
|
||||||
struct PCacheEntry
|
struct PCacheEntry
|
||||||
@ -109,14 +114,18 @@ class ProgramShaderCache
|
|||||||
PROGRAMSHADER program;
|
PROGRAMSHADER program;
|
||||||
int frameCount;
|
int frameCount;
|
||||||
PCacheEntry() : frameCount(0) {}
|
PCacheEntry() : frameCount(0) {}
|
||||||
void Destroy() {
|
|
||||||
|
void Destroy()
|
||||||
|
{
|
||||||
glDeleteProgram(program.glprogid);
|
glDeleteProgram(program.glprogid);
|
||||||
program.glprogid = 0;
|
program.glprogid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* Data()
|
u8* Data()
|
||||||
{
|
{
|
||||||
return program.Data();
|
return program.Data();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint Size()
|
GLint Size()
|
||||||
{
|
{
|
||||||
return program.Size();
|
return program.Size();
|
||||||
@ -173,9 +182,6 @@ public:
|
|||||||
|
|
||||||
static void Init(void);
|
static void Init(void);
|
||||||
static void Shutdown(void);
|
static void Shutdown(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OGL
|
} // namespace OGL
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "VideoConfig.h"
|
#include "VideoConfig.h"
|
||||||
@ -94,7 +93,6 @@ void VertexShaderCache::Shutdown()
|
|||||||
vshaders.clear();
|
vshaders.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VERTEXSHADER* VertexShaderCache::SetShader(u32 components)
|
VERTEXSHADER* VertexShaderCache::SetShader(u32 components)
|
||||||
{
|
{
|
||||||
VERTEXSHADERUID uid;
|
VERTEXSHADERUID uid;
|
||||||
@ -156,8 +154,6 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
|||||||
|
|
||||||
void VertexShaderCache::DisableShader()
|
void VertexShaderCache::DisableShader()
|
||||||
{
|
{
|
||||||
if(g_ActiveConfig.bUseGLSL)
|
|
||||||
assert(true);
|
|
||||||
if (ShaderEnabled)
|
if (ShaderEnabled)
|
||||||
{
|
{
|
||||||
glDisable(GL_VERTEX_PROGRAM_ARB);
|
glDisable(GL_VERTEX_PROGRAM_ARB);
|
||||||
@ -165,11 +161,8 @@ void VertexShaderCache::DisableShader()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VertexShaderCache::SetCurrentShader(GLuint Shader)
|
void VertexShaderCache::SetCurrentShader(GLuint Shader)
|
||||||
{
|
{
|
||||||
if(g_ActiveConfig.bUseGLSL)
|
|
||||||
assert(true);
|
|
||||||
if (!ShaderEnabled)
|
if (!ShaderEnabled)
|
||||||
{
|
{
|
||||||
glEnable(GL_VERTEX_PROGRAM_ARB);
|
glEnable(GL_VERTEX_PROGRAM_ARB);
|
||||||
@ -182,6 +175,7 @@ void VertexShaderCache::SetCurrentShader(GLuint Shader)
|
|||||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, CurrentShader);
|
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, CurrentShader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLSL Specific
|
// GLSL Specific
|
||||||
bool CompileGLSLVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
|
bool CompileGLSLVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
|
||||||
{
|
{
|
||||||
@ -223,10 +217,12 @@ bool CompileGLSLVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
|
|||||||
vs.bGLSL = true;
|
vs.bGLSL = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetVSConstant4fvByName(const char * name, unsigned int offset, const float *f, const unsigned int count = 1)
|
void SetVSConstant4fvByName(const char * name, unsigned int offset, const float *f, const unsigned int count = 1)
|
||||||
{
|
{
|
||||||
PROGRAMSHADER tmp = ProgramShaderCache::GetShaderProgram();
|
PROGRAMSHADER tmp = ProgramShaderCache::GetShaderProgram();
|
||||||
for (int a = 0; a < NUM_UNIFORMS; ++a)
|
for (int a = 0; a < NUM_UNIFORMS; ++a)
|
||||||
|
{
|
||||||
if (!strcmp(name, UniformNames[a]))
|
if (!strcmp(name, UniformNames[a]))
|
||||||
{
|
{
|
||||||
if (tmp.UniformLocations[a] == -1)
|
if (tmp.UniformLocations[a] == -1)
|
||||||
@ -238,6 +234,8 @@ void SetVSConstant4fvByName(const char * name, unsigned int offset, const float
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SetGLSLVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
void SetGLSLVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
||||||
{
|
{
|
||||||
float const buf[4] = {f1, f2, f3, f4};
|
float const buf[4] = {f1, f2, f3, f4};
|
||||||
@ -457,5 +455,4 @@ void Renderer::SetMultiVSConstant3fv(unsigned int const_number, unsigned int cou
|
|||||||
pSetMultiVSConstant3fv(const_number, count, f);
|
pSetMultiVSConstant3fv(const_number, count, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace OGL
|
} // namespace OGL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user