Skip to content

ir3: Make const file allocations simpler, generic, and order independent, fix a hang with zero-instanced indirect draw uploading driver params

What does this MR do and why?

Each previous change of ir3_setup_const_state made sense alone, but all together now - it became a spaghetti. We had to call it each time before calculating the space left, the allocations were order dependent and some were shifting after each call.

The trigger for the refactor was the need to move VS driver params to the start of the const file, it wasn't nice to do with previous way of things.

Now, the consts allocation flow is as follows:

  1. Turnip/Freedreno allocates consts required by corresponding API, e.g. push const, inline uniforms, etc. Then passes ir3_const_allocations into IR3.
  2. ir3_setup_const_state allocates consts with non-negotiable size.
  3. IR3 lowerings afterwards allocate from the free space left.

The allocation order now doesn't matter, and it's easy to add new consts.

The only thing I'm not happy about is a verbosity of how const offsets are accessed now:

const_state->allocs.consts[IR3_CONST_ALLOC_UBO_RANGES].offset_vec4

vs

const_state->offsets.ubo

As for the hang fix - the GPU hang happened in the following case:

  • Indirect draw call with zero instances.
  • Due to being with zero instance - draw states are now applied.
  • Without draw states the constlen for VS is stale.
  • Apparently, the driver params uploaded by HW at CP_DRAW_INDIRECT_MULTI_1_DST_OFF offset are still attempted to be uploaded.
  • GPU doesn't like this and hang.

Fortunately, the hang happened only when offset exceeded 0x39, so even if constlen is 1, but CP_DRAW_INDIRECT_MULTI_1_DST_OFF == 0x39 - there is no hang.

So the solution is to move allocation of driver params for VS as early as possible, which for us is to after push consts.

This fixes a hang in "Disney Epic Mickey: Rebrushed" on A750/A740.

Merge request reports

Loading