Commit Graph

670 Commits

Author SHA1 Message Date
Christian Gmeiner 84fa286602 etnaviv: remove primconvert
This is no longer used.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12516>
2021-08-26 10:44:04 +00:00
Christian Gmeiner a3d6aa43a6 etnaviv: export supported prim types
This is now handled by gallium, so the related codepaths can be dropped.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12516>
2021-08-26 10:44:04 +00:00
Marek Olšák bb89cf4bf3 gallium: add take_ownership into set_sampler_views to skip reference counting
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12334>
2021-08-20 15:04:20 +00:00
Simon Ser b5919b0b10 etnaviv: add stride, offset and modifier to resource_get_param
Prior to this commit, the stride, offset and modifier were fetched
via WINSYS_HANDLE_TYPE_KMS. However we can't make such a query
succeed if the buffer couldn't be imported to the KMS device.

Instead, extend the resource_get_param hook to allow users to fetch
this information without WINSYS_HANDLE_TYPE_KMS.

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: 9da901d2b2 ("etnaviv: fail in get_handle(TYPE_KMS) without a scanout resource")
Reported-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12370>
2021-08-19 13:12:51 +00:00
Lucas Stach 826f95778a etnaviv: always try to create KMS side handles for imported resources
By creating the KMS side handles we allow GBM to return the proper KMS
side GEM handles for imported buffers. Always creating the KMS side
handles adds a bit of overhead, as we don't need them on all imported
resources, but seems like the most robust solution for now.

Cc: mesa-stable
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12018>
2021-08-09 23:41:43 +02:00
Timothy Arceri a9ed4538ab nir: add indirect loop unrolling to compiler options
This is where it should be rather than having to pass it into the
optimisation pass every time.

It also allows us to call the loop analysis pass without having to
duplicate these options which we will do later in this series.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-08-03 10:54:50 +00:00
Simon Ser 9da901d2b2 etnaviv: fail in get_handle(TYPE_KMS) without a scanout resource
The previous logic was returning a handle valid for the render-only
device if rsc->scanout was NULL. However the caller doesn't expect
this: the caller will use the handle with the KMS device.

Instead of returning a handle for the wrong device, fail if we don't
have one.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12074>
2021-07-29 21:01:10 +02:00
Simon Ser 3b3cd51286 etnaviv: fix renderonly check in etna_resource_alloc
When the driver hasn't been initialized via renderonly, screen->ro
will be NULL. This fixes a crash when passing USE_SCANOUT to etnaviv
when it's missing renderonly.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12074>
2021-07-29 20:59:21 +02:00
Philipp Zabel 8ba44103b3 etnaviv: fix gbm_bo_get_handle_for_plane for multiplanar images
Implement resource_get_param for PIPE_RESOURCE_PARAM_NPLANES and fix
resource_get_handle to walk to the correct linked resource for
multiplanar images, allowing gbm_bo_get_handle_for_plane to be called
with plane > 0.

This fixes an assert that is triggered when a wayland client tries
to send weston an NV12 dmabuf, for example:

  weston: .../mesa/src/gbm/backends/dri/gbm_dri.c:752: gbm_dri_bo_get_handle_for_plane: Assertion `plane == 0' failed.

Fixes: 788f6dc857 ('Revert "gallium/dri: fix dri2_from_planar for multiplanar images"')
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12037>
2021-07-27 23:13:57 +02:00
Jason Ekstrand d4b482d378 android: Drop the Android.mk build system
Android.mk files haven't really been supported by Mesa devs for a long
time.  Most of us have been willing to update Makefile.sources if we
remember and sometimes we try to blind code some Android.mk for a new
generator.  However, the reality is that it breaks regularly and ends up
being maintained by the Android community.  To address this problem
another approach was implemented in !10183 utilizing the maintained
meson build system.  The old Android.mk files are no longer required.

This commit was created with the following commands:

    git rm **/Android.mk
    git rm **/Android.*.mk
    git rm **/Makefile.sources
    git rm CleanSpec.mk

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4487
Acked-by: Roman Stratiienko <r.stratiienko@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9728>
2021-07-08 14:44:02 -05:00
Rhys Perry 1cbcfb8b38 nir, nir/algebraic: add byte/word insertion instructions
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3151>
2021-06-08 08:57:42 +00:00
Eric Anholt 95d41a3525 ra: Use struct ra_class in the public API.
All these unsigned ints are awful to keep track of.  Use pointers so we
get some type checking.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9437>
2021-06-04 19:08:57 +00:00
Alyssa Rosenzweig b92a6edf82 etnaviv: Use Rn_UINT instead of In_UINT for index buffers
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10990>
2021-06-01 23:40:47 +00:00
Lucas Stach 7b9d8d1936 etnaviv: flush used render buffers on context flush when neccessary
Some resources like backbuffers are explicitly flushed by the frontend
at the appropriate time, others however won't get flushed explicitly.
Remember those resources when they get emitted as a render buffer and
flush them on a context flush to make their content visible to other
entities sharing the buffer.

We still keep the optimized path for most resources where the frontend
promises to do the flushing for us and only enable implicit flushing
when a buffer handle is exported/imported without the
PIPE_HANDLE_USAGE_EXPLICIT_FLUSH flag set.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7603>
2021-05-25 10:38:29 +00:00
Lucas Stach 1c539bbb06 etnaviv: remove double assigment of surface->texture
surf->base.texture is already assigned earlier via a proper
pipe_resource_reference call. Remove the superfluous assignement.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7603>
2021-05-25 10:38:29 +00:00
Marek Olšák eb74f97769 gallium: split transfer_(un)map into buffer_(un)map and texture_(un)map
The u_resource_vtbl indirection is going to be removed.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10659>
2021-05-21 17:38:04 +00:00
Lucas Stach 92ed827fbd etnaviv: fix vertex sampler setup
The start offset of the vertex samplers isn't zero, but the indexing of
the passed in views array is still zero based. Use the correct indexing
variable to fix vertex sampler setup.

Cc: <mesa-stable@lists.freedesktop.org>
Fixes: 81ab9fe2d0 ("etnaviv: handle NULL views in set_sampler_views")
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10724>
2021-05-18 09:23:46 +00:00
Mike Blumenkrantz dae3113c3d gallium: split drawid out of pipe_draw_info and as a separate draw_vbo param
the only case in which this is nonzero is if a multidraw gets split by the frontend,
i.e., mesa core, and in all other cases it can be ignored. the value can also be ignored
for all indirect draws, though it seems many (most?) gallium drivers are not aware of this

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10166>
2021-04-30 03:59:19 +00:00
Mike Blumenkrantz 4566383ae4 gallium: move pipe_draw_info::index_bias to pipe_draw_start_count_bias
this moves index_bias into the multidraw struct, enabling draws where the value
changes to be merged; the draw_info struct member is renamed and moved to the end
of the struct for tc use

u_vbuf still has some checks to split draws if index_bias changes, maybe
this can be removed at some point?

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10166>
2021-04-30 03:59:19 +00:00
Mike Blumenkrantz 4fe6c85526 gallium: rename pipe_draw_start_count -> pipe_draw_start_count_bias
and add an index_bias member

no functional changes yet, just the rename and unused struct member

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10166>
2021-04-30 03:59:19 +00:00
Eric Anholt 5de3cbbb2e nir: Generate load_ubo_vec4 directly for !PIPE_CAP_NATIVE_INTEGERS
The prog_to_nir->NIR-to-TGSI change ended up causing regressions on r300,
and svga against r300-class hardware, because nir_lower_uniforms_to_ubo()
introduced shifts that nir_lower_ubo_vec4() tried to reverse, but that NIR
couldn't prove are no-ops (since shifting up and back down may drop bits),
and the hardware can't do the integer ops.

Instead, make it so that nir_lower_uniforms_to_ubo can generate
nir_intrinsic_load_ubo_vec4 directly for !INTEGER hardware.

Fixes: cf3fc79cd0 ("st/mesa: Replace mesa_to_tgsi() with prog_to_nir() and nir_to_tgsi().")
Closes: #4602
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10194>
2021-04-16 21:58:00 +00:00
Michel Dänzer d200f45875 Use explicit break instead of fall-through to break-only case
clang generates a warning if there's no explicit break or fall-through
annotation. The latter would be kind of silly in this case, and not
robust against any future changes turning the fall-through invalid.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10220>
2021-04-15 16:01:22 +00:00
Marek Olšák d7250b0b08 gallium: add PIPE_SHADER_CAP_FP16_CONST_BUFFERS for FP16 uniforms
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9050>
2021-04-13 05:07:42 +00:00
Rhys Perry a2619b97f5 nir/lower_idiv: add options to use fp32 for 8-bit division lowering
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10081>
2021-04-12 16:19:46 +00:00
Lucas Stach 76c0217fb0 etnaviv: remove stale comment in etna_resource_copy_region
The comment about using the RS engine was correct before the code got
changed to use the 3D blitter and a fallback before etnaviv was merged
into upstream Mesa. It has been incorrect ever since. As it's just
adding confusion, instead of being helpful, remove it.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9310>
2021-04-09 22:44:17 +02:00
Lucas Stach 171d7a3081 etnaviv: don't try to copy PIPE_BUFFER with the 3D engine
PIPE_BUFFER layout is incompatible with the 3D pipe, so don't try to
blit it via a 3D engine blit, but fall back to the software copy.

Fixes crashes in piglit tests arb_copy_buffer and arb_map_buffer_range.

Fixes: c9e8b49b88 (etnaviv: gallium driver for Vivante GPUs)
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9310>
2021-04-09 22:43:59 +02:00
Christian Gmeiner 663272c4da etnaviv: tell the truth if alpha-test is supported
GPUs with the feature bit PE_NO_ALPHA_TEST set have no fixed-function
alpha test unit and we want to let st lower it with a shader variant.

For GC7000K this fixes all fbo-alphatest-formats piglits like:
 spec@ext_framebuffer_object@fbo-alphatest-formats
 spec@ext_packed_float@fbo-alphatest-formats
 spec@ext_texture_srgb@fbo-alphatest-formats

This only works with the NIR compiler backend.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Tested-by: Lukas F. Hartmann <lukas@mntmn.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9871>
2021-04-08 19:25:26 +00:00
Rob Clark ea2c47390a util/primconvert: Handle indirect and multi-draw
Indirect handling was completely missing.  And even though we have to
emulate multi-draw, this pushes it out of the fast/hot path in the
driver's draw_vbo()

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9742>
2021-03-27 19:30:04 +00:00
Rob Clark e6148a2724 etnaviv: Use util_draw_multi() helper
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9742>
2021-03-27 19:30:04 +00:00
Christian Gmeiner 09117357b7 etnaviv: rename struct members
As the structs are used for TE and NTE change the naming of the
struct members to be more generic.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8103>
2021-03-20 10:51:21 +01:00
Christian Gmeiner 53b51a1037 etnaviv: add support for NTE
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8103>
2021-03-20 10:51:15 +01:00
Christian Gmeiner a9494a8b9c etnaviv: factor out TS state emitting
Will be reused in NTE path.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8103>
2021-03-20 10:51:12 +01:00
Christian Gmeiner ec91456952 etnaviv: etnaviv: put sampler limit determination into own function
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8103>
2021-03-20 10:51:06 +01:00
Lucas Stach 187218395d renderonly: remove layering violations
The renderonly object is something the winsys creates, so the pipe
driver has no business in memcpying or freeing it. Move those bits
to the winsys.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6983>
2021-03-11 14:41:48 +00:00
Marek Vasut f7dc0520d9 etnaviv: Fix point sprite Z,W coordinate replacement
Mesa fixed pipeline texture loading on programmable pipeline hardware emits
a generic fragment shader program which contains gl_TexCoord.xyzw as a vec4
and then expects to configure the varying assignments to the shader in the
pipeline command stream, to select what is wired to the XYZW fragment shader
inputs.

This gl_TexCoord.xyzw is turned into texture load with projection (TGSI TXP
opcode, similar for NIR). Texture load with projection does not exist in the
Vivante GPU as a dedicated opcode and is emulated. The shader program first
divides texture coordinates XYZ by projector W and then applies regular TEX
opcode to load the texture (i.e. TEX(gl_TexCoord.xyzw/gl_TexCoord.wwww)).

For point sprites, XY are the point coordinates from VS, Z=0 and W=1, always.
The Vivante GPU can only configure varying to be either of -- point coord X,
point coord Y, used, unused -- which covers XYZ, but not W. Z is fine because
unused means 0.

W used to be 0 too before this patch and that led to division by 0 in shader.
The only known way to solve this is to set Z=0, W=1 in the shader program
itself if the point sprites are enabled. This means we have to generate a
special shader variant which does extra SET to set the W=1 in case the point
sprites are enabled.

In case of TGSI, emitting the SET.TRUE opcode permits setting W=1 without
allocating additional constants. With NIR, use nir_lower_texcoord_replace()
to lower TEXn to PNTC, which sets Z=0, W=1, and let NIR optimize the shader.
Note that nir_lower_texcoord_replace() must be called before input linking
is set up, as it might add new FS input.

Also note that it should be possible to simply drop PIPE_CAP_POINT_SPRITE
in the long run, ST would then apply the same optimization pass, but that
option is so far misbehaving. And for etnaviv TGSI this is not applicable
yet.

This fixes neverball point sprites (exit cylinder stars) and eglretrace of
gl4es pointsprite test:
https://github.com/ptitSeb/gl4es/blob/master/traces/pointsprite.tgz

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8618>
2021-03-10 11:48:21 +00:00
Christian Gmeiner f532202f2d etnaviv: use nir_lower_idiv(..) before opt loop
nir_lower_idiv(..) creates during its lowering isub instructions.
Move nir_lower_idiv(..) before the opt loop to have a chance to
optimize/lower isub away. Also drop the drop the halti dependency to
make it easier to follow.

This fixes the following assert on GC3000:
  Unhandled ALU op: isub

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9447>
2021-03-09 06:45:31 +00:00
Jason Ekstrand e20e85f01e nir: Make nir_ssa_def_rewrite_uses_after take an SSA value
This replaces the new_src parameter of nir_ssa_def_rewrite_uses_after()
with an SSA def, and rewrites all the users as needed.

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

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Alyssa Rosenzweig <alyssa@collabora.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9383>
2021-03-08 16:59:55 +00:00
Rhys Perry cbb5ed476c nir/opt_shrink_vectors: add option to skip shrinking image stores
Some games declare the wrong format, so we might want to disable this
optimization in that case.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Fixes: e4d75c22 ("nir/opt_shrink_vectors: shrink image stores using the format")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9229>
2021-03-03 14:18:37 +00:00
Christian Gmeiner cfd835b45a etnaviv: extend lower ubo tests
Test a full transformation path (load_uniform -> load_ubo -> load_uniform)
and validate the load_uniform offset.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9305>
2021-02-26 19:52:53 +00:00
Christian Gmeiner 5705ecb6f4 etnaviv: fix etna_nir_lower_ubo_to_uniform pass
The restoring of the acutal uniform offset was wrong.

Fixes: 1837135f7c ("etnaviv: nir: add ubo lowering pass")
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9305>
2021-02-26 19:52:53 +00:00
Rob Clark 0ca5b1a6b9 etnaviv: Drop foreach_bit() macro
Now that we have a global one.

Signed-off-by: Rob Clark <robdclark@chromium.org>

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9191>
2021-02-24 17:11:44 +00:00
Christian Gmeiner dba692c618 etnaviv: use nir_lower_uniforms_to_ubo(..)
This removes our local copy and fixes the following nir validation problem:
  error: nir_intrinsic_range(instr) != 0 (../src/compiler/nir/nir_validate.c:646)

No piglit or deqp regression seen.

shader-db results for GC3000:

instructions helped:   shaders/deqp_gles2/23470.shader_test VERT:        328 -> 316 (-3.66%)
instructions helped:   shaders/deqp_gles2/23473.shader_test FRAG:        328 -> 316 (-3.66%)
instructions helped:   shaders/glamor/88.shader_test FRAG:               472 -> 452 (-4.24%)
instructions helped:   shaders/chromeos/36.shader_test VERT:             60 -> 56 (-6.67%)
instructions helped:   shaders/chromeos/24.shader_test VERT:             60 -> 56 (-6.67%)
instructions helped:   shaders/chromeos/18.shader_test VERT:             60 -> 56 (-6.67%)
instructions helped:   shaders/chromeos/45.shader_test VERT:             60 -> 56 (-6.67%)
instructions helped:   shaders/deqp_gles2/23494.shader_test VERT:        176 -> 164 (-6.82%)
instructions helped:   shaders/deqp_gles2/23497.shader_test FRAG:        176 -> 164 (-6.82%)
instructions helped:   shaders/glamor/82.shader_test FRAG:               280 -> 260 (-7.14%)
instructions helped:   shaders/chromeos/21.shader_test VERT:             56 -> 52 (-7.14%)
instructions helped:   shaders/chromeos/15.shader_test VERT:             56 -> 52 (-7.14%)
instructions helped:   shaders/tesseract/268.shader_test VERT:           152 -> 136 (-10.53%)
instructions helped:   shaders/tesseract/270.shader_test VERT:           184 -> 164 (-10.87%)
instructions helped:   shaders/tesseract/272.shader_test VERT:           216 -> 192 (-11.11%)
instructions helped:   shaders/tesseract/266.shader_test VERT:           88 -> 76 (-13.64%)
instructions helped:   shaders/deqp_gles2/23488.shader_test VERT:        112 -> 96 (-14.29%)
instructions helped:   shaders/deqp_gles2/23491.shader_test FRAG:        112 -> 96 (-14.29%)
instructions helped:   shaders/chromeos/102.shader_test VERT:            168 -> 144 (-14.29%)
instructions helped:   shaders/deqp_gles2/23449.shader_test FRAG:        64 -> 52 (-18.75%)
instructions helped:   shaders/deqp_gles2/23446.shader_test VERT:        64 -> 52 (-18.75%)
instructions helped:   shaders/deqp_gles2/23461.shader_test FRAG:        124 -> 100 (-19.35%)
instructions helped:   shaders/deqp_gles2/23458.shader_test VERT:        124 -> 100 (-19.35%)
instructions helped:   shaders/chromeos/39.shader_test VERT:             124 -> 100 (-19.35%)

temps helped:   shaders/chromeos/102.shader_test VERT:            6 -> 5 (-16.67%)
temps helped:   shaders/deqp_gles2/23470.shader_test VERT:        5 -> 4 (-20.00%)
temps helped:   shaders/deqp_gles2/23473.shader_test FRAG:        5 -> 4 (-20.00%)

temps HURT:   shaders/tesseract/272.shader_test VERT:           6 -> 7 (16.67%)

immediates helped:   shaders/deqp_gles2/23470.shader_test VERT:        24 -> 20 (-16.67%)
immediates helped:   shaders/deqp_gles2/23473.shader_test FRAG:        24 -> 20 (-16.67%)
immediates helped:   shaders/chromeos/102.shader_test VERT:            8 -> 4 (-50.00%)
immediates helped:   shaders/chromeos/39.shader_test VERT:             8 -> 4 (-50.00%)

immediates HURT:   shaders/glamor/88.shader_test FRAG:               32 -> 36 (12.50%)
immediates HURT:   shaders/deqp_gles2/23494.shader_test VERT:        4 -> 8 (100.00%)
immediates HURT:   shaders/deqp_gles2/23497.shader_test FRAG:        4 -> 8 (100.00%)

total instructions in shared programs: 1123728 -> 1123392 (-0.03%)
instructions in affected programs: 3644 -> 3308 (-9.22%)
helped: 24
HURT: 0
helped stats (abs) min: 4 max: 24 x̄: 14.00 x̃: 12
helped stats (rel) min: 3.66% max: 19.35% x̄: 10.74% x̃: 8.83%
95% mean confidence interval for instructions value: -17.11 -10.89
95% mean confidence interval for instructions %-change: -13.03% -8.45%
Instructions are helped.

total temps in shared programs: 86978 -> 86976 (<.01%)
temps in affected programs: 22 -> 20 (-9.09%)
helped: 3
HURT: 1
helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1
helped stats (rel) min: 16.67% max: 20.00% x̄: 18.89% x̃: 20.00%
HURT stats (abs)   min: 1 max: 1 x̄: 1.00 x̃: 1
HURT stats (rel)   min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67%
95% mean confidence interval for temps value: -2.09 1.09
95% mean confidence interval for temps %-change: -38.40% 18.40%
Inconclusive result (value mean confidence interval includes 0).

total immediates in shared programs: 141464 -> 141460 (<.01%)
immediates in affected programs: 104 -> 100 (-3.85%)
helped: 4
HURT: 3
helped stats (abs) min: 4 max: 4 x̄: 4.00 x̃: 4
helped stats (rel) min: 16.67% max: 50.00% x̄: 33.33% x̃: 33.33%
HURT stats (abs)   min: 4 max: 4 x̄: 4.00 x̃: 4
HURT stats (rel)   min: 12.50% max: 100.00% x̄: 70.83% x̃: 100.00%
95% mean confidence interval for immediates value: -4.53 3.38
95% mean confidence interval for immediates %-change: -48.17% 70.79%
Inconclusive result (value mean confidence interval includes 0).

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9039>
2021-02-23 14:55:34 +00:00
Christian Gmeiner 1837135f7c etnaviv: nir: add ubo lowering pass
Adds a pass to lower the load_ubo intrinsics for block 0 back
to load_uniform intrinsic.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9039>
2021-02-23 14:55:34 +00:00
Christian Gmeiner 9c67324542 etnaviv: let st lower rect tex
Before this change we used a dummy load_uniform to represent texcoord
scale. That dummy load was converted to a load_const where we are using
the upper 32 bits to store the uniform content type and that breaks nir's
validation. With the new nir_intrinsic_load_texture_scaling we know the
uniform type and do not need to go from load_ubo->load_const (with type
information).

shader-db for GC3000:

instructions helped:   shaders/tesseract/491.shader_test FRAG:           260 -> 248 (-4.62%)
instructions helped:   shaders/tesseract/494.shader_test FRAG:           256 -> 244 (-4.69%)
instructions helped:   shaders/tesseract/238.shader_test FRAG:           244 -> 232 (-4.92%)
instructions helped:   shaders/tesseract/241.shader_test FRAG:           244 -> 232 (-4.92%)
instructions helped:   shaders/tesseract/127.shader_test FRAG:           80 -> 76 (-5.00%)
instructions helped:   shaders/tesseract/130.shader_test FRAG:           156 -> 148 (-5.13%)
instructions helped:   shaders/tesseract/226.shader_test FRAG:           204 -> 192 (-5.88%)
instructions helped:   shaders/tesseract/229.shader_test FRAG:           204 -> 192 (-5.88%)
instructions helped:   shaders/tesseract/217.shader_test FRAG:           164 -> 152 (-7.32%)
instructions helped:   shaders/tesseract/214.shader_test FRAG:           164 -> 152 (-7.32%)
instructions helped:   shaders/tesseract/205.shader_test FRAG:           124 -> 112 (-9.68%)
instructions helped:   shaders/tesseract/202.shader_test FRAG:           124 -> 112 (-9.68%)
instructions helped:   shaders/tesseract/169.shader_test FRAG:           36 -> 32 (-11.11%)
instructions helped:   shaders/tesseract/166.shader_test FRAG:           36 -> 32 (-11.11%)
instructions helped:   shaders/tesseract/118.shader_test FRAG:           32 -> 28 (-12.50%)
instructions helped:   shaders/tesseract/181.shader_test FRAG:           60 -> 52 (-13.33%)
instructions helped:   shaders/tesseract/178.shader_test FRAG:           60 -> 52 (-13.33%)
instructions helped:   shaders/tesseract/121.shader_test FRAG:           60 -> 52 (-13.33%)
instructions helped:   shaders/tesseract/193.shader_test FRAG:           84 -> 72 (-14.29%)
instructions helped:   shaders/tesseract/190.shader_test FRAG:           84 -> 72 (-14.29%)

temps HURT:   shaders/tesseract/494.shader_test FRAG:           6 -> 7 (16.67%)
temps HURT:   shaders/tesseract/491.shader_test FRAG:           6 -> 7 (16.67%)

total instructions in shared programs: 1122112 -> 1121920 (-0.02%)
instructions in affected programs: 2676 -> 2484 (-7.17%)
helped: 20
HURT: 0
helped stats (abs) min: 4 max: 12 x̄: 9.60 x̃: 12
helped stats (rel) min: 4.62% max: 14.29% x̄: 8.92% x̃: 8.50%
95% mean confidence interval for instructions value: -11.14 -8.06
95% mean confidence interval for instructions %-change: -10.65% -7.18%
Instructions are helped.

total temps in shared programs: 86942 -> 86944 (<.01%)
temps in affected programs: 12 -> 14 (16.67%)
helped: 0
HURT: 2

total immediates in shared programs: 141216 -> 141216 (0.00%)
immediates in affected programs: 0 -> 0
helped: 0
HURT: 0

total loops in shared programs: 0 -> 0
loops in affected programs: 0 -> 0
helped: 0
HURT: 0

LOST:   0
GAINED: 0

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8898>
2021-02-23 14:04:30 +00:00
Christian Gmeiner 06f409a8c1 etnaviv: nir: support nir_intrinsic_load_texture_rect_scaling
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8898>
2021-02-23 14:04:30 +00:00
Eric Anholt 175c827e72 gallium: Flip the default value of PIPE_CAP_SHAREABLE_SHADERS.
We should be exposing it in every driver, since it's required eventually
to reduce jank.  Make drivers have to explicitly opt out instead of opt
in.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9088>
2021-02-17 19:31:07 +00:00
Vinson Lee a7a7d25e5b etnaviv: Fix memory leak in etna_vertex_elements_state_create.
Fix defect reported by Coverity Scan.

Resource leak (RESOURCE_LEAK)
leaked_storage: Variable cs going out of scope leaks the storage it points to.

Fixes: c9e8b49b88 ("etnaviv: gallium driver for Vivante GPUs")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9034>
2021-02-16 20:53:51 -08:00
Caio Marcelo de Oliveira Filho 0589bd46c8 etnaviv: Use gl_varying_slot_name_for_stage()
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8998>
2021-02-13 00:44:53 +00:00
Marek Olšák 27dcb46629 gallium: add take_ownership param into set_vertex_buffers to eliminate atomics
There are a few places (mainly u_threaded_context) that do:
   set_vertex_buffers(...);
   for (i = 0; i < count; i++)
      pipe_resource_reference(&buffers[i].resource.buffer, NULL);

set_vertex_buffers increments the reference counts while the loop
decrements them.

This commit eliminates those reference count changes by adding a parameter
into set_vertex_buffers that tells the callee to accept all buffers
without incrementing the reference counts.

AMD Zen benefits from this because it has slow atomics if they come from
different CCXs.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>
2021-01-27 23:53:35 +00:00