/** * video_shader_read_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Loads preset file and all associated state (passes, * textures, imports, etc). * * Returns: true (1) if successful, otherwise false (0). **/ bool video_shader_read_conf_cgp(config_file_t *conf, struct video_shader *shader) { unsigned shaders, i; memset(shader, 0, sizeof(*shader)); shader->type = RARCH_SHADER_CG; shaders = 0; if (!config_get_uint(conf, "shaders", &shaders)) { RARCH_ERR("Cannot find \"shaders\" param.\n"); return false; } if (!shaders) { RARCH_ERR("Need to define at least 1 shader.\n"); return false; } if (!config_get_int(conf, "feedback_pass", &shader->feedback_pass)) shader->feedback_pass = -1; shader->passes = MIN(shaders, GFX_MAX_SHADERS); for (i = 0; i < shader->passes; i++) { if (!video_shader_parse_pass(conf, &shader->pass[i], i)) return false; } if (!video_shader_parse_textures(conf, shader)) return false; if (!video_shader_parse_imports(conf, shader)) return false; return true; }
/** * video_shader_read_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Loads preset file and all associated state (passes, * textures, imports, etc). * * Returns: true (1) if successful, otherwise false (0). **/ bool video_shader_read_conf_cgp(config_file_t *conf, struct video_shader *shader) { unsigned i; union string_list_elem_attr attr; unsigned shaders = 0; settings_t *settings = config_get_ptr(); struct string_list *file_list = NULL; (void)file_list; memset(shader, 0, sizeof(*shader)); shader->type = RARCH_SHADER_CG; if (!config_get_uint(conf, "shaders", &shaders)) { RARCH_ERR("Cannot find \"shaders\" param.\n"); return false; } if (!shaders) { RARCH_ERR("Need to define at least 1 shader.\n"); return false; } if (!config_get_int(conf, "feedback_pass", &shader->feedback_pass)) shader->feedback_pass = -1; shader->passes = MIN(shaders, GFX_MAX_SHADERS); attr.i = 0; strlcpy(shader->path, conf->path, sizeof(shader->path)); if (settings->bools.video_shader_watch_files) { if (file_change_data) frontend_driver_watch_path_for_changes(NULL, 0, &file_change_data); file_change_data = NULL; file_list = string_list_new(); string_list_append(file_list, conf->path, attr); } for (i = 0; i < shader->passes; i++) { if (!video_shader_parse_pass(conf, &shader->pass[i], i)) { if (file_list) { string_list_free(file_list); file_list = NULL; } return false; } if (settings->bools.video_shader_watch_files && file_list) string_list_append(file_list, shader->pass[i].source.path, attr); } if (settings->bools.video_shader_watch_files) { int flags = PATH_CHANGE_TYPE_MODIFIED | PATH_CHANGE_TYPE_WRITE_FILE_CLOSED | PATH_CHANGE_TYPE_FILE_MOVED | PATH_CHANGE_TYPE_FILE_DELETED; frontend_driver_watch_path_for_changes(file_list, flags, &file_change_data); if (file_list) string_list_free(file_list); } command_event(CMD_EVENT_SHADER_PRESET_LOADED, NULL); if (!video_shader_parse_textures(conf, shader)) return false; if (!video_shader_parse_imports(conf, shader)) return false; return true; }