   DirectX8 to DirectX9: replacement for CopyRects
  I'm trying to convert old code from DirectX8 to DirectX9 and am running into problems with how to replace CopyRects.The old code has calls like:g_pd3dDevice->CopyRects(pSurf, &rSrc, 1, pDstSurf, &ptDst)Where pSurf had been created with CreateImageSurface() now I'm replacing that with CreateOffscreenPlainSurface() and filled with D3DXLoadSurfaceFromFile(pSurf, ...). And pDstSurf was filled by calling texture->GetSurfaceLevel(0, &pDstSurf). Basically, I'm trying to copy from a surface into a texture.I've tried g_pd3dDevice->StretchRect(pSurf, &rSrc, pDstSurf, &rDst, D3DTEXF_NONE) and  g_pd3dDevice->UpdateSurface(pSurf, &rSrc, pDstSurf, &ptDst) both of which are failing.   
  Just to be specific here what I'm trying to do amounts to the following:LPDIRECT3DSURFACE9 surface;LPDIRECT3DTEXTURE9 texture;LPDIRECT3DSURFACE9 texture_surface;if (FAILED(hr = g_pd3dDevice->CreateOffscreenPlainSurface(wd, hgt,   D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL))) {    throw std::runtime_error("CreateOffscreenPlainSurface() failed");}if (FAILED(hr = D3DXLoadSurfaceFromFile(surface, NULL, NULL,file, NULL, D3DX_DEFAULT , 0, NULL))) {    surface->Release();    throw std::runtime_error("D3DXLoadSurfaceFromFile() failed");}if (FAILED(hr = g_pd3dDevice->CreateTexture(256, 256, 1, 0, D3DFMT_A8R8G8B8,    D3DPOOL_DEFAULT, &texture, NULL))) {    surface->Release();    throw std::runtime_error("CreateTexture() failed");}if (FAILED(hr = texture->GetSurfaceLevel(0, &texture_surface))) {    surface->Release();    texture->Release();    throw std::runtime_error("GetSurfaceLevel() failed");}// Now I want to copy from surface to texture_surface, but everything I try to do this// with fails. Below I try to use D3DXLoadSurfaceFromSurface()...RECT rSrc = {0, 0, 256, 256};RECT rDst = rSrc;if (FAILED(hr = D3DXLoadSurfaceFromSurface(texture_surface, NULL, &rDst,surface, NULL, &rSrc, D3DTEXF_NONE, 0))) {    surface->Release();    texture->Release();    throw std::runtime_error("D3DXLoadSurfaceFromSurface() failed");}EDIT: okay, it looks like D3DXLoadSurfaceFromSurface will succeed if I create the texture with D3DXCreateTexture and set the usage as D3DUSAGE_RENDERTARGET. But I came up with this strictly through trial-and-error style debugging and don't really know what's going on. Is this an okay way to copy from a surface to a texture? Could someone explain the theory behind what's going on? Is there a cost to RENDERTARGETness?[Edited by - jwezorek on May 14, 2010 1:22:54 PM]