I'm writing a path tracer. I have the following data (see attached file for the context):
__constant Scene scene = {
.planes = {
{&mat_sky, {1000, 0, 0}, {-1, 0, 0}},
{&mat_sky, {-1000, 0, 0}, {1, 0, 0}},
{&mat_sky, {0, 1000, 0}, {0, -1, 0}},
{&mat_sky, {0, -1000, 0}, {0, 1, 0}},
{&mat_sky, {0, 0, 1000}, {0, 0, -1}},
{&mat_sky, {0, 0, -1000}, {0, 0, 1}},
},
.spheres = {
{&mat_sun, {2, 1, 3}, .5f},
{&mat_plastic, {5, 0, -3}, 2},
{&mat_brushed_metal, {5, 0, 0}, 1},
{&mat_mirror, {5, 4, 0}, 3},
{&mat_glass, {5, -4, 0}, 3},
},
};
However, my code was segfaulting when trying to dereference some of the material fields. Setting a breakpoint in the kernel and inspecting the data showed that it was corrupted:
scene = {
.planes = {
{0x7fffed83f010 <mat_sky>, {1000, 0, 0}, {-1, 0, 0}},
{0x0, {0, 0, 0}, {-5.10409426e+27, 4.59163468e-41, 0}},
{0xc47a0000, {1, 0, 0}, {0, 0, 0}},
{0x0, {-5.10409426e+27, 4.59163468e-41, 0}, {0, 1000, 0}},
{0xbf80000000000000, {0, 0, 0}, {0, 0, 0}},
{0x7fffed83f010 <mat_sky>, {0, -1000, 0}, {0, 1, 0}}
},
.spheres = {
{0x0, {0, 0, 0}, -5.10409426e+27},
{0x0, {0, 0, -1}, 0},
{0x0, {-5.10409426e+27, 4.59163468e-41, 0}, 0},
{0x0, {0, 0, 0}, 0},
{0x7fffed83f0b0 <mat_sun>, {2, 1, 3}, 0.5}
}
}
This corruption does not change from run to run. Using "-save-temps" I have verified that the assembler output contained the correct data. Interestingly, if I replace the kernel with a function that just prints out all the pointers in a loop, the output is correct, even though inspecting with GDB confirms that the data is still corrupt. I am on Funtoo Linux (amd64) with catalyst 13.1 (clinfo version: OpenCL 1.2 AMD-APP (1084.4)).
EDIT: Note that this kernel must be compiled for CPU; compiling it for the GPU (at least on my 7970) fails with "Internal Error: Link failed".
Message was edited by: Kyle Blake