summaryrefslogtreecommitdiffstats
path: root/drivers/gles3/shader_gles3.cpp
diff options
context:
space:
mode:
authorDani Frank <pdaniq@gmail.com>2023-03-25 12:46:33 +0300
committerChibiDenDen <pdaniq@gmail.com>2023-05-26 23:11:02 +0300
commit6d3634e29f32d1d481a2d71e3eb7cc0718bde0a9 (patch)
tree17f5e97868d509e274e819650748f7af71db41b0 /drivers/gles3/shader_gles3.cpp
parent2210111eb5e8bac6a476227c01205ac44745e21e (diff)
downloadredot-engine-6d3634e29f32d1d481a2d71e3eb7cc0718bde0a9.tar.gz
fix gles texture uniform array binding
Diffstat (limited to 'drivers/gles3/shader_gles3.cpp')
-rw-r--r--drivers/gles3/shader_gles3.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp
index abf13fe5ab..29e9ada72b 100644
--- a/drivers/gles3/shader_gles3.cpp
+++ b/drivers/gles3/shader_gles3.cpp
@@ -268,10 +268,17 @@ void ShaderGLES3::_get_uniform_locations(Version::Specialization &spec, Version
}
}
// textures
- for (int i = 0; i < p_version->texture_uniforms.size(); i++) {
- String native_uniform_name = _mkid(p_version->texture_uniforms[i]);
+ int texture_index = 0;
+ for (uint32_t i = 0; i < p_version->texture_uniforms.size(); i++) {
+ String native_uniform_name = _mkid(p_version->texture_uniforms[i].name);
GLint location = glGetUniformLocation(spec.id, (native_uniform_name).ascii().get_data());
- glUniform1i(location, i + base_texture_index);
+ Vector<int32_t> texture_uniform_bindings;
+ int texture_count = p_version->texture_uniforms[i].array_size;
+ for (int j = 0; j < texture_count; j++) {
+ texture_uniform_bindings.append(texture_index + base_texture_index);
+ texture_index++;
+ }
+ glUniform1iv(location, texture_uniform_bindings.size(), texture_uniform_bindings.ptr());
}
glUseProgram(0);
@@ -674,7 +681,7 @@ void ShaderGLES3::_initialize_version(Version *p_version) {
_save_to_cache(p_version);
}
-void ShaderGLES3::version_set_code(RID p_version, const HashMap<String, String> &p_code, const String &p_uniforms, const String &p_vertex_globals, const String &p_fragment_globals, const Vector<String> &p_custom_defines, const Vector<StringName> &p_texture_uniforms, bool p_initialize) {
+void ShaderGLES3::version_set_code(RID p_version, const HashMap<String, String> &p_code, const String &p_uniforms, const String &p_vertex_globals, const String &p_fragment_globals, const Vector<String> &p_custom_defines, const LocalVector<ShaderGLES3::TextureUniformData> &p_texture_uniforms, bool p_initialize) {
Version *version = version_owner.get_or_null(p_version);
ERR_FAIL_COND(!version);