mesa.git
11 years agoi965: Emit post-sync non-zero flush before 3DSTATE_DRAWING_RECTANGLE.
Kenneth Graunke [Thu, 24 Oct 2013 07:36:42 +0000 (00:36 -0700)]
i965: Emit post-sync non-zero flush before 3DSTATE_DRAWING_RECTANGLE.

This is another non-pipelined command that needs a flush on Sandybridge.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Xinkai Chen <yeled.nova@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Cc: "9.2" <mesa-stable@lists.freedesktop.org>
11 years agoi965: Emit post-sync non-zero flush before 3DSTATE_GS_SVB_INDEX.
Kenneth Graunke [Thu, 24 Oct 2013 07:32:52 +0000 (00:32 -0700)]
i965: Emit post-sync non-zero flush before 3DSTATE_GS_SVB_INDEX.

From the comments above intel_emit_post_sync_nonzero_flush:
"[DevSNB-C+{W/A}] Before any depth stall flush (including those
 produced by non-pipelined state commands), software needs to first
 send a PIPE_CONTROL with no bits set except Post-Sync Operation != 0."

This suggests that every non-pipelined (0x79xx) command needs a
post-sync non-zero flush before it.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Xinkai Chen <yeled.nova@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Cc: "9.2" <mesa-stable@lists.freedesktop.org>
11 years agoi965: CS writes/reads should use I915_GEM_INSTRUCTION
Daniel Vetter [Wed, 9 Oct 2013 13:49:11 +0000 (15:49 +0200)]
i965: CS writes/reads should use I915_GEM_INSTRUCTION

Otherwise the gen6 w/a in the kernel won't kick in and the write will
land nowhere.

