Put some stuff in the gfx plugins into namespaces, so that the symbols won't collide if someone decides to merge the gfx plugins into dolphin too. still more things left to do though.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6972 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2011-01-29 20:16:51 +00:00
parent fb35a83d2c
commit 7f97ce79bb
55 changed files with 531 additions and 329 deletions

View File

@ -21,7 +21,12 @@
#include "TextureConverter.h"
#include "Render.h"
extern bool s_bHaveFramebufferBlit; // comes from Render.cpp
namespace OGL
{
extern bool s_bHaveFramebufferBlit; // comes from Render.cpp. ugly.
int FramebufferManager::m_targetWidth;
int FramebufferManager::m_targetHeight;
@ -401,3 +406,5 @@ void FramebufferManager::GetTargetSize(unsigned int *width, unsigned int *height
*width = m_targetWidth;
*height = m_targetHeight;
}
} // namespace OGL

View File

@ -53,6 +53,8 @@
// There may be multiple XFBs in GameCube RAM. This is the maximum number to
// virtualize.
namespace OGL {
struct XFBSource : public XFBSourceBase
{
XFBSource(GLuint tex) : texture(tex) {}
@ -118,4 +120,6 @@ private:
static GLuint m_xfbFramebuffer; // Only used in MSAA mode
};
} // namespace OGL
#endif

View File

@ -32,6 +32,9 @@
#include "FileUtil.h"
#include "Debugger.h"
namespace OGL
{
static int s_nMaxPixelInstructions;
static GLuint s_ColorMatrixProgram = 0;
static GLuint s_DepthMatrixProgram = 0;
@ -53,23 +56,6 @@ GLuint PixelShaderCache::GetColorMatrixProgram()
return s_ColorMatrixProgram;
}
void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
float f[4] = { f1, f2, f3, f4 };
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f);
}
void SetPSConstant4fv(unsigned int const_number, const float *f)
{
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f);
}
void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
for (unsigned int i = 0; i < count; i++,f+=4)
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f);
}
void PixelShaderCache::Init()
{
glEnable(GL_FRAGMENT_PROGRAM_ARB);
@ -354,3 +340,23 @@ void PixelShaderCache::SetCurrentShader(GLuint Shader)
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, CurrentShader);
}
}
} // namespace OGL
void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
float f[4] = { f1, f2, f3, f4 };
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f);
}
void SetPSConstant4fv(unsigned int const_number, const float *f)
{
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f);
}
void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
for (unsigned int i = 0; i < count; i++,f+=4)
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f);
}

View File

@ -24,6 +24,9 @@
#include "BPMemory.h"
#include "PixelShaderGen.h"
namespace OGL
{
struct FRAGMENTSHADER
{
FRAGMENTSHADER() : glprogid(0) { }
@ -83,4 +86,6 @@ public:
static void DisableShader();
};
} // namespace OGL
#endif // _PIXELSHADERCACHE_H_

View File

@ -22,6 +22,9 @@
#include "PostProcessing.h"
#include "PixelShaderCache.h"
namespace OGL
{
namespace PostProcessing
{
@ -85,3 +88,5 @@ bool ApplyShader()
}
} // namespace
} // namespace OGL

View File

@ -21,6 +21,9 @@
#include "VideoCommon.h"
#include "GLUtil.h"
namespace OGL
{
namespace PostProcessing
{
@ -33,4 +36,6 @@ bool ApplyShader();
} // namespace
} // namespace
#endif // _POSTPROCESSING_H_

View File

