2009-04-03 14:35:49 +00:00
|
|
|
// Copyright (C) 2003-2009 Dolphin Project.
|
2009-02-23 06:17:57 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#ifndef _PIXELSHADERCACHE_H_
|
|
|
|
#define _PIXELSHADERCACHE_H_
|
|
|
|
|
2009-02-23 06:17:57 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
#include "BPMemory.h"
|
2009-02-23 06:17:57 +00:00
|
|
|
#include "PixelShaderGen.h"
|
|
|
|
|
|
|
|
struct FRAGMENTSHADER
|
|
|
|
{
|
|
|
|
FRAGMENTSHADER() : glprogid(0) { }
|
2009-06-08 18:34:24 +00:00
|
|
|
void Destroy()
|
|
|
|
{
|
|
|
|
if (glprogid)
|
|
|
|
{
|
|
|
|
glDeleteProgramsARB(1, &glprogid);
|
|
|
|
glprogid = 0;
|
|
|
|
}
|
|
|
|
}
|
2009-02-23 06:17:57 +00:00
|
|
|
GLuint glprogid; // opengl program id
|
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
|
|
std::string strprog;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
class PixelShaderCache
|
|
|
|
{
|
|
|
|
struct PSCacheEntry
|
|
|
|
{
|
|
|
|
FRAGMENTSHADER shader;
|
|
|
|
int frameCount;
|
|
|
|
PSCacheEntry() : frameCount(0) {}
|
|
|
|
~PSCacheEntry() {}
|
2009-06-08 18:34:24 +00:00
|
|
|
void Destroy()
|
|
|
|
{
|
|
|
|
shader.Destroy();
|
2009-02-23 06:17:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<PIXELSHADERUID, PSCacheEntry> PSCache;
|
|
|
|
|
|
|
|
static PSCache pshaders;
|
|
|
|
|
|
|
|
static PIXELSHADERUID s_curuid; // the current pixel shader uid (progressively changed as memory is written)
|
|
|
|
|
2009-03-01 00:57:39 +00:00
|
|
|
static bool s_displayCompileAlert;
|
|
|
|
|
2009-02-23 06:17:57 +00:00
|
|
|
public:
|
|
|
|
static void Init();
|
2009-02-28 16:33:59 +00:00
|
|
|
static void ProgressiveCleanup();
|
2009-02-23 06:17:57 +00:00
|
|
|
static void Shutdown();
|
|
|
|
|
2009-03-16 02:47:48 +00:00
|
|
|
static FRAGMENTSHADER* GetShader(bool dstAlphaEnable);
|
2009-02-23 06:17:57 +00:00
|
|
|
static bool CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrprogram);
|
|
|
|
|
|
|
|
static GLuint GetColorMatrixProgram();
|
2009-05-15 02:39:55 +00:00
|
|
|
|
|
|
|
static GLuint GetDepthMatrixProgram();
|
2009-02-23 06:17:57 +00:00
|
|
|
};
|
2009-04-03 14:35:49 +00:00
|
|
|
|
|
|
|
#endif // _PIXELSHADERCACHE_H_
|