diff --git a/gfx/shader_common.h b/gfx/shader_common.h index 5c99aa4c1a..200e58f765 100644 --- a/gfx/shader_common.h +++ b/gfx/shader_common.h @@ -17,7 +17,9 @@ #define SHADER_COMMON_H__ #include "../boolean.h" +#ifdef HAVE_OPENGL #include "gl_common.h" +#endif #include "gfx_context.h" #include "shader_parse.h" #include "math/matrix.h" diff --git a/gfx/shader_hlsl.c b/gfx/shader_hlsl.c index 23f7b7563b..b26b927cda 100644 --- a/gfx/shader_hlsl.c +++ b/gfx/shader_hlsl.c @@ -103,7 +103,10 @@ void hlsl_set_proj_matrix(XMMATRIX rotation_value) static void hlsl_set_params(unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, - unsigned frame_count) + unsigned frame_counter, + const struct gl_tex_info *info, + const struct gl_tex_info *prev_info, + const struct gl_tex_info *fbo_info, unsigned fbo_info_cnt) { if (!hlsl_active) return; @@ -111,7 +114,7 @@ static void hlsl_set_params(unsigned width, unsigned height, const float ori_size[2] = { (float)width, (float)height }; const float tex_size[2] = { (float)tex_width, (float)tex_height }; const float out_size[2] = { (float)out_width, (float)out_height }; - float frame_cnt = frame_count; + float frame_cnt = frame_counter; prg[active_index].f_ctable->SetDefaults(d3d_device_ptr); prg[active_index].v_ctable->SetDefaults(d3d_device_ptr); @@ -330,12 +333,9 @@ static bool load_preset(const char *path) return true; } -static bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr) +static bool hlsl_init(const char *path) { - if (!device_ptr) - return false; - - d3d_device_ptr = device_ptr; + xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; if (path && strcmp(path_get_extension(path), ".cgp") == 0) { @@ -351,8 +351,9 @@ static bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr) for(unsigned i = 1; i <= cg_shader->passes; i++) set_program_attributes(i); - d3d_device_ptr->SetVertexShader(prg[1].vprg); - d3d_device_ptr->SetPixelShader(prg[1].fprg); + d3d_device_ptr = d3d->d3d_render_device; + d3d->d3d_render_device->SetVertexShader(prg[1].vprg); + d3d->d3d_render_device->SetPixelShader(prg[1].fprg); hlsl_active = true; return true; diff --git a/gfx/shader_hlsl.h b/gfx/shader_hlsl.h index b74a9bc81c..330f73613b 100644 --- a/gfx/shader_hlsl.h +++ b/gfx/shader_hlsl.h @@ -18,7 +18,7 @@ #ifndef __RARCH_HLSL_H #define __RARCH_HLSL_H -#include "../boolean.h" +#include "shader_common.h" #include void hlsl_set_proj_matrix(XMMATRIX rotation_value); diff --git a/xdk/xdk_d3d.cpp b/xdk/xdk_d3d.cpp index 11546bae68..62ec82e955 100644 --- a/xdk/xdk_d3d.cpp +++ b/xdk/xdk_d3d.cpp @@ -171,11 +171,12 @@ static void xdk_d3d_free(void *data) if (!d3d) return; -#ifdef HAVE_HLSL - hlsl_deinit(); -#endif d3d->font_ctx->deinit(d3d); + if (d3d->shader) + d3d->shader->deinit(); + d3d->shader = NULL; + d3d->ctx_driver->destroy(); free(d3d); @@ -255,6 +256,9 @@ static void xdk_d3d_set_viewport(bool force_full) vp.MaxZ = m_zFar; d3dr->SetViewport(&vp); + if (d3d->shader) + d3d->shader->set_mvp(NULL); + #ifdef _XBOX1 font_x = vp.X; font_y = vp.Y; @@ -672,7 +676,7 @@ static void *xdk_d3d_init(const video_info_t *video, const input_driver_t **inpu return NULL; } - RARCH_LOG("D3D: Loaded %u program(s).\n", d3d->shader->num_func()); + RARCH_LOG("D3D: Loaded %u program(s).\n", d3d->shader->num_shaders()); #endif #if 0 /* ifdef HAVE_FBO */ @@ -888,9 +892,12 @@ static bool xdk_d3d_frame(void *data, const void *frame, #endif { #ifdef HAVE_HLSL + if (d3d->shader) d3d->shader->set_params(width, height, d3d->tex_w, d3d->tex_h, d3d->win_width, - d3d->win_height, g_extern.frame_count); + d3d->win_height, g_extern.frame_count, + /* TODO - missing a bunch of params at the end */ +NULL, NULL, NULL, 0); #endif } diff --git a/xdk/xdk_d3d.h b/xdk/xdk_d3d.h index ddc8326416..024c90075a 100644 --- a/xdk/xdk_d3d.h +++ b/xdk/xdk_d3d.h @@ -41,9 +41,12 @@ typedef struct DrawVerticeFormats float u, v; } DrawVerticeFormats; +typedef struct gl_shader_backend gl_shader_backend_t; + typedef struct xdk_d3d_video { const gfx_ctx_driver_t *ctx_driver; + const gl_shader_backend_t *shader; #ifdef HAVE_FBO bool fbo_inited; #endif