diff options
author | Thomas White <taw@physics.org> | 2010-03-10 14:26:41 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-03-10 14:26:41 +0100 |
commit | d8245ab6f1bdf34c37c7d079496683272c181e54 (patch) | |
tree | 6b048f5a016f5eefa6389fedc76f27b3f42de472 /src | |
parent | bda63e5f6eeed249f0effb4f990e887b3912dad6 (diff) |
Tidy up
Diffstat (limited to 'src')
-rw-r--r-- | src/diffraction-gpu.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c index f71df74e..ecc04446 100644 --- a/src/diffraction-gpu.c +++ b/src/diffraction-gpu.c @@ -57,7 +57,6 @@ struct gpu_context static void check_sinc_lut(struct gpu_context *gctx, int n) { cl_int err; - size_t sinc_lut_size; cl_image_format fmt; int i; @@ -78,12 +77,13 @@ static void check_sinc_lut(struct gpu_context *gctx, int n) gctx->max_sinc_lut = n; } - fmt.image_channel_order = CL_INTENSITY; - fmt.image_channel_data_type = CL_FLOAT; - sinc_lut_size = SINC_LUT_ELEMENTS*sizeof(cl_float); + if ( gctx->sinc_lut_ptrs[n-1] != NULL ) { + STATUS("Already have %i\n", n); + return; + } /* Create a new sinc LUT */ - gctx->sinc_lut_ptrs[n-1] = malloc(sinc_lut_size); + gctx->sinc_lut_ptrs[n-1] = malloc(SINC_LUT_ELEMENTS*sizeof(cl_float)); gctx->sinc_lut_ptrs[n-1][0] = n; if ( n == 1 ) { for ( i=1; i<SINC_LUT_ELEMENTS; i++ ) { @@ -98,10 +98,17 @@ static void check_sinc_lut(struct gpu_context *gctx, int n) } } + fmt.image_channel_order = CL_INTENSITY; + fmt.image_channel_data_type = CL_FLOAT; + gctx->sinc_luts[n-1] = clCreateImage2D(gctx->ctx, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, &fmt, SINC_LUT_ELEMENTS, 1, 0, gctx->sinc_lut_ptrs[n-1], &err); + if ( err != CL_SUCCESS ) { + ERROR("Couldn't create LUT for %i\n", n); + return; + } } |