Sign in to follow this  

inversion of GetRenderTargetData

This topic is 3558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

GetRenderTargetData is used to copys the render-target data from device memory to system memory. If I want to inverse the operation(from system memory to device memory), how do I do that?

Share this post


Link to post
Share on other sites
Quote:
Original post by ET3D
UpdateSurface.


I use DirectX9 and try to use StrechRect to copy texture. I just try the creation of texture. So my method is very strange.

In the line 29, pSmTile->m_pShadowMapSurf and m_pShadowMapSurf are RenderTraget Texture's surface. The copy between them is all right. But in the line 30, I try to copy the Texture Loading from file to RenderTraget Texture's surface.

The function of StretchRect always return "D3DERR_INVALIDCALL -2005530516". I see the MSDN that the StretchRect can support the Destination of RT texture no matter source format.

How do I solve this problem? And then let line 30 return S_OK.
I also try UpdateSurface in line31, it still return "D3DERR_INVALIDCALL -2005530516". I think the reason the source surface is not created with D3DPOOL_SYSTEMMEM. But how do I copy the texture loading from xfile to the RenderTarget texture? That is very strange.


HRESULT hr;

ReleaseSMTexture();
//CreateSMTexture();

V_RETURN(m_pd3dDevice->CreateTexture(
SHADOW_MAP_SIZE,
SHADOW_MAP_SIZE,
1,
D3DUSAGE_RENDERTARGET,
SHADOW_MAP_FORMAT,
D3DPOOL_DEFAULT,
&m_pShadowMapTex,
NULL
));

V_RETURN(m_pShadowMapTex->GetSurfaceLevel(0, &m_pShadowMapSurf));

V_RETURN(m_pd3dDevice->CreateDepthStencilSurface(
SHADOW_MAP_SIZE,
SHADOW_MAP_SIZE,
D3DFMT_D24S8,
D3DMULTISAMPLE_NONE,
0,
TRUE,
&m_pShadowMapZ,
NULL
));

LPDIRECT3DTEXTURE9 pTex;
LPDIRECT3DSURFACE9 pSourceSurface;

hr=D3DXCreateTextureFromFile( m_pd3dDevice, L"Texture.bmp", &pTex );
hr=pTex->GetSurfaceLevel(0,&pSourceSurface);

//StretchRect for Dest format=RT texture
line29=>//hr=m_pd3dDevice->StretchRect(pSmTile->m_pShadowMapSurf,NULL,m_pShadowMapSurf,NULL,D3DTEXF_LINEAR); //S_OK
line30=>//hr=m_pd3dDevice->StretchRect(pSourceSurface,NULL,m_pShadowMapSurf,NULL,D3DTEXF_LINEAR); //D3DERR_INVALIDCALL -2005530516
line31=>hr=m_pd3dDevice->UpdateSurface(pSourceSurface,NULL,m_pShadowMapSurf,NULL); //D3DERR_INVALIDCALL -2005530516

hr=D3DXSaveTextureToFile(L"t1.png",D3DXIFF_PNG ,m_pShadowMapTex,NULL);

SAFE_RELEASE(pTex);
SAFE_RELEASE(pSourceSurface);

Share this post


Link to post
Share on other sites

This topic is 3558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this