Re: [Mesa-dev] [PATCH] mesa/st: Don't modify the context draw/read buffers.

2011-12-09 Thread Jose Fonseca
- Original Message -
 On Fri, Dec 9, 2011 at 2:02 PM, Chia-I Wu o...@lunarg.com wrote:
  On Thu, Dec 8, 2011 at 10:00 PM,  jfons...@vmware.com wrote:
  From: José Fonseca jfons...@vmware.com
 
  It sets the wrong values (GL_XXX_LEFT instead of GL_XXX), and no
  other
  Mesa driver does this, given that Mesa sets the right draw/read
  buffers
  provided the Mesa visual has the doublebuffer flag filled
  correctly
  which is the case.
  In EGL, when an EGLSurface is created, users can specify whether
  the
  front or back buffer will be rendered to.  The function is used to
  make a double-buffered context work with an EGLSurface whose front
  buffer is supposed to be rendered to.  But I admit that the
  function
  is hacky.
 and may be wrong for GL.  It is ok for GLES because GLES does not
 have
 GL_DRAW_BUFFER thus the value can be modified.
 
  Since this is brought up, I did this experiment some time ago:
 It was done using GLX and GL.
   1. create a single-buffered drawable
   2. create a context with a GLX_DOUBLEBUFFER visual
   3. make the context and drawable current
   4. query GL_DRAW_BUFFER
 
  Mesa returned GL_BACK and nVidia's proprietary driver returned
  GL_FRONT.  This difference, IMHO, comes from that Mesa uses the
  visual
  of the context to determine whether the context is double-buffered
  or
  single-buffered, while nVidia uses the visual of the drawable to
  make
  the decision (and at the time when the context is first made
  current).
 
  What I want to argue here is that, maybe there should be no
  single-buffered or double-buffered contexts, but single-buffered or
  double-buffered drawables.  Or more precisely, the type of the
  context
  should be determined by the type of the current drawable.  I
  checked
  GLX spec and it seemed that GLX_DOUBLEBUFFER applies for drawables.
  Since GL 3.0, GL_DOUBLEBUFFER is also listed as one of the
  framebuffer
  dependent values.  That implies the state may change when the
  current
  drawable changes.  So it is still a correct behavior for the
  drawable
  to determine the type of the context.
 
  I did not have a chance to look deeper into this due to the lack of
  time.  So I may be terribly wrong here...

Thanks for the explanation.

You make a valid point: intuitively, double-buffering is a property of 
drawables and not contexts. But the specs seem to maintain the view that it is 
also a property of contexts:

- glDrawBuffer man page talks about single-buffered contexts and 
double-buffered contexts and not drawables [1]

- glXMakeCurrent says that BadMatch is generated if drawable was not created 
with the same X screen and visual as ctx [2], therefore mixing single with 
double buffer context as you did is non-standard behavior -- glxMakeCurrent 
should had returned BadMatch.  I know that on Windows this is enforced by the 
MS OpenGL runtime, and when apps want to mix double and single bufferd render 
they need to use double buffered pixelformats, and use GL_FRONT for

However eglMakeCurrent is indeed a bit more lenient, as the spec says If draw 
or read are not compatible with ctx, then an EGL_BAD_MATCH error
is generated., where the definition compatible is not really spelled out.

But at the end of the day I feel that:
a) mixing single- double- buffered drawables/visuals is non-standard, probably 
seldom used, and not worth spending much time on it, and if we do it is better 
to find a solution in Mesa core for all drivers
b) GL_(FRONT|BACK)_LEFT is definitely wrong -- it should be either GL_FRONT or 
BACK -- specially when the drawable/context are consistent on this regard which 
is the common case

Jose

[1] http://www.opengl.org/sdk/docs/man/xhtml/glDrawBuffer.xml
[2] http://www.talisman.org/opengl-1.1/Reference/glXMakeCurrent.html
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] util: Fix -Wimplicit-function-declaration for ffs with GCC

2011-12-09 Thread Kai Wasserbäch
AFAICS GCC was missed from the last #elif clause. With this patch
applied the warning is gone.

Signed-off-by: Kai Wasserbäch k...@dev.carbon-project.org
---
 There certainly other warnings thrown during a build, but I saw this one
 scrolling by, while checking on a build. Hence I went to fix it.

 src/gallium/auxiliary/util/u_math.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_math.h 
b/src/gallium/auxiliary/util/u_math.h
index f908341..068a8d1 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -364,7 +364,7 @@ unsigned ffs( unsigned u )
 
return i;
 }
-#elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID)
+#elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID) || defined(PIPE_CC_GCC)
 #define ffs __builtin_ffs
 #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] [RFC] program: fix out of bounds array accesses and other bad things

2011-12-09 Thread nobled
Noticed a warning: array subscript is above array bounds given at one of
the existing sanity-check asserts. Turns out all the arrays of strings
haven't matched the corresponding enum values in a while, if ever.

I didn't know the proper names for any of these and couldn't find
them in the base specs aside from result.pointsize in
ARB_vertex_program, so I just filled in the enum's value
as was done with other slots.

Also add four STATIC_ASSERT()s to be sure and catch future additions
or bumps to MAX_VARYING/etc again, and some more non-static asserts
where there weren't any before.

(Note, the fragment enum that corresponded to result.color(half) was removed in
8d475822e6e19fa79719c856a2db5b6a205db1b9.)
---
 src/mesa/program/prog_print.c |   73 +
 1 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index e9bf3aa..dfb5793 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -95,15 +95,15 @@ arb_input_attrib_string(GLint index, GLenum progType)
/*
 * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens.
 */
-   const char *vertAttribs[] = {
+   static const char *const vertAttribs[] = {
   vertex.position,
   vertex.weight,
   vertex.normal,
   vertex.color.primary,
   vertex.color.secondary,
   vertex.fogcoord,
-  vertex.(six),
-  vertex.(seven),
+  vertex.(six), /* VERT_ATTRIB_COLOR_INDEX */
+  vertex.(seven), /* VERT_ATTRIB_EDGEFLAG */
   vertex.texcoord[0],
   vertex.texcoord[1],
   vertex.texcoord[2],
@@ -112,6 +112,7 @@ arb_input_attrib_string(GLint index, GLenum progType)
   vertex.texcoord[5],
   vertex.texcoord[6],
   vertex.texcoord[7],
+  vertex.(sixteen), /* VERT_ATTRIB_POINT_SIZE */
   vertex.attrib[0],
   vertex.attrib[1],
   vertex.attrib[2],
@@ -127,9 +128,9 @@ arb_input_attrib_string(GLint index, GLenum progType)
   vertex.attrib[12],
   vertex.attrib[13],
   vertex.attrib[14],
-  vertex.attrib[15]
+  vertex.attrib[15] /* MAX_VARYING = 16 */
};
-   const char *fragAttribs[] = {
+   static const char *const fragAttribs[] = {
   fragment.position,
   fragment.color.primary,
   fragment.color.secondary,
@@ -142,6 +143,10 @@ arb_input_attrib_string(GLint index, GLenum progType)
   fragment.texcoord[5],
   fragment.texcoord[6],
   fragment.texcoord[7],
+  fragment.(twelve), /* FRAG_ATTRIB_FACE */
+  fragment.(thirteen), /* FRAG_ATTRIB_PNTC */
+  fragment.(fourteen), /* FRAG_ATTRIB_CLIP_DIST0 */
+  fragment.(fifteen), /* FRAG_ATTRIB_CLIP_DIST1 */
   fragment.varying[0],
   fragment.varying[1],
   fragment.varying[2],
@@ -149,18 +154,31 @@ arb_input_attrib_string(GLint index, GLenum progType)
   fragment.varying[4],
   fragment.varying[5],
   fragment.varying[6],
-  fragment.varying[7]
+  fragment.varying[7],
+  fragment.varying[8],
+  fragment.varying[9],
+  fragment.varying[10],
+  fragment.varying[11],
+  fragment.varying[12],
+  fragment.varying[13],
+  fragment.varying[14],
+  fragment.varying[15] /* MAX_VARYING = 16 */
};

/* sanity checks */
+   STATIC_ASSERT(Elements(vertAttribs) == VERT_ATTRIB_MAX);
+   STATIC_ASSERT(Elements(fragAttribs) == FRAG_ATTRIB_MAX);
assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], vertex.texcoord[0]) == 0);
assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15],
vertex.attrib[15]) == 0);
+   assert(strcmp(fragAttribs[FRAG_ATTRIB_TEX0], fragment.texcoord[0]) == 0);
+   assert(strcmp(fragAttribs[FRAG_ATTRIB_VAR0+15],
fragment.varying[15]) == 0);

if (progType == GL_VERTEX_PROGRAM_ARB) {
   assert(index  Elements(vertAttribs));
   return vertAttribs[index];
}
else {
+  assert(progType == GL_FRAGMENT_PROGRAM_ARB);
   assert(index  Elements(fragAttribs));
   return fragAttribs[index];
}
@@ -213,7 +231,7 @@ arb_output_attrib_string(GLint index, GLenum progType)
/*
 * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens.
 */
