swr/rast: Fix index buffer overfetch issue for non-indexed draws

Populate pLastIndex, even for the non-indexed case.  An zero pLastIndex
can cause the index offsets inside the fetcher to have non-sensical values
that can be either very large positive or very large negative numbers.

cc: "18.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>

(cherry picked from commit 539de78633)
[George Kyriazis: patch is a backport for 18.0 of the cherry-pick above]
This commit is contained in:
George Kyriazis 2018-02-28 13:16:16 -06:00 committed by Emil Velikov
parent 682a859dbe
commit 3a9454f9d4

View file

@ -1724,6 +1724,21 @@ void ProcessDraw(
if (i < endVertex)
{
if (!IsIndexedT::value)
{
fetchInfo_lo.pLastIndex = fetchInfo_lo.pIndices;
uint32_t offset;
offset = std::min(endVertex-i, (uint32_t) KNOB_SIMD16_WIDTH);
#if USE_SIMD16_SHADERS
fetchInfo_lo.pLastIndex += offset;
#else
fetchInfo_lo.pLastIndex += std::min(offset, (uint32_t) KNOB_SIMD_WIDTH);
uint32_t offset2 = std::min(offset, (uint32_t) KNOB_SIMD16_WIDTH)-KNOB_SIMD_WIDTH;
assert(offset >= 0);
fetchInfo_hi.pLastIndex = fetchInfo_hi.pIndices;
fetchInfo_hi.pLastIndex += offset2;
#endif
}
// 1. Execute FS/VS for a single SIMD.
AR_BEGIN(FEFetchShader, pDC->drawId);
#if USE_SIMD16_SHADERS