aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_texture.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker/st_texture.c')
-rw-r--r--src/mesa/state_tracker/st_texture.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 844a9f80d85..ff33da6f9e4 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -62,6 +62,10 @@ target_to_target(GLenum target)
/**
* Allocate a new pipe_texture object
+ * width0, height0, depth0 are the dimensions of the level 0 image
+ * (the highest resolution). last_level indicates how many mipmap levels
+ * to allocate storage for. For non-mipmapped textures, this will be zero.
+ * XXX first_level obsolete
*/
struct pipe_texture *
st_texture_create(struct st_context *st,
@@ -84,9 +88,9 @@ st_texture_create(struct st_context *st,
assert(format);
+ memset(&pt, 0, sizeof(pt));
pt.target = target;
pt.format = format;
- pt.first_level = first_level;
pt.last_level = last_level;
pt.width[0] = width0;
pt.height[0] = height0;
@@ -266,23 +270,36 @@ st_texture_image_data(struct pipe_context *pipe,
*/
void
st_texture_image_copy(struct pipe_context *pipe,
- struct pipe_texture *dst,
- GLuint face, GLuint level,
- struct pipe_texture *src)
+ struct pipe_texture *dst, GLuint dstLevel,
+ struct pipe_texture *src,
+ GLuint face)
{
- GLuint width = src->width[level];
- GLuint height = src->height[level];
- GLuint depth = src->depth[level];
+ GLuint width = dst->width[dstLevel];
+ GLuint height = dst->height[dstLevel];
+ GLuint depth = dst->depth[dstLevel];
struct pipe_surface *src_surface;
struct pipe_surface *dst_surface;
GLuint i;
+ /* XXX this is a hack */
if (dst->compressed)
height /= 4;
for (i = 0; i < depth; i++) {
- dst_surface = pipe->get_tex_surface(pipe, dst, face, level, i);
- src_surface = pipe->get_tex_surface(pipe, src, face, level, i);
+ GLuint srcLevel;
+
+ /* find src texture level of needed size */
+ for (srcLevel = 0; srcLevel <= src->last_level; srcLevel++) {
+ if (src->width[srcLevel] == width &&
+ src->height[srcLevel] == height) {
+ break;
+ }
+ }
+ assert(src->width[srcLevel] == width);
+ assert(src->height[srcLevel] == height);
+
+ dst_surface = pipe->get_tex_surface(pipe, dst, face, dstLevel, i);
+ src_surface = pipe->get_tex_surface(pipe, src, face, srcLevel, i);
pipe->surface_copy(pipe,
dst_surface,