contributed by<yanang
>
yanang
進度落後請加緊腳步!
課程助教
# Rendering scene
Done!
Execution time of raytracing() : 2.817711 sec
# Rendering scene
Done!
Execution time of raytracing() : 5.906013 sec
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
24.71 0.60 0.60 56956357 0.00 0.00 subtract_vector
21.00 1.11 0.51 69646433 0.00 0.00 dot_product
9.47 1.34 0.23 31410180 0.00 0.00 multiply_vector
8.24 1.54 0.20 17836094 0.00 0.00 add_vector
7.41 1.72 0.18 13861875 0.00 0.00 rayRectangularIntersection
5.76 1.86 0.14 13861875 0.00 0.00 raySphereIntersection
4.94 1.98 0.12 10598450 0.00 0.00 normalize
double dot_product(const double *v1, const double *v2)
{
return (v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]);
}
# Rendering scene
Done!
Execution time of raytracing() : 2.384672 sec sec
typedef struct __PARAMETER{
uint8_t *pixels;
rectangular_node rectangulars;
sphere_node spheres;
light_node lights;
const viewpoint *view;
int width_start;
int width;
int height_start;
int height;
} para;
CC ?= gcc
CFLAGS = \
-std=gnu99 -Wall -O0 -g
LDFLAGS = \
-lm -lpthread
para *ptr = malloc(sizeof(para));
ptr->pixels = pixels;
ptr->rectangulars = rectangulars;
...
pthread_create(&pid0, NULL, raytracing, (void *)ptr);
para ptr[4];
ptr[0].pixels = pixels;
ptr[0].rectangulars = rectangulars;
...
pthread_create(&pid0, NULL, raytracing, (void *)&ptr[0]);
raytracing() 運算當中的 width 和 height 指的是邊界(512),而非輸入的最大 width 和 height ,未修改結果
修改後測試 (回復正常的圖)
$ ./rayracing
# Rendering scene
Done!
Execution time of raytracing() : 0.963422 sec
# Rendering scene
Done!
Execution time of raytracing() : 0.806448 sec
# Rendering scene
Done!
Execution time of raytracing() : 0.654491 sec
# Rendering scene
Done!
Execution time of raytracing() : 0.272825 sec