Commit 14588c07 authored by Kenneth Graunke's avatar Kenneth Graunke Committed by Dylan Baker

iris: Fix broken aux.possible/sampler_usages bitmask handling

For renderable surfaces, we allocate SURFACE_STATEs for each bit in
res->aux.possible_usages.  Sampler views use res->aux.sampler_usages.

When pinning buffers, we call surf_state_offset_for_aux() to calculate
the offset to the desired surface state.  surf_state_offset_for_aux()
took an aux_modes parameter, which should be one of those two fields.
However...it was not using that parameter.  It always used the broader
res->aux.possible_usages field directly.

One of the callers, update_clear_value(), was passing incorrect masks
for this parameter.  It iterated through the bits in order, using
u_bit_scan(), which destructively modifies the mask.  So each time we
called it, the count of bits before our selected mode was 0, which would
cause us to always update the SURFACE_STATE for ISL_AUX_USAGE_NONE,
rather than updating each in turn.  This was hidden by the earlier bug
where surf_state_offset_for_aux() ignored the parameter.

Fixes: 7339660e ("iris: Add aux.sampler_usages.")
Reviewed-by: Rafael Antognolli's avatarRafael Antognolli <rafael.antognolli@intel.com>
(cherry picked from commit 117a0368)
parent 973d58e9
......@@ -3999,7 +3999,7 @@ surf_state_offset_for_aux(struct iris_resource *res,
enum isl_aux_usage aux_usage)
{
return SURFACE_STATE_ALIGNMENT *
util_bitcount(res->aux.possible_usages & ((1 << aux_usage) - 1));
util_bitcount(aux_modes & ((1 << aux_usage) - 1));
}
static void
......@@ -4029,10 +4029,11 @@ update_clear_value(struct iris_context *ice,
struct iris_batch *batch,
struct iris_resource *res,
struct iris_state_ref *state,
unsigned aux_modes,
unsigned all_aux_modes,
struct isl_view *view)
{
UNUSED struct isl_device *isl_dev = &batch->screen->isl_dev;
UNUSED unsigned aux_modes = all_aux_modes;
/* We only need to update the clear color in the surface state for gen8 and
* gen9. Newer gens can read it directly from the clear color state buffer.
......@@ -4044,14 +4045,14 @@ update_clear_value(struct iris_context *ice,
while (aux_modes) {
enum isl_aux_usage aux_usage = u_bit_scan(&aux_modes);
surf_state_update_clear_value(batch, res, state, aux_modes, aux_usage);
surf_state_update_clear_value(batch, res, state, all_aux_modes,
aux_usage);
}
#elif GEN_GEN == 8
pipe_resource_reference(&state->res, NULL);
void *map = alloc_surface_states(ice->state.surface_uploader,
state, res->aux.possible_usages);
state, all_aux_modes);
while (aux_modes) {
enum isl_aux_usage aux_usage = u_bit_scan(&aux_modes);
fill_surface_state(isl_dev, map, res, &res->surf, view, aux_usage, 0, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment