diff --git a/gfx/common/d3d_common.cpp b/gfx/common/d3d_common.cpp index c34650b9d8..dd598862c0 100644 --- a/gfx/common/d3d_common.cpp +++ b/gfx/common/d3d_common.cpp @@ -113,6 +113,20 @@ void d3d_texture_free(LPDIRECT3DTEXTURE tex) } } +void d3d_surface_free(void *data) +{ + LPDIRECT3DSURFACE surf = (LPDIRECT3DSURFACE)data; + if (!surf) + return; +#if defined(HAVE_D3D9) && !defined(__cplusplus) + IDirect3DSurface9_Release(surf); +#elif defined(HAVE_D3D8) && !defined(__cplusplus) + IDirect3DSurface8_Release(surf); +#else + surf->Release(); +#endif +} + void d3d_vertex_declaration_free(void *data) { LPDIRECT3DVERTEXDECLARATION vertex_decl = (LPDIRECT3DVERTEXDECLARATION)data; @@ -125,7 +139,6 @@ void d3d_vertex_declaration_free(void *data) #endif } - bool d3d_vertex_declaration_new(LPDIRECT3DDEVICE dev, const void *vertex_data, void **decl_data) { diff --git a/gfx/common/d3d_common.h b/gfx/common/d3d_common.h index b82378b343..4622874122 100644 --- a/gfx/common/d3d_common.h +++ b/gfx/common/d3d_common.h @@ -108,6 +108,8 @@ void d3d_enable_alpha_blend_texture_func(void *data); void d3d_frame_postprocess(void *data); +void d3d_surface_free(void *data); + void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value); bool d3d_reset(LPDIRECT3DDEVICE dev, D3DPRESENT_PARAMETERS *d3dpp); diff --git a/gfx/drivers_renderchain/d3d9_cg_renderchain.cpp b/gfx/drivers_renderchain/d3d9_cg_renderchain.cpp index 3e4960d6f3..047844fdbb 100644 --- a/gfx/drivers_renderchain/d3d9_cg_renderchain.cpp +++ b/gfx/drivers_renderchain/d3d9_cg_renderchain.cpp @@ -1455,7 +1455,7 @@ static bool d3d9_cg_renderchain_render( current_width = out_width; current_height = out_height; - target->Release(); + d3d_surface_free(target); } /* Final pass */ @@ -1482,7 +1482,7 @@ static bool d3d9_cg_renderchain_render( chain->frame_count++; - back_buffer->Release(); + d3d_surface_free(back_buffer); if (chain) { @@ -1597,9 +1597,9 @@ static bool d3d9_cg_renderchain_read_viewport( end: if (target) - target->Release(); + d3d_surface_free(target); if (dest) - dest->Release(); + d3d_surface_free(dest); return ret; }