Fix for the hang after close caused by my previews perf queries commit.

Sorry for that.
fix issue 6205
This commit is contained in:
Rodolfo Bogado 2013-04-04 12:53:06 -03:00
parent e11f5630b1
commit d032f3fd79
4 changed files with 24 additions and 12 deletions

View File

@ -8,6 +8,16 @@ namespace DX9 {
PerfQuery::PerfQuery()
: m_query_read_pos()
, m_query_count()
{
}
PerfQuery::~PerfQuery()
{
}
void PerfQuery::CreateDeviceObjects()
{
for (int i = 0; i != ARRAYSIZE(m_query_buffer); ++i)
{
@ -15,8 +25,7 @@ PerfQuery::PerfQuery()
}
ResetQuery();
}
PerfQuery::~PerfQuery()
void PerfQuery::DestroyDeviceObjects()
{
for (int i = 0; i != ARRAYSIZE(m_query_buffer); ++i)
{
@ -91,7 +100,7 @@ void PerfQuery::FlushOne()
{
auto& entry = m_query_buffer[m_query_read_pos];
UINT64 result = 0;
DWORD result = 0;
HRESULT hr = S_FALSE;
while (hr != S_OK && hr != D3DERR_DEVICELOST)
{
@ -100,7 +109,7 @@ void PerfQuery::FlushOne()
}
// NOTE: Reported pixel metrics should be referenced to native resolution
m_results[entry.query_type] += (u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight();
m_results[entry.query_type] += (u32)((u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight());
m_query_read_pos = (m_query_read_pos + 1) % ARRAYSIZE(m_query_buffer);
--m_query_count;
@ -119,13 +128,13 @@ void PerfQuery::WeakFlush()
{
auto& entry = m_query_buffer[m_query_read_pos];
UINT64 result = 0;
DWORD result = 0;
HRESULT hr = entry.query->GetData(&result, sizeof(result), 0);
if (hr == S_OK)
{
// NOTE: Reported pixel metrics should be referenced to native resolution
m_results[entry.query_type] += (u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight();
m_results[entry.query_type] += (u32)((u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight());
m_query_read_pos = (m_query_read_pos + 1) % ARRAYSIZE(m_query_buffer);
--m_query_count;

View File

@ -17,6 +17,8 @@ public:
u32 GetQueryResult(PerfQueryType type);
void FlushResults();
bool IsFlushed() const;
void CreateDeviceObjects();
void DestroyDeviceObjects();
private:
struct ActiveQuery
@ -25,8 +27,7 @@ private:
PerfQueryGroup query_type;
};
void WeakFlush();
void WeakFlush();
// Only use when non-empty
void FlushOne();

View File

@ -88,7 +88,7 @@ void SetupDeviceObjects()
VertexShaderCache::Init();
PixelShaderCache::Init();
g_vertex_manager->CreateDeviceObjects();
g_perf_query = new PerfQuery;
((PerfQuery*)g_perf_query)->CreateDeviceObjects();
// Texture cache will recreate themselves over time.
}
@ -101,7 +101,7 @@ void TeardownDeviceObjects()
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
delete g_framebuffer_manager;
delete g_perf_query;
((PerfQuery*)g_perf_query)->DestroyDeviceObjects();
D3D::font.Shutdown();
TextureCache::Invalidate();
VertexLoaderManager::Shutdown();

View File

@ -57,6 +57,7 @@
#include "ConfigManager.h"
#include "VideoBackend.h"
#include "PerfQuery.h"
namespace DX9
{
@ -176,8 +177,9 @@ void VideoBackend::Video_Prepare()
// internal interfaces
g_vertex_manager = new VertexManager;
g_perf_query = new PerfQuery;
g_renderer = new Renderer;
g_texture_cache = new TextureCache;
g_texture_cache = new TextureCache;
// VideoCommon
BPInit();
Fifo_Init();
@ -215,9 +217,9 @@ void VideoBackend::Shutdown()
// internal interfaces
PixelShaderCache::Shutdown();
VertexShaderCache::Shutdown();
delete g_perf_query;
delete g_texture_cache;
delete g_renderer;
delete g_perf_query;
delete g_vertex_manager;
g_renderer = NULL;
g_texture_cache = NULL;