[Mesa-dev] [PATCH 1/2] mesa: remove redundant modulus operation
Ian Romanick
idr at freedesktop.org
Tue May 23 22:07:31 UTC 2017
On 05/23/2017 05:01 AM, Timothy Arceri wrote:
> The if check above means we can only get here if size is less than 4.
> ---
> src/mesa/program/prog_parameter.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c
> index 44e680c..40bc47d 100644
> --- a/src/mesa/program/prog_parameter.c
> +++ b/src/mesa/program/prog_parameter.c
> @@ -260,23 +260,22 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
> struct gl_program_parameter *p = paramList->Parameters + oldNum + i;
> p->Name = strdup(name ? name : "");
> p->Type = type;
> p->Size = size;
> p->DataType = datatype;
> if (values) {
> if (size >= 4) {
> COPY_4V(paramList->ParameterValues[oldNum + i], values);
> } else {
> /* copy 1, 2 or 3 values */
> - GLuint remaining = size % 4;
> - assert(remaining < 4);
> - for (j = 0; j < remaining; j++) {
> + assert(size < 4);
> + for (j = 0; j < size; j++) {
> paramList->ParameterValues[oldNum + i][j].f = values[j].f;
> }
> /* fill in remaining positions with zeros */
> for (; j < 4; j++) {
> paramList->ParameterValues[oldNum + i][j].f = 0.0f;
> }
It might be interesting to see if just setting all four values to 0.0
before the copy produces better code. There are a bunch of different
micro optimizations possible depending on what GCC does.
Either way, this patch is
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> }
> values += 4;
> } else {
> /* silence valgrind */
>
More information about the mesa-dev
mailing list