diff options
author | Roland Scheidegger <[email protected]> | 2016-11-12 22:47:22 +0100 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2016-11-21 20:02:53 +0100 |
commit | 7a55c436c64a8bb031c8823522cde8f3adc67d89 (patch) | |
tree | bcbd9bc3e93efa9aedd2ab4c48cb563f7c41eac8 /src/gallium/auxiliary/draw/draw_private.h | |
parent | 9aae167e9474b7c220cbc3f172a27c0b6bf9b20a (diff) |
draw: simplify vsplit elts code a bit
vsplit_get_base_idx explicitly returned idx 0 and set the ofbit
in case of overflow. We'd then check the ofbit and use idx 0 instead of
looking it up. This was necessary because DRAW_GET_IDX used to return
DRAW_MAX_FETCH_IDX and not 0 in case of overflows.
However, this is all unnecessary, we can just let DRAW_GET_IDX return 0
in case of overflow. In fact before bbd1e60198548a12be3405fc32dd39a87e8968ab
the code already did that, not sure why this particular bit was changed
(might have been one half of an attempt to get these indices to actual draw
shader execution - in fact I think this would make things less awkward, it
would require moving the eltBias handling to the shader as well).
Note there's other callers of DRAW_GET_IDX - those code paths however
explicitly do not handle index buffer overflows, therefore the overflow
value doesn't matter for them.
Also do some trivial simplification - for (unsigned) a + b, checking res < a
is sufficient for overflow detection, we don't need to check for res < b too
(similar for signed).
And an index buffer overflow check looked bogus - eltMax is the number of
elements in the index buffer, not the maximum element which can be fetched.
(Drop the start check against the idx buffer though, this is already covered
by end check and end < start).
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_private.h')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_private.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index a6aa6105264..030bb2cece6 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -489,11 +489,10 @@ void draw_update_viewport_flags(struct draw_context *draw); /** * Return index i from the index buffer. - * If the index buffer would overflow we return the - * maximum possible index. + * If the index buffer would overflow we return index 0. */ #define DRAW_GET_IDX(_elts, _i) \ - (((_i) >= draw->pt.user.eltMax) ? DRAW_MAX_FETCH_IDX : (_elts)[_i]) + (((_i) >= draw->pt.user.eltMax) ? 0 : (_elts)[_i]) /** * Return index of the given viewport clamping it @@ -515,7 +514,7 @@ draw_overflow_uadd(unsigned a, unsigned b, unsigned overflow_value) { unsigned res = a + b; - if (res < a || res < b) { + if (res < a) { res = overflow_value; } return res; |