[Mesa-dev] [Bug 43682] New: SIGSEGV src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4560

2011-12-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43682

 Bug #: 43682
   Summary: SIGSEGV
src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4560
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: x86-64 (AMD64)
OS/Version: Linux (All)
Status: NEW
  Severity: critical
  Priority: medium
 Component: Mesa core
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: v...@vmware.com
CC: mar...@gmail.com


mesa: 06f217d80f3d1318da4974bf7b31ea7edcf5eb0b

Run piglit test fdo23670-depth_test on a Gallium driver.

$ ./bin/fdo23670-depth_test -auto
Segmentation fault (core dumped)

(gdb) bt
#0  0x7effa69ce1b7 in st_translate_program (ctx=0x25fdd10, procType=0,
ureg=0x280a730, program=0x2713570,
proginfo=0x2860380, numInputs=1, inputMapping=0x7fffa6d5f500,
inputSemanticName=0x7fffa6d5f680 \005\366զ,
inputSemanticIndex=0x7fffa6d5f6a0 , interpMode=0x7fffa6d5f580,
numOutputs=1, outputMapping=0x7fffa6d5f600,
outputSemanticName=0x7fffa6d5f6c0 \001\367զ\377\177,
outputSemanticIndex=0x7fffa6d5f6e0 ,
passthrough_edgeflags=0 '\000') at
src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4560
#1  0x7effa68edd53 in st_translate_fragment_program (st=0x2666b20,
stfp=0x2860380, key=0x7fffa6d5f780)
at src/mesa/state_tracker/st_program.c:653
#2  0x7effa68edf73 in st_get_fp_variant (st=0x2666b20, stfp=0x26e04d0,
key=0x7fffa6d5f780)
at src/mesa/state_tracker/st_program.c:728
#3  0x7effa69b757d in get_color_fp_variant (st=0x2666b20) at
src/mesa/state_tracker/st_cb_drawpixels.c:1008
#4  0x7effa69b779b in st_DrawPixels (ctx=0x25fdd10, x=0, y=0, width=1,
height=1, format=6408, type=5126,
unpack=0x260d5e0, pixels=0x669300) at
src/mesa/state_tracker/st_cb_drawpixels.c:1089
#5  0x7effa692046b in _mesa_DrawPixels (width=1, height=1, format=6408,
type=5126, pixels=0x669300)
at src/mesa/main/drawpix.c:131
#6  0x00429929 in piglit_display () at
piglit/tests/bugs/fdo23670-depth_test.c:67
#7  0x00429a29 in display () at piglit/tests/util/piglit-framework.c:56
#8  0x7effa62bd220 in fghRedrawWindow (window=0x2541ad0) at
freeglut_main.c:210
#9  fghcbDisplayWindow (window=0x2541ad0, enumerator=0x7fffa6d5f9b0) at
freeglut_main.c:227
#10 0x7effa62c0939 in fgEnumWindows (enumCallback=0x7effa62bd120
fghcbDisplayWindow, enumerator=0x7fffa6d5f9b0)
at freeglut_structure.c:394
#11 0x7effa62bd65a in fghDisplayAll () at freeglut_main.c:249
#12 glutMainLoopEvent () at freeglut_main.c:1450
#13 0x7effa62bdf0e in glutMainLoop () at freeglut_main.c:1498
#14 0x0042a14f in main (argc=1, argv=0x7fffa6d5fd08)
at piglit/tests/util/piglit-framework.c:294
(gdb) frame 0
#0  0x7effa69ce1b7 in st_translate_program (ctx=0x25fdd10, procType=0,
ureg=0x280a730, program=0x2713570,
proginfo=0x2860380, numInputs=1, inputMapping=0x7fffa6d5f500,
inputSemanticName=0x7fffa6d5f680 \005\366զ,
inputSemanticIndex=0x7fffa6d5f6a0 , interpMode=0x7fffa6d5f580,
numOutputs=1, outputMapping=0x7fffa6d5f600,
outputSemanticName=0x7fffa6d5f6c0 \001\367զ\377\177,
outputSemanticIndex=0x7fffa6d5f6e0 ,
passthrough_edgeflags=0 '\000') at
src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4560
4560  if (program-shader_program-FragDepthLayout !=
FRAG_DEPTH_LAYOUT_NONE) {
(gdb) print program-shader_program
$3 = (gl_shader_program *) 0x0


06f217d80f3d1318da4974bf7b31ea7edcf5eb0b is the first bad commit
commit 06f217d80f3d1318da4974bf7b31ea7edcf5eb0b
Author: Marek Olšák mar...@gmail.com
Date:   Fri Nov 18 15:45:03 2011 +0100

gallium: implement ARB_conservative_depth

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

:04 04 60cb0724736eca98d91fc0e3c0de339832a33416
e5e763680792788c93c6ebfdf11eac6527792617 M  src
bisect run success

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 43683] New: src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4575:st_translate_program: Assertion `0' failed.

2011-12-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43683

 Bug #: 43683
   Summary: src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4575:st_tra
nslate_program: Assertion `0' failed.
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: x86-64 (AMD64)
OS/Version: Linux (All)
Status: NEW
  Severity: critical
  Priority: medium
 Component: Mesa core
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: v...@vmware.com
CC: mar...@gmail.com


mesa: 06f217d80f3d1318da4974bf7b31ea7edcf5eb0b (master)

Run piglit test fbo-copypix on llvmpipe.

$ ./bin/fbo-copypix -auto
src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4575:st_translate_program: Assertion
`0' failed.
Trace/breakpoint trap (core dumped)


(gdb) bt
#0  0x7f4134f1b975 in _debug_assert_fail (expr=0x7f41356a7d8b 0,
file=0x7f41356a7ab8 src/mesa/state_tracker/st_glsl_to_tgsi.cpp,
line=4575,
function=0x7f41356a8b00 st_translate_program) at
src/gallium/auxiliary/util/u_debug.c:278
#1  0x7f4134e5f26a in st_translate_program (ctx=0x974d10, procType=0,
ureg=0xb503e0, program=0xac94c0,
proginfo=0xbd5240, numInputs=1, inputMapping=0x7fff83e79320,
inputSemanticName=0x7fff83e794a0 \005\224\347\203\377\177,
inputSemanticIndex=0x7fff83e794c0 ,
interpMode=0x7fff83e793a0, numOutputs=1, outputMapping=0x7fff83e79420,
outputSemanticName=0x7fff83e794e0 \001\225\347\203\n,
outputSemanticIndex=0x7fff83e79500 ,
passthrough_edgeflags=0 '\000') at
src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4575
#2  0x7f4134d7ed53 in st_translate_fragment_program (st=0x9ddb20,
stfp=0xbd5240, key=0x7fff83e795a0)
at src/mesa/state_tracker/st_program.c:653
#3  0x7f4134d7ef73 in st_get_fp_variant (st=0x9ddb20, stfp=0xa57220,
key=0x7fff83e795a0)
at src/mesa/state_tracker/st_program.c:728
#4  0x7f4134e4857d in get_color_fp_variant (st=0x9ddb20) at
src/mesa/state_tracker/st_cb_drawpixels.c:1008
#5  0x7f4134e4961d in st_CopyPixels (ctx=0x974d10, srcx=10, srcy=10,
width=20, height=20, dstx=10, dsty=40,
type=6144) at src/mesa/state_tracker/st_cb_drawpixels.c:1475
#6  0x7f4134db1a16 in _mesa_CopyPixels (srcx=10, srcy=10, width=20,
height=20, type=6144)
at src/mesa/main/drawpix.c:226
#7  0x00429ced in copy (srcX0=10, srcY0=10, srcX1=30, srcY1=30,
dstX0=10, dstY0=40, dstX1=30, dstY1=60)
at piglit/tests/fbo/fbo-copypix.c:129
#8  0x00429eb2 in run_test () at piglit/tests/fbo/fbo-copypix.c:172
#9  0x0042a04c in piglit_display () at
piglit/tests/fbo/fbo-copypix.c:203
#10 0x0042a70d in display () at piglit/tests/util/piglit-framework.c:56
#11 0x7f413474e220 in fghRedrawWindow (window=0x8b8ad0) at
freeglut_main.c:210
#12 fghcbDisplayWindow (window=0x8b8ad0, enumerator=0x7fff83e79900) at
freeglut_main.c:227
#13 0x7f4134751939 in fgEnumWindows (enumCallback=0x7f413474e120
fghcbDisplayWindow, enumerator=0x7fff83e79900)
at freeglut_structure.c:394
#14 0x7f413474e65a in fghDisplayAll () at freeglut_main.c:249
#15 glutMainLoopEvent () at freeglut_main.c:1450
#16 0x7f413474ef65 in glutMainLoop () at freeglut_main.c:1498
#17 0x0042ae33 in main (argc=1, argv=0x7fff83e79c58)
at piglit/tests/util/piglit-framework.c:294
(gdb) frame 1
#1  0x7f4134e5f26a in st_translate_program (ctx=0x974d10, procType=0,
ureg=0xb503e0, program=0xac94c0,
proginfo=0xbd5240, numInputs=1, inputMapping=0x7fff83e79320,
inputSemanticName=0x7fff83e794a0 \005\224\347\203\377\177,
inputSemanticIndex=0x7fff83e794c0 ,
interpMode=0x7fff83e793a0, numOutputs=1, outputMapping=0x7fff83e79420,
outputSemanticName=0x7fff83e794e0 \001\225\347\203\n,
outputSemanticIndex=0x7fff83e79500 ,
passthrough_edgeflags=0 '\000') at
src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4575
4575assert(0);
(gdb) print program-shader_program-FragDepthLayout
$1 = 32577


06f217d80f3d1318da4974bf7b31ea7edcf5eb0b is the first bad commit
commit 06f217d80f3d1318da4974bf7b31ea7edcf5eb0b
Author: Marek Olšák mar...@gmail.com
Date:   Fri Nov 18 15:45:03 2011 +0100

gallium: implement ARB_conservative_depth

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

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 43682] SIGSEGV src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4560

2011-12-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43682

--- Comment #1 from Jos van Wolput wol...@onsneteindhoven.nl 2011-12-10 
03:14:15 PST ---
mesa 06f217d80f3d1318da4974bf7b31ea7edcf5eb0b, gallium driver
breaks boinc-manager graphics: doesn't show graphics of starsphere
(einstein@home), restarting xsession instead.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] R600g LLVM shader backend

2011-12-10 Thread Stéphane Marchesin
On Fri, Dec 9, 2011 at 14:15, Tom Stellard tstel...@gmail.com wrote:
 Hi,

 I have just pushed a branch containing an LLVM shader backend for r600g to my
 personal git repo:

 http://cgit.freedesktop.org/~tstellar/mesa/ r600g-llvm-shader

 There are three main components to this branch:

 1. A TGSI-LLVM converter (commit ec9bb644cf7dde055c6c3ee5b8890a2d367337e5)

 The goal of this converter is to give all gallium drivers a convenient
 way to convert from TGSI to LLVM.  The interface is still evolving,
 and I'm interested in getting some feedback for it.

 2. Changes to gallivm so that code can be shared between it and
 the TGSI-LLVM converter.  These changes are attached, please review.

 3. An LLVM backend for r600g.


I can't help but notice the additional license restrictions in that
code -- is this something that could be sorted out?

Stéphane
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 43683] src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4575:st_translate_program: Assertion `0' failed.

2011-12-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43683

Dave Airlie airl...@freedesktop.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||DUPLICATE

--- Comment #1 from Dave Airlie airl...@freedesktop.org 2011-12-10 09:34:52 
PST ---


*** This bug has been marked as a duplicate of bug 43682 ***

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 43682] SIGSEGV src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4560

2011-12-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43682

--- Comment #2 from Dave Airlie airl...@freedesktop.org 2011-12-10 09:34:52 
PST ---
*** Bug 43683 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/3] egl: add EGL_NV_post_sub_buffer

2011-12-10 Thread Fredrik Höglund
Signed-off-by: Fredrik Höglund fred...@kde.org
---
 include/EGL/eglext.h  |9 +
 src/egl/main/eglapi.c |   24 
 src/egl/main/eglapi.h |8 
 src/egl/main/egldisplay.h |2 ++
 src/egl/main/eglmisc.c|2 ++
 src/egl/main/eglsurface.c |9 +
 src/egl/main/eglsurface.h |4 
 7 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
index 9484b83..d03a24d 100644
--- a/include/EGL/eglext.h
+++ b/include/EGL/eglext.h
@@ -144,6 +144,15 @@ typedef EGLImageKHR (EGLAPIENTRYP 
PFNEGLCREATEDRMIMAGEMESA) (EGLDisplay dpy, con
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESA) (EGLDisplay dpy, 
EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
 #endif
 
+#ifndef EGL_NV_post_sub_buffer
+#define EGL_NV_post_sub_buffer 1
+#define EGL_POST_SUB_BUFFER_SUPPORTED_NV   0x30BE
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV(EGLDisplay dpy, EGLSurface 
surface, EGLint x, EGLint y, EGLint width, EGLint height);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, 
EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
+#endif
+
 #ifndef EGL_WL_bind_wayland_display
 #define EGL_WL_bind_wayland_display 1
 
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 3cb1a5b..ff15476 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -951,6 +951,9 @@ eglGetProcAddress(const char *procname)
 #ifdef EGL_ANDROID_swap_rectangle
   { eglSetSwapRectangleANDROID, (_EGLProc) eglSetSwapRectangleANDROID },
 #endif
+#ifdef EGL_NV_post_sub_buffer
+  { eglPostSubBufferNV, (_EGLProc) eglPostSubBufferNV },
+#endif
   { NULL, NULL }
};
EGLint i;
@@ -1590,3 +1593,24 @@ eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface 
draw,
RETURN_EGL_EVAL(disp, ret);
 }
 #endif
+
+#ifdef EGL_NV_post_sub_buffer
+EGLBoolean EGLAPIENTRY
+eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface,
+   EGLint x, EGLint y, EGLint width, EGLint height)
+{
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+   _EGLSurface *surf = _eglLookupSurface(surface, disp);
+   _EGLDriver *drv;
+   EGLBoolean ret;
+
+   _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
+
+   if (!disp-Extensions.NV_post_sub_buffer)
+  RETURN_EGL_EVAL(disp, EGL_FALSE);
+
+   ret = drv-API.PostSubBufferNV(drv, disp, surf, x, y, width, height);
+
+   RETURN_EGL_EVAL(disp, ret);
+}
+#endif
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index 1e0aef6..f374273 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -135,6 +135,10 @@ typedef EGLBoolean (*UnbindWaylandDisplayWL_t)(_EGLDriver 
*drv, _EGLDisplay *dis
 typedef EGLBoolean (*SetSwapRectangleANDROID_t)(_EGLDriver *drv, _EGLDisplay 
*disp, _EGLSurface *draw, EGLint left, EGLint top, EGLint width, EGLint height);
 #endif
 
+#ifdef EGL_NV_post_sub_buffer
+typedef EGLBoolean (*PostSubBufferNV_t)(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surface, EGLint x, EGLint y, EGLint width, EGLint height);
+#endif
+
 /**
  * The API dispatcher jumps through these functions
  */
@@ -218,6 +222,10 @@ struct _egl_api
 #ifdef EGL_ANDROID_swap_rectangle
SetSwapRectangleANDROID_t SetSwapRectangleANDROID;
 #endif
+
+#ifdef EGL_NV_post_sub_buffer
+   PostSubBufferNV_t PostSubBufferNV;
+#endif
 };
 
 #endif /* EGLAPI_INCLUDED */
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 67a2e24..8f737df 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -112,6 +112,8 @@ struct _egl_extensions
 
EGLBoolean ANDROID_image_native_buffer;
EGLBoolean ANDROID_swap_rectangle;
+
+   EGLBoolean NV_post_sub_buffer;
 };
 
 
diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c
index ab48bc6..30cd04e 100644
--- a/src/egl/main/eglmisc.c
+++ b/src/egl/main/eglmisc.c
@@ -116,6 +116,8 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
 
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
_EGL_CHECK_EXTENSION(ANDROID_swap_rectangle);
+
+   _EGL_CHECK_EXTENSION(NV_post_sub_buffer);
 #undef _EGL_CHECK_EXTENSION
 }
 
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 3564ecd..92edff5 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -323,6 +323,10 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, 
EGLint type,
surf-VerticalResolution = EGL_UNKNOWN;
surf-AspectRatio = EGL_UNKNOWN;
 
+#ifdef EGL_NV_post_sub_buffer
+   surf-PostSubBufferSupportedNV = EGL_FALSE;
+#endif
+
/* the default swap interval is 1 */
_eglClampSwapInterval(surf, 1);
 
@@ -392,6 +396,11 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLSurface *surface,
case EGL_VG_COLORSPACE:
   *value = surface-VGColorspace;
   break;
+#ifdef EGL_NV_post_sub_buffer
+   case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
+  *value = 

[Mesa-dev] [PATCH 0/3] Add support for EGL_NV_post_sub_buffer

2011-12-10 Thread Fredrik Höglund
This patch series adds support for EGL_NV_post_sub_buffer.

This extension provides the same functionality as EGL_NOK_swap_region, with
the exception that it only supports a single rectangle. Unlike the latter,
however, it is registered with Khronos and the specification is available.

This probably makes it more likely to be used by EGL clients, so supporting
it seems worthwhile. Doing so is also trivial since it can use the
infrastructure already in place for EGL_NOK_swap_region.

Note that the changes to the EGL state tracker depend on the patches
I posted earlier that add support for EGL_NOK_swap_region.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/3] egl_dri2/x11: Add support for EGL_NV_post_sub_buffer

2011-12-10 Thread Fredrik Höglund
Signed-off-by: Fredrik Höglund fred...@kde.org
---
 src/egl/drivers/dri2/platform_x11.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index 8dd231a..5592fff 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -248,6 +248,10 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
EGLint type,
   free(reply);
}
 
+   if (dri2_dpy-dri2  type == EGL_WINDOW_BIT 
+   dri2_surf-base.RenderBuffer == EGL_BACK_BUFFER)
+  dri2_surf-base.PostSubBufferSupportedNV = EGL_TRUE;
+
return dri2_surf-base;
 
  cleanup_dri_drawable:
@@ -749,6 +753,15 @@ dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay 
*disp, _EGLSurface *draw,
 }
 
 static EGLBoolean
+dri2_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw,
+EGLint x, EGLint y, EGLint width, EGLint height)
+{
+   const EGLint rect[4] = { x, draw-Height - y - height, width, height };
+
+   return dri2_swap_buffers_region(drv, disp, draw, 1, rect);
+}
+
+static EGLBoolean
 dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
  EGLNativePixmapType target)
 {
@@ -971,6 +984,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
drv-API.CopyBuffers = dri2_copy_buffers;
drv-API.CreateImageKHR = dri2_x11_create_image_khr;
drv-API.SwapBuffersRegionNOK = dri2_swap_buffers_region;
+   drv-API.PostSubBufferNV = dri2_post_sub_buffer;
 
dri2_dpy = malloc(sizeof *dri2_dpy);
if (!dri2_dpy)
@@ -1041,6 +1055,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay 
*disp)
disp-Extensions.KHR_image_pixmap = EGL_TRUE;
disp-Extensions.NOK_swap_region = EGL_TRUE;
disp-Extensions.NOK_texture_from_pixmap = EGL_TRUE;
+   disp-Extensions.NV_post_sub_buffer = EGL_TRUE;
 
 #ifdef HAVE_WAYLAND_PLATFORM
disp-Extensions.WL_bind_wayland_display = EGL_TRUE;
-- 
1.7.7.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/3] st/egl: Add support for EGL_NV_post_sub_buffer

2011-12-10 Thread Fredrik Höglund
Signed-off-by: Fredrik Höglund fred...@kde.org
---
 src/gallium/state_trackers/egl/common/egl_g3d.c|6 -
 .../state_trackers/egl/common/egl_g3d_api.c|   24 
 2 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c 
b/src/gallium/state_trackers/egl/common/egl_g3d.c
index feebfaf..554c23c 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -606,10 +606,14 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy)
   dpy-Extensions.WL_bind_wayland_display = EGL_TRUE;
 #endif
 
+   if (gdpy-native-get_param(gdpy-native, NATIVE_PARAM_PRESENT_REGION)) {
 #ifdef EGL_NOK_swap_region
-   if (gdpy-native-get_param(gdpy-native, NATIVE_PARAM_PRESENT_REGION))
   dpy-Extensions.NOK_swap_region = EGL_TRUE;
 #endif
+#ifdef EGL_NV_post_sub_buffer
+  dpy-Extensions.NV_post_sub_buffer = EGL_TRUE;
+#endif
+   }
 
if (egl_g3d_add_configs(drv, dpy, 1) == 1) {
   _eglError(EGL_NOT_INITIALIZED, eglInitialize(unable to add configs));
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c 
b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
index e8f2abc..7fa31bc 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
@@ -296,6 +296,14 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLConfig *conf,
gconf-stvis.buffer_mask  ST_ATTACHMENT_FRONT_LEFT_MASK)
   gsurf-stvis.render_buffer = ST_ATTACHMENT_FRONT_LEFT;
 
+#ifdef EGL_NV_post_sub_buffer
+   if (dpy-Extensions.NV_post_sub_buffer) {
+  if (gsurf-base.Type == EGL_WINDOW_BIT 
+  gsurf-base.RenderBuffer == EGL_BACK_BUFFER)
+ gsurf-base.PostSubBufferSupportedNV = EGL_TRUE;
+   }
+#endif
+
gsurf-stfbi = egl_g3d_create_st_framebuffer(gsurf-base);
if (!gsurf-stfbi) {
   nsurf-destroy(nsurf);
@@ -602,6 +610,18 @@ egl_g3d_swap_buffers_region(_EGLDriver *drv, _EGLDisplay 
*dpy, _EGLSurface *surf
 }
 #endif /* EGL_NOK_swap_region */
 
+#ifdef EGL_NV_post_sub_buffer
+static EGLBoolean
+egl_g3d_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+EGLint x, EGLint y, EGLint width, EGLint height)
+{
+   /* Note: y=0=bottom */
+   const EGLint rect[4] = { x, surf-Height - y - height, width, height };
+
+   return swap_buffers(drv, dpy, surf, 1, rect, EGL_TRUE);
+}
+#endif /* EGL_NV_post_sub_buffer */
+
 static EGLBoolean
 egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
  EGLNativePixmapType target)
@@ -894,4 +914,8 @@ egl_g3d_init_driver_api(_EGLDriver *drv)
 #ifdef EGL_NOK_swap_region
drv-API.SwapBuffersRegionNOK = egl_g3d_swap_buffers_region;
 #endif
+
+#ifdef EGL_NV_post_sub_buffer
+   drv-API.PostSubBufferNV = egl_g3d_post_sub_buffer;
+#endif
 }
-- 
1.7.7.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] glsl_to_tgsi: make sure copied instructions don't lose texture target.

2011-12-10 Thread Dave Airlie
From: Dave Airlie airl...@redhat.com

The piglit draw-pixel-with-texture was asserting in the glsl-tgsi code,
due to 0 texture target, this makes sure the texture target is copied over
correctly when we copy instructions around.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 6cc655d..68eaddc 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3786,6 +3786,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
 * new visitor. */
foreach_iter(exec_list_iterator, iter, original-instructions) {
   glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+  glsl_to_tgsi_instruction *newinst;
   st_src_reg src_regs[3];
 
   if (inst-dst.file == PROGRAM_OUTPUT)
@@ -3803,7 +3804,8 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
 prog-InputsRead |= BITFIELD64_BIT(src_regs[i].index);
   }
 
-  v-emit(NULL, inst-op, inst-dst, src_regs[0], src_regs[1], 
src_regs[2]);
+  newinst = v-emit(NULL, inst-op, inst-dst, src_regs[0], src_regs[1], 
src_regs[2]);
+  newinst-tex_target = inst-tex_target;
}
 
/* Make modifications to fragment program info. */
-- 
1.7.7.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: use a double in _mesa_pack_float_z_row() for Z32

2011-12-10 Thread Brian Paul
Otherwise, 1.0 was converted to zero instead of 0x.
---
 src/mesa/main/format_pack.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
index ba23bab..27482d8 100644
--- a/src/mesa/main/format_pack.c
+++ b/src/mesa/main/format_pack.c
@@ -2318,7 +2318,7 @@ _mesa_pack_float_z_row(gl_format format, GLuint n,
case MESA_FORMAT_Z32:
   {
  GLuint *d = ((GLuint *) dst);
- const GLfloat scale = (GLfloat) 0x;
+ const GLdouble scale = (GLdouble) 0x;
  GLuint i;
  for (i = 0; i  n; i++) {
 d[i] = (GLuint) (src[i] * scale);
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] swrast: add missing state validation calls for Blit, Clear

2011-12-10 Thread Brian Paul
---
 src/mesa/swrast/s_blit.c  |3 +++
 src/mesa/swrast/s_clear.c |3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c
index f094be8..2817ec1 100644
--- a/src/mesa/swrast/s_blit.c
+++ b/src/mesa/swrast/s_blit.c
@@ -573,6 +573,9 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
   return;
}
 
+   if (SWRAST_CONTEXT(ctx)-NewState)
+  _swrast_validate_derived(ctx);
+
swrast_render_start(ctx);
 
if (srcX1 - srcX0 == dstX1 - dstX0 
diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c
index 615747d..851f6d1 100644
--- a/src/mesa/swrast/s_clear.c
+++ b/src/mesa/swrast/s_clear.c
@@ -213,6 +213,9 @@ _swrast_Clear(struct gl_context *ctx, GLbitfield buffers)
if (!_mesa_check_conditional_render(ctx))
   return; /* don't clear */
 
+   if (SWRAST_CONTEXT(ctx)-NewState)
+  _swrast_validate_derived(ctx);
+
swrast_render_start(ctx);
 
/* do software clearing here */
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 01/13] st/mesa: stop using _DepthBuffer, _StencilBuffer fields

2011-12-10 Thread Brian Paul
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.
---
 src/mesa/state_tracker/st_cb_drawpixels.c |   16 +---
 src/mesa/state_tracker/st_cb_texture.c|5 +
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index 912241b..65b4445 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1182,12 +1182,9 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, 
GLint srcy,
   return;
}
 
-   /* Get the dest renderbuffer.  If there's a wrapper, use the
-* underlying renderbuffer.
-*/
-   rbDraw = st_renderbuffer(ctx-DrawBuffer-_StencilBuffer);
-   if (rbDraw-Base.Wrapped)
-  rbDraw = st_renderbuffer(rbDraw-Base.Wrapped);
+   /* Get the dest renderbuffer */
+   rbDraw = st_renderbuffer(ctx-DrawBuffer-
+Attachment[BUFFER_STENCIL].Renderbuffer);
 
/* this will do stencil pixel transfer ops */
_mesa_readpixels(ctx, srcx, srcy, width, height,
@@ -1484,7 +1481,8 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint 
srcy,
}
else {
   assert(type == GL_DEPTH);
-  rbRead = st_renderbuffer(ctx-ReadBuffer-_DepthBuffer);
+  rbRead = st_renderbuffer(ctx-ReadBuffer-
+   Attachment[BUFFER_DEPTH].Renderbuffer);
   color = ctx-Current.Attrib[VERT_ATTRIB_COLOR0];
 
   fpv = get_depth_stencil_fp_variant(st, GL_TRUE, GL_FALSE);
@@ -1496,10 +1494,6 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint 
srcy,
/* update fragment program constants */
st_upload_constants(st, fpv-parameters, PIPE_SHADER_FRAGMENT);
 
-
-   if (rbRead-Base.Wrapped)
-  rbRead = st_renderbuffer(rbRead-Base.Wrapped);
-
sample_count = rbRead-texture-nr_samples;
/* I believe this would be legal, presumably would need to do a resolve
   for color, and for depth/stencil spec says to just use one of the
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 52f654d..289ad51 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1385,10 +1385,7 @@ st_copy_texsubimage(struct gl_context *ctx,
/* determine if copying depth or color data */
if (texBaseFormat == GL_DEPTH_COMPONENT ||
texBaseFormat == GL_DEPTH_STENCIL) {
-  strb = st_renderbuffer(fb-_DepthBuffer);
-  if (strb-Base.Wrapped) {
- strb = st_renderbuffer(strb-Base.Wrapped);
-  }
+  strb = st_renderbuffer(fb-Attachment[BUFFER_DEPTH].Renderbuffer);
}
else {
   /* texBaseFormat == GL_RGB, GL_RGBA, GL_ALPHA, etc */
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 02/13] mesa: stop using _Depth, _StencilBuffer fields in _mesa_BlitFramebufferEXT()

2011-12-10 Thread Brian Paul
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.
---
 src/mesa/main/fbobject.c |   14 --
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 9111caa..611a6d0 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2669,8 +2669,10 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
}
 
if (mask  GL_STENCIL_BUFFER_BIT) {
-  struct gl_renderbuffer *readRb = readFb-_StencilBuffer;
-  struct gl_renderbuffer *drawRb = drawFb-_StencilBuffer;
+  struct gl_renderbuffer *readRb =
+ readFb-Attachment[BUFFER_STENCIL].Renderbuffer;
+  struct gl_renderbuffer *drawRb =
+ drawFb-Attachment[BUFFER_STENCIL].Renderbuffer;
 
   /* From the EXT_framebuffer_object spec:
*
@@ -2679,7 +2681,6 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
* ignored.
*/
   if ((readRb == NULL) || (drawRb == NULL)) {
-readRb = drawRb = NULL;
 mask = ~GL_STENCIL_BUFFER_BIT;
   }
   else if (_mesa_get_format_bits(readRb-Format, GL_STENCIL_BITS) !=
@@ -2691,8 +2692,10 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
}
 
if (mask  GL_DEPTH_BUFFER_BIT) {
-  struct gl_renderbuffer *readRb = readFb-_DepthBuffer;
-  struct gl_renderbuffer *drawRb = drawFb-_DepthBuffer;
+  struct gl_renderbuffer *readRb =
+ readFb-Attachment[BUFFER_DEPTH].Renderbuffer;
+  struct gl_renderbuffer *drawRb =
+ drawFb-Attachment[BUFFER_DEPTH].Renderbuffer;
 
   /* From the EXT_framebuffer_object spec:
*
@@ -2701,7 +2704,6 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
* ignored.
*/
   if ((readRb == NULL) || (drawRb == NULL)) {
-readRb = drawRb = NULL;
 mask = ~GL_DEPTH_BUFFER_BIT;
   }
   else if (_mesa_get_format_bits(readRb-Format, GL_DEPTH_BITS) !=
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 03/13] nouveau: stop using _DepthBuffer, _StencilBuffer fields

2011-12-10 Thread Brian Paul
---
 src/mesa/drivers/dri/nouveau/nouveau_span.c  |4 ++--
 src/mesa/drivers/dri/nouveau/nv04_state_fb.c |4 ++--
 src/mesa/drivers/dri/nouveau/nv10_context.c  |9 +
 src/mesa/drivers/dri/nouveau/nv10_state_fb.c |4 ++--
 src/mesa/drivers/dri/nouveau/nv20_context.c  |2 +-
 src/mesa/drivers/dri/nouveau/nv20_state_fb.c |4 ++--
 6 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.c 
b/src/mesa/drivers/dri/nouveau/nouveau_span.c
index 761cc76..c02682b 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_span.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_span.c
@@ -152,8 +152,8 @@ framebuffer_map_unmap(struct gl_framebuffer *fb, GLboolean 
map)
 
renderbuffer_map_unmap(fb-_ColorReadBuffer, map);
 
-   if (fb-_DepthBuffer)
-   renderbuffer_map_unmap(fb-_DepthBuffer-Wrapped, map);
+   if (fb-Attachment[BUFFER_DEPTH].Renderbuffer)
+   
renderbuffer_map_unmap(fb-Attachment[BUFFER_DEPTH].Renderbuffer, map);
 }
 
 static void
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_fb.c 
b/src/mesa/drivers/dri/nouveau/nv04_state_fb.c
index 854571d..cc591a3 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_fb.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_fb.c
@@ -76,9 +76,9 @@ nv04_emit_framebuffer(struct gl_context *ctx, int emit)
}
 
/* depth/stencil */
-   if (fb-_DepthBuffer) {
+   if (fb-Attachment[BUFFER_DEPTH].Renderbuffer) {
s = to_nouveau_renderbuffer(
-   fb-_DepthBuffer-Wrapped)-surface;
+   fb-Attachment[BUFFER_DEPTH].Renderbuffer)-surface;
 
zeta_pitch = s-pitch;
 
diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c 
b/src/mesa/drivers/dri/nouveau/nv10_context.c
index c4dc1c5..0b0d549 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_context.c
@@ -61,10 +61,11 @@ nv10_use_viewport_zclear(struct gl_context *ctx)
 {
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct gl_framebuffer *fb = ctx-DrawBuffer;
+   struct gl_renderbuffer *depthRb = 
fb-Attachment[BUFFER_DEPTH].Renderbuffer;
 
return context_chipset(ctx)  0x17 
-   !nctx-hierz.clear_blocked  fb-_DepthBuffer 
-   (_mesa_get_format_bits(fb-_DepthBuffer-Format,
+   !nctx-hierz.clear_blocked  depthRb 
+   (_mesa_get_format_bits(depthRb-Format,
   GL_DEPTH_BITS) = 24);
 }
 
@@ -97,7 +98,7 @@ nv10_zclear(struct gl_context *ctx, GLbitfield *buffers)
struct gl_framebuffer *fb = ctx-DrawBuffer;
struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb);
struct nouveau_surface *s = to_nouveau_renderbuffer(
-   fb-_DepthBuffer-Wrapped)-surface;
+   fb-Attachment[BUFFER_DEPTH].Renderbuffer)-surface;
 
if (nv10_use_viewport_zclear(ctx)) {
int x, y, w, h;
@@ -148,7 +149,7 @@ nv17_zclear(struct gl_context *ctx, GLbitfield *buffers)
struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(
ctx-DrawBuffer);
struct nouveau_surface *s = to_nouveau_renderbuffer(
-   nfb-base._DepthBuffer-Wrapped)-surface;
+   nfb-base.Attachment[BUFFER_DEPTH].Renderbuffer)-surface;
 
/* Clear the hierarchical depth buffer */
BEGIN_RING(chan, celsius, NV17_3D_HIERZ_FILL_VALUE, 1);
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c 
b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c
index 0505547..a590bcd 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c
@@ -125,9 +125,9 @@ nv10_emit_framebuffer(struct gl_context *ctx, int emit)
}
 
/* depth/stencil */
-   if (fb-_DepthBuffer) {
+   if (fb-Attachment[BUFFER_DEPTH].Renderbuffer) {
s = to_nouveau_renderbuffer(
-   fb-_DepthBuffer-Wrapped)-surface;
+   fb-Attachment[BUFFER_DEPTH].Renderbuffer)-surface;
 
rt_format |= get_rt_format(s-format);
zeta_pitch = s-pitch;
diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c 
b/src/mesa/drivers/dri/nouveau/nv20_context.c
index 2a883e3..83091fe 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_context.c
@@ -66,7 +66,7 @@ nv20_clear(struct gl_context *ctx, GLbitfield buffers)
 
if (buffers  (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) {
struct nouveau_surface *s = to_nouveau_renderbuffer(
-   fb-_DepthBuffer-Wrapped)-surface;
+   fb-Attachment[BUFFER_DEPTH].Renderbuffer)-surface;
 
if (buffers  BUFFER_BIT_DEPTH  ctx-Depth.Mask)
clear |= NV20_3D_CLEAR_BUFFERS_DEPTH;
diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_fb.c 

[Mesa-dev] [PATCH 04/13] radeon: stop using _DepthBuffer, _StencilBuffer fields

2011-12-10 Thread Brian Paul
---
 src/mesa/drivers/dri/radeon/radeon_common.c   |8 
 src/mesa/drivers/dri/radeon/radeon_tex_copy.c |9 -
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c 
b/src/mesa/drivers/dri/radeon/radeon_common.c
index 894a01f..bb9cb2a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -313,8 +313,8 @@ void radeon_draw_buffer(struct gl_context *ctx, struct 
gl_framebuffer *fb)
radeon-vtbl.fallback(ctx, RADEON_FALLBACK_DRAW_BUFFER, 
GL_FALSE);
 
 
-   if (fb-_DepthBuffer  fb-_DepthBuffer-Wrapped) {
-   rrbDepth = radeon_renderbuffer(fb-_DepthBuffer-Wrapped);
+   if (fb-Attachment[BUFFER_DEPTH].Renderbuffer) {
+   rrbDepth = 
radeon_renderbuffer(fb-Attachment[BUFFER_DEPTH].Renderbuffer);
if (rrbDepth  rrbDepth-bo) {
radeon-vtbl.fallback(ctx, 
RADEON_FALLBACK_DEPTH_BUFFER, GL_FALSE);
} else {
@@ -325,8 +325,8 @@ void radeon_draw_buffer(struct gl_context *ctx, struct 
gl_framebuffer *fb)
rrbDepth = NULL;
}
 
-   if (fb-_StencilBuffer  fb-_StencilBuffer-Wrapped) {
-   rrbStencil = radeon_renderbuffer(fb-_StencilBuffer-Wrapped);
+   if (fb-Attachment[BUFFER_STENCIL].Renderbuffer) {
+   rrbStencil = 
radeon_renderbuffer(fb-Attachment[BUFFER_STENCIL].Renderbuffer);
if (rrbStencil  rrbStencil-bo) {
radeon-vtbl.fallback(ctx, 
RADEON_FALLBACK_STENCIL_BUFFER, GL_FALSE);
/* need to re-compute stencil hw state */
diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c 
b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
index ca0ac16..76ca8e6 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
@@ -58,13 +58,12 @@ do_copy_texsubimage(struct gl_context *ctx,
 }
 
 if (_mesa_get_format_bits(timg-base.Base.TexFormat, GL_DEPTH_BITS)  0) {
-if (ctx-ReadBuffer-_DepthBuffer  
ctx-ReadBuffer-_DepthBuffer-Wrapped) {
-rrb = radeon_renderbuffer(ctx-ReadBuffer-_DepthBuffer-Wrapped);
-} else {
-rrb = radeon_renderbuffer(ctx-ReadBuffer-_DepthBuffer);
-}
+/* copying a depth values */
+rrb = 
radeon_renderbuffer(ctx-ReadBuffer-Attachment[BUFFER_DEPTH].Renderbuffer);
+assert(rrb);
 flip_y = ctx-ReadBuffer-Attachment[BUFFER_DEPTH].Type == GL_NONE;
 } else {
+/* copying color */
 rrb = radeon_renderbuffer(ctx-ReadBuffer-_ColorReadBuffer);
 flip_y = ctx-ReadBuffer-Attachment[BUFFER_COLOR0].Type == GL_NONE;
 }
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 05/13] mesa: move update_depth/stencil_buffer() functions

2011-12-10 Thread Brian Paul
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.
---
 src/mesa/main/depthstencil.c |   90 ++
 src/mesa/main/depthstencil.h |   17 ++--
 src/mesa/main/framebuffer.c  |   78 +---
 3 files changed, 89 insertions(+), 96 deletions(-)

diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
index af5c12f..18f2705 100644
--- a/src/mesa/main/depthstencil.c
+++ b/src/mesa/main/depthstencil.c
@@ -349,9 +349,9 @@ put_mono_values_z24(struct gl_context *ctx, struct 
gl_renderbuffer *z24rb,
  * a depth renderbuffer.
  * \return new depth renderbuffer
  */
-struct gl_renderbuffer *
-_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
-   struct gl_renderbuffer *dsrb)
+static struct gl_renderbuffer *
+new_z24_renderbuffer_wrapper(struct gl_context *ctx,
+ struct gl_renderbuffer *dsrb)
 {
struct gl_renderbuffer *z24rb;
 
@@ -563,9 +563,9 @@ put_mono_values_z32f(struct gl_context *ctx, struct 
gl_renderbuffer *z32frb,
  * a depth renderbuffer.
  * \return new depth renderbuffer
  */
-struct gl_renderbuffer *
-_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
-struct gl_renderbuffer *dsrb)
+static struct gl_renderbuffer *
+new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
+  struct gl_renderbuffer *dsrb)
 {
struct gl_renderbuffer *z32frb;
 
@@ -915,8 +915,8 @@ put_mono_values_s8(struct gl_context *ctx, struct 
gl_renderbuffer *s8rb, GLuint
  * a stencil renderbuffer.
  * \return new stencil renderbuffer
  */
-struct gl_renderbuffer *
-_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct 
gl_renderbuffer *dsrb)
+static struct gl_renderbuffer *
+new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer 
*dsrb)
 {
struct gl_renderbuffer *s8rb;
 
@@ -957,3 +957,77 @@ _mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, 
struct gl_renderbuffer
 
return s8rb;
 }
+
+
+/**
+ * Update the framebuffer's _DepthBuffer field using the renderbuffer
+ * found at the given attachment index.
+ *
+ * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
+ * create and install a depth wrapper/adaptor.
+ *
+ * \param fb  the framebuffer whose _DepthBuffer field to update
+ */
+void
+_mesa_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+   struct gl_renderbuffer *depthRb =
+  fb-Attachment[BUFFER_DEPTH].Renderbuffer;
+
+   if (depthRb  _mesa_is_format_packed_depth_stencil(depthRb-Format)) {
+  /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
+  if (!fb-_DepthBuffer
+  || fb-_DepthBuffer-Wrapped != depthRb
+  || _mesa_get_format_base_format(fb-_DepthBuffer-Format) != 
GL_DEPTH_COMPONENT) {
+ /* need to update wrapper */
+ struct gl_renderbuffer *wrapper;
+
+ if (depthRb-Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+wrapper = new_z32f_renderbuffer_wrapper(ctx, depthRb);
+ }
+ else {
+wrapper = new_z24_renderbuffer_wrapper(ctx, depthRb);
+ }
+ _mesa_reference_renderbuffer(fb-_DepthBuffer, wrapper);
+ ASSERT(fb-_DepthBuffer-Wrapped == depthRb);
+  }
+   }
+   else {
+  /* depthRb may be null */
+  _mesa_reference_renderbuffer(fb-_DepthBuffer, depthRb);
+   }
+}
+
+
+/**
+ * Update the framebuffer's _StencilBuffer field using the renderbuffer
+ * found at the given attachment index.
+ *
+ * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
+ * create and install a stencil wrapper/adaptor.
+ *
+ * \param fb  the framebuffer whose _StencilBuffer field to update
+ */
+void
+_mesa_update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+   struct gl_renderbuffer *stencilRb =
+  fb-Attachment[BUFFER_STENCIL].Renderbuffer;
+
+   if (stencilRb  _mesa_is_format_packed_depth_stencil(stencilRb-Format)) {
+  /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */
+  if (!fb-_StencilBuffer
+  || fb-_StencilBuffer-Wrapped != stencilRb
+  || _mesa_get_format_base_format(fb-_StencilBuffer-Format) != 
GL_STENCIL_INDEX) {
+ /* need to update wrapper */
+ struct gl_renderbuffer *wrapper
+= new_s8_renderbuffer_wrapper(ctx, stencilRb);
+ _mesa_reference_renderbuffer(fb-_StencilBuffer, wrapper);
+ ASSERT(fb-_StencilBuffer-Wrapped == stencilRb);
+  }
+   }
+   else {
+  /* stencilRb may be null */
+  _mesa_reference_renderbuffer(fb-_StencilBuffer, stencilRb);
+   }
+}
diff --git a/src/mesa/main/depthstencil.h b/src/mesa/main/depthstencil.h
index 

[Mesa-dev] [PATCH 06/13] swrast: add new s_depthstencil.[ch] files

2011-12-10 Thread Brian Paul
These files are copies of main/depthstencil.[ch] with s/mesa/swrast/.
The main/depthstencil.[ch] will go away soon.
---
 src/mesa/swrast/s_depthstencil.c | 1033 ++
 src/mesa/swrast/s_depthstencil.h |   39 ++
 2 files changed, 1072 insertions(+), 0 deletions(-)
 create mode 100644 src/mesa/swrast/s_depthstencil.c
 create mode 100644 src/mesa/swrast/s_depthstencil.h

diff --git a/src/mesa/swrast/s_depthstencil.c b/src/mesa/swrast/s_depthstencil.c
new file mode 100644
index 000..9799f48
--- /dev/null
+++ b/src/mesa/swrast/s_depthstencil.c
@@ -0,0 +1,1033 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  6.5
+ *
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include main/glheader.h
+#include main/imports.h
+#include main/context.h
+#include main/formats.h
+#include main/mtypes.h
+#include main/renderbuffer.h
+#include swrast/s_depthstencil.h
+
+
+/**
+ * Adaptor/wrappers for GL_DEPTH_STENCIL renderbuffers.
+ *
+ * The problem with a GL_DEPTH_STENCIL renderbuffer is that sometimes we
+ * want to treat it as a stencil buffer, other times we want to treat it
+ * as a depth/z buffer and still other times when we want to treat it as
+ * a combined Z+stencil buffer!  That implies we need three different sets
+ * of Get/Put functions.
+ *
+ * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and
+ * stencil adaptors, each with the right kind of depth/stencil Get/Put 
functions.
+ */
+
+
+static void *
+nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, 
GLint y)
+{
+   (void) ctx;
+   (void) rb;
+   (void) x;
+   (void) y;
+   return NULL;
+}
+
+
+/**
+ * Delete a depth or stencil wrapper renderbuffer.
+ */
+static void
+delete_wrapper(struct gl_renderbuffer *rb)
+{
+   ASSERT(rb-Format == MESA_FORMAT_S8 ||
+  rb-Format == MESA_FORMAT_X8_Z24 ||
+  rb-Format == MESA_FORMAT_Z32_FLOAT);
+   _mesa_reference_renderbuffer(rb-Wrapped, NULL);
+   free(rb);
+}
+
+
+/**
+ * Realloc storage for wrapper.
+ */
+static GLboolean
+alloc_wrapper_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
+  GLenum internalFormat, GLuint width, GLuint height)
+{
+   /* just pass this on to the wrapped renderbuffer */
+   struct gl_renderbuffer *dsrb = rb-Wrapped;
+   GLboolean retVal;
+
+   (void) internalFormat;
+
+   ASSERT(dsrb-Format == MESA_FORMAT_Z24_S8 ||
+  dsrb-Format == MESA_FORMAT_Z24_X8 ||
+  dsrb-Format == MESA_FORMAT_S8_Z24 ||
+  dsrb-Format == MESA_FORMAT_X8_Z24);
+
+   retVal = dsrb-AllocStorage(ctx, dsrb, dsrb-InternalFormat, width, height);
+   if (retVal) {
+  rb-Width = width;
+  rb-Height = height;
+  rb-RowStride = dsrb-RowStride;
+   }
+   return retVal;
+}
+
+
+
+
+/*==
+ * Depth wrapper around depth/stencil renderbuffer
+ */
+
+static void
+get_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint 
count,
+GLint x, GLint y, void *values)
+{
+   struct gl_renderbuffer *dsrb = z24rb-Wrapped;
+   GLuint temp[MAX_WIDTH], i;
+   GLuint *dst = (GLuint *) values;
+   const GLuint *src = (const GLuint *) dsrb-GetPointer(ctx, dsrb, x, y);
+   ASSERT(z24rb-DataType == GL_UNSIGNED_INT);
+   ASSERT(dsrb-DataType == GL_UNSIGNED_INT_24_8_EXT);
+   if (!src) {
+  dsrb-GetRow(ctx, dsrb, count, x, y, temp);
+  src = temp;
+   }
+   if (dsrb-Format == MESA_FORMAT_Z24_S8) {
+  for (i = 0; i  count; i++) {
+ dst[i] = src[i]  8;
+  }
+   }
+   else {
+  assert(dsrb-Format == MESA_FORMAT_S8_Z24);
+  for (i = 0; i  count; i++) {
+ dst[i] = src[i]  0xff;
+  }
+   }
+}
+
+static void
+get_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint 
count,
+   const GLint x[], const GLint y[], void *values)
+{
+   struct gl_renderbuffer *dsrb 

[Mesa-dev] [PATCH 07/13] mesa: build swrast/s_depthstencil.c

2011-12-10 Thread Brian Paul
---
 src/mesa/SConscript  |1 +
 src/mesa/sources.mak |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index da4d9b1..4093e3f 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -162,6 +162,7 @@ swrast_sources = [
 'swrast/s_copypix.c',
 'swrast/s_context.c',
 'swrast/s_depth.c',
+'swrast/s_depthstencil.c',
 'swrast/s_drawpix.c',
 'swrast/s_feedback.c',
 'swrast/s_fog.c',
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index a3ce855..44c5c75 100644
--- a/src/mesa/sources.mak
+++ b/src/mesa/sources.mak
@@ -134,6 +134,7 @@ SWRAST_SOURCES = \
swrast/s_copypix.c \
swrast/s_context.c \
swrast/s_depth.c \
+   swrast/s_depthstencil.c \
swrast/s_drawpix.c \
swrast/s_feedback.c \
swrast/s_fog.c \
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 08/13] swrast: update depth/stencil wrapper sizes

2011-12-10 Thread Brian Paul
---
 src/mesa/swrast/s_depthstencil.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/swrast/s_depthstencil.c b/src/mesa/swrast/s_depthstencil.c
index 9799f48..dc768e2 100644
--- a/src/mesa/swrast/s_depthstencil.c
+++ b/src/mesa/swrast/s_depthstencil.c
@@ -989,8 +989,10 @@ _swrast_update_depth_buffer(struct gl_context *ctx, struct 
gl_framebuffer *fb)
 wrapper = new_z24_renderbuffer_wrapper(ctx, depthRb);
  }
  _mesa_reference_renderbuffer(fb-_DepthBuffer, wrapper);
