summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMounir Tohami <53877170+WhalesState@users.noreply.github.com>2023-08-16 15:58:23 +0000
committerMounir Tohami <53877170+WhalesState@users.noreply.github.com>2023-08-16 15:58:23 +0000
commit2987dd0c71ae4ec7ac1b1d345e9e5e32925fa3b8 (patch)
tree273301b58330175efae23357881fd77ec7dfaae1 /drivers
parentc5da2e54fe50cad34b5f93fa10538978b33af88d (diff)
downloadredot-engine-2987dd0c71ae4ec7ac1b1d345e9e5e32925fa3b8.tar.gz
fix GLES3 changing 2d shadow atlas size is broken
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp20
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.h2
2 files changed, 18 insertions, 4 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 86405fa3f0..9f8d9164ce 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -2048,16 +2048,26 @@ void RasterizerCanvasGLES3::occluder_polygon_set_cull_mode(RID p_occluder, RS::C
void RasterizerCanvasGLES3::set_shadow_texture_size(int p_size) {
GLES3::Config *config = GLES3::Config::get_singleton();
p_size = nearest_power_of_2_templated(p_size);
- if (p_size == state.shadow_texture_size) {
- return;
- }
if (p_size > config->max_texture_size) {
p_size = config->max_texture_size;
WARN_PRINT("Attempting to set CanvasItem shadow atlas size to " + itos(p_size) + " which is beyond limit of " + itos(config->max_texture_size) + "supported by hardware.");
}
+ if (p_size == state.shadow_texture_size) {
+ return;
+ }
state.shadow_texture_size = p_size;
+
+ if (state.shadow_fb != 0) {
+ glDeleteFramebuffers(1, &state.shadow_fb);
+ GLES3::Utilities::get_singleton()->texture_free_data(state.shadow_texture);
+ glDeleteRenderbuffers(1, &state.shadow_depth_buffer);
+ state.shadow_fb = 0;
+ state.shadow_texture = 0;
+ state.shadow_depth_buffer = 0;
+ }
+ _update_shadow_atlas();
}
bool RasterizerCanvasGLES3::free(RID p_rid) {
@@ -2442,6 +2452,7 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec
return id;
}
+
void RasterizerCanvasGLES3::free_polygon(PolygonID p_polygon) {
PolygonBuffers *pb_ptr = polygon_buffers.polygons.getptr(p_polygon);
ERR_FAIL_COND(!pb_ptr);
@@ -2521,6 +2532,8 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() {
GLES3::MaterialStorage *material_storage = GLES3::MaterialStorage::get_singleton();
GLES3::Config *config = GLES3::Config::get_singleton();
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1.0, 1.0, 1.0, 1.0);
+
polygon_buffers.last_id = 1;
// quad buffer
{
@@ -2700,6 +2713,7 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() {
GLES3::MaterialStorage::get_singleton()->shaders.canvas_shader.initialize(global_defines, 1);
data.canvas_shader_default_version = GLES3::MaterialStorage::get_singleton()->shaders.canvas_shader.version_create();
+ state.shadow_texture_size = GLOBAL_GET("rendering/2d/shadow_atlas/size");
shadow_render.shader.initialize();
shadow_render.shader_version = shadow_render.shader.version_create();
diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h
index 2eac5f57e1..c1b3e20e33 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.h
+++ b/drivers/gles3/rasterizer_canvas_gles3.h
@@ -192,7 +192,7 @@ public:
GLuint index_buffer = 0;
int count = 0;
bool color_disabled = false;
- Color color;
+ Color color = Color(1.0, 1.0, 1.0, 1.0);
};
struct {