Commit Graph

472 Commits

Author SHA1 Message Date
Alyssa Rosenzweig fb7860ed24 asahi: Handle empty fragment shaders
When an empty fragment shader is used with Metal, the stop command is
still included but this special bit is set, suppressing tilebuffer
access. Failing to do so but using empty shaders for u_blitter depth
clears causes Glitch Lina:

   https://twitter.com/LinaAsahi/status/1537869064793575424

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 968bbca578 asahi: Note some more unknowns in the XML
Lot of r/e waiting here...

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 47831969c8 asahi: Split up unk 2b
Seems to be flags.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 5f57fe0bc9 asahi: Fix Indexed Draw command
Add the missing stub in the decoder for it, so we can decode indexed
draws instead of reading back garbage, and fill in some known unknowns
in the structure.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 10c9aceadf agx: Plumb through nir_op_txf
nir_op_txf maps to AGX's texture_load, which is encoded like
texture_sample. The one outstanding question with this commit is the
rules for the sample required ... in NIR and APIs (including Metal), txf
is samplerless, but the AGX instruction consumes a sampler. Hopefully
any sampler will do, though?

Passes dEQP-GLES3.functional.shaders.texture_functions.texelfetch.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 44d79d39b6 agx: Defeature indirect vbufs
vb_mask can include garbage vbufs, we can't rely on it. This will
prevent a regression when switching to u_blitter based clears. This is
also simpler and shrinks the VS shader key so all in all a good thing.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 0fccd564b6 agx: Don't hardcode uniform enums
Let the compiler number them for us, the numbers are meaningless.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 18bb64fd3a agx: Add more unit tests for float copyprop
Would have caught the bug fixed by the previous commit.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 095415cdf7 agx: Fix float copyprop of neg(neg) case
They should cancel each other. Fixes:

   dEQP-GLES2.functional.shaders.random.basic_expression.combined.0

Fixes: 28801b4849 ("agx: Add forward optimizing pass for fmov")
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 9645e46a53 agx: Fix tib access in internal shaders
The only case where tilebuffer access can be specially optimized is the
st_tile used in internal clear (or reload) shaders. However, other
shaders (like those used with u_blitter) may have nir->info.internal
set, so we can't key off that. Instead, add a special key for this
optimization to ensure correctness with other internal shaders.

Fixes flaky tests in dEQP-GLES2.functional.color_clear.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
2022-09-04 18:05:31 +00:00
Alyssa Rosenzweig 65c00ba7cb ail: Add unit tests for miptree layouts
The equations for calculating miptree offsets are complicated,
nonobvious, and full of subtle footguns. Worse, the driver doesn't
control the offsets -- it must simply agree with the offsets
implicitly calculated in the hardware. The CTS doesn't adequately
exercise all the corner cases. Make sure we have unit tests that do.

The tests themselves are generated by instrumenting agxdecode to scan
GPU memory after uploading test patterns in a variety of layout with a
Metal application.

Thank you to Asahi Lina and Dougall Johnson for the reverse-engineering
that led to this. The tests selected here are a subset of those used for
the reverse-engineering. The full set may be found in Lina's tilecalc
repo:

   https://github.com/asahilina/tilecalc

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig 4ed9843a26 asahi: Advertise ASTC formats
Now that we have layout and tiling code that can handle block-compressed
formats, including the non-square blocks found with some ASTC formats,
we can advertise ASTC formats. Passes dEQP-GLES3.*astc* which
exercises everything here. (These tests passed before by decompressing
the textures to RGBA8 UNORM in the frontend, but it's much more
efficient to use real ASTC textures as done here.)

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig c71e84b37e asahi: Advertise ETC1
ETC2 is backwards compatible with ETC1, we just need to declare the
format mapping.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig b37b8eabd3 asahi: Handle 2-channel sRGB textures
I'm not sure why we need to set this magic bit, but this fixes the
non-depth_component portion of
dEQP-GLES3.functional.texture.format.sized.*, e.g

dEQP-GLES3.functional.texture.format.sized.cube.srgb_rg8_pot

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig 464f59f723 ail: Rewrite tiled memcpy for correctness
Move tiling.c into ail, using ail data structures and helpers to manage
the tiling. This fixes a staggering number of issues with the tiling
routines:

