Skip to content

Commit 76ff622

Browse files
Treat DeviceLost a non-fatal until it is.
1 parent 1defc56 commit 76ff622

7 files changed

Lines changed: 360 additions & 88 deletions

File tree

samples/DrawingBackendBenchmark/Program.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,27 @@ private static void Main()
2222
/// <summary>
2323
/// Running statistics for the render-time samples collected during one benchmark run.
2424
/// </summary>
25-
internal readonly record struct BenchmarkStatistics(double MeanMilliseconds, double StdDevMilliseconds)
25+
internal readonly struct BenchmarkStatistics
2626
{
27+
/// <summary>
28+
/// Initializes a new instance of the <see cref="BenchmarkStatistics"/> struct.
29+
/// </summary>
30+
public BenchmarkStatistics(double meanMilliseconds, double stdDevMilliseconds)
31+
{
32+
this.MeanMilliseconds = meanMilliseconds;
33+
this.StdDevMilliseconds = stdDevMilliseconds;
34+
}
35+
36+
/// <summary>
37+
/// Gets the mean render time in milliseconds.
38+
/// </summary>
39+
public double MeanMilliseconds { get; }
40+
41+
/// <summary>
42+
/// Gets the render-time standard deviation in milliseconds.
43+
/// </summary>
44+
public double StdDevMilliseconds { get; }
45+
2746
/// <summary>
2847
/// Computes the mean and standard deviation for the current sample window.
2948
/// </summary>

samples/DrawingBackendBenchmark/VisualLine.cs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,52 @@ namespace DrawingBackendBenchmark;
1414
/// <summary>
1515
/// One random line draw command used by the benchmark scene.
1616
/// </summary>
17-
internal readonly record struct VisualLine(PointF Start, PointF End, Color Color, float Width)
17+
internal readonly struct VisualLine
1818
{
1919
private static readonly Brush BackgroundBrush = Brushes.Solid(Color.ParseHex("#003366"));
2020

21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="VisualLine"/> struct.
23+
/// </summary>
24+
public VisualLine(PointF start, PointF end, Color color, float width)
25+
{
26+
this.Start = start;
27+
this.End = end;
28+
this.Color = color;
29+
this.Width = width;
30+
this.SkiaColor = ToSkiaColor(color);
31+
this.Pen = new SolidPen(color, width);
32+
}
33+
34+
/// <summary>
35+
/// Gets the line start point.
36+
/// </summary>
37+
public PointF Start { get; }
38+
39+
/// <summary>
40+
/// Gets the line end point.
41+
/// </summary>
42+
public PointF End { get; }
43+
44+
/// <summary>
45+
/// Gets the line color.
46+
/// </summary>
47+
public Color Color { get; }
48+
49+
/// <summary>
50+
/// Gets the line width.
51+
/// </summary>
52+
public float Width { get; }
53+
2154
/// <summary>
2255
/// Gets the pre-converted SkiaSharp color for this line, avoiding per-frame conversion overhead.
2356
/// </summary>
24-
public SKColor SkiaColor { get; } = ToSkiaColor(Color);
57+
public SKColor SkiaColor { get; }
2558

2659
/// <summary>
2760
/// Gets the pre-created ImageSharp pen for this line, avoiding one per-frame allocation in the benchmark hot path.
2861
/// </summary>
29-
public SolidPen Pen { get; } = new(Color, Width);
62+
public SolidPen Pen { get; }
3063

3164
private static SKColor ToSkiaColor(Color color)
3265
{

src/ImageSharp.Drawing.WebGPU/WebGPUSceneDispatch.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,41 @@ public enum BindingLimitBuffer
9393
/// <summary>
9494
/// Describes one binding-limit failure reported while planning a staged scene.
9595
/// </summary>
96-
/// <param name="Buffer">The staged-scene binding that exceeded the current device limit.</param>
97-
/// <param name="RequiredBytes">The number of bytes required by that binding.</param>
98-
/// <param name="LimitBytes">The maximum number of bytes the current device allows for that binding.</param>
99-
public readonly record struct BindingLimitFailure(BindingLimitBuffer Buffer, nuint RequiredBytes, nuint LimitBytes)
96+
public readonly struct BindingLimitFailure
10097
{
98+
/// <summary>
99+
/// Initializes a new instance of the <see cref="BindingLimitFailure"/> struct.
100+
/// </summary>
101+
/// <param name="buffer">The staged-scene binding that exceeded the current device limit.</param>
102+
/// <param name="requiredBytes">The number of bytes required by that binding.</param>
103+
/// <param name="limitBytes">The maximum number of bytes the current device allows for that binding.</param>
104+
public BindingLimitFailure(BindingLimitBuffer buffer, nuint requiredBytes, nuint limitBytes)
105+
{
106+
this.Buffer = buffer;
107+
this.RequiredBytes = requiredBytes;
108+
this.LimitBytes = limitBytes;
109+
}
110+
101111
/// <summary>
102112
/// Gets the empty binding-limit result.
103113
/// </summary>
104114
public static BindingLimitFailure None { get; } = new(BindingLimitBuffer.None, 0, 0);
105115

116+
/// <summary>
117+
/// Gets the staged-scene binding that exceeded the current device limit.
118+
/// </summary>
119+
public BindingLimitBuffer Buffer { get; }
120+
121+
/// <summary>
122+
/// Gets the number of bytes required by the binding.
123+
/// </summary>
124+
public nuint RequiredBytes { get; }
125+
126+
/// <summary>
127+
/// Gets the maximum number of bytes the current device allows for the binding.
128+
/// </summary>
129+
public nuint LimitBytes { get; }
130+
106131
/// <summary>
107132
/// Gets a value indicating whether one binding exceeded the current device limit.
108133
/// </summary>

0 commit comments

Comments
 (0)