Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9de7288

Browse files
nonuniform: unify image asm functions
1 parent d99cb68 commit 9de7288

File tree

6 files changed

+52
-46
lines changed

6 files changed

+52
-46
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 mutresult = 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 mutresult = 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/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: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(&self) -> Size
20+
941 | pub fn query_size<Size: ImageSizeQuery<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: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(
15+
982 | pub fn query_size_lod<Size: ImageSizeQuery<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

‎tests/compiletests/ui/image/query/sampled_image_rect_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 `SampledImage::<Image<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#9}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>>::query_size_lod`
13-
--> /image.rs:1138:12
13+
--> /image.rs:1144:12
1414
|
15-
1124 | pub fn query_size_lod<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(
15+
1130 | pub fn query_size_lod<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(
1616
| -------------- required by a bound in this associated function
1717
...
18-
1138 | >: HasQuerySizeLod,
18+
1144 | >: HasQuerySizeLod,
1919
| ^^^^^^^^^^^^^^^ required by this bound in `SampledImage::<Image<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#9}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>>::query_size_lod`
2020

2121
error: aborting due to 1 previous error

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /