Skip to content

Conversation

@bailsman
Copy link
Contributor

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

Base automatically changed from master to main March 8, 2021 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant