i965: Fix can_cut_index_handle_restart_index() for byte/short types. 95/6795/1
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 25 May 2013 17:17:32 +0000 (10:17 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 29 May 2013 21:22:08 +0000 (14:22 -0700)
commit49aba27973d81e388bef49a79391d5fdef3f5f18
tree6ed1c8ed7ff4d9084f093095b92cf44793a90b53
parent7c87a3b5dac118697a9b67caa7b6d5cab60f316d
i965: Fix can_cut_index_handle_restart_index() for byte/short types.

Pre-Haswell hardware doesn't support an arbitrary restart index, and
instead compares the index buffer value against 0xFF for byte-size
buffers, 0xFFFF for short-size buffers, or 0xFFFFFFFF for unsigned
integer buffers.

OpenGL allows the restart index to be an arbitrary unsigned integer.
When comparing against byte/short types, the index buffer value should
be promoted to a full 32-bit integer before doing the comparison.  The
restart index is /not/ supposed to be masked to byte/short size.

This means that with certain restart indexes, the comparison should
always fail.  For example, a restart index of 0xF000FFFF should never
match any byte/short index buffer values due to the extra high bits.

We must not enable hardware primitive restart in such a case.  For now,
fall back to software primitive restart as it's the simplest fix.  In
the future, we could detect restart indexes that will never match and
skip both hardware and software primitive restart.

NOTE: This is a candidate for stable branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/brw_primitive_restart.c