mesa.git
7 years agogbm: Add Android build support
Rob Herring [Wed, 4 May 2016 02:02:42 +0000 (21:02 -0500)]
gbm: Add Android build support

In order to use libgbm for gralloc, add it to the Android build.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
7 years agogbm: add Android gallium_dri.so library loading support
Rob Herring [Wed, 4 May 2016 02:02:41 +0000 (21:02 -0500)]
gbm: add Android gallium_dri.so library loading support

GBM needs the same special gallium_dri.so loading as EGL for Android, so
copy over the same hunk from the EGL code.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
7 years agogbm: split out source file to Makefile.sources
Rob Herring [Wed, 4 May 2016 02:02:40 +0000 (21:02 -0500)]
gbm: split out source file to Makefile.sources

In preparation to add Android build support, split out the source file
lists to Makefile.sources

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
[Emil Velikov: Whitespace cleanup.]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
7 years agoAndroid: Move setting DEFAULT_DRIVER_DIR to shared location
Rob Herring [Wed, 4 May 2016 02:02:39 +0000 (21:02 -0500)]
Android: Move setting DEFAULT_DRIVER_DIR to shared location

Move the defining of DEFAULT_DRIVER_DIR path to a common location so both
EGL and GBM can use it.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
7 years agoc11/threads: create mutexattrs only when needed
Emil Velikov [Sun, 24 Apr 2016 15:14:04 +0000 (16:14 +0100)]
c11/threads: create mutexattrs only when needed

If the mutexattrs are the default one can just pass NULL to
pthread_mutex_init. As the compiler does not know this detail it
unnecessarily creates/destroys the attrs.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure: added xcb to dri3 modules to pkg-conf
Andres Gomez [Fri, 20 May 2016 13:54:35 +0000 (16:54 +0300)]
configure: added xcb to dri3 modules to pkg-conf

This fixes a recent linking error in libvulkan_common

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Andres Gomez <agomez@igalia.com>
7 years agoglsl/linker: dvec3/dvec4 consume twice input vertex attributes
Juan A. Suarez Romero [Mon, 23 May 2016 08:46:42 +0000 (10:46 +0200)]
glsl/linker: dvec3/dvec4 consume twice input vertex attributes

From the GL 4.5 core spec, section 11.1.1 (Vertex Attributes):

"A program with more than the value of MAX_VERTEX_ATTRIBS
active attribute variables may fail to link, unless
device-dependent optimizations are able to make the program
fit within available hardware resources. For the purposes
of this test, attribute variables of the type dvec3, dvec4,
dmat2x3, dmat2x4, dmat3, dmat3x4, dmat4x3, and dmat4 may
count as consuming twice as many attributes as equivalent
single-precision types. While these types use the same number
of generic attributes as their single-precision equivalents,
implementations are permitted to consume two single-precision
vectors of internal storage for each three- or four-component
double-precision vector."

This commits makes dvec3, dvec4, dmat2x3, dmat2x4, dmat3, dmat3x4,
dmat4x3 and dmat4 consume twice as many attributes as equivalent
single-precision types.

v3: count doubles as consuming two attributes (Dave Airlie)
v4: make reference to spec (Michael Schellenberger Costa)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Antia Puentes <apuentes@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
7 years agoi965/fs: do not depend on std140 alignment rules for UBO loads
Francisco Jerez [Thu, 19 May 2016 10:50:01 +0000 (12:50 +0200)]
i965/fs: do not depend on std140 alignment rules for UBO loads

The previous implementation relied on the std140 alignment rules to
avoid handling misalignment in the case where we are loading more than
2 double components from a vector, which requires to emit a second load
message.

This alternative implementation deals with misalignment and is more
flexible going forward.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
7 years agonir: handle double-precision in fsign, fsat, fnot and frcp
Iago Toral Quiroga [Fri, 20 May 2016 07:38:20 +0000 (09:38 +0200)]
nir: handle double-precision in fsign, fsat, fnot and frcp

I think these are not strictly necessary since the floats in them
should be automatically promoted to doubles when operated with
double sources, but it makes things more explicit at least.

Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agonir: handle double-precision in fabs, frsq and fsqrt
Iago Toral Quiroga [Fri, 20 May 2016 07:12:28 +0000 (09:12 +0200)]
nir: handle double-precision in fabs, frsq and fsqrt

Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agoglsl/parser: handle multiple layout sections with AST nodes.
Dave Airlie [Mon, 23 May 2016 05:55:06 +0000 (15:55 +1000)]
glsl/parser: handle multiple layout sections with AST nodes.

For geometry/compute inputs and tess control outputs, we create
an AST node to keep track of some things. However if we have
multiple layout sections, we don't ever link the node into the AST.

This is because we create the node on the rightmost layout declaration
and don't pass it back in so it gets linked at the end of the parsing
of the rightmost.

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoglsl: allow layout qualifier overrides with ARB_shading_language_420pack
Dave Airlie [Mon, 23 May 2016 04:29:09 +0000 (14:29 +1000)]
glsl: allow layout qualifier overrides with ARB_shading_language_420pack

GLSL 4.20 allows overriding the layout qualifiers.

This helps fix:
GL45-CTS.shading_language_420pack.qualifier_override_layout

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agosubroutines: handle explicit indexes properly
Dave Airlie [Tue, 17 May 2016 04:44:47 +0000 (14:44 +1000)]
subroutines: handle explicit indexes properly

The code didn't deal with explicit function indexes properly.
It also handed out the indexes at link time, when we really
need them in the lowering pass to create the correct if ladder.

So this patch moves assigning the non-explicit indexes earlier,
fixes the lowering pass and the lookups to get the correct values.

This fixes a few of:
GL45-CTS.explicit_uniform_location.subroutine-index-*

Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agomesa/subroutines: fix reset on bindpipeline
Dave Airlie [Tue, 17 May 2016 06:25:02 +0000 (16:25 +1000)]
mesa/subroutines: fix reset on bindpipeline

Fixes:
GL45-CTS.shader_subroutine.subroutine_uniform_reset

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agomesa/subroutines: count number subroutines properly.
Dave Airlie [Tue, 17 May 2016 04:22:57 +0000 (14:22 +1000)]
mesa/subroutines: count number subroutines properly.

The code was implementing the ACTIVE_SUBROUTINE_UNIFORMS
incorrectly, using the number of types not the number of
uniforms. This is different than the locations as the
locations may be sparsly allocated.

This fixes:
GL43-CTS.shader_subroutine.four_subroutines_with_two_uniforms

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agomesa/subroutines: don't generate error in GetSubroutineIndex.
Dave Airlie [Tue, 17 May 2016 04:20:00 +0000 (14:20 +1000)]
mesa/subroutines: don't generate error in GetSubroutineIndex.

GLSL spec says this doesn't generate an error.

Fixes:
GL45-CTS.explicit_uniform_location.subroutine-loc

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoglsl/ast: for geom shaders allow stream flags in input flags.
Dave Airlie [Tue, 17 May 2016 03:47:59 +0000 (13:47 +1000)]
glsl/ast: for geom shaders allow stream flags in input flags.

This fixes:
GL45-CTS.shader_subroutine.subroutines_with_separate_shader_objects

Since we set the stream flags earlier on all geom shaders, we
shouldn't fall over later if we find one.

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoglsl/linker: skip inactive explicit locations.
Dave Airlie [Wed, 18 May 2016 07:06:41 +0000 (17:06 +1000)]
glsl/linker: skip inactive explicit locations.

This fixes a crash in:
GL45-CTS.explicit_uniform_location.subroutine-loc-negative-link-max-num-of-locations

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoglsl: fix subroutine uniform .length().
Dave Airlie [Tue, 17 May 2016 03:07:40 +0000 (13:07 +1000)]
glsl: fix subroutine uniform .length().

This fixes .length() on subroutine uniform arrays, if
we don't find the identifier normally, we look up the corresponding
subroutine identifier instead.

Fixes:
GL45-CTS.shader_subroutine.arrays_of_arrays_of_uniforms
GL45-CTS.shader_subroutine.arrayed_subroutine_uniforms

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoglsl/linker: link error on too many subroutine functions.
Dave Airlie [Tue, 17 May 2016 04:52:38 +0000 (14:52 +1000)]
glsl/linker: link error on too many subroutine functions.

This fixes:
GL45-CTS.explicit_uniform_location.subroutine-index-negative-link-max-num-of-indices

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoglsl: produce a linker error for a subroutine uniform with no functions.
Dave Airlie [Fri, 6 May 2016 01:37:06 +0000 (11:37 +1000)]
glsl: produce a linker error for a subroutine uniform with no functions.

If a subroutine uniform is declared with no functions backing it,
that isn't legal, so we should fail to link.

Fixes:
GL43-CTS.shader_subroutine.subroutine_uniform_wo_matching_subroutines

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoglsl: validate subroutine types match function signature.
Dave Airlie [Fri, 6 May 2016 01:28:40 +0000 (11:28 +1000)]
glsl: validate subroutine types match function signature.

This fixes:
GL43-CTS.shader_subroutine.subroutines_incompatible_with_subroutine_type

It just makes sure the signatures match as well as the return
types.

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoarb_shader_subroutine: check active subroutine limit
Dave Airlie [Tue, 28 Jul 2015 06:11:06 +0000 (07:11 +0100)]
arb_shader_subroutine: check active subroutine limit

_mesa_GetActiveSubroutineUniformiv needs to check
against the number of types here.

Noticed while playing with ogl conform.

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agonv30: don't assert when running out of registers
Ilia Mirkin [Sun, 22 May 2016 22:21:55 +0000 (18:21 -0400)]
nv30: don't assert when running out of registers

This happens with dEQP tests. The code doesn't at all protect against
this condition, so while unhandled, this is an expected situation.

Also avoid using more than the first 16 registers for nv3x vertex
programs.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonouveau: allow allocating non-object-backed buffers
Ilia Mirkin [Sun, 22 May 2016 20:35:28 +0000 (16:35 -0400)]
nouveau: allow allocating non-object-backed buffers

On nv30, for example, there is no hardware index buffer support. So all
of those will be created entirely in user memory.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agollvm/softpipe: Enable cull_distance as draw supports it.
Tobias Klausmann [Sun, 8 May 2016 20:44:10 +0000 (22:44 +0200)]
llvm/softpipe: Enable cull_distance as draw supports it.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agotgsi: remove culldist semantic.
Dave Airlie [Fri, 13 May 2016 05:47:34 +0000 (15:47 +1000)]
tgsi: remove culldist semantic.

This isn't used anymore in the tree, culldist's
are part of the clipdist semantic, we could in theory
rename it, but I'm not sure there is much point, and
I'd have to be careful with virgl.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agodraw: stop using CULLDIST semantic.
Dave Airlie [Fri, 13 May 2016 05:42:19 +0000 (15:42 +1000)]
draw: stop using CULLDIST semantic.

The way the HW works doesn't really fit with having
two semantics for this.

The GLSL compiler emits 2 vec4s and two properties,
this makes draw use those instead of CULLDIST semantics.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agovirgl: remove unused state_tracker/graw.h include
Emil Velikov [Mon, 16 May 2016 15:16:23 +0000 (16:16 +0100)]
virgl: remove unused state_tracker/graw.h include

Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agomesa/queryobject: return INVALID_VALUE if offset < 0 (v2)
Dave Airlie [Sun, 22 May 2016 21:20:50 +0000 (07:20 +1000)]
mesa/queryobject: return INVALID_VALUE if offset < 0 (v2)

This fixes:
GL45-CTS.direct_state_access.queries_errors

The ARB_direct_state_access spec agrees.

v2: move check down further (Ilia)

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agonvc0/ir: fix indirect access for images
Samuel Pitoiset [Sun, 22 May 2016 20:39:31 +0000 (22:39 +0200)]
nvc0/ir: fix indirect access for images

When the array doesn't start at 0 we need to account for su->tex.r.
While we are at it, make sure to avoid out of bounds access by masking
the index.

This fixes GL45-CTS.shading_language_420pack.binding_image_array.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reported-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonv30: reset the stencil mask when fast-clearing
Ilia Mirkin [Sun, 22 May 2016 18:34:28 +0000 (14:34 -0400)]
nv30: reset the stencil mask when fast-clearing

Apparently the stencil mask applies to clears on nv30/nv40. Reset it to
0xff before doing a stencil clear. This fixes gl-1.0-readpixsanity and
a number of other piglit tests.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonv30,nv50: add PIPE_SHADER_CAP_PREFERRED_IR support
Ilia Mirkin [Sun, 22 May 2016 18:05:36 +0000 (14:05 -0400)]
nv30,nv50: add PIPE_SHADER_CAP_PREFERRED_IR support

The mesa state tracker has recently started to query this.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonvc0: fix setting of tess_mode in various situations
Ilia Mirkin [Sat, 21 May 2016 20:16:50 +0000 (16:16 -0400)]
nvc0: fix setting of tess_mode in various situations

This fixes a lot of INVALID_VALUE errors reported by the card when
running dEQP tests.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
7 years agonv50/ir: fix prog info init
Ilia Mirkin [Sat, 21 May 2016 20:14:50 +0000 (16:14 -0400)]
nv50/ir: fix prog info init

Left over from the pre-mainline tess support. Adapt to use the new
defines.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
7 years agonvc0/ir: return 0 for gl_TessCoord.z for non-triangles modes
Ilia Mirkin [Sat, 21 May 2016 19:41:03 +0000 (15:41 -0400)]
nvc0/ir: return 0 for gl_TessCoord.z for non-triangles modes

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
7 years agomesa: Unlock mutex on error path.
Matt Turner [Sun, 22 May 2016 14:00:34 +0000 (07:00 -0700)]
mesa: Unlock mutex on error path.

Caught by Coverity (CID 1362021). Caused by commit 015f2207c.

7 years agoi965: remove redundant NULL check
Timothy Arceri [Sat, 21 May 2016 02:06:58 +0000 (12:06 +1000)]
i965: remove redundant NULL check