* NPOT block sizes defeatured. The hardware only supports POT block
  sizes. There's no need to handle anything else.

* Use ail to determine tile sizes, instead of the broken
  agx_select_tile_shift routine that didn't work for non-square tile
  sizes (for instance).

* Handle up to 128x128 tiles, as required by 8bpp textures.

* Handle non-square tiles. If the block size is not a multiple of 4, the
  tile size will be of the form 2n x n. This is easy with the ail_tile
  data structure, but not possible architecturally with
  agx_select_tile_shift. This is required for 16bpp and 64bpp textures.

* Express in terms of elements instead of pixels, using unit
  suffixes to make the dimensional analysis obvious. In particular this
  handles tiling of block-compressed textures by tiling the blocks
  themselves. This is required for block-compressed textures (internally handled
  like smaller 64bpp textures).

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig 6ff75da8aa ail: Introduce image layout module
Introduce ail, a small library for working with the image (and buffer)
layouts encountered with AGX hardware. Its design is inspired by isl. In
particular, ail strives to use isl unit suffixes and to represent
quantities in a canonical, API-agnostic fashion [1].

ail replaces the old miptree code (based on some ad hoc heuristics that
passed a few dEQP tests). It is based on a thorough reverse-engineering
of AGX's twiddled format, courtesy of Asahi Lina, Dougall Johnson, and
me. This corrects our handling of many common cases that were totally
wrong in the old code, leading to GPU faults.

Unlike the code, ail differentiates between pixels and elements
consistently, allowing block-compressed formats like ETC2 to be
supported correctly. These formats will be enabled later in the series.

This commit fixes Inochi2D, glmark2 -brefract and -bterrain, and who
knows what else.

ail stands for { Asahi, AGX } Image { Layout, Library } at your
convenience. ail is best served warm.

Liberal use of ail is recommended. Yum!

