Re: [Mesa-dev] [PATCH 1/4] Use INV_SQRT instead of 1/SQRTF

2012-07-20 Thread Kenneth Graunke
On 07/20/2012 04:15 PM, Matt Turner wrote:
> On Fri, Jul 20, 2012 at 3:29 PM, Kenneth Graunke  
> wrote:
>> On 07/20/2012 11:24 AM, Matt Turner wrote:
>>> ---
>>>  src/mesa/math/m_debug_norm.c |4 ++--
>>>  src/mesa/tnl/t_vb_points.c   |2 +-
>>>  2 files changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c
>>> index 02eb1f9..dc768f3 100644
>>> --- a/src/mesa/math/m_debug_norm.c
>>> +++ b/src/mesa/math/m_debug_norm.c
>>> @@ -165,7 +165,7 @@ static void ref_norm_transform_normalize( const 
>>> GLmatrix *mat,
>>>   /* Hmmm, don't know how we could test the precalculated
>>>* length case...
>>>*/
>>> -scale = 1.0 / SQRTF( len );
>>> +scale = INV_SQRTF( len );
>>>   SCALE_SCALAR_3V( out[i], scale, t );
>>>   } else {
>>>  out[i][0] = out[i][1] = out[i][2] = 0;
>>> @@ -241,7 +241,7 @@ static int test_norm_function( normal_func func, int 
>>> mtype, long *cycles )
>>>ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
>>>for ( j = 0 ; j < 3 ; j++ )
>>>   s[i][j] = rnd();
>>> -  length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
>>> +  length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
>>> }
>>>
>>> source->data = (GLfloat(*)[4]) s;
>>> diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c
>>> index 9edbbc7..0e33b69 100644
>>> --- a/src/mesa/tnl/t_vb_points.c
>>> +++ b/src/mesa/tnl/t_vb_points.c
>>> @@ -64,7 +64,7 @@ run_point_stage(struct gl_context *ctx, struct 
>>> tnl_pipeline_stage *stage)
>>>for (i = 0; i < VB->Count; i++) {
>>>   const GLfloat dist = FABSF(*eyeCoord);
>>>   const GLfloat q = p0 + dist * (p1 + dist * p2);
>>> - const GLfloat atten = (q != 0.0F) ? SQRTF(1.0F / q) : 1.0F;
>>> + const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F;
>>>   size[i][0] = pointSize * atten; /* clamping done in rasterization 
>>> */
>>>   eyeCoord += eyeCoordStride;
>>>}
>>
>> Why change this?  I don't see why the new version is any better.  More
>> precise, maybe?
>>
>> Also, why use INV_SQRT rather than just leaving all of these as 1.0 / SQRTF?
> 
> Really just because of the annoyance of having an INV_SQRTF macro and
> then seeing 1.0 / SQRTF in the code. There's no functional change.
> 
> I thought about getting rid of SQRTF/INV_SQRTF but that was sort of a
> hassle, and there is some possibility that they could be useful in the
> future if we had some optimized routines.

Yeah, okay, that's what I figured.  I don't really care either way, so
feel free to go ahead with this unless somebody else objects. :)

Reviewed-by: Kenneth Graunke 


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


[Mesa-dev] [PATCH 2/2] glxgears: Add support for multisample visuals

2012-07-20 Thread Chad Versace
Add a command line parameter, `-sample N`, which selects a visual with at
least N samples.

CC: Paul Berry 
Signed-off-by: Chad Versace 
---
 src/xdemos/glxgears.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/xdemos/glxgears.c b/src/xdemos/glxgears.c
index 74b0bfd..79b7226 100644
--- a/src/xdemos/glxgears.c
+++ b/src/xdemos/glxgears.c
@@ -102,6 +102,7 @@ static GLfloat angle = 0.0;
 
 static GLboolean fullscreen = GL_FALSE;/* Create a single fullscreen 
window */
 static GLboolean stereo = GL_FALSE;/* Enable stereo.  */
+static GLint samples = 0;   /* Choose visual with at least N 
samples. */
 static GLboolean animate = GL_TRUE;/* Animation */
 static GLfloat eyesep = 5.0;   /* Eye separation. */
 static GLfloat fix_point = 40.0;   /* Fixation point distance.  */
@@ -504,6 +505,12 @@ make_window( Display *dpy, const char *name,
attribs[i++] = 1;
attribs[i++] = GLX_DEPTH_SIZE;
attribs[i++] = 1;
+   if (samples > 0) {
+  attribs[i++] = GLX_SAMPLE_BUFFERS;
+  attribs[i++] = 1;
+  attribs[i++] = GLX_SAMPLES;
+  attribs[i++] = samples;
+   }
 
attribs[i++] = None;
 
@@ -521,6 +528,8 @@ make_window( Display *dpy, const char *name,
   printf("Error: couldn't get an RGB, Double-buffered");
   if (stereo)
  printf(", Stereo");
+  if (samples > 0)
+ printf(", Multisample");
   printf(" visual\n");
   exit(1);
}
@@ -707,6 +716,7 @@ usage(void)
printf("Usage:\n");
printf("  -display   set the display to run on\n");
printf("  -stereo run in stereo mode\n");
+   printf("  -samples N  run in multisample mode with at least N 
samples\n");
printf("  -fullscreen run in fullscreen mode\n");
printf("  -info   display OpenGL renderer info\n");
printf("  -geometry WxH+X+Y   window geometry\n");
@@ -736,6 +746,10 @@ main(int argc, char *argv[])
   else if (strcmp(argv[i], "-stereo") == 0) {
  stereo = GL_TRUE;
   }
+  else if (i < argc-1 && strcmp(argv[i], "-samples") == 0) {
+ samples = strtod(argv[i+1], NULL );
+ ++i;
+  }
   else if (strcmp(argv[i], "-fullscreen") == 0) {
  fullscreen = GL_TRUE;
   }
-- 
1.7.11.2

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


[Mesa-dev] [PATCH 1/2] glxgears: Refactor visual attributes

2012-07-20 Thread Chad Versace
Procedurally construct the attribute array according to command-line args.
This is in preparation for the next commit, which add support for
multisampling.

CC: Paul Berry 
Signed-off-by: Chad Versace 
---
 src/xdemos/glxgears.c | 50 ++
 1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/src/xdemos/glxgears.c b/src/xdemos/glxgears.c
index a9b4c0d..74b0bfd 100644
--- a/src/xdemos/glxgears.c
+++ b/src/xdemos/glxgears.c
@@ -478,21 +478,9 @@ make_window( Display *dpy, const char *name,
  int x, int y, int width, int height,
  Window *winRet, GLXContext *ctxRet)
 {
-   int attribs[] = { GLX_RGBA,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_DOUBLEBUFFER,
- GLX_DEPTH_SIZE, 1,
- None };
-   int stereoAttribs[] = { GLX_RGBA,
-   GLX_RED_SIZE, 1,
-   GLX_GREEN_SIZE, 1,
-   GLX_BLUE_SIZE, 1,
-   GLX_DOUBLEBUFFER,
-   GLX_DEPTH_SIZE, 1,
-   GLX_STEREO,
-   None };
+   int attribs[64];
+   int i = 0;
+
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
@@ -501,6 +489,24 @@ make_window( Display *dpy, const char *name,
GLXContext ctx;
XVisualInfo *visinfo;
 
+   /* Singleton attributes. */
+   attribs[i++] = GLX_RGBA;
+   attribs[i++] = GLX_DOUBLEBUFFER;
+   if (stereo)
+  attribs[i++] = GLX_STEREO;
+
+   /* Key/value attributes. */
+   attribs[i++] = GLX_RED_SIZE;
+   attribs[i++] = 1;
+   attribs[i++] = GLX_GREEN_SIZE;
+   attribs[i++] = 1;
+   attribs[i++] = GLX_BLUE_SIZE;
+   attribs[i++] = 1;
+   attribs[i++] = GLX_DEPTH_SIZE;
+   attribs[i++] = 1;
+
+   attribs[i++] = None;
+
scrnum = DefaultScreen( dpy );
root = RootWindow( dpy, scrnum );
 
@@ -510,16 +516,12 @@ make_window( Display *dpy, const char *name,
   height = DisplayHeight( dpy, scrnum );
}
 
-   if (stereo)
-  visinfo = glXChooseVisual( dpy, scrnum, stereoAttribs );
-   else
-  visinfo = glXChooseVisual( dpy, scrnum, attribs );
+   visinfo = glXChooseVisual(dpy, scrnum, attribs);
if (!visinfo) {
-  if (stereo) {
- printf("Error: couldn't get an RGB, "
-"Double-buffered, Stereo visual\n");
-  } else
- printf("Error: couldn't get an RGB, Double-buffered visual\n");
+  printf("Error: couldn't get an RGB, Double-buffered");
+  if (stereo)
+ printf(", Stereo");
+  printf(" visual\n");
   exit(1);
}
 
-- 
1.7.11.2

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


[Mesa-dev] [PATCH 0/2] glxgears: Add support for multisample visuals

2012-07-20 Thread Chad Versace
Tested on Ivybridge. You can find this series on
  git://people.freedesktop.org/~chadversary/mesa-demos.git ; msaa

Chad Versace (2):
  glxgears: Refactor visual attributes
  glxgears: Add support for multisample visuals

 src/xdemos/glxgears.c | 64 ---
 1 file changed, 40 insertions(+), 24 deletions(-)

-- 
1.7.11.2

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


Re: [Mesa-dev] [PATCH, android-build] android-build: fix dricore build for autogenerated files

2012-07-20 Thread Charles, Daniel
On Fri, Jul 20, 2012 at 4:26 PM, Matt Turner  wrote:
> On Fri, Jul 20, 2012 at 2:41 PM, Daniel Charles
>  wrote:
>> Change-Id: I75e86453d23f6b6f0e2a7dfb1b48272965c9fbf2
>
> What is this?

It is a gerrit change id [1].  If the patch is merged it can be discarded.

-- 
Daniel.


[1]http://gerrit.googlecode.com/svn/documentation/2.0/user-changeid.html
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] automake: add ARCH_FLAGS, OPT_FLAGS, PIC_FLAGS into AM_CFLAGS and AM_CXXFLAGS

2012-07-20 Thread Marek Olšák
This fixes a build system regression after Makefile conversions
to automake.

I need only OPT_FLAGS to set -fno-omit-frame-pointer.
ARCH_FLAGS is for --enable-32-bit.
I am not sure what PIC_FLAGS is good for, but r600g uses it.

VISIBILITY_CFLAGS might be missing too.
---
 src/egl/drivers/dri2/Makefile.am  |6 +-
 src/egl/drivers/glx/Makefile.am   |5 -
 src/egl/main/Makefile.am  |6 +-
 src/egl/wayland/wayland-drm/Makefile.am   |6 +-
 src/egl/wayland/wayland-egl/Makefile.am   |5 -
 src/gallium/auxiliary/pipe-loader/Makefile.am |5 -
 src/gallium/drivers/r600/Makefile.am  |5 -
 src/gbm/Makefile.am   |5 -
 src/glsl/Makefile.am  |5 -
 src/glsl/glcpp/Makefile.am|5 -
 src/glx/Makefile.am   |5 -
 src/mesa/Makefile.am  |7 +--
 src/mesa/drivers/dri/common/Makefile.am   |5 -
 src/mesa/drivers/dri/i915/Makefile.am |5 -
 src/mesa/drivers/dri/i965/Makefile.am |5 -
 src/mesa/drivers/dri/nouveau/Makefile.am  |5 -
 src/mesa/drivers/dri/r200/Makefile.am |5 -
 src/mesa/drivers/dri/radeon/Makefile.am   |5 -
 src/mesa/drivers/dri/swrast/Makefile.am   |5 -
 src/mesa/drivers/osmesa/Makefile.am   |5 -
 src/mesa/libdricore/Makefile.am   |   14 --
 21 files changed, 96 insertions(+), 23 deletions(-)

diff --git a/src/egl/drivers/dri2/Makefile.am b/src/egl/drivers/dri2/Makefile.am
index 49ec06b..3e50b84 100644
--- a/src/egl/drivers/dri2/Makefile.am
+++ b/src/egl/drivers/dri2/Makefile.am
@@ -30,7 +30,11 @@ AM_CFLAGS = \
$(DEFINES) \
$(LIBDRM_CFLAGS) \
$(LIBUDEV_CFLAGS) \
-   -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\"
+   -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \
+   $(ARCH_FLAGS) \
+   $(OPT_FLAGS) \
+   $(PIC_FLAGS)
+
 
 noinst_LTLIBRARIES = libegl_dri2.la
 
diff --git a/src/egl/drivers/glx/Makefile.am b/src/egl/drivers/glx/Makefile.am
index 6bf67ea..fae7f6b 100644
--- a/src/egl/drivers/glx/Makefile.am
+++ b/src/egl/drivers/glx/Makefile.am
@@ -23,7 +23,10 @@ AM_CFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/egl/main \
$(X11_CFLAGS) \
-   $(DEFINES)
+   $(DEFINES) \
+   $(ARCH_FLAGS) \
+   $(OPT_FLAGS) \
+   $(PIC_FLAGS)
 
 noinst_LTLIBRARIES = libegl_glx.la
 
diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am
index ca5257a..83935aa 100644
--- a/src/egl/main/Makefile.am
+++ b/src/egl/main/Makefile.am
@@ -32,7 +32,11 @@ AM_CFLAGS = \
$(EGL_CFLAGS) \
-D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \
-D_EGL_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\" \
-   -D_EGL_OS_UNIX=1
+   -D_EGL_OS_UNIX=1 \
+   $(ARCH_FLAGS) \
+   $(OPT_FLAGS) \
+   $(PIC_FLAGS)
+
 
 lib_LTLIBRARIES = libEGL.la
 
diff --git a/src/egl/wayland/wayland-drm/Makefile.am 
b/src/egl/wayland/wayland-drm/Makefile.am
index 4b2aeb3..a675dd8 100644
--- a/src/egl/wayland/wayland-drm/Makefile.am
+++ b/src/egl/wayland/wayland-drm/Makefile.am
@@ -1,7 +1,11 @@
 AM_CFLAGS = -I$(top_srcdir)/src/egl/main \
-I$(top_srcdir)/include \
$(DEFINES) \
-   $(WAYLAND_CFLAGS) 
+   $(WAYLAND_CFLAGS)  \
+   $(ARCH_FLAGS) \
+   $(OPT_FLAGS) \
+   $(PIC_FLAGS)
+
 
 noinst_LTLIBRARIES = libwayland-drm.la
 libwayland_drm_la_SOURCES = wayland-drm.c wayland-drm-protocol.c
diff --git a/src/egl/wayland/wayland-egl/Makefile.am 
b/src/egl/wayland/wayland-egl/Makefile.am
index 7d20a1a..9533086 100644
--- a/src/egl/wayland/wayland-egl/Makefile.am
+++ b/src/egl/wayland/wayland-egl/Makefile.am
@@ -2,7 +2,10 @@ pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = wayland-egl.pc
 
 AM_CFLAGS = $(DEFINES) \
-   $(WAYLAND_CFLAGS)
+   $(WAYLAND_CFLAGS) \
+   $(ARCH_FLAGS) \
+   $(OPT_FLAGS) \
+   $(PIC_FLAGS)
 
 lib_LTLIBRARIES = libwayland-egl.la
 noinst_HEADERS = wayland-egl-priv.h
diff --git a/src/gallium/auxiliary/pipe-loader/Makefile.am 
b/src/gallium/auxiliary/pipe-loader/Makefile.am
index c63dce3..5971144 100644
--- a/src/gallium/auxiliary/pipe-loader/Makefile.am
+++ b/src/gallium/auxiliary/pipe-loader/Makefile.am
@@ -7,7 +7,10 @@ AM_CPPFLAGS = $(DEFINES) \
-I$(top_srcdir)/src/gallium/auxiliary \
-I$(top_srcdir)/src/gallium/winsys
 
-AM_CFLAGS = $(PIC_FLAGS)
+AM_CFLAGS = \
+   $(ARCH_FLAGS) \
+   $(OPT_FLAGS) \
+   $(PIC_FLAGS)
 
 noinst_LTLIBRARIES =
 
diff --git a/src/gallium/drivers/r600/Makefile.am 
b/src/gallium/drivers/r600/Makefile.am
index ed89d2a..c6ce376 100644
--- a/src/gallium/drivers/r600/Makefile.am
+++ b/src/gallium/drivers/r600/Makefile.am
@@ -36,7 +36,10 @@ AM_CFLAGS += \
-I$(top_src

Re: [Mesa-dev] [PATCH] i830: Fix stack corruption

2012-07-20 Thread Ian Romanick

On 07/20/2012 04:18 PM, Matt Turner wrote:

On Fri, Jul 20, 2012 at 3:45 PM, Chad Versace
 wrote:

Found by compiler warning:
 i830_texstate.c:131:28: warning: argument to 'sizeof' in 'memset' call
   is the same expression as the destination; did you mean to
   dereference it?  [-Wsizeof-pointer-memaccess]
memset(state, 0, sizeof(state));
   ~^

On 64-bit systems, memset here would write an extra 4 bytes.

Signed-off-by: Chad Versace 
---
  src/mesa/drivers/dri/i915/i830_texstate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c 
b/src/mesa/drivers/dri/i915/i830_texstate.c
index 5f32b92..b7d2d33 100644
--- a/src/mesa/drivers/dri/i915/i830_texstate.c
+++ b/src/mesa/drivers/dri/i915/i830_texstate.c
@@ -128,7 +128,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint 
unit, GLuint ss3)
 GLubyte border[4];
 GLuint dst_x, dst_y;

-   memset(state, 0, sizeof(state));
+   memset(state, 0, sizeof(*state));

 /*We need to refcount these. */

--


Reviewed-by: Matt Turner 

I don't guess there are any 64-bit systems with i915s in them though, are there?


Yes.  There are lots of 64-bit i915 and some 64-bit i830 (i865G, 
specifically).  Remember the Pentium 4 "Prescott"? :)  There was even 
one crazy i865G motherboard that could take a Core2.

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


Re: [Mesa-dev] [PATCH] i830: Fix stack corruption

2012-07-20 Thread Chad Versace
On 07/20/2012 04:18 PM, Matt Turner wrote:
> On Fri, Jul 20, 2012 at 3:45 PM, Chad Versace
>  wrote:
>> Found by compiler warning:
>> i830_texstate.c:131:28: warning: argument to 'sizeof' in 'memset' call
>>   is the same expression as the destination; did you mean to
>>   dereference it?  [-Wsizeof-pointer-memaccess]
>>memset(state, 0, sizeof(state));
>>   ~^
>>
>> On 64-bit systems, memset here would write an extra 4 bytes.


> Reviewed-by: Matt Turner 
> 
> I don't guess there are any 64-bit systems with i915s in them though, are 
> there?

Doh.
/blush


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


Re: [Mesa-dev] [PATCH, android-build] android-build: fix dricore build for autogenerated files

2012-07-20 Thread Matt Turner
On Fri, Jul 20, 2012 at 2:41 PM, Daniel Charles
 wrote:
> Change-Id: I75e86453d23f6b6f0e2a7dfb1b48272965c9fbf2

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


Re: [Mesa-dev] [PATCH] i830: Fix stack corruption

2012-07-20 Thread Matt Turner
On Fri, Jul 20, 2012 at 3:45 PM, Chad Versace
 wrote:
> Found by compiler warning:
> i830_texstate.c:131:28: warning: argument to 'sizeof' in 'memset' call
>   is the same expression as the destination; did you mean to
>   dereference it?  [-Wsizeof-pointer-memaccess]
>memset(state, 0, sizeof(state));
>   ~^
>
> On 64-bit systems, memset here would write an extra 4 bytes.
>
> Signed-off-by: Chad Versace 
> ---
>  src/mesa/drivers/dri/i915/i830_texstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c 
> b/src/mesa/drivers/dri/i915/i830_texstate.c
> index 5f32b92..b7d2d33 100644
> --- a/src/mesa/drivers/dri/i915/i830_texstate.c
> +++ b/src/mesa/drivers/dri/i915/i830_texstate.c
> @@ -128,7 +128,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint 
> unit, GLuint ss3)
> GLubyte border[4];
> GLuint dst_x, dst_y;
>
> -   memset(state, 0, sizeof(state));
> +   memset(state, 0, sizeof(*state));
>
> /*We need to refcount these. */
>
> --

Reviewed-by: Matt Turner 

I don't guess there are any 64-bit systems with i915s in them though, are there?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 11/11] glsl: Reject linking shaders with too many uniform blocks.

2012-07-20 Thread Ian Romanick

On 07/20/2012 03:49 PM, Brian Paul wrote:

On 07/20/2012 04:33 PM, Eric Anholt wrote:

Part of fixing piglit maxblocks.
---
  src/glsl/linker.cpp |   34 ++
  1 file changed, 34 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index bfdde40..f4e578f 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2324,6 +2324,12 @@ check_resources(struct gl_context *ctx, struct
gl_shader_program *prog)
0  /* FINISHME: Geometry shaders. */
 };

+   const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = {
+  ctx->Const.VertexProgram.MaxUniformBlocks,
+  ctx->Const.FragmentProgram.MaxUniformBlocks,
+  ctx->Const.GeometryProgram.MaxUniformBlocks,
+   };
+
 for (unsigned i = 0; i<  MESA_SHADER_TYPES; i++) {
struct gl_shader *sh = prog->_LinkedShaders[i];

@@ -2348,6 +2354,34 @@ check_resources(struct gl_context *ctx, struct
gl_shader_program *prog)
}
 }

+   unsigned blocks[] = {0, 0, 0};


Should that be:
unsigned blocks[MESA_SHADER_TYPES] = { 0, 0, 0 };

The idea would be to get a compiler warning if the blocks array isn't
grown in the future for new shader types.


This is a good idea, but it won't cause a warning.  At least it won't on 
a C99 savvy compiler.  The C99 rules for that usage cause the missing 
fields to get initialized to 0.



+   unsigned total_uniform_blocks = 0;
+
+   for (unsigned i = 0; i<  prog->NumUniformBlocks; i++) {
+  for (unsigned j = 0; j<  MESA_SHADER_TYPES; j++) {
+ if (prog->UniformBlockStageIndex[j][i] != -1) {
+blocks[j]++;
+total_uniform_blocks++;
+ }
+  }
+
+  if (total_uniform_blocks>  ctx->Const.MaxCombinedUniformBlocks) {
+ linker_error(prog, "Too many combined uniform blocks (%d/%d)",
+  prog->NumUniformBlocks,
+  ctx->Const.MaxCombinedUniformBlocks);
+  } else {
+ for (unsigned i = 0; i<  MESA_SHADER_TYPES; i++) {
+if (blocks[i]>  max_uniform_blocks[i]) {
+   linker_error(prog, "Too many %s uniform blocks (%d/%d)",
+shader_names[i],
+blocks[i],
+max_uniform_blocks[i]);
+   break;
+}
+ }
+  }
+   }
+
 return prog->LinkStatus;
  }



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


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


Re: [Mesa-dev] [PATCH 1/4] Use INV_SQRT instead of 1/SQRTF

2012-07-20 Thread Matt Turner
On Fri, Jul 20, 2012 at 3:29 PM, Kenneth Graunke  wrote:
> On 07/20/2012 11:24 AM, Matt Turner wrote:
>> ---
>>  src/mesa/math/m_debug_norm.c |4 ++--
>>  src/mesa/tnl/t_vb_points.c   |2 +-
>>  2 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c
>> index 02eb1f9..dc768f3 100644
>> --- a/src/mesa/math/m_debug_norm.c
>> +++ b/src/mesa/math/m_debug_norm.c
>> @@ -165,7 +165,7 @@ static void ref_norm_transform_normalize( const GLmatrix 
>> *mat,
>>   /* Hmmm, don't know how we could test the precalculated
>>* length case...
>>*/
>> -scale = 1.0 / SQRTF( len );
>> +scale = INV_SQRTF( len );
>>   SCALE_SCALAR_3V( out[i], scale, t );
>>   } else {
>>  out[i][0] = out[i][1] = out[i][2] = 0;
>> @@ -241,7 +241,7 @@ static int test_norm_function( normal_func func, int 
>> mtype, long *cycles )
>>ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
>>for ( j = 0 ; j < 3 ; j++ )
>>   s[i][j] = rnd();
>> -  length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
>> +  length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
>> }
>>
>> source->data = (GLfloat(*)[4]) s;
>> diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c
>> index 9edbbc7..0e33b69 100644
>> --- a/src/mesa/tnl/t_vb_points.c
>> +++ b/src/mesa/tnl/t_vb_points.c
>> @@ -64,7 +64,7 @@ run_point_stage(struct gl_context *ctx, struct 
>> tnl_pipeline_stage *stage)
>>for (i = 0; i < VB->Count; i++) {
>>   const GLfloat dist = FABSF(*eyeCoord);
>>   const GLfloat q = p0 + dist * (p1 + dist * p2);
>> - const GLfloat atten = (q != 0.0F) ? SQRTF(1.0F / q) : 1.0F;
>> + const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F;
>>   size[i][0] = pointSize * atten; /* clamping done in rasterization 
>> */
>>   eyeCoord += eyeCoordStride;
>>}
>
> Why change this?  I don't see why the new version is any better.  More
> precise, maybe?
>
> Also, why use INV_SQRT rather than just leaving all of these as 1.0 / SQRTF?

Really just because of the annoyance of having an INV_SQRTF macro and
then seeing 1.0 / SQRTF in the code. There's no functional change.

I thought about getting rid of SQRTF/INV_SQRTF but that was sort of a
hassle, and there is some possibility that they could be useful in the
future if we had some optimized routines.

> Patches 2-4 are:
> Reviewed-by: Kenneth Graunke 

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


Re: [Mesa-dev] [PATCH 02/11] glsl: Incorporate all UBO language changes into GLSL 1.40.

2012-07-20 Thread Ian Romanick

On 07/20/2012 03:33 PM, Eric Anholt wrote:

---
  src/glsl/glsl_parser.yy |4 
  1 file changed, 4 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index b2533c8..0ed424d 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -291,6 +291,10 @@ version_statement:
   state->version_string,
   state->supported_version_string);
   }
+
+  if (state->language_version >= 140) {
+ state->ARB_uniform_buffer_object_enable = true;
+  }


Do we need something to prevent

#extension GL_ARB_uniform_buffer_object: disable

from making dumb things happen?


}
;



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


Re: [Mesa-dev] [PATCH] i830: Fix stack corruption

2012-07-20 Thread Chad Versace
On 07/20/2012 03:53 PM, Brian Paul wrote:
> On 07/20/2012 04:45 PM, Chad Versace wrote:
>> Found by compiler warning:
>>  i830_texstate.c:131:28: warning: argument to 'sizeof' in 'memset' call
>>is the same expression as the destination; did you mean to
>>dereference it?  [-Wsizeof-pointer-memaccess]
>> memset(state, 0, sizeof(state));
>>~^
> 
> Huh, I've never seen that one before.  Is that something new in recent gcc?  I
> like it.

I compiled with clang. On the terminal, the messages have pretty colors too :)

>> On 64-bit systems, memset here would write an extra 4 bytes.
> 
> Candidate for 8.0 branch?

Thanks for the reminder. I'll add the tag when I push it.

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


Re: [Mesa-dev] [PATCH] i830: Fix stack corruption

2012-07-20 Thread Brian Paul

On 07/20/2012 04:45 PM, Chad Versace wrote:

Found by compiler warning:
 i830_texstate.c:131:28: warning: argument to 'sizeof' in 'memset' call
   is the same expression as the destination; did you mean to
   dereference it?  [-Wsizeof-pointer-memaccess]
memset(state, 0, sizeof(state));
   ~^


Huh, I've never seen that one before.  Is that something new in recent 
gcc?  I like it.




On 64-bit systems, memset here would write an extra 4 bytes.


Candidate for 8.0 branch?



Signed-off-by: Chad Versace
---
  src/mesa/drivers/dri/i915/i830_texstate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c 
b/src/mesa/drivers/dri/i915/i830_texstate.c
index 5f32b92..b7d2d33 100644
--- a/src/mesa/drivers/dri/i915/i830_texstate.c
+++ b/src/mesa/drivers/dri/i915/i830_texstate.c
@@ -128,7 +128,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint 
unit, GLuint ss3)
 GLubyte border[4];
 GLuint dst_x, dst_y;

-   memset(state, 0, sizeof(state));
+   memset(state, 0, sizeof(*state));

 /*We need to refcount these. */



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


Re: [Mesa-dev] [PATCH 11/11] glsl: Reject linking shaders with too many uniform blocks.

2012-07-20 Thread Brian Paul

On 07/20/2012 04:33 PM, Eric Anholt wrote:

Part of fixing piglit maxblocks.
---
  src/glsl/linker.cpp |   34 ++
  1 file changed, 34 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index bfdde40..f4e578f 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2324,6 +2324,12 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
0  /* FINISHME: Geometry shaders. */
 };

+   const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = {
+  ctx->Const.VertexProgram.MaxUniformBlocks,
+  ctx->Const.FragmentProgram.MaxUniformBlocks,
+  ctx->Const.GeometryProgram.MaxUniformBlocks,
+   };
+
 for (unsigned i = 0; i<  MESA_SHADER_TYPES; i++) {
struct gl_shader *sh = prog->_LinkedShaders[i];

@@ -2348,6 +2354,34 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 }

+   unsigned blocks[] = {0, 0, 0};


Should that be:
   unsigned blocks[MESA_SHADER_TYPES] = { 0, 0, 0 };

The idea would be to get a compiler warning if the blocks array isn't 
grown in the future for new shader types.




+   unsigned total_uniform_blocks = 0;
+
+   for (unsigned i = 0; i<  prog->NumUniformBlocks; i++) {
+  for (unsigned j = 0; j<  MESA_SHADER_TYPES; j++) {
+if (prog->UniformBlockStageIndex[j][i] != -1) {
+   blocks[j]++;
+   total_uniform_blocks++;
+}
+  }
+
+  if (total_uniform_blocks>  ctx->Const.MaxCombinedUniformBlocks) {
+linker_error(prog, "Too many combined uniform blocks (%d/%d)",
+ prog->NumUniformBlocks,
+ ctx->Const.MaxCombinedUniformBlocks);
+  } else {
+for (unsigned i = 0; i<  MESA_SHADER_TYPES; i++) {
+   if (blocks[i]>  max_uniform_blocks[i]) {
+  linker_error(prog, "Too many %s uniform blocks (%d/%d)",
+   shader_names[i],
+   blocks[i],
+   max_uniform_blocks[i]);
+  break;
+   }
+}
+  }
+   }
+
 return prog->LinkStatus;
  }



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


[Mesa-dev] [PATCH] i830: Fix stack corruption

2012-07-20 Thread Chad Versace
Found by compiler warning:
i830_texstate.c:131:28: warning: argument to 'sizeof' in 'memset' call
  is the same expression as the destination; did you mean to
  dereference it?  [-Wsizeof-pointer-memaccess]
   memset(state, 0, sizeof(state));
  ~^

On 64-bit systems, memset here would write an extra 4 bytes.

Signed-off-by: Chad Versace 
---
 src/mesa/drivers/dri/i915/i830_texstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c 
b/src/mesa/drivers/dri/i915/i830_texstate.c
index 5f32b92..b7d2d33 100644
--- a/src/mesa/drivers/dri/i915/i830_texstate.c
+++ b/src/mesa/drivers/dri/i915/i830_texstate.c
@@ -128,7 +128,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint 
unit, GLuint ss3)
GLubyte border[4];
GLuint dst_x, dst_y;
 
-   memset(state, 0, sizeof(state));
+   memset(state, 0, sizeof(*state));
 
/*We need to refcount these. */
 
-- 
1.7.11.2

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


Re: [Mesa-dev] [PATCH 01/11] mesa: Add support for glGetProgramiv pnames for UBOs.

2012-07-20 Thread Brian Paul

On 07/20/2012 04:33 PM, Eric Anholt wrote:

Fixes piglit ARB_uniform_buffer_object/getprogramiv.
---
  src/mesa/main/shaderapi.c |   19 +++
  1 file changed, 19 insertions(+)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 6927368..f381915 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -542,6 +542,25 @@ get_programiv(struct gl_context *ctx, GLuint program, 
GLenum pname, GLint *param
*params = shProg->Geom.OutputType;
break;
  #endif
+   case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: {
+  unsigned i;
+  GLint max_len = 0;
+
+  for (i = 0; i<  shProg->NumUniformBlocks; i++) {
+/* Add one for the terminating NUL character.
+ */
+const GLint len = strlen(shProg->UniformBlocks[i].Name) + 1;
+
+if (len>  max_len)
+   max_len = len;
+  }
+
+  *params = max_len;
+  break;
+   }
+   case GL_ACTIVE_UNIFORM_BLOCKS:
+  *params = shProg->NumUniformBlocks;
+  break;
 default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
return;


It looks like these new cases (and the existing cases for geometry 
shaders and transform feedback) need extension tests:


if (!ctx->Extensions.ARB_uniform_buffer_object) {
   _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv");
   return;
}

Since there would be a quite a few of these, a goto-error handler at 
the end of the function would be good.


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


[Mesa-dev] [PATCH 11/11] glsl: Reject linking shaders with too many uniform blocks.

2012-07-20 Thread Eric Anholt
Part of fixing piglit maxblocks.
---
 src/glsl/linker.cpp |   34 ++
 1 file changed, 34 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index bfdde40..f4e578f 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2324,6 +2324,12 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
   0  /* FINISHME: Geometry shaders. */
};
 
+   const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = {
+  ctx->Const.VertexProgram.MaxUniformBlocks,
+  ctx->Const.FragmentProgram.MaxUniformBlocks,
+  ctx->Const.GeometryProgram.MaxUniformBlocks,
+   };
+
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
   struct gl_shader *sh = prog->_LinkedShaders[i];
 
@@ -2348,6 +2354,34 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
   }
}
 
+   unsigned blocks[] = {0, 0, 0};
+   unsigned total_uniform_blocks = 0;
+
+   for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+  for (unsigned j = 0; j < MESA_SHADER_TYPES; j++) {
+if (prog->UniformBlockStageIndex[j][i] != -1) {
+   blocks[j]++;
+   total_uniform_blocks++;
+}
+  }
+
+  if (total_uniform_blocks > ctx->Const.MaxCombinedUniformBlocks) {
+linker_error(prog, "Too many combined uniform blocks (%d/%d)",
+ prog->NumUniformBlocks,
+ ctx->Const.MaxCombinedUniformBlocks);
+  } else {
+for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+   if (blocks[i] > max_uniform_blocks[i]) {
+  linker_error(prog, "Too many %s uniform blocks (%d/%d)",
+   shader_names[i],
+   blocks[i],
+   max_uniform_blocks[i]);
+  break;
+   }
+}
+  }
+   }
+
return prog->LinkStatus;
 }
 
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 10/11] mesa: Return -1 for glGetUniformLocation on UBOs.

2012-07-20 Thread Eric Anholt
Fixes piglit ARB_uniform_buffer_object/getuniformlocation.
---
 src/mesa/main/uniforms.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index b5aaa1b..f43d0fb 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -522,6 +522,16 @@ _mesa_GetUniformLocationARB(GLhandleARB programObj, const 
GLcharARB *name)
if (index == GL_INVALID_INDEX)
   return -1;
 
+   /* From the GL_ARB_uniform_buffer_object spec:
+*
+* "The value -1 will be returned if  does not correspond to an
+*  active uniform variable name in , if  is associated
+*  with a named uniform block, or if  starts with the reserved
+*  prefix "gl_"."
+*/
+   if (shProg->UniformStorage[index].block_index != -1)
+  return -1;
+
return _mesa_uniform_merge_location_offset(index, offset);
 }
 
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 07/11] glsl: Merge UBO layout qualifiers in a qualifier list.

2012-07-20 Thread Eric Anholt
Yes, you get to say things like "layout(row_major, column_major)" and
get column major.

Part of fixing piglit ARB_uniform_buffer_object/row_major.
---
 src/glsl/glsl_parser.yy |   24 +++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 0ed424d..2787721 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1106,13 +1106,35 @@ layout_qualifier_id_list:
layout_qualifier_id
| layout_qualifier_id_list ',' layout_qualifier_id
{
-  if (($1.flags.i & $3.flags.i) != 0) {
+  ast_type_qualifier ubo_mat_mask;
+  ubo_mat_mask.flags.i = 0;
+  ubo_mat_mask.flags.q.row_major = 1;
+  ubo_mat_mask.flags.q.column_major = 1;
+
+  ast_type_qualifier ubo_layout_mask;
+  ubo_layout_mask.flags.i = 0;
+  ubo_layout_mask.flags.q.std140 = 1;
+  ubo_layout_mask.flags.q.packed = 1;
+  ubo_layout_mask.flags.q.shared = 1;
+
+  /* Uniform block layout qualifiers get to overwrite each
+   * other (rightmost having priority), while all other
+   * qualifiers currently don't allow duplicates.
+   */
+  if (($1.flags.i & $3.flags.i & ~(ubo_mat_mask.flags.i |
+   ubo_layout_mask.flags.i)) != 0) {
  _mesa_glsl_error(& @3, state,
   "duplicate layout qualifiers used\n");
  YYERROR;
   }
 
   $$ = $1;
+
+  if (($3.flags.i & ubo_mat_mask.flags.i) != 0)
+ $$.flags.i &= ~ubo_mat_mask.flags.i;
+  if (($3.flags.i & ubo_layout_mask.flags.i) != 0)
+ $$.flags.i &= ~ubo_layout_mask.flags.i;
+
   $$.flags.i |= $3.flags.i;
 
   if ($3.flags.q.explicit_location)
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 09/11] glsl: Assign array and matrix stride values according to std140 layout.

2012-07-20 Thread Eric Anholt
---
 src/glsl/link_uniforms.cpp |   19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index d7ef5d4..1baa46c 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -328,10 +328,21 @@ private:
 this->uniforms[id].offset = this->ubo_byte_offset;
 this->ubo_byte_offset += type->std140_size(ubo_var->RowMajor);
 
-this->uniforms[id].array_stride = 0;
-this->uniforms[id].matrix_stride = 0;
-this->uniforms[id].row_major = base_type->is_matrix() &&
-   ubo_var->RowMajor;
+if (type->is_array()) {
+   this->uniforms[id].array_stride =
+  align(type->fields.array->std140_size(ubo_var->RowMajor), 16);
+} else {
+   this->uniforms[id].array_stride = 0;
+}
+
+if (type->is_matrix() ||
+(type->is_array() && type->fields.array->is_matrix())) {
+   this->uniforms[id].matrix_stride = 16;
+   this->uniforms[id].row_major = ubo_var->RowMajor;
+} else {
+   this->uniforms[id].matrix_stride = 0;
+   this->uniforms[id].row_major = false;
+}
   } else {
 this->uniforms[id].block_index = -1;
 this->uniforms[id].offset = -1;
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 06/11] mesa: Add support for GL_ARB_ubo's glGetActiveUniformName().

2012-07-20 Thread Eric Anholt
This is like a stripped-down version of glGetActiveUniform that just
returns the name, since the other return values (type and size) of
that function are now meant to be handled with
glGetActiveUniformsiv().

Fixes piglit ARB_uniform_buffer_object/getactiveuniformname
---
 src/mesa/main/uniforms.c |   39 +++
 1 file changed, 39 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 6652251..b5aaa1b 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -752,6 +752,44 @@ _mesa_GetActiveUniformBlockName(GLuint program,
}
 }
 
+static void GLAPIENTRY
+_mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex,
+  GLsizei bufSize, GLsizei *length,
+  GLchar *uniformName)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_program *shProg;
+
+   if (!ctx->Extensions.ARB_uniform_buffer_object) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+  return;
+   }
+
+   if (bufSize < 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformName(bufSize %d < 0)",
+ bufSize);
+  return;
+   }
+
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   shProg = _mesa_lookup_shader_program_err(ctx, program, 
"glGetActiveUniformName");
+
+   if (!shProg)
+  return;
+
+   if (uniformIndex >= shProg->NumUserUniformStorage) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)");
+  return;
+   }
+
+   if (uniformName) {
+  _mesa_copy_string(uniformName, bufSize, length,
+   shProg->UniformStorage[uniformIndex].name);
+   }
+}
+
 /**
  * Plug in shader uniform-related functions into API dispatch table.
  */
@@ -815,6 +853,7 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table 
*exec)
SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv);
SET_GetActiveUniformBlockiv(exec, _mesa_GetActiveUniformBlockiv);
SET_GetActiveUniformBlockName(exec, _mesa_GetActiveUniformBlockName);
+   SET_GetActiveUniformName(exec, _mesa_GetActiveUniformName);
SET_UniformBlockBinding(exec, _mesa_UniformBlockBinding);
 
 #endif /* FEATURE_GL */
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 08/11] glsl: Add support for default layout qualifiers for uniforms.

2012-07-20 Thread Eric Anholt
I ended up having to add rallocing of the ast_type_qualifier in order
to avoid pulling in ast.h for glsl_parser_extras.h, because I wanted
to track an ast_type_qualifier in the state.

Fixes piglit ARB_uniform_buffer_object/row-major.
---
 src/glsl/ast.h  |   23 
 src/glsl/ast_type.cpp   |   45 ++
 src/glsl/glsl_parser.yy |   58 ++-
 src/glsl/glsl_parser_extras.cpp |4 +++
 src/glsl/glsl_parser_extras.h   |7 +
 5 files changed, 99 insertions(+), 38 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index de3f2df..5074782 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -338,6 +338,25 @@ enum {
 };
 
 struct ast_type_qualifier {
+   /* Callers of this ralloc-based new need not call delete. It's
+* easier to just ralloc_free 'ctx' (or any of its ancestors). */
+   static void* operator new(size_t size, void *ctx)
+   {
+  void *node;
+
+  node = rzalloc_size(ctx, size);
+  assert(node != NULL);
+
+  return node;
+   }
+
+   /* If the user *does* call delete, that's OK, we will just
+* ralloc_free in that case. */
+   static void operator delete(void *table)
+   {
+  ralloc_free(table);
+   }
+
union {
   struct {
 unsigned invariant:1;
@@ -424,6 +443,10 @@ struct ast_type_qualifier {
 * returned string is undefined but not null.
 */
const char *interpolation_string() const;
+
+   bool merge_qualifier(YYLTYPE *loc,
+   _mesa_glsl_parse_state *state,
+   ast_type_qualifier q);
 };
 
 class ast_declarator_list;
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index 6c44f8c..29493e2 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -71,3 +71,48 @@ ast_type_qualifier::interpolation_string() const
else
   return NULL;
 }
+
+bool
+ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
+   _mesa_glsl_parse_state *state,
+   ast_type_qualifier q)
+{
+   ast_type_qualifier ubo_mat_mask;
+   ubo_mat_mask.flags.i = 0;
+   ubo_mat_mask.flags.q.row_major = 1;
+   ubo_mat_mask.flags.q.column_major = 1;
+
+   ast_type_qualifier ubo_layout_mask;
+   ubo_layout_mask.flags.i = 0;
+   ubo_layout_mask.flags.q.std140 = 1;
+   ubo_layout_mask.flags.q.packed = 1;
+   ubo_layout_mask.flags.q.shared = 1;
+
+   /* Uniform block layout qualifiers get to overwrite each
+* other (rightmost having priority), while all other
+* qualifiers currently don't allow duplicates.
+*/
+
+   if ((this->flags.i & q.flags.i & ~(ubo_mat_mask.flags.i |
+ ubo_layout_mask.flags.i)) != 0) {
+  _mesa_glsl_error(loc, state,
+  "duplicate layout qualifiers used\n");
+  return false;
+   }
+
+   if ((q.flags.i & ubo_mat_mask.flags.i) != 0)
+  this->flags.i &= ~ubo_mat_mask.flags.i;
+   if ((q.flags.i & ubo_layout_mask.flags.i) != 0)
+  this->flags.i &= ~ubo_layout_mask.flags.i;
+
+   this->flags.i |= q.flags.i;
+
+   if (q.flags.q.explicit_location)
+  this->location = q.location;
+
+   if (q.flags.q.explicit_index)
+  this->index = q.index;
+
+   return true;
+}
+
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 2787721..52858e1 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1106,42 +1106,10 @@ layout_qualifier_id_list:
layout_qualifier_id
| layout_qualifier_id_list ',' layout_qualifier_id
{
-  ast_type_qualifier ubo_mat_mask;
-  ubo_mat_mask.flags.i = 0;
-  ubo_mat_mask.flags.q.row_major = 1;
-  ubo_mat_mask.flags.q.column_major = 1;
-
-  ast_type_qualifier ubo_layout_mask;
-  ubo_layout_mask.flags.i = 0;
-  ubo_layout_mask.flags.q.std140 = 1;
-  ubo_layout_mask.flags.q.packed = 1;
-  ubo_layout_mask.flags.q.shared = 1;
-
-  /* Uniform block layout qualifiers get to overwrite each
-   * other (rightmost having priority), while all other
-   * qualifiers currently don't allow duplicates.
-   */
-  if (($1.flags.i & $3.flags.i & ~(ubo_mat_mask.flags.i |
-   ubo_layout_mask.flags.i)) != 0) {
- _mesa_glsl_error(& @3, state,
-  "duplicate layout qualifiers used\n");
+  $$ = $1;
+  if (!$$.merge_qualifier(& @3, state, $3)) {
  YYERROR;
   }
-
-  $$ = $1;
-
-  if (($3.flags.i & ubo_mat_mask.flags.i) != 0)
- $$.flags.i &= ~ubo_mat_mask.flags.i;
-  if (($3.flags.i & ubo_layout_mask.flags.i) != 0)
- $$.flags.i &= ~ubo_layout_mask.flags.i;
-
-  $$.flags.i |= $3.flags.i;
-
-  if ($3.flags.q.explicit_location)
- $$.location = $3.location;
-
-  if ($3.flags.q.explicit_index)
- $$.

[Mesa-dev] [PATCH 02/11] glsl: Incorporate all UBO language changes into GLSL 1.40.

2012-07-20 Thread Eric Anholt
---
 src/glsl/glsl_parser.yy |4 
 1 file changed, 4 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index b2533c8..0ed424d 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -291,6 +291,10 @@ version_statement:
   state->version_string,
   state->supported_version_string);
   }
+
+  if (state->language_version >= 140) {
+ state->ARB_uniform_buffer_object_enable = true;
+  }
}
;
 
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 05/11] mesa: Add support for most of the other pnames of glGetActiveUniformBlockiv().

2012-07-20 Thread Eric Anholt
---
 src/mesa/main/uniforms.c |   30 ++
 1 file changed, 30 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 3236d6e..6652251 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -643,6 +643,7 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
GET_CURRENT_CONTEXT(ctx);
struct gl_shader_program *shProg;
struct gl_uniform_block *block;
+   unsigned i;
 
if (!ctx->Extensions.ARB_uniform_buffer_object) {
   _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
@@ -668,10 +669,39 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
   params[0] = block->Binding;
   return;
 
+   case GL_UNIFORM_BLOCK_DATA_SIZE:
+  params[0] = block->UniformBufferSize;
+  return;
+
case GL_UNIFORM_BLOCK_NAME_LENGTH:
   params[0] = strlen(block->Name) + 1;
   return;
 
+   case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
+  params[0] = block->NumUniforms;
+  return;
+
+   case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
+  for (i = 0; i < block->NumUniforms; i++) {
+unsigned offset;
+params[i] = _mesa_get_uniform_location(ctx, shProg,
+   block->Uniforms[i].Name,
+   &offset);
+  }
+  return;
+
+   case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
+  params[0] = 
shProg->UniformBlockStageIndex[MESA_SHADER_VERTEX][uniformBlockIndex] != -1;
+  return;
+
+   case GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER:
+  params[0] = 
shProg->UniformBlockStageIndex[MESA_SHADER_GEOMETRY][uniformBlockIndex] != -1;
+  return;
+
+   case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
+  params[0] = 
shProg->UniformBlockStageIndex[MESA_SHADER_FRAGMENT][uniformBlockIndex] != -1;
+  return;
+
default:
   _mesa_error(ctx, GL_INVALID_ENUM,
  "glGetActiveUniformBlockiv(pname 0x%x (%s))",
-- 
1.7.10.4

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


[Mesa-dev] Last big core UBO support dump.

2012-07-20 Thread Eric Anholt
I've managed to get the lowering pass working sufficiently to get the same set
of tests passing on i965, and the problems seem tractable enough to go with
that.  I'm hoping to finish up UBOs by the end of the month.  Here are my
remaining core changes other than that lowering pass.

There are a couple of oglconform failures related to the core support that I
haven't dealt with yet.  It expects to be able to declare a structure type
without declaring a variable.  I need to spend a bit more time with the spec,
and maybe just some experimenting on other drivers, to see if this is correct.
Also, it complains about the offset of variable 13 in one of the awful
make-random-variables-in-a-uniform-block tests.  We also don't check block
size against limits yet, but it's not in an oglconform or piglit test currently.

As usual, the WIP stuff is in the "ubo" branch of my mesa tree.

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


[Mesa-dev] [PATCH 04/11] mesa: Add support for getting active uniform block names.

2012-07-20 Thread Eric Anholt
Fixes piglit ARB_uniform_buffer_object/getactiveuniformblockname.
---
 src/mesa/main/uniforms.c |   47 ++
 1 file changed, 47 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 940cb07..3236d6e 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -668,6 +668,10 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
   params[0] = block->Binding;
   return;
 
+   case GL_UNIFORM_BLOCK_NAME_LENGTH:
+  params[0] = strlen(block->Name) + 1;
+  return;
+
default:
   _mesa_error(ctx, GL_INVALID_ENUM,
  "glGetActiveUniformBlockiv(pname 0x%x (%s))",
@@ -676,6 +680,48 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
}
 }
 
+static void GLAPIENTRY
+_mesa_GetActiveUniformBlockName(GLuint program,
+   GLuint uniformBlockIndex,
+   GLsizei bufSize,
+   GLsizei *length,
+   GLchar *uniformBlockName)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_program *shProg;
+   struct gl_uniform_block *block;
+
+   if (!ctx->Extensions.ARB_uniform_buffer_object) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+  return;
+   }
+
+   if (bufSize < 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformBlockName(bufSize %d < 0)",
+ bufSize);
+  return;
+   }
+
+   shProg = _mesa_lookup_shader_program_err(ctx, program,
+   "glGetActiveUniformBlockiv");
+   if (!shProg)
+  return;
+
+   if (uniformBlockIndex >= shProg->NumUniformBlocks) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformBlockiv(block index %d >= %d)",
+ uniformBlockIndex, shProg->NumUniformBlocks);
+  return;
+   }
+
+   block = &shProg->UniformBlocks[uniformBlockIndex];
+
+   if (uniformBlockName) {
+  _mesa_copy_string(uniformBlockName, bufSize, length, block->Name);
+   }
+}
+
 /**
  * Plug in shader uniform-related functions into API dispatch table.
  */
@@ -738,6 +784,7 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table 
*exec)
SET_GetUniformIndices(exec, _mesa_GetUniformIndices);
SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv);
SET_GetActiveUniformBlockiv(exec, _mesa_GetActiveUniformBlockiv);
+   SET_GetActiveUniformBlockName(exec, _mesa_GetActiveUniformBlockName);
SET_UniformBlockBinding(exec, _mesa_UniformBlockBinding);
 
 #endif /* FEATURE_GL */
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 01/11] mesa: Add support for glGetProgramiv pnames for UBOs.

2012-07-20 Thread Eric Anholt
Fixes piglit ARB_uniform_buffer_object/getprogramiv.
---
 src/mesa/main/shaderapi.c |   19 +++
 1 file changed, 19 insertions(+)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 6927368..f381915 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -542,6 +542,25 @@ get_programiv(struct gl_context *ctx, GLuint program, 
GLenum pname, GLint *param
   *params = shProg->Geom.OutputType;
   break;
 #endif
+   case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: {
+  unsigned i;
+  GLint max_len = 0;
+
+  for (i = 0; i < shProg->NumUniformBlocks; i++) {
+/* Add one for the terminating NUL character.
+ */
+const GLint len = strlen(shProg->UniformBlocks[i].Name) + 1;
+
+if (len > max_len)
+   max_len = len;
+  }
+
+  *params = max_len;
+  break;
+   }
+   case GL_ACTIVE_UNIFORM_BLOCKS:
+  *params = shProg->NumUniformBlocks;
+  break;
default:
   _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
   return;
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 03/11] mesa: Add support for glUniformBlockBinding() and the API to get it back.

2012-07-20 Thread Eric Anholt
Fixes piglit ARB_uniform_buffer_object/uniformbufferbinding.
---
 src/mesa/main/uniforms.c |   95 ++
 1 file changed, 95 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index ccbd753..940cb07 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -41,6 +41,7 @@
 #include "main/shaderapi.h"
 #include "main/shaderobj.h"
 #include "main/uniforms.h"
+#include "main/enums.h"
 #include "ir_uniform.h"
 #include "glsl_types.h"
 
@@ -583,6 +584,98 @@ _mesa_GetUniformIndices(GLuint program,
}
 }
 
+static void GLAPIENTRY
+_mesa_UniformBlockBinding(GLuint program,
+ GLuint uniformBlockIndex,
+ GLuint uniformBlockBinding)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_program *shProg;
+
+   if (!ctx->Extensions.ARB_uniform_buffer_object) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glUniformBlockBinding");
+  return;
+   }
+
+   shProg = _mesa_lookup_shader_program_err(ctx, program,
+   "glUniformBlockBinding");
+   if (!shProg)
+  return;
+
+   if (uniformBlockIndex >= shProg->NumUniformBlocks) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+ "glUniformBlockBinding(block index %d >= %d)",
+ uniformBlockIndex, shProg->NumUniformBlocks);
+  return;
+   }
+
+   if (uniformBlockBinding >= ctx->Const.MaxUniformBufferBindings) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+ "glUniformBlockBinding(block binding %d >= %d)",
+ uniformBlockBinding, ctx->Const.MaxUniformBufferBindings);
+  return;
+   }
+
+   if (shProg->UniformBlocks[uniformBlockIndex].Binding !=
+   uniformBlockBinding) {
+  int i;
+
+  FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
+  shProg->UniformBlocks[uniformBlockIndex].Binding = uniformBlockBinding;
+
+  for (i = 0; i < MESA_SHADER_TYPES; i++) {
+int stage_index = shProg->UniformBlockStageIndex[i][uniformBlockIndex];
+
+if (stage_index != -1) {
+   struct gl_shader *sh = shProg->_LinkedShaders[i];
+   sh->UniformBlocks[stage_index].Binding = uniformBlockBinding;
+}
+  }
+   }
+}
+
+static void GLAPIENTRY
+_mesa_GetActiveUniformBlockiv(GLuint program,
+ GLuint uniformBlockIndex,
+ GLenum pname,
+ GLint *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_program *shProg;
+   struct gl_uniform_block *block;
+
+   if (!ctx->Extensions.ARB_uniform_buffer_object) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+  return;
+   }
+
+   shProg = _mesa_lookup_shader_program_err(ctx, program,
+   "glGetActiveUniformBlockiv");
+   if (!shProg)
+  return;
+
+   if (uniformBlockIndex >= shProg->NumUniformBlocks) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformBlockiv(block index %d >= %d)",
+ uniformBlockIndex, shProg->NumUniformBlocks);
+  return;
+   }
+
+   block = &shProg->UniformBlocks[uniformBlockIndex];
+
+   switch (pname) {
+   case GL_UNIFORM_BLOCK_BINDING:
+  params[0] = block->Binding;
+  return;
+
+   default:
+  _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetActiveUniformBlockiv(pname 0x%x (%s))",
+ pname, _mesa_lookup_enum_by_nr(pname));
+  return;
+   }
+}
+
 /**
  * Plug in shader uniform-related functions into API dispatch table.
  */
@@ -644,6 +737,8 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table 
*exec)
SET_GetUniformBlockIndex(exec, _mesa_GetUniformBlockIndex);
SET_GetUniformIndices(exec, _mesa_GetUniformIndices);
SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv);
+   SET_GetActiveUniformBlockiv(exec, _mesa_GetActiveUniformBlockiv);
+   SET_UniformBlockBinding(exec, _mesa_UniformBlockBinding);
 
 #endif /* FEATURE_GL */
 }
-- 
1.7.10.4

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


Re: [Mesa-dev] [PATCH, android-build] android-build: fix dricore build for autogenerated files

2012-07-20 Thread Sean V Kelley
On Fri, Jul 20, 2012 at 2:41 PM, Daniel Charles
 wrote:
> Recently more files were removed from control to be auto-generated
> in the dricore library. Android build was not able to locate the
> new files if they were not created beforehand.
>
> LOCAL_SRC_FILES includes some of those files and Android.gen.mk
> re-defines this variable by filtering out the auto-generated files.
> Unfortunately for this variable it is not the same to have the SRCDIR
> variable defined as the current directory.
>
> By removing SRCDIR the Android build system is happy again and the new
> files were actually removed from the sources to use the auto generated
> versions.
>
> Also patch d5c1801a018efda8ac2b was partially reverted as the files
> can not be compiled to the LOCAL_PATH, instead they should live on the
> intermediates folder so that a clean can wipe them out.
>
> Change-Id: I75e86453d23f6b6f0e2a7dfb1b48272965c9fbf2
> Signed-off-by: Daniel Charles 

Acked-by: Sean V Kelley 


Sean

> ---
>  src/mesa/Android.gen.mk |   68 +--
>  src/mesa/Android.mk |1 -
>  src/mesa/sources.mak|  558 
> +++
>  3 files changed, 330 insertions(+), 297 deletions(-)
>
> diff --git a/src/mesa/Android.gen.mk b/src/mesa/Android.gen.mk
> index 2ea8cc4..5443bb9 100644
> --- a/src/mesa/Android.gen.mk
> +++ b/src/mesa/Android.gen.mk
> @@ -28,12 +28,19 @@ LOCAL_MODULE_CLASS := STATIC_LIBRARIES
>  endif
>
>  intermediates := $(call local-intermediates-dir)
> -mydir := $(call my-dir)
>
> +# This is the list of auto-generated files: sources and headers
>  sources := \
> +   main/enums.c \
> +   main/api_exec_es1.c \
> main/api_exec_es1_dispatch.h \
> main/api_exec_es1_remap_helper.h \
> +   main/api_exec_es2.c \
> main/api_exec_es2_dispatch.h \
> +   program/program_parse.tab.c \
> +   program/lex.yy.c \
> +   main/dispatch.h \
> +   main/remap_helper.h \
> main/api_exec_es2_remap_helper.h
>
>  LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
> @@ -65,37 +72,49 @@ es_hdr_deps := \
> $(wildcard $(glapi)/*.py) \
> $(wildcard $(glapi)/*.xml)
>
> +define local-l-to-c
> +   @mkdir -p $(dir $@)
> +   @echo "Mesa Lex: $(PRIVATE_MODULE) <= $<"
> +   $(hide) $(LEX) -o$@ $<
> +endef
> +
> +define local-y-to-c-and-h
> +   @mkdir -p $(dir $@)
> +   @echo "Mesa Yacc: $(PRIVATE_MODULE) <= $<"
> +   $(hide) $(YACC) -o $@ $<
> +endef
> +
>  define es-gen
> @mkdir -p $(dir $@)
> @echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
> $(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
>  endef
>
> -define generate-local
> -   @echo "generate local sources"
> -   $(hide) $(MESA_PYTHON2) $(glapi)/gl_enums.py -f 
> $(glapi)/gl_and_es_API.xml > $(mydir)/main/enums.c
> -   $(hide) $(MESA_PYTHON2) $(glapi)/gl_table.py -m remap_table -f 
> $(glapi)/gl_and_es_API.xml > $(mydir)/main/dispatch.h
> -   $(hide) $(MESA_PYTHON2) $(glapi)/remap_helper.py -f 
> $(glapi)/gl_API.xml > $(mydir)/main/remap_helper.h
> -   $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES1.1 -S 
> $(mydir)/main/APIspec.xml > $(mydir)/main/api_exec_es1.c
> -   $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES2.0 -S 
> $(mydir)/main/APIspec.xml > $(mydir)/main/api_exec_es2.c
> -
> -   @echo "Mesa Lex : $(PRIVATE_MODULE)"
> -   $(hide) $(LEX) -o $(mydir)/program/lex.yy.c 
> $(mydir)/program/program_lexer.l
> -   @echo "Mesa Yacc: $(PRIVATE_MODULE)"
> -   $(hide) $(YACC) -d -o $(mydir)/program/program_parse.tab.c 
> $(mydir)/program/program_parse.y
> -endef
> -
> +$(intermediates)/main/api_exec_%.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) 
> $(LOCAL_PATH)/main/es_generator.py
> +$(intermediates)/main/api_exec_%.c: PRIVATE_XML := -S 
> $(LOCAL_PATH)/main/APIspec.xml
>  $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_SCRIPT := 
> $(MESA_PYTHON2) $(glapi)/gl_table.py
>  $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_XML := -f 
> $(glapi)/gl_and_es_API.xml
>  $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_SCRIPT := 
> $(MESA_PYTHON2) $(glapi)/remap_helper.py
>  $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_XML := -f 
> $(glapi)/gl_and_es_API.xml
>
> +$(intermediates)/main/api_exec_es1.c: $(es_src_deps)
> +   $(call es-gen, -V GLES1.1)
> +
> +$(intermediates)/main/api_exec_es2.c: $(es_src_deps)
> +   $(call es-gen, -V GLES2.0)
> +
>  $(intermediates)/main/api_exec_%_dispatch.h: $(es_hdr_deps)
> $(call es-gen, -c $* -m remap_table)
>
>  $(intermediates)/main/api_exec_%_remap_helper.h: $(es_hdr_deps)
> $(call es-gen, -c $*)
>
> +$(intermediates)/program/program_parse.tab.c: 
> $(LOCAL_PATH)/program/program_parse.y
> +   $(local-y-to-c-and-h)
> +
> +$(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program/program_lexer.l
> +   $(local-l-to-c)
> +
>  $(intermediates)/main/git_sha1.h:
> @mkdir -p $(dir

Re: [Mesa-dev] [PATCH 1/4] Use INV_SQRT instead of 1/SQRTF

2012-07-20 Thread Kenneth Graunke
On 07/20/2012 11:24 AM, Matt Turner wrote:
> ---
>  src/mesa/math/m_debug_norm.c |4 ++--
>  src/mesa/tnl/t_vb_points.c   |2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c
> index 02eb1f9..dc768f3 100644
> --- a/src/mesa/math/m_debug_norm.c
> +++ b/src/mesa/math/m_debug_norm.c
> @@ -165,7 +165,7 @@ static void ref_norm_transform_normalize( const GLmatrix 
> *mat,
>   /* Hmmm, don't know how we could test the precalculated
>* length case...
>*/
> -scale = 1.0 / SQRTF( len );
> +scale = INV_SQRTF( len );
>   SCALE_SCALAR_3V( out[i], scale, t );
>   } else {
>  out[i][0] = out[i][1] = out[i][2] = 0;
> @@ -241,7 +241,7 @@ static int test_norm_function( normal_func func, int 
> mtype, long *cycles )
>ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
>for ( j = 0 ; j < 3 ; j++ )
>   s[i][j] = rnd();
> -  length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
> +  length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
> }
>  
> source->data = (GLfloat(*)[4]) s;
> diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c
> index 9edbbc7..0e33b69 100644
> --- a/src/mesa/tnl/t_vb_points.c
> +++ b/src/mesa/tnl/t_vb_points.c
> @@ -64,7 +64,7 @@ run_point_stage(struct gl_context *ctx, struct 
> tnl_pipeline_stage *stage)
>for (i = 0; i < VB->Count; i++) {
>   const GLfloat dist = FABSF(*eyeCoord);
>   const GLfloat q = p0 + dist * (p1 + dist * p2);
> - const GLfloat atten = (q != 0.0F) ? SQRTF(1.0F / q) : 1.0F;
> + const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F;
>   size[i][0] = pointSize * atten; /* clamping done in rasterization */
>   eyeCoord += eyeCoordStride;
>}

Why change this?  I don't see why the new version is any better.  More
precise, maybe?

Also, why use INV_SQRT rather than just leaving all of these as 1.0 / SQRTF?

Patches 2-4 are:
Reviewed-by: Kenneth Graunke 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/4] i965: make the length for PIPE_CONTROL explicit

2012-07-20 Thread Daniel Vetter
PIPE_CONTROL has variable length, depending upon gen and whether we
write out 32bit or 64bit. So make this explicit.

Suggested by Kenneth Graunke.
---
 src/mesa/drivers/dri/i965/brw_queryobj.c   |   22 +++---
 src/mesa/drivers/dri/i965/gen6_vs_state.c  |2 +-
 src/mesa/drivers/dri/intel/intel_batchbuffer.c |   16 
 src/mesa/drivers/dri/intel/intel_reg.h |2 +-
 4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c 
b/src/mesa/drivers/dri/i965/brw_queryobj.c
index a6b3e22..663344a 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -137,7 +137,7 @@ brw_begin_query(struct gl_context *ctx, struct 
gl_query_object *q)
* needs a pipe control with CS_STALL set beforehand.
* Workaround: CS_STALL can't be set alone, we pick 
STALL_AT_SCOREBOARD
* like the kernel. */
-  OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+  OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
   OUT_BATCH(PIPE_CONTROL_CS_STALL |
 PIPE_CONTROL_STALL_AT_SCOREBOARD);
   OUT_BATCH(0);
@@ -156,7 +156,7 @@ brw_begin_query(struct gl_context *ctx, struct 
gl_query_object *q)
   } else {
  BEGIN_BATCH(4);
  OUT_BATCH(_3DSTATE_PIPE_CONTROL |
- PIPE_CONTROL_WRITE_TIMESTAMP);
+ PIPE_CONTROL_WRITE_TIMESTAMP | (4 - 2));
  OUT_RELOC(query->bo,
  I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
  PIPE_CONTROL_GLOBAL_GTT_WRITE |
@@ -219,7 +219,7 @@ brw_end_query(struct gl_context *ctx, struct 
gl_query_object *q)
* needs a pipe control with CS_STALL set beforehand.
* Workaround: CS_STALL can't be set alone, we pick 
STALL_AT_SCOREBOARD
* like the kernel. */
-  OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+  OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
   OUT_BATCH(PIPE_CONTROL_CS_STALL |
 PIPE_CONTROL_STALL_AT_SCOREBOARD);
   OUT_BATCH(0);
@@ -238,7 +238,7 @@ brw_end_query(struct gl_context *ctx, struct 
gl_query_object *q)
   } else {
  BEGIN_BATCH(4);
  OUT_BATCH(_3DSTATE_PIPE_CONTROL |
- PIPE_CONTROL_WRITE_TIMESTAMP);
+ PIPE_CONTROL_WRITE_TIMESTAMP | (4 - 2));
  OUT_RELOC(query->bo,
  I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
  PIPE_CONTROL_GLOBAL_GTT_WRITE |
@@ -367,7 +367,7 @@ brw_emit_query_begin(struct brw_context *brw)
* needs a pipe control with CS_STALL set beforehand.
* Workaround: CS_STALL can't be set alone, we pick STALL_AT_SCOREBOARD
* like the kernel. */
-   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
OUT_BATCH(PIPE_CONTROL_CS_STALL |
 PIPE_CONTROL_STALL_AT_SCOREBOARD);
OUT_BATCH(0);
@@ -386,7 +386,7 @@ brw_emit_query_begin(struct brw_context *brw)
/* We need to emit depth stall to get the right value for the depth
* count. As a workaround this needs a preceeding pipe control with a
* non-zero post-sync op, the depth count write above does that for us. 
*/
-   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
OUT_BATCH(PIPE_CONTROL_DEPTH_STALL);
OUT_BATCH(0);
OUT_BATCH(0);
@@ -396,7 +396,7 @@ brw_emit_query_begin(struct brw_context *brw)
BEGIN_BATCH(4);
OUT_BATCH(_3DSTATE_PIPE_CONTROL |
   PIPE_CONTROL_DEPTH_STALL |
-  PIPE_CONTROL_WRITE_DEPTH_COUNT);
+  PIPE_CONTROL_WRITE_DEPTH_COUNT | (4 - 2));
/* This object could be mapped cacheable, but we don't have an exposed
* mechanism to support that.  Since it's going uncached, tell GEM that
* we're writing to it.  The usual clflush should be all that's required
@@ -438,9 +438,9 @@ brw_emit_query_end(struct brw_context *brw)
* needs a pipe control with CS_STALL set beforehand.
* Workaround: CS_STALL can't be set alone, we pick STALL_AT_SCOREBOARD
* like the kernel. */
-   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
OUT_BATCH(PIPE_CONTROL_CS_STALL |
-PIPE_CONTROL_STALL_AT_SCOREBOARD);
+PIPE_CONTROL_STALL_AT_SCOREBOARD | (4 - 2));
OUT_BATCH(0);
OUT_BATCH(0);
 
@@ -457,7 +457,7 @@ brw_emit_query_end(struct brw_context *brw)
/* We need to emit depth stall to get the right value for the depth
* count. As a workaround this needs a preceeding pipe control with a
* non-zero post-sync op, the depth count write above does that for us. 
*/
-   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
OUT_BATCH(PIPE_CONTROL_DEPTH_STALL);
OUT_BATCH(0)

[Mesa-dev] [PATCH 3/4] i965: adjust gen6+ timestamp pipe_control writes

2012-07-20 Thread Daniel Vetter
Similar treatment to the depth count pipe_control writes
- Add the CS_STALL workaround, timestamp writes are non-zero post-sync
  ops, too.
- Also ensure that we write the full 64bits by using the 5 dword long
  variant of pipe_control.

v2: Implement |(5-2) suggestion from Kenneth Graunke.
---
 src/mesa/drivers/dri/i965/brw_queryobj.c |   32 ++
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c 
b/src/mesa/drivers/dri/i965/brw_queryobj.c
index 8049580..a6b3e22 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -131,14 +131,26 @@ brw_begin_query(struct gl_context *ctx, struct 
gl_query_object *q)
 4096, 4096);
 
   if (intel->gen >= 6) {
- BEGIN_BATCH(4);
- OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+ BEGIN_BATCH(9);
+
+  /* Workaround: A non-zero post-sync op (i.e. the DEPTH_COUNT write 
below
+   * needs a pipe control with CS_STALL set beforehand.
+   * Workaround: CS_STALL can't be set alone, we pick 
STALL_AT_SCOREBOARD
+   * like the kernel. */
+  OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+  OUT_BATCH(PIPE_CONTROL_CS_STALL |
+PIPE_CONTROL_STALL_AT_SCOREBOARD);
+  OUT_BATCH(0);
+  OUT_BATCH(0);
+
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (5 - 2));
  OUT_BATCH(PIPE_CONTROL_WRITE_TIMESTAMP);
  OUT_RELOC(query->bo,
  I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
  PIPE_CONTROL_GLOBAL_GTT_WRITE |
  0);
  OUT_BATCH(0);
+ OUT_BATCH(0);
  ADVANCE_BATCH();
   
   } else {
@@ -201,14 +213,26 @@ brw_end_query(struct gl_context *ctx, struct 
gl_query_object *q)
switch (query->Base.Target) {
case GL_TIME_ELAPSED_EXT:
   if (intel->gen >= 6) {
- BEGIN_BATCH(4);
- OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+ BEGIN_BATCH(9);
+
+  /* Workaround: A non-zero post-sync op (i.e. the DEPTH_COUNT write 
below
+   * needs a pipe control with CS_STALL set beforehand.
+   * Workaround: CS_STALL can't be set alone, we pick 
STALL_AT_SCOREBOARD
+   * like the kernel. */
+  OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+  OUT_BATCH(PIPE_CONTROL_CS_STALL |
+PIPE_CONTROL_STALL_AT_SCOREBOARD);
+  OUT_BATCH(0);
+  OUT_BATCH(0);
+
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL | (5 - 2));
  OUT_BATCH(PIPE_CONTROL_WRITE_TIMESTAMP);
  OUT_RELOC(query->bo,
  I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
  PIPE_CONTROL_GLOBAL_GTT_WRITE |
  8);
  OUT_BATCH(0);
+ OUT_BATCH(0);
  ADVANCE_BATCH();
   
   } else {
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 1/4] i965: tackle the occlusion query pipe control mess

2012-07-20 Thread Daniel Vetter
- Separate out the depth stall from the depth count write, workarounds
  say that a depth stall needs to be preceeded with a non-zero
  post-sync op.
- Implement the cs stall workaround like the kernel does.

I've hoped that this would fix a occlusion query issue on snb, but
alas, it doesn't seem to help.
---
 src/mesa/drivers/dri/i965/brw_queryobj.c |   53 ++
 1 file changed, 39 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c 
b/src/mesa/drivers/dri/i965/brw_queryobj.c
index 240fe32..52db050 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -337,22 +337,34 @@ brw_emit_query_begin(struct brw_context *brw)
   return;
 
if (intel->gen >= 6) {
-   BEGIN_BATCH(8);
+   BEGIN_BATCH(12);
 
-   /* workaround: CS stall required before depth stall. */
+   /* Workaround: A non-zero post-sync op (i.e. the DEPTH_COUNT write below
+   * needs a pipe control with CS_STALL set beforehand.
+   * Workaround: CS_STALL can't be set alone, we pick STALL_AT_SCOREBOARD
+   * like the kernel. */
OUT_BATCH(_3DSTATE_PIPE_CONTROL);
-   OUT_BATCH(PIPE_CONTROL_CS_STALL);
-   OUT_BATCH(0); /* write address */
-   OUT_BATCH(0); /* write data */
+   OUT_BATCH(PIPE_CONTROL_CS_STALL |
+PIPE_CONTROL_STALL_AT_SCOREBOARD);
+   OUT_BATCH(0);
+   OUT_BATCH(0);
 
+   /* The actual DEPTH_COUNT write. */
OUT_BATCH(_3DSTATE_PIPE_CONTROL);
-   OUT_BATCH(PIPE_CONTROL_DEPTH_STALL |
-PIPE_CONTROL_WRITE_DEPTH_COUNT);
+   OUT_BATCH(PIPE_CONTROL_WRITE_DEPTH_COUNT);
OUT_RELOC(brw->query.bo,
 I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
 PIPE_CONTROL_GLOBAL_GTT_WRITE |
 ((brw->query.index * 2) * sizeof(uint64_t)));
OUT_BATCH(0);
+
+   /* We need to emit depth stall to get the right value for the depth
+   * count. As a workaround this needs a preceeding pipe control with a
+   * non-zero post-sync op, the depth count write above does that for us. 
*/
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(PIPE_CONTROL_DEPTH_STALL);
+   OUT_BATCH(0);
+   OUT_BATCH(0);
ADVANCE_BATCH();

} else {
@@ -395,21 +407,34 @@ brw_emit_query_end(struct brw_context *brw)
   return;
 
if (intel->gen >= 6) {
-   BEGIN_BATCH(8);
-   /* workaround: CS stall required before depth stall. */
+   BEGIN_BATCH(12);
+
+   /* Workaround: A non-zero post-sync op (i.e. the DEPTH_COUNT write below
+   * needs a pipe control with CS_STALL set beforehand.
+   * Workaround: CS_STALL can't be set alone, we pick STALL_AT_SCOREBOARD
+   * like the kernel. */
OUT_BATCH(_3DSTATE_PIPE_CONTROL);
-   OUT_BATCH(PIPE_CONTROL_CS_STALL);
-   OUT_BATCH(0); /* write address */
-   OUT_BATCH(0); /* write data */
+   OUT_BATCH(PIPE_CONTROL_CS_STALL |
+PIPE_CONTROL_STALL_AT_SCOREBOARD);
+   OUT_BATCH(0);
+   OUT_BATCH(0);
 
+   /* The actual DEPTH_COUNT write. */
OUT_BATCH(_3DSTATE_PIPE_CONTROL);
-   OUT_BATCH(PIPE_CONTROL_DEPTH_STALL |
-PIPE_CONTROL_WRITE_DEPTH_COUNT);
+   OUT_BATCH(PIPE_CONTROL_WRITE_DEPTH_COUNT);
OUT_RELOC(brw->query.bo,
 I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
 PIPE_CONTROL_GLOBAL_GTT_WRITE |
 ((brw->query.index * 2 + 1) * sizeof(uint64_t)));
OUT_BATCH(0);
+
+   /* We need to emit depth stall to get the right value for the depth
+   * count. As a workaround this needs a preceeding pipe control with a
+   * non-zero post-sync op, the depth count write above does that for us. 
*/
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(PIPE_CONTROL_DEPTH_STALL);
+   OUT_BATCH(0);
+   OUT_BATCH(0);
ADVANCE_BATCH();

} else {
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 2/4] i965: we want 64bit writes for depth count

2012-07-20 Thread Daniel Vetter
... and the hardware seems to take the lenght of the pipe control
command to indicate whether the write is 64bit or 32bit. Which makes
sense for immediate writes.

I've discovered this by writing a pattern into the query object bo and
noticing that the high 32bits are left intact, even on those pipe
control writes that seemingly worked.

v2: use | (5-2) to denote 5 dword long PIPE_CONTROL commands, as
suggested by Kenneth Graunke.
---
 src/mesa/drivers/dri/i965/brw_queryobj.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c 
b/src/mesa/drivers/dri/i965/brw_queryobj.c
index 52db050..8049580 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -337,7 +337,7 @@ brw_emit_query_begin(struct brw_context *brw)
   return;
 
if (intel->gen >= 6) {
-   BEGIN_BATCH(12);
+   BEGIN_BATCH(13);
 
/* Workaround: A non-zero post-sync op (i.e. the DEPTH_COUNT write below
* needs a pipe control with CS_STALL set beforehand.
@@ -350,13 +350,14 @@ brw_emit_query_begin(struct brw_context *brw)
OUT_BATCH(0);
 
/* The actual DEPTH_COUNT write. */
-   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL | (5 - 3));
OUT_BATCH(PIPE_CONTROL_WRITE_DEPTH_COUNT);
OUT_RELOC(brw->query.bo,
 I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
 PIPE_CONTROL_GLOBAL_GTT_WRITE |
 ((brw->query.index * 2) * sizeof(uint64_t)));
OUT_BATCH(0);
+   OUT_BATCH(0);
 
/* We need to emit depth stall to get the right value for the depth
* count. As a workaround this needs a preceeding pipe control with a
@@ -407,7 +408,7 @@ brw_emit_query_end(struct brw_context *brw)
   return;
 
if (intel->gen >= 6) {
-   BEGIN_BATCH(12);
+   BEGIN_BATCH(13);
 
/* Workaround: A non-zero post-sync op (i.e. the DEPTH_COUNT write below
* needs a pipe control with CS_STALL set beforehand.
@@ -420,13 +421,14 @@ brw_emit_query_end(struct brw_context *brw)
OUT_BATCH(0);
 
/* The actual DEPTH_COUNT write. */
-   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL | (5 - 3));
OUT_BATCH(PIPE_CONTROL_WRITE_DEPTH_COUNT);
OUT_RELOC(brw->query.bo,
 I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
 PIPE_CONTROL_GLOBAL_GTT_WRITE |
 ((brw->query.index * 2 + 1) * sizeof(uint64_t)));
OUT_BATCH(0);
+   OUT_BATCH(0);
 
/* We need to emit depth stall to get the right value for the depth
* count. As a workaround this needs a preceeding pipe control with a
-- 
1.7.10.4

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


[Mesa-dev] [PATCH, android-build] android-build: fix dricore build for autogenerated files

2012-07-20 Thread Daniel Charles
Recently more files were removed from control to be auto-generated
in the dricore library. Android build was not able to locate the
new files if they were not created beforehand.

LOCAL_SRC_FILES includes some of those files and Android.gen.mk
re-defines this variable by filtering out the auto-generated files.
Unfortunately for this variable it is not the same to have the SRCDIR
variable defined as the current directory.

By removing SRCDIR the Android build system is happy again and the new
files were actually removed from the sources to use the auto generated
versions.

Also patch d5c1801a018efda8ac2b was partially reverted as the files
can not be compiled to the LOCAL_PATH, instead they should live on the
intermediates folder so that a clean can wipe them out.

Change-Id: I75e86453d23f6b6f0e2a7dfb1b48272965c9fbf2
Signed-off-by: Daniel Charles 
---
 src/mesa/Android.gen.mk |   68 +--
 src/mesa/Android.mk |1 -
 src/mesa/sources.mak|  558 +++
 3 files changed, 330 insertions(+), 297 deletions(-)

diff --git a/src/mesa/Android.gen.mk b/src/mesa/Android.gen.mk
index 2ea8cc4..5443bb9 100644
--- a/src/mesa/Android.gen.mk
+++ b/src/mesa/Android.gen.mk
@@ -28,12 +28,19 @@ LOCAL_MODULE_CLASS := STATIC_LIBRARIES
 endif
 
 intermediates := $(call local-intermediates-dir)
-mydir := $(call my-dir)
 
+# This is the list of auto-generated files: sources and headers
 sources := \
+   main/enums.c \
+   main/api_exec_es1.c \
main/api_exec_es1_dispatch.h \
main/api_exec_es1_remap_helper.h \
+   main/api_exec_es2.c \
main/api_exec_es2_dispatch.h \
+   program/program_parse.tab.c \
+   program/lex.yy.c \
+   main/dispatch.h \
+   main/remap_helper.h \
main/api_exec_es2_remap_helper.h
 
 LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
@@ -65,37 +72,49 @@ es_hdr_deps := \
$(wildcard $(glapi)/*.py) \
$(wildcard $(glapi)/*.xml)
 
+define local-l-to-c
+   @mkdir -p $(dir $@)
+   @echo "Mesa Lex: $(PRIVATE_MODULE) <= $<"
+   $(hide) $(LEX) -o$@ $<
+endef
+
+define local-y-to-c-and-h
+   @mkdir -p $(dir $@)
+   @echo "Mesa Yacc: $(PRIVATE_MODULE) <= $<"
+   $(hide) $(YACC) -o $@ $<
+endef
+
 define es-gen
@mkdir -p $(dir $@)
@echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
$(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
 endef
 
-define generate-local
-   @echo "generate local sources"
-   $(hide) $(MESA_PYTHON2) $(glapi)/gl_enums.py -f 
$(glapi)/gl_and_es_API.xml > $(mydir)/main/enums.c
-   $(hide) $(MESA_PYTHON2) $(glapi)/gl_table.py -m remap_table -f 
$(glapi)/gl_and_es_API.xml > $(mydir)/main/dispatch.h
-   $(hide) $(MESA_PYTHON2) $(glapi)/remap_helper.py -f $(glapi)/gl_API.xml 
> $(mydir)/main/remap_helper.h
-   $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES1.1 -S 
$(mydir)/main/APIspec.xml > $(mydir)/main/api_exec_es1.c
-   $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES2.0 -S 
$(mydir)/main/APIspec.xml > $(mydir)/main/api_exec_es2.c
-
-   @echo "Mesa Lex : $(PRIVATE_MODULE)"
-   $(hide) $(LEX) -o $(mydir)/program/lex.yy.c 
$(mydir)/program/program_lexer.l
-   @echo "Mesa Yacc: $(PRIVATE_MODULE)"
-   $(hide) $(YACC) -d -o $(mydir)/program/program_parse.tab.c 
$(mydir)/program/program_parse.y
-endef
-
+$(intermediates)/main/api_exec_%.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) 
$(LOCAL_PATH)/main/es_generator.py
+$(intermediates)/main/api_exec_%.c: PRIVATE_XML := -S 
$(LOCAL_PATH)/main/APIspec.xml
 $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) 
$(glapi)/gl_table.py
 $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_XML := -f 
$(glapi)/gl_and_es_API.xml
 $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_SCRIPT := 
$(MESA_PYTHON2) $(glapi)/remap_helper.py
 $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_XML := -f 
$(glapi)/gl_and_es_API.xml
 
+$(intermediates)/main/api_exec_es1.c: $(es_src_deps)
+   $(call es-gen, -V GLES1.1)
+
+$(intermediates)/main/api_exec_es2.c: $(es_src_deps)
+   $(call es-gen, -V GLES2.0)
+
 $(intermediates)/main/api_exec_%_dispatch.h: $(es_hdr_deps)
$(call es-gen, -c $* -m remap_table)
 
 $(intermediates)/main/api_exec_%_remap_helper.h: $(es_hdr_deps)
$(call es-gen, -c $*)
 
+$(intermediates)/program/program_parse.tab.c: 
$(LOCAL_PATH)/program/program_parse.y
+   $(local-y-to-c-and-h)
+
+$(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program/program_lexer.l
+   $(local-l-to-c)
+
 $(intermediates)/main/git_sha1.h:
@mkdir -p $(dir $@)
@echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"
@@ -115,4 +134,21 @@ $(intermediates)/x86/matypes.h: $(matypes_deps)
@mkdir -p $(dir $@)
@echo "MATYPES: $(PRIVATE_MODULE) <= $(notdir $@)"
$(hide) $< > $@
-   $(call generate-local)
+
+$(intermediates)/main/dispatch.h: PRIVATE_SCRIPT := $(ME

Re: [Mesa-dev] [PATCH] i965/gen7: Increase the WM threads to hardware limits.

2012-07-20 Thread Matt Turner
On Thu, Jul 19, 2012 at 1:17 AM, Kenneth Graunke  wrote:
> With my Sandybridge GT2's register 0x20d0 value of 0x0, bumping the
> maximum thread count to 80 also seems to work (Unigine Heaven didn't
> tank my system).  I haven't done any performance measurements.

As a quick data point, the Counter-Strike: Source video stress test
improves from 39.90 to 42.80 FPS on my i5-2540M GT2 by bumping the
thread count to 80. So, seems like it's worth investigating.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/mesa: call update_renderbuffer_surface for sRGB renderbuffers, too

2012-07-20 Thread Brian Paul

On 07/20/2012 01:04 PM, Christoph Bumiller wrote:

sRGBEnabled should affect both textures and renderbuffers, so we need
to check/update the pipe_surface format for both.

Fixes, for instance, rendering appearing too bright in wine applications
using sRGB multisample renderbuffers.
---
  src/mesa/state_tracker/st_atom_framebuffer.c |5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c 
b/src/mesa/state_tracker/st_atom_framebuffer.c
index a8907c1..1886292 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -52,7 +52,7 @@ update_renderbuffer_surface(struct st_context *st,
  struct st_renderbuffer *strb)
  {
 struct pipe_context *pipe = st->pipe;
-   struct pipe_resource *resource = strb->rtt->pt;
+   struct pipe_resource *resource = strb->rtt ? strb->rtt->pt : strb->texture;
 int rtt_width = strb->Base.Width;
 int rtt_height = strb->Base.Height;
 enum pipe_format format = st->ctx->Color.sRGBEnabled ? resource->format : 
util_format_linear(resource->format);
@@ -117,7 +117,8 @@ update_framebuffer_state( struct st_context *st )

if (strb) {
   /*printf("- framebuffer surface rtt %p\n", strb->rtt);*/
- if (strb->rtt) {
+ if (strb->rtt ||
+ (strb->texture&&  util_format_is_srgb(strb->texture->format))) {
  /* rendering to a GL texture, may have to update surface */
  update_renderbuffer_surface(st, strb);
   }


Candidate for the 8.0 branch?

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


[Mesa-dev] [PATCH] st/mesa: call update_renderbuffer_surface for sRGB renderbuffers, too

2012-07-20 Thread Christoph Bumiller
sRGBEnabled should affect both textures and renderbuffers, so we need
to check/update the pipe_surface format for both.

Fixes, for instance, rendering appearing too bright in wine applications
using sRGB multisample renderbuffers.
---
 src/mesa/state_tracker/st_atom_framebuffer.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c 
b/src/mesa/state_tracker/st_atom_framebuffer.c
index a8907c1..1886292 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -52,7 +52,7 @@ update_renderbuffer_surface(struct st_context *st,
 struct st_renderbuffer *strb)
 {
struct pipe_context *pipe = st->pipe;
-   struct pipe_resource *resource = strb->rtt->pt;
+   struct pipe_resource *resource = strb->rtt ? strb->rtt->pt : strb->texture;
int rtt_width = strb->Base.Width;
int rtt_height = strb->Base.Height;
enum pipe_format format = st->ctx->Color.sRGBEnabled ? resource->format : 
util_format_linear(resource->format);
@@ -117,7 +117,8 @@ update_framebuffer_state( struct st_context *st )
 
   if (strb) {
  /*printf("- framebuffer surface rtt %p\n", strb->rtt);*/
- if (strb->rtt) {
+ if (strb->rtt ||
+ (strb->texture && util_format_is_srgb(strb->texture->format))) {
 /* rendering to a GL texture, may have to update surface */
 update_renderbuffer_surface(st, strb);
  }
-- 
1.7.3.4

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


Re: [Mesa-dev] [PATCH 1/4] Use INV_SQRT instead of 1/SQRTF

2012-07-20 Thread Brian Paul

On 07/20/2012 12:24 PM, Matt Turner wrote:

---
  src/mesa/math/m_debug_norm.c |4 ++--
  src/mesa/tnl/t_vb_points.c   |2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c
index 02eb1f9..dc768f3 100644
--- a/src/mesa/math/m_debug_norm.c
+++ b/src/mesa/math/m_debug_norm.c
@@ -165,7 +165,7 @@ static void ref_norm_transform_normalize( const GLmatrix 
*mat,
/* Hmmm, don't know how we could test the precalculated
 * length case...
 */
-scale = 1.0 / SQRTF( len );
+scale = INV_SQRTF( len );
SCALE_SCALAR_3V( out[i], scale, t );
   } else {
  out[i][0] = out[i][1] = out[i][2] = 0;
@@ -241,7 +241,7 @@ static int test_norm_function( normal_func func, int mtype, 
long *cycles )
ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
for ( j = 0 ; j<  3 ; j++ )
   s[i][j] = rnd();
-  length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
+  length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
 }

 source->data = (GLfloat(*)[4]) s;
diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c
index 9edbbc7..0e33b69 100644
--- a/src/mesa/tnl/t_vb_points.c
+++ b/src/mesa/tnl/t_vb_points.c
@@ -64,7 +64,7 @@ run_point_stage(struct gl_context *ctx, struct 
tnl_pipeline_stage *stage)
for (i = 0; i<  VB->Count; i++) {
   const GLfloat dist = FABSF(*eyeCoord);
   const GLfloat q = p0 + dist * (p1 + dist * p2);
- const GLfloat atten = (q != 0.0F) ? SQRTF(1.0F / q) : 1.0F;
+ const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F;


I had to study sqrt(1/q) vs. 1/sqrt(q) for a minute but it's equivalent.


   size[i][0] = pointSize * atten; /* clamping done in rasterization */
   eyeCoord += eyeCoordStride;
}


For the series:
Reviewed-by: Brian Paul 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/7] build: fix location of generated files in src/mesa (v3)

2012-07-20 Thread Eric Anholt
Christopher James Halse Rogers 
writes:
> Also fix include paths for the generated headers.
>
> v2: Switch to using self-explanatory BUILDDIR/SRCDIR defined from
> top_builddir/top_srcdir rather than the ambiguous TOP.
> v3: Add both top_builddir and top_srcdir to include flags for mesa asm.
> These rely on both in-tree and build-time-generated includes.


>  ### Include directories
>  
>  INCLUDE_DIRS = \
> - -I$(TOP)/include \
> - -I$(TOP)/src/glsl \
> - -I$(TOP)/src/mesa \
> - -I$(TOP)/src/mapi \
> - -I$(TOP)/src/gallium/include \
> - -I$(TOP)/src/gallium/auxiliary
> + -I$(top_srcdir)/include \
> + -I$(top_srcdir)/src/glsl \
> +-I$(top_builddir)/src/glsl \
> + -I$(top_srcdir)/src/mesa \
> +-I$(top_builddir)/src/mesa \

weird whitespace.

This series is:

Reviewed-by: Eric Anholt 


pgpkjkXe0GN7C.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/4] Remove unused _mesa_memset16

2012-07-20 Thread Matt Turner
Unused since commit fd104a845.
---
 src/mesa/main/imports.c |   13 -
 src/mesa/main/imports.h |3 ---
 2 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index e7e877b..444de87 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -223,19 +223,6 @@ _mesa_realloc(void *oldBuffer, size_t oldSize, size_t 
newSize)
return newBuffer;
 }
 
-/**
- * Fill memory with a constant 16bit word.
- * \param dst destination pointer.
- * \param val value.
- * \param n number of words.
- */
-void
-_mesa_memset16( unsigned short *dst, unsigned short val, size_t n )
-{
-   while (n-- > 0)
-  *dst++ = val;
-}
-
 /*@}*/
 
 
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 2544400..0fc8f55 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -558,9 +558,6 @@ _mesa_exec_free( void *addr );
 extern void *
 _mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize );
 
-extern void
-_mesa_memset16( unsigned short *dst, unsigned short val, size_t n );
-
 
 #ifndef FFS_DEFINED
 #define FFS_DEFINED 1
-- 
1.7.8.6

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


[Mesa-dev] [PATCH 3/4] Remove _mesa_inv_sqrtf in favor of 1/SQRTF

2012-07-20 Thread Matt Turner
Except for a couple of explicit uses, _mesa_inv_sqrtf was disabled since
its addition in 2003 (see f9b1e524).
---
 src/mesa/main/imports.c|  106 
 src/mesa/main/imports.h|9 +---
 src/mesa/tnl/t_rasterpos.c |2 +-
 src/mesa/tnl/t_vb_texgen.c |4 +-
 4 files changed, 4 insertions(+), 117 deletions(-)

diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index fc30a6e..e7e877b 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -244,112 +244,6 @@ _mesa_memset16( unsigned short *dst, unsigned short val, 
size_t n )
 /*@{*/
 
 
-/**
- inv_sqrt - A single precision 1/sqrt routine for IEEE format floats.
- written by Josh Vanderhoof, based on newsgroup posts by James Van Buskirk
- and Vesa Karvonen.
-*/
-float
-_mesa_inv_sqrtf(float n)
-{
-#if defined(USE_IEEE) && !defined(DEBUG)
-float r0, x0, y0;
-float r1, x1, y1;
-float r2, x2, y2;
-#if 0 /* not used, see below -BP */
-float r3, x3, y3;
-#endif
-fi_type u;
-unsigned int magic;
-
-/*
- Exponent part of the magic number -
-
- We want to:
- 1. subtract the bias from the exponent,
- 2. negate it
- 3. divide by two (rounding towards -inf)
- 4. add the bias back
-
- Which is the same as subtracting the exponent from 381 and dividing
- by 2.
-
- floor(-(x - 127) / 2) + 127 = floor((381 - x) / 2)
-*/
-
-magic = 381 << 23;
-
-/*
- Significand part of magic number -
-
- With the current magic number, "(magic - u.i) >> 1" will give you:
-
- for 1 <= u.f <= 2: 1.25 - u.f / 4
- for 2 <= u.f <= 4: 1.00 - u.f / 8
-
- This isn't a bad approximation of 1/sqrt.  The maximum difference from
- 1/sqrt will be around .06.  After three Newton-Raphson iterations, the
- maximum difference is less than 4.5e-8.  (Which is actually close
- enough to make the following bias academic...)
-
- To get a better approximation you can add a bias to the magic
- number.  For example, if you subtract 1/2 of the maximum difference in
- the first approximation (.03), you will get the following function:
-
- for 1 <= u.f <= 2:1.22 - u.f / 4
- for 2 <= u.f <= 3.76: 0.97 - u.f / 8
- for 3.76 <= u.f <= 4: 0.72 - u.f / 16
- (The 3.76 to 4 range is where the result is < .5.)
-
- This is the closest possible initial approximation, but with a maximum
- error of 8e-11 after three NR iterations, it is still not perfect.  If
- you subtract 0.0332281 instead of .03, the maximum error will be
- 2.5e-11 after three NR iterations, which should be about as close as
- is possible.
-
- for 1 <= u.f <= 2:1.2167719 - u.f / 4
- for 2 <= u.f <= 3.73: 0.9667719 - u.f / 8
- for 3.73 <= u.f <= 4: 0.7167719 - u.f / 16
-
-*/
-
-magic -= (int)(0.0332281 * (1 << 25));
-
-u.f = n;
-u.i = (magic - u.i) >> 1;
-
-/*
- Instead of Newton-Raphson, we use Goldschmidt's algorithm, which
- allows more parallelism.  From what I understand, the parallelism
- comes at the cost of less precision, because it lets error
- accumulate across iterations.
-*/
-x0 = 1.0f;
-y0 = 0.5f * n;
-r0 = u.f;
-
-x1 = x0 * r0;
-y1 = y0 * r0 * r0;
-r1 = 1.5f - y1;
-
-x2 = x1 * r1;
-y2 = y1 * r1 * r1;
-r2 = 1.5f - y2;
-
-#if 1
-return x2 * r2;  /* we can stop here, and be conformant -BP */
-#else
-x3 = x2 * r2;
-y3 = y2 * r2 * r2;
-r3 = 1.5f - y3;
-
-return x3 * r3;
-#endif
-#else
-return (float) (1.0 / sqrt(n));
-#endif
-}
-
 #ifndef __GNUC__
 /**
  * Find the first bit set in a word.
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index e825f21..2544400 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -105,11 +105,7 @@ typedef union { GLfloat f; GLint i; } fi_type;
 /***
  *** INV_SQRTF: single-precision inverse square root
  ***/
-#if 0
-#define INV_SQRTF(X) _mesa_inv_sqrt(X)
-#else
-#define INV_SQRTF(X) (1.0F / SQRTF(X))  /* this is faster on a P4 */
-#endif
+#define INV_SQRTF(X) (1.0F / SQRTF(X))
 
 
 /**
@@ -565,9 +561,6 @@ _mesa_realloc( void *oldBuffer, size_t oldSize, size_t 
newSize );
 extern void
 _mesa_memset16( unsigned short *dst, unsigned short val, size_t n );
 
-extern float
-_mesa_inv_sqrtf(float x);
-
 
 #ifndef FFS_DEFINED
 #define FFS_DEFINED 1
diff --git a/src/mesa/tnl/t_rasterpos.c b/src/mesa/tnl/t_rasterpos.c
index 50b5fcb..a28ad0d 100644
--- a/src/mesa/tnl/t_rasterpos.c
+++ b/src/mesa/tnl/t_rasterpos.c
@@ -271,7 +271,7 @@ compute_texgen(struct gl_context *ctx, const GLfloat 
vObj[4], const GLfloat vEye
rz = u[2] - normal[2] * two_nu;
m = rx * rx + ry * ry + (rz + 1.0F) * 

[Mesa-dev] [PATCH 2/4] Remove _mesa_sqrt* in favor of plain sqrt

2012-07-20 Thread Matt Turner
Temporarily disabled since 2003 (see 386578c5b).

This saves us from calling sqrt() 128 times to generate the sqrttab in
one_time_init().
---
 src/mesa/main/context.c |2 -
 src/mesa/main/imports.c |  101 ---
 src/mesa/main/imports.h |   15 +--
 3 files changed, 1 insertions(+), 117 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index d5ccce0..1546c88 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -404,8 +404,6 @@ one_time_init( struct gl_context *ctx )
 
   _mesa_get_cpu_features();
 
-  _mesa_init_sqrt_table();
-
   /* context dependence is never a one-time thing... */
   _mesa_init_get_hash(ctx);
 
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 2d592a6..fc30a6e 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -243,107 +243,6 @@ _mesa_memset16( unsigned short *dst, unsigned short val, 
size_t n )
 /** \name Math */
 /*@{*/
 
-/** Wrapper around sqrt() */
-double
-_mesa_sqrtd(double x)
-{
-   return sqrt(x);
-}
-
-
-/*
- * A High Speed, Low Precision Square Root
- * by Paul Lalonde and Robert Dawson
- * from "Graphics Gems", Academic Press, 1990
- *
- * SPARC implementation of a fast square root by table
- * lookup.
- * SPARC floating point format is as follows:
- *
- * BIT 31  30  23  22  0
- * signexponentmantissa
- */
-static short sqrttab[0x100];/* declare table of square roots */
-
-void
-_mesa_init_sqrt_table(void)
-{
-#if defined(USE_IEEE) && !defined(DEBUG)
-   unsigned short i;
-   fi_type fi; /* to access the bits of a float in  C quickly  */
-   /* we use a union defined in glheader.h */
-
-   for(i=0; i<= 0x7f; i++) {
-  fi.i = 0;
-
-  /*
-   * Build a float with the bit pattern i as mantissa
-   * and an exponent of 0, stored as 127
-   */
-
-  fi.i = (i << 16) | (127 << 23);
-  fi.f = _mesa_sqrtd(fi.f);
-
-  /*
-   * Take the square root then strip the first 7 bits of
-   * the mantissa into the table
-   */
-
-  sqrttab[i] = (fi.i & 0x7f) >> 16;
-
-  /*
-   * Repeat the process, this time with an exponent of
-   * 1, stored as 128
-   */
-
-  fi.i = 0;
-  fi.i = (i << 16) | (128 << 23);
-  fi.f = sqrt(fi.f);
-  sqrttab[i+0x80] = (fi.i & 0x7f) >> 16;
-   }
-#else
-   (void) sqrttab;  /* silence compiler warnings */
-#endif /*HAVE_FAST_MATH*/
-}
-
-
-/**
- * Single precision square root.
- */
-float
-_mesa_sqrtf( float x )
-{
-#if defined(USE_IEEE) && !defined(DEBUG)
-   fi_type num;
-/* to access the bits of a float in C
- * we use a union from glheader.h */
-
-   short e; /* the exponent */
-   if (x == 0.0F) return 0.0F;  /* check for square root of 0 */
-   num.f = x;
-   e = (num.i >> 23) - 127; /* get the exponent - on a SPARC the */
-/* exponent is stored with 127 added */
-   num.i &= 0x7f;   /* leave only the mantissa */
-   if (e & 0x01) num.i |= 0x80;
-/* the exponent is odd so we have to */
-/* look it up in the second half of  */
-/* the lookup table, so we set the   */
-/* high bit*/
-   e >>= 1; /* divide the exponent by two */
-/* note that in C the shift */
-/* operators are sign preserving */
-/* for signed operands */
-   /* Do the table lookup, based on the quaternary mantissa,
-* then reconstruct the result back into a float
-*/
-   num.i = ((sqrttab[num.i >> 16]) << 16) | ((e + 127) << 23);
-
-   return num.f;
-#else
-   return (float) _mesa_sqrtd((double) x);
-#endif
-}
-
 
 /**
  inv_sqrt - A single precision 1/sqrt routine for IEEE format floats.
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index c0b6cec..e825f21 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -99,11 +99,7 @@ typedef union { GLfloat f; GLint i; } fi_type;
 /***
  *** SQRTF: single-precision square root
  ***/
-#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */
-#  define SQRTF(X)  _mesa_sqrtf(X)
-#else
-#  define SQRTF(X)  (float) sqrt((float) (X))
-#endif
+#define SQRTF(X)  (float) sqrt((float) (X))
 
 
 /***
@@ -569,18 +565,9 @@ _mesa_realloc( void *oldBuffer, size_t oldSize, size_t 
newSize );
 extern void
 _mesa_memset16( unsigned short *dst, unsigned short val, size_t n );
 
-extern double
-_mesa_sqrtd(double x);
-
-extern float
-_mesa_sqrtf(float x);
-
 extern float
 _mesa_inv_sqrtf(float x);
 
-extern void
-_mesa_init_sqrt_table(void);
-
 
 #ifndef FFS_DEFINED
 #define FFS_DEFINED 1
-- 
1.7.8.6

_

[Mesa-dev] [PATCH 1/4] Use INV_SQRT instead of 1/SQRTF

2012-07-20 Thread Matt Turner
---
 src/mesa/math/m_debug_norm.c |4 ++--
 src/mesa/tnl/t_vb_points.c   |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c
index 02eb1f9..dc768f3 100644
--- a/src/mesa/math/m_debug_norm.c
+++ b/src/mesa/math/m_debug_norm.c
@@ -165,7 +165,7 @@ static void ref_norm_transform_normalize( const GLmatrix 
*mat,
/* Hmmm, don't know how we could test the precalculated
 * length case...
 */
-scale = 1.0 / SQRTF( len );
+scale = INV_SQRTF( len );
SCALE_SCALAR_3V( out[i], scale, t );
  } else {
 out[i][0] = out[i][1] = out[i][2] = 0;
@@ -241,7 +241,7 @@ static int test_norm_function( normal_func func, int mtype, 
long *cycles )
   ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
   for ( j = 0 ; j < 3 ; j++ )
  s[i][j] = rnd();
-  length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
+  length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
}
 
source->data = (GLfloat(*)[4]) s;
diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c
index 9edbbc7..0e33b69 100644
--- a/src/mesa/tnl/t_vb_points.c
+++ b/src/mesa/tnl/t_vb_points.c
@@ -64,7 +64,7 @@ run_point_stage(struct gl_context *ctx, struct 
tnl_pipeline_stage *stage)
   for (i = 0; i < VB->Count; i++) {
  const GLfloat dist = FABSF(*eyeCoord);
  const GLfloat q = p0 + dist * (p1 + dist * p2);
- const GLfloat atten = (q != 0.0F) ? SQRTF(1.0F / q) : 1.0F;
+ const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F;
  size[i][0] = pointSize * atten; /* clamping done in rasterization */
  eyeCoord += eyeCoordStride;
   }
-- 
1.7.8.6

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


Re: [Mesa-dev] [Intel-gfx] [PATCH 4/9] intel gen4-5: Fix backface/frontface selection when one one color is written to.

2012-07-20 Thread Olivier Galibert
On Fri, Jul 20, 2012 at 10:01:03AM -0700, Eric Anholt wrote:
> > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> > b/src/mesa/drivers/dri/i965/brw_fs.cpp
> > index 3f98137..3b62952 100644
> > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> > @@ -972,6 +972,15 @@ fs_visitor::calculate_urb_setup()
> >  if (c->key.vp_outputs_written & BITFIELD64_BIT(i)) {
> > int fp_index = _mesa_vert_result_to_frag_attrib((gl_vert_result) i);
> >  
> > +/* Special case: two-sided vertex option, vertex program
> > + * only writes to the back color.  Map it to the
> > + * associated front color location.
> > + */
> > +if (i >= VERT_RESULT_BFC0 && i <= VERT_RESULT_BFC1 &&
> > +ctx->VertexProgram._TwoSideEnabled &&
> > +urb_setup[i - VERT_RESULT_BFC0 + FRAG_ATTRIB_COL0] == -1)
> > +   fp_index = i - VERT_RESULT_BFC0 + FRAG_ATTRIB_COL0;
> 
> In the fs_visitor (and brw_wm_pass*), you don't get to look at ctx->
> state like that -- you're getting called once with some set of ctx
> state, but the program will get reused even if the ctx state changes.
> You'd have to get that state into the wm prog key, and use that, which
> would guarantee that you have the appropriate program code.

Ok.  OTOH, we don't actually *need* to look at TwoSideEnabled.  If the
rest of the condition triggers it's either correct or undefined
behaviour.  So we can do it systematically.

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


Re: [Mesa-dev] [Intel-gfx] [PATCH 4/9] intel gen4-5: Fix backface/frontface selection when one one color is written to.

2012-07-20 Thread Eric Anholt
Olivier Galibert  writes:

> Shaders, piglit test ones in particular, may write only to one of
> gl_FrontColor/gl_BackColor.  The standard is unclear on whether the
> behaviour is defined in that case, but it seems reasonable to support
> it.
>
> The choice done there to pick up whichever color was actually written
> to.  That makes most of the generated piglit tests useless to test the
> backface selection, but it's simple and it works.
>
> Signed-off-by: Olivier Galibert 
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp |9 +
>  src/mesa/drivers/dri/i965/brw_wm_pass2.c |9 +
>  2 files changed, 18 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 3f98137..3b62952 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -972,6 +972,15 @@ fs_visitor::calculate_urb_setup()
>if (c->key.vp_outputs_written & BITFIELD64_BIT(i)) {
>   int fp_index = _mesa_vert_result_to_frag_attrib((gl_vert_result) i);
>  
> +/* Special case: two-sided vertex option, vertex program
> + * only writes to the back color.  Map it to the
> + * associated front color location.
> + */
> +if (i >= VERT_RESULT_BFC0 && i <= VERT_RESULT_BFC1 &&
> +ctx->VertexProgram._TwoSideEnabled &&
> +urb_setup[i - VERT_RESULT_BFC0 + FRAG_ATTRIB_COL0] == -1)
> +   fp_index = i - VERT_RESULT_BFC0 + FRAG_ATTRIB_COL0;

In the fs_visitor (and brw_wm_pass*), you don't get to look at ctx->
state like that -- you're getting called once with some set of ctx
state, but the program will get reused even if the ctx state changes.
You'd have to get that state into the wm prog key, and use that, which
would guarantee that you have the appropriate program code.


pgpO2ZaD3olsW.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] radeonsi: New state handling

2012-07-20 Thread Michel Dänzer
On Fre, 2012-07-20 at 12:21 +0200, Christian König wrote: 
> 
> this is going to be a big patchset. Since on SI+ some of the
> rendering state especially the texture and vertex setup isn't
> inside registers any more we are going to need a new state
> handling for radeonsi.
> 
> So the following patchset is a complete rewrite of it. It
> makes a couple of assumptions which as far as I know is true
> for SI and all the following generations, like having VM support,
> having a constant engine, etc...
> 
> From what I can tell it doesn't really change the functionality
> that is currently there, but at least glxgears is starting to
> show something.
> 
> So please take a look and tell me what you think about it,

The series looks good to me.

Only one minor comment: 'qued' is spelled 'queued'.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 12/18] glsl: Set the uniform_block index for the linked shader variables.

2012-07-20 Thread Eric Anholt
Ian Romanick  writes:

> On 07/02/2012 05:38 PM, Eric Anholt wrote:
>> At this point in the linking, we've totally lost track of the struct
>> gl_uniform_buffer that this pointed to in the original unlinked
>> shader, so we do a nasty n^2 walk to find it the new one based on the
>> variable name.
>>
>> Note that these point into the shader's list of gl_uniform_buffers,
>> not the linked program's.
>
> And this works when a shader is linked to multiple programs because it's 
> the copy of the original shader.  Right?

Yeah, it's the linked shader, not the original shader.


pgpVzAMyilSlu.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/xorg: fix masked transformations

2012-07-20 Thread Michel Dänzer
On Don, 2012-07-19 at 21:09 +0200, Lucas Stach wrote: 
> Someone tried to be clever and "optimized" add_vertex_data2() to just use
> two points for the texture coordinates and then reuse individual
> components. Sadly this is not how matrix multiplication works.
> 
> Fixes rendercheck -t tmcoords
> 
> Signed-off-by: Lucas Stach 

Pushed, thanks.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 52140] Ubuntu Unity - Launcher and switcher icons disappeared

2012-07-20 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=52140

--- Comment #11 from Loris Z.  2012-07-20 15:29:56 
PDT ---
I'm experiencing this bug too with xorg-edgers ppa, Ubuntu 12.10, Unity 6.0
series.

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


Re: [Mesa-dev] [PATCH 0/7] i965/blorp: Improvements to the blorp engine for Gen7.

2012-07-20 Thread Paul Berry
On 19 July 2012 18:17, Anuj Phogat  wrote:

> On Thu, Jul 12, 2012 at 10:43 AM, Paul Berry 
> wrote:
> > This patch series makes three improvements to the blorp engine (which
> > does MSAA resolves and other blits) for Gen7:
> >
> > Patches 1-3 fix downsampling of integer format framebuffers on Gen7,
> > by using the "AVG" instruction to average the samples, rather than
> > adding the samples and performing a division.  This is necessary to
> > avoid overflow with 32-bit integer buffers.  In the process, we
> > rearrange the order of adds/averages to reduce the accumulation of
> > numerical errors (patch 2).
> >
> > Patch 4 adds an optimization to the MSAA resolve when using Gen7's CMS
> > MSAA layout: when the MCS buffer indicates that all samples
> > corresponding to a given pixel contain the same color value, we don't
> > have to load all the samples and average them; we just load the first
> > sample and use its value.
> >
> > Patches 5-7 make blorp take advantage of the 3D pipeline's ability to
> > decode the IMS MSAA layout when reading from depth and stencil
> > textures.  Previously blorp would emit extra shader instructions to
> > account for the IMS MSAA layout.  This change should make blits from
> > multisampled depth and stencil buffers more efficient.
> >
> > [PATCH 1/7] i965: Add support for AVG instruction.
> > [PATCH 2/7] i965/blorp: Modify manual_blend() to avoid unnecessary loss
> of precision.
> > [PATCH 3/7] i965/blorp: Fix integer downsampling on Gen7.
> > [PATCH 4/7] i965/blorp: Optimize manual_blend() for compressed
> multisampled surfaces.
> > [PATCH 5/7] i965/blorp: Configure SURFACE_STATE correctly for IMS
> surfaces.
> > [PATCH 6/7] i965/blorp: Loosen assertions in
> compute_msaa_layout_for_pipeline.
> > [PATCH 7/7] i965/blorp: Use IMS layout when texturing from depth/stencil
> surfaces.
>
> Paul, Most of the code in these patches was unfamiliar to me. I
> reviewed these patches
> by referring to ivybridge PRM and assume that you have already tested
> them on a ivybridge
> system. I couldn't test because i don't have one.
>

No problem, Anuj.  Thanks for the review.  I have tested these patches on
Ivy Bridge (and the ones that follow) and they pass all MSAA piglit tests.
 Mostly I was looking for a second pair of eyes to double-check my reading
of the PRM and make sure I hadn't made any stupid blunders in the code :)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/3] glx: Simplify __glXReadPixelReply

2012-07-20 Thread Matt Turner
On Fri, Jul 20, 2012 at 2:09 AM, Julien Cristau  wrote:

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


[Mesa-dev] [Bug 52277] src/gallium/state_trackers/egl/common/egl_g3d_api.c:43:25: fatal error: wayland-drm.h: No such file or directory

2012-07-20 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=52277

--- Comment #1 from Kristian Høgsberg  2012-07-20 14:02:05 
UTC ---
This one should be fixed in master.

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


Re: [Mesa-dev] [PATCH v2 1/3] glx: Simplify __glXReadPixelReply

2012-07-20 Thread Alex Deucher
On Fri, Jul 20, 2012 at 5:09 AM, Julien Cristau  wrote:
> From: Julien Cristau 
>
> Doing
> size = reply.length * 4;
> [...]
> extra = 4 - (size & 3);
>
> is useless, size & 3 will always be 0.
>
> Signed-off-by: Julien Cristau 

Reviewed-by: Alex Deucher 

