Commit Graph

42781 Commits

Author SHA1 Message Date
Maarten Lankhorst ebe7c687ce nouveau: Fix bugs in nouveau_video_buffer
Double free and array overflow, even if only 2 members are
used the last one needs to be set to NULL explicitly.

Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com
2011-12-23 16:21:25 +01:00
Lauri Kasanen 2eafd07323 gallivm: Close a memory leak
Hi all

This fixes a memory leak of 32 bytes on exit.

From 924f8fdccb41b011f372bc57252005bcdb096105 Mon Sep 17 00:00:00 2001
From: Lauri Kasanen <curaga@operamail.com>
Date: Thu, 22 Dec 2011 21:28:33 +0200
Subject: [PATCH] gallivm: Close a memory leak

As reported by "valgrind --leak-check=full glxgears".

Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: José Fonseca <jfonseca@vmware.com>
2011-12-22 23:03:18 +00:00
Dave Airlie 7fd8dc3aa9 softpipe: try and use back color for a slot if color fails.
In the case where a front and back output are specified, the draw code will
copy the back output into the front color slot and everything is happy.

However if no front is specified then the draw code will do a bad copy (separate patch), but also the frag shader won't pick up the color as there there is
no write to COLOR from the vertex shader just BCOLOR.

This patch fixes that problem so if it can't find a vertex shader output
for the front color slot, it will go and lookup and use one for the back color
slot.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2011-12-22 12:25:33 +00:00
Dave Airlie d61d39922b format_unpack: add 8/16 rgba/rgb types.
fixing these makes piglit fbo-integer pass on softpipe.

modified to re-order things, haven't addressed Eric's concerns,
can't find anything in spec that mentions sign extensions, it does say
integers aren't clamped or modified.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2011-12-22 12:25:32 +00:00
Eric Anholt f1d89638c0 i965: Don't make consumers of brw_CONT/brw_WHILE track if depth in loop.
The codegen backends all had this same tracking, so just do it at the
EU level.

Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2011-12-21 14:31:33 -08:00
Eric Anholt ce6be334bb i965: Don't make consumers of brw_WHILE do pre-gen6 BREAK/CONT patching.
The EU code itself can just do this work, since all the consumers were
duplicating it.

Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2011-12-21 14:31:33 -08:00
Eric Anholt 32118cfe37 i965: Don't make consumers of brw_DO()/brw_WHILE() track loop start.
This is a similar cleanup to what we did for brw_IF(), brw_ELSE(),
brw_ENDIF() handling.

Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2011-12-21 14:31:33 -08:00
Eric Anholt 9f8814752f i965: Drop unused do_insn argument from gen6_CONT().
The branch distances get patched up later at the WHILE instruction.

Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2011-12-21 14:31:33 -08:00
Paul Berry d44878e754 mesa: Add _NEW_RASTERIZER_DISCARD as synonym for _NEW_TRANSFORM.
This makes it easier to keep track of which dirty bits correspond to
which pieces of context, since it makes _NEW_RASTERIZER_DISCARD
correspond with ctx->RasterDiscard.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
2011-12-21 13:33:35 -08:00
Paul Berry aee96806f0 mesa: Move RasterDiscard to toplevel of gl_context.
Previously we were storing the RasterDiscard flag (for
GL_RASTERIZER_DISCARD) in gl_context::TransformFeedback.  This was
confusing, because we use the _NEW_TRANSFORM flag (not
_NEW_TRANSFORM_FEEDBACK) to track state updates to it, and because
rasterizer discard has effects even when transform feedback is not in
use.

This patch makes RasterDiscard a toplevel element in gl_context rather
than a subfield of gl_context::TransformFeedback.

