Using float2 as an alias for double in textures

Hi all,

I have a 2D array of doubles. I’d love to be able to use texture memory and the associated cache, but textures are limited to ints and floats. Is there any way I can treat my array of doubles as an array of float2’s? I tried a few things but nothing worked. Is there any way to do implicit aliasing between float2 and double?

I’m thinking something like:

[codebox]float2 x_f2[10];

double *pd;

pd = (double*)x_f2;[/codebox]

Since the memory layout of float2 should be the same as a double (64-bits each) it seems like this should work.

Thanks.

Hi all,

I have a 2D array of doubles. I’d love to be able to use texture memory and the associated cache, but textures are limited to ints and floats. Is there any way I can treat my array of doubles as an array of float2’s? I tried a few things but nothing worked. Is there any way to do implicit aliasing between float2 and double?

I’m thinking something like:

[codebox]float2 x_f2[10];

double *pd;

pd = (double*)x_f2;[/codebox]

Since the memory layout of float2 should be the same as a double (64-bits each) it seems like this should work.

Thanks.

I’d use int2 as texture type and __hiloint2double() to convert to doubles. And be sure not to use normalization or interpolation on the texture…

I’d use int2 as texture type and __hiloint2double() to convert to doubles. And be sure not to use normalization or interpolation on the texture…

Thanks! That worked, except the performance was pretty lousy.

Thanks! That worked, except the performance was pretty lousy.