summaryrefslogtreecommitdiff
path: root/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
diff options
context:
space:
mode:
authordonkopunchstania <donkopunchstania@gmail.com>2009-05-15 02:39:55 +0000
committerdonkopunchstania <donkopunchstania@gmail.com>2009-05-15 02:39:55 +0000
commit14a67bc8bc5d663b5cd2d1d324d76444be3602d7 (patch)
tree19511fe94b78527c1b35317821fedc4229c860ea /Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
parent034e3c72a22601e2bfe2d43f72d2a16c8f2c6e96 (diff)
Changing where depth is read. Trying to use the same depth buffer GL uses when copying depth to a texture. This eliminates some quirky code and gets depth copies working in AA, but may not work on older graphics cards.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3234 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp')
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
index a6927acb86..7da020485c 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
@@ -36,6 +36,7 @@
static int s_nMaxPixelInstructions;
static GLuint s_ColorMatrixProgram = 0;
+static GLuint s_DepthMatrixProgram = 0;
PixelShaderCache::PSCache PixelShaderCache::pshaders;
PIXELSHADERUID PixelShaderCache::s_curuid;
bool PixelShaderCache::s_displayCompileAlert;
@@ -86,12 +87,42 @@ void PixelShaderCache::Init()
glDeleteProgramsARB(1, &s_ColorMatrixProgram);
s_ColorMatrixProgram = 0;
}
+
+ sprintf(pmatrixprog, "!!ARBfp1.0"
+ "TEMP R0;\n"
+ "TEMP R1;\n"
+ "TEMP R2;\n"
+ "PARAM K0 = { 65536.0, 256.0 };\n"
+ "TEX R2, fragment.texcoord[0], texture[0], RECT;\n"
+ "MUL R0.x, R2.x, K0.x;\n"
+ "FRC R0.x, R0.x;\n"
+ "MUL R0.y, R2.x, K0.y;\n"
+ "FRC R0.y, R0.y;\n"
+ "MOV R0.z, R2.x;\n"
+ "DP4 R1.x, R0, program.env[%d];\n"
+ "DP4 R1.y, R0, program.env[%d];\n"
+ "DP4 R1.z, R0, program.env[%d];\n"
+ "DP4 R1.w, R0, program.env[%d];\n"
+ "ADD result.color, R1, program.env[%d];\n"
+ "END\n", C_COLORMATRIX, C_COLORMATRIX+1, C_COLORMATRIX+2, C_COLORMATRIX+3, C_COLORMATRIX+4);
+ glGenProgramsARB(1, &s_DepthMatrixProgram);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, s_DepthMatrixProgram);
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pmatrixprog), pmatrixprog);
+
+ err = GL_REPORT_ERROR();
+ if (err != GL_NO_ERROR) {
+ ERROR_LOG(VIDEO, "Failed to create depth matrix fragment program");
+ glDeleteProgramsARB(1, &s_DepthMatrixProgram);
+ s_DepthMatrixProgram = 0;
+ }
}
void PixelShaderCache::Shutdown()
{
glDeleteProgramsARB(1, &s_ColorMatrixProgram);
s_ColorMatrixProgram = 0;
+ glDeleteProgramsARB(1, &s_DepthMatrixProgram);
+ s_DepthMatrixProgram = 0;
PSCache::iterator iter = pshaders.begin();
for (; iter != pshaders.end(); iter++)
iter->second.Destroy();
@@ -103,15 +134,18 @@ GLuint PixelShaderCache::GetColorMatrixProgram()
return s_ColorMatrixProgram;
}
+GLuint PixelShaderCache::GetDepthMatrixProgram()
+{
+ return s_DepthMatrixProgram;
+}
+
FRAGMENTSHADER* PixelShaderCache::GetShader(bool dstAlphaEnable)
{
DVSTARTPROFILE();
PIXELSHADERUID uid;
- u32 zbufrender = (Renderer::UseFakeZTarget() && bpmem.zmode.updateenable) ? 1 : 0;
- u32 zBufRenderToCol0 = Renderer::GetRenderMode() != Renderer::RM_Normal;
u32 dstAlpha = dstAlphaEnable ? 1 : 0;
- GetPixelShaderId(uid, PixelShaderManager::GetTextureMask(), zbufrender, zBufRenderToCol0, dstAlpha);
+ GetPixelShaderId(uid, PixelShaderManager::GetTextureMask(), dstAlpha);
PSCache::iterator iter = pshaders.find(uid);
@@ -127,8 +161,6 @@ FRAGMENTSHADER* PixelShaderCache::GetShader(bool dstAlphaEnable)
PSCacheEntry& newentry = pshaders[uid];
const char *code = GeneratePixelShader(PixelShaderManager::GetTextureMask(),
- Renderer::UseFakeZTarget(),
- Renderer::GetRenderMode() != Renderer::RM_Normal,
dstAlphaEnable);
#if defined(_DEBUG) || defined(DEBUGFAST)