Preparing stuff for DX11:

- be more strict with the input signature of generated pixel shaders
- replace the D3D parameter with an API_TYPE one, so that we can further distinguish between DX9 and DX11
- for what it's worth dx11 (using vs_4_0) doesn't support D3DCOLORtoUBYTE4; added a workaround for this
- add a "dx9-" prefix to the shader cache files to avoid conflicts with dx11 shaders

Apart from that we're calling CommandProcessor::Shutdown() in main.cpp,Shutdown() now.
Delete all files in User/ShaderCache if you want to save a few KB disk space :P


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5659 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX
2010-06-12 15:49:21 +00:00
parent f0d178122e
commit a6ebc8234f
11 changed files with 75 additions and 61 deletions

View File

@ -48,7 +48,6 @@ static LPDIRECT3DPIXELSHADER9 s_DepthMatrixProgram[3];
static LPDIRECT3DPIXELSHADER9 s_ClearProgram = 0;
LPDIRECT3DPIXELSHADER9 PixelShaderCache::GetColorMatrixProgram(int SSAAMode)
{
return s_ColorMatrixProgram[SSAAMode % 3];
@ -69,7 +68,7 @@ LPDIRECT3DPIXELSHADER9 PixelShaderCache::GetClearProgram()
return s_ClearProgram;
}
void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4)
void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
if (lastPSconstants[const_number][0] != f1 || lastPSconstants[const_number][1] != f2 ||
lastPSconstants[const_number][2] != f3 || lastPSconstants[const_number][3] != f4)
@ -83,7 +82,7 @@ void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4)
}
}
void SetPSConstant4fv(int const_number, const float *f)
void SetPSConstant4fv(unsigned int const_number, const float *f)
{
if (memcmp(&lastPSconstants[const_number], f, sizeof(float) * 4)) {
memcpy(&lastPSconstants[const_number], f, sizeof(float) * 4);
@ -91,7 +90,7 @@ void SetPSConstant4fv(int const_number, const float *f)
}
}
void SetMultiPSConstant4fv(int const_number, int count, const float *f)
void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
if (memcmp(&lastPSconstants[const_number], f, count * sizeof(float) * 4)) {
memcpy(&lastPSconstants[const_number], f, count * sizeof(float) * 4);
@ -260,7 +259,7 @@ void PixelShaderCache::Init()
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
char cache_filename[MAX_PATH];
sprintf(cache_filename, "%s%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id);
sprintf(cache_filename, "%sdx9-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id);
PixelShaderCacheInserter inserter;
int read_items = g_ps_disk_cache.OpenAndRead(cache_filename, &inserter);
}

View File

@ -56,7 +56,7 @@ LPDIRECT3DVERTEXSHADER9 VertexShaderCache::GetClearVertexShader()
}
void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4)
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
if (lastVSconstants[const_number][0] != f1 ||
lastVSconstants[const_number][1] != f2 ||
@ -71,7 +71,7 @@ void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4)
}
}
void SetVSConstant4fv(int const_number, const float *f)
void SetVSConstant4fv(unsigned int const_number, const float *f)
{
if (memcmp(&lastVSconstants[const_number], f, sizeof(float) * 4)) {
memcpy(&lastVSconstants[const_number], f, sizeof(float) * 4);
@ -79,10 +79,10 @@ void SetVSConstant4fv(int const_number, const float *f)
}
}
void SetMultiVSConstant3fv(int const_number, int count, const float *f)
void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f)
{
bool change = false;
for (int i = 0; i < count; i++)
for (unsigned int i = 0; i < count; i++)
{
if (lastVSconstants[const_number + i][0] != f[0 + i*3] ||
lastVSconstants[const_number + i][1] != f[1 + i*3] ||
@ -94,7 +94,7 @@ void SetMultiVSConstant3fv(int const_number, int count, const float *f)
}
if (change)
{
for (int i = 0; i < count; i++)
for (unsigned int i = 0; i < count; i++)
{
lastVSconstants[const_number + i][0] = f[0 + i*3];
lastVSconstants[const_number + i][1] = f[1 + i*3];
@ -105,7 +105,7 @@ void SetMultiVSConstant3fv(int const_number, int count, const float *f)
}
}
void SetMultiVSConstant4fv(int const_number, int count, const float *f)
void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
if (memcmp(&lastVSconstants[const_number], f, count * sizeof(float) * 4)) {
memcpy(&lastVSconstants[const_number], f, count * sizeof(float) * 4);
@ -215,7 +215,7 @@ void VertexShaderCache::Init()
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
char cache_filename[MAX_PATH];
sprintf(cache_filename, "%s%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id);
sprintf(cache_filename, "%sdx9-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id);
VertexShaderCacheInserter inserter;
int read_items = g_vs_disk_cache.OpenAndRead(cache_filename, &inserter);
}
@ -284,7 +284,7 @@ bool VertexShaderCache::SetShader(u32 components)
return false;
}
const char *code = GenerateVertexShaderCode(components, true);
const char *code = GenerateVertexShaderCode(components, API_D3D9);
u8 *bytecode;
int bytecodelen;
if (!D3D::CompileVertexShader(code, (int)strlen(code), &bytecode, &bytecodelen))

View File

@ -286,6 +286,7 @@ void Shutdown()
s_FifoShuttingDown = FALSE;
s_swapRequested = FALSE;
Fifo_Shutdown();
CommandProcessor::Shutdown();
VertexManager::Shutdown();
VertexLoaderManager::Shutdown();
VertexShaderCache::Shutdown();

View File

@ -48,7 +48,7 @@ static FRAGMENTSHADER* pShaderLast = NULL;
static float lastPSconstants[C_COLORMATRIX+16][4];
void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4)
void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
if (lastPSconstants[const_number][0] != f1 || lastPSconstants[const_number][1] != f2 ||
lastPSconstants[const_number][2] != f3 || lastPSconstants[const_number][3] != f4)
@ -62,7 +62,7 @@ void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4)
}
}
void SetPSConstant4fv(int const_number, const float *f)
void SetPSConstant4fv(unsigned int const_number, const float *f)
{
if (memcmp(&lastPSconstants[const_number], f, sizeof(float) * 4)) {
memcpy(&lastPSconstants[const_number], f, sizeof(float) * 4);
@ -70,10 +70,10 @@ void SetPSConstant4fv(int const_number, const float *f)
}
}
void SetMultiPSConstant4fv(int const_number, int count, const float *f)
void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
const float *f0 = f;
for (int i = 0; i < count ;i++,f0+=4)
for (unsigned int i = 0; i < count ;i++,f0+=4)
{
if (memcmp(&lastPSconstants[const_number + i], f0, sizeof(float) * 4)) {
memcpy(&lastPSconstants[const_number + i], f0, sizeof(float) * 4);
@ -89,7 +89,7 @@ void PixelShaderCache::Init()
CurrentShader = 0;
GL_REPORT_ERRORD();
for (int i = 0; i < (C_COLORMATRIX+16) * 4; i++)
for (unsigned int i = 0; i < (C_COLORMATRIX+16) * 4; i++)
lastPSconstants[i/4][i%4] = -100000000.0f;
memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid));