> ---
> v2: also change the copy in src/glx/apple
>
>  src/glx/apple/glxreply.c |5 -
>  src/mapi/glapi/gen/glX_proto_send.py |5 -
>  2 files changed, 0 insertions(+), 10 deletions(-)
>
> diff --git a/src/glx/apple/glxreply.c b/src/glx/apple/glxreply.c
> index f17ebe6..6234e3c 100644
> --- a/src/glx/apple/glxreply.c
> +++ b/src/glx/apple/glxreply.c
> @@ -86,12 +86,7 @@ __glXReadPixelReply(Display * dpy, struct glx_context * 
> gc, unsigned max_dim,
>   __glXSetError(gc, GL_OUT_OF_MEMORY);
>}
>else {
> - const GLint extra = 4 - (size & 3);
> -
>   _XRead(dpy, buf, size);
> - if (extra < 4) {
> -_XEatData(dpy, extra);
> - }
>
>   __glEmptyImage(gc, 3, width, height, depth, format, type, buf, 
> dest);
>   Xfree(buf);
> diff --git a/src/mapi/glapi/gen/glX_proto_send.py 
> b/src/mapi/glapi/gen/glX_proto_send.py
> index bec0222..9068a61 100644
> --- a/src/mapi/glapi/gen/glX_proto_send.py
> +++ b/src/mapi/glapi/gen/glX_proto_send.py
> @@ -246,12 +246,7 @@ __glXReadPixelReply( Display *dpy, struct glx_context * 
> gc, unsigned max_dim,
>  __glXSetError(gc, GL_OUT_OF_MEMORY);
>  }
>  else {
> -const GLint extra = 4 - (size & 3);
> -
>  _XRead(dpy, buf, size);
> -if ( extra < 4 ) {
> -_XEatData(dpy, extra);
> -}
>
>  __glEmptyImage(gc, 3, width, height, depth, format, type,
> buf, dest);
> --
> 1.7.2.5
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 23/23] radeonsi: remove old state handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|  191 
 src/gallium/drivers/radeonsi/r600.h|   97 --
 src/gallium/drivers/radeonsi/r600_hw_context.c |  313 +---
 .../drivers/radeonsi/r600_hw_context_priv.h|   19 --
 src/gallium/drivers/radeonsi/r600_state_common.c   |   42 ---
 src/gallium/drivers/radeonsi/radeonsi_pipe.c   |6 -
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |   19 --
 src/gallium/drivers/radeonsi/si_state_draw.c   |4 -
 8 files changed, 1 insertion(+), 690 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 299ead8..c27221c 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -30,208 +30,17 @@
 #include "util/u_memory.h"
 #include 
 
-#define GROUP_FORCE_NEW_BLOCK  0
-
-static const struct r600_reg si_config_reg_list[] = {
-   {R_0088B0_VGT_VTX_VECT_EJECT_REG, REG_FLAG_FLUSH_CHANGE},
-   {R_0088C8_VGT_ESGS_RING_SIZE, REG_FLAG_FLUSH_CHANGE},
-   {R_0088CC_VGT_GSVS_RING_SIZE, REG_FLAG_FLUSH_CHANGE},
-   {R_008A14_PA_CL_ENHANCE, REG_FLAG_FLUSH_CHANGE},
-   {R_009100_SPI_CONFIG_CNTL, REG_FLAG_ENABLE_ALWAYS | 
REG_FLAG_FLUSH_CHANGE},
-   {R_00913C_SPI_CONFIG_CNTL_1, REG_FLAG_ENABLE_ALWAYS | 
REG_FLAG_FLUSH_CHANGE},
-};
-
-static const struct r600_reg si_context_reg_list[] = {
-   {R_028004_DB_COUNT_CONTROL, 0},
-   {R_028010_DB_RENDER_OVERRIDE2, 0},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028014_DB_HTILE_DATA_BASE, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028080_TA_BC_BASE_ADDR, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_0286C4_SPI_VS_OUT_CONFIG, 0},
-   {R_0286CC_SPI_PS_INPUT_ENA, 0},
-   {R_0286D0_SPI_PS_INPUT_ADDR, 0},
-   {R_0286D8_SPI_PS_IN_CONTROL, 0},
-   {R_0286E0_SPI_BARYC_CNTL, 0},
-   {R_02870C_SPI_SHADER_POS_FORMAT, 0},
-   {R_028710_SPI_SHADER_Z_FORMAT, 0},
-   {R_028714_SPI_SHADER_COL_FORMAT, 0},
-   {R_0287D4_PA_CL_POINT_X_RAD, 0},
-   {R_0287D8_PA_CL_POINT_Y_RAD, 0},
-   {R_0287DC_PA_CL_POINT_SIZE, 0},
-   {R_0287E0_PA_CL_POINT_CULL_RAD, 0},
-   {R_028804_DB_EQAA, 0},
-   {R_02880C_DB_SHADER_CONTROL, 0},
-   {R_028824_PA_SU_LINE_STIPPLE_CNTL, 0},
-   {R_028828_PA_SU_LINE_STIPPLE_SCALE, 0},
-   {R_02882C_PA_SU_PRIM_FILTER_CNTL, 0},
-   {R_028A10_VGT_OUTPUT_PATH_CNTL, 0},
-   {R_028A14_VGT_HOS_CNTL, 0},
-   {R_028A18_VGT_HOS_MAX_TESS_LEVEL, 0},
-   {R_028A1C_VGT_HOS_MIN_TESS_LEVEL, 0},
-   {R_028A20_VGT_HOS_REUSE_DEPTH, 0},
-   {R_028A24_VGT_GROUP_PRIM_TYPE, 0},
-   {R_028A28_VGT_GROUP_FIRST_DECR, 0},
-   {R_028A2C_VGT_GROUP_DECR, 0},
-   {R_028A30_VGT_GROUP_VECT_0_CNTL, 0},
-   {R_028A34_VGT_GROUP_VECT_1_CNTL, 0},
-   {R_028A38_VGT_GROUP_VECT_0_FMT_CNTL, 0},
-   {R_028A3C_VGT_GROUP_VECT_1_FMT_CNTL, 0},
-   {R_028A40_VGT_GS_MODE, 0},
-   {R_028A4C_PA_SC_MODE_CNTL_1, 0},
-   {R_028A50_VGT_ENHANCE, 0},
-   {R_028A54_VGT_GS_PER_ES, 0},
-   {R_028A58_VGT_ES_PER_GS, 0},
-   {R_028A5C_VGT_GS_PER_VS, 0},
-   {R_028A60_VGT_GSVS_RING_OFFSET_1, 0},
-   {R_028A64_VGT_GSVS_RING_OFFSET_2, 0},
-   {R_028A68_VGT_GSVS_RING_OFFSET_3, 0},
-   {R_028A6C_VGT_GS_OUT_PRIM_TYPE, 0},
-   {R_028A70_IA_ENHANCE, 0},
-   {R_028A84_VGT_PRIMITIVEID_EN, 0},
-   {R_028A8C_VGT_PRIMITIVEID_RESET, 0},
-   {R_028AA0_VGT_INSTANCE_STEP_RATE_0, 0},
-   {R_028AA4_VGT_INSTANCE_STEP_RATE_1, 0},
-   {R_028AA8_IA_MULTI_VGT_PARAM, 0},
-   {R_028AAC_VGT_ESGS_RING_ITEMSIZE, 0},
-   {R_028AB0_VGT_GSVS_RING_ITEMSIZE, 0},
-   {R_028AB4_VGT_REUSE_OFF, 0},
-   {R_028AB8_VGT_VTX_CNT_EN, 0},
-   {R_028ABC_DB_HTILE_SURFACE, 0},
-   {R_028B54_VGT_SHADER_STAGES_EN, 0},
-   {R_028B94_VGT_STRMOUT_CONFIG, 0},
-   {R_028B98_VGT_STRMOUT_BUFFER_CONFIG, 0},
-   {R_028BD4_PA_SC_CENTROID_PRIORITY_0, 0},
-   {R_028BD8_PA_SC_CENTROID_PRIORITY_1, 0},
-   {R_028BF8_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0, 0},
-   {R_028BFC_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_1, 0},
-   {R_028C00_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_2, 0},
-   {R_028C04_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_3, 0},
-   {R_028C08_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_0, 0},
-   {R_028C0C_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_1, 0},
-   {R_028C10_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_2, 0},
-   {R_028C14_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_3, 0},
-   {R_028C18_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_0, 0},
-   {R_028C1C_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_1, 0},
-   {R_028C20_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_2, 0},
-   {R_028C24_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_3, 0},
-   {R_028C28_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_0, 0},
-   {

[Mesa-dev] [PATCH 22/23] radeonsi: move everything else into the new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 src/gallium/drivers/radeonsi/Makefile.sources|1 -
 src/gallium/drivers/radeonsi/evergreen_state.c   |   98 ---
 src/gallium/drivers/radeonsi/r600_state_common.c |  157 -
 src/gallium/drivers/radeonsi/radeonsi_pipe.c |2 +-
 src/gallium/drivers/radeonsi/radeonsi_pipe.h |   32 
 src/gallium/drivers/radeonsi/si_state.c  |  197 ++
 src/gallium/drivers/radeonsi/si_state.h  |1 +
 7 files changed, 199 insertions(+), 289 deletions(-)
 delete mode 100644 src/gallium/drivers/radeonsi/evergreen_state.c

diff --git a/src/gallium/drivers/radeonsi/Makefile.sources 
b/src/gallium/drivers/radeonsi/Makefile.sources
index b5c193b..8e27b6c 100644
--- a/src/gallium/drivers/radeonsi/Makefile.sources
+++ b/src/gallium/drivers/radeonsi/Makefile.sources
@@ -8,7 +8,6 @@ C_SOURCES := \
radeonsi_shader.c \
r600_texture.c \
evergreen_hw_context.c \
-   evergreen_state.c \
r600_translate.c \
r600_state_common.c \
radeonsi_pm4.c \
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
deleted file mode 100644
index f362753..000
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2010 Jerome Glisse 
- *
- * 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
- * on 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
- * THE AUTHOR(S) AND/OR THEIR 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.
- */
-
-/* TODO:
- * - fix mask for depth control & cull for query
- */
-#include 
-#include 
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "pipe/p_context.h"
-#include "tgsi/tgsi_scan.h"
-#include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_util.h"
-#include "util/u_blitter.h"
-#include "util/u_double_list.h"
-#include "util/u_transfer.h"
-#include "util/u_surface.h"
-#include "util/u_pack_color.h"
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-#include "util/u_framebuffer.h"
-#include "pipebuffer/pb_buffer.h"
-#include "r600.h"
-#include "sid.h"
-#include "r600_resource.h"
-#include "radeonsi_pipe.h"
-#include "si_state.h"
-
-#if 0
-static uint32_t r600_translate_stencil_op(int s_op)
-{
-   switch (s_op) {
-   case PIPE_STENCIL_OP_KEEP:
-   return V_028800_STENCIL_KEEP;
-   case PIPE_STENCIL_OP_ZERO:
-   return V_028800_STENCIL_ZERO;
-   case PIPE_STENCIL_OP_REPLACE:
-   return V_028800_STENCIL_REPLACE;
-   case PIPE_STENCIL_OP_INCR:
-   return V_028800_STENCIL_INCR;
-   case PIPE_STENCIL_OP_DECR:
-   return V_028800_STENCIL_DECR;
-   case PIPE_STENCIL_OP_INCR_WRAP:
-   return V_028800_STENCIL_INCR_WRAP;
-   case PIPE_STENCIL_OP_DECR_WRAP:
-   return V_028800_STENCIL_DECR_WRAP;
-   case PIPE_STENCIL_OP_INVERT:
-   return V_028800_STENCIL_INVERT;
-   default:
-   R600_ERR("Unknown stencil op %d", s_op);
-   assert(0);
-   break;
-   }
-   return 0;
-}
-#endif
-
-static void evergreen_set_polygon_stipple(struct pipe_context *ctx,
-const struct pipe_poly_stipple *state)
-{
-}
-
-void cayman_init_state_functions(struct r600_context *rctx)
-{
-   si_init_state_functions(rctx);
-   rctx->context.create_vertex_elements_state = si_create_vertex_elements;
-   rctx->context.bind_vertex_elements_state = r600_bind_vertex_elements;
-   rctx->context.delete_vertex_elements_state = r600_delete_vertex_element;
-   rctx->context.set_polygon_stipple = evergreen_set_polygon_stipple;
-   rctx->context.set_vertex_buffers = r600_set_vertex_buffers;
-   rctx->context.set_index_buffer = r600_set_index_buffer;
-   rctx->context.sampler_view_destroy = r600_sampler_view_destroy;
-   rctx->context.texture_barrier = r600_texture_barrier;
-   rctx->context.create_stream_output_target = r6

[Mesa-dev] [PATCH 21/23] radeonsi: move format handling into si_state.c

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 src/gallium/drivers/radeonsi/evergreen_state.c |  534 
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |9 -
 src/gallium/drivers/radeonsi/si_state.c|  100 +
 src/gallium/drivers/radeonsi/si_state.h|9 +
 4 files changed, 109 insertions(+), 543 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index 441a09b..f362753 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -76,540 +76,6 @@ static uint32_t r600_translate_stencil_op(int s_op)
 }
 #endif
 
-static uint32_t si_translate_dbformat(enum pipe_format format)
-{
-   switch (format) {
-   case PIPE_FORMAT_Z16_UNORM:
-   return V_028040_Z_16;
-   case PIPE_FORMAT_Z24X8_UNORM:
-   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
-   return V_028040_Z_24; /* XXX no longer supported on SI */
-   case PIPE_FORMAT_Z32_FLOAT:
-   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
-   return V_028040_Z_32_FLOAT;
-   default:
-   return ~0U;
-   }
-}
-
-static uint32_t si_translate_colorswap(enum pipe_format format)
-{
-   switch (format) {
-   /* 8-bit buffers. */
-   case PIPE_FORMAT_L4A4_UNORM:
-   case PIPE_FORMAT_A4R4_UNORM:
-   return V_028C70_SWAP_ALT;
-
-   case PIPE_FORMAT_A8_UNORM:
-   case PIPE_FORMAT_A8_UINT:
-   case PIPE_FORMAT_A8_SINT:
-   case PIPE_FORMAT_R4A4_UNORM:
-   return V_028C70_SWAP_ALT_REV;
-   case PIPE_FORMAT_I8_UNORM:
-   case PIPE_FORMAT_L8_UNORM:
-   case PIPE_FORMAT_I8_UINT:
-   case PIPE_FORMAT_I8_SINT:
-   case PIPE_FORMAT_L8_UINT:
-   case PIPE_FORMAT_L8_SINT:
-   case PIPE_FORMAT_L8_SRGB:
-   case PIPE_FORMAT_R8_UNORM:
-   case PIPE_FORMAT_R8_SNORM:
-   case PIPE_FORMAT_R8_UINT:
-   case PIPE_FORMAT_R8_SINT:
-   return V_028C70_SWAP_STD;
-
-   /* 16-bit buffers. */
-   case PIPE_FORMAT_B5G6R5_UNORM:
-   return V_028C70_SWAP_STD_REV;
-
-   case PIPE_FORMAT_B5G5R5A1_UNORM:
-   case PIPE_FORMAT_B5G5R5X1_UNORM:
-   return V_028C70_SWAP_ALT;
-
-   case PIPE_FORMAT_B4G4R4A4_UNORM:
-   case PIPE_FORMAT_B4G4R4X4_UNORM:
-   return V_028C70_SWAP_ALT;
-
-   case PIPE_FORMAT_Z16_UNORM:
-   return V_028C70_SWAP_STD;
-
-   case PIPE_FORMAT_L8A8_UNORM:
-   case PIPE_FORMAT_L8A8_UINT:
-   case PIPE_FORMAT_L8A8_SINT:
-   case PIPE_FORMAT_L8A8_SRGB:
-   return V_028C70_SWAP_ALT;
-   case PIPE_FORMAT_R8G8_UNORM:
-   case PIPE_FORMAT_R8G8_UINT:
-   case PIPE_FORMAT_R8G8_SINT:
-   return V_028C70_SWAP_STD;
-
-   case PIPE_FORMAT_R16_UNORM:
-   case PIPE_FORMAT_R16_UINT:
-   case PIPE_FORMAT_R16_SINT:
-   case PIPE_FORMAT_R16_FLOAT:
-   return V_028C70_SWAP_STD;
-
-   /* 32-bit buffers. */
-   case PIPE_FORMAT_A8B8G8R8_SRGB:
-   return V_028C70_SWAP_STD_REV;
-   case PIPE_FORMAT_B8G8R8A8_SRGB:
-   return V_028C70_SWAP_ALT;
-
-   case PIPE_FORMAT_B8G8R8A8_UNORM:
-   case PIPE_FORMAT_B8G8R8X8_UNORM:
-   return V_028C70_SWAP_ALT;
-
-   case PIPE_FORMAT_A8R8G8B8_UNORM:
-   case PIPE_FORMAT_X8R8G8B8_UNORM:
-   return V_028C70_SWAP_ALT_REV;
-   case PIPE_FORMAT_R8G8B8A8_SNORM:
-   case PIPE_FORMAT_R8G8B8A8_UNORM:
-   case PIPE_FORMAT_R8G8B8A8_SSCALED:
-   case PIPE_FORMAT_R8G8B8A8_USCALED:
-   case PIPE_FORMAT_R8G8B8A8_SINT:
-   case PIPE_FORMAT_R8G8B8A8_UINT:
-   case PIPE_FORMAT_R8G8B8X8_UNORM:
-   return V_028C70_SWAP_STD;
-
-   case PIPE_FORMAT_A8B8G8R8_UNORM:
-   case PIPE_FORMAT_X8B8G8R8_UNORM:
-   /* case PIPE_FORMAT_R8SG8SB8UX8U_NORM: */
-   return V_028C70_SWAP_STD_REV;
-
-   case PIPE_FORMAT_Z24X8_UNORM:
-   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
-   return V_028C70_SWAP_STD;
-
-   case PIPE_FORMAT_X8Z24_UNORM:
-   case PIPE_FORMAT_S8_UINT_Z24_UNORM:
-   return V_028C70_SWAP_STD;
-
-   case PIPE_FORMAT_R10G10B10A2_UNORM:
-   case PIPE_FORMAT_R10G10B10X2_SNORM:
-   case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
-   return V_028C70_SWAP_STD;
-
-   case PIPE_FORMAT_B10G10R10A2_UNORM:
-   case PIPE_FORMAT_B10G10R10A2_UINT:
-   return V_028C70_SWAP_ALT;
-
-   case PIPE_FORMAT_R11G11B10_FLOAT:
-   case PIPE_FORMAT_R32_FLOAT:
-   case PIPE_FORMAT_R32_UINT:
-   case PIPE_FORMAT_R32_SINT:
-   case PIPE_FORMAT_Z32_FLOAT:
-   case PIPE_FORMAT_R16G16_FLOAT:
-   case PIPE_FORMAT_R16G16_UNORM:
-   case PIPE_FORMAT_R16G16_UINT:
-   case PIPE_FORMAT_R16G16_SINT:
-   return V_028C70_SWAP_STD;
-
-   /* 64-bit buffers. */
-   case PIPE_FORMAT_R32G32_FLOAT:
-   

[Mesa-dev] [PATCH 20/23] radeonsi: move remaining sampler state into si_state.c

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 src/gallium/drivers/radeonsi/evergreen_state.c |  339 --
 src/gallium/drivers/radeonsi/si_state.c|  440 
 2 files changed, 440 insertions(+), 339 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index 74e8c81..441a09b 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -76,96 +76,6 @@ static uint32_t r600_translate_stencil_op(int s_op)
 }
 #endif
 
-static unsigned si_tex_wrap(unsigned wrap)
-{
-   switch (wrap) {
-   default:
-   case PIPE_TEX_WRAP_REPEAT:
-   return V_008F30_SQ_TEX_WRAP;
-   case PIPE_TEX_WRAP_CLAMP:
-   return V_008F30_SQ_TEX_CLAMP_HALF_BORDER;
-   case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
-   return V_008F30_SQ_TEX_CLAMP_LAST_TEXEL;
-   case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
-   return V_008F30_SQ_TEX_CLAMP_BORDER;
-   case PIPE_TEX_WRAP_MIRROR_REPEAT:
-   return V_008F30_SQ_TEX_MIRROR;
-   case PIPE_TEX_WRAP_MIRROR_CLAMP:
-   return V_008F30_SQ_TEX_MIRROR_ONCE_HALF_BORDER;
-   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
-   return V_008F30_SQ_TEX_MIRROR_ONCE_LAST_TEXEL;
-   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
-   return V_008F30_SQ_TEX_MIRROR_ONCE_BORDER;
-   }
-}
-
-static unsigned si_tex_filter(unsigned filter)
-{
-   switch (filter) {
-   default:
-   case PIPE_TEX_FILTER_NEAREST:
-   return V_008F38_SQ_TEX_XY_FILTER_POINT;
-   case PIPE_TEX_FILTER_LINEAR:
-   return V_008F38_SQ_TEX_XY_FILTER_BILINEAR;
-   }
-}
-
-static unsigned si_tex_mipfilter(unsigned filter)
-{
-   switch (filter) {
-   case PIPE_TEX_MIPFILTER_NEAREST:
-   return V_008F38_SQ_TEX_Z_FILTER_POINT;
-   case PIPE_TEX_MIPFILTER_LINEAR:
-   return V_008F38_SQ_TEX_Z_FILTER_LINEAR;
-   default:
-   case PIPE_TEX_MIPFILTER_NONE:
-   return V_008F38_SQ_TEX_Z_FILTER_NONE;
-   }
-}
-
-static unsigned si_tex_compare(unsigned compare)
-{
-   switch (compare) {
-   default:
-   case PIPE_FUNC_NEVER:
-   return V_008F30_SQ_TEX_DEPTH_COMPARE_NEVER;
-   case PIPE_FUNC_LESS:
-   return V_008F30_SQ_TEX_DEPTH_COMPARE_LESS;
-   case PIPE_FUNC_EQUAL:
-   return V_008F30_SQ_TEX_DEPTH_COMPARE_EQUAL;
-   case PIPE_FUNC_LEQUAL:
-   return V_008F30_SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
-   case PIPE_FUNC_GREATER:
-   return V_008F30_SQ_TEX_DEPTH_COMPARE_GREATER;
-   case PIPE_FUNC_NOTEQUAL:
-   return V_008F30_SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
-   case PIPE_FUNC_GEQUAL:
-   return V_008F30_SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
-   case PIPE_FUNC_ALWAYS:
-   return V_008F30_SQ_TEX_DEPTH_COMPARE_ALWAYS;
-   }
-}
-
-static unsigned si_tex_dim(unsigned dim)
-{
-   switch (dim) {
-   default:
-   case PIPE_TEXTURE_1D:
-   return V_008F1C_SQ_RSRC_IMG_1D;
-   case PIPE_TEXTURE_1D_ARRAY:
-   return V_008F1C_SQ_RSRC_IMG_1D_ARRAY;
-   case PIPE_TEXTURE_2D:
-   case PIPE_TEXTURE_RECT:
-   return V_008F1C_SQ_RSRC_IMG_2D;
-   case PIPE_TEXTURE_2D_ARRAY:
-   return V_008F1C_SQ_RSRC_IMG_2D_ARRAY;
-   case PIPE_TEXTURE_3D:
-   return V_008F1C_SQ_RSRC_IMG_3D;
-   case PIPE_TEXTURE_CUBE:
-   return V_008F1C_SQ_RSRC_IMG_CUBE;
-   }
-}
-
 static uint32_t si_translate_dbformat(enum pipe_format format)
 {
switch (format) {
@@ -467,48 +377,6 @@ static uint32_t si_translate_colorformat(enum pipe_format 
format)
}
 }
 
-static uint32_t si_colorformat_endian_swap(uint32_t colorformat)
-{
-   if (R600_BIG_ENDIAN) {
-   switch(colorformat) {
-   /* 8-bit buffers. */
-   case V_028C70_COLOR_8:
-   return V_028C70_ENDIAN_NONE;
-
-   /* 16-bit buffers. */
-   case V_028C70_COLOR_5_6_5:
-   case V_028C70_COLOR_1_5_5_5:
-   case V_028C70_COLOR_4_4_4_4:
-   case V_028C70_COLOR_16:
-   case V_028C70_COLOR_8_8:
-   return V_028C70_ENDIAN_8IN16;
-
-   /* 32-bit buffers. */
-   case V_028C70_COLOR_8_8_8_8:
-   case V_028C70_COLOR_2_10_10_10:
-   case V_028C70_COLOR_8_24:
-   case V_028C70_COLOR_24_8:
-   case V_028C70_COLOR_16_16:
-   return V_028C70_ENDIAN_8IN32;
-
-   /* 64-bit buffers. */
-   case V_028C70_COLOR_16_16_16_16:
-   return V_028C70_ENDIAN_8IN16;
-
-   case V_028C70_COLOR_32_32:
-   return V_028C70_ENDIAN_8IN32;
-
-   /* 128-bit buf

[Mesa-dev] [PATCH 18/23] radeonsi: move constants to new state handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 src/gallium/drivers/radeonsi/evergreen_state.c   |1 -
 src/gallium/drivers/radeonsi/r600_state_common.c |   57 --
 src/gallium/drivers/radeonsi/radeonsi_pipe.h |4 --
 src/gallium/drivers/radeonsi/si_state.c  |   55 +
 src/gallium/drivers/radeonsi/si_state.h  |6 ++-
 5 files changed, 59 insertions(+), 64 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index 1b4f669..74e8c81 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -959,7 +959,6 @@ void cayman_init_state_functions(struct r600_context *rctx)
rctx->context.bind_vertex_elements_state = r600_bind_vertex_elements;
rctx->context.delete_sampler_state = si_delete_sampler_state;
rctx->context.delete_vertex_elements_state = r600_delete_vertex_element;
-   rctx->context.set_constant_buffer = r600_set_constant_buffer;
rctx->context.set_polygon_stipple = evergreen_set_polygon_stipple;
rctx->context.set_sample_mask = evergreen_set_sample_mask;
rctx->context.set_vertex_buffers = r600_set_vertex_buffers;
diff --git a/src/gallium/drivers/radeonsi/r600_state_common.c 
b/src/gallium/drivers/radeonsi/r600_state_common.c
index 3e81495..61879d6 100644
--- a/src/gallium/drivers/radeonsi/r600_state_common.c
+++ b/src/gallium/drivers/radeonsi/r600_state_common.c
@@ -193,63 +193,6 @@ static void r600_update_alpha_ref(struct r600_context 
*rctx)
 #endif
 }
 
-void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint 
index,
- struct pipe_constant_buffer *cb)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct r600_resource *rbuffer = cb ? r600_resource(cb->buffer) : NULL;
-   struct r600_pipe_state *rstate;
-   uint64_t va_offset;
-   uint32_t offset;
-
-   /* Note that the state tracker can unbind constant buffers by
-* passing NULL here.
-*/
-   if (cb == NULL) {
-   return;
-   }
-
-   r600_inval_shader_cache(rctx);
-
-   if (cb->user_buffer)
-   r600_upload_const_buffer(rctx, &rbuffer, cb->user_buffer, 
cb->buffer_size, &offset);
-   else
-   offset = 0;
-   va_offset = r600_resource_va(ctx->screen, (void*)rbuffer);
-   va_offset += offset;
-   //va_offset >>= 8;
-
-   switch (shader) {
-   case PIPE_SHADER_VERTEX:
-   rstate = &rctx->vs_const_buffer;
-   rstate->nregs = 0;
-   r600_pipe_state_add_reg(rstate,
-   R_00B130_SPI_SHADER_USER_DATA_VS_0,
-   va_offset, rbuffer, RADEON_USAGE_READ);
-   r600_pipe_state_add_reg(rstate,
-   R_00B134_SPI_SHADER_USER_DATA_VS_1,
-   va_offset >> 32, NULL, 0);
-   break;
-   case PIPE_SHADER_FRAGMENT:
-   rstate = &rctx->ps_const_buffer;
-   rstate->nregs = 0;
-   r600_pipe_state_add_reg(rstate,
-   R_00B030_SPI_SHADER_USER_DATA_PS_0,
-   va_offset, rbuffer, RADEON_USAGE_READ);
-   r600_pipe_state_add_reg(rstate,
-   R_00B034_SPI_SHADER_USER_DATA_PS_1,
-   va_offset >> 32, NULL, 0);
-   break;
-   default:
-   R600_ERR("unsupported %d\n", shader);
-   return;
-   }
-
-   r600_context_pipe_state_set(rctx, rstate);
-
-   if (cb->buffer != &rbuffer->b.b)
-   pipe_resource_reference((struct pipe_resource**)&rbuffer, NULL);
-}
 
 struct pipe_stream_output_target *
 r600_create_so_target(struct pipe_context *ctx,
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index c8313fb..118f84a 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -165,9 +165,7 @@ struct r600_context {
struct r600_pipe_state  config;
struct si_pipe_shader   *ps_shader;
struct si_pipe_shader   *vs_shader;
-   struct r600_pipe_state  vs_const_buffer;
struct r600_pipe_state  vs_user_data;
-   struct r600_pipe_state  ps_const_buffer;
struct pipe_query   *current_render_cond;
unsignedcurrent_render_cond_mode;
struct pipe_query   *saved_render_cond;
@@ -330,8 +328,6 @@ void r600_bind_ps_shader(struct pipe_context *ctx, void 
*state);
 void r600_bind_vs_shader(struct pipe_context *ctx, void *state);
 void r600_delete_ps_shader(struct pipe_context *ctx, void *state);
 void r600_delete_vs_shad

[Mesa-dev] [PATCH 17/23] radeonsi: move sampler states into new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 src/gallium/drivers/radeonsi/evergreen_state.c |  105 --
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |2 -
 src/gallium/drivers/radeonsi/si_state.c|  113 
 src/gallium/drivers/radeonsi/si_state.h|2 +
 4 files changed, 115 insertions(+), 107 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index bb027ee..1b4f669 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -941,107 +941,6 @@ static struct pipe_sampler_view 
*evergreen_create_sampler_view(struct pipe_conte
return &view->base;
 }
 
-static void evergreen_set_vs_sampler_view(struct pipe_context *ctx, unsigned 
count,
-   struct pipe_sampler_view **views)
-{
-}
-
-static void evergreen_set_ps_sampler_view(struct pipe_context *ctx, unsigned 
count,
-   struct pipe_sampler_view **views)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct si_pipe_sampler_view **resource = (struct si_pipe_sampler_view 
**)views;
-   struct r600_pipe_state *rstate = &rctx->ps_samplers.views_state;
-   struct r600_resource *bo;
-   int i;
-   int has_depth = 0;
-   uint64_t va;
-   char *ptr;
-
-   if (!count)
-   goto out;
-
-   r600_inval_texture_cache(rctx);
-
-   bo = (struct r600_resource*)
-   pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, 
PIPE_USAGE_IMMUTABLE,
-  count * sizeof(resource[0]->state));
-   ptr = rctx->ws->buffer_map(bo->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
-
-   for (i = 0; i < count; i++, ptr += sizeof(resource[0]->state)) {
-   pipe_sampler_view_reference(
-   (struct pipe_sampler_view 
**)&rctx->ps_samplers.views[i],
-   views[i]);
-
-   if (resource[i]) {
-   if (((struct r600_resource_texture 
*)resource[i]->base.texture)->depth)
-   has_depth = 1;
-
-   memcpy(ptr, resource[i]->state, 
sizeof(resource[0]->state));
-   } else
-   memset(ptr, 0, sizeof(resource[0]->state));
-   }
-
-   rctx->ws->buffer_unmap(bo->cs_buf);
-
-   for (i = count; i < NUM_TEX_UNITS; i++) {
-   if (rctx->ps_samplers.views[i])
-   pipe_sampler_view_reference((struct pipe_sampler_view 
**)&rctx->ps_samplers.views[i], NULL);
-   }
-
-   rstate->nregs = 0;
-   va = r600_resource_va(ctx->screen, (void *)bo);
-   r600_pipe_state_add_reg(rstate, R_00B040_SPI_SHADER_USER_DATA_PS_4, va, 
bo, RADEON_USAGE_READ);
-   r600_pipe_state_add_reg(rstate, R_00B044_SPI_SHADER_USER_DATA_PS_5, va 
>> 32, NULL, 0);
-   r600_context_pipe_state_set(rctx, rstate);
-
-out:
-   rctx->have_depth_texture = has_depth;
-   rctx->ps_samplers.n_views = count;
-}
-
-static void evergreen_bind_ps_sampler(struct pipe_context *ctx, unsigned 
count, void **states)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct si_pipe_sampler_state **rstates = (struct si_pipe_sampler_state 
**)states;
-   struct r600_pipe_state *rstate = &rctx->ps_samplers.samplers_state;
-   struct r600_resource *bo;
-   uint64_t va;
-   char *ptr;
-   int i;
-
-   if (!count)
-   goto out;
-
-   r600_inval_texture_cache(rctx);
-
-   bo = (struct r600_resource*)
-   pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, 
PIPE_USAGE_IMMUTABLE,
-  count * sizeof(rstates[0]->val));
-   ptr = rctx->ws->buffer_map(bo->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
-
-   for (i = 0; i < count; i++, ptr += sizeof(rstates[0]->val)) {
-   memcpy(ptr, rstates[i]->val, sizeof(rstates[0]->val));
-   }
-
-   rctx->ws->buffer_unmap(bo->cs_buf);
-
-   memcpy(rctx->ps_samplers.samplers, states, sizeof(void*) * count);
-
-   rstate->nregs = 0;
-   va = r600_resource_va(ctx->screen, (void *)bo);
-   r600_pipe_state_add_reg(rstate, R_00B038_SPI_SHADER_USER_DATA_PS_2, va, 
bo, RADEON_USAGE_READ);
-   r600_pipe_state_add_reg(rstate, R_00B03C_SPI_SHADER_USER_DATA_PS_3, va 
>> 32, NULL, 0);
-   r600_context_pipe_state_set(rctx, rstate);
-
-out:
-   rctx->ps_samplers.n_samplers = count;
-}
-
-static void evergreen_bind_vs_sampler(struct pipe_context *ctx, unsigned 
count, void **states)
-{
-}
-
 static void evergreen_set_polygon_stipple(struct pipe_context *ctx,
 const struct pipe_poly_stipple *state)
 {
@@ -1057,18 +956,14 @@ void cayman_init_state_functions(struct r600_context 
*rctx)
rctx->context.create_sampler_state = si_create_sampler_state;
rctx->conte

[Mesa-dev] [PATCH 16/23] radeonsi: move shaders to new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 src/gallium/drivers/radeonsi/evergreen_state.c   |  214 --
 src/gallium/drivers/radeonsi/r600_state_common.c |   77 +--
 src/gallium/drivers/radeonsi/radeonsi_pipe.h |   44 +---
 src/gallium/drivers/radeonsi/radeonsi_shader.c   |4 +-
 src/gallium/drivers/radeonsi/si_state.c  |  250 +-
 src/gallium/drivers/radeonsi/si_state.h  |   42 
 6 files changed, 295 insertions(+), 336 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index d336bd8..bb027ee 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -1054,20 +1054,14 @@ static void evergreen_set_sample_mask(struct 
pipe_context *pipe, unsigned sample
 void cayman_init_state_functions(struct r600_context *rctx)
 {
si_init_state_functions(rctx);
-   rctx->context.create_fs_state = si_create_shader_state;
rctx->context.create_sampler_state = si_create_sampler_state;
rctx->context.create_sampler_view = evergreen_create_sampler_view;
rctx->context.create_vertex_elements_state = si_create_vertex_elements;
-   rctx->context.create_vs_state = si_create_shader_state;
rctx->context.bind_fragment_sampler_states = evergreen_bind_ps_sampler;
-   rctx->context.bind_fs_state = r600_bind_ps_shader;
rctx->context.bind_vertex_elements_state = r600_bind_vertex_elements;
rctx->context.bind_vertex_sampler_states = evergreen_bind_vs_sampler;
-   rctx->context.bind_vs_state = r600_bind_vs_shader;
-   rctx->context.delete_fs_state = r600_delete_ps_shader;
rctx->context.delete_sampler_state = si_delete_sampler_state;
rctx->context.delete_vertex_elements_state = r600_delete_vertex_element;
-   rctx->context.delete_vs_state = r600_delete_vs_shader;
rctx->context.set_constant_buffer = r600_set_constant_buffer;
rctx->context.set_fragment_sampler_views = 
evergreen_set_ps_sampler_view;
rctx->context.set_polygon_stipple = evergreen_set_polygon_stipple;
@@ -1081,211 +1075,3 @@ void cayman_init_state_functions(struct r600_context 
*rctx)
rctx->context.stream_output_target_destroy = r600_so_target_destroy;
rctx->context.set_stream_output_targets = r600_set_so_targets;
 }
-
-void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader *shader)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct r600_pipe_state *rstate = &shader->rstate;
-   struct r600_shader *rshader = &shader->shader;
-   unsigned i, exports_ps, num_cout, spi_ps_in_control, db_shader_control;
-   unsigned num_sgprs, num_user_sgprs;
-   int pos_index = -1, face_index = -1;
-   int ninterp = 0;
-   boolean have_linear = FALSE, have_centroid = FALSE, have_perspective = 
FALSE;
-   unsigned spi_baryc_cntl;
-   uint64_t va;
-
-   if (si_pipe_shader_create(ctx, shader))
-   return;
-
-   rstate->nregs = 0;
-
-   db_shader_control = S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z);
-   for (i = 0; i < rshader->ninput; i++) {
-   ninterp++;
-   /* XXX: Flat shading hangs the GPU */
-   if (rshader->input[i].interpolate == TGSI_INTERPOLATE_CONSTANT 
||
-   (rshader->input[i].interpolate == TGSI_INTERPOLATE_COLOR &&
-rctx->qued.named.rasterizer->flatshade))
-   have_linear = TRUE;
-   if (rshader->input[i].interpolate == TGSI_INTERPOLATE_LINEAR)
-   have_linear = TRUE;
-   if (rshader->input[i].interpolate == 
TGSI_INTERPOLATE_PERSPECTIVE)
-   have_perspective = TRUE;
-   if (rshader->input[i].centroid)
-   have_centroid = TRUE;
-   }
-
-   for (i = 0; i < rshader->noutput; i++) {
-   if (rshader->output[i].name == TGSI_SEMANTIC_POSITION)
-   db_shader_control |= S_02880C_Z_EXPORT_ENABLE(1);
-   if (rshader->output[i].name == TGSI_SEMANTIC_STENCIL)
-   db_shader_control |= 0; // XXX OP_VAL or TEST_VAL?
-   }
-   if (rshader->uses_kill)
-   db_shader_control |= S_02880C_KILL_ENABLE(1);
-
-   exports_ps = 0;
-   num_cout = 0;
-   for (i = 0; i < rshader->noutput; i++) {
-   if (rshader->output[i].name == TGSI_SEMANTIC_POSITION ||
-   rshader->output[i].name == TGSI_SEMANTIC_STENCIL)
-   exports_ps |= 1;
-   else if (rshader->output[i].name == TGSI_SEMANTIC_COLOR) {
-   if (rshader->fs_write_all)
-   num_cout = rshader->nr_cbufs;
-   else
-   num_cout++;
-   }
-   }
-   if (!exports_ps) {
-   /* alw

[Mesa-dev] [PATCH 15/23] radeonsi: move spi into new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|   32 --
 src/gallium/drivers/radeonsi/evergreen_state.c |   46 
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |2 -
 src/gallium/drivers/radeonsi/si_state.c|   44 +++
 src/gallium/drivers/radeonsi/si_state.h|2 +
 5 files changed, 46 insertions(+), 80 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 157fe01..299ead8 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -51,38 +51,6 @@ static const struct r600_reg si_context_reg_list[] = {
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028644_SPI_PS_INPUT_CNTL_0, 0},
-   {R_028648_SPI_PS_INPUT_CNTL_1, 0},
-   {R_02864C_SPI_PS_INPUT_CNTL_2, 0},
-   {R_028650_SPI_PS_INPUT_CNTL_3, 0},
-   {R_028654_SPI_PS_INPUT_CNTL_4, 0},
-   {R_028658_SPI_PS_INPUT_CNTL_5, 0},
-   {R_02865C_SPI_PS_INPUT_CNTL_6, 0},
-   {R_028660_SPI_PS_INPUT_CNTL_7, 0},
-   {R_028664_SPI_PS_INPUT_CNTL_8, 0},
-   {R_028668_SPI_PS_INPUT_CNTL_9, 0},
-   {R_02866C_SPI_PS_INPUT_CNTL_10, 0},
-   {R_028670_SPI_PS_INPUT_CNTL_11, 0},
-   {R_028674_SPI_PS_INPUT_CNTL_12, 0},
-   {R_028678_SPI_PS_INPUT_CNTL_13, 0},
-   {R_02867C_SPI_PS_INPUT_CNTL_14, 0},
-   {R_028680_SPI_PS_INPUT_CNTL_15, 0},
-   {R_028684_SPI_PS_INPUT_CNTL_16, 0},
-   {R_028688_SPI_PS_INPUT_CNTL_17, 0},
-   {R_02868C_SPI_PS_INPUT_CNTL_18, 0},
-   {R_028690_SPI_PS_INPUT_CNTL_19, 0},
-   {R_028694_SPI_PS_INPUT_CNTL_20, 0},
-   {R_028698_SPI_PS_INPUT_CNTL_21, 0},
-   {R_02869C_SPI_PS_INPUT_CNTL_22, 0},
-   {R_0286A0_SPI_PS_INPUT_CNTL_23, 0},
-   {R_0286A4_SPI_PS_INPUT_CNTL_24, 0},
-   {R_0286A8_SPI_PS_INPUT_CNTL_25, 0},
-   {R_0286AC_SPI_PS_INPUT_CNTL_26, 0},
-   {R_0286B0_SPI_PS_INPUT_CNTL_27, 0},
-   {R_0286B4_SPI_PS_INPUT_CNTL_28, 0},
-   {R_0286B8_SPI_PS_INPUT_CNTL_29, 0},
-   {R_0286BC_SPI_PS_INPUT_CNTL_30, 0},
-   {R_0286C0_SPI_PS_INPUT_CNTL_31, 0},
{R_0286C4_SPI_VS_OUT_CONFIG, 0},
{R_0286CC_SPI_PS_INPUT_ENA, 0},
{R_0286D0_SPI_PS_INPUT_ADDR, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index fdf9047..d336bd8 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -1288,50 +1288,4 @@ void si_pipe_shader_vs(struct pipe_context *ctx, struct 
si_pipe_shader *shader)
NULL, 0);
 }
 
-void si_update_spi_map(struct r600_context *rctx)
-{
-   struct r600_shader *ps = &rctx->ps_shader->shader;
-   struct r600_shader *vs = &rctx->vs_shader->shader;
-   struct r600_pipe_state *rstate = &rctx->spi;
-   unsigned i, j, tmp;
-
-   rstate->nregs = 0;
-
-   for (i = 0; i < ps->ninput; i++) {
-   tmp = 0;
-
-#if 0
-   /* XXX: Flat shading hangs the GPU */
-   if (ps->input[i].name == TGSI_SEMANTIC_POSITION ||
-   ps->input[i].interpolate == TGSI_INTERPOLATE_CONSTANT ||
-   (ps->input[i].interpolate == TGSI_INTERPOLATE_COLOR &&
-rctx->rasterizer && rctx->rasterizer->flatshade)) {
-   tmp |= S_028644_FLAT_SHADE(1);
-   }
-#endif
-
-   if (ps->input[i].name == TGSI_SEMANTIC_GENERIC &&
-   rctx->sprite_coord_enable & (1 << ps->input[i].sid)) {
-   tmp |= S_028644_PT_SPRITE_TEX(1);
-   }
-
-   for (j = 0; j < vs->noutput; j++) {
-   if (ps->input[i].name == vs->output[j].name &&
-   ps->input[i].sid == vs->output[j].sid) {
-   tmp |= 
S_028644_OFFSET(vs->output[j].param_offset);
-   break;
-   }
-   }
 
-   if (j == vs->noutput) {
-   /* No corresponding output found, load defaults into 
input */
-   tmp |= S_028644_OFFSET(0x20);
-   }
-
-   r600_pipe_state_add_reg(rstate, R_028644_SPI_PS_INPUT_CNTL_0 + 
i * 4,
-   tmp, NULL, 0);
-   }
-
-   if (rstate->nregs > 0)
-   r600_context_pipe_state_set(rctx, rstate);
-}
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index 5e39d14..6898cf9 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -210,7 +210,6 @@ struct r600_context {
struct r600_pipe_state  vs_const_buffer;
struct r60

[Mesa-dev] [PATCH 14/23] radeonsi: move init state to new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 src/gallium/drivers/radeonsi/evergreen_state.c |   37 --
 src/gallium/drivers/radeonsi/radeonsi_pipe.c   |1 +
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |1 -
 src/gallium/drivers/radeonsi/si_state.c|   40 
 src/gallium/drivers/radeonsi/si_state.h|2 ++
 5 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index fd43d8a..fdf9047 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -1082,43 +1082,6 @@ void cayman_init_state_functions(struct r600_context 
*rctx)
rctx->context.set_stream_output_targets = r600_set_so_targets;
 }
 
-void si_init_config(struct r600_context *rctx)
-{
-   struct r600_pipe_state *rstate = &rctx->config;
-   unsigned tmp;
-
-   r600_pipe_state_add_reg(rstate, R_028A4C_PA_SC_MODE_CNTL_1, 0x0, NULL, 
0);
-
-   r600_pipe_state_add_reg(rstate, R_028A10_VGT_OUTPUT_PATH_CNTL, 0x0, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A14_VGT_HOS_CNTL, 0x0, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A18_VGT_HOS_MAX_TESS_LEVEL, 0x0, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A1C_VGT_HOS_MIN_TESS_LEVEL, 0x0, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A20_VGT_HOS_REUSE_DEPTH, 0x0, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A24_VGT_GROUP_PRIM_TYPE, 0x0, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A28_VGT_GROUP_FIRST_DECR, 0x0, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A2C_VGT_GROUP_DECR, 0x0, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A30_VGT_GROUP_VECT_0_CNTL, 0x0, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A34_VGT_GROUP_VECT_1_CNTL, 0x0, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A38_VGT_GROUP_VECT_0_FMT_CNTL, 
0x0, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A3C_VGT_GROUP_VECT_1_FMT_CNTL, 
0x0, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A40_VGT_GS_MODE, 0x0, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028A84_VGT_PRIMITIVEID_EN, 0x0, NULL, 
0);
-   r600_pipe_state_add_reg(rstate, R_028A8C_VGT_PRIMITIVEID_RESET, 0x0, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028B94_VGT_STRMOUT_CONFIG, 0x0, NULL, 
0);
-   r600_pipe_state_add_reg(rstate, R_028B98_VGT_STRMOUT_BUFFER_CONFIG, 
0x0, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028AA8_IA_MULTI_VGT_PARAM, 
S_028AA8_SWITCH_ON_EOP(1) | S_028AA8_PARTIAL_VS_WAVE_ON(1) | 
S_028AA8_PRIMGROUP_SIZE(63), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028AB4_VGT_REUSE_OFF, 0x, 
NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028AB8_VGT_VTX_CNT_EN, 0x0, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_008A14_PA_CL_ENHANCE, (3 << 1) | 1, 
NULL, 0);
-
-   r600_pipe_state_add_reg(rstate, R_028B54_VGT_SHADER_STAGES_EN, 0, NULL, 
0);
-   r600_pipe_state_add_reg(rstate, R_028BD4_PA_SC_CENTROID_PRIORITY_0, 
0x76543210, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028BD8_PA_SC_CENTROID_PRIORITY_1, 
0xfedcba98, NULL, 0);
-
-   r600_pipe_state_add_reg(rstate, R_028804_DB_EQAA, 0x11, NULL, 0);
-   r600_context_pipe_state_set(rctx, rstate);
-}
-
 void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader *shader)
 {
struct r600_context *rctx = (struct r600_context *)ctx;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
index f3e9cfd..4e695c3 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
@@ -47,6 +47,7 @@
 #include "r600_resource.h"
 #include "radeonsi_pipe.h"
 #include "r600_hw_context_priv.h"
+#include "si_state.h"
 
 /*
  * pipe_context
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index 4886605..5e39d14 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -298,7 +298,6 @@ static INLINE void r600_atom_dirty(struct r600_context 
*rctx, struct r600_atom *
 
 /* evergreen_state.c */
 void cayman_init_state_functions(struct r600_context *rctx);
-void si_init_config(struct r600_context *rctx);
 void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader 
*shader);
 void si_pipe_shader_vs(struct pipe_context *ctx, struct si_pipe_shader 
*shader);
 void si_update_spi_map(struct r600_context *rctx);
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 8b054d9..d2dd802 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1314,6 +1314,46 @@ void si_init_state_functions(struct r600_context *rctx)
rctx->context.set_framebuffer_state = si_set_framebuffer_state;
 }
 
+void si_init_config(struct r

[Mesa-dev] [PATCH 13/23] radeonsi: move draw_info to new state handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|   11 ---
 src/gallium/drivers/radeonsi/evergreen_state.c |2 -
 src/gallium/drivers/radeonsi/r600_state_common.c   |   86 +---
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |2 -
 src/gallium/drivers/radeonsi/si_state.c|   78 ++
 src/gallium/drivers/radeonsi/si_state.h|3 +
 6 files changed, 84 insertions(+), 98 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 9bd547f..157fe01 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -36,7 +36,6 @@ static const struct r600_reg si_config_reg_list[] = {
{R_0088B0_VGT_VTX_VECT_EJECT_REG, REG_FLAG_FLUSH_CHANGE},
{R_0088C8_VGT_ESGS_RING_SIZE, REG_FLAG_FLUSH_CHANGE},
{R_0088CC_VGT_GSVS_RING_SIZE, REG_FLAG_FLUSH_CHANGE},
-   {R_008958_VGT_PRIMITIVE_TYPE, 0},
{R_008A14_PA_CL_ENHANCE, REG_FLAG_FLUSH_CHANGE},
{R_009100_SPI_CONFIG_CNTL, REG_FLAG_ENABLE_ALWAYS | 
REG_FLAG_FLUSH_CHANGE},
{R_00913C_SPI_CONFIG_CNTL_1, REG_FLAG_ENABLE_ALWAYS | 
REG_FLAG_FLUSH_CHANGE},
@@ -52,12 +51,6 @@ static const struct r600_reg si_context_reg_list[] = {
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028400_VGT_MAX_VTX_INDX, 0},
-   {R_028404_VGT_MIN_VTX_INDX, 0},
-   {R_028408_VGT_INDX_OFFSET, 0},
-   {R_02840C_VGT_MULTI_PRIM_IB_RESET_INDX, 0},
-   {R_028A94_VGT_MULTI_PRIM_IB_RESET_EN, 0},
-   {GROUP_FORCE_NEW_BLOCK, 0},
{R_028644_SPI_PS_INPUT_CNTL_0, 0},
{R_028648_SPI_PS_INPUT_CNTL_1, 0},
{R_02864C_SPI_PS_INPUT_CNTL_2, 0},
@@ -104,13 +97,9 @@ static const struct r600_reg si_context_reg_list[] = {
{R_0287E0_PA_CL_POINT_CULL_RAD, 0},
{R_028804_DB_EQAA, 0},
{R_02880C_DB_SHADER_CONTROL, 0},
-   {R_028810_PA_CL_CLIP_CNTL, 0},
-   {R_028814_PA_SU_SC_MODE_CNTL, 0},
-   {R_02881C_PA_CL_VS_OUT_CNTL, 0},
{R_028824_PA_SU_LINE_STIPPLE_CNTL, 0},
{R_028828_PA_SU_LINE_STIPPLE_SCALE, 0},
{R_02882C_PA_SU_PRIM_FILTER_CNTL, 0},
-   {R_028A0C_PA_SC_LINE_STIPPLE, 0},
{R_028A10_VGT_OUTPUT_PATH_CNTL, 0},
{R_028A14_VGT_HOS_CNTL, 0},
{R_028A18_VGT_HOS_MAX_TESS_LEVEL, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index cf99d58..fd43d8a 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -,8 +,6 @@ void si_init_config(struct r600_context *rctx)
r600_pipe_state_add_reg(rstate, R_028AB8_VGT_VTX_CNT_EN, 0x0, NULL, 0);
r600_pipe_state_add_reg(rstate, R_008A14_PA_CL_ENHANCE, (3 << 1) | 1, 
NULL, 0);
 
-   r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL, 0x0, NULL, 0);
-
r600_pipe_state_add_reg(rstate, R_028B54_VGT_SHADER_STAGES_EN, 0, NULL, 
0);
r600_pipe_state_add_reg(rstate, R_028BD4_PA_SC_CENTROID_PRIORITY_0, 
0x76543210, NULL, 0);
r600_pipe_state_add_reg(rstate, R_028BD8_PA_SC_CENTROID_PRIORITY_1, 
0xfedcba98, NULL, 0);
diff --git a/src/gallium/drivers/radeonsi/r600_state_common.c 
b/src/gallium/drivers/radeonsi/r600_state_common.c
index a28490e..97b7efc 100644
--- a/src/gallium/drivers/radeonsi/r600_state_common.c
+++ b/src/gallium/drivers/radeonsi/r600_state_common.c
@@ -92,33 +92,6 @@ void r600_texture_barrier(struct pipe_context *ctx)
r600_atom_dirty(rctx, &rctx->atom_surface_sync.atom);
 }
 
-static bool r600_conv_pipe_prim(unsigned pprim, unsigned *prim)
-{
-   static const int prim_conv[] = {
-   V_008958_DI_PT_POINTLIST,
-   V_008958_DI_PT_LINELIST,
-   V_008958_DI_PT_LINELOOP,
-   V_008958_DI_PT_LINESTRIP,
-   V_008958_DI_PT_TRILIST,
-   V_008958_DI_PT_TRISTRIP,
-   V_008958_DI_PT_TRIFAN,
-   V_008958_DI_PT_QUADLIST,
-   V_008958_DI_PT_QUADSTRIP,
-   V_008958_DI_PT_POLYGON,
-   -1,
-   -1,
-   -1,
-   -1
-   };
-
-   *prim = prim_conv[pprim];
-   if (*prim == -1) {
-   fprintf(stderr, "%s:%d unsupported %d\n", __func__, __LINE__, 
pprim);
-   return false;
-   }
-   return true;
-}
-
 /* common state between evergreen and r600 */
 void r600_sampler_view_destroy(struct pipe_context *ctx,
   struct pipe_sampler_view *state)
@@ -554,14 +527,12 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *dinfo)
struct pipe_draw_info info = *dinfo;
struct r600_draw rdraw = {};
struct pipe_index_buffer ib = {};
-   unsigned prim, ls_mask = 0;

[Mesa-dev] [PATCH 12/23] radeonsi: move CB_TARGET_MASK into fb/blend state

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|1 -
 src/gallium/drivers/radeonsi/r600_state_common.c   |   12 +--
 src/gallium/drivers/radeonsi/si_state.c|   21 
 src/gallium/drivers/radeonsi/si_state.h|1 +
 4 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index eedc61a..9bd547f 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -51,7 +51,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028080_TA_BC_BASE_ADDR, REG_FLAG_NEED_BO},
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0},
-   {R_028238_CB_TARGET_MASK, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028400_VGT_MAX_VTX_INDX, 0},
{R_028404_VGT_MIN_VTX_INDX, 0},
diff --git a/src/gallium/drivers/radeonsi/r600_state_common.c 
b/src/gallium/drivers/radeonsi/r600_state_common.c
index b6c83f8..a28490e 100644
--- a/src/gallium/drivers/radeonsi/r600_state_common.c
+++ b/src/gallium/drivers/radeonsi/r600_state_common.c
@@ -554,10 +554,9 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *dinfo)
struct pipe_draw_info info = *dinfo;
struct r600_draw rdraw = {};
struct pipe_index_buffer ib = {};
-   unsigned prim, mask, ls_mask = 0;
+   unsigned prim, ls_mask = 0;
struct r600_block *dirty_block = NULL, *next_block = NULL;
struct r600_atom *state = NULL, *next_state = NULL;
-   struct si_state_blend *blend;
int i;
 
