summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/prog_statevars.c
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2010-02-04 19:23:09 +0100
committerRoland Scheidegger <[email protected]>2010-02-04 19:23:09 +0100
commit2c326e72664e65166c68b027b26aaf373f3be36d (patch)
tree936c473da596c90f7a649f25da93dc7a07d7157b /src/mesa/shader/prog_statevars.c
parent8091e73cc2142945c297191a9b746be71360ef26 (diff)
gallium: add point size clamp to implementation limits in vertex shader
The point size min/max registers (unused by mesa state tracker) were removed since most hardware couldn't do much with them. However, we don't want to have to rely on hw to do point size clamping correctly to implementation dependent limits, hence have to do that in the vertex shader. This should also solve a potential problem with (non-AA) points smaller than 1.0 which according to OGL still have size 1.0. Note that OGL point rendering is odd, in particular point sprites are rasterized differently to points. Some hardware might support those different modes, but in any case the different clamping values used for smooth/multisampled/sprite enabled points might help a bit for hw which rasterizes points the same as point sprites. Also tweak mesa's ff to vertex shader translation so don't have to clamp twice in case of point attenuation.
Diffstat (limited to 'src/mesa/shader/prog_statevars.c')
-rw-r--r--src/mesa/shader/prog_statevars.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c
index 058d4bbafb7..460ecd44a84 100644
--- a/src/mesa/shader/prog_statevars.c
+++ b/src/mesa/shader/prog_statevars.c
@@ -444,6 +444,61 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
value[3] = (GLfloat)(ctx->Fog.Density * ONE_DIV_SQRT_LN2);
return;
+ case STATE_POINT_SIZE_CLAMPED:
+ {
+ /* this includes implementation dependent limits, to avoid
+ * another potentially necessary clamp.
+ * Note: for sprites, point smooth (point AA) is ignored
+ * and we'll clamp to MinPointSizeAA and MaxPointSize, because we
+ * expect drivers will want to say their minimum for AA size is 0.0
+ * but for non-AA it's 1.0 (because normal points with size below 1.0
+ * need to get rounded up to 1.0, hence never disappear). GL does
+ * not specify max clamp size for sprites, other than it needs to be
+ * at least as large as max AA size, hence use non-AA size there.
+ */
+ GLfloat minImplSize;
+ GLfloat maxImplSize;
+ if (ctx->Point.PointSprite) {
+ minImplSize = ctx->Const.MinPointSizeAA;
+ maxImplSize = ctx->Const.MaxPointSize;
+ }
+ else if (ctx->Point.SmoothFlag || ctx->Multisample._Enabled) {
+ minImplSize = ctx->Const.MinPointSizeAA;
+ maxImplSize = ctx->Const.MaxPointSizeAA;
+ }
+ else {
+ minImplSize = ctx->Const.MinPointSize;
+ maxImplSize = ctx->Const.MaxPointSize;
+ }
+ value[0] = ctx->Point.Size;
+ value[1] = ctx->Point.MinSize >= minImplSize ? ctx->Point.MinSize : minImplSize;
+ value[2] = ctx->Point.MaxSize <= maxImplSize ? ctx->Point.MaxSize : maxImplSize;
+ value[3] = ctx->Point.Threshold;
+ }
+ return;
+ case STATE_POINT_SIZE_IMPL_CLAMP:
+ {
+ /* for implementation clamp only in vs */
+ GLfloat minImplSize;
+ GLfloat maxImplSize;
+ if (ctx->Point.PointSprite) {
+ minImplSize = ctx->Const.MinPointSizeAA;
+ maxImplSize = ctx->Const.MaxPointSize;
+ }
+ else if (ctx->Point.SmoothFlag || ctx->Multisample._Enabled) {
+ minImplSize = ctx->Const.MinPointSizeAA;
+ maxImplSize = ctx->Const.MaxPointSizeAA;
+ }
+ else {
+ minImplSize = ctx->Const.MinPointSize;
+ maxImplSize = ctx->Const.MaxPointSize;
+ }
+ value[0] = ctx->Point.Size;
+ value[1] = minImplSize;
+ value[2] = maxImplSize;
+ value[3] = ctx->Point.Threshold;
+ }
+ return;
case STATE_LIGHT_SPOT_DIR_NORMALIZED:
{
/* here, state[2] is the light number */
@@ -639,6 +694,9 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
return _NEW_TEXTURE;
case STATE_FOG_PARAMS_OPTIMIZED:
return _NEW_FOG;
+ case STATE_POINT_SIZE_CLAMPED:
+ case STATE_POINT_SIZE_IMPL_CLAMP:
+ return _NEW_POINT | _NEW_MULTISAMPLE;
case STATE_LIGHT_SPOT_DIR_NORMALIZED:
case STATE_LIGHT_POSITION:
case STATE_LIGHT_POSITION_NORMALIZED:
@@ -830,6 +888,12 @@ append_token(char *dst, gl_state_index k)
case STATE_FOG_PARAMS_OPTIMIZED:
append(dst, "fogParamsOptimized");
break;
+ case STATE_POINT_SIZE_CLAMPED:
+ append(dst, "pointSizeClamped");
+ break;
+ case STATE_POINT_SIZE_IMPL_CLAMP:
+ append(dst, "pointSizeImplClamp");
+ break;
case STATE_LIGHT_SPOT_DIR_NORMALIZED:
append(dst, "lightSpotDirNormalized");
break;