summaryrefslogtreecommitdiff
path: root/drivers/gles3/shader_gles3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles3/shader_gles3.cpp')
-rw-r--r--drivers/gles3/shader_gles3.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp
index 404a9107ab..fa7cc00230 100644
--- a/drivers/gles3/shader_gles3.cpp
+++ b/drivers/gles3/shader_gles3.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -133,15 +133,6 @@ bool ShaderGLES3::bind() {
active = this;
uniforms_dirty = true;
- /*
- * why on earth is this code here?
- for (int i=0;i<texunit_pair_count;i++) {
-
- glUniform1i(texunit_pairs[i].location, texunit_pairs[i].index);
- DEBUG_TEST_ERROR("Uniform 1 i");
- }
-
-*/
return true;
}
@@ -559,6 +550,9 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() {
glUseProgram(0);
v.ok = true;
+ if (cc) {
+ cc->versions.insert(conditional_version.version);
+ }
return &v;
}
@@ -741,8 +735,26 @@ 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)
- conditional_version.code_version = 0; //bye
+ 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;
+ for (Set<uint32_t>::Element *E = custom_code_map[p_code_id].versions.front(); E; E = E->next()) {
+ key.version = E->get();
+ ERR_CONTINUE(!version_map.has(key));
+ Version &v = version_map[key];
+
+ glDeleteShader(v.vert_id);
+ glDeleteShader(v.frag_id);
+ glDeleteProgram(v.id);
+ memdelete_arr(v.uniform_location);
+ v.id = 0;
+
+ version_map.erase(key);
+ }
custom_code_map.erase(p_code_id);
}