if ((!info.count && (info.indexed || !info.count_from_stream_output)) ||
@@ -569,11 +568,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *dinfo)
if (!rctx->ps_shader || !rctx->vs_shader)
return;
 
-   /* only temporary */
-   if (!rctx->qued.named.blend)
-   return;
-   blend = rctx->qued.named.blend;
-
si_update_derived_state(rctx);
 
r600_vertex_buffer_update(rctx);
@@ -617,13 +611,10 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *dinfo)
 
rctx->vs_shader_so_strides = rctx->vs_shader->so_strides;
 
-   mask = (1ULL << ((unsigned)rctx->framebuffer.nr_cbufs * 4)) - 1;
-
if (rctx->vgt.id != R600_PIPE_STATE_VGT) {
rctx->vgt.id = R600_PIPE_STATE_VGT;
rctx->vgt.nregs = 0;
r600_pipe_state_add_reg(&rctx->vgt, 
R_008958_VGT_PRIMITIVE_TYPE, prim, NULL, 0);
-   r600_pipe_state_add_reg(&rctx->vgt, R_028238_CB_TARGET_MASK, 
blend->cb_target_mask & mask, NULL, 0);
r600_pipe_state_add_reg(&rctx->vgt, R_028400_VGT_MAX_VTX_INDX, 
~0, NULL, 0);
r600_pipe_state_add_reg(&rctx->vgt, R_028404_VGT_MIN_VTX_INDX, 
0, NULL, 0);
r600_pipe_state_add_reg(&rctx->vgt, R_028408_VGT_INDX_OFFSET, 
info.index_bias, NULL, 0);
@@ -641,7 +632,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *dinfo)
 
rctx->vgt.nregs = 0;
r600_pipe_state_mod_reg(&rctx->vgt, prim);
-   r600_pipe_state_mod_reg(&rctx->vgt, blend->cb_target_mask & mask);
r600_pipe_state_mod_reg(&rctx->vgt, ~0);
r600_pipe_state_mod_reg(&rctx->vgt, 0);
r600_pipe_state_mod_reg(&rctx->vgt, info.index_bias);
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index eaf20d2..ddcf6aa 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -31,6 +31,25 @@
 #include "sid.h"
 
 /*
+ * inferred framebuffer and blender state
+ */
+static void si_update_fb_blend_state(struct r600_context *rctx)
+{
+   struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+   struct si_state_blend *blend = rctx->qued.named.blend;
+   uint32_t mask;
+
+   if (pm4 == NULL || blend == NULL)
+   return;
+
+   mask = (1ULL << ((unsigned)rctx->framebuffer.nr_cbufs * 4)) - 1;
+   mask &= blend->cb_target_mask;
+   si_pm4_set_reg(pm4, R_028238_CB_TARGET_MASK, mask);
+
+   si_pm4_set_state(rctx, fb_blend, pm4);
+}
+
+/*
  * Blender functions
  */
 
@@ -169,6 +188,7 @@ static void si_bind_blend_state(struct pipe_context *ctx, 
void *state)
 {
struct r600_context *rctx = (struct r600_context *)ctx;
si_pm4_bind_state(rctx, blend, (struct si_state_blend *)state);
+   si_update_fb_blend_state(rctx);
 }
 
 static void si_delete_blend_state(struct pipe_context *ctx, void *state)
@@ -1267,6 +1287,7 @@ static void si_set_framebuffer_state(struct pipe_context 
*ctx,
 
si_pm4_set_state(rctx, framebuffer, pm4);
si_update_fb_rs_state(rctx);
+   si_update_fb_blend_state(rctx);
 }
 
 void si_init_state_functions(struct r600_con

[Mesa-dev] [PATCH 11/23] radeonsi: move stencil_ref to new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|2 -
 src/gallium/drivers/radeonsi/evergreen_state.c |1 -
 src/gallium/drivers/radeonsi/r600_blit.c   |4 +-
 src/gallium/drivers/radeonsi/r600_state_common.c   |   50 
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |   12 -
 src/gallium/drivers/radeonsi/si_state.c|   45 ++
 src/gallium/drivers/radeonsi/si_state.h|1 +
 7 files changed, 37 insertions(+), 78 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 8cab629..eedc61a 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -59,8 +59,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_02840C_VGT_MULTI_PRIM_IB_RESET_INDX, 0},
{R_028A94_VGT_MULTI_PRIM_IB_RESET_EN, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028430_DB_STENCILREFMASK, 0},
-   {R_028434_DB_STENCILREFMASK_BF, 0},
{R_028644_SPI_PS_INPUT_CNTL_0, 0},
{R_028648_SPI_PS_INPUT_CNTL_1, 0},
{R_02864C_SPI_PS_INPUT_CNTL_2, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index 1fd5118..cf99d58 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -1072,7 +1072,6 @@ void cayman_init_state_functions(struct r600_context 
*rctx)
rctx->context.set_fragment_sampler_views = 
evergreen_set_ps_sampler_view;
rctx->context.set_polygon_stipple = evergreen_set_polygon_stipple;
rctx->context.set_sample_mask = evergreen_set_sample_mask;
-   rctx->context.set_stencil_ref = r600_set_pipe_stencil_ref;
rctx->context.set_vertex_buffers = r600_set_vertex_buffers;
rctx->context.set_index_buffer = r600_set_index_buffer;
rctx->context.set_vertex_sampler_views = evergreen_set_vs_sampler_view;
diff --git a/src/gallium/drivers/radeonsi/r600_blit.c 
b/src/gallium/drivers/radeonsi/r600_blit.c
index 57b272a..e49b09a 100644
--- a/src/gallium/drivers/radeonsi/r600_blit.c
+++ b/src/gallium/drivers/radeonsi/r600_blit.c
@@ -50,9 +50,7 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum 
r600_blitter_op op
 
util_blitter_save_blend(rctx->blitter, rctx->qued.named.blend);
util_blitter_save_depth_stencil_alpha(rctx->blitter, 
rctx->qued.named.dsa);
-   if (rctx->states[R600_PIPE_STATE_STENCIL_REF]) {
-   util_blitter_save_stencil_ref(rctx->blitter, 
&rctx->stencil_ref);
-   }
+   util_blitter_save_stencil_ref(rctx->blitter, &rctx->stencil_ref);
util_blitter_save_rasterizer(rctx->blitter, 
rctx->qued.named.rasterizer);
util_blitter_save_fragment_shader(rctx->blitter, rctx->ps_shader);
util_blitter_save_vertex_shader(rctx->blitter, rctx->vs_shader);
diff --git a/src/gallium/drivers/radeonsi/r600_state_common.c 
b/src/gallium/drivers/radeonsi/r600_state_common.c
index a8db271..b6c83f8 100644
--- a/src/gallium/drivers/radeonsi/r600_state_common.c
+++ b/src/gallium/drivers/radeonsi/r600_state_common.c
@@ -120,56 +120,6 @@ static bool r600_conv_pipe_prim(unsigned pprim, unsigned 
*prim)
 }
 
 /* common state between evergreen and r600 */
-void r600_set_stencil_ref(struct pipe_context *ctx,
- const struct r600_stencil_ref *state)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
-
-   if (rstate == NULL)
-   return;
-
-   rstate->id = R600_PIPE_STATE_STENCIL_REF;
-   r600_pipe_state_add_reg(rstate,
-   R_028430_DB_STENCILREFMASK,
-   S_028430_STENCILTESTVAL(state->ref_value[0]) |
-   S_028430_STENCILMASK(state->valuemask[0]) |
-   S_028430_STENCILWRITEMASK(state->writemask[0]),
-   NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_028434_DB_STENCILREFMASK_BF,
-   S_028434_STENCILTESTVAL_BF(state->ref_value[1]) 
|
-   S_028434_STENCILMASK_BF(state->valuemask[1]) |
-   
S_028434_STENCILWRITEMASK_BF(state->writemask[1]),
-   NULL, 0);
-
-   free(rctx->states[R600_PIPE_STATE_STENCIL_REF]);
-   rctx->states[R600_PIPE_STATE_STENCIL_REF] = rstate;
-   r600_context_pipe_state_set(rctx, rstate);
-}
-
-void r600_set_pipe_stencil_ref(struct pipe_context *ctx,
-  const struct pipe_stencil_ref *state)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct si_state_dsa *dsa = rctx->qued.named.dsa;
-   struct r600_stencil_ref r

[Mesa-dev] [PATCH 10/23] radeonsi: move dsa state to new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|   12 --
 src/gallium/drivers/radeonsi/evergreen_state.c |  101 ---
 src/gallium/drivers/radeonsi/r600_blit.c   |2 +-
 src/gallium/drivers/radeonsi/r600_state_common.c   |   33 +
 src/gallium/drivers/radeonsi/radeonsi_pipe.c   |1 -
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |   13 +-
 src/gallium/drivers/radeonsi/si_state.c|  132 
 src/gallium/drivers/radeonsi/si_state.h|   10 ++
 8 files changed, 149 insertions(+), 155 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 07fa74f..8cab629 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -43,18 +43,11 @@ static const struct r600_reg si_config_reg_list[] = {
 };
 
 static const struct r600_reg si_context_reg_list[] = {
-   {R_028000_DB_RENDER_CONTROL, 0},
{R_028004_DB_COUNT_CONTROL, 0},
-   {R_02800C_DB_RENDER_OVERRIDE, 0},
{R_028010_DB_RENDER_OVERRIDE2, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028014_DB_HTILE_DATA_BASE, REG_FLAG_NEED_BO},
{GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028020_DB_DEPTH_BOUNDS_MIN, 0},
-   {R_028024_DB_DEPTH_BOUNDS_MAX, 0},
-   {R_028028_DB_STENCIL_CLEAR, 0},
-   {R_02802C_DB_DEPTH_CLEAR, 0},
-   {GROUP_FORCE_NEW_BLOCK, 0},
{R_028080_TA_BC_BASE_ADDR, REG_FLAG_NEED_BO},
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0},
@@ -112,7 +105,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_0287D8_PA_CL_POINT_Y_RAD, 0},
{R_0287DC_PA_CL_POINT_SIZE, 0},
{R_0287E0_PA_CL_POINT_CULL_RAD, 0},
-   {R_028800_DB_DEPTH_CONTROL, 0},
{R_028804_DB_EQAA, 0},
{R_02880C_DB_SHADER_CONTROL, 0},
{R_028810_PA_CL_CLIP_CNTL, 0},
@@ -155,11 +147,7 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028AB4_VGT_REUSE_OFF, 0},
{R_028AB8_VGT_VTX_CNT_EN, 0},
{R_028ABC_DB_HTILE_SURFACE, 0},
-   {R_028AC0_DB_SRESULTS_COMPARE_STATE0, 0},
-   {R_028AC4_DB_SRESULTS_COMPARE_STATE1, 0},
-   {R_028AC8_DB_PRELOAD_CONTROL, 0},
{R_028B54_VGT_SHADER_STAGES_EN, 0},
-   {R_028B70_DB_ALPHA_TO_MASK, 0},
{R_028B94_VGT_STRMOUT_CONFIG, 0},
{R_028B98_VGT_STRMOUT_BUFFER_CONFIG, 0},
{R_028BD4_PA_SC_CENTROID_PRIORITY_0, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index b36be3f..1fd5118 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -76,12 +76,6 @@ static uint32_t r600_translate_stencil_op(int s_op)
 }
 #endif
 
