From: Kenneth Graunke Date: Wed, 16 Jan 2019 06:35:02 +0000 (-0800) Subject: mesa: Align doubles to a 64-bit starting boundary, even if packing. X-Git-Tag: upstream/19.3.0~9674 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9c835eb56afc88a94b18052cbef001ae8a49031;p=platform%2Fupstream%2Fmesa.git mesa: Align doubles to a 64-bit starting boundary, even if packing. 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 --- diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index 2bc1b6d..62f31f2 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -246,8 +246,12 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList, { 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);