i965: Work around incorrect usage of glDrawRangeElements in UE4
authorDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Mon, 25 May 2020 16:07:08 +0000 (19:07 +0300)
committerMarge Bot <eric+marge@anholt.net>
Tue, 9 Jun 2020 15:04:35 +0000 (15:04 +0000)
commita751051248d445c3d726a3eab8fc999b0876364e
treea197eb3dfb33a2849d2a9791f3d1b4909a7cd37a
parent487aa807bd1b70602fcb6fbdabd101d4cff7c07b
i965: Work around incorrect usage of glDrawRangeElements in UE4

Unreal Engine 4 has a bug in usage of glDrawRangeElements,
causing it to be called with a number of vertices in place
of "end" parameter (which specifies the maximum array index
contained in indices).

Since there is unknown amount of games affected and we
could not identify that a game is built with UE4 - we are
forced to make a blanket workaround, disregarding max_index
in range calculations. Fortunately all such calls look like:
  glDrawRangeElements(GL_TRIANGLES, 0, 3, 3, ...);
So we are able to narrow down this workaround.

This was uncovered after b684030c3a656ffdbc93581856034e0982db46fd
broke a bunch of UE4 games.

Cc: 20.1 <mesa-stable@lists.freedesktop.org>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2917
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5203>
src/mesa/drivers/dri/i965/brw_draw_upload.c