Can we use/ declare many texture reference?

Can we use/ declare more than one texture reference? If yes, how to declare them?

I need to process more than one input data in the same .cu file. I tried to write as

texture<float4, 2, cudaReadModeNormalizedFloat> input1, input2, input3, input4, input5, input6, input7, input8, input9, input10, input1_1, input1_2;

and as

texture<float4, 2, cudaReadModeNormalizedFloat> input1;

texture<float4, 2, cudaReadModeNormalizedFloat> input2; 

texture<float4, 2, cudaReadModeNormalizedFloat> input3;

texture<float4, 2, cudaReadModeNormalizedFloat> input4;

texture<float4, 2, cudaReadModeNormalizedFloat> input5; 

texture<float4, 2, cudaReadModeNormalizedFloat> input6;

texture<float4, 2, cudaReadModeNormalizedFloat> input7; 

texture<float4, 2, cudaReadModeNormalizedFloat> input8; 

texture<float4, 2, cudaReadModeNormalizedFloat> input9; 

texture<float4, 2, cudaReadModeNormalizedFloat> input10;

texture<float4, 2, cudaReadModeNormalizedFloat> input1_1; 

texture<float4, 2, cudaReadModeNormalizedFloat> input1_2;

But both built fail with the error messages shows that the compiler can’t recognize

the keyword “texture.” I don’t know what is the problem…Can’t it use the type “float4?” Or there are any other setting that I didn’t notice? Thank you for your reply.

I use 8 textures in my code (declared as in your second example) without a problem. Are you missing an include somewhere? Do you get the same compiler error if you only declare one texture?

Hello,

Thank you for your reply.

I include all the files as the sample code did…

// Calling CUDA kernel files in this file

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <math.h>

#include <GL/glew.h>

#include <GL/glut.h>

#include <cuda_gl_interop.h>

#include <cutil.h>

#include <cutil_interop.h>

typedef unsigned int TColor;

////////////////////////////////////////////////////////////////////////////////

// Helper functions

////////////////////////////////////////////////////////////////////////////////

[skip]

////////////////////////////////////////////////////////////////////////////////

// Global data handlers and parameters

////////////////////////////////////////////////////////////////////////////////

//Texture reference and channel descriptor for image texture 

                                        

texture<float4, 2, cudaReadModeNormalizedFloat> input1;

texture<float4, 2, cudaReadModeNormalizedFloat> input2; 

texture<float4, 2, cudaReadModeNormalizedFloat> input3;

texture<float4, 2, cudaReadModeNormalizedFloat> input4;

texture<float4, 2, cudaReadModeNormalizedFloat> input5; 

texture<float4, 2, cudaReadModeNormalizedFloat> input6;

texture<float4, 2, cudaReadModeNormalizedFloat> input7; 

texture<float4, 2, cudaReadModeNormalizedFloat> input8; 

texture<float4, 2, cudaReadModeNormalizedFloat> input9; 

texture<float4, 2, cudaReadModeNormalizedFloat> input10;

texture<float4, 2, cudaReadModeNormalizedFloat> input1_1; 

texture<float4, 2, cudaReadModeNormalizedFloat> input1_2;

Did I miss anything?

By the way, if I just declare one texture, the error message become different. That is, the compiler can recognize the declaration the texture, all the remained error messages are only because those undeclared texture.

Can you (Or anyone) give me more comment?

#include <cuda.h> is mijjing

Hello,

I tried to add "include <cuda.h>, " but the result is the same as I posted on the first post. :(

Why didn’t you provide us with exact error messages? It’s not enough to know that it is ‘different’.

Seems like you’re compiling file with texture declarations not with nvcc but with other compiler.

Sorry for not providing the exact error messages, because I use visual studio 2005 Chinese version and I thought most of you can’t read Chinese…

I also thought about the texture declarations are not compiled with nvcc, but I did set the compiler command just as the sample project did.

Here is the project. I will appreciate very very much if you are so kind that help me to check the compiler setting.
HFU_CUDA.rar (765 KB)

Well, yes, Chinese may be a problem :)

Strange, but when I’m trying to compile Image.cu I do not get texture-related errors. Everything I get comes from saft.cu when compiler cannot determine which overloaded pow() to use. The only change I’ve made is commenting out #include <cutil_interop.h> because I don’t know where can I get it :). If I comment out #include “saft.cu” and respective kernel invocation then everything compiles fine.

Hello,

Thanks for your reply. I tried to upgrade CUDA from v1.0 to v1.1. at first I derived the same result as you mentioned. But then as I commented out the related code with “saft.cu,” or modified the using of pow() to be powf(), the compile result become the same as I mentioned at the first post again… It is really strange and confused me very much. Do you have any further suggestion?

Thank you.

No, I’ve got no compile-time errors with “saft.cu” commented out…

Certainly! I did with 8 or more texture references and without problem
But i think the max texture references can be execute as paralle is 8(four-dim vector type) /16(two-dim vector type) /32(single type)

last,I`m a chinese^-^