mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 10:20:57 +00:00
(Cg/HLSL) Since everything goes through the shader backend interface now,
we can drop public scope on all the functions and make them static instead
This commit is contained in:
parent
e2039f8bff
commit
a6db35875d
@ -147,7 +147,7 @@ static void gl_cg_reset_attrib(void)
|
||||
cg_attrib_index = 0;
|
||||
}
|
||||
|
||||
bool gl_cg_set_mvp(const math_matrix *mat)
|
||||
static bool gl_cg_set_mvp(const math_matrix *mat)
|
||||
{
|
||||
if (cg_active && prg[active_index].mvp)
|
||||
{
|
||||
@ -167,7 +167,7 @@ bool gl_cg_set_mvp(const math_matrix *mat)
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
bool gl_cg_set_coords(const struct gl_coords *coords)
|
||||
static bool gl_cg_set_coords(const struct gl_coords *coords)
|
||||
{
|
||||
if (!cg_active)
|
||||
return false;
|
||||
@ -185,7 +185,7 @@ bool gl_cg_set_coords(const struct gl_coords *coords)
|
||||
#define set_param_1f(param, x) \
|
||||
if (param) cgGLSetParameter1f(param, x)
|
||||
|
||||
void gl_cg_set_params(unsigned width, unsigned height,
|
||||
static void gl_cg_set_params(unsigned width, unsigned height,
|
||||
unsigned tex_width, unsigned tex_height,
|
||||
unsigned out_width, unsigned out_height,
|
||||
unsigned frame_count,
|
||||
@ -378,7 +378,7 @@ static void gl_cg_deinit_context_state(void)
|
||||
}
|
||||
|
||||
// Full deinit.
|
||||
void gl_cg_deinit(void)
|
||||
static void gl_cg_deinit(void)
|
||||
{
|
||||
if (!cg_active)
|
||||
return;
|
||||
@ -387,6 +387,8 @@ void gl_cg_deinit(void)
|
||||
gl_cg_deinit_context_state();
|
||||
}
|
||||
|
||||
static bool gl_cg_init(const char *path);
|
||||
|
||||
// Deinit as much as possible without resetting context (broken on PS3),
|
||||
// and reinit cleanly.
|
||||
// If this fails, we're kinda screwed without resetting everything on PS3.
|
||||
@ -774,7 +776,7 @@ static void set_program_attributes(unsigned i)
|
||||
}
|
||||
}
|
||||
|
||||
bool gl_cg_init(const char *path)
|
||||
static bool gl_cg_init(const char *path)
|
||||
{
|
||||
#ifdef HAVE_CG_RUNTIME_COMPILER
|
||||
cgRTCgcInit();
|
||||
@ -838,7 +840,7 @@ bool gl_cg_init(const char *path)
|
||||
return true;
|
||||
}
|
||||
|
||||
void gl_cg_use(unsigned index)
|
||||
static void gl_cg_use(unsigned index)
|
||||
{
|
||||
if (cg_active && prg[index].vprg && prg[index].fprg)
|
||||
{
|
||||
@ -850,7 +852,7 @@ void gl_cg_use(unsigned index)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned gl_cg_num(void)
|
||||
static unsigned gl_cg_num(void)
|
||||
{
|
||||
if (cg_active)
|
||||
return cg_shader->passes;
|
||||
@ -858,7 +860,7 @@ unsigned gl_cg_num(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool gl_cg_filter_type(unsigned index, bool *smooth)
|
||||
static bool gl_cg_filter_type(unsigned index, bool *smooth)
|
||||
{
|
||||
if (cg_active && index)
|
||||
{
|
||||
@ -871,7 +873,7 @@ bool gl_cg_filter_type(unsigned index, bool *smooth)
|
||||
return false;
|
||||
}
|
||||
|
||||
void gl_cg_shader_scale(unsigned index, struct gfx_fbo_scale *scale)
|
||||
static void gl_cg_shader_scale(unsigned index, struct gfx_fbo_scale *scale)
|
||||
{
|
||||
if (cg_active && index)
|
||||
*scale = cg_shader->pass[index - 1].fbo;
|
||||
|
@ -20,37 +20,13 @@
|
||||
#include "shader_common.h"
|
||||
#include <stdint.h>
|
||||
|
||||
bool gl_cg_init(const char *path);
|
||||
bool gl_cg_reinit(const char *path);
|
||||
void gl_cg_deinit(void);
|
||||
|
||||
void gl_cg_set_params(unsigned width, unsigned height,
|
||||
unsigned tex_width, unsigned tex_height,
|
||||
unsigned out_width, unsigned out_height,
|
||||
unsigned frame_count,
|
||||
const struct gl_tex_info *info,
|
||||
const struct gl_tex_info *prev_info,
|
||||
const struct gl_tex_info *fbo_info,
|
||||
unsigned fbo_info_cnt);
|
||||
|
||||
void gl_cg_use(unsigned index);
|
||||
|
||||
unsigned gl_cg_num(void);
|
||||
|
||||
bool gl_cg_filter_type(unsigned index, bool *smooth);
|
||||
void gl_cg_shader_scale(unsigned index, struct gfx_fbo_scale *scale);
|
||||
|
||||
bool gl_cg_set_mvp(const math_matrix *mat);
|
||||
bool gl_cg_set_coords(const struct gl_coords *coords);
|
||||
|
||||
|
||||
// Used on PS3, but not really platform specific.
|
||||
|
||||
#define RARCH_CG_MAX_SHADERS 16
|
||||
void gl_cg_set_compiler_args(const char **argv);
|
||||
|
||||
bool gl_cg_load_shader(unsigned index, const char *path);
|
||||
|
||||
void gl_cg_invalidate_context(void); // Call when resetting GL context on PS3.
|
||||
extern const gl_shader_backend_t gl_cg_backend;
|
||||
|
||||
|
@ -100,7 +100,7 @@ void hlsl_set_proj_matrix(XMMATRIX rotation_value)
|
||||
#define set_param_1f(param, x, constanttable) \
|
||||
if (param) constanttable->SetFloat(d3d_device_ptr, param, x)
|
||||
|
||||
void hlsl_set_params(unsigned width, unsigned height,
|
||||
static void hlsl_set_params(unsigned width, unsigned height,
|
||||
unsigned tex_width, unsigned tex_height,
|
||||
unsigned out_width, unsigned out_height,
|
||||
unsigned frame_count)
|
||||
@ -128,9 +128,6 @@ void hlsl_set_params(unsigned width, unsigned height,
|
||||
set_param_1f(prg[active_index].frame_cnt_v, frame_cnt, prg[active_index].v_ctable);
|
||||
set_param_1f(prg[active_index].frame_dir_v, g_extern.frame_is_reverse ? -1.0 : 1.0,prg[active_index].v_ctable);
|
||||
|
||||
/* TODO: Move to D3DXMATRIX here */
|
||||
if(prg[active_index].mvp)
|
||||
prg[active_index].v_ctable->SetMatrix(d3d_device_ptr, prg[active_index].mvp, (D3DXMATRIX*)&prg[active_index].mvp_val);
|
||||
|
||||
/* TODO - set lookup textures/FBO textures/state parameters/etc */
|
||||
}
|
||||
@ -333,7 +330,7 @@ static bool load_preset(const char *path)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr)
|
||||
static bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr)
|
||||
{
|
||||
if (!device_ptr)
|
||||
return false;
|
||||
@ -362,7 +359,7 @@ bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr)
|
||||
}
|
||||
|
||||
// Full deinit.
|
||||
void hlsl_deinit(void)
|
||||
static void hlsl_deinit(void)
|
||||
{
|
||||
if (!hlsl_active)
|
||||
return;
|
||||
@ -370,7 +367,7 @@ void hlsl_deinit(void)
|
||||
hlsl_deinit_state();
|
||||
}
|
||||
|
||||
void hlsl_use(unsigned index)
|
||||
static void hlsl_use(unsigned index)
|
||||
{
|
||||
if (hlsl_active && prg[index].vprg && prg[index].fprg)
|
||||
{
|
||||
@ -380,7 +377,7 @@ void hlsl_use(unsigned index)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned d3d_hlsl_num(void)
|
||||
static unsigned hlsl_num(void)
|
||||
{
|
||||
if (hlsl_active)
|
||||
return cg_shader->passes;
|
||||
@ -388,7 +385,7 @@ unsigned d3d_hlsl_num(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool hlsl_filter_type(unsigned index, bool *smooth)
|
||||
static bool hlsl_filter_type(unsigned index, bool *smooth)
|
||||
{
|
||||
if (hlsl_active && index)
|
||||
{
|
||||
@ -401,10 +398,36 @@ bool hlsl_filter_type(unsigned index, bool *smooth)
|
||||
return false;
|
||||
}
|
||||
|
||||
void hlsl_shader_scale(unsigned index, struct gfx_fbo_scale *scale)
|
||||
static void hlsl_shader_scale(unsigned index, struct gfx_fbo_scale *scale)
|
||||
{
|
||||
if (hlsl_active && index)
|
||||
*scale = cg_shader->pass[index - 1].fbo;
|
||||
else
|
||||
scale->valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool hlsl_set_mvp(const math_matrix *mat)
|
||||
{
|
||||
/* TODO: Move to D3DXMATRIX here */
|
||||
if(hlsl_active && prg[active_index].mvp)
|
||||
{
|
||||
prg[active_index].v_ctable->SetMatrix(d3d_device_ptr, prg[active_index].mvp, (D3DXMATRIX*)&prg[active_index].mvp_val);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
const gl_shader_backend_t hlsl_backend = {
|
||||
hlsl_init,
|
||||
hlsl_deinit,
|
||||
hlsl_set_params,
|
||||
hlsl_use,
|
||||
hlsl_num,
|
||||
hlsl_filter_type,
|
||||
hlsl_shader_scale,
|
||||
NULL, /* hlsl_set_coords */
|
||||
hlsl_set_mvp,
|
||||
|
||||
RARCH_SHADER_HLSL,
|
||||
};
|
||||
|
@ -21,22 +21,10 @@
|
||||
#include "../boolean.h"
|
||||
#include <stdint.h>
|
||||
|
||||
bool hlsl_init(const char *path, IDirect3DDevice9 *device_ptr);
|
||||
|
||||
void hlsl_deinit(void);
|
||||
|
||||
void hlsl_set_proj_matrix(XMMATRIX rotation_value);
|
||||
|
||||
void hlsl_set_params(unsigned width, unsigned height,
|
||||
unsigned tex_width, unsigned tex_height,
|
||||
unsigned out_width, unsigned out_height,
|
||||
unsigned frame_count);
|
||||
|
||||
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
|
||||
|
||||
extern const gl_shader_backend_t hlsl_backend;
|
||||
|
||||
#endif
|
||||
|
@ -132,9 +132,30 @@ static void check_window(void *data)
|
||||
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.shader_path;
|
||||
const gl_shader_backend_t *backend = NULL;
|
||||
|
||||
return hlsl_init(shader_path, d3d->d3d_render_device);
|
||||
const char *shader_path = g_settings.video.shader_path;
|
||||
enum rarch_shader_type type = gfx_shader_parse_type(shader_path, DEFAULT_SHADER_TYPE);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
#ifdef HAVE_HLSL
|
||||
case RARCH_SHADER_HLSL:
|
||||
RARCH_LOG("[D3D]: Using HLSL shader backend.\n");
|
||||
backend = &hlsl_backend;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!backend)
|
||||
{
|
||||
RARCH_ERR("[GL]: Didn't find valid shader backend. Continuing without shaders.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
d3d->shader = backend;
|
||||
return d3d->shader->init(shader_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -651,7 +672,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_hlsl_num());
|
||||
RARCH_LOG("D3D: Loaded %u program(s).\n", d3d->shader->num_func());
|
||||
#endif
|
||||
|
||||
#if 0 /* ifdef HAVE_FBO */
|
||||
@ -842,15 +863,17 @@ static bool xdk_d3d_frame(void *data, const void *frame,
|
||||
d3dr->SetTexture(0, d3d->lpTexture);
|
||||
|
||||
#ifdef HAVE_HLSL
|
||||
hlsl_use(1);
|
||||
if (d3d->shader)
|
||||
d3d->shader->use(1);
|
||||
#endif
|
||||
|
||||
#if 0 /* ifdef HAVE_FBO */
|
||||
if (d3d->fbo_inited)
|
||||
{
|
||||
#ifdef HAVE_HLSL
|
||||
hlsl_set_params(width, height, d3d->tex_w, d3d->tex_h, g_settings.video.fbo.scale_x * width,
|
||||
g_settings.video.fbo.scale_y * height, g_extern.frame_count);
|
||||
if (d3d->shader)
|
||||
d3d->shader->set_params(width, height, d3d->tex_w, d3d->tex_h, g_settings.video.fbo.scale_x * width,
|
||||
g_settings.video.fbo.scale_y * height, g_extern.frame_count);
|
||||
#endif
|
||||
D3DVIEWPORT vp = {0};
|
||||
vp.Width = g_settings.video.fbo.scale_x * width;
|
||||
@ -865,8 +888,9 @@ static bool xdk_d3d_frame(void *data, const void *frame,
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_HLSL
|
||||
hlsl_set_params(width, height, d3d->tex_w, d3d->tex_h, d3d->win_width,
|
||||
d3d->win_height, g_extern.frame_count);
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -916,8 +940,10 @@ static bool xdk_d3d_frame(void *data, const void *frame,
|
||||
|
||||
#ifdef HAVE_HLSL
|
||||
hlsl_use(2);
|
||||
hlsl_set_params(g_settings.video.fbo.scale_x * width, g_settings.video.fbo.scale_y * height, g_settings.video.fbo.scale_x * d3d->tex_w, g_settings.video.fbo.scale_y * d3d->tex_h, d3d->win_width,
|
||||
d3d->win_height, g_extern.frame_count);
|
||||
|
||||
if (d3d->shader)
|
||||
d3d->shader->set_params(g_settings.video.fbo.scale_x * width, g_settings.video.fbo.scale_y * height, g_settings.video.fbo.scale_x * d3d->tex_w, g_settings.video.fbo.scale_y * d3d->tex_h, d3d->win_width,
|
||||
d3d->win_height, g_extern.frame_count);
|
||||
#endif
|
||||
xdk_d3d_set_viewport(false);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user