#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)
{
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.
*/
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;
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;
}
= _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;