st/mesa: improve the format choosing code for DrawPixels
authorBrian Paul <brianp@vmware.com>
Fri, 1 Feb 2013 18:38:28 +0000 (11:38 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 4 Feb 2013 15:28:17 +0000 (08:28 -0700)
The code before was getting a pipe format, then calling
st_pipe_format_to_mesa_format() and then converting back again with
st_mesa_format_to_pipe_format().  This removes one conversion step.

src/mesa/state_tracker/st_cb_drawpixels.c

index ec44a4359d11ba8b3283e9cf942f941a52f60781..26d1923b54152ee32aad891457a348cd0227dc8a 100644 (file)
@@ -489,12 +489,14 @@ make_texture(struct st_context *st,
    intFormat = internal_format(ctx, format, type);
    baseInternalFormat = _mesa_base_tex_format(ctx, intFormat);
 
-   mformat = st_ChooseTextureFormat_renderable(ctx, intFormat,
-                                               format, type, GL_FALSE);
-   assert(mformat);
-
-   pipeFormat = st_mesa_format_to_pipe_format(mformat);
-   assert(pipeFormat);
+   /* Choose a pixel format for the temp texture which will hold the
+    * image to draw.
+    */
+   pipeFormat = st_choose_format(pipe->screen, intFormat, format, type,
+                                 PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW,
+                                 FALSE);
+   assert(pipeFormat != PIPE_FORMAT_NONE);
+   mformat = st_pipe_format_to_mesa_format(pipeFormat);
 
    pixels = _mesa_map_pbo_source(ctx, unpack, pixels);
    if (!pixels)