diff options
Diffstat (limited to 'drivers/gles3/storage/texture_storage.cpp')
-rw-r--r-- | drivers/gles3/storage/texture_storage.cpp | 75 |
1 files changed, 69 insertions, 6 deletions
diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index bd4793f4dc..e9df3c6fc8 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1981,10 +1981,25 @@ void TextureStorage::_update_render_target(RenderTarget *rt) { Config *config = Config::get_singleton(); - rt->color_internal_format = rt->is_transparent ? GL_RGBA8 : GL_RGB10_A2; - rt->color_format = GL_RGBA; - rt->color_type = rt->is_transparent ? GL_UNSIGNED_BYTE : GL_UNSIGNED_INT_2_10_10_10_REV; - rt->image_format = Image::FORMAT_RGBA8; + if (rt->hdr) { + rt->color_internal_format = GL_RGBA16F; + rt->color_format = GL_RGBA; + rt->color_type = GL_FLOAT; + rt->color_format_size = 8; + rt->image_format = Image::FORMAT_RGBAF; + } else if (rt->is_transparent) { + rt->color_internal_format = GL_RGBA8; + rt->color_format = GL_RGBA; + rt->color_type = GL_UNSIGNED_BYTE; + rt->color_format_size = 4; + rt->image_format = Image::FORMAT_RGBA8; + } else { + rt->color_internal_format = GL_RGB10_A2; + rt->color_format = GL_RGBA; + rt->color_type = GL_UNSIGNED_INT_2_10_10_10_REV; + rt->color_format_size = 4; + rt->image_format = Image::FORMAT_RGBA8; + } glDisable(GL_SCISSOR_TEST); glColorMask(1, 1, 1, 1); @@ -2023,7 +2038,7 @@ void TextureStorage::_update_render_target(RenderTarget *rt) { texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST); texture->gl_set_repeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - GLES3::Utilities::get_singleton()->texture_allocated_data(rt->color, rt->size.x * rt->size.y * rt->view_count * 4, "Render target color texture"); + GLES3::Utilities::get_singleton()->texture_allocated_data(rt->color, rt->size.x * rt->size.y * rt->view_count * rt->color_format_size, "Render target color texture"); } #ifndef IOS_ENABLED if (use_multiview) { @@ -2194,7 +2209,7 @@ void GLES3::TextureStorage::check_backbuffer(RenderTarget *rt, const bool uses_s } else { glTexImage2D(texture_target, 0, rt->color_internal_format, rt->size.x, rt->size.y, 0, rt->color_format, rt->color_type, nullptr); } - GLES3::Utilities::get_singleton()->texture_allocated_data(rt->backbuffer, rt->size.x * rt->size.y * rt->view_count * 4, "Render target backbuffer color texture (3D)"); + GLES3::Utilities::get_singleton()->texture_allocated_data(rt->backbuffer, rt->size.x * rt->size.y * rt->view_count * rt->color_format_size, "Render target backbuffer color texture (3D)"); glTexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -2548,6 +2563,54 @@ RS::ViewportMSAA TextureStorage::render_target_get_msaa(RID p_render_target) con return rt->msaa; } +void TextureStorage::render_target_set_use_hdr(RID p_render_target, bool p_use_hdr_2d) { + RenderTarget *rt = render_target_owner.get_or_null(p_render_target); + ERR_FAIL_NULL(rt); + ERR_FAIL_COND(rt->direct_to_screen); + if (p_use_hdr_2d == rt->hdr) { + return; + } + + _clear_render_target(rt); + rt->hdr = p_use_hdr_2d; + _update_render_target(rt); +} + +bool TextureStorage::render_target_is_using_hdr(RID p_render_target) const { + RenderTarget *rt = render_target_owner.get_or_null(p_render_target); + ERR_FAIL_NULL_V(rt, false); + + return rt->hdr; +} + +GLuint TextureStorage::render_target_get_color_internal_format(RID p_render_target) const { + RenderTarget *rt = render_target_owner.get_or_null(p_render_target); + ERR_FAIL_NULL_V(rt, GL_RGBA8); + + return rt->color_internal_format; +} + +GLuint TextureStorage::render_target_get_color_format(RID p_render_target) const { + RenderTarget *rt = render_target_owner.get_or_null(p_render_target); + ERR_FAIL_NULL_V(rt, GL_RGBA); + + return rt->color_format; +} + +GLuint TextureStorage::render_target_get_color_type(RID p_render_target) const { + RenderTarget *rt = render_target_owner.get_or_null(p_render_target); + ERR_FAIL_NULL_V(rt, GL_UNSIGNED_BYTE); + + return rt->color_type; +} + +uint32_t TextureStorage::render_target_get_color_format_size(RID p_render_target) const { + RenderTarget *rt = render_target_owner.get_or_null(p_render_target); + ERR_FAIL_NULL_V(rt, 4); + + return rt->color_format_size; +} + void TextureStorage::render_target_request_clear(RID p_render_target, const Color &p_clear_color) { RenderTarget *rt = render_target_owner.get_or_null(p_render_target); ERR_FAIL_NULL(rt); |