summaryrefslogtreecommitdiff
path: root/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2010-11-15 05:22:03 +0000
committerJordan Woyak <jordan.woyak@gmail.com>2010-11-15 05:22:03 +0000
commitb4ffd640b7a5f66309bcf22e9008e0059f66ca98 (patch)
tree51d659dfb995e20814513614d749ce4e1858dd41 /Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp
parentb0257521929246188b1ea067db398a5770d766ba (diff)
Made LinearDiskCache a template class. Keys are now some POD type (fixed size). Eliminates casting and key size checking.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6420 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp')
-rw-r--r--Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp
index d83fba4dfd..4dd0338539 100644
--- a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp
@@ -38,7 +38,7 @@ extern int frameCount;
PixelShaderCache::PSCache PixelShaderCache::PixelShaders;
const PixelShaderCache::PSCacheEntry* PixelShaderCache::last_entry;
-LinearDiskCache g_ps_disk_cache;
+LinearDiskCache<PIXELSHADERUID, u8> g_ps_disk_cache;
ID3D11PixelShader* s_ColorMatrixProgram = NULL;
ID3D11PixelShader* s_ColorCopyProgram = NULL;
@@ -158,17 +158,12 @@ void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const
}
// this class will load the precompiled shaders into our cache
-class PixelShaderCacheInserter : public LinearDiskCacheReader {
+class PixelShaderCacheInserter : public LinearDiskCacheReader<PIXELSHADERUID, u8>
+{
public:
- void Read(const u8* key, int key_size, const u8* value, int value_size)
+ void Read(const PIXELSHADERUID &key, const u8 *value, u32 value_size)
{
- PIXELSHADERUID uid;
- if (key_size != sizeof(uid)) {
- ERROR_LOG(VIDEO, "Wrong key size in pixel shader cache");
- return;
- }
- memcpy(&uid, key, key_size);
- PixelShaderCache::InsertByteCode(uid, (void*)value, value_size);
+ PixelShaderCache::InsertByteCode(key, value, value_size);
}
};
@@ -205,7 +200,7 @@ void PixelShaderCache::Init()
char cache_filename[MAX_PATH];
sprintf(cache_filename, "%sdx11-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id);
PixelShaderCacheInserter inserter;
- g_ps_disk_cache.OpenAndRead(cache_filename, &inserter);
+ g_ps_disk_cache.OpenAndRead(cache_filename, inserter);
}
// ONLY to be used during shutdown.
@@ -266,7 +261,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
}
// Insert the bytecode into the caches
- g_ps_disk_cache.Append((u8*)&uid, sizeof(uid), (const u8*)pbytecode->Data(), pbytecode->Size());
+ g_ps_disk_cache.Append(uid, pbytecode->Data(), pbytecode->Size());
g_ps_disk_cache.Sync();
bool result = InsertByteCode(uid, pbytecode->Data(), pbytecode->Size());
@@ -275,7 +270,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
return result;
}
-bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, void* bytecode, unsigned int bytecodelen)
+bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const void* bytecode, unsigned int bytecodelen)
{
ID3D11PixelShader* shader = D3D::CreatePixelShaderFromByteCode(bytecode, bytecodelen);
if (shader == NULL)