|
|
m_pShadowMapSurf is the surface attach to RenderTarget texture.
I copy the pSmTile->m_pShadowMapSurf to m_pShadowMapSurf_For_CPU(m_pShadowMapTex) successfully.
But I have a problem
hr=m_pEffect_QVSM_ADAPTIVE->SetTexture("TestBaseTexture", m_pShadowMapTex_For_CPU);
When I SetTexture of m_pShadowMapTex_For_CPU for an effect, it return S_OK.
But I cannot see the Texture I want.
If I save the Texture of m_pShadowMapTex_For_CPU to a png file.
The png file is what I want.
If effect SetTexure of RenderTarget texture, it return OK and the texture display in the screen. So shader code and relative source code have no problems
Is the parameters of D3DUSAGE_DYNAMIC and D3DPOOL_MANAGED incompatible with Effect->SetTexture?
- HRESULT CSmTile::CopySmTileFrom_GPU_To_CPU(CSmTile* pSmTile)
- {
- HRESULT hr;
- D3DSURFACE_DESC Desc;
- pSmTile->m_pShadowMapSurf->GetDesc(&Desc);
- // setup shadow map objects
- hr=m_pd3dDevice->CreateTexture(
- Desc.Width,
- Desc.Height,
- 1,
- D3DUSAGE_DYNAMIC,
- Desc.Format,
- D3DPOOL_MANAGED,
- &m_pShadowMapTex_For_CPU,
- NULL
- );
- hr=m_pShadowMapTex_For_CPU->GetSurfaceLevel(0,&m_pShadowMapSurf_For_CPU);
- //V_RETURN(m_pd3dDevice->CreateOffscreenPlainSurface(Desc.Width,Desc.Height,Desc.Format,D3DPOOL_SYSTEMMEM,&m_pShadowMapSurf_For_CPU,NULL));//Must be D3DPOOL_SYSTEMMEM for MSDN
- V_RETURN(m_pd3dDevice->GetRenderTargetData(pSmTile->m_pShadowMapSurf,m_pShadowMapSurf_For_CPU));
- //hr=D3DXSaveTextureToFile(L"t1.png",D3DXIFF_PNG ,m_pShadowMapTex_For_CPU,NULL);
- return S_OK;
- }
复制代码 |
|