[Mesa-dev] [PATCH 2/2] gallium : st_glsl_to_tgsi handles UBO

Fredrik Höglund fredrik at kde.org
Fri Dec 2 09:07:00 PST 2011


On Friday 02 December 2011, Vincent Lejeune wrote:
> ---
>  src/mesa/state_tracker/st_atom_constbuf.c  |    8 +++
>  src/mesa/state_tracker/st_extensions.c     |    4 +
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   92 ++++++++++++++--------------
>  3 files changed, 59 insertions(+), 45 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
> index 05667a7..8061347 100644
> --- a/src/mesa/state_tracker/st_atom_constbuf.c
> +++ b/src/mesa/state_tracker/st_atom_constbuf.c
> @@ -45,6 +45,8 @@
>  #include "st_atom_constbuf.h"
>  #include "st_program.h"
>  
> +#include "st_cb_bufferobjects.h"
> +
>  
>  /**
>   * Pass the given program parameters to the graphics pipe as a
> @@ -55,6 +57,7 @@ void st_upload_constants( struct st_context *st,
>                            struct gl_program_parameter_list *params,
>                            unsigned shader_type)
>  {
> +   unsigned i;
>     struct pipe_context *pipe = st->pipe;
>  
>     assert(shader_type == PIPE_SHADER_VERTEX ||
> @@ -100,6 +103,11 @@ void st_upload_constants( struct st_context *st,
>        st->state.constants[shader_type].size = 0;
>        st->pipe->set_constant_buffer(st->pipe, shader_type, 0, NULL);
>     }
> +
> +   for (i = 0; i < params->NumUBO; i++) {
> +      struct st_buffer_object* buf = st_buffer_object(st->ctx->UniformBufferObject.BindingPoint[i]);
> +      st->pipe->set_constant_buffer(st->pipe,shader_type,i+1,buf->buffer);
> +   }
>  }
>  
>  
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index c741d13..93f6bc6 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -670,4 +670,8 @@ void st_init_extensions(struct st_context *st)
>                                     PIPE_BIND_SAMPLER_VIEW))
>         ctx->Extensions.ARB_texture_rgb10_a2ui = GL_TRUE;
>  
> +#if FEATURE_ARB_uniform_buffer_object
> +   if (screen->get_param(screen,PIPE_SHADER_CAP_MAX_CONST_BUFFERS) > 1)
> +      ctx->Extensions.ARB_uniform_buffer_object = GL_TRUE;
> +#endif

As I pointed out on IRC, you are using the wrong function here. You should
be calling screen->get_shader_param().

When you pass PIPE_SHADER_CAP_MAX_CONST_BUFFERS to
pipe_screen::get_param(), you are actually quering the driver for
PIPE_CAP_MAX_RENDER_TARGETS.

Regards,
Fredrik



More information about the mesa-dev mailing list