From e4d5eb5d6cf45ff134fe187d8ebd3fb73e06eaab Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 13 Sep 2014 19:56:08 -0700 Subject: [PATCH] d3d: Dynamically size the drawPixelsTex_ like gl. --- GPU/Directx9/FramebufferDX9.cpp | 39 +++++++++++++++++++-------------- GPU/Directx9/FramebufferDX9.h | 3 ++- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index 00d4e3d6b5..13b17c7eab 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -122,26 +122,12 @@ namespace DX9 { FramebufferManagerDX9::FramebufferManagerDX9() : drawPixelsTex_(0), - drawPixelsTexFormat_(GE_FORMAT_INVALID), convBuf(0), - gameUsesSequentialCopies_(false) - { - // TODO: Check / use D3DCAPS2_DYNAMICTEXTURES? - int usage = 0; - D3DPOOL pool = D3DPOOL_MANAGED; - if (pD3DdeviceEx) { - pool = D3DPOOL_DEFAULT; - usage = D3DUSAGE_DYNAMIC; - } - HRESULT hr = pD3Ddevice->CreateTexture(512, 272, 1, usage, D3DFMT(D3DFMT_A8R8G8B8), pool, &drawPixelsTex_, NULL); - if (FAILED(hr)) { - drawPixelsTex_ = nullptr; - ERROR_LOG(G3D, "Failed to create drawpixels texture"); - } + gameUsesSequentialCopies_(false) { } FramebufferManagerDX9::~FramebufferManagerDX9() { - if(drawPixelsTex_) { + if (drawPixelsTex_) { drawPixelsTex_->Release(); } delete [] convBuf; @@ -166,10 +152,29 @@ namespace DX9 { } void FramebufferManagerDX9::MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) { - u8 *convBuf = NULL; D3DLOCKED_RECT rect; + // TODO: Check / use D3DCAPS2_DYNAMICTEXTURES? + if (drawPixelsTex_ && (drawPixelsTexW_ != width || drawPixelsTexH_ != height)) { + drawPixelsTex_->Release(); + drawPixelsTex_ = nullptr; + } + + if (!drawPixelsTex_) { + int usage = 0; + D3DPOOL pool = D3DPOOL_MANAGED; + if (pD3DdeviceEx) { + pool = D3DPOOL_DEFAULT; + usage = D3DUSAGE_DYNAMIC; + } + HRESULT hr = pD3Ddevice->CreateTexture(width, height, 1, usage, D3DFMT(D3DFMT_A8R8G8B8), pool, &drawPixelsTex_, NULL); + if (FAILED(hr)) { + drawPixelsTex_ = nullptr; + ERROR_LOG(G3D, "Failed to create drawpixels texture"); + } + } + if (!drawPixelsTex_) { return; } diff --git a/GPU/Directx9/FramebufferDX9.h b/GPU/Directx9/FramebufferDX9.h index bafd1cade8..aa650d201d 100644 --- a/GPU/Directx9/FramebufferDX9.h +++ b/GPU/Directx9/FramebufferDX9.h @@ -109,7 +109,8 @@ private: // Used by DrawPixels LPDIRECT3DTEXTURE9 drawPixelsTex_; - GEBufferFormat drawPixelsTexFormat_; + int drawPixelsTexW_; + int drawPixelsTexH_; u8 *convBuf;