renderstat.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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::addCastedRay()
  74. {
  75. #pragma omp atomic
  76. this->rayCasted++;
  77. };
  78. void RenderStats::addLightRay()
  79. {
  80. this->addCastedRay();
  81. #pragma omp atomic
  82. this->lightRayEmitedCount++;
  83. };
  84. void RenderStats::addReflectRay()
  85. {
  86. this->addCastedRay();
  87. #pragma omp atomic
  88. this->reflectionRayCount++;
  89. };
  90. void RenderStats::addRefractRay()
  91. {
  92. this->addCastedRay();
  93. #pragma omp atomic
  94. this->refractedRayCount++;
  95. };
  96. void RenderStats::addIntersect()
  97. {
  98. #pragma omp atomic
  99. this->intersectCount++;
  100. };
  101. void RenderStats::addIntersection()
  102. {
  103. #pragma omp atomic
  104. this->intersectionCount++;
  105. };
  106. void RenderStats::addMalloc()
  107. {
  108. #pragma omp atomic
  109. this->mallocCallCount++;
  110. };
  111. void RenderStats::addRealloc()
  112. {
  113. #pragma omp atomic
  114. this->reallocCallCount++;
  115. };
  116. void RenderStats::addDiscardedIntersect()
  117. {
  118. #pragma omp atomic
  119. this->discardedIntersectCount++;
  120. };
  121. void RenderStats::addCsg()
  122. {
  123. #pragma omp atomic
  124. this->csgCount++;
  125. };
  126. void RenderStats::setMaxDepth(uint32_t depth)
  127. {
  128. if (this->maxDepthAttained > depth)
  129. {
  130. this->maxDepthAttained = depth;
  131. }
  132. };
  133. void RenderStats::setMaxIntersect(uint32_t count)
  134. {
  135. if (this->maxIntersectOnARay < count)
  136. {
  137. this->maxIntersectOnARay = count;
  138. }
  139. };
  140. void RenderStats::printStats()
  141. {
  142. printf("Rendering statistics:\n");
  143. printf("Cones : %lld\n", this->coneCount);
  144. printf("Cubes : %lld\n", this->cubeCount);
  145. printf("Cylinders : %lld\n", this->cylinderCount);
  146. printf("Groups : %lld\n", this->groupCount);
  147. printf("Lights : %lld\n", this->lightCount);
  148. printf("Planes : %lld\n", this->planeCount);
  149. printf("Spheres : %lld\n", this->sphereCount);
  150. printf("Triangles : %lld\n", this->triangleCount);
  151. printf("Smooth Triangles : %lld\n", this->smoothTriangleCount);
  152. printf("OBJ File : %lld\n", this->objfileCount);
  153. printf("CSG : %lld\n", this->csgCount);
  154. printf("==================================================\n");
  155. printf("Pixel rendered : %lld\n", this->pixelCount);
  156. printf("Ray created : %lld\n", this->rayCount);
  157. printf("Ray casted : %lld\n", this->rayCasted);
  158. printf("Light Ray casted : %lld\n", this->lightRayEmitedCount);
  159. printf("Reflection ray casted : %lld\n", this->reflectionRayCount);
  160. printf("Refraction ray casted : %lld\n", this->refractedRayCount);
  161. printf("Intersect object created: %lld\n", this->intersectCount);
  162. printf("Intersection created : %lld\n", this->intersectionCount);
  163. printf("Malloc called : %lld\n", this->mallocCallCount);
  164. printf("Realloc called : %lld\n", this->reallocCallCount);
  165. printf("Bounding box missed : %lld\n", this->discardedIntersectCount);
  166. printf("Min depth attained : %lld\n", this->maxDepthAttained);
  167. printf("Max intersect count : %lld\n", this->maxIntersectOnARay);
  168. printf("==================================================\n");
  169. };
  170. #endif