aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/i915simple
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-09-19 18:53:36 -0600
committerBrian <[email protected]>2007-09-19 18:53:59 -0600
commit37cf13ed9a429c755f121daa1776b1b30a985ab3 (patch)
tree8ae423c054011d6826024b173e1de892c8bed78e /src/mesa/pipe/i915simple
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/i915simple')
-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
4 files changed, 146 insertions, 11 deletions
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index 36372898ce6..715e1ef6563 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 84e4c5a6f36..5c4f2f90e98 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 32c5600496a..df8859bec82 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 8d404c55ab2..dece6974978 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);
}