static void gl_glsl_set_params(void *data, void *shader_data, unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_count, const void *_info, const void *_prev_info, const void *_feedback_info, const void *_fbo_info, unsigned fbo_info_cnt) { unsigned i; GLfloat buffer[512]; struct glsl_attrib attribs[32]; float input_size[2], output_size[2], texture_size[2]; unsigned texunit = 1; const struct shader_uniforms *uni = NULL; size_t size = 0, attribs_size = 0; const struct video_tex_info *info = (const struct video_tex_info*)_info; const struct video_tex_info *prev_info = (const struct video_tex_info*)_prev_info; const struct video_tex_info *feedback_info = (const struct video_tex_info*)_feedback_info; const struct video_tex_info *fbo_info = (const struct video_tex_info*)_fbo_info; struct glsl_attrib *attr = (struct glsl_attrib*)attribs; glsl_shader_data_t *glsl = (glsl_shader_data_t*)shader_data; if (!glsl) return; uni = (const struct shader_uniforms*)&glsl->uniforms[glsl->active_idx]; if (glsl->prg[glsl->active_idx].id == 0) return; input_size [0] = (float)width; input_size [1] = (float)height; output_size[0] = (float)out_width; output_size[1] = (float)out_height; texture_size[0] = (float)tex_width; texture_size[1] = (float)tex_height; if (uni->input_size >= 0) glUniform2fv(uni->input_size, 1, input_size); if (uni->output_size >= 0) glUniform2fv(uni->output_size, 1, output_size); if (uni->texture_size >= 0) glUniform2fv(uni->texture_size, 1, texture_size); if (uni->frame_count >= 0 && glsl->active_idx) { unsigned modulo = glsl->shader->pass[glsl->active_idx - 1].frame_count_mod; if (modulo) frame_count %= modulo; glUniform1i(uni->frame_count, frame_count); } if (uni->frame_direction >= 0) glUniform1i(uni->frame_direction, state_manager_frame_is_reversed() ? -1 : 1); /* Set lookup textures. */ for (i = 0; i < glsl->shader->luts; i++) { if (uni->lut_texture[i] < 0) continue; /* Have to rebind as HW render could override this. */ glActiveTexture(GL_TEXTURE0 + texunit); glBindTexture(GL_TEXTURE_2D, glsl->lut_textures[i]); glUniform1i(uni->lut_texture[i], texunit); texunit++; } if (glsl->active_idx) { /* Set original texture. */ if (uni->orig.texture >= 0) { /* Bind original texture. */ glActiveTexture(GL_TEXTURE0 + texunit); glUniform1i(uni->orig.texture, texunit); glBindTexture(GL_TEXTURE_2D, info->tex); texunit++; } if (uni->orig.texture_size >= 0) glUniform2fv(uni->orig.texture_size, 1, info->tex_size); if (uni->orig.input_size >= 0) glUniform2fv(uni->orig.input_size, 1, info->input_size); /* Pass texture coordinates. */ if (uni->orig.tex_coord >= 0) { attr->loc = uni->orig.tex_coord; attr->size = 2; attr->offset = size * sizeof(GLfloat); attribs_size++; attr++; memcpy(buffer + size, info->coord, 8 * sizeof(GLfloat)); size += 8; } /* Set feedback texture. */ if (uni->feedback.texture >= 0) { /* Bind original texture. */ glActiveTexture(GL_TEXTURE0 + texunit); glUniform1i(uni->feedback.texture, texunit); glBindTexture(GL_TEXTURE_2D, feedback_info->tex); texunit++; } if (uni->feedback.texture_size >= 0) glUniform2fv(uni->feedback.texture_size, 1, feedback_info->tex_size); if (uni->feedback.input_size >= 0) glUniform2fv(uni->feedback.input_size, 1, feedback_info->input_size); /* Pass texture coordinates. */ if (uni->feedback.tex_coord >= 0) { attr->loc = uni->feedback.tex_coord; attr->size = 2; attr->offset = size * sizeof(GLfloat); attribs_size++; attr++; memcpy(buffer + size, feedback_info->coord, 8 * sizeof(GLfloat)); size += 8; } /* Bind FBO textures. */ for (i = 0; i < fbo_info_cnt; i++) { if (uni->pass[i].texture) { glActiveTexture(GL_TEXTURE0 + texunit); glBindTexture(GL_TEXTURE_2D, fbo_info[i].tex); glUniform1i(uni->pass[i].texture, texunit); texunit++; } if (uni->pass[i].texture_size >= 0) glUniform2fv(uni->pass[i].texture_size, 1, fbo_info[i].tex_size); if (uni->pass[i].input_size >= 0) glUniform2fv(uni->pass[i].input_size, 1, fbo_info[i].input_size); if (uni->pass[i].tex_coord >= 0) { attr->loc = uni->pass[i].tex_coord; attr->size = 2; attr->offset = size * sizeof(GLfloat); attribs_size++; attr++; memcpy(buffer + size, fbo_info[i].coord, 8 * sizeof(GLfloat)); size += 8; } } } /* Set previous textures. Only bind if they're actually used. */ for (i = 0; i < PREV_TEXTURES; i++) { if (uni->prev[i].texture >= 0) { glActiveTexture(GL_TEXTURE0 + texunit); glBindTexture(GL_TEXTURE_2D, prev_info[i].tex); glUniform1i(uni->prev[i].texture, texunit); texunit++; } if (uni->prev[i].texture_size >= 0) glUniform2fv(uni->prev[i].texture_size, 1, prev_info[i].tex_size); if (uni->prev[i].input_size >= 0) glUniform2fv(uni->prev[i].input_size, 1, prev_info[i].input_size); /* Pass texture coordinates. */ if (uni->prev[i].tex_coord >= 0) { attr->loc = uni->prev[i].tex_coord; attr->size = 2; attr->offset = size * sizeof(GLfloat); attribs_size++; attr++; memcpy(buffer + size, prev_info[i].coord, 8 * sizeof(GLfloat)); size += 8; } } if (size) gl_glsl_set_attribs(glsl, glsl->vbo[glsl->active_idx].vbo_secondary, &glsl->vbo[glsl->active_idx].buffer_secondary, &glsl->vbo[glsl->active_idx].size_secondary, buffer, size, attribs, attribs_size); glActiveTexture(GL_TEXTURE0); /* #pragma parameters. */ for (i = 0; i < glsl->shader->num_parameters; i++) { int location = glGetUniformLocation( glsl->prg[glsl->active_idx].id, glsl->shader->parameters[i].id); glUniform1f(location, glsl->shader->parameters[i].current); } /* Set state parameters. */ if (glsl->state_tracker) { static struct state_tracker_uniform state_info[GFX_MAX_VARIABLES]; static unsigned cnt = 0; if (glsl->active_idx == 1) cnt = state_tracker_get_uniform(glsl->state_tracker, state_info, GFX_MAX_VARIABLES, frame_count); for (i = 0; i < cnt; i++) { int location = glGetUniformLocation( glsl->prg[glsl->active_idx].id, state_info[i].id); glUniform1f(location, state_info[i].value); } } }
bool runloop_ctl(enum runloop_ctl_state state, void *data) { static rarch_dir_list_t runloop_shader_dir; static char runloop_fullpath[PATH_MAX_LENGTH]; static rarch_system_info_t runloop_system; static unsigned runloop_pending_windowed_scale; static retro_keyboard_event_t runloop_key_event = NULL; static unsigned runloop_max_frames = false; static bool runloop_frame_time_last = false; static bool runloop_set_frame_limit = false; static bool runloop_paused = false; static bool runloop_idle = false; static bool runloop_exec = false; static bool runloop_slowmotion = false; static bool runloop_shutdown_initiated = false; static bool runloop_core_shutdown_initiated = false; static bool runloop_perfcnt_enable = false; static bool runloop_overrides_active = false; static bool runloop_game_options_active = false; #ifdef HAVE_THREADS static slock_t *runloop_msg_queue_lock = NULL; #endif static core_info_t *core_info_current = NULL; static core_info_list_t *core_info_curr_list = NULL; settings_t *settings = config_get_ptr(); switch (state) { case RUNLOOP_CTL_DATA_ITERATE: rarch_task_check(); return true; case RUNLOOP_CTL_SHADER_DIR_DEINIT: shader_dir_free(&runloop_shader_dir); return true; case RUNLOOP_CTL_SHADER_DIR_INIT: return shader_dir_init(&runloop_shader_dir); case RUNLOOP_CTL_SYSTEM_INFO_INIT: core.retro_get_system_info(&runloop_system.info); if (!runloop_system.info.library_name) runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); if (!runloop_system.info.library_version) runloop_system.info.library_version = "v0"; #ifndef RARCH_CONSOLE strlcpy(runloop_system.title_buf, msg_hash_to_str(MSG_PROGRAM), sizeof(runloop_system.title_buf)); strlcat(runloop_system.title_buf, " : ", sizeof(runloop_system.title_buf)); #endif strlcat(runloop_system.title_buf, runloop_system.info.library_name, sizeof(runloop_system.title_buf)); strlcat(runloop_system.title_buf, " ", sizeof(runloop_system.title_buf)); strlcat(runloop_system.title_buf, runloop_system.info.library_version, sizeof(runloop_system.title_buf)); strlcpy(runloop_system.valid_extensions, runloop_system.info.valid_extensions ? runloop_system.info.valid_extensions : DEFAULT_EXT, sizeof(runloop_system.valid_extensions)); runloop_system.block_extract = runloop_system.info.block_extract; break; case RUNLOOP_CTL_GET_CORE_OPTION_SIZE: { unsigned *idx = (unsigned*)data; if (!idx) return false; *idx = core_option_size(runloop_system.core_options); } return true; case RUNLOOP_CTL_HAS_CORE_OPTIONS: return runloop_system.core_options; case RUNLOOP_CTL_CURRENT_CORE_LIST_FREE: if (core_info_curr_list) core_info_list_free(core_info_curr_list); core_info_curr_list = NULL; return true; case RUNLOOP_CTL_CURRENT_CORE_LIST_INIT: core_info_curr_list = core_info_list_new(); return true; case RUNLOOP_CTL_CURRENT_CORE_LIST_GET: { core_info_list_t **core = (core_info_list_t**)data; if (!core) return false; *core = core_info_curr_list; } return true; case RUNLOOP_CTL_CURRENT_CORE_FREE: if (core_info_current) free(core_info_current); core_info_current = NULL; return true; case RUNLOOP_CTL_CURRENT_CORE_INIT: core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t)); if (!core_info_current) return false; return true; case RUNLOOP_CTL_CURRENT_CORE_GET: { core_info_t **core = (core_info_t**)data; if (!core) return false; *core = core_info_current; } return true; case RUNLOOP_CTL_SYSTEM_INFO_GET: { rarch_system_info_t **system = (rarch_system_info_t**)data; if (!system) return false; *system = &runloop_system; } return true; case RUNLOOP_CTL_SYSTEM_INFO_FREE: if (runloop_system.core_options) { core_option_flush(runloop_system.core_options); core_option_free(runloop_system.core_options); } runloop_system.core_options = NULL; /* No longer valid. */ if (runloop_system.special) free(runloop_system.special); runloop_system.special = NULL; if (runloop_system.ports) free(runloop_system.ports); runloop_system.ports = NULL; runloop_key_event = NULL; global_get_ptr()->frontend_key_event = NULL; audio_driver_unset_callback(); memset(&runloop_system, 0, sizeof(rarch_system_info_t)); break; case RUNLOOP_CTL_IS_FRAME_COUNT_END: { uint64_t *frame_count = NULL; video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); return runloop_max_frames && (*frame_count >= runloop_max_frames); } case RUNLOOP_CTL_SET_FRAME_TIME_LAST: runloop_frame_time_last = true; break; case RUNLOOP_CTL_UNSET_FRAME_TIME_LAST: runloop_frame_time_last = false; break; case RUNLOOP_CTL_SET_OVERRIDES_ACTIVE: runloop_overrides_active = true; break; case RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE: runloop_overrides_active = false; break; case RUNLOOP_CTL_IS_OVERRIDES_ACTIVE: return runloop_overrides_active; case RUNLOOP_CTL_SET_GAME_OPTIONS_ACTIVE: runloop_game_options_active = true; break; case RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE: runloop_game_options_active = false; break; case RUNLOOP_CTL_IS_GAME_OPTIONS_ACTIVE: return runloop_game_options_active; case RUNLOOP_CTL_IS_FRAME_TIME_LAST: return runloop_frame_time_last; case RUNLOOP_CTL_SET_FRAME_LIMIT: runloop_set_frame_limit = true; break; case RUNLOOP_CTL_UNSET_FRAME_LIMIT: runloop_set_frame_limit = false; break; case RUNLOOP_CTL_SHOULD_SET_FRAME_LIMIT: return runloop_set_frame_limit; case RUNLOOP_CTL_GET_PERFCNT: { bool **perfcnt = (bool**)data; if (!perfcnt) return false; *perfcnt = &runloop_perfcnt_enable; } return true; case RUNLOOP_CTL_SET_PERFCNT_ENABLE: runloop_perfcnt_enable = true; break; case RUNLOOP_CTL_UNSET_PERFCNT_ENABLE: runloop_perfcnt_enable = false; break; case RUNLOOP_CTL_IS_PERFCNT_ENABLE: return runloop_perfcnt_enable; case RUNLOOP_CTL_GET_WINDOWED_SCALE: { unsigned **scale = (unsigned**)data; if (!scale) return false; *scale = (unsigned*)&runloop_pending_windowed_scale; } break; case RUNLOOP_CTL_SET_WINDOWED_SCALE: { unsigned *idx = (unsigned*)data; if (!idx) return false; runloop_pending_windowed_scale = *idx; } break; case RUNLOOP_CTL_SET_LIBRETRO_PATH: { const char *fullpath = (const char*)data; if (!fullpath) return false; strlcpy(settings->libretro, fullpath, sizeof(settings->libretro)); } break; case RUNLOOP_CTL_CLEAR_CONTENT_PATH: *runloop_fullpath = '\0'; break; case RUNLOOP_CTL_GET_CONTENT_PATH: { char **fullpath = (char**)data; if (!fullpath) return false; *fullpath = (char*)runloop_fullpath; } break; case RUNLOOP_CTL_SET_CONTENT_PATH: { const char *fullpath = (const char*)data; if (!fullpath) return false; strlcpy(runloop_fullpath, fullpath, sizeof(runloop_fullpath)); } break; case RUNLOOP_CTL_CHECK_FOCUS: if (settings->pause_nonactive) return video_driver_ctl(RARCH_DISPLAY_CTL_IS_FOCUSED, NULL); return true; case RUNLOOP_CTL_CHECK_IDLE_STATE: { event_cmd_state_t *cmd = (event_cmd_state_t*)data; bool focused = runloop_ctl(RUNLOOP_CTL_CHECK_FOCUS, NULL); check_pause(settings, focused, runloop_cmd_triggered(cmd, RARCH_PAUSE_TOGGLE), runloop_cmd_triggered(cmd, RARCH_FRAMEADVANCE)); if (!runloop_ctl(RUNLOOP_CTL_CHECK_PAUSE_STATE, cmd) || !focused) return false; break; } case RUNLOOP_CTL_CHECK_STATE: { bool tmp = false; event_cmd_state_t *cmd = (event_cmd_state_t*)data; if (!cmd || runloop_idle) return false; if (runloop_cmd_triggered(cmd, RARCH_SCREENSHOT)) event_command(EVENT_CMD_TAKE_SCREENSHOT); if (runloop_cmd_triggered(cmd, RARCH_MUTE)) event_command(EVENT_CMD_AUDIO_MUTE_TOGGLE); if (runloop_cmd_triggered(cmd, RARCH_OSK)) { if (input_driver_ctl(RARCH_INPUT_CTL_IS_KEYBOARD_LINEFEED_ENABLED, NULL)) input_driver_ctl(RARCH_INPUT_CTL_UNSET_KEYBOARD_LINEFEED_ENABLED, NULL); else input_driver_ctl(RARCH_INPUT_CTL_SET_KEYBOARD_LINEFEED_ENABLED, NULL); } if (runloop_cmd_press(cmd, RARCH_VOLUME_UP)) event_command(EVENT_CMD_VOLUME_UP); else if (runloop_cmd_press(cmd, RARCH_VOLUME_DOWN)) event_command(EVENT_CMD_VOLUME_DOWN); #ifdef HAVE_NETPLAY tmp = runloop_cmd_triggered(cmd, RARCH_NETPLAY_FLIP); netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, &tmp); tmp = runloop_cmd_triggered(cmd, RARCH_FULLSCREEN_TOGGLE_KEY); netplay_driver_ctl(RARCH_NETPLAY_CTL_FULLSCREEN_TOGGLE, &tmp); #endif if (!runloop_ctl(RUNLOOP_CTL_CHECK_IDLE_STATE, data)) return false; check_fast_forward_button( runloop_cmd_triggered(cmd, RARCH_FAST_FORWARD_KEY), runloop_cmd_press (cmd, RARCH_FAST_FORWARD_HOLD_KEY), runloop_cmd_pressed (cmd, RARCH_FAST_FORWARD_HOLD_KEY)); check_stateslots(settings, runloop_cmd_triggered(cmd, RARCH_STATE_SLOT_PLUS), runloop_cmd_triggered(cmd, RARCH_STATE_SLOT_MINUS) ); if (runloop_cmd_triggered(cmd, RARCH_SAVE_STATE_KEY)) event_command(EVENT_CMD_SAVE_STATE); else if (runloop_cmd_triggered(cmd, RARCH_LOAD_STATE_KEY)) event_command(EVENT_CMD_LOAD_STATE); state_manager_check_rewind(runloop_cmd_press(cmd, RARCH_REWIND)); tmp = runloop_cmd_press(cmd, RARCH_SLOWMOTION); runloop_ctl(RUNLOOP_CTL_CHECK_SLOWMOTION, &tmp); if (runloop_cmd_triggered(cmd, RARCH_MOVIE_RECORD_TOGGLE)) runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE, NULL); check_shader_dir(&runloop_shader_dir, runloop_cmd_triggered(cmd, RARCH_SHADER_NEXT), runloop_cmd_triggered(cmd, RARCH_SHADER_PREV)); if (runloop_cmd_triggered(cmd, RARCH_DISK_EJECT_TOGGLE)) event_command(EVENT_CMD_DISK_EJECT_TOGGLE); else if (runloop_cmd_triggered(cmd, RARCH_DISK_NEXT)) event_command(EVENT_CMD_DISK_NEXT); else if (runloop_cmd_triggered(cmd, RARCH_DISK_PREV)) event_command(EVENT_CMD_DISK_PREV); if (runloop_cmd_triggered(cmd, RARCH_RESET)) event_command(EVENT_CMD_RESET); cheat_manager_state_checks( runloop_cmd_triggered(cmd, RARCH_CHEAT_INDEX_PLUS), runloop_cmd_triggered(cmd, RARCH_CHEAT_INDEX_MINUS), runloop_cmd_triggered(cmd, RARCH_CHEAT_TOGGLE)); } break; case RUNLOOP_CTL_CHECK_PAUSE_STATE: { bool check_is_oneshot; event_cmd_state_t *cmd = (event_cmd_state_t*)data; if (!cmd) return false; check_is_oneshot = runloop_cmd_triggered(cmd, RARCH_FRAMEADVANCE) || runloop_cmd_press(cmd, RARCH_REWIND); if (!runloop_paused) return true; if (runloop_cmd_triggered(cmd, RARCH_FULLSCREEN_TOGGLE_KEY)) { event_command(EVENT_CMD_FULLSCREEN_TOGGLE); video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); } if (!check_is_oneshot) return false; } break; case RUNLOOP_CTL_CHECK_SLOWMOTION: { bool *ptr = (bool*)data; if (!ptr) return false; runloop_slowmotion = *ptr; if (!runloop_slowmotion) return false; if (settings->video.black_frame_insertion) video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); if (state_manager_frame_is_reversed()) runloop_msg_queue_push_new(MSG_SLOW_MOTION_REWIND, 0, 30, true); else runloop_msg_queue_push_new(MSG_SLOW_MOTION, 0, 30, true); } break; case RUNLOOP_CTL_CHECK_MOVIE: if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_PLAYBACK, NULL); if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_INIT, NULL); return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_RECORD, NULL); case RUNLOOP_CTL_CHECK_MOVIE_RECORD: if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) return false; runloop_msg_queue_push_new( MSG_MOVIE_RECORD_STOPPED, 2, 180, true); RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED)); event_command(EVENT_CMD_BSV_MOVIE_DEINIT); break; case RUNLOOP_CTL_CHECK_MOVIE_INIT: if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) return false; { char msg[128]; char path[PATH_MAX_LENGTH]; settings->rewind_granularity = 1; if (settings->state_slot > 0) snprintf(path, sizeof(path), "%s%d", bsv_movie_get_path(), settings->state_slot); else strlcpy(path, bsv_movie_get_path(), sizeof(path)); strlcat(path, ".bsv", sizeof(path)); snprintf(msg, sizeof(msg), "%s \"%s\".", msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), path); bsv_movie_init_handle(path, RARCH_MOVIE_RECORD); if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) return false; else if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) { runloop_msg_queue_push(msg, 1, 180, true); RARCH_LOG("%s \"%s\".\n", msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), path); } else { runloop_msg_queue_push_new( MSG_FAILED_TO_START_MOVIE_RECORD, 1, 180, true); RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD)); } } break; case RUNLOOP_CTL_CHECK_MOVIE_PLAYBACK: if (!bsv_movie_ctl(BSV_MOVIE_CTL_END, NULL)) return false; runloop_msg_queue_push_new( MSG_MOVIE_PLAYBACK_ENDED, 1, 180, false); RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED)); event_command(EVENT_CMD_BSV_MOVIE_DEINIT); bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL); bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL); break; case RUNLOOP_CTL_STATE_FREE: runloop_perfcnt_enable = false; runloop_idle = false; runloop_paused = false; runloop_slowmotion = false; runloop_frame_time_last = false; runloop_set_frame_limit = false; runloop_overrides_active = false; runloop_max_frames = 0; break; case RUNLOOP_CTL_GLOBAL_FREE: { global_t *global; event_command(EVENT_CMD_TEMPORARY_CONTENT_DEINIT); event_command(EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT); event_command(EVENT_CMD_RECORD_DEINIT); event_command(EVENT_CMD_LOG_FILE_DEINIT); rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); runloop_overrides_active = false; global = global_get_ptr(); memset(global, 0, sizeof(struct global)); } break; case RUNLOOP_CTL_CLEAR_STATE: driver_ctl(RARCH_DRIVER_CTL_DEINIT, NULL); runloop_ctl(RUNLOOP_CTL_STATE_FREE, NULL); runloop_ctl(RUNLOOP_CTL_GLOBAL_FREE, NULL); break; case RUNLOOP_CTL_SET_MAX_FRAMES: { unsigned *ptr = (unsigned*)data; if (!ptr) return false; runloop_max_frames = *ptr; } break; case RUNLOOP_CTL_IS_IDLE: return runloop_idle; case RUNLOOP_CTL_SET_IDLE: { bool *ptr = (bool*)data; if (!ptr) return false; runloop_idle = *ptr; } break; case RUNLOOP_CTL_IS_SLOWMOTION: { bool *ptr = (bool*)data; if (!ptr) return false; *ptr = runloop_slowmotion; } break; case RUNLOOP_CTL_SET_SLOWMOTION: { bool *ptr = (bool*)data; if (!ptr) return false; runloop_slowmotion = *ptr; } break; case RUNLOOP_CTL_SET_PAUSED: { bool *ptr = (bool*)data; if (!ptr) return false; runloop_paused = *ptr; } break; case RUNLOOP_CTL_IS_PAUSED: return runloop_paused; case RUNLOOP_CTL_MSG_QUEUE_FREE: #ifdef HAVE_THREADS slock_free(runloop_msg_queue_lock); runloop_msg_queue_lock = NULL; #endif break; case RUNLOOP_CTL_MSG_QUEUE_DEINIT: if (!g_msg_queue) return true; runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_LOCK, NULL); msg_queue_free(g_msg_queue); runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_UNLOCK, NULL); runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_FREE, NULL); g_msg_queue = NULL; break; case RUNLOOP_CTL_MSG_QUEUE_INIT: runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_DEINIT, NULL); g_msg_queue = msg_queue_new(8); retro_assert(g_msg_queue); #ifdef HAVE_THREADS runloop_msg_queue_lock = slock_new(); retro_assert(runloop_msg_queue_lock); #endif break; case RUNLOOP_CTL_MSG_QUEUE_LOCK: #ifdef HAVE_THREADS slock_lock(runloop_msg_queue_lock); #endif break; case RUNLOOP_CTL_MSG_QUEUE_UNLOCK: #ifdef HAVE_THREADS slock_unlock(runloop_msg_queue_lock); #endif break; case RUNLOOP_CTL_PREPARE_DUMMY: #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL); #endif runloop_data_clear_state(); runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); break; case RUNLOOP_CTL_SET_CORE_SHUTDOWN: runloop_core_shutdown_initiated = true; break; case RUNLOOP_CTL_UNSET_CORE_SHUTDOWN: runloop_core_shutdown_initiated = false; break; case RUNLOOP_CTL_IS_CORE_SHUTDOWN: return runloop_core_shutdown_initiated; case RUNLOOP_CTL_SET_SHUTDOWN: runloop_shutdown_initiated = true; break; case RUNLOOP_CTL_UNSET_SHUTDOWN: runloop_shutdown_initiated = false; break; case RUNLOOP_CTL_IS_SHUTDOWN: return runloop_shutdown_initiated; case RUNLOOP_CTL_SET_EXEC: runloop_exec = true; break; case RUNLOOP_CTL_UNSET_EXEC: runloop_exec = false; break; case RUNLOOP_CTL_IS_EXEC: return runloop_exec; case RUNLOOP_CTL_DATA_DEINIT: rarch_task_deinit(); break; case RUNLOOP_CTL_IS_CORE_OPTION_UPDATED: return runloop_system.core_options ? core_option_updated(runloop_system.core_options) : false; case RUNLOOP_CTL_CORE_OPTION_PREV: { unsigned *idx = (unsigned*)data; if (!idx) return false; core_option_prev(runloop_system.core_options, *idx); if (ui_companion_is_on_foreground()) ui_companion_driver_notify_refresh(); } return true; case RUNLOOP_CTL_CORE_OPTION_NEXT: { unsigned *idx = (unsigned*)data; if (!idx) return false; core_option_next(runloop_system.core_options, *idx); if (ui_companion_is_on_foreground()) ui_companion_driver_notify_refresh(); } return true; case RUNLOOP_CTL_CORE_OPTIONS_GET: { struct retro_variable *var = (struct retro_variable*)data; if (!runloop_system.core_options || !var) return false; RARCH_LOG("Environ GET_VARIABLE %s:\n", var->key); core_option_get(runloop_system.core_options, var); RARCH_LOG("\t%s\n", var->value ? var->value : "N/A"); } return true; case RUNLOOP_CTL_CORE_OPTIONS_INIT: { char *game_options_path = NULL; bool ret = false; const struct retro_variable *vars = (const struct retro_variable*)data; char buf[PATH_MAX_LENGTH] = {0}; global_t *global = global_get_ptr(); const char *options_path = settings->core_options_path; if (!*options_path && *global->path.config) { fill_pathname_resolve_relative(buf, global->path.config, "retroarch-core-options.cfg", sizeof(buf)); options_path = buf; } if (settings->game_specific_options) ret = rarch_game_specific_options(&game_options_path); if(ret) { runloop_ctl(RUNLOOP_CTL_SET_GAME_OPTIONS_ACTIVE, NULL); runloop_system.core_options = core_option_new(game_options_path, vars); free(game_options_path); } else { runloop_ctl(RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE, NULL); runloop_system.core_options = core_option_new(options_path, vars); } } break; case RUNLOOP_CTL_CORE_OPTIONS_DEINIT: if (!runloop_system.core_options) return false; core_option_flush(runloop_system.core_options); core_option_free(runloop_system.core_options); runloop_system.core_options = NULL; return true; case RUNLOOP_CTL_KEY_EVENT_GET: { retro_keyboard_event_t **key_event = (retro_keyboard_event_t**)data; if (!key_event) return false; *key_event = &runloop_key_event; } break; case RUNLOOP_CTL_NONE: default: return false; } return true; }
static void gl_glsl_set_params(void *data, void *shader_data, unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_count, const void *_info, const void *_prev_info, const void *_feedback_info, const void *_fbo_info, unsigned fbo_info_cnt) { unsigned i; struct uniform_info uniform_params[10] = {{0}}; GLfloat buffer[512]; struct glsl_attrib attribs[32]; float input_size[2], output_size[2], texture_size[2]; unsigned uniform_count = 0; unsigned texunit = 1; const struct shader_uniforms *uni = NULL; size_t size = 0, attribs_size = 0; const struct gfx_tex_info *info = (const struct gfx_tex_info*)_info; const struct gfx_tex_info *prev_info = (const struct gfx_tex_info*)_prev_info; const struct gfx_tex_info *feedback_info = (const struct gfx_tex_info*)_feedback_info; const struct gfx_tex_info *fbo_info = (const struct gfx_tex_info*)_fbo_info; struct glsl_attrib *attr = (struct glsl_attrib*)attribs; glsl_shader_data_t *glsl = (glsl_shader_data_t*)shader_data; if (!glsl) return; uni = (const struct shader_uniforms*)&glsl->uniforms[glsl->active_idx]; if (glsl->prg[glsl->active_idx].id == 0) return; input_size [0] = (float)width; input_size [1] = (float)height; output_size[0] = (float)out_width; output_size[1] = (float)out_height; texture_size[0] = (float)tex_width; texture_size[1] = (float)tex_height; uniform_params[0].enabled = false; uniform_params[0].location = uni->input_size; uniform_params[0].type = UNIFORM_2FV; uniform_params[0].result.floatv = input_size; if (uni->input_size >= 0) uniform_params[0].enabled = true; uniform_params[1].enabled = false; uniform_params[1].location = uni->output_size; uniform_params[1].type = UNIFORM_2FV; uniform_params[1].result.floatv = output_size; if (uni->output_size >= 0) uniform_params[1].enabled = true; uniform_params[2].enabled = false; uniform_params[2].location = uni->texture_size; uniform_params[2].type = UNIFORM_2FV; uniform_params[2].result.floatv = texture_size; if (uni->texture_size >= 0) uniform_params[2].enabled = true; uniform_count += 3; if (uni->frame_count >= 0 && glsl->active_idx) { unsigned modulo = glsl->shader->pass[glsl->active_idx - 1].frame_count_mod; if (modulo) frame_count %= modulo; uniform_params[uniform_count].enabled = true; uniform_params[uniform_count].location = uni->frame_count; uniform_params[uniform_count].type = UNIFORM_1I; uniform_params[uniform_count].result.integer.v0 = frame_count; uniform_count++; } uniform_params[uniform_count].enabled = true; uniform_params[uniform_count].location = uni->frame_direction; uniform_params[uniform_count].type = UNIFORM_1I; uniform_params[uniform_count].result.integer.v0 = state_manager_frame_is_reversed() ? -1 : 1; uniform_count++; for (i = 0; i < uniform_count; i++) gl_glsl_set_uniform_parameter(glsl, &uniform_params[i], NULL); /* Set lookup textures. */ for (i = 0; i < glsl->shader->luts; i++) { struct uniform_info lut_uniform = {0}; if (uni->lut_texture[i] < 0) continue; /* Have to rebind as HW render could override this. */ glActiveTexture(GL_TEXTURE0 + texunit); glBindTexture(GL_TEXTURE_2D, glsl->lut_textures[i]); lut_uniform.enabled = true; lut_uniform.location = uni->lut_texture[i]; lut_uniform.type = UNIFORM_1I; lut_uniform.result.integer.v0 = texunit; gl_glsl_set_uniform_parameter(glsl, &lut_uniform, NULL); texunit++; } if (glsl->active_idx) { unsigned j; struct uniform_info orig_uniforms[2] = {{0}}; struct uniform_info feedback_uniforms[2] = {{0}}; /* Set original texture. */ if (uni->orig.texture >= 0) { struct uniform_info orig_tex_uniform = {0}; /* Bind original texture. */ glActiveTexture(GL_TEXTURE0 + texunit); orig_tex_uniform.enabled = true; orig_tex_uniform.location = uni->orig.texture; orig_tex_uniform.type = UNIFORM_1I; orig_tex_uniform.result.integer.v0 = texunit; gl_glsl_set_uniform_parameter(glsl, &orig_tex_uniform, NULL); glBindTexture(GL_TEXTURE_2D, info->tex); texunit++; } orig_uniforms[0].enabled = false; orig_uniforms[0].location = uni->orig.texture_size; orig_uniforms[0].type = UNIFORM_2FV; orig_uniforms[0].result.floatv = (float*)info->tex_size; if (uni->orig.texture_size >= 0) orig_uniforms[0].enabled = true; orig_uniforms[1].enabled = false; orig_uniforms[1].location = uni->orig.input_size; orig_uniforms[1].type = UNIFORM_2FV; orig_uniforms[1].result.floatv = (float*)info->input_size; if (uni->orig.input_size >= 0) orig_uniforms[1].enabled = true; for (j = 0; j < 2; j++) gl_glsl_set_uniform_parameter(glsl, &orig_uniforms[j], NULL); /* Pass texture coordinates. */ if (uni->orig.tex_coord >= 0) { attr->loc = uni->orig.tex_coord; attr->size = 2; attr->offset = size * sizeof(GLfloat); attribs_size++; attr++; memcpy(buffer + size, info->coord, 8 * sizeof(GLfloat)); size += 8; } /* Set feedback texture. */ if (uni->feedback.texture >= 0) { struct uniform_info feedback_texture_param = {0}; /* Bind original texture. */ glActiveTexture(GL_TEXTURE0 + texunit); feedback_texture_param.enabled = true; feedback_texture_param.location = uni->pass[i].texture; feedback_texture_param.type = UNIFORM_1I; feedback_texture_param.result.integer.v0 = texunit; gl_glsl_set_uniform_parameter(glsl, &feedback_texture_param, NULL); glBindTexture(GL_TEXTURE_2D, feedback_info->tex); texunit++; } feedback_uniforms[0].enabled = false; feedback_uniforms[0].location = uni->feedback.texture_size; feedback_uniforms[0].type = UNIFORM_2FV; feedback_uniforms[0].result.floatv = (float*)feedback_info->tex_size; if (uni->feedback.texture_size >= 0) feedback_uniforms[0].enabled = true; feedback_uniforms[1].enabled = false; feedback_uniforms[1].location = uni->feedback.input_size; feedback_uniforms[1].type = UNIFORM_2FV; feedback_uniforms[1].result.floatv = (float*)feedback_info->input_size; if (uni->feedback.input_size >= 0) feedback_uniforms[1].enabled = true; for (j = 0; j < 2; j++) gl_glsl_set_uniform_parameter(glsl, &feedback_uniforms[j], NULL); /* Pass texture coordinates. */ if (uni->feedback.tex_coord >= 0) { attr->loc = uni->feedback.tex_coord; attr->size = 2; attr->offset = size * sizeof(GLfloat); attribs_size++; attr++; memcpy(buffer + size, feedback_info->coord, 8 * sizeof(GLfloat)); size += 8; } /* Bind FBO textures. */ for (i = 0; i < fbo_info_cnt; i++) { unsigned j; struct uniform_info fbo_tex_params[3] = {{0}}; if (uni->pass[i].texture) { glActiveTexture(GL_TEXTURE0 + texunit); glBindTexture(GL_TEXTURE_2D, fbo_info[i].tex); fbo_tex_params[0].enabled = true; fbo_tex_params[0].location = uni->pass[i].texture; fbo_tex_params[0].type = UNIFORM_1I; fbo_tex_params[0].result.integer.v0 = texunit; texunit++; } fbo_tex_params[1].enabled = false; fbo_tex_params[1].location = uni->pass[i].texture_size; fbo_tex_params[1].type = UNIFORM_2FV; fbo_tex_params[1].result.floatv = (float*)fbo_info[i].tex_size; if (uni->pass[i].texture_size >= 0) fbo_tex_params[1].enabled = true; fbo_tex_params[2].enabled = false; fbo_tex_params[2].location = uni->pass[i].input_size; fbo_tex_params[2].type = UNIFORM_2FV; fbo_tex_params[2].result.floatv = (float*)fbo_info[i].input_size; if (uni->pass[i].input_size >= 0) fbo_tex_params[2].enabled = true; for (j = 0; j < 3; j++) gl_glsl_set_uniform_parameter(glsl, &fbo_tex_params[j], NULL); if (uni->pass[i].tex_coord >= 0) { attr->loc = uni->pass[i].tex_coord; attr->size = 2; attr->offset = size * sizeof(GLfloat); attribs_size++; attr++; memcpy(buffer + size, fbo_info[i].coord, 8 * sizeof(GLfloat)); size += 8; } } } /* Set previous textures. Only bind if they're actually used. */ for (i = 0; i < PREV_TEXTURES; i++) { unsigned j; struct uniform_info prev_tex_params[3] = {{0}}; if (uni->prev[i].texture >= 0) { glActiveTexture(GL_TEXTURE0 + texunit); glBindTexture(GL_TEXTURE_2D, prev_info[i].tex); prev_tex_params[0].enabled = true; prev_tex_params[0].location = uni->prev[i].texture; prev_tex_params[0].type = UNIFORM_1I; prev_tex_params[0].result.integer.v0 = texunit; texunit++; } prev_tex_params[1].enabled = false; prev_tex_params[1].location = uni->prev[i].texture_size; prev_tex_params[1].type = UNIFORM_2FV; prev_tex_params[1].result.floatv = (float*)prev_info[i].tex_size; if (uni->prev[i].texture_size >= 0) prev_tex_params[1].enabled = true; prev_tex_params[2].enabled = false; prev_tex_params[2].location = uni->prev[i].input_size; prev_tex_params[2].type = UNIFORM_2FV; prev_tex_params[2].result.floatv = (float*)prev_info[i].input_size; if (uni->prev[i].input_size >= 0) prev_tex_params[2].enabled = true; for (j = 0; j < 3; j++) gl_glsl_set_uniform_parameter(glsl, &prev_tex_params[j], NULL); /* Pass texture coordinates. */ if (uni->prev[i].tex_coord >= 0) { attr->loc = uni->prev[i].tex_coord; attr->size = 2; attr->offset = size * sizeof(GLfloat); attribs_size++; attr++; memcpy(buffer + size, prev_info[i].coord, 8 * sizeof(GLfloat)); size += 8; } } if (size) gl_glsl_set_attribs(glsl, glsl->vbo[glsl->active_idx].vbo_secondary, &glsl->vbo[glsl->active_idx].buffer_secondary, &glsl->vbo[glsl->active_idx].size_secondary, buffer, size, attribs, attribs_size); glActiveTexture(GL_TEXTURE0); /* #pragma parameters. */ for (i = 0; i < glsl->shader->num_parameters; i++) { struct uniform_info pragma_param = {0}; pragma_param.lookup.enable = true; pragma_param.lookup.idx = glsl->active_idx; pragma_param.lookup.ident = glsl->shader->parameters[i].id; pragma_param.lookup.type = SHADER_PROGRAM_COMBINED; pragma_param.enabled = true; pragma_param.type = UNIFORM_1F; pragma_param.result.f.v0 = glsl->shader->parameters[i].current; gl_glsl_set_uniform_parameter(glsl, &pragma_param, NULL); } /* Set state parameters. */ if (glsl->state_tracker) { static struct state_tracker_uniform state_info[GFX_MAX_VARIABLES]; static unsigned cnt = 0; if (glsl->active_idx == 1) cnt = state_tracker_get_uniform(glsl->state_tracker, state_info, GFX_MAX_VARIABLES, frame_count); for (i = 0; i < cnt; i++) { struct uniform_info state_param = {0}; state_param.lookup.enable = true; state_param.lookup.idx = glsl->active_idx; state_param.lookup.ident = state_info[i].id; state_param.lookup.type = SHADER_PROGRAM_COMBINED; state_param.enabled = true; state_param.type = UNIFORM_1F; state_param.result.f.v0 = state_info[i].value; gl_glsl_set_uniform_parameter(glsl, &state_param, NULL); } } }
/** * check_rewind: * @pressed : was rewind key pressed or held? * * Checks if rewind toggle/hold was being pressed and/or held. **/ void state_manager_check_rewind(bool pressed) { static bool first = true; settings_t *settings = config_get_ptr(); if (state_manager_frame_is_reversed()) { audio_driver_frame_is_reverse(); state_manager_set_frame_is_reversed(false); } if (first) { first = false; return; } if (!rewind_state.state) return; if (pressed) { const void *buf = NULL; if (state_manager_pop(rewind_state.state, &buf)) { retro_ctx_serialize_info_t serial_info; state_manager_set_frame_is_reversed(true); audio_driver_setup_rewind(); runloop_msg_queue_push( msg_hash_to_str(MSG_REWINDING), 0, runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) ? 1 : 30, true); serial_info.data_const = buf; serial_info.size = rewind_state.size; core_unserialize(&serial_info); if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) bsv_movie_ctl(BSV_MOVIE_CTL_FRAME_REWIND, NULL); } else runloop_msg_queue_push( msg_hash_to_str(MSG_REWIND_REACHED_END), 0, 30, true); } else { static unsigned cnt = 0; cnt = (cnt + 1) % (settings->rewind_granularity ? settings->rewind_granularity : 1); /* Avoid possible SIGFPE. */ if ((cnt == 0) || bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) { retro_ctx_serialize_info_t serial_info; static struct retro_perf_counter rewind_serialize = {0}; void *state = NULL; state_manager_push_where(rewind_state.state, &state); performance_counter_init(&rewind_serialize, "rewind_serialize"); performance_counter_start(&rewind_serialize); serial_info.data = state; serial_info.size = rewind_state.size; core_serialize(&serial_info); performance_counter_stop(&rewind_serialize); state_manager_push_do(rewind_state.state); } } core_set_rewind_callbacks(); }
static void gl_cg_set_params(void *data, unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_count, const void *_info, const void *_prev_info, const void *_feedback_info, const void *_fbo_info, unsigned fbo_info_cnt) { unsigned i; const struct gfx_tex_info *info = (const struct gfx_tex_info*)_info; const struct gfx_tex_info *prev_info = (const struct gfx_tex_info*)_prev_info; const struct gfx_tex_info *feedback_info = (const struct gfx_tex_info*)_feedback_info; const struct gfx_tex_info *fbo_info = (const struct gfx_tex_info*)_fbo_info; driver_t *driver = driver_get_ptr(); cg_shader_data_t *cg = (cg_shader_data_t*)driver->video_shader_data; (void)data; if (!cg || (cg->active_idx == 0) || (cg->active_idx == GL_SHADER_STOCK_BLEND)) return; /* Set frame. */ set_param_2f(cg->prg[cg->active_idx].vid_size_f, width, height); set_param_2f(cg->prg[cg->active_idx].tex_size_f, tex_width, tex_height); set_param_2f(cg->prg[cg->active_idx].out_size_f, out_width, out_height); set_param_1f(cg->prg[cg->active_idx].frame_dir_f, state_manager_frame_is_reversed() ? -1.0 : 1.0); set_param_2f(cg->prg[cg->active_idx].vid_size_v, width, height); set_param_2f(cg->prg[cg->active_idx].tex_size_v, tex_width, tex_height); set_param_2f(cg->prg[cg->active_idx].out_size_v, out_width, out_height); set_param_1f(cg->prg[cg->active_idx].frame_dir_v, state_manager_frame_is_reversed() ? -1.0 : 1.0); if (cg->prg[cg->active_idx].frame_cnt_f || cg->prg[cg->active_idx].frame_cnt_v) { unsigned modulo = cg->shader->pass[cg->active_idx - 1].frame_count_mod; if (modulo) frame_count %= modulo; set_param_1f(cg->prg[cg->active_idx].frame_cnt_f, (float)frame_count); set_param_1f(cg->prg[cg->active_idx].frame_cnt_v, (float)frame_count); } /* Set orig texture. */ gl_cg_set_texture_info(cg, &cg->prg[cg->active_idx].orig, info); /* Set feedback texture. */ gl_cg_set_texture_info(cg, &cg->prg[cg->active_idx].feedback, feedback_info); /* Set prev textures. */ for (i = 0; i < PREV_TEXTURES; i++) gl_cg_set_texture_info(cg, &cg->prg[cg->active_idx].prev[i], &prev_info[i]); /* Set lookup textures. */ for (i = 0; i < cg->shader->luts; i++) { CGparameter vparam; CGparameter fparam = cgGetNamedParameter( cg->prg[cg->active_idx].fprg, cg->shader->lut[i].id); if (fparam) { cgGLSetTextureParameter(fparam, cg->lut_textures[i]); cgGLEnableTextureParameter(fparam); } vparam = cgGetNamedParameter(cg->prg[cg->active_idx].vprg, cg->shader->lut[i].id); if (vparam) { cgGLSetTextureParameter(vparam, cg->lut_textures[i]); cgGLEnableTextureParameter(vparam); } } /* Set FBO textures. */ if (cg->active_idx) { for (i = 0; i < fbo_info_cnt; i++) gl_cg_set_texture_info(cg, &cg->prg[cg->active_idx].fbo[i], &fbo_info[i]); } /* #pragma parameters. */ for (i = 0; i < cg->shader->num_parameters; i++) { CGparameter param_v = cgGetNamedParameter( cg->prg[cg->active_idx].vprg, cg->shader->parameters[i].id); CGparameter param_f = cgGetNamedParameter( cg->prg[cg->active_idx].fprg, cg->shader->parameters[i].id); set_param_1f(param_v, cg->shader->parameters[i].current); set_param_1f(param_f, cg->shader->parameters[i].current); } /* Set state parameters. */ if (cg->state_tracker) { /* Only query uniforms in first pass. */ static struct state_tracker_uniform tracker_info[MAX_VARIABLES]; static unsigned cnt = 0; if (cg->active_idx == 1) cnt = state_tracker_get_uniform(cg->state_tracker, tracker_info, MAX_VARIABLES, frame_count); for (i = 0; i < cnt; i++) { CGparameter param_v = cgGetNamedParameter( cg->prg[cg->active_idx].vprg, tracker_info[i].id); CGparameter param_f = cgGetNamedParameter( cg->prg[cg->active_idx].fprg, tracker_info[i].id); set_param_1f(param_v, tracker_info[i].value); set_param_1f(param_f, tracker_info[i].value); } } }