From 37cf13ed9a429c755f121daa1776b1b30a985ab3 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 19 Sep 2007 18:53:36 -0600 Subject: Checkpoint: replacement of TGSI_ATTRIB_x tokens with input/output semantics. TGSI_ATTRIB_x tokens still present and used in a few places. Expanded set of TGSI_SEMANTIC_x tokens for describing the meaning of inputs/outputs. These tokens are in a crude state ATM. Lots of #if 0 / disabled code to be removed yet, etc... Softpipe and i915 drivers should be in working condition but not heavily tested. --- src/mesa/pipe/softpipe/sp_context.c | 10 ++++ src/mesa/pipe/softpipe/sp_state_derived.c | 90 ++++++++++++++++--------------- 2 files changed, 56 insertions(+), 44 deletions(-) (limited to 'src/mesa/pipe/softpipe') diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index a56793d683..ebd5530950 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -236,6 +236,15 @@ static const char *softpipe_get_vendor( struct pipe_context *pipe ) return "Tungsten Graphics, Inc."; } +static int softpipe_get_param(struct pipe_context *pipe, uint param) +{ + switch (param) { + case PIPE_PARAM_FS_NEEDS_POS: + return 1; + default: + return 0; + } +} struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, struct softpipe_winsys *softpipe_winsys ) @@ -248,6 +257,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, /* queries */ softpipe->pipe.supported_formats = softpipe_supported_formats; softpipe->pipe.max_texture_size = softpipe_max_texture_size; + softpipe->pipe.get_param = softpipe_get_param; /* state setters */ softpipe->pipe.create_blend_state = softpipe_create_blend_state; diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 9611a2ac99..0dd0eea0b8 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -34,6 +34,7 @@ #include "sp_state.h" #include "pipe/tgsi/exec/tgsi_attribs.h" +#include "pipe/tgsi/exec/tgsi_token.h" /** @@ -43,7 +44,7 @@ */ static void calculate_vertex_layout( struct softpipe_context *softpipe ) { - const uint inputsRead = softpipe->fs->inputs_read; + const struct pipe_shader_state *fs = softpipe->fs; const interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &softpipe->vertex_info; @@ -52,57 +53,59 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) memset(vinfo, 0, sizeof(*vinfo)); - /* Need Z if depth test is enabled or the fragment program uses the - * fragment position (XYZW). - */ - if (softpipe->depth_stencil->depth.enabled || - (inputsRead & (1 << TGSI_ATTRIB_POS))) + if (softpipe->depth_stencil->depth.enabled) softpipe->need_z = TRUE; else softpipe->need_z = FALSE; + softpipe->need_w = FALSE; - /* Need W if we do any perspective-corrected interpolation or the - * fragment program uses the fragment position. - */ - if (inputsRead & (1 << TGSI_ATTRIB_POS)) - softpipe->need_w = TRUE; - else - softpipe->need_w = FALSE; - - /* position */ + /* always emit vertex pos */ /* TODO - Figure out if we need to do perspective divide, etc. */ draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_4F, INTERP_LINEAR); - - /* color0 */ - if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { - front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, - FORMAT_4F, colorInterp); - } - - /* color1 */ - if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) { - front1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1, - FORMAT_4F, colorInterp); - } - /* fog */ - if (inputsRead & (1 << TGSI_ATTRIB_FOG)) { - draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_FOG, - FORMAT_1F, INTERP_PERSPECTIVE); - } - - /* point size */ + for (i = 0; i < fs->num_inputs; i++) { + switch (fs->input_semantics[i]) { + case TGSI_SEMANTIC_POSITION: + /* Need Z if depth test is enabled or the fragment program uses the + * fragment position (XYZW). + */ + softpipe->need_z = TRUE; + softpipe->need_w = TRUE; + break; + case TGSI_SEMANTIC_COLOR0: + front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, + FORMAT_4F, colorInterp); + break; + case TGSI_SEMANTIC_COLOR1: + front1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1, + FORMAT_4F, colorInterp); + break; + case TGSI_SEMANTIC_FOG: + draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_FOG, + FORMAT_1F, INTERP_PERSPECTIVE); + break; #if 0 - /* XXX only emit if drawing points or front/back polygon mode is point mode */ - draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POINTSIZE, - FORMAT_4F, INTERP_CONSTANT); + case TGSI_SEMANTIC_PSIZE: + /* XXX only emit if drawing points or front/back polygon mode + * is point mode + */ + draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POINTSIZE, + FORMAT_4F, INTERP_CONSTANT); + break; #endif - - /* texcoords and varying vars */ - for (i = TGSI_ATTRIB_TEX0; i < TGSI_ATTRIB_VAR7; i++) { - if (inputsRead & (1 << i)) { + /*case TGSI_SEMANTIC_TEXCOORD:*/ + case TGSI_SEMANTIC_TEX0: + draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_TEX0, + FORMAT_4F, INTERP_PERSPECTIVE); + softpipe->need_w = TRUE; + break; + case TGSI_SEMANTIC_OTHER: draw_emit_vertex_attr(vinfo, i, FORMAT_4F, INTERP_PERSPECTIVE); softpipe->need_w = TRUE; + break; + + default: + assert(0); } } @@ -113,12 +116,11 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) * the vertex header. */ if (softpipe->rasterizer->light_twoside) { - if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { + if (front0) { back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, FORMAT_OMIT, colorInterp); } - - if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) { + if (back0) { back1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC1, FORMAT_OMIT, colorInterp); } -- cgit v1.2.3