Material Clustering Benchmark
FrameTime.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
11 public FrameTime(
12 int kernelSize,
13 UnityEngine.Video.VideoClip[] videos,
14 ComputeShader csHighlightRemoval
16
18 {
19 var workList = new BenchmarkDescription(ClusteringTest.LogType.FrameTime, "Frame time");
20
21 for (int i = 0; i < 5; i++)
22 {
23 foreach (UnityEngine.Video.VideoClip video in this.videos)
24 {
25 // 3 iterations
26 {
27 const int numIterations = 3;
28
29 // KM
30 workList.dispatches.Push(
32 staggeredJitter: false,
33 video: video,
34 doDownscale: false,
35 dispatcher: new DispatcherKM(
36 computeShader: this.csHighlightRemoval,
37 numIterations: numIterations,
38 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
39 useFullResTexRef: false,
40 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
41 numClusters: 6,
42 workingSize: textureSize,
44 jitterSize: 1
45 )
46 )
47 )
48 );
49
50 // KHM
51 workList.dispatches.Push(
53 staggeredJitter: false,
54 video: video,
55 doDownscale: false,
56 dispatcher: new DispatcherKHMp(
57 computeShader: this.csHighlightRemoval,
58 numIterations: numIterations,
59 doRandomizeEmptyClusters,
60 useFullResTexRef: false,
61 parameters: DispatcherKHMp.Parameters.Default(),
62 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
63 numClusters: 6,
64 workingSize: textureSize,
66 jitterSize: 1
67 )
68 )
69 )
70 );
71
72 foreach (bool doReadback in new bool[] { true, false })
73 {
74 // RS(2KM)
75 workList.dispatches.Push(
77 staggeredJitter: false,
78 video: video,
79 doDownscale: false,
80 dispatcher: new DispatcherRSfixed(
81 computeShader: this.csHighlightRemoval,
82 numIterations: numIterations,
83 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
84 useFullResTexRef: false,
85 parameters: DispatcherRSfixed.Parameters.Default(),
86 doReadback: doReadback,
87 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
88 numClusters: 6,
89 workingSize: textureSize,
91 jitterSize: 1
92 )
93 )
94 )
95 );
96 }
97 }
98
99 // 2 iterations
100 {
101 const int numIterations = 2;
102
103 // KM
104 workList.dispatches.Push(
106 staggeredJitter: false,
107 video: video,
108 doDownscale: false,
109 dispatcher: new DispatcherKM(
110 computeShader: this.csHighlightRemoval,
111 numIterations: numIterations,
112 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
113 useFullResTexRef: false,
114 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
115 numClusters: 6,
116 workingSize: textureSize,
118 jitterSize: 1
119 )
120 )
121 )
122 );
123 // KM + readback
124 workList.dispatches.Push(
126 staggeredJitter: false,
127 video: video,
128 doDownscale: false,
129 dispatcher: new WrapperArtificialReadback(
130 new DispatcherKM(
131 computeShader: this.csHighlightRemoval,
132 numIterations: numIterations,
133 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
134 useFullResTexRef: false,
135 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
136 numClusters: 6,
137 workingSize: textureSize,
139 jitterSize: 1
140 )
141 )
142 )
143 )
144 );
145
146 // KHM
147 workList.dispatches.Push(
149 staggeredJitter: false,
150 video: video,
151 doDownscale: false,
152 dispatcher: new DispatcherKHMp(
153 computeShader: this.csHighlightRemoval,
154 numIterations: numIterations,
155 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
156 useFullResTexRef: false,
157 parameters: DispatcherKHMp.Parameters.Default(),
158 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
159 numClusters: 6,
160 workingSize: textureSize,
162 jitterSize: 1
163 )
164 )
165 )
166 );
167 // KHM + readback
168 workList.dispatches.Push(
170 staggeredJitter: false,
171 video: video,
172 doDownscale: false,
173 dispatcher: new WrapperArtificialReadback(
174 new DispatcherKHMp(
175 computeShader: this.csHighlightRemoval,
176 numIterations: numIterations,
177 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
178 useFullResTexRef: false,
179 parameters: DispatcherKHMp.Parameters.Default(),
180 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
181 numClusters: 6,
182 workingSize: textureSize,
184 jitterSize: 1
185 )
186 )
187 )
188 )
189 );
190 }
191
192 AddStopCondtion(
193 workList: workList,
194 video: video,
195 textureSize: textureSize,
197 );
198 }
199 }
200
201 return workList;
202 }
203
204 private static void AddStopCondtion(
205 BenchmarkDescription workList,
206 UnityEngine.Video.VideoClip video,
207 int textureSize,
208 ComputeShader csHighlightRemoval
209 )
210 {
211 // Knecht
212 workList.dispatches.Push(
214 staggeredJitter: false,
215 video: video,
216 doDownscale: false,
217 dispatcher: new DispatcherKnecht(
218 computeShader: csHighlightRemoval,
219 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
220 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
221 numClusters: 6,
222 workingSize: textureSize,
224 jitterSize: 1
225 )
226 )
227 )
228 );
229
230 // RS stop condition
231 workList.dispatches.Push(
233 staggeredJitter: false,
234 video: video,
235 doDownscale: false,
236 dispatcher: new DispatcherRSstopCondition(
237 computeShader: csHighlightRemoval,
238 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
239 useFullResTexRef: false,
240 parameters: DispatcherRSfixed.Parameters.Default(),
241 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
242 numClusters: 6,
243 workingSize: textureSize,
245 jitterSize: 1
246 )
247 )
248 )
249 );
250
251 // KM stop condition
252 workList.dispatches.Push(
254 staggeredJitter: false,
255 video: video,
256 doDownscale: false,
257 dispatcher: new WrapperStopCondition(
258 new DispatcherKM(
259 computeShader: csHighlightRemoval,
260 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
261 useFullResTexRef: false,
262 numIterations: 1,
263 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
264 numClusters: 6,
265 workingSize: textureSize,
267 jitterSize: 1
268 )
269 )
270 )
271 )
272 );
273
274 // KHM stop condition
275 workList.dispatches.Push(
277 staggeredJitter: false,
278 video: video,
279 doDownscale: false,
280 dispatcher: new WrapperStopCondition(
281 new DispatcherKHMp(
282 computeShader: csHighlightRemoval,
283 doRandomizeEmptyClusters: doRandomizeEmptyClusters,
284 useFullResTexRef: false,
285 numIterations: 1,
286 parameters: DispatcherKHMp.Parameters.Default(),
287 clusteringRTsAndBuffers: new ClusteringRTsAndBuffers(
288 numClusters: 6,
289 workingSize: textureSize,
291 jitterSize: 1
292 )
293 )
294 )
295 )
296 );
297 }
298 }
299}
readonly UnityEngine.Video.VideoClip[] videos
readonly Stack< LaunchParameters > dispatches
override BenchmarkDescription GenerateBenchmark()
Definition: FrameTime.cs:17
FrameTime(int kernelSize, UnityEngine.Video.VideoClip[] videos, ComputeShader csHighlightRemoval)
Definition: FrameTime.cs:11
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...
Runs the clustering function from the wrapped dispatcher and performs one (useless) readback after ev...
const int fullTextureSize