From 51c07a662a883352c888243ecada6a0c70b84919 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Mon, 27 Jan 2025 13:48:07 -0500 Subject: [PATCH] util/matrix: Simplify matrix_projection The transform argument is always passed WL_OUTPUT_TRANSFORM_FLIPPED_180 --- include/util/matrix.h | 6 ++---- render/gles2/pass.c | 3 +-- render/vulkan/pass.c | 4 +--- util/matrix.c | 14 +++----------- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/include/util/matrix.h b/include/util/matrix.h index e6197cecc..5c9db1634 100644 --- a/include/util/matrix.h +++ b/include/util/matrix.h @@ -31,12 +31,10 @@ void wlr_matrix_transform(float mat[static 9], void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box); /** - * Writes a 2D orthographic projection matrix to mat of (width, height) with a - * specified wl_output_transform. + * Writes a 2D orthographic projection matrix to mat of (width, height). * * Equivalent to glOrtho(0, width, 0, height, 1, -1) with the transform applied. */ -void matrix_projection(float mat[static 9], int width, int height, - enum wl_output_transform transform); +void matrix_projection(float mat[static 9], int width, int height); #endif diff --git a/render/gles2/pass.c b/render/gles2/pass.c index f27a6a755..a1a593fd9 100644 --- a/render/gles2/pass.c +++ b/render/gles2/pass.c @@ -327,8 +327,7 @@ struct wlr_gles2_render_pass *begin_gles2_buffer_pass(struct wlr_gles2_buffer *b pass->signal_point = signal_point; } - matrix_projection(pass->projection_matrix, wlr_buffer->width, wlr_buffer->height, - WL_OUTPUT_TRANSFORM_FLIPPED_180); + matrix_projection(pass->projection_matrix, wlr_buffer->width, wlr_buffer->height); push_gles2_debug(renderer); glBindFramebuffer(GL_FRAMEBUFFER, fbo); diff --git a/render/vulkan/pass.c b/render/vulkan/pass.c index 92c771f06..104fbda3c 100644 --- a/render/vulkan/pass.c +++ b/render/vulkan/pass.c @@ -1131,9 +1131,7 @@ struct wlr_vk_render_pass *vulkan_begin_render_pass(struct wlr_vk_renderer *rend .maxDepth = 1, }); - // matrix_projection() assumes a GL coordinate system so we need - // to pass WL_OUTPUT_TRANSFORM_FLIPPED_180 to adjust it for vulkan. - matrix_projection(pass->projection, width, height, WL_OUTPUT_TRANSFORM_FLIPPED_180); + matrix_projection(pass->projection, width, height); wlr_buffer_lock(buffer->wlr_buffer); pass->render_buffer = buffer; diff --git a/util/matrix.c b/util/matrix.c index d049b6ce3..d111926df 100644 --- a/util/matrix.c +++ b/util/matrix.c @@ -97,19 +97,11 @@ void wlr_matrix_transform(float mat[static 9], wlr_matrix_multiply(mat, mat, transforms[transform]); } -void matrix_projection(float mat[static 9], int width, int height, - enum wl_output_transform transform) { +void matrix_projection(float mat[static 9], int width, int height) { memset(mat, 0, sizeof(*mat) * 9); - const float *t = transforms[transform]; - float x = 2.0f / width; - float y = 2.0f / height; - - // Rotation + reflection - mat[0] = x * t[0]; - mat[1] = x * t[1]; - mat[3] = y * -t[3]; - mat[4] = y * -t[4]; + mat[0] = 2.0f / width; + mat[4] = 2.0f / height; // Translation mat[2] = -copysign(1.0f, mat[0] + mat[1]);