(360) Attempt to fix memory leaks - still broken

This commit is contained in:
TwinAphex51224 2012-04-15 18:13:24 +02:00
parent 48b8c78de2
commit 1cdaa652a9
3 changed files with 18 additions and 12 deletions

View File

@ -189,14 +189,15 @@ static void xdk360_gfx_free(void * data)
if (!vid)
return;
hlsl_deinit();
D3DResource_Release((D3DResource *)vid->lpTexture);
D3DResource_Release((D3DResource *)vid->vertex_buf);
D3DResource_Release((D3DResource *)vid->v_decl);
D3DDevice_Release(vid->xdk360_render_device);
Direct3D_Release();
//breaks right now
//hlsl_deinit();
free(vid);
}

View File

@ -106,6 +106,11 @@ static bool load_program(unsigned index, const char *prog, bool path_is_file)
ret_fp = false;
ret_vp = false;
if(prg[index].f_ctable)
D3DResource_Release((D3DResource *)prg[index].f_ctable);
if(prg[index].v_ctable)
D3DResource_Release((D3DResource *)prg[0].v_ctable);
if (path_is_file)
{
ret_fp = D3DXCompileShaderFromFile(prog, NULL, NULL, "main_fragment", "ps_2_0", 0, &code_f, &listing_f, &prg[index].f_ctable);
@ -130,6 +135,11 @@ static bool load_program(unsigned index, const char *prog, bool path_is_file)
goto end;
}
if(prg[index].fprg)
D3DResource_Release((D3DResource *)prg[0].fprg);
if(prg[index].vprg)
D3DResource_Release((D3DResource *)prg[0].vprg);
prg[index].fprg = D3DDevice_CreatePixelShader((const DWORD*)code_f->GetBufferPointer());
prg[index].vprg = D3DDevice_CreateVertexShader((const DWORD*)code_v->GetBufferPointer());
code_f->Release();
@ -171,12 +181,6 @@ static bool load_plain(const char *path)
static void hlsl_deinit_progs(void)
{
if (prg[0].fprg)
D3DResource_Release((D3DResource *)prg[0].fprg);
if (prg[0].vprg)
D3DResource_Release((D3DResource *)prg[0].vprg);
D3DResource_Release((D3DResource *)prg[0].f_ctable);
D3DResource_Release((D3DResource *)prg[0].v_ctable);
}
static void hlsl_deinit_state(void)
@ -210,10 +214,10 @@ static void set_program_attributes(unsigned i)
bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr)
{
if (device_ptr != NULL)
d3d_device_ptr = device_ptr;
else
return false;
if(!device_ptr)
return false;
d3d_device_ptr = device_ptr;
if (strstr(path, ".cgp"))
{

View File

@ -18,6 +18,7 @@
#ifndef __SSNES_HLSL_H
#define __SSNES_HLSL_H
#include "../boolean.h"
#include <stdint.h>
bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr);