Permalink
Browse files

D3D9: Use an unordered_map for offscreen.

Also cleanup.  Mostly just for consistent usage.
  • Loading branch information...
unknownbrackets committed Jun 3, 2018
1 parent e90b01d commit 2ab1552f2d8984d46c59a18f54ef67edf57a378b
Showing with 16 additions and 28 deletions.
  1. +6 −11 GPU/Directx9/FramebufferDX9.cpp
  2. +10 −17 GPU/Directx9/FramebufferDX9.h
@@ -82,12 +82,7 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
};
FramebufferManagerDX9::FramebufferManagerDX9(Draw::DrawContext *draw)
: FramebufferManagerCommon(draw),
drawPixelsTex_(0),
convBuf(0),
stencilUploadPS_(nullptr),
stencilUploadVS_(nullptr),
stencilUploadFailed_(false) {
: FramebufferManagerCommon(draw) {
device_ = (LPDIRECT3DDEVICE9)draw->GetNativeObject(Draw::NativeObject::DEVICE);
deviceEx_ = (LPDIRECT3DDEVICE9)draw->GetNativeObject(Draw::NativeObject::DEVICE_EX);
@@ -119,8 +114,8 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
if (drawPixelsTex_) {
drawPixelsTex_->Release();
}
for (auto it = offscreenSurfaces_.begin(), end = offscreenSurfaces_.end(); it != end; ++it) {
it->second.surface->Release();
for (auto &it : offscreenSurfaces_) {
it.second.surface->Release();
}
delete [] convBuf;
if (stencilUploadPS_) {
@@ -680,7 +675,7 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
int age = frameLastFramebufUsed_ - it->second.last_frame_used;
if (age > FBO_OLD_AGE) {
it->second.surface->Release();
offscreenSurfaces_.erase(it++);
it = offscreenSurfaces_.erase(it);
} else {
++it;
}
@@ -706,8 +701,8 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
}
bvfbs_.clear();
for (auto it = offscreenSurfaces_.begin(), end = offscreenSurfaces_.end(); it != end; ++it) {
it->second.surface->Release();
for (auto &it : offscreenSurfaces_) {
it.second.surface->Release();
}
offscreenSurfaces_.clear();
@@ -17,9 +17,7 @@
#pragma once
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <d3d9.h>
@@ -91,20 +89,20 @@ class FramebufferManagerDX9 : public FramebufferManagerCommon {
LPDIRECT3DDEVICE9 deviceEx_;
// Used by DrawPixels
LPDIRECT3DTEXTURE9 drawPixelsTex_;
LPDIRECT3DTEXTURE9 drawPixelsTex_ = nullptr;
int drawPixelsTexW_;
int drawPixelsTexH_;
LPDIRECT3DVERTEXSHADER9 pFramebufferVertexShader;
LPDIRECT3DPIXELSHADER9 pFramebufferPixelShader;
LPDIRECT3DVERTEXDECLARATION9 pFramebufferVertexDecl;
LPDIRECT3DVERTEXSHADER9 pFramebufferVertexShader = nullptr;
LPDIRECT3DPIXELSHADER9 pFramebufferPixelShader = nullptr;
LPDIRECT3DVERTEXDECLARATION9 pFramebufferVertexDecl = nullptr;
u8 *convBuf;
u8 *convBuf = nullptr;
int plainColorLoc_;
LPDIRECT3DPIXELSHADER9 stencilUploadPS_;
LPDIRECT3DVERTEXSHADER9 stencilUploadVS_;
bool stencilUploadFailed_;
LPDIRECT3DPIXELSHADER9 stencilUploadPS_ = nullptr;
LPDIRECT3DVERTEXSHADER9 stencilUploadVS_ = nullptr;
bool stencilUploadFailed_ = false;
TextureCacheDX9 *textureCacheDX9_;
ShaderManagerDX9 *shaderManagerDX9_;
@@ -115,12 +113,7 @@ class FramebufferManagerDX9 : public FramebufferManagerCommon {
int last_frame_used;
};
std::map<u64, OffscreenSurface> offscreenSurfaces_;
#if 0
AsyncPBO *pixelBufObj_; //this isn't that large
u8 currentPBO_;
#endif
std::unordered_map<u64, OffscreenSurface> offscreenSurfaces_;
};
};

0 comments on commit 2ab1552

Please sign in to comment.