diff options
author | clayjohn <claynjohn@gmail.com> | 2022-05-18 08:04:41 -0700 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2022-05-24 11:00:34 -0700 |
commit | 3e20c1347db323438a76693bb9f7eea87f3a305d (patch) | |
tree | 98ed91197c8eaf8e4604089eea44c3c420ef5d22 /servers | |
parent | d81c5eab8cfd1d91ef2cf1599a6b929ccbed0a3a (diff) |
Add clipping, backbuffer, and CanvasGroups to 2D GLES3 renderer
As well as significant consequent cleanup in the RenderTarget, Texture, and Canvas renderer code
Diffstat (limited to 'servers')
5 files changed, 16 insertions, 19 deletions
diff --git a/servers/rendering/dummy/storage/texture_storage.h b/servers/rendering/dummy/storage/texture_storage.h index 534b9f07d8..11d827a6e3 100644 --- a/servers/rendering/dummy/storage/texture_storage.h +++ b/servers/rendering/dummy/storage/texture_storage.h @@ -152,7 +152,8 @@ public: virtual void render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) override {} virtual RID render_target_get_texture(RID p_render_target) override { return RID(); } virtual void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) override {} - virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) override {} + virtual void render_target_set_transparent(RID p_render_target, bool p_is_transparent) override {} + virtual void render_target_set_direct_to_screen(RID p_render_target, bool p_direct_to_screen) override {} virtual bool render_target_was_used(RID p_render_target) override { return false; } virtual void render_target_set_as_unused(RID p_render_target) override {} diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp index 7d4808f936..329c23bad0 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp @@ -2075,7 +2075,7 @@ void TextureStorage::_update_render_target(RenderTarget *rt) { //until we implement support for HDR monitors (and render target is attached to screen), this is enough. rt->color_format = RD::DATA_FORMAT_R8G8B8A8_UNORM; rt->color_format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB; - rt->image_format = rt->flags[RENDER_TARGET_TRANSPARENT] ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8; + rt->image_format = rt->is_transparent ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8; RD::TextureFormat rd_format; RD::TextureView rd_view; @@ -2127,7 +2127,7 @@ void TextureStorage::_update_render_target(RenderTarget *rt) { //so transparent can be supported RD::TextureView view; view.format_override = rt->color_format; - if (!rt->flags[RENDER_TARGET_TRANSPARENT]) { + if (!rt->is_transparent) { view.swizzle_a = RD::TEXTURE_SWIZZLE_ONE; } tex->rd_texture = RD::get_singleton()->texture_create_shared(view, rt->color); @@ -2194,9 +2194,6 @@ RID TextureStorage::render_target_create() { render_target.was_used = false; render_target.clear_requested = false; - for (int i = 0; i < RENDER_TARGET_FLAG_MAX; i++) { - render_target.flags[i] = false; - } _update_render_target(&render_target); return render_target_owner.make_rid(render_target); } @@ -2240,13 +2237,16 @@ RID TextureStorage::render_target_get_texture(RID p_render_target) { void TextureStorage::render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) { } -void TextureStorage::render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) { +void TextureStorage::render_target_set_transparent(RID p_render_target, bool p_is_transparent) { RenderTarget *rt = render_target_owner.get_or_null(p_render_target); ERR_FAIL_COND(!rt); - rt->flags[p_flag] = p_value; + rt->is_transparent = p_is_transparent; _update_render_target(rt); } +void TextureStorage::render_target_set_direct_to_screen(RID p_render_target, bool p_value) { +} + bool TextureStorage::render_target_was_used(RID p_render_target) { RenderTarget *rt = render_target_owner.get_or_null(p_render_target); ERR_FAIL_COND_V(!rt, false); diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h index 418eb82808..901f764085 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h @@ -207,7 +207,7 @@ struct RenderTarget { RD::DataFormat color_format_srgb = RD::DATA_FORMAT_R4G4_UNORM_PACK8; Image::Format image_format = Image::FORMAT_L8; - bool flags[RendererTextureStorage::RENDER_TARGET_FLAG_MAX]; + bool is_transparent = false; bool sdf_enabled = false; @@ -525,7 +525,8 @@ public: virtual void render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) override; virtual RID render_target_get_texture(RID p_render_target) override; virtual void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) override; - virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) override; + virtual void render_target_set_transparent(RID p_render_target, bool p_is_transparent) override; + virtual void render_target_set_direct_to_screen(RID p_render_target, bool p_direct_to_screen) override; virtual bool render_target_was_used(RID p_render_target) override; virtual void render_target_set_as_unused(RID p_render_target) override; diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 7c2d7a1e1d..74fafe8381 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -866,7 +866,7 @@ void RendererViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool RSG::texture_storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y, viewport->get_view_count()); } - RSG::texture_storage->render_target_set_flag(viewport->render_target, RendererTextureStorage::RENDER_TARGET_DIRECT_TO_SCREEN, p_enable); + RSG::texture_storage->render_target_set_direct_to_screen(viewport->render_target, p_enable); viewport->viewport_render_direct_to_screen = p_enable; // if attached to screen already, setup screen size and position, this needs to happen after setting flag to avoid an unnecessary buffer allocation @@ -980,7 +980,7 @@ void RendererViewport::viewport_set_transparent_background(RID p_viewport, bool Viewport *viewport = viewport_owner.get_or_null(p_viewport); ERR_FAIL_COND(!viewport); - RSG::texture_storage->render_target_set_flag(viewport->render_target, RendererTextureStorage::RENDER_TARGET_TRANSPARENT, p_enabled); + RSG::texture_storage->render_target_set_transparent(viewport->render_target, p_enabled); viewport->transparent_bg = p_enabled; } diff --git a/servers/rendering/storage/texture_storage.h b/servers/rendering/storage/texture_storage.h index 4c4213d7c1..e3a969d032 100644 --- a/servers/rendering/storage/texture_storage.h +++ b/servers/rendering/storage/texture_storage.h @@ -111,12 +111,6 @@ public: /* RENDER TARGET */ - enum RenderTargetFlags { - RENDER_TARGET_TRANSPARENT, - RENDER_TARGET_DIRECT_TO_SCREEN, - RENDER_TARGET_FLAG_MAX - }; - virtual RID render_target_create() = 0; virtual void render_target_free(RID p_rid) = 0; @@ -124,7 +118,8 @@ public: virtual void render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) = 0; virtual RID render_target_get_texture(RID p_render_target) = 0; virtual void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) = 0; - virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) = 0; + virtual void render_target_set_transparent(RID p_render_target, bool p_is_transparent) = 0; + virtual void render_target_set_direct_to_screen(RID p_render_target, bool p_direct_to_screen) = 0; virtual bool render_target_was_used(RID p_render_target) = 0; virtual void render_target_set_as_unused(RID p_render_target) = 0; |