Inspired by a patch Ken pointed me at which had the same issue (but
isn't yet merged and also for a gen7+ feature). An audit of the entire
driver didn't reveal any other case than the one in in the write_reg
helper used by the gen6 queryobj code.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Tested-by: Xinkai Chen <yeled.nova@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Cc: "9.2" <mesa-stable@lists.freedesktop.org>
11 years agoi965: Do not set bilinear_filter flag in case of multisample blits
Anuj Phogat [Fri, 18 Oct 2013 23:07:42 +0000 (16:07 -0700)]
i965: Do not set bilinear_filter flag in case of multisample blits

Setting bilinear_filter flag in case of multisample blits with
GL_LINEAR filter causes incorrect behavior in translate_dst_to_src()
function. This broke Modern Warfare (1, 2 and 3) on SNB, IVB and HSW.

Tested on SNB and IVB, no Piglit regressions. Trace file of the game
(taken with apitrace) works fine with this patch.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69078
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reported-by: Armin K <krejzi@email.com>
Tested-by: Armin K <krejzi@email.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
11 years agomesa: Remove trailing whitespace in texparam.c
Rico Schüller [Sun, 27 Oct 2013 14:02:00 +0000 (08:02 -0600)]
mesa: Remove trailing whitespace in texparam.c

Signed-off-by: Rico Schüller <kgbricola@web.de>
Signed-off-by: Brian Paul <brianp@vmware.com>
11 years agomesa: use void in _mesa_VDPAUFiniNV() as in the header file
Brian Paul [Sat, 26 Oct 2013 14:11:46 +0000 (08:11 -0600)]
mesa: use void in _mesa_VDPAUFiniNV() as in the header file

11 years agoglsl: Add check for unsized arrays to glsl types
Timothy Arceri [Wed, 23 Oct 2013 10:31:27 +0000 (21:31 +1100)]
glsl: Add check for unsized arrays to glsl types

The main purpose of this patch is to increase readability of
the array code by introducing is_unsized_array() to glsl_types.
Some redundent is_array() checks are also removed, and small number
of other related clean ups.

The introduction of is_unsized_array() should also make the
ARB_arrays_of_arrays code simpler and more readable when it arrives.

V2: Also replace code that checks for unsized arrays directly with the
length variable

Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au>
v3 (Paul Berry <stereotype441@gmail.com>): clean up formatting.
Separate whitespace cleanups to their own patch.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
11 years agoglsl: whitespace cleanups.
Timothy Arceri [Wed, 23 Oct 2013 10:31:27 +0000 (21:31 +1100)]
glsl: whitespace cleanups.

Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au>
v2 (Paul Berry <stereotype441@gmail.com>): Separate from "glsl: Add
check for unsized arrays to glsl types".

Reviewed-by: Paul Berry <stereotype441@gmail.com>
11 years agoglsl: Fix comment
Timothy Arceri [Tue, 22 Oct 2013 11:38:12 +0000 (22:38 +1100)]
glsl: Fix comment

Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
11 years agovl/h264: split fields into SPS/PPS
Christian König [Tue, 24 Sep 2013 09:03:33 +0000 (03:03 -0600)]
vl/h264: split fields into SPS/PPS

Add alot of missing fields as well.

Signed-off-by: Christian König <christian.koenig@amd.com>
11 years agoradeon/uvd: fix H264 chroma format handling
Christian König [Thu, 24 Oct 2013 11:12:58 +0000 (05:12 -0600)]
radeon/uvd: fix H264 chroma format handling

Signed-off-by: Christian König <christian.koenig@amd.com>
11 years agovl: add 400 chroma format as well
Christian König [Thu, 24 Oct 2013 11:47:08 +0000 (05:47 -0600)]
vl: add 400 chroma format as well

Signed-off-by: Christian König <christian.koenig@amd.com>
11 years agoilo: minor cleanups for recent interface changes
Chia-I Wu [Mon, 28 Oct 2013 03:18:43 +0000 (11:18 +0800)]
ilo: minor cleanups for recent interface changes

Kill ilo_bind_sampler_states2 and ilo_set_sampler_views2.  Map
PIPE_FORMAT_R10G10B10A2_UINT to BRW_SURFACEFORMAT_R10G10B10A2_UINT.

11 years agoglsl: Move error message inside validation check reducing duplicate message handling
Timothy Arceri [Thu, 17 Oct 2013 11:42:18 +0000 (22:42 +1100)]
glsl: Move error message inside validation check reducing duplicate message handling

v2 (Paul Berry <stereotype441@gmail.com): Fix precedence error in call
to _mesa_glsl_error().

Reviewed-by: Paul Berry <stereotype441@gmail.com>
11 years agoi965: Make fs gl_PrimitiveID input work even when there's no gs.
Paul Berry [Wed, 23 Oct 2013 03:34:30 +0000 (20:34 -0700)]
i965: Make fs gl_PrimitiveID input work even when there's no gs.

When a geometry shader is present, the fragment shader gl_PrimitiveID
input acts like an ordinary varying, receiving data from the gs
gl_PrimitiveID output.  When there's no geometry shader, we have to
ask the fixed function SF hardware to provide the primitive ID to the
fragment shader instead.

Previously, the SF setup code would handle this situation by
recognizing that the FS gl_PrimitiveID input didn't match to any VS
output; since normally an FS input with no corresponding VS output
leads to undefined data, the SF setup code used to just arbitrarily
assign it to receive data from attribute 0.

This patch changes the SF setup code so that instead of arbitrarily
using attribute 0, it assigns the unmatched FS input to receive
gl_PrimitiveID.  In the case where the FS input really is
gl_PrimitiveID, this produces the intended result.  In all other
cases, no harm is done since GL specifies that the behaviour is
undefined.

Fixes piglit test primitive-id-no-gs.

v2: If an attribute is already being overridden with point
coordinates, don't try to also override it with gl_PrimitiveID.  This
is necessary to avoid regressing piglit tests such as
shaders/glsl-fs-pointcoord.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agomesa: Add GL_NV_vdpau_interop functions to dispatch_sanity.cpp.
Vinson Lee [Sun, 27 Oct 2013 06:09:30 +0000 (23:09 -0700)]
mesa: Add GL_NV_vdpau_interop functions to dispatch_sanity.cpp.

Fixes 'make check' failures introduced with commit
80964226e9b8a05c39157f9305c06c0b2861e080.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70900
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
11 years agomesa: add vdpau.c and st_vdpau.c to src/mesa/SConscript
Brian Paul [Sat, 26 Oct 2013 13:17:53 +0000 (07:17 -0600)]
mesa: add vdpau.c and st_vdpau.c to src/mesa/SConscript

Fixes SCons build.

11 years agoimplement NV_vdpau_interop v7
Christian König [Wed, 15 May 2013 13:10:11 +0000 (15:10 +0200)]
implement NV_vdpau_interop v7

v2: Actually implement interop between the gallium
    state tracker and the VDPAU backend.

v3: Make it also available in non legacy contexts,
    fix video buffer sharing.

v4: deny interop if we don't have the same screen object

v5: rebased on upstream changes

v6: implemented VDPAUGetSurfaceivNV, improved error handling,
    unregister all surfaces in VDPAUFiniNV

v7: squash merge with Mareks changes

Signed-off-by: Christian König <christian.koenig@amd.com>
11 years agowinsys/radeon: make radeon_drm_winsys_create public
Christian König [Fri, 11 Oct 2013 09:07:44 +0000 (11:07 +0200)]
winsys/radeon: make radeon_drm_winsys_create public

Otherwise OpenGL/VDPAU interop won't work as expected.

Signed-off-by: Christian König <christian.koenig@amd.com>
11 years agoi965: Remove ir_txf coord+offset special case in visitors
Chris Forbes [Sat, 12 Oct 2013 11:02:04 +0000 (00:02 +1300)]
i965: Remove ir_txf coord+offset special case in visitors

Just let it be handled by the lowering pass.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Generalize coord+offset lowering pass for ir_txf
Chris Forbes [Sat, 12 Oct 2013 11:02:55 +0000 (00:02 +1300)]
i965: Generalize coord+offset lowering pass for ir_txf

ir_txf expects an ivec* coordinate, and may be larger than ivec2;
shuffle things around so that this will work.

V2: Fix style nits, use ir_builder

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Add lowering pass to fold offset into unnormalized coords
Chris Forbes [Sat, 12 Oct 2013 10:14:15 +0000 (23:14 +1300)]
i965: Add lowering pass to fold offset into unnormalized coords

It turns out that nonzero offsets with gsampler2DRect don't work -- they
just return garbage. Work around this by folding the offset into the
coord.

Done as an IR pass rather than yet another hack in the visitors because
it's clear what's going on this way. Can possibly reuse this to replace
the existing txf coord+offset hacks.

V2: Use ir_builder

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Add lowering pass for splitting textureGatherOffsets
Chris Forbes [Thu, 10 Oct 2013 09:15:14 +0000 (22:15 +1300)]
i965: Add lowering pass for splitting textureGatherOffsets

Rewrites textureGatherOffsets(s, p, offsets) into

   gvec4(
      textureGatherOffset(s, p, offsets[0]).w,
      textureGatherOffset(s, p, offsets[1]).w,
      textureGatherOffset(s, p, offsets[2]).w,
      textureGatherOffset(s, p, offsets[3]).w
      )

V2: Use ir_builder to be slightly clearer.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Add asserts to ensure that ir_tg4 offset arrays are lowered
Chris Forbes [Thu, 10 Oct 2013 08:40:46 +0000 (21:40 +1300)]
i965: Add asserts to ensure that ir_tg4 offset arrays are lowered

We don't have a message that does 4 independent offsets; a lowering
pass needs to lower it to 4 normal gather4s before reaching this
point.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoglsl: add signatures for textureGatherOffsets()
Chris Forbes [Thu, 10 Oct 2013 08:38:43 +0000 (21:38 +1300)]
glsl: add signatures for textureGatherOffsets()

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoglsl: add support for texture functions with offset arrays
Chris Forbes [Thu, 10 Oct 2013 08:34:03 +0000 (21:34 +1300)]
glsl: add support for texture functions with offset arrays

This is needed for textureGatherOffsets()

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/fs: Add support for shadow comparitors with gather4
Chris Forbes [Thu, 10 Oct 2013 06:57:29 +0000 (19:57 +1300)]
i965/fs: Add support for shadow comparitors with gather4

Note that gather4_po_c's parameters are too long for SIMD16. It might be
worth emitting 2xSIMD8 messages in this case at some point.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/vs: Add support for shadow comparitors with gather4
Chris Forbes [Thu, 10 Oct 2013 06:42:47 +0000 (19:42 +1300)]
i965/vs: Add support for shadow comparitors with gather4

gather4_c's argument layout is straightforward -- refz just goes on the
end.

gather4_po_c's layout however -- the array index is replaced with refz.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Add Gen7 gather4_c and gather4_po_c message types
Chris Forbes [Thu, 10 Oct 2013 06:39:54 +0000 (19:39 +1300)]
i965: Add Gen7 gather4_c and gather4_po_c message types

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoglsl: Add new textureGather[Offset]() overloads for shadow samplers
Chris Forbes [Thu, 10 Oct 2013 06:35:36 +0000 (19:35 +1300)]
glsl: Add new textureGather[Offset]() overloads for shadow samplers

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoglsl: Add support for separate reference Z for shadow samplers
Chris Forbes [Thu, 10 Oct 2013 06:32:34 +0000 (19:32 +1300)]
glsl: Add support for separate reference Z for shadow samplers

ARB_gpu_shader5's textureGather*() functions which take shadow samplers
have a separate `refz` parameter rather than adding it to the
coordinate.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/vs: add support for gather4 with nonconstant offsets
Chris Forbes [Tue, 8 Oct 2013 09:19:58 +0000 (22:19 +1300)]
i965/vs: add support for gather4 with nonconstant offsets

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
11 years agoi965/fs: add support for gather4 with nonconstant offsets
Chris Forbes [Tue, 8 Oct 2013 09:10:34 +0000 (22:10 +1300)]
i965/fs: add support for gather4 with nonconstant offsets

V3: fixup crazy check for whether we need to emit the coordinate after
    custom handling.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: relax brw_texture_offset assert
Chris Forbes [Tue, 8 Oct 2013 09:09:28 +0000 (22:09 +1300)]
i965: relax brw_texture_offset assert

Some texturing ops are about to have nonconstant offset support; the
offset in the header in these cases should be zero.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agoi965: Add SHADER_OPCODE_TG4_OFFSET for gather with nonconstant offsets.
Chris Forbes [Tue, 8 Oct 2013 08:42:10 +0000 (21:42 +1300)]
i965: Add SHADER_OPCODE_TG4_OFFSET for gather with nonconstant offsets.

The generator code ends up clearer this way than if we had to sniff
via the message length. Implemented via the gather4_po message in
hardware, which is present in Gen7 and later.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agoi965: add missing tg4 case in brw_instruction_name
Chris Forbes [Tue, 8 Oct 2013 08:34:22 +0000 (21:34 +1300)]
i965: add missing tg4 case in brw_instruction_name

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agoglsl: relax const offset requirement for textureGatherOffset
Chris Forbes [Sun, 6 Oct 2013 01:26:01 +0000 (14:26 +1300)]
glsl: relax const offset requirement for textureGatherOffset

Prior to ARB_gpu_shader5 / GLSL 4.0, the offset is required to be
a constant expression.

With that extension, it is relaxed to be an arbitrary expression.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agoglsl: Add ARB_gpu_shader5 textureGatherOffset signatures
Chris Forbes [Sun, 6 Oct 2013 00:23:59 +0000 (13:23 +1300)]
glsl: Add ARB_gpu_shader5 textureGatherOffset signatures

- gsampler2DRect
- optional `comp` parameter

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agoi965: Weaken the flushing in gen7_end_transform_feedback().
Kenneth Graunke [Tue, 28 May 2013 02:18:14 +0000 (19:18 -0700)]
i965: Weaken the flushing in gen7_end_transform_feedback().

Since 062317d6671 (i965: Go back to using the kernel SOL reset feature.)
we've been flushing the batch on BeginTransformFeedback().  So it's not
necessary to do it on EndTransformFeedback().  A PIPE_CONTROL will work.

This makes gen7_end_transform_feedback() exactly the same as the gen6
variant.  However, they'll diverge again shortly.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965/fs: Stop trying to hack around MRF dep chains on gen7+ LIFO scheduling.
Eric Anholt [Tue, 22 Oct 2013 19:38:14 +0000 (12:38 -0700)]
i965/fs: Stop trying to hack around MRF dep chains on gen7+ LIFO scheduling.

This was a hack to avoid choosing to schedule all texturing before
consumption of any texture results due to the way dependency chains worked
out in the presence of MRFs.  On gen7, we don't have MRFs, so the problem
doesn't apply, and this was just badly constraining our scheduling.

total instructions in shared programs: 1615306 -> 1612534 (-0.17%)
instructions in affected programs:     9958 -> 7186 (-27.84%)
GAINED:                                259
LOST:                                  9

Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoi965: Try not to reverse-schedule things when doing LIFO scheduling.
Eric Anholt [Tue, 22 Oct 2013 19:27:06 +0000 (12:27 -0700)]
i965: Try not to reverse-schedule things when doing LIFO scheduling.

The LIFO plan was simple: Take the most recently made available
instructions, and pick those first.

But because of the order we were pushing things onto our list of
available-to-schedule instructions, it meant that when a set of
instructions was made available at the same time (for example, everything
at the start of the program that didn't depend on other instructions) we'd
schedule them in reverse order.

If you had 10 texture calls in a row in your program, each with
independent argument setup, we'd set up the last texture call's args and
execute it first, even though we wouldn't be able to consume its results
until we'd finished the other 9 texture calls (assuming consumption of
texture results happens near each texture call, and combines it with
another texture result, which is normal for a convolution shader).

To fix this, walk the list for doing LIFO in the order that instructions
were originally generated in the program, but choose to push
newly-made-available instructions to the other end of the list instead.

total instructions in shared programs: 1587242 -> 1586290 (-0.06%)
instructions in affected programs:     7801 -> 6849 (-12.20%)
GAINED:                                76
LOST:                                  67

Thanks to Chia-I Wu for pointing out the bug in my first version of the
patch that made it a huge loss.

Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agomesa/st: disable ARB_framebuffer_object when no driver support.
Ilia Mirkin [Fri, 4 Oct 2013 08:32:16 +0000 (04:32 -0400)]
mesa/st: disable ARB_framebuffer_object when no driver support.

When PIPE_CAP_MIXED_FRAMEBUFFER_SIZES is not provided, parts of
ARB_framebuffer_object can't be supported, such as on NV30.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
11 years agogallium: add PIPE_CAP_MIXED_FRAMEBUFFER_SIZES
Ilia Mirkin [Fri, 4 Oct 2013 08:32:15 +0000 (04:32 -0400)]
gallium: add PIPE_CAP_MIXED_FRAMEBUFFER_SIZES

This CAP will determine whether ARB_framebuffer_object can be enabled.
The nv30 driver does not allow mixing swizzled and linear zsbuf/cbuf
textures.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
11 years agoglx: Fix return value from indirect_bind_context
Adam Jackson [Fri, 25 Oct 2013 19:12:04 +0000 (15:12 -0400)]
glx: Fix return value from indirect_bind_context

_XReply returns 1 on success, but indirect_bind_context returns 0 on
success.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70486
Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
11 years agoglsl: Optimize (not A) and (not B) into not (A or B).
Matt Turner [Wed, 23 Oct 2013 23:42:34 +0000 (16:42 -0700)]
glsl: Optimize (not A) and (not B) into not (A or B).

No shader-db changes, but seems like a good idea.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoglsl: Optimize (not A) or (not B) into not (A and B).
Matt Turner [Wed, 23 Oct 2013 23:40:16 +0000 (16:40 -0700)]
glsl: Optimize (not A) or (not B) into not (A and B).

A few Serious Sam 3 shaders affected:

instructions in affected programs:     4384 -> 4344 (-0.91%)

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965/fs: Match commutative expressions with reversed arguments.
Matt Turner [Fri, 18 Oct 2013 23:02:11 +0000 (16:02 -0700)]
i965/fs: Match commutative expressions with reversed arguments.

total instructions in shared programs: 1645011 -> 1644938 (-0.00%)
instructions in affected programs:     17543 -> 17470 (-0.42%)

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965: s/Muchnik/Muchnick/.
Matt Turner [Sat, 19 Oct 2013 23:40:19 +0000 (16:40 -0700)]
i965: s/Muchnik/Muchnick/.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agor600g,radeonsi: use fences provided by the winsys
Marek Olšák [Tue, 8 Oct 2013 19:50:43 +0000 (21:50 +0200)]
r600g,radeonsi: use fences provided by the winsys

11 years agowinsys/radeon: add the implementation of fences from r300g
Marek Olšák [Tue, 8 Oct 2013 19:26:34 +0000 (21:26 +0200)]
winsys/radeon: add the implementation of fences from r300g

11 years agoradeonsi: add the vertex shader position output if it's missing
Marek Olšák [Wed, 23 Oct 2013 14:10:38 +0000 (16:10 +0200)]
radeonsi: add the vertex shader position output if it's missing

This fixes a lockup in piglit/spec/glsl-1.40/execution/tf-no-position.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
11 years agoradeonsi: respect semantic indices for COLOR[i] fragment shader outputs
Marek Olšák [Tue, 22 Oct 2013 20:05:35 +0000 (22:05 +0200)]
radeonsi: respect semantic indices for COLOR[i] fragment shader outputs

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
11 years agoglsl: When disabling gl_PerVertex variables, check that mode matches.
Paul Berry [Tue, 15 Oct 2013 21:56:28 +0000 (14:56 -0700)]
glsl: When disabling gl_PerVertex variables, check that mode matches.

In commit 1b4a737 (glsl: Support redeclaration of VS and GS
gl_PerVertex output), I added code to ensure that when an unnamed
gl_PerVertex interface block is redeclared, any ir_variables that
weren't included in the redeclaration are removed from the IR (and the
symbol table).  This ensures that only those variables that were
explicitly redeclared may be used.

However, when I wrote this code, I neglected to match the variable
mode when finding variables to remove.  This meant that redeclaring a
built-in output block might cause the built-in input gl_in to be
accidentally removed.

Fixes piglit test gs-redeclares-pervertex-out-only.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl: Remove unused gl_PerVertex interface blocks.
Paul Berry [Tue, 15 Oct 2013 22:13:59 +0000 (15:13 -0700)]
glsl: Remove unused gl_PerVertex interface blocks.

The GLSL 4.10 rules for redeclaration of built-in interface blocks
(which we've chosen to regard as clarifications of GLSL 1.50) only
require gl_PerVertex blocks to match in shaders that actually use
those blocks.  The easiest way to implement this is to detect
situations where a compiled shader doesn't refer to any elements of
gl_PerVertex, and remove all the associated ir_variables from the
shader at the end of ast-to-ir conversion.

Fixes piglit tests
linker/interstage-{pervertex,pervertex-in,pervertex-out}-redeclaration-unneeded.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl: Call check_builtin_array_max_size when redeclaring gl_in.
Paul Berry [Tue, 15 Oct 2013 23:48:59 +0000 (16:48 -0700)]
glsl: Call check_builtin_array_max_size when redeclaring gl_in.

Normally when a built-in array (such as gl_ClipDistance) is
redeclared, we call get_variable_being_redeclared() to do the
redeclaration, and it in turn calls check_builtin_array_max_size() to
make sure that the redeclared array size isn't too large.

However when a built-in array is redeclared as part of redeclaring
gl_in, we don't call get_variable_being_redeclared() (since the
individual built-ins aren't each represented by their own ir_variable
anymore).  So we need to add an explicit call to
check_builtin_array_max_size() to make sure the new array size isn't
too large.

Note: at the moment this is redundant with a test that's done at link
time, so there's no change to piglit results.  But the patch that
follows will prevent link errors from being reported if gl_PerVertex
isn't used, so in order to prevent that patch from causing
regressions, we need to add the compile check now.  Besides, it's
nicer to report this error at compile time anyhow.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agomesa: Fix geometry shader program queries.
Paul Berry [Wed, 16 Oct 2013 18:01:42 +0000 (11:01 -0700)]
mesa: Fix geometry shader program queries.

The queries GEOMETRY_VERTICES_OUT, GEOMETRY_INPUT_TYPE, and
GEOMETRY_OUTPUT_TYPE (defined by GL 3.2) differ from the corresponding
queries in ARB_geometry_shader4 in the following ways:

- They use different enum values

- They can only be queried; they cannot be set.

- Attempting to query them yields INVALID_OPERATION if the program is
  not linked, or lacks a geometry shader.

This patch switches us over from the ARB_geometry_shader4 behaviour to
the GL 3.2 behaviour.

Fixes piglit test query-gs-prim-types.

v2: Improve comment above has_core_gs.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl: Account for interface block lowering in program_resource_visitor.
Paul Berry [Tue, 22 Oct 2013 04:09:47 +0000 (21:09 -0700)]
glsl: Account for interface block lowering in program_resource_visitor.

When program_resource_visitor visits variables that were created by
lower_named_interface_blocks, it needs to do extra work to un-do the
effects of lower_named_interface_blocks and construct the proper API
names.

Fixes piglit test
spec/glsl-1.50/execution/interface-blocks-api-access-members.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl: mark variables produced by lower_named_interface_blocks.
Paul Berry [Tue, 22 Oct 2013 03:27:23 +0000 (20:27 -0700)]
glsl: mark variables produced by lower_named_interface_blocks.

These variables will need to be treated specially by
program_resource_visitor, so that they can be addressed through the
API using their interface block name (and array index, for interface
block arrays).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl: Keep track of centroid/interpolation mode for interface block members.
Paul Berry [Tue, 22 Oct 2013 22:11:51 +0000 (15:11 -0700)]
glsl: Keep track of centroid/interpolation mode for interface block members.

Fixes piglit tests:
- interface-block-interpolation-{array,named,unnamed}
- glsl-1.50-interface-block-centroid {array,named,unnamed}

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl: Pass variable mode into ast_process_structure_or_interface_block().
Paul Berry [Tue, 22 Oct 2013 22:03:29 +0000 (15:03 -0700)]
glsl: Pass variable mode into ast_process_structure_or_interface_block().

Later patches will use this information to do proper error checking of
interpolation qualifiers that appear inside of interface blocks.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl: Extract interpretation of interpolation to its own function.
Paul Berry [Tue, 22 Oct 2013 21:54:10 +0000 (14:54 -0700)]
glsl: Extract interpretation of interpolation to its own function.

In future patches, we will need this in order to interpret
interpolation qualifiers that appear inside interface blocks.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl: Pull interpolation_string() out of ir_variable.
Paul Berry [Tue, 22 Oct 2013 21:48:08 +0000 (14:48 -0700)]
glsl: Pull interpolation_string() out of ir_variable.

Future patches will need to call this function when there isn't an
ir_varible present to refer to.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoi965: Reduce gl_MaxGeometryInputComponents to 64.
Paul Berry [Wed, 16 Oct 2013 03:44:00 +0000 (20:44 -0700)]
i965: Reduce gl_MaxGeometryInputComponents to 64.

Although in principle there is no hardware limitation that prevents
gl_MaxGeometryInputComponents from being set to 128 on Gen7, we have
the following limitations in the vec4 compiler back end:

- Registers assigned to geometry shader inputs can't be spilled or
  later re-used for any other purpose.

- The last 16 registers are set aside for the "MRF hack", meaning they
  can only be used to send messages, and not for general purpose
  computation.

- Up to 32 registers may be reserved for push constants, even if there
  is sufficient register pressure to make this impractical.

A shader using 128 geometry input components, and having an input type
of triangles_adjacency, would use up:

- 1 register for r0 (which holds URB handles and various pieces of
  control information).

- 1 register for gl_PrimitiveID.

- 102 registers for geometry shader inputs (17 registers per input
  vertex, assuming DUAL_INSTANCED dispatch mode and allowing for one
  register of overhead for gl_Position and gl_PointSize, which are
  present in the URB map even if they are not used).

- Up to 32 registers for push constants.

- 16 registers for the "MRF hack".

That's a total of 152 registers, which is well over the 128 registers
the hardware supports.

Fortunately, the GLSL 1.50 spec allows us to reduce
gl_MaxGeometryInputComponents to 64.  Doing that frees up 48
registers, brining the total down to 104 registers, leaving 24
registers available to do computation.

Fixes piglit test
spec/glsl-1.50/execution/geometry/max-input-components.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoi965/gs: If a DUAL_OBJECT gs would spill, fall back to DUAL_INSTANCED.
Paul Berry [Wed, 16 Oct 2013 19:27:37 +0000 (12:27 -0700)]
i965/gs: If a DUAL_OBJECT gs would spill, fall back to DUAL_INSTANCED.

This is similar to what we do for 16-wide vs 8-wide fragment shaders.
First we try compiling the geometry shader in DUAL_OBJECT mode.  If we
can't do that without spilling, we fall back on DUAL_INSTANCED mode,
which should require less spilling (since it uses an interleaved
layout of payload registers).

In an ideal world we'd fall back to SINGLE mode, which would allow us
to interleave general-purpose registers too (resulting in even less
likelihood of spilling).  But at the moment, the vec4 generator and
visitor classes don't have the infrastructure to interleave general
purpose registers, so DUAL_INSTANCED is the best we can do.

As a side benefit this paves the way for implementing instanced
geometry shaders (which are incompatible with DUAL_OBJECT mode).

Since most geometry shaders used in piglit testing are small,
DUAL_INSTANCED mode won't get exercised very much in a normal piglit
run.  To force DUAL_INSTANCED mode to be used for all geometry
shaders, set INTEL_DEBUG=nodualobj.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965/gs: Fix up gl_PointSize input swizzling for DUAL_INSTANCED gs.
Paul Berry [Wed, 16 Oct 2013 20:18:11 +0000 (13:18 -0700)]
i965/gs: Fix up gl_PointSize input swizzling for DUAL_INSTANCED gs.

Geometry shaders that run in "DUAL_INSTANCED" mode store their inputs
in vec4's.  This means that when compiling gl_PointSize input
swizzling (a MOV instruction which uses a geometry shader input as
both source and destination), we need to do two things:

- Set force_writemask_all to ensure that the MOV happens regardless of
  which channels are enabled.

