2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 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 _VERTEXSHADERCACHE_H_
|
|
|
|
#define _VERTEXSHADERCACHE_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 "VertexShaderGen.h"
|
|
|
|
|
|
|
|
struct VERTEXSHADER
|
|
|
|
{
|
|
|
|
VERTEXSHADER() : glprogid(0) {}
|
|
|
|
GLuint glprogid; // opengl program id
|
|
|
|
|
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
|
|
std::string strprog;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
class VertexShaderCache
|
|
|
|
{
|
|
|
|
struct VSCacheEntry
|
|
|
|
{
|
|
|
|
VERTEXSHADER shader;
|
|
|
|
int frameCount;
|
|
|
|
VSCacheEntry() : frameCount(0) {}
|
|
|
|
void Destroy() {
|
|
|
|
// printf("Destroying vs %i\n", shader.glprogid);
|
|
|
|
glDeleteProgramsARB(1, &shader.glprogid);
|
|
|
|
shader.glprogid = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<VERTEXSHADERUID, VSCacheEntry> VSCache;
|
|
|
|
|
|
|
|
static VSCache vshaders;
|
|
|
|
|
2009-03-01 00:57:39 +00:00
|
|
|
static bool s_displayCompileAlert;
|
2009-09-26 12:39:12 +00:00
|
|
|
|
|
|
|
static GLuint CurrentShader;
|
|
|
|
static bool ShaderEnabled;
|
2009-03-01 00:57:39 +00:00
|
|
|
|
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();
|
|
|
|
|
|
|
|
static VERTEXSHADER* GetShader(u32 components);
|
|
|
|
static bool CompileVertexShader(VERTEXSHADER& ps, const char* pstrprogram);
|
2009-09-26 12:39:12 +00:00
|
|
|
|
|
|
|
static void SetCurrentShader(GLuint Shader);
|
|
|
|
|
|
|
|
static void DisableShader();
|
|
|
|
static void EnableShader(GLuint Shader);
|
2009-02-23 06:17:57 +00:00
|
|
|
};
|
2009-04-03 14:35:49 +00:00
|
|
|
|
|
|
|
#endif // _VERTEXSHADERCACHE_H_
|