mirror of
https://github.com/libretro/RetroArch
synced 2025-02-14 06:40:48 +00:00
(Shaders) Rename index variables
This commit is contained in:
parent
3e45884b67
commit
059ed8fb07
@ -144,7 +144,7 @@ struct cg_program
|
|||||||
static struct cg_program prg[GFX_MAX_SHADERS];
|
static struct cg_program prg[GFX_MAX_SHADERS];
|
||||||
static bool cg_active;
|
static bool cg_active;
|
||||||
static CGprofile cgVProf, cgFProf;
|
static CGprofile cgVProf, cgFProf;
|
||||||
static unsigned active_index;
|
static unsigned active_idx;
|
||||||
|
|
||||||
static struct gfx_shader *cg_shader;
|
static struct gfx_shader *cg_shader;
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ static state_tracker_t *state_tracker;
|
|||||||
static GLuint lut_textures[GFX_MAX_TEXTURES];
|
static GLuint lut_textures[GFX_MAX_TEXTURES];
|
||||||
|
|
||||||
static CGparameter cg_attribs[PREV_TEXTURES + 1 + 4 + GFX_MAX_SHADERS];
|
static CGparameter cg_attribs[PREV_TEXTURES + 1 + 4 + GFX_MAX_SHADERS];
|
||||||
static unsigned cg_attrib_index;
|
static unsigned cg_attrib_idx;
|
||||||
|
|
||||||
static char cg_alias_define[GFX_MAX_SHADERS][128];
|
static char cg_alias_define[GFX_MAX_SHADERS][128];
|
||||||
|
|
||||||
@ -160,19 +160,19 @@ static void gl_cg_reset_attrib(void)
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
/* Add sanity check that we did not overflow. */
|
/* Add sanity check that we did not overflow. */
|
||||||
rarch_assert(cg_attrib_index <= ARRAY_SIZE(cg_attribs));
|
rarch_assert(cg_attrib_idx <= ARRAY_SIZE(cg_attribs));
|
||||||
|
|
||||||
for (i = 0; i < cg_attrib_index; i++)
|
for (i = 0; i < cg_attrib_idx; i++)
|
||||||
cgGLDisableClientState(cg_attribs[i]);
|
cgGLDisableClientState(cg_attribs[i]);
|
||||||
cg_attrib_index = 0;
|
cg_attrib_idx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gl_cg_set_mvp(void *data, const math_matrix *mat)
|
static bool gl_cg_set_mvp(void *data, const math_matrix *mat)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
if (cg_active && prg[active_index].mvp)
|
if (cg_active && prg[active_idx].mvp)
|
||||||
{
|
{
|
||||||
cgGLSetMatrixParameterfc(prg[active_index].mvp, mat->data);
|
cgGLSetMatrixParameterfc(prg[active_idx].mvp, mat->data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,11 +183,11 @@ static bool gl_cg_set_mvp(void *data, const math_matrix *mat)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define SET_COORD(name, coords_name, len) do { \
|
#define SET_COORD(name, coords_name, len) do { \
|
||||||
if (prg[active_index].name) \
|
if (prg[active_idx].name) \
|
||||||
{ \
|
{ \
|
||||||
cgGLSetParameterPointer(prg[active_index].name, len, GL_FLOAT, 0, coords->coords_name); \
|
cgGLSetParameterPointer(prg[active_idx].name, len, GL_FLOAT, 0, coords->coords_name); \
|
||||||
cgGLEnableClientState(prg[active_index].name); \
|
cgGLEnableClientState(prg[active_idx].name); \
|
||||||
cg_attribs[cg_attrib_index++] = prg[active_index].name; \
|
cg_attribs[cg_attrib_idx++] = prg[active_idx].name; \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
@ -230,82 +230,82 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
(void)data;
|
(void)data;
|
||||||
if (!cg_active || (active_index == 0) ||
|
if (!cg_active || (active_idx == 0) ||
|
||||||
(active_index == GL_SHADER_STOCK_BLEND))
|
(active_idx == GL_SHADER_STOCK_BLEND))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Set frame. */
|
/* Set frame. */
|
||||||
set_param_2f(prg[active_index].vid_size_f, width, height);
|
set_param_2f(prg[active_idx].vid_size_f, width, height);
|
||||||
set_param_2f(prg[active_index].tex_size_f, tex_width, tex_height);
|
set_param_2f(prg[active_idx].tex_size_f, tex_width, tex_height);
|
||||||
set_param_2f(prg[active_index].out_size_f, out_width, out_height);
|
set_param_2f(prg[active_idx].out_size_f, out_width, out_height);
|
||||||
set_param_1f(prg[active_index].frame_dir_f,
|
set_param_1f(prg[active_idx].frame_dir_f,
|
||||||
g_extern.frame_is_reverse ? -1.0 : 1.0);
|
g_extern.frame_is_reverse ? -1.0 : 1.0);
|
||||||
|
|
||||||
set_param_2f(prg[active_index].vid_size_v, width, height);
|
set_param_2f(prg[active_idx].vid_size_v, width, height);
|
||||||
set_param_2f(prg[active_index].tex_size_v, tex_width, tex_height);
|
set_param_2f(prg[active_idx].tex_size_v, tex_width, tex_height);
|
||||||
set_param_2f(prg[active_index].out_size_v, out_width, out_height);
|
set_param_2f(prg[active_idx].out_size_v, out_width, out_height);
|
||||||
set_param_1f(prg[active_index].frame_dir_v,
|
set_param_1f(prg[active_idx].frame_dir_v,
|
||||||
g_extern.frame_is_reverse ? -1.0 : 1.0);
|
g_extern.frame_is_reverse ? -1.0 : 1.0);
|
||||||
|
|
||||||
if (prg[active_index].frame_cnt_f || prg[active_index].frame_cnt_v)
|
if (prg[active_idx].frame_cnt_f || prg[active_idx].frame_cnt_v)
|
||||||
{
|
{
|
||||||
unsigned modulo = cg_shader->pass[active_index - 1].frame_count_mod;
|
unsigned modulo = cg_shader->pass[active_idx - 1].frame_count_mod;
|
||||||
if (modulo)
|
if (modulo)
|
||||||
frame_count %= modulo;
|
frame_count %= modulo;
|
||||||
|
|
||||||
set_param_1f(prg[active_index].frame_cnt_f, (float)frame_count);
|
set_param_1f(prg[active_idx].frame_cnt_f, (float)frame_count);
|
||||||
set_param_1f(prg[active_index].frame_cnt_v, (float)frame_count);
|
set_param_1f(prg[active_idx].frame_cnt_v, (float)frame_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set orig texture. */
|
/* Set orig texture. */
|
||||||
CGparameter param = prg[active_index].orig.tex;
|
CGparameter param = prg[active_idx].orig.tex;
|
||||||
if (param)
|
if (param)
|
||||||
{
|
{
|
||||||
cgGLSetTextureParameter(param, info->tex);
|
cgGLSetTextureParameter(param, info->tex);
|
||||||
cgGLEnableTextureParameter(param);
|
cgGLEnableTextureParameter(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_param_2f(prg[active_index].orig.vid_size_v,
|
set_param_2f(prg[active_idx].orig.vid_size_v,
|
||||||
info->input_size[0], info->input_size[1]);
|
info->input_size[0], info->input_size[1]);
|
||||||
set_param_2f(prg[active_index].orig.vid_size_f,
|
set_param_2f(prg[active_idx].orig.vid_size_f,
|
||||||
info->input_size[0], info->input_size[1]);
|
info->input_size[0], info->input_size[1]);
|
||||||
set_param_2f(prg[active_index].orig.tex_size_v,
|
set_param_2f(prg[active_idx].orig.tex_size_v,
|
||||||
info->tex_size[0], info->tex_size[1]);
|
info->tex_size[0], info->tex_size[1]);
|
||||||
set_param_2f(prg[active_index].orig.tex_size_f,
|
set_param_2f(prg[active_idx].orig.tex_size_f,
|
||||||
info->tex_size[0], info->tex_size[1]);
|
info->tex_size[0], info->tex_size[1]);
|
||||||
if (prg[active_index].orig.coord)
|
if (prg[active_idx].orig.coord)
|
||||||
{
|
{
|
||||||
cgGLSetParameterPointer(prg[active_index].orig.coord, 2,
|
cgGLSetParameterPointer(prg[active_idx].orig.coord, 2,
|
||||||
GL_FLOAT, 0, info->coord);
|
GL_FLOAT, 0, info->coord);
|
||||||
cgGLEnableClientState(prg[active_index].orig.coord);
|
cgGLEnableClientState(prg[active_idx].orig.coord);
|
||||||
cg_attribs[cg_attrib_index++] = prg[active_index].orig.coord;
|
cg_attribs[cg_attrib_idx++] = prg[active_idx].orig.coord;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set prev textures. */
|
/* Set prev textures. */
|
||||||
for (i = 0; i < PREV_TEXTURES; i++)
|
for (i = 0; i < PREV_TEXTURES; i++)
|
||||||
{
|
{
|
||||||
param = prg[active_index].prev[i].tex;
|
param = prg[active_idx].prev[i].tex;
|
||||||
if (param)
|
if (param)
|
||||||
{
|
{
|
||||||
cgGLSetTextureParameter(param, prev_info[i].tex);
|
cgGLSetTextureParameter(param, prev_info[i].tex);
|
||||||
cgGLEnableTextureParameter(param);
|
cgGLEnableTextureParameter(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_param_2f(prg[active_index].prev[i].vid_size_v,
|
set_param_2f(prg[active_idx].prev[i].vid_size_v,
|
||||||
prev_info[i].input_size[0], prev_info[i].input_size[1]);
|
prev_info[i].input_size[0], prev_info[i].input_size[1]);
|
||||||
set_param_2f(prg[active_index].prev[i].vid_size_f,
|
set_param_2f(prg[active_idx].prev[i].vid_size_f,
|
||||||
prev_info[i].input_size[0], prev_info[i].input_size[1]);
|
prev_info[i].input_size[0], prev_info[i].input_size[1]);
|
||||||
set_param_2f(prg[active_index].prev[i].tex_size_v,
|
set_param_2f(prg[active_idx].prev[i].tex_size_v,
|
||||||
prev_info[i].tex_size[0], prev_info[i].tex_size[1]);
|
prev_info[i].tex_size[0], prev_info[i].tex_size[1]);
|
||||||
set_param_2f(prg[active_index].prev[i].tex_size_f,
|
set_param_2f(prg[active_idx].prev[i].tex_size_f,
|
||||||
prev_info[i].tex_size[0], prev_info[i].tex_size[1]);
|
prev_info[i].tex_size[0], prev_info[i].tex_size[1]);
|
||||||
|
|
||||||
if (prg[active_index].prev[i].coord)
|
if (prg[active_idx].prev[i].coord)
|
||||||
{
|
{
|
||||||
cgGLSetParameterPointer(prg[active_index].prev[i].coord,
|
cgGLSetParameterPointer(prg[active_idx].prev[i].coord,
|
||||||
2, GL_FLOAT, 0, prev_info[i].coord);
|
2, GL_FLOAT, 0, prev_info[i].coord);
|
||||||
cgGLEnableClientState(prg[active_index].prev[i].coord);
|
cgGLEnableClientState(prg[active_idx].prev[i].coord);
|
||||||
cg_attribs[cg_attrib_index++] = prg[active_index].prev[i].coord;
|
cg_attribs[cg_attrib_idx++] = prg[active_idx].prev[i].coord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
|
|||||||
for (i = 0; i < cg_shader->luts; i++)
|
for (i = 0; i < cg_shader->luts; i++)
|
||||||
{
|
{
|
||||||
CGparameter fparam = cgGetNamedParameter(
|
CGparameter fparam = cgGetNamedParameter(
|
||||||
prg[active_index].fprg, cg_shader->lut[i].id);
|
prg[active_idx].fprg, cg_shader->lut[i].id);
|
||||||
|
|
||||||
if (fparam)
|
if (fparam)
|
||||||
{
|
{
|
||||||
@ -322,7 +322,7 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CGparameter vparam = cgGetNamedParameter(
|
CGparameter vparam = cgGetNamedParameter(
|
||||||
prg[active_index].vprg, cg_shader->lut[i].id);
|
prg[active_idx].vprg, cg_shader->lut[i].id);
|
||||||
if (vparam)
|
if (vparam)
|
||||||
{
|
{
|
||||||
cgGLSetTextureParameter(vparam, lut_textures[i]);
|
cgGLSetTextureParameter(vparam, lut_textures[i]);
|
||||||
@ -331,33 +331,33 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set FBO textures. */
|
/* Set FBO textures. */
|
||||||
if (active_index)
|
if (active_idx)
|
||||||
{
|
{
|
||||||
for (i = 0; i < fbo_info_cnt; i++)
|
for (i = 0; i < fbo_info_cnt; i++)
|
||||||
{
|
{
|
||||||
if (prg[active_index].fbo[i].tex)
|
if (prg[active_idx].fbo[i].tex)
|
||||||
{
|
{
|
||||||
cgGLSetTextureParameter(
|
cgGLSetTextureParameter(
|
||||||
prg[active_index].fbo[i].tex, fbo_info[i].tex);
|
prg[active_idx].fbo[i].tex, fbo_info[i].tex);
|
||||||
cgGLEnableTextureParameter(prg[active_index].fbo[i].tex);
|
cgGLEnableTextureParameter(prg[active_idx].fbo[i].tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_param_2f(prg[active_index].fbo[i].vid_size_v,
|
set_param_2f(prg[active_idx].fbo[i].vid_size_v,
|
||||||
fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
|
fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
|
||||||
set_param_2f(prg[active_index].fbo[i].vid_size_f,
|
set_param_2f(prg[active_idx].fbo[i].vid_size_f,
|
||||||
fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
|
fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
|
||||||
|
|
||||||
set_param_2f(prg[active_index].fbo[i].tex_size_v,
|
set_param_2f(prg[active_idx].fbo[i].tex_size_v,
|
||||||
fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
|
fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
|
||||||
set_param_2f(prg[active_index].fbo[i].tex_size_f,
|
set_param_2f(prg[active_idx].fbo[i].tex_size_f,
|
||||||
fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
|
fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
|
||||||
|
|
||||||
if (prg[active_index].fbo[i].coord)
|
if (prg[active_idx].fbo[i].coord)
|
||||||
{
|
{
|
||||||
cgGLSetParameterPointer(prg[active_index].fbo[i].coord,
|
cgGLSetParameterPointer(prg[active_idx].fbo[i].coord,
|
||||||
2, GL_FLOAT, 0, fbo_info[i].coord);
|
2, GL_FLOAT, 0, fbo_info[i].coord);
|
||||||
cgGLEnableClientState(prg[active_index].fbo[i].coord);
|
cgGLEnableClientState(prg[active_idx].fbo[i].coord);
|
||||||
cg_attribs[cg_attrib_index++] = prg[active_index].fbo[i].coord;
|
cg_attribs[cg_attrib_idx++] = prg[active_idx].fbo[i].coord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,9 +366,9 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
|
|||||||
for (i = 0; i < cg_shader->num_parameters; i++)
|
for (i = 0; i < cg_shader->num_parameters; i++)
|
||||||
{
|
{
|
||||||
CGparameter param_v = cgGetNamedParameter(
|
CGparameter param_v = cgGetNamedParameter(
|
||||||
prg[active_index].vprg, cg_shader->parameters[i].id);
|
prg[active_idx].vprg, cg_shader->parameters[i].id);
|
||||||
CGparameter param_f = cgGetNamedParameter(
|
CGparameter param_f = cgGetNamedParameter(
|
||||||
prg[active_index].fprg, cg_shader->parameters[i].id);
|
prg[active_idx].fprg, cg_shader->parameters[i].id);
|
||||||
set_param_1f(param_v, cg_shader->parameters[i].current);
|
set_param_1f(param_v, cg_shader->parameters[i].current);
|
||||||
set_param_1f(param_f, cg_shader->parameters[i].current);
|
set_param_1f(param_f, cg_shader->parameters[i].current);
|
||||||
}
|
}
|
||||||
@ -380,16 +380,16 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
|
|||||||
static struct state_tracker_uniform info[MAX_VARIABLES];
|
static struct state_tracker_uniform info[MAX_VARIABLES];
|
||||||
static unsigned cnt = 0;
|
static unsigned cnt = 0;
|
||||||
|
|
||||||
if (active_index == 1)
|
if (active_idx == 1)
|
||||||
cnt = state_get_uniform(state_tracker, info,
|
cnt = state_get_uniform(state_tracker, info,
|
||||||
MAX_VARIABLES, frame_count);
|
MAX_VARIABLES, frame_count);
|
||||||
|
|
||||||
for (i = 0; i < cnt; i++)
|
for (i = 0; i < cnt; i++)
|
||||||
{
|
{
|
||||||
CGparameter param_v = cgGetNamedParameter(
|
CGparameter param_v = cgGetNamedParameter(
|
||||||
prg[active_index].vprg, info[i].id);
|
prg[active_idx].vprg, info[i].id);
|
||||||
CGparameter param_f = cgGetNamedParameter(
|
CGparameter param_f = cgGetNamedParameter(
|
||||||
prg[active_index].fprg, info[i].id);
|
prg[active_idx].fprg, info[i].id);
|
||||||
set_param_1f(param_v, info[i].value);
|
set_param_1f(param_v, info[i].value);
|
||||||
set_param_1f(param_f, info[i].value);
|
set_param_1f(param_f, info[i].value);
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ static void gl_cg_deinit(void)
|
|||||||
listing_##type = strdup(list); \
|
listing_##type = strdup(list); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool load_program(unsigned index,
|
static bool load_program(unsigned idx,
|
||||||
const char *prog, bool path_is_file)
|
const char *prog, bool path_is_file)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
@ -489,24 +489,24 @@ static bool load_program(unsigned index,
|
|||||||
|
|
||||||
if (path_is_file)
|
if (path_is_file)
|
||||||
{
|
{
|
||||||
prg[index].fprg = cgCreateProgramFromFile(cgCtx, CG_SOURCE,
|
prg[idx].fprg = cgCreateProgramFromFile(cgCtx, CG_SOURCE,
|
||||||
prog, cgFProf, "main_fragment", argv);
|
prog, cgFProf, "main_fragment", argv);
|
||||||
SET_LISTING(f);
|
SET_LISTING(f);
|
||||||
prg[index].vprg = cgCreateProgramFromFile(cgCtx, CG_SOURCE,
|
prg[idx].vprg = cgCreateProgramFromFile(cgCtx, CG_SOURCE,
|
||||||
prog, cgVProf, "main_vertex", argv);
|
prog, cgVProf, "main_vertex", argv);
|
||||||
SET_LISTING(v);
|
SET_LISTING(v);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prg[index].fprg = cgCreateProgram(cgCtx, CG_SOURCE,
|
prg[idx].fprg = cgCreateProgram(cgCtx, CG_SOURCE,
|
||||||
prog, cgFProf, "main_fragment", argv);
|
prog, cgFProf, "main_fragment", argv);
|
||||||
SET_LISTING(f);
|
SET_LISTING(f);
|
||||||
prg[index].vprg = cgCreateProgram(cgCtx, CG_SOURCE,
|
prg[idx].vprg = cgCreateProgram(cgCtx, CG_SOURCE,
|
||||||
prog, cgVProf, "main_vertex", argv);
|
prog, cgVProf, "main_vertex", argv);
|
||||||
SET_LISTING(v);
|
SET_LISTING(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prg[index].fprg || !prg[index].vprg)
|
if (!prg[idx].fprg || !prg[idx].vprg)
|
||||||
{
|
{
|
||||||
RARCH_ERR("CG error: %s\n", cgGetErrorString(cgGetError()));
|
RARCH_ERR("CG error: %s\n", cgGetErrorString(cgGetError()));
|
||||||
if (listing_f)
|
if (listing_f)
|
||||||
@ -518,8 +518,8 @@ static bool load_program(unsigned index,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
cgGLLoadProgram(prg[index].fprg);
|
cgGLLoadProgram(prg[idx].fprg);
|
||||||
cgGLLoadProgram(prg[index].vprg);
|
cgGLLoadProgram(prg[idx].vprg);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
free(listing_f);
|
free(listing_f);
|
||||||
@ -929,17 +929,17 @@ error:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gl_cg_use(void *data, unsigned index)
|
static void gl_cg_use(void *data, unsigned idx)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
if (cg_active && prg[index].vprg && prg[index].fprg)
|
if (cg_active && prg[idx].vprg && prg[idx].fprg)
|
||||||
{
|
{
|
||||||
gl_cg_reset_attrib();
|
gl_cg_reset_attrib();
|
||||||
|
|
||||||
active_index = index;
|
active_idx = idx;
|
||||||
cgGLBindProgram(prg[index].vprg);
|
cgGLBindProgram(prg[idx].vprg);
|
||||||
cgGLBindProgram(prg[index].fprg);
|
cgGLBindProgram(prg[idx].fprg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -950,30 +950,30 @@ static unsigned gl_cg_num(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gl_cg_filter_type(unsigned index, bool *smooth)
|
static bool gl_cg_filter_type(unsigned idx, bool *smooth)
|
||||||
{
|
{
|
||||||
if (cg_active && index &&
|
if (cg_active && idx &&
|
||||||
(cg_shader->pass[index - 1].filter != RARCH_FILTER_UNSPEC)
|
(cg_shader->pass[idx - 1].filter != RARCH_FILTER_UNSPEC)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
*smooth = (cg_shader->pass[index - 1].filter == RARCH_FILTER_LINEAR);
|
*smooth = (cg_shader->pass[idx - 1].filter == RARCH_FILTER_LINEAR);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum gfx_wrap_type gl_cg_wrap_type(unsigned index)
|
static enum gfx_wrap_type gl_cg_wrap_type(unsigned idx)
|
||||||
{
|
{
|
||||||
if (cg_active && index)
|
if (cg_active && idx)
|
||||||
return cg_shader->pass[index - 1].wrap;
|
return cg_shader->pass[idx - 1].wrap;
|
||||||
return RARCH_WRAP_BORDER;
|
return RARCH_WRAP_BORDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gl_cg_shader_scale(unsigned index, struct gfx_fbo_scale *scale)
|
static void gl_cg_shader_scale(unsigned idx, struct gfx_fbo_scale *scale)
|
||||||
{
|
{
|
||||||
if (cg_active && index)
|
if (cg_active && idx)
|
||||||
*scale = cg_shader->pass[index - 1].fbo;
|
*scale = cg_shader->pass[idx - 1].fbo;
|
||||||
else
|
else
|
||||||
scale->valid = false;
|
scale->valid = false;
|
||||||
}
|
}
|
||||||
@ -993,11 +993,11 @@ static unsigned gl_cg_get_prev_textures(void)
|
|||||||
return max_prev;
|
return max_prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gl_cg_mipmap_input(unsigned index)
|
static bool gl_cg_mipmap_input(unsigned idx)
|
||||||
{
|
{
|
||||||
#ifndef HAVE_GCMGL
|
#ifndef HAVE_GCMGL
|
||||||
if (cg_active && index)
|
if (cg_active && idx)
|
||||||
return cg_shader->pass[index - 1].mipmap;
|
return cg_shader->pass[idx - 1].mipmap;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -82,14 +82,14 @@ struct hlsl_program
|
|||||||
|
|
||||||
static struct hlsl_program prg[RARCH_HLSL_MAX_SHADERS] = {0};
|
static struct hlsl_program prg[RARCH_HLSL_MAX_SHADERS] = {0};
|
||||||
static bool hlsl_active = false;
|
static bool hlsl_active = false;
|
||||||
static unsigned active_index = 0;
|
static unsigned active_idx = 0;
|
||||||
|
|
||||||
static struct gfx_shader *cg_shader;
|
static struct gfx_shader *cg_shader;
|
||||||
|
|
||||||
void hlsl_set_proj_matrix(XMMATRIX rotation_value)
|
void hlsl_set_proj_matrix(XMMATRIX rotation_value)
|
||||||
{
|
{
|
||||||
if (hlsl_active)
|
if (hlsl_active)
|
||||||
prg[active_index].mvp_val = rotation_value;
|
prg[active_idx].mvp_val = rotation_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define set_param_2f(param, xy, constanttable) \
|
#define set_param_2f(param, xy, constanttable) \
|
||||||
@ -119,26 +119,26 @@ static void hlsl_set_params(void *data, unsigned width, unsigned height,
|
|||||||
const float out_size[2] = { (float)out_width, (float)out_height };
|
const float out_size[2] = { (float)out_width, (float)out_height };
|
||||||
float frame_cnt = frame_counter;
|
float frame_cnt = frame_counter;
|
||||||
|
|
||||||
prg[active_index].f_ctable->SetDefaults(d3d_device_ptr);
|
prg[active_idx].f_ctable->SetDefaults(d3d_device_ptr);
|
||||||
prg[active_index].v_ctable->SetDefaults(d3d_device_ptr);
|
prg[active_idx].v_ctable->SetDefaults(d3d_device_ptr);
|
||||||
|
|
||||||
set_param_2f(prg[active_index].vid_size_f, ori_size, prg[active_index].f_ctable);
|
set_param_2f(prg[active_idx].vid_size_f, ori_size, prg[active_idx].f_ctable);
|
||||||
set_param_2f(prg[active_index].tex_size_f, tex_size, prg[active_index].f_ctable);
|
set_param_2f(prg[active_idx].tex_size_f, tex_size, prg[active_idx].f_ctable);
|
||||||
set_param_2f(prg[active_index].out_size_f, out_size, prg[active_index].f_ctable);
|
set_param_2f(prg[active_idx].out_size_f, out_size, prg[active_idx].f_ctable);
|
||||||
set_param_1f(prg[active_index].frame_cnt_f, frame_cnt, prg[active_index].f_ctable);
|
set_param_1f(prg[active_idx].frame_cnt_f, frame_cnt, prg[active_idx].f_ctable);
|
||||||
set_param_1f(prg[active_index].frame_dir_f, g_extern.frame_is_reverse ? -1.0 : 1.0,prg[active_index].f_ctable);
|
set_param_1f(prg[active_idx].frame_dir_f, g_extern.frame_is_reverse ? -1.0 : 1.0,prg[active_idx].f_ctable);
|
||||||
|
|
||||||
set_param_2f(prg[active_index].vid_size_v, ori_size, prg[active_index].v_ctable);
|
set_param_2f(prg[active_idx].vid_size_v, ori_size, prg[active_idx].v_ctable);
|
||||||
set_param_2f(prg[active_index].tex_size_v, tex_size, prg[active_index].v_ctable);
|
set_param_2f(prg[active_idx].tex_size_v, tex_size, prg[active_idx].v_ctable);
|
||||||
set_param_2f(prg[active_index].out_size_v, out_size, prg[active_index].v_ctable);
|
set_param_2f(prg[active_idx].out_size_v, out_size, prg[active_idx].v_ctable);
|
||||||
set_param_1f(prg[active_index].frame_cnt_v, frame_cnt, prg[active_index].v_ctable);
|
set_param_1f(prg[active_idx].frame_cnt_v, frame_cnt, prg[active_idx].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);
|
set_param_1f(prg[active_idx].frame_dir_v, g_extern.frame_is_reverse ? -1.0 : 1.0,prg[active_idx].v_ctable);
|
||||||
|
|
||||||
|
|
||||||
/* TODO - set lookup textures/FBO textures/state parameters/etc */
|
/* TODO - set lookup textures/FBO textures/state parameters/etc */
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool load_program(void *data, unsigned index, const char *prog, bool path_is_file)
|
static bool load_program(void *data, unsigned idx, const char *prog, bool path_is_file)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
LPDIRECT3DDEVICE d3d_device_ptr = (LPDIRECT3DDEVICE)d3d->dev;
|
LPDIRECT3DDEVICE d3d_device_ptr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||||
@ -151,17 +151,17 @@ static bool load_program(void *data, unsigned index, const char *prog, bool path
|
|||||||
if (path_is_file)
|
if (path_is_file)
|
||||||
{
|
{
|
||||||
ret_fp = D3DXCompileShaderFromFile(prog, NULL, NULL,
|
ret_fp = D3DXCompileShaderFromFile(prog, NULL, NULL,
|
||||||
"main_fragment", "ps_3_0", 0, &code_f, &listing_f, &prg[index].f_ctable);
|
"main_fragment", "ps_3_0", 0, &code_f, &listing_f, &prg[idx].f_ctable);
|
||||||
ret_vp = D3DXCompileShaderFromFile(prog, NULL, NULL,
|
ret_vp = D3DXCompileShaderFromFile(prog, NULL, NULL,
|
||||||
"main_vertex", "vs_3_0", 0, &code_v, &listing_v, &prg[index].v_ctable);
|
"main_vertex", "vs_3_0", 0, &code_v, &listing_v, &prg[idx].v_ctable);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* TODO - crashes currently - to do with 'end of line' of stock shader */
|
/* TODO - crashes currently - to do with 'end of line' of stock shader */
|
||||||
ret_fp = D3DXCompileShader(prog, strlen(prog), NULL, NULL,
|
ret_fp = D3DXCompileShader(prog, strlen(prog), NULL, NULL,
|
||||||
"main_fragment", "ps_3_0", 0, &code_f, &listing_f, &prg[index].f_ctable );
|
"main_fragment", "ps_3_0", 0, &code_f, &listing_f, &prg[idx].f_ctable );
|
||||||
ret_vp = D3DXCompileShader(prog, strlen(prog), NULL, NULL,
|
ret_vp = D3DXCompileShader(prog, strlen(prog), NULL, NULL,
|
||||||
"main_vertex", "vs_3_0", 0, &code_v, &listing_v, &prg[index].v_ctable );
|
"main_vertex", "vs_3_0", 0, &code_v, &listing_v, &prg[idx].v_ctable );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret_fp < 0 || ret_vp < 0 || listing_v || listing_f)
|
if (ret_fp < 0 || ret_vp < 0 || listing_v || listing_f)
|
||||||
@ -176,8 +176,8 @@ static bool load_program(void *data, unsigned index, const char *prog, bool path
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
d3d_device_ptr->CreatePixelShader((const DWORD*)code_f->GetBufferPointer(), &prg[index].fprg);
|
d3d_device_ptr->CreatePixelShader((const DWORD*)code_f->GetBufferPointer(), &prg[idx].fprg);
|
||||||
d3d_device_ptr->CreateVertexShader((const DWORD*)code_v->GetBufferPointer(), &prg[index].vprg);
|
d3d_device_ptr->CreateVertexShader((const DWORD*)code_v->GetBufferPointer(), &prg[idx].vprg);
|
||||||
code_f->Release();
|
code_f->Release();
|
||||||
code_v->Release();
|
code_v->Release();
|
||||||
|
|
||||||
@ -370,18 +370,18 @@ static void hlsl_deinit(void)
|
|||||||
hlsl_deinit_state();
|
hlsl_deinit_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hlsl_use(void *data, unsigned index)
|
static void hlsl_use(void *data, unsigned idx)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||||
if (hlsl_active && prg[index].vprg && prg[index].fprg)
|
if (hlsl_active && prg[idx].vprg && prg[idx].fprg)
|
||||||
{
|
{
|
||||||
active_index = index;
|
active_idx = idx;
|
||||||
d3d_set_vertex_shader(d3dr, index, prg[index].vprg);
|
d3d_set_vertex_shader(d3dr, idx, prg[idx].vprg);
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
D3DDevice_SetPixelShader(d3dr, prg[index].fprg);
|
D3DDevice_SetPixelShader(d3dr, prg[idx].fprg);
|
||||||
#else
|
#else
|
||||||
d3dr->SetPixelShader(prg[index].fprg);
|
d3dr->SetPixelShader(prg[idx].fprg);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -393,21 +393,21 @@ static unsigned hlsl_num(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hlsl_filter_type(unsigned index, bool *smooth)
|
static bool hlsl_filter_type(unsigned idx, bool *smooth)
|
||||||
{
|
{
|
||||||
if (hlsl_active && index
|
if (hlsl_active && idx
|
||||||
&& (cg_shader->pass[index - 1].filter != RARCH_FILTER_UNSPEC))
|
&& (cg_shader->pass[idx - 1].filter != RARCH_FILTER_UNSPEC))
|
||||||
{
|
{
|
||||||
*smooth = cg_shader->pass[index - 1].filter = RARCH_FILTER_LINEAR;
|
*smooth = cg_shader->pass[idx - 1].filter = RARCH_FILTER_LINEAR;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hlsl_shader_scale(unsigned index, struct gfx_fbo_scale *scale)
|
static void hlsl_shader_scale(unsigned idx, struct gfx_fbo_scale *scale)
|
||||||
{
|
{
|
||||||
if (hlsl_active && index)
|
if (hlsl_active && idx)
|
||||||
*scale = cg_shader->pass[index - 1].fbo;
|
*scale = cg_shader->pass[idx - 1].fbo;
|
||||||
else
|
else
|
||||||
scale->valid = false;
|
scale->valid = false;
|
||||||
}
|
}
|
||||||
@ -417,17 +417,17 @@ static bool hlsl_set_mvp(void *data, const math_matrix *mat)
|
|||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
LPDIRECT3DDEVICE d3d_device_ptr = (LPDIRECT3DDEVICE)d3d->dev;
|
LPDIRECT3DDEVICE d3d_device_ptr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||||
|
|
||||||
if(hlsl_active && prg[active_index].mvp)
|
if(hlsl_active && prg[active_idx].mvp)
|
||||||
{
|
{
|
||||||
prg[active_index].v_ctable->SetMatrix(d3d_device_ptr, prg[active_index].mvp, (D3DXMATRIX*)&prg[active_index].mvp_val);
|
prg[active_idx].v_ctable->SetMatrix(d3d_device_ptr, prg[active_idx].mvp, (D3DXMATRIX*)&prg[active_idx].mvp_val);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hlsl_mipmap_input(unsigned index)
|
static bool hlsl_mipmap_input(unsigned idx)
|
||||||
{
|
{
|
||||||
(void)index;
|
(void)idx;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,8 +78,10 @@ static bool shader_null_set_coords(const void *data)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shader_null_use(void *data, unsigned index)
|
static void shader_null_use(void *data, unsigned idx)
|
||||||
{
|
{
|
||||||
|
(void)data;
|
||||||
|
(void)idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned shader_null_num(void)
|
static unsigned shader_null_num(void)
|
||||||
@ -87,19 +89,24 @@ static unsigned shader_null_num(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool shader_null_filter_type(unsigned index, bool *smooth)
|
static bool shader_null_filter_type(unsigned idx, bool *smooth)
|
||||||
{
|
{
|
||||||
|
(void)idx;
|
||||||
|
(void)smooth;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum gfx_wrap_type shader_null_wrap_type(unsigned index)
|
static enum gfx_wrap_type shader_null_wrap_type(unsigned idx)
|
||||||
{
|
{
|
||||||
|
(void)idx;
|
||||||
return RARCH_WRAP_BORDER;
|
return RARCH_WRAP_BORDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shader_null_shader_scale(unsigned index,
|
static void shader_null_shader_scale(unsigned idx,
|
||||||
struct gfx_fbo_scale *scale)
|
struct gfx_fbo_scale *scale)
|
||||||
{
|
{
|
||||||
|
(void)idx;
|
||||||
|
(void)scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned shader_null_get_prev_textures(void)
|
static unsigned shader_null_get_prev_textures(void)
|
||||||
@ -107,8 +114,9 @@ static unsigned shader_null_get_prev_textures(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool shader_null_mipmap_input(unsigned index)
|
static bool shader_null_mipmap_input(unsigned idx)
|
||||||
{
|
{
|
||||||
|
(void)idx;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user