Skip to content

Commit 7584a01

Browse files
Firestar99LegNeato
authored andcommitted
make image::fetch() implicitly declare lod 0
* glsl [`texelFetch(sampler, coordinate, lod)`](https://docs.gl/sl4/texelFetch) takes the lod as an explicit parameter, so you can't emit a texel fetch in glsl without explicit lod * naga doesn't understand texel fetch without explicit lod
1 parent 8eecf61 commit 7584a01

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
@@ -144,21 +144,7 @@ impl<
144144
where
145145
I: Integer,
146146
{
147-
let mut result = SampledType::Vec4::default();
148-
unsafe {
149-
asm! {
150-
"OpDecorate %image NonUniform",
151-
"OpDecorate %result NonUniform",
152-
"%image = OpLoad _ {this}",
153-
"%coordinate = OpLoad _ {coordinate}",
154-
"%result = OpImageFetch typeof*{result} %image %coordinate",
155-
"OpStore {result} %result",
156-
result = in(reg) &mut result,
157-
this = in(reg) self,
158-
coordinate = in(reg) &coordinate,
159-
}
160-
}
161-
result.truncate_into()
147+
self.fetch_with_lod(coordinate, 0)
162148
}
163149

164150
/// 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:214:15
12+
--> $SPIRV_STD_SRC/image.rs:200: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:214:15
31+
--> $SPIRV_STD_SRC/image.rs:200: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:985:15
13+
--> $SPIRV_STD_SRC/image.rs:971: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:1015:15
13+
--> $SPIRV_STD_SRC/image.rs:1001: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:1051:15
18+
--> $SPIRV_STD_SRC/image.rs:1037: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:1098:15
13+
--> $SPIRV_STD_SRC/image.rs:1084: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:1267:12
13+
--> /image.rs:1253: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)