mesa.git
4 years agoglx: Relax validate_renderType_against_config for EXT_no_config_context
Adam Jackson [Tue, 7 Nov 2017 16:36:51 +0000 (11:36 -0500)]
glx: Relax validate_renderType_against_config for EXT_no_config_context

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
4 years agoanv: fix build failure
Nicolai Hähnle [Thu, 9 Nov 2017 13:49:19 +0000 (14:49 +0100)]
anv: fix build failure

Fixes: e3a8013de8ca ("util/u_queue: add util_queue_fence_wait_timeout")
4 years agomesa: flush and wait after creating a fallback texture
Nicolai Hähnle [Sun, 22 Oct 2017 15:39:04 +0000 (17:39 +0200)]
mesa: flush and wait after creating a fallback texture

Fixes non-deterministic failures in
dEQP-EGL.functional.sharing.gles2.multithread.simple_egl_sync.images.texture_source.teximage2d_render
and others in dEQP-EGL.functional.sharing.gles2.multithread.*

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agomesa: increase MaxServerWaitTimeout
Nicolai Hähnle [Sun, 22 Oct 2017 15:39:03 +0000 (17:39 +0200)]
mesa: increase MaxServerWaitTimeout

The current value was introduced in commit a27180d0d8666, which claims
that it represents ~1.11 years. However, it is interpreted in nanoseconds,
so it actually only represents ~9.8 hours. That seems a bit short.

Use the largest value consistent with both int32 and int64. It
corresponds to ~292 years in nanoseconds.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agost/mesa: remove redundant flushes from st_flush
Nicolai Hähnle [Sun, 22 Oct 2017 15:39:02 +0000 (17:39 +0200)]
st/mesa: remove redundant flushes from st_flush

st_flush should flush state tracker-internal state and the pipe, but
not mesa/main state. Of the four callers:

- glFlush/glFinish already call FLUSH_{VERTICES,STATE}.
- st_vdpau doesn't need to call them.
- st_manager will now call them explicitly.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agost/dri: use stapi flush instead of pipe flush when creating fences
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:37 +0000 (17:38 +0200)]
st/dri: use stapi flush instead of pipe flush when creating fences

There may be pending operations (e.g. vertices) that need to be flushed
by the state tracker.

Found by inspection.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: use a threaded context even for debug contexts
Nicolai Hähnle [Sun, 22 Oct 2017 15:39:05 +0000 (17:39 +0200)]
radeonsi: use a threaded context even for debug contexts

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: record and dump time of flush
Nicolai Hähnle [Sun, 22 Oct 2017 15:39:05 +0000 (17:39 +0200)]
radeonsi: record and dump time of flush

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoddebug: optionally handle transfer commands like draws
Nicolai Hähnle [Sun, 22 Oct 2017 15:39:01 +0000 (17:39 +0200)]
ddebug: optionally handle transfer commands like draws

Transfer commands can have associated GPU operations.

Enabled by passing GALLIUM_DDEBUG=transfers.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoddebug: dump context and before/after times of draws
Nicolai Hähnle [Sun, 22 Oct 2017 15:39:01 +0000 (17:39 +0200)]
ddebug: dump context and before/after times of draws

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoddebug: generalize print_named_xxx via a PRINT_NAMED macro
Nicolai Hähnle [Sun, 22 Oct 2017 15:39:00 +0000 (17:39 +0200)]
ddebug: generalize print_named_xxx via a PRINT_NAMED macro

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoddebug: rewrite to always use a threaded approach
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:59 +0000 (17:38 +0200)]
ddebug: rewrite to always use a threaded approach

This patch has multiple goals:

1. Off-load the writing of records in 'always' mode to another thread
   for performance.

2. Allow using ddebug with threaded contexts. This really forces us to
   move some of the "after_draw" handling into another thread.

3. Simplify the different modes of ddebug, both in the code and in
   the user interface, i.e. GALLIUM_DDEBUG. In particular, there's
   no 'pipelined' anymore, since we're always pipelined; and 'noflush'
   is replaced by 'flush', since we no longer flush by default.

4. Fix the fences in pipelining mode. They previously relied on writes
   via pipe_context::clear_buffer. However, on radeonsi, those could
   (quite reasonably) end up in the SDMA buffer. So we use the newly
   added PIPE_FLUSH_{TOP,BOTTOM}_OF_PIPE fences instead.

5. Improve pipelined mode overall, using the finer grained information
   provided by the new fences.

Overall, the result is that pipelined mode should be more useful, and
using ddebug in default mode is much less invasive, in the sense that
it changes the overall driver behavior less (which is kind of crucial
for a driver debugging tool).

An example of the new hang debug output:

  Gallium debugger active.
  Hang detection timeout is 1000ms.
  GPU hang detected, collecting information...

  Draw #   driver  prev BOP  TOP  BOP  dump file
  -------------------------------------------------------------
  2          YES      YES    YES  NO   /home/nha/ddebug_dumps/shader_runner_19919_00000000
  3          YES      NO     YES  NO   /home/nha/ddebug_dumps/shader_runner_19919_00000001
  4          YES      NO     YES  NO   /home/nha/ddebug_dumps/shader_runner_19919_00000002
  5          YES      NO     YES  NO   /home/nha/ddebug_dumps/shader_runner_19919_00000003

  Done.

We can see that there were almost certainly 4 draws in flight when
the hang happened: the top-of-pipe fence was signaled for all 4 draws,
the bottom-of-pipe fence for none of them. In virtually all cases,
we'd expect the first draw in the list to be at fault, but due to the
GPU parallelism, it's possible (though highly unlikely) that one of
the later draws causes a component to get stuck in a way that prevents
the earlier draws from making progress as well.

(In the above example, there were actually only 3 draws truly in flight:
the last draw is a blit that waits for the earlier draws; however, its
top-of-pipe fence is emitted before the cache flush and wait, and so
the fact that the draw hasn't truly started yet can only be seen from a
closer inspection of GPU state.)

Acked-by: Marek Olšák <marek.olsak@amd.com>
4 years agoddebug: use an atomic increment when numbering files
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:58 +0000 (17:38 +0200)]
ddebug: use an atomic increment when numbering files

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agodd/util: extract dd_get_debug_filename_and_mkdir
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:58 +0000 (17:38 +0200)]
dd/util: extract dd_get_debug_filename_and_mkdir

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium/u_dump: add and use util_dump_transfer_usage
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:57 +0000 (17:38 +0200)]
gallium/u_dump: add and use util_dump_transfer_usage

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium/u_dump: add util_dump_ns
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:56 +0000 (17:38 +0200)]
gallium/u_dump: add util_dump_ns

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium/u_dump: export util_dump_ptr
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:55 +0000 (17:38 +0200)]
gallium/u_dump: export util_dump_ptr

Change format to %p while we're at it.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: implement PIPE_FLUSH_{TOP,BOTTOM}_OF_PIPE
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:54 +0000 (17:38 +0200)]
radeonsi: implement PIPE_FLUSH_{TOP,BOTTOM}_OF_PIPE

v2: use uncached system memory for the fence, and use the CPU to
    clear it so we never read garbage when checking the fence

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: document some subtle details of fence_finish & fence_server_sync
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:53 +0000 (17:38 +0200)]
radeonsi: document some subtle details of fence_finish & fence_server_sync

v2: remove the change to si_fence_server_sync, we'll handle that more
    robustly

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium: add pipe_context::callback
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:53 +0000 (17:38 +0200)]
gallium: add pipe_context::callback

For running post-draw operations inside the driver thread. ddebug will
use it.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium/u_threaded: implement pipe_context::set_log_context
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:52 +0000 (17:38 +0200)]
gallium/u_threaded: implement pipe_context::set_log_context

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium/u_threaded: avoid syncs for get_query_result
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:51 +0000 (17:38 +0200)]
gallium/u_threaded: avoid syncs for get_query_result

Queries should still get marked as flushed when flushes are executed
asynchronously in the driver thread.

To this end, the management of the unflushed_queries list is moved into
the driver thread.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium/u_threaded: implement asynchronous flushes
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:50 +0000 (17:38 +0200)]
gallium/u_threaded: implement asynchronous flushes

This requires out-of-band creation of fences, and will be signaled to
the pipe_context::flush implementation by a special TC_FLUSH_ASYNC flag.

v2:
- remove an incorrect assertion
- handle fence_server_sync for unsubmitted fences by
  relying on the improved cs_add_fence_dependency
- only implement asynchronous flushes on amdgpu

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium/u_threaded: mark queries flushed only for non-deferred flushes
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:50 +0000 (17:38 +0200)]
gallium/u_threaded: mark queries flushed only for non-deferred flushes

The driver uses (and must use) the flushed flag of queries as a hint that
it does not have to check for synchronization with currently queued up
commands. Deferred flushes do not actually flush queued up commands, so
we must not set the flushed flag for them.

Found by inspection.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: move fence functions to si_fence.c
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:49 +0000 (17:38 +0200)]
radeonsi: move fence functions to si_fence.c

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agowinsys/amdgpu: handle cs_add_fence_dependency for deferred/unsubmitted fences
Nicolai Hähnle [Thu, 9 Nov 2017 13:00:22 +0000 (14:00 +0100)]
winsys/amdgpu: handle cs_add_fence_dependency for deferred/unsubmitted fences

The idea is to fix the following interleaving of operations
that can arise from deferred fences:

 Thread 1 / Context 1          Thread 2 / Context 2
 --------------------          --------------------
 f = deferred flush
 <------- application-side synchronization ------->
                               fence_server_sync(f)
                               ...
                               flush()
 flush()

We will now stall in fence_server_sync until the flush of context 1
has completed.

This scenario was unlikely to occur previously, because applications
seem to be doing

 Thread 1 / Context 1          Thread 2 / Context 2
 --------------------          --------------------
 f = glFenceSync()
 glFlush()
 <------- application-side synchronization ------->
                               glWaitSync(f)

... and indeed they probably *have* to use this ordering to avoid
deadlocks in the GLX model, where all GL operations conceptually
go through a single connection to the X server. However, it's less
clear whether applications have to do this with other WSI (i.e. EGL).
Besides, even this sequence of GL commands can be translated into
the Gallium-level sequence outlined above when Gallium threading
and asynchronous flushes are used. So it makes sense to be more
robust.

As a side effect, we no longer busy-wait on submission_in_progress.

We won't enable asynchronous flushes on radeon, but add a
cs_add_fence_dependency stub anyway to document the potential
issue.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium: add PIPE_FLUSH_{TOP,BOTTOM}_OF_PIPE bits
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:48 +0000 (17:38 +0200)]
gallium: add PIPE_FLUSH_{TOP,BOTTOM}_OF_PIPE bits

These bits are intended to be used by the ddebug hang detection and are
named in analogy to the Vulkan stage bits (and the corresponding Radeon
pipeline event).

Hang detection needs fences on the granularity of individual commands,
which nothing else really covers. The closest alternative would have
been PIPE_QUERY_GPU_FINISHED, but (a) queries are a per-context object
and we really want a per-screen object, (b) queries don't offer a
wait with timeout, and (c) in any case, PIPE_QUERY_GPU_FINISHED is
meant to imply that GPU caches are flushed, which the new bits
explicitly aren't.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium: add PIPE_FLUSH_ASYNC and PIPE_FLUSH_HINT_FINISH
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:47 +0000 (17:38 +0200)]
gallium: add PIPE_FLUSH_ASYNC and PIPE_FLUSH_HINT_FINISH

Also document some subtleties of pipe_context::flush.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoutil/u_queue: add util_queue_fence_wait_timeout
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:46 +0000 (17:38 +0200)]
util/u_queue: add util_queue_fence_wait_timeout

v2:
- style fixes
- fix missing timeout handling in futex path

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agothreads: update for late C11 changes
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:45 +0000 (17:38 +0200)]
threads: update for late C11 changes

C11 threads were changed to use struct timespec instead of xtime, and
thrd_sleep got a second argument.

See http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1554.htm and
http://en.cppreference.com/w/c/thread/{thrd_sleep,cnd_timedwait,mtx_timedlock}

Note that cnd_timedwait is spec'd to be relative to TIME_UTC / CLOCK_REALTIME.

v2: Fix Windows build errors. Tested with a default Appveyor config
    that uses Visual Studio 2013. Judging from Brian's email and
    random internet sources, Visual Studio 2015 does have timespec
    and timespec_get, hence the _MSC_VER-based guard which I have
    not tested.

Cc: Jose Fonseca <jfonseca@vmware.com>
Cc: Brian Paul <brianp@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
4 years agogallium: remove unused and deprecated u_time.h
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:44 +0000 (17:38 +0200)]
gallium: remove unused and deprecated u_time.h

Cc: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoutil: move os_time.[ch] to src/util
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:44 +0000 (17:38 +0200)]
util: move os_time.[ch] to src/util

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: always use async compiles when creating shader/compute states
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:43 +0000 (17:38 +0200)]
radeonsi: always use async compiles when creating shader/compute states

With Gallium threaded contexts, creating shader/compute states is
effectively a screen operation, so we should not use context state.

In particular, this allows us to avoid using the context's LLVM
TargetMachine.

This isn't an issue yet because u_threaded_context filters out non-async
debug callbacks, and we disable threaded contexts for debug contexts.
However, we may want to change that in the future.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: fix potential use-after-free of debug callbacks
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:42 +0000 (17:38 +0200)]
radeonsi: fix potential use-after-free of debug callbacks

Found by inspection.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: move pipe debug callback to si_context
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:39 +0000 (17:38 +0200)]
radeonsi: move pipe debug callback to si_context

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agou_queue: add util_queue_finish for waiting for previously added jobs
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:41 +0000 (17:38 +0200)]
u_queue: add util_queue_finish for waiting for previously added jobs

Schedule one job for every thread, and wait on a barrier inside the job
execution function.

v2: avoid alloca (fixes Windows build error)

Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
4 years agoutil: move pipe_barrier into src/util and rename to util_barrier
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:40 +0000 (17:38 +0200)]
util: move pipe_barrier into src/util and rename to util_barrier

The #if guard is probably not 100% equivalent to the previous PIPE_OS
check, but if anything it should be an over-approximation (are there
pthread implementations without barriers?), so people will get either
a good implementation or compile errors that are easy to fix.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium: add async debug message forwarding helper
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:38 +0000 (17:38 +0200)]
gallium: add async debug message forwarding helper

v2: use util_vasprintf for Windows portability

Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
4 years agost/mesa: guard sampler views changes with a mutex
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:36 +0000 (17:38 +0200)]
st/mesa: guard sampler views changes with a mutex

Some locking is unfortunately required, because well-formed GL programs
can have multiple threads racing to access the same texture, e.g.: two
threads/contexts rendering from the same texture, or one thread destroying
a context while the other is rendering from or modifying a texture.

Since even the simple mutex caused noticable slowdowns in the piglit
drawoverhead micro-benchmark, this patch uses a slightly more involved
approach to keep locks out of the fast path:

- the initial lookup of sampler views happens without taking a lock
- a per-texture lock is only taken when we have to modify the sampler
  view(s)
- since each thread mostly operates only on the entry corresponding to
  its context, the main issue is re-allocation of the sampler view array
  when it needs to be grown, but the old copy is not freed

Old copies of the sampler views array are kept around in a linked list
until the entire texture object is deleted. The total memory wasted
in this way is roughly equal to the size of the current sampler views
array.

Fixes non-deterministic memory corruption in some
dEQP-EGL.functional.sharing.gles2.multithread.* tests, e.g.
dEQP-EGL.functional.sharing.gles2.multithread.simple.images.texture_source.create_texture_render

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agost/mesa: re-arrange st_finalize_texture
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:34 +0000 (17:38 +0200)]
st/mesa: re-arrange st_finalize_texture

Move the early-out for surface-based textures earlier. This narrows the
scope of the locking added in a follow-up commit.

Fix one remaining case of initializing a surface-based texture
without properly finalizing it.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agogallium: clarify the constraints on sampler_view_destroy
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:33 +0000 (17:38 +0200)]
gallium: clarify the constraints on sampler_view_destroy

r600 expects the context that created the sampler view to still be alive
(there is a per-context list of sampler views).

svga currently bails when the context of destruction is not the same as
creation.

The GL state tracker, which is the only one that runs into the
multi-context subtleties (due to share groups), already guarantees that
sampler views are destroyed before their context of creation is destroyed.

Most drivers are context-agnostic, so the warning message in
pipe_sampler_view_release doesn't really make sense.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: reduce the scope of sel->mutex in si_shader_select_with_key
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:32 +0000 (17:38 +0200)]
radeonsi: reduce the scope of sel->mutex in si_shader_select_with_key

We only need the lock to guard changes in the variant linked list. The
actual compilation can happen outside the lock, since we use the ready
fence as a guard.

v2: fix double-unlock

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoradeonsi: use ready fences on all shaders, not just optimized ones
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:32 +0000 (17:38 +0200)]
radeonsi: use ready fences on all shaders, not just optimized ones

There's a race condition between si_shader_select_with_key and
si_bind_XX_shader:

  Thread 1                         Thread 2
  --------                         --------
  si_shader_select_with_key
    begin compiling the first
    variant
    (guarded by sel->mutex)
                                   si_bind_XX_shader
                                     select first_variant by default
                                     as state->current
                                   si_shader_select_with_key
                                     match state->current and early-out

Since thread 2 never takes sel->mutex, it may go on rendering without a
PM4 for that shader, for example.

The solution taken by this patch is to broaden the scope of
shader->optimized_ready to a fence shader->ready that applies to
all shaders. This does not hurt the fast path (if anything it makes
it faster, because we don't explicitly check is_optimized).

It will also allow reducing the scope of sel->mutex locks, but this is
deferred to a later commit for better bisectability.

Fixes dEQP-EGL.functional.sharing.gles2.multithread.simple.buffers.bufferdata_render

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agou_queue: add a futex-based implementation of fences
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:31 +0000 (17:38 +0200)]
u_queue: add a futex-based implementation of fences

Fences are now 4 bytes instead of 96 bytes (on my 64-bit system).

Signaling a fence is a single atomic operation in the fast case plus a
syscall in the slow case.

Testing if a fence is signaled is the same as before (a simple comparison),
but waiting on a fence is now no more expensive than just testing it in
the fast (already signaled) case.

v2:
- style fixes
- use p_atomic_xxx macros with the right barriers

Acked-by: Marek Olšák <marek.olsak@amd.com>
4 years agou_queue: add util_queue_fence_reset
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:30 +0000 (17:38 +0200)]
u_queue: add util_queue_fence_reset

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agou_queue: export util_queue_fence_signal
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:29 +0000 (17:38 +0200)]
u_queue: export util_queue_fence_signal

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agou_queue: group fence functions together
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:29 +0000 (17:38 +0200)]
u_queue: group fence functions together

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoutil/u_atomic: add p_atomic_xchg
Nicolai Hähnle [Fri, 3 Nov 2017 14:19:57 +0000 (15:19 +0100)]
util/u_atomic: add p_atomic_xchg

The closest to it in the old-style gcc builtins is __sync_lock_test_and_set,
however, that is only guaranteed to work with values 0 and 1 and only
provides an acquire barrier. I also don't know about other OSes, so we
provide a simple & stupid emulation via p_atomic_cmpxchg.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
4 years agoutil: move futex helpers into futex.h
Nicolai Hähnle [Sun, 22 Oct 2017 15:38:26 +0000 (17:38 +0200)]
util: move futex helpers into futex.h

v2: style fixes

Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
4 years agoglsl: Make #pragma STDGL invariant(all) only modify outputs.
Kenneth Graunke [Tue, 7 Nov 2017 08:57:52 +0000 (00:57 -0800)]
glsl: Make #pragma STDGL invariant(all) only modify outputs.

According to the GLSL ES 3.20, GLSL 4.50, and GLSL 1.20 specs:

   "To force all output variables to be invariant, use the pragma

       #pragma STDGL invariant(all)

    before all declarations in a shader."

Notably, this is only supposed to affect output variables.  Furthermore,

   "Only variables output from a shader can be candidates for invariance."

It looks like this has been wrong since we first supported the pragma in
2011 (commit 86b4398cd158024f6be9fa830554a11c2a7ebe0c).

Fixes dEQP-GLES2.functional.shaders.preprocessor.pragmas.pragma_fragment.

v2: Now that all cases are identical (other than compute shaders, which
    have no output variables anyway), we can drop the switch statement
    entirely.  We also don't need the current_function == NULL check;
    this was a hold over from when we had a single var_mode_out for both
    function parameters and shader varyings, in the bad old days.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
4 years agoi965: expose SRGB visuals and turn on EGL_KHR_gl_colorspace
Tapani Pälli [Tue, 31 Oct 2017 08:56:28 +0000 (10:56 +0200)]
i965: expose SRGB visuals and turn on EGL_KHR_gl_colorspace

Patch exposes sRGB visuals and adds DRI integer query support for
__DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB. Further changes make sure that
we mark if the app explicitly wanted sRGB and for these framebuffers
we don't turn sRGB off in intel_gles3_srgb_workaround. This way we
keep compatibility for existing applications relying on default sRGB
and ony add more visual support.

With this change, following dEQP tests start to pass:

   dEQP-EGL.functional.wide_color.window_8888_colorspace_srgb
   dEQP-EGL.functional.wide_color.pbuffer_8888_colorspace_srgb

v2: some code cleanup (Emil Velikov)
    update num_formats correctly (reported by deveee@gmail.com)

v3: cleanup, remove redundant is_srgb
    rename explicit_srgb as 'need_srgb' to follow style better

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com> (v2)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102264
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102354
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102503

4 years agoglsl: Transform fb buffers are only active if a variable uses them
Neil Roberts [Mon, 30 Oct 2017 12:22:49 +0000 (13:22 +0100)]
glsl: Transform fb buffers are only active if a variable uses them

The GL spec will soon be revised to clarify that a buffer binding for
a transform feedback buffer is only required if a variable is actually
defined to use the buffer binding point. Previously a declaration for
the default transform buffer would make it require a binding even if
nothing was declared to use the default buffer.

Affects:
KHR-GL44/45.enhanced_layouts.xfb_stride_of_empty_list
KHR-GL44/45.enhanced_layouts.xfb_stride_of_empty_list_and_api

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Cc: mesa-stable@lists.freedesktop.org
4 years agointel/nir: Use the correct indirect lowering masks in link_shaders
Jason Ekstrand [Sat, 28 Oct 2017 16:02:14 +0000 (09:02 -0700)]
intel/nir: Use the correct indirect lowering masks in link_shaders

Previously, if we were linking a vec4 VS with a SIMD8/16 FS, we wouldn't
lower indirects on the fragment shader which is wrong.  Instead of using
a single indirect mask, take advantage of our new little helper.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Cc: mesa-stable@lists.freedesktop.org
4 years agor600g: use SIMPLE_FLOAT for blending to enable some optimizations
Ilia Mirkin [Sat, 4 Nov 2017 17:49:45 +0000 (13:49 -0400)]
r600g: use SIMPLE_FLOAT for blending to enable some optimizations

Radeonsi also sets this flag. Seems to avoid pulling up the desintation
RT value when the dst blend factor is zero if it's not otherwise being
loaded. Among other things, it allows blending to overwrite infinity/NaN
values in the destination RT.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
4 years agonv50: make blending work so that zero wins in a multiplication
Ilia Mirkin [Sat, 4 Nov 2017 17:49:04 +0000 (13:49 -0400)]
nv50: make blending work so that zero wins in a multiplication

This matches nvc0 behavior, tested with the fbo-float-nan piglit.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tobias Klausmann<tobias.johannes.klausmann@mni.thm.de>
4 years agoglsl: Minor cleanups after previous commit
Ian Romanick [Thu, 2 Nov 2017 00:34:12 +0000 (17:34 -0700)]
glsl: Minor cleanups after previous commit

I think it's more clear to only call emit_access once.  The only
difference between the two calls is the value of size_mul used for the
offset parameter... but you really have to look at it to be sure.

The s/is_64bit/is_double/ change is because there are no int64_t or
uint64_t matrix types.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
4 years agoglsl: Use more link_calculate_matrix_stride in lower_buffer_access
Ian Romanick [Wed, 1 Nov 2017 23:40:32 +0000 (16:40 -0700)]
glsl: Use more link_calculate_matrix_stride in lower_buffer_access

I was going to squash this with the previous commit, but there's a lot
of churn in that commit.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
4 years agoglsl: Use link_calculate_matrix_stride in lower_buffer_access and friends
Ian Romanick [Wed, 1 Nov 2017 23:34:32 +0000 (16:34 -0700)]
glsl: Use link_calculate_matrix_stride in lower_buffer_access and friends

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
4 years agoglsl: Refactor matrix stride calculation into a utility function
Ian Romanick [Wed, 1 Nov 2017 23:27:53 +0000 (16:27 -0700)]
glsl: Refactor matrix stride calculation into a utility function

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
4 years agoglsl/linker: Optimize swizzles again after linking
Ian Romanick [Wed, 1 Nov 2017 05:18:10 +0000 (22:18 -0700)]
glsl/linker: Optimize swizzles again after linking

Without this, the SPIR-V generator has to deal with a bunch of junk
like:

    (swiz z (swiz xxx (swiz x (var_ref packed:binormal.z,light_dir))))

It seems better to cull that stuff out than to add code to deal with
it.  The problem is the way swizzles to and from scalars have to be
handled in SPIR-V.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
4 years agoglsl: Combine nop-swizzle optimization with swizzle-swizzle optimization
Ian Romanick [Wed, 1 Nov 2017 06:37:14 +0000 (23:37 -0700)]
glsl: Combine nop-swizzle optimization with swizzle-swizzle optimization

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: <thomashelland90@gmail.com>
4 years agoglsl: Make the swizzle-swizzle optimization greedy
Ian Romanick [Wed, 1 Nov 2017 06:16:38 +0000 (23:16 -0700)]
glsl: Make the swizzle-swizzle optimization greedy

If there is a long sequence of swizzled swizzles, compact all of them
down to a single swizzle.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: <thomashelland90@gmail.com>
4 years agoglsl: Remove program_resource_visitor::visit_field(const glsl_struct_field *)
Ian Romanick [Tue, 31 Oct 2017 22:06:24 +0000 (15:06 -0700)]
glsl: Remove program_resource_visitor::visit_field(const glsl_struct_field *)

I could not find any remaining users.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
4 years agoglsl: Silence unused parameter warning
Ian Romanick [Wed, 1 Nov 2017 23:25:37 +0000 (16:25 -0700)]
glsl: Silence unused parameter warning

glsl/lower_shared_reference.cpp: In member function ‘virtual void
{anonymous}::lower_shared_reference_visitor::insert_buffer_access(void*,
ir_dereference*, const glsl_type*, ir_rvalue*, unsigned int, int)’:

glsl/lower_shared_reference.cpp:244:58: warning: unused parameter
‘channel’ [-Wunused-parameter]
                                                      int channel)
                                                          ^~~~~~~

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
4 years agoac/nir: add support for all intrinsics. (v2)
Dave Airlie [Thu, 9 Nov 2017 01:00:50 +0000 (01:00 +0000)]
ac/nir: add support for all intrinsics. (v2)

This is derived from tgsi/radeonsi code from the GLSL intrinsics.

This should pre-fix radv for the upcoming spirv patches.

v2: actually use wait_cnt, sleep deprived dad time! (Bas)

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
4 years agoamdgpu: use simple mtx
Timothy Arceri [Mon, 16 Oct 2017 00:59:32 +0000 (11:59 +1100)]
amdgpu: use simple mtx

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
4 years agomesa: use simple mtx in core mesa
Timothy Arceri [Mon, 16 Oct 2017 00:59:31 +0000 (11:59 +1100)]
mesa: use simple mtx in core mesa

Results from x11perf -copywinwin10 on Eric's SKL:
   4.33338% ± 0.905054% (n=40)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Tested-by: Yogesh Marathe <yogesh.marathe@intel.com>
4 years agomesa: Add new fast mtx_t mutex type for basic use cases
Timothy Arceri [Mon, 16 Oct 2017 07:06:49 +0000 (18:06 +1100)]
mesa: Add new fast mtx_t mutex type for basic use cases

While modern pthread mutexes are very fast, they still incur a call to an
external DSO and overhead of the generality and features of pthread mutexes.
Most mutexes in mesa only needs lock/unlock, and the idea here is that we can
inline the atomic operation and make the fast case just two intructions.
Mutexes are subtle and finicky to implement, so we carefully copy the
implementation from Ulrich Dreppers well-written and well-reviewed paper:

  "Futexes Are Tricky"
  http://www.akkadia.org/drepper/futex.pdf

We implement "mutex3", which gives us a mutex that has no syscalls on
uncontended lock or unlock.  Further, the uncontended case boils down to a
cmpxchg and an untaken branch and the uncontended unlock is just a locked decr
and an untaken branch.  We use __builtin_expect() to indicate that contention
is unlikely so that gcc will put the contention code out of the main code
flow.

A fast mutex only supports lock/unlock, can't be recursive or used with
condition variables.  We keep the pthread mutex implementation around as
for the few places where we use condition variables or recursive locking.
For platforms or compilers where futex and atomics aren't available,
simple_mtx_t falls back to the pthread mutex.

The pthread mutex lock/unlock overhead shows up on benchmarks for CPU bound
applications.  Most CPU bound cases are helped and some of our internal
bind_buffer_object heavy benchmarks gain up to 10%.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
4 years agomesa: rework how we free gl_shader_program_data
Timothy Arceri [Tue, 7 Nov 2017 23:57:21 +0000 (10:57 +1100)]
mesa: rework how we free gl_shader_program_data

When I introduced gl_shader_program_data one of the intentions was to
fix a bug where a failed linking attempt freed data required by a
currently active program. However I seem to have failed to finish
hooking up the final steps required to have the data hang around.

Here we create a fresh instance of gl_shader_program_data every
time we link. gl_program has a reference to gl_shader_program_data
so it will be freed once the program is no longer active.

Cc: "17.2 17.3" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Neil Roberts <nroberts@igalia.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102177

4 years agoglsl: use the correct parent when allocating program data members
Timothy Arceri [Wed, 8 Nov 2017 00:34:10 +0000 (11:34 +1100)]
glsl: use the correct parent when allocating program data members

Cc: "17.2 17.3" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
4 years agoglsl: drop cache_fallback
Timothy Arceri [Tue, 7 Nov 2017 22:54:22 +0000 (09:54 +1100)]
glsl: drop cache_fallback

This turned out to be a dead end, it is much easier and less error
prone to just cache the IR used by the drivers backend e.g. TGSI or
NIR.

Cc: "17.2 17.3" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
4 years agoi965: properly initialize brw->cs.base.stage to MESA_SHADER_COMPUTE
Kenneth Graunke [Tue, 31 Oct 2017 07:56:24 +0000 (00:56 -0700)]
i965: properly initialize brw->cs.base.stage to MESA_SHADER_COMPUTE

This has a bit of a surprising effect:

For the render pipeline, the upload_sampler_state_table atom emits
3DSTATE_BINDING_TABLE_POINTERS_XS.  It tries to avoid this for compute:

   if (GEN_GEN >= 7 && stage_state->stage != MESA_SHADER_COMPUTE) {
      /* Emit a 3DSTATE_SAMPLER_STATE_POINTERS_XS packet. */
      genX(emit_sampler_state_pointers_xs)(brw, stage_state);
   } ...

However, we were failing to initialize brw->cs.base.stage, so it was
left as 0 (MESA_SHADER_VERTEX), causing this condition to break.  We
then emitted 3DSTATE_SAMPLER_STATE_POINTERS_VS in GPGPU mode, when
trying to upload CS samplers.  Nothing good can come of this.

Found by inspection while debugging a GPU hang.  Jordan believes this
helps the Deus Ex: Mankind Divided benchmark mode's stability when
running with shader cache.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
4 years agointel/nir: Break the linking code into a helper in brw_nir.c
Jason Ekstrand [Sat, 28 Oct 2017 15:57:23 +0000 (08:57 -0700)]
intel/nir: Break the linking code into a helper in brw_nir.c

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Cc: mesa-stable@lists.freedesktop.org
4 years agointel/nir: Add a helper for getting the NoIndirect mask
Jason Ekstrand [Sat, 28 Oct 2017 15:50:54 +0000 (08:50 -0700)]
intel/nir: Add a helper for getting the NoIndirect mask

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Cc: mesa-stable@lists.freedesktop.org
4 years agonir: Don't print swizzles when there are more than 4 components
Matt Turner [Sat, 28 Oct 2017 01:15:46 +0000 (18:15 -0700)]
nir: Don't print swizzles when there are more than 4 components

... as can happen with various types like mat4, or else we'll smash the
stack writing past the end of components_local[].

Fixes: 5a0d3e1129b7 ("nir: Print the components referenced for split or
                      packed shader in/outs.")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
4 years agomeson: Add threads dependencies to glsl_compiler executable
Dylan Baker [Fri, 27 Oct 2017 18:19:46 +0000 (11:19 -0700)]
meson: Add threads dependencies to glsl_compiler executable

Fixes compiling the optional standalone glsl compiler.

Reported-by: DrNick (on irc)
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Reviewed-and-Tested-by: Eric Engestrom <eric.engestrom@imgtec.com>
4 years agoglsl: Fix typo fragement -> fragment
Andreas Boll [Wed, 8 Nov 2017 14:15:08 +0000 (15:15 +0100)]
glsl: Fix typo fragement -> fragment

Fixes: 94d669b0d2f ("glsl: enforce fragment shader input restrictions in
       GLSL ES 3.10")

Signed-off-by: Andreas Boll <andreas.boll.dev@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
4 years agobroadcom/vc5: Remove unused v3d_compiler.c
Andreas Boll [Wed, 8 Nov 2017 14:15:07 +0000 (15:15 +0100)]
broadcom/vc5: Remove unused v3d_compiler.c

Unused since original import of VC5.

Fixes: ade416d0236 ("broadcom: Add VC5 NIR compiler.")
Signed-off-by: Andreas Boll <andreas.boll.dev@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
4 years agobroadcom/vc5: Add vc5_drm.h to the release tarball
Andreas Boll [Wed, 8 Nov 2017 14:15:06 +0000 (15:15 +0100)]
broadcom/vc5: Add vc5_drm.h to the release tarball

Fixes: 45bb8f29571 ("broadcom: Add V3D 3.3 gallium driver called "vc5",
       for BCM7268.")

Cc: 17.3 <mesa-stable@lists.freedesktop.org>
Signed-off-by: Andreas Boll <andreas.boll.dev@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
4 years agoclover: use the unified check for c++11 instead of the gcc version number
Gert Wollny [Wed, 18 Oct 2017 15:05:27 +0000 (17:05 +0200)]
clover: use the unified check for c++11 instead of the gcc version number

So far clover based its test for compiler support on the version of gcc,
while in reality support for c++11 is required. This patch replaces the
version check by the check unified for all modules that require c++11.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
4 years agoswr: Replace the check for c++11 by the unified version
Gert Wollny [Wed, 18 Oct 2017 15:05:26 +0000 (17:05 +0200)]
swr: Replace the check for c++11 by the unified version

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
4 years agoconfigure: check for -std=c++11 support and enable st/mesa test accordingly
Gert Wollny [Wed, 18 Oct 2017 15:05:25 +0000 (17:05 +0200)]
configure: check for -std=c++11 support and enable st/mesa test accordingly

Add a check that tests whether the c++ compiler supports c++11, either
by default, by adding the compiler flag -std=c++11, or by adding a
compiler flag that the user has specified via the environment variable
CXX11_CXXFLAGS.

The test only does a very shallow check of c++11 support, i.e. it tests
whether the define  __cplusplus >= 201103L to confirm language support
by the compiler, and it checks whether the header <tuple> is available
to test the availability of the c++11 standard library.

A make file conditional HAVE_STD_CXX11 is provided that is used in this
patch to enable the test in st/mesa if C++11 support is available.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102665
Acked-by: Emil Velikov <emil.velikov@collabora.com>
4 years agoconfigure.ac: append to existing initializer override flags
Emil Velikov [Tue, 31 Oct 2017 19:26:33 +0000 (19:26 +0000)]
configure.ac: append to existing initializer override flags

Currently we were overwriting the existing warning flags, instead of
adding new [as applicable].

Fixes c5d2e2d43f6 ("configure: Test for -Wno-initializer-overrides")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
4 years agoconfigure.ac: append to existing MSVC compat flags
Emil Velikov [Tue, 31 Oct 2017 19:26:32 +0000 (19:26 +0000)]
configure.ac: append to existing MSVC compat flags

Currently we were overwriting the existing warning flags, instead of
adding new [as applicable].

v2: Add missing space before -Werror (Eric)

Fixes e4b2b69e828 ("configure: Add and use AX_CHECK_COMPILE_FLAG")
Cc: Matt Turner <mattst88@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
4 years agomeson: Allow building glvnd with EGL and non-dri based GLX
Dylan Baker [Wed, 1 Nov 2017 17:24:10 +0000 (10:24 -0700)]
meson: Allow building glvnd with EGL and non-dri based GLX

Because meson mirrors the auototools logic, it needs the same changes to
allow building glvnd based egl.

v2: - change if to elif (Eric)

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
4 years agoconfigure.ac: require xcb* for the omx/va/... when using x11 platform
Emil Velikov [Tue, 31 Oct 2017 18:58:10 +0000 (18:58 +0000)]
configure.ac: require xcb* for the omx/va/... when using x11 platform

Targets such as omx and va can work w/o anything X related. Mandate the
xcb* dependencies only when the X11 platform is selected.

Reported-by: Lukas Rusak <lorusak@gmail.com>
Fixes: 63e11ac2b5c ("configure: error out if building VA w/o supported
platform")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Tested-by: Lukas Rusak <lorusak@gmail.com> (v1)
4 years agoconfigure.ac: loosen --enable-glvnd check to honour egl
Emil Velikov [Tue, 31 Oct 2017 18:58:09 +0000 (18:58 +0000)]
configure.ac: loosen --enable-glvnd check to honour egl

Currently we error out when building GLVND w/o GLX.

That was the original premice before we had EGL. As the commit says,
that error should be reworked to honour both - do so.

v2: Drop noop *);; (Eric)

Reported-by: Lukas Rusak <lorusak@gmail.com>
Fixes: ce562f9e3fa ("EGL: Implement the libglvnd interface for EGL (v3)")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Tested-by: Lukas Rusak <lorusak@gmail.com> (v1)
4 years agoegl/android: add a note about .swap_buffers_with_damage
Emil Velikov [Mon, 16 Oct 2017 16:10:42 +0000 (17:10 +0100)]
egl/android: add a note about .swap_buffers_with_damage

Android implements the API and does the native damage handling itself.
At the same time it
 a) does call the vendor's eglSwapBuffersWithDamageKHR
 b) does not implement eglSetDamageRegionKHR

There's something strange happening here. For now simply note about the
'lack' of eglSwapBuffersWithDamageKHR support.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
4 years agowayland-drm: static inline wayland_drm_buffer_get
Emil Velikov [Tue, 24 Oct 2017 16:14:20 +0000 (17:14 +0100)]
wayland-drm: static inline wayland_drm_buffer_get

The function is effectively a direct function call into
libwayland-server.so.

Thus GBM no longer depends on the wayland-drm static library, making the
build more straight forward. And the resulting binary is a bit smaller.

Note: we need to move struct wayland_drm_callbacks further up,
otherwise we'll get an error since the type is incomplete.

v2: Rebase, beef-up commit message, update meson, move struct
wayland_drm_callbacks.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com> (v1)
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> # meson bit only
Acked-by: Eric Engestrom <eric.engestrom@imgtec.com> # for the rest
Reviewed-by: Dylan Baker <dylan@pnwbakers.com> # meson
4 years agoautomake: intel: correctly append to the LIBADD variable
Emil Velikov [Mon, 23 Oct 2017 12:29:30 +0000 (13:29 +0100)]
automake: intel: correctly append to the LIBADD variable

Commit 05fc62d89f5 sets the variable, yet it forgot the update the
existing reference to append (instead of assign).

Thus as-is the expat library was discarded from the link chain when
building with Android.

Fixes: 05fc62d89f5 ("automake: intel: move expat handling where it's
used")
Cc: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
4 years agoconfigure: enable the OpenCL ICD by default
Emil Velikov [Mon, 16 Oct 2017 15:40:08 +0000 (16:40 +0100)]
configure: enable the OpenCL ICD by default

Nearly all the distributions* that build Mesa OpenCL, enable the ICD.
Since building a non-ICD driver has the chance of conflicting with
existing OpenCL binary (libOpenCL.so).

Furthermore, some applications expect the library to provide
annotated/versioned symbols.

https://lists.freedesktop.org/archives/mesa-dev/2017-September/171093.html

*Fedora, Suse, Arch, Debian, Ubuntu, FreeBSD use the ICD
Gentoo manages the conflicting files via eselect.

Cc: Matt Turner <mattst88@gmail.com>
Cc: Jan Vesely <jan.vesely@rutgers.edu>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-By: Aaron Watry <awatry@gmail.com>
4 years agotargets/opencl: don't hardcode the icd file install to /etc/...
Emil Velikov [Mon, 16 Oct 2017 15:40:07 +0000 (16:40 +0100)]
targets/opencl: don't hardcode the icd file install to /etc/...

Use $(sysconfdir) instead of hardcoding /etc.

While the OpenCL spec expects the file in /etc, people building their
stack can override that, esp. !Linux users.

Furthermore this removes a fundamental violation, which results in the
system file being overwritten even as one explicitly sets --prefix
and/or DESTDIR.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-By: Aaron Watry <awatry@gmail.com>
4 years agoamd: add amdgpu_asic_addr.h to the sources list
Emil Velikov [Wed, 8 Nov 2017 14:07:27 +0000 (14:07 +0000)]
amd: add amdgpu_asic_addr.h to the sources list

Otherwise it will be missing from the release tarball

Fixes: 7f33e94e43a ("amd/addrlib: update to latest version")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
4 years agogallivm: Use new LLVM fast-math-flags API
Tobias Droste [Wed, 8 Nov 2017 09:44:19 +0000 (10:44 +0100)]
gallivm: Use new LLVM fast-math-flags API

LLVM 6 changed the API on the fast-math-flags:
https://reviews.llvm.org/rL317488

NOTE: This also enables the new flag 'ApproxFunc' to allow for
approximations for library functions (sin, cos, ...). I'm not completly
convinced, that this is something mesa should do.

Signed-off-by: Tobias Droste <tdroste@gmx.de>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
4 years agoglsl: add varying resources for arrays of complex types
Juan A. Suarez Romero [Tue, 31 Oct 2017 17:39:17 +0000 (17:39 +0000)]
glsl: add varying resources for arrays of complex types

This patch is mostly a patch done by Ilia Mirkin.

It fixes KHR-GL45.enhanced_layouts.varying_structure_locations.

v2: fix locations for TCS/TES/GS inputs and outputs (Ilia)

CC: Ilia Mirkin <imirkin@alum.mit.edu>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103098
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
4 years agost/glsl_to_nir: use nir_shader_gather_info()
Timothy Arceri [Wed, 1 Nov 2017 09:32:12 +0000 (20:32 +1100)]
st/glsl_to_nir: use nir_shader_gather_info()

Use the NIR helper rather than the GLSL IR helper to get in/out
masks. This allows us to ignore varyings removed by NIR
optimisations.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
4 years agost/glsl_to_nir: generate NIR earlier
Timothy Arceri [Wed, 1 Nov 2017 06:28:09 +0000 (17:28 +1100)]
st/glsl_to_nir: generate NIR earlier

We want to use nir_shader_gather_info() the GLSL IR version might
be including varyings that NIR later eliminates. To do this we
need to generate NIR before we we start using the in/out bitmasks.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
4 years agost/glsl_to_nir: delay adding built-in uniforms to Parameters list
Timothy Arceri [Wed, 1 Nov 2017 03:15:22 +0000 (14:15 +1100)]
st/glsl_to_nir: delay adding built-in uniforms to Parameters list

Delaying adding built-in uniforms until after we convert to NIR
gives us a better chance to optimise them away. Also NIR allows
us to iterate over the uniforms directly so should be faster.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
4 years agoamd/addrlib: update to latest version
Marek Olšák [Mon, 6 Nov 2017 23:56:13 +0000 (00:56 +0100)]
amd/addrlib: update to latest version

This uses C++11 initializer lists.

I just overwrote all Mesa files with internal addrlib and discarded
hunks that we should probably keep, but I might have missed something.

The code depending on ADDR_AM_BUILD is removed. We can add it back next
time if needed.

Acked-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
4 years agobraodcom/vc5: Flush the job when it grows over 1GB.
Eric Anholt [Tue, 7 Nov 2017 19:05:16 +0000 (11:05 -0800)]
braodcom/vc5: Flush the job when it grows over 1GB.

Fixes GL_OUT_OF_MEMORY from streaming-texture-leak (and will hopefully
keep piglit from ooming on my no-swap platform, as well).