-/* translates straight */
-static uint32_t si_translate_ds_func(int func)
-{
-   return func;
-}
-
 static unsigned si_tex_wrap(unsigned wrap)
 {
switch (wrap) {
@@ -748,81 +742,6 @@ boolean si_is_format_supported(struct pipe_screen *screen,
return retval == usage;
 }
 
-static void *evergreen_create_dsa_state(struct pipe_context *ctx,
-  const struct pipe_depth_stencil_alpha_state 
*state)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct r600_pipe_dsa *dsa = CALLOC_STRUCT(r600_pipe_dsa);
-   unsigned db_depth_control, alpha_test_control, alpha_ref;
-   unsigned db_render_override, db_render_control;
-   struct r600_pipe_state *rstate;
-
-   if (dsa == NULL) {
-   return NULL;
-   }
-
-   dsa->valuemask[0] = state->stencil[0].valuemask;
-   dsa->valuemask[1] = state->stencil[1].valuemask;
-   dsa->writemask[0] = state->stencil[0].writemask;
-   dsa->writemask[1] = state->stencil[1].writemask;
-
-   rstate = &dsa->rstate;
-
-   rstate->id = R600_PIPE_STATE_DSA;
-   db_depth_control = S_028800_Z_ENABLE(state->depth.enabled) |
-   S_028800_Z_WRITE_ENABLE(state->depth.writemask) |
-   S_028800_ZFUNC(state->depth.func);
-
-   /* stencil */
-   if (state->stencil[0].enabled) {
-   db_depth_control |= S_028800_STENCIL_ENABLE(1);
-   db_depth_control |= 
S_028800_STENCILFUNC(si_translate_ds_func(state->stencil[0].func));
-   //db_depth_control |= 
S_028800_STENCILFAIL(r600_translate_stencil_op(state->stencil[0].fail_op));
-   //db_depth_control |= 
S_028800_STENCILZPASS(r600_translate_stencil_op(state->stencil[0].zpass_op));
-   //db_depth_control |= 
S_028800_STENCILZFAIL(r600_translate_stencil_op(state->stencil[0].zfail_op));
-
-   if (state->stencil[1].enabled) {
-   db_depth_control |= S_028800_BACKFACE_ENABLE(1);
-   db_depth_control |= 
S_028800_STENCILFUNC_BF(si_translate_ds_func(st

[Mesa-dev] [PATCH 08/23] radeonsi: move rasterizer state into new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|   14 --
 src/gallium/drivers/radeonsi/evergreen_state.c |  135 +
 src/gallium/drivers/radeonsi/r600_blit.c   |2 +-
 src/gallium/drivers/radeonsi/r600_state_common.c   |   38 -
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |   16 --
 src/gallium/drivers/radeonsi/radeonsi_shader.c |3 +-
 src/gallium/drivers/radeonsi/si_state.c|  153 
 src/gallium/drivers/radeonsi/si_state.h|   13 ++
 8 files changed, 174 insertions(+), 200 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 052e6a5..9d3187b 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -57,7 +57,6 @@ static const struct r600_reg si_context_reg_list[] = {
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028080_TA_BC_BASE_ADDR, REG_FLAG_NEED_BO},
{GROUP_FORCE_NEW_BLOCK, 0},
-   {R_02820C_PA_SC_CLIPRECT_RULE, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0},
{R_028238_CB_TARGET_MASK, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
@@ -104,7 +103,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_0286C4_SPI_VS_OUT_CONFIG, 0},
{R_0286CC_SPI_PS_INPUT_ENA, 0},
{R_0286D0_SPI_PS_INPUT_ADDR, 0},
-   {R_0286D4_SPI_INTERP_CONTROL_0, 0},
{R_0286D8_SPI_PS_IN_CONTROL, 0},
{R_0286E0_SPI_BARYC_CNTL, 0},
{R_02870C_SPI_SHADER_POS_FORMAT, 0},
@@ -120,13 +118,9 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028810_PA_CL_CLIP_CNTL, 0},
{R_028814_PA_SU_SC_MODE_CNTL, 0},
{R_02881C_PA_CL_VS_OUT_CNTL, 0},
-   {R_028820_PA_CL_NANINF_CNTL, 0},
{R_028824_PA_SU_LINE_STIPPLE_CNTL, 0},
{R_028828_PA_SU_LINE_STIPPLE_SCALE, 0},
{R_02882C_PA_SU_PRIM_FILTER_CNTL, 0},
-   {R_028A00_PA_SU_POINT_SIZE, 0},
-   {R_028A04_PA_SU_POINT_MINMAX, 0},
-   {R_028A08_PA_SU_LINE_CNTL, 0},
{R_028A0C_PA_SC_LINE_STIPPLE, 0},
{R_028A10_VGT_OUTPUT_PATH_CNTL, 0},
{R_028A14_VGT_HOS_CNTL, 0},
@@ -141,7 +135,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028A38_VGT_GROUP_VECT_0_FMT_CNTL, 0},
{R_028A3C_VGT_GROUP_VECT_1_FMT_CNTL, 0},
{R_028A40_VGT_GS_MODE, 0},
-   {R_028A48_PA_SC_MODE_CNTL_0, 0},
{R_028A4C_PA_SC_MODE_CNTL_1, 0},
{R_028A50_VGT_ENHANCE, 0},
{R_028A54_VGT_GS_PER_ES, 0},
@@ -168,7 +161,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028B54_VGT_SHADER_STAGES_EN, 0},
{R_028B70_DB_ALPHA_TO_MASK, 0},
{R_028B78_PA_SU_POLY_OFFSET_DB_FMT_CNTL, 0},
-   {R_028B7C_PA_SU_POLY_OFFSET_CLAMP, 0},
{R_028B80_PA_SU_POLY_OFFSET_FRONT_SCALE, 0},
{R_028B84_PA_SU_POLY_OFFSET_FRONT_OFFSET, 0},
{R_028B88_PA_SU_POLY_OFFSET_BACK_SCALE, 0},
@@ -177,12 +169,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028B98_VGT_STRMOUT_BUFFER_CONFIG, 0},
{R_028BD4_PA_SC_CENTROID_PRIORITY_0, 0},
{R_028BD8_PA_SC_CENTROID_PRIORITY_1, 0},
-   {R_028BDC_PA_SC_LINE_CNTL, 0},
-   {R_028BE4_PA_SU_VTX_CNTL, 0},
-   {R_028BE8_PA_CL_GB_VERT_CLIP_ADJ, 0},
-   {R_028BEC_PA_CL_GB_VERT_DISC_ADJ, 0},
-   {R_028BF0_PA_CL_GB_HORZ_CLIP_ADJ, 0},
-   {R_028BF4_PA_CL_GB_HORZ_DISC_ADJ, 0},
{R_028BF8_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0, 0},
{R_028BFC_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_1, 0},
{R_028C00_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_2, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index b85e8bd..975ebda 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -76,21 +76,6 @@ static uint32_t r600_translate_stencil_op(int s_op)
 }
 #endif
 
-static uint32_t si_translate_fill(uint32_t func)
-{
-   switch(func) {
-   case PIPE_POLYGON_MODE_FILL:
-   return V_028814_X_DRAW_TRIANGLES;
-   case PIPE_POLYGON_MODE_LINE:
-   return V_028814_X_DRAW_LINES;
-   case PIPE_POLYGON_MODE_POINT:
-   return V_028814_X_DRAW_POINTS;
-   default:
-   assert(0);
-   return V_028814_X_DRAW_POINTS;
-   }
-}
-
 /* translates straight */
 static uint32_t si_translate_ds_func(int func)
 {
@@ -838,113 +823,6 @@ static void *evergreen_create_dsa_state(struct 
pipe_context *ctx,
return rstate;
 }
 
-static void *evergreen_create_rs_state(struct pipe_context *ctx,
-   const struct pipe_rasterizer_state 
*state)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct r600_pipe_rasterizer *rs = CALLOC_STRUCT(r600_pipe_rasterizer);
-   struct r600_pipe_state *rstate;
-   unsigned tmp;

[Mesa-dev] [PATCH 09/23] radeonsi: move infeered fb/rs state to new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|5 --
 src/gallium/drivers/radeonsi/evergreen_state.c |   50 -
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |2 -
 src/gallium/drivers/radeonsi/si_state.c|   59 +---
 src/gallium/drivers/radeonsi/si_state.h|1 +
 5 files changed, 52 insertions(+), 65 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 9d3187b..07fa74f 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -160,11 +160,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028AC8_DB_PRELOAD_CONTROL, 0},
{R_028B54_VGT_SHADER_STAGES_EN, 0},
{R_028B70_DB_ALPHA_TO_MASK, 0},
-   {R_028B78_PA_SU_POLY_OFFSET_DB_FMT_CNTL, 0},
-   {R_028B80_PA_SU_POLY_OFFSET_FRONT_SCALE, 0},
-   {R_028B84_PA_SU_POLY_OFFSET_FRONT_OFFSET, 0},
-   {R_028B88_PA_SU_POLY_OFFSET_BACK_SCALE, 0},
-   {R_028B8C_PA_SU_POLY_OFFSET_BACK_OFFSET, 0},
{R_028B94_VGT_STRMOUT_CONFIG, 0},
{R_028B98_VGT_STRMOUT_BUFFER_CONFIG, 0},
{R_028BD4_PA_SC_CENTROID_PRIORITY_0, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index 975ebda..b36be3f 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -1206,56 +1206,6 @@ void si_init_config(struct r600_context *rctx)
r600_context_pipe_state_set(rctx, rstate);
 }
 
-void cayman_polygon_offset_update(struct r600_context *rctx)
-{
-   struct r600_pipe_state state;
-
-   state.id = R600_PIPE_STATE_POLYGON_OFFSET;
-   state.nregs = 0;
-   if (rctx->qued.named.rasterizer && rctx->framebuffer.zsbuf) {
-   float offset_units = rctx->qued.named.rasterizer->offset_units;
-   unsigned offset_db_fmt_cntl = 0, depth;
-
-   switch (rctx->framebuffer.zsbuf->texture->format) {
-   case PIPE_FORMAT_Z24X8_UNORM:
-   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
-   depth = -24;
-   offset_units *= 2.0f;
-   break;
-   case PIPE_FORMAT_Z32_FLOAT:
-   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
-   depth = -23;
-   offset_units *= 1.0f;
-   offset_db_fmt_cntl |= 
S_028B78_POLY_OFFSET_DB_IS_FLOAT_FMT(1);
-   break;
-   case PIPE_FORMAT_Z16_UNORM:
-   depth = -16;
-   offset_units *= 4.0f;
-   break;
-   default:
-   return;
-   }
-   /* FIXME some of those reg can be computed with cso */
-   offset_db_fmt_cntl |= 
S_028B78_POLY_OFFSET_NEG_NUM_DB_BITS(depth);
-   r600_pipe_state_add_reg(&state,
-   R_028B80_PA_SU_POLY_OFFSET_FRONT_SCALE,
-   fui(rctx->qued.named.rasterizer->offset_scale), 
NULL, 0);
-   r600_pipe_state_add_reg(&state,
-   R_028B84_PA_SU_POLY_OFFSET_FRONT_OFFSET,
-   fui(offset_units), NULL, 0);
-   r600_pipe_state_add_reg(&state,
-   R_028B88_PA_SU_POLY_OFFSET_BACK_SCALE,
-   fui(rctx->qued.named.rasterizer->offset_scale), 
NULL, 0);
-   r600_pipe_state_add_reg(&state,
-   R_028B8C_PA_SU_POLY_OFFSET_BACK_OFFSET,
-   fui(offset_units), NULL, 0);
-   r600_pipe_state_add_reg(&state,
-   R_028B78_PA_SU_POLY_OFFSET_DB_FMT_CNTL,
-   offset_db_fmt_cntl, NULL, 0);
-   r600_context_pipe_state_set(rctx, &state);
-   }
-}
-
 void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader *shader)
 {
struct r600_context *rctx = (struct r600_context *)ctx;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index 02abd32..1e1fcc8 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -85,7 +85,6 @@ enum r600_pipe_state_id {
R600_PIPE_STATE_CONSTANT,
R600_PIPE_STATE_SAMPLER,
R600_PIPE_STATE_RESOURCE,
-   R600_PIPE_STATE_POLYGON_OFFSET,
R600_PIPE_NSTATES
 };
 
@@ -324,7 +323,6 @@ void si_pipe_shader_ps(struct pipe_context *ctx, struct 
si_pipe_shader *shader);
 void si_pipe_shader_vs(struct pipe_context *ctx, struct si_pipe_shader 
*shader);
 void si_update_spi_map(struct r600_context *rctx);
 void *cayman_create_db_flush_dsa(struct r600_context *rctx);
-void cayman_polygon_off

[Mesa-dev] [PATCH 07/23] radeonsi: move framebuffer to new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|   86 ---
 src/gallium/drivers/radeonsi/evergreen_state.c |  358 ---
 src/gallium/drivers/radeonsi/r600_state_common.c   |2 +-
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |2 -
 src/gallium/drivers/radeonsi/radeonsi_shader.c |2 +-
 src/gallium/drivers/radeonsi/si_state.c|  663 
 src/gallium/drivers/radeonsi/si_state.h|1 +
 7 files changed, 666 insertions(+), 448 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 424728e..052e6a5 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -45,7 +45,6 @@ static const struct r600_reg si_config_reg_list[] = {
 static const struct r600_reg si_context_reg_list[] = {
{R_028000_DB_RENDER_CONTROL, 0},
{R_028004_DB_COUNT_CONTROL, 0},
-   {R_028008_DB_DEPTH_VIEW, 0},
{R_02800C_DB_RENDER_OVERRIDE, 0},
{R_028010_DB_RENDER_OVERRIDE2, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
@@ -55,40 +54,12 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028024_DB_DEPTH_BOUNDS_MAX, 0},
{R_028028_DB_STENCIL_CLEAR, 0},
{R_02802C_DB_DEPTH_CLEAR, 0},
-   {R_028030_PA_SC_SCREEN_SCISSOR_TL, 0},
-   {R_028034_PA_SC_SCREEN_SCISSOR_BR, 0},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_02803C_DB_DEPTH_INFO, 0},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028040_DB_Z_INFO, 0},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028044_DB_STENCIL_INFO, 0},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028048_DB_Z_READ_BASE, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_02804C_DB_STENCIL_READ_BASE, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028050_DB_Z_WRITE_BASE, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028054_DB_STENCIL_WRITE_BASE, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028058_DB_DEPTH_SIZE, 0},
-   {R_02805C_DB_DEPTH_SLICE, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028080_TA_BC_BASE_ADDR, REG_FLAG_NEED_BO},
{GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028200_PA_SC_WINDOW_OFFSET, 0},
-   {R_028204_PA_SC_WINDOW_SCISSOR_TL, 0},
-   {R_028208_PA_SC_WINDOW_SCISSOR_BR, 0},
{R_02820C_PA_SC_CLIPRECT_RULE, 0},
-   {R_028230_PA_SC_EDGERULE, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0},
{R_028238_CB_TARGET_MASK, 0},
-   {R_02823C_CB_SHADER_MASK, 0},
-   {R_028240_PA_SC_GENERIC_SCISSOR_TL, 0},
-   {R_028244_PA_SC_GENERIC_SCISSOR_BR, 0},
-   {R_028250_PA_SC_VPORT_SCISSOR_0_TL, 0},
-   {R_028254_PA_SC_VPORT_SCISSOR_0_BR, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028400_VGT_MAX_VTX_INDX, 0},
{R_028404_VGT_MIN_VTX_INDX, 0},
@@ -207,7 +178,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028BD4_PA_SC_CENTROID_PRIORITY_0, 0},
{R_028BD8_PA_SC_CENTROID_PRIORITY_1, 0},
{R_028BDC_PA_SC_LINE_CNTL, 0},
-   {R_028BE0_PA_SC_AA_CONFIG, 0},
{R_028BE4_PA_SU_VTX_CNTL, 0},
{R_028BE8_PA_CL_GB_VERT_CLIP_ADJ, 0},
{R_028BEC_PA_CL_GB_VERT_DISC_ADJ, 0},
@@ -229,62 +199,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028C2C_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_1, 0},
{R_028C30_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_2, 0},
{R_028C34_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_3, 0},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028C60_CB_COLOR0_BASE, REG_FLAG_NEED_BO},
-   {R_028C64_CB_COLOR0_PITCH, 0},
-   {R_028C68_CB_COLOR0_SLICE, 0},
-   {R_028C6C_CB_COLOR0_VIEW, 0},
-   {R_028C70_CB_COLOR0_INFO, REG_FLAG_NEED_BO},
-   {R_028C74_CB_COLOR0_ATTRIB, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028C9C_CB_COLOR1_BASE, REG_FLAG_NEED_BO},
-   {R_028CA0_CB_COLOR1_PITCH, 0},
-   {R_028CA4_CB_COLOR1_SLICE, 0},
-   {R_028CA8_CB_COLOR1_VIEW, 0},
-   {R_028CAC_CB_COLOR1_INFO, REG_FLAG_NEED_BO},
-   {R_028CB0_CB_COLOR1_ATTRIB, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028CD8_CB_COLOR2_BASE, REG_FLAG_NEED_BO},
-   {R_028CDC_CB_COLOR2_PITCH, 0},
-   {R_028CE0_CB_COLOR2_SLICE, 0},
-   {R_028CE4_CB_COLOR2_VIEW, 0},
-   {R_028CE8_CB_COLOR2_INFO, REG_FLAG_NEED_BO},
-   {R_028CEC_CB_COLOR2_ATTRIB, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028D14_CB_COLOR3_BASE, REG_FLAG_NEED_BO},
-   {R_028D18_CB_COLOR3_PITCH, 0},
-   {R_028D1C_CB_COLOR3_SLICE, 0},
-   {R_028D20_CB_COLOR3_VIEW, 0},
-   {R_028D24_CB_COLOR3_INFO, REG_FLAG_NEED_BO},
-   {R_028D28_CB_COLOR3_ATTRIB, REG_FLAG_NEED_BO},
-   {GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028D50_CB_COLOR4_BASE, REG_FLAG_NEED_BO},
-   {R_028D54_CB_COLOR4_PITCH, 0},
-   {R_028D58_CB_COLOR4_SLICE, 0},

