Debian Codegraph @

drivers/gles3/storage/render_scene_buffers_gles3.h

raw symbols SCIP
1 /**************************************************************************/
2 /* render_scene_buffers_gles3.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
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; // Size of the buffer we render 3D content to.
45 Size2i target_size; // Size of our output buffer (render target).
46 RS::ViewportScaling3DMode scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF;
47 //float fsr_sharpness = 0.2f;
48 //RS::ViewportScreenSpaceAA screen_space_aa = RS::VIEWPORT_SCREEN_SPACE_AA_DISABLED;
49 //bool use_taa = false;
50 //bool use_debanding = false;
51 uint32_t view_count = 1;
52 bool apply_color_adjustments_in_post = false;
53
54 RID render_target;
55
56 // Color format details from our render target
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; // MSAA buffers used to render 3D
79
80 FBDEF internal3d; // buffers used to either render 3D (scaled/post) or to resolve MSAA into
81
82 FBDEF backbuffer3d; // our back buffer
83
84 // Buffers for our glow implementation
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); // Check if we need to initialize our backbuffer.
114 void check_glow_buffers(); // Check if we need to initialize our 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 // Getters
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 //_FORCE_INLINE_ float get_fsr_sharpness() const { return fsr_sharpness; }
159 _FORCE_INLINE_ RS::ViewportMSAA get_msaa_3d() const { return msaa3d.mode; }
160 //_FORCE_INLINE_ RS::ViewportScreenSpaceAA get_screen_space_aa() const { return screen_space_aa; }
161 //_FORCE_INLINE_ bool get_use_taa() const { return use_taa; }
162 //_FORCE_INLINE_ bool get_use_debanding() const { return use_debanding; }
163 };
164
165 #endif // GLES3_ENABLED