Commit Graph

99 Commits

Author SHA1 Message Date
Connor Abbott c68ea960a7 ir3, tu: Add compiler flag for robust UBO behavior
This needs to be part of the compiler because it's the only piece that
we always have access to in all the places ir3_optimize_loop() is
called, and it's only enabled for the whole Vulkan device. Right now
it's just used for constraining vectorization, but the next commit adds
another use.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7573>
2021-04-15 16:05:11 +02:00
Danylo Piliaiev 0709a6b363 turnip: fix alignment of non-32b types in workgroup memory
Fixes tests:
 dEQP-VK.spirv_assembly.instruction.compute.workgroup_memory.float16

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10039>
2021-04-05 17:31:11 +00:00
Danylo Piliaiev ce1a381e57 turnip: enable VK_KHR_16bit_storage on A650
A650 can use the same SSBO descriptor for both 32-bit and 16-bit access,
which makes it easy to enable this extension.

Passes tests that run under:

dEQP-VK.spirv_assembly.instruction.*.16bit_storage.*

Rebased and modified commit from Jonathan Marek.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9840>
2021-04-01 17:51:07 +00:00
Jonathan Marek 14acc64c3b turnip: enable VK_KHR_shader_float16_int8
ir3 supports 16-bit floats, so we can enable this.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9840>
2021-04-01 17:51:07 +00:00
Jonathan Marek 3777ecdf11 turnip: implement VK_KHR_shader_float_controls
This matches the blob and doesn't require actually implementing controls
since the supported modes are just what the HW does.

Passes tests under:

dEQP-VK.spirv_assembly.*.float_controls.*

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9840>
2021-04-01 17:51:07 +00:00
Danylo Piliaiev 2087168a30 turnip,ir3: account for dispatch group offsets
Fixes tests:
 dEQP-VK.compute.device_group.dispatch_base

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9339>
2021-03-29 14:31:44 +03:00
Hyunjun Ko d9fcf5de55 turnip: Enable nonuniform descriptor indexing
Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9125>
2021-03-17 01:09:30 +00:00
Danylo Piliaiev b8ca39a80d turnip: implement intrinsic_vulkan_resource_reindex
Descriptor arrays are continuous, so it's just an addition of offset.

Fixes test:
 dEQP-VK.spirv_assembly.instruction.compute.variable_pointers.dynamic_offset.select_descriptor_array

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9495>
2021-03-15 23:56:26 +00:00
Mike Blumenkrantz 71b17149e8 tu: use common interfaces for shader modules
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9508>
2021-03-15 21:47:44 +00:00
Danylo Piliaiev ae3b95daa7 turnip: lower device index to zero
Vulkan 1.1 has VK_KHR_device_group and VK_KHR_device_group_creation
promoted to core, thus we should handle DeviceIndex built-in.

While we are here, also add these extensions to the extensions list,
even though they are not doing anything useful.

Fixes test:
 dEQP-VK.compute.device_group.device_index

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9516>
2021-03-11 21:12:52 +00:00
Dave Airlie 8027a7ba8a shader_info: convert textures_used to a bitset.
For now keep it a bitset of 1 32-bit dword.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9456>
2021-03-10 06:16:09 +10:00
Jason Ekstrand e20e85f01e nir: Make nir_ssa_def_rewrite_uses_after take an SSA value
This replaces the new_src parameter of nir_ssa_def_rewrite_uses_after()
with an SSA def, and rewrites all the users as needed.

Acked-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9383>
2021-03-08 16:59:55 +00:00
Jason Ekstrand 117668b811 nir: Make nir_ssa_def_rewrite_uses take an SSA value
This commit replaces the new_src parameter of nir_ssa_def_rewrite_uses()
with an SSA def, removes nir_ssa_def_rewrite_uses_ssa(), and rewrites
all the users as needed.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Alyssa Rosenzweig <alyssa@collabora.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9383>
2021-03-08 16:59:55 +00:00
Jason Ekstrand 13a0ee8a51 nir: Add and use a new nir_ssa_def_rewrite_uses_src helper
This is currently an alias for nir_ssa_def_rewrite_uses but we move all
the instances which used it to write a non-SSA source to the newly named
helper.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Alyssa Rosenzweig <alyssa@collabora.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9383>
2021-03-08 16:59:55 +00:00
Christian Gmeiner 32bd47f6fa tu: use intrinsic builders
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8295>
2021-01-06 14:34:41 +00:00
Samuel Iglesias Gonsálvez 84136d78e6 turnip: fix cube map array image size calculation
imageSize() expects the last component of the return value to be the
number of layers in the texture array. In the case of cube map array,
it will return a ivec3, with the third component being the number of
layer-faces.

Fixes: dEQP-VK.image.image_size.cube_array.*

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8087>
2020-12-18 06:43:07 +01:00
Eric Anholt 1882a02d83 tu: Make sure spirv_to_nir knows we support imageStorageWithoutFormat.
You have to set these flags along with the extension, or you get a bunch
of warnings from spirv-to-nir.

Fixes: e781cc7025 ("tu: Expose shaderStorageImage*WithoutFormat")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7465>
2020-11-05 22:34:32 +00:00
Jason Ekstrand 3f0a29fffb nir/builder: Add a nir_ieq_imm helper
This shows up surprisingly often.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6332>
2020-11-03 22:18:28 +00:00
Connor Abbott 841f736824 tu: Support geometryStreams
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6962>
2020-11-03 10:14:45 +00:00
Connor Abbott b4224c39e1 tu: Implement clip/cull distances
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6959>
2020-10-23 11:09:18 +00:00
Jason Ekstrand 92a594b154 spirv: Delete the legacy offset/index UBO/SSBO lowering
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5275>
2020-09-30 07:20:39 +00:00
Jason Ekstrand d3fa7451a6 anv,radv,tu,val: Call nir_lower_io for push constants
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5275>
2020-09-30 07:20:39 +00:00
Connor Abbott 8d2757789a tu: Enable multi-position output
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6515>
2020-09-29 16:16:05 +00:00
Connor Abbott 6982e8510b ir3, tu: Run optimization loop twice
This call to ir3_optimize_nir() mirrors what st/mesa does for us in
Gallium, and will be necessary for cross-stage linking and the multiview
lowering.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6515>
2020-09-29 16:16:05 +00:00
Connor Abbott 41a5a21858 tu: Refactor shader compilation flow
In order to do cross-stage linking, we'll need to split out SPIR-V->NIR
and NIR finalization, so that we can do a round of linking in between.
The multiview lowering pass also assumes that it sits between two
optimization loops, which in anv are the pre-linking optimizations and
post-linking finalization.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6515>
2020-09-29 16:16:05 +00:00
Jason Ekstrand 9750164c09 nir: Rename get_buffer_size to get_ssbo_size
This makes it explicit that this intrinsic is only for SSBOs.  For the
v3dv driver, we'll be adding a get_ubo_size intrinsic and we want to be
able to distinguish between the two.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6812>
2020-09-22 13:34:12 +00:00
Jonathan Marek efff734220 turnip: multiViewport and VK_EXT_shader_viewport_index_layer
Passes at least:
dEQP-VK.dynamic_state.vp_state.viewport_array
dEQP-VK.draw.shader_viewport_index.*
dEQP-VK.draw.shader_layer.*

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5832>
2020-09-15 16:18:45 +00:00
Jonathan Marek 3b144d5fb8 turnip: fix the type of tu_shader_module code field, delete unused sha1
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6664>
2020-09-09 17:01:51 +00:00
Jason Ekstrand 38a83a3048 nir/lower_indirect_derefs: Add a threshold
Instead of always lowering everything, we add a threshold such that if
the total indirected array size (AoA size) is above that threshold, it
won't lower.  It's assumed that the driver will sort things out somehow
by, for instance, lowering to scratch.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5909>
2020-09-03 14:26:49 +00:00
Jesse Natalie d3faac7a15 nir: Add options to nir_lower_compute_system_values to control compute ID base lowering
If no options are provided, existing intrinsics are used.
If the lowering pass indicates there should be offsets used for global
invocation ID or work group ID, then those instructions are lowered to
include the offset.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5891>
2020-08-21 22:07:05 +00:00
Jesse Natalie 2e1df6a17f nir: Move compute system value lowering to a separate pass
The actual variable -> intrinsic lowering stays where it is, but
ops which convert one intrinsic to be implemented in terms of
another have moved.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5891>
2020-08-21 22:07:05 +00:00
Connor Abbott b708a1acb8 tu: Enable VK_KHR_multiview
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5720>
2020-08-20 19:21:18 +00:00
Connor Abbott c0c7dbd103 tu: Implement multiview pipeline state
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5720>
2020-08-20 19:21:18 +00:00
Connor Abbott 76f711d09d tu: Use an input for the layer when lowering input attachments
Also remove a hack that's no longer needed. This should fix input
attachments with layered rendering.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5719>
2020-08-19 16:36:43 +00:00
Connor Abbott d243bf1032 nir/lower_input_attachments: Support loading layer id as an input
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5719>
2020-08-19 16:36:43 +00:00
Connor Abbott e72895767b nir/lower_input_attachments: Refactor to use an options struct
While we're at it, fold the details of how to load the fragcoord into
load_fragcoord().

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5719>
2020-08-19 16:36:43 +00:00
Jason Ekstrand caab46c1e9 nir: Take a shader and variable mode in nir_assign_io_var_locations
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
2020-07-29 17:38:58 +00:00
Jason Ekstrand 196db51fc2 anv,turnip,radv,clover,glspirv: Run nir_copy_prop before nir_opt_deref
We're about to make the SPIR-V -> NIR path generate a bit more complex
SSA chains for certain derefs.  This will ensure we don't regress anyone
when we start making vec2's of derefs.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5278>
2020-07-23 22:43:21 -05:00
Connor Abbott b5a48a948a tu: Enable VK_EXT_shader_stencil_export
This passes the grand total of 3 CTS tests (2 actually enabled due to
missing D32_SFLOAT_S8_UINT support) under
dEQP-VK.pipeline.shader_stencil_export.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5936>
2020-07-16 20:49:20 +00:00
Hyunjun Ko 5d3fdbc52b turnip: Use the common base object type and struct.
v2. Define new helper function to avoid duplicated a pair of function calls.
v3. Move new helper functions to vk_object.h and call them.
v4. Merge 2 commits to use commomn base object type and struct into one.

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5539>
2020-07-14 02:48:30 +00:00
Connor Abbott 7682c887b3 tu: Enable KHR_variable_pointers
Passes dEQP-VK.spirv_assembly.instruction.graphics.variable_pointers.*
and dEQP-VK.spirv_assembly.instruction.compute.variable_pointers.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5684>
2020-07-06 22:48:57 +00:00
Connor Abbott 9aec89ead3 tu: Rewrite variable lowering
Don't lower to offsets, instead use nir_lower_explicit_io here and
use actual pointers for UBO's and SSBO's. This makes
KHR_variable_pointers trivial. This also fixes asserts with shared
variables, which are now supposed to be lowered with
nir_lower_explicit_io.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5684>
2020-07-06 22:48:57 +00:00
Jonathan Marek b76c6dcbc5 freedreno/ir3: fix/rework tess levels
The previous version assumes tess level outputs will only be written once
in the shader, however its not possible to guarantee that.

It also assumes all invocations will write all the levels, which is also
not guaranteed.

This is required to fix the "tesselation" and "terraintessellation" demos
with turnip.

The comment about nir_lower_io_to_temporaries in lower_tess_ctrl_block is
removed because nir_lower_io_to_temporaries specifically skips TESS_CTRL
shaders so the comment doesn't make sense.

The split load for tess levels workaround is removed, the new version only
has scalar access unless if ever gets vectorized.

This sets NIR_COMPACT_ARRAYS cap to avoid the glsl tess vec lowering with
gallium. It seems this will also disable "LowerCombinedClipCullDistance",
which I'm not sure was needed or not.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5744>
2020-07-06 08:48:06 -04:00
Rob Clark f1ab57359c freedreno/ir3: move finalize_nir to pscreen hook
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5372>
2020-06-26 08:43:22 -07:00
Jonathan Marek 62de79ac44 turnip: implement VK_KHR_shader_draw_parameters
Note: going by the blob, VFD_INDEX_OFFSET/FD_INSTANCE_START_OFFSET seem
completely unused by indirect draws, so this changes them to only be set
for non-indirect draws (and moves them to the vs_params draw state).

Passes dEQP-VK.draw.shader_draw_parameters.*

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5635>
2020-06-25 15:57:45 +00:00
Brian Ho b09e690f3b turnip: Lower shaders for tessellation
To enable lowering of tess-related shaders, this commit sets the
tessellation primitive field of the ir3_shader_key. In addition,
this commit sets various tessellation flags for
spirv_to_nir configuration.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5059>
2020-06-22 14:35:45 +00:00
Jonathan Marek 159a1300ce turnip: input attachment descriptor set rework
Implement GMEM input attachments by using non-bindless texture state which
is emitted at the start of every subpass.

This achieves two things:
* More vulkan-like CmdBindDescriptorSets
* Fixing secondary command buffer input attachments with GMEM

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5446>
2020-06-17 15:32:30 +00:00
Connor Abbott a3464c567c tu: Actually remove dead variables after io lowering
I forgot that their derefs would still be lying around, so we need to
eliminate them first.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5519>
2020-06-17 14:36:50 +00:00
Connor Abbott 568e06b3a6 tu: Set num_components to 0 when building bindless intrinsics
Fixes: 167fa288 (" nir/validate: validate intr->num_components")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5520>
2020-06-17 15:49:40 +02:00
Connor Abbott 6fcbce3b99 tu: Remove tu_shader_compile_options
The only two fields were always true, and I don't think we'd ever have
use for them. If we want to disable optimizations then we'd need a
different approach, and I don't even know what include_binning_pass was
for.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5500>
2020-06-17 13:13:05 +00:00