From 13e885842a4b962cd02f57e140b348daf551dff3 Mon Sep 17 00:00:00 2001 From: Charmaine Lee Date: Wed, 12 Apr 2023 03:24:40 +0300 Subject: [PATCH] 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 Part-of: --- .../auxiliary/translate/translate_generic.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c index 097058aea36..c4213fb5de9 100644 --- a/src/gallium/auxiliary/translate/translate_generic.c +++ b/src/gallium/auxiliary/translate/translate_generic.c @@ -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; } }