Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example error handling flow example
static void * map_buffer( ID3D11DeviceContext * d3d, HRESULT * hr, ID3D11Buffer * buf, D3D11_MAP map_type )
{
D3D11_MAPPED_SUBRESOURCE mapped;
if ( FAILED( *hr ) )
return NULL;
*hr = d3d->Map( buf, 0, map_type, 0, &mapped );
return mapped.pData;
}
void Begin_Update( ID3D11DeviceContext * d3d, BINKGPU_D3D11 * ctx )
{
HRESULT hr = S_OK;
U8 * dc_base = (U8 *) map_buffer( d3d, &hr, ctx->dc_buf_in, D3D11_MAP_WRITE_DISCARD );
U8 * ac_base = (U8 *) map_buffer( d3d, &hr, ctx->ac_buf, D3D11_MAP_WRITE_DISCARD );
BINKGPUMOVEC * motion_base = (BINKGPUMOVEC *) map_buffer( d3d, &hr, ctx->motion_buf, D3D11_MAP_WRITE_DISCARD );
if ( FAILED( hr ) )
{
if ( dc_base ) d3d->Unmap( ctx->dc_buf_in, 0 );
if ( ac_base ) d3d->Unmap( ctx->ac_buf, 0 );
if ( motion_base ) d3d->Unmap( ctx->motion_buf, 0 );
return;
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment