mesa.git
7 years agoutil: Make CLAMP turn NaN into MIN.
Kenneth Graunke [Thu, 13 Jul 2017 23:22:12 +0000 (16:22 -0700)]
util: Make CLAMP turn NaN into MIN.

The previous implementation of CLAMP() allowed NaN to pass through
unscathed, by failing both comparisons.  NaN isn't exactly a value
between MIN and MAX, which can break the assumptions of many callers.

This patch changes CLAMP to convert NaN to MIN, arbitrarily.  Callers
that need NaN to be handled in a specific manner should probably open
code something, or use a macro specifically designed to do that.

Section 2.3.4.1 of the OpenGL 4.5 spec says:

   "Any representable floating-point value is legal as input to a GL
    command that requires floating-point data. The result of providing a
    value that is not a floating-point number to such a command is
    unspecified, but must not lead to GL interruption or termination.
    In IEEE arithmetic, for example, providing a negative zero or a
    denormalized number to a GL command yields predictable results,
    while providing a NaN or an infinity yields unspecified results."

While CLAMP may apply to more than just GL inputs, it seems reasonable
to follow those rules, and allow MIN as an "unspecified result".

This prevents assertion failures in i965 when running the games
"XCOM: Enemy Unknown" and "XCOM: Enemy Within", which call

   glTexEnv(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT,
            -nan(0x7ffff3));

presumably unintentionally.  i965 clamps the LOD bias to be in range,
and asserts that it's in the proper range when converting to fixed
point.  NaN is not, so it crashed.  We'd like to at least avoid that.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
7 years agonir: Use nir_src_copy instead of direct assignments.
Kenneth Graunke [Tue, 18 Jul 2017 04:08:42 +0000 (21:08 -0700)]
nir: Use nir_src_copy instead of direct assignments.

If the source is an indirect register, there is ralloc'd data.  Copying
with a direct assignment will copy the pointer, but the data will still
belong to the old instruction's memory context.  Since we're lowering
and throwing away instructions, that could free the data by mistake.

Instead, use nir_src_copy, which properly handles this.

This is admittedly not a common case, so I think the bug is real,
but unlikely to be hit.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agoglsl: disable array splitting for AoA
Timothy Arceri [Thu, 25 May 2017 02:29:20 +0000 (12:29 +1000)]
glsl: disable array splitting for AoA

While it produces functioning code the pass creates worse code
for arrays of arrays. See the comment added in this patch for more
detail.

V2: skip splitting of AoA of matrices too.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agonir: fix nir_opt_copy_prop_vars() for arrays of arrays
Timothy Arceri [Fri, 30 Jun 2017 02:03:18 +0000 (12:03 +1000)]
nir: fix nir_opt_copy_prop_vars() for arrays of arrays

Previously we only incremented the guide for a single
dimension/wildcard.

V2: rework logic to avoid code duplication

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: mesa-stable@lists.freedesktop.org
7 years agonir/vars_to_ssa: Handle missing struct members in foreach_deref_node
Jason Ekstrand [Tue, 18 Jul 2017 23:50:39 +0000 (16:50 -0700)]
nir/vars_to_ssa: Handle missing struct members in foreach_deref_node

This can happen if, for instance, you have an array of structs and there
are both direct and wildcard references to the same struct and some
members only have direct or only have indirect.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agoi965/blorp: Use the return value of brw_emit_reloc.
Kenneth Graunke [Sun, 23 Apr 2017 03:00:14 +0000 (20:00 -0700)]
i965/blorp: Use the return value of brw_emit_reloc.

This guarantees that the value written in the batch matches the
value recorded in the relocation entry.

(Chris Wilson wrote an identical patch as well.)

7 years agoi965: Delete dead brw_program_reloc function.
Kenneth Graunke [Tue, 18 Jul 2017 06:57:04 +0000 (23:57 -0700)]
i965: Delete dead brw_program_reloc function.

Rafael eliminated the last use of brw_program_reloc recently.

7 years agoi965: Convert WM_STATE to genxml on gen4-5.
Rafael Antognolli [Wed, 21 Jun 2017 18:13:48 +0000 (11:13 -0700)]
i965: Convert WM_STATE to genxml on gen4-5.

The code doesn't get exactly a lot simpler but at least it is in a single
place, and we delete more than we add.

Another good point is that you get rid of struct brw_wm_unit_state
which was a third mechanism for encoding GEN state. We used to have
GENXML, manual packing and these bitfield structs. Now we're down to
just GENXML and some manual packing. (Khristian)

Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965: Convert CLIP_STATE to genxml.
Rafael Antognolli [Fri, 14 Jul 2017 18:02:57 +0000 (11:02 -0700)]
i965: Convert CLIP_STATE to genxml.

Add the code into its own function and atom, since almost nothing is
shared with GEN >= 6.

v2: Split GEN <=5 and GEN >= 6 into separate functions (Ken).
v3: Minor tidying by Ken.

Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoegl/wayland: Use linux-dmabuf interface for buffers
Daniel Stone [Fri, 16 Jun 2017 17:01:23 +0000 (18:01 +0100)]
egl/wayland: Use linux-dmabuf interface for buffers

When available, use the zwp_linux_dambuf_v1 interface to create buffers,
which allows multiple planes and buffer modifiers to be used.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoegl/wayland: Remove duplicate wl_buffer creation code
Daniel Stone [Fri, 16 Jun 2017 16:37:19 +0000 (17:37 +0100)]
egl/wayland: Remove duplicate wl_buffer creation code

Now create_wl_buffer is generic enough, we can use it for the
EGL_WL_create_wayland_buffer_from_image extension.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoegl/wayland: Remove more surface specifics from create_wl_buffer
Daniel Stone [Fri, 16 Jun 2017 16:33:56 +0000 (17:33 +0100)]
egl/wayland: Remove more surface specifics from create_wl_buffer

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoegl/wayland: Make create_wl_buffer more generic
Daniel Stone [Fri, 16 Jun 2017 16:29:42 +0000 (17:29 +0100)]
egl/wayland: Make create_wl_buffer more generic

Remove surface-specific code from create_wl_buffer, so it's now just a
generic translation from DRIimage to wl_buffer.

Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agogbm: Remove is_planar_format dead code
Daniel Stone [Fri, 16 Jun 2017 13:28:42 +0000 (14:28 +0100)]
gbm: Remove is_planar_format dead code

This was only used in create_dumb() to blacklist planar formats.
However, the start of the function already whitelists ARGB8888 (cursor)
and XRGB8888 (scanout), and nothing else. So this entire function can be
removed.

Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agogbm: Check harder for supported formats
Daniel Stone [Fri, 16 Jun 2017 13:19:40 +0000 (14:19 +0100)]
gbm: Check harder for supported formats

Luckily no-one really used the is_format_supported() call, because it
only supported three formats.

Also, since buffers with alpha can be displayed on planes, stop banning
them from use.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agogbm: Pull out FourCC <-> DRIimage format table
Daniel Stone [Fri, 16 Jun 2017 13:11:16 +0000 (14:11 +0100)]
gbm: Pull out FourCC <-> DRIimage format table

Rather than duplicated (yet asymmetric) open-coded tables, pull them out
to a common structure.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agogbm: Axe buffer import format conversion table
Daniel Stone [Fri, 16 Jun 2017 09:28:03 +0000 (10:28 +0100)]
gbm: Axe buffer import format conversion table

Wayland buffers coming from wl_drm use the WL_DRM_FORMAT_* enums, which
are identical to GBM_FORMAT_*. Similarly, FD imports do not need to
convert between GBM and DRI FourCC, since they are (almost) completely
compatible.

This widens the formats accepted by gbm_bo_import() when importing
wl_buffers; previously, only XRGB8888, ARGB8888, RGB565 and YUYV were
supported.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoi965/gen4: Set tile offsets to zero after depth rebase
Topi Pohjolainen [Mon, 5 Jun 2017 10:00:49 +0000 (13:00 +0300)]
i965/gen4: Set tile offsets to zero after depth rebase

Current logic calls intel_renderbuffer_set_draw_offset() which in
turn tries to calculate x and y offset against layer/level settings
that are against the original miptree actually having sufficient
levels/layers. This returns correctly x=0 y=0 regardless of the given
layer/level only because one calls intel_miptree_get_image_offset()
which goes and consults miptree offset table which in turn luckily
contains entries for max-mipmap levels, all initialised to zero even
in case of non-mipmapped.

This patch stops consulting the table and simply sets the draw
offsets to zero that are compatible with the single slice miptree
backing the renderbuffer.
This prepares for ISL based miptrees that calculate offsets
on-demand and do not tolerate levels beyond what the miptree has.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965: Refactor check for separate stencil
Topi Pohjolainen [Mon, 29 May 2017 12:17:48 +0000 (15:17 +0300)]
i965: Refactor check for separate stencil

v2 (Jason): s/needs_stencil/needs_separate_stencil/

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agointel/blorp/gen4: Drop cube map flag for single face copy
Topi Pohjolainen [Fri, 7 Jul 2017 08:33:12 +0000 (11:33 +0300)]
intel/blorp/gen4: Drop cube map flag for single face copy

This will falsely trigger an assert on number of layers once
isl is used for 3D layouts of Gen4 cube maps.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/wm: Use level offsets directly
Topi Pohjolainen [Wed, 28 Jun 2017 06:22:14 +0000 (09:22 +0300)]
i965/wm: Use level offsets directly

dropping dependency to slice table.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965: Use offset helper in intel_readpixels_tiled_memcpy()
Topi Pohjolainen [Wed, 28 Jun 2017 06:14:02 +0000 (09:14 +0300)]
i965: Use offset helper in intel_readpixels_tiled_memcpy()

providing support for isl based.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/miptree: Pass flags instead of explicit tiling to surface creator
Topi Pohjolainen [Mon, 3 Jul 2017 06:57:00 +0000 (09:57 +0300)]
i965/miptree: Pass flags instead of explicit tiling to surface creator

allowing one to use isl tiling filter.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/miptree: Add pitch override for imported buffer objects
Topi Pohjolainen [Thu, 29 Jun 2017 14:03:01 +0000 (17:03 +0300)]
i965/miptree: Add pitch override for imported buffer objects

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/miptree: Stop setting total_width/height for existing bo
Topi Pohjolainen [Tue, 27 Jun 2017 18:52:19 +0000 (21:52 +0300)]
i965/miptree: Stop setting total_width/height for existing bo

Now that image surface vertical slice calculator doesn't depend
on total_height, total dimensions are only needed when new buffer
objects are created. Therefore one can safely ignore them when
miptrees are created for already exisiting buffer objects.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/wm: Use isl for filling tex image parameters
Topi Pohjolainen [Tue, 27 Jun 2017 19:39:32 +0000 (22:39 +0300)]
i965/wm: Use isl for filling tex image parameters

This helps to drop dependency to miptree::total_height which is
used in brw_miptree_get_vertical_slice_pitch().

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agointel/isl: Take 3D surfaces into account in image params
Topi Pohjolainen [Tue, 18 Jul 2017 05:53:16 +0000 (08:53 +0300)]
intel/isl: Take 3D surfaces into account in image params

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/miptree: Check for miptree_create() failures
Topi Pohjolainen [Tue, 20 Jun 2017 14:36:46 +0000 (17:36 +0300)]
i965/miptree: Check for miptree_create() failures

Rest of the function assumes it always succeeds.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/miptree: Do not rely on msaa type to decide if aux is needed
Topi Pohjolainen [Thu, 22 Jun 2017 08:26:05 +0000 (11:26 +0300)]
i965/miptree: Do not rely on msaa type to decide if aux is needed

Once the driver moves to ISL both compressed and uncompressed have
the same type. One needs to tell them apart by other means. This
can be done by checking the existence of mcs_buf.

There is a short period of time within intel_miptree_create()
where mcs_buf doesn't exist yet (between calls to
intel_miptree_create_layout() and intel_miptree_alloc_mcs()).
First compute_msaa_layout() makes the decision if compression is
to be used and sets the msaa_layout type. Then based on the type
one sets aux_usage and finally decides if mcs_buf is needed.

This patch duplicates the logic in compute_msaa_layout() and uses
that to make the decision on aux_usage and mcs_buf allocation.
Most of the original logic in compute_msaa_layout() will be gone
in later patch leaving only one version.

Elsewhere only brw_populate_sampler_prog_key_data() needs to know
if compression is used based on the msaa_type. This is now
replaced with consideration for number of samples and existence
of mcs_buf. All other occurrences consider CMS || UMS which can
be represented using single the type of ISL_MSAA_LAYOUT_ARRAY
without any tweaks.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965: Make irb::mt_layer logical instead of physical
Topi Pohjolainen [Thu, 29 Jun 2017 07:36:58 +0000 (10:36 +0300)]
i965: Make irb::mt_layer logical instead of physical

same as irb::layer_count. In case of copies and blits msaa
surfacas already fall to blorp which natively works with logical
slices.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/tex: Use offset helper instead of accessing table directly
Topi Pohjolainen [Fri, 30 Jun 2017 17:56:01 +0000 (20:56 +0300)]
i965/tex: Use offset helper instead of accessing table directly

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965: Mark read-only args as const in intel_miptree_supports_hiz()
Topi Pohjolainen [Wed, 28 Jun 2017 05:33:14 +0000 (08:33 +0300)]
i965: Mark read-only args as const in intel_miptree_supports_hiz()

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/miptree: Use > 1 instead of > 0 to check for multisampling
Topi Pohjolainen [Wed, 28 Jun 2017 08:40:15 +0000 (11:40 +0300)]
i965/miptree: Use > 1 instead of > 0 to check for multisampling

Checking against zero currently works as single sampling is
represented with zero. Once one moves to isl single sampling
really has sample number of one.

This keeps later patches simpler.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/miptree: Set refcount before failing via _release()
Topi Pohjolainen [Mon, 3 Jul 2017 11:23:35 +0000 (14:23 +0300)]
i965/miptree: Set refcount before failing via _release()

Otherwise one wraps uint to UINT_MAX via -1.

Fixes: 3cf470f2b6c ("i965: Add isl based miptree creator")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agobuild: Add $(top_srcdir)/src/compiler/spirv to AM_CPPFLAGS
Kenneth Graunke [Tue, 18 Jul 2017 18:09:37 +0000 (11:09 -0700)]
build: Add $(top_srcdir)/src/compiler/spirv to AM_CPPFLAGS

Generated C files try to include spirv_info.h.  For in-tree builds,
the header is in the same directory, so it just works.  For out-of-tree
builds, we need to look for it in srcdir rather than builddir.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101831
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoradeonsi: add back the USE_MININUM_PRIORITY flag to the low-prio compiler queue
Marek Olšák [Mon, 17 Jul 2017 20:03:29 +0000 (16:03 -0400)]
radeonsi: add back the USE_MININUM_PRIORITY flag to the low-prio compiler queue

Accidentally removed in 9f320e0a387a1009c5218daf130b3b754a3c2800.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agocompiler/spirv: Add a .gitignore and ignore spirv_info.c
Jason Ekstrand [Tue, 18 Jul 2017 16:49:13 +0000 (09:49 -0700)]
compiler/spirv: Add a .gitignore and ignore spirv_info.c

7 years agoanv: Advertise support for VK_KHR_variable_pointers
Jason Ekstrand [Tue, 16 May 2017 15:35:07 +0000 (08:35 -0700)]
anv: Advertise support for VK_KHR_variable_pointers

We don't support the general version yet because that requires us to
lower shared variables up-front in SPIR-V -> NIR.  This shouldn't be a
whole lot of work but it's not something we support today.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agoanv: Advertise support for VK_KHR_storage_buffer_storage_class
Jason Ekstrand [Thu, 29 Jun 2017 17:26:53 +0000 (10:26 -0700)]
anv: Advertise support for VK_KHR_storage_buffer_storage_class

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agonir/spirv: Add support for SPV_KHR_variable_pointers
Jason Ekstrand [Wed, 28 Jun 2017 07:45:36 +0000 (00:45 -0700)]
nir/spirv: Add support for SPV_KHR_variable_pointers

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agonir/spirv: Add a helper for pushing SSA values
Jason Ekstrand [Wed, 28 Jun 2017 09:50:33 +0000 (02:50 -0700)]
nir/spirv: Add a helper for pushing SSA values

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agonir/spirv: Implement OpPtrAccessChain for buffers
Jason Ekstrand [Wed, 28 Jun 2017 23:31:06 +0000 (16:31 -0700)]
nir/spirv: Implement OpPtrAccessChain for buffers

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agospirv/nir: Add some useful asserts for type decorations
Jason Ekstrand [Wed, 5 Jul 2017 22:30:22 +0000 (15:30 -0700)]
spirv/nir: Add some useful asserts for type decorations

Now that vtn_type has piles of unions, we should assert sanity before
setting fields that may stomp others.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agospirv: Add support for the StorageBuffer storage class
Jason Ekstrand [Tue, 16 May 2017 15:34:50 +0000 (08:34 -0700)]
spirv: Add support for the StorageBuffer storage class

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agospirv: Generate spirv_info.c
Ian Romanick [Mon, 17 Jul 2017 19:31:06 +0000 (12:31 -0700)]
spirv: Generate spirv_info.c

The old table based spirv_*_to_string functions would return NULL for
any values "inside" the table that didn't have entries.  The tables also
needed to be updated by hand each time a new spirv.h was imported.
Generate the file instead.

v2: Make this script work more like src/mesa/main/format_fallback.py.
Suggested by Jason.  Remove SCons supports.  Suggested by Jason and
Emil.  Put all the build work in Makefile.nir.am in lieu of adding a new
Makefile.spirv.am.  Suggested by Emil.  Add support for Android builds
based on code provided by Emil.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agospirv: Import the lastest 1.0.2 JSON from Khronos
Ian Romanick [Sat, 15 Jul 2017 01:39:02 +0000 (18:39 -0700)]
spirv: Import the lastest 1.0.2 JSON from Khronos

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agospirv: Import the latest 1.2 header from Khronos
Jason Ekstrand [Thu, 13 Jul 2017 19:36:59 +0000 (12:36 -0700)]
spirv: Import the latest 1.2 header from Khronos

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agomesa: whitespace fixes in get.c
Brian Paul [Mon, 17 Jul 2017 18:31:57 +0000 (12:31 -0600)]
mesa: whitespace fixes in get.c

Remove trailing whitespace.
Replace tabs with spaces.
Trivial.

7 years agomesa: fix GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT query
Brian Paul [Mon, 17 Jul 2017 18:09:42 +0000 (12:09 -0600)]
mesa: fix GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT query

This query is not allowed in GL core profile 3.3 and later (since
GL_QUADS and GL_QUAD_STRIP are disallowed).  The query was (mistakenly)
supported in GL 3.2.  This fixes the glGet error test accordingly.

Reviewed-by: Neha Bhende<bhenden@vmware.com>
7 years agovulkan/util: fix typo in comment
Eric Engestrom [Tue, 18 Jul 2017 10:06:43 +0000 (11:06 +0100)]
vulkan/util: fix typo in comment

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agomapi: add missing no_error tag to glBlitNamedFramebuffer()
Samuel Pitoiset [Mon, 17 Jul 2017 20:40:49 +0000 (22:40 +0200)]
mapi: add missing no_error tag to glBlitNamedFramebuffer()

Fixes: 6fedb31785 ("mesa: add KHR_no_error support for glBlitNamedFramebuffer()")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
7 years agoradv: Set the RADEON_SURF_OPTIMIZE_FOR_SPACE flag for images
Alex Smith [Mon, 17 Jul 2017 10:14:33 +0000 (11:14 +0100)]
radv: Set the RADEON_SURF_OPTIMIZE_FOR_SPACE flag for images

This looks like a regression from df301237940 ("radv: use
ac_compute_surface"). Before that, the opt4Space addrlib flag was set
to true unless the image has FMASK (ac_compute_surface will similarly
only set that flag for images without FMASK).

This saves multiple gigabytes of VRAM on one of our games, and brings
its VRAM utilisation on RADV in line with AMDGPU-PRO and NVIDIA.

Signed-off-by: Alex Smith <asmith@feralinteractive.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: don't shadow meta_va.
Dave Airlie [Mon, 12 Jun 2017 19:54:08 +0000 (05:54 +1000)]
radv: don't shadow meta_va.

Coverity warned about dead code below, as meta_va was being shadowed.

Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoi965: Delete brw_sf_state.c again
Kenneth Graunke [Tue, 18 Jul 2017 05:42:50 +0000 (22:42 -0700)]
i965: Delete brw_sf_state.c again

"...and stay dead!"

Rafael deleted this file in c2b5a26dc25b9c62954a75465e25294c7fd3851a
(i965: Convert SF_STATE to genxml.) but Marek accidentally brought it
back in commit e7a091936fb6fd578c6ced9baa38b306b638a11b (mesa: replace
ctx->Polygon._FrontBit with a helper function) when resolving conflicts.

It's not actually even compiled, but it's still here trolling people
into thinking it still exists and needs patching.

7 years agoac/nir: rewrite shared variable handling (v2)
Connor Abbott [Mon, 26 Jun 2017 22:50:07 +0000 (15:50 -0700)]
ac/nir: rewrite shared variable handling (v2)

Translate the NIR variables directly to LLVM instead of lowering to a
TGSI-style giant array of vec4's and then back to a variable. This
should fix indirect dereferences, make shared variables more tightly
packed, and make LLVM's alias analysis more precise. This should fix an
upcoming Feral title, which has a compute shader that was failing to
compile because the extra padding made us run out of LDS space.

v2: Combine the previous two patches into one, only use this for shared
variables for now until LLVM becomes smarter.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Tested-by: Alex Smith <asmith@feralinteractive.com>
7 years agoi965: Check if the modifier is supported in select_best_modifier
Jason Ekstrand [Sun, 16 Jul 2017 23:54:44 +0000 (16:54 -0700)]
i965: Check if the modifier is supported in select_best_modifier

Otherwise, if a client gave us a list of modifiers that contained a
modifier we understand but which is not supported on the hardware, we
might return that one and then fail to create the image.

Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoi965: Rework the modifier info map
Jason Ekstrand [Sun, 16 Jul 2017 23:35:22 +0000 (16:35 -0700)]
i965: Rework the modifier info map

This commit splits the mapping in half.  The modifier_infos table now
only contains the modifier and the since_gen field.  The tiling bits
have been moved into a table in tiling_to_modifier as that's the only
place it was ever used.  The modifier_is_supported function now takes a
devinfo and does the since_gen check.

Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoi965/surface_state: Remove the mcs_buf->offset == 0 restriction
Jason Ekstrand [Fri, 14 Jul 2017 22:28:21 +0000 (15:28 -0700)]
i965/surface_state: Remove the mcs_buf->offset == 0 restriction

This assert was removed in b0cc55f29831638069407a4c1a5c809b26902ab6 but
got added back in 1a43d774b613d0b00e26b28cc752d944ce8049aa, probably by
accident.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agointel/isl: Add a row_pitch parameter to surf_get_ccs_surf
Jason Ekstrand [Tue, 13 Jun 2017 20:35:15 +0000 (13:35 -0700)]
intel/isl: Add a row_pitch parameter to surf_get_ccs_surf

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
7 years agoi965/miptree: Use BO_ALLOC_ZEROED for CCS_E buffers
Jason Ekstrand [Thu, 13 Jul 2017 00:14:49 +0000 (17:14 -0700)]
i965/miptree: Use BO_ALLOC_ZEROED for CCS_E buffers

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/screen: Allocate ZEROED BOs for images
Jason Ekstrand [Thu, 13 Jul 2017 00:06:29 +0000 (17:06 -0700)]
i965/screen: Allocate ZEROED BOs for images

Reviewed-by: Chad Versace <chadversary@chromium.org>
7 years agoi965/bufmgr: Add a BO_ALLOC_ZEROED flag
Jason Ekstrand [Wed, 12 Jul 2017 23:48:43 +0000 (16:48 -0700)]
i965/bufmgr: Add a BO_ALLOC_ZEROED flag

Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965/miptree: Replace is_lossless_compressed with mt->aux_usage checks
Jason Ekstrand [Thu, 13 Jul 2017 02:20:22 +0000 (19:20 -0700)]
i965/miptree: Replace is_lossless_compressed with mt->aux_usage checks

Now that we have an actual aux_usage field, we no longer need the
complex logic of is_lossless_compressed in order to figure out if a
miptree is CCS_E compressed.  As a side-effect, there is not longer any
need to overload MSAA_LAYOUT_CMS for CCS_E and we can stop doing so.

Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/miptree: Allocate HiZ up-front
Jason Ekstrand [Wed, 12 Jul 2017 23:29:45 +0000 (16:29 -0700)]
i965/miptree: Allocate HiZ up-front

HiZ, like MCS and CCS_E, can compress more than just clear colors so we
want it turned on whenever the miptree is being used as a depth
attachment.  It's theoretically possible for someone to create a depth
texture, upload data with glTexSubImage2D, and texture from it without
ever binding it as a depth target.  If this happens, we would end up
wasting a bit of space by allocating a HiZ surface we never use.
However, this is rather unlikely out side of test cases, so we're better
off just allocating it up-front.

Reviewed-by: Chad Versace <chadversary@chromium.org>
7 years agoi965/miptree: Add an intel_tiling_supports_hiz helper
Jason Ekstrand [Mon, 17 Jul 2017 15:01:34 +0000 (08:01 -0700)]
i965/miptree: Add an intel_tiling_supports_hiz helper

We need this split for the same reason that we need the split for CCS:
intel_miptree_supports_hiz is called *before* we choose the actual
tiling.  Adding a tiling_supports_hiz helper lets choose_aux_usage
more accurately decide whether or not to enable hiz.  In particular,
this prevents us from enabling HiZ on linear depth buffers.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agoi965/miptree: Gather initial aux allocation into a single function
Jason Ekstrand [Wed, 12 Jul 2017 23:11:47 +0000 (16:11 -0700)]
i965/miptree: Gather initial aux allocation into a single function

Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
7 years agost/mesa: init winsys buffers list only if context creation succeeds
Charmaine Lee [Wed, 12 Jul 2017 04:55:13 +0000 (21:55 -0700)]
st/mesa: init winsys buffers list only if context creation succeeds

Fixes piglit test crash when context creation fails.

v2: As suggested by Brian, move the init to st_create_context_priv()

Reviewed-by: Brian Paul <brianp@vmware.com>
7 years agowinsys/svga/drm: Enable import/export fence FD
Sinclair Yeh [Tue, 16 May 2017 15:19:41 +0000 (08:19 -0700)]
winsys/svga/drm: Enable import/export fence FD

Enable the capability if the DRM supports it.

Hook up mechanism to send and receive fence FD from the DRM.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
7 years agowinsys/svga/drm: Connect winsys-side fence_* functions
Sinclair Yeh [Tue, 16 May 2017 00:10:38 +0000 (17:10 -0700)]
winsys/svga/drm: Connect winsys-side fence_* functions

Connect fence_get_fd, fence_create_fd, and fence_server_sync.

Implement the required functions in vmw_fence module.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
7 years agodrivers/svga: Connect driver-side fence_* functions
Sinclair Yeh [Mon, 15 May 2017 23:22:53 +0000 (16:22 -0700)]
drivers/svga: Connect driver-side fence_* functions

Connect fence_get_fd, fence_create_fd, and fence_server_sync.
Return PIPE_CAP_NATIVE_FENCE_FD capability based on what the
winsys reports

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
7 years agowinsys/svga/drm: Create winsys interface for Fence FD
Sinclair Yeh [Mon, 17 Jul 2017 16:03:48 +0000 (10:03 -0600)]
winsys/svga/drm: Create winsys interface for Fence FD

The new interfaces will be used to enable
EGL_ANDROID_native_fence_sync.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
7 years agowinsys/svga/drm: Prepare to support fence fd
Sinclair Yeh [Mon, 15 May 2017 22:25:31 +0000 (15:25 -0700)]
winsys/svga/drm: Prepare to support fence fd

Make the fields and flags available.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
7 years agodrivers/svga, winsys/svga/drm: Thread through timeout for fence_finish
Sinclair Yeh [Wed, 3 May 2017 18:48:25 +0000 (11:48 -0700)]
drivers/svga, winsys/svga/drm: Thread through timeout for fence_finish

The timeout parameter is required to implement
EGL_ANDROID_native_fence_sync.

v2
* Replaced default timeout from 0 to PIPE_TIMEOUT_INFINITE
* Add more documentation to the new timeout parameter

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
7 years agosvga: whitespace clean-up in svga_winsys.h
Brian Paul [Mon, 17 Jul 2017 16:08:40 +0000 (10:08 -0600)]
svga: whitespace clean-up in svga_winsys.h

Trivial.

7 years agosvga: add some const qualifiers
Brian Paul [Fri, 14 Jul 2017 04:18:04 +0000 (22:18 -0600)]
svga: add some const qualifiers

Trivial.

7 years agosvga: add comment about 'extra' constant locations
Brian Paul [Fri, 14 Jul 2017 04:11:46 +0000 (22:11 -0600)]
svga: add comment about 'extra' constant locations

Trivial.

7 years agoanv/image: Add INPUT_ATTACHMENT to the list of required usages
Jason Ekstrand [Tue, 11 Jul 2017 23:28:55 +0000 (16:28 -0700)]
anv/image: Add INPUT_ATTACHMENT to the list of required usages

From the Vulkan 1.0.53 spec VU for vkCreateImageView:

    "image must have been created with a usage value containing at least
    one of VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_USAGE_STORAGE_BIT,
    VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
    VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, or
    VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT"

We were missing VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT from out list.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agoanv: Stop leaking the no_aux sampler surface state
Jason Ekstrand [Tue, 11 Jul 2017 15:13:13 +0000 (08:13 -0700)]
anv: Stop leaking the no_aux sampler surface state

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agoanv/cmd_buffer: Properly handle render passes with 0 attachments
Jason Ekstrand [Tue, 11 Jul 2017 22:47:36 +0000 (15:47 -0700)]
anv/cmd_buffer: Properly handle render passes with 0 attachments

We were early returning and never created the NULL surface state.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Tested-by: James Legg <jlegg@feralinteractive.com>
Cc: mesa-stable@lists.freedesktop.org
7 years agoradeonsi/gfx9: add VM fault dmesg parser support
Marek Olšák [Mon, 10 Jul 2017 21:13:14 +0000 (23:13 +0200)]
radeonsi/gfx9: add VM fault dmesg parser support

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: automatically resize shader compiler thread queues when they are full
Marek Olšák [Mon, 10 Jul 2017 20:16:26 +0000 (22:16 +0200)]
radeonsi: automatically resize shader compiler thread queues when they are full

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: prevent a deadlock in util_queue_add_job with too many GL contexts
Marek Olšák [Mon, 10 Jul 2017 19:59:43 +0000 (21:59 +0200)]
radeonsi: prevent a deadlock in util_queue_add_job with too many GL contexts

If the queue is full, util_queue_add_job will wait while bo_fence_lock is
held.

It pb_slab wants to reuse a buffer, it will lock the pb_slab mutex and
try to check BO fence busyness, but it has to wait for bo_fence_lock to get
released. Both bo_fence_lock and pb_slab mutex are locked now.

When the CS thread unreferences and releases a suballocated buffer,
it will try to lock the pb_slab mutex and has to wait. The CS thread
can't finish its job in order to free a queue slot and unblock
util_queue_add_job ==> deadlock.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoutil/u_queue: add an option to resize the queue when it's full
Marek Olšák [Mon, 10 Jul 2017 19:17:04 +0000 (21:17 +0200)]
util/u_queue: add an option to resize the queue when it's full

Consider the following situation:
  mtx_lock(mutex);
  do_something();
  util_queue_add_job(...);
  mtx_unlock(mutex);

If the queue is full, util_queue_add_job will wait for a free slot.
If the job which is currently being executed tries to lock the mutex,
it will be stuck forever, because util_queue_add_job is stuck.

The deadlock can be trivially resolved by increasing the queue size
(reallocating the queue) in util_queue_add_job if the queue is full.
Then util_queue_add_job becomes wait-free.

radeonsi will use it.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: expose ARB_timer_query unconditionally
Marek Olšák [Mon, 10 Jul 2017 14:06:08 +0000 (16:06 +0200)]
radeonsi: expose ARB_timer_query unconditionally

clock_crystal_freq is always non-zero now.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoac/gpu_info: if clock crystal frequency is 0, print an error and set 1
Marek Olšák [Mon, 10 Jul 2017 14:01:28 +0000 (16:01 +0200)]
ac/gpu_info: if clock crystal frequency is 0, print an error and set 1

During bring-up, this is often 0. Prevent automatic disablement of
ARB_timer_query and demotion of the OpenGL version to 3.2 by setting
a non-zero frequency. Print an error message instead.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi/gfx9: don't read back non-existent register SRBM_STATUS2
Marek Olšák [Sun, 9 Jul 2017 23:33:38 +0000 (01:33 +0200)]
radeonsi/gfx9: don't read back non-existent register SRBM_STATUS2

It looks like there is no way to monitor SDMA busyness on GFX9.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: prevent a crash with DBG_CHECK_VM and u_threaded_context
Marek Olšák [Sun, 9 Jul 2017 21:44:57 +0000 (23:44 +0200)]
radeonsi: prevent a crash with DBG_CHECK_VM and u_threaded_context

by setting PIPE_CONTEXT_DEBUG in the caller

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoac/surface/gfx9: flags.texture currently refers to TC-compatible HTILE
Marek Olšák [Sat, 8 Jul 2017 18:22:54 +0000 (20:22 +0200)]
ac/surface/gfx9: flags.texture currently refers to TC-compatible HTILE

This should lead to better MSAA performance on GFX9.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: simplify computation of tessellation offchip buffers
Marek Olšák [Sat, 8 Jul 2017 17:49:05 +0000 (19:49 +0200)]
radeonsi: simplify computation of tessellation offchip buffers

This is overly cautious, but better safe than sorry.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi/gfx9: add workarounds to avoid VGPR indexing completely
Marek Olšák [Wed, 5 Jul 2017 21:33:13 +0000 (23:33 +0200)]
radeonsi/gfx9: add workarounds to avoid VGPR indexing completely

For inputs and outputs, indirect indexing is lowered by the GLSL compiler.
For temporaries, use alloca and disable the "promote-alloca" pass.

In the future, we could switch all codepaths to alloca permanently and
just rely on the "promote-alloca" pass.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: emit param exports after position exports
Marek Olšák [Tue, 4 Jul 2017 22:24:11 +0000 (00:24 +0200)]
radeonsi: emit param exports after position exports

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: move building parameter exports into a separate function
Marek Olšák [Sat, 27 May 2017 18:56:33 +0000 (20:56 +0200)]
radeonsi: move building parameter exports into a separate function

Both loops now look simple.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: don't use info.num_inputs when it's unused
Marek Olšák [Thu, 1 Jun 2017 20:25:57 +0000 (22:25 +0200)]
radeonsi: don't use info.num_inputs when it's unused

For clarity. It's only used by color interpolation.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: add si_build_fs_interp helper
Marek Olšák [Thu, 1 Jun 2017 20:18:58 +0000 (22:18 +0200)]
radeonsi: add si_build_fs_interp helper

This is much simpler.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: merge si_llvm_get_amdgpu_target into ac_get_llvm_target
Marek Olšák [Tue, 4 Jul 2017 20:38:37 +0000 (22:38 +0200)]
radeonsi: merge si_llvm_get_amdgpu_target into ac_get_llvm_target

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agogallivm: inline gallivm_init_llvm_targets
Marek Olšák [Thu, 6 Jul 2017 00:15:35 +0000 (02:15 +0200)]
gallivm: inline gallivm_init_llvm_targets

there is only one user.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: don't call gallivm_init_llvm_targets
Marek Olšák [Thu, 6 Jul 2017 00:14:53 +0000 (02:14 +0200)]
radeonsi: don't call gallivm_init_llvm_targets

It's for initializing the native (x86) target.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agogallium/radeon: reallocate suballocated buffers when exported
Marek Olšák [Tue, 4 Jul 2017 15:29:46 +0000 (17:29 +0200)]
gallium/radeon: reallocate suballocated buffers when exported

This should fix exports of suballocated buffers.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agogallium/radeon: flush the context after in-place texture realloc before export
Marek Olšák [Tue, 4 Jul 2017 15:26:31 +0000 (17:26 +0200)]
gallium/radeon: flush the context after in-place texture realloc before export

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agost/va: Fix scaling list ordering for H.265
Mark Thompson [Sat, 15 Jul 2017 18:51:56 +0000 (19:51 +0100)]
st/va: Fix scaling list ordering for H.265

Mesa here requires the scaling lists in diagonal scan order, but
VAAPI passes them in raster scan order.  Therefore, rearrange the
elements when copying.

v2: Move scan tables to vl_zscan.c.
    Fix type in size assertion.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Mark Thompson <sw@jkqxz.net>
Reviewed-by: Christian König <christian.koenig@amd.com>