mesa.git
8 years agostate_tracker: Initialize the draw context only when needed.
Eric Anholt [Tue, 2 Aug 2016 19:28:27 +0000 (12:28 -0700)]
state_tracker: Initialize the draw context only when needed.

It's only used for rarely-used deprecated GL features
(feedback/rasterpos), so we can skip the memory allocation and
initialization for it most of the time.

Saves about 659k (out of 1605k) of maximum memory size according to massif
on simulated vc4 glsl-algebraic-add-add-1

Reviewed-by: Brian Paul <brianp@vmware.com>
8 years agovc4: Move scalarizing and some lowering to link time.
Eric Anholt [Wed, 3 Aug 2016 21:01:03 +0000 (14:01 -0700)]
vc4: Move scalarizing and some lowering to link time.

This works out to be a wash in terms of memory usage: We use more memory
to store the separate ALU instructions, but we optimize out a lot of code
as well.  The main result, though, is that we do more of our work at link
time rather than draw time.

8 years agovc4: Avoid VS shader recompiles by keeping a set of FS inputs seen so far.
Eric Anholt [Wed, 3 Aug 2016 18:55:55 +0000 (11:55 -0700)]
vc4: Avoid VS shader recompiles by keeping a set of FS inputs seen so far.

We don't want to bake the whole array into the FS key, because of the
hashing overhead.  But we can keep a set of the arrays seen, and use a
pointer to the copy in as the array's proxy.

Between this and the previous patch, gl-1.0-blend-func now passes on
hardware, where previously it was filling the 256MB CMA area with shaders
and OOMing.

Drops 712 shaders from shader-db.

8 years agovc4: Don't recompile the CS when the FS changes.
Eric Anholt [Wed, 3 Aug 2016 18:57:53 +0000 (11:57 -0700)]
vc4: Don't recompile the CS when the FS changes.

The compiled_fs_id is a proxy for the vc4->prog.fs->input_slots[], but
only the VS dereferences it.

Drops 754 shaders from shader-db.

8 years agovc4: Move FS inputs setup out to a helper function.
Eric Anholt [Wed, 3 Aug 2016 18:39:59 +0000 (11:39 -0700)]
vc4: Move FS inputs setup out to a helper function.

It's a pretty big block, and I was about to make it bigger.

8 years agonir: Make nir_opt_remove_phis see through moves.
Kenneth Graunke [Fri, 29 Jul 2016 08:29:12 +0000 (01:29 -0700)]
nir: Make nir_opt_remove_phis see through moves.

I found a shader in Tales of Maj'Eyal that contains:

        if ssa_21 {
                block block_1:
                /* preds: block_0 */
                ...instructions that prevent the select peephole...
                vec1 32 ssa_23 = imov ssa_4
                vec1 32 ssa_24 = imov ssa_4.y
                vec1 32 ssa_25 = imov ssa_4.z
                /* succs: block_3 */
        } else {
                block block_2:
                /* preds: block_0 */
                vec1 32 ssa_26 = imov ssa_4
                vec1 32 ssa_27 = imov ssa_4.y
                vec1 32 ssa_28 = imov ssa_4.z
                /* succs: block_3 */
        }
        block block_3:
        /* preds: block_1 block_2 */
        vec1 32 ssa_29 = phi block_1: ssa_23, block_2: ssa_26
        vec1 32 ssa_30 = phi block_1: ssa_24, block_2: ssa_27
        vec1 32 ssa_31 = phi block_1: ssa_25, block_2: ssa_28

Here, copy propagation will bail because phis cannot perform swizzles,
and CSE won't do anything because there is no dominance relationship
between the imovs.  By making nir_opt_remove_phis handle identical moves,
we can eliminate the phis and rewrite everything to use ssa_4 directly,
so all the moves become dead and get eliminated.

I don't think we need to check "exact" - just the alu sources.
Presumably phi sources should match in their exactness.

On Broadwell:

total instructions in shared programs: 11639872 -> 11638535 (-0.01%)
instructions in affected programs: 134222 -> 132885 (-1.00%)
helped: 338
HURT: 0

v2: Fix return value to be NULL, not false (caught by Iago).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agonir: Make nir_alu_srcs_equal non-static.
Kenneth Graunke [Fri, 29 Jul 2016 08:29:11 +0000 (01:29 -0700)]
nir: Make nir_alu_srcs_equal non-static.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agonir: Turn imov/fmov of undef into undef.
Kenneth Graunke [Fri, 29 Jul 2016 08:29:10 +0000 (01:29 -0700)]
nir: Turn imov/fmov of undef into undef.

On Broadwell:

total instructions in shared programs: 11640214 -> 11639872 (-0.00%)
instructions in affected programs: 17744 -> 17402 (-1.93%)
helped: 78
HURT: 0

total spills in shared programs: 2924 -> 2922 (-0.07%)
spills in affected programs: 104 -> 102 (-1.92%)
helped: 1
HURT: 0

total fills in shared programs: 4394 -> 4389 (-0.11%)
fills in affected programs: 237 -> 232 (-2.11%)
helped: 1
HURT: 0

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agoi965: Use a separate register for every access to an SSA undef.
Kenneth Graunke [Fri, 29 Jul 2016 08:29:09 +0000 (01:29 -0700)]
i965: Use a separate register for every access to an SSA undef.

Previously, we allocated a new VGRF for every undefined definition.
Instead, this patch makes us allocate a new VGRF for every use of an
undefined definition.  This makes sure that undefined values are
fully independent of one another, and have live ranges limited to
their single use.  This allows register coalescing to combine the
source and destination of MOVs from undefined sources, eliminating
the MOV altogether.

On Broadwell:

total instructions in shared programs: 11641187 -> 11640214 (-0.01%)
instructions in affected programs: 70199 -> 69226 (-1.39%)
helped: 213
HURT: 1

v2: Add a comment (based on Iago's suggested one).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agovl/dri3: Destroy Present event context when destroying drawable v2
Michel Dänzer [Thu, 28 Jul 2016 08:52:11 +0000 (17:52 +0900)]
vl/dri3: Destroy Present event context when destroying drawable v2

Without this, the X server may accumulate stale Present event contexts
if a client performs several video decoding sessions using the same
window.

v2: Based on Chris Wilson's review:
* Use xcb_discard_reply() instead of free(xcb_request_check())

Reviewed-and-Tested-by: Leo Liu <leo.liu@amd.com>
8 years agoloader/dri3: Destroy Present event context when destroying drawable v2
Michel Dänzer [Thu, 28 Jul 2016 08:44:49 +0000 (17:44 +0900)]
loader/dri3: Destroy Present event context when destroying drawable v2

Without this, the X server may accumulate stale Present event contexts
if a client ends up creating and destroying DRI drawables for the same
window.

v2: Based on Chris Wilson's review:
* Use xcb_present_select_input_checked so that protocol errors
  generated by old X servers can be handled gracefully
* Use xcb_discard_reply() instead of free(xcb_request_check())

8 years agogbm: Correct bo_import documentation (trivial)
Ben Widawsky [Tue, 2 Aug 2016 00:18:48 +0000 (17:18 -0700)]
gbm: Correct bo_import documentation (trivial)

Missed here:
commit a43d286ef7ff65087b1f051d071b829ca7b02073
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Fri Mar 28 10:17:11 2014 -0700

    gbm: Add import from fd

Cc: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
8 years agovc4: Avoid generating a custom shader per level in glGenerateMipmaps().
Eric Anholt [Tue, 2 Aug 2016 23:01:34 +0000 (16:01 -0700)]
vc4: Avoid generating a custom shader per level in glGenerateMipmaps().

We were baking in the LOD of the source level to each shader.  Instead,
pass it in as a uniform -- this requires storing it to a temp register,
but that's better than compiling a ton of separate shaders:

total instructions in shared programs: 115032 -> 115036 (0.00%)
instructions in affected programs:     96 -> 100 (4.17%)
LOST:                                  572

8 years agovc4: Tell valgrind about BO allocations from mmap time to destroy.
Eric Anholt [Tue, 2 Aug 2016 22:01:59 +0000 (15:01 -0700)]
vc4: Tell valgrind about BO allocations from mmap time to destroy.

This helps in debugging memory pressure.  It would be nice if we could
tell valgrind about it all the way from allocation time to destroy, but we
need a pointer to hand to VALGRIND_MALLOCLIKE_BLOCK.

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

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
8 years agovc4: Fix leak of the bo_handles table.
Eric Anholt [Tue, 2 Aug 2016 17:57:01 +0000 (10:57 -0700)]
vc4: Fix leak of the bo_handles table.

8 years agovc4: Fix handling of UBO range offsets.
Eric Anholt [Wed, 27 Jul 2016 21:58:43 +0000 (14:58 -0700)]
vc4: Fix handling of UBO range offsets.

The ranges are in units of bytes, not dwords.  This wasn't caught by
piglit tests because ttn tends to make one big uniform file, so we only
had one UBO range with a src and dst offset of 0.

8 years agonir: Allow opt_peephole_select to work on empty blocks.
Eric Anholt [Thu, 28 Jul 2016 00:26:59 +0000 (17:26 -0700)]
nir: Allow opt_peephole_select to work on empty blocks.

nir_opt_peephole_select has the job of removing IF statements with no side
effects.  However, if the IF statement's successor didn't have any
instructions in it, we were skipping it, which occurred in mupen64 on vc4
with glsl_to_nir enabled:

instructions in affected programs:     6134 -> 4120 (-32.83%)
total uniforms in shared programs: 38268 -> 38219 (-0.13%)

No changes on Haswell shader-db.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
8 years agovc4: Dump NIR at shader state creation time as well.
Eric Anholt [Wed, 27 Jul 2016 00:21:46 +0000 (17:21 -0700)]
vc4: Dump NIR at shader state creation time as well.

I keep wanting to see this version of the NIR.

8 years agor600g: use last_gfx_fence like radeonsi
Marek Olšák [Thu, 14 Jul 2016 23:06:58 +0000 (01:06 +0200)]
r600g: use last_gfx_fence like radeonsi

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agogallium/radeon: move last_gfx_fence from radeonsi to common code
Marek Olšák [Thu, 14 Jul 2016 22:39:38 +0000 (00:39 +0200)]
gallium/radeon: move last_gfx_fence from radeonsi to common code

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agoradeonsi: skip unnecessary si_update_shaders calls
Marek Olšák [Tue, 2 Aug 2016 09:51:21 +0000 (11:51 +0200)]
radeonsi: skip unnecessary si_update_shaders calls

Small decrease in draw call overhead.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agoradeonsi: print the command line to VM fault reports (v2)
Marek Olšák [Sat, 30 Jul 2016 12:57:20 +0000 (14:57 +0200)]
radeonsi: print the command line to VM fault reports (v2)

v2: rebase on top of Brian's commit

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agoddebug: print the command line to all logs (v2)
Marek Olšák [Sat, 30 Jul 2016 12:56:28 +0000 (14:56 +0200)]
ddebug: print the command line to all logs (v2)

for piglit with the pipelined hang detection mode

v2: rebase on top of Brian's commit

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agoddebug: don't use fmemopen on non-Linux OS
Marek Olšák [Sat, 30 Jul 2016 21:54:06 +0000 (23:54 +0200)]
ddebug: don't use fmemopen on non-Linux OS

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

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agoradeonsi: don't set the last parameter component of llvm.AMDGPU.cube
Marek Olšák [Sat, 30 Jul 2016 14:32:32 +0000 (16:32 +0200)]
radeonsi: don't set the last parameter component of llvm.AMDGPU.cube

LLVM doesn't use it.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agoradeonsi: use llvm.amdgcn.cube* if available
Marek Olšák [Sat, 30 Jul 2016 14:28:20 +0000 (16:28 +0200)]
radeonsi: use llvm.amdgcn.cube* if available

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agoradeonsi: use llvm.amdgcn.rsq.f64 if available
Marek Olšák [Sat, 30 Jul 2016 14:23:48 +0000 (16:23 +0200)]
radeonsi: use llvm.amdgcn.rsq.f64 if available

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agoradeonsi: use v_mad_f32 for fma
Marek Olšák [Tue, 26 Jul 2016 20:34:03 +0000 (22:34 +0200)]
radeonsi: use v_mad_f32 for fma

v_fma_f32 runs at FP64 rate (= slow). Alien Isolation and F1 2015 seem
to use fma for all d3d multiply-add instructions, which is silly.

This tries to restore performance for those games.

The main difference between v_mad_f32 and v_fma_f32 is that v_mad doesn't
support denormals, which we don't enable anyway, because they are slow too.

Also, there is code size reduction:
  Totals from affected shaders:
  VGPRS: 109796 -> 109808 (0.01 %)
  Spilled SGPRs: 29995 -> 30022 (0.09 %)
  Spilled VGPRs: 12 -> 13 (8.33 %) <-- it's just one shader going from 12 to 13
  Code Size: 6667596 -> 6476356 (-2.87 %) bytes
  Max Waves: 26931 -> 26899 (-0.12 %)

I've not actually tested real performance.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agoi965: use mt->offset in intel_miptree_map_movntdqa()
Haixia Shi [Wed, 3 Aug 2016 00:03:32 +0000 (17:03 -0700)]
i965: use mt->offset in intel_miptree_map_movntdqa()

We need to include mt->offset in the calculation of src pointer because its
value may be non-zero, for example in a cubemap texture.

Signed-off-by: Haixia Shi <hshi@chromium.org>
Cc: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Chad Versace <chad@kiwitree.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Change-Id: I461ad5b204626d5a1c45611fc6b63735dcf29f63

8 years agonir: fix validation message
Timothy Arceri [Tue, 2 Aug 2016 07:46:19 +0000 (17:46 +1000)]
nir: fix validation message

Looks like a copy and paste error from f752effa087

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
8 years ago.mailmap: Update my address
Chad Versace [Tue, 2 Aug 2016 20:29:53 +0000 (13:29 -0700)]
.mailmap: Update my address

I left Intel, so make my personal address the canonical address.

8 years agoswr: build swr with -fno-strict-aliasing
Tim Rowley [Tue, 2 Aug 2016 18:18:08 +0000 (13:18 -0500)]
swr: build swr with -fno-strict-aliasing

swr rasterizer contains numerous data transfers between vectors
and ordinary C types.  Fixing for strict aliasing will take time.

Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agoast: Updated AST_NUM_OPERATORS for coherence with ast_operators
Andres Gomez [Sun, 31 Jul 2016 16:07:34 +0000 (19:07 +0300)]
ast: Updated AST_NUM_OPERATORS for coherence with ast_operators

AST_NUM_OPERATORS stores the dimension of the ast_operators
enumeration but was not updated after its last modification.

This doesn't add any real modification for any code paths but it makes
sense for coherence.

v2 (Eric Engestrom): Just place the define at the end of the
                     enumeration, not below.

Signed-off-by: Andres Gomez <agomez@igalia.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
8 years agoi965: Disable the unlit centroid workaround on Gen7.
Matt Turner [Mon, 1 Aug 2016 19:18:45 +0000 (12:18 -0700)]
i965: Disable the unlit centroid workaround on Gen7.

Once upon a time (commit 8313f44409) Paul added code for the unlit
centroid workaround (WaCopyUnlitCentroidBarys). His commit message
claims it fixed the EXT_framebuffer_multisample/interpolation {2,4}
{centroid-deriv,centroid-deriv-disabled} piglit tests but does not say
on which platform, though he cites the IVB PRM.

"3DSTATE_WM [DevIVB, DevHSW]" says

   "[DevIVB]: Workaround: When Centroid Barycentric mode is required, HW
    may produce incorrect interpolation results when a 2X2 pixels have
    unlit pixels."

I later disabled it for Haswell (commit f6db414f3c) with no known ill
effects.

The Sandybridge page does not have this text, but the workarounds
database (see WaCopyUnlitCentroidBarys) says the issues applies *only*
to Sandybridge, and in fact in commit 1a2de7dce8fc I note that disabling
the workaround on Sandybridge causes the tests Paul originally mentioned
to fail.

So this is, and always has been, a huge confusing mess.

Disabling the workaround indeed causes the tests Paul originally
mentioned to fail on Sandybridge but not on Ivybridge/Baytrail.

On Ivybridge:

   total instructions in shared programs: 6914901 -> 6909599 (-0.08%)
   instructions in affected programs: 106766 -> 101464 (-4.97%)
   helped: 884

   total cycles in shared programs: 70874764 -> 70813774 (-0.09%)
   cycles in affected programs: 794144 -> 733154 (-7.68%)
   helped: 688
   HURT: 186

   LOST:   1
   GAINED: 6

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 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>
8 years agomesa: Drop -fno-strict-aliasing.
Matt Turner [Thu, 26 May 2016 23:34:02 +0000 (16:34 -0700)]
mesa: Drop -fno-strict-aliasing.

Improves performance of OglBatch7 by 4.06851% +/- 1.17925% (n=169) on
Haswell, and cuts ~18k of .text:

   text     data      bss      dec      hex  filename
5824627   287816    29384  6141827   5db783  before/i965_dri.so
5806354   287816    29384  6123554   5d7022  after/i965_dri.so

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agoi915: Avoid aliasing violation.
Matt Turner [Thu, 28 Jul 2016 19:44:41 +0000 (12:44 -0700)]
i915: Avoid aliasing violation.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agodraw: Avoid aliasing violations.
Matt Turner [Thu, 28 Jul 2016 21:41:17 +0000 (14:41 -0700)]
draw: Avoid aliasing violations.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agor600g: Avoid aliasing violations.
Matt Turner [Thu, 28 Jul 2016 19:38:21 +0000 (12:38 -0700)]
r600g: Avoid aliasing violations.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agor300g: Avoid aliasing violation.
Matt Turner [Thu, 28 Jul 2016 20:57:06 +0000 (13:57 -0700)]
r300g: Avoid aliasing violation.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agogallium/auxiliary: Add u_bitcast.h header.
Matt Turner [Thu, 28 Jul 2016 21:34:14 +0000 (14:34 -0700)]
gallium/auxiliary: Add u_bitcast.h header.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agoglsl_to_tgsi: Avoid aliasing violations.
Matt Turner [Thu, 28 Jul 2016 19:43:19 +0000 (12:43 -0700)]
glsl_to_tgsi: Avoid aliasing violations.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agost/mesa: silence missing braces warning in st_program.c
Brian Paul [Mon, 1 Aug 2016 15:56:21 +0000 (09:56 -0600)]
st/mesa: silence missing braces warning in st_program.c

Silence a gcc warning:
state_tracker/st_program.c: In function 'st_create_fp_variant':
state_tracker/st_program.c:957:10: warning: missing braces around initializer [-Wmissing-braces]
          nir_lower_drawpixels_options options = {0};
          ^
state_tracker/st_program.c:957:10: warning: (near initialization for 'options.texcoord_state_tokens') [-Wmissing-braces]

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agoauxiliary/os: add new os_get_command_line() function
Brian Paul [Wed, 29 Jun 2016 22:30:54 +0000 (16:30 -0600)]
auxiliary/os: add new os_get_command_line() function

This can be used by the driver to get the command line which started
the process.  Will be used by the VMware driver for extra logging.

For now, this is only implemented for Linux via /proc/self/cmdline
and Windows via GetCommandLine().

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agosvga: avoid redundant SetVertexBuffer/SetIndexBuffer commands at rebind
Charmaine Lee [Fri, 22 Jul 2016 22:05:02 +0000 (15:05 -0700)]
svga: avoid redundant SetVertexBuffer/SetIndexBuffer commands at rebind

This patch eliminates the redundant SetVertexBuffers and
SetIndexBuffer commands that are emitted for rebind purpose.
With this patch, the set commands will be skipped, but we will still
reference the associated resources to allow the kernel to
bring in the resources.

Tested with Lightsmark2008, Valley, MTT glretrace, piglit, conform.

Reviewed-by: Brian Paul <brianp@vmware.com>
8 years agou_vbuf: fix potentially bogus assert
Rob Clark [Sat, 30 Jul 2016 15:22:52 +0000 (11:22 -0400)]
u_vbuf: fix potentially bogus assert

There are cases where we hit u_vbuf path due to alignment or pitch-
alignment restrictions, but for an output-format that u_vbuf does not
support translating (yet the driver does support natively).  In which
case we hit the memcpy() path and don't care that u_vbuf doesn't
understand it.

Fixes crash with debug build of mesa in:
dEQP-GLES3.functional.vertex_arrays.single_attribute.strides.fixed.user_ptr_stride17_components2_quads1

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95000
Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agogbm: Removed unused function.
Ben Widawsky [Fri, 29 Jul 2016 20:42:04 +0000 (13:42 -0700)]
gbm: Removed unused function.

AFAICT, it's never been used.

It was briefly nudged in the right direction here:
commit 10e5ffd4961055ebba5be4d85a93cc66cdd5a635
Author: Emil Velikov <emil.l.velikov@gmail.com>
Date:   Sat Jan 25 17:19:10 2014 +0000

    gbm: do not export _gbm_mesa_get_device

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
8 years agoi965: fix comparison warning
Timothy Arceri [Mon, 1 Aug 2016 00:35:06 +0000 (10:35 +1000)]
i965: fix comparison warning

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agovc4: Zero-initialize the hardware sampler view structure.
Eric Anholt [Tue, 26 Jul 2016 22:32:11 +0000 (15:32 -0700)]
vc4: Zero-initialize the hardware sampler view structure.

Fixes failure to initialize the force_first_level flag, causing
failures in piglit levelclamp.

8 years agomesa: Remove set but not used gl_client_array::Stride.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:05 +0000 (08:09 +0200)]
mesa: Remove set but not used gl_client_array::Stride.

The field is only read for printing today and
there it was probably a leftover.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agomesa: Remove set but not used gl_client_array::Enabled.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:05 +0000 (08:09 +0200)]
mesa: Remove set but not used gl_client_array::Enabled.

The way it is used today does not care about the
Enabled flag anymore.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agovbo: Use the VAO array enabled flags in vbo_exec_array.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:05 +0000 (08:09 +0200)]
vbo: Use the VAO array enabled flags in vbo_exec_array.

Instead of gl_client_array::Enabled inside a VAO,
directly use the gl_vertex_attrib_array::Enabled value
which is the origin of the above.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agovbo: Walk the VAO in check_array_data.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:05 +0000 (08:09 +0200)]
vbo: Walk the VAO in check_array_data.

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agovbo: Walk the VAO in print_draw_arrays.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:05 +0000 (08:09 +0200)]
vbo: Walk the VAO in print_draw_arrays.

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO. Also make use of gl_vert_attrib_name.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agomesa: Walk the VAO in _mesa_print_arrays.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:05 +0000 (08:09 +0200)]
mesa: Walk the VAO in _mesa_print_arrays.

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO. Also make use of gl_vert_attrib_name.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agovbo: Walk the VAO to check for mapped buffers.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:05 +0000 (08:09 +0200)]
vbo: Walk the VAO to check for mapped buffers.

Similarily to _mesa_all_varyings_in_vbos walk the VAO
to check if we have an illegal mapped buffer object
instead of walking all gl_client_arrays.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agovbo: Walk the VAO to see if all varyings are in vbos.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:05 +0000 (08:09 +0200)]
vbo: Walk the VAO to see if all varyings are in vbos.

In vbo_draw_transform_feedback we currently look at
exec->array.inputs to determine if all varying
vertex attributes reside in vbos. But the vbo_bind_arrays
call only happens past the vbo_all_varyings_in_vbos
query. Thus we may work on a stale set of client arrays.
Using the current VAOs content for this query feels much
more logical to me.
Additionally with this change mesa makes more use of the
information already tracked in the VAO instead of looping
across VERT_ATTRIB_MAX vertex arrays.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agomesa: Implement _mesa_all_varyings_in_vbos.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:04 +0000 (08:09 +0200)]
mesa: Implement _mesa_all_varyings_in_vbos.

Implement the equivalent of vbo_all_varyings_in_vbos for
vertex array objects.

v2: Update comment.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agomesa: Unbind deleted vbo using _mesa_bind_vertex_buffer.
Mathias Fröhlich [Fri, 17 Jun 2016 06:09:04 +0000 (08:09 +0200)]
mesa: Unbind deleted vbo using _mesa_bind_vertex_buffer.

When a vertex buffer object gets deleted, it is unbound
at the VAO. To do this use _mesa_bind_vertex_buffer instead
of plain unreferencing the buffer object. This keeps the VAOs
internal state consistent. In this case it showed up with
gl_vertex_array_object::VertexAttribBufferMask getting out of
sync.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
8 years agoglsl: be more strict on block qualifiers
Timothy Arceri [Sat, 30 Jul 2016 04:51:21 +0000 (14:51 +1000)]
glsl: be more strict on block qualifiers

V2: Add spec references and allow patch qualifier (Ken)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96528

8 years agoglsl: add name param to validate_flags()
Timothy Arceri [Sat, 30 Jul 2016 06:33:26 +0000 (16:33 +1000)]
glsl: add name param to validate_flags()

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agoglsl: add component to ast_type_qualifier::validate_flags
Timothy Arceri [Sat, 30 Jul 2016 04:53:20 +0000 (14:53 +1000)]
glsl: add component to ast_type_qualifier::validate_flags

This was added with ARB_enhanced_layouts.

V2: Add an extra format specifier for the new qualifier.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agodocs: Add GL4.4 and ARB_enhanced_layouts to the release notes
Timothy Arceri [Sat, 30 Jul 2016 00:25:09 +0000 (10:25 +1000)]
docs: Add GL4.4 and ARB_enhanced_layouts to the release notes

Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
8 years agoanv: Perform rasterizer discard in the SOL stage instead of the clipper.
Kenneth Graunke [Mon, 18 Jul 2016 23:02:02 +0000 (16:02 -0700)]
anv: Perform rasterizer discard in the SOL stage instead of the clipper.

