Built-in variables and texture fetching functions float2 var=tex2D(tex1,x,y)

I implemented matrix multiplication with texture.

//compute the block sub-matrices of A and B

………….

for (int k = 0; k < BLOCK_SIZE; k++)

	 Csub +=tex1D(tex1,a + wA * ty + k)*tex1D(tex2, b + wB * k + tx);

………….

The result of the A and B muultiplication computed like above is right. Because of tex2D function is optimized,so I try to use it.

But,when I use the fuction tex2D,the results are wrong. I don’t know the reason.

………….

for (int k = 0; k < BLOCK_SIZE; k++)

Csub +=tex2D(tex1,k,a+wA*ty)tex2D(tex2,tx,wBk);

…………

So, I don’t know where is wrong ? Is it the coordinates of tex2D?

And I also want to fetch the values of textures like this:

………….

for (int k = 0; k < BLOCK_SIZE; k++)

{

   float2  var1=tex2D(tex1,k,a+wA*ty);

  float2  var2= tex2D(tex2,tx,wB*k)

Csub + = var1.x *var2.x +var1.y * var2.y;

}

…………

tex2D returns a value of float2 type. Does that means we can get two values from textue tex1 every interation? Does the tex1 fetches values by row or by colum?

After I tested the program, the var1.y is always zero. I don’t know why. If the float2 can get the correct values , we can obtain two data from a texture by one insturction and this will save some time. I think this is feasible, but I don’t know where is wrong?

How can I get the correct data of built-in types?