st/mesa: do vertex and fragment color clamping in shaders

For ARB_color_buffer_float. Most hardware can't do it and st/mesa is
the perfect place for a fallback.
The exceptions are:
- r500 (vertex clamp only)
- nv50 (both)
- nvc0 (both)
- softpipe (both)

We also have to take into account that r300 can do CLAMPED vertex colors only,
while r600 can do UNCLAMPED vertex colors only. The difference can be expressed
with the two new CAPs.
This commit is contained in:
Marek Olšák
2012-01-23 03:11:17 +01:00
parent c2e2b58a58
commit bc1c836938
22 changed files with 147 additions and 56 deletions

View File

@@ -83,6 +83,10 @@ update_fp( struct st_context *st )
memset(&key, 0, sizeof(key));
key.st = st;
/* _NEW_FRAG_CLAMP */
key.clamp_color = st->clamp_frag_color_in_shader &&
st->ctx->Color._ClampFragmentColor;
st->fp_variant = st_get_fp_variant(st, stfp, &key);
st_reference_fragprog(st, &st->fp, stfp);
@@ -141,6 +145,9 @@ update_vp( struct st_context *st )
st->ctx->Polygon.FrontMode != GL_FILL ||
st->ctx->Polygon.BackMode != GL_FILL));
key.clamp_color = st->clamp_vert_color_in_shader &&
st->ctx->Light._ClampVertexColor;
st->vp_variant = st_get_vp_variant(st, stvp, &key);
st_reference_vertprog(st, &st->vp, stvp);