Mesa (7.11): nv50, nvc0: use screen instead of context for flush notifier

2011-12-11 Thread Marcin Ślusarz
Module: Mesa
Branch: 7.11
Commit: 0e9b79c22a53efb8413ba6b4e49085a08221a5d3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e9b79c22a53efb8413ba6b4e49085a08221a5d3

Author: Christoph Bumiller e0425...@student.tuwien.ac.at
Date:   Thu Jul  7 14:58:29 2011 +0200

nv50,nvc0: use screen instead of context for flush notifier

Context may become NULL and we still have to be able to flush
pending fences.

(Cherry picked from commit 3069a7eaa5d83e7f41616347ba244c0dc0d944ae)
Fixes crash on screen shutdown: 
https://bugs.freedesktop.org/show_bug.cgi?id=43428

---

 src/gallium/drivers/nv50/nv50_context.c|   13 +
 src/gallium/drivers/nv50/nv50_screen.c |2 ++
 src/gallium/drivers/nv50/nv50_state_validate.c |3 +--
 src/gallium/drivers/nv50/nv50_vbo.c|7 +++
 src/gallium/drivers/nvc0/nvc0_context.c|   13 +
 src/gallium/drivers/nvc0/nvc0_screen.c |8 ++--
 src/gallium/drivers/nvc0/nvc0_state_validate.c |3 +--
 src/gallium/drivers/nvc0/nvc0_vbo.c|7 +++
 8 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_context.c 
b/src/gallium/drivers/nv50/nv50_context.c
index ceb83f6..ac3e361 100644
--- a/src/gallium/drivers/nv50/nv50_context.c
+++ b/src/gallium/drivers/nv50/nv50_context.c
@@ -60,13 +60,13 @@ nv50_texture_barrier(struct pipe_context *pipe)
 void
 nv50_default_flush_notify(struct nouveau_channel *chan)
 {
-   struct nv50_context *nv50 = chan-user_private;
+   struct nv50_screen *screen = chan-user_private;
 
-   if (!nv50)
+   if (!screen)
   return;
 
-   nouveau_fence_update(nv50-screen-base, TRUE);
-   nouveau_fence_next(nv50-screen-base);
+   nouveau_fence_update(screen-base, TRUE);
+   nouveau_fence_next(screen-base);
 }
 
 static void
@@ -100,10 +100,8 @@ nv50_destroy(struct pipe_context *pipe)
 
draw_destroy(nv50-draw);
 
-   if (nv50-screen-cur_ctx == nv50) {
-  nv50-screen-base.channel-user_private = NULL;
+   if (nv50-screen-cur_ctx == nv50)
   nv50-screen-cur_ctx = NULL;
-   }
 
FREE(nv50);
 }
@@ -140,7 +138,6 @@ nv50_create(struct pipe_screen *pscreen, void *priv)
 
if (!screen-cur_ctx)
   screen-cur_ctx = nv50;
-   screen-base.channel-user_private = nv50;
screen-base.channel-flush_notify = nv50_default_flush_notify;
 
nv50_init_query_functions(nv50);
diff --git a/src/gallium/drivers/nv50/nv50_screen.c 
b/src/gallium/drivers/nv50/nv50_screen.c
index 9606c99..4fcf529 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -215,6 +215,7 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
   nouveau_fence_wait(screen-base.fence.current);
   nouveau_fence_ref (NULL, screen-base.fence.current);
}
+   screen-base.channel-user_private = NULL;
 
nouveau_bo_ref(NULL, screen-code);
nouveau_bo_ref(NULL, screen-tls_bo);
@@ -304,6 +305,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct 
nouveau_device *dev)
   FAIL_SCREEN_INIT(nouveau_screen_init failed: %d\n, ret);
 
chan = screen-base.channel;
+   chan-user_private = screen;
 
pscreen-winsys = ws;
pscreen-destroy = nv50_screen_destroy;
diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c 
b/src/gallium/drivers/nv50/nv50_state_validate.c
index 11561f5..d29c1e9 100644
--- a/src/gallium/drivers/nv50/nv50_state_validate.c
+++ b/src/gallium/drivers/nv50/nv50_state_validate.c
@@ -282,8 +282,7 @@ nv50_switch_pipe_context(struct nv50_context *ctx_to)
if (!ctx_to-zsa)
   ctx_to-dirty = ~NV50_NEW_ZSA;
 
