summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2011-12-02 18:46:07 -0600
committerRyan Houdek <Sonicadvance1@gmail.com>2011-12-02 18:46:07 -0600
commit8a18a110b7bda3c244a8478010b71f951cfffdc6 (patch)
tree7e82472be429672d520f54dd6fb7ad49fa4e72be /Source
parent6882e00d5e39b2cfa92975a51f717a19bc9319c9 (diff)
mah
Diffstat (limited to 'Source')
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp8
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.h9
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp10
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h15
4 files changed, 33 insertions, 9 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
index 36a8f054f5..32e6fb3374 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
@@ -20,6 +20,7 @@
#include "GLUtil.h"
#include <cmath>
+#include <assert.h>
#include "Statistics.h"
#include "VideoConfig.h"
@@ -234,7 +235,8 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 comp
// Make an entry in the table
PSCacheEntry& newentry = PixelShaders[uid];
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)
{
@@ -271,6 +273,8 @@ 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);
@@ -281,6 +285,8 @@ void PixelShaderCache::DisableShader()
//bind a program if is diferent from the binded oone
void PixelShaderCache::SetCurrentShader(GLuint Shader)
{
+ if(g_ActiveConfig.bUseGLSL)
+ assert(true);
if(!ShaderEnabled)
{
glEnable(GL_FRAGMENT_PROGRAM_ARB);
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.h b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.h
index 429af249f1..d5e2cae6bc 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.h
@@ -29,16 +29,21 @@ namespace OGL
struct FRAGMENTSHADER
{
- FRAGMENTSHADER() : glprogid(0) { }
+ FRAGMENTSHADER() : glprogid(0), bGLSL(0) { }
void Destroy()
{
if (glprogid)
{
- glDeleteProgramsARB(1, &glprogid);
+ if(bGLSL)
+ glDeleteShader(glprogid);
+ else
+ glDeleteProgramsARB(1, &glprogid);
glprogid = 0;
}
}
GLuint glprogid; // opengl program id
+
+ bool bGLSL;
std::string strprog;
};
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp
index f58e9eb786..ea7a97196b 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp
@@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/
#include <math.h>
+#include <assert.h>
#include "Globals.h"
#include "VideoConfig.h"
@@ -73,7 +74,7 @@ void VertexShaderCache::Init()
pSetVSConstant4fv = SetCGVSConstant4fv;
pSetMultiVSConstant4fv = SetMultiCGVSConstant4fv;
pSetMultiVSConstant3fv = SetMultiCGVSConstant3fv;
- pCompileVertexShader = CompileGLSLVertexShader;
+ pCompileVertexShader = CompileCGVertexShader;
}
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
VSCacheEntry& entry = vshaders[uid];
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);
#if defined(_DEBUG) || defined(DEBUGFAST)
@@ -155,6 +157,8 @@ 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,6 +169,8 @@ void VertexShaderCache::DisableShader()
void VertexShaderCache::SetCurrentShader(GLuint Shader)
{
+ if(g_ActiveConfig.bUseGLSL)
+ assert(true);
if (!ShaderEnabled)
{
glEnable(GL_VERTEX_PROGRAM_ARB);
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h
index fc08cc4efd..c3a6146b53 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h
@@ -29,9 +29,18 @@ namespace OGL
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
+ bool bGLSL;
std::string strprog;
};
@@ -43,9 +52,7 @@ class VertexShaderCache
VERTEXSHADERUIDSAFE safe_uid;
VSCacheEntry() {}
void Destroy() {
- // printf("Destroying vs %i\n", shader.glprogid);
- glDeleteProgramsARB(1, &shader.glprogid);
- shader.glprogid = 0;
+ shader.Destroy();
}
};