
208 GPGPU Programming for Games and Science
FIGURE 4.12: Copying data between processors.
D3D11 MAPPED SUBRESOURCE s ub ;
context−>Map ( out put . b u f f e r , 0 , D3D11
MAP WRITE DISCARD, 0 , &sub ) ;
memcpy(sub .pData , input . data + input . offset , input .numActiveBytes );
context−>Unmap( output . buffer , 0);
LISTING 4.55: Updating an ID3D11Buffer object using mapped writes.
The
ID3D11DeviceContext::Map function [39] takes as input the buffer object,
the subresource index zero because buffers have only one subresource, a
D3D11 MAP value [29], and a D3D11 MAP FLAG value [30]; the function then
fills in a
D3D11 MAPPED SUBRESOURCE subresource data structure ...