Commit Graph

1417 Commits

Author SHA1 Message Date
Chia-I Wu 6929ccedff turnip: shared_consts and push_consts are mutually exclusive
Skip gather_push_constants when shared consts are enabled.  This makes
sure push_consts is only zero-initialized, and reserved_user_consts is
0.  This saves some space in the const file.

This change also adds a few asserts and a comment to
lower_load_push_constant.  Because shared consts share the same range
for all stages, we should not apply per-stage offsets in
lower_load_push_constant.  It worked because nir_lower_explicit_io
always sets base to 0 for nir_var_mem_push_const and
shader->push_consts.lo was always 0 for all stages.

Fixes: 0c787d57e6 ("tu: increase maxPushConstantsSize to 256.")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17777>
2022-07-29 16:22:43 +00:00
Chia-I Wu 562e5ba286 turnip: remove shared_consts from tu_compiled_shaders
It is set but unused.  We also don't serialize/deserialize shared_consts
to/from the pipeline cache.

Fixes: e1f2cabc5e ("turnip: Change to use shared consts for PushConstants")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17777>
2022-07-29 16:22:43 +00:00
Eric Engestrom 438d5baa36 turnip: expose support for VK_EXT_acquire_drm_display
Turnip supports VK_EXT_direct_mode_display and can use the common
implementation of AcquireDrmDisplayEXT() & GetDrmDisplayEXT() (which use
wsi->can_present_on_device() that turnip implements).

Signed-off-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17768>
2022-07-29 07:49:47 +00:00
Danylo Piliaiev a9ebf55d02 turnip: Simple breadcrumbs implementation to debug hangs
A simple implementations of breadcrumbs tracking of GPU progress
intended to be the last resort when debugging unrecoverable hangs.
For best results use Vulkan traces to have a predictable place of hang.

Requires compilation with TU_BREADCRUMBS_ENABLED=1. See tu_cs_breadcrumbs.c
for details on how to use this feature.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15452>
2022-07-28 08:48:39 +00:00
Connor Abbott 9b844d7c42 tu: Add debug option to use emulated renderpass support
This should be useful for stress-testing dynamic rendering.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott b90d628a7d tu: Use common vk_image_view base struct
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott 89263fde20 tu: Use common vk_image struct
This eliminates some boilerplate, and will be necessary to use the
common render pass implementation for debugging purposes.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott cb0f414b2a tu: Add support for suspending and resuming renderpasses
This is unfortunately very complicated because we have to stitch
together the state of the suspended passes after the fact, with primary
command buffers at submit time.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott 3aa20a4409 tu: Split out some state into a separate struct
These bits of state will have to be treated specially when
suspending/resuming a render pass, because they will need to be tracked
across command buffers.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott 9689433eee tu: Update more state with secondaries
Some of these are actually bugfixes, some like the drawcall information
are just for autotune so they are just performance fixes. However this
came from an audit into what state is used in CmdEndRenderPass().

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott 79c7c6e492 tu: Remove has_subpass_predication
The workaround this was used for was removed.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott ed125e6cca tu: Initial support for dynamic rendering
Support for suspend/resume will be added later. This just sets up
the internal render pass, and adds support to pipeline creation and
secondary inheritance.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott 22be08a21e tu: Remove usage of RenderPassBeginInfo
More preparation for using this with dynamic rendering.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott cf391db4c6 tu: Move tu_render_pass definition up
So that we can embed one in tu_cmd_buffer.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott 2b8b5259c7 tu: Disable GMEM for multiview inside tu_render_pass_gmem_config
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott c42e7aa46c tu: Move TU_DONT_CARE_AS_LOAD into attachment_set_ops()
So that we can share it with dynamic rendering.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott 907b892bb2 tu: Rewrite tess factor emission
Emit it at EndRenderPass time, if the renderpass has tessellation. This
avoids all the special handling for secondaries, will work with
suspended/resumed render passes, and will handle secondaries that
contain render passes which will be allowed with dynamic rendering.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott c5be444500 tu: Treat CP_WAIT_FOR_ME as a cache invalidate
The workaround for draws that need a CP_WAIT_FOR_ME didn't work if the
barrier before the draw is in a separate command buffer from the draw.
The barrier would add a pending CP_WAIT_FOR_ME, but it would get dropped
on the floor at the end of the command buffer and the draw wouldn't have
a pending CP_WAIT_FOR_ME so it wouldn't emit one. We don't know in the
barrier if the destination is a draw with the workaround, so we have two
options:

- Emit any pending CP_WAIT_FOR_ME at the end of the command buffer (and
  before secondaries) in case there is a workaround draw later. This
  will emit an extra CP_WAIT_FOR_ME at the end of the command buffer in
  case there is an indirect command barrier.
- Always assume at the beginning of the command buffer that there is a
  pending CP_WAIT_FOR_ME. This will emit an extra CP_WAIT_FOR_ME before
  the first workaround-requiring draw in the command buffer, in case
  there was a barrier earlier.

The only draws requiring a workaround are currently
vkCmdDraw*IndirectCount(), which we assume are rarer than indirect
command barriers, so we implement the second option. This entails
treating it as a cache invalidate.

This fixes some upcoming dynamic rendering CTS tests that do
vkCmdDrawIndirectCount() in a secondary but put the barrier for it in
the primary.

Fixes: 37939e9c54 ("turnip: Fix the lack of WFM before indirect draws")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Connor Abbott d2ad4c739c tu/lrz: Do not use framebuffer when inheriting LRZ
The only thing it's used for is to get the image view, and we can't rely
on it existing anyway. With dynamic rendering, we only have the format
of the attachments and sample count, so moving forward we can't rely on
anything other than that.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17378>
2022-07-27 19:40:44 +00:00
Danylo Piliaiev 4ba129cd86 tu: Do not dereference descriptorSetLayout in push descriptors tmpl
Fixes crash when capturing with RenderDoc.

From VK spec:

 descriptorSetLayout [...] This parameter is ignored if templateType
 is not VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17751>
2022-07-26 18:18:48 +00:00
Connor Abbott 19a2353446 tu: Fix resolving d32s8 into s8 on fast path
The code assumed that if the source was d32s8 then the destination would
also be d32s8, in particular that depth_base_addr/stencil_base_addr
would also be filled out. Move the destination and source handling into
two different ifs with different conditions.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17684>
2022-07-26 15:00:01 +00:00
Connor Abbott d426ee6a99 tu: Support resolving D24S8 -> S8
This was missed when we added support for VK_KHR_depth_stencil_resolve.
There is a similar feature where the stencil aspect of a D24S8 can be
copied "tightly" in CopyImageToBuffer, but it used the texture swizzle
and so required the 3d path. To get it to work with the 2D path, which
is required for resolves, we have to instead use the A8_UNORM format,
which works for texture sampling even for tiled images. We also have to
reuse the pre-existing image views because subpass resolves work on
image views rather than images, whereas before the fixup was applied
while creating the image view. This means threading through the
corresponding "opposite" format through setup, src, and dst functions,
doing the fixup there (through some shared helpers), and then getting
every user to specify the right format. As a bonus, we no longer need to
force the 3d path for the CopyImageToBuffer and CopyBufferToImage
special cases.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17684>
2022-07-26 15:00:01 +00:00
Hyunjun Ko 0c787d57e6 tu: increase maxPushConstantsSize to 256.
Now there are two paths for push constants.

When it's range is under 128b, we can use shared consts.
When it's over 128b, we can instead do loading data through
regular path, which is same as the previous way.

Now we can satisfy emulations like vkd3d that requires 256b for
its root signatures and we think it fairly maps to push constants
rather than inline uniform blocks that requires one indirection.

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15503>
2022-07-24 09:03:47 +00:00
Hyunjun Ko e1f2cabc5e turnip: Change to use shared consts for PushConstants
Follow the way blob is doing for PushConstants though it supports only
128b, same as previous.

v1. Rename tu_push_constant_range.count into dwords to redue confusion.
( Danylo Piliaiev <dpiliaiev@igalia.com> )

v2. Enable shared constants only if necessary.

v3. Merge the two draw states TU_DRAW_STATE_SHADER_GEOM_CONST and
TU_DRAW_STATE_FS_CONST as shared constants are used.

