Create d3d_surface_free

This commit is contained in:
twinaphex 2017-10-01 22:28:48 +02:00
parent ff40cba3de
commit 563024502f
3 changed files with 20 additions and 5 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -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;
}