summaryrefslogtreecommitdiffstats
path: root/cuda/2d/par_fp.cu
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2021-11-22 14:43:07 +0100
committerWillem Jan Palenstijn <wjp@usecode.org>2021-11-26 12:09:09 +0100
commitbe2da43a560a7241c56e727fb481f1389e9f7fdf (patch)
tree318df874ff0efb63d01749006f09318289d0844b /cuda/2d/par_fp.cu
parentc11ee1cffd53bdf4530eb4381bf484cd1a1ce9cb (diff)
downloadastra-be2da43a560a7241c56e727fb481f1389e9f7fdf.tar.gz
astra-be2da43a560a7241c56e727fb481f1389e9f7fdf.tar.bz2
astra-be2da43a560a7241c56e727fb481f1389e9f7fdf.tar.xz
astra-be2da43a560a7241c56e727fb481f1389e9f7fdf.zip
De-duplicate 2D texture object creation
Diffstat (limited to 'cuda/2d/par_fp.cu')
-rw-r--r--cuda/2d/par_fp.cu39
1 files changed, 2 insertions, 37 deletions
diff --git a/cuda/2d/par_fp.cu b/cuda/2d/par_fp.cu
index cccf672..6035e0c 100644
--- a/cuda/2d/par_fp.cu
+++ b/cuda/2d/par_fp.cu
@@ -47,42 +47,6 @@ static const unsigned int g_anglesPerBlock = 16;
static const unsigned int g_detBlockSize = 32;
static const unsigned int g_blockSlices = 64;
-// fixed point scaling factor
-#define fPREC_FACTOR 16.0f
-#define iPREC_FACTOR 16
-
-
-static bool bindVolumeDataTexture(float* data, cudaArray*& dataArray, cudaTextureObject_t& texObj, unsigned int pitch, unsigned int width, unsigned int height)
-{
- // TODO: For very small sizes (roughly <=512x128) with few angles (<=180)
- // not using an array is more efficient.
-
- cudaChannelFormatDesc channelDesc =
- cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat);
-
- dataArray = 0;
- cudaMallocArray(&dataArray, &channelDesc, width, height);
- cudaMemcpy2DToArray(dataArray, 0, 0, data, pitch*sizeof(float), width*sizeof(float), height, cudaMemcpyDeviceToDevice);
-
- cudaResourceDesc resDesc;
- memset(&resDesc, 0, sizeof(resDesc));
- resDesc.resType = cudaResourceTypeArray;
- resDesc.res.array.array = dataArray;
-
- cudaTextureDesc texDesc;
- memset(&texDesc, 0, sizeof(texDesc));
- texDesc.addressMode[0] = cudaAddressModeBorder;
- texDesc.addressMode[1] = cudaAddressModeBorder;
- texDesc.filterMode = cudaFilterModeLinear;
- texDesc.readMode = cudaReadModeElementType;
- texDesc.normalizedCoords = 0;
-
- texObj = 0;
-
- return checkCuda(cudaCreateTextureObject(&texObj, &resDesc, &texDesc, NULL), "par_fp texture");
-}
-
-
// projection for angles that are roughly horizontal
// (detector roughly vertical)
__global__ void FPhorizontal_simple(float* D_projData, unsigned int projPitch, cudaTextureObject_t tex, unsigned int startSlice, unsigned int startAngle, unsigned int endAngle, const SDimensions dims, float outputScale)
@@ -274,7 +238,8 @@ bool FP_simple_internal(float* D_volumeData, unsigned int volumePitch,
cudaArray* D_dataArray;
cudaTextureObject_t D_texObj;
- bindVolumeDataTexture(D_volumeData, D_dataArray, D_texObj, volumePitch, dims.iVolWidth, dims.iVolHeight);
+ if (!createTextureObject2D(D_volumeData, D_dataArray, D_texObj, volumePitch, dims.iVolWidth, dims.iVolHeight))
+ return false;
convertAndUploadAngles(angles, dims.iProjAngles, dims.iProjDets);