Move renderstat function into the CPP file and add atomic to the variables.
This commit is contained in:
@@ -11,9 +11,6 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef RENDER_STATS
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
class RenderStats
|
class RenderStats
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -44,58 +41,29 @@ public:
|
|||||||
pixelCount(0), rayCount(0), lightRayEmitedCount(0), reflectionRayCount(0), refractedRayCount(0),
|
pixelCount(0), rayCount(0), lightRayEmitedCount(0), reflectionRayCount(0), refractedRayCount(0),
|
||||||
intersectCount(0), intersectionCount(0), reallocCallCount(0), mallocCallCount(0),
|
intersectCount(0), intersectionCount(0), reallocCallCount(0), mallocCallCount(0),
|
||||||
discardedIntersectCount(0), maxDepthAttained(UINT64_MAX), maxIntersectOnARay(0) {};
|
discardedIntersectCount(0), maxDepthAttained(UINT64_MAX), maxIntersectOnARay(0) {};
|
||||||
|
#ifdef RENDER_STATS
|
||||||
void addCone() { this->coneCount++; };
|
void addCone();
|
||||||
void addCylinder() { this->cylinderCount++; };
|
void addCylinder();
|
||||||
void addCube() { this->cubeCount++; };
|
void addCube();
|
||||||
void addGroup() { this->groupCount++; };
|
void addGroup();
|
||||||
void addLight() { this->lightCount++; };
|
void addLight();
|
||||||
void addPlane() { this->planeCount++; };
|
void addPlane();
|
||||||
void addSphere() { this->sphereCount++; };
|
void addSphere();
|
||||||
void addTriangle() { this->triangleCount++; };
|
void addTriangle();
|
||||||
|
void printStats();
|
||||||
void addPixel() { this->pixelCount++; };
|
void addPixel();
|
||||||
void addRay() { this->rayCount++; };
|
void addRay();
|
||||||
void addLightRay() { this->lightRayEmitedCount++; };
|
void addLightRay();
|
||||||
void addReflectRay() { this->reflectionRayCount++; };
|
void addReflectRay();
|
||||||
void addRefractRay() { this->refractedRayCount++; };
|
void addRefractRay();
|
||||||
void addIntersect() { this->intersectCount++; };
|
void addIntersection();
|
||||||
void addIntersection() { this->intersectionCount++; };
|
void addDiscardedIntersect();
|
||||||
void addMalloc() { this->mallocCallCount++; };
|
void setMaxDepth(uint32_t depth);
|
||||||
void addRealloc() { this->reallocCallCount++; };
|
void addIntersect();
|
||||||
void addDiscardedIntersect() { this->discardedIntersectCount++; };
|
void addMalloc();
|
||||||
void setMaxDepth(uint32_t depth) { if (this->maxDepthAttained>depth) { this->maxDepthAttained = depth; } };
|
void addRealloc();
|
||||||
void setMaxIntersect(uint32_t count) { if (this->maxIntersectOnARay<count) { this->maxIntersectOnARay = count; } };
|
void setMaxIntersect(uint32_t count);
|
||||||
void printStats() {
|
|
||||||
printf("Rendering statistics:\n");
|
|
||||||
printf("Cones : %lld\n", this->coneCount);
|
|
||||||
printf("Cubes : %lld\n", this->cubeCount);
|
|
||||||
printf("Cylinders : %lld\n", this->cylinderCount);
|
|
||||||
printf("Groups : %lld\n", this->groupCount);
|
|
||||||
printf("Lights : %lld\n", this->lightCount);
|
|
||||||
printf("Planes : %lld\n", this->planeCount);
|
|
||||||
printf("Spheres : %lld\n", this->sphereCount);
|
|
||||||
printf("Triangles : %lld\n", this->triangleCount);
|
|
||||||
printf("==================================================\n");
|
|
||||||
printf("Pixel rendered : %lld\n", this->pixelCount);
|
|
||||||
printf("Ray casted : %lld\n", this->rayCount);
|
|
||||||
printf("Light Ray casted : %lld\n", this->lightRayEmitedCount);
|
|
||||||
printf("Reflection ray casted : %lld\n", this->reflectionRayCount);
|
|
||||||
printf("Refraction ray casted : %lld\n", this->refractedRayCount);
|
|
||||||
printf("Intersect object created: %lld\n", this->intersectCount);
|
|
||||||
printf("Intersection created : %lld\n", this->intersectionCount);
|
|
||||||
printf("Malloc called : %lld\n", this->mallocCallCount);
|
|
||||||
printf("Realloc called : %lld\n", this->reallocCallCount);
|
|
||||||
printf("Bounding box missed : %lld\n", this->discardedIntersectCount);
|
|
||||||
printf("Min depth atteined : %lld\n", this->maxDepthAttained);
|
|
||||||
printf("Max intersect count : %lld\n", this->maxIntersectOnARay);
|
|
||||||
printf("==================================================\n");
|
|
||||||
};
|
|
||||||
};
|
|
||||||
#else
|
#else
|
||||||
class RenderStats
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void addCone() {};
|
static void addCone() {};
|
||||||
static void addCylinder() {};
|
static void addCylinder() {};
|
||||||
static void addCube() {};
|
static void addCube() {};
|
||||||
@@ -117,8 +85,9 @@ public:
|
|||||||
static void addMalloc() {};
|
static void addMalloc() {};
|
||||||
static void addRealloc() {};
|
static void addRealloc() {};
|
||||||
static void setMaxIntersect(uint32_t count) {};
|
static void setMaxIntersect(uint32_t count) {};
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
extern RenderStats stats;
|
extern RenderStats stats;
|
||||||
|
|
||||||
|
|||||||
@@ -7,5 +7,161 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <renderstat.h>
|
#include <renderstat.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
RenderStats stats;
|
RenderStats stats;
|
||||||
|
|
||||||
|
#ifdef RENDER_STATS
|
||||||
|
|
||||||
|
void RenderStats::addCone()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->coneCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addCylinder()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->cylinderCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addCube()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->cubeCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addGroup()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->groupCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addLight()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->lightCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addPlane()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->planeCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addSphere()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->sphereCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addTriangle()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->triangleCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addPixel()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->pixelCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addRay()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->rayCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addLightRay()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->lightRayEmitedCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addReflectRay()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->reflectionRayCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addRefractRay()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->refractedRayCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addIntersect()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->intersectCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addIntersection()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->intersectionCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addMalloc()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->mallocCallCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addRealloc()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->reallocCallCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::addDiscardedIntersect()
|
||||||
|
{
|
||||||
|
#pragma omp atomic
|
||||||
|
this->discardedIntersectCount++;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::setMaxDepth(uint32_t depth)
|
||||||
|
{
|
||||||
|
if (this->maxDepthAttained > depth)
|
||||||
|
{
|
||||||
|
this->maxDepthAttained = depth;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::setMaxIntersect(uint32_t count)
|
||||||
|
{
|
||||||
|
if (this->maxIntersectOnARay < count)
|
||||||
|
{
|
||||||
|
this->maxIntersectOnARay = count;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void RenderStats::printStats()
|
||||||
|
{
|
||||||
|
printf("Rendering statistics:\n");
|
||||||
|
printf("Cones : %lld\n", this->coneCount);
|
||||||
|
printf("Cubes : %lld\n", this->cubeCount);
|
||||||
|
printf("Cylinders : %lld\n", this->cylinderCount);
|
||||||
|
printf("Groups : %lld\n", this->groupCount);
|
||||||
|
printf("Lights : %lld\n", this->lightCount);
|
||||||
|
printf("Planes : %lld\n", this->planeCount);
|
||||||
|
printf("Spheres : %lld\n", this->sphereCount);
|
||||||
|
printf("Triangles : %lld\n", this->triangleCount);
|
||||||
|
printf("==================================================\n");
|
||||||
|
printf("Pixel rendered : %lld\n", this->pixelCount);
|
||||||
|
printf("Ray casted : %lld\n", this->rayCount);
|
||||||
|
printf("Light Ray casted : %lld\n", this->lightRayEmitedCount);
|
||||||
|
printf("Reflection ray casted : %lld\n", this->reflectionRayCount);
|
||||||
|
printf("Refraction ray casted : %lld\n", this->refractedRayCount);
|
||||||
|
printf("Intersect object created: %lld\n", this->intersectCount);
|
||||||
|
printf("Intersection created : %lld\n", this->intersectionCount);
|
||||||
|
printf("Malloc called : %lld\n", this->mallocCallCount);
|
||||||
|
printf("Realloc called : %lld\n", this->reallocCallCount);
|
||||||
|
printf("Bounding box missed : %lld\n", this->discardedIntersectCount);
|
||||||
|
printf("Min depth atteined : %lld\n", this->maxDepthAttained);
|
||||||
|
printf("Max intersect count : %lld\n", this->maxIntersectOnARay);
|
||||||
|
printf("==================================================\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user