More minor code style tweaks (remove extra blank lines, etc.)
このコミットが含まれているのは:
1 親
8be9203a1c
コミット
f2ed8a2d3b
22ファイル変更
+39
-38
検索条件に一致するファイルはありません
@@ -163,7 +163,6 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
return Hlsl.Max(shade, 0.0f);
|
||||
}
|
||||
|
||||
|
||||
// I keep a collection of occlusion routines... OK, that sounded really nerdy. :)
|
||||
// Anyway, I like this one. I'm assuHlsl.Ming it's based on IQ's original.
|
||||
private float CalculateAO(in float3 p, in float3 n)
|
||||
|
||||
@@ -72,7 +72,6 @@ internal readonly partial struct FourColorGradient : IPixelShader<float4>
|
||||
return 0.5f + (0.5f * n);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public float4 Execute()
|
||||
{
|
||||
|
||||
@@ -81,7 +81,9 @@ internal readonly partial struct MengerJourney : IPixelShader<float4>
|
||||
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));
|
||||
|
||||
@@ -109,7 +109,6 @@ internal readonly partial struct PyramidPattern : IPixelShader<float4>
|
||||
return 1.0f - Hlsl.Max(p.X, p.Y);
|
||||
}
|
||||
|
||||
|
||||
// Standard function-based bump mapping function, with an edge value included for good measure
|
||||
private float3 DoBumpMap(in float2 p, in float3 n, float bumpfactor, ref float edge)
|
||||
{
|
||||
@@ -131,7 +130,6 @@ internal readonly partial struct PyramidPattern : IPixelShader<float4>
|
||||
return Hlsl.Normalize(n + (grad * bumpfactor));
|
||||
}
|
||||
|
||||
|
||||
// A hatch-like algorithm, or a stipple... or some kind of textured pattern
|
||||
private float DoHatch(float2 p, float res)
|
||||
{
|
||||
|
||||
@@ -185,6 +185,7 @@ internal static unsafe class Win32ApplicationRunner
|
||||
{
|
||||
isPaused = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -124,6 +124,7 @@ partial class ID2D1ShaderGenerator
|
||||
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.Add(ref {rowLocalName}, {j})"),
|
||||
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.As<byte, {rowTypeName}>(ref global::System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref r0, (nint){matrix.Offsets[j]}))"))));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -149,6 +149,7 @@ partial class ID2D1ShaderGenerator
|
||||
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.As<byte, {rowTypeName}>(ref global::System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref r0, (nint){matrix.Offsets[j]}))"),
|
||||
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.Add(ref {rowLocalName}, {j})"))));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -49,6 +49,7 @@ partial class ID2D1ShaderGenerator
|
||||
|
||||
inputDescriptionsBuilder.Add(new InputDescription((uint)index, filter, levelOfDetailCount));
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
|
||||
#pragma warning disable IDE0025
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Translation;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,6 +5,8 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
|
||||
#pragma warning disable IDE0052
|
||||
|
||||
namespace ComputeSharp.__Internals;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -26,26 +26,6 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// </summary>
|
||||
private static readonly char[] FloatLiteralSpecialCharacters = { '.', 'E' };
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SemanticModelProvider"/> instance with semantic info on the target syntax tree.
|
||||
/// </summary>
|
||||
protected readonly SemanticModelProvider SemanticModel;
|
||||
|
||||
/// <summary>
|
||||
/// The collection of discovered custom types.
|
||||
/// </summary>
|
||||
protected readonly ICollection<INamedTypeSymbol> DiscoveredTypes;
|
||||
|
||||
/// <summary>
|
||||
/// The collection of discovered constant definitions.
|
||||
/// </summary>
|
||||
protected readonly IDictionary<IFieldSymbol, string> ConstantDefinitions;
|
||||
|
||||
/// <summary>
|
||||
/// The collection of produced <see cref="DiagnosticInfo"/> instances.
|
||||
/// </summary>
|
||||
protected readonly ImmutableArrayBuilder<DiagnosticInfo> Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HlslSourceRewriter"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -65,6 +45,26 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
Diagnostics = diagnostics;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SemanticModelProvider"/> instance with semantic info on the target syntax tree.
|
||||
/// </summary>
|
||||
protected SemanticModelProvider SemanticModel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of discovered custom types.
|
||||
/// </summary>
|
||||
protected ICollection<INamedTypeSymbol> DiscoveredTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of discovered constant definitions.
|
||||
/// </summary>
|
||||
protected IDictionary<IFieldSymbol, string> ConstantDefinitions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of produced <see cref="DiagnosticInfo"/> instances.
|
||||
/// </summary>
|
||||
protected ImmutableArrayBuilder<DiagnosticInfo> Diagnostics { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitCastExpression(CastExpressionSyntax node)
|
||||
{
|
||||
|
||||
@@ -560,8 +560,6 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
return updatedNode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Rewrites a sampled texture access.
|
||||
/// </summary>
|
||||
|
||||
+1
@@ -234,6 +234,7 @@ partial class IShaderGenerator
|
||||
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.As<uint, {rowTypeName}>(ref global::System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref r0, (nint){matrix.Offsets[j]}))"),
|
||||
ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.Add(ref {rowLocalName}, {j})"))));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -44,7 +44,7 @@ partial class IShaderGenerator
|
||||
.WithType(IdentifierName("TLoader")),
|
||||
Parameter(Identifier("result"))
|
||||
.AddModifiers(Token(SyntaxKind.OutKeyword))
|
||||
.WithType(IdentifierName($"global::System.{typeof(IntPtr).Name}")))
|
||||
.WithType(IdentifierName($"global::System.{nameof(IntPtr)}")))
|
||||
.WithBody(Block(GetDispatchMetadataLoadingStatements(metadataInfo)));
|
||||
}
|
||||
|
||||
@@ -122,7 +122,6 @@ partial class IShaderGenerator
|
||||
statements.Add(ParseStatement($"global::System.Runtime.CompilerServices.Unsafe.WriteUnaligned<int>(ref global::System.Runtime.CompilerServices.Unsafe.Add(ref r0, 0), {metadataInfo.Root32BitConstantCount});"));
|
||||
statements.Add(ParseStatement($"global::System.Runtime.CompilerServices.Unsafe.WriteUnaligned<bool>(ref global::System.Runtime.CompilerServices.Unsafe.Add(ref r0, 4), {metadataInfo.IsSamplerUsed.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()});"));
|
||||
|
||||
|
||||
// Populate the sequence of resource descriptors
|
||||
foreach (ResourceDescriptor descriptor in metadataInfo.ResourceDescriptors)
|
||||
{
|
||||
|
||||
@@ -92,7 +92,7 @@ partial class HlslKnownProperties
|
||||
// Programmatically load mappings for the normalized thread ids
|
||||
foreach (PropertyInfo? property in typeof(ThreadIds.Normalized).GetProperties(BindingFlags.Static | BindingFlags.Public))
|
||||
{
|
||||
string key = $"{typeof(ThreadIds).FullName}{Type.Delimiter}{typeof(ThreadIds.Normalized).Name}{Type.Delimiter}{property.Name}";
|
||||
string key = $"{typeof(ThreadIds).FullName}{Type.Delimiter}{nameof(ThreadIds.Normalized)}{Type.Delimiter}{property.Name}";
|
||||
|
||||
// The normalized value must be in the [0, 1] range, inclusive. As such, the expression is rewritten to be:
|
||||
// 1D: (float)ThreadIds.<XYZ> / (float)(max(1, __<xyz> - 1));
|
||||
@@ -105,11 +105,11 @@ partial class HlslKnownProperties
|
||||
switch (property.Name)
|
||||
{
|
||||
case string name when name.Length == 1:
|
||||
knownProperties.Add(key, $"(float){typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[0])} / (float)(max(1, __{char.ToLowerInvariant(name[0])} - 1))");
|
||||
knownProperties.Add(key, $"(float){nameof(ThreadIds)}.{char.ToLowerInvariant(name[0])} / (float)(max(1, __{char.ToLowerInvariant(name[0])} - 1))");
|
||||
break;
|
||||
case string name when name.Length == 2:
|
||||
{
|
||||
string numerator = $"float2({typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[0])}, {typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[1])})";
|
||||
string numerator = $"float2({nameof(ThreadIds)}.{char.ToLowerInvariant(name[0])}, {nameof(ThreadIds)}.{char.ToLowerInvariant(name[1])})";
|
||||
string denominator = $"float2(max(1, int2(__{char.ToLowerInvariant(name[0])}, __{char.ToLowerInvariant(name[1])}) - 1))";
|
||||
|
||||
knownProperties.Add(key, $"{numerator} / {denominator}");
|
||||
@@ -117,7 +117,7 @@ partial class HlslKnownProperties
|
||||
}
|
||||
case string name when name.Length == 3:
|
||||
{
|
||||
string numerator = $"float3({typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[0])}, {typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[1])}, {typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[2])})";
|
||||
string numerator = $"float3({nameof(ThreadIds)}.{char.ToLowerInvariant(name[0])}, {nameof(ThreadIds)}.{char.ToLowerInvariant(name[1])}, {nameof(ThreadIds)}.{char.ToLowerInvariant(name[2])})";
|
||||
string denominator = $"float3(max(1, int3(__{char.ToLowerInvariant(name[0])}, __{char.ToLowerInvariant(name[1])}, __{char.ToLowerInvariant(name[2])}) - 1))";
|
||||
|
||||
knownProperties.Add(key, $"{numerator} / {denominator}");
|
||||
|
||||
@@ -170,6 +170,7 @@ public abstract unsafe class TransferBuffer<T> : NativeObject, IGraphicsResource
|
||||
/// <inheritdoc/>
|
||||
public override Memory<T> Memory
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => CreateMemory(this.buffer.Length);
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -105,7 +105,6 @@ public abstract class NativeLibrariesResolverTestsBase
|
||||
Assert.AreEqual(0, Exec(pathToAppHostDirectory, $"{SampleProjectName}.exe", ""));
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(PublishMode.SelfContained, DeploymentMode.Multiassembly, NativeLibrariesDeploymentMode.NotApplicable)]
|
||||
[DataRow(PublishMode.FrameworkDependent, DeploymentMode.Multiassembly, NativeLibrariesDeploymentMode.NotApplicable)]
|
||||
|
||||
@@ -151,7 +151,6 @@ internal readonly partial struct ExtrudedTruchetPattern : IComputeShader
|
||||
return Hlsl.Max(shade, 0.0f);
|
||||
}
|
||||
|
||||
|
||||
// I keep a collection of occlusion routines... OK, that sounded really nerdy. :)
|
||||
// Anyway, I like this one. I'm assuHlsl.Ming it's based on IQ's original.
|
||||
private float CalculateAO(in float3 p, in float3 n)
|
||||
|
||||
@@ -76,7 +76,6 @@ internal readonly partial struct FourColorGradient : IComputeShader
|
||||
return 0.5f + 0.5f * n;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Execute()
|
||||
{
|
||||
|
||||
@@ -85,7 +85,9 @@ internal readonly partial struct MengerJourney : IComputeShader
|
||||
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);
|
||||
|
||||
@@ -101,7 +101,6 @@ internal readonly partial struct PyramidPattern : IComputeShader
|
||||
return 1.0f - Hlsl.Max(p.X, p.Y);
|
||||
}
|
||||
|
||||
|
||||
// Standard function-based bump mapping function, with an edge value included for good measure
|
||||
private float3 DoBumpMap(in float2 p, in float3 n, float bumpfactor, ref float edge)
|
||||
{
|
||||
@@ -123,7 +122,6 @@ internal readonly partial struct PyramidPattern : IComputeShader
|
||||
return Hlsl.Normalize(n + grad * bumpfactor);
|
||||
}
|
||||
|
||||
|
||||
// A hatch-like algorithm, or a stipple... or some kind of textured pattern
|
||||
private float DoHatch(float2 p, float res)
|
||||
{
|
||||
|
||||
@@ -64,7 +64,6 @@ internal readonly partial struct TriangleGridContouring : IComputeShader
|
||||
return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y);
|
||||
}
|
||||
|
||||
|
||||
// The isofunction. Just a Hlsl.Single noise function, but it can be more elaborate.
|
||||
private float IsoFunction(in float2 p)
|
||||
{
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする