OSDN Git Service

android-x86/external-mesa.git
7 years agoMerge remote-tracking branch 'mesa/12.0' into marshmallow-x86 android-x86-6.0-r1
Chih-Wei Huang [Tue, 6 Sep 2016 03:18:33 +0000 (11:18 +0800)]
Merge remote-tracking branch 'mesa/12.0' into marshmallow-x86

Conflicts:
src/egl/drivers/dri2/platform_android.c
src/mesa/drivers/dri/i965/intel_syncobj.c

7 years agodocs: add sha256 checksums for 12.0.2
Emil Velikov [Mon, 5 Sep 2016 15:03:06 +0000 (16:03 +0100)]
docs: add sha256 checksums for 12.0.2

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agodocs: add release notes for 12.0.2
Emil Velikov [Mon, 5 Sep 2016 11:14:11 +0000 (12:14 +0100)]
docs: add release notes for 12.0.2

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoUpdate version to 12.0.2
Emil Velikov [Mon, 5 Sep 2016 11:09:24 +0000 (12:09 +0100)]
Update version to 12.0.2

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoglx/glvnd: list the strcmp arguments in correct order
Emil Velikov [Thu, 1 Sep 2016 09:36:44 +0000 (10:36 +0100)]
glx/glvnd: list the strcmp arguments in correct order

Currently, due to the inverse order, strcmp will produce negative result
when the needle is towards the start of the haystack. Thus on the next
iteration(s) we'll end up further towards the end and eventually fail to
locate the entry.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
(cherry picked from commit 62b224d428e04760dc96afb93873d67683337f88)

7 years agogk110/ir: fix quadop dall emission
Ilia Mirkin [Sun, 4 Sep 2016 22:21:29 +0000 (18:21 -0400)]
gk110/ir: fix quadop dall emission

We recently starting to always emit the NDV (== dall) bit for quadops.
However it was folded into the wrong code word.

Fixes: e0a067ed48 (nv50/ir: always emit the NDV bit for OP_QUADOP)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 61e978524a0e5de4f8570b44bcb9b907a9187684)

7 years agoa4xx: make sure to actually clamp depth as requested
Ilia Mirkin [Fri, 2 Sep 2016 01:49:26 +0000 (21:49 -0400)]
a4xx: make sure to actually clamp depth as requested

We were previously ... not clamping. I guess this meant that everything
got clamped to 1/0, which was enough to pass the existing tests. Or
perhaps the clamping would only happen to the rasterized depth value and
not the frag shader's output depth value.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97231
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
(cherry-picked from 89f00f749fda4c1beca38f362c7f86bdc6e32785)
[imirkin: adjust ctx->batch to just ctx]

7 years agoRevert "i965/miptree: Set logical_depth0 == 6 for cube maps"
Emil Velikov [Sat, 3 Sep 2016 17:52:06 +0000 (18:52 +0100)]
Revert "i965/miptree: Set logical_depth0 == 6 for cube maps"

This reverts commit 48e9ecc47f078cba3f56694e4583003681717410.

The commit regressed several piglit tests on SNB/ILK hardware.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97567

7 years agoappveyor: Force Visual Studio 2013 image.
Jose Fonseca [Thu, 11 Aug 2016 13:11:00 +0000 (14:11 +0100)]
appveyor: Force Visual Studio 2013 image.

It seems the default build image is now Visual Studio 2015, and Visual
Studio 2013 is not installed.

7 years agoappveyor: Install pywin32 extensions.
Jose Fonseca [Thu, 11 Aug 2016 13:00:35 +0000 (14:00 +0100)]
appveyor: Install pywin32 extensions.

AppVeyor build images seem to have been upgraded to Python 2.7.12, but
no longer have pywin32 pre-installed.

7 years agonv30: only bail on color/depth bpp mismatch when surfaces are swizzled
Ilia Mirkin [Wed, 31 Aug 2016 04:54:17 +0000 (00:54 -0400)]
nv30: only bail on color/depth bpp mismatch when surfaces are swizzled

The actual restriction is a little weaker than I originally thought. See
https://bugs.freedesktop.org/show_bug.cgi?id=92306#c17 for the
suggestion. This also explain why things weren't *always* failing
before, only sometimes. We will allocate a non-swizzled depth buffer for
NPOT winsys buffer sizes, which they almost always are.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit 8caf2cb0c06fe0a1dddff3aed56392f376fda424)

7 years agoanv: Rework pipeline caching
Jason Ekstrand [Thu, 25 Aug 2016 08:49:49 +0000 (01:49 -0700)]
anv: Rework pipeline caching

The original pipeline cache the Kristian wrote was based on a now-false
premise that the shaders can be stored in the pipeline cache.  The Vulkan
1.0 spec explicitly states that the pipeline cache object is transiant and
you are allowed to delete it after using it to create a pipeline with no
ill effects.  As nice as Kristian's design was, it doesn't jive with the
expectation provided by the Vulkan spec.

The new pipeline cache uses reference-counted anv_shader_bin objects that
are backed by a large state pool.  The cache itself is just a hash table
mapping keys hashes to anv_shader_bin objects.  This has the added
advantage of removing one more hand-rolled hash table from mesa.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97476
Acked-by: Kristian Høgsberg Kristensen <krh@bitplanet.net>
(cherry picked from commit 10f9901bcef7724cb72fb2fe7e3dd8d6660d2f34)

7 years agoanv/pipeline: Add support for caching the push constant map
Jason Ekstrand [Sat, 4 Jun 2016 22:10:22 +0000 (15:10 -0700)]
anv/pipeline: Add support for caching the push constant map

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
(cherry picked from commit ffcef720b74737b07086db86f34aa2f4b8c58a50)
[Emil Velikov: dependency for the next patch]
Nominated-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoanv: Add a struct for storing a compiled shader
Jason Ekstrand [Thu, 25 Aug 2016 06:48:32 +0000 (23:48 -0700)]
anv: Add a struct for storing a compiled shader

This new anv_shader_bin struct stores the compiled kernel (as an anv_state)
as well as all of the metadata that is generated at shader compile time.
The struct is very similar to the old cache_entry struct except that it
is reference counted and stores the actual pipeline_bind_map.  Similarly to
cache_entry, much of the actual data is floating-size and stored after the
main struct.  Unlike cache_entry, which was storred in GPU-accessable
memory, the storage for anv_shader_bin kernels comes from a state pool.
The struct itself is reference-counted so that it can be used by multiple
pipelines at a time without fear of allocation issues.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Acked-by: Kristian Høgsberg Kristensen <krh@bitplanet.net>
(cherry picked from commit 689971847005219178f5a484dffecf9e5e515192)

7 years agoanv: Add pipeline_has_stage guards a few places
Jason Ekstrand [Thu, 25 Aug 2016 19:22:28 +0000 (12:22 -0700)]
anv: Add pipeline_has_stage guards a few places

All of these worked before because they were depending on prog_data to be
null.  Soon, we won't be able to depend on a nice prog_data pointer and
it's nice to be more explicit anyway.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 13c09fdd0cfb62f3f45c39ad01a1c8f4b37c9c19)

7 years agoanv: Remove unused fields from anv_pipeline_bind_map
Jason Ekstrand [Thu, 25 Aug 2016 06:12:18 +0000 (23:12 -0700)]
anv: Remove unused fields from anv_pipeline_bind_map

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit b259d86ad62503dfb3a18e501fb5ddff2c5c099a)

7 years agoanv/pipeline: Properly handle OOM during shader compilation
Jason Ekstrand [Mon, 29 Aug 2016 15:30:37 +0000 (08:30 -0700)]
anv/pipeline: Properly handle OOM during shader compilation

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit d5945bec124ab21606d0d2719abbae8c44a70cf1)

7 years agoanv/allocator: Correctly set the number of buckets
Jason Ekstrand [Sat, 27 Aug 2016 02:31:05 +0000 (19:31 -0700)]
anv/allocator: Correctly set the number of buckets

The range from ANV_MIN_STATE_SIZE_LOG2 to ANV_MAX_STATE_SIZE_LOG2 should
be inclusive and we have asserts that ensure that you never try to allocate
a state larger than (1 << ANV_MAX_STATE_SIZE_LOG2).  However, without
adding 1 to the difference, we allocate 1 too few bucckts and so, even
though we have an assert, anything landing in the last bucket will fail to
allocate properly..

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit a0f5c496e348b918a556dd275289d4dda63b94c9)

7 years agoanv/pipeline: Fix bind maps for fragment output arrays
Jason Ekstrand [Thu, 25 Aug 2016 19:21:51 +0000 (12:21 -0700)]
anv/pipeline: Fix bind maps for fragment output arrays

Found by inspection.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 4200c2266e9c1f76e54d667e69a1a69516e6bf57)

7 years agoanv/descriptor_set: memset anv_descriptor_set_layout
Jason Ekstrand [Thu, 25 Aug 2016 09:37:19 +0000 (02:37 -0700)]
anv/descriptor_set: memset anv_descriptor_set_layout

We hash this data structure so we can't afford to have uninitialized data
even if it is just structure padding.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit d316cec1c1e3a77f63332f99883ffeeeb21a6f5e)

7 years agonv50/ir: always emit the NDV bit for OP_QUADOP
Samuel Pitoiset [Thu, 25 Aug 2016 16:41:05 +0000 (18:41 +0200)]
nv50/ir: always emit the NDV bit for OP_QUADOP

This silences a divergent error found with F1 2015.

Basically, the NDV bit has to be set when a FSWZ instruction is
inside divergent code, but it's not needed otherwise. The correct
fix should be to set it only in divergent code situations.

GM107 emitter already sets that bit.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: <mesa-stable@lists.freedesktop.org>
(cherry picked from commit e0a067ed484698ff62dd8c8750aeb46f18988b17)

7 years agoi915: Check return value of screen->image.loader->getBuffers
Emil Velikov [Wed, 24 Aug 2016 11:50:33 +0000 (12:50 +0100)]
i915: Check return value of screen->image.loader->getBuffers

Ported from the i965 commit e7ab358e8186dd8651cf920d4db1500c60ccd2fc.

Cc: 11.2 12.0 <mesa-stable@lists.freedesktop.org>
Cc: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
(cherry picked from commit 5de640a5185ce831b9a7ae86c6fc0da3b0adbb48)

7 years agonouveau: always enable at least one RC
Ilia Mirkin [Sat, 27 Aug 2016 23:51:29 +0000 (19:51 -0400)]
nouveau: always enable at least one RC

Experimentally, this is required for glxgears and others to display the
proper colors. This is also what the code used to do before the
referenced commit.

Fixes: c703658b396 (mesa: Drop _EnabledUnits.)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit 357d8261f1e9fd93105dd704c94828582dc02043)

7 years agomesa: fix format conversion bug in get_tex_rgba_uncompressed()
Brian Paul [Mon, 29 Aug 2016 17:18:18 +0000 (11:18 -0600)]
mesa: fix format conversion bug in get_tex_rgba_uncompressed()

We need to set the need_convert flag with each loop iteration, not
just when the rgba pointer is null.

Bug reported by Markus Müller <mueller@imfusion.de> on mesa-users list.
Fixes new piglit arb_texture_float-get-tex3d test.

Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
(cherry picked from commit b9b88516f8d3efc902696f1092519e298ceb7cdb)

7 years agomain: add missing EXTRA_END in OES_sample_variables get check
Ilia Mirkin [Sun, 28 Aug 2016 23:21:12 +0000 (19:21 -0400)]
main: add missing EXTRA_END in OES_sample_variables get check

Fixes: 3002296cb68 (mesa: add GL_OES_shader_multisample_interpolation support)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Cc: <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 05b37e20dea5fc4d920bbf9c28bffc60c4731330)

7 years agoisl: Allow multisampled array textures
Jason Ekstrand [Thu, 25 Aug 2016 22:07:31 +0000 (15:07 -0700)]
isl: Allow multisampled array textures

This probably isn't the only thing that needs to be done to get
multisampled array textures working in Vulkan but I think this is all that
ISL really needs and it does fix 8 of the new CTS tests.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
(cherry picked from commit fb895510477a9ce809cf5890afb1ea84ced6771e)

7 years agoglsl: Mark cube map array sampler types as reserved in GLSL ES 3.10
Ian Romanick [Wed, 17 Aug 2016 09:10:56 +0000 (10:10 +0100)]
glsl: Mark cube map array sampler types as reserved in GLSL ES 3.10

All the GLSL 4.x keywords were added to the list of reserved keywords
in GLSL ES 3.10.  As far as I can tell, these are the only ones that
were missed.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit c879dbc4e4184511cb3d831b66380c087216d850)

7 years agovbo: set draw_id
Miklós Máté [Fri, 26 Aug 2016 12:48:00 +0000 (06:48 -0600)]
vbo: set draw_id

Fixes conditional jump depending on uninitialized value
in si_state_draw.c:593

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Miklós Máté <mtmkls@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit b9ac72b5116d25529fc19bd849e85d5d91413f66)

7 years agoi965: Respect miptree offsets in intel_readpixels_tiled_memcpy()
Chad Versace [Thu, 25 Aug 2016 23:08:27 +0000 (16:08 -0700)]
i965: Respect miptree offsets in intel_readpixels_tiled_memcpy()

Respect intel_miptree_slice::x_offset,y_offset and
intel_mipmap_tree::offset. All three may be non-zero when glReadPixels
is called on an EGLImage created from the non-base slice of a miptree.

Patch 2/2 that fixes test
'dEQP-EGL.functional.image.create.gles2_cubemap_*'.

Reported-by: Haixia Shi <hshi@chromium.org>
Diagnosed-by: Haixia Shi <hshi@chromium.org>
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Change-Id: I4b397b27e55a743a7094d29fb0a6a4b6b34352b0
(cherry picked from commit 5b03975889046640a0b87fb08cf06e8fb7ef9953)

7 years agoi965: Fix miptree layout for EGLImage-based renderbuffers
Chad Versace [Thu, 25 Aug 2016 23:08:15 +0000 (16:08 -0700)]
i965: Fix miptree layout for EGLImage-based renderbuffers

When glEGLImageTargetRenderbufferStorageOES() was given an EGLImage
created from the non-base slice of a miptree,
intel_image_target_renderbuffer_storage() forgot to apply the intra-tile
offsets __DRIimage::tile_x,tile_y to the miptree layout.

This patch fixes the problem with a quick hack suitable for
cherry-picking. A proper fix requires more thorough plumbing in
intel_miptree_create_layout() and brw_tex_layout().

Patch 1/2 that fixes test
'dEQP-EGL.functional.image.create.gles2_cubemap_*'.

Reported-by: Haixia Shi <hshi@chromium.org>
Diagnosed-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: mesa-stable@lists.freedesktop.org
Change-Id: I8a64b0048a1ee9e714ebb3f33fffd8334036450b
(cherry picked from commit c82f99e883cfa66b3a3b135e7b1dab0a5bfae164)

7 years agonir: Walk blocks in source code order in lower_vars_to_ssa.
Matt Turner [Thu, 25 Aug 2016 02:25:58 +0000 (19:25 -0700)]
nir: Walk blocks in source code order in lower_vars_to_ssa.

Prior to this commit rename_variables_block() is recursively called,
performing a depth-first traversal of the control flow graph. The
function uses a non-trivial amount of stack space for local variables,
which puts us in danger of smashing the stack, given a sufficiently deep
dominance tree.

XCOM: Enemy Within contains a shader with such a dominance tree (1574
nir_blocks in total, depth of at least 143).

Jason tells me that he believes that any walk over the nir_blocks that
respects dominance is sufficient (a DFS might have been necessary prior
to the introduction of nir_phi_builder).

In fact, the introduction of nir_phi_builder made the problem worse:
rename_variables_block(), walks to the bottom of the dominance tree
before calling nir_phi_builder_value_get_block_def() which walks back to
the top of the dominance tree...

In any case, this patch ensures we avoid that problem as well.

Cc: mesa-stable@lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97225
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
(cherry picked from commit e53130cc27b966a09d48be53cb51e09ea7ad0649)

7 years agoswrast: fix incorrectly positioned putImage() in swrast driver
Brian Paul [Wed, 24 Aug 2016 14:52:29 +0000 (08:52 -0600)]
swrast: fix incorrectly positioned putImage() in swrast driver

Some front buffer rendering was in the wrong position.  This included
scissored clears, glDrawPixels and glCopyPixels.  The problem was the
y coordinate passed to putImage() didn't match the y coordinate passed
to getImage().

We fix this by setting xrb->map_y to the inverted coordinate in
swrast_map_renderbuffer() which is used later by the putImage() call.
Also pass xrb->map_y to getImage() to be symmetric.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97426
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit 2a2dc416b6816ac8914c5f45ac80545d2c09246f)

7 years agoradeonsi: disable SDMA texture copying on Carrizo
Marek Olšák [Wed, 24 Aug 2016 21:34:01 +0000 (23:34 +0200)]
radeonsi: disable SDMA texture copying on Carrizo

Cc: 12.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
(cherry picked from commit 3ff0b67e1b6b492d5793c1580f4be0c6f58a1bc2)

7 years agoanv: Include the pipeline layout in the shader hash
Jason Ekstrand [Thu, 25 Aug 2016 00:14:11 +0000 (17:14 -0700)]
anv: Include the pipeline layout in the shader hash

The pipeline layout affects shader compilation because it is what
determines binding table locations as well as whether or not a particular
buffer has dynamic offsets.  Since this affects the generated shader, it
needs to be in the hash.  This fixes a bunch of CTS tests now that the CTS
is using a pipeline cache.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 2301705dee6324634520559b27ac6728ebb02191)

7 years agonvc0: invalidate textures/samplers on GK104+
Samuel Pitoiset [Wed, 24 Aug 2016 18:22:52 +0000 (20:22 +0200)]
nvc0: invalidate textures/samplers on GK104+

Like Fermi, textures and samplers are aliased between 3D and compute,
especially the TIC_FLUSH/TSC_FLUSH methods and we have to re-validate
these resources when switching between the two pipelines.

This fixes a GPU hang with Elemental (and most likely with other UE4 demos).

Tested on GK107 and GM107.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
CC: <mesa-stable@lists.freedesktop.org>
(cherry picked from commit a227b0a4f1354f145ff49183b687dd7541a24c86)

7 years agoradeonsi: fix VM faults due NULL internal const buffers on CIK
Marek Olšák [Thu, 18 Aug 2016 13:25:51 +0000 (15:25 +0200)]
radeonsi: fix VM faults due NULL internal const buffers on CIK

They are harmless, but the interrupts do decrease performance.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97039

Cc: 12.0 <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 2c13abb49137d0f81b530b3c67f1ed79c58c796e)

7 years agoradeonsi: add si_set_rw_buffer to be used for internal descriptors
Nicolai Hähnle [Fri, 3 Jun 2016 13:27:09 +0000 (15:27 +0200)]
radeonsi: add si_set_rw_buffer to be used for internal descriptors

So that callers outside of si_descriptors.c need to worry less about the
details of descriptor handling.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit ba4a2840c7fb52169400420fd94c655b2b229f7e)

7 years agogallium/winsys/kms: Look up the GEM handle after importing a prime FD
Tomasz Figa [Tue, 2 Aug 2016 10:46:28 +0000 (19:46 +0900)]
gallium/winsys/kms: Look up the GEM handle after importing a prime FD

drmPrimeHandleToFD() will return the same GEM handle every time the same
buffer is imported, even from a different prime FD. Since GEM handles
are not reference counted, we need to make sure that each GEM handle is
referenced only by one display target struct, by looking it up in
kms_sw->bo_list first and bumping the refcount of the found dt on hit
and falling back to creating a new dt only on miss.

v2: Split into separate function.
    Use helper function for lookup.

v3 [Emil Velikov]:
    Rename kms_sw_displaytarget_{lookup,find_and_ref} (Jordan)

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
CC: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com> (v2)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 577f85e2bba093084d5d2af6047aeb328d708d9b)

7 years agogallium/winsys/kms: Move display target handle lookup to separate function
Tomasz Figa [Tue, 2 Aug 2016 10:46:27 +0000 (19:46 +0900)]
gallium/winsys/kms: Move display target handle lookup to separate function

As a preparation to use the lookup in more than once place, move the
code that looks up given KMS/GEM handle to a separate function. This
change should not introduce any functional changes.

v2: Split into separate patch.
    Move lookup code into separate function.

v3 [Emil Velikov]:
    Rename kms_sw_displaytarget_{lookup,find_and_ref} (Jordan)

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
CC: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com> (v2)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 0465c72d46e49bb26c5f1f09bc70074d49e82196)

7 years agogallium/winsys/kms: Fully initialize kms_sw_dt at prime import time (v2)
Tomasz Figa [Tue, 2 Aug 2016 10:46:26 +0000 (19:46 +0900)]
gallium/winsys/kms: Fully initialize kms_sw_dt at prime import time (v2)

Currently kms_sw_displaytarget_add_from_prime() allocates the struct and
fills in only some of the fields, resulting in a half-baked struct that
needs to be further completed by the caller. To make this a bit more
consistent, pass width, height and stride to this function and fill in
everything there, so that caller can take the returned struct as is.

v2: Split from one big patch into four fixing one thing at a time.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
CC: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit e71b78ebf9a405f2831826de2cb2d4ebb8658262)

7 years agogallium/winsys/kms: Fix double refcount when importing from prime FD (v2)
Tomasz Figa [Tue, 2 Aug 2016 10:46:25 +0000 (19:46 +0900)]
gallium/winsys/kms: Fix double refcount when importing from prime FD (v2)

Currently the code creates a display target struct with refcount field
initialized to 1 and then the caller again increments it, leading to
a leaked reference. Let's remove the unnecessary increment.

v2: Split from one big patch into four fixing one thing at a time.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
CC: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 0aa6a818ef60e01f304987fe07ac1370d68d38b1)

7 years agonv50/ir: make sure cfg iterator always hits all blocks
Ilia Mirkin [Fri, 19 Aug 2016 04:41:59 +0000 (00:41 -0400)]
nv50/ir: make sure cfg iterator always hits all blocks

In some very specially-crafted cases, we could attempt to visit a node
that has already been visited, and then run out of bb's to visit, while
there were still cross blocks on the list. Make sure that those get
moved over in that case.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96274
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit 092f994a034b718f6170c631655ccaba8d2aa768)

7 years agovc4: Fix leak of the bo_handles table.
Eric Anholt [Tue, 2 Aug 2016 17:57:01 +0000 (10:57 -0700)]
vc4: Fix leak of the bo_handles table.

(cherry picked from commit 9f956909591fb259ce01f1882c3367978e8ec2fb)

7 years agovc4: add hash table look-up for exported dmabufs
Rob Herring [Fri, 22 Jul 2016 20:28:30 +0000 (15:28 -0500)]
vc4: add hash table look-up for exported dmabufs

It is necessary to reuse existing BOs when dmabufs are imported. There
are 2 cases that need to be handled. dmabufs can be created/exported and
imported by the same process and can be imported multiple times.
Copying other drivers, add a hash table to track exported BOs so the
BOs get reused.

v2: Whitespace fixup (by anholt)

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit 9ace2c13550609dfe78164f104500d438821f383)

7 years agovc4: Fix a leak of the src[] array of VPM reads in optimization.
Eric Anholt [Tue, 2 Aug 2016 18:02:21 +0000 (11:02 -0700)]
vc4: Fix a leak of the src[] array of VPM reads in optimization.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit a0671d67def9e83ae511f758091b87d4ac34bea4)

7 years agovc4: Disable early Z with computed depth.
Eric Anholt [Tue, 19 Jul 2016 18:10:36 +0000 (11:10 -0700)]
vc4: Disable early Z with computed depth.

We don't tell the hardware whether we're computing depth, so we need
to manage early Z state manually.  Fixes piglit early-z.

(cherry picked from commit ce8504d196291452b42ed755ed3830ecb16febcd)

7 years agovc4: Close our screen's fd on screen close.
Eric Anholt [Mon, 11 Jul 2016 23:46:20 +0000 (16:46 -0700)]
vc4: Close our screen's fd on screen close.

We're passed in a freshly dup()ed fd on screen create, so we should close
it on exit.  Debugged by Hugh Cole-Baker.

(cherry picked from commit c65a00eaff85160dd556856c8c2eecf3aabdc4d5)

7 years agovc4: fix vc4_resource_from_handle() stride calculation
Rob Herring [Tue, 14 Jun 2016 21:17:44 +0000 (16:17 -0500)]
vc4: fix vc4_resource_from_handle() stride calculation

The expected stride calculation is completely wrong. It should
ultimately be multiplying cpp and width rather than dividing. The width
also needs to be aligned to the tiling width first before converting to
stride bytes.

The whole stride check here is possibly pointless. Any buffers which
were allocated outside of vc4 may have strides with larger alignment
requirements.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit 067c5b10b690b949ac28c4aea237f398f8251fff)

7 years agomesa: Use AC_HEADER_MAJOR to include correct header for major().
Matt Turner [Thu, 21 Jul 2016 18:46:23 +0000 (11:46 -0700)]
mesa: Use AC_HEADER_MAJOR to include correct header for major().

Gentoo has been smoke testing an upcoming change to glibc.

Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=580392
(cherry picked from commit 20553e4a2d952f6dc37f40f63d2c86b0718c58f9)

7 years agoegl/wayland-egl: Fix for segfault in dri2_wl_destroy_surface.
Stencel, Joanna [Mon, 22 Aug 2016 07:48:50 +0000 (09:48 +0200)]
egl/wayland-egl: Fix for segfault in dri2_wl_destroy_surface.

Segfault occurs when destroying EGL surface attached to already destroyed
Wayland window. The fix is to set to NULL the pointer of surface's
native window when wl_egl_destroy_window() is called.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Stencel, Joanna <joanna.stencel@intel.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 690ead4a135aed68ddb8dcfceccd11adf27ff1f1)

7 years agoanv/clear: Clear E5B9G9R9 images as R32_UINT
Jason Ekstrand [Wed, 3 Aug 2016 18:41:45 +0000 (11:41 -0700)]
anv/clear: Clear E5B9G9R9 images as R32_UINT

We can't actually clear these images normally because we can't render to
them.  Instead, we have to manually unpack the rgb9e5 color value on the
CPU and clear it as R32_UINT.  We still have a bit of work to do to clear
non-power-of-two images, but this should get all of the power-of-two clears
working on at least Haswell.  This fixes three of the new Vulkan CTS tests
in the dEQP-VK.api.image_clearing.clear_color_image.* group.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 7bdccd104bf49861adfd891ea35884f2197e1c44)
[Emil Velikov: rgb9e5 header is renamed in master
s/format_rgb9e5.h/u_format_rgb9e5.h/]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoanv/clear: Make cmd_clear_image take an actual VkClearValue
Jason Ekstrand [Wed, 3 Aug 2016 18:37:24 +0000 (11:37 -0700)]
anv/clear: Make cmd_clear_image take an actual VkClearValue

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit afa7ca0f7764a049b0ff870fb6964207393be533)

7 years agoanv/blit2d: Add support for RGB destinations
Jason Ekstrand [Tue, 2 Aug 2016 15:47:51 +0000 (08:47 -0700)]
anv/blit2d: Add support for RGB destinations

This fixes 104 of the new image_clearing and copy_and_blit Vulkan CTS
tests.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit cf3cf2ecfc019051f9ffb72dcbe1baeeb5a7a34a)

7 years agoanv/blit2d: Add a format parameter to bind_dst and create_iview
Jason Ekstrand [Tue, 2 Aug 2016 15:28:39 +0000 (08:28 -0700)]
anv/blit2d: Add a format parameter to bind_dst and create_iview

Signed-off-by: Jasosn Ekstrand <jason@jlekstrand.net>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 16ddda845260213c27b6f844395ed25edbc3c091)
[Emil Velikov: don't attribute if using ISL_TILING_W. patches that
attribute and require the ISL_TILING_W handling aren't in 12.0]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/intel/vulkan/anv_meta_blit2d.c

7 years agost/glsl_to_tgsi: fix st_src_reg_for_double constant.
Dave Airlie [Tue, 5 Jul 2016 00:26:14 +0000 (10:26 +1000)]
st/glsl_to_tgsi: fix st_src_reg_for_double constant.

This needs to set the src swizzle so it doesn't access the .zw
members ever when we are just emitting a 0 constant here.

This fixes:
vert-conversion-explicit-dvec3-bvec3.shader_test
and a bunch of other fp64 tests on softpipe and radeonsi.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 26187f3890cd92d6871ffb431763b27cacd8d4fe)

7 years agomesa: Fix fixed function spot lighting on newer hardware (again)
Daniel Scharrer [Sat, 20 Aug 2016 02:23:29 +0000 (04:23 +0200)]
mesa: Fix fixed function spot lighting on newer hardware (again)

This was first fixed in commit b3f9c5c and then broken again in commit
fe2d2c7, which removed the abs modifier from input registers.

v2: Don't change the size of struct ureg.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91342
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Daniel Scharrer <daniel@constexpr.org>
(cherry picked from commit 16ef7ab5c13d2c5638f5a4e1fe7f0303d26b4e96)

7 years agoi965/vec4: Ignore swizzle of VGRF for use by var_range_end().
Matt Turner [Thu, 18 Aug 2016 22:54:47 +0000 (15:54 -0700)]
i965/vec4: Ignore swizzle of VGRF for use by var_range_end().

var_range_end(v, n) loops over the n components of variable number v and
finds the maximum value, giving the last use of any component of v.
Therefore it expects v to correspond to the variable associated with the
.x channel of the VGRF.

var_from_reg() however returns the variable for the first channel of the
VGRF, post-swizzle.

So, if the last register had a swizzle with y, z, or w in the swizzle
component, we would read out of bounds. For any other register, we would
read liveness information from the next register.

The fix is to convert the src_reg to a dst_reg in order to call the
dst_reg version of var_from_reg() that doesn't consider the swizzle.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit e7c376adfdecd4c1333997c8be8bb066a87c67b4)

7 years agocherry-ignore: temporary(?) drop "a4xx: make sure to actually clamp depth"
Emil Velikov [Thu, 1 Sep 2016 09:09:48 +0000 (10:09 +0100)]
cherry-ignore: temporary(?) drop "a4xx: make sure to actually clamp depth"

The commit depends a 700+ patch introducing fd_batch.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoa4xx: only disable depth clipping, not all clipping, when requested
Ilia Mirkin [Fri, 19 Aug 2016 00:12:29 +0000 (20:12 -0400)]
a4xx: only disable depth clipping, not all clipping, when requested

The previous bit disables the whole clipper, including the regular
viewport-related clipping that would go on. The two new bits disable
near and far clipping (separately, as verified with the
depth-clamp-range piglit).

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit cd8e30452f6d308a0c5e5668d6bba63f01895f1f)

7 years agovbo: add basevertex when looking up elements for vbo splitting
Ilia Mirkin [Wed, 17 Aug 2016 21:12:09 +0000 (17:12 -0400)]
vbo: add basevertex when looking up elements for vbo splitting

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97351
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 659dc10d32b5a2ca61d23f2ae43c9e241aff6a26)

7 years agoisl: automake: use VISIBILITY_CFLAGS to restrict symbol visibility
Emil Velikov [Thu, 28 Jul 2016 13:43:46 +0000 (14:43 +0100)]
isl: automake: use VISIBILITY_CFLAGS to restrict symbol visibility

v2: Add VISIBILITY_CFLAGS to AM_CFLAGS (Ken)

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> (v1)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit d61d25951887a08fd6ea2a9d0db82d52813ce532)
[Emil Velikov: drop not applicable gen4-6 hunks]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/intel/isl/Makefile.am

7 years agoanv: remove dummy VK_DEBUG_MARKER_EXT entry points
mil Velikov [Wed, 27 Jul 2016 15:19:41 +0000 (08:19 -0700)]
anv: remove dummy VK_DEBUG_MARKER_EXT entry points

The vkCmdDbgMarker{Begin,End} symbols are exported, yet the json does no
advertise that the driver supports the extension. Furthermore the
functions are empty stubs.

Remove those until we get a proper implementation and json notation.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Cc: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit ebd5dc8826ccd23a40bef452181604832c7c913a)

7 years agoanv: do not export the Vulkan API
Emil Velikov [Wed, 27 Jul 2016 13:02:53 +0000 (14:02 +0100)]
anv: do not export the Vulkan API

With version 1 of the Loader interface there is an internal/private symbol
(vk_icdGetInstanceProcAddr) which is used to retrieve all the API from the
Vulkan entrypoints from the ICD. Implying that exposing the Vulkan API is not
recommended.

Version 2 goes a step further explicitly forbiding the ICD from exposing Vulkan
symbols (and adding a negotiation API)

As a reference:
 - Nvidia 367.35
Missing negotiation API - version 1.
Exposes only vk_icdGetInstanceProcAddr.

 - AMD 16.30.3.306809
Have negotiation API - version 2,
Exposes vk_icdGetInstanceProcAddr.
Exposes a couple of Vulkan entry points - seems to be in violation with the spec.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
(cherry picked from commit 49394e8d7713fa42bccc273ed4c060149291614c)

7 years agoanv: automake: build with -Bsymbolic
Emil Velikov [Wed, 27 Jul 2016 13:02:52 +0000 (14:02 +0100)]
anv: automake: build with -Bsymbolic

Explicitly suggested in the Loader interface version 2 section, but it's good
idea either way. It essentially, ensures that our symbols are not interposed.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Cc: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 1cdb6ca40b8a2daa09ce5c972da3a96e60aceaed)

7 years agoanv: automake: use VISIBILITY_CFLAGS to restrict symbol visibility
Emil Velikov [Thu, 28 Jul 2016 13:40:08 +0000 (14:40 +0100)]
anv: automake: use VISIBILITY_CFLAGS to restrict symbol visibility

Hide the internal symbols and annotate the vk_icdGetInstanceProcAddr as public
since the loader needs it (since v1 of the loader interface).

v2: Add VISIBILITY_CFLAGS to AM_CFLAGS (Ken)

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> (v1)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 40e4fff563ef1448656b1d3e6c11f5bd0c0b9e8a)

7 years agoanv: remove internal 'validate' layer
Emil Velikov [Thu, 28 Jul 2016 13:39:21 +0000 (14:39 +0100)]
anv: remove internal 'validate' layer

Presently the layer has only a single entry point. As mentioned by Jason the
function does not validate anything that isn't checked elsewhere, thus we can
drop the whole thing.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Cc: Jason Ekstrand <jason@jlekstrand.net>
Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit b0d56f2f4f1f4f7ecdf96f0a0246d0db5392e075)

7 years agoi965: Fix barrier count shift in scalar TCS backend.
Kenneth Graunke [Wed, 17 Aug 2016 13:35:01 +0000 (06:35 -0700)]
i965: Fix barrier count shift in scalar TCS backend.

The "Barrier Count" field goes in 14:9 of m0.2.  The vec4 backend
correctly shifts by 9, but the scalar backend only shifted by 8.

It's not like this changed - I think I just made a typo when writing
the original scalar TCS backend code.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
(cherry picked from commit d14dd727f4aded5bd34a78dc2c81374a78114440)

7 years agoi965: Fix execution size of scalar TCS barrier setup code.
Kenneth Graunke [Wed, 17 Aug 2016 13:26:01 +0000 (06:26 -0700)]
i965: Fix execution size of scalar TCS barrier setup code.

Previously, the scalar TCS backend was generating:

mov(8)   g17<1>UD     0x00000000UD    { align1 WE_all 1Q compacted };
and(8)   g17.2<1>UD   g0.2<0,1,0>UD   0x0001e000UD  { align1 WE_all 1Q };
shl(8)   g17.2<1>UD   g17.2<8,8,1>UD  0x0000000bUD  { align1 WE_all 1Q };
or(8)    g17.2<1>UD   g17.2<8,8,1>UD  0x00008200UD  { align1 WE_all 1Q };
send(8)  null<1>UW    g17<8,8,1>UD
         gateway (barrier msg) mlen 1 rlen 0 { align1 WE_all 1Q };

This is rubbish - g17.2<8,8,1>UD spans two registers, and is an illegal
region.  Not to mention it clobbers 8 channels of data when we only
wanted to touch m0.2.

Instead, we want:

mov(8)   g17<1>UD     0x00000000UD    { align1 WE_all 1Q compacted };
and(1)   g17.2<1>UD   g0.2<0,1,0>UD   0x0001e000UD  { align1 WE_all };
shl(1)   g17.2<1>UD   g17.2<0,1,0>UD  0x0000000bUD  { align1 WE_all };
or(1)    g17.2<1>UD   g17.2<0,1,0>UD  0x00008200UD  { align1 WE_all };
send(8)  null<1>UW    g17<8,8,1>UD
         gateway (barrier msg) mlen 1 rlen 0 { align1 WE_all 1Q };

Using component() accomplishes this.

Fixes GL44-CTS.tessellation_shader.tessellation_shader_tc_barriers.
barrier_guarded_read_write_calls on Skylake.  Probably fixes other
barrier issues on Gen8+.

v2: Use a group(1, 0) builder so inst->exec_size is set correctly
    (thanks to Francisco Jerez for catching that it was incorrect).

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> [v1]
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
(cherry picked from commit 159f0377556c45630cdc0721b193f34217a329b0)

7 years agoi965: Implement the WaPreventHSTessLevelsInterference workaround.
Kenneth Graunke [Wed, 8 Jun 2016 01:18:49 +0000 (18:18 -0700)]
i965: Implement the WaPreventHSTessLevelsInterference workaround.

Fixes several GL44-CTS.tessellation_shader (and GL45 and ES31) subcases:
- vertex_spacing
- tessellation_shader_point_mode.points_verification
- tessellation_shader_quads_tessellation.inner_tessellation_level_rounding

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
(cherry picked from commit 9e778837ff9abba0bed963d003297e3333cc7f1f)
[Emil Velikov: attribute for the lack of gl_linked_shader struct.]
[Namely: s/tes->info./shader_prog->/;s/gl_linked_shader/gl_shader/]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/mesa/drivers/dri/i965/brw_tcs.c

7 years agonir/builder: Add bany_inequal and bany helpers.
Kenneth Graunke [Wed, 17 Aug 2016 12:03:29 +0000 (05:03 -0700)]
nir/builder: Add bany_inequal and bany helpers.

The first simply picks the bany_inequal[234] opcodes based on the SSA
def's number of components.  The latter implicitly compares with zero
to achieve the same semantics of GLSL's any().

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
(cherry picked from commit d8971128accc84db04becf820b66e455d5d7534c)

7 years agomesa: Fix uf10_to_f32() scale factor in the E == 0 and M != 0 case.
Kenneth Graunke [Tue, 16 Aug 2016 05:26:42 +0000 (22:26 -0700)]
mesa: Fix uf10_to_f32() scale factor in the E == 0 and M != 0 case.

GL_EXT_packed_float, 2.1.B Unsigned 10-Bit Floating-Point Numbers:

        0.0,                      if E == 0 and M == 0,
        2^-14 * (M / 32),         if E == 0 and M != 0,
        2^(E-15) * (1 + M/32),    if 0 < E < 31,
        INF,                      if E == 31 and M == 0, or
        NaN,                      if E == 31 and M != 0,

In the second case (E == 0 and M != 0), we were multiplying the mantissa
by 2^-20, when we should have been multiplying by 2^-19 (which is
2^(-14 + -5), or 2^-14 * 2^-5, or 2^-14 / 32).

The previous section defines the formula for 11-bit numbers, which is:

        2^-14 * (M / 64),         if E == 0 and M != 0,

In other words, we had accidentally copy and pasted the 11-bit code
to the 10-bit case, and neglected to change the exponent.

Fixes dEQP-GLES3.functional.pbo.renderbuffer.r11f_g11f_b10f_triangles
when run with surface dimensions of 1536x1152 or 1920x1080.

Cc: mesa-stable@lists.freedesktop.org
References: https://code.google.com/p/chrome-os-partner/issues/detail?id=56244
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Stephane Marchesin <stephane.marchesin@gmail.com>
Reviewed-by: Antia Puentes <apuentes@igalia.com>
(cherry picked from commit 01e99cba043084be7477e3a801029bfee581ab87)

7 years agoglx: Don't use current context in __glXSendError
Michel Dänzer [Tue, 16 Aug 2016 06:35:44 +0000 (15:35 +0900)]
glx: Don't use current context in __glXSendError

There's no guarantee that there is one, and we don't need one anyway.

Fixes piglit tests:

glx@glx-fbconfig-bad
glx@glx_ext_import_context@import context, multi process
glx@glx_ext_import_context@import context, single process

Fixes: 2e3f067458e4 ("glx: fix error code when there is no context bound")
Cc: "11.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
(cherry picked from commit 4ac640e3d207ab84ee4468c7017e5410b7a05d7a)

7 years agonv50/ir: fix bb positions after exit instructions
Ilia Mirkin [Sun, 14 Aug 2016 02:19:39 +0000 (22:19 -0400)]
nv50/ir: fix bb positions after exit instructions

It's fairly rare that the BB layout puts BBs after the exit block, which
is likely the reason these issues lingered for so long.

This fixes a fraction of issues with the giant pixmark piano shader.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Cc: <mesa-stable@lists.freedesktop.org>
(cherry picked from commit e988999791c32fd2594986fde742367d7f71c724)

7 years agoanv: fix writemask on blit fragment shader.
Dave Airlie [Tue, 16 Aug 2016 00:00:28 +0000 (10:00 +1000)]
anv: fix writemask on blit fragment shader.

I'm not sure if anything even uses this, but I found this on radv, so
just fix it on anv for consistency.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit c2f225203721681fe964cb6f1f4fec317260a91e)

7 years agoglx: fix error code when there is no context bound
Bernard Kilarski [Tue, 7 Jun 2016 10:33:33 +0000 (13:33 +0300)]
glx: fix error code when there is no context bound

v2: change all related NULL checks to check against dummyContext
v3: really check for dummyContext *only* when ctx was from
    __glXGetCurrentContext
v4: cover more checks, add dummyBuffer, dummyVtable (Emil)

Signed-off-by: Bernard Kilarski <bernard.r.kilarski@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Cc: "11.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 2e3f067458e4a70da91b27fab61ef3d292ded4cf)

7 years agonv50,nvc0: fix depth range when halfz is enabled
Ilia Mirkin [Sat, 13 Aug 2016 01:40:52 +0000 (21:40 -0400)]
nv50,nvc0: fix depth range when halfz is enabled

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97231
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 5c1ccd8053412b6a42098481d2fde3d483208c33)

7 years agogallium/util: add helper to compute zmin/zmax for a viewport state
Ilia Mirkin [Sun, 14 Aug 2016 17:01:45 +0000 (13:01 -0400)]
gallium/util: add helper to compute zmin/zmax for a viewport state

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit c85b7f0e873518c332d23d1492332941355cb600)

7 years agovbo: allow DrawElementsBaseVertex in display lists
Ilia Mirkin [Sun, 14 Aug 2016 06:28:35 +0000 (02:28 -0400)]
vbo: allow DrawElementsBaseVertex in display lists

Looks like it was missed originally. The multi version is there already.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97331
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit 68b64f32e84c951ca22de8cd5f65305e0142230d)

7 years agoglsl: Fix invariant matching in GLSL 4.30 and GLSL ES 1.00.
Kenneth Graunke [Thu, 11 Aug 2016 13:12:53 +0000 (06:12 -0700)]
glsl: Fix invariant matching in GLSL 4.30 and GLSL ES 1.00.

Old languages (GLSL <= 4.20 and GLSL ES 1.00) require "invariant"
to be specified on both inputs and outputs, and match when linking.

New languages only allow outputs to be qualified as "invariant"
and remove the "invariant must match" restriction when linking
varyings (because no input can have that qualifier).

Commit 426a50e2089b12d33f5c075aa5622f64076914a3 introduced the new
behavior for ES 3.00.  It also removed the "must match" restriction
for ES 1.00 shaders, which I believe is incorrect.  This patch adds
that back, as well as making 4.30+ follow the new rules.

Thanks to Qiankun Miao for noticing this discrepancy.

Fixes a WebGL 2.0 conformance test when run in Chromium:
https://www.khronos.org/registry/webgl/sdk/tests/deqp/data/gles3/shaders/qualification_order.html?webglVersion=2

Cc: mesa-stable@lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96971
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
(cherry picked from commit f9f462936ad903f93829404ce99a2580ea21b725)

7 years agoglcpp: Only disallow #undef of pre-defined macros on GLSL ES >= 3.00 shaders
Ian Romanick [Tue, 9 Aug 2016 21:32:24 +0000 (14:32 -0700)]
glcpp: Only disallow #undef of pre-defined macros on GLSL ES >= 3.00 shaders

Section 3.4 (Preprocessor) of the GLSL ES 3.00 spec says:

   It is an error to undefine or to redefine a built-in (pre-defined)
   macro name.

The GLSL ES 1.00 spec does not contain this text.

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

   #define and #undef functionality are defined as is standard for C++
   preprocessors for macro definitions both with and without macro
   parameters.

At least as far as I can tell GCC allow '#undef __FILE__'.  Furthermore,
there are desktop OpenGL conformance tests that expect '#undef
__VERSION__' and '#undef GL_core_profile' to work.

Fixes:

    GL45-CTS.shaders.preprocessor.definitions.undefine_version_vertex
    GL45-CTS.shaders.preprocessor.definitions.undefine_version_fragment
    GL45-CTS.shaders.preprocessor.definitions.undefine_core_profile_vertex
    GL45-CTS.shaders.preprocessor.definitions.undefine_core_profile_fragment

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit 50b49d242d702e4728329cc59f87d929963e7c53)

Squashed with commit

glcpp: Update tests for new #undef of built-in macro rules.

Ian recently changed the preprocessor to allow this in most GLSL
versions, but not GLSL ES 3.00+.  This patch converts the existing
test that expects a failure to a #version 300 es shader, and adds
a #version 110 shader to make sure that it's allowed.

Fixes 'make check'.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97307
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Tested-by: Vinson Lee <vlee@freedesktop.org>
(cherry picked from commit 1f47f78fc3193ecff13799305a8e35af82e68a06)

7 years agoglcpp: Track the actual version instead of just the version_resolved flag
Ian Romanick [Tue, 9 Aug 2016 21:31:49 +0000 (14:31 -0700)]
glcpp: Track the actual version instead of just the version_resolved flag

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit eda6349346616f3a45ca2d03e2c1a3da956df6b3)
[Emil Velikov: resolve trivial conflicts]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/compiler/glsl/glcpp/glcpp-parse.y

7 years agoi965/vec4: Make opt_vector_float reset at the top of each block
Jason Ekstrand [Wed, 20 Jul 2016 19:21:41 +0000 (12:21 -0700)]
i965/vec4: Make opt_vector_float reset at the top of each block

The pass isn't really control-flow aware and you can get into case where it
tries to combine instructions from different blocks.  This can actually
lead to an assertion failure when removing unneeded instructions if part of
the vector is set in one block and part in another.  This prevents
regressions in the next commit.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 4c3a6b07e2960266adca634f8607ef38f71b8318)

7 years agoradeonsi: only set dual source blending for MRT0
Marek Olšák [Tue, 9 Aug 2016 10:43:13 +0000 (12:43 +0200)]
radeonsi: only set dual source blending for MRT0

This is the proper fix for Overlord and Witcher 2 hangs.

The hang condition is that 1 app must write to MRT0 and MRT1 from a pixel
shader while MRT1 is disabled in CB_TARGET_MASK (does this generate
unflushable pixel quads? I don't know), and another app (e.g. Glamor)
must enable dual source blending in both MRT0 and MRT1. The hw gets
confused, which leads to corruption and hangs.

Cc: 12.0 11.2 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
(cherry picked from commit 947e0614d091c260651e4f3d6209bd6bcc2cfa0d)

7 years agoradeonsi: flush TC L2 cache for indirect draw data
Nicolai Hähnle [Mon, 8 Aug 2016 15:06:22 +0000 (17:06 +0200)]
radeonsi: flush TC L2 cache for indirect draw data

This fixes a bug when indirect draw data is generated by transform
feedback.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 2852dedaa0c45e426a53ba0042ecdb0f1b87950f)

7 years agoglsl: Fix location bias for patch variables.
Kenneth Graunke [Fri, 24 Jun 2016 07:09:00 +0000 (00:09 -0700)]
glsl: Fix location bias for patch variables.

We need to subtract VARYING_SLOT_PATCH0, not VARYING_SLOT_VAR0.

Since "patch" only applies to inputs and outputs, we can just handle
this once outside the switch statement, rather than replicating the
check twice and complicating the earlier conditions.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
(cherry picked from commit 398428f40684addd0a1465cf268436e8b1865351)

7 years agoglsl: Fix the program resource names of gl_TessLevelOuter/Inner[].
Kenneth Graunke [Fri, 24 Jun 2016 06:12:45 +0000 (23:12 -0700)]
glsl: Fix the program resource names of gl_TessLevelOuter/Inner[].

These are lowered to gl_TessLevel{Outer,Inner}MESA.  We need them to
appear in the program resource list with their original names and types.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
(cherry picked from commit 1556f16e46ba3037c3901808c2e1ac5df8e2b20e)

7 years agoglsl: Delete bogus ir_set_program_inouts assert.
Kenneth Graunke [Wed, 28 Oct 2015 23:39:11 +0000 (16:39 -0700)]
glsl: Delete bogus ir_set_program_inouts assert.

This assertion is bogus.  Varying structs, and arrays of structs, are
allowed by GLSL, and we can see them here.  While we currently don't
have any partial-variable support for those, simply returning false
and marking the entire thing as used is certainly legitimate.

I believe this is often swept under the rug by varying packing,
but that's disabled in certain tessellation situations.

Hit by 20 dEQP-GLES31.functional.tessellation.user_defined_io.* tests.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
(cherry picked from commit 4a49851da140fedf0e133034a202570725ad03a9)

7 years agoanv/gen7_pipeline: Set PixelShaderKillPixel for discards
Nanley Chery [Thu, 4 Aug 2016 22:47:23 +0000 (15:47 -0700)]
anv/gen7_pipeline: Set PixelShaderKillPixel for discards

According to the IVB PRM Vol2 P1, this bit must be set if a pixel shader
contains a discard instruction.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97207
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
(cherry picked from commit c495c18b24d6ea5ba346709daf673e2037172a39)

7 years agoloader: fix memory leak in loader_dri3_open
Jan Ziak [Sat, 30 Jul 2016 00:31:10 +0000 (02:31 +0200)]
loader: fix memory leak in loader_dri3_open

Found via "valgrind --leak-check=full glxgears".

Signed-off-by: Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0x9b@gmail.com>
Acked-by: Boyan Ding <boyan.j.ding@gmail.com>
Cc: "12.0 11.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit fd32868590c7cbc5c6c2b3d59ff66694de3864b8)

7 years agogallium/util: fix align64
Marek Olšák [Fri, 29 Jul 2016 13:00:12 +0000 (15:00 +0200)]
gallium/util: fix align64

it cut off the upper 32 bits

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
(cherry picked from commit 6db93cd167d3ae04688c192806aad54a05a9d161)

7 years agoegl/dri2: Add reference count for dri2_egl_display
Nicolas Boichat [Fri, 22 Jul 2016 03:27:41 +0000 (11:27 +0800)]
egl/dri2: Add reference count for dri2_egl_display

android.opengl.cts.WrapperTest#testGetIntegerv1 CTS test calls
eglTerminate, followed by eglReleaseThread. A similar case is
observed in this bug: https://bugs.freedesktop.org/show_bug.cgi?id=69622,
where the test calls eglTerminate, then eglMakeCurrent(dpy, NULL, NULL, NULL).

With the current code, dri2_dpy structure is freed on eglTerminate
call, so the display is not initialized when eglReleaseThread calls
MakeCurrent with NULL parameters, to unbind the context, which
causes a a segfault in drv->API.MakeCurrent (dri2_make_current),
either in glFlush or in a latter call.

eglTerminate specifies that "If contexts or surfaces associated
with display is current to any thread, they are not released until
they are no longer current as a result of eglMakeCurrent."

However, to properly free the current context/surface (i.e., call
glFlush, unbindContext, driDestroyContext), we still need the
display vtbl (and possibly an active dri dpy connection). Therefore,
we add some reference counter to dri2_egl_display, to make sure
the structure is kept allocated as long as it is required.

One drawback of this is that eglInitialize may not completely reinitialize
the display (if eglTerminate was called with a current context), however,
this seems to meet the EGL spec quite well, and does not permanently
leak any context/display even for incorrectly written apps.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 9ee683f877b283020c6f24776236f1145cb7a4ea)

Squashed with commit

egl/dri2: dri2_make_current: Release previous context's display

eglMakeCurrent can also be used to change the active display. In that
case, we need to decrement ref_count of the previous display (possibly
destroying it), and increment it on the next display.

Also, old_dsurf/old_rsurf cannot be non-NULL if old_ctx is NULL, so
we only need to test if old_ctx is non-NULL.

v2: Save the old display before destroying the context.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97214
Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reported-by: Alexandr Zelinsky <mexahotabop@w1l.ru>
Tested-by: Alexandr Zelinsky <mexahotabop@w1l.ru>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
(cherry picked from commit 78e3cea4197802253401766fc44362786898e024)

Squashed with commit

egl/dri2: dri2_initialize: Do not reference-count TestOnly display

In the case where dri2_initialize is called with a TestOnly display,
the display is not actually initialized, so dri2_egl_display always
fails, and we cannot do any reference counting.

Fixes piglit spec@egl_khr_create_context@verify gl flavor (reproducible
with LIBGL_ALWAYS_SOFTWARE=1).

Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reported-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 4f3f8bb59dd98e39c363fe47a55a7f97e7df9f4b)

7 years agoegl/android: Set dpy->DriverData to NULL on error
Nicolas Boichat [Thu, 4 Aug 2016 02:07:54 +0000 (10:07 +0800)]
egl/android: Set dpy->DriverData to NULL on error

Avoid use-after-free on error.

Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Martin Peres <martin.peres@linux.intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit c0580f6a3859ec373ed11b3a6266c9b94d01a343)

7 years agoegl/drm: Set disp->DriverData to NULL on error
Nicolas Boichat [Thu, 4 Aug 2016 02:07:53 +0000 (10:07 +0800)]
egl/drm: Set disp->DriverData to NULL on error

Avoid use-after-free on error.

Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Martin Peres <martin.peres@linux.intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit a9e8fb73977beaa407b72c4843e75db3b186ea09)

7 years agoegl/surfaceless: Set disp->DriverData to NULL on error
Nicolas Boichat [Thu, 4 Aug 2016 02:07:52 +0000 (10:07 +0800)]
egl/surfaceless: Set disp->DriverData to NULL on error

Avoid use-after-free on error.

Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Martin Peres <martin.peres@linux.intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 0e67d86540cb5f6bedffe4ff5dfcb1070e76b28b)

7 years agoegl/wayland: Set disp->DriverData to NULL on error
Nicolas Boichat [Thu, 4 Aug 2016 02:07:51 +0000 (10:07 +0800)]
egl/wayland: Set disp->DriverData to NULL on error

Avoid use-after-free, fix spec@egl_khr_fence_sync@conformance.

Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reported-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Martin Peres <martin.peres@linux.intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 48fd952f28a5fcd71eed5a60c8e3a10231c7a5b0)

7 years agoegl/x11: avoid using freed memory if dri2 init fails
Jan Ziak [Sun, 31 Jul 2016 13:44:18 +0000 (15:44 +0200)]
egl/x11: avoid using freed memory if dri2 init fails

Found with valgrind:

==4841== Invalid read of size 4
==4841==    at 0x56BDC80: dri2_initialize (egl_dri2.c:783)
==4841==    by 0x56BAFE5: _eglMatchAndInitialize (egldriver.c:261)
==4841==    by 0x56BB15E: _eglMatchDriver (egldriver.c:295)
==4841==    by 0x56B58C9: eglInitialize (eglapi.c:480)
==4841==    by 0x4F537DC: _glfwInitEGL (in /usr/lib64/libglfw.so.3.2)
==4841==    by 0x4F4BEFB: _glfwPlatformInit (in /usr/lib64/libglfw.so.3.2)
==4841==    by 0x4F46F40: glfwInit (in /usr/lib64/libglfw.so.3.2)
==4841==    by 0x402E59: main
==4841==  Address 0x6a05824 is 148 bytes inside a block of size 480 free'd
==4841==    at 0x4C2B680: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4841==    by 0x56C2AAE: dri2_initialize_x11_swrast (platform_x11.c:1233)
==4841==    by 0x56C2AAE: dri2_initialize_x11 (platform_x11.c:1493)
==4841==    by 0x56BDCEB: dri2_initialize (egl_dri2.c:805)
==4841==    by 0x56BAFAF: _eglMatchAndInitialize (egldriver.c:261)
==4841==    by 0x56BB0C9: _eglMatchDriver (egldriver.c:292)
==4841==    by 0x56B58C9: eglInitialize (eglapi.c:480)
==4841==    by 0x4F537DC: _glfwInitEGL (in /usr/lib64/libglfw.so.3.2)
==4841==    by 0x4F4BEFB: _glfwPlatformInit (in /usr/lib64/libglfw.so.3.2)
==4841==    by 0x4F46F40: glfwInit (in /usr/lib64/libglfw.so.3.2)
==4841==    by 0x402E59: main
==4841==  Block was alloc'd at
==4841==    at 0x4C2A868: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4841==    by 0x56C2A47: dri2_initialize_x11_swrast (platform_x11.c:1171)
==4841==    by 0x56C2A47: dri2_initialize_x11 (platform_x11.c:1493)
==4841==    by 0x56BDCEB: dri2_initialize (egl_dri2.c:805)
==4841==    by 0x56BAFAF: _eglMatchAndInitialize (egldriver.c:261)
==4841==    by 0x56BB0C9: _eglMatchDriver (egldriver.c:292)
==4841==    by 0x56B58C9: eglInitialize (eglapi.c:480)
==4841==    by 0x4F537DC: _glfwInitEGL (in /usr/lib64/libglfw.so.3.2)
==4841==    by 0x4F4BEFB: _glfwPlatformInit (in /usr/lib64/libglfw.so.3.2)
==4841==    by 0x4F46F40: glfwInit (in /usr/lib64/libglfw.so.3.2)
==4841==    by 0x402E59: main

Signed-off-by: Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0x9b@gmail.com>
Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 769ac1ec78e5bc52191ef0393e4702945bbacaa9)

7 years agovirgl: add openarena readpixels workaround.
Dave Airlie [Wed, 29 Jun 2016 06:42:29 +0000 (16:42 +1000)]
virgl: add openarena readpixels workaround.

So OA with flares does 8 readback from the depth buffer,
each of those was causing a host roundtrip and readback,

instead just sync the whole buffer and see how things go.

I'm not sure this won't destroy some other apps

7 years agoadd sync setting interface
Dave Airlie [Wed, 29 Jun 2016 06:42:18 +0000 (16:42 +1000)]
add sync setting interface

7 years agodon't flush with only 2 command words
Dave Airlie [Wed, 29 Jun 2016 06:29:36 +0000 (16:29 +1000)]
don't flush with only 2 command words

7 years agostart moving is synced check into winsys
Dave Airlie [Wed, 29 Jun 2016 06:27:10 +0000 (16:27 +1000)]
start moving is synced check into winsys