mesa.git
5 years agofreedreno/a2xx: use sysval for pointcoord
Jonathan Marek [Sat, 5 Oct 2019 20:09:55 +0000 (16:09 -0400)]
freedreno/a2xx: use sysval for pointcoord

Fixes a problem with shaders using gl_PointCoord.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reported-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
5 years agopan/midgard: Disable precise occlusion queries
Alyssa Rosenzweig [Sat, 26 Oct 2019 13:02:34 +0000 (09:02 -0400)]
pan/midgard: Disable precise occlusion queries

I thought there was hardware support for this, but it seems to broken,
or at least more complex than I believed.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
5 years agopanfrost: allocate bo for occlusion query results
Urja Rannikko [Tue, 22 Oct 2019 12:05:07 +0000 (12:05 +0000)]
panfrost: allocate bo for occlusion query results

This memory needs to still be available after all the drawing is done
and forgotten about, so cannot be transient.
Also clear the result so that no rendering returns a zero.

Signed-off-by: Urja Rannikko <urjaman@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
5 years agopanfrost: Expose serialized NIR support
Alyssa Rosenzweig [Sat, 19 Oct 2019 21:14:44 +0000 (17:14 -0400)]
panfrost: Expose serialized NIR support

Serialized NIR is required for clover with the SPIR-V pipeline. With
this change and PAN_MESA_DEBUG=deqp, clinfo is able to successfully
probe panfrost.

Code from Nouveau (commit 7955fabcf89c7265f7f4244e46c5bcb83b9687fa by
Karol Herbst).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
5 years agopipe-loader: Default to kmsro if probe fails
Alyssa Rosenzweig [Sat, 19 Oct 2019 20:46:54 +0000 (16:46 -0400)]
pipe-loader: Default to kmsro if probe fails

A device supported by kmsro will not automatically probe kmsro since the
driver name will be panfrost/lima/v3d/..., not "kmsro". Since kmsro is a
bit of a catch-all for generic (mostly embedded) GPUs, add a fallback on
kmsro for the dynamic loader.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Acked-by: Karol Herbst <kherbst@redhat.com>
5 years agopipe-loader: Add kmsro pipe_loader target
Alyssa Rosenzweig [Sat, 19 Oct 2019 20:51:30 +0000 (16:51 -0400)]
pipe-loader: Add kmsro pipe_loader target

kmsro is used by numerous embedded GPUs for a common winsys abstraction.
Let's add support for it for the dynamic pipe loader, so clover can
probe on these drivers.

We build the target with Panfrost. When other drivers need kmsro+clover,
we can revisit the build system part; my mesonfu is wanting.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Acked-by: Karol Herbst <kherbst@redhat.com>
5 years agoscons: Fix force_scons parsing.
Jose Fonseca [Fri, 25 Oct 2019 21:09:34 +0000 (22:09 +0100)]
scons: Fix force_scons parsing.

- Use parsed options instead of using ARGUMENTS directly.
- Handle the case of mingw cross compilation.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2003
5 years agoradv: enable secure compile support
Timothy Arceri [Wed, 31 Jul 2019 04:06:46 +0000 (14:06 +1000)]
radv: enable secure compile support

Can be enabled via the environment variable which tells the
driver how many compilation threads are expected to be called,
and therefore how many forked processes the driver should
create.

For example we would expect to call fossilize replay with
something like this:

RADV_SECURE_COMPILE_THREADS=8 ./fossilize-replay --num-threads 8 \
--shader-cache-size 0 --ignore-derived-pipelines pipeline_cache.foz

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: a support for a secure compile fork at device creation
Timothy Arceri [Wed, 31 Jul 2019 04:03:53 +0000 (14:03 +1000)]
radv: a support for a secure compile fork at device creation

This added support for the fork, the installation of the seccomp
filter, and the main loop for the actual compilation to be called
from i.e. run_secure_compile_device().

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: add radv_secure_compile()
Timothy Arceri [Wed, 31 Jul 2019 03:59:17 +0000 (13:59 +1000)]
radv: add radv_secure_compile()

This function will be called by the parent process when doing a
secure compile. It first selects a free process to work with then
passes it all the information it needs to compile the pipeline.

Once the pipeline information has been passed to the secure
process, it then waits around to read/write any disk cache entries
required before exiting.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: for secure compile exit early from radv_shader_variant_create()
Timothy Arceri [Wed, 31 Jul 2019 03:57:16 +0000 (13:57 +1000)]
radv: for secure compile exit early from radv_shader_variant_create()

We don't have permission to be creating shared memory etc.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: allow the secure process to read and write from disk cache
Timothy Arceri [Wed, 31 Jul 2019 03:50:52 +0000 (13:50 +1000)]
radv: allow the secure process to read and write from disk cache

This allows the secure process to read and write to the disk cache
via the parent process. This commit just adds the functionality
needed for the secure process, the following commit will add the
functionality for the parent process.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: add radv_device_use_secure_compile() helper
Timothy Arceri [Thu, 24 Oct 2019 03:17:15 +0000 (14:17 +1100)]
radv: add radv_device_use_secure_compile() helper

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: add some new members to radv device and instance for secure compile
Timothy Arceri [Wed, 31 Jul 2019 03:47:08 +0000 (13:47 +1000)]
radv: add some new members to radv device and instance for secure compile

These will be used by the following commits to hold information about
the forked secure compile processes.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: add radv_secure_compile_type enum
Timothy Arceri [Wed, 31 Jul 2019 03:44:44 +0000 (13:44 +1000)]
radv: add radv_secure_compile_type enum

This will be used to identify information being passed between the
parent and secure process during a secure compile.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: add radv_create_shaders() to radv_shader.h
Timothy Arceri [Wed, 31 Jul 2019 03:39:52 +0000 (13:39 +1000)]
radv: add radv_create_shaders() to radv_shader.h

In a follwing commit we want to be able to call this for secure
compiles from radv_device.c

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: add debug option to turn off in memory cache
Timothy Arceri [Fri, 12 Jul 2019 04:45:16 +0000 (14:45 +1000)]
radv: add debug option to turn off in memory cache

This can be usefull for debugging the on disk cache, but is also
useful in the following patch for secure compiles which will be
used to compile huge pipeline collections. These pipeline
collections can be multiple GBs and the in memory cache grows to
multiple GBs very quickly when they are compiled so we want to
be able to turn off the in memory cache.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoradv: get topology from pipeline key rather than VkGraphicsPipelineCreateInfo
Timothy Arceri [Thu, 24 Oct 2019 02:03:20 +0000 (13:03 +1100)]
radv: get topology from pipeline key rather than VkGraphicsPipelineCreateInfo

This is cleaner and avoids having to read/write an additional copy of
topology for use with secure compile.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agodocs: document new feature EGL_EXT_image_flush_external
Marek Olšák [Fri, 25 Oct 2019 20:59:07 +0000 (16:59 -0400)]
docs: document new feature EGL_EXT_image_flush_external

5 years agoegl: implement new functions from EGL_EXT_image_flush_external
Marek Olšák [Fri, 18 Oct 2019 00:07:32 +0000 (20:07 -0400)]
egl: implement new functions from EGL_EXT_image_flush_external

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-By: Tapani Pälli <tapani.palli@intel.com>
5 years agoegl: handle EGL_IMAGE_EXTERNAL_FLUSH_EXT
Marek Olšák [Thu, 17 Oct 2019 22:59:23 +0000 (18:59 -0400)]
egl: handle EGL_IMAGE_EXTERNAL_FLUSH_EXT

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-By: Tapani Pälli <tapani.palli@intel.com>
5 years agost/dri: add support for EGL_EXT_image_flush_external
Marek Olšák [Thu, 17 Oct 2019 21:47:14 +0000 (17:47 -0400)]
st/dri: add support for EGL_EXT_image_flush_external

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-By: Tapani Pälli <tapani.palli@intel.com>
5 years agost/dri: assume external consumers of back buffers can write to the buffers
Marek Olšák [Thu, 17 Oct 2019 20:46:06 +0000 (16:46 -0400)]
st/dri: assume external consumers of back buffers can write to the buffers

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-By: Tapani Pälli <tapani.palli@intel.com>
5 years agodri_interface: add interface for EGL_EXT_image_flush_external
Marek Olšák [Thu, 17 Oct 2019 20:48:48 +0000 (16:48 -0400)]
dri_interface: add interface for EGL_EXT_image_flush_external

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-By: Tapani Pälli <tapani.palli@intel.com>
5 years agoinclude: add the definition of EGL_EXT_image_flush_external
Marek Olšák [Thu, 17 Oct 2019 22:58:42 +0000 (18:58 -0400)]
include: add the definition of EGL_EXT_image_flush_external

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-By: Tapani Pälli <tapani.palli@intel.com>
5 years agogitlab-ci: Add a job for meson on windows
Dylan Baker [Wed, 23 Oct 2019 21:36:19 +0000 (14:36 -0700)]
gitlab-ci: Add a job for meson on windows

This adds a new CI job that runs on windows with MSVC. It currently
builds softpipe and osmesa, and runs the related unit tests. It does
rely on meson's wraps for zlib, but I've set up caching of the wrap
dependencies so hopefully that wont be a problem.

I really wanted to user powershell for this, but there just isn't an
easy way to do that, it's much easier to use batch scripts, so thats
what I used.

The leading `/` for .gitlab-ci/lava... must be removed because windows
doesn't understand it, and when it reads the file the job ends in error.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
5 years agogitlab-ci: refactor out some common stuff for Windows and Linux
Dylan Baker [Wed, 23 Oct 2019 21:21:31 +0000 (14:21 -0700)]
gitlab-ci: refactor out some common stuff for Windows and Linux

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
5 years agonir: Fix invalid code for MSVC
Dylan Baker [Fri, 25 Oct 2019 20:56:23 +0000 (13:56 -0700)]
nir: Fix invalid code for MSVC

Fixes: ee2050b1111b65594f3470035f7b6f1330824684
       ("nir: Use BITSET for tracking varyings in lower_io_arrays")

5 years agodocs: update releasing process to use new scripts and gitlab
Dylan Baker [Thu, 24 Oct 2019 20:21:45 +0000 (13:21 -0700)]
docs: update releasing process to use new scripts and gitlab

There were several out of date entries in this document, update them to
current practices.

Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
5 years agobin/gen_release_notes.py: Add a warning if new features are introduced in a point...
Dylan Baker [Thu, 24 Oct 2019 20:11:40 +0000 (13:11 -0700)]
bin/gen_release_notes.py: Add a warning if new features are introduced in a point release

Fixes: 86079447da1e00d49db0cbff9a102eb4e71e8702
       ("scripts: Add a gen_release_notes.py script")
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
5 years agobin/gen_release_notes.py: html escape all external data
Dylan Baker [Wed, 23 Oct 2019 15:50:40 +0000 (08:50 -0700)]
bin/gen_release_notes.py: html escape all external data

