mesa.git
11 years agogalahad, noop: Fix visibility CFLAGS in automake
Adam Jackson [Wed, 2 Jan 2013 19:02:59 +0000 (14:02 -0500)]
galahad, noop: Fix visibility CFLAGS in automake

Note: this is a candidate for the 9.0 stable branch.

Signed-off-by: Adam Jackson <ajax@redhat.com>
11 years agoglcpp: Fix visibility CFLAGS in automake
Adam Jackson [Wed, 2 Jan 2013 19:02:00 +0000 (14:02 -0500)]
glcpp: Fix visibility CFLAGS in automake

Note: this is a candidate for the 9.0 stable branch.

Signed-off-by: Adam Jackson <ajax@redhat.com>
11 years agomesa: Implement compressed 2D array textures.
Paul Berry [Fri, 28 Dec 2012 19:26:06 +0000 (11:26 -0800)]
mesa: Implement compressed 2D array textures.

This patch adds functionality to Mesa to upload compressed
2-dimensional array textures, using the glCompressedTexImage3D and
glCompressedTexSubImage3D calls.

Fixes piglit tests "EXT_texture_array/compressed *" and "!OpenGL ES
3.0/ext_texture_array-compressed_gles3 *".  Also partially fixes GLES3
conformance test "CoverageES30.test".

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agomesa: Fix error reporting in _mesa_invalidate_pbo_{compressed_,}teximage.
Paul Berry [Mon, 31 Dec 2012 17:00:41 +0000 (09:00 -0800)]
mesa: Fix error reporting in _mesa_invalidate_pbo_{compressed_,}teximage.

The old error reporting was completely bogus, passing _mesa_error() a
format string that didn't even match the remaining arguments.  Also,
in many cases the number of dimensions in the TexImage call was not
preserved in the error message (e.g. an error in glTexImage2D was
reported simply as an error in glTexImage).

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agomesa: fix signed/unsignd mix-up in fetch_signed_l_latc1()
Brian Paul [Wed, 2 Jan 2013 16:00:36 +0000 (09:00 -0700)]
mesa: fix signed/unsignd mix-up in fetch_signed_l_latc1()

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

11 years agoglsl: add cast to silence signed/unsigned comparision warning
Brian Paul [Tue, 1 Jan 2013 15:47:04 +0000 (08:47 -0700)]
glsl: add cast to silence signed/unsigned comparision warning

11 years agoxlib: handle _mesa_initialize_visual()'s return value
Brian Paul [Wed, 26 Dec 2012 23:26:58 +0000 (16:26 -0700)]
xlib: handle _mesa_initialize_visual()'s return value

If the call fails, we should return NULL from XMesaCreateVisual().
This was found when Waffle tried to create a visual with depth/stencil
bits = -1.  That's an illegal value for glXChooseFBConfig() and we should
return NULL in that situation.

Note: This is a candidate for the stable branches.

11 years agoi965: Fail to blit rather than assert on invalid pitch requirements.
Kenneth Graunke [Wed, 26 Dec 2012 04:55:38 +0000 (20:55 -0800)]
i965: Fail to blit rather than assert on invalid pitch requirements.

Dungeon Defenders hits TexImage()'s try_pbo_upload() path where
image->Width == 2, which doesn't meet intelEmitCopyBlit's requirement
that the pitch needs to be a multiple of 4.

Since intelEmitCopyBlit can already fail for a myriad of other reasons,
and it's not clear that other callers are immune to this failure mode,
simply make it return false rather than assert.

Fixes Dungeon Defenders on i965/Ivybridge.  Now playable (aside from
having to work around the EXT_bindable_uniform issue).

NOTE: This is probably a candidate for the 9.0 branch.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agointel: Skip texture validation logic when nothing has changed.
Eric Anholt [Thu, 20 Dec 2012 22:09:32 +0000 (14:09 -0800)]
intel: Skip texture validation logic when nothing has changed.

Improves GLBenchmark 2.1 offscreen performance by 3.2% +/- 1.5% (n=52).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agointel: Turn a test in miptree_match_image into an assert.
Eric Anholt [Thu, 20 Dec 2012 21:52:30 +0000 (13:52 -0800)]
intel: Turn a test in miptree_match_image into an assert.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Stop making a copy of non-builtin uniforms in ParameterValues[].
Eric Anholt [Wed, 21 Nov 2012 22:33:52 +0000 (14:33 -0800)]
i965: Stop making a copy of non-builtin uniforms in ParameterValues[].

We don't need them now that our set of parameter pointers points at the
GL core storage for them.  This should save memory/bandwidth/overhead in
uniform updates.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Consistently use nr_pull_params instead of NumParameters.
Eric Anholt [Wed, 21 Nov 2012 22:30:55 +0000 (14:30 -0800)]
i965: Consistently use nr_pull_params instead of NumParameters.

NumParameters used to be an upper bound on the number of vec4s to be
uploaded, which was basically safe (unless your buffer was bound near
the top of address space *and* you array indexed outside the buffer, in
which case I think you might GPU hang).  As I migrate the driver away
from ParameterValues[], this is no longer true.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/vs: Reference the core GL uniform storage for non-builtin uniforms.
Eric Anholt [Wed, 21 Nov 2012 03:18:45 +0000 (19:18 -0800)]
i965/vs: Reference the core GL uniform storage for non-builtin uniforms.

Like in the FS, there's no reason to use an external copy if the
ParameterValues[] relayout of it isn't the layout we need.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/fs: Reference the core GL uniform storage for non-builtin uniforms.
Eric Anholt [Wed, 21 Nov 2012 01:43:31 +0000 (17:43 -0800)]
i965/fs: Reference the core GL uniform storage for non-builtin uniforms.

There's no reason to use an external copy if the relayout in the
external copy isn't serving us.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoglsl: Add a note about a surprising feature of gl_uniform_storage->type.
Eric Anholt [Wed, 21 Nov 2012 02:53:34 +0000 (18:53 -0800)]
glsl: Add a note about a surprising feature of gl_uniform_storage->type.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/fs: Remove the param_index/param_offset indirection.
Eric Anholt [Wed, 21 Nov 2012 00:26:22 +0000 (16:26 -0800)]
i965/fs: Remove the param_index/param_offset indirection.

Now that ParameterValues doesn't change across the visitor, we don't
need to go through this.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Add asserts to check that we don't realloc ParameterValues.
Eric Anholt [Wed, 21 Nov 2012 21:11:32 +0000 (13:11 -0800)]
i965: Add asserts to check that we don't realloc ParameterValues.

Things are even more restrictive than they used to be, so I've made
mistakes in this area.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Add texrect scale parameters before pointers to ParameterValues.
Eric Anholt [Wed, 21 Nov 2012 21:23:36 +0000 (13:23 -0800)]
i965: Add texrect scale parameters before pointers to ParameterValues.

If adding scale parameters during program compile caused a realloc of
ParameterValues, then the driver uniform storage set up by
_mesa_associate_uniform_storage() would point to potentially freed
memory.

Note that this uses TexturesUsed, which may change at runtime for GLSL
when sampler uniforms change.  This is a flaw in our handling of texrect
in general, and not one I'm fixing currently.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Fix a typo in a comment.
Eric Anholt [Wed, 21 Nov 2012 21:57:58 +0000 (13:57 -0800)]
i965: Fix a typo in a comment.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Add a note about a bug from the no-recompile-on-sampler-updates change.
Eric Anholt [Tue, 20 Nov 2012 22:28:48 +0000 (14:28 -0800)]
i965: Add a note about a bug from the no-recompile-on-sampler-updates change.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agomesa: add missing texel fetch code for sRGB DXT formats
Brian Paul [Fri, 21 Dec 2012 20:41:23 +0000 (13:41 -0700)]
mesa: add missing texel fetch code for sRGB DXT formats

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=58548

11 years agoi965: Fix border color handling for deprecated SNORM formats.
Eric Anholt [Thu, 20 Dec 2012 23:45:11 +0000 (15:45 -0800)]
i965: Fix border color handling for deprecated SNORM formats.

We don't have native hardware support for these, so they get promoted to
RGBA, in which case we don't have hardware dealing with the channel
swizzling for us.

Fixes piglit EXT_texture_snorm/texwrap formats bordercolor (-swizzled).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Start using HIZ for Z16 textures.
Eric Anholt [Wed, 19 Dec 2012 00:05:24 +0000 (16:05 -0800)]
i965: Start using HIZ for Z16 textures.

I had left this out for a long time because it regressed some
depthstencil-render-miplevels cases when it was enabled.  Now that the
bugs causing those are fixed, there's nothing stopping us.

Improves glbenchmark 2.1 offscreen performance by 7.3% +/- 2.8% (n=10).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agointel: Use the parent miptree's format for setting up HiZ miptrees.
Eric Anholt [Thu, 20 Dec 2012 19:36:38 +0000 (11:36 -0800)]
intel: Use the parent miptree's format for setting up HiZ miptrees.

This worked out before because the parent was always 4 bytes so it
didn't affect the layout, but now we want to support Z16 too.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agointel: Remove a couple of dead function prototypes.
Eric Anholt [Tue, 18 Dec 2012 22:12:50 +0000 (14:12 -0800)]
intel: Remove a couple of dead function prototypes.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agoi965: Add perf debug for depth/stencil alignment workaround.
Eric Anholt [Tue, 18 Dec 2012 21:45:14 +0000 (13:45 -0800)]
i965: Add perf debug for depth/stencil alignment workaround.

Fixing these rendering bugs has been implicated in performance
regressions (which may be unfixable), but at least knowing that it's
happening should help diagnose those regressions.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agoi965: Assert that relayout laid out something that won't need it again.
Eric Anholt [Tue, 18 Dec 2012 19:55:16 +0000 (11:55 -0800)]
i965: Assert that relayout laid out something that won't need it again.

The ETC1 changes failed at this, so let's make sure it will be caught in
testing next time.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agoi965: Also fix validation of Z32F_S8 textures.
Eric Anholt [Tue, 18 Dec 2012 21:10:29 +0000 (13:10 -0800)]
i965: Also fix validation of Z32F_S8 textures.

This was caught by the assertion in the next commit.  It fixes the
remaining piglit depthstencil-render-miplevels cases, probably by
avoiding broken stencil copies in the validation path.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agoi965: Fix validation of ETC miptrees.
Eric Anholt [Tue, 18 Dec 2012 20:03:49 +0000 (12:03 -0800)]
i965: Fix validation of ETC miptrees.

When comparing to the teximage's format, we have to look at the
format-the-mt-was-created-for not the format-actually-stored-in-the-mt.

Improves glbenchmark 2.1 offscreen test performance 159% +/- 17% (n=3).

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54582
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agoqi965: Add perf debug for texture relayout.
Eric Anholt [Tue, 18 Dec 2012 19:47:25 +0000 (11:47 -0800)]
qi965: Add perf debug for texture relayout.

Relayout is expensive, so it's something developers (both us and others)
should know about when it happens.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agoi965: Fix hiz resolves getting stomped by depth offset validation.
Eric Anholt [Tue, 18 Dec 2012 22:25:42 +0000 (14:25 -0800)]
i965: Fix hiz resolves getting stomped by depth offset validation.

Fixes all the remaining non-Z32F_S8 depthstencil-render-miplevels tests
in piglit.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agor600g: rename GPU_FLUSH -> INVAL_READ_CACHES
Marek Olšák [Sat, 22 Dec 2012 18:05:37 +0000 (19:05 +0100)]
r600g: rename GPU_FLUSH -> INVAL_READ_CACHES

because that's what it does.

11 years agor600g: remove redundant parameter alloc_bo from r600_texture_create_object
Marek Olšák [Sat, 22 Dec 2012 01:54:52 +0000 (02:54 +0100)]
r600g: remove redundant parameter alloc_bo from r600_texture_create_object

alloc_bo == !buf

11 years agoMake IsVertexArray() return false before BindVertexArray()
Matt Turner [Thu, 20 Dec 2012 04:20:34 +0000 (20:20 -0800)]
Make IsVertexArray() return false before BindVertexArray()

Rename existing _Used flag to EverBound.

The GL 4.3 and ES 3.0 specs say

   These names are marked as used, for the purposes of GenVertexArrays
   only, but they do not acquire array state until they are first bound.

This also affects Apple VAOs, which is fine since the
APPLE_vertex_array_object spec says

   A vertex array object is created by binding an unused name. This
   binding is accomplished by calling BindVertexArrayAPPLE with id set
   to the name of the new vertex array object.

Fixes arb_vertex_array_object_isvertexarray.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoMake IsTransformFeedback() return false before BindTransformFeedback()
Matt Turner [Wed, 19 Dec 2012 21:43:31 +0000 (13:43 -0800)]
Make IsTransformFeedback() return false before BindTransformFeedback()

The GL 4.3 an ES 3.0 specs say

   A transform feedback object is created by binding a name returned by
   GenTransformFeedbacks with the command
      void BindTransformFeedback( enum target, uint id );

Fixes arb_transform_feedback2-istransformfeedback and part of
es3conform's CoverageES30.test.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agonouveau: deal with tbo cap for now.
Dave Airlie [Sat, 22 Dec 2012 03:12:30 +0000 (13:12 +1000)]
nouveau: deal with tbo cap for now.

This fixes the printk running apps against master.

Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agor600g: always use a tiled resource as the destination of MSAA resolve
Marek Olšák [Fri, 21 Dec 2012 19:34:52 +0000 (20:34 +0100)]
r600g: always use a tiled resource as the destination of MSAA resolve

i.e. we have to allocate a temporary tiled resource if dst isn't tiled.

This fixes hardlocks on r6xx-r7xx, though using a linear resource is forbidden
on later asics as well.

NOTE: This is a candidate for the stable branches.

11 years agowinsys/radeon: the env var RADEON_NOOP can be used to skip CS ioctls
Marek Olšák [Fri, 21 Dec 2012 18:15:20 +0000 (19:15 +0100)]
winsys/radeon: the env var RADEON_NOOP can be used to skip CS ioctls

11 years agor600g: remove a false comment
Marek Olšák [Fri, 21 Dec 2012 18:15:02 +0000 (19:15 +0100)]
r600g: remove a false comment

11 years agor600g: don't suspend TIME_ELAPSED queries during flushing
Marek Olšák [Fri, 21 Dec 2012 15:29:19 +0000 (16:29 +0100)]
r600g: don't suspend TIME_ELAPSED queries during flushing

According to the GL spec, the result should be equivalent to comparing
two timestamps.

11 years agogallium/tests: fix build breakage after pipe_surface::usage removal
Marek Olšák [Fri, 21 Dec 2012 15:56:41 +0000 (16:56 +0100)]
gallium/tests: fix build breakage after pipe_surface::usage removal

11 years agomesa: add bounds checking for uniform array access
Frank Henigman [Fri, 14 Dec 2012 20:52:17 +0000 (15:52 -0500)]
mesa: add bounds checking for uniform array access

No piglit regressions and now passes glsl-uniform-out-of-bounds-2.

validate_uniform_parameters now checks that the array index is
valid.  This means if an index is out of bounds, glGetUniform* now
fails with GL_INVALID_OPERATION, as it should.
_mesa_uniform and _mesa_uniform_matrix also call
validate_uniform_parameters so the bounds checks there became
redundant and were removed.

The test in glGetUniformLocation is modified to check array bounds
so it now returns GL_INVALID_INDEX (-1) if you ask for the location
of a non-existent array element, as it should.

Signed-off-by: Frank Henigman <fjhenigman@google.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
11 years agoutil/u_format: Round when converting depth values from float to z16_unorm.
José Fonseca [Thu, 20 Dec 2012 12:03:45 +0000 (12:03 +0000)]
util/u_format: Round when converting depth values from float to z16_unorm.

This makes the z16_unorm -> float -> z16_unorm conversion lossless.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
11 years agor600g: add cs tracing infrastructure for lockup pin pointing
Jerome Glisse [Wed, 19 Dec 2012 17:23:50 +0000 (12:23 -0500)]
r600g: add cs tracing infrastructure for lockup pin pointing

It's a build time option you need to set R600_TRACE_CS to 1 and it
will print to stderr all cs along as cs trace point value which
gave last offset into a cs process by the GPU.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
11 years agor600g: add htile support v16
Jerome Glisse [Thu, 11 Oct 2012 14:40:30 +0000 (10:40 -0400)]
r600g: add htile support v16

htile is used for HiZ and HiS support and fast Z/S clears.
This commit just adds the htile setup and Fast Z clear.
We don't take full advantage of HiS with that patch.