- ASSERT(fb-_DepthBuffer-Wrapped == depthRb);
   }
+  ASSERT(fb-_DepthBuffer-Wrapped == depthRb);
+  fb-_DepthBuffer-Width = depthRb-Width;
+  fb-_DepthBuffer-Height = depthRb-Height;
}
else {
   /* depthRb may be null */
@@ -1023,8 +1025,10 @@ _swrast_update_stencil_buffer(struct gl_context *ctx, 
struct gl_framebuffer *fb)
  struct gl_renderbuffer *wrapper
 = new_s8_renderbuffer_wrapper(ctx, stencilRb);
  _mesa_reference_renderbuffer(fb-_StencilBuffer, wrapper);
- ASSERT(fb-_StencilBuffer-Wrapped == stencilRb);
   }
+  ASSERT(fb-_StencilBuffer-Wrapped == stencilRb);
+  fb-_StencilBuffer-Width = stencilRb-Width;
+  fb-_StencilBuffer-Height = stencilRb-Height;
}
else {
   /* stencilRb may be null */
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 10/13] mesa: remove unused depthstencil.[ch] files

2011-12-10 Thread Brian Paul
---
 src/mesa/SConscript  |1 -
 src/mesa/main/depthstencil.c | 1033 --
 src/mesa/main/depthstencil.h |   39 --
 src/mesa/sources.mak |1 -
 4 files changed, 0 insertions(+), 1074 deletions(-)
 delete mode 100644 src/mesa/main/depthstencil.c
 delete mode 100644 src/mesa/main/depthstencil.h

diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 4093e3f..bd9e94b 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -58,7 +58,6 @@ main_sources = [
 'main/cpuinfo.c',
 'main/debug.c',
 'main/depth.c',
-'main/depthstencil.c',
 'main/dlist.c',
 'main/dlopen.c',
 'main/drawpix.c',
diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
deleted file mode 100644
index 18f2705..000
--- a/src/mesa/main/depthstencil.c
+++ /dev/null
@@ -1,1033 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  6.5
- *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the Software),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include glheader.h
-#include imports.h
-#include context.h
-#include formats.h
-#include mtypes.h
-#include depthstencil.h
-#include renderbuffer.h
-
-
-/**
- * Adaptor/wrappers for GL_DEPTH_STENCIL renderbuffers.
- *
- * The problem with a GL_DEPTH_STENCIL renderbuffer is that sometimes we
- * want to treat it as a stencil buffer, other times we want to treat it
- * as a depth/z buffer and still other times when we want to treat it as
- * a combined Z+stencil buffer!  That implies we need three different sets
- * of Get/Put functions.
- *
- * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and
- * stencil adaptors, each with the right kind of depth/stencil Get/Put 
functions.
- */
-
-
-static void *
-nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, 
GLint y)
-{
-   (void) ctx;
-   (void) rb;
-   (void) x;
-   (void) y;
-   return NULL;
-}
-
-
-/**
- * Delete a depth or stencil wrapper renderbuffer.
- */
-static void
-delete_wrapper(struct gl_renderbuffer *rb)
-{
-   ASSERT(rb-Format == MESA_FORMAT_S8 ||
-  rb-Format == MESA_FORMAT_X8_Z24 ||
-  rb-Format == MESA_FORMAT_Z32_FLOAT);
-   _mesa_reference_renderbuffer(rb-Wrapped, NULL);
-   free(rb);
-}
-
-
-/**
- * Realloc storage for wrapper.
- */
-static GLboolean
-alloc_wrapper_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
-  GLenum internalFormat, GLuint width, GLuint height)
-{
-   /* just pass this on to the wrapped renderbuffer */
-   struct gl_renderbuffer *dsrb = rb-Wrapped;
-   GLboolean retVal;
-
-   (void) internalFormat;
-
-   ASSERT(dsrb-Format == MESA_FORMAT_Z24_S8 ||
-  dsrb-Format == MESA_FORMAT_Z24_X8 ||
-  dsrb-Format == MESA_FORMAT_S8_Z24 ||
-  dsrb-Format == MESA_FORMAT_X8_Z24);
-
-   retVal = dsrb-AllocStorage(ctx, dsrb, dsrb-InternalFormat, width, height);
-   if (retVal) {
-  rb-Width = width;
-  rb-Height = height;
-  rb-RowStride = dsrb-RowStride;
-   }
-   return retVal;
-}
-
-
-
-
-/*==
- * Depth wrapper around depth/stencil renderbuffer
- */
-
-static void
-get_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint 
count,
-GLint x, GLint y, void *values)
-{
-   struct gl_renderbuffer *dsrb = z24rb-Wrapped;
-   GLuint temp[MAX_WIDTH], i;
-   GLuint *dst = (GLuint *) values;
-   const GLuint *src = (const GLuint *) dsrb-GetPointer(ctx, dsrb, x, y);
-   ASSERT(z24rb-DataType == GL_UNSIGNED_INT);
-   ASSERT(dsrb-DataType == GL_UNSIGNED_INT_24_8_EXT);
-   if (!src) {
-  dsrb-GetRow(ctx, dsrb, count, x, y, temp);
-  src = temp;
-   }
-   if (dsrb-Format == MESA_FORMAT_Z24_S8) {
-  for (i = 0; i  count; i++) {
- dst[i] = src[i]  8;
-  }
-   }
-   else {
-  assert(dsrb-Format == MESA_FORMAT_S8_Z24);
-  for (i = 0; i  count; i++) {
- dst[i] = 

[Mesa-dev] [PATCH 11/13] swrast: add debug code to test combined depth/stencil buffers

2011-12-10 Thread Brian Paul
---
 src/mesa/swrast/s_renderbuffer.c |   54 +-
 1 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c
index 7622e38..bb7cdeb 100644
--- a/src/mesa/swrast/s_renderbuffer.c
+++ b/src/mesa/swrast/s_renderbuffer.c
@@ -1888,6 +1888,31 @@ add_stencil_renderbuffer(struct gl_context *ctx, struct 
gl_framebuffer *fb,
 }
 
 
+static GLboolean
+add_depth_stencil_renderbuffer(struct gl_context *ctx,
+   struct gl_framebuffer *fb)
+{
+   struct gl_renderbuffer *rb;
+
+   assert(fb-Attachment[BUFFER_DEPTH].Renderbuffer == NULL);
+   assert(fb-Attachment[BUFFER_STENCIL].Renderbuffer == NULL);
+
+   rb = _mesa_new_renderbuffer(ctx, 0);
+   if (!rb) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, Allocating depth+stencil buffer);
+  return GL_FALSE;
+   }
+
+   rb-InternalFormat = GL_DEPTH_STENCIL;
+
+   rb-AllocStorage = soft_renderbuffer_storage;
+   _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
+   _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
+
+   return GL_TRUE;
+}
+
+
 /**
  * Add a software-based accumulation renderbuffer to the given framebuffer.
  * This is a helper routine for device drivers when creating a
@@ -1999,14 +2024,29 @@ _swrast_add_soft_renderbuffers(struct gl_framebuffer 
*fb,
   frontRight, backRight);
}
 
-   if (depth) {
-  assert(fb-Visual.depthBits  0);
-  add_depth_renderbuffer(NULL, fb, fb-Visual.depthBits);
-   }
+#if 0
+   /* This is pretty much for debugging purposes only since there's a perf
+* hit for using combined depth/stencil in swrast.
+*/
+   if (depth  fb-Visual.depthBits == 24 
+   stencil  fb-Visual.stencilBits == 8) {
+  /* use combined depth/stencil buffer */
+  add_depth_stencil_renderbuffer(NULL, fb);
+   }
+   else
+#else
+   (void) add_depth_stencil_renderbuffer;
+#endif
+   {
+  if (depth) {
+ assert(fb-Visual.depthBits  0);
+ add_depth_renderbuffer(NULL, fb, fb-Visual.depthBits);
+  }
 
-   if (stencil) {
-  assert(fb-Visual.stencilBits  0);
-  add_stencil_renderbuffer(NULL, fb, fb-Visual.stencilBits);
+  if (stencil) {
+ assert(fb-Visual.stencilBits  0);
+ add_stencil_renderbuffer(NULL, fb, fb-Visual.stencilBits);
+  }
}
 
if (accum) {
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 12/13] mesa: remove _DepthBuffer, _StencilBuffer resize code

2011-12-10 Thread Brian Paul
This is handled in swrast now when we validate the framebuffer state.
---
 src/mesa/main/framebuffer.c |   18 --
 1 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 4a4ade0..6d5e452 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -306,24 +306,6 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct 
gl_framebuffer *fb,
   }
}
 
-   if (fb-_DepthBuffer) {
-  struct gl_renderbuffer *rb = fb-_DepthBuffer;
-  if (rb-Width != width || rb-Height != height) {
- if (!rb-AllocStorage(ctx, rb, rb-InternalFormat, width, height)) {
-_mesa_error(ctx, GL_OUT_OF_MEMORY, Resizing framebuffer);
- }
-  }
-   }
-
-   if (fb-_StencilBuffer) {
-  struct gl_renderbuffer *rb = fb-_StencilBuffer;
-  if (rb-Width != width || rb-Height != height) {
- if (!rb-AllocStorage(ctx, rb, rb-InternalFormat, width, height)) {
-_mesa_error(ctx, GL_OUT_OF_MEMORY, Resizing framebuffer);
- }
-  }
-   }
-
fb-Width = width;
fb-Height = height;
 
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 13/13] mesa: update comments for _DepthBuffer, _StencilBuffer fields

2011-12-10 Thread Brian Paul
---
 src/mesa/main/mtypes.h |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index fc494f7..1e06cd5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2650,8 +2650,9 @@ struct gl_framebuffer
struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
struct gl_renderbuffer *_ColorReadBuffer;
 
-   /** The Actual depth/stencil buffers to use.  May be wrappers around the
-* depth/stencil buffers attached above. */
+   /** Wrappers to make combined depth/stencil buffers look like separate
+* buffers.  Only used by swrast.  Will be removed in the future.
+*/
struct gl_renderbuffer *_DepthBuffer;
struct gl_renderbuffer *_StencilBuffer;
 
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] meta: rework dest image allocation in mipmap generation code

2011-12-10 Thread Brian Paul
This fixes two things:
1. If the texture object was created with glTexStorage2D, the call
   to _mesa_TexImage2D() would generate INVALID_OPERATION since the
   texture is marked as immutable.
2. _mesa_TexImage2D() always frees any existing texture image memory
   before allocating new memory.  That's inefficient since the existing
   image is usually the right size already.
---
 src/mesa/drivers/common/meta.c |  114 +++
 1 files changed, 79 insertions(+), 35 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 259041f..3ec8828 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2789,6 +2789,75 @@ setup_texture_coords(GLenum faceTarget,
 
 
 /**
+ * Helper function for mipmap generation.
+ * Make sure the specified destination mipmap level is the right size/format
+ * for mipmap generation.  If not, (re) allocate it.
+ * \return GL_TRUE if successful, GL_FALSE if mipmap generation should stop
+ */
+static GLboolean
+prepare_dest_image(struct gl_context *ctx,
+   struct gl_texture_object *texObj, GLuint level,
+   GLsizei width, GLsizei height, GLsizei depth,
+   GLsizei border, GLenum intFormat, gl_format format)
+{
+   const GLuint numFaces = texObj-Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+   GLuint face;
+
+   if (texObj-Immutable) {
+  /* The texture was created with glTexStorage() so the number/size of
+   * mipmap levels is fixed and the storage for all images is already
+   * allocated.
+   */
+  if (!texObj-Image[0][level]) {
+ /* No more levels to create - we're done */
+ return GL_FALSE;
+  }
+  else {
+ /* Nothing to do - the texture memory must have already been
+  * allocated to the right size so we're all set.
+  */
+ return GL_TRUE;
+  }
+   }
+
+   for (face = 0; face  numFaces; face++) {
+  struct gl_texture_image *dstImage;
+  GLenum target;
+
+  if (numFaces == 1)
+ target = texObj-Target;
+  else
+ target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
+
+  dstImage = _mesa_get_tex_image(ctx, texObj, target, level);
+  if (!dstImage) {
+ /* out of memory */
+ return GL_FALSE;
+  }
+
+  if (dstImage-Width != width ||
+  dstImage-Height != height ||
+  dstImage-Depth != depth ||
+  dstImage-Border != border ||
+  dstImage-InternalFormat != intFormat ||
+  dstImage-TexFormat != format) {
+ /* need to (re)allocate image */
+ ctx-Driver.FreeTextureImageBuffer(ctx, dstImage);
+
+ _mesa_init_teximage_fields(ctx, target, dstImage,
+width, height, depth,
+border, intFormat, format);
+
+ ctx-Driver.AllocTextureImageBuffer(ctx, dstImage,
+ format, width, height, depth);
+  }
+   }
+
+   return GL_TRUE;
+}
+
+
+/**
  * Called via ctx-Driver.GenerateMipmap()
  * Note: We don't yet support 3D textures, 1D/2D array textures or texture
  * borders.
@@ -2943,43 +3012,18 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, 
GLenum target,
  break;
   }
 
-  /* Set MaxLevel large enough to hold the new level when we allocate it  
*/
+  /* Allocate storage for the destination mipmap image(s) */
+
+  /* Set MaxLevel large enough to hold the new level when we allocate it */
   _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, dstLevel);
 