We would have segfaulted in the above code if prog could be NULL.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoanv/nir_apply_pipeline_layout: Pass the nir_src from the nir_tex_src
Eduardo Lima Mitev [Sat, 21 May 2016 07:24:03 +0000 (09:24 +0200)]
anv/nir_apply_pipeline_layout: Pass the nir_src from the nir_tex_src

nir_instr_rewrite_src() expects a nir_src and it is currently being fed a
nir_tex_src. This will crash something.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agonvc0: expose GLSL version 420 on GF100
Samuel Pitoiset [Tue, 26 Apr 2016 21:23:19 +0000 (23:23 +0200)]
nvc0: expose GLSL version 420 on GF100

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonvc0: enable ARB_shader_image_load_store on GF100
Samuel Pitoiset [Tue, 26 Apr 2016 21:23:12 +0000 (23:23 +0200)]
nvc0: enable ARB_shader_image_load_store on GF100

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonvc0/ir: add a lowering pass for surfaces on Fermi
Samuel Pitoiset [Sun, 8 May 2016 17:13:15 +0000 (19:13 +0200)]
nvc0/ir: add a lowering pass for surfaces on Fermi

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonvc0/ir: add emission for SULDB and SUSTx
Samuel Pitoiset [Wed, 27 Apr 2016 17:14:59 +0000 (19:14 +0200)]
nvc0/ir: add emission for SULDB and SUSTx

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonvc0/ir: add emission for OP_SULEA
Samuel Pitoiset [Wed, 27 Apr 2016 17:14:35 +0000 (19:14 +0200)]
nvc0/ir: add emission for OP_SULEA

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonv50/ir: fix tex constraints for surface coords on Fermi
Samuel Pitoiset [Wed, 27 Apr 2016 16:27:10 +0000 (18:27 +0200)]
nv50/ir: fix tex constraints for surface coords on Fermi

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonv50/ir: use moveSources to condense sources
Ilia Mirkin [Sun, 31 Jan 2016 03:08:06 +0000 (22:08 -0500)]
nv50/ir: use moveSources to condense sources

This makes sure that rIndirectSrc and other things stay updated.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agonvc0: bind images on fragment and compute shaders for Fermi
Samuel Pitoiset [Wed, 27 Apr 2016 16:25:33 +0000 (18:25 +0200)]
nvc0: bind images on fragment and compute shaders for Fermi

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonvc0/ir: don't check the format for surface stores on Kepler
Samuel Pitoiset [Sat, 21 May 2016 14:28:09 +0000 (16:28 +0200)]
nvc0/ir: don't check the format for surface stores on Kepler

Initially to make sure the format doesn't mismatch and won't produce
out-of-bounds access, we checked that both formats have exactly the same
number of bytes, but this should not be checked for type stores.

This fixes serious rendering issues in the UE4 demos (tested with
realistic and reflections).

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonv50/ir: fix a comment in canDualIssue()
Samuel Pitoiset [Sat, 21 May 2016 14:13:48 +0000 (16:13 +0200)]
nv50/ir: fix a comment in canDualIssue()

Trivial.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonv50/ir: fix SUSTx constraints on Kepler
Samuel Pitoiset [Thu, 19 May 2016 22:52:26 +0000 (00:52 +0200)]
nv50/ir: fix SUSTx constraints on Kepler

To prevent out-of-bounds access and format mismatch we add a predicate
on sustp, but we have to account for it when the sources are condensed
because a predicate is a source. Using the range 3:6 will only condense
the input data and it's always the case. This also fixes constraints
when an indirect access is used.

This ensures that sources are correctly aligned.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agoi965: Just read the existing tally on EndTransformFeedback if paused.
Kenneth Graunke [Mon, 9 May 2016 05:48:02 +0000 (22:48 -0700)]
i965: Just read the existing tally on EndTransformFeedback if paused.

If the transform feedback object is paused when ending, then there are
no new snapshots to add to the tally.  In fact, we haven't written a
starting snapshot, so we'd best not try and compute (end - start).

Just load the existing tally so we can convert it to the number of
vertices written and store it to the final result location.

This is the Haswell+ equivalent of the previous commit.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
7 years agoi965: Don't write a counter snapshot on EndTransformFeedback if paused.
Kenneth Graunke [Mon, 9 May 2016 05:48:02 +0000 (22:48 -0700)]
i965: Don't write a counter snapshot on EndTransformFeedback if paused.

If the transform feedback object is paused, then we've already written
an ending counter snapshot.  We don't want to write another one.

This fixes assertions in GL33-CTS.transform_feedback.api_errors_test,
which calls EndTransformfeedback after PauseTransformFeedback.  On the
next BeginTransformFeedback, we tried to tally up the results, and saw
an odd number of snapshots (due to the double-end), and tripped an
assertion.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
7 years agomesa: Call TransformFeedback driver hooks before setting flags.
Kenneth Graunke [Mon, 9 May 2016 05:45:01 +0000 (22:45 -0700)]
mesa: Call TransformFeedback driver hooks before setting flags.

This way, the driver's EndTransformFeedback() hook can tell whether the
transform feedback operation was paused.  It's also convenient to have
Paused remain false until the driver's PauseTransformFeedback hook
finishes.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
7 years agonir: Fix crash in nir_lower_wpos_center().
Kenneth Graunke [Fri, 20 May 2016 23:29:44 +0000 (16:29 -0700)]
nir: Fix crash in nir_lower_wpos_center().

Otherwise we rewrote the fadd to use itself, causing crashes in
validation.  Instead, start after the last use like we should.

A brown paper bag fix.  Fixes crashes in several Vulkan tests.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agonir: remove dead glsl variables before lowering io.
Dave Airlie [Fri, 20 May 2016 20:48:05 +0000 (06:48 +1000)]
nir: remove dead glsl variables before lowering io.

For cull distance GLSL will let unsized unused arrays get
into the backend, we should nuke those straight away, to
save caring about them later.

This fixes:
arb_separate_shader_objects/linker/large-number-of-unused-varyings
as a side effect (even without culling changes).

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agospirv: Handle the PixelCenterInteger execution mode.
Kenneth Graunke [Wed, 18 May 2016 18:06:08 +0000 (11:06 -0700)]
spirv: Handle the PixelCenterInteger execution mode.

This isn't allowed by Vulkan, but might be useful someday for
SPIR-V in OpenGL (if that ever becomes a thing).  It's easy enough
to hook up, and as precedent, we already do so for OriginLowerLeft.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoi965: Delete dead dFdy flipping code.
Kenneth Graunke [Wed, 18 May 2016 17:35:54 +0000 (10:35 -0700)]
i965: Delete dead dFdy flipping code.

Rob's nir_lower_wpos_ytransform() pass flips dFdy in the opposite case
of what I expected, so we always take the negate_value case.  It doesn't
really matter.

v2: Write src0 before src1 in ADD instructions (requested by Matt).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agoi965: Delete brw_wm_prog_key::render_to_fbo and drawable_height.
Kenneth Graunke [Tue, 17 May 2016 10:40:11 +0000 (03:40 -0700)]
i965: Delete brw_wm_prog_key::render_to_fbo and drawable_height.

Now that we handle flipping and other gl_FragCoord transformations
via a uniform, these key fields have no users.

This patch actually eliminates the associated recompiles.  The Tomb
Raider benchmark's minimum FPS increases from ~1 FPS to a reasonable
number.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agoi965, anv: Use NIR FragCoord re-center and y-transform passes.
Kenneth Graunke [Tue, 17 May 2016 08:52:16 +0000 (01:52 -0700)]
i965, anv: Use NIR FragCoord re-center and y-transform passes.

This handles gl_FragCoord transformations and other window system vs.
user FBO coordinate system flipping by multiplying/adding uniform
values, rather than recompiles.

This is much better because we have no decent way to guess whether
the application is going to use a shader with the window system FBO
or a user FBO, much less the drawable height.  This led to a lot of
recompiles in many applications.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agonir: Add a simple nir_lower_wpos_center() pass for Vulkan drivers.
Kenneth Graunke [Wed, 18 May 2016 18:38:32 +0000 (11:38 -0700)]
nir: Add a simple nir_lower_wpos_center() pass for Vulkan drivers.

nir_lower_wpos_ytransform() is great for OpenGL, which allows
applications to choose whether their coordinate system's origin is
upper left/lower left, and whether the pixel center should be on
integer/half-integer boundaries.

Vulkan, however, has much simpler requirements: the pixel center
is always half-integer, and the origin is always upper left.  No
coordinate transform is needed - we just need to add <0.5, 0.5>.
This means that we can avoid using (and setting up) a uniform.

I thought about adding more options to nir_lower_wpos_ytransform(),
but making a new pass that never even touched uniforms seemed simpler.

v2: Use normal iterator rather than _safe variant (noticed by Matt).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Rob Clark <robdclark@gmail.com>
7 years agonir: Don't use ffma in nir_lower_wpos_ytransform().
Kenneth Graunke [Wed, 18 May 2016 19:14:02 +0000 (12:14 -0700)]
nir: Don't use ffma in nir_lower_wpos_ytransform().

ffma is an explicitly fused multiply add with higher precision.
The optimizer will take care of promoting mul/add to fma when
it's beneficial to do so.

This fixes failures on Gen4-5 when using this pass, as those platforms
don't actually implement fma().

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agonir: Handle fddy_fine and fddy_coarse in nir_lower_wpos_ytransform.
Kenneth Graunke [Wed, 18 May 2016 17:32:33 +0000 (10:32 -0700)]
nir: Handle fddy_fine and fddy_coarse in nir_lower_wpos_ytransform.

These also need flipping!

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Rob Clark <robdclark@gmail.com>
7 years agonir: Make lower_wpos_ytransform_block a void function.
Kenneth Graunke [Wed, 18 May 2016 18:19:00 +0000 (11:19 -0700)]
nir: Make lower_wpos_ytransform_block a void function.

The return value was used for the old nir_foreach_block callback system,
but at this point it no longer means anything.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Rob Clark <robdclark@gmail.com>
7 years agonir: Make nir_lower_wpos_ytransform() match FragCoord by location.
Kenneth Graunke [Wed, 18 May 2016 16:31:49 +0000 (09:31 -0700)]
nir: Make nir_lower_wpos_ytransform() match FragCoord by location.

gl_FragCoord is a shader input with location == VARYING_SLOT_POS.
ARB_fragment_programs have an equivalent input at VARYING_SLOT_POS,
but it isn't called gl_FragCoord.  We do want to transform it.

Matching by location guarantees we catch both.

Fixes several fp tests on a branch which uses this pass on i965.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Rob Clark <robdclark@gmail.com>
7 years agonir: Add interp_var_at_offset flipping.
Kenneth Graunke [Tue, 17 May 2016 10:30:58 +0000 (03:30 -0700)]
nir: Add interp_var_at_offset flipping.

The Y-offset needs flipping as well, similar to ddy.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Rob Clark <robdclark@gmail.com>
7 years agonir: Fix fddy swizzles in nir_lower_wpos_ytransform().
Kenneth Graunke [Wed, 18 May 2016 06:16:14 +0000 (23:16 -0700)]
nir: Fix fddy swizzles in nir_lower_wpos_ytransform().

The original value might have been swizzled.  That's taken care of in
the fmul source - we don't want to reswizzle it again.

Fixes validation failures in glsl-derivs-varyings on a branch of mine
which uses this pass in i965.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Rob Clark <robdclark@gmail.com>
7 years agonir: Fix wpos_ytransform lowering state_slot swizzle.
Kenneth Graunke [Tue, 17 May 2016 10:05:56 +0000 (03:05 -0700)]
nir: Fix wpos_ytransform lowering state_slot swizzle.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Rob Clark <robdclark@gmail.com>
7 years agoi965: Fix brw_regs_equal() for NaN and positive/negative zero.
Kenneth Graunke [Tue, 17 May 2016 00:28:19 +0000 (17:28 -0700)]
i965: Fix brw_regs_equal() for NaN and positive/negative zero.

We'd like the comparisons to mean "the exact same bits".  Comparing
doubles won't do that for NaN values or positive vs. negative zero.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agovirgl: handle cull distance cap.
Dave Airlie [Fri, 20 May 2016 20:19:29 +0000 (06:19 +1000)]
virgl: handle cull distance cap.

Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agovirgl: Add missing texture transfer_inline_write
Rob Herring [Fri, 20 May 2016 17:51:00 +0000 (12:51 -0500)]
virgl: Add missing texture transfer_inline_write

transfer_inline_write cannot be NULL and the virgl renderer doesn't support
inline writes for textures, so add the default version.

