[PATCH 06/20] glamor: Add infrastructure for generating shaders on the fly

Eric Anholt eric at anholt.net
Thu Mar 20 13:06:51 PDT 2014


Keith Packard <keithp at keithp.com> writes:

> This just adds a bunch of support code to construct shaders from
> 'facets', which bundle attributes needed for each layer of the
> rendering system. At this point, that includes only the primtive and
> the fill stuff.
>
> Signed-off-by: Keith Packard <keithp at keithp.com>

> diff --git a/glamor/glamor_transform.c b/glamor/glamor_transform.c
> new file mode 100644
> index 0000000..f5a6bb2
> --- /dev/null
> +++ b/glamor/glamor_transform.c

> +
> +    /* A tricky computation to find the right value for the two linear functions
> +     * that transform rendering coordinates to pixmap coordinates
> +     *
> +     *  pixmap_x = render_x + drawable->x + off_x
> +     *  pixmap_y = render_y + drawable->y + off_y
> +     *
> +     *  gl_x = pixmap_x * 2 / width - 1
> +     *  gl_y = pixmap_y * 2 / height - 1
> +     *
> +     *  gl_x = (render_x + drawable->x + off_x) * 2 / width - 1
> +     *
> +     *  gl_x = (render_x) * 2 / width + (drawable->x + off_x) * 2 / width - 1
> +     *
> +     * To get GL_POINTS drawn in the right spot, we need to adjust the
> +     * coordinates by 1/2 a pixel. This doesn't hurt rectangles at
> +     * all, so we just always do it. If we need to change someday, we
> +     * can add a parameter to this function

This comment is stale now that center_offset exists.

> +
> +    if (do_drawable_translate) {
> +        off_x += drawable->x;
> +        off_y += drawable->y;
> +    }
> +
> +    if (center_offset)
> +        center_adjust = 0.5f;
> +
> +    glUniform4f(matrix_uniform_location,
> +                scale_x, (off_x + center_adjust) * scale_x - 1.0f,
> +                scale_y, (off_y + center_adjust) * scale_y - 1.0f);
> +
> +    glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo_at(pixmap_priv, box_x, box_y),
> +                                      0, 0, w, h);
> +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140320/9cddb533/attachment.sig>


More information about the xorg-devel mailing list