- Set the source register region to <4;4,1> (instead of <0;4,1> to
  satisfy register region restrictions.

v2: move the source register region fixup to the top of
vec4_generator::generate_vec4_instruction(), so that it applies to all
instructions rather than just MOV.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965/gs: Add the ability to compile a DUAL_INSTANCED geometry shader.
Paul Berry [Wed, 16 Oct 2013 19:04:19 +0000 (12:04 -0700)]
i965/gs: Add the ability to compile a DUAL_INSTANCED geometry shader.

Not yet enabled.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965/vec4: Add the ability to suppress register spilling.
Paul Berry [Wed, 16 Oct 2013 19:13:20 +0000 (12:13 -0700)]
i965/vec4: Add the ability to suppress register spilling.

In future patches, this will allow us to first try compiling a
geometry shader in DUAL_OBJECT mode (which is more efficient but uses
more registers) and then if spilling is required, fall back on
DUAL_INSTANCED mode.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965/vec4: if register allocation fails, don't try to schedule.
Paul Berry [Wed, 16 Oct 2013 20:13:20 +0000 (13:13 -0700)]
i965/vec4: if register allocation fails, don't try to schedule.

Otherwise the scheduler would be invoked with prog_data->total_grf ==
0, causing havoc.

In a future patch, this will allow us to try compiling a geometry
shader in DUAL_OBJECT mode with spilling disabled, and then fall back
to DUAL_INSTANCED mode if that failed.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965/vec4: Add the ability for attributes to be interleaved.
Paul Berry [Wed, 16 Oct 2013 18:40:41 +0000 (11:40 -0700)]
i965/vec4: Add the ability for attributes to be interleaved.

When geometry shaders are operated in "single" or "dual instanced"
mode, a single set of geometry shader inputs is interleaved into the
thread payload (with each payload register containing a pair of
inputs) in order to save register space.

This patch modifies vec4_visitor::lower_attributes_to_hw_regs so that
it can handle the interleaved format.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965/gs: Set force_writemask_all when setting up g0.
Paul Berry [Sat, 19 Oct 2013 20:26:27 +0000 (13:26 -0700)]
i965/gs: Set force_writemask_all when setting up g0.

All geometry shaders begin this instruction:

    mov(1) g0.2<1>:ud 0x0:ud { align1 }

which sets up GRF0 properly for scratch reads and writes.  Since this
instruction has a SIMD size of 1, it will only have an effect if the
first channel is enabled.  In practice, the hardware seems to always
dispatch geometry shaders with the first channel enabled, but I can't
find anything in the docs to guarantee that.

So to be on the safe side, set force_writemask_all on the instruction,
which guarantees that it will have the desired effect regardless of
which channels are enabled.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoglsl: set explicit_location correctly in lower_named_interface_blocks.
Paul Berry [Wed, 23 Oct 2013 14:55:09 +0000 (07:55 -0700)]
glsl: set explicit_location correctly in lower_named_interface_blocks.

When lower_named_interface_blocks lowers a built-in interface block
member to an ir_variable, it needs to set explicit_location in the
ir_variable.  Otherwise the linker gets confused and treats the
variable as a generic varying.

Fixes the following piglit tests, which were regressed by commit
63974c0 (glsl: Simplify the interface to
link_invalidate_variable_locations):
- clip-distance-bulk-copy
- clip-distance-in-bulk-read
- clip-distance-in-explicitly-sized
- clip-distance-in-param
- clip-distance-in-values
- core-inputs
- gs-redeclares-both-pervertex-blocks
- gs-redeclares-pervertex-in-only
- redeclare-pervertex-subset-vs-to-gs
- unsized-in-named-interface-block-gs
- unsized-in-named-interface-block-multiple
- unsized-in-unnamed-interface-block-gs
- unsized-in-unnamed-interface-block-multiple

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

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoi965/gs: Precompile geometry shaders.
Paul Berry [Wed, 23 Oct 2013 17:19:39 +0000 (10:19 -0700)]
i965/gs: Precompile geometry shaders.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoi965/vec4: Extract function to set up vec4 prog key for precompiling.
Paul Berry [Wed, 23 Oct 2013 17:17:30 +0000 (10:17 -0700)]
i965/vec4: Extract function to set up vec4 prog key for precompiling.

This will allow us to re-use it for precompiling geometry shaders.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoi965/vec4: Remove uses_clip_distance from program key.
Paul Berry [Wed, 23 Oct 2013 18:10:14 +0000 (11:10 -0700)]
i965/vec4: Remove uses_clip_distance from program key.

This should never have been in the program key in the first place,
since it's determined by the shader source, not by GL state.  Change
the code to just refer to gl_program::UsesClipDistanceOut directly.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl: Move UsesClipDistance from gl_{vertex,geometry}_program into gl_program.
Paul Berry [Wed, 23 Oct 2013 17:59:57 +0000 (10:59 -0700)]
glsl: Move UsesClipDistance from gl_{vertex,geometry}_program into gl_program.

This will make it easier for back-ends to share code between geometry
shader and vertex shader compilation.  Also, it is renamed to
"UsesClipDistanceOut" to clarify that (a) in geometry shaders, it
refers to the gl_ClipDistance output rather than the gl_ClipDistance
input, and (b) it is irrelevant in fragment shaders.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoglsl/gs: Fix transform feedback of gl_ClipDistance.
Paul Berry [Wed, 23 Oct 2013 19:55:24 +0000 (12:55 -0700)]
glsl/gs: Fix transform feedback of gl_ClipDistance.

Since gl_ClipDistance is lowered from an array of floats to an array
of vec4's during compilation, transform feedback has special logic to
keep track of the pre-lowered array size so that attempting to perform
transform feedback on gl_ClipDistance produces a result with the
correct size.

Previously, this special logic always consulted the vertex shader's
size for gl_ClipDistance.  This patch fixes it so that it uses the
geometry shader's size for gl_ClipDistance when a geometry shader is
in use.

Fixes piglit test spec/glsl-1.50/transform-feedback-type-and-size.

v2: Change the type of LastClipDistanceArraySize to "unsigned", and
clarify the comment above it.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoi965: Fix gl_MaxCombinedTextureImageUnits.
Paul Berry [Wed, 23 Oct 2013 20:36:25 +0000 (13:36 -0700)]
i965: Fix gl_MaxCombinedTextureImageUnits.

We've always overriden
ctx->Const.{Vertex,Fragment}Program.MaxTextureImageUnits to reflect
the number of texture image units supported by the hardware (rather
than using the default values assigned by Mesa core) so it seems
sensible to do that for GeometryProgram.MaxTextureImageUnits too.  We
set it to 0 if geometry shaders aren't supported.

Once that is done, we can just unconditionally add
GeometryProgram.MaxTextureImageUnits to MaxCombinedTextureImageUnits.

Fixes piglit test "spec/glsl-1.50/built-in
constants/gl_MaxCombinedTextureImageUnits".

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agofreedreno/a3xx/compiler: relative addressing
Rob Clark [Thu, 24 Oct 2013 21:53:31 +0000 (17:53 -0400)]
freedreno/a3xx/compiler: relative addressing

Signed-off-by: Rob Clark <robclark@freedesktop.org>
11 years agofreedreno/a3xx: fix const/rel/const-rel encoding
Rob Clark [Thu, 24 Oct 2013 21:45:27 +0000 (17:45 -0400)]
freedreno/a3xx: fix const/rel/const-rel encoding

The encoding of constant, relative, and relative-const src registers is
a bit more complex than originally thought, which gives an extra bit to
encode const reg # at expense of taking a bit from relative offset.

In most cases a3xx seems to actually use a scheme whereby it can encode
an extra bit for const register.  You have three possible encodings in
thirteen bits:

   register:  (11 bits for N.c)
     00........... rN.c

   relative:  (10 bits for N)
     010.......... r<a0.x + N>
     011.......... c<a0.x + N>

   const:     (12 bits for N.c)
     1............ cN.c

Which means we can deal w/ more consts than previously thought.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
11 years agofreedreno/a3xx: add blend state
Rob Clark [Thu, 19 Sep 2013 14:17:09 +0000 (10:17 -0400)]
freedreno/a3xx: add blend state

Signed-off-by: Rob Clark <robclark@freedesktop.org>
11 years agofreedreno/resource: fail more gracefully
Rob Clark [Fri, 27 Sep 2013 19:35:19 +0000 (15:35 -0400)]
freedreno/resource: fail more gracefully

Fail more gracefully when buffer allocation/import fails.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
11 years agogallivm: implement fully accurate corner filtering for seamless cube maps
Roland Scheidegger [Wed, 23 Oct 2013 17:13:21 +0000 (19:13 +0200)]
gallivm: implement fully accurate corner filtering for seamless cube maps

d3d10 requires that cube corners are filtered with accurate weights (that
is, the weight of the non-existing corner texel should be evenly distributed
to the other 3 texels). OpenGL does not require this (but recommends it).
This requires us to use different filtering code, since we need per-texel
weights which our 2d lerp doesn't (and can't) do. And of course the (now
per element) weights need to be adjusted too for it to work.
Invoke the new filtering code whenever there's an edge to keep things simpler,
as it will work for edges too not just corners but of course it's only needed
with corners.
More ugly code for not much gain but at least a hacked up cubemap demo
shows very nice corners now... Not sure yet if and how this should be
configurable...

v2: incorporate feedback from Jose, only use special corner filtering code
when there's a corner not when there's only an edge (as corner filtering code
is slower, though a perf difference was only measureable when always
forcing edge code). Plus some minor style fixes.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agomesa: Remove dricore from the build.
Eric Anholt [Sat, 28 Sep 2013 00:03:58 +0000 (17:03 -0700)]
mesa: Remove dricore from the build.

No driver uses it any more, and it's been replaced by megadrivers.

v2: Remove always-on conditional for NEED_LIBPROGRAM (review by Emil)

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agoswrast: Build the driver into the shared mesa_dri_drivers.so.
Eric Anholt [Fri, 27 Sep 2013 23:57:11 +0000 (16:57 -0700)]
swrast: Build the driver into the shared mesa_dri_drivers.so.

v2: drop dridir now that it's unused.
v3: Fix linking after rebase when building just swrast from classic but a
    drm-using gallium driver.
v4: Consistently put spaces around += in the updated Makefile.am block.
v5: Set a global driverAPI variable so loaders don't have to update to
    createNewScreen2() (though they may want to for thread safety).

Reviewed-by: Matt Turner <mattst88@gmail.com> (v3)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agoradeon: Build the driver into the shared mesa_dri_drivers.so.
Eric Anholt [Fri, 27 Sep 2013 23:32:40 +0000 (16:32 -0700)]
radeon: Build the driver into the shared mesa_dri_drivers.so.

This required some reordering of headers to ensure that the symbol name
redefines happened before any prototypes.

v2: drop dridir now that it's unused.
v3: Consistently put spaces around += in the updated Makefile.am blocks.
v4: Set a global driverAPI variable so loaders don't have to update to
    createNewScreen2() (though they may want to for thread safety).

Reviewed-by: Matt Turner <mattst88@gmail.com> (v2)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agoi915: Build the driver into the shared mesa_dri_drivers.so.
Eric Anholt [Fri, 27 Sep 2013 21:22:59 +0000 (14:22 -0700)]
i915: Build the driver into the shared mesa_dri_drivers.so.

i915 has symbols for formerly-shared code that conflict with i965, so we
define them away using gen-symbol-redefs.py.  Options considered:

- This option.  Downsides: The symbols in profiling and debugging don't
  match the source.  The symbol list may change in the future and we won't
  notice without manually running the tool again.

- Use objcopy --localize-hidden to automatically demote our symbols to
  locals.  This didn't work on i965 due to c++ weak symbols (which can't
  be localized), but could work on i915.  We could do it on i915 only, but
  it does produce libtool warnings at link time due to libtool not knowing
  if the resulting .o file is safe to link (stupid libtool).  Plus you end
  up with different symbols of the same name, which is confusing for
  debugging too.  On the other hand, no future symbol conflicts long term.

- Write our own libelf tool that handles c++ weak symbols like we want and
  apply it to all drivers.  All the downsides of above, but applies
  uniformly across drivers.

- Edit the files to just rename all the i915 or i965 symbols that
  conflict.  There are on the order of 100 that have a prefix we used to
  share, so it would take a bit of typing.  Fewest downsides, but still
  can have conflicts long term.

Ultimately, this is the least invasive change at the moment, and we can
see if the "more symbol conflicts appear later" thing is a real concern or
not.

Note that the ability to compile a version of i915 without INTEL_DEBUG env
support is dropped.  It's too useful.

v2: drop dridir now that it's unused.
v3: Consistently put spaces around += in the updated Makefile.am block.
v4: Set a global driverAPI variable so loaders don't have to update to
    createNewScreen2() (though they may want to for thread safety).

Reviewed-by: Matt Turner <mattst88@gmail.com> (v2)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agodri: Add a tool for generating #defines to namespace driver global symbols.
Eric Anholt [Fri, 27 Sep 2013 22:14:56 +0000 (15:14 -0700)]
dri: Add a tool for generating #defines to namespace driver global symbols.

Acked-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agonouveau: Build the driver into the shared mesa_dri_drivers.so.
Eric Anholt [Tue, 24 Sep 2013 17:24:07 +0000 (10:24 -0700)]
nouveau: Build the driver into the shared mesa_dri_drivers.so.

v2: drop dridir now that it's unused.
v3: Consistently put spaces around += in the updated Makefile.am block.
v4: Set a global driverAPI variable so loaders don't have to update to
    createNewScreen2() (though they may want to for thread safety).
v5: Fix missed public symbol in nouveau. (caught by Emil)

Reviewed-by: Matt Turner <mattst88@gmail.com> (v2)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agoi965: Build the driver into a shared mesa_dri_drivers.so .
Eric Anholt [Wed, 26 Jun 2013 20:04:51 +0000 (13:04 -0700)]
i965: Build the driver into a shared mesa_dri_drivers.so .

Previously, we've split things such that mesa core is in libdricore,
exposing the whole Mesa core interface in the global namespace, and the
i965_dri.so code all links against that.  Along with polluting application
namespace terribly, it requires extra PLT indirections and prevents LTO.

Instead, we can build all of the driver contents into the same .so with
just a few symbols exposed to be referenced from the actual driver .so
file, allowing LTO and reducing our exposed symbol count massively.

FPS improvement on GLB2.7 with INTEL_NO_HW=1: 2.61061% +/- 1.16957% (n=50)
(without LTO, just the PLT reductions from this commit)

Note that the X Server requires commit
7ecfab47eb221dbb996ea6c033348b8eceaeb893 to successfully load this driver!

v2: Set a global driverAPI variable so loaders don't have to update to
    createNewScreen2() (though they may want to for thread safety).
v3: Drop AM_CPPFLAGS addition (Emil pointed out I'd missed some cflags
    that would be necessary, though only if we actually relied on them).
v4: Fix install with DESTDIR set.

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> (v2)
11 years agodri: Implement a DRI vtable extension to replace the global driDriverAPI.
Eric Anholt [Thu, 26 Sep 2013 17:51:29 +0000 (10:51 -0700)]
dri: Implement a DRI vtable extension to replace the global driDriverAPI.

As we move to megadrivers, we are unable to build multiple drivers with
the same public global symbol per driver (Think an X Server with an intel
and a nouveau driver, and the X Server implementing indirect for both --
we have to actually talk to the right driver).  By slipping the
driDriverAPI vtable into the driver's extension list, we can replace the
usage of the global symbol with usage of the loader-dlsym()ed driver
information.

v2: Pull in the hunk to avoid crashing on null driver_extensions.  Thanks,
    Emil!

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agodri: Pass in the dlsym()ed driver extension to screen creation.
Eric Anholt [Fri, 27 Sep 2013 18:39:25 +0000 (11:39 -0700)]
dri: Pass in the dlsym()ed driver extension to screen creation.

This will allow a megadrivers build to reference the actual driver being
loaded from the shared dri_util screen creation code.

v2: Fix indentation, fallback case in EGL (review by Emil).

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com> (v1)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agogbm: Add support for the new __driDriverGetExtensions interface.
Eric Anholt [Sat, 12 Oct 2013 00:38:18 +0000 (17:38 -0700)]
gbm: Add support for the new __driDriverGetExtensions interface.

v2: Fix uninitialized variable use in the old-ABI case.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com> (v1)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agoegl: Add an optional function call for getting the DRI driver interface.
Eric Anholt [Tue, 24 Sep 2013 18:05:22 +0000 (11:05 -0700)]
egl: Add an optional function call for getting the DRI driver interface.

v2: Fix asprintf error checking.

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agoglx: Add an optional function call for getting the DRI driver interface.
Eric Anholt [Mon, 23 Sep 2013 21:44:10 +0000 (14:44 -0700)]
glx: Add an optional function call for getting the DRI driver interface.

The previous interface relied on a static struct, which meant that the
driver didn't get a chance to edit the struct before the struct got used.
For megadrivers, I want struct specific to the driver being loaded.

v2: Fix the prototype in the docs (caught by Marek).  Since the driver
    name was in the function, we didn't need to also pass it in.
v3: Fix asprintf error checking (caught by Matt's gcc).

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agodri: Move driver config options to dri driver extensions.
Eric Anholt [Fri, 27 Sep 2013 22:25:40 +0000 (15:25 -0700)]
dri: Move driver config options to dri driver extensions.

This way they aren't all sitting in the global namespace (with the same
name per driver).

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agodri: Allow config options to be passed to the loader through extensions.
Eric Anholt [Wed, 26 Jun 2013 22:15:57 +0000 (15:15 -0700)]
dri: Allow config options to be passed to the loader through extensions.

Turns out already we have this nice mechanism for providing optional
things from the driver to the loader, and I was going to have to rename
the public global symbol to avoid conflicts when doing megadrivers.

While the former __driConfigOptions is technically loader interface, this
is the only loader that made use of that symbol.  Continue paying
attention to it if we can't find the new option, to retain compatibility
with old drivers.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agoglx: Move the driver extension-loading to a helper function.
Eric Anholt [Fri, 27 Sep 2013 22:36:59 +0000 (15:36 -0700)]
glx: Move the driver extension-loading to a helper function.

I'm planning on doing driver extension parsing from 3 places, and making
the extension loading step a bit longer.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
11 years agoclover: Query maximum kernel block size from the device instead of the kernel object.
Francisco Jerez [Thu, 24 Oct 2013 19:09:55 +0000 (12:09 -0700)]
clover: Query maximum kernel block size from the device instead of the kernel object.

Based on a similar fix from Aaron Watry.  It seems unlikely that we
will ever need a kernel-specific setting for this, and the Gallium API
doesn't support it.  Remove kernel::max_block_size() altogether.

11 years agoglsl: silence unused 'var' variable warning
Brian Paul [Tue, 22 Oct 2013 22:50:57 +0000 (16:50 -0600)]
glsl: silence unused 'var' variable warning

Reviewed-by: Paul Berry <stereotype441@gmail.com>
11 years agosvga: remove user-space vertex/index buffer code
Brian Paul [Tue, 22 Oct 2013 22:47:38 +0000 (16:47 -0600)]
svga: remove user-space vertex/index buffer code

The gallium vbuf module, which we've been using for some time now, takes
care of uploading user-space vertex/index data into real buffers.  The
upload code in the svga driver was unused.

Reviewed-by: José Fonseca <jfonseca@vmware.com>