Skip to content

Conversation

@grebmeg
Copy link
Collaborator

@grebmeg grebmeg commented Dec 18, 2025

I find this report very useful! It looks like this:

{
  "pixel_count": 20,
  "max_difference": [
    1,
    3,
    1,
    0
  ],
  "pixels": [
    {
      "x": 14,
      "y": 10,
      "reference": [
        94,
        139,
        198,
        255
      ],
      "actual": [
        95,
        142,
        199,
        255
      ],
      "difference": [
        1,
        3,
        1,
        0
      ]
    },
  ]
}

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks interesting; having exactly what RGBA colour things worked out to is good. I think it could land as-is, but I'd like to see a few things changed. If you do change the formatting, please re-request my review.

One small question; I notice that your example data there should be 20 entries, but it only has one. Am I correct that the rest were elided for space?

Cargo.toml Outdated
Comment on lines 157 to 158
serde = { version = "1.0", default-features = false }
serde_json = "1.0"
Copy link
Member

@DJMcNab DJMcNab Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These version numbers should be fully specified. This is a blocker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Fixed.

let json_data = serde_json::to_string_pretty(&report).unwrap();
std::fs::write(&json_path, json_data).unwrap();

panic!("test didnt match reference image");
Copy link
Member

@DJMcNab DJMcNab Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we provide the path to the diff report in this error message? This is not a blocker.

I keep meaning to come back through and massively improve the UX of these, but that's not for this PR...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s really good advice, thank you!

I keep meaning to come back through and massively improve the UX of these, but that's not for this PR...

Honestly, I’ve already started on this and even have a branch with changes to the testing framework, including some API updates. I just haven’t had enough time to get it ready for review yet. If you’re keen, I’d be happy to share it.

Fixed.

Copy link
Member

@DJMcNab DJMcNab Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the UX of this kind of testing much less opaque is really helpful for contributors. I put a lot of care into that in Vello Classic's tests, which unfortunately didn't get carried into the sparse strips work.

When you have a PR, I can try and prioritise it.

Comment on lines +43 to +46
/// The RGBA values from the reference image.
pub reference: [u8; 4],
/// The RGBA values from the actual image.
pub actual: [u8; 4],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered serialising this as either #rrggbbaa or rgba(rrr, ggg, bbb, aaa) (i.e. as a string); I believe if we do that, vscode will show a colour picker as a preview. Plus, the formatting of the lines will be much shorter.

I think we can either do that with a custom serialise function (which would use https://docs.rs/serde/latest/serde/trait.Serializer.html#method.collect_str), or by storing the field as a String (which of course would be much more allocation intensive, and so wouldn't be my preferred solution).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I had been thinking about custom serialization from a slightly different angle, mainly focusing on putting the color data on single lines because it felt easier to read and compare. I hadn’t considered using #rrggbbaa, but that could definitely be worth adding alongside the current format. When I tried implementing it, things got a bit heavy, but I’m happy for this to be explored further, either by me or someone else as a follow-up later.

@grebmeg grebmeg force-pushed the gemberg/tests-diff-log-data branch from 52be151 to d9ec9a2 Compare December 22, 2025 01:31
Copy link
Collaborator Author

@grebmeg grebmeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small question; I notice that your example data there should be 20 entries, but it only has one. Am I correct that the rest were elided for space?

Yes, sorry for the confusion. I just omitted the rest from the snippet.

Cargo.toml Outdated
Comment on lines 157 to 158
serde = { version = "1.0", default-features = false }
serde_json = "1.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Fixed.

let json_data = serde_json::to_string_pretty(&report).unwrap();
std::fs::write(&json_path, json_data).unwrap();

panic!("test didnt match reference image");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s really good advice, thank you!

I keep meaning to come back through and massively improve the UX of these, but that's not for this PR...

Honestly, I’ve already started on this and even have a branch with changes to the testing framework, including some API updates. I just haven’t had enough time to get it ready for review yet. If you’re keen, I’d be happy to share it.

Fixed.

Comment on lines +43 to +46
/// The RGBA values from the reference image.
pub reference: [u8; 4],
/// The RGBA values from the actual image.
pub actual: [u8; 4],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I had been thinking about custom serialization from a slightly different angle, mainly focusing on putting the color data on single lines because it felt easier to read and compare. I hadn’t considered using #rrggbbaa, but that could definitely be worth adding alongside the current format. When I tried implementing it, things got a bit heavy, but I’m happy for this to be explored further, either by me or someone else as a follow-up later.

@grebmeg grebmeg changed the base branch from gemberg/perf/image-rendering-improvements to main December 22, 2025 01:51
@grebmeg grebmeg added this pull request to the merge queue Dec 22, 2025
Merged via the queue into main with commit c15340d Dec 22, 2025
17 checks passed
@grebmeg grebmeg deleted the gemberg/tests-diff-log-data branch December 22, 2025 02:03
DJMcNab added a commit to DJMcNab/vello that referenced this pull request Dec 22, 2025
Follow-up from
linebender#1328

The new formatting looks like:
```json
...
{
  "x": 1,
  "y": 18,
  "reference": "#ece5f2",
  "actual": "#bfffbf",
  "difference": [
    -45,
    26,
    -51,
    0
  ]
},
{
  "x": 2,
  "y": 1,
  "reference": "#d9cce5",
  "actual": "#7fff7f",
  "difference": [
    -90,
    51,
    -102,
    0
  ]
},
...
```
github-merge-queue bot pushed a commit that referenced this pull request Dec 23, 2025
Follow-up from #1328

The new formatting looks like:
```json
...
{
  "x": 1,
  "y": 18,
  "reference": "#ece5f2",
  "actual": "#bfffbf",
  "difference": [
    -45,
    26,
    -51,
    0
  ]
},
{
  "x": 2,
  "y": 1,
  "reference": "#d9cce5",
  "actual": "#7fff7f",
  "difference": [
    -90,
    51,
    -102,
    0
  ]
},
...
```

I've also tweaked the in-repo settings of vscode to show the colour
picker in these diff files:
<img width="348" height="241" alt="image"
src="https://github.com/user-attachments/assets/2ed7cb9f-f785-4e70-ac63-ae2fc2e2d950"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants