mesa.git
5 years agogallium/util: Fix build error due to cast to different size
Robert Foss [Fri, 4 May 2018 15:05:13 +0000 (17:05 +0200)]
gallium/util: Fix build error due to cast to different size

Signed-off-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
5 years agoradv: fix HTILE metadata initialization in presence of subpass clears
Samuel Pitoiset [Mon, 25 Jun 2018 11:34:10 +0000 (13:34 +0200)]
radv: fix HTILE metadata initialization in presence of subpass clears

If the driver ends up by performing a slow depthstencil clear,
the HTILE metadata won't be initialized correctly.

This fixes random VM faults on Polaris while running CTS
with Bas's runner. This doesn't seem to regress performance.

CC: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agor600/sb: give the scheduler more margin to find valid instructions groups
Gert Wollny [Thu, 31 May 2018 23:20:54 +0000 (01:20 +0200)]
r600/sb: give the scheduler more margin to find valid instructions groups

For instruction sequences that change the address register with every load
the current limit to bail out of the scheduler and reject the optimisation
was too tight, i.e. it was expected that at least one pending instruction
would be scheduled each time.

Give the scheduler more margin to sort out these load sequences by allowing
a number of rounds where no instruction is scheduled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106163

Signed-off-by: Gert Wollny <gw.fossdev@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
5 years agor600/sb: fix rotated register in while loop
Gert Wollny [Thu, 31 May 2018 21:25:09 +0000 (23:25 +0200)]
r600/sb: fix rotated register in while loop

This patch is based on
https://lists.freedesktop.org/archives/mesa-dev/2018-February/185805.html

Dave Airlie:

 "A bunch of CTS tests led me to write
  tests/shaders/ssa/fs-while-loop-rotate-value.shader_test
  which r600/sb always fell over on.

  GCM seems to move some of the copies into other basic blocks,
  if we don't allow this to happen then it doesn't seem to schedule
  them badly.

  Everything I've read on SSA/phi copies say they have to happen
  in parallel, so keeping them in the same basic block seems like
  a good way to keep some of that property."

This patch differs from the one proposed by Dave in that it only adds
the NF_DONT_MOVE flag to copy_move instructions that are created by split_phi*
and that are located in loops.

Fixes piglit: tests/shaders/ssa/fs-while-loop-rotate-value.shader_test
(no regressions in the shader set). It also fixes all failing tests from

  dEQP-GLES3.functional.shaders.loops.*

Signed-off-by: Gert Wollny <gw.fossdev@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
5 years agofreedreno/ir3: fix deref conversion fallout
Rob Clark [Sat, 23 Jun 2018 15:02:50 +0000 (11:02 -0400)]
freedreno/ir3: fix deref conversion fallout

Signed-off-by: Rob Clark <robdclark@gmail.com>
5 years agofreedreno/ir3: fix unused variable warning
Rob Clark [Sat, 23 Jun 2018 10:47:49 +0000 (06:47 -0400)]
freedreno/ir3: fix unused variable warning

Fixes: cf0c7258ee0 freedreno/a5xx: MSAA
Signed-off-by: Rob Clark <robdclark@gmail.com>
5 years agofreedreno: fix HW_ATOMIC_COUNTERS cap
Rob Clark [Fri, 22 Jun 2018 20:09:25 +0000 (16:09 -0400)]
freedreno: fix HW_ATOMIC_COUNTERS cap

This was mistakenly exposed, even though we want atomic counters to be
lowered to atomic ops on an SSBO like nearly every other GPU.  Which
somehow recently started getting segfaults due to calling a null
pipe->set_hw_atomic_buffers().

Fixes a crash in stk, and probably other things.

Signed-off-by: Rob Clark <robdclark@gmail.com>
5 years agoradv: add VK_EXT_display_control to radv driver [v5]
Keith Packard [Fri, 16 Jun 2017 04:00:56 +0000 (21:00 -0700)]
radv: add VK_EXT_display_control to radv driver [v5]

This extension provides fences and frame count information to direct
display contexts. It uses new kernel ioctls to provide 64-bits of
vblank sequence and nanosecond resolution.

v2:
Rework fence integration into the driver so that waiting for
any of a mixture of fence types (wsi, driver or syncobjs)
causes the driver to poll, while a list of just syncobjs or
just driver fences will block. When we get syncobjs for wsi
fences, we'll adapt to use them.

v3: Adopt Jason Ekstrand's coding conventions

Declare variables at first use, eliminate extra whitespace between
types and names. Wrap lines to 80 columns.

Suggested-by: Jason Ekstrand <jason.ekstrand@intel.com>
v4: Adapt to WSI fence API change. It now returns VkResult and
no longer has an option for relative timeouts.

v5: wsi_register_display_event and wsi_register_device_event now
use the default allocator when NULL is provided, so remove the
computation of 'alloc' here.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoanv: add VK_EXT_display_control to anv driver [v5]
Keith Packard [Fri, 16 Jun 2017 04:00:56 +0000 (21:00 -0700)]
anv: add VK_EXT_display_control to anv driver [v5]

This extension provides fences and frame count information to direct
display contexts. It uses new kernel ioctls to provide 64-bits of
vblank sequence and nanosecond resolution.

v2: Adopt Jason Ekstrand's coding conventions

Declare variables at first use, eliminate extra whitespace between
types and names. Wrap lines to 80 columns.

Add extension to list in alphabetical order

Suggested-by: Jason Ekstrand <jason.ekstrand@intel.com>
v3: Adapt to WSI fence API change. It now returns VkResult and
no longer has an option for relative timeouts.

v4: wsi_register_display_event and wsi_register_device_event now
use the default allocator when NULL is provided, so remove the
computation of 'alloc' here.

v5: use zalloc2 instead of alloc2 for the WSI fence.

Suggested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
5 years agovulkan: add VK_EXT_display_control [v10]
Keith Packard [Fri, 16 Jun 2017 04:00:56 +0000 (21:00 -0700)]
vulkan: add VK_EXT_display_control [v10]

This extension provides fences and frame count information to direct
display contexts. It uses new kernel ioctls to provide 64-bits of
vblank sequence and nanosecond resolution.

v2: Remove DRM_CRTC_SEQUENCE_FIRST_PIXEL_OUT flag. This has
    been removed from the proposed kernel API.

    Add NULL parameter to drmCrtcQueueSequence ioctl as we
    don't care what sequence the event was actually queued to.

v3: Adapt to pthread clock switch to MONOTONIC

v4: Fix scope for wsi_display_mode andwsi_display_connector allocs

Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
v5: Adopt Jason Ekstrand's coding conventions

    Declare variables at first use, eliminate extra whitespace between
    types and names. Wrap lines to 80 columns.

    Use wsi_rel_to_abs_time helper function to convert relative
    timeouts to absolute timeouts without causing overflow.

Suggested-by: Jason Ekstrand <jason.ekstrand@intel.com>
v6:
    Change WSI fence wait function to return VkResult instead of
    bool. This makes the meaning of the return value easier to
    understand, and allows for the indication of failure.

    Also change the WSI fence wait function to take only absolute
    timeouts and not provide an option for a relative timeout. No
    users wanted relative timeouts, and it's simpler if that option
    isn't available.

    Terminate the DPMS property loop once we've found the property.

    Assert that the fence hasn't already been destroyed in
    wsi_display_fence_destroy.

    Rearrange the event handler function order in the file to place
    routines in an easier to find order.

Suggested-by: Jason Ekstrand <jason.ekstrand@intel.com>
v7:
    Adapt to API changes for surface_get_capabilities

v8:
    Use wsi->alloc in register_display_event so that callers
    don't have to dig out an allocator for us.

v9:
    Fix a few minor formatting issues

Suggested-by: Jason Ekstrand <jason.ekstrand@intel.com>
v10:
    Use wsi->alloc if none provided in wsi_display_fence_alloc.

    Now that drivers are expected to pass the allocator argument
    straight through from the application, we need to check those
    for NULL everywhere.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
5 years agoanv: Support wait for heterogeneous list of fences [v3]
Keith Packard [Wed, 6 Jun 2018 05:18:56 +0000 (23:18 -0600)]
anv: Support wait for heterogeneous list of fences [v3]

Handle the case where the set of fences to wait for is not all of the
same type by either waiting for them sequentially (waitAll), or
polling them until the timer has expired (!waitAll). We hope the
latter case is not common.

While the current code makes sure that it always has fences of only
one type, that will not be true when we add WSI fences. Split out this
refactoring to make merging that clearer.

v2: Adopt Jason Ekstrand's coding conventions

    Declare variables at first use, eliminate extra whitespace between
    types and names. Wrap lines to 80 columns.

Suggested-by: Jason Ekstrand <jason.ekstrand@intel.com>
v2:
    Cast INT64_MAX to uint64_t to make of its use as the maximum
    possible timeout clearly unsigned to the reader.

Suggested-by: Jason Ekstrand <jason.ekstrand@intel.com>
    Make anv_wait_for_fences with !waitAll check all fences at least
    once, even if the requested timeout has already passed.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
5 years agoradv: Enable lower_io_to_temporaries after deref changes.
Bas Nieuwenhuizen [Sun, 3 Jun 2018 23:10:12 +0000 (01:10 +0200)]
radv: Enable lower_io_to_temporaries after deref changes.

Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/lower_system_values: Assert/assume direct var derefs
Jason Ekstrand [Sat, 7 Apr 2018 05:34:57 +0000 (22:34 -0700)]
nir/lower_system_values: Assert/assume direct var derefs

System values are never arrays or structs so we can assume a direct var
deref.  This simplifies things a bit and prevents us from accidentally
throwing away an array index.

Suggested-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove old-school deref chain support
Jason Ekstrand [Mon, 26 Mar 2018 21:50:38 +0000 (14:50 -0700)]
nir: Remove old-school deref chain support

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from analyze_loops
Jason Ekstrand [Mon, 26 Mar 2018 22:26:21 +0000 (15:26 -0700)]
nir: Remove deref chain support from analyze_loops

Note that this patch needs to come late in the series since this pass
can be run after any pass that damages nir_metadata_loop_analysis.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agofreedreno/ir3: convert to deref instructions
Rob Clark [Thu, 5 Apr 2018 00:41:59 +0000 (20:41 -0400)]
freedreno/ir3: convert to deref instructions

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: promote intrinsic_get_var() to helper
Rob Clark [Thu, 5 Apr 2018 00:40:33 +0000 (20:40 -0400)]
nir: promote intrinsic_get_var() to helper

Useful in a few other places.. let's not copy-pasta

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Rework lower_locals_to_regs to use deref instructions
Jason Ekstrand [Tue, 3 Apr 2018 00:41:28 +0000 (17:41 -0700)]
nir: Rework lower_locals_to_regs to use deref instructions

This completely reworks the pass to support deref instructions and
delete support for old deref chains

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agointel,ir3: Re-enable nir_opt_copy_prop_vars
Jason Ekstrand [Wed, 28 Mar 2018 04:00:01 +0000 (21:00 -0700)]
intel,ir3: Re-enable nir_opt_copy_prop_vars

Now that it's rewritten for deref instructions, we can turn it back on.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoradeonsi: Remove deref chain support in nir scan pass.
Bas Nieuwenhuizen [Sat, 12 May 2018 23:17:23 +0000 (01:17 +0200)]
radeonsi: Remove deref chain support in nir scan pass.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
5 years agoradv: Remove deref chain support in radv shader info pass.
Bas Nieuwenhuizen [Fri, 11 May 2018 12:38:12 +0000 (14:38 +0200)]
radv: Remove deref chain support in radv shader info pass.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
5 years agoac/nir: Remove deref chain support.
Bas Nieuwenhuizen [Sat, 12 May 2018 23:48:18 +0000 (01:48 +0200)]
ac/nir: Remove deref chain support.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
5 years agoradeonsi: Add deref support to the nir scan pass.
Bas Nieuwenhuizen [Fri, 11 May 2018 23:02:32 +0000 (01:02 +0200)]
radeonsi: Add deref support to the nir scan pass.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
5 years agonir: Rework opt_copy_prop_vars to use deref instructions
Jason Ekstrand [Wed, 28 Mar 2018 03:57:30 +0000 (20:57 -0700)]
nir: Rework opt_copy_prop_vars to use deref instructions

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/copy_prop_vars: Re-order some logic in compare_derefs
Jason Ekstrand [Wed, 28 Mar 2018 00:21:35 +0000 (17:21 -0700)]
nir/copy_prop_vars: Re-order some logic in compare_derefs

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from split_per_member_structs
Jason Ekstrand [Mon, 2 Apr 2018 23:47:35 +0000 (16:47 -0700)]
nir: Remove deref chain support from split_per_member_structs

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from opt_undef
Jason Ekstrand [Mon, 2 Apr 2018 23:44:40 +0000 (16:44 -0700)]
nir: Remove deref chain support from opt_undef

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from split_var_copies
Jason Ekstrand [Mon, 2 Apr 2018 23:24:10 +0000 (16:24 -0700)]
nir: Remove deref chain support from split_var_copies

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from dead_variables
Jason Ekstrand [Mon, 2 Apr 2018 23:15:39 +0000 (16:15 -0700)]
nir: Remove deref chain support from dead_variables

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from propagate_invariant
Jason Ekstrand [Mon, 2 Apr 2018 23:10:04 +0000 (16:10 -0700)]
nir: Remove deref chain support from propagate_invariant

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_var_copies
Jason Ekstrand [Mon, 2 Apr 2018 23:02:43 +0000 (16:02 -0700)]
nir: Remove deref chain support from lower_var_copies

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_drawpixels
Jason Ekstrand [Mon, 2 Apr 2018 22:59:39 +0000 (15:59 -0700)]
nir: Remove deref chain support from lower_drawpixels

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from opt_peephole_select
Jason Ekstrand [Tue, 27 Mar 2018 16:45:23 +0000 (09:45 -0700)]
nir: Remove deref chain support from opt_peephole_select

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_tex
Jason Ekstrand [Tue, 27 Mar 2018 16:43:23 +0000 (09:43 -0700)]
nir: Remove deref chain support from lower_tex

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_wpos_ytransform
Jason Ekstrand [Tue, 27 Mar 2018 16:15:54 +0000 (09:15 -0700)]
nir: Remove deref chain support from lower_wpos_ytransform

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_wpos_center
Jason Ekstrand [Tue, 27 Mar 2018 16:14:56 +0000 (09:14 -0700)]
nir: Remove deref chain support from lower_wpos_center

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_system_values
Jason Ekstrand [Tue, 27 Mar 2018 16:08:31 +0000 (09:08 -0700)]
nir: Remove deref chain support from lower_system_values

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from remove_unused_varyings
Jason Ekstrand [Tue, 27 Mar 2018 14:56:49 +0000 (07:56 -0700)]
nir: Remove deref chain support from remove_unused_varyings

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Delete lower_io_types
Jason Ekstrand [Tue, 27 Mar 2018 14:37:18 +0000 (07:37 -0700)]
nir: Delete lower_io_types

It's only used by the ir3 stand-alone compiler and Rob said we could
delete it.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_phis_to_scalar
Jason Ekstrand [Tue, 27 Mar 2018 01:14:24 +0000 (18:14 -0700)]
nir: Remove deref chain support from lower_phis_to_scalar

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Convert lower_io to deref instructions
Jason Ekstrand [Tue, 27 Mar 2018 01:01:12 +0000 (18:01 -0700)]
nir: Convert lower_io to deref instructions

This deletes support for _var intrinsics and legacy deref chains in
favor of deref instructions.  The internals are also reworked a bit to
use deref instructions directly.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/lower_io: Convert atomic lowering to deref instructions
Jason Ekstrand [Tue, 27 Mar 2018 00:27:16 +0000 (17:27 -0700)]
nir/lower_io: Convert atomic lowering to deref instructions

No one is currently using so we can make this change irrespective of
driver.  We may use it again in i965 so it's best to pretend to keep it
working.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_global_vars_to_local
Jason Ekstrand [Tue, 27 Mar 2018 01:08:14 +0000 (18:08 -0700)]
nir: Remove deref chain support from lower_global_vars_to_local

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_clamp_color_outputs
Jason Ekstrand [Tue, 27 Mar 2018 00:21:08 +0000 (17:21 -0700)]
nir: Remove deref chain support from lower_clamp_color_outputs

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_alpha_test
Jason Ekstrand [Tue, 27 Mar 2018 00:06:51 +0000 (17:06 -0700)]
nir: Remove deref chain support from lower_alpha_test

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_atomics
Jason Ekstrand [Mon, 26 Mar 2018 23:46:09 +0000 (16:46 -0700)]
nir: Remove deref chain support from lower_atomics

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_clip_cull_distance_arrays
Jason Ekstrand [Mon, 26 Mar 2018 23:02:25 +0000 (16:02 -0700)]
nir: Remove deref chain support from lower_clip_cull_distance_arrays

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Remove deref chain support from lower_indirect_derefs
Jason Ekstrand [Mon, 26 Mar 2018 22:59:01 +0000 (15:59 -0700)]
nir: Remove deref chain support from lower_indirect_derefs

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Rework gather_info to entirely use deref instructions
Jason Ekstrand [Mon, 26 Mar 2018 22:53:17 +0000 (15:53 -0700)]
nir: Rework gather_info to entirely use deref instructions

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/vars_to_ssa: Rework to entirely use deref instructions
Jason Ekstrand [Mon, 26 Mar 2018 21:36:43 +0000 (14:36 -0700)]
nir/vars_to_ssa: Rework to entirely use deref instructions

This commit reworks nir_lower_vars_to_ssa to use deref instructions and
deref paths internally instead of deref chains.  We also drop support
for the old load/store/copy_var intrinsics.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/vars_to_ssa: Add an is_direct field to deref_node
Jason Ekstrand [Mon, 2 Apr 2018 20:51:02 +0000 (13:51 -0700)]
nir/vars_to_ssa: Add an is_direct field to deref_node

This makes us build the is_direct parameter as the nodes are constructed
rather than as we walk the chain.  This will be useful later.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agobroadcom/vc4: Remove deref chain support from nir_lower_txf_ms.
Eric Anholt [Mon, 9 Apr 2018 23:22:55 +0000 (16:22 -0700)]
broadcom/vc4: Remove deref chain support from nir_lower_txf_ms.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agost,ir3,radeonsi: push lower_deref_instrs back into driver
Rob Clark [Thu, 17 May 2018 19:04:08 +0000 (15:04 -0400)]
st,ir3,radeonsi: push lower_deref_instrs back into driver

vc4+vc5 is not really effected by the deref chain to deref instr
conversion, so it no longer needs this pass.  For others, now that
all the passes mesa/st uses are using deref instructions, push the
lowering to deref chains back into driver.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/lower_samplers: remove legacy version
Rob Clark [Tue, 15 May 2018 22:43:22 +0000 (18:43 -0400)]
nir/lower_samplers: remove legacy version

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: convert lower_samplers_as_deref to deref instructions
Rob Clark [Thu, 5 Apr 2018 23:59:54 +0000 (19:59 -0400)]
nir: convert lower_samplers_as_deref to deref instructions

This also removes the legacy version of lower_samplers.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agomesa/st: re-enable lower_io_to_elements()
Rob Clark [Thu, 17 May 2018 18:38:24 +0000 (14:38 -0400)]
mesa/st: re-enable lower_io_to_elements()

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: convert lower_io_arrays_to_elements to deref instructions
Rob Clark [Thu, 5 Apr 2018 17:21:55 +0000 (13:21 -0400)]
nir: convert lower_io_arrays_to_elements to deref instructions

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agomesa/st/nir: convert lower_builtins to deref instructions
Rob Clark [Thu, 5 Apr 2018 12:23:25 +0000 (08:23 -0400)]
mesa/st/nir: convert lower_builtins to deref instructions

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agomesa/st: temporarily disable lower_io_to_elements()
Rob Clark [Thu, 17 May 2018 18:22:01 +0000 (14:22 -0400)]
mesa/st: temporarily disable lower_io_to_elements()

Not required for correctness, and makes the order of converting passes
to deref instructions hard to get right for both prog_to_nir and
glsl_to_nir cases.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: convert lower_io_to_scalar to deref instructions
Rob Clark [Thu, 5 Apr 2018 18:24:33 +0000 (14:24 -0400)]
nir: convert lower_io_to_scalar to deref instructions

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agomove lower_deref_instrs
Rob Clark [Thu, 17 May 2018 14:37:37 +0000 (10:37 -0400)]
move lower_deref_instrs

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Use deref instructions in lower_constant_initializers
Jason Ekstrand [Fri, 16 Mar 2018 19:08:15 +0000 (12:08 -0700)]
nir: Use deref instructions in lower_constant_initializers

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/builder: Use deref instructions for load/store/copy_var
Jason Ekstrand [Mon, 26 Mar 2018 21:35:05 +0000 (14:35 -0700)]
nir/builder: Use deref instructions for load/store/copy_var

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoradv: Disable lower_io_to_temporaries during deref changes.
Bas Nieuwenhuizen [Sun, 3 Jun 2018 23:10:05 +0000 (01:10 +0200)]
radv: Disable lower_io_to_temporaries during deref changes.

Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Use derefs in nir_lower_samplers
Jason Ekstrand [Mon, 19 Mar 2018 17:53:45 +0000 (10:53 -0700)]
nir: Use derefs in nir_lower_samplers

We change glsl_to_nir to provide derefs for bot textures and samplers
while we're at it.  This makes the lowering much easier since we only
either replace sources or remove them.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/lower_samplers: Clean up function arguments
Jason Ekstrand [Thu, 15 Mar 2018 16:32:24 +0000 (09:32 -0700)]
nir/lower_samplers: Clean up function arguments

This little refactor makes us stop passing stage around and puts the
builder as the first parameter to some functions.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/lower_samplers: split out _legacy version for deref chains
Rob Clark [Tue, 15 May 2018 22:27:18 +0000 (18:27 -0400)]
nir/lower_samplers: split out _legacy version for deref chains

To simplify the transition, and make things bisectable, split out a
legacy copy or lower_samplers.  This way the i965 and gallium drivers
can independently switch over to deref instructions.

Since the lower_samplers_as_deref pass is only used by gallium drivers,
it can be converted in lock-step with moving the lower_deref_instrs
pass, and so does not need a corresponding _legacy clone.

This legacy pass will be removed in a future commit.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agointel/blorp: Stop setting tex->texture/sampler
Jason Ekstrand [Mon, 2 Apr 2018 23:48:59 +0000 (16:48 -0700)]
intel/blorp: Stop setting tex->texture/sampler

nir_tex_instr_create uses rzalloc so it's already NULL

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agointel/nir: Only lower load/store derefs
Jason Ekstrand [Fri, 23 Mar 2018 17:31:59 +0000 (10:31 -0700)]
intel/nir: Only lower load/store derefs

Everything else should already be handled.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agointel/fs: Use image_deref intrinsics instead of image_var
Jason Ekstrand [Fri, 23 Mar 2018 17:27:12 +0000 (10:27 -0700)]
intel/fs: Use image_deref intrinsics instead of image_var

Since we had to rewrite the deref walking loop anyway, I took the
opportunity to make it a bit clearer and more efficient.  In particular,
in the AoA case, we will now emit one minmax instead of one per array
level.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoanv/pipeline: Convert apply_pipeline_layout to deref instructions
Jason Ekstrand [Fri, 23 Mar 2018 06:25:07 +0000 (23:25 -0700)]
anv/pipeline: Convert apply_pipeline_layout to deref instructions

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoanv/apply_pipeline_layout: Simplify extract_tex_src_plane
Jason Ekstrand [Sun, 18 Mar 2018 04:37:36 +0000 (21:37 -0700)]
anv/apply_pipeline_layout: Simplify extract_tex_src_plane

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoanv/pipeline: Convert lower_multiview to deref instructions
Jason Ekstrand [Tue, 3 Apr 2018 00:46:36 +0000 (17:46 -0700)]
anv/pipeline: Convert lower_multiview to deref instructions

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoanv/pipeline: Convert YCbCr lowering to deref instructiosn
Jason Ekstrand [Fri, 23 Mar 2018 05:32:45 +0000 (22:32 -0700)]
anv/pipeline: Convert YCbCr lowering to deref instructiosn

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoanv/pipeline: Convert lower_input_attachments to deref instructions
Jason Ekstrand [Fri, 23 Mar 2018 05:15:51 +0000 (22:15 -0700)]
anv/pipeline: Convert lower_input_attachments to deref instructions

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoanv/pipeline: Do less deref instruction lowering
Jason Ekstrand [Fri, 23 Mar 2018 05:11:23 +0000 (22:11 -0700)]
anv/pipeline: Do less deref instruction lowering

