コード例 #1
0
ファイル: shader_hlsl.c プロジェクト: arakerlu/RetroArch
static bool hlsl_load_preset(hlsl_shader_data_t *hlsl, void *data, const char *path)
{
   unsigned i;
   config_file_t *conf = NULL;
   if (!hlsl_load_stock(hlsl, data))
      return false;

   RARCH_LOG("Loading Cg meta-shader: %s\n", path);

   conf = config_file_new(path);

   if (!conf)
      goto error;

   if (!hlsl->cg_shader)
      hlsl->cg_shader = (struct video_shader*)calloc(1, sizeof(*hlsl->cg_shader));
   if (!hlsl->cg_shader)
      goto error;

   if (!video_shader_read_conf_cgp(conf, hlsl->cg_shader))
   {
      RARCH_ERR("Failed to parse CGP file.\n");
      goto error;
   }

   config_file_free(conf);

   if (hlsl->cg_shader->passes > RARCH_HLSL_MAX_SHADERS - 3)
   {
      RARCH_WARN("Too many shaders ... Capping shader amount to %d.\n", RARCH_HLSL_MAX_SHADERS - 3);
      hlsl->cg_shader->passes = RARCH_HLSL_MAX_SHADERS - 3;
   }

   for (i = 0; i < hlsl->cg_shader->passes; i++)
   {
      if (!hlsl_load_shader(hlsl, data, path, i))
         goto error;
   }

   /* TODO - textures / imports */
   return true;

error:
   RARCH_ERR("Failed to load preset.\n");
   if (conf)
      config_file_free(conf);
   conf = NULL;

   return false;
}
コード例 #2
0
void rarch_load_shader(unsigned slot, const char *path)
{
#if defined(HAVE_HLSL)
   hlsl_load_shader(slot, path);
#elif defined(HAVE_CG) && defined(HAVE_OPENGL)
   gl_cg_load_shader(slot, path);
#else
RARCH_WARN("Shader support is not implemented for this build.\n");
#endif

#if defined(HAVE_HLSL) || defined(HAVE_CG)
   if (g_console.info_msg_enable)
      rarch_settings_msg(S_MSG_SHADER_LOADING_SUCCEEDED, S_DELAY_180);
#endif
}