//-----------------------------------------------------------------------------
void D3D11HardwarePixelBuffer::unlockImpl(void)
{
    if(mUsage == HBU_STATIC)
        _unmapstagingbuffer();
    else if(mUsage & HBU_DYNAMIC)
    {
        if(mCurrentLockOptions == HBL_READ_ONLY || mCurrentLockOptions == HBL_NORMAL || mCurrentLockOptions == HBL_WRITE_ONLY)
        {
            size_t sizeinbytes = D3D11Mappings::_getSizeInBytes(mParentTexture->getFormat(), mParentTexture->getWidth(), mParentTexture->getHeight());
            PixelBox box;
            _map(mParentTexture->getTextureResource(), D3D11_MAP_WRITE_DISCARD, box);
            void *data = box.data;

            memcpy(data, mCurrentLock.data, sizeinbytes);

            // unmap the texture and the staging buffer
            _unmap(mParentTexture->getTextureResource());

            _unmapstagingbuffer(false);
        }
        else
            _unmap(mParentTexture->getTextureResource());
    }
    else
        _unmapstaticbuffer();

    _genMipmaps();
}
示例#2
0
    void unmap()
    {
        if (!ptr)
            return;

        _unmap();
        ptr = nullptr;
        size = 0;
    }
//-----------------------------------------------------------------------------
void D3D11HardwarePixelBuffer::_unmapstagingbuffer(bool copyback)
{
    _unmap(mStagingBuffer);

    if(copyback)
    {
        if(mLockBox.getHeight() == mParentTexture->getHeight() && mLockBox.getWidth() == mParentTexture->getWidth())
            mDevice.GetImmediateContext()->CopyResource(mParentTexture->getTextureResource(), mStagingBuffer);
        else
        {
            D3D11_BOX dstBoxDx11 = OgreImageBoxToDx11Box(mLockBox);
            dstBoxDx11.front = 0;
            dstBoxDx11.back = mLockBox.getDepth();

            unsigned int subresource = D3D11CalcSubresource(mSubresourceIndex, mLockBox.front, mParentTexture->getNumMipmaps()+1);
            mDevice.GetImmediateContext()->CopySubresourceRegion(mParentTexture->getTextureResource(), subresource, mLockBox.left, mLockBox.top, mSubresourceIndex, mStagingBuffer, subresource, &dstBoxDx11);
        }
    }
}
void io::MMapInputStream::close()
{
    _unmap();
    fclose(mFile);
    mFile = NULL;
}