v2 really use fast clear, still random issue with some tiles
   need to try more flush combination, fix depth/stencil
   texture decompression
v3 fix random issue on r6xx/r7xx
v4 rebase on top of lastest mesa, disable CB export when clearing
   htile surface to avoid wasting bandwidth
v5 resummarize htile surface when uploading z value. Fix z/stencil
   decompression, the custom blitter with custom dsa is no longer
   needed.
v6 Reorganize render control/override update mecanism, fixing more
   issues in the process.
v7 Add nop after depth surface base update to work around some htile
   flushing issue. For htile to 8x8 on r6xx/r7xx as other combination
   have issue. Do not enable hyperz when flushing/uncompressing
   depth buffer.
v8 Fix htile surface, preload and prefetch setup. Only set preload
   and prefetch on htile surface clear like fglrx. Record depth
   clear value per level. Support several level for the htile
   surface. First depth clear can't be a fast clear.
v9 Fix comments, properly account new register in emit function,
   disable fast zclear if clearing different layer of texture
   array to different value
v10 Disable hyperz for texture array making test simpler. Force
    db_misc_state update when no depth buffer is bound. Remove
    unused variable, rename depth_clearstencil to depth_clear.
    Don't allocate htile surface for flushed depth. Something
    broken the cliprect change, this need to be investigated.
v11 Rebase on top of newer mesa
v12 Rebase on top of newer mesa
v13 Rebase on top of newer mesa, htile surface need to be initialized
    to zero, somehow special casing first clear to not use fast clear
    and thus initialize the htile surface with proper value does not
    work in all case.
v14 Use resource not texture for htile buffer make the htile buffer
    size computation easier and simpler. Disable preload on evergreen
    as its still troublesome in some case
v15 Cleanup some comment and remove some left over
v16 Define name for bit 20 of CP_COHER_CNTL

Signed-off-by: Pierre-Eric Pelloux-Prayer <pelloux@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
11 years agor600g: rework flusing and synchronization pattern v7
Jerome Glisse [Thu, 1 Nov 2012 20:09:40 +0000 (16:09 -0400)]
r600g: rework flusing and synchronization pattern v7

This bring r600g allmost inline with closed source driver when
it comes to flushing and synchronization pattern.

v2-v4: history lost somewhere in outer space
v5: Fix compute size of flushing, use define for flags, update
    worst case cs size requirement for flush, treat rs780 and
    newer as r7xx when it comes to streamout.
v6: Fix num dw computation for framebuffer state, remove dead
    code, use define instead of hardcoded value.
v7: Remove dead code

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
11 years agomesa: Allow glReadBuffer(GL_NONE) for winsys framebuffers.
Paul Berry [Wed, 19 Dec 2012 18:08:58 +0000 (10:08 -0800)]
mesa: Allow glReadBuffer(GL_NONE) for winsys framebuffers.

Previously, Mesa code assumed that glReadBuffer(GL_NONE) was only
valid for user-created framebuffer objects.  However, the spec is
quite clear that is should also be valid for the default framebuffer.
From section 18.2.1 ("Obtaining Pixels from the Framebuffer") of the
GL 4.3 spec:

    "When READ_FRAMEBUFFER_BINDING is zero, i.e. the default
    framebuffer, src must be one of the values listed in table 17.4,
    including NONE."

Similar language exists in the GLES 3.0 spec, and in desktop GL all
the way back to ARB_framebuffer_object.

Partially fixes GLES3 conformance test "CoverageES30.test".

NOTE: This is a candidate for stable branches.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agollvmpipe: Drop PIPE_QUERY_TIME_ELAPSED support.
José Fonseca [Sun, 9 Dec 2012 10:15:19 +0000 (10:15 +0000)]
llvmpipe: Drop PIPE_QUERY_TIME_ELAPSED support.

It was slightly wrong: we were computing the longest duration of
the query among all the rasterizer tasks.

Regardless, for tile-based implementations such as llvmpipe, time differences
will never be very useful, because rendering before/during/after the query
is all interleaved.  And this is expected, see ARB_timer_query spec, issue 10.

In particular, piglit ext_timer_query-time-elapsed still fails, because
it makes assumptions that don't hold true in in tiled architectures. Not
sure how to fix that though.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agomesa/st: Implement GL_TIME_ELAPSED w/ PIPE_QUERY_TIMESTAMP.
José Fonseca [Sun, 9 Dec 2012 10:08:13 +0000 (10:08 +0000)]
mesa/st: Implement GL_TIME_ELAPSED w/ PIPE_QUERY_TIMESTAMP.

ARB/EXT_timer_query's definition of GL_TIME_ELAPSED match precisely the
subtraction of two GL_TIMESTAMP queries.

And for a lot of drivers, that's precisely how they have to implement
internally -- by emitting two hardware timestamp queries.

So, to simplify driver implementation, simply allow doing so in the state
tracker.

Eventually if no driver implements PIPE_QUERY_TIME_ELAPSED then we could
retire it.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agogallium: s/PIPE_CAP_TIMER_QUERY/PIPE_CAP_QUERY_TIME_ELAPSED/
José Fonseca [Sun, 9 Dec 2012 09:50:34 +0000 (09:50 +0000)]
gallium: s/PIPE_CAP_TIMER_QUERY/PIPE_CAP_QUERY_TIME_ELAPSED/

To better reflect what it is being advertised.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agor600g: add assertions to prevent creation of invalid surfaces
Marek Olšák [Wed, 19 Dec 2012 23:28:24 +0000 (00:28 +0100)]
r600g: add assertions to prevent creation of invalid surfaces

11 years agor600g: refactor and make streamout dumping more informative
Marek Olšák [Wed, 19 Dec 2012 16:05:01 +0000 (17:05 +0100)]
r600g: refactor and make streamout dumping more informative

Reviewed-by: Dave Airlie <airlied@redhat.com>
11 years agor600g: try to fix streamout for the cases where BURST_COUNT > 0
Marek Olšák [Wed, 19 Dec 2012 15:59:45 +0000 (16:59 +0100)]
r600g: try to fix streamout for the cases where BURST_COUNT > 0

The burst was incorrectly used, because ELEM_SIZE was always 0.
I don't know if the burst works, because I don't know of any test
which uses it.

NOTE: This is a candidate for the stable branches.

Reviewed-by: Dave Airlie <airlied@redhat.com>
11 years agor600g: lower stream outputs with dst_offset < start_component
Marek Olšák [Wed, 19 Dec 2012 14:09:54 +0000 (15:09 +0100)]
r600g: lower stream outputs with dst_offset < start_component

This fixes streamout breakage caused by the varying packing.

Reviewed-by: Dave Airlie <airlied@redhat.com>
11 years agor600g: use r600_get_temp to get temporaries for CLIPDIST shader outputs
Marek Olšák [Wed, 19 Dec 2012 14:00:45 +0000 (15:00 +0100)]
r600g: use r600_get_temp to get temporaries for CLIPDIST shader outputs

I need this to be able to use r600_get_temp in the function later.

Reviewed-by: Dave Airlie <airlied@redhat.com>
11 years agosoftpipe: fix up FS variant unbinding / deletion
Brian Paul [Fri, 14 Dec 2012 17:47:46 +0000 (10:47 -0700)]
softpipe: fix up FS variant unbinding / deletion

The old call to tgsi_exec_machine_bind_shader() in
softpipe_delete_fs_state() was never called since the shader's original
tokens are never passed to the tgsi interpreter (only shader _variant_
tokens are).  Now, unbind the variant's tokens from the tgsi interpreter
when we free the variant.

This doesn't fix any known bugs but it's the right thing to do.

Note: This is a candidate for the stable branches.

11 years agosoftpipe: fix unreliable FS variant binding bug
Brian Paul [Fri, 14 Dec 2012 17:34:33 +0000 (10:34 -0700)]
softpipe: fix unreliable FS variant binding bug

