diff options
author | Keith Whitwell <[email protected]> | 2010-12-22 14:04:42 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2012-02-03 18:51:14 +0000 |
commit | 9a1fd9a37ce3ee2ede5bef5cf508a02f3bdb6098 (patch) | |
tree | 23bf97b3ef46de38f599c8b7f393c3701ef1470c /src/gallium/drivers/llvmpipe/lp_texture.c | |
parent | 87b4c9b322dabeba7c9a9d02e9efefd2c89e6625 (diff) |
llvmpipe: clear storage for newly allocated resources
Was previously being done in a state-tracker, but in a way which was
difficult for some drivers to optimize. Push down to this level and
make it the individual drivers responsibility.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_texture.c')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_texture.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index d86d493a0a2..8fac77b0c57 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -219,7 +219,20 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen, 16, &lpr->row_stride[0] ); - return lpr->dt != NULL; + if (lpr->dt == NULL) + return FALSE; + + { + void *map = winsys->displaytarget_map(winsys, lpr->dt, + PIPE_TRANSFER_WRITE); + + if (map) + memset(map, 0, height * lpr->row_stride[0]); + + winsys->displaytarget_unmap(winsys, lpr->dt); + } + + return TRUE; } @@ -265,6 +278,7 @@ llvmpipe_resource_create(struct pipe_screen *_screen, lpr->data = align_malloc(bytes, 16); if (!lpr->data) goto fail; + memset(lpr->data, 0, bytes); } lpr->id = id_counter++; @@ -964,11 +978,14 @@ alloc_image_data(struct llvmpipe_resource *lpr, unsigned level, /* tiled data is stored in regular memory */ uint buffer_size = tex_image_size(lpr, level, layout); lpr->tiled[level].data = align_malloc(buffer_size, alignment); + memset(lpr->tiled[level].data, 0, buffer_size); } else { assert(layout == LP_TEX_LAYOUT_LINEAR); if (lpr->dt) { - /* we get the linear memory from the winsys */ + /* we get the linear memory from the winsys, and it has + * already been zeroed + */ struct llvmpipe_screen *screen = llvmpipe_screen(lpr->base.screen); struct sw_winsys *winsys = screen->winsys; @@ -980,6 +997,7 @@ alloc_image_data(struct llvmpipe_resource *lpr, unsigned level, /* not a display target - allocate regular memory */ uint buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_LINEAR); lpr->linear[level].data = align_malloc(buffer_size, alignment); + memset(lpr->linear[level].data, 0, buffer_size); } } } |