保存した畳み込みの値にゲインを掛けて描く処理を追加する

このコミットが含まれているのは:
routersys committed 2026-10-03 14:10:52 +09:00
1 親 ae0e17ed1b
コミット 36faac26d2
3ファイル変更
+56

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

+23
ファイルの表示
@@ -146,6 +146,29 @@ public sealed class GpuTileConvolverTests
}
}
[Theory]
[InlineData(1f)]
[InlineData(2.75f)]
[InlineData(0.3f)]
public void RenderingTheStoreMatchesTheConvolutionBitForBit(float gain)
{
var scene = Scene(64, 5, 150, 97, 11, 47);
var device = HardwareOrDefault();
var fused = Run(device, scene, gain);
using var convolver = new GpuTileConvolver(device);
var stored = Run(device, convolver, scene, 1f);
var width = scene.Plan.RegionWidth;
var height = scene.Plan.RegionHeight;
using var output = device.AllocateReadWriteTexture2D<Bgra32, Float4>(width, height);
using (var context = device.CreateComputeContext())
GpuTileConvolver.RecordStored(in context, convolver.StoreFor(stored.Job), output, width, height, gain);
var pixels = new Bgra32[width * height];
output.CopyTo(pixels);
Assert.Equal(fused.Output, MemoryMarshal.Cast<Bgra32, byte>(pixels).ToArray());
}
[Fact]
public void TheStatisticsDescribeTheSource()
{
+9
ファイルの表示
@@ -226,6 +226,15 @@ internal sealed class GpuTileConvolver : IDisposable
context.Barrier(report);
}
public static void RecordStored(
in ComputeContext context,
ReadWriteBuffer<Float4> store,
ReadWriteTexture2D<Bgra32, Float4> output,
int width,
int height,
float gain)
=> context.For(width, height, new StoredRenderShader(store, output, width, height, gain));
public void Dispose()
{
tiles?.Dispose();
+24
ファイルの表示
@@ -16,6 +16,30 @@ internal readonly partial struct ReportResetShader(
}
}
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
[CompileOptions(CompileOptions.Default | CompileOptions.IeeeStrictness)]
internal readonly partial struct StoredRenderShader(
ReadWriteBuffer<Float4> store,
ReadWriteTexture2D<Bgra32, Float4> output,
int width,
int height,
float gain) : IComputeShader
{
private readonly ReadWriteBuffer<Float4> store = store;
private readonly ReadWriteTexture2D<Bgra32, Float4> output = output;
private readonly int width = width;
private readonly int height = height;
private readonly float gain = gain;
public void Execute()
{
if (ThreadIds.X >= width || ThreadIds.Y >= height)
return;
output[ThreadIds.XY] = store[ThreadIds.Y * width + ThreadIds.X] * gain;
}
}
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
[GeneratedComputeShaderDescriptor]
[CompileOptions(CompileOptions.Default | CompileOptions.IeeeStrictness)]