简体   繁体   中英

How to declare a function (method) using cuda texture<>?

I'm working on a cuda 10.2 project in VS2019. I'm trying to create a class which has methods with texture<> as argument, but it seems not possible.

I start a definition in a .cu file like this:

template<class T, cudaTextureReadMode mode>
void CBSplines::CreateTextureFromVolume(texture<T, 3, mode>* tex, //...

Then I get this error:

Error class "CBSplines" has no member "CreateTextureFromVolume"

In order to solve this I add the definition is the header, but then I get this error:

Error (active) E0864 texture is not a template

How can I have a class using methods with texture<> argument(s) ?

__

More details: I'm using the header for several .cu files which define global functions and methods. The errors are from nvcc ie., compilation, not roslyn.

You can't do that. Quoting the documentation :

A texture reference is declared at file scope as a variable of type texture

You cannot do anything other than define them at the used translation unit scope and refer to them by name in host or device code. They are opaque objects with template like syntax, but they are not a type nor a template.

What you are looking for is the texture object API , which can be passed as function arguments. I'm not sure they can be used as template arguments, however.

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