|
|
@@ -94,34 +94,6 @@ namespace CamelotFramework
|
|
|
mRowPitch = mWidth;
|
|
|
mSlicePitch = mHeight*mWidth;
|
|
|
mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
|
|
|
-
|
|
|
- // TODO PORT - My Texture doesn't inherit from Resource and doesn't have that method. Not sure why it needs to call it,
|
|
|
- // but since we're not there's potential for trouble here.
|
|
|
- if (isNewBuffer /*&& mOwnerTexture->isManuallyLoaded()*/)
|
|
|
- {
|
|
|
- DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
|
|
|
-
|
|
|
- while (it != mMapDeviceToBufferResources.end())
|
|
|
- {
|
|
|
- if (it->second != bufferResources &&
|
|
|
- it->second->surface != NULL &&
|
|
|
- it->first->TestCooperativeLevel() == D3D_OK &&
|
|
|
- dev->TestCooperativeLevel() == D3D_OK)
|
|
|
- {
|
|
|
- Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
|
|
|
- PixelData dstBox(fullBufferBox, mFormat);
|
|
|
- dstBox.allocateInternalBuffer();
|
|
|
-
|
|
|
- blitToMemory(fullBufferBox, dstBox, it->second, it->first);
|
|
|
- blitFromMemory(dstBox, fullBufferBox, bufferResources);
|
|
|
-
|
|
|
- dstBox.freeInternalBuffer();
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- ++it;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void D3D9PixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *volume, IDirect3DBaseTexture9 *mipTex)
|
|
|
@@ -153,34 +125,6 @@ namespace CamelotFramework
|
|
|
mRowPitch = mWidth;
|
|
|
mSlicePitch = mHeight*mWidth;
|
|
|
mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
|
|
|
-
|
|
|
- // TODO PORT - My Texture doesn't inherit from Resource and doesn't have that method. Not sure why it needs to call it,
|
|
|
- // but since we're not there's potential for trouble here.
|
|
|
- if (isNewBuffer /*&& mOwnerTexture->isManuallyLoaded()*/)
|
|
|
- {
|
|
|
- DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
|
|
|
-
|
|
|
- while (it != mMapDeviceToBufferResources.end())
|
|
|
- {
|
|
|
- if (it->second != bufferResources &&
|
|
|
- it->second->volume != NULL &&
|
|
|
- it->first->TestCooperativeLevel() == D3D_OK &&
|
|
|
- dev->TestCooperativeLevel() == D3D_OK)
|
|
|
- {
|
|
|
- Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
|
|
|
- PixelData dstBox(fullBufferBox, mFormat);
|
|
|
- dstBox.allocateInternalBuffer();
|
|
|
-
|
|
|
- blitToMemory(fullBufferBox, dstBox, it->second, it->first);
|
|
|
- blitFromMemory(dstBox, fullBufferBox, bufferResources);
|
|
|
-
|
|
|
- dstBox.freeInternalBuffer();
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- ++it;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
@@ -372,7 +316,6 @@ namespace CamelotFramework
|
|
|
// PixelBox will be re-based from the locking point onwards
|
|
|
PixelData rval(lockBox.getWidth(), lockBox.getHeight(), lockBox.getDepth(), mFormat);
|
|
|
|
|
|
-
|
|
|
if (bufferResources->surface != NULL)
|
|
|
{
|
|
|
// Surface
|
|
|
@@ -419,22 +362,7 @@ namespace CamelotFramework
|
|
|
CM_EXCEPT(RenderingAPIException, "There are no resources attached to this pixel buffer !!");
|
|
|
}
|
|
|
|
|
|
- DeviceToBufferResourcesIterator it;
|
|
|
-
|
|
|
- // 1. Update duplicates buffers.
|
|
|
- it = mMapDeviceToBufferResources.begin();
|
|
|
- ++it;
|
|
|
- while (it != mMapDeviceToBufferResources.end())
|
|
|
- {
|
|
|
- BufferResources* bufferResources = it->second;
|
|
|
-
|
|
|
- // Update duplicated buffer from the from the locked buffer content.
|
|
|
- blitFromMemory(mCurrentLock, mLockedBox, bufferResources);
|
|
|
- ++it;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. Unlock the locked buffer.
|
|
|
- it = mMapDeviceToBufferResources.begin();
|
|
|
+ DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
|
|
|
unlockBuffer( it->second);
|
|
|
if(mDoMipmapGen)
|
|
|
_genMipmaps(it->second->mipTex);
|
|
|
@@ -454,402 +382,6 @@ namespace CamelotFramework
|
|
|
bufferResources->volume->UnlockBox();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //-----------------------------------------------------------------------------
|
|
|
- void D3D9PixelBuffer::blit(const PixelBufferPtr &rsrc,
|
|
|
- const Box &srcBox,
|
|
|
- const Box &dstBox)
|
|
|
- {
|
|
|
- D3D9_DEVICE_ACCESS_CRITICAL_SECTION
|
|
|
-
|
|
|
- D3D9PixelBuffer *src = static_cast<D3D9PixelBuffer*>(rsrc.get());
|
|
|
- DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
|
|
|
-
|
|
|
- // Update all the buffer copies.
|
|
|
- while (it != mMapDeviceToBufferResources.end())
|
|
|
- {
|
|
|
- BufferResources* srcBufferResources = src->getBufferResources(it->first);
|
|
|
- BufferResources* dstBufferResources = it->second;
|
|
|
-
|
|
|
- if (srcBufferResources == NULL)
|
|
|
- {
|
|
|
- CM_EXCEPT(RenderingAPIException, "There are no matching resources attached to the source pixel buffer !!");
|
|
|
- }
|
|
|
-
|
|
|
- blit(it->first, rsrc, srcBox, dstBox, srcBufferResources, dstBufferResources);
|
|
|
- ++it;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //-----------------------------------------------------------------------------
|
|
|
- void D3D9PixelBuffer::blit(IDirect3DDevice9* d3d9Device,
|
|
|
- const PixelBufferPtr &rsrc,
|
|
|
- const Box &srcBox,
|
|
|
- const Box &dstBox,
|
|
|
- BufferResources* srcBufferResources,
|
|
|
- BufferResources* dstBufferResources)
|
|
|
- {
|
|
|
- if(dstBufferResources->surface && srcBufferResources->surface)
|
|
|
- {
|
|
|
- // Surface-to-surface
|
|
|
- RECT dsrcRect = toD3DRECT(srcBox);
|
|
|
- RECT ddestRect = toD3DRECT(dstBox);
|
|
|
-
|
|
|
- D3DSURFACE_DESC srcDesc;
|
|
|
- if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
|
|
|
- CM_EXCEPT(RenderingAPIException, "Could not get surface information");
|
|
|
-
|
|
|
- // If we're blitting from a RTT, try GetRenderTargetData
|
|
|
- // if we're going to try to use GetRenderTargetData, need to use system mem pool
|
|
|
- bool tryGetRenderTargetData = false;
|
|
|
- if ((srcDesc.Usage & D3DUSAGE_RENDERTARGET) != 0
|
|
|
- && srcDesc.MultiSampleType == D3DMULTISAMPLE_NONE)
|
|
|
- {
|
|
|
-
|
|
|
- // Temp texture
|
|
|
- IDirect3DTexture9 *tmptex;
|
|
|
- IDirect3DSurface9 *tmpsurface;
|
|
|
-
|
|
|
- if(D3DXCreateTexture(
|
|
|
- d3d9Device,
|
|
|
- srcDesc.Width, srcDesc.Height,
|
|
|
- 1, // 1 mip level ie topmost, generate no mipmaps
|
|
|
- 0, srcDesc.Format, D3DPOOL_SYSTEMMEM,
|
|
|
- &tmptex
|
|
|
- ) != D3D_OK)
|
|
|
- {
|
|
|
- CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
|
|
|
- }
|
|
|
- if(tmptex->GetSurfaceLevel(0, &tmpsurface) != D3D_OK)
|
|
|
- {
|
|
|
- tmptex->Release();
|
|
|
- CM_EXCEPT(RenderingAPIException, "Get surface level failed");
|
|
|
- }
|
|
|
- if(d3d9Device->GetRenderTargetData(srcBufferResources->surface, tmpsurface) == D3D_OK)
|
|
|
- {
|
|
|
- // Hey, it worked
|
|
|
- // Copy from this surface instead
|
|
|
- if(D3DXLoadSurfaceFromSurface(
|
|
|
- dstBufferResources->surface, NULL, &ddestRect,
|
|
|
- tmpsurface, NULL, &dsrcRect,
|
|
|
- D3DX_DEFAULT, 0) != D3D_OK)
|
|
|
- {
|
|
|
- tmpsurface->Release();
|
|
|
- tmptex->Release();
|
|
|
- CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
|
|
|
- }
|
|
|
- tmpsurface->Release();
|
|
|
- tmptex->Release();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // Otherwise, try the normal method
|
|
|
-
|
|
|
- // D3DXLoadSurfaceFromSurface
|
|
|
- if(D3DXLoadSurfaceFromSurface(
|
|
|
- dstBufferResources->surface, NULL, &ddestRect,
|
|
|
- srcBufferResources->surface, NULL, &dsrcRect,
|
|
|
- D3DX_DEFAULT, 0) != D3D_OK)
|
|
|
- {
|
|
|
- CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
|
|
|
- }
|
|
|
- }
|
|
|
- else if(dstBufferResources->volume && srcBufferResources->volume)
|
|
|
- {
|
|
|
- // Volume-to-volume
|
|
|
- D3DBOX dsrcBox = toD3DBOX(srcBox);
|
|
|
- D3DBOX ddestBox = toD3DBOX(dstBox);
|
|
|
-
|
|
|
- // D3DXLoadVolumeFromVolume
|
|
|
- if(D3DXLoadVolumeFromVolume(
|
|
|
- dstBufferResources->volume, NULL, &ddestBox,
|
|
|
- srcBufferResources->volume, NULL, &dsrcBox,
|
|
|
- D3DX_DEFAULT, 0) != D3D_OK)
|
|
|
- {
|
|
|
- CM_EXCEPT(RenderingAPIException, "D3DXLoadVolumeFromVolume failed");
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // Software fallback
|
|
|
- PixelBuffer::blit(rsrc, srcBox, dstBox);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //-----------------------------------------------------------------------------
|
|
|
- void D3D9PixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox)
|
|
|
- {
|
|
|
- D3D9_DEVICE_ACCESS_CRITICAL_SECTION
|
|
|
-
|
|
|
- DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
|
|
|
-
|
|
|
- while (it != mMapDeviceToBufferResources.end())
|
|
|
- {
|
|
|
- BufferResources* dstBufferResources = it->second;
|
|
|
-
|
|
|
- blitFromMemory(src, dstBox, dstBufferResources);
|
|
|
- ++it;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //-----------------------------------------------------------------------------
|
|
|
- void D3D9PixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox, BufferResources* dstBufferResources)
|
|
|
- {
|
|
|
- // for scoped deletion of conversion buffer
|
|
|
- PixelData converted = src;
|
|
|
-
|
|
|
- // convert to pixelbuffer's native format if necessary
|
|
|
- if (D3D9Mappings::_getPF(src.getFormat()) == D3DFMT_UNKNOWN)
|
|
|
- {
|
|
|
- converted = PixelData(src.getWidth(), src.getHeight(), src.getDepth(), mFormat);
|
|
|
- converted.allocateInternalBuffer();
|
|
|
- PixelUtil::bulkPixelConversion(src, converted);
|
|
|
- }
|
|
|
-
|
|
|
- UINT32 rowWidth;
|
|
|
- if (PixelUtil::isCompressed(converted.getFormat()))
|
|
|
- {
|
|
|
- // D3D wants the width of one row of cells in bytes
|
|
|
- if (converted.getFormat() == PF_DXT1)
|
|
|
- {
|
|
|
- // 64 bits (8 bytes) per 4x4 block
|
|
|
- rowWidth = (converted.getRowPitch() / 4) * 8;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // 128 bits (16 bytes) per 4x4 block
|
|
|
- rowWidth = (converted.getRowPitch() / 4) * 16;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- rowWidth = converted.getRowPitch() * PixelUtil::getNumElemBytes(converted.getFormat());
|
|
|
- }
|
|
|
-
|
|
|
- if (dstBufferResources->surface)
|
|
|
- {
|
|
|
- RECT destRect, srcRect;
|
|
|
- srcRect = toD3DRECT(converted.getExtents());
|
|
|
- destRect = toD3DRECT(dstBox);
|
|
|
-
|
|
|
- if(D3DXLoadSurfaceFromMemory(dstBufferResources->surface, NULL, &destRect,
|
|
|
- converted.getData(), D3D9Mappings::_getPF(converted.getFormat()),
|
|
|
- static_cast<UINT>(rowWidth),
|
|
|
- NULL, &srcRect, D3DX_DEFAULT, 0) != D3D_OK)
|
|
|
- {
|
|
|
- CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromMemory failed");
|
|
|
- }
|
|
|
- }
|
|
|
- else if (dstBufferResources->volume)
|
|
|
- {
|
|
|
- D3DBOX destBox, srcBox;
|
|
|
- srcBox = toD3DBOX(converted.getExtents());
|
|
|
- destBox = toD3DBOX(dstBox);
|
|
|
- UINT32 sliceWidth;
|
|
|
- if (PixelUtil::isCompressed(converted.getFormat()))
|
|
|
- {
|
|
|
- // D3D wants the width of one slice of cells in bytes
|
|
|
- if (converted.getFormat() == PF_DXT1)
|
|
|
- {
|
|
|
- // 64 bits (8 bytes) per 4x4 block
|
|
|
- sliceWidth = (converted.getSlicePitch() / 16) * 8;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // 128 bits (16 bytes) per 4x4 block
|
|
|
- sliceWidth = (converted.getSlicePitch() / 16) * 16;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sliceWidth = converted.getSlicePitch() * PixelUtil::getNumElemBytes(converted.getFormat());
|
|
|
- }
|
|
|
-
|
|
|
- if(D3DXLoadVolumeFromMemory(dstBufferResources->volume, NULL, &destBox,
|
|
|
- converted.getData(), D3D9Mappings::_getPF(converted.getFormat()),
|
|
|
- static_cast<UINT>(rowWidth), static_cast<UINT>(sliceWidth),
|
|
|
- NULL, &srcBox, D3DX_DEFAULT, 0) != D3D_OK)
|
|
|
- {
|
|
|
- CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromMemory failed");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(mDoMipmapGen)
|
|
|
- _genMipmaps(dstBufferResources->mipTex);
|
|
|
-
|
|
|
- converted.freeInternalBuffer();
|
|
|
- }
|
|
|
-
|
|
|
- //-----------------------------------------------------------------------------
|
|
|
- void D3D9PixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst)
|
|
|
- {
|
|
|
- D3D9_DEVICE_ACCESS_CRITICAL_SECTION
|
|
|
-
|
|
|
- DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
|
|
|
- BufferResources* bufferResources = it->second;
|
|
|
-
|
|
|
- blitToMemory(srcBox, dst, bufferResources, it->first);
|
|
|
- }
|
|
|
-
|
|
|
- //-----------------------------------------------------------------------------
|
|
|
- void D3D9PixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst,
|
|
|
- BufferResources* srcBufferResources,
|
|
|
- IDirect3DDevice9* d3d9Device)
|
|
|
- {
|
|
|
- // Decide on pixel format of temp surface
|
|
|
- PixelFormat tmpFormat = mFormat;
|
|
|
- if(D3D9Mappings::_getPF(dst.getFormat()) != D3DFMT_UNKNOWN)
|
|
|
- {
|
|
|
- tmpFormat = dst.getFormat();
|
|
|
- }
|
|
|
-
|
|
|
- if (srcBufferResources->surface)
|
|
|
- {
|
|
|
- assert(srcBox.getDepth() == 1 && dst.getDepth() == 1);
|
|
|
- // Create temp texture
|
|
|
- IDirect3DTexture9 *tmp;
|
|
|
- IDirect3DSurface9 *surface;
|
|
|
-
|
|
|
- D3DSURFACE_DESC srcDesc;
|
|
|
- if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
|
|
|
- CM_EXCEPT(RenderingAPIException, "Could not get surface information");
|
|
|
-
|
|
|
- D3DPOOL temppool = D3DPOOL_SCRATCH;
|
|
|
- // if we're going to try to use GetRenderTargetData, need to use system mem pool
|
|
|
- bool tryGetRenderTargetData = false;
|
|
|
- if (((srcDesc.Usage & D3DUSAGE_RENDERTARGET) != 0) &&
|
|
|
- (srcBox.getWidth() == dst.getWidth()) && (srcBox.getHeight() == dst.getHeight()) &&
|
|
|
- (srcBox.getWidth() == getWidth()) && (srcBox.getHeight() == getHeight()) &&
|
|
|
- (mFormat == tmpFormat))
|
|
|
- {
|
|
|
- tryGetRenderTargetData = true;
|
|
|
- temppool = D3DPOOL_SYSTEMMEM;
|
|
|
- }
|
|
|
-
|
|
|
- if(D3DXCreateTexture(
|
|
|
- d3d9Device,
|
|
|
- static_cast<UINT>(dst.getWidth()), static_cast<UINT>(dst.getHeight()),
|
|
|
- 1, // 1 mip level ie topmost, generate no mipmaps
|
|
|
- 0, D3D9Mappings::_getPF(tmpFormat), temppool,
|
|
|
- &tmp
|
|
|
- ) != D3D_OK)
|
|
|
- {
|
|
|
- CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
|
|
|
- }
|
|
|
- if(tmp->GetSurfaceLevel(0, &surface) != D3D_OK)
|
|
|
- {
|
|
|
- tmp->Release();
|
|
|
- CM_EXCEPT(RenderingAPIException, "Get surface level failed");
|
|
|
- }
|
|
|
- // Copy texture to this temp surface
|
|
|
- RECT destRect, srcRect;
|
|
|
- srcRect = toD3DRECT(srcBox);
|
|
|
- destRect = toD3DRECTExtent(dst);
|
|
|
-
|
|
|
- // Get the real temp surface format
|
|
|
- D3DSURFACE_DESC dstDesc;
|
|
|
- if(surface->GetDesc(&dstDesc) != D3D_OK)
|
|
|
- CM_EXCEPT(RenderingAPIException, "Could not get surface information");
|
|
|
- tmpFormat = D3D9Mappings::_getPF(dstDesc.Format);
|
|
|
-
|
|
|
- // Use fast GetRenderTargetData if we are in its usage conditions
|
|
|
- bool fastLoadSuccess = false;
|
|
|
- if (tryGetRenderTargetData)
|
|
|
- {
|
|
|
- if(d3d9Device->GetRenderTargetData(srcBufferResources->surface, surface) == D3D_OK)
|
|
|
- {
|
|
|
- fastLoadSuccess = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!fastLoadSuccess)
|
|
|
- {
|
|
|
- if(D3DXLoadSurfaceFromSurface(
|
|
|
- surface, NULL, &destRect,
|
|
|
- srcBufferResources->surface, NULL, &srcRect,
|
|
|
- D3DX_DEFAULT, 0) != D3D_OK)
|
|
|
- {
|
|
|
- surface->Release();
|
|
|
- tmp->Release();
|
|
|
- CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Lock temp surface and copy it to memory
|
|
|
- D3DLOCKED_RECT lrect; // Filled in by D3D
|
|
|
- if(surface->LockRect(&lrect, NULL, D3DLOCK_READONLY) != D3D_OK)
|
|
|
- {
|
|
|
- surface->Release();
|
|
|
- tmp->Release();
|
|
|
- CM_EXCEPT(RenderingAPIException, "surface->LockRect");
|
|
|
- }
|
|
|
- // Copy it
|
|
|
- PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
|
|
|
- fromD3DLock(locked, lrect);
|
|
|
- PixelUtil::bulkPixelConversion(locked, dst);
|
|
|
- surface->UnlockRect();
|
|
|
- // Release temporary surface and texture
|
|
|
- surface->Release();
|
|
|
- tmp->Release();
|
|
|
- }
|
|
|
- else if (srcBufferResources->volume)
|
|
|
- {
|
|
|
- // Create temp texture
|
|
|
- IDirect3DVolumeTexture9 *tmp;
|
|
|
- IDirect3DVolume9 *surface;
|
|
|
-
|
|
|
- if(D3DXCreateVolumeTexture(
|
|
|
- d3d9Device,
|
|
|
- static_cast<UINT>(dst.getWidth()),
|
|
|
- static_cast<UINT>(dst.getHeight()),
|
|
|
- static_cast<UINT>(dst.getDepth()), 0,
|
|
|
- 0, D3D9Mappings::_getPF(tmpFormat), D3DPOOL_SCRATCH,
|
|
|
- &tmp
|
|
|
- ) != D3D_OK)
|
|
|
- {
|
|
|
- CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
|
|
|
- }
|
|
|
- if(tmp->GetVolumeLevel(0, &surface) != D3D_OK)
|
|
|
- {
|
|
|
- tmp->Release();
|
|
|
- CM_EXCEPT(RenderingAPIException, "Get volume level failed");
|
|
|
- }
|
|
|
- // Volume
|
|
|
- D3DBOX ddestBox, dsrcBox;
|
|
|
- ddestBox = toD3DBOXExtent(dst);
|
|
|
- dsrcBox = toD3DBOX(srcBox);
|
|
|
-
|
|
|
- if(D3DXLoadVolumeFromVolume(
|
|
|
- surface, NULL, &ddestBox,
|
|
|
- srcBufferResources->volume, NULL, &dsrcBox,
|
|
|
- D3DX_DEFAULT, 0) != D3D_OK)
|
|
|
- {
|
|
|
- surface->Release();
|
|
|
- tmp->Release();
|
|
|
- CM_EXCEPT(RenderingAPIException, "D3DXLoadVolumeFromVolume failed");
|
|
|
- }
|
|
|
- // Lock temp surface and copy it to memory
|
|
|
- D3DLOCKED_BOX lbox; // Filled in by D3D
|
|
|
- if(surface->LockBox(&lbox, NULL, D3DLOCK_READONLY) != D3D_OK)
|
|
|
- {
|
|
|
- surface->Release();
|
|
|
- tmp->Release();
|
|
|
- CM_EXCEPT(RenderingAPIException, "surface->LockBox");
|
|
|
- }
|
|
|
- // Copy it
|
|
|
- PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
|
|
|
- fromD3DLock(locked, lbox);
|
|
|
- PixelUtil::bulkPixelConversion(locked, dst);
|
|
|
- surface->UnlockBox();
|
|
|
- // Release temporary surface and texture
|
|
|
- surface->Release();
|
|
|
- tmp->Release();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void D3D9PixelBuffer::_genMipmaps(IDirect3DBaseTexture9* mipTex)
|
|
|
{
|