platform/upstream/mesa.git
11 years agollvmpipe: improve alignment calculation for fetching/storing pixels 59/6859/1
Roland Scheidegger [Tue, 4 Jun 2013 01:20:55 +0000 (03:20 +0200)]
llvmpipe: improve alignment calculation for fetching/storing pixels

This was always doing per-pixel alignment which isn't necessary, except
for the buffer case (due to the per-element offset). The disabled code
for calculating it was incorrect because it assumed that always the full
block would be fetched, which may not be the case, so fix this up.
The original code failed for instance for r10g10b10a2 the alignment would
have been calculated as 4 (block_width) * 4 (bytes) so 16, but the actual
fetch may have only fetched 2 values at a time, hence only alignment 8 -
it is unclear what exactly would happen in this case (alignment larger
than size to fetch).
So just use the (already calculated) fetch size instead and get alignment
from that which should always work, no matter if fetching 1,2 or 4 pixels.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agollvmpipe: reduce alignment requirement for 1d resources from 4x4 to 4x1 58/6858/1
Roland Scheidegger [Tue, 4 Jun 2013 22:17:22 +0000 (00:17 +0200)]
llvmpipe: reduce alignment requirement for 1d resources from 4x4 to 4x1

For rendering to buffers, we cannot have any y alignment.
So make sure that tile clear commands only clear up to the fb width/height,
not more (do this for all resources actually as clearing more seems
pointless for other resources too). For the jit fs function, skip execution
of the lower half of the fragment shader for the 4x4 stamp completely,
for depth/stencil only load/store the values from the first row
(replace other row with undef).
For the blend function, also only load half the values from fs output,
replace the rest with undefs so that everything still operates on the
full 4x4 block to keep code the same between 4x1 and 4x4 (except for
load/store of course which also needs to skip (store) or replace these
values with undefs (load))., at the cost of slightly less optimal code
being produced in some cases.
Also reduce 1d and 1d array alignment too, because they can be handled the
same as buffers so don't need to waste memory.

v2: don't try to run special blend code for 4x1, (very) slightly less
complexity if we just use the same code as for 4x4 which may or may not
make it easier to optimize in the future (as we care a lot more about 4x4
performance than 1d).

v2: don't use undef values for unused fs src outputs with llvm 3.1 as it
apparently can trigger a bug in llvm.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agollvmpipe: cleanup of generate_unswizzled_blend 57/6857/1
Roland Scheidegger [Mon, 3 Jun 2013 14:01:05 +0000 (16:01 +0200)]
llvmpipe: cleanup of generate_unswizzled_blend

Some parameters were used inconsistently, for instance not using
block_width/block_height/block_size for deferring number of pixels
but rather relying on guesses from the number of fragment shaders etc,
so fix this up (no actual change in behavior since the block size stays
fixed). (Though most of the code would work with different block_height,
with three exceptions, one being the hacked r11g11b10 conversions and
twiddle code which only work with block_height 2 not 1, and the last
one being blend vector type not being 128bit wide.)

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agogallivm: enhance special sse2 4x4f and 2x8f -> 1x16ub conversion 56/6856/1
Roland Scheidegger [Tue, 4 Jun 2013 22:11:45 +0000 (00:11 +0200)]
gallivm: enhance special sse2 4x4f and 2x8f -> 1x16ub conversion

There's no good reason why it can't handle 2x4f->1x8ub, 1x4f->1x4ub and
1x8f->1x8ub cases, there might be legitimate reasons why we don't have
enough input vectors for a full destination vector, and using pack
intrinsics should still be much better than using generic conversion
(it looks like convert_alpha from the blend code might hit this though
I suspect it could be avoided).

v2: add another test vector format to lp_test_conv so this gets tested.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agogallivm: (trivial) fix lp_build_concat_n 55/6855/1
Roland Scheidegger [Sat, 1 Jun 2013 18:55:17 +0000 (20:55 +0200)]
gallivm: (trivial) fix lp_build_concat_n

The code was designed to handle no-op concat but failed (unless the
caller was using same pointer for src and dst).

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agomesa: change MAX_PROGRAM_ADDRESS_REGS to 1, clamp to it in state tracker 54/6854/1
Brian Paul [Tue, 4 Jun 2013 16:51:15 +0000 (09:51 -0700)]
mesa: change MAX_PROGRAM_ADDRESS_REGS to 1, clamp to it in state tracker

We've never properly supported more than one address register.  There
isn't even a field in prog_src_register or prog_dst_register to indicate
which address register to use if RelAddr!=0.

In the state tracker, clamp MaxAddressRegs against MAX_PROGRAM_ADDRESS_REGS
since many gallium drivers do support more.

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

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agointel: Don't try to blorp or blit CopyTexSubImage(1D_ARRAY). 53/6853/1
Paul Berry [Sun, 2 Jun 2013 23:25:03 +0000 (16:25 -0700)]
intel: Don't try to blorp or blit CopyTexSubImage(1D_ARRAY).

Blorp and the hardware blitter can't be used to implement
CopyTexSubImage when the image type is 1D_ARRAY, because of a
coordinate system mismatch (the Y coordinate in the source image is
supposed to be matched up to the Z coordinate in the destination
texture).

The hardware blitter path (intel_copy_texsubimage) contained a perf
debug warning for this case, but it failed to actually fall back.  The
blorp path didn't even check.

Fixes piglit test "copyteximage 1D_ARRAY".

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoi965/gen6+: Fix multisample assertions in CopyTexSubImage hw blitter path. 52/6852/1
Paul Berry [Sun, 2 Jun 2013 21:31:46 +0000 (14:31 -0700)]
i965/gen6+: Fix multisample assertions in CopyTexSubImage hw blitter path.

Commit 045612c (intel: Add an assert for glCopyTexSubImage() being
called on MSAA buffers) added an assertion to intel_copy_texsubimage()
to make sure that multisampling was not in use, based on the
assumption that glCopyTexSubImage() can't legally be used with
multisampling.

However, there is one case where glCopyTexSubImage() can legally be
used with multisampling: when the source buffer is a multisampled
window system buffer.  If the source and destination color formats
don't match, the blorp path will fail, so intel_copy_texsubimage()
will be called.  In this case, we need intel_copy_texsubimage() to
return false so that we fall back to meta to do the copy.  (The
multisampled source buffer won't cause a problem for the meta path,
because it uses glReadPixels, which forces a multisample resolve).

It's still safe to assert that the destination image is
single-sampled, because it's not legal to call glCopyTexSubImage() on
multisampled textures.

