Skip to content

iris: Fix a bug in the code to unsuballocate a resource for export, and simplify it

Kenneth Graunke requested to merge kwg/mesa:iris-suballoc-flush-resource into main

@daenzer mentioned on IRC the other night that attempting to export a resource not marked PIPE_BIND_SHARED is a bug. We were hitting that case with Piglit's ext_image_dma_buf_import/export-tex, which did:

  1. glTexStorage2D (make a texture, allocate storage, upload data)
  2. eglCreateImageKHR (turn the texture into an EGL image)
  3. eglExportDMABUFImageMESA (export it)

The first step suballocates the texture because we have no idea it'll be used externally at that moment. Previously, iris was following the radeonsi approach and transitioning it to a dedicated (non-suballocated) resource at step 3, when dri_query_image requests a handle. This is a bit painful as dri_query_image doesn't give us a context to work with, and we need one.

This series moves the transition point to step 2. eglCreateImageKHR calls pipe->flush_resource(), which already does some aux-disabling in preparation for sharing an image externally. Now, we also un-suballocate it there. This point in time has a context, so we don't need the whole "make a temporary context" stuff.

This seems to happen a bit more frequently, as it comes up in a couple extra EGL dmabuf Piglit tests. On the plus side, this testing exposed a simple bug: We had accidentally passed <x, y, z, l> instead of <l, x, y, z>. We fix that here too.

+@pzanoni

Merge request reports