fix formatting uglies introduced in glsl-master branch

This commit is contained in:
Shawn Hoffman 2011-12-26 00:15:54 -05:00
parent f59063c8e7
commit 4bc14c3473
15 changed files with 1069 additions and 1054 deletions

View File

@ -112,7 +112,7 @@ protected:
void Event_ProgressiveScan(wxCommandEvent &ev)
{
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();
}

View File

@ -508,6 +508,7 @@ const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
sprintf(result, " : register(%s%d)", prefix, num);
return result;
}
const char* WriteBinding(API_TYPE ApiType, const u32 num)
{
if (ApiType != API_GLSL || !g_ActiveConfig.backend_info.bSupportsGLSLBinding)
@ -516,6 +517,7 @@ const char* WriteBinding(API_TYPE ApiType, const u32 num)
sprintf(result, "layout(binding = %d) ", num);
return result;
}
const char *WriteLocation(API_TYPE ApiType)
{
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
@ -1339,7 +1341,8 @@ static const char *tevFogFuncsTable[] =
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)
{
@ -1377,6 +1380,4 @@ static void WriteFog(char *&p)
}
WRITE(p, " prev.rgb = lerp(prev.rgb,"I_FOG"[0].rgb,fog);\n");
}

View File

@ -66,6 +66,7 @@ u16 GetEncodedSampleCount(u32 format)
default: return 1;
}
}
const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
{
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);
return result;
}
const char *WriteLocation(API_TYPE ApiType)
{
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 halfxb = floor(xb / 2);\n");
WRITE(p, " sampleUv.x = xib + (halfxb * %f);\n", blkW);
WRITE(p, " sampleUv.y = yb + xoff;\n");
WRITE(p, " sampleUv = sampleUv * "I_COLORS"[0].xy;\n");

View File

@ -235,7 +235,6 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
WRITE(p, "};\n");
p = GenerateVSOutputStruct(p, components, ApiType);
if(ApiType == API_GLSL)
@ -277,7 +276,6 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
}
else
{
WRITE(p, "VS_OUTPUT main(\n");
// inputs
@ -306,9 +304,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
}
if (components & VB_HAS_POSMTXIDX) {
if (is_d3d)
{
WRITE(p, " float4 blend_indices : BLENDINDICES,\n");
}
else
WRITE(p, " float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB);
}
@ -603,7 +599,6 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
else
WRITE(p, "return o;\n}\n");
if (text[sizeof(text) - 1] != 0x7C)
PanicAlert("VertexShader generator - buffer too small, canary has been eaten!");
setlocale(LC_NUMERIC, ""); // restore locale

View File

@ -20,7 +20,6 @@
#include "GLUtil.h"
#include <cmath>
#include <assert.h>
#include "Statistics.h"
#include "VideoConfig.h"
@ -65,6 +64,7 @@ GLuint PixelShaderCache::GetColorMatrixProgram()
{
return s_ColorMatrixProgram.glprogid;
}
void PixelShaderCache::Init()
{
ShaderEnabled = true;
@ -355,8 +355,6 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
// Disable Fragment programs and reset the selected Program
void PixelShaderCache::DisableShader()
{
if(g_ActiveConfig.bUseGLSL)
assert(true);
if (ShaderEnabled)
{
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)
{
if(g_ActiveConfig.bUseGLSL)
assert(true);
if (!ShaderEnabled)
{
glEnable(GL_FRAGMENT_PROGRAM_ARB);
@ -381,6 +377,7 @@ void PixelShaderCache::SetCurrentShader(GLuint Shader)
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, CurrentShader);
}
}
// GLSL Specific
bool CompileGLSLPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
{
@ -422,10 +419,12 @@ bool CompileGLSLPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
ps.bGLSL = true;
return true;
}
void SetPSConstant4fvByName(const char * name, unsigned int offset, const float *f, const unsigned int count = 1)
{
PROGRAMSHADER tmp = ProgramShaderCache::GetShaderProgram();
for (int a = 0; a < NUM_UNIFORMS; ++a)
{
if (!strcmp(name, UniformNames[a]))
{
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)
{
@ -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)
{
GLenum err = GL_REPORT_ERROR();
@ -576,6 +576,7 @@ bool CompileCGPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
return true;
}
void SetCGPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float 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)
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f);
}
// Renderer functions
void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{

View File

@ -18,9 +18,9 @@
#include "ProgramShaderCache.h"
#include "MathUtil.h"
#include <assert.h>
namespace OGL
{
GLuint ProgramShaderCache::CurrentFShader = 0, ProgramShaderCache::CurrentVShader = 0, ProgramShaderCache::CurrentProgram = 0;
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
GLuint ProgramShaderCache::s_ps_vs_ubo;
@ -30,7 +30,8 @@ namespace OGL
GLenum ProgramFormat;
std::pair<u32, u32> ProgramShaderCache::CurrentShaderProgram;
const char *UniformNames[NUM_UNIFORMS] = {
const char *UniformNames[NUM_UNIFORMS] =
{
// SAMPLERS
"samp0","samp1","samp2","samp3","samp4","samp5","samp6","samp7",
// PIXEL SHADER UNIFORMS
@ -65,7 +66,8 @@ namespace OGL
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
{
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);
}
@ -73,13 +75,15 @@ namespace OGL
// Once we move up to a newer version of GLSL, ~1.30
// 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);
// Got to do it this crappy way.
if (!g_ActiveConfig.backend_info.bSupportsGLSLUBO)
for (int a = 8; a < NUM_UNIFORMS; ++a)
entry.program.UniformLocations[a] = glGetUniformLocation(entry.program.glprogid, UniformNames[a]);
if (!g_ActiveConfig.backend_info.bSupportsGLSLBinding)
{
for (int a = 0; a < 8; ++a)
{
// 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)
glUniform1i(entry.program.UniformLocations[a], a);
}
}
// 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_NORM2_ATTRIB, "rawnorm2");
glBindAttribLocation(entry.program.glprogid, SHADER_POSMTX_ATTRIB, "fposmtx");
}
}
void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
{
PROGRAMUID uid;
CurrentFShader = PS;
CurrentVShader = VS;
GetProgramShaderId(&uid, CurrentVShader, CurrentFShader);
if (uid.uid.id == 0)
@ -126,6 +130,7 @@ namespace OGL
CurrentProgram = entry.program.glprogid;
return;
}
PCacheEntry entry;
entry.program.vsid = CurrentVShader;
entry.program.psid = CurrentFShader;
@ -138,6 +143,7 @@ namespace OGL
glAttachShader(entry.program.glprogid, entry.program.vsid);
glAttachShader(entry.program.glprogid, entry.program.psid);
#ifdef GLEW_VERSION_4_0
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
glProgramParameteri(entry.program.glprogid, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
@ -166,12 +172,16 @@ namespace OGL
count * sizeof(float) * 4, f);
}
GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; }
GLuint ProgramShaderCache::GetCurrentProgram(void)
{
return CurrentProgram;
}
PROGRAMSHADER ProgramShaderCache::GetShaderProgram(void)
{
return pshaders[CurrentShaderProgram].program;
}
void ProgramShaderCache::Init(void)
{
// 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, 2, s_ps_vs_ubo, s_vs_data_offset, vs_data_size);
}
#ifdef GLEW_VERSION_4_0
// Read our shader cache, only if supported
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
@ -214,7 +225,8 @@ namespace OGL
GLint *Formats = new GLint[Supported];
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;
}
#endif
@ -244,7 +256,8 @@ namespace OGL
s_ps_vs_ubo = 0;
}
}
}
} // namespace OGL
void GetProgramShaderId(PROGRAMUID *uid, GLuint _v, GLuint _p)
{

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"
@ -30,7 +29,8 @@
union PID
{
struct {
struct
{
GLuint vsid, psid;
};
u64 id;
@ -39,7 +39,6 @@
class PROGRAMUID
{
public:
PID uid;
PROGRAMUID()
@ -51,33 +50,39 @@ 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
// 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
@ -89,6 +94,7 @@ struct PROGRAMSHADER
return NULL;
#endif
}
GLint Size()
{
#ifdef GLEW_VERSION_4_0
@ -101,7 +107,6 @@ struct PROGRAMSHADER
}
};
class ProgramShaderCache
{
struct PCacheEntry
@ -109,14 +114,18 @@ 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();
@ -173,9 +182,6 @@ public:
static void Init(void);
static void Shutdown(void);
};
} // namespace OGL
#endif

View File

@ -16,7 +16,6 @@
// http://code.google.com/p/dolphin-emu/
#include <math.h>
#include <assert.h>
#include "Globals.h"
#include "VideoConfig.h"
@ -94,7 +93,6 @@ void VertexShaderCache::Shutdown()
vshaders.clear();
}
VERTEXSHADER* VertexShaderCache::SetShader(u32 components)
{
VERTEXSHADERUID uid;
@ -156,8 +154,6 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
void VertexShaderCache::DisableShader()
{
if(g_ActiveConfig.bUseGLSL)
assert(true);
if (ShaderEnabled)
{
glDisable(GL_VERTEX_PROGRAM_ARB);
@ -165,11 +161,8 @@ void VertexShaderCache::DisableShader()
}
}
void VertexShaderCache::SetCurrentShader(GLuint Shader)
{
if(g_ActiveConfig.bUseGLSL)
assert(true);
if (!ShaderEnabled)
{
glEnable(GL_VERTEX_PROGRAM_ARB);
@ -182,6 +175,7 @@ void VertexShaderCache::SetCurrentShader(GLuint Shader)
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, CurrentShader);
}
}
// GLSL Specific
bool CompileGLSLVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
{
@ -223,10 +217,12 @@ bool CompileGLSLVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
vs.bGLSL = true;
return true;
}
void SetVSConstant4fvByName(const char * name, unsigned int offset, const float *f, const unsigned int count = 1)
{
PROGRAMSHADER tmp = ProgramShaderCache::GetShaderProgram();
for (int a = 0; a < NUM_UNIFORMS; ++a)
{
if (!strcmp(name, UniformNames[a]))
{
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)
{
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);
}
} // namespace OGL