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:
@@ -62,16 +62,19 @@ Canvas Camera::render(World world, uint32_t depth)
|
|||||||
uint32_t x, y;
|
uint32_t x, y;
|
||||||
Canvas image = Canvas(this->horizontalSize, this->verticalSize);
|
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
|
#pragma omp for
|
||||||
for(x = 0; x < this->horizontalSize; x++)
|
for (y = 0 ; y < this->verticalSize ; y++)
|
||||||
|
{
|
||||||
|
for (x = 0 ; x < this->horizontalSize ; x++)
|
||||||
{
|
{
|
||||||
Ray r = this->rayForPixel(x, y);
|
Ray r = this->rayForPixel(x, y);
|
||||||
Tuple colour = world.colourAt(r, depth);
|
Tuple colour = world.colourAt(r, depth);
|
||||||
image.putPixel(x, y, colour);
|
image.putPixel(x, y, colour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user