summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-04-19 16:49:37 -0600
committerBrian Paul <brianp@vmware.com>2010-04-19 17:07:25 -0600
commit2cad62475b8263472f6fbd541b5b8ec2a1d40e62 (patch)
tree5e8e603a1663eeabf0bef225d2ea09c83fc66591
parent202ff7db490f4a1d041a88f11665fbd3ccea2201 (diff)
llvmpipe: consolidate some code in llvmpipe_set_texture_image_layout()
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 5da67bad1b..002669adaa 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -820,6 +820,24 @@ llvmpipe_set_texture_tile_layout(struct llvmpipe_resource *lpr,
/**
+ * Set the layout mode for all tiles in a particular image.
+ */
+static INLINE void
+llvmpipe_set_texture_image_layout(struct llvmpipe_resource *lpr,
+ unsigned face_slice, unsigned level,
+ unsigned width_t, unsigned height_t,
+ enum lp_texture_layout layout)
+{
+ const unsigned start = face_slice * lpr->tiles_per_image[level];
+ unsigned i;
+
+ for (i = 0; i < width_t * height_t; i++) {
+ lpr->layout[level][start + i] = layout;
+ }
+}
+
+
+/**
* Return pointer to texture image data (either linear or tiled layout)
* for a particular cube face or 3D texture slice.
*
@@ -910,15 +928,8 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
/* Just allocating tiled memory. Don't initialize it from the
* linear data if it exists.
*/
- {
- unsigned x, y;
- for (y = 0; y < height_t; y++) {
- for (x = 0; x < width_t; x++) {
- llvmpipe_set_texture_tile_layout(lpr, face_slice, level,
- x, y, layout);
- }
- }
- }
+ llvmpipe_set_texture_image_layout(lpr, face_slice, level,
+ width_t, height_t, layout);
return target_data;
}
@@ -961,13 +972,8 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
}
else {
/* no other data */
- unsigned x, y;
- for (y = 0; y < height_t; y++) {
- for (x = 0; x < width_t; x++) {
- llvmpipe_set_texture_tile_layout(lpr, face_slice, level,
- x, y, layout);
- }
- }
+ llvmpipe_set_texture_image_layout(lpr, face_slice, level,
+ width_t, height_t, layout);
}
assert(target_data);