GraphicsStream.Write not writing as expected

I have a method where I write a 2d array into a texture. It is used for running some ordinary calculations on the gpu.

privatevoid writeToInputTexture(Vector4[,] inputData,Texture inputTexture)

{

GraphicsStream graphicsStream = inputTexture.LockRectangle(0,LockFlags.None);

unsafe

{

Vector4* textureData = (Vector4*)graphicsStream.InternalDataPointer;

for (int y = 0; y < dataHeight; y++)

for (int x = 0; x < dataWidth; x++)

textureData[x + y * dataWidth] = inputData[x, y];

}

inputTexture.UnlockRectangle(0);

}

That works as expected. However, if i try to use the graphics sctream write as below, it does not do as expected. The input is not written corrently into the array. I can not debug the pixel shader right now, so all I can see is that input is not passed the same way as the unsafe version.

privatevoid writeToInputTexture(Vector4[,] inputData,Texture inputTexture)

{

GraphicsStream graphicsStream = inputTexture.LockRectangle(0,LockFlags.None);

graphicsStream.Write(inputData);

inputTexture.UnlockRectangle(0);

}

What am I doing wrong here?

As a side question, is the begin write and end write methods of the stream dma? Will the cpu rest peacefully while the write is running asynchronously, or will it still be bussy showlelling data to the gpu?

[2479 byte] By [ThomasGreenleaf] at [2007-12-23]
# 1

I just realized that the difference was the column row order.

I was reading data as rows, while the graphicsstream read it as columns. Actually it is more about how the array object in .net stores its data, but it works now.

ThomasGreenleaf at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...