You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Optimize Glow with local memory
This commit is contained in:
@@ -389,14 +389,14 @@ void RasterizerEffectsRD::gaussian_blur(RID p_source_rd_texture, RID p_texture,
|
||||
RD::get_singleton()->compute_list_end();
|
||||
}
|
||||
|
||||
void RasterizerEffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_texture, RID p_back_texture, const Size2i &p_size, float p_strength, bool p_high_quality, bool p_first_pass, float p_luminance_cap, float p_exposure, float p_bloom, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, RID p_auto_exposure, float p_auto_exposure_grey) {
|
||||
void RasterizerEffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_back_texture, const Size2i &p_size, float p_strength, bool p_high_quality, bool p_first_pass, float p_luminance_cap, float p_exposure, float p_bloom, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, RID p_auto_exposure, float p_auto_exposure_grey) {
|
||||
zeromem(©.push_constant, sizeof(CopyPushConstant));
|
||||
|
||||
CopyMode copy_mode = p_first_pass && p_auto_exposure.is_valid() ? COPY_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE : COPY_MODE_GAUSSIAN_GLOW;
|
||||
uint32_t base_flags = 0;
|
||||
|
||||
int32_t x_groups = (p_size.width - 1) / 8 + 1;
|
||||
int32_t y_groups = (p_size.height - 1) / 8 + 1;
|
||||
int32_t x_groups = (p_size.width + 7) / 8;
|
||||
int32_t y_groups = (p_size.height + 7) / 8;
|
||||
|
||||
copy.push_constant.section[2] = p_size.x;
|
||||
copy.push_constant.section[3] = p_size.y;
|
||||
@@ -411,29 +411,15 @@ void RasterizerEffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_texture,
|
||||
|
||||
copy.push_constant.glow_auto_exposure_grey = p_auto_exposure_grey; //unused also
|
||||
|
||||
//HORIZONTAL
|
||||
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
|
||||
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, copy.pipelines[copy_mode]);
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_source_rd_texture), 0);
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_texture), 3);
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_back_texture), 3);
|
||||
if (p_auto_exposure.is_valid() && p_first_pass) {
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_auto_exposure), 1);
|
||||
}
|
||||
|
||||
copy.push_constant.flags = base_flags | COPY_FLAG_HORIZONTAL | (p_first_pass ? COPY_FLAG_GLOW_FIRST_PASS : 0) | (p_high_quality ? COPY_FLAG_HIGH_QUALITY_GLOW : 0);
|
||||
RD::get_singleton()->compute_list_set_push_constant(compute_list, ©.push_constant, sizeof(CopyPushConstant));
|
||||
|
||||
RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1);
|
||||
RD::get_singleton()->compute_list_add_barrier(compute_list);
|
||||
|
||||
copy_mode = COPY_MODE_GAUSSIAN_GLOW;
|
||||
|
||||
//VERTICAL
|
||||
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, copy.pipelines[copy_mode]);
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_texture), 0);
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_back_texture), 3);
|
||||
|
||||
copy.push_constant.flags = base_flags;
|
||||
copy.push_constant.flags = base_flags | (p_first_pass ? COPY_FLAG_GLOW_FIRST_PASS : 0) | (p_high_quality ? COPY_FLAG_HIGH_QUALITY_GLOW : 0);
|
||||
RD::get_singleton()->compute_list_set_push_constant(compute_list, ©.push_constant, sizeof(CopyPushConstant));
|
||||
|
||||
RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1);
|
||||
@@ -692,7 +678,13 @@ void RasterizerEffectsRD::tonemapper(RID p_source_color, RID p_dst_framebuffer,
|
||||
|
||||
tonemap.push_constant.use_glow = p_settings.use_glow;
|
||||
tonemap.push_constant.glow_intensity = p_settings.glow_intensity;
|
||||
tonemap.push_constant.glow_level_flags = p_settings.glow_level_flags;
|
||||
tonemap.push_constant.glow_levels[0] = p_settings.glow_levels[0]; // clean this up to just pass by pointer or something
|
||||
tonemap.push_constant.glow_levels[1] = p_settings.glow_levels[1];
|
||||
tonemap.push_constant.glow_levels[2] = p_settings.glow_levels[2];
|
||||
tonemap.push_constant.glow_levels[3] = p_settings.glow_levels[3];
|
||||
tonemap.push_constant.glow_levels[4] = p_settings.glow_levels[4];
|
||||
tonemap.push_constant.glow_levels[5] = p_settings.glow_levels[5];
|
||||
tonemap.push_constant.glow_levels[6] = p_settings.glow_levels[6];
|
||||
tonemap.push_constant.glow_texture_size[0] = p_settings.glow_texture_size.x;
|
||||
tonemap.push_constant.glow_texture_size[1] = p_settings.glow_texture_size.y;
|
||||
tonemap.push_constant.glow_mode = p_settings.glow_mode;
|
||||
|
||||
Reference in New Issue
Block a user