[Mesa-dev] [PATCH 14/17] st/mesa: simplify the signature of get_client_array

Nicolai Hähnle nhaehnle at gmail.com
Wed May 3 15:57:44 UTC 2017


Patches 8 - 14:

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

On 01.05.2017 14:53, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>  src/mesa/state_tracker/st_atom_array.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atom_array.c b/src/mesa/state_tracker/st_atom_array.c
> index f873460..cc9cac1 100644
> --- a/src/mesa/state_tracker/st_atom_array.c
> +++ b/src/mesa/state_tracker/st_atom_array.c
> @@ -293,25 +293,23 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
>        break;
>     }
>
>     index = integer*2 + normalized;
>     assert(index <= 2);
>     assert(type >= GL_BYTE && type <= GL_FIXED);
>     return vertex_formats[type - GL_BYTE][index][size-1];
>  }
>
>  static const struct gl_vertex_array *
> -get_client_array(const struct st_vertex_program *vp,
> -                 const struct gl_vertex_array **arrays,
> -                 int attr)
> +get_client_array(const struct gl_vertex_array **arrays,
> +                 unsigned mesaAttr)
>  {
> -   const GLuint mesaAttr = vp->index_to_input[attr];
>     /* st_program uses 0xffffffff to denote a double placeholder attribute */
>     if (mesaAttr == ST_DOUBLE_ATTRIB_PLACEHOLDER)
>        return NULL;
>     return arrays[mesaAttr];
>  }
>
>  /**
>   * Examine the active arrays to determine if we have interleaved
>   * vertex arrays all living in one VBO, or all living in user space.
>   */
> @@ -324,21 +322,21 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
>     const struct gl_buffer_object *firstBufObj = NULL;
>     GLint firstStride = -1;
>     const GLubyte *firstPtr = NULL;
>     GLboolean userSpaceBuffer = GL_FALSE;
>
>     for (attr = 0; attr < num_inputs; attr++) {
>        const struct gl_vertex_array *array;
>        const struct gl_buffer_object *bufObj;
>        GLsizei stride;
>
> -      array = get_client_array(vp, arrays, attr);
> +      array = get_client_array(arrays, vp->index_to_input[attr]);
>        if (!array)
>  	 continue;
>
>        stride = array->StrideB; /* in bytes */
>        bufObj = array->BufferObj;
>        if (attr == 0) {
>           /* save info about the first array */
>           firstStride = stride;
>           firstPtr = array->Ptr;
>           firstBufObj = bufObj;
> @@ -460,35 +458,35 @@ setup_interleaved_attribs(struct st_context *st,
>     GLboolean usingVBO;      /* all arrays in a VBO? */
>     struct gl_buffer_object *bufobj;
>     GLsizei stride;
>
>     /* Find the lowest address of the arrays we're drawing,
>      * Init bufobj and stride.
>      */
>     if (num_inputs) {
>        const struct gl_vertex_array *array;
>
> -      array = get_client_array(vp, arrays, 0);
> +      array = get_client_array(arrays, vp->index_to_input[0]);
>        assert(array);
>
>        /* Since we're doing interleaved arrays, we know there'll be at most
>         * one buffer object and the stride will be the same for all arrays.
>         * Grab them now.
>         */
>        bufobj = array->BufferObj;
>        stride = array->StrideB;
>
>        low_addr = arrays[vp->index_to_input[0]]->Ptr;
>
>        for (attr = 1; attr < num_inputs; attr++) {
>           const GLubyte *start;
> -         array = get_client_array(vp, arrays, attr);
> +         array = get_client_array(arrays, vp->index_to_input[attr]);
>           if (!array)
>              continue;
>           start = array->Ptr;
>           low_addr = MIN2(low_addr, start);
>        }
>     }
>     else {
>        /* not sure we'll ever have zero inputs, but play it safe */
>        bufobj = NULL;
>        stride = 0;
> @@ -496,21 +494,21 @@ setup_interleaved_attribs(struct st_context *st,
>     }
>
>     /* are the arrays in user space? */
>     usingVBO = _mesa_is_bufferobj(bufobj);
>
>     for (attr = 0; attr < num_inputs;) {
>        const struct gl_vertex_array *array;
>        unsigned src_offset;
>        unsigned src_format;
>
> -      array = get_client_array(vp, arrays, attr);
> +      array = get_client_array(arrays, vp->index_to_input[attr]);
>        assert(array);
>
>        src_offset = (unsigned) (array->Ptr - low_addr);
>        assert(array->_ElementSize ==
>               _mesa_bytes_per_vertex_attrib(array->Size, array->Type));
>
>        src_format = st_pipe_vertex_format(array->Type,
>                                           array->Size,
>                                           array->Format,
>                                           array->Normalized,
> @@ -569,28 +567,28 @@ setup_non_interleaved_attribs(struct st_context *st,
>                                const struct gl_vertex_array **arrays,
>                                unsigned num_inputs)
>  {
>     struct gl_context *ctx = st->ctx;
>     struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
>     struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS] = {{0}};
>     unsigned num_vbuffers = 0;
>     GLuint attr;
>
>     for (attr = 0; attr < num_inputs;) {
> -      const GLuint mesaAttr = vp->index_to_input[attr];
> +      const unsigned mesaAttr = vp->index_to_input[attr];
>        const struct gl_vertex_array *array;
>        struct gl_buffer_object *bufobj;
>        GLsizei stride;
>        unsigned src_format;
>        unsigned bufidx;
>
> -      array = get_client_array(vp, arrays, attr);
> +      array = get_client_array(arrays, mesaAttr);
>        assert(array);
>
>        bufidx = num_vbuffers++;
>
>        stride = array->StrideB;
>        bufobj = array->BufferObj;
>        assert(array->_ElementSize ==
>               _mesa_bytes_per_vertex_attrib(array->Size, array->Type));
>
>        if (_mesa_is_bufferobj(bufobj)) {
>


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list