summaryrefslogtreecommitdiffstats
path: root/drivers/gles3
diff options
context:
space:
mode:
authorpatwork <patwork@gmail.com>2024-06-07 00:06:27 +0200
committerpatwork <patwork@gmail.com>2024-06-14 01:53:12 +0200
commited5f33ef07540fa7529363819f40c4df3110ef80 (patch)
treeb4c7af9facbcc6d5005214c68cda4768676cc2ec /drivers/gles3
parent680e489189796af2c34f06df49e19b17dec5c6fc (diff)
downloadredot-engine-ed5f33ef07540fa7529363819f40c4df3110ef80.tar.gz
Make query for GL_MAX_VIEWPORT_DIMS compatible with web exports
Diffstat (limited to 'drivers/gles3')
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp3
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp3
-rw-r--r--drivers/gles3/shader_gles3.cpp5
-rw-r--r--drivers/gles3/shader_gles3.h2
-rw-r--r--drivers/gles3/storage/config.cpp17
-rw-r--r--drivers/gles3/storage/config.h11
-rw-r--r--drivers/gles3/storage/utilities.cpp5
7 files changed, 24 insertions, 22 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 5fabeb94f5..941b1a1b28 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 993197e371..60891b8b4e 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 876309d22c..4a15ed827a 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 8968e76c12..9ee939e343 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 6b5e227782..2ab1ef1c9d 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 c3ab65f0bc..1ff80d9a9e 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 356dc06733..7f0be36466 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]);
}