summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2020-01-20 22:14:11 -0500
committerMarek Olšák <[email protected]>2020-02-14 18:16:27 -0500
commit61e4c582e0fe246ac0d494a2391573f63e1ee0dc (patch)
tree2fc4e259c0c59060647dc1c64af62cd8a99266fd /src/mesa
parent3c98dccd405cf57cbc5a8534e93d7ba020d0e055 (diff)
st/mesa: always inline the code setting non-64bit vertex elements
Reviewed-by: Mathias Fröhlich <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3829>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_array.c109
1 files changed, 63 insertions, 46 deletions
diff --git a/src/mesa/state_tracker/st_atom_array.c b/src/mesa/state_tracker/st_atom_array.c
index be1729311e2..bbbe0e236d3 100644
--- a/src/mesa/state_tracker/st_atom_array.c
+++ b/src/mesa/state_tracker/st_atom_array.c
@@ -50,7 +50,7 @@
#include "main/varray.h"
#include "main/arrayobj.h"
-static void init_velement(struct pipe_vertex_element *velement,
+static void set_velement(struct pipe_vertex_element *velement,
int src_offset, int format,
int instance_divisor, int vbo_index)
{
@@ -61,50 +61,67 @@ static void init_velement(struct pipe_vertex_element *velement,
assert(velement->src_format);
}
-static void init_velement_lowered(const struct st_vertex_program *vp,
- struct pipe_vertex_element *velements,
- const struct gl_vertex_format *vformat,
- int src_offset, int instance_divisor,
- int vbo_index, int idx)
+static void init_velement_64bit(const struct st_vertex_program *vp,
+ struct pipe_vertex_element *velements,
+ const struct gl_vertex_format *vformat,
+ int src_offset, int instance_divisor,
+ int vbo_index, int idx)
{
const GLubyte nr_components = vformat->Size;
-
- if (vformat->Doubles) {
- int lower_format;
-
- if (nr_components < 2)
- lower_format = PIPE_FORMAT_R32G32_UINT;
- else
- lower_format = PIPE_FORMAT_R32G32B32A32_UINT;
-
- init_velement(&velements[idx], src_offset,
- lower_format, instance_divisor, vbo_index);
- idx++;
-
- if (idx < vp->num_inputs &&
- vp->index_to_input[idx] == ST_DOUBLE_ATTRIB_PLACEHOLDER) {
- if (nr_components >= 3) {
- if (nr_components == 3)
- lower_format = PIPE_FORMAT_R32G32_UINT;
- else
- lower_format = PIPE_FORMAT_R32G32B32A32_UINT;
-
- init_velement(&velements[idx], src_offset + 4 * sizeof(float),
- lower_format, instance_divisor, vbo_index);
- } else {
- /* The values here are undefined. Fill in some conservative
- * dummy values.
- */
- init_velement(&velements[idx], src_offset, PIPE_FORMAT_R32G32_UINT,
- instance_divisor, vbo_index);
- }
+ int lower_format;
+
+ if (nr_components < 2)
+ lower_format = PIPE_FORMAT_R32G32_UINT;
+ else
+ lower_format = PIPE_FORMAT_R32G32B32A32_UINT;
+
+ set_velement(&velements[idx], src_offset,
+ lower_format, instance_divisor, vbo_index);
+ idx++;
+
+ if (idx < vp->num_inputs &&
+ vp->index_to_input[idx] == ST_DOUBLE_ATTRIB_PLACEHOLDER) {
+ if (nr_components >= 3) {
+ if (nr_components == 3)
+ lower_format = PIPE_FORMAT_R32G32_UINT;
+ else
+ lower_format = PIPE_FORMAT_R32G32B32A32_UINT;
+
+ set_velement(&velements[idx], src_offset + 4 * sizeof(float),
+ lower_format, instance_divisor, vbo_index);
+ } else {
+ /* The values here are undefined. Fill in some conservative
+ * dummy values.
+ */
+ set_velement(&velements[idx], src_offset, PIPE_FORMAT_R32G32_UINT,
+ instance_divisor, vbo_index);
}
- } else {
- init_velement(&velements[idx], src_offset, vformat->_PipeFormat,
- instance_divisor, vbo_index);
}
}
+/* Always inline the non-64bit element code, so that the compiler can see
+ * that velements is on the stack.
+ */
+static void ALWAYS_INLINE
+init_velement(const struct st_vertex_program *vp,
+ struct pipe_vertex_element *velements,
+ const struct gl_vertex_format *vformat,
+ int src_offset, int instance_divisor,
+ int vbo_index, int idx)
+{
+ if (!vformat->Doubles) {
+ velements[idx].src_offset = src_offset;
+ velements[idx].src_format = vformat->_PipeFormat;
+ velements[idx].instance_divisor = instance_divisor;
+ velements[idx].vertex_buffer_index = vbo_index;
+ assert(velements[idx].src_format);
+ return;
+ }
+
+ init_velement_64bit(vp, velements, vformat, src_offset, instance_divisor,
+ vbo_index, idx);
+}
+
/* ALWAYS_INLINE helps the compiler realize that most of the parameters are
* on the stack.
*/
@@ -163,9 +180,9 @@ st_setup_arrays(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->Format, off,
- binding->InstanceDivisor, bufidx,
- input_to_index[attr]);
+ init_velement(vp, velements, &attrib->Format, off,
+ binding->InstanceDivisor, bufidx,
+ input_to_index[attr]);
}
}
*has_user_vertex_buffers = uses_user_vertex_buffers;
@@ -205,8 +222,8 @@ st_setup_current(struct st_context *st,
if (alignment != size)
memset(cursor + size, 0, alignment - size);
- init_velement_lowered(vp, velements, &attrib->Format, cursor - data, 0,
- bufidx, input_to_index[attr]);
+ init_velement(vp, velements, &attrib->Format, cursor - data, 0,
+ bufidx, input_to_index[attr]);
cursor += alignment;
}
@@ -254,8 +271,8 @@ st_setup_current_user(struct st_context *st,
= _mesa_draw_current_attrib(ctx, attr);
const unsigned bufidx = (*num_vbuffers)++;
- init_velement_lowered(vp, velements, &attrib->Format, 0, 0,
- bufidx, input_to_index[attr]);
+ init_velement(vp, velements, &attrib->Format, 0, 0,
+ bufidx, input_to_index[attr]);
vbuffer[bufidx].is_user_buffer = true;
vbuffer[bufidx].buffer.user = attrib->Ptr;