add bmBufferGetSubData

This commit is contained in:
Keith Whitwell 2006-02-24 16:50:22 +00:00
parent 59dd8ad752
commit 84f7ded925
2 changed files with 40 additions and 0 deletions

View file

@ -115,6 +115,12 @@ void bmBufferSubData(struct bufmgr *,
unsigned size,
const void *data );
void bmBufferGetSubData(struct bufmgr *,
unsigned buffer,
unsigned offset,
unsigned size,
void *data );
void *bmMapBuffer( struct bufmgr *,
unsigned buffer,
unsigned access );

View file

@ -808,6 +808,40 @@ void bmBufferSubData(struct bufmgr *bm,
}
/* Extract data from the buffer:
*/
void bmBufferGetSubData(struct bufmgr *bm,
unsigned buffer,
unsigned offset,
unsigned size,
void *data )
{
struct buffer *buf = (struct buffer *)_mesa_HashLookup( bm->hash, buffer );
DBG("bmBufferSubdata %d offset 0x%x sz 0x%x\n", buffer, offset, size);
if (buf->block == 0)
return;
if (buf->block->mem_type != BM_MEM_LOCAL)
bmFinishFence(bm, buf->block->fence);
if (size) {
#if 0
memcpy(data, buf->block->virtual + offset, size);
#else
/* Do an implicit map/unmap to get this working for now:
*/
memcpy(data, bmMapBuffer(bm, buf->id, 0) + offset, size);
bmUnmapBuffer(bm, buf->id);
#endif
}
}
/* Return a pointer to whatever space the buffer is currently resident in:
*/
void *bmMapBuffer( struct bufmgr *bm,