mesa.git
10 years agoi965: Drop special case for edgeflag thanks to Marek's change to core.
Eric Anholt [Wed, 5 Mar 2014 01:26:54 +0000 (17:26 -0800)]
i965: Drop special case for edgeflag thanks to Marek's change to core.

As of 780ce576bb1781f027797039693b98253ee4813e, we end up with R8_SSCALED
anyway.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agomesa: include stdbool.h in register_allocate.h to fix build
Brian Paul [Tue, 18 Mar 2014 17:55:50 +0000 (11:55 -0600)]
mesa: include stdbool.h in register_allocate.h to fix build

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

10 years agoi965: Enable EWA anisotropic filtering algorithm
Ian Romanick [Tue, 4 Mar 2014 09:08:05 +0000 (11:08 +0200)]
i965: Enable EWA anisotropic filtering algorithm

Volume 4, part 1 of the Ivybridge PRM says, "Generally, the EWA
approximation algorithm results in higher image quality than the legacy
algorithm."  Using a classic anisotropic filtering "tunnel" demo, it
appears that there is *no* anisotropic filtering on IVB without this bit
set.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agoi965: Actually initialize simd16_unsupported and no16_msg.
Kenneth Graunke [Tue, 18 Mar 2014 17:49:10 +0000 (10:49 -0700)]
i965: Actually initialize simd16_unsupported and no16_msg.

I meant to include this fixes in v3 of commit
de7ad2c88f4ec243c95eaed22c41d0e537912e01, but accidentally pushed a
previous version.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agoi965/upload: Refactor open-coded ALIGN-like computations.
Kenneth Graunke [Mon, 3 Mar 2014 07:09:20 +0000 (23:09 -0800)]
i965/upload: Refactor open-coded ALIGN-like computations.

Sadly, we can't use actual ALIGN(), since that only supports
power-of-two values for the alignment parameter.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoi965: Fix indentation in brw_upload_indices().
Kenneth Graunke [Mon, 3 Mar 2014 00:39:56 +0000 (16:39 -0800)]
i965: Fix indentation in brw_upload_indices().

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoi965: Consolidate code for setting brw->ib.start_vertex_offset.
Kenneth Graunke [Sun, 2 Mar 2014 23:02:54 +0000 (15:02 -0800)]
i965: Consolidate code for setting brw->ib.start_vertex_offset.

This was set identically in three places.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoi965: Allocate register sets at screen creation, not context creation.
Kenneth Graunke [Mon, 17 Mar 2014 20:53:44 +0000 (13:53 -0700)]
i965: Allocate register sets at screen creation, not context creation.

Register sets depend on the particular hardware generation, but don't
depend on anything in the actual OpenGL context.  Computing them is
fairly expensive, and they take up a large amount of memory.  Putting
them in the screen allows us to compute/allocate them once for all
contexts, saving both time and space.

Improves the performance of a context creation/destruction
microbenchmark by about 3x on my Haswell i7-4750HQ.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agoi965: Allocate the screen using ralloc rather than calloc.
Kenneth Graunke [Mon, 17 Mar 2014 20:57:14 +0000 (13:57 -0700)]
i965: Allocate the screen using ralloc rather than calloc.

This will allow us to use the screen as a memory context.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agora: Convert another bool array to bitsets.
Eric Anholt [Mon, 17 Mar 2014 21:53:08 +0000 (14:53 -0700)]
ra: Convert another bool array to bitsets.

This one saves about 2MB peak allocation in glsl-fs-algebraic-add-add-1,
with no performance difference on timing short shader-db runs (n=9/10,
warmup outlier removed).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agora: Use a bitset for storing which registers belong to a class.
Kenneth Graunke [Sat, 22 Feb 2014 03:50:15 +0000 (19:50 -0800)]
ra: Use a bitset for storing which registers belong to a class.

This should use 1/8 the memory.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Christoph Brill <egore911@gmail.com>
10 years agora: Create a reg_belongs_to_class() helper function.
Kenneth Graunke [Sat, 22 Feb 2014 03:31:44 +0000 (19:31 -0800)]
ra: Create a reg_belongs_to_class() helper function.

This is a little easier to read.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Christoph Brill <egore911@gmail.com>
10 years agora: Use bool instead of GLboolean.
Kenneth Graunke [Sat, 22 Feb 2014 03:32:24 +0000 (19:32 -0800)]
ra: Use bool instead of GLboolean.

This isn't the GL API, so there's no reason to use GLboolean.

Using bool is safer: any non-zero value is treated as "true".  When
converting a value to a GLboolean, all but the low byte is discarded,
which means that values like 256 will be incorrectly rendered as false.

Done via the following vim commands:
:%s/GLboolean/bool/g
:%s/GL_TRUE/true/g
:%s/GL_FALSE/false/g
and one line of manual whitespace tidying.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agoi965: Accurately bail on SIMD16 compiles.
Kenneth Graunke [Fri, 7 Mar 2014 08:49:45 +0000 (00:49 -0800)]
i965: Accurately bail on SIMD16 compiles.

Ideally, we'd like to never even attempt the SIMD16 compile if we could
know ahead of time that it won't succeed---it's purely a waste of time.
This is especially important for state-based recompiles, which happen at
draw time.

The fragment shader compiler has a number of checks like:

   if (dispatch_width == 16)
      fail("...some reason...");

This patch introduces a new no16() function which replaces the above
pattern.  In the SIMD8 compile, it sets a "SIMD16 will never work" flag.
Then, brw_wm_fs_emit can check that flag, skip the SIMD16 compile, and
issue a helpful performance warning if INTEL_DEBUG=perf is set.  (In
SIMD16 mode, no16() calls fail(), for safety's sake.)

The great part is that this is not a heuristic---if the flag is set, we
know with 100% certainty that the SIMD16 compile would fail.  (It might
fail anyway if we run out of registers, but it's always worth trying.)

v2: Fix missing va_end in early-return case (caught by Ilia Mirkin).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz> [v1]
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> [v1]
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agoi965/fs: Support pull parameters in SIMD16 mode.
Kenneth Graunke [Sat, 8 Mar 2014 00:10:50 +0000 (16:10 -0800)]
i965/fs: Support pull parameters in SIMD16 mode.

This is just a matter of reusing the pull/push constant information set
up by the SIMD8 compile.

This gains us 78 SIMD16 programs in shader-db.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agoi965/fs: Use a single instance of the pull_constant_loc[] array.
Kenneth Graunke [Wed, 12 Mar 2014 05:24:39 +0000 (22:24 -0700)]
i965/fs: Use a single instance of the pull_constant_loc[] array.

Now that we don't renumber uniform registers, assign_constant_locations
and move_uniform_array_access_to_pull_constants use the same names.
So, they can share a single copy of the pull_constant_loc[] array.

This simplifies the code considerably.  assign_constant_locations()
doesn't need to walk through pull_params[] to rediscover reladdr
demotions; it just has that information in pull_constant_loc[].  We also
only need to rewrite the instruction stream once, instead of twice.

Even better, we now have a single array describing the layout of
all pull parameters, which we can pass to the SIMD16 program.

This actually hurts a few shaders in Serious Sam 3, and one in KWin:
total instructions in shared programs: 1841957 -> 1842035 (0.00%)
instructions in affected programs:     1165 -> 1243 (6.70%)
Comparing dump_instructions() before and after the pull constant
transformations with and without this patch, it appears that there is
a uniform array with variable indexing (reladdr) and constant indexing
(of array element 0).  Previously, we uploaded array element 0 as both
a pull constant (for reladdr) /and/ a push constant.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agoi965/fs: Don't renumber UNIFORM registers.
Kenneth Graunke [Tue, 11 Mar 2014 21:35:27 +0000 (14:35 -0700)]
i965/fs: Don't renumber UNIFORM registers.

Previously, remove_dead_constants() would renumber the UNIFORM registers
to be sequential starting from zero, and the resulting register number
would be used directly as an index into the params[] array.

This renumbering made it difficult to collect and save information about
pull constant locations, since setup_pull_constants() and
move_uniform_array_access_to_pull_constants() used different names.

This patch generalizes setup_pull_constants() to decide whether each
uniform register should be a pull constant, push constant, or neither
(because it's unused).  Then, it stores mappings from UNIFORM register
numbers to params[] or pull_params[] indices in the push_constant_loc
and pull_constant_loc arrays.  (We already did this for pull constants.)

Then, assign_curb_setup() just needs to consult the push_constant_loc
array to get the real index into the params[] array.

This effectively folds all the remove_dead_constants() functionality
into assign_constant_locations(), while being less irritable to work
with.

v2: Add assert(remapped <= i), requested by Topi.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agoi965/fs: Split pull parameter decision making from mechanical demoting.
Kenneth Graunke [Mon, 10 Mar 2014 20:14:03 +0000 (13:14 -0700)]
i965/fs: Split pull parameter decision making from mechanical demoting.

move_uniform_array_access_to_pull_constants() and setup_pull_constants()
both have two parts:

1. Decide which UNIFORM registers to demote to pull constants, and
   assign locations.
2. Mechanically rewrite the instruction stream to pull the uniform
   value into a temporary VGRF and use that, eliminating the UNIFORM
   file access.

In order to support pull constants in SIMD16 mode, we will need to make
decisions exactly once, but rewrite both instruction streams.
Separating these two tasks will make this easier.

This patch introduces a new helper, demote_pull_constants(), which
takes care of rewriting the instruction stream, in both cases.

For the moment, a single invocation of demote_pull_constants can't
safely handle both reladdr and non-reladdr tasks, since the two callers
still use different names for uniforms due to remove_dead_constants()
remapping of things.  So, we get an ugly boolean parameter saying
which to do.  This will go away.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agoi965/fs: Record pull constant locations for all array elements.
Kenneth Graunke [Fri, 7 Mar 2014 23:45:13 +0000 (15:45 -0800)]
i965/fs: Record pull constant locations for all array elements.

When demoting a variably indexed uniform array to pull constants, we
only recorded the location for the base of the array (element 0).

Recording locations for all array elements is a trivial amount of code
and will make subsequent refactoring easier.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agoi965/fs: Save push constant location information.
Kenneth Graunke [Fri, 7 Mar 2014 10:10:14 +0000 (02:10 -0800)]
i965/fs: Save push constant location information.

Previously, both move_uniform_array_access_to_pull_constants() and
setup_pull_constants() maintained stack-local arrays with this
information.  Storing this information will allow it to be used from
multiple functions, allowing us to split and move code around.

We'll also eventually want to pass pull constant location information
to the SIMD16 compile.  Saving this information will help us do that.

Unfortunately, the two functions *cannot* share the contents of the
array just yet.  remove_dead_constants() renumbers all the UNIFORM
registers to be contiguous starting at zero, so the two functions
talk about uniforms using different names.  We can't even remap them,
since move_uniform_array_access_to_pull_constants() deletes UNIFORM
registers that are only accessed with reladdr, so remove_dead_constants
can't even see them.

This situation will improve in the next few patches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agoi965/fs: Delete dead code to fail compiles with SIMD16 pull parameters.
Kenneth Graunke [Tue, 11 Mar 2014 06:22:48 +0000 (23:22 -0700)]
i965/fs: Delete dead code to fail compiles with SIMD16 pull parameters.

The SIMD8 compile will determine whether pull parameters are necessary.
If so, it will set prog_data->nr_pull_params to a value greater than 0.

brw_wm_fs_emit checks if nr_pull_params > 0 and skips the SIMD16 compile
altogether.  So, this code should never occur.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agogallium/docs: update SLT, SGE, SFL, STR opcode docs
Brian Paul [Mon, 17 Mar 2014 21:13:55 +0000 (15:13 -0600)]
gallium/docs: update SLT, SGE, SFL, STR opcode docs

To emphasize that the result is floating point 1.0 or 0.0, to match
other opcodes like SLE and SEQ.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
10 years agoglx: Fix incorrect pdp assignment in dri2_bind_context().
Charmaine Lee [Thu, 13 Mar 2014 17:33:00 +0000 (11:33 -0600)]
glx: Fix incorrect pdp assignment in dri2_bind_context().

pdp should be set to dpyPriv->dri2Display.
Fixes blank frame failure running glretrace ClearView.

Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agonvc0: Handle user mapped vertex buffer for edgeflag
Maarten Lankhorst [Tue, 18 Mar 2014 13:47:40 +0000 (14:47 +0100)]
nvc0: Handle user mapped vertex buffer for edgeflag

Handle mapping edgeflag data similar to the code around it.
This fixes a crash in piglit test gl-2.0-edgeflag.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
10 years agoclover: Fix region size error checking in some buffer transfer commands.
Francisco Jerez [Fri, 14 Mar 2014 10:31:11 +0000 (11:31 +0100)]
clover: Fix region size error checking in some buffer transfer commands.

Tested-by: Tom Stellard <thomas.stellard@amd.com>
10 years agonv50/ir/gk110: add postfactor support for fmul
Ilia Mirkin [Sat, 15 Mar 2014 16:42:51 +0000 (12:42 -0400)]
nv50/ir/gk110: add postfactor support for fmul

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: set not modifier on first source of logic op
Ilia Mirkin [Sat, 15 Mar 2014 14:22:22 +0000 (10:22 -0400)]
nv50/ir/gk110: set not modifier on first source of logic op

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: use shl/shr instead of lshf/rshf so that c[] is supported
Ilia Mirkin [Fri, 14 Mar 2014 12:16:00 +0000 (08:16 -0400)]
nv50/ir/gk110: use shl/shr instead of lshf/rshf so that c[] is supported

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: add 64/128-bit fetch/export support
Ilia Mirkin [Fri, 14 Mar 2014 10:20:36 +0000 (06:20 -0400)]
nv50/ir/gk110: add 64/128-bit fetch/export support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: fix handling of OP_SUB for floating point ops
Ilia Mirkin [Fri, 14 Mar 2014 10:11:37 +0000 (06:11 -0400)]
nv50/ir/gk110: fix handling of OP_SUB for floating point ops

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: presin/preex2 take their source at bit 23
Ilia Mirkin [Fri, 14 Mar 2014 09:46:14 +0000 (05:46 -0400)]
nv50/ir/gk110: presin/preex2 take their source at bit 23

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: add implementations of div u32/s32
Ilia Mirkin [Wed, 12 Mar 2014 16:00:58 +0000 (12:00 -0400)]
nv50/ir/gk110: add implementations of div u32/s32

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: implement quadop
Ilia Mirkin [Wed, 12 Mar 2014 13:33:00 +0000 (09:33 -0400)]
nv50/ir/gk110: implement quadop

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: fill in mov from predicate
Ilia Mirkin [Tue, 11 Mar 2014 18:54:25 +0000 (14:54 -0400)]
nv50/ir/gk110: fill in mov from predicate

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: handle derivAll flag, fix useOffsets for non-txf
Ilia Mirkin [Tue, 11 Mar 2014 17:03:02 +0000 (13:03 -0400)]
nv50/ir/gk110: handle derivAll flag, fix useOffsets for non-txf

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: fix setting texture for txd/txf/txq
Ilia Mirkin [Tue, 11 Mar 2014 16:13:45 +0000 (12:13 -0400)]
nv50/ir/gk110: fix setting texture for txd/txf/txq

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: add texcsaa implementation
Ilia Mirkin [Tue, 11 Mar 2014 15:21:35 +0000 (11:21 -0400)]
nv50/ir/gk110: add texcsaa implementation

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: add pfetch support
Ilia Mirkin [Tue, 11 Mar 2014 14:48:15 +0000 (10:48 -0400)]
nv50/ir/gk110: add pfetch support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: add emit/restart implementations
Ilia Mirkin [Tue, 11 Mar 2014 14:25:29 +0000 (10:25 -0400)]
nv50/ir/gk110: add emit/restart implementations

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: add missing break in sched emit
Ilia Mirkin [Tue, 11 Mar 2014 13:38:38 +0000 (09:38 -0400)]
nv50/ir/gk110: add missing break in sched emit

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: implement partial txq support
Ilia Mirkin [Tue, 11 Mar 2014 12:30:49 +0000 (08:30 -0400)]
nv50/ir/gk110: implement partial txq support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: fill out texture instruction support
Ilia Mirkin [Tue, 11 Mar 2014 12:30:01 +0000 (08:30 -0400)]
nv50/ir/gk110: fill out texture instruction support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonv50/ir/gk110: fix control flow opcode emission, add sat flag
Ilia Mirkin [Tue, 11 Mar 2014 09:44:00 +0000 (05:44 -0400)]
nv50/ir/gk110: fix control flow opcode emission, add sat flag

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agoegl/main: Enable Linux platform extensions
Chad Versace [Thu, 23 Jan 2014 15:26:10 +0000 (07:26 -0800)]
egl/main: Enable Linux platform extensions

Enable EGL_EXT_platform_base and the Linux platform extensions layered
atop it: EGL_EXT_platform_x11, EGL_EXT_platform_wayland,
and EGL_MESA_platform_gbm.

Tested with Piglit's EGL_EXT_platform_base tests under an X11 session.
To enable running the Wayland and GBM tests, windowed Weston was running
and the kernel had render nodes enabled.

I regression tested my EGL_EXT_platform_base patch set with Piglit on
Ivybridge under X11/EGL, standalone Weston, and GBM with rendernodes. No
regressions found.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/wayland: Emit EGL_BAD_PARAMETER for eglCreatePlatformPixmapSurface
Chad Versace [Sun, 9 Feb 2014 17:13:27 +0000 (09:13 -0800)]
egl/wayland: Emit EGL_BAD_PARAMETER for eglCreatePlatformPixmapSurface

From the EGL_EXT_wayland_spec, version 3:

  It is not valid to call eglCreatePlatformPixmapSurfaceEXT with a <dpy>
  that belongs to Wayland. Any such call fails and generates
  EGL_BAD_PARAMETER.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/gbm: Emit EGL_BAD_PARAMETER for eglCreatePlatformPixmapSurface
Chad Versace [Sun, 9 Feb 2014 17:13:08 +0000 (09:13 -0800)]
egl/gbm: Emit EGL_BAD_PARAMETER for eglCreatePlatformPixmapSurface

From the EGL_MESA_platform_gbm spec, version 5:

  It is not valid to call eglCreatePlatformPixmapSurfaceEXT with a <dpy>
  that belongs to the GBM platform. Any such call fails and generates
  EGL_BAD_PARAMETER.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/main: Stop using EGLNative types internally
Chad Versace [Tue, 7 Jan 2014 22:54:51 +0000 (14:54 -0800)]
egl/main: Stop using EGLNative types internally

Internally, much of the EGL code uses EGLNativeDisplayType,
EGLNativeWindowType, and EGLPixmapType. However, the EGLNative type
often does not match the variable's actual type.

The concept of EGLNative types are a bad match for Linux, as explained
below. And the EGL platform extensions don't use EGLNative types at all.
Those extensions attempt to solve cross-platform issues by moving the
EGL API away from the EGLNative types.

The core of the problem is that eglplatform.h can define each EGLNative
type once only, but Linux supports multiple EGL platforms.

To work around the problem, Mesa's eglplatform.h contains multiple
definitions of each EGLNative type, selected by feature macros. Mesa
expects EGL clients to set the feature macro approrpiately. But the
feature macros don't work when a single codebase must be built with
support for multiple EGL platforms, *such as Mesa itself*.

When building libEGL, autotools chooses the EGLNative typedefs based on
the first element of '--with-egl-platforms'. For example,
'--with-egl-platforms=x11,drm,wayland' defines the following:

    typedef Display* EGLNativeDisplayType;
    typedef Window   EGLNativeWindowType;
    typedef Pixmap   EGLNativePixmapType;

Clearly, this doesn't work well for Wayland and GBM.  Mesa works around
the problem by casting the EGLNative types to different things in
different files.

For sanity's sake, and to prepare for the EGL platform extensions, this
patch removes from egl/main and egl/dri2 all internal use of the
EGLNative types. It replaces them with 'void*' and checks each explicit
cast with a static assertion. Also, the patch touches egl_gallium the
minimal amount to keep it compatible with eglapi.h.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl: Add STATIC_ASSERT() macro
Chad Versace [Tue, 7 Jan 2014 22:23:49 +0000 (14:23 -0800)]
egl: Add STATIC_ASSERT() macro

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglCreateImageKHR by display, not driver
Chad Versace [Wed, 29 Jan 2014 01:03:03 +0000 (17:03 -0800)]
egl/dri2: Dispatch eglCreateImageKHR by display, not driver

Add dri2_egl_display_vtbl::create_image, set it for each platform, and
let egl_dri2 dispatch eglCreateImageKHR to that.

To remove ambiguity, rename egl_dri2.c:dri2_create_image() to
dri2_create_image_from_dri().

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2/x11: Don't clobber _EGLDriver::API
Chad Versace [Wed, 29 Jan 2014 03:38:39 +0000 (19:38 -0800)]
egl/dri2/x11: Don't clobber _EGLDriver::API

dri2_initialize_x11_swrast() does a strange thing. For some extensions
it doesn't support, it sets the corresponding functions in
_EGLDriver::API to NULL. The intention here is clear, but misplaced.

NULL or not, the function pointers never get called because their
extensions aren't supported.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglCreateWaylandBufferFromImageWL by display, not driver
Chad Versace [Wed, 29 Jan 2014 01:03:03 +0000 (17:03 -0800)]
egl/dri2: Dispatch eglCreateWaylandBufferFromImageWL by display, not driver

Add dri2_egl_display_vtbl::create_wayland_buffer_from_image, set it for
each platform, and let egl_dri2 dispatch
eglCreateWaylandBufferFromImageWL to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Consolidate eglTerminate
Chad Versace [Wed, 29 Jan 2014 02:53:56 +0000 (18:53 -0800)]
egl/dri2: Consolidate eglTerminate

egl_dri2.c:dri2_terminate() handled terminating X11 and DRM displays.
The Wayland platform implemented its own dri2_wl_terminate(), which was
nearly a copy of the common one.

To implement the EGL platform extensions, we either need to dispatch
eglTerminate per display or define a common implementation for all
platforms. This patch chooses consolidation.  It removes
dri2_wl_terminate() by folding it into the common dri2_terminate().

It was necessary to invert the `if (disp->PlatformDisplay == NULL)` and
the switch statement because, unlike DRM and X11, Wayland's terminator
performed action even when EGL didn't own the native display. In the
inversion, I replaced `disp->PlatformDisplay == NULL` with
`dri2_dpy->own_device` because the two expressions are synonymous, but
the latter's meaning is clearer.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2/x11: Set dri2_dpy->own_device
Chad Versace [Wed, 29 Jan 2014 02:52:00 +0000 (18:52 -0800)]
egl/dri2/x11: Set dri2_dpy->own_device

When the user calls eglGetDisplay(EGL_DEFAULT_DISPLAY), the Wayland and
DRM platforms set dri2_dpy->own_device=true. This patch makes the X11
platform do the same for consistency.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglPostSubBufferNV by display, not driver
Chad Versace [Wed, 29 Jan 2014 01:03:03 +0000 (17:03 -0800)]
egl/dri2: Dispatch eglPostSubBufferNV by display, not driver

Add dri2_egl_display_vtbl::post_sub_buffer, set it for each
platform, and let egl_dri2 dispatch eglPostSubBufferNV to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglSwapBuffersRegionNOK by display, not driver
Chad Versace [Wed, 29 Jan 2014 01:03:03 +0000 (17:03 -0800)]
egl/dri2: Dispatch eglSwapBuffersRegionNOK by display, not driver

Add dri2_egl_display_vtbl::swap_buffers_region, set it for each
platform, and let egl_dri2 dispatch eglSwapBuffersRegionNOK to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglCopyBuffers by display, not driver
Chad Versace [Wed, 29 Jan 2014 01:03:03 +0000 (17:03 -0800)]
egl/dri2: Dispatch eglCopyBuffers by display, not driver

Add dri2_egl_display_vtbl::copy_buffers, set it for each
platform, and let egl_dri2 dispatch eglCopyBuffers to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch API.QueryBufferAge by display, not driver
Chad Versace [Wed, 29 Jan 2014 01:03:03 +0000 (17:03 -0800)]
egl/dri2: Dispatch API.QueryBufferAge by display, not driver

Add dri2_egl_display_vtbl::query_buffer_age, set it for each
platform, and let egl_dri2 dispatch API.QueryBufferAge to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglDestroySurface by display, not driver
Chad Versace [Wed, 29 Jan 2014 01:03:03 +0000 (17:03 -0800)]
egl/dri2: Dispatch eglDestroySurface by display, not driver

Add dri2_egl_display_vtbl::destroy_surface, set it for each
platform, and let egl_dri2 dispatch eglDestroySurface to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglCreatePbufferSurface by display, not driver
Chad Versace [Wed, 29 Jan 2014 01:03:03 +0000 (17:03 -0800)]
egl/dri2: Dispatch eglCreatePbufferSurface by display, not driver

Add dri2_egl_display_vtbl::create_pbuffer_surface, set it for each
platform, and let egl_dri2 dispatch eglCreatePbufferSurface to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglCreatePixmapSurface by display, not driver
Chad Versace [Wed, 29 Jan 2014 00:45:07 +0000 (16:45 -0800)]
egl/dri2: Dispatch eglCreatePixmapSurface by display, not driver

Add dri2_egl_display_vtbl::create_pbuffer_surface, set it for each
platform, and let egl_dri2 dispatch eglCreatePixmapSurface to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglCreateWindowSurface by display, not driver
Chad Versace [Wed, 29 Jan 2014 00:39:09 +0000 (16:39 -0800)]
egl/dri2: Dispatch eglCreateWindowSurface by display, not driver

Add dri2_egl_display_vtbl::create_window_surface, set it for each
platform, and let egl_dri2 dispatch eglCreateWindowSurface to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglSwapBuffersWithDamage by display, not driver
Chad Versace [Wed, 29 Jan 2014 00:26:44 +0000 (16:26 -0800)]
egl/dri2: Dispatch eglSwapBuffersWithDamage by display, not driver

Add dri2_egl_display_vtbl::swap_buffers_with_damage, set it for each
platform, and let egl_dri2 dispatch eglSwapBuffersWithDamageEXT to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglSwapBuffers by display, not driver
Chad Versace [Wed, 29 Jan 2014 00:21:21 +0000 (16:21 -0800)]
egl/dri2: Dispatch eglSwapBuffers  by display, not driver

Add dri2_egl_display_vtbl::swap_buffers, set it for each platform, and
let egl_dri2 dispatch eglSwapBuffers to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Dispatch eglSwapInterval by display, not driver
Chad Versace [Tue, 28 Jan 2014 20:34:19 +0000 (12:34 -0800)]
egl/dri2: Dispatch eglSwapInterval by display, not driver

Add dri2_egl_display_vtbl::swap_interval, set it for each platform, and
let egl_dri2 dispatch eglSwapInterval to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/wl,x11: Call dri2_swap_interval() statically
Chad Versace [Tue, 28 Jan 2014 00:42:10 +0000 (16:42 -0800)]
egl/wl,x11: Call dri2_swap_interval() statically

Don't call it through the driver dispatch table. Just call it
statically.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Put platform func names into proper namespaces
Chad Versace [Tue, 28 Jan 2014 20:47:38 +0000 (12:47 -0800)]
egl/dri2: Put platform func names into proper namespaces

Each of the egl_dri2 platforms (except Android) prefix their function
names with "dri2", not "dri2_${platform}". This means many function
names have three separate definitions in the egl_dri2 directory: one in
each of platform_drm.c, platform_wayland.c, and platform_x11.c. For
example, each of the three files defines dri2_create_window_surface().

The name collisions make it difficult to review patches for correctness
("Is this patch hunk calling a platform_x11 function or a global
egl_dri2 function?"), complicate debugging, and confuse code navigation
tools.

For each function in platform_x11.c prefixed with 'dri2', this patch
changes its prefix to 'dri2_x11'. Likewise for platform_drm.c and
'dri2_drm'; and platform_wayland.c and 'dri2_wl'.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl/dri2: Move dri2_egl_display virtual funcs to vtbl
Chad Versace [Tue, 28 Jan 2014 19:41:46 +0000 (11:41 -0800)]
egl/dri2: Move dri2_egl_display virtual funcs to vtbl

dri2_egl_display has only one virtual function, 'authenticate'.  Define
dri2_egl_display::vtbl and move 'authenticate' there.

This prepares for the EGL platform extensions, which will add many
more virtual functions to dri2_egl_display.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agoegl: Update to revision 24567 of eglext.h
Chad Versace [Tue, 7 Jan 2014 20:23:06 +0000 (12:23 -0800)]
egl: Update to revision 24567 of eglext.h

This pulls in EGL_EXT_platform_base, EGL_EXT_platform_wayland,
EGL_EXT_platform_x11, and EGL_MESA_platform_gbm.

This patch has a lot of churn because Khronos recently changed its
method of generating headers. Khronos now generates it headers from XML.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
10 years agowinsys/radeon: Store GPU virtual memory addresses of BOs in a hash table
Michel Dänzer [Thu, 13 Mar 2014 01:25:10 +0000 (10:25 +0900)]
winsys/radeon: Store GPU virtual memory addresses of BOs in a hash table

This allows retrieving the existing BO and incrementing its reference count,
instead of creating a separate winsys representation for it, when the kernel
reports that the BO was already assigned a virtual memory address.

This fixes problems with XWayland using radeonsi and the
xf86-video-wlglamor driver, which calls GEM flink outside of the radeon
winsys code and creates BOs from the flinked names using the same DRM file
descriptor.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
10 years agotargets/dri-ilo: make the driver installable
Chia-I Wu [Sat, 15 Mar 2014 15:18:35 +0000 (23:18 +0800)]
targets/dri-ilo: make the driver installable

install-gallium-links.mk fails to create the compat link for ilo_dri.so
because it looks for dri_LTLIBRARIES instead of noinst_LTLIBRARIES.  Fix this
by switching to dri_LTLIBRARIES (and make the driver installable).

Since pci_id_driver_map.h and the DDX both tell libGL.so to look for "i965",
ilo_dri.so will never be loaded even enabled and installed.  The change should
not create any more confusion.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
10 years agomesa: mark GL_RGB9_E5 as not color-renderable
Marek Olšák [Sun, 9 Mar 2014 13:18:45 +0000 (14:18 +0100)]
mesa: mark GL_RGB9_E5 as not color-renderable

The GL 4.4 spec says it's not color-renderable and not accepted
by RenderBufferStorage. The EXT_texture_shared_exponent spec says
it's not color-renderable but it's accepted by RenderBufferStorageEXT.
This seems to be a bug in the extension spec.

Let's do what GL 4.4 says.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
10 years agoradeonsi/compute: Fix memory leak
Aaron Watry [Wed, 12 Mar 2014 18:26:10 +0000 (13:26 -0500)]
radeonsi/compute: Fix memory leak

Free shader buffer object for all kernels when deleting compute state.

Signed-off-by: Aaron Watry <awatry@gmail.com>
10 years agost/mesa: remove _NEW_POLYGON dependency from vertex shader
Marek Olšák [Tue, 4 Mar 2014 00:45:48 +0000 (01:45 +0100)]
st/mesa: remove _NEW_POLYGON dependency from vertex shader

We can just check the polygon mode when updating the edge flag state.
Also, we can just flag ST_NEW_VERTEX_PROGRAM directly, which makes
ST_NEW_EDGEFLAGS_DATA useless.

10 years agost/mesa: implement zero-stride edge flag by culling primitives
Marek Olšák [Tue, 4 Mar 2014 00:11:49 +0000 (01:11 +0100)]
st/mesa: implement zero-stride edge flag by culling primitives

This was unimplemented.

10 years agost/mesa: fix per-vertex edge flags and GLSL support (v2)
Marek Olšák [Mon, 3 Mar 2014 00:04:22 +0000 (01:04 +0100)]
st/mesa: fix per-vertex edge flags and GLSL support (v2)

This fixes piglit/gl-2.0-edgeflag.

v2: use StrideB to recognize per-vertex edge flags

Cc: mesa-stable@lists.freedesktop.org
10 years agoi965/fs: Invalidate live intervals when demoting uniforms to pull params.
Kenneth Graunke [Tue, 11 Mar 2014 06:55:21 +0000 (23:55 -0700)]
i965/fs: Invalidate live intervals when demoting uniforms to pull params.

Normally, nothing uses live intervals at this point, so this isn't
necessary.  However, dump_instructions() calculates them and uses them
to show register pressure.  So, calling dump_instructions() in this area
of the code would segfault due to the arrays being the wrong size.

This is not a candidate for stable branches because it only serves to
fix internal debugging code that you manually have to invoke by altering
the source code or using gdb.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agoi965/fs: Print "+reladdr" on variably-indexed uniform arrays.
Kenneth Graunke [Tue, 11 Mar 2014 07:11:42 +0000 (00:11 -0700)]
i965/fs: Print "+reladdr" on variably-indexed uniform arrays.

Previously, dump_instruction() would print output such as:
   {  2}    3: mov vgrf1:F, u0:F
   {  3}    4: mov vgrf7:F, u0:F
   {  4}    5: mov vgrf8:F, u0:F
which looked like either a scalar access or perhaps a constant-indexed
access of element 0, when it was really a variable index.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agoi965: Fix register types in dump_instructions(), again.
Kenneth Graunke [Tue, 11 Mar 2014 07:04:35 +0000 (00:04 -0700)]
i965: Fix register types in dump_instructions(), again.

In commit e57d77280efcbfd6579a88f071426653287ef833, I fixed this for
destinations in the Vec4 backend, and sources in the scalar backend.
But not both types in both backends.

To prevent this mess from continuing, make the reg_encoding table
static, so only the disassembler can use it.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
10 years agoi965/fs: Fix register comparisons in saturate propagation.
Kenneth Graunke [Wed, 12 Mar 2014 00:11:36 +0000 (17:11 -0700)]
i965/fs: Fix register comparisons in saturate propagation.

opt_saturate_propagation_local compares scan_inst->dst.reg/reg_offset
with inst->src[0].reg/reg_offset, and ensures that scan_inst->dst.file
is GRF.  But nothing ensured that inst->src[0].file was GRF.

In the following program, this resulted in u1:F matching vgrf1:UW,
and a saturate being incorrectly propagated from instruction 8 to
instruction 1.

{  1}    0: add vgrf0:UW, hw_reg1+8:UW, hw_reg0:V
{  1}    1: add vgrf1:UW, hw_reg1+10:UW, hw_reg0:V
{  1}    2: linterp vgrf6:F, hw_reg2:F, hw_reg3:F, hw_reg0:F
{  2}    3: linterp vgrf27:F, hw_reg2:F, hw_reg3:F, hw_reg0+16:F
{  4}    4: mov vgrf10+0.0:F, vgrf6:F
{  3}    5: mov vgrf10+1.0:F, vgrf27:F
{  6}    6: tex vgrf8+0.0:F, vgrf10+0.0:F
{  5}    7: mov vgrf32:F, u1:F
{  5}    8: mov.sat vgrf12:F, u1:F

From shader-db:
   total instructions in shared programs: 1841932 -> 1841957 (0.00%)
   instructions in affected programs:     5823 -> 5848 (0.43%)
I inspected two of the 25 hurt shaders, and concluded that they were
both hitting this bug, and not legitimately optimized.

This fixes bugs in Left 4 Dead 2 and Team Fortress 2, possibly among
others.  The optimization pass didn't exist in 10.0, so this is only
a candidate for 10.1.

Cc: "10.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agoglsl: Improve debug output and variable names for opt_dead_code_local.
Eric Anholt [Thu, 6 Mar 2014 07:03:42 +0000 (23:03 -0800)]
glsl: Improve debug output and variable names for opt_dead_code_local.

I know this code has confused others, and it confused me 3 years later,
too.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
10 years agoi965: Add support for GL_ARB_buffer_storage.
Eric Anholt [Tue, 25 Feb 2014 22:25:46 +0000 (14:25 -0800)]
i965: Add support for GL_ARB_buffer_storage.

It turns out we can allow COHERENT storage/mappings all the time,
regardless of LLC vs non-LLC.  It just means never using temporary
mappings to avoid GPU stalls, and on non-LLC we have to use the GTT intead
of CPU mappings.  If we were to use CPU maps on non-LLC (which might be
useful if apps end up using buffer_storage on PBO reads, to avoid WC read
slowness), those would be PERSISTENT but not COHERENT, but doing that
would require us driving the clflushes from userspace somehow.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agoi965: Always use CPU mappings for BOs on LLC platforms.
Eric Anholt [Thu, 27 Feb 2014 18:05:39 +0000 (10:05 -0800)]
i965: Always use CPU mappings for BOs on LLC platforms.

It looks like there's no big difference for write-only workloads, but
using a CPU map means that if they happen to read without having set the
MAP_READ_BIT, they get 100x the performance for those reads.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agoi965: Drop the system-memory temporary allocations for flush explicit.
Eric Anholt [Tue, 25 Feb 2014 19:50:44 +0000 (11:50 -0800)]
i965: Drop the system-memory temporary allocations for flush explicit.

While in expected usage patterns nobody will ever hit this path, doubling
our bandwidth used seems like a waste, and it cost us extra code too.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agoi965: Switch mapping modes for non-explicit-flush blit-temporary maps.
Eric Anholt [Tue, 25 Feb 2014 20:15:31 +0000 (12:15 -0800)]
i965: Switch mapping modes for non-explicit-flush blit-temporary maps.

On LLC, it should always be better to use a cached mapping than the GTT.
On non-LLC, it seems pretty silly to try to optimize read performance for
the INVALIDATE_RANGE_BIT case.  This will make the buffer_storage logic
easier.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agogallivm: optimize repeat linear npot code in the aos int path
Jeff Muizelaar [Sat, 15 Feb 2014 00:47:12 +0000 (01:47 +0100)]
gallivm: optimize repeat linear npot code in the aos int path

Similar to the other cases, shift some weight/coord calculations to int
space. This should be slightly faster (on x86 sse it should actually safe one
instruction, and generally int instructions are cheaper).

10 years agogallivm: use correct rounding for nearest wrap mode (in the aos int path)
Roland Scheidegger [Sat, 15 Feb 2014 02:45:00 +0000 (03:45 +0100)]
gallivm: use correct rounding for nearest wrap mode (in the aos int path)

The previous code used coords which were calculated as
(int) (f_coord * tex_size * 256) >> 8.
This is not only unnecessarily complex but can give the wrong texel due to
rounding for negative coords (as an example, after denormalization coords
from -1.0 to 0.0 should give -1, but this will give -1 for numbers from
-1.0-1/256 - 0.0-1/256.
Instead, juse use ifloor, dropping the shift stuff.
Unfortunately, this will most likely be slower - with arch rounding available
it shouldn't be too bad (trades a int shift for a round but also saves an int
mul (which is shared by all coords) but otherwise it's a mess.

10 years agogallivm: use correct rounding for linear wrap mode (in the aos int path)
Jeff Muizelaar [Sat, 15 Feb 2014 01:34:39 +0000 (02:34 +0100)]
gallivm: use correct rounding for linear wrap mode (in the aos int path)

The previous method for converting coords to ints was sligthly inaccurate
(effectively losing 1bit from the 8bit lerp weight). This is probably
especially noticeable when trying to draw a pixel-aligned texture.
As an example, for a 100x100 texture after dernormalization the texture
coords in this case would turn up as
0.5, 1.5, 2.5, 3.5, 4.5, ...
After the mul by 256, conversion to int and 128 subtraction, they end up as
0, 256, 512, 768, 1024, ...
which gets us the correct coords/weights of
0/0, 1/0, 2/0, 3/0, 4/0, ...
But even LSB errors (which are unavoidable) in the input coords may cause
these coords/weights to be wrong, e.g. for a coord of 3.49999 we'd get a
coord/weight of 2/255 instead.

Fix this by using round-to-nearest int instead of FPToSi (trunc). Should be
equally fast on x86 sse though other archs probably suffer a little.

10 years agoglapi: restore _glthread_GetID() function
Brian Paul [Fri, 14 Mar 2014 16:13:16 +0000 (10:13 -0600)]
glapi: restore _glthread_GetID() function

This partially reverts patch 02cb04c68f.  This fixes an unresolved
symbol error when using older builds of libGL.

Tested-by: Chia-I Wu <olv@lunarg.com>
10 years agoradeonsi: flush the dma ring in si_flush_from_st
Niels Ole Salscheider [Thu, 13 Mar 2014 19:07:14 +0000 (20:07 +0100)]
radeonsi: flush the dma ring in si_flush_from_st

Signed-off-by: Niels Ole Salscheider <niels_ole@salscheider-online.de>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
10 years agoradeon: Move DMA ring creation to common code
Niels Ole Salscheider [Thu, 13 Mar 2014 19:07:13 +0000 (20:07 +0100)]
radeon: Move DMA ring creation to common code

Signed-off-by: Niels Ole Salscheider <niels_ole@salscheider-online.de>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
10 years agomesa: return v.value_int64 when the requested type is TYPE_INT64
Emil Velikov [Thu, 13 Mar 2014 06:35:52 +0000 (06:35 +0000)]
mesa: return v.value_int64 when the requested type is TYPE_INT64

Fixes "Operands don't affect result" defect reported by Coverity.

Cc: "9.2 10.0 10.1" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
10 years agonvc0: minor cleanups in stream output handling
Emil Velikov [Wed, 12 Mar 2014 17:09:38 +0000 (17:09 +0000)]
nvc0: minor cleanups in stream output handling

Constify the offsets parameter to silence gcc warning 'assignment
from incompatible pointer type' due to function prototype miss-match.

Use a boolean changed as a shorthand for target != current_target.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonouveau: honor fread return value in the nouveau_compiler
Emil Velikov [Wed, 12 Mar 2014 16:58:26 +0000 (16:58 +0000)]
nouveau: honor fread return value in the nouveau_compiler

There is little point of continuing if fread returns zero, as it
indicates that either the file is empty or cannot be read from.
Bail out if fread returns zero after closing the file.

Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agonouveau: typecast the prime_fd handle when calling nouveau_bo_set_prime
Emil Velikov [Wed, 12 Mar 2014 16:35:10 +0000 (16:35 +0000)]
nouveau: typecast the prime_fd handle when calling nouveau_bo_set_prime

Core drm defines that the handle is of type int, while all drivers
treat it as uint internally. Typecast the value to silence gcc
warning messages and be consistent amongst all drivers.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
10 years agonv50: add missing brackets when handling the samplers array
Emil Velikov [Wed, 12 Mar 2014 16:22:15 +0000 (16:22 +0000)]
nv50: add missing brackets when handling the samplers array

Commit 3805a864b1d(nv50: assert before trying to out-of-bounds access
samplers) introduced a series of asserts as a precausion of a previous
illegal memory access.

Although it failed to encapsulate loop within nv50_sampler_state_delete
effectively failing to clear the sampler state, apart from exadurating
the illegal memory access issue.

Fixes gcc warning "array subscript is above array bounds" and
"Nesting level does not match indentation" and "Out-of-bounds read"
defects reported by Coverity.

Cc: "10.1" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
10 years agoi965: Fix build warning of unused variable
Anuj Phogat [Wed, 26 Feb 2014 02:32:54 +0000 (18:32 -0800)]
i965: Fix build warning of unused variable

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Tested-by: Kenneth Graunke <kenneth@whitecape.org>
10 years agodri3: Add GLX_EXT_buffer_age support
Adel Gadllah [Mon, 24 Feb 2014 19:44:42 +0000 (20:44 +0100)]
dri3: Add GLX_EXT_buffer_age support

v2: Indent according to Mesa style, reuse sbc instead of making a new
    swap_count field, and actually get a usable back before returning the
    age of the back (fixing updated piglit tests).  Changes by anholt.

Signed-off-by: Adel Gadllah <adel.gadllah@gmail.com>
Reviewed-by: Robert Bragg <robert@sixbynine.org> (v1)
Reviewed-by: Adel Gadllah <adel.gadllah@gmail.com> (v2)
Reviewed-by: Eric Anholt <eric@anholt.net>
10 years agodri3: Prefer the last chosen back when finding a new one.
Eric Anholt [Fri, 7 Mar 2014 23:56:06 +0000 (15:56 -0800)]
dri3: Prefer the last chosen back when finding a new one.

With the buffer_age code, I need to be able to potentially call this more
than once per frame, and it would be bad if a new special event showing up
meant I chose a different back mid-frame.  Now, once we've chosen a back
for the frame, another find_back will choose it again since we know that
it won't have ->busy set until swap.

Note that this makes find_back return a buffer id instead of a backbuffer
index.  That's kind of a silly distinction anyway, since it's an identity
mapping between the two (it's the front buffer that is at an offset).

Reviewed-By: Adel Gadllah <adel.gadllah@gmail.com>
10 years agoAdd the EGL_MESA_configless_context extension
Neil Roberts [Fri, 7 Mar 2014 18:05:47 +0000 (18:05 +0000)]
Add the EGL_MESA_configless_context extension

This extension provides a way for an application to render to multiple
surfaces with different buffer formats without having to use multiple
contexts. An EGLContext can be created without an EGLConfig by passing
EGL_NO_CONFIG_MESA. In that case there are no restrictions on the surfaces
that can be used with the context apart from that they must be using the same
EGLDisplay.

_mesa_initialze_context can now take a NULL gl_config which will mark the
context as ‘configless’. It will memset the visual to zero in that case.
Previously the i965 and i915 drivers were explicitly creating a zeroed visual
whenever 0 is passed for the EGLConfig. Mesa needs to be aware that the
context is configless because it affects the initial value to use for
glDrawBuffer. The first time the context is bound it will set the initial
value for configless contexts depending on whether the framebuffer used is
double-buffered.

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
10 years agoeglCreateContext: Remove the check for whether config == 0
Neil Roberts [Fri, 7 Mar 2014 18:05:46 +0000 (18:05 +0000)]
eglCreateContext: Remove the check for whether config == 0

In eglCreateContext there is a check for whether the config parameter is zero
and in this case it will avoid reporting an error if the
EGL_KHR_surfacless_context extension is supported. However there is nothing in
that extension which says you can create a context without a config and Mesa
breaks if you try this so it is probably better to leave it reporting an
error.

The original check was added in b90a3e7d8b1bc based on the API-specific
extensions EGL_KHR_surfaceless_opengl/gles1/gles2. This was later changed to
refer to EGL_KHR_surfacless_context in b50703aea5. Perhaps the original
extensions specified a configless context but the new one does not.

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>