-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendering compositor identifies is_opengl
API; minor optimisation
#102302
Conversation
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, render_target_descriptors[rd_texture], 0); | ||
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, it->value, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaces a 3rd hash table lookup
if (!render_target_descriptors.has(rd_texture) || !RD::get_singleton()->uniform_set_is_valid(render_target_descriptors[rd_texture])) { | ||
HashMap<RID, RID>::Iterator it = render_target_descriptors.find(rd_texture); | ||
if (it == render_target_descriptors.end() || !RD::get_singleton()->uniform_set_is_valid(it->value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaces potentially two hash table lookups
if (OS::get_singleton()->get_current_rendering_driver_name().begins_with("opengl3")) { | ||
if (RSG::rasterizer->is_opengl()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ultimately, the compositor determines if it requires gl_end_frame
be called, so it can determine that by returning true
for is_opengl
.
More efficient, as the string comparison performs increment / decrement of the COW string buffer to perform the begins_with
.
if (OS::get_singleton()->get_current_rendering_driver_name().begins_with("opengl3")) { | ||
Vector<BlitToScreen> blit_to_screen_vec; | ||
blit_to_screen_vec.push_back(blit); | ||
RSG::rasterizer->blit_render_targets_to_screen(vp->viewport_to_screen, blit_to_screen_vec.ptr(), 1); | ||
if (RSG::rasterizer->is_opengl()) { | ||
RSG::rasterizer->blit_render_targets_to_screen(vp->viewport_to_screen, &blit, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced a Vector heap allocation here too.
b411401
to
645221a
Compare
viewport_set_force_motion_vectors(vp->self, true); | ||
_viewport_set_force_motion_vectors(vp, true); | ||
} else { | ||
viewport_set_force_motion_vectors(vp->self, false); | ||
_viewport_set_force_motion_vectors(vp, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow same pattern for private implementations that already have a reference to a Viewport *
, which avoids looking it up again in the hash map.
if (viewport->force_motion_vectors == p_force_motion_vectors) { | ||
_viewport_set_force_motion_vectors(viewport, p_force_motion_vectors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with private function that takes a Viewport *
rather than RID, to avoid performing the lookup and check.
@@ -208,6 +208,7 @@ class RendererViewport { | |||
Vector<Viewport *> _sort_active_viewports(); | |||
void _viewport_set_size(Viewport *p_viewport, int p_width, int p_height, uint32_t p_view_count); | |||
bool _viewport_requires_motion_vectors(Viewport *p_viewport); | |||
void _viewport_set_force_motion_vectors(Viewport *p_viewport, bool p_force_motion_vectors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just like the other _viewport_
functions, this takes a Viewport *
as the first argument, rather than RID
is_opengl
API; minor optimisationis_opengl
API; minor optimisation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Should probably be rebased before merging since it has been so long and CI might be out of date
645221a
to
5e1fe80
Compare
Good call – I've rebased 👍🏻 |
Thanks! |
A couple of minor improvements in the rendering code.
is_opengl
to theRendererCompositor
, given it has agl_end_frame
, allowing it to determine whethergl_end_frame
should be called rather than RendererRD blit. Faster than performing string comparisons every frame.