Fix handling artificial fields in D3D12 constant buffer

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

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

+1 -1
ファイルの表示
@@ -59,7 +59,7 @@ partial class ComputeShaderDescriptorGenerator
writer.WriteLine("/// <inheritdoc/>");
writer.WriteGeneratedAttributes(GeneratorName);
writer.WriteLine("[global::System.Runtime.CompilerServices.SkipLocalsInit]");
writer.WriteLine($"static void global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{typeName}>.LoadConstantBuffer<TLoader>(in {typeName} shader, ref TLoader loader, int x, int y, int z)");
writer.WriteLine($"static unsafe void global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{typeName}>.LoadConstantBuffer<TLoader>(in {typeName} shader, ref TLoader loader, int x, int y, int z)");
using (writer.WriteBlock())
{
@@ -33,4 +33,14 @@ partial class ConstantBufferSyntaxProcessor
// Leave a trailing blank line if the shader has any fields
writer.WriteLineIf(!info.Fields.IsEmpty);
}
/// <inheritdoc/>
static partial void InitializeArtificialFields(IConstantBufferInfo info, IndentedTextWriter writer)
{
// Ignore the artificial fields (they will be set separately)
writer.WriteLine("Unsafe.SkipInit(out buffer.__x);");
writer.WriteLine("Unsafe.SkipInit(out buffer.__y);");
writer.WriteLineIf(!((ShaderInfo)info).IsPixelShaderLike, "Unsafe.SkipInit(out buffer.__z);");
writer.WriteLineIf(!info.Fields.IsEmpty);
}
}