D3D9: Fix issue where the shader caches were lost whenever the render window was resized. Add some error logging to LinearDiskCache. + some minor cleanup.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5747 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
8c6ae1f6f4
commit
ccbc1feb0b
|
@ -46,6 +46,11 @@ bool LinearDiskCache::ValidateHeader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int LinearDiskCache::OpenAndRead(const char *filename, LinearDiskCacheReader *reader) {
|
int LinearDiskCache::OpenAndRead(const char *filename, LinearDiskCacheReader *reader) {
|
||||||
|
if (file_)
|
||||||
|
{
|
||||||
|
ERROR_LOG(VIDEO, "LinearDiskCache trying to open an alredy opened cache");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int items_read_count = 0;
|
int items_read_count = 0;
|
||||||
file_ = fopen(filename, "rb");
|
file_ = fopen(filename, "rb");
|
||||||
int file_size = 0;
|
int file_size = 0;
|
||||||
|
@ -143,11 +148,25 @@ void LinearDiskCache::Append(
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinearDiskCache::Sync() {
|
void LinearDiskCache::Sync() {
|
||||||
fflush(file_);
|
if (file_)
|
||||||
|
{
|
||||||
|
fflush(file_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ERROR_LOG(VIDEO, "LinearDiskCache trying to sync closed cache");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinearDiskCache::Close() {
|
void LinearDiskCache::Close() {
|
||||||
fclose(file_);
|
if (file_)
|
||||||
file_ = 0;
|
{
|
||||||
num_entries_ = 0;
|
fclose(file_);
|
||||||
|
file_ = 0;
|
||||||
|
num_entries_ = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ERROR_LOG(VIDEO, "LinearDiskCache trying to close an alredy closed cache");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,6 @@ public:
|
||||||
static void ResetAPIState();
|
static void ResetAPIState();
|
||||||
static void RestoreAPIState();
|
static void RestoreAPIState();
|
||||||
|
|
||||||
static void ReinitView();
|
|
||||||
|
|
||||||
static void SetColorMask();
|
static void SetColorMask();
|
||||||
static void SetBlendMode(bool forceUpdate);
|
static void SetBlendMode(bool forceUpdate);
|
||||||
static bool SetScissorRect();
|
static bool SetScissorRect();
|
||||||
|
|
|
@ -333,12 +333,10 @@ void GFXDebuggerDX9::OnClearTextureCacheButton(wxCommandEvent& event)
|
||||||
|
|
||||||
void GFXDebuggerDX9::OnClearVertexShaderCacheButton(wxCommandEvent& event)
|
void GFXDebuggerDX9::OnClearVertexShaderCacheButton(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
VertexShaderCache::Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GFXDebuggerDX9::OnClearPixelShaderCacheButton(wxCommandEvent& event)
|
void GFXDebuggerDX9::OnClearPixelShaderCacheButton(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
PixelShaderCache::Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFPSDisplay(const char *text);
|
void UpdateFPSDisplay(const char *text);
|
||||||
|
|
|
@ -297,8 +297,8 @@ void GFXConfigDialogDX::CreateGUIControls()
|
||||||
m_OverlayFPS = new wxCheckBox( m_PageAdvanced, ID_OVERLAYFPS, wxT("Overlay FPS Counter"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_OverlayFPS = new wxCheckBox( m_PageAdvanced, ID_OVERLAYFPS, wxT("Overlay FPS Counter"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_CopyEFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEEFBCOPY, wxT("Enable EFB Copy"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_CopyEFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEEFBCOPY, wxT("Enable EFB Copy"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_EnableHotkeys = new wxCheckBox( m_PageAdvanced, ID_ENABLEHOTKEY, wxT("Enable Hotkey"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_EnableHotkeys = new wxCheckBox( m_PageAdvanced, ID_ENABLEHOTKEY, wxT("Enable Hotkey"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_Radio_CopyEFBToRAM = new wxRadioButton( m_PageAdvanced, ID_EFBTORAM, wxT("To Ram"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_Radio_CopyEFBToRAM = new wxRadioButton( m_PageAdvanced, ID_EFBTORAM, wxT("To RAM (accuracy)"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_Radio_CopyEFBToGL = new wxRadioButton( m_PageAdvanced, ID_EFBTOTEX, wxT("To Texture"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_Radio_CopyEFBToGL = new wxRadioButton( m_PageAdvanced, ID_EFBTOTEX, wxT("To Texture (performance, resolution)"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_WireFrame = new wxCheckBox( m_PageAdvanced, ID_WIREFRAME, wxT("Enable Wireframe"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_WireFrame = new wxCheckBox( m_PageAdvanced, ID_WIREFRAME, wxT("Enable Wireframe"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_EnableRealXFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEREALXFB, wxT("Enable Real XFB"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_EnableRealXFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEREALXFB, wxT("Enable Real XFB"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_EnableXFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEXFB, wxT("Enable XFB"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_EnableXFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEXFB, wxT("Enable XFB"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
|
|
@ -258,6 +258,9 @@ void PixelShaderCache::Init()
|
||||||
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
||||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
||||||
|
|
||||||
|
SETSTAT(stats.numPixelShadersCreated, 0);
|
||||||
|
SETSTAT(stats.numPixelShadersAlive, 0);
|
||||||
|
|
||||||
char cache_filename[MAX_PATH];
|
char cache_filename[MAX_PATH];
|
||||||
sprintf(cache_filename, "%sdx9-%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;
|
PixelShaderCacheInserter inserter;
|
||||||
|
|
|
@ -54,11 +54,10 @@ private:
|
||||||
|
|
||||||
static PSCache PixelShaders;
|
static PSCache PixelShaders;
|
||||||
static const PSCacheEntry *last_entry;
|
static const PSCacheEntry *last_entry;
|
||||||
|
static void Clear();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Init();
|
static void Init();
|
||||||
static void Clear();
|
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
static bool SetShader(bool dstAlpha);
|
static bool SetShader(bool dstAlpha);
|
||||||
static bool InsertByteCode(const PIXELSHADERUID &uid, const u8 *bytecode, int bytecodelen, bool activate);
|
static bool InsertByteCode(const PIXELSHADERUID &uid, const u8 *bytecode, int bytecodelen, bool activate);
|
||||||
|
|
|
@ -225,8 +225,12 @@ void SetupDeviceObjects()
|
||||||
VertexShaderManager::Dirty();
|
VertexShaderManager::Dirty();
|
||||||
PixelShaderManager::Dirty();
|
PixelShaderManager::Dirty();
|
||||||
TextureConverter::Init();
|
TextureConverter::Init();
|
||||||
// Tex and shader caches will recreate themselves over time.
|
|
||||||
|
// To avoid shader compilation stutters, read back all shaders from cache.
|
||||||
|
VertexShaderCache::Init();
|
||||||
|
PixelShaderCache::Init();
|
||||||
|
|
||||||
|
// Texture cache will recreate themselves over time.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill off all POOL_DEFAULT device objects.
|
// Kill off all POOL_DEFAULT device objects.
|
||||||
|
@ -241,8 +245,8 @@ void TeardownDeviceObjects()
|
||||||
D3D::font.Shutdown();
|
D3D::font.Shutdown();
|
||||||
TextureCache::Invalidate(false);
|
TextureCache::Invalidate(false);
|
||||||
VertexLoaderManager::Shutdown();
|
VertexLoaderManager::Shutdown();
|
||||||
VertexShaderCache::Clear();
|
VertexShaderCache::Shutdown();
|
||||||
PixelShaderCache::Clear();
|
PixelShaderCache::Shutdown();
|
||||||
TextureConverter::Shutdown();
|
TextureConverter::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +503,6 @@ void CheckForResize()
|
||||||
{
|
{
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (EmuWindow::GetParentWnd())
|
if (EmuWindow::GetParentWnd())
|
||||||
{
|
{
|
||||||
|
|
|
@ -214,6 +214,9 @@ void VertexShaderCache::Init()
|
||||||
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
||||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
||||||
|
|
||||||
|
SETSTAT(stats.numVertexShadersCreated, 0);
|
||||||
|
SETSTAT(stats.numVertexShadersAlive, 0);
|
||||||
|
|
||||||
char cache_filename[MAX_PATH];
|
char cache_filename[MAX_PATH];
|
||||||
sprintf(cache_filename, "%sdx9-%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;
|
VertexShaderCacheInserter inserter;
|
||||||
|
@ -234,7 +237,7 @@ void VertexShaderCache::Clear()
|
||||||
|
|
||||||
void VertexShaderCache::Shutdown()
|
void VertexShaderCache::Shutdown()
|
||||||
{
|
{
|
||||||
for (int i = 0; i<3;i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if (SimpleVertexShader[i])
|
if (SimpleVertexShader[i])
|
||||||
SimpleVertexShader[i]->Release();
|
SimpleVertexShader[i]->Release();
|
||||||
|
@ -245,7 +248,6 @@ void VertexShaderCache::Shutdown()
|
||||||
ClearVertexShader->Release();
|
ClearVertexShader->Release();
|
||||||
ClearVertexShader = NULL;
|
ClearVertexShader = NULL;
|
||||||
|
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
g_vs_disk_cache.Sync();
|
g_vs_disk_cache.Sync();
|
||||||
g_vs_disk_cache.Close();
|
g_vs_disk_cache.Close();
|
||||||
|
|
|
@ -49,10 +49,10 @@ private:
|
||||||
|
|
||||||
static VSCache vshaders;
|
static VSCache vshaders;
|
||||||
static const VSCacheEntry *last_entry;
|
static const VSCacheEntry *last_entry;
|
||||||
|
static void Clear();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Init();
|
static void Init();
|
||||||
static void Clear();
|
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
static bool SetShader(u32 components);
|
static bool SetShader(u32 components);
|
||||||
static LPDIRECT3DVERTEXSHADER9 GetSimpleVertexShader(int level);
|
static LPDIRECT3DVERTEXSHADER9 GetSimpleVertexShader(int level);
|
||||||
|
|
|
@ -287,9 +287,7 @@ void Video_Prepare()
|
||||||
Fifo_Init();
|
Fifo_Init();
|
||||||
VertexLoaderManager::Init();
|
VertexLoaderManager::Init();
|
||||||
OpcodeDecoder_Init();
|
OpcodeDecoder_Init();
|
||||||
VertexShaderCache::Init();
|
|
||||||
VertexShaderManager::Init();
|
VertexShaderManager::Init();
|
||||||
PixelShaderCache::Init();
|
|
||||||
PixelShaderManager::Init();
|
PixelShaderManager::Init();
|
||||||
CommandProcessor::Init();
|
CommandProcessor::Init();
|
||||||
PixelEngine::Init();
|
PixelEngine::Init();
|
||||||
|
@ -307,9 +305,7 @@ void Shutdown()
|
||||||
CommandProcessor::Shutdown();
|
CommandProcessor::Shutdown();
|
||||||
VertexManager::Shutdown();
|
VertexManager::Shutdown();
|
||||||
VertexLoaderManager::Shutdown();
|
VertexLoaderManager::Shutdown();
|
||||||
VertexShaderCache::Shutdown();
|
|
||||||
VertexShaderManager::Shutdown();
|
VertexShaderManager::Shutdown();
|
||||||
PixelShaderCache::Shutdown();
|
|
||||||
PixelShaderManager::Shutdown();
|
PixelShaderManager::Shutdown();
|
||||||
TextureCache::Shutdown();
|
TextureCache::Shutdown();
|
||||||
OpcodeDecoder_Shutdown();
|
OpcodeDecoder_Shutdown();
|
||||||
|
|
|
@ -448,8 +448,8 @@ void GFXConfigDialogOGL::CreateGUIControls()
|
||||||
|
|
||||||
m_StaticBox_EFB = new wxStaticBox(m_PageAdvanced, ID_STATICBOX_EFB, wxT("EFB Copy"));
|
m_StaticBox_EFB = new wxStaticBox(m_PageAdvanced, ID_STATICBOX_EFB, wxT("EFB Copy"));
|
||||||
m_CheckBox_DisableCopyEFB = new wxCheckBox(m_PageAdvanced, ID_CHECKBOX_DISABLECOPYEFB, wxT("Disable"));
|
m_CheckBox_DisableCopyEFB = new wxCheckBox(m_PageAdvanced, ID_CHECKBOX_DISABLECOPYEFB, wxT("Disable"));
|
||||||
m_Radio_CopyEFBToRAM = new wxRadioButton(m_PageAdvanced, ID_RADIO_COPYEFBTORAM, wxT("Copy EFB to system RAM (real)"));
|
m_Radio_CopyEFBToRAM = new wxRadioButton(m_PageAdvanced, ID_RADIO_COPYEFBTORAM, wxT("To RAM (accuracy)"));
|
||||||
m_Radio_CopyEFBToGL = new wxRadioButton(m_PageAdvanced, ID_RADIO_COPYEFBTOGL, wxT("Copy EFB to GL texture (hack)"));
|
m_Radio_CopyEFBToGL = new wxRadioButton(m_PageAdvanced, ID_RADIO_COPYEFBTOGL, wxT("To GL texture (performance)"));
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
sbUtilities = new wxStaticBoxSizer(wxVERTICAL, m_PageAdvanced, wxT("Utilities"));
|
sbUtilities = new wxStaticBoxSizer(wxVERTICAL, m_PageAdvanced, wxT("Utilities"));
|
||||||
|
|
|
@ -571,11 +571,6 @@ void Renderer::ResetAPIState()
|
||||||
|
|
||||||
void UpdateViewport();
|
void UpdateViewport();
|
||||||
|
|
||||||
void Renderer::ReinitView()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::RestoreAPIState()
|
void Renderer::RestoreAPIState()
|
||||||
{
|
{
|
||||||
// Gets us back into a more game-like state.
|
// Gets us back into a more game-like state.
|
||||||
|
|
Loading…
Reference in New Issue