See commit b0629e6894513a2c49a018bc3342a4e55435a236, where we discovered
that the SOL stage's "Rendering Disable" feature is a lot faster at
throwing away all geometry than the clipper's "reject all" mode.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
8 years agoRevert "gallium/util: fix resource leak"
Roland Scheidegger [Sat, 30 Jul 2016 16:18:09 +0000 (18:18 +0200)]
Revert "gallium/util: fix resource leak"

This reverts commit d1fe26a62862f4e47a799222dca1bc1dc14ca4af.

Replacing a resource leak with a segfault isn't the solution.

8 years agogallium/util: fix resource leak
Eric Engestrom [Sat, 30 Jul 2016 00:35:39 +0000 (01:35 +0100)]
gallium/util: fix resource leak

CovID: 401540
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
8 years agofreedreno/a4xx: fix comparison out of range warnings
francians@gmail.com [Sat, 30 Jul 2016 07:49:59 +0000 (09:49 +0200)]
freedreno/a4xx: fix comparison out of range warnings

Signed-off-by: Francesco Ansanelli <francians@gmail.com>
Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno/a3xx: fix comparison out of range warnings
francians@gmail.com [Sat, 30 Jul 2016 07:49:58 +0000 (09:49 +0200)]
freedreno/a3xx: fix comparison out of range warnings

Signed-off-by: Francesco Ansanelli <francians@gmail.com>
Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno/a2xx: fix comparison out of range warnings
francians@gmail.com [Sat, 30 Jul 2016 07:49:57 +0000 (09:49 +0200)]
freedreno/a2xx: fix comparison out of range warnings

Signed-off-by: Francesco Ansanelli <francians@gmail.com>
Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno/ir3: init ir3_shader_key with memset()
francians@gmail.com [Sat, 30 Jul 2016 06:20:58 +0000 (08:20 +0200)]
freedreno/ir3: init ir3_shader_key with memset()

To silence missing initializers warning

Signed-off-by: Francesco Ansanelli <francians@gmail.com>
Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agogallium/freedreno: move cast to avoid integer overflow
Eric Engestrom [Sat, 30 Jul 2016 00:33:56 +0000 (01:33 +0100)]
gallium/freedreno: move cast to avoid integer overflow

Previously, the bitshift would be performed on a simple int (32 bits on
most systems), overflow, and then be cast to 64 bits.

CovID: 1362461
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno/a2xx: remove duplicate assignment
Eric Engestrom [Sat, 30 Jul 2016 00:23:09 +0000 (01:23 +0100)]
freedreno/a2xx: remove duplicate assignment

