platform/upstream/mesa.git
3 years agomesa: don't save gl_shared_state in glPushAttrib
Marek Olšák [Sun, 20 Dec 2020 00:12:48 +0000 (19:12 -0500)]
mesa: don't save gl_shared_state in glPushAttrib

glPushAttrib only saves values and names. It doesn't save objects.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: partially skip glPush/PopAttrib for MSAA textures and texture buffers
Marek Olšák [Sat, 19 Dec 2020 08:21:25 +0000 (03:21 -0500)]
mesa: partially skip glPush/PopAttrib for MSAA textures and texture buffers

This is based on the GL 4.6 Compatibility profile spec. Some fields just
don't have to be restored. This decreases CPU overhead.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: only pop states in glPopAttrib that have been changed since glPushAttrib
Marek Olšák [Sat, 19 Dec 2020 07:46:03 +0000 (02:46 -0500)]
mesa: only pop states in glPopAttrib that have been changed since glPushAttrib

PopAttribState records all state changes. glPopAttrib uses it to skip
restoring state groups that haven't been changed.

This eliminates a lot of glPopAttrib overhead.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: optimize out _NEW_ALL in glPopAttrib(GL_ENABLE_BIT)
Marek Olšák [Sat, 19 Dec 2020 07:41:32 +0000 (02:41 -0500)]
mesa: optimize out _NEW_ALL in glPopAttrib(GL_ENABLE_BIT)

I reviewed all affected states and this if the minimum attrib mask.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: fix trivial bugs in glPopAttrib
Marek Olšák [Sat, 19 Dec 2020 07:40:15 +0000 (02:40 -0500)]
mesa: fix trivial bugs in glPopAttrib

There were quite a few. Hopefully the comments make it clear.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: for every state change, remember states we changed for glPopAttrib
Marek Olšák [Sat, 19 Dec 2020 06:37:40 +0000 (01:37 -0500)]
mesa: for every state change, remember states we changed for glPopAttrib

The idea is to restore only those states in glPopAttrib that have been
changed. This will reduce glPopAttrib overhead a lot.

This is based on the state tables in the OpenGL 4.6 Compatibility Profile
specification and many extension specifications.

This code might superfluously flag GL_TEXTURE_BIT for texture and
sampler functions that don't have effect on states popped by glPopAttrib,
but I don't wanna test my luck and make a mistake. Thus,
if _NEW_TEXTURE_OBJECT if flagged, GL_TEXTURE_BIT is usually flagged too.

This has no effect on glPopAttrib yet. glPopAttrib will use this in a later
commit. This only adds attrib masks into FLUSH_VERTICES based on specs.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: flush glBegin/End before changing GL_DEPTH_STENCIL_TEXTURE_MODE
Marek Olšák [Sat, 19 Dec 2020 06:48:40 +0000 (01:48 -0500)]
mesa: flush glBegin/End before changing GL_DEPTH_STENCIL_TEXTURE_MODE

Fixes: 23e81b93bbe3 "mesa: Add core API support for GL_ARB_stencil_texturing (from 4.3)."

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: fix glPopAttrib for many texture fields
Marek Olšák [Sat, 19 Dec 2020 06:19:35 +0000 (01:19 -0500)]
mesa: fix glPopAttrib for many texture fields

Move the fields that should be restored by glPopAttrib into the Attrib
structure, which is the only portion of texture objects that is restored
by glPopAttrib. Also moves fields that should not be restored by glPopAttrib
out of the Attrib structure.

This is based on the GL 4.6 Compatibility spec.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: don't push/pop gl_texture_object::Target
Marek Olšák [Sun, 20 Dec 2020 00:33:40 +0000 (19:33 -0500)]
mesa: don't push/pop gl_texture_object::Target

This field is immutable because each texture unit is an array of texture
target slots and only matching targets can be bound into each slot.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: optimize glPopAttrib(GL_VIEWPORT_BIT)
Marek Olšák [Sat, 19 Dec 2020 08:14:01 +0000 (03:14 -0500)]
mesa: optimize glPopAttrib(GL_VIEWPORT_BIT)

We can just copy the variables because they are already clamped
to ctx->Const limits.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: optimize most _mesa_ActiveTexture calls in glPopAttrib
Marek Olšák [Sat, 19 Dec 2020 08:04:45 +0000 (03:04 -0500)]
mesa: optimize most _mesa_ActiveTexture calls in glPopAttrib

_mesa_ActiveTexture changes CurrentUnit and the texture matrix stack
if the matrix mode is a texture matrix. In these cases, the texture matrix
stack is not touched.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agomesa: remove/replace FLUSH_VERTICES when it doesn't do anything
Marek Olšák [Sat, 19 Dec 2020 06:41:04 +0000 (01:41 -0500)]
mesa: remove/replace FLUSH_VERTICES when it doesn't do anything

In _mesa_PopAttrib, we call FLUSH_VERTICES at the beginning, so we don't
need to do it again.

In the MultiMode functions, we call standard Draw functions
using the dispatch, which do the flushing by themselves.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>

3 years agoradeonsi: precompute NGG cull flags in si_create_rs_state
Marek Olšák [Thu, 14 Jan 2021 12:43:19 +0000 (07:43 -0500)]
radeonsi: precompute NGG cull flags in si_create_rs_state

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: prefetch VB descriptors right after uploading
Marek Olšák [Mon, 11 Jan 2021 20:14:40 +0000 (15:14 -0500)]
radeonsi: prefetch VB descriptors right after uploading

This skips the logic that sets and checks prefetch_L2_mask.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: set VB user SGPRs in si_upload_vertex_buffer_descriptors
Marek Olšák [Mon, 11 Jan 2021 20:02:48 +0000 (15:02 -0500)]
radeonsi: set VB user SGPRs in si_upload_vertex_buffer_descriptors

so that we don't have to enter the state emit loop and invoke the more
complicated function si_emit_graphics_shader_pointers.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: reorganize si_draw_vbo for lower register pressure (part 2)
Marek Olšák [Sun, 10 Jan 2021 02:43:33 +0000 (21:43 -0500)]
radeonsi: reorganize si_draw_vbo for lower register pressure (part 2)

Move statements that use the least number of local variables as close
to the beginning as possible. Also move local variables closer to their use.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: reorganize si_draw_vbo for lower register pressure (part 1)
Marek Olšák [Sun, 10 Jan 2021 02:43:33 +0000 (21:43 -0500)]
radeonsi: reorganize si_draw_vbo for lower register pressure (part 1)

Move statements that use the least number of local variables as close
to the beginning as possible. Also move local variables closer to their use.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: optimize si_emit_prefetch_L2 when it's split
Marek Olšák [Sat, 9 Jan 2021 22:41:17 +0000 (17:41 -0500)]
radeonsi: optimize si_emit_prefetch_L2 when it's split

When using the prefetch with VS_ONLY=true followed by VS_ONLY=false,
we tested the VS_ONLY bits in the mask when executing VS_ONLY=false where
the bits were always 0. It's also useless to clear the prefetch mask when
VS_ONLY=true.

This commit skips those tests by splitting the function properly using
BEFORE_DRAW and AFTER_DRAW template parameters.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: don't check for redundant and NULL states in si_emit_all_states
Marek Olšák [Sat, 9 Jan 2021 13:12:38 +0000 (08:12 -0500)]
radeonsi: don't check for redundant and NULL states in si_emit_all_states

All places set dirty_states correctly now.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: delete si_pm4_delete_state
Marek Olšák [Wed, 27 Jan 2021 23:06:57 +0000 (18:06 -0500)]
radeonsi: delete si_pm4_delete_state

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: move si_pm4_delete_state logic into si_pm4_free_state
Marek Olšák [Sat, 9 Jan 2021 12:55:59 +0000 (07:55 -0500)]
radeonsi: move si_pm4_delete_state logic into si_pm4_free_state

also clear dirty_states.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: mark shader_pointers dirty once outside the upload descriptors loop
Marek Olšák [Tue, 12 Jan 2021 06:30:53 +0000 (01:30 -0500)]
radeonsi: mark shader_pointers dirty once outside the upload descriptors loop

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoradeonsi: optimize no-op cases in si_upload_shader_descriptors
Marek Olšák [Tue, 12 Jan 2021 06:29:28 +0000 (01:29 -0500)]
radeonsi: optimize no-op cases in si_upload_shader_descriptors

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agoac,radeonsi: track memory usage in KB to reduce types from uint64 to uint32
Marek Olšák [Sun, 10 Jan 2021 05:29:01 +0000 (00:29 -0500)]
ac,radeonsi: track memory usage in KB to reduce types from uint64 to uint32

Decreasing the time spent in radeon_cs_memory_below_limit is the motivation.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8794>

3 years agodocs: update calendar for 21.0.0-rc3
Dylan Baker [Sat, 30 Jan 2021 04:14:07 +0000 (20:14 -0800)]
docs: update calendar for 21.0.0-rc3

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

3 years agodocs: update calendar for 21.0.0-rc2
Dylan Baker [Sat, 30 Jan 2021 04:13:58 +0000 (20:13 -0800)]
docs: update calendar for 21.0.0-rc2

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

3 years agodocs: update calendar and link releases notes for 20.3.4
Dylan Baker [Sat, 30 Jan 2021 04:13:33 +0000 (20:13 -0800)]
docs: update calendar and link releases notes for 20.3.4

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

3 years agodocs: Add sha256sum for 20.3.4
Dylan Baker [Sat, 30 Jan 2021 04:11:41 +0000 (20:11 -0800)]
docs: Add sha256sum for 20.3.4

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

3 years agodocs: add release notes for 20.3.4
Dylan Baker [Fri, 29 Jan 2021 18:12:48 +0000 (10:12 -0800)]
docs: add release notes for 20.3.4

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

3 years agospirv: Store SPIR-V version of the module
Caio Marcelo de Oliveira Filho [Mon, 11 Jan 2021 19:51:24 +0000 (11:51 -0800)]
spirv: Store SPIR-V version of the module

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8786>

3 years agospirv: Don't remove dead variables in `create_library` mode
Caio Marcelo de Oliveira Filho [Thu, 21 Jan 2021 10:35:43 +0000 (02:35 -0800)]
spirv: Don't remove dead variables in `create_library` mode

The issues fixed by the removal happen when a module has multiple
entry points and conflicting global variables.  Neither conditions are
expected in a library.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8786>

3 years agospirv: Don't bother counting num_images/num_textures
Caio Marcelo de Oliveira Filho [Tue, 12 Jan 2021 17:21:07 +0000 (09:21 -0800)]
spirv: Don't bother counting num_images/num_textures

Not only these are recalculated in nir_shader_gather_info, but
currently they are also counting all the images / textures in the
module instead of in the shader (entrypoint).

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8786>

3 years agomesa/st: Allocate the gl_context with 16-byte alignment.
Eric Anholt [Fri, 29 Jan 2021 17:59:34 +0000 (09:59 -0800)]
mesa/st: Allocate the gl_context with 16-byte alignment.

The _ModelProjectMatrix matrix embedded inside has members inside of it
marked as 16-byte aligned, and so the context also has to be 16-byte
aligned or access to those members would be invalid.  I believe the
compiler used this to use better 16-byte-aligned load/stores to other
members of the context, breaking when the context's alignment was only 8
(as normal mallocs guarantee).

Fixes: 3175b63a0dfa ("mesa: don't allocate matrices with malloc")
Tested-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8783>

3 years agolavapipe: add missing loader interface negoitation
Dave Airlie [Thu, 28 Jan 2021 20:32:57 +0000 (06:32 +1000)]
lavapipe: add missing loader interface negoitation

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8769>

3 years agomicrosoft/compiler: Make resource_state_manager only build with_gallium_d3d12
Michael Tang [Fri, 29 Jan 2021 20:48:43 +0000 (12:48 -0800)]
microsoft/compiler: Make resource_state_manager only build with_gallium_d3d12

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8785>

3 years agoCI: windows: Force using LLVM 12
Benjamin Tissoires [Fri, 29 Jan 2021 13:30:23 +0000 (14:30 +0100)]
CI: windows: Force using LLVM 12

LLVM is moving to the 13 release, but LLVM-SPIRV is still so in the past.
Given that LLVM 12.0.0 is still not out (we are at 12.0.0-rc1 today),
use the `release/12.x` branch for LLVM.

We should also tag LLVM-SPIRV, but... it seems that they haven't caught up
yet, so keep using the master branch, but add a note for a future
committer.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8740>

3 years agoCI: windows: split the layers to meet new registry requirements
Benjamin Tissoires [Wed, 27 Jan 2021 14:17:28 +0000 (15:17 +0100)]
CI: windows: split the layers to meet new registry requirements

The new registry caching in place for registry.fd.o can not handle layers
bigger than 5 GB. The last layer we used to build on windows was 5.2 GB,
meaning that the upload would fail.

Split the layers by calling multiple `RUN`, hoping that the size will be
roughly split between those steps if we have a special layer for VS2019.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8740>

3 years agoCI: windows: augment the timeout of building the windows container
Benjamin Tissoires [Wed, 27 Jan 2021 14:21:37 +0000 (15:21 +0100)]
CI: windows: augment the timeout of building the windows container

https://gitlab.freedesktop.org/mesa/mesa/-/jobs/6898838 failed at
uploading the containers but got kicked out right before being able to
give us a valid error.

Bump the timeout for windows container builds, to not have this
unfortunate situation.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8740>

3 years agoglsl: support 64bit integer loop iterators
Mike Blumenkrantz [Mon, 26 Oct 2020 14:47:37 +0000 (10:47 -0400)]
glsl: support 64bit integer loop iterators

this was crashing due to the assumption that non-32bit integer values must be
floats

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7316>

3 years agopan/bi: Add packing format tests
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:31:34 +0000 (13:31 -0500)]
pan/bi: Add packing format tests

These are based on reference outputs generated by the blob.

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

3 years agopan/bi: Test pack_sync
Alyssa Rosenzweig [Tue, 29 Dec 2020 16:29:45 +0000 (11:29 -0500)]
pan/bi: Test pack_sync

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

3 years agopan/bi: Test pack_tuple_bits
Alyssa Rosenzweig [Tue, 29 Dec 2020 16:18:02 +0000 (11:18 -0500)]
pan/bi: Test pack_tuple_bits

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

3 years agopan/bi: Test pack_upper
Alyssa Rosenzweig [Tue, 29 Dec 2020 16:00:31 +0000 (11:00 -0500)]
pan/bi: Test pack_upper

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

3 years agopan/bi: Test pack_literal
Alyssa Rosenzweig [Tue, 29 Dec 2020 15:56:08 +0000 (10:56 -0500)]
pan/bi: Test pack_literal

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

3 years agopan/bi: Add packing unit test group
Alyssa Rosenzweig [Tue, 29 Dec 2020 15:35:11 +0000 (10:35 -0500)]
pan/bi: Add packing unit test group

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

3 years agopan/bi: Pack multiple tuples per clause
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:43:37 +0000 (13:43 -0500)]
pan/bi: Pack multiple tuples per clause

Use all of the new helpers to pick formats and use them.

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

3 years agopan/bi: Calculate pos for constant packing
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:42:44 +0000 (13:42 -0500)]
pan/bi: Calculate pos for constant packing

We do not yet support multiple (format 12 quadword) constants per clause
but this is a step in the right direction.

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

3 years agopan/bi: Add pack_format helper
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:41:06 +0000 (13:41 -0500)]
pan/bi: Add pack_format helper

Packs a single quadword of a clause with a particular format and
parameters.

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

3 years agopan/bi: Add subword 4 or 7 pack
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:40:50 +0000 (13:40 -0500)]
pan/bi: Add subword 4 or 7 pack

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

3 years agopan/bi: Add subword 5/6 pack
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:40:31 +0000 (13:40 -0500)]
pan/bi: Add subword 5/6 pack

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

3 years agopan/bi: Add tuple/embedded constant pack
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:39:59 +0000 (13:39 -0500)]
pan/bi: Add tuple/embedded constant pack

Used for the first 4 subwords.

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

3 years agopan/bi: Add bi_pack_sync
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:39:28 +0000 (13:39 -0500)]
pan/bi: Add bi_pack_sync

The type/sync byte, also known as the tag.

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

3 years agopan/bi: Add bi_pack_tuple_bits
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:38:23 +0000 (13:38 -0500)]
pan/bi: Add bi_pack_tuple_bits

More general than the top 3 bit special case. There's some serious
complication around 78-bit shifting but I digress.

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

3 years agopan/bi: Add bi_pack_upper
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:37:51 +0000 (13:37 -0500)]
pan/bi: Add bi_pack_upper

Top 3-bits, found e.g. in the tag.

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

3 years agopan/bi: Add bi_pack_literal
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:37:11 +0000 (13:37 -0500)]
pan/bi: Add bi_pack_literal

Identifies formats.

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

3 years agopan/bi: Move bi_packed_tuple to compiler.h
Alyssa Rosenzweig [Wed, 6 Jan 2021 18:36:15 +0000 (13:36 -0500)]
pan/bi: Move bi_packed_tuple to compiler.h

To be used for pack prototype.

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

3 years agopan/bi: Add clause encodings as a table
Alyssa Rosenzweig [Tue, 29 Dec 2020 12:51:29 +0000 (07:51 -0500)]
pan/bi: Add clause encodings as a table

We would rather not type out all of the packs by hand (that's error
prone), so declaratively specify the encodings as a table corresponding
to the bit patterns.

This is all formats, except for format 12 which just encodes constants.

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

3 years agopan/bi: Pack multiple tuples in-memory
Alyssa Rosenzweig [Mon, 28 Dec 2020 22:56:31 +0000 (17:56 -0500)]
pan/bi: Pack multiple tuples in-memory

There's still some silly clause-level packing required, but this way the
register slots are at least assigned correctly.

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

3 years agopan/bi: Amend misleading comment
Alyssa Rosenzweig [Mon, 28 Dec 2020 22:56:18 +0000 (17:56 -0500)]
pan/bi: Amend misleading comment

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

3 years agopan/bi: Clarify tuple comment
Alyssa Rosenzweig [Tue, 22 Dec 2020 20:41:16 +0000 (15:41 -0500)]
pan/bi: Clarify tuple comment

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

3 years agopan/bi: Use enum bifrost_message_type
Alyssa Rosenzweig [Tue, 22 Dec 2020 20:38:33 +0000 (15:38 -0500)]
pan/bi: Use enum bifrost_message_type

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

3 years agopan/bi: Use canonical terminology for tuple
Alyssa Rosenzweig [Tue, 22 Dec 2020 20:36:20 +0000 (15:36 -0500)]
pan/bi: Use canonical terminology for tuple

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

3 years agopan/bi: Move bi_constants to bifrost.h
Alyssa Rosenzweig [Tue, 22 Dec 2020 20:33:23 +0000 (15:33 -0500)]
pan/bi: Move bi_constants to bifrost.h

Although it's software-defined, this stems from architectural traits and
is useful in both the disasm and the compiler.

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

3 years agopan/bi: Test read predicates
Alyssa Rosenzweig [Mon, 21 Dec 2020 21:23:34 +0000 (16:23 -0500)]
pan/bi: Test read predicates

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

3 years agopan/bi: Test bi_must_message
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:57:16 +0000 (15:57 -0500)]
pan/bi: Test bi_must_message

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

