OSDN Git Service

android-x86/external-mesa.git
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 agoglsl: fix optimization of discard nested multiple levels
Nicolai Hähnle [Tue, 26 Jul 2016 08:04:57 +0000 (10:04 +0200)]
glsl: fix optimization of discard nested multiple levels

The order of optimizations can lead to the conditional discard optimization
being applied twice to the same discard statement. In this case, we must
ensure that both conditions are applied.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96762
Cc: mesa-stable@lists.freedesktop.org
Tested-by: Kai Wasserbäch <kai@dev.carbon-project.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 21556d86fc74d91ab58a7496a876ad33e0f950df)
[Emil Velikov: s/get_head_raw()/head/]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/compiler/glsl/opt_conditional_discard.cpp

7 years agost_glsl_to_tgsi: only skip over slots of an input array that are present
Nicolai Hähnle [Mon, 25 Jul 2016 16:05:46 +0000 (18:05 +0200)]
st_glsl_to_tgsi: only skip over slots of an input array that are present

When an application declares varying arrays but does not actually do any
indirect indexing, some array indices may end up unused in the consuming
shader, so the number of input slots that correspond to the array ends
up less than the array_size.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 185b0c15abfba8b011f5b009e9f1890305e40ff6)

7 years agoi965/miptree: Stop multiplying cube depth by 6 in HiZ calculations
Jason Ekstrand [Wed, 20 Jul 2016 15:24:15 +0000 (08:24 -0700)]
i965/miptree: Stop multiplying cube depth by 6 in HiZ calculations

intel_mipmap_tree::logical_depth0 is now in number of 2D slices so we no
longer need to be multiplying by 6.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 5d76690f170de9acc541aa6b4a507ccd20a78158)

7 years agoradeonsi: ensure sample locations are set for line and polygon smoothing
Nicolai Hähnle [Sat, 16 Jul 2016 18:41:18 +0000 (20:41 +0200)]
radeonsi: ensure sample locations are set for line and polygon smoothing

Since commit d938b8c, the sample locations are no longer set unconditionally,
so we need to set the atom to dirty on all chips, not just Polaris.

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

7 years agoradeonsi: fix Polaris MSAA regression
Nicolai Hähnle [Sat, 16 Jul 2016 18:37:29 +0000 (20:37 +0200)]
radeonsi: fix Polaris MSAA regression

The regression was introduced by commit d938b8c. The problem here is that in
order to use the small primitive filter, we need to explicitly set the sample
locations to 0. But the DB doesn't properly process the change of sample
locations without a flush, and so we can end up with incorrect Z values.

Instead of doing a flush, just disable the small primitive filter when MSAA
is force-disabled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96908
Cc: 12.0 <mesa-stable@lists.freedesktop.org>
(cherry picked from commit f755da0f2f8609e603b50424aa254358eb72fa25)

7 years agomesa: Don't call GenerateMipmap if Width or Height == 0.
Kenneth Graunke [Fri, 22 Jul 2016 05:13:38 +0000 (22:13 -0700)]
mesa: Don't call GenerateMipmap if Width or Height == 0.

One of the WebGL 2.0 conformance tests is trying to call
glGenerateMipmaps with a width and height of 0.  With the meta
implementation, this generates a "framebuffer attachment incomplete"
status, and falls back to the CPU path, calling MapTextureImage.

Except that there's no actual texture to map, and we assert fail.

There's no work to do in this case.  The test expects it to succeed,
so just return early with no error and avoid hassling the driver.

Cc: mesa-stable@lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96911
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
(cherry picked from commit f80bea2d8066d228e78a1744d036f69a0265116e)

7 years agoanv/pipeline: Set up point coord enables
Jason Ekstrand [Fri, 22 Jul 2016 22:59:22 +0000 (15:59 -0700)]
anv/pipeline: Set up point coord enables

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit b33bccb51917b9058541641702623bbe89841f1e)

7 years agomesa: Add GL_BGRA_EXT to the list of GenerateMipmap internal formats.
Kenneth Graunke [Thu, 21 Jul 2016 23:48:05 +0000 (16:48 -0700)]
mesa: Add GL_BGRA_EXT to the list of GenerateMipmap internal formats.

The GL_EXT_texture_format_BGRA8888 extension specification defines a
GL_BGRA_EXT unsized internal format (which is a little odd - usually
BGRA is a pixel transfer format).  The extension is written against
the ES 1.0 specification, so it's a little hard to map, but I believe
it's effectively adding it to the table used here, so we should allow
it here as well.

Note that GL_EXT_texture_format_BGRA8888 is always enabled (dummy_true),
so we don't need to check if it's enabled here.

This fixes mipmap generation in Skia and ChromeOS.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
References: https://bugs.chromium.org/p/chromium/issues/detail?id=630371
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reported-by: Stéphane Marchesin <marcheu@chromium.org>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit cb7077312954299fb1febed5b016190c00cccfa0)

7 years agoi965: Fix shared atomic intrinsics to pay attention to base.
Kenneth Graunke [Mon, 18 Jul 2016 21:55:07 +0000 (14:55 -0700)]
i965: Fix shared atomic intrinsics to pay attention to base.

Cc: "12.0" <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 76e161056a424e5b9c35b02a9f4e520c8c44cf2b)

7 years agonir: Add a base const_index to shared atomic intrinsics.
Kenneth Graunke [Mon, 18 Jul 2016 21:47:42 +0000 (14:47 -0700)]
nir: Add a base const_index to shared atomic intrinsics.

Commit 52e75dcb8c04c0dde989970c4c587cbe8313f7cf made nir_lower_io
start using nir_intrinsic_set_base instead of writing const_index[0]
directly.  However, those intrinsics apparently don't /have/ a base,
so this caused assert failures.

However, the old code was happily setting non-existent const_index
fields, so it was pretty bogus too.

Jason pointed out that load_shared and store_shared have a base,
and that the i965 driver uses that field.  So presumably atomics
should have one as well, so that loads/stores/atomics all refer
to variables with consistent addressing.

Cc: "12.0" <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 cf6f2d3ce72a8b9dac5830aaf518aeed17a3833d)

7 years agoi965: Include VUE handles for GS with invocations > 1.
Kenneth Graunke [Wed, 20 Jul 2016 23:11:18 +0000 (16:11 -0700)]
i965: Include VUE handles for GS with invocations > 1.

We always resort to the pull model for instanced GS inputs.  So, we'd
better include the VUE handles, or else we can't actually pull anything.

Ian reports that on his branch with OES_geometry_shader enabled,
this fixes a bunch of dEQP-GLES31.functional.geometry_shading tests::

- instanced.draw_2_instances_geometry_2_invocations
- instanced.draw_2_instances_geometry_8_invocations
- instanced.draw_4_instances_geometry_2_invocations
- instanced.draw_4_instances_geometry_8_invocations
- instanced.draw_8_instances_geometry_2_invocations
- instanced.draw_8_instances_geometry_8_invocations
- instanced.geometry_2_invocations
- instanced.geometry_32_invocations
- instanced.geometry_8_invocations
- instanced.geometry_max_invocations
- instanced.geometry_output_different_2_invocations
- instanced.geometry_output_different_32_invocations
- instanced.geometry_output_different_8_invocations
- instanced.geometry_output_different_max_invocations
- instanced.invocation_output_vary_by_attribute
- instanced.invocation_output_vary_by_texture
- instanced.invocation_output_vary_by_uniform
- query.primitives_generated_instanced

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Tested-by: Ian Romanick <ian.d.romanick@intel.com>
(cherry picked from commit 2db357e4c3dcb49deabae7b68721d57ad9ea0000)

7 years agoswr: Refactor checks for compiler feature flags
Chuck Atkins [Tue, 28 Jun 2016 19:50:47 +0000 (15:50 -0400)]
swr: Refactor checks for compiler feature flags

Encapsulate the test for which flags are needed to get a compiler to
support certain features.  Along with this, give various options to try
for AVX and AVX2 support.  Ideally we want to use specific instruction
set feature flags, like -mavx2 for instance instead of -march=haswell,
but the flags required for certain compilers are different.  This
allows, for AVX2 for instance, GCC to use -mavx2 -mfma -mbmi2 -mf16c
while the Intel compiler which doesn't support those flags can fall
back to using -march=core-avx2.

This addresses a bug where the Intel compiler will silently ignore the
AVX2 instruction feature flags and then potentially fail to build.

v2: Pass preprocessor-check argument as true-state instead of
    false-state for clarity.
v3: Reduce AVX2 define test to just __AVX2__.  Additional defines suchas
    __FMA__, __BMI2__, and __F16C__ appear to be inconsistently defined
    w.r.t thier availability.
v4: Fix C++11 flags being added globally and add more logic to
    swr_require_cxx_feature_flags

Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
Tested-by: Tim Rowley <timothy.o.rowley@Intel.com>
Signed-off-by: Chuck Atkins <chuck.atkins@kitware.com>
(cherry picked from commit c1bf6692beb662e5749e5680e0ebd15af2cd032a)

7 years agoswr: switch from overriding -march to selecting features
Tim Rowley [Thu, 16 Jun 2016 19:56:39 +0000 (14:56 -0500)]
swr: switch from overriding -march to selecting features

Acked-by: Chuck Atkins <chuck.atkins@kitware.com>
Tested-by: Chuck Atkins <chuck.atkins@kitware.com>
(cherry picked from commit 5a64549f54bf1f67a4d0d098ab480affaaabd8ab)

7 years agowinsys/amdgpu: disallow DCC with mipmaps
Marek Olšák [Tue, 7 Jun 2016 16:35:52 +0000 (18:35 +0200)]
winsys/amdgpu: disallow DCC with mipmaps

It has never been implemented. master will get a different fix.

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

Cc: 11.1 11.2 12.0 <mesa-stable@lists.freedesktop.org>
7 years agonvc0: upload sample locations on GM20x
Samuel Pitoiset [Sun, 24 Jul 2016 22:02:12 +0000 (00:02 +0200)]
nvc0: upload sample locations on GM20x

This fixes a bunch of multisample piglit tests on GM206, like
bin/arb_texture_multisample-texelfetch 2 -auto -fbo

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
(cherry picked from commit e7b2ce5fd872f6bf348310dcb6541ee5263886d5)
[Emil Velikov: resolve conflicts]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c

7 years agoAndroid: add missing u_math.h include path for libmesa_isl
Rob Herring [Mon, 13 Jun 2016 18:45:53 +0000 (13:45 -0500)]
Android: add missing u_math.h include path for libmesa_isl

Commit 87d062a94080 ("i965: Fix shared local memory size for Gen9+.")
added u_math.h include which broke the Android build:

In file included from external/mesa3d/src/intel/isl/isl_storage_image.c:25:
In file included from external/mesa3d/src/mesa/drivers/dri/i965/brw_compiler.h:29:
external/mesa3d/src/mesa/main/macros.h:35:10: fatal error: 'util/u_math.h' file not found
         ^

Add the missing include paths for libmesa_isl.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Kenneth Garunke <kenneth@whitecape.org>
Nominated-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 789ed13284cb99b96f2aa69f237959b27c5c3bc2)

7 years agomapi: Massage code to allow clang to compile.
Matt Turner [Mon, 11 Jul 2016 17:44:25 +0000 (10:44 -0700)]
mapi: Massage code to allow clang to compile.

According to https://llvm.org/bugs/show_bug.cgi?id=19778#c3 this code
was violating the spec, resulting in it failing to compile.

Cc: mesa-stable@lists.freedesktop.org
Co-authored-by: Tomasz Paweł Gajc <tpgxyz@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89599
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 5ec140c17b54c25920091501b665b9aa809cc5e8)

Squashed with commit:

mapi: fix typo in macro name

Fixes: 5ec140c17b54c2592009 ("mapi: Massage code to allow clang to compile.")
Reported-by: Alexandre Demers <alexandre.f.demers@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
(cherry picked from commit 4da9f7e7ce3e5fc62336dc6f041a30aabd2cacdc)

7 years agonir/inline: Constant-initialize local variables in the callee if needed
Jason Ekstrand [Fri, 15 Jul 2016 22:44:32 +0000 (15:44 -0700)]
nir/inline: Constant-initialize local variables in the callee if needed

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 9d503aea069e08cffd57a4d590a6a0ca3b8ae4a2)

7 years agonir: Add a nir_deref_foreach_leaf helper
Jason Ekstrand [Fri, 15 Jul 2016 22:21:19 +0000 (15:21 -0700)]
nir: Add a nir_deref_foreach_leaf helper

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

7 years agoanv: Properly call gen75_emit_state_base_address on Haswell.
Kenneth Graunke [Mon, 18 Jul 2016 23:13:36 +0000 (16:13 -0700)]
anv: Properly call gen75_emit_state_base_address on Haswell.

This should fix MOCS values.  Caught by Coverity.

CID: 1364155

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

7 years agogenxml: Rename "API Rendering Disable" to "Rendering Disable".
Kenneth Graunke [Mon, 18 Jul 2016 23:00:20 +0000 (16:00 -0700)]
genxml: Rename "API Rendering Disable" to "Rendering Disable".

Gen7/7.5 call it "Rendering Disable" while Gen8/9 prefix it with "API".

Pick one for consistency, and so we can share code between generations.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
(cherry picked from commit 87660579f587dbb390cf89c3ce7f5ccdb5c6839e)

7 years agoanv: Unify 3DSTATE_CLIP code across generations.
Kenneth Graunke [Mon, 18 Jul 2016 21:27:35 +0000 (14:27 -0700)]
anv: Unify 3DSTATE_CLIP code across generations.

The bulk of this is the same.  There are just a couple fields that only
exist on one generation or another, and we can easily handle those with
an #ifdef.

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

7 years agoanv: Enable early culling on Gen7.
Kenneth Graunke [Mon, 18 Jul 2016 20:52:07 +0000 (13:52 -0700)]
anv: Enable early culling on Gen7.

We set the cull mode, but forgot the enable bit.  Gen8 uses this.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
(cherry picked from commit 44502afd8219c298fafa39625a178713c912d975)

7 years agoanv: Fix near plane clipping on Gen7/7.5.
Kenneth Graunke [Mon, 18 Jul 2016 21:15:49 +0000 (14:15 -0700)]
anv: Fix near plane clipping on Gen7/7.5.

The Gen7/7.5 clip code used APIMODE_OGL, while the Gen8+ clip code used
APIMODE_D3D.  The meaning hasn't changed, so one of these must be wrong.

It appears that the hardware documentation is completely wrong.  It
claims that the "API Mode" bit means:

   0h    APIMODE_OGL    NEAR_VP boundary == 0.0 (NDC)
   1h    APIMODE_D3D    NEAR_VP boundary == -1.0 (NDC)

However, DirectX typically uses 0.0 for the near plane, while unextended
OpenGL uses -1.0.  i965's gen6_clip_state.c uses APIMODE_D3D for the
GL_ZERO_TO_ONE case, so I believe the meanings are backwards from what
the documentation says.

Section 23.2 ("Primitive Clipping") of the Vulkan 1.0.21 specification
contains the following equations:

   -w_c <= x_c <= w_c
   -w_c <= y_c <= w_c
      0 <= z_c <= w_c

This means that Vulkan follows D3D semantics.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
(cherry picked from commit 0d77f08042b00cff81bebceb7877bc20f80c0965)

7 years agogenxml: Add APIMODE_D3D missing enum values and improve consistency.
Kenneth Graunke [Mon, 18 Jul 2016 20:56:23 +0000 (13:56 -0700)]
genxml: Add APIMODE_D3D missing enum values and improve consistency.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
(cherry picked from commit 6b6727026228bd1eab715034416194317e4d0fc6)

7 years agogenxml: Add CLIPMODE_* prefix to 3DSTATE_CLIP's "Clip Mode" enum values.
Kenneth Graunke [Mon, 18 Jul 2016 22:36:43 +0000 (15:36 -0700)]
genxml: Add CLIPMODE_* prefix to 3DSTATE_CLIP's "Clip Mode" enum values.

Gen6-7.5 use CLIPMODE_REJECT_ALL, while Gen8+ just used REJECT_ALL.
Being consistent will let me unify code, and I prefer having the prefix.

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

7 years agoi965/miptree: Set logical_depth0 == 6 for cube maps
Jason Ekstrand [Tue, 19 Jul 2016 05:00:30 +0000 (22:00 -0700)]
i965/miptree: Set logical_depth0 == 6 for cube maps

This matches what we do for cube maps where logical_depth0 is in number of
face-layers rather than number of cubes.  This does mean that we will
temporarily be setting the surface bounds too loose for cube map textures
but we are already setting them too loose for cube arrays and we will be
fixing that in the next commit anyway.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Cc: "12.0 11.2 11.1" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit e19b7f7f1b5d6a1d325c0129d6d6b9da6234330a)

7 years agoi965/miptree: Enforce that height == 1 for 1-D array textures
Jason Ekstrand [Tue, 19 Jul 2016 01:46:43 +0000 (18:46 -0700)]
i965/miptree: Enforce that height == 1 for 1-D array textures

The GL API and mesa internals do this differently than we do.  In GL, there
is no depth parameter for 1-D arrays and height is used.  In the i965
miptree code we do the sane thing and make height == 1 and use depth for
number of slices.  This makes for a mismatch every time we create a 1-D
array texture from GL.  Instead of actually solving this problem, we just
said "1-D is hard, let's make sure it works no matter which way we pass the
parameters" and called it a day.

This commit fixes the one GL -> i965 transition point where we weren't
already handling 1-D array textures to do the right thing and then replaces
the magic fixup code with an assert that you're doing the right thing.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Cc: "12.0 11.2 11.1" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit d4d505d0b04b9bce7c346fe0710df9921861edd6)

7 years agoAvoid overflow in 'last' variable of FindGLXFunction(...)
Stefan Dirsch [Thu, 14 Jul 2016 13:21:20 +0000 (15:21 +0200)]
Avoid overflow in 'last' variable of FindGLXFunction(...)

This 'last' variable used in FindGLXFunction(...) may become negative,
but has been defined as unsigned int resulting in an overflow,
finally resulting in a segfault when accessing _glXDispatchTableStrings[...].
Fixed this by definining it as signed int. 'first' variable also needs to be
defined as signed int. Otherwise condition for while loop fails due to C
implicitly converting signed to unsigned values before comparison.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Stefan Dirsch <sndirsch@suse.de>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 27ef7bfd6cd2d960844f4c79d6dddc0bda0b20b0)

7 years agoegl/android: Stop leaking DRI images
Tomasz Figa [Fri, 15 Jul 2016 07:53:50 +0000 (16:53 +0900)]
egl/android: Stop leaking DRI images

Current implementation of the DRI image loader does not free the images
created in get_back_bo() and so leaks memory. Moreover, it creates a new
image every time the DRI driver queries for buffers, even if the backing
native buffer has not changed. leaking memory again.

This patch adds missing call to destroyImage() in droid_enqueue_buffer()
and a check if image is already created to get_back_bo() to fix the
above.

Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 9e1248d0752e692714b58ef1f2211ec7e172c8cf)

7 years agoegl/android: Check return value of dri2_get_dri_config()
Tomasz Figa [Fri, 15 Jul 2016 07:53:48 +0000 (16:53 +0900)]
egl/android: Check return value of dri2_get_dri_config()

It might return NULL if specific config variant is unsupported.

Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 94282b6dd0e7c15030b09b6789a7aa5a15e8a869)

7 years agoi965: store reference to the context within struct brw_fence (v2)
Emil Velikov [Fri, 15 Jul 2016 07:27:09 +0000 (16:27 +0900)]
i965: store reference to the context within struct brw_fence (v2)

As the spec allows for {server,client}_wait_sync to be called without
currently bound context, while our implementation requires context
pointer.

v2: Add a mutex and acquire it for the duration of
    brw_fence_client_wait() and brw_fence_is_completed() as suggested
    by Chad.

Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
(cherry picked from commit 4f48674d51f03d8c954a89dfc49539a1dc750c4d)

7 years agoegl/dri2: dri2_make_current: Set EGL error if bindContext fails
Nicolas Boichat [Fri, 15 Jul 2016 08:24:20 +0000 (16:24 +0800)]
egl/dri2: dri2_make_current: Set EGL error if bindContext fails

Without this, if a configuration is, say, available only on GLES2/3, but
not on GLES1, and is rejected by the dri module's bindContext call,
eglMakeCurrent fails with error "EGL_SUCCESS".

In this patch, we set error to EGL_BAD_MATCH, which is what CTS/dEQP
dEQP-EGL.functional.surfaceless_context expect.

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

7 years agoegl/android: Remove unused variables
Tomasz Figa [Wed, 13 Jul 2016 03:33:24 +0000 (11:33 +0800)]
egl/android: Remove unused variables

There are some unused variables left after previous clean-ups triggering
compiler warnings. Let's remove them.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit ccda100a5a2838adec16ac10b2cc1c73e666e7d2)

7 years agoplatform_android: prevent deadlock in droid_swap_buffers
Haixia Shi [Thu, 2 Jun 2016 19:48:23 +0000 (12:48 -0700)]
platform_android: prevent deadlock in droid_swap_buffers

To avoid blocking other EGL calls, release the display mutex before
we enqueue buffer to android frameworks and re-acquire the mutex
upon return.

v2: moved lock/unlock inside droid_window_enqueue_buffer().

TEST=verify pinch zoom in Photos app no longer causes hangs

Signed-off-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 1ea233c6f30a74e6ff5456c3521328237b01eed8)

7 years agogallium/dri: Add shared glapi to LIBADD on Android
Tomasz Figa [Wed, 13 Jul 2016 03:29:45 +0000 (11:29 +0800)]
gallium/dri: Add shared glapi to LIBADD on Android

An earlier patch fixed the problem for classic drivers, however Gallium
was still left broken. This patch applies the same workaround to
Gallium, when compiled for Android. Following is a quote from the
original patch:

0cbc90c57cfc mesa: dri: Add shared glapi to LIBADD on Android

