mah
This commit is contained in:
parent
411357b54a
commit
7a4c080c70
|
@ -20,6 +20,7 @@
|
||||||
#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"
|
||||||
|
@ -234,7 +235,8 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 comp
|
||||||
// Make an entry in the table
|
// Make an entry in the table
|
||||||
PSCacheEntry& newentry = PixelShaders[uid];
|
PSCacheEntry& newentry = PixelShaders[uid];
|
||||||
last_entry = &newentry;
|
last_entry = &newentry;
|
||||||
const char *code = GeneratePixelShaderCode(dstAlphaMode, API_OPENGL, components);
|
newentry.shader.bGLSL = g_ActiveConfig.bUseGLSL;
|
||||||
|
const char *code = GeneratePixelShaderCode(dstAlphaMode, g_ActiveConfig.bUseGLSL ? API_GLSL : API_OPENGL, components);
|
||||||
|
|
||||||
if (g_ActiveConfig.bEnableShaderDebugging && code)
|
if (g_ActiveConfig.bEnableShaderDebugging && code)
|
||||||
{
|
{
|
||||||
|
@ -271,6 +273,8 @@ 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);
|
||||||
|
@ -281,6 +285,8 @@ void PixelShaderCache::DisableShader()
|
||||||
//bind a program if is diferent from the binded oone
|
//bind a program if is diferent 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);
|
||||||
|
|
|
@ -29,16 +29,21 @@ namespace OGL
|
||||||
|
|
||||||
struct FRAGMENTSHADER
|
struct FRAGMENTSHADER
|
||||||
{
|
{
|
||||||
FRAGMENTSHADER() : glprogid(0) { }
|
FRAGMENTSHADER() : glprogid(0), bGLSL(0) { }
|
||||||
void Destroy()
|
void Destroy()
|
||||||
{
|
{
|
||||||
if (glprogid)
|
if (glprogid)
|
||||||
{
|
{
|
||||||
glDeleteProgramsARB(1, &glprogid);
|
if(bGLSL)
|
||||||
|
glDeleteShader(glprogid);
|
||||||
|
else
|
||||||
|
glDeleteProgramsARB(1, &glprogid);
|
||||||
glprogid = 0;
|
glprogid = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GLuint glprogid; // opengl program id
|
GLuint glprogid; // opengl program id
|
||||||
|
|
||||||
|
bool bGLSL;
|
||||||
std::string strprog;
|
std::string strprog;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
// 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"
|
||||||
|
@ -73,7 +74,7 @@ void VertexShaderCache::Init()
|
||||||
pSetVSConstant4fv = SetCGVSConstant4fv;
|
pSetVSConstant4fv = SetCGVSConstant4fv;
|
||||||
pSetMultiVSConstant4fv = SetMultiCGVSConstant4fv;
|
pSetMultiVSConstant4fv = SetMultiCGVSConstant4fv;
|
||||||
pSetMultiVSConstant3fv = SetMultiCGVSConstant3fv;
|
pSetMultiVSConstant3fv = SetMultiCGVSConstant3fv;
|
||||||
pCompileVertexShader = CompileGLSLVertexShader;
|
pCompileVertexShader = CompileCGVertexShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, (GLint *)&s_nMaxVertexInstructions);
|
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, (GLint *)&s_nMaxVertexInstructions);
|
||||||
|
@ -124,7 +125,8 @@ VERTEXSHADER* VertexShaderCache::SetShader(u32 components)
|
||||||
// Make an entry in the table
|
// Make an entry in the table
|
||||||
VSCacheEntry& entry = vshaders[uid];
|
VSCacheEntry& entry = vshaders[uid];
|
||||||
last_entry = &entry;
|
last_entry = &entry;
|
||||||
const char *code = GenerateVertexShaderCode(components, API_OPENGL);
|
entry.shader.bGLSL = g_ActiveConfig.bUseGLSL;
|
||||||
|
const char *code = GenerateVertexShaderCode(components, g_ActiveConfig.bUseGLSL ? API_GLSL : API_OPENGL);
|
||||||
GetSafeVertexShaderId(&entry.safe_uid, components);
|
GetSafeVertexShaderId(&entry.safe_uid, components);
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
|
@ -155,6 +157,8 @@ 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,6 +169,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);
|
||||||
|
|
|
@ -29,9 +29,18 @@ namespace OGL
|
||||||
|
|
||||||
struct VERTEXSHADER
|
struct VERTEXSHADER
|
||||||
{
|
{
|
||||||
VERTEXSHADER() : glprogid(0) {}
|
VERTEXSHADER() : glprogid(0), bGLSL(0) {}
|
||||||
|
void Destroy()
|
||||||
|
{
|
||||||
|
if(bGLSL)
|
||||||
|
glDeleteShader(glprogid);
|
||||||
|
else
|
||||||
|
glDeleteProgramsARB(1, &glprogid);
|
||||||
|
glprogid = 0;
|
||||||
|
}
|
||||||
GLuint glprogid; // opengl program id
|
GLuint glprogid; // opengl program id
|
||||||
|
|
||||||
|
bool bGLSL;
|
||||||
std::string strprog;
|
std::string strprog;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,9 +52,7 @@ class VertexShaderCache
|
||||||
VERTEXSHADERUIDSAFE safe_uid;
|
VERTEXSHADERUIDSAFE safe_uid;
|
||||||
VSCacheEntry() {}
|
VSCacheEntry() {}
|
||||||
void Destroy() {
|
void Destroy() {
|
||||||
// printf("Destroying vs %i\n", shader.glprogid);
|
shader.Destroy();
|
||||||
glDeleteProgramsARB(1, &shader.glprogid);
|
|
||||||
shader.glprogid = 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue