renderstat.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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::addPixel()
  54. {
  55. #pragma omp atomic
  56. this->pixelCount++;
  57. };
  58. void RenderStats::addRay()
  59. {
  60. #pragma omp atomic
  61. this->rayCount++;
  62. };
  63. void RenderStats::addLightRay()
  64. {
  65. #pragma omp atomic
  66. this->lightRayEmitedCount++;
  67. };
  68. void RenderStats::addReflectRay()
  69. {
  70. #pragma omp atomic
  71. this->reflectionRayCount++;
  72. };
  73. void RenderStats::addRefractRay()
  74. {
  75. #pragma omp atomic
  76. this->refractedRayCount++;
  77. };
  78. void RenderStats::addIntersect()
  79. {
  80. #pragma omp atomic
  81. this->intersectCount++;
  82. };
  83. void RenderStats::addIntersection()
  84. {
  85. #pragma omp atomic
  86. this->intersectionCount++;
  87. };
  88. void RenderStats::addMalloc()
  89. {
  90. #pragma omp atomic
  91. this->mallocCallCount++;
  92. };
  93. void RenderStats::addRealloc()
  94. {
  95. #pragma omp atomic
  96. this->reallocCallCount++;
  97. };
  98. void RenderStats::addDiscardedIntersect()
  99. {
  100. #pragma omp atomic
  101. this->discardedIntersectCount++;
  102. };
  103. void RenderStats::setMaxDepth(uint32_t depth)
  104. {
  105. if (this->maxDepthAttained > depth)
  106. {
  107. this->maxDepthAttained = depth;
  108. }
  109. };
  110. void RenderStats::setMaxIntersect(uint32_t count)
  111. {
  112. if (this->maxIntersectOnARay < count)
  113. {
  114. this->maxIntersectOnARay = count;
  115. }
  116. };
  117. void RenderStats::printStats()
  118. {
  119. printf("Rendering statistics:\n");
  120. printf("Cones : %lld\n", this->coneCount);
  121. printf("Cubes : %lld\n", this->cubeCount);
  122. printf("Cylinders : %lld\n", this->cylinderCount);
  123. printf("Groups : %lld\n", this->groupCount);
  124. printf("Lights : %lld\n", this->lightCount);
  125. printf("Planes : %lld\n", this->planeCount);
  126. printf("Spheres : %lld\n", this->sphereCount);
  127. printf("Triangles : %lld\n", this->triangleCount);
  128. printf("==================================================\n");
  129. printf("Pixel rendered : %lld\n", this->pixelCount);
  130. printf("Ray casted : %lld\n", this->rayCount);
  131. printf("Light Ray casted : %lld\n", this->lightRayEmitedCount);
  132. printf("Reflection ray casted : %lld\n", this->reflectionRayCount);
  133. printf("Refraction ray casted : %lld\n", this->refractedRayCount);
  134. printf("Intersect object created: %lld\n", this->intersectCount);
  135. printf("Intersection created : %lld\n", this->intersectionCount);
  136. printf("Malloc called : %lld\n", this->mallocCallCount);
  137. printf("Realloc called : %lld\n", this->reallocCallCount);
  138. printf("Bounding box missed : %lld\n", this->discardedIntersectCount);
  139. printf("Min depth atteined : %lld\n", this->maxDepthAttained);
  140. printf("Max intersect count : %lld\n", this->maxIntersectOnARay);
  141. printf("==================================================\n");
  142. };
  143. #endif