CovID: 13624451362446
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: defer flush_queue allocation
Rob Clark [Fri, 22 Jul 2016 21:55:59 +0000 (17:55 -0400)]
freedreno: defer flush_queue allocation

Some apps, like warsow, create a bazillion contexts but don't render on
most of them.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: add some hw query traces
Rob Clark [Wed, 20 Jul 2016 18:50:14 +0000 (14:50 -0400)]
freedreno: add some hw query traces

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: some locking
Rob Clark [Tue, 19 Jul 2016 22:24:57 +0000 (18:24 -0400)]
freedreno: some locking

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agoos: add pipe_mutex_assert_locked()
Rob Clark [Thu, 21 Jul 2016 17:51:36 +0000 (13:51 -0400)]
os: add pipe_mutex_assert_locked()

Would be nice if we could also have lockdep, like in the linux kernel.
But this is better than nothing.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: drop needs_rb_fbd
Rob Clark [Tue, 19 Jul 2016 17:22:01 +0000 (13:22 -0400)]
freedreno: drop needs_rb_fbd

We need to emit RB_FRAME_BUFFER_DIMENSION once per batch.. tracking this
in fd_context is wrong when the gmem code executes asynchronously from
the flush_queue worker.  But in fact we don't really need to track it at
all.  We cannot assume previous value at the beginning of the batch
(because of other processes potentially using the GPU), so just drop the
tracking and emit it in _tile_init().

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: move needs_wfi into batch
Rob Clark [Tue, 19 Jul 2016 16:08:42 +0000 (12:08 -0400)]
freedreno: move needs_wfi into batch

This is also used in gmem code, which executes from the "bottom half"
(ie. from the flush_queue worker thread), so it cannot be in fd_context.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: a bit of micro-optimization
Rob Clark [Thu, 14 Jul 2016 20:44:34 +0000 (16:44 -0400)]
freedreno: a bit of micro-optimization

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: drop mem2gmem/gmem2mem query stages
Rob Clark [Thu, 14 Jul 2016 17:27:32 +0000 (13:27 -0400)]
freedreno: drop mem2gmem/gmem2mem query stages

They weren't really used, and it gets somewhat more complicated to deal
with if batches are flushed asynchronously (on another thread).  So just
drop them, and move _query_set_state(NULL) call into batch (so it is not
happening on background thread).

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: threaded batch flush
Rob Clark [Wed, 13 Jul 2016 13:49:53 +0000 (09:49 -0400)]
freedreno: threaded batch flush

With the state accessed from GMEM+submit factored out of fd_context and
into fd_batch, now it is possible to punt this off to a helper thread.
And more importantly, since there are cases where one context might
force the batch-cache to flush another context's batches (ie. when there
are too many in-flight batches), using a per-context helper thread keeps
various different flushes for a given context serialized.

TODO as with batch-cache, there are a few places where we'll need a
mutex to protect critical sections, which is completely missing at the
moment.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: track batch/blit types
Rob Clark [Thu, 14 Jul 2016 14:32:02 +0000 (10:32 -0400)]
freedreno: track batch/blit types

Add a bit of extra book-keeping about blits and back-blits (from
resource shadowing).  If the app uploads all mipmap levels, as opposed
to uploading the first level and then glGenerateMipmap(), we can discard
the back-blit (as opposed to being naive and shadowing the resource for
each mipmap level).  Also, after a normal blit, we might as well flush
the batch immediately, since there is not likely to be further rendering
to the surface.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: re-order support for hw queries
Rob Clark [Mon, 11 Jul 2016 21:36:45 +0000 (17:36 -0400)]
freedreno: re-order support for hw queries

Push query state down to batch, and use the resource tracking to figure
out which batch(es) need to be flushed to get the query result.

This means we actually need to allocate the prsc up front, before we
know the size.  So we have to add a special way to allocate an un-
backed resource, and then later allocate the backing storage.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: use prsc for hw queries
Rob Clark [Mon, 11 Jul 2016 20:23:10 +0000 (16:23 -0400)]
freedreno: use prsc for hw queries

Switch to using a pipe_resource (rather than an fd_bo directly) for hw
query result buffers.  This is first step towards making queries work
properly with reordered batches, since we'll need the additional
dependency tracking to know which batches to flush.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: support discarding previous rendering in special cases
Rob Clark [Fri, 1 Jul 2016 16:38:16 +0000 (12:38 -0400)]
freedreno: support discarding previous rendering in special cases

Basically, to "DCE" blits triggered by resource shadowing, in cases
where the levels are immediately completely overwritten.  For example,
mid-frame texture upload to level zero triggers shadowing and back-blits
to the remaining levels, which are immediately overwritten by
glGenerateMipmap().

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: shadow textures if possible to avoid stall/flush
Rob Clark [Wed, 29 Jun 2016 17:51:26 +0000 (13:51 -0400)]
freedreno: shadow textures if possible to avoid stall/flush

To make batch re-ordering useful, we need to be able to create shadow
resources to avoid a flush/stall in transfer_map().  For example,
uploading new texture contents or updating a UBO mid-batch.  In these
cases, we want to clone the buffer, and update the new buffer, leaving
the old buffer (whose reference is held by cmdstream) as a shadow.

This is done by blitting the remaining other levels (and whatever part
of current level that is not discarded) from the old/shadow buffer to
the new one.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: spiff up some debug traces
Rob Clark [Tue, 28 Jun 2016 11:53:34 +0000 (07:53 -0400)]
freedreno: spiff up some debug traces

Make it easier to track batches, to ensure things happen properly when
they are reordered.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: add batch-cache and batch reordering
Rob Clark [Mon, 27 Jun 2016 13:44:15 +0000 (09:44 -0400)]
freedreno: add batch-cache and batch reordering

Note that I originally also had a entry-point that would construct a key
and do lookup from a pipe_surface.  I ended up not needing that (yet?)
but it is easy-enough to re-introduce later if we need it for the blit
path.

For now, not enabled by default, but can be enabled (on a3xx/a4xx) with
FD_MESA_DEBUG=reorder.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: move more batch related tracking to fd_batch
Rob Clark [Mon, 27 Jun 2016 15:28:37 +0000 (11:28 -0400)]
freedreno: move more batch related tracking to fd_batch

To flush batches out of order, the gmem code needs to not depend on
state from fd_context (since that may apply to a more recent batch).
So this all moves into batch.

The one exception is the gmem/pipe/tile state itself.  But this is
only used from gmem code (and batches are flushed serially).  The
alternative would be having to re-calculate GMEM layout on every
batch, even if the dimensions of the render targets are the same.

Note: This opens up the possibility of pushing gmem/submit into a
helper thread.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: dynamically sized/growable cmd buffers
Rob Clark [Tue, 21 Jun 2016 16:39:32 +0000 (12:39 -0400)]
freedreno: dynamically sized/growable cmd buffers

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: push resource tracking down into batch
Rob Clark [Sat, 21 May 2016 00:05:26 +0000 (20:05 -0400)]
freedreno: push resource tracking down into batch

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agofreedreno: introduce fd_batch
Rob Clark [Fri, 20 May 2016 19:36:10 +0000 (15:36 -0400)]
freedreno: introduce fd_batch

Introduce the batch object, to track a batch/submit's worth of
ringbuffers and other bookkeeping.  In this first step, just move
the ringbuffers into batch, since that is mostly uninteresting
churn.

For now there is just a single batch at a time.  Note that one
outcome of this change is that rb's are allocated/freed on each
use.  But the expectation is that the bo pool in libdrm_freedreno
will save us the GEM bo alloc/free which was the initial reason
to implement a rb pool in gallium.

The purpose of the batch is to eventually facilitate out-of-order
rendering, with batches associated to framebuffer state, and
tracking the dependencies on other batches.

Signed-off-by: Rob Clark <robdclark@gmail.com>
8 years agomesa: remove dd_function_table::UseProgram
Marek Olšák [Sun, 17 Jul 2016 18:54:51 +0000 (20:54 +0200)]
mesa: remove dd_function_table::UseProgram

finally unused

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agost/mesa: update sampler states when shaders are changed
Marek Olšák [Sun, 17 Jul 2016 19:37:58 +0000 (21:37 +0200)]
st/mesa: update sampler states when shaders are changed

This bug seems to have always been there. Applications changing shaders
but not textures between draw calls would have gotten undefined behavior.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agost/mesa: don't dirty sample shading on _NEW_PROGRAM
Marek Olšák [Sun, 17 Jul 2016 18:59:42 +0000 (20:59 +0200)]
st/mesa: don't dirty sample shading on _NEW_PROGRAM

Already done as part of ST_NEW_FRAGMENT_PROGRAM in st_validate_state.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agost/mesa: remove excessive shader state dirtying
Marek Olšák [Sun, 17 Jul 2016 18:37:58 +0000 (20:37 +0200)]
st/mesa: remove excessive shader state dirtying

This just needs to be done by st_validate_state.

v2: add "shaders_may_be_dirty" flags for not skipping st_validate_state
    on _NEW_PROGRAM to detect real shader changes

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agost/mesa: unreference optional shaders when unbinding
Marek Olšák [Sun, 17 Jul 2016 18:32:46 +0000 (20:32 +0200)]
st/mesa: unreference optional shaders when unbinding

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agost/mesa: skip updates of states that have no effect
Marek Olšák [Sun, 17 Jul 2016 17:47:12 +0000 (19:47 +0200)]
st/mesa: skip updates of states that have no effect

v2: - also don't check edge flags for GLES

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>