From c7f8535ecfa7c637e82f605e96413a0923b95117 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 1 Oct 2012 02:45:29 +0200 Subject: [PATCH] (360) Shows amount of shaders that were loaded at init --- 360/xdk_d3d9.cpp | 30 ++++++++++++++++++++++++++++-- gfx/shader_hlsl.c | 8 ++++++++ gfx/shader_hlsl.h | 1 + 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/360/xdk_d3d9.cpp b/360/xdk_d3d9.cpp index 597e20a647..c7e633d686 100644 --- a/360/xdk_d3d9.cpp +++ b/360/xdk_d3d9.cpp @@ -124,6 +124,24 @@ static void check_window(xdk_d3d_video_t *d3d) d3d->should_resize = true; } +#ifdef HAVE_HLSL +static bool hlsl_shader_init(void) +{ + xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; + const char *shader_path = g_settings.video.cg_shader_path; + + return hlsl_init(g_settings.video.cg_shader_path, d3d->d3d_render_device); +} + +static unsigned d3d_hlsl_shader_num(void) +{ + unsigned num = d3d_hlsl_num(); + if (num) + return num; + return 0; +} +#endif + static void xdk_d3d_free(void * data) { #ifdef RARCH_CONSOLE @@ -503,7 +521,15 @@ static void *xdk_d3d_init(const video_info_t *video, const input_driver_t **inpu gfx_ctx_xdk_set_swap_interval(d3d->vsync ? 1 : 0); #ifdef HAVE_HLSL - hlsl_init(g_settings.video.cg_shader_path, d3d->d3d_render_device); + if (!hlsl_shader_init()) + { + RARCH_ERR("Shader init failed.\n"); + d3d->driver->destroy(); + free(d3d); + return NULL; + } + + RARCH_LOG("D3D: Loaded %u program(s).\n", d3d_hlsl_shader_num()); #endif #ifdef HAVE_FBO @@ -516,7 +542,7 @@ static void *xdk_d3d_init(const video_info_t *video, const input_driver_t **inpu if(hr < 0) { - RARCH_ERR("Couldn't create debug console.\n"); + RARCH_ERR("Couldn't initialize HLSL shader fonts.\n"); } //really returns driver.video_data to driver.video_data - see comment above diff --git a/gfx/shader_hlsl.c b/gfx/shader_hlsl.c index 85f0ff662d..519653258b 100644 --- a/gfx/shader_hlsl.c +++ b/gfx/shader_hlsl.c @@ -91,6 +91,14 @@ void hlsl_set_proj_matrix(XMMATRIX rotation_value) prg[active_index].mvp_val = rotation_value; } +unsigned d3d_hlsl_num(void) +{ + if (hlsl_active) + return hlsl_shader_num; + else + return 0; +} + #define set_param_2f(param, xy, constanttable) \ if (param) constanttable->SetFloatArray(d3d_device_ptr, param, xy, 2) #define set_param_1f(param, x, constanttable) \ diff --git a/gfx/shader_hlsl.h b/gfx/shader_hlsl.h index 2079ce5cda..01f9210b1b 100644 --- a/gfx/shader_hlsl.h +++ b/gfx/shader_hlsl.h @@ -35,6 +35,7 @@ void hlsl_set_params(unsigned width, unsigned height, void hlsl_use(unsigned index); bool hlsl_load_shader(unsigned index, const char *path); +unsigned d3d_hlsl_num(void); #define RARCH_HLSL_MAX_SHADERS 16