Shaders: Try to clean up in case we reuse GLSLShader.

This commit is contained in:
Brandon Wright 2019-01-29 17:49:40 -06:00
parent a569fbeabc
commit f825f14a06
3 changed files with 15 additions and 4 deletions

View File

@ -96,6 +96,7 @@ bool GLSLShader::load_shader_preset_file(char *filename)
!strcasecmp(&filename[length - 6], ".slang")))
singlepass = true;
this->using_slang = false;
if (length > 7 && (!strcasecmp(&filename[length - 6], ".slang") ||
!strcasecmp(&filename[length - 7], ".slangp")))
{
@ -1157,6 +1158,15 @@ void GLSLShader::destroy()
glDeleteProgram(pass[i].program);
glDeleteTextures(1, &pass[i].texture);
glDeleteFramebuffers(1, &pass[i].fbo);
#ifdef USE_SLANG
if (using_slang)
{
if (pass[i].uses_feedback)
glDeleteTextures(1, &pass[i].feedback_texture);
if (pass[i].ubo_buffer.size() > 0)
glDeleteBuffers(1, &pass[i].ubo);
}
#endif
}
for (unsigned int i = 0; i < lut.size(); i++)
@ -1169,6 +1179,8 @@ void GLSLShader::destroy()
glDeleteTextures(1, &prev_frame[i].texture);
}
glDeleteBuffers(1, &vbo);
param.clear();
pass.clear();
lut.clear();

View File

@ -181,10 +181,8 @@ typedef struct
unsigned int frame_count;
GLuint vbo;
GLuint prev_fbo;
GLfloat *fa;
bool using_slang = false;
bool using_slang;
#ifdef USE_SLANG
std::string slang_get_stage(std::vector<std::string> &lines,
std::string name);
@ -194,7 +192,7 @@ typedef struct
void slang_set_shader_vars(int p, bool inverted);
void slang_clear_shader_vars();
bool using_feedback = false;
bool using_feedback;
#endif
} GLSLShader;

View File

@ -379,6 +379,7 @@ static inline bool isalldigits(std::string str)
void GLSLShader::slang_introspect()
{
max_prev_frame = 0;
using_feedback = false;
for (int i = 1; i < (int)pass.size(); i++)
{