-   const char *vertResults[] = {
+   static const char *const vertResults[] = {
   result.position,
   result.color.primary,
   result.color.secondary,
@@ -226,6 +244,13 @@ arb_output_attrib_string(GLint index, GLenum progType)
   result.texcoord[5],
   result.texcoord[6],
   result.texcoord[7],
+  result.pointsize, /* VERT_RESULT_PSIZ */
+  result.(thirteen), /* VERT_RESULT_BFC0 */
+  result.(fourteen), /* VERT_RESULT_BFC1 */
+  result.(fifteen), /* VERT_RESULT_EDGE */
+  result.(sixteen), /* VERT_RESULT_CLIP_VERTEX */
+  result.(seventeen), /* VERT_RESULT_CLIP_DIST0 */
+  result.(eighteen), /* VERT_RESULT_CLIP_DIST1 */
   result.varying[0],
   result.varying[1],
   result.varying[2],
@@ -233,23 +258,43 @@ arb_output_attrib_string(GLint 

[Mesa-dev] [PATCH] gen_matypes: eliminate printf warnings

2011-12-09 Thread nobled
The VERT_BIT_* defines are 64-bit values since commit
f364ac1da10ff67eba5196c1074aff579864f741, but the printf
was still expecting a simple int. This worked on little-endian
hosts because the values were still less than INT_MAX, but
probably would've gone bad and printed zero on big-endian ones.
---
 src/mesa/x86/gen_matypes.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/mesa/x86/gen_matypes.c b/src/mesa/x86/gen_matypes.c
index 648bf87..18baa29 100644
--- a/src/mesa/x86/gen_matypes.c
+++ b/src/mesa/x86/gen_matypes.c
@@ -32,6 +32,11 @@
  * Mesa, including lighting, clipping, texture image conversion etc.
  */

+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+#include inttypes.h
+
 #include main/glheader.h
 #include main/mtypes.h
 #include tnl/t_context.h
@@ -68,7 +73,7 @@ do {  
\
printf( #define %s\t%lu\n, s, (unsigned long) sizeof(t) );

 #define DEFINE( s, d ) \
-   printf( #define %s\t0x%x\n, s, d );
+   printf( #define %s\t0x%PRIx64\n, s, (uint64_t) d );



-- 
1.7.4.1
From f88d54fde18f4109b5af5d90e513ef761e4021bd Mon Sep 17 00:00:00 2001
From: nobled nob...@dreamwidth.org
Date: Thu, 8 Dec 2011 20:53:25 +
Subject: [PATCH 2/4] gen_matypes: eliminate printf warnings

The VERT_BIT_* defines are 64-bit values since commit
f364ac1da10ff67eba5196c1074aff579864f741, but the printf
was still expecting a simple int. This worked on little-endian
hosts because the values were still less than INT_MAX, but
probably would've gone bad and printed zero on big-endian ones.
---
 src/mesa/x86/gen_matypes.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/mesa/x86/gen_matypes.c b/src/mesa/x86/gen_matypes.c
index 648bf87..18baa29 100644
--- a/src/mesa/x86/gen_matypes.c
+++ b/src/mesa/x86/gen_matypes.c
@@ -32,6 +32,11 @@
  * Mesa, including lighting, clipping, texture image conversion etc.
  */
 
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+#include inttypes.h
+
 #include main/glheader.h
 #include main/mtypes.h
 #include tnl/t_context.h
@@ -68,7 +73,7 @@ do {	\
printf( #define %s\t%lu\n, s, (unsigned long) sizeof(t) );
 
 #define DEFINE( s, d )			\
-   printf( #define %s\t0x%x\n, s, d );
+   printf( #define %s\t0x%PRIx64\n, s, (uint64_t) d );
 
 
 
-- 
1.7.4.1

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


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

2011-12-09 Thread nobled
From: Jeremy Huddleston jerem...@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 Huddleston jerem...@apple.com
---

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

-- 
1.7.4.1
From 60549bd4cee04817d097871e61f8c2a6d47a8b5d Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston jerem...@apple.com
Date: Thu, 5 May 2011 14:08:57 -0700
Subject: [PATCH 3/4] configure: Don't use $CLANG since it will collide with the static analyzer.

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

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

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
 
-- 
1.7.4.1

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


Re: [Mesa-dev] [PATCH] [RFC] program: fix out of bounds array accesses and other bad things

2011-12-09 Thread Brian Paul

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

Noticed a warning: array subscript is above array bounds given at one of
the existing sanity-check asserts. Turns out all the arrays of strings
haven't matched the corresponding enum values in a while, if ever.

I didn't know the proper names for any of these and couldn't find
them in the base specs aside from result.pointsize in
ARB_vertex_program, so I just filled in the enum's value
as was done with other slots.

Also add four STATIC_ASSERT()s to be sure and catch future additions
or bumps to MAX_VARYING/etc again, and some more non-static asserts
where there weren't any before.

(Note, the fragment enum that corresponded to result.color(half) was removed in
8d475822e6e19fa79719c856a2db5b6a205db1b9.)
---
  src/mesa/program/prog_print.c |   73 +
  1 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index e9bf3aa..dfb5793 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -95,15 +95,15 @@ arb_input_attrib_string(GLint index, GLenum progType)
 /*
  * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens.
  */
-   const char *vertAttribs[] = {
+   static const char *const vertAttribs[] = {
vertex.position,
vertex.weight,
vertex.normal,
vertex.color.primary,
vertex.color.secondary,
vertex.fogcoord,
-  vertex.(six),
-  vertex.(seven),
+  vertex.(six), /* VERT_ATTRIB_COLOR_INDEX */
+  vertex.(seven), /* VERT_ATTRIB_EDGEFLAG */
vertex.texcoord[0],
vertex.texcoord[1],
vertex.texcoord[2],
@@ -112,6 +112,7 @@ arb_input_attrib_string(GLint index, GLenum progType)
vertex.texcoord[5],
vertex.texcoord[6],
vertex.texcoord[7],
+  vertex.(sixteen), /* VERT_ATTRIB_POINT_SIZE */
vertex.attrib[0],
vertex.attrib[1],
vertex.attrib[2],
@@ -127,9 +128,9 @@ arb_input_attrib_string(GLint index, GLenum progType)
vertex.attrib[12],
vertex.attrib[13],
vertex.attrib[14],
-  vertex.attrib[15]
+  vertex.attrib[15] /* MAX_VARYING = 16 */
 };
-   const char *fragAttribs[] = {
+   static const char *const fragAttribs[] = {
fragment.position,
fragment.color.primary,
fragment.color.secondary,
@@ -142,6 +143,10 @@ arb_input_attrib_string(GLint index, GLenum progType)
fragment.texcoord[5],
fragment.texcoord[6],
fragment.texcoord[7],
+  fragment.(twelve), /* FRAG_ATTRIB_FACE */
+  fragment.(thirteen), /* FRAG_ATTRIB_PNTC */
+  fragment.(fourteen), /* FRAG_ATTRIB_CLIP_DIST0 */
+  fragment.(fifteen), /* FRAG_ATTRIB_CLIP_DIST1 */
fragment.varying[0],
fragment.varying[1],
fragment.varying[2],
@@ -149,18 +154,31 @@ arb_input_attrib_string(GLint index, GLenum progType)
fragment.varying[4],
fragment.varying[5],
fragment.varying[6],
-  fragment.varying[7]
+  fragment.varying[7],
+  fragment.varying[8],
+  fragment.varying[9],
+  fragment.varying[10],
+  fragment.varying[11],
+  fragment.varying[12],
+  fragment.varying[13],
+  fragment.varying[14],
+  fragment.varying[15] /* MAX_VARYING = 16 */
 };

 /* sanity checks */
+   STATIC_ASSERT(Elements(vertAttribs) == VERT_ATTRIB_MAX);
+   STATIC_ASSERT(Elements(fragAttribs) == FRAG_ATTRIB_MAX);
 assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], vertex.texcoord[0]) == 0);
 assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15],
vertex.attrib[15]) == 0);
+   assert(strcmp(fragAttribs[FRAG_ATTRIB_TEX0], fragment.texcoord[0]) == 0);
+   assert(strcmp(fragAttribs[FRAG_ATTRIB_VAR0+15],
fragment.varying[15]) == 0);

 if (progType == GL_VERTEX_PROGRAM_ARB) {
assert(index  Elements(vertAttribs));
return vertAttribs[index];
 }
 else {
+  assert(progType == GL_FRAGMENT_PROGRAM_ARB);
assert(index  Elements(fragAttribs));
return fragAttribs[index];
 }
@@ -213,7 +231,7 @@ arb_output_attrib_string(GLint index, GLenum progType)
 /*
  * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens.
  */
-   const char *vertResults[] = {
+   static const char *const vertResults[] = {
result.position,
result.color.primary,
result.color.secondary,
@@ -226,6 +244,13 @@ arb_output_attrib_string(GLint index, GLenum progType)
result.texcoord[5],
result.texcoord[6],
result.texcoord[7],
+  result.pointsize, /* VERT_RESULT_PSIZ */
+  result.(thirteen), /* VERT_RESULT_BFC0 */
+  result.(fourteen), /* VERT_RESULT_BFC1 */
+  result.(fifteen), /* VERT_RESULT_EDGE */
+  result.(sixteen), /* VERT_RESULT_CLIP_VERTEX */
+  result.(seventeen), /* VERT_RESULT_CLIP_DIST0 */
+  result.(eighteen), /* VERT_RESULT_CLIP_DIST1 */
result.varying[0],

Re: [Mesa-dev] [PATCH] gen_matypes: eliminate printf warnings

2011-12-09 Thread Brian Paul

On 12/09/2011 07:00 AM, nobled wrote:

The VERT_BIT_* defines are 64-bit values since commit
f364ac1da10ff67eba5196c1074aff579864f741, but the printf
was still expecting a simple int. This worked on little-endian
hosts because the values were still less than INT_MAX, but
probably would've gone bad and printed zero on big-endian ones.
---
  src/mesa/x86/gen_matypes.c |7 ++-
  1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/mesa/x86/gen_matypes.c b/src/mesa/x86/gen_matypes.c
index 648bf87..18baa29 100644
--- a/src/mesa/x86/gen_matypes.c
+++ b/src/mesa/x86/gen_matypes.c
@@ -32,6 +32,11 @@
   * Mesa, including lighting, clipping, texture image conversion etc.
   */

+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+#includeinttypes.h
+
  #include main/glheader.h
  #include main/mtypes.h
  #include tnl/t_context.h
@@ -68,7 +73,7 @@ do {  
\
 printf( #define %s\t%lu\n, s, (unsigned long) sizeof(t) );

  #define DEFINE( s, d )
\
-   printf( #define %s\t0x%x\n, s, d );
+   printf( #define %s\t0x%PRIx64\n, s, (uint64_t) d );



I'm not sure that inttypes.h exists on Windows.  We may need some 
#ifdef stuff there.


-Brian

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


Re: [Mesa-dev] [PATCH] gen_matypes: eliminate printf warnings

2011-12-09 Thread Jose Fonseca


- Original Message -
 On 12/09/2011 07:00 AM, nobled wrote:
  The VERT_BIT_* defines are 64-bit values since commit
  f364ac1da10ff67eba5196c1074aff579864f741, but the printf
  was still expecting a simple int. This worked on little-endian
  hosts because the values were still less than INT_MAX, but
  probably would've gone bad and printed zero on big-endian ones.
  ---
src/mesa/x86/gen_matypes.c |7 ++-
1 files changed, 6 insertions(+), 1 deletions(-)
 
  diff --git a/src/mesa/x86/gen_matypes.c
  b/src/mesa/x86/gen_matypes.c
  index 648bf87..18baa29 100644
  --- a/src/mesa/x86/gen_matypes.c
  +++ b/src/mesa/x86/gen_matypes.c
  @@ -32,6 +32,11 @@
 * Mesa, including lighting, clipping, texture image conversion
 etc.
 */
 
  +#ifndef __STDC_FORMAT_MACROS
  +#define __STDC_FORMAT_MACROS
  +#endif
  +#includeinttypes.h
  +
#include main/glheader.h
#include main/mtypes.h
#include tnl/t_context.h
  @@ -68,7 +73,7 @@ do {  
  \
   printf( #define %s\t%lu\n, s, (unsigned long) sizeof(t) );
 
#define DEFINE( s, d )
  \
  -   printf( #define %s\t0x%x\n, s, d );
  +   printf( #define %s\t0x%PRIx64\n, s, (uint64_t) d );
 
 
 I'm not sure that inttypes.h exists on Windows.  We may need some
 #ifdef stuff there.

We provide our own in mesa/include/c99/ so it should be ok.

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


Re: [Mesa-dev] [PATCH] gen_matypes: eliminate printf warnings

2011-12-09 Thread Brian Paul

On 12/09/2011 07:59 AM, Jose Fonseca wrote:



- Original Message -

On 12/09/2011 07:00 AM, nobled wrote:

The VERT_BIT_* defines are 64-bit values since commit
f364ac1da10ff67eba5196c1074aff579864f741, but the printf
was still expecting a simple int. This worked on little-endian
hosts because the values were still less than INT_MAX, but
probably would've gone bad and printed zero on big-endian ones.
---
   src/mesa/x86/gen_matypes.c |7 ++-
   1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/mesa/x86/gen_matypes.c
b/src/mesa/x86/gen_matypes.c
index 648bf87..18baa29 100644
--- a/src/mesa/x86/gen_matypes.c
+++ b/src/mesa/x86/gen_matypes.c
@@ -32,6 +32,11 @@
* Mesa, including lighting, clipping, texture image conversion
etc.
*/

+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+#includeinttypes.h
+
   #include main/glheader.h
   #include main/mtypes.h
   #include tnl/t_context.h
@@ -68,7 +73,7 @@ do {  
\
  printf( #define %s\t%lu\n, s, (unsigned long) sizeof(t) );

   #define DEFINE( s, d )   
\
-   printf( #define %s\t0x%x\n, s, d );
+   printf( #define %s\t0x%PRIx64\n, s, (uint64_t) d );



I'm not sure that inttypes.h exists on Windows.  We may need some
#ifdef stuff there.


We provide our own in mesa/include/c99/ so it should be ok.


Oh that's right.

BTW, there's a few other places where we want to print 64-bit values 
and use the %llx format plus (unsigned long long) casting.  But that 
generates warnings on some platforms.  I think we could fix those if 
we used the PRI macros in those places.


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


Re: [Mesa-dev] [PATCH] mesa/st: Don't modify the context draw/read buffers.

2011-12-09 Thread Brian Paul

On 12/09/2011 01:58 AM, Jose Fonseca wrote:

- Original Message -

On Fri, Dec 9, 2011 at 2:02 PM, Chia-I Wuo...@lunarg.com  wrote:

On Thu, Dec 8, 2011 at 10:00 PM,jfons...@vmware.com  wrote:

From: José Fonsecajfons...@vmware.com

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

In EGL, when an EGLSurface is created, users can specify whether
the
front or back buffer will be rendered to.  The function is used to
make a double-buffered context work with an EGLSurface whose front
buffer is supposed to be rendered to.  But I admit that the
function
is hacky.

and may be wrong for GL.  It is ok for GLES because GLES does not
have
GL_DRAW_BUFFER thus the value can be modified.


Since this is brought up, I did this experiment some time ago:

It was done using GLX and GL.

  1. create a single-buffered drawable
  2. create a context with a GLX_DOUBLEBUFFER visual
  3. make the context and drawable current
  4. query GL_DRAW_BUFFER

Mesa returned GL_BACK and nVidia's proprietary driver returned
GL_FRONT.  This difference, IMHO, comes from that Mesa uses the
visual
of the context to determine whether the context is double-buffered
or
single-buffered, while nVidia uses the visual of the drawable to
make
the decision (and at the time when the context is first made
current).

What I want to argue here is that, maybe there should be no
single-buffered or double-buffered contexts, but single-buffered or
double-buffered drawables.  Or more precisely, the type of the
context
should be determined by the type of the current drawable.  I
checked
GLX spec and it seemed that GLX_DOUBLEBUFFER applies for drawables.
Since GL 3.0, GL_DOUBLEBUFFER is also listed as one of the
framebuffer
dependent values.  That implies the state may change when the
current
drawable changes.  So it is still a correct behavior for the
drawable
to determine the type of the context.

I did not have a chance to look deeper into this due to the lack of
time.  So I may be terribly wrong here...


Thanks for the explanation.

You make a valid point: intuitively, double-buffering is a property of 
drawables and not contexts. But the specs seem to maintain the view that it is 
also a property of contexts:

- glDrawBuffer man page talks about single-buffered contexts and double-buffered 
contexts and not drawables [1]

- glXMakeCurrent says that BadMatch is generated if drawable was not created with 
the same X screen and visual as ctx [2], therefore mixing single with double buffer 
context as you did is non-standard behavior -- glxMakeCurrent should had returned 
BadMatch.  I know that on Windows this is enforced by the MS OpenGL runtime, and when 
apps want to mix double and single bufferd render they need to use double buffered 
pixelformats, and use GL_FRONT for

However eglMakeCurrent is indeed a bit more lenient, as the spec says If draw 
or read are not compatible with ctx, then an EGL_BAD_MATCH error
is generated., where the definition compatible is not really spelled out.

But at the end of the day I feel that:
a) mixing single- double- buffered drawables/visuals is non-standard, probably 
seldom used, and not worth spending much time on it, and if we do it is better 
to find a solution in Mesa core for all drivers
b) GL_(FRONT|BACK)_LEFT is definitely wrong -- it should be either GL_FRONT or 
BACK -- specially when the drawable/context are consistent on this regard which 
is the common case

Jose

[1] http://www.opengl.org/sdk/docs/man/xhtml/glDrawBuffer.xml
[2] http://www.talisman.org/opengl-1.1/Reference/glXMakeCurrent.html


I think core Mesa should be as flexible as possible when binding 
contexts to drawables, in terms of visuals/configs.  Leave it up to 
GLX/WGL/EGL/etc to enforce rules like Jose quoted.  The 
check_compatible() function in context.c should probably be (re)moved.


I think one solution here is to make initialization of the context's 
GL_DRAW_BUFFER and GL_READ_BUFFER state the responsibility of the 
context creator.  Then we could initialize the state according to the 
API (use the context's double-buffer state for GL/GLX, use the 
surface's double-buffer state for EGL).  As a fallback, upon the first 
make-current we could check if the values are still zero and set them 
according to the buffer's db/sb type.  How does that sound?


I checked the code and it turns out that ctx-Visual is _only_ used 
for initializing GL_DRAW_BUFFER and GL_READ_BUFFER.  If we change the 
initialization as I described, I think that we could get rid of 
ctx-Visual completely.


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


Re: [Mesa-dev] [PATCH] gen_matypes: eliminate printf warnings

2011-12-09 Thread Jose Fonseca
- Original Message -
 On 12/09/2011 07:59 AM, Jose Fonseca wrote:
 
 
  - Original Message -
  On 12/09/2011 07:00 AM, nobled wrote:
  The VERT_BIT_* defines are 64-bit values since commit
  f364ac1da10ff67eba5196c1074aff579864f741, but the printf
  was still expecting a simple int. This worked on little-endian
  hosts because the values were still less than INT_MAX, but
  probably would've gone bad and printed zero on big-endian ones.
  ---
 src/mesa/x86/gen_matypes.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)
 
  diff --git a/src/mesa/x86/gen_matypes.c
  b/src/mesa/x86/gen_matypes.c
  index 648bf87..18baa29 100644
  --- a/src/mesa/x86/gen_matypes.c
  +++ b/src/mesa/x86/gen_matypes.c
  @@ -32,6 +32,11 @@
  * Mesa, including lighting, clipping, texture image
  conversion
  etc.
  */
 
  +#ifndef __STDC_FORMAT_MACROS
  +#define __STDC_FORMAT_MACROS
  +#endif
  +#includeinttypes.h
  +
 #include main/glheader.h
 #include main/mtypes.h
 #include tnl/t_context.h
  @@ -68,7 +73,7 @@ do {
  \
printf( #define %s\t%lu\n, s, (unsigned long) sizeof(t)
);
 
 #define DEFINE( s, d ) 
  \
  -   printf( #define %s\t0x%x\n, s, d );
  +   printf( #define %s\t0x%PRIx64\n, s, (uint64_t) d );
 
 
  I'm not sure that inttypes.h exists on Windows.  We may need some
  #ifdef stuff there.
 
  We provide our own in mesa/include/c99/ so it should be ok.
 
 Oh that's right.
 
 BTW, there's a few other places where we want to print 64-bit values
 and use the %llx format plus (unsigned long long) casting.  But that
 generates warnings on some platforms.  I think we could fix those if
 we used the PRI macros in those places.

Sounds good. I think the mesa/include/c99/inttypes.h is fairly comprehensive. 
If not we could just add any missing bits.

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


Re: [Mesa-dev] [PATCH] mesa/st: Don't modify the context draw/read buffers.

2011-12-09 Thread Jose Fonseca


- Original Message -
 On 12/09/2011 01:58 AM, Jose Fonseca wrote:
  - Original Message -
  On Fri, Dec 9, 2011 at 2:02 PM, Chia-I Wuo...@lunarg.com  wrote:
  On Thu, Dec 8, 2011 at 10:00 PM,jfons...@vmware.com  wrote:
  From: José Fonsecajfons...@vmware.com
 
  It sets the wrong values (GL_XXX_LEFT instead of GL_XXX), and no
  other
  Mesa driver does this, given that Mesa sets the right draw/read
  buffers
  provided the Mesa visual has the doublebuffer flag filled
  correctly
  which is the case.
  In EGL, when an EGLSurface is created, users can specify whether
  the
  front or back buffer will be rendered to.  The function is used
  to
  make a double-buffered context work with an EGLSurface whose
  front
  buffer is supposed to be rendered to.  But I admit that the
  function
  is hacky.
  and may be wrong for GL.  It is ok for GLES because GLES does not
  have
  GL_DRAW_BUFFER thus the value can be modified.
 
  Since this is brought up, I did this experiment some time ago:
  It was done using GLX and GL.
1. create a single-buffered drawable
2. create a context with a GLX_DOUBLEBUFFER visual
3. make the context and drawable current
4. query GL_DRAW_BUFFER
 
  Mesa returned GL_BACK and nVidia's proprietary driver returned
  GL_FRONT.  This difference, IMHO, comes from that Mesa uses the
  visual
  of the context to determine whether the context is
  double-buffered
  or
  single-buffered, while nVidia uses the visual of the drawable to
  make
  the decision (and at the time when the context is first made
  current).
 
  What I want to argue here is that, maybe there should be no
  single-buffered or double-buffered contexts, but single-buffered
  or
  double-buffered drawables.  Or more precisely, the type of the
  context
  should be determined by the type of the current drawable.  I
  checked
  GLX spec and it seemed that GLX_DOUBLEBUFFER applies for
  drawables.
  Since GL 3.0, GL_DOUBLEBUFFER is also listed as one of the
  framebuffer
  dependent values.  That implies the state may change when the
  current
  drawable changes.  So it is still a correct behavior for the
  drawable
  to determine the type of the context.
 
  I did not have a chance to look deeper into this due to the lack
  of
  time.  So I may be terribly wrong here...
 
  Thanks for the explanation.
 
  You make a valid point: intuitively, double-buffering is a property
  of drawables and not contexts. But the specs seem to maintain the
  view that it is also a property of contexts:
 
  - glDrawBuffer man page talks about single-buffered contexts and
  double-buffered contexts and not drawables [1]
 
  - glXMakeCurrent says that BadMatch is generated if drawable was
  not created with the same X screen and visual as ctx [2],
  therefore mixing single with double buffer context as you did is
  non-standard behavior -- glxMakeCurrent should had returned
  BadMatch.  I know that on Windows this is enforced by the MS
  OpenGL runtime, and when apps want to mix double and single
  bufferd render they need to use double buffered pixelformats, and
  use GL_FRONT for
 
  However eglMakeCurrent is indeed a bit more lenient, as the spec
  says If draw or read are not compatible with ctx, then an
  EGL_BAD_MATCH error
  is generated., where the definition compatible is not really
  spelled out.
 
  But at the end of the day I feel that:
  a) mixing single- double- buffered drawables/visuals is
  non-standard, probably seldom used, and not worth spending much
  time on it, and if we do it is better to find a solution in Mesa
  core for all drivers
  b) GL_(FRONT|BACK)_LEFT is definitely wrong -- it should be either
  GL_FRONT or BACK -- specially when the drawable/context are
  consistent on this regard which is the common case
 
  Jose
 
  [1] http://www.opengl.org/sdk/docs/man/xhtml/glDrawBuffer.xml
  [2]
  http://www.talisman.org/opengl-1.1/Reference/glXMakeCurrent.html
 
 I think core Mesa should be as flexible as possible when binding
 contexts to drawables, in terms of visuals/configs.  Leave it up to
 GLX/WGL/EGL/etc to enforce rules like Jose quoted.  The
 check_compatible() function in context.c should probably be
 (re)moved.
 
 I think one solution here is to make initialization of the context's
 GL_DRAW_BUFFER and GL_READ_BUFFER state the responsibility of the
 context creator.  Then we could initialize the state according to the
 API (use the context's double-buffer state for GL/GLX, use the
 surface's double-buffer state for EGL).  As a fallback, upon the
 first
 make-current we could check if the values are still zero and set them
 according to the buffer's db/sb type.  How does that sound?

 I checked the code and it turns out that ctx-Visual is _only_ used
 for initializing GL_DRAW_BUFFER and GL_READ_BUFFER.  If we change the
 initialization as I described, I think that we could get rid of
 ctx-Visual completely.

Sounds the most flexible solution to me.  But it would not be a risk-less 

[Mesa-dev] [PATCH 1/2] st/egl: Add support for EGL_NOK_swap_region

2011-12-09 Thread Fredrik Höglund
Backends indicate that they support this extension by returning
EGL_TRUE when native_display::get_param() is called with
NATIVE_PARAM_PRESENT_REGION.

native_present_control is extended to include the region that should
be presented. When the whole surface is to be presented, this region
will be a single rect containing the dimensions of the surface.

Signed-off-by: Fredrik Höglund fred...@kde.org
---
 src/gallium/state_trackers/egl/common/egl_g3d.c|5 +++
 .../state_trackers/egl/common/egl_g3d_api.c|   31 ++-
 src/gallium/state_trackers/egl/common/native.h |   12 +++-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c 
b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 182ce68..feebfaf 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -606,6 +606,11 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy)
   dpy-Extensions.WL_bind_wayland_display = EGL_TRUE;
 #endif
 
+#ifdef EGL_NOK_swap_region
+   if (gdpy-native-get_param(gdpy-native, NATIVE_PARAM_PRESENT_REGION))
+  dpy-Extensions.NOK_swap_region = EGL_TRUE;
+#endif
+
if (egl_g3d_add_configs(drv, dpy, 1) == 1) {
   _eglError(EGL_NOT_INITIALIZED, eglInitialize(unable to add configs));
   goto fail;
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 911540e..e8f2abc 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
@@ -546,7 +546,8 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy,
 }
 
 static EGLBoolean
-egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
+swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+ EGLint num_rects, const EGLint *rects, EGLBoolean preserve)
 {
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
_EGLContext *ctx = _eglGetCurrentContext();
@@ -572,14 +573,36 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLSurface *surf)
 
memset(ctrl, 0, sizeof(ctrl));
ctrl.natt = NATIVE_ATTACHMENT_BACK_LEFT;
-   ctrl.preserve = (gsurf-base.SwapBehavior == EGL_BUFFER_PRESERVED);
+   ctrl.preserve = preserve;
ctrl.swap_interval = gsurf-base.SwapInterval;
ctrl.premultiplied_alpha = (gsurf-base.VGAlphaFormat == 
EGL_VG_ALPHA_FORMAT_PRE);
+   ctrl.num_rects = num_rects;
+   ctrl.rects = rects;
 
return gsurf-native-present(gsurf-native, ctrl);
 }
 
 static EGLBoolean
+egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
+{
+   struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+   const EGLint rect[4] = { 0, 0, gsurf-base.Width, gsurf-base.Height };
+
+   return swap_buffers(drv, dpy, surf, 1, rect,
+   (gsurf-base.SwapBehavior == EGL_BUFFER_PRESERVED));
+}
+
+#ifdef EGL_NOK_swap_region
+static EGLBoolean
+egl_g3d_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface 
*surf,
+EGLint num_rects, const EGLint *rects)
+{
+   /* Note: y=0=top */
+   return swap_buffers(drv, dpy, surf, num_rects, rects, EGL_TRUE);
+}
+#endif /* EGL_NOK_swap_region */
+
+static EGLBoolean
 egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
  EGLNativePixmapType target)
 {
@@ -867,4 +890,8 @@ egl_g3d_init_driver_api(_EGLDriver *drv)
drv-API.CreateScreenSurfaceMESA = egl_g3d_create_screen_surface;
drv-API.ShowScreenSurfaceMESA = egl_g3d_show_screen_surface;
 #endif
+
+#ifdef EGL_NOK_swap_region
+   drv-API.SwapBuffersRegionNOK = egl_g3d_swap_buffers_region;
+#endif
 }
diff --git a/src/gallium/state_trackers/egl/common/native.h 
b/src/gallium/state_trackers/egl/common/native.h
index ee24c22..f1e067e 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -81,7 +81,13 @@ enum native_param_type {
 * EGL_ALPHA_SIZE.  EGL_VG_ALPHA_FORMAT attribute of a surface will affect
 * how the surface is presented.
 */
-   NATIVE_PARAM_PREMULTIPLIED_ALPHA
+   NATIVE_PARAM_PREMULTIPLIED_ALPHA,
+
+   /**
+* Return TRUE if native_surface::present supports presenting a partial
+* surface.
+*/
+   NATIVE_PARAM_PRESENT_REGION
 };
 
 /**
@@ -99,6 +105,10 @@ struct native_present_control {
 
/** pixels use premultiplied alpha */
boolean premultiplied_alpha;
+
+   /** the region to present. y=0=top */
+   int num_rects;
+   const int *rects; /* x, y, width, height */
 };
 
 struct native_surface {
-- 
1.7.7.3

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


[Mesa-dev] [PATCH 2/2] st/egl: Implement EGL_NOK_swap_region for x11

2011-12-09 Thread Fredrik Höglund
Signed-off-by: Fredrik Höglund fred...@kde.org
---
 src/gallium/state_trackers/egl/x11/native_dri2.c |   16 +-
 src/gallium/state_trackers/egl/x11/x11_screen.c  |   24 ++
 src/gallium/state_trackers/egl/x11/x11_screen.h  |5 
 3 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c 
b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 4754744..a976dd4 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -313,21 +313,22 @@ dri2_surface_flush_frontbuffer(struct native_surface 
*nsurf)
 }
 
 static boolean
-dri2_surface_swap_buffers(struct native_surface *nsurf)
+dri2_surface_swap_buffers(struct native_surface *nsurf, int num_rects,
+  const int *rects)
 {
struct dri2_surface *dri2surf = dri2_surface(nsurf);
struct dri2_display *dri2dpy = dri2surf-dri2dpy;
 
/* copy to front buffer */
if (dri2surf-have_back)
-  x11_drawable_copy_buffers(dri2dpy-xscr, dri2surf-drawable,
-0, 0, dri2surf-width, dri2surf-height,
+  x11_drawable_copy_buffers_region(dri2dpy-xscr, dri2surf-drawable,
+num_rects, rects,
 DRI2BufferBackLeft, DRI2BufferFrontLeft);
 
/* and update fake front buffer */
if (dri2surf-have_fake)
-  x11_drawable_copy_buffers(dri2dpy-xscr, dri2surf-drawable,
-0, 0, dri2surf-width, dri2surf-height,
+  x11_drawable_copy_buffers_region(dri2dpy-xscr, dri2surf-drawable,
+num_rects, rects,
 DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
 
/* force buffers to be updated in next validation call */
@@ -354,7 +355,7 @@ dri2_surface_present(struct native_surface *nsurf,
   ret = dri2_surface_flush_frontbuffer(nsurf);
   break;
case NATIVE_ATTACHMENT_BACK_LEFT:
-  ret = dri2_surface_swap_buffers(nsurf);
+  ret = dri2_surface_swap_buffers(nsurf, ctrl-num_rects, ctrl-rects);
   break;
default:
   ret = FALSE;
@@ -722,6 +723,9 @@ dri2_display_get_param(struct native_display *ndpy,
   /* DRI2CopyRegion is used */
   val = TRUE;
   break;
+   case NATIVE_PARAM_PRESENT_REGION:
+  val = TRUE;
+  break;
case NATIVE_PARAM_MAX_SWAP_INTERVAL:
default:
   val = 0;
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c 
b/src/gallium/state_trackers/egl/x11/x11_screen.c
index 6155b4d..45b5464 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.c
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.c
@@ -341,6 +341,30 @@ x11_drawable_enable_dri2(struct x11_screen *xscr,
  * Copy between buffers of the DRI2 drawable.
  */
 void
+x11_drawable_copy_buffers_region(struct x11_screen *xscr, Drawable drawable,
+ int num_rects, const int *rects,
+ int src_buf, int dst_buf)
+{
+   XserverRegion region;
+   XRectangle *rectangles = CALLOC(num_rects, sizeof(XRectangle));
+
+   for (int i = 0; i  num_rects; i++) {
+  rectangles[i].x = rects[i * 4 + 0];
+  rectangles[i].y = rects[i * 4 + 1];
+  rectangles[i].width = rects[i * 4 + 2];
+  rectangles[i].height = rects[i * 4 + 3];
+   }
+
+   region = XFixesCreateRegion(xscr-dpy, rectangles, num_rects);
+   DRI2CopyRegion(xscr-dpy, drawable, region, dst_buf, src_buf);
+   XFixesDestroyRegion(xscr-dpy, region);
+   FREE(rectangles);
+}
+
+/**
+ * Copy between buffers of the DRI2 drawable.
+ */
+void
 x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable,
   int x, int y, int width, int height,
   int src_buf, int dst_buf)
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.h 
b/src/gallium/state_trackers/egl/x11/x11_screen.h
index acf1300..1fa3464 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.h
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.h
@@ -112,6 +112,11 @@ x11_drawable_copy_buffers(struct x11_screen *xscr, 
Drawable drawable,
   int x, int y, int width, int height,
   int src_buf, int dst_buf);
 
+void
+x11_drawable_copy_buffers_region(struct x11_screen *xscr, Drawable drawable,
+ int num_rects, const int *rects,
+ int src_buf, int dst_buf);
+
 struct x11_drawable_buffer *
 x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable,
  int *width, int *height, unsigned int *attachments,
-- 
1.7.7.3

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


Re: [Mesa-dev] [PATCH] util: Fix -Wimplicit-function-declaration for ffs with GCC

2011-12-09 Thread Kai Wasserbäch
Dear mesa-dev list,
Kai Wasserbäch schrieb am 09.12.2011 12:59:
 AFAICS GCC was missed from the last #elif clause. With this patch
 applied the warning is gone.
 
 Signed-off-by: Kai Wasserbäch k...@dev.carbon-project.org
 ---
  There certainly other warnings thrown during a build, but I saw this one
  scrolling by, while checking on a build. Hence I went to fix it.
 
  src/gallium/auxiliary/util/u_math.h |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 [...]

I just noticed, I haven't pointed out, that I don't have commit access for Mesa
and somebody else would need to commit this, if that patch is accepted.

Kind regards,
Kai Wasserbäch



-- 

Kai Wasserbäch (Kai Wasserbaech)

E-Mail: k...@dev.carbon-project.org



signature.asc
Description: OpenPGP digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] [RFC] program: fix out of bounds array accesses and other bad things

2011-12-09 Thread Matt Turner
On Fri, Dec 9, 2011 at 8:54 AM, nobled nob...@dreamwidth.org wrote:

Can you set your name in git? It makes the log look a lot better.

git config --global user.name Firstname Lastname
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 02/11] gallium: disable stream output in drivers that support it

2011-12-09 Thread Christoph Bumiller
From: Marek Olšák mar...@gmail.com

I am going to make interface changes and I don't want to break compilation.
---
 src/gallium/drivers/llvmpipe/lp_state_so.c |7 +++
 src/gallium/drivers/nvc0/nvc0_state.c  |7 +++
 src/gallium/drivers/softpipe/sp_context.c  |2 +-
 src/gallium/drivers/softpipe/sp_screen.c   |2 +-
 src/gallium/drivers/softpipe/sp_state_so.c |7 +++
 5 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_so.c 
b/src/gallium/drivers/llvmpipe/lp_state_so.c
index 30b17c9..35de52c 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_so.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_so.c
@@ -125,6 +125,7 @@ llvmpipe_set_stream_output_buffers(struct pipe_context 
*pipe,
 void
 llvmpipe_init_so_funcs(struct llvmpipe_context *llvmpipe)
 {
+#if 0
llvmpipe-pipe.create_stream_output_state =
   llvmpipe_create_stream_output_state;
llvmpipe-pipe.bind_stream_output_state =
@@ -134,4 +135,10 @@ llvmpipe_init_so_funcs(struct llvmpipe_context *llvmpipe)
 
llvmpipe-pipe.set_stream_output_buffers =
   llvmpipe_set_stream_output_buffers;
+#else
+   (void) llvmpipe_create_stream_output_state;
+   (void) llvmpipe_bind_stream_output_state;
+   (void) llvmpipe_delete_stream_output_state;
+   (void) llvmpipe_set_stream_output_buffers;
+#endif
 }
diff --git a/src/gallium/drivers/nvc0/nvc0_state.c 
b/src/gallium/drivers/nvc0/nvc0_state.c
index 1a37d04..0d6952d 100644
--- a/src/gallium/drivers/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nvc0/nvc0_state.c
@@ -871,10 +871,17 @@ nvc0_init_state_functions(struct nvc0_context *nvc0)
pipe-set_vertex_buffers = nvc0_set_vertex_buffers;
pipe-set_index_buffer = nvc0_set_index_buffer;
 
+#if 0
pipe-create_stream_output_state = nvc0_tfb_state_create;
pipe-delete_stream_output_state = nvc0_tfb_state_delete;
pipe-bind_stream_output_state = nvc0_tfb_state_bind;
pipe-set_stream_output_buffers = nvc0_set_transform_feedback_buffers;
+#else
+   (void)nvc0_tfb_state_create;
+   (void)nvc0_tfb_state_delete;
+   (void)nvc0_tfb_state_bind;
+   (void)nvc0_set_transform_feedback_buffers;
+#endif
 
pipe-redefine_user_buffer = u_default_redefine_user_buffer;
 }
diff --git a/src/gallium/drivers/softpipe/sp_context.c 
b/src/gallium/drivers/softpipe/sp_context.c
index 3a83e58..a720600 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -257,7 +257,7 @@ softpipe_create_context( struct pipe_screen *screen,
softpipe-pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
 
softpipe-pipe.draw_vbo = softpipe_draw_vbo;
-   softpipe-pipe.draw_stream_output = softpipe_draw_stream_output;
+   /* XXX softpipe-pipe.draw_stream_output = softpipe_draw_stream_output; */
 
softpipe-pipe.clear = softpipe_clear;
softpipe-pipe.flush = softpipe_flush_wrapped;
diff --git a/src/gallium/drivers/softpipe/sp_screen.c 
b/src/gallium/drivers/softpipe/sp_screen.c
index 7a09be7..ef98f25 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -106,7 +106,7 @@ softpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
   return 1;
case PIPE_CAP_STREAM_OUTPUT:
-  return 1;
+  return 0;
case PIPE_CAP_PRIMITIVE_RESTART:
   return 1;
case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE:
diff --git a/src/gallium/drivers/softpipe/sp_state_so.c 
b/src/gallium/drivers/softpipe/sp_state_so.c
index ddfa3ef..40e5634 100644
--- a/src/gallium/drivers/softpipe/sp_state_so.c
+++ b/src/gallium/drivers/softpipe/sp_state_so.c
@@ -131,10 +131,17 @@ softpipe_set_stream_output_buffers(struct pipe_context 
*pipe,
 void
 softpipe_init_streamout_funcs(struct pipe_context *pipe)
 {
+#if 0
pipe-create_stream_output_state = softpipe_create_stream_output_state;
pipe-bind_stream_output_state = softpipe_bind_stream_output_state;
pipe-delete_stream_output_state = softpipe_delete_stream_output_state;
 
pipe-set_stream_output_buffers = softpipe_set_stream_output_buffers;
+#else
+   (void) softpipe_create_stream_output_state;
+   (void) softpipe_bind_stream_output_state;
+   (void) softpipe_delete_stream_output_state;
+   (void) softpipe_set_stream_output_buffers;
+#endif
 }
 
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 06/11] trace: implement stream output interface

2011-12-09 Thread Christoph Bumiller
---
 src/gallium/drivers/trace/tr_context.c |   73 
 1 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_context.c 
b/src/gallium/drivers/trace/tr_context.c
index 6021bb9..240d85c 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -1067,6 +1067,76 @@ trace_context_set_index_buffer(struct pipe_context 
*_pipe,
trace_dump_call_end();
 }
 
+
+static INLINE struct pipe_stream_output_target *
+trace_context_create_stream_output_target(struct pipe_context *_pipe,
+  struct pipe_resource *res,
+  unsigned buffer_offset,
+  unsigned buffer_size)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx-pipe;
+   struct pipe_stream_output_target *result;
+
+   res = trace_resource_unwrap(tr_ctx, res);
+
+   trace_dump_call_begin(pipe_context, create_stream_output_target);
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(ptr, res);
+   trace_dump_arg(uint, buffer_offset);
+   trace_dump_arg(uint, buffer_size);
+
+   result = pipe-create_stream_output_target(pipe,
+  res, buffer_offset, buffer_size);
+
+   trace_dump_call_end();
+
+   return result;
+}
+
+
+static INLINE void
+trace_context_stream_output_target_destroy(
+   struct pipe_context *_pipe,
+   struct pipe_stream_output_target *target)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx-pipe;
+
+   trace_dump_call_begin(pipe_context, stream_output_target_destroy);
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(ptr, target);
+
+   pipe-stream_output_target_destroy(pipe, target);
+
+   trace_dump_call_end();
+}
+
+
+static INLINE void
+trace_context_set_stream_output_targets(struct pipe_context *_pipe,
+unsigned num_targets,
+struct pipe_stream_output_target **tgs,
+unsigned append_bitmask)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx-pipe;
+
+   trace_dump_call_begin(pipe_context, set_stream_output_targets);
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, num_targets);
+   trace_dump_arg_array(ptr, tgs, num_targets);
+   trace_dump_arg(uint, append_bitmask);
+
+   pipe-set_stream_output_targets(pipe, num_targets, tgs, append_bitmask);
+
+   trace_dump_call_end();
+}
+
+
 static INLINE void
 trace_context_resource_copy_region(struct pipe_context *_pipe,
struct pipe_resource *dst,
@@ -1528,6 +1598,9 @@ trace_context_create(struct trace_screen *tr_scr,
tr_ctx-base.surface_destroy = trace_surface_destroy;
tr_ctx-base.set_vertex_buffers = trace_context_set_vertex_buffers;
tr_ctx-base.set_index_buffer = trace_context_set_index_buffer;
+   tr_ctx-base.create_stream_output_target = 
trace_context_create_stream_output_target;
+   tr_ctx-base.stream_output_target_destroy = 
trace_context_stream_output_target_destroy;
+   tr_ctx-base.set_stream_output_targets = 
trace_context_set_stream_output_targets;
tr_ctx-base.resource_copy_region = trace_context_resource_copy_region;
tr_ctx-base.clear = trace_context_clear;
tr_ctx-base.clear_render_target = trace_context_clear_render_target;
-- 
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/11] noop: implement stream output

2011-12-09 Thread Christoph Bumiller
From: Marek Olšák mar...@gmail.com

---
 src/gallium/drivers/noop/noop_state.c |   35 +
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/noop/noop_state.c 
b/src/gallium/drivers/noop/noop_state.c
index 58ea8be..9d8dbfc 100644
--- a/src/gallium/drivers/noop/noop_state.c
+++ b/src/gallium/drivers/noop/noop_state.c
@@ -124,6 +124,7 @@ static struct pipe_surface *noop_create_surface(struct 
pipe_context *ctx,
 
return surface;
 }
+
 static void noop_set_vs_sampler_view(struct pipe_context *ctx, unsigned count,
struct pipe_sampler_view **views)
 {
@@ -244,6 +245,37 @@ static void *noop_create_shader_state(struct pipe_context 
*ctx,
return nstate;
 }
 
+static struct pipe_stream_output_target *noop_create_stream_output_target(
+  struct pipe_context *ctx,
+  struct pipe_resource *res,
+  unsigned buffer_offset,
+  unsigned buffer_size)
+{
+   struct pipe_stream_output_target *t = 
CALLOC_STRUCT(pipe_stream_output_target);
+   if (!t)
+  return NULL;
+
+   pipe_reference_init(t-reference, 1);
+   pipe_resource_reference(t-buffer, res);
+   t-buffer_offset = buffer_offset;
+   t-buffer_size = buffer_size;
+   return t;
+}
+
+static void noop_stream_output_target_destroy(struct pipe_context *ctx,
+  struct pipe_stream_output_target *t)
+{
+   pipe_resource_reference(t-buffer, NULL);
+   FREE(t);
+}
+
+static void noop_set_stream_output_targets(struct pipe_context *ctx,
+   unsigned num_targets,
+   struct pipe_stream_output_target **targets,
+   unsigned append_bitmask)
+{
+}
+
 void noop_init_state_functions(struct pipe_context *ctx);
 
 void noop_init_state_functions(struct pipe_context *ctx)
@@ -289,4 +321,7 @@ void noop_init_state_functions(struct pipe_context *ctx)
ctx-surface_destroy = noop_surface_destroy;
ctx-draw_vbo = noop_draw_vbo;
ctx-redefine_user_buffer = u_default_redefine_user_buffer;
+   ctx-create_stream_output_target = noop_create_stream_output_target;
+   ctx-stream_output_target_destroy = noop_stream_output_target_destroy;
+   ctx-set_stream_output_targets = noop_set_stream_output_targets;
 }
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 04/11] gallium: utility helper functions for stream output

2011-12-09 Thread Christoph Bumiller
From: Marek Olšák mar...@gmail.com

---
 src/gallium/auxiliary/tgsi/tgsi_ureg.c|9 +++--
 src/gallium/auxiliary/tgsi/tgsi_ureg.h|   18 ++
 src/gallium/auxiliary/util/u_debug_describe.c |   10 ++
 src/gallium/auxiliary/util/u_debug_describe.h |2 ++
 src/gallium/auxiliary/util/u_inlines.h|   12 
 src/gallium/auxiliary/util/u_simple_shaders.c |   14 +-
 src/gallium/auxiliary/util/u_simple_shaders.h |8 
 7 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index daa77ef..d3adf32 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1574,14 +1574,19 @@ const struct tgsi_token *ureg_finalize( struct 
ureg_program *ureg )
 
 
 void *ureg_create_shader( struct ureg_program *ureg,
-  struct pipe_context *pipe )
+  struct pipe_context *pipe,
+  const struct pipe_stream_output_info *so )
 {
struct pipe_shader_state state;
 
state.tokens = ureg_finalize(ureg);
if(!state.tokens)
   return NULL;
-   memset(state.stream_output, 0, sizeof(state.stream_output));
+
+   if (so)
+  state.stream_output = *so;
+   else
+  memset(state.stream_output, 0, sizeof(state.stream_output));
 
if (ureg-processor == TGSI_PROCESSOR_VERTEX)
   return pipe-create_vs_state( pipe, state );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 8f5f22e..72b837a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -37,6 +37,7 @@ extern C {
 #endif

 struct ureg_program;
+struct pipe_stream_output_info;
 
 /* Almost a tgsi_src_register, but we need to pull in the Absolute
  * flag from the _ext token.  Indirect flag always implies ADDR[0].
@@ -97,7 +98,8 @@ ureg_finalize( struct ureg_program * );
  */
 void *
 ureg_create_shader( struct ureg_program *,
-struct pipe_context *pipe );
+struct pipe_context *pipe,
+   const struct pipe_stream_output_info *so );
 
 
 /* Alternately, return the built token stream and hand ownership of
@@ -120,14 +122,22 @@ ureg_destroy( struct ureg_program * );
  * Convenience routine:
  */
 static INLINE void *
-ureg_create_shader_and_destroy( struct ureg_program *p,
-struct pipe_context *pipe )
+ureg_create_shader_with_so_and_destroy( struct ureg_program *p,
+   struct pipe_context *pipe,
+   const struct pipe_stream_output_info *so )
 {
-   void *result = ureg_create_shader( p, pipe );
+   void *result = ureg_create_shader( p, pipe, so );
ureg_destroy( p );
return result;
 }
 
+static INLINE void *
+ureg_create_shader_and_destroy( struct ureg_program *p,
+struct pipe_context *pipe )
+{
+   return ureg_create_shader_with_so_and_destroy(p, pipe, NULL);
+}
+
 
 /***
  * Build shader properties:
diff --git a/src/gallium/auxiliary/util/u_debug_describe.c 
b/src/gallium/auxiliary/util/u_debug_describe.c
index 3574acc..df73ed8 100644
--- a/src/gallium/auxiliary/util/u_debug_describe.c
+++ b/src/gallium/auxiliary/util/u_debug_describe.c
@@ -79,3 +79,13 @@ debug_describe_sampler_view(char* buf, const struct 
pipe_sampler_view *ptr)
debug_describe_resource(res, ptr-texture);
util_sprintf(buf, pipe_sampler_view%s,%s, res, 
util_format_short_name(ptr-format));
 }
+
+void
+debug_describe_so_target(char* buf,
+ const struct pipe_stream_output_target *ptr)
+{
+   char res[128];
+   debug_describe_resource(res, ptr-buffer);
+   util_sprintf(buf, pipe_stream_output_target%s,%u,%u, res,
+ptr-buffer_offset, ptr-buffer_size);
+}
diff --git a/src/gallium/auxiliary/util/u_debug_describe.h 
b/src/gallium/auxiliary/util/u_debug_describe.h
index 26d1f80..4f7882b 100644
--- a/src/gallium/auxiliary/util/u_debug_describe.h
+++ b/src/gallium/auxiliary/util/u_debug_describe.h
@@ -41,6 +41,8 @@ void debug_describe_reference(char* buf, const struct 
pipe_reference*ptr);
 void debug_describe_resource(char* buf, const struct pipe_resource *ptr);
 void debug_describe_surface(char* buf, const struct pipe_surface *ptr);
 void debug_describe_sampler_view(char* buf, const struct pipe_sampler_view 
*ptr);
+void debug_describe_so_target(char* buf,
+  const struct pipe_stream_output_target *ptr);
 
 #ifdef __cplusplus
 }
diff --git a/src/gallium/auxiliary/util/u_inlines.h 
b/src/gallium/auxiliary/util/u_inlines.h
index ddb81b5..4428390 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -136,6 +136,18 @@ pipe_sampler_view_reference(struct pipe_sampler_view 
**ptr, struct 

[Mesa-dev] [PATCH 01/11] mesa: implement DrawTransformFeedback from ARB_transform_feedback2

2011-12-09 Thread Christoph Bumiller
From: Marek Olšák mar...@gmail.com

It's like DrawArrays, but the count is taken from a transform feedback
object.

This removes DrawTransformFeedback from dd_function_table and adds the same
function to GLvertexformat (with the function parameters matching GL).

The vbo_draw_func callback has a new parameter
struct gl_transform_feedback_object *tfb_vertcount.

The rest of the code just validates states and forwards the transform
feedback object into vbo_draw_func.
---
 src/mesa/drivers/dri/i965/brw_draw.c |3 +-
 src/mesa/drivers/dri/i965/brw_draw.h |3 +-
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c |   15 +++--
 src/mesa/main/api_validate.c |   34 +
 src/mesa/main/api_validate.h |   10 +++
 src/mesa/main/dd.h   |3 +-
 src/mesa/main/mtypes.h   |2 +
 src/mesa/main/transformfeedback.c|   61 ++---
 src/mesa/main/transformfeedback.h|6 +-
 src/mesa/main/varray.h   |7 ++
 src/mesa/main/vtxfmt.c   |1 +
 src/mesa/state_tracker/st_cb_rasterpos.c |3 +-
 src/mesa/state_tracker/st_cb_xformfb.c   |   13 
 src/mesa/state_tracker/st_draw.c |4 +-
 src/mesa/state_tracker/st_draw.h |6 +-
 src/mesa/state_tracker/st_draw_feedback.c|3 +-
 src/mesa/tnl/t_draw.c|3 +-
 src/mesa/tnl/tnl.h   |3 +-
 src/mesa/vbo/vbo.h   |4 +-
 src/mesa/vbo/vbo_exec_array.c|   93 --
 src/mesa/vbo/vbo_exec_draw.c |3 +-
 src/mesa/vbo/vbo_rebase.c|3 +-
 src/mesa/vbo/vbo_save_api.c  |   11 +++
 src/mesa/vbo/vbo_save_draw.c |3 +-
 src/mesa/vbo/vbo_split_copy.c|3 +-
 src/mesa/vbo/vbo_split_inplace.c |3 +-
 26 files changed, 205 insertions(+), 98 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index bf3c95c..6627a48 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -517,7 +517,8 @@ void brw_draw_prims( struct gl_context *ctx,
 const struct _mesa_index_buffer *ib,
 GLboolean index_bounds_valid,
 GLuint min_index,
-GLuint max_index )
+GLuint max_index,
+struct gl_transform_feedback_object *tfb_vertcount )
 {
bool retval;
 
diff --git a/src/mesa/drivers/dri/i965/brw_draw.h 
b/src/mesa/drivers/dri/i965/brw_draw.h
index 1fe4172..b910419 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.h
+++ b/src/mesa/drivers/dri/i965/brw_draw.h
@@ -41,7 +41,8 @@ void brw_draw_prims( struct gl_context *ctx,
 const struct _mesa_index_buffer *ib,
 GLboolean index_bounds_valid,
 GLuint min_index,
-GLuint max_index );
+GLuint max_index,
+struct gl_transform_feedback_object *tfb_vertcount );
 
 void brw_draw_init( struct brw_context *brw );
 void brw_draw_destroy( struct brw_context *brw );
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index d8b331c..de04d18 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -219,7 +219,8 @@ TAG(vbo_render_prims)(struct gl_context *ctx, const struct 
gl_client_array **arr
  const struct _mesa_prim *prims, GLuint nr_prims,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
- GLuint min_index, GLuint max_index);
+ GLuint min_index, GLuint max_index,
+ struct gl_transform_feedback_object *tfb_vertcount);
 
 static GLboolean
 vbo_maybe_split(struct gl_context *ctx, const struct gl_client_array **arrays,
@@ -430,7 +431,8 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
  const struct _mesa_prim *prims, GLuint nr_prims,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
- GLuint min_index, GLuint max_index)
+ GLuint min_index, GLuint max_index,
+ struct gl_transform_feedback_object *tfb_vertcount)
 {
struct nouveau_render_state *render = to_render_state(ctx);
 
@@ -464,7 +466,8 @@ TAG(vbo_check_render_prims)(struct gl_context *ctx,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
-   GLuint min_index, GLuint max_index)
+   GLuint 

[Mesa-dev] [PATCH 07/11] u_blitter: restore stream output targets

2011-12-09 Thread Christoph Bumiller
From: Marek Olšák mar...@gmail.com

---
 src/gallium/auxiliary/util/u_blitter.c |   18 ++
 src/gallium/auxiliary/util/u_blitter.h |   18 ++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index f5cc5cb..c0c477b 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -109,6 +109,7 @@ struct blitter_context_priv
 
boolean has_geometry_shader;
boolean vertex_has_integers;
+   boolean has_stream_out;
 };
 
 static void blitter_draw_rectangle(struct blitter_context *blitter,
@@ -148,6 +149,7 @@ struct blitter_context *util_blitter_create(struct 
pipe_context *pipe)
ctx-base.saved_num_sampler_views = ~0;
ctx-base.saved_num_sampler_states = ~0;
ctx-base.saved_num_vertex_buffers = ~0;
+   ctx-base.saved_num_so_targets = ~0;
 
ctx-has_geometry_shader =
   pipe-screen-get_shader_param(pipe-screen, PIPE_SHADER_GEOMETRY,
@@ -155,6 +157,9 @@ struct blitter_context *util_blitter_create(struct 
pipe_context *pipe)
ctx-vertex_has_integers =
   pipe-screen-get_shader_param(pipe-screen, PIPE_SHADER_VERTEX,
  PIPE_SHADER_CAP_INTEGERS);
+   ctx-has_stream_out =
+  pipe-screen-get_param(pipe-screen,
+  PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS) != 0;
 
/* blend state objects */
memset(blend, 0, sizeof(blend));
@@ -319,6 +324,7 @@ static void blitter_check_saved_vertex_states(struct 
blitter_context_priv *ctx)
   ctx-base.saved_velem_state != INVALID_PTR 
   ctx-base.saved_vs != INVALID_PTR 
   (!ctx-has_geometry_shader || ctx-base.saved_gs != INVALID_PTR) 
+  (!ctx-has_stream_out || ctx-base.saved_num_so_targets != ~0) 
   ctx-base.saved_rs_state != INVALID_PTR);
 }
 
@@ -354,6 +360,18 @@ static void blitter_restore_vertex_states(struct 
blitter_context_priv *ctx)
   ctx-base.saved_gs = INVALID_PTR;
}
 
+   /* Stream outputs. */
+   if (ctx-has_stream_out) {
+  pipe-set_stream_output_targets(pipe,
+  ctx-base.saved_num_so_targets,
+  ctx-base.saved_so_targets, ~0);
+
+  for (i = 0; i  ctx-base.saved_num_so_targets; i++)
+ pipe_so_target_reference(ctx-base.saved_so_targets[i], NULL);
+
+  ctx-base.saved_num_so_targets = ~0;
+   }
+
/* Rasterizer. */
pipe-bind_rasterizer_state(pipe, ctx-base.saved_rs_state);
ctx-base.saved_rs_state = INVALID_PTR;
diff --git a/src/gallium/auxiliary/util/u_blitter.h 
b/src/gallium/auxiliary/util/u_blitter.h
index 3e1457a..d02cfaf 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -104,6 +104,9 @@ struct blitter_context
 
int saved_num_vertex_buffers;
struct pipe_vertex_buffer saved_vertex_buffers[PIPE_MAX_ATTRIBS];
+
+   int saved_num_so_targets;
+   struct pipe_stream_output_target *saved_so_targets[PIPE_MAX_SO_BUFFERS];
 };
 
 /**
@@ -131,6 +134,7 @@ struct pipe_context *util_blitter_get_pipe(struct 
blitter_context *blitter)
  * - vertex elements
  * - vertex shader
  * - geometry shader (if supported)
+ * - stream output targets (if supported)
  * - rasterizer state
  */
 
@@ -379,6 +383,20 @@ util_blitter_save_vertex_buffers(struct blitter_context 
*blitter,
 num_vertex_buffers);
 }
 
+static INLINE void
+util_blitter_save_so_targets(struct blitter_context *blitter,
+ int num_targets,
+ struct pipe_stream_output_target **targets)
+{
+   unsigned i;
+   assert(num_targets = Elements(blitter-saved_so_targets));
+
+   blitter-saved_num_so_targets = num_targets;
+   for (i = 0; i  num_targets; i++)
+  pipe_so_target_reference(blitter-saved_so_targets[i],
+   targets[i]);
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
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/11] u_blitter: implement copy_buffer using stream output

2011-12-09 Thread Christoph Bumiller
From: Marek Olšák mar...@gmail.com

---
 src/gallium/auxiliary/util/u_blitter.c |   87 +++-
 src/gallium/auxiliary/util/u_blitter.h |   11 
 2 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index c0c477b..3c50181 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -63,6 +63,7 @@ struct blitter_context_priv
/* Constant state objects. */
/* Vertex shaders. */
void *vs; /** Vertex shader which passes {pos, generic} to the output.*/
+   void *vs_pos_only; /** Vertex shader which passes pos to the output.*/
 
/* Fragment shaders. */
/* The shader at index i outputs color to color buffers 0,1,...,i-1. */
@@ -87,15 +88,18 @@ struct blitter_context_priv
void *dsa_keep_depth_stencil;
void *dsa_keep_depth_write_stencil;
 
+   /* Vertex elements states. */
void *velem_state;
void *velem_uint_state;
void *velem_sint_state;
+   void *velem_state_readbuf;
 
/* Sampler state. */
void *sampler_state;
 
/* Rasterizer state. */
void *rs_state;
+   void *rs_discard_state;
 
/* Viewport state. */
struct pipe_viewport_state viewport;
@@ -210,7 +214,12 @@ struct blitter_context *util_blitter_create(struct 
pipe_context *pipe)
rs_state.flatshade = 1;
ctx-rs_state = pipe-create_rasterizer_state(pipe, rs_state);
 
-   /* vertex elements state */
+   if (ctx-has_stream_out) {
+  rs_state.rasterizer_discard = 1;
+  ctx-rs_discard_state = pipe-create_rasterizer_state(pipe, rs_state);
+   }
+
+   /* vertex elements states */
memset(velem[0], 0, sizeof(velem[0]) * 2);
for (i = 0; i  2; i++) {
   velem[i].src_offset = i * 4 * sizeof(float);
@@ -234,9 +243,14 @@ struct blitter_context *util_blitter_create(struct 
pipe_context *pipe)
   ctx-velem_uint_state = pipe-create_vertex_elements_state(pipe, 2, 
velem[0]);
}
 
+   if (ctx-has_stream_out) {
+  velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+  ctx-velem_state_readbuf = pipe-create_vertex_elements_state(pipe, 1, 
velem[0]);
+   }
+
/* fragment shaders are created on-demand */
 
-   /* vertex shader */
+   /* vertex shaders */
{
   const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
   TGSI_SEMANTIC_GENERIC };
@@ -245,6 +259,20 @@ struct blitter_context *util_blitter_create(struct 
pipe_context *pipe)
  util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
  semantic_indices);
}
+   if (ctx-has_stream_out) {
+  struct pipe_stream_output_info so;
+  const uint semantic_names[] = { TGSI_SEMANTIC_POSITION };
+  const uint semantic_indices[] = { 0 };
+
+  memset(so, 0, sizeof(so));
+  so.num_outputs = 1;
+  so.output[0].register_mask = TGSI_WRITEMASK_XYZW;
+  so.stride = 4;
+
+  ctx-vs_pos_only =
+ util_make_vertex_passthrough_shader_with_so(pipe, 1, semantic_names,
+ semantic_indices, so);
+   }
 
/* set invariant vertex coordinates */
for (i = 0; i  4; i++)
@@ -274,12 +302,18 @@ void util_blitter_destroy(struct blitter_context *blitter)
pipe-delete_depth_stencil_alpha_state(pipe, 
ctx-dsa_keep_depth_write_stencil);
 
pipe-delete_rasterizer_state(pipe, ctx-rs_state);
+   if (ctx-rs_discard_state)
+  pipe-delete_rasterizer_state(pipe, ctx-rs_discard_state);
pipe-delete_vs_state(pipe, ctx-vs);
+   if (ctx-vs_pos_only)
+  pipe-delete_vs_state(pipe, ctx-vs_pos_only);
pipe-delete_vertex_elements_state(pipe, ctx-velem_state);
if (ctx-vertex_has_integers) {
   pipe-delete_vertex_elements_state(pipe, ctx-velem_sint_state);
   pipe-delete_vertex_elements_state(pipe, ctx-velem_uint_state);
}
+   if (ctx-velem_state_readbuf)
+  pipe-delete_vertex_elements_state(pipe, ctx-velem_state_readbuf);
 
for (i = 0; i  PIPE_MAX_TEXTURE_TYPES; i++) {
   if (ctx-fs_texfetch_col[i])
@@ -1178,3 +1212,52 @@ void util_blitter_custom_depth_stencil(struct 
blitter_context *blitter,
blitter_restore_fb_state(ctx);
blitter_unset_running_flag(ctx);
 }
+
+void util_blitter_copy_buffer(struct blitter_context *blitter,
+  struct pipe_resource *dst,
+  unsigned dstx,
+  struct pipe_resource *src,
+  unsigned srcx,
+  unsigned size)
+{
+   struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+   struct pipe_context *pipe = ctx-base.pipe;
+   struct pipe_vertex_buffer vb;
+   struct pipe_stream_output_target *so_target;
+
+   /* Drivers not capable of Stream Out should not call this function
+* in the first place. */
+   assert(ctx-has_stream_out);
+
+   /* Some alignment is required. */
+   if (srcx % 4 != 0 

[Mesa-dev] [PATCH 10/11] d3d1x: implement new stream output interface

2011-12-09 Thread Christoph Bumiller
---
 .../state_trackers/d3d1x/dxgi/src/dxgi_native.cpp  |4 +-
 .../state_trackers/d3d1x/gd3d11/d3d11_context.h|  104 +---
 .../state_trackers/d3d1x/gd3d11/d3d11_objects.h|   25 +-
 .../state_trackers/d3d1x/gd3d11/d3d11_screen.h |   86 ++--
 .../state_trackers/d3d1x/gd3d1x/d3d_enums.cpp  |4 +-
 .../state_trackers/d3d1x/gd3d1x/sm4_to_tgsi.cpp|   39 
 .../state_trackers/d3d1x/gd3d1x/sm4_to_tgsi.h  |1 +
 7 files changed, 213 insertions(+), 50 deletions(-)

diff --git a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp 
b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
index 5f270cd..2828389 100644
--- a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
+++ b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
@@ -846,8 +846,8 @@ struct dxgi_blitter
pipe-bind_vs_state(pipe, vs);
if(pipe-bind_gs_state)
pipe-bind_gs_state(pipe, 0);
-   if(pipe-bind_stream_output_state)
-   pipe-bind_stream_output_state(pipe, 0);
+   if(pipe-set_stream_output_targets)
+   pipe-set_stream_output_targets(pipe, 0, NULL, 0);
pipe-set_fragment_sampler_views(pipe, 1, view);
 
pipe-draw_vbo(pipe, draw);
diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h 
b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
index 4055c54..8ea7ccc 100644
--- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
+++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
@@ -58,7 +58,7 @@ struct GalliumD3D10Device : public 
GalliumD3D10ScreenImplthreadsafe
refcnt_ptrGalliumD3D11SamplerState, PtrTraits 
samplers[D3D11_STAGES][D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
refcnt_ptrGalliumD3D11Buffer, PtrTraits 
input_buffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
refcnt_ptrGalliumD3D11RenderTargetView, PtrTraits 
render_target_views[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT];
-   refcnt_ptrGalliumD3D11Buffer, PtrTraits 
so_targets[D3D11_SO_BUFFER_SLOT_COUNT];
+   refcnt_ptrGalliumD3D11Buffer, PtrTraits 
so_buffers[D3D11_SO_BUFFER_SLOT_COUNT];
 
 #if API = 11
refcnt_ptrID3D11UnorderedAccessView, PtrTraits 
cs_unordered_access_views[D3D11_PS_CS_UAV_REGISTER_COUNT];
@@ -67,7 +67,6 @@ struct GalliumD3D10Device : public 
GalliumD3D10ScreenImplthreadsafe
 
D3D11_VIEWPORT 
viewports[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE];
D3D11_RECT 
scissor_rects[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE];
-   unsigned so_offsets[D3D11_SO_BUFFER_SLOT_COUNT];
D3D11_PRIMITIVE_TOPOLOGY primitive_topology;
DXGI_FORMAT index_format;
unsigned index_offset;
@@ -88,10 +87,9 @@ struct GalliumD3D10Device : public 
GalliumD3D10ScreenImplthreadsafe
// derived state
int primitive_mode;
struct pipe_vertex_buffer 
vertex_buffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
-   struct pipe_resource* so_buffers[D3D11_SO_BUFFER_SLOT_COUNT];
+   struct pipe_stream_output_target* 
so_targets[D3D11_SO_BUFFER_SLOT_COUNT];
struct pipe_sampler_view* 
sampler_views[D3D11_STAGES][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
void* sampler_csos[D3D11_STAGES][D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
-   struct pipe_resource* buffers[D3D11_SO_BUFFER_SLOT_COUNT];
unsigned num_shader_resource_views[D3D11_STAGES];
unsigned num_samplers[D3D11_STAGES];
unsigned num_vertex_buffers;
@@ -150,8 +148,7 @@ struct GalliumD3D10Device : public 
GalliumD3D10ScreenImplthreadsafe
caps.gs = false;
caps.stages = 2;
}
-   if(!pipe-set_stream_output_buffers)
-   caps.so = false;
+   assert(!caps.so || pipe-set_stream_output_targets);
if(!pipe-set_geometry_sampler_views)
caps.stages_with_sampling =~ (1  
PIPE_SHADER_GEOMETRY);
if(!pipe-set_fragment_sampler_views)
@@ -164,7 +161,6 @@ struct GalliumD3D10Device : public 
GalliumD3D10ScreenImplthreadsafe
// pipeline state
memset(viewports, 0, sizeof(viewports));
memset(scissor_rects, 0, sizeof(scissor_rects));
-   memset(so_offsets, 0, sizeof(so_offsets));
primitive_topology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED;
index_format = DXGI_FORMAT_UNKNOWN;
index_offset = 0;
@@ -178,7 +174,7 @@ struct GalliumD3D10Device : public 
GalliumD3D10ScreenImplthreadsafe
// derived state
primitive_mode = 0;
memset(vertex_buffers, 0, sizeof(vertex_buffers));
-   memset(so_buffers, 0, sizeof(so_buffers));
+   memset(so_targets, 0, sizeof(so_buffers));
memset(sampler_views, 0, 

[Mesa-dev] [PATCH 09/11] st/mesa: implement EXT_transform_feedback and ARB_transform_feedback2

2011-12-09 Thread Christoph Bumiller
From: Marek Olšák mar...@gmail.com

---
 src/gallium/auxiliary/cso_cache/cso_context.c |  101 ++
 src/gallium/auxiliary/cso_cache/cso_context.h |8 ++
 src/gallium/auxiliary/util/u_blit.c   |6 +
 src/gallium/auxiliary/util/u_gen_mipmap.c |3 +
 src/mesa/state_tracker/st_atom_rasterizer.c   |7 +-
 src/mesa/state_tracker/st_cb_bitmap.c |3 +
 src/mesa/state_tracker/st_cb_clear.c  |3 +
 src/mesa/state_tracker/st_cb_drawpixels.c |3 +
 src/mesa/state_tracker/st_cb_drawtex.c|3 +
 src/mesa/state_tracker/st_cb_xformfb.c|  142 +++--
 src/mesa/state_tracker/st_cb_xformfb.h|   12 ++
 src/mesa/state_tracker/st_draw.c  |   12 ++-
 src/mesa/state_tracker/st_extensions.c|   15 +++
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp|   27 +
 src/mesa/state_tracker/st_glsl_to_tgsi.h  |6 +
 src/mesa/state_tracker/st_program.c   |   12 ++
 16 files changed, 326 insertions(+), 37 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index b2a2b79..49318e7 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -79,6 +79,7 @@ struct cso_context {
struct cso_cache *cache;
 
boolean has_geometry_shader;
+   boolean has_streamout;
 
struct sampler_info fragment_samplers;
struct sampler_info vertex_samplers;
@@ -89,6 +90,12 @@ struct cso_context {
uint nr_vertex_buffers_saved;
struct pipe_vertex_buffer vertex_buffers_saved[PIPE_MAX_ATTRIBS];
 
+   unsigned nr_so_targets;
+   struct pipe_stream_output_target *so_targets[PIPE_MAX_SO_BUFFERS];
+
+   unsigned nr_so_targets_saved;
+   struct pipe_stream_output_target *so_targets_saved[PIPE_MAX_SO_BUFFERS];
+
/** Current and saved state.
 * The saved state is used as a 1-deep stack.
 */
@@ -276,6 +283,10 @@ struct cso_context *cso_create_context( struct 
pipe_context *pipe )
 PIPE_SHADER_CAP_MAX_INSTRUCTIONS)  0) {
   ctx-has_geometry_shader = TRUE;
}
+   if (pipe-screen-get_param(pipe-screen,
+   PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS) != 0) {
+  ctx-has_streamout = TRUE;
+   }
 
return ctx;
 
@@ -306,6 +317,7 @@ void cso_release_all( struct cso_context *ctx )
   ctx-pipe-set_fragment_sampler_views(ctx-pipe, 0, NULL);
   if (ctx-pipe-set_vertex_sampler_views)
  ctx-pipe-set_vertex_sampler_views(ctx-pipe, 0, NULL);
+  ctx-pipe-set_stream_output_targets(ctx-pipe, 0, NULL, 0);
}
 
/* free fragment samplers, views */
@@ -332,6 +344,11 @@ void cso_release_all( struct cso_context *ctx )
 ctx-nr_vertex_buffers_saved,
 NULL, 0);
 
+   for (i = 0; i  PIPE_MAX_SO_BUFFERS; i++) {
+  pipe_so_target_reference(ctx-so_targets[i], NULL);
+  pipe_so_target_reference(ctx-so_targets_saved[i], NULL);
+   }
+
if (ctx-cache) {
   cso_cache_delete( ctx-cache );
   ctx-cache = NULL;
@@ -1311,3 +1328,87 @@ cso_restore_vertex_sampler_views(struct cso_context *ctx)
restore_sampler_views(ctx, ctx-vertex_samplers,
  ctx-pipe-set_vertex_sampler_views);
 }
+
+
+void
+cso_set_stream_outputs(struct cso_context *ctx,
+   unsigned num_targets,
+   struct pipe_stream_output_target **targets,
+   unsigned append_bitmask)
+{
+   struct pipe_context *pipe = ctx-pipe;
+   uint i;
+
+   if (!ctx-has_streamout) {
+  assert(num_targets == 0);
+  return;
+   }
+
+   if (ctx-nr_so_targets == 0  num_targets == 0) {
+  /* Nothing to do. */
+  return;
+   }
+
+   /* reference new targets */
+   for (i = 0; i  num_targets; i++) {
+  pipe_so_target_reference(ctx-so_targets[i], targets[i]);
+   }
+   /* unref extra old targets, if any */
+   for (; i  ctx-nr_so_targets; i++) {
+  pipe_so_target_reference(ctx-so_targets[i], NULL);
+   }
+
+   pipe-set_stream_output_targets(pipe, num_targets, targets,
+   append_bitmask);
+   ctx-nr_so_targets = num_targets;
+}
+
+void
+cso_save_stream_outputs(struct cso_context *ctx)
+{
+   uint i;
+
+   if (!ctx-has_streamout) {
+  return;
+   }
+
+   ctx-nr_so_targets_saved = ctx-nr_so_targets;
+
+   for (i = 0; i  ctx-nr_so_targets; i++) {
+  assert(!ctx-so_targets_saved[i]);
+  pipe_so_target_reference(ctx-so_targets_saved[i], ctx-so_targets[i]);
+   }
+}
+
+void
+cso_restore_stream_outputs(struct cso_context *ctx)
+{
+   struct pipe_context *pipe = ctx-pipe;
+   uint i;
+
+   if (!ctx-has_streamout) {
+  return;
+   }
+
+   if (ctx-nr_so_targets == 0  ctx-nr_so_targets_saved == 0) {
+  /* Nothing to do. */
+  return;
+   }
+
+   for (i = 0; i  ctx-nr_so_targets_saved; i++) {
+  pipe_so_target_reference(ctx-so_targets[i], NULL);
+  /* move 

[Mesa-dev] [PATCH 11/11] nvc0: implement new stream output interface

2011-12-09 Thread Christoph Bumiller
---
 src/gallium/drivers/nouveau/nv_object.xml.h|   13 ++-
 src/gallium/drivers/nvc0/nvc0_3d.xml.h |8 +-
 src/gallium/drivers/nvc0/nvc0_context.c|2 +-
 src/gallium/drivers/nvc0/nvc0_context.h|   25 +++--
 src/gallium/drivers/nvc0/nvc0_program.c|   43 
 src/gallium/drivers/nvc0/nvc0_program.h|   11 ++-
 src/gallium/drivers/nvc0/nvc0_push.c   |   21 +++-
 src/gallium/drivers/nvc0/nvc0_query.c  |  135 +++-
 src/gallium/drivers/nvc0/nvc0_screen.c |8 ++-
 src/gallium/drivers/nvc0/nvc0_shader_state.c   |  104 +++---
 src/gallium/drivers/nvc0/nvc0_state.c  |  118 ++--
 src/gallium/drivers/nvc0/nvc0_state_validate.c |   16 +++-
 src/gallium/drivers/nvc0/nvc0_stateobj.h   |   16 ++-
 src/gallium/drivers/nvc0/nvc0_surface.c|6 +-
 src/gallium/drivers/nvc0/nvc0_vbo.c|   35 ++
 15 files changed, 372 insertions(+), 189 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv_object.xml.h 
b/src/gallium/drivers/nouveau/nv_object.xml.h
index a5b0d04..47dc675 100644
--- a/src/gallium/drivers/nouveau/nv_object.xml.h
+++ b/src/gallium/drivers/nouveau/nv_object.xml.h
@@ -185,15 +185,18 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
 #define NV01_SUBCHAN_OBJECT0x
 
 
-#define NV84_SUBCHAN_QUERY_ADDRESS_HIGH
0x0010
+#define NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH0x0010
 
-#define NV84_SUBCHAN_QUERY_ADDRESS_LOW 0x0014
+#define NV84_SUBCHAN_SEMAPHORE_ADDRESS_LOW 0x0014
 
-#define NV84_SUBCHAN_QUERY_COUNTER 0x0018
+#define NV84_SUBCHAN_SEMAPHORE_SEQUENCE
0x0018
 
-#define NV84_SUBCHAN_QUERY_GET 0x001c
+#define NV84_SUBCHAN_SEMAPHORE_TRIGGER 0x001c
+#define NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL   0x0001
+#define NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG  0x0002
+#define NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_GEQUAL  0x0004
 
-#define NV84_SUBCHAN_QUERY_INTR
0x0020
+#define NV84_SUBCHAN_NOTIFY_INTR   0x0020
 
 #define NV84_SUBCHAN_WRCACHE_FLUSH 0x0024
 
diff --git a/src/gallium/drivers/nvc0/nvc0_3d.xml.h 
b/src/gallium/drivers/nvc0/nvc0_3d.xml.h
index a8d9108..c32fa3a 100644
--- a/src/gallium/drivers/nvc0/nvc0_3d.xml.h
+++ b/src/gallium/drivers/nvc0/nvc0_3d.xml.h
@@ -130,11 +130,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
 
 #define NVC0_3D_TFB_BUFFER_SIZE(i0)   (0x038c + 
0x20*(i0))
 
-#define NVC0_3D_TFB_PRIMITIVE_ID(i0)  (0x0390 + 
0x20*(i0))
+#define NVC0_3D_TFB_BUFFER_OFFSET(i0) (0x0390 + 
0x20*(i0))
 
-#define NVC0_3D_TFB_UNK07X0(i0)   
(0x0700 + 0x10*(i0))
-#define NVC0_3D_TFB_UNK07X0__ESIZE 0x0010
-#define NVC0_3D_TFB_UNK07X0__LEN   0x0004
+#define NVC0_3D_TFB_STREAM(i0)(0x0700 + 
0x10*(i0))
+#define NVC0_3D_TFB_STREAM__ESIZE  0x0010
+#define NVC0_3D_TFB_STREAM__LEN
0x0004
 
 #define NVC0_3D_TFB_VARYING_COUNT(i0) (0x0704 + 
0x10*(i0))
 #define NVC0_3D_TFB_VARYING_COUNT__ESIZE   0x0010
diff --git a/src/gallium/drivers/nvc0/nvc0_context.c 
b/src/gallium/drivers/nvc0/nvc0_context.c
index 2927a09..1cc1756 100644
--- a/src/gallium/drivers/nvc0/nvc0_context.c
+++ b/src/gallium/drivers/nvc0/nvc0_context.c
@@ -77,7 +77,7 @@ nvc0_context_unreference_resources(struct nvc0_context *nvc0)
}
 
for (i = 0; i  nvc0-num_tfbbufs; ++i)
-  pipe_resource_reference(nvc0-tfbbuf[i], NULL);
+  pipe_so_target_reference(nvc0-tfbbuf[i], NULL);
 }
 
 static void
diff --git a/src/gallium/drivers/nvc0/nvc0_context.h 
b/src/gallium/drivers/nvc0/nvc0_context.h
index 4435c1b..af95d1a 100644
--- a/src/gallium/drivers/nvc0/nvc0_context.h
+++ b/src/gallium/drivers/nvc0/nvc0_context.h
@@ -49,14 +49,14 @@
 #define NVC0_NEW_CONSTBUF (1  18)
 #define NVC0_NEW_TEXTURES (1  19)
 #define NVC0_NEW_SAMPLERS (1  20)
-#define NVC0_NEW_TFB  (1  21)
-#define NVC0_NEW_TFB_BUFFERS  (1  22)
+#define NVC0_NEW_TFB_TARGETS  (1  21)
 
 #define NVC0_BUFCTX_CONSTANT 0
 #define NVC0_BUFCTX_FRAME1
 #define NVC0_BUFCTX_VERTEX   2
 #define NVC0_BUFCTX_TEXTURES 3
-#define NVC0_BUFCTX_COUNT4
+#define NVC0_BUFCTX_TFB  4
+#define NVC0_BUFCTX_COUNT5
 
 struct nvc0_context {
struct nouveau_context base;
@@ -75,6 +75,7 @@ struct 

Re: [Mesa-dev] [PATCH] util: Fix -Wimplicit-function-declaration for ffs with GCC

2011-12-09 Thread Jose Fonseca


- Original Message -
 Dear mesa-dev list,
 Kai Wasserbäch schrieb am 09.12.2011 12:59:
  AFAICS GCC was missed from the last #elif clause. With this patch
  applied the warning is gone.
  
  Signed-off-by: Kai Wasserbäch k...@dev.carbon-project.org
  ---
   There certainly other warnings thrown during a build, but I saw
   this one
   scrolling by, while checking on a build. Hence I went to fix it.
  
   src/gallium/auxiliary/util/u_math.h |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
  
  [...]

The system headers should normally define thi already.

man ffs says it is defined in strings.h

Does adding

  #include strings.h

to u_math.h fixes the issue?


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


Re: [Mesa-dev] [PATCH] util: Fix -Wimplicit-function-declaration for ffs with GCC

2011-12-09 Thread Kai Wasserbäch
Dear José
Jose Fonseca schrieb am 09.12.2011 19:33:
 - Original Message -
 Dear mesa-dev list,
 Kai Wasserbäch schrieb am 09.12.2011 12:59:
 AFAICS GCC was missed from the last #elif clause. With this patch
 applied the warning is gone.

 Signed-off-by: Kai Wasserbäch k...@dev.carbon-project.org
 ---
  There certainly other warnings thrown during a build, but I saw
  this one
  scrolling by, while checking on a build. Hence I went to fix it.

  src/gallium/auxiliary/util/u_math.h |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 [...]
 
 The system headers should normally define thi already.
 
 man ffs says it is defined in strings.h
 
 Does adding
 
   #include strings.h
 
 to u_math.h fixes the issue?

yes, that seems to fix this too.

Kind regards,
Kai Wasserbäch



-- 

Kai Wasserbäch (Kai Wasserbaech)

E-Mail: k...@dev.carbon-project.org



signature.asc
Description: OpenPGP digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] R600g LLVM shader backend

2011-12-09 Thread Tom Stellard
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.

This backend is mostly based on AMD's AMDIL LLVM backend for OpenCL with a
few changes added for emitting machine code.  Currently, it passes about
99% of the piglit tests that pass with the current r600g shader backend.
Most of the failures are due to some unimplemented texture instructions.
Indirect addressing is also missing from the LLVM backend, and it relies
on the current r600g shader code to do this.

In reality, the LLVM backend does not emit actual machine code,
but rather a byte stream that is converted to struct r600_bytecode.
The final transformations are done by r600_asm.c, just like in the current
shader backend.  The LLVM backend is not optimized for VLIW, and it only
emits one instruction per group.  The optimizations in r600_asm.c are
able to do some instruction packing, but the resulting code is not yet
as good as the current backend.

The main motivation for this LLVM backend is to help bring compute/OpenCL
support to r600g by making it easier to support different compiler
frontends.  I don't have a concrete plan for integrating this into
mainline Mesa yet, but I don't expect it to be in the next release.
I would really like to make it compatible with LLVM 3.0 before it gets
merged (it only works with LLVM 2.9 now), but if compute support evolves
quickly, I might be tempted to push the 2.9 version into the master
branch.

If you are interested, test it out and let me know what you think.

Thanks,
Tom Stellard


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


[Mesa-dev] [PATCH 02/15] gallivm: Allow user to configure behavior of emit_fetch() - aos

2011-12-09 Thread Tom Stellard
In lp_bld_tgsi_aos.c, emit_fetch() the switch statement is
replaced by a call to to a function pointer, which has been added
as a field of struct lp_build_tgsi_aos_context.
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |4 ++
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c |   40 +++
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index b5b1c6e..9118a68 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -43,6 +43,7 @@
 #include tgsi/tgsi_scan.h
 
 
+struct tgsi_full_src_register;
 struct tgsi_token;
 struct tgsi_shader_info;
 struct lp_build_mask_context;
@@ -246,6 +247,9 @@ struct lp_build_tgsi_aos_context
 
struct tgsi_full_instruction *instructions;
uint max_instructions;
+
+   LLVMValueRef (*emit_fetch_switch_file_fn)(struct lp_build_tgsi_aos_context 
*,
+ const struct tgsi_full_src_register 
*);
 };
 
 
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index b968c22..3677e76 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -98,28 +98,16 @@ swizzle_scalar_aos(struct lp_build_tgsi_aos_context *bld,
return lp_build_swizzle_scalar_aos(bld-base, a, chan);
 }
 
-
-/**
- * Register fetch.
- */
 static LLVMValueRef
-emit_fetch(
+emit_fetch_switch_file(
struct lp_build_tgsi_aos_context *bld,
-   const struct tgsi_full_instruction *inst,
-   unsigned src_op)
+   const struct tgsi_full_src_register *reg)
 {
LLVMBuilderRef builder = bld-base.gallivm-builder;
struct lp_type type = bld-base.type;
-   const struct tgsi_full_src_register *reg = inst-Src[src_op];
LLVMValueRef res;
unsigned chan;
 
-   assert(!reg-Register.Indirect);
-
-   /*
-* Fetch the from the register file.
-*/
-
switch (reg-Register.File) {
case TGSI_FILE_CONSTANT:
   /*
@@ -201,6 +189,29 @@ emit_fetch(
   return bld-base.undef;
}
 
+   return res;
+
+}
+
+/**
+ * Register fetch.
+ */
+static LLVMValueRef
+emit_fetch(
+   struct lp_build_tgsi_aos_context *bld,
+   const struct tgsi_full_instruction *inst,
+   unsigned src_op)
+{
+   LLVMValueRef res;
+   const struct tgsi_full_src_register *reg = inst-Src[src_op];
+
+   assert(!reg-Register.Indirect);
+
+   /*
+* Fetch the from the register file.
+*/
+   res = bld-emit_fetch_switch_file_fn(bld, reg);
+
/*
 * Apply sign modifier.
 */
@@ -1025,6 +1036,7 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm,
bld.consts_ptr = consts_ptr;
bld.sampler = sampler;
bld.indirect_files = info-indirect_files;
+   bld.emit_fetch_switch_file_fn = emit_fetch_switch_file;
bld.instructions = (struct tgsi_full_instruction *)
   MALLOC(LP_MAX_INSTRUCTIONS * sizeof(struct 
tgsi_full_instruction));
bld.max_instructions = LP_MAX_INSTRUCTIONS;
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 03/15] gallivm: Add userdata field to struct lp_build_tgsi_aos_context

2011-12-09 Thread Tom Stellard
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 9118a68..b235e90 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -248,6 +248,10 @@ struct lp_build_tgsi_aos_context
struct tgsi_full_instruction *instructions;
uint max_instructions;
 
+   /* Allow the user to store data in this structure rather than passing it
+* to every function. */
+   void * userdata;
+
LLVMValueRef (*emit_fetch_switch_file_fn)(struct lp_build_tgsi_aos_context 
*,
  const struct tgsi_full_src_register 
*);
 };
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 04/15] gallivm: Increase visibility of some lp_bld_tgsi_aos functions

2011-12-09 Thread Tom Stellard
lp_emit_{declaration,instruction,store,fetch}_aos are now visibile
in other files.
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |   32 +
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c |  140 ---
 2 files changed, 103 insertions(+), 69 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index b235e90..12a3cac 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -43,7 +43,10 @@
 #include tgsi/tgsi_scan.h
 
 
+struct tgsi_full_declaration;
+struct tgsi_full_instruction;
 struct tgsi_full_src_register;
+struct tgsi_opcode_info;
 struct tgsi_token;
 struct tgsi_shader_info;
 struct lp_build_mask_context;
@@ -257,4 +260,33 @@ struct lp_build_tgsi_aos_context
 };
 
 
+void
+lp_emit_declaration_aos(
+   struct lp_build_tgsi_aos_context *bld,
+   const struct tgsi_full_declaration *decl);
+
+
+boolean
+lp_emit_instruction_aos(
+   struct lp_build_tgsi_aos_context *bld,
+   const struct tgsi_full_instruction *inst,
+   const struct tgsi_opcode_info *info,
+   int *pc);
+
+
+LLVMValueRef
+lp_emit_fetch_aos(
+   struct lp_build_tgsi_aos_context *bld,
+   const struct tgsi_full_instruction *inst,
+   unsigned src_op);
+
+
+void
+lp_emit_store_aos(
+   struct lp_build_tgsi_aos_context *bld,
+   const struct tgsi_full_instruction *inst,
+   unsigned index,
+   LLVMValueRef value);
+
+
 #endif /* LP_BLD_TGSI_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index 3677e76..35e8d43 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -196,8 +196,8 @@ emit_fetch_switch_file(
 /**
  * Register fetch.
  */
-static LLVMValueRef
-emit_fetch(
+LLVMValueRef
+lp_emit_fetch_aos(
struct lp_build_tgsi_aos_context *bld,
const struct tgsi_full_instruction *inst,
unsigned src_op)
@@ -241,8 +241,8 @@ emit_fetch(
 /**
  * Register store.
  */
-static void
-emit_store(
+void
+lp_emit_store_aos(
struct lp_build_tgsi_aos_context *bld,
const struct tgsi_full_instruction *inst,
unsigned index,
@@ -303,6 +303,8 @@ emit_store(
   return;
}
 
+   if (!ptr)
+  return;
/*
 * Predicate
 */
@@ -392,11 +394,11 @@ emit_tex(struct lp_build_tgsi_aos_context *bld,
 
target = inst-Texture.Texture;
 
-   coords = emit_fetch( bld, inst, 0 );
+   coords = lp_emit_fetch_aos( bld, inst, 0 );
 
if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) {
-  ddx = emit_fetch( bld, inst, 1 );
-  ddy = emit_fetch( bld, inst, 2 );
+  ddx = lp_emit_fetch_aos( bld, inst, 1 );
+  ddy = lp_emit_fetch_aos( bld, inst, 2 );
   unit = inst-Src[3].Register.Index;
}  else {
 #if 0
@@ -418,8 +420,8 @@ emit_tex(struct lp_build_tgsi_aos_context *bld,
 }
 
 
-static void
-emit_declaration(
+void
+lp_emit_declaration_aos(
struct lp_build_tgsi_aos_context *bld,
const struct tgsi_full_declaration *decl)
 {
@@ -469,8 +471,8 @@ emit_declaration(
  * Emit LLVM for one TGSI instruction.
  * \param return TRUE for success, FALSE otherwise
  */
-static boolean
-emit_instruction(
+boolean
+lp_emit_instruction_aos(
struct lp_build_tgsi_aos_context *bld,
const struct tgsi_full_instruction *inst,
const struct tgsi_opcode_info *info,
@@ -500,12 +502,12 @@ emit_instruction(
 
switch (inst-Instruction.Opcode) {
case TGSI_OPCODE_ARL:
-  src0 = emit_fetch(bld, inst, 0);
+  src0 = lp_emit_fetch_aos(bld, inst, 0);
   dst0 = lp_build_floor(bld-base, src0);
   break;
 
case TGSI_OPCODE_MOV:
-  dst0 = emit_fetch(bld, inst, 0);
+  dst0 = lp_emit_fetch_aos(bld, inst, 0);
   break;
 
case TGSI_OPCODE_LIT:
@@ -513,13 +515,13 @@ emit_instruction(
 
case TGSI_OPCODE_RCP:
/* TGSI_OPCODE_RECIP */
-  src0 = emit_fetch(bld, inst, 0);
+  src0 = lp_emit_fetch_aos(bld, inst, 0);
   dst0 = lp_build_rcp(bld-base, src0);
   break;
 
case TGSI_OPCODE_RSQ:
/* TGSI_OPCODE_RECIPSQRT */
-  src0 = emit_fetch(bld, inst, 0);
+  src0 = lp_emit_fetch_aos(bld, inst, 0);
   tmp0 = lp_build_abs(bld-base, src0);
   dst0 = lp_build_rsqrt(bld-base, tmp0);
   break;
@@ -531,14 +533,14 @@ emit_instruction(
   return FALSE;
 
case TGSI_OPCODE_MUL:
-  src0 = emit_fetch(bld, inst, 0);
-  src1 = emit_fetch(bld, inst, 1);
+  src0 = lp_emit_fetch_aos(bld, inst, 0);
+  src1 = lp_emit_fetch_aos(bld, inst, 1);
   dst0 = lp_build_mul(bld-base, src0, src1);
   break;
 
case TGSI_OPCODE_ADD:
-  src0 = emit_fetch(bld, inst, 0);
-  src1 = emit_fetch(bld, inst, 1);
+  src0 = lp_emit_fetch_aos(bld, inst, 0);
+  src1 = lp_emit_fetch_aos(bld, inst, 1);
   dst0 = lp_build_add(bld-base, src0, src1);
   break;
 
@@ -554,61 +556,61 @@ emit_instruction(
   return FALSE;
 
case TGSI_OPCODE_MIN:
-  src0 = emit_fetch(bld, 

[Mesa-dev] [PATCH 05/15] gallivm: Move struct lp_build_tgsi_soa_context to header file

2011-12-09 Thread Tom Stellard
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |   95 +++
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |   92 --
 2 files changed, 95 insertions(+), 92 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 12a3cac..2698e29 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -43,6 +43,13 @@
 #include tgsi/tgsi_scan.h
 
 
+#define CHAN_X 0
+#define CHAN_Y 1
+#define CHAN_Z 2
+#define CHAN_W 3
+#define NUM_CHANNELS 4
+
+
 struct tgsi_full_declaration;
 struct tgsi_full_instruction;
 struct tgsi_full_src_register;
@@ -211,6 +218,94 @@ lp_build_system_values_array(struct gallivm_state *gallivm,
  LLVMValueRef facing);
 
 
+struct lp_exec_mask {
+   struct lp_build_context *bld;
+
+   boolean has_mask;
+
+   LLVMTypeRef int_vec_type;
+
+   LLVMValueRef cond_stack[LP_MAX_TGSI_NESTING];
+   int cond_stack_size;
+   LLVMValueRef cond_mask;
+
+   LLVMBasicBlockRef loop_block;
+   LLVMValueRef cont_mask;
+   LLVMValueRef break_mask;
+   LLVMValueRef break_var;
+   struct {
+  LLVMBasicBlockRef loop_block;
+  LLVMValueRef cont_mask;
+  LLVMValueRef break_mask;
+  LLVMValueRef break_var;
+   } loop_stack[LP_MAX_TGSI_NESTING];
+   int loop_stack_size;
+
+   LLVMValueRef ret_mask;
+   struct {
+  int pc;
+  LLVMValueRef ret_mask;
+   } call_stack[LP_MAX_TGSI_NESTING];
+   int call_stack_size;
+
+   LLVMValueRef exec_mask;
+};
+
+
+struct lp_build_tgsi_soa_context
+{
+   struct lp_build_context base;
+
+   /* Builder for vector integer masks and indices */
+   struct lp_build_context uint_bld;
+
+   /* Builder for scalar elements of shader's data type (float) */
+   struct lp_build_context elem_bld;
+
+   LLVMValueRef consts_ptr;
+   const LLVMValueRef *pos;
+   const LLVMValueRef (*inputs)[NUM_CHANNELS];
+   LLVMValueRef (*outputs)[NUM_CHANNELS];
+
+   const struct lp_build_sampler_soa *sampler;
+
+   LLVMValueRef immediates[LP_MAX_TGSI_IMMEDIATES][NUM_CHANNELS];
+   LLVMValueRef temps[LP_MAX_TGSI_TEMPS][NUM_CHANNELS];
+   LLVMValueRef addr[LP_MAX_TGSI_ADDRS][NUM_CHANNELS];
+   LLVMValueRef preds[LP_MAX_TGSI_PREDS][NUM_CHANNELS];
+
+   /* We allocate/use this array of temps if (1  TGSI_FILE_TEMPORARY) is
+* set in the indirect_files field.
+* The temps[] array above is unused then.
+*/
+   LLVMValueRef temps_array;
+
+   /* We allocate/use this array of output if (1  TGSI_FILE_OUTPUT) is
+* set in the indirect_files field.
+* The outputs[] array above is unused then.
+*/
+   LLVMValueRef outputs_array;
+
+   /* We allocate/use this array of inputs if (1  TGSI_FILE_INPUT) is
+* set in the indirect_files field.
+* The inputs[] array above is unused then.
+*/
+   LLVMValueRef inputs_array;
+
+   LLVMValueRef system_values_array;
+
+   const struct tgsi_shader_info *info;
+   /** bitmask indicating which register files are accessed indirectly */
+   unsigned indirect_files;
+
+   struct lp_build_mask_context *mask;
+   struct lp_exec_mask exec_mask;
+
+   struct tgsi_full_instruction *instructions;
+   uint max_instructions;
+};
+
+
 struct lp_build_tgsi_aos_context
 {
struct lp_build_context base;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 40744e3..67592ee 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -75,101 +75,9 @@
FOR_EACH_CHANNEL( CHAN )\
   IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )
 
-#define CHAN_X 0
-#define CHAN_Y 1
-#define CHAN_Z 2
-#define CHAN_W 3
-#define NUM_CHANNELS 4
-
 #define LP_MAX_INSTRUCTIONS 256
 
 
-struct lp_exec_mask {
-   struct lp_build_context *bld;
-
-   boolean has_mask;
-
-   LLVMTypeRef int_vec_type;
-
-   LLVMValueRef cond_stack[LP_MAX_TGSI_NESTING];
-   int cond_stack_size;
-   LLVMValueRef cond_mask;
-
-   LLVMBasicBlockRef loop_block;
-   LLVMValueRef cont_mask;
-   LLVMValueRef break_mask;
-   LLVMValueRef break_var;
-   struct {
-  LLVMBasicBlockRef loop_block;
-  LLVMValueRef cont_mask;
-  LLVMValueRef break_mask;
-  LLVMValueRef break_var;
-   } loop_stack[LP_MAX_TGSI_NESTING];
-   int loop_stack_size;
-
-   LLVMValueRef ret_mask;
-   struct {
-  int pc;
-  LLVMValueRef ret_mask;
-   } call_stack[LP_MAX_TGSI_NESTING];
-   int call_stack_size;
-
-   LLVMValueRef exec_mask;
-};
-
-struct lp_build_tgsi_soa_context
-{
-   struct lp_build_context base;
-
-   /* Builder for vector integer masks and indices */
-   struct lp_build_context uint_bld;
-
-   /* Builder for scalar elements of shader's data type (float) */
-   struct lp_build_context elem_bld;
-
-   LLVMValueRef consts_ptr;
-   const LLVMValueRef *pos;
-   const LLVMValueRef (*inputs)[NUM_CHANNELS];
-   LLVMValueRef (*outputs)[NUM_CHANNELS];
-
-   const struct lp_build_sampler_soa *sampler;

[Mesa-dev] [PATCH 06/15] gallivm: Allow user to configure behavior of emit_fetch() - soa

2011-12-09 Thread Tom Stellard
 In lp_bld_tgsi_soa.c, emit_fetch() the switch statement is
 replaced by a call to to a function pointer, which has been added
 as a field of struct lp_build_tgsi_aos_context.
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |4 ++
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |   46 ++
 2 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 2698e29..cabf907 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -303,6 +303,10 @@ struct lp_build_tgsi_soa_context
 
struct tgsi_full_instruction *instructions;
uint max_instructions;
+
+   LLVMValueRef (*emit_fetch_switch_file_fn)(struct lp_build_tgsi_soa_context 
*,
+ const struct tgsi_full_src_register *,
+ const unsigned);
 };
 
 
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 67592ee..3b06c87 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -532,30 +532,18 @@ get_indirect_index(struct lp_build_tgsi_soa_context *bld,
return index;
 }
 
-
-/**
- * Register fetch.
- */
 static LLVMValueRef
-emit_fetch(
+emit_fetch_switch_file(
struct lp_build_tgsi_soa_context *bld,
-   const struct tgsi_full_instruction *inst,
-   unsigned src_op,
-   const unsigned chan_index )
+   const struct tgsi_full_src_register *reg,
+   const unsigned swizzle)
+
 {
struct gallivm_state *gallivm = bld-base.gallivm;
LLVMBuilderRef builder = gallivm-builder;
struct lp_build_context *uint_bld = bld-uint_bld;
-   const struct tgsi_full_src_register *reg = inst-Src[src_op];
-   const unsigned swizzle =
-  tgsi_util_get_full_src_register_swizzle(reg, chan_index);
-   LLVMValueRef res;
LLVMValueRef indirect_index = NULL;
-
-   if (swizzle  3) {
-  assert(0  invalid swizzle in emit_fetch());
-  return bld-base.undef;
-   }
+   LLVMValueRef res;
 
if (reg-Register.Indirect) {
   indirect_index = get_indirect_index(bld,
@@ -690,6 +678,29 @@ emit_fetch(
   assert(0  invalid src register in emit_fetch());
   return bld-base.undef;
}
+   return res;
+}
+/**
+ * Register fetch.
+ */
+static LLVMValueRef
+emit_fetch(
+   struct lp_build_tgsi_soa_context *bld,
+   const struct tgsi_full_instruction *inst,
+   unsigned src_op,
+   const unsigned chan_index )
+{
+   const struct tgsi_full_src_register *reg = inst-Src[src_op];
+   const unsigned swizzle =
+  tgsi_util_get_full_src_register_swizzle(reg, chan_index);
+   LLVMValueRef res;
+
+   if (swizzle  3) {
+  assert(0  invalid swizzle in emit_fetch());
+  return bld-base.undef;
+   }
+
+   res = bld-emit_fetch_switch_file_fn(bld, reg, swizzle);
 
if (reg-Register.Absolute) {
   res = lp_build_abs( bld-base, res );
@@ -2282,6 +2293,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
bld.sampler = sampler;
bld.info = info;
bld.indirect_files = info-indirect_files;
+   bld.emit_fetch_switch_file_fn = emit_fetch_switch_file;
bld.instructions = (struct tgsi_full_instruction *)
   MALLOC( LP_MAX_INSTRUCTIONS * sizeof(struct 
tgsi_full_instruction) );
bld.max_instructions = LP_MAX_INSTRUCTIONS;
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 07/15] gallivm: Add userdata field to struct lp_build_tgsi_soa_context

2011-12-09 Thread Tom Stellard
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index cabf907..be017c9 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -304,6 +304,10 @@ struct lp_build_tgsi_soa_context
struct tgsi_full_instruction *instructions;
uint max_instructions;
 
+   /* Allow the user to store data in this structure rather than passing it
+* to every function. */
+   void * userdata;
+
LLVMValueRef (*emit_fetch_switch_file_fn)(struct lp_build_tgsi_soa_context 
*,
  const struct tgsi_full_src_register *,
  const unsigned);
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 08/15] gallivm: Increase visibility of some lp_bld_tgsi_soa functions

2011-12-09 Thread Tom Stellard
lp_emit_{declaration,instruction,store,fetch,get_temp_ptr}_soa
are now visibile in other files.

Add lp_get_temp_ptr_soa to header, squash with previous commit.
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |   37 
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |  264 +++---
 2 files changed, 169 insertions(+), 132 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index be017c9..04d5a72 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -313,6 +313,43 @@ struct lp_build_tgsi_soa_context
  const unsigned);
 };
 
+void
+lp_emit_declaration_soa(
+   struct lp_build_tgsi_soa_context *bld,
+   const struct tgsi_full_declaration *decl);
+
+
+boolean
+lp_emit_instruction_soa(
+   struct lp_build_tgsi_soa_context *bld,
+   const struct tgsi_full_instruction *inst,
+   const struct tgsi_opcode_info *info,
+   int *pc);
+
+
+LLVMValueRef
+lp_emit_fetch_soa(
+   struct lp_build_tgsi_soa_context *bld,
+   const struct tgsi_full_instruction *inst,
+   unsigned src_op,
+   const unsigned chan_index );
+
+
+void
+lp_emit_store_soa(
+   struct lp_build_tgsi_soa_context *bld,
+   const struct tgsi_full_instruction *inst,
+   unsigned index,
+   unsigned chan_index,
+   LLVMValueRef pred,
+   LLVMValueRef value);
+
+LLVMValueRef
+lp_get_temp_ptr_soa(
+   struct lp_build_tgsi_soa_context *bld,
+   unsigned index,
+   unsigned chan);
+
 
 struct lp_build_tgsi_aos_context
 {
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 3b06c87..c09a8d7 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -362,8 +362,8 @@ static void lp_exec_mask_endsub(struct lp_exec_mask *mask, 
int *pc)
  * \param index  which temporary register
  * \param chan  which channel of the temp register.
  */
-static LLVMValueRef
-get_temp_ptr(struct lp_build_tgsi_soa_context *bld,
+LLVMValueRef
+lp_get_temp_ptr_soa(struct lp_build_tgsi_soa_context *bld,
  unsigned index,
  unsigned chan)
 {
@@ -650,7 +650,7 @@ emit_fetch_switch_file(
   }
   else {
  LLVMValueRef temp_ptr;
- temp_ptr = get_temp_ptr(bld, reg-Register.Index, swizzle);
+ temp_ptr = lp_get_temp_ptr_soa(bld, reg-Register.Index, swizzle);
  res = LLVMBuildLoad(builder, temp_ptr, );
  if (!res)
 return bld-base.undef;
@@ -683,8 +683,8 @@ emit_fetch_switch_file(
 /**
  * Register fetch.
  */
-static LLVMValueRef
-emit_fetch(
+LLVMValueRef
+lp_emit_fetch_soa(
struct lp_build_tgsi_soa_context *bld,
const struct tgsi_full_instruction *inst,
unsigned src_op,
@@ -729,7 +729,7 @@ emit_fetch_deriv(
 {
LLVMValueRef src;
 
-   src = emit_fetch(bld, inst, index, chan_index);
+   src = lp_emit_fetch_soa(bld, inst, index, chan_index);
 
if(res)
   *res = src;
@@ -815,8 +815,8 @@ emit_fetch_predicate(
 /**
  * Register store.
  */
-static void
-emit_store(
+void
+lp_emit_store_soa(
struct lp_build_tgsi_soa_context *bld,
const struct tgsi_full_instruction *inst,
unsigned index,
@@ -937,7 +937,7 @@ emit_store(
bld-exec_mask, pred);
   }
   else {
- LLVMValueRef temp_ptr = get_temp_ptr(bld, reg-Register.Index,
+ LLVMValueRef temp_ptr = lp_get_temp_ptr_soa(bld, reg-Register.Index,
   chan_index);
  lp_exec_mask_store(bld-exec_mask, pred, value, temp_ptr);
   }
@@ -1014,12 +1014,12 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
}
 
if (modifier == LP_BLD_TEX_MODIFIER_LOD_BIAS) {
-  lod_bias = emit_fetch( bld, inst, 0, 3 );
+  lod_bias = lp_emit_fetch_soa( bld, inst, 0, 3 );
   explicit_lod = NULL;
}
else if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_LOD) {
   lod_bias = NULL;
-  explicit_lod = emit_fetch( bld, inst, 0, 3 );
+  explicit_lod = lp_emit_fetch_soa( bld, inst, 0, 3 );
}
else {
   lod_bias = NULL;
@@ -1027,12 +1027,12 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
}
 
if (modifier == LP_BLD_TEX_MODIFIER_PROJECTED) {
-  oow = emit_fetch( bld, inst, 0, 3 );
+  oow = lp_emit_fetch_soa( bld, inst, 0, 3 );
   oow = lp_build_rcp(bld-base, oow);
}
 
for (i = 0; i  num_coords; i++) {
-  coords[i] = emit_fetch( bld, inst, 0, i );
+  coords[i] = lp_emit_fetch_soa( bld, inst, 0, i );
   if (modifier == LP_BLD_TEX_MODIFIER_PROJECTED)
  coords[i] = lp_build_mul(bld-base, coords[i], oow);
}
@@ -1043,8 +1043,8 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) {
   LLVMValueRef index0 = lp_build_const_int32(bld-base.gallivm, 0);
   for (i = 0; i  num_coords; i++) {
- LLVMValueRef src1 = 

[Mesa-dev] [PATCH 09/15] gallivm: Move duplicate LP_MAX_INSTRUCTIONS def into common headers

2011-12-09 Thread Tom Stellard
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |2 ++
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c |3 ---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |2 --
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 04d5a72..5d31318 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -49,6 +49,8 @@
 #define CHAN_W 3
 #define NUM_CHANNELS 4
 
+#define LP_MAX_INSTRUCTIONS 256
+
 
 struct tgsi_full_declaration;
 struct tgsi_full_instruction;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index 35e8d43..f9d1942 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -58,9 +58,6 @@
 #include lp_bld_debug.h
 
 
-#define LP_MAX_INSTRUCTIONS 256
-
-
 /**
  * Wrapper around lp_build_swizzle_aos which translates swizzles to another 
  * ordering.
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index c09a8d7..f504fed 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -75,8 +75,6 @@
FOR_EACH_CHANNEL( CHAN )\
   IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )
 
-#define LP_MAX_INSTRUCTIONS 256
-
 
 static void lp_exec_mask_init(struct lp_exec_mask *mask, struct 
lp_build_context *bld)
 {
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 10/15] gallivm: Allow user to supply the swizzle function to lp_bld_tgsi_aos

2011-12-09 Thread Tom Stellard
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |2 ++
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c |5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 5d31318..e8b73e5 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -399,6 +399,8 @@ struct lp_build_tgsi_aos_context
 
LLVMValueRef (*emit_fetch_switch_file_fn)(struct lp_build_tgsi_aos_context 
*,
  const struct tgsi_full_src_register 
*);
+   LLVMValueRef (*emit_swizzle)(struct lp_build_tgsi_aos_context *,
+ LLVMValueRef, unsigned, unsigned, unsigned, unsigned);
 };
 
 
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index f9d1942..bf623ca 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -225,7 +225,7 @@ lp_emit_fetch_aos(
 * Swizzle the argument
 */
 
-   res = swizzle_aos(bld, res,
+   res = bld-emit_swizzle(bld, res,
  reg-Register.SwizzleX,
  reg-Register.SwizzleY,
  reg-Register.SwizzleZ,
@@ -327,7 +327,7 @@ lp_emit_store_aos(
  pred = LLVMBuildNot(builder, pred, );
   }
 
-  pred = swizzle_aos(bld, pred,
+  pred = bld-emit_swizzle(bld, pred,
  inst-Predicate.SwizzleX,
  inst-Predicate.SwizzleY,
  inst-Predicate.SwizzleZ,
@@ -1039,6 +1039,7 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm,
bld.instructions = (struct tgsi_full_instruction *)
   MALLOC(LP_MAX_INSTRUCTIONS * sizeof(struct 
tgsi_full_instruction));
bld.max_instructions = LP_MAX_INSTRUCTIONS;
+   bld.emit_swizzle = swizzle_aos;
 
if (!bld.instructions) {
   return;
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 11/15] gallivm: Refactor identical code out of lp_bld_tgsi_{aos, soa}.c

2011-12-09 Thread Tom Stellard
The code to create and add the list of tgsi instructions is now in
lp_bld_tgsi.c.
---
 src/gallium/auxiliary/Makefile.sources  |1 +
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.c |   71 +++
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |   19 +-
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c |   36 ++--
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |   37 ++--
 5 files changed, 99 insertions(+), 65 deletions(-)
 create mode 100644 src/gallium/auxiliary/gallivm/lp_bld_tgsi.c

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index d40b954..eb4f2d5 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -175,6 +175,7 @@ GALLIVM_SOURCES := \
 gallivm/lp_bld_sample_soa.c \
 gallivm/lp_bld_struct.c \
 gallivm/lp_bld_swizzle.c \
+   gallivm/lp_bld_tgsi.c \
 gallivm/lp_bld_tgsi_aos.c \
 gallivm/lp_bld_tgsi_info.c \
 gallivm/lp_bld_tgsi_soa.c \
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
new file mode 100644
index 000..5a7c5ac
--- /dev/null
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright 2010 VMware, Inc.
+ * Copyright 2009 VMware, Inc.
+ * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 gallivm/lp_bld_tgsi.h
+#include tgsi/tgsi_parse.h
+#include util/u_memory.h
+
+/* The user is responsible for freeing list-instructions */
+unsigned lp_bld_tgsi_list_init(struct lp_build_tgsi_inst_list * list)
+{
+   list-instructions = (struct tgsi_full_instruction *)
+ MALLOC( LP_MAX_INSTRUCTIONS * sizeof(struct tgsi_full_instruction) );
+   if (!list-instructions) {
+  return 0;
+   }
+   list-max_instructions = LP_MAX_INSTRUCTIONS;
+   return 1;
+}
+
+
+unsigned lp_bld_tgsi_add_instruction(
+   struct lp_build_tgsi_inst_list * list,
+   struct tgsi_full_instruction *inst_to_add)
+{
+
+   if (list-num_instructions == list-max_instructions) {
+  struct tgsi_full_instruction *instructions;
+  instructions = REALLOC(list-instructions, list-max_instructions
+  * sizeof(struct tgsi_full_instruction),
+  (list-max_instructions + 
LP_MAX_INSTRUCTIONS)
+  * sizeof(struct tgsi_full_instruction));
+  if (!instructions) {
+ return 0;
+  }
+  list-instructions = instructions;
+  list-max_instructions += LP_MAX_INSTRUCTIONS;
+   }
+   memcpy(list-instructions + list-num_instructions, inst_to_add,
+  sizeof(list-instructions[0]));
+
+   list-num_instructions++;
+
+   return 1;
+}
+
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index e8b73e5..ec366ca 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -253,6 +253,19 @@ struct lp_exec_mask {
LLVMValueRef exec_mask;
 };
 
+struct lp_build_tgsi_inst_list
+{
+   struct tgsi_full_instruction *instructions;
+   uint max_instructions;
+   uint num_instructions;
+};
+
+unsigned lp_bld_tgsi_list_init(struct lp_build_tgsi_inst_list * list);
+
+
+unsigned lp_bld_tgsi_add_instruction(
+   struct lp_build_tgsi_inst_list * list,
+   struct tgsi_full_instruction *inst_to_add);
 
 struct lp_build_tgsi_soa_context
 {
@@ -303,8 +316,7 @@ struct lp_build_tgsi_soa_context
struct lp_build_mask_context *mask;
struct lp_exec_mask exec_mask;
 
-   struct tgsi_full_instruction *instructions;
-   uint max_instructions;
+   

[Mesa-dev] [PATCH 12/15] gallivm: Allow user to define the load_store() function

2011-12-09 Thread Tom Stellard
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |9 +
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c |3 ++-
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |3 ++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index ec366ca..554b4cb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -325,6 +325,10 @@ struct lp_build_tgsi_soa_context
LLVMValueRef (*emit_fetch_switch_file_fn)(struct lp_build_tgsi_soa_context 
*,
  const struct tgsi_full_src_register *,
  const unsigned);
+
+   void (*emit_store)(struct lp_build_tgsi_soa_context *,
+  const struct tgsi_full_instruction *, unsigned,
+  unsigned, LLVMValueRef,  LLVMValueRef);
 };
 
 void
@@ -410,6 +414,11 @@ struct lp_build_tgsi_aos_context
 
LLVMValueRef (*emit_fetch_switch_file_fn)(struct lp_build_tgsi_aos_context 
*,
  const struct tgsi_full_src_register 
*);
+
+   void (*emit_store)(struct lp_build_tgsi_aos_context *,
+  const struct tgsi_full_instruction *,
+  unsigned,  LLVMValueRef);
+
LLVMValueRef (*emit_swizzle)(struct lp_build_tgsi_aos_context *,
  LLVMValueRef, unsigned, unsigned, unsigned, unsigned);
 };
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index 5f88eca..7bd59eb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -995,7 +995,7 @@ lp_emit_instruction_aos(
}

if (info-num_dst) {
-  lp_emit_store_aos(bld, inst, 0, dst0);
+  bld-emit_store(bld, inst, 0, dst0);
}
 
return TRUE;
@@ -1035,6 +1035,7 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm,
bld.sampler = sampler;
bld.indirect_files = info-indirect_files;
bld.emit_fetch_switch_file_fn = emit_fetch_switch_file;
+   bld.emit_store = lp_emit_store_aos;
bld.emit_swizzle = swizzle_aos;
 
if (!lp_bld_tgsi_list_init(bld.inst_list)) {
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 93968e7..419d5b4 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -2242,7 +2242,7 @@ lp_emit_instruction_soa(
   emit_fetch_predicate( bld, inst, pred );
 
   FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) {
- lp_emit_store_soa( bld, inst, 0, chan_index, pred[chan_index], 
dst0[chan_index]);
+ bld-emit_store( bld, inst, 0, chan_index, pred[chan_index], 
dst0[chan_index]);
   }
}
 
@@ -2291,6 +2291,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
bld.info = info;
bld.indirect_files = info-indirect_files;
bld.emit_fetch_switch_file_fn = emit_fetch_switch_file;
+   bld.emit_store = lp_emit_store_soa;
 
if (!lp_bld_tgsi_list_init(bld.inst_list)) {
   return;
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 13/15] gallivm: Move tgsi_soa helper macros to header file

2011-12-09 Thread Tom Stellard
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h |   12 
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |   14 --
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 554b4cb..1258620 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -51,6 +51,18 @@
 
 #define LP_MAX_INSTRUCTIONS 256
 
+#define FOR_EACH_CHANNEL( CHAN )\
+   for (CHAN = 0; CHAN  NUM_CHANNELS; CHAN++)
+
+#define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
+   ((INST)-Dst[0].Register.WriteMask  (1  (CHAN)))
+
+#define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
+   if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
+
+#define FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\
+   FOR_EACH_CHANNEL( CHAN )\
+  IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )
 
 struct tgsi_full_declaration;
 struct tgsi_full_instruction;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 419d5b4..be4ddef 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -62,20 +62,6 @@
 #include lp_bld_printf.h
 
 
-#define FOR_EACH_CHANNEL( CHAN )\
-   for (CHAN = 0; CHAN  NUM_CHANNELS; CHAN++)
-
-#define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
-   ((INST)-Dst[0].Register.WriteMask  (1  (CHAN)))
-
-#define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
-   if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
-
-#define FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\
-   FOR_EACH_CHANNEL( CHAN )\
-  IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )
-
-
 static void lp_exec_mask_init(struct lp_exec_mask *mask, struct 
lp_build_context *bld)
 {
mask-bld = bld;
-- 
1.7.6.4

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


[Mesa-dev] [Bug 43678] New: Compilation error for OSMesa 7.10

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

 Bug #: 43678
   Summary: Compilation error for OSMesa 7.10
Classification: Unclassified
   Product: Mesa
   Version: 7.10
  Platform: x86 (IA32)
OS/Version: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Other
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: excol...@gmail.com


Getting the following compilation (using gcc-4.4.5 20110214) errors while
compiling OSMesa:

main/transformfeedback.c:43: error: expected identifier or ‘(’ before ‘/’ token
main/transformfeedback.c:43: error: stray ‘#’ in program
make[3]: *** [main/transformfeedback.o] Error 1
make[3]: Leaving directory `/data/kozaka/gerris-suite/Mesa-7.10/src/mesa'
make[2]: *** [subdirs] Error 1
make[2]: Leaving directory `/data/kozaka/gerris-suite/Mesa-7.10/src'
make[1]: *** [default] Error 1
make[1]: Leaving directory `/data/kozaka/gerris-suite/Mesa-7.10'
make: *** [linux-osmesa32] Error 2


same error in src/mesa/state_tracker/st_context.h line:1
  src/glsl/glcpp/pp.c line:79  

I am no expert in C or C++ but I replaced the // with /* -- */ and the
compilation was completed without any problems.

-- 
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] mesa: add const flags to skip MaxVarying and MaxUniform linker checks

2011-12-09 Thread Marek Olšák
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.

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

The second one is:
- Remove the Mesa IR.
- Replace TGSI by the GLSL IR completely.
- Move the dead-constant elimination pass from the R300 compiler
  to the GLSL IR.
- Implement a GLSL optimization pass which breaks varying arrays
  into separate elements when possible.

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);
@@ -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
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -224,6 +224,14 @@ void st_init_limits(struct st_context *st)
c-UniformBooleanTrue = ~0;
 
c-StripTextureBorder = GL_TRUE;
+
+   c-GLSLSKipStrictMaxUniformLimitCheck =
+  screen-get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+   PIPE_SHADER_CAP_MAX_CONSTS) = 256;
+
+   c-GLSLSkipStrictMaxVaryingLimitCheck =
+  screen-get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+   PIPE_SHADER_CAP_MAX_INPUTS) = 10;
 }
 
 
-- 
1.7.5.4

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