mesa.git
7 years agoglsl: define __STDC_FORMAT_MACROS to get PRIx64 macro
Brian Paul [Fri, 11 Nov 2016 16:16:34 +0000 (09:16 -0700)]
glsl: define __STDC_FORMAT_MACROS to get PRIx64 macro

Otherwise, inttypes.h may not define the macro for C++ on MinGW.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98681
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agomesa: fix comment indentation in bind_buffers_check_offset_and_size()
Brian Paul [Fri, 11 Nov 2016 15:11:40 +0000 (08:11 -0700)]
mesa: fix comment indentation in bind_buffers_check_offset_and_size()

Trivial.

7 years agoglsl: automake: add opt_add_neg_to_sub.h to the sources list
Emil Velikov [Fri, 11 Nov 2016 14:45:02 +0000 (14:45 +0000)]
glsl: automake: add opt_add_neg_to_sub.h to the sources list

Otherwise it'll be missing in the release tarball.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoi965: update gl_PrimitiveIDIn to be a system variable
Timothy Arceri [Tue, 25 Oct 2016 10:55:17 +0000 (21:55 +1100)]
i965: update gl_PrimitiveIDIn to be a system variable

Now that we have switched to using nir_shader_gather_info() we
can remove the hacks and just use the system variable.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965: use nir_shader_gather_info() over do_set_program_inouts()
Timothy Arceri [Thu, 27 Oct 2016 01:22:36 +0000 (12:22 +1100)]
i965: use nir_shader_gather_info() over do_set_program_inouts()

This takes us one step closer to being able to drop the GLSL IR
optimisation passes during linking in favour of the NIR passes.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965: remove remaining tabs in brw_program_cache.c
Timothy Arceri [Fri, 11 Nov 2016 04:08:42 +0000 (15:08 +1100)]
i965: remove remaining tabs in brw_program_cache.c

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965: rename brw_state_cache_check_size() to brw_program_cache_check_size()
Timothy Arceri [Fri, 11 Nov 2016 04:06:28 +0000 (15:06 +1100)]
i965: rename brw_state_cache_check_size() to brw_program_cache_check_size()

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965: rename brw_state_cache.c -> brw_program_cache.c
Timothy Arceri [Fri, 11 Nov 2016 04:01:24 +0000 (15:01 +1100)]
i965: rename brw_state_cache.c -> brw_program_cache.c

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965/gs: Allow primitive id to be a system value
Jason Ekstrand [Fri, 11 Nov 2016 06:36:39 +0000 (22:36 -0800)]
i965/gs: Allow primitive id to be a system value

This allows for gl_PrimitiveId to come in as a system value rather than as
an input.  This is the way it will come in from SPIR-V. We keeps the input
path working for now so we don't break GL.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agovulkan/wsi/x11: Implement FIFO mode.
Jason Ekstrand [Thu, 3 Nov 2016 23:59:08 +0000 (16:59 -0700)]
vulkan/wsi/x11: Implement FIFO mode.

This implements VK_PRESENT_MODE_FIFO_KHR for X11.  Unfortunately, due to
the way the present extension works, we have to manage the queue of
presented images in a separate thread.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agovulkan/wsi: Report the correct min/maxImageCount
Jason Ekstrand [Fri, 4 Nov 2016 22:42:48 +0000 (15:42 -0700)]
vulkan/wsi: Report the correct min/maxImageCount

From the Vulkan spec 1.0.32 section 29.6 docs for vkAcquireNextImageKHR:

   "Let n be the total number of images in the swapchain, m be the value of
   VkSurfaceCapabilitiesKHR::minImageCount, and a be the number of
   presentable images that the application has currently acquired (i.e.
   images acquired with vkAcquireNextImageKHR, but not yet presented with
   vkQueuePresentKHR).  vkAcquireNextImageKHR can always succeed if a ≤ n -
   m at the time vkAcquireNextImageKHR is called. vkAcquireNextImageKHR
   should not be called if a > n - m with a timeout of UINT64_MAX; in such
   a case, vkAcquireNextImageKHR may block indefinitely."

With minImageCount == 2 (as it was previously, the client is allowed to
acquire all but one image withoutblocking.  If we really need 4 images for
mailbox mode + pageflipping, then we need to request a minimum of 4 images
up-front.  This is a bit unfortunate because it means we will always
consume 4 images.  In the future, we may be able to optimize this a bit by
waiting until the server starts to flip and returning OUT_OF_DATE to get
the client to re-allocate with more images or something like that.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agovulkan/wsi: Add a thread-safe queue implementation
Kevin Strasser [Thu, 3 Nov 2016 01:18:44 +0000 (18:18 -0700)]
vulkan/wsi: Add a thread-safe queue implementation

In order to support FIFO mode without blocking the application on calls
to vkQueuePresentKHR it is necessary to enqueue the request and defer
calling the server until the next vblank period. The xcb present api
doesn't offer a way to register a callback, so we will have to spawn a
worker thread that will wait for a request to be added to the queue, call
to the server, and then make the image available for reuse.  This commit
introduces the queue data structure needed to implement this.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agoandroid/i965: add libmesa_i965_compiler static library
Tapani Pälli [Thu, 10 Nov 2016 08:20:26 +0000 (10:20 +0200)]
android/i965: add libmesa_i965_compiler static library

this will be shared between OpenGL and Vulkan drivers

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoandroid: add SPIRV_FILES to libmesa_nir
Tapani Pälli [Tue, 8 Nov 2016 10:49:18 +0000 (12:49 +0200)]
android: add SPIRV_FILES to libmesa_nir

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoanv: use STATIC_ASSERT instead of static_assert
Tapani Pälli [Wed, 9 Nov 2016 07:02:39 +0000 (09:02 +0200)]
anv: use STATIC_ASSERT instead of static_assert

fixes following compilation warnings on Android build:

"warning: implicit declaration of function 'static_assert' is invalid in
C99 [-Wimplicit-function-declaration]"

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoutil: use STATIC_ASSERT instead of static_assert
Tapani Pälli [Wed, 9 Nov 2016 06:58:12 +0000 (08:58 +0200)]
util: use STATIC_ASSERT instead of static_assert

fixes following compilation warnings on Android build:

"warning: implicit declaration of function 'static_assert' is invalid in
C99 [-Wimplicit-function-declaration]"

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agovulkan: import latest public vulkan headers + and fix drivers.
Dave Airlie [Fri, 11 Nov 2016 01:44:10 +0000 (11:44 +1000)]
vulkan: import latest public vulkan headers + and fix drivers.

I just noticed the new vulkan headers changed a prototype,
so I've decided to import them and fix the drivers to use the
new API.

Acked-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agodocs: add news item and link release notes for 12.0.4
Emil Velikov [Fri, 11 Nov 2016 01:57:50 +0000 (01:57 +0000)]
docs: add news item and link release notes for 12.0.4

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agodocs: add sha256 checksums for 12.0.4
Emil Velikov [Fri, 11 Nov 2016 01:55:08 +0000 (01:55 +0000)]
docs: add sha256 checksums for 12.0.4

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 7b9d7257b27c15547ffab8d73d10d8a850af364a)

7 years agodocs: add release notes for 12.0.4
Emil Velikov [Fri, 11 Nov 2016 01:53:32 +0000 (01:53 +0000)]
docs: add release notes for 12.0.4

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 3776e97f9d366db8a720e2412ece6a1059999858)

7 years agoglsl: include inttypes.h for PRIx64 macro
Brian Paul [Fri, 11 Nov 2016 00:29:28 +0000 (17:29 -0700)]
glsl: include inttypes.h for PRIx64 macro

To fix MinGW build.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
7 years agoradv: fix texturesamples to handle single sample case
Dave Airlie [Thu, 10 Nov 2016 00:32:08 +0000 (10:32 +1000)]
radv: fix texturesamples to handle single sample case

We can only read the valid samples if this is an MSAA
texture, which means the type field must be 0x14 or 0x15.

This fixes:
dEQP-VK.glsl.texture_functions.query.texturesamples.*

Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoanv/cmd_buffer: Enable a CS stall workaround for Sky Lake gt4
Jason Ekstrand [Thu, 10 Nov 2016 22:09:08 +0000 (14:09 -0800)]
anv/cmd_buffer: Enable a CS stall workaround for Sky Lake gt4

This fixes hangs in Dota2

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "12.0 13.0" <mesa-stable@lists.freedesktop.org>
7 years agoanv/cmd_buffer: Take a command buffer instead of a batch in two helpers
Jason Ekstrand [Thu, 10 Nov 2016 22:08:43 +0000 (14:08 -0800)]
anv/cmd_buffer: Take a command buffer instead of a batch in two helpers

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "12.0 13.0" <mesa-stable@lists.freedesktop.org>
7 years agoglsl/standalone: Add the ability to generate ir_builder code
Ian Romanick [Thu, 15 Sep 2016 18:37:32 +0000 (11:37 -0700)]
glsl/standalone: Add the ability to generate ir_builder code

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agoglsl: Add a C++ code generator that uses ir_builder to rebuild a program
Ian Romanick [Thu, 15 Sep 2016 18:36:16 +0000 (11:36 -0700)]
glsl: Add a C++ code generator that uses ir_builder to rebuild a program

This is only in libstandalone currently because it will only be used in
the stand-alone compiler.

v2: Change the signature of the generated function.  The ir_factory is
created in the generator, and an availability predicate is taken as a
parameter.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoglsl: Generate strings that are the enum names without the ir_*op_ prefix
Ian Romanick [Thu, 15 Sep 2016 18:26:28 +0000 (11:26 -0700)]
glsl: Generate strings that are the enum names without the ir_*op_ prefix

For many expressions, this is different from the printable name.  The
printable name for ir_binop_add is "+", but we want "add".  This is
needed for ir_builder_print_visitor.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoglsl/standalone: Enable par-linking
Ian Romanick [Thu, 15 Sep 2016 18:24:12 +0000 (11:24 -0700)]
glsl/standalone: Enable par-linking

If the user did not request full linking, link the shader with the
built-in functions, inline them, and eliminate them.  Previous to this
you'd see all these calls to "dot" and "max" in the output.  This
prevented a lot of expected optimizations and cluttered the output.
This gives it some chance of being useful.

v2: Rebase on top of Ken's "built-ins now" work.

v3: Don't do_common_optimizations if par-linking fails.  Update expected
output of warnings tests to prevent 'make check' regressions.

v4: Optimize harder.  Most important, do function inlining.  Otherwise
it's quite impractical for one function in a file to call another
function in the same file.

v5: Add some code simplifications and an assertion suggested by Iago.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agoglsl/standalone: Optimize dead variable declarations
Ian Romanick [Thu, 15 Sep 2016 18:18:35 +0000 (11:18 -0700)]
glsl/standalone: Optimize dead variable declarations

We didn't bother with this in the regular compiler because it doesn't
change the generated code.  In the stand-alone compiler, this can
clutter the output with useless variables.  It's especially bad after
functions are inlined but the foo_retval declarations remain.

v2: Use set_foreach.  Suggested by Tapani.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agoglsl/standalone: Optimize add-of-neg to subtract
Ian Romanick [Wed, 14 Sep 2016 20:52:42 +0000 (13:52 -0700)]
glsl/standalone: Optimize add-of-neg to subtract

This just makes the output of the standalone compiler a little more
compact.

v2: Fix indexing typo noticed by Iago.  Move the add_neg_to_sub_visitor
to it's own header file.  Add a unit test that exercises the visitor.
Both the neg_a_plus_b and neg_a_plus_neg_b tests reproduced the bug that
Iago discovered.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoglsl/linker: Allow link_intrastage_shaders when there is no main()
Ian Romanick [Thu, 15 Sep 2016 18:09:34 +0000 (11:09 -0700)]
glsl/linker: Allow link_intrastage_shaders when there is no main()

