diff options
author | Mathias Fröhlich <[email protected]> | 2018-11-17 07:13:11 +0100 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2018-11-21 06:27:19 +0100 |
commit | 0a7020b4e60ef69e0e4b38aee31bfce385e594d8 (patch) | |
tree | 64e68add5e2e22579c6ef715707c1dd99c1ecde1 /src/mesa/state_tracker | |
parent | 2da7b0a2fbf0dbc5e89f19622cf3bbfa346ed0f1 (diff) |
mesa: Factor out struct gl_vertex_format.
Factor out struct gl_vertex_format from array attributes.
The data type is supposed to describe the type of a vertex
element. At this current stage the data type is only used
with the VAO, but actually is useful in various other places.
Due to the bitfields being used, special care needs to be
taken for the glGet code paths.
v2: Change unsigned char -> GLubyte.
Use struct assignment for struct gl_vertex_format.
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom.h | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_array.c | 28 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_draw_feedback.c | 2 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 96e128d38cf..9f3ca38c191 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -55,7 +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(const struct gl_array_attributes *attrib); +st_pipe_vertex_format(const struct gl_vertex_format *glformat); /* 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 e4fc19eb5e2..19a5ef29a98 100644 --- a/src/mesa/state_tracker/st_atom_array.c +++ b/src/mesa/state_tracker/st_atom_array.c @@ -238,18 +238,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(const struct gl_array_attributes *attrib) +st_pipe_vertex_format(const struct gl_vertex_format *vformat) { - const GLubyte size = attrib->Size; - const GLenum16 format = attrib->Format; - const bool normalized = attrib->Normalized; - const bool integer = attrib->Integer; - GLenum16 type = attrib->Type; + const GLubyte size = vformat->Size; + const GLenum16 format = vformat->Format; + const bool normalized = vformat->Normalized; + const bool integer = vformat->Integer; + GLenum16 type = vformat->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)); + assert(vformat->_ElementSize == _mesa_bytes_per_vertex_attrib(size, type)); switch (type) { case GL_HALF_FLOAT_OES: @@ -320,13 +320,13 @@ static void init_velement(struct pipe_vertex_element *velement, static void init_velement_lowered(const struct st_vertex_program *vp, struct pipe_vertex_element *velements, - const struct gl_array_attributes *attrib, + const struct gl_vertex_format *vformat, int src_offset, int instance_divisor, int vbo_index, int idx) { - const GLubyte nr_components = attrib->Size; + const GLubyte nr_components = vformat->Size; - if (attrib->Doubles) { + if (vformat->Doubles) { int lower_format; if (nr_components < 2) @@ -357,7 +357,7 @@ static void init_velement_lowered(const struct st_vertex_program *vp, } } } else { - const unsigned format = st_pipe_vertex_format(attrib); + const unsigned format = st_pipe_vertex_format(vformat); init_velement(&velements[idx], src_offset, format, instance_divisor, vbo_index); @@ -447,7 +447,7 @@ st_update_array(struct st_context *st) const struct gl_array_attributes *const attrib = _mesa_draw_array_attrib(vao, attr); const GLuint off = _mesa_draw_attributes_relative_offset(attrib); - init_velement_lowered(vp, velements, attrib, off, + init_velement_lowered(vp, velements, &attrib->Format, off, binding->InstanceDivisor, bufidx, input_to_index[attr]); } @@ -468,14 +468,14 @@ st_update_array(struct st_context *st) const gl_vert_attrib attr = u_bit_scan(&curmask); const struct gl_array_attributes *const attrib = _mesa_draw_current_attrib(ctx, attr); - const unsigned size = attrib->_ElementSize; + const unsigned size = attrib->Format._ElementSize; const unsigned alignment = util_next_power_of_two(size); max_alignment = MAX2(max_alignment, alignment); memcpy(cursor, attrib->Ptr, size); if (alignment != size) memset(cursor + size, 0, alignment - size); - init_velement_lowered(vp, velements, attrib, cursor - data, 0, + init_velement_lowered(vp, velements, &attrib->Format, cursor - data, 0, bufidx, input_to_index[attr]); cursor += alignment; diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index eb05ac96696..11097b4cac6 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -212,7 +212,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); + velements[attr].src_format = st_pipe_vertex_format(&attrib->Format); assert(velements[attr].src_format); /* tell draw about this attribute */ |