From d4645875801d29402b1e3f2a42a5d9902a37a718 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 22 Nov 2021 14:14:55 +0100 Subject: De-duplicate 3D texture object creation --- cuda/3d/util3d.cu | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cuda/3d/util3d.cu') diff --git a/cuda/3d/util3d.cu b/cuda/3d/util3d.cu index 71b5668..3dc915d 100644 --- a/cuda/3d/util3d.cu +++ b/cuda/3d/util3d.cu @@ -378,6 +378,28 @@ bool transferHostProjectionsToArray(const float *projData, cudaArray* array, con return checkCuda(cudaMemcpy3D(&p), "transferHostProjectionsToArray 3D"); } +bool createTextureObject3D(cudaArray* array, cudaTextureObject_t& texObj) +{ + cudaChannelFormatDesc channelDesc = + cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat); + + cudaResourceDesc resDesc; + memset(&resDesc, 0, sizeof(resDesc)); + resDesc.resType = cudaResourceTypeArray; + resDesc.res.array.array = array; + + cudaTextureDesc texDesc; + memset(&texDesc, 0, sizeof(texDesc)); + texDesc.addressMode[0] = cudaAddressModeBorder; + texDesc.addressMode[1] = cudaAddressModeBorder; + texDesc.addressMode[2] = cudaAddressModeBorder; + texDesc.filterMode = cudaFilterModeLinear; + texDesc.readMode = cudaReadModeElementType; + texDesc.normalizedCoords = 0; + + return checkCuda(cudaCreateTextureObject(&texObj, &resDesc, &texDesc, NULL), "createTextureObject3D"); +} + float dotProduct3D(cudaPitchedPtr data, unsigned int x, unsigned int y, -- cgit v1.2.3