Library/ManagedCuda/CudaTexture.cs
/// <summary>
/// Create a new CudaMipmappedArray and bind it to a texture reference.
/// </summary>
/// <param name="kernel"></param>
/// <param name="texName"></param>
/// <param name="addressMode0"></param>
/// <param name="addressMode1"></param>
/// <param name="addressMode2"></param>
/// <param name="filterMode"></param>
/// <param name="flags"></param>
/// <param name="descriptor"></param>
/// <param name="numMipmapLevels"></param>
/// <param name="maxAniso"></param>
/// <param name="mipmapFilterMode"></param>
/// <param name="mipmapLevelBias"></param>
/// <param name="minMipmapLevelClamp"></param>
/// <param name="maxMipmapLevelClamp"></param>
Create a new CudaMipmappedArray and bind it to a texture reference.
Create a new CudaMipmappedArray and bind it to a texture reference .
public static CudaMipmappedArray BindTexture(CudaKernel kernel, string texName, CUAddressMode addressMode0, CUAddressMode addressMode1, CUAddressMode addressMode2,
			CUFilterMode filterMode, CUTexRefSetFlags flags, CUDAArray3DDescriptor descriptor, uint numMipmapLevels,
			uint maxAniso, CUFilterMode mipmapFilterMode, float mipmapLevelBias, float minMipmapLevelClamp, float maxMipmapLevelClamp)
		{
			CUtexref texref = new CUtexref();
			CUResult res = DriverAPINativeMethods.ModuleManagement.cuModuleGetTexRef(ref texref, kernel.CUModule, texName);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}, Texture name: {3}", DateTime.Now, "cuModuleGetTexRef", res, texName));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetAddressMode(texref, 0, addressMode0);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetAddressMode", res));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetAddressMode(texref, 1, addressMode1);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetAddressMode", res));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetAddressMode(texref, 2, addressMode2);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetAddressMode", res));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetFilterMode(texref, filterMode);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetFilterMode", res));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetFlags(texref, flags);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetFlags", res));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetFormat(texref, descriptor.Format, (int)descriptor.NumChannels);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetFormat", res));
			if (res != CUResult.Success) throw new CudaException(res);
			CudaMipmappedArray array = new CudaMipmappedArray(descriptor, numMipmapLevels);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetMipmappedArray(texref, array.CUMipmappedArray, CUTexRefSetArrayFlags.OverrideFormat);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetMipmappedArray", res));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetMaxAnisotropy(texref, maxAniso);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetMaxAnisotropy", res));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetMipmapFilterMode(texref, mipmapFilterMode);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetMipmapFilterMode", res));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetMipmapLevelBias(texref, mipmapLevelBias);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetMipmapLevelBias", res));
			if (res != CUResult.Success) throw new CudaException(res);
			res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetMipmapLevelClamp(texref, minMipmapLevelClamp, maxMipmapLevelClamp);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetMipmapLevelClamp", res));
			if (res != CUResult.Success) throw new CudaException(res);
			return array;
		}
public static CudaMipmappedArray BindTexture ( CudaKernel kernel , string texName , CUAddressMode addressMode0 , CUAddressMode addressMode1 , CUAddressMode addressMode2 , CUFilterMode filterMode , CUTexRefSetFlags flags , CUDAArray3DDescriptor descriptor , uint numMipmapLevels , uint maxAniso , CUFilterMode mipmapFilterMode , float mipmapLevelBias , float minMipmapLevelClamp , float maxMipmapLevelClamp ) { CUtexref texref = new CUtexref ( ) ; CUResult res = DriverAPINativeMethods . ModuleManagement . cuModuleGetTexRef ( ref texref , kernel . CUModule , texName ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res , texName ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetAddressMode ( texref , 0 , addressMode0 ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetAddressMode ( texref , 1 , addressMode1 ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetAddressMode ( texref , 2 , addressMode2 ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetFilterMode ( texref , filterMode ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetFlags ( texref , flags ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetFormat ( texref , descriptor . Format , ( int ) descriptor . NumChannels ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; CudaMipmappedArray array = new CudaMipmappedArray ( descriptor , numMipmapLevels ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetMipmappedArray ( texref , array . CUMipmappedArray , CUTexRefSetArrayFlags . OverrideFormat ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetMaxAnisotropy ( texref , maxAniso ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetMipmapFilterMode ( texref , mipmapFilterMode ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetMipmapLevelBias ( texref , mipmapLevelBias ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . TextureReferenceManagement . cuTexRefSetMipmapLevelClamp ( texref , minMipmapLevelClamp , maxMipmapLevelClamp ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; return array ; }
Create a new CudaMipmappedArray and bind it to a texture reference.
Create a new CudaMipmappedArray and bind it to a texture reference .
kernel
CudaKernel
None
texName
string
None
addressMode0
CUAddressMode
None
addressMode1
CUAddressMode
None
addressMode2
CUAddressMode
None
filterMode
CUFilterMode
None
flags
CUTexRefSetFlags
None
descriptor
CUDAArray3DDescriptor
None
numMipmapLevels
uint
None
maxAniso
uint
None
mipmapFilterMode
CUFilterMode
None
mipmapLevelBias
float
None
minMipmapLevelClamp
float
None
maxMipmapLevelClamp
float
None