/system/vendor/lib/dri/*_dri.so actually depend on libglapi: without
this, loading the so file fails with:
cannot locate symbol "__emutls_v._glapi_tls_Context"

On non-Android (non-bionic) platform, EGL uses the following
workflow, which works fine:
  dlopen("libglapi.so", RTLD_LAZY | RTLD_GLOBAL);
  dlopen("dri/<driver>_dri.so", RTLD_NOW | RTLD_GLOBAL);

However, bionic does not respect the RTLD_GLOBAL flag, and the dri
library cannot find symbols in libglapi.so, so we need to link
to libglapi.so explicitly. Android.mk already does this.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 70a28afb296de3e89248ad2a2bc0611e7afb762b)

7 years agomesa: scons: list builddir before srcdir
Emil Velikov [Mon, 18 Jul 2016 18:23:02 +0000 (19:23 +0100)]
mesa: scons: list builddir before srcdir

Analogous to previous commit.

Note: scons always uses OOT builds, while the in-tree generated files
could be created either manually or by the autoconf build.

Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
Cc: Alexander von Gluck IV <kallisti5@unixzen.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit 1c7c0d77ac1f7035558c37fc0297e9d22991d429)
[Emil Velikov: remove not-applicable "Dir('main')" entry]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/mesa/SConscript

7 years agomesa: automake: list builddir before srcdir
Emil Velikov [Mon, 18 Jul 2016 18:12:17 +0000 (19:12 +0100)]
mesa: automake: list builddir before srcdir

In the case of building in out-of-tree fashion, while having generated
in-tree sources, the latter [likely stale] files will be used.

Flip the order to prevent that.

Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(cherry picked from commit eafa82e20e35c532bd2918c62d0100cbbecc7f1f)

7 years agogm107/ir: make use of ADD32I for all immediates
Samuel Pitoiset [Tue, 19 Jul 2016 12:47:57 +0000 (14:47 +0200)]
gm107/ir: make use of ADD32I for all immediates

ADD only allows to emit 19-bits immediates.

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 9c63224540ef0f727aae24274fa4afdf2e2376ac)

7 years agogm107/ir: add missing NEG modifier for IADD32I
Samuel Pitoiset [Tue, 19 Jul 2016 12:47:56 +0000 (14:47 +0200)]
gm107/ir: add missing NEG modifier for IADD32I

Like FADD32I, the NEG modifier of src0 is at position 56.

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 0904a2ba9717e5706f8869dc9244e2c742fadd12)

7 years agoconfigure.ac: Use ${datarootdir} for --with-vulkan-icddir help string too
Andreas Boll [Tue, 19 Jul 2016 10:30:40 +0000 (12:30 +0200)]
configure.ac: Use ${datarootdir} for --with-vulkan-icddir help string too

The help string wasn't updated in cbc37f7.

Fixes: cbc37f7 ("anv: install the intel_icd.json to ${datarootdir} by
default")

Signed-off-by: Andreas Boll <andreas.boll.dev@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit d66cb7c84f2b35b76ad47f6f9add2c0512375815)

7 years agonv50,nvc0: srgb rendering is only available for rgba/bgra
Ilia Mirkin [Sun, 17 Jul 2016 21:14:24 +0000 (17:14 -0400)]
nv50,nvc0: srgb rendering is only available for rgba/bgra

Mark both L8_SRGB and L8A8_SRGB as non-renderable (the latter already
didn't have the bind flags). This makes the state tracker pick a
different format when rendering is required, or mark the fb as
incomplete. This fixes:

  bin/getteximage-formats init-by-clear-and-render -auto -fbo
  bin/getteximage-formats init-by-rendering -auto -fbo

which previously ran into srgb-encoding differences.

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 ed9dd3bcd9990b321f523823287643cbf893949f)

7 years agovl/dri3: fix a memory leak from front buffer
Leo Liu [Thu, 14 Jul 2016 13:19:59 +0000 (09:19 -0400)]
vl/dri3: fix a memory leak from front buffer

Inspired by fix for mem leak of vdpau interop, resource_from_handle
set texture reference count, that need to be decreased and released,
recall there is a similar case for DRI3, that is with VA-API glx
extension, there is temporary TFP(texture from pixmap), we target it
through dma-buf. leak happens when without count down the reference.

Checked and found with mpv vo=opengl case, there only one static TFP,
the leak happens once, but for totem player using gstreamer VA-API glx,
the dynamic TFP for each frame, so leak quite a bit.

This fixes mem leak for mpv and totem.

Signed-off-by: Leo Liu <leo.liu@amd.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 134d6e4e4f980d738361bfcae1daedb8cc58b5df)

7 years agoanv: Handle VK_WHOLE_SIZE properly for buffer views
Jason Ekstrand [Fri, 15 Jul 2016 04:11:14 +0000 (21:11 -0700)]
anv: Handle VK_WHOLE_SIZE properly for buffer views

The old calculation, which used view->offset, encorporated buffer->offset
into the size calculation where it doesn't belong.  This meant that, if
buffer->offset > buffer->size, you would always get a negative size.  This
fixes 170 dEQP-VK.renderpass.attachment.* Vulkan CTS tests on Haswell.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 593731ea3cc1aa9385e43ebc18c67574f181e1c3)
[Emil Velikov: s|bpb / 8|bs|g]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/intel/vulkan/anv_image.c

7 years agoanv: Add an align_down_npot_u32 helper
Jason Ekstrand [Fri, 15 Jul 2016 18:50:20 +0000 (11:50 -0700)]
anv: Add an align_down_npot_u32 helper

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

7 years agoanv: Enable independentBlend on gen7
Jason Ekstrand [Fri, 15 Jul 2016 01:01:29 +0000 (18:01 -0700)]
anv: Enable independentBlend on gen7

We can totally do it, we were just only setting up one BLEND_STATE and, now
that the code is unified with gen8, we should be handling it correctly.

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

7 years agoanv/pipeline: Unify blend state setup between gen7 and gen8
Jason Ekstrand [Fri, 15 Jul 2016 01:00:50 +0000 (18:00 -0700)]
anv/pipeline: Unify blend state setup between gen7 and gen8

This fixes all 674 broken dEQP-VK.pipeline.blend Vulkan CTS tests on
Haswell.

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

7 years agogenxml: Make gen6-7 blending look more like gen8
Jason Ekstrand [Fri, 15 Jul 2016 00:52:07 +0000 (17:52 -0700)]
genxml: Make gen6-7 blending look more like gen8

This renames BLEND_STATE to BLEND_STATE_ENTRY and adds an new struct
BLEND_STATE which is just an array of 8 BLEND_STATE_ENTRYs.  This will make
it much easier to write gen-agnostic blend handling code.

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

7 years agomesa: use _mesa_clear_texture_image() in clear_texture_fields()
Brian Paul [Wed, 13 Jul 2016 19:52:31 +0000 (13:52 -0600)]
mesa: use _mesa_clear_texture_image() in clear_texture_fields()

This avoids a failed assert(img->_BaseFormat != -1) in
init_teximage_fields_ms() because the internalFormat argument is GL_NONE.
This was hit when using glTexStorage() to do a proxy texture test.

Fixes a failure with the updated Piglit tex3d-maxsize test.

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

7 years agoisl: Fix isl_tiling_is_any_y()
Nanley Chery [Fri, 24 Jun 2016 22:37:34 +0000 (15:37 -0700)]
isl: Fix isl_tiling_is_any_y()

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

7 years agoanv/device: Fix max buffer range limits
Nanley Chery [Wed, 6 Jul 2016 18:13:48 +0000 (11:13 -0700)]
anv/device: Fix max buffer range limits

Set limits that are consistent with ISL's assertions in
isl_genX(buffer_fill_state_s)() and Anvil's format-DescriptorType
mapping in anv_isl_format_for_descriptor_type().

Fixes the following new crucible tests:
* stress.limits.buffer-update.range.uniform
* stress.limits.buffer-update.range.storage

These tests are in this patch: https://patchwork.freedesktop.org/patch/98726/

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 a5748cb9204f872cbaa6764b95a33ef20c4dd5da)

7 years agoisl: Fix assert on raw buffer surface state size
Nanley Chery [Wed, 6 Jul 2016 18:13:15 +0000 (11:13 -0700)]
isl: Fix assert on raw buffer surface state size

See inline PRM reference.

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 028f6d8317f00a94b09df81e8f2cb944077e64a7)

7 years agoanv/descriptor_set: Fix binding partly undefined descriptor sets
Nanley Chery [Tue, 12 Jul 2016 00:33:24 +0000 (17:33 -0700)]
anv/descriptor_set: Fix binding partly undefined descriptor sets

Section 13.2.3. of the Vulkan spec requires that implementations be able to
bind sparsely-defined Descriptor Sets without any errors or exceptions.

When binding a descriptor set that contains a dynamic buffer binding/descriptor,
the driver attempts to dereference the descriptor's buffer_view field if it is
non-NULL. It currently segfaults on undefined descriptors as this field is never
zero-initialized. Zero undefined descriptors to avoid segfaulting. This
solution was suggested by Jason Ekstrand.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96850
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 fd16e6432104389fa659bb1d011aa6fb82952737)

7 years agosvga: handle mismatched number of samplers, sampler views
Brian Paul [Fri, 15 Jul 2016 13:08:13 +0000 (07:08 -0600)]
svga: handle mismatched number of samplers, sampler views

in svga_init_shader_key_common().  Since the CSO module only tracks
sampler views for fragment shaders, the number of samplers and sampler
views can be mismatched for other types of shaders.  This situation
triggered an assertion in Chrome with maps.google.com

This patch adds defensive code to handle that situation.

Fixes VMware bug 1694027
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
(cherry picked from commit 50a669de4e216d2e3bea3ec1148c7e79f77ecb27)

7 years agost/omx/enc: check uninitialized list from task release
Leo Liu [Mon, 11 Jul 2016 19:27:16 +0000 (15:27 -0400)]
st/omx/enc: check uninitialized list from task release

The uninitialized list should be checked and returned.

Thank Julien for the notification and suggested fix.

Signed-off-by: Leo Liu <leo.liu@amd.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit b9d10e79c88842ba05d6937a3803cb5740b866da)

7 years agoglsl/types: Use _mesa_hash_data for hashing function types
Jason Ekstrand [Wed, 13 Jul 2016 21:26:50 +0000 (14:26 -0700)]
glsl/types: Use _mesa_hash_data for hashing function types

This is way better than the stupid string approach especially since you
could overflow the string.  Again, I thought I had something better at one
point but it obviously got lost.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit b919100d6101c0bd7e15a187968af9a36b49e6de)

7 years agoglsl/types: Fix function type comparison function
Jason Ekstrand [Wed, 13 Jul 2016 21:25:11 +0000 (14:25 -0700)]
glsl/types: Fix function type comparison function

It was returning true if the function types have different lengths rather
than false.  This was new with the SPIR-V to NIR pass and I thought I'd
fixed it a while ago but it may have gotten lost in rebasing somewhere.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 11ac1c4dbbc9fc41d163fa4d9a76bb73c3907871)

7 years agost/mesa: fix reference counting bug in st_vdpau
Christian König [Wed, 13 Jul 2016 12:54:31 +0000 (14:54 +0200)]
st/mesa: fix reference counting bug in st_vdpau

Otherwise we leak the resources created for the DMA-buf descriptors.

Signed-off-by: Christian König <christian.koenig@amd.com>
Cc: 12.0 <mesa-stable@lists.freedesktop.org>
Tested-and-Reviewed by: Leo Liu <leo.liu@amd.com>
Ack-by: Tom St Denis <tom.stdenis@amd.com>
(cherry picked from commit 9ce52baf7f479d506bcea17a371dcf2fad92f139)

7 years agoanv: Add a stub for CmdCopyQueryPoolResults on Ivy Bridge
Jason Ekstrand [Thu, 14 Jul 2016 03:11:30 +0000 (20:11 -0700)]
anv: Add a stub for CmdCopyQueryPoolResults on Ivy Bridge

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

7 years agoRevert "gallium: Force blend color to 16-byte alignment"
Tim Rowley [Wed, 13 Jul 2016 15:30:46 +0000 (10:30 -0500)]
Revert "gallium: Force blend color to 16-byte alignment"

This reverts commit d8d6091a846ac2a40a011d512d6d57f6c8442e6a.

Heap allocations may be only 8-byte aligned on 32-bit system, and so having
members with 16-byte alignment (such as in the case where pipe_blend_color is
embedded in radeonsi's si_context) is undefined behavior which indeed causes
crashes when compiled with gcc -O3.

Cc: <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96835
Signed-off-by: Tim Rowley <timothy.o.rowley@intel.com>
Acked-by: Chuck Atkins <chuck.atkins@kitware.com>
(cherry picked from commit 29f53d793781b67a92bb95fe66d7d38adc5488bb)

7 years agonir/spirv: Don't multiply the push constant block size by 4
Jason Ekstrand [Wed, 13 Jul 2016 18:35:29 +0000 (11:35 -0700)]
nir/spirv: Don't multiply the push constant block size by 4

I have no idea why we were multiplying by 4 before.  The offsets we get
from SPIR-V are in bytes and so is nir->num_uniforms so there's no need to
do any adjustment whatsoever.

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

7 years agoradeonsi: add a workaround for a compute VGPR-usage LLVM bug
Marek Olšák [Sun, 3 Jul 2016 18:00:17 +0000 (20:00 +0200)]
radeonsi: add a workaround for a compute VGPR-usage LLVM bug

v2: use abort(), describe which LLVM version is affected

Cc: 12.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
(cherry picked from commit d227dbe2721728c89acc6495bf657cb9fc4d3c69)

7 years agoglsl_to_tgsi: don't use the negate modifier in integer ops after bitcast
Marek Olšák [Sun, 3 Jul 2016 12:33:55 +0000 (14:33 +0200)]
glsl_to_tgsi: don't use the negate modifier in integer ops after bitcast

This bug is uncovered by glsl/lower_if_to_cond_assign.
I don't know if it can be reproduced in any other way.

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

7 years agomesa: set _NEW_BUFFERS when updating texture bound to current buffers
Ilia Mirkin [Fri, 8 Jul 2016 18:24:38 +0000 (14:24 -0400)]
mesa: set _NEW_BUFFERS when updating texture bound to current buffers

When a glTexImage call updates the parameters of a currently bound
framebuffer, we might miss out on revalidating whether it is complete.
Make sure to set _NEW_BUFFERS which will trigger the revalidation in
that case.

Also while we're at it, fix the fb parameter passed in to the eventual
RenderTexture call.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94148
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
(cherry picked from commit da7223ebdc82609a112aae24003bbdc154c170bf)

7 years agost/mesa: return appropriate mesa format for ETC texture formats
Ilia Mirkin [Fri, 8 Jul 2016 03:46:28 +0000 (23:46 -0400)]
st/mesa: return appropriate mesa format for ETC texture formats

Even when the backend driver does not support ETC formats, we handle the
decoding into an uncompressed backing texture. However as far as core
mesa is concerned, it's an ETC texture and we should return the relevant
ETC mesa format. This condition can get hit when using glTexStorage to
create the texture object.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 00d4315d37ec736fccfee50a402fa2a929054bde)

7 years agomesa: etc2 online compression is unsupported, don't attempt it
Ilia Mirkin [Fri, 8 Jul 2016 22:41:03 +0000 (18:41 -0400)]
mesa: etc2 online compression is unsupported, don't attempt it

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 8ee3cdde049d30095451f44080a9cd2d6e949459)

7 years agonvc0: fix the driver cb size when draw parameters are used
Samuel Pitoiset [Mon, 11 Jul 2016 19:26:25 +0000 (21:26 +0200)]
nvc0: fix the driver cb size when draw parameters are used

The size of the driver constant buffer for each stage should be 2048
and not 512 because it has been increased recently for buffers/images.
While we are at it, do the same change for indirect draws.

This fixes all ARB_shader_draw_parameters tests on GM107.

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

7 years agonvc0/ir: fix images indirect access on Fermi
Samuel Pitoiset [Sun, 10 Jul 2016 14:19:46 +0000 (16:19 +0200)]
nvc0/ir: fix images indirect access on Fermi

This fixes the following piglits:

arb_arrays_of_arrays-basic-imagestore-mixed-const-non-const-uniform-index
arb_arrays_of_arrays-basic-imagestore-mixed-const-non-const-uniform-index2

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