Skip to content

Commit 395ed1a

Browse files
committed
nonuniform: unify image asm functions
1 parent 019cf7e commit 395ed1a

File tree

8 files changed

+55
-49
lines changed

8 files changed

+55
-49
lines changed

crates/spirv-std/src/image.rs

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -733,14 +733,16 @@ impl<
733733
) where
734734
I: Integer,
735735
{
736-
asm! {
737-
"%image = OpLoad _ {this}",
738-
"%coordinate = OpLoad _ {coordinate}",
739-
"%texels = OpLoad _ {texels}",
740-
"OpImageWrite %image %coordinate %texels",
741-
this = in(reg) self,
742-
coordinate = in(reg) &coordinate,
743-
texels = in(reg) &texels,
736+
unsafe {
737+
asm! {
738+
"%image = OpLoad _ {this}",
739+
"%coordinate = OpLoad _ {coordinate}",
740+
"%texels = OpLoad _ {texels}",
741+
"OpImageWrite %image %coordinate %texels",
742+
this = in(reg) self,
743+
coordinate = in(reg) &coordinate,
744+
texels = in(reg) &texels,
745+
}
744746
}
745747
}
746748
}
@@ -802,14 +804,16 @@ impl<
802804
) where
803805
I: Integer,
804806
{
805-
asm! {
806-
"%image = OpLoad _ {this}",
807-
"%coordinate = OpLoad _ {coordinate}",
808-
"%texels = OpLoad _ {texels}",
809-
"OpImageWrite %image %coordinate %texels",
810-
this = in(reg) self,
811-
coordinate = in(reg) &coordinate,
812-
texels = in(reg) &texels,
807+
unsafe {
808+
asm! {
809+
"%image = OpLoad _ {this}",
810+
"%coordinate = OpLoad _ {coordinate}",
811+
"%texels = OpLoad _ {texels}",
812+
"OpImageWrite %image %coordinate %texels",
813+
this = in(reg) self,
814+
coordinate = in(reg) &coordinate,
815+
texels = in(reg) &texels,
816+
}
813817
}
814818
}
815819
}
@@ -848,13 +852,13 @@ impl<
848852

849853
unsafe {
850854
asm! {
851-
"%image = OpLoad _ {this}",
852-
"%coordinate = OpLoad _ {coordinate}",
853-
"%result = OpImageRead typeof*{result} %image %coordinate",
854-
"OpStore {result} %result",
855-
this = in(reg) self,
856-
coordinate = in(reg) &coordinate,
857-
result = in(reg) &mut result,
855+
"%image = OpLoad _ {this}",
856+
"%coordinate = OpLoad _ {coordinate}",
857+
"%result = OpImageRead typeof*{result} %image %coordinate",
858+
"OpStore {result} %result",
859+
this = in(reg) self,
860+
coordinate = in(reg) &coordinate,
861+
result = in(reg) &mut result,
858862
}
859863
}
860864

@@ -880,13 +884,14 @@ impl<
880884
where
881885
Self: HasQueryLevels,
882886
{
883-
let result: u32;
887+
let mut result = Default::default();
884888
unsafe {
885889
asm! {
886890
"%image = OpLoad _ {this}",
887-
"{result} = OpImageQueryLevels typeof{result} %image",
891+
"%result = OpImageQueryLevels typeof*{result} %image",
892+
"OpStore {result} %result",
888893
this = in(reg) self,
889-
result = out(reg) result,
894+
result = in(reg) &mut result,
890895
}
891896
}
892897
result
@@ -1019,13 +1024,14 @@ impl<
10191024
#[crate::macros::gpu_only]
10201025
#[doc(alias = "OpImageQuerySamples")]
10211026
pub fn query_samples(&self) -> u32 {
1022-
let result: u32;
1027+
let mut result = Default::default();
10231028
unsafe {
10241029
asm! {
10251030
"%image = OpLoad _ {this}",
1026-
"{result} = OpImageQuerySamples typeof{result} %image",
1031+
"%result = OpImageQuerySamples typeof*{result} %image",
1032+
"OpStore {result} %result",
10271033
this = in(reg) self,
1028-
result = out(reg) result,
1034+
result = in(reg) &mut result,
10291035
}
10301036
}
10311037
result

tests/compiletests/ui/dis/non_uniform_load.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ OpDecorate %23 NonUniform
8181
%3 = OpVariable %26 Output
8282
%1 = OpFunction %27 None %28
8383
%42 = OpLabel
84-
OpLine %7 20 4
84+
OpLine %7 22 4
8585
%43 = OpLoad %24 %2
8686
OpLine %5 35 8
8787
%44 = OpAccessChain %29 %9 %43
@@ -142,7 +142,7 @@ OpLine %4 97 8
142142
%23 = OpInBoundsAccessChain %39 %45 %22
143143
%67 = OpLoad %24 %23
144144
%68 = OpCompositeConstruct %8 %62 %63 %64 %65 %66 %67
145-
OpLine %7 25 8
145+
OpLine %7 27 8
146146
OpStore %3 %68
147147
OpNoLine
148148
OpReturn

tests/compiletests/ui/dis/non_uniform_load_mut.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ OpDecorate %23 NonUniform
8080
%3 = OpVariable %26 Output
8181
%1 = OpFunction %27 None %28
8282
%42 = OpLabel
83-
OpLine %7 20 4
83+
OpLine %7 22 4
8484
%43 = OpLoad %24 %2
8585
OpLine %5 56 8
8686
%44 = OpAccessChain %29 %9 %43
@@ -141,7 +141,7 @@ OpLine %4 97 8
141141
%23 = OpInBoundsAccessChain %39 %45 %22
142142
%67 = OpLoad %24 %23
143143
%68 = OpCompositeConstruct %8 %62 %63 %64 %65 %66 %67
144-
OpLine %7 25 8
144+
OpLine %7 27 8
145145
OpStore %3 %68
146146
OpNoLine
147147
OpReturn

tests/compiletests/ui/dis/non_uniform_store.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ OpDecorate %23 NonUniform
8181
%41 = OpConstant %24 3
8282
%1 = OpFunction %27 None %28
8383
%42 = OpLabel
84-
OpLine %7 20 4
84+
OpLine %7 22 4
8585
%43 = OpLoad %24 %2
86-
OpLine %7 21 4
86+
OpLine %7 23 4
8787
%44 = OpLoad %8 %3
8888
OpLine %5 56 8
8989
%45 = OpAccessChain %29 %9 %43

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ error[E0277]: the trait bound `Image<f32, 4, 2, 0, 0, 1, 0, 4>: HasQueryLevels`
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:881:15
13+
--> $SPIRV_STD_SRC/image.rs:885:15
1414
|
15-
879 | pub fn query_levels(&self) -> u32
15+
883 | pub fn query_levels(&self) -> u32
1616
| ------------ required by a bound in this associated function
17-
880 | where
18-
881 | Self: HasQueryLevels,
17+
884 | where
18+
885 | Self: HasQueryLevels,
1919
| ^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_levels`
2020

2121
error: aborting due to 1 previous error

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ error[E0277]: the trait bound `Image<f32, 4, 2, 0, 0, 1, 0, 4>: HasQueryLevels`
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:907:15
13+
--> $SPIRV_STD_SRC/image.rs:912:15
1414
|
15-
901 | pub fn query_lod(
15+
906 | pub fn query_lod(
1616
| --------- required by a bound in this associated function
1717
...
18-
907 | Self: HasQueryLevels,
18+
912 | Self: HasQueryLevels,
1919
| ^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_lod`
2020

2121
error: aborting due to 1 previous error

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ error[E0277]: the trait bound `Image<f32, 1, 2, 0, 0, 1, 0, 4>: HasQuerySize` is
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:938:15
18+
--> $SPIRV_STD_SRC/image.rs:943:15
1919
|
20-
936 | pub fn query_size<Size: ImageCoordinate<u32, DIM, ARRAYED> + Default>(&self) -> Size
20+
941 | pub fn query_size<Size: ImageCoordinate<u32, DIM, ARRAYED> + Default>(&self) -> Size
2121
| ---------- required by a bound in this associated function
22-
937 | where
23-
938 | Self: HasQuerySize,
22+
942 | where
23+
943 | Self: HasQuerySize,
2424
| ^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_size`
2525

2626
error: aborting due to 1 previous error

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ error[E0277]: the trait bound `Image<f32, 4, 2, 0, 0, 1, 0, 4>: HasQuerySizeLod`
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:982:15
13+
--> $SPIRV_STD_SRC/image.rs:987:15
1414
|
15-
977 | pub fn query_size_lod<Size: ImageCoordinate<u32, DIM, ARRAYED> + Default>(
15+
982 | pub fn query_size_lod<Size: ImageCoordinate<u32, DIM, ARRAYED> + Default>(
1616
| -------------- required by a bound in this associated function
1717
...
18-
982 | Self: HasQuerySizeLod,
18+
987 | Self: HasQuerySizeLod,
1919
| ^^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#7}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::query_size_lod`
2020

2121
error: aborting due to 1 previous error

0 commit comments

Comments
 (0)