SPIR-V derivative instructions include OpDPdx
, OpDPdy
,
OpDPdxFine
, OpDPdyFine
, OpDPdxCoarse
, and OpDPdyCoarse
.
Derivative instructions are only available in a fragment shader.
Derivatives are computed as if there is a 2x2 neighborhood of fragments for each fragment shader invocation. These neighboring fragments are used to compute derivatives with the assumption that the values of P in the neighborhood are piecewise linear. It is further assumed that the values of P in the neighborhood are locally continuous, therefore derivatives in non-uniform control flow are undefined.
The Fine
derivative instructions must return the values above, for a
group of fragments in a 2x2 neighborhood.
Coarse derivatives may return only two values.
In this case, the values should be:
OpDPdx
and OpDPdy
must return the same result as either
OpDPdxFine
or OpDPdxCoarse
and either OpDPdyFine
or
OpDPdyCoarse
, respectively.
Implementations must make the same choice of either coarse or fine for both
OpDPdx
and OpDPdy
, and implementations should make the choice
that is more efficient to compute.