texture reference question

I have a structure…

typedef struct

{

    float3 a;

    float3 b;

    float c;

    int d;

    long e;

} myStruct;

…and I would like to store a 1D array of these structures in linear memory using texture references. The problem is that texture references only use built-in types (int, float, float2 etc…). Does anyone have a solution to this problem using my exact structure?

you can pack them into a float4 textures, every 3 texel storing a myStr:
myStruct[i] = tex[i/3], tex[i/3+1], tex[i/3+2].
how to extract them in kernel?
my.a: tex[i/3].rgb
my.c: tex[i/3].a
my.b: tex[i/3+1].rgb
my.d: tex[i/3+1].a
my.e: tex[i/3+2].r.

for perf issue, can you manage to reduce sizeof(myStruct) to be 8 sizeof(floats)? that’ll be much faster than 9.

thank you! your help is much appreciated!!! another simple question… during host runtime I can convert my long to float by using __int_as_float(int) and during kernel execution use __float_as_int(float) right? will this also keep good performance??

__int_as_float() and __float_as_int() do not actually emit any conversion code, they just let you tell the compiler what type of data there, as documented in the programming guide. The device registers don’t use any special formats to require conversion. So there cannot possibly be a performance loss from using them.