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

@ -22,11 +22,15 @@
#include "StringUtil.h"
#include "VideoCommon.h"
// D3DX
HINSTANCE hD3DXDll = NULL;
D3DXSAVESURFACETOFILEATYPE PD3DXSaveSurfaceToFileA = NULL;
D3DXSAVETEXTURETOFILEATYPE PD3DXSaveTextureToFileA = NULL;
D3DXCOMPILESHADERTYPE PD3DXCompileShader = NULL;
namespace DX9
{
// D3DX
HINSTANCE hD3DXDll = NULL;
int d3dx_dll_ref = 0;
typedef IDirect3D9* (WINAPI* DIRECT3DCREATE9)(UINT);
@ -820,3 +824,5 @@ void SetPixelShader(LPDIRECT3DPIXELSHADER9 shader)
} // namespace
} // namespace DX9

View File

@ -15,8 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _D3DBASE_H
#define _D3DBASE_H
#pragma once
#include <vector>
#include <set>
@ -25,6 +24,9 @@
#include "Common.h"
namespace DX9
{
namespace D3D
{
@ -151,6 +153,8 @@ int GetNumAdapters();
} // namespace
} // namespace DX9
// Used to not require the SDK and runtime versions to match:
// Linking with d3dx9.lib makes the most recent d3dx9_xx.dll of the
@ -163,7 +167,3 @@ typedef HRESULT (WINAPI* D3DXCOMPILESHADERTYPE)(LPCSTR, UINT, CONST D3DXMACRO*,
extern D3DXSAVESURFACETOFILEATYPE PD3DXSaveSurfaceToFileA;
extern D3DXSAVETEXTURETOFILEATYPE PD3DXSaveTextureToFileA;
extern D3DXCOMPILESHADERTYPE PD3DXCompileShader;
#endif

View File

@ -21,6 +21,9 @@
#include "VideoConfig.h"
#include "D3DShader.h"
namespace DX9
{
namespace D3D
{
@ -151,3 +154,5 @@ LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char* code, unsigned in
}
} // namespace
} // namespace DX9

View File

@ -19,6 +19,9 @@
#include "D3DBase.h"
namespace DX9
{
namespace D3D
{
LPDIRECT3DVERTEXSHADER9 CreateVertexShaderFromByteCode(const u8 *bytecode, int len);
@ -32,3 +35,5 @@ namespace D3D
LPDIRECT3DVERTEXSHADER9 CompileAndCreateVertexShader(const char *code, int len);
LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char *code, unsigned int len);
}
} // namespace DX9

View File

@ -27,6 +27,9 @@
#include <tmmintrin.h>
#endif
namespace DX9
{
namespace D3D
{
@ -412,3 +415,5 @@ void ReplaceTexture2D(LPDIRECT3DTEXTURE9 pTexture, const u8* buffer, const int w
}
} // namespace
} // namespace DX9

View File

@ -19,6 +19,9 @@
#include "D3DBase.h"
namespace DX9
{
namespace D3D
{
LPDIRECT3DTEXTURE9 CreateTexture2D(const u8* buffer, const int width, const int height, const int pitch, D3DFORMAT fmt = D3DFMT_A8R8G8B8, bool swap_r_b = false, int levels = 1);
@ -27,3 +30,5 @@ namespace D3D
LPDIRECT3DSURFACE9 CreateDepthStencilSurface(const int width, const int height);
LPDIRECT3DTEXTURE9 CreateOnlyTexture2D(const int width, const int height, D3DFORMAT fmt);
}
} // namespace DX9

View File

@ -24,6 +24,9 @@
#include "PixelShaderCache.h"
#include "VertexShaderCache.h"
namespace DX9
{
namespace D3D
{
CD3DFont font;
@ -463,3 +466,5 @@ void drawClearQuad(u32 Color,float z,IDirect3DPixelShader9 *PShader,IDirect3DVer
} // namespace
} // namespace DX9

View File

@ -21,6 +21,9 @@
#include <math.h>
#include <MathUtil.h>
namespace DX9
{
namespace D3D
{
// Font creation flags
@ -85,3 +88,5 @@ namespace D3D
void SaveRenderStates();
void RestoreRenderStates();
}
} // namespace DX9

View File

@ -23,6 +23,9 @@
#include "VertexShaderCache.h"
#include "TextureConverter.h"
namespace DX9
{
// TODO: this is probably somewhere else
#define SAFE_RELEASE(p) if (p) { (p)->Release(); (p) = NULL; }
@ -229,3 +232,5 @@ void XFBSource::CopyEFB(float Gamma)
Rendersurf->Release();
}
} // namespace DX9

View File

@ -15,8 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _FRAMEBUFFERMANAGER_D3D_H_
#define _FRAMEBUFFERMANAGER_D3D_H_
#pragma once
#include "D3DBase.h"
#include "FramebufferManagerBase.h"
@ -50,6 +49,9 @@
// Disadvantages: If the GameCube CPU writes directly to the XFB (which is
// possible but uncommon), the Virtual XFB will not capture this information.
namespace DX9
{
struct XFBSource : public XFBSourceBase
{
XFBSource(LPDIRECT3DTEXTURE9 tex) : texture(tex) {}
@ -133,4 +135,4 @@ private:
} s_efb;
};
#endif
} // namespace DX9

View File

@ -173,7 +173,7 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
elems[elem_idx].Type = D3DDECLTYPE_UNUSED;
++elem_idx;
if (FAILED(D3D::dev->CreateVertexDeclaration(elems, &d3d_decl)))
if (FAILED(DX9::D3D::dev->CreateVertexDeclaration(elems, &d3d_decl)))
{
PanicAlert("Failed to create D3D vertex declaration!");
return;
@ -187,7 +187,7 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
void D3DVertexFormat::SetupVertexPointers()
{
if (d3d_decl)
D3D::SetVertexDeclaration(d3d_decl);
DX9::D3D::SetVertexDeclaration(d3d_decl);
else
ERROR_LOG(VIDEO, "invalid d3d decl");
}

View File

@ -37,6 +37,9 @@
#include "ImageWrite.h"
#include "Debugger.h"
namespace DX9
{
PixelShaderCache::PSCache PixelShaderCache::PixelShaders;
const PixelShaderCache::PSCacheEntry *PixelShaderCache::last_entry;
@ -62,6 +65,15 @@ static LPDIRECT3DPIXELSHADER9 s_ClearProgram = NULL;
static LPDIRECT3DPIXELSHADER9 s_rgba6_to_rgb8 = NULL;
static LPDIRECT3DPIXELSHADER9 s_rgb8_to_rgba6 = NULL;
class PixelShaderCacheInserter : public LinearDiskCacheReader<PIXELSHADERUID, u8>
{
public:
void Read(const PIXELSHADERUID &key, const u8 *value, u32 value_size)
{
PixelShaderCache::InsertByteCode(key, value, value_size, false);
}
};
LPDIRECT3DPIXELSHADER9 PixelShaderCache::GetColorMatrixProgram(int SSAAMode)
{
return s_CopyProgram[COPY_TYPE_MATRIXCOLOR][DEPTH_CONVERSION_TYPE_NONE][SSAAMode % MAX_SSAA_SHADERS];
@ -141,31 +153,6 @@ LPDIRECT3DPIXELSHADER9 PixelShaderCache::ReinterpRGB8ToRGBA6()
return s_rgb8_to_rgba6;
}
void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
float f[4] = { f1, f2, f3, f4 };
D3D::dev->SetPixelShaderConstantF(const_number, f, 1);
}
void SetPSConstant4fv(unsigned int const_number, const float *f)
{
D3D::dev->SetPixelShaderConstantF(const_number, f, 1);
}
void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
D3D::dev->SetPixelShaderConstantF(const_number, f, count);
}
class PixelShaderCacheInserter : public LinearDiskCacheReader<PIXELSHADERUID, u8>
{
public:
void Read(const PIXELSHADERUID &key, const u8 *value, u32 value_size)
{
PixelShaderCache::InsertByteCode(key, value, value_size, false);
}
};
#define WRITE p+=sprintf
static LPDIRECT3DPIXELSHADER9 CreateCopyShader(int copyMatrixType, int depthConversionType, int SSAAMode)
@ -430,3 +417,22 @@ bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const u8 *bytec
}
return true;
}
} // namespace DX9
void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
float f[4] = { f1, f2, f3, f4 };
DX9::D3D::dev->SetPixelShaderConstantF(const_number, f, 1);
}
void SetPSConstant4fv(unsigned int const_number, const float *f)
{
DX9::D3D::dev->SetPixelShaderConstantF(const_number, f, 1);
}
void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
DX9::D3D::dev->SetPixelShaderConstantF(const_number, f, count);
}

View File

@ -15,8 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _PIXELSHADERCACHE_H
#define _PIXELSHADERCACHE_H
#pragma once
#include "Common.h"
#include "LinearDiskCache.h"
@ -27,6 +26,9 @@
#include "PixelShaderGen.h"
#include "VertexShaderGen.h"
namespace DX9
{
typedef u32 tevhash;
tevhash GetCurrentTEV();
@ -68,5 +70,4 @@ public:
static LPDIRECT3DPIXELSHADER9 ReinterpRGB8ToRGBA6();
};
#endif // _PIXELSHADERCACHE_H
} // namespace DX9

View File

@ -51,6 +51,9 @@
#include "DLCache.h"
#include "Debugger.h"
namespace DX9
{
static int s_fps = 0;
static int s_recordWidth;
@ -243,9 +246,6 @@ void TeardownDeviceObjects()
TextureConverter::Shutdown();
}
namespace DX9
{
// Init functions
Renderer::Renderer()
{
@ -1397,4 +1397,4 @@ void Renderer::SetInterlacingMode()
// TODO
}
}
} // namespace DX9

View File

@ -50,6 +50,6 @@ public:
static void SetWindowSize(int width, int height);
};
}
} // namespace DX9
#endif

View File

@ -32,6 +32,9 @@
#include "Math.h"
#include "FileUtil.h"
namespace DX9
{
namespace TextureConverter
{
struct TransformBuffer
@ -549,3 +552,5 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE
}
} // namespace
} // namespace DX9

View File

@ -24,7 +24,10 @@
#include "D3DUtil.h"
#include "D3DShader.h"
// Converts textures between formats
namespace DX9
{
// Converts textures between formats using shaders
// TODO: support multiple texture formats
namespace TextureConverter
{
@ -45,4 +48,6 @@ u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture, u32 So
}
} // namespace DX9
#endif // _TEXTURECONVERTER_H_

View File

@ -32,6 +32,9 @@
#include "XFMemory.h"
#include "Debugger.h"
namespace DX9
{
VertexShaderCache::VSCache VertexShaderCache::vshaders;
const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry;
@ -52,35 +55,6 @@ LPDIRECT3DVERTEXSHADER9 VertexShaderCache::GetClearVertexShader()
return ClearVertexShader;
}
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
const float f[4] = { f1, f2, f3, f4 };
D3D::dev->SetVertexShaderConstantF(const_number, f, 1);
}
void SetVSConstant4fv(unsigned int const_number, const float *f)
{
D3D::dev->SetVertexShaderConstantF(const_number, f, 1);
}
void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f)
{
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;
}
D3D::dev->SetVertexShaderConstantF(const_number, buf, count);
}
void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
D3D::dev->SetVertexShaderConstantF(const_number, f, count);
}
// this class will load the precompiled shaders into our cache
class VertexShaderCacheInserter : public LinearDiskCacheReader<VERTEXSHADERUID, u8>
{
@ -271,3 +245,35 @@ bool VertexShaderCache::InsertByteCode(const VERTEXSHADERUID &uid, const u8 *byt
}
return false;
}
} // namespace DX9
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
const float f[4] = { f1, f2, f3, f4 };
DX9::D3D::dev->SetVertexShaderConstantF(const_number, f, 1);
}
void SetVSConstant4fv(unsigned int const_number, const float *f)
{
DX9::D3D::dev->SetVertexShaderConstantF(const_number, f, 1);
}
void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f)
{
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;
}
DX9::D3D::dev->SetVertexShaderConstantF(const_number, buf, count);
}
void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
DX9::D3D::dev->SetVertexShaderConstantF(const_number, f, count);
}

View File

@ -15,8 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _VERTEXSHADERCACHE_H
#define _VERTEXSHADERCACHE_H
#pragma once
#include "D3DBase.h"
@ -26,6 +25,9 @@
#include "D3DBase.h"
#include "VertexShaderGen.h"
namespace DX9
{
class VertexShaderCache
{
private:
@ -62,4 +64,4 @@ public:
static std::string GetCurrentShaderCode();
};
#endif // _VERTEXSHADERCACHE_H
} // namespace DX9

View File

@ -185,7 +185,7 @@ void InitBackendInfo()
g_Config.backend_info.bAllowSignedBytes = false;
g_Config.backend_info.bSupportsDualSourceBlend = false;
g_Config.backend_info.bSupportsFormatReinterpretation = true;
int shaderModel = ((D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF);
int shaderModel = ((DX9::D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF);
int maxConstants = (shaderModel < 3) ? 32 : ((shaderModel < 4) ? 224 : 65536);
g_Config.backend_info.bSupportsPixelLighting = C_PLIGHTS + 40 <= maxConstants && C_PMATERIALS + 4 <= maxConstants;
}
@ -194,18 +194,18 @@ void DllConfig(void *_hParent)
{
#if defined(HAVE_WX) && HAVE_WX
InitBackendInfo();
D3D::Init();
DX9::D3D::Init();
// adapters
g_Config.backend_info.Adapters.clear();
for (int i = 0; i < D3D::GetNumAdapters(); ++i)
g_Config.backend_info.Adapters.push_back(D3D::GetAdapter(i).ident.Description);
for (int i = 0; i < DX9::D3D::GetNumAdapters(); ++i)
g_Config.backend_info.Adapters.push_back(DX9::D3D::GetAdapter(i).ident.Description);
// aamodes
g_Config.backend_info.AAModes.clear();
if (g_Config.iAdapter < D3D::GetNumAdapters())
if (g_Config.iAdapter < DX9::D3D::GetNumAdapters())
{
const D3D::Adapter &adapter = D3D::GetAdapter(g_Config.iAdapter);
const DX9::D3D::Adapter &adapter = DX9::D3D::GetAdapter(g_Config.iAdapter);
for (int i = 0; i < (int)adapter.aa_levels.size(); ++i)
g_Config.backend_info.AAModes.push_back(adapter.aa_levels[i].name);
@ -216,7 +216,7 @@ void DllConfig(void *_hParent)
diag->ShowModal();
diag->Destroy();
D3D::Shutdown();
DX9::D3D::Shutdown();
#endif
}
@ -241,7 +241,7 @@ void Initialize(void *init)
ERROR_LOG(VIDEO, "An error has occurred while trying to create the window.");
return;
}
else if (FAILED(D3D::Init()))
else if (FAILED(DX9::D3D::Init()))
{
MessageBox(GetActiveWindow(), _T("Unable to initialize Direct3D. Please make sure that you have the latest version of DirectX 9.0c correctly installed."), _T("Fatal Error"), MB_ICONERROR|MB_OK);
return;
@ -304,11 +304,11 @@ void Shutdown()
VertexLoaderManager::Shutdown();
// internal interfaces
PixelShaderCache::Shutdown();
VertexShaderCache::Shutdown();
DX9::PixelShaderCache::Shutdown();
DX9::VertexShaderCache::Shutdown();
delete g_vertex_manager;
delete g_texture_cache;
delete g_renderer;
D3D::Shutdown();
DX9::D3D::Shutdown();
EmuWindow::Close();
}