Commit Graph

298 Commits

Author SHA1 Message Date
Mike Blumenkrantz cfca760d6e mesa/st: handle copy_deref cases for adding pointsize
these may not have been lowered yet

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15821>
2022-04-10 16:45:15 +00:00
Mike Blumenkrantz 2b626af110 mesa/st: also add pointsize to fixedfunction vertex shaders as needed
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15699>
2022-04-07 21:56:10 -04:00
Mike Blumenkrantz d773055d92 mesa/st: always inject a 1.0 pointsize for vertex stages
since 1.0 is used in nearly every case, drivers requiring this exporting
can avoid potential shader variants by adding a 1.0 export to the base
shader variant and the only using the ubo upload when pointsize is explicitly
set for wide point functionality

drivers can then be responsible for removing unused pointsize exports
as needed (or desired)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15699>
2022-04-07 21:56:09 -04:00
Mike Blumenkrantz 3aa449ff72 mesa/st: declare added pointsize var as hidden
ensure this isn't counted as part of the shader and ignored for e.g.,
glGetProgramInterfaceiv

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15699>
2022-04-07 21:56:09 -04:00
Mike Blumenkrantz 6cfde0abe9 mesa/st: don't add pointsize to ES programs if it already exists
an obvious missed case from the previous series, but there's no need
to-readd an output if it already exists here

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15590>
2022-03-30 03:49:36 +00:00
Erik Faye-Lund 930b38e7cd gallium: rename read-outputs cap
This cap is no longer TGSI-specific, so let's update the name to reflect
reality.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15316>
2022-03-17 16:44:42 +00:00
Erik Faye-Lund 2a8e11e101 gallium: rename pixel-coord caps
These aren't specific to TGSI, so let's rename them to reflect the
reality.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15316>
2022-03-17 16:44:42 +00:00
Mike Blumenkrantz 9d98bc238e mesa/st: only add pointsize output if it doesn't exceed max component limit
fixes (zink-nvidia):
dEQP-GLES31.functional.geometry_shading.basic*

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15228>
2022-03-09 05:10:21 +00:00
Mike Blumenkrantz fdee7240ff mesa/st: conditionally add pointsize outputs to ES tess/geom shaders
if the driver requires this value to be set, add it if the shader doesn't
use the ext to allow exporting it

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15228>
2022-03-09 05:10:21 +00:00
Mike Blumenkrantz 597bd11b7b mesa/st: add a gl_program struct flag to skip psiz exports for xfb
if this output did not exist in the original shader,
then it must not be exported in xfb

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15228>
2022-03-09 05:10:21 +00:00
Marek Olšák 5ca7c20cf7 st/mesa: do nir_lower_io() for inputs & outputs with transform feedback info
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:56 +00:00
Timothy Arceri 6eec8fcbfa glsl/nir: free GLSL IR right after we convert to NIR
Gives us memory back faster which is useful for pathalogical CTS
tests.

The GLSL IR was previously used after converting to NIR for things
like building the GL resource list but we have had a NIR version
for this for some time and I don't believe there are any other
use cases left for keeping the old IR hanging around this long.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15127>
2022-02-24 01:10:49 +00:00
Mike Blumenkrantz 7e9481eaac gallium: add PIPE_CAP_CULL_DISTANCE_NOCOMBINE
for drivers where separate cull distance variables are required, this
lets them avoid having to write yet another pass to undo gallium's mangling
of shader info

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14878>
2022-02-08 14:03:09 +00:00
Timothy Arceri bfa096a0b9 glsl/st: move st_nir_opts() into gl compiler common code
This will allow us to use this in future NIR linker work. It also makes
more sense to move it here as the classic drivers are gone, tgsi is
going away and we are merging more of the st into the gl common code.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14785>
2022-01-31 11:49:21 +00:00
Dave Airlie 3faa21bda7 mesa/st: collapse st_program into gl_program object.
Remove the subclass for this.

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14700>
2022-01-26 00:42:59 +00:00
Dave Airlie 7b7f627600 glsl/fp64: move context.h dependent checks into main.
allows dropping context.h include.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14437>
2022-01-20 00:20:06 +00:00
Dave Airlie f7bb68e499 glsl/nir: don't pass gl_context to the convertor routine.
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14433>
2022-01-07 06:19:49 +00:00
Dave Airlie e943af6a55 glsl/nir/linker: avoid passing gl_context inside gl_nir linker
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14433>
2022-01-07 06:19:49 +00:00
Timothy Arceri 74a1f103b6 mesa: update or remove out of date references to ir_to_mesa
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14066>
2021-12-06 10:15:08 +00:00
Timothy Arceri bf1f809d7f mesa: rename ir_to_mesa.{cpp,h} -> link_program.{cpp,h}
The only code now left in this file is the linking function.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14066>
2021-12-06 10:15:08 +00:00
Marek Olšák e54264c84f nir: add shader_info::source_sha1, its initialization and printing
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13869>
2021-11-26 11:58:27 +00:00
Jason Ekstrand 956199e870 nir: s/nir_var_mem_image/nir_var_image/g
We typically use nir_var_mem_* for stuff that has an explicit byte-based
memory layout.  Images are opaque.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13386>
2021-10-16 03:47:10 +00:00
Jason Ekstrand 12b3ffe400 st/nir: Assign uniform locations to nir_var_mem_image vars
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4743>
2021-10-15 14:58:56 +00:00
Qiang Yu 3127282944 mesa/st: delay nir spirv link
Following commit for st_nir_link_shaders->nir_link_opt_varyings
may copy uniform variable from one shader to another, so delay
the nir_spirv link which contains mesa uniform information
update (gl_nir_link_uniforms) after it and align with glsl link.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12613>
2021-10-13 04:45:15 +00:00
Emma Anholt ba6368b54d mesa/st: Don't bump locations of patch vars for !PIPE_CAP_TEXCOORD.
There's no need to reserve the bottom 9 VARYING_SLOT_PATCH*, since
VARYING_SLOT_TEXCOORD won't be mapped there.  This helps us match up with
nir_to_tgsi, which wasn't shifting down by 9 for patch.

Acked-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12800>
2021-10-06 03:44:17 +00:00
Emma Anholt 17332ceb0f mesa/st: Add an optional GLSL link fail msg to finalize_nir.
GLES2 drivers are allowed to reject some GLSL constructs, like dynamic
loop bounds (which neither i915g nor vc4 can fully support), but gallium
hasn't had any way to trigger a link failure.  Add a return msg to the
finalize_nir hook, which is called at the end of GLSL linking, and use
that.  This means that some other callers of finalize need to do something
with the msg, and we (for now) just throw it away.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12218>
2021-09-06 18:09:25 +00:00
Emma Anholt 6dd87592a6 mesa/st: Add an assertion for finalize_nir versus PIPE_CAP_TEXCOORD.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12218>
2021-09-06 18:09:25 +00:00
Ian Romanick 5f2dbd45f2 gallium: Remove "optimize" parameter from pipe_screen::finalize_nir
As part of adding support for inline uniforms in Iris, I was going to
add a finalize_nir hook.  I went looking to see how other drivers use
the "optimize" parameter, and I discovered that *nobody* uses it at all.

v2: Fix typo in commit message.  Noticed by Mike.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12317>
2021-08-13 15:45:29 -07:00
Pierre-Eric Pelloux-Prayer 7684d57a05 nir: add a pass to optimize "gl_FragDepth = gl_FragCoord.z" away
gl_FragDepth default value is gl_FragCoord.z so if a shader does:

   gl_FragDepth = gl_FragCoord.z

we can drop this assignment.

v2: use nir_ssa_scalar_resolved and don't do this is gl_FragDepth
    is wrote multiple times (Jason)
v3: - move to its own pass (Jason)
    - handle var = NULL (Rhys)
v4: refactoring (Jason)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10697>
2021-08-11 11:00:11 +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
Marek Olšák 521651d106 st/mesa: remove st_vertex_program::input_to_index
It's the same as a prefix bitcount of inputs_read.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11370>
2021-08-02 19:58:28 +00:00
Rob Clark c7b935962b nir: Add pass to lower phi precision
In addition to register pressure benefits from getting more fp16/int16,
this avoids i2imp's from standing in the way of loop unrolling.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11545>
2021-06-29 23:27:28 +00:00
Dave Airlie 1956ff08ad st/nir: always revectorise if scalarising happens.
This fixes arb_gpu_shader_fp64-vs-non-uniform-control-flow-ssbo
on crocus.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11098>
2021-06-03 02:10:00 +00:00
Connor Abbott a40714abf7 nir/lower_phis_to_scalar: Add "lower_all" option
We don't want to have to deal with vector phis in freedreno, because
vectors are always split/unsplit around vectorized instructions anyways,
and the stated reason for not scalarising them (it hurting coalescing)
won't apply to us because we won't be using nir_from_ssa. Add this
option so that we don't have to do the equivalent thing while
translating from NIR.

Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10809>
2021-05-17 09:59:45 +00:00
Gert Wollny e36d5c5f6e gallium: pass lower_to_scalar_filter to lower_to_scalar pass
v2: Fix the callback name

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9943>
2021-05-07 12:09:03 +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
Marek Olšák a0718e8977 st/mesa: fix nir_lower_io if it's done right after IO vectorization
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9050>
2021-04-13 05:07:42 +00:00
Alyssa Rosenzweig 5d32cf642f nir: Add varying precision linking helper (v2)
It is useful for the precisions of varyings to match across shader
stages at link-time to enable precision lowering optimizations, which
would otherwise require costly draw-time fixups.

The goal is to enable `producer->precision == consumer->precision` to be
an invariant drivers may rely on for linked shaders.

v2: keep transform feedback outputs at mediump - mareko

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> (v1)
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9050>
2021-04-13 05:07:42 +00:00
Mike Blumenkrantz f9c83782f7 st/glsl_to_nir: lower indirect derefs of builtins in non-packed uniform case
the builtin lowering can't handle dynamic array indexing, so this requires
that all indirect derefs be lowered any time this pass is invoked in order
to avoid crashing

fixes #4132

Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9741>
2021-03-23 14:44:48 +00:00
Dave Airlie 8027a7ba8a shader_info: convert textures_used to a bitset.
For now keep it a bitset of 1 32-bit dword.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9456>
2021-03-10 06:16:09 +10:00
Andrii Simiklit 39ea95330f mesa: ensure parameter list capacity before associating uniform storage
We have to reserve at lease 16 program parameters in storage to
avoid its reallocation.

v2: move allocation to `st_deserialise_ir_program` and add helper for that
                     ( Eric Anholt <eric@anholt.net> )

v3 amend comments a bit

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4352
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9282>
2021-02-28 05:55:50 +00:00
Eric Anholt 9fcc369770 mesa: Always make sure uniform storage doesn't get reallocated.
Every caller of associate_uniform_storage was doing this to safety-check
that the uniform storage didn't get reallocated, except for
st_deserialise_ir_program().  This ended up leaving an opening for
use-after-free without hitting the assert in the hot-cache case (and I
found it on freedreno).  Having added it, it also reveals use-after-frees
in the drawpixels shader variant cases on llvmpipe and zink.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8997>
2021-02-24 21:48:54 +00:00
Christian Gmeiner 08e072015a gallium/st: lower rectangle textures if not supported
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
Marek Olšák 81f7cb149d st/mesa: enable state var merging to improve fetch_state performance
The requirement is that drivers must implement finalize_nir for
st_finalize_nir to be invoked at link time and before shader variant
generation. Without that, _mesa_optimize_state_parameters won't be called.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8183>
2021-01-21 21:59:30 +00:00
Marek Olšák b4f3497786 mesa: remove STATE_INTERNAL
Let's flatten the tokens to generate optimal code for fetch_state.

There was only one name conflict: STATE_NORMAL_SCALE was used both as
internal and non-internal.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8183>
2021-01-21 21:59:29 +00:00
Danylo Piliaiev 33fd9e5d8a nir: account for point-coord origin when lowering it
The resulting point-coord origin not only depends on whether
the draw buffer is flipped but also on GL_POINT_SPRITE_COORD_ORIGIN
state. Which makes its transform differ from a transform of wpos.

On freedreno fixes:
 gl-3.2-pointsprite-origin
 gl-3.2-pointsprite-origin -fbo

Fixes: d934d320 "nir: Add flipping of gl_PointCoord.y in nir_lower_wpos_ytransform."
Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8200>
2021-01-04 13:41:33 +00:00
Rhys Perry d7d0b4445a nir/opt_access: infer writeonly
This isn't always done for GL because it could cause ImageAccess to be
incorrect: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3278

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6483>
2020-12-09 14:41:38 +00:00
Rhys Perry 4dc5659463 nir/opt_access: add basic Vulkan support
This involves determining the variables referenced by intrinsics, setting and
using the access qualifier correctly and considering that images and buffers
can alias.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6483>
2020-12-09 14:41:38 +00:00
Mike Blumenkrantz 9d22c438cb mesa/st: set reserved storage for params+values to 16
zink apparently has a lot of uniform data, and 8x8 isn't enough to avoid realloc

fixes mesa/mesa#3930

Fixes: eda37fb2 ("mesa: properly disallow param list reallocation")

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7990>
2020-12-08 21:22:32 +00:00
Gert Wollny 454c848592 mesa/st: lower 64 bit ops to scalar before lowering to soft-float
The fp64 emulation is not prepared for vectorized 64 bit code, so
if the driver doesn't ask for lowering to scalar by itself, do it before
lowering to soft-fb, and run a vectorizazion pass afterwards.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7961>
2020-12-08 10:52:34 +00:00