[Mesa-dev] [PATCH 06/23] radeonsi: move viewport to new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|   10 ---
 src/gallium/drivers/radeonsi/evergreen_state.c |   28 
 src/gallium/drivers/radeonsi/r600_blit.c   |5 ++--
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |2 --
 src/gallium/drivers/radeonsi/si_state.c|   26 ++
 src/gallium/drivers/radeonsi/si_state.h|   14 +++---
 6 files changed, 39 insertions(+), 46 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 155489f..424728e 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -89,9 +89,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028244_PA_SC_GENERIC_SCISSOR_BR, 0},
{R_028250_PA_SC_VPORT_SCISSOR_0_TL, 0},
{R_028254_PA_SC_VPORT_SCISSOR_0_BR, 0},
-   {R_0282D0_PA_SC_VPORT_ZMIN_0, 0},
-   {R_0282D4_PA_SC_VPORT_ZMAX_0, 0},
-   {R_028350_PA_SC_RASTER_CONFIG, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028400_VGT_MAX_VTX_INDX, 0},
{R_028404_VGT_MIN_VTX_INDX, 0},
@@ -101,12 +98,6 @@ static const struct r600_reg si_context_reg_list[] = {
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028430_DB_STENCILREFMASK, 0},
{R_028434_DB_STENCILREFMASK_BF, 0},
-   {R_02843C_PA_CL_VPORT_XSCALE_0, 0},
-   {R_028440_PA_CL_VPORT_XOFFSET_0, 0},
-   {R_028444_PA_CL_VPORT_YSCALE_0, 0},
-   {R_028448_PA_CL_VPORT_YOFFSET_0, 0},
-   {R_02844C_PA_CL_VPORT_ZSCALE_0, 0},
-   {R_028450_PA_CL_VPORT_ZOFFSET_0, 0},
{R_028644_SPI_PS_INPUT_CNTL_0, 0},
{R_028648_SPI_PS_INPUT_CNTL_1, 0},
{R_02864C_SPI_PS_INPUT_CNTL_2, 0},
@@ -157,7 +148,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_02880C_DB_SHADER_CONTROL, 0},
{R_028810_PA_CL_CLIP_CNTL, 0},
{R_028814_PA_SU_SC_MODE_CNTL, 0},
-   {R_028818_PA_CL_VTE_CNTL, 0},
{R_02881C_PA_CL_VS_OUT_CNTL, 0},
{R_028820_PA_CL_NANINF_CNTL, 0},
{R_028824_PA_SU_LINE_STIPPLE_CNTL, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index cfae877..2b3403b 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -1254,33 +1254,6 @@ static void evergreen_set_sample_mask(struct 
pipe_context *pipe, unsigned sample
 {
 }
 
-static void evergreen_set_viewport_state(struct pipe_context *ctx,
-   const struct pipe_viewport_state *state)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
-
-   if (rstate == NULL)
-   return;
-
-   rctx->viewport = *state;
-   rstate->id = R600_PIPE_STATE_VIEWPORT;
-   r600_pipe_state_add_reg(rstate, R_0282D0_PA_SC_VPORT_ZMIN_0, 
0x, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_0282D4_PA_SC_VPORT_ZMAX_0, 
0x3F80, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028350_PA_SC_RASTER_CONFIG, 
0x, NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_02843C_PA_CL_VPORT_XSCALE_0, 
fui(state->scale[0]), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028444_PA_CL_VPORT_YSCALE_0, 
fui(state->scale[1]), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_02844C_PA_CL_VPORT_ZSCALE_0, 
fui(state->scale[2]), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028440_PA_CL_VPORT_XOFFSET_0, 
fui(state->translate[0]), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028448_PA_CL_VPORT_YOFFSET_0, 
fui(state->translate[1]), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028450_PA_CL_VPORT_ZOFFSET_0, 
fui(state->translate[2]), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028818_PA_CL_VTE_CNTL, 0x043F, 
NULL, 0);
-
-   free(rctx->states[R600_PIPE_STATE_VIEWPORT]);
-   rctx->states[R600_PIPE_STATE_VIEWPORT] = rstate;
-   r600_context_pipe_state_set(rctx, rstate);
-}
-
 static void evergreen_cb(struct r600_context *rctx, struct r600_pipe_state 
*rstate,
 const struct pipe_framebuffer_state *state, int cb)
 {
@@ -1670,7 +1643,6 @@ void cayman_init_state_functions(struct r600_context 
*rctx)
rctx->context.set_vertex_buffers = r600_set_vertex_buffers;
rctx->context.set_index_buffer = r600_set_index_buffer;
rctx->context.set_vertex_sampler_views = evergreen_set_vs_sampler_view;
-   rctx->context.set_viewport_state = evergreen_set_viewport_state;
rctx->context.sampler_view_destroy = r600_sampler_view_destroy;
rctx->context.texture_barrier = r600_texture_barrier;
rctx->context.create_stream_output_target = r600_create_so_target;
diff --git a/src/gallium/drivers/radeonsi/r600_blit.c 
b/src/gallium/drivers/radeonsi/r600_blit.c
index be7

[Mesa-dev] [PATCH 05/23] radeonsi: move scissor state to new state handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|8 
 src/gallium/drivers/radeonsi/evergreen_state.c |   44 
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |1 -
 src/gallium/drivers/radeonsi/si_state.c|   25 +++
 src/gallium/drivers/radeonsi/si_state.h|1 +
 5 files changed, 26 insertions(+), 53 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index d68e4b8..155489f 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -81,14 +81,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028204_PA_SC_WINDOW_SCISSOR_TL, 0},
{R_028208_PA_SC_WINDOW_SCISSOR_BR, 0},
{R_02820C_PA_SC_CLIPRECT_RULE, 0},
-   {R_028210_PA_SC_CLIPRECT_0_TL, 0},
-   {R_028214_PA_SC_CLIPRECT_0_BR, 0},
-   {R_028218_PA_SC_CLIPRECT_1_TL, 0},
-   {R_02821C_PA_SC_CLIPRECT_1_BR, 0},
-   {R_028220_PA_SC_CLIPRECT_2_TL, 0},
-   {R_028224_PA_SC_CLIPRECT_2_BR, 0},
-   {R_028228_PA_SC_CLIPRECT_3_TL, 0},
-   {R_02822C_PA_SC_CLIPRECT_3_BR, 0},
{R_028230_PA_SC_EDGERULE, 0},
{R_028234_PA_SU_HARDWARE_SCREEN_OFFSET, 0},
{R_028238_CB_TARGET_MASK, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index 025e317..cfae877 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -1254,49 +1254,6 @@ static void evergreen_set_sample_mask(struct 
pipe_context *pipe, unsigned sample
 {
 }
 
-static void evergreen_set_scissor_state(struct pipe_context *ctx,
-   const struct pipe_scissor_state *state)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
-   uint32_t tl, br;
-
-   if (rstate == NULL)
-   return;
-
-   rstate->id = R600_PIPE_STATE_SCISSOR;
-   tl = S_028240_TL_X(state->minx) | S_028240_TL_Y(state->miny);
-   br = S_028244_BR_X(state->maxx) | S_028244_BR_Y(state->maxy);
-   r600_pipe_state_add_reg(rstate,
-   R_028210_PA_SC_CLIPRECT_0_TL, tl,
-   NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_028214_PA_SC_CLIPRECT_0_BR, br,
-   NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_028218_PA_SC_CLIPRECT_1_TL, tl,
-   NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_02821C_PA_SC_CLIPRECT_1_BR, br,
-   NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_028220_PA_SC_CLIPRECT_2_TL, tl,
-   NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_028224_PA_SC_CLIPRECT_2_BR, br,
-   NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_028228_PA_SC_CLIPRECT_3_TL, tl,
-   NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_02822C_PA_SC_CLIPRECT_3_BR, br,
-   NULL, 0);
-
-   free(rctx->states[R600_PIPE_STATE_SCISSOR]);
-   rctx->states[R600_PIPE_STATE_SCISSOR] = rstate;
-   r600_context_pipe_state_set(rctx, rstate);
-}
-
 static void evergreen_set_viewport_state(struct pipe_context *ctx,
const struct pipe_viewport_state *state)
 {
@@ -1709,7 +1666,6 @@ void cayman_init_state_functions(struct r600_context 
*rctx)
rctx->context.set_framebuffer_state = evergreen_set_framebuffer_state;
rctx->context.set_polygon_stipple = evergreen_set_polygon_stipple;
rctx->context.set_sample_mask = evergreen_set_sample_mask;
-   rctx->context.set_scissor_state = evergreen_set_scissor_state;
rctx->context.set_stencil_ref = r600_set_pipe_stencil_ref;
rctx->context.set_vertex_buffers = r600_set_vertex_buffers;
rctx->context.set_index_buffer = r600_set_index_buffer;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index 66f4cdf..6e14f19 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -77,7 +77,6 @@ struct r600_atom_surface_sync {
 enum r600_pipe_state_id {
R600_PIPE_STATE_CONFIG,
R600_PIPE_STATE_SEAMLESS_CUBEMAP,
-   R600_PIPE_STATE_SCISSOR,
R600_PIPE_STATE_VIEWPORT,
R600_PIPE_STATE_RASTERIZER,
R600_PIPE_STATE_VGT,
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 9e52f86..68

[Mesa-dev] [PATCH 04/23] radeonsi: move clip state to new handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|   24 ---
 src/gallium/drivers/radeonsi/evergreen_state.c |   32 
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |2 --
 src/gallium/drivers/radeonsi/si_state.c|   25 +++
 src/gallium/drivers/radeonsi/si_state.h|1 +
 5 files changed, 26 insertions(+), 58 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 4971a60..d68e4b8 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -115,30 +115,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028448_PA_CL_VPORT_YOFFSET_0, 0},
{R_02844C_PA_CL_VPORT_ZSCALE_0, 0},
{R_028450_PA_CL_VPORT_ZOFFSET_0, 0},
-   {R_0285BC_PA_CL_UCP_0_X, 0},
-   {R_0285C0_PA_CL_UCP_0_Y, 0},
-   {R_0285C4_PA_CL_UCP_0_Z, 0},
-   {R_0285C8_PA_CL_UCP_0_W, 0},
-   {R_0285CC_PA_CL_UCP_1_X, 0},
-   {R_0285D0_PA_CL_UCP_1_Y, 0},
-   {R_0285D4_PA_CL_UCP_1_Z, 0},
-   {R_0285D8_PA_CL_UCP_1_W, 0},
-   {R_0285DC_PA_CL_UCP_2_X, 0},
-   {R_0285E0_PA_CL_UCP_2_Y, 0},
-   {R_0285E4_PA_CL_UCP_2_Z, 0},
-   {R_0285E8_PA_CL_UCP_2_W, 0},
-   {R_0285EC_PA_CL_UCP_3_X, 0},
-   {R_0285F0_PA_CL_UCP_3_Y, 0},
-   {R_0285F4_PA_CL_UCP_3_Z, 0},
-   {R_0285F8_PA_CL_UCP_3_W, 0},
-   {R_0285FC_PA_CL_UCP_4_X, 0},
-   {R_028600_PA_CL_UCP_4_Y, 0},
-   {R_028604_PA_CL_UCP_4_Z, 0},
-   {R_028608_PA_CL_UCP_4_W, 0},
-   {R_02860C_PA_CL_UCP_5_X, 0},
-   {R_028610_PA_CL_UCP_5_Y, 0},
-   {R_028614_PA_CL_UCP_5_Z, 0},
-   {R_028618_PA_CL_UCP_5_W, 0},
{R_028644_SPI_PS_INPUT_CNTL_0, 0},
{R_028648_SPI_PS_INPUT_CNTL_1, 0},
{R_02864C_SPI_PS_INPUT_CNTL_2, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index 23d7297..025e317 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -1245,37 +1245,6 @@ static void evergreen_bind_vs_sampler(struct 
pipe_context *ctx, unsigned count,
 {
 }
 
-static void evergreen_set_clip_state(struct pipe_context *ctx,
-   const struct pipe_clip_state *state)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
-
-   if (rstate == NULL)
-   return;
-
-   rctx->clip = *state;
-   rstate->id = R600_PIPE_STATE_CLIP;
-   for (int i = 0; i < 6; i++) {
-   r600_pipe_state_add_reg(rstate,
-   R_0285BC_PA_CL_UCP_0_X + i * 16,
-   fui(state->ucp[i][0]), NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_0285C0_PA_CL_UCP_0_Y + i * 16,
-   fui(state->ucp[i][1]) , NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_0285C4_PA_CL_UCP_0_Z + i * 16,
-   fui(state->ucp[i][2]), NULL, 0);
-   r600_pipe_state_add_reg(rstate,
-   R_0285C8_PA_CL_UCP_0_W + i * 16,
-   fui(state->ucp[i][3]), NULL, 0);
-   }
-
-   free(rctx->states[R600_PIPE_STATE_CLIP]);
-   rctx->states[R600_PIPE_STATE_CLIP] = rstate;
-   r600_context_pipe_state_set(rctx, rstate);
-}
-
 static void evergreen_set_polygon_stipple(struct pipe_context *ctx,
 const struct pipe_poly_stipple *state)
 {
@@ -1735,7 +1704,6 @@ void cayman_init_state_functions(struct r600_context 
*rctx)
rctx->context.delete_sampler_state = si_delete_sampler_state;
rctx->context.delete_vertex_elements_state = r600_delete_vertex_element;
rctx->context.delete_vs_state = r600_delete_vs_shader;
-   rctx->context.set_clip_state = evergreen_set_clip_state;
rctx->context.set_constant_buffer = r600_set_constant_buffer;
rctx->context.set_fragment_sampler_views = 
evergreen_set_ps_sampler_view;
rctx->context.set_framebuffer_state = evergreen_set_framebuffer_state;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index 6abbc28..66f4cdf 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -77,7 +77,6 @@ struct r600_atom_surface_sync {
 enum r600_pipe_state_id {
R600_PIPE_STATE_CONFIG,
R600_PIPE_STATE_SEAMLESS_CUBEMAP,
-   R600_PIPE_STATE_CLIP,
R600_PIPE_STATE_SCISSOR,
R600_PIPE_STATE_VIEWPORT,
R600_PIPE_STATE_RASTERIZER,
@@ -242,7 +241,6 @@ struct r600_context {
/

[Mesa-dev] [PATCH 03/23] radeonsi: move blend color to new state handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|4 
 src/gallium/drivers/radeonsi/evergreen_state.c |   21 
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |1 -
 src/gallium/drivers/radeonsi/si_state.c|   18 +
 src/gallium/drivers/radeonsi/si_state.h|1 +
 5 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 68d53d4..4971a60 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -107,10 +107,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_02840C_VGT_MULTI_PRIM_IB_RESET_INDX, 0},
{R_028A94_VGT_MULTI_PRIM_IB_RESET_EN, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
-   {R_028414_CB_BLEND_RED, 0},
-   {R_028418_CB_BLEND_GREEN, 0},
-   {R_02841C_CB_BLEND_BLUE, 0},
-   {R_028420_CB_BLEND_ALPHA, 0},
{R_028430_DB_STENCILREFMASK, 0},
{R_028434_DB_STENCILREFMASK_BF, 0},
{R_02843C_PA_CL_VPORT_XSCALE_0, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index 62f138a..23d7297 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -763,26 +763,6 @@ boolean si_is_format_supported(struct pipe_screen *screen,
return retval == usage;
 }
 
-static void evergreen_set_blend_color(struct pipe_context *ctx,
-   const struct pipe_blend_color *state)
-{
-   struct r600_context *rctx = (struct r600_context *)ctx;
-   struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
-
-   if (rstate == NULL)
-   return;
-
-   rstate->id = R600_PIPE_STATE_BLEND_COLOR;
-   r600_pipe_state_add_reg(rstate, R_028414_CB_BLEND_RED, 
fui(state->color[0]), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028418_CB_BLEND_GREEN, 
fui(state->color[1]), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_02841C_CB_BLEND_BLUE, 
fui(state->color[2]), NULL, 0);
-   r600_pipe_state_add_reg(rstate, R_028420_CB_BLEND_ALPHA, 
fui(state->color[3]), NULL, 0);
-
-   free(rctx->states[R600_PIPE_STATE_BLEND_COLOR]);
-   rctx->states[R600_PIPE_STATE_BLEND_COLOR] = rstate;
-   r600_context_pipe_state_set(rctx, rstate);
-}
-
 static void *evergreen_create_dsa_state(struct pipe_context *ctx,
   const struct pipe_depth_stencil_alpha_state 
*state)
 {
@@ -1755,7 +1735,6 @@ void cayman_init_state_functions(struct r600_context 
*rctx)
rctx->context.delete_sampler_state = si_delete_sampler_state;
rctx->context.delete_vertex_elements_state = r600_delete_vertex_element;
rctx->context.delete_vs_state = r600_delete_vs_shader;
-   rctx->context.set_blend_color = evergreen_set_blend_color;
rctx->context.set_clip_state = evergreen_set_clip_state;
rctx->context.set_constant_buffer = r600_set_constant_buffer;
rctx->context.set_fragment_sampler_views = 
evergreen_set_ps_sampler_view;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index b61d1c0..6abbc28 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -75,7 +75,6 @@ struct r600_atom_surface_sync {
 };
 
 enum r600_pipe_state_id {
-   R600_PIPE_STATE_BLEND_COLOR,
R600_PIPE_STATE_CONFIG,
R600_PIPE_STATE_SEAMLESS_CUBEMAP,
R600_PIPE_STATE_CLIP,
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 8373f42..51ee5c5 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -176,9 +176,27 @@ static void si_delete_blend_state(struct pipe_context 
*ctx, void *state)
si_pm4_delete_state(rctx, blend, (struct si_state_blend *)state);
 }
 
+static void si_set_blend_color(struct pipe_context *ctx,
+  const struct pipe_blend_color *state)
+{
+   struct r600_context *rctx = (struct r600_context *)ctx;
+   struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+
+if (pm4 == NULL)
+return;
+
+   si_pm4_set_reg(pm4, R_028414_CB_BLEND_RED, fui(state->color[0]));
+   si_pm4_set_reg(pm4, R_028418_CB_BLEND_GREEN, fui(state->color[1]));
+   si_pm4_set_reg(pm4, R_02841C_CB_BLEND_BLUE, fui(state->color[2]));
+   si_pm4_set_reg(pm4, R_028420_CB_BLEND_ALPHA, fui(state->color[3]));
+
+   si_pm4_set_state(rctx, blend_color, pm4);
+}
+
 void si_init_state_functions(struct r600_context *rctx)
 {
rctx->context.create_blend_state = si_create_blend_state;
rctx->context.bind_blend_state = si_bind_blend_state;
rctx->context.delete_blend_state

[Mesa-dev] [PATCH 02/23] radeonsi: move blender to new state handling

2012-07-20 Thread Christian König
Signed-off-by: Christian König 
---
 .../drivers/radeonsi/evergreen_hw_context.c|   11 --
 src/gallium/drivers/radeonsi/evergreen_state.c |  152 +--
 src/gallium/drivers/radeonsi/r600_blit.c   |2 +-
 src/gallium/drivers/radeonsi/r600_state_common.c   |   27 ++--
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |   10 --
 src/gallium/drivers/radeonsi/si_state.c|  158 +++-
 src/gallium/drivers/radeonsi/si_state.h|   11 +-
 7 files changed, 179 insertions(+), 192 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/evergreen_hw_context.c 
b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
index 4cf6a9e..68d53d4 100644
--- a/src/gallium/drivers/radeonsi/evergreen_hw_context.c
+++ b/src/gallium/drivers/radeonsi/evergreen_hw_context.c
@@ -184,21 +184,12 @@ static const struct r600_reg si_context_reg_list[] = {
{R_02870C_SPI_SHADER_POS_FORMAT, 0},
{R_028710_SPI_SHADER_Z_FORMAT, 0},
{R_028714_SPI_SHADER_COL_FORMAT, 0},
-   {R_028780_CB_BLEND0_CONTROL, 0},
-   {R_028784_CB_BLEND1_CONTROL, 0},
-   {R_028788_CB_BLEND2_CONTROL, 0},
-   {R_02878C_CB_BLEND3_CONTROL, 0},
-   {R_028790_CB_BLEND4_CONTROL, 0},
-   {R_028794_CB_BLEND5_CONTROL, 0},
-   {R_028798_CB_BLEND6_CONTROL, 0},
-   {R_02879C_CB_BLEND7_CONTROL, 0},
{R_0287D4_PA_CL_POINT_X_RAD, 0},
{R_0287D8_PA_CL_POINT_Y_RAD, 0},
{R_0287DC_PA_CL_POINT_SIZE, 0},
{R_0287E0_PA_CL_POINT_CULL_RAD, 0},
{R_028800_DB_DEPTH_CONTROL, 0},
{R_028804_DB_EQAA, 0},
-   {R_028808_CB_COLOR_CONTROL, 0},
{R_02880C_DB_SHADER_CONTROL, 0},
{R_028810_PA_CL_CLIP_CNTL, 0},
{R_028814_PA_SU_SC_MODE_CNTL, 0},
@@ -284,8 +275,6 @@ static const struct r600_reg si_context_reg_list[] = {
{R_028C2C_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_1, 0},
{R_028C30_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_2, 0},
{R_028C34_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_3, 0},
-   {R_028C38_PA_SC_AA_MASK_X0Y0_X1Y0, 0},
-   {R_028C3C_PA_SC_AA_MASK_X0Y1_X1Y1, 0},
{GROUP_FORCE_NEW_BLOCK, 0},
{R_028C60_CB_COLOR0_BASE, REG_FLAG_NEED_BO},
{R_028C64_CB_COLOR0_PITCH, 0},
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c 
b/src/gallium/drivers/radeonsi/evergreen_state.c
index 9c45719..62f138a 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -45,76 +45,7 @@
 #include "sid.h"
 #include "r600_resource.h"
 #include "radeonsi_pipe.h"
-
-static uint32_t si_translate_blend_function(int blend_func)
-{
-   switch (blend_func) {
-   case PIPE_BLEND_ADD:
-   return V_028780_COMB_DST_PLUS_SRC;
-   case PIPE_BLEND_SUBTRACT:
-   return V_028780_COMB_SRC_MINUS_DST;
-   case PIPE_BLEND_REVERSE_SUBTRACT:
-   return V_028780_COMB_DST_MINUS_SRC;
-   case PIPE_BLEND_MIN:
-   return V_028780_COMB_MIN_DST_SRC;
-   case PIPE_BLEND_MAX:
-   return V_028780_COMB_MAX_DST_SRC;
-   default:
-   R600_ERR("Unknown blend function %d\n", blend_func);
-   assert(0);
-   break;
-   }
-   return 0;
-}
-
-static uint32_t si_translate_blend_factor(int blend_fact)
-{
-   switch (blend_fact) {
-   case PIPE_BLENDFACTOR_ONE:
-   return V_028780_BLEND_ONE;
-   case PIPE_BLENDFACTOR_SRC_COLOR:
-   return V_028780_BLEND_SRC_COLOR;
-   case PIPE_BLENDFACTOR_SRC_ALPHA:
-   return V_028780_BLEND_SRC_ALPHA;
-   case PIPE_BLENDFACTOR_DST_ALPHA:
-   return V_028780_BLEND_DST_ALPHA;
-   case PIPE_BLENDFACTOR_DST_COLOR:
-   return V_028780_BLEND_DST_COLOR;
-   case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
-   return V_028780_BLEND_SRC_ALPHA_SATURATE;
-   case PIPE_BLENDFACTOR_CONST_COLOR:
-   return V_028780_BLEND_CONSTANT_COLOR;
-   case PIPE_BLENDFACTOR_CONST_ALPHA:
-   return V_028780_BLEND_CONSTANT_ALPHA;
-   case PIPE_BLENDFACTOR_ZERO:
-   return V_028780_BLEND_ZERO;
-   case PIPE_BLENDFACTOR_INV_SRC_COLOR:
-   return V_028780_BLEND_ONE_MINUS_SRC_COLOR;
-   case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
-   return V_028780_BLEND_ONE_MINUS_SRC_ALPHA;
-   case PIPE_BLENDFACTOR_INV_DST_ALPHA:
-   return V_028780_BLEND_ONE_MINUS_DST_ALPHA;
-   case PIPE_BLENDFACTOR_INV_DST_COLOR:
-   return V_028780_BLEND_ONE_MINUS_DST_COLOR;
-   case PIPE_BLENDFACTOR_INV_CONST_COLOR:
-   return V_028780_BLEND_ONE_MINUS_CONSTANT_COLOR;
-   case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
-   return V_028780_BLEND_ONE_MINUS_CONSTANT_ALPHA;
-   case PIPE_BLENDFACTOR_SRC1_COLOR:
-   return V_028780_BLEND_SRC1_COLOR;
-   case PIPE_BLENDFACTOR_SRC1_ALPHA:
-   return V_028780_BLEND_SRC1_ALPHA;
-   ca

[Mesa-dev] [PATCH 01/23] radeonsi: rework state handling

2012-07-20 Thread Christian König
Add a complete new state handling for SI.

Signed-off-by: Christian König 
---
 src/gallium/drivers/radeonsi/Makefile.sources|4 +-
 src/gallium/drivers/radeonsi/r600_hw_context.c   |2 +
 src/gallium/drivers/radeonsi/r600_state_common.c |3 +
 src/gallium/drivers/radeonsi/radeonsi_pipe.h |6 +
 src/gallium/drivers/radeonsi/radeonsi_pm4.c  |  175 ++
 src/gallium/drivers/radeonsi/radeonsi_pm4.h  |   76 ++
 src/gallium/drivers/radeonsi/si_state.c  |   28 
 src/gallium/drivers/radeonsi/si_state.h  |   65 
 8 files changed, 358 insertions(+), 1 deletion(-)
 create mode 100644 src/gallium/drivers/radeonsi/radeonsi_pm4.c
 create mode 100644 src/gallium/drivers/radeonsi/radeonsi_pm4.h
 create mode 100644 src/gallium/drivers/radeonsi/si_state.c
 create mode 100644 src/gallium/drivers/radeonsi/si_state.h

diff --git a/src/gallium/drivers/radeonsi/Makefile.sources 
b/src/gallium/drivers/radeonsi/Makefile.sources
index 394cfe9..8aeea8d 100644
--- a/src/gallium/drivers/radeonsi/Makefile.sources
+++ b/src/gallium/drivers/radeonsi/Makefile.sources
@@ -10,4 +10,6 @@ C_SOURCES := \
evergreen_hw_context.c \
evergreen_state.c \
r600_translate.c \
-   r600_state_common.c
+   r600_state_common.c \
+   radeonsi_pm4.c \
+   si_state.c
diff --git a/src/gallium/drivers/radeonsi/r600_hw_context.c 
b/src/gallium/drivers/radeonsi/r600_hw_context.c
index 9422adc..858bd16 100644
--- a/src/gallium/drivers/radeonsi/r600_hw_context.c
+++ b/src/gallium/drivers/radeonsi/r600_hw_context.c
@@ -24,6 +24,7 @@
  *  Jerome Glisse
  */
 #include "r600_hw_context_priv.h"
+#include "radeonsi_pm4.h"
 #include "radeonsi_pipe.h"
 #include "sid.h"
 #include "util/u_memory.h"
@@ -563,6 +564,7 @@ void r600_context_flush(struct r600_context *ctx, unsigned 
flags)
ctx->pm4_dirty_cdwords += enable_block->pm4_ndwords;
enable_block->nreg_dirty = enable_block->nreg;
}
+   si_pm4_reset_emitted(ctx);
 }
 
 void r600_context_emit_fence(struct r600_context *ctx, struct r600_resource 
*fence_bo, unsigned offset, unsigned value)
diff --git a/src/gallium/drivers/radeonsi/r600_state_common.c 
b/src/gallium/drivers/radeonsi/r600_state_common.c
index b63027e..18ba7a8 100644
--- a/src/gallium/drivers/radeonsi/r600_state_common.c
+++ b/src/gallium/drivers/radeonsi/r600_state_common.c
@@ -801,6 +801,8 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *dinfo)
rdraw.db_render_control = dsa->db_render_control;
 
/* Emit states. */
+   rctx->pm4_dirty_cdwords += si_pm4_dirty_dw(rctx);
+
r600_need_cs_space(rctx, 0, TRUE);
 
LIST_FOR_EACH_ENTRY_SAFE(state, next_state, &rctx->dirty_states, head) {
@@ -809,6 +811,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *dinfo)
LIST_FOR_EACH_ENTRY_SAFE(dirty_block, next_block, &rctx->dirty,list) {
r600_context_block_emit_dirty(rctx, dirty_block);
}
+   si_pm4_emit_dirty(rctx);
rctx->pm4_dirty_cdwords = 0;
 
/* Enable stream out if needed. */
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h 
b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index 6ba1017..43037e9 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -36,6 +36,8 @@
 #include "util/u_slab.h"
 #include "r600.h"
 #include "radeonsi_public.h"
+#include "radeonsi_pm4.h"
+#include "si_state.h"
 #include "r600_resource.h"
 #include "sid.h"
 
@@ -320,6 +322,10 @@ struct r600_context {
struct pipe_index_buffer index_buffer;
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
unsignednr_vertex_buffers;
+
+   /* SI state handling */
+   union si_state  qued;
+   union si_state  emitted;
 };
 
 static INLINE void r600_emit_atom(struct r600_context *rctx, struct r600_atom 
*atom)
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pm4.c 
b/src/gallium/drivers/radeonsi/radeonsi_pm4.c
new file mode 100644
index 000..ad1a8cf
--- /dev/null
+++ b/src/gallium/drivers/radeonsi/radeonsi_pm4.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2012 Advanced Micro Devices, Inc.
+ *
+ * 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
+ * on 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, EX

[Mesa-dev] radeonsi: New state handling

2012-07-20 Thread Christian König
Hi everyone,

this is going to be a big patchset. Since on SI+ some of the
rendering state especially the texture and vertex setup isn't
inside registers any more we are going to need a new state
handling for radeonsi.

So the following patchset is a complete rewrite of it. It
makes a couple of assumptions which as far as I know is true
for SI and all the following generations, like having VM support,
having a constant engine, etc...

>From what I can tell it doesn't really change the functionality
that is currently there, but at least glxgears is starting to
show something.

So please take a look and tell me what you think about it,
Christian.

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


[Mesa-dev] [PATCH 3/3] glx: drop unused 'dim' argument from __glEmptyImage

2012-07-20 Thread Julien Cristau
From: Julien Cristau 

Suggested-by: Ian Romanick 
Signed-off-by: Julien Cristau 
---
 src/glx/apple/glxreply.c |2 +-
 src/glx/glxclient.h  |2 +-
 src/glx/pixel.c  |2 +-
 src/glx/singlepix.c  |8 
 src/mapi/glapi/gen/glX_proto_send.py |4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/glx/apple/glxreply.c b/src/glx/apple/glxreply.c
index 6234e3c..db0817b 100644
--- a/src/glx/apple/glxreply.c
+++ b/src/glx/apple/glxreply.c
@@ -88,7 +88,7 @@ __glXReadPixelReply(Display * dpy, struct glx_context * gc, 
unsigned max_dim,
   else {
  _XRead(dpy, buf, size);
 
- __glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest);
+ __glEmptyImage(gc, width, height, depth, format, type, buf, dest);
  Xfree(buf);
   }
}
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index f8ae450..6d7fc8d 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -718,7 +718,7 @@ extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
 ** Empty an image out of the reply buffer into the clients memory applying
 ** the pack modes to pack back into the clients requested format.
 */
-extern void __glEmptyImage(struct glx_context *, GLint, GLint, GLint, GLint, 
GLenum,
+extern void __glEmptyImage(struct glx_context *, GLint, GLint, GLint, GLenum,
GLenum, const GLubyte *, GLvoid *);
 
 
diff --git a/src/glx/pixel.c b/src/glx/pixel.c
index d508d62..15a5ed5 100644
--- a/src/glx/pixel.c
+++ b/src/glx/pixel.c
@@ -388,7 +388,7 @@ EmptyBitmap(struct glx_context * gc, GLint width, GLint 
height,
 */
 /* ARGSUSED */
 void
-__glEmptyImage(struct glx_context * gc, GLint dim, GLint width, GLint height,
+__glEmptyImage(struct glx_context * gc, GLint width, GLint height,
GLint depth, GLenum format, GLenum type,
const GLubyte * sourceImage, GLvoid * userdata)
 {
diff --git a/src/glx/singlepix.c b/src/glx/singlepix.c
index d8a7166..4c85cf0 100644
--- a/src/glx/singlepix.c
+++ b/src/glx/singlepix.c
@@ -80,7 +80,7 @@ __indirect_glGetSeparableFilter(GLenum target, GLenum format, 
GLenum type,
   }
   else {
  __GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize);
- __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
+ __glEmptyImage(gc, width, 1, 1, format, type, rowBuf, row);
  Xfree((char *) rowBuf);
   }
   colBuf = (GLubyte *) Xmalloc(heightsize);
@@ -94,7 +94,7 @@ __indirect_glGetSeparableFilter(GLenum target, GLenum format, 
GLenum type,
   }
   else {
  __GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize);
- __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
+ __glEmptyImage(gc, height, 1, 1, format, type, colBuf, column);
  Xfree((char *) colBuf);
   }
}
@@ -174,7 +174,7 @@ void gl_dispatch_stub_GetSeparableFilterEXT (GLenum target, 
GLenum format,
   _XEatData(dpy, extra);
}
 
-   __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, row);
+   __glEmptyImage(gc, width, 1, 1, format, type, buf, row);
 
extra = 4 - (heightsize & 3);
_XRead(dpy, (char *) buf, heightsize);
@@ -182,7 +182,7 @@ void gl_dispatch_stub_GetSeparableFilterEXT (GLenum target, 
GLenum format,
   _XEatData(dpy, extra);
}
 
-   __glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column);
+   __glEmptyImage(gc, height, 1, 1, format, type, buf, column);
 
Xfree((char *) buf);
 }
diff --git a/src/mapi/glapi/gen/glX_proto_send.py 
b/src/mapi/glapi/gen/glX_proto_send.py
index 029f8d9..acf603a 100644
--- a/src/mapi/glapi/gen/glX_proto_send.py
+++ b/src/mapi/glapi/gen/glX_proto_send.py
@@ -248,7 +248,7 @@ __glXReadPixelReply( Display *dpy, struct glx_context * gc, 
unsigned max_dim,
 else {
 _XRead(dpy, buf, size);
 
-__glEmptyImage(gc, 3, width, height, depth, format, type,
+__glEmptyImage(gc, width, height, depth, format, type,
buf, dest);
 Xfree(buf);
 }
@@ -689,7 +689,7 @@ generic_%u_byte( GLint rop, const void * ptr )
else:
print '
if (%s == 0) { %s = 1; }' % (d, d)
 
-   print '
__glEmptyImage(gc, 3, %s, %s, %s, %s, %s, %s_data(reply), %s);' % (w, h, d, 
output.img_format, output.img_type, xcb_name, output.name)
+   print '
__glEmptyImage(gc, %s, %s, %s, %s, %s, %s_data(reply), %s);' % (w, h, d, 
output.img_format, output.img_type, xcb_name, output.name)
else:
  

[Mesa-dev] [PATCH v2 2/3] glapi/glx: call __glEmptyImage if USE_XCB, not memcpy directly

2012-07-20 Thread Julien Cristau
From: Julien Cristau 

We were stomping on the caller's buffer by ignoring their alignment
requests and other pixel store modes.  This patch makes the USE_XCB path match
the older one more closely.

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

Signed-off-by: Julien Cristau 
---
v2: add explicit bugzilla reference to commit message, drop unused
assignment

 src/mapi/glapi/gen/glX_proto_send.py |   35 -
 1 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/mapi/glapi/gen/glX_proto_send.py 
b/src/mapi/glapi/gen/glX_proto_send.py
index 9068a61..029f8d9 100644
--- a/src/mapi/glapi/gen/glX_proto_send.py
+++ b/src/mapi/glapi/gen/glX_proto_send.py
@@ -673,16 +673,31 @@ generic_%u_byte( GLint rop, const void * ptr )
 
if f.needs_reply():
print '%s_reply_t *reply = %s_reply(c, 
%s, NULL);' % (xcb_name, xcb_name, xcb_request)
-   if output and f.reply_always_array:
-   print '(void)memcpy(%s, 
%s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, 
xcb_name, output.get_base_type_string())
-
-   elif output and not f.reply_always_array:
-   if not output.is_image():
-   print 'if 
(%s_data_length(reply) == 0)' % (xcb_name)
-   print '
(void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)
-   print 'else'
-   print '(void)memcpy(%s, 
%s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, 
xcb_name, output.get_base_type_string())
-
+   if output:
+   if output.is_image():
+   [dim, w, h, d, junk] = 
output.get_dimensions()
+   if f.dimensions_in_reply:
+   w = "reply->width"
+   h = "reply->height"
+   d = "reply->depth"
+   if dim < 2:
+   h = "1"
+   else:
+   print '
if (%s == 0) { %s = 1; }' % (h, h)
+   if dim < 3:
+   d = "1"
+   else:
+   print '
if (%s == 0) { %s = 1; }' % (d, d)
+
+   print '
__glEmptyImage(gc, 3, %s, %s, %s, %s, %s, %s_data(reply), %s);' % (w, h, d, 
output.img_format, output.img_type, xcb_name, output.name)
+   else:
+   if f.reply_always_array:
+   print '
(void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % 
(output.name, xcb_name, xcb_name, output.get_base_type_string())
+   else:
+   print 'if 
(%s_data_length(reply) == 0)' % (xcb_name)
+   print '
(void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)
+   print 'else'
+   print '
(void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % 
(output.name, xcb_name, xcb_name, output.get_base_type_string())
 
if f.return_type != 'void':
print 'retval = reply->ret_val;'
-- 
1.7.2.5

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


[Mesa-dev] [PATCH v2 1/3] glx: Simplify __glXReadPixelReply

2012-07-20 Thread Julien Cristau
From: Julien Cristau 

Doing
size = reply.length * 4;
[...]
extra = 4 - (size & 3);

is useless, size & 3 will always be 0.

Signed-off-by: Julien Cristau 
---
v2: also change the copy in src/glx/apple

 src/glx/apple/glxreply.c |5 -
 src/mapi/glapi/gen/glX_proto_send.py |5 -
 2 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/src/glx/apple/glxreply.c b/src/glx/apple/glxreply.c
index f17ebe6..6234e3c 100644
--- a/src/glx/apple/glxreply.c
+++ b/src/glx/apple/glxreply.c
@@ -86,12 +86,7 @@ __glXReadPixelReply(Display * dpy, struct glx_context * gc, 
unsigned max_dim,
  __glXSetError(gc, GL_OUT_OF_MEMORY);
   }
   else {
- const GLint extra = 4 - (size & 3);
-
  _XRead(dpy, buf, size);
- if (extra < 4) {
-_XEatData(dpy, extra);
- }
 
  __glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest);
  Xfree(buf);
diff --git a/src/mapi/glapi/gen/glX_proto_send.py 
b/src/mapi/glapi/gen/glX_proto_send.py
index bec0222..9068a61 100644
--- a/src/mapi/glapi/gen/glX_proto_send.py
+++ b/src/mapi/glapi/gen/glX_proto_send.py
@@ -246,12 +246,7 @@ __glXReadPixelReply( Display *dpy, struct glx_context * 
gc, unsigned max_dim,
 __glXSetError(gc, GL_OUT_OF_MEMORY);
 }
 else {
-const GLint extra = 4 - (size & 3);
-
 _XRead(dpy, buf, size);
-if ( extra < 4 ) {
-_XEatData(dpy, extra);
-}
 
 __glEmptyImage(gc, 3, width, height, depth, format, type,
buf, dest);
-- 
1.7.2.5

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


Re: [Mesa-dev] Mesa (master): gallium-egl: Implement eglQueryWaylandBufferWL

2012-07-20 Thread Jose Fonseca


- Original Message -
> On Thu, Jul 19, 2012 at 3:26 PM, Kristian Høgsberg
>  wrote:
> > On Thu, Jul 19, 2012 at 2:44 PM, Jose Fonseca 
> > wrote:
> >>
> >>
> >> - Original Message -
> >>> This commit is causing build failures in several platforms
> >>> because
> >>> EGL_WL_bind_wayland_display is defined everywhere (including
> >>> windows), and not just on platforms where wayland-drm.h exists.
> >
> > Yes, I see the problem, I'm fixing it now. I'm using the
> > wayland_bufmgr that is already in place now, so it should work as
> > well
> > as before.
> >
> > Kristian
> 
> Should be fixed in mesa master now.

Yep. Thanks Kristian.

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


[Mesa-dev] [Bug 52282] [softpipe] piglit arb_shader_texture_lod-texgrad regression

2012-07-20 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=52282

--- Comment #1 from Olivier Galibert  2012-07-20 07:15:45 
UTC ---
galibert@tata:~/X/piglit #16 >./bin/arb_shader_texture_lod-texgrad -auto
Left: texture2D, Right: texture2DGradARB
PIGLIT: {'result': 'pass' }

I'm not getting that, and I'm obviously not getting the moire effect either. 
I'll try to reproduce on other systems.

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