Add renderstat to get some info about rendering.

This commit is contained in:
Godzil
2020-02-27 17:20:55 +00:00
parent a4ddfddbf3
commit a6f0422bd1
19 changed files with 194 additions and 12 deletions

View File

@@ -11,13 +11,21 @@
#include <intersect.h>
#include <float.h>
#include <renderstat.h>
#define MIN_ALLOC (2)
/* TODO: Memory allocation, even if using standard calloc/realloc have a huge impact on performances. need to find a way
* to reuse the intersect object without reallocating from scratch all the time. We use a lot of Intersect objects as
* there is at least 2 per ray (one for Ray intersect object, one object per light)
*/
Intersect::Intersect()
{
this->allocated = MIN_ALLOC;
this->list = (Intersection **)calloc(sizeof(Intersection *), MIN_ALLOC);
stats.addMalloc();
stats.addIntersect();
this->num = 0;
}
@@ -35,10 +43,13 @@ void Intersect::add(Intersection i)
if ((this->num + 1) > this->allocated)
{
this->allocated *= 2;
stats.addRealloc();
this->list = (Intersection **)realloc(this->list, sizeof(Intersection *) * this->allocated);
}
this->list[this->num++] = new Intersection(i.t, i.object);
stats.setMaxIntersect(this->num);
/* Now sort.. */
for(j = 1; j < (this->num); j++)
{