In the new Intel Iris driver, I am using Tim's new packed uniform
storage system. It works great, with one caveat: our scalar compiler
backend assumes that uniform offsets will be aligned to the underlying
data type. For example, doubles must be 64-bit aligned, floats 32-bit,
half-floats 16-bit, and so on. It does not need any other padding.
Currently, _mesa_add_parameter aligns everything to 32-bit offsets,
creating doubles that have an unaligned offset. This patch alters
that code to align doubles to 64-bit offsets.
This may be slightly less optimal for drivers which can support full
packing, and allow reads from unaligned offsets at no penalty. We could
make this extra alignment optional. However, it only comes into play
when intermixing double and single precision uniforms. Doubles are
already not too common, and intermixed values (floats then doubles)
is probably even less common. At most, we burn a single 32-bit slot
to the alignment, which is not that expensive. So, it doesn't seem
worthwhile to add the extra complexity.
Eventually, we'll likely want to update this code to allow half-float
values to be packed tighter than 32-bit offsets. At that point, we'll
probably want to revisit what drivers ultimately want, and add options.
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
{
assert(0 < size && size <=4);
const GLuint oldNum = paramList->NumParameters;
- unsigned oldValNum = pad_and_align ?
- align(paramList->NumParameterValues, 4) : paramList->NumParameterValues;
+ unsigned oldValNum = paramList->NumParameterValues;
+
+ if (pad_and_align)
+ oldValNum = align(oldValNum, 4); /* pad start to a vec4 boundary */
+ else if (_mesa_gl_datatype_is_64bit(datatype))
+ oldValNum = align(oldValNum, 2); /* pad start to 64-bit */
_mesa_reserve_parameter_storage(paramList, 1);