[1] https://docs.mesa3d.org/isl/units.html

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig 5057d6787a asahi: Fix ASTC enums
The ASTC enum only encodes the block width/height. By contrast the
LDR/HDR/sRGB distinction is encoded as UNORM/Float and via the sRGB bit.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig 01323ba470 asahi: Fix bind sizes
Otherwise we get a nonsensical count of 129 in one Metal sample. Exact
size still not known but this bounds somewhat.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig e71f8ef439 asahi: Add XML for multisampled textures
Metal supports MSAA 2x and MSAA 4x, neither at the same time as
mipmapping. That matches the GL spec requirement.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig c8435e4bc6 asahi: Rename 'tiled 64x64' to 'twiddled'
To account for non-64x64 tile sizes, as well as the other forms of
tiling that may come up with compression.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Alyssa Rosenzweig 88eea62adb asahi: Identify compressed render target fields
We won't be implementing AGX compression for a while, but this gets some
unknowns out of the way when looking at dumps from Metal that use it.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18167>
2022-09-01 22:30:48 +00:00
Emma Anholt 28b2252d0a nir: Make nir_lower_discard_if() handle demotes and terminates, too.
AGX and zink both want all of these lowered, but nir_to_tgsi will want
only demote (and terminate if it was possible from GLSL but it's not)

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15932>
2022-08-31 18:26:19 +00:00
Jason Ekstrand 4fab5ae8ba asahi: Use util/bitpack_helpers.h
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18062>
2022-08-30 04:28:34 +00:00
Alyssa Rosenzweig 15e15422ba asahi: Fix warning building for macOS 12.0
Unnecessary rename that breaks forward compatibility... but Apple says
this is just NULL. Do the simpler thing. Note that the argument is a
mach_port_t, which is a natural_t == uint32_t in userspace... even
though it's a pointer in the kernel. Although Apple's docs claim that
kIOMasterPortDefault is NULL, it's really just 0.

../src/asahi/lib/agx_device.c:290:35: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
      IOServiceGetMatchingService(kIOMasterPortDefault, matching);
                                  ^~~~~~~~~~~~~~~~~~~~
                                  kIOMainPortDefault

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18121>
2022-08-21 14:32:40 -04:00
Alyssa Rosenzweig 5fd8ae1541 asahi: Identify depth clip mode bit
Setting this bit (at the batch level, not the draw level!) switches to
[-1, 1] clipping instead of Metal's preferred [0, 1] clipping. Using
this bit allows us to drop the clip_halfz lowering we had before, saving
2 instructions in every vertex shader.

Fixes dEQP-GLES2.functional.depth_range.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17948>
2022-08-14 19:59:19 +00:00
Alyssa Rosenzweig 3712609ee3 agx: Only emit the used components of gl_FragCoord
In case a shader only use gl_FragCoord.xy, this avoids wasting
coefficient registers for gl_FragCoord.zw which should be a small
optimization. It's also less work for DCE but I'm less worried about
that.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig 17168162fb agx: Remove p_extract
It's now unused. We didn't have coalescing for it anyway, splits are the
preferred alternative.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig c1900cb951 agx: Handle type-changing splits
If we want to break down a 64-bit value into its 32-bit halves, we want
to be able to use a split for this:

   lo, hi = split long

Extend the RA to handle this case.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig f86ad382c5 agx: Stop using broken idiv lowering
It is, as the name suggests, broken. Instruction count goes from 50->53
on the shader in
dEQP-GLES2.functional.shaders.operator.binary_operator.div.highp_int_fragment.
I'm happy to eat that cost in exchange for correct results!

There are lots more low-hanging opportunities for optimizations to that
shader:

- fuse double icmpsel for the b2i32(cmp) sequences
- promoting big immediates to uniforms
- fusing integer multiply+add

But for now this is acceptable and anyway I'm doing this on "fix broken
NIR lowering" time and not Asahi time.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig f28c631a89 agx: Implement nir_op_umul_high
This is crucial to the efficiency of the accurate idiv path.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig aab535ffda agx: Extract umul_high implementation
We can implement umul_high (for both 16-bit and 32-bit types)
efficiently by multiplying in the next larger type size and extracting
the upper word. We already have such an implementation (for instancing).
Extract it so we can use it for emit_alu too.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig a8cea8679d agx: Assert that registers are naturally aligned
This seems to be an architectural constraint. Ensure that RA satisfies
it, because otherwise we're left with mysterious fails.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig 8c2e626064 agx: Align 64-bit register pairs
This seems to be necessary for correct operation.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig 5631b3352e agx: Lower more ALU operations
Noticed while switching idiv lowerings. We could do better on some of these.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig f759459cd6 agx: Implement noperspective interpolation
We need to get a matching coefficient register and change the encoding
of the iter instruction slightly, but otherwise this is normal.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig 638d7f542e agx: Use split instead of extract for ldcf
For more uniform handling in the RA. This gets rid of the extra moves
with flat shading.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:54 -04:00
Alyssa Rosenzweig 744b4a0f7f agx: Rename varying load instructions
Unlike Mali (where I borrowed the old names from), these are not loads
in the memory sense. They are simply register loads and arithmetic.
Rename accordingly, using PowerVR names and public Apple names as a
guide.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:53 -04:00
Alyssa Rosenzweig 14bf020d75 agx: Model perspective coefficient reg in the IR
For perspective-correct interpolation, the W coefficient register is
needed. Instead of hardcoding this to cf0 and special casing, model this
in the IR and let the general handling kick in.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:53 -04:00
Alyssa Rosenzweig 24c3084411 agx: Add AGX_MESA_DEBUG=noopt option
To disable the optimizer. Trying to root cause a Neverball bug, this
gives one less thing to worry.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:53 -04:00
Alyssa Rosenzweig f3877f56ba asahi,agx: Rewrite varying linking
Instead of using driver_location magic and hoping things work, make the
linkage between vertex and fragment shaders explicit. Thanks to the
coefficient register mechanism reverse-engineered and documented earlier
in this series, this does not require any shader keys to support
separable shaders. It just requires that we regenerate the coefficient
register binding tables at draw time, based on the varying layouts
decided by the compiler independently for the VS and FS. This is more
robust in the face of separate shaders.

This also gets us glProvokingVertex() support without shader keys.

After that, we don't need any of the remapping prepasses. For fragment
shaders, any old mapping will do, so we can assign coefficient registers
as we go (based on what the program actually uses, not nir_variable
information that might be stale by this point). We do want to cache
coefficient registers, particularly for fragcoord.w which is used for
perspective interpolation everywhere.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:43:26 -04:00
Alyssa Rosenzweig 4b21db4111 asahi: Decode Interpolation packets
These have been known, just were missed.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:38:11 -04:00
Alyssa Rosenzweig c67169d218 asahi: Fix varying XML
Lots of changes from reverse-engineering harder the interactions with
fp16 and noperspective and such, and comparing against the PowerVR
driver code in Mesa that's been released since this XML was
originally written.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:38:11 -04:00
Alyssa Rosenzweig ed215183e2 asahi: Encode known bits of Linkage in the XML
I'm pretty sure about these. There's too much hex anyway.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:15:03 -04:00
Alyssa Rosenzweig 034d52643c asahi: Correct bind fragment pipeline size
A number of structures encode their size, but we were ignoring it just
for this fragment pipeline bind. Fix that.

This fix might also apply to bind vertex pipeline. Unsure.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:15:03 -04:00
Alyssa Rosenzweig 651e4677ca asahi: Split vertex/fragment pipeline binds
Although these are similar data structures, they are not identical and
trying to cover both in the same struct is causing problems with
aliasing. Split them out to get a more accurate representation.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:15:03 -04:00
Alyssa Rosenzweig b1180fe2f6 asahi: Fix using multiple textures/samplers
The counts for textures/samplers are specified in the bind
texture/sampler packets. What's in the bind pipeline appear to be...
hints? of some kind? It's a direct function of the numbers of textures
and samplers, but much more coarse. Unknown purpose.

This should be correct for up to 48 textures and at least 8 samplers.
For more than 48 textures, Metal switches to a "bindless" mode, where
the textures are instead bound with a bind uniform packet, ts* is no
longer read in the shader, and instead registers and immediates are used
to index the texture with a substantial preshader. Details TBD. We don't
need to worry about that for a long while, though.

Fixes a number of dEQPs.

   dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.array_in_struct.sampler2D_samplerCube_both,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.array_in_struct.sampler2D_samplerCube_fragment,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.array_in_struct.sampler2D_samplerCube_vertex,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.nested_structs_arrays.sampler2D_samplerCube_both,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.nested_structs_arrays.sampler2D_samplerCube_fragment,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.nested_structs_arrays.sampler2D_samplerCube_vertex,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.array_in_struct.sampler2D_samplerCube_both,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.array_in_struct.sampler2D_samplerCube_fragment,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.array_in_struct.sampler2D_samplerCube_vertex,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.nested_structs_arrays.sampler2D_samplerCube_both,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.nested_structs_arrays.sampler2D_samplerCube_fragment,Crash
   dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.nested_structs_arrays.sampler2D_samplerCube_vertex,Crash

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:15:03 -04:00
Alyssa Rosenzweig d2fef02cc0 asahi: Dump all textures&samplers
This confirms the actual size of the texture descriptor -- 24 bytes.
The last 8 bytes have so far only been zeroed. It also confirms we got
the sampler descriptor size right.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:15:03 -04:00
Alyssa Rosenzweig c045d3761c asahi: Extend counts in BIND packets
We can bind at least 16 textures. Fix the sizes in the XML so this can
be decoded correctly.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:15:03 -04:00
Alyssa Rosenzweig e441896eb8 agx: Fix ld_var cf packing
Make it handle larger coefficient registers.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:15:03 -04:00
Alyssa Rosenzweig 47a3f1226c agx: Fix packing of samplers in texture instrs
Typo in the handwritten packing code, oof!

Fixes incorrectly repeated shadows in Neverball (among many other bugs,
I assume). Huge thanks to Lina for the idea that this was the
bug -- fixing it was a breeze from there :-)

Fixes: 9f55538834 ("agx: Pack texture ops")
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Suggested-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
2022-08-07 20:15:03 -04:00
Alyssa Rosenzweig 8066ef9d30 agx: Port minifloat tests to GTest
These tests predate using GTest in the compiler. Now that we do, we'd like to
have the tests together so they run regularly.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17824>
2022-08-01 18:34:11 +00:00
Jason Ekstrand 642283a2c1 panfrost,asahi: Use util_sign_extend for unpacking
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17214>
2022-07-06 11:23:18 +00:00
Alyssa Rosenzweig 76981e5615 agx: Handle loop { if { loop { .. } } }
We need to push loop nesting to handle this correctly -- at the end of
the innermost loop, the correct nesting is 1 (from the if), not 0.

Fixes assertion failure in

  dEQP-GLES2.functional.shaders.struct.local.dynamic_loop_nested_struct_array_fragment,UnexpectedPass
  dEQP-GLES2.functional.shaders.struct.local.dynamic_loop_nested_struct_array_vertex,UnexpectedPass
  dEQP-GLES2.functional.shaders.struct.uniform.dynamic_loop_nested_struct_array_fragment,UnexpectedPass
  dEQP-GLES2.functional.shaders.struct.uniform.dynamic_loop_nested_struct_array_vertex,UnexpectedPass

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17128>
2022-06-22 21:23:50 +00:00
Alyssa Rosenzweig 2338dcd392 asahi,agx: Don't set PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT
Tell the state tracker our point coordinates have a lower left origin
instead of an upper left origin, and remove our point coordinate
flipping code. Saves an instruction in any shader that reads
gl_PointCoord.y

Note: the OpenGL blob also emits an "fadd $y', ^y.neg, 1.0" to flip
point coordinates, so this isn't just a Metal weirdness.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16829>
2022-06-08 14:10:50 +00:00
Alyssa Rosenzweig 1b7304f44b asahi: Add wrap library
Add a library that wraps the key IOKit entrypoints used in the macOS
UABI for AGX. Our wrapped routines print information about the kernel
calls made and dump work submitted to the GPU using agxdecode. This code
has two major use cases:

1. Debugging Mesa, particularly around the undocumented macOS
   user-kernel interface. Logs from Mesa may compared to Metal to check
   that the UABI is being used correcrly.

2. Reverse-engineering the hardware, using this as glue to get at the
   "interesting" GPU memory.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:58:07 -04:00
Alyssa Rosenzweig 1d0d27aac7 asahi: Allocate a larger segment list
This ought to be dynamically allocated but because this is macOS kernel
UABI only gunk, let's just hack around it...

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig 689be69681 asahi: Fix pipeline decoding
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig 8a1ee708a4 asahi: Improve render target dumping
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig d8227f09d0 asahi: Drop some unknowns
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig 03a3a7843e asahi: Identify suballocated size
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig 14d966734f asahi: Identify suballocation mechanism
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig ca9b1d48fe asahi: Decode resource allocation requests
We already know much of this structure, let's pretty print to simplify
our traces.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig 0c120cf141 asahi: Decode resource allocation responses
We already know much of this structure, let's pretty print to simplify
our traces.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig 1e42e4a390 asahi: Validate segment list length
This is easy now!

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig 343f4f886f asahi: Split unknown field in segment list header
Seen as 0x8000.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig 6b12292754 asahi: Add segment list pretty printer
Validate all the new expectations and print all the fields. This should
make differences between the drivers obvious, I hope.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:11:08 -04:00
Alyssa Rosenzweig db32b4a064 asahi: Sync some names with Project Zero
This should clarify a few things I didn't get independently
investigating the interface. Of coruse, I got other pieces... the sum of
the parts is better :-)

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:10:57 -04:00
Alyssa Rosenzweig 6e59474ced asahi: Identify partial render pipeline
Needed if a partial render is incurred from overflowing the parameter
buffer (too much geometry).

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:04 -04:00
Alyssa Rosenzweig 666f307d41 asahi: Add a depth bias structure
This is simple and corresponds directly to the Metal inputs. However,
the alignment is a bit tricky, so let's add formal XML for it.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:04 -04:00
Alyssa Rosenzweig cb760a00c2 asahi: Identify depth bias enable bit
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:04 -04:00
Alyssa Rosenzweig 7a0c220401 asahi: Identify "set depth bias index" field
Grouped together with the "set scissor index" field, which is natural.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:04 -04:00
Alyssa Rosenzweig ff84c07b21 asahi: Identify depth bias array
"Inspired" by PowerVR code, by comparison.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:04 -04:00
Alyssa Rosenzweig a39fb009d2 asahi: Note unknown field
...used internally with visibility tests, together with a weird
vertex/compute-like shader used to zero the visibility buffer.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:04 -04:00
Alyssa Rosenzweig baa54da7d6 asahi: Relax Draw "command" check
Other values in the lower byte seen with multiple draws and
visibility testing.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:04 -04:00
Alyssa Rosenzweig d8541d52d2 asahi: Add XML used for visibility tests
Aka occlusion queries. There is an annoying limitation in the hardware
(reflected in Metal) that only a single buffer may be bound per render
pass, with the per-draw settings merely specifying an offset.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:04 -04:00
Alyssa Rosenzweig 46a7c10349 asahi: Dump "unknown 4a" structure
A few fields are known at least, let's decode them correctly instead of
falling back to a hex dump.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:04 -04:00
Alyssa Rosenzweig a5e6a5e585 asahi: Identify more depth pipeline fields
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-22 17:09:00 -04:00
Alyssa Rosenzweig 6aadd72bd4 asahi: Account for every byte of the cmdbuf
This adds the remaining XML. I don't know how much of this is correct,
but it nominally accounts for every byte. So there shouldn't be more
surprises in the command buffer after this.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-21 22:01:33 -04:00
Alyssa Rosenzweig c61e660323 asahi: Handle 3rd deflake address
Context switching is so broken. Just trying to get closer. Adding some
XML here to see if we're missing something else obvious.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-21 22:01:33 -04:00
Alyssa Rosenzweig 43f6c08a3b asahi: Handle uncompressed Z32F depth buffers
This uses a subset of the depth/stencil infrastructure we built out to
support writing back tiled, uncompressed Z32F depth buffers to memory.
Texturing from this format is already supported.

This gets glmark2 -bshadow working.

v2: Fix partial renders

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-21 22:01:32 -04:00
Alyssa Rosenzweig e6c809d767 asahi: Use z24_in_z32f lowering
Thanks Dave!

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>
2022-05-21 22:01:32 -04:00
Alyssa Rosenzweig 6b1e73c700 asahi: Fix hangs waiting on the notification queue
Dequeue and WaitForAvailableData can race. Restructure the loop to avoid
this. Fixes all timeouts in dEQP.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16518>
2022-05-17 15:00:15 +00:00
Timothy Arceri c4295816af asahi: switch to NIR loop unrolling
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16543>
2022-05-17 02:12:21 +00:00
Timothy Arceri d7a071a28f gallium/drivers: set force_indirect_unrolling_sampler for all required drivers
This is set to true for all drivers that have a GLSL level
of support lower than 4.00. This matches the rule for setting the
GLSL IR option EmitNoIndirectSampler.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16543>
2022-05-17 02:12:21 +00:00
Alyssa Rosenzweig 28220b2778 agx: Restore Valve copyright header
Parallel copy code is from ir3_lower_parallel_copy.c. This was attributed in the
commit message but lost in the copyright header due to a copypaste mistake.
Rectify this.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16413>
2022-05-10 01:36:18 +00:00
Alyssa Rosenzweig 31fd926334 agx: Lower mediump flat shading
This isn't supported by the hardware. Fixes

dEQP-GLES2.functional.shaders.constants.float_uniform_vertex

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 18ef9398de agx: Remove nir_register support
We don't use it anymore, now that we can handle SSA form. Gets rid of
the most gross hack in the compiler.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 3927a9e911 agx: Remove has_liveness
Given we do no metadata tracking, this is an accident waiting to happen.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 1c6bd0357f agx: Update RA comment
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 6b22bbab36 agx: Add validation pass
For now, just check that we didn't botch the structure of the block,
since this just bit me.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 4498799822 agx: Remove identity moves
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig c712043b9c agx: Unit test parallel copy lowering
It's pretty tricky.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 6a4d742369 agx: Always use hash table for extracts
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 860832e41b agx: Split up RA from post-RA lowering
This allows us to validate results in the middle.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig ea065537cb agx: Lower phi nodes to parallel copies
Now we have an SSA RA :-)

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig ccb0210761 agx: Don't lower phis in NIR
We're ready for them now! Just scalarize.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig a8da17f628 agx: Copy prop into phi nodes
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 8ff0a29baf agx: Translate phi nodes
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 4791dc9125 agx: Make DCE dumber
The current DCE pass hits issue around phi nodes. These need to be
solved properly eventually, but for now workaround them by doing
something obviously correct (but suboptimal compile time).

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 606d9340f3 agx: Adapt liveness analysis for SSA
Lifted from nir_liveness.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 590df764d6 agx: Introduce worklist infrastructure
Using the common NIR stuff.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig e414a8c16f agx: Add agx_after_block_logical helper
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig a2a947031a agx: Mark the logical ends of blocks
We need to insert parallel copies at the logical end of blocks, before branches.
Add a pseudo instruction signaling that. Cribbed from ACO.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 5be26e8624 agx: Add predecessor index helper
To order phi sources.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 3f1e926bf4 agx: Use a dynarray for predecessors
This imposes a fixed ordering, allowing phi sources to be implicitly ordered.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig d02e913e95 agx: Remove else optimization
It will conflict with SSA-based RA and needs to be rewritten to happen
late.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 4d79f6ca76 agx: Use extract helper for tex internally
Allows better optimization.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 4f78141c77 agx: Emit splits for intrinsics
This allows optimizing the extracts.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig d06394095b agx: Optimize p_split(kill) specially
Let's make sure these are allocated optimally.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig e16ad8f443 agx: Lower p_split after RA
Using existing regalloc infrastructure.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 4fc023ed42 agx: Use a transfer graph for parallel copies
Lifted from ir3. Algorithm is the same; the data structures and interface are
lightly modified to decouple from ir3's IR.

