@@ -197,76 +197,76 @@ int main(int argc, char *argv[]) {
197
197
auto wallsBuf = sycl::buffer<std::array<vecType, 2 >>(walls.data (), walls.size ());
198
198
auto pathsBuf = sycl::buffer<Path>(paths.data (), paths.size ());
199
199
200
- // int delayCounter = 0;
201
- // int updateBBoxCounter = 0;
202
- // bool isQuit = false;
203
- // bool isPause = false;
204
- // SDL_Event event;
205
-
206
- // std::vector<int> executionTimes;
207
-
208
- // while (!isQuit) {
209
- // if (SDL_PollEvent(&event)) {
210
- // if (event.type == SDL_QUIT) {
211
- // isQuit = true;
212
- // } else if (event.type == SDL_KEYDOWN &&
213
- // event.key.keysym.sym == SDLK_SPACE) {
214
- // isPause = !isPause;
215
- // }
216
- // }
217
-
218
- // if (!isPause) {
219
- // if (delayCounter >= DELAY) {
220
- // delayCounter = 0;
221
- // auto start = std::chrono::high_resolution_clock::now();
222
-
223
- // if (updateBBoxCounter <= 0) {
224
- // updateBBox(myQueue, actorBuf);
225
- // updateBBoxCounter = 20;
226
- // }
227
-
228
- // updateVariations(myQueue, actorBuf);
229
- // update(myQueue, actorBuf, wallsBuf, pathsBuf);
230
-
231
- // auto end = std::chrono::high_resolution_clock::now();
232
- // auto duration =
233
- // std::chrono::duration_cast<std::chrono::milliseconds>(
234
- // end - start);
235
- // executionTimes.push_back(duration.count());
236
- // // std::cout << "fps: " << (1000.0f / duration.count()) <<
237
- // // std::endl;
238
-
239
- // sycl::host_accessor<Actor, 1, sycl::access::mode::read> actorHostAcc(actorBuf);
240
-
241
- // draw(SCALE, render, actorHostAcc, room);
242
- // updateBBoxCounter--;
243
- // } else {
244
- // delayCounter++;
245
- // }
246
- // }
247
- // }
200
+ int delayCounter = 0 ;
201
+ int updateBBoxCounter = 0 ;
202
+ bool isQuit = false ;
203
+ bool isPause = false ;
204
+ SDL_Event event;
205
+
206
+ std::vector<int > executionTimes;
207
+
208
+ while (!isQuit) {
209
+ if (SDL_PollEvent (&event)) {
210
+ if (event.type == SDL_QUIT) {
211
+ isQuit = true ;
212
+ } else if (event.type == SDL_KEYDOWN &&
213
+ event.key .keysym .sym == SDLK_SPACE) {
214
+ isPause = !isPause;
215
+ }
216
+ }
248
217
249
- // executionTimes.erase(executionTimes.begin());
250
- // float count = static_cast<float>(executionTimes.size());
251
- // float mean =
252
- // std::accumulate(executionTimes.begin(), executionTimes.end(), 0.0) /
253
- // count;
254
- // std::cout << "Mean execution time: " << mean << std::endl;
255
-
256
- // close(win, render);
257
-
258
- // For Profiling
259
- int updateBBoxCounterr = 0 ;
260
- for (int x = 0 ; x < 500 ; x++) {
261
- if (updateBBoxCounterr <= 0 ) {
262
- updateBBox (myQueue, actorBuf);
263
- updateBBoxCounterr = 20 ;
218
+ if (!isPause) {
219
+ if (delayCounter >= DELAY) {
220
+ delayCounter = 0 ;
221
+ auto start = std::chrono::high_resolution_clock::now ();
222
+
223
+ if (updateBBoxCounter <= 0 ) {
224
+ updateBBox (myQueue, actorBuf);
225
+ updateBBoxCounter = 20 ;
226
+ }
227
+
228
+ updateVariations (myQueue, actorBuf);
229
+ update (myQueue, actorBuf, wallsBuf, pathsBuf);
230
+
231
+ auto end = std::chrono::high_resolution_clock::now ();
232
+ auto duration =
233
+ std::chrono::duration_cast<std::chrono::milliseconds>(
234
+ end - start);
235
+ executionTimes.push_back (duration.count ());
236
+ // std::cout << "fps: " << (1000.0f / duration.count()) <<
237
+ // std::endl;
238
+
239
+ sycl::host_accessor<Actor, 1 , sycl::access::mode::read> actorHostAcc (actorBuf);
240
+
241
+ draw (SCALE, render, actorHostAcc, room);
242
+ updateBBoxCounter--;
243
+ } else {
244
+ delayCounter++;
245
+ }
264
246
}
265
- updateVariations (myQueue, actorBuf);
266
- update (myQueue, actorBuf, wallsBuf, pathsBuf);
267
- sycl::host_accessor<Actor, 1 , sycl::access::mode::read> actorHostAcc (actorBuf);
268
- updateBBoxCounterr--;
269
247
}
270
248
249
+ executionTimes.erase (executionTimes.begin ());
250
+ float count = static_cast <float >(executionTimes.size ());
251
+ float mean =
252
+ std::accumulate (executionTimes.begin (), executionTimes.end (), 0.0 ) /
253
+ count;
254
+ std::cout << " Mean execution time: " << mean << std::endl;
255
+
256
+ close (win, render);
257
+
258
+ // // For Profiling
259
+ // int updateBBoxCounterr = 0;
260
+ // for (int x = 0; x < 500; x++) {
261
+ // if (updateBBoxCounterr <= 0) {
262
+ // updateBBox(myQueue, actorBuf);
263
+ // updateBBoxCounterr = 20;
264
+ // }
265
+ // updateVariations(myQueue, actorBuf);
266
+ // update(myQueue, actorBuf, wallsBuf, pathsBuf);
267
+ // sycl::host_accessor<Actor, 1, sycl::access::mode::read> actorHostAcc(actorBuf);
268
+ // updateBBoxCounterr--;
269
+ // }
270
+
271
271
return 0 ;
272
272
}
0 commit comments