Skip to main content
GameDev.net gamedev.net
🔒 Locked

dynamic texture, streaming data

Started by ruysch Mar 9, 2008 at 8:59 AM 1 replies 1.1k views
Original Post
ruysch
ruysch
I am coding a small demo program. The basic idea is simple 2D pixel graphics. I create a random matrix, say 32x32 I then solve it interactively. Anyways I have to download data rapidly to the graphics card and I am very much unsure of what the optimal approach is under DirectX9? Under OpenGL I would proberly use pixel buffer objects to download the data async. Currently I have this simple piece of code to download pixel data.

HRESULT hr = S_OK;
D3DLOCKED_RECT LockedRect;
hr = texture->LockRect (0, &LockedRect, NULL, 0);
if (FAILED(hr))
  return hr;
D3DXVECTOR4 *pbits = (D3DXVECTOR4 *) LockedRect.pBits;
for(int y = 0; y < int(image.height()); y++) {
  DWORD dwOffset = y*image.width();
  for(int x = 0; x < int(image.width()); x++) {
    pbits[dwOffset+x] = image(x,y);	
  }
}
hr = texture->UnlockRect(0);
if(FAILED(hr))
  return hr;
return S_OK; 

Cycles
Cycles
The fastest way to do this would probably to modify the texture through a pixel shader, rendering the results back to the same texture. This might take an initial lock to fill the texture with your starting data, but solving matrices (if you're doing elementary row operations) is a task pretty suitable for parellelism, I think.

Not quite the answer you're looking for, but I think LockRect is pretty fast.
Oliver Charles (aka aCiD2) [ Cycles Blog ]
ruysch
ruysch
I am doing gaussian elimination and I then show intermediate result incrementally and reinitialize the matrix with a new one once a solution has been computed.

Ofcourse if I ported the gaussian elimination to a shader implementation I could do as you suggest but I would prefer not to do that.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.