linebender / linebender/vello

vello_hybrid: Extend calculation for images is wrong

Open
#1,590 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
4.3k
Forks
300
Avg merge
2d 13h
Merged PRs (30d)
61

Description

The following test case causes a huge mismatch between Vello CPU and Vello Hybrid:

#[vello_test(width = 100, height = 100)]
fn image_bilinear_probe_centered_pad(ctx: &mut impl Renderer) {
    let image_source = ctx.get_image_source(bilinear_probe_gradient());
    let image = Image {
        image: image_source,
        sampler: ImageSampler {
            x_extend: Extend::Pad,
            y_extend: Extend::Pad,
            quality: ImageQuality::Medium,
            alpha: 1.0,
        },
    };

    ctx.set_paint_transform(Affine::translate((47.5, 47.5)));
    ctx.set_paint(image);
    ctx.fill_rect(&Rect::new(10.0, 10.0, 90.0, 90.0));
}

Left is Vello CPU, right is Vello Hybrid:

Image

Vello CPU correctly renders the right part in fully red (255,0,0), while Vello Hybrid renders it as (223, 0 32). The problem is that in Vello hybrid, we first apply the extend to the coordinates and then apply the -0.5/+0.5 offsets for bilinear sampling. However, how it should be done (and how it is currently done in Vello CPU) is that each position for bilinear sampling is extended individually. Unfortunately, fixing this would probably make image rendering even slower than it already is...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating and running the image_bilinear_probe_centered_pad test case. Compare the Vello CPU and Vello Hybrid image-sampling paths, focusing on Extend::Pad and the bilinear sampling offsets. Done means Vello Hybrid matches Vello CPU at the padded edge, including the fully red pixels shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.