don't hardcode cpp
authorBrian <brian.paul@tungstengraphics.com>
Fri, 10 Aug 2007 19:11:47 +0000 (13:11 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Fri, 10 Aug 2007 19:11:47 +0000 (13:11 -0600)
src/mesa/state_tracker/st_cb_drawpixels.c

index afe034295793470c45caf934fcb959f5d2396a2c..81b48859f0c22465456825f7b8661faab89c6b8c 100644 (file)
@@ -102,16 +102,18 @@ make_mipmap_tree(struct st_context *st,
 {
    struct pipe_context *pipe = st->pipe;
    const struct gl_texture_format *mformat;
-   GLuint pipeFormat = st_choose_pipe_format(st->pipe, GL_RGBA, format, type);
-   int cpp = 4;
-   struct pipe_mipmap_tree *mt = CALLOC_STRUCT(pipe_mipmap_tree);
-   GLbitfield flags = PIPE_SURFACE_FLAG_TEXTURE;
+   const GLbitfield flags = PIPE_SURFACE_FLAG_TEXTURE;
+   struct pipe_mipmap_tree *mt;
+   GLuint pipeFormat, cpp;
 
    mformat = st_ChooseTextureFormat(st->ctx, GL_RGBA, format, type);
-   assert(format);
+   assert(mformat);
 
    pipeFormat = st_mesa_format_to_pipe_format(mformat->MesaFormat);
    assert(pipeFormat);
+   cpp = st_sizeof_format(pipeFormat);
+
+   mt = CALLOC_STRUCT(pipe_mipmap_tree);
 
    if (unpack->BufferObj && unpack->BufferObj->Name) {
       /*
@@ -137,7 +139,7 @@ make_mipmap_tree(struct st_context *st,
                                     mformat,          /* gl_texture_format */
                                     dest,             /* dest */
                                     0, 0, 0,          /* dstX/Y/Zoffset */
-                                    pitch * cpp,      /* dstRowStride */
+                                    pitch * cpp,      /* dstRowStride, bytes */
                                     &dstImageOffsets, /* dstImageOffsets */
                                     width, height, 1, /* size */
                                     format, type,     /* src format/type */