    }
 #endif
 
+#ifdef FLOATIMG
+   int shmsize = intImg->width*sizeof(float4);
+#else
+   int shmsize = intImg->width*vvSoftImg::PIXEL_SIZE;
+#endif
+#ifdef SHMLOAD
+   shmsize += vd->vox[principal]*vd->getBPV()*sizeof(Scalar);
+#endif
+
    // do the computation on the device
 #ifdef PITCHED
 #define compositeNearest(sliceStep, principal) \
-   compositeSlicesNearest<Scalar, 1, sliceStep, principal> <<<to-from, 128, intImg->width*vvSoftImg::PIXEL_SIZE+ vd->vox[principal]*vd->getBPV()*sizeof(Scalar)>>>( \
+   compositeSlicesNearest<Scalar, 1, sliceStep, principal> <<<to-from, 128, shmsize>>>( \
          d_img, intImg->width, intImg->height, \
          d_voxptr[principal], \
          firstSlice, lastSlice, \
          from, to)
 #else
 #define compositeNearest(sliceStep, principal) \
-   compositeSlicesNearest<Scalar, 1, sliceStep, principal> <<<to-from, 128, intImg->width*vvSoftImg::PIXEL_SIZE+vd->vox[principal]*vd->getBPV()*sizeof(Scalar)>>>( \
+   compositeSlicesNearest<Scalar, 1, sliceStep, principal> <<<to-from, 128, shmsize>>>( \
          d_img, intImg->width, intImg->height, \
          (Scalar *)(d_voxels+sizeof(Scalar)*vd->getBPV()*principal*(vd->vox[0]*vd->vox[1]*vd->vox[2])), \
          firstSlice, lastSlice, \

//#define NOOP
//#define NOLOAD
//#define NODISPLAY
#define SHMLOAD
//#define ARRAY
#define PITCHED
#define FLOATDATA
//#define CONSTLOAD
#define THREADPERVOXEL
#define CONSTDATA

const int Repetitions = 1;


            d.y += w*c.y;
            d.z += w*c.z;
            d.w += w;
#endif

            // store into shmem
            *pix = d;
#ifdef THREADPERVOXEL
            __syncthreads();
#endif
