[Mesa-dev] [PATCH 5/7] mesa: introduce MS variants of line width min/max/granularity

Ilia Mirkin imirkin at alum.mit.edu
Thu Sep 1 03:02:42 UTC 2016


On Wed, Aug 31, 2016 at 10:32 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 08/28/2016 07:10 PM, Ilia Mirkin wrote:
>> These are exposed in ES 3.2. However this moves all st/mesa to clamping
>> on the MS variants. But for now the MS variants are initialized to the
>> AA values.
>
> Do you know where these are in the spec?  I'm not familiar with these.

https://www.khronos.org/registry/gles/specs/3.2/es_spec_3.2.pdf page
361 section 13.6.4, Line Multisample Rasterization:

The supported [min, max] range of multisampled line widths, and the
width of evenly-spaced gradations within that range are
implementation-dependent and may be queried as
MULTISAMPLE_LINE_WIDTH_RANGE and MULTISAMPLE_LINE_WIDTH_GRANULARITY
respectively, as described in table 21.40.

Also see Appendix F.1 New Features:

Support for querying MULTISAMPLE_LINE_WIDTH_RANGE and
MULTISAMPLE_LINE_WIDTH_GRANULARITY (see section 13.6.4). Note that
these are different query and enum values than desktop GL’s
SMOOTH_LINE_WIDTH_*, which remain unsupported (Bug 13828).

>
>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>> ---
>>  src/mesa/drivers/dri/i965/brw_context.c     |  5 +++++
>>  src/mesa/main/context.c                     |  3 +++
>>  src/mesa/main/mtypes.h                      |  2 ++
>>  src/mesa/state_tracker/st_atom_rasterizer.c | 16 ++++++++++------
>>  src/mesa/state_tracker/st_extensions.c      |  1 +
>>  5 files changed, 21 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
>> index 888097d..b29df32 100644
>> --- a/src/mesa/drivers/dri/i965/brw_context.c
>> +++ b/src/mesa/drivers/dri/i965/brw_context.c
>> @@ -604,14 +604,19 @@ brw_initialize_context_constants(struct brw_context *brw)
>>
>>     ctx->Const.MinLineWidth = 1.0;
>>     ctx->Const.MinLineWidthAA = 1.0;
>> +   ctx->Const.MinLineWidthMS = 1.0;
>>     if (brw->gen >= 6) {
>>        ctx->Const.MaxLineWidth = 7.375;
>>        ctx->Const.MaxLineWidthAA = 7.375;
>> +      ctx->Const.MaxLineWidthMS = 7.375;
>>        ctx->Const.LineWidthGranularity = 0.125;
>> +      ctx->Const.LineWidthGranularityMS = 0.125;
>>     } else {
>>        ctx->Const.MaxLineWidth = 7.0;
>>        ctx->Const.MaxLineWidthAA = 7.0;
>> +      ctx->Const.MaxLineWidthMS = 7.0;
>>        ctx->Const.LineWidthGranularity = 0.5;
>> +      ctx->Const.LineWidthGranularityMS = 0.5;
>>     }
>>
>>     /* For non-antialiased lines, we have to round the line width to the
>> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
>> index f550b0c..f0a5d64 100644
>> --- a/src/mesa/main/context.c
>> +++ b/src/mesa/main/context.c
>> @@ -575,7 +575,10 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
>>     consts->MaxLineWidth = MAX_LINE_WIDTH;
>>     consts->MinLineWidthAA = MIN_LINE_WIDTH;
>>     consts->MaxLineWidthAA = MAX_LINE_WIDTH;
>> +   consts->MinLineWidthMS = MIN_LINE_WIDTH;
>> +   consts->MaxLineWidthMS = MAX_LINE_WIDTH;
>>     consts->LineWidthGranularity = (GLfloat) LINE_WIDTH_GRANULARITY;
>> +   consts->LineWidthGranularityMS = (GLfloat) LINE_WIDTH_GRANULARITY;
>>     consts->MaxClipPlanes = 6;
>>     consts->MaxLights = MAX_LIGHTS;
>>     consts->MaxShininess = 128.0;
>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>> index 2a93f29..a5bdf93 100644
>> --- a/src/mesa/main/mtypes.h
>> +++ b/src/mesa/main/mtypes.h
>> @@ -3451,7 +3451,9 @@ struct gl_constants
>>     GLfloat PointSizeGranularity;
>>     GLfloat MinLineWidth, MaxLineWidth;       /**< aliased */
>>     GLfloat MinLineWidthAA, MaxLineWidthAA;   /**< antialiased */
>> +   GLfloat MinLineWidthMS, MaxLineWidthMS;   /**< multisampled */
>>     GLfloat LineWidthGranularity;
>> +   GLfloat LineWidthGranularityMS;
>>
>>     GLuint MaxClipPlanes;
>>     GLuint MaxLights;
>> diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
>> index ca975aa..c364b07 100644
>> --- a/src/mesa/state_tracker/st_atom_rasterizer.c
>> +++ b/src/mesa/state_tracker/st_atom_rasterizer.c
>> @@ -226,10 +226,17 @@ static void update_raster_state( struct st_context *st )
>>                                   ctx->Point.MaxSize);
>>     }
>>
>> -   /* _NEW_LINE
>> -    */
>> +   /* _NEW_MULTISAMPLE */
>> +   raster->multisample = _mesa_is_multisample_enabled(ctx);
>> +
>> +   /* _NEW_LINE | _NEW_MULTISAMPLE */
>>     raster->line_smooth = ctx->Line.SmoothFlag;
>> -   if (ctx->Line.SmoothFlag) {
>> +   if (raster->multisample) {
>> +      raster->line_width = CLAMP(ctx->Line.Width,
>> +                                 ctx->Const.MinLineWidthMS,
>> +                                 ctx->Const.MaxLineWidthMS);
>> +   }
>> +   else if (ctx->Line.SmoothFlag) {
>>        raster->line_width = CLAMP(ctx->Line.Width,
>>                                   ctx->Const.MinLineWidthAA,
>>                                   ctx->Const.MaxLineWidthAA);
>> @@ -245,9 +252,6 @@ static void update_raster_state( struct st_context *st )
>>     /* GL stipple factor is in [1,256], remap to [0, 255] here */
>>     raster->line_stipple_factor = ctx->Line.StippleFactor - 1;
>>
>> -   /* _NEW_MULTISAMPLE */
>> -   raster->multisample = _mesa_is_multisample_enabled(ctx);
>> -
>>     /* _NEW_MULTISAMPLE | _NEW_BUFFERS */
>>     raster->force_persample_interp =
>>           !st->force_persample_in_shader &&
>> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
>> index f86a5a3..b8c3ece 100644
>> --- a/src/mesa/state_tracker/st_extensions.c
>> +++ b/src/mesa/state_tracker/st_extensions.c
>> @@ -121,6 +121,7 @@ void st_init_limits(struct pipe_screen *screen,
>>        _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_LINE_WIDTH));
>>     c->MaxLineWidthAA =
>>        _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_LINE_WIDTH_AA));
>> +   c->MaxLineWidthMS = c->MaxLineWidthAA;
>>
>>     c->MaxPointSize =
>>        _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_POINT_WIDTH));
>>
>


More information about the mesa-dev mailing list