diff options
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.cpp | 2 | ||||
-rw-r--r-- | drivers/gles2/shader_gles2.cpp | 11 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 2 | ||||
-rw-r--r-- | drivers/gles3/shader_gles3.cpp | 11 |
4 files changed, 8 insertions, 18 deletions
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index f0deff4791..38fcff3ab2 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -4631,7 +4631,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) { Shader *shader = shader_owner.get(p_rid); - if (shader->shader) { + if (shader->shader && shader->custom_code_id) { shader->shader->free_custom_shader(shader->custom_code_id); } diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp index 3bf5baec14..5e259a01f0 100644 --- a/drivers/gles2/shader_gles2.cpp +++ b/drivers/gles2/shader_gles2.cpp @@ -229,7 +229,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { glDeleteShader(v.vert_id); glDeleteShader(v.frag_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; } } @@ -329,7 +328,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { if (iloglen < 0) { glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; ERR_PRINT("No OpenGL vertex shader compiler log. What the frick?"); @@ -351,7 +349,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { Memory::free_static(ilogmem); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; } @@ -406,7 +403,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { glDeleteShader(v.frag_id); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; ERR_PRINT("No OpenGL fragment shader compiler log. What the frick?"); @@ -429,7 +425,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { glDeleteShader(v.frag_id); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; } @@ -457,7 +452,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { glDeleteShader(v.frag_id); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; ERR_PRINT("No OpenGL program link log. What the frick?"); @@ -482,7 +476,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { glDeleteShader(v.frag_id); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; ERR_FAIL_V(NULL); @@ -696,8 +689,10 @@ void ShaderGLES2::set_custom_shader(uint32_t p_code_id) { void ShaderGLES2::free_custom_shader(uint32_t p_code_id) { ERR_FAIL_COND(!custom_code_map.has(p_code_id)); - if (conditional_version.code_version == p_code_id) + if (conditional_version.code_version == p_code_id) { conditional_version.code_version = 0; //do not keep using a version that is going away + unbind(); + } VersionKey key; key.code_version = p_code_id; diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 8b3f1a1b77..70037dfc33 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -7486,7 +7486,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) { // delete the texture Shader *shader = shader_owner.get(p_rid); - if (shader->shader) + if (shader->shader && shader->custom_code_id) shader->shader->free_custom_shader(shader->custom_code_id); if (shader->dirty_list.in_list()) diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 64396cadd1..2db0223edd 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -204,7 +204,6 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { glDeleteShader(v.vert_id); glDeleteShader(v.frag_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; } } @@ -325,7 +324,6 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; ERR_PRINT("Vertex shader compilation failed with empty log"); @@ -347,7 +345,6 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { memfree(ilogmem); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; } @@ -421,7 +418,6 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { glDeleteShader(v.frag_id); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; ERR_PRINT("Fragment shader compilation failed with empty log"); } else { @@ -444,7 +440,6 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { glDeleteShader(v.frag_id); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; } @@ -491,7 +486,6 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { glDeleteShader(v.frag_id); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; ERR_FAIL_COND_V(iloglen <= 0, NULL); } @@ -514,7 +508,6 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { glDeleteShader(v.frag_id); glDeleteShader(v.vert_id); glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); v.id = 0; ERR_FAIL_V(NULL); @@ -751,8 +744,10 @@ void ShaderGLES3::set_custom_shader(uint32_t p_code_id) { void ShaderGLES3::free_custom_shader(uint32_t p_code_id) { ERR_FAIL_COND(!custom_code_map.has(p_code_id)); - if (conditional_version.code_version == p_code_id) + if (conditional_version.code_version == p_code_id) { conditional_version.code_version = 0; //do not keep using a version that is going away + unbind(); + } VersionKey key; key.code_version = p_code_id; |