mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 18:50:29 +00:00
Move Cg Context to render_chain.cpp
This commit is contained in:
parent
2ae20608e8
commit
1a7d3e3ea0
@ -110,15 +110,7 @@ static void d3d_deinit_shader(void *data)
|
||||
(void)d3d;
|
||||
(void)data;
|
||||
|
||||
#ifdef HAVE_CG
|
||||
if (!d3d->cgCtx)
|
||||
return;
|
||||
|
||||
cgD3D9UnloadAllPrograms();
|
||||
cgD3D9SetDevice(NULL);
|
||||
cgDestroyContext(d3d->cgCtx);
|
||||
d3d->cgCtx = NULL;
|
||||
#endif
|
||||
renderchain_deinit_shader();
|
||||
}
|
||||
|
||||
static bool d3d_init_shader(void *data)
|
||||
@ -144,16 +136,7 @@ static bool d3d_init_shader(void *data)
|
||||
|
||||
return d3d->shader->init(d3d, shader_path);
|
||||
#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;
|
||||
return renderchain_init_shader(d3d);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@ -767,9 +750,6 @@ static void *d3d_init(const video_info_t *info,
|
||||
vid->dev = NULL;
|
||||
vid->dev_rotation = 0;
|
||||
vid->needs_restore = false;
|
||||
#ifdef HAVE_CG
|
||||
vid->cgCtx = NULL;
|
||||
#endif
|
||||
#ifdef HAVE_OVERLAY
|
||||
vid->overlays_enabled = false;
|
||||
#endif
|
||||
@ -1016,11 +996,6 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info)
|
||||
return false;
|
||||
|
||||
if (!renderchain_init(d3d->chain, &d3d->video_info, d3dr,
|
||||
#ifdef HAVE_CG
|
||||
d3d->cgCtx,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
&d3d->final_viewport, &link_info,
|
||||
d3d->video_info.rgb32 ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565))
|
||||
{
|
||||
|
@ -140,9 +140,6 @@ typedef struct d3d_video
|
||||
|
||||
bool needs_restore;
|
||||
|
||||
#ifdef HAVE_CG
|
||||
CGcontext cgCtx;
|
||||
#endif
|
||||
RECT font_rect;
|
||||
RECT font_rect_shifted;
|
||||
|
||||
|
@ -28,9 +28,6 @@ struct lut_info
|
||||
typedef struct renderchain
|
||||
{
|
||||
LPDIRECT3DDEVICE dev;
|
||||
#ifdef HAVE_CG
|
||||
CGcontext cgCtx;
|
||||
#endif
|
||||
unsigned pixel_size;
|
||||
const video_info_t *video_info;
|
||||
state_tracker_t *tracker;
|
||||
@ -55,6 +52,8 @@ typedef struct renderchain
|
||||
std::vector<unsigned> bound_vert;
|
||||
} renderchain_t;
|
||||
|
||||
static CGcontext cgCtx;
|
||||
|
||||
static INLINE D3DTEXTUREFILTERTYPE translate_filter(unsigned type)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -183,33 +182,33 @@ bool renderchain_compile_shaders(void *data, void *fragment_data,
|
||||
if (shader.length() > 0)
|
||||
{
|
||||
RARCH_LOG("[D3D Cg]: Compiling shader: %s.\n", shader.c_str());
|
||||
*fPrg = cgCreateProgramFromFile(chain->cgCtx, CG_SOURCE,
|
||||
*fPrg = cgCreateProgramFromFile(cgCtx, CG_SOURCE,
|
||||
shader.c_str(), fragment_profile, "main_fragment", fragment_opts);
|
||||
|
||||
if (cgGetLastListing(chain->cgCtx))
|
||||
RARCH_ERR("[D3D Cg]: Fragment error:\n%s\n", cgGetLastListing(chain->cgCtx));
|
||||
if (cgGetLastListing(cgCtx))
|
||||
RARCH_ERR("[D3D Cg]: Fragment error:\n%s\n", cgGetLastListing(cgCtx));
|
||||
|
||||
*vPrg = cgCreateProgramFromFile(chain->cgCtx, CG_SOURCE,
|
||||
*vPrg = cgCreateProgramFromFile(cgCtx, CG_SOURCE,
|
||||
shader.c_str(), vertex_profile, "main_vertex", vertex_opts);
|
||||
|
||||
if (cgGetLastListing(chain->cgCtx))
|
||||
RARCH_ERR("[D3D Cg]: Vertex error:\n%s\n", cgGetLastListing(chain->cgCtx));
|
||||
if (cgGetLastListing(cgCtx))
|
||||
RARCH_ERR("[D3D Cg]: Vertex error:\n%s\n", cgGetLastListing(cgCtx));
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_LOG("[D3D Cg]: Compiling stock shader.\n");
|
||||
|
||||
*fPrg = cgCreateProgram(chain->cgCtx, CG_SOURCE, stock_program,
|
||||
*fPrg = cgCreateProgram(cgCtx, CG_SOURCE, stock_program,
|
||||
fragment_profile, "main_fragment", fragment_opts);
|
||||
|
||||
if (cgGetLastListing(chain->cgCtx))
|
||||
RARCH_ERR("[D3D Cg]: Fragment error:\n%s\n", cgGetLastListing(chain->cgCtx));
|
||||
if (cgGetLastListing(cgCtx))
|
||||
RARCH_ERR("[D3D Cg]: Fragment error:\n%s\n", cgGetLastListing(cgCtx));
|
||||
|
||||
*vPrg = cgCreateProgram(chain->cgCtx, CG_SOURCE, stock_program,
|
||||
*vPrg = cgCreateProgram(cgCtx, CG_SOURCE, stock_program,
|
||||
vertex_profile, "main_vertex", vertex_opts);
|
||||
|
||||
if (cgGetLastListing(chain->cgCtx))
|
||||
RARCH_ERR("[D3D Cg]: Vertex error:\n%s\n", cgGetLastListing(chain->cgCtx));
|
||||
if (cgGetLastListing(cgCtx))
|
||||
RARCH_ERR("[D3D Cg]: Vertex error:\n%s\n", cgGetLastListing(cgCtx));
|
||||
}
|
||||
|
||||
if (!fPrg || !vPrg)
|
||||
@ -719,6 +718,40 @@ void *renderchain_new(void)
|
||||
return renderchain;
|
||||
}
|
||||
|
||||
void renderchain_deinit_shader(void)
|
||||
{
|
||||
#ifdef HAVE_CG
|
||||
if (!cgCtx)
|
||||
return;
|
||||
|
||||
cgD3D9UnloadAllPrograms();
|
||||
cgD3D9SetDevice(NULL);
|
||||
cgDestroyContext(d3d->cgCtx);
|
||||
d3d->cgCtx = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool renderchain_init_shader(void *data)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
|
||||
if (!d3d)
|
||||
return false;
|
||||
|
||||
#ifdef HAVE_CG
|
||||
cgCtx = cgCreateContext();
|
||||
if (!cgCtx)
|
||||
return false;
|
||||
|
||||
RARCH_LOG("[D3D]: Created shader context.\n");
|
||||
|
||||
HRESULT ret = cgD3D9SetDevice(d3d->dev);
|
||||
if (FAILED(ret))
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void renderchain_deinit(void *data)
|
||||
{
|
||||
renderchain_t *renderchain = (renderchain_t*)data;
|
||||
@ -731,21 +764,16 @@ void renderchain_deinit(void *data)
|
||||
|
||||
bool renderchain_init(void *data, const video_info_t *video_info,
|
||||
void *dev_,
|
||||
void *shader_context,
|
||||
const void *final_viewport_,
|
||||
const void *info_data, unsigned fmt)
|
||||
{
|
||||
const LinkInfo *info = (const LinkInfo*)info_data;
|
||||
renderchain_t *chain = (renderchain_t*)data;
|
||||
CGcontext cgCtx_ = (CGcontext)shader_context;
|
||||
|
||||
if (!chain)
|
||||
return false;
|
||||
|
||||
chain->dev = (LPDIRECT3DDEVICE)dev_;
|
||||
#ifdef HAVE_CG
|
||||
chain->cgCtx = cgCtx_;
|
||||
#endif
|
||||
chain->video_info = video_info;
|
||||
chain->tracker = NULL;
|
||||
chain->final_viewport = (D3DVIEWPORT*)final_viewport_;
|
||||
|
@ -68,7 +68,6 @@ void renderchain_deinit(void *data);
|
||||
|
||||
bool renderchain_init(void *data, const video_info_t *video_info,
|
||||
void *dev_,
|
||||
void *shader_data,
|
||||
const void *final_viewport_,
|
||||
const void *info_data,
|
||||
unsigned fmt);
|
||||
|
Loading…
Reference in New Issue
Block a user