Skip to content

Commit cb5c920

Browse files
committed
make image::fetch() implicitly declare lod 0
* glsl `texelFetch(sampler, coordinate, lod)` also takes the lod as an explicit parameter * naga doesn't understand texel fetch without explicit lod
1 parent 5719b27 commit cb5c920

File tree

7 files changed

+8
-22
lines changed

7 files changed

+8
-22
lines changed

crates/spirv-std/src/image.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,7 @@ impl<
143143
where
144144
I: Integer,
145145
{
146-
let mut result = SampledType::Vec4::default();
147-
unsafe {
148-
asm! {
149-
"OpDecorate %image NonUniform",
150-
"OpDecorate %result NonUniform",
151-
"%image = OpLoad _ {this}",
152-
"%coordinate = OpLoad _ {coordinate}",
153-
"%result = OpImageFetch typeof*{result} %image %coordinate",
154-
"OpStore {result} %result",
155-
result = in(reg) &mut result,
156-
this = in(reg) self,
157-
coordinate = in(reg) &coordinate,
158-
}
159-
}
160-
result.truncate_into()
146+
self.fetch_with_lod(coordinate, 0)
161147
}
162148

163149
/// Fetch a single texel at a mipmap `lod` with a sampler set at compile time

tests/compiletests/ui/image/gather_err.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | let r1: glam::Vec4 = image1d.gather(*sampler, 0.0f32, 0);
99
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
1010
Image<SampledType, 4, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
1111
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
12-
--> $SPIRV_STD_SRC/image.rs:212:15
12+
--> $SPIRV_STD_SRC/image.rs:198:15
1313
|
1414
LL | pub fn gather<F>(
1515
| ------ required by a bound in this associated function
@@ -28,7 +28,7 @@ LL | let r2: glam::Vec4 = image3d.gather(*sampler, v3, 0);
2828
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
2929
Image<SampledType, 4, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
3030
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
31-
--> $SPIRV_STD_SRC/image.rs:212:15
31+
--> $SPIRV_STD_SRC/image.rs:198:15
3232
|
3333
LL | pub fn gather<F>(
3434
| ------ required by a bound in this associated function

tests/compiletests/ui/image/query/query_levels_err.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | *output = image.query_levels();
1010
Image<SampledType, 2, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
1111
Image<SampledType, 3, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
1212
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_levels`
13-
--> $SPIRV_STD_SRC/image.rs:964:15
13+
--> $SPIRV_STD_SRC/image.rs:950:15
1414
|
1515
LL | pub fn query_levels(&self) -> u32
1616
| ------------ required by a bound in this associated function

tests/compiletests/ui/image/query/query_lod_err.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | *output = image.query_lod(*sampler, glam::Vec2::new(0.0, 1.0));
1010
Image<SampledType, 2, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
1111
Image<SampledType, 3, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
1212
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_lod`
13-
--> $SPIRV_STD_SRC/image.rs:993:15
13+
--> $SPIRV_STD_SRC/image.rs:979:15
1414
|
1515
LL | pub fn query_lod(
1616
| --------- required by a bound in this associated function

tests/compiletests/ui/image/query/query_size_err.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LL | *output = image.query_size();
1515
Image<SampledType, 2, DEPTH, ARRAYED, 0, 2, FORMAT, COMPONENTS>
1616
and 6 others
1717
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_size`
18-
--> $SPIRV_STD_SRC/image.rs:1028:15
18+
--> $SPIRV_STD_SRC/image.rs:1014:15
1919
|
2020
LL | pub fn query_size<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(&self) -> Size
2121
| ---------- required by a bound in this associated function

tests/compiletests/ui/image/query/query_size_lod_err.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | *output = image.query_size_lod(0);
1010
Image<SampledType, 2, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
1111
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
1212
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#7}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::query_size_lod`
13-
--> $SPIRV_STD_SRC/image.rs:1074:15
13+
--> $SPIRV_STD_SRC/image.rs:1060:15
1414
|
1515
LL | pub fn query_size_lod<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(
1616
| -------------- required by a bound in this associated function

tests/compiletests/ui/image/query/sampled_image_rect_query_size_lod_err.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | *output = rect_sampled.query_size_lod(0);
1010
Image<SampledType, 2, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
1111
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
1212
note: required by a bound in `SampledImage::<Image<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#9}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>>::query_size_lod`
13-
--> /image.rs:1239:12
13+
--> /image.rs:1225:12
1414
|
1515
LL | pub fn query_size_lod<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(
1616
| -------------- required by a bound in this associated function

0 commit comments

Comments
 (0)