6d2a14cc6f84964c185e6c7291e1851f819dfc9c
9 #include "AnimateurFreeGL.h"
14 /*----------------------------------------------------------------------*\
16 \*---------------------------------------------------------------------*/
18 /*--------------------------------------*\
20 \*-------------------------------------*/
22 /*--------------------------------------*\
24 \*-------------------------------------*/
26 /*--------------------------------------*\
28 \*-------------------------------------*/
30 /*----------------------------------------------------------------------*\
32 \*---------------------------------------------------------------------*/
34 /*--------------------------------------*\
36 \*-------------------------------------*/
38 AnimateurFreeGL::AnimateurFreeGL(Animable_I
* ptrAnimable
, int nbIteration
)
41 this->nbIteration
= nbIteration
;
42 this->ptrAnimable
= ptrAnimable
;
46 this->timeElapseS
= -1;
52 AnimateurFreeGL::~AnimateurFreeGL()
54 delete ptrAnimable
; // discutable!
57 int AnimateurFreeGL::getFps(void)
62 /*--------------------------------------*\
64 \*-------------------------------------*/
66 int AnimateurFreeGL::start()
68 cout
<< "\n[AnimateurFreeGL] : started : " << ptrAnimable
->getTitle() << endl
;
70 int w
= ptrAnimable
->getW();
71 int h
= ptrAnimable
->getH();
72 size_t size
= w
* h
* sizeof(uchar4
);
75 HANDLE_ERROR(cudaMalloc((void**) &ptrDevImage
, size
));
76 HANDLE_ERROR(cudaMemset(ptrDevImage
, 0, size
));
80 const char* messageError
=ptrAnimable
->getTitle().c_str();
81 while (i
< nbIteration
)
83 ptrAnimable
->runGPU(ptrDevImage
);
85 Device::checkKernelError(messageError
);
86 Device::synchronize(); // Important!
88 ptrAnimable
->animationStep();
94 HANDLE_ERROR(cudaFree(ptrDevImage
));
96 this->timeElapseS
= chrono
.getDeltaTime();
97 this->fps
= nbIteration
/ timeElapseS
;
102 void AnimateurFreeGL::printStat()
105 cout
<< "Benchmark : [" << ptrAnimable
->getTitle()<<"]" << endl
;
106 cout
<< "#Iteration : " << nbIteration
<< endl
;
107 cout
<< "#secondes : " << timeElapseS
<< " (s)" << endl
;
108 cout
<< "#fps : " << fps
<< endl
;
111 /*----------------------------------------------------------------------*\
113 \*---------------------------------------------------------------------*/