[Mesa-dev] [PATCH] gallium: Use struct gl_array_attributes* as st_pipe_vertex_format argument.
Eric Engestrom
eric.engestrom at imgtec.com
Mon Mar 12 09:52:39 UTC 2018
On Monday, 2018-03-12 07:52:49 +0100, Mathias.Froehlich at gmx.net wrote:
> From: Mathias Fröhlich <mathias.froehlich at web.de>
>
> Hi Brian,
>
> As requested in the past review, change the argument
> of st_pipe_vertex_format to something more concise.
>
> Please review
> best
> Mathias
>
>
> Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
Looks good to me!
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
> ---
> src/mesa/state_tracker/st_atom.h | 3 +--
> src/mesa/state_tracker/st_atom_array.c | 25 +++++++++----------------
> src/mesa/state_tracker/st_draw_feedback.c | 7 +------
> 3 files changed, 11 insertions(+), 24 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
> index 68388a5674..2567ad30df 100644
> --- a/src/mesa/state_tracker/st_atom.h
> +++ b/src/mesa/state_tracker/st_atom.h
> @@ -55,8 +55,7 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
> GLuint st_compare_func_to_pipe(GLenum func);
>
> enum pipe_format
> -st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
> - GLboolean normalized, GLboolean integer);
> +st_pipe_vertex_format(const struct gl_array_attributes *attrib);
>
>
> /* Define ST_NEW_xxx_INDEX */
> diff --git a/src/mesa/state_tracker/st_atom_array.c b/src/mesa/state_tracker/st_atom_array.c
> index ff7a5d0746..2fd67e8d84 100644
> --- a/src/mesa/state_tracker/st_atom_array.c
> +++ b/src/mesa/state_tracker/st_atom_array.c
> @@ -237,13 +237,18 @@ static const uint16_t vertex_formats[][4][4] = {
> * Return a PIPE_FORMAT_x for the given GL datatype and size.
> */
> enum pipe_format
> -st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
> - GLboolean normalized, GLboolean integer)
> +st_pipe_vertex_format(const struct gl_array_attributes *attrib)
> {
> + const GLubyte size = attrib->Size;
> + const GLenum16 format = attrib->Format;
> + const bool normalized = attrib->Normalized;
> + const bool integer = attrib->Integer;
> + GLenum16 type = attrib->Type;
> unsigned index;
>
> assert(size >= 1 && size <= 4);
> assert(format == GL_RGBA || format == GL_BGRA);
> + assert(attrib->_ElementSize == _mesa_bytes_per_vertex_attrib(size, type));
>
> switch (type) {
> case GL_HALF_FLOAT_OES:
> @@ -532,14 +537,8 @@ setup_interleaved_attribs(struct st_context *st,
> ptr = _mesa_vertex_attrib_address(attrib, binding);
>
> src_offset = (unsigned) (ptr - low_addr);
> - assert(attrib->_ElementSize ==
> - _mesa_bytes_per_vertex_attrib(attrib->Size, attrib->Type));
>
> - src_format = st_pipe_vertex_format(attrib->Type,
> - attrib->Size,
> - attrib->Format,
> - attrib->Normalized,
> - attrib->Integer);
> + src_format = st_pipe_vertex_format(attrib);
>
> init_velement_lowered(vp, velements, src_offset, src_format,
> binding->InstanceDivisor, 0,
> @@ -623,8 +622,6 @@ setup_non_interleaved_attribs(struct st_context *st,
> attrib = array->VertexAttrib;
> stride = binding->Stride;
> bufobj = binding->BufferObj;
> - assert(attrib->_ElementSize ==
> - _mesa_bytes_per_vertex_attrib(attrib->Size, attrib->Type));
>
> if (_mesa_is_bufferobj(bufobj)) {
> /* Attribute data is in a VBO.
> @@ -688,11 +685,7 @@ setup_non_interleaved_attribs(struct st_context *st,
> /* common-case setup */
> vbuffer[bufidx].stride = stride; /* in bytes */
>
> - src_format = st_pipe_vertex_format(attrib->Type,
> - attrib->Size,
> - attrib->Format,
> - attrib->Normalized,
> - attrib->Integer);
> + src_format = st_pipe_vertex_format(attrib);
>
> init_velement_lowered(vp, velements, 0, src_format,
> binding->InstanceDivisor, bufidx,
> diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
> index 46a12848c0..fa96b4e2e2 100644
> --- a/src/mesa/state_tracker/st_draw_feedback.c
> +++ b/src/mesa/state_tracker/st_draw_feedback.c
> @@ -240,12 +240,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
> vbuffers[attr].stride = binding->Stride; /* in bytes */
> velements[attr].instance_divisor = 0;
> velements[attr].vertex_buffer_index = attr;
> - velements[attr].src_format =
> - st_pipe_vertex_format(attrib->Type,
> - attrib->Size,
> - attrib->Format,
> - attrib->Normalized,
> - attrib->Integer);
> + velements[attr].src_format = st_pipe_vertex_format(attrib);
> assert(velements[attr].src_format);
>
> /* tell draw about this attribute */
> --
> 2.14.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list