You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, please pay attention to this piece of code in monte_carlo_renderer.cl (actually, this pattern appears in many kernels):
int idx = pixel_idx[global_id];
int y = idx / output_width;
int x = idx % output_width;
// Get pointer to ray & path handles
GLOBAL ray* my_ray = rays + global_id;
// Initialize sampler
Sampler sampler;
#if SAMPLER == SOBOL
uint scramble = random[x + output_width * y] * 0x1fe3434f;
if (frame & 0xF)
{
random[x + output_width * y] = WangHash(scramble);
}
Sampler_Init(&sampler, frame, SAMPLE_DIM_CAMERA_OFFSET, scramble);
#elif SAMPLER == RANDOM
uint scramble = x + output_width * y * rng_seed;
Sampler_Init(&sampler, scramble);
#elif SAMPLER == CMJ
uint rnd = random[x + output_width * y];
uint scramble = rnd * 0x1fe3434f * ((frame + 133 * rnd) / (CMJ_DIM * CMJ_DIM));
Sampler_Init(&sampler, frame % (CMJ_DIM * CMJ_DIM), SAMPLE_DIM_CAMERA_OFFSET, scramble);
#endif
We know that MonteCarloRenderer call RenderTile method to render. When the output size is bigger than kTileSizeX * kTileSizeY, then each time we only render a tile. That is why we use pixel_idx buffer to establish the relationship between ray index and output index.
We use x + output_width * y to read or write data in the random buffer, however, the random buffer size is kTileSizeX * kTileSizeY. So the index may be out of bound. It should be correct to just use the global_id to read or write the random buffer.
I don't know how OpenCL handle the out of range problem. There is something wrong with the logic. Hope for reply, thanks :-)
The text was updated successfully, but these errors were encountered:
Hi, please pay attention to this piece of code in
monte_carlo_renderer.cl
(actually, this pattern appears in many kernels):We know that MonteCarloRenderer call
RenderTile
method to render. When the output size is bigger thankTileSizeX * kTileSizeY
, then each time we only render a tile. That is why we usepixel_idx
buffer to establish the relationship between ray index and output index.We use
x + output_width * y
to read or write data in therandom
buffer, however, therandom
buffer size iskTileSizeX * kTileSizeY
. So the index may be out of bound. It should be correct to just use theglobal_id
to read or write therandom
buffer.I don't know how OpenCL handle the out of range problem. There is something wrong with the logic. Hope for reply, thanks :-)
The text was updated successfully, but these errors were encountered: