mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-01 01:00:10 +01:00
freedreno/a6xx: Fix antichamber trace replay assert
This app is generating viewports with scale[0]==0, so that is not a good condition for testing viewport validity. It would result in skipping the only viewport, and ending up with gb x/y being ~0. Triggering an assert in the register builder. The main reason this was done previously was to avoid an assert in fd_calc_guardband(). Lets just flip it around and return 0x1ff on errors instead of asserting. This also makes it more consistent with the other error cases. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7628 Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26086>
This commit is contained in:
parent
b33aa7b01a
commit
b1fc5390c6
2 changed files with 9 additions and 8 deletions
|
|
@ -28,6 +28,9 @@
|
|||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* All 1's but don't overflow the GUARDBAND_CLIP_ADJ bitfields: */
|
||||
#define MAX_GB 0x1ff
|
||||
|
||||
static inline unsigned
|
||||
fd_calc_guardband(float offset, float scale, bool is_a3xx)
|
||||
{
|
||||
|
|
@ -57,13 +60,14 @@ fd_calc_guardband(float offset, float scale, bool is_a3xx)
|
|||
const float gb_adj = fminf(-gb_min_ndc, gb_max_ndc);
|
||||
|
||||
/* The viewport should always be contained in the guardband. */
|
||||
assert(gb_adj >= 1.0);
|
||||
if (gb_adj < 1.0)
|
||||
return MAX_GB;
|
||||
|
||||
/* frexp returns an unspecified value if given an infinite value, which
|
||||
* can happen if scale == 0.
|
||||
*/
|
||||
if (isinf(gb_adj))
|
||||
return 0x1ff;
|
||||
return MAX_GB;
|
||||
|
||||
/* Convert gb_adj to 3.6 floating point, rounding down since it's always
|
||||
* safe to make the guard band smaller (but not the other way around!).
|
||||
|
|
@ -85,11 +89,12 @@ fd_calc_guardband(float offset, float scale, bool is_a3xx)
|
|||
*/
|
||||
int gb_adj_exp;
|
||||
float gb_adj_mantissa = frexpf(gb_adj, &gb_adj_exp);
|
||||
assert(gb_adj_exp > 0);
|
||||
if (gb_adj_exp <= 0)
|
||||
return MAX_GB;
|
||||
|
||||
/* Round non-representable numbers down to the largest possible number. */
|
||||
if (gb_adj_exp > 8)
|
||||
return 0x1ff;
|
||||
return MAX_GB;
|
||||
|
||||
return ((gb_adj_exp - 1) << 6) |
|
||||
((unsigned)truncf(gb_adj_mantissa * (1 << 7)) - (1 << 6));
|
||||
|
|
|
|||
|
|
@ -459,10 +459,6 @@ fd_set_viewport_states(struct pipe_context *pctx, unsigned start_slot,
|
|||
for (unsigned i = 0; i < PIPE_MAX_VIEWPORTS; i++) {
|
||||
const struct pipe_viewport_state *vp = & ctx->viewport[i];
|
||||
|
||||
/* skip unused viewports: */
|
||||
if (vp->scale[0] == 0)
|
||||
continue;
|
||||
|
||||
unsigned gx = fd_calc_guardband(vp->translate[0], vp->scale[0], is3x);
|
||||
unsigned gy = fd_calc_guardband(vp->translate[1], vp->scale[1], is3x);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue