renderstat.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Render statistics implementation
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #include <renderstat.h>
  10. #include <stdio.h>
  11. RenderStats stats;
  12. #ifdef RENDER_STATS
  13. void RenderStats::addCone()
  14. {
  15. #pragma omp atomic
  16. this->coneCount++;
  17. };
  18. void RenderStats::addCylinder()
  19. {
  20. #pragma omp atomic
  21. this->cylinderCount++;
  22. };
  23. void RenderStats::addCube()
  24. {
  25. #pragma omp atomic
  26. this->cubeCount++;
  27. };
  28. void RenderStats::addGroup()
  29. {
  30. #pragma omp atomic
  31. this->groupCount++;
  32. };
  33. void RenderStats::addLight()
  34. {
  35. #pragma omp atomic
  36. this->lightCount++;
  37. };
  38. void RenderStats::addPlane()
  39. {
  40. #pragma omp atomic
  41. this->planeCount++;
  42. };
  43. void RenderStats::addSphere()
  44. {
  45. #pragma omp atomic
  46. this->sphereCount++;
  47. };
  48. void RenderStats::addTriangle()
  49. {
  50. #pragma omp atomic
  51. this->triangleCount++;
  52. };
  53. void RenderStats::addSmoothTriangle()
  54. {
  55. #pragma omp atomic
  56. this->smoothTriangleCount++;
  57. };
  58. void RenderStats::addOBJFile()
  59. {
  60. #pragma omp atomic
  61. this->objfileCount++;
  62. };
  63. void RenderStats::addPixel()
  64. {
  65. #pragma omp atomic
  66. this->pixelCount++;
  67. };
  68. void RenderStats::addRay()
  69. {
  70. #pragma omp atomic
  71. this->rayCount++;
  72. };
  73. void RenderStats::addLightRay()
  74. {
  75. #pragma omp atomic
  76. this->lightRayEmitedCount++;
  77. };
  78. void RenderStats::addReflectRay()
  79. {
  80. #pragma omp atomic
  81. this->reflectionRayCount++;
  82. };
  83. void RenderStats::addRefractRay()
  84. {
  85. #pragma omp atomic
  86. this->refractedRayCount++;
  87. };
  88. void RenderStats::addIntersect()
  89. {
  90. #pragma omp atomic
  91. this->intersectCount++;
  92. };
  93. void RenderStats::addIntersection()
  94. {
  95. #pragma omp atomic
  96. this->intersectionCount++;
  97. };
  98. void RenderStats::addMalloc()
  99. {
  100. #pragma omp atomic
  101. this->mallocCallCount++;
  102. };
  103. void RenderStats::addRealloc()
  104. {
  105. #pragma omp atomic
  106. this->reallocCallCount++;
  107. };
  108. void RenderStats::addDiscardedIntersect()
  109. {
  110. #pragma omp atomic
  111. this->discardedIntersectCount++;
  112. };
  113. void RenderStats::setMaxDepth(uint32_t depth)
  114. {
  115. if (this->maxDepthAttained > depth)
  116. {
  117. this->maxDepthAttained = depth;
  118. }
  119. };
  120. void RenderStats::setMaxIntersect(uint32_t count)
  121. {
  122. if (this->maxIntersectOnARay < count)
  123. {
  124. this->maxIntersectOnARay = count;
  125. }
  126. };
  127. void RenderStats::printStats()
  128. {
  129. printf("Rendering statistics:\n");
  130. printf("Cones : %lld\n", this->coneCount);
  131. printf("Cubes : %lld\n", this->cubeCount);
  132. printf("Cylinders : %lld\n", this->cylinderCount);
  133. printf("Groups : %lld\n", this->groupCount);
  134. printf("Lights : %lld\n", this->lightCount);
  135. printf("Planes : %lld\n", this->planeCount);
  136. printf("Spheres : %lld\n", this->sphereCount);
  137. printf("Triangles : %lld\n", this->triangleCount);
  138. printf("Smooth Triangles : %lld\n", this->smoothTriangleCount);
  139. printf("OBJ File : %lld\n", this->objfileCount);
  140. printf("==================================================\n");
  141. printf("Pixel rendered : %lld\n", this->pixelCount);
  142. printf("Ray casted : %lld\n", this->rayCount);
  143. printf("Light Ray casted : %lld\n", this->lightRayEmitedCount);
  144. printf("Reflection ray casted : %lld\n", this->reflectionRayCount);
  145. printf("Refraction ray casted : %lld\n", this->refractedRayCount);
  146. printf("Intersect object created: %lld\n", this->intersectCount);
  147. printf("Intersection created : %lld\n", this->intersectionCount);
  148. printf("Malloc called : %lld\n", this->mallocCallCount);
  149. printf("Realloc called : %lld\n", this->reallocCallCount);
  150. printf("Bounding box missed : %lld\n", this->discardedIntersectCount);
  151. printf("Min depth atteined : %lld\n", this->maxDepthAttained);
  152. printf("Max intersect count : %lld\n", this->maxIntersectOnARay);
  153. printf("==================================================\n");
  154. };
  155. #endif