diff --git a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs index 0d68fc03..3ae91639 100644 --- a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs +++ b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs @@ -39,7 +39,7 @@ internal static partial class BlasHelpers for (int k = 0; k < m; k++) { - result += Unsafe.Add(ref rx, x_offset + k) * Unsafe.Add(ref rw, k * p + j); + result += Unsafe.Add(ref rx, x_offset + k) * Unsafe.Add(ref rw, (k * p) + j); } Unsafe.Add(ref ry, y_offset + j) = result + Unsafe.Add(ref rb, j); @@ -94,15 +94,15 @@ internal static partial class BlasHelpers /// public void Execute() { - int x_offset = ThreadIds.X * n * p + ThreadIds.Y * m; + int x_offset = (ThreadIds.X * n * p) + (ThreadIds.Y * m); float result = 0f; for (int k = 0; k < m; k++) { - result += x[x_offset + k] * w[k * p + ThreadIds.Z]; + result += x[x_offset + k] * w[(k * p) + ThreadIds.Z]; } - y[ThreadIds.X * n * p + ThreadIds.Y * p + ThreadIds.Z] = result + b[ThreadIds.Z]; + y[(ThreadIds.X * n * p) + (ThreadIds.Y * p) + ThreadIds.Z] = result + b[ThreadIds.Z]; } } } \ No newline at end of file diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs index b438da57..fe46d6d0 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs @@ -72,7 +72,7 @@ public sealed partial class HlslBokehBlurProcessor { graphicsDevice = definition.GraphicsDevice; radius = definition.Radius; - kernelSize = radius * 2 + 1; + kernelSize = (radius * 2) + 1; componentsCount = definition.Components; // Reuse the initialized values from the cache, if possible @@ -239,8 +239,8 @@ public sealed partial class HlslBokehBlurProcessor ref Complex64 kRef = ref Unsafe.Add(ref valueRef, k); total += - paramsRef.Z * (jRef.Real * kRef.Real - jRef.Imaginary * kRef.Imaginary) - + paramsRef.W * (jRef.Real * kRef.Imaginary + jRef.Imaginary * kRef.Real); + (paramsRef.Z * ((jRef.Real * kRef.Real) - (jRef.Imaginary * kRef.Imaginary))) + + (paramsRef.W * ((jRef.Real * kRef.Imaginary) + (jRef.Imaginary * kRef.Real))); } } } @@ -378,8 +378,8 @@ public sealed partial class HlslBokehBlurProcessor float4 sourceImaginary = imaginaries[offsetX, offsetY]; Complex64 factors = kernel[i]; - result.Real += (Vector4)(factors.Real * sourceReal - factors.Imaginary * sourceImaginary); - result.Imaginary += (Vector4)(factors.Real * sourceImaginary + factors.Imaginary * sourceReal); + result.Real += (Vector4)((factors.Real * sourceReal) - (factors.Imaginary * sourceImaginary)); + result.Imaginary += (Vector4)((factors.Real * sourceImaginary) + (factors.Imaginary * sourceReal)); } target[ThreadIds.XY] += (float4)result.WeightedSum(z, w); diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs index dd029b2e..c7aebcce 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs @@ -36,7 +36,7 @@ public sealed partial class HlslGaussianBlurProcessor public Implementation(HlslGaussianBlurProcessor definition, Configuration configuration, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) { - int kernelSize = definition.Radius * 2 + 1; + int kernelSize = (definition.Radius * 2) + 1; graphicsDevice = definition.graphicsDevice; kernel = CreateGaussianBlurKernel(kernelSize, definition.Sigma); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs index e8fa6ca3..9dbc5e8a 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs @@ -40,7 +40,7 @@ internal readonly partial struct ColorfulInfinity : IPixelShader for (int i = 0; i++ < NumberOfIterations;) { - o.XZYW = Hlsl.Abs(o / Hlsl.Dot(o, o) - dec); + o.XZYW = Hlsl.Abs((o / Hlsl.Dot(o, o)) - dec); } return o; @@ -49,7 +49,7 @@ internal readonly partial struct ColorfulInfinity : IPixelShader /// public float4 Execute() { - float2 uv = (ThreadIds.XY - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y; + float2 uv = (ThreadIds.XY - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y; float3 col = 0; float t = time * 0.3f; diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs index db95adc0..2dbc441f 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs @@ -34,7 +34,7 @@ internal readonly partial struct ContouredLayers : IPixelShader p = Hlsl.Frac(new float2(262144, 32768) * n); - return Hlsl.Sin(p * 6.2831853f + time); + return Hlsl.Sin((p * 6.2831853f) + time); } // float2 to float2 hash. @@ -42,7 +42,7 @@ internal readonly partial struct ContouredLayers : IPixelShader { float n = Hlsl.Sin(Hlsl.Dot(p, new float2(41, 289))); - return Hlsl.Frac(new float2(262144, 32768) * n) * 2.0f - 1.0f; + return (Hlsl.Frac(new float2(262144, 32768) * n) * 2.0f) - 1.0f; } // Smooth 2D noise @@ -59,7 +59,7 @@ internal readonly partial struct ContouredLayers : IPixelShader v.Z = Hlsl.Dot(Hash22B(i + float2.UnitY), p - float2.UnitY); v.W = Hlsl.Dot(Hash22B(i + 1.0f), p - 1.0f); - p = p * p * (3.0f - 2.0f * p); + p = p * p * (3.0f - (2.0f * p)); return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y); } @@ -78,7 +78,7 @@ internal readonly partial struct ContouredLayers : IPixelShader v.Z = Hlsl.Dot(Hash22(i + float2.UnitY), p - float2.UnitY); v.W = Hlsl.Dot(Hash22(i + 1.0f), p - 1.0f); - p = p * p * p * (p * (p * 6.0f - 15.0f) + 10.0f); + p = p * p * p * ((p * ((p * 6.0f) - 15.0f)) + 10.0f); return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y); } @@ -86,7 +86,7 @@ internal readonly partial struct ContouredLayers : IPixelShader // Map function with noise layers private float MapNoise(float3 p, float i) { - return Noise2D3G(p.XY * 3.0f) * 0.66f + Noise2D3G(p.XY * 6.0f) * 0.34f + i / 10.0f * 1.0f - 0.15f; + return (Noise2D3G(p.XY * 3.0f) * 0.66f) + (Noise2D3G(p.XY * 6.0f) * 0.34f) + (i / 10.0f * 1.0f) - 0.15f; } // 2D derivative function. @@ -117,7 +117,7 @@ internal readonly partial struct ContouredLayers : IPixelShader float3 col; - col = (float3)1.0 * (1.0f - 0.75f / (1.0f + sh * sh * 2.0f)); + col = (float3)1.0 * (1.0f - (0.75f / (1.0f + (sh * sh * 2.0f)))); col = Hlsl.Min(col * tx * 3.0f, 1.0f); return col; @@ -128,12 +128,12 @@ internal readonly partial struct ContouredLayers : IPixelShader { p *= res / 16.0f; - float hatch = Hlsl.Clamp(Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f + 0.5f, 0.0f, 1.0f); + float hatch = Hlsl.Clamp((Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f) + 0.5f, 0.0f, 1.0f); float hRnd = Hash21(Hlsl.Floor(p * 6.0f) + 0.73f); if (hRnd > 0.66f) hatch = hRnd; - hatch = hatch * 0.75f + 0.5f; + hatch = (hatch * 0.75f) + 0.5f; return hatch; } @@ -143,7 +143,7 @@ internal readonly partial struct ContouredLayers : IPixelShader { float2 fragCoord = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y); float res = Hlsl.Min(DispatchSize.Y, 700.0f); - float2 uv = (fragCoord - (float2)DispatchSize.XY * 0.5f) / res; + float2 uv = (fragCoord - ((float2)DispatchSize.XY * 0.5f)) / res; float sf = 1.0f / DispatchSize.Y; float3 col = GetColor(uv, 0.0f, 0.0f); float pL = 0.0f; @@ -161,7 +161,7 @@ internal readonly partial struct ContouredLayers : IPixelShader hatch = Hatch(uv + Hlsl.Sin(new float2(41.0f, 289.0f) * (fi + 1.0f)), res); float4 c = MapLayer(new float3(uv, 1.0f), fi); - float4 cSh = MapLayer(new float3(uv - new float2(0.03f, -0.03f) * ((flNum - fi) / flNum * 0.5f + 0.5f), 1.0f), fi); + float4 cSh = MapLayer(new float3(uv - (new float2(0.03f, -0.03f) * (((flNum - fi) / flNum * 0.5f) + 0.5f)), 1.0f), fi); float sh = (fi + 1.0f) / (flNum); float3 lCol = GetColor(uv, sh, fi + 1.0f); float3 ld = Hlsl.Normalize(new float3(-1, 1, -0.25f)); @@ -178,17 +178,17 @@ internal readonly partial struct ContouredLayers : IPixelShader col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sfLSh, Hlsl.Max(cSh.X, pL))) * shF); col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sfL * 3.0f, c.X)) * 0.25f); col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X)) * 0.85f); - col = Hlsl.Lerp(col, eCol * hatch, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + Hlsl.Length(c.YZX) * 0.003f))); - col = Hlsl.Lerp(col, lCol * hatch, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + Hlsl.Length(c.YZX) * 0.006f))); + col = Hlsl.Lerp(col, eCol * hatch, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + (Hlsl.Length(c.YZX) * 0.003f)))); + col = Hlsl.Lerp(col, lCol * hatch, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + (Hlsl.Length(c.YZX) * 0.006f)))); pL = c.X; } col *= Hlsl.Lerp(new float3(1.8f, 1, 0.7f).ZYX, new float3(1.8f, 1, 0.7f).XZY, Noise2D(uv * 2.0f)); - float3 rn3 = Noise2D(uv * DispatchSize.Y / 1.0f + 1.7f) - Noise2D(uv * DispatchSize.Y / 1.0f + 3.4f); + float3 rn3 = Noise2D((uv * DispatchSize.Y / 1.0f) + 1.7f) - Noise2D((uv * DispatchSize.Y / 1.0f) + 3.4f); - col *= 0.93f + 0.07f * rn3.XYZ + 0.07f * Hlsl.Dot(rn3, new float3(0.299f, 0.587f, 0.114f)); + col *= 0.93f + (0.07f * rn3.XYZ) + (0.07f * Hlsl.Dot(rn3, new float3(0.299f, 0.587f, 0.114f))); uv = fragCoord / DispatchSize.XY; diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs index 4caa2fbf..b10a58d4 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs @@ -52,7 +52,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader switch (SHAPE) { - case 1: return Hlsl.Max(Hlsl.Length(p), (p.X + p.Y) * 0.7071f + 0.015f); + case 1: return Hlsl.Max(Hlsl.Length(p), ((p.X + p.Y) * 0.7071f) + 0.015f); case 2: return Hlsl.Max((p.X + p.Y) * 0.7071f, Hlsl.Max(p.X, p.Y)); case 3: return Hlsl.Pow(Hlsl.Dot(Hlsl.Pow(p, 3), 1), 1.0f / 3.0f); default: return (p.X + p.Y) * 0.7071f; @@ -62,7 +62,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader // GLSL's mod function private static float Mod(float x, float y) { - return x - y * Hlsl.Floor(x / y); + return x - (y * Hlsl.Floor(x / y)); } // A standard square grid 2D blobby Truchet routine: Render circles @@ -79,11 +79,11 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader if (rnd < 0.5f) p.Y = -p.Y; - float d = Hlsl.Min(Distance(p - 0.5f * sc), Distance(p + 0.5f * sc)) - 0.5f * sc; + float d = Hlsl.Min(Distance(p - (0.5f * sc)), Distance(p + (0.5f * sc))) - (0.5f * sc); if (SHAPE == 4) { - d += (0.5f - 0.5f / Hlsl.Sqrt(2.0f)) * sc; + d += (0.5f - (0.5f / Hlsl.Sqrt(2.0f))) * sc; } if (rnd < 0.5f) d = -d; @@ -100,18 +100,18 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader float fl = -p.Z; float obj = Truchet(p.XY); - obj = Hlsl.Max(obj, Hlsl.Abs(p.Z) - 0.125f) - Hlsl.SmoothStep(0.03f, 0.25f, -obj) * 0.1f; + obj = Hlsl.Max(obj, Hlsl.Abs(p.Z) - 0.125f) - (Hlsl.SmoothStep(0.03f, 0.25f, -obj) * 0.1f); float studs = 1e5f; const float sc = 0.5f; - float2 q = p.XY + 0.5f * sc; + float2 q = p.XY + (0.5f * sc); float2 iq = Hlsl.Floor(q / sc) + 0.5f; q -= iq * sc; if (Mod(iq.X + iq.Y, 2.0f) > 0.5f) { - studs = Hlsl.Max(Hlsl.Length(q) - 0.1f * sc - 0.02f, Hlsl.Abs(p.Z) - 0.26f); + studs = Hlsl.Max(Hlsl.Length(q) - (0.1f * sc) - 0.02f, Hlsl.Abs(p.Z) - 0.26f); } objID = fl < obj && fl < studs ? 0 : obj < studs ? 1 : 2; @@ -136,7 +136,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader for (int i = 0; i < iter; i++) { - float d = M(ro + rd * t); + float d = M(ro + (rd * t)); shade = Hlsl.Min(shade, k * d / t); t += Hlsl.Clamp(d, 0.01f, 0.25f); @@ -158,7 +158,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader for (int i = (int)Hlsl.Min(time, 0f); i < 5; i++) { float hr = (i + 1f) * 0.15f / 5.0f; - float d = M(p + n * hr); + float d = M(p + (n * hr)); occ += (hr - d) * sca; sca *= 0.7f; @@ -184,7 +184,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader public float4 Execute() { int2 coords = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y); - float2 u = (coords - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y; + float2 u = (coords - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y; float3 r = Hlsl.Normalize(new float3(u, 1)); float3 o = new(0, time / 2.0f, -3); float3 l = o + new float3(0.25f, 0.25f, 2.0f); @@ -194,21 +194,21 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader r.XY = Hlsl.Mul(Rotate2x2(Hlsl.Sin(time * 3.14159f / 32.0f) / 8.0f), r.XY); float d; - float t = Hash21(r.XY * 57.0f + Hlsl.Frac(time)) * 0.5f; + float t = Hash21((r.XY * 57.0f) + Hlsl.Frac(time)) * 0.5f; float glow = 0; for (int i = 0; i < 96; i++) { - d = M(o + r * t); + d = M(o + (r * t)); if (Hlsl.Abs(d) < 0.001f) break; t += d * 0.7f; - glow += 0.2f / (1.0f + Hlsl.Abs(d) * 5.0f); + glow += 0.2f / (1.0f + (Hlsl.Abs(d) * 5.0f)); } int gObjID = objID; - float3 p = o + r * t; + float3 p = o + (r * t); float3 n = Normal(p); float2 uv = p.XY; float sc = 0.5f; @@ -216,21 +216,21 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader uv -= iuv * sc; - float2 uv2 = p.XY + 0.5f * sc; + float2 uv2 = p.XY + (0.5f * sc); float2 iuv2 = Hlsl.Floor(uv2 / sc) + 0.5f; uv2 -= iuv2 * sc; - float bord = Hlsl.Max(Hlsl.Abs(uv.X), Hlsl.Abs(uv.Y)) - 0.5f * sc; + float bord = Hlsl.Max(Hlsl.Abs(uv.X), Hlsl.Abs(uv.Y)) - (0.5f * sc); bord = Hlsl.Abs(bord) - 0.002f; d = Truchet(p.XY); float lSc = 20.0f; - float pat = (Hlsl.Abs(Hlsl.Frac((uv.X - uv.Y) * lSc - 0.5f) - 0.5f) * 2.0f - 0.5f) / lSc; - float pat2 = (Hlsl.Abs(Hlsl.Frac((uv.X + uv.Y) * lSc + 0.5f) - 0.5f) * 2.0f - 0.5f) / lSc; + float pat = ((Hlsl.Abs(Hlsl.Frac(((uv.X - uv.Y) * lSc) - 0.5f) - 0.5f) * 2.0f) - 0.5f) / lSc; + float pat2 = ((Hlsl.Abs(Hlsl.Frac(((uv.X + uv.Y) * lSc) + 0.5f) - 0.5f) * 2.0f) - 0.5f) / lSc; float sf = Hlsl.Dot(Hlsl.Sin(p.XY - Hlsl.Cos(p.YX * 2.0f)), 0.5f); - float sf2 = Hlsl.Dot(Hlsl.Sin(p.XY * 1.5f - Hlsl.Cos(p.YX * 3.0f)), 0.5f); + float sf2 = Hlsl.Dot(Hlsl.Sin((p.XY * 1.5f) - Hlsl.Cos(p.YX * 3.0f)), 0.5f); float4 col1 = Hlsl.Lerp(new float4(1, 0.75f, 0.6f, 0), new float4(1, 0.85f, 0.65f, 0), Hlsl.SmoothStep(-0.5f, 0.5f, sf)); float4 col2 = Hlsl.Lerp(new float4(0.4f, 0.7f, 1, 0), new float4(0.3f, 0.85f, 0.95f, 0), Hlsl.SmoothStep(-0.5f, 0.5f, sf2) * 0.5f); @@ -283,13 +283,13 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader ld /= lDist; - float at = 1.0f / (1.0f + lDist * lDist * 0.125f); + float at = 1.0f / (1.0f + (lDist * lDist * 0.125f)); float sh = SoftShadow(p, l, n, 8); float ao = CalculateAO(p, n); float df = Hlsl.Max(Hlsl.Dot(n, ld), 0); float sp = Hlsl.Pow(Hlsl.Max(Hlsl.Dot(Hlsl.Reflect(r, n), ld), 0), 32); - float4 c = oCol * (df * sh + sp * sh + 0.5f) * at * ao; + float4 c = oCol * ((df * sh) + (sp * sh) + 0.5f) * at * ao; c = Hlsl.Sqrt(Hlsl.Max(c, 0)); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs index 03d1abf1..4a3663e9 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs @@ -55,21 +55,21 @@ internal readonly partial struct FourColorGradient : IPixelShader { float2 i = Hlsl.Floor(p); float2 f = Hlsl.Frac(p); - float2 u = f * f * (3.0f - 2.0f * f); + float2 u = f * f * (3.0f - (2.0f * f)); // Mix -> Lerp float n = Hlsl.Lerp( Hlsl.Lerp( - Hlsl.Dot(-1.0f + 2.0f * Hash(i + new float2(0.0f, 0.0f)), f - new float2(0.0f, 0.0f)), - Hlsl.Dot(-1.0f + 2.0f * Hash(i + new float2(1.0f, 0.0f)), f - new float2(1.0f, 0.0f)), + Hlsl.Dot(-1.0f + (2.0f * Hash(i + new float2(0.0f, 0.0f))), f - new float2(0.0f, 0.0f)), + Hlsl.Dot(-1.0f + (2.0f * Hash(i + new float2(1.0f, 0.0f))), f - new float2(1.0f, 0.0f)), u.X), Hlsl.Lerp( - Hlsl.Dot(-1.0f + 2.0f * Hash(i + new float2(0.0f, 1.0f)), f - new float2(0.0f, 1.0f)), - Hlsl.Dot(-1.0f + 2.0f * Hash(i + new float2(1.0f, 1.0f)), f - new float2(1.0f, 1.0f)), + Hlsl.Dot(-1.0f + (2.0f * Hash(i + new float2(0.0f, 1.0f))), f - new float2(0.0f, 1.0f)), + Hlsl.Dot(-1.0f + (2.0f * Hash(i + new float2(1.0f, 1.0f))), f - new float2(1.0f, 1.0f)), u.X), u.Y); - return 0.5f + 0.5f * n; + return 0.5f + (0.5f * n); } @@ -87,7 +87,7 @@ internal readonly partial struct FourColorGradient : IPixelShader float degree = Noise(new float2(time * 0.1f, tuv.X * tuv.Y)); tuv.Y *= 1.0f / ratio; - tuv.XY = Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians((degree - 0.5f) * 720.0f + 180.0f))); + tuv.XY = Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(((degree - 0.5f) * 720.0f) + 180.0f))); tuv.Y *= ratio; // Wave warp with sin @@ -95,8 +95,8 @@ internal readonly partial struct FourColorGradient : IPixelShader float amplitude = 30.0f; float speed = time * 2.0f; - tuv.X += Hlsl.Sin(tuv.Y * frequency + speed) / amplitude; - tuv.Y += Hlsl.Sin(tuv.X * frequency * 1.5f + speed) / (amplitude * 0.5f); + tuv.X += Hlsl.Sin((tuv.Y * frequency) + speed) / amplitude; + tuv.Y += Hlsl.Sin((tuv.X * frequency * 1.5f) + speed) / (amplitude * 0.5f); // Draw the image float3 layer1 = Hlsl.Lerp(ColorOne, ColorTwo, Hlsl.SmoothStep(-0.3f, 0.2f, Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(-5.0f))).X)); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs index b63b4698..75d7c757 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs @@ -20,7 +20,7 @@ internal readonly partial struct FractalTiling : IPixelShader /// public float4 Execute() { - float2 position = ((float2)(256 * ThreadIds.XY)) / DispatchSize.X + time; + float2 position = (((float2)(256 * ThreadIds.XY)) / DispatchSize.X) + time; float4 color = 0; for (int i = 0; i < 6; i++) @@ -28,7 +28,7 @@ internal readonly partial struct FractalTiling : IPixelShader float2 a = Hlsl.Floor(position); float2 b = Hlsl.Frac(position); float4 w = Hlsl.Frac( - (Hlsl.Sin(a.X * 7 + 31.0f * a.Y + 0.01f * time) + + (Hlsl.Sin((a.X * 7) + (31.0f * a.Y) + (0.01f * time)) + new float4(0.035f, 0.01f, 0, 0.7f)) * 13.545317f); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs index 4680e460..1437f7a8 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs @@ -22,7 +22,7 @@ internal readonly partial struct HelloWorld : IPixelShader float2 uv = ThreadIds.Normalized.XY; // Time varying pixel color - float3 col = 0.5f + 0.5f * Hlsl.Cos(time + new float3(uv, uv.X) + new float3(0, 2, 4)); + float3 col = 0.5f + (0.5f * Hlsl.Cos(time + new float3(uv, uv.X) + new float3(0, 2, 4))); // Output to screen return new(col, 1f); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs index 262329b1..aa4d6c66 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs @@ -39,7 +39,7 @@ internal readonly partial struct MengerJourney : IPixelShader /// private static float2 Rotate(float2 v, float a) { - return new(Hlsl.Cos(a) * v.X + Hlsl.Sin(a) * v.Y, -Hlsl.Sin(a) * v.X + Hlsl.Cos(a) * v.Y); + return new((Hlsl.Cos(a) * v.X) + (Hlsl.Sin(a) * v.Y), (-Hlsl.Sin(a) * v.X) + (Hlsl.Cos(a) * v.Y)); } /// @@ -55,8 +55,8 @@ internal readonly partial struct MengerJourney : IPixelShader float diffuse2 = Hlsl.Max(0.0f, Hlsl.Dot(-normal, lightDir2)); return - (diffuse * Diffuse) * (LightColor * color) + - (diffuse2 * Diffuse) * (LightColor2 * color); + ((diffuse * Diffuse) * (LightColor * color)) + + ((diffuse2 * Diffuse) * (LightColor2 * color)); } /// @@ -68,7 +68,7 @@ internal readonly partial struct MengerJourney : IPixelShader // Performs the GLSL mod function. static float3 Mod(float3 x, float y) { - return x - y * Hlsl.Floor(x / y); + return x - (y * Hlsl.Floor(x / y)); } z = Hlsl.Abs(1.0f - Mod(z, 2.0f)); @@ -77,14 +77,14 @@ internal readonly partial struct MengerJourney : IPixelShader for (int n = 0; n < Iterations; n++) { - z.XY = Rotate(z.XY, 4.0f + 2.0f * Hlsl.Cos(time / 8.0f)); + z.XY = Rotate(z.XY, 4.0f + (2.0f * Hlsl.Cos(time / 8.0f))); z = Hlsl.Abs(z); if (z.X < z.Y) { z.XY = z.YX; } if (z.X < z.Z) { z.XZ = z.ZX; } if (z.Y < z.Z) { z.YZ = z.ZY; } - z = Scale * z - Offset * (Scale - 1.0f); + z = (Scale * z) - (Offset * (Scale - 1.0f)); if (z.Z < -0.5f * Offset.Z * (Scale - 1.0)) { @@ -130,7 +130,7 @@ internal readonly partial struct MengerJourney : IPixelShader for (int i = 0; i < MaxSteps; i++) { dir.ZY = Rotate(dir2.ZY, totalDistance * Hlsl.Cos(time / 4.0f) * NonLinearPerspective); - pos = from + totalDistance * dir; + pos = from + (totalDistance * dir); distance = DE(pos) * FudgeFactor; totalDistance += distance; @@ -139,13 +139,13 @@ internal readonly partial struct MengerJourney : IPixelShader steps = i; } - float smoothStep = steps + distance / MinimumDistance; - float ao = 1.1f - smoothStep / MaxSteps; - float3 normal = GetNormal(pos - dir * NormalDistance * 3.0f); + float smoothStep = steps + (distance / MinimumDistance); + float ao = 1.1f - (smoothStep / MaxSteps); + float3 normal = GetNormal(pos - (dir * NormalDistance * 3.0f)); float3 color = 1.0f; float3 light = GetLight(color, normal); - color = (color * Ambient + light) * ao; + color = ((color * Ambient) + light) * ao; return new(color.X, color.Y, color.Z, 1.0f); } @@ -158,14 +158,14 @@ internal readonly partial struct MengerJourney : IPixelShader float3 camDir = Hlsl.Normalize(target - camPos); float3 camUp = new(0.0f, 1.0f, 0.0f); - camUp = Hlsl.Normalize(camUp - Hlsl.Dot(camDir, camUp) * camDir); + camUp = Hlsl.Normalize(camUp - (Hlsl.Dot(camDir, camUp) * camDir)); float3 camRight = Hlsl.Normalize(Hlsl.Cross(camDir, camUp)); - float2 coord = -1.0f + 2.0f * (float2)ThreadIds.XY / DispatchSize.XY; + float2 coord = -1.0f + (2.0f * (float2)ThreadIds.XY / DispatchSize.XY); coord.X *= (float)DispatchSize.X / DispatchSize.Y; - float3 rayDir = Hlsl.Normalize(camDir + (coord.X * camRight + coord.Y * camUp) * FieldOfView); + float3 rayDir = Hlsl.Normalize(camDir + (((coord.X * camRight) + (coord.Y * camUp)) * FieldOfView)); return RayMarch(camPos, rayDir, ThreadIds.XY); } diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs index 472d4851..8cc6df70 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs @@ -53,25 +53,25 @@ internal readonly partial struct Octagrams : IPixelShader pos.Y += Hlsl.Sin(gTime * 0.4f) * 2.5f; pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f)); - float box1 = Box(pos, 2.0f - Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f); + float box1 = Box(pos, 2.0f - (Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f)); pos = pos_origin; pos.Y -= Hlsl.Sin(gTime * 0.4f) * 2.5f; pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f)); - float box2 = Box(pos, 2.0f - Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f); + float box2 = Box(pos, 2.0f - (Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f)); pos = pos_origin; pos.X += Hlsl.Sin(gTime * 0.4f) * 2.5f; pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f)); - float box3 = Box(pos, 2.0f - Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f); + float box3 = Box(pos, 2.0f - (Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f)); pos = pos_origin; pos.X -= Hlsl.Sin(gTime * 0.4f) * 2.5f; pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f)); - float box4 = Box(pos, 2.0f - Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f); + float box4 = Box(pos, 2.0f - (Hlsl.Abs(Hlsl.Sin(gTime * 0.4f)) * 1.5f)); pos = pos_origin; pos.XY = Hlsl.Mul(pos.XY, Rotate(0.8f)); @@ -89,7 +89,7 @@ internal readonly partial struct Octagrams : IPixelShader /// public float4 Execute() { - float2 p = ((float2)ThreadIds.XY * 2.0f - DispatchSize.XY) / Hlsl.Min(DispatchSize.X, DispatchSize.Y); + float2 p = (((float2)ThreadIds.XY * 2.0f) - DispatchSize.XY) / Hlsl.Min(DispatchSize.X, DispatchSize.Y); float3 ro = new(0.0f, -0.2f, time * 4.0f); float3 ray = Hlsl.Normalize(new float3(p, 1.5f)); @@ -103,14 +103,14 @@ internal readonly partial struct Octagrams : IPixelShader { static float3 Mod(float3 x, float y) { - return x - y * Hlsl.Floor(x / y); + return x - (y * Hlsl.Floor(x / y)); } - float3 pos = ro + ray * t; + float3 pos = ro + (ray * t); pos = Mod(pos - 2.0f, 4.0f) - 2.0f; - float gTime = time - i * 0.01f; + float gTime = time - (i * 0.01f); float d = BoxSet(pos, gTime); d = Hlsl.Max(Hlsl.Abs(d), 0.01f); @@ -118,8 +118,8 @@ internal readonly partial struct Octagrams : IPixelShader t += d * 0.55f; } - float3 col = ac * 0.02f + new float3(0.0f, 0.2f * Hlsl.Abs(Hlsl.Sin(time)), 0.5f + Hlsl.Sin(time) * 0.2f); - float4 color = new(col, 1.0f - t * (0.02f + 0.02f * Hlsl.Sin(time))); + float3 col = (ac * 0.02f) + new float3(0.0f, 0.2f * Hlsl.Abs(Hlsl.Sin(time)), 0.5f + (Hlsl.Sin(time) * 0.2f)); + float4 color = new(col, 1.0f - (t * (0.02f + (0.02f * Hlsl.Sin(time))))); return color; } diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs index cf29d2d9..ab438f68 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs @@ -42,7 +42,7 @@ internal readonly partial struct ProteanClouds : IPixelShader float3 p2 = p; p2.XY -= Disp(p.Z).XY; - p.XY = Hlsl.Mul(p.XY, Rotate(Hlsl.Sin(p.Z + time) * (0.1f + prm1 * 0.05f) + time * 0.09f)); + p.XY = Hlsl.Mul(p.XY, Rotate((Hlsl.Sin(p.Z + time) * (0.1f + (prm1 * 0.05f))) + (time * 0.09f))); float cl = Hlsl.Dot(p2.XY, p2.XY); float d = 0.0f; @@ -51,11 +51,11 @@ internal readonly partial struct ProteanClouds : IPixelShader float z = 1.0f; float trk = 1.0f; - float dspAmp = 0.1f + prm1 * 0.2f; + float dspAmp = 0.1f + (prm1 * 0.2f); for (int i = 0; i < 5; i++) { - p += Hlsl.Sin(p.ZXY * 0.75f * trk + time * trk * 0.8f) * dspAmp; + p += Hlsl.Sin((p.ZXY * 0.75f * trk) + (time * trk * 0.8f)) * dspAmp; d -= Hlsl.Abs(Hlsl.Dot(Hlsl.Cos(p), Hlsl.Sin(p.YZX)) * z); z *= 0.57f; trk *= 1.4f; @@ -63,9 +63,9 @@ internal readonly partial struct ProteanClouds : IPixelShader p = Hlsl.Mul(p, M3); } - d = Hlsl.Abs(d + prm1 * 3.0f) + prm1 * 0.3f - 2.5f + bsMo.Y; + d = Hlsl.Abs(d + (prm1 * 3.0f)) + (prm1 * 0.3f) - 2.5f + bsMo.Y; - return new float2(d + cl * 0.2f + 0.25f, cl); + return new float2(d + (cl * 0.2f) + 0.25f, cl); } private float4 Render(float3 ro, float3 rd, float time, float prm1, float2 bsMo) @@ -78,7 +78,7 @@ internal readonly partial struct ProteanClouds : IPixelShader { if (rez.A > 0.99f) break; - float3 pos = ro + t * rd; + float3 pos = ro + (t * rd); float2 mpv = Map(pos, prm1, bsMo); float den = Hlsl.Clamp(mpv.X - 0.3f, 0.0f, 1.0f) * 1.12f; float dn = Hlsl.Clamp((mpv.X + 2.0f), 0.0f, 3.0f); @@ -87,22 +87,22 @@ internal readonly partial struct ProteanClouds : IPixelShader if (mpv.X > 0.6f) { - col = new float4(Hlsl.Sin(new float3(5.0f, 0.4f, 0.2f) + mpv.Y * 0.1f + Hlsl.Sin(pos.Z * 0.4f) * 0.5f + 1.8f) * 0.5f + 0.5f, 0.08f); + col = new float4((Hlsl.Sin(new float3(5.0f, 0.4f, 0.2f) + (mpv.Y * 0.1f) + (Hlsl.Sin(pos.Z * 0.4f) * 0.5f) + 1.8f) * 0.5f) + 0.5f, 0.08f); col *= den * den * den; col.RGB *= LinStep(4.0f, -2.5f, mpv.X) * 2.3f; float dif = Hlsl.Clamp((den - Map(pos + 0.8f, prm1, bsMo).X) / 9.0f, 0.001f, 1.0f); dif += Hlsl.Clamp((den - Map(pos + 0.35f, prm1, bsMo).X) / 2.5f, 0.001f, 1.0f); - col.XYZ *= den * (new float3(0.005f, 0.045f, 0.075f) + 1.5f * new float3(0.033f, 0.07f, 0.03f) * dif); + col.XYZ *= den * (new float3(0.005f, 0.045f, 0.075f) + (1.5f * new float3(0.033f, 0.07f, 0.03f) * dif)); } - float fogC = Hlsl.Exp(t * 0.2f - 2.2f); + float fogC = Hlsl.Exp((t * 0.2f) - 2.2f); col += new float4(0.06f, 0.11f, 0.11f, 0.1f) * Hlsl.Clamp(fogC - fogT, 0.0f, 1.0f); fogT = fogC; rez += col * (1.0f - rez.A); - t += Hlsl.Clamp(0.5f - dn * dn * 0.05f, 0.09f, 0.3f); + t += Hlsl.Clamp(0.5f - (dn * dn * 0.05f), 0.09f, 0.3f); } return Hlsl.Clamp(rez, 0.0f, 1.0f); @@ -120,7 +120,7 @@ internal readonly partial struct ProteanClouds : IPixelShader { float3 ic = Hlsl.Lerp(a, b, x) + new float3((float)1e-6, 0.0f, 0.0f); float sd = Hlsl.Abs(GetSaturation(ic) - Hlsl.Lerp(GetSaturation(a), GetSaturation(b), x)); - float3 dir = Hlsl.Normalize(new float3(2.0f * ic.X - ic.Y - ic.Z, 2.0f * ic.Y - ic.X - ic.Z, 2.0f * ic.Z - ic.Y - ic.X)); + float3 dir = Hlsl.Normalize(new float3((2.0f * ic.X) - ic.Y - ic.Z, (2.0f * ic.Y) - ic.X - ic.Z, (2.0f * ic.Z) - ic.Y - ic.X)); float lgt = Hlsl.Dot(1.0f, ic); float ff = Hlsl.Dot(dir, Hlsl.Normalize(ic)); @@ -133,7 +133,7 @@ internal readonly partial struct ProteanClouds : IPixelShader public float4 Execute() { float2 q = (float2)ThreadIds.XY / DispatchSize.XY; - float2 p = (ThreadIds.XY - 0.5f * (float2)DispatchSize.XY) / DispatchSize.Y; + float2 p = (ThreadIds.XY - (0.5f * (float2)DispatchSize.XY)) / DispatchSize.Y; float2 bsMo = -0.5f * (float2)DispatchSize.XY / DispatchSize.Y; float scaledTime = time * 3.0f; float3 ro = new(0, 0, scaledTime); @@ -154,9 +154,9 @@ internal readonly partial struct ProteanClouds : IPixelShader rightdir = Hlsl.Normalize(Hlsl.Cross(updir, target)); - float3 rd = Hlsl.Normalize((p.X * rightdir + p.Y * updir) * 1.0f - target); + float3 rd = Hlsl.Normalize((((p.X * rightdir) + (p.Y * updir)) * 1.0f) - target); - rd.XY = Hlsl.Mul(rd.XY, Rotate(-Disp(scaledTime + 3.5f).X * 0.2f + bsMo.X)); + rd.XY = Hlsl.Mul(rd.XY, Rotate((-Disp(scaledTime + 3.5f).X * 0.2f) + bsMo.X)); float prm1 = Hlsl.SmoothStep(-0.4f, 0.4f, Hlsl.Sin(time * 0.3f)); float4 scn = Render(ro, rd, scaledTime, prm1, bsMo); @@ -164,7 +164,7 @@ internal readonly partial struct ProteanClouds : IPixelShader col = ILerp(col.BGR, col.RGB, Hlsl.Clamp(1.0f - prm1, 0.05f, 1.0f)); col = Hlsl.Pow(col, new float3(0.55f, 0.65f, 0.6f)) * new float3(1.0f, 0.97f, 0.9f); - col *= Hlsl.Pow(16.0f * q.X * q.Y * (1.0f - q.X) * (1.0f - q.Y), 0.12f) * 0.7f + 0.3f; + col *= (Hlsl.Pow(16.0f * q.X * q.Y * (1.0f - q.X) * (1.0f - q.Y), 0.12f) * 0.7f) + 0.3f; return new(col, 1.0f); } diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs index a72a0dda..29b55cd3 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs @@ -37,7 +37,7 @@ internal readonly partial struct PyramidPattern : IPixelShader { float n = Hlsl.Sin(Hlsl.Dot(p, new float2(41, 289))); - return Hlsl.Frac(new float2(262144, 32768) * n) * 2.0f - 1.0f; + return (Hlsl.Frac(new float2(262144, 32768) * n) * 2.0f) - 1.0f; } // Based on IQ's gradient noise formula. @@ -54,7 +54,7 @@ internal readonly partial struct PyramidPattern : IPixelShader v.Z = Hlsl.Dot(Hash22B(i + float2.UnitY), p - float2.UnitY); v.W = Hlsl.Dot(Hash22B(i + 1.0f), p - 1.0f); - p = p * p * (3.0f - 2.0f * p); + p = p * p * (3.0f - (2.0f * p)); return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y); } @@ -62,13 +62,13 @@ internal readonly partial struct PyramidPattern : IPixelShader // Two layers of noise. private static float FBM(float2 p) { - return N2D3G(p) * 0.66f + N2D3G(p * 2.0f) * 0.34f; + return (N2D3G(p) * 0.66f) + (N2D3G(p * 2.0f) * 0.34f); } // HLSL mod from GLSL private static float Mod(float x, float y) { - return x - y * Hlsl.Floor(x / y); + return x - (y * Hlsl.Floor(x / y)); } private float BMap(float2 p) @@ -84,14 +84,14 @@ internal readonly partial struct PyramidPattern : IPixelShader p -= ip + 0.5f; - float ang = -3.14159f * 3.0f / 5.0f + (FBM(ip / 8.0f + time / 3.0f)) * 6.2831f * 2.0f; + float ang = (-3.14159f * 3.0f / 5.0f) + ((FBM((ip / 8.0f) + (time / 3.0f))) * 6.2831f * 2.0f); float2 offs = new float2(Hlsl.Cos(ang), Hlsl.Sin(ang)) * 0.35f; - if (p.X < offs.X) p.X = 1.0f - (p.X + 0.5f) / Hlsl.Abs(offs.X + 0.5f); + if (p.X < offs.X) p.X = 1.0f - ((p.X + 0.5f) / Hlsl.Abs(offs.X + 0.5f)); else p.X = (p.X - offs.X) / (0.5f - offs.X); - if (p.Y < offs.Y) p.Y = 1.0f - (p.Y + 0.5f) / Hlsl.Abs(offs.Y + 0.5f); + if (p.Y < offs.Y) p.Y = 1.0f - ((p.Y + 0.5f) / Hlsl.Abs(offs.Y + 0.5f)); else p.Y = (p.Y - offs.Y) / (0.5f - offs.Y); return 1.0f - Hlsl.Max(p.X, p.Y); @@ -111,12 +111,12 @@ internal readonly partial struct PyramidPattern : IPixelShader float3 grad = (new float3(fx - fx2, fy - fx2, 0)) / e.X / 2.0f; - edge = Hlsl.Length(new float2(fx, fy) + new float2(fx2, fy2) - f * 2.0f); + edge = Hlsl.Length(new float2(fx, fy) + new float2(fx2, fy2) - (f * 2.0f)); edge = Hlsl.SmoothStep(0.0f, 1.0f, edge / e.X); grad -= n * Hlsl.Dot(n, grad); - return Hlsl.Normalize(n + grad * bumpfactor); + return Hlsl.Normalize(n + (grad * bumpfactor)); } @@ -125,7 +125,7 @@ internal readonly partial struct PyramidPattern : IPixelShader { p *= res / 16.0f; - float hatch = Hlsl.Clamp(Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f + 0.5f, 0.0f, 1.0f); + float hatch = Hlsl.Clamp((Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f) + 0.5f, 0.0f, 1.0f); float hRnd = Hash21(Hlsl.Floor(p * 6.0f) + 0.73f); if (hRnd > 0.66f) hatch = hRnd; @@ -138,10 +138,10 @@ internal readonly partial struct PyramidPattern : IPixelShader { int2 coordinate = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y); float iRes = Hlsl.Min(DispatchSize.Y, 800.0f); - float2 uv = (coordinate - (float2)DispatchSize.XY * 0.5f) / iRes; + float2 uv = (coordinate - ((float2)DispatchSize.XY * 0.5f)) / iRes; float3 rd = Hlsl.Normalize(new float3(uv, 0.5f)); const float gSc = 10.0f; - float2 p = uv * gSc + new float2(0, time / 2.0f); + float2 p = (uv * gSc) + new float2(0, time / 2.0f); float2 oP = p; float m = BMap(p); float3 n = new(0, 0, -1); @@ -150,7 +150,7 @@ internal readonly partial struct PyramidPattern : IPixelShader n = DoBumpMap(p, n, bumpFactor, ref edge); - float3 lp = new float3(-0.0f + Hlsl.Sin(time) * 0.3f, 0.0f + Hlsl.Cos(time * 1.3f) * 0.3f, -1) - new float3(uv, 0); + float3 lp = new float3(-0.0f + (Hlsl.Sin(time) * 0.3f), 0.0f + (Hlsl.Cos(time * 1.3f) * 0.3f), -1) - new float3(uv, 0); float lDist = Hlsl.Max(Hlsl.Length(lp), 0.001f); float3 ld = lp / lDist; float diff = Hlsl.Max(Hlsl.Dot(n, ld), 0.0f); @@ -159,19 +159,19 @@ internal readonly partial struct PyramidPattern : IPixelShader float spec = Hlsl.Pow(Hlsl.Max(Hlsl.Dot(Hlsl.Reflect(-ld, n), -rd), 0.0f), 16.0f); float fre = Hlsl.Min(Hlsl.Pow(Hlsl.Max(1.0f + Hlsl.Dot(n, rd), 0.0f), 4.0f), 3.0f); - float3 col = 0.15f * (diff + 0.251f + spec * new float3(1, 0.7f, 0.3f) * 9.0f + fre * new float3(0.1f, 0.3f, 1) * 12.0f); - float rf = Hlsl.SmoothStep(0.0f, 0.35f, BMap(Hlsl.Reflect(rd, n).XY * 2.0f) * FBM(Hlsl.Reflect(rd, n).XY * 3.0f) + 0.1f); + float3 col = 0.15f * (diff + 0.251f + (spec * new float3(1, 0.7f, 0.3f) * 9.0f) + (fre * new float3(0.1f, 0.3f, 1) * 12.0f)); + float rf = Hlsl.SmoothStep(0.0f, 0.35f, (BMap(Hlsl.Reflect(rd, n).XY * 2.0f) * FBM(Hlsl.Reflect(rd, n).XY * 3.0f)) + 0.1f); col += col * col * rf * rf * new float3(1, 0.1f, 0.1f) * 15.0f; - float shade = m * 0.83f + 0.17f; + float shade = (m * 0.83f) + 0.17f; col *= shade; - col *= 1.0f - edge * 0.8f; + col *= 1.0f - (edge * 0.8f); float hatch = DoHatch(oP / gSc, iRes); - col *= hatch * 0.5f + 0.7f; + col *= (hatch * 0.5f) + 0.7f; return new(Hlsl.Sqrt(Hlsl.Max(col, 0.0f)), 1); } diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs index 06ccdfd2..bc14ad4e 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs @@ -38,7 +38,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader p = Hlsl.Frac(new float2(262144, 32768) * n); - return Hlsl.Sin(p * 6.2831853f + time); + return Hlsl.Sin((p * 6.2831853f) + time); } // Based on IQ's gradient noise formula. @@ -55,7 +55,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader v.Z = Hlsl.Dot(Hash22(i + float2.UnitY), p - float2.UnitY); v.W = Hlsl.Dot(Hash22(i + 1.0f), p - 1.0f); - p = p * p * p * (p * (p * 6.0f - 15.0f) + 10.0f); + p = p * p * p * ((p * ((p * 6.0f) - 15.0f)) + 10.0f); return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y); } @@ -63,7 +63,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader // The isofunction. Just a Hlsl.Single noise function, but it can be more elaborate. private float IsoFunction(in float2 p) { - return N2D3G(p / 4.0f + 0.07f); + return N2D3G((p / 4.0f) + 0.07f); } // Unsigned distance to the segment joining "a" and "b". @@ -73,7 +73,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader float h = Hlsl.Clamp(Hlsl.Dot(a, b) / Hlsl.Dot(b, b), 0.0f, 1.0f); - return Hlsl.Length(a - b * h); + return Hlsl.Length(a - (b * h)); } // Based on IQ's signed distance to the segment joining "a" and "b". @@ -85,7 +85,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader // Interpolating along the edge connecting vertices v1 and v2 with respect to the isovalue. private static float2 Interpolate(in float2 p1, in float2 p2, float v1, float v2, float isovalue) { - return Hlsl.Lerp(p1, p2, (isovalue - v1) / (v2 - v1) * 0.75f + 0.25f / 2.0f); + return Hlsl.Lerp(p1, p2, ((isovalue - v1) / (v2 - v1) * 0.75f) + (0.25f / 2.0f)); } // Isoline function. @@ -153,11 +153,11 @@ internal readonly partial struct TriangleGridContouring : IPixelShader float2 oP = p; - p += new float2(N2D3G(p * 3.5f), N2D3G(p * 3.5f + 7.3f)) * 0.015f; + p += new float2(N2D3G(p * 3.5f), N2D3G((p * 3.5f) + 7.3f)) * 0.015f; - float2 s = Hlsl.Floor(p + (p.X + p.Y) * 0.36602540378f); + float2 s = Hlsl.Floor(p + ((p.X + p.Y) * 0.36602540378f)); - p -= s - (s.X + s.Y) * 0.211324865f; + p -= s - ((s.X + s.Y) * 0.211324865f); float i = p.X < p.Y ? 1.0f : 0.0f; float2 ioffs = new(1.0f - i, i); @@ -231,12 +231,12 @@ internal readonly partial struct TriangleGridContouring : IPixelShader col = Hlsl.Lerp(col, new float3(1.5f, 0.9f, 0.6f) * 0.6f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d - 0.012f))); col = Hlsl.Lerp(col, new float3(1, 0.8f, 0.6f) * new float3(0.7f, 1.0f, 0.75f) * 0.95f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d))); - if (d2 > 0.0f) col *= (Hlsl.Abs(Hlsl.Dot(n3, float3.One)) * 1.25f + 1.25f) / 2.0f; - else col *= Hlsl.Max(2.0f - (Hlsl.Dot(n3, float3.One) + 1.45f) / 1.25f, 0.0f); + if (d2 > 0.0f) col *= ((Hlsl.Abs(Hlsl.Dot(n3, float3.One)) * 1.25f) + 1.25f) / 2.0f; + else col *= Hlsl.Max(2.0f - ((Hlsl.Dot(n3, float3.One) + 1.45f) / 1.25f), 0.0f); - float pat = Hlsl.Abs(Hlsl.Frac(tri * 12.5f + 0.4f) - 0.5f) * 2.0f; + float pat = Hlsl.Abs(Hlsl.Frac((tri * 12.5f) + 0.4f) - 0.5f) * 2.0f; - col *= pat * 0.425f + 0.75f; + col *= (pat * 0.425f) + 0.75f; col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d5)) * 0.95f); col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d3))); col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d4))); @@ -247,12 +247,12 @@ internal readonly partial struct TriangleGridContouring : IPixelShader col = Hlsl.Min(col, 1.0f); float gr = Hlsl.Sqrt(Hlsl.Dot(col, new float3(0.299f, 0.587f, 0.114f))) * 1.25f; - float ns = (N2D3G(q * 4.0f * new float2(1.0f / 3.0f, 3)) * 0.64f + N2D3G(q * 8.0f * new float2(1.0f / 3.0f, 3)) * 0.34f) * 0.5f + 0.5f; + float ns = (((N2D3G(q * 4.0f * new float2(1.0f / 3.0f, 3)) * 0.64f) + (N2D3G(q * 8.0f * new float2(1.0f / 3.0f, 3)) * 0.34f)) * 0.5f) + 0.5f; ns = gr - ns; q = Hlsl.Mul(q, Rotate2x2(3.14159f / 3.0f)); - float ns2 = (N2D3G(q * 4.0f * new float2(1.0f / 3.0f, 3)) * 0.64f + N2D3G(q * 8.0f * new float2(1.0f / 3.0f, 3)) * 0.34f) * 0.5f + 0.5f; + float ns2 = (((N2D3G(q * 4.0f * new float2(1.0f / 3.0f, 3)) * 0.64f) + (N2D3G(q * 8.0f * new float2(1.0f / 3.0f, 3)) * 0.34f)) * 0.5f) + 0.5f; ns2 = gr - ns2; ns = Hlsl.SmoothStep(0.0f, 1.0f, Hlsl.Min(ns, ns2)); @@ -265,8 +265,8 @@ internal readonly partial struct TriangleGridContouring : IPixelShader public float4 Execute() { int2 coordinate = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y); - float2 uv = (coordinate - (float2)DispatchSize.XY * 0.5f) / Hlsl.Min(650.0f, DispatchSize.Y); - float2 p = Hlsl.Mul(Rotate2x2(3.14159f / 12.0f), uv) + new float2(0.8660254f, 0.5f) * time / 16.0f; + float2 uv = (coordinate - ((float2)DispatchSize.XY * 0.5f)) / Hlsl.Min(650.0f, DispatchSize.Y); + float2 p = Hlsl.Mul(Rotate2x2(3.14159f / 12.0f), uv) + (new float2(0.8660254f, 0.5f) * time / 16.0f); float3 col = SimplexContour(p); uv = coordinate / (float2)DispatchSize.XY; diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs index ca025a1c..1004cce9 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs @@ -33,7 +33,7 @@ internal readonly partial struct TwoTiledTruchet : IPixelShader // HLSL's port of the GLSL mod intrinsic static float Mod(float x, float y) { - return x - y * Hlsl.Floor(x / y); + return x - (y * Hlsl.Floor(x / y)); } float2 ip2 = Hlsl.Floor(p / 2.0f); @@ -106,7 +106,7 @@ internal readonly partial struct TwoTiledTruchet : IPixelShader ang *= 2.0f; } - ang = Hlsl.Frac(ang + time / 4.0f); + ang = Hlsl.Frac(ang + (time / 4.0f)); return d; } @@ -114,28 +114,28 @@ internal readonly partial struct TwoTiledTruchet : IPixelShader /// public float4 Execute() { - float2 uv = (ThreadIds.XY - (float2)DispatchSize.XY * 0.5f) / DispatchSize.Y; + float2 uv = (ThreadIds.XY - ((float2)DispatchSize.XY * 0.5f)) / DispatchSize.Y; float gSc = 7.0f; - float2 p = uv * gSc - new float2(-1, -0.5f) * time / 2.0f; + float2 p = (uv * gSc) - (new float2(-1, -0.5f) * time / 2.0f); float sf = 2.0f / DispatchSize.Y * gSc; float lSc = 6.0f; float lw = 1.0f / lSc / gSc; - float2 d = DistanceField(p, out float2 ang) - 2.5f / lSc; + float2 d = DistanceField(p, out float2 ang) - (2.5f / lSc); float3 col = new(1.0f, 0.9f, 0.8f); for (int i = 0; i < 2; i++) { - float di = d[i] - lw / 4.0f; - float tracks = Hlsl.Clamp(Hlsl.Sin(ang[i] * 6.2831f + time * 6.0f) * 4.0f, 0.0f, 1.0f); + float di = d[i] - (lw / 4.0f); + float tracks = Hlsl.Clamp(Hlsl.Sin((ang[i] * 6.2831f) + (time * 6.0f)) * 4.0f, 0.0f, 1.0f); float gap = 1.0f + lw; col = Hlsl.Lerp(col, 0, (1.0f - Hlsl.SmoothStep(0.0f, sf * 6.0f, di)) * 0.35f); col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di)); - col = Hlsl.Lerp(col, new(1.0f, 0.9f, 0.8f), 1.0f - Hlsl.SmoothStep(0.0f, sf, di + lw * 2.0f)); - col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + gap / lSc)); - col = Hlsl.Lerp(col, 1, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + gap / lSc + lw)); - col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + 2.0f * gap / lSc)); - col = Hlsl.Lerp(col, 1 * tracks, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + 2.0f * gap / lSc + lw)); + col = Hlsl.Lerp(col, new(1.0f, 0.9f, 0.8f), 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (lw * 2.0f))); + col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (gap / lSc))); + col = Hlsl.Lerp(col, 1, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (gap / lSc) + lw)); + col = Hlsl.Lerp(col, 0, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (2.0f * gap / lSc))); + col = Hlsl.Lerp(col, 1 * tracks, 1.0f - Hlsl.SmoothStep(0.0f, sf, di + (2.0f * gap / lSc) + lw)); } float3 rgb = Hlsl.Sqrt(Hlsl.Max(col, 0.0f)); diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs index 987db1ce..e3f23d17 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs @@ -132,7 +132,7 @@ partial class ID2D1ShaderGenerator builder.Add(startingRawDataOffset); - rawDataOffset = startingRawDataOffset + fieldPack * columns; + rawDataOffset = startingRawDataOffset + (fieldPack * columns); } return new FieldInfo.NonLinearMatrix( diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs index e3d59524..959f5ffe 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs @@ -485,7 +485,7 @@ unsafe partial struct D2D1ResourceTextureManagerImpl (dimensions > 2 ? z * strides[1] : 0); byte* destinationDataPlane = @this->data + - (dimensions > 2 ? minimumExtents[2] * @this->strides[1] + z * @this->strides[1] : 0) + + (dimensions > 2 ? (minimumExtents[2] * @this->strides[1]) + (z * @this->strides[1]) : 0) + (dimensions > 1 ? minimumExtents[1] * @this->strides[0] : 0); for (int y = 0; y < updateExtents[1]; y++) @@ -582,7 +582,7 @@ unsafe partial struct D2D1ResourceTextureManagerImpl try { - extent01SizeInBytes = checked((extents[1] - 1) * strides[0] + extent0SizeInBytes); + extent01SizeInBytes = checked(((extents[1] - 1) * strides[0]) + extent0SizeInBytes); } catch (OverflowException) { @@ -609,7 +609,7 @@ unsafe partial struct D2D1ResourceTextureManagerImpl try { - extent012SizeInBytes = (extents[2] - 1) * strides[1] + extent01SizeInBytes; + extent012SizeInBytes = ((extents[2] - 1) * strides[1]) + extent01SizeInBytes; } catch (OverflowException) { diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Point64.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Point64.cs index f11923eb..f2aa05f4 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Point64.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Point64.cs @@ -77,7 +77,7 @@ internal struct Point64 // [ M21, M22 ] // [ x, y] [ M31, M32 ] = [ x * M11 + y * M21 + M31, x * M12 + y * M22 + m32] return ( - Math.Round((double)this.x * matrix.M11 + (double)this.y * matrix.M21 + matrix.M31), - Math.Round((double)this.x * matrix.M12 + (double)this.y * matrix.M22 + matrix.M32)); + Math.Round(((double)this.x * matrix.M11) + ((double)this.y * matrix.M21) + matrix.M31), + Math.Round(((double)this.x * matrix.M12) + ((double)this.y * matrix.M22) + matrix.M32)); } } \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Helpers/SyntaxTokenHelper.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Helpers/SyntaxTokenHelper.cs index e2bf0f07..f537568f 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Helpers/SyntaxTokenHelper.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Helpers/SyntaxTokenHelper.cs @@ -23,7 +23,7 @@ internal static class SyntaxTokenHelper // An extra newline and indentation has to be added to the raw text when there is no trailing newline, as not doing // so would otherwise case the terminating """ token to fall on the same line, which is invalid syntax. This is only // needed to make the code valid, as the actual literal context of the string is not affected and remains the same. - string indentation = new(' ', 4 * indentationLevel + 4 + 4); + string indentation = new(' ', (4 * indentationLevel) + 4 + 4); return Token( TriviaList(), diff --git a/src/ComputeSharp.SourceGeneration/Helpers/HashCode.cs b/src/ComputeSharp.SourceGeneration/Helpers/HashCode.cs index 835b1872..bd2a4c6f 100644 --- a/src/ComputeSharp.SourceGeneration/Helpers/HashCode.cs +++ b/src/ComputeSharp.SourceGeneration/Helpers/HashCode.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security.Cryptography; -#pragma warning disable CS0809, IDE0009, IDE1006 +#pragma warning disable CS0809, IDE0009, IDE1006, IDE0048 namespace System; diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs index f4a15b92..cb2604f7 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs @@ -157,7 +157,7 @@ partial class IShaderGenerator builder.Add(startingRawDataOffset); - rawDataOffset = startingRawDataOffset + fieldPack * columns; + rawDataOffset = startingRawDataOffset + (fieldPack * columns); } return new FieldInfo.NonLinearMatrix( diff --git a/src/ComputeSharp/Graphics/Helpers/MemoryHelper.cs b/src/ComputeSharp/Graphics/Helpers/MemoryHelper.cs index 6109b4a2..ae0aaaf0 100644 --- a/src/ComputeSharp/Graphics/Helpers/MemoryHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/MemoryHelper.cs @@ -31,8 +31,8 @@ internal static class MemoryHelper where T : unmanaged { // Offset adjustment - source = (byte*)source + sourceElementOffset * sourceElementPitchInBytes; - destination = (byte*)destination + destinationElementOffset * destinationElementPitchInBytes; + source = (byte*)source + (sourceElementOffset * sourceElementPitchInBytes); + destination = (byte*)destination + (destinationElementOffset * destinationElementPitchInBytes); if (sourceElementPitchInBytes == (uint)sizeof(T)) { @@ -54,7 +54,7 @@ internal static class MemoryHelper uint destinationElementPitchInBytes, uint count) { - void* sourceEnd = (byte*)source + count * sizeof(T); + void* sourceEnd = (byte*)source + (count * sizeof(T)); while (source < sourceEnd) { @@ -77,7 +77,7 @@ internal static class MemoryHelper uint sourceElementPitchInBytes, uint count) { - void* sourceEnd = (byte*)source + count * sourceElementPitchInBytes; + void* sourceEnd = (byte*)source + (count * sourceElementPitchInBytes); while (source < sourceEnd) { @@ -100,7 +100,7 @@ internal static class MemoryHelper uint destinationElementPitchInBytes, uint count) { - void* sourceEnd = (byte*)source + count * sourceElementPitchInBytes; + void* sourceEnd = (byte*)source + (count * sourceElementPitchInBytes); while (source < sourceEnd) { @@ -140,8 +140,8 @@ internal static class MemoryHelper for (int i = 0; i < height; i++) { Buffer.MemoryCopy( - (byte*)source + (uint)i * widthInBytes, - (byte*)destination + (uint)i * pitchInBytes, + (byte*)source + ((uint)i * widthInBytes), + (byte*)destination + ((uint)i * pitchInBytes), ulong.MaxValue, widthInBytes); } @@ -173,8 +173,8 @@ internal static class MemoryHelper for (int i = 0; i < height; i++) { Buffer.MemoryCopy( - (byte*)source + (uint)i * pitchInBytes, - (byte*)destination + (uint)i * widthInBytes, + (byte*)source + ((uint)i * pitchInBytes), + (byte*)destination + ((uint)i * widthInBytes), ulong.MaxValue, widthInBytes); } @@ -215,8 +215,8 @@ internal static class MemoryHelper for (int i = 0; i < height; i++) { Buffer.MemoryCopy( - (byte*)source + sourceZOffset + (uint)i * widthInBytes, - (byte*)destination + destinationZOffset + (uint)i * pitchInBytes, + (byte*)source + sourceZOffset + ((uint)i * widthInBytes), + (byte*)destination + destinationZOffset + ((uint)i * pitchInBytes), ulong.MaxValue, widthInBytes); } @@ -258,8 +258,8 @@ internal static class MemoryHelper for (int i = 0; i < height; i++) { Buffer.MemoryCopy( - (byte*)source + sourceZOffset + (uint)i * pitchInBytes, - (byte*)destination + destinationZOffset + (uint)i * widthInBytes, + (byte*)source + sourceZOffset + ((uint)i * pitchInBytes), + (byte*)destination + destinationZOffset + ((uint)i * widthInBytes), ulong.MaxValue, widthInBytes); } diff --git a/src/ComputeSharp/Graphics/Luid.cs b/src/ComputeSharp/Graphics/Luid.cs index 03dec9c0..995738af 100644 --- a/src/ComputeSharp/Graphics/Luid.cs +++ b/src/ComputeSharp/Graphics/Luid.cs @@ -60,20 +60,20 @@ public readonly struct Luid : IEquatable /// public override string ToString() { - return (((long)this.highPart) << 32 | this.lowPart).ToString(); + return ((((long)this.highPart) << 32) | this.lowPart).ToString(); } #if NET6_0_OR_GREATER /// public string ToString(string? format, IFormatProvider? formatProvider) { - return (((long)this.highPart) << 32 | this.lowPart).ToString(format, formatProvider); + return ((((long)this.highPart) << 32) | this.lowPart).ToString(format, formatProvider); } /// public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) { - return (((long)this.highPart) << 32 | this.lowPart).TryFormat(destination, out charsWritten, format, provider); + return ((((long)this.highPart) << 32) | this.lowPart).TryFormat(destination, out charsWritten, format, provider); } #endif diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs index 22f7dfd9..c7bf4b0c 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs @@ -689,7 +689,7 @@ public partial class D2D1ResourceTextureManagerTests for (int y = 0; y < updateLengthY; y++) { ReadOnlySpan source = data.AsSpan(y * updateLengthX, updateLengthX); - Span destination = texture.AsSpan(startOffsetY * width + y * width + startOffsetX, updateLengthX); + Span destination = texture.AsSpan((startOffsetY * width) + (y * width) + startOffsetX, updateLengthX); source.CopyTo(destination); } @@ -707,7 +707,7 @@ public partial class D2D1ResourceTextureManagerTests for (int y = 0; y < height; y++) { - foreach (Bgra32 pixel in new ReadOnlySpan(d2D1MappedRect.bits + d2D1MappedRect.pitch * y, width)) + foreach (Bgra32 pixel in new ReadOnlySpan(d2D1MappedRect.bits + (d2D1MappedRect.pitch * y), width)) { resultingBytes[i++] = pixel.B; } @@ -793,8 +793,8 @@ public partial class D2D1ResourceTextureManagerTests { for (int y = 0; y < updateLengthY; y++) { - ReadOnlySpan source = data.AsSpan(z * updateLengthX * updateLengthY + y * updateLengthX, updateLengthX); - Span destination = texture.AsSpan((startOffsetZ + z) * (width * height) + (startOffsetY + y) * width + startOffsetX, updateLengthX); + ReadOnlySpan source = data.AsSpan((z * updateLengthX * updateLengthY) + (y * updateLengthX), updateLengthX); + Span destination = texture.AsSpan(((startOffsetZ + z) * (width * height)) + ((startOffsetY + y) * width) + startOffsetX, updateLengthX); source.CopyTo(destination); } @@ -813,7 +813,7 @@ public partial class D2D1ResourceTextureManagerTests for (int y = 0; y < height * depth; y++) { - foreach (Bgra32 pixel in new ReadOnlySpan(d2D1MappedRect.bits + d2D1MappedRect.pitch * y, width)) + foreach (Bgra32 pixel in new ReadOnlySpan(d2D1MappedRect.bits + (d2D1MappedRect.pitch * y), width)) { resultingBytes[i++] = pixel.B; } diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs index a2a7abbb..d4a2be20 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs @@ -74,7 +74,7 @@ public sealed partial class BokehBlurEffect public BokehBlurEffect(int radius, int componentsCount) { this.radius = radius; - this.kernelSize = this.radius * 2 + 1; + this.kernelSize = (this.radius * 2) + 1; this.componentsCount = componentsCount; // Reuse the initialized values from the cache, if possible @@ -246,8 +246,8 @@ public sealed partial class BokehBlurEffect ref Complex64 kRef = ref Unsafe.Add(ref valueRef, k); total += - paramsRef.Z * (jRef.Real * kRef.Real - jRef.Imaginary * kRef.Imaginary) - + paramsRef.W * (jRef.Real * kRef.Imaginary + jRef.Imaginary * kRef.Real); + (paramsRef.Z * ((jRef.Real * kRef.Real) - (jRef.Imaginary * kRef.Imaginary))) + + (paramsRef.W * ((jRef.Real * kRef.Imaginary) + (jRef.Imaginary * kRef.Real))); } } } @@ -582,8 +582,8 @@ public sealed partial class BokehBlurEffect float realFactor = kernelReals[i]; float imaginaryFactor = kernelImaginaries[i]; - result.Real += (Vector4)(realFactor * sourceReal - imaginaryFactor * sourceImaginary); - result.Imaginary += (Vector4)(realFactor * sourceImaginary + imaginaryFactor * sourceReal); + result.Real += (Vector4)((realFactor * sourceReal) - (imaginaryFactor * sourceImaginary)); + result.Imaginary += (Vector4)((realFactor * sourceImaginary) + (imaginaryFactor * sourceReal)); } return result.WeightedSum(z, w); diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs index 718e0569..92c9e71e 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs @@ -34,7 +34,7 @@ public readonly partial struct ZonePlateEffect : ID2D1PixelShader float yd = yo * yo; float xd = xo * xo; float d = xd + yd; - float v = 1.0f + (1.0f + Hlsl.Tanh((rm - Hlsl.Sqrt(d)) / w)) * Hlsl.Sin(km * d) * 0.5f; + float v = 1.0f + ((1.0f + Hlsl.Tanh((rm - Hlsl.Sqrt(d)) / w)) * Hlsl.Sin(km * d) * 0.5f); return new Float4(v, v, v, 1.0f); } diff --git a/tests/ComputeSharp.D2D1.Tests/Helpers/ImageHelper.cs b/tests/ComputeSharp.D2D1.Tests/Helpers/ImageHelper.cs index a31a5685..7d4f6c08 100644 --- a/tests/ComputeSharp.D2D1.Tests/Helpers/ImageHelper.cs +++ b/tests/ComputeSharp.D2D1.Tests/Helpers/ImageHelper.cs @@ -48,7 +48,7 @@ internal static class ImageHelper for (int i = 0; i < (int)height; i++) { - ReadOnlySpan source = new(buffer + i * (int)strideInBytes, (int)width * sizeof(Bgra32)); + ReadOnlySpan source = new(buffer + (i * (int)strideInBytes), (int)width * sizeof(Bgra32)); source.CopyTo(pixelData.AsSpan(i * (int)width * sizeof(Bgra32))); } diff --git a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs index d178b589..8962414f 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs @@ -170,7 +170,7 @@ public partial class DeviceDisposalTests public float4 Execute() { float2 uv = ThreadIds.Normalized.XY; - float3 col = 0.5f + 0.5f * Hlsl.Cos(new float3(uv, uv.X) + new float3(0, 2, 4)); + float3 col = 0.5f + (0.5f * Hlsl.Cos(new float3(uv, uv.X) + new float3(0, 2, 4))); return new(col, 1f); } diff --git a/tests/ComputeSharp.Tests/BufferTests.cs b/tests/ComputeSharp.Tests/BufferTests.cs index bf6dec9a..3417d739 100644 --- a/tests/ComputeSharp.Tests/BufferTests.cs +++ b/tests/ComputeSharp.Tests/BufferTests.cs @@ -365,7 +365,7 @@ public partial class BufferTests for (int i = 0; i < 128; i++) { - Assert.IsTrue(Math.Abs(result[i] - (array[i] * 2.0 + 3.14)) < 0.00001); + Assert.IsTrue(Math.Abs(result[i] - ((array[i] * 2.0) + 3.14)) < 0.00001); } } @@ -378,7 +378,7 @@ public partial class BufferTests /// public void Execute() { - buffer[ThreadIds.X] = buffer[ThreadIds.X] * factor + 3.14; + buffer[ThreadIds.X] = (buffer[ThreadIds.X] * factor) + 3.14; } } diff --git a/tests/ComputeSharp.Tests/DispatchTests.cs b/tests/ComputeSharp.Tests/DispatchTests.cs index 8fdcde6e..db787199 100644 --- a/tests/ComputeSharp.Tests/DispatchTests.cs +++ b/tests/ComputeSharp.Tests/DispatchTests.cs @@ -145,7 +145,7 @@ public partial class DispatchTests Assert.AreEqual(x % 4, value[0]); Assert.AreEqual(y % 4, value[1]); Assert.AreEqual(z % 4, value[2]); - Assert.AreEqual(value[2] * 4 * 4 + value[1] * 4 + value[0], value[3]); + Assert.AreEqual((value[2] * 4 * 4) + (value[1] * 4) + value[0], value[3]); } } } diff --git a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs index da5f3953..22dc4179 100644 --- a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs @@ -30,7 +30,7 @@ namespace ComputeSharp.Tests float exp = Hlsl.Exp(dword * row_major[ThreadIds.X]); float log = Hlsl.Log(1 + exp); - row_major[ThreadIds.X] = log / dword + float2 + int2x2; + row_major[ThreadIds.X] = (log / dword) + float2 + int2x2; } } @@ -68,7 +68,7 @@ namespace ComputeSharp.Tests float log = Hlsl.Log(1 + exp); float temp = log + cellData.dword + cellData.int2x2; - row_major[ThreadIds.X] = log / dword + float2 + int2x2 + cbuffer.float2; + row_major[ThreadIds.X] = (log / dword) + float2 + int2x2 + cbuffer.float2; } } @@ -144,10 +144,10 @@ namespace ComputeSharp.Tests float s2 = s1 + this.intensity + Hlsl.Tan(s1 * this.scale); float t2 = t1 + this.intensity + Hlsl.Tan(t1 * this.scale); - float u2 = this.cos * s2 - this.sin * t2; - float v2 = this.sin * s2 - this.cos * t2; + float u2 = (this.cos * s2) - (this.sin * t2); + float v2 = (this.sin * s2) - (this.cos * t2); - row_major[ThreadIds.X] = log / dword + float2 + int2x2 + u2 + v2; + row_major[ThreadIds.X] = (log / dword) + float2 + int2x2 + u2 + v2; } } @@ -304,7 +304,7 @@ namespace ComputeSharp.Tests { for (var i = 0; i < 10; i++) { - buffer[ThreadIds.X * 10 + i] = i; + buffer[(ThreadIds.X * 10) + i] = i; } } } @@ -486,7 +486,7 @@ namespace ExternalNamespace { for (var i = 0; i < 10; i++) { - buffer[ThreadIds.X * 10 + i] = i; + buffer[(ThreadIds.X * 10) + i] = i; } } } diff --git a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs index 40af7999..ce10ef54 100644 --- a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs +++ b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs @@ -441,7 +441,7 @@ public partial class ShaderRewriterTests internal readonly partial struct ConstantsInShaderConstantFieldsShader : IComputeShader { public const float rot_angle = (float)(137.2 / 180.0 * Math.PI); - public const float rot_angle2 = rot_angle + (float)Math.E * 100; + public const float rot_angle2 = rot_angle + ((float)Math.E * 100); public const float sin = 42; public const float exponentLowercase = 1234567e-4f; public const float exponentUppercase = 1234567E-4f; @@ -743,7 +743,7 @@ public partial class ShaderRewriterTests for (int i = 0; i < source.Length; i++) { - Assert.AreEqual(i * 2 + 1, results1[i].value); + Assert.AreEqual((i * 2) + 1, results1[i].value); Assert.AreEqual(results1[i].value, results2[i]); } } diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ColorfulInfinity.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ColorfulInfinity.cs index 4020bb74..dd3d5182 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/ColorfulInfinity.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/ColorfulInfinity.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs index 728df90c..fc6deea6 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs index b2b54cac..e29ea08f 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/FourColorGradient.cs b/tests/ComputeSharp.Tests/Shaders/Compute/FourColorGradient.cs index fe128cc8..a6792cf1 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/FourColorGradient.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/FourColorGradient.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/FractalTiling.cs b/tests/ComputeSharp.Tests/Shaders/Compute/FractalTiling.cs index ad877489..bbde1bf1 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/FractalTiling.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/FractalTiling.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/HelloWorld.cs b/tests/ComputeSharp.Tests/Shaders/Compute/HelloWorld.cs index 133a697f..4e260610 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/HelloWorld.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/HelloWorld.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs b/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs index 2d09ae4c..f62634a5 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/Octagrams.cs b/tests/ComputeSharp.Tests/Shaders/Compute/Octagrams.cs index 43149166..21058894 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/Octagrams.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/Octagrams.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs index c54a058e..44c3f447 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs b/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs index 9336d753..02bbaf47 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs b/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs index 5a9085f9..b1af7575 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/TwoTiledTruchet.cs b/tests/ComputeSharp.Tests/Shaders/Compute/TwoTiledTruchet.cs index c1ce9665..04e78e1c 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/TwoTiledTruchet.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/TwoTiledTruchet.cs @@ -1,3 +1,5 @@ +#pragma warning disable IDE0048 + namespace ComputeSharp.SwapChain.Shaders.Compute; /// diff --git a/tests/ComputeSharp.Tests/Texture2DTests.cs b/tests/ComputeSharp.Tests/Texture2DTests.cs index a3879583..d962c984 100644 --- a/tests/ComputeSharp.Tests/Texture2DTests.cs +++ b/tests/ComputeSharp.Tests/Texture2DTests.cs @@ -435,7 +435,7 @@ public partial class Texture2DTests public void Execute() { - destination[ThreadIds.Y * 32 + ThreadIds.X] = source[ThreadIds.XY]; + destination[(ThreadIds.Y * 32) + ThreadIds.X] = source[ThreadIds.XY]; } } diff --git a/tests/ComputeSharp.Tests/Texture3DTests.cs b/tests/ComputeSharp.Tests/Texture3DTests.cs index 2752d1cf..7908274c 100644 --- a/tests/ComputeSharp.Tests/Texture3DTests.cs +++ b/tests/ComputeSharp.Tests/Texture3DTests.cs @@ -540,7 +540,7 @@ public partial class Texture3DTests public void Execute() { - destination[ThreadIds.Z * 32 * 32 + ThreadIds.Y * 32 + ThreadIds.X] = source[ThreadIds.XYZ]; + destination[(ThreadIds.Z * 32 * 32) + (ThreadIds.Y * 32) + ThreadIds.X] = source[ThreadIds.XYZ]; } } diff --git a/tests/ComputeSharp.Tests/TransferTexture3DTests.cs b/tests/ComputeSharp.Tests/TransferTexture3DTests.cs index 9c145e17..d5408fce 100644 --- a/tests/ComputeSharp.Tests/TransferTexture3DTests.cs +++ b/tests/ComputeSharp.Tests/TransferTexture3DTests.cs @@ -87,7 +87,7 @@ public partial class TransferTexture3DTests { for (int j = 0; j < uploadTexture3D.Height; j++) { - new Random(i * 5381 + j).NextBytes(uploadTexture3D.View.GetRowSpan(j, i).AsBytes()); + new Random((i * 5381) + j).NextBytes(uploadTexture3D.View.GetRowSpan(j, i).AsBytes()); } } @@ -131,7 +131,7 @@ public partial class TransferTexture3DTests { for (int j = 0; j < uploadTexture3D.Height; j++) { - new Random(i * 5381 + j).NextBytes(uploadTexture3D.View.GetRowSpan(j, i).AsBytes()); + new Random((i * 5381) + j).NextBytes(uploadTexture3D.View.GetRowSpan(j, i).AsBytes()); } }