diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 5fabeb94f5b..941b1a1b280 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -2742,8 +2742,7 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } - int uniform_max_size = config->max_uniform_buffer_size; - if (uniform_max_size < 65536) { + if (config->max_uniform_buffer_size < 65536) { data.max_lights_per_render = 64; } else { data.max_lights_per_render = 256; diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 993197e371c..60891b8b4e1 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -398,8 +398,7 @@ void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, Display // Viewport doesn't cover entire window so clear window to black before blitting. // Querying the actual window size from the DisplayServer would deadlock in separate render thread mode, // so let's set the biggest viewport the implementation supports, to be sure the window is fully covered. - GLsizei max_vp[2] = {}; - glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max_vp); + Size2i max_vp = GLES3::Utilities::get_singleton()->get_maximum_viewport_size(); glViewport(0, 0, max_vp[0], max_vp[1]); glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 876309d22c5..4a15ed827a0 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -37,6 +37,7 @@ #include "core/io/file_access.h" #include "drivers/gles3/rasterizer_gles3.h" +#include "drivers/gles3/storage/config.h" static String _mkid(const String &p_id) { String id = "m_" + p_id.replace("__", "_dus_"); @@ -801,7 +802,9 @@ void ShaderGLES3::initialize(const String &p_general_defines, int p_base_texture print_verbose("Shader '" + name + "' SHA256: " + base_sha256); } - glGetInteger64v(GL_MAX_TEXTURE_IMAGE_UNITS, &max_image_units); + GLES3::Config *config = GLES3::Config::get_singleton(); + ERR_FAIL_NULL(config); + max_image_units = config->max_texture_image_units; } void ShaderGLES3::set_shader_cache_dir(const String &p_dir) { diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h index 8968e76c12c..9ee939e3439 100644 --- a/drivers/gles3/shader_gles3.h +++ b/drivers/gles3/shader_gles3.h @@ -148,7 +148,7 @@ private: static bool shader_cache_save_debug; bool shader_cache_dir_valid = false; - int64_t max_image_units = 0; + GLint max_image_units = 0; enum StageType { STAGE_TYPE_VERTEX, diff --git a/drivers/gles3/storage/config.cpp b/drivers/gles3/storage/config.cpp index 6b5e2277826..2ab1ef1c9d4 100644 --- a/drivers/gles3/storage/config.cpp +++ b/drivers/gles3/storage/config.cpp @@ -45,9 +45,9 @@ Config::Config() { singleton = this; { - int64_t max_extensions = 0; - glGetInteger64v(GL_NUM_EXTENSIONS, &max_extensions); - for (int64_t i = 0; i < max_extensions; i++) { + GLint max_extensions = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &max_extensions); + for (int i = 0; i < max_extensions; i++) { const GLubyte *s = glGetStringi(GL_EXTENSIONS, i); if (!s) { break; @@ -80,11 +80,14 @@ Config::Config() { rgtc_supported = extensions.has("GL_EXT_texture_compression_rgtc") || extensions.has("GL_ARB_texture_compression_rgtc") || extensions.has("EXT_texture_compression_rgtc"); } - glGetInteger64v(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &max_vertex_texture_image_units); - glGetInteger64v(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_image_units); - glGetInteger64v(GL_MAX_TEXTURE_SIZE, &max_texture_size); + glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &max_vertex_texture_image_units); + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_image_units); + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); + glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max_viewport_size); glGetInteger64v(GL_MAX_UNIFORM_BLOCK_SIZE, &max_uniform_buffer_size); - glGetInteger64v(GL_MAX_VIEWPORT_DIMS, max_viewport_size); + + // sanity clamp buffer size to 16K..1MB + max_uniform_buffer_size = CLAMP(max_uniform_buffer_size, 16384, 1048576); support_anisotropic_filter = extensions.has("GL_EXT_texture_filter_anisotropic"); if (support_anisotropic_filter) { diff --git a/drivers/gles3/storage/config.h b/drivers/gles3/storage/config.h index c3ab65f0bc0..1ff80d9a9e8 100644 --- a/drivers/gles3/storage/config.h +++ b/drivers/gles3/storage/config.h @@ -57,11 +57,12 @@ public: bool use_nearest_mip_filter = false; bool use_depth_prepass = true; - int64_t max_vertex_texture_image_units = 0; - int64_t max_texture_image_units = 0; - int64_t max_texture_size = 0; - int64_t max_viewport_size[2] = { 0, 0 }; - int64_t max_uniform_buffer_size = 0; + GLint max_vertex_texture_image_units = 0; + GLint max_texture_image_units = 0; + GLint max_texture_size = 0; + GLint max_viewport_size[2] = { 0, 0 }; + GLint64 max_uniform_buffer_size = 0; + int64_t max_renderable_elements = 0; int64_t max_renderable_lights = 0; int64_t max_lights_per_object = 0; diff --git a/drivers/gles3/storage/utilities.cpp b/drivers/gles3/storage/utilities.cpp index 356dc06733b..7f0be364663 100644 --- a/drivers/gles3/storage/utilities.cpp +++ b/drivers/gles3/storage/utilities.cpp @@ -463,10 +463,7 @@ String Utilities::get_video_adapter_api_version() const { Size2i Utilities::get_maximum_viewport_size() const { Config *config = Config::get_singleton(); - if (!config) { - return Size2i(); - } - + ERR_FAIL_NULL_V(config, Size2i()); return Size2i(config->max_viewport_size[0], config->max_viewport_size[1]); }