Remove unnecessary ResourceInfo.Offset property

このコミットが含まれているのは:
Sergio Pedri committed 2023-11-20 21:11:45 +01:00
1 親 fcf287c4ad
コミット e4fb230068
2ファイル変更
+5 -8

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

+4 -6
ファイルの表示
@@ -33,8 +33,6 @@ partial class ComputeShaderDescriptorGenerator
int constantBufferSizeInBytes,
out ImmutableArray<ResourceInfo> resources)
{
int resourceOffset = 0;
using ImmutableArrayBuilder<ResourceInfo> resourceBuilder = new();
foreach (ISymbol memberSymbol in structDeclarationSymbol.GetMembers())
@@ -57,7 +55,7 @@ partial class ComputeShaderDescriptorGenerator
// Check if the field is a resource (note: resources can only be top level fields)
if (HlslKnownTypes.IsTypedResourceType(typeName))
{
resourceBuilder.Add(new ResourceInfo(fieldName, typeName, resourceOffset++));
resourceBuilder.Add(new ResourceInfo(fieldName, typeName));
}
}
@@ -71,7 +69,7 @@ partial class ComputeShaderDescriptorGenerator
// So here we check whether the current signature respects that constraint,
// and emit a build error otherwise. For more info on this, see the docs here:
// https://docs.microsoft.com/windows/win32/direct3d12/root-signature-limits.
if ((constantBufferSizeInBytes / sizeof(int)) + resourceOffset > 64)
if ((constantBufferSizeInBytes / sizeof(int)) + resourceBuilder.Count > 64)
{
diagnostics.Add(ShaderDispatchDataSizeExceeded, structDeclarationSymbol, structDeclarationSymbol);
}
@@ -93,9 +91,9 @@ partial class ComputeShaderDescriptorGenerator
using (writer.WriteBlock())
{
// Generate loading statements for each captured resource
foreach (ResourceInfo resource in info.Resources)
for (int i = 0; i < info.Resources.Length; i++)
{
writer.WriteLine($"loader.LoadGraphicsResource(shader.{resource.FieldName}, {resource.Offset});");
writer.WriteLine($"loader.LoadGraphicsResource(shader.{info.Resources[i].FieldName}, {i});");
}
}
}
+1 -2
ファイルの表示
@@ -5,5 +5,4 @@ namespace ComputeSharp.SourceGenerators.Models;
/// </summary>
/// <param name="FieldName">The name of the resource field.</param>
/// <param name="TypeName">The full metadata name for the resource type.</param>
/// <param name="Offset">The offset for the resource within the root signature.</param>
public sealed record ResourceInfo(string FieldName, string TypeName, int Offset);
public sealed record ResourceInfo(string FieldName, string TypeName);