mesa.git
12 years agoglsl: Fix crashes caused by Bison error messages involving "'%'".
Kenneth Graunke [Thu, 8 Dec 2011 09:35:48 +0000 (01:35 -0800)]
glsl: Fix crashes caused by Bison error messages involving "'%'".

Invalid shaders containing the character % at an unexpected location
would cause Bison to call yyerror with a message of:

    syntax error, unexpected '%'

Bison expects yyerror() to take a string, while _mesa_glsl_error() is a
printf-style function.  This hit the classic printf string escape issue:

    _mesa_glsl_error(loc, state, "unexpected '%'");       // invalid!
    _mesa_glsl_error(loc, state, "%s", "unexpected '%'"); // correct.

This caused assertion failures after ralloc_asprintf_append called
vsnprintf to determine the length of the text that would be printed:
vsnprintf would see the invalid format and return -1, an invalid length.

The solution is to define a proper yyerror() wrapper function that calls
_mesa_glsl_error with the "%s".  Since we compile with -p "_mesa_glsl",
yyerror is defined as:

    #define yyerror         _mesa_glsl_error

So we have to #undef yyerror in order to be able to declare it.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=43564
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Paul Berry <stereotype441@gmail.com>
12 years agoRegenerate files from previous commits
Ian Romanick [Thu, 8 Dec 2011 20:27:38 +0000 (12:27 -0800)]
Regenerate files from previous commits

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
12 years agoglapi/glx: For GLX code, use the existing _X_HIDDEN and _X_INTERNAL defines
Ian Romanick [Thu, 8 Dec 2011 18:58:06 +0000 (10:58 -0800)]
glapi/glx: For GLX code, use the existing _X_HIDDEN and _X_INTERNAL defines

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
12 years agoglapi/glx: Generate glapi_gentable.c so that the xserver can use it
Ian Romanick [Mon, 5 Dec 2011 23:24:49 +0000 (15:24 -0800)]
glapi/glx: Generate glapi_gentable.c so that the xserver can use it

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
12 years agoglapi/glx: Generate dispatch.h so that the xserver can use it
Ian Romanick [Mon, 5 Dec 2011 23:24:05 +0000 (15:24 -0800)]
glapi/glx: Generate dispatch.h so that the xserver can use it

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
12 years agoglapi/glx: Xserver wants dispatch.h, not glapidispatch.h
Ian Romanick [Mon, 5 Dec 2011 23:20:06 +0000 (15:20 -0800)]
glapi/glx: Xserver wants dispatch.h, not glapidispatch.h

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
12 years agoglapi/glx: Don't send GL API files to the xserver
Ian Romanick [Mon, 5 Dec 2011 23:18:54 +0000 (15:18 -0800)]
glapi/glx: Don't send GL API files to the xserver

The versions in the xserver and in libGL have diverged enough that the
xserver doesn't want these.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
12 years agoglapi: Remove mention of nonexistent enums
Ian Romanick [Mon, 5 Dec 2011 23:12:07 +0000 (15:12 -0800)]
glapi: Remove mention of nonexistent enums

glext.h doesn't have GL_MIN_PROGRAM_TEXEL_OFFSET_EXT or
GL_MAX_PROGRAM_TEXEL_OFFSET_EXT.  Using them in the XML causes code to
be generated for the xserver that won't compile.  Use the names that
exist instead.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
12 years agoglapi/glx: Remove g_disptab.h from xserver generated files
Ian Romanick [Mon, 5 Dec 2011 23:10:55 +0000 (15:10 -0800)]
glapi/glx: Remove g_disptab.h from xserver generated files

That file was removed from the xserver with commit:

    commit a80780a7638f847c3be20e5e0c7fe85e83d9bdd1
    Author: Adam Jackson <ajax@redhat.com>
    Date:   Wed Nov 17 09:03:06 2010 -0500

        glx: Remove swap barrier and hyperpipe support

        Never implemented in any open source driver.  The implementation
        assumed explicit DDX driver knowledge of how the client-side driver
        worked, since at the time the server's GL renderer was not a DRI driver.
        But now, it is, so any implementation of these should be done with
        additional DRI driver API, like the swap control extension.

Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
12 years agor300g: take advantage of KEEP_TILING_FLAGS flush flag
Marek Olšák [Tue, 13 Dec 2011 19:27:48 +0000 (20:27 +0100)]
r300g: take advantage of KEEP_TILING_FLAGS flush flag

This fixes at least two multi-context-related races.

12 years agonouveau: get rid of winsys object
Marcin Slusarz [Fri, 2 Dec 2011 21:02:51 +0000 (22:02 +0100)]
nouveau: get rid of winsys object

Its only purpose was to destroy itself.

12 years agoi915g: Roll back to the previous shader limits.
Stéphane Marchesin [Fri, 9 Dec 2011 03:22:13 +0000 (19:22 -0800)]
i915g: Roll back to the previous shader limits.

Those shader limits seem to be responsible for a piglit hang.

12 years agoi915g: Update TODO.
Stéphane Marchesin [Fri, 4 Nov 2011 23:13:50 +0000 (16:13 -0700)]
i915g: Update TODO.

12 years agowinsys/radeon: add flush option not to rewrite tiling flags in registers
Marek Olšák [Mon, 24 Oct 2011 23:44:45 +0000 (01:44 +0200)]
winsys/radeon: add flush option not to rewrite tiling flags in registers

Not used yet.

12 years agomesa: add const flags to skip MaxVarying and MaxUniform linker checks (v2)
Marek Olšák [Sat, 10 Dec 2011 03:14:46 +0000 (04:14 +0100)]
mesa: add const flags to skip MaxVarying and MaxUniform linker checks (v2)

This is only temporary until a better solution is available.

v2: print warnings and add gallium CAPs

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
12 years agomesa: fix an out-of-bounds access in prog_print.c
Marek Olšák [Mon, 12 Dec 2011 05:29:31 +0000 (06:29 +0100)]
mesa: fix an out-of-bounds access in prog_print.c

Reviewed-by: Brian Paul <brianp@vmware.com>
12 years agoglsl_to_tgsi: fix typo in comment
Bryan Cain [Tue, 13 Dec 2011 16:33:44 +0000 (10:33 -0600)]
glsl_to_tgsi: fix typo in comment

12 years agoglsl_to_tgsi: emit both operands of shift and bitwise operations
Bryan Cain [Tue, 13 Dec 2011 16:30:59 +0000 (10:30 -0600)]
glsl_to_tgsi: emit both operands of shift and bitwise operations

Fixes these operations when native integers are enabled.

12 years agoegl_dri2: Fix some valgrind reported leaks
Benjamin Franzke [Tue, 13 Dec 2011 13:43:48 +0000 (14:43 +0100)]
egl_dri2: Fix some valgrind reported leaks

Free the device_name, reported by Pekka Paalanen.

Destroy wayland display and drm resources,
if created by dri2_initialize_wayland.

12 years agomesa: update comments for _DepthBuffer, _StencilBuffer fields
Brian Paul [Sat, 10 Dec 2011 18:44:44 +0000 (11:44 -0700)]
mesa: update comments for _DepthBuffer, _StencilBuffer fields

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: remove _DepthBuffer, _StencilBuffer resize code
Brian Paul [Sat, 10 Dec 2011 18:44:44 +0000 (11:44 -0700)]
mesa: remove _DepthBuffer, _StencilBuffer resize code

This is handled in swrast now when we validate the framebuffer state.

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoswrast: add debug code to test combined depth/stencil buffers
Brian Paul [Sat, 10 Dec 2011 18:44:44 +0000 (11:44 -0700)]
swrast: add debug code to test combined depth/stencil buffers

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: remove unused depthstencil.[ch] files
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
mesa: remove unused depthstencil.[ch] files

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: move depth/stencil buffer validation to swrast
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
mesa: move depth/stencil buffer validation to swrast

Since gl_framebuffer::_DepthBuffer and _StencilBuffer are only used
by swrast, do the validation of those fields in swrast too.
The main/depthstencil.[ch] code is no longer used and will be removed
next.

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoswrast: update depth/stencil wrapper sizes
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
swrast: update depth/stencil wrapper sizes

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: build swrast/s_depthstencil.c
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
mesa: build swrast/s_depthstencil.c

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoswrast: add new s_depthstencil.[ch] files
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
swrast: add new s_depthstencil.[ch] files

These files are copies of main/depthstencil.[ch] with s/mesa/swrast/.
The main/depthstencil.[ch] will go away soon.

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: move update_depth/stencil_buffer() functions
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
mesa: move update_depth/stencil_buffer() functions

These functions update the gl_framebuffer::_DepthBuffer and _StencilBuffer
fields, possibly creating renderbuffer wrappers that make a shared
depth+stencil accessible as depth-only or stencil only.
This stuff is only used by swrast now and will be moved there next.

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoradeon: stop using _DepthBuffer, _StencilBuffer fields
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
radeon: stop using _DepthBuffer, _StencilBuffer fields

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agonouveau: stop using _DepthBuffer, _StencilBuffer fields
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
nouveau: stop using _DepthBuffer, _StencilBuffer fields

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: stop using _Depth, _StencilBuffer fields in _mesa_BlitFramebufferEXT()
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
mesa: stop using _Depth, _StencilBuffer fields in _mesa_BlitFramebufferEXT()

We're just looking at the depth/stencil renderbuffers to do error
checking.  We don't need to look at the depth/stencil wrappers to do
that.  Also, remove pointless readRb = depthRb = NULL assignments.

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agost/mesa: stop using _DepthBuffer, _StencilBuffer fields
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
st/mesa: stop using _DepthBuffer, _StencilBuffer fields

We never want to use the depth/stencil buffer wrappers so always just
use the attachment renderbuffers.  This is a step toward removing the
_DepthBuffer, _StencilBuffer fields.

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoswrast: add missing state validation calls for Blit, Clear
Brian Paul [Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)]
swrast: add missing state validation calls for Blit, Clear

