summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/glsl.meta.slang72
-rw-r--r--source/slang/hlsl.meta.slang124
2 files changed, 128 insertions, 68 deletions
diff --git a/source/slang/glsl.meta.slang b/source/slang/glsl.meta.slang
index 85c8b174c..0ea7d1c89 100644
--- a/source/slang/glsl.meta.slang
+++ b/source/slang/glsl.meta.slang
@@ -8898,23 +8898,7 @@ public vector<float, N> dFdyCoarse(vector<float, N> p)
[require(glsl_hlsl_spirv, fragmentprocessing_derivativecontrol)]
public float fwidthFine(float p)
{
- __requireComputeDerivative();
- __target_switch
- {
- case hlsl:
- {
- return abs(ddx_fine(p)) + abs(ddy_fine(p));
- }
- case glsl: __intrinsic_asm "fwidthFine($0)";
- case spirv:
- {
- return spirv_asm
- {
- OpCapability DerivativeControl;
- OpFwidthFine $$float result $p;
- };
- }
- }
+ return fwidth_fine(p);
}
__generic<let N : int>
[__NoSideEffect]
@@ -8922,23 +8906,7 @@ __generic<let N : int>
[require(glsl_hlsl_spirv, fragmentprocessing_derivativecontrol)]
public vector<float, N> fwidthFine(vector<float, N> p)
{
- __requireComputeDerivative();
- __target_switch
- {
- case hlsl:
- {
- return abs(ddx_fine(p)) + abs(ddy_fine(p));
- }
- case glsl: __intrinsic_asm "fwidthFine($0)";
- case spirv:
- {
- return spirv_asm
- {
- OpCapability DerivativeControl;
- OpFwidthFine $$vector<float, N> result $p;
- };
- }
- }
+ return fwidth_fine(p);
}
[__NoSideEffect]
@@ -8946,23 +8914,7 @@ public vector<float, N> fwidthFine(vector<float, N> p)
[require(glsl_hlsl_spirv, fragmentprocessing_derivativecontrol)]
public float fwidthCoarse(float p)
{
- __requireComputeDerivative();
- __target_switch
- {
- case hlsl:
- {
- return abs(ddx_coarse(p)) + abs(ddy_coarse(p));
- }
- case glsl: __intrinsic_asm "fwidthCoarse($0)";
- case spirv:
- {
- return spirv_asm
- {
- OpCapability DerivativeControl;
- OpFwidthCoarse $$float result $p;
- };
- }
- }
+ return fwidth_coarse(p);
}
__generic<let N : int>
[__NoSideEffect]
@@ -8970,23 +8922,7 @@ __generic<let N : int>
[require(glsl_hlsl_spirv, fragmentprocessing_derivativecontrol)]
public vector<float, N> fwidthCoarse(vector<float, N> p)
{
- __requireComputeDerivative();
- __target_switch
- {
- case hlsl:
- {
- return abs(ddx_coarse(p)) + abs(ddy_coarse(p));
- }
- case glsl: __intrinsic_asm "fwidthCoarse($0)";
- case spirv:
- {
- return spirv_asm
- {
- OpCapability DerivativeControl;
- OpFwidthCoarse $$vector<float, N> result $p;
- };
- }
- }
+ return fwidth_coarse(p);
}
[__NoSideEffect]
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index 3d83e33c1..0f04006e5 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -9940,6 +9940,130 @@ matrix<T, N, M> fwidth(matrix<T, N, M> x)
}
}
+/// Texture filter width (coarse).
+/// Calculates the sum abs(ddx_coarse(`p`)) + abs(ddy_coarse(`p`)).
+/// @param p The value to sum x and y partial derivative magnitudes for.
+/// @return The sum of abs(ddx_coarse(`p`)) and abs(ddy_coarse(`p`)).
+/// @remarks For SPIR-V, this function maps to `OpFwidthCoarse`.
+/// @category derivative
+__generic<T : __BuiltinFloatingPointType>
+[__readNone]
+[require(glsl_hlsl_spirv, fragmentprocessing_derivativecontrol)]
+T fwidth_coarse(T p)
+{
+ __requireComputeDerivative();
+ __target_switch
+ {
+ case hlsl:
+ __intrinsic_asm "abs(ddx_coarse($0)) + abs(ddy_coarse($0))";
+ case glsl:
+ __intrinsic_asm "fwidthCoarse($0)";
+ case spirv:
+ return spirv_asm
+ {
+ OpCapability DerivativeControl;
+ OpFwidthCoarse $$T result $p;
+ };
+ }
+}
+
+__generic<T : __BuiltinFloatingPointType, let N : int>
+[__readNone]
+[require(glsl_hlsl_spirv, fragmentprocessing_derivativecontrol)]
+vector<T, N> fwidth_coarse(vector<T, N> x)
+{
+ __requireComputeDerivative();
+ __target_switch
+ {
+ case hlsl:
+ __intrinsic_asm "abs(ddx_coarse($0)) + abs(ddy_coarse($0))";
+ case glsl:
+ __intrinsic_asm "fwidthCoarse($0)";
+ case spirv:
+ return spirv_asm
+ {
+ OpCapability DerivativeControl;
+ OpFwidthCoarse $$vector<T, N> result $x;
+ };
+ }
+}
+
+__generic<T : __BuiltinFloatingPointType, let N : int, let M : int>
+[__readNone]
+[require(glsl_hlsl_spirv, fragmentprocessing)]
+matrix<T, N, M> fwidth_coarse(matrix<T, N, M> x)
+{
+ __target_switch
+ {
+ case hlsl:
+ __intrinsic_asm "abs(ddx_coarse($0)) + abs(ddy_coarse($0))";
+ default:
+ MATRIX_MAP_UNARY(T, N, M, fwidth_coarse, x);
+ }
+}
+
+/// Texture filter width (fine).
+/// Calculates the sum abs(ddx_fine(`p`)) + abs(ddy_fine(`p`)).
+/// @param p The value to sum x and y partial derivative magnitudes for.
+/// @return The sum of abs(ddx_fine(`p`)) and abs(ddy_fine(`p`)).
+/// @remarks For SPIR-V, this function maps to `OpFwidthFine`.
+/// @category derivative
+__generic<T : __BuiltinFloatingPointType>
+[__readNone]
+[require(glsl_hlsl_spirv, fragmentprocessing_derivativecontrol)]
+T fwidth_fine(T p)
+{
+ __requireComputeDerivative();
+ __target_switch
+ {
+ case hlsl:
+ __intrinsic_asm "abs(ddx_fine($0)) + abs(ddy_fine($0))";
+ case glsl:
+ __intrinsic_asm "fwidthFine($0)";
+ case spirv:
+ return spirv_asm
+ {
+ OpCapability DerivativeControl;
+ OpFwidthFine $$T result $p;
+ };
+ }
+}
+
+__generic<T : __BuiltinFloatingPointType, let N : int>
+[__readNone]
+[require(glsl_hlsl_spirv, fragmentprocessing_derivativecontrol)]
+vector<T, N> fwidth_fine(vector<T, N> x)
+{
+ __requireComputeDerivative();
+ __target_switch
+ {
+ case hlsl:
+ __intrinsic_asm "abs(ddx_fine($0)) + abs(ddy_fine($0))";
+ case glsl:
+ __intrinsic_asm "fwidthFine($0)";
+ case spirv:
+ return spirv_asm
+ {
+ OpCapability DerivativeControl;
+ OpFwidthFine $$vector<T, N> result $x;
+ };
+ }
+}
+
+__generic<T : __BuiltinFloatingPointType, let N : int, let M : int>
+[__readNone]
+[require(glsl_hlsl_spirv, fragmentprocessing)]
+matrix<T, N, M> fwidth_fine(matrix<T, N, M> x)
+{
+ __target_switch
+ {
+ case hlsl:
+ __intrinsic_asm "abs(ddx_fine($0)) + abs(ddy_fine($0))";
+ default:
+ MATRIX_MAP_UNARY(T, N, M, fwidth_fine, x);
+ }
+}
+
__intrinsic_op($(kIROp_ResolveVaryingInputRef))
Ref<T> __ResolveVaryingInputRef<T>(__constref T attribute);