mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 15:30:29 +02:00
Fix a number of resource leaks, both D3D11-only and general.
Additionally, fix D3D11 BlitFramebuffer
This commit is contained in:
1 parent
13a3d179d5
commit
2fabe3e1c5
10 files changed
+47
-39
No files matched your search
@@ -505,7 +505,7 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(const Frame
|
||||
void FramebufferManagerCommon::DestroyFramebuf(VirtualFramebuffer *v) {
|
||||
textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED);
|
||||
if (v->fbo) {
|
||||
delete v->fbo;
|
||||
v->fbo->Release();
|
||||
v->fbo = nullptr;
|
||||
}
|
||||
|
||||
@@ -1028,7 +1028,7 @@ void FramebufferManagerCommon::DecimateFBOs() {
|
||||
for (auto it = tempFBOs_.begin(); it != tempFBOs_.end(); ) {
|
||||
int age = frameLastFramebufUsed_ - it->second.last_frame_used;
|
||||
if (age > FBO_OLD_AGE) {
|
||||
delete it->second.fbo;
|
||||
it->second.fbo->Release();
|
||||
tempFBOs_.erase(it++);
|
||||
} else {
|
||||
++it;
|
||||
|
||||
@@ -116,6 +116,8 @@ void StockObjectsD3D11::Destroy() {
|
||||
rasterStateNoCull->Release();
|
||||
samplerPoint2DWrap->Release();
|
||||
samplerLinear2DWrap->Release();
|
||||
samplerPoint2DClamp->Release();
|
||||
samplerLinear2DClamp->Release();
|
||||
}
|
||||
|
||||
StockObjectsD3D11 stockD3D11;
|
||||
@@ -100,16 +100,36 @@ DrawEngineD3D11::DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device,
|
||||
|
||||
InitDeviceObjects();
|
||||
|
||||
tessDataTransfer = new TessellationDataTransferD3D11();
|
||||
|
||||
// Vertex pushing buffers. For uniforms we use short DISCARD buffers, but we could use
|
||||
// this kind of buffer there as well with D3D11.1. We might be able to use the same buffer
|
||||
// for both vertices and indices, and possibly all three data types.
|
||||
pushVerts_ = new PushBufferD3D11(device, VERTEX_PUSH_SIZE, D3D11_BIND_VERTEX_BUFFER);
|
||||
pushInds_ = new PushBufferD3D11(device, INDEX_PUSH_SIZE, D3D11_BIND_INDEX_BUFFER);
|
||||
}
|
||||
|
||||
DrawEngineD3D11::~DrawEngineD3D11() {
|
||||
DestroyDeviceObjects();
|
||||
FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
|
||||
FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
|
||||
FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE);
|
||||
FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE);
|
||||
FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void DrawEngineD3D11::InitDeviceObjects() {
|
||||
pushVerts_ = new PushBufferD3D11(device_, VERTEX_PUSH_SIZE, D3D11_BIND_VERTEX_BUFFER);
|
||||
pushInds_ = new PushBufferD3D11(device_, INDEX_PUSH_SIZE, D3D11_BIND_INDEX_BUFFER);
|
||||
|
||||
tessDataTransfer = new TessellationDataTransferD3D11();
|
||||
}
|
||||
|
||||
void DrawEngineD3D11::ClearTrackedVertexArrays() {
|
||||
for (auto &vai : vai_) {
|
||||
delete vai.second;
|
||||
}
|
||||
vai_.clear();
|
||||
}
|
||||
|
||||
void DrawEngineD3D11::DestroyDeviceObjects() {
|
||||
delete tessDataTransfer;
|
||||
delete pushVerts_;
|
||||
delete pushInds_;
|
||||
|
||||
@@ -122,23 +142,9 @@ DrawEngineD3D11::~DrawEngineD3D11() {
|
||||
for (auto &blend : blendCache_) {
|
||||
blend.second->Release();
|
||||
}
|
||||
|
||||
DestroyDeviceObjects();
|
||||
FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
|
||||
FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
|
||||
FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE);
|
||||
FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE);
|
||||
FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
|
||||
|
||||
delete tessDataTransfer;
|
||||
}
|
||||
|
||||
void DrawEngineD3D11::InitDeviceObjects() {
|
||||
|
||||
}
|
||||
|
||||
void DrawEngineD3D11::DestroyDeviceObjects() {
|
||||
ClearTrackedVertexArrays();
|
||||
for (auto &raster : rasterCache_) {
|
||||
raster.second->Release();
|
||||
}
|
||||
}
|
||||
|
||||
struct DeclTypeInfo {
|
||||
@@ -508,13 +514,6 @@ ReliableHashType DrawEngineD3D11::ComputeHash() {
|
||||
return fullhash;
|
||||
}
|
||||
|
||||
void DrawEngineD3D11::ClearTrackedVertexArrays() {
|
||||
for (auto vai = vai_.begin(); vai != vai_.end(); vai++) {
|
||||
delete vai->second;
|
||||
}
|
||||
vai_.clear();
|
||||
}
|
||||
|
||||
void DrawEngineD3D11::BeginFrame() {
|
||||
pushVerts_->Reset();
|
||||
pushInds_->Reset();
|
||||
|
||||
@@ -124,7 +124,7 @@ FramebufferManagerD3D11::~FramebufferManagerD3D11() {
|
||||
|
||||
// FBO cleanup
|
||||
for (auto it = tempFBOs_.begin(), end = tempFBOs_.end(); it != end; ++it) {
|
||||
delete it->second.fbo;
|
||||
it->second.fbo->Release();
|
||||
}
|
||||
delete[] convBuf;
|
||||
|
||||
@@ -568,6 +568,8 @@ void FramebufferManagerD3D11::SimpleBlit(
|
||||
draw_->BindFramebufferAsTexture(src, 0, Draw::FB_COLOR_BIT, 0);
|
||||
draw_->BindFramebufferAsRenderTarget(dest);
|
||||
Bind2DShader();
|
||||
D3D11_VIEWPORT vp{ 0.0f, 0.0f, (float)destW, (float)destH, 0.0f, 1.0f };
|
||||
context_->RSSetViewports(1, &vp);
|
||||
context_->RSSetState(stockD3D11.rasterStateNoCull);
|
||||
context_->OMSetBlendState(stockD3D11.blendStateDisabledWithColorMask[0xF], nullptr, 0xFFFFFFFF);
|
||||
context_->OMSetDepthStencilState(stockD3D11.depthStencilDisabled, 0);
|
||||
|
||||
@@ -141,13 +141,6 @@ private:
|
||||
|
||||
bool resized_;
|
||||
|
||||
struct TempFBO {
|
||||
Draw::Framebuffer *fbo;
|
||||
int last_frame_used;
|
||||
};
|
||||
|
||||
std::map<u64, TempFBO> tempFBOs_;
|
||||
|
||||
#if 0
|
||||
AsyncPBO *pixelBufObj_; //this isn't that large
|
||||
u8 currentPBO_;
|
||||
|
||||
@@ -107,6 +107,9 @@ ShaderManagerD3D11::ShaderManagerD3D11(ID3D11Device *device, ID3D11DeviceContext
|
||||
}
|
||||
|
||||
ShaderManagerD3D11::~ShaderManagerD3D11() {
|
||||
push_base->Release();
|
||||
push_lights->Release();
|
||||
push_bones->Release();
|
||||
ClearShaders();
|
||||
delete[] codeBuffer_;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,10 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||
inputLayout, depth, blendstateOff, rasterNoCull, &vsTexColBufDesc
|
||||
};
|
||||
texColor = draw_->CreateGraphicsPipeline(pipelineDesc);
|
||||
inputLayout->Release();
|
||||
depth->Release();
|
||||
blendstateOff->Release();
|
||||
rasterNoCull->Release();
|
||||
|
||||
fb.data = Memory::GetPointer(0x44000000); // TODO: correct default address?
|
||||
depthbuf.data = Memory::GetPointer(0x44000000); // TODO: correct default address?
|
||||
|
||||
@@ -607,6 +607,8 @@ void NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
colorPipeline = g_draw->CreateGraphicsPipeline(colorDesc);
|
||||
texColorPipeline = g_draw->CreateGraphicsPipeline(texColorDesc);
|
||||
|
||||
// Release these now, reference counting should ensure that they get completely released
|
||||
// once we delete both pipelines.
|
||||
inputLayout->Release();
|
||||
rasterNoCull->Release();
|
||||
blendNormal->Release();
|
||||
|
||||
+3
-1
@@ -17,10 +17,12 @@ public:
|
||||
register_gl_resource_holder(this);
|
||||
}
|
||||
~ManagedTexture() {
|
||||
if (texture_)
|
||||
texture_->Release();
|
||||
unregister_gl_resource_holder(this);
|
||||
}
|
||||
void GLLost() override {
|
||||
delete texture_;
|
||||
texture_->Release();
|
||||
texture_ = nullptr;
|
||||
}
|
||||
void GLRestore() override {
|
||||
|
||||
@@ -14,6 +14,7 @@ UIContext::UIContext()
|
||||
}
|
||||
|
||||
UIContext::~UIContext() {
|
||||
sampler_->Release();
|
||||
delete fontStyle_;
|
||||
delete textDrawer_;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user