Fix memory corruption bug (overshoot in colorclip)

This commit is contained in:
Steven Robertson 2011-10-25 15:43:05 -04:00
parent efc2ac23e2
commit be31708c09
2 changed files with 5 additions and 5 deletions

View File

@ -8,10 +8,10 @@ class ColorClip(HunkOCode):
defs_tmpl = Template(''' defs_tmpl = Template('''
__global__ __global__
void colorclip(float4 *pixbuf, float gamma, float vibrancy, float highpow, void colorclip(float4 *pixbuf, float gamma, float vibrancy, float highpow,
float linrange, float lingam, float3 bkgd) { float linrange, float lingam, float3 bkgd, int fbsize) {
// TODO: test if over an edge of the framebuffer - currently gutters are int i = gtid();
// used and up to 256 pixels are ignored, which breaks when width<256 if (i >= fbsize) return;
int i = (gridDim.x * blockIdx.y + blockIdx.x) * blockDim.x + threadIdx.x;
float4 pix = pixbuf[i]; float4 pix = pixbuf[i];
if (pix.w <= 0) { if (pix.w <= 0) {

View File

@ -338,7 +338,7 @@ class Animation(object):
color_fun = self.mod.get_function("colorclip") color_fun = self.mod.get_function("colorclip")
blocks = int(np.ceil(np.sqrt(nbins / 256))) blocks = int(np.ceil(np.sqrt(nbins / 256)))
color_fun(d_out, gam, vib, hipow, lin, lingam, bkgd, color_fun(d_out, gam, vib, hipow, lin, lingam, bkgd, np.int32(nbins),
block=(256, 1, 1), grid=(blocks, blocks), block=(256, 1, 1), grid=(blocks, blocks),
stream=filt_stream) stream=filt_stream)
cuda.memcpy_dtoh_async(h_out, d_out, filt_stream) cuda.memcpy_dtoh_async(h_out, d_out, filt_stream)