*/
static void setup_tri_coefficients( struct setup_stage *setup )
{
- const enum interp_mode *interp = setup->softpipe->vertex_info.interp_mode;
+ const enum interp_mode *interp;
#define USE_INPUT_MAP 01
#if USE_INPUT_MAP
const struct pipe_shader_state *fs = &setup->softpipe->fs->shader;
#endif
uint fragSlot;
+ if (setup->softpipe->vertex_info.format[0] == FORMAT_HEADER) {
+ /* skip header, pos slots */
+ interp = setup->softpipe->vertex_info.interp_mode + 2;
+ }
+ else {
+ /* skip pos slot */
+ interp = setup->softpipe->vertex_info.interp_mode + 1;
+ }
+
/* z and w are done by linear interpolation:
*/
tri_linear_coeff(setup, &setup->posCoef, 0, 2);
else {
#endif
uint j;
- switch (interp[vertSlot]) {
+ switch (interp[fragSlot]) {
case INTERP_CONSTANT:
for (j = 0; j < NUM_CHANNELS; j++)
const_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
#include "sp_state.h"
+static int
+find_vs_output(const struct pipe_shader_state *vs,
+ uint semantic_name,
+ uint semantic_index)
+{
+ uint i;
+ for (i = 0; i < vs->num_outputs; i++) {
+ if (vs->output_semantic_name[i] == semantic_name &&
+ vs->output_semantic_index[i] == semantic_index)
+ return i;
+ }
+ return -1;
+}
+
+
+
/**
* Determine which post-transform / pre-rasterization vertex attributes
* we need.
= softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
struct vertex_info *vinfo = &softpipe->vertex_info;
uint i;
+ int src;
memset(vinfo, 0, sizeof(*vinfo));
draw_emit_vertex_attr(vinfo, FORMAT_HEADER, INTERP_LINEAR, 0);
}
+ /* always emit pos for softpipe rasterization */
+ src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0);
+ assert(src >= 0);
+ draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR, src);
+
/*
* XXX I think we need to reconcile the vertex shader outputs with
* the fragment shader inputs here to make sure the slots line up.
* Or maybe do that in the state tracker?
*/
- for (i = 0; i < vs->num_outputs; i++) {
- switch (vs->output_semantic_name[i]) {
+ for (i = 0; i < fs->num_inputs; i++) {
+ switch (fs->input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
- draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR, i);
+ /* handled above */
break;
case TGSI_SEMANTIC_COLOR:
- if (vs->output_semantic_index[i] == 0) {
- draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, i);
- }
- else {
- assert(vs->output_semantic_index[i] == 1);
- draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, i);
- }
- break;
-
- case TGSI_SEMANTIC_BCOLOR:
- /* no-op */
+ src = find_vs_output(vs, TGSI_SEMANTIC_COLOR,
+ fs->input_semantic_index[i]);
+ assert(src >= 0);
+ draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src);
break;
case TGSI_SEMANTIC_FOG:
- draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE, i);
- break;
-
- case TGSI_SEMANTIC_PSIZE:
- /* XXX only emit if drawing points or front/back polygon mode
- * is point mode
- */
- softpipe->psize_slot
- = draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT, i);
+ src = find_vs_output(vs, TGSI_SEMANTIC_FOG, 0);
+#if 1
+ if (src < 0) /* XXX temp hack, try demos/fogcoord.c with this */
+ src = 0;
+#endif
+ assert(src >= 0);
+ draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src);
break;
case TGSI_SEMANTIC_GENERIC:
/* this includes texcoords and varying vars */
- draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, i);
+ src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC,
+ fs->input_semantic_index[i]);
+ assert(src >= 0);
+ draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src);
break;
default:
}
}
+ src = find_vs_output(vs, TGSI_SEMANTIC_PSIZE, 0);
+ if (src >= 0) {
+ softpipe->psize_slot = src;
+ draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_CONSTANT, src);
+ }
+
+
draw_compute_vertex_size(vinfo);
softpipe->nr_frag_attrs = fs->num_inputs;
*/
void softpipe_update_derived( struct softpipe_context *softpipe )
{
- if (softpipe->dirty & (SP_NEW_RASTERIZER | SP_NEW_FS))
+ if (softpipe->dirty & (SP_NEW_RASTERIZER | SP_NEW_FS | SP_NEW_VS))
calculate_vertex_layout( softpipe );
if (softpipe->dirty & (SP_NEW_SCISSOR |