All of these (bug titles, patch titles, features, and people's names)
can contain characters that are not valid html. Just escape everything
for safety.

Fixes: 86079447da1e00d49db0cbff9a102eb4e71e8702
       ("scripts: Add a gen_release_notes.py script")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
5 years agobin/post_release.py: Add .html to hrefs
Dylan Baker [Wed, 9 Oct 2019 17:33:14 +0000 (10:33 -0700)]
bin/post_release.py: Add .html to hrefs

oops.

Fixes: 3226b12a09bbcbd25526fd6da6257057d26ddb31
       ("release: Add an update_release_calendar.py script")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
5 years agobin/post_version.py: white space fixes
Dylan Baker [Wed, 9 Oct 2019 17:33:02 +0000 (10:33 -0700)]
bin/post_version.py: white space fixes

Fixes: 3226b12a09bbcbd25526fd6da6257057d26ddb31
       ("release: Add an update_release_calendar.py script")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
5 years agobin/post_version.py: Pass version as an argument
Dylan Baker [Wed, 9 Oct 2019 17:31:16 +0000 (10:31 -0700)]
bin/post_version.py: Pass version as an argument

I made a bad assumption; I assumed this would be run in the release
branch. But we don't do that, we run in the master branch. As a result
we need to pass the version as an argument.

Fixes: 3226b12a09bbcbd25526fd6da6257057d26ddb31
       ("release: Add an update_release_calendar.py script")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
5 years agobin/gen_release_notes.py: Return "None" if there are no new features
Dylan Baker [Wed, 9 Oct 2019 17:30:17 +0000 (10:30 -0700)]
bin/gen_release_notes.py: Return "None" if there are no new features

Which is very likely .Z > 0 releases.

Fixes: 86079447da1e00d49db0cbff9a102eb4e71e8702
       ("scripts: Add a gen_release_notes.py script")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
5 years agobin/gen_release_notes.py: strip '#' from gitlab bugs
Dylan Baker [Wed, 9 Oct 2019 17:29:41 +0000 (10:29 -0700)]
bin/gen_release_notes.py: strip '#' from gitlab bugs

If they use the `Fixes: #1` form.

Fixes: 86079447da1e00d49db0cbff9a102eb4e71e8702
       ("scripts: Add a gen_release_notes.py script")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
5 years agobin/gen_release_notes.py: fix conditional of bugfix
Dylan Baker [Wed, 9 Oct 2019 17:27:13 +0000 (10:27 -0700)]
bin/gen_release_notes.py: fix conditional of bugfix

Previously this would result in the .0 warning be generated for .z > 0
and the .z == 0 would get the other message.

Fixes: 86079447da1e00d49db0cbff9a102eb4e71e8702
       ("scripts: Add a gen_release_notes.py script")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
5 years agomesa/main: Ignore filter state for MS texture completeness
Illia Iorin [Tue, 13 Aug 2019 08:57:37 +0000 (11:57 +0300)]
mesa/main: Ignore filter state for MS texture completeness

After the discussion in
https://github.com/KhronosGroup/OpenGL-API/issues/45
the section 8.17 (texture completeness) of the OpenGL 4.6 core profile
was changed to explicitly say that multisample texture completeness
ignores filter state of the texture.

"Using the preceding definitions, a texture is complete unless any of the
 following conditions hold true:
   ...
  - The minification filter requires a mipmap (is neither NEAREST nor LINEAR),
    the texture is not multisample, and the texture is not mipmap complete.
  - The texture is not multisample; either the magnification filter is not
    NEAREST, or the minification filter is neither NEAREST nor NEAREST_-
    MIPMAP_NEAREST; and any of
    – The internal format of the texture is integer (see table 8.12).
    – The internal format is STENCIL_INDEX.
    – The internal format is DEPTH_STENCIL, and the value of DEPTH_-
      STENCIL_TEXTURE_MODE for the texture is STENCIL_INDEX."

Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Signed-off-by: Illia Iorin <illia.iorin@globallogic.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
5 years agoRevert "mesa/main: Fix multisample texture initialize"
Illia Iorin [Mon, 22 Jul 2019 14:07:39 +0000 (17:07 +0300)]
Revert "mesa/main: Fix multisample texture initialize"

This reverts commit a113a42e7369a4e43a1db1c9a7a35a3f7175615e.

Per https://github.com/KhronosGroup/OpenGL-API/issues/45 it
was a wrong way to fix the issue.

Signed-off-by: Illia Iorin <illia.iorin@globallogic.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
5 years agoglsl/serialize: optimize for equal offsets in uniform remap tables
Marek Olšák [Fri, 25 Oct 2019 03:26:57 +0000 (23:26 -0400)]
glsl/serialize: optimize for equal offsets in uniform remap tables

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/1416
This decreases the shader cache size in the ticket from 1.6 MB to 40 KB.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
5 years agoglsl/serialize: restructure remap table code
Marek Olšák [Fri, 25 Oct 2019 02:54:24 +0000 (22:54 -0400)]
glsl/serialize: restructure remap table code

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
5 years agonir: Use VARYING_SLOT_TESS_MAX to size indirect bitmasks
Kenneth Graunke [Fri, 25 Oct 2019 18:18:52 +0000 (11:18 -0700)]
nir: Use VARYING_SLOT_TESS_MAX to size indirect bitmasks

MAX_VARYINGS_INCL_PATCH subtracts VARYING_SLOT_VAR0 giving us a size
that's too small, so BITSET_SET writes words out of bounds, corrupting
the stack and causing all kinds of chaos.  VARYING_SLOT_TESS_MAX is
the right value to use here, as it's the largest location.

Closes: 2002
Fixes: ee2050b1111 ("nir: Use BITSET for tracking varyings in lower_io_arrays")
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agoRevert "ci: Disable lima until its farm can get fixed."
Neil Armstrong [Fri, 25 Oct 2019 10:19:24 +0000 (12:19 +0200)]
Revert "ci: Disable lima until its farm can get fixed."

This reverts commit fb9362c6fb9d5bd92073d31d3242614856b91f5d.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
5 years agoRevert "mapi: Inline call x86_current_tls."
Jason Ekstrand [Fri, 25 Oct 2019 16:31:23 +0000 (11:31 -0500)]
Revert "mapi: Inline call x86_current_tls."

This reverts commit e137b3a9b71a2711c1f68c8a8b9c0a7407fbcc4b.  It
completely broke 32-bit EGL such that wflinfo can't even run without
crashing.

5 years agorbug: Fix use of alloca() without #include "c99_alloca.h"
Jon Turney [Sat, 19 Oct 2019 13:43:49 +0000 (14:43 +0100)]
rbug: Fix use of alloca() without #include "c99_alloca.h"

[12/60] Compiling C object 'src/gallium/auxiliary/eb820e8@@gallium@sta/rbug_rbug_texture.c.o'.
FAILED: src/gallium/auxiliary/eb820e8@@gallium@sta/rbug_rbug_texture.c.o
[...]
../src/gallium/auxiliary/rbug/rbug_texture.c: In function 'rbug_send_texture_info_reply':
../src/gallium/auxiliary/rbug/rbug_texture.c:302:21: error: implicit declaration of function 'alloca'; did you mean 'malloc'? [-Werror=implicit-function-declaration]
  uint32_t *height = alloca(sizeof(uint32_t) * height_len);
                     ^~~~~~
                     malloc
../src/gallium/auxiliary/rbug/rbug_texture.c:302:21: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
../src/gallium/auxiliary/rbug/rbug_texture.c:303:20: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
  uint32_t *depth = alloca(sizeof(uint32_t) * height_len);
                    ^~~~~~
cc1: some warnings being treated as errors

Include c99_alloca.h to portably make the alloca() prototype available.

See also: 498d9d0fadfb9c5cfc8139b1

Fixes: 6174cba7 ("rbug: fix transmitted texture sizes")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
5 years agopan/midgard: Express allocated registers as offsets
Alyssa Rosenzweig [Thu, 24 Oct 2019 00:19:22 +0000 (20:19 -0400)]
pan/midgard: Express allocated registers as offsets

Rather than supplying a mask/swizzle to compose with the original, just
supply the offset of the allocated register so we can directly offset
the mask/swizzle, without resorting to composition.

This is simpler, cleaner, and will generalize to non-32-bit.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
5 years agopan/midgard: Expose more typesize manipulation routines
Alyssa Rosenzweig [Thu, 24 Oct 2019 13:15:28 +0000 (09:15 -0400)]
pan/midgard: Expose more typesize manipulation routines

These internal mir.c routines will help the RA.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
5 years agopan/midgard: Add mir_set_bytemask helper
Alyssa Rosenzweig [Thu, 24 Oct 2019 00:19:11 +0000 (20:19 -0400)]
pan/midgard: Add mir_set_bytemask helper

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
5 years agost/nine: Fix unused variable warnings in release build.
Timur Kristóf [Fri, 25 Oct 2019 08:46:43 +0000 (10:46 +0200)]
st/nine: Fix unused variable warnings in release build.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
5 years agost/nine: Fix build with -Werror=empty-body
Timur Kristóf [Fri, 25 Oct 2019 08:44:23 +0000 (10:44 +0200)]
st/nine: Fix build with -Werror=empty-body

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/1995
Fixes: 8d43e2b2ded0fe3c82d4 ("meson: add -Werror=empty-body to disallow `if(x);`")
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
5 years agoaco: Refactor hazard mitigations, separate pass for GFX10.
Timur Kristóf [Thu, 24 Oct 2019 10:26:12 +0000 (12:26 +0200)]
aco: Refactor hazard mitigations, separate pass for GFX10.

GFX10 hazards require a different approach compared to previous
generations, for example it doesn't need s_nop, and most hazards
can't be solved by adding NOPs at all. Also, they are not
resolved by branch instructions.

This commit reorganizes aco_insert_NOPs so that there is now a
separate pass for GFX10. The new GFX10 pass also respects the
control flow of the shader.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
5 years agoaco/gfx10: Fix mitigation of VMEMtoScalarWriteHazard.
Timur Kristóf [Wed, 23 Oct 2019 19:51:14 +0000 (21:51 +0200)]
aco/gfx10: Fix mitigation of VMEMtoScalarWriteHazard.

This commit refines the VMEMtoScalarWriteHazard mitigation, based
upon a closer look at what LLVM does. Also changes the code to
match the structure of the other hazard mitigations.

* The hazard is not only triggered by VMEM, FLAT and GLOBAL
  but also SCRATCH and DS instructions.
* The SMEM/SALU instructions only cause a hazard when they
  write a register that the VMEM/etc. are reading.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
5 years agoaco/gfx10: Mitigate LdsBranchVmemWARHazard.
Timur Kristóf [Thu, 24 Oct 2019 16:55:07 +0000 (18:55 +0200)]
aco/gfx10: Mitigate LdsBranchVmemWARHazard.

There is a hazard caused by there is a branch between a
VMEM/GLOBAL/SCRATCH instruction and a DS instruction.
This commit adds a workaround that avoids the problem.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
5 years agoaco/gfx10: Mitigate SMEMtoVectorWriteHazard.
Timur Kristóf [Thu, 24 Oct 2019 09:45:27 +0000 (11:45 +0200)]
aco/gfx10: Mitigate SMEMtoVectorWriteHazard.

There is a hazard that happens when an SMEM instruction
reads an SGPR and then a VALU instruction writes that same SGPR.
This commit adds a workaround that avoids the problem.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
5 years agoaco/gfx10: Mitigate VcmpxExecWARHazard.
Timur Kristóf [Wed, 23 Oct 2019 19:43:50 +0000 (21:43 +0200)]
aco/gfx10: Mitigate VcmpxExecWARHazard.

There is a hazard when a non-VALU instruction reads the EXEC mask
and then a VALU instruction writes the EXEC mask.
This commit adds a workaround that avoids the problem.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
5 years agoaco/gfx10: Mitigate VcmpxPermlaneHazard.
Timur Kristóf [Wed, 23 Oct 2019 09:24:53 +0000 (11:24 +0200)]
aco/gfx10: Mitigate VcmpxPermlaneHazard.

Any permlane instruction that follows any VOPC instruction can cause a hazard,
this commit implements a workaround that avoids this causing a problem.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
5 years agoaco/gfx10: Add notes about some GFX10 hazards.
Timur Kristóf [Thu, 17 Oct 2019 15:14:37 +0000 (17:14 +0200)]
aco/gfx10: Add notes about some GFX10 hazards.

ACO currently mitigates VMEMtoScalarWriteHazard and Offset3fBug
(names from LLVM). There are some bugs that ACO needn't care about.
Just to be on the safe side, add an assertion that makes sure
that we aren't hit by FlatSegmentOffsetBug.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
5 years agoradv: fix VK_KHR_shader_float_controls dependency on GFX6-7
Samuel Pitoiset [Thu, 24 Oct 2019 13:16:07 +0000 (15:16 +0200)]
radv: fix VK_KHR_shader_float_controls dependency on GFX6-7

From the Vulkan spec 1.1.126 :
   "VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY_KHR specifies
    that shader float controls for 32-bit floating point can be set
    independently; other bit widths must be set identically to each
    other."

Forgot to update this when I enabled that extension recently.

Fixes dEQP-VK.spirv_assembly.instruction.compute.float_controls.independence_settings.independence_setting

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agomapi: Inline call x86_current_tls.
Lepton Wu [Tue, 22 Oct 2019 03:22:18 +0000 (20:22 -0700)]
mapi: Inline call x86_current_tls.

This saves one return and a simple benchmark which calls glGetString
repeatedly on my desktop shows it improves calls per second from 118M
to 128M.

Signed-off-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agovirgl: Remove formats with unusual sample count.
Lepton Wu [Mon, 16 Sep 2019 03:05:44 +0000 (20:05 -0700)]
virgl: Remove formats with unusual sample count.

Most GPU require the sample count is power of 2. Just remove those
formats with unusual sample count. This decreases dEQP EGL tests run
time a lot.

Signed-off-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
5 years agonir: Use BITSET for tracking varyings in lower_io_arrays
Kristian H. Kristensen [Thu, 24 Oct 2019 04:41:45 +0000 (21:41 -0700)]
nir: Use BITSET for tracking varyings in lower_io_arrays

MAX_VARYINGS_INCL_PATCH is greater than 64, so we'll need more that 64
bits (per component) to track which vars have indirects. This pass was
trying to track patch varyings (which start at bit 63) in a separate
64 bit word, but failed to subtract VARYING_SLOT_PATCH0 and accessed
out of bounds.

Do away with the ad-hoc bit mask tracking and just use a BITSET.

Fixes: dEQP-GLES31.functional.tessellation.user_defined_io.per_patch_block.vertex_io_array_size_implicit.triangles
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agodocs: update calendar, add news item and link release notes for 19.2.2
Dylan Baker [Thu, 24 Oct 2019 21:11:31 +0000 (14:11 -0700)]
docs: update calendar, add news item and link release notes for 19.2.2

5 years agodocs: Add sha256 sum for 19.2.2
Dylan Baker [Thu, 24 Oct 2019 21:08:25 +0000 (14:08 -0700)]
docs: Add sha256 sum for 19.2.2

5 years agodocs: Add release notes for 19.2.2
Dylan Baker [Wed, 23 Oct 2019 15:54:11 +0000 (08:54 -0700)]
docs: Add release notes for 19.2.2

5 years agofreedreno/ir3: handle the progress case
Rob Clark [Fri, 18 Oct 2019 22:55:10 +0000 (15:55 -0700)]
freedreno/ir3: handle the progress case

In some cases, in particular when you have things that can be src
modifiers ((abs)/(neg)), once eliminating one mov, there is a
possibility to remove another.  Handle this by re-visiting an
instruction after eliminating a copy on one of it's srcs.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agofreedreno/ir3: remove restrictions on const + (abs)/(neg)
Rob Clark [Fri, 18 Oct 2019 22:53:07 +0000 (15:53 -0700)]
freedreno/ir3: remove restrictions on const + (abs)/(neg)

These date back to relatively early days of ir3, when a lot was still
not well understood.  But according to CI (and what I've seen blob
driver do), these are not actually real restrictions.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agofreedreno/ir3: allow copy-propagate out of fanout
Rob Clark [Fri, 18 Oct 2019 22:46:59 +0000 (15:46 -0700)]
freedreno/ir3: allow copy-propagate out of fanout

Now that we fixed the sharp edges that this was papering over, we can
relax the restriction about eliminating a mov coming out of a fanout
(for example from result of texture fetch).

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agofreedreno/ir3: treat high vs low reg as conversion
Rob Clark [Tue, 15 Oct 2019 23:08:26 +0000 (16:08 -0700)]
freedreno/ir3: treat high vs low reg as conversion

This avoids copy-propagating a high register into an instruction which
cannot consume it.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agofreedreno/ir3: propagate dest flags for collect/fanin
Rob Clark [Tue, 15 Oct 2019 22:46:42 +0000 (15:46 -0700)]
freedreno/ir3: propagate dest flags for collect/fanin

We did this properly already for split/fanout.  But collect was missed.
Extract out a helper to share.

This way we avoid copy propagating a mov from high or half reg into an
instruction which cannot consume a high/half reg.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agofreedreno/ir3: make high regs easier to see in IR dumps
Rob Clark [Tue, 15 Oct 2019 23:28:50 +0000 (16:28 -0700)]
freedreno/ir3: make high regs easier to see in IR dumps

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agofreedreno/ir3: debug cleanup
Rob Clark [Mon, 14 Oct 2019 17:42:25 +0000 (10:42 -0700)]
freedreno/ir3: debug cleanup

1) deduplicate IR3_SHADER_DEBUG=disasm versus fs/vs/etc handling
2) standardize shader stage name prints, in particular VERT vs BVERT
3) don't mix stderr and stdout

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
5 years agospirv: Add helper to find args of Image Operands
Caio Marcelo de Oliveira Filho [Wed, 23 Oct 2019 06:37:18 +0000 (23:37 -0700)]
spirv: Add helper to find args of Image Operands

Avoid keeping track of the idx and all possible image operands for
each operation.  Note for convenience we split up the handling of
ImageOperandsOffsetMask and ImageOperandsConstOffsetMask.

Suggested by Jason Ekstrand.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agospirv: Check that only one offset is defined as Image Operand
Caio Marcelo de Oliveira Filho [Wed, 23 Oct 2019 06:40:08 +0000 (23:40 -0700)]
spirv: Check that only one offset is defined as Image Operand

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agospirv: Add imageoperands_to_string helper
Caio Marcelo de Oliveira Filho [Wed, 23 Oct 2019 05:25:29 +0000 (22:25 -0700)]
spirv: Add imageoperands_to_string helper

Change the information to also include the category, so that the
particulars of BitEnum enumeration can be handled in the template.

Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agoanv: Implement VK_KHR_vulkan_memory_model
Caio Marcelo de Oliveira Filho [Thu, 5 Sep 2019 18:10:02 +0000 (11:10 -0700)]
anv: Implement VK_KHR_vulkan_memory_model

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
5 years agospirv: Handle MakePointerAvailable/Visible
Caio Marcelo de Oliveira Filho [Tue, 10 Sep 2019 20:21:08 +0000 (13:21 -0700)]
spirv: Handle MakePointerAvailable/Visible

Emit barriers with semantics matching the access operand and the
storage class of the pointer.

v2: Fix order of visible / available emission relative to the
    operations.  (Bas)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agospirv: Handle MakeTexelAvailable/Visible
Caio Marcelo de Oliveira Filho [Tue, 10 Sep 2019 20:16:46 +0000 (13:16 -0700)]
spirv: Handle MakeTexelAvailable/Visible

Set the memory semantics and scope for later emitting the barrier.
Note the barrier emission code already exist in vtn_handle_image for
the Image atomics.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agospirv: Add option to emit scoped memory barriers
Caio Marcelo de Oliveira Filho [Tue, 10 Sep 2019 19:19:08 +0000 (12:19 -0700)]
spirv: Add option to emit scoped memory barriers

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agospirv: Add SpvMemoryModelVulkan and related capabilities
Caio Marcelo de Oliveira Filho [Tue, 10 Sep 2019 19:38:00 +0000 (12:38 -0700)]
spirv: Add SpvMemoryModelVulkan and related capabilities

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agospirv: Emit memory barriers for atomic operations
Caio Marcelo de Oliveira Filho [Tue, 10 Sep 2019 20:21:49 +0000 (13:21 -0700)]
spirv: Emit memory barriers for atomic operations

Add a helper to split the memory semantics into before and after the
operation, and use that result to emit memory barriers.

v2: Be more explicit about which bits we are keeping around when
    splitting memory semantics into a before and after.  For now
    we are ignoring Volatile.  (Jason)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agospirv: Parse memory semantics for atomic operations
Caio Marcelo de Oliveira Filho [Tue, 10 Sep 2019 20:16:36 +0000 (13:16 -0700)]
spirv: Parse memory semantics for atomic operations

Including the right storage memory semantic based on the storage class
of the operation.  These will be used later to emit memory barriers.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agointel/fs: Implement scoped_memory_barrier
Caio Marcelo de Oliveira Filho [Thu, 5 Sep 2019 18:08:05 +0000 (11:08 -0700)]
intel/fs: Implement scoped_memory_barrier

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
5 years agonir/tests: Add copy propagation tests with scoped_memory_barrier
Caio Marcelo de Oliveira Filho [Fri, 18 Oct 2019 05:58:57 +0000 (22:58 -0700)]
nir/tests: Add copy propagation tests with scoped_memory_barrier

Three groups of tests, effectively defining what cases the
optimization is allowed or prevented

- Redudant loads       (a load  generated the value)
- Propagate SSA values (a store generated the value)
- Propagate a var      (a copy  generated the value)

Change the shader type of the tests to be COMPUTE so
nir_var_mem_shared can also be used.  Doesn't affect the semantic of
the copy propagation.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agonir: Add scoped_memory_barrier intrinsic
Caio Marcelo de Oliveira Filho [Thu, 18 Jul 2019 23:14:03 +0000 (16:14 -0700)]
nir: Add scoped_memory_barrier intrinsic

Add a NIR instrinsic that represent a memory barrier in SPIR-V /
Vulkan Memory Model, with extra attributes that describe the barrier:

- Ordering: whether is an Acquire or Release;
- "Cache control": availability ("ensure this gets written in the memory")
  and visibility ("ensure my cache is up to date when I'm reading");
- Variable modes: which memory types this barrier applies to;
- Scope: how far this barrier applies.

Note that unlike in SPIR-V, the "Storage Semantics" and the "Memory
Semantics" are split into two different attributes so we can use
variable modes for the former.

NIR passes that took barriers in consideration were also changed

- nir_opt_copy_prop_vars: clean up the values for the mode of an
  ACQUIRE barrier.  Copy propagation effect is to "pull up a load" (by
  not performing it), which is what ACQUIRE restricts.

- nir_opt_dead_write_vars and nir_opt_combine_writes: clean up the
  pending writes for the modes of an RELEASE barrier.  Dead writes
  effect is to "push down a store", which is what RELEASE restricts.

- nir_opt_access: treat the ACQUIRE and RELEASE as a full barrier for
  the modes.  This is conservative, but since this is a GL-specific
  pass, doesn't make a difference for now.

v2: Fix the scoped barrier handling in copy propagation.  (Jason)
    Add scoped barrier handling to nir_opt_access and
    nir_opt_combine_writes.  (Rhys)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agospirv/info: Add a memorymodel_to_string helper
Jason Ekstrand [Fri, 6 Jul 2018 21:05:22 +0000 (14:05 -0700)]
spirv/info: Add a memorymodel_to_string helper

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agodocs: Add release not about scons deprecation
Dylan Baker [Thu, 24 Oct 2019 17:09:21 +0000 (10:09 -0700)]
docs: Add release not about scons deprecation

5 years agoscons: Also print a deprecation warning on windows
Dylan Baker [Mon, 21 Oct 2019 17:18:50 +0000 (10:18 -0700)]
scons: Also print a deprecation warning on windows

This warning is different. Meson support for windows is less mature than
for other platforms, and the goal here is to alert people that
eventually we plan to drop scons and move to meson, and that they should
try out meson and report issues.

Reviewed-by: Eric Anholt <eric@anholt.net>
5 years agoscons: Print a deprecation warning about using scons on not windows
Dylan Baker [Mon, 21 Oct 2019 16:29:23 +0000 (09:29 -0700)]
scons: Print a deprecation warning about using scons on not windows

At this point meson should be able to handle all of the non-windows
platforms just fine; we'd like to be able to stop maintaining scons for
those platforms sooner than later.

Reviewed-by: Eric Anholt <eric@anholt.net>
5 years agoscons: Use print_function ins SConstruct
Dylan Baker [Mon, 21 Oct 2019 16:24:12 +0000 (09:24 -0700)]
scons: Use print_function ins SConstruct

This ensures that we get python3's print() function behavior even in
python2, instead of python2's print statement behavior. We'll be using
this in the next patch.

Reviewed-by: Eric Anholt <eric@anholt.net>
5 years agogallium: Fix a bunch of undefined left-shifts in u_format_*
Adam Jackson [Wed, 23 Oct 2019 21:07:03 +0000 (17:07 -0400)]
gallium: Fix a bunch of undefined left-shifts in u_format_*

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
5 years agoradv: compute the number of records correctly for vertex buffers
Samuel Pitoiset [Mon, 21 Oct 2019 16:41:33 +0000 (18:41 +0200)]
radv: compute the number of records correctly for vertex buffers

On GFX8 the number of records is in bytes while on other chips
it's in units of "stride".

Fixes dEQP-VK.robustness.vertex_access.*.draw.vertex_* on RAVEN.

Tested on GFX6, GFX8, GFX10 and RAVEN.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
5 years agogitlab-ci: Enable UBSan for the meson-vulkan job
Michel Dänzer [Wed, 25 Sep 2019 10:56:58 +0000 (12:56 +0200)]
gitlab-ci: Enable UBSan for the meson-vulkan job