-  /* Create empty dest image */
-  if (target == GL_TEXTURE_1D) {
- _mesa_TexImage1D(target, dstLevel, srcImage-InternalFormat,
-  dstWidth, border,
-  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-  }
-  else if (target == GL_TEXTURE_3D) {
- _mesa_TexImage3D(target, dstLevel, srcImage-InternalFormat,
-  dstWidth, dstHeight, dstDepth, border,
-  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-  }
-  else {
- /* 2D or cube */
- _mesa_TexImage2D(faceTarget, dstLevel, srcImage-InternalFormat,
-  dstWidth, dstHeight, border,
-  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-
- if (target == GL_TEXTURE_CUBE_MAP) {
-/* If texturing from a cube, we need to make sure all src faces
- * have been defined (even if we're not sampling from them.)
- * Otherwise the texture object will be 'incomplete' and
- * texturing from it will not be allowed.
- */
-GLuint face;
-for (face = 0; face  6; face++) {
-   if (!texObj-Image[face][srcLevel] ||
-   texObj-Image[face][srcLevel]-Width != srcWidth) {
-  _mesa_TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face,
-   

[Mesa-dev] [PATCH 1/3] swrast: do depth/stencil clearing with Map/UnmapRenderbuffer()

2011-12-10 Thread Brian Paul
Another step toward getting rid of the renderbuffer PutRow/etc functions.
---
 src/mesa/swrast/s_clear.c   |   48 ++---
 src/mesa/swrast/s_depth.c   |  224 +++---
 src/mesa/swrast/s_depth.h   |5 +-
 src/mesa/swrast/s_stencil.c |  155 ++
 src/mesa/swrast/s_stencil.h |2 +-
 5 files changed, 294 insertions(+), 140 deletions(-)

diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c
index 851f6d1..778911f 100644
--- a/src/mesa/swrast/s_clear.c
+++ b/src/mesa/swrast/s_clear.c
@@ -195,6 +195,8 @@ clear_color_buffers(struct gl_context *ctx)
 void
 _swrast_Clear(struct gl_context *ctx, GLbitfield buffers)
 {
+   const GLbitfield BUFFER_DS = BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL;
+
 #ifdef DEBUG_FOO
{
   const GLbitfield legalBits =
@@ -216,24 +218,38 @@ _swrast_Clear(struct gl_context *ctx, GLbitfield buffers)
if (SWRAST_CONTEXT(ctx)-NewState)
   _swrast_validate_derived(ctx);
 
-   swrast_render_start(ctx);
+   if ((buffers  BUFFER_BITS_COLOR)
+(ctx-DrawBuffer-_NumColorDrawBuffers  0)) {
+  /* XXX remove the swrast_render_start/finish() calls after
+   * clear_color_buffers() is converted to use Map/UnmapRenderbuffer()
+   * The other clearing functions don't need these calls.
+   */
+  swrast_render_start(ctx);
+  clear_color_buffers(ctx);
+  swrast_render_finish(ctx);
+   }
 
-   /* do software clearing here */
-   if (buffers) {
-  if ((buffers  BUFFER_BITS_COLOR)
-   (ctx-DrawBuffer-_NumColorDrawBuffers  0)) {
- clear_color_buffers(ctx);
-  }
-  if (buffers  BUFFER_BIT_DEPTH) {
- _swrast_clear_depth_buffer(ctx, ctx-DrawBuffer-_DepthBuffer);
-  }
-  if (buffers  BUFFER_BIT_ACCUM) {
- _mesa_clear_accum_buffer(ctx);
+   if (buffers  BUFFER_BIT_ACCUM) {
+  _mesa_clear_accum_buffer(ctx);
+   }
+
+   if (buffers  BUFFER_DS) {
+  struct gl_renderbuffer *rb =
+ ctx-DrawBuffer-Attachment[BUFFER_DEPTH].Renderbuffer;
+
+  if ((buffers  BUFFER_DS) == BUFFER_DS  rb 
+  _mesa_is_format_packed_depth_stencil(rb-Format)) {
+ /* clear depth and stencil together */
+ _swrast_clear_depth_stencil_buffer(ctx);
   }
-  if (buffers  BUFFER_BIT_STENCIL) {
- _swrast_clear_stencil_buffer(ctx, ctx-DrawBuffer-_StencilBuffer);
+  else {
+ /* clear depth, stencil separately */
+ if (buffers  BUFFER_BIT_DEPTH) {
+_swrast_clear_depth_buffer(ctx);
+ }
+ if (buffers  BUFFER_BIT_STENCIL) {
+_swrast_clear_stencil_buffer(ctx);
+ }
   }
}
-
-   swrast_render_finish(ctx);
 }
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 8d3ad10..e2a81d8 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -26,6 +26,7 @@
 #include main/glheader.h
 #include main/context.h
 #include main/formats.h
+#include main/format_pack.h
 #include main/macros.h
 #include main/imports.h
 
@@ -1312,14 +1313,21 @@ _swrast_read_depth_span_float( struct gl_context *ctx, 
struct gl_renderbuffer *r
}
 }
 
+
 /**
- * Clear the given z/depth renderbuffer.
+ * Clear the given z/depth renderbuffer.  If the buffer is a combined
+ * depth+stencil buffer, only the Z bits will be touched.
  */
 void
-_swrast_clear_depth_buffer( struct gl_context *ctx, struct gl_renderbuffer *rb 
)
+_swrast_clear_depth_buffer(struct gl_context *ctx)
 {
+   struct gl_renderbuffer *rb =
+  ctx-DrawBuffer-Attachment[BUFFER_DEPTH].Renderbuffer;
GLuint clearValue;
GLint x, y, width, height;
+   GLubyte *map;
+   GLint rowStride, i, j;
+   GLbitfield mapMode;
 
if (!rb || !ctx-Depth.Mask) {
   /* no depth buffer, or writing to it is disabled */
@@ -1334,67 +1342,207 @@ _swrast_clear_depth_buffer( struct gl_context *ctx, 
struct gl_renderbuffer *rb )
   clearValue = (GLuint) (ctx-Depth.Clear * ctx-DrawBuffer-_DepthMaxF);
}
 
-   assert(rb-_BaseFormat == GL_DEPTH_COMPONENT);
-
/* compute region to clear */
x = ctx-DrawBuffer-_Xmin;
y = ctx-DrawBuffer-_Ymin;
width  = ctx-DrawBuffer-_Xmax - ctx-DrawBuffer-_Xmin;
height = ctx-DrawBuffer-_Ymax - ctx-DrawBuffer-_Ymin;
 
-   if (rb-GetPointer(ctx, rb, 0, 0)) {
-  /* Direct buffer access is possible.  Either this is just malloc'd
-   * memory, or perhaps the driver mmap'd the zbuffer memory.
-   */
-  if (rb-DataType == GL_UNSIGNED_SHORT) {
- if ((clearValue  0xff) == ((clearValue  8)  0xff) 
- ((GLushort *) rb-GetPointer(ctx, rb, 0, 0) + width ==
-  (GLushort *) rb-GetPointer(ctx, rb, 0, 1))) {
-/* optimized case */
-GLushort *dst = (GLushort *) rb-GetPointer(ctx, rb, x, y);
-GLuint len = width * height * sizeof(GLushort);
-memset(dst, (clearValue  0xff), len);
+   mapMode = GL_MAP_WRITE_BIT;
+   if (_mesa_get_format_bits(rb-Format, GL_STENCIL_BITS)  0) {
+ 

[Mesa-dev] [PATCH 2/3] swrast: rewrite color buffer clearing to use Map/UnmapRenderbuffer()

2011-12-10 Thread Brian Paul
---
 src/mesa/swrast/s_clear.c |  234 +++--
 1 files changed, 119 insertions(+), 115 deletions(-)

diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c
index 778911f..30c89bc 100644
--- a/src/mesa/swrast/s_clear.c
+++ b/src/mesa/swrast/s_clear.c
@@ -24,131 +24,149 @@
 
 #include main/glheader.h
 #include main/accum.h
-#include main/colormac.h
 #include main/condrender.h
+#include main/format_pack.h
 #include main/macros.h
 #include main/imports.h
 #include main/mtypes.h
 
 #include s_context.h
 #include s_depth.h
-#include s_masking.h
 #include s_stencil.h
 
 
 /**
- * Clear the color buffer when glColorMask is in effect.
+ * Clear an rgba color buffer with masking if needed.
  */
 static void
-clear_rgba_buffer_with_masking(struct gl_context *ctx, struct gl_renderbuffer 
*rb,
-   GLuint buf)
+clear_rgba_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb,
+  const GLubyte colorMask[4])
 {
const GLint x = ctx-DrawBuffer-_Xmin;
const GLint y = ctx-DrawBuffer-_Ymin;
const GLint height = ctx-DrawBuffer-_Ymax - ctx-DrawBuffer-_Ymin;
const GLint width  = ctx-DrawBuffer-_Xmax - ctx-DrawBuffer-_Xmin;
-   SWspan span;
-   GLint i;
-
-   ASSERT(rb-PutRow);
-
-   /* Initialize color span with clear color */
-   /* XXX optimize for clearcolor == black/zero (bzero) */
-   INIT_SPAN(span, GL_BITMAP);
-   span.end = width;
-   span.arrayMask = SPAN_RGBA;
-   span.array-ChanType = rb-DataType;
-   if (span.array-ChanType == GL_UNSIGNED_BYTE) {
-  GLubyte clearColor[4];
-  _mesa_unclamped_float_rgba_to_ubyte(clearColor, ctx-Color.ClearColor.f);
-  for (i = 0; i  width; i++) {
- COPY_4UBV(span.array-rgba[i], clearColor);
-  }
-   }
-   else if (span.array-ChanType == GL_UNSIGNED_SHORT) {
-  GLushort clearColor[4];
-  UNCLAMPED_FLOAT_TO_USHORT(clearColor[RCOMP], ctx-Color.ClearColor.f[0]);
-  UNCLAMPED_FLOAT_TO_USHORT(clearColor[GCOMP], ctx-Color.ClearColor.f[1]);
-  UNCLAMPED_FLOAT_TO_USHORT(clearColor[BCOMP], ctx-Color.ClearColor.f[2]);
-  UNCLAMPED_FLOAT_TO_USHORT(clearColor[ACOMP], ctx-Color.ClearColor.f[3]);
-  for (i = 0; i  width; i++) {
- COPY_4V_CAST(span.array-rgba[i], clearColor, GLchan);
-  }
-   }
-   else {
-  ASSERT(span.array-ChanType == GL_FLOAT);
-  for (i = 0; i  width; i++) {
- UNCLAMPED_FLOAT_TO_CHAN(span.array-rgba[i][0], 
ctx-Color.ClearColor.f[0]);
- UNCLAMPED_FLOAT_TO_CHAN(span.array-rgba[i][1], 
ctx-Color.ClearColor.f[1]);
- UNCLAMPED_FLOAT_TO_CHAN(span.array-rgba[i][2], 
ctx-Color.ClearColor.f[2]);
- UNCLAMPED_FLOAT_TO_CHAN(span.array-rgba[i][3], 
ctx-Color.ClearColor.f[3]);
-  }
+   const GLuint pixelSize = _mesa_get_format_bytes(rb-Format);
+   const GLboolean doMasking = (colorMask[0] == 0 ||
+colorMask[1] == 0 ||
+colorMask[2] == 0 ||
+colorMask[3] == 0);
+   const GLfloat (*clearColor)[4] =
+  (const GLfloat (*)[4]) ctx-Color.ClearColor.f;
+   GLfloat maskColor[4];
+   GLubyte *map;
+   GLint rowStride;
+   GLint i, j;
+
+   /* map dest buffer */
+   ctx-Driver.MapRenderbuffer(ctx, rb, x, y, width, height,
+   GL_MAP_WRITE_BIT,
+   map, rowStride);
+   if (!map) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, glClear(color));
+  return;
}
 
-   /* Note that masking will change the color values, but only the
-* channels for which the write mask is GL_FALSE.  The channels
-* which which are write-enabled won't get modified.
-*/
-   for (i = 0; i  height; i++) {
-  span.x = x;
-  span.y = y + i;
-  _swrast_mask_rgba_span(ctx, rb, span, buf);
-  /* write masked row */
-  rb-PutRow(ctx, rb, width, x, y + i, span.array-rgba, NULL);
+   if (doMasking) {
+  /* Convert the boolean mask to a color */
+  maskColor[0] = colorMask[0] ? 1.0 : 0.0;
+  maskColor[1] = colorMask[1] ? 1.0 : 0.0;
+  maskColor[2] = colorMask[2] ? 1.0 : 0.0;
+  maskColor[3] = colorMask[3] ? 1.0 : 0.0;
}
-}
 
+   /* for 1, 2, 4-byte clearing */
+#define SIMPLE_TYPE_CLEAR(TYPE) \
+   do { \
+  TYPE pixel, pixelMask;\
+  _mesa_pack_float_rgba_row(rb-Format, 1, clearColor, pixel); \
+  if (doMasking) {  \
+ _mesa_pack_float_rgba_row(rb-Format, 1,   \
+(const GLfloat (*)[4]) maskColor, pixelMask);  \
+ pixel = ~pixelMask;   \
+  } \
+  for (i = 0; i  height; i++) {\
+ TYPE *row = 

Re: [Mesa-dev] [PATCH] mesa: add const flags to skip MaxVarying and MaxUniform linker checks

2011-12-10 Thread Ian Romanick

On 12/09/2011 07:14 PM, Marek Olšák wrote:

This is only temporary until a better solution is available.
---

I haven't given up yet because reporting incorrect driver limits
may cause more troubles than this. I made it pretty small this
time.

It doesn't change any driver besides Gallium. Please review,
especially the part in st_extensions.c whether it's acceptable
or whether some other conditions should be used instead.
(e.g. strcmp(get_vendor(), X.Org R300 Project) is possible too)

I plan to implement a better solution, so that this code can go
away.

I see only two ways out of this.


To be honest, I we want to do both.


The first one is:
- Let Gallium drivers report an error when they can't run
   a certain shader.


I was thinking this would look like:

- Have the linker calculate the most conservative and most optimistic 
uniform and varying usage.


- Have the linker call into the driver to calculate the actual usage. 
Driver's that don't optimize can just report back the data supplied by 
the linker.


- If the driver's usage calculation is less than the conservative 
calculation, generate a link warning as a portability aid.


- If the driver's usage calculation is less than the optimistic 
calculation, generate an assertion failure.  Clearly, some piece of 
software is broken, and some sort of other failure is likely imminent.


- If the driver's usage calculation is greater than the driver's 
advertised limits, generate a link error.



The second one is:
- Remove the Mesa IR.


It won't be much longer until i915 and r200 are the only users of Mesa 
IR.  It's a pretty good fit for that hardware, so it won't disappear. 
However, it should disappear from the execution paths of every other driver.



- Replace TGSI by the GLSL IR completely.


I think that would be useful, but it doesn't seem strictly necessary.


- Move the dead-constant elimination pass from the R300 compiler
   to the GLSL IR.


I've added this to my todo list.  The new uniform tracking mechanism may 
make this a little bit more complex.



- Implement a GLSL optimization pass which breaks varying arrays
   into separate elements when possible.


This may not be necessary in the short term.  I think r300 is 
under-reporting it's capabilities.  See 
https://bugs.freedesktop.org/show_bug.cgi?id=34201#c9



Thanks.

  src/glsl/linker.cpp|9 ++---
  src/mesa/main/mtypes.h |9 +
  src/mesa/state_tracker/st_extensions.c |8 
  3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 3527088..fe35ed3 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1814,7 +1814,8 @@ assign_varying_locations(struct gl_context *ctx,
 }

 if (ctx-API == API_OPENGLES2 || prog-Version == 100) {
-  if (varying_vectors  ctx-Const.MaxVarying) {
+  if (varying_vectors  ctx-Const.MaxVarying
+  !ctx-Const.GLSLSkipStrictMaxVaryingLimitCheck) {
 linker_error(prog, shader uses too many varying vectors 
  (%u  %u)\n,
  varying_vectors, ctx-Const.MaxVarying);


Even when we have compaction in the front-end, it seems useful, as a 
portability aid, to keep a warning in this case.



@@ -1822,7 +1823,8 @@ assign_varying_locations(struct gl_context *ctx,
}
 } else {
const unsigned float_components = varying_vectors * 4;
-  if (float_components  ctx-Const.MaxVarying * 4) {
+  if (float_components  ctx-Const.MaxVarying * 4
+  !ctx-Const.GLSLSkipStrictMaxVaryingLimitCheck) {
 linker_error(prog, shader uses too many varying components 
  (%u  %u)\n,
  float_components, ctx-Const.MaxVarying * 4);
@@ -1959,7 +1961,8 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
  shader_names[i]);
}

-  if (sh-num_uniform_components  max_uniform_components[i]) {
+  if (sh-num_uniform_components  max_uniform_components[i]
+  !ctx-Const.GLSLSKipStrictMaxUniformLimitCheck) {
   linker_error(prog, Too many %s shader uniform components,
  shader_names[i]);
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index fc494f7..7e9f6ca 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2829,6 +2829,15 @@ struct gl_constants
  * Texture borders are deprecated in GL 3.0.
  **/
 GLboolean StripTextureBorder;
+
+   /**
+* For drivers which can do a better job at eliminating unused varyings
+* and uniforms than the GLSL compiler.
+*
+* XXX Remove these as soon as a better solution is available.
+*/
+   GLboolean GLSLSkipStrictMaxVaryingLimitCheck;
+   GLboolean GLSLSKipStrictMaxUniformLimitCheck;
  };


diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 37fb3e7..fdaffa8 100644
--- 

Re: [Mesa-dev] [PATCH] configure: Don't use $CLANG since it will collide with the static analyzer.

2011-12-10 Thread Ian Romanick

On 12/09/2011 06:12 AM, nobled wrote:

From: Jeremy Huddlestonjerem...@apple.com
Date: Thu, 5 May 2011 14:08:57 -0700

We just prefix the $CLANG environment variable in configure.ac with acv_mesa_

Found by: tinderbox
Signed-off-by: Jeremy Huddlestonjerem...@apple.com


Reviewed-by: Ian Romanick ian.d.roman...@intel.com

Jeremy should have commit access to push this at his leisure.  I suppose 
this should also go on the 7.11 branch as well, right?



---

Originally posted here:
http://lists.freedesktop.org/archives/mesa-dev/2011-May/007411.html

  configure.ac |8 
  1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index a4943e1..162945b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,13 +75,13 @@ AC_COMPILE_IFELSE(
 not clang
  #endif
  ]])],
-[CLANG=yes], [CLANG=no])
+[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no])

-AC_MSG_RESULT([$CLANG])
+AC_MSG_RESULT([$acv_mesa_CLANG])

  dnl If we're using GCC, make sure that it is at least version 3.3.0.  Older
  dnl versions are explictly not supported.
-if test x$GCC = xyes -a x$CLANG = xno; then
+if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then
  AC_MSG_CHECKING([whether gcc version is sufficient])
  major=0
  minor=0
@@ -155,7 +155,7 @@ esac
  dnl Add flags for gcc and g++
  if test x$GCC = xyes; then
  CFLAGS=$CFLAGS -Wall -Wmissing-prototypes -std=c99
-if test x$CLANG = xno; then
+if test x$acv_mesa_CLANG = xno; then
 CFLAGS=$CFLAGS -ffast-math
  fi




___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl_to_tgsi: make sure copied instructions don't lose texture target.

2011-12-10 Thread Dave Airlie
On Sat, Dec 10, 2011 at 6:34 PM, Dave Airlie airl...@gmail.com wrote:
 From: Dave Airlie airl...@redhat.com

 The piglit draw-pixel-with-texture was asserting in the glsl-tgsi code,
 due to 0 texture target, this makes sure the texture target is copied over
 correctly when we copy instructions around.

Oh so it looks like this could be fun or maybe the other one, so
glsl-tgsi is broken for draw pixels where a texturing is enabled.

The problem is we ignore the fact that texturing is enabled and we
blindly write over the original programs texture info, we also seem to
bind our samplers on top of the original states which also seems
doomed to failure.

I'm not 100% sure how best to solve this, I'll just tool around until
I have an answer unless someone comes up with a better one.

Dave.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: add const flags to skip MaxVarying and MaxUniform linker checks

2011-12-10 Thread Christoph Bumiller
On 10.12.2011 20:19, Ian Romanick wrote:
 On 12/09/2011 07:14 PM, Marek Olšák wrote:
 This is only temporary until a better solution is available.
 ---

 I haven't given up yet because reporting incorrect driver limits
 may cause more troubles than this. I made it pretty small this
 time.

 It doesn't change any driver besides Gallium. Please review,
 especially the part in st_extensions.c whether it's acceptable
 or whether some other conditions should be used instead.
 (e.g. strcmp(get_vendor(), X.Org R300 Project) is possible too)

 I plan to implement a better solution, so that this code can go
 away.

 I see only two ways out of this.

 To be honest, I we want to do both.

 The first one is:
 - Let Gallium drivers report an error when they can't run
a certain shader.

 I was thinking this would look like:

 - Have the linker calculate the most conservative and most optimistic
 uniform and varying usage.

 - Have the linker call into the driver to calculate the actual usage.
 Driver's that don't optimize can just report back the data supplied by
 the linker.

 - If the driver's usage calculation is less than the conservative
 calculation, generate a link warning as a portability aid.

 - If the driver's usage calculation is less than the optimistic
 calculation, generate an assertion failure.  Clearly, some piece of
 software is broken, and some sort of other failure is likely imminent.

 - If the driver's usage calculation is greater than the driver's
 advertised limits, generate a link error.

 The second one is:
 - Remove the Mesa IR.

 It won't be much longer until i915 and r200 are the only users of Mesa
 IR.  It's a pretty good fit for that hardware, so it won't disappear.
 However, it should disappear from the execution paths of every other
 driver.

 - Replace TGSI by the GLSL IR completely.

 I think that would be useful, but it doesn't seem strictly necessary.

 - Move the dead-constant elimination pass from the R300 compiler
to the GLSL IR.

 I've added this to my todo list.  The new uniform tracking mechanism
 may make this a little bit more complex.

 - Implement a GLSL optimization pass which breaks varying arrays
into separate elements when possible.

 This may not be necessary in the short term.  I think r300 is
 under-reporting it's capabilities.  See
 https://bugs.freedesktop.org/show_bug.cgi?id=34201#c9

 Thanks.

   src/glsl/linker.cpp|9 ++---
   src/mesa/main/mtypes.h |9 +
   src/mesa/state_tracker/st_extensions.c |8 
   3 files changed, 23 insertions(+), 3 deletions(-)

 diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
 index 3527088..fe35ed3 100644
 --- a/src/glsl/linker.cpp
 +++ b/src/glsl/linker.cpp
 @@ -1814,7 +1814,8 @@ assign_varying_locations(struct gl_context *ctx,
  }

  if (ctx-API == API_OPENGLES2 || prog-Version == 100) {
 -  if (varying_vectors  ctx-Const.MaxVarying) {
 +  if (varying_vectors  ctx-Const.MaxVarying
 +  !ctx-Const.GLSLSkipStrictMaxVaryingLimitCheck) {
linker_error(prog, shader uses too many varying vectors 
 (%u  %u)\n,
 varying_vectors, ctx-Const.MaxVarying);

 Even when we have compaction in the front-end, it seems useful, as a
 portability aid, to keep a warning in this case.

 @@ -1822,7 +1823,8 @@ assign_varying_locations(struct gl_context *ctx,
 }
  } else {
 const unsigned float_components = varying_vectors * 4;
 -  if (float_components  ctx-Const.MaxVarying * 4) {
 +  if (float_components  ctx-Const.MaxVarying * 4
 +  !ctx-Const.GLSLSkipStrictMaxVaryingLimitCheck) {
linker_error(prog, shader uses too many varying components 
 (%u  %u)\n,
 float_components, ctx-Const.MaxVarying * 4);
 @@ -1959,7 +1961,8 @@ check_resources(struct gl_context *ctx, struct
 gl_shader_program *prog)
 shader_names[i]);
 }

 -  if (sh-num_uniform_components  max_uniform_components[i]) {
 +  if (sh-num_uniform_components  max_uniform_components[i]
 +  !ctx-Const.GLSLSKipStrictMaxUniformLimitCheck) {
linker_error(prog, Too many %s shader uniform components,
 shader_names[i]);
 }
 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
 index fc494f7..7e9f6ca 100644
 --- a/src/mesa/main/mtypes.h
 +++ b/src/mesa/main/mtypes.h
 @@ -2829,6 +2829,15 @@ struct gl_constants
   * Texture borders are deprecated in GL 3.0.
   **/
  GLboolean StripTextureBorder;
 +
 +   /**
 +* For drivers which can do a better job at eliminating unused
 varyings
 +* and uniforms than the GLSL compiler.
 +*
 +* XXX Remove these as soon as a better solution is available.
 +*/
 +   GLboolean GLSLSkipStrictMaxVaryingLimitCheck;
 +   GLboolean GLSLSKipStrictMaxUniformLimitCheck;
   };


 diff --git a/src/mesa/state_tracker/st_extensions.c
 

Re: [Mesa-dev] [PATCH] glsl_to_tgsi: make sure copied instructions don't lose texture target.

2011-12-10 Thread Dave Airlie

 The piglit draw-pixel-with-texture was asserting in the glsl-tgsi code,
 due to 0 texture target, this makes sure the texture target is copied over
 correctly when we copy instructions around.

 Oh so it looks like this could be fun or maybe the other one, so
 glsl-tgsi is broken for draw pixels where a texturing is enabled.

 The problem is we ignore the fact that texturing is enabled and we
 blindly write over the original programs texture info, we also seem to
 bind our samplers on top of the original states which also seems
 doomed to failure.

 I'm not 100% sure how best to solve this, I'll just tool around until
 I have an answer unless someone comes up with a better one.

Okay I suspect the st_cb_drawpixels.c needs to start looking a lot
more like the st_cb_bitmap.c, if the draw-pixel-with-texture test is
correct, which I've no reason to believe it isn't.

Dave.



 Dave.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 43683] src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4575:st_translate_program: Assertion `0' failed.

2011-12-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43683

Vinson Lee v...@vmware.com changed:

   What|Removed |Added

 Status|RESOLVED|CLOSED

--- Comment #2 from Vinson Lee v...@vmware.com 2011-12-10 14:05:52 PST ---
mesa: 72cb103cf518c86d8d094380d9f8e16650a0060b (master)

Verified fixed.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 43682] SIGSEGV src/mesa/state_tracker/st_glsl_to_tgsi.cpp:4560

2011-12-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43682

Vinson Lee v...@vmware.com changed:

   What|Removed |Added

 Status|RESOLVED|CLOSED

--- Comment #4 from Vinson Lee v...@vmware.com 2011-12-10 14:07:45 PST ---
mesa: 72cb103cf518c86d8d094380d9f8e16650a0060b (master)

Verified fixed.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] g3dvl/xlib: fix build by changing include order

2011-12-10 Thread Tobias Droste
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 tdro...@gmx.de
---
 src/gallium/winsys/g3dvl/xlib/xsp_winsys.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c 
b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
index e86d92f..c0c7cde 100644
--- a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
+++ b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
@@ -25,14 +25,14 @@
  *
  **/
 
-#include X11/Xlibint.h
-
 #include pipe/p_state.h
 
 #include util/u_memory.h
 #include util/u_format.h
 #include util/u_inlines.h
 
+#include X11/Xlibint.h
+
 #include state_tracker/xlib_sw_winsys.h
 #include softpipe/sp_public.h
 
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] vdpau: Handle destination rectangles correctly

2011-12-10 Thread Younes Manton
On Tue, Dec 6, 2011 at 4:51 PM, Andy Furniss andy...@ukfsn.org wrote:
 Maarten Lankhorst wrote:

 The brokenness in vlVdpVideoMixerRender was compensating for
 brokenness in vlVdpPresentationQueueDisplay, so fix both at
 the same time.


 These fix the two remaining issues (aspect not maintained when fullscreen
 and subtitle position getting changed when toggling back from fullscreen to
 windowed) I had with R600 + mplayer + -vo vdpau (sw decode).

Can you provide a tested-by line for this and any other patches you've
tried that you can confirm don't regress? That way I can push the ones
that don't require discussion.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/6] vl: Add missing mpeg fields to pipe_mpeg12_picture_desc

2011-12-10 Thread Younes Manton
On Thu, Dec 1, 2011 at 7:00 PM, Maarten Lankhorst
m.b.lankho...@gmail.com wrote:
 Signed-off-by: Maarten Lankhorst m.b.lankho...@gmail.com
 ---
  src/gallium/include/pipe/p_video_state.h  |    3 +++
  src/gallium/state_trackers/vdpau/decode.c |    3 +++
  2 files changed, 6 insertions(+), 0 deletions(-)

 diff --git a/src/gallium/include/pipe/p_video_state.h 
 b/src/gallium/include/pipe/p_video_state.h
 index 1940bf1..9a70eb7 100644
 --- a/src/gallium/include/pipe/p_video_state.h
 +++ b/src/gallium/include/pipe/p_video_state.h
 @@ -134,6 +134,9 @@ struct pipe_mpeg12_picture_desc
    unsigned concealment_motion_vectors;
    unsigned intra_dc_precision;
    unsigned f_code[2][2];
 +   unsigned top_field_first;
 +   unsigned full_pel_forward_vector;
 +   unsigned full_pel_backward_vector;
    unsigned num_slices;
  };

 diff --git a/src/gallium/state_trackers/vdpau/decode.c 
 b/src/gallium/state_trackers/vdpau/decode.c
 index f135129..47212e3 100644
 --- a/src/gallium/state_trackers/vdpau/decode.c
 +++ b/src/gallium/state_trackers/vdpau/decode.c
 @@ -245,6 +245,9 @@ vlVdpDecoderRenderMpeg12(struct pipe_video_decoder 
 *decoder,
    picture.f_code[1][0] = picture_info-f_code[1][0] - 1;
    picture.f_code[1][1] = picture_info-f_code[1][1] - 1;
    picture.num_slices = picture_info-slice_count;
 +   picture.top_field_first = picture_info-top_field_first;
 +   picture.full_pel_forward_vector = picture_info-full_pel_forward_vector;
 +   picture.full_pel_backward_vector = picture_info-full_pel_backward_vector;

    decoder-set_picture_parameters(decoder, picture.base);

 --
 1.7.7.3



 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Pushed. Thanks.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: add const flags to skip MaxVarying and MaxUniform linker checks

2011-12-10 Thread Marek Olšák
On Sat, Dec 10, 2011 at 8:19 PM, Ian Romanick i...@freedesktop.org wrote:
 On 12/09/2011 07:14 PM, Marek Olšák wrote:

 This is only temporary until a better solution is available.
 ---

 I haven't given up yet because reporting incorrect driver limits
 may cause more troubles than this. I made it pretty small this
 time.

 It doesn't change any driver besides Gallium. Please review,
 especially the part in st_extensions.c whether it's acceptable
 or whether some other conditions should be used instead.
 (e.g. strcmp(get_vendor(), X.Org R300 Project) is possible too)

 I plan to implement a better solution, so that this code can go
 away.

 I see only two ways out of this.


 To be honest, I we want to do both.


 The first one is:
 - Let Gallium drivers report an error when they can't run
   a certain shader.


 I was thinking this would look like:

 - Have the linker calculate the most conservative and most optimistic
 uniform and varying usage.

 - Have the linker call into the driver to calculate the actual usage.
 Driver's that don't optimize can just report back the data supplied by the
 linker.

 - If the driver's usage calculation is less than the conservative
 calculation, generate a link warning as a portability aid.

 - If the driver's usage calculation is less than the optimistic calculation,
 generate an assertion failure.  Clearly, some piece of software is broken,
 and some sort of other failure is likely imminent.

 - If the driver's usage calculation is greater than the driver's advertised
 limits, generate a link error.

Sounds good.



 The second one is:
 - Remove the Mesa IR.


 It won't be much longer until i915 and r200 are the only users of Mesa IR.
  It's a pretty good fit for that hardware, so it won't disappear. However,
 it should disappear from the execution paths of every other driver.


 - Replace TGSI by the GLSL IR completely.


 I think that would be useful, but it doesn't seem strictly necessary.


 - Move the dead-constant elimination pass from the R300 compiler
   to the GLSL IR.


 I've added this to my todo list.  The new uniform tracking mechanism may
 make this a little bit more complex.


 - Implement a GLSL optimization pass which breaks varying arrays
   into separate elements when possible.


 This may not be necessary in the short term.  I think r300 is
 under-reporting it's capabilities.  See
 https://bugs.freedesktop.org/show_bug.cgi?id=34201#c9

The problem is st/mesa is under-reporting its capabilities, because
when I was writing that code, I thought color varyings just don't
belong to the max varying limit. The color varyings shouldn't be
considered a generic varying resource (at least internally in Mesa),
because there may have different precision. They don't have to be
float when clamped, and they don't have to be exactly 32-bit float
when not clamped (r300 is an example of such a behavior).

I see this solution:

We don't need exact GL limits in gl_constants, only the limits which
make sense for drivers, like Gallium has. So we'd have something like
MaxGenericVaryings and glGet*(GL_MAX_VARYING_FLOATS) would return
MaxGenericVaryings*4+8. Then the linker wouldn't count the color
varyings in the number of used varying components. How does it sound?



 Thanks.

  src/glsl/linker.cpp                    |    9 ++---
  src/mesa/main/mtypes.h                 |    9 +
  src/mesa/state_tracker/st_extensions.c |    8 
  3 files changed, 23 insertions(+), 3 deletions(-)

 diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
 index 3527088..fe35ed3 100644
 --- a/src/glsl/linker.cpp
 +++ b/src/glsl/linker.cpp
 @@ -1814,7 +1814,8 @@ assign_varying_locations(struct gl_context *ctx,
     }

     if (ctx-API == API_OPENGLES2 || prog-Version == 100) {
 -      if (varying_vectors  ctx-Const.MaxVarying) {
 +      if (varying_vectors  ctx-Const.MaxVarying
 +          !ctx-Const.GLSLSkipStrictMaxVaryingLimitCheck) {
         linker_error(prog, shader uses too many varying vectors 
                      (%u  %u)\n,
                      varying_vectors, ctx-Const.MaxVarying);


 Even when we have compaction in the front-end, it seems useful, as a
 portability aid, to keep a warning in this case.

Will do.



 @@ -1822,7 +1823,8 @@ assign_varying_locations(struct gl_context *ctx,
        }
     } else {
        const unsigned float_components = varying_vectors * 4;
 -      if (float_components  ctx-Const.MaxVarying * 4) {
 +      if (float_components  ctx-Const.MaxVarying * 4
 +          !ctx-Const.GLSLSkipStrictMaxVaryingLimitCheck) {
         linker_error(prog, shader uses too many varying components 
                      (%u  %u)\n,
                      float_components, ctx-Const.MaxVarying * 4);
 @@ -1959,7 +1961,8 @@ check_resources(struct gl_context *ctx, struct
 gl_shader_program *prog)
                      shader_names[i]);
        }

 -      if (sh-num_uniform_components  max_uniform_components[i]) {
 +      if (sh-num_uniform_components