From 849596c40c49a6d9b5437b60264261e4b1e97bcd Mon Sep 17 00:00:00 2001
From: Daniel Rakos <daniel.rakos@rastergrid.com>
Date: Fri, 22 Mar 2019 11:09:23 +0100
Subject: Fixed handling of depth texture so it's resolved and bound when
 needed

- Cleaned up and improved the code determining when we need to use a depth
  prepass (previously it wasn't executed in certain cases even if it was
  needed)
- Added code to prepare and bind the depth texture even when no depth prepass
  or MRTs (more precisely effect buffers) are used

Fixes #25870, #25535, and #25387.
---
 drivers/gles3/rasterizer_scene_gles3.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'drivers/gles3/rasterizer_scene_gles3.h')

diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index 56e378d7fa..59e23e5ac9 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -206,7 +206,10 @@ public:
 		bool used_screen_texture;
 
 		bool used_depth_prepass;
-		bool used_depth_prepass_and_resolved;
+
+		bool used_depth_texture;
+		bool prepared_depth_texture;
+		bool bound_depth_texture;
 
 		VS::ViewportDebugDraw debug_draw;
 	} state;
@@ -848,6 +851,9 @@ public:
 	void _render_mrts(Environment *env, const CameraMatrix &p_cam_projection);
 	void _post_process(Environment *env, const CameraMatrix &p_cam_projection);
 
+	void _prepare_depth_texture();
+	void _bind_depth_texture();
+
 	virtual void render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass);
 	virtual void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count);
 	virtual bool free(RID p_rid);
-- 
cgit v1.2.3