-   ctx_to-screen-base.channel-user_private = ctx_to-screen-cur_ctx =
-  ctx_to;
+   ctx_to-screen-cur_ctx = ctx_to;
 }
 
 static struct state_validate {
diff --git a/src/gallium/drivers/nv50/nv50_vbo.c 
b/src/gallium/drivers/nv50/nv50_vbo.c
index bb08941..f23008a 100644
--- a/src/gallium/drivers/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nv50/nv50_vbo.c
@@ -389,11 +389,11 @@ nv50_prim_gl(unsigned prim)
 static void
 nv50_draw_vbo_flush_notify(struct nouveau_channel *chan)
 {
-   struct nv50_context *nv50 = chan-user_private;
+   struct nv50_screen *screen = chan-user_private;
 
-   nouveau_fence_update(nv50-screen-base, TRUE);
+   nouveau_fence_update(screen-base, TRUE);
 
-   nv50_bufctx_emit_relocs(nv50);
+   nv50_bufctx_emit_relocs(screen-cur_ctx);
 }
 
 static void
@@ -650,7 +650,6 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
nv50_state_validate(nv50);
 
chan-flush_notify = nv50_draw_vbo_flush_notify;
-   chan-user_private = nv50;
 
if (nv50-vbo_fifo) {
   nv50_push_vbo(nv50, info);
diff --git a/src/gallium/drivers/nvc0/nvc0_context.c 
b/src/gallium/drivers/nvc0/nvc0_context.c
index 2679b7f..983db23 100644
--- a/src/gallium/drivers/nvc0/nvc0_context.c
+++ b/src/gallium/drivers/nvc0/nvc0_context.c
@@ -89,10 +89,8 @@ nvc0_destroy(struct pipe_context *pipe)
 
draw_destroy(nvc0-draw);
 
-   if (nvc0-screen-cur_ctx == nvc0) {

Mesa (7.11): nv50/nvc0: fix crash when channel allocation fails

2011-12-11 Thread Marcin Ślusarz
Module: Mesa
Branch: 7.11
Commit: 237d6fa97a3c94b1ffb9d0ce230b8c7b95fccae4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=237d6fa97a3c94b1ffb9d0ce230b8c7b95fccae4

Author: Marcin Slusarz marcin.slus...@gmail.com
Date:   Fri Nov 11 20:45:08 2011 +0100

nv50/nvc0: fix crash when channel allocation fails

---

 src/gallium/drivers/nv50/nv50_screen.c |3 ++-
 src/gallium/drivers/nvc0/nvc0_screen.c |3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_screen.c 
b/src/gallium/drivers/nv50/nv50_screen.c
index 4fcf529..f176a86 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -215,7 +215,8 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
   nouveau_fence_wait(screen-base.fence.current);
   nouveau_fence_ref (NULL, screen-base.fence.current);
}
-   screen-base.channel-user_private = NULL;
+   if (screen-base.channel)
+  screen-base.channel-user_private = NULL;
 
nouveau_bo_ref(NULL, screen-code);
nouveau_bo_ref(NULL, screen-tls_bo);
diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nvc0/nvc0_screen.c
index 0946fd7..43eb6ce 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nvc0/nvc0_screen.c
@@ -202,7 +202,8 @@ nvc0_screen_destroy(struct pipe_screen *pscreen)
   nouveau_fence_wait(screen-base.fence.current);
   nouveau_fence_ref(NULL, screen-base.fence.current);
}
-   screen-base.channel-user_private = NULL;
+   if (screen-base.channel)
+  screen-base.channel-user_private = NULL;
 
nouveau_bo_ref(NULL, screen-text);
nouveau_bo_ref(NULL, screen-tls);

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


Mesa (master): i915g: Fix wrong indices for LINE_LOOP case

2011-12-11 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 13632e64a0da67149d81bef2da42f159f8ddb1ea
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=13632e64a0da67149d81bef2da42f159f8ddb1ea

Author: Fatih Aşıcı fatih.as...@gmail.com
Date:   Sun Dec 11 13:21:53 2011 -0800

i915g: Fix wrong indices for LINE_LOOP case

---

 src/gallium/drivers/i915/i915_prim_vbuf.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_prim_vbuf.c 
b/src/gallium/drivers/i915/i915_prim_vbuf.c
index 79db3b6..3f85466 100644
--- a/src/gallium/drivers/i915/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915/i915_prim_vbuf.c
@@ -400,8 +400,8 @@ draw_arrays_generate_indices(struct vbuf_render *render,
case PIPE_PRIM_LINE_LOOP:
   if (nr = 2) {
  for (i = start + 1; i  end; i++)
-OUT_BATCH((i-0) | (i+0)  16);
- OUT_BATCH((i-0) | ( start)  16);
+OUT_BATCH((i-1) | (i+0)  16);
+ OUT_BATCH((i-1) | ( start)  16);
   }
   break;
case PIPE_PRIM_QUADS:

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


Mesa (master): i915g: fix debug dump on 64 bit systems

2011-12-11 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 592323de1ea5b9e5eab8b66690c8aecc6901c5de
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=592323de1ea5b9e5eab8b66690c8aecc6901c5de

Author: Michael Karcher freedesktop-bugzi...@mkarcher.dialup.fu-berlin.de
Date:   Sun Dec 11 13:24:10 2011 -0800

i915g: fix debug dump on 64 bit systems

---

 src/gallium/drivers/i915/i915_debug.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_debug.c 
b/src/gallium/drivers/i915/i915_debug.c
index 295c47e..b6c442d 100644
--- a/src/gallium/drivers/i915/i915_debug.c
+++ b/src/gallium/drivers/i915/i915_debug.c
@@ -232,7 +232,7 @@ BITS(
 ... )
 {
va_list  args;
-   unsigned himask = ~0UL  (31 - (hi));
+   unsigned himask = 0xUL  (31 - (hi));
 
PRINTF(stream, \t\t );
 

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


Mesa (master): st/mesa: add color varyings to MaxVarying

2011-12-11 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: 1ded658ce074a85bc08c989ff17840b840ff3051
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ded658ce074a85bc08c989ff17840b840ff3051

Author: Marek Olšák mar...@gmail.com
Date:   Tue Nov 22 15:05:29 2011 +0100

st/mesa: add color varyings to MaxVarying

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

NOTE: This is a candidate for the 7.11 branch.

---

 src/mesa/state_tracker/st_extensions.c |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 37fb3e7..9e39729 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -210,12 +210,10 @@ void st_init_limits(struct st_context *st)
  options-MaxUnrollIterations = MIN2(screen-get_shader_param(screen, 
sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
}
 
-   /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs
-* and is set in MaxNativeAttribs. It's always 2 colors + N generic
-* attributes. The GLSL compiler never uses COLORn for varyings, so we
-* subtract the 2 colors to get the maximum number of varyings (generic
-* attributes) supported by a driver. */
-   c-MaxVarying = screen-get_shader_param(screen, PIPE_SHADER_FRAGMENT, 
PIPE_SHADER_CAP_MAX_INPUTS) - 2;
+   /* PIPE_SHADER_CAP_MAX_INPUTS for the FS specifies the maximum number
+* of inputs. It's always 2 colors + N generic inputs. */
+   c-MaxVarying = screen-get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+PIPE_SHADER_CAP_MAX_INPUTS);
c-MaxVarying = MIN2(c-MaxVarying, MAX_VARYING);
 
c-MinProgramTexelOffset = screen-get_param(screen, 
PIPE_CAP_MIN_TEXEL_OFFSET);

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


Mesa (master): r300g: integer and fixed-point 16. 16 textures are not supported

2011-12-11 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: 4298c88f656c191f3daca0c341850dd8c23f5f92
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4298c88f656c191f3daca0c341850dd8c23f5f92

Author: Marek Olšák mar...@gmail.com
Date:   Sun Dec 11 13:25:56 2011 +0100

r300g: integer and fixed-point 16.16 textures are not supported

---

 src/gallium/drivers/r300/r300_texture.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_texture.c 
b/src/gallium/drivers/r300/r300_texture.c
index fa09410..2738f58 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -236,6 +236,17 @@ uint32_t r300_translate_texformat(enum pipe_format format,
 return R300_TX_FORMAT_CxV8U8 | result;
 }
 
+/* Integer and fixed-point 16.16 textures are not supported. */
+for (i = 0; i  4; i++) {
+if (desc-channel[i].type == UTIL_FORMAT_TYPE_FIXED ||
+((desc-channel[i].type == UTIL_FORMAT_TYPE_SIGNED ||
+  desc-channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) 
+ (!desc-channel[i].normalized ||
+  desc-channel[i].pure_integer))) {
+return ~0; /* Unsupported/unknown. */
+}
+}
+
 /* Add sign. */
 for (i = 0; i  desc-nr_channels; i++) {
 if (desc-channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {

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


Mesa (master): mesa: fix possible precision issues in pack/unpack/ fetch functions

2011-12-11 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: fc52534f012837a39c03a764eb611d460210514a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc52534f012837a39c03a764eb611d460210514a

Author: Marek Olšák mar...@gmail.com
Date:   Sun Dec 11 16:18:36 2011 +0100

mesa: fix possible precision issues in pack/unpack/fetch functions

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

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

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

Reviewed-by: Brian Paul bri...@vmware.com

---

 src/mesa/main/format_pack.c  |   20 ++--
 src/mesa/main/format_unpack.c|8 
 src/mesa/swrast/s_texfetch_tmp.h |4 ++--
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
index ba23bab..390b494 100644
--- a/src/mesa/main/format_pack.c
+++ b/src/mesa/main/format_pack.c
@@ -2058,7 +2058,7 @@ pack_float_z_Z24_S8(const GLfloat *src, void *dst)
 {
/* don't disturb the stencil values */
GLuint *d = ((GLuint *) dst);
-   const GLfloat scale = (GLfloat) 0xff;
+   const GLdouble scale = (GLdouble) 0xff;
GLuint s = *d  0xff;
GLuint z = (GLuint) (*src * scale);
assert(z = 0xff);
@@ -2070,7 +2070,7 @@ pack_float_z_S8_Z24(const GLfloat *src, void *dst)
 {
/* don't disturb the stencil values */
GLuint *d = ((GLuint *) dst);
-   const GLfloat scale = (GLfloat) 0xff;
+   const GLdouble scale = (GLdouble) 0xff;
GLuint s = *d  0xff00;
GLuint z = (GLuint) (*src * scale);
assert(z = 0xff);
@@ -2089,7 +2089,7 @@ static void
 pack_float_z_Z32(const GLfloat *src, void *dst)
 {
GLuint *d = ((GLuint *) dst);
-   const GLfloat scale = (GLfloat) 0x;
+   const GLdouble scale = (GLdouble) 0x;
*d = (GLuint) (*src * scale);
 }
 
@@ -2169,7 +2169,7 @@ static void
 pack_uint_z_Z32_FLOAT(const GLuint *src, void *dst)
 {
GLuint *d = ((GLuint *) dst);
-   const GLfloat scale = 1.0f / (GLfloat) 0x;
+   const GLdouble scale = 1.0 / (GLdouble) 0x;
*d = *src * scale;
assert(*d = 0.0f);
assert(*d = 1.0f);
@@ -2179,7 +2179,7 @@ static void
 pack_uint_z_Z32_FLOAT_X24S8(const GLuint *src, void *dst)
 {
GLfloat *d = ((GLfloat *) dst);
-   const GLfloat scale = 1.0f / (GLfloat) 0x;
+   const GLdouble scale = 1.0 / (GLdouble) 0x;
*d = *src * scale;
assert(*d = 0.0f);
assert(*d = 1.0f);
@@ -2280,7 +2280,7 @@ _mesa_pack_float_z_row(gl_format format, GLuint n,
   {
  /* don't disturb the stencil values */
  GLuint *d = ((GLuint *) dst);
- const GLfloat scale = (GLfloat) 0xff;
+ const GLdouble scale = (GLdouble) 0xff;
  GLuint i;
  for (i = 0; i  n; i++) {
 GLuint s = d[i]  0xff;
@@ -2295,7 +2295,7 @@ _mesa_pack_float_z_row(gl_format format, GLuint n,
   {
  /* don't disturb the stencil values */
  GLuint *d = ((GLuint *) dst);
- const GLfloat scale = (GLfloat) 0xff;
+ const GLdouble scale = (GLdouble) 0xff;
  GLuint i;
  for (i = 0; i  n; i++) {
 GLuint s = d[i]  0xff00;
@@ -2318,7 +2318,7 @@ _mesa_pack_float_z_row(gl_format format, GLuint n,
case MESA_FORMAT_Z32:
   {
  GLuint *d = ((GLuint *) dst);
- const GLfloat scale = (GLfloat) 0x;
+ const GLdouble scale = (GLdouble) 0x;
  GLuint i;
  for (i = 0; i  n; i++) {
 d[i] = (GLuint) (src[i] * scale);
@@ -2392,7 +2392,7 @@ _mesa_pack_uint_z_row(gl_format format, GLuint n,
case MESA_FORMAT_Z32_FLOAT:
   {
  GLuint *d = ((GLuint *) dst);
- const GLfloat scale = 1.0f / (GLfloat) 0x;
+ const GLdouble scale = 1.0 / (GLdouble) 0x;
  GLuint i;
  for (i = 0; i  n; i++) {
 d[i] = src[i] * scale;
@@ -2404,7 +2404,7 @@ _mesa_pack_uint_z_row(gl_format format, GLuint n,
case MESA_FORMAT_Z32_FLOAT_X24S8:
   {
  GLfloat *d = ((GLfloat *) dst);
- const GLfloat scale = 1.0f / (GLfloat) 0x;
+ const GLdouble scale = 1.0 / (GLdouble) 0x;
  GLuint i;
  for (i = 0; i  n; i++) {
 d[i * 2] = src[i] * scale;
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index f821c2b..4f23f3d 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -587,7 +587,7 @@ unpack_Z24_S8(const void *src, GLfloat dst[][4], GLuint n)
 {
/* only return Z, not stencil data */
const GLuint *s = ((const GLuint *) src);
-   const GLfloat scale = 1.0F / (GLfloat) 0xff;
+   const GLdouble