Demos (master): cmake: Build more egl/opengl samples .

2011-11-09 Thread Jose Fonseca
Module: Demos
Branch: master
Commit: 73d91dce17aa42dc1126aa28cef300ed40bad38e
URL:
http://cgit.freedesktop.org/mesa/demos/commit/?id=73d91dce17aa42dc1126aa28cef300ed40bad38e

Author: José Fonseca 
Date:   Thu Nov 10 06:57:02 2011 +

cmake: Build more egl/opengl samples .

---

 src/egl/opengl/CMakeLists.txt |   57 +
 1 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/src/egl/opengl/CMakeLists.txt b/src/egl/opengl/CMakeLists.txt
index 8883bbb..854f64a 100644
--- a/src/egl/opengl/CMakeLists.txt
+++ b/src/egl/opengl/CMakeLists.txt
@@ -1,20 +1,55 @@
-include_directories(${EGL_INCLUDE_DIR}
-  ../eglut
-  ../../util
-  )
+include_directories(
+   ${CMAKE_SOURCE_DIR}/src/egl/eglut
+   ${CMAKE_SOURCE_DIR}/src/util
+   ${EGL_INCLUDE_DIR}
+   ${OPENGL_INCLUDE_PATH}
+)
 
 link_libraries (
${EGL_egl_LIBRARY}
${OPENGL_gl_LIBRARY}
 )
 
-add_executable(eglinfo eglinfo.c)
+set (subdir egl)
+
+set (targets
+   demo1
+   demo2
+   demo3
+)
+
+foreach (target ${targets})
+   add_executable (${subdir}_${target} ${target}.c)
+   set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME 
${target})
+   install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+endforeach (target)
+
+
+# Targets that can be built both for fullscreen EGL and X11
+
+set (targets
+   egltri
+   eglgears
+)
+
+foreach (target ${targets})
+   add_executable (${target}_screen ${target}.c)
+   target_link_libraries (${target}_screen eglut_screen)
+   install (TARGETS ${target}_screen DESTINATION ${subdir})
+
+   if (X11_FOUND)
+   add_executable (${target}_x11 ${target}.c)
+   target_link_libraries (${target}_x11 eglut_x11)
+   install (TARGETS ${target}_x11 DESTINATION ${subdir})
+   endif ()
+endforeach (target)
+
 
-add_executable(eglgears_screen eglgears.c)
-target_link_libraries(eglgears_screen eglut_screen)
+if (X11_FOUND)
+   add_executable (xeglgears xeglgears.c)
+   target_link_libraries (xeglgears ${X11_X11_LIB})
 
-if(X11_FOUND)
-   add_executable(eglgears_x11 eglgears.c)
-   target_link_libraries(eglgears_x11 eglut_x11)
-endif(X11_FOUND)
+   add_executable (xeglthreads xeglthreads.c)
+   target_link_libraries (xeglthreads ${X11_X11_LIB})
+endif (X11_FOUND)
 

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


Mesa (master): swrast: Add support for glReadPixels() to integer types.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 11a90af1ef6384b3ac7730d16db9a65b4a799466
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=11a90af1ef6384b3ac7730d16db9a65b4a799466

Author: Eric Anholt 
Date:   Thu Nov  3 17:27:23 2011 -0700

swrast: Add support for glReadPixels() to integer types.

With this change, i965 passes
GL_EXT_texture_integer/fbo_integer_precision_clear

Reviewed-by: Kenneth Graunke 

---

 src/mesa/swrast/s_readpix.c |   19 +--
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 50422db..54f42db 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -236,7 +236,10 @@ slow_read_rgba_pixels( struct gl_context *ctx,
   GLbitfield transferOps )
 {
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
-   GLfloat rgba[MAX_WIDTH][4];
+   union {
+  float f[MAX_WIDTH][4];
+  unsigned int i[MAX_WIDTH][4];
+   } rgba;
GLubyte *dst, *map;
int dstStride, stride, j;
 
@@ -248,11 +251,15 @@ slow_read_rgba_pixels( struct gl_context *ctx,
   &map, &stride);
 
for (j = 0; j < height; j++) {
-  _mesa_unpack_rgba_row(_mesa_get_srgb_format_linear(rb->Format),
-   width, map, rgba);
-  _mesa_pack_rgba_span_float(ctx, width, rgba, format, type, dst,
-packing, transferOps);
-
+  if (_mesa_is_integer_format(format)) {
+_mesa_unpack_int_rgba_row(rb->Format, width, map, rgba.i);
+_mesa_pack_rgba_span_int(ctx, width, rgba.i, format, type, dst);
+  } else {
+_mesa_unpack_rgba_row(_mesa_get_srgb_format_linear(rb->Format),
+  width, map, rgba.f);
+_mesa_pack_rgba_span_float(ctx, width, rgba.f, format, type, dst,
+   packing, transferOps);
+  }
   dst += dstStride;
   map += stride;
}

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


Mesa (master): mesa: Add support for unpacking 32-bit integer formats to int spans.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: e34c9edcda9167c634fe8381bd039f1a65925d0a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e34c9edcda9167c634fe8381bd039f1a65925d0a

Author: Eric Anholt 
Date:   Thu Nov  3 17:08:16 2011 -0700

mesa: Add support for unpacking 32-bit integer formats to int spans.

This is the inverse operation to _mesa_pack_rgba_span_int.  The 16-bit
code isn't done because of lack of testing and not being sure how sign
extension/clamping should be handled between, say, 16-bit int and
32-bit int or uint.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/main/format_unpack.c |  120 +
 src/mesa/main/format_unpack.h |8 +++
 2 files changed, 128 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index eaa33df..525bbcb 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1258,7 +1258,127 @@ _mesa_unpack_rgba_row(gl_format format, GLuint n,
}
 }
 
+static void
+unpack_int_rgba_RGBA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+   memcpy(dst, src, n * 4 * sizeof(GLuint));
+}
+
+static void
+unpack_int_rgba_RGB_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+  dst[i][0] = src[i * 3 + 0];
+  dst[i][1] = src[i * 3 + 1];
+  dst[i][2] = src[i * 3 + 2];
+  dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_RG_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+  dst[i][0] = src[i * 2 + 0];
+  dst[i][1] = src[i * 2 + 1];
+  dst[i][2] = 0;
+  dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_R_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+  dst[i][0] = src[i];
+  dst[i][1] = 0;
+  dst[i][2] = 0;
+  dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_LUMINANCE_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+  dst[i][0] = dst[i][1] = dst[i][2] = src[i];
+  dst[i][3] = 1;
+   }
+}
 
+static void
+unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], 
GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+  dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+  dst[i][3] = src[i * 2 + 1];
+   }
+}
+
+static void
+unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+  dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+   }
+}
+
+void
+_mesa_unpack_int_rgba_row(gl_format format, GLuint n,
+ const void *src, GLuint dst[][4])
+{
+   switch (format) {
+  /* Since there won't be any sign extension happening, there's no need to
+   * make separate paths for 32-bit-to-32-bit integer unpack.
+   */
+   case MESA_FORMAT_RGBA_UINT32:
+   case MESA_FORMAT_RGBA_INT32:
+  unpack_int_rgba_RGBA_UINT32(src, dst, n);
+  break;
+   case MESA_FORMAT_RGB_UINT32:
+   case MESA_FORMAT_RGB_INT32:
+  unpack_int_rgba_RGB_UINT32(src, dst, n);
+  break;
+   case MESA_FORMAT_RG_UINT32:
+   case MESA_FORMAT_RG_INT32:
+  unpack_int_rgba_RG_UINT32(src, dst, n);
+  break;
+   case MESA_FORMAT_R_UINT32:
+   case MESA_FORMAT_R_INT32:
+  unpack_int_rgba_R_UINT32(src, dst, n);
+  break;
+
+   case MESA_FORMAT_LUMINANCE_UINT32:
+   case MESA_FORMAT_LUMINANCE_INT32:
+  unpack_int_rgba_LUMINANCE_UINT32(src, dst, n);
+  break;
+   case MESA_FORMAT_LUMINANCE_ALPHA_UINT32:
+   case MESA_FORMAT_LUMINANCE_ALPHA_INT32:
+  unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src, dst, n);
+  break;
+   case MESA_FORMAT_INTENSITY_UINT32:
+   case MESA_FORMAT_INTENSITY_INT32:
+  unpack_int_rgba_INTENSITY_UINT32(src, dst, n);
+  break;
+
+   default:
+  _mesa_problem(NULL, "%s: bad format %s", __FUNCTION__,
+_mesa_get_format_name(format));
+  return;
+   }
+}
 
 /**
  * Unpack a 2D rect of pixels returning float RGBA colors.
diff --git a/src/mesa/main/format_unpack.h b/src/mesa/main/format_unpack.h
index a8a829c..0d13a2d 100644
--- a/src/mesa/main/format_unpack.h
+++ b/src/mesa/main/format_unpack.h
@@ -29,12 +29,20 @@ _mesa_unpack_rgba_row(gl_format format, GLuint n,
   const void *src, GLfloat dst[][4]);
 
 
+void
+_mesa_unpack_int_rgba_row(gl_format format, GLuint n,
+ const void *src, GLuint dst[][4]);
+
 extern void
 _mesa_unpack_rgba_block(gl_format format,
 const void *src, GLint srcRowStride,
 GLfloat dst[][4], GLint dstRowStride,
 GLuint x, GLuint y, GLuint width, GLuint height);
 
+extern void
+_mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
+  const void *src, GLuint dst[][4]);
+
 
 extern void
 _mesa_unpack_float_z

Mesa (master): meta: Add support for glClear() to integer color buffers.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 84277cb7d325cdeade8ce75eb4154adb744626dc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=84277cb7d325cdeade8ce75eb4154adb744626dc

Author: Eric Anholt 
Date:   Wed Nov  2 14:01:25 2011 -0700

meta: Add support for glClear() to integer color buffers.

This requires using a new fragment shader to get the integer color
output, and a new vertex shader because #version has to match between
the two.

v2: Clarify that there's no need for BindFragDataLocation.

Reviewed-by: Kenneth Graunke  (v1)

---

 src/mesa/drivers/common/meta.c |  113 ++--
 1 files changed, 109 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 3e55334..8d589e4 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -182,7 +182,6 @@ struct save_state
GLboolean Lighting;
 };
 
-
 /**
  * Temporary texture used for glBlitFramebuffer, glDrawPixels, etc.
  * This is currently shared by all the meta ops.  But we could create a
@@ -221,6 +220,9 @@ struct clear_state
GLuint VBO;
GLuint ShaderProg;
GLint ColorLocation;
+
+   GLuint IntegerShaderProg;
+   GLint IntegerColorLocation;
 };
 
 
@@ -310,6 +312,67 @@ struct gl_meta_state
struct drawtex_state DrawTex;  /**< For _mesa_meta_DrawTex() */
 };
 
+static GLuint
+compile_shader_with_debug(struct gl_context *ctx, GLenum target, const 
GLcharARB *source)
+{
+   GLuint shader;
+   GLint ok, size;
+   GLchar *info;
+
+   shader = _mesa_CreateShaderObjectARB(target);
+   _mesa_ShaderSourceARB(shader, 1, &source, NULL);
+   _mesa_CompileShaderARB(shader);
+
+   _mesa_GetShaderiv(shader, GL_COMPILE_STATUS, &ok);
+   if (ok)
+  return shader;
+
+   _mesa_GetShaderiv(shader, GL_INFO_LOG_LENGTH, &size);
+   if (size == 0)
+  return 0;
+
+   info = malloc(size);
+   if (!info)
+  return 0;
+
+   _mesa_GetProgramInfoLog(shader, size, NULL, info);
+   _mesa_problem(ctx,
+"meta program compile failed:\n%s\n"
+"source:\n%s\n",
+info, source);
+
+   free(info);
+
+   return 0;
+}
+
+static GLuint
+link_program_with_debug(struct gl_context *ctx, GLuint program)
+{
+   GLint ok, size;
+   GLchar *info;
+
+   _mesa_LinkProgramARB(program);
+
+   _mesa_GetProgramiv(program, GL_LINK_STATUS, &ok);
+   if (ok)
+  return program;
+
+   _mesa_GetProgramiv(program, GL_INFO_LOG_LENGTH, &size);
+   if (size == 0)
+  return 0;
+
+   info = malloc(size);
+   if (!info)
+  return 0;
+
+   _mesa_GetProgramInfoLog(program, size, NULL, info);
+   _mesa_problem(ctx, "meta program link failed:\n%s", info);
+
+   free(info);
+
+   return 0;
+}
 
 /**
  * Initialize meta-ops for a context.
@@ -1646,6 +1709,22 @@ meta_glsl_clear_init(struct gl_context *ctx, struct 
clear_state *clear)
   "{\n"
   "   gl_FragColor = color;\n"
   "}\n";
+   const char *vs_int_source =
+  "#version 130\n"
+  "attribute vec4 position;\n"
+  "void main()\n"
+  "{\n"
+  "   gl_Position = position;\n"
+  "}\n";
+   const char *fs_int_source =
+  "#version 130\n"
+  "uniform ivec4 color;\n"
+  "out ivec4 out_color;\n"
+  "\n"
+  "void main()\n"
+  "{\n"
+  "   out_color = color;\n"
+  "}\n";
GLuint vs, fs;
 
if (clear->ArrayObj != 0)
@@ -1679,6 +1758,26 @@ meta_glsl_clear_init(struct gl_context *ctx, struct 
clear_state *clear)
 
clear->ColorLocation = _mesa_GetUniformLocationARB(clear->ShaderProg,
  "color");
+
+   if (ctx->Const.GLSLVersion >= 130) {
+  vs = compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_int_source);
+  fs = compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_int_source);
+
+  clear->IntegerShaderProg = _mesa_CreateProgramObjectARB();
+  _mesa_AttachShader(clear->IntegerShaderProg, fs);
+  _mesa_AttachShader(clear->IntegerShaderProg, vs);
+  _mesa_BindAttribLocationARB(clear->IntegerShaderProg, 0, "position");
+
+  /* Note that user-defined out attributes get automatically assigned
+   * locations starting from 0, so we don't need to explicitly
+   * BindFragDataLocation to 0.
+   */
+
+  link_program_with_debug(ctx, clear->IntegerShaderProg);
+
+  clear->IntegerColorLocation =
+_mesa_GetUniformLocationARB(clear->IntegerShaderProg, "color");
+   }
 }
 
 /**
@@ -1722,9 +1821,15 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield 
buffers)
 
meta_glsl_clear_init(ctx, clear);
 
-   _mesa_UseProgramObjectARB(clear->ShaderProg);
-   _mesa_Uniform4fvARB(clear->ColorLocation, 1,
-  ctx->Color.ClearColor.f);
+   if (fb->_IntegerColor) {
+  _mesa_UseProgramObjectARB(clear->IntegerShaderProg);
+  _mesa_Uniform4ivARB(clear->IntegerColorLocation, 1,
+ ctx->Color.ClearColor.i);
+   } else {
+  _mesa_UseProgramObjectARB(clear->ShaderProg)

Mesa (master): i965: Claim to support rendering to integer FBOs.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 42c5552b0eef9c06898d29bb3f5c985f31316250
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=42c5552b0eef9c06898d29bb3f5c985f31316250

Author: Eric Anholt 
Date:   Wed Nov  2 13:51:38 2011 -0700

i965: Claim to support rendering to integer FBOs.

We're missing support for the software paths still, but basic
rendering is working.

v2: Override RGB_INT32/UINT32 to not be renderable, since the hardware
can't do it but we do allow texturing from it now.  Drop the
DataType override, since the _mesa_problem() isn't in that path
any more.

Reviewed-by: Kenneth Graunke  (v1)

---

 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |7 +++
 src/mesa/drivers/dri/intel/intel_span.c  |7 ++-
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 3359622..0a00ab9 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -174,6 +174,13 @@ brw_render_target_supported(gl_format format)
if (format == MESA_FORMAT_RGBA_FLOAT32)
   return true;
 
+   /* While we can texture from these formats, they're not actually supported
+* for rendering.
+*/
+   if (format == MESA_FORMAT_RGB_UINT32 ||
+   format == MESA_FORMAT_RGB_INT32)
+  return false;
+
/* Not exactly true, as some of those formats are not renderable.
 * But at least we know how to translate them.
 */
diff --git a/src/mesa/drivers/dri/intel/intel_span.c 
b/src/mesa/drivers/dri/intel/intel_span.c
index 191f776..478aec8 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -421,7 +421,12 @@ static span_init_func 
intel_span_init_funcs[MESA_FORMAT_COUNT] =
 bool
 intel_span_supports_format(gl_format format)
 {
-   return intel_span_init_funcs[format] != NULL;
+   /* Rendering to/from integer textures will be done using MapRenderbuffer,
+* rather than coding up new paths through GetRow/PutRow(), so claim support
+* for those formats in here for now.
+*/
+   return (intel_span_init_funcs[format] != NULL ||
+  _mesa_is_format_integer_color(format));
 }
 
 /**

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


Mesa (master): i965/fs: Add support for user-defined out variables.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 6d874d0ee18b3694c49e0206fa519bd8b746ec24
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d874d0ee18b3694c49e0206fa519bd8b746ec24

Author: Eric Anholt 
Date:   Tue Nov  8 19:27:46 2011 -0800

i965/fs: Add support for user-defined out variables.

Before, I was tracking the ir_variable * found for gl_FragColor or
gl_FragData[].  Instead, when visiting those variables, set up an
array of per-render-target fs_regs to copy the output data from.  This
cleans up the color emit path, while making handling of multiple
user-defined out variables easier.

v2: incorporate idr's feedback about ir->location (changes by Kenneth Graunke)

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_fs.h   |8 ++--
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |   66 ++
 2 files changed, 39 insertions(+), 35 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 3e45030..de31644 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -376,9 +376,8 @@ public:
   else
 this->reg_null_cmp = reg_null_f;
 
-  this->frag_color = NULL;
-  this->frag_data = NULL;
   this->frag_depth = NULL;
+  memset(this->outputs, 0, sizeof(this->outputs));
   this->first_non_payload_grf = 0;
 
   this->current_annotation = NULL;
@@ -533,7 +532,7 @@ public:
void emit_if_gen6(ir_if *ir);
void emit_unspill(fs_inst *inst, fs_reg reg, uint32_t spill_offset);
 
-   void emit_color_write(int index, int first_color_mrf, fs_reg color);
+   void emit_color_write(int target, int index, int first_color_mrf);
void emit_fb_writes();
bool try_rewrite_rhs_to_dst(ir_assignment *ir,
   fs_reg dst,
@@ -581,7 +580,8 @@ public:
int *params_remap;
 
struct hash_table *variable_ht;
-   ir_variable *frag_color, *frag_data, *frag_depth;
+   ir_variable *frag_depth;
+   fs_reg outputs[BRW_MAX_DRAW_BUFFERS];
int first_non_payload_grf;
int urb_setup[FRAG_ATTRIB_MAX];
bool kill_emitted;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 3e2feaf..a76ba96 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -58,14 +58,6 @@ fs_visitor::visit(ir_variable *ir)
if (variable_storage(ir))
   return;
 
-   if (strcmp(ir->name, "gl_FragColor") == 0) {
-  this->frag_color = ir;
-   } else if (strcmp(ir->name, "gl_FragData") == 0) {
-  this->frag_data = ir;
-   } else if (strcmp(ir->name, "gl_FragDepth") == 0) {
-  this->frag_depth = ir;
-   }
-
if (ir->mode == ir_var_in) {
   if (!strcmp(ir->name, "gl_FragCoord")) {
 reg = emit_fragcoord_interpolation(ir);
@@ -77,9 +69,29 @@ fs_visitor::visit(ir_variable *ir)
   assert(reg);
   hash_table_insert(this->variable_ht, reg, ir);
   return;
-   }
+   } else if (ir->mode == ir_var_out) {
+  reg = new(this->mem_ctx) fs_reg(this, ir->type);
 
-   if (ir->mode == ir_var_uniform) {
+  if (ir->location == FRAG_RESULT_COLOR) {
+/* Writing gl_FragColor outputs to all color regions. */
+for (int i = 0; i < c->key.nr_color_regions; i++) {
+   this->outputs[i] = *reg;
+}
+  } else if (ir->location == FRAG_RESULT_DEPTH) {
+this->frag_depth = ir;
+  } else {
+/* gl_FragData or a user-defined FS output */
+assert(ir->location >= FRAG_RESULT_DATA0 &&
+   ir->location < FRAG_RESULT_DATA0 + BRW_MAX_DRAW_BUFFERS);
+
+/* General color output. */
+for (unsigned int i = 0; i < MAX2(1, ir->type->length); i++) {
+   int output = ir->location - FRAG_RESULT_DATA0 + i;
+   this->outputs[output] = *reg;
+   this->outputs[output].reg_offset += 4 * i;
+}
+  }
+   } else if (ir->mode == ir_var_uniform) {
   int param_index = c->prog_data.nr_params;
 
   if (c->dispatch_width == 16) {
@@ -1830,10 +1842,18 @@ fs_visitor::emit_interpolation_setup_gen6()
 }
 
 void
-fs_visitor::emit_color_write(int index, int first_color_mrf, fs_reg color)
+fs_visitor::emit_color_write(int target, int index, int first_color_mrf)
 {
int reg_width = c->dispatch_width / 8;
fs_inst *inst;
+   fs_reg color = outputs[target];
+   fs_reg mrf;
+
+   /* If there's no color data to be written, skip it. */
+   if (color.file == BAD_FILE)
+  return;
+
+   color.reg_offset += index;
 
if (c->dispatch_width == 8 || intel->gen >= 6) {
   /* SIMD8 write looks like:
@@ -1959,27 +1979,12 @@ fs_visitor::emit_fb_writes()
   nr += reg_width;
}
 
-   fs_reg color = reg_undef;
-   if (this->frag_color)
-  color = *(variable_storage(this->frag_color));
-   else if (this->frag_data) {
-  color = *(variable_storage(this->frag_data));
-  color.type = BRW_REGISTER_TYPE_F;
-   }
-
for (int target = 0;

Mesa (master): i965/fs: Preserve the source register type when doing color writes.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: e988d816e16f9c0844424472d689486a833931c3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e988d816e16f9c0844424472d689486a833931c3

Author: Eric Anholt 
Date:   Tue Nov  8 19:26:39 2011 -0800

i965/fs: Preserve the source register type when doing color writes.

When rendering to integer color buffers, we need to be careful to use
MRFs of the correct type when emitting color writes.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |   11 +++
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 15009dc..3e2feaf 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1853,7 +1853,7 @@ fs_visitor::emit_color_write(int index, int 
first_color_mrf, fs_reg color)
* m + 7: a1
*/
   inst = emit(BRW_OPCODE_MOV,
- fs_reg(MRF, first_color_mrf + index * reg_width),
+ fs_reg(MRF, first_color_mrf + index * reg_width, color.type),
  color);
   inst->saturate = c->key.clamp_fragment_color;
} else {
@@ -1874,19 +1874,22 @@ fs_visitor::emit_color_write(int index, int 
first_color_mrf, fs_reg color)
  * destination + 4.
  */
 inst = emit(BRW_OPCODE_MOV,
-fs_reg(MRF, BRW_MRF_COMPR4 + first_color_mrf + index),
+fs_reg(MRF, BRW_MRF_COMPR4 + first_color_mrf + index,
+   color.type),
 color);
 inst->saturate = c->key.clamp_fragment_color;
   } else {
 push_force_uncompressed();
-inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, first_color_mrf + index),
+inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, first_color_mrf + index,
+   color.type),
 color);
 inst->saturate = c->key.clamp_fragment_color;
 pop_force_uncompressed();
 
 push_force_sechalf();
 color.sechalf = true;
-inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, first_color_mrf + index + 4),
+inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, first_color_mrf + index + 4,
+   color.type),
 color);
 inst->saturate = c->key.clamp_fragment_color;
 pop_force_sechalf();

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


Mesa (master): i965: Make brw_type_for_base_type return the element type for arrays.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: e19dfc75b67e263437bd08b161c15b34582ccb2f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e19dfc75b67e263437bd08b161c15b34582ccb2f

Author: Eric Anholt 
Date:   Tue Nov  8 19:26:38 2011 -0800

i965: Make brw_type_for_base_type return the element type for arrays.

Previously, brw_type_for_base_type returned UD for array variables,
similar to structures.  For structures, each field may have a different
type, so every field access must explicitly override the register's type
with that field's type.  We chose to return UD in this case since it was
the least common, so errors would be more obvious.

For arrays, it makes far more sense to return the type corresponding to
an element of the array.  This allows normal array access to work
without the hassle of explicitly overriding the register's type.

This should obsolete a bunch of type overrides throughout the code.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_shader.cpp |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp 
b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 7679b6e..f25fab3 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -170,6 +170,7 @@ brw_type_for_base_type(const struct glsl_type *type)
case GLSL_TYPE_UINT:
   return BRW_REGISTER_TYPE_UD;
case GLSL_TYPE_ARRAY:
+  return brw_type_for_base_type(type->fields.array);
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_SAMPLER:
   /* These should be overridden with the type of the member when

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


Mesa (master): i965: Enable ChooseTexFormat for supported GL_EXT_texture_integer formats.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: a00c5a71cd95d340f9ba54a0360f654414d627d2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a00c5a71cd95d340f9ba54a0360f654414d627d2

Author: Eric Anholt 
Date:   Wed Oct  5 13:42:19 2011 -0700

i965: Enable ChooseTexFormat for supported GL_EXT_texture_integer formats.

v2: s/GL_TRUE/true/, and re-enable RGB_INT32 based on discussion
yesterday about required RB formats vs texture formats.

Reviewed-by: Kenneth Graunke  (v1)

---

 src/mesa/drivers/dri/intel/intel_context.c |   30 
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_context.c 
b/src/mesa/drivers/dri/intel/intel_context.c
index 3e10ce0..d00d5d4 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -710,6 +710,36 @@ intelInitContext(struct intel_context *intel,
   ctx->TextureFormatSupported[MESA_FORMAT_SLA8] = true;
}
 
+   if (intel->gen >= 4) {
+  /* Each combination of 32-bit ints are supported, but the RGB 32-bit ints
+   * don't support use as a render target (GPU hangs).
+   */
+  ctx->TextureFormatSupported[MESA_FORMAT_R_INT32] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RG_INT32] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RGB_INT32] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RGBA_INT32] = true;
+
+  ctx->TextureFormatSupported[MESA_FORMAT_R_UINT32] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RG_UINT32] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RGB_UINT32] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RGBA_UINT32] = true;
+
+  /* For 16 and 8 bits, RGB is unsupported entirely. */
+  ctx->TextureFormatSupported[MESA_FORMAT_R_UINT16] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RG_UINT16] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RGBA_UINT16] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_R_INT16] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RG_INT16] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RGBA_INT16] = true;
+
+  ctx->TextureFormatSupported[MESA_FORMAT_R_UINT8] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RG_UINT8] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RGBA_UINT8] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_R_INT8] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RG_INT8] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_RGBA_INT8] = true;
+   }
+
 #ifdef TEXTURE_FLOAT_ENABLED
ctx->TextureFormatSupported[MESA_FORMAT_RGBA_FLOAT32] = true;
ctx->TextureFormatSupported[MESA_FORMAT_RG_FLOAT32] = true;

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


Mesa (master): i965: Add mapping from MESA_FORMAT to BRW_SURFACEFORMAT for integer.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 35be4ae77eb813bf6184699c038e82ad32bd267d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=35be4ae77eb813bf6184699c038e82ad32bd267d

Author: Eric Anholt 
Date:   Wed Oct  5 13:38:03 2011 -0700

i965: Add mapping from MESA_FORMAT to BRW_SURFACEFORMAT for integer.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   24 ++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 66a8a5a..3359622 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -127,6 +127,30 @@ brw_format_for_mesa_format(gl_format mesa_format)
   [MESA_FORMAT_SIGNED_RG_RGTC2] = BRW_SURFACEFORMAT_BC5_SNORM,
   [MESA_FORMAT_RGB9_E5_FLOAT] = BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP,
   [MESA_FORMAT_R11_G11_B10_FLOAT] = BRW_SURFACEFORMAT_R11G11B10_FLOAT,
+
+  [MESA_FORMAT_R_INT32] = BRW_SURFACEFORMAT_R32_SINT,
+  [MESA_FORMAT_RG_INT32] = BRW_SURFACEFORMAT_R32G32_SINT,
+  [MESA_FORMAT_RGB_INT32] = BRW_SURFACEFORMAT_R32G32B32_SINT,
+  [MESA_FORMAT_RGBA_INT32] = BRW_SURFACEFORMAT_R32G32B32A32_SINT,
+
+  [MESA_FORMAT_R_UINT32] = BRW_SURFACEFORMAT_R32_UINT,
+  [MESA_FORMAT_RG_UINT32] = BRW_SURFACEFORMAT_R32G32_UINT,
+  [MESA_FORMAT_RGB_UINT32] = BRW_SURFACEFORMAT_R32G32B32_UINT,
+  [MESA_FORMAT_RGBA_UINT32] = BRW_SURFACEFORMAT_R32G32B32A32_UINT,
+
+  [MESA_FORMAT_RGBA_UINT16] = BRW_SURFACEFORMAT_R16G16B16A16_UINT,
+  [MESA_FORMAT_RGBA_INT16] = BRW_SURFACEFORMAT_R16G16B16A16_SINT,
+  [MESA_FORMAT_RG_UINT16] = BRW_SURFACEFORMAT_R16G16_UINT,
+  [MESA_FORMAT_RG_INT16] = BRW_SURFACEFORMAT_R16G16_SINT,
+  [MESA_FORMAT_R_UINT16] = BRW_SURFACEFORMAT_R16_UINT,
+  [MESA_FORMAT_R_INT16] = BRW_SURFACEFORMAT_R16_SINT,
+
+  [MESA_FORMAT_RGBA_UINT8] = BRW_SURFACEFORMAT_R8G8B8A8_UINT,
+  [MESA_FORMAT_RGBA_INT8] = BRW_SURFACEFORMAT_R8G8B8A8_SINT,
+  [MESA_FORMAT_RG_UINT8] = BRW_SURFACEFORMAT_R8G8_UINT,
+  [MESA_FORMAT_RG_INT8] = BRW_SURFACEFORMAT_R8G8_SINT,
+  [MESA_FORMAT_R_UINT8] = BRW_SURFACEFORMAT_R8_UINT,
+  [MESA_FORMAT_R_INT8] = BRW_SURFACEFORMAT_R8_SINT,
};
assert(mesa_format < MESA_FORMAT_COUNT);
return table[mesa_format];

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


Mesa (master): intel: Expose GL_EXT_texture_integer when GL 3. 0 override is set.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 704b7551e88b680f2bf814cbcacd24051ad8e19c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=704b7551e88b680f2bf814cbcacd24051ad8e19c

Author: Eric Anholt 
Date:   Wed Oct  5 13:25:36 2011 -0700

intel: Expose GL_EXT_texture_integer when GL 3.0 override is set.

This will let the feature be incrementally developed, hidden behind
the flag we're all using as we work on GL 3.0 support.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/intel/intel_extensions.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c 
b/src/mesa/drivers/dri/intel/intel_extensions.c
index 7a5ef3e..89f0920 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -41,6 +41,14 @@ void
 intelInitExtensions(struct gl_context *ctx)
 {
struct intel_context *intel = intel_context(ctx);
+   char *override = getenv("MESA_GL_VERSION_OVERRIDE");
+   int override_major, override_minor;
+   int override_version = 0;
+
+   if (override &&
+   sscanf(override, "%u.%u", &override_major, &override_minor) == 2) {
+  override_version = override_major * 10 + override_minor;
+   }
 
ctx->Extensions.ARB_draw_elements_base_vertex = true;
ctx->Extensions.ARB_explicit_attrib_location = true;
@@ -117,6 +125,8 @@ intelInitExtensions(struct gl_context *ctx)
   ctx->Extensions.EXT_draw_buffers2 = true;
   ctx->Extensions.EXT_framebuffer_sRGB = true;
   ctx->Extensions.EXT_texture_array = true;
+  if (override_version >= 30)
+ctx->Extensions.EXT_texture_integer = true;
   ctx->Extensions.EXT_texture_snorm = true;
   ctx->Extensions.EXT_texture_sRGB = true;
   ctx->Extensions.EXT_texture_sRGB_decode = true;

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


Mesa (master): docs: Note EXT_texture_array on i965.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 6e610a0485769e07eb7092d6922ccb91482f057c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e610a0485769e07eb7092d6922ccb91482f057c

Author: Eric Anholt 
Date:   Wed Oct  5 13:26:42 2011 -0700

docs: Note EXT_texture_array on i965.

Reviewed-by: Kenneth Graunke 

---

 docs/relnotes-7.12.html |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/docs/relnotes-7.12.html b/docs/relnotes-7.12.html
index a92278e..06aeda0 100644
--- a/docs/relnotes-7.12.html
+++ b/docs/relnotes-7.12.html
@@ -41,7 +41,7 @@ tbd
 GL_ARB_vertex_type_2_10_10_10_rev (r600g)
 GL_ARB_texture_storage (gallium drivers and swrast)
 GL_EXT_packed_float (i965)
-GL_EXT_texture_array (r600g)
+GL_EXT_texture_array (r600g, i965)
 GL_EXT_texture_shared_exponent (i965)
 GL_NV_fog_distance (all gallium drivers, nouveau classic)
 GL_NV_primitive_restart (r600g)

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


Mesa (master): intel: Don' t _mesa_problem when asked for an RB of a texturing-only type.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: b5444a6ebd48a2bf4c258be98aac831636164e10
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5444a6ebd48a2bf4c258be98aac831636164e10

Author: Eric Anholt 
Date:   Tue Nov  8 11:19:45 2011 -0800

intel: Don't _mesa_problem when asked for an RB of a texturing-only type.

We want to be able to support some formats for texturing that we can't
render to, which means that some choices for RenderbufferStorage end
up being incomplete (for example, L8 currently).  For these, where we
don't render to them, we don't want to have to make up an rb->DataType
that's only used for GetRow()/PutRow().

---

 src/mesa/drivers/dri/intel/intel_span.c   |7 +++
 src/mesa/drivers/dri/intel/intel_tex_format.c |6 --
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_span.c 
b/src/mesa/drivers/dri/intel/intel_span.c
index 604962d..191f776 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -436,4 +436,11 @@ intel_set_span_functions(struct intel_context *intel,
 
assert(intel_span_init_funcs[irb->Base.Format]);
intel_span_init_funcs[irb->Base.Format](rb);
+
+   if (rb->DataType == GL_NONE) {
+  _mesa_problem(NULL,
+   "renderbuffer format %s is missing "
+   "intel_mesa_format_to_rb_datatype() support.",
+   _mesa_get_format_name(rb->Format));
+   }
 }
diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c 
b/src/mesa/drivers/dri/intel/intel_tex_format.c
index 6890a69..a9f4981 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_format.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_format.c
@@ -42,8 +42,10 @@ intel_mesa_format_to_rb_datatype(gl_format format)
   return GL_FLOAT;
 
default:
-  _mesa_problem(NULL, "unexpected MESA_FORMAT for renderbuffer");
-  return GL_UNSIGNED_BYTE;
+  /* Unsupported format.  We may hit this when people ask for 
FBO-incomplete
+   * formats.
+   */
+  return GL_NONE;
}
 }
 

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


Mesa (master): i965: Add support for 16-bit unorm L, A, and I textures.

2011-11-09 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: e56aecf2492e3ca63ea70332a346f3f8414cba6c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e56aecf2492e3ca63ea70332a346f3f8414cba6c

Author: Eric Anholt 
Date:   Tue Nov  8 11:05:17 2011 -0800

i965: Add support for 16-bit unorm L, A, and I textures.

While not required by any particular spec version, mplayer was asking
for L16 and hoping for actual L16 without checking.  The 8 bits
allocated led to 10-bit planar video data stored in the lower 10 bits
giving only 2 bits of precision in video.  While it was an amusing
effect, give them what they actually wanted instead.

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

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |3 +++
 src/mesa/drivers/dri/intel/intel_context.c   |6 +-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 04dc389..66a8a5a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -80,6 +80,9 @@ brw_format_for_mesa_format(gl_format mesa_format)
   [MESA_FORMAT_I8] = BRW_SURFACEFORMAT_I8_UNORM,
   [MESA_FORMAT_A8] = BRW_SURFACEFORMAT_A8_UNORM,
   [MESA_FORMAT_AL88] = BRW_SURFACEFORMAT_L8A8_UNORM,
+  [MESA_FORMAT_L16] = BRW_SURFACEFORMAT_L16_UNORM,
+  [MESA_FORMAT_A16] = BRW_SURFACEFORMAT_A16_UNORM,
+  [MESA_FORMAT_I16] = BRW_SURFACEFORMAT_I16_UNORM,
   [MESA_FORMAT_AL1616] = BRW_SURFACEFORMAT_L16A16_UNORM,
   [MESA_FORMAT_R8] = BRW_SURFACEFORMAT_R8_UNORM,
   [MESA_FORMAT_R16] = BRW_SURFACEFORMAT_R16_UNORM,
diff --git a/src/mesa/drivers/dri/intel/intel_context.c 
b/src/mesa/drivers/dri/intel/intel_context.c
index 8e8ab73..3e10ce0 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -640,8 +640,12 @@ intelInitContext(struct intel_context *intel,
ctx->TextureFormatSupported[MESA_FORMAT_A8] = true;
ctx->TextureFormatSupported[MESA_FORMAT_I8] = true;
ctx->TextureFormatSupported[MESA_FORMAT_AL88] = true;
-   if (intel->gen >= 4)
+   if (intel->gen >= 4) {
+  ctx->TextureFormatSupported[MESA_FORMAT_L16] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_A16] = true;
+  ctx->TextureFormatSupported[MESA_FORMAT_I16] = true;
   ctx->TextureFormatSupported[MESA_FORMAT_AL1616] = true;
+   }
 
/* Depth and stencil */
ctx->TextureFormatSupported[MESA_FORMAT_S8_Z24] = true;

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


Mesa (master): r200: remove dangling radeon.h symlink.

2011-11-09 Thread Paul Berry
Module: Mesa
Branch: master
Commit: 01ccddbed6ff970e1018c250ba9044bf06671d25
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=01ccddbed6ff970e1018c250ba9044bf06671d25

Author: Paul Berry 
Date:   Tue Nov  8 07:50:56 2011 -0800

r200: remove dangling radeon.h symlink.

Commit 1401b96b (radeon: cleanup radeon shared code after r300 and
r600 classic drivers removal) removed the file
src/mesa/drivers/dri/radeon/server/radeon.h, but it left behind the
symlink which was used to share that file into the
src/mesa/drivers/dri/r200/server directory.

This patch removes the dangling symlink.

Reviewed-by: Alex Deucher 

---

 src/mesa/drivers/dri/r200/server/radeon.h |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/server/radeon.h 
b/src/mesa/drivers/dri/r200/server/radeon.h
deleted file mode 12
index 81274a5..000
--- a/src/mesa/drivers/dri/r200/server/radeon.h
+++ /dev/null
@@ -1 +0,0 @@
-../../radeon/server/radeon.h
\ No newline at end of file

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


Mesa (master): glsl: Assign transform feedback varying slots in linker.

2011-11-09 Thread Paul Berry
Module: Mesa
Branch: master
Commit: 871ddb919b424293894a23a8f83200fed572d6a9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=871ddb919b424293894a23a8f83200fed572d6a9

Author: Paul Berry 
Date:   Sat Nov  5 11:17:32 2011 -0700

glsl: Assign transform feedback varying slots in linker.

This patch modifies the GLSL linker to assign additional slots for
varying variables used by transform feedback, and record the varying
slots used by transform feedback for use by the driver back-end.

This required modifying assign_varying_locations() so that it assigns
a varying location if either (a) the varying is used by the next stage
of the GL pipeline, or (b) the varying is required by transform
feedback.  In order to avoid duplicating the code to assign a single
varying location, I moved it into its own function,
assign_varying_location().

In addition, to support transform feedback in the case where there is
no fragment shader, it is now possible to call
assign_varying_locations() with a consumer of NULL.

Reviewed-by: Marek Olšák 
Tested-by: Marek Olšák 

---

 src/glsl/linker.cpp|  553 ++--
 src/mesa/main/mtypes.h |   13 ++
 2 files changed, 503 insertions(+), 63 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 0306b7a..351680d 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1369,10 +1369,359 @@ demote_shader_inputs_and_outputs(gl_shader *sh, enum 
ir_variable_mode mode)
 }
 
 
+/**
+ * Data structure tracking information about a transform feedback declaration
+ * during linking.
+ */
+class tfeedback_decl
+{
+public:
+   bool init(struct gl_shader_program *prog, const void *mem_ctx,
+ const char *input);
+   static bool is_same(const tfeedback_decl &x, const tfeedback_decl &y);
+   bool assign_location(struct gl_context *ctx, struct gl_shader_program *prog,
+ir_variable *output_var);
+   bool store(struct gl_shader_program *prog,
+  struct gl_transform_feedback_info *info, unsigned buffer) const;
+
+
+   /**
+* True if assign_location() has been called for this object.
+*/
+   bool is_assigned() const
+   {
+  return this->location != -1;
+   }
+
+   /**
+* Determine whether this object refers to the variable var.
+*/
+   bool matches_var(ir_variable *var) const
+   {
+  return strcmp(var->name, this->var_name) == 0;
+   }
+
+   /**
+* The total number of varying components taken up by this variable.  Only
+* valid if is_assigned() is true.
+*/
+   unsigned num_components() const
+   {
+  return this->vector_elements * this->matrix_columns;
+   }
+
+private:
+   /**
+* The name that was supplied to glTransformFeedbackVaryings.  Used for
+* error reporting.
+*/
+   const char *orig_name;
+
+   /**
+* The name of the variable, parsed from orig_name.
+*/
+   char *var_name;
+
+   /**
+* True if the declaration in orig_name represents an array.
+*/
+   bool is_array;
+
+   /**
+* If is_array is true, the array index that was specified in orig_name.
+*/
+   unsigned array_index;
+
+   /**
+* The vertex shader output location that the linker assigned for this
+* variable.  -1 if a location hasn't been assigned yet.
+*/
+   int location;
+
+   /**
+* If location != -1, the number of vector elements in this variable, or 1
+* if this variable is a scalar.
+*/
+   unsigned vector_elements;
+
+   /**
+* If location != -1, the number of matrix columns in this variable, or 1
+* if this variable is not a matrix.
+*/
+   unsigned matrix_columns;
+};
+
+
+/**
+ * Initialize this object based on a string that was passed to
+ * glTransformFeedbackVaryings.  If there is a parse error, the error is
+ * reported using linker_error(), and false is returned.
+ */
+bool
+tfeedback_decl::init(struct gl_shader_program *prog, const void *mem_ctx,
+ const char *input)
+{
+   /* We don't have to be pedantic about what is a valid GLSL variable name,
+* because any variable with an invalid name can't exist in the IR anyway.
+*/
+
+   this->location = -1;
+   this->orig_name = input;
+
+   const char *bracket = strrchr(input, '[');
+
+   if (bracket) {
+  this->var_name = ralloc_strndup(mem_ctx, input, bracket - input);
+  if (sscanf(bracket, "[%u]", &this->array_index) == 1) {
+ this->is_array = true;
+ return true;
+  }
+   } else {
+  this->var_name = ralloc_strdup(mem_ctx, input);
+  this->is_array = false;
+  return true;
+   }
+
+   linker_error(prog, "Cannot parse transform feedback varying %s", input);
+   return false;
+}
+
+
+/**
+ * Determine whether two tfeedback_decl objects refer to the same variable and
+ * array index (if applicable).
+ */
+bool
+tfeedback_decl::is_same(const tfeedback_decl &x, const tfeedback_decl &y)
+{
+   if (strcmp(x.var_name, y.var_name) != 0)
+  return false;
+   if (x.is_array != 

Mesa (master): glsl: Clamp vector indices when lowering to swizzles

2011-11-09 Thread Ian Romanick
Module: Mesa
Branch: master
Commit: 6f5c73797087c6e7842665f84e41caedea59bb65
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f5c73797087c6e7842665f84e41caedea59bb65

Author: Ian Romanick 
Date:   Mon Nov  7 10:58:00 2011 -0800

glsl: Clamp vector indices when lowering to swizzles

This prevents other code from seeing a swizzle of the 16th component
of a vector, for example.

NOTE: This is a candidate for the 7.11 branch.

Signed-off-by: Ian Romanick 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42517
Reviewed-by: Kenneth Graunke 
Reviewed-by: Paul Berry 
Tested-by: Christian Holler 

---

 src/glsl/lower_vec_index_to_swizzle.cpp |   22 --
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/glsl/lower_vec_index_to_swizzle.cpp 
b/src/glsl/lower_vec_index_to_swizzle.cpp
index c7630c2..46fd6ac 100644
--- a/src/glsl/lower_vec_index_to_swizzle.cpp
+++ b/src/glsl/lower_vec_index_to_swizzle.cpp
@@ -33,6 +33,7 @@
 #include "ir_visitor.h"
 #include "ir_optimization.h"
 #include "glsl_types.h"
+#include "main/macros.h"
 
 /**
  * Visitor class for replacing expressions with ir_constant values.
@@ -76,8 +77,25 @@ 
ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir)
 
void *ctx = ralloc_parent(ir);
this->progress = true;
-   return new(ctx) ir_swizzle(deref->array,
- ir_constant->value.i[0], 0, 0, 0, 1);
+
+   /* Page 40 of the GLSL 1.20 spec says:
+*
+* "When indexing with non-constant expressions, behavior is undefined
+* if the index is negative, or greater than or equal to the size of
+* the vector."
+*
+* The quoted spec text mentions non-constant expressions, but this code
+* operates on constants.  These constants are the result of non-constant
+* expressions that have been optimized to constants.  The common case here
+* is a loop counter from an unrolled loop that is used to index a vector.
+*
+* The ir_swizzle constructor gets angry if the index is negative or too
+* large.  For simplicity sake, just clamp the index to [0, size-1].
+*/
+   const int i = MIN2(MAX2(ir_constant->value.i[0], 0),
+ (deref->array->type->vector_elements - 1));
+
+   return new(ctx) ir_swizzle(deref->array, i, 0, 0, 0, 1);
 }
 
 ir_visitor_status

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


Mesa (master): scons: Disable deprecated POSIX name MSVC warnings.

2011-11-09 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 1d1c0fa2f31de5190909c869452ae9a2e23bba00
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d1c0fa2f31de5190909c869452ae9a2e23bba00

Author: José Fonseca 
Date:   Wed Nov  9 10:33:21 2011 +

scons: Disable deprecated POSIX name MSVC warnings.

---

 scons/gallium.py |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/scons/gallium.py b/scons/gallium.py
index 18be73f..9651925 100755
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -453,6 +453,7 @@ def generate(env):
 '/fp:fast', # fast floating point 
 '/W3', # warning level
 #'/Wp64', # enable 64 bit porting warnings
+'/wd4996', # disable deprecated POSIX name warnings
 ]
 if env['machine'] == 'x86':
 ccflags += [

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


Mesa (master): mesa, glsl, mapi: Put extern "C" { ... } where appropriate.

2011-11-09 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 63e7a4c6e5bf51d8090046ebc5adcb4207448565
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=63e7a4c6e5bf51d8090046ebc5adcb4207448565

Author: José Fonseca 
Date:   Wed Nov  9 10:20:51 2011 +

mesa,glsl,mapi: Put extern "C" { ... } where appropriate.

Probably a several places missing, but enough to cover all headers
(in)directly included by uniform_query.cpp, and fix the MSVC build.

---

 src/glsl/glsl_types.h |6 +++---
 src/glsl/ir_uniform.h |9 ++---
 src/mapi/glapi/glapi.h|7 +--
 src/mapi/glapi/glthread.h |8 
 src/mapi/mapi/u_thread.h  |   22 +++---
 src/mesa/main/context.h   |9 +
 src/mesa/main/core.h  |8 
 src/mesa/main/formats.h   |   11 +++
 src/mesa/main/glheader.h  |   10 ++
 src/mesa/main/mtypes.h|9 +
 src/mesa/main/shaderapi.h |   11 +++
 src/mesa/main/shaderobj.h |3 +++
 src/mesa/main/simple_list.h   |8 
 src/mesa/main/uniform_query.cpp   |6 +++---
 src/mesa/main/uniforms.h  |   11 +++
 src/mesa/math/m_matrix.h  |9 +
 src/mesa/program/hash_table.h |9 +
 src/mesa/program/ir_to_mesa.h |   15 ---
 src/mesa/program/prog_parameter.h |9 +
 src/mesa/program/prog_statevars.h |   11 +++
 20 files changed, 158 insertions(+), 33 deletions(-)

diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index efbf335..4ac9011 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -29,13 +29,13 @@
 #include 
 #include 
 
-struct _mesa_glsl_parse_state;
-struct glsl_symbol_table;
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+struct _mesa_glsl_parse_state;
+struct glsl_symbol_table;
+
 extern void
 _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
 
diff --git a/src/glsl/ir_uniform.h b/src/glsl/ir_uniform.h
index be9f6b2..225da3f 100644
--- a/src/glsl/ir_uniform.h
+++ b/src/glsl/ir_uniform.h
@@ -25,15 +25,18 @@
 #ifndef IR_UNIFORM_H
 #define IR_UNIFORM_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 /* stdbool.h is necessary because this file is included in both C and C++ code.
  */
 #include 
+
 #include "program/prog_parameter.h"  /* For union gl_constant_value. */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum gl_uniform_driver_format {
uniform_native = 0,  /**< Store data in the native format. */
uniform_int_float,   /**< Store integer data as floats. */
diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h
index b9351d1..f685475 100644
--- a/src/mapi/glapi/glapi.h
+++ b/src/mapi/glapi/glapi.h
@@ -44,10 +44,14 @@
 #ifndef _GLAPI_H
 #define _GLAPI_H
 
+#include "glapi/glthread.h"
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+
 #ifdef _GLAPI_NO_EXPORTS
 #  define _GLAPI_EXPORT
 #else /* _GLAPI_NO_EXPORTS */
@@ -75,8 +79,6 @@ extern "C" {
 #define _glapi_Context _mglapi_Context
 #endif
 
-#include "glapi/glthread.h"
-
 typedef void (*_glapi_proc)(void);
 struct _glapi_table;
 
@@ -180,6 +182,7 @@ _glapi_noop_enable_warnings(unsigned char enable);
 _GLAPI_EXPORT void
 _glapi_set_warning_func(_glapi_proc func);
 
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/mapi/glapi/glthread.h b/src/mapi/glapi/glthread.h
index fc4ece7..1c3f4e2 100644
--- a/src/mapi/glapi/glthread.h
+++ b/src/mapi/glapi/glthread.h
@@ -3,6 +3,10 @@
 
 #include "mapi/u_thread.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define _glthread_DECLARE_STATIC_MUTEX(name) u_mutex_declare_static(name)
 #define _glthread_INIT_MUTEX(name)   u_mutex_init(name)
 #define _glthread_DESTROY_MUTEX(name)u_mutex_destroy(name)
@@ -17,4 +21,8 @@
 typedef struct u_tsd _glthread_TSD;
 typedef u_mutex _glthread_Mutex;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* GLTHREAD_H */
diff --git a/src/mapi/mapi/u_thread.h b/src/mapi/mapi/u_thread.h
index 4405ec9..7db22b7 100644
--- a/src/mapi/mapi/u_thread.h
+++ b/src/mapi/mapi/u_thread.h
@@ -44,12 +44,25 @@
 
 #include "u_compiler.h"
 
-#if defined(PTHREADS) || defined(WIN32)
+#if defined(PTHREADS)
+#include  /* POSIX threads headers */
+#endif
+#ifdef _WIN32
+#include 
+#endif
+
+#if defined(PTHREADS) || defined(_WIN32)
 #ifndef THREADS
 #define THREADS
 #endif
 #endif
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 /*
  * POSIX threads. This should be your choice in the Unix world
  * whenever possible.  When building with POSIX threads, be sure
@@ -60,7 +73,6 @@
  * proper compiling for MT-safe libc etc.
  */
 #if defined(PTHREADS)
-#include  /* POSIX threads headers */
 
 struct u_tsd {
pthread_key_t key;
@@ -86,7 +98,6 @@ typedef pthread_mutex_t u_mutex;
  * used!
  */
 #ifdef WIN32
-#include 
 
 struct u_tsd {
DWORD key;
@@ -142,4 +153,9 @@ u_tsd_get(struct u_tsd *tsd);
 void
 u_tsd_set(struct u_tsd *tsd, void *ptr);
 
+
+#ifdef __cplusplu

Mesa (master): scons: Don't list m_xform.c twice.

2011-11-09 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: f4b42aa5b7a3d11f839d5576b4c42406529131be
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f4b42aa5b7a3d11f839d5576b4c42406529131be

Author: José Fonseca 
Date:   Wed Nov  9 10:17:02 2011 +

scons: Don't list m_xform.c twice.

---

 src/mesa/SConscript |5 -
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 5f5c9e6..8f97809 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -149,10 +149,6 @@ math_sources = [
 'math/m_xform.c',
 ]
 
-math_xform_sources = [
-'math/m_xform.c'
-]
-
 swrast_sources = [
 'swrast/s_aaline.c',
 'swrast/s_aatriangle.c',
@@ -322,7 +318,6 @@ common_driver_sources = [
 mesa_sources = (
 main_sources +
 math_sources +
-math_xform_sources +
 program_sources +
 vbo_sources +
 tnl_sources +

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


Mesa (master): glu: Fix deprecated conversion from string constant to ‘char*’ warning.

2011-11-09 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 9b8ee08248c08d8841d3352fdef5844d58d8bc46
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b8ee08248c08d8841d3352fdef5844d58d8bc46

Author: José Fonseca 
Date:   Wed Nov  9 09:08:58 2011 +

glu: Fix deprecated conversion from string constant to ‘char*’ warning.

---

 src/glu/sgi/libnurbs/internals/bin.cc |2 +-
 src/glu/sgi/libnurbs/internals/bin.h  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glu/sgi/libnurbs/internals/bin.cc 
b/src/glu/sgi/libnurbs/internals/bin.cc
index ff75b86..d85bd80 100644
--- a/src/glu/sgi/libnurbs/internals/bin.cc
+++ b/src/glu/sgi/libnurbs/internals/bin.cc
@@ -119,7 +119,7 @@ Bin::adopt()
  */
 
 void
-Bin::show( char *name )
+Bin::show( const char *name )
 {
 #ifndef NDEBUG
 _glu_dprintf( "%s\n", name );
diff --git a/src/glu/sgi/libnurbs/internals/bin.h 
b/src/glu/sgi/libnurbs/internals/bin.h
index 2f976eb..dd0f878 100644
--- a/src/glu/sgi/libnurbs/internals/bin.h
+++ b/src/glu/sgi/libnurbs/internals/bin.h
@@ -57,7 +57,7 @@ public:
 intnumarcs( void );
 void   adopt( void );
 void   markall( void );
-void   show( char * );
+void   show( const char * );
 void   listBezier( void );
 };
 

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