@ -70,9 +70,23 @@
#include <wx/image.h>
#endif
// Declarations and definitions
// ----------------------------
int s_fps=0;
void VideoConfig::UpdateProjectionHack()
{
::UpdateProjectionHack(g_Config.iPhackvalue);
}
#if defined(HAVE_WX) && HAVE_WX
// Screenshot thread struct
typedef struct
{
int W, H;
std::string filename;
wxImage *img;
} ScrStrct;
#endif
#if defined HAVE_CG && HAVE_CG
CGcontext g_cgcontext;
@ -80,6 +94,20 @@ CGprofile g_cgvProf;
CGprofile g_cgfProf;
#endif
#ifdef _WIN32
extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH;
#else
int OSDChoice, OSDTime, OSDInternalW, OSDInternalH;
#endif
namespace OGL
{
// Declarations and definitions
// ----------------------------
int s_fps=0;
RasterFont* s_pfont = NULL;
#if defined _WIN32 || defined HAVE_LIBAV
@ -100,24 +128,6 @@ static u32 s_blendMode;
static std::thread scrshotThread;
#endif
#ifdef _WIN32
extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH;
#else
int OSDChoice, OSDTime, OSDInternalW, OSDInternalH;
#endif
namespace
{
#if defined(HAVE_WX) && HAVE_WX
// Screenshot thread struct
typedef struct
{
int W, H;
std::string filename;
wxImage *img;
} ScrStrct;
#endif
static const GLenum glSrcFactors[8] =
{
@ -182,15 +192,6 @@ void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
}
#endif
} // namespace
void VideoConfig::UpdateProjectionHack()
{
::UpdateProjectionHack(g_Config.iPhackvalue);
}
namespace OGL
{
// Init functions
Renderer::Renderer()
{

View File

@ -31,6 +31,9 @@
#include <math.h>
#include "FileUtil.h"
namespace OGL
{
namespace TextureConverter
{
@ -469,3 +472,5 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
}
} // namespace
} // namespace OGL

View File

@ -21,7 +21,10 @@
#include "VideoCommon.h"
#include "GLUtil.h"
// Converts textures between formats
namespace OGL
{
// Converts textures between formats using shaders
// TODO: support multiple texture formats
namespace TextureConverter
{
@ -41,4 +44,6 @@ u64 EncodeToRamFromTexture(u32 address, GLuint source_texture, bool bFromZBuffer
}
} // namespace OGL
#endif // _TEXTURECONVERTER_H_

View File

@ -34,6 +34,9 @@
#include "FileUtil.h"
#include "Debugger.h"
namespace OGL
{
VertexShaderCache::VSCache VertexShaderCache::vshaders;
bool VertexShaderCache::s_displayCompileAlert;
GLuint VertexShaderCache::CurrentShader;
@ -42,57 +45,6 @@ bool VertexShaderCache::ShaderEnabled;
static VERTEXSHADER *pShaderLast = NULL;
static int s_nMaxVertexInstructions;
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, const_number, f1, f2, f3, f4);
}
void SetVSConstant4fv(unsigned int const_number, const float *f)
{
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number, f);
}
void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
if(GLEW_EXT_gpu_program_parameters)
{
glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, f);
}
else
{
for (unsigned int i = 0; i < count; i++,f+=4)
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, f);
}
}
void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f)
{
if(GLEW_EXT_gpu_program_parameters)
{
float buf[4 * C_VENVCONST_END];
for (unsigned int i = 0; i < count; i++)
{
buf[4*i ] = *f++;
buf[4*i+1] = *f++;
buf[4*i+2] = *f++;
buf[4*i+3] = 0.f;
}
glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, buf);
}
else
{
for (unsigned int i = 0; i < count; i++)
{
float buf[4];
buf[0] = *f++;
buf[1] = *f++;
buf[2] = *f++;
buf[3] = 0.f;
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, buf);
}
}
}
void VertexShaderCache::Init()
{
@ -257,3 +209,56 @@ void VertexShaderCache::SetCurrentShader(GLuint Shader)
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, CurrentShader);
}
}
} // namespace OGL
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, const_number, f1, f2, f3, f4);
}
void SetVSConstant4fv(unsigned int const_number, const float *f)
{
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number, f);
}
void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
if(GLEW_EXT_gpu_program_parameters)
{
glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, f);
}
else
{
for (unsigned int i = 0; i < count; i++,f+=4)
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, f);
}
}
void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f)
{
if(GLEW_EXT_gpu_program_parameters)
{
float buf[4 * C_VENVCONST_END];
for (unsigned int i = 0; i < count; i++)
{
buf[4*i ] = *f++;
buf[4*i+1] = *f++;
buf[4*i+2] = *f++;
buf[4*i+3] = 0.f;
}
glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, buf);
}
else
{
for (unsigned int i = 0; i < count; i++)
{
float buf[4];
buf[0] = *f++;
buf[1] = *f++;
buf[2] = *f++;
buf[3] = 0.f;
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, buf);
}
}
}

View File

@ -24,6 +24,9 @@
#include "BPMemory.h"
#include "VertexShaderGen.h"
namespace OGL
{
struct VERTEXSHADER
{
VERTEXSHADER() : glprogid(0) {}
@ -69,4 +72,6 @@ public:
};
} // namespace OGL
#endif // _VERTEXSHADERCACHE_H_

View File

@ -311,14 +311,14 @@ void Video_Prepare()
g_vertex_manager = new OGL::VertexManager;
Fifo_Init(); // must be done before OpcodeDecoder_Init()
OpcodeDecoder_Init();
VertexShaderCache::Init();
OGL::VertexShaderCache::Init();
VertexShaderManager::Init();
PixelShaderCache::Init();
OGL::PixelShaderCache::Init();
PixelShaderManager::Init();
PostProcessing::Init();
OGL::PostProcessing::Init();
GL_REPORT_ERRORD();
VertexLoaderManager::Init();
TextureConverter::Init();
OGL::TextureConverter::Init();
DLCache::Init();
// Notify the core that the video plugin is ready
@ -338,16 +338,16 @@ void Shutdown()
s_swapRequested = FALSE;
DLCache::Shutdown();
Fifo_Shutdown();
PostProcessing::Shutdown();
OGL::PostProcessing::Shutdown();
// The following calls are NOT Thread Safe
// And need to be called from the video thread
TextureConverter::Shutdown();
OGL::TextureConverter::Shutdown();
VertexLoaderManager::Shutdown();
VertexShaderCache::Shutdown();
OGL::VertexShaderCache::Shutdown();
VertexShaderManager::Shutdown();
PixelShaderManager::Shutdown();
PixelShaderCache::Shutdown();
OGL::PixelShaderCache::Shutdown();
delete g_vertex_manager;
delete g_texture_cache;
OpcodeDecoder_Shutdown();