简体   繁体   中英

Why does texture binding require non-const device pointers?

I'm using cudaTextureObject_t do do some linear interpolation. For binding to the lookup data array to the texture object I've got to provide void *devPtr , as defined in driver_types.h . I'm curious why that's not a const void *devPtr ? Since this data is for looking up values I don't expect CUDA to modify it. I certainly can make things work with creating casting, just curious.

The generic cudaResourceDesc which is passed to cudaCreateTextureObject() does indeed take a

void * devPtr

However the same generic resource descriptor is used for surface objects as well. So it cannot be const for that usage. Surfaces are a writable (from CUDA kernel code) resource.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM