Material Clustering Benchmark
WrapperArtificialReadback.cs
Go to the documentation of this file.
1using static Diagnostics;
2
4{
5 /// <summary>
6 /// Runs the clustering function from the wrapped dispatcher and performs one (useless) readback after every iteration. Used to measure the impact of readback on frame times.
7 /// </summary>
9 {
10 private readonly ASimpleDispatcer wrappedDispatcher;
11
13 {
14 this.wrappedDispatcher = wrappedDispatcher;
15 if (wrappedDispatcher.usesStopCondition)
16 {
17 Throw(
18 new System.InvalidOperationException(
19 "WrapperArtificialReadback must be given a dispatcher, which does not use stop condition."
20 )
21 );
22 }
23 if (wrappedDispatcher.doesReadback)
24 {
25 Throw(
26 new System.InvalidOperationException(
27 "WrapperArtificialReadback must be given a dispatcher, which does not use readback."
28 )
29 );
30 }
31 }
32
33 public void Dispose()
34 {
35 this.wrappedDispatcher.Dispose();
36 }
37
38 public bool usesStopCondition => this.wrappedDispatcher.usesStopCondition;
39 public bool doesReadback => true;
40 public int warningCounter => this.wrappedDispatcher.warningCounter;
41
42 public virtual string name => $"{this.wrappedDispatcher.name} + readback";
43 public bool doRandomizeEmptyClusters => this.wrappedDispatcher.doRandomizeEmptyClusters;
44 public int numIterations => this.wrappedDispatcher.numIterations;
46 this.wrappedDispatcher.clusteringRTsAndBuffers;
47 public DispatcherParameters abstractParameters => this.wrappedDispatcher.abstractParameters;
48
49 public void UpdateClusterCenters(ClusteringTextures clusteringTextures, bool rejectOld)
50 {
51 this.wrappedDispatcher.UpdateClusterCenters(
52 clusteringTextures: clusteringTextures,
53 rejectOld: rejectOld
54 );
55 }
56
57 public void AttributeClustersKM(ClusteringTextures clusteringTextures)
58 {
59 this.wrappedDispatcher.AttributeClustersKM(clusteringTextures: clusteringTextures);
60 }
61
62 public bool useFullResTexRef => this.wrappedDispatcher.useFullResTexRef;
63
64 public float? GetVariance()
65 {
66 return this.wrappedDispatcher.GetVariance();
67 }
68
69 public virtual void RunClustering(ClusteringTextures clusteringTextures)
70 {
71 for (int i = 0; i < this.wrappedDispatcher.numIterations; i++)
72 {
73 this.wrappedDispatcher.SingleIteration(clusteringTextures);
74
75 // artificial readback
76 this.wrappedDispatcher.clusteringRTsAndBuffers.GetClusterCenters().Dispose();
77 }
78 }
79 }
80}
Call Allocate before using and Dispose after using.
Runs the clustering function from the wrapped dispatcher and performs one (useless) readback after ev...
WrapperArtificialReadback(ASimpleDispatcer wrappedDispatcher)
virtual void RunClustering(ClusteringTextures clusteringTextures)
void AttributeClustersKM(ClusteringTextures clusteringTextures)
float? GetVariance()
Computes variance for the current cluster centers. Depending on this.useFullResTexRef uses either wor...
void UpdateClusterCenters(ClusteringTextures clusteringTextures, bool rejectOld)
Call Dispose after using.
Call Dispose after using.
Definition: IDispatcher.cs:9