Example #1
0
void setup_prepare( struct setup_context *setup )
{
   struct softpipe_context *sp = setup->softpipe;
   unsigned i;

   if (sp->dirty) {
      softpipe_update_derived(sp);
   }

   /* Note: nr_attrs is only used for debugging (vertex printing) */
   setup->quad.nr_attrs = draw_num_vs_outputs(sp->draw);

   for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
      sp->quad[i].first->begin( sp->quad[i].first );
   }

   if (sp->reduced_api_prim == PIPE_PRIM_TRIANGLES &&
       sp->rasterizer->fill_cw == PIPE_POLYGON_MODE_FILL &&
       sp->rasterizer->fill_ccw == PIPE_POLYGON_MODE_FILL) {
      /* we'll do culling */
      setup->winding = sp->rasterizer->cull_mode;
   }
   else {
      /* 'draw' will do culling */
      setup->winding = PIPE_WINDING_NONE;
   }
}
Example #2
0
/**
 * The vertex info describes how to convert the post-transformed vertices
 * (simple float[][4]) used by the 'draw' module into vertices for
 * rasterization.
 *
 * This function validates the vertex layout and returns a pointer to a
 * vertex_info object.
 */
struct vertex_info *
softpipe_get_vertex_info(struct softpipe_context *softpipe)
{
   struct vertex_info *vinfo = &softpipe->vertex_info;

   if (vinfo->num_attribs == 0) {
      /* compute vertex layout now */
      const struct sp_fragment_shader *spfs = softpipe->fs;
      const enum interp_mode colorInterp
         = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
      uint i;

      if (softpipe->vbuf) {
         /* if using the post-transform vertex buffer, tell draw_vbuf to
          * simply emit the whole post-xform vertex as-is:
          */
         struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf;
         const uint num = draw_num_vs_outputs(softpipe->draw);
         uint i;

         /* No longer any need to try and emit draw vertex_header info.
          */
         vinfo_vbuf->num_attribs = 0;
         for (i = 0; i < num; i++) {
            draw_emit_vertex_attr(vinfo_vbuf, EMIT_4F, INTERP_PERSPECTIVE, i);
         }
         draw_compute_vertex_size(vinfo_vbuf);
      }

      /*
       * Loop over fragment shader inputs, searching for the matching output
       * from the vertex shader.
       */
      vinfo->num_attribs = 0;
      for (i = 0; i < spfs->info.num_inputs; i++) {
         int src;
         switch (spfs->info.input_semantic_name[i]) {
         case TGSI_SEMANTIC_POSITION:
            src = draw_find_vs_output(softpipe->draw,
                                      TGSI_SEMANTIC_POSITION, 0);
            draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
            break;

         case TGSI_SEMANTIC_COLOR:
            src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_COLOR, 
                                 spfs->info.input_semantic_index[i]);
            draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
            break;

         case TGSI_SEMANTIC_FOG:
            src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_FOG, 0);
            draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
            break;

         case TGSI_SEMANTIC_GENERIC:
         case TGSI_SEMANTIC_FACE:
            /* this includes texcoords and varying vars */
            src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_GENERIC,
                                      spfs->info.input_semantic_index[i]);
            draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
            break;

         default:
            assert(0);
         }
      }

      softpipe->psize_slot = draw_find_vs_output(softpipe->draw,
                                                 TGSI_SEMANTIC_PSIZE, 0);
      if (softpipe->psize_slot > 0) {
         draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT,
                               softpipe->psize_slot);
      }

      draw_compute_vertex_size(vinfo);
   }

   return vinfo;
}