platform/upstream/mesa.git
3 years agoradv: make sure to load the Primitive ID for VS+GS as NGG
Samuel Pitoiset [Thu, 30 Sep 2021 11:24:55 +0000 (13:24 +0200)]
radv: make sure to load the Primitive ID for VS+GS as NGG

When the VS doesn't export the Primitive ID but the FS needs it.

Fixes dEQP-VK.pipeline.framebuffer_attachment.no_attachments*.

Fixes: 7ad69e2f7ee ("radv: stop loading invocation ID for NGG vertex shaders")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13116>

3 years agoiris: Suballocate BO using the Gallium pb_slab mechanism
Kenneth Graunke [Sun, 8 Aug 2021 06:00:44 +0000 (23:00 -0700)]
iris: Suballocate BO using the Gallium pb_slab mechanism

With all the preparation in place to handle suballocated BOs at
submission and export, we can now wire up the actual suballocator.
We use Gallium's pb_slab infrastructure for this, which is already
used for this purpose in the amdgpu winsys and now zink as well.

Unlike those drivers, we don't use pb_buffer (it doesn't do much) nor
pb_cache (we already have a buffer cache).  Just pb_slab for now.

We can now suballocate BOs at power-of-two (or 3/4 power-of-two)
granularity, between 256B and 2MB.  Beyond that, we use actual GEM
objects as before.  This should save us some memory on current GPUs
where we previously had a minimum allocation granularity of 4K (page
size), but should save us a /ton/ of memory on future GPUs where the
minimum page size is 64K.  Fewer actual GEM objects should also mean
shorter exec_object2 lists passed to the kernel, which could reduce
CPU overhead a bit.  Using large allocations where the underlying
GEM objects correspond with the PTE fragment size may also allow the
kernel to use a more efficient page table layout, improving memory
access times.

This cuts nearly half of the memory usage in a Unity3D demo on a
GPU that uses 64K pages.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4722

Acked-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12623>

3 years agoiris: Move suballocated resources to a dedicated allocation on export
Kenneth Graunke [Thu, 16 Sep 2021 18:38:03 +0000 (11:38 -0700)]
iris: Move suballocated resources to a dedicated allocation on export

We don't want to export suballocated resources to external consumers,
for a variety of reasons.  First of all, it would be exporting random
other pieces of memory which we may not want those external consumers
to have access to.  Secondly, external clients wouldn't be aware of
what buffers are packed together and busy-tracking implications there.
Nor should they be.  And those are just the obvious reasons.

When we allocate a resource with the PIPE_BIND_SHARED flag, indicating
that it's going to be used externally, we avoid suballocation.

However, there are times when the client may suddenly decide to export
a texture or buffer, without any prior warning.  Since we had no idea
this buffer would be exported, we suballocated it.  Unfortunately, this
means we need to transition it to a dedicated allocation on the fly, by
allocating a new buffer and copying the contents over.

Making things worse, this often happens in DRI hooks that don't have an
associated context (which we need to say, run BLORP commands).  We have
to create an temporary context for this purpose, perform our blit, then
destroy it.  The radeonsi driver uses a permanent auxiliary context
stored in the screen for this purpose, but we can't do that because it
causes circular reference counting.  radeonsi doesn't do the reference
counting that we do, but also doesn't use u_transfer_helper, so they
get lucky in avoiding stale resource->screen pointers.  Other drivers
don't create an auxiliary context, so they avoid this problem for now.

For auxiliary data, rather than copying it over bit-for-bit, we simply
copy over the underlying data using iris_copy_region (GPU memcpy), and
take whatever the resulting aux state is from that operation.  Assuming
the copy operation compresses, the result will be compressed.

v2: Stop using a screen->aux_context and just invent one on the fly to
    avoid circular reference counting issues.

Acked-by: Paulo Zanoni <paulo.r.zanoni@intel.com> [v1]
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12623>

3 years agoiris: Change the validation list debug code to print the BO list instead
Kenneth Graunke [Sun, 8 Aug 2021 08:48:27 +0000 (01:48 -0700)]
iris: Change the validation list debug code to print the BO list instead

This code assumed that batch->exec_bos[i] matched validation_list[i],
which won't be true once we start suballocating BOs.  This patch changes
it to print the full exec_bos[i] list instead of the validation list,
as that has the logical list of objects, names, addresses, placement,
whether they are suballocated, and so on.

It may be useful to look at the actual validation list as well; I'm not
sure how common that is.  We may want to add additional debug prints in
the future.

Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12623>

3 years agoiris: Introduce a BO_ALLOC_NO_SUBALLOC flag and set it in a few places
Kenneth Graunke [Sun, 8 Aug 2021 08:31:30 +0000 (01:31 -0700)]
iris: Introduce a BO_ALLOC_NO_SUBALLOC flag and set it in a few places

We don't want to suballocate some buffers, such as ones that we know
we're intending to export to other clients, or ones with special
semantics (such as the workaround BO not having proper synchronization).

Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12623>

3 years agoiris: Begin handling slab-allocated wrapper BOs in various places
Kenneth Graunke [Thu, 5 Aug 2021 06:42:45 +0000 (23:42 -0700)]
iris: Begin handling slab-allocated wrapper BOs in various places

The vast majority of cases need no handling at all, as they simply
read bo->address or similar fields, which works in either case.

Some other cases simply need to unwrap to look at the underlying BO.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12623>

3 years agoiris: Handle multiple BOs backed by the same GEM object in execbuf code
Kenneth Graunke [Wed, 4 Aug 2021 18:22:45 +0000 (11:22 -0700)]
iris: Handle multiple BOs backed by the same GEM object in execbuf code

With suballocation, our batch BO list may have multiple BOs that are
suballocated from the same GEM object.  We still need to track each of
those buffers for cross-batch write tracking, cache tracking, and busy
tracking.  However, we only want to include underlying GEM objects in
the actual validation list building.  The validation list entry should
have EXEC_OBJECT_WRITE if any of the BOs are marked as writable.

We use a temporary array to map GEM handles to validation list entries
so we can quickly see if we've already emitted one and update the
EXEC_OBJECT_WRITE flag as needed.

Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12623>

3 years agoiris: Move some iris_bo entries into a union
Kenneth Graunke [Tue, 20 Jul 2021 05:46:45 +0000 (22:46 -0700)]
iris: Move some iris_bo entries into a union

We would like to start performing slab allocation of resources, where
multiple resources can be backed by a single GEM object.

Originally, I had thought to move busy tracking, cache domain tracking,
and so on into resources themselves, instead of having them at the BO
level.  Multiple resources would point at the same BO with an offset.
Unfortunately, this meant adjusting the batch BO pinning code to take
resources rather than BOs.  That cascades into needing iris_address
for genxml packing to store resources, not BOs.  Which means that places
which have use raw BOs would need to start creating resources instead.
Except some places, like aux BO handling, really don't make sense as
pipe resources and really would rather use raw BOs.  So iris_address
would need to store both, which convolutes the genxml field.  And,
having a BO and resource means that every place in the code needs to
handle that offset correctly.  It sounds simple, but is a giant mess.

Instead, we take a different route: adjust iris_bo itself, so that BOs
are either be backed by a GEM object (as is the case today), or backed
by another underlying BO.  "Real" BOs have bo->gem_handle != 0.  "Slab
allocated" or "fake" or "wrapper" BOs have bo->gem_handle == 0.  We move
fields into a union based on these cases.  amdgpu takes this approach.

This sounds complex at first glance---in theory, every place that
interacts with BOs might need to handle the wrapper BO special case.
But in practice, they don't.  For suballocated BOs, we can set the
wrapper's address field to the underlying BO's address plus any offset,
at which point it looks like any other BO.  Most other properties are
easily queried; the main code that needs updating is execbuf handling
and bufmgr internals.

For now, we simply move the fields.  Any code that accesses either
bo->real.* or bo->gem_handle will need updating in future patches to
actually handle the slab-allocated case.

Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12623>

3 years agogbm: assume USE_SCANOUT in create_with_modifiers
Simon Ser [Fri, 27 Aug 2021 13:03:39 +0000 (15:03 +0200)]
gbm: assume USE_SCANOUT in create_with_modifiers

gbm_{bo,surface}_create_with_modifiers doesn't allow callers to
pass usage flags. Assume USE_SCANOUT since this is what most
callers want.

Bump the GBM ABI version so that other backends can discover when
the usage flags can be used.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: James Jones <jajones@nvidia.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3197>

3 years agogbm: add gbm_{bo,surface}_create_with_modifiers2
Simon Ser [Sun, 22 Dec 2019 20:46:57 +0000 (21:46 +0100)]
gbm: add gbm_{bo,surface}_create_with_modifiers2

gbm_{bo,surface}_create_with_modifiers is missing the usage flags. Add a new
function which lets library users specify it.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: James Jones <jajones@nvidia.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3197>

3 years agogbm: consistently use the same name for BO flags
Simon Ser [Mon, 30 Aug 2021 13:43:51 +0000 (15:43 +0200)]
gbm: consistently use the same name for BO flags

We were sometimes using "usage", sometimes using "flags". Let's
just use "flags" everywhere (since the enum is named gbm_bo_flags).

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: James Jones <jajones@nvidia.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3197>

3 years agowsi/x11: fix uninit value by using zalloc for swapchain
Mike Blumenkrantz [Wed, 29 Sep 2021 01:50:51 +0000 (21:50 -0400)]
wsi/x11: fix uninit value by using zalloc for swapchain

==767499== Conditional jump or move depends on uninitialised value(s)
==767499==    at 0xEB8E3ED: x11_image_finish (wsi_common_x11.c:1539)
==767499==    by 0xEB8E768: x11_swapchain_destroy (wsi_common_x11.c:1640)
==767499==    by 0xEB8A8FA: wsi_common_destroy_swapchain (wsi_common.c:505)
==767499==    by 0xDE30BA1: anv_DestroySwapchainKHR (anv_wsi.c:242)
==767499==    by 0x6817A21: copper_displaytarget_destroy (zink_copper.c:192)
==767499==    by 0x6882BE6: zink_destroy_resource_object (zink_resource.c:95)
==767499==    by 0x6882447: zink_resource_object_reference (zink_resource.h:198)
==767499==    by 0x6882D33: zink_resource_destroy (zink_resource.c:123)
==767499==    by 0x688AC97: pipe_resource_destroy (u_inlines.h:145)
==767499==    by 0x688AD2E: pipe_resource_reference (u_inlines.h:162)
==767499==    by 0x688BE1E: zink_destroy_surface (zink_surface.c:319)
==767499==    by 0x688AE0A: zink_surface_reference (zink_surface.h:102)
==767499==    by 0x688BE6D: zink_surface_destroy (zink_surface.c:328)
==767499==    by 0x67F9CA2: pipe_surface_release (u_inlines.h:134)
==767499==    by 0x67FB8AD: zink_context_destroy (zink_context.c:92)
==767499==    by 0x5D47B65: st_destroy_context_priv (st_context.c:475)
==767499==    by 0x5D49AF2: st_destroy_context (st_context.c:1193)
==767499==    by 0x5D5C90F: st_context_destroy (st_manager.c:816)
==767499==    by 0x5CC1FC9: dri_destroy_context (dri_context.c:248)
==767499==    by 0x658DD63: driDestroyContext (dri_util.c:535)
==767499==    by 0x5A30166: drisw_destroy_context (drisw_glx.c:417)
==767499==    by 0x5A32484: glXDestroyContext (glxcmds.c:515)
==767499==    by 0x5315AEB: glXDestroyContext (libglx.c:332)
==767499==    by 0x4AA8E7D: glXDestroyContext (g_libglglxwrapper.c:384)
==767499==    by 0x4D5A3F0: ??? (in /usr/lib64/libwaffle-1.so.0.6.1)
==767499==    by 0x499DDD5: piglit_wfl_framework_teardown (piglit_wfl_framework.c:638)
==767499==    by 0x499E4C5: piglit_winsys_framework_teardown (piglit_winsys_framework.c:238)
==767499==    by 0x499F50C: destroy (piglit_x11_framework.c:212)
==767499==    by 0x498C535: destroy (piglit-framework-gl.c:210)
==767499==    by 0x4F48AF6: __run_exit_handlers (in /usr/lib64/libc-2.33.so)
==767499==    by 0x4F48C9F: exit (in /usr/lib64/libc-2.33.so)
==767499==    by 0x4AEFD71: piglit_report_result (piglit-util.c:245)
==767499==    by 0x499F2CA: process_next_event (piglit_x11_framework.c:139)
==767499==    by 0x499F365: enter_event_loop (piglit_x11_framework.c:153)
==767499==    by 0x499DF88: run_test (piglit_winsys_framework.c:88)
==767499==    by 0x498C5EF: piglit_gl_test_run (piglit-framework-gl.c:229)
==767499==    by 0x4022B4: main (primitive-restart.c:45)
==767499==  Uninitialised value was created by a heap allocation
==767499==    at 0x484086F: malloc (vg_replace_malloc.c:380)
==767499==    by 0xE964E85: vk_default_alloc (vk_alloc.c:26)
==767499==    by 0xEB8B24B: vk_alloc (vk_alloc.h:43)
==767499==    by 0xEB8EAF9: x11_surface_create_swapchain (wsi_common_x11.c:1723)
==767499==    by 0xEB8A82A: wsi_common_create_swapchain (wsi_common.c:476)
==767499==    by 0xDE30B47: anv_CreateSwapchainKHR (anv_wsi.c:225)
==767499==    by 0xE96134F: vk_tramp_CreateSwapchainKHR (vk_dispatch_table.c:6592)
==767499==    by 0xD7B88F0: ??? (in /usr/lib64/libvulkan.so.1.2.162)
==767499==    by 0x6817796: copper_CreateSwapchain (zink_copper.c:123)
==767499==    by 0x6817960: copper_displaytarget_create (zink_copper.c:170)
==767499==    by 0x6884C65: resource_create (zink_resource.c:780)
==767499==    by 0x6884EC5: zink_resource_create_drawable (zink_resource.c:829)
==767499==    by 0x5CC0FE3: copper_allocate_textures (copper.c:199)
==767499==    by 0x5CC28C2: dri_st_framebuffer_validate (dri_drawable.c:82)
==767499==    by 0x5D5B69A: st_framebuffer_validate (st_manager.c:222)
==767499==    by 0x5D5D32D: st_api_make_current (st_manager.c:1102)
==767499==    by 0x5CC220B: dri_make_current (dri_context.c:306)
==767499==    by 0x658DE23: driBindContext (dri_util.c:588)
==767499==    by 0x5A3022A: drisw_bind_context (drisw_glx.c:435)
==767499==    by 0x5A36CC2: MakeContextCurrent (glxcurrent.c:220)
==767499==    by 0x5A36DF9: glXMakeCurrent (glxcurrent.c:253)
==767499==    by 0x531849C: InternalMakeCurrentVendor (libglx.c:875)
==767499==    by 0x53185C3: InternalMakeCurrentDispatch (libglx.c:930)
==767499==    by 0x5318DE5: CommonMakeCurrent (libglx.c:1074)
==767499==    by 0x5318ED5: glXMakeCurrent (libglx.c:1119)
==767499==    by 0x4AA9CFA: glXMakeCurrent (g_libglglxwrapper.c:930)
==767499==    by 0x4D5AA36: ??? (in /usr/lib64/libwaffle-1.so.0.6.1)
==767499==    by 0x4D5E16E: waffle_make_current (in /usr/lib64/libwaffle-1.so.0.6.1)
==767499==    by 0x499C8CD: wfl_checked_make_current (piglit-util-waffle.h:115)
==767499==    by 0x499DA04: make_context_current_singlepass (piglit_wfl_framework.c:488)
==767499==    by 0x499DC43: make_context_current (piglit_wfl_framework.c:565)
==767499==    by 0x499DD88: piglit_wfl_framework_init (piglit_wfl_framework.c:628)
==767499==    by 0x499E3FC: piglit_winsys_framework_init (piglit_winsys_framework.c:209)
==767499==    by 0x499F581: piglit_x11_framework_create (piglit_x11_framework.c:229)
==767499==    by 0x499E361: piglit_winsys_framework_factory (piglit_winsys_framework.c:175)
==767499==    by 0x498CA60: piglit_gl_framework_factory (piglit_gl_framework.c:53)
==767499==    by 0x498C587: piglit_gl_test_run (piglit-framework-gl.c:221)
==767499==    by 0x4022B4: main (primitive-restart.c:45)

Fixes: b5c390c113d ("vulkan/wsi: add support for detecting mit-shm pixmaps.")

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13124>

3 years agogallium/dri: Make YUV formats we're going to emulate external-only.
Emma Anholt [Fri, 24 Sep 2021 17:04:49 +0000 (10:04 -0700)]
gallium/dri: Make YUV formats we're going to emulate external-only.

If we're going to have to bind them as separate planes with colorspace
conversion for sampling on the frontend, then we need to report that
they're only for external-image samplers, otherwise the lowering won't be
applied.

Fixes: 4e3a7dcf ("gallium: enable EGL_EXT_image_dma_buf_import_modifiers unconditionally")
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13038>

3 years agogallium/va: Remove VP9 header parsing for secure playback
Veerabadhran Gopalakrishnan [Tue, 7 Sep 2021 14:42:07 +0000 (20:12 +0530)]
gallium/va: Remove VP9 header parsing for secure playback

Latest VCN FW is capable of parsing the VP9 uncompressed header.
Removing the parsing from gallium.

Signed-off-by: Veerabadhran Gopalakrishnan <veerabadhran.gopalakrishnan@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13106>

3 years agoanv/slice_hash: Don't allocate more than once with multiple queues
Jordan Justen [Thu, 30 Sep 2021 01:49:59 +0000 (18:49 -0700)]
anv/slice_hash: Don't allocate more than once with multiple queues

emit_slice_hashing_state gets called once per queue, meaning
device->slice_hash can get allocated multiple times. This can be
reproduced by setting the env-var ANV_QUEUE_OVERRIDE=gc=2.

