pycuda
pycuda copied to clipboard
Add get_surfobj and get_texobj to cuda arrays
Adds get_surfobj() and get_texobj(TextureDesc) method to CUDA Arrays to use the Surface/Texture object API.
Example usage:
descriptor = cuda.ArrayDescriptor()
descriptor.width = 1024
descriptor.height = 1024
descriptor.format = cuda.array_format.FLOAT
descriptor.num_channels = 4
array = cuda.Array(descriptor)
texdesc = cuda.TextureDesc()
texdesc.address_mode[0] = cuda.address_mode.CLAMP
texdesc.address_mode[1] = cuda.address_mode.CLAMP
texdesc.address_mode[2] = cuda.address_mode.CLAMP
texdesc.flags = cuda.TRSF_NORMALIZED_COORDINATES
texdesc.filter_mode = cuda.filter_mode.LINEAR
# You can pass these to a kernel and use as parameters to
# tex2D<float>(texobj, x, y) or
# surf2Dwrite(data, surfobj, x * sizeof(float4), y)
texobj = array.get_texobj(texdesc)
surfobj = array.get_surfobj()
Please review carefully as I don't really know what I'm doing.
The array helper is taken from: https://stackoverflow.com/questions/18882089/wrapping-arrays-in-boost-python