summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe/lp_texture.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-04-19 14:07:23 -0600
committerBrian Paul <brianp@vmware.com>2010-04-19 17:07:25 -0600
commit254dd0c23f53d535fb612746885fea8c0d4c21cd (patch)
tree0b1bd666bbbfe6fa3192a9314a68572ddba3e630 /src/gallium/drivers/llvmpipe/lp_texture.c
parentf189caeed046e05bfeec8adf2ebeaae01d1bf2f6 (diff)
llvmpipe: another fix for surface memory allocation
The previous patch broke cube maps. The logic is a bit clearer now.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_texture.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index f719ca48ee..41f028a238 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -825,6 +825,7 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
const unsigned width_t = align(width, TILE_SIZE) / TILE_SIZE;
const unsigned height_t = align(height, TILE_SIZE) / TILE_SIZE;
enum lp_texture_layout other_layout;
+ boolean only_allocate;
assert(layout == LP_TEX_LAYOUT_NONE ||
layout == LP_TEX_LAYOUT_TILED ||
@@ -834,6 +835,15 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
usage == LP_TEX_USAGE_READ_WRITE ||
usage == LP_TEX_USAGE_WRITE_ALL);
+ /* check for the special case of layout == LP_TEX_LAYOUT_NONE */
+ if (layout == LP_TEX_LAYOUT_NONE) {
+ only_allocate = TRUE;
+ layout = LP_TEX_LAYOUT_TILED;
+ }
+ else {
+ only_allocate = FALSE;
+ }
+
if (lpr->dt) {
assert(lpr->linear[level].data);
}
@@ -855,11 +865,7 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
if (!target_data) {
/* allocate memory for the target image now */
- unsigned buffer_size;
- if (layout == LP_TEX_LAYOUT_LINEAR)
- buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_LINEAR);
- else
- buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_TILED);
+ unsigned buffer_size = tex_image_size(lpr, level, layout);
target_img->data = align_malloc(buffer_size, 16);
target_data = target_img->data;
}
@@ -874,7 +880,7 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
}
}
- if (layout == LP_TEX_LAYOUT_NONE) {
+ if (only_allocate) {
/* Just allocating tiled memory. Don't initialize it from the the
* linear data if it exists.
*/