Пример #1
0
static void gl_cg_destroy_resources(void *data)
{
   cg_shader_data_t *cg_data = (cg_shader_data_t*)data;
   if (!cg_data)
      return;

   gl_cg_reset_attrib(data);

   gl_cg_deinit_progs(data);

   if (cg_data->shader && cg_data->shader->luts)
   {
      glDeleteTextures(cg_data->shader->luts, cg_data->lut_textures);
      memset(cg_data->lut_textures, 0, sizeof(cg_data->lut_textures));
   }

   if (cg_data->state_tracker)
   {
      state_tracker_free(cg_data->state_tracker);
      cg_data->state_tracker = NULL;
   }

   free(cg_data->shader);
   cg_data->shader = NULL;
}
Пример #2
0
static void cg_d3d9_renderchain_clear(cg_renderchain_t *chain)
{
   unsigned i;

   for (i = 0; i < TEXTURES; i++)
   {
      if (chain->prev.tex[i])
         d3d_texture_free(chain->prev.tex[i]);
      if (chain->prev.vertex_buf[i])
         d3d_vertex_buffer_free(chain->prev.vertex_buf[i], NULL);
   }

   cg_d3d9_renderchain_clear_passes(chain);

   for (i = 0; i < chain->luts.size(); i++)
   {
      if (chain->luts[i].tex)
         d3d_texture_free(chain->luts[i].tex);
   }

#if 0
   if (chain->tracker)
      state_tracker_free(chain->tracker);
   chain->tracker = NULL;
#endif
   chain->luts.clear();
}
Пример #3
0
static void d3d9_cg_destroy_resources(void *data)
{
   unsigned i;
   cg_renderchain_t *cg_data = (cg_renderchain_t*)data;

   for (i = 0; i < TEXTURES; i++)
   {
      if (cg_data->prev.tex[i])
         d3d_texture_free(cg_data->prev.tex[i]);
      if (cg_data->prev.vertex_buf[i])
         d3d_vertex_buffer_free(cg_data->prev.vertex_buf[i], NULL);
   }

   d3d9_cg_deinit_progs(cg_data);

   for (i = 0; i < cg_data->luts.size(); i++)
   {
      if (cg_data->luts[i].tex)
         d3d_texture_free(cg_data->luts[i].tex);
   }

   cg_data->luts.clear();

   if (cg_data->state_tracker)
   {
      state_tracker_free(cg_data->state_tracker);
      cg_data->state_tracker = NULL;
   }

   cgD3D9UnloadAllPrograms();
   cgD3D9SetDevice(NULL);
}
Пример #4
0
void renderchain_add_state_tracker(void *data, state_tracker_t *tracker)
{
   renderchain_t *chain = (renderchain_t*)data;
   if (chain->tracker)
      state_tracker_free(chain->tracker);
   chain->tracker = tracker;
}
Пример #5
0
static void gl_glsl_deinit(void)
{
   if (glsl_enable)
   {
      pglUseProgram(0);
      for (unsigned i = 0; i < GFX_MAX_SHADERS; i++)
      {
         if (gl_program[i] == 0 || (i && gl_program[i] == gl_program[0]))
            continue;

         gl_glsl_delete_shader(gl_program[i]);
      }

      if (glsl_shader)
         glDeleteTextures(glsl_shader->luts, gl_teximage);
   }

   memset(gl_program, 0, sizeof(gl_program));
   glsl_enable  = false;
   active_index = 0;

   gl_glsl_free_shader();

   if (gl_state_tracker)
      state_tracker_free(gl_state_tracker);
   gl_state_tracker = NULL;

   gl_glsl_reset_attrib();
}
Пример #6
0
static void cg_d3d9_renderchain_add_state_tracker(
      void *data, void *tracker_data)
{
   state_tracker_t *tracker = (state_tracker_t*)tracker_data;
   cg_renderchain_t     *chain = (cg_renderchain_t*)data;
   if (chain->state_tracker)
      state_tracker_free(chain->state_tracker);
   chain->state_tracker = tracker;
}
Пример #7
0
void renderchain_free(void *data)
{
   renderchain_t *chain = (renderchain_t*)data;

   renderchain_clear(chain);
   renderchain_destroy_stock_shader(chain);
   if (chain->tracker)
      state_tracker_free(chain->tracker);
}
Пример #8
0
static void renderchain_free(void *data)
{
   d3d_video_t *chain = (d3d_video_t*)data;

   renderchain_clear(chain);
   //renderchain_destroy_stock_shader(chain);
#ifndef DONT_HAVE_STATE_TRACKER
   if (chain->tracker)
      state_tracker_free(chain->tracker);
#endif
}
Пример #9
0
RenderChain::~RenderChain()
{
   clear();
#ifdef HAVE_CG
   if (fStock)
      cgDestroyProgram(fStock);
   if (vStock)
      cgDestroyProgram(vStock);
#endif
   if (tracker)
      state_tracker_free(tracker);
}
Пример #10
0
void gl_glsl_deinit(void)
{
   if (glsl_enable)
   {
      pglUseProgram(0);
      for (unsigned i = 0; i <= gl_num_programs; i++)
      {
         if (gl_program[i] == 0 || (i && gl_program[i] == gl_program[0]))
            continue;

         GLsizei count;
         GLuint shaders[2];

         pglGetAttachedShaders(gl_program[i], 2, &count, shaders);
         for (GLsizei j = 0; j < count; j++)
         {
            pglDetachShader(gl_program[i], shaders[j]);
            pglDeleteShader(shaders[j]);
         }

         pglDeleteProgram(gl_program[i]);
      }

      glDeleteTextures(gl_teximage_cnt, gl_teximage);
      gl_teximage_cnt = 0;
      memset(gl_teximage_uniforms, 0, sizeof(gl_teximage_uniforms));
   }

   memset(gl_program, 0, sizeof(gl_program));
   glsl_enable  = false;
   active_index = 0;

   gl_tracker_info_cnt = 0;
   memset(gl_tracker_info, 0, sizeof(gl_tracker_info));
   memset(gl_tracker_script, 0, sizeof(gl_tracker_script));
   memset(gl_tracker_script_class, 0, sizeof(gl_tracker_script_class));

   if (gl_script_program)
   {
      free(gl_script_program);
      gl_script_program = NULL;
   }

   if (gl_state_tracker)
   {
      state_tracker_free(gl_state_tracker);
      gl_state_tracker = NULL;
   }

   gl_glsl_reset_attrib();
}
Пример #11
0
static void xdk_renderchain_free(void *data)
{
   d3d_video_t *chain = (d3d_video_t*)data;

   if (!chain)
      return;

   xdk_renderchain_deinit_shader(chain);
   xdk_renderchain_deinit(chain->renderchain_data);
   xdk_renderchain_clear(chain->renderchain_data);

#ifndef _XBOX
   if (chain->tracker)
      state_tracker_free(chain->tracker);
#endif
}
Пример #12
0
static void gl_glsl_destroy_resources(glsl_shader_data_t *glsl)
{
   unsigned i;

   if (!glsl)
      return;

   current_idx = 0;
   glUseProgram(0);
   for (i = 0; i < GFX_MAX_SHADERS; i++)
   {
      if (glsl->prg[i].id == 0 || (i && glsl->prg[i].id == glsl->prg[0].id))
         continue;
      if (!glIsProgram(glsl->prg[i].id))
         continue;

      glDeleteProgram(glsl->prg[i].id);
   }

   if (glsl->shader && glsl->shader->luts)
      glDeleteTextures(glsl->shader->luts, glsl->lut_textures);

   memset(glsl->prg, 0, sizeof(glsl->prg));
   memset(glsl->uniforms, 0, sizeof(glsl->uniforms));
   glsl->active_idx = 0;

   gl_glsl_deinit_shader(glsl);

   if (glsl->state_tracker)
      state_tracker_free(glsl->state_tracker);
   glsl->state_tracker = NULL;

   gl_glsl_reset_attrib(glsl);

   for (i = 0; i < GFX_MAX_SHADERS; i++)
   {
      if (glsl->vbo[i].vbo_primary)
         glDeleteBuffers(1, &glsl->vbo[i].vbo_primary);
      if (glsl->vbo[i].vbo_secondary)
         glDeleteBuffers(1, &glsl->vbo[i].vbo_secondary);

      free(glsl->vbo[i].buffer_primary);
      free(glsl->vbo[i].buffer_secondary);
   }
   memset(&glsl->vbo, 0, sizeof(glsl->vbo));
}
Пример #13
0
static void gl_glsl_destroy_resources(glsl_shader_data_t *glsl)
{
    unsigned i;

    if (!glsl)
        return;

    glUseProgram(0);
    for (i = 0; i < GFX_MAX_SHADERS; i++)
    {
        if (glsl->gl_program[i] == 0 || (i && glsl->gl_program[i] == glsl->gl_program[0]))
            continue;

        glDeleteProgram(glsl->gl_program[i]);
    }

    if (glsl->shader && glsl->shader->luts)
        glDeleteTextures(glsl->shader->luts, glsl->gl_teximage);

    memset(glsl->gl_program, 0, sizeof(glsl->gl_program));
    memset(glsl->gl_uniforms, 0, sizeof(glsl->gl_uniforms));
    glsl->glsl_active_index = 0;

    gl_glsl_deinit_shader(glsl);

    if (glsl->gl_state_tracker)
        state_tracker_free(glsl->gl_state_tracker);
    glsl->gl_state_tracker = NULL;

    gl_glsl_reset_attrib(glsl);

    for (i = 0; i < GFX_MAX_SHADERS; i++)
    {
        if (glsl->glsl_vbo[i].vbo_primary)
            glDeleteBuffers(1, &glsl->glsl_vbo[i].vbo_primary);
        if (glsl->glsl_vbo[i].vbo_secondary)
            glDeleteBuffers(1, &glsl->glsl_vbo[i].vbo_secondary);

        free(glsl->glsl_vbo[i].buffer_primary);
        free(glsl->glsl_vbo[i].buffer_secondary);
    }
    memset(&glsl->glsl_vbo, 0, sizeof(glsl->glsl_vbo));
}
Пример #14
0
static void gl_cg_deinit_state(void)
{
   gl_cg_reset_attrib();
   cg_active = false;

   gl_cg_deinit_progs();

   if (cg_shader && cg_shader->luts)
   {
      glDeleteTextures(cg_shader->luts, lut_textures);
      memset(lut_textures, 0, sizeof(lut_textures));
   }

   if (state_tracker)
   {
      state_tracker_free(state_tracker);
      state_tracker = NULL;
   }

   free(cg_shader);
   cg_shader = NULL;
}
Пример #15
0
void gl_glsl_deinit(void)
{
   if (glsl_enable)
   {
      pglUseProgram(0);
      for (unsigned i = 0; i <= gl_num_programs; i++)
      {
         if (gl_program[i] == 0 || (i && gl_program[i] == gl_program[0]))
            continue;

         gl_glsl_delete_shader(gl_program[i]);
      }

      glDeleteTextures(gl_teximage_cnt, gl_teximage);
      gl_teximage_cnt = 0;
      memset(gl_teximage_uniforms, 0, sizeof(gl_teximage_uniforms));
   }

   memset(gl_program, 0, sizeof(gl_program));
   glsl_enable  = false;
   active_index = 0;

   gl_tracker_info_cnt = 0;
   memset(gl_tracker_info, 0, sizeof(gl_tracker_info));
   memset(gl_tracker_script_class, 0, sizeof(gl_tracker_script_class));

   free(gl_script_program);
   gl_script_program = NULL;

   if (gl_state_tracker)
   {
      state_tracker_free(gl_state_tracker);
      gl_state_tracker = NULL;
   }

   gl_glsl_reset_attrib();
}
Пример #16
0
static void gl_glsl_deinit(void)
{
   unsigned i;
   glUseProgram(0);
   for (i = 0; i < GFX_MAX_SHADERS; i++)
   {
      if (gl_program[i] == 0 || (i && gl_program[i] == gl_program[0]))
         continue;

      glDeleteProgram(gl_program[i]);
   }

   if (glsl_shader && glsl_shader->luts)
      glDeleteTextures(glsl_shader->luts, gl_teximage);

   memset(gl_program, 0, sizeof(gl_program));
   memset(gl_uniforms, 0, sizeof(gl_uniforms));
   glsl_enable  = false;
   active_index = 0;

   gl_glsl_free_shader();

   if (gl_state_tracker)
      state_tracker_free(gl_state_tracker);
   gl_state_tracker = NULL;

   gl_glsl_reset_attrib();

   for (i = 0; i < GFX_MAX_SHADERS; i++)
   {
      if (glsl_vbo[i].vbo_primary)
         glDeleteBuffers(1, &glsl_vbo[i].vbo_primary);
      if (glsl_vbo[i].vbo_secondary)
         glDeleteBuffers(1, &glsl_vbo[i].vbo_secondary);
   }
   memset(&glsl_vbo, 0, sizeof(glsl_vbo));
}
Пример #17
0
void RenderChain::add_state_tracker(state_tracker_t *tracker)
{
   if (this->tracker)
      state_tracker_free(this->tracker);
   this->tracker = tracker;
}