aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw/draw_pipe_clip.c
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2017-07-08 00:14:35 +0200
committerRoland Scheidegger <[email protected]>2017-07-08 06:02:18 +0200
commit4db72852a16fc4a2a559255f9965e1d02e4f2b9c (patch)
treec1870ee4f833acadd2288f2befe9f641e2ea87e9 /src/gallium/auxiliary/draw/draw_pipe_clip.c
parentf728435e1f872af3efcd6b9215e8d722d35090cc (diff)
draw: handle more TGSI_SEMANTIC_COLOR indices
It could only handle indices 0/1, otherwise what happened was bad (accessing array out of bounds, no crash but kind of random). This is enough for the gl state tracker (primary/secondary color) but not enough for some other state trackers (d3d9 has no limits on the number of color interpolants). The complexity with color semantics are all due to the front/back mapping (2 outputs in the vs map to one input in the fs) so this isn't extended to indices > 1 - d3d9 has no use for back colors, therefore this isn't needed and still only 2 back colors can be handled correctly. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_pipe_clip.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_clip.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index cf2b41738bf..4cfa54b2e17 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -771,8 +771,9 @@ find_interp(const struct draw_fragment_shader *fs, int *indexed_interp,
int interp;
/* If it's gl_{Front,Back}{,Secondary}Color, pick up the mode
* from the array we've filled before. */
- if (semantic_name == TGSI_SEMANTIC_COLOR ||
- semantic_name == TGSI_SEMANTIC_BCOLOR) {
+ if ((semantic_name == TGSI_SEMANTIC_COLOR ||
+ semantic_name == TGSI_SEMANTIC_BCOLOR) &&
+ semantic_index < 2) {
interp = indexed_interp[semantic_index];
} else if (semantic_name == TGSI_SEMANTIC_POSITION ||
semantic_name == TGSI_SEMANTIC_CLIPVERTEX) {
@@ -851,7 +852,8 @@ clip_init_state(struct draw_stage *stage)
if (fs) {
for (i = 0; i < fs->info.num_inputs; i++) {
- if (fs->info.input_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
+ if (fs->info.input_semantic_name[i] == TGSI_SEMANTIC_COLOR &&
+ fs->info.input_semantic_index[i] < 2) {
if (fs->info.input_interpolate[i] != TGSI_INTERPOLATE_COLOR)
indexed_interp[fs->info.input_semantic_index[i]] = fs->info.input_interpolate[i];
}
@@ -881,6 +883,15 @@ clip_init_state(struct draw_stage *stage)
clipper->perspect_attribs[clipper->num_perspect_attribs] = i;
clipper->num_perspect_attribs++;
break;
+ case TGSI_INTERPOLATE_COLOR:
+ if (draw->rasterizer->flatshade) {
+ clipper->const_attribs[clipper->num_const_attribs] = i;
+ clipper->num_const_attribs++;
+ } else {
+ clipper->perspect_attribs[clipper->num_perspect_attribs] = i;
+ clipper->num_perspect_attribs++;
+ }
+ break;
default:
assert(interp == -1);
break;