| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#ifdef GLES3_ENABLED |
| 34 |
|
| 35 |
#include "drivers/gles3/effects/glow.h" |
| 36 |
#include "servers/rendering/storage/render_scene_buffers.h" |
| 37 |
|
| 38 |
#include "platform_gl.h" |
| 39 |
|
| 40 |
class RenderSceneBuffersGLES3 : public RenderSceneBuffers { |
| 41 |
GDCLASS(RenderSceneBuffersGLES3, RenderSceneBuffers); |
| 42 |
|
| 43 |
public: |
| 44 |
Size2i internal_size; |
| 45 |
Size2i target_size; |
| 46 |
RS::ViewportScaling3DMode scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
uint32_t view_count = 1; |
| 52 |
bool apply_color_adjustments_in_post = false; |
| 53 |
|
| 54 |
RID render_target; |
| 55 |
|
| 56 |
|
| 57 |
GLuint color_internal_format = GL_RGBA8; |
| 58 |
GLuint color_format = GL_RGBA; |
| 59 |
GLuint color_type = GL_UNSIGNED_BYTE; |
| 60 |
uint32_t color_format_size = 4; |
| 61 |
|
| 62 |
struct FBDEF { |
| 63 |
GLuint color = 0; |
| 64 |
GLuint depth = 0; |
| 65 |
GLuint fbo = 0; |
| 66 |
}; |
| 67 |
|
| 68 |
struct RTMSAA3D { |
| 69 |
RS::ViewportMSAA mode = RS::VIEWPORT_MSAA_DISABLED; |
| 70 |
bool needs_resolve = false; |
| 71 |
GLsizei samples = 1; |
| 72 |
GLuint color = 0; |
| 73 |
GLuint depth = 0; |
| 74 |
GLuint fbo = 0; |
| 75 |
|
| 76 |
bool check_fbo_cache = false; |
| 77 |
Vector<FBDEF> cached_fbos; |
| 78 |
} msaa3d; |
| 79 |
|
| 80 |
FBDEF internal3d; |
| 81 |
|
| 82 |
FBDEF backbuffer3d; |
| 83 |
|
| 84 |
|
| 85 |
struct GLOW { |
| 86 |
GLES3::Glow::GLOWLEVEL levels[4]; |
| 87 |
} glow; |
| 88 |
|
| 89 |
private: |
| 90 |
void _check_render_buffers(); |
| 91 |
void _clear_msaa3d_buffers(); |
| 92 |
void _clear_intermediate_buffers(); |
| 93 |
void _clear_back_buffers(); |
| 94 |
void _clear_glow_buffers(); |
| 95 |
|
| 96 |
void _rt_attach_textures(GLuint p_color, GLuint p_depth, GLsizei p_samples, uint32_t p_view_count, bool p_depth_has_stencil); |
| 97 |
GLuint _rt_get_cached_fbo(GLuint p_color, GLuint p_depth, GLsizei p_samples, uint32_t p_view_count); |
| 98 |
|
| 99 |
public: |
| 100 |
RenderSceneBuffersGLES3(); |
| 101 |
virtual ~RenderSceneBuffersGLES3(); |
| 102 |
virtual void configure(const RenderSceneBuffersConfiguration *p_config) override; |
| 103 |
void configure_for_probe(Size2i p_size); |
| 104 |
|
| 105 |
virtual void set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) override {} |
| 106 |
virtual void set_fsr_sharpness(float p_fsr_sharpness) override {} |
| 107 |
virtual void set_texture_mipmap_bias(float p_texture_mipmap_bias) override {} |
| 108 |
virtual void set_use_debanding(bool p_use_debanding) override {} |
| 109 |
void set_apply_color_adjustments_in_post(bool p_apply_in_post); |
| 110 |
|
| 111 |
void free_render_buffer_data(); |
| 112 |
|
| 113 |
void check_backbuffer(bool p_need_color, bool p_need_depth); |
| 114 |
void check_glow_buffers(); |
| 115 |
|
| 116 |
GLuint get_render_fbo(); |
| 117 |
GLuint get_msaa3d_fbo() { |
| 118 |
_check_render_buffers(); |
| 119 |
return msaa3d.fbo; |
| 120 |
} |
| 121 |
GLuint get_msaa3d_color() { |
| 122 |
_check_render_buffers(); |
| 123 |
return msaa3d.color; |
| 124 |
} |
| 125 |
GLuint get_msaa3d_depth() { |
| 126 |
_check_render_buffers(); |
| 127 |
return msaa3d.depth; |
| 128 |
} |
| 129 |
bool get_msaa_needs_resolve() { |
| 130 |
_check_render_buffers(); |
| 131 |
return msaa3d.needs_resolve; |
| 132 |
} |
| 133 |
GLuint get_internal_fbo() { |
| 134 |
_check_render_buffers(); |
| 135 |
return internal3d.fbo; |
| 136 |
} |
| 137 |
GLuint get_internal_color() { |
| 138 |
_check_render_buffers(); |
| 139 |
return internal3d.color; |
| 140 |
} |
| 141 |
GLuint get_internal_depth() { |
| 142 |
_check_render_buffers(); |
| 143 |
return internal3d.depth; |
| 144 |
} |
| 145 |
GLuint get_backbuffer_fbo() const { return backbuffer3d.fbo; } |
| 146 |
GLuint get_backbuffer() const { return backbuffer3d.color; } |
| 147 |
GLuint get_backbuffer_depth() const { return backbuffer3d.depth; } |
| 148 |
|
| 149 |
const GLES3::Glow::GLOWLEVEL *get_glow_buffers() const { return &glow.levels[0]; } |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
_FORCE_INLINE_ RID get_render_target() const { return render_target; } |
| 154 |
_FORCE_INLINE_ uint32_t get_view_count() const { return view_count; } |
| 155 |
_FORCE_INLINE_ Size2i get_internal_size() const { return internal_size; } |
| 156 |
_FORCE_INLINE_ Size2i get_target_size() const { return target_size; } |
| 157 |
_FORCE_INLINE_ RS::ViewportScaling3DMode get_scaling_3d_mode() const { return scaling_3d_mode; } |
| 158 |
|
| 159 |
_FORCE_INLINE_ RS::ViewportMSAA get_msaa_3d() const { return msaa3d.mode; } |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
}; |
| 164 |
|
| 165 |
#endif |