diff options
author | Kenneth Graunke <[email protected]> | 2019-01-15 22:35:02 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-02-19 13:26:58 -0800 |
commit | f9c835eb56afc88a94b18052cbef001ae8a49031 (patch) | |
tree | ad182ff043cafa534fc212fe29e5b79280c869db /src/mesa | |
parent | 3c2c6bd1c7636793ccb5e25f05677ae02e0fdb47 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/program/prog_parameter.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index 2bc1b6db6eb..62f31f205af 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); |