It doesn't report any errors now.

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
5 years agoutil/tests: Avoid int64_t overflow issues in fast_idiv_by_const test
Michel Dänzer [Wed, 25 Sep 2019 09:55:33 +0000 (11:55 +0200)]
util/tests: Avoid int64_t overflow issues in fast_idiv_by_const test

Flagged by UBSan:

../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:233:14: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
    #0 0x55b4c1a2a428 in rand_sint ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:233
    #1 0x55b4c1a2ad3a in random_sdiv_test ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:308
    #2 0x55b4c1a2b837 in fast_idiv_by_const_int32_Test::TestBody() ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:410
    #3 0x55b4c1abc13f in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #4 0x55b4c1aa7a4d in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #5 0x55b4c1a4ce57 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
    #6 0x55b4c1a4f530 in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #7 0x55b4c1a51cbe in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #8 0x55b4c1a6d698 in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #9 0x55b4c1abfd58 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #10 0x55b4c1aab425 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #11 0x55b4c1a64cba in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #12 0x55b4c1ae4b73 in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #13 0x55b4c1ae4a33 in main ../src/gtest/src/gtest_main.cc:37
    #14 0x7ff172d1dbba in __libc_start_main ../csu/libc-start.c:308
    #15 0x55b4c1a28dc9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test+0x96dc9)

../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:309:52: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself
    #0 0x563b24dafd2d in random_sdiv_test ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:309
    #1 0x563b24db0f0f in fast_idiv_by_const_int64_Test::TestBody() ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:473
    #2 0x563b24e41111 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #3 0x563b24e2ca1f in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #4 0x563b24dd1e29 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
    #5 0x563b24dd4502 in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #6 0x563b24dd6c90 in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #7 0x563b24df266a in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #8 0x563b24e44d2a in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #9 0x563b24e303f7 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #10 0x563b24de9c8c in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #11 0x563b24e69b45 in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #12 0x563b24e69a05 in main ../src/gtest/src/gtest_main.cc:37
    #13 0x7f9a90330bba in __libc_start_main ../csu/libc-start.c:308
    #14 0x563b24daddc9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test+0x96dc9)

v2:
* Use INT64_MIN instead of LLONG_MIN (Jason Ekstrand)
* Simpler test for INT64_MIN result from rand_sint (Jason Ekstrand)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
5 years agoutil: Use uint64_t for shifting left in sign_extend and strunc
Michel Dänzer [Wed, 25 Sep 2019 09:44:24 +0000 (11:44 +0200)]
util: Use uint64_t for shifting left in sign_extend and strunc

Shifting int64_t values left into the sign bit has undefined behaviour:

../src/util/fast_idiv_by_const.c:175:14: runtime error: left shift of 131 by 56 places cannot be represented in type 'long int'
    #0 0x561337ed10c1 in sign_extend ../src/util/fast_idiv_by_const.c:175
    #1 0x561337ed1335 in util_compute_fast_sdiv_info ../src/util/fast_idiv_by_const.c:239
    #2 0x561337e17519 in fast_idiv_by_const_int8_Test::TestBody() ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:357
    #3 0x561337ea815d in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #4 0x561337e93a6b in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #5 0x561337e38e75 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
    #6 0x561337e3b54e in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #7 0x561337e3dcdc in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #8 0x561337e596b6 in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #9 0x561337eabd76 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #10 0x561337e97443 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #11 0x561337e50cd8 in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #12 0x561337ed0b91 in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #13 0x561337ed0a51 in main ../src/gtest/src/gtest_main.cc:37
    #14 0x7f85ba483bba in __libc_start_main ../csu/libc-start.c:308
    #15 0x561337e14dc9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test+0x96dc9)

../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:51:14: runtime error: left shift of negative value -63
    #0 0x55fc3c0e67cc in strunc ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:51
    #1 0x55fc3c0e6d93 in smul_high ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:140
    #2 0x55fc3c0e7067 in fast_sdiv ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:181
    #3 0x55fc3c0e858b in fast_idiv_by_const_int8_Test::TestBody() ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:358
    #4 0x55fc3c17915d in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #5 0x55fc3c164a6b in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #6 0x55fc3c109e75 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
    #7 0x55fc3c10c54e in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #8 0x55fc3c10ecdc in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #9 0x55fc3c12a6b6 in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #10 0x55fc3c17cd76 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #11 0x55fc3c168443 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #12 0x55fc3c121cd8 in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #13 0x55fc3c1a1b91 in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #14 0x55fc3c1a1a51 in main ../src/gtest/src/gtest_main.cc:37
    #15 0x7fd224759bba in __libc_start_main ../csu/libc-start.c:308
    #16 0x55fc3c0e5dc9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test+0x96dc9)

v2:
* Use two casts instead of changing the argument type (Jason Ekstrand)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
5 years agogallium/util: Cast to target type before shifting left
Michel Dänzer [Wed, 25 Sep 2019 09:37:49 +0000 (11:37 +0200)]
gallium/util: Cast to target type before shifting left

Otherwise a smaller type may be promoted to int, which can hit undefined
behaviour:

../src/gallium/auxiliary/util/u_half.h:126:29: runtime error: left shift of 32768 by 16 places cannot be represented in type 'int'
    #0 0x5646ff63d488 in util_half_to_float ../src/gallium/auxiliary/util/u_half.h:126
    #1 0x5646ff63d749 in _mesa_half_to_float ../src/util/half_float.c:145
    #2 0x5646ff54d557 in nir_const_value_negative_equal ../src/compiler/nir/nir_instr_set.c:372
    #3 0x5646ff44d29a in const_value_negative_equal_test_nir_type_float16_trivially_true_Test::TestBody() ../src/compiler/nir/tests/negative_equal_tests.cpp:121
    #4 0x5646ff505c05 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #5 0x5646ff4f1513 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #6 0x5646ff4979b5 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
    #7 0x5646ff49a08e in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #8 0x5646ff49c81c in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #9 0x5646ff4b81f6 in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #10 0x5646ff50981e in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #11 0x5646ff4f4eeb in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #12 0x5646ff4af818 in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #13 0x5646ff52e639 in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #14 0x5646ff52e4f9 in main ../src/gtest/src/gtest_main.cc:37
    #15 0x7f6bacb78bba in __libc_start_main ../csu/libc-start.c:308
    #16 0x5646ff448019 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/compiler/nir/negative_equal+0x17c019)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
5 years agointel/fs: Check for NULL key in fs_visitor constructor
Michel Dänzer [Wed, 25 Sep 2019 09:34:27 +0000 (11:34 +0200)]
intel/fs: Check for NULL key in fs_visitor constructor

Flagged by UBSan:

../src/intel/compiler/brw_fs_visitor.cpp:986:20: runtime error: member access within null pointer of type 'const struct brw_base_prog_key'
    #0 0x559fadb48556 in fs_visitor::init() ../src/intel/compiler/brw_fs_visitor.cpp:986
    #1 0x559fadb46db3 in fs_visitor::fs_visitor(brw_compiler const*, void*, void*, brw_base_prog_key const*, brw_stage_prog_data*, nir_shader const*, unsigned int, int, brw_vue_map const*) ../src/intel/compiler/brw_fs_visitor.cpp:962
    #2 0x559fad9c7cd8 in saturate_propagation_fs_visitor::saturate_propagation_fs_visitor(brw_compiler*, brw_wm_prog_data*, nir_shader*) (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/intel/compiler/fs_saturate_propagation+0x61bcd8)
    #3 0x559fad9960a1 in saturate_propagation_test::SetUp() ../src/intel/compiler/test_fs_saturate_propagation.cpp:65
    #4 0x559fadd7a32d in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #5 0x559fadd65c3b in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #6 0x559fadd0af75 in testing::Test::Run() ../src/gtest/src/gtest.cc:2470
    #7 0x559fadd0d8a4 in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #8 0x559fadd10032 in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #9 0x559fadd2ba0c in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #10 0x559fadd7df46 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #11 0x559fadd69613 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #12 0x559fadd2302e in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #13 0x559fadda2d61 in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #14 0x559fadda2c21 in main ../src/gtest/src/gtest_main.cc:37
    #15 0x7fe8f6748bba in __libc_start_main ../csu/libc-start.c:308
    #16 0x559fad9950f9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/intel/compiler/fs_saturate_propagation+0x5e90f9)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
5 years agointel/compiler: Cast to target type before shifting left
Michel Dänzer [Wed, 25 Sep 2019 09:31:23 +0000 (11:31 +0200)]
intel/compiler: Cast to target type before shifting left

Otherwise a smaller type may be promoted to int, which can hit undefined
behaviour:

../src/intel/compiler/brw_packed_float.c:66:17: runtime error: left shift of 128 by 24 places cannot be represented in type 'int'
    #0 0x5604a03969aa in brw_vf_to_float ../src/intel/compiler/brw_packed_float.c:66
    #1 0x5604a0391305 in vf_float_conversion_test_test_vf_to_float_Test::TestBody() ../src/intel/compiler/test_vf_float_conversions.cpp:70
    #2 0x5604a041a323 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #3 0x5604a0405c31 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #4 0x5604a03ab03b in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
    #5 0x5604a03ad714 in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #6 0x5604a03afea2 in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #7 0x5604a03cb87c in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #8 0x5604a041df3c in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #9 0x5604a0409609 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #10 0x5604a03c2e9e in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #11 0x5604a0442d57 in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #12 0x5604a0442c17 in main ../src/gtest/src/gtest_main.cc:37
    #13 0x7f9a1983dbba in __libc_start_main ../csu/libc-start.c:308
    #14 0x5604a0390d89 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/intel/compiler/vf_float_conversions+0x8dd89)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
5 years agointel/compiler: Don't left-shift by >= the number of bits of the type
Michel Dänzer [Wed, 25 Sep 2019 09:17:11 +0000 (11:17 +0200)]
intel/compiler: Don't left-shift by >= the number of bits of the type

To avoid it, use the modulo of the number of bits in the value being
shifted, which is presumably what ended up happening on x86.

Flagged by UBSan:

../src/intel/compiler/brw_eu_validate.c:974:33: runtime error: shift exponent 64 is too large for 64-bit type 'long unsigned int'
    #0 0x561abb612ab3 in general_restrictions_on_region_parameters ../src/intel/compiler/brw_eu_validate.c:974
    #1 0x561abb617574 in brw_validate_instructions ../src/intel/compiler/brw_eu_validate.c:1851
    #2 0x561abb53bd31 in validate ../src/intel/compiler/test_eu_validate.cpp:106
    #3 0x561abb555369 in validation_test_source_cannot_span_more_than_2_registers_Test::TestBody() ../src/intel/compiler/test_eu_validate.cpp:486
    #4 0x561abb742651 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #5 0x561abb72e64d in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #6 0x561abb6d5451 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
    #7 0x561abb6d7b2a in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #8 0x561abb6da2b8 in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #9 0x561abb6f5c92 in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #10 0x561abb74626a in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #11 0x561abb732025 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #12 0x561abb6ed2b4 in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #13 0x561abb768b3b in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #14 0x561abb7689fb in main ../src/gtest/src/gtest_main.cc:37
    #15 0x7f525e5a9bba in __libc_start_main ../csu/libc-start.c:308
    #16 0x561abb538ed9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/intel/compiler/eu_validate+0x1b8ed9)

Reviewed-by: Adam Jackson <ajax@redhat.com>
5 years agoanv: fix error message
Eric Engestrom [Thu, 24 Oct 2019 12:04:51 +0000 (13:04 +0100)]
anv: fix error message

`strerror()` takes an `errno`, not the negative value returned by the
`ioctl()`.
Instead of fixing this as `"%s", strerror(errno)`, let's just use the
`"%m"` shortcut for it.

Fixes: 2b5f30b1d91b98ab27ba ("anv: implement VK_INTEL_performance_query")
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
5 years agomeson: add -Werror=empty-body to disallow `if(x);`
Eric Engestrom [Mon, 23 Sep 2019 16:21:20 +0000 (17:21 +0100)]
meson: add -Werror=empty-body to disallow `if(x);`

This would have prevented a bug in MR 2058 [1]; with that MR fixed,
nothing else uses empty-body blocks, so let's just forbid them altogether.

[1] https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2058#note_237880

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>