summaryrefslogtreecommitdiff
path: root/src/modules/swab
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-12-31 14:30:56 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-12-31 14:33:32 -0800
commit3d6ba50682bb1384eb487789275f95c87930944c (patch)
tree515a0a9314729b37efb8dcc7e0461548d64ca587 /src/modules/swab
parenteae8514b9b31b0d09fc82450a74c7e53067ff701 (diff)
modules/swab: update sample coords piecemeal
Now that din() leaves the input coordinate alone as a const, the rendering loop can reuse the unchanging members across din() calls and only refresh the changing members as needed. Good for a small 62->64FPS boost on the i7 X230 in `--module=swab --video=mem --defaults` tests
Diffstat (limited to 'src/modules/swab')
-rw-r--r--src/modules/swab/swab.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/modules/swab/swab.c b/src/modules/swab/swab.c
index c4f1c91..952046d 100644
--- a/src/modules/swab/swab.c
+++ b/src/modules/swab/swab.c
@@ -114,21 +114,42 @@ static void swab_render_fragment(til_module_context_t *context, til_stream_t *st
float xscale = 1.f / (float)fragment->frame_width;
float yscale = 1.f / (float)fragment->frame_height;
float yscaled;
+ v3f_t t_coord = {
+ .z = -z2
+ };
+ v3f_t r_coord = {
+ .z = z1
+ };
+ v3f_t g_coord = {
+ .z = -z1
+ };
+ v3f_t b_coord = {
+ .z = z2
+ };
yscaled = (float)fragment->y * yscale;
for (unsigned y = 0; y < frag_h; y++, yscaled += yscale) {
float xscaled = (float)fragment->x * xscale;
+ t_coord.y = yscaled * .5f;
+ r_coord.y = yscaled * .7f;
+ g_coord.y = yscaled * .93f;
+ b_coord.y = yscaled * .81f;
+
for (unsigned x = 0; x < frag_w; x++, xscaled += xscale) {
color_t color;
uint32_t pixel;
float t;
- t = din(ctxt->din, &(v3f_t){ .x = xscaled * .5f, .y = yscaled * .5f, .z = -z2 }) * 33.f;
+ t_coord.x = xscaled * .5f;
+ r_coord.x = xscaled * .7f;
+ g_coord.x = xscaled * .93f;
+ b_coord.x = xscaled * .81f;
- color.r = din(ctxt->din, &(v3f_t){ .x = xscaled * .7f, .y = yscaled * .7f, .z = z1 }) * t;
- color.g = din(ctxt->din, &(v3f_t){ .x = xscaled * .93f, .y = yscaled * .93f, .z = -z1 }) * t;
- color.b = din(ctxt->din, &(v3f_t){ .x = xscaled * .81f, .y = yscaled * .81f, .z = z2 }) * t;
+ t = din(ctxt->din, &t_coord) * 33.f;
+ color.r = din(ctxt->din, &r_coord) * t;
+ color.g = din(ctxt->din, &g_coord) * t;
+ color.b = din(ctxt->din, &b_coord) * t;
pixel = color_to_uint32(color);
til_fb_fragment_put_pixel_unchecked(fragment, 0, fragment->x + x, fragment->y + y, pixel);
© All Rights Reserved