Skip to content

Commit 872b315

Browse files
Remove WebGPUTextureTransfer and use Readback APIs
1 parent de08b34 commit 872b315

9 files changed

Lines changed: 119 additions & 438 deletions

File tree

src/ImageSharp.Drawing.WebGPU/WebGPURenderTargetAllocation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace SixLabors.ImageSharp.Drawing.Processing.Backends;
88

99
/// <summary>
10-
/// Shared WebGPU render-target allocation helpers used by the public target API and internal tests.
10+
/// Shared WebGPU render-target allocation helpers used by the public target API.
1111
/// </summary>
1212
internal static unsafe class WebGPURenderTargetAllocation
1313
{

src/ImageSharp.Drawing.WebGPU/WebGPURenderTarget{TPixel}.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,11 @@ public void ReadbackInto(Image<TPixel> destination)
211211
nameof(destination));
212212
}
213213

214-
Buffer2DRegion<TPixel> region = new(destination.Frames.RootFrame.PixelBuffer, destination.Bounds);
215214
if (!this.Graphics.Backend.TryReadRegion(
216215
this.Graphics.Configuration,
217216
this.NativeFrame,
218217
new Rectangle(0, 0, this.Width, this.Height),
219-
region,
218+
new Buffer2DRegion<TPixel>(destination.Frames.RootFrame.PixelBuffer),
220219
out string? error))
221220
{
222221
if (error is null)

src/ImageSharp.Drawing.WebGPU/WebGPUTextureTransfer.cs

Lines changed: 0 additions & 298 deletions
This file was deleted.

tests/ImageSharp.Drawing.Benchmarks/Drawing/FillParis.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ internal static void VerifyOutput()
191191
bench.skSurface,
192192
bench.sdBitmap,
193193
bench.image,
194-
bench.webGpuTarget.TextureHandle);
194+
bench.webGpuTarget);
195195

196196
bench.Cleanup();
197197
}

tests/ImageSharp.Drawing.Benchmarks/Drawing/FillTiger.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public static void VerifyOutput(int dimensions = 1000)
218218
bench.skSurface,
219219
bench.sdBitmap,
220220
bench.image,
221-
bench.webGpuTarget.TextureHandle);
221+
bench.webGpuTarget);
222222

223223
bench.Cleanup();
224224
}
@@ -278,15 +278,8 @@ public static void VerifyTransformBaked(int width, int height, float zoom, float
278278
System.IO.Directory.CreateDirectory(dir);
279279
image.Save(System.IO.Path.Combine(dir, tag + "-imagesharp.png"));
280280

281-
if (WebGPUTextureTransfer.TryReadTexture(webGpuTarget.TextureHandle, width, height, out Image<Rgba32> gpuImage, out string readError))
282-
{
283-
gpuImage.SaveAsPng(System.IO.Path.Combine(dir, tag + "-webgpu.png"));
284-
gpuImage.Dispose();
285-
}
286-
else
287-
{
288-
Console.WriteLine($"WebGPU readback failed: {readError}");
289-
}
281+
using Image<Rgba32> gpuImage = webGpuTarget.Readback();
282+
gpuImage.SaveAsPng(System.IO.Path.Combine(dir, tag + "-webgpu.png"));
290283

291284
Console.WriteLine($"Output saved to: {dir}");
292285

@@ -370,7 +363,7 @@ public static void VerifyTransform(int width, int height, float zoom, float panX
370363
PrintWebGpuDiagnostics(printer);
371364

372365
string tag = $"tiger-xform-{width}x{height}-z{zoom:0.##}-p{panX:0.##}_{panY:0.##}";
373-
SvgBenchmarkHelper.VerifyOutput(tag, width, height, sk, sdBitmap, image, webGpuTarget.TextureHandle);
366+
SvgBenchmarkHelper.VerifyOutput(tag, width, height, sk, sdBitmap, image, webGpuTarget);
374367

375368
foreach ((SKPath path, SKPaint fill, SKPaint stroke) in skElements)
376369
{

0 commit comments

Comments
 (0)