DXGL r527 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r526‎ | r527 | r528 >
Date:22:59, 7 September 2014
Author:admin
Status:new
Tags:
Comment:
Fix major resource leak in execute buffers.
Use glTexSubImage2D or glTextureSubImage2DEXT for texture upload.
Modified paths:
  • /ddraw/TextureManager.c (modified) (history)
  • /ddraw/glDirect3DExecuteBuffer.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/TextureManager.c
@@ -505,13 +505,18 @@
506506 do
507507 {
508508 ClearError();
509 - if (This->ext->GLEXT_EXT_direct_state_access) This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
510 - width, height, 0, texture->format, texture->type, data);
 509+ if (This->ext->GLEXT_EXT_direct_state_access)
 510+ {
 511+ This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
 512+ //This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
 513+ // width, height, 0, texture->format, texture->type, data);
 514+ }
511515 else
512516 {
513517 TextureManager_SetActiveTexture(This, 0);
514518 TextureManager_SetTexture(This, 0, texture);
515 - glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
 519+ glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
 520+ //glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
516521 }
517522 error = glGetError();
518523 if (error != GL_NO_ERROR)
@@ -529,13 +534,18 @@
530535 }
531536 else
532537 {
533 - if (This->ext->GLEXT_EXT_direct_state_access) This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
534 - width, height, 0, texture->format, texture->type, data);
 538+ if (This->ext->GLEXT_EXT_direct_state_access)
 539+ {
 540+ This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
 541+ //This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
 542+ //width, height, 0, texture->format, texture->type, data);
 543+ }
535544 else
536545 {
537546 TextureManager_SetActiveTexture(This, 0);
538547 TextureManager_SetTexture(This, 0, texture);
539 - glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
 548+ glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
 549+ //glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
540550 }
541551 }
542552 }
Index: ddraw/glDirect3DExecuteBuffer.cpp
@@ -21,6 +21,7 @@
2222 glDirect3DExecuteBuffer::glDirect3DExecuteBuffer(LPD3DEXECUTEBUFFERDESC lpDesc)
2323 {
2424 TRACE_ENTER(2,14,this,14,lpDesc);
 25+ refcount = 1;
2526 locked = false;
2627 inuse = false;
2728 data = NULL;
Index: ddraw/glDirectDrawSurface.cpp
@@ -510,7 +510,7 @@
511511 tmpd3d->CreateDevice(riid,this,(LPDIRECT3DDEVICE7*)&tmpdev);
512512 if(!tmpdev)
513513 {
514 - tmpdev->Release();
 514+ tmpd3d->Release();
515515 TRACE_EXIT(23,E_NOINTERFACE);
516516 return E_NOINTERFACE;
517517 }