From 3d1b294cc078c96120a4fb44a885a0eebe07ba96 Mon Sep 17 00:00:00 2001 From: Will McKinnon Date: Mon, 24 Apr 2023 00:53:55 -0400 Subject: [PATCH] removed width and height parameters from fx_framebuffer_bind() --- .../sway/desktop/fx_renderer/fx_framebuffer.h | 2 +- sway/desktop/fx_renderer/fx_framebuffer.c | 5 ++-- sway/desktop/fx_renderer/fx_renderer.c | 3 ++- sway/desktop/render.c | 23 ++++++++----------- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/include/sway/desktop/fx_renderer/fx_framebuffer.h b/include/sway/desktop/fx_renderer/fx_framebuffer.h index a7a9cd21..289b4d87 100644 --- a/include/sway/desktop/fx_renderer/fx_framebuffer.h +++ b/include/sway/desktop/fx_renderer/fx_framebuffer.h @@ -12,7 +12,7 @@ struct fx_framebuffer { GLuint fb; }; -void fx_framebuffer_bind(struct fx_framebuffer *buffer, GLsizei width, GLsizei height); +void fx_framebuffer_bind(struct fx_framebuffer *buffer); void fx_framebuffer_create(struct fx_framebuffer *buffer, int width, int height, bool bind); diff --git a/sway/desktop/fx_renderer/fx_framebuffer.c b/sway/desktop/fx_renderer/fx_framebuffer.c index 36652011..6cc1dbf3 100644 --- a/sway/desktop/fx_renderer/fx_framebuffer.c +++ b/sway/desktop/fx_renderer/fx_framebuffer.c @@ -1,9 +1,8 @@ #include "log.h" #include "sway/desktop/fx_renderer/fx_framebuffer.h" -void fx_framebuffer_bind(struct fx_framebuffer *buffer, GLsizei width, GLsizei height) { +void fx_framebuffer_bind(struct fx_framebuffer *buffer) { glBindFramebuffer(GL_FRAMEBUFFER, buffer->fb); - glViewport(0, 0, width, height); } void fx_framebuffer_create(struct fx_framebuffer *buffer, int width, int height, bool bind) { @@ -48,7 +47,7 @@ void fx_framebuffer_create(struct fx_framebuffer *buffer, int width, int height, // Bind the default framebuffer glBindTexture(GL_TEXTURE_2D, 0); if (bind) { - fx_framebuffer_bind(buffer, width, height); + fx_framebuffer_bind(buffer); } } diff --git a/sway/desktop/fx_renderer/fx_renderer.c b/sway/desktop/fx_renderer/fx_renderer.c index 71ccfbe7..7eb95ec9 100644 --- a/sway/desktop/fx_renderer/fx_renderer.c +++ b/sway/desktop/fx_renderer/fx_renderer.c @@ -374,6 +374,7 @@ void fx_renderer_fini(struct fx_renderer *renderer) { } void fx_renderer_begin(struct fx_renderer *renderer, int width, int height) { + glViewport(0, 0, width, height); renderer->viewport_width = width; renderer->viewport_height = height; @@ -399,7 +400,7 @@ void fx_renderer_begin(struct fx_renderer *renderer, int width, int height) { glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // Bind to our main framebuffer - fx_framebuffer_bind(&renderer->main_buffer, width, height); + fx_framebuffer_bind(&renderer->main_buffer); } void fx_renderer_end(struct fx_renderer *renderer) { diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 9f543144..2787181c 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -167,17 +167,15 @@ damage_finish: } /* Renders the blur for each damaged rect and swaps the buffer */ -void render_blur_segments(struct fx_renderer *renderer, struct sway_output *output, +void render_blur_segments(struct fx_renderer *renderer, const float matrix[static 9], pixman_region32_t* damage, struct fx_framebuffer **buffer, struct blur_shader* shader, const struct wlr_box *box, int blur_radius) { - int width, height; - wlr_output_transformed_resolution(output->wlr_output, &width, &height); if (*buffer == &renderer->effects_buffer) { - fx_framebuffer_bind(&renderer->effects_buffer_swapped, width, height); + fx_framebuffer_bind(&renderer->effects_buffer_swapped); } else { - fx_framebuffer_bind(&renderer->effects_buffer, width, height); + fx_framebuffer_bind(&renderer->effects_buffer); } if (pixman_region32_not_empty(damage)) { @@ -221,7 +219,7 @@ struct fx_framebuffer *get_main_buffer_blur(struct fx_renderer *renderer, struct struct fx_framebuffer *current_buffer = &renderer->main_buffer; // Bind to blur framebuffer - fx_framebuffer_bind(&renderer->effects_buffer, monitor_box.width, monitor_box.height); + fx_framebuffer_bind(&renderer->effects_buffer); glBindTexture(renderer->main_buffer.texture.target, renderer->main_buffer.texture.id); // damage region will be scaled, make a temp @@ -234,13 +232,13 @@ struct fx_framebuffer *get_main_buffer_blur(struct fx_renderer *renderer, struct int blur_passes = config->blur_params.num_passes; // First pass - render_blur_segments(renderer, output, gl_matrix, &tempDamage, ¤t_buffer, + render_blur_segments(renderer, gl_matrix, &tempDamage, ¤t_buffer, &renderer->shaders.blur1, box, blur_radius); // Downscale for (int i = 1; i < blur_passes; ++i) { wlr_region_scale(&tempDamage, &damage, 1.0f / (1 << (i + 1))); - render_blur_segments(renderer, output, gl_matrix, &tempDamage, ¤t_buffer, + render_blur_segments(renderer, gl_matrix, &tempDamage, ¤t_buffer, &renderer->shaders.blur1, box, blur_radius); } @@ -248,7 +246,7 @@ struct fx_framebuffer *get_main_buffer_blur(struct fx_renderer *renderer, struct for (int i = blur_passes - 1; i >= 0; --i) { // when upsampling we make the region twice as big wlr_region_scale(&tempDamage, &damage, 1.0f / (1 << i)); - render_blur_segments(renderer, output, gl_matrix, &tempDamage, ¤t_buffer, + render_blur_segments(renderer, gl_matrix, &tempDamage, ¤t_buffer, &renderer->shaders.blur2, box, blur_radius); } @@ -256,7 +254,7 @@ struct fx_framebuffer *get_main_buffer_blur(struct fx_renderer *renderer, struct pixman_region32_fini(&damage); // Bind back to the default buffer - fx_framebuffer_bind(&renderer->main_buffer, monitor_box.width, monitor_box.height); + fx_framebuffer_bind(&renderer->main_buffer); return current_buffer; } @@ -493,7 +491,7 @@ void render_monitor_blur(struct sway_output *output, pixman_region32_t *damage) fx_renderer_clear(clear_color); } render_whole_output(renderer, wlr_output, &fake_damage, &buffer->texture); - fx_framebuffer_bind(&renderer->main_buffer, monitor_box.width, monitor_box.height); + fx_framebuffer_bind(&renderer->main_buffer); pixman_region32_fini(&fake_damage); @@ -1762,7 +1760,6 @@ void output_render(struct sway_output *output, struct timespec *when, int width, height; wlr_output_transformed_resolution(wlr_output, &width, &height); - fx_renderer_begin(renderer, width, height); if (debug.damage == DAMAGE_RERENDER) { @@ -1949,7 +1946,7 @@ render_overlay: renderer_end: // Draw the contents of our buffer into the wlr buffer - fx_framebuffer_bind(&renderer->wlr_buffer, width, height); + fx_framebuffer_bind(&renderer->wlr_buffer); float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f}; if (pixman_region32_not_empty(&extended_damage)) { int nrects;