[Mesa-dev] [PATCH 4/4] st/mesa: use _mesa_RasterPos() when possible

Roland Scheidegger sroland at vmware.com
Wed Oct 21 17:40:40 PDT 2015


Ahhh legacy functionality from hell...

For the series:
Reviewed-by: Roland Scheidegger <sroland at vmware.com>

I'm wondering if it would be possible to omit the rasterPos execution
completely, by incorporating it into drawPixels etc. at least in the
hopefully common case there's no state changes affecting the results in
between. Albeit I guess since the current raster pos needs to be always
maintained we'd need to maintain significant state in the case we'd need
to really evaluate it...


Roland

Am 22.10.2015 um 00:41 schrieb Brian Paul:
> The st_RasterPos() function goes to great pains to implement the
> rasterpos transformation.  It basically uses gallium's draw module to
> execute the vertex shader to draw a point, then capture that point's
> attributes.
> 
> But glRasterPos isn't typically used with a vertex shader so we can
> usually use the old/fixed-function implementation which is a lot simpler
> and faster.
> 
> This can add up for legacy apps that make a lot of calls to glRasterPos.
> ---
>  src/mesa/state_tracker/st_cb_rasterpos.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c
> index b9997da..747b414 100644
> --- a/src/mesa/state_tracker/st_cb_rasterpos.c
> +++ b/src/mesa/state_tracker/st_cb_rasterpos.c
> @@ -39,6 +39,7 @@
>  #include "main/imports.h"
>  #include "main/macros.h"
>  #include "main/feedback.h"
> +#include "main/rastpos.h"
>  
>  #include "st_context.h"
>  #include "st_atom.h"
> @@ -224,6 +225,15 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
>     struct rastpos_stage *rs;
>     const struct gl_client_array **saved_arrays = ctx->Array._DrawArrays;
>  
> +   if (ctx->VertexProgram._Current == NULL ||
> +       ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) {
> +      /* No vertex shader/program is enabled, used the simple/fast fixed-
> +       * function implementation of RasterPos.
> +       */
> +      _mesa_RasterPos(ctx, v);
> +      return;
> +   }
> +
>     if (st->rastpos_stage) {
>        /* get rastpos stage info */
>        rs = rastpos_stage(st->rastpos_stage);
> 



More information about the mesa-dev mailing list