3 years agopan/bi: Test bi_must_last
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:55:06 +0000 (15:55 -0500)]
pan/bi: Test bi_must_last

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

3 years agopan/bi: Unit test bi_can_{fma, add}
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:45:51 +0000 (15:45 -0500)]
pan/bi: Unit test bi_can_{fma, add}

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

3 years agopan/bi: Add various read predicates
Alyssa Rosenzweig [Mon, 21 Dec 2020 21:23:19 +0000 (16:23 -0500)]
pan/bi: Add various read predicates

Correpsonding to source masks in the XML.

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

3 years agopan/bi: Emit branch and table bits in opcode table
Alyssa Rosenzweig [Mon, 21 Dec 2020 21:23:03 +0000 (16:23 -0500)]
pan/bi: Emit branch and table bits in opcode table

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

3 years agopan/bi: Label table instructions
Alyssa Rosenzweig [Mon, 21 Dec 2020 21:22:43 +0000 (16:22 -0500)]
pan/bi: Label table instructions

Table instructions are a subset of those scheduled to the ADD unit. They
typically involve lookup tables. Table (TBL) instructions have
additional restrictions on their sources which the scheduler must
respect.

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

3 years agopan/bi: Add bi_must_message predicate
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:57:11 +0000 (15:57 -0500)]
pan/bi: Add bi_must_message predicate

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

3 years agopan/bi: Add bi_must_last predicate
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:54:48 +0000 (15:54 -0500)]
pan/bi: Add bi_must_last predicate

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

3 years agopan/bi: Pipe last flag into opcode tables
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:54:31 +0000 (15:54 -0500)]
pan/bi: Pipe last flag into opcode tables

Only ADD unit for now.

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

3 years agopan/bi: Annotate ISA.xml with 'last' parameter
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:53:57 +0000 (15:53 -0500)]
pan/bi: Annotate ISA.xml with 'last' parameter

If this instruction must be the last in the clause.

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

3 years agopan/bi: Add bi_can_{fma, add} predicates
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:45:23 +0000 (15:45 -0500)]
pan/bi: Add bi_can_{fma, add} predicates

Stubs due to some edge cases, for the scheduler.

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

3 years agopan/bi: Factor nir_function_impl out of the context
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:44:51 +0000 (15:44 -0500)]
pan/bi: Factor nir_function_impl out of the context

Unnecessary and complicates unit testing.

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

3 years agopan/bi: Stub out scheduler unit test
Alyssa Rosenzweig [Mon, 21 Dec 2020 20:20:37 +0000 (15:20 -0500)]
pan/bi: Stub out scheduler unit test

Someone who understands meson and gtest could do something much nicer,
but for now let's just stuff some assertions into debug builds of the
standalone compiler and call it a day...

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

3 years agopan/bi: Add "word equivalence" relation for index
Alyssa Rosenzweig [Tue, 29 Dec 2020 21:56:23 +0000 (16:56 -0500)]
pan/bi: Add "word equivalence" relation for index

Takes offset *but not swizzle* into account, so the scheduler can
predict whether indices will end up mapped to the same scalar register.

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

3 years agopan/bi: Move init_builder to common code
Alyssa Rosenzweig [Tue, 5 Jan 2021 18:26:56 +0000 (13:26 -0500)]
pan/bi: Move init_builder to common code

Needs to take a cursor to be applicable outside NIR->BIR of course.

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

3 years agopan/bi: Print multiple destinations if needed
Alyssa Rosenzweig [Tue, 5 Jan 2021 18:26:25 +0000 (13:26 -0500)]
pan/bi: Print multiple destinations if needed

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

3 years agopan/bi: Add CUBEFACE pseudoinstruction
Alyssa Rosenzweig [Tue, 5 Jan 2021 18:25:42 +0000 (13:25 -0500)]
pan/bi: Add CUBEFACE pseudoinstruction

Abstracts over *CUBEFACE1/+CUBEFACE2, takes the sources of the former
and outputs two destinations.

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

3 years agopan/bi: Don't fill garbage
Alyssa Rosenzweig [Thu, 7 Jan 2021 23:02:40 +0000 (18:02 -0500)]
pan/bi: Don't fill garbage

If an index is an SSA form and we haven't even written to it yet, there
is absolutely no value in filling it, it'd just be uninitialized garbage
that won't get used. Saves some fills in STK.

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

3 years agopan/bi: Implement spilling at the clause-level
Alyssa Rosenzweig [Wed, 30 Dec 2020 15:09:47 +0000 (10:09 -0500)]
pan/bi: Implement spilling at the clause-level

We use essentially the same logic, but we need to treat entire clauses
as large instructions, and spill on clause boundaries instead of
instruction boundaries. So factor out the code a bit, using the new
iterators, removing bi_unwrap_singleton.

A few specific fixes are needed to adapt. One is simple: rewriting
destinations needs to preserve clamps and such. The other is a much more
subtle bug. Consider the clause

   {
      ADD 0, ...
      ---unrelated code---
      MUL 1, 0, ...
   }

Suppose we spill 0. The naive spill code would generate an SSA temporary to
spill to and another SSA temporary to fill from, generating:

   {
      LOAD.tl 10
   }
   {
      ADD 11, ...
      ---unrelated code---
      MUL 1, 10, ...
   }
   {
      STORE.tl 11
   }

But this is wrong; the MUL now reads stale (and for SSA, likely
undefined/uninitialized) data. The simplest fix, employed here, is to
spill/fill within a clause simultaneously, which means the temporary
can't be SSA, generating correct code:

   {
      LOAD.tl r0
   }
   {
      ADD r0, ...
      ---unrelated code---
      MUL 1, r0, ...
   }
   {
      STORE.tl r0
   }

This is suboptimal, since the LOAD is still likely reading garbage that
is unused. But it is still correct, and the next commit will avoid
generating the load in this case.

To make the bug even more subtle, if ADD/MUL are within 2-3 instructions
of each other, the scheduler will optimize the load to a
temporary/passthrough, so the bug isn't noticed. It only happens if they
are 3+ instructions apart yet still in the same clause (<=16
instructions).

Special thanks to macc24 for reporting this bug and to Jason Ekstrand
for allowing me to rubberduck.

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

3 years agopan/bi: Add interference per clause
Alyssa Rosenzweig [Wed, 6 Jan 2021 17:25:45 +0000 (12:25 -0500)]
pan/bi: Add interference per clause

With new helpers.

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

3 years agopan/bi: Permit multiple destinations in RA
Alyssa Rosenzweig [Tue, 5 Jan 2021 15:30:09 +0000 (10:30 -0500)]
pan/bi: Permit multiple destinations in RA

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

3 years agopan/bi: Don't open code bi_foreach_dest
Alyssa Rosenzweig [Tue, 5 Jan 2021 15:29:01 +0000 (10:29 -0500)]
pan/bi: Don't open code bi_foreach_dest

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

3 years agopan/bi: Add destination iterator macro
Alyssa Rosenzweig [Tue, 5 Jan 2021 15:28:47 +0000 (10:28 -0500)]
pan/bi: Add destination iterator macro

Convenience.

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

3 years agopan/bi: Add bi_foreach_instr_in_clause iterators
Alyssa Rosenzweig [Wed, 6 Jan 2021 17:22:36 +0000 (12:22 -0500)]
pan/bi: Add bi_foreach_instr_in_clause iterators

These are convenient for post-sched passes, in particular register
allocation. They work by noting the underlying linked list of
instructions in the block must be preserved by scheduling. It isn't
necessary iterate the clause structure directly, it can simply be used
to bound a iteration within the block by recalling clauses are strictly
contained in a single block.

   <alyssa> I don't think I'm enough of a C ninja to write fancy iterator macros yet.
   <zmike> sometimes those can get pretty mind-bendy

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

3 years agopan/bi: Add bi_foreach_instr_in_tuple helper
Alyssa Rosenzweig [Wed, 6 Jan 2021 21:17:37 +0000 (16:17 -0500)]
pan/bi: Add bi_foreach_instr_in_tuple helper

Written in a funny way but easy to convince yourself of correctness by
considering cases.

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

3 years agopan/bi: Add bi_foreach_clause_in_block_rev
Alyssa Rosenzweig [Wed, 6 Jan 2021 17:21:36 +0000 (12:21 -0500)]
pan/bi: Add bi_foreach_clause_in_block_rev

Trivial absense.

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

3 years agopan/bi: Add bi_{before,after}_clause cursors
Alyssa Rosenzweig [Tue, 29 Dec 2020 22:21:37 +0000 (17:21 -0500)]
pan/bi: Add bi_{before,after}_clause cursors

Will be needed to insert spill code after scheduling once we have
multiple instructions in a clause.

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

3 years agopan/bi: Add "soft" mode to DCE
Alyssa Rosenzweig [Wed, 30 Dec 2020 18:41:14 +0000 (13:41 -0500)]
pan/bi: Add "soft" mode to DCE

We would like to reuse the DCE logic to eliminate register writes
without eliminating instructions, as a post-sched pass. This type of
operation will eventually generalize to intrinsics that write a register
*and* have side effects (just atomics, I think).

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

3 years agopan/bi: Add dead branch elimination pass
Alyssa Rosenzweig [Thu, 21 Jan 2021 00:09:34 +0000 (19:09 -0500)]
pan/bi: Add dead branch elimination pass

Ported from Midgard due to the same quirk of our code generation.
Additional validation, though.

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

3 years agopan/bi: Pass through wait_{6, 7} flags
Alyssa Rosenzweig [Sat, 9 Jan 2021 03:58:09 +0000 (22:58 -0500)]
pan/bi: Pass through wait_{6, 7} flags

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

3 years agopan/bi: Move bi_next_clause to bir.c
Alyssa Rosenzweig [Sat, 9 Jan 2021 03:57:53 +0000 (22:57 -0500)]
pan/bi: Move bi_next_clause to bir.c

Not really packing specific anyway.

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

3 years agopan/bi: Pull out bi_count_read_registers helper
Alyssa Rosenzweig [Wed, 20 Jan 2021 21:40:52 +0000 (16:40 -0500)]
pan/bi: Pull out bi_count_read_registers helper

I want to transition away from the ad hoc masks anyway.

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

3 years agopan/bi: Fix M1/M2 decoding in disassembler
Alyssa Rosenzweig [Sat, 9 Jan 2021 02:38:09 +0000 (21:38 -0500)]
pan/bi: Fix M1/M2 decoding in disassembler

C's definition of the % operator has a footgun around sign conversion.
Avoid it and just use bitwise arithemtic instead like the hardware
would, fixing the disassembly and making buggy assembly more obvious.

Fixes: 08a9e5e3e89 ("pan/bi: Decode M values in disasm")
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8723>

3 years agopan/bi: Fix dependency wait calculation
Alyssa Rosenzweig [Wed, 6 Jan 2021 00:06:53 +0000 (19:06 -0500)]
pan/bi: Fix dependency wait calculation

Unconditional branches have a successor in the first slot only.

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

3 years agopan/bi: Fix staging register packing
Alyssa Rosenzweig [Thu, 31 Dec 2020 17:30:05 +0000 (12:30 -0500)]
pan/bi: Fix staging register packing

Writes are from the previous tuple, not the current one, otherwise we
incorrectly write to "two" places at once and raise an INSTR_INVALID_ENC
fault. While we're at it, fix the weird spacing.

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

3 years agopan/bi: Fix IDLE register mode packing
Alyssa Rosenzweig [Wed, 30 Dec 2020 18:15:13 +0000 (13:15 -0500)]
pan/bi: Fix IDLE register mode packing

Was incorrectly returning zero. Special case like IDLE_1.

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