12 years agor600g: add some new pci ids
Alex Deucher [Mon, 12 Dec 2011 14:48:15 +0000 (09:48 -0500)]
r600g: add some new pci ids

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

Note: this is a candidate for the stable branches.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
12 years agomesa: fix possible precision issues in pack/unpack/fetch functions
Marek Olšák [Sun, 11 Dec 2011 15:18:36 +0000 (16:18 +0100)]
mesa: fix possible precision issues in pack/unpack/fetch functions

GLfloat doesn't have enough precision to exactly represent 0xffffff
and 0xffffffff. (and a reciprocal of those, if I am not mistaken)

If -ffast-math is enabled, using GLfloat causes assertion failures in:
- fbo-blit-d24s8
- fbo-depth-sample-compare
- fbo-readpixels-depth-formats
- glean/depthStencil

For example:
fbo-depth-sample-compare: main/format_unpack.c:1769:
unpack_float_z_Z24_X8: Assertion `dst[i] <= 1.0F' failed.

Reviewed-by: Brian Paul <brianp@vmware.com>
12 years agor300g: integer and fixed-point 16.16 textures are not supported
Marek Olšák [Sun, 11 Dec 2011 12:25:56 +0000 (13:25 +0100)]
r300g: integer and fixed-point 16.16 textures are not supported

12 years agost/mesa: add color varyings to MaxVarying
Marek Olšák [Tue, 22 Nov 2011 14:05:29 +0000 (15:05 +0100)]
st/mesa: add color varyings to MaxVarying

The linker now adds color varyings to the number of used varyings and checks
against that limit.

NOTE: This is a candidate for the 7.11 branch.

12 years agoi915g: fix debug dump on 64 bit systems
Michael Karcher [Sun, 11 Dec 2011 21:24:10 +0000 (13:24 -0800)]
i915g: fix debug dump on 64 bit systems

12 years agoi915g: Fix wrong indices for LINE_LOOP case
Fatih Aşıcı [Sun, 11 Dec 2011 21:21:53 +0000 (13:21 -0800)]
i915g: Fix wrong indices for LINE_LOOP case

12 years agovl: Add missing mpeg fields to pipe_mpeg12_picture_desc
Maarten Lankhorst [Fri, 2 Dec 2011 00:00:54 +0000 (01:00 +0100)]
vl: Add missing mpeg fields to pipe_mpeg12_picture_desc

Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
12 years agog3dvl/xlib: fix build by changing include order
Tobias Droste [Sun, 11 Dec 2011 04:13:47 +0000 (05:13 +0100)]
g3dvl/xlib: fix build by changing include order

fixes the following build error since
c83fb4d45f2a47042f395271efe6e5489b2c4aee:

/usr/include/strings.h:46:13: error: expected declaration specifiers or
‘...’ before numeric constant
/usr/include/strings.h:46:13: error: conflicting types for ‘memset’
In file included from
../../../../src/gallium/winsys/g3dvl/xlib/xsp_winsys.c:34:0:
../../../../src/gallium/auxiliary/util/u_inlines.h: In function
‘pipe_buffer_create’:
../../../../src/gallium/auxiliary/util/u_inlines.h:189:4: error: too
many arguments to function ‘memset’
/usr/include/strings.h:46:13: note: declared here

bzero is defined in X11 as: #define bzero(b,len) memset(b,0,len)
including strings.h after the X11 header results in preprocessor
replacing 'bzero' in strings.h and generating unbuildable code.

Signed-off-by: Tobias Droste <tdroste@gmx.de>
12 years agost/mesa: move frag depth up a level.
Dave Airlie [Sat, 10 Dec 2011 17:30:37 +0000 (17:30 +0000)]
st/mesa: move frag depth up a level.

This fixes the segfault, and seems to put this closer to where other
properties are being set. Hopefully it still conforms.

Signed-off-by: Dave Airlie <airlied@redhat.com>
12 years agoRevert "st/mesa: only resolve is number of samples is > 1"
Dave Airlie [Sat, 10 Dec 2011 09:04:46 +0000 (09:04 +0000)]
Revert "st/mesa: only resolve is number of samples is > 1"

This reverts commit 8c713626db33c40c18e24c880fe47d7948f4dcd7.

Didn't mean to push this at all

12 years agost/mesa: only resolve is number of samples is > 1
Dave Airlie [Wed, 30 Nov 2011 20:10:33 +0000 (20:10 +0000)]
st/mesa: only resolve is number of samples is > 1

This fixes the firefox crash but I've no idea if its correct.

Signed-off-by: Dave Airlie <airlied@redhat.com>
12 years agomesa: add missing RG_INTEGER and some RED_INTEGER_EXT checks.
Dave Airlie [Sun, 4 Dec 2011 20:14:09 +0000 (20:14 +0000)]
mesa: add missing RG_INTEGER and some RED_INTEGER_EXT checks.

This just adds the correct checks and asserts in the right places. This doesn't
fix all the tests that I've sent to piglit, need to add int paths to go alongside the uint paths that don't go via float to fix it up properly.

I'm not sure how much of that could be templated/shared will have a look
once I write it the long way.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
12 years agogallium: implement ARB_conservative_depth
Marek Olšák [Fri, 18 Nov 2011 14:45:03 +0000 (15:45 +0100)]
gallium: implement ARB_conservative_depth

This adds a new TGSI property to represent the GLSL layout qualifier in TGSI.

12 years agoutil: Add strings.h include on unices
José Fonseca [Fri, 9 Dec 2011 20:05:27 +0000 (20:05 +0000)]
util: Add strings.h include on unices

Fixes -Wimplicit-function-declaration for ffs with GCC.  Spotted/tested
by Kai Wasserbäch.

12 years agomesa/st: Don't modify the context draw/read buffers.
José Fonseca [Thu, 8 Dec 2011 13:25:10 +0000 (13:25 +0000)]
mesa/st: Don't modify the context draw/read buffers.

It sets the wrong values (GL_XXX_LEFT instead of GL_XXX), and no other
Mesa driver does this, given that Mesa sets the right draw/read buffers
provided the Mesa visual has the doublebuffer flag filled correctly
which is the case.

Reviewed-by: Brian Paul <brianp@vmware.com>
12 years agomesa,intel: use _mesa_image_offset() for PBOs
nobled [Wed, 19 Oct 2011 06:35:53 +0000 (06:35 +0000)]
mesa,intel: use _mesa_image_offset() for PBOs

This avoids forming invalid pointers needlessly, which even if
never dereferenced is undefined behavior. It also makes
_mesa_validate_pbo_access() more comprehensible.

Reviewed-by: Brian Paul <brianp@vmware.com>
12 years agomesa: add _mesa_image_offset()
nobled [Tue, 18 Oct 2011 20:50:16 +0000 (20:50 +0000)]
mesa: add _mesa_image_offset()

Reviewed-by: Brian Paul <brianp@vmware.com>
12 years agomesa/image: assert on bad format
nobled [Mon, 17 Oct 2011 21:34:44 +0000 (21:34 +0000)]
mesa/image: assert on bad format

NULL as an error indicator is meaningless, since it will return NULL
on success anyway if the caller passes in zero as the image's address
and asks to calculate the offset of the first pixel. For example,
_mesa_validate_pbo_access() does this.

This also matches the code in the non-GL_BITMAP codepath, which
already has an assert like this.

v2: Per Brian Paul's review, remove the function call entirely
and tighten the assert to only accept the two formats compatible with
GL_BITMAP. They always have one component per pixel.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
12 years agomesa/image: delete dead store
nobled [Mon, 17 Oct 2011 21:27:55 +0000 (21:27 +0000)]
mesa/image: delete dead store

The return value here is a) always zero, b) never used.

Reviewed-by: Brian Paul <brianp@vmware.com>
12 years agoglsl_to_tgsi: fix a bug in eliminate_dead_code_advanced()
Bryan Cain [Thu, 8 Dec 2011 19:48:27 +0000 (13:48 -0600)]
glsl_to_tgsi: fix a bug in eliminate_dead_code_advanced()

The bug, reported to me by Vadim Girlin on IRC, was causing overzealous
elimination of code in parallel if statements such as the following:

if (x) {
r = false;
}
if (y) {
r = true;
}

Before this commit, the assignment inside the first if block would be
misdetected as dead code and removed.

12 years agollvmpipe: Trim the fragment shader cached based on LLVM IR instruction count.
José Fonseca [Wed, 30 Nov 2011 17:12:00 +0000 (17:12 +0000)]
llvmpipe: Trim the fragment shader cached based on LLVM IR instruction count.

Number of fragment shader variants is not very representative of the
memory used by LLVM, neither is number of shader instructions, as often
texture sampling constitutes most of the generated code.

This change adds an additional trim criteria: least recently used
fragment shader variants will be freed until the total number of LLVM IR
instruction falls below a specified threshold.

Reviewed-by: Brian Paul <brianp@vmware.com>
12 years agollvmpipe,draw,gallivm: Ensure we don't walk beyond the end of the shader variant...
José Fonseca [Mon, 28 Nov 2011 16:54:09 +0000 (16:54 +0000)]
llvmpipe,draw,gallivm: Ensure we don't walk beyond the end of the shader variant list.

u_simple_list.h uses a sentinel element, and not a NULL element. So
ensure list is not empty when reducing the list of shader variants.

Something I noticed while trying to free variants more aggressively.

Reviewed-by: Brian Paul <brianp@vmware.com>
12 years agoswrast: use malloc instead of MAX_WIDTH arrays in glCopyPixels, zoom code
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
swrast: use malloc instead of MAX_WIDTH arrays in glCopyPixels, zoom code

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: use malloc instead of MAX_WIDTH array in glReadPixels()
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
mesa: use malloc instead of MAX_WIDTH array in glReadPixels()

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: use malloc instead of MAX_WIDTH array in _mesa_convert_colors()
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
mesa: use malloc instead of MAX_WIDTH array in _mesa_convert_colors()

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: add MAX_PIXEL_BYTES define
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
mesa: add MAX_PIXEL_BYTES define

In a few places we need to allocate space for some number of generic
pixels.  Use this new define instead of a magic number like 16 or
4 * sizeof(GLuint).

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: simplify _mesa_remove_renderbuffer()
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
mesa: simplify _mesa_remove_renderbuffer()

12 years agomesa: remove software-based renderbuffer code from core Mesa
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
mesa: remove software-based renderbuffer code from core Mesa

We're now using the functions that live in swrast.

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa/drivers: use new swrast renderbuffer functions
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
mesa/drivers: use new swrast renderbuffer functions

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: build new s_renderbuffer.c file
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
mesa: build new s_renderbuffer.c file

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoswrast: remove core renderbuffer functions from s_renderbuffer.[ch]
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
swrast: remove core renderbuffer functions from s_renderbuffer.[ch]

We'll use the functions that live in main/
Plus, rename the remaining functions with "swrast_" prefix.

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoswrast: add s_renderbuffer.[ch], copied from main/renderbuffer.[ch]
Brian Paul [Tue, 6 Dec 2011 03:40:48 +0000 (20:40 -0700)]
swrast: add s_renderbuffer.[ch], copied from main/renderbuffer.[ch]

Copying these files is the first step in moving the software buffer
code from main/renderbuffer.c to swrast/s_renderbuffer.c

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: remove unused functions in depthstencil.c
Brian Paul [Sun, 4 Dec 2011 20:39:27 +0000 (13:39 -0700)]
mesa: remove unused functions in depthstencil.c

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: make some renderbuffer functions static
Brian Paul [Sun, 4 Dec 2011 20:34:04 +0000 (13:34 -0700)]
mesa: make some renderbuffer functions static

The functions to allocate software color, depth, accum, etc buffers aren't
called from anywhere else.

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoswrast: remove dead accum buffer context fields
Brian Paul [Sat, 3 Dec 2011 17:04:19 +0000 (10:04 -0700)]
swrast: remove dead accum buffer context fields

12 years agomesa: remove dead swrast and state tracker accum buffer code
Brian Paul [Sat, 3 Dec 2011 17:04:19 +0000 (10:04 -0700)]
mesa: remove dead swrast and state tracker accum buffer code

12 years agomesa: rewrite accum buffer support
Brian Paul [Sat, 3 Dec 2011 17:04:18 +0000 (10:04 -0700)]
mesa: rewrite accum buffer support

Implemented in terms of renderbuffer mapping/unmapping and format
packing/unpacking functions.

The swrast and state tracker code for implementing accumulation are
unused and will be removed in the next commit.

v2: don't use memcpy() in _mesa_clear_accum_buffer()
v3: don't allocate MAX_WIDTH arrays, be more careful with mapping flags

Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agomesa: new format_pack.c code
Brian Paul [Sat, 3 Dec 2011 17:04:18 +0000 (10:04 -0700)]
mesa: new format_pack.c code

This code packs colors, Z, stencil, etc. in the various mesa pixel
formats.  Will be used for things like glDrawPixels, glTexImage,
glAccum, etc.

12 years agomesa: remove the ctx->Driver.IsTextureResident() hook
Brian Paul [Sat, 3 Dec 2011 17:04:18 +0000 (10:04 -0700)]
mesa: remove the ctx->Driver.IsTextureResident() hook

No driver implemented this and we always returned "True" for residence
queries.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
12 years agomesa: remove TextureMemCpy driver hook
Brian Paul [Sat, 3 Dec 2011 17:04:18 +0000 (10:04 -0700)]
mesa: remove TextureMemCpy driver hook

There's probably no reason to use a special version of memcpy() anymore.

12 years agost/mesa: Use util_blit_pixels_writemask() for depth blits as well in st_copy_texsubim...
Henri Verbeet [Sat, 3 Dec 2011 12:10:57 +0000 (13:10 +0100)]
st/mesa: Use util_blit_pixels_writemask() for depth blits as well in st_copy_texsubimage().

This has no piglit regressions on r600g and softpipe.

Signed-off-by: Henri Verbeet <hverbeet@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
12 years agost/xa: Update xa_yuv_planar_blit semantics
Thomas Hellstrom [Wed, 7 Dec 2011 19:11:23 +0000 (20:11 +0100)]
st/xa: Update xa_yuv_planar_blit semantics

Change and document the interpretation of the color conversion matrix
in order to make the function more versatile and to simplify the
generated shader.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
12 years agoi965 gen6: Implement pass-through GS for transform feedback.
Paul Berry [Tue, 29 Nov 2011 22:51:03 +0000 (14:51 -0800)]
i965 gen6: Implement pass-through GS for transform feedback.

In Gen6, transform feedback is accomplished by having the geometry
shader send vertex data to the data port using "Streamed Vertex Buffer
Write" messages, while simultaneously passing vertices through to the
rest of the graphics pipeline (if rendering is enabled).

This patch adds a geometry shader program that simply passes vertices
through to the rest of the graphics pipeline.  The rest of transform
feedback functionality will be added in future patches.

To make the new geometry shader easier to test, I've added an
environment variable "INTEL_FORCE_GS".  If this environment variable
is enabled, then the pass-through geometry shader will always be used,
regardless of whether transform feedback is in effect.

On my Sandy Bridge laptop, I'm able to enable INTEL_FORCE_GS with no
Piglit regressions.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Eric Anholt <eric@anholt.net>
12 years agoi965: Clean up misleading defines for DWORD 2 of URB_WRITE header.
Paul Berry [Fri, 2 Dec 2011 22:38:52 +0000 (14:38 -0800)]
i965: Clean up misleading defines for DWORD 2 of URB_WRITE header.

R02_PRIM_END and R02_PRIM_START don't actually refer to bits in DWORD
2 of R0 (as the name, and comments in the code, would seem to
indicate).  Actually they refer to bits in DWORD 2 of the header for
URB_WRITE messages.

This patch renames the defines to reflect what they actually mean.  It
also addes a define URB_WRITE_PRIM_TYPE_SHIFT, which previously was
just hardcoded in .c files.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
12 years agoi965 gs: Clean up dodgy register re-use, at the cost of a few MOVs.
Paul Berry [Tue, 29 Nov 2011 22:54:02 +0000 (14:54 -0800)]
i965 gs: Clean up dodgy register re-use, at the cost of a few MOVs.

Prior to this patch, in the Gen4 and Gen5 GS, we used GRF 0 (called
"R0" in the code) as a staging area to prepare the message header for
the FF_SYNC and URB_WRITE messages.  This cleverly avoided an
unnecessary MOV operation (since the initial value of GRF 0 contains
data that needs to be included in the message header), but it made the
code confusing, since GRF 0 could no longer be relied upon to contain
its initial value once the GS started preparing its first message.
This patch avoids confusion by using a separate register ("header") as
the staging area, at the cost of one MOV instruction.

Worse yet, prior to this patch, the GS would completely overwrite the
contents of GRF 0 with the writeback data it received from a completed
FF_SYNC or URB_WRITE message.  It did this because DWORD 0 of the
writeback data contains the new URB handle, and that neds to be
included in DWORD 0 of the next URB_WRITE message header.  However,
that caused the rest of the message header to be corrupted either with
undefined data or zeros.  Astonishingly, this did not produce any
known failures (probably by dumb luck).  However, it seems really
dodgy--corrupting FFTID in particular seems likely to cause GPU hangs.
This patch avoids the corruption by storing the writeback data in a
temporary register and then copying just DWORD 0 to the header for the
next message.  This costs one extra MOV instruction per message sent,
except for the final message.

Also, this patch moves the logic for overriding DWORD 2 of the header
(which contains PrimType, PrimStart, PrimEnd, and some other data that
we don't care about yet).  This logic is now in the function
brw_gs_overwrite_header_dw2() rather than in brw_gs_emit_vue().  This
saves one MOV instruction in brw_gs_quads() and brw_gs_quad_strip(),
and paves the way for the Gen6 GS, which will need more complex logic
to override DWORD 2 of the header.

Finally, the function brw_gs_alloc_regs() contained a benign bug: it
neglected to increment the register counter when allocating space for
the "temp" register.  This turned out not to have any effect because
the temp register wasn't used on Gen4 and Gen5, the only hardware
models (so far) to require a GS program.  Now, all the registers
allocated by brw_gs_alloc_regs() are actually used, and properly
accounted for.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
12 years agoi965 gen6: Allocate URB space for GS
Paul Berry [Wed, 7 Dec 2011 17:56:42 +0000 (09:56 -0800)]
i965 gen6: Allocate URB space for GS

When the GS is not in use, the entire URB space is available for the
VS.  When the GS is in use, we split the URB space 50/50.

The 50/50 split is probably not optimal--we'll probably want tune this
for performance in a future patch.  For example, in most situations,
it's probably worth allocating more than 50% of the space to the VS,
since VS space is used for vertex caching.  But for now this is good
enough.

Based on previous work by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoi965: Set the maximum number of GS URB entries on Sandybridge.
Kenneth Graunke [Tue, 15 Nov 2011 03:13:27 +0000 (19:13 -0800)]
i965: Set the maximum number of GS URB entries on Sandybridge.

We never filled this in before because we didn't care.

I'm skeptical these are correct; my sources indicate that both the VS
and GS # of entries are 256 on both GT1 and GT2.

I'm also loathe to change it and break stuff.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
12 years agoi965: Only convert if/else to conditional adds prior to Gen6.
Paul Berry [Fri, 25 Nov 2011 05:41:07 +0000 (21:41 -0800)]
i965: Only convert if/else to conditional adds prior to Gen6.

Normally when outputting instructions in SPF (single program flow)
mode, we convert IF and ELSE instructions to conditional ADD
instructions applied to the IP register.  On platforms prior to Gen6,
flow control instructions cause an implied thread switch, so this is a
significant savings.

However, according to the SandyBridge PRM (Volume 4 part 2, p79):

   [Errata DevSNB{WA}] - When SPF is ON, IP may not be updated by
   non-flow control instructions.

So we have to disable this optimization on Gen6.

On later platforms, there is no significant benefit to converting flow
control instructions to ADDs, so for the sake of consistency, this
patch disables the optimization on later platforms too.

The reason we never noticed this problem before is that so far we
haven't needed to use SPF mode on Gen6.  However, later patches in
this series will introduce a Gen6 GS program which uses SPF mode.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
12 years agoi965 gs: Remove unnecessary mapping of key->primitive.
Paul Berry [Tue, 22 Nov 2011 18:30:36 +0000 (10:30 -0800)]
i965 gs: Remove unnecessary mapping of key->primitive.

Previously, GS generation code contained a lookup table that mapped
primitive types POLYGON, TRISTRIP, and TRIFAN to TRILIST, mapped
LINESTRIP to LINELIST, and left all other primitives unchanged.  This
was silly, because we never generate a GS program for those primitive
types anyhow.

This patch removes the unnecessary lookup table.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
12 years agomesa: Track changes to transform feedback state.
Paul Berry [Tue, 22 Nov 2011 19:53:46 +0000 (11:53 -0800)]
mesa: Track changes to transform feedback state.

This patch adds a new bit to the ctx->NewState bitfield,
_NEW_TRANSFORM_FEEDBACK, to track state changes that affect
ctx->TransformFeedback.  This bit can be used by driver back-ends to
avoid expensive recomputations when transform feedback state has not
been modified.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoglx: Fix indirect fallback when a non-Mesa GLX extension is present.
Aaron Plattner [Tue, 6 Dec 2011 18:20:30 +0000 (10:20 -0800)]
glx: Fix indirect fallback when a non-Mesa GLX extension is present.

When driCreateScreen calls driConvertConfigs to try to convert the
configs for swrast, it fails and returns NULL.  Instead of checking,
it just clobbers psc->base.configs.  Then, when the application asks
for the FBconfigs, there aren't any.

Instead, make the caller responsible for freeing the old modes lists
if both calls to driConvertConfigs succeed.

Without the second fix, glxinfo fails unless you run it with
LIBGL_ALWAYS_INDIRECT:

    $ glxinfo
    name of display: :0.0
    Error: couldn't find RGB GLX visual or fbconfig

    $ LIBGL_ALWAYS_INDIRECT=1 glxinfo
    name of display: :0.0
    display: :0  screen: 0
    direct rendering: No (LIBGL_ALWAYS_INDIRECT set)
    server glx vendor string: NVIDIA Corporation
    server glx version string: 1.4
    [...]

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Brian Paul <brianp@vmware.com>
12 years agoglsl: Fix samplerCubeShadow support in shader compiler
Anuj Phogat [Tue, 6 Dec 2011 19:11:03 +0000 (11:11 -0800)]
glsl: Fix samplerCubeShadow support in shader compiler

This patch fixes the samplerCubeShadow support in GLSL shader compiler.
shader compiler was picking the 'r' texture coordinate for shadow comparison
when the expected behaviour is to use 'q' texture coordinate in case of cube
shadow maps.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
12 years agoi965: Set Ivybridge's is_array SURFACE_STATE bit.
Kenneth Graunke [Wed, 7 Dec 2011 20:34:28 +0000 (12:34 -0800)]
i965: Set Ivybridge's is_array SURFACE_STATE bit.

Fixes piglit tests fbo-array, fbo-depth-array, fbo-generatemipmap-array,
and array-texture, as well as the array variants of my new textureSize
and texelFetch tests.

Not a candidate for 7.11 because EXT_texture_array wasn't supported.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agoi965: Return BRW_DEPTHBUFFER_D32_FLOAT as the null-depthbuffer format.
Kenneth Graunke [Wed, 7 Dec 2011 10:21:37 +0000 (02:21 -0800)]
i965: Return BRW_DEPTHBUFFER_D32_FLOAT as the null-depthbuffer format.

Fixes many crashes on Ivybridge due to upload_sf_state calling
brw_depthbuffer_format without an actual depth buffer.  This was a
recent regression on master.

+3992 piglits on Ivybridge.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
12 years agointel: Update comment about how depth/stencil miptrees are handled.
Eric Anholt [Wed, 30 Nov 2011 16:41:52 +0000 (08:41 -0800)]
intel: Update comment about how depth/stencil miptrees are handled.

This evolved over several commits, and I also wanted to document some
new information about how we handle formats.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
12 years agointel: Rely on miptree mapping for all renderbuffer maps.
Eric Anholt [Wed, 30 Nov 2011 16:31:53 +0000 (08:31 -0800)]
intel: Rely on miptree mapping for all renderbuffer maps.

Now that all RBs have miptrees, and miptree mapping covered these last
two code paths, consistently use them.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
12 years agointel: Add support for LLC-cached reads of X-tiled miptrees using a blit.
Eric Anholt [Wed, 30 Nov 2011 15:36:26 +0000 (07:36 -0800)]
intel: Add support for LLC-cached reads of X-tiled miptrees using a blit.

This mimics the MapRenderbuffer code, and should improve the
performance of glGetTexImage().

v2: Fix broken error handling.

12 years agointel: Handle MapRenderbuffer of fake packed depth/stencil using miptree maps.
Eric Anholt [Wed, 30 Nov 2011 15:18:42 +0000 (07:18 -0800)]
intel: Handle MapRenderbuffer of fake packed depth/stencil using miptree maps.

This gets the same performance win as the miptree maps did, and
removes a pile of code duplication.

12 years agointel: Track miptrees for fake packed depth/stencil renderbuffers.
Eric Anholt [Wed, 30 Nov 2011 16:27:53 +0000 (08:27 -0800)]
intel: Track miptrees for fake packed depth/stencil renderbuffers.

Right now the fake packed d/s RBs are creating two sub-renderbuffers
with their own storage, and the hardware setup and the mapping code
have been explicitly referencing them.  By setting miptrees on them,
we'll be able to make our renderbuffer code for fake packed
depth/stencil more consistent with all our other renderbuffers.

The interesting new behavior here is that there is now a mt with a
non-depthstencil format (X8Z24) that has a stencil_mt field
associated.  This looks like it should be safe, and we'll need to be
able to do this for floating point depth/stencil as well.

12 years agointel: Make the fake packed depth/stencil mappings use a cached temporary.
Eric Anholt [Wed, 30 Nov 2011 15:03:03 +0000 (07:03 -0800)]
intel: Make the fake packed depth/stencil mappings use a cached temporary.

Before, we had an uncached read of S8 to untile, then a RMW (so
uncached penalty) of the packed S8Z24 to store the value, then the
consumer would uncached read that once per pixel.  If data was written
to the map, we would then have to uncached read the written data back
out and do the scatter to the tiled S8 buffer (also uncached access
penalties, since WC couldn't actually combine).  So 3 or 5 uncached
accesses per pixel in the ROI (and we we were ignoring the ROI, so it
was the whole image).

Now we get an uncached read of S8 to untile, and an uncached read of
Z.  The consumer gets to do cached accesses.  Then if data was
written, we do streaming Z writes (WC success), and scattered S8
tiling writes (uncached penalty).  So 2 or 3 uncached accesses per
pixel in the ROI.

This should be a performance win, to the extent that anybody is doing
software accesses of packed depth/stencil buffers.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
12 years agointel: Make intel_region_map return void *.
Eric Anholt [Wed, 30 Nov 2011 14:47:27 +0000 (06:47 -0800)]
intel: Make intel_region_map return void *.

We don't gripe about void * arithmetic for our driver, and this
prevents silly casting when assigning the result of mapping to
non-byte types.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
12 years agointel: Move separate-stencil s8 mapping logic to intel_miptree_map.
Eric Anholt [Tue, 29 Nov 2011 00:08:46 +0000 (16:08 -0800)]
intel: Move separate-stencil s8 mapping logic to intel_miptree_map.

We're going to want to reuse this logic in mapping of fake packed
miptrees wrapping separate depth/stencil miptrees.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
12 years agointel: Move the gtt-particular texture mapping logic to a helper function.
Eric Anholt [Mon, 28 Nov 2011 23:49:01 +0000 (15:49 -0800)]
intel: Move the gtt-particular texture mapping logic to a helper function.

This code will be incrementally moving to a model like intel_fbo.c's
renderbuffer mapping with helper functions, as I move that code here.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
12 years agointel: Make mapping of texture slices track the region of interest.
Eric Anholt [Mon, 28 Nov 2011 19:02:59 +0000 (11:02 -0800)]
intel: Make mapping of texture slices track the region of interest.

This will be used for things like packed depth/stencil temporaries and
making LLC-cached temporary mappings using blits.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
12 years agointel: Move the teximage mapping logic to a miptree level/slice mapping.
Eric Anholt [Mon, 28 Nov 2011 19:17:11 +0000 (11:17 -0800)]
intel: Move the teximage mapping logic to a miptree level/slice mapping.

This will let us share teximage mapping logic with renderbuffer
mapping, which has an intel_mipmap_tree but not a gl_texture_image.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
12 years agointel: Only prefer separate stencil when we can do HiZ.
Eric Anholt [Wed, 30 Nov 2011 16:52:54 +0000 (08:52 -0800)]
intel: Only prefer separate stencil when we can do HiZ.

This required is_hiz_depth_format to start returning true on S8_Z24 as
well, since that's the format we have here.  The two previous callers
are only calling it on non-depthstencil formats.

This avoids us needing to have HiZ working on a new Z format
immediately upon exposing the format (particularly painful for
Z32_FLOAT_X24S8, which means all the fake packed depth/stencil paths).

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
12 years agost/dri: Use depth instead of bpp when communicating formats with the X server v3
Thomas Hellstrom [Tue, 6 Dec 2011 09:16:13 +0000 (10:16 +0100)]
st/dri: Use depth instead of bpp when communicating formats with the X server v3

Some hardware can't reinterpret the format of hardware buffers and thus
the X server needs to know the format when the buffer is created.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Michel Daenzer <michel@daenzer.net>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>