Use ImmutableArrayBuilder<char> for bytecode text
このコミットが含まれているのは:
1 親
a751d128a3
コミット
a15fce2a54
5ファイル変更
+21
-16
検索条件に一致するファイルはありません
@@ -63,7 +63,6 @@
|
||||
|
||||
<!-- ComputeSharp APIs -->
|
||||
<Compile Include="..\ComputeSharp\Core\Helpers\AlignmentHelper.cs" Link="ComputeSharp\Core\Helpers\AlignmentHelper.cs" />
|
||||
<Compile Include="..\ComputeSharp\Shaders\Dispatching\__Internals\ArrayPoolStringBuilder.cs" Link="ComputeSharp\Shaders\Dispatching\__Internals\ArrayPoolStringBuilder.cs" />
|
||||
|
||||
<!-- ComputeSharp.D2D1 APIs -->
|
||||
<Compile Include="..\ComputeSharp.D2D1\Properties\Polyfills\StringSyntaxAttribute.cs" Link="ComputeSharp.D2D1\Properties\Polyfills\StringSyntaxAttribute.cs" />
|
||||
|
||||
+6
-7
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.D2D1.__Internals;
|
||||
using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
@@ -216,18 +216,17 @@ partial class ID2D1ShaderGenerator
|
||||
/// <returns>A formatted <see cref="string"/> with the serialized data.</returns>
|
||||
internal static string BuildShaderBytecodeExpressionString(ReadOnlySpan<byte> bytecode)
|
||||
{
|
||||
//The estimation is 4 characters per byte (up to "255" in hex), plus ", " to separate sequential values
|
||||
using ArrayPoolStringBuilder builder = ArrayPoolStringBuilder.Create(bytecode.Length * 6);
|
||||
using ImmutableArrayBuilder<char> builder = ImmutableArrayBuilder<char>.Rent();
|
||||
|
||||
builder.Append(formattedBytes[bytecode[0]]);
|
||||
builder.AddRange(formattedBytes[bytecode[0]].AsSpan());
|
||||
|
||||
foreach (byte b in bytecode.Slice(1))
|
||||
{
|
||||
builder.Append(", ");
|
||||
builder.Append(formattedBytes[b]);
|
||||
builder.AddRange(", ".AsSpan());
|
||||
builder.AddRange(formattedBytes[b].AsSpan());
|
||||
}
|
||||
|
||||
return builder.WrittenSpan.ToString();
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,15 @@ internal ref struct ImmutableArrayBuilder<T>
|
||||
/// </summary>
|
||||
public Writer()
|
||||
{
|
||||
this.array = new T[8];
|
||||
if (typeof(T) == typeof(char))
|
||||
{
|
||||
this.array = new T[1024];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.array = new T[8];
|
||||
}
|
||||
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
<Compile Include="..\ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" Link="ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" />
|
||||
<Compile Include="..\ComputeSharp.Dynamic\Shaders\Exceptions\DxcCompilationException.cs" Link="ComputeSharp\Shaders\Exceptions\DxcCompilationException.cs" />
|
||||
<Compile Include="..\ComputeSharp.Dynamic\Shaders\Translation\ShaderCompiler.cs" Link="ComputeSharp\Shaders\Translation\ShaderCompiler.cs" />
|
||||
<Compile Include="..\ComputeSharp\Shaders\Dispatching\__Internals\ArrayPoolStringBuilder.cs" Link="ComputeSharp\Shaders\Dispatching\__Internals\ArrayPoolStringBuilder.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGenerators.Models;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
@@ -237,18 +238,17 @@ partial class IShaderGenerator
|
||||
/// <returns>A formatted <see cref="string"/> with the serialized data.</returns>
|
||||
private static string BuildShaderBytecodeExpressionString(ReadOnlySpan<byte> bytecode)
|
||||
{
|
||||
//The estimation is 4 characters per byte (up to "255" in hex), plus ", " to separate sequential values
|
||||
using ArrayPoolStringBuilder builder = ArrayPoolStringBuilder.Create(bytecode.Length * 6);
|
||||
using ImmutableArrayBuilder<char> builder = ImmutableArrayBuilder<char>.Rent();
|
||||
|
||||
builder.Append(formattedBytes[bytecode[0]]);
|
||||
builder.AddRange(formattedBytes[bytecode[0]].AsSpan());
|
||||
|
||||
foreach (byte b in bytecode.Slice(1))
|
||||
{
|
||||
builder.Append(", ");
|
||||
builder.Append(formattedBytes[b]);
|
||||
builder.AddRange(", ".AsSpan());
|
||||
builder.AddRange(formattedBytes[b].AsSpan());
|
||||
}
|
||||
|
||||
return builder.WrittenSpan.ToString();
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする