platform/upstream/mesa.git
23 months agozink: improve oom error message
Mike Blumenkrantz [Fri, 15 Jul 2022 15:22:07 +0000 (11:22 -0400)]
zink: improve oom error message

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17639>

23 months agozink: fix crashing on bo allocation failure
Mike Blumenkrantz [Fri, 15 Jul 2022 15:21:34 +0000 (11:21 -0400)]
zink: fix crashing on bo allocation failure

list init occurs after mem allocation, so check this first

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17639>

23 months agozink: handle null samplerview in get_imageview_for_binding()
Mike Blumenkrantz [Mon, 11 Jul 2022 17:06:06 +0000 (13:06 -0400)]
zink: handle null samplerview in get_imageview_for_binding()

this is legal

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17639>

23 months agozink: handle max_vertices=0 in geometry shader
Mike Blumenkrantz [Mon, 11 Jul 2022 16:04:22 +0000 (12:04 -0400)]
zink: handle max_vertices=0 in geometry shader

this is a weird corner case where glsl permits a zero value, so clamp to 1
and then don't emit any vertices to avoid driver hangs

affects:
dEQP-GL45-ES31.functional.geometry_shading.emit.points_emit_0_end_0

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17639>

23 months agov3d/v3dv: use NIR_PASS(_
Alejandro Piñeiro [Mon, 18 Jul 2022 11:10:24 +0000 (13:10 +0200)]
v3d/v3dv: use NIR_PASS(_

Instead of NIR_PASS_V, when possible.

This was done recently on anv (see commit ce60195ec and MR#17014)

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agobroadcom/compiler: make several passes to return a progress
Alejandro Piñeiro [Tue, 19 Jul 2022 11:28:55 +0000 (13:28 +0200)]
broadcom/compiler: make several passes to return a progress

Two advantages:
   * When using NIR_DEBUG=nir_print_xx, will print outcome only if
     there is a change
   * We can use NIR_PASS(_, ...) instead of NIR_PASS_V, that has
     slightly more validation checks.

This includes:
  * v3d_nir_lower_image_load_store
  * v3d_nir_lower_io
  * v3d_nir_lower_line_smooth
  * v3d_nir_lower_load_store_bitsize
  * v3d_nir_lower_robust_buffer_access
  * v3d_nir_lower_scratch
  * v3d_nir_lower_txf_ms

As we are here we also simplify some of them by using the
nir_shader_instructions_pass helper.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agobroadcom/compiler: removed unused function
Alejandro Piñeiro [Tue, 19 Jul 2022 11:19:43 +0000 (13:19 +0200)]
broadcom/compiler: removed unused function

It is not even implemented.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agov3dv/pipeline: use nir_shader_instructions_pass when lowering layout
Alejandro Piñeiro [Mon, 18 Jul 2022 12:31:21 +0000 (14:31 +0200)]
v3dv/pipeline: use nir_shader_instructions_pass when lowering layout

The trigger for this commit was when we found that we were not calling
nir_metadata_preserve when lowering the layout code. But then I found
that it would be better to just update the code to use
nir_shader_instructions_pass, so we can avoid to manually:
   * Initialize the nir_builder
   * Call nir_foreach functions (we pass the callback)
   * Call nir_metadata_preserve functions (that as mentioned we were not calling)

We also get a nice cleanup of several functions by reducing the number
of parameters (we pass a state struct).

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agonir: call nir_metadata_preserve at nir_remove_unused_io_vars
Alejandro Piñeiro [Mon, 18 Jul 2022 13:28:16 +0000 (15:28 +0200)]
nir: call nir_metadata_preserve at nir_remove_unused_io_vars

Without it we got a metadata assert:
deqp-vk: ../src/compiler/nir/nir_metadata.c:108: nir_metadata_check_validation_flag: Assertion `!(function->impl->valid_metadata & nir_metadata_not_properly_reset)' failed

if we try to use NIR_PASS(_, instead of NIR_PASS_V (that among other
things, do more validations).

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agobroadcom/compiler: use NIR_PASS for nir_lower_vars_to_ssa at v3d_optimize_nir
Alejandro Piñeiro [Mon, 18 Jul 2022 10:52:21 +0000 (12:52 +0200)]
broadcom/compiler: use NIR_PASS for nir_lower_vars_to_ssa at v3d_optimize_nir

There's no reason to not take into account progress at that point.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agobroadcom/compiler: wrap nir_convert_to_lcssa with NIR_PASS_V
Alejandro Piñeiro [Wed, 13 Jul 2022 10:53:14 +0000 (12:53 +0200)]
broadcom/compiler: wrap nir_convert_to_lcssa with NIR_PASS_V

So we get it included with the NIR_DEBUG=print_xx debug options.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agobroadcom: document which debug options are specific for a given driver
Alejandro Piñeiro [Tue, 5 Jul 2022 11:10:52 +0000 (13:10 +0200)]
broadcom: document which debug options are specific for a given driver

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agobroadcom: add no_merge_jobs debug option
Alejandro Piñeiro [Tue, 5 Jul 2022 11:04:59 +0000 (13:04 +0200)]
broadcom: add no_merge_jobs debug option

To avoid having a custom getenv on v3dv.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agov3dv/device: add comment on depthClamp feature
Alejandro Piñeiro [Mon, 4 Jul 2022 12:49:53 +0000 (14:49 +0200)]
v3dv/device: add comment on depthClamp feature

As we can't support it, and I need to recheck now and then when I read
that code.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17609>

23 months agovulkan: allow null descriptor set layouts in pipeline layouts
Ricardo Garcia [Wed, 20 Jul 2022 10:13:53 +0000 (12:13 +0200)]
vulkan: allow null descriptor set layouts in pipeline layouts

VK_NULL_HANDLE descriptor set layouts are allowed when creating pipeline
layouts without VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT.

From VUID-VkPipelineLayoutCreateInfo-graphicsPipelineLibrary-06753:

> If graphicsPipelineLibrary is not enabled, elements of pSetLayouts
> must be valid VkDescriptorSetLayout objects

From VUID-VkPipelineLayoutCreateInfo-pSetLayouts-parameter:

> If setLayoutCount is not 0, pSetLayouts must be a valid pointer to an
> array of setLayoutCount valid or VK_NULL_HANDLE VkDescriptorSetLayout
> handles

Signed-off-by: Ricardo Garcia <rgarcia@igalia.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17629>

23 months agov3dv: fix offset reported by vkGetImageSubresourceLayout
Iago Toral Quiroga [Wed, 20 Jul 2022 08:35:18 +0000 (10:35 +0200)]
v3dv: fix offset reported by vkGetImageSubresourceLayout

This represents an offset from the actual start of the image data,
not from the start of the memory allocation bound to the image.

Fixes:
dEQP-VK.image.subresource_layout.*

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

23 months agov3dv: remove assert that poolSizeCount must be larger than 0
Iago Toral Quiroga [Wed, 20 Jul 2022 07:56:30 +0000 (09:56 +0200)]
v3dv: remove assert that poolSizeCount must be larger than 0

From the Vulkan spec:

   "If poolSizeCount is not 0, pPoolSizes must be a valid pointer to an
    array of poolSizeCount valid VkDescriptorPoolSize structures"

So 0 is actually allowed and there is a CTS to check it is handled gracefully.

Fixes:
dEQP-VK.api.descriptor_pool.zero_pool_size_count

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

23 months agov3dv: handle VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_2_EXT
Iago Toral Quiroga [Tue, 19 Jul 2022 07:05:09 +0000 (09:05 +0200)]
v3dv: handle VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_2_EXT

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

23 months agonir: convert unused mesh outputs to shared memory
Marcin Ślusarz [Wed, 13 Jul 2022 11:55:32 +0000 (13:55 +0200)]
nir: convert unused mesh outputs to shared memory

Otherwise reads from output in one subgroup may not see
writes from other subgroups. Temp variables are later converted
to scratch, so even within one subgroup we may not see correct values.

Test case in https://gitlab.freedesktop.org/mesa/crucible/-/merge_requests/115

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17517>

23 months agoci: wine-apitrace bump to 11.1
David Heidelberg [Mon, 18 Jul 2022 15:05:33 +0000 (17:05 +0200)]
ci: wine-apitrace bump to 11.1

In the future, bump will be needed to update non-VK tags as wine traces get
used elsewhere.

Reviewed-by: Andres Gomez <agomez@igalia.com>
Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17623>

23 months agov3d/ci: (partially) revert expected list
Juan A. Suarez Romero [Wed, 20 Jul 2022 07:36:52 +0000 (09:36 +0200)]
v3d/ci: (partially) revert expected list

This reverts the traces expected list changed in f3579a62e9b
("v3d/v3dv/ci: update expected results").

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17647>

23 months agozink: default to lazy/templated descriptors
Mike Blumenkrantz [Tue, 19 Jul 2022 14:12:33 +0000 (10:12 -0400)]
zink: default to lazy/templated descriptors

cached mode was great 2 years ago when template support was less widespread,
but now that templates are everywhere, caching is less performant in
every scenario

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17636>

23 months agozink: add an explicit ZINK_DESCRIPTOR_MODE_CACHED
Mike Blumenkrantz [Tue, 19 Jul 2022 14:08:07 +0000 (10:08 -0400)]
zink: add an explicit ZINK_DESCRIPTOR_MODE_CACHED

no functional changes, but now AUTO is no longer a mode that gets used

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17636>

23 months agozink: delete ZINK_DESCRIPTOR_MODE_NOFALLBACK
Mike Blumenkrantz [Tue, 19 Jul 2022 14:02:46 +0000 (10:02 -0400)]
zink: delete ZINK_DESCRIPTOR_MODE_NOFALLBACK

this was useful for testing but is going to be less useful soon

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17636>

23 months agozink: move descriptor_mode to be a global
Mike Blumenkrantz [Tue, 19 Jul 2022 13:58:03 +0000 (09:58 -0400)]
zink: move descriptor_mode to be a global

this can't change once it's been set, so having it per-object is pointless

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17636>

23 months agonir/loop_unroll: clean up after complex_unroll_single_terminator()
Timothy Arceri [Mon, 18 Jul 2022 09:18:15 +0000 (19:18 +1000)]
nir/loop_unroll: clean up after complex_unroll_single_terminator()

Previously we would just unroll the loop one extra iteration and let
other optimisation passes clean up the mess. This worked to a degree
but if the loop happened to be nested inside another loop we would
end up with phi chains that would block other passes from being able
to do the cleanup.

With this commit we explicitly clone the variables create by lcsaa
and insert them directly in the last continue branch after we are done
unrolling. With this optimisation passes can recognise both sides
of the if output the same values and can progress further.

Help with the issues described in:
https://gitlab.freedesktop.org/mesa/mesa/-/issues/6051

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17611>

23 months agolavapipe: state latest conformance tests passed
Dave Airlie [Tue, 28 Sep 2021 23:45:07 +0000 (09:45 +1000)]
lavapipe: state latest conformance tests passed

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Cc: mesa-stable "22.1"
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17643>

23 months agoturnip: Disable LRZ fast-clear for gen1 and gen2
Danylo Piliaiev [Mon, 18 Jul 2022 15:59:32 +0000 (18:59 +0300)]
turnip: Disable LRZ fast-clear for gen1 and gen2

LRZ fast-clear works on all gens, however blob disables it on
gen1 and gen2. We also elect to disable fast-clear on these gens
because for close to none gains it adds complexity and seem to work
a bit differently from gen3+. Which creates at least one edge case:
if first draw which uses LRZ fast-clear doesn't lock LRZ direction
the fast-clear value is undefined.

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

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17599>

23 months agoci/freedreno: Switch a630 to manual/disabled for lab maintenance.
Emma Anholt [Tue, 19 Jul 2022 22:29:34 +0000 (15:29 -0700)]
ci/freedreno: Switch a630 to manual/disabled for lab maintenance.

We're getting several more 630s in the lab, but need a bit of time to swap
out some broken old ones and stabilize the new ones.  Fritz thinks this
should be done in an hour or so, but I want to turn off the CI for main so
that we don't block anyone else.

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

23 months agovenus: reenable VK_EXT_extended_dynamic_state2
Yiwei Zhang [Sat, 16 Jul 2022 16:48:25 +0000 (16:48 +0000)]
venus: reenable VK_EXT_extended_dynamic_state2

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

23 months agovenus: check dynamic state for raster enablement
Yiwei Zhang [Sat, 16 Jul 2022 16:20:48 +0000 (16:20 +0000)]
venus: check dynamic state for raster enablement

We should not scrub raster dedicated states when dynamic state includes
VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE.

Test:
- dEQP-VK.pipeline.extended_dynamic_state.*_raster
- dEQP-VK.api.pipeline.pipeline_invalid_pointers_unused_structs.graphics

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

23 months agocrocus: fail query begin if upload allocation fails.
Dave Airlie [Tue, 19 Jul 2022 05:46:14 +0000 (15:46 +1000)]
crocus: fail query begin if upload allocation fails.

This is the only place I think I can see this crashing.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17615>

23 months agoZink: Fix clear being missed when using emulated draws in zink_blit
SoroushIMG [Tue, 19 Jul 2022 13:50:11 +0000 (14:50 +0100)]
Zink: Fix clear being missed when using emulated draws in zink_blit

zink_kopper_acquire_readback will flush any outstanding clears, this means that
the current clears need to be applied first before calling zink_kopper_acquire_readback.
This was already done for native_blit and native_resolve, also do this for the emulated draw path.
Seen as intermittent failures in cts case GTF-GL33.gtf21.GL2FixedTests.buffer_clear.buffer_clear.

Cc: mesa-stable
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17631>

23 months agozink: Fix spirv stream 0 vertex emit for multistream shaders
SoroushIMG [Wed, 13 Jul 2022 10:59:05 +0000 (11:59 +0100)]
zink: Fix spirv stream 0 vertex emit for multistream shaders

Spirv spec does not allow the use of OpEmitVertex or OpEndPrimitive when there are multiple streams.
Instead emit the multi-stream version of these with stream set to 0.
This issue was seen when testing cts case KHR-GL46.transform_feedback.draw_xfb_stream_test

Fixes: 35e346f4280 ("zink: handle vertex streams")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17513>

23 months agoanv: Do depth/stencil optimization for dynamic depth/stencil
Jason Ekstrand [Fri, 15 Jul 2022 02:02:35 +0000 (21:02 -0500)]
anv: Do depth/stencil optimization for dynamic depth/stencil

When we made depth/stencil dynamic, we lost the optimization.  This is
particularly important for cases where the stencil test is enabled but
never writes anything as certain combinations with discard can cause
the stencil write (which doesn't do anything) to get moved late which
can be a measurable perf hit.  According to 028e1137e67b ("anv/pipeline:
Be smarter about depth/stencil state", it was a couple percent for DOTA2
on Broadwell back in the day.  No idea how it affects current titles.

This may also improve the depth/stncil PMA workarounds on Gen8 and Gen9
since they're now looking at optimized depth/stencil state.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agovulkan/graphics_state: Improve the depth/stencil optimization code
Jason Ekstrand [Fri, 15 Jul 2022 01:59:38 +0000 (20:59 -0500)]
vulkan/graphics_state: Improve the depth/stencil optimization code

We now disable stencil writes when the stencil test is disabled or when
both stencil write masks are zero.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agoanv: Switch to using common dynamic state tracking
Jason Ekstrand [Thu, 14 Jul 2022 20:09:46 +0000 (15:09 -0500)]
anv: Switch to using common dynamic state tracking

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agoanv: Stop merging DEPTH_STENCIL state
Jason Ekstrand [Thu, 14 Jul 2022 16:55:04 +0000 (11:55 -0500)]
anv: Stop merging DEPTH_STENCIL state

Now that we've stopped trying to do dynamic stuff up-front, we're only
merging in one bit: DoubleSidedStencilEnable.  There's no point in all
the merging code for one bit which is a constant anyway.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agoanv: Rework setting primitive topology
Jason Ekstrand [Thu, 14 Jul 2022 16:41:17 +0000 (11:41 -0500)]
anv: Rework setting primitive topology

For one thing, we were deceptively setting it wrong in genX_cmd_buffer.c
and then overwriting it in each of of gfx7_cmd_buffer.c and
gfx8_cmd_buffer.c.  Pull it all into genX_cmd_buffer.c so it's no longer
duplicated.  Also, stop doing the PATCHLIST conversion in anv_pipeline.c
and just store the number of patch vertices.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agoanv: Convert to using vk_graphics_pipeline_state
Jason Ekstrand [Tue, 12 Jul 2022 21:16:55 +0000 (16:16 -0500)]
anv: Convert to using vk_graphics_pipeline_state

This attempts to be a pretty minimal refactor.  We just switch all the
state emit code to use the new graphics pipeline state object.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agoanv: remove pipeline setting dynamic state
Lionel Landwerlin [Sat, 2 Jul 2022 11:35:10 +0000 (14:35 +0300)]
anv: remove pipeline setting dynamic state

Following our rule that anything that can be dynamic should be set
(and is this case is already) in the following files :

   - genX_cmd_buffer.c
   - gfx8_cmd_buffer.c
   - gfx7_cmd_buffer.c

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agoanv: Stop recording sample locations per-sample-count
Jason Ekstrand [Tue, 12 Jul 2022 21:30:46 +0000 (16:30 -0500)]
anv: Stop recording sample locations per-sample-count

The only reason why we recorded them per-sample-count is because Intel
hardware is weird starting with Broadwell.  The API, requires that the
dynamic sample pattern be reset every time the sample count changes so
we only need to record the pattern for the current sample count.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agoanv: Handle vertex buffer sizes in anv_CmdBindVertexBuffers2
Jason Ekstrand [Tue, 5 Jul 2022 10:06:27 +0000 (05:06 -0500)]
anv: Handle vertex buffer sizes in anv_CmdBindVertexBuffers2

There's no good reason to defer figuring out the size until we emit the
packet.  We know everything when the bind happens.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agoanv: Add an instance multiplier to anv_pipeline
Jason Ekstrand [Thu, 7 Jul 2022 16:43:12 +0000 (11:43 -0500)]
anv: Add an instance multiplier to anv_pipeline

This lets us get rid of the view_mask and pipeline replication logic
repeated all over everywhere.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>

23 months agospirv: handle phis decorated with RelaxedPrecision
Daniel Schürmann [Fri, 3 Jun 2022 12:00:11 +0000 (14:00 +0200)]
spirv: handle phis decorated with RelaxedPrecision

If the driver can do 16-bit ALU ops, then store RelaxedPrecision phi
values into 16-bit NIR variables with downconverts/upconverts on the way
in/out.

This has no impact on shader-db on freedreno (not that we have a ton of
GLES content there), but it does cause an ANGLE-translated CTS shader on
vulkan to get consistent conversions between two copies of a value, and
avoid a test bug.

Reviewed-by: Emma Anholt <emma@anholt.net>
Closes: #6585
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14018>

23 months agoci/bare-metal: Add timeouts to the shell commands called in fastboot.
Emma Anholt [Mon, 18 Jul 2022 21:16:05 +0000 (14:16 -0700)]
ci/bare-metal: Add timeouts to the shell commands called in fastboot.

It seems that we sometimes stall out executing "fastboot boot", and if
that happens we want to reboot the board and try again.

Fixes: #6682
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17607>

23 months agoradv: don't update misaligned_mask in CmdBindVertexBuffers2
Rhys Perry [Wed, 13 Jul 2022 15:43:44 +0000 (16:43 +0100)]
radv: don't update misaligned_mask in CmdBindVertexBuffers2

This can't do it in the loop because it doesn't easily know what
attributes use a binding.

We could do it in a separate loop, but there's no point, especially since
zink does CmdSetVertexInputEXT() after CmdBindVertexBuffers2().

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fixes: c335a4d70ed ("radv: dynamically calculate misaligned_mask for dynamic vertex input")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17521>

23 months agoradv: fix vbo_bound_mask indexing
Rhys Perry [Wed, 13 Jul 2022 15:33:04 +0000 (16:33 +0100)]
radv: fix vbo_bound_mask indexing

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6812
Fixes: 1b8bdecf6e0 ("radv: add a mask of bound descriptor buffers for dynamic vertex input")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17521>

23 months agor300: disable PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF
Pavel Ondračka [Sat, 16 Jul 2022 05:57:33 +0000 (07:57 +0200)]
r300: disable PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF

We can't do uniform buffer objects and from the hardware
perspective constants (uniforms) and immediates are treated in
the same way. They are uploaded together and fit together into the
(rather low) total constant limit. Therefore, there is actually no
advantage in converting immediates to uniforms, and a whole lot of
disadvantages (less possible optimizations and no inlining).

Fixes the dEQP regressions from https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16770

The tests failed because when there is an indirect array access the
compiler inserts a big if ladder and converting the temp to a uniform
means more instructions because the ifs cant be lowered at least
partially to selects. It is particularly visible, because the code
NIR currently emits for the indirect access doesn't really fit the
hardware, see: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6366

No change in my shader-db, so this concerns the tests only.

Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17576>

23 months agovulkan: Detect pNext chain loops in vk_foreach_struct() (v2)
Jason Ekstrand [Mon, 18 Jul 2022 14:05:59 +0000 (09:05 -0500)]
vulkan: Detect pNext chain loops in vk_foreach_struct() (v2)

This implements the "tortoise and the hare" algorithm for detecting
cycles in graphs.  We use the caller's iterator as the hare and our own
internal copy as the tortoise.  Conveniently, VkBaseOutStructure (and
VkBaseInStructure which is identical except the pointer type on pNext)
have a pointer we can use for the tortoise and an sType which we can use
for a counter to ensure we only increment the tortose every other loop
iteration.

There are more efficient algorithms than tortoise and hare but they
require allocating memory for something like a hash set of seen nodes.
Since this for debug purposes only, it's ok for it to be a bit
inefficient in the case where it hits the assert.  In the usual case of
no loops, it's the same runtime efficiency as the unchecked version
except that it does a tiny bit of math and 50% more pointer chases.

Version 1 worked fine with clang and with GCC 12.1 with -O0 but not with
optimizations. See https://gitlab.freedesktop.org/mesa/mesa/-/issues/6895.
Unfortunately, the first version required modifying a temporary declared
const inside the for loop and that seems to have been the problem.  This
version instead has an iterator struct which is managed by an outer for
loop and the inner for loop exists to declare the user's requested
iteration variable and manage the actual iteration.  Because the outer
for loop is effectively `for (bool done = false; !done; done = true)`,
it will execute exactly once, regardless of the inner loop, so break and
continue inside the inner loop should work the same as if it's a single
for loop.

The other major difference with the new version is that the code is the
same for debug and release except the half_iter and loop check are gone.
I've verified by hand that this produces virtually identical code to the
old simple iterators on both GCC andl clang with an optimized build.

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

23 months agoUse vk_foreach_struct_const where needed
Jason Ekstrand [Tue, 19 Jul 2022 08:39:14 +0000 (03:39 -0500)]
Use vk_foreach_struct_const where needed

We're about to make it so that the compiler warns/errors if you use the
wrong iterator macro.  Fix up a bunch of places where someone used the
wrong one before we break anything.

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

23 months agovulkan: Copy the depth/stencil state optimization code from ANV
Jason Ekstrand [Thu, 7 Jul 2022 17:09:16 +0000 (12:09 -0500)]
vulkan: Copy the depth/stencil state optimization code from ANV

Instead of having stencil writes as an out parameter of the optimization
function, we add a new write_enable field for stencil that's equivalent
to the similarly named field for depth.  This doesn't mean drivers must
actually support disabling stencil writes independently but the
information may be helpful on some hardware.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17328>

23 months agovulkan: Add a common implementation of vkCmdSet*
Jason Ekstrand [Fri, 1 Jul 2022 03:35:44 +0000 (22:35 -0500)]
vulkan: Add a common implementation of vkCmdSet*

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17328>

23 months agovulkan: Add a common data structure for dynamic states
Jason Ekstrand [Wed, 29 Jun 2022 23:26:05 +0000 (18:26 -0500)]
vulkan: Add a common data structure for dynamic states

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17328>

23 months agoutil: Constify __bitset_test_range
Jason Ekstrand [Wed, 13 Jul 2022 20:20:38 +0000 (15:20 -0500)]
util: Constify __bitset_test_range

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17328>

23 months agovulkan: Add data structures to store all graphics state
Jason Ekstrand [Wed, 13 Jul 2022 15:02:30 +0000 (10:02 -0500)]
vulkan: Add data structures to store all graphics state

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17328>

23 months agovulkan: Add standard sample locations
Jason Ekstrand [Mon, 4 Jul 2022 14:49:02 +0000 (09:49 -0500)]
vulkan: Add standard sample locations

This looks a bit funny because we define the struct in the .c file but
that will be fixed in the next commit.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17328>

23 months agovulkan: Add an enum for all dynamic graphics states
Jason Ekstrand [Mon, 27 Jun 2022 14:03:02 +0000 (09:03 -0500)]
vulkan: Add an enum for all dynamic graphics states

Also, add a helper function to turn VkPipelineDynamicStateCreateInfo
into a bitset.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17328>

23 months agovulkan: Add a vk_limits.h file for runtime limits
Jason Ekstrand [Wed, 29 Jun 2022 18:42:26 +0000 (13:42 -0500)]
vulkan: Add a vk_limits.h file for runtime limits

Individual driver limits may be smaller than these.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17328>

23 months agoaco: requires Exact for p_jump_to_epilog
Samuel Pitoiset [Mon, 18 Jul 2022 08:10:26 +0000 (10:10 +0200)]
aco: requires Exact for p_jump_to_epilog

Otherwise, in presence of p_exit_early_if the main FS will always
jump to the PS epilog regardless the exact mask.

This fixes dEQP-VK.draw.renderpass.shader_invocation.helper_invocation
and few vkd3d-proton regressions when PS epilogs are forced.

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/17617>

23 months agov3d/v3dv/ci: update expected results
Juan A. Suarez Romero [Tue, 19 Jul 2022 14:25:21 +0000 (16:25 +0200)]
v3d/v3dv/ci: update expected results

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17632>

23 months agoaco: fix assertion in insert_exec_mask
Daniel Schürmann [Thu, 7 Jul 2022 17:05:43 +0000 (19:05 +0200)]
aco: fix assertion in insert_exec_mask

The exec mask might also be of type mask_type_loop.

Fixes: d068eb53e84ca1e44ad96c31dab63476880b3c72 ('aco/insert_exec_mask: optimize top-level transition to exact before demote')
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17402>

23 months agoaco: Avoid live-range splits in Exact mode
Daniel Schürmann [Fri, 11 Mar 2022 18:12:50 +0000 (19:12 +0100)]
aco: Avoid live-range splits in Exact mode

Because the data register of atomic VMEM instructions
is shared between src and dst, it might be necessary
to create live-range splits during RA.
Make the live-range splits explicit in WQM mode.

Totals from 7 (0.01% of 134913) affected shaders: (GFX10.3)
Latency: 17209 -> 17210 (+0.01%)

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

23 months agoaco: avoid unnecessary copies in emit_wqm()
Daniel Schürmann [Fri, 11 Mar 2022 16:14:38 +0000 (17:14 +0100)]
aco: avoid unnecessary copies in emit_wqm()

No fossil-db changes.

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

23 months agoturnip: expose VK_EXT_shader_module_identifier
Hyunjun Ko [Fri, 15 Jul 2022 08:06:09 +0000 (17:06 +0900)]
turnip: expose VK_EXT_shader_module_identifier

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17614>

23 months agoturnip: Remove an unnecessary assert.
Hyunjun Ko [Fri, 15 Jul 2022 08:04:17 +0000 (17:04 +0900)]
turnip: Remove an unnecessary assert.

The assertion is already in the common implementation.

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17614>

23 months agoac/llvm: Remove load_vertex_id handling
Konstantin Seurer [Thu, 14 Jul 2022 12:01:19 +0000 (14:01 +0200)]
ac/llvm: Remove load_vertex_id handling

Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17539>

23 months agoaco: Remove dead nir_intrinsic_load_vertex_id case
Konstantin Seurer [Thu, 14 Jul 2022 11:58:54 +0000 (13:58 +0200)]
aco: Remove dead nir_intrinsic_load_vertex_id case

This intrinsic is lowered in NIR.

Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17539>

23 months agoradeonsi: Set vertex_id_zero_based
Konstantin Seurer [Thu, 14 Jul 2022 11:56:05 +0000 (13:56 +0200)]
radeonsi: Set vertex_id_zero_based

Let NIR lower load_vertex_id instead of LLVM.

Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17539>

23 months agov3dv: Use nir_gen_rect_vertices
Konstantin Seurer [Thu, 14 Jul 2022 09:16:22 +0000 (11:16 +0200)]
v3dv: Use nir_gen_rect_vertices

Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17535>

23 months agoradv: Use nir_gen_rect_vertices
Konstantin Seurer [Thu, 14 Jul 2022 09:13:18 +0000 (11:13 +0200)]
radv: Use nir_gen_rect_vertices

Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17535>

23 months agonir: Add a common gen_rect_vertices implementation
Konstantin Seurer [Thu, 14 Jul 2022 09:09:38 +0000 (11:09 +0200)]
nir: Add a common gen_rect_vertices implementation

Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17535>

23 months agoradv: disable viewport depth clamping only when necessary
Samuel Pitoiset [Thu, 5 May 2022 14:53:13 +0000 (16:53 +0200)]
radv: disable viewport depth clamping only when necessary

When the application uses depth values outside of the [0.0,1.0] range
with VK_EXT_depth_range_unrestricted, or when explicitly disabled.
Otherwise, the driver can clamp to [0.0,1.0] internally for optimal
performance.

From the Vulkan spec "in 28.10.1. Depth Clamping and Range Adjustment":

    "If depth clamping is not enabled and zf is not in the range [0, 1]
    and either VK_EXT_depth_range_unrestricted is not enabled, or the
    depth attachment has a fixed-point format, then zf is undefined
    following this step."

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/16349>

23 months agov3dv: implement VK_KHR_buffer_device_address
Iago Toral Quiroga [Mon, 27 Jun 2022 12:12:25 +0000 (14:12 +0200)]
v3dv: implement VK_KHR_buffer_device_address

This feature allows shaders to use pointers to buffers which may
not be bound via descriptor sets. Access to these buffers is done
via global intrinsics.

Because the buffers are not accessed through descriptor sets, any
live buffer flagged with VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR
can be accessed by any shader using global intrinsics, so the driver
needs to make sure all these buffers are mapped by the kernel when
it submits the job for execution.

We handle this by tracking if any draw call or compute dispatch in
a job uses a pipeline that has any such shaders. If so, the job is
flagged as using buffer device address and the kernel submission
for that job will add all live BOs bound to buffers flagged with the
buffer device address usage flag.

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

23 months agobroadcom/compiler: track if a shader uses global intrinsics
Iago Toral Quiroga [Mon, 27 Jun 2022 12:09:47 +0000 (14:09 +0200)]
broadcom/compiler: track if a shader uses global intrinsics

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

23 months agobroadcom/compiler: implement 2x32 global intrinsics
Iago Toral Quiroga [Mon, 27 Jun 2022 12:09:28 +0000 (14:09 +0200)]
broadcom/compiler: implement 2x32 global intrinsics

Notice we ignore the high 32-bit component of the address because
we know it must be 0.

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

23 months agonir: add nir_address_format_2x32bit_global
Iago Toral Quiroga [Wed, 22 Jun 2022 09:28:53 +0000 (11:28 +0200)]
nir: add nir_address_format_2x32bit_global

This adds support for global 64-bit GPU addresses as a pair of
32-bit values. This is useful for platforms with 32-bit GPUs
that want to support VK_KHR_buffer_device_address, which makes
GPU addresses explicitly 64-bit.

With the new format we also add new global intrinsics with 2x32
suffix that consume the new address format.

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

23 months agov3dv: remove duplicate condition
Iago Toral Quiroga [Fri, 15 Jul 2022 03:29:39 +0000 (05:29 +0200)]
v3dv: remove duplicate condition

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

23 months agov3dv: explain why we clear certain state after a draw call
Iago Toral Quiroga [Fri, 15 Jul 2022 03:27:04 +0000 (05:27 +0200)]
v3dv: explain why we clear certain state after a draw call

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

23 months agov3dv: add a dirty state for pending push constants UBO updates
Iago Toral Quiroga [Fri, 15 Jul 2022 03:01:22 +0000 (05:01 +0200)]
v3dv: add a dirty state for pending push constants UBO updates

If we have 2 pipelines that consume the same push constant data
but where one of them only uses direct access and the other has
indirect access, a draw with the first pipeline would clear the
dirty flag without updating the UBO and by the time we bind and
draw with the second pipeline we won't upload the constants either
because the first draw cleared the dirty flag.

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

23 months agov3dv: allocate more push constant buffers if needed
Iago Toral Quiroga [Thu, 14 Jul 2022 09:15:22 +0000 (11:15 +0200)]
v3dv: allocate more push constant buffers if needed

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

23 months agov3dv: stop tracking push constant buffer references
Iago Toral Quiroga [Thu, 14 Jul 2022 09:08:49 +0000 (11:08 +0200)]
v3dv: stop tracking push constant buffer references

Since we allocate this ourselves we can immediately add it to the
job at the time we allocate it.

This also fixes a bug we introduced when we implemented inline
uniforms because since that commit, if we had an inline uniform
buffer at index 1 which happend to have indirect access we would
track it in slot 0 instead of slot 1, potentially overwriting
the push constant buffer reference.

Fixes: ea3223e7a46 ('v3dv: implement VK_EXT_inline_uniform_block')
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17536>

23 months agov3dv: don't allocate MAX_PUSH_CONSTANTS_SIZE bytes for the push constants UBO
Iago Toral Quiroga [Thu, 14 Jul 2022 06:58:06 +0000 (08:58 +0200)]
v3dv: don't allocate MAX_PUSH_CONSTANTS_SIZE bytes for the push constants UBO

We have code in there to allocate various segments of MAX_PUSH_CONSTANTS_SIZE
to handle the case of various draw calls in the same command buffer requiring
different push constants, so we are implicitly expecting it to be larger than
this. In fact, this only works now because when we allocate a BO we are always
at least allocating a full page, so the least we ever allocate is 4096 bytes,
so be explicit about it to avoid confusion.

Also, since we were always mapping MAX_PUSH_CONSTANTS_SIZE and the mapping
always starts at the beginning of the BO, it looks like after the first copy
when the resource offset is not zero, we would be writing outside the mapped
range. Always map the full size of the BO instead to ensure this doesn't
happen.

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

23 months agov3dv: limit upload of indirect push constant data
Iago Toral Quiroga [Thu, 14 Jul 2022 08:29:36 +0000 (10:29 +0200)]
v3dv: limit upload of indirect push constant data

We have been always uploading MAX_PUSH_CONSTANTS_SIZE but now that
we track the actual size of the push constant buffer we can use
this instead.

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

23 months agov3dv: move push constant data to the command buffer state
Iago Toral Quiroga [Wed, 13 Jul 2022 10:44:45 +0000 (12:44 +0200)]
v3dv: move push constant data to the command buffer state

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

23 months agov3dv: only save/restore push constant data for meta operations if needed
Iago Toral Quiroga [Wed, 13 Jul 2022 09:29:02 +0000 (11:29 +0200)]
v3dv: only save/restore push constant data for meta operations if needed

If the command buffer didn't have any push constants or the meta
operation didn't write any new constants we don't need to restore
the state.

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

23 months agoRevert "vulkan: Detect pNext chain loops in vk_foreach_struct()"
Jason Ekstrand [Tue, 19 Jul 2022 04:48:59 +0000 (23:48 -0500)]
Revert "vulkan: Detect pNext chain loops in vk_foreach_struct()"

This reverts commit 4c56b535f5b415c24805dccc8d147a60af3f03e3.

23 months agoanv: move restart index to gfx state
Lionel Landwerlin [Mon, 4 Jul 2022 07:05:21 +0000 (10:05 +0300)]
anv: move restart index to gfx state

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: fix primitive topology dynamic state emission on gfx7
Lionel Landwerlin [Sat, 2 Jul 2022 19:29:41 +0000 (22:29 +0300)]
anv: fix primitive topology dynamic state emission on gfx7

This dynamic state uses the pipeline information so it needs to be
reemitted whenever the pipeline changes.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: name non dynamic state fields correctly
Lionel Landwerlin [Sun, 23 Jan 2022 14:20:46 +0000 (16:20 +0200)]
anv: name non dynamic state fields correctly

Those fields have confusing names. They hold non dynamic state,
specified at pipeline creation that we copy into the dynamic state of
the command buffer whenever we bind a pipeline. This non dynamic state
might get picked up in the dynamically emitted instructions of the 3D
pipeline because our HW packets are not exactly splitted like the
Vulkan API.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: reorder & document fields of anv_graphics_pipeline
Lionel Landwerlin [Sun, 23 Jan 2022 14:15:10 +0000 (16:15 +0200)]
anv: reorder & document fields of anv_graphics_pipeline

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: move CreateRayTracingPipelines to common code
Lionel Landwerlin [Fri, 28 Jan 2022 11:22:26 +0000 (13:22 +0200)]
anv: move CreateRayTracingPipelines to common code

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: move CreateComputePipelines to common code
Lionel Landwerlin [Sat, 22 Jan 2022 20:33:35 +0000 (22:33 +0200)]
anv: move CreateComputePipelines to common code

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: move CreateGraphicsPipelines to common code
Lionel Landwerlin [Sat, 22 Jan 2022 20:26:46 +0000 (22:26 +0200)]
anv: move CreateGraphicsPipelines to common code

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: rename internal function for consistency
Lionel Landwerlin [Sat, 22 Jan 2022 12:47:59 +0000 (14:47 +0200)]
anv: rename internal function for consistency

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: Don't use the wrong ARRAY_SIZE
Jason Ekstrand [Fri, 15 Jul 2022 10:19:12 +0000 (05:19 -0500)]
anv: Don't use the wrong ARRAY_SIZE

Even though this doesn't change anything, it's not good to use an
ARRAY_SIZE for one array to iterate over another.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: split graphics nir loading
Lionel Landwerlin [Fri, 21 Jan 2022 22:35:24 +0000 (00:35 +0200)]
anv: split graphics nir loading

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: break up anv_pipeline_compile_graphics()
Lionel Landwerlin [Fri, 21 Jan 2022 12:36:34 +0000 (14:36 +0200)]
anv: break up anv_pipeline_compile_graphics()

This function is pretty overwhelming.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: simplify dynamic buffer count in pipeline layout
Lionel Landwerlin [Wed, 23 Mar 2022 15:05:15 +0000 (17:05 +0200)]
anv: simplify dynamic buffer count in pipeline layout

anv_descriptor_set_layout already has the information we're gather
here.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>

23 months agoanv: remove local computation of dynamic states
Lionel Landwerlin [Fri, 21 Jan 2022 12:35:04 +0000 (14:35 +0200)]
anv: remove local computation of dynamic states

This bit mask is already computed in
anv_graphics_pipeline::dynamic_states in anv_graphics_pipeline_init().

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17601>