View File

@ -46,7 +46,7 @@ static VERTEXSHADER *pShaderLast = NULL;
static int s_nMaxVertexInstructions;
static float GC_ALIGNED16(lastVSconstants[C_FOGPARAMS+8][4]);
void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4)
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
if ( lastVSconstants[const_number][0] != f1 ||
lastVSconstants[const_number][1] != f2 ||
@ -61,7 +61,7 @@ void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4)
}
}
void SetVSConstant4fv(int const_number, const float *f)
void SetVSConstant4fv(unsigned int const_number, const float *f)
{
if (memcmp(&lastVSconstants[const_number], f, sizeof(float) * 4)) {
memcpy(&lastVSconstants[const_number], f, sizeof(float) * 4);
@ -69,10 +69,10 @@ void SetVSConstant4fv(int const_number, const float *f)
}
}
void SetMultiVSConstant4fv(int const_number, int count, const float *f)
void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
const float *f0 = f;
for (int i = 0; i < count; i++,f0+=4)
for (unsigned int i = 0; i < count; i++,f0+=4)
{
if (memcmp(&lastVSconstants[const_number + i], f0, sizeof(float) * 4)) {
memcpy(&lastVSconstants[const_number + i], f0, sizeof(float) * 4);
@ -81,9 +81,9 @@ void SetMultiVSConstant4fv(int const_number, int count, const float *f)
}
}
void SetMultiVSConstant3fv(int const_number, int count, const float *f)
void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f)
{
for (int i = 0; i < count; i++)
for (unsigned int i = 0; i < count; i++)
{
if (lastVSconstants[const_number + i][0] != f[0 + i*3] ||
lastVSconstants[const_number + i][1] != f[1 + i*3] ||
@ -151,7 +151,7 @@ VERTEXSHADER* VertexShaderCache::GetShader(u32 components)
VSCacheEntry& entry = vshaders[uid];
entry.frameCount = frameCount;
pShaderLast = &entry.shader;
const char *code = GenerateVertexShaderCode(components, false);
const char *code = GenerateVertexShaderCode(components, API_OPENGL);
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {