From 9ffc071e34d232e0ed38b6ed0d52c68f8236324f Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Mon, 4 Oct 2010 11:09:32 +0000 Subject: [PATCH] Some stuff which was still lying around on my hard disk: - Add a sanity check in CRenderFrame::MSWWindowProc. Possibly reduces the risk of a crash when starting a game and immediately closing the emulation window when using the DX9 plugin. - DX11: Add the resource usage as a parameter to CreateQuadVertexBuffer, possibly to be used in the future. - reduce the size of the EFB access buffers from 4x4 to 1x1 since they needn't be bigger anymore - some fixes to the recent hires commit. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6256 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/Frame.cpp | 6 ++++++ .../Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp | 20 ++++++++++++++++--- .../Src/FramebufferManager.cpp | 4 ++-- .../Plugin_VideoDX9/Src/TextureCache.cpp | 14 ++++++------- .../Plugin_VideoOGL/Src/TextureCache.cpp | 14 ++++++------- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 301a43fde7..3b5c66136d 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -218,6 +218,12 @@ WXLRESULT CRenderFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPa return wxFrame::MSWWindowProc(nMsg, wParam, lParam); } break; + + case WM_CLOSE: + // Let Core finish initializing before accepting any WM_CLOSE messages + if (Core::GetState() == Core::CORE_UNINITIALIZED) break; + // Use default action otherwise + default: // By default let wxWidgets do what it normally does with this event return wxFrame::MSWWindowProc(nMsg, wParam, lParam); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp index 44d9f3f2fb..6ebc2e17bc 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp @@ -391,15 +391,29 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw return S_OK; } -ID3D11Buffer* CreateQuadVertexBuffer(unsigned int size, void* data) +ID3D11Buffer* CreateQuadVertexBuffer(unsigned int size, void* data, D3D11_USAGE usage = D3D11_USAGE_DYNAMIC) { ID3D11Buffer* vb; D3D11_BUFFER_DESC vbdesc; vbdesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; vbdesc.ByteWidth = size; - vbdesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; vbdesc.MiscFlags = 0; - vbdesc.Usage = D3D11_USAGE_DYNAMIC; + vbdesc.Usage = usage; + switch (usage) + { + case D3D11_USAGE_DEFAULT: + case D3D11_USAGE_IMMUTABLE: + vbdesc.CPUAccessFlags = 0; + break; + + case D3D11_USAGE_DYNAMIC: + vbdesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + break; + + case D3D11_USAGE_STAGING: + vbdesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE|D3D11_CPU_ACCESS_READ; + break; + } if (data) { D3D11_SUBRESOURCE_DATA bufdata; diff --git a/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.cpp index 591fa20844..94cd925886 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.cpp @@ -65,7 +65,7 @@ void FramebufferManager::Create() D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_tex->GetSRV(), "EFB depth texture shader resource view"); // render target for depth buffer access in Renderer::AccessEFB - texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 4, 4, 1, 1, D3D11_BIND_RENDER_TARGET); + texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 1, 1, 1, 1, D3D11_BIND_RENDER_TARGET); hr = D3D::device->CreateTexture2D(&texdesc, NULL, &buf); CHECK(hr==S_OK, "create EFB depth read texture (hr=%#x)", hr); m_efb.depth_read_texture = new D3DTexture2D(buf, D3D11_BIND_RENDER_TARGET); @@ -74,7 +74,7 @@ void FramebufferManager::Create() D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_read_texture->GetRTV(), "EFB depth read texture render target view (used in Renderer::AccessEFB)"); // staging texture to which we copy the data from m_efb.depth_read_texture - texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 4, 4, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ|D3D11_CPU_ACCESS_WRITE); + texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 1, 1, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ|D3D11_CPU_ACCESS_WRITE); hr = D3D::device->CreateTexture2D(&texdesc, NULL, &m_efb.depth_staging_buf); CHECK(hr==S_OK, "create EFB depth staging buffer (hr=%#x)", hr); D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_staging_buf, "EFB depth staging texture (used for Renderer::AccessEFB)"); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp index 650b060df5..d656fd90c4 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp @@ -291,18 +291,16 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, { // Load Custom textures char texPathTemp[MAX_PATH]; - int oldWidth = width; - int oldHeight = height; + int newWidth = width; + int newHeight = height; sprintf(texPathTemp, "%s_%08x_%i", globals->unique_id, texHash, tex_format); - pcfmt = HiresTextures::GetHiresTex(texPathTemp, &width, &height, tex_format, temp); + pcfmt = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, tex_format, temp); if (pcfmt != PC_TEX_FMT_NONE) { - expandedWidth = width; - expandedHeight = height; - entry.Realw = oldWidth; - entry.Realh = oldHeight; + expandedWidth = width = newWidth; + expandedHeight = height = newHeight; } } @@ -394,6 +392,8 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, entry.frameCount = frameCount; entry.w = width; entry.h = height; + entry.Scaledw = width; + entry.Scaledh = height; entry.fmt = FullFormat; if (g_ActiveConfig.bDumpTextures) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 19e61b45ef..2b7baae227 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -382,18 +382,16 @@ TextureCache::TCacheEntry* TextureCache::Load(int texstage, u32 address, int wid // Load Custom textures char texPathTemp[MAX_PATH]; - int oldWidth = width; - int oldHeight = height; - + int newWidth = width; + int newHeight = height; + sprintf(texPathTemp, "%s_%08x_%i", globals->unique_id, (unsigned int) texHash, tex_format); - pcfmt = HiresTextures::GetHiresTex(texPathTemp, &width, &height, tex_format, temp); + pcfmt = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, tex_format, temp); if (pcfmt != PC_TEX_FMT_NONE) { - expandedWidth = width; - expandedHeight = height; - entry.Realw = oldWidth; - entry.Realh = oldHeight; + expandedWidth = width = newWidth; + expandedHeight = height = newHeight; } }