Note that this leaves tu_push_constant_range in tu_shader so we could
use it again in the following patch.

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15503>
2022-07-24 09:03:47 +00:00
Hyunjun Ko ce8e8051af turnip: clean up unused parameters for user consts.
Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15503>
2022-07-24 09:03:47 +00:00
Chia-I Wu 8ec81a4b11 turnip: fix an assertion with drm-shim
Fixes

  deqp-vk: ../src/vulkan/runtime/vk_device.c:49:
  get_timeline_mode: Assertion `timeline_type == NULL' failed.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17571>
2022-07-22 02:11:14 +00:00
Jason Ekstrand 87ab287436 vulkan: Call lower_clip_cull_distance_arrays in vk_spirv_to_nir
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17644>
2022-07-21 21:18:48 +00:00
Konstantin Seurer 630df88a74 turnip: Remove format desc null assert
Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17490>
2022-07-21 12:48:01 +00:00
Jason Ekstrand b510ee0d22 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>
2022-07-19 19:55:17 +00:00
Hyunjun Ko 4bccee123f 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>
2022-07-19 16:12:15 +00:00
Hyunjun Ko d046d6e9e0 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>
2022-07-19 16:12:15 +00:00
Konstantin Seurer fc26fbde3d vulkan: Common vk_format_get_component_bits
RADV and PowerVR use the same implementation.
Turnip does use a slightly modified version but the helper only has one
use -> just inline it and get rid of turnip's vk_format.h.

Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17515>
2022-07-18 22:14:06 +00:00
Connor Abbott 67c9ca2319 tu: Use incoherent CCU write for buffer accesses
Unlike image writes, buffer writes may access the same memory in
different ways, which we've seen in the past can cause problems. Use an
incoherent access to force flush/invalidate between accesses to the same
buffer, unless we know the barrier applies to images only.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17193>
2022-07-14 17:23:39 +00:00
Danylo Piliaiev b059cdad40 turnip: Add TU_GPU_TRACEPOINT envvar to toggle tracepoints
All tracepoints are enabled by default.

Example:
 TU_GPU_TRACEPOINT=-sysmem_clear

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16781>
2022-07-12 22:24:19 +00:00
Danylo Piliaiev d903c6c7f3 turnip: Refactor tracepoints generation to reduce duplication
This way we will not need to repeat arguments for "start" and "end"
tracepoints.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16781>
2022-07-12 22:24:19 +00:00
Connor Abbott cf0cfd572e freedreno/a6xx: VPC_SO_NCOMP is actually VPC_SO_BUFFER_STRIDE
This answers the question in a comment in turnip, and fixes some GL46
tests and piglit tests.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17494>
2022-07-12 17:57:07 +00:00
Eric Engestrom 2c99dc5b22 turnip: use updated tokens from vk.xml
Signed-off-by: Eric Engestrom <eric@igalia.com>
Acked-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17342>
2022-07-12 15:53:11 +00:00
Emma Anholt 240a98297d freedreno: Rename the "SIZE" regs for interpolateAtOffset to "CENTERRHW"
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17322>
2022-07-11 16:56:05 +00:00
Emma Anholt 0e1fb2d984 nir+ir3: Rename load_size_ir3 to load_center_rhw_ir3.
Now that we know what it does, it also explains what it's doing in
interpolateAtOffset in ir3.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17322>
2022-07-11 16:56:05 +00:00
Emma Anholt 4b404e22d0 turnip: Refactor vertex input setup a little.
The repeated reservation code could be moved into the function.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17102>
2022-07-11 16:32:03 +00:00
Emma Anholt ec5984c0d4 turnip: Fix the reservation for vertex inputs.
It was too large since 2cd30266f1 ("tu: Refactor VS DECODE/DEST to be
emitted in two pkt4"), so fix it and also give it a name next to the code
it relates to.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17102>
2022-07-11 16:32:03 +00:00
Emma Anholt 12314067c4 turnip: Fix up per-stage additional size accounting.
input_size is the dwords emitted (hard to tell because of all of the * 4 /
4 going on), and constant_data is emitted with the emit_program call too.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17102>
2022-07-11 16:32:03 +00:00
Emma Anholt 7d9a824d27 turnip: Account for additional_cs_reserve_size for both bin and render.
Both emit_program() calls will use this space.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17102>
2022-07-11 16:32:03 +00:00
Marek Olšák c9ca8abe4f Change all debug_assert calls to assert
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Acked-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17403>
2022-07-10 00:50:35 +00:00
Rob Clark 62c5d428bc turnip: assert valid vertex_flag reg
If this somehow gets optimized out, the GS will run forever.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17341>
2022-07-08 20:32:35 +00:00
Danylo Piliaiev bf4c160909 tu: Fix prim gen query and pipeline stats query interaction
Fixed:
- VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT was able to stop prim counter
  when pipeline stats query is running.
  - This may have happened when prim gen query was in secondary cmdbuf.
- VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT counting geometry in each tile.
- VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT counting geometry in each tile
  when pipeline stats query is started inside prim gen query and inside
  a renderpass.

The matter of VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT and pipeline stats
interaction is solved by tracking whether pipeline stats query is
running both on CPU (for non secondary cmdbuf case) and on GPU (for
secondary cmdbuf).

Note, prim gen query is not allowed with secondary command buffers, so
only pipeline stats query is tracked on gpu.
See https://gitlab.khronos.org/vulkan/vulkan/-/issues/3142

Counting geometry per each tile is solved by:
- Conditionally executing START/STOP_PRIMITIVE_CTRS to not run in tiling
  pass. Solves the case when prim gen query is inside a renderpass.
- Stop prim counters before executing `draw_cs` and restarting them
  afterwards. Solves prim gen query being outside a renderpass.

Fixes GL CTS tests with Zink + `TU_DEBUG=gmem`:
 GTF-GL46.gtf30.GL3Tests.transform_feedback.transform_feedback_max_separate
 GTF-GL46.gtf40.GL3Tests.transform_feedback2.transform_feedback2_basic
 GTF-GL46.gtf40.GL3Tests.transform_feedback2.transform_feedback2_framebuffer
 GTF-GL46.gtf40.GL3Tests.transform_feedback3.transform_feedback3_streams_overflow
 GTF-GL46.gtf40.GL3Tests.transform_feedback3.transform_feedback3_streams_queried
 GTF-GL46.gtf40.GL3Tests.transform_feedback2.transform_feedback2_states

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

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17163>
2022-07-08 11:14:18 +03:00
Danylo Piliaiev 465e7c303b tu,freedreno: Refactored START/STOP events for pipeline stats
For a5xx+ renamed:
- RST_PIX_CNT -> START_FRAGMENT_CTRS
- RST_VTX_CNT -> STOP_FRAGMENT_CTRS
- TILE_FLUSH  -> START_COMPUTE_CTRS
- STAT_EVENT  -> STOP_COMPUTE_CTRS
I'm not sure about a5xx itself but I'll take a chance of it being
similar to a6xx in this regard.

Knowing this emit_begin_stat_query/emit_end_stat_query can now emit
only events that are needed for the pool's flags.

Also primitive generated query clearly doesn't need fragment and
compute counters.

Passes tests:
 dEQP-VK.query_pool.statistics_query.*
 dEQP-VK.transform_feedback.primitives_generated_query.*

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17163>
2022-07-08 11:14:18 +03:00
Hyunjun Ko f4b72fa26d turnip: keep the depth_clip_disable state at the pipeline builder.
So we could later decide whether to enable Z_CLIP_DISABLE on not.

Closes: #6732

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17248>
2022-06-30 01:08:17 +00:00
Hyunjun Ko 6cb41c5188 freedreno,ir3: rename Z_CLAMP_ENABLE to Z_CLIP_DISABLE
UNK5 of GRAS_CL_CNTL is still unclear though.

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17248>
2022-06-30 01:08:17 +00:00
Hyunjun Ko d2e769c1b6 turnip: fix wrong size for lrz cs when lrz_track_quirk is enabled.
Fixes: 4b5f0d98fd ("tu: Overhaul LRZ, implement on-GPU dir tracking and
LRZ fast-clear")

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17289>
2022-06-29 11:15:23 +00:00