Skip to content

Commit

Permalink
Fix major resource leak in execute buffers.
Browse files Browse the repository at this point in the history
Use glTexSubImage2D or glTextureSubImage2DEXT for texture upload.

git-svn-id: https://www.williamfeely.info/svn/dxgl@527 8a90861a-4eca-46d5-b744-240ff16d0c4d
  • Loading branch information
dxgldotorg committed Sep 7, 2014
1 parent 542b94e commit 2332273
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
22 changes: 16 additions & 6 deletions ddraw/TextureManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,18 @@ void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture,
do
{
ClearError();
if (This->ext->GLEXT_EXT_direct_state_access) This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
width, height, 0, texture->format, texture->type, data);
if (This->ext->GLEXT_EXT_direct_state_access)
{
This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
//This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
// width, height, 0, texture->format, texture->type, data);
}
else
{
TextureManager_SetActiveTexture(This, 0);
TextureManager_SetTexture(This, 0, texture);
glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
//glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
}
error = glGetError();
if (error != GL_NO_ERROR)
Expand All @@ -529,13 +534,18 @@ void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture,
}
else
{
if (This->ext->GLEXT_EXT_direct_state_access) This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
width, height, 0, texture->format, texture->type, data);
if (This->ext->GLEXT_EXT_direct_state_access)
{
This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
//This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
//width, height, 0, texture->format, texture->type, data);
}
else
{
TextureManager_SetActiveTexture(This, 0);
TextureManager_SetTexture(This, 0, texture);
glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
//glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions ddraw/glDirect3DExecuteBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
glDirect3DExecuteBuffer::glDirect3DExecuteBuffer(LPD3DEXECUTEBUFFERDESC lpDesc)
{
TRACE_ENTER(2,14,this,14,lpDesc);
refcount = 1;
locked = false;
inuse = false;
data = NULL;
Expand Down
2 changes: 1 addition & 1 deletion ddraw/glDirectDrawSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ HRESULT WINAPI glDirectDrawSurface7::QueryInterface(REFIID riid, void** ppvObj)
tmpd3d->CreateDevice(riid,this,(LPDIRECT3DDEVICE7*)&tmpdev);
if(!tmpdev)
{
tmpdev->Release();
tmpd3d->Release();
TRACE_EXIT(23,E_NOINTERFACE);
return E_NOINTERFACE;
}
Expand Down

0 comments on commit 2332273

Please sign in to comment.