This fixes a crash in st_TexSubImage since commit fb9fe352ea41 ("st/mesa:
use transfer_inline_write for memcpy TexSubImage path").

Cc: Marek Olšák <marek.olsak@amd.com>
Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoanv: Merge in my TODO list items
Kristian Høgsberg Kristensen [Fri, 20 May 2016 17:35:57 +0000 (10:35 -0700)]
anv: Merge in my TODO list items

Signed-off-by: Kristian Høgsberg Kristensen <krh@bitplanet.net>
7 years agomesa: Replace uses of Shared->Mutex with hash-table mutexes
Matt Turner [Thu, 30 Jul 2015 21:31:04 +0000 (14:31 -0700)]
mesa: Replace uses of Shared->Mutex with hash-table mutexes

We were locking the Shared->Mutex and then using calling functions like
_mesa_HashInsert that do additional per-hash-table locking internally.

Instead just lock each hash-table's mutex and use functions like
_mesa_HashInsertLocked and the new _mesa_HashRemoveLocked.

In order to do this, we need to remove the locking from
_mesa_HashFindFreeKeyBlock since it will always be called with the
per-hash-table lock taken.

Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Brian Paul <brianp@vmware.com>
7 years agohash: Add _mesa_HashRemoveLocked() function.
Matt Turner [Thu, 30 Jul 2015 21:24:07 +0000 (14:24 -0700)]
hash: Add _mesa_HashRemoveLocked() function.

Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Brian Paul <brianp@vmware.com>
7 years agoi965: Pass nir_src/nir_dest by reference.
Matt Turner [Thu, 19 May 2016 21:43:23 +0000 (14:43 -0700)]
i965: Pass nir_src/nir_dest by reference.

Cuts 6K of .text.

   text    data     bss     dec     hex filename
5772372  264648   29320 6066340  5c90a4 lib/i965_dri.so before
5766074  264648   29320 6060042  5c780a lib/i965_dri.so after

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoglsl: Guard against NULL dereference
Mark Janes [Fri, 20 May 2016 15:50:39 +0000 (08:50 -0700)]
glsl: Guard against NULL dereference

This trivially corrects mesa 3ca1c221, which introduced a check that
crashes when a match is not found.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005
Fixes: piglit.spec.glsl-1_50.compiler.interface-blocks-name-reused-globally-4.vert
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
7 years agoanv: Enable textureCompressionASTC_LDR on Gen9+
Nanley Chery [Wed, 18 May 2016 17:50:48 +0000 (10:50 -0700)]
anv: Enable textureCompressionASTC_LDR on Gen9+

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoanv/format: Reorder ASTC mappings to match ISL enum ordering
Nanley Chery [Wed, 18 May 2016 17:40:39 +0000 (10:40 -0700)]
anv/format: Reorder ASTC mappings to match ISL enum ordering

Keep the lists consistent for ease of use.

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agogenxml: Expand SKL's SurfaceFormat field width for ASTC
Nanley Chery [Wed, 18 May 2016 17:45:30 +0000 (10:45 -0700)]
genxml: Expand SKL's SurfaceFormat field width for ASTC

In the expanded field, only ASTC format enums have the MSB set to 1.
Expanding the field width makes the process of handling these formats
identical to the way other formats are handled.

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoisl: Handle npot ASTC block dimensions on Gen9+
Nanley Chery [Wed, 18 May 2016 23:19:23 +0000 (16:19 -0700)]
isl: Handle npot ASTC block dimensions on Gen9+

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoisl: Add 2D ASTC format layouts and enums
Nanley Chery [Wed, 18 May 2016 17:43:42 +0000 (10:43 -0700)]
isl: Add 2D ASTC format layouts and enums

Also, make changes needed for successful compilation and registration
as a texture compression mode.

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agomesa: Build EGL without X11 headers after interop patchset
Youry Metlitsky [Wed, 27 Apr 2016 22:33:14 +0000 (22:33 +0000)]
mesa: Build EGL without X11 headers after interop patchset

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agonir/validate: assume() that hashtable entry exists
Rob Clark [Wed, 18 May 2016 15:43:15 +0000 (11:43 -0400)]
nir/validate: assume() that hashtable entry exists

At this point, it would require a logic error in nir_validate to not
have already populated this hashtable entry, but coverity doesn't
realize that:

CID 1265547 (#1 of 1): Dereference null return value (NULL_RETURNS)3.
dereference: Dereferencing a null pointer entry.

CID 1271039 (#1 of 1): Dereference null return value (NULL_RETURNS)3.
dereference: Dereferencing a null pointer entry.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agonir: coverity unitialized pointer read
Rob Clark [Wed, 18 May 2016 14:38:40 +0000 (10:38 -0400)]
nir: coverity unitialized pointer read

Not sure how coverity arrives at the conclusion that we can read comp[j]
unitialized (around line 204), other than not being aware that ncomp is
greater than 1 so it won't underflow in the 'if (tex->is_array)' case.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agonir: coverity sign-extension fix
Rob Clark [Wed, 18 May 2016 14:17:02 +0000 (10:17 -0400)]
nir: coverity sign-extension fix

Not 100% sure, but I think being an unsigned literal will help:

CID 1358505 (#1 of 1): Unintended sign extension
(SIGN_EXTENSION)sign_extension: Suspicious implicit sign extension:
load1->def.num_components with type unsigned char (8 bits, unsigned) is
promoted in load1->def.num_components * (load1->def.bit_size / 8) to
type int (32 bits, signed), then sign-extended to type unsigned long (64
bits, unsigned). If load1->def.num_components * (load1->def.bit_size /
8) is greater than 0x7FFFFFFF, the upper bits of the result will all be
1.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agonir/glsl_to_nir: quell some uninit_member coverity errors
Rob Clark [Wed, 18 May 2016 14:58:29 +0000 (10:58 -0400)]
nir/glsl_to_nir: quell some uninit_member coverity errors

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Acked-by: Matt Turner <mattst88@gmail.com>
7 years agofreedreno/ir3: need to lower fmod too
Rob Clark [Tue, 17 May 2016 13:52:24 +0000 (09:52 -0400)]
freedreno/ir3: need to lower fmod too

Signed-off-by: Rob Clark <robclark@freedesktop.org>
7 years agoi965: Fix strerror error code sign
Mark Janes [Thu, 19 May 2016 20:42:16 +0000 (13:42 -0700)]
i965: Fix strerror error code sign

This trivial fix to error-handling corrects the sign of drm error
codes before passing them to strerror.

Identified by Coverity: CID1358581

7 years agonir/spirv: Handle the NonReadable decoration on struct members
Jason Ekstrand [Fri, 20 May 2016 03:58:32 +0000 (20:58 -0700)]
nir/spirv: Handle the NonReadable decoration on struct members

7 years agoanv/pipeline: Bounds-check resource indices when robuts_buffer_access is enabled
Jason Ekstrand [Thu, 19 May 2016 04:41:05 +0000 (21:41 -0700)]
anv/pipeline: Bounds-check resource indices when robuts_buffer_access is enabled

7 years agoanv/pipeline: Only do buffer bounds checks if robustBufferAccess is enabled
Jason Ekstrand [Sat, 14 May 2016 21:55:39 +0000 (14:55 -0700)]
anv/pipeline: Only do buffer bounds checks if robustBufferAccess is enabled

7 years agoanv/apply_dynamic_offsets: Use rewrite_src instead of a regular assignment
Jason Ekstrand [Sat, 14 May 2016 21:53:11 +0000 (14:53 -0700)]
anv/apply_dynamic_offsets: Use rewrite_src instead of a regular assignment

Originally we removed the instruction, changed the source, and then
re-inserted it.  This works, but nir_instr_rewrite_src is a bit more
obviously correct.

7 years agoanv/device: Add a boolean for robust buffer access
Jason Ekstrand [Sat, 14 May 2016 21:52:36 +0000 (14:52 -0700)]
anv/device: Add a boolean for robust buffer access

7 years agoanv: Add a TODO file
Jason Ekstrand [Fri, 20 May 2016 03:08:55 +0000 (20:08 -0700)]
anv: Add a TODO file

7 years agoglsl: handle same struct redeclaration (v2)
Dave Airlie [Tue, 17 May 2016 00:58:53 +0000 (10:58 +1000)]
glsl: handle same struct redeclaration (v2)

This works around a bug in older version of UE4, where a shader
defines the same structure twice. Although we aren't sure this is correct
GLSL (it most likely isn't) there are enough UE4 based things out there
we should deal with this.

This drops the error to a warning if the struct names and contents match.

v1.1: do better C++ on record_compare declaration (Rob)
v2: restrict this to desktop GL only (Ian)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoi965/fs: Recognize and emit ld_lz, sample_lz, sample_c_lz.
Matt Turner [Wed, 4 May 2016 22:37:02 +0000 (15:37 -0700)]
i965/fs: Recognize and emit ld_lz, sample_lz, sample_c_lz.

Ken suggested instead of a big and complicated optimization pass, to
just recognize the operations here. It's certainly less code and a lot
prettier, but it seems to actually perform worse for currently unknown
reasons.

total instructions in shared programs: 8923452 -> 8904108 (-0.22%)
instructions in affected programs: 814563 -> 795219 (-2.37%)
helped: 3336
HURT: 10

total cycles in shared programs: 66970734 -> 66651476 (-0.48%)
cycles in affected programs: 10582686 -> 10263428 (-3.02%)
helped: 2438
HURT: 691

total spills in shared programs: 1811 -> 1789 (-1.21%)
spills in affected programs: 85 -> 63 (-25.88%)
helped: 4

total fills in shared programs: 3143 -> 3109 (-1.08%)
fills in affected programs: 167 -> 133 (-20.36%)
helped: 4

LOST:   2
GAINED: 36

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965: Add infrastucture for sample lod-zero operations.
Matt Turner [Wed, 4 May 2016 22:46:45 +0000 (15:46 -0700)]
i965: Add infrastucture for sample lod-zero operations.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965/fs: Add and use get_nir_src_imm().
Matt Turner [Wed, 4 May 2016 22:10:25 +0000 (15:10 -0700)]
i965/fs: Add and use get_nir_src_imm().

The next patch wants to inspect the LOD argument and do something
different if it's 0.0f. But at that point we've emitted a MOV for it and
we just have a register to look at.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agonvc0: account for shader-allocated local memory needs
Ilia Mirkin [Thu, 19 May 2016 01:27:33 +0000 (21:27 -0400)]
nvc0: account for shader-allocated local memory needs

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
7 years agonv50/ir: treat addresses as local
Ilia Mirkin [Wed, 18 May 2016 00:44:21 +0000 (20:44 -0400)]
nv50/ir: treat addresses as local

Address registers are always loaded right before use. Don't treat them
as "global", which will cause them to be put into the function's
linkage, and will make the register allocator hold onto that
register until the end of the function.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agoswr: [rasterizer] utility functions for shared libs
Tim Rowley [Fri, 13 May 2016 00:12:55 +0000 (18:12 -0600)]
swr: [rasterizer] utility functions for shared libs

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>