Path: blob/master/drivers/gles3/storage/render_scene_buffers_gles3.h
10000 views
/**************************************************************************/1/* render_scene_buffers_gles3.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#ifdef GLES3_ENABLED3334#include "drivers/gles3/effects/glow.h"35#include "servers/rendering/storage/render_scene_buffers.h"3637#include "platform_gl.h"3839class RenderSceneBuffersGLES3 : public RenderSceneBuffers {40GDCLASS(RenderSceneBuffersGLES3, RenderSceneBuffers);4142public:43Size2i internal_size; // Size of the buffer we render 3D content to.44Size2i target_size; // Size of our output buffer (render target).45RS::ViewportScaling3DMode scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF;46//float fsr_sharpness = 0.2f;47//RS::ViewportScreenSpaceAA screen_space_aa = RS::VIEWPORT_SCREEN_SPACE_AA_DISABLED;48//bool use_taa = false;49//bool use_debanding = false;50uint32_t view_count = 1;51bool apply_color_adjustments_in_post = false;5253RID render_target;5455// Color format details from our render target56GLuint color_internal_format = GL_RGBA8;57GLuint color_format = GL_RGBA;58GLuint color_type = GL_UNSIGNED_BYTE;59uint32_t color_format_size = 4;6061struct FBDEF {62GLuint color = 0;63GLuint depth = 0;64GLuint fbo = 0;65};6667struct RTMSAA3D {68RS::ViewportMSAA mode = RS::VIEWPORT_MSAA_DISABLED;69bool needs_resolve = false;70GLsizei samples = 1;71GLuint color = 0;72GLuint depth = 0;73GLuint fbo = 0;7475bool check_fbo_cache = false;76Vector<FBDEF> cached_fbos;77} msaa3d; // MSAA buffers used to render 3D7879FBDEF internal3d; // buffers used to either render 3D (scaled/post) or to resolve MSAA into8081FBDEF backbuffer3d; // our back buffer8283// Buffers for our glow implementation84struct GLOW {85GLES3::Glow::GLOWLEVEL levels[4];86} glow;8788private:89void _check_render_buffers();90void _clear_msaa3d_buffers();91void _clear_intermediate_buffers();92void _clear_back_buffers();93void _clear_glow_buffers();9495void _rt_attach_textures(GLuint p_color, GLuint p_depth, GLsizei p_samples, uint32_t p_view_count, bool p_depth_has_stencil);96GLuint _rt_get_cached_fbo(GLuint p_color, GLuint p_depth, GLsizei p_samples, uint32_t p_view_count);9798public:99RenderSceneBuffersGLES3();100virtual ~RenderSceneBuffersGLES3();101virtual void configure(const RenderSceneBuffersConfiguration *p_config) override;102void configure_for_probe(Size2i p_size);103104virtual void set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) override {}105virtual void set_fsr_sharpness(float p_fsr_sharpness) override {}106virtual void set_texture_mipmap_bias(float p_texture_mipmap_bias) override {}107virtual void set_use_debanding(bool p_use_debanding) override {}108void set_apply_color_adjustments_in_post(bool p_apply_in_post);109110void free_render_buffer_data();111112void check_backbuffer(bool p_need_color, bool p_need_depth); // Check if we need to initialize our backbuffer.113void check_glow_buffers(); // Check if we need to initialize our glow buffers.114115GLuint get_render_fbo();116GLuint get_msaa3d_fbo() {117_check_render_buffers();118return msaa3d.fbo;119}120GLuint get_msaa3d_color() {121_check_render_buffers();122return msaa3d.color;123}124GLuint get_msaa3d_depth() {125_check_render_buffers();126return msaa3d.depth;127}128bool get_msaa_needs_resolve() {129_check_render_buffers();130return msaa3d.needs_resolve;131}132GLuint get_internal_fbo() {133_check_render_buffers();134return internal3d.fbo;135}136GLuint get_internal_color() {137_check_render_buffers();138return internal3d.color;139}140GLuint get_internal_depth() {141_check_render_buffers();142return internal3d.depth;143}144GLuint get_backbuffer_fbo() const { return backbuffer3d.fbo; }145GLuint get_backbuffer() const { return backbuffer3d.color; }146GLuint get_backbuffer_depth() const { return backbuffer3d.depth; }147148const GLES3::Glow::GLOWLEVEL *get_glow_buffers() const { return &glow.levels[0]; }149150// Getters151152_FORCE_INLINE_ RID get_render_target() const { return render_target; }153_FORCE_INLINE_ uint32_t get_view_count() const { return view_count; }154_FORCE_INLINE_ Size2i get_internal_size() const { return internal_size; }155_FORCE_INLINE_ Size2i get_target_size() const { return target_size; }156_FORCE_INLINE_ RS::ViewportScaling3DMode get_scaling_3d_mode() const { return scaling_3d_mode; }157//_FORCE_INLINE_ float get_fsr_sharpness() const { return fsr_sharpness; }158_FORCE_INLINE_ RS::ViewportMSAA get_msaa_3d() const { return msaa3d.mode; }159//_FORCE_INLINE_ RS::ViewportScreenSpaceAA get_screen_space_aa() const { return screen_space_aa; }160//_FORCE_INLINE_ bool get_use_taa() const { return use_taa; }161//_FORCE_INLINE_ bool get_use_debanding() const { return use_debanding; }162};163164#endif // GLES3_ENABLED165166167