From bf0260de6107bb29a3c52897b7ffb6348b0fbbd1 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Wed, 18 Nov 2026 00:56:02 -0500 Subject: [PATCH] fix(effects): keep upscaling and sharpening at panel size with frame generation on (#2728) * fix(effects): keep upscaling and sharpening at panel size with frame generation on * fix(effects): stub sharpening query in the terminal callers probe --- .../main/cpp/waylandcomp/src/effects_chain.c | 4 +++ .../main/cpp/waylandcomp/src/effects_chain.h | 1 + app/src/main/cpp/waylandcomp/src/vk_present.c | 2 +- tools/tests/test_effects_source_resolution.py | 30 +++++++++++++++++-- tools/tests/vk_terminal_callers_test.c | 1 + 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/waylandcomp/src/effects_chain.c b/app/src/main/cpp/waylandcomp/src/effects_chain.c index 141a536229..385a46b322 100644 --- a/app/src/main/cpp/waylandcomp/src/effects_chain.c +++ b/app/src/main/cpp/waylandcomp/src/effects_chain.c @@ -155,6 +155,10 @@ int vkp_effects_upscaling(void) { return spatial_mode(g_cur.scaling) && g_cur.scaling != 6; } +int vkp_effects_sharpening(void) { + return vkp_effects_upscaling() || cas_active(&g_cur); +} + int vkp_effects_postprocessing(void) { vkp_effects_sync(); return effect_count(&g_cur) > 0; diff --git a/app/src/main/cpp/waylandcomp/src/effects_chain.h b/app/src/main/cpp/waylandcomp/src/effects_chain.h index 25f00225fc..bb1ca5ae1f 100644 --- a/app/src/main/cpp/waylandcomp/src/effects_chain.h +++ b/app/src/main/cpp/waylandcomp/src/effects_chain.h @@ -11,6 +11,7 @@ int vkp_effects_sync(void); int vkp_effects_active(void); int vkp_effects_upscaling(void); +int vkp_effects_sharpening(void); int vkp_effects_postprocessing(void); VkFilter vkp_effects_blit_filter(void); diff --git a/app/src/main/cpp/waylandcomp/src/vk_present.c b/app/src/main/cpp/waylandcomp/src/vk_present.c index 8c595d1711..53ddadaeb0 100644 --- a/app/src/main/cpp/waylandcomp/src/vk_present.c +++ b/app/src/main/cpp/waylandcomp/src/vk_present.c @@ -2179,7 +2179,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i VkImageLayout result_layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; if (fx) { int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f); - if (fg) { mapped_w = scene_w; mapped_h = scene_h; } + if (fg && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; } vkp_effects_set_formats(scene_fmt, scene_fmt); result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, &rw, &rh); effects_overlay_draws(cmd, result, rw, rh, scene_w, scene_h, diff --git a/tools/tests/test_effects_source_resolution.py b/tools/tests/test_effects_source_resolution.py index 043f392129..aae6052cec 100644 --- a/tools/tests/test_effects_source_resolution.py +++ b/tools/tests/test_effects_source_resolution.py @@ -33,7 +33,9 @@ class EffectsSourceResolutionTest(unittest.TestCase): 'static void effects_overlay_draws(', 'static int render_impl(', 'static int pass_begin_impl(')) functions = (re.search(r'static int spatial_mode\([^\n]+', effects).group() + '\n' + + re.search(r'static int cas_active\([^\n]+', effects).group() + '\n' + function(effects, 'int vkp_effects_upscaling(') + + function(effects, 'int vkp_effects_sharpening(') + function(effects, 'int vkp_effects_postprocessing(') + functions) image = source[source.index('struct vkp_image {'):source.index('\n};', source.index('struct vkp_image {')) + 3] draw = header[header.index('struct vkp_draw {'):header.index('\n};', header.index('struct vkp_draw {')) + 3] @@ -101,6 +103,9 @@ class EffectsSourceResolutionTest(unittest.TestCase): def test_postprocessing_keeps_foreground_inside_the_effect_chain(self): self.check_case('postprocessing') + def test_frame_generation_keeps_upscaling_and_sharpening_at_panel_size(self): + self.check_case('framegen-sharpening') + TYPES = r''' #include @@ -192,7 +197,8 @@ static struct vkp_img_slot g_hdrscene, g_fgscene; static struct { int active, rw, rh; VkImage result; } g_pass; static struct { int64_t present_ns, present_max_ns; unsigned presents; } g_perf; static int effects_active = 1, framegen, cardboard; -static struct { int scaling; } g_cur = {4}; +struct fx_settings { int scaling, cas_on, cas_pct; }; +static struct fx_settings g_cur = {4}; static int copy_count, effects_count, screen_count, hdr_count, fail_scene, fail_effects, postprocessing; static int copied_w, copied_h, target_w, target_h; static int effects_w, effects_h, output_w, output_h, logical_w, logical_h; @@ -276,7 +282,7 @@ static struct vkp_draw fullscreen(void) { } static void reset(void) { copy_count = effects_count = screen_count = hdr_count = barrier_count = 0; - effects_active = 1; g_cur.scaling = 4; + effects_active = 1; g_cur = (struct fx_settings){4}; framegen = cardboard = fail_scene = fail_effects = postprocessing = g_plain_frame = 0; g_pass.active = 0; g_extent = (VkExtent2D){1920, 1080}; image.w = 1280; image.h = 720; @@ -552,6 +558,25 @@ static void check_allocation(void) { assert(recorded_blits[1].dstOffsets[1].x == 1920 && recorded_blits[1].dstOffsets[1].y == 1080); assert(target_w == 1920 && target_h == 1080); } +static void check_framegen_output(int scaling, int cas, int grading, int panel) { + reset(); framegen = 1; postprocessing = grading; + g_cur = (struct fx_settings){scaling, cas, cas ? 60 : 0}; + g_extent = (VkExtent2D){2880, 1620}; + struct vkp_draw draw = fullscreen(); + run_path(0, &draw, 1, NULL); + assert(effects_count == 1); + assert(output_w == (panel ? 2880 : 1920) && output_h == (panel ? 1620 : 1080)); +} +static void check_framegen_sharpening(void) { + check_framegen_output(4, 0, 0, 1); + check_framegen_output(3, 0, 0, 1); + check_framegen_output(8, 0, 0, 1); + check_framegen_output(0, 1, 1, 1); + check_framegen_output(1, 1, 1, 1); + check_framegen_output(0, 0, 1, 0); + check_framegen_output(6, 0, 0, 0); + check_framegen_output(2, 0, 1, 0); +} int main(int argc, char **argv) { assert(argc == 2); reset(); if (!strcmp(argv[1], "helper")) check_helper(); @@ -567,6 +592,7 @@ int main(int argc, char **argv) { else if (!strcmp(argv[1], "effect-failure")) check_effect_failure(); else if (!strcmp(argv[1], "overlay-barriers")) check_overlay_barriers(); else if (!strcmp(argv[1], "postprocessing")) check_postprocessing(); + else if (!strcmp(argv[1], "framegen-sharpening")) check_framegen_sharpening(); else assert(0); puts("PASS"); } diff --git a/tools/tests/vk_terminal_callers_test.c b/tools/tests/vk_terminal_callers_test.c index c5857a7710..2398608bd2 100644 --- a/tools/tests/vk_terminal_callers_test.c +++ b/tools/tests/vk_terminal_callers_test.c @@ -72,6 +72,7 @@ PFN_vkGetInstanceProcAddr vk_loader_gipa(void) { return NULL; } void vkp_effects_bind_device(VkDevice d, VkPhysicalDevice p, const VkPhysicalDeviceMemoryProperties *m) {} int vkp_effects_active(void) { return 0; } int vkp_effects_upscaling(void) { return 0; } +int vkp_effects_sharpening(void) { return 0; } int vkp_effects_postprocessing(void) { return 0; } VkFilter vkp_effects_blit_filter(void) { return VK_FILTER_NEAREST; } void vkp_effects_set_formats(VkFormat a, VkFormat b) {}