This enables a sort of par-linking.  The primary use for this feature is
resolving built-in functions in the stand-alone compiler.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agonir: update nir_gather_info to only mark used array/matrix elements
Timothy Arceri [Thu, 27 Oct 2016 01:21:52 +0000 (12:21 +1100)]
nir: update nir_gather_info to only mark used array/matrix elements

This is based on the code from the GLSL IR pass however unlike the GLSL IR
pass it also supports arrays of arrays.

As well as implementing the logic from the GLSL IR pass we add some
additional intrinsic cases to catch more system values.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agomesa/compiler: move MAX_VARYING to shader_enums.h
Kenneth Graunke [Wed, 2 Mar 2016 01:41:02 +0000 (17:41 -0800)]
mesa/compiler: move MAX_VARYING to shader_enums.h

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
7 years agonir: add more helpers to nir_types.cpp
Timothy Arceri [Tue, 25 Oct 2016 06:04:31 +0000 (17:04 +1100)]
nir: add more helpers to nir_types.cpp

These new helpers will be used in nir_gather_info.c in a following patch.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agonir: Generalize the "is per-vertex variable?" helpers and export them.
Kenneth Graunke [Mon, 26 Sep 2016 05:19:07 +0000 (22:19 -0700)]
nir: Generalize the "is per-vertex variable?" helpers and export them.

I want this function for nir_gather_info(), and realized it's basically
the same as the ones in nir_lower_io().

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
7 years agonvc0: support MP performance counters on Maxwell
Samuel Pitoiset [Sat, 5 Nov 2016 16:23:33 +0000 (17:23 +0100)]
nvc0: support MP performance counters on Maxwell

This adds some performance counters/metrics for SM50/SM52.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Pierre Moreau <pierre.morrow@free.fr>
7 years agogallium: detect avx512 cpu features
Tim Rowley [Thu, 26 May 2016 20:06:07 +0000 (15:06 -0500)]
gallium: detect avx512 cpu features

v3: fix check for xmm/ymm test
v2: style code, add avx512 to cpu dump

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
7 years agoglsl: Parse 0 as a preprocessor INTCONSTANT
Ian Romanick [Tue, 8 Nov 2016 19:14:49 +0000 (11:14 -0800)]
glsl: Parse 0 as a preprocessor INTCONSTANT

This allows a more reasonable error message for '#version 0' of

    0:1(10): error: GLSL 0.00 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

instead of

    0:1(10): error: syntax error, unexpected $undefined, expecting INTCONSTANT

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97420
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Cc: mesa-stable@lists.freedesktop.org
Cc: Juan A. Suarez Romero <jasuarez@igalia.com>
Cc: Karol Herbst <karolherbst@gmail.com>
7 years agoglcpp: Handle '#version 0' and other invalid values
Ian Romanick [Tue, 8 Nov 2016 19:06:05 +0000 (11:06 -0800)]
glcpp: Handle '#version 0' and other invalid values

The #version directive can only handle decimal constants.  Enforce that
the value is a decimal constant.

Section 3.3 (Preprocessor) of the GLSL 4.50 spec says:

    The language version a shader is written to is specified by

        #version number profile opt

    where number must be a version of the language, following the same
    convention as __VERSION__ above.

The same section also says:

    __VERSION__ will substitute a decimal integer reflecting the version
    number of the OpenGL shading language.

Use a separate flag to track whether or not the #version line has been
encountered.  Any possible sentinel (0 is currently used) could be
specified in a #version directive.  This would lead to trying to
(internally) redefine __VERSION__.  Since there is no parser location
for this addition, NULL is passed.  This eventually results in a NULL
dereference and a segfault.

Attempts to use -1 as the sentinel would also fail if '#version
4294967295' or '#version 18446744073709551615' were used.  We should
have piglit tests for both of these.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97420
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Cc: mesa-stable@lists.freedesktop.org
Cc: Juan A. Suarez Romero <jasuarez@igalia.com>
Cc: Karol Herbst <karolherbst@gmail.com>
7 years agolinker: Remove unnecessary overload of program_resource_visitor::visit_field
Ian Romanick [Wed, 9 Nov 2016 20:45:39 +0000 (12:45 -0800)]
linker: Remove unnecessary overload of program_resource_visitor::visit_field

It looks like I added this version as a short-hand for users that didn't
need the fuller version.  I don't think there's any real utility in
that.  I'm not sure what my thinking was there.  Maybe if those users
overloaded the recursion function could just call the compact version to
avoid passing some parameters?  None of the users do that.

Either way, having this extra overload is not useful.  Delete it.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
7 years agoradv: automake: list correct file in the EXTRA_DIST
Emil Velikov [Thu, 10 Nov 2016 18:50:13 +0000 (18:50 +0000)]
radv: automake: list correct file in the EXTRA_DIST

Earlier commit renamed the file radeon_icd.json{,.in} but missed one
reference of the file - in EXTRA_DIST.

Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Fixes: 0f434a68a ("radv: Suffix the radeon_icd file with the host CPU")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agomesa: remove LowerShaderSharedVariables
Marek Olšák [Wed, 9 Nov 2016 12:04:09 +0000 (13:04 +0100)]
mesa: remove LowerShaderSharedVariables

always true for compute shaders

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoglsl: handle partial swizzles in opt_dead_code_local correctly
Marek Olšák [Mon, 7 Nov 2016 21:56:21 +0000 (22:56 +0100)]
glsl: handle partial swizzles in opt_dead_code_local correctly

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoglsl: don't run loop passes if loop unrolling is disabled
Marek Olšák [Fri, 4 Nov 2016 11:57:53 +0000 (12:57 +0100)]
glsl: don't run loop passes if loop unrolling is disabled

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoradeonsi: fix r600_texture::tc_compatible_htile
Marek Olšák [Sun, 6 Nov 2016 21:27:56 +0000 (22:27 +0100)]
radeonsi: fix r600_texture::tc_compatible_htile

htile_size is now always non-zero if HTILE is allocated.

It seems to have caused no issues.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: accept is_store in image_fetch_rsrc instead of dcc_off
Marek Olšák [Sat, 5 Nov 2016 17:32:26 +0000 (18:32 +0100)]
radeonsi: accept is_store in image_fetch_rsrc instead of dcc_off

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: don't rely on tgsi_scan::images_buffers
Marek Olšák [Sat, 5 Nov 2016 17:26:09 +0000 (18:26 +0100)]
radeonsi: don't rely on tgsi_scan::images_buffers

the instruction knows the target

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: re-order cases in si_get_shader_param
Marek Olšák [Fri, 4 Nov 2016 11:41:34 +0000 (12:41 +0100)]
radeonsi: re-order cases in si_get_shader_param

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: increase MAX_CONTROL_FLOW_DEPTH AKA MaxIfDepth
Marek Olšák [Fri, 4 Nov 2016 11:31:53 +0000 (12:31 +0100)]
radeonsi: increase MAX_CONTROL_FLOW_DEPTH AKA MaxIfDepth

we don't want to lower deep IFs unconditionally

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoRevert "configure.ac: honour LLVM_LIBDIR when linking against LLVM"
Emil Velikov [Thu, 10 Nov 2016 15:10:34 +0000 (15:10 +0000)]
Revert "configure.ac: honour LLVM_LIBDIR when linking against LLVM"

This reverts commit a39ad185932eab4f25a0cb2b112c10d8700ef242.

The commit aims to address "missing" -L/foo/bar during linking stage. At
the same time it doesn't add the -L and yet the LLVM_LDFLAGS [which
provide -L/foo/bar] are already used throughout.

Seems like something pretty unique (broken?) on my end. Since the commit
introduces issues (due to the missing -L) revert until we get to the
root of it (PEBKAC or a genuine issue).

7 years agoradeonsi: fix/silence unused variable warnings in optimized builds
Nicolai Hähnle [Fri, 4 Nov 2016 09:39:45 +0000 (10:39 +0100)]
radeonsi: fix/silence unused variable warnings in optimized builds

I'm leaving num_out_sgpr around since it's not in a fast path, and besides
the compiler should be able to optimize it away easily. The alternative
with #if/#endif would be extremely ugly.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agogallivm: fix [IU]MUL_HI regression harder
Nicolai Hähnle [Wed, 9 Nov 2016 11:44:47 +0000 (12:44 +0100)]
gallivm: fix [IU]MUL_HI regression harder

The fix in commit 88f791db75e9f065bac8134e0937e1b76600aa36 was insufficient
for radeonsi because the vector case was not handled properly. It seems
piglit only covers the scalar case, unfortunately.

Fixes GL45-CTS.shader_bitfield_operation.[iu]mulExtended.*

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
7 years agoRevert "wayland: Block for the frame callback in get_back_bo not dri2_swap_buffers"
Daniel Stone [Wed, 1 Jun 2016 08:59:06 +0000 (09:59 +0100)]
Revert "wayland: Block for the frame callback in get_back_bo not dri2_swap_buffers"

This reverts commit 25cc889004aad6d1cab9edd76db898658e347b97, though
since the code has changed, it was applied manually.

The intent of moving blocking from SwapBuffers to get_back_bo, was to
avoid unnecessary triple-buffering by ensuring that the compositor had
fully processed the previous frame before we started rendering. This
means that the only time we would have to resort to triple-buffering
would be when the buffer is directly scanned out, thus saving an extra
buffer for composition anyway.

The 'repaint window' changes introduced in Weston since then, however,
have narrowed the window of time between the frame event being sent and
the repaint loop needing to conclude, to 7ms by default, in order to
reduce latency. This means however that blocking in get_back_bo gives a
maximum of 7ms for the entire GL submission to begin and complete.

Not only this, but if a client is using buffer_age to avoid full
repaints, the buffer-age request will stall in get_back_bo until the
frame callback completes, meaning that the client cannot even calculate
the repaint area before the 7ms window.

The combination of the two meant that WebKit-GTK+ was failing to
achieve full framerate on a Minnowboard, due to spending a great deal of
its time attempting to query the age of the next buffer before redraw.

Revert to the previous behaviour of allowing rendering to begin but
delaying SwapBuffers, unless and until we can find a more gentle
behaviour.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Derek Foreman <derekf@osg.samsung.com>
Cc: Kristian Høgsberg <krh@bitplanet.net>
7 years agoglsl: validate output blocks against input blocks
Iago Toral Quiroga [Fri, 4 Nov 2016 12:37:58 +0000 (13:37 +0100)]
glsl: validate output blocks against input blocks

Until now were validating in/out blocks by listing the inputs in the
consumer stage and then, for each output of the producer, we checked that
it was a match if it was consumed. This method does not catch the case
where the consumer has an input that is not present as an output in the
producer stage, because it only generates link errors for outputs present
in the producer stage that don't match the inputs in the consumer stage.
The current method does catch the case were an output from the producer
stage is not consumed, which is irrelevant and is ignored.

By reversing the way we do this, we can detect this situation, so this
patch lists the outputs of the producer stage and then validates inputs
of the consumer stage against them. If we see an input in the consumer
for which there is no associated output in the producer, we produce a
link error.

The only exception to this is the special built-in input block gl_in[],
since this is implicitly generated for geometry and tessellation stages,
but we don't generate it if the producer stage does not write to any of
the pre-defined outputs (for example, if the vertex shader does not write
to gl_Position, etc). Since writing to these is not mandatory, do not
produce a link error in that case. There is a CTS tessellation test
(GL45-CTS.tessellation_shader.program_object_properties) that has an
empty vertex shader (so it does not produce gl_in[]) and would fail to
link if we don't do this.

This fixes the following dEQP test:
dEQP-GLES31.functional.shaders.linkage.io_block.missing_output_block

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98245
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradv: fixup botched llvm API changes.
Dave Airlie [Thu, 10 Nov 2016 04:12:32 +0000 (14:12 +1000)]
radv: fixup botched llvm API changes.

Reported-by: Jan Vesely <jan.vesely@rutgers.edu>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoac/nir/llvm: adopt to new LLVM attribute API.
Dave Airlie [Thu, 10 Nov 2016 03:04:54 +0000 (13:04 +1000)]
ac/nir/llvm: adopt to new LLVM attribute API.

Ported from corresponding changes to gallivm.

tested build against 3.9 and master.

Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agovulkan/wsi/wayland: Clean up some error handling paths
Jason Ekstrand [Wed, 9 Nov 2016 18:21:03 +0000 (10:21 -0800)]
vulkan/wsi/wayland: Clean up some error handling paths

This gets rid of all the memory leaks reported by the WSI CTS tests.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agovulkan/wsi/wayland: Include pthread.h
Jason Ekstrand [Wed, 9 Nov 2016 18:20:31 +0000 (10:20 -0800)]
vulkan/wsi/wayland: Include pthread.h

We use pthreads and, for some reason, it wasn't getting included

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agoanv/device: Implicitly unmap memory objects in FreeMemory
Jason Ekstrand [Tue, 8 Nov 2016 01:25:07 +0000 (17:25 -0800)]
anv/device: Implicitly unmap memory objects in FreeMemory

From the Vulkan spec version 1.0.32 docs for vkFreeMemory:

   "If a memory object is mapped at the time it is freed, it is implicitly
   unmapped."

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Cc: "12.0 13.0" <mesa-dev@lists.freedesktop.org>
7 years agoanv/device: Return the right error for failed maps
Jason Ekstrand [Tue, 8 Nov 2016 01:24:24 +0000 (17:24 -0800)]
anv/device: Return the right error for failed maps

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Cc: "12.0 13.0" <mesa-dev@lists.freedesktop.org>
7 years agoanv/device: Add some asserts to MapMemory
Jason Ekstrand [Tue, 8 Nov 2016 01:23:44 +0000 (17:23 -0800)]
anv/device: Add some asserts to MapMemory

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoanv: Rework fences
Jason Ekstrand [Wed, 2 Nov 2016 16:11:11 +0000 (09:11 -0700)]
anv: Rework fences

Our previous fence implementation was very simple.  Fences had two states:
signaled and unsignaled.  However, this didn't properly handle all of the
edge-cases that we need to handle.  In order to handle the case where the
client calls vkGetFenceStatus on a fence that has not yet been submitted
via vkQueueSubmit, we need a three-status system.  In order to handle the
case where the client calls vkWaitForFences on fences which have not yet
been submitted, we need more complex logic and a condition variable.  It's
rather annoying but, so long as the client doesn't do that, we should still
hit the fast path and use i915_gem_wait to do all our waiting.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agoanv/wsi: Set the fence to signaled in AcquireNextImageKHR
Jason Ekstrand [Wed, 2 Nov 2016 21:45:37 +0000 (14:45 -0700)]
anv/wsi: Set the fence to signaled in AcquireNextImageKHR

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agoanv/gen8: Stall when needed in Cmd(Set|Reset)Event
Jason Ekstrand [Sat, 8 Oct 2016 06:02:25 +0000 (23:02 -0700)]
anv/gen8: Stall when needed in Cmd(Set|Reset)Event

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agoglsl: record number of components used in each slot for varying packing
Ilia Mirkin [Sat, 5 Nov 2016 13:31:21 +0000 (09:31 -0400)]
glsl: record number of components used in each slot for varying packing

Instead of packing varyings into vec4's, keep track of how many
components each slot uses and create varyings with matching types. This
ensures that we don't end up using more components than the orginal
shader, which is especially important for geometry shader output limits.

This comes up for NVIDIA hw, where the limit is 1024 output components
for a GS, and the hardware complains *loudly* if you even think about
going over.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
7 years agoglsl: fix slot_end calculations and simplify reserved_slots check
Ilia Mirkin [Sat, 5 Nov 2016 01:01:18 +0000 (21:01 -0400)]
glsl: fix slot_end calculations and simplify reserved_slots check

The previous code was confused about whether slot_end was inclusive or
exclusive. Make it so that it is inclusive consistently, and use it for
setting the new location. This also avoids discrepancies in how
num_components is calculated vs the more manual approach taken for the
former reserved_slots check.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
7 years agoswr: correct setting of independentAlphaBlendEnable
Ilia Mirkin [Wed, 9 Nov 2016 19:31:25 +0000 (14:31 -0500)]
swr: correct setting of independentAlphaBlendEnable

This setting is for whether color and alpha have different blend
settings, not for whether blending is enabled on a per-RT basis.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
7 years agoswr: [rasterizer] add a .dir-locals.el to support 4-space indents
Ilia Mirkin [Wed, 9 Nov 2016 17:07:42 +0000 (12:07 -0500)]
swr: [rasterizer] add a .dir-locals.el to support 4-space indents

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
7 years agoswr: set halfz rasterizer setting
Ilia Mirkin [Wed, 9 Nov 2016 06:19:34 +0000 (01:19 -0500)]
swr: set halfz rasterizer setting

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
7 years agoswr: [rasterizer core] allow an OpenGL driver to specify halfz clipping
Ilia Mirkin [Wed, 9 Nov 2016 06:18:05 +0000 (01:18 -0500)]
swr: [rasterizer core] allow an OpenGL driver to specify halfz clipping

With ARB_clip_control, GL may also do 0..1 depth clipping, not just
-1..1. This removes clip's reliance on driver type. DX users will need
to be updated to set the new clipHalfZ flag to get proper clipping
functionality.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
7 years agoswr: fix support for inverted depth scales
Ilia Mirkin [Wed, 9 Nov 2016 06:16:32 +0000 (01:16 -0500)]
swr: fix support for inverted depth scales

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
7 years agoswr: [rasterizer jitter] fix logic op to work with unorm/snorm
Ilia Mirkin [Tue, 8 Nov 2016 00:12:23 +0000 (19:12 -0500)]
swr: [rasterizer jitter] fix logic op to work with unorm/snorm

Most logic op usage is probably going to end up with normalized
textures. Scale the floating point values and convert to integer before
performing the logic operations.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
7 years agovc4: Clamp the shadow comparison value.
Eric Anholt [Mon, 7 Nov 2016 20:25:47 +0000 (12:25 -0800)]
vc4: Clamp the shadow comparison value.

Fixes piglit glsl-fs-shadow2D-clamp-z.

Cc: <mesa-stable@lists.freedesktop.org>
7 years agovc4: Don't pair up TLB scoreboard locking instructions early in QPU sched.
Eric Anholt [Mon, 7 Nov 2016 18:52:32 +0000 (10:52 -0800)]
vc4: Don't pair up TLB scoreboard locking instructions early in QPU sched.

Jonas Pfeil noticed that we were putting passthrough tlb_z writes early in
the shader, despite QIR and QPU scheduling both trying to delay scoreboard
locking for as long as possible.

The problem was that when trying to pair up QPU instructions, at some
point the passthrough tlb_z would be the last one available and it would
get paired, even if the other half would open up other instructions to be
scheduled and we could have paired tlb_z with something later in the
program.  Also, since passthrough z is just a mov, it pairs up really
easily.

The proper fix would probably be to flip the order of scheduling
instructions so we went from bottom to top (also relevant for branch delay
slot scheduling).

However, we can do a quick fix here to just not schedule a TLB lock until
there's nothing but TLB left in the program, at a slight instruction cost
(est .61% cycle count in shader-db) but a major fragment shader
parallelism win.

glmark2 results:
  texture:texture-filter=linear: +1.24481% +/- 0.626117% (n=15)
  bump:bump-render=height: 1.24991% +/- 0.154793% (n=136,133 -- screensaver
    outliers removed)

7 years agovc4: Print a reg pressure estimate in our reg allocation failure dump.
Eric Anholt [Mon, 7 Nov 2016 18:16:45 +0000 (10:16 -0800)]
vc4: Print a reg pressure estimate in our reg allocation failure dump.

7 years agovc4: Don't abort when a shader compile fails.
Eric Anholt [Mon, 7 Nov 2016 17:05:59 +0000 (09:05 -0800)]
vc4: Don't abort when a shader compile fails.

It's much better to just skip the draw call entirely.  Getting this
information out of register allocation will also be useful for
implementing threaded fragment shaders, which will need to retry
non-threaded if RA fails.

Cc: <mesa-stable@lists.freedesktop.org>
7 years agomesa: Fix pixel shader scratch space allocation on Gen9+ platforms.
Kenneth Graunke [Tue, 8 Nov 2016 01:12:54 +0000 (17:12 -0800)]
mesa: Fix pixel shader scratch space allocation on Gen9+ platforms.

We had missed a bit of errata - PS scratch needs to be computed as if
there were 4 subslices per slice, rather than 3.

                          Skylake      Broxton        Kabylake
                      GT1 GT2 GT3 GT4  2x6 3x6  GT1 GT1.5 GT2 GT3 GT4
Actual Slices          1   1   2   3    1   1    1    1    1   2   3
Total Subslices        3   3   6   9    2   3    2    3    3   6   9
Subsl. for PS Scratch  4   4   8   12   4   4    4    4    4   8   12

Note that Skylake GT1-3 already worked because we allocated 64 * 9
(trying to use a value that would work on GT4, with 9 subslices),
and the actual required values were 64 * 4 or 64 * 8.  However, all
others (Skylake GT4, Broxton, and Kabylake GT1-4) underallocated,
which can lead to scratch writes trashing random process memory,
and rendering corruption or GPU hangs.

Fixes GPU hangs and rendering corruption on Skylake GT4 in shaders that
spill.  Particularly, dEQP-GLES31.functional.ubo.all_per_block_buffers.*
now runs successfully with no hangs and renders correctly.  This may
fix problems on Broxton and Kabylake as well.

Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
7 years agomesa/extensions: expose OES_vertex_half_float for ES2
Kevin Strasser [Mon, 10 Oct 2016 21:29:58 +0000 (14:29 -0700)]
mesa/extensions: expose OES_vertex_half_float for ES2

Half float support already exists for desktop GL. Reuse the
ARB_half_float_vertex enable bit and account for the different enum to
enable the extension for ES2.

Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoRevert "egl: remove explicit config_id management from dri2_add_config()"
Emil Velikov [Wed, 9 Nov 2016 21:45:07 +0000 (21:45 +0000)]
Revert "egl: remove explicit config_id management from dri2_add_config()"

This reverts commit 3652d1d5942a857f225700d67ce2c900396982f2.

Self nack/reject on this one. The base.ConfigID is overwritten
immediately after we store the current value, thus one memcpy [further
down] the wrong value will be copied.

7 years agoutil: add MSVC HAS_TRIVIAL_DESTRUCTOR implementation
Brian Paul [Wed, 9 Nov 2016 21:48:45 +0000 (14:48 -0700)]
util: add MSVC HAS_TRIVIAL_DESTRUCTOR implementation

Based on a patch by George Kyriazis but changed to test for
_MSC_VER >= 1800 (Visual Studio 2015).

This fixes the failed CANARY assertion in src/util/ralloc.c:get_header()
on Windows.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98595
Tested-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Brian Paul <brianp@vmware.com>
7 years agoradv: Suffix the radeon_icd file with the host CPU
Emil Velikov [Wed, 9 Nov 2016 18:11:27 +0000 (18:11 +0000)]
radv: Suffix the radeon_icd file with the host CPU

Port of the anv commit d96345de989 ("anv: Suffix the intel_icd file with
the host CPU").

v2: s/intel_icd/radeon_icd/ in commit summary (Gražvydas)

Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com> (IRC)
7 years agoradv: use correct .specVersion for extensions
Emil Velikov [Wed, 9 Nov 2016 18:10:47 +0000 (18:10 +0000)]
radv: use correct .specVersion for extensions

Analogous to previous commit.

Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com> (IRC)
7 years agoanv: use correct .specVersion for extensions
Emil Velikov [Wed, 9 Nov 2016 18:10:46 +0000 (18:10 +0000)]
anv: use correct .specVersion for extensions

Vulkan has introduced the consept of .specVersion which can be used to
attribute changes of the said extension.

The current loader does not check the value, thus it have gone unnoticed
that the driver exposes an old version of the following extensions:

VK_KHR_xcb_surface        (Rev 6)
VK_KHR_xlib_surface       (Rev 6)
VK_KHR_wayland_surface    (Rev 5)
- Updated the surface create function to take a pCreateInfo structure

VK_KHR_swapchain          (Rev 68)
- Moved the "validity" include for vkAcquireNextImage to be in its proper
  place, after the prototype and list of parameters.
...

According to the documentation:

  * pname:specVersion is the version of this extension.
    It is an integer, incremented with backward compatible changes.

Based on the history of vk.xml the above (latest) revision has been
available since Vulkan 1.0 so even if they were any backwards
incompatible change(s) [as hinted by the revision log] those should be
safe.

Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoamd/addrlib: limit fastcall/regparm to GCC i386
Emil Velikov [Wed, 2 Nov 2016 15:32:22 +0000 (15:32 +0000)]
amd/addrlib: limit fastcall/regparm to GCC i386

The use of regparm causes an error on arm/arm64 builds with clang.
fastcall is allowed, but still throws a warning. As both options only
have effect on 32-bit x86 builds, limit them to that case.

v2: keep the __i386__ within GCC (Nicolai)

Cc: 13.0 <mesa-stable@lists.freedesktop.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Nicolai Hähnle <nhaehnle@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Rob Herring <robh@kernel.org>
7 years agoconfigure.ac: honour LLVM_LIBDIR when linking against LLVM
Emil Velikov [Mon, 24 Oct 2016 17:11:33 +0000 (18:11 +0100)]
configure.ac: honour LLVM_LIBDIR when linking against LLVM

Currently if one uses a non-default prefix, the path won't get
propagated and we'll fail at link-time.

A very quick and easy example is to install to /usr/local.
At this point, llvm-config will be picked even without the
--with-llvm-prefix, but regardless of the latter linking will fail.

Currently people can workaround that via LD_LIBRARY_PATH.

Cc: "12.0 13.0" <mesa-stable@lists.freedesktop.org>
Cc: Tom Stellard <thomas.stellard@amd.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoegl: remove explicit config_id management from dri2_add_config()
Emil Velikov [Fri, 30 Sep 2016 12:45:55 +0000 (13:45 +0100)]
egl: remove explicit config_id management from dri2_add_config()

Currently we only saved the id to memcpy the whole _EGLConfig to write
back the exact same id value.

Remove the unneeded and confusing/misleading code.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agolinker: Accurately track gl_uniform_block::stageref
Ian Romanick [Mon, 7 Nov 2016 23:59:35 +0000 (15:59 -0800)]
linker: Accurately track gl_uniform_block::stageref

As the linked per-stage shaders are processed, mark any block that has a
field that is accessed as referenced.  When combining all the linked
shaders, combine the per-stage stageref masks.

This fixes a number of GLES CTS tests:

    ES31-CTS.core.geometry_shader.program_resource.program_resource
    ES32-CTS.core.geometry_shader.program_resource.program_resource
    ESEXT-CTS.geometry_shader.program_resource.program_resource
    piglit.gl45-cts.geometry_shader.program_resource.program_resource

However, it makes quite a few more fail:

    ES31-CTS.functional.program_interface_query.buffer_variable.random.6
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.compute.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.separable_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment_only_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment_only_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment_only_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment_only_fragment.unnamed_block.float
    ES31-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.random.6
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.compute.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.separable_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment_only_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment_only_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_geo_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment_only_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment_only_fragment.unnamed_block.float
    ES32-CTS.functional.program_interface_query.buffer_variable.referenced_by.vertex_tess_geo_fragment.unnamed_block.float

I have diagnosed the failures, but I'm not sure whether we or the
tests are wrong.  After optimizations are applied, all of the tests
are of the form:

    buffer X {
        float f;
    } x;

    void main()
    {
        x.f = x.f;
    }

The test then queries that x is referenced by that shader stage.  We
eliminate the assignment of x.f to itself, and that removes the last
reference to x.  We report that x is not referenced, and the test fails.
I do not know whether or not we are allowed to eliminate that assignment
of x.f to itself.

After discussions with the OpenGL ES group in Khronos, we believe that
Mesa's behavior is correct.  I will provide patches to the CTS tests
to Khronos.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agolinker: Slight code rearrange to prevent duplication in the next commit
Ian Romanick [Mon, 7 Nov 2016 23:54:46 +0000 (15:54 -0800)]
linker: Slight code rearrange to prevent duplication in the next commit

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agolinker: Trivial coding standards fixes
Ian Romanick [Fri, 4 Nov 2016 19:36:08 +0000 (12:36 -0700)]
linker: Trivial coding standards fixes

v2: Revert the unreachable to assert in
parcel_out_uniform_storage::visit_field.  Suggested by Ilia.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoglsl: Add some comments to methods of ir_variable_refcount_visitor
Ian Romanick [Mon, 7 Nov 2016 22:24:39 +0000 (14:24 -0800)]
glsl: Add some comments to methods of ir_variable_refcount_visitor

It was not obvious from the just the .h file what the hash table
contained.  It was also not obvious that get_variable_entry would create
a new entry in the hash table.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agollvmpipe: Fix build after removal of deprecated attribute API v2
Aaron Watry [Tue, 8 Nov 2016 03:55:14 +0000 (21:55 -0600)]
llvmpipe: Fix build after removal of deprecated attribute API v2

Applies on top of v3 of Tom's gallivm change.

v2:
  - Tom Stellard: Use enums instread of strings.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Signed-off-by: Aaron Watry <awatry@gmail.com>
CC: Tom Stellard <thomas.stellard@amd.com>
CC: Jan Vesely <jan.vesely@rutgers.edu>
7 years agogallivm: Fix build after removal of deprecated attribute API v3
Tom Stellard [Mon, 7 Nov 2016 18:35:09 +0000 (18:35 +0000)]
gallivm: Fix build after removal of deprecated attribute API v3

v2:
  Fix adding parameter attributes with LLVM < 4.0.

v3:
  Fix typo.
  Fix parameter index.
  Add a gallivm enum for function attributes.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradv: fix GetFenceStatus for signaled fences
Dave Airlie [Wed, 9 Nov 2016 01:21:30 +0000 (01:21 +0000)]
radv: fix GetFenceStatus for signaled fences

if a fence is created pre-signaled we should return that
in GetFenceStatus even if it hasn't been submitted.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Gustaw Smolarczyk <wielkiegie@gmail.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: enable conditional discard optimisation on radv.
Dave Airlie [Wed, 2 Nov 2016 01:23:11 +0000 (01:23 +0000)]
radv: enable conditional discard optimisation on radv.

This fixes a bunch of GPU hangs introduced in some CTS
tests like
dEQP-VK.memory.pipeline_barrier.host_write_uniform_buffer.65536

It works around an issue seen in the LLVM backend, but
also makes the radv code work more like the radeonsi stack.

Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agonir: add conditional discard optimisation (v4)
Dave Airlie [Wed, 2 Nov 2016 01:22:07 +0000 (01:22 +0000)]
nir: add conditional discard optimisation (v4)

This is ported from GLSL and converts

if (cond)
discard;

into
discard_if(cond);

This removes a block, but also is needed by radv
to workaround a bug in the LLVM backend.

v2: handle if (a) discard_if(b) (nha)
cleanup and drop pointless loop (Matt)
make sure there are no dependent phis (Eric)
v3: make sure only one instruction in the then block.
v4: remove sneaky tabs, add cursor init (Eric)

Reviewed-by: Eric Anholt <eric@anholt.net>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoac/nir: add support for discard_if intrinsic (v2)
Dave Airlie [Wed, 2 Nov 2016 01:21:15 +0000 (01:21 +0000)]
ac/nir: add support for discard_if intrinsic (v2)

We are going to start lowering to this in NIR code,
so prepare radv for it.

v2: handle conversion to kilp properly (nha)

Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoanv: Do relocations in userspace before execbuf ioctl
Kristian Høgsberg Kristensen [Tue, 8 Mar 2016 23:31:47 +0000 (15:31 -0800)]
anv: Do relocations in userspace before execbuf ioctl

Since our surface state buffer is shared by all batches, the kernel does a
full stall and sync with the CPU between batches every time we call
execbuf2 because it refuses to do relocations on an active buffer.  Doing
them in userspace and passing the NO_RELOC flag to the kernel allows us to
perform the relocations without stalling.

This improves the performance of Dota 2 by around 30% on a Sky Lake GT2.

v2 (Jason Ekstrand):
 - Better comments (Chris Wilson)
 - Fixed write_reloc for correct canonical form (Chris Wilson)

v3 (Jason Ekstrand):
 - Skip relocations which aren't needed
 - Provide an environment variable to always use the kernel
 - More comments about correctness (Chris Wilson)

v4 (Jason Ekstrand):
 - More comments (Chris Wilson)

v5 (Jason Ekstrand):
 - Rebase on top of moving execbuf2 setup go QueueSubmit

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agoanv: Move relocation handling from EndCommandBuffer to QueueSubmit
Jason Ekstrand [Sun, 6 Nov 2016 02:47:33 +0000 (19:47 -0700)]
anv: Move relocation handling from EndCommandBuffer to QueueSubmit

Ever since the early days of the Vulkan driver, we've been setting up the
lists of relocations at EndCommandBuffer time.  The idea behind this was to
move some of the CPU load out of QueueSubmit which the client is required
to lock around and into command buffer building which could be done in
parallel.  Then QueueSubmit basically just becomes a bunch of execbuf2
calls.

Technically, this works.  However, when you start to do more in QueueSubmit
than just execbuf2, you start to run into problems.  In particular, if a
block pool is resized between EndCommandBuffer and QueueSubmit, the list of
anv_bo's and the execbuf2 object list can get out of sync.  This can cause
problems if, for instance, you wanted to do relocations in userspace.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agoanv/batch: Move last_ss_pool_bo_offset to the command buffer
Jason Ekstrand [Mon, 7 Nov 2016 16:07:43 +0000 (08:07 -0800)]
anv/batch: Move last_ss_pool_bo_offset to the command buffer

The original reason for putting it in the batch_bo was to allow primaries
to share it across secondaries or something like that.  However, the
relocation lists in secondary command buffers are are always left alone and
copied into the primary command buffer's relocation list.  This means that
the offset really applies at the command buffer level and putting it in the
batch_bo doesn't make sense.  This fixes a couple of potential bugs around
re-submission of command buffers that are not likely to be hit but are bugs
none the less.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
7 years agoanv: Add an anv_execbuf helper struct
Jason Ekstrand [Sun, 6 Nov 2016 02:01:44 +0000 (19:01 -0700)]
anv: Add an anv_execbuf helper struct

This commit adds a little helper struct for storing everything we use to
build an execbuf2 call.  Since the add_bo function really has nothing to do
with a command buffer, it makes sense to break it out a bit.  This also
reduces some of the churn in the next commit.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>