This commit removes most of the deref instruction lowering.  Instead of
lowering early, we only lower textures and images and we only do so
right before any of the anv image lowering passes.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoradv: Remove image_var stores.
Bas Nieuwenhuizen [Fri, 11 May 2018 12:02:13 +0000 (14:02 +0200)]
radv: Remove image_var stores.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoradv: Use deref instructions for tex derefs in meta shaders.
Bas Nieuwenhuizen [Sun, 25 Mar 2018 11:10:07 +0000 (13:10 +0200)]
radv: Use deref instructions for tex derefs in meta shaders.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoac/nir: Add deref interp support.
Bas Nieuwenhuizen [Wed, 25 Apr 2018 16:57:46 +0000 (18:57 +0200)]
ac/nir: Add deref interp support.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoac/nir: Add shared atomic deref instr support.
Bas Nieuwenhuizen [Wed, 25 Apr 2018 16:22:02 +0000 (18:22 +0200)]
ac/nir: Add shared atomic deref instr support.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoradv: Gather info for deref instr based load/store.
Bas Nieuwenhuizen [Wed, 25 Apr 2018 15:07:16 +0000 (17:07 +0200)]
radv: Gather info for deref instr based load/store.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoac/nir: Add deref based var loads/stores.
Bas Nieuwenhuizen [Tue, 24 Apr 2018 22:08:39 +0000 (00:08 +0200)]
ac/nir: Add deref based var loads/stores.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoradv: Add shader info support for image deref instructions.
Bas Nieuwenhuizen [Sun, 25 Mar 2018 14:22:46 +0000 (16:22 +0200)]
radv: Add shader info support for image deref instructions.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoac/nir: Add deref support to image intrinsics.
Bas Nieuwenhuizen [Sun, 25 Mar 2018 13:03:01 +0000 (15:03 +0200)]
ac/nir: Add deref support to image intrinsics.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoac/nir: Implement derefs for integer gather4 lowering.
Bas Nieuwenhuizen [Fri, 11 May 2018 13:56:52 +0000 (15:56 +0200)]
ac/nir: Implement derefs for integer gather4 lowering.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoac/nir: Support deref instructions in tex instructions.
Bas Nieuwenhuizen [Wed, 21 Mar 2018 23:45:54 +0000 (00:45 +0100)]
ac/nir: Support deref instructions in tex instructions.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoac/nir: Support deref instructions in get_sampler_desc.
Bas Nieuwenhuizen [Wed, 21 Mar 2018 11:52:41 +0000 (12:52 +0100)]
ac/nir: Support deref instructions in get_sampler_desc.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agoac/nir: Implement the deref instr for shared memory.
Bas Nieuwenhuizen [Tue, 24 Apr 2018 22:45:33 +0000 (00:45 +0200)]
ac/nir: Implement the deref instr for shared memory.

v2: Store the result in ctx->ssa_defs.
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir,spirv: Rework function calls
Jason Ekstrand [Thu, 22 Mar 2018 23:41:18 +0000 (16:41 -0700)]
nir,spirv: Rework function calls

This commit completely reworks function calls in NIR.  Instead of having
a set of variables for the parameters and return value, nir_call_instr
now has simply has a number of sources which get mapped to load_param
intrinsics inside the functions.  It's up to the client API to build an
ABI on top of that.  In SPIR-V, out parameters are handled by passing
the result of a deref through as an SSA value and storing to it.

This virtue of this approach can be seen by how much it allows us to
delete from core NIR.  In particular, nir_inline_functions gets halved
and goes from a fairly difficult pass to understand in detail to almost
trivial.  It also simplifies spirv_to_nir somewhat because NIR functions
never were a good fit for SPIR-V.

Unfortunately, there is no good way to do this without a mega-commit.
Core NIR and SPIR-V have to be changed at the same time.  This also
requires changes to anv and radv because nir_inline_functions couldn't
handle deref instructions before this change and can't work without them
after this change.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agospirv/cfg: Make the builder fully capable for both walks
Jason Ekstrand [Fri, 23 Mar 2018 01:48:01 +0000 (18:48 -0700)]
spirv/cfg: Make the builder fully capable for both walks

We were only initializing vtn_builder::func for the pre-walk where we
build the CFG.  We were only initializing the nir_builder for the later
walk through the instructions even though were were setting b->cursor
for the pre-walk.  Let's set both both places so that everything is
consistent.  This useful because we handle OpFunctionParameter in the
pre-walk and we're going to need to be able to emit instructions.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agospirv: Record the type of functions
Jason Ekstrand [Fri, 23 Mar 2018 01:44:06 +0000 (18:44 -0700)]
spirv: Record the type of functions

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agospirv: Update vtn_pointer_to/from_ssa to handle deref pointers
Jason Ekstrand [Thu, 22 Mar 2018 23:39:54 +0000 (16:39 -0700)]
spirv: Update vtn_pointer_to/from_ssa to handle deref pointers

