Material Clustering Benchmark
AlgorithmsConvergence.cs
Go to the documentation of this file.
1using UnityEngine;
3
5{
7 {
8 private const int textureSize = 64;
9 private const bool doRandomizeEmptyClusters = false;
10
12 int kernelSize,
13 UnityEngine.Video.VideoClip[] videos,
14 ComputeShader csHighlightRemoval
16
18 {
19 var workList = new BenchmarkDescription(
20 ClusteringTest.LogType.Variance,
21 "Algorithm convergence"
22 );
23
24 foreach (UnityEngine.Video.VideoClip video in this.videos)
25 {
26 for (int numIterations = 1; numIterations < 30; numIterations++)
27 {
28 AddFixedIterations(
29 workList: workList,
30 video: video,
31 textureSize: textureSize,
32 numIterations: numIterations,
34 );
35 }
36
37 AddStopCondtion(
38 workList: workList,
39 video: video,
40 textureSize: textureSize,
42 );
43 }
44
45 return workList;
46 }
47
48 private static void AddFixedIterations(
49 BenchmarkDescription workList,
50 UnityEngine.Video.VideoClip video,
51 int textureSize,
52 int numIterations,
53 ComputeShader csHighlightRemoval
54 )
55 {
56 // KM
57 workList.dispatches.Push(
59 staggeredJitter: false,
60 video: video,
61 doDownscale: false,
62 dispatcher: new DispatcherKM(
63 computeShader: csHighlightRemoval,
64 numIterations: numIterations,
65 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
66 useFullResTexRef: false,
67 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
68 numClusters: 6,
69 workingSize: textureSize,
71 jitterSize: 1
72 )
73 )
74 )
75 );
76
77 // KHM
78 workList.dispatches.Push(
80 staggeredJitter: false,
81 video: video,
82 doDownscale: false,
83 dispatcher: new DispatcherKHMp(
84 computeShader: csHighlightRemoval,
85 numIterations: numIterations,
86 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
87 useFullResTexRef: false,
88 parameters: DispatcherKHMp.Parameters.Default(),
89 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
90 numClusters: 6,
91 workingSize: textureSize,
93 jitterSize: 1
94 )
95 )
96 )
97 );
98
99 // RS
100 if (DispatcherRSfixed.IsNumIterationsValid(iterations: numIterations, iterationsKM: 2))
101 {
102 workList.dispatches.Push(
104 staggeredJitter: false,
105 video: video,
106 doDownscale: false,
107 dispatcher: new DispatcherRSfixed(
108 computeShader: csHighlightRemoval,
109 numIterations: numIterations,
110 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
111 useFullResTexRef: false,
112 parameters: DispatcherRSfixed.Parameters.Default(),
113 doReadback: false,
114 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
115 numClusters: 6,
116 workingSize: textureSize,
118 jitterSize: 1
119 )
120 )
121 )
122 );
123 }
124 }
125
126 private static void AddStopCondtion(
127 BenchmarkDescription workList,
128 UnityEngine.Video.VideoClip video,
129 int textureSize,
130 ComputeShader csHighlightRemoval
131 )
132 {
133 // Knecht
134 workList.dispatches.Push(
135 new LaunchParameters(
136 staggeredJitter: false,
137 video: video,
138 doDownscale: false,
139 dispatcher: new DispatcherKnecht(
140 computeShader: csHighlightRemoval,
141 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
142 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
143 numClusters: 6,
144 workingSize: textureSize,
146 jitterSize: 1
147 )
148 )
149 )
150 );
151
152 // RS stop condition
153 workList.dispatches.Push(
154 new LaunchParameters(
155 staggeredJitter: false,
156 video: video,
157 doDownscale: false,
158 dispatcher: new DispatcherRSstopCondition(
159 computeShader: csHighlightRemoval,
160 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
161 useFullResTexRef: false,
162 parameters: DispatcherRSfixed.Parameters.Default(),
163 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
164 numClusters: 6,
165 workingSize: textureSize,
167 jitterSize: 1
168 )
169 )
170 )
171 );
172
173 // KM stop condition
174 workList.dispatches.Push(
175 new LaunchParameters(
176 staggeredJitter: false,
177 video: video,
178 doDownscale: false,
179 dispatcher: new WrapperStopCondition(
180 new DispatcherKM(
181 computeShader: csHighlightRemoval,
182 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
183 useFullResTexRef: false,
184 numIterations: 1,
185 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
186 numClusters: 6,
187 workingSize: textureSize,
189 jitterSize: 1
190 )
191 )
192 )
193 )
194 );
195
196 // KHM stop condition
197 workList.dispatches.Push(
198 new LaunchParameters(
199 staggeredJitter: false,
200 video: video,
201 doDownscale: false,
202 dispatcher: new WrapperStopCondition(
203 new DispatcherKHMp(
204 computeShader: csHighlightRemoval,
205 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
206 useFullResTexRef: false,
207 numIterations: 1,
208 parameters: DispatcherKHMp.Parameters.Default(),
209 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
210 numClusters: 6,
211 workingSize: textureSize,
213 jitterSize: 1
214 )
215 )
216 )
217 )
218 );
219 }
220 }
221}
readonly UnityEngine.Video.VideoClip[] videos
AlgorithmsConvergence(int kernelSize, UnityEngine.Video.VideoClip[] videos, ComputeShader csHighlightRemoval)
override BenchmarkDescription GenerateBenchmark()
readonly Stack< LaunchParameters > dispatches
Call Allocate before using and Dispose after using.
static Parameters Default()
Default value of Parameters.p is 2.5, which we experimentally confirmed to be optimal for our dataset...
static bool IsNumIterationsValid(int iterationsKM, int iterations)
const int fullTextureSize