コード例 #1
0
ファイル: shader_gl_cg.c プロジェクト: XavierMoon/RetroArch
static void gl_cg_set_texture_info(void *data, 
      const struct cg_fbo_params *params, const struct gfx_tex_info *info)
{
   cg_shader_data_t *cg_data = (cg_shader_data_t*)data;
   CGparameter param = params->tex;
   if (param)
   {
      cgGLSetTextureParameter(param, info->tex);
      cgGLEnableTextureParameter(param);
   }

   set_param_2f(params->vid_size_v,
         info->input_size[0], info->input_size[1]);
   set_param_2f(params->vid_size_f,
         info->input_size[0], info->input_size[1]);
   set_param_2f(params->tex_size_v,
         info->tex_size[0],   info->tex_size[1]);
   set_param_2f(params->tex_size_f,
         info->tex_size[0],   info->tex_size[1]);

   if (params->coord)
   {
      cgGLSetParameterPointer(params->coord, 2,
            GL_FLOAT, 0, info->coord);
      cgGLEnableClientState(params->coord);
      cg_data->cg_attribs[cg_data->cg_attrib_idx++] = params->coord;
   }
}
コード例 #2
0
static void gl_cg_set_texture_info(
      cg_shader_data_t *cg, 
      const struct cg_fbo_params *params,
      const struct video_tex_info *info)
{
   CGparameter param                     = params->tex;

   cg_gl_set_texture_parameter(param, info->tex);

   set_param_2f(params->vid_size_v,
         info->input_size[0], info->input_size[1]);
   set_param_2f(params->vid_size_f,
         info->input_size[0], info->input_size[1]);
   set_param_2f(params->tex_size_v,
         info->tex_size[0],   info->tex_size[1]);
   set_param_2f(params->tex_size_f,
         info->tex_size[0],   info->tex_size[1]);

   if (params->coord)
      gl_cg_set_coord_array(params->coord, cg, info->coord, 2);
}
コード例 #3
0
ファイル: shader_hlsl.c プロジェクト: AbelFlos/RetroArch
static void hlsl_set_params(unsigned width, unsigned height,
      unsigned tex_width, unsigned tex_height,
      unsigned out_width, unsigned out_height,
      unsigned frame_counter,
      const struct gl_tex_info *info,
      const struct gl_tex_info *prev_info,
      const struct gl_tex_info *fbo_info, unsigned fbo_info_cnt)
{
   if (!hlsl_active)
      return;

   const float ori_size[2] = { (float)width,     (float)height     };
   const float tex_size[2] = { (float)tex_width, (float)tex_height };
   const float out_size[2] = { (float)out_width, (float)out_height };
   float frame_cnt = frame_counter;

   prg[active_index].f_ctable->SetDefaults(d3d_device_ptr);
   prg[active_index].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_index].tex_size_f, tex_size, prg[active_index].f_ctable);
   set_param_2f(prg[active_index].out_size_f, out_size, prg[active_index].f_ctable);
   set_param_1f(prg[active_index].frame_cnt_f, frame_cnt, prg[active_index].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_2f(prg[active_index].vid_size_v, ori_size, prg[active_index].v_ctable);
   set_param_2f(prg[active_index].tex_size_v, tex_size, prg[active_index].v_ctable);
   set_param_2f(prg[active_index].out_size_v, out_size, prg[active_index].v_ctable);
   set_param_1f(prg[active_index].frame_cnt_v, frame_cnt, prg[active_index].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);


   /* TODO - set lookup textures/FBO textures/state parameters/etc */
}
コード例 #4
0
ファイル: shader_hlsl.c プロジェクト: magicseb/RetroArch
void hlsl_set_params(unsigned width, unsigned height,
      unsigned tex_width, unsigned tex_height,
      unsigned out_width, unsigned out_height,
      unsigned frame_count)
{
   if (!hlsl_active)
      return;

   const float ori_size[2] = { (float)width,     (float)height     };
   const float tex_size[2] = { (float)tex_width, (float)tex_height };
   const float out_size[2] = { (float)out_width, (float)out_height };
   float frame_cnt = frame_count;

   prg[active_index].f_ctable->SetDefaults(d3d_device_ptr);
   prg[active_index].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_index].tex_size_f, tex_size, prg[active_index].f_ctable);
   set_param_2f(prg[active_index].out_size_f, out_size, prg[active_index].f_ctable);
   set_param_1f(prg[active_index].frame_cnt_f, frame_cnt, prg[active_index].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_2f(prg[active_index].vid_size_v, ori_size, prg[active_index].v_ctable);
   set_param_2f(prg[active_index].tex_size_v, tex_size, prg[active_index].v_ctable);
   set_param_2f(prg[active_index].out_size_v, out_size, prg[active_index].v_ctable);
   set_param_1f(prg[active_index].frame_cnt_v, frame_cnt, prg[active_index].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);

   /* TODO: Move to D3DXMATRIX here */
   prg[active_index].v_ctable->SetMatrix(d3d_device_ptr, prg[active_index].mvp, (D3DXMATRIX*)&prg[active_index].mvp_val);
}
コード例 #5
0
ファイル: shader_hlsl.c プロジェクト: 6lackmag3/RetroArch
static void hlsl_set_params(void *data, unsigned width, unsigned height,
      unsigned tex_width, unsigned tex_height,
      unsigned out_width, unsigned out_height,
      unsigned frame_counter,
      const void *_info,
      const void *_prev_info,
      const void *_feedback_info,
      const void *_fbo_info, unsigned fbo_info_cnt)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   LPDIRECT3DDEVICE d3d_device_ptr = (LPDIRECT3DDEVICE)d3d->dev;
   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;
   (void)_feedback_info;
   const struct gfx_tex_info *fbo_info = (const struct gfx_tex_info*)_fbo_info;
   driver_t *driver = driver_get_ptr();
   global_t *global = global_get_ptr();
   hlsl_shader_data_t *hlsl = (hlsl_shader_data_t*)driver->video_shader_data;

   if (!hlsl)
      return;

   const float ori_size[2] = { (float)width,     (float)height     };
   const float tex_size[2] = { (float)tex_width, (float)tex_height };
   const float out_size[2] = { (float)out_width, (float)out_height };
   float frame_cnt = frame_counter;

   hlsl->prg[hlsl->active_idx].f_ctable->SetDefaults(d3d_device_ptr);
   hlsl->prg[hlsl->active_idx].v_ctable->SetDefaults(d3d_device_ptr);

   set_param_2f(hlsl->prg[hlsl->active_idx].vid_size_f, ori_size, hlsl->prg[hlsl->active_idx].f_ctable);
   set_param_2f(hlsl->prg[hlsl->active_idx].tex_size_f, tex_size, hlsl->prg[hlsl->active_idx].f_ctable);
   set_param_2f(hlsl->prg[hlsl->active_idx].out_size_f, out_size, hlsl->prg[hlsl->active_idx].f_ctable);
   set_param_1f(hlsl->prg[hlsl->active_idx].frame_cnt_f, frame_cnt, hlsl->prg[hlsl->active_idx].f_ctable);
   set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_f, global->rewind.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].f_ctable);

   set_param_2f(hlsl->prg[hlsl->active_idx].vid_size_v, ori_size, hlsl->prg[hlsl->active_idx].v_ctable);
   set_param_2f(hlsl->prg[hlsl->active_idx].tex_size_v, tex_size, hlsl->prg[hlsl->active_idx].v_ctable);
   set_param_2f(hlsl->prg[hlsl->active_idx].out_size_v, out_size, hlsl->prg[hlsl->active_idx].v_ctable);
   set_param_1f(hlsl->prg[hlsl->active_idx].frame_cnt_v, frame_cnt, hlsl->prg[hlsl->active_idx].v_ctable);
   set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_v, global->rewind.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].v_ctable);

   /* TODO - set lookup textures/FBO textures/state parameters/etc */
}
コード例 #6
0
ファイル: shader_gl_cg.c プロジェクト: XavierMoon/RetroArch
static void gl_cg_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;
   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;
   cg_shader_data_t *cg_data = (cg_shader_data_t*)shader_data;

   if (!cg_data || (cg_data->active_idx == 0) ||
         (cg_data->active_idx == GL_SHADER_STOCK_BLEND))
      return;

   /* Set frame. */
   set_param_2f(cg_data->prg[cg_data->active_idx].vid_size_f, width, height);
   set_param_2f(cg_data->prg[cg_data->active_idx].tex_size_f, tex_width, tex_height);
   set_param_2f(cg_data->prg[cg_data->active_idx].out_size_f, out_width, out_height);
   cg_gl_set_param_1f(cg_data->prg[cg_data->active_idx].frame_dir_f,
         state_manager_frame_is_reversed() ? -1.0 : 1.0);

   set_param_2f(cg_data->prg[cg_data->active_idx].vid_size_v, width, height);
   set_param_2f(cg_data->prg[cg_data->active_idx].tex_size_v, tex_width, tex_height);
   set_param_2f(cg_data->prg[cg_data->active_idx].out_size_v, out_width, out_height);
   cg_gl_set_param_1f(cg_data->prg[cg_data->active_idx].frame_dir_v,
         state_manager_frame_is_reversed() ? -1.0 : 1.0);

   if (cg_data->prg[cg_data->active_idx].frame_cnt_f || cg_data->prg[cg_data->active_idx].frame_cnt_v)
   {
      unsigned modulo = cg_data->shader->pass[cg_data->active_idx - 1].frame_count_mod;
      if (modulo)
         frame_count %= modulo;

      cg_gl_set_param_1f(cg_data->prg[cg_data->active_idx].frame_cnt_f, (float)frame_count);
      cg_gl_set_param_1f(cg_data->prg[cg_data->active_idx].frame_cnt_v, (float)frame_count);
   }

   /* Set orig texture. */
   gl_cg_set_texture_info(cg_data, &cg_data->prg[cg_data->active_idx].orig, info);

   /* Set feedback texture. */
   gl_cg_set_texture_info(cg_data, &cg_data->prg[cg_data->active_idx].feedback, feedback_info);

   /* Set prev textures. */
   for (i = 0; i < PREV_TEXTURES; i++)
      gl_cg_set_texture_info(cg_data, &cg_data->prg[cg_data->active_idx].prev[i], &prev_info[i]);

   /* Set lookup textures. */
   for (i = 0; i < cg_data->shader->luts; i++)
   {
      CGparameter vparam;
      CGparameter fparam = cgGetNamedParameter(
            cg_data->prg[cg_data->active_idx].fprg, cg_data->shader->lut[i].id);

      if (fparam)
      {
         cgGLSetTextureParameter(fparam, cg_data->lut_textures[i]);
         cgGLEnableTextureParameter(fparam);
      }

      vparam = cgGetNamedParameter(cg_data->prg[cg_data->active_idx].vprg,
		  cg_data->shader->lut[i].id);

      if (vparam)
      {
         cgGLSetTextureParameter(vparam, cg_data->lut_textures[i]);
         cgGLEnableTextureParameter(vparam);
      }
   }

   /* Set FBO textures. */
   if (cg_data->active_idx)
   {
      for (i = 0; i < fbo_info_cnt; i++)
         gl_cg_set_texture_info(cg_data, &cg_data->prg[cg_data->active_idx].fbo[i], &fbo_info[i]);
   }

   /* #pragma parameters. */
   for (i = 0; i < cg_data->shader->num_parameters; i++)
   {
      CGparameter param_v = cgGetNamedParameter(
            cg_data->prg[cg_data->active_idx].vprg, cg_data->shader->parameters[i].id);
      CGparameter param_f = cgGetNamedParameter(
            cg_data->prg[cg_data->active_idx].fprg, cg_data->shader->parameters[i].id);
      cg_gl_set_param_1f(param_v, cg_data->shader->parameters[i].current);
      cg_gl_set_param_1f(param_f, cg_data->shader->parameters[i].current);
   }

   /* Set state parameters. */
   if (cg_data->state_tracker)
   {
      /* Only query uniforms in first pass. */
      static struct state_tracker_uniform tracker_info[GFX_MAX_VARIABLES];
      static unsigned cnt = 0;

      if (cg_data->active_idx == 1)
         cnt = state_tracker_get_uniform(cg_data->state_tracker, tracker_info,
               GFX_MAX_VARIABLES, frame_count);

      for (i = 0; i < cnt; i++)
      {
         CGparameter param_v = cgGetNamedParameter(
               cg_data->prg[cg_data->active_idx].vprg, tracker_info[i].id);
         CGparameter param_f = cgGetNamedParameter(
               cg_data->prg[cg_data->active_idx].fprg, tracker_info[i].id);
         cg_gl_set_param_1f(param_v, tracker_info[i].value);
         cg_gl_set_param_1f(param_f, tracker_info[i].value);
      }
   }
}
コード例 #7
0
ファイル: shader_cg.c プロジェクト: AreaScout/retro
static void gl_cg_set_params(unsigned width, unsigned height, 
      unsigned tex_width, unsigned tex_height,
      unsigned out_width, unsigned out_height,
      unsigned frame_count,
      const struct gl_tex_info *info,
      const struct gl_tex_info *prev_info,
      const struct gl_tex_info *fbo_info,
      unsigned fbo_info_cnt)
{
   unsigned i;
   if (!cg_active || (active_index == 0) || (active_index == GL_SHADER_STOCK_BLEND))
      return;

   // Set frame.
   set_param_2f(prg[active_index].vid_size_f, width, height);
   set_param_2f(prg[active_index].tex_size_f, tex_width, tex_height);
   set_param_2f(prg[active_index].out_size_f, out_width, out_height);
   set_param_1f(prg[active_index].frame_dir_f, 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_index].tex_size_v, tex_width, tex_height);
   set_param_2f(prg[active_index].out_size_v, out_width, out_height);
   set_param_1f(prg[active_index].frame_dir_v, g_extern.frame_is_reverse ? -1.0 : 1.0);

   if (prg[active_index].frame_cnt_f || prg[active_index].frame_cnt_v)
   {
      unsigned modulo = cg_shader->pass[active_index - 1].frame_count_mod;
      if (modulo)
         frame_count %= modulo;

      set_param_1f(prg[active_index].frame_cnt_f, (float)frame_count);
      set_param_1f(prg[active_index].frame_cnt_v, (float)frame_count);
   }

   // Set orig texture.
   CGparameter param = prg[active_index].orig.tex;
   if (param)
   {
      cgGLSetTextureParameter(param, info->tex);
      cgGLEnableTextureParameter(param);
   }

   set_param_2f(prg[active_index].orig.vid_size_v, info->input_size[0], info->input_size[1]);
   set_param_2f(prg[active_index].orig.vid_size_f, info->input_size[0], info->input_size[1]);
   set_param_2f(prg[active_index].orig.tex_size_v, info->tex_size[0],   info->tex_size[1]);
   set_param_2f(prg[active_index].orig.tex_size_f, info->tex_size[0],   info->tex_size[1]);
   if (prg[active_index].orig.coord)
   {
      cgGLSetParameterPointer(prg[active_index].orig.coord, 2, GL_FLOAT, 0, info->coord);
      cgGLEnableClientState(prg[active_index].orig.coord);
      cg_attribs[cg_attrib_index++] = prg[active_index].orig.coord;
   }

   // Set prev textures.
   for (i = 0; i < PREV_TEXTURES; i++)
   {
      param = prg[active_index].prev[i].tex;
      if (param)
      {
         cgGLSetTextureParameter(param, prev_info[i].tex);
         cgGLEnableTextureParameter(param);
      }

      set_param_2f(prg[active_index].prev[i].vid_size_v, prev_info[i].input_size[0], prev_info[i].input_size[1]);
      set_param_2f(prg[active_index].prev[i].vid_size_f, prev_info[i].input_size[0], prev_info[i].input_size[1]);
      set_param_2f(prg[active_index].prev[i].tex_size_v, prev_info[i].tex_size[0],   prev_info[i].tex_size[1]);
      set_param_2f(prg[active_index].prev[i].tex_size_f, prev_info[i].tex_size[0],   prev_info[i].tex_size[1]);

      if (prg[active_index].prev[i].coord)
      {
         cgGLSetParameterPointer(prg[active_index].prev[i].coord, 2, GL_FLOAT, 0, prev_info[i].coord);
         cgGLEnableClientState(prg[active_index].prev[i].coord);
         cg_attribs[cg_attrib_index++] = prg[active_index].prev[i].coord;
      }
   }

   // Set lookup textures.
   for (i = 0; i < cg_shader->luts; i++)
   {
      CGparameter fparam = cgGetNamedParameter(prg[active_index].fprg, cg_shader->lut[i].id);
      if (fparam)
      {
         cgGLSetTextureParameter(fparam, lut_textures[i]);
         cgGLEnableTextureParameter(fparam);
      }

      CGparameter vparam = cgGetNamedParameter(prg[active_index].vprg, cg_shader->lut[i].id);
      if (vparam)
      {
         cgGLSetTextureParameter(vparam, lut_textures[i]);
         cgGLEnableTextureParameter(vparam);
      }
   }

   // Set FBO textures.
   if (active_index > 2)
   {
      for (i = 0; i < fbo_info_cnt; i++)
      {
         if (prg[active_index].fbo[i].tex)
         {
            cgGLSetTextureParameter(prg[active_index].fbo[i].tex, fbo_info[i].tex);
            cgGLEnableTextureParameter(prg[active_index].fbo[i].tex);
         }

         set_param_2f(prg[active_index].fbo[i].vid_size_v, fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
         set_param_2f(prg[active_index].fbo[i].vid_size_f, fbo_info[i].input_size[0], fbo_info[i].input_size[1]);

         set_param_2f(prg[active_index].fbo[i].tex_size_v, fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
         set_param_2f(prg[active_index].fbo[i].tex_size_f, fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);

         if (prg[active_index].fbo[i].coord)
         {
            cgGLSetParameterPointer(prg[active_index].fbo[i].coord, 2, GL_FLOAT, 0, fbo_info[i].coord);
            cgGLEnableClientState(prg[active_index].fbo[i].coord);
            cg_attribs[cg_attrib_index++] = prg[active_index].fbo[i].coord;
         }
      }
   }

   // Set state parameters
   if (state_tracker)
   {
      // Only query uniforms in first pass.
      static struct state_tracker_uniform info[MAX_VARIABLES];
      static unsigned cnt = 0;

      if (active_index == 1)
         cnt = state_get_uniform(state_tracker, info, MAX_VARIABLES, frame_count);

      for (i = 0; i < cnt; i++)
      {
         CGparameter param_v = cgGetNamedParameter(prg[active_index].vprg, info[i].id);
         CGparameter param_f = cgGetNamedParameter(prg[active_index].fprg, info[i].id);
         set_param_1f(param_v, info[i].value);
         set_param_1f(param_f, info[i].value);
      }
   }
}
コード例 #8
0
ファイル: shader_gl_cg.c プロジェクト: Markko/RetroArch
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 *_fbo_info,
      unsigned fbo_info_cnt)
{
   unsigned i;
   const struct gl_tex_info *info = (const struct gl_tex_info*)_info;
   const struct gl_tex_info *prev_info = (const struct gl_tex_info*)_prev_info;
   const struct gl_tex_info *fbo_info = (const struct gl_tex_info*)_fbo_info;
   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,
         g_extern.frame_is_reverse ? -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,
         g_extern.frame_is_reverse ? -1.0 : 1.0);

   if (cg->prg[cg->active_idx].frame_cnt_f || cg->prg[cg->active_idx].frame_cnt_v)
   {
      unsigned modulo = cg->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. */
   CGparameter param = cg->prg[cg->active_idx].orig.tex;
   if (param)
   {
      cgGLSetTextureParameter(param, info->tex);
      cgGLEnableTextureParameter(param);
   }

   set_param_2f(cg->prg[cg->active_idx].orig.vid_size_v,
         info->input_size[0], info->input_size[1]);
   set_param_2f(cg->prg[cg->active_idx].orig.vid_size_f,
         info->input_size[0], info->input_size[1]);
   set_param_2f(cg->prg[cg->active_idx].orig.tex_size_v,
         info->tex_size[0],   info->tex_size[1]);
   set_param_2f(cg->prg[cg->active_idx].orig.tex_size_f,
         info->tex_size[0],   info->tex_size[1]);

   if (cg->prg[cg->active_idx].orig.coord)
   {
      cgGLSetParameterPointer(cg->prg[cg->active_idx].orig.coord, 2,
            GL_FLOAT, 0, info->coord);
      cgGLEnableClientState(cg->prg[cg->active_idx].orig.coord);
      cg->cg_attribs[cg->cg_attrib_idx++] = cg->prg[cg->active_idx].orig.coord;
   }

   /* Set prev textures. */
   for (i = 0; i < PREV_TEXTURES; i++)
   {
      param = cg->prg[cg->active_idx].prev[i].tex;
      if (param)
      {
         cgGLSetTextureParameter(param, prev_info[i].tex);
         cgGLEnableTextureParameter(param);
      }

      set_param_2f(cg->prg[cg->active_idx].prev[i].vid_size_v,
            prev_info[i].input_size[0], prev_info[i].input_size[1]);
      set_param_2f(cg->prg[cg->active_idx].prev[i].vid_size_f,
            prev_info[i].input_size[0], prev_info[i].input_size[1]);
      set_param_2f(cg->prg[cg->active_idx].prev[i].tex_size_v,
            prev_info[i].tex_size[0],   prev_info[i].tex_size[1]);
      set_param_2f(cg->prg[cg->active_idx].prev[i].tex_size_f,
            prev_info[i].tex_size[0],   prev_info[i].tex_size[1]);

      if (cg->prg[cg->active_idx].prev[i].coord)
      {
         cgGLSetParameterPointer(cg->prg[cg->active_idx].prev[i].coord, 
               2, GL_FLOAT, 0, prev_info[i].coord);
         cgGLEnableClientState(cg->prg[cg->active_idx].prev[i].coord);
         cg->cg_attribs[cg->cg_attrib_idx++] = cg->prg[cg->active_idx].prev[i].coord;
      }
   }

   /* Set lookup textures. */
   for (i = 0; i < cg->cg_shader->luts; i++)
   {
      CGparameter fparam = cgGetNamedParameter(
            cg->prg[cg->active_idx].fprg, cg->cg_shader->lut[i].id);

      if (fparam)
      {
         cgGLSetTextureParameter(fparam, cg->lut_textures[i]);
         cgGLEnableTextureParameter(fparam);
      }

      CGparameter vparam = cgGetNamedParameter(
            cg->prg[cg->active_idx].vprg, cg->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++)
      {
         if (cg->prg[cg->active_idx].fbo[i].tex)
         {
            cgGLSetTextureParameter(
                  cg->prg[cg->active_idx].fbo[i].tex, fbo_info[i].tex);
            cgGLEnableTextureParameter(cg->prg[cg->active_idx].fbo[i].tex);
         }

         set_param_2f(cg->prg[cg->active_idx].fbo[i].vid_size_v,
               fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
         set_param_2f(cg->prg[cg->active_idx].fbo[i].vid_size_f,
               fbo_info[i].input_size[0], fbo_info[i].input_size[1]);

         set_param_2f(cg->prg[cg->active_idx].fbo[i].tex_size_v,
               fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
         set_param_2f(cg->prg[cg->active_idx].fbo[i].tex_size_f,
               fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);

         if (cg->prg[cg->active_idx].fbo[i].coord)
         {
            cgGLSetParameterPointer(cg->prg[cg->active_idx].fbo[i].coord,
                  2, GL_FLOAT, 0, fbo_info[i].coord);
            cgGLEnableClientState(cg->prg[cg->active_idx].fbo[i].coord);
            cg->cg_attribs[cg->cg_attrib_idx++] = cg->prg[cg->active_idx].fbo[i].coord;
         }
      }
   }

   /* #pragma parameters. */
   for (i = 0; i < cg->cg_shader->num_parameters; i++)
   {
      CGparameter param_v = cgGetNamedParameter(
            cg->prg[cg->active_idx].vprg, cg->cg_shader->parameters[i].id);
      CGparameter param_f = cgGetNamedParameter(
            cg->prg[cg->active_idx].fprg, cg->cg_shader->parameters[i].id);
      set_param_1f(param_v, cg->cg_shader->parameters[i].current);
      set_param_1f(param_f, cg->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_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);
      }
   }
}