mesa.git
7 years agodrirc: Add allow_glsl_builtin_variable_redeclaration for Dead Island Riptide Definiti...
Benedikt Schemmer [Mon, 22 May 2017 17:32:02 +0000 (19:32 +0200)]
drirc: Add allow_glsl_builtin_variable_redeclaration for Dead Island Riptide Definitive Edition

Signed-off-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agogallium/radeon: add a query for monitoring Gallium thread load
Marek Olšák [Fri, 12 May 2017 23:08:03 +0000 (01:08 +0200)]
gallium/radeon: add a query for monitoring Gallium thread load

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agoradeonsi/gfx9: compile shaders with +xnack
Marek Olšák [Fri, 7 Apr 2017 16:30:28 +0000 (18:30 +0200)]
radeonsi/gfx9: compile shaders with +xnack

so that LLVM doesn't allocate SGPRs where XNACK is.

Cc: 17.1 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agovc4: Remove dead code in vc4_dump_surface_msaa()
Rhys Kidd [Mon, 22 May 2017 03:42:47 +0000 (23:42 -0400)]
vc4: Remove dead code in vc4_dump_surface_msaa()

Coverity caught the use of dead code copy-paste for
found_colors[] and num_found_colors.

CID: 1341850
Signed-off-by: Rhys Kidd <rhyskidd@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
7 years agoegl/wayland: verify event queue was allocated
Lionel Landwerlin [Mon, 22 May 2017 10:07:53 +0000 (11:07 +0100)]
egl/wayland: verify event queue was allocated

We're already verified that 'window' wasn't NULL, I'm guessing this
allocation error is about the newly created queue.

CID: 1409754
Fixes: 03dd9a88b0b ("egl/wayland: Use per-surface event queues")
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agomesa: add APPLE_vertex_array_object stubs
Timothy Arceri [Fri, 19 May 2017 02:31:47 +0000 (12:31 +1000)]
mesa: add APPLE_vertex_array_object stubs

APPLE_vertex_array_object support was removed in 7927d0378fc7.
However it turns out we can't remove the functions because this
can cause issues when libglapi is used together with DRI
drivers built prior to said commit

Fixes: 7927d0378fc ("mesa: drop APPLE_vertex_array_object support")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoglsl: set mask via initialisation list rather than in constructor body
Timothy Arceri [Sat, 20 May 2017 03:54:20 +0000 (13:54 +1000)]
glsl: set mask via initialisation list rather than in constructor body

Potentially more efficient as it may avoid the struct being initialised
twice.

Also add var to the initialisation list while we are here.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agoralloc: Use strnlen() inside of strncat()
Vladislav Egorov [Sun, 21 May 2017 20:49:19 +0000 (22:49 +0200)]
ralloc: Use strnlen() inside of strncat()

If the str is long or isn't null-terminated, strlen() could take a lot
of time or even crash. I don't know why was it used in the first place,
maybe for platforms without strnlen(), but strnlen() is already used
inside of ralloc_strndup(), so this change should not additionally
break anything.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
7 years agoglcpp: Skip unnecessary line continuations removal
Vladislav Egorov [Sun, 21 May 2017 20:49:17 +0000 (22:49 +0200)]
glcpp: Skip unnecessary line continuations removal

Overwhelming majority of shaders don't use line continuations. In my
shader-db only shaders from the Talos Principle and Serious Sam used
them, less than 1% out of all shaders. Optimize for this case, don't
do any copying if no line continuation was found.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
7 years agoglcpp: Avoid unnecessary strcmp()
Vladislav Egorov [Sun, 21 May 2017 20:49:15 +0000 (22:49 +0200)]
glcpp: Avoid unnecessary strcmp()

strcmp() is slow. Initiate comparison with "__LINE__" or "__FILE__"
only if the identifier starts with '_', which is rare.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
7 years agomain: Move hashLockMutex/hashUnlockMutex to header and inline
Thomas Helland [Sun, 21 May 2017 13:17:26 +0000 (15:17 +0200)]
main: Move hashLockMutex/hashUnlockMutex to header and inline

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
7 years agomain: Use _mesa_HashLock/UnlockMutex consistently
Thomas Helland [Thu, 18 May 2017 18:39:20 +0000 (20:39 +0200)]
main: Use _mesa_HashLock/UnlockMutex consistently

This is shorter and easier on the eyes. At the same time this
also ensures that we are always asserting that the table pointer
is not NULL. Currently that was not done for all situations.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
7 years agoutil: Change the pointer hashing function
Thomas Helland [Fri, 10 Feb 2017 18:14:32 +0000 (19:14 +0100)]
util: Change the pointer hashing function

Use our knowledge that pointers are at least 4 byte aligned to remove
the useless digits. Then shift by 6, 10, and 14 bits and add this to
the original pointer, effectively folding in the entropy of the higher
bits of the pointer into a 4-bit section. Stopping at 14 means we can
add the entropy from 18 bits, or at least a 600Kbyte section of memory.
Assuming that ralloc allocates from a linearly allocated heap less than
this we can make a very efficient pointer hashing function for our usecase.
Even if we are not on an architecture that is 4 byte aligned, there is
still a high big chance that the thing we are allocating is at least
8 bytes in size, so even then we will have entropy into the third bit.

The 4 bit increment on the shifts is chosen rather arbitrarily; if we
had chosen a 3 bit increment we would need to add another xor to
cover a decently sized memorypool. Increasing it to 5 bits would
spread our entropy more, possibly hurting us with more collisions on
hash tables of size less than 32. With a hash table of size 16 there
are a max of 11 entries, and we can assume that with such a small table
collisions are not that painfull.

This allows us to hash the whole 32 or 64 bit pointer at once,
instead of running FNV1a, looping through each byte and doing
increments, decrements, muls, and xors on every byte. This cuts
_mesa_hash_data from 1.5 % on profiles, to making _mesa_hash_pointer
show up with a 0.09% share. Collisions on insertion actually seems to be
ever so slightly lower with this hash function, as found by printing
a loop counter and sorting the data.

perf stat shows a 1.5% reduction in instruction count,
and a 5% reduction in stalled cycles. Shader-db runtime goes
from 225 to 220 seconds.

No instruction-count changes in shader-db, but there are some minor
changes in cycle-count that is likely caused by nir walking a set
in some of its passes, and this causing a different ordering.
That might eventually lead to a difference in register allocation.
However, the effect is a net positive;

total cycles in shared programs: 24739550 -> 24738482 (-0.00%)
cycles in affected programs: 374468 -> 373400 (-0.29%)
helped: 178
HURT: 49

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
7 years agovulkan/wsi/wayland: Fix proxy wrappers for swapchain recreation
Philipp Zabel [Fri, 19 May 2017 22:07:12 +0000 (00:07 +0200)]
vulkan/wsi/wayland: Fix proxy wrappers for swapchain recreation

Before the swapchain event queue is destroyed, all proxy objects that reference
it must be dropped. Otherwise we risk a use-after-free if a frame callback event
or buffer release events are received afterwards.
This happens when an application destroys and recreates a swapchain in FIFO
mode between two frames without using the VkSwapchainCreateInfoKHR::oldSwapchain
mechanism to keep the old swapchain until after the next redraw.

Fixes: 5034c615582a ("vulkan/wsi/wayland: Use proxy wrappers for swapchain")
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agodrirc: Add allow_glsl_builtin_variable_redeclaration for Dying Light and Dead Island...
John Brooks [Mon, 15 May 2017 05:47:39 +0000 (01:47 -0400)]
drirc: Add allow_glsl_builtin_variable_redeclaration for Dying Light and Dead Island Definitive Edition

This fixes the long-standing problem with Dying Light where the game would
produce a black screen when running under Mesa. This happened because the
game's vertex shaders redeclare gl_VertexID, which is a GLSL builtin.
Mesa's GLSL compiler is a little more strict than others, and would not
compile them:

    error: `gl_VertexID' redeclared

The allow_glsl_builtin_variable_redeclaration directive allows the shaders
to compile and the game to render. The game also requires OpenGL 4.4+ (GLSL
440), but does not request it explicitly. It must be forced with an
override, such as MESA_GL_VERSION_OVERRIDE=4.5 and
MESA_GLSL_VERSION_OVERRIDE=450. A compatibility context is *not* required
and forcing one with 4.5COMPAT or allow_higher_compat_version results in
graphical artifacts.

Dead Island Definitive Edition is another Techland port on the same engine
with the same problems, so we set the
allow_glsl_builtin_variable_redeclaration option for that game as well.

v2 (Samuel Pitoiset):
    - Rename allow_glsl_builtin_redeclaration ->
      allow_glsl_builtin_variable_redeclaration

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96449
Signed-off-by: John Brooks <john@fastquake.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agoglsl: Conditionally allow redeclaration of built-in variables
John Brooks [Mon, 15 May 2017 05:47:38 +0000 (01:47 -0400)]
glsl: Conditionally allow redeclaration of built-in variables

Conditional on allow_glsl_builtin_variable_redeclaration driconf option.

v2 (Samuel Pitoiset):
    - Rename allow_glsl_builtin_redeclaration ->
      allow_glsl_builtin_variable_redeclaration
    - style: put spaces after 'if'

Signed-off-by: John Brooks <john@fastquake.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agodriconf: Add allow_glsl_builtin_variable_redeclaration option
John Brooks [Mon, 15 May 2017 05:47:37 +0000 (01:47 -0400)]
driconf: Add allow_glsl_builtin_variable_redeclaration option

This option will allow GLSL builtins to be redeclared verbatim (e.g.
redeclaring "in int gl_VertexID" in a vertex shader). This is not strictly
valid and would normally fail to compile, but some applications (such as
newer Techland ports) do it and need more leniency.

v2 (Samuel Pitoiset):
    - Rename allow_glsl_builtin_redeclaration ->
      allow_glsl_builtin_variable_redeclaration

Signed-off-by: John Brooks <john@fastquake.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agonv50,nvc0: clear index buffer bufctx bin unconditionally
Ilia Mirkin [Sat, 20 May 2017 08:18:20 +0000 (04:18 -0400)]
nv50,nvc0: clear index buffer bufctx bin unconditionally

The previous condition was to clear it out if it had previously been
set, not what's in the current draw. That information is gone now, so
just clear it unconditionally.

Fixes: 330d0607e ("gallium: remove pipe_index_buffer and set_index_buffer")
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonv50: fix vtxbuf cleanup
Ilia Mirkin [Sat, 20 May 2017 08:17:22 +0000 (04:17 -0400)]
nv50: fix vtxbuf cleanup

Use a user-buffer-aware cleanup function.

Fixes: c24c3b94ed ("gallium: decrease the size of pipe_vertex_buffer - 24 -> 16 bytes")
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agoi965: Use the upload BO for push constants on Gen7.5-Gen8.
Kenneth Graunke [Fri, 12 May 2017 05:23:14 +0000 (22:23 -0700)]
i965: Use the upload BO for push constants on Gen7.5-Gen8.

We can easily use the upload BO for push constants on Gen7.5/Gen8 too,
at the cost of a relocation when emitting 3DSTATE_CONSTANT_XS.  We can
simply switch to using constant buffer pointer 2 instead of pointer 0,
like we do on Gen9+.

Ivybridge and Baytrail can't do this trick because they require the
constant buffers to be enabled in order, starting with 0.  We'd have
to set the INSTPM bit to make the constant buffer pointer not relative
to dynamic state base address, which would need kernel command parser
support.

Improves performance in GLBenchmark 2.7/TRex Offscreen by:
- Broadwell GT2: 0.305608% +/- 0.19877% (n = 68)
- Braswell: No difference proven (n = 742)
- Haswell GT3e: 0.180755% +/- 0.0237505% (n = 30)

Reviewed-by: Chris Forbes <chrisforbes@google.com>
7 years agoi965: Use the upload BO for push constants on Gen9+.
Kenneth Graunke [Fri, 15 Aug 2014 05:46:54 +0000 (22:46 -0700)]
i965: Use the upload BO for push constants on Gen9+.

Shaders can use quite a bit of uniform data.  Better to put it in the
upload buffers, like we do for client vertex data, rather than the
batch buffer state area, which is primarly used for indirect state.

This should free up batch space, allowing us to emit more commands in a
batch before flushing.  Because BRW_NEW_BATCH also causes a lot of state
to be re-emitted, it may also reduce CPU overhead a little bit.

We took this approach on Gen4-5, but switched to using the batch area
on Gen6+ because buffer 0 is relative to Dynamic State Base Address by
default, which is set to the start of the batch.

On Gen9+, we already use a relocation due to a workaround, so this is
trivial to change and has basically no downside.

Unfortunately we can't change compute shader push constants because
MEDIA_CURBE_LOAD always uses an offset from dynamic state base address.

Improves performance in GLBenchmark 2.7/TRex Offscreen by:
- Skylake GT4e: 0.52821% +/- 0.113402% (n = 190)
- Apollolake: 0.510225% +/- 0.273064% (n = 70)

Reviewed-by: Chris Forbes <chrisforbes@google.com>
7 years agoi965: Drop BRW_NEW_PUSH_CONSTANT_ALLOCATION from CS packets.
Kenneth Graunke [Tue, 29 Nov 2016 09:30:18 +0000 (01:30 -0800)]
i965: Drop BRW_NEW_PUSH_CONSTANT_ALLOCATION from CS packets.

I don't think CS push constant uploading uses the section of L3
controlled by 3DSTATE_PUSH_CONSTANT_ALLOC_XS.  So I don't think
it needs to be re-emitted when that space is reallocated.

The programming note in gen7_allocate_push_constants doesn't
indicate this is necessary, at least.

Reviewed-by: Chris Forbes <chrisforbes@google.com>
7 years agonvc0/ir: SHLADD's middle source must be an immediate
Ilia Mirkin [Sat, 20 May 2017 07:11:12 +0000 (03:11 -0400)]
nvc0/ir: SHLADD's middle source must be an immediate

The instruction encodings only allow for immediates. Don't try to
replace a zero (which is dumb to have in that op in any case) with RZ.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
7 years agoandroid: add -Wl,--build-id=sha1 to LDFLAGS for libvulkan_intel
Tapani Pälli [Fri, 19 May 2017 11:25:49 +0000 (14:25 +0300)]
android: add -Wl,--build-id=sha1 to LDFLAGS for libvulkan_intel

Just like is done on desktop and what is expected by the build-id code.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoconfigure.ac: s/xcb-fixes/xcb-xfixes/
Emil Velikov [Sat, 20 May 2017 00:15:02 +0000 (01:15 +0100)]
configure.ac: s/xcb-fixes/xcb-xfixes/

Former is not a thing, even if I have a hacked xcb-fixes.pc on my system.
Thanks for spotting it Mark!

Fixes: 9a90d6a9d4e ("configure.ac: add xcb-fixes to the XCB DRI3 list")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure.ac: add xcb-fixes to the XCB DRI3 list
Emil Velikov [Fri, 19 May 2017 23:04:33 +0000 (00:04 +0100)]
configure.ac: add xcb-fixes to the XCB DRI3 list

The XCB module is used by the VL targets. Thus omitting it can lead to
link-time errors due to unresolved symbols.

Other DRI3 users such as the Vulkan WSI and the dri3 loader helper do
not use an update region in their xcb_present_pixmap() call. We will
look into that at a later stage.

Fixes: acf3d2afab0 ("configure: check once for DRI3 dependencies")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101110
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoautomake: add SWR LLVM gen_builder.hpp workaround
Emil Velikov [Thu, 18 May 2017 20:27:01 +0000 (21:27 +0100)]
automake: add SWR LLVM gen_builder.hpp workaround

As gen_builder.hpp file is generated, it contains information that is
specific to the LLVM version it originates from.

As suggested by Tim, the file seems to be forwards compatible. So in
order to produce ship a file which will work everywhere we should be
using earlies supported LLVM - 3.9.

With this we're back on track and can build all of mesa without
python/mako/flex and friends.

In the long term we might want to see if the python generators can be
updated to produce LLVM version agnostic files. At least within the
range supported by SWR.

Cc: <mesa-stable@lists.freedesktop.org>
Cc: Chuck Atkins <chuck.atkins@kitware.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
7 years agost/mesa: don't mark the program as in cache_fallback when there is cache miss
Timothy Arceri [Thu, 18 May 2017 05:10:08 +0000 (15:10 +1000)]
st/mesa: don't mark the program as in cache_fallback when there is cache miss

When we fallback currently the gl_program objects are re-allocated.

This is likely to change when the i965 cache lands, but for now
this fixes a crash when using MESA_GLSL=cache_fb. This env var
simulates the fallback path taken when a tgsi cache item doesn't
exist due to being evicted previously or some kind of error.

Unlike i965 we are always falling back at link time so it's safe to
just re-allocate everything. We will be unnecessarily freeing and
re-allocate a bunch of things here but it's probably not a huge deal,
and can be changed when the i965 code lands.

Fixes: 0e9991f957e2 ("glsl: don't reference shader prog data during cache fallback")
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agomesa: add an env var to force cache fallback
Timothy Arceri [Thu, 18 May 2017 05:00:40 +0000 (15:00 +1000)]
mesa: add an env var to force cache fallback

For the gallium state tracker a tgsi binary may have been evicted
from the cache to make space. In this case we would take the
fallback path and recompile/link the shader.

On i965 there are a number of reasons we can get to the program
upload stage and have neither IR nor a valid cached binary.
For example the binary may have been evicted from the cache or
we need a variant that wasn't previously cached.

This environment variable enables us to force the fallback path that
would be taken in these cases and makes it easier to debug these
otherwise hard to reproduce scenarios.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agost/mesa: improve shader cache debug info
Timothy Arceri [Thu, 18 May 2017 04:22:03 +0000 (14:22 +1000)]
st/mesa: improve shader cache debug info

This will explicitly state that we are following the fallback
path when we find invalid/corrupt cache items. It will also
output the fallback message when the fallback path is forced
via an environment variable, the following patches will allow
this.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agotravis: remove workarounds for the Vulkan target
Emil Velikov [Thu, 4 May 2017 10:05:27 +0000 (11:05 +0100)]
travis: remove workarounds for the Vulkan target

Previously we required --enable-egl for the platform selection to work.
Additionally due to the broken DRI3 dependency tracking we needed
--enable-glx.

Since both of these are now sorted now we no longer need the
workarounds.

While we're here, explicitly enable dri3.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agoconfigure: trivial whitespace cleanup
Emil Velikov [Wed, 7 Dec 2016 14:43:04 +0000 (14:43 +0000)]
configure: trivial whitespace cleanup

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agoconfigure: error out if building XVMC w/o supported platform
Emil Velikov [Wed, 7 Dec 2016 14:42:00 +0000 (14:42 +0000)]
configure: error out if building XVMC w/o supported platform

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agoconfigure: error out if building VDPAU w/o supported platform
Emil Velikov [Wed, 7 Dec 2016 14:40:39 +0000 (14:40 +0000)]
configure: error out if building VDPAU w/o supported platform

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agoconfigure: error out if building OMX w/o supported platform
Emil Velikov [Wed, 7 Dec 2016 14:38:10 +0000 (14:38 +0000)]
configure: error out if building OMX w/o supported platform

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agoconfigure: error out if building VA w/o supported platform
Emil Velikov [Wed, 7 Dec 2016 14:32:45 +0000 (14:32 +0000)]
configure: error out if building VA w/o supported platform

A bit pedantic patch to fool proof should someone start thinkering
without knowing what they do.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agost/xvmc: add DRI3 support
Emil Velikov [Fri, 25 Nov 2016 17:43:00 +0000 (17:43 +0000)]
st/xvmc: add DRI3 support

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agost/omx: add DRI3 support
Emil Velikov [Fri, 25 Nov 2016 17:23:33 +0000 (17:23 +0000)]
st/omx: add DRI3 support

Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-and-Tested-by: Leo Liu <leo.liu@amd.com>
7 years agogallium/targets: link against XCB only as needed
Emil Velikov [Wed, 3 May 2017 21:04:20 +0000 (22:04 +0100)]
gallium/targets: link against XCB only as needed

OMX and VA can optionally use the X11 DRI2/DRI3, thus we should link
only as required.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agost/omx: fix building against X11-less setups
Emil Velikov [Mon, 5 Dec 2016 22:22:44 +0000 (22:22 +0000)]
st/omx: fix building against X11-less setups

The vl_*_screen_create API properly falls back to a NOP when we're
building without specific platforms. So the only thing we need is to
handle the lack of X11/Xlib.h and provide a dummy Display define.

Cc: <mesa-stable@lists.freedesktop.org>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agost/omx: remove unneeded X11 include
Emil Velikov [Mon, 5 Dec 2016 22:27:21 +0000 (22:27 +0000)]
st/omx: remove unneeded X11 include

En route to a X11-less builds

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
7 years agost/omx: remove unused drm_driver.h includes
Emil Velikov [Mon, 5 Dec 2016 22:33:05 +0000 (22:33 +0000)]
st/omx: remove unused drm_driver.h includes

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
7 years agost/va: check if vl_*_screen_create has failed only once
Emil Velikov [Wed, 7 Dec 2016 14:04:03 +0000 (14:04 +0000)]
st/va: check if vl_*_screen_create has failed only once

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
7 years agost/va: fix misplaced closing bracket
Emil Velikov [Fri, 25 Nov 2016 17:55:52 +0000 (17:55 +0000)]
st/va: fix misplaced closing bracket

It's been like this since the code was introduced.

Fixes: 86eb4131a90 (st/va: add headless support, i.e. VA_DISPLAY_DRM)
Cc: <mesa-stable@lists.freedesktop.org>
Cc: Julien Isorce <julien.isorce@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
7 years agost/va: move variable declaration to where its used
Emil Velikov [Fri, 25 Nov 2016 17:52:28 +0000 (17:52 +0000)]
st/va: move variable declaration to where its used

... and make it const, since we shouldn't tinker with it.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
7 years agoauxiliary/vl: use vl_*_screen_create stubs when building w/o platform
Emil Velikov [Tue, 2 May 2017 16:53:17 +0000 (17:53 +0100)]
auxiliary/vl: use vl_*_screen_create stubs when building w/o platform

Provide a dummy stub when the user has opted w/o said platform, thus
we can build the binaries without unnecessarily requiring X11/other
headers.

In order to avoid build and link-time issues, we remove the HAVE_DRI3
guards in the VA and VDPAU state-trackers.

With this change st/va will return VA_STATUS_ERROR_ALLOCATION_FAILED
instead of VA_STATUS_ERROR_UNIMPLEMENTED. That is fine since upstream
users of libva such as vlc and mpv do little error checking, let
alone distinguish between the two.

Cc: Leo Liu <leo.liu@amd.com>
Cc: Guttula, Suresh <Suresh.Guttula@amd.com>
Cc: mesa-stable@lists.freedesktop.org
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure: error out when building X11 Vulkan without DRI3
Emil Velikov [Mon, 5 Dec 2016 20:14:24 +0000 (20:14 +0000)]
configure: error out when building X11 Vulkan without DRI3

Vulkan supports only DRI3 enabled X11 platforms. Make it obvious,
should one consider building without it.

Cc: Jason Ekstrand <jason@jlekstrand.net>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoloader: build libloader_dri3_helper.la only with HAVE_PLATFORM_X11
Emil Velikov [Wed, 3 May 2017 15:20:49 +0000 (16:20 +0100)]
loader: build libloader_dri3_helper.la only with HAVE_PLATFORM_X11

Pretty much every other place does the same.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agovulkan: automake: remove unused VULKAN_LIB_DEPS variable
Emil Velikov [Tue, 25 Apr 2017 15:20:24 +0000 (16:20 +0100)]
vulkan: automake: remove unused VULKAN_LIB_DEPS variable

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoconfigure: check once for DRI3 dependencies
Emil Velikov [Sun, 27 Nov 2016 00:25:28 +0000 (00:25 +0000)]
configure: check once for DRI3 dependencies

Currently we are having the XCB_DRI3 dependencies duplicated,
partially.

Just do a once-off check and add all of the respective CFLAGS/LIBS
where needed.

As a nice side effect this helps us solve a couple of FIXMEs.

DRI3 is not a thing w/o X11 so disable it in such cases.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoconfigure: error out when building GLX w/o the X11 platform
Emil Velikov [Wed, 3 May 2017 14:57:31 +0000 (15:57 +0100)]
configure: error out when building GLX w/o the X11 platform

Building EGL/Vulkan/other without X11, while GLX is enabled is confusing
and misleading. In practise anyone aiming at the former will also
disable GLX.

The inverse (some examples below) should still work:
 ./configure --disable-glx --with-platforms=x11 --with-vulkan-drivers=intel
 ./configure --disable-glx --with-platforms=x11 --enable-egl

Keep in mind that the X11 platform is enabled, by default.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoconfigure: set HAVE_foo_PLATFORM as applicable
Emil Velikov [Mon, 5 Dec 2016 21:32:30 +0000 (21:32 +0000)]
configure: set HAVE_foo_PLATFORM as applicable

Rather than having multiple places that define the macros, do it just
once in configure. Makes existing code a bit shorter and easier to
manage as we fix the VL targets with follow-up commits.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoconfigure: enable the surfaceless platform by default
Emil Velikov [Tue, 25 Apr 2017 15:39:52 +0000 (16:39 +0100)]
configure: enable the surfaceless platform by default

A simple platform that you want to use in a many usecases. See the
spec file details.

It has no special requirements plus it takes less than a second to
build.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Acked-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoconfigure: loosen --with-platforms heuristics
Emil Velikov [Wed, 3 May 2017 20:24:26 +0000 (21:24 +0100)]
configure: loosen --with-platforms heuristics

Remove the enable-egl pre-requirement. Platform selection does not
depend on EGL.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoconfigure: update remaining --with-egl-platforms references
Emil Velikov [Fri, 25 Nov 2016 18:34:03 +0000 (18:34 +0000)]
configure: update remaining --with-egl-platforms references

Rename the remaining references to omit the egl part.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoconfigure: rename remaining HAVE_EGL_PLATFORM_* guards
Emil Velikov [Fri, 25 Nov 2016 17:11:51 +0000 (17:11 +0000)]
configure: rename remaining HAVE_EGL_PLATFORM_* guards

Analogous to others earlier, these will be used to control the platform
for more than the EGL driver.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoconfigure: move platform handling further up
Emil Velikov [Wed, 3 May 2017 16:02:35 +0000 (17:02 +0100)]
configure: move platform handling further up

We'll need it for the Vulkan drivers and the VL targets.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
7 years agoAndroid: r600: fix build when LLVM is disabled
Rob Herring [Fri, 12 May 2017 16:55:16 +0000 (11:55 -0500)]
Android: r600: fix build when LLVM is disabled

There's still an error after my recent clean-up if LLVM is not patched to
enable AMDGPU target:

external/mesa3d/src/amd/common/ac_llvm_util.c:38:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetInfo' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUTargetInfo();
        ^
external/mesa3d/src/amd/common/ac_llvm_util.c:39:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTarget' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUTarget();
        ^
external/mesa3d/src/amd/common/ac_llvm_util.c:40:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetMC' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUTargetMC();
        ^
external/mesa3d/src/amd/common/ac_llvm_util.c:41:2: error: implicit declaration of function 'LLVMInitializeAMDGPUAsmPrinter' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUAsmPrinter();
        ^

We need to drop libmesa_amd_common when LLVM is disabled, however there's
still a dependency on include paths for ac_binary.h. So explicitly add the
include path when LLVM is disabled.

Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agovirgl: fix virgl_bo_transfer_{put, get} box struct copy
Rob Herring [Fri, 12 May 2017 22:05:53 +0000 (17:05 -0500)]
virgl: fix virgl_bo_transfer_{put, get} box struct copy

Commit 3dfe61ed6ec6 ("gallium: decrease the size of pipe_box - 24 -> 16
bytes") changed the size of pipe_box, but the virgl code was relying on
pipe_box and drm_virtgpu_3d_box structs having the same size/layout doing
a struct copy. Copy the fields one by one instead.

Cc: Marek Olšák <marek.olsak@amd.com>
Cc: Dave Airlie <airlied@redhat.com>
Fixes: 3dfe61ed6ec ("gallium: decrease the size of pipe_box - 24 -> 16 bytes")
Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoegl: add g_egldispatchstubs.h to the release tarball
Emil Velikov [Thu, 18 May 2017 18:07:08 +0000 (19:07 +0100)]
egl: add g_egldispatchstubs.h to the release tarball

Fixes: ce562f9e3fa ("EGL: Implement the libglvnd interface for EGL (v3)")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoegl/android: fix segfault within swap_buffers
Tapani Pälli [Thu, 18 May 2017 07:21:59 +0000 (10:21 +0300)]
egl/android: fix segfault within swap_buffers

Function droid_swap_buffers may get called without dri2_surf->buffer set,
in these cases we don't have a back buffer set either. Patch fixes segfault
seen with 3DMark that uses android.opengl.GLSurfaceView for rendering it's UI.

backtrace:
   #00 pc 00013f88  /system/lib/egl/libGLES_mesa.so (droid_swap_buffers+104)
   #01 pc 000117b2  /system/lib/egl/libGLES_mesa.so (dri2_swap_buffers+50)
   #02 pc 000058b2  /system/lib/egl/libGLES_mesa.so (eglSwapBuffers+386)
   #03 pc 00011329  /system/lib/libEGL.so (eglSwapBuffersWithDamageKHR+553)
   #04 pc 000118e7  /system/lib/libEGL.so (eglSwapBuffers+55)
   #05 pc 000754dc  /system/lib/libandroid_runtime.so

Note, this is v1 as v2 caused dEQP regressions.

Fixes: 2acc69d ("EGL/Android: Add EGL_EXT_buffer_age extension")
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
Cc: "17.1" <mesa-stable@lists.freedesktop.org>
7 years agoegl/wayland: Ensure we get a back buffer
Daniel Stone [Mon, 15 May 2017 21:22:32 +0000 (22:22 +0100)]
egl/wayland: Ensure we get a back buffer

Commit 9ca6711faa03 changed the Wayland winsys to only block for the
frame callback inside SwapBuffers, rather than get_back_bo. get_back_bo
would perform a single non-blocking Wayland event dispatch, to try to
find any release events which we had pulled off the wire but not
actually processed. The blocking dispatch was moved to SwapBuffers.

This removed a guarantee that we would've processed all events inside
get_back_bo(), and introduced a failure whereby the server could've sent
a buffer release event, but we wouldn't have read it. In clients
unconstrained by SwapInterval (rendering ~as fast as possible), which
were being displayed directly without composition (buffer release delayed),
this could lead to get_back_bo() failing because there were no free
buffers available to it.

The drawing rightly failed, but this was papered over because of the
path in eglSwapBuffers() which attempts to guarantee a BO, in order to
support calling SwapBuffers twice in a row with no rendering actually
having been performed.

Since eglSwapBuffers will perform a blocking dispatch of Wayland
events, a buffer release would have arrived by that point, and we
could then choose a buffer to post to the server. The effect was that
frames were displayed out-of-order, since we grabbed a frame with random
past content to display to the compositor.

Ideally get_back_bo() failing should store a failure flag inside the
surface and cause the next SwapBuffers to fail, but for the meantime,
restore the correct behaviour such that get_back_bo() no longer fails.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Eero Tamminen <eero.t.tamminen@intel.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98833
Fixes: 9ca6711faa03 ("Revert "wayland: Block for the frame callback in get_back_bo not dri2_swap_buffers"")
7 years agoegl/wayland: Use per-surface event queues
Daniel Stone [Fri, 5 May 2017 13:49:09 +0000 (14:49 +0100)]
egl/wayland: Use per-surface event queues

During display initialisation, we need a separate event queue to handle
the registry events, which is correctly handled. But we also need
separate per-surface event queues to handle swapchain-related events,
such as surface frame events and buffer release events. This avoids two
surfaces from the same EGLDisplay, both current on separate threads,
dispatching each other's events.

Create separate per-surface event queues, create wl_surface and wl_drm
proxy wrapper objects per surface, so we eliminate the race around
sending events to the wrong queue. swrast buffers do not need a
dedicated proxy wrapper, as the wl_shm_pool used to create the
wl_buffers, being transient, can itself be assigned to a queue.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 36b9976e1f99 ("egl/wayland: Avoid race conditions when on non-main thread")
Cc: mesa-stable@lists.freedesktop.org
7 years agoegl/wayland: Don't open-code roundtrip
Daniel Stone [Fri, 5 May 2017 13:44:20 +0000 (14:44 +0100)]
egl/wayland: Don't open-code roundtrip

wl_display_roundtrip_queue() exists and can replace roundtrip(). The
API was introduced with wayland 1.6, while we currently require 1.11.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agovulkan/wsi/wayland: Use proxy wrappers for swapchain
Daniel Stone [Tue, 2 May 2017 09:06:32 +0000 (10:06 +0100)]
vulkan/wsi/wayland: Use proxy wrappers for swapchain

Though most swapchain operations used a queue, they were racy in that
the object was created with the queue only set later, meaning that its
event could potentially be dispatched from the default queue in between
these two steps.

Use proxy wrappers to avoid this race, also assigning wl_buffers created
for the swapchain to the event queue.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agovulkan/wsi/wayland: Use per-display event queue
Daniel Stone [Tue, 2 May 2017 09:04:33 +0000 (10:04 +0100)]
vulkan/wsi/wayland: Use per-display event queue

Calling random callbacks on the display's event queue is hostile, as
we may call into client code when it least expects it. Create our own
event queue, one per wsi_wl_display, and use that for the registry.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agovulkan/wsi/wayland: Remove roundtrip when creating image
Daniel Stone [Tue, 2 May 2017 08:51:40 +0000 (09:51 +0100)]
vulkan/wsi/wayland: Remove roundtrip when creating image

There's no need to call wl_display_roundtrip() after trying to create a
buffer through wl_drm; if it succeeds then everything is fine, and if it
fails, then we get a fatal protocol error so can't recover anyway.

Additionally, doing a roundtrip on the default / main application queue,
is destructive anyway, so would need to be its own queue.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agovulkan: Fix Wayland uninitialised registry
Daniel Stone [Fri, 28 Apr 2017 14:49:47 +0000 (16:49 +0200)]
vulkan: Fix Wayland uninitialised registry

Untangle the exit cleanup paths so we don't try to use the registry
variable before it's been initialised.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agoi965/formats: Update the three-channel DXT1 mappings
Nanley Chery [Thu, 11 May 2017 22:57:59 +0000 (15:57 -0700)]
i965/formats: Update the three-channel DXT1 mappings

The procedure for decompressing an opaque DXT1 OpenGL format is
dependant on the comparison of two colors stored in the first 32 bits of
the compressed block. Here's the specified OpenGL behavior for
reference:

   The RGB color for a texel at location (x,y) in the block is given by:

      RGB0,              if color0 > color1 and code(x,y) == 0
      RGB1,              if color0 > color1 and code(x,y) == 1
      (2*RGB0+RGB1)/3,   if color0 > color1 and code(x,y) == 2
      (RGB0+2*RGB1)/3,   if color0 > color1 and code(x,y) == 3

      RGB0,              if color0 <= color1 and code(x,y) == 0
      RGB1,              if color0 <= color1 and code(x,y) == 1
      (RGB0+RGB1)/2,     if color0 <= color1 and code(x,y) == 2
      BLACK,             if color0 <= color1 and code(x,y) == 3

The sampling operation performed on an opaque DXT1 Intel format essentially
hard-codes the comparison result of the two colors as color0 > color1.
This means that the behavior is incompatible with OpenGL. This is stated
in the SKL PRM, Vol 5: Memory Views:

   Opaque Textures (DXT1_RGB)
      Texture format DXT1_RGB is identical to DXT1, with the exception that the
      One-bit Alpha encoding is removed. Color 0 and Color 1 are not compared, and
      the resulting texel color is derived strictly from the Opaque Color Encoding.
      The alpha channel defaults to 1.0.

      Programming Note
      Context: Opaque Textures (DXT1_RGB)
      The behavior of this format is not compliant with the OGL spec.

The opaque and non-opaque DXT1 OpenGL formats are specified to be
decoded in exactly the same way except the BLACK value must have a
transparent alpha channel in the latter. Use the four-channel BC1 Intel
formats with the alpha set to 1 to provide the behavior required by the
spec. Note that the alpha is already set to 1 for RGB formats in
brw_get_texture_swizzle().

v2: Provide a more detailed commit message (Kenneth Graunke).
v3: Ensure the alpha channel is set to 1 for DXT1 formats.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100925
Cc: <mesa-stable@lists.freedesktop.org>
Acked-by: Tapani Pälli <tapani.palli@intel.com> (v1)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
7 years agoanv/formats: Update the three-channel BC1 mappings
Nanley Chery [Thu, 11 May 2017 22:57:59 +0000 (15:57 -0700)]
anv/formats: Update the three-channel BC1 mappings

The procedure for decompressing an opaque BC1 Vulkan format is dependant on the
comparison of two colors stored in the first 32 bits of the compressed block.
Here's the specified OpenGL (and Vulkan) behavior for reference:

   The RGB color for a texel at location (x,y) in the block is given by:

      RGB0,              if color0 > color1 and code(x,y) == 0
      RGB1,              if color0 > color1 and code(x,y) == 1
      (2*RGB0+RGB1)/3,   if color0 > color1 and code(x,y) == 2
      (RGB0+2*RGB1)/3,   if color0 > color1 and code(x,y) == 3

      RGB0,              if color0 <= color1 and code(x,y) == 0
      RGB1,              if color0 <= color1 and code(x,y) == 1
      (RGB0+RGB1)/2,     if color0 <= color1 and code(x,y) == 2
      BLACK,             if color0 <= color1 and code(x,y) == 3

The sampling operation performed on an opaque DXT1 Intel format essentially
hard-codes the comparison result of the two colors as color0 > color1. This
means that the behavior is incompatible with OpenGL and Vulkan. This is stated
in the SKL PRM, Vol 5: Memory Views:

   Opaque Textures (DXT1_RGB)
      Texture format DXT1_RGB is identical to DXT1, with the exception that the
      One-bit Alpha encoding is removed. Color 0 and Color 1 are not compared, and
      the resulting texel color is derived strictly from the Opaque Color Encoding.
      The alpha channel defaults to 1.0.

      Programming Note
      Context: Opaque Textures (DXT1_RGB)
      The behavior of this format is not compliant with the OGL spec.

The opaque and non-opaque BC1 Vulkan formats are specified to be decoded in
exactly the same way except the BLACK value must have a transparent alpha
channel in the latter. Use the four-channel BC1 Intel formats with the alpha
set to 1 to provide the behavior required by the spec.

v2 (Kenneth Graunke):
- Provide a more detailed commit message.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100925
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
7 years agoanv: Add an option to abort on device loss
Jason Ekstrand [Thu, 18 May 2017 20:51:16 +0000 (13:51 -0700)]
anv: Add an option to abort on device loss

This is mostly for running in our CI system to prevent dEQP from
continuing on to the next test if we get a GPU hang.  As it currently
stands, dEQP uses the same VkDevice for almost all tests and if one of
the tests hangs, we set the anv_device::device_lost flag and report
VK_ERROR_DEVICE_LOST for all queue operations from that point forward
without sending anything to the GPU.  dEQP will happily continue trying
to run tests and reporting failures until it eventually gets crash that
forces the test runner to start over.  This circumvents the problem by
just aborting the process if we ever get a GPU hang.  Since this is not
the recommended behavior most of the time, we hide it behind an
environment variable.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoanv: Wrap the device lost error in vk_error in QueueSubmit
Jason Ekstrand [Thu, 18 May 2017 21:07:27 +0000 (14:07 -0700)]
anv: Wrap the device lost error in vk_error in QueueSubmit

We weren't wrapping this before because anv_cmd_buffer_execbuf may throw
a more meaningful error message.  However, we do change the error code
into VK_ERROR_DEVICE_LOST, so we should print a new message.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoradeonsi/gfx9: use CE RAM optimally
Marek Olšák [Wed, 17 May 2017 00:49:40 +0000 (02:49 +0200)]
radeonsi/gfx9: use CE RAM optimally

On GFX9 with only 4K CE RAM, define the range of slots that will be
allocated in CE RAM. All other slots will be uploaded directly. This will
switch dynamically according to which slots are used by current shaders.

GFX9 CE usage should now be similar to VI instead of being often disabled.

Tested on VI by taking the GFX9 CE allocation codepath and setting
num_ce_slots = 2 everywhere to get frequent switches between both modes.
CE is still disabled on GFX9.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: remove CE offset alignment restriction
Marek Olšák [Wed, 17 May 2017 00:45:25 +0000 (02:45 +0200)]
radeonsi: remove CE offset alignment restriction

This was only needed by LOAD_CONST_RAM, which is now only used to load
whole CE.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: only upload (dump to L2) those descriptors that are used by shaders
Marek Olšák [Mon, 15 May 2017 21:03:01 +0000 (23:03 +0200)]
radeonsi: only upload (dump to L2) those descriptors that are used by shaders

This decreases the size of CE RAM dumps to L2, or the size of descriptor
uploads without CE.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: record which descriptor slots are used by shaders
Marek Olšák [Mon, 15 May 2017 22:03:52 +0000 (00:03 +0200)]
radeonsi: record which descriptor slots are used by shaders

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: update si_ce_needed_cs_space
Marek Olšák [Mon, 15 May 2017 21:57:37 +0000 (23:57 +0200)]
radeonsi: update si_ce_needed_cs_space

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: do only 1 big CE dump at end of IBs and one reload in the preamble
Marek Olšák [Mon, 15 May 2017 21:45:57 +0000 (23:45 +0200)]
radeonsi: do only 1 big CE dump at end of IBs and one reload in the preamble

A later commit will only upload descriptors used by shaders, so we won't do
full dumps anymore, so the only way to have a complete mirror of CE RAM
in memory is to do a separate dump after the last draw call.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: remove early return in si_upload_descriptors
Marek Olšák [Mon, 15 May 2017 17:59:41 +0000 (19:59 +0200)]
radeonsi: remove early return in si_upload_descriptors

All updates of descriptors_dirty also set dirty_mask, so the return is
unnecessary. The next commit will want this function to be executed
even if dirty_mask == 0.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: clamp indirect index to the number of declared shader resources
Marek Olšák [Wed, 17 May 2017 19:11:13 +0000 (21:11 +0200)]
radeonsi: clamp indirect index to the number of declared shader resources

We'll do partial uploads of descriptor arrays, so we need to clamp
against what shaders declare.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: merge sampler and image descriptor lists into one
Marek Olšák [Sat, 13 May 2017 15:16:27 +0000 (17:16 +0200)]
radeonsi: merge sampler and image descriptor lists into one

Sampler slots: slot[8], .. slot[39] (ascending)
Image slots: slot[7], .. slot[0] (descending)

Each image occupies 1/2 of each slot, so there are 16 images in total,
therefore the layout is: slot[15], .. slot[0]. (in 1/2 slot increments)

Updating image slot 2n+i (i <= 1) also dirties and re-uploads slot 2n+!i.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: merge constant and shader buffers descriptor lists into one
Marek Olšák [Sat, 13 May 2017 12:01:27 +0000 (14:01 +0200)]
radeonsi: merge constant and shader buffers descriptor lists into one

Constant buffers: slot[16], .. slot[31] (ascending)
Shader buffers: slot[15], .. slot[0] (descending)

The idea is that if we have 4 constant buffers and 2 shader buffers, we only
have to upload 6 slots. That optimization is left for a later commit.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agogallium/u_threaded: add a fast path for unbinding shader buffers
Marek Olšák [Fri, 12 May 2017 19:38:12 +0000 (21:38 +0200)]
gallium/u_threaded: add a fast path for unbinding shader buffers

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agogallium/u_threaded: add a fast path for unbinding shader images
Marek Olšák [Fri, 12 May 2017 19:38:12 +0000 (21:38 +0200)]
gallium/u_threaded: add a fast path for unbinding shader images

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agost/mesa: silence a valgrind warning in u_threaded_context due to st_draw_vbo
Marek Olšák [Tue, 16 May 2017 08:56:08 +0000 (10:56 +0200)]
st/mesa: silence a valgrind warning in u_threaded_context due to st_draw_vbo

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoglsl_to_tgsi: declare all SSBOs and atomics when indirect indexing is used
Marek Olšák [Tue, 16 May 2017 22:26:06 +0000 (00:26 +0200)]
glsl_to_tgsi: declare all SSBOs and atomics when indirect indexing is used

Only the first array element was declared, so tgsi_shader_info::
shader_buffers_declared didn't match what the shader was using.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: get the sampler view type from inst->Texture for TG4
Samuel Pitoiset [Wed, 17 May 2017 08:55:51 +0000 (10:55 +0200)]
radeonsi: get the sampler view type from inst->Texture for TG4

This will also magically fix this special lowering for
bindless samplers.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agotgsi: store the sampler view type directly in the instruction
Samuel Pitoiset [Wed, 17 May 2017 08:51:59 +0000 (10:51 +0200)]
tgsi: store the sampler view type directly in the instruction

RadeonSI needs to do a special lowering for Gather4 with integer
formats, but with bindless samplers we just can't access the index.

Instead, store the return type in the instruction like the target.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agotgsi: remove some unused OPCODE macros
Samuel Pitoiset [Wed, 17 May 2017 08:27:33 +0000 (10:27 +0200)]
tgsi: remove some unused OPCODE macros

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agogallivm: Make sure module has the correct data layout when pass manager runs
Tom Stellard [Fri, 5 May 2017 01:07:00 +0000 (01:07 +0000)]
gallivm: Make sure module has the correct data layout when pass manager runs

The datalayout for modules was purposely not being set in order to work around
the fact that the ExecutionEngine requires that the module's datalayout
matches the datalayout of the TargetMachine that the ExecutionEngine is
using.

When the pass manager runs on a module with no datalayout, it uses
the default datalayout which is little-endian.  This causes problems
on big-endian targets, because some optimizations that are legal on
little-endian or illegal on big-endian.

To resolve this, we set the datalayout prior to running the pass
manager, and then clear it before creating the ExectionEngine.

This patch fixes a lot of piglit tests on big-endian ppc64.

Cc: mesa-stable@lists.freedesktop.org
7 years agoegl: Partially revert 23c86c74, fix eglMakeCurrent
Chad Versace [Fri, 12 May 2017 04:49:14 +0000 (21:49 -0700)]
egl: Partially revert 23c86c74, fix eglMakeCurrent

Fixes regressions in Android CtsVerifier.apk on Intel Chrome OS devices
due to incorrect error handling in eglMakeCurrent. See below on how to
confirm the regression is fixed.

This partially reverts

    commit 23c86c74cc450a23848b85cfe914376caede1cdf
    Author:  Chad Versace <chadversary@chromium.org>
    Subject: egl: Emit error when EGLSurface is lost

The problem with commit 23c86c74 is that, once an EGLSurface became
lost, the app could never unbind the bad surface. Each attempt to unbind
the bad surface with eglMakeCurrent failed with EGL_BAD_CURRENT_SURFACE.

Specificaly, the bad commit added the error handling below. #2 and #3
were right, but #1 was wrong.

    1. eglMakeCurrent emits EGL_BAD_CURRENT_SURFACE if the calling
       thread has unflushed commands and either previous surface is no
       longer valid.

    2. eglMakeCurrent emits EGL_BAD_NATIVE_WINDOW if either new surface
       is no longer valid.

    3. eglSwapBuffers emits EGL_BAD_NATIVE_WINDOW if the swapped surface
       is no longer valid.

Whe I wrote the bad commit, I misunderstood the EGL spec language
for #1. The correct behavior is, if I understand correctly now, is
below. This patch doesn't implement the correct behavior, though, it
just reverts the broken behavior.

    - Assume a bound EGLSurface is no longer valid.
    - Assume the bound EGLContext has unflushed commands.
    - The app calls eglMakeCurrent. The spec requires eglMakeCurrent to
      implicitly flush. After flushing, eglMakeCurrent emits
      EGL_BAD_CURRENT_SURFACE and does *not* alter the thread's
      current bindings.
    - If the app calls eglMakeCurrent again, and the app inserts no
      commands into the GL command stream between the two eglMakeCurrent
      calls, then this second eglMakeCurrent succeeds without emitting an
      error.

How to confirm this fixes the regression:

    Download android-cts-verifier-7.1_r5-linux_x86-x86.zip from
    source.android.com, unpack, and `adb install CtsVerifier.apk`.
    Run test "Projection Cube". Click the Pass button (a
    green checkmark). Then run test "Projection Widget". Confirm that
    widgets are visible and that logcat does not complain about
    eglMakeCurrent failure.

    Then confirm there are no regressions in the cts-traded module that
    commit 263243b1 fixed:

        cts-tf > run cts --skip-preconditions --skip-device-info \
                 -m CtsCameraTestCases \
                 -t android.hardware.camera2.cts.RobustnessTest

    Tested with Chrome OS board "reef".

Fixes: 23c86c74 (egl: Emit error when EGLSurface is lost)
Acked-by: Tapani Pälli <tapani.palli@intel.com>
Cc: "17.1" <mesa-stable@lists.freedesktop.org>
Cc: Tomasz Figa <tfiga@chromium.org>
Cc: Nicolas Boichat <drinkcat@chromium.org>
Cc: Emil Velikov <emil.velikov@collabora.com>
7 years agoanv: fix multiview for clear commands
Iago Toral Quiroga [Thu, 18 May 2017 06:23:38 +0000 (08:23 +0200)]
anv: fix multiview for clear commands

According to the VK_KHX_multiview spec:

"Multiview causes all drawing and clear commands in the subpass to
behave as if they were broadcast to each view, where each view is
represented by one layer of the framebuffer attachments."

This adds support for multiview clears, which were missing in the
initial implementation.

v2 (Jason):
  - split multiview from regular case
  - Use for_each_bit() macro

Fixes new CTS multiview tests:
dEQP-VK.multiview.clear_attachments.*

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoac: add missing extern "C" guards
Nicolai Hähnle [Sat, 13 May 2017 20:59:19 +0000 (22:59 +0200)]
ac: add missing extern "C" guards

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoac: add radeon_info::num_{sdma,compute}_rings
Nicolai Hähnle [Thu, 11 May 2017 23:04:56 +0000 (01:04 +0200)]
ac: add radeon_info::num_{sdma,compute}_rings

Vulkan needs them.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoac: add radeon_surf::htile_slice_size
Nicolai Hähnle [Wed, 10 May 2017 20:52:27 +0000 (22:52 +0200)]
ac: add radeon_surf::htile_slice_size

Vulkan needs it.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoac_surface: use radeon_info from ac_gpu_info
Nicolai Hähnle [Thu, 11 May 2017 23:24:48 +0000 (01:24 +0200)]
ac_surface: use radeon_info from ac_gpu_info

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoac/radeonsi: move radeon_info initialization to amd/common
Nicolai Hähnle [Thu, 11 May 2017 12:14:06 +0000 (14:14 +0200)]
ac/radeonsi: move radeon_info initialization to amd/common

v2: update Android.common.mk (Emil)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoac/radeonsi: move struct radeon_info to ac_gpu_info.h
Nicolai Hähnle [Thu, 11 May 2017 08:19:26 +0000 (10:19 +0200)]
ac/radeonsi: move struct radeon_info to ac_gpu_info.h

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoac/radeonsi: move some aspects of sanity checking to ac_surface
Nicolai Hähnle [Wed, 10 May 2017 18:44:51 +0000 (20:44 +0200)]
ac/radeonsi: move some aspects of sanity checking to ac_surface

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoac/radeonsi: add ac_compute_surface to automatically switch gfx6 vs. gfx9
Nicolai Hähnle [Wed, 10 May 2017 18:40:14 +0000 (20:40 +0200)]
ac/radeonsi: add ac_compute_surface to automatically switch gfx6 vs. gfx9

Reviewed-by: Marek Olšák <marek.olsak@amd.com>