Why does texture binding require non-const device pointers?

Viewed 55

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.

1 Answers

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.

Related