diff --git a/gfx/d3d9/d3d_shared.h b/gfx/d3d9/d3d_shared.h index a6bcaf4c49..469a1266f1 100644 --- a/gfx/d3d9/d3d_shared.h +++ b/gfx/d3d9/d3d_shared.h @@ -15,8 +15,7 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info); static void renderchain_free(void *data); -void d3d_deinit_shader(void *data); -bool d3d_init_shader(void *data); + void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp); @@ -30,6 +29,44 @@ extern LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, static RECT d3d_monitor_rect(d3d_video_t *d3d); #endif +static void d3d_deinit_shader(void *data) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + (void)d3d; + (void)data; + +#ifdef HAVE_CG + if (!d3d->cgCtx) + return; + + cgD3D9UnloadAllPrograms(); + cgD3D9SetDevice(NULL); + cgDestroyContext(d3d->cgCtx); + d3d->cgCtx = NULL; +#endif +} + +static bool d3d_init_shader(void *data) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + (void)d3d; + (void)data; +#if defined(_XBOX) + return false; +#elif defined(HAVE_CG) + d3d->cgCtx = cgCreateContext(); + if (!d3d->cgCtx) + return false; + + RARCH_LOG("[D3D]: Created shader context.\n"); + + HRESULT ret = cgD3D9SetDevice(d3d->dev); + if (FAILED(ret)) + return false; + return true; +#endif +} + static void d3d_deinit_chain(d3d_video_t *d3d) { #ifdef _XBOX diff --git a/gfx/d3d9/render_chain_cg.h b/gfx/d3d9/render_chain_cg.h index 121cd0f4b2..9daf559f2d 100644 --- a/gfx/d3d9/render_chain_cg.h +++ b/gfx/d3d9/render_chain_cg.h @@ -569,33 +569,4 @@ void renderchain_bind_pass(void *data, Pass &pass, unsigned pass_index) } } } - -bool d3d_init_shader(void *data) -{ - d3d_video_t *d3d = (d3d_video_t*)data; - d3d->cgCtx = cgCreateContext(); - if (!d3d->cgCtx) - return false; - - RARCH_LOG("[D3D]: Created shader context.\n"); - - HRESULT ret = cgD3D9SetDevice(d3d->dev); - if (FAILED(ret)) - return false; - - return true; -} - -void d3d_deinit_shader(void *data) -{ - d3d_video_t *d3d = (d3d_video_t*)data; - if (!d3d->cgCtx) - return; - - cgD3D9UnloadAllPrograms(); - cgD3D9SetDevice(NULL); - cgDestroyContext(d3d->cgCtx); - d3d->cgCtx = NULL; -} - #endif diff --git a/gfx/d3d9/xdk_d3d.cpp b/gfx/d3d9/xdk_d3d.cpp index 4cc7ae5428..74c0445b77 100644 --- a/gfx/d3d9/xdk_d3d.cpp +++ b/gfx/d3d9/xdk_d3d.cpp @@ -34,17 +34,6 @@ #include "render_chain_xdk.h" -static void d3d_deinit_shader(void *data) -{ - (void)data; -} - -static bool d3d_init_shader(void *data) -{ - (void)data; - return false; -} - static void d3d_free(void *data) { d3d_video_t *d3d = (d3d_video_t*)data;