summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe/sp_state_derived.c
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-09-19 18:53:36 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-09-19 18:53:59 -0600
commit37cf13ed9a429c755f121daa1776b1b30a985ab3 (patch)
tree8ae423c054011d6826024b173e1de892c8bed78e /src/mesa/pipe/softpipe/sp_state_derived.c
parent83a674a7af4e58f677a56aae2111d2cbdbf1e21d (diff)
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.
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_state_derived.c')
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c90
1 files changed, 46 insertions, 44 deletions
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);
}