Skip to content

Commit 556e12f

Browse files
authored
refactor: Slight refactor of textures.rs asm functions for consistency (#488)
1 parent c3cf9fe commit 556e12f

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

crates/spirv-std/src/textures.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ pub struct Image2d {
2424

2525
impl Image2d {
2626
#[spirv_std_macros::gpu_only]
27-
pub fn sample(&self, sampler: Sampler, coord: Vec2) -> Vec4 {
27+
pub fn sample(&self, sampler: Sampler, coordinate: Vec2) -> Vec4 {
2828
unsafe {
2929
let mut result = Default::default();
3030
asm!(
31-
"%image = OpLoad _ {1}",
32-
"%sampler = OpLoad _ {2}",
33-
"%coord = OpLoad _ {3}",
31+
"%image = OpLoad _ {this}",
32+
"%sampler = OpLoad _ {sampler}",
33+
"%coordinate = OpLoad _ {coordinate}",
3434
"%sampledImage = OpSampledImage _ %image %sampler",
35-
"%result = OpImageSampleImplicitLod _ %sampledImage %coord",
36-
"OpStore {0} %result",
37-
in(reg) &mut result,
38-
in(reg) self,
39-
in(reg) &sampler,
40-
in(reg) &coord
35+
"%result = OpImageSampleImplicitLod _ %sampledImage %coordinate",
36+
"OpStore {result} %result",
37+
result = in(reg) &mut result,
38+
this = in(reg) self,
39+
sampler = in(reg) &sampler,
40+
coordinate = in(reg) &coordinate,
4141
);
4242
result
4343
}
@@ -55,9 +55,9 @@ impl Image2d {
5555
"%coordinate = OpLoad _ {coordinate}",
5656
"%result = OpImageFetch typeof*{result} %image %coordinate",
5757
"OpStore {result} %result",
58+
result = in(reg) &mut result,
5859
this = in(reg) self,
5960
coordinate = in(reg) &coordinate,
60-
result = in(reg) &mut result,
6161
}
6262
}
6363

@@ -141,20 +141,20 @@ pub struct Image2dArray {
141141

142142
impl Image2dArray {
143143
#[spirv_std_macros::gpu_only]
144-
pub fn sample(&self, sampler: Sampler, coord: Vec3A) -> Vec4 {
144+
pub fn sample(&self, sampler: Sampler, coordinate: Vec3A) -> Vec4 {
145145
unsafe {
146146
let mut result = Default::default();
147147
asm!(
148-
"%image = OpLoad _ {1}",
149-
"%sampler = OpLoad _ {2}",
150-
"%coord = OpLoad _ {3}",
148+
"%image = OpLoad _ {this}",
149+
"%sampler = OpLoad _ {sampler}",
150+
"%coordinate = OpLoad _ {coordinate}",
151151
"%sampledImage = OpSampledImage _ %image %sampler",
152-
"%result = OpImageSampleImplicitLod _ %sampledImage %coord",
153-
"OpStore {0} %result",
154-
in(reg) &mut result,
155-
in(reg) self,
156-
in(reg) &sampler,
157-
in(reg) &coord
152+
"%result = OpImageSampleImplicitLod _ %sampledImage %coordinate",
153+
"OpStore {result} %result",
154+
result = in(reg) &mut result,
155+
this = in(reg) self,
156+
sampler = in(reg) &sampler,
157+
coordinate = in(reg) &coordinate,
158158
);
159159
result
160160
}
@@ -169,17 +169,17 @@ pub struct SampledImage<I> {
169169

170170
impl SampledImage<Image2d> {
171171
#[spirv_std_macros::gpu_only]
172-
pub fn sample(&self, coord: Vec2) -> Vec4 {
172+
pub fn sample(&self, coordinate: Vec2) -> Vec4 {
173173
unsafe {
174174
let mut result = Default::default();
175175
asm!(
176-
"%sampledImage = OpLoad _ {1}",
177-
"%coord = OpLoad _ {2}",
178-
"%result = OpImageSampleImplicitLod _ %sampledImage %coord",
179-
"OpStore {0} %result",
180-
in(reg) &mut result,
181-
in(reg) self,
182-
in(reg) &coord
176+
"%sampledImage = OpLoad _ {this}",
177+
"%coordinate = OpLoad _ {coordinate}",
178+
"%result = OpImageSampleImplicitLod _ %sampledImage %coordinate",
179+
"OpStore {result} %result",
180+
result = in(reg) &mut result,
181+
this = in(reg) self,
182+
coordinate = in(reg) &coordinate
183183
);
184184
result
185185
}

0 commit comments

Comments
 (0)