Skip to content

Add Image::fetch_with_lod - #361

Merged
LegNeato merged 6 commits into
Rust-GPU:mainfrom
caibear:fetch_with_level
Aug 17, 2025
Merged

Add Image::fetch_with_lod#361
LegNeato merged 6 commits into
Rust-GPU:mainfrom
caibear:fetch_with_level

Conversation

@caibear

Copy link
Copy Markdown
Contributor

Fixes#360

I used the terminology level since that's what WGSL used, but it would also make sense to use lod since that's what SPIR-V and GLSL's texelFetch use.

@schellschell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good, thank you!

@Firestar99Firestar99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can already fetch image texels with additional settings, like lod, bias, grad and sampleIndex. And naga for some reason requires explicitly fetching from lod 0, like below.

use spirv_std::image::sample_with::lod;use spirv_std::image::{Image2d,ImageWithMethods};
mask_texture.fetch_with(frag_coord.xy().as_uvec2(),lod(0))

Also I'd call it lod since we're following spirv / glsl naming conventions.

You may also find this thing I've been working on useful: #280

@LegNeatoLegNeato changed the title Add Image::fetch_with_levelAdd Image::fetch_with_lodAug 12, 2025
@LegNeato

Copy link
Copy Markdown
Collaborator

Not required, but it would be nice to put "level" somewhere as a doc alias (or even in the comment) so it comes up if folks search the webgpu terminology.

@schellschell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yup, this makes sense now 👍

@LegNeato

Copy link
Copy Markdown
Collaborator

Looks like some compiletests are failing. You should be able to run them locally with cargo compiletest.

@LegNeatoLegNeato left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CI failures

@caibear

Copy link
Copy Markdown
ContributorAuthor

CI failures

The test I added passes on my local machine. The CI failures look unrelated to the changes I made, so I'm not sure how to fix them. The tests that are failing appear to be tests that are supposed to cause compile errors being erroneously marked as failing.

failures:
[ui] ui/image/gather_err.rs
[ui] ui/image/query/query_levels_err.rs
[ui] ui/image/query/query_lod_err.rs
[ui] ui/image/query/query_size_err.rs
[ui] ui/image/query/query_size_lod_err.rs

@LegNeato

LegNeato commented Aug 16, 2025

Copy link
Copy Markdown
Collaborator

It looks like the line numbers when it refers to that file changed, so it affects other tests that refer to those files with error messages. You can run cargo compiletest --bless to update the tests I believe

@LegNeato
LegNeato merged commit b320baf into Rust-GPU:mainAug 17, 2025
13 checks passed
Sign up for freeto 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.

Image fetch with level

4 participants

@caibear@LegNeato@schell@Firestar99