In exec_prepare() we were comparing pointers to see if the fragment
shader variant had changed before calling tgsi_exec_machine_bind_shader().
This didn't work reliably when there was a lot of shader token malloc/
freeing going on because the memory might get reused.
Instead, bind the shader variant during regular state validation.

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=40404
(fixes a couple of piglit's glsl-max-varyings test)

Note: This is a candidate for the stable branches.

11 years agoRevert "r600g: work around ddx over alignment"
Jerome Glisse [Wed, 19 Dec 2012 14:56:17 +0000 (09:56 -0500)]
Revert "r600g: work around ddx over alignment"

This reverts commit d8287bac1fd4a77abc2db38de134f14176740d23.

Cause more issue than it fix. Need to think of a proper solution.

11 years agor600g: work around ddx over alignment
Jerome Glisse [Tue, 18 Dec 2012 17:45:31 +0000 (12:45 -0500)]
r600g: work around ddx over alignment

This force surface allocated from ddx to be consider as height
aligned on 8 and fix 1D->2D tiling transition that result from
this.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
11 years agoi965: Fix gl_VertexID when there are no other vertex inputs.
Paul Berry [Mon, 17 Dec 2012 17:55:48 +0000 (09:55 -0800)]
i965: Fix gl_VertexID when there are no other vertex inputs.

brw_emit_vertices contains special case logic to handle the case where
a vertex shader doesn't read any inputs.  This special case logic was
incorrectly activating in the case were the only vertex input is
gl_VertexID.  As a result, if a shader used gl_VertexID but used no
other inputs, then all vertices got a gl_VertexID of zero.

Fixes oglconform test "ubo-usage advanced.transform_feedback".

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agomesa: Make a function is_transform_feedback_active_and_unpaused.
Paul Berry [Sat, 15 Dec 2012 22:21:32 +0000 (14:21 -0800)]
mesa: Make a function is_transform_feedback_active_and_unpaused.

The rather unweildy logic for determining this condition was repeated
in a large number of places.  This patch consolidates it to a single
inline function.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agomesa: Fix corner cases of BindBufferBase with transform feedback.
Paul Berry [Sat, 15 Dec 2012 21:06:10 +0000 (13:06 -0800)]
mesa: Fix corner cases of BindBufferBase with transform feedback.

This patch implements the following behaviours, which are mandated by
the GL 4.3 and GLES3 specs.

1. Regarding the GL_TRANSFORM_FEEDBACK_BUFFER_SIZE query: "If the
   ... size was not specified when the buffer object was bound
   (e.g. if it was bound with BindBufferBase), ... zero is returned."
   (GL 4.3 section 6.7.1 "Indexed Buffer Object Limits and Binding
   Queries").

2. "BindBufferBase binds the entire buffer, even when the size of the
   buffer is changed after the binding is established. It is
   equivalent to calling BindBufferRange with offset zero, while size
   is determined by the size of the bound buffer at the time the
   binding is used."  (GL 4.3 section 6.1.1 "Binding Buffer Objects to
   Indexed Targets").  I interpret "at the time the binding is used"
   to mean "at the time of the call to glBeginTransformFeedback".

3. "Regardless of the size specified with BindBufferRange, or
   indirectly with BindBufferBase, the GL will never read or write
   beyond the end of a bound buffer. In some cases this constraint may
   result in visibly different behavior when a buffer overflow would
   otherwise result, such as described for transform feedback
   operations in section 13.2.2."  (GL 4.3 section 6.1.1 "Binding
   Buffer Objects to Indexed Targets").

Item 1 has been part of the spec all the way back to the inception of
the EXT_transform_feedback extension.  Items 2 and 3 were added in GL
4.2 and GLES 3.

Prior to GL 4.2, in place of items 2 and 3, the spec simply said
"BindBufferBase is equivalent to calling BindBufferRange with offset
zero and size equal to the size of buffer."  For transform feedback,
Mesa behaved as though this meant "...equal to the size of buffer at
the time of the call to BindBufferBase".  However, this was
problematic because it left it ambiguous what to do if the buffer is
shrunk between the call to BindBuffer{Base,Range} and the call to
BeginTransformFeedback.  Prior to this patch, Mesa's behaviour was to
try to write beyond the end of the buffer, likely resulting in memory
corruption.  In light of this, I'm interpreting the spec change as a
clarification, not an intended behavioural change, so I'm making the
change apply regardless of API version.

Fixes GLES3 conformance test transform_feedback2_pause_resume.test.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agomesa/gles3: Generate error on draw call if transform feedback would overflow.
Paul Berry [Thu, 13 Dec 2012 17:30:09 +0000 (09:30 -0800)]
mesa/gles3: Generate error on draw call if transform feedback would overflow.

In desktop GL, if a draw call would cause transform feedback buffers
to overflow, the draw call should succeed, and the extra primitives
should simply not be recorded in the transform feedback buffers.

In GLES3, however, if a draw call would cause transform feedback
buffers to overflow, the draw call is supposed to produce an
INVALID_OPERATION error and no drawing should occur.

This patch implements the GLES3-required behaviour.

Fixes GLES3 conformance test "transform_feedback_overflow.test".

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agomesa/gles3: Generate error on DrawElements* calls if transform feedback active.
Paul Berry [Fri, 14 Dec 2012 20:20:08 +0000 (12:20 -0800)]
mesa/gles3: Generate error on DrawElements* calls if transform feedback active.

In GLES3, only glDrawArrays() and glDrawArraysInstanced() calls are
allowed when transform feedback is active.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agomesa: refactor _mesa_compute_max_transform_feedback_vertices from i965.
Paul Berry [Wed, 12 Dec 2012 22:14:12 +0000 (14:14 -0800)]
mesa: refactor _mesa_compute_max_transform_feedback_vertices from i965.

Previously, the i965 driver contained code to compute the maximum
number of vertices that could be written without overflowing any
transform feedback buffers.  This code wasn't driver-specific, and for
GLES3 support we're going to need to use it in core mesa.  So this
patch moves the code into a core mesa function,
_mesa_compute_max_transform_feedback_vertices().

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
v2: Eliminate C++-style variable declarations, since these won't work
with MSVC.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agomesa: Change args to vbo_count_tessellated_primitives.
Paul Berry [Wed, 12 Dec 2012 21:37:45 +0000 (13:37 -0800)]
mesa: Change args to vbo_count_tessellated_primitives.

No functional change--this simply paves the way to allow futures
patches to call vbo_count_tessellated_primitives() during error
checking, before the _mesa_prim struct has been constructed.

This will be needed for GLES3, which requires draw calls to fail if
there is not enough space available in transform feedback buffers to
accommodate the primitives to be drawn.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agoradeon/llvm: improve cube map handling
Vadim Girlin [Tue, 18 Dec 2012 13:39:19 +0000 (17:39 +0400)]
radeon/llvm: improve cube map handling

Add support for TEX2, TXB2, TXL2, fix SHADOWCUBE

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
11 years agoradeon/llvm: fix TXQ_LZ handling for cube maps
Vadim Girlin [Tue, 18 Dec 2012 13:40:36 +0000 (17:40 +0400)]
radeon/llvm: fix TXQ_LZ handling for cube maps

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
11 years agor600g: initialize inst_mod in r600_tex_from_byte_stream
Vadim Girlin [Tue, 18 Dec 2012 13:40:06 +0000 (17:40 +0400)]
r600g: initialize inst_mod in r600_tex_from_byte_stream

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
11 years agogallivm: fix conversion for pure integer formats
Roland Scheidegger [Mon, 17 Dec 2012 21:06:40 +0000 (22:06 +0100)]
gallivm: fix conversion for pure integer formats

Since the idea is to just expand or shrink the bit width but not otherwise do
conversion we also need to adjust the sign bit according to src, otherwise
the conversion code will incorrectly clamp the values. (Since this only works
for casting to ordinary floats the norm and fixed bits should always be fine.)

This fixes the remaining piglit attribs GL3 failures.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
11 years agoglsl: Fix gl_context vs. ralloc context in check_version again, again.
Kenneth Graunke [Mon, 17 Dec 2012 19:20:53 +0000 (11:20 -0800)]
glsl: Fix gl_context vs. ralloc context in check_version again, again.

Dave found some, but there were more.

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

11 years agovega: fix for object handle leak
Andreas Pokorny [Sat, 15 Dec 2012 22:28:57 +0000 (23:28 +0100)]
vega: fix for object handle leak

frees the object handle when a OpenVG
is destroyed.

Signed-off-by: Andreas Pokorny <andreas.pokorny@elektrobit.com>
Signed-off-by: Brian Paul <brianp@vmware.com>
11 years agowmesa: include version.h to silence warning
Brian Paul [Mon, 17 Dec 2012 15:39:17 +0000 (08:39 -0700)]
wmesa: include version.h to silence warning

11 years agoxlib: include headers to fix errors/warnings
Brian Paul [Mon, 17 Dec 2012 17:22:10 +0000 (10:22 -0700)]
xlib: include headers to fix errors/warnings

11 years agomesa osmesa/x11: fix build error introduced in 4bea4cb9
Jordan Justen [Mon, 17 Dec 2012 00:53:02 +0000 (16:53 -0800)]
mesa osmesa/x11: fix build error introduced in 4bea4cb9

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

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agogallivm: fix texel fetch for array textures (2)
Roland Scheidegger [Fri, 14 Dec 2012 20:17:05 +0000 (21:17 +0100)]
gallivm: fix texel fetch for array textures (2)

a460aea3f14222af46f88d1bc686f82180b8a872 wasn't entirely correct,
since all coords are already ints hence need to skip the iround.
Passes piglit texelFetch with sampler1DArray/sampler2DArray.

Reviewed-by: Dave Airlie <airlied@redhat.com>
11 years agomesa: assert if driver did not compute the version
Jordan Justen [Fri, 16 Nov 2012 21:40:59 +0000 (13:40 -0800)]
mesa: assert if driver did not compute the version

Make sure drivers initialize the version before:
 * _mesa_initialize_exec_table is called
 * _mesa_initialize_exec_table_vbo is called
 * A context is made current

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agomesa: don't initialize VBO vtxfmt in _vbo_CreateContext
Jordan Justen [Mon, 19 Nov 2012 19:21:05 +0000 (11:21 -0800)]
mesa: don't initialize VBO vtxfmt in _vbo_CreateContext

The driver should call _mesa_initialize_vbo_vtxfmt after
computing the context version.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agomesa: don't initialize exec dispatch tables in _mesa_initialize_context
Jordan Justen [Fri, 16 Nov 2012 18:42:02 +0000 (10:42 -0800)]
mesa: don't initialize exec dispatch tables in _mesa_initialize_context

Drivers must compute the context version, and then call
_mesa_initialize_exec_table themselves.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agomesa dispatch_sanity: call new functions to initialize exec table
Jordan Justen [Sat, 17 Nov 2012 02:25:35 +0000 (18:25 -0800)]
mesa dispatch_sanity: call new functions to initialize exec table

In a future patch the exec functions will no longer set up
by _mesa_initialize_context and _vbo_CreateContext.

Therefore we must call _mesa_initialize_exec_table and
_mesa_initialize_exec_table_vbo.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agodrivers: compute version and then initialize exec table
Jordan Justen [Fri, 16 Nov 2012 18:30:19 +0000 (10:30 -0800)]
drivers: compute version and then initialize exec table

This change forces the context version to be computed before
initilizing the exec dispatch tables.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agovbo: add _mesa_initialize_vbo_vtxfmt
Jordan Justen [Mon, 19 Nov 2012 19:17:39 +0000 (11:17 -0800)]
vbo: add _mesa_initialize_vbo_vtxfmt

This function initializes the exec/save dispatch tables
for VBO vtxfmt.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agomesa: separate exec allocation from initialization
Jordan Justen [Fri, 16 Nov 2012 18:27:13 +0000 (10:27 -0800)]
mesa: separate exec allocation from initialization

In glapi/gl_genexec.py:
* Remove _mesa_alloc_dispatch_table call

In glapi/gl_genexec.py and api_exec.h:
* Rename _mesa_create_exec_table to _mesa_initialize_exec_table

In context.c:
* Call _mesa_alloc_dispatch_table instead of _mesa_create_exec_table
* Call _mesa_initialize_exec_table (this is temporary)

Once all drivers have been modified to call
_mesa_initialize_exec_table, then the call to
_mesa_initialize_context can be removed from context.c.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agor600g: fixup offset types for printing
Dave Airlie [Sun, 16 Dec 2012 10:16:09 +0000 (10:16 +0000)]
r600g: fixup offset types for printing

This allows the debug code to at least show the sign properly.

Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agogallium/u_blitter: Remove the overlapped blit assert from util_blitter_blit_generic().
Henri Verbeet [Fri, 14 Dec 2012 03:14:14 +0000 (04:14 +0100)]
gallium/u_blitter: Remove the overlapped blit assert from util_blitter_blit_generic().

This is used by st_BlitFramebuffer() / r600_blit(), and ARB_fbo allows
overlapped blits, even though the result is undefined. No piglit regressions
on r600g / CYPRESS.

Signed-off-by: Henri Verbeet <hverbeet@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
11 years agoglsl_parser_extras.cpp: fixup gl vs mem contexts again.
Dave Airlie [Sun, 16 Dec 2012 01:47:01 +0000 (11:47 +1000)]
glsl_parser_extras.cpp: fixup gl vs mem contexts again.

This should fix:
https://bugs.freedesktop.org/show_bug.cgi?id=58039

Tested-by: Darxus on bug 58039
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agoi965: Move BRW_MAX_GRF and similar defines to brw_reg.h.
Kenneth Graunke [Sat, 10 Nov 2012 05:20:05 +0000 (21:20 -0800)]
i965: Move BRW_MAX_GRF and similar defines to brw_reg.h.

These don't really belong in brw_structs.h.

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965: Split struct brw_reg out from brw_eu.h into its own header.
Kenneth Graunke [Fri, 9 Nov 2012 22:00:15 +0000 (14:00 -0800)]
i965: Split struct brw_reg out from brw_eu.h into its own header.

struct brw_instruction and the related instruction emitting code won't
be useful on Gen8+, as the instruction encoding changed.  However, the
struct brw_reg code is still extremely valuable.

While we're at it, fix up some style points:
- s/GLuint/unsigned/g
- s/GLint/int/g
- s/GLshort/int16_t/g
- s/GLushort/uint16_t/g
- s/INLINE/inline/g
- Replace tabs with spaces
- Put return types on a separate line from the function name/parameters
- Remove trailing whitespace
- Remove extraneous whitespace around function parameters

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agodocs: add ARB_texture_buffer_object_rgb32
Dave Airlie [Sat, 15 Dec 2012 21:06:54 +0000 (07:06 +1000)]
docs: add ARB_texture_buffer_object_rgb32

Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agost/mesa: add texture buffer object rgb32 support.
Dave Airlie [Sat, 15 Dec 2012 03:03:54 +0000 (13:03 +1000)]
st/mesa: add texture buffer object rgb32 support.

This checks if the pipe driver can support RGB32 formats.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agomesa: add support for ARB_texture_buffer_object_rgb32
Dave Airlie [Sat, 15 Dec 2012 03:03:40 +0000 (13:03 +1000)]
mesa: add support for ARB_texture_buffer_object_rgb32

This adds the extensions + the tex buffer support for checking
the formats.

There is a piglit test enhancement sent to that list.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agoglsl: avoid using gl context as a memory context
Dave Airlie [Sat, 15 Dec 2012 03:24:52 +0000 (13:24 +1000)]
glsl: avoid using gl context as a memory context

Not sure what was going on here, but running piglit with debug builds
might be a good plan :-)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agoi965: Add missing autoconf bits so test_vec4_register_coalesce will build
Ian Romanick [Sat, 15 Dec 2012 01:22:29 +0000 (17:22 -0800)]
i965: Add missing autoconf bits so test_vec4_register_coalesce will build

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Eric Anholt <eric@anholt.net>
11 years agoi965: Generalize VS compute-to-MRF for compute-to-another-GRF, too.
Eric Anholt [Thu, 2 Aug 2012 02:35:18 +0000 (19:35 -0700)]
i965: Generalize VS compute-to-MRF for compute-to-another-GRF, too.

No statistically significant performance difference on glbenchmark 2.7
(n=60).  It reduces cycles spent in the vertex shader by 3.3% +/- 0.8%
(n=5), but that's only about .3% of all cycles spent according to the
fixed shader_time.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/vs: Extend opt_compute_to_mrf to handle limited "reswizzling"
Eric Anholt [Sat, 1 Dec 2012 06:29:26 +0000 (22:29 -0800)]
i965/vs: Extend opt_compute_to_mrf to handle limited "reswizzling"

The way our visitor works, scalar expression/swizzle results that get
stored in channels other than .x will have an intermediate MOV from
their result in the .x channel to the real .y (or whatever) channel, and
similarly for vec2/vec3 results.

By knowing how to adjust DP4-type instructions for optimizing out a
swizzled MOV, we can reduce instructions in common matrix multiplication
cases.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/vs: Add a unit test for opt_compute_to_mrf().
Eric Anholt [Sat, 1 Dec 2012 07:52:38 +0000 (23:52 -0800)]
i965/vs: Add a unit test for opt_compute_to_mrf().

The compute-to-mrf code is really twitchy, and it's hard to construct
GLSL testcases for it.  This unit test is also really hard to work with
(for example, if your instruction is removed by dead code elimination,
you end up inspecting something irrelevant), but I did use it for
debugging some of the commits to follow.

I called it test_vec4_register_coalesce because the compute-to-mrf code
is about to morph into that.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/fs: Drop an unnecessary _safe on a list walk.
Eric Anholt [Sat, 1 Dec 2012 05:15:35 +0000 (21:15 -0800)]
i965/fs: Drop an unnecessary _safe on a list walk.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/fs: Add a note explaining a detail of register_coalesce_2().
Eric Anholt [Fri, 30 Nov 2012 23:54:19 +0000 (15:54 -0800)]
i965/fs: Add a note explaining a detail of register_coalesce_2().

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Also consider HALTs a potential block end.
Eric Anholt [Wed, 12 Dec 2012 20:47:50 +0000 (12:47 -0800)]
i965: Also consider HALTs a potential block end.

The final halt of the fragment shader turns off the remaining channels,
then jumps such that everything is turned back on.  So, we can have our
last ENDIF of the shader point at that directly.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Jump to the end of the next outer conditional block on ENDIFs.
Kenneth Graunke [Wed, 12 Dec 2012 10:20:05 +0000 (02:20 -0800)]
i965: Jump to the end of the next outer conditional block on ENDIFs.

From the Ivybridge PRM, Volume 4, Part 3, section 6.24 (page 172):

"The endif instruction is also used to hop out of nested conditionals by
 jumping to the end of the next outer conditional block when all
 channels are disabled."

Also:
"Pseudocode:
 Evaluate(WrEn);
 if ( WrEn == 0 ) {  // all channels false
   Jump(IP + JIP);
 }"

First, ENDIF re-enables any channels that were disabled because they
didn't match the conditional.  If any channels are active, it proceeds
to the next instruction (IP + 16).  However, if they're all disabled,
there's no point in walking through all of the instructions that have no
effect---it can jump to the next instruction that might re-enable some
channels (an ELSE, ENDIF, or WHILE).

Previously, we always set JIP on ENDIF instructions to 2 (which is
measured in 8-byte units).  This made it do Jump(IP + 16), which just
meant it would go to the next instruction even if all channels were off.

It turns out that walking over instructions while all the channels are
disabled like this is worse than just instruction dispatch overhead: if
there are texturing messages, it still costs a couple hundred cycles to
not-actually-read from the texture results.

This patch finds the next instruction that could re-enable channels and
sets JIP accordingly.

Reviewed-by: Eric Anholt <eric@anholt.net>