Sequentializing parallel copies after RA is tricky. ir3's implementation works
well enough, so I use that one.

Original implementation by Connor Abbott.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 22:00:00 -04:00
Alyssa Rosenzweig 330ec4260d agx: Add helper to emit splits
This should be used for vector destinations, to facilitate the extraction
optimization.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig b30c718a57 agx: Add helper to emit combines
...in such a way that subsequent extracts will be optimized.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig 5bc65ef963 agx: Add a hash table for vector extracts
This will allow us to introduce splits gradually, giving a graceful fallback.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig d285c63417 agx: Add phi pseudo instruction
For SSA.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig 2a4a8a8902 agx: Add p_split pseudoinstruction
Easier on RA for extracts.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig bb1fb0a9db agx: Dynamically allocate agx_instr->src
Required for phi nodes.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig d39b1c3426 agx: Implement simple copyprop
Cleans up some of the mess.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig 7d38bcb7ee agx: Use pseudo ops for mov/not/and/xor/or
Rather than using builder magic (implicitly lowered on emit), add actual pseudo
operations (explicitly lowered before encoding). In theory this is slower, I
doubt it matters. This makes the instruction aliases first-class for IR prining
and machine inspection, which will make optimization passes easier to write.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig 3d8c2f2693 agx: Add unit test infrastructure
Lifted from Bifrost. Add some basic optimizer tests (they pass!) to show the
compiler is ready to be unit tested. Given we can't have hardware CI for Asahi
yet -- and dEQP is still pretty janky -- unit testing should prove quite useful.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig 43c701424b agx: Wrap compiler header in extern "C"
So we can use it from GTest.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig f0a973081f agx: Use correct types for some IR enums
Otherwise there are implicit int->enum casts which prevent us from building as
C++ (with -fpermissive).

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig b87ce10210 agx: Match order for designated initializers
Required to compile our headers with C++, to allow us to use GTest unit tests.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig ff660dd637 agx: Track write registers more accurately
We may not write a full 32-bit vec4, don't be so pessimistic.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig 0c82b5c99c agx: Note that RA proceeds in dominance-order
This is an important invariant for SSA-based RA to work.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Alyssa Rosenzweig 81477f3809 agx: Implement some shader-db stats
Instructions, bytes, and registers -- this should hold us over until we
can reverse the underlying uarch and get proper cycle estimations.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
2022-05-01 21:58:29 -04:00
Emma Anholt 536c8ee96d nir/lower_tex: Make the adding a 0 LOD to nir_op_tex in the VS optional.
This controls the whole lowering of "make tex ops with implicit
derivatives on non-implicit-derivative stages be tex ops with an explicit
lod of 0 instead", but it's really hard to describe that in a git commit
summary.

All existing callers get it added except:
- nir_to_tgsi which didn't want it.
- nouveau, which didn't want it (fixes regressions in shadowcube and
  shadow2darray with NIR, since the shading languages don't expose txl of
  those sampler types and thus it's not supported in HW)