Reworks:
 * Only pack the struct once (s-b Lionel, Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13114>

3 years agoci/freedreno: Disable flaky a530 for now.
Emma Anholt [Thu, 30 Sep 2021 16:05:08 +0000 (09:05 -0700)]
ci/freedreno: Disable flaky a530 for now.

This morning saw at least 3 pipelines fail from a530 not responding and
not coming back after we tried to power cycle, and airlied was having some
similar trouble yesterday.  Until I can figure out what's going wrong
(python script failing to set up serial after retry?  relays worn out?
Power supply failing?), just disable the boards.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13123>

3 years agoanv/blorp: Force compute blorp on compute-only queues
Jordan Justen [Tue, 1 Jan 2019 00:06:47 +0000 (16:06 -0800)]
anv/blorp: Force compute blorp on compute-only queues

Reworks:
 * Set BLORP_BATCH_USE_COMPUTE in anv_blorp_batch_init (s-b Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agoanv/blorp: Add anv_blorp_batch_init, anv_blorp_batch_finish
Jordan Justen [Wed, 15 Sep 2021 19:35:30 +0000 (12:35 -0700)]
anv/blorp: Add anv_blorp_batch_init, anv_blorp_batch_finish

Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agoanv/blorp: Select pipeline based on BLORP_BATCH_USE_COMPUTE
Jordan Justen [Tue, 30 Oct 2018 18:57:33 +0000 (11:57 -0700)]
anv/blorp: Select pipeline based on BLORP_BATCH_USE_COMPUTE

Reworks:
 * Let blorp_clear handle DEBUG_BLOCS
 * Old subject was: "Use compute blorp for vkCmdFillBuffer with
   INTEL_DEBUG=blocs"
 * Old subject was: "anv/blorp: Support params.cs_prog_data being set"

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agoanv/blorp: Make sure blorp type is supported by the queue
Jordan Justen [Wed, 4 Aug 2021 09:40:17 +0000 (02:40 -0700)]
anv/blorp: Make sure blorp type is supported by the queue

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agoanv: Prevent starting a render pass on compute queues
Jordan Justen [Wed, 15 Sep 2021 08:06:25 +0000 (01:06 -0700)]
anv: Prevent starting a render pass on compute queues

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agoanv: Store anv_queue_family type in cmd-pool
Jordan Justen [Tue, 14 Aug 2018 09:34:16 +0000 (02:34 -0700)]
anv: Store anv_queue_family type in cmd-pool

v2 (Jason Ekstrand):
 - Use an anv_queue_family pointer

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Support some image/buffer blit operations using compute
Jordan Justen [Fri, 26 Oct 2018 20:06:03 +0000 (13:06 -0700)]
intel/blorp: Support some image/buffer blit operations using compute

Reworks:
 * Use BLORP_BATCH_USE_COMPUTE flag rather than compute param to
   blorp_copy (s-b Jason)
 * Squash "intel/blorp: Set shader_pipeline for compute"
 * Squash "intel/blorp: Add blorp_copy_supports_compute function"
 * Squash "intel: Support compute for image/buffer copy if INTEL_DEBUG=blocs
           is set"
 * Squash "intel/blorp: Support compute for some blit operations"
 * Use nir_image_store (s-b Jason)
 * Use nir_push_if (s-b Jason)
 * Require gfx12 for ccs in blorp_copy_supports_compute (s-b Jason)
 * Add nir_pop_if (s-b Ken)
 * Fix aux_usage check on gfx12 blorp_copy_supports_compute (s-b Ken)
 * Use blorp_set_cs_dims (s-b Jason)
 * Use dim=2d with array=true for nir_image_store (s-b Jason, Francisco)
 * Restructure gen checks in blorp_copy_supports_compute (s-b Ken)
 * Use nir_load_global_invocation_id (s-b Jason)
 * Fix inefficient calculation of store_pos (s-b Jason)
 * Use bounds_if being NULL/non-NULL for nir_pop_if (s-b Jason)
 * discard => bounds (s-b Ken)
 * Re-add ISL_AUX_USAGE_CCS_E in *_supports_compute (s-b Sagar)
 * Skip duplicated in_bounds calculation (s-b Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp/blit: Rename wm_prog_key and prog_key to key
Jordan Justen [Thu, 16 Sep 2021 20:21:04 +0000 (13:21 -0700)]
intel/blorp/blit: Rename wm_prog_key and prog_key to key

Suggested-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Support compute for slow clears
Jordan Justen [Fri, 26 Oct 2018 19:56:20 +0000 (12:56 -0700)]
intel/blorp: Support compute for slow clears

Reworks:
 * Use BLORP_BATCH_USE_COMPUTE flag rather than compute param to
   blorp_clear (s-b Jason)
 * Use nir_load_global_invocation_id (s-b Jason)
 * Use nir_push_if (s-b Jason)
 * Use nir_image_store (s-b Jason)
 * Require gfx12 for ccs in blorp_clear_supports_compute (s-b Jason)
 * Add nir_pop_if (s-b Ken)
 * Fix aux_usage check on gfx12 blorp_clear_supports_compute (s-b Ken)
 * Use blorp_set_cs_dims (s-b Jason)
 * Simplify rgb-as-red calculation (s-b Jason)
 * Use dim=2d with array=true for nir_image_store (s-b Jason, Francisco)
 * discard => bounds (s-b Ken)
 * Re-add ISL_AUX_USAGE_CCS_E in *_supports_compute (s-b Sagar)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Convert blorp_clear color_write_disable to a bitmask
Jordan Justen [Thu, 16 Sep 2021 21:25:42 +0000 (14:25 -0700)]
intel/blorp: Convert blorp_clear color_write_disable to a bitmask

Reworks:
 * Various cleanups adding BITFIELD_* (s-b Jason)
 * Add /* color_write_disable */ comment (s-b Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agoblorp/clear: Simplify rbg-as-red channel packing
Jordan Justen [Wed, 1 Sep 2021 00:45:06 +0000 (17:45 -0700)]
blorp/clear: Simplify rbg-as-red channel packing

Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agoblorp: Set view usage to ISL_SURF_USAGE_STORAGE_BIT for compute
Jordan Justen [Thu, 5 Aug 2021 03:39:58 +0000 (20:39 -0700)]
blorp: Set view usage to ISL_SURF_USAGE_STORAGE_BIT for compute

Suggested-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Use blorp_check_in_bounds for discards
Jordan Justen [Fri, 27 Aug 2021 06:46:55 +0000 (23:46 -0700)]
intel/blorp: Use blorp_check_in_bounds for discards

Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Add blorp_check_in_bounds()
Jordan Justen [Wed, 7 Jul 2021 08:51:20 +0000 (01:51 -0700)]
intel/blorp: Add blorp_check_in_bounds()

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Change discard terminology to bounds
Jordan Justen [Thu, 16 Sep 2021 19:52:23 +0000 (12:52 -0700)]
intel/blorp: Change discard terminology to bounds

Suggested-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Add blorp_get_cs_local_y, blorp_set_cs_dims
Jordan Justen [Fri, 2 Nov 2018 08:56:52 +0000 (01:56 -0700)]
intel/blorp: Add blorp_get_cs_local_y, blorp_set_cs_dims

Based the blorp_params, blorp_get_cs_local_y returns a recommended
local_y size for a compute shader.

blorp_set_cs_dims sets the compute program dims based on a given
local_y size.

Reworks:
 * Add blorp_set_cs_dims (s-b Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/gfx7: Change GPGPU Mode to bool
Jordan Justen [Tue, 29 Jun 2021 08:52:16 +0000 (01:52 -0700)]
intel/gfx7: Change GPGPU Mode to bool

Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Emit compute program based on BLORP_BATCH_USE_COMPUTE
Jordan Justen [Fri, 26 Oct 2018 19:52:44 +0000 (12:52 -0700)]
intel/blorp: Emit compute program based on BLORP_BATCH_USE_COMPUTE

Reworks:
 * Don't pack params, just memcpy param struct (s-b Jason)
 * Old subject: "intel/blorp: Emit compute program if
   params.cs_prog_data is set"
 * Various cleanups of push-const size/alignment (s-b Jason)
 * Fix subslice count by moving to devinfo (s-b Ken)
 * Simplify cw.InterfaceDescriptor code (s-b Ken)
 * Drop some comments from i965 (s-b Ken)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agoanv,iris,genxml: Use NumberOfBarriers on XeHP
Jason Ekstrand [Fri, 5 Feb 2021 01:11:07 +0000 (19:11 -0600)]
anv,iris,genxml: Use NumberOfBarriers on XeHP

Ref: bspec 55400
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agoblorp: Add blorp_alloc_general_state
Jordan Justen [Mon, 21 Jun 2021 19:45:24 +0000 (12:45 -0700)]
blorp: Add blorp_alloc_general_state

Reworks:
 * Add crocus

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Split out surface setup from state emission
Jordan Justen [Fri, 26 Oct 2018 19:48:40 +0000 (12:48 -0700)]
intel/blorp: Split out surface setup from state emission

Render will use blorp_setup_binding_table and blorp_emit_btp, but
compute will only use blorp_setup_binding_table.

Rework:
 * Use blorp_setup_binding_table, blorp_emit_btp (s-b Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Split out ps specific sampler state into a separate function
Jordan Justen [Fri, 26 Oct 2018 19:45:44 +0000 (12:45 -0700)]
intel/blorp: Split out ps specific sampler state into a separate function

The compute path will use blorp_emit_sampler_state, whereas the render
path will use blorp_emit_sampler_state_ps.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Add blorp_compile_cs
Jordan Justen [Fri, 26 Oct 2018 19:38:57 +0000 (12:38 -0700)]
intel/blorp: Add blorp_compile_cs

Reworks:
 * Don't pack params (s-b Jason)
 * Drop nir_remove_dead_variables (s-b Jason)
 * Fix comment s/render target/destination image/ (s-b Ken)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Add subgroup_id input for compute programs
Jordan Justen [Wed, 18 Aug 2021 00:31:58 +0000 (17:31 -0700)]
intel/blorp: Add subgroup_id input for compute programs

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/compiler: Use INTEL_DEBUG=blorp to dump blorp compute shaders
Jordan Justen [Mon, 29 Mar 2021 23:14:03 +0000 (16:14 -0700)]
intel/compiler: Use INTEL_DEBUG=blorp to dump blorp compute shaders

Make INTEL_DEBUG=blorp dump the blorp compute shaders instead using
the general INTEL_DEBUG=cs which is now reserved for actual compute
programs.

Ref: 05933fb0f7e ("intel/compiler: Use INTEL_DEBUG=blorp to dump blorp shaders")
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Add brw_blorp_init_cs_prog_key
Jordan Justen [Fri, 26 Oct 2018 19:36:00 +0000 (12:36 -0700)]
intel/blorp: Add brw_blorp_init_cs_prog_key

Reworks:
 * Split out blorp_init_base_prog_key to share with fs/cs key init (s-b Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Add shader_pipeline to brw_blorp_base_key
Jordan Justen [Sat, 3 Jul 2021 23:43:05 +0000 (16:43 -0700)]
intel/blorp: Add shader_pipeline to brw_blorp_base_key

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Add compute support to BLORP_CREATE_NIR_INPUT
Jordan Justen [Thu, 25 Oct 2018 23:17:04 +0000 (16:17 -0700)]
intel/blorp: Add compute support to BLORP_CREATE_NIR_INPUT

Reworks:
 * Set driver_location (s-b Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agointel/blorp: Move most of BLORP_CREATE_NIR_INPUT into a function
Jordan Justen [Tue, 16 Oct 2018 22:54:11 +0000 (15:54 -0700)]
intel/blorp: Move most of BLORP_CREATE_NIR_INPUT into a function

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11564>

3 years agofrontends/va: Fix test_va_api VAAPIDisplayAttribs tests
Ed Baker [Thu, 2 Sep 2021 23:03:24 +0000 (16:03 -0700)]
frontends/va: Fix test_va_api VAAPIDisplayAttribs tests

Set max_display_attribs to 0 instead of 1 to match
va[Query,Get,Set]DisplayAttributes implementations [1].

If max_display_attribs is greater than 0 libva-utils tests check
vaQueryDisplayAttributes() accordingly [2].

[1] https://gitlab.freedesktop.org/mesa/mesa/-/blob/2de348cdb01e45/src/gallium/frontends/va/display.c#L32
[2] https://github.com/intel/libva-utils/blob/master/test/test_va_api_display_attribs.cpp#L90

Signed-off-by: Ed Baker <edward.baker@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12941>

3 years agovirgl/drm: explicit context initialization
Gurchetan Singh [Thu, 19 Nov 2020 22:20:55 +0000 (14:20 -0800)]
virgl/drm: explicit context initialization

If the host supports explicit context initialization, try it.
If no capabilitiies associated with virgl are present, return
an error.

Reviewed-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com>
Tested-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7712>

3 years agovirgl/drm: query for context init ioctl and supported capset ids
Gurchetan Singh [Thu, 19 Nov 2020 22:03:41 +0000 (14:03 -0800)]
virgl/drm: query for context init ioctl and supported capset ids

Just add the params to the existing lists.

Reviewed-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com>
Tested-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7712>

3 years agodrm-uapi: virtgpu_drm.h: context init feature
Gurchetan Singh [Thu, 19 Nov 2020 21:50:30 +0000 (13:50 -0800)]
drm-uapi: virtgpu_drm.h: context init feature

This change allows creating contexts of depending on set of
context parameters.  The meaning of each of the parameters
is listed below:

1) VIRTGPU_CONTEXT_PARAM_CAPSET_ID

This determines the type of a context based on the capability set
ID.  For example, the current capsets:

VIRTIO_GPU_CAPSET_VIRGL
VIRTIO_GPU_CAPSET_VIRGL2

define a Gallium, TGSI based "virgl" context.  We only need 1 capset
ID per context type, though virgl has two due a bug that has since
been fixed.

The use case is the "gfxstream" rendering library and "venus"
renderer.

gfxstream doesn't do Gallium/TGSI translation and mostly relies on
auto-generated API streaming.  Certain users prefer gfxstream over
virgl for GLES on GLES emulation.  {gfxstream vk}/{venus} are also
required for Vulkan emulation.

The goal is for guest userspace to choose the optimal context type
depending on the situation/hardware.

2) VIRTGPU_CONTEXT_PARAM_NUM_RINGS

This tells the number of independent command rings that the context
will use.  This value may be zero and is inferred to be zero if
VIRTGPU_CONTEXT_PARAM_NUM_RINGS is not passed in.  This is backwards
compatibility for virgl, which has one big giant command ring for all
commands.

The maxiumum number of rings is 32.  In practice, multi-queue or
multi-ring submission is used for powerful dGPUs and virtio-gpu
may not be the best option in that case (see PCI passthrough or
rendernode forwarding).

3) VIRTGPU_CONTEXT_PARAM_POLL_RING_IDX_MASK

This is a mask of ring indices for which the DRM fd is pollable.
For example, if VIRTGPU_CONTEXT_PARAM_NUM_RINGS is 2, then the mask
may be:

[ring idx]  |  [1 << ring_idx] | final mask
-------------------------------------------
    0              1                1
    1              2                3

The "Sommelier" guest Wayland proxy uses this to poll for events
from the host compositor.

Reviewed-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com>
Tested-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7712>

3 years agoradv: plug leaks in radv_device_init_accel_struct_build_state
Chia-I Wu [Thu, 30 Sep 2021 03:36:46 +0000 (20:36 -0700)]
radv: plug leaks in radv_device_init_accel_struct_build_state

Fixes: 0dad88b4694 ("radv: Implement device-side BVH building.")
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13110>

3 years agopanvk/ci: Enable blend tests
Boris Brezillon [Mon, 27 Sep 2021 09:21:52 +0000 (11:21 +0200)]
panvk/ci: Enable blend tests

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>

3 years agopanvk: Lower blend operations when needed
Boris Brezillon [Mon, 6 Sep 2021 10:12:15 +0000 (12:12 +0200)]
panvk: Lower blend operations when needed

The gallium driver makes use of blend shaders, but panvk takes a
slightly different approach. Vulkan drivers are passed the blend
operation at pipeline creation time, which means they know it when
compiling the fragment shader and can lower the blend operation
directly in the fragment shader itself. Doing that simplifies the
pipeline creation since we don't have to deal with blend shaders
anymore.

This might come at a cost for translation layers like Zink though,
since it requires re-compiling the fragment shader every time the
blend operation changes, which we do anyway, since we don't have
a pipeline cache yet. Let's keep things simple for now and revise
things if/when we end up having performance issues.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>

3 years agopanvk: Fill the blend constants sysval
Boris Brezillon [Mon, 6 Sep 2021 14:12:50 +0000 (16:12 +0200)]
panvk: Fill the blend constants sysval

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>

3 years agopan/blend: Allow passing blend constants through a sysval
Boris Brezillon [Mon, 6 Sep 2021 11:08:45 +0000 (13:08 +0200)]
pan/blend: Allow passing blend constants through a sysval

This is needed to allow lowering blend operations in fragment shaders
when the blend operation uses dynamic blend constants.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>

3 years agonir/lower_blend: Shrink blended result if needed
Boris Brezillon [Sat, 25 Sep 2021 12:08:58 +0000 (14:08 +0200)]
nir/lower_blend: Shrink blended result if needed

Make sure the new and old sources have the same number of components,
otherwise the NIR validation pass complains.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>

3 years agonir/lower_blend: Make sure we're not passed scaled formats
Boris Brezillon [Mon, 6 Sep 2021 10:24:29 +0000 (12:24 +0200)]
nir/lower_blend: Make sure we're not passed scaled formats

SCALED formats are interpreted as floats, but not in the usual [0, 1]
or [-1, 1] range, meaning that the blend lowering logic can't directly
apply to those. Assert that the format being passed is not a scaled
format.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>

3 years agonir/lower_blend: Don't lower RTs whose format is set to NONE
Boris Brezillon [Thu, 10 Jun 2021 14:29:34 +0000 (16:29 +0200)]
nir/lower_blend: Don't lower RTs whose format is set to NONE

The caller doesn't necessarily want to lower blend operations on all
render targets since some of them might be supported natively (panvk
will be in that case). Let's just skip RTs that have a format set to
PIPE_FORMAT_NONE to allow that.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>

3 years agonir/lower_blend: Pad src to a 4-component vector
Boris Brezillon [Mon, 27 Sep 2021 16:37:34 +0000 (18:37 +0200)]
nir/lower_blend: Pad src to a 4-component vector

nir_ssa_for_src() is not supposed to pad the src vector if
dst->num_components > src->num_components. Let's pad things explicitly
with nir_pad_vector().

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>

3 years agonir: Make sure src->num_components < dst->num_components in nir_ssa_for_src()
Boris Brezillon [Sat, 25 Sep 2021 12:06:08 +0000 (14:06 +0200)]
nir: Make sure src->num_components < dst->num_components in nir_ssa_for_src()

The NIR validation complains if the swizzle accesses a component that's
not present in the source.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13060>

3 years agopanfrost: Add ASTC 3D texture format entries
Icecream95 [Sun, 12 Sep 2021 00:11:59 +0000 (12:11 +1200)]
panfrost: Add ASTC 3D texture format entries

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12814>

3 years agopanfrost: Encode 3D ASTC dimensions
Alyssa Rosenzweig [Thu, 30 Sep 2021 13:55:25 +0000 (09:55 -0400)]
panfrost: Encode 3D ASTC dimensions

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12814>

3 years agopanfrost: Use ASTC 2D enums
Alyssa Rosenzweig [Thu, 30 Sep 2021 13:35:23 +0000 (09:35 -0400)]
panfrost: Use ASTC 2D enums

Rather than manipulating the bits to do the mapping, use a dead simple
switch() with the enum definition.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12814>

3 years agopanfrost: Assert ASTC/AFBC are not used on v4
Alyssa Rosenzweig [Thu, 30 Sep 2021 13:34:52 +0000 (09:34 -0400)]
panfrost: Assert ASTC/AFBC are not used on v4

These are not introduced until v5. The required enums do not exist on
v4. Assert this is so.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12814>

3 years agopanfrost: Add ASTC stretch factor enums
Alyssa Rosenzweig [Wed, 15 Sep 2021 23:49:33 +0000 (19:49 -0400)]
panfrost: Add ASTC stretch factor enums

ASTC textures all use a common ASTC format, with the ASTC block
dimension configured with auxiliary bits at the bottom of the payload
pointer. Add the corresponding enum for ASTC 2D and 3D.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12814>

3 years agodrirc: Set vs_position_always_precise for Assault Android Cactus
Vadym Shovkoplias [Fri, 24 Sep 2021 08:49:10 +0000 (11:49 +0300)]
drirc: Set vs_position_always_precise for Assault Android Cactus

A couple of tesselation evaluation shaders lack some precise marks
on its outputs which can lead to different results after optimizations.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias@globallogic.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5376
Fixes: 09705747d72 ("nir/algebraic: Reassociate fadd into fmul in DPH-like pattern")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13027>

3 years agodriconf, glsl: Add a vs_position_always_precise option
Vadym Shovkoplias [Fri, 24 Sep 2021 08:46:10 +0000 (11:46 +0300)]
driconf, glsl: Add a vs_position_always_precise option

This is basically the same workaround as in 9b577f2a88 (driconf, glsl: Add a
vs_position_always_invariant option) commit but for tesselation evaluation
shaders. Some applications do not mark outputs as precise in tesselation
evaluation shaders which can lead to different results in case some
optimizations were applied.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias@globallogic.com>
Fixes: 09705747d72 ("nir/algebraic: Reassociate fadd into fmul in DPH-like pattern")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13027>

3 years agopanfrost: Move genxml related files to a subdir
Boris Brezillon [Thu, 5 Aug 2021 09:12:53 +0000 (11:12 +0200)]
panfrost: Move genxml related files to a subdir

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12208>

3 years agopanfrost: Split command stream descriptor definitions per-gen
Boris Brezillon [Thu, 29 Jul 2021 15:19:39 +0000 (17:19 +0200)]
panfrost: Split command stream descriptor definitions per-gen

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12208>

3 years agopanfrost: Add a common genxml file so we can share a few definitions
Boris Brezillon [Wed, 4 Aug 2021 08:55:46 +0000 (10:55 +0200)]
panfrost: Add a common genxml file so we can share a few definitions

Start with the enums that were manually redefined in
pan_{texture,format}.h and the blend equation descriptors.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12208>

3 years agoradv: fix selecting the hash when RADV_FORCE_VRS is enabled
Samuel Pitoiset [Wed, 29 Sep 2021 09:24:28 +0000 (11:24 +0200)]
radv: fix selecting the hash when RADV_FORCE_VRS is enabled

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13098>

3 years agoradv: fix adjusting the frag coord when RADV_FORCE_VRS is enabled
Samuel Pitoiset [Wed, 29 Sep 2021 09:28:01 +0000 (11:28 +0200)]
radv: fix adjusting the frag coord when RADV_FORCE_VRS is enabled

force_vrs was always RADV_FORCE_VRS_NONE at that point and the
hw workaround was never applied.

Found by inspection.

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13098>

3 years agoradv: remove the LLVM stat about the number of private VGPRs
Samuel Pitoiset [Thu, 23 Sep 2021 13:00:30 +0000 (15:00 +0200)]
radv: remove the LLVM stat about the number of private VGPRs

This doesn't seem really useful.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12999>

3 years agoaco/ra: don't rewrite affinities for phi operands after register assignment
Daniel Schürmann [Wed, 8 Sep 2021 09:56:52 +0000 (11:56 +0200)]
aco/ra: don't rewrite affinities for phi operands after register assignment

The effect of doing so is random and not meaningful.

Totals from 52 (0.03% of 150170) affected shaders: (GFX10.3)
CodeSize: 538768 -> 538784 (+0.00%); split: -0.04%, +0.04%
Instrs: 100661 -> 100707 (+0.05%); split: -0.01%, +0.06%
Latency: 1205950 -> 1205768 (-0.02%); split: -0.07%, +0.05%
InvThroughput: 200106 -> 200040 (-0.03%); split: -0.31%, +0.28%
Copies: 5717 -> 5754 (+0.65%); split: -0.17%, +0.82%
Branches: 3153 -> 3162 (+0.29%)

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoaco/ra: create nested affinities for loop header phis
Daniel Schürmann [Fri, 10 Sep 2021 14:00:25 +0000 (16:00 +0200)]
aco/ra: create nested affinities for loop header phis

Totals from 875 (0.58% of 150170) affected shaders: (GFX10.3)
CodeSize: 6084528 -> 6066628 (-0.29%); split: -0.32%, +0.02%
Instrs: 1136497 -> 1133565 (-0.26%); split: -0.28%, +0.02%
Latency: 23355051 -> 22952592 (-1.72%); split: -1.83%, +0.10%
InvThroughput: 13028151 -> 12859628 (-1.29%); split: -1.38%, +0.09%
Copies: 85673 -> 82790 (-3.37%); split: -3.62%, +0.26%
Branches: 25049 -> 25098 (+0.20%); split: -0.08%, +0.28%

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoaco/ra: create affinities between nested phis
Daniel Schürmann [Mon, 6 Sep 2021 12:58:23 +0000 (14:58 +0200)]
aco/ra: create affinities between nested phis

Totals from 17143 (11.42% of 150170) affected shaders: (GFX10.3)
VGPRs: 1138112 -> 1138440 (+0.03%); split: -0.00%, +0.03%
CodeSize: 131235532 -> 131147080 (-0.07%); split: -0.14%, +0.07%
Instrs: 24848044 -> 24775419 (-0.29%); split: -0.32%, +0.02%
Latency: 599031816 -> 596005601 (-0.51%); split: -0.52%, +0.01%
InvThroughput: 152059329 -> 151054105 (-0.66%); split: -0.66%, +0.00%
VClause: 410951 -> 410958 (+0.00%); split: -0.01%, +0.01%
Copies: 1696885 -> 1621908 (-4.42%); split: -4.64%, +0.22%
Branches: 846710 -> 851052 (+0.51%); split: -0.29%, +0.80%

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoaco/ra: don't set affinities for ssa-repair phis
Daniel Schürmann [Wed, 8 Sep 2021 20:44:19 +0000 (22:44 +0200)]
aco/ra: don't set affinities for ssa-repair phis

These have no effect anymore.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoaco/ra: for phis try to find an operand-matching register earlier
Daniel Schürmann [Wed, 8 Sep 2021 07:45:45 +0000 (09:45 +0200)]
aco/ra: for phis try to find an operand-matching register earlier

Totals from 3557 (2.37% of 150170) affected shaders: (GFX10.3)
VGPRs: 257976 -> 257984 (+0.00%)
CodeSize: 34296232 -> 34270552 (-0.07%); split: -0.09%, +0.01%
Instrs: 6512289 -> 6506900 (-0.08%); split: -0.10%, +0.01%
Latency: 136376181 -> 136262553 (-0.08%); split: -0.10%, +0.02%
InvThroughput: 33042816 -> 32992849 (-0.15%); split: -0.18%, +0.03%
VClause: 104687 -> 104686 (-0.00%)
SClause: 238657 -> 238663 (+0.00%); split: -0.00%, +0.00%
Copies: 477690 -> 471058 (-1.39%); split: -1.52%, +0.13%
Branches: 223058 -> 224326 (+0.57%); split: -0.02%, +0.59%

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoaco/ra: try more aggressive to assign phi defs the same register
Daniel Schürmann [Mon, 6 Sep 2021 12:47:21 +0000 (14:47 +0200)]
aco/ra: try more aggressive to assign phi defs the same register

Totals from 4158 (2.77% of 150170) affected shaders: (GFX10.3)
VGPRs: 312008 -> 312000 (-0.00%)
CodeSize: 42902064 -> 42892200 (-0.02%); split: -0.06%, +0.04%
Instrs: 8086443 -> 8084532 (-0.02%); split: -0.07%, +0.05%
Latency: 138551153 -> 138215222 (-0.24%); split: -0.28%, +0.03%
InvThroughput: 39676773 -> 39570850 (-0.27%); split: -0.29%, +0.02%
SClause: 306299 -> 306284 (-0.00%); split: -0.01%, +0.00%
Copies: 552481 -> 553353 (+0.16%); split: -0.75%, +0.91%
Branches: 284381 -> 282409 (-0.69%); split: -0.74%, +0.04%

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoaco/ra: split register assignment for phis into separate function
Daniel Schürmann [Mon, 6 Sep 2021 11:51:05 +0000 (13:51 +0200)]
aco/ra: split register assignment for phis into separate function

No fossil-db changes.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoaco/ra: remove some redundant code
Daniel Schürmann [Tue, 22 Jun 2021 10:37:20 +0000 (12:37 +0200)]
aco/ra: remove some redundant code

No fossil-db changes.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoaco/ra: refactor affinities into assignment struct
Daniel Schürmann [Tue, 22 Jun 2021 10:20:07 +0000 (12:20 +0200)]
aco/ra: refactor affinities into assignment struct

This lets us get rid of an unordered_map<>.

No fossil-db changes.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoaco/ra: fix intersects()
Daniel Schürmann [Mon, 21 Jun 2021 14:36:28 +0000 (16:36 +0200)]
aco/ra: fix intersects()

The previous implementation failed when a contained b.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12836>

3 years agoradv: fix missing features for BDA
Samuel Pitoiset [Fri, 24 Sep 2021 14:59:03 +0000 (16:59 +0200)]
radv: fix missing features for BDA

Only the KHR one is filled by the common code.

Fixes: ec2007d47ed ("radv: Use the shared now-in-core feature/prop extension helper functions.")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13035>

3 years agocompiler/clc: grab opencl-c.h from the system path by default
Jason Ekstrand [Fri, 19 Feb 2021 05:28:48 +0000 (23:28 -0600)]
compiler/clc: grab opencl-c.h from the system path by default

By default we use the header installed opencl-c.h header. But in the
case Mesa is compiled for microsoft clon12 we keep the injected file.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>

3 years agocompiler/clc: Clean ups
Jason Ekstrand [Fri, 19 Feb 2021 05:28:30 +0000 (23:28 -0600)]
compiler/clc: Clean ups

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>

3 years agoMove a bunch of the CLC stuff from src/microsoft to common code
Jason Ekstrand [Fri, 19 Feb 2021 03:19:24 +0000 (21:19 -0600)]
Move a bunch of the CLC stuff from src/microsoft to common code

The D3D12-specific stuff isn't useful to have in common code but all the
stuff to invoke clang really should be common.

v2: Rebase (Lionel)

v3: Define a new clc_libclc_new_dxil() entrypoint to create a clc
    context with DXIL nir_options (Jesse)

v4: Fixup meson build (Lionel)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>

3 years agomeson: extract libversion checks from clc & clover
Lionel Landwerlin [Wed, 29 Sep 2021 16:59:30 +0000 (19:59 +0300)]
meson: extract libversion checks from clc & clover

The src/microsoft/clc/meson.build was assuming to be run only on
Windows. That's about to change.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>

3 years agomicrosoft/clc: fix compiler warning on uninitiailzed variable use
Lionel Landwerlin [Wed, 29 Sep 2021 16:52:41 +0000 (19:52 +0300)]
microsoft/clc: fix compiler warning on uninitiailzed variable use

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>

3 years agomicrosoft/clc: drop MSVC specific function
Lionel Landwerlin [Wed, 29 Sep 2021 11:25:26 +0000 (14:25 +0300)]
microsoft/clc: drop MSVC specific function

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9156>

3 years agovirgl: Flush context before waiting on fences
Stéphane Marchesin [Sat, 26 Jun 2021 01:02:42 +0000 (03:02 +0200)]
virgl: Flush context before waiting on fences

The logic behind this change is intuitive: if we are waiting for
something, we should probably flush all pending rendering so that it
starts executing in the meantime. This prevents the GPU from sitting
idle for long periods of time while we are also blocked in the app.

With the gun3d trace:
Before: 79 fps After: 215 fps

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13096>

3 years agoutil: fix sign comparison
Yiwei Zhang [Tue, 28 Sep 2021 04:45:03 +0000 (04:45 +0000)]
util: fix sign comparison

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13074>

3 years agost/texture: Fall back to single-slice uploads in st_CompressedTexSubImage
Jason Ekstrand [Tue, 29 Jun 2021 17:17:08 +0000 (12:17 -0500)]
st/texture: Fall back to single-slice uploads in st_CompressedTexSubImage

Currently, if we ever fail to create a re-interpreted uncompressed view
of the resource, we fall back to a SW path.  On some Intel hardware,
this happens whenever LOD > 0.  Instead, we should fall back to
attempting to upload one slice at a time and only fall back to SW as a
last resort.

v2 [by Ken]: Fix buf_offset calculation and loop over layers.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> [v1]
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11737>

3 years agost/texture: Dedent surface setup in CompressedTexSubImage
Jason Ekstrand [Tue, 29 Jun 2021 16:44:01 +0000 (11:44 -0500)]
st/texture: Dedent surface setup in CompressedTexSubImage

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11737>

3 years agoloader/dri3: fix swap out of order when changing swap interval
Qiang Yu [Fri, 24 Sep 2021 07:47:50 +0000 (15:47 +0800)]
loader/dri3: fix swap out of order when changing swap interval

This fixes SPECVIEWPERF13 creo test case hang:
  1. Client: send present pixmap request (serial=1) when swap_interval==1
     and increase send_sbc=1
  2. Server: pend the request before vblank arrives
  3. Client: set swap_interval=0 (so set XCB_PRESENT_OPTION_ASYNC),
     send another present pixmap request (serial=2), increase send_sbc=2
  4. Server: handle the async request immediately and send complete event
     (serial=2)
  5. Client: handle the event and set recv_sbc=event->serial=2
  6. Server: vblank arrives so handle pending request and send complete
     event (serial=1)
  7. Client: handle the event and set recv_sbc=event->serial=1
  8. Client: someone call loader_dri3_swapbuffer_barrier() and waiting
     on recv_sbc==send_sbc, but no one will set recv_sbc=2 again

So basically it's caused by swap happens out of order. This commit
fixes the problem by waiting on the pending sync swaps all done when
switching to async mode, so move 6&7 before 3.

Attach the xtrace when problem happens:

  005:<:003e: 72: Present-Request(148,1): Pixmap window=0x03000002 pixmap=0x0300000b serial=1 valid=0x00000000 update=0x00000000 x_off=0 y_off=0 target_crtc=0x00000000 wait_fence=0x00000000 idle_fence=0x0300000c options=0 target_msc=4294967296 divisor=0 remainder=0 notifies=;
  ...
  005:<:0041: 72: Present-Request(148,1): Pixmap window=0x03000002 pixmap=0x03000011 serial=2 valid=0x00000000 update=0x00000000 x_off=0 y_off=0 target_crtc=0x00000000 wait_fence=0x00000000 idle_fence=0x03000012 options=Async target_msc=0 divisor=0 remainder=0 notifies=;
  005:>:0041: Event Generic(35) Present(148) IdleNotify(2) event=0x03000006 window=0x03000002 serial=2 pixmap=0x03000011 idle_fence=0x03000012
  005:>:0041: Event Generic(35) Present(148) CompleteNotify(1) kind=Pixmap(0x00) mode=Copy(0x00) event=0x03000006 window=0x03000002 serial=2 ust=7505462213117739011 msc=3565046193979392
  005:>:0041: Event Generic(35) Present(148) IdleNotify(2) event=0x03000006 window=0x03000002 serial=1 pixmap=0x0300000b idle_fence=0x0300000c
  005:>:0041: Event Generic(35) Present(148) CompleteNotify(1) kind=Pixmap(0x00) mode=Copy(0x00) event=0x03000006 window=0x03000002 serial=1 ust=7505533793042694147 msc=3565050488946688

Cc: mesa-stable
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13019>

3 years agovenus: keep layouts of descriptor sets alive
Chia-I Wu [Tue, 28 Sep 2021 17:33:29 +0000 (10:33 -0700)]
venus: keep layouts of descriptor sets alive

We might reorder vkCmdBindDescriptorSets after
vkDestroyDescriptorSetLayout due to batching, which is likely invalid.
Keep the layouts alive with the sets to defer
vkDestroyDescriptorSetLayout.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>

3 years agovenus: add vn_refcount to vn_descriptor_set_layout
Chia-I Wu [Tue, 28 Sep 2021 16:07:13 +0000 (09:07 -0700)]
venus: add vn_refcount to vn_descriptor_set_layout

The reference count does not go beyond 1 yet.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>

3 years agovenus: add a helper to destroy vn_descriptor_set
Chia-I Wu [Tue, 28 Sep 2021 17:27:42 +0000 (10:27 -0700)]
venus: add a helper to destroy vn_descriptor_set

Add vn_descriptor_set_destroy.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>

3 years agovenus: convert bo and shmem to use vn_refcount
Chia-I Wu [Tue, 28 Sep 2021 17:04:47 +0000 (10:04 -0700)]
venus: convert bo and shmem to use vn_refcount

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>

3 years agovenus: add vn_refcount
Chia-I Wu [Tue, 28 Sep 2021 17:03:04 +0000 (10:03 -0700)]
venus: add vn_refcount

Memory ordering is hard.  Add vn_refcount to take care of the details.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090>

3 years agov3dv: Use VK_DEFINE_*HANDLE_CASTS instead of rolling our own
Jason Ekstrand [Wed, 29 Sep 2021 13:30:24 +0000 (08:30 -0500)]
v3dv: Use VK_DEFINE_*HANDLE_CASTS instead of rolling our own

The core ones have some nifty stuff like asserts that it's a valid
vk_object_base and has the right type.  We don't have real type safety
with Vulkan handles but this is as close as we can get.  The core ones
also track when we've started handing out handles for logging purposes
which we want.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13101>