Now that pointers can be derefs and derefs just produce SSA values, we
can convert any pointer to/from SSA.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agospirv: Allow pointers to have a deref at the base
Jason Ekstrand [Fri, 23 Mar 2018 15:22:54 +0000 (08:22 -0700)]
spirv: Allow pointers to have a deref at the base

Previously, pointers fell into two categories: index/offset for UBOs,
SSBOs, etc. and var + access chain for logical pointers.  This commit
adds another logical pointer mode that's deref + access chain.

It's tempting to think that we can just replace variable-based pointers
with deref-based or at least replace the access chain with a deref
chain.  Unfortunately, there are a few sticky bits that prevent this:

 1) We can't return deref-based pointers from OpVariable because those
    opcodes may come outside of a function so there's no place to emit
    the deref instructions.

 2) We can't always use variable-based pointers because we may not
    always know the variable.  (We do now, but he upcoming function
    rework will take that option away.)

 3) We also can't replace the access chain struct with a deref.  Due to
    the re-ordering we do in order to handle loop continues, the derefs
    we would emit as part of OpAccessChain may not dominate their uses.
    We normally fix this up with nir_repair_ssa but that generates phi
    nodes which we don't want in the middle of our deref chains.

All in all, we have no real better option than to support partial access
chains while also re-emitting the deref instructions on the spot.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agospirv: Clean up vtn_pointer_to_offset
Jason Ekstrand [Thu, 22 Mar 2018 16:07:01 +0000 (09:07 -0700)]
spirv: Clean up vtn_pointer_to_offset

Now that push constants are using on-the-fly offsets, we no longer need
to handle access chains in vtn_pointer_to_offset.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agospirv: Make push constants an offset-based pointer
Jason Ekstrand [Thu, 22 Mar 2018 15:50:34 +0000 (08:50 -0700)]
spirv: Make push constants an offset-based pointer

Push constants have been a weird edge-case for a while in that they have
explitic offsets but we've been internally building access chains for
them.  This mostly works but it means that passing pointers to push
constants through as function arguments is broken.  The easy thing to do
for now is to just treat them like UBOs or SSBOs only without a block
index.  This does loose a bit of information since we no longer have an
accurate access range and any indirect access will look like it could
read the whole block.  Unfortunately, there's not much we can do about
that.  Once NIR derefs get a bit more powerful, we can plumb these
through as derefs and be able to reason about them again.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agospirv: Use NIR per-member splitting
Jason Ekstrand [Thu, 22 Mar 2018 00:30:22 +0000 (17:30 -0700)]
spirv: Use NIR per-member splitting

Before, we were doing structure splitting in spirv_to_nir.
Unfortunately, this doesn't really work when you think about passing
struct pointers into functions.  Doing it later in NIR is a much better
plan.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir/spirv: Pass nir_variable_data into apply_var_decoration
Jason Ekstrand [Thu, 22 Mar 2018 00:24:07 +0000 (17:24 -0700)]
nir/spirv: Pass nir_variable_data into apply_var_decoration

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agonir: Add a concept of per-member structs and a lowering pass
Jason Ekstrand [Wed, 21 Mar 2018 23:48:35 +0000 (16:48 -0700)]
nir: Add a concept of per-member structs and a lowering pass

This adds a concept of "members" to a variable with an interface type.
It allows you to specify the full variable data for each member of the
interface instead of once for the variable.  We also add a lowering pass
to lower those variables to a sequence of variables and rewrite all the
derefs accordingly.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agospirv: Use deref instructions for most variables
Jason Ekstrand [Fri, 16 Mar 2018 20:35:59 +0000 (13:35 -0700)]
spirv: Use deref instructions for most variables

The only thing still using old-school drefs are function calls.

Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
5 years agost/nir: Move lower_deref_instrs later
Jason Ekstrand [Tue, 20 Mar 2018 19:28:35 +0000 (12:28 -0700)]
st/nir: Move lower_deref_instrs later

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>