Found the problem with openmp.

X here need to be declared as private, else each thread are sharing the same variable which... well.... don't work well .. :/
This commit is contained in:
Godzil
2020-02-26 16:09:28 +00:00
parent f1849cdbc1
commit a4ddfddbf3

View File

@@ -62,16 +62,19 @@ Canvas Camera::render(World world, uint32_t depth)
uint32_t x, y;
Canvas image = Canvas(this->horizontalSize, this->verticalSize);
for(y = 0; y < this->verticalSize; y++)
#pragma omp parallel private(x, y) shared(image)
{
#pragma omp parallel for
for(x = 0; x < this->horizontalSize; x++)
#pragma omp for
for (y = 0 ; y < this->verticalSize ; y++)
{
for (x = 0 ; x < this->horizontalSize ; x++)
{
Ray r = this->rayForPixel(x, y);
Tuple colour = world.colourAt(r, depth);
image.putPixel(x, y, colour);
}
}
}
return image;
}