Note: We can't put RasterDiscard inside gl_context::Transform, since
all items inside gl_context::Transform need to be pieces of state that
are saved and restored using PushAttrib and PopAttrib.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
2011-12-21 13:33:31 -08:00
Kristian Høgsberg 636f2fc46c egl/x11: Merge the right version of Frederiks change
Argh, I merged an older broken version of the swapbuffer change instead of
Frederiks fixed version.  This diffs gets us back to the right version.
2011-12-21 10:29:30 -05:00
Fredrik Höglund 352c889c10 egl_dri2/x11: Add support for the DRI2 SwapBuffers request 2011-12-20 22:11:18 -05:00
Fredrik Höglund 655f2c1d65 egl_dri2/x11: Add support for eglSwapInterval 2011-12-20 22:11:17 -05:00
Paul Berry 3a2e71874b i965 gen6: Turn on transform feedback extension unconditionally.
Previously, we only enabled transform feedback when
MESA_GL_VERSION_OVERRIDE was 3.0 or greater, since transform feedback
support was not completely finished, so it didn't make sense to
advertise support for it unless absolutely necessary.

Now that transform feedback is fully implemented on gen6, we can
enable this extension unconditionally.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 15:22:28 -08:00
Paul Berry c59393b706 i965 gen6: Implement transform feedback queries.
This patch adds software-based PRIMITIVES_GENERATED and
TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN queries that work by keeping
track of the number of primitives that are sent down the pipeline, and
adjusting as necessary to account for the way each primitive type is
tessellated.

In the long run we'll want to replace this with a hardware-based
implementation, because the software approach won't work with geometry
shaders or primitive restart.  However, at the moment, we don't have
the necessary kernel support to implement a hardware-based query (we
would need the kernel to save GPU registers when context switching, so
that drawing performed by another process doesn't get counted).

Fixes Piglit tests EXT_transform_feedback/query-primitives_generated-*
and EXT_transform_feedback/query-primitives-written-*.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 15:22:28 -08:00
Paul Berry c5e17a8498 i965: Convert if/else to switch statements in brw_queryobj.c
Previously, i965 only supported two query types: GL_TIME_ELAPSED_EXT
and GL_SAMPLES_PASSED_ARB, and it distinguished between the two using
if/else statements that compared query->Base.Target to
GL_TIME_ELAPSED_EXT.

This patch changes the if/else statements to switch statements so that
we can add more query types without having to have a chain of
else-ifs.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 15:22:28 -08:00
Paul Berry f8328c998b i965 gen6: Ensure correct transform feedback indices on new batch.
We don't currently have kernel support for saving GPU registers on a
context switch, so if multiple processes are performing transform
feedback at the same time, their SVBI registers will interfere with
each other.  To avoid this situation, we keep a software shadow of the
state of the SVBI 0 register (which is the only register we use), and
re-upload it on every new batch.

The function that updates the shadow state of SVBI 0 is called
brw_update_primitive_count, since it will also be used to update the
counters for the PRIMITIVES_GENERATED and
TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN queries.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 15:22:28 -08:00
Paul Berry 163611d7b2 mesa: Add a function to query whether a meta-op is in progress.
This is needed by i965 to ensure that transform feedback counters are
not incremented during meta-ops.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 15:22:28 -08:00
Paul Berry dc7b6d7d6d mesa: Add count_tessellated_primitives() function.
This function computes the number of primitives that will be generated
when the given drawing operation is performed.  It accounts for the
tessellation that is performed on line strips, line loops, triangle
strips, triangle fans, quads, quad strips, and polygons, so it is
suitable for implementing the primitive counters needed by transform
feedback.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 15:22:28 -08:00
Paul Berry 291ae4e639 mesa: Remove unnecessary FLUSH_VERTICES in bind_buffer_range
It isn't necessary to call FLUSH_VERTICES from bind_buffer_range,
because transform feedback buffers are not allowed to be changed when
transform feedback is active.

Thanks to Marek Olšák for pointing out this bug.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
2011-12-20 15:22:28 -08:00
Paul Berry 7d2ff0bf0b i965 gen6: Implement rasterizer discard.
This patch enables rasterizer discard functionality (a part of
transform feedback) in Gen6, by generating an alternate GS program
when rasterizer discard is active.  Instead of forwarding vertices
down the pipeline, the alternate GS program uses a URB Write message
to deallocate the URB entry that was allocated by FF sync and
terminate the thread.

Note: parts of the Sandy Bridge PRM seem to imply that we could do
this more efficiently, by clearing the GEN6_GS_RENDERING_ENABLE bit,
and not allocating a URB entry at all.  However, it's not clear how we
are supposed to terminate the thread if we do that.  Volume 2 part 1,
section 4.5.4, says "GS threads must terminate by sending a URB_WRITE
message with the EOT and Complete bits set.", and my experiments so
far confirm that.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 15:22:08 -08:00
Kenneth Graunke 21504b462a i965: Implement bounds checking for transform feedback output.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
2011-12-20 15:17:23 -08:00
Paul Berry 63cf7fad13 i965: Flush pipeline on EndTransformFeedback.
A common use case for transform feedback is to perform one draw
operation that writes transform feedback output to a buffer, followed
by a second draw operation that consumes that buffer as vertex input.
Since vertex input is consumed at an earlier pipeline stage than
writing transform feedback output, we need to flush the pipeline to
ensure that the transform feedback output is completely written before
the data is consumed.

In an ideal world, we would do some dependency tracking, so that we
would only flush the pipeline if the next draw call was about to
consume data generated by a previous draw call in the same batch.
However, since we don't have that sort of dependency tracking
infrastructure right now, we just unconditionally flush the buffer
every time glEndTransformFeedback() is called.  This will cause a
performance hit compared to the ideal case (since we will sometimes
flush the pipeline unnecessarily), but fortunately the performance hit
will be confined to circumstances where transform feedback is in use.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
2011-12-20 15:00:29 -08:00
Paul Berry c3161b629f i965 gen6+: Make intel_batchbuffer_emit_mi_flush() actually flush.
Previous to this patch, the function intel_batchbuffer_emit_mi_flush()
was a bit of a misnomer.  On Gen4+, when not using the blit engine, it
didn't actually flush the pipeline--it simply generated a PIPE_CONTROL
command with the necessary bits set to flush GPU caches.  This was
usually sufficient, since in most situations where
intel_batchbuffer_emit_mi_flush() was called, all we really care about
was ensuring cache coherency.

However, with the advent of OpenGL 3.0, there are two cases in which
data output by one stage of the pipeline might be consumed, in a later
draw operation, by an earlier stage of the pipeline:

(a) When using textures in the vertex shader.

(b) When using drawing with a vertex buffer that was previously
    generated using transform feedback.

This patch addresses case (a) by changing
intel_batchbuffer_emit_mi_flush() so that on Gen6+, it sets the
PIPE_CONTROL_CS_STALL bit (this forces the pipeline to actually
flush).  (Case (b) will be addressed by the next patch in the series).

This is not an ideal solution--in a perfect world, the driver would
have some buffer dependency tracking so that we would only have to
flush the pipeline in the two cases above.  Until that dependency
tracking is implemented, however, it seems prudent to have
intel_batchbuffer_emit_mi_flush() actually flush the pipeline, so that
we get correct rendering, at the expense of a (hopefully small)
performance hit.

The change is only applied to Gen6+, since at the moment only Gen6+
supports the OpenGL 3.0 features that make a full pipeline flush
necessary.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
2011-12-20 15:00:28 -08:00
Paul Berry 6ca61441b5 i965 gen6: Turn on transform feedback extension.
This patch advertises support for EXT_transform_feedback on Intel
Gen6.

Since transform feedback support is not completely finished yet, for
now we only advertise support for it when MESA_GL_VERSION_OVERRIDE is
3.0 or greater (since transform feedback is required by GL version
3.0).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 15:00:28 -08:00
Paul Berry 9308f29830 i965 gen6: Initial implementation of transform feedback.
This patch adds basic transform feedback capability for Gen6 hardware.
This consists of several related pieces of functionality:

(1) In gen6_sol.c, we set up binding table entries for use by
transform feedback.  We use one binding table entry per transform
feedback varying (this allows us to avoid doing pointer arithmetic in
the shader, since we can set up the binding table entries with the
appropriate offsets and surface pitches to place each varying at the
correct address).

(2) In brw_context.c, we advertise the hardware capabilities, which
are as follows:

   MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 64
   MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS        4
   MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS    16

OpenGL 3.0 requires these values to be at least 64, 4, and 4,
respectively.  The reason we advertise a larger value than required
for MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS is that we have already
set aside 64 binding table entries, so we might as well make them all
available in both separate attribs and interleaved modes.

(3) We set aside a single SVBI ("streamed vertex buffer index") for
use by transform feedback.  The hardware supports four independent
SVBI's, but we only need one, since vertices are added to all
transform feedback buffers at the same rate.  Note: at the moment this
index is reset to 0 only when the driver is initialized.  It needs to
be reset to 0 whenever BeginTransformFeedback() is called, and
otherwise preserved.

(4) In brw_gs_emit.c and brw_gs.c, we modify the geometry shader
program to output transform feedback data as a side effect.

(5) In gen6_gs_state.c, we configure the geometry shader stage to
handle the SVBI pointer correctly.

Note: ordering of vertices is not yet correct for triangle strips
(alternate triangles are improperly oriented).  This will be addressed
in a future patch.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
2011-12-20 15:00:23 -08:00
Paul Berry 1413f955eb i965 gs: Move vue_map to brw_gs_compile.
This patch stores the geometry shader VUE map from a local variable in
compile_gs_prog() to a field in the brw_gs_compile struct, so that it
will be available while compiling the geometry shader.  This is
necessary in order to support transform feedback on Gen6, because the
Gen6 geometry shader code that supports transform feedback needs to be
able to inspect the VUE map in order to find the correct vertex data
to output.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 14:32:16 -08:00
Paul Berry fd5d0c8b12 i965 gen6+: Use 1-wide null operands for IF instructions
The Sandy Bridge PRM, volume 4, part 2, section 5.3.10 ("5.3.10
Register Region Restrictions") contains the following restriction on
the execution size and operand width of instructions:

   "3. ExecSize must be equal to or greater than Width."

When emitting an IF instruction in single program flow mode on Gen6+,
we use an ExecSize of 1, therefore the Width of each operand must also
be 1.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 14:32:16 -08:00
Paul Berry 38b118d49d mesa: Fix off-by-one error in transform feedback size check.
In _mesa_BindBufferRange(), we need to verify that the offset and size
specified by the client do not exceed the size of the underlying
buffer.  We were accidentally doing this check using ">=" rather than
">", so we were generating a bogus error if the client specified an
offset and size that fit exactly in the underlying buffer.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-12-20 14:32:16 -08:00
Paul Berry 942d452047 mesa: Record transform feedback strides/offsets in linker output.
This patch adds two new fields to the gl_transform_feedback_info
struct:

- BufferStride records the total number of components (per vertex)
  that transform feedback is being instructed to store in each buffer.

- Outputs[i].DstOffset records the offset within the interleaved
  structure of each transform feedback output.

These values are needed by the i965 gen6 and r600g back-ends, so it
seems better to have the linker provide them rather than force each
back-end to compute them independently.

Also, DstOffset helps pave the way for supporting
ARB_transform_feedback3, which allows the transform feedback output to
contain holes between attributes by specifying
gl_SkipComponents{1,2,3,4} as the varying name.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
2011-12-20 14:32:16 -08:00
Jon TURNEY 9f8573b7ae Fix compilation on cygwin after commit 762c9766c9
Fix compilation on cygwin after commit 762c9766c9
"Use VERT_ATTRIB_* indexed array in gl_array_object" added the first non-driver
use of ffsll(), which exposes the fact that this isn't provided on cygwin.

Found by tinderbox, see [1]

[1] http://tinderbox.freedesktop.org/builds/2011-11-30-0017/logs/libGL/#build

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Brian Paul <brianp@vmware.com>
2011-12-20 13:45:27 +00:00
Maarten Lankhorst 704d22dfc1 xvmc: Remove unused variable
Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Signed-off-by: Christian König <deathsimple@vodafone.de>
2011-12-20 13:12:54 +01:00
Maarten Lankhorst 68651c3243 vl: Remove unused declaration
csc is not used for rgba and gives a warning.

Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Signed-off-by: Christian König <deathsimple@vodafone.de>
2011-12-20 13:12:39 +01:00
Maarten Lankhorst 72325ee6e3 vl: Use pipe clear_render_target instead of util_clear_render_target
Mapping to software and uploading again clearing is killing performance.

Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Signed-off-by: Christian König <deathsimple@vodafone.de>
2011-12-20 13:05:49 +01:00
Pekka Paalanen dae2fca705 mesa: fix a leak in _mesa_delete_texture_image()
Valgrind complains about a definitely lost block allocated in
intelNewTextureImage(). This leak was apparently created by
6e0f9001fe, "mesa: move
gl_texture_image::Data, RowStride, ImageOffsets to swrast", as it
removes the free() from _mesa_delete_texture_image().

Put the free() back, fixes a Valgrind error.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2011-12-20 11:58:23 +02:00
Chia-I Wu 249c6f1934 st/egl: error check and clamp coordinates in eglPostSubBufferNV
EGL_BAD_PARAMETER should be returned when any of the coordinates is negative.
2011-12-20 17:26:18 +08:00
Chia-I Wu eb7d1b9474 egl_dri2/x11: error check coordinates in eglPostSubBufferNV
EGL_BAD_PARAMETER should be returned when any of the coordinates is negative.
2011-12-20 17:26:18 +08:00
Fredrik Höglund 7577284213 st/egl: Add support for EGL_NV_post_sub_buffer
Signed-off-by: Fredrik Höglund <fredrik@kde.org>

[olv: remove #ifdef checks]
2011-12-20 17:09:06 +08:00
Fredrik Höglund 71b8fc9872 egl_dri2/x11: Add support for EGL_NV_post_sub_buffer
Signed-off-by: Fredrik Höglund <fredrik@kde.org>
2011-12-20 17:05:11 +08:00
Fredrik Höglund 7d46b45c5b egl: add EGL_NV_post_sub_buffer
v2: Handle EGL_POST_SUB_BUFFER_SUPPORTED_NV in
    _eglParseSurfaceAttribList()

Signed-off-by: Fredrik Höglund <fredrik@kde.org>

[olv: remove #ifdef checks]
2011-12-20 17:04:46 +08:00
Chia-I Wu f63e129d5f egl: KHR_reusable_sync entrypoints are missing from eglGetProcAddress 2011-12-20 17:00:01 +08:00
Chia-I Wu f957cac772 egl: remove #ifdef's for official extensions
There is no point in having them when we distribute eglext.h.

As for unofficial extensions, there is a chance that we might remove some of
them evetually.  Keeping the #ifdef's for now should make that easier.
2011-12-20 16:59:09 +08:00
Chia-I Wu ed1ff2acec egl: remove EGL_ANDROID_swap_rectangle
We never support this unofficial extension, and it has been removed from
Android recently.  There is no point in keeping it.
2011-12-20 16:20:17 +08:00
Stéphane Marchesin 67e6a40605 i915g: Add unsupported caps. 2011-12-19 18:33:03 -08:00
Stéphane Marchesin 1981042341 i915g: Turn an assert into a debug message, print more debug info for missing depth swz.
Also fix indentation a bit.
2011-12-19 18:28:26 -08:00
Stéphane Marchesin a7534d8943 i915g: Make the pipe_sampler_state struct non const and get rid of useless memcpy. 2011-12-19 18:28:26 -08:00
Stéphane Marchesin c661843ab6 i915g: Implement KILP. 2011-12-19 18:24:39 -08:00
Stéphane Marchesin 3c01aefe5f i915g: Add two unsupported caps. 2011-12-19 18:24:39 -08:00
Stéphane Marchesin 9c76ba04f8 i915g: Put the templates at the beggining of the structures.
Seriously. This fixes fragment-and-vertex-texturing in piglit and probably
a boatload of other stuff.
2011-12-19 18:24:39 -08:00
Kenneth Graunke 37d24a70da i965: Advertise our vertex shader texture units.
Previously, we advertised 0 VS texture units.  Now that we have proper
support for using the sampling engine in the VS, we can advertise 16,
which is conveniently the number required for OpenGL 3.0.

v2: Enable on Gen4.  I hacked up my tests to not use flat ivec varyings
    and they pass.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-12-19 16:33:11 -08:00