Removed multiline variable declarations

このコミットが含まれているのは:
Sergio Pedri committed 2021-11-06 23:05:49 +01:00
1 親 6fa7464f84
コミット ee0d3a7b68
31ファイル変更
+182 -194

検索条件に一致するファイルはありません

+3 -4
ファイルの表示
@@ -679,10 +679,9 @@ public sealed partial class IShaderGenerator
AppendCharacterAndLF('}');
int
constantBuffersCount = 1,
readOnlyBuffersCount = 0,
readWriteBuffersCount = 0;
int constantBuffersCount = 1;
int readOnlyBuffersCount = 0;
int readWriteBuffersCount = 0;
// Optional implicit texture field
if (!isComputeShader)
+6 -9
ファイルの表示
@@ -67,9 +67,8 @@ public sealed partial class IShaderGenerator
var pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IPixelShader<byte>) });
var isComputeShader = pixelShaderSymbol is null;
int
resourceOffset = 0,
rawDataOffset = sizeof(int) * (isComputeShader ? 3 : 2);
int resourceOffset = 0;
int rawDataOffset = sizeof(int) * (isComputeShader ? 3 : 2);
// Append the statements for the dispatch ranges:
//
@@ -232,9 +231,8 @@ public sealed partial class IShaderGenerator
!fieldSymbol.IsConst && !fieldSymbol.IsStatic && !fieldSymbol.IsFixedSizeBuffer
select fieldSymbol)
{
string
fieldName = fieldSymbol.Name,
typeName = fieldSymbol.Type.GetFullMetadataName();
string fieldName = fieldSymbol.Name;
string typeName = fieldSymbol.Type.GetFullMetadataName();
// Disambiguates the name of target fields against the current input parameters
if (fieldName is "loader" or "device" or "x" or "y" or "z")
@@ -290,9 +288,8 @@ public sealed partial class IShaderGenerator
// each row needs to be at a multiple of 16 bytes (a float4 register).
if (HlslKnownTypes.IsNonLinearMatrixType(typeName, out string? elementName, out int rows, out int columns))
{
string
rowTypeName = $"global::ComputeSharp.{elementName}{columns}",
rowLocalName = $"__{string.Join("_", fieldPath)}__row0";
string rowTypeName = $"global::ComputeSharp.{elementName}{columns}";
string rowLocalName = $"__{string.Join("_", fieldPath)}__row0";
statements.Add(ParseStatement($"ref {rowTypeName} {rowLocalName} = ref global::System.Runtime.CompilerServices.Unsafe.As<global::{typeName}, {rowTypeName}>(ref global::System.Runtime.CompilerServices.Unsafe.AsRef(in {string.Join(".", fieldPath)}));"));
+4 -5
ファイルの表示
@@ -122,11 +122,10 @@ public sealed partial class IShaderGenerator
yield return ParseStatement($"global::System.Runtime.CompilerServices.Unsafe.WriteUnaligned<int>(ref global::System.Runtime.CompilerServices.Unsafe.Add(ref r0, 0), {root32BitConstantsCount});");
yield return ParseStatement($"global::System.Runtime.CompilerServices.Unsafe.WriteUnaligned<bool>(ref global::System.Runtime.CompilerServices.Unsafe.Add(ref r0, 4), {isSamplerUsed.ToString().ToLowerInvariant()});");
int
constantBufferOffset = 1,
readOnlyResourceOffset = 0,
readWriteResourceOffset = 0,
resourceOffset = 0;
int constantBufferOffset = 1;
int readOnlyResourceOffset = 0;
int readWriteResourceOffset = 0;
int resourceOffset = 0;
// Add the implicit texture descriptor, if needed
if (implicitTextureType is not null)
+4 -5
ファイルの表示
@@ -56,11 +56,10 @@ public sealed partial class IShaderGenerator : ISourceGenerator
private static void OnExecute(GeneratorExecutionContext context, StructDeclarationSyntax structDeclaration, INamedTypeSymbol structDeclarationSymbol)
{
// Create the required interface methods for the current shader type
MethodDeclarationSyntax
getDispatchIdMethod = CreateGetDispatchIdMethod(structDeclarationSymbol),
loadDispatchDataMethod = CreateLoadDispatchDataMethod(context, structDeclarationSymbol, out var discoveredResources, out int root32BitConstants),
buildHlslStringMethod = CreateBuildHlslStringMethod(context, structDeclaration, structDeclarationSymbol, out string? implicitTextureType, out bool isSamplerUsed),
loadDispatchMetadataMethod = CreateLoadDispatchMetadataMethod(implicitTextureType, discoveredResources, root32BitConstants, isSamplerUsed);
MethodDeclarationSyntax getDispatchIdMethod = CreateGetDispatchIdMethod(structDeclarationSymbol);
MethodDeclarationSyntax loadDispatchDataMethod = CreateLoadDispatchDataMethod(context, structDeclarationSymbol, out var discoveredResources, out int root32BitConstants);
MethodDeclarationSyntax buildHlslStringMethod = CreateBuildHlslStringMethod(context, structDeclaration, structDeclarationSymbol, out string? implicitTextureType, out bool isSamplerUsed);
MethodDeclarationSyntax loadDispatchMetadataMethod = CreateLoadDispatchMetadataMethod(implicitTextureType, discoveredResources, root32BitConstants, isSamplerUsed);
// Reorder the method declarations to respect the order in the interface definition
MethodDeclarationSyntax[] methods =
+6 -9
ファイルの表示
@@ -214,9 +214,8 @@ internal static class HlslKnownMembers
where Regex.IsMatch(property.Name, "^M[1-4]{2}$")
select (Type: type, Property: property))
{
char
row = (char)(item.Property.Name[1] - 1),
column = (char)(item.Property.Name[2] - 1);
char row = (char)(item.Property.Name[1] - 1);
char column = (char)(item.Property.Name[2] - 1);
knownMembers.Add($"{item.Type.FullName}{Type.Delimiter}{item.Property.Name}", $"_m{row}{column}");
}
@@ -254,18 +253,16 @@ internal static class HlslKnownMembers
break;
case string name when name.Length == 2:
{
string
numerator = $"float2({typeof(ThreadIds).Name}.{char.ToLower(name[0])}, {typeof(ThreadIds).Name}.{char.ToLower(name[1])})",
denominator = $"float2(__{char.ToLower(name[0])}, __{char.ToLower(name[1])})";
string numerator = $"float2({typeof(ThreadIds).Name}.{char.ToLower(name[0])}, {typeof(ThreadIds).Name}.{char.ToLower(name[1])})";
string denominator = $"float2(__{char.ToLower(name[0])}, __{char.ToLower(name[1])})";
knownMembers.Add(key, $"{numerator} / {denominator}");
break;
}
case string name when name.Length == 3:
{
string
numerator = $"float3({typeof(ThreadIds).Name}.{char.ToLower(name[0])}, {typeof(ThreadIds).Name}.{char.ToLower(name[1])}, {typeof(ThreadIds).Name}.{char.ToLower(name[2])})",
denominator = $"float3(__{char.ToLower(name[0])}, __{char.ToLower(name[1])}, __{char.ToLower(name[2])})";
string numerator = $"float3({typeof(ThreadIds).Name}.{char.ToLower(name[0])}, {typeof(ThreadIds).Name}.{char.ToLower(name[1])}, {typeof(ThreadIds).Name}.{char.ToLower(name[2])})";
string denominator = $"float3(__{char.ToLower(name[0])}, __{char.ToLower(name[1])}, __{char.ToLower(name[2])})";
knownMembers.Add(key, $"{numerator} / {denominator}");
break;
+2 -3
ファイルの表示
@@ -404,9 +404,8 @@ internal sealed class ShaderSourceRewriter : HlslSourceRewriter
if (!this.staticMethods.ContainsKey(method))
{
ShaderSourceRewriter shaderSourceRewriter = new(SemanticModel, DiscoveredTypes, this.staticMethods, ConstantDefinitions, Context);
MethodDeclarationSyntax
methodNode = (MethodDeclarationSyntax)method.DeclaringSyntaxReferences[0].GetSyntax(),
processedMethod = shaderSourceRewriter.Visit(methodNode)!.NormalizeWhitespace(eol: "\n").WithoutTrivia();
MethodDeclarationSyntax methodNode = (MethodDeclarationSyntax)method.DeclaringSyntaxReferences[0].GetSyntax();
MethodDeclarationSyntax processedMethod = shaderSourceRewriter.Visit(methodNode)!.NormalizeWhitespace(eol: "\n").WithoutTrivia();
this.staticMethods.Add(method, processedMethod.WithIdentifier(Identifier(methodIdentifier)));
}