mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
D3D: Reduce the number of DirectX API calls. However, it does not seem to give tiny speed up. If anyone find that this change actually slows DX9 down, I will revert it.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4237 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
aeac44596a
commit
c1665ec6cd
@ -32,21 +32,43 @@
|
||||
|
||||
PixelShaderCache::PSCache PixelShaderCache::PixelShaders;
|
||||
const PixelShaderCache::PSCacheEntry *PixelShaderCache::last_entry;
|
||||
PIXELSHADERUID PixelShaderCache::last_entry_uid;
|
||||
static float lastPSConstants[C_COLORMATRIX+16][4];
|
||||
|
||||
void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4)
|
||||
{
|
||||
const float f[4] = {f1, f2, f3, f4};
|
||||
D3D::dev->SetPixelShaderConstantF(const_number, f, 1);
|
||||
if( lastPSConstants[const_number][0] != f1 || lastPSConstants[const_number][1] != f2 ||
|
||||
lastPSConstants[const_number][2] != f3 || lastPSConstants[const_number][3] != f4 )
|
||||
{
|
||||
const float f[4] = {f1, f2, f3, f4};
|
||||
D3D::dev->SetPixelShaderConstantF(const_number, f, 1);
|
||||
lastPSConstants[const_number][0] = f1;
|
||||
lastPSConstants[const_number][1] = f2;
|
||||
lastPSConstants[const_number][2] = f3;
|
||||
lastPSConstants[const_number][3] = f4;
|
||||
}
|
||||
}
|
||||
|
||||
void SetPSConstant4fv(int const_number, const float *f)
|
||||
{
|
||||
D3D::dev->SetPixelShaderConstantF(const_number, f, 1);
|
||||
if( lastPSConstants[const_number][0] != f[0] || lastPSConstants[const_number][1] != f[1] ||
|
||||
lastPSConstants[const_number][2] != f[2] || lastPSConstants[const_number][3] != f[3] )
|
||||
{
|
||||
D3D::dev->SetPixelShaderConstantF(const_number, f, 1);
|
||||
lastPSConstants[const_number][0] = f[0];
|
||||
lastPSConstants[const_number][1] = f[1];
|
||||
lastPSConstants[const_number][2] = f[2];
|
||||
lastPSConstants[const_number][3] = f[3];
|
||||
}
|
||||
}
|
||||
|
||||
void PixelShaderCache::Init()
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<(C_COLORMATRIX+16)*4;i++)
|
||||
lastPSConstants[i/4][i%4]= -1;
|
||||
|
||||
memset(&last_entry_uid,0xFF,sizeof(last_entry_uid));
|
||||
}
|
||||
|
||||
void PixelShaderCache::Shutdown()
|
||||
@ -63,7 +85,16 @@ bool PixelShaderCache::SetShader(bool dstAlpha)
|
||||
|
||||
PIXELSHADERUID uid;
|
||||
GetPixelShaderId(uid, PixelShaderManager::GetTextureMask(), dstAlpha);
|
||||
if (uid == last_entry_uid)
|
||||
{
|
||||
if (PixelShaders[uid].shader)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(&last_entry_uid, &uid, sizeof(PIXELSHADERUID));
|
||||
|
||||
PSCache::iterator iter;
|
||||
iter = PixelShaders.find(uid);
|
||||
if (iter != PixelShaders.end())
|
||||
@ -71,6 +102,8 @@ bool PixelShaderCache::SetShader(bool dstAlpha)
|
||||
iter->second.frameCount = frameCount;
|
||||
const PSCacheEntry &entry = iter->second;
|
||||
last_entry = &entry;
|
||||
|
||||
|
||||
DEBUGGER_PAUSE_COUNT_N(NEXT_PIXEL_SHADER_CHANGE);
|
||||
|
||||
if (entry.shader)
|
||||
|
@ -51,6 +51,7 @@ private:
|
||||
|
||||
static PSCache PixelShaders;
|
||||
static const PSCacheEntry *last_entry;
|
||||
static PIXELSHADERUID last_entry_uid;
|
||||
|
||||
public:
|
||||
static void Init();
|
||||
|
@ -32,21 +32,47 @@
|
||||
|
||||
VertexShaderCache::VSCache VertexShaderCache::vshaders;
|
||||
const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry;
|
||||
VERTEXSHADERUID VertexShaderCache::last_entry_uid;
|
||||
|
||||
static float lastVSconstants[C_FOGPARAMS+8][4];
|
||||
|
||||
void SetVSConstant4f(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);
|
||||
if( lastVSconstants[const_number][0] != f1 ||
|
||||
lastVSconstants[const_number][1] != f2 ||
|
||||
lastVSconstants[const_number][2] != f3 ||
|
||||
lastVSconstants[const_number][3] != f4)
|
||||
{
|
||||
const float f[4] = {f1, f2, f3, f4};
|
||||
D3D::dev->SetVertexShaderConstantF(const_number, f, 1);
|
||||
lastVSconstants[const_number][0] = f1;
|
||||
lastVSconstants[const_number][1] = f2;
|
||||
lastVSconstants[const_number][2] = f3;
|
||||
lastVSconstants[const_number][3] = f4;
|
||||
}
|
||||
}
|
||||
|
||||
void SetVSConstant4fv(int const_number, const float *f)
|
||||
{
|
||||
D3D::dev->SetVertexShaderConstantF(const_number, f, 1);
|
||||
if( lastVSconstants[const_number][0] != f[0] ||
|
||||
lastVSconstants[const_number][1] != f[1] ||
|
||||
lastVSconstants[const_number][2] != f[2] ||
|
||||
lastVSconstants[const_number][3] != f[3])
|
||||
{
|
||||
D3D::dev->SetVertexShaderConstantF(const_number, f, 1);
|
||||
lastVSconstants[const_number][0] = f[0];
|
||||
lastVSconstants[const_number][1] = f[1];
|
||||
lastVSconstants[const_number][2] = f[2];
|
||||
lastVSconstants[const_number][3] = f[3];
|
||||
}
|
||||
}
|
||||
|
||||
void VertexShaderCache::Init()
|
||||
{
|
||||
for( int i=0; i<C_FOGPARAMS+8*4; i++)
|
||||
lastVSconstants[i/4][i%4]=-1;
|
||||
|
||||
memset(last_entry_uid.values,0xFF,sizeof(last_entry_uid.values));
|
||||
}
|
||||
|
||||
void VertexShaderCache::Shutdown()
|
||||
@ -63,6 +89,14 @@ bool VertexShaderCache::SetShader(u32 components)
|
||||
|
||||
VERTEXSHADERUID uid;
|
||||
GetVertexShaderId(uid, components);
|
||||
if (uid == last_entry_uid)
|
||||
{
|
||||
if (vshaders[uid].shader)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
memcpy(&last_entry_uid, &uid, sizeof(VERTEXSHADERUID));
|
||||
|
||||
VSCache::iterator iter;
|
||||
iter = vshaders.find(uid);
|
||||
|
@ -48,6 +48,7 @@ private:
|
||||
|
||||
static VSCache vshaders;
|
||||
static const VSCacheEntry *last_entry;
|
||||
static VERTEXSHADERUID last_entry_uid;
|
||||
|
||||
public:
|
||||
static void Init();
|
||||
|
Loading…
Reference in New Issue
Block a user