游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1684|回复: 0

D3DUSAGE_DYNAMIC to D3DUSAGE_RENDERTARGET

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2008-3-22 01:54:00 | 显示全部楼层 |阅读模式
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?


  1. HRESULT CSmTile::CopySmTileFrom_GPU_To_CPU(CSmTile* pSmTile)
  2. {
  3.         HRESULT hr;

  4.         D3DSURFACE_DESC Desc;
  5.         pSmTile->m_pShadowMapSurf->GetDesc(&Desc);

  6.         // setup shadow map objects
  7.         hr=m_pd3dDevice->CreateTexture(
  8.                 Desc.Width,
  9.                 Desc.Height,
  10.                 1,
  11.                 D3DUSAGE_DYNAMIC,
  12.                 Desc.Format,
  13.                 D3DPOOL_MANAGED,
  14.                 &m_pShadowMapTex_For_CPU,
  15.                 NULL
  16.                 );

  17.         hr=m_pShadowMapTex_For_CPU->GetSurfaceLevel(0,&m_pShadowMapSurf_For_CPU);

  18.         //V_RETURN(m_pd3dDevice->CreateOffscreenPlainSurface(Desc.Width,Desc.Height,Desc.Format,D3DPOOL_SYSTEMMEM,&m_pShadowMapSurf_For_CPU,NULL));//Must be D3DPOOL_SYSTEMMEM for MSDN
  19.         V_RETURN(m_pd3dDevice->GetRenderTargetData(pSmTile->m_pShadowMapSurf,m_pShadowMapSurf_For_CPU));

  20.         //hr=D3DXSaveTextureToFile(L"t1.png",D3DXIFF_PNG ,m_pShadowMapTex_For_CPU,NULL);

  21.         return S_OK;
  22. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-20 15:46

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表