Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMJP

Posted 29 October 2012 - 08:41 PM

You have to copy the data into the pointer provided by D3D11_MAPPED_SUBRESOURCE, not just copy the pointer itself. This is different then when you initialize a texture with data, where you give it a pointer. You also need to mind the pitch of the texture, which could be padded due to hardware requirements. Usually you do something like this for a 2D texture:

const uint32_t pixelSize = 12; // sizeof(DXGI_FORMAT_R32G32B32_FLOAT)
const uint32_t srcPitch = pixelSize * textureWidth;
uint8_t* textureData = reinterpret_cast<uint8_t*>(data.pData);
const uint8_t* srcData = reinterpret_cast<const uint8_t*>(mBlendMap.data());
for(uint32_t i = 0; i < textureHeight; ++i)
{
    // Copy the texture data for a single row
    memcpy(textureData, srcData, srcPitch);
   
    // Advance the pointers
    textureData += data.RowPitch;
    srcData += srcPitch;
}

#1MJP

Posted 29 October 2012 - 08:37 PM

You have to copy the data into the pointer provided by D3D11_MAPPED_SUBRESOURCE, not just copy the pointer itself. This is different then when you initialize a texture with data, where you give it a pointer.

PARTNERS