mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 08:15:44 +00:00
Merge pull request #441 from rextimmy/d3d11_texture_lock
D3d11 texture lock
This commit is contained in:
commit
9dce04d3e2
2 changed files with 10 additions and 28 deletions
|
|
@ -76,7 +76,7 @@ void GFXD3D11TextureManager::_innerCreateTexture( GFXD3D11TextureObject *retTex,
|
||||||
else if ( retTex->mProfile->isSystemMemory() )
|
else if ( retTex->mProfile->isSystemMemory() )
|
||||||
{
|
{
|
||||||
usage |= D3D11_USAGE_STAGING;
|
usage |= D3D11_USAGE_STAGING;
|
||||||
cpuFlags |= D3D11_CPU_ACCESS_READ;
|
cpuFlags |= D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -90,17 +90,13 @@ GFXLockedRect *GFXD3D11TextureObject::lock(U32 mipLevel /*= 0*/, RectI *inRect /
|
||||||
GFXD3D11TextureObject* pD3DStagingTex = (GFXD3D11TextureObject*)&(*mStagingTex);
|
GFXD3D11TextureObject* pD3DStagingTex = (GFXD3D11TextureObject*)&(*mStagingTex);
|
||||||
|
|
||||||
//map staging texture
|
//map staging texture
|
||||||
HRESULT hr;
|
HRESULT hr = pContext->Map(pD3DStagingTex->getResource(), mLockedSubresource, D3D11_MAP_WRITE, 0, &mapInfo);
|
||||||
|
|
||||||
bool is3D = mStagingTex->getDepth() != 0;
|
|
||||||
if (is3D) //3d texture
|
|
||||||
hr = pContext->Map(pD3DStagingTex->get3DTex(), mLockedSubresource, D3D11_MAP_READ, 0, &mapInfo);
|
|
||||||
else
|
|
||||||
hr = pContext->Map(pD3DStagingTex->get2DTex(), mLockedSubresource, D3D11_MAP_READ, 0, &mapInfo);
|
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
AssertFatal(false, "GFXD3D11TextureObject:lock - failed to map render target resource!");
|
AssertFatal(false, "GFXD3D11TextureObject:lock - failed to map render target resource!");
|
||||||
|
|
||||||
|
|
||||||
|
const bool is3D = mStagingTex->getDepth() != 0;
|
||||||
const U32 width = mTextureSize.x >> mipLevel;
|
const U32 width = mTextureSize.x >> mipLevel;
|
||||||
const U32 height = mTextureSize.y >> mipLevel;
|
const U32 height = mTextureSize.y >> mipLevel;
|
||||||
const U32 depth = is3D ? mTextureSize.z >> mipLevel : 1;
|
const U32 depth = is3D ? mTextureSize.z >> mipLevel : 1;
|
||||||
|
|
@ -147,27 +143,13 @@ void GFXD3D11TextureObject::unlock(U32 mipLevel)
|
||||||
|
|
||||||
ID3D11DeviceContext* pContext = D3D11DEVICECONTEXT;
|
ID3D11DeviceContext* pContext = D3D11DEVICECONTEXT;
|
||||||
GFXD3D11TextureObject* pD3DStagingTex = (GFXD3D11TextureObject*)&(*mStagingTex);
|
GFXD3D11TextureObject* pD3DStagingTex = (GFXD3D11TextureObject*)&(*mStagingTex);
|
||||||
|
ID3D11Resource* pStagingResource = pD3DStagingTex->getResource();
|
||||||
|
const bool is3D = mStagingTex->getDepth() != 0;
|
||||||
|
|
||||||
bool is3D = mStagingTex->getDepth() != 0;
|
//unmap staging texture
|
||||||
|
pContext->Unmap(pStagingResource, mLockedSubresource);
|
||||||
if (is3D)
|
//copy lock box region from the staging texture to our regular texture
|
||||||
{
|
pContext->CopySubresourceRegion(mD3DTexture, mLockedSubresource, mLockBox.left, mLockBox.top, is3D ? mLockBox.back : 0, pStagingResource, mLockedSubresource, &mLockBox);
|
||||||
ID3D11Texture3D* pStagingTex = pD3DStagingTex->get3DTex();
|
|
||||||
|
|
||||||
//unmap staging texture
|
|
||||||
pContext->Unmap(pStagingTex, mLockedSubresource);
|
|
||||||
//copy lock box region from the staging texture to our regular texture
|
|
||||||
pContext->CopySubresourceRegion(mD3DTexture, mLockedSubresource, mLockBox.left, mLockBox.top, mLockBox.front, pStagingTex, mLockedSubresource, &mLockBox);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ID3D11Texture2D* pStagingTex = pD3DStagingTex->get2DTex();
|
|
||||||
|
|
||||||
//unmap staging texture
|
|
||||||
pContext->Unmap(pStagingTex, mLockedSubresource);
|
|
||||||
//copy lock box region from the staging texture to our regular texture
|
|
||||||
pContext->CopySubresourceRegion(mD3DTexture, mLockedSubresource, mLockBox.left, mLockBox.top, 0, pStagingTex, mLockedSubresource, &mLockBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
PROFILE_END();
|
PROFILE_END();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue