Improve the shader UID debugging stuff and merge it to VideoCommon, effectively enabling it in D3D9 and D3D11 as well.

This commit is contained in:
NeoBrainX
2011-09-09 00:32:04 +02:00
parent 349a3ae91d
commit b28348066e
16 changed files with 614 additions and 527 deletions

View File

@ -461,6 +461,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
{
PSCache::const_iterator iter = PixelShaders.find(uid);
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE,true);
ValidatePixelShaderIDs(API_D3D11, PixelShaders[uid].safe_uid, PixelShaders[uid].code, dstAlphaMode, components);
return (iter != PixelShaders.end() && iter->second.shader);
}
@ -476,6 +477,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
last_entry = &entry;
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE,true);
ValidatePixelShaderIDs(API_D3D11, entry.safe_uid, entry.code, dstAlphaMode, components);
return (entry.shader != NULL);
}
@ -494,10 +496,17 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
g_ps_disk_cache.Append(uid, pbytecode->Data(), pbytecode->Size());
g_ps_disk_cache.Sync();
bool result = InsertByteCode(uid, pbytecode->Data(), pbytecode->Size());
bool success = InsertByteCode(uid, pbytecode->Data(), pbytecode->Size());
pbytecode->Release();
if (success)
{
PixelShaders[uid].code = code;
GetSafePixelShaderId(&PixelShaders[uid].safe_uid, dstAlphaMode);
}
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
return result;
return success;
}
bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const void* bytecode, unsigned int bytecodelen)

View File

@ -55,6 +55,9 @@ private:
ID3D11PixelShader* shader;
int frameCount;
PIXELSHADERUIDSAFE safe_uid;
std::string code;
PSCacheEntry() : shader(NULL), frameCount(0) {}
void Destroy() { SAFE_RELEASE(shader); }
};

View File

@ -205,6 +205,7 @@ bool VertexShaderCache::SetShader(u32 components)
if (uid == last_vertex_shader_uid && vshaders[uid].frameCount == frameCount)
{
GFX_DEBUGGER_PAUSE_AT(NEXT_VERTEX_SHADER_CHANGE, true);
ValidateVertexShaderIDs(API_D3D11, vshaders[uid].safe_uid, vshaders[uid].code, components);
return (vshaders[uid].shader != NULL);
}
@ -218,6 +219,7 @@ bool VertexShaderCache::SetShader(u32 components)
last_entry = &entry;
GFX_DEBUGGER_PAUSE_AT(NEXT_VERTEX_SHADER_CHANGE, true);
ValidateVertexShaderIDs(API_D3D11, entry.safe_uid, entry.code, components);
return (entry.shader != NULL);
}
@ -235,10 +237,17 @@ bool VertexShaderCache::SetShader(u32 components)
g_vs_disk_cache.Append(uid, pbytecode->Data(), pbytecode->Size());
g_vs_disk_cache.Sync();
bool result = InsertByteCode(uid, pbytecode);
bool success = InsertByteCode(uid, pbytecode);
pbytecode->Release();
if (success)
{
vshaders[uid].code = code;
GetSafeVertexShaderId(&vshaders[uid].safe_uid, components);
}
GFX_DEBUGGER_PAUSE_AT(NEXT_VERTEX_SHADER_CHANGE, true);
return result;
return success;
}
bool VertexShaderCache::InsertByteCode(const VERTEXSHADERUID &uid, D3DBlob* bcodeblob)

View File

@ -53,6 +53,9 @@ private:
D3DBlob* bytecode; // needed to initialize the input layout
int frameCount;
VERTEXSHADERUIDSAFE safe_uid;
std::string code;
VSCacheEntry() : shader(NULL), bytecode(NULL), frameCount(0) {}
void SetByteCode(D3DBlob* blob)
{