Create SHADER_CTL_INFO

This commit is contained in:
twinaphex 2016-02-14 19:30:48 +01:00
parent cdd6684bb9
commit 02ec7830d9
3 changed files with 31 additions and 15 deletions

View File

@ -657,9 +657,13 @@ static void gl_init_fbo(gl_t *gl, unsigned fbo_width, unsigned fbo_height)
int i;
unsigned width, height;
video_shader_ctx_scale_t scaler;
video_shader_ctx_info_t shader_info;
struct gfx_fbo_scale scale, scale_last;
if (!gl || video_shader_driver_num_shaders() == 0)
if (!video_shader_driver_ctl(SHADER_CTL_INFO, &shader_info))
return;
if (!gl || shader_info.num == 0)
return;
video_driver_get_size(&width, &height);
@ -669,13 +673,13 @@ static void gl_init_fbo(gl_t *gl, unsigned fbo_width, unsigned fbo_height)
video_shader_driver_ctl(SHADER_CTL_SCALE, &scaler);
scaler.idx = video_shader_driver_num_shaders();
scaler.idx = shader_info.num;
scaler.scale = &scale_last;
video_shader_driver_ctl(SHADER_CTL_SCALE, &scaler);
/* we always want FBO to be at least initialized on startup for consoles */
if (video_shader_driver_num_shaders() == 1 && !scale.valid)
if (shader_info.num == 1 && !scale.valid)
return;
if (!gl_check_fbo_proc(gl))
@ -684,7 +688,7 @@ static void gl_init_fbo(gl_t *gl, unsigned fbo_width, unsigned fbo_height)
return;
}
gl->fbo_pass = video_shader_driver_num_shaders() - 1;
gl->fbo_pass = shader_info.num - 1;
if (scale_last.valid)
gl->fbo_pass++;
@ -2598,6 +2602,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
gfx_ctx_mode_t mode;
gfx_ctx_input_t inp;
unsigned interval, mip_level;
video_shader_ctx_info_t shader_info;
unsigned win_width, win_height, temp_width = 0, temp_height = 0;
bool force_smooth = false;
const char *vendor = NULL;
@ -2750,9 +2755,12 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
gl->textures = max(minimum + 1, gl->textures);
}
if (!video_shader_driver_ctl(SHADER_CTL_INFO, &shader_info))
goto error;
RARCH_LOG("[GL]: Using %u textures.\n", gl->textures);
RARCH_LOG("[GL]: Loaded %u program(s).\n",
video_shader_driver_num_shaders());
shader_info.num);
gl->tex_w = gl->tex_h = (RARCH_SCALE_BASE * video->input_scale);
gl->keep_aspect = video->force_aspect;

View File

@ -83,13 +83,6 @@ const char *video_shader_driver_get_ident(void)
return current_shader->ident;
}
unsigned video_shader_driver_num_shaders(void)
{
if (!current_shader)
return 0;
return current_shader->num_shaders(shader_data);
}
unsigned video_shader_driver_get_prev_textures(void)
{
if (!current_shader)
@ -225,6 +218,17 @@ bool video_shader_driver_ctl(enum video_shader_driver_ctl_state state, void *dat
current_shader->shader_scale(shader_data, scaler->idx, scaler->scale);
}
break;
case SHADER_CTL_INFO:
{
video_shader_ctx_info_t *shader_info = (video_shader_ctx_info_t*)data;
if (!shader_info || !current_shader)
return false;
shader_info->num = 0;
if (current_shader->num_shaders)
shader_info->num = current_shader->num_shaders(shader_data);
}
break;
case SHADER_CTL_NONE:
default:
break;

View File

@ -64,7 +64,8 @@ enum video_shader_driver_ctl_state
SHADER_CTL_GET_FEEDBACK_PASS,
SHADER_CTL_MIPMAP_INPUT,
SHADER_CTL_SET_COORDS,
SHADER_CTL_SCALE
SHADER_CTL_SCALE,
SHADER_CTL_INFO
};
typedef struct shader_backend
@ -139,6 +140,11 @@ typedef struct video_shader_ctx_scale
struct gfx_fbo_scale *scale;
} video_shader_ctx_scale_t;
typedef struct video_shader_ctx_info
{
unsigned num;
} video_shader_ctx_info_t;
extern const shader_backend_t gl_glsl_backend;
extern const shader_backend_t hlsl_backend;
extern const shader_backend_t gl_cg_backend;
@ -160,8 +166,6 @@ void video_shader_driver_use(void *data, unsigned index);
const char *video_shader_driver_get_ident(void);
unsigned video_shader_driver_num_shaders(void);
bool video_shader_driver_set_mvp(void *data, const math_matrix_4x4 *mat);
unsigned video_shader_driver_get_prev_textures(void);