fix formatting uglies introduced in glsl-master branch

This commit is contained in:
Shawn Hoffman
2011-12-26 00:15:54 -05:00
committed by Sonicadvance1
parent 4a4833e617
commit 31a8424bcc
15 changed files with 1061 additions and 1051 deletions

View File

@ -15,8 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _ProgramShaderCache_H_
#define _ProgramShaderCache_H_
#pragma once
#include "GLUtil.h"
@ -28,18 +27,18 @@
#include "LinearDiskCache.h"
#include "ConfigManager.h"
union PID
union PID
{
struct
{
struct {
GLuint vsid, psid;
};
u64 id;
};
u64 id;
};
class PROGRAMUID
{
public:
PID uid;
PROGRAMUID()
@ -51,57 +50,63 @@ public:
{
uid.id = r.uid.id;
}
PROGRAMUID(GLuint _v, GLuint _p)
{
uid.vsid = _v;
uid.psid = _p;
}
int GetNumValues() const
u64 GetNumValues() const
{
return uid.id;
}
};
void GetProgramShaderId(PROGRAMUID *uid, GLuint _v, GLuint _p);
namespace OGL
{
#define NUM_UNIFORMS 27
const int NUM_UNIFORMS = 27;
extern const char *UniformNames[NUM_UNIFORMS];
extern GLenum ProgramFormat;
struct PROGRAMSHADER
{
PROGRAMSHADER() : glprogid(0), vsid(0), psid(0), binaryLength(0){}
GLuint glprogid; // opengl program id
PROGRAMSHADER() : glprogid(0), vsid(0), psid(0), binaryLength(0) {}
// opengl program id
GLuint glprogid;
GLuint vsid, psid;
PROGRAMUID uid;
GLint UniformLocations[NUM_UNIFORMS];
GLint binaryLength;
// TODO at first glance looks bad - malloc/no free/pointer not saved in instance...
u8 *Data()
{
#ifdef GLEW_VERSION_4_0
#ifdef GLEW_VERSION_4_0
glGetProgramiv(glprogid, GL_PROGRAM_BINARY_LENGTH, &binaryLength);
u8* binary = (u8*)malloc(binaryLength);
glGetProgramBinary(glprogid, binaryLength, NULL, &ProgramFormat, binary);
return binary;
#else
return NULL;
#endif
u8* binary = (u8*)malloc(binaryLength);
glGetProgramBinary(glprogid, binaryLength, NULL, &ProgramFormat, binary);
return binary;
#else
return NULL;
#endif
}
GLint Size()
{
#ifdef GLEW_VERSION_4_0
if(!binaryLength)
#ifdef GLEW_VERSION_4_0
if (!binaryLength)
glGetProgramiv(glprogid, GL_PROGRAM_BINARY_LENGTH, &binaryLength);
return binaryLength;
#else
#else
return 0;
#endif
#endif
}
};
class ProgramShaderCache
{
struct PCacheEntry
@ -109,50 +114,54 @@ class ProgramShaderCache
PROGRAMSHADER program;
int frameCount;
PCacheEntry() : frameCount(0) {}
void Destroy() {
void Destroy()
{
glDeleteProgram(program.glprogid);
program.glprogid = 0;
}
u8* Data()
{
return program.Data();
}
GLint Size()
{
return program.Size();
}
};
class ProgramShaderCacheInserter : public LinearDiskCacheReader<PROGRAMUID, u8>
{
public:
void Read(const PROGRAMUID &key, const u8 *value, u32 value_size)
public:
void Read(const PROGRAMUID &key, const u8 *value, u32 value_size)
{
#ifdef GLEW_VERSION_4_0
PCacheEntry entry;
// The two shaders might not even exist anymore
// But it is fine, no need to worry about that
entry.program.vsid = key.uid.vsid;
entry.program.psid = key.uid.psid;
entry.program.glprogid = glCreateProgram();
glProgramBinary(entry.program.glprogid, ProgramFormat, value, value_size);
GLint success;
glGetProgramiv(entry.program.glprogid, GL_LINK_STATUS, &success);
if (success)
{
#ifdef GLEW_VERSION_4_0
PCacheEntry entry;
// The two shaders might not even exist anymore
// But it is fine, no need to worry about that
entry.program.vsid = key.uid.vsid;
entry.program.psid = key.uid.psid;
entry.program.glprogid = glCreateProgram();
glProgramBinary(entry.program.glprogid, ProgramFormat, value, value_size);
GLint success;
glGetProgramiv(entry.program.glprogid, GL_LINK_STATUS, &success);
if (success)
{
pshaders[std::make_pair(key.uid.psid, key.uid.vsid)] = entry;
glUseProgram(entry.program.glprogid);
SetProgramVariables(entry, key);
}
#endif
pshaders[std::make_pair(key.uid.psid, key.uid.vsid)] = entry;
glUseProgram(entry.program.glprogid);
SetProgramVariables(entry, key);
}
#endif
}
};
typedef std::map<std::pair<u32, u32>, PCacheEntry> PCache;
static PCache pshaders;
@ -162,7 +171,7 @@ class ProgramShaderCache
static GLuint s_ps_vs_ubo;
static GLintptr s_vs_data_offset;
static void SetProgramVariables(PCacheEntry &entry, const PROGRAMUID &uid);
public:
static PROGRAMSHADER GetShaderProgram(void);
static void SetBothShaders(GLuint PS, GLuint VS);
@ -170,12 +179,9 @@ public:
static void SetMultiPSConstant4fv(unsigned int offset, const float *f, unsigned int count);
static void SetMultiVSConstant4fv(unsigned int offset, const float *f, unsigned int count);
static void Init(void);
static void Shutdown(void);
};
} // namespace OGL
#endif