- optional lowering passes in mesa/st (lower_rect, YUV lowering, etc)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16156>
2022-04-28 21:26:08 +00:00
Alyssa Rosenzweig b219e9a96e asahi: Port driver to macOS 12.x ABI
There's lots of reshuffling required. Nothing "interesting", though.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15482>
2022-03-22 00:19:30 +00:00
Alyssa Rosenzweig f5ae88d36f asahi: Identify IOGPU_MISC data structure
This will be elaborated upon soon.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15482>
2022-03-22 00:19:29 +00:00
Alyssa Rosenzweig d5ee1eacf1 asahi: Add stencil buffer attachment type
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15482>
2022-03-22 00:19:29 +00:00
Alyssa Rosenzweig 50f9b4ceba asahi: Identify IOGPU Internal Pipelines structure
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15482>
2022-03-22 00:19:29 +00:00
Alyssa Rosenzweig eb9da583d7 asahi: Identify aux framebuffer data structure
Total guess at the name.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15482>
2022-03-22 00:19:29 +00:00
Alyssa Rosenzweig 535f1c1166 asahi: Identify IOGPU Clear Z/S structure
Not sure on the details yet but identify and dump the data structure to start.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15482>
2022-03-22 00:19:29 +00:00
Timur Kristóf 64acec0ef9 nir: Fix lowering terminology of compute system values: "from"->"to".
This is to match other NIR terminology.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15103>
2022-03-08 17:36:31 +00:00
Alyssa Rosenzweig 01d1bf6228 asahi: Wire in pure integer texture formats
Passes dEQP-GLES3.functional.texture.format.sized.2d.r*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:33 +00:00
Alyssa Rosenzweig cc3e98e201 asahi: Identify minimum/maximum LOD fields
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:33 +00:00
Alyssa Rosenzweig 6554790dfb asahi: Add LOD clamp packing unit tests
With GTest.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig e3a5c1b478 asahi: Add LOD type
Automatically packs and unpacks float <==> clamped 4:6 fixed point, used
for min/max LOD fields on the Sampler descriptor.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig db93090ffc asahi: Allow GenXML to be used in C++
C++ requires explicit casts from integers to enums. Fixes errors like
the following when trying to use Asahi GenXML from a GTest unit test.

src/asahi/lib/agx_pack.h:554:23: error: assigning to 'enum agx_channels' from incompatible type 'uint64_t' (aka 'unsigned long long')
   values->channels = __gen_unpack_uint(cl, 0, 6);

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig 055c5a59f8 agx: Round and clamp array indices
Conforming with the GLSL spec. Fixes:

dEQP-GLES3.functional.shaders.texture_functions.texture.sampler2darray_fixed_fragment

(and probably others)

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig a822b7b6cc agx: Naturally align uniform pushes
Required to pack correctly, e.g if we push a 16-bit value then a 64-bit
value.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig 0c2bbb470a agx: Add agx_size_align_16 helper
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig 9aeb5156bc agx: Add typed move helper
Useful for u2u16 in lowering code.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig 830d16e9f0 asahi: Add AGX_PUSH_ARRAY_SIZE_MINUS_1
Required to clamp array indices against the array sizes per the GLSL
spec. Metal also does this, implying it's required by the hardware for
correct operation.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig a8bf729f8a asahi: Support 2D array and 3D textures
As far as I can tell, these *must* be tiled. Other than that, the
implementation is completely routine. Passes

dEQP-GLES3.functional.texture.format.unsized.*2d_array*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig 856f64de24 asahi: Allow tiling of all bpps
Use the usual macro trick via Panfrost. Fixes textures with formats with
non-32-bit bpp, including:

dEQP-GLES2.functional.texture.specification.basic_teximage2d.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig 2028873ef6 asahi: Dynamically configure tile size
We need to shrink the tile size when using small images (including
due to mipmapping) or when using large block sizes.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig d103d64df6 asahi: Add some notes to XML about mipmapping
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig 06b2d97666 asahi: Add 2D Array and 3D texture dimensions
Add to XML and translate in the driver.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00
Alyssa Rosenzweig 1a3e21a4de asahi: Identify Level field of render target descriptor
Hardware support for rendering into nonzero mip levels.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14903>
2022-02-18 23:48:32 +00:00