mesa.git
7 years agointel/blorp: Internally expose surf_convert_to_uncompressed
Jason Ekstrand [Thu, 10 Aug 2017 17:43:46 +0000 (10:43 -0700)]
intel/blorp: Internally expose surf_convert_to_uncompressed

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoanv/image: Support creating uncompressed views of compressed images
Jason Ekstrand [Tue, 11 Jul 2017 20:17:06 +0000 (13:17 -0700)]
anv/image: Support creating uncompressed views of compressed images

In order to get support everywhere, this gets a bit complicated.  On Sky
Lake and later, everything is fine because HALIGN/VALIGN are specified
in surface elements and are required to be at least 4 so any offsetting
we may need to do falls neatly within the heavy restrictions placed on
the X/Y Offset parameter of RENDER_SURFACE_STATE.  On Broadwell and
earlier, HALIGN/VALIGN are specified in pixels and are hard-coded to
align to exactly the block size of the compressed texture.  This means
that, when reinterpreted as a non-compressed texture, the tile offsets
may be anything and we can't rely on X/Y Offset.

In order to work around this issue, we fall back to linear where we can
trivially offset to whatever element we so choose.  However, since
linear texturing performance is terrible, we create a tiled shadow copy
of the image to use for texturing.  Whenever the user does a layout
transition from anything to SHADER_READ_ONLY_OPTIMAL, we use blorp to
copy the contents of the texture from the linear copy to the tiled
shadow copy.  This assumes that the client will use the image far more
for texturing than as a storage image or render target.

Even though we don't need the shadow copy on Sky Lake, we implement it
this way first to make testing easier.  Due to the hardware restriction
that ASTC must not be linear, ASTC does not work yet.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoanv: Add a new anv_surface_state struct
Jason Ekstrand [Tue, 11 Jul 2017 18:06:49 +0000 (11:06 -0700)]
anv: Add a new anv_surface_state struct

This struct represents a full surface state including the addresses of
the referenced main and auxiliary surfaces (if any).  This makes
relocation setup substantially simpler and allows us to move 100% of the
surface state setup logic into anv_image where it belongs.  Before, we
were manually fishing data out of surface states when emitting
relocations so we knew how to offset aux address.  It's best to keep all
of the surface state emit logic together.  This also gets us closer, at
least cosmetically, to a world of no relocations where addresses are
placed in surface states up-front.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoanv/image: Break surface state fill logic into a helper
Jason Ekstrand [Tue, 11 Jul 2017 17:06:36 +0000 (10:06 -0700)]
anv/image: Break surface state fill logic into a helper

This gives us a single centralized place where we take an image view and
use it to fill out a surface state.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoanv/image: Add support for the VkImageViewUsageCreateInfoKHR struct
Jason Ekstrand [Tue, 11 Jul 2017 16:07:36 +0000 (09:07 -0700)]
anv/image: Add support for the VkImageViewUsageCreateInfoKHR struct

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoanv: Advertise point clipping properties
Samuel Iglesias Gonsálvez [Wed, 17 May 2017 08:02:24 +0000 (10:02 +0200)]
anv: Advertise point clipping properties

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoanv: Add support for tessellation domain origin control
Jason Ekstrand [Wed, 24 May 2017 18:38:06 +0000 (11:38 -0700)]
anv: Add support for tessellation domain origin control

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agospirv: Flip the tessellation winding order
Jason Ekstrand [Fri, 28 Apr 2017 14:12:24 +0000 (07:12 -0700)]
spirv: Flip the tessellation winding order

It's not SPIR-V that's backwards from GLSL, it's Vulkan that's backwards
from GL.  Let's make NIR consistent with the source language and do the
flipping inside the Vulkan driver instead.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoanv/image: Add support for the new depth/stencil layouts
Jason Ekstrand [Fri, 28 Apr 2017 13:10:29 +0000 (06:10 -0700)]
anv/image: Add support for the new depth/stencil layouts

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoclover: Wait for requested operation if blocking flag is set
Jan Vesely [Wed, 2 Aug 2017 21:04:24 +0000 (17:04 -0400)]
clover: Wait for requested operation if blocking flag is set

v2: wait in map_buffer and map_image as well
v3: use event::wait instead of wait (skips fence wait for hard_event)
v4: use wait_signalled()

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Aaron Watry <awatry@gmail.com>
7 years agoclover: Run the associated action before an event is signalled.
Francisco Jerez [Tue, 9 Jun 2015 19:59:43 +0000 (22:59 +0300)]
clover: Run the associated action before an event is signalled.

And define a method for other threads to wait until the action
function associated with an event has been executed to completion.

For hard events, this will mean waiting until the corresponding
command has been submitted to the pipe driver, without necessarily
flushing the pipe_context and waiting for the actual command to be
processed by the GPU (which is what hard_event::wait() already does).

This weaker kind of event wait will allow implementing blocking memory
transfers efficiently.

Acked-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
7 years agoclover: Wrap event::wait_count in a method taking care of the required locking.
Francisco Jerez [Tue, 9 Jun 2015 19:52:25 +0000 (22:52 +0300)]
clover: Wrap event::wait_count in a method taking care of the required locking.

Acked-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
7 years agoanv/entrypoints_gen: Dedent the C code
Jason Ekstrand [Wed, 20 Sep 2017 14:09:08 +0000 (07:09 -0700)]
anv/entrypoints_gen: Dedent the C code

This makes the C code be justified over to the left.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoradv: Don't use a virtual function for getting the buffer virtual address.
Bas Nieuwenhuizen [Sun, 17 Sep 2017 10:15:02 +0000 (12:15 +0200)]
radv: Don't use a virtual function for getting the buffer virtual address.

We are really not going to use a winsys which does not need to store
the va, so might as well store it in a standard field.

Not sure this helps perf much though, as most of the cost is in the
cache miss accessing the bo anyway, which we stil need to do.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agoradv: Only enter the immutable samplers init loop when we have some.
Bas Nieuwenhuizen [Sun, 17 Sep 2017 10:59:24 +0000 (12:59 +0200)]
radv: Only enter the immutable samplers init loop when we have some.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agoradv: Use for_each_bit in the descriptor set flush.
Bas Nieuwenhuizen [Sun, 17 Sep 2017 10:03:03 +0000 (12:03 +0200)]
radv: Use for_each_bit in the descriptor set flush.

Since most games use only a few, iterating through all of them is
a waste. Simplifies the code too.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agoradv: Add VK_KHR_bind_memory2 support.
Bas Nieuwenhuizen [Sun, 17 Sep 2017 11:55:16 +0000 (13:55 +0200)]
radv: Add VK_KHR_bind_memory2 support.

Nothing too exciting, just adding the possibility for a pNext pointer,
and batch binding. Our binding is pretty much trivial.

It also adds VK_IMAGE_CREATE_ALIAS_BIT_KHR, but since we store no
state in radv_image, I don't think we have to do anything there.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agollvmpipe, gallivm: implement lod queries (LODQ opcode)
Roland Scheidegger [Mon, 18 Sep 2017 02:52:26 +0000 (04:52 +0200)]
llvmpipe, gallivm: implement lod queries (LODQ opcode)

This uses all the existing code to calculate lod values for mip linear
filtering. Though we'll have to disable the simplifications (if we know some
parts of the lod calculation won't actually matter for filtering purposes due
to mip clamps etc.). For better or worse, we'll also disable lod calculation
hacks (mostly should make a difference for cube maps) always - the issue with
per-pixel lod being difficult is mostly because we then have different mipmaps
needed for the actual texel fetch, which isn't a problem with lodq.
We still use approximation for the log2 - for that reason I believe the float
part of the lod is only accurate to about 4-5 bits (and one bit less with 1d
textures actually) which is hopefully good enough (though d3d10 technically
requires 6 bits - could use quadratic interpolation instead of linear to get
8 bits or so).
Since lodq requires unclamped lod, we also have to move some sampler key
calculations to texture sampling code - even if we know we're going to access
mipmap 0 we still have to calculate lod and apply lod_bias for lodq.

Passes piglit ARB_texture_query_lod tests (after having fixed the test).

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
7 years agoi965: Fix duplication of DRI images
Louis-Francis Ratté-Boulianne [Thu, 31 Aug 2017 04:20:46 +0000 (00:20 -0400)]
i965: Fix duplication of DRI images

Some DRI image properties weren't properly duplicated in the
new image. Some properties are still missing, but I'm not
certain if there was a good reason to let them out in the first
place.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoradeonsi: set MIP_POINT_PRECLAMP to 0
Nicolai Hähnle [Sun, 17 Sep 2017 16:03:04 +0000 (18:03 +0200)]
radeonsi: set MIP_POINT_PRECLAMP to 0

This fixes a bug with nearest ("point") mip selection when the fractional
part of max_lod is in (0.5,1). In this case, the spec mandates that
we still select the mip level ceil(max_lod) in the clamping case. However,
MIP_POINT_PRECLAMP will clamp before the mip selection, which is wrong.

Supposedly this setting was originally copied from the closed Vulkan
driver, but as far as I can tell, closed Vulkan was actually changed back
recently :)

Fixes dEQP-GLES3.functional.texture.mipmap.2d.max_lod.{nearest,linear}_nearest

Fixes: f7420ef5b464 ("radeonsi: enable some sampler fields to match the closed driver")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
7 years agoradeonsi: fix array textures layer coordinate
Nicolai Hähnle [Sun, 17 Sep 2017 14:00:38 +0000 (16:00 +0200)]
radeonsi: fix array textures layer coordinate

Like for cube map (array) gather, we need to round to nearest on <= VI.

Fixes tests in dEQP-GLES3.functional.shaders.texture_functions.texture.*

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoglsl/linker: fix output variable overlap check
Nicolai Hähnle [Sun, 17 Sep 2017 16:25:39 +0000 (18:25 +0200)]
glsl/linker: fix output variable overlap check

Prevent an overflow caused by too many output variables. To limit the
scope of the issue, write to the assigned array only for the non-ES
fragment shader path, which is the only place where it's needed.

Since the function will bail with an error when output variables with
overlapping components are found, (max # of FS outputs) * 4 is an upper
limit to the space we need.

Found by address sanitizer.

Fixes dEQP-GLES3.functional.attribute_location.bind_aliasing.*

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
7 years agoetnaviv: move sw query defines to etnaviv_query_sw.h
Christian Gmeiner [Tue, 19 Sep 2017 16:16:05 +0000 (18:16 +0200)]
etnaviv: move sw query defines to etnaviv_query_sw.h

Also add new define ETNA_SW_QUERY_BASE.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Wladimir J. van der Laan <laanwj@gmail.com>
7 years agoetnaviv: move sw get_driver_query_info(..)
Christian Gmeiner [Tue, 19 Sep 2017 16:16:04 +0000 (18:16 +0200)]
etnaviv: move sw get_driver_query_info(..)

This change makes etna_get_driver_query_info(..) more generic
and puts the knowledge of supported queries directly besides
the implementation.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Wladimir J. van der Laan <laanwj@gmail.com>
7 years agoanv: Fix descriptors copying
Józef Kucia [Sat, 16 Sep 2017 12:23:43 +0000 (14:23 +0200)]
anv: Fix descriptors copying

Trivial.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoradv: do not update the number of scissors in vkCmdSetScissor()
Samuel Pitoiset [Mon, 18 Sep 2017 09:47:53 +0000 (11:47 +0200)]
radv: do not update the number of scissors in vkCmdSetScissor()

The Vulkan spec (1.0.61) says:

   "The number of scissors used by a pipeline is still specified
    by the scissorCount member of VkPipelinescissorStateCreateInfo."

So, the number of scissors is defined at pipeline creation
time and shouldn't be updated when they are set dynamically.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: do not update the number of viewports in vkCmdSetViewport()
Samuel Pitoiset [Mon, 18 Sep 2017 09:45:55 +0000 (11:45 +0200)]
radv: do not update the number of viewports in vkCmdSetViewport()

The Vulkan spec (1.0.61) says:

   "The number of viewports used by a pipeline is still specified
   by the viewportCount member of VkPipelineViewportStateCreateInfo."

So, the number of viewports is defined at pipeline creation
time and shouldn't be updated when they are set dynamically.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: add some assertions in vkCmdSetScissor()
Samuel Pitoiset [Mon, 18 Sep 2017 09:44:54 +0000 (11:44 +0200)]
radv: add some assertions in vkCmdSetScissor()

To check some valid usage requirements.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: add some assertions in vkCmdSetViewport()
Samuel Pitoiset [Mon, 18 Sep 2017 09:42:53 +0000 (11:42 +0200)]
radv: add some assertions in vkCmdSetViewport()

To check some valid usage requirements.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: inline radv_flush_compute_state() into radv_dispatch()
Samuel Pitoiset [Thu, 14 Sep 2017 12:13:30 +0000 (14:13 +0200)]
radv: inline radv_flush_compute_state() into radv_dispatch()

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: add radv_dispatch() helper
Samuel Pitoiset [Thu, 14 Sep 2017 12:12:00 +0000 (14:12 +0200)]
radv: add radv_dispatch() helper

To share common dispatch compute code.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: add radv_emit_dispatch_packets() helper
Samuel Pitoiset [Thu, 14 Sep 2017 12:07:52 +0000 (14:07 +0200)]
radv: add radv_emit_dispatch_packets() helper

To share common dispatch compute code.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
7 years agoac/surface: handle S8 on gfx9
Dave Airlie [Mon, 18 Sep 2017 03:17:33 +0000 (20:17 -0700)]
ac/surface: handle S8 on gfx9

If we don't have a depth piece, we don't get a correct
swizzle mode and we hit an assert in addrlib.

In case of no depth get the preferrred swizzle mode for
stencil alone.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Cc: "17.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoegl: fix build fallouts from 1d0be5b3fe5
Krzysztof Sobiecki [Tue, 19 Sep 2017 20:20:48 +0000 (21:20 +0100)]
egl: fix build fallouts from 1d0be5b3fe5

Fixes: 1d0be5b3fe5 ("wayland-drm: constify the callbacks struct")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoanv: Advertise support VK_FORMAT_R8_SRGB
Jason Ekstrand [Fri, 30 Jun 2017 01:52:03 +0000 (18:52 -0700)]
anv: Advertise support VK_FORMAT_R8_SRGB

Unreal Engine 4 seems to really like this format for some reason.  We
don't technically have the hardware format but we do have L8_SRGB.  It's
easy enough to fake with that and a swizzle.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agointel/blorp: Support clearing L8_UNORM_SRGB surfaces
Jason Ekstrand [Wed, 2 Aug 2017 22:07:33 +0000 (15:07 -0700)]
intel/blorp: Support clearing L8_UNORM_SRGB surfaces

Vulkan needs to be able to clear any texture you can create.  We want to
add support for VK_FORMAT_R8_SRGB and we need to use L8_UNORM_SRGB to do
that so we need to be able to clear it.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoegl: use switch statements over if/else chain
Emil Velikov [Thu, 7 Sep 2017 16:03:53 +0000 (17:03 +0100)]
egl: use switch statements over if/else chain

Shorter, explicit and consistent with the rest of the co debase.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agoegl: remove unneeded braces around since line if statements
Emil Velikov [Thu, 7 Sep 2017 16:03:51 +0000 (17:03 +0100)]
egl: remove unneeded braces around since line if statements

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agoegl: simplify _eglDebugReport* API
Emil Velikov [Thu, 7 Sep 2017 16:03:50 +0000 (17:03 +0100)]
egl: simplify _eglDebugReport* API

Instead of having three, almost identical but not quite,
_eglDebugReport* functions, simply fold them into one.

While doing so drop the unnecessary arguments 'command' and
'objectLabel'. Former is identical to funcName, while the latter is
already stored (yet unused) in _EGLThreadInfo::CurrentObjectLabel.

Cc: Kyle Brenneman <kbrenneman@nvidia.com>
Cc: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (IRC)
7 years agoegl: use _eglError's 'msg' as an actual message in EGL_KHR_debug
Emil Velikov [Thu, 7 Sep 2017 16:03:52 +0000 (17:03 +0100)]
egl: use _eglError's 'msg' as an actual message in EGL_KHR_debug

Seemingly, the original intent behind _eglError's 'msg' was aimed to
provide a function name.

At some point, people started using it the way EGL_KHR_debug's
callback() message is meant to be used. Aka providing meaningful
information to the developer/user.

Swap the funcName/msg argument order in the _eglDebugReport() call.
The 'funcName' variable is implicitly set, props to the
_eglSetFuncName() call at the start of each public entrypoint.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agoautomake: adjust wayland-drm comment
Emil Velikov [Thu, 7 Sep 2017 16:58:02 +0000 (17:58 +0100)]
automake: adjust wayland-drm comment

Vulkan does not depend on the library or any of the objects
created in the process.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoconfigure.ac: split the wayland client/server confusion
Emil Velikov [Fri, 1 Sep 2017 16:39:36 +0000 (17:39 +0100)]
configure.ac: split the wayland client/server confusion

At the moment wayland-clients, such as the Vulkan drivers were
over-linking against libwayland-server.so.

That went unnoticed, since both client and server code uses the
wl*interface symbols, which are present in both libwayland-client.so and
libwayland-server.so.

I've looked at correcting that, although that's orthogonal to this fix.

Note: wayland-egl does _not_ depend on wayland-client, although it does
need wayland-egl.h. There's no distinct package that provides it (I have
a WIP on the topic) so current solution will do for now.

v2: Rebase with the "...inline wayland_drm_buffer_get" patch removed.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agowayland-drm: constify the callbacks struct
Emil Velikov [Fri, 1 Sep 2017 13:18:50 +0000 (14:18 +0100)]
wayland-drm: constify the callbacks struct

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agowayland-drm: add wl_display/wl_resource forward declarations
Emil Velikov [Fri, 1 Sep 2017 13:17:41 +0000 (14:17 +0100)]
wayland-drm: add wl_display/wl_resource forward declarations

... making the header self-contained.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoconfigure.ac: define WL_HIDE_DEPRECATED at global scale
Emil Velikov [Fri, 1 Sep 2017 10:51:49 +0000 (11:51 +0100)]
configure.ac: define WL_HIDE_DEPRECATED at global scale

Due to GCC feature described in previous commit, the expected
deprecation warnings may be missing.

Set the WL_HIDE_DEPRECATED macro which will omit the deprecated
functionality, resulting in more distinct build issues.

That is safe since the symbols guarded within the macro is static.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agowayland-drm: avoid deprecated use of struct wl_resource
Micah Fedke [Tue, 7 Feb 2017 22:29:53 +0000 (17:29 -0500)]
wayland-drm: avoid deprecated use of struct wl_resource

Wayland v1.2 with commit 1488c96a5db ("Add accessor functions for
wl_resource and deprecate wl_client_add_resource") paves the way towards
making wl_resource opaque.

Namely, new helpers were introduced and the struct was annotated as
deprecated.

Since wayland headers are normally installed in /usr/include, which is
in -isystem, GCC did not generate warnings as documented in the manual.
  "Warnings from system headers are normally suppressed..."

Signed-off-by: Micah Fedke <micah.fedke@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[Emil Velikov: add commit message]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agowayland-drm: remove unused wayland_drm_buffer_get_{format,buffer}
Emil Velikov [Fri, 1 Sep 2017 10:26:11 +0000 (11:26 +0100)]
wayland-drm: remove unused wayland_drm_buffer_get_{format,buffer}

Unused anywhere throughout the codebase. We could start using it,
although that contradicts to an evil plan* of mine.

* Only wayland servers will make use of the static library, providing
actual distinction between server vs client.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agowayland-drm: remove hardcoded enum wl_drm_format
Emil Velikov [Fri, 1 Sep 2017 10:23:28 +0000 (11:23 +0100)]
wayland-drm: remove hardcoded enum wl_drm_format

The exact same copy is generated in the client/server protocol header.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agobroadcom/genxml: Set up enums for VC5 blending, depth, stencil, and prims.
Eric Anholt [Fri, 8 Sep 2017 18:52:36 +0000 (11:52 -0700)]
broadcom/genxml: Set up enums for VC5 blending, depth, stencil, and prims.

These will be used in tables in the Vulkan driver, and give us pretty CLIF
dump output.

7 years agobroadcom/genxml: Add support for enum-typed fields.
Eric Anholt [Fri, 8 Sep 2017 22:31:37 +0000 (15:31 -0700)]
broadcom/genxml: Add support for enum-typed fields.

This basically comes from the intel genxml script.  This will help improve
gdb and CLIF output once we convert fields over.

7 years agointel: automake: add isl_genX_priv.h in the source list
Juan A. Suarez Romero [Tue, 19 Sep 2017 14:49:46 +0000 (16:49 +0200)]
intel: automake: add isl_genX_priv.h in the source list

Fixes:

 CC       isl/isl_format_layout.lo
In file included from
../../../../src/intel/isl/isl_storage_image.c:24:0:
../../../../src/intel/isl/isl_priv.h:170:29: fatal error:
isl_genX_priv.h: No such file or directory
compilation terminated.
Makefile:2936: recipe for target 'isl/isl_storage_image.lo' failed
make[5]: *** [isl/isl_storage_image.lo] Error 1
make[5]: *** Waiting for unfinished jobs....
In file included from ../../../../src/intel/isl/isl.c:36:0:
../../../../src/intel/isl/isl_priv.h:170:29: fatal error:
isl_genX_priv.h: No such file or directory
compilation terminated.
make[5]: *** [isl/isl.lo] Error 1
Makefile:2936: recipe for target 'isl/isl.lo' failed
make[4]: *** [all] Error 2

when running `make distcheck`.

v2: Fix commit title (Emil)

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agovulkan: automake: add vk_android_native_buffer.h in the source list
Juan A. Suarez Romero [Tue, 19 Sep 2017 14:26:56 +0000 (16:26 +0200)]
vulkan: automake: add vk_android_native_buffer.h in the source list

Fixes:

  CCLD     libvulkan_wsi.la
ar: `u' modifier ignored since `D' is the default (see `U')
../../../../src/vulkan/util/vk_enum_to_str.c:26:45: fatal error:
vulkan/vk_android_native_buffer.h: No such file or directory
compilation terminated.
make[5]: *** [util/vk_enum_to_str.lo] Error 1

When running `make distcheck`.

v2: Fix commit title (Emil)

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoglsl: Unify ir_constant::const_elements and ::components
Ian Romanick [Fri, 8 Sep 2017 02:23:51 +0000 (19:23 -0700)]
glsl: Unify ir_constant::const_elements and ::components

There was no reason to treat array types and record types differently.
Unifying them saves a bunch of code and saves a few bytes in every
ir_constant.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
7 years agoglsl: Rename ir_constant::array_elements to ::const_elements
Ian Romanick [Fri, 8 Sep 2017 02:02:48 +0000 (19:02 -0700)]
glsl: Rename ir_constant::array_elements to ::const_elements

The next patch will unify ::array_elements and ::components, so the
name ::array_elements wouldn't be appropriate.  A lot of things use
the names array_elements and components, so grepping for either is
pretty useless.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
7 years agoglsl: Silence unused parameter warnings
Ian Romanick [Fri, 8 Sep 2017 01:40:11 +0000 (18:40 -0700)]
glsl: Silence unused parameter warnings

glsl/ast_type.cpp: In function ‘void merge_bindless_qualifier(YYLTYPE*, _mesa_glsl_parse_state*, const ast_type_qualifier&, const ast_type_qualifier&)’:
glsl/ast_type.cpp:189:35: warning: unused parameter ‘loc’ [-Wunused-parameter]
 merge_bindless_qualifier(YYLTYPE *loc,
                                   ^~~
glsl/ast_type.cpp:191:52: warning: unused parameter ‘qualifier’ [-Wunused-parameter]
                          const ast_type_qualifier &qualifier,
                                                    ^~~~~~~~~
glsl/ast_type.cpp:192:52: warning: unused parameter ‘new_qualifier’ [-Wunused-parameter]
                          const ast_type_qualifier &new_qualifier)
                                                    ^~~~~~~~~~~~~

glsl/ir_constant_expression.cpp: In member function ‘virtual ir_constant* ir_rvalue::constant_expression_value(void*, hash_table*)’:
glsl/ir_constant_expression.cpp:512:44: warning: unused parameter ‘mem_ctx’ [-Wunused-parameter]
 ir_rvalue::constant_expression_value(void *mem_ctx, struct hash_table *)
                                            ^~~~~~~
glsl/ir_constant_expression.cpp: In member function ‘virtual ir_constant* ir_texture::constant_expression_value(void*, hash_table*)’:
glsl/ir_constant_expression.cpp:705:45: warning: unused parameter ‘mem_ctx’ [-Wunused-parameter]
 ir_texture::constant_expression_value(void *mem_ctx, struct hash_table *)
                                             ^~~~~~~
glsl/ir_constant_expression.cpp: In member function ‘virtual ir_constant* ir_assignment::constant_expression_value(void*, hash_table*)’:
glsl/ir_constant_expression.cpp:851:48: warning: unused parameter ‘mem_ctx’ [-Wunused-parameter]
 ir_assignment::constant_expression_value(void *mem_ctx, struct hash_table *)
                                                ^~~~~~~
glsl/ir_constant_expression.cpp: In member function ‘virtual ir_constant* ir_constant::constant_expression_value(void*, hash_table*)’:
glsl/ir_constant_expression.cpp:859:46: warning: unused parameter ‘mem_ctx’ [-Wunused-parameter]
 ir_constant::constant_expression_value(void *mem_ctx, struct hash_table *)
                                              ^~~~~~~

glsl/linker.cpp: In function ‘void link_xfb_stride_layout_qualifiers(gl_context*, gl_shader_program*, gl_linked_shader*, gl_shader**, unsigned int)’:
glsl/linker.cpp:1655:60: warning: unused parameter ‘linked_shader’ [-Wunused-parameter]
                                   struct gl_linked_shader *linked_shader,
                                                            ^~~~~~~~~~~~~
glsl/linker.cpp: In function ‘void link_bindless_layout_qualifiers(gl_shader_program*, gl_program*, gl_shader**, unsigned int)’:
glsl/linker.cpp:1693:52: warning: unused parameter ‘gl_prog’ [-Wunused-parameter]
                                 struct gl_program *gl_prog,
                                                    ^~~~~~~

glsl/lower_distance.cpp: In member function ‘virtual void {anonymous}::lower_distance_visitor_counter::handle_rvalue(ir_rvalue**)’:
glsl/lower_distance.cpp:652:59: warning: unused parameter ‘rv’ [-Wunused-parameter]
 lower_distance_visitor_counter::handle_rvalue(ir_rvalue **rv)
                                                           ^~

glsl/opt_array_splitting.cpp: In member function ‘virtual ir_visitor_status {anonymous}::ir_array_reference_visitor::visit_leave(ir_assignment*)’:
glsl/opt_array_splitting.cpp:198:56: warning: unused parameter ‘ir’ [-Wunused-parameter]
 ir_array_reference_visitor::visit_leave(ir_assignment *ir)
                                                        ^~

glsl/glsl_parser_extras.cpp: In function ‘void assign_subroutine_indexes(gl_shader*, _mesa_glsl_parse_state*)’:
glsl/glsl_parser_extras.cpp:1869:45: warning: unused parameter ‘sh’ [-Wunused-parameter]
 assign_subroutine_indexes(struct gl_shader *sh,
                                             ^~

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
7 years agoglsl: buffer variables can be readonly and writeonly
Juan A. Suarez Romero [Thu, 14 Sep 2017 16:21:24 +0000 (16:21 +0000)]
glsl: buffer variables can be readonly and writeonly

In GLSL ES 3.10 session 4.9 [Memory Access Qualifiers], it has the
following description:

"A variable could be qualified as both readonly and writeonly,
disallowing both read and write, but still be passed to
imageSize() to have the size queried.".

This is for image variable, but not for buffer variables.

According to https://github.com/KhronosGroup/OpenGL-API/issues/7 Khronos
intent is to allow both readonly and writeonly in buffer variables, and
as such it will update the GLSL specification.

This commit address this issue, and fixes:

KHR-GL{43,44,45}.shader_storage_buffer_object.basic-readonly-writeonly
KHR-GLES31.core.shader_storage_buffer_object.basic-readonly-writeonly

v2: set correctly fields[i] memory flags (Samuel Pitoiset).

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agoRevert "i965: Reset miptree aux state on update_image_buffer"
Jason Ekstrand [Tue, 19 Sep 2017 13:55:32 +0000 (06:55 -0700)]
Revert "i965: Reset miptree aux state on update_image_buffer"

This reverts commit e97f4b748094466567c7f3bad1a02ecee13db9c8.

7 years agoegl/android: Use per surface out fence
Zhongmin Wu [Fri, 15 Sep 2017 17:32:43 +0000 (18:32 +0100)]
egl/android: Use per surface out fence

Use the plumbing introduced with previous patch to interact with the
Android framework.

Namely: currently we use an invalid fd of -1 for our calls to
ANativeWindow::{queue,cancel}Buffer.

At the same time applications (like flatland) may rely on it being
a valid one. Thus as they attempt to query the timestamp of the fence,
they get unexpected results/behaviour.

In the case of flatland - the benchmark hang inside getSignalTime().

Make use of the out fence and pass the correct fd to Android.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101655
Signed-off-by: Zhongmin Wu <zhongmin.wu@intel.com>
Signed-off-by: Yogesh Marathe <yogesh.marathe@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
[Emil Velikov: split from larger patch]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoegl: Allow creation of per surface out fence
Zhongmin Wu [Fri, 15 Sep 2017 17:32:42 +0000 (18:32 +0100)]
egl: Allow creation of per surface out fence

Add plumbing to allow creation of per display surface out fence.

This can be used to implement explicit sync. One user of which is
Android - which will be addressed with next commit.

Signed-off-by: Zhongmin Wu <zhongmin.wu@intel.com>
Signed-off-by: Yogesh Marathe <yogesh.marathe@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
[Emil Velikov: reorder so there's no intermetent regressions, split]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoegl: Wrap dri3 surface primitive around dri2 egl surface
Yogesh Marathe [Fri, 15 Sep 2017 17:32:41 +0000 (18:32 +0100)]
egl: Wrap dri3 surface primitive around dri2 egl surface

Originally dri3 egl surface was wrapped around _EGLSurface.

With next commit we'll add additional attributes, which will be checked
from generic code. Thus in order to access that we need to use
dri2_egl_surface.

The name of the latter is a misnomer - it should really be dri or
dri_common...

Signed-off-by: Yogesh Marathe <yogesh.marathe@intel.com>
[Emil Velikov: commit message, squash the patches appropriately, add
relevant _eglInitSurface hunk to prevent build breakage]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoScons: Add LLVM 5.0 support
Alexandru-Liviu Prodea [Fri, 15 Sep 2017 07:26:33 +0000 (07:26 +0000)]
Scons: Add LLVM 5.0 support

1 new required library - LLVMBinaryFormat

Cc: "17.2" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org=/show_bug.cgi?id=3D102318
Signed-off-by: Alexandru-Liviu Prodea <liviuprodea@yahoo.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoradv: replace conditional compilation with MAYBE_UNUSED
Eric Engestrom [Mon, 18 Sep 2017 15:35:11 +0000 (16:35 +0100)]
radv: replace conditional compilation with MAYBE_UNUSED

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agoglsl: replace conditional compilation with MAYBE_UNUSED
Eric Engestrom [Mon, 18 Sep 2017 15:35:28 +0000 (16:35 +0100)]
glsl: replace conditional compilation with MAYBE_UNUSED

Suggested-by: Nicolai Hähnle <nhaehnle@gmail.com>
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agobroadcom/vc4: Fix use-after-free when deleting a program.
Eric Anholt [Tue, 19 Sep 2017 00:47:44 +0000 (17:47 -0700)]
broadcom/vc4: Fix use-after-free when deleting a program.

By leaving the compiled shader in the context's stage state, the next
compile of a new FS would look in the old compiled FS for figuring out
whether to set various dirty flags for the VS compile.  Clear out the
pointer when deleting the program, and make sure that we always mark the
state as dirty if the previous program had been lost.  Fixes valgrind
warnings on glsl-max-varyings.

Fixes: 2350569a78c6 ("vc4: Avoid VS shader recompiles by keeping a set of FS inputs seen so far.")
7 years agoi965: Fix batch map failure check in INTEL_DEBUG=bat handling.
Kenneth Graunke [Tue, 19 Sep 2017 01:50:06 +0000 (18:50 -0700)]
i965: Fix batch map failure check in INTEL_DEBUG=bat handling.

I originally wrote the code to call the maps 'batch' and 'state',
until I remembered that 'batch' is the intel_batchbuffer struct pointer.
The NULL check was still using the wrong variable.

Caught by Coverity.

CID: 1418109

7 years agobroadcom/vc4: Fix crashes since the gallium blitter reworks.
Eric Anholt [Mon, 18 Sep 2017 19:58:05 +0000 (12:58 -0700)]
broadcom/vc4: Fix crashes since the gallium blitter reworks.

Even if we're not clearing color, the blitter has started dereferencing
the color value.

7 years agobroadcom/vc4: Fix use-after-free trying to mix a quad and tile clear.
Eric Anholt [Mon, 18 Sep 2017 22:17:31 +0000 (15:17 -0700)]
broadcom/vc4: Fix use-after-free trying to mix a quad and tile clear.

The blitter will bind just the depth buffer, which flushes the current job
if we had both a color and depth/stencil.  If the clear was doing partial
depth/stencil (quad-based) and color (tile-based), we'd go on to try to
set up the rest of the tile clear in the now flushed job.

Instead, move the partial clear up before we start setting up the job for
the current FBO state, and re-fetch the job if we're continuing on to a
tile-based clear.  Fixes valgrind failures in fbo-depthtex.

Fixes: 9421a6065c4e ("vc4: Fix fallback to quad clears of depth in GLX.")
7 years agobroadcom/vc4: Fix use-after-free for flushing when writing to a texture.
Eric Anholt [Mon, 18 Sep 2017 21:52:32 +0000 (14:52 -0700)]
broadcom/vc4: Fix use-after-free for flushing when writing to a texture.

I was trying to continue the hash table loop, not the inner loop.  This
tended to work out, because we would have *just* freed the job struct.
Fixes some valgrind failures in fbo-depthtex.

Fixes: f597ac396640 ("vc4: Implement job shuffling")
7 years agottn: Fix out-of-bounds accesses since the always-2D-constants change.
Eric Anholt [Thu, 7 Sep 2017 17:17:02 +0000 (10:17 -0700)]
ttn: Fix out-of-bounds accesses since the always-2D-constants change.

Only one of the three checks for dim was updated, so we would try to set a
UBO buffer index source value on a nir_load_uniform, and wouldn't actually
declare non-UBO uniforms.

Fixes: 37dd8e8dee1d ("gallium: all drivers should accept two-dimensional constant buffer indexing")
Tested-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoanv/android: Disable surface and swapchain extensions (v2)
Chad Versace [Fri, 1 Sep 2017 22:54:38 +0000 (15:54 -0700)]
anv/android: Disable surface and swapchain extensions (v2)

Android's Vulkan loader implements VK_KHR_surface and VK_KHR_swapchain,
and applications cannot access the driver's implementation. Moreoever,
if the driver exposes the those extension strings, then tests
dEQP-VK.api.info.instance.extensions and dEQP-VK.api.info.device fail
due to the duplicated strings.

v2: Replace !ANDROID with ANV_HAS_SURFACE. (for jekstrand)

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Tested-by: Tapani Pälli <tapani.palli@intel.com>
7 years agoanv: Feed vk_android_native_buffer.xml to generators (v2)
Chad Versace [Tue, 22 Aug 2017 23:26:03 +0000 (16:26 -0700)]
anv: Feed vk_android_native_buffer.xml to generators (v2)

Feed the XML to anv_extensions.py and anv_entrypoints_gen.py.
Do it on all platforms, not just Android. Tested on Android and Fedora.

We always parse the Android XML, regardless of target platform, to
help reduce the chance that people working on non-Android break the
Android build.

v2:
  - Squash in Tapani's changes to Android.*.mk.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com> (v1)
7 years agoanv: Teach generator scripts how to parse mutliple XML files
Chad Versace [Tue, 22 Aug 2017 23:23:26 +0000 (16:23 -0700)]
anv: Teach generator scripts how to parse mutliple XML files

The taught scripts are anv_extensions.py and anv_entrypoints_gen.py.  To
give a script multiple XML files, call it like so:

    anv_extensions.py --xml a.xml --xml b.xml --xml c.xml ...

The scripts parse the XML files in the given order.

This will allow us to feed the scripts XML files for extensions that are
missing from the official vk.xml, such as VK_ANDROID_native_buffer.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
7 years agovulkan/registry: Feed vk_android_native_buffer.xml to gen_enum_to_str.py
Chad Versace [Tue, 15 Aug 2017 23:48:38 +0000 (16:48 -0700)]
vulkan/registry: Feed vk_android_native_buffer.xml to gen_enum_to_str.py

Tested on Android and Fedora.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
7 years agovulkan/util: Teach gen_enum_to_str.py to parse mutliple XML files
Chad Versace [Tue, 15 Aug 2017 23:34:20 +0000 (16:34 -0700)]
vulkan/util: Teach gen_enum_to_str.py to parse mutliple XML files

To give the script multiple XML files, call it like so:

    gen_enum_to_str.py --xml a.xml --xml b.xml --xml c.xml ...

The script parses the XML files in the given order.

This will allow us to feed the script XML files for extensions that are
missing from the official vk.xml, such as VK_ANDROID_native_buffer.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
7 years agovulkan/registry: Add VK_ANDROID_native_buffer
Chad Versace [Mon, 10 Jul 2017 17:43:08 +0000 (10:43 -0700)]
vulkan/registry: Add VK_ANDROID_native_buffer

The VK_ANDROID_native_buffer extension is missing from the official
vk.xml. This patch defines the extension in a separate, minimal XML
file: vk_android_native_buffer.xml.

I chose to add the extension to a new XML file instead of adding it to
the official vk.xml in order to avoid conflicts each time we sync the
vk.xml from Khronos.

This should be only a temporary solution until Jesse Hall is persuaded
to add it to the official vk.xml.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
7 years agovulkan: Add #ifdef hack to vk_android_native_buffer.h
Chad Versace [Tue, 29 Aug 2017 21:41:24 +0000 (14:41 -0700)]
vulkan: Add #ifdef hack to vk_android_native_buffer.h

This patch consolidates many potential `#ifdef ANDROID` messes
throughout src/vulkan and src/intel/vulkan into a simple, localized
hack. The hack is an `#ifdef ANDROID` in vk_android_native_buffer.h
that, on non-Android platorms, avoids including the Android platform
headers and typedefs any Android-specific types to void*.

This hack doesn't remove *all* the `#ifdef ANDROID`s in upcoming
patches, but it does remove a lot.

I first tried implementing VK_ANDROID_native_buffer without this hack,
but eventually gave up when the yak shaving became too much.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
7 years agovulkan: Import vk_android_native_buffer.h
Chad Versace [Tue, 15 Nov 2016 00:05:40 +0000 (16:05 -0800)]
vulkan: Import vk_android_native_buffer.h

Just as Mesa imports the Khronos Vulkan headers, it should import this
Android-private Vulkan header too. This guarantees that Mesa will
continue to build even when upstream Android breaks header
compatibility.

This header is only for *implementers* of Vulkan, not for consumers of
Vulkan.

Imported from tag 'android-7.1.1_r28' in aosp/frameworks/native.

References: https://android.googlesource.com/platform/frameworks/native/+/android-7.1.1_r28/vulkan/include/vulkan/vk_android_native_buffer.h
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
7 years agoi965: Use prepare_external instead of make_shareable in setTexBuffer2
Jason Ekstrand [Tue, 12 Sep 2017 22:40:19 +0000 (15:40 -0700)]
i965: Use prepare_external instead of make_shareable in setTexBuffer2

The setTexBuffer2 hook from GLX is used to implement glxBindTexImageEXT
which has tighter restrictions than just "it's shared".  In particular,
it says that any rendering to the image while it is bound causes the
contents to become undefined.  This means that we can do whatever aux
tracking we want between glxBindTexImageEXT and glxReleaseTexImageEXT so
long as we always transition from external in Bind and to external in
Release.

The fact that we were using make_shareable before was a problem because
it would resolve away 100% of the aux data and then throw away our
reference to the aux buffer.  If the aux data was shared with some other
application (i.e. if we're using I915_FORMAT_MOD_Y_TILED_CCS) then we
would forget that the aux data even existed for the rest of eternity.
This is fine for the first frame but any subsequent calls to
glxBindTexImageEXT would bind the texture as if it has no aux
whatsoever and no resolves would happen and texturing would happen as if
there is no aux.  This was causing rendering corruption in mutter when
running on top of X11 with modifiers.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
7 years agoi965/tex_image: Reference the renderbuffer miptree in setTexBuffer2
Jason Ekstrand [Tue, 12 Sep 2017 21:26:04 +0000 (14:26 -0700)]
i965/tex_image: Reference the renderbuffer miptree in setTexBuffer2

The old code made a new miptree that referenced the same BO as the
renderbuffer and just trusted in the memory aliasing to work.  There are
only two ways in which the new miptree is liable to differ from the one
in the renderbuffer and neither of them matter:

 1) It may have a different target.  The only targets that we can ever
    see in intelSetTexBuffer2 are GL_TEXTURE_2D and GL_TEXTURE_RECTANGLE
    and the difference between the two doesn't matter as far as the
    miptree is concerned; genX(update_sampler_state) only looks at the
    gl_texture_object and not the miptree when determining whether or
    not to use normalized coordinates.

 2) It may have a very slightly different format.  Again, this doesn't
    matter because we've supported texture views for quite some time so
    we always look at the gl_texture_object format instead of the
    miptree format for hardware setup anyway.

On the other hand, because we were recreating the miptree, we were using
intel_miptree_create_for_bo which doesn't understand modifiers.  We
really want this function to work without doing a resolve so long as you
have modifiers so we need to fix that.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
7 years agoi965: Reset miptree aux state on update_image_buffer
Jason Ekstrand [Tue, 12 Sep 2017 22:24:40 +0000 (15:24 -0700)]
i965: Reset miptree aux state on update_image_buffer

When we get a miptree in through glxBindImageEXT, we don't know the
current aux state so we have to assume the worst-case.  If the image
gets recreated, everything is fine because miptreecreate_for_dri_image
sets it to the default.  However, if our miptree is recycled, then we
may have stale aux_usage and we need to reset to the default otherwise
our aux_state tracking will get messed up.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
7 years agointel/isl: Add a drm_modifier_get_default_aux_state helper
Jason Ekstrand [Tue, 12 Sep 2017 22:20:26 +0000 (15:20 -0700)]
intel/isl: Add a drm_modifier_get_default_aux_state helper

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
7 years agoi965: Warn for GTT fallbacks when mapping the batch/state buffers.
Kenneth Graunke [Sat, 16 Sep 2017 07:24:41 +0000 (00:24 -0700)]
i965: Warn for GTT fallbacks when mapping the batch/state buffers.

This shouldn't really happen in practice, but I hit it a couple of times
when running a driver with a bad memory leak.  We may as well hook up
the warning, because if it ever triggers, we'll know something is wrong.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
7 years agoi965: Plumb brw through to intel_batchbuffer_reset().
Kenneth Graunke [Sat, 16 Sep 2017 07:23:51 +0000 (00:23 -0700)]
i965: Plumb brw through to intel_batchbuffer_reset().

We'll want to pass this to brw_bo_map in a moment.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
7 years agoradeonsi: reallocate if a non-sharable textures is being shared
Marek Olšák [Thu, 14 Sep 2017 13:41:09 +0000 (15:41 +0200)]
radeonsi: reallocate if a non-sharable textures is being shared

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: PIPE_BIND_SHARED should allow inter-process sharing
Marek Olšák [Thu, 14 Sep 2017 13:40:45 +0000 (15:40 +0200)]
radeonsi: PIPE_BIND_SHARED should allow inter-process sharing

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agofreedreno: compile fix
Nicolai Hähnle [Mon, 18 Sep 2017 15:38:41 +0000 (17:38 +0200)]
freedreno: compile fix

Fixes: 3f6b3d9db ("gallium: add PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE")
Reported-by: Jan Vesely <jan.vesely@rutgers.edu>
7 years agoclover: add missing include to compat.h
Jan Vesely [Sun, 17 Sep 2017 02:05:39 +0000 (22:05 -0400)]
clover: add missing include to compat.h

Fixes build issues with llvm-3.6
Fixes: 3115687f9b9830417c408228db2bc679e346bba6 (clover: Fix build after
LLVM r313390)

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Tested-by: Gert Wollny <gw.fossdev@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
7 years agoclover: Query and export half precision support
Jan Vesely [Fri, 1 Sep 2017 21:48:39 +0000 (17:48 -0400)]
clover: Query and export half precision support

v2: PIPE_CAP_HALFS -> PIPE_SHADER_CAP_FP16
    has_halfs -> has_halves

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
7 years agogallium: Add PIPE_SHADER_CAP_FP16
Jan Vesely [Fri, 1 Sep 2017 21:47:55 +0000 (17:47 -0400)]
gallium: Add PIPE_SHADER_CAP_FP16

Denotes native half precision float operations capability
v2: PIPE_CAP_HALFS -> PIPE_SHADER_CAP_FP16
    fix indentation

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoanv: Implement VK_KHR_image_format_list
Jason Ekstrand [Mon, 19 Jun 2017 15:38:48 +0000 (08:38 -0700)]
anv: Implement VK_KHR_image_format_list

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoanv: Implement VK_KHR_bind_memory2
Jason Ekstrand [Tue, 18 Jul 2017 16:02:53 +0000 (09:02 -0700)]
anv: Implement VK_KHR_bind_memory2

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agonvc0: fix compile error
Benedikt Schemmer [Mon, 18 Sep 2017 13:27:26 +0000 (15:27 +0200)]
nvc0: fix compile error

Fixes: 3f6b3d9db ("gallium: add PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE")
Signed-off-by: Benedikt Schemmer <ben@besd.de>
Previously-pointed-out-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: allow out-of-order rasterization in commutative blending cases
Nicolai Hähnle [Mon, 18 Sep 2017 09:24:10 +0000 (11:24 +0200)]
radeonsi: allow out-of-order rasterization in commutative blending cases

We do not enable this by default for additive blending, since it slightly
breaks OpenGL invariance guarantees due to non-determinism.

Still, there may be some applications can benefit from white-listing
via the radeonsi_commutative_blend_add drirc setting without any real
visible artifacts.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
7 years agoradeonsi: add drirc option "radeonsi_assume_no_z_fights"
Nicolai Hähnle [Fri, 8 Sep 2017 13:15:08 +0000 (15:15 +0200)]
radeonsi: add drirc option "radeonsi_assume_no_z_fights"

This option enables a performance optimization where typical non-blending
draws with depth buffer may be rasterized out-of-order (on VI+, multi-SE
chips).

This optimization can lead to incorrect results when an applications
renders multiple objects with the same Z value at the same pixel, so we
will never enable it by default. But there may be applications that could
benefit from white-listing.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
7 years agoradeonsi: enable out-of-order rasterization when possible on VI and GFX9 dGPUs
Nicolai Hähnle [Fri, 8 Sep 2017 10:05:24 +0000 (12:05 +0200)]
radeonsi: enable out-of-order rasterization when possible on VI and GFX9 dGPUs

This does not take commutative blending into account yet.

R600_DEBUG=nooutoforder disables it.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
7 years agogallium/radeon: pass old_(perfect_)enable to set_occlusion_query_state
Nicolai Hähnle [Fri, 8 Sep 2017 09:54:37 +0000 (11:54 +0200)]
gallium/radeon: pass old_(perfect_)enable to set_occlusion_query_state

The callee can derive the current enable state itself.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
7 years agogallium: add PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE
Nicolai Hähnle [Tue, 12 Sep 2017 16:46:46 +0000 (18:46 +0200)]
gallium: add PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE

To be able to properly distinguish between GL_ANY_SAMPLES_PASSED
and GL_ANY_SAMPLES_PASSED_CONSERVATIVE.

This patch goes through all drivers, having them treat the two
query types identically, except:

1. radeon incorrectly enabled conservative mode on
   PIPE_QUERY_OCCLUSION_PREDICATE. We now do it correctly, only
   on PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE.
2. st/mesa uses the new query type.

Fixes dEQP-GLES31.functional.fbo.no_attachments.*

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoamd/common: add workaround for cube map array layer clamping
Nicolai Hähnle [Wed, 13 Sep 2017 13:33:23 +0000 (15:33 +0200)]
amd/common: add workaround for cube map array layer clamping

Fixes dEQP-GLES31.functional.texture.filtering.cube_array.*

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoamd/common: remove has_ds_bpermute argument from ac_build_ddxy
Nicolai Hähnle [Wed, 13 Sep 2017 12:38:17 +0000 (14:38 +0200)]
amd/common: remove has_ds_bpermute argument from ac_build_ddxy

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agoamd/common: add chip_class to ac_llvm_context
Nicolai Hähnle [Wed, 13 Sep 2017 12:36:23 +0000 (14:36 +0200)]
amd/common: add chip_class to ac_llvm_context

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