diff --git a/360/xdk360_video.cpp b/360/xdk360_video.cpp index 922d96700f..1c892fa3a3 100644 --- a/360/xdk360_video.cpp +++ b/360/xdk360_video.cpp @@ -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); } diff --git a/gfx/shader_hlsl.c b/gfx/shader_hlsl.c index d99bd8cbed..e5ad5ab0cd 100644 --- a/gfx/shader_hlsl.c +++ b/gfx/shader_hlsl.c @@ -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")) { diff --git a/gfx/shader_hlsl.h b/gfx/shader_hlsl.h index 163b53c7d4..7b083b7202 100644 --- a/gfx/shader_hlsl.h +++ b/gfx/shader_hlsl.h @@ -18,6 +18,7 @@ #ifndef __SSNES_HLSL_H #define __SSNES_HLSL_H +#include "../boolean.h" #include bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr);