(Shader) Implement shader parameter action OK callbacks

This commit is contained in:
twinaphex 2019-12-23 05:39:10 +01:00
parent 18f2b9c63e
commit 9988bae6f4
10 changed files with 177 additions and 35 deletions

View File

@ -283,6 +283,10 @@ MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL,
"deferred_dropdown_box_list_special")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION,
"deferred_dropdown_box_list_resolution")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PARAMETER,
"deferred_dropdown_box_list_video_shader_parameter")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PRESET_PARAMETER,
"deferred_dropdown_box_list_video_shader_preset_parameter")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_NUM_PASSES,
"deferred_dropdown_box_list_video_shader_num_passes")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE,

View File

@ -647,6 +647,8 @@ generic_deferred_push_clear_general(deferred_push_dropdown_box_list, PUSH_DEFAUL
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_special, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_SPECIAL)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_resolution, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_RESOLUTION)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_video_shader_num_passes, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_NUM_PASSES)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_shader_parameter, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_PARAMETER)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_shader_preset_parameter, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_PRESET_PARAMETER)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_playlist_default_core, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_DEFAULT_CORE)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_playlist_label_display_mode, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_LABEL_DISPLAY_MODE)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_playlist_right_thumbnail_mode, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_RIGHT_THUMBNAIL_MODE)
@ -673,6 +675,8 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL, deferred_push_dropdown_box_list_special},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION, deferred_push_dropdown_box_list_resolution},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_NUM_PASSES, deferred_push_dropdown_box_list_video_shader_num_passes},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PARAMETER, deferred_push_dropdown_box_list_shader_parameter},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PRESET_PARAMETER, deferred_push_dropdown_box_list_shader_preset_parameter},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE, deferred_push_dropdown_box_list_playlist_default_core},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE, deferred_push_dropdown_box_list_playlist_label_display_mode},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_RIGHT_THUMBNAIL_MODE, deferred_push_dropdown_box_list_playlist_right_thumbnail_mode},

View File

@ -170,6 +170,10 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
{
switch (lbl)
{
case ACTION_OK_DL_DROPDOWN_BOX_LIST_SHADER_PARAMETER:
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PARAMETER;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_SHADER_PRESET_PARAMETER:
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PRESET_PARAMETER;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_VIDEO_SHADER_NUM_PASSES:
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_NUM_PASSES;
case ACTION_OK_DL_DROPDOWN_BOX_LIST:
@ -430,6 +434,24 @@ int generic_action_ok_displaylist_push(const char *path,
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_SHADER_PARAMETER:
info.type = MENU_SETTINGS_SHADER_PARAMETER_0 + idx;
info.directory_ptr = idx;
info_path = path;
info_label = msg_hash_to_str(
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PARAMETER);
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PARAMETER;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_SHADER_PRESET_PARAMETER:
info.type = type;
info.directory_ptr = idx;
info_path = path;
info_label = msg_hash_to_str(
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PRESET_PARAMETER);
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PRESET_PARAMETER;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_VIDEO_SHADER_NUM_PASSES:
info.type = type;
info.directory_ptr = idx;
@ -5496,6 +5518,47 @@ static int action_ok_push_dropdown_item_video_shader_num_pass(const char *path,
#endif
}
static int action_ok_push_dropdown_item_video_shader_param_generic(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx,
size_t setting_offset)
{
video_shader_ctx_t shader_info;
unsigned offset = setting_offset;
float val = atof(path);
struct video_shader *shader = menu_shader_get();
struct video_shader_parameter *param_menu = NULL;
struct video_shader_parameter *param_prev = NULL;
video_shader_driver_get_current_shader(&shader_info);
param_prev = &shader_info.data->parameters[entry_idx - offset];
param_menu = shader ? &shader->parameters [entry_idx - offset] : NULL;
if (!param_prev || !param_menu)
return menu_cbs_exit();
param_prev->current = val;
param_menu->current = param_prev->current;
menu_shader_set_modified(true);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_item_video_shader_param(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return action_ok_push_dropdown_item_video_shader_param_generic(path, label, type,
idx, entry_idx, MENU_SETTINGS_SHADER_PARAMETER_0);
}
static int action_ok_push_dropdown_item_video_shader_preset_param(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return action_ok_push_dropdown_item_video_shader_param_generic(path, label, type,
idx, entry_idx, MENU_SETTINGS_SHADER_PRESET_PARAMETER_0);
}
static int action_ok_push_dropdown_item_resolution(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -5867,6 +5930,20 @@ static int action_ok_playlist_right_thumbnail_mode(const char *path,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_RIGHT_THUMBNAIL_MODE);
}
static int action_ok_shader_parameter_dropdown_box_list(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_dropdown_box_list(idx,
ACTION_OK_DL_DROPDOWN_BOX_LIST_SHADER_PARAMETER);
}
static int action_ok_shader_preset_parameter_dropdown_box_list(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_dropdown_box_list(idx,
ACTION_OK_DL_DROPDOWN_BOX_LIST_SHADER_PRESET_PARAMETER);
}
static int action_ok_playlist_left_thumbnail_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -7110,12 +7187,12 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
else if (type >= MENU_SETTINGS_SHADER_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PARAMETER_LAST)
{
BIND_ACTION_OK(cbs, NULL);
BIND_ACTION_OK(cbs, action_ok_shader_parameter_dropdown_box_list);
}
else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST)
{
BIND_ACTION_OK(cbs, NULL);
BIND_ACTION_OK(cbs, action_ok_shader_preset_parameter_dropdown_box_list);
}
else if (type >= MENU_SETTINGS_CHEAT_BEGIN
&& type <= MENU_SETTINGS_CHEAT_END)
@ -7152,6 +7229,12 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
case MENU_SETTING_DROPDOWN_ITEM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_item);
break;
case MENU_SETTING_DROPDOWN_ITEM_VIDEO_SHADER_PARAM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_item_video_shader_param);
break;
case MENU_SETTING_DROPDOWN_ITEM_VIDEO_SHADER_PRESET_PARAM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_item_video_shader_preset_param);
break;
case MENU_SETTING_DROPDOWN_ITEM_RESOLUTION:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_item_resolution);
break;

View File

@ -122,20 +122,6 @@ static int action_select_core_setting(const char *path, const char *label, unsig
return action_ok_core_option_dropdown_list(path, label, type, idx, 0);
}
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
static int shader_action_parameter_select(const char *path, const char *label, unsigned type,
size_t idx, size_t entry_idx)
{
return shader_action_parameter_right(type, label, true);
}
static int shader_action_parameter_preset_select(const char *path, const char *label, unsigned type,
size_t idx, size_t entry_idx)
{
return shader_action_preset_parameter_right(type, label, true);
}
#endif
static int action_select_cheat(const char *path, const char *label, unsigned type,
size_t idx, size_t entry_idx)
{
@ -197,18 +183,6 @@ static int menu_cbs_init_bind_select_compare_type(
{
BIND_ACTION_SELECT(cbs, action_select_cheat);
}
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
else if (type >= MENU_SETTINGS_SHADER_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PARAMETER_LAST)
{
BIND_ACTION_SELECT(cbs, shader_action_parameter_select);
}
else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST)
{
BIND_ACTION_SELECT(cbs, shader_action_parameter_preset_select);
}
#endif
else if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN
&& type <= MENU_SETTINGS_INPUT_DESC_END)
{

View File

@ -403,6 +403,8 @@ default_title_macro(action_get_title_collection, MENU_ENUM_LABEL_
default_title_macro(action_get_title_deferred_core_list, MENU_ENUM_LABEL_VALUE_SUPPORTED_CORES)
default_title_macro(action_get_title_dropdown_resolution_item, MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION)
default_title_macro(action_get_title_dropdown_video_shader_num_pass_item, MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_NUM_PASSES)
default_title_macro(action_get_title_dropdown_video_shader_parameter_item, MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS)
default_title_macro(action_get_title_dropdown_video_shader_preset_parameter_item, MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS)
default_title_macro(action_get_title_dropdown_playlist_default_core_item, MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_DEFAULT_CORE)
default_title_macro(action_get_title_dropdown_playlist_label_display_mode_item, MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE)
default_title_macro(action_get_title_manual_content_scan_list, MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_LIST)
@ -1446,6 +1448,8 @@ int menu_cbs_init_bind_title(menu_file_list_cbs_t *cbs,
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST, action_get_title_dropdown_item},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL, action_get_title_dropdown_item},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION, action_get_title_dropdown_resolution_item },
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PARAMETER, action_get_title_dropdown_video_shader_parameter_item },
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PRESET_PARAMETER, action_get_title_dropdown_video_shader_preset_parameter_item },
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_NUM_PASSES, action_get_title_dropdown_video_shader_num_pass_item },
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE, action_get_title_dropdown_playlist_default_core_item},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE, action_get_title_dropdown_playlist_label_display_mode_item},

View File

@ -48,6 +48,8 @@ enum
ACTION_OK_DL_DROPDOWN_BOX_LIST,
ACTION_OK_DL_DROPDOWN_BOX_LIST_SPECIAL,
ACTION_OK_DL_DROPDOWN_BOX_LIST_RESOLUTION,
ACTION_OK_DL_DROPDOWN_BOX_LIST_SHADER_PARAMETER,
ACTION_OK_DL_DROPDOWN_BOX_LIST_SHADER_PRESET_PARAMETER,
ACTION_OK_DL_DROPDOWN_BOX_LIST_VIDEO_SHADER_NUM_PASSES,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE,

View File

@ -105,6 +105,9 @@ static char new_lbl_entry[4096] = {0};
static char new_entry[4096] = {0};
static enum msg_hash_enums new_type = MSG_UNKNOWN;
/* TODO/FIXME - global state */
static unsigned current_entry_type = 0;
#define menu_displaylist_parse_settings_enum(list, label, parse_type, add_empty_entry) menu_displaylist_parse_settings_internal_enum(list, parse_type, add_empty_entry, menu_setting_find_enum(label), label, true)
#define menu_displaylist_parse_settings(list, label, parse_type, add_empty_entry, entry_type) menu_displaylist_parse_settings_internal_enum(list, parse_type, add_empty_entry, menu_setting_find(label), entry_type, false)
@ -7011,6 +7014,52 @@ static bool history_needs_navigation_clear(menu_handle_t *menu, playlist_t *play
}
#endif
static unsigned menu_displaylist_build_shader_parameter(
menu_displaylist_info_t *info,
file_list_t *list,
unsigned entry_type, unsigned _offset,
unsigned setting_type)
{
video_shader_ctx_t shader_info;
float current_value = 0.0f;
unsigned count = 0;
float min = 0;
float max = 0;
unsigned i = 0;
struct video_shader *shader = menu_shader_get();
struct video_shader_parameter *param = NULL;
unsigned offset = entry_type - _offset;
video_shader_driver_get_current_shader(&shader_info);
param = &shader_info.data->parameters[offset];
if (!param)
return 0;
min = param->minimum;
max = param->maximum;
current_value = min;
for (i = 0; current_value < (max + 0.0001f); i++)
{
char val_s[16], val_d[16];
snprintf(val_s, sizeof(val_s), "%.2f", current_value);
snprintf(val_d, sizeof(val_d), "%d", i);
if (menu_entries_append_enum(list,
val_s,
val_d,
MENU_ENUM_LABEL_NO_ITEMS,
setting_type,
i, current_entry_type))
count++;
current_value += param->step;
}
return count;
}
bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
menu_displaylist_info_t *info)
{
@ -7023,13 +7072,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
int ret = 0;
menu_handle_t *menu = menu_driver_get_ptr();
/* TODO/FIXME
* We cannot perform a:
* if (!menu)
* return false;
* sanity check here, because menu_displaylist_ctl() can be
* called by menu driver init functions - i.e. we can legally
* reach this point before the menu has been created... */
disp_list.info = info;
disp_list.type = type;
@ -7037,6 +7079,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
if (menu_driver_push_list(&disp_list))
return true;
current_entry_type = info->type;
switch (type)
{
#ifdef HAVE_CDROM
@ -8509,6 +8553,27 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
info->need_push = true;
break;
case DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_PARAMETER:
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
count = menu_displaylist_build_shader_parameter(
info, info->list, current_entry_type,
MENU_SETTINGS_SHADER_PARAMETER_0,
MENU_SETTING_DROPDOWN_ITEM_VIDEO_SHADER_PARAM);
info->need_refresh = true;
info->need_push = true;
break;
case DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_PRESET_PARAMETER:
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
count = menu_displaylist_build_shader_parameter(
info, info->list, current_entry_type,
MENU_SETTINGS_SHADER_PRESET_PARAMETER_0,
MENU_SETTING_DROPDOWN_ITEM_VIDEO_SHADER_PRESET_PARAM);
info->need_refresh = true;
info->need_push = true;
break;
case DISPLAYLIST_SAVING_SETTINGS_LIST:
case DISPLAYLIST_DRIVER_SETTINGS_LIST:

View File

@ -56,6 +56,8 @@ enum menu_displaylist_ctl_state
DISPLAYLIST_DROPDOWN_LIST,
DISPLAYLIST_DROPDOWN_LIST_SPECIAL,
DISPLAYLIST_DROPDOWN_LIST_RESOLUTION,
DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_PARAMETER,
DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_PRESET_PARAMETER,
DISPLAYLIST_DROPDOWN_LIST_VIDEO_SHADER_NUM_PASSES,
DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_DEFAULT_CORE,
DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_LABEL_DISPLAY_MODE,

View File

@ -87,6 +87,8 @@ enum menu_settings_type
MENU_PLAYLISTS_TAB,
MENU_SETTING_DROPDOWN_ITEM,
MENU_SETTING_DROPDOWN_ITEM_RESOLUTION,
MENU_SETTING_DROPDOWN_ITEM_VIDEO_SHADER_PARAM,
MENU_SETTING_DROPDOWN_ITEM_VIDEO_SHADER_PRESET_PARAM,
MENU_SETTING_DROPDOWN_ITEM_VIDEO_SHADER_NUM_PASS,
MENU_SETTING_DROPDOWN_ITEM_PLAYLIST_DEFAULT_CORE,
MENU_SETTING_DROPDOWN_ITEM_PLAYLIST_LABEL_DISPLAY_MODE,

View File

@ -1246,6 +1246,8 @@ enum msg_hash_enums
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PARAMETER,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_PRESET_PARAMETER,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_NUM_PASSES,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE,