This project is read-only.

Using CudaTextureArray

Dec 9, 2013 at 2:01 PM
To use Data on GPU which is organized as 2D or 3D Array one can use CudaArray. In order to get linear interpolation for this one can use CudaTextureArray. Because of the Z-Order Organization which is handled by the GPU the interpolation is almost for free.

The style for uploading these things with managedCUDA incorporates a step where the specific texture is assigned to a specific kernel
new CudaTextureArray3D(kernel, "tex", CUAddressMode.Clamp, CUFilterMode.Linear, CUTexRefSetFlags.NormalizedCoordinates, cuda_3d_array);
This makes it imposible to use one texture (in ptx code named "tex") for two different kernels.

Lets say there is one init kernel and one run kernel. So how can these two kernels access the same data (e.g. the texture named "tex") ?
Dec 9, 2013 at 2:41 PM
You have actually two possibilities:
1) “The old interface”: Create a CudaTextureArray3D object for kernel1, run kernel1 – Create a 2nd CudaTextureArray3D object for kernel2 and run kernel2. The first texture object is then kind of invalid and is of no more use. Each time you want to change texture reference you have to create a new object.
2) As this is very ugly, there’s a new interface using static methods: Call each time you want to change the texture binding one of the CudaTexture.BindTexture() overloads.

CudaTextureArray3D has only some code in its constructor, everything else is more or less empty, why the new interface is way cleaner to use.

Dec 9, 2013 at 3:28 PM
Yes, that works! I got rid of the CudaTextureArray3D object and only use the static BindTexture Method.

Thank you very much!!

Please do me a favor and keep up the great work! managedCuda integrates in C# as smooth as OpenTK does. Its just amazingly nice to code now!