sp_state_derived.c File Reference

Include dependency graph for sp_state_derived.c:

Go to the source code of this file.

Functions

static void invalidate_vertex_layout (struct softpipe_context *softpipe)
 Mark the current vertex layout as "invalid".
struct vertex_infosoftpipe_get_vertex_info (struct softpipe_context *softpipe)
 The vertex info describes how to convert the post-transformed vertices (simple float[][4]) used by the 'draw' module into vertices for rasterization.
struct vertex_infosoftpipe_get_vbuf_vertex_info (struct softpipe_context *softpipe)
 Called from vbuf module.
static void compute_cliprect (struct softpipe_context *sp)
 Recompute cliprect from scissor bounds, scissor enable and surface size.
void softpipe_update_derived (struct softpipe_context *softpipe)


Function Documentation

static void compute_cliprect ( struct softpipe_context sp  )  [static]

Recompute cliprect from scissor bounds, scissor enable and surface size.

Definition at line 164 of file sp_state_derived.c.

References softpipe_context::cliprect, softpipe_context::framebuffer, pipe_framebuffer_state::height, MAX2, pipe_scissor_state::maxx, pipe_scissor_state::maxy, MIN2, pipe_scissor_state::minx, pipe_scissor_state::miny, softpipe_context::rasterizer, softpipe_context::scissor, pipe_rasterizer_state::scissor, and pipe_framebuffer_state::width.

00165 {
00166    uint surfWidth = sp->framebuffer.width;
00167    uint surfHeight = sp->framebuffer.height;
00168 
00169    if (sp->rasterizer->scissor) {
00170       /* clip to scissor rect */
00171       sp->cliprect.minx = MAX2(sp->scissor.minx, 0);
00172       sp->cliprect.miny = MAX2(sp->scissor.miny, 0);
00173       sp->cliprect.maxx = MIN2(sp->scissor.maxx, surfWidth);
00174       sp->cliprect.maxy = MIN2(sp->scissor.maxy, surfHeight);
00175    }
00176    else {
00177       /* clip to surface bounds */
00178       sp->cliprect.minx = 0;
00179       sp->cliprect.miny = 0;
00180       sp->cliprect.maxx = surfWidth;
00181       sp->cliprect.maxy = surfHeight;
00182    }
00183 }

static void invalidate_vertex_layout ( struct softpipe_context softpipe  )  [static]

Mark the current vertex layout as "invalid".

We'll validate the vertex layout later, when we start to actually render a point or line or tri.

Definition at line 44 of file sp_state_derived.c.

References vertex_info::num_attribs, and softpipe_context::vertex_info.

00045 {
00046    softpipe->vertex_info.num_attribs =  0;
00047 }

struct vertex_info* softpipe_get_vbuf_vertex_info ( struct softpipe_context softpipe  )  [read]

Called from vbuf module.

Note that there's actually two different vertex layouts in softpipe.

The normal one is computed in softpipe_get_vertex_info() above and is used by the point/line/tri "setup" code.

The other one (this one) is only used by the vbuf module (which is not normally used by default but used in testing). For the vbuf module, we basically want to pass-through the draw module's vertex layout as-is. When the softpipe vbuf code begins drawing, the normal vertex layout will come into play again.

Definition at line 153 of file sp_state_derived.c.

References softpipe_get_vertex_info(), and softpipe_context::vertex_info_vbuf.

00154 {
00155    (void) softpipe_get_vertex_info(softpipe);
00156    return &softpipe->vertex_info_vbuf;
00157 }

struct vertex_info* softpipe_get_vertex_info ( struct softpipe_context softpipe  )  [read]

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.

Definition at line 59 of file sp_state_derived.c.

References assert, softpipe_context::draw, draw_compute_vertex_size(), draw_emit_vertex_attr(), draw_find_vs_output(), draw_num_vs_outputs(), EMIT_4F, pipe_rasterizer_state::flatshade, softpipe_context::fs, sp_fragment_shader::info, tgsi_shader_info::input_semantic_index, tgsi_shader_info::input_semantic_name, INTERP_CONSTANT, INTERP_LINEAR, INTERP_PERSPECTIVE, INTERP_POS, vertex_info::num_attribs, tgsi_shader_info::num_inputs, softpipe_context::psize_slot, softpipe_context::rasterizer, TGSI_SEMANTIC_COLOR, TGSI_SEMANTIC_FOG, TGSI_SEMANTIC_GENERIC, TGSI_SEMANTIC_POSITION, TGSI_SEMANTIC_PSIZE, softpipe_context::vbuf, softpipe_context::vertex_info, and softpipe_context::vertex_info_vbuf.

00060 {
00061    struct vertex_info *vinfo = &softpipe->vertex_info;
00062 
00063    if (vinfo->num_attribs == 0) {
00064       /* compute vertex layout now */
00065       const struct sp_fragment_shader *spfs = softpipe->fs;
00066       const enum interp_mode colorInterp
00067          = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
00068       uint i;
00069 
00070       if (softpipe->vbuf) {
00071          /* if using the post-transform vertex buffer, tell draw_vbuf to
00072           * simply emit the whole post-xform vertex as-is:
00073           */
00074          struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf;
00075          const uint num = draw_num_vs_outputs(softpipe->draw);
00076          uint i;
00077 
00078          /* No longer any need to try and emit draw vertex_header info.
00079           */
00080          vinfo_vbuf->num_attribs = 0;
00081          for (i = 0; i < num; i++) {
00082             draw_emit_vertex_attr(vinfo_vbuf, EMIT_4F, INTERP_PERSPECTIVE, i);
00083          }
00084          draw_compute_vertex_size(vinfo_vbuf);
00085       }
00086 
00087       /*
00088        * Loop over fragment shader inputs, searching for the matching output
00089        * from the vertex shader.
00090        */
00091       vinfo->num_attribs = 0;
00092       for (i = 0; i < spfs->info.num_inputs; i++) {
00093          int src;
00094          switch (spfs->info.input_semantic_name[i]) {
00095          case TGSI_SEMANTIC_POSITION:
00096             src = draw_find_vs_output(softpipe->draw,
00097                                       TGSI_SEMANTIC_POSITION, 0);
00098             draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
00099             break;
00100 
00101          case TGSI_SEMANTIC_COLOR:
00102             src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_COLOR, 
00103                                  spfs->info.input_semantic_index[i]);
00104             draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
00105             break;
00106 
00107          case TGSI_SEMANTIC_FOG:
00108             src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_FOG, 0);
00109             draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
00110             break;
00111 
00112          case TGSI_SEMANTIC_GENERIC:
00113             /* this includes texcoords and varying vars */
00114             src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_GENERIC,
00115                                       spfs->info.input_semantic_index[i]);
00116             draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
00117             break;
00118 
00119          default:
00120             assert(0);
00121          }
00122       }
00123 
00124       softpipe->psize_slot = draw_find_vs_output(softpipe->draw,
00125                                                  TGSI_SEMANTIC_PSIZE, 0);
00126       if (softpipe->psize_slot > 0) {
00127          draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT,
00128                                softpipe->psize_slot);
00129       }
00130 
00131       draw_compute_vertex_size(vinfo);
00132    }
00133 
00134    return vinfo;
00135 }

void softpipe_update_derived ( struct softpipe_context softpipe  ) 

Definition at line 189 of file sp_state_derived.c.

References compute_cliprect(), softpipe_context::dirty, invalidate_vertex_layout(), sp_build_quad_pipeline(), SP_NEW_BLEND, SP_NEW_DEPTH_STENCIL_ALPHA, SP_NEW_FRAMEBUFFER, SP_NEW_FS, SP_NEW_QUERY, SP_NEW_RASTERIZER, SP_NEW_SCISSOR, and SP_NEW_VS.

00190 {
00191    if (softpipe->dirty & (SP_NEW_RASTERIZER |
00192                           SP_NEW_FS |
00193                           SP_NEW_VS))
00194       invalidate_vertex_layout( softpipe );
00195 
00196    if (softpipe->dirty & (SP_NEW_SCISSOR |
00197                           SP_NEW_DEPTH_STENCIL_ALPHA |
00198                           SP_NEW_FRAMEBUFFER))
00199       compute_cliprect(softpipe);
00200 
00201    if (softpipe->dirty & (SP_NEW_BLEND |
00202                           SP_NEW_DEPTH_STENCIL_ALPHA |
00203                           SP_NEW_FRAMEBUFFER |
00204                           SP_NEW_RASTERIZER |
00205                           SP_NEW_FS | 
00206                           SP_NEW_QUERY))
00207       sp_build_quad_pipeline(softpipe);
00208 
00209    softpipe->dirty = 0;
00210 }


Generated on Tue Sep 29 06:25:41 2009 for Gallium3D by  doxygen 1.5.4