Skip to content

Commit 1151ec1

Browse files
committed
derivative: do not implicitly turn on OpCapability DerivativeControl, fix warnings
1 parent 7a43090 commit 1151ec1

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

crates/spirv-std/src/arch/derivative.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
use crate::sealed::Sealed;
22
use glam::{Vec2, Vec3, Vec3A, Vec4};
33

4-
macro_rules! cap_deriv_control {
5-
() => {
6-
unsafe {
7-
core::arch::asm!("OpCapability DerivativeControl");
8-
}
9-
};
10-
}
11-
4+
#[cfg(target_arch = "spirv")]
125
macro_rules! deriv_fn {
136
($inst:ident, $param:expr) => {
147
unsafe {
@@ -51,7 +44,6 @@ pub unsafe trait Derivative: Sealed + Default {
5144
#[crate::macros::gpu_only]
5245
#[inline]
5346
fn ddx_fine(self) -> Self {
54-
cap_deriv_control!();
5547
deriv_fn!(OpDPdxFine, self)
5648
}
5749

@@ -67,7 +59,6 @@ pub unsafe trait Derivative: Sealed + Default {
6759
#[crate::macros::gpu_only]
6860
#[inline]
6961
fn ddx_coarse(self) -> Self {
70-
cap_deriv_control!();
7162
deriv_fn!(OpDPdxCoarse, self)
7263
}
7364

@@ -95,7 +86,6 @@ pub unsafe trait Derivative: Sealed + Default {
9586
#[crate::macros::gpu_only]
9687
#[inline]
9788
fn ddy_fine(self) -> Self {
98-
cap_deriv_control!();
9989
deriv_fn!(OpDPdyFine, self)
10090
}
10191

@@ -111,7 +101,6 @@ pub unsafe trait Derivative: Sealed + Default {
111101
#[crate::macros::gpu_only]
112102
#[inline]
113103
fn ddy_coarse(self) -> Self {
114-
cap_deriv_control!();
115104
deriv_fn!(OpDPdyCoarse, self)
116105
}
117106

@@ -136,7 +125,6 @@ pub unsafe trait Derivative: Sealed + Default {
136125
#[crate::macros::gpu_only]
137126
#[inline]
138127
fn fwidth_fine(self) -> Self {
139-
cap_deriv_control!();
140128
deriv_fn!(OpFwidthFine, self)
141129
}
142130

@@ -149,7 +137,6 @@ pub unsafe trait Derivative: Sealed + Default {
149137
#[crate::macros::gpu_only]
150138
#[inline]
151139
fn fwidth_coarse(self) -> Self {
152-
cap_deriv_control!();
153140
deriv_fn!(OpFwidthCoarse, self)
154141
}
155142
}

tests/ui/arch/derivative.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 41 8
3+
OpLine %5 34 8
44
%6 = OpDPdx %7 %8
5-
OpLine %5 85 8
5+
OpLine %5 76 8
66
%9 = OpDPdy %7 %8
7-
OpLine %5 127 8
7+
OpLine %5 116 8
88
%10 = OpFwidth %7 %8
99
OpNoLine
1010
OpReturn

tests/ui/arch/derivative_control.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 55 8
3+
OpLine %5 47 8
44
%6 = OpDPdxFine %7 %8
5-
OpLine %5 99 8
5+
OpLine %5 89 8
66
%9 = OpDPdyFine %7 %8
7-
OpLine %5 140 8
7+
OpLine %5 128 8
88
%10 = OpFwidthFine %7 %8
9-
OpLine %5 71 8
9+
OpLine %5 62 8
1010
%11 = OpDPdxCoarse %7 %8
11-
OpLine %5 115 8
11+
OpLine %5 104 8
1212
%12 = OpDPdyCoarse %7 %8
13-
OpLine %5 153 8
13+
OpLine %5 140 8
1414
%13 = OpFwidthCoarse %7 %8
1515
OpNoLine
1616
OpReturn

0 commit comments

Comments
 (0)