[Mesa-dev] [PATCH 3/3] st/mesa: add support for GL_ARB_texture_buffer_range

Brian Paul brian.e.paul at gmail.com
Sun Dec 16 09:15:57 PST 2012


On Sun, Dec 16, 2012 at 9:50 AM, Christoph Bumiller
<e0425955 at student.tuwien.ac.at> wrote:
> ---
>  src/mesa/state_tracker/st_atom_texture.c |   15 ++++++++++++++-
>  src/mesa/state_tracker/st_extensions.c   |    6 ++++++
>  2 files changed, 20 insertions(+), 1 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
> index dba1d82..bd2135f 100644
> --- a/src/mesa/state_tracker/st_atom_texture.c
> +++ b/src/mesa/state_tracker/st_atom_texture.c
> @@ -152,7 +152,20 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
>     u_sampler_view_default_template(&templ,
>                                     stObj->pt,
>                                     format);
> -   templ.u.tex.first_level = stObj->base.BaseLevel;
> +
> +   if (stObj->pt->target == PIPE_BUFFER) {
> +      unsigned f, n;
> +      const struct util_format_description *desc
> +         = util_format_description(templ.format);
> +
> +      f = (stObj->base.BufferOffset * 8 / desc->block.bits) * desc->block.width;
> +      n = (stObj->base.BufferSize * 8 / desc->block.bits) * desc->block.width;
> +
> +      templ.u.buf.first_element = f;
> +      templ.u.buf.last_element = f + (n ? (n - 1) : 0);
> +   } else {
> +      templ.u.tex.first_level = stObj->base.BaseLevel;
> +   }
>
>     if (swizzle != SWIZZLE_NOOP) {
>        templ.swizzle_r = GET_SWZ(swizzle, 0);
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index 262cc3d..60db753 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -670,7 +670,13 @@ void st_init_extensions(struct st_context *st)
>        ctx->Extensions.ARB_map_buffer_alignment = GL_TRUE;
>     }
>     if (screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OBJECTS)) {
> +      ctx->Const.TextureBufferOffsetAlignment =
> +         screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT);
> +
>        ctx->Extensions.ARB_texture_buffer_object = GL_TRUE;
> +      if (ctx->Const.TextureBufferOffsetAlignment)
> +         ctx->Extensions.ARB_texture_buffer_range = GL_TRUE;
> +
>        init_format_extensions(st, tbo_rgb32, Elements(tbo_rgb32),
>                               PIPE_BUFFER, PIPE_BIND_SAMPLER_VIEW);
>     }

Reviewed-by: Brian Paul <brianp at vmware.com>


More information about the mesa-dev mailing list