translate: do not clamp element index in generic_run

The buffer max_index value in translate_generic struct is relevant for
indexed draw only. So do not clamp the element index in generic_run() as it
is called for non-indexed draw only.
This patch passes index_size to the common generic_run_one function
so index clamping is only performed when a non-zero index_size is specified.

This fixes a text selection bug with kitty terminal emulator running on ARM
when it falls back to the generic translate path for unsigned byte vertex
array.

cc: mesa-stable

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22568>
This commit is contained in:
Charmaine Lee
2023-04-12 03:24:40 +03:00
committed by Marge Bot
parent 5075e9f7c7
commit 13e885842a

View File

@@ -1,6 +1,6 @@
/**************************************************************************
*
* Copyright 2007 VMware, Inc.
* Copyright 2007-2023 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -589,7 +589,8 @@ generic_run_one(struct translate_generic *tg,
unsigned elt,
unsigned start_instance,
unsigned instance_id,
void *vert)
void *vert,
unsigned index_size)
{
unsigned nr_attrs = tg->nr_attrib;
unsigned attr;
@@ -613,8 +614,10 @@ generic_run_one(struct translate_generic *tg,
}
else {
index = elt;
/* clamp to avoid going out of bounds */
index = MIN2(index, tg->attrib[attr].max_index);
if (index_size > 0) {
/* clamp to avoid going out of bounds */
index = MIN2(index, tg->attrib[attr].max_index);
}
}
src = tg->attrib[attr].input_ptr +
@@ -664,7 +667,7 @@ generic_run_elts(struct translate *translate,
unsigned i;
for (i = 0; i < count; i++) {
generic_run_one(tg, *elts++, start_instance, instance_id, vert);
generic_run_one(tg, *elts++, start_instance, instance_id, vert, 4);
vert += tg->translate.key.output_stride;
}
}
@@ -682,7 +685,7 @@ generic_run_elts16(struct translate *translate,
unsigned i;
for (i = 0; i < count; i++) {
generic_run_one(tg, *elts++, start_instance, instance_id, vert);
generic_run_one(tg, *elts++, start_instance, instance_id, vert, 2);
vert += tg->translate.key.output_stride;
}
}
@@ -700,7 +703,7 @@ generic_run_elts8(struct translate *translate,
unsigned i;
for (i = 0; i < count; i++) {
generic_run_one(tg, *elts++, start_instance, instance_id, vert);
generic_run_one(tg, *elts++, start_instance, instance_id, vert, 1);
vert += tg->translate.key.output_stride;
}
}
@@ -718,7 +721,7 @@ generic_run(struct translate *translate,
unsigned i;
for (i = 0; i < count; i++) {
generic_run_one(tg, start + i, start_instance, instance_id, vert);
generic_run_one(tg, start + i, start_instance, instance_id, vert, 0);
vert += tg->translate.key.output_stride;
}
}