gallium: introduce GLSL based interpolation rules. (v2)

This introduces an unspecified interpolation paramter that is only allowed for
color semantics, so a specified GLSL interpolation will override the ShadeModel
specified interpolation, but not vice-versa.

This fixes a lot of the interpolation tests in piglit.

v2: rename from unspecified to color

Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
Dave Airlie
2012-01-09 15:57:02 +00:00
parent 5a7c343352
commit 67e3cbf163
7 changed files with 19 additions and 6 deletions

View File

@@ -2371,6 +2371,10 @@ exec_declaration(struct tgsi_exec_machine *mach,
eval = eval_perspective_coef;
break;
case TGSI_INTERPOLATE_COLOR:
eval = mach->flatshade_color ? eval_constant_coef : eval_perspective_coef;
break;
default:
assert(0);
return;

View File

@@ -263,7 +263,7 @@ struct tgsi_exec_machine
const struct tgsi_interp_coef *InterpCoefs;
struct tgsi_exec_vector QuadPos;
float Face; /**< +1 if front facing, -1 if back facing */
bool flatshade_color;
/* Conditional execution masks */
uint CondMask; /**< For IF/ELSE/ENDIF */
uint LoopMask; /**< For BGNLOOP/ENDLOOP */

View File

@@ -117,7 +117,8 @@ const char *tgsi_interpolate_names[TGSI_INTERPOLATE_COUNT] =
{
"CONSTANT",
"LINEAR",
"PERSPECTIVE"
"PERSPECTIVE",
"COLOR"
};
const char *tgsi_primitive_names[PIPE_PRIM_MAX] =

View File

@@ -74,6 +74,7 @@ shade_quad(struct quad_stage *qs, struct quad_header *quad)
struct tgsi_exec_machine *machine = softpipe->fs_machine;
/* run shader */
machine->flatshade_color = softpipe->rasterizer->flatshade ? TRUE : FALSE;
return softpipe->fs_variant->run( softpipe->fs_variant, machine, quad );
}

View File

@@ -100,6 +100,9 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
case TGSI_INTERPOLATE_PERSPECTIVE:
interp = INTERP_PERSPECTIVE;
break;
case TGSI_INTERPOLATE_COLOR:
assert(fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_COLOR);
break;
default:
assert(0);
interp = INTERP_LINEAR;
@@ -111,8 +114,11 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
break;
case TGSI_SEMANTIC_COLOR:
if (softpipe->rasterizer->flatshade) {
interp = INTERP_CONSTANT;
if (fsInfo->input_interpolate[i] == TGSI_INTERPOLATE_COLOR) {
if (softpipe->rasterizer->flatshade)
interp = INTERP_CONSTANT;
else
interp = INTERP_PERSPECTIVE;
}
break;
}

View File

@@ -100,7 +100,8 @@ enum tgsi_file_type {
#define TGSI_INTERPOLATE_CONSTANT 0
#define TGSI_INTERPOLATE_LINEAR 1
#define TGSI_INTERPOLATE_PERSPECTIVE 2
#define TGSI_INTERPOLATE_COUNT 3
#define TGSI_INTERPOLATE_COLOR 3 /* special color case for smooth/flat */
#define TGSI_INTERPOLATE_COUNT 4
#define TGSI_CYLINDRICAL_WRAP_X (1 << 0)
#define TGSI_CYLINDRICAL_WRAP_Y (1 << 1)

View File

@@ -441,7 +441,7 @@ st_translate_interp(enum glsl_interp_qualifier glsl_qual, bool is_color)
switch (glsl_qual) {
case INTERP_QUALIFIER_NONE:
if (is_color)
return TGSI_INTERPOLATE_LINEAR;
return TGSI_INTERPOLATE_COLOR;
return TGSI_INTERPOLATE_PERSPECTIVE;
case INTERP_QUALIFIER_SMOOTH:
return TGSI_INTERPOLATE_PERSPECTIVE;