Fixes some failures with piglit tests "copyteximage
{1D,2D,CUBE,RECT,2D_ARRAY}" (with "samples=..." argument).

Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agomesa: Prevent possible out-of-bounds read by save_SamplerParameterfv. 51/6851/1
Vinson Lee [Mon, 3 Jun 2013 06:16:42 +0000 (23:16 -0700)]
mesa: Prevent possible out-of-bounds read by save_SamplerParameterfv.

Fixes "Out-of-bounds access" defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agoi965: fix problem with constant out of bounds access (v3) 50/6850/1
Dave Airlie [Thu, 30 May 2013 10:21:56 +0000 (20:21 +1000)]
i965: fix problem with constant out of bounds access (v3)

Okay I now understand why Frank would want to run away, this is
my attempt at fixing the CVE out of bounds access to constants
outside the range. This attempt converts any illegal constants
to constant 0 as per the GL spec, and is undefined behaviour.

A future patch should add some debug for users to find this out,
but this needs to be backported to stable branches.

CVE-2013-1872

v2: drop the last hunk which was a separate fix (now in master).
hopefully fix the indentations.

v3: don't fail piglit, the whole 8/16 dispatch stuff was over
my head, and I spent a while figuring it out, but this one is
definitely safe, one piglit pass extra on my Ironlake.

NOTE: This is a candidate for stable branches.

Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agointel: Fix copying of separate stencil data in glCopyTexSubImage(). 49/6849/1
Eric Anholt [Thu, 30 May 2013 21:20:04 +0000 (14:20 -0700)]
intel: Fix copying of separate stencil data in glCopyTexSubImage().

We were copying the source stencil data onto the destination depth data.

Fixes piglit copyteximage other than 1D_ARRAY.

v2: Fix unintentional dropping of the "don't double-copy for packed
    depth/stencil" check.  While blorp is only supported on separate
    stencil hardware at the moment, hopefully that will change soon.
    Review by Jordan.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
11 years agometa: Fix temporary image type for float depth/stencil. 48/6848/1
Eric Anholt [Thu, 30 May 2013 17:06:49 +0000 (10:06 -0700)]
meta: Fix temporary image type for float depth/stencil.

Fixes assertion failure in piglit copyteximage.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
11 years agointel: Fix performance regression from miptree blit changes. 47/6847/1
Eric Anholt [Thu, 30 May 2013 16:43:45 +0000 (09:43 -0700)]
intel: Fix performance regression from miptree blit changes.

When making v2 of da2880bea05bfc87109477ab026a7f5401fc8f0c, I carefully
checked all of the calls in that commit to see that I'd updated them, but
forgot to update the new calls in the later commits such as
.e845c5cf7abce55759501a473459aff3bf25c9ca.  As a result, we were getting Y
tiled temporaries even though the whole point of the temporary was to
untile!

The steady state of the intro scene of lightsmark goes from 13 to 17 fps.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65154
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
11 years agoglcpp: Add test case for recently fixed loop-control underflow bug. 46/6846/1
Carl Worth [Mon, 3 Jun 2013 19:49:10 +0000 (12:49 -0700)]
glcpp: Add test case for recently fixed loop-control underflow bug.

To trigger the bug, it suffices to have a line-continuation followed by
a newline and then a non-line-continuation backslash.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoglcpp: Fix post-decrement underflow in loop-control variable 45/6845/1
Carl Worth [Mon, 3 Jun 2013 18:35:43 +0000 (11:35 -0700)]
glcpp: Fix post-decrement underflow in loop-control variable

This loop-control condition with a post-decrement operator would lead to
an underflow of collapsed_newlines. This in turn would cause a subsequent
execution of the loop to labor inordinately trying to return the loop-control
variable to a value of 0 again.

Fix this by dis-intertwining the test and the decrement.

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

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965: Fix glColorPointer(GL_FIXED) 44/6844/1
Chad Versace [Tue, 28 May 2013 23:26:07 +0000 (16:26 -0700)]
i965: Fix glColorPointer(GL_FIXED)

When a gl_client_array is created with glColorPointer,
gl_client_array::Normalized is true. This caused the translation from the
gl_client_array's type to a BRW_SURFACEFORMAT to assertion fail.

Fixes the spinning cube's color in Android 4.2's ApiDemos.apk,
"Graphics > OpenGL ES".

Fixes assertion failure in mesa-demos/src/egl/opengles1/tri_x11 on Haswell
and Ivybridge:
  brw_draw_upload.c:287: get_surface_type: Assertion `0' failed.

No Piglit regressions on Haswell.

Note: This is a candidate for the 9.1 branch.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42182
Issue: AXIA-2954
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
11 years agosoftpipe: draw_find_shader_output returns -1 on invalid outputs 43/6843/1
Zack Rusin [Thu, 30 May 2013 21:01:19 +0000 (17:01 -0400)]
softpipe: draw_find_shader_output returns -1 on invalid outputs

It was changed from 0 to allow shader outputs at 0 that are
different from position.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agoradeonsi/compute: Upload work group, work item size in input buffer 42/6842/1
Tom Stellard [Tue, 14 May 2013 02:13:53 +0000 (22:13 -0400)]
radeonsi/compute: Upload work group, work item size in input buffer

11 years agoradeonsi/compute: Pass kernel arguments in a buffer v2 41/6841/1
Tom Stellard [Tue, 7 May 2013 02:11:39 +0000 (22:11 -0400)]
radeonsi/compute: Pass kernel arguments in a buffer v2

v2:
  - Fix memory leak in si_set_constant_buffer()

11 years agoradeonsi/compute: Implement un-binding of global buffers 40/6840/1
Tom Stellard [Fri, 17 May 2013 21:02:25 +0000 (17:02 -0400)]
radeonsi/compute: Implement un-binding of global buffers

11 years agoradeonsi/compute: Support multiple kernels in a compute program 39/6839/1
Tom Stellard [Tue, 21 May 2013 21:02:33 +0000 (17:02 -0400)]
radeonsi/compute: Support multiple kernels in a compute program

11 years agoradeonsi/compute: Add missing PIPE_COMPUTE caps 38/6838/1
Tom Stellard [Tue, 14 May 2013 02:14:50 +0000 (22:14 -0400)]
radeonsi/compute: Add missing PIPE_COMPUTE caps

11 years agoi965 gen7: use SURFACE_STATE fields to select render level/layer 37/6837/1
Jordan Justen [Fri, 19 Apr 2013 08:13:31 +0000 (01:13 -0700)]
i965 gen7: use SURFACE_STATE fields to select render level/layer

Rather than pointing the surface_state directly at a single
sub-image of the texture for rendering, we now point the
surface_state at the top level of the texture, and configure
the surface_state as needed based on this.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agomesa/texformat: add _mesa_tex_target_is_array function 36/6836/1
Jordan Justen [Wed, 17 Apr 2013 23:30:59 +0000 (16:30 -0700)]
mesa/texformat: add _mesa_tex_target_is_array function

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agointel: add layered parameter to update_renderbuffer_surface 35/6835/1
Jordan Justen [Fri, 19 Apr 2013 08:00:20 +0000 (01:00 -0700)]
intel: add layered parameter to update_renderbuffer_surface

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agointel_fbo: set gl_renderbuffer Depth field 34/6834/1
Jordan Justen [Thu, 18 Apr 2013 21:18:09 +0000 (14:18 -0700)]
intel_fbo: set gl_renderbuffer Depth field

Set the renderbuffer's Depth field to match the texture's
Depth when rendering to a texture.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agointel: print image depth in debug message 33/6833/1
Jordan Justen [Thu, 18 Apr 2013 20:40:56 +0000 (13:40 -0700)]
intel: print image depth in debug message

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agomesa: handle missing read buffer in _mesa_get_color_read_format/type() 32/6832/1
Brian Paul [Mon, 3 Jun 2013 00:07:55 +0000 (18:07 -0600)]
mesa: handle missing read buffer in _mesa_get_color_read_format/type()

We were crashing when GL_READ_BUFFER == GL_NONE.  Check for NULL
pointers and reorganize the code.  The spec doesn't say which error
to generate in this situation, but NVIDIA raises GL_INVALID_OPERATION.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65173
NOTE: This is a candidate for the stable branches.

Tested-by: Vedran Rodic <vrodic@gmail.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
11 years agometa: move vertex array enables for mipmap generation 31/6831/1
Brian Paul [Mon, 3 Jun 2013 00:06:17 +0000 (18:06 -0600)]
meta: move vertex array enables for mipmap generation

Before, on the second call to GenerateMipmap we were enabling two
vertex arrays for the current vertex array object, rather than
the private generate-mipmap vertex array object.  This caused
things to blow up elsewhere.

This patch moves the array enables into the block where the
generate-mipmap vertex array object is created, as we do in
the setup_ff_generate_mipmap() function.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=60518
NOTE: This is a candidate for the stable branches.

Tested-by: core13@gmx.net
Reviewed-by: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agomesa: fix hodge podge indentation, update comments in texformat.c 30/6830/1
Brian Paul [Mon, 3 Jun 2013 00:06:17 +0000 (18:06 -0600)]
mesa: fix hodge podge indentation, update comments in texformat.c

11 years agogallium: add support for layered rendering 29/6829/1
Roland Scheidegger [Sat, 1 Jun 2013 18:02:17 +0000 (20:02 +0200)]
gallium: add support for layered rendering

Since pipe_surface already has all the necessary fields no interface
changes are necessary except adding a new shader semantic value
(TGSI_SEMANTIC_LAYER).
(Note that what GL knows as "gl_Layer" variable d3d10 is naming
"RENDER_TARGET_ARRAY_INDEX".)

v2: drop cap bit (just tied to geometry shader), add docs.

11 years agogallivm: fix out-of-bounds access with mirror_clamp_to_edge address mode 28/6828/1
Roland Scheidegger [Sat, 1 Jun 2013 00:17:09 +0000 (02:17 +0200)]
gallivm: fix out-of-bounds access with mirror_clamp_to_edge address mode

Surprising this bug survived so long, we were missing a clamp (in the
linear filtering version).
(Valgrind complained a lot about invalid reads with piglit texwrap,
I've also seen spurios failures in this test which might have
happened due to this. Valgrind probably didn't complain before the
alignment reduction in llvmpipe to 4x4 since the test is using tiny
textures so the reads were still always well within allocated area.)
While here, also do an effective clamp (after half subtraction)
of [0,length-0.5] instead of [0, length-1] which saves an instruction
(the filtering weight could be different due to this, but only if
both texels point to the same max texel so it doesn't matter).
(Both changes are borrowed from PIPE_TEX_CLAMP_TO_EDGE case.)

Note: This is a candidate for the stable branches.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agollvmpipe: fix bogus assertions for buffer surfaces 27/6827/1
Roland Scheidegger [Sat, 1 Jun 2013 14:48:03 +0000 (16:48 +0200)]
llvmpipe: fix bogus assertions for buffer surfaces

One of the assertion made no sense for buffer rendertargets
(due to the union), so drop it. (The same assertion is present already in
the path for texture surfaces later.).

v2: make assertion completely accurate (suggested by Jose).

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agoi965: Fix haswell_upload_cut_index when there's no index buffer. 26/6826/1
Kenneth Graunke [Thu, 30 May 2013 01:51:29 +0000 (18:51 -0700)]
i965: Fix haswell_upload_cut_index when there's no index buffer.

brw->ib.type is reset to -1 at the start of each batch.  If there's no
index buffer, it won't get updated to a sensible value, resulting in
_mesa_primitive_restart_index's "Invalid index buffer type" assertion
tripping.

Fixes a regression since 7c87a3b5dac118697a9b67caa7b6d5cab60f316d.

NOTE: This is a candidate for the 9.1 branch (and should be squashed).
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65195
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agollvmpipe: reduce alignment requirement for resources from 64x64 to 4x4 25/6825/1
Roland Scheidegger [Thu, 30 May 2013 00:05:01 +0000 (02:05 +0200)]
llvmpipe: reduce alignment requirement for resources from 64x64 to 4x4

The overallocation was very bad especially for things like 1d array
textures which got blown up by a factor of 64. (Even ordinary smallish
2d textures benefit a lot from this, a mipmapped 64x64 rgba8 texture
previously used 7*16kB = 112kB instead of now ~22kB.)
4x4 is chosen because this is the size the jit functions run on, so
making it smaller is going to be a bit more complicated.
It is actually not strictly 4x4 pixel, since we'd want to avoid situations
where different threads are rendering to the same cacheline so we keep
cacheline size alignment in x direction (often 64bytes).
To make this work introduce new task width/height parameters and make
sure clears don't clear the whole tile if it's a partial tile. Likewise,
the rasterizer may produce fragments outside the 4x4 blocks present in a
tile, so don't call the jit function for them.
This does not yet fix rendering to buffers (which cannot have any y
alignment at all), and 1d/1d array textures are still overallocated by a
factor of 4.

v2: replace magic number 4 with LP_RASTER_BLOCK_SIZE, fix size of buffers
allocated (needed in case we render to them).

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agollvmpipe: Remove x/y from cmd_bin 24/6824/1
Adam Jackson [Tue, 28 May 2013 23:36:43 +0000 (01:36 +0200)]
llvmpipe: Remove x/y from cmd_bin

These were mostly just a waste of memory and cache pressure, and were
really only used for debugging.

This change reduces instruction count (as measured by callgrind's Ir
event) of gnome-shell-perf-tool on Ivybridge by 3.5% ± 0.015% (n=20).

Signed-off-by: Adam Jackson <ajax@redhat.com>
11 years agor600g/sb: fix broken assert 23/6823/1
Vadim Girlin [Fri, 31 May 2013 13:35:30 +0000 (17:35 +0400)]
r600g/sb: fix broken assert

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
11 years agoglapi: Add some missing static_dispatch="false" annotations to es_EXT.xml 22/6822/1
Andreas Boll [Thu, 30 May 2013 11:32:43 +0000 (13:32 +0200)]
glapi: Add some missing static_dispatch="false" annotations to es_EXT.xml

This fixes the following build errors on powerpc:

  CC     glapi_dispatch.lo
  In file included from glapi_dispatch.c:90:0:
  ../../../../../src/mapi/glapi/glapitemp.h:1640:1: error: no previous
  prototype for 'glReadBufferNV' [-Werror=missing-prototypes]
  ../../../../../src/mapi/glapi/glapitemp.h:4198:1: error: no previous
  prototype for 'glDrawBuffersNV' [-Werror=missing-prototypes]
  ../../../../../src/mapi/glapi/glapitemp.h:6377:1: error: no previous
  prototype for 'glFlushMappedBufferRangeEXT'
  [-Werror=missing-prototypes]
  ../../../../../src/mapi/glapi/glapitemp.h:6389:1: error: no previous
  prototype for 'glMapBufferRangeEXT' [-Werror=missing-prototypes]
  ../../../../../src/mapi/glapi/glapitemp.h:6401:1: error: no previous
  prototype for 'glBindVertexArrayOES' [-Werror=missing-prototypes]
  ../../../../../src/mapi/glapi/glapitemp.h:6413:1: error: no previous
  prototype for 'glDeleteVertexArraysOES' [-Werror=missing-prototypes]
  ../../../../../src/mapi/glapi/glapitemp.h:6433:1: error: no previous
  prototype for 'glGenVertexArraysOES' [-Werror=missing-prototypes]
  ../../../../../src/mapi/glapi/glapitemp.h:6445:1: error: no previous
  prototype for 'glIsVertexArrayOES' [-Werror=missing-prototypes]

NOTE: This is a candidate for the 9.0 and 9.1 branches.

Reviewed-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agomesa: Add missing break statement in _mesa_choose_tex_format. 21/6821/1
Vinson Lee [Tue, 28 May 2013 00:54:35 +0000 (17:54 -0700)]
mesa: Add missing break statement in _mesa_choose_tex_format.

Fixes "Missing break in switch" defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agointeger overflow in XF86DRIGetClientDriverName() [CVE-2013-1993 2/2] 20/6820/1
Alan Coopersmith [Fri, 26 Apr 2013 23:33:03 +0000 (16:33 -0700)]
integer overflow in XF86DRIGetClientDriverName() [CVE-2013-1993 2/2]

clientDriverNameLength is a CARD32 and needs to be bounds checked before
adding one to it to come up with the total size to allocate, to avoid
integer overflow leading to underallocation and writing data from the
network past the end of the allocated buffer.

NOTE: This is a candidate for stable release branches.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agointeger overflow in XF86DRIOpenConnection() [CVE-2013-1993 1/2] 19/6819/1
Alan Coopersmith [Fri, 26 Apr 2013 23:31:58 +0000 (16:31 -0700)]
integer overflow in XF86DRIOpenConnection() [CVE-2013-1993 1/2]

busIdStringLength is a CARD32 and needs to be bounds checked before adding
one to it to come up with the total size to allocate, to avoid integer
overflow leading to underallocation and writing data from the network past
the end of the allocated buffer.

NOTE: This is a candidate for stable release branches.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agomesa: fix error checking of DXT sRGB formats in _mesa_base_tex_format() 18/6818/1
Brian Paul [Thu, 30 May 2013 15:18:27 +0000 (09:18 -0600)]
mesa: fix error checking of DXT sRGB formats in _mesa_base_tex_format()

For formats such as GL_COMPRESSED_SRGB_S3TC_DXT1_EXT we need to
have both the GL_EXT_texture_sRGB and GL_EXT_texture_compression_s3tc
extensions.  This patch adds the missing check for the later.

Found when checking out https://bugs.freedesktop.org/show_bug.cgi?id=65173

NOTE: This is a candidate for the stable branches.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agomesa: asst. whitespace, formatting fixes in teximage.c 17/6817/1
Brian Paul [Thu, 30 May 2013 15:16:49 +0000 (09:16 -0600)]
mesa: asst. whitespace, formatting fixes in teximage.c

11 years agodraw: fix vs/fs input/output mismatches 16/6816/1
Zack Rusin [Thu, 30 May 2013 17:48:36 +0000 (13:48 -0400)]
draw: fix vs/fs input/output mismatches

When we've changed draw_find_shader_output to return -1 instead
of 0 on non found attribs we broke the default behavior of
draw, which was to always redirect those to the first (0th) slot.
To preserve that behavior if draw_emit_vertex_attr notices a
mismatched vertex attrib, it just redirects it to the first slot
(instead of trying to use negative index in an array).

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
11 years agointel: Add multisample scaled blitting in blorp engine 15/6815/1
Anuj Phogat [Wed, 15 May 2013 00:20:02 +0000 (17:20 -0700)]
intel: Add multisample scaled blitting in blorp engine

In traditional multisampled framebuffer rendering, color samples must be
explicitly resolved via BlitFramebuffer before doing the scaled blitting
of the framebuffer. So, scaled blitting of a multisample framebuffer
takes two separate calls to BlitFramebuffer.

This patch implements the functionality of doing multisampled scaled
resolve using just one BlitFramebuffer call. Important changes involved
in this patch are listed below:
    - Use float registers to scale and offset texture coordinates.
    - Change offset computation to consider float coordinates.
    - Round the scaled coordinates down to nearest integer.
    - Modify src texture coordinates clipping to account for scaling..
    - Linear filter is not yet implemented in blorp. So, don't use
      blorp engine to do single sampled scaled blitting.

V3: Fix nearest filtering issue in scaled blits. Makes failing piglit
fbo-blit-stetch test and framebuffer_blit_functionality_magnifying_blit.test
in gles3 CTS pass.

Observed no piglit, gles3 CTS regressions on sandybridge & ivybridge with
this patch.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Change the register type from UW to UD in blorp engine 14/6814/1
Anuj Phogat [Wed, 8 May 2013 00:06:23 +0000 (17:06 -0700)]
intel: Change the register type from UW to UD in blorp engine

These changes are required to implement scaled blitting in blorp
in my next patch.

No regressions observed in piglit quick-driver.tests with this patch.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
11 years agomesa: Implement ext_framebuffer_multisample_blit_scaled extension 13/6813/1
Anuj Phogat [Thu, 18 Apr 2013 23:31:35 +0000 (16:31 -0700)]
mesa: Implement ext_framebuffer_multisample_blit_scaled extension

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agoRevert "i965: fix problem with constant out of bounds access (v2)" 12/6812/1
Kenneth Graunke [Thu, 30 May 2013 06:27:45 +0000 (23:27 -0700)]
Revert "i965: fix problem with constant out of bounds access (v2)"

This reverts commit 98dfd59a0445666060c97b0dccaf0e9f030b547a.

The patch was clearly not Piglit tested, as it caused at least 225
tests to start crashing with assertion failures.  That was before my
desktop tanked and the test run died completely.

11 years agoilo: simplify shader variant handling 11/6811/1
Courtney Goeltzenleuchter [Tue, 28 May 2013 15:54:43 +0000 (09:54 -0600)]
ilo: simplify shader variant handling

Remove hash function on shader variants. Nature of variants limits them to a
small number and thus its more efficient to just do a memory compare of the
actual shader structures rather than compute and compare hashes.

11 years agoi965: fix problem with constant out of bounds access (v2) 10/6810/1
Dave Airlie [Wed, 29 May 2013 23:51:41 +0000 (09:51 +1000)]
i965: fix problem with constant out of bounds access (v2)

This is my attempt at fixing this as the CVE is making RH security team
care enough to make me look at this. (please upstream, security fixes are
more important than whatever else you are doing, if for no other reason than
it saves me having to fix stuff I've no real clue about).

Since Frank's original fix was denied, here is my attempt to just
alias all constants that are out of bounds < 0 or > nr_params to constant 0,
hopefully this provides the undefined behaviour idr requires..

CVE-2013-1872

v2: drop the last hunk which was a separate fix (now in master).
hopefully fix the indentations.

NOTE: This is a candidate for stable branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agointel: initialize fs_visitor::params_remap in constructor 09/6809/1
Frank Henigman [Tue, 29 Jan 2013 01:06:59 +0000 (20:06 -0500)]
intel: initialize fs_visitor::params_remap in constructor

Set fs_visitor::params_remap to NULL in the constructor.
This variable was potentially tested in fs_visitor::remove_dead_constants()
before being set.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Frank Henigman <fjhenigman@google.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
11 years agodraw: add cast in debug_printf() to silence warning 08/6808/1
Brian Paul [Thu, 30 May 2013 00:07:35 +0000 (18:07 -0600)]
draw: add cast in debug_printf() to silence warning

11 years agosvga: add PIPE_CAP_MAX_VIEWPORTS to switch to silence warning 07/6807/1
Brian Paul [Thu, 30 May 2013 00:07:11 +0000 (18:07 -0600)]
svga: add PIPE_CAP_MAX_VIEWPORTS to switch to silence warning

11 years agodraw: make sure viewport index is fetched from leading vertex 06/6806/1
Zack Rusin [Sat, 25 May 2013 05:46:16 +0000 (01:46 -0400)]
draw: make sure viewport index is fetched from leading vertex

Viewport index should only be used on a per primitive basis, so
instead of fetching it from each vertex, potentially making each
vertex in a primitive use a different viewport index, which is
obviously broken, make sure that we only fetch from the first
vertex in the primitive making the viewport index the same
for the entire primtive.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca<jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agollvmpipe: clamp scissors to be between 0 and max 05/6805/1
Zack Rusin [Sat, 25 May 2013 05:04:17 +0000 (01:04 -0400)]
llvmpipe: clamp scissors to be between 0 and max

We need to clamp to make sure invalid shader doesn't crash our
driver. The spec says to return 0-th index for everything that's
out of bounds.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca<jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agodraw: clamp the viewports to always be between 0 and max 04/6804/1
Zack Rusin [Sat, 25 May 2013 05:02:46 +0000 (01:02 -0400)]
draw: clamp the viewports to always be between 0 and max

If the viewport index is larger than the PIPE_MAX_VIEWPORTS,
then the first (0-th) viewport should be used.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca<jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
11 years agogallium/docs: adds documentation for multi viewport cap 03/6803/1
Zack Rusin [Sat, 25 May 2013 13:14:57 +0000 (09:14 -0400)]
gallium/docs: adds documentation for multi viewport cap

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
11 years agodraw: fixup draw_find_shader_output 02/6802/1
Zack Rusin [Fri, 24 May 2013 20:39:59 +0000 (16:39 -0400)]
draw: fixup draw_find_shader_output

draw_find_shader_output like most of the code in draw used to
depend on position always being at output slot 0. which meant
that any other attribute being at 0 could signify an error.
unfortunately position can be at any of the output slots, thus
other attributes can occupy slot 0 and we need to mark the ones
which were not found by something else. This commit changes
draw_find_shader_output so that it returns -1 if it can't
find the given attribute and adjust the code that depended
on it returning >0 whenever it correctly found an attrib.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca<jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
11 years agollvmpipe: implement support for multiple viewports 01/6801/1
Zack Rusin [Fri, 24 May 2013 20:28:19 +0000 (16:28 -0400)]
llvmpipe: implement support for multiple viewports

Largely related to making sure the rasterizer can correctly
pick out the correct scissor box for the current viewport.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca<jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
11 years agodraw: implement support for multiple viewports 00/6800/1
Zack Rusin [Fri, 24 May 2013 20:17:26 +0000 (16:17 -0400)]
draw: implement support for multiple viewports

This adds support for multiple viewports to the draw module.
Multiple viewports depend on the presence of geometry shaders
which can write the viewport index.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca<jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
11 years agogallium: Add support for multiple viewports 99/6799/1
Zack Rusin [Fri, 24 May 2013 20:08:39 +0000 (16:08 -0400)]
gallium: Add support for multiple viewports

Gallium supported only a single viewport/scissor combination. This
commit changes the interface to allow us to add support for multiple
viewports/scissors.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Reviewed-by: José Fonseca<jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
11 years agomesa: Delete the ctx->Array._RestartIndex derived state. 98/6798/1
Kenneth Graunke [Wed, 29 May 2013 15:31:54 +0000 (08:31 -0700)]
mesa: Delete the ctx->Array._RestartIndex derived state.

It's incorrect and isn't used any longer.

v2: Actually flush vertices/flag _NEW_TRANSFORM on RestartIndex change.

NOTE: This is a candidate for the 9.1 branch.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agomesa: Ignore fixed-index primitive restart in ArrayElement(). 97/6797/1
Kenneth Graunke [Wed, 29 May 2013 15:29:26 +0000 (08:29 -0700)]
mesa: Ignore fixed-index primitive restart in ArrayElement().

GL_PRIMITIVE_RESTART_FIXED_INDEX is only supposed to apply to
glDrawElements*.  This code is for legacy drawing paths and display
lists, so it shouldn't apply.

NOTE: This is a candidate for the 9.1 branch.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agost/mesa: Go back to using ctx->Array.RestartIndex, not _RestartIndex. 96/6796/1
Kenneth Graunke [Wed, 29 May 2013 14:57:34 +0000 (07:57 -0700)]
st/mesa: Go back to using ctx->Array.RestartIndex, not _RestartIndex.

The derived _RestartIndex field is an attempt to support both
GL_PRIMITIVE_RESTART and GL_PRIMITIVE_RESTART_FIXED_INDEX (part of ES
3.0).  Gallium drivers don't appear to support ES 3.0 yet, so they don't
need to use it.  Plus, it's broken and going to go away soon.

NOTE: This is a candidate for the 9.1 branch.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agoi965: Fix can_cut_index_handle_restart_index() for byte/short types. 95/6795/1
Kenneth Graunke [Sat, 25 May 2013 17:17:32 +0000 (10:17 -0700)]
i965: Fix can_cut_index_handle_restart_index() for byte/short types.

Pre-Haswell hardware doesn't support an arbitrary restart index, and
instead compares the index buffer value against 0xFF for byte-size
buffers, 0xFFFF for short-size buffers, or 0xFFFFFFFF for unsigned
integer buffers.

OpenGL allows the restart index to be an arbitrary unsigned integer.
When comparing against byte/short types, the index buffer value should
be promoted to a full 32-bit integer before doing the comparison.  The
restart index is /not/ supposed to be masked to byte/short size.

This means that with certain restart indexes, the comparison should
always fail.  For example, a restart index of 0xF000FFFF should never
match any byte/short index buffer values due to the extra high bits.

We must not enable hardware primitive restart in such a case.  For now,
fall back to software primitive restart as it's the simplest fix.  In
the future, we could detect restart indexes that will never match and
skip both hardware and software primitive restart.

NOTE: This is a candidate for stable branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agoi965: Use the correct restart index for fixed index mode on Haswell. 94/6794/1
Kenneth Graunke [Fri, 24 May 2013 16:28:56 +0000 (09:28 -0700)]
i965: Use the correct restart index for fixed index mode on Haswell.

The code that updates the ctx->Array._RestartIndex derived state mashed
it to 0xFFFFFFFF when GL_PRIMITIVE_RESTART_FIXED_INDEX was enabled
regardless of the index buffer type.  It's supposed to be 0xFF for byte,
0xFFFF for short, or 0xFFFFFFFF for integer types.

The new _mesa_primitive_restart_index() helper gets this right.

The hardware appears to compare against the full 32-bit value some of
the time, causing primitive restart not to occur when it should.  The
fact that it works some of the time is rather frightening.

Fixes sporadic failures in the ES 3 instanced_arrays_primitive_restart
conformance test when run in combination with other tests.

NOTE: This is a candidate for the 9.1 branch.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agovbo: Use the new primitive restart index helper function. 93/6793/1
Kenneth Graunke [Wed, 29 May 2013 15:21:14 +0000 (08:21 -0700)]
vbo: Use the new primitive restart index helper function.

This gets the correct restart index for unsigned byte/short types when
using GL_PRIMITIVE_RESTART_FIXED_INDEX.

NOTE: This is a candidate for the 9.1 branch.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agomesa: Add a helper function for determining the restart index. 92/6792/1
Kenneth Graunke [Wed, 29 May 2013 15:07:01 +0000 (08:07 -0700)]
mesa: Add a helper function for determining the restart index.

The derived state approach currently used (_RestartIndex) doesn't work:
in the GL_PRIMITIVE_RESTART_FIXED_INDEX case, the restart index depends
on the index buffer's data type, and that isn't known until draw time.

The existing code also fails to obey the GL 4.3 rules which say that
FIXED_INDEX takes precedence over normal primitive restart.

This helper function correctly determines the restart index, and will
replace the derived state.

NOTE: This is a candidate for the 9.1 branch.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agovbo: Ignore PRIMITIVE_RESTART_FIXED_INDEX for glDrawArrays(). 91/6791/1
Kenneth Graunke [Sat, 25 May 2013 15:19:40 +0000 (08:19 -0700)]
vbo: Ignore PRIMITIVE_RESTART_FIXED_INDEX for glDrawArrays().

The derived _PrimitiveRestart enable flag combines the PrimitiveRestart
and PrimitiveRestartFixedIndex enable flags.  However, DrawArrays is not
supposed to do FixedIndex restart:

From the OpenGL 4.3 Core specification, section 10.3.5 (page 302):
"If PRIMITIVE_RESTART_FIXED_INDEX is enabled, primitive restart is not
 performed for array elements transferred by any drawing command not
 taking a type parameter, including all of the *Draw* commands other
 than *DrawElements*."

The OpenGL ES 3.0 specification agrees by omission:
"When DrawElements, DrawElementsInstanced, or DrawRangeElements
 transfers a set of generic attribute array elements to the GL..."

Notably, DrawArrays is not included in the list of draw calls that
take PRIMITIVE_RESTART_FIXED_INDEX into consideration.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
11 years agoi965/vs: Fix implied_mrf_writes() for integer division pre-gen6. 90/6790/1
Eric Anholt [Tue, 28 May 2013 21:35:19 +0000 (14:35 -0700)]
i965/vs: Fix implied_mrf_writes() for integer division pre-gen6.

Previously it would assertion fail in debug builds (though the correct
value was returned in a non-debug build).  Marking it as a candidate for
stable even though it has no current consumers in the stable branches, in
case one shows up in a later backport.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64727
NOTE: This is a candidate for stable branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/fs: Fix test for smearing enabled on an instruction. 89/6789/1
Eric Anholt [Fri, 3 May 2013 00:44:28 +0000 (17:44 -0700)]
i965/fs: Fix test for smearing enabled on an instruction.

We were expanding the live range too far, breaking register_coalesce_2()
and compute_to_mrf() on 16-wide shaders.  Turning it back on improves
GLB2.7 performance by 0.239355% +/- 0.0850649% (n=398). shader-db stats
are:

total instructions in shared programs: 1627211 -> 1609262 (-1.10%)
instructions in affected programs:     450351 -> 432402 (-3.99%)

While 33 new 16-wide shaders are gained, 70 are lost.  Despite that,
tropics (the app that lost the most 16-wide) shows a .41% +/- .16%
(n=7/8, first-run outlier removed) performance improvement on my HSW.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agoi965/fs: Fix segfault in instruction scheduling with LINTERP using last GRF. 88/6788/1
Eric Anholt [Thu, 9 May 2013 16:00:11 +0000 (09:00 -0700)]
i965/fs: Fix segfault in instruction scheduling with LINTERP using last GRF.

The scheduler didn't know about uniform-type accesses, and if a uniform
access was last in a 16-wide, we'd walk off the end of the array.  This
never happened, because we'd never coalesce out all the GRFs, due to a bug
to be fixed in the next commit.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agomesa: Fix test for optimistic coloring being necessary. 87/6787/1
Eric Anholt [Mon, 6 May 2013 20:47:27 +0000 (13:47 -0700)]
mesa: Fix test for optimistic coloring being necessary.

i965 and radeon use ra_set_node_reg() to force payload registers to
specific registers while exposing those registers to the allocator still.
We were treating those register nodes as unsuccessfully allocated in the
ra_simplify() step, leading to walking the registers again to do
optimistic coloring even if there was nothing left ot do.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
11 years agogallium: fix build on uclibc system 86/6786/1
Anthony G. Basile [Tue, 28 May 2013 22:58:10 +0000 (22:58 +0000)]
gallium: fix build on uclibc system

execinfo.h and debug_symbol_name_glibc() are pure GNU-isms and do not
build on uclibc systems.  A previous patch addressed this issue, but
there was an error.  This patch corrects that error.  See

  https://bugs.freedesktop.org/show_bug.cgi?id=51782
  https://bugs.gentoo.org/show_bug.cgi?id=469768

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Signed-off-by: Brian Paul <brianp@vmware.com>
11 years agointel: Enable blit glCopyTexSubImage/glBlitFramebuffer with sRGB. 85/6785/1
Eric Anholt [Tue, 28 May 2013 17:59:53 +0000 (10:59 -0700)]
intel: Enable blit glCopyTexSubImage/glBlitFramebuffer with sRGB.

Since the introduction of default-to-SARGB8 window system framebuffers,
non-blorp hardware lost blit acceleration for these two paths between the
window system and ARGB8888 textures.  Since we shouldn't be doing any
conversion anyway, just compatibility-check the linear variants of the
formats.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61954
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
11 years agoradeonsi: Add ipo to LLVM_COMPONENTS 84/6784/1
Andreas Hartmetz [Tue, 28 May 2013 21:59:41 +0000 (23:59 +0200)]
radeonsi: Add ipo to LLVM_COMPONENTS

r600g needs it too, so add ipo in the common radeon_llvm_check().

radeonsi compiled and linked, but it failed at dynamic link time
with a missing symbol.

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
11 years agollvmpipe: get rid of tiled/linear layout remains 83/6783/1
Roland Scheidegger [Tue, 28 May 2013 00:34:27 +0000 (02:34 +0200)]
llvmpipe: get rid of tiled/linear layout remains

Eliminate the rest of the no longer needed layout logic.
(It is possible some code could be simplified a bit further still.)

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
11 years agointel: Remove dead intel_drawbuf_region(). 82/6782/1
Eric Anholt [Fri, 24 May 2013 19:50:11 +0000 (12:50 -0700)]
intel: Remove dead intel_drawbuf_region().

Since the glBitmap() MRT change, it's unused.  There was basically no way
to responsibly use this function since MRT was introduced.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Fix format handling of blit glBitmap() 81/6781/1
Eric Anholt [Fri, 24 May 2013 19:48:47 +0000 (12:48 -0700)]
intel: Fix format handling of blit glBitmap()

Any 32-bit format got ARGB8888 handling (including, say, GL_RG1616), and
anything else got 16-bit (including, say, GL_R8), which could potentially
hang the GPU by writing out of bounds.

NOTE: This is a candidate for the stable branches.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Fix MRT handling of glBitmap(). 80/6780/1
Eric Anholt [Fri, 24 May 2013 19:40:14 +0000 (12:40 -0700)]
intel: Fix MRT handling of glBitmap().

We'd only hit color buffer 0 even if multiple draw buffers were bound.

NOTE: This is a candidate for the stable branches.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Rebuild PBO blit glTexImage() on top of miptrees. 79/6779/1
Eric Anholt [Fri, 24 May 2013 18:42:10 +0000 (11:42 -0700)]
intel: Rebuild PBO blit glTexImage() on top of miptrees.

This will ensure that we have resolves if we ever extend this to
glTexSubImage(), and fixes missing image start offset handling.

The texture buffer alloc ended up getting moved up, because we want to
look at the format of the image's actual mt to see if we'll end up
blitting the right thing, in the case of packed depth/stencil uploads.

This is the last caller of intelEmitCopyBlit() on a miptree-wrapped BO.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Rebuild PBO blit glReadPixels() on top of miptrees. 78/6778/1
Eric Anholt [Fri, 24 May 2013 18:10:37 +0000 (11:10 -0700)]
intel: Rebuild PBO blit glReadPixels() on top of miptrees.

The previous code was missing depth resolves, that had only been prevented
due to no blitting of Y tiling.  The pair of flip args in the new blit
function means that we can just drop the pack->Invert fallback.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Rework intel_miptree_create_for_region() to wrap a BO. 77/6777/1
Eric Anholt [Fri, 24 May 2013 17:54:36 +0000 (10:54 -0700)]
intel: Rework intel_miptree_create_for_region() to wrap a BO.

I needed to do this for the PBO blit cases to use intel_miptree_blit().
But this also actually partially fixes a bug in EGLImage handling: We
can't share regions across contexts, because regions have a refcount that
isn't protected by a mutex, and different contexts can be simulataneously
accessed from multiple threads.  Now we just need to get regions out of
__DRIImage.  There was also a missing use of image->offset in the EGLImage
renderbuffer storage code.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Make a temporary miptree for the blit path of miptree mapping. 76/6776/1
Eric Anholt [Thu, 23 May 2013 23:58:58 +0000 (16:58 -0700)]
intel: Make a temporary miptree for the blit path of miptree mapping.

In a bit of debug code, we no longer have the inter-slice x/y to print.
But I think the level/slice is more useful in this case for looking at
what's getting mapped, especially given that INTEL_DEBUG=blit will tell
you the other value.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Make a temporary miptree when doing blit uploads for glTexSubImage(). 75/6775/1
Eric Anholt [Thu, 23 May 2013 21:16:15 +0000 (14:16 -0700)]
intel: Make a temporary miptree when doing blit uploads for glTexSubImage().

While this is a bit more CPU work, it also is less code to handle this
path, and fixes problems with 32k-pitch textures and missing resolves.

v2: Add error checking in new code.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com> (v1)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Extend the force_y_tiling flag to allow forcing no tiling. 74/6774/1
Eric Anholt [Thu, 23 May 2013 23:08:22 +0000 (16:08 -0700)]
intel: Extend the force_y_tiling flag to allow forcing no tiling.

For a blit-uploaded temporary, it's faster on current hardware to memcpy
the data into a linear CPU mapping than to go through the GTT.

v2: Turn the not-fully-supported mask into 3 supported enum values.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com> (v1)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
Reviewed-by: Paul Berry <stereotype441@gmail.com> (v2)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com> (v2)
11 years agointel: Add an assert for glCopyTexSubImage() being called on MSAA buffers. 73/6773/1
Eric Anholt [Fri, 24 May 2013 20:37:13 +0000 (13:37 -0700)]
intel: Add an assert for glCopyTexSubImage() being called on MSAA buffers.

This is just in case someone else trips over this due to our weird reuse
of this code in glBlitFramebuffer().

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agoi965: Allow glCopyTexSubImage() on depth textures. 72/6772/1
Eric Anholt [Thu, 23 May 2013 20:40:26 +0000 (13:40 -0700)]
i965: Allow glCopyTexSubImage() on depth textures.

If the hw is pre-gen5 and can't blit depth, it'll cleanly error out.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agoi965: Prefer blorp glBlitFramebuffer() to the glCopyTexSubImage-based blit. 71/6771/1
Eric Anholt [Thu, 23 May 2013 23:43:58 +0000 (16:43 -0700)]
i965: Prefer blorp glBlitFramebuffer() to the glCopyTexSubImage-based blit.

I think we've measured no performance difference from this in the past,
except that the blorp code can do things like multisample resolves.
Prevents piglit regression in the next commit when a testcase started
trying to do a multisampled resolve through the old glCopyTexSubImage()
path.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agoi965: Consistently do depth resolves before blitting. 70/6770/1
Eric Anholt [Thu, 23 May 2013 20:36:26 +0000 (13:36 -0700)]
i965: Consistently do depth resolves before blitting.

We were protected for a long time by the fact that depth was Y tiled and
you couldn't blit Y.  Now that we can blit Y, we were failing to resolve
depth in glCopyPixels().

Note in the comment about swrast, that the swrast map path does resolves
appropriately already.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Make a wrapper for intelEmitCopyBlit using miptrees. 69/6769/1
Eric Anholt [Mon, 4 Feb 2013 22:24:09 +0000 (14:24 -0800)]
intel: Make a wrapper for intelEmitCopyBlit using miptrees.

I had previously asserted that it was hard to write a useful, simpler
blit function, but I think this might be it.

This has the side effect of extending the 32k pitch check to a few more
places that were missing it.

v2: Update comment for being moved inside intel_miptree_blit().

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Rename intel_renderbuffer_tile_offsets. 68/6768/1
Eric Anholt [Mon, 4 Feb 2013 22:21:24 +0000 (14:21 -0800)]
intel: Rename intel_renderbuffer_tile_offsets.

This makes it more consistent with intel_miptree_get_tile_offsets().

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Reduce intel_renderbuffer_tile_offsets to a thin wrapper. 67/6767/1
Eric Anholt [Mon, 4 Feb 2013 18:05:51 +0000 (10:05 -0800)]
intel: Reduce intel_renderbuffer_tile_offsets to a thin wrapper.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agointel: Make intel_miptree_get_tile_offsets return a page offset. 66/6766/1
Eric Anholt [Mon, 4 Feb 2013 18:00:10 +0000 (10:00 -0800)]
intel: Make intel_miptree_get_tile_offsets return a page offset.

Right now, the callers in i965 don't expect a nonzero page offset to
actually occur (since that's being handled elsewhere), but it seems
like a trap to leave it this way.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
11 years agoglsl: Fix MSVC build. 65/6765/1
José Fonseca [Tue, 28 May 2013 12:56:18 +0000 (13:56 +0100)]
glsl: Fix MSVC build.

It appears that `sizeof(Class::member)` is either non-standard or
merely unsupported in MSVC.

So use `sizeof(instance->member)` instead, which is guaranteed to work
everywhere.

Also promote the assert to a static assert.

Trivial.

11 years agomesa: fix GLSL program objects with more than 16 samplers combined 64/6764/1
Marek Olšák [Mon, 13 May 2013 13:46:49 +0000 (15:46 +0200)]
mesa: fix GLSL program objects with more than 16 samplers combined

The problem is the sampler units are allocated from the same pool for all
shader stages, so if a vertex shader uses 12 samplers (0..11), the fragment
shader samplers start at index 12, leaving only 4 sampler units
for the fragment shader. The main cause is probably the fact that samplers
(texture unit -> sampler unit mapping, etc.) are tracked globally
for an entire program object.

This commit adapts the GLSL linker and core Mesa such that the sampler units
are assigned to sampler uniforms for each shader stage separately
(if a sampler uniform is used in all shader stages, it may occupy a different
sampler unit in each, and vice versa, an i-th sampler unit may refer to
a different sampler uniform in each shader stage), and the sampler-specific
variables are moved from gl_shader_program to gl_shader.

This doesn't require any driver changes, and it fixes piglit/max-samplers
for gallium and classic swrast. It also works with any number of shader
stages.

v2: - converted tabs to spaces
    - added an assertion to _mesa_get_sampler_uniform_value

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agoswrast: increase array size of TextureSample 63/6763/1
Marek Olšák [Mon, 13 May 2013 14:24:57 +0000 (16:24 +0200)]
swrast: increase array size of TextureSample

to match the size of ctx->Texture.Unit, and it will also fix
piglit/max-samplers with the following commit.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
11 years agomesa: declare UniformBufferBindings as an array with a static size 62/6762/1
Marek Olšák [Tue, 14 May 2013 15:58:32 +0000 (17:58 +0200)]
mesa: declare UniformBufferBindings as an array with a static size

Some Gallium drivers were crashing, because the array was not large enough.

v2: clamp the per-shader maximum in st/mesa, then sum them all up

NOTE: This is a candidate for the stable branches.

11 years agoradeonsi: Enable GLSL 1.30 61/6761/1
Michel Dänzer [Fri, 24 May 2013 14:49:42 +0000 (16:49 +0200)]
radeonsi: Enable GLSL 1.30

11 years agoradeonsi: Handle TGSI TXQ opcode 60/6760/1
Michel Dänzer [Mon, 6 May 2013 10:45:14 +0000 (12:45 +0200)]
radeonsi: Handle TGSI TXQ opcode