st/mesa: move some st_cb_drawpixels.c code, add comments
authorBrian Paul <brianp@vmware.com>
Tue, 9 Feb 2016 21:19:25 +0000 (14:19 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 10 Feb 2016 00:47:42 +0000 (17:47 -0700)
src/mesa/state_tracker/st_cb_drawpixels.c

index 04a9de06520dd89364e243e1991f8a3a4907fe7b..9c1eba49dcd281de63ce80938876cff573900006 100644 (file)
@@ -648,6 +648,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
       sampler.normalized_coords = normalized;
 
       if (fpv) {
+         /* drawing a color image */
          const struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
          uint num = MAX2(MAX2(fpv->drawpix_sampler, fpv->pixelmap_sampler) + 1,
                          st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
@@ -662,12 +663,33 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
 
          cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, num, samplers);
       } else {
+         /* drawing a depth/stencil image */
          const struct pipe_sampler_state *samplers[2] = {&sampler, &sampler};
 
          cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, num_sampler_view, samplers);
       }
    }
 
+   /* user textures, plus the drawpix textures */
+   if (fpv) {
+      /* drawing a color image */
+      struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
+      uint num = MAX3(fpv->drawpix_sampler + 1,
+                      fpv->pixelmap_sampler + 1,
+                      st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
+
+      memcpy(sampler_views, st->state.sampler_views[PIPE_SHADER_FRAGMENT],
+             sizeof(sampler_views));
+
+      sampler_views[fpv->drawpix_sampler] = sv[0];
+      if (sv[1])
+         sampler_views[fpv->pixelmap_sampler] = sv[1];
+      cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num, sampler_views);
+   } else {
+      /* drawing a depth/stencil image */
+      cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num_sampler_view, sv);
+   }
+
    /* viewport state: viewport matching window dims */
    {
       const float w = (float) ctx->DrawBuffer->Width;
@@ -685,23 +707,6 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
    cso_set_vertex_elements(cso, 3, st->velems_util_draw);
    cso_set_stream_outputs(st->cso_context, 0, NULL, NULL);
 
-   /* user textures, plus the drawpix textures */
-   if (fpv) {
-      struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
-      uint num = MAX3(fpv->drawpix_sampler + 1,
-                      fpv->pixelmap_sampler + 1,
-                      st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
-
-      memcpy(sampler_views, st->state.sampler_views[PIPE_SHADER_FRAGMENT],
-             sizeof(sampler_views));
-
-      sampler_views[fpv->drawpix_sampler] = sv[0];
-      if (sv[1])
-         sampler_views[fpv->pixelmap_sampler] = sv[1];
-      cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num, sampler_views);
-   } else
-      cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num_sampler_view, sv);
-
    /* Compute Gallium window coords (y=0=top) with pixel zoom.
     * Recall that these coords are transformed by the current
     * vertex shader and viewport transformation.