Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_surfobj and get_texobj to cuda arrays #174

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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