Skip to content

Commit dd0c512

Browse files
committed
derivative: rename derivative functions to match GLSL
1 parent 1151ec1 commit dd0c512

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

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

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ macro_rules! deriv_fn {
2121
/// Types that can be derived by partial derivatives
2222
pub unsafe trait Derivative: Sealed + Default {
2323
/// Result is the partial derivative of `Self` with respect to the window x coordinate. Uses local differencing
24-
/// based on the value of `Self`. Same result as either [`ddx_fine`] or [`ddx_coarse`] on `Self`. Selection of which
24+
/// based on the value of `Self`. Same result as either [`dfdx_fine`] or [`dfdx_coarse`] on `Self`. Selection of which
2525
/// one is based on external factors.
2626
///
2727
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
@@ -30,7 +30,7 @@ pub unsafe trait Derivative: Sealed + Default {
3030
/// This instruction is only valid in the Fragment Execution Model.
3131
#[crate::macros::gpu_only]
3232
#[inline]
33-
fn ddx(self) -> Self {
33+
fn dfdx(self) -> Self {
3434
deriv_fn!(OpDPdx, self)
3535
}
3636

@@ -43,27 +43,27 @@ pub unsafe trait Derivative: Sealed + Default {
4343
/// This instruction is only valid in the Fragment Execution Model.
4444
#[crate::macros::gpu_only]
4545
#[inline]
46-
fn ddx_fine(self) -> Self {
46+
fn dfdx_fine(self) -> Self {
4747
deriv_fn!(OpDPdxFine, self)
4848
}
4949

5050
/// Result is the partial derivative of `Self` with respect to the window x coordinate. Uses local differencing
5151
/// based on the value of `Self` for the current fragment’s neighbors, and possibly, but not necessarily, includes
5252
/// the value of `Self` for the current fragment. That is, over a given area, the implementation can compute x
53-
/// derivatives in fewer unique locations than would be allowed for [`ddx_fine`].
53+
/// derivatives in fewer unique locations than would be allowed for [`dfdx_fine`].
5454
///
5555
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
5656
/// derivative group have executed all dynamic instances that are program-ordered before X'.
5757
///
5858
/// This instruction is only valid in the Fragment Execution Model.
5959
#[crate::macros::gpu_only]
6060
#[inline]
61-
fn ddx_coarse(self) -> Self {
61+
fn dfdx_coarse(self) -> Self {
6262
deriv_fn!(OpDPdxCoarse, self)
6363
}
6464

6565
/// Result is the partial derivative of `Self` with respect to the window y coordinate. Uses local differencing
66-
/// based on the value of `Self`. Same result as either [`ddy_fine`] or [`ddy_coarse`] on `Self`. Selection of which
66+
/// based on the value of `Self`. Same result as either [`dfdy_fine`] or [`dfdy_coarse`] on `Self`. Selection of which
6767
/// one is based on external factors.
6868
///
6969
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
@@ -72,7 +72,7 @@ pub unsafe trait Derivative: Sealed + Default {
7272
/// This instruction is only valid in the Fragment Execution Model.
7373
#[crate::macros::gpu_only]
7474
#[inline]
75-
fn ddy(self) -> Self {
75+
fn dfdy(self) -> Self {
7676
deriv_fn!(OpDPdy, self)
7777
}
7878

@@ -85,26 +85,26 @@ pub unsafe trait Derivative: Sealed + Default {
8585
/// This instruction is only valid in the Fragment Execution Model.
8686
#[crate::macros::gpu_only]
8787
#[inline]
88-
fn ddy_fine(self) -> Self {
88+
fn dfdy_fine(self) -> Self {
8989
deriv_fn!(OpDPdyFine, self)
9090
}
9191

9292
/// Result is the partial derivative of `Self` with respect to the window y coordinate. Uses local differencing
9393
/// based on the value of `Self` for the current fragment’s neighbors, and possibly, but not necessarily, includes
9494
/// the value of `Self` for the current fragment. That is, over a given area, the implementation can compute y
95-
/// derivatives in fewer unique locations than would be allowed for [`ddy_fine`].
95+
/// derivatives in fewer unique locations than would be allowed for [`dfdy_fine`].
9696
///
9797
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
9898
/// derivative group have executed all dynamic instances that are program-ordered before X'.
9999
///
100100
/// This instruction is only valid in the Fragment Execution Model.
101101
#[crate::macros::gpu_only]
102102
#[inline]
103-
fn ddy_coarse(self) -> Self {
103+
fn dfdy_coarse(self) -> Self {
104104
deriv_fn!(OpDPdyCoarse, self)
105105
}
106106

107-
/// Result is the same as computing the sum of the absolute values of [`ddx`] and [`ddy`] on P.
107+
/// Result is the same as computing the sum of the absolute values of [`dfdx`] and [`dfdy`] on P.
108108
///
109109
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
110110
/// derivative group have executed all dynamic instances that are program-ordered before X'.
@@ -116,7 +116,7 @@ pub unsafe trait Derivative: Sealed + Default {
116116
deriv_fn!(OpFwidth, self)
117117
}
118118

119-
/// Result is the same as computing the sum of the absolute values of [`ddx_fine`] and [`ddy_fine`] on P.
119+
/// Result is the same as computing the sum of the absolute values of [`dfdx_fine`] and [`dfdy_fine`] on P.
120120
///
121121
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
122122
/// derivative group have executed all dynamic instances that are program-ordered before X'.
@@ -128,7 +128,7 @@ pub unsafe trait Derivative: Sealed + Default {
128128
deriv_fn!(OpFwidthFine, self)
129129
}
130130

131-
/// Result is the same as computing the sum of the absolute values of [`ddx_coarse`] and [`ddy_coarse`] on P.
131+
/// Result is the same as computing the sum of the absolute values of [`dfdx_coarse`] and [`dfdy_coarse`] on P.
132132
///
133133
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
134134
/// derivative group have executed all dynamic instances that are program-ordered before X'.

tests/ui/arch/derivative.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn main() {
1010
}
1111

1212
pub fn derivative() {
13-
Derivative::ddx(0.);
14-
Derivative::ddy(0.);
13+
Derivative::dfdx(0.);
14+
Derivative::dfdy(0.);
1515
Derivative::fwidth(0.);
1616
}

tests/ui/arch/derivative_control.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ pub fn main() {
1111
}
1212

1313
pub fn derivative() {
14-
Derivative::ddx_fine(0.);
15-
Derivative::ddy_fine(0.);
14+
Derivative::dfdx_fine(0.);
15+
Derivative::dfdy_fine(0.);
1616
Derivative::fwidth_fine(0.);
1717

18-
Derivative::ddx_coarse(0.);
19-
Derivative::ddy_coarse(0.);
18+
Derivative::dfdx_coarse(0.);
19+
Derivative::dfdy_coarse(0.);
2020
Derivative::fwidth_coarse(0.);
2121
}

0 commit comments

Comments
 (0)