summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
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
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')
-rw-r--r--src/mesa/pipe/draw/draw_vertex_shader.c4
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c14
-rw-r--r--src/mesa/pipe/i915simple/i915_fpc.h2
-rw-r--r--src/mesa/pipe/i915simple/i915_fpc_translate.c81
-rw-r--r--src/mesa/pipe/i915simple/i915_state_derived.c60
-rw-r--r--src/mesa/pipe/p_context.h3
-rw-r--r--src/mesa/pipe/p_defines.h7
-rw-r--r--src/mesa/pipe/p_state.h11
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c10
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c90
-rwxr-xr-xsrc/mesa/pipe/tgsi/exec/tgsi_build.c2
-rwxr-xr-xsrc/mesa/pipe/tgsi/exec/tgsi_dump.c18
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_token.h31
-rw-r--r--src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c118
-rw-r--r--src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h2
15 files changed, 360 insertions, 93 deletions
diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c
index cb6c605b8d..2d424632e7 100644
--- a/src/mesa/pipe/draw/draw_vertex_shader.c
+++ b/src/mesa/pipe/draw/draw_vertex_shader.c
@@ -94,7 +94,11 @@ run_vertex_program(struct draw_context *draw,
const float *trans = draw->viewport.translate;
assert(count <= 4);
+#if 0
assert(draw->vertex_shader.outputs_written & (1 << TGSI_ATTRIB_POS));
+#else
+ assert(draw->vertex_shader.output_semantics[0] == TGSI_SEMANTIC_POSITION);
+#endif
#ifdef DEBUG
memset( &machine, 0, sizeof( machine ) );
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index 36372898ce..715e1ef656 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -138,6 +138,18 @@ i915_max_texture_size(struct pipe_context *pipe, unsigned textureType,
}
+static int
+i915_get_param(struct pipe_context *pipe, uint param)
+{
+ switch (param) {
+ case PIPE_PARAM_FS_NEEDS_POS:
+ return 0;
+ default:
+ return 0;
+ }
+}
+
+
static void i915_destroy( struct pipe_context *pipe )
{
struct i915_context *i915 = i915_context( pipe );
@@ -272,6 +284,8 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915->pipe.destroy = i915_destroy;
i915->pipe.supported_formats = i915_supported_formats;
i915->pipe.max_texture_size = i915_max_texture_size;
+ i915->pipe.get_param = i915_get_param;
+
i915->pipe.clear = i915_clear;
i915->pipe.begin_query = i915_begin_query;
diff --git a/src/mesa/pipe/i915simple/i915_fpc.h b/src/mesa/pipe/i915simple/i915_fpc.h
index 84e4c5a6f3..5c4f2f90e9 100644
--- a/src/mesa/pipe/i915simple/i915_fpc.h
+++ b/src/mesa/pipe/i915simple/i915_fpc.h
@@ -51,6 +51,8 @@ struct i915_fp_compile {
uint declarations[I915_PROGRAM_SIZE];
uint program[I915_PROGRAM_SIZE];
+ uint input_semantic[PIPE_MAX_SHADER_INPUTS];
+
/** points into the i915->current.constants array: */
float (*constants)[4];
uint num_constants;
diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c
index 32c5600496..df8859bec8 100644
--- a/src/mesa/pipe/i915simple/i915_fpc_translate.c
+++ b/src/mesa/pipe/i915simple/i915_fpc_translate.c
@@ -128,7 +128,7 @@ src_vector(struct i915_fp_compile *p,
const struct tgsi_full_src_register *source)
{
uint index = source->SrcRegister.Index;
- uint src;
+ uint src, sem;
switch (source->SrcRegister.File) {
case TGSI_FILE_TEMPORARY:
@@ -151,6 +151,46 @@ src_vector(struct i915_fp_compile *p,
/* use vertex format info to map a slot number to a VF attrib */
assert(index < p->vertex_info->num_attribs);
+
+ sem = p->input_semantic[index];
+
+#if 1
+ switch (sem) {
+ case TGSI_SEMANTIC_POSITION:
+ printf("SKIP SEM POS\n");
+ /*
+ assert(p->wpos_tex != -1);
+ src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL);
+ */
+ break;
+ case TGSI_SEMANTIC_COLOR0:
+ src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL);
+ break;
+ case TGSI_SEMANTIC_COLOR1:
+ src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ);
+ src = swizzle(src, X, Y, Z, ONE);
+ break;
+ case TGSI_SEMANTIC_FOG:
+ src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W);
+ src = swizzle(src, W, W, W, W);
+ break;
+ case TGSI_SEMANTIC_TEX0:
+ case TGSI_SEMANTIC_TEX1:
+ case TGSI_SEMANTIC_TEX2:
+ case TGSI_SEMANTIC_TEX3:
+ case TGSI_SEMANTIC_TEX4:
+ case TGSI_SEMANTIC_TEX5:
+ case TGSI_SEMANTIC_TEX6:
+ case TGSI_SEMANTIC_TEX7:
+ src = i915_emit_decl(p, REG_TYPE_T,
+ T_TEX0 + (sem - TGSI_SEMANTIC_TEX0),
+ D0_CHANNEL_ALL);
+ break;
+ default:
+ i915_program_error(p, "Bad source->Index");
+ return 0;
+ }
+#else
index = p->vertex_info->slot_to_attrib[index];
switch (index) {
@@ -185,6 +225,7 @@ src_vector(struct i915_fp_compile *p,
i915_program_error(p, "Bad source->Index");
return 0;
}
+#endif
break;
case TGSI_FILE_CONSTANT:
@@ -220,9 +261,12 @@ src_vector(struct i915_fp_compile *p,
}
/* no abs() or post-abs negation */
+#if 0
+ /* XXX assertions disabled to allow arbfplight.c to run */
+ /* XXX enable these assertions, or fix things */
assert(!source->SrcRegisterExtMod.Absolute);
assert(!source->SrcRegisterExtMod.Negate);
-
+#endif
return src;
}
@@ -848,7 +892,15 @@ i915_translate_instructions(struct i915_fp_compile *p,
switch( parse.FullToken.Token.Type ) {
case TGSI_TOKEN_TYPE_DECLARATION:
- /* XXX no-op? */
+ if (parse.FullToken.FullDeclaration.Declaration.File
+ == TGSI_FILE_INPUT) {
+ /* save input register info for use in src_vector() */
+ uint ind, sem;
+ ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
+ sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
+ /*printf("FS Input DECL [%u] sem %u\n", ind, sem);*/
+ p->input_semantic[ind] = sem;
+ }
break;
case TGSI_TOKEN_TYPE_IMMEDIATE:
@@ -989,6 +1041,7 @@ i915_fini_compile(struct i915_context *i915, struct i915_fp_compile *p)
static void
i915_find_wpos_space(struct i915_fp_compile *p)
{
+#if 0
const uint inputs
= p->shader->inputs_read | (1 << TGSI_ATTRIB_POS); /*XXX hack*/
uint i;
@@ -1005,6 +1058,14 @@ i915_find_wpos_space(struct i915_fp_compile *p)
i915_program_error(p, "No free texcoord for wpos value");
}
+#else
+ if (p->shader->input_semantics[0] == TGSI_SEMANTIC_POSITION) {
+ /* frag shader using the fragment position input */
+#if 0
+ assert(0);
+#endif
+ }
+#endif
}
@@ -1018,13 +1079,17 @@ i915_find_wpos_space(struct i915_fp_compile *p)
static void
i915_fixup_depth_write(struct i915_fp_compile *p)
{
- if (p->shader->outputs_written & (1 << TGSI_ATTRIB_POS)) {
- uint depth = UREG(REG_TYPE_OD, 0);
+ /* XXX assuming depth is always in output[0] */
+ if (p->shader->output_semantics[0] == TGSI_SEMANTIC_DEPTH) {
+ const uint depth = UREG(REG_TYPE_OD, 0);
i915_emit_arith(p,
- A0_MOV,
- depth, A0_DEST_CHANNEL_W, 0,
- swizzle(depth, X, Y, Z, Z), 0, 0);
+ A0_MOV, /* opcode */
+ depth, /* dest reg */
+ A0_DEST_CHANNEL_W, /* write mask */
+ 0, /* saturate? */
+ swizzle(depth, X, Y, Z, Z), /* src0 */
+ 0, 0 /* src1, src2 */);
}
}
diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c
index 8d404c55ab..dece697497 100644
--- a/src/mesa/pipe/i915simple/i915_state_derived.c
+++ b/src/mesa/pipe/i915simple/i915_state_derived.c
@@ -33,6 +33,7 @@
#include "i915_state.h"
#include "i915_reg.h"
#include "i915_fpc.h"
+#include "pipe/tgsi/exec/tgsi_token.h"
/**
@@ -42,19 +43,71 @@
*/
static void calculate_vertex_layout( struct i915_context *i915 )
{
- const uint inputsRead = i915->fs->inputs_read;
+ const struct pipe_shader_state *fs = i915->fs;
const interp_mode colorInterp
= i915->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
struct vertex_info *vinfo = &i915->current.vertex_info;
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
boolean needW = 0;
+ uint i;
+ boolean texCoords[8];
+ memset(texCoords, 0, sizeof(texCoords));
memset(vinfo, 0, sizeof(*vinfo));
/* pos */
draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_3F, INTERP_LINEAR);
/* Note: we'll set the S4_VFMT_XYZ[W] bits below */
+ for (i = 0; i < fs->num_inputs; i++) {
+ switch (fs->input_semantics[i]) {
+ case TGSI_SEMANTIC_POSITION:
+ break;
+ case TGSI_SEMANTIC_COLOR0:
+ front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0,
+ FORMAT_4UB, colorInterp);
+ vinfo->hwfmt[0] |= S4_VFMT_COLOR;
+ break;
+ case TGSI_SEMANTIC_COLOR1:
+ assert(0); /* untested */
+ front1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1,
+ FORMAT_4UB, colorInterp);
+ vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG;
+ break;
+ case TGSI_SEMANTIC_TEX0:
+ case TGSI_SEMANTIC_TEX1:
+ case TGSI_SEMANTIC_TEX2:
+ case TGSI_SEMANTIC_TEX3:
+ case TGSI_SEMANTIC_TEX4:
+ case TGSI_SEMANTIC_TEX5:
+ case TGSI_SEMANTIC_TEX6:
+ case TGSI_SEMANTIC_TEX7:
+ {
+ const uint unit = fs->input_semantics[i] - TGSI_SEMANTIC_TEX0;
+ uint hwtc;
+ texCoords[unit] = TRUE;
+ draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_TEX0 + i,
+ FORMAT_4F, INTERP_PERSPECTIVE);
+ hwtc = TEXCOORDFMT_4D;
+ needW = TRUE;
+ vinfo->hwfmt[1] |= hwtc << (unit * 4);
+ }
+ break;
+ default:
+ assert(0);
+ }
+
+ }
+
+ /* finish up texcoord fields */
+ for (i = 0; i < 8; i++) {
+ if (!texCoords[i]) {
+ const uint hwtc = TEXCOORDFMT_NOT_PRESENT;
+ vinfo->hwfmt[1] |= hwtc << (i* 4);
+ }
+ }
+
+#if 0
/* color0 */
if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) {
front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0,
@@ -88,6 +141,7 @@ static void calculate_vertex_layout( struct i915_context *i915 )
vinfo->hwfmt[1] |= hwtc << ((i - TGSI_ATTRIB_TEX0) * 4);
}
}
+#endif
/* go back and fill in the vertex position info now that we have needW */
if (needW) {
@@ -104,11 +158,11 @@ static void calculate_vertex_layout( struct i915_context *i915 )
* the vertex header.
*/
if (i915->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);
}
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 1c0ab794f0..65001dfdf9 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -57,7 +57,8 @@ struct pipe_context {
const char *(*get_vendor)( struct pipe_context *pipe );
-
+ int (*get_param)( struct pipe_context *pipe, int param );
+
/*
* Drawing.
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
index b3ee890576..2a8109b10c 100644
--- a/src/mesa/pipe/p_defines.h
+++ b/src/mesa/pipe/p_defines.h
@@ -307,4 +307,11 @@
#define PIPE_QUERY_PRIMITIVES_EMITTED 2
#define PIPE_QUERY_TYPES 3
+
+/**
+ * Pipe capabilities/queries
+ */
+#define PIPE_PARAM_FS_NEEDS_POS 1
+
+
#endif
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index d2cc76a59b..6396d49b84 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -50,6 +50,8 @@
#define PIPE_MAX_COLOR_BUFS 8
#define PIPE_MAX_TEXTURE_LEVELS 16
#define PIPE_MAX_FEEDBACK_ATTRIBS 16
+#define PIPE_MAX_SHADER_INPUTS 16
+#define PIPE_MAX_SHADER_OUTPUTS 16
/* fwd decl */
@@ -140,13 +142,14 @@ struct pipe_constant_buffer {
struct pipe_shader_state {
- unsigned inputs_read; /**< TGSI_ATTRIB_ bits */
- unsigned outputs_written; /**< TGSI_ATTRIB_ bits */
const struct tgsi_token *tokens;
void *executable;
- uint num_inputs;
- uint num_outputs;
+ /** These fields somewhat constitute the shader "signature" */
+ ubyte num_inputs;
+ ubyte num_outputs;
+ ubyte input_semantics[PIPE_MAX_SHADER_INPUTS];
+ ubyte output_semantics[PIPE_MAX_SHADER_OUTPUTS];
};
struct pipe_depth_stencil_state
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);
}
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_build.c b/src/mesa/pipe/tgsi/exec/tgsi_build.c
index 20e4cf17f0..1320872c64 100755
--- a/src/mesa/pipe/tgsi/exec/tgsi_build.c
+++ b/src/mesa/pipe/tgsi/exec/tgsi_build.c
@@ -325,7 +325,7 @@ tgsi_build_declaration_semantic(
{
struct tgsi_declaration_semantic ds;
- assert( semantic_name <= TGSI_SEMANTIC_COLOR );
+ assert( semantic_name <= TGSI_SEMANTIC_COUNT );
assert( semantic_index <= 0xFFFF );
ds = tgsi_default_declaration_semantic();
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_dump.c b/src/mesa/pipe/tgsi/exec/tgsi_dump.c
index e6e99d9d75..0a47ad2a8c 100755
--- a/src/mesa/pipe/tgsi/exec/tgsi_dump.c
+++ b/src/mesa/pipe/tgsi/exec/tgsi_dump.c
@@ -202,13 +202,27 @@ static const char *TGSI_INTERPOLATES_SHORT[] =
static const char *TGSI_SEMANTICS[] =
{
"SEMANTIC_DEPTH",
- "SEMANTIC_COLOR"
+ "SEMANTIC_COLOR0",
+ "SEMANTIC_COLOR1",
+ "SEMANTIC_COLOR0B",
+ "SEMANTIC_COLOR1B",
+ "SEMANTIC_POSITION",
+ "SEMANTIC_FOG",
+ "SEMANTIC_OTHER,"
+ "SEMANTIC_TEX0",
};
static const char *TGSI_SEMANTICS_SHORT[] =
{
"DEPTH",
- "COLOR"
+ "COLOR0",
+ "COLOR1",
+ "COLOR0B",
+ "COLOR1B",
+ "POSITION",
+ "FOG",
+ "OTHER",
+ "TEX0"
};
static const char *TGSI_IMMS[] =
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_token.h b/src/mesa/pipe/tgsi/exec/tgsi_token.h
index ca53071a60..a642ba131a 100644
--- a/src/mesa/pipe/tgsi/exec/tgsi_token.h
+++ b/src/mesa/pipe/tgsi/exec/tgsi_token.h
@@ -73,11 +73,11 @@ struct tgsi_declaration
{
unsigned Type : 4; /* TGSI_TOKEN_TYPE_DECLARATION */
unsigned Size : 8; /* UINT */
- unsigned File : 4; /* TGSI_FILE_ */
- unsigned Declare : 4; /* TGSI_DECLARE_ */
- unsigned UsageMask : 4; /* TGSI_WRITEMASK_ */
- unsigned Interpolate : 1; /* BOOL */
- unsigned Semantic : 1; /* BOOL */
+ unsigned File : 4; /* one of TGSI_FILE_x */
+ unsigned Declare : 4; /* one of TGSI_DECLARE_x */
+ unsigned UsageMask : 4; /* bitmask of TGSI_WRITEMASK_x flags */
+ unsigned Interpolate : 1; /* BOOL, any interpolation info? */
+ unsigned Semantic : 1; /* BOOL, any semantic info? */
unsigned Padding : 5;
unsigned Extended : 1; /* BOOL */
};
@@ -103,12 +103,27 @@ struct tgsi_declaration_interpolation
unsigned Padding : 28;
};
-#define TGSI_SEMANTIC_DEPTH 0
-#define TGSI_SEMANTIC_COLOR 1
+#define TGSI_SEMANTIC_DEPTH 0
+#define TGSI_SEMANTIC_COLOR0 1
+#define TGSI_SEMANTIC_COLOR1 2
+#define TGSI_SEMANTIC_COLOR0B 3 /**< back-face primary color */
+#define TGSI_SEMANTIC_COLOR1B 4 /**< back-face secondary color */
+#define TGSI_SEMANTIC_POSITION 5
+#define TGSI_SEMANTIC_FOG 6
+#define TGSI_SEMANTIC_OTHER 7 /* XXX temp */
+#define TGSI_SEMANTIC_TEX0 8
+#define TGSI_SEMANTIC_TEX1 9
+#define TGSI_SEMANTIC_TEX2 10
+#define TGSI_SEMANTIC_TEX3 11
+#define TGSI_SEMANTIC_TEX4 12
+#define TGSI_SEMANTIC_TEX5 13
+#define TGSI_SEMANTIC_TEX6 14
+#define TGSI_SEMANTIC_TEX7 15
+#define TGSI_SEMANTIC_COUNT 16 /**< number of semantic values */
struct tgsi_declaration_semantic
{
- unsigned SemanticName : 8; /* TGSI_SEMANTIC_ */
+ unsigned SemanticName : 8; /* one of TGSI_SEMANTIC_ */
unsigned SemanticIndex : 16; /* UINT */
unsigned Padding : 8;
};
diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
index 1f8d937bc6..fb8365aab5 100644
--- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
+++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
@@ -3,9 +3,9 @@
#include "pipe/tgsi/exec/tgsi_attribs.h"
#include "pipe/tgsi/mesa/mesa_to_tgsi.h"
-#define TGSI_DEBUG 1
-
+#define TGSI_DEBUG 0
+#if 0
/**
* Convert a VERT_ATTRIB_x to a TGSI_ATTRIB_y
*/
@@ -209,9 +209,10 @@ tgsi_mesa_translate_fragment_output(GLuint attrib)
return 0;
}
}
+#endif
-#if 01
+#if 0
uint
tgsi_mesa_translate_vertex_input_mask(GLbitfield mask)
{
@@ -225,7 +226,6 @@ tgsi_mesa_translate_vertex_input_mask(GLbitfield mask)
}
return tgsiMask;
}
-#endif
uint
tgsi_mesa_translate_vertex_output_mask(GLbitfield mask)
@@ -271,6 +271,7 @@ tgsi_mesa_translate_fragment_output_mask(GLbitfield mask)
}
+#endif
@@ -319,12 +320,16 @@ map_register_file_index(
GLuint processor,
GLuint file,
GLuint index,
+#if 0
GLbitfield usage_bitmask,
+#endif
const GLuint inputMapping[],
const GLuint outputMapping[])
{
GLuint mapped_index;
+#if 0
GLuint i;
+#endif
assert(processor == TGSI_PROCESSOR_FRAGMENT
|| processor == TGSI_PROCESSOR_VERTEX);
@@ -345,7 +350,8 @@ map_register_file_index(
inputMapping[index]);
return inputMapping[index];
}
-
+ assert(0);
+#if 0
assert( usage_bitmask & (1 << index) );
mapped_index = 0;
for( i = 0; i < index; i++ ) {
@@ -354,6 +360,7 @@ map_register_file_index(
}
}
printf("Map %d input %d to %d\n", processor, index, mapped_index);
+#endif
break;
case TGSI_FILE_OUTPUT:
@@ -375,14 +382,17 @@ map_register_file_index(
else {
/* vertex output slots are tightly packed, find mapped pos */
/* mapped_index = VERT_RESULT_x */
+#if 0
mapped_index = 0;
for( i = 0; i < index; i++ ) {
if( usage_bitmask & (1 << i) ) {
mapped_index++;
}
}
- printf("Map VP output from %d to %d\n", index, mapped_index);
assert(outputMapping[index] == mapped_index);
+#endif
+ mapped_index = outputMapping[index];
+ printf("Map VP output from %d to %d\n", index, mapped_index);
}
break;
@@ -452,8 +462,10 @@ static GLboolean
compile_instruction(
const struct prog_instruction *inst,
struct tgsi_full_instruction *fullinst,
+#if 0
GLuint inputs_read,
GLuint outputs_written,
+#endif
const GLuint inputMapping[],
const GLuint outputMapping[],
GLuint preamble_size,
@@ -475,8 +487,14 @@ compile_instruction(
processor,
fulldst->DstRegister.File,
inst->DstReg.Index,
+#if 0
outputs_written,
+#endif
+#if 0
NULL,
+#else
+ inputMapping,
+#endif
outputMapping
);
fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask );
@@ -490,7 +508,9 @@ compile_instruction(
processor,
fullsrc->SrcRegister.File,
inst->SrcReg[i].Index,
+#if 0
inputs_read,
+#endif
inputMapping,
outputMapping );
@@ -766,10 +786,10 @@ compile_instruction(
static struct tgsi_full_declaration
make_frag_input_decl(
- GLuint first,
- GLuint last,
+ GLuint index,
GLuint interpolate,
- GLuint usage_mask )
+ GLuint usage_mask,
+ GLuint semantic_name )
{
struct tgsi_full_declaration decl;
@@ -777,9 +797,11 @@ make_frag_input_decl(
decl.Declaration.File = TGSI_FILE_INPUT;
decl.Declaration.Declare = TGSI_DECLARE_RANGE;
decl.Declaration.UsageMask = usage_mask;
+ decl.Declaration.Semantic = 1;
decl.Declaration.Interpolate = 1;
- decl.u.DeclarationRange.First = first;
- decl.u.DeclarationRange.Last = last;
+ decl.u.DeclarationRange.First = index;
+ decl.u.DeclarationRange.Last = index;
+ decl.Semantic.SemanticName = semantic_name;
decl.Interpolation.Interpolate = interpolate;
return decl;
@@ -809,15 +831,20 @@ make_frag_output_decl(
/**
* Convert Mesa fragment program to TGSI format.
- * \param inputMapping array to map original Mesa fragment program inputs
- * registers to TGSI generic input indexes
- * \param interpMode array[FRAG_ATTRIB_x] of TGSI_INTERPOLATE_LINEAR/PERSP.
+ * \param inputMapping maps Mesa fragment program inputs to TGSI generic
+ * input indexes
+ * \param inputSemantic the TGSI_SEMANTIC flag for each input
+ * \param interpMode the TGSI_INTERPOLATE_LINEAR/PERSP mode for each input
+ * \param outputMapping maps Mesa fragment program outputs to TGSI
+ * generic outputs
*
*/
GLboolean
tgsi_mesa_compile_fp_program(
const struct gl_fragment_program *program,
+ GLuint numInputs,
const GLuint inputMapping[],
+ const ubyte inputSemantic[],
const GLuint interpMode[],
const GLuint outputMapping[],
struct tgsi_token *tokens,
@@ -831,9 +858,9 @@ tgsi_mesa_compile_fp_program(
/*
struct tgsi_full_dst_register *fulldst;
struct tgsi_full_src_register *fullsrc;
- */
GLuint inputs_read;
GLboolean reads_wpos;
+ */
GLuint preamble_size = 0;
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();
@@ -846,6 +873,7 @@ tgsi_mesa_compile_fp_program(
ti = 3;
+#if 0
reads_wpos = program->Base.InputsRead & (1 << FRAG_ATTRIB_WPOS);
inputs_read = program->Base.InputsRead | (1 << FRAG_ATTRIB_WPOS);
@@ -857,9 +885,9 @@ tgsi_mesa_compile_fp_program(
if( reads_wpos ) {
fulldecl = make_frag_input_decl(
0,
- 0,
TGSI_INTERPOLATE_CONSTANT,
- TGSI_WRITEMASK_XY );
+ TGSI_WRITEMASK_XY,
+ TGSI_SEMANTIC_POSITION );
ti += tgsi_build_full_declaration(
&fulldecl,
&tokens[ti],
@@ -870,9 +898,9 @@ tgsi_mesa_compile_fp_program(
/* Fragment zw. */
fulldecl = make_frag_input_decl(
0,
- 0,
TGSI_INTERPOLATE_LINEAR,
- reads_wpos ? TGSI_WRITEMASK_ZW : TGSI_WRITEMASK_Z );
+ reads_wpos ? TGSI_WRITEMASK_ZW : TGSI_WRITEMASK_Z,
+ TGSI_SEMANTIC_POSITION );
ti += tgsi_build_full_declaration(
&fulldecl,
&tokens[ti],
@@ -884,15 +912,55 @@ tgsi_mesa_compile_fp_program(
if( inputs_read & (1 << i) ) {
count++;
fulldecl = make_frag_input_decl(count,
- count,
interpMode[i],
- TGSI_WRITEMASK_XYZW );
+ TGSI_WRITEMASK_XYZW,
+ inputSemantic[count] );
ti += tgsi_build_full_declaration(&fulldecl,
&tokens[ti],
header,
maxTokens - ti );
}
}
+#else
+
+ for (i = 0; i < numInputs; i++) {
+ switch (inputSemantic[i]) {
+ case TGSI_SEMANTIC_POSITION:
+ /* Fragment XY pos */
+ fulldecl = make_frag_input_decl(i,
+ TGSI_INTERPOLATE_CONSTANT,
+ TGSI_WRITEMASK_XY,
+ TGSI_SEMANTIC_POSITION );
+ ti += tgsi_build_full_declaration(
+ &fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
+ /* Fragment ZW pos */
+ fulldecl = make_frag_input_decl(i,
+ TGSI_INTERPOLATE_LINEAR,
+ TGSI_WRITEMASK_ZW,
+ TGSI_SEMANTIC_POSITION );
+ ti += tgsi_build_full_declaration(
+ &fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
+ break;
+ default:
+ fulldecl = make_frag_input_decl(i,
+ interpMode[i],
+ TGSI_WRITEMASK_XYZW,
+ inputSemantic[i] );
+ ti += tgsi_build_full_declaration(&fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
+ break;
+ }
+ }
+#endif
+
/*
* Declare output attributes.
@@ -914,7 +982,7 @@ tgsi_mesa_compile_fp_program(
if( program->Base.OutputsWritten & (1 << FRAG_RESULT_COLR) ) {
fulldecl = make_frag_output_decl(
1,
- TGSI_SEMANTIC_COLOR,
+ TGSI_SEMANTIC_COLOR0,
TGSI_WRITEMASK_XYZW );
ti += tgsi_build_full_declaration(
&fulldecl,
@@ -956,8 +1024,10 @@ tgsi_mesa_compile_fp_program(
if( compile_instruction(
&program->Base.Instructions[i],
&fullinst,
+#if 0
inputs_read,
~0, /*outputs_written*/
+#endif
inputMapping,
outputMapping,
preamble_size,
@@ -992,10 +1062,12 @@ tgsi_mesa_compile_vp_program(
struct tgsi_header *header;
struct tgsi_processor *processor;
struct tgsi_full_instruction fullinst;
+#if 0
GLuint inputs_read = ~0;
GLuint outputs_written;
outputs_written = program->Base.OutputsWritten;
+#endif
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();
@@ -1011,8 +1083,10 @@ tgsi_mesa_compile_vp_program(
if( compile_instruction(
&program->Base.Instructions[i],
&fullinst,
+#if 0
inputs_read,
outputs_written,
+#endif
inputMapping,
outputMapping,
0,
diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h
index 017cfce72e..8105e9e738 100644
--- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h
+++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h
@@ -10,7 +10,9 @@ struct tgsi_token;
GLboolean
tgsi_mesa_compile_fp_program(
const struct gl_fragment_program *program,
+ GLuint numInputs,
const GLuint inputMapping[],
+ const ubyte inputSemantic[],
const GLuint interpMode[],
const GLuint outputMapping[],
struct tgsi_token *tokens,