Re: [Mesa-dev] [PATCH 1/5] u_format: Fix bit definition of UF10_MANTISSA_BITS.

2011-10-28 Thread Ian Romanick

On 10/26/2011 04:46 PM, Eric Anholt wrote:

This is only used in the code for packing to INF, and resulted in an
extra bit set that was set anyway, so it was harmless except for the
confusion caused.


There Mesa fixes and the piglit test look good.

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


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

diff --git a/src/gallium/auxiliary/util/u_format_r11g11b10f.h 
b/src/gallium/auxiliary/util/u_format_r11g11b10f.h
index 8e0572a..b1946f8 100644
--- a/src/gallium/auxiliary/util/u_format_r11g11b10f.h
+++ b/src/gallium/auxiliary/util/u_format_r11g11b10f.h
@@ -37,7 +37,7 @@
  #define UF10_EXPONENT_BIAS   15
  #define UF10_EXPONENT_BITS   0x1F
  #define UF10_EXPONENT_SHIFT  5
-#define UF10_MANTISSA_BITS   0x3F
+#define UF10_MANTISSA_BITS   0x1F
  #define UF10_MANTISSA_SHIFT  (23 - UF10_EXPONENT_SHIFT)
  #define UF10_MAX_EXPONENT(UF10_EXPONENT_BITS  UF10_EXPONENT_SHIFT)



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


Re: [Mesa-dev] [PATCH 2/4 v2] mesa/image: assert on bad format

2011-10-28 Thread Ian Romanick

On 10/19/2011 05:10 PM, nobled wrote:

NULL as an error indicator is meaningless, since it will return NULL
on success anyway if the caller passes in zero as the image's address
and asks to calculate the offset of the first pixel. For example,
_mesa_validate_pbo_access() does this.

This also matches the code in the non-GL_BITMAP codepath, which
already has an assert like this.

v2: Per Brian Paul's review, remove the function call entirely
and tighten the assert to only accept the two formats compatible with
GL_BITMAP. They always have one component per pixel.


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


---
  src/mesa/main/image.c |   20 +---
  1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index ca5771c..af96107 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1093,17 +1093,17 @@ _mesa_is_compressed_format(struct gl_context
*ctx, GLenum format)
   * Pixel unpacking/packing parameters are observed according to \p packing.
   *
   * \param dimensions either 1, 2 or 3 to indicate dimensionality of image
+ * \param packing  the pixelstore attributes
   * \param image  starting address of image data
   * \param width  the image width
- * \param height  theimage height
- * \param format  the pixel format
- * \param type  the pixel data type
- * \param packing  the pixelstore attributes
+ * \param height  the image height
+ * \param format  the pixel format (must be validated beforehand)
+ * \param type  the pixel data type (must be validated beforehand)
   * \param img  which image in the volume (0 for 1D or 2D images)
   * \param row  row of pixel in the image (0 for 1D images)
   * \param column column of pixel in the image
   *
- * \return address of pixel on success, or NULL on error.
+ * \return address of pixel.
   *
   * \sa gl_pixelstore_attrib.
   */
@@ -1147,15 +1147,13 @@ _mesa_image_address( GLuint dimensions,

 if (type == GL_BITMAP) {
/* BITMAP data */
-  GLint comp_per_pixel;   /* components per pixel */
GLint bytes_per_row;
GLint bytes_per_image;
+  /* components per pixel for color or stencil index: */
+  const GLint comp_per_pixel = 1;

-  /* Compute number of components per pixel */
-  comp_per_pixel = _mesa_components_in_format( format );
-  if (comp_per_pixel  0) {
- return NULL;
-  }
+  /* The pixel type and format should have been error checked earlier */
+  assert(format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX);

bytes_per_row = alignment
  * CEILING( comp_per_pixel*pixels_per_row, 8*alignment );



___
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 00/20] Rewrite GL API handling of uniforms

2011-10-28 Thread Ian Romanick
This is it.  All the refactors that I've sent over the last month or
so have been building towards this.  This completely guts the existing
uniform handling code and replaces it with something new.  This work
had a few goals:

1. Separate the way the GL API handles uniforms from the way the
driver stores the data.  Specifically, I wanted to isolate the uses of
gl_program_parameter as much as possible.

2. Enable future optimizations in the glUniform path.  Due to the
current storage mechanism, the glUniform path has a lot of steps and a
lot of extra validation.  Some of that has been removed, and future
changes should allow more optimization.

3. Fix known bugs in the current uniform handling code (e.g.,
currently glGetUniformLocation(foo.bar[3].asdf) will fail).

This work isn't quite done, but it's done enough to get the top layers
in.  As mentioned in the commit message of patch 17/20, a bunch of the
code in ir_to_mesa needs to be split up.  Right now the i965 driver
has to use ir_to_mesa to generate connections between uniforms and
gl_program_parameter structures.  In the process, ir_to_mesa also does
some lowering passes and generates Mesa IR.  These things are
separate, and should be split up.

The structure used to store uniforms from the API's perspective has a
variable numuber of slots where the driver can request data be stored.
The glUniform path will dump data, in the formats requested by the
driver, in each of these locations.  One future optimization is for
drivers to allocate a buffer object or a command buffer and have the
glUniform dump data directly in that buffer.  This would cut out the
extra step of copying from the gl_program_parameter.

Another future step is to store built-in uniforms using the same
mechanism.  Once this happens, drivers will just see uniforms.
Period.  Not only will this simplify driver code, but it will also
enable fixing bug #32403.

For those so inclined, this work is also available in the
uniform-rework branch of my person repo.  The first couple patches in
that branch are not part of this work, and they can be ignored.

   git://anongit.freedesktop.org/~idr/mesa uniform-rework

 src/glsl/glsl_types.h  |   23 +-
 src/glsl/ir_uniform.h  |  128 
 src/glsl/link_uniforms.cpp |  250 +++
 src/glsl/linker.cpp|  164 +-
 src/glsl/linker.h  |7 +
 src/mesa/drivers/dri/i965/brw_shader.cpp   |6 +-
 src/mesa/main/core.h   |1 -
 src/mesa/main/mtypes.h |   26 +-
 src/mesa/main/shaderapi.c  |   23 +-
 src/mesa/main/shaderobj.c  |   13 +-
 src/mesa/main/uniform_query.cpp|  855 +++-
 src/mesa/main/uniforms.c   | 1013 ++--
 src/mesa/main/uniforms.h   |   73 ++
 src/mesa/program/ir_to_mesa.cpp|  115 +++-
 src/mesa/program/ir_to_mesa.h  |5 +
 src/mesa/program/prog_uniform.c|  103 ---
 src/mesa/program/prog_uniform.h|   85 ---
 src/mesa/program/sampler.cpp   |   12 +-
 src/mesa/sources.mak   |1 -
 src/mesa/state_tracker/st_draw.c   |   11 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   14 +-
 21 files changed, 1543 insertions(+), 1385 deletions(-)

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


[Mesa-dev] [PATCH 01/20] glsl: Allow glsl_types.h to be included in C sources

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Some C code will want access to the glsl_base_type and
glsl_sampler_dim enums in the near future.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/glsl_types.h |   23 +++
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 0486966..e3ad999 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -29,21 +29,23 @@
 #include string.h
 #include assert.h
 
-extern C {
-#include GL/gl.h
-}
-
-#include ralloc.h
-
 struct _mesa_glsl_parse_state;
 struct glsl_symbol_table;
 
-extern C void
+#ifdef __cplusplus
+extern C {
+#endif
+
+extern void
 _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
 
-extern C void
+extern void
 _mesa_glsl_release_types(void);
 
+#ifdef __cplusplus
+}
+#endif
+
 enum glsl_base_type {
GLSL_TYPE_UINT = 0,
GLSL_TYPE_INT,
@@ -65,6 +67,9 @@ enum glsl_sampler_dim {
GLSL_SAMPLER_DIM_BUF
 };
 
+#ifdef __cplusplus
+#include GL/gl.h
+#include ralloc.h
 
 struct glsl_type {
GLenum gl_type;
@@ -516,4 +521,6 @@ struct glsl_struct_field {
const char *name;
 };
 
+#endif /* __cplusplus */
+
 #endif /* GLSL_TYPES_H */
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 02/20] linker: Make invalidate_variable_locations available outside the compilation unit

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/linker.cpp |   10 +-
 src/glsl/linker.h   |4 
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index beadec6..3d7bab8 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -191,8 +191,8 @@ linker_warning(gl_shader_program *prog, const char *fmt, 
...)
 
 
 void
-invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode,
- int generic_base)
+link_invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode,
+  int generic_base)
 {
foreach_list(node, sh-ir) {
   ir_variable *const var = ((ir_instruction *) node)-as_variable();
@@ -1296,7 +1296,7 @@ assign_attribute_or_color_locations(gl_shader_program 
*prog,
   (target_index == MESA_SHADER_VERTEX) ? ir_var_in : ir_var_out;
 
 
-   invalidate_variable_locations(sh, direction, generic_base);
+   link_invalidate_variable_locations(sh, direction, generic_base);
 
/* Temporary storage for the set of attributes that need locations assigned.
 */
@@ -1498,8 +1498,8 @@ assign_varying_locations(struct gl_context *ctx,
 *not being inputs.  This lets the optimizer eliminate them.
 */
 
-   invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0);
-   invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0);
+   link_invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0);
+   link_invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0);
 
foreach_list(node, producer-ir) {
   ir_variable *const output_var = ((ir_instruction *) node)-as_variable();
diff --git a/src/glsl/linker.h b/src/glsl/linker.h
index 78c6329..669549b 100644
--- a/src/glsl/linker.h
+++ b/src/glsl/linker.h
@@ -30,6 +30,10 @@ extern bool
 link_function_calls(gl_shader_program *prog, gl_shader *main,
gl_shader **shader_list, unsigned num_shaders);
 
+extern void
+link_invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode,
+  int generic_base);
+
 /**
  * Class for processing all of the leaf fields of an uniform
  *
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 04/20] mesa: Make get_uniform available outside compilation unit

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Also rename to _mesa_get_uniform.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/main/uniforms.c |   14 +++---
 src/mesa/main/uniforms.h |4 
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index da8702a..89560a8 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -369,9 +369,9 @@ split_location_offset(GLint *location, GLint *offset)
 /**
  * Called via glGetUniform[fiui]v() to get the current value of a uniform.
  */
-static void
-get_uniform(struct gl_context *ctx, GLuint program, GLint location,
-GLsizei bufSize, GLenum returnType, GLvoid *paramsOut)
+void
+_mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
+ GLsizei bufSize, GLenum returnType, GLvoid *paramsOut)
 {
struct gl_shader_program *shProg =
   _mesa_lookup_shader_program_err(ctx, program, glGetUniformfv);
@@ -1343,7 +1343,7 @@ _mesa_GetnUniformfvARB(GLhandleARB program, GLint 
location,
GLsizei bufSize, GLfloat *params)
 {
GET_CURRENT_CONTEXT(ctx);
-   get_uniform(ctx, program, location, bufSize, GL_FLOAT, params);
+   _mesa_get_uniform(ctx, program, location, bufSize, GL_FLOAT, params);
 }
 
 void GLAPIENTRY
@@ -1358,7 +1358,7 @@ _mesa_GetnUniformivARB(GLhandleARB program, GLint 
location,
GLsizei bufSize, GLint *params)
 {
GET_CURRENT_CONTEXT(ctx);
-   get_uniform(ctx, program, location, bufSize, GL_INT, params);
+   _mesa_get_uniform(ctx, program, location, bufSize, GL_INT, params);
 }
 
 void GLAPIENTRY
@@ -1374,7 +1374,7 @@ _mesa_GetnUniformuivARB(GLhandleARB program, GLint 
location,
 GLsizei bufSize, GLuint *params)
 {
GET_CURRENT_CONTEXT(ctx);
-   get_uniform(ctx, program, location, bufSize, GL_UNSIGNED_INT, params);
+   _mesa_get_uniform(ctx, program, location, bufSize, GL_UNSIGNED_INT, params);
 }
 
 void GLAPIENTRY
@@ -1397,7 +1397,7 @@ _mesa_GetnUniformdvARB(GLhandleARB program, GLint 
location,
(void) params;
 
/*
-   get_uniform(ctx, program, location, bufSize, GL_DOUBLE, params);
+   _mesa_get_uniform(ctx, program, location, bufSize, GL_DOUBLE, params);
*/
_mesa_error(ctx, GL_INVALID_OPERATION, glGetUniformdvARB
(GL_ARB_gpu_shader_fp64 not implemented));
diff --git a/src/mesa/main/uniforms.h b/src/mesa/main/uniforms.h
index 77f55d4..5c1dded 100644
--- a/src/mesa/main/uniforms.h
+++ b/src/mesa/main/uniforms.h
@@ -184,6 +184,10 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct 
gl_shader_program *shProg,
  GLint location, GLsizei count,
  GLboolean transpose, const GLfloat *values);
 
+void
+_mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
+ GLsizei bufSize, GLenum returnType, GLvoid *paramsOut);
+
 extern void
 _mesa_update_shader_textures_used(struct gl_program *prog);
 
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 05/20] glsl: Add new structures for tracking uniforms in linked shaders

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/ir_uniform.h |  128 +
 1 files changed, 128 insertions(+), 0 deletions(-)
 create mode 100644 src/glsl/ir_uniform.h

diff --git a/src/glsl/ir_uniform.h b/src/glsl/ir_uniform.h
new file mode 100644
index 000..ba442f8
--- /dev/null
+++ b/src/glsl/ir_uniform.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+#pragma once
+#ifndef IR_UNIFORM_H
+#define IR_UNIFORM_H
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+#include program/prog_parameter.h  /* For union gl_constant_value. */
+
+enum gl_uniform_driver_format {
+   uniform_native = 0,  /** Store data in the native format. */
+   uniform_int_float,   /** Store integer data as floats. */
+   uniform_bool_float,  /** Store boolean data as floats. */
+
+   /**
+* Store boolean data as integer using 1 for \c true.
+*/
+   uniform_bool_int_0_1,
+
+   /**
+* Store boolean data as integer using ~0 for \c true.
+*/
+   uniform_bool_int_0_not0,
+};
+
+struct gl_uniform_driver_storage {
+   /**
+* Number of bytes from one array element to the next.
+*/
+   uint8_t element_stride;
+
+   /**
+* Number of bytes from one vector in a matrix to the next.
+*/
+   uint8_t vector_stride;
+
+   /**
+* Base format of the stored data.
+*
+* This field must have a value from \c GLSL_TYPE_UINT through \c
+* GLSL_TYPE_SAMPLER.
+*/
+   uint8_t format;
+
+   /**
+* Pointer to the base of the data.
+*/
+   void *data;
+};
+
+struct gl_uniform_storage {
+   char *name;
+   const struct glsl_type *type;
+
+   /**
+* The number of elements in this uniform.
+*
+* For non-arrays, this is always 0.  For arrays, the value is the size of
+* the array.
+*/
+   unsigned array_elements;
+
+   /**
+* Has this uniform ever been set?
+*/
+   unsigned initialized:1;
+
+   /**
+* Set each time the value of the uniform is change.
+*
+* Drivers that do not used the \c ::driver_storage interface should clear
+* this bit when the value of the uniform is updated on the hardware.
+*/
+   unsigned dirty:1;
+
+   /**
+* Base sampler index
+*
+* If \c ::base_type is \c GLSL_TYPE_SAMPLER, this represents the base
+* index of this sampler.
+*/
+   unsigned sampler:8;
+
+   /**
+* Storage used by the driver for the uniform
+*/
+   unsigned num_driver_storage;
+   struct gl_uniform_driver_storage *driver_storage;
+
+   /**
+* Storage used by Mesa for the uniform
+*
+* This form of the uniform is used by Mesa's implementation of \c
+* glGetUniform.  It can also be used by drivers to obtain the value of the
+* uniform if the \c ::driver_storage interface is not used.
+*/
+   union gl_constant_value *storage;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IR_UNIFORM_H */
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 07/20] mesa: Refactor parameter validate for GetUniform, Uniform, and UniformMatrix

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/main/uniforms.c |  142 +-
 1 files changed, 90 insertions(+), 52 deletions(-)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index f968d9b..2a5318d 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -35,7 +35,7 @@
  * 2. Insert FLUSH_VERTICES calls in various places
  */
 
-
+#include stdbool.h
 #include main/glheader.h
 #include main/context.h
 #include main/dispatch.h
@@ -317,6 +317,81 @@ get_uniform_rows_cols(const struct gl_program_parameter *p,
}
 }
 
+static bool
+validate_uniform_parameters(struct gl_context *ctx,
+   struct gl_shader_program *shProg,
+   GLint location, GLsizei count,
+   unsigned *loc,
+   unsigned *array_index,
+   const char *caller,
+   bool negative_one_is_not_valid)
+{
+   if (!shProg || !shProg-LinkStatus) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, %s(program not linked), caller);
+  return false;
+   }
+
+   if (location == -1) {
+  /* Page 264 (page 278 of the PDF) of the OpenGL 2.1 spec says:
+   *
+   * The error INVALID_OPERATION is generated if program has not been
+   * linked successfully, or if location is not a valid location for
+   * program.
+   *
+   * However, page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says:
+   *
+   * If the value of location is -1, the Uniform* commands will
+   * silently ignore the data passed in, and the current uniform
+   * values will not be changed.
+   *
+   * The negative_one_is_not_valid flag selects between the two behaviors.
+   */
+  if (negative_one_is_not_valid) {
+_mesa_error(ctx, GL_INVALID_OPERATION, %s(location=%d),
+caller, location);
+  }
+
+  return false;
+   }
+
+   /* From page 12 (page 26 of the PDF) of the OpenGL 2.1 spec:
+*
+* If a negative number is provided where an argument of type sizei or
+* sizeiptr is specified, the error INVALID_VALUE is generated.
+*/
+   if (count  0) {
+  _mesa_error(ctx, GL_INVALID_VALUE, %s(count  0), caller);
+  return false;
+   }
+
+   /* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says:
+*
+* If any of the following conditions occur, an INVALID_OPERATION
+* error is generated by the Uniform* commands, and no uniform values
+* are changed:
+*
+* ...
+*
+* - if no variable with a location of location exists in the
+*   program object currently in use and location is not -1,
+*/
+   if (location  -1) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, %s(location=%d),
+  caller, location);
+  return false;
+   }
+
+   _mesa_uniform_split_location_offset(location, loc, array_index);
+
+   if (*loc = shProg-Uniforms-NumUniforms) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, %s(location=%d),
+ caller, location);
+  return false;
+   }
+
+   return true;
+}
+
 /**
  * Called via glGetUniform[fiui]v() to get the current value of a uniform.
  */
@@ -327,14 +402,14 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, 
GLint location,
struct gl_shader_program *shProg =
   _mesa_lookup_shader_program_err(ctx, program, glGetUniformfv);
struct gl_program *prog;
-   GLint paramPos, offset;
+   GLint paramPos;
+   unsigned loc, offset;
 
-   if (!shProg)
+   if (!validate_uniform_parameters(ctx, shProg, location, 1,
+   loc, offset, glGetUniform, true))
   return;
 
-   _mesa_uniform_split_location_offset(location, location, offset);
-
-   if (!find_uniform_parameter_pos(shProg, location, prog, paramPos)) {
+   if (!find_uniform_parameter_pos(shProg, loc, prog, paramPos)) {
   _mesa_error(ctx, GL_INVALID_OPERATION,  glGetUniformfv(location));
}
else {
@@ -743,41 +818,20 @@ _mesa_uniform(struct gl_context *ctx, struct 
gl_shader_program *shProg,
   const GLvoid *values, GLenum type)
 {
struct gl_uniform *uniform;
-   GLint elems, offset;
+   GLint elems;
+   unsigned loc, offset;
 
ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (!shProg || !shProg-LinkStatus) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, glUniform(program not linked));
-  return;
-   }
-
-   if (location == -1)
-  return;   /* The standard specifies this as a no-op */
-
-   if (location  -1) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, glUniform(location=%d),
-  location);
-  return;
-   }
-
-   _mesa_uniform_split_location_offset(location, location, offset);
-
-   if (location  0 || location = (GLint) shProg-Uniforms-NumUniforms) {
-  _mesa_error(ctx, GL_INVALID_VALUE, 

[Mesa-dev] [PATCH 09/20] linker: Add helper class for determining uniform usage

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

This class could probably be named better.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/link_uniforms.cpp |   68 
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 6dd1f53..2de7165c 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -34,6 +34,21 @@
  * \author Ian Romanick ian.d.roman...@intel.com
  */
 
+/**
+ * Count the backing storage requirements for a type
+ */
+static unsigned
+values_for_type(const glsl_type *type)
+{
+   if (type-is_sampler()) {
+  return 1;
+   } else if (type-is_array()  type-fields.array-is_sampler()) {
+  return type-array_size();
+   } else {
+  return type-component_slots();
+   }
+}
+
 void
 uniform_field_visitor::process(ir_variable *var)
 {
@@ -83,3 +98,56 @@ uniform_field_visitor::recursion(const glsl_type *t, char 
**name,
   this-visit_field(t, *name);
}
 }
+
+/**
+ * Class to help calculate the storage requirements for a set of uniforms
+ *
+ * As uniforms are added to the active set the number of active uniforms and
+ * the storage requirements for those uniforms are accumulated.  The active
+ * uniforms are added the the hash table supplied to the constructor.
+ *
+ * If the same uniform is added multiple times (i.e., once for each shader
+ * target), it will only be accounted once.
+ */
+class count_uniform_usage : public uniform_field_visitor {
+public:
+   count_uniform_usage(struct string_to_uint_map *map)
+  : num_active_uniforms(0), num_values(0), map(map)
+   {
+  /* empty */
+   }
+
+   /**
+* Total number of active uniforms counted
+*/
+   unsigned num_active_uniforms;
+
+   /**
+* Number of data values required to back the storage for the active 
uniforms
+*/
+   unsigned num_values;
+
+private:
+   virtual void visit_field(const glsl_type *type, const char *name)
+   {
+  assert(!type-is_record());
+  assert(!(type-is_array()  type-fields.array-is_record()));
+
+  /* If the uniform is already in the map, there's nothing more to do.
+   */
+  unsigned id;
+  if (this-map-get(id, name))
+return;
+
+  char *key = strdup(name);
+  this-map-put(this-num_active_uniforms, key);
+
+  /* Each leaf uniform occupies one entry in the list of active
+   * uniforms.
+   */
+  this-num_active_uniforms++;
+  this-num_values += values_for_type(type);
+   }
+
+   struct string_to_uint_map *map;
+};
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 10/20] linker: Add helper class for parcelling out backing storage to uniforms

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/link_uniforms.cpp |   87 
 1 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 2de7165c..54af326 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -24,6 +24,7 @@
 #include main/core.h
 #include ir.h
 #include linker.h
+#include ir_uniform.h
 #include glsl_symbol_table.h
 #include program/hash_table.h
 
@@ -151,3 +152,89 @@ private:
 
struct string_to_uint_map *map;
 };
+
+/**
+ * Class to help parcel out pieces of backing storage to uniforms
+ *
+ * Each uniform processed has some range of the \c gl_constant_value
+ * structures associated with it.  The association is done by finding
+ * the uniform in the \c string_to_uint_map and using the value from
+ * the map to connect that slot in the \c gl_uniform_storage table
+ * with the next available slot in the \c gl_constant_value array.
+ *
+ * \warning
+ * This class assumes that every uniform that will be processed is
+ * already in the \c string_to_uint_map.  In addition, it assumes that
+ * the \c gl_uniform_storage and \c gl_constant_value arrays are big
+ * enough.
+ */
+class parcel_out_uniform_storage : public uniform_field_visitor {
+public:
+   parcel_out_uniform_storage(struct string_to_uint_map *map,
+ struct gl_uniform_storage *uniforms,
+ union gl_constant_value *values)
+  : map(map), uniforms(uniforms), next_sampler(0), values(values)
+   {
+  /* empty */
+   }
+
+private:
+   virtual void visit_field(const glsl_type *type, const char *name)
+   {
+  assert(!type-is_record());
+  assert(!(type-is_array()  type-fields.array-is_record()));
+
+  unsigned id;
+  bool found = this-map-get(id, name);
+  assert(found);
+
+  if (!found)
+return;
+
+  /* If there is already storage associated with this uniform, it means
+   * that it was set while processing an earlier shader stage.  For
+   * example, we may be processing the uniform in the fragment shader, but
+   * the uniform was already processed in the vertex shader.
+   */
+  if (this-uniforms[id].storage != NULL)
+return;
+
+  const glsl_type *base_type;
+  if (type-is_array()) {
+this-uniforms[id].array_elements = type-length;
+base_type = type-fields.array;
+  } else {
+this-uniforms[id].array_elements = 0;
+base_type = type;
+  }
+
+  if (base_type-is_sampler()) {
+this-uniforms[id].sampler = this-next_sampler;
+
+/* Increment the sampler by 1 for non-arrays and by the number of
+ * array elements for arrays.
+ */
+this-next_sampler += MAX2(1, this-uniforms[id].array_elements);
+  } else {
+this-uniforms[id].sampler = ~0;
+  }
+
+  this-uniforms[id].name = strdup(name);
+  this-uniforms[id].type = base_type;
+  this-uniforms[id].initialized = 0;
+  this-uniforms[id].dirty = 0;
+  this-uniforms[id].num_driver_storage = 0;
+  this-uniforms[id].driver_storage = NULL;
+  this-uniforms[id].storage = this-values;
+
+  this-values += values_for_type(type);
+   }
+
+   struct string_to_uint_map *map;
+
+   struct gl_uniform_storage *uniforms;
+   unsigned next_sampler;
+
+public:
+   union gl_constant_value *values;
+};
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 11/20] mesa: Add structures for new style uniform tracking in shader programs

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/main/mtypes.h |   25 +
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index aa3fa6a..d7314a2 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -77,6 +77,7 @@ struct gl_program_cache;
 struct gl_texture_object;
 struct gl_context;
 struct st_context;
+struct gl_uniform_storage;
 /*@}*/
 
 
@@ -2198,6 +2199,30 @@ struct gl_shader_program
} Vert;
 
/* post-link info: */
+   unsigned NumUserUniformStorage;
+   struct gl_uniform_storage *UniformStorage;
+
+   /**
+* Map of active uniform names to locations
+*
+* Maps any active uniform that is not an array element to a location.
+* Each active uniform, including individual structure members will appear
+* in this map.  This roughly corresponds to the set of names that would be
+* enumerated by \c glGetActiveUniform.
+*/
+   struct string_to_uint_map *UniformHash;
+
+   /**
+* Map from sampler unit to texture unit (set by glUniform1i())
+*
+* A sampler unit is associated with each sampler uniform by the linker.
+* The sampler unit associated with each uniform is stored in the
+* \c gl_uniform_storage::sampler field.
+*/
+   GLubyte SamplerUnits[MAX_SAMPLERS];
+   /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
+   gl_texture_index SamplerTargets[MAX_SAMPLERS];
+
struct gl_uniform_list *Uniforms;
struct gl_program_parameter_list *Varying;
GLboolean LinkStatus;   /** GL_LINK_STATUS */
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 12/20] linker: Track uniform locations to new tracking structures

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

This is just the infrastructure and the code.  It's not used yet.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/link_uniforms.cpp |   95 
 src/glsl/linker.h  |3 +
 2 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 54af326..a87e69f 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -238,3 +238,98 @@ private:
 public:
union gl_constant_value *values;
 };
+
+void
+link_assign_uniform_locations(struct gl_shader_program *prog)
+{
+   ralloc_free(prog-UniformStorage);
+   prog-UniformStorage = NULL;
+   prog-NumUserUniformStorage = 0;
+
+   if (prog-UniformHash != NULL) {
+  prog-UniformHash-clear();
+   } else {
+  prog-UniformHash = new string_to_uint_map;
+   }
+
+   for (unsigned i = 0; i  Elements(prog-SamplerUnits); i++) {
+  prog-SamplerUnits[i] = i;
+   }
+
+   /* First pass: Count the uniform resources used by the user-defined
+* uniforms.  While this happens, each active uniform will have an index
+* assined to it.
+*
+* Note: this is *NOT* the index that is returned to the application by
+* glGetUnfiormLocation.
+*/
+   count_uniform_usage usage(prog-UniformHash);
+   for (unsigned i = 0; i  MESA_SHADER_TYPES; i++) {
+  if (prog-_LinkedShaders[i] == NULL)
+continue;
+
+  foreach_list(node, prog-_LinkedShaders[i]-ir) {
+ir_variable *const var = ((ir_instruction *) node)-as_variable();
+
+if ((var == NULL) || (var-mode != ir_var_uniform))
+   continue;
+
+/* FINISHME: Update code to process built-in uniforms!
+ */
+if (strncmp(gl_, var-name, 3) == 0)
+   continue;
+
+usage.process(var);
+  }
+   }
+
+   const unsigned num_user_uniforms = usage.num_active_uniforms;
+   const unsigned num_data_slots = usage.num_values;
+
+   /* On the outside chance that there were no uniforms, bail out.
+*/
+   if (num_user_uniforms == 0)
+  return;
+
+   struct gl_uniform_storage *uniforms =
+  rzalloc_array(prog, struct gl_uniform_storage, num_user_uniforms);
+   union gl_constant_value *data =
+  rzalloc_array(uniforms, union gl_constant_value, num_data_slots);
+#ifndef NDEBUG
+   union gl_constant_value *data_end = data[num_data_slots];
+#endif
+
+   parcel_out_uniform_storage parcel(prog-UniformHash, uniforms, data);
+
+   for (unsigned i = 0; i  MESA_SHADER_TYPES; i++) {
+  if (prog-_LinkedShaders[i] == NULL)
+continue;
+
+  foreach_list(node, prog-_LinkedShaders[i]-ir) {
+ir_variable *const var = ((ir_instruction *) node)-as_variable();
+
+if ((var == NULL) || (var-mode != ir_var_uniform))
+   continue;
+
+/* FINISHME: Update code to process built-in uniforms!
+ */
+if (strncmp(gl_, var-name, 3) == 0)
+   continue;
+
+parcel.process(var);
+  }
+   }
+
+#ifndef NDEBUG
+   for (unsigned i = 0; i  num_user_uniforms; i++) {
+  assert(uniforms[i].storage != NULL);
+   }
+#endif
+
+   assert(parcel.values == data_end);
+
+   prog-NumUserUniformStorage = num_user_uniforms;
+   prog-UniformStorage = uniforms;
+
+   return;
+}
diff --git a/src/glsl/linker.h b/src/glsl/linker.h
index 669549b..433c63b 100644
--- a/src/glsl/linker.h
+++ b/src/glsl/linker.h
@@ -34,6 +34,9 @@ extern void
 link_invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode,
   int generic_base);
 
+extern void
+link_assign_uniform_locations(struct gl_shader_program *prog);
+
 /**
  * Class for processing all of the leaf fields of an uniform
  *
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 15/20] ir_to_mesa: Add _mesa_associate_uniform_storage

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Connects all of the gl_program_parameter structures with the correct
gl_uniform_storage structures.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/program/ir_to_mesa.cpp |   71 +++
 src/mesa/program/ir_to_mesa.h   |5 +++
 2 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 3935917..5bac511 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2696,6 +2696,77 @@ _mesa_generate_parameters_list_for_uniforms(struct 
gl_shader_program
}
 }
 
+void
+_mesa_associate_uniform_storage(struct gl_context *ctx,
+   struct gl_shader_program *shader_program,
+   struct gl_program_parameter_list *params)
+{
+   /* After adding each uniform to the parameter list, connect the storage for
+* the parameter with the tracking structure used by the API for the
+* uniform.
+*/
+   unsigned last_location = unsigned(~0);
+   for (unsigned i = 0; i  params-NumParameters; i++) {
+  if (params-Parameters[i].Type != PROGRAM_UNIFORM)
+continue;
+
+  unsigned location;
+  const bool found =
+shader_program-UniformHash-get(location, params-Parameters[i].Name);
+  assert(found);
+
+  if (!found)
+continue;
+
+  if (location != last_location) {
+struct gl_uniform_storage *storage =
+   shader_program-UniformStorage[location];
+enum gl_uniform_driver_format format = uniform_native;
+
+unsigned columns = 0;
+switch (storage-type-base_type) {
+case GLSL_TYPE_UINT:
+   assert(ctx-Const.NativeIntegers);
+   format = uniform_native;
+   columns = 1;
+   break;
+case GLSL_TYPE_INT:
+   format =
+  (ctx-Const.NativeIntegers) ? uniform_native : uniform_int_float;
+   columns = 1;
+   break;
+case GLSL_TYPE_FLOAT:
+   format = uniform_native;
+   columns = storage-type-matrix_columns;
+   break;
+case GLSL_TYPE_BOOL:
+   if (ctx-Const.NativeIntegers) {
+  format = (ctx-Const.UniformBooleanTrue == 1)
+ ? uniform_bool_int_0_1 : uniform_bool_int_0_not0;
+   } else {
+  format = uniform_bool_float;
+   }
+   columns = 1;
+   break;
+case GLSL_TYPE_SAMPLER:
+   format = uniform_native;
+   columns = 1;
+   break;
+default:
+   assert(!Should not get here.);
+   break;
+}
+
+_mesa_uniform_attach_driver_storage(storage,
+4 * sizeof(float) * columns,
+4 * sizeof(float),
+format,
+params-ParameterValues[i]);
+last_location = location;
+  }
+   }
+}
+
 static void
 set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
struct gl_shader_program *shader_program,
diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h
index d046b0f..2891682 100644
--- a/src/mesa/program/ir_to_mesa.h
+++ b/src/mesa/program/ir_to_mesa.h
@@ -45,4 +45,9 @@ _mesa_generate_parameters_list_for_uniforms(struct 
gl_shader_program
struct gl_shader *sh,
struct gl_program_parameter_list
*params);
+void
+_mesa_associate_uniform_storage(struct gl_context *ctx,
+   struct gl_shader_program *shader_program,
+   struct gl_program_parameter_list *params);
+
 #endif
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 16/20] mesa: Add log_uniform and log_program_parameters to dump data

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

These were both useful debugging aids while developing this code.
log_uniform will be used to keep the MESA_GLSL=uniform behavior.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/main/uniform_query.cpp |   72 +++
 1 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 1817164..db2f200 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -528,6 +528,78 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, 
GLint location,
}
 }
 
+static void
+log_uniform(const void *values, enum glsl_base_type basicType,
+   unsigned rows, unsigned cols, unsigned count,
+   bool transpose,
+   const struct gl_shader_program *shProg,
+   GLint location,
+   const struct gl_uniform_storage *uni)
+{
+
+   const union gl_constant_value *v = (const union gl_constant_value *) values;
+   const unsigned elems = rows * cols * count;
+   const char *const extra = (cols == 1) ? uniform : uniform matrix;
+
+   printf(Mesa: set program %u %s \%s\ (loc %d, type \%s\, 
+ transpose = %s) to: ,
+ shProg-Name, extra, uni-name, location, uni-type-name,
+ transpose ? true : false);
+   for (unsigned i = 0; i  elems; i++) {
+  if (i != 0  ((i % rows) == 0))
+printf(, );
+
+  switch (basicType) {
+  case GLSL_TYPE_UINT:
+printf(%u , v[i].u);
+break;
+  case GLSL_TYPE_INT:
+printf(%d , v[i].i);
+break;
+  case GLSL_TYPE_FLOAT:
+printf(%g , v[i].f);
+break;
+  default:
+assert(!Should not get here.);
+break;
+  }
+   }
+   printf(\n);
+   fflush(stdout);
+}
+
+#if 0
+static void
+log_program_parameters(const struct gl_shader_program *shProg)
+{
+   static const char *stages[] = {
+  vertex, fragment, geometry
+   };
+
+   assert(Elements(stages) == MESA_SHADER_TYPES);
+
+   for (unsigned i = 0; i  MESA_SHADER_TYPES; i++) {
+  if (shProg-_LinkedShaders[i] == NULL)
+continue;
+
+  const struct gl_program *const prog = shProg-_LinkedShaders[i]-Program;
+
+  printf(Program %d %s shader parameters:\n,
+shProg-Name, stages[i]);
+  for (unsigned j = 0; j  prog-Parameters-NumParameters; j++) {
+printf(%s: %p %f %f %f %f\n,
+   prog-Parameters-Parameters[j].Name,
+   prog-Parameters-ParameterValues[j],
+   prog-Parameters-ParameterValues[j][0].f,
+   prog-Parameters-ParameterValues[j][1].f,
+   prog-Parameters-ParameterValues[j][2].f,
+   prog-Parameters-ParameterValues[j][3].f);
+  }
+   }
+   fflush(stdout);
+}
+#endif
+
 /**
  * Check if the type given by userType is allowed to set a uniform of the
  * target type.  Generally, equivalence is required, but setting Boolean
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 17/20] i965: Move _mesa_ir_link_shader call before device-specific linking

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

_mesa_ir_link_shader needs to be called before cloning the IR tree so
that the var-location field for uniforms is set.

WARNING: This change breaks several integer division related piglit
tests.  The tests break because _mesa_ir_link_shader lowers integer
division to an RCP followed by a MUL.  The fix is to factor out more
of the code from ir_to_mesa so that _mesa_ir_link_shader does not need
to be called at all by the i965 driver.  This will be the subject of
several follow-on patches.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/drivers/dri/i965/brw_shader.cpp |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp 
b/src/mesa/drivers/dri/i965/brw_shader.cpp
index d9d9414..7679b6e 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -81,6 +81,9 @@ brw_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
struct intel_context *intel = brw-intel;
unsigned int stage;
 
+   if (!_mesa_ir_link_shader(ctx, prog))
+  return false;
+
for (stage = 0; stage  ARRAY_SIZE(prog-_LinkedShaders); stage++) {
   struct brw_shader *shader =
 (struct brw_shader *)prog-_LinkedShaders[stage];
@@ -148,9 +151,6 @@ brw_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
   ralloc_free(mem_ctx);
}
 
-   if (!_mesa_ir_link_shader(ctx, prog))
-  return false;
-
if (!brw_shader_precompile(ctx, prog))
   return false;
 
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 18/20] mesa: Rewrite the way uniforms are tracked and handled

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Switch all of the code in ir_to_mesa, st_glsl_to_tgsi, glUniform*,
glGetUniform, glGetUniformLocation, and glGetActiveUniforms to use the
gl_uniform_storage structures in the gl_shader_program.

A couple of notes:

 * Like most rewrite-the-world patches, this should be reviewed by
   applying the patch and examining the modified functions.

 * This leaves a lot of dead code around in linker.cpp and
   uniform_query.cpp.  This will be deleted in the next patches.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/linker.cpp|2 +-
 src/mesa/main/shaderapi.c  |   22 +-
 src/mesa/main/shaderobj.c  |   12 +-
 src/mesa/main/uniform_query.cpp|  627 +++-
 src/mesa/main/uniforms.c   |8 +-
 src/mesa/main/uniforms.h   |4 +-
 src/mesa/program/ir_to_mesa.cpp|   47 ++-
 src/mesa/program/sampler.cpp   |   12 +-
 src/mesa/state_tracker/st_draw.c   |   10 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   13 +-
 10 files changed, 505 insertions(+), 252 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 3d7bab8..b3374de 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1817,7 +1817,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 
update_array_sizes(prog);
-   assign_uniform_locations(prog);
+   link_assign_uniform_locations(prog);
 
/* OpenGL ES requires that a vertex shader and a fragment shader both be
 * present in a linked program.  By checking for use of shading language
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 6868dfa..b075002 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -51,6 +51,7 @@
 #include ralloc.h
 #include stdbool.h
 #include ../glsl/glsl_parser_extras.h
+#include ../glsl/ir_uniform.h
 
 /** Define this to enable shader substitution (see below) */
 #define SHADER_SUBST 0
@@ -571,13 +572,24 @@ get_programiv(struct gl_context *ctx, GLuint program, 
GLenum pname, GLint *param
   *params = _mesa_longest_attribute_name_length(shProg);
   break;
case GL_ACTIVE_UNIFORMS:
-  *params = shProg-Uniforms ? shProg-Uniforms-NumUniforms : 0;
+  *params = shProg-NumUserUniformStorage;
   break;
-   case GL_ACTIVE_UNIFORM_MAX_LENGTH:
-  *params = _mesa_longest_uniform_name(shProg-Uniforms);
-  if (*params  0)
- (*params)++;  /* add one for terminating zero */
+   case GL_ACTIVE_UNIFORM_MAX_LENGTH: {
+  unsigned i;
+  GLint max_len = 0;
+
+  for (i = 0; i  shProg-NumUserUniformStorage; i++) {
+/* Add one for the terminating NUL character.
+ */
+const GLint len = strlen(shProg-UniformStorage[i].name) + 1;
+
+if (len  max_len)
+   max_len = len;
+  }
+
+  *params = max_len;
   break;
+   }
case GL_PROGRAM_BINARY_LENGTH_OES:
   *params = 0;
   break;
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index ccf7efd..c0abc97 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -275,9 +275,15 @@ void
 _mesa_clear_shader_program_data(struct gl_context *ctx,
 struct gl_shader_program *shProg)
 {
-   if (shProg-Uniforms) {
-  _mesa_free_uniform_list(shProg-Uniforms);
-  shProg-Uniforms = NULL;
+   if (shProg-UniformStorage) {
+  ralloc_free(shProg-UniformStorage);
+  shProg-NumUserUniformStorage = 0;
+  shProg-UniformStorage = NULL;
+   }
+
+   if (shProg-UniformHash) {
+  string_to_uint_map_dtor(shProg-UniformHash);
+  shProg-UniformHash = NULL;
}
 
if (shProg-Varying) {
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index db2f200..50a724b 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -22,15 +22,16 @@
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
+#include stdlib.h
 #include main/core.h
 #include main/context.h
 #include ir.h
 #include ir_uniform.h
+#include program/hash_table.h
 #include ../glsl/program.h
 #include ../glsl/ir_uniform.h
 
 extern C {
-#include main/image.h
 #include main/shaderapi.h
 #include main/shaderobj.h
 #include uniforms.h
@@ -44,42 +45,30 @@ _mesa_GetActiveUniformARB(GLhandleARB program, GLuint index,
GET_CURRENT_CONTEXT(ctx);
struct gl_shader_program *shProg =
   _mesa_lookup_shader_program_err(ctx, program, glGetActiveUniform);
-   const struct gl_program_parameter *param;
 
if (!shProg)
   return;
 
-   if (!shProg-Uniforms || index = shProg-Uniforms-NumUniforms) {
+   if (index = shProg-NumUserUniformStorage) {
   _mesa_error(ctx, GL_INVALID_VALUE, glGetActiveUniform(index));
   return;
}
 
-   param = 

[Mesa-dev] [PATCH 19/20] mesa: Add missing check for glUniform*v count 1 on non-array

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/main/uniform_query.cpp |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 50a724b..96de541 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -389,6 +389,8 @@ validate_uniform_parameters(struct gl_context *ctx,
 *
 * - if no variable with a location of location exists in the
 *   program object currently in use and location is not -1,
+* - if count is greater than one, and the uniform declared in the
+*   shader is not an array variable,
 */
if (location  -1) {
   _mesa_error(ctx, GL_INVALID_OPERATION, %s(location=%d),
@@ -404,6 +406,13 @@ validate_uniform_parameters(struct gl_context *ctx,
   return false;
}
 
+   if (shProg-UniformStorage[*loc].array_elements == 0  count  1) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+ %s(count  1 for non-array, location=%d),
+ caller, location);
+  return false;
+   }
+
/* This case should be impossible.  The implication is that a call like
 * glGetUniformLocation(prog, foo[8]) was successful but foo is not an
 * array.
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 20/20] Delete code made dead by previous uniform related patches

2011-10-28 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/linker.cpp|  152 
 src/mesa/main/core.h   |1 -
 src/mesa/main/mtypes.h |1 -
 src/mesa/main/shaderapi.c  |1 -
 src/mesa/main/shaderobj.c  |1 -
 src/mesa/main/uniform_query.cpp|  530 
 src/mesa/program/ir_to_mesa.cpp|1 -
 src/mesa/program/prog_uniform.c|  103 --
 src/mesa/program/prog_uniform.h|   85 -
 src/mesa/sources.mak   |1 -
 src/mesa/state_tracker/st_draw.c   |1 -
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |1 -
 12 files changed, 0 insertions(+), 878 deletions(-)
 delete mode 100644 src/mesa/program/prog_uniform.c
 delete mode 100644 src/mesa/program/prog_uniform.h

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index b3374de..c18087c 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -980,13 +980,6 @@ link_intrastage_shaders(void *mem_ctx,
return linked;
 }
 
-
-struct uniform_node {
-   exec_node link;
-   struct gl_uniform *u;
-   unsigned slots;
-};
-
 /**
  * Update the sizes of linked shader uniform arrays to the maximum
  * array index used.
@@ -1059,151 +1052,6 @@ update_array_sizes(struct gl_shader_program *prog)
}
 }
 
-static void
-add_uniform(void *mem_ctx, exec_list *uniforms, struct hash_table *ht,
-   const char *name, const glsl_type *type, GLenum shader_type,
-   unsigned *next_shader_pos, unsigned *total_uniforms)
-{
-   if (type-is_record()) {
-  for (unsigned int i = 0; i  type-length; i++) {
-const glsl_type *field_type = type-fields.structure[i].type;
-char *field_name = ralloc_asprintf(mem_ctx, %s.%s, name,
-   type-fields.structure[i].name);
-
-add_uniform(mem_ctx, uniforms, ht, field_name, field_type,
-shader_type, next_shader_pos, total_uniforms);
-  }
-   } else {
-  uniform_node *n = (uniform_node *) hash_table_find(ht, name);
-  unsigned int vec4_slots;
-  const glsl_type *array_elem_type = NULL;
-
-  if (type-is_array()) {
-array_elem_type = type-fields.array;
-/* Array of structures. */
-if (array_elem_type-is_record()) {
-   for (unsigned int i = 0; i  type-length; i++) {
-  char *elem_name = ralloc_asprintf(mem_ctx, %s[%d], name, i);
-  add_uniform(mem_ctx, uniforms, ht, elem_name, array_elem_type,
-  shader_type, next_shader_pos, total_uniforms);
-   }
-   return;
-}
-  }
-
-  /* Fix the storage size of samplers at 1 vec4 each. Be sure to pad out
-   * vectors to vec4 slots.
-   */
-  if (type-is_array()) {
-if (array_elem_type-is_sampler())
-   vec4_slots = type-length;
-else
-   vec4_slots = type-length * array_elem_type-matrix_columns;
-  } else if (type-is_sampler()) {
-vec4_slots = 1;
-  } else {
-vec4_slots = type-matrix_columns;
-  }
-
-  if (n == NULL) {
-n = (uniform_node *) calloc(1, sizeof(struct uniform_node));
-n-u = (gl_uniform *) calloc(1, sizeof(struct gl_uniform));
-n-slots = vec4_slots;
-
-n-u-Name = strdup(name);
-n-u-Type = type;
-n-u-VertPos = -1;
-n-u-FragPos = -1;
-n-u-GeomPos = -1;
-(*total_uniforms)++;
-
-hash_table_insert(ht, n, name);
-uniforms-push_tail( n-link);
-  }
-
-  switch (shader_type) {
-  case GL_VERTEX_SHADER:
-n-u-VertPos = *next_shader_pos;
-break;
-  case GL_FRAGMENT_SHADER:
-n-u-FragPos = *next_shader_pos;
-break;
-  case GL_GEOMETRY_SHADER:
-n-u-GeomPos = *next_shader_pos;
-break;
-  }
-
-  (*next_shader_pos) += vec4_slots;
-   }
-}
-
-void
-assign_uniform_locations(struct gl_shader_program *prog)
-{
-   /* */
-   exec_list uniforms;
-   unsigned total_uniforms = 0;
-   hash_table *ht = hash_table_ctor(32, hash_table_string_hash,
-   hash_table_string_compare);
-   void *mem_ctx = ralloc_context(NULL);
-
-   for (unsigned i = 0; i  MESA_SHADER_TYPES; i++) {
-  if (prog-_LinkedShaders[i] == NULL)
-continue;
-
-  unsigned next_position = 0;
-
-  foreach_list(node, prog-_LinkedShaders[i]-ir) {
-ir_variable *const var = ((ir_instruction *) node)-as_variable();
-
-if ((var == NULL) || (var-mode != ir_var_uniform))
-   continue;
-
-if (strncmp(var-name, gl_, 3) == 0) {
-   /* At the moment, we don't allocate uniform locations for
-* builtin uniforms.  It's permitted by spec, and we'll
-* likely switch to doing that at some point, but not yet.
-*/
-  

Re: [Mesa-dev] mis-counting varying vars in the linker

2011-10-28 Thread Paul Berry
On 27 October 2011 10:20, Ian Romanick i...@freedesktop.org wrote:

 On 10/26/2011 11:11 AM, Brian Paul wrote:


 I think the linker is mis-counting gl_TexCoord[] varying vars when
 linking.

 For example, if we have this vertex/fragment shader combination:

 // vs
 void main()
 {
 gl_Position = ftransform();
 gl_TexCoord[6] = gl_MultiTexCoord[0];
 }

 // fs
 void main()
 {
 gl_Color = gl_TexCoord[6];
 }


 the varying_vectors counter in assign_varying_locations() will be 7, not
 1. It seems the gl_TexCoord var is being seen as an array of 7 elements
 and we're counting the whole array rather than the individual elements
 used.


 This is correct behavior.  Page 54 (page 60 of the PDF) of the GLSL 1.20
 spec says:

As with all arrays, indices used to subscript gl_TexCoord must
either be an integral constant expressions, or this array must
be re-declared by the shader with a size. The size can be at
most gl_MaxTextureCoords. Using indexes close to 0 may aid the
implementation in preserving varying resources.

 The last sentence is the most important bit.


  This is causing a link failure in an app here because the vs/fs shader
 pair uses several user-defined varying vars plus gl_TexCoord[4]. The
 varying count exceeds GL_MAX_VARYING_FLOATS even though we're really not
 using that many varying slots.


 We do have other problems with varyings that may be the actual cause of the
 failure.  We don't currently pack multiple variables into a vec4, so even
 using 17 float varyings will fail today.  This is the topic of bug #34201.

 I believe that Paul is going to work on this as part of his work to
 implement the new 1.30 interpolation qualifiers.  There were also some
 patches by Vincent Lejeune posted to the mesa-dev list a couple months ago.
  These patches had some significant issues, and Vincent never responded to
 the review comments.


FTR, I don't have any immediate plans to work on varying packing, since it's
not required to implement the new 1.30 interpolation qualifiers.  I may
tackle it in the long term, but I think I need to get my feet wet with some
simpler linker features first.



 I think this will need to be implemented in at least two parts. Something
 like Vincent's code should be used in the linker to pack varyings with
 identical interpolation modes.  This should cover 90% of cases.  Each driver
 will need some device-specific code to handle packing varyings with
 differing interpolation modes.  I don't know about other hardware, but it
 looks like i965-like GPUs will have some issues with mixing flat with
 either smooth or noperspective.  Mixing smooth and noperspective
 shouldn't be a problem, but the driver still needs to know that they've been
 mixed.

 __**_
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/**mailman/listinfo/mesa-devhttp://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] r600g: remove one pointless flush

2011-10-28 Thread Marek Olšák
I've got no idea what the flush was good for, but it's useless from
the looks of it. The rest of the patch is just a cleanup resulting
from some of the variables being no longer used for anything useful.

There are no piglit regressions.
---
 src/gallium/drivers/r600/r600.h|6 +-
 src/gallium/drivers/r600/r600_blit.c   |2 +-
 src/gallium/drivers/r600/r600_hw_context.c |   21 ++---
 3 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index f58549a..9367651 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -176,10 +176,6 @@ struct r600_query {
unsignedresults_end;
/* Size of the result */
unsignedresult_size;
-   /* Count of new queries started in one stream without flushing */
-   unsignedqueries_emitted;
-   /* State flags */
-   boolean flushed;
/* The buffer where query results are stored. It's used as a ring,
 * data blocks for current query are stored sequentially from
 * results_start to results_end, with wrapping on the buffer end */
@@ -258,7 +254,7 @@ boolean r600_context_query_result(struct r600_context *ctx,
 void r600_query_begin(struct r600_context *ctx, struct r600_query *query);
 void r600_query_end(struct r600_context *ctx, struct r600_query *query);
 void r600_context_queries_suspend(struct r600_context *ctx);
-void r600_context_queries_resume(struct r600_context *ctx, boolean flushed);
+void r600_context_queries_resume(struct r600_context *ctx);
 void r600_query_predication(struct r600_context *ctx, struct r600_query 
*query, int operation,
int flag_wait);
 void r600_context_emit_fence(struct r600_context *ctx, struct r600_resource 
*fence,
diff --git a/src/gallium/drivers/r600/r600_blit.c 
b/src/gallium/drivers/r600/r600_blit.c
index 3eba0ad..9326dc6 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -96,7 +96,7 @@ static void r600_blitter_end(struct pipe_context *ctx)
   rctx-saved_render_cond_mode);
rctx-saved_render_cond = NULL;
}
-   r600_context_queries_resume(rctx-ctx, FALSE);
+   r600_context_queries_resume(rctx-ctx);
 }
 
 static unsigned u_num_layers(struct pipe_resource *r, unsigned level)
diff --git a/src/gallium/drivers/r600/r600_hw_context.c 
b/src/gallium/drivers/r600/r600_hw_context.c
index a7d7ce6..1332748 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -1521,7 +1521,7 @@ void r600_context_flush(struct r600_context *ctx, 
unsigned flags)
r600_init_cs(ctx);
 
/* resume queries */
-   r600_context_queries_resume(ctx, TRUE);
+   r600_context_queries_resume(ctx);
 
/* set all valid group as dirty so they get reemited on
 * next draw command
@@ -1619,18 +1619,6 @@ void r600_query_begin(struct r600_context *ctx, struct 
r600_query *query)
r600_context_flush(ctx, RADEON_FLUSH_ASYNC);
}
 
-   if (query-type == PIPE_QUERY_OCCLUSION_COUNTER) {
-   /* Count queries emitted without flushes, and flush if more than
-* half of buffer used, to avoid overwriting results which may 
be
-* still in use. */
-   if (query-flushed) {
-   query-queries_emitted = 1;
-   } else {
-   if (++query-queries_emitted  
query-buffer-b.b.b.width0 / query-result_size / 2)
-   r600_context_flush(ctx, RADEON_FLUSH_ASYNC);
-   }
-   }
-
new_results_end = query-results_end + query-result_size;
if (new_results_end = query-buffer-b.b.b.width0)
new_results_end = 0;
@@ -1713,8 +1701,6 @@ void r600_query_end(struct r600_context *ctx, struct 
r600_query *query)
if (query-results_end = query-buffer-b.b.b.width0)
query-results_end = 0;
 
-   query-flushed = FALSE;
-
ctx-num_query_running--;
 }
 
@@ -1842,14 +1828,11 @@ void r600_context_queries_suspend(struct r600_context 
*ctx)
}
 }
 
-void r600_context_queries_resume(struct r600_context *ctx, boolean flushed)
+void r600_context_queries_resume(struct r600_context *ctx)
 {
struct r600_query *query;
 
LIST_FOR_EACH_ENTRY(query, ctx-active_query_list, list) {
-   if (flushed)
-   query-flushed = TRUE;
-
r600_query_begin(ctx, query);
}
 }
-- 
1.7.4.1

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


[Mesa-dev] [PATCH] mesa/st: get interpolation mode from the fragment shader.

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

With the recent changes to interpolation stuff, we can now get the value
direct from the program instead of just being fail.

fixes some of the glsl-1.30 interpolation tests with softpipe

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/mesa/state_tracker/st_program.c |   15 ++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/mesa/state_tracker/st_program.c 
b/src/mesa/state_tracker/st_program.c
index c419c40..023879d 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -416,6 +416,19 @@ st_get_vp_variant(struct st_context *st,
return vpv;
 }
 
+static int st_translate_interp(enum glsl_interp_qualifier glsl_qual)
+{
+   switch (glsl_qual) {
+   case INTERP_QUALIFIER_NONE:
+   case INTERP_QUALIFIER_SMOOTH:
+  return TGSI_INTERPOLATE_PERSPECTIVE;
+   case INTERP_QUALIFIER_FLAT:
+  return TGSI_INTERPOLATE_CONSTANT;
+   case INTERP_QUALIFIER_NOPERSPECTIVE:
+  return TGSI_INTERPOLATE_LINEAR;
+   }
+   assert(0);
+}
 
 /**
  * Translate a Mesa fragment shader into a TGSI shader using extra info in
@@ -558,7 +571,7 @@ st_translate_fragment_program(struct st_context *st,
if (attr == FRAG_ATTRIB_PNTC)
   interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
else
-  interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
+  interpMode[slot] = 
st_translate_interp(stfp-Base.InterpQualifier[attr]);
break;
 }
  }
-- 
1.7.6.4

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


Re: [Mesa-dev] [PATCH 2/5] glsl: Extend s-expression parsing to handle infinity.

2011-10-28 Thread Paul Berry
On 27 October 2011 20:13, Kenneth Graunke kenn...@whitecape.org wrote:

 On 10/26/2011 06:42 PM, Paul Berry wrote:
  In order to implement the GLSL 1.30 isinf() function, it will be
  necessary to be able to represent infinity in the GLSL IR s-expression
  format.  This patch extends the s-expression parser so that it treats
  the string #inf as a floating point value representing positive
  infinity.
  ---
   src/glsl/s_expression.cpp |   33 +++--
   1 files changed, 19 insertions(+), 14 deletions(-)

 Two kind of stupid comments:

 Scheme represents infinity as +inf.0 or -inf.0 and NaN as +nan.0.  If
 you wanted to be more Scheme-like, you could do that (and also gain a
 representation of -infinity if you wanted...)

 Also...strtod() already accepts INF/INFINITY and NAN for these
 cases.  Which actually kind of sucks because somebody could totally name
 their variables that (unlike #inf or +inf.0).


Interesting, I wasn't aware of that.  According to
http://pubs.opengroup.org/onlinepubs/007904975/functions/strtod.html,
+INFINITY and +INF are also allowed as a representation of infinity;
likewise for +NAN.



 That should be fixed someday.  But there are a lot of things the reader
 can't do (like structs), so...not terribly important.  It works well
 enough for now and we can always fix it when it actually matters.


Agreed.  In particular, if we ever decide to use the s-expression IR
representation to support ARB_get_program_binary, we'll need to fix this.
I'll put a comment in the function as a reminder.



 So, I guess you've got a few options:
 1. Keep patch as is (#inf)
 2. Switch to +inf.0, -inf.0, +nan.0 to be like Scheme
 3. Drop this patch and just use INFINITY in the built-in files.


Ok, I'm now favoring a fourth option:

4. drop this patch and use +INF in the built-in files.

That has the advantage that it can't be confused with a variable name.

I was going to push the patch series today, but I'm not in any rush.  I'll
leave it open for another day in case anyone else wants to comment.  If no
one comments by Monday I'll go with option 4.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Use the actual hardware g0 register for texel offset setup.

2011-10-28 Thread Eric Anholt
On Thu, 27 Oct 2011 10:49:14 -0700, Kenneth Graunke kenn...@whitecape.org 
wrote:
 The idea here is to set up the message header with the Sampler State
 pointer which the hardware provides as part of the PS Thread Payload in
 register g0.
 
 Unfortunately, the existing code
 
fs_reg(GRF, 0, BRW_REGISTER_TYPE_UD))
 
 actually references virtual GRF 0 rather than the hardware g0.  This
 is just some arbitrary GRF temporary which will get register allocated.
 
 So, we ended up setting up the header with garbage.
 
 Signed-off-by: Kenneth Graunke kenn...@whitecape.org

Reviewed-by: Eric Anholt e...@anholt.net



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


[Mesa-dev] Renderbuffer mapping

2011-10-28 Thread Eric Anholt
The non-intel/swrast code is not tested.  I don't have the hardware,
now that r300 is gone.

One the intel side, there's one regression on the last commit of the
series, in gles2 conformance (I wouldn't push that commit until it's
fixed).  I haven't tracked it down yet -- I can't even figure out how
to see the images from GTF any more.

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


[Mesa-dev] [PATCH 04/24] intel: Use MapRenderbuffer in spans setup.

2011-10-28 Thread Eric Anholt
---
 src/mesa/drivers/dri/intel/intel_span.c |   33 +-
 1 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_span.c 
b/src/mesa/drivers/dri/intel/intel_span.c
index bdc4a0e..ecccd30 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -221,7 +221,10 @@ intel_offset_S8(uint32_t stride, uint32_t x, uint32_t y)
 void
 intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb)
 {
+   struct gl_context *ctx = intel-ctx;
struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+   GLubyte *map;
+   int stride;
 
if (!irb)
   return;
@@ -231,25 +234,11 @@ intel_renderbuffer_map(struct intel_context *intel, 
struct gl_renderbuffer *rb)
if (irb-wrapped_stencil)
   intel_renderbuffer_map(intel, irb-wrapped_stencil);
 
-   if (!irb-region)
-  return;
-
-   drm_intel_gem_bo_map_gtt(irb-region-bo);
-
-   rb-Data = irb-region-bo-virtual;
-   rb-RowStride = irb-region-pitch;
-
-   if (!rb-Name) {
-  /* Flip orientation of the window system buffer */
-  rb-Data += rb-RowStride * (irb-region-height - 1) * irb-region-cpp;
-  rb-RowStride = -rb-RowStride;
-   } else {
-  /* Adjust the base pointer of a texture image drawbuffer to the image
-   * within the miptree region (all else has draw_x/y = 0).
-   */
-  rb-Data += irb-draw_x * irb-region-cpp;
-  rb-Data += irb-draw_y * rb-RowStride * irb-region-cpp;
-   }
+   ctx-Driver.MapRenderbuffer(ctx, rb, 0, 0, rb-Width, rb-Height,
+  GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
+  map, stride);
+   rb-Data = map;
+   rb-RowStride = stride / _mesa_get_format_bytes(rb-Format);
 
intel_set_span_functions(intel, rb);
 }
@@ -258,6 +247,7 @@ void
 intel_renderbuffer_unmap(struct intel_context *intel,
 struct gl_renderbuffer *rb)
 {
+   struct gl_context *ctx = intel-ctx;
struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
if (!irb)
@@ -268,10 +258,7 @@ intel_renderbuffer_unmap(struct intel_context *intel,
if (irb-wrapped_stencil)
   intel_renderbuffer_unmap(intel, irb-wrapped_stencil);
 
-   if (!irb-region)
-  return;
-
-   drm_intel_gem_bo_unmap_gtt(irb-region-bo);
+   ctx-Driver.UnmapRenderbuffer(ctx, rb);
 
rb-GetRow = NULL;
rb-PutRow = NULL;
-- 
1.7.7

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


[Mesa-dev] [PATCH 03/24] intel: Add an implementation of MapRenderbuffer.

2011-10-28 Thread Eric Anholt
---
 src/mesa/drivers/dri/intel/intel_fbo.c |   55 
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c 
b/src/mesa/drivers/dri/intel/intel_fbo.c
index 4537f1f..c9a1df5 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -83,6 +83,59 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb)
free(irb);
 }
 
+static void
+intel_map_renderbuffer(struct gl_context *ctx,
+  struct gl_renderbuffer *rb,
+  GLuint x, GLuint y, GLuint w, GLuint h,
+  GLbitfield mode,
+  GLubyte **out_map,
+  GLint *out_stride)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+   GLubyte *map;
+   int stride;
+
+   /* We sometimes get called with this by our intel_span.c usage. */
+   if (!irb-region) {
+  *out_map = NULL;
+  *out_stride = 0;
+  return;
+   }
+
+   if (drm_intel_bo_references(intel-batch.bo, irb-region-bo)) {
+  intel_batchbuffer_flush(intel);
+   }
+
+   drm_intel_gem_bo_map_gtt(irb-region-bo);
+
+   map = irb-region-bo-virtual;
+   stride = irb-region-pitch * irb-region-cpp;
+
+   if (rb-Name == 0) {
+  map += stride * (irb-region-height - 1);
+  stride = -stride;
+   } else {
+  map += irb-draw_x * irb-region-cpp;
+  map += (int)irb-draw_y * stride;
+   }
+
+   map += x * irb-region-cpp;
+   map += (int)y * stride;
+
+   *out_map = map;
+   *out_stride = stride;
+}
+
+static void
+intel_unmap_renderbuffer(struct gl_context *ctx,
+struct gl_renderbuffer *rb)
+{
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+   if (irb-region)
+  drm_intel_gem_bo_unmap_gtt(irb-region-bo);
+}
 
 /**
  * Return a pointer to a specific pixel in a renderbuffer.
@@ -938,6 +991,8 @@ intel_fbo_init(struct intel_context *intel)
 {
intel-ctx.Driver.NewFramebuffer = intel_new_framebuffer;
intel-ctx.Driver.NewRenderbuffer = intel_new_renderbuffer;
+   intel-ctx.Driver.MapRenderbuffer = intel_map_renderbuffer;
+   intel-ctx.Driver.UnmapRenderbuffer = intel_unmap_renderbuffer;
intel-ctx.Driver.BindFramebuffer = intel_bind_framebuffer;
intel-ctx.Driver.FramebufferRenderbuffer = intel_framebuffer_renderbuffer;
intel-ctx.Driver.RenderTexture = intel_render_texture;
-- 
1.7.7

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


[Mesa-dev] [PATCH 01/24] mesa: Add a driver hook for mapping renderbuffers.

2011-10-28 Thread Eric Anholt
---
 src/mesa/main/dd.h |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 8607008..d6cbcf1 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -514,6 +514,15 @@ struct dd_function_table {
/** Unmap texture images from user space */
void (*UnmapTexture)( struct gl_context *ctx, struct gl_texture_object 
*tObj );
 
+   void (*MapRenderbuffer)(struct gl_context *ctx,
+  struct gl_renderbuffer *rb,
+  GLuint x, GLuint y, GLuint w, GLuint h,
+  GLbitfield mode,
+  GLubyte **mapOut, GLint *rowStrideOut);
+
+   void (*UnmapRenderbuffer)(struct gl_context *ctx,
+struct gl_renderbuffer *rb);
+
/**
 * Note: no context argument.  This function doesn't initially look
 * like it belongs here, except that the driver is the only entity
-- 
1.7.7

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


[Mesa-dev] [PATCH 02/24] Add MapRenderbuffer implementations for software drivers.

2011-10-28 Thread Eric Anholt
Mesa core's is generic for things like osmesa.

For swrast_dri.so, we have to do Y flipping.  The front-buffer path
isn't actually tested, though, because both before and after it fails
with a BadMatch in XGetImage.
---
 src/mesa/drivers/common/driverfuncs.c |2 +
 src/mesa/drivers/dri/swrast/swrast.c  |   84 +++--
 src/mesa/drivers/dri/swrast/swrast_priv.h |5 ++
 src/mesa/main/renderbuffer.c  |   27 +
 src/mesa/main/renderbuffer.h  |   12 
 src/mesa/swrast/s_texrender.c |1 +
 6 files changed, 127 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 263d402..42259f8 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -179,6 +179,8 @@ _mesa_init_driver_functions(struct dd_function_table 
*driver)
 
driver-NewFramebuffer = _mesa_new_framebuffer;
driver-NewRenderbuffer = _mesa_new_soft_renderbuffer;
+   driver-MapRenderbuffer = _mesa_map_soft_renderbuffer;
+   driver-UnmapRenderbuffer = _mesa_unmap_soft_renderbuffer;
driver-RenderTexture = _swrast_render_texture;
driver-FinishRenderTexture = _swrast_finish_render_texture;
driver-FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
diff --git a/src/mesa/drivers/dri/swrast/swrast.c 
b/src/mesa/drivers/dri/swrast/swrast.c
index 75d2525..bc115e8 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -291,7 +291,7 @@ swrast_alloc_front_storage(struct gl_context *ctx, struct 
gl_renderbuffer *rb,
 rb-Data = NULL;
 rb-Width = width;
 rb-Height = height;
-
+rb-RowStride = width;
 xrb-pitch = bytes_per_line(width * xrb-bpp, 32);
 
 return GL_TRUE;
@@ -315,7 +315,8 @@ swrast_alloc_back_storage(struct gl_context *ctx, struct 
gl_renderbuffer *rb,
 }
 
 static struct swrast_renderbuffer *
-swrast_new_renderbuffer(const struct gl_config *visual, GLboolean front)
+swrast_new_renderbuffer(const struct gl_config *visual, __DRIdrawable *dPriv,
+   GLboolean front)
 {
 struct swrast_renderbuffer *xrb = calloc(1, sizeof *xrb);
 GLuint pixel_format;
@@ -329,6 +330,7 @@ swrast_new_renderbuffer(const struct gl_config *visual, 
GLboolean front)
 
 pixel_format = choose_pixel_format(visual);
 
+xrb-dPriv = dPriv;
 xrb-Base.Delete = swrast_delete_renderbuffer;
 if (front) {
xrb-Base.AllocStorage = swrast_alloc_front_storage;
@@ -375,6 +377,78 @@ swrast_new_renderbuffer(const struct gl_config *visual, 
GLboolean front)
 return xrb;
 }
 
+static void
+swrast_map_renderbuffer(struct gl_context *ctx,
+   struct gl_renderbuffer *rb,
+   GLuint x, GLuint y, GLuint w, GLuint h,
+   GLbitfield mode,
+   GLubyte **out_map,
+   GLint *out_stride)
+{
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+   GLubyte *map = rb-Data;
+   int cpp = _mesa_get_format_bytes(rb-Format);
+   int stride = rb-RowStride * cpp;
+
+   if (rb-AllocStorage == swrast_alloc_front_storage) {
+  __DRIdrawable *dPriv = xrb-dPriv;
+  __DRIscreen *sPriv = dPriv-driScreenPriv;
+
+  xrb-map_mode = mode;
+  xrb-map_x = x;
+  xrb-map_y = y;
+  xrb-map_w = w;
+  xrb-map_h = h;
+
+  stride = w * cpp;
+  rb-Data = malloc(h * stride);
+
+  sPriv-swrast_loader-getImage(dPriv, x, y, w, h,
+(char *)rb-Data,
+dPriv-loaderPrivate);
+
+  *out_map = rb-Data;
+  *out_stride = stride;
+  return;
+   }
+
+   ASSERT(rb-Data);
+
+   if (rb-AllocStorage == swrast_alloc_back_storage) {
+  map += (rb-Height - 1) * stride;
+  stride = -stride;
+   }
+
+   map += y * stride;
+   map += x * cpp;
+
+   *out_map = map;
+   *out_stride = stride;
+}
+
+static void
+swrast_unmap_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+
+   if (rb-AllocStorage == swrast_alloc_front_storage) {
+  __DRIdrawable *dPriv = xrb-dPriv;
+  __DRIscreen *sPriv = dPriv-driScreenPriv;
+
+  if (xrb-map_mode  GL_MAP_WRITE_BIT) {
+sPriv-swrast_loader-putImage(dPriv, __DRI_SWRAST_IMAGE_OP_DRAW,
+   xrb-map_x, xrb-map_y,
+   xrb-map_w, xrb-map_h,
+   rb-Data,
+   dPriv-loaderPrivate);
+  }
+
+  free(rb-Data);
+  rb-Data = NULL;
+   }
+}
+
 static GLboolean
 dri_create_buffer(__DRIscreen * sPriv,
  __DRIdrawable * dPriv,
@@ -406,12 +480,12 @@ dri_create_buffer(__DRIscreen * sPriv,
 _mesa_initialize_window_framebuffer(fb, visual);
 
 /* add front renderbuffer */
-frontrb = 

[Mesa-dev] [PATCH 06/24] nouveau: Add implementation of MapRenderbuffer.

2011-10-28 Thread Eric Anholt
Perhaps the easiest implementation, nouveau can directly map buffers
even if tiled, and uses separate surfaces for its texture
renderbuffers so we don't have to worry about that offset.
---
 src/mesa/drivers/dri/nouveau/nouveau_fbo.c |   46 
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c 
b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
index b36b578..d56e954 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
@@ -133,6 +133,50 @@ nouveau_renderbuffer_new(struct gl_context *ctx, GLuint 
name)
return rb;
 }
 
+static void
+nouveau_renderbuffer_map(struct gl_context *ctx,
+struct gl_renderbuffer *rb,
+GLuint x, GLuint y, GLuint w, GLuint h,
+GLbitfield mode,
+GLubyte **out_map,
+GLint *out_stride)
+{
+   struct nouveau_surface *s = to_nouveau_renderbuffer(rb)-surface;
+   GLubyte *map;
+   int stride;
+   int flags = 0;
+
+   if (mode  GL_MAP_READ_BIT)
+   flags |= NOUVEAU_BO_RD;
+   if (mode  GL_MAP_WRITE_BIT)
+   flags |= NOUVEAU_BO_WR;
+
+   nouveau_bo_map(s-bo, flags);
+
+   map = s-bo-map;
+   stride = s-pitch;
+
+   if (rb-Name == 0) {
+   map += stride * (rb-Height - 1);
+   stride = -stride;
+   }
+
+   map += x * s-cpp;
+   map += (int)y * stride;
+
+   *out_map = map;
+   *out_stride = stride;
+}
+
+static void
+nouveau_renderbuffer_unmap(struct gl_context *ctx,
+  struct gl_renderbuffer *rb)
+{
+   struct nouveau_surface *s = to_nouveau_renderbuffer(rb)-surface;
+
+   nouveau_bo_unmap(s-bo);
+}
+
 static GLboolean
 nouveau_renderbuffer_dri_storage(struct gl_context *ctx, struct 
gl_renderbuffer *rb,
 GLenum internalFormat,
@@ -268,6 +312,8 @@ nouveau_fbo_functions_init(struct dd_function_table 
*functions)
 #if FEATURE_EXT_framebuffer_object
functions-NewFramebuffer = nouveau_framebuffer_new;
functions-NewRenderbuffer = nouveau_renderbuffer_new;
+   functions-MapRenderbuffer = nouveau_renderbuffer_map;
+   functions-UnmapRenderbuffer = nouveau_renderbuffer_unmap;
functions-BindFramebuffer = nouveau_bind_framebuffer;
functions-FramebufferRenderbuffer = nouveau_framebuffer_renderbuffer;
functions-RenderTexture = nouveau_render_texture;
-- 
1.7.7

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


[Mesa-dev] [PATCH 09/24] swrast: Directly map the stencil buffer in read_stencil_pixels.

2011-10-28 Thread Eric Anholt
This avoids going through the wrapper that has to rewrite the data for
packed depth/stencil.  This isn't done in _swrast_read_stencil_span
because we don't want to map/unmap for each span.
---
 src/mesa/swrast/s_readpix.c |   43 +++
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 187c27e..4ecb5b8 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -142,8 +142,10 @@ read_stencil_pixels( struct gl_context *ctx,
  const struct gl_pixelstore_attrib *packing )
 {
struct gl_framebuffer *fb = ctx-ReadBuffer;
-   struct gl_renderbuffer *rb = fb-_StencilBuffer;
-   GLint j;
+   struct gl_renderbuffer *rb = fb-Attachment[BUFFER_STENCIL].Renderbuffer;
+   GLint j, i;
+   GLubyte *map;
+   GLint stride;
 
if (!rb)
   return;
@@ -151,18 +153,51 @@ read_stencil_pixels( struct gl_context *ctx,
/* width should never be  MAX_WIDTH since we did clipping earlier */
ASSERT(width = MAX_WIDTH);
 
+   ctx-Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT,
+  map, stride);
+
/* process image row by row */
-   for (j=0;jheight;j++,y++) {
+   for (j = 0; j  height; j++) {
   GLvoid *dest;
   GLstencil stencil[MAX_WIDTH];
 
-  _swrast_read_stencil_span(ctx, rb, width, x, y, stencil);
+  switch (rb-Format) {
+
+  case MESA_FORMAT_S8_Z24: {
+uint32_t *data = (uint32_t *)map;
+for (i = 0; i  width; i++)
+   stencil[i] = data[i]  24;
+break;
+  }
+
+  case MESA_FORMAT_Z24_S8: {
+uint32_t *data = (uint32_t *)map;
+for (i = 0; i  width; i++)
+   stencil[i] = data[i]  0xff;
+break;
+  }
+
+  case MESA_FORMAT_S8:
+for (i = 0; i  width; i++)
+   stencil[i] = map[i];
+break;
+
+  default:
+_mesa_problem(ctx, Unknown format %s in %s\n,
+  _mesa_get_format_name(rb-Format), __FUNCTION__);
+memset(stencil, 0, MAX_WIDTH);
+break;
+  }
 
   dest = _mesa_image_address2d(packing, pixels, width, height,
GL_STENCIL_INDEX, type, j, 0);
 
   _mesa_pack_stencil_span(ctx, width, type, dest, stencil, packing);
+
+  map += stride;
}
+
+   ctx-Driver.UnmapRenderbuffer(ctx, rb);
 }
 
 
-- 
1.7.7

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


[Mesa-dev] [PATCH 07/24] mesa: Make unpack_uint_z_row return 32 bits of data.

2011-10-28 Thread Eric Anholt
Some of the return values were u32, some were 24 bits, and z16
returned 16 bits.  The caller would have to do all the work of
interpreting the format all over again.  However, there are no callers
of this function at this point.
---
 src/mesa/main/format_unpack.c |   35 ++-
 1 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 2051f68..adec7d7 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1415,37 +1415,26 @@ _mesa_unpack_float_z_row(gl_format format, GLuint n,
 typedef void (*unpack_uint_z_func)(const void *src, GLuint *dst);
 
 static void
-unpack_uint_z_Z24_S8(const void *src, GLuint *dst)
+unpack_uint_z_Z24_X8(const void *src, GLuint *dst)
 {
/* only return Z, not stencil data */
const GLuint s = *((const GLuint *) src);
-   *dst = (s  8);
+   *dst = (s  0xff00) | (s  24);;
 }
 
 static void
-unpack_uint_z_S8_Z24(const void *src, GLuint *dst)
+unpack_uint_z_X8_Z24(const void *src, GLuint *dst)
 {
/* only return Z, not stencil data */
const GLuint s = *((const GLuint *) src);
-   *dst = s  0x00ff;
+   *dst = (s  8) | ((s  16)  0xff);
 }
 
 static void
 unpack_uint_z_Z16(const void *src, GLuint *dst)
 {
-   *dst = *((const GLushort *) src);
-}
-
-static void
-unpack_uint_z_X8_Z24(const void *src, GLuint *dst)
-{
-   unpack_uint_z_S8_Z24(src, dst);
-}
-
-static void
-unpack_uint_z_Z24_X8(const void *src, GLuint *dst)
-{
-   unpack_uint_z_Z24_S8(src, dst);
+   const GLushort s = *((const GLushort *)src);
+   *dst = (s  16) | s;
 }
 
 static void
@@ -1466,19 +1455,15 @@ _mesa_unpack_uint_z_row(gl_format format, GLuint n,
 
switch (format) {
case MESA_FORMAT_Z24_S8:
-  unpack = unpack_uint_z_Z24_S8;
+   case MESA_FORMAT_Z24_X8:
+  unpack = unpack_uint_z_Z24_X8;
   break;
case MESA_FORMAT_S8_Z24:
-  unpack = unpack_uint_z_S8_Z24;
-  break;
-   case MESA_FORMAT_Z16:
-  unpack = unpack_uint_z_Z16;
-  break;
case MESA_FORMAT_X8_Z24:
   unpack = unpack_uint_z_X8_Z24;
   break;
-   case MESA_FORMAT_Z24_X8:
-  unpack = unpack_uint_z_Z24_X8;
+   case MESA_FORMAT_Z16:
+  unpack = unpack_uint_z_Z16;
   break;
case MESA_FORMAT_Z32:
   unpack = unpack_uint_z_Z32;
-- 
1.7.7

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


[Mesa-dev] [PATCH 05/24] radeon: Add implementation of MapRenderbuffer.

2011-10-28 Thread Eric Anholt
Unlike intel, we do a blit to/from GTT memory in order to
untile/retile the renderbuffer data, since we don't have fence
registers for accessing it.

(There is software tiling code in radeon_tile.c, but it's unused and
doesn't support macro tiling)
---
 .../drivers/dri/radeon/radeon_common_context.h |4 +
 src/mesa/drivers/dri/radeon/radeon_fbo.c   |   94 
 2 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h 
b/src/mesa/drivers/dri/radeon/radeon_common_context.h
index 1b23481..899e57d 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h
@@ -86,6 +86,10 @@ struct radeon_renderbuffer
/* unsigned int offset; */
unsigned int pitch;
 
+   struct radeon_bo *map_bo;
+   GLbitfield map_mode;
+   int map_x, map_y, map_w, map_h;
+
uint32_t draw_offset; /* FBO */
/* boo Xorg 6.8.2 compat */
int has_surface;
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c 
b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 4b64cac..cf89fe5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -70,6 +70,98 @@ radeon_delete_renderbuffer(struct gl_renderbuffer *rb)
   free(rrb);
 }
 
+static void
+radeon_map_renderbuffer(struct gl_context *ctx,
+  struct gl_renderbuffer *rb,
+  GLuint x, GLuint y, GLuint w, GLuint h,
+  GLbitfield mode,
+  GLubyte **out_map,
+  GLint *out_stride)
+{
+   struct radeon_context *const rmesa = RADEON_CONTEXT(ctx);
+   struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+   GLubyte *map;
+   GLboolean ok;
+   int stride, ret;
+
+   assert(rrb  rrb-bo);
+
+   /* Make a temporary buffer and blit the current contents of the renderbuffer
+* out to it.  This gives us linear access to the buffer, instead of having
+* to do detiling in software.
+*/
+   assert(!rrb-map_bo);
+   rrb-map_bo = radeon_bo_open(rmesa-radeonScreen-bom, 0,
+   rrb-pitch * h, 4,
+   RADEON_GEM_DOMAIN_GTT, 0);
+   rrb-map_mode = mode;
+   rrb-map_x = x;
+   rrb-map_y = y;
+   rrb-map_w = w;
+   rrb-map_h = h;
+
+   ok = rmesa-vtbl.check_blit(rb-Format);
+   assert(ok);
+
+   ok = rmesa-vtbl.blit(ctx, rrb-bo, rrb-draw_offset,
+rb-Format, rrb-pitch / rrb-cpp,
+rb-Width, rb-Height,
+x, y,
+rrb-map_bo, 0,
+rb-Format, rrb-pitch / rrb-cpp,
+w, h,
+0, 0,
+w, h,
+GL_FALSE);
+   assert(ok);
+
+   radeon_bo_wait(rrb-map_bo);
+   ret = radeon_bo_map(rrb-map_bo, !!(mode  GL_MAP_WRITE_BIT));
+   assert(!ret);
+
+   map = rrb-map_bo-ptr;
+   stride = rrb-pitch;
+
+   if (rb-Name == 0) {
+  map += stride * (rb-Height - 1);
+  stride = -stride;
+   }
+
+   map += x * _mesa_get_format_bytes(rb-Format);
+   map += (int)y * stride;
+
+   *out_map = map;
+   *out_stride = stride;
+}
+
+static void
+radeon_unmap_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+   struct radeon_context *const rmesa = RADEON_CONTEXT(ctx);
+   struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+   GLboolean ok;
+
+   radeon_bo_unmap(rrb-map_bo);
+
+   if (rrb-map_mode  GL_MAP_WRITE_BIT) {
+  ok = rmesa-vtbl.blit(ctx, rrb-map_bo, 0,
+   rb-Format, rrb-pitch / rrb-cpp,
+   rrb-map_w, rrb-map_h,
+   0, 0,
+   rrb-bo, rrb-draw_offset,
+   rb-Format, rrb-pitch / rrb-cpp,
+   rb-Width, rb-Height,
+   rrb-map_x, rrb-map_y,
+   rrb-map_w, rrb-map_h,
+   GL_FALSE);
+  assert(ok);
+   }
+
+   radeon_bo_unref(rrb-map_bo);
+   rrb-map_bo = NULL;
+}
+
 static void *
 radeon_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb,
   GLint x, GLint y)
@@ -639,6 +731,8 @@ void radeon_fbo_init(struct radeon_context *radeon)
 #if FEATURE_EXT_framebuffer_object
   radeon-glCtx-Driver.NewFramebuffer = radeon_new_framebuffer;
   radeon-glCtx-Driver.NewRenderbuffer = radeon_new_renderbuffer;
+  radeon-glCtx-Driver.MapRenderbuffer = radeon_map_renderbuffer;
+  radeon-glCtx-Driver.UnmapRenderbuffer = radeon_unmap_renderbuffer;
   radeon-glCtx-Driver.BindFramebuffer = radeon_bind_framebuffer;
   radeon-glCtx-Driver.FramebufferRenderbuffer = 
radeon_framebuffer_renderbuffer;
   radeon-glCtx-Driver.RenderTexture = radeon_render_texture;
-- 
1.7.7

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

[Mesa-dev] [PATCH 12/24] swrast: MapRenderbuffer in separate depth/stencil readpixels fastpath

2011-10-28 Thread Eric Anholt
This introduces two new span helper functions we'll want to use in
several palces as we move to MapRenderbuffer, which pull out integer
depth and stencil values from a renderbuffer mapping based on the
renderbuffer format.
---
 src/mesa/swrast/s_depth.h   |1 -
 src/mesa/swrast/s_readpix.c |   76 ---
 src/mesa/swrast/s_stencil.c |   39 ++
 src/mesa/swrast/s_stencil.h |4 ++
 4 files changed, 100 insertions(+), 20 deletions(-)

diff --git a/src/mesa/swrast/s_depth.h b/src/mesa/swrast/s_depth.h
index 44820ac..8d5cdfa 100644
--- a/src/mesa/swrast/s_depth.h
+++ b/src/mesa/swrast/s_depth.h
@@ -53,7 +53,6 @@ extern void
 _swrast_read_depth_span_uint( struct gl_context *ctx, struct gl_renderbuffer 
*rb,
   GLint n, GLint x, GLint y, GLuint depth[] );
 
-
 extern void
 _swrast_clear_depth_buffer( struct gl_context *ctx, struct gl_renderbuffer *rb 
);
 
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 7b74ed3..b4db25d 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -400,7 +400,7 @@ static GLboolean
 fast_read_depth_stencil_pixels(struct gl_context *ctx,
   GLint x, GLint y,
   GLsizei width, GLsizei height,
-  GLenum type, GLvoid *dst, int dstStride)
+  GLvoid *dst, int dstStride)
 {
struct gl_framebuffer *fb = ctx-ReadBuffer;
struct gl_renderbuffer *rb = fb-Attachment[BUFFER_DEPTH].Renderbuffer;
@@ -411,9 +411,6 @@ fast_read_depth_stencil_pixels(struct gl_context *ctx,
if (rb != stencilRb)
   return GL_FALSE;
 
-   if (type != GL_UNSIGNED_INT_24_8)
-  return GL_FALSE;
-
if (rb-Format != MESA_FORMAT_Z24_S8 
rb-Format != MESA_FORMAT_S8_Z24)
   return GL_FALSE;
@@ -445,6 +442,53 @@ fast_read_depth_stencil_pixels(struct gl_context *ctx,
 
 
 /**
+ * For separate depth/stencil buffers being read as 24/8 depth/stencil, memcpy
+ * the data (possibly swapping 8/24 vs 24/8 as we go).
+ */
+static GLboolean
+fast_read_depth_stencil_pixels_separate(struct gl_context *ctx,
+   GLint x, GLint y,
+   GLsizei width, GLsizei height,
+   uint32_t *dst, int dstStride)
+{
+   struct gl_framebuffer *fb = ctx-ReadBuffer;
+   struct gl_renderbuffer *depthRb = fb-Attachment[BUFFER_DEPTH].Renderbuffer;
+   struct gl_renderbuffer *stencilRb = 
fb-Attachment[BUFFER_STENCIL].Renderbuffer;
+   GLubyte *depthMap, *stencilMap;
+   int depthStride, stencilStride, i, j;
+
+   if (_mesa_get_format_datatype(depthRb-Format) != GL_UNSIGNED_INT)
+  return GL_FALSE;
+
+   ctx-Driver.MapRenderbuffer(ctx, depthRb, x, y, width, height,
+  GL_MAP_READ_BIT, depthMap, depthStride);
+   ctx-Driver.MapRenderbuffer(ctx, stencilRb, x, y, width, height,
+  GL_MAP_READ_BIT, stencilMap, stencilStride);
+
+   for (j = 0; j  height; j++) {
+  GLstencil stencilVals[MAX_WIDTH];
+
+  _mesa_unpack_uint_z_row(depthRb-Format, width, depthMap, dst);
+  _swrast_read_stencil_span_mapped(ctx, stencilRb, stencilMap, width,
+  stencilVals);
+
+  for (i = 0; i  width; i++) {
+dst[i] = (dst[i]  0xff00) | stencilVals[i];
+  }
+
+  depthMap += depthStride;
+  stencilMap += stencilStride;
+  dst += dstStride / 4;
+   }
+
+   ctx-Driver.UnmapRenderbuffer(ctx, depthRb);
+   ctx-Driver.UnmapRenderbuffer(ctx, stencilRb);
+
+   return GL_TRUE;
+}
+
+
+/**
  * Read combined depth/stencil values.
  * We'll have already done error checking to be sure the expected
  * depth and stencil buffers really exist.
@@ -477,10 +521,16 @@ read_depth_stencil_pixels(struct gl_context *ctx,
dstStride = _mesa_image_row_stride(packing, width,
  GL_DEPTH_STENCIL_EXT, type);
 
-   if (!scaleOrBias  !stencilTransfer  !packing-SwapBytes) {
-  if (fast_read_depth_stencil_pixels(ctx, x, y, width, height, type,
+   /* Fast 24/8 reads. */
+   if (type == GL_UNSIGNED_INT_24_8 
+   !scaleOrBias  !stencilTransfer  !packing-SwapBytes) {
+  if (fast_read_depth_stencil_pixels(ctx, x, y, width, height,
 dst, dstStride))
 return;
+
+  if (fast_read_depth_stencil_pixels_separate(ctx, x, y, width, height,
+ (uint32_t *)dst, dstStride))
+return;
}
 
   /* Reading GL_DEPTH_STENCIL pixels from separate depth/stencil buffers,
@@ -496,19 +546,7 @@ read_depth_stencil_pixels(struct gl_context *ctx,
  _swrast_read_stencil_span(ctx, stencilRb, width,
x, y + i, stencilVals);
 
- if (!scaleOrBias  !stencilTransfer
-  ctx-ReadBuffer-Visual.depthBits == 24) {
-   

[Mesa-dev] [PATCH 13/24] swrast: Switch the remaining depth/stencil readpixels path to MapRenderbuffer.

2011-10-28 Thread Eric Anholt
---
 src/mesa/swrast/s_readpix.c |   72 +--
 1 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index b4db25d..a0dc3e1 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -487,6 +487,45 @@ fast_read_depth_stencil_pixels_separate(struct gl_context 
*ctx,
return GL_TRUE;
 }
 
+static void
+slow_read_depth_stencil_pixels_separate(struct gl_context *ctx,
+   GLint x, GLint y,
+   GLsizei width, GLsizei height,
+   GLenum type,
+   const struct gl_pixelstore_attrib 
*packing,
+   GLubyte *dst, int dstStride)
+{
+   struct gl_framebuffer *fb = ctx-ReadBuffer;
+   struct gl_renderbuffer *depthRb = fb-Attachment[BUFFER_DEPTH].Renderbuffer;
+   struct gl_renderbuffer *stencilRb = 
fb-Attachment[BUFFER_STENCIL].Renderbuffer;
+   GLubyte *depthMap, *stencilMap;
+   int depthStride, stencilStride, j;
+
+   ctx-Driver.MapRenderbuffer(ctx, depthRb, x, y, width, height,
+  GL_MAP_READ_BIT, depthMap, depthStride);
+   ctx-Driver.MapRenderbuffer(ctx, stencilRb, x, y, width, height,
+  GL_MAP_READ_BIT, stencilMap, stencilStride);
+
+   for (j = 0; j  height; j++) {
+  GLstencil stencilVals[MAX_WIDTH];
+  GLfloat depthVals[MAX_WIDTH];
+
+  _mesa_unpack_float_z_row(depthRb-Format, width, depthMap, depthVals);
+  _swrast_read_stencil_span_mapped(ctx, stencilRb, stencilMap, width,
+  stencilVals);
+
+  _mesa_pack_depth_stencil_span(ctx, width, type, (GLuint *)dst,
+   depthVals, stencilVals, packing);
+
+  depthMap += depthStride;
+  stencilMap += stencilStride;
+  dst += dstStride;
+   }
+
+   ctx-Driver.UnmapRenderbuffer(ctx, depthRb);
+   ctx-Driver.UnmapRenderbuffer(ctx, stencilRb);
+}
+
 
 /**
  * Read combined depth/stencil values.
@@ -504,16 +543,9 @@ read_depth_stencil_pixels(struct gl_context *ctx,
   = ctx-Pixel.DepthScale != 1.0 || ctx-Pixel.DepthBias != 0.0;
const GLboolean stencilTransfer = ctx-Pixel.IndexShift
   || ctx-Pixel.IndexOffset || ctx-Pixel.MapStencilFlag;
-   struct gl_renderbuffer *depthRb, *stencilRb;
GLubyte *dst;
int dstStride;
 
-   depthRb = ctx-ReadBuffer-_DepthBuffer;
-   stencilRb = ctx-ReadBuffer-_StencilBuffer;
-
-   if (!depthRb || !stencilRb)
-  return;
-
dst = (GLubyte *) _mesa_image_address2d(packing, pixels,
   width, height,
   GL_DEPTH_STENCIL_EXT,
@@ -533,29 +565,9 @@ read_depth_stencil_pixels(struct gl_context *ctx,
 return;
}
 
-  /* Reading GL_DEPTH_STENCIL pixels from separate depth/stencil buffers,
-   * or we need pixel transfer.
-   */
-   {
-  GLint i;
-
-  for (i = 0; i  height; i++) {
- GLstencil stencilVals[MAX_WIDTH];
- GLuint *depthStencilDst = (GLuint *) (dst + dstStride * i);
-
- _swrast_read_stencil_span(ctx, stencilRb, width,
-   x, y + i, stencilVals);
-
-{
-/* general case */
-GLfloat depthVals[MAX_WIDTH];
-_swrast_read_depth_span_float(ctx, depthRb, width, x, y + i,
-  depthVals);
-_mesa_pack_depth_stencil_span(ctx, width, type, depthStencilDst,
-  depthVals, stencilVals, packing);
- }
-  }
-   }
+   slow_read_depth_stencil_pixels_separate(ctx, x, y, width, height,
+  type, packing,
+  dst, dstStride);
 }
 
 
-- 
1.7.7

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


[Mesa-dev] [PATCH 11/24] swrast: Calculate image address/stride once for depth/stencil readpixels.

2011-10-28 Thread Eric Anholt
The fast and slow paths were doing these separately before.
---
 src/mesa/swrast/s_readpix.c |   30 ++
 1 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index c0bb399..7b74ed3 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -400,14 +400,13 @@ static GLboolean
 fast_read_depth_stencil_pixels(struct gl_context *ctx,
   GLint x, GLint y,
   GLsizei width, GLsizei height,
-  GLenum type, GLvoid *pixels,
-  const struct gl_pixelstore_attrib *packing)
+  GLenum type, GLvoid *dst, int dstStride)
 {
struct gl_framebuffer *fb = ctx-ReadBuffer;
struct gl_renderbuffer *rb = fb-Attachment[BUFFER_DEPTH].Renderbuffer;
struct gl_renderbuffer *stencilRb = 
fb-Attachment[BUFFER_DEPTH].Renderbuffer;
-   GLubyte *dst, *map;
-   int stride, dstStride, i;
+   GLubyte *map;
+   int stride, i;
 
if (rb != stencilRb)
   return GL_FALSE;
@@ -422,13 +421,6 @@ fast_read_depth_stencil_pixels(struct gl_context *ctx,
ctx-Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT,
   map, stride);
 
-   dstStride = _mesa_image_row_stride(packing, width,
- GL_DEPTH_STENCIL_EXT, type);
-   dst = (GLubyte *) _mesa_image_address2d(packing, pixels,
-  width, height,
-  GL_DEPTH_STENCIL_EXT,
-  type, 0, 0);
-
for (i = 0; i  height; i++) {
   memcpy(dst, map, width * 4);
 
@@ -469,6 +461,8 @@ read_depth_stencil_pixels(struct gl_context *ctx,
const GLboolean stencilTransfer = ctx-Pixel.IndexShift
   || ctx-Pixel.IndexOffset || ctx-Pixel.MapStencilFlag;
struct gl_renderbuffer *depthRb, *stencilRb;
+   GLubyte *dst;
+   int dstStride;
 
depthRb = ctx-ReadBuffer-_DepthBuffer;
stencilRb = ctx-ReadBuffer-_StencilBuffer;
@@ -476,9 +470,16 @@ read_depth_stencil_pixels(struct gl_context *ctx,
if (!depthRb || !stencilRb)
   return;
 
+   dst = (GLubyte *) _mesa_image_address2d(packing, pixels,
+  width, height,
+  GL_DEPTH_STENCIL_EXT,
+  type, 0, 0);
+   dstStride = _mesa_image_row_stride(packing, width,
+ GL_DEPTH_STENCIL_EXT, type);
+
if (!scaleOrBias  !stencilTransfer  !packing-SwapBytes) {
   if (fast_read_depth_stencil_pixels(ctx, x, y, width, height, type,
-pixels, packing))
+dst, dstStride))
 return;
}
 
@@ -490,10 +491,7 @@ read_depth_stencil_pixels(struct gl_context *ctx,
 
   for (i = 0; i  height; i++) {
  GLstencil stencilVals[MAX_WIDTH];
-
- GLuint *depthStencilDst = (GLuint *)
-_mesa_image_address2d(packing, pixels, width, height,
-  GL_DEPTH_STENCIL_EXT, type, i, 0);
+ GLuint *depthStencilDst = (GLuint *) (dst + dstStride * i);
 
  _swrast_read_stencil_span(ctx, stencilRb, width,
x, y + i, stencilVals);
-- 
1.7.7

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


[Mesa-dev] [PATCH 10/24] swrast: Make the packed depth/stencil read fastpath use MapRenderbuffer.

2011-10-28 Thread Eric Anholt
This also makes it handle 24/8 vs 8/24, fixing piglit
depthstencil-default_fb-readpixels-24_8 on i965.  While here, avoid
incorrectly fast-pathing if packing-SwapBytes is set.
---
 src/mesa/swrast/s_readpix.c |   94 +-
 1 files changed, 65 insertions(+), 29 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 4ecb5b8..c0bb399 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -392,6 +392,65 @@ read_rgba_pixels( struct gl_context *ctx,
}
 }
 
+/**
+ * For a packed depth/stencil buffer being read as depth/stencil, memcpy the
+ * data (possibly swapping 8/24 vs 24/8 as we go).
+ */
+static GLboolean
+fast_read_depth_stencil_pixels(struct gl_context *ctx,
+  GLint x, GLint y,
+  GLsizei width, GLsizei height,
+  GLenum type, GLvoid *pixels,
+  const struct gl_pixelstore_attrib *packing)
+{
+   struct gl_framebuffer *fb = ctx-ReadBuffer;
+   struct gl_renderbuffer *rb = fb-Attachment[BUFFER_DEPTH].Renderbuffer;
+   struct gl_renderbuffer *stencilRb = 
fb-Attachment[BUFFER_DEPTH].Renderbuffer;
+   GLubyte *dst, *map;
+   int stride, dstStride, i;
+
+   if (rb != stencilRb)
+  return GL_FALSE;
+
+   if (type != GL_UNSIGNED_INT_24_8)
+  return GL_FALSE;
+
+   if (rb-Format != MESA_FORMAT_Z24_S8 
+   rb-Format != MESA_FORMAT_S8_Z24)
+  return GL_FALSE;
+
+   ctx-Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT,
+  map, stride);
+
+   dstStride = _mesa_image_row_stride(packing, width,
+ GL_DEPTH_STENCIL_EXT, type);
+   dst = (GLubyte *) _mesa_image_address2d(packing, pixels,
+  width, height,
+  GL_DEPTH_STENCIL_EXT,
+  type, 0, 0);
+
+   for (i = 0; i  height; i++) {
+  memcpy(dst, map, width * 4);
+
+  if (rb-Format == MESA_FORMAT_S8_Z24) {
+int j;
+uint32_t *data = (uint32_t *)dst;
+
+for (j = 0; j  width; j++) {
+   uint32_t val = *data;
+   *(data++) = (val  24) | (val  8);
+}
+  }
+
+  map += stride;
+  dst += dstStride;
+   }
+
+   ctx-Driver.UnmapRenderbuffer(ctx, rb);
+
+   return GL_TRUE;
+}
+
 
 /**
  * Read combined depth/stencil values.
@@ -417,40 +476,17 @@ read_depth_stencil_pixels(struct gl_context *ctx,
if (!depthRb || !stencilRb)
   return;
 
-   depthRb = ctx-ReadBuffer-Attachment[BUFFER_DEPTH].Renderbuffer;
-   stencilRb = ctx-ReadBuffer-Attachment[BUFFER_STENCIL].Renderbuffer;
-
-   if (depthRb-_BaseFormat == GL_DEPTH_STENCIL_EXT 
-   depthRb-Format == MESA_FORMAT_Z24_S8 
-   type == GL_UNSIGNED_INT_24_8 
-   depthRb == stencilRb 
-   depthRb-GetRow   /* May be null if depthRb is a wrapper around
-   * separate depth and stencil buffers. */
-   !scaleOrBias 
-   !stencilTransfer) {
-  /* This is the ideal case.
-   * Reading GL_DEPTH_STENCIL pixels from combined depth/stencil buffer.
-   * Plus, no pixel transfer ops to worry about!
-   */
-  GLint i;
-  GLint dstStride = _mesa_image_row_stride(packing, width,
-   GL_DEPTH_STENCIL_EXT, type);
-  GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, pixels,
-   width, height,
-   GL_DEPTH_STENCIL_EXT,
-   type, 0, 0);
-  for (i = 0; i  height; i++) {
- depthRb-GetRow(ctx, depthRb, width, x, y + i, dst);
- dst += dstStride;
-  }
+   if (!scaleOrBias  !stencilTransfer  !packing-SwapBytes) {
+  if (fast_read_depth_stencil_pixels(ctx, x, y, width, height, type,
+pixels, packing))
+return;
}
-   else {
+
   /* Reading GL_DEPTH_STENCIL pixels from separate depth/stencil buffers,
* or we need pixel transfer.
*/
+   {
   GLint i;
-  depthRb = ctx-ReadBuffer-_DepthBuffer;
-  stencilRb = ctx-ReadBuffer-_StencilBuffer;
 
   for (i = 0; i  height; i++) {
  GLstencil stencilVals[MAX_WIDTH];
-- 
1.7.7

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


[Mesa-dev] [PATCH 17/24] swrast: Skip _swrast_validate_derived in _swrast_ReadPixels().

2011-10-28 Thread Eric Anholt
None of the callgraph below this uses derived state (almost nothing
even dereferences the swrast context).
---
 src/mesa/swrast/s_readpix.c |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index bf2fe9d..21dc5ea 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -643,7 +643,6 @@ _swrast_ReadPixels( struct gl_context *ctx,
const struct gl_pixelstore_attrib *packing,
GLvoid *pixels )
 {
-   SWcontext *swrast = SWRAST_CONTEXT(ctx);
struct gl_pixelstore_attrib clippedPacking = *packing;
 
if (ctx-NewState)
@@ -655,9 +654,6 @@ _swrast_ReadPixels( struct gl_context *ctx,
 */
swrast_render_start(ctx);
 
-   if (swrast-NewState)
-  _swrast_validate_derived( ctx );
-
/* Do all needed clipping here, so that we can forget about it later */
if (_mesa_clip_readpixels(ctx, x, y, width, height, clippedPacking)) {
 
-- 
1.7.7

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


[Mesa-dev] [PATCH 14/24] swrast: Switch the remaining depth readpixels to MapRenderbuffer.

2011-10-28 Thread Eric Anholt
This avoids the wrapper, which should improve performance on packed
depth/stencil drivers.
---
 src/mesa/swrast/s_readpix.c |   22 +-
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index a0dc3e1..91205fc 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -103,8 +103,10 @@ read_depth_pixels( struct gl_context *ctx,
const struct gl_pixelstore_attrib *packing )
 {
struct gl_framebuffer *fb = ctx-ReadBuffer;
-   struct gl_renderbuffer *rb = fb-_DepthBuffer;
+   struct gl_renderbuffer *rb = fb-Attachment[BUFFER_DEPTH].Renderbuffer;
GLint j;
+   GLubyte *dst, *map;
+   int dstStride, stride;
 
if (!rb)
   return;
@@ -120,14 +122,24 @@ read_depth_pixels( struct gl_context *ctx,
if (fast_read_depth_pixels(ctx, x, y, width, height, type, pixels, packing))
   return;
 
+   dstStride = _mesa_image_row_stride(packing, width, GL_DEPTH_COMPONENT, 
type);
+   dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
+  GL_DEPTH_COMPONENT, type, 0, 0);
+
+   ctx-Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT,
+  map, stride);
+
/* General case (slower) */
for (j = 0; j  height; j++, y++) {
   GLfloat depthValues[MAX_WIDTH];
-  GLvoid *dest = _mesa_image_address2d(packing, pixels, width, height,
-  GL_DEPTH_COMPONENT, type, j, 0);
-  _swrast_read_depth_span_float(ctx, rb, width, x, y, depthValues);
-  _mesa_pack_depth_span(ctx, width, dest, type, depthValues, packing);
+  _mesa_unpack_float_z_row(rb-Format, width, map, depthValues);
+  _mesa_pack_depth_span(ctx, width, dst, type, depthValues, packing);
+
+  dst += dstStride;
+  map += stride;
}
+
+   ctx-Driver.UnmapRenderbuffer(ctx, rb);
 }
 
 
-- 
1.7.7

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


[Mesa-dev] [PATCH 15/24] mesa: Add a function for comparing gl_format to format/type.

2011-10-28 Thread Eric Anholt
This should be useful in making more generic fast paths in the pixel
paths.
---
 src/mesa/main/formats.c |  306 +++
 src/mesa/main/formats.h |3 +
 2 files changed, 309 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 6307f8e..b9a2434 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -2444,3 +2444,309 @@ _mesa_format_to_type_and_comps(gl_format format,
   *comps = 1;
}
 }
+
+/**
+ * Returns a MESA_FORMAT describing pixels with the given format/type if
+ * available, or MESA_FORMAT_NONE.
+ *
+ * If a format is returned, it should be suitable to memcpy
+ * _mesa_get_format_bytes() at a time to move the pixel data.
+ */
+GLboolean
+_mesa_format_matches_format_and_type(gl_format gl_format,
+GLenum format, GLenum type)
+{
+   /* Note: When reading a GL format/type combination, the format lists channel
+* assignments from most significant channel in the type to least
+* significant.  A type with _REV indicates that the assignments are 
swapped,
+* so they are listed from least significant to most significant.
+*
+* For sanity, please keep this switch statement ordered the same as the 
enum
+* in formats.h.
+*/
+
+   switch (gl_format) {
+
+   case MESA_FORMAT_NONE:
+   case MESA_FORMAT_COUNT:
+  return GL_FALSE;
+
+   case MESA_FORMAT_RGBA:
+  return format == GL_RGBA  type == GL_UNSIGNED_INT_8_8_8_8;
+   case MESA_FORMAT_RGBA_REV:
+  return format == GL_RGBA  type == GL_UNSIGNED_INT_8_8_8_8_REV;
+
+   case MESA_FORMAT_ARGB:
+  return format == GL_BGRA  type == GL_UNSIGNED_INT_8_8_8_8_REV;
+   case MESA_FORMAT_ARGB_REV:
+  return format == GL_BGRA  type == GL_UNSIGNED_INT_8_8_8_8;
+
+   case MESA_FORMAT_XRGB:
+   case MESA_FORMAT_XRGB_REV:
+  return GL_FALSE;
+
+   case MESA_FORMAT_RGB888:
+  return format == GL_RGB  type == GL_UNSIGNED_BYTE;
+   case MESA_FORMAT_BGR888:
+  return GL_FALSE;
+
+   case MESA_FORMAT_RGB565:
+  return format == GL_RGB  type == GL_UNSIGNED_SHORT_5_6_5;
+   case MESA_FORMAT_RGB565_REV:
+  /* Some of the 16-bit MESA_FORMATs that would seem to correspond to
+   * GL_UNSIGNED_SHORT_* are byte-swapped instead of channel-reversed,
+   * according to formats.h, so they can't be matched.
+   */
+  return GL_FALSE;
+
+   case MESA_FORMAT_ARGB:
+  return format == GL_BGRA  type == GL_UNSIGNED_SHORT_4_4_4_4_REV;
+   case MESA_FORMAT_ARGB_REV:
+  return GL_FALSE;
+
+   case MESA_FORMAT_RGBA5551:
+  return format == GL_RGBA  type == GL_UNSIGNED_SHORT_5_5_5_1;
+
+   case MESA_FORMAT_ARGB1555:
+  return format == GL_BGRA  type == GL_UNSIGNED_SHORT_1_5_5_5_REV;
+   case MESA_FORMAT_ARGB1555_REV:
+  return GL_FALSE;
+
+   case MESA_FORMAT_AL44:
+  return GL_FALSE;
+   case MESA_FORMAT_AL88:
+  return GL_FALSE;
+   case MESA_FORMAT_AL88_REV:
+  return format == GL_LUMINANCE_ALPHA  type == GL_UNSIGNED_BYTE;
+
+   case MESA_FORMAT_AL1616:
+  return GL_FALSE;
+   case MESA_FORMAT_AL1616_REV:
+  return format == GL_LUMINANCE_ALPHA  type == GL_UNSIGNED_SHORT;
+
+   case MESA_FORMAT_RGB332:
+  return format == GL_RGB  type == GL_UNSIGNED_BYTE_3_3_2;
+
+   case MESA_FORMAT_A8:
+  return format == GL_ALPHA  type == GL_UNSIGNED_BYTE;
+   case MESA_FORMAT_A16:
+  return format == GL_ALPHA  type == GL_UNSIGNED_SHORT;
+   case MESA_FORMAT_L8:
+  return format == GL_LUMINANCE  type == GL_UNSIGNED_BYTE;
+   case MESA_FORMAT_L16:
+  return format == GL_LUMINANCE  type == GL_UNSIGNED_SHORT;
+   case MESA_FORMAT_I8:
+  return format == GL_INTENSITY  type == GL_UNSIGNED_BYTE;
+   case MESA_FORMAT_I16:
+  return format == GL_INTENSITY  type == GL_UNSIGNED_SHORT;
+
+   case MESA_FORMAT_YCBCR:
+   case MESA_FORMAT_YCBCR_REV:
+  return GL_FALSE;
+
+   case MESA_FORMAT_R8:
+  return format == GL_RED  type == GL_UNSIGNED_BYTE;
+   case MESA_FORMAT_RG88:
+  return format == GL_RG  type == GL_UNSIGNED_BYTE;
+   case MESA_FORMAT_RG88_REV:
+  return GL_FALSE;
+
+   case MESA_FORMAT_R16:
+  return format == GL_RED  type == GL_UNSIGNED_SHORT;
+   case MESA_FORMAT_RG1616:
+  return format == GL_RG  type == GL_UNSIGNED_SHORT;
+   case MESA_FORMAT_RG1616_REV:
+  return GL_FALSE;
+
+   case MESA_FORMAT_ARGB2101010:
+  return format == GL_BGRA  type == GL_UNSIGNED_INT_2_10_10_10_REV;
+
+   case MESA_FORMAT_Z24_S8:
+  return format == GL_DEPTH_STENCIL  type == GL_UNSIGNED_INT_24_8;
+   case MESA_FORMAT_Z24_X8:
+   case MESA_FORMAT_S8_Z24:
+  return GL_FALSE;
+
+   case MESA_FORMAT_Z16:
+  return format == GL_DEPTH_COMPONENT  type == GL_UNSIGNED_SHORT;
+
+   case MESA_FORMAT_X8_Z24:
+  return GL_FALSE;
+
+   case MESA_FORMAT_Z32:
+  return format == GL_DEPTH_COMPONENT  type == GL_UNSIGNED_INT;
+
+   case MESA_FORMAT_S8:
+  return GL_FALSE;
+

[Mesa-dev] [PATCH 18/24] swrast: Convert color glReadPixels slow path to using MapRenderbuffer.

2011-10-28 Thread Eric Anholt
This may be a bit slower than before because we're switching from
per-format compiled loops in GetRow to
_mesa_unpack_rgba_block_unpack's loop around a callback to unpack a
pixel.  The solution there would be to make _mesa_unpack_rgba_block
fold the span loop into the format handlers.

(On the other hand, function call overhead will hardly matter if
MapRenderbuffer means the driver gets the data into cacheable memory
instead of uncached).

The adjust_colors code should no longer be required, since the unpack
function does the 565 to float conversion in a single pass instead of
converting it (poorly) through  as apparently happened in the
past.

This commit regresses some srgb tests.
---
 src/mesa/swrast/s_readpix.c |  101 +-
 1 files changed, 31 insertions(+), 70 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 21dc5ea..b55f525 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -337,50 +337,41 @@ fast_read_rgba_pixels_memcpy( struct gl_context *ctx,
return GL_TRUE;
 }
 
-
-/**
- * When we're using a low-precision color buffer (like 16-bit 5/6/5)
- * we have to adjust our color values a bit to pass conformance.
- * The problem is when a 5 or 6-bit color value is converted to an 8-bit
- * value and then a floating point value, the floating point values don't
- * increment uniformly as the 5 or 6-bit value is incremented.
- *
- * This function adjusts floating point values to compensate.
- */
-static void
-adjust_colors(const struct gl_framebuffer *fb, GLuint n, GLfloat rgba[][4])
+static GLboolean
+slow_read_rgba_pixels( struct gl_context *ctx,
+  GLint x, GLint y,
+  GLsizei width, GLsizei height,
+  GLenum format, GLenum type,
+  GLvoid *pixels,
+  const struct gl_pixelstore_attrib *packing,
+  GLbitfield transferOps )
 {
-   const GLuint rShift = 8 - fb-Visual.redBits;
-   const GLuint gShift = 8 - fb-Visual.greenBits;
-   const GLuint bShift = 8 - fb-Visual.blueBits;
-   GLfloat rScale = 1.0F / (GLfloat) ((1  fb-Visual.redBits  ) - 1);
-   GLfloat gScale = 1.0F / (GLfloat) ((1  fb-Visual.greenBits) - 1);
-   GLfloat bScale = 1.0F / (GLfloat) ((1  fb-Visual.blueBits ) - 1);
-   GLuint i;
+   struct gl_renderbuffer *rb = ctx-ReadBuffer-_ColorReadBuffer;
+   GLfloat rgba[MAX_WIDTH][4];
+   GLubyte *dst, *map;
+   int dstStride, stride, j;
 
-   if (fb-Visual.redBits == 0)
-  rScale = 0;
-   if (fb-Visual.greenBits == 0)
-  gScale = 0;
-   if (fb-Visual.blueBits == 0)
-  bScale = 0;
+   dstStride = _mesa_image_row_stride(packing, width, format, type);
+   dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
+  format, type, 0, 0);
+
+   ctx-Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT,
+  map, stride);
 
-   for (i = 0; i  n; i++) {
-  GLint r, g, b;
-  /* convert float back to ubyte */
-  CLAMPED_FLOAT_TO_UBYTE(r, rgba[i][RCOMP]);
-  CLAMPED_FLOAT_TO_UBYTE(g, rgba[i][GCOMP]);
-  CLAMPED_FLOAT_TO_UBYTE(b, rgba[i][BCOMP]);
-  /* using only the N most significant bits of the ubyte value, convert to
-   * float in [0,1].
-   */
-  rgba[i][RCOMP] = (GLfloat) (r  rShift) * rScale;
-  rgba[i][GCOMP] = (GLfloat) (g  gShift) * gScale;
-  rgba[i][BCOMP] = (GLfloat) (b  bShift) * bScale;
+   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);
+
+  dst += dstStride;
+  map += stride;
}
-}
 
+   ctx-Driver.UnmapRenderbuffer(ctx, rb);
 
+   return GL_TRUE;
+}
 
 /*
  * Read R, G, B, A, RGB, L, or LA pixels.
@@ -392,7 +383,6 @@ read_rgba_pixels( struct gl_context *ctx,
   GLenum format, GLenum type, GLvoid *pixels,
   const struct gl_pixelstore_attrib *packing )
 {
-   SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLbitfield transferOps = ctx-_ImageTransferState;
struct gl_framebuffer *fb = ctx-ReadBuffer;
struct gl_renderbuffer *rb = fb-_ColorReadBuffer;
@@ -419,37 +409,8 @@ read_rgba_pixels( struct gl_context *ctx,
   }
}
 
-   /* width should never be  MAX_WIDTH since we did clipping earlier */
-   ASSERT(width = MAX_WIDTH);
-
-   {
-  const GLint dstStride
- = _mesa_image_row_stride(packing, width, format, type);
-  GLfloat (*rgba)[4] = swrast-SpanArrays-attribs[FRAG_ATTRIB_COL0];
-  GLint row;
-  GLubyte *dst
- = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
- format, type, 0, 0);
-
-  for (row = 0; row  height; row++, y++) {
-
- /* Get 

[Mesa-dev] [PATCH 16/24] swrast: Add a readpixels fast-path based on memcpy and MapRenderbuffer.

2011-10-28 Thread Eric Anholt
---
 src/mesa/swrast/s_readpix.c |   56 +++---
 1 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 91205fc..bf2fe9d 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -297,6 +297,46 @@ fast_read_rgba_pixels( struct gl_context *ctx,
return GL_FALSE;
 }
 
+static GLboolean
+fast_read_rgba_pixels_memcpy( struct gl_context *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ GLbitfield transferOps )
+{
+   struct gl_renderbuffer *rb = ctx-ReadBuffer-_ColorReadBuffer;
+   GLubyte *dst, *map;
+   int dstStride, stride, j;
+
+   if (!_mesa_format_matches_format_and_type(rb-Format, format, type))
+  return GL_FALSE;
+
+   /* check for things we can't handle here */
+   if (packing-SwapBytes ||
+   packing-LsbFirst) {
+  return GL_FALSE;
+   }
+
+   dstStride = _mesa_image_row_stride(packing, width, format, type);
+   dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
+  format, type, 0, 0);
+
+   ctx-Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT,
+  map, stride);
+
+   for (j = 0; j  height; j++) {
+  memcpy(dst, map, width * _mesa_get_format_bytes(rb-Format));
+  dst += dstStride;
+  map += stride;
+   }
+
+   ctx-Driver.UnmapRenderbuffer(ctx, rb);
+
+   return GL_TRUE;
+}
+
 
 /**
  * When we're using a low-precision color buffer (like 16-bit 5/6/5)
@@ -365,10 +405,18 @@ read_rgba_pixels( struct gl_context *ctx,
   transferOps |= IMAGE_CLAMP_BIT;
}
 
-   /* Try the optimized path first. */
-   if (fast_read_rgba_pixels(ctx, x, y, width, height,
- format, type, pixels, packing, transferOps)) {
-  return; /* done! */
+   if (!transferOps) {
+  /* Try the optimized paths first. */
+  if (fast_read_rgba_pixels_memcpy(ctx, x, y, width, height,
+  format, type, pixels, packing,
+  transferOps)) {
+return;
+  }
+
+  if (fast_read_rgba_pixels(ctx, x, y, width, height,
+   format, type, pixels, packing, transferOps)) {
+return;
+  }
}
 
/* width should never be  MAX_WIDTH since we did clipping earlier */
-- 
1.7.7

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


[Mesa-dev] [PATCH 19/24] swrast: Remove dead _swrast_read_depth_span_uint().

2011-10-28 Thread Eric Anholt
All the code using it is converted to MapRenderbuffer and the core
unpack functions.
---
 src/mesa/swrast/s_depth.c |   83 -
 src/mesa/swrast/s_depth.h |5 ---
 2 files changed, 0 insertions(+), 88 deletions(-)

diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 58440cb..6ffa0a3 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -1313,89 +1313,6 @@ _swrast_read_depth_span_float( struct gl_context *ctx, 
struct gl_renderbuffer *r
}
 }
 
-
-/**
- * As above, but return 32-bit GLuint values.
- */
-void
-_swrast_read_depth_span_uint( struct gl_context *ctx, struct gl_renderbuffer 
*rb,
-  GLint n, GLint x, GLint y, GLuint depth[] )
-{
-   GLuint depthBits;
-
-   if (!rb) {
-  /* really only doing this to prevent FP exceptions later */
-  memset(depth, 0, n * sizeof(GLuint));
-  return;
-   }
-
-   depthBits = _mesa_get_format_bits(rb-Format, GL_DEPTH_BITS);
-
-   ASSERT(rb-_BaseFormat == GL_DEPTH_COMPONENT);
-
-   if (y  0 || y = (GLint) rb-Height ||
-   x + n = 0 || x = (GLint) rb-Width) {
-  /* span is completely outside framebuffer */
-  memset(depth, 0, n * sizeof(GLfloat));
-  return;
-   }
-
-   if (x  0) {
-  GLint dx = -x;
-  GLint i;
-  for (i = 0; i  dx; i++)
- depth[i] = 0;
-  x = 0;
-  n -= dx;
-  depth += dx;
-   }
-   if (x + n  (GLint) rb-Width) {
-  GLint dx = x + n - (GLint) rb-Width;
-  GLint i;
-  for (i = 0; i  dx; i++)
- depth[n - i - 1] = 0;
-  n -= dx;
-   }
-   if (n = 0) {
-  return;
-   }
-
-   if (rb-DataType == GL_UNSIGNED_INT) {
-  rb-GetRow(ctx, rb, n, x, y, depth);
-  if (depthBits  32) {
- GLuint shift = 32 - depthBits;
- GLint i;
- for (i = 0; i  n; i++) {
-GLuint z = depth[i];
-depth[i] = z  shift; /* XXX lsb bits? */
- }
-  }
-   }
-   else if (rb-DataType == GL_UNSIGNED_SHORT) {
-  GLushort temp[MAX_WIDTH];
-  GLint i;
-  rb-GetRow(ctx, rb, n, x, y, temp);
-  if (depthBits == 16) {
- for (i = 0; i  n; i++) {
-GLuint z = temp[i];
-depth[i] = (z  16) | z;
- }
-  }
-  else {
- GLuint shift = 16 - depthBits;
- for (i = 0; i  n; i++) {
-GLuint z = temp[i];
-depth[i] = (z  (shift + 16)) | (z  shift); /* XXX lsb bits? */
- }
-  }
-   }
-   else {
-  _mesa_problem(ctx, Invalid depth renderbuffer data type);
-   }
-}
-
-
-
 /**
  * Clear the given z/depth renderbuffer.
  */
diff --git a/src/mesa/swrast/s_depth.h b/src/mesa/swrast/s_depth.h
index 8d5cdfa..2caea82 100644
--- a/src/mesa/swrast/s_depth.h
+++ b/src/mesa/swrast/s_depth.h
@@ -48,11 +48,6 @@ extern void
 _swrast_read_depth_span_float( struct gl_context *ctx, struct gl_renderbuffer 
*rb,
GLint n, GLint x, GLint y, GLfloat depth[] );
 
-
-extern void
-_swrast_read_depth_span_uint( struct gl_context *ctx, struct gl_renderbuffer 
*rb,
-  GLint n, GLint x, GLint y, GLuint depth[] );
-
 extern void
 _swrast_clear_depth_buffer( struct gl_context *ctx, struct gl_renderbuffer *rb 
);
 
-- 
1.7.7

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


[Mesa-dev] [PATCH 21/24] swrast: Drop the global mapping of buffers across glReadPixels().

2011-10-28 Thread Eric Anholt
---
 src/mesa/swrast/s_readpix.c |8 
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index b67e081..fce9762 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -519,12 +519,6 @@ _swrast_ReadPixels( struct gl_context *ctx,
if (ctx-NewState)
   _mesa_update_state(ctx);
 
-   /* Need to do swrast_render_start() before clipping or anything else
-* since this is where a driver may grab the hw lock and get an updated
-* window size.
-*/
-   swrast_render_start(ctx);
-
/* Do all needed clipping here, so that we can forget about it later */
if (_mesa_clip_readpixels(ctx, x, y, width, height, clippedPacking)) {
 
@@ -553,6 +547,4 @@ _swrast_ReadPixels( struct gl_context *ctx,
  _mesa_unmap_pbo_dest(ctx, clippedPacking);
   }
}
-
-   swrast_render_finish(ctx);
 }
-- 
1.7.7

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


[Mesa-dev] [PATCH 08/24] swrast: Use MapRenderbuffer for glReadPixels(GL_DEPTH_COMPONENT) fast-paths.

2011-10-28 Thread Eric Anholt
This fixes issues with the code playing fast and loose with types of
buffers, and as a bonus avoids the wrappers that were previously used
to pull bits out of packed depth/stencil buffers.
---
 src/mesa/swrast/s_readpix.c |  131 +--
 1 files changed, 63 insertions(+), 68 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 0d2e63f..187c27e 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -27,6 +27,7 @@
 #include main/colormac.h
 #include main/feedback.h
 #include main/formats.h
+#include main/format_unpack.h
 #include main/image.h
 #include main/imports.h
 #include main/macros.h
@@ -39,6 +40,57 @@
 #include s_span.h
 #include s_stencil.h
 
+/**
+ * Tries to implement glReadPixels() of GL_DEPTH_COMPONENT using memcpy of the
+ * mapping.
+ */
+static GLboolean
+fast_read_depth_pixels( struct gl_context *ctx,
+   GLint x, GLint y,
+   GLsizei width, GLsizei height,
+   GLenum type, GLvoid *pixels,
+   const struct gl_pixelstore_attrib *packing )
+{
+   struct gl_framebuffer *fb = ctx-ReadBuffer;
+   struct gl_renderbuffer *rb = fb-Attachment[BUFFER_DEPTH].Renderbuffer;
+   GLubyte *map, *dst;
+   int stride, dstStride, j;
+
+   if (ctx-Pixel.DepthScale != 1.0 || ctx-Pixel.DepthBias != 0.0)
+  return GL_FALSE;
+
+   if (packing-SwapBytes)
+  return GL_FALSE;
+
+   if (_mesa_get_format_datatype(rb-Format) != GL_UNSIGNED_INT)
+  return GL_FALSE;
+
+   if (!((type == GL_UNSIGNED_SHORT  rb-Format == MESA_FORMAT_Z16) ||
+type == GL_UNSIGNED_INT))
+  return GL_FALSE;
+
+   ctx-Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT,
+  map, stride);
+
+   dstStride = _mesa_image_row_stride(packing, width, GL_DEPTH_COMPONENT, 
type);
+   dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
+  GL_DEPTH_COMPONENT, type, 0, 0);
+
+   for (j = 0; j  height; j++) {
+  if (type == GL_UNSIGNED_INT) {
+_mesa_unpack_uint_z_row(rb-Format, width, map, (GLuint *)dst);
+  } else {
+ASSERT(type == GL_UNSIGNED_SHORT  rb-Format == MESA_FORMAT_Z16);
+memcpy(dst, map, width * 2);
+  }
+
+  map += stride;
+  dst += dstStride;
+   }
+   ctx-Driver.UnmapRenderbuffer(ctx, rb);
+
+   return GL_TRUE;
+}
 
 /**
  * Read pixels for format=GL_DEPTH_COMPONENT.
@@ -52,8 +104,7 @@ read_depth_pixels( struct gl_context *ctx,
 {
struct gl_framebuffer *fb = ctx-ReadBuffer;
struct gl_renderbuffer *rb = fb-_DepthBuffer;
-   const GLboolean biasOrScale
-  = ctx-Pixel.DepthScale != 1.0 || ctx-Pixel.DepthBias != 0.0;
+   GLint j;
 
if (!rb)
   return;
@@ -66,72 +117,16 @@ read_depth_pixels( struct gl_context *ctx,
/* width should never be  MAX_WIDTH since we did clipping earlier */
ASSERT(width = MAX_WIDTH);
 
-   if (type == GL_UNSIGNED_SHORT  fb-Visual.depthBits == 16
-!biasOrScale  !packing-SwapBytes) {
-  /* Special case: directly read 16-bit unsigned depth values. */
-  GLint j;
-  ASSERT(rb-Format == MESA_FORMAT_Z16);
-  ASSERT(rb-DataType == GL_UNSIGNED_SHORT);
-  for (j = 0; j  height; j++, y++) {
- void *dest =_mesa_image_address2d(packing, pixels, width, height,
-   GL_DEPTH_COMPONENT, type, j, 0);
- rb-GetRow(ctx, rb, width, x, y, dest);
-  }
-   }
-   else if (type == GL_UNSIGNED_INT  fb-Visual.depthBits == 24
- !biasOrScale  !packing-SwapBytes) {
-  /* Special case: directly read 24-bit unsigned depth values. */
-  GLint j;
-  ASSERT(rb-Format == MESA_FORMAT_X8_Z24 ||
- rb-Format == MESA_FORMAT_S8_Z24 ||
- rb-Format == MESA_FORMAT_Z24_X8 ||
- rb-Format == MESA_FORMAT_Z24_S8);
-  ASSERT(rb-DataType == GL_UNSIGNED_INT ||
- rb-DataType == GL_UNSIGNED_INT_24_8);
-  for (j = 0; j  height; j++, y++) {
- GLuint *dest = (GLuint *)
-_mesa_image_address2d(packing, pixels, width, height,
-  GL_DEPTH_COMPONENT, type, j, 0);
- GLint k;
- rb-GetRow(ctx, rb, width, x, y, dest);
- /* convert range from 24-bit to 32-bit */
- if (rb-Format == MESA_FORMAT_X8_Z24 ||
- rb-Format == MESA_FORMAT_S8_Z24) {
-for (k = 0; k  width; k++) {
-   /* Note: put MSByte of 24-bit value into LSByte */
-   dest[k] = (dest[k]  8) | ((dest[k]  16)  0xff);
-}
- }
- else {
-for (k = 0; k  width; k++) {
-   /* Note: fill in LSByte by replication */
-   dest[k] = dest[k] | ((dest[k]  8)  0xff);
-}
- }
-  }
-   }
-   else if (type == GL_UNSIGNED_INT  fb-Visual.depthBits == 32
- !biasOrScale  !packing-SwapBytes) {
-   

[Mesa-dev] [PATCH 23/24] intel: Don't force a batchbuffer flush in readpixels.

2011-10-28 Thread Eric Anholt
Renderbuffer mapping handles flushing the batchbuffer if required, so
all we need to do is make sure any pending rendering has reached the
batchbuffer.
---
 src/mesa/drivers/dri/intel/intel_context.c|   10 +-
 src/mesa/drivers/dri/intel/intel_context.h|1 +
 src/mesa/drivers/dri/intel/intel_pixel_read.c |4 ++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_context.c 
b/src/mesa/drivers/dri/intel/intel_context.c
index 501b00d..5bebac7 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -511,7 +511,7 @@ intelInvalidateState(struct gl_context * ctx, GLuint 
new_state)
 }
 
 void
-intel_flush(struct gl_context *ctx)
+intel_flush_rendering_to_batch(struct gl_context *ctx)
 {
struct intel_context *intel = intel_context(ctx);
 
@@ -520,6 +520,14 @@ intel_flush(struct gl_context *ctx)
 
if (intel-gen  4)
   INTEL_FIREVERTICES(intel);
+}
+
+void
+intel_flush(struct gl_context *ctx)
+{
+   struct intel_context *intel = intel_context(ctx);
+
+   intel_flush_rendering_to_batch(ctx);
 
if (intel-batch.used)
   intel_batchbuffer_flush(intel);
diff --git a/src/mesa/drivers/dri/intel/intel_context.h 
b/src/mesa/drivers/dri/intel/intel_context.h
index 938112a..9b62435 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -478,6 +478,7 @@ extern bool intelInitContext(struct intel_context *intel,
   struct dd_function_table *functions);
 
 extern void intelFinish(struct gl_context * ctx);
+extern void intel_flush_rendering_to_batch(struct gl_context *ctx);
 extern void intel_flush(struct gl_context * ctx);
 
 extern void intelInitDriverFunctions(struct dd_function_table *functions);
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c 
b/src/mesa/drivers/dri/intel/intel_pixel_read.c
index 803d714..a79b69c 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_read.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c
@@ -172,14 +172,14 @@ intelReadPixels(struct gl_context * ctx,
struct intel_context *intel = intel_context(ctx);
bool dirty;
 
+   intel_flush_rendering_to_batch(ctx);
+
DBG(%s\n, __FUNCTION__);
 
if (do_blit_readpixels
(ctx, x, y, width, height, format, type, pack, pixels))
   return;
 
-   intel_flush(ctx);
-
/* glReadPixels() wont dirty the front buffer, so reset the dirty
 * flag after calling intel_prepare_render(). */
dirty = intel-front_buffer_dirty;
-- 
1.7.7

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


[Mesa-dev] [PATCH 24/24] i965/gen6: Improve glReadPixels() performance by blitting to a linear temp.

2011-10-28 Thread Eric Anholt
The readpixels microbenchmark in mesa-demos goes from 47Mpix/sec on
1000x1000 to 450Mpix/sec.  The 10x10 sizes stay about the same.
---
 src/mesa/drivers/dri/intel/intel_fbo.c |   89 +++-
 src/mesa/drivers/dri/intel/intel_fbo.h |2 +-
 2 files changed, 76 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c 
b/src/mesa/drivers/dri/intel/intel_fbo.c
index c9a1df5..f570339 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -41,6 +41,7 @@
 #include intel_context.h
 #include intel_batchbuffer.h
 #include intel_buffers.h
+#include intel_blit.h
 #include intel_fbo.h
 #include intel_mipmap_tree.h
 #include intel_regions.h
@@ -94,7 +95,7 @@ intel_map_renderbuffer(struct gl_context *ctx,
struct intel_context *intel = intel_context(ctx);
struct intel_renderbuffer *irb = intel_renderbuffer(rb);
GLubyte *map;
-   int stride;
+   int stride, flip_stride;
 
/* We sometimes get called with this by our intel_span.c usage. */
if (!irb-region) {
@@ -103,28 +104,82 @@ intel_map_renderbuffer(struct gl_context *ctx,
   return;
}
 
-   if (drm_intel_bo_references(intel-batch.bo, irb-region-bo)) {
-  intel_batchbuffer_flush(intel);
-   }
+   stride = irb-region-pitch * irb-region-cpp;
 
-   drm_intel_gem_bo_map_gtt(irb-region-bo);
+   /* On gen6+, we have LLC sharing, which means we can get high-performance
+* access to linear-mapped buffers.  So, blit out a tiled buffer (if
+* possible, which it isn't really for Y tiling) to a temporary BO and 
return
+* a map of that.
+*/
+   if (intel-gen = 6 
+   !(mode  GL_MAP_WRITE_BIT) 
+   irb-region-tiling == I915_TILING_X) {
+  int dst_stride = w * irb-region-cpp;
+  int src_x, src_y;
 
-   map = irb-region-bo-virtual;
-   stride = irb-region-pitch * irb-region-cpp;
+  if (rb-Name) {
+src_x = x + irb-draw_x;
+src_y = y + irb-draw_y;
+  } else {
+src_x = x;
+src_y = irb-region-height - y - h;
+  }
+
+  irb-map_bo = drm_intel_bo_alloc(intel-bufmgr, MapRenderbuffer() temp,
+  dst_stride * h, 4096);
+
+  /* We don't do the flip in the blit, because it's always so tricky to get
+   * right.
+   */
+  if (irb-map_bo 
+ intelEmitCopyBlit(intel,
+   irb-region-cpp,
+   irb-region-pitch, irb-region-bo,
+   0, irb-region-tiling,
+   dst_stride / irb-region-cpp, irb-map_bo,
+   0, I915_TILING_NONE,
+   src_x, src_y,
+   0, 0,
+   w, h,
+   GL_COPY)) {
+intel_batchbuffer_flush(intel);
+drm_intel_bo_map(irb-map_bo, false);
+
+if (rb-Name) {
+   *out_map = irb-map_bo-virtual;
+   *out_stride = dst_stride;
+} else {
+   *out_map = irb-map_bo-virtual + (h - 1) * dst_stride;
+   *out_stride = -dst_stride;
+}
+return;
+  } else {
+drm_intel_bo_unreference(irb-map_bo);
+irb-map_bo = NULL;
+  }
+   }
 
if (rb-Name == 0) {
-  map += stride * (irb-region-height - 1);
-  stride = -stride;
+  y = irb-region-height - 1 - y;
+  flip_stride = -stride;
} else {
-  map += irb-draw_x * irb-region-cpp;
-  map += (int)irb-draw_y * stride;
+  x += irb-draw_x;
+  y += irb-draw_y;
+  flip_stride = stride;
}
 
+   if (drm_intel_bo_references(intel-batch.bo, irb-region-bo)) {
+  intel_batchbuffer_flush(intel);
+   }
+
+   drm_intel_gem_bo_map_gtt(irb-region-bo);
+
+   map = irb-region-bo-virtual;
map += x * irb-region-cpp;
map += (int)y * stride;
 
*out_map = map;
-   *out_stride = stride;
+   *out_stride = flip_stride;
 }
 
 static void
@@ -133,8 +188,14 @@ intel_unmap_renderbuffer(struct gl_context *ctx,
 {
struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
-   if (irb-region)
-  drm_intel_gem_bo_unmap_gtt(irb-region-bo);
+   if (irb-map_bo) {
+  drm_intel_bo_unmap(irb-map_bo);
+  drm_intel_bo_unreference(irb-map_bo);
+  irb-map_bo = 0;
+   } else {
+  if (irb-region)
+drm_intel_gem_bo_unmap_gtt(irb-region-bo);
+   }
 }
 
 /**
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h 
b/src/mesa/drivers/dri/intel/intel_fbo.h
index e12d0fd..0aafa0d 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.h
+++ b/src/mesa/drivers/dri/intel/intel_fbo.h
@@ -44,6 +44,7 @@ struct intel_renderbuffer
 {
struct gl_renderbuffer Base;
struct intel_region *region;
+   drm_intel_bo *map_bo;
 
/** Only used by depth renderbuffers for which HiZ is enabled. */
struct intel_region *hiz_region;
@@ -57,7 +58,6 @@ struct intel_renderbuffer
 */
struct gl_renderbuffer *wrapped_depth;
struct gl_renderbuffer *wrapped_stencil;
-

[Mesa-dev] [PATCH 20/24] swrast: Drop the remaining GetRow-based glReadPixels() fast-path.

2011-10-28 Thread Eric Anholt
In all of piglit, only two tests hit it (reading to RGBA float, where
GetRow would drop floats into place from R, RG, or RGB).
---
 src/mesa/swrast/s_readpix.c |   90 ---
 1 files changed, 0 insertions(+), 90 deletions(-)

diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index b55f525..b67e081 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -212,91 +212,6 @@ read_stencil_pixels( struct gl_context *ctx,
ctx-Driver.UnmapRenderbuffer(ctx, rb);
 }
 
-
-
-/**
- * Optimized glReadPixels for particular pixel formats when pixel
- * scaling, biasing, mapping, etc. are disabled.
- * \return GL_TRUE if success, GL_FALSE if unable to do the readpixels
- */
-static GLboolean
-fast_read_rgba_pixels( struct gl_context *ctx,
-   GLint x, GLint y,
-   GLsizei width, GLsizei height,
-   GLenum format, GLenum type,
-   GLvoid *pixels,
-   const struct gl_pixelstore_attrib *packing,
-   GLbitfield transferOps)
-{
-   struct gl_renderbuffer *rb = ctx-ReadBuffer-_ColorReadBuffer;
-
-   if (!rb)
-  return GL_FALSE;
-
-   ASSERT(rb-_BaseFormat == GL_RGBA ||
- rb-_BaseFormat == GL_RGB ||
- rb-_BaseFormat == GL_RG ||
- rb-_BaseFormat == GL_RED ||
- rb-_BaseFormat == GL_LUMINANCE ||
- rb-_BaseFormat == GL_INTENSITY ||
- rb-_BaseFormat == GL_LUMINANCE_ALPHA ||
- rb-_BaseFormat == GL_ALPHA);
-
-   /* clipping should have already been done */
-   ASSERT(x + width = (GLint) rb-Width);
-   ASSERT(y + height = (GLint) rb-Height);
-
-   /* check for things we can't handle here */
-   if (transferOps ||
-   packing-SwapBytes ||
-   packing-LsbFirst) {
-  return GL_FALSE;
-   }
-
-   if (format == GL_RGBA  rb-DataType == type) {
-  const GLint dstStride = _mesa_image_row_stride(packing, width,
- format, type);
-  GLubyte *dest
- = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
- format, type, 0, 0);
-  GLint row;
-  ASSERT(rb-GetRow);
-  for (row = 0; row  height; row++) {
- rb-GetRow(ctx, rb, width, x, y + row, dest);
- dest += dstStride;
-  }
-  return GL_TRUE;
-   }
-
-   if (format == GL_RGB 
-   rb-DataType == GL_UNSIGNED_BYTE 
-   type == GL_UNSIGNED_BYTE) {
-  const GLint dstStride = _mesa_image_row_stride(packing, width,
- format, type);
-  GLubyte *dest
- = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
- format, type, 0, 0);
-  GLint row;
-  ASSERT(rb-GetRow);
-  for (row = 0; row  height; row++) {
- GLubyte tempRow[MAX_WIDTH][4];
- GLint col;
- rb-GetRow(ctx, rb, width, x, y + row, tempRow);
- /* convert RGBA to RGB */
- for (col = 0; col  width; col++) {
-dest[col * 3 + 0] = tempRow[col][0];
-dest[col * 3 + 1] = tempRow[col][1];
-dest[col * 3 + 2] = tempRow[col][2];
- }
- dest += dstStride;
-  }
-  return GL_TRUE;
-   }
-
-   /* not handled */
-   return GL_FALSE;
-}
-
 static GLboolean
 fast_read_rgba_pixels_memcpy( struct gl_context *ctx,
  GLint x, GLint y,
@@ -402,11 +317,6 @@ read_rgba_pixels( struct gl_context *ctx,
   transferOps)) {
 return;
   }
-
-  if (fast_read_rgba_pixels(ctx, x, y, width, height,
-   format, type, pixels, packing, transferOps)) {
-return;
-  }
}
 
slow_read_rgba_pixels(ctx, x, y, width, height,
-- 
1.7.7

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


[Mesa-dev] [PATCH 22/24] radeon: Remove early dereference of src/dst width in glCopyTexSubImage.

2011-10-28 Thread Eric Anholt
There doesn't appear to be any particular reason for this -- it's not
like the width is changing between the deref and the use.
---
 src/mesa/drivers/dri/radeon/radeon_tex_copy.c |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c 
b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
index 47b4180..bc9015e 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
@@ -51,8 +51,6 @@ do_copy_texsubimage(struct gl_context *ctx,
 unsigned dst_bpp;
 gl_format src_mesaformat;
 gl_format dst_mesaformat;
-unsigned src_width;
-unsigned dst_width;
 unsigned flip_y;
 
 if (!radeon-vtbl.blit) {
@@ -101,8 +99,6 @@ do_copy_texsubimage(struct gl_context *ctx,
 
 src_mesaformat = rrb-base.Format;
 dst_mesaformat = timg-base.Base.TexFormat;
-src_width = rrb-base.Width;
-dst_width = timg-base.Base.Width;
 src_bpp = _mesa_get_format_bytes(src_mesaformat);
 dst_bpp = _mesa_get_format_bytes(dst_mesaformat);
 if (!radeon-vtbl.check_blit(dst_mesaformat)) {
@@ -133,10 +129,10 @@ do_copy_texsubimage(struct gl_context *ctx,
 
 /* blit from src buffer to texture */
 return radeon-vtbl.blit(ctx, rrb-bo, src_offset, src_mesaformat, 
rrb-pitch/rrb-cpp,
- src_width, rrb-base.Height, x, y,
+ rrb-base.Width, rrb-base.Height, x, y,
  timg-mt-bo, dst_offset, dst_mesaformat,
  timg-mt-levels[level].rowstride / dst_bpp,
- dst_width, timg-base.Base.Height,
+ timg-base.Base.Width, timg-base.Base.Height,
  dstx, dsty, width, height, flip_y);
 }
 
-- 
1.7.7

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


Re: [Mesa-dev] [PATCH 1/2] glsl: Generate an error for array-of-array declarations

2011-10-28 Thread Kenneth Graunke
On 10/26/2011 02:46 PM, Ian Romanick wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 Other parts of the code already caught things like 'float x[4][2]'.
 However, nothing caught 'float [4] x[2]'.
 
 Fixes piglit test array-multidimensional-new-syntax.vert.
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com

For the series:
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

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


Re: [Mesa-dev] [PATCH 05/20] glsl: Add new structures for tracking uniforms in linked shaders

2011-10-28 Thread Eric Anholt
On Fri, 28 Oct 2011 10:42:32 -0700, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 ---
  src/glsl/ir_uniform.h |  128 
 +
  1 files changed, 128 insertions(+), 0 deletions(-)
  create mode 100644 src/glsl/ir_uniform.h
 
 diff --git a/src/glsl/ir_uniform.h b/src/glsl/ir_uniform.h
 new file mode 100644
 index 000..ba442f8
 --- /dev/null
 +++ b/src/glsl/ir_uniform.h
 @@ -0,0 +1,128 @@
 +   /**
 +* Set each time the value of the uniform is change.

is changed

 +* Drivers that do not used the \c ::driver_storage interface should clear

do not use

 +* this bit when the value of the uniform is updated on the hardware.
 +*/
 +   unsigned dirty:1;
 +
 +   /**
 +* Base sampler index
 +*
 +* If \c ::base_type is \c GLSL_TYPE_SAMPLER, this represents the base
 +* index of this sampler.
 +*/
 +   unsigned sampler:8;

Not sure what the base index of a sampler is.


pgpRgnw1sSov9.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 05/20] glsl: Add new structures for tracking uniforms in linked shaders

2011-10-28 Thread Ian Romanick

On 10/28/2011 01:23 PM, Eric Anholt wrote:

On Fri, 28 Oct 2011 10:42:32 -0700, Ian Romanicki...@freedesktop.org  wrote:

From: Ian Romanickian.d.roman...@intel.com

Signed-off-by: Ian Romanickian.d.roman...@intel.com
---
  src/glsl/ir_uniform.h |  128 +
  1 files changed, 128 insertions(+), 0 deletions(-)
  create mode 100644 src/glsl/ir_uniform.h

diff --git a/src/glsl/ir_uniform.h b/src/glsl/ir_uniform.h
new file mode 100644
index 000..ba442f8
--- /dev/null
+++ b/src/glsl/ir_uniform.h
@@ -0,0 +1,128 @@
+   /**
+* Set each time the value of the uniform is change.


is changed


+* Drivers that do not used the \c ::driver_storage interface should clear


do not use


+* this bit when the value of the uniform is updated on the hardware.
+*/
+   unsigned dirty:1;
+
+   /**
+* Base sampler index
+*
+* If \c ::base_type is \c GLSL_TYPE_SAMPLER, this represents the base
+* index of this sampler.
+*/
+   unsigned sampler:8;


Not sure what the base index of a sampler is.


If you have an array of samplers, it's the index of the sampler at 
array[0].  The array will use sampler indices base_index through 
base_index + array_elements - 1.

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


Re: [Mesa-dev] [PATCH 09/20] linker: Add helper class for determining uniform usage

2011-10-28 Thread Eric Anholt
On Fri, 28 Oct 2011 10:42:36 -0700, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 This class could probably be named better.

Maybe just count_uniform_size?  usage makes me think way it's
dereferenced or something.


pgp8IA7B0UhWe.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 12/20] linker: Track uniform locations to new tracking structures

2011-10-28 Thread Eric Anholt
On Fri, 28 Oct 2011 10:42:39 -0700, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 This is just the infrastructure and the code.  It's not used yet.
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 ---
  src/glsl/link_uniforms.cpp |   95 
 
  src/glsl/linker.h  |3 +
  2 files changed, 98 insertions(+), 0 deletions(-)
 
 diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
 index 54af326..a87e69f 100644
 --- a/src/glsl/link_uniforms.cpp
 +++ b/src/glsl/link_uniforms.cpp
 +   /* First pass: Count the uniform resources used by the user-defined
 +* uniforms.  While this happens, each active uniform will have an index
 +* assined to it.

assigned

 +* Note: this is *NOT* the index that is returned to the application by
 +* glGetUnfiormLocation.

Uniform

 +*/
 +   count_uniform_usage usage(prog-UniformHash);
 +   for (unsigned i = 0; i  MESA_SHADER_TYPES; i++) {
 +  if (prog-_LinkedShaders[i] == NULL)
 +  continue;
 +
 +  foreach_list(node, prog-_LinkedShaders[i]-ir) {
 +  ir_variable *const var = ((ir_instruction *) node)-as_variable();
 +
 +  if ((var == NULL) || (var-mode != ir_var_uniform))
 + continue;
 +
 +  /* FINISHME: Update code to process built-in uniforms!
 +   */
 +  if (strncmp(gl_, var-name, 3) == 0)
 + continue;
 +
 +  usage.process(var);
 +  }
 +   }
 +
 +   const unsigned num_user_uniforms = usage.num_active_uniforms;
 +   const unsigned num_data_slots = usage.num_values;
 +
 +   /* On the outside chance that there were no uniforms, bail out.
 +*/
 +   if (num_user_uniforms == 0)
 +  return;

No need to set NumUserUniformStorage?



pgpmrBtkoM1LQ.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] r600g: remove one pointless flush

2011-10-28 Thread Vadim Girlin
On Fri, 2011-10-28 at 19:47 +0200, Marek Olšák wrote:
 I've got no idea what the flush was good for, but it's useless from
 the looks of it. The rest of the patch is just a cleanup resulting
 from some of the variables being no longer used for anything useful.
 
 There are no piglit regressions.

It was intended to handle multiple interleaved query and conditional
render calls with single query object (in this case in theory we may
have multiple outstanding queries in current CS and separate data block
in the buffer for each query, with possible buffer overflow). I wasn't
sure if this is possible to do in one CS, so I used this additional
check to be on the safe side. Probably such situation is not possible
currently due to the flushes from the other paths, but might be possible
in the future after removing all unnecessary flushes. If you think it
won't be possible at all, I'm OK with this patch. Though I don't like
existing solution in any case, so even if we'll need this check later,
probably it should be done in some better way. 

IIRR this case isn't covered by the piglit. Probably I'll try to
create/modify some test for this.

Vadim

 ---
  src/gallium/drivers/r600/r600.h|6 +-
  src/gallium/drivers/r600/r600_blit.c   |2 +-
  src/gallium/drivers/r600/r600_hw_context.c |   21 ++---
  3 files changed, 4 insertions(+), 25 deletions(-)
 
 diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
 index f58549a..9367651 100644
 --- a/src/gallium/drivers/r600/r600.h
 +++ b/src/gallium/drivers/r600/r600.h
 @@ -176,10 +176,6 @@ struct r600_query {
   unsignedresults_end;
   /* Size of the result */
   unsignedresult_size;
 - /* Count of new queries started in one stream without flushing */
 - unsignedqueries_emitted;
 - /* State flags */
 - boolean flushed;
   /* The buffer where query results are stored. It's used as a ring,
* data blocks for current query are stored sequentially from
* results_start to results_end, with wrapping on the buffer end */
 @@ -258,7 +254,7 @@ boolean r600_context_query_result(struct r600_context 
 *ctx,
  void r600_query_begin(struct r600_context *ctx, struct r600_query *query);
  void r600_query_end(struct r600_context *ctx, struct r600_query *query);
  void r600_context_queries_suspend(struct r600_context *ctx);
 -void r600_context_queries_resume(struct r600_context *ctx, boolean flushed);
 +void r600_context_queries_resume(struct r600_context *ctx);
  void r600_query_predication(struct r600_context *ctx, struct r600_query 
 *query, int operation,
   int flag_wait);
  void r600_context_emit_fence(struct r600_context *ctx, struct r600_resource 
 *fence,
 diff --git a/src/gallium/drivers/r600/r600_blit.c 
 b/src/gallium/drivers/r600/r600_blit.c
 index 3eba0ad..9326dc6 100644
 --- a/src/gallium/drivers/r600/r600_blit.c
 +++ b/src/gallium/drivers/r600/r600_blit.c
 @@ -96,7 +96,7 @@ static void r600_blitter_end(struct pipe_context *ctx)
  rctx-saved_render_cond_mode);
   rctx-saved_render_cond = NULL;
   }
 - r600_context_queries_resume(rctx-ctx, FALSE);
 + r600_context_queries_resume(rctx-ctx);
  }
  
  static unsigned u_num_layers(struct pipe_resource *r, unsigned level)
 diff --git a/src/gallium/drivers/r600/r600_hw_context.c 
 b/src/gallium/drivers/r600/r600_hw_context.c
 index a7d7ce6..1332748 100644
 --- a/src/gallium/drivers/r600/r600_hw_context.c
 +++ b/src/gallium/drivers/r600/r600_hw_context.c
 @@ -1521,7 +1521,7 @@ void r600_context_flush(struct r600_context *ctx, 
 unsigned flags)
   r600_init_cs(ctx);
  
   /* resume queries */
 - r600_context_queries_resume(ctx, TRUE);
 + r600_context_queries_resume(ctx);
  
   /* set all valid group as dirty so they get reemited on
* next draw command
 @@ -1619,18 +1619,6 @@ void r600_query_begin(struct r600_context *ctx, struct 
 r600_query *query)
   r600_context_flush(ctx, RADEON_FLUSH_ASYNC);
   }
  
 - if (query-type == PIPE_QUERY_OCCLUSION_COUNTER) {
 - /* Count queries emitted without flushes, and flush if more than
 -  * half of buffer used, to avoid overwriting results which may 
 be
 -  * still in use. */
 - if (query-flushed) {
 - query-queries_emitted = 1;
 - } else {
 - if (++query-queries_emitted  
 query-buffer-b.b.b.width0 / query-result_size / 2)
 - r600_context_flush(ctx, RADEON_FLUSH_ASYNC);
 - }
 - }
 -
   new_results_end = query-results_end + query-result_size;
   if (new_results_end = query-buffer-b.b.b.width0)
   new_results_end = 0;
 @@ -1713,8 +1701,6 @@ void 

Re: [Mesa-dev] [PATCH 13/20] mesa: Add _mesa_propagate_uniforms_to_driver_storage

2011-10-28 Thread Eric Anholt
On Fri, 28 Oct 2011 10:42:40 -0700, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 This function propagates the values from the backing storage of a
 gl_uniform_storage structure to the driver supplied data locations.
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 ---
  src/mesa/main/uniform_query.cpp |  117 
 +++
  src/mesa/main/uniforms.h|5 ++
  2 files changed, 122 insertions(+), 0 deletions(-)
 
 diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
 index 781af2d..c693055 100644
 --- a/src/mesa/main/uniform_query.cpp
 +++ b/src/mesa/main/uniform_query.cpp
 @@ -26,6 +26,7 @@
  #include main/context.h
  #include ir.h
  #include ../glsl/program.h
 +#include ../glsl/ir_uniform.h
  
  extern C {
  #include main/image.h
 @@ -728,6 +729,122 @@ set_program_uniform(struct gl_context *ctx, struct 
 gl_program *program,
  }
  
  /**
 + * Propagate some values from uniform backing storage to driver storage
 + *
 + * Values propagates from uniform backing storage to driver storage

propagated


pgpayJczwLDN4.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 14/20] mesa: Add _mesa_uniform_{attach, detach_all}_driver_storage functions

2011-10-28 Thread Eric Anholt
On Fri, 28 Oct 2011 10:42:41 -0700, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 This functions are used to create and destroy the connections between

These


pgpyKHsOz0pvy.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] r600g: remove one pointless flush

2011-10-28 Thread Marek Olšák
On Fri, Oct 28, 2011 at 10:52 PM, Vadim Girlin vadimgir...@gmail.com wrote:
 On Fri, 2011-10-28 at 19:47 +0200, Marek Olšák wrote:
 I've got no idea what the flush was good for, but it's useless from
 the looks of it. The rest of the patch is just a cleanup resulting
 from some of the variables being no longer used for anything useful.

 There are no piglit regressions.

 It was intended to handle multiple interleaved query and conditional
 render calls with single query object (in this case in theory we may
 have multiple outstanding queries in current CS and separate data block
 in the buffer for each query, with possible buffer overflow). I wasn't

Do you mean this?

while (1) {
  begin_query(q);
  draw();
  end_query(q);
  render_condition(q);
  draw();
  render_condition(NULL);
}

begin_query always resets query results to 0 anyway, so in theory, we
could re-use the same data block over and over again. I think the only
case where buffer overflow may happen is:

begin_query(q);
while (1) {
  draw();
  suspend_queries(); // flush or u_blitter
  resume_queries();
}
end_query(q);

Correct?

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


Re: [Mesa-dev] [PATCH 05/20] glsl: Add new structures for tracking uniforms in linked shaders

2011-10-28 Thread Eric Anholt
On Fri, 28 Oct 2011 10:42:32 -0700, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 ---
  src/glsl/ir_uniform.h |  128 
 +
  1 files changed, 128 insertions(+), 0 deletions(-)
  create mode 100644 src/glsl/ir_uniform.h
 
 diff --git a/src/glsl/ir_uniform.h b/src/glsl/ir_uniform.h
 new file mode 100644
 index 000..ba442f8
 --- /dev/null
 +++ b/src/glsl/ir_uniform.h

 +   /**
 +* Set each time the value of the uniform is change.
 +*
 +* Drivers that do not used the \c ::driver_storage interface should clear
 +* this bit when the value of the uniform is updated on the hardware.
 +*/
 +   unsigned dirty:1;

Having reached near the end of the patch series, I don't see any user of
the dirty bit, nor any reasonable way for someone to actually use the
dirty bit.  Are you imagining some implementation where somebody's
DMAing in the dirty uniform components into an existing hardware uniform
buffer?  Wouldn't that be a property of driver storage, not this
structure?


pgpKENb3mhIm3.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] r600g: remove one pointless flush

2011-10-28 Thread Vadim Girlin
On Fri, 2011-10-28 at 23:16 +0200, Marek Olšák wrote:
 On Fri, Oct 28, 2011 at 10:52 PM, Vadim Girlin vadimgir...@gmail.com wrote:
  On Fri, 2011-10-28 at 19:47 +0200, Marek Olšák wrote:
  I've got no idea what the flush was good for, but it's useless from
  the looks of it. The rest of the patch is just a cleanup resulting
  from some of the variables being no longer used for anything useful.
 
  There are no piglit regressions.
 
  It was intended to handle multiple interleaved query and conditional
  render calls with single query object (in this case in theory we may
  have multiple outstanding queries in current CS and separate data block
  in the buffer for each query, with possible buffer overflow). I wasn't
 
 Do you mean this?
 
 while (1) {
   begin_query(q);
   draw();
   end_query(q);
   render_condition(q);
   draw();
   render_condition(NULL);
 }
 
 begin_query always resets query results to 0 anyway, so in theory, we
 could re-use the same data block over and over again. 

I think it's possible to run this loop without flushes, so we'll have
multiple queries queued in current cs. From the driver point of view
these queries will be executed simultaneously after flush, that's why we
need to reserve and initialize separate data blocks for them.

Vadim

 I think the only
 case where buffer overflow may happen is:
 
 begin_query(q);
 while (1) {
   draw();
   suspend_queries(); // flush or u_blitter
   resume_queries();
 }
 end_query(q);
 
 Correct?
 
 Marek



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


Re: [Mesa-dev] [PATCH 18/20] mesa: Rewrite the way uniforms are tracked and handled

2011-10-28 Thread Eric Anholt
On Fri, 28 Oct 2011 10:42:45 -0700, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 Switch all of the code in ir_to_mesa, st_glsl_to_tgsi, glUniform*,
 glGetUniform, glGetUniformLocation, and glGetActiveUniforms to use the
 gl_uniform_storage structures in the gl_shader_program.
 
 A couple of notes:
 
  * Like most rewrite-the-world patches, this should be reviewed by
applying the patch and examining the modified functions.
 
  * This leaves a lot of dead code around in linker.cpp and
uniform_query.cpp.  This will be deleted in the next patches.
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 ---
  src/glsl/linker.cpp|2 +-
  src/mesa/main/shaderapi.c  |   22 +-
  src/mesa/main/shaderobj.c  |   12 +-
  src/mesa/main/uniform_query.cpp|  627 
 +++-
  src/mesa/main/uniforms.c   |8 +-
  src/mesa/main/uniforms.h   |4 +-
  src/mesa/program/ir_to_mesa.cpp|   47 ++-
  src/mesa/program/sampler.cpp   |   12 +-
  src/mesa/state_tracker/st_draw.c   |   10 +-
  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   13 +-
  10 files changed, 505 insertions(+), 252 deletions(-)
 

 diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
 index db2f200..50a724b 100644
 --- a/src/mesa/main/uniform_query.cpp
 +++ b/src/mesa/main/uniform_query.cpp

 +  log_uniform(values, basicType, components, 1, count,
 +   false, shProg, location, uni);
 +   }
 +
 +   /* Validate the texture unit setting.
 +*/
 +   /* FINISHME: I cannot find any justification for this in the GL spec.
 +*/

I think this maybe comes from (2.1 spec, page 106):

Setting a sampler’s value to i selects texture image unit number
 i. The values of i range from zero to the implementation-dependent
 maximum supported number of texture image units.

Though the spec doesn't say what *should* happen when someone gives an i
out of range.  This seems like a reasonable behavior, though.

 @@ -3288,6 +3290,15 @@ get_mesa_program(struct gl_context *ctx,
}
 }
  
 +   /* This has to be done last.  Any operation the can cause

that can



pgpgGprZjecX4.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 17/20] i965: Move _mesa_ir_link_shader call before device-specific linking

2011-10-28 Thread Eric Anholt
On Fri, 28 Oct 2011 10:42:44 -0700, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 _mesa_ir_link_shader needs to be called before cloning the IR tree so
 that the var-location field for uniforms is set.
 
 WARNING: This change breaks several integer division related piglit
 tests.  The tests break because _mesa_ir_link_shader lowers integer
 division to an RCP followed by a MUL.  The fix is to factor out more
 of the code from ir_to_mesa so that _mesa_ir_link_shader does not need
 to be called at all by the i965 driver.  This will be the subject of
 several follow-on patches.

How close are we to avoiding Mesa IR at this point?  I'd rather see us
hack in something to suppress that lowering or something if it's going
to be very long.


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


[Mesa-dev] DRI1 Cleanup

2011-10-28 Thread Kristian Høgsberg
Hello,

Here's a follow-up series to Eric's removal of the last DRI1 driver.
Now that all DRI drivers are DRI2-only, there's a lot of DRI1 driver
infrastructure that we can remove.

Kristian

 .../state_trackers/dri/common/dri_drawable.c   |6 +-
 src/gallium/state_trackers/dri/drm/Makefile|4 +-
 src/gallium/state_trackers/dri/drm/dri2.c  |   30 +-
 src/gallium/state_trackers/dri/sw/dri_drawable.c   |6 +-
 src/gallium/targets/Makefile.dri   |4 +-
 src/mesa/drivers/dri/common/Makefile.sources   |5 +-
 src/mesa/drivers/dri/common/dri_util.c |  577 +
 src/mesa/drivers/dri/common/dri_util.h |  284 +
 src/mesa/drivers/dri/common/drirenderbuffer.c  |  200 ---
 src/mesa/drivers/dri/common/drirenderbuffer.h  |   71 -
 src/mesa/drivers/dri/common/memops.h   |   17 -
 src/mesa/drivers/dri/common/spantmp_common.h   |   11 +-
 src/mesa/drivers/dri/common/texmem.c   | 1338 
 src/mesa/drivers/dri/common/texmem.h   |  330 -
 src/mesa/drivers/dri/common/utils.c|  118 --
 src/mesa/drivers/dri/common/utils.h|   25 -
 src/mesa/drivers/dri/common/vblank.c   |  434 ---
 src/mesa/drivers/dri/common/vblank.h   |   71 -
 src/mesa/drivers/dri/i915/i830_state.c |2 -
 src/mesa/drivers/dri/i915/i915_state.c |2 -
 src/mesa/drivers/dri/intel/intel_context.c |   18 +-
 src/mesa/drivers/dri/intel/intel_screen.c  |1 -
 src/mesa/drivers/dri/nouveau/nouveau_context.c |8 +-
 src/mesa/drivers/dri/r200/r200_context.h   |1 -
 src/mesa/drivers/dri/r200/r200_ioctl.c |2 -
 src/mesa/drivers/dri/r200/r200_state.c |   12 +-
 src/mesa/drivers/dri/r200/r200_swtcl.c |3 +-
 src/mesa/drivers/dri/r200/r200_tex.c   |1 -
 src/mesa/drivers/dri/radeon/radeon_common.c|5 -
 .../drivers/dri/radeon/radeon_common_context.c |  121 +--
 .../drivers/dri/radeon/radeon_common_context.h |1 -
 src/mesa/drivers/dri/radeon/radeon_context.h   |1 -
 src/mesa/drivers/dri/radeon/radeon_dma.c   |4 +-
 src/mesa/drivers/dri/radeon/radeon_fbo.c   |6 +-
 src/mesa/drivers/dri/radeon/radeon_ioctl.c |2 -
 src/mesa/drivers/dri/radeon/radeon_screen.c|   11 -
 src/mesa/drivers/dri/radeon/radeon_state.c |   12 +-
 src/mesa/drivers/dri/radeon/radeon_texture.c   |   78 +-
 src/mesa/drivers/dri/radeon/radeon_texture.h   |8 +
 39 files changed, 135 insertions(+), 3695 deletions(-)


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


[Mesa-dev] [PATCH 01/27] dri: Drop driLegacyExtension

2011-10-28 Thread Kristian Høgsberg
There are no DRI1 drivers left.
---
 src/gallium/state_trackers/dri/drm/dri2.c   |1 -
 src/mesa/drivers/dri/common/dri_util.c  |8 
 src/mesa/drivers/dri/common/dri_util.h  |1 -
 src/mesa/drivers/dri/radeon/radeon_screen.c |1 -
 4 files changed, 0 insertions(+), 11 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index f3c9e10..68848aa 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -741,7 +741,6 @@ const struct __DriverAPIRec driDriverAPI = {
 /* This is the table of extensions that the loader will dlsym() for. */
 PUBLIC const __DRIextension *__driDriverExtensions[] = {
 driCoreExtension.base,
-driLegacyExtension.base,
 driDRI2Extension.base,
 NULL
 };
diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index cdd4137..ffaa9f9 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -943,14 +943,6 @@ const __DRIcoreExtension driCoreExtension = {
 driUnbindContext
 };
 
-/** Legacy DRI interface */
-const __DRIlegacyExtension driLegacyExtension = {
-{ __DRI_LEGACY, __DRI_LEGACY_VERSION },
-driCreateNewScreen,
-driCreateNewDrawable,
-driCreateNewContext,
-};
-
 /** DRI2 interface */
 const __DRIdri2Extension driDRI2Extension = {
 { __DRI_DRI2, __DRI_DRI2_VERSION },
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index 3d3d5c9..0f6a061 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -63,7 +63,6 @@ typedef struct __DRIswapInfoRec__DRIswapInfo;
 /**
  * Extensions.
  */
-extern const __DRIlegacyExtension driLegacyExtension;
 extern const __DRIcoreExtension driCoreExtension;
 extern const __DRIdri2Extension driDRI2Extension;
 extern const __DRIextension driReadDrawableExtension;
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index c142239..7dc5cbd 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -1555,7 +1555,6 @@ const struct __DriverAPIRec driDriverAPI = {
 /* This is the table of extensions that the loader will dlsym() for. */
 PUBLIC const __DRIextension *__driDriverExtensions[] = {
 driCoreExtension.base,
-driLegacyExtension.base,
 driDRI2Extension.base,
 NULL
 };
-- 
1.7.7

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


[Mesa-dev] [PATCH 02/27] dri: Drop driReadDrawableExtension

2011-10-28 Thread Kristian Høgsberg
All DRI2 drivers support setting a separate read drawable.
---
 src/gallium/state_trackers/dri/drm/dri2.c   |2 --
 src/mesa/drivers/dri/common/dri_util.c  |8 
 src/mesa/drivers/dri/common/dri_util.h  |1 -
 src/mesa/drivers/dri/intel/intel_screen.c   |1 -
 src/mesa/drivers/dri/radeon/radeon_screen.c |1 -
 5 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 68848aa..0c6f165 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -612,7 +612,6 @@ static struct __DRIimageExtensionRec dri2ImageExtension = {
  */
 
 static const __DRIextension *dri_screen_extensions[] = {
-   driReadDrawableExtension,
driCopySubBufferExtension.base,
driSwapControlExtension.base,
driMediaStreamCounterExtension.base,
@@ -624,7 +623,6 @@ static const __DRIextension *dri_screen_extensions[] = {
 };
 
 static const __DRIextension *dri_screen_extensions_throttle[] = {
-   driReadDrawableExtension,
driCopySubBufferExtension.base,
driSwapControlExtension.base,
driMediaStreamCounterExtension.base,
diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index ffaa9f9..90eba67 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -50,14 +50,6 @@ typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) 
(__DRIdrawable *drawable, int32_t
 static void dri_get_drawable(__DRIdrawable *pdp);
 static void dri_put_drawable(__DRIdrawable *pdp);
 
-/**
- * This is just a token extension used to signal that the driver
- * supports setting a read drawable.
- */
-const __DRIextension driReadDrawableExtension = {
-__DRI_READ_DRAWABLE, __DRI_READ_DRAWABLE_VERSION
-};
-
 GLint
 driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 )
 {
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index 0f6a061..2db8c97 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -65,7 +65,6 @@ typedef struct __DRIswapInfoRec__DRIswapInfo;
  */
 extern const __DRIcoreExtension driCoreExtension;
 extern const __DRIdri2Extension driDRI2Extension;
-extern const __DRIextension driReadDrawableExtension;
 extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
 extern const __DRIswapControlExtension driSwapControlExtension;
 extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension;
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c 
b/src/mesa/drivers/dri/intel/intel_screen.c
index 6a6b851..4ee70f9 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -326,7 +326,6 @@ static struct __DRIimageExtensionRec intelImageExtension = {
 };
 
 static const __DRIextension *intelScreenExtensions[] = {
-driReadDrawableExtension,
 intelTexBufferExtension.base,
 intelFlushExtension.base,
 intelImageExtension.base,
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 7dc5cbd..167091b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -1270,7 +1270,6 @@ radeonCreateScreen2(__DRIscreen *sPriv)
 
i = 0;
screen-extensions[i++] = driCopySubBufferExtension.base;
-   screen-extensions[i++] = driReadDrawableExtension;
screen-extensions[i++] = dri2ConfigQueryExtension.base;
 
if ( screen-irq != 0 ) {
-- 
1.7.7

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


[Mesa-dev] [PATCH 03/27] dri: Drop driCopySubBufferExtension

2011-10-28 Thread Kristian Høgsberg
Another DRI1-only extension.
---
 src/gallium/state_trackers/dri/drm/dri2.c   |2 --
 src/mesa/drivers/dri/common/dri_util.c  |   19 ---
 src/mesa/drivers/dri/common/dri_util.h  |1 -
 src/mesa/drivers/dri/radeon/radeon_screen.c |1 -
 4 files changed, 0 insertions(+), 23 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 0c6f165..2194856 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -612,7 +612,6 @@ static struct __DRIimageExtensionRec dri2ImageExtension = {
  */
 
 static const __DRIextension *dri_screen_extensions[] = {
-   driCopySubBufferExtension.base,
driSwapControlExtension.base,
driMediaStreamCounterExtension.base,
driTexBufferExtension.base,
@@ -623,7 +622,6 @@ static const __DRIextension *dri_screen_extensions[] = {
 };
 
 static const __DRIextension *dri_screen_extensions_throttle[] = {
-   driCopySubBufferExtension.base,
driSwapControlExtension.base,
driMediaStreamCounterExtension.base,
driTexBufferExtension.base,
diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 90eba67..6e7c1ed 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -360,25 +360,6 @@ const __DRImediaStreamCounterExtension 
driMediaStreamCounterExtension = {
 };
 
 
-static void driCopySubBuffer(__DRIdrawable *dPriv,
- int x, int y, int w, int h)
-{
-drm_clip_rect_t rect;
-
-rect.x1 = x;
-rect.y1 = dPriv-h - y - h;
-rect.x2 = x + w;
-rect.y2 = rect.y1 + h;
-driReportDamage(dPriv, rect, 1);
-
-dPriv-driScreenPriv-DriverAPI.CopySubBuffer(dPriv, x, y, w, h);
-}
-
-const __DRIcopySubBufferExtension driCopySubBufferExtension = {
-{ __DRI_COPY_SUB_BUFFER, __DRI_COPY_SUB_BUFFER_VERSION },
-driCopySubBuffer
-};
-
 static void driSetSwapInterval(__DRIdrawable *dPriv, unsigned int interval)
 {
 dPriv-swap_interval = interval;
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index 2db8c97..292cbef 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -65,7 +65,6 @@ typedef struct __DRIswapInfoRec__DRIswapInfo;
  */
 extern const __DRIcoreExtension driCoreExtension;
 extern const __DRIdri2Extension driDRI2Extension;
-extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
 extern const __DRIswapControlExtension driSwapControlExtension;
 extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension;
 extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 167091b..fd0aea7 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -1269,7 +1269,6 @@ radeonCreateScreen2(__DRIscreen *sPriv)
}
 
i = 0;
-   screen-extensions[i++] = driCopySubBufferExtension.base;
screen-extensions[i++] = dri2ConfigQueryExtension.base;
 
if ( screen-irq != 0 ) {
-- 
1.7.7

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


[Mesa-dev] [PATCH 04/27] dri: Remove driSwapControlExtension

2011-10-28 Thread Kristian Høgsberg
DRI1-only as well.
---
 src/gallium/state_trackers/dri/drm/dri2.c   |2 --
 src/mesa/drivers/dri/common/dri_util.c  |   17 -
 src/mesa/drivers/dri/common/dri_util.h  |1 -
 src/mesa/drivers/dri/radeon/radeon_screen.c |4 +---
 4 files changed, 1 insertions(+), 23 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 2194856..637d000 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -612,7 +612,6 @@ static struct __DRIimageExtensionRec dri2ImageExtension = {
  */
 
 static const __DRIextension *dri_screen_extensions[] = {
-   driSwapControlExtension.base,
driMediaStreamCounterExtension.base,
driTexBufferExtension.base,
dri2FlushExtension.base,
@@ -622,7 +621,6 @@ static const __DRIextension *dri_screen_extensions[] = {
 };
 
 static const __DRIextension *dri_screen_extensions_throttle[] = {
-   driSwapControlExtension.base,
driMediaStreamCounterExtension.base,
driTexBufferExtension.base,
dri2FlushExtension.base,
diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 6e7c1ed..5d9b251 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -360,23 +360,6 @@ const __DRImediaStreamCounterExtension 
driMediaStreamCounterExtension = {
 };
 
 
-static void driSetSwapInterval(__DRIdrawable *dPriv, unsigned int interval)
-{
-dPriv-swap_interval = interval;
-}
-
-static unsigned int driGetSwapInterval(__DRIdrawable *dPriv)
-{
-return dPriv-swap_interval;
-}
-
-const __DRIswapControlExtension driSwapControlExtension = {
-{ __DRI_SWAP_CONTROL, __DRI_SWAP_CONTROL_VERSION },
-driSetSwapInterval,
-driGetSwapInterval
-};
-
-
 /**
  * This is called via __DRIscreenRec's createNewDrawable pointer.
  */
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index 292cbef..c1e6712 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -65,7 +65,6 @@ typedef struct __DRIswapInfoRec__DRIswapInfo;
  */
 extern const __DRIcoreExtension driCoreExtension;
 extern const __DRIdri2Extension driDRI2Extension;
-extern const __DRIswapControlExtension driSwapControlExtension;
 extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension;
 extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index fd0aea7..23ec8ec 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -1271,10 +1271,8 @@ radeonCreateScreen2(__DRIscreen *sPriv)
i = 0;
screen-extensions[i++] = dri2ConfigQueryExtension.base;
 
-   if ( screen-irq != 0 ) {
-   screen-extensions[i++] = driSwapControlExtension.base;
+   if ( screen-irq != 0 )
screen-extensions[i++] = driMediaStreamCounterExtension.base;
-   }
 
 #if defined(RADEON_R100)
screen-extensions[i++] = radeonTexBufferExtension.base;
-- 
1.7.7

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


[Mesa-dev] [PATCH 06/27] dri: Remove unused __DRIswapInfoRec

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.h |   40 
 1 files changed, 0 insertions(+), 40 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index 2f33a62..1ace19e 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -58,8 +58,6 @@
 
 #define GLX_BAD_CONTEXT5
 
-typedef struct __DRIswapInfoRec__DRIswapInfo;
-
 /**
  * Extensions.
  */
@@ -183,13 +181,6 @@ struct __DriverAPIRec {
 GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
   
 /**
- * Retrieves statistics about buffer swap operations.  Required if
- * GLX_OML_sync_control or GLX_MESA_swap_frame_usage is supported.
- */
-int (*GetSwapInfo)( __DRIdrawable *dPriv, __DRIswapInfo * sInfo );
-
-
-/**
  * These are required if GLX_OML_sync_control is supported.
  */
 /*@{*/
@@ -229,37 +220,6 @@ struct __DriverAPIRec {
 extern const struct __DriverAPIRec driDriverAPI;
 
 
-struct __DRIswapInfoRec {
-/** 
- * Number of swapBuffers operations that have been *completed*. 
- */
-uint64_t swap_count;
-
-/**
- * Unadjusted system time of the last buffer swap.  This is the time
- * when the swap completed, not the time when swapBuffers was called.
- */
-int64_t   swap_ust;
-
-/**
- * Number of swap operations that occurred after the swap deadline.  That
- * is if a swap happens more than swap_interval frames after the previous
- * swap, it has missed its deadline.  If swap_interval is 0, then the
- * swap deadline is 1 frame after the previous swap.
- */
-uint64_t swap_missed_count;
-
-/**
- * Amount of time used by the last swap that missed its deadline.  This
- * is calculated as (__glXGetUST() - swap_ust) / (swap_interval * 
- * time_for_single_vrefresh)).  If the actual value of swap_interval is
- * 0, then 1 is used instead.  If swap_missed_count is non-zero, this
- * should be greater-than 1.0.
- */
-float swap_missed_usage;
-};
-
-
 /**
  * Per-drawable private DRI driver information.
  */
-- 
1.7.7

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


[Mesa-dev] [PATCH 07/27] dri: Remove unsused driCreateNewScreen

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.c |   93 
 1 files changed, 0 insertions(+), 93 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 1118b19..46ef661 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -692,99 +692,6 @@ setupLoaderExtensions(__DRIscreen *psp,
 }
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c struct gl_config that the driver can support for windows or
- * pbuffers.
- *
- * For legacy DRI.
- * 
- * \param scrn  Index of the screen
- * \param ddx_version Version of the 2D DDX.  This may not be meaningful for
- *all drivers.
- * \param dri_version Version of the server-side DRI.
- * \param drm_version Version of the kernel DRM.
- * \param frame_buffer Data describing the location and layout of the
- * framebuffer.
- * \param pSAREA   Pointer to the SAREA.
- * \param fd   Device handle for the DRM.
- * \param extensions   ??
- * \param driver_modes  Returns modes suppoted by the driver
- * \param loaderPrivate  ??
- * 
- * \note There is no need to check the minimum API version in this
- * function.  Since the name of this function is versioned, it is
- * impossible for a loader that is too old to even load this driver.
- */
-static __DRIscreen *
-driCreateNewScreen(int scrn,
-  const __DRIversion *ddx_version,
-  const __DRIversion *dri_version,
-  const __DRIversion *drm_version,
-  const __DRIframebuffer *frame_buffer,
-  drmAddress pSAREA, int fd, 
-  const __DRIextension **extensions,
-  const __DRIconfig ***driver_modes,
-  void *loaderPrivate)
-{
-static const __DRIextension *emptyExtensionList[] = { NULL };
-__DRIscreen *psp;
-
-(void) loaderPrivate;
-
-if (driDriverAPI.InitScreen == NULL) {
-   __driUtilMessage(driver does not support DRI1);
-   return NULL;
-}
-
-psp = calloc(1, sizeof *psp);
-if (!psp)
-   return NULL;
-
-setupLoaderExtensions(psp, extensions);
-
-/*
-** NOT_DONE: This is used by the X server to detect when the client
-** has died while holding the drawable lock.  The client sets the
-** drawable lock to this value.
-*/
-psp-drawLockID = 1;
-
-psp-drm_version = *drm_version;
-psp-ddx_version = *ddx_version;
-psp-dri_version = *dri_version;
-
-psp-pSAREA = pSAREA;
-psp-lock = (drmLock *) psp-pSAREA-lock;
-
-psp-pFB = frame_buffer-base;
-psp-fbSize = frame_buffer-size;
-psp-fbStride = frame_buffer-stride;
-psp-fbWidth = frame_buffer-width;
-psp-fbHeight = frame_buffer-height;
-psp-devPrivSize = frame_buffer-dev_priv_size;
-psp-pDevPriv = frame_buffer-dev_priv;
-psp-fbBPP = psp-fbStride * 8 / frame_buffer-width;
-
-psp-extensions = emptyExtensionList;
-psp-fd = fd;
-psp-myNum = scrn;
-psp-dri2.enabled = GL_FALSE;
-
-psp-DriverAPI = driDriverAPI;
-psp-api_mask = (1  __DRI_API_OPENGL);
-
-*driver_modes = driDriverAPI.InitScreen(psp);
-if (*driver_modes == NULL) {
-   free(psp);
-   return NULL;
-}
-
-return psp;
-}
-
-/**
  * DRI2
  */
 static __DRIscreen *
-- 
1.7.7

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


[Mesa-dev] [PATCH 08/27] dri: Fold driCreateNewDrawable into dri2CreateNewDrawable

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.c |   81 +++-
 1 files changed, 28 insertions(+), 53 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 46ef661..15f600c 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -321,74 +321,49 @@ static void driSwapBuffers(__DRIdrawable *dPriv)
 free(rects);
 }
 
-/**
- * This is called via __DRIscreenRec's createNewDrawable pointer.
- */
 static __DRIdrawable *
-driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,
-drm_drawable_t hwDrawable, int renderType,
-const int *attrs, void *data)
+dri2CreateNewDrawable(__DRIscreen *screen,
+ const __DRIconfig *config,
+ void *loaderPrivate)
 {
-__DRIdrawable *pdp;
-
-/* Since pbuffers are not yet supported, no drawable attributes are
- * supported either.
- */
-(void) attrs;
-(void) renderType;
+__DRIdrawable *pdraw;
 
-pdp = malloc(sizeof *pdp);
-if (!pdp) {
+pdraw = malloc(sizeof *pdraw);
+if (!pdraw)
return NULL;
-}
 
-pdp-driContextPriv = NULL;
-pdp-loaderPrivate = data;
-pdp-hHWDrawable = hwDrawable;
-pdp-refcount = 1;
-pdp-pStamp = NULL;
-pdp-lastStamp = 0;
-pdp-index = 0;
-pdp-x = 0;
-pdp-y = 0;
-pdp-w = 0;
-pdp-h = 0;
-pdp-numClipRects = 0;
-pdp-numBackClipRects = 0;
-pdp-pClipRects = NULL;
-pdp-pBackClipRects = NULL;
-pdp-vblSeq = 0;
-pdp-vblFlags = 0;
+pdraw-driContextPriv = NULL;
+pdraw-loaderPrivate = loaderPrivate;
+pdraw-hHWDrawable = 0;
+pdraw-refcount = 1;
+pdraw-pStamp = NULL;
+pdraw-lastStamp = 0;
+pdraw-index = 0;
+pdraw-x = 0;
+pdraw-y = 0;
+pdraw-w = 0;
+pdraw-h = 0;
+pdraw-numClipRects = 0;
+pdraw-numBackClipRects = 0;
+pdraw-pClipRects = NULL;
+pdraw-pBackClipRects = NULL;
+pdraw-vblSeq = 0;
+pdraw-vblFlags = 0;
 
-pdp-driScreenPriv = psp;
+pdraw-driScreenPriv = screen;
 
-if (!(*psp-DriverAPI.CreateBuffer)(psp, pdp, config-modes, 0)) {
-   free(pdp);
+if (!(*screen-DriverAPI.CreateBuffer)(screen, pdraw, config-modes, 0)) {
+   free(pdraw);
return NULL;
 }
 
-pdp-msc_base = 0;
+pdraw-msc_base = 0;
 
 /* This special default value is replaced with the configured
  * default value when the drawable is first bound to a direct
  * rendering context. 
  */
-pdp-swap_interval = (unsigned)-1;
-
-return pdp;
-}
-
-
-static __DRIdrawable *
-dri2CreateNewDrawable(__DRIscreen *screen,
- const __DRIconfig *config,
- void *loaderPrivate)
-{
-__DRIdrawable *pdraw;
-
-pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, loaderPrivate);
-if (!pdraw)
-   return NULL;
+pdraw-swap_interval = (unsigned)-1;
 
 pdraw-pClipRects = pdraw-dri2.clipRect;
 pdraw-pBackClipRects = pdraw-dri2.clipRect;
-- 
1.7.7

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


[Mesa-dev] [PATCH 09/27] dri: Drop unused driCreateNewContext

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.c |   52 
 1 files changed, 0 insertions(+), 52 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 15f600c..348b06a 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -483,58 +483,6 @@ driDestroyContext(__DRIcontext *pcp)
 }
 }
 
-
-/**
- * Create the per-drawable private driver information.
- * 
- * \param render_type   Type of rendering target.  \c GLX_RGBA_TYPE is the only
- *  type likely to ever be supported for direct-rendering.
- *  However, \c GLX_RGBA_FLOAT_TYPE_ARB may eventually be
- *  supported by some drivers.
- * \param sharedContext with which to share textures, etc. or NULL
- *
- * \returns An opaque pointer to the per-context private information on
- *  success, or \c NULL on failure.
- * 
- * \internal
- * This function allocates and fills a __DRIcontextRec structure.  It
- * performs some device independent initialization and passes all the
- * relevent information to __DriverAPIRec::CreateContext to create the
- * context.
- *
- */
-static __DRIcontext *
-driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
-   int render_type, __DRIcontext *shared, 
-   drm_context_t hwContext, void *data)
-{
-__DRIcontext *pcp;
-void * const shareCtx = (shared != NULL) ? shared-driverPrivate : NULL;
-
-(void) render_type;
-
-pcp = malloc(sizeof *pcp);
-if (!pcp)
-   return NULL;
-
-pcp-driScreenPriv = psp;
-pcp-driDrawablePriv = NULL;
-pcp-loaderPrivate = data;
-
-pcp-dri2.draw_stamp = 0;
-pcp-dri2.read_stamp = 0;
-
-pcp-hHWContext = hwContext;
-
-if ( !(*psp-DriverAPI.CreateContext)(API_OPENGL,
- config-modes, pcp, shareCtx) ) {
-free(pcp);
-return NULL;
-}
-
-return pcp;
-}
-
 static unsigned int
 dri2GetAPIMask(__DRIscreen *screen)
 {
-- 
1.7.7

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


[Mesa-dev] [PATCH 10/27] dri: Remove unused driSwapBuffers

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.c |   65 +---
 1 files changed, 1 insertions(+), 64 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 348b06a..b3e6b12 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -258,69 +258,6 @@ __driUtilUpdateDrawableInfo(__DRIdrawable *pdp)
 DRM_SPINLOCK(psp-pSAREA-drawable_lock, psp-drawLockID);
 }
 
-/*@}*/
-
-/*/
-/** \name GLX callbacks  */
-/*/
-/*@{*/
-
-static void driReportDamage(__DRIdrawable *pdp,
-   struct drm_clip_rect *pClipRects, int numClipRects)
-{
-__DRIscreen *psp = pdp-driScreenPriv;
-
-/* Check that we actually have the new damage report method */
-if (psp-damage) {
-   /* Report the damage.  Currently, all our drivers draw
-* directly to the front buffer, so we report the damage there
-* rather than to the backing storein (if any).
-*/
-   (*psp-damage-reportDamage)(pdp,
-pdp-x, pdp-y,
-pClipRects, numClipRects,
-GL_TRUE, pdp-loaderPrivate);
-}
-}
-
-
-/**
- * Swap buffers.
- *
- * \param drawablePrivate opaque pointer to the per-drawable private info.
- * 
- * \internal
- * This function calls __DRIdrawable::swapBuffers.
- * 
- * Is called directly from glXSwapBuffers().
- */
-static void driSwapBuffers(__DRIdrawable *dPriv)
-{
-__DRIscreen *psp = dPriv-driScreenPriv;
-drm_clip_rect_t *rects;
-int i;
-
-psp-DriverAPI.SwapBuffers(dPriv);
-
-if (!dPriv-numClipRects)
-return;
-
-rects = malloc(sizeof(*rects) * dPriv-numClipRects);
-
-if (!rects)
-return;
-
-for (i = 0; i  dPriv-numClipRects; i++) {
-rects[i].x1 = dPriv-pClipRects[i].x1 - dPriv-x;
-rects[i].y1 = dPriv-pClipRects[i].y1 - dPriv-y;
-rects[i].x2 = dPriv-pClipRects[i].x2 - dPriv-x;
-rects[i].y2 = dPriv-pClipRects[i].y2 - dPriv-y;
-}
-
-driReportDamage(dPriv, rects, dPriv-numClipRects);
-free(rects);
-}
-
 static __DRIdrawable *
 dri2CreateNewDrawable(__DRIscreen *screen,
  const __DRIconfig *config,
@@ -682,7 +619,7 @@ const __DRIcoreExtension driCoreExtension = {
 driIndexConfigAttrib,
 NULL,
 driDestroyDrawable,
-driSwapBuffers,
+NULL,
 NULL,
 driCopyContext,
 driDestroyContext,
-- 
1.7.7

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


[Mesa-dev] [PATCH 11/27] dri: Drop __driUtilUpdateDrawableInfo and helper macros

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.c |   88 
 src/mesa/drivers/dri/common/dri_util.h |   57 
 2 files changed, 0 insertions(+), 145 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index b3e6b12..c7154df 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -166,98 +166,10 @@ static int driBindContext(__DRIcontext *pcp,
dri_get_drawable(prp);
 }
 
-/*
-** Now that we have a context associated with this drawable, we can
-** initialize the drawable information if has not been done before.
-*/
-
-if (!psp-dri2.enabled) {
-   if (pdp  !pdp-pStamp) {
-   DRM_SPINLOCK(psp-pSAREA-drawable_lock, psp-drawLockID);
-   __driUtilUpdateDrawableInfo(pdp);
-   DRM_SPINUNLOCK(psp-pSAREA-drawable_lock, psp-drawLockID);
-   }
-   if (prp  pdp != prp  !prp-pStamp) {
-   DRM_SPINLOCK(psp-pSAREA-drawable_lock, psp-drawLockID);
-   __driUtilUpdateDrawableInfo(prp);
-   DRM_SPINUNLOCK(psp-pSAREA-drawable_lock, psp-drawLockID);
-}
-}
-
 /* Call device-specific MakeCurrent */
 return (*psp-DriverAPI.MakeCurrent)(pcp, pdp, prp);
 }
 
-/*@}*/
-
-
-/*/
-/** \name Drawable handling functions*/
-/*/
-/*@{*/
-
-/**
- * Update private drawable information.
- *
- * \param pdp pointer to the private drawable information to update.
- * 
- * This function basically updates the __DRIdrawable struct's
- * cliprect information by calling \c __DRIinterfaceMethods::getDrawableInfo.
- * This is usually called by the DRI_VALIDATE_DRAWABLE_INFO macro which
- * compares the __DRIdrwablePrivate pStamp and lastStamp values.  If
- * the values are different that means we have to update the clipping
- * info.
- */
-void
-__driUtilUpdateDrawableInfo(__DRIdrawable *pdp)
-{
-__DRIscreen *psp = pdp-driScreenPriv;
-__DRIcontext *pcp = pdp-driContextPriv;
-
-if (!pcp 
-   || ((pdp != pcp-driDrawablePriv)  (pdp != pcp-driReadablePriv))) {
-   /* ERROR!!! 
-* ...but we must ignore it. There can be many contexts bound to a
-* drawable.
-*/
-}
-
-if (pdp-pClipRects) {
-   free(pdp-pClipRects); 
-   pdp-pClipRects = NULL;
-}
-
-if (pdp-pBackClipRects) {
-   free(pdp-pBackClipRects); 
-   pdp-pBackClipRects = NULL;
-}
-
-DRM_SPINUNLOCK(psp-pSAREA-drawable_lock, psp-drawLockID);
-
-if (! (*psp-getDrawableInfo-getDrawableInfo)(pdp,
- pdp-index, pdp-lastStamp,
- pdp-x, pdp-y, pdp-w, pdp-h,
- pdp-numClipRects, pdp-pClipRects,
- pdp-backX,
- pdp-backY,
- pdp-numBackClipRects,
- pdp-pBackClipRects,
- pdp-loaderPrivate)) {
-   /* Error -- eg the window may have been destroyed.  Keep going
-* with no cliprects.
-*/
-pdp-pStamp = pdp-lastStamp; /* prevent endless loop */
-   pdp-numClipRects = 0;
-   pdp-pClipRects = NULL;
-   pdp-numBackClipRects = 0;
-   pdp-pBackClipRects = NULL;
-}
-else
-   pdp-pStamp = (psp-pSAREA-drawableTable[pdp-index].stamp);
-
-DRM_SPINLOCK(psp-pSAREA-drawable_lock, psp-drawLockID);
-}
-
 static __DRIdrawable *
 dri2CreateNewDrawable(__DRIscreen *screen,
  const __DRIconfig *config,
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index 1ace19e..c9a3980 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -66,60 +66,6 @@ extern const __DRIdri2Extension driDRI2Extension;
 extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
 
 /**
- * Used by DRI_VALIDATE_DRAWABLE_INFO
- */
-#define DRI_VALIDATE_DRAWABLE_INFO_ONCE(pDrawPriv)  \
-do {\
-   if (*(pDrawPriv-pStamp) != pDrawPriv-lastStamp) { \
-   __driUtilUpdateDrawableInfo(pDrawPriv); \
-   }   \
-} while (0)
-
-
-/**
- * Utility macro to validate the drawable information.
- *
- * See __DRIdrawable::pStamp and __DRIdrawable::lastStamp.
- */
-#define DRI_VALIDATE_DRAWABLE_INFO(psp, pdp)\
-do {\
-while (*(pdp-pStamp) != pdp-lastStamp) {  \
-register unsigned int hwContext = psp-pSAREA-lock.lock   \
-~(DRM_LOCK_HELD | DRM_LOCK_CONT);  \
-   DRM_UNLOCK(psp-fd, psp-pSAREA-lock, hwContext);   

[Mesa-dev] [PATCH 12/27] dri: Remove unused driIntersectArea

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.c |   13 -
 src/mesa/drivers/dri/common/dri_util.h |3 ---
 2 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index c7154df..5d5f99d 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -50,19 +50,6 @@ typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) 
(__DRIdrawable *drawable, int32_t
 static void dri_get_drawable(__DRIdrawable *pdp);
 static void dri_put_drawable(__DRIdrawable *pdp);
 
-GLint
-driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 )
-{
-   if (rect2.x1  rect1.x1) rect1.x1 = rect2.x1;
-   if (rect2.x2  rect1.x2) rect1.x2 = rect2.x2;
-   if (rect2.y1  rect1.y1) rect1.y1 = rect2.y1;
-   if (rect2.y2  rect1.y2) rect1.y2 = rect2.y2;
-
-   if (rect1.x1  rect1.x2 || rect1.y1  rect1.y2) return 0;
-
-   return (rect1.x2 - rect1.x1) * (rect1.y2 - rect1.y1);
-}
-
 /*/
 /** \name Context (un)binding functions  */
 /*/
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index c9a3980..316afa6 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -452,9 +452,6 @@ extern float
 driCalculateSwapUsage( __DRIdrawable *dPriv,
   int64_t last_swap_ust, int64_t current_ust );
 
-extern GLint
-driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 );
-
 extern void
 dri2InvalidateDrawable(__DRIdrawable *drawable);
 
-- 
1.7.7

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


[Mesa-dev] [PATCH 13/27] dri: Drop unused driCalculateSwapUsage

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.c |   63 
 src/mesa/drivers/dri/common/dri_util.h |4 --
 2 files changed, 0 insertions(+), 67 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 5d5f99d..945c85c 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -545,69 +545,6 @@ const __DRI2configQueryExtension dri2ConfigQueryExtension 
= {
dri2ConfigQueryf,
 };
 
-/**
- * Calculate amount of swap interval used between GLX buffer swaps.
- * 
- * The usage value, on the range [0,max], is the fraction of total swap
- * interval time used between GLX buffer swaps is calculated.
- *
- *\f$p = t_d / (i * t_r)\f$
- * 
- * Where \f$t_d\f$ is the time since the last GLX buffer swap, \f$i\f$ is the
- * swap interval (as set by \c glXSwapIntervalSGI), and \f$t_r\f$ time
- * required for a single vertical refresh period (as returned by \c
- * glXGetMscRateOML).
- * 
- * See the documentation for the GLX_MESA_swap_frame_usage extension for more
- * details.
- *
- * \param   dPriv  Pointer to the private drawable structure.
- * \return  If less than a single swap interval time period was required
- *  between GLX buffer swaps, a number greater than 0 and less than
- *  1.0 is returned.  If exactly one swap interval time period is
- *  required, 1.0 is returned, and if more than one is required then
- *  a number greater than 1.0 will be returned.
- *
- * \sa glXSwapIntervalSGI glXGetMscRateOML
- * 
- * \todo Instead of caching the \c glXGetMscRateOML function pointer, would it
- *   be possible to cache the sync rate?
- */
-float
-driCalculateSwapUsage( __DRIdrawable *dPriv, int64_t last_swap_ust,
-  int64_t current_ust )
-{
-   int32_t   n;
-   int32_t   d;
-   int   interval;
-   float usage = 1.0;
-   __DRIscreen *psp = dPriv-driScreenPriv;
-
-   if ( (*psp-systemTime-getMSCRate)(dPriv, n, d, dPriv-loaderPrivate) ) {
-  interval = (dPriv-swap_interval != 0) ? dPriv-swap_interval : 1;
-
-
-  /* We want to calculate
-   * (current_UST - last_swap_UST) / (interval * us_per_refresh).  We get
-   * current_UST by calling __glXGetUST.  last_swap_UST is stored in
-   * dPriv-swap_ust.  interval has already been calculated.
-   *
-   * The only tricky part is us_per_refresh.  us_per_refresh is
-   * 100 / MSC_rate.  We know the MSC_rate is n / d.  We can flip it
-   * around and say us_per_refresh = 100 * d / n.  Since this goes in
-   * the denominator of the final calculation, we calculate
-   * (interval * 100 * d) and move n into the numerator.
-   */
-
-  usage = (current_ust - last_swap_ust);
-  usage *= n;
-  usage /= (interval * d);
-  usage /= 100.0;
-   }
-   
-   return usage;
-}
-
 void
 dri2InvalidateDrawable(__DRIdrawable *drawable)
 {
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index 316afa6..817d77d 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -448,10 +448,6 @@ struct __DRIscreenRec {
void *loaderPrivate;
 };
 
-extern float
-driCalculateSwapUsage( __DRIdrawable *dPriv,
-  int64_t last_swap_ust, int64_t current_ust );
-
 extern void
 dri2InvalidateDrawable(__DRIdrawable *drawable);
 
-- 
1.7.7

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


[Mesa-dev] [PATCH 14/27] dri: Remove cliprect information from __DRIdrawable

2011-10-28 Thread Kristian Høgsberg
---
 src/gallium/state_trackers/dri/drm/dri2.c  |   19 +
 src/mesa/drivers/dri/common/dri_util.c |   17 
 src/mesa/drivers/dri/common/dri_util.h |   28 +---
 src/mesa/drivers/dri/common/spantmp_common.h   |   11 +++-
 src/mesa/drivers/dri/intel/intel_context.c |   15 --
 src/mesa/drivers/dri/r200/r200_state.c |   12 
 src/mesa/drivers/dri/r200/r200_swtcl.c |3 +-
 .../drivers/dri/radeon/radeon_common_context.c |   15 --
 src/mesa/drivers/dri/radeon/radeon_state.c |   12 
 9 files changed, 19 insertions(+), 113 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 64c4cde..710a61a 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -158,25 +158,8 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
 num_buffers, dri_drawable-loaderPrivate);
}
 
-   if (buffers) {
-  /* set one cliprect to cover the whole dri_drawable */
-  dri_drawable-x = 0;
-  dri_drawable-y = 0;
-  dri_drawable-backX = 0;
-  dri_drawable-backY = 0;
-  dri_drawable-numClipRects = 1;
-  dri_drawable-pClipRects[0].x1 = 0;
-  dri_drawable-pClipRects[0].y1 = 0;
-  dri_drawable-pClipRects[0].x2 = dri_drawable-w;
-  dri_drawable-pClipRects[0].y2 = dri_drawable-h;
-  dri_drawable-numBackClipRects = 1;
-  dri_drawable-pBackClipRects[0].x1 = 0;
-  dri_drawable-pBackClipRects[0].y1 = 0;
-  dri_drawable-pBackClipRects[0].x2 = dri_drawable-w;
-  dri_drawable-pBackClipRects[0].y2 = dri_drawable-h;
-
+   if (buffers)
   *count = num_buffers;
-   }
 
return buffers;
 }
diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 945c85c..6d78f82 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -175,14 +175,8 @@ dri2CreateNewDrawable(__DRIscreen *screen,
 pdraw-pStamp = NULL;
 pdraw-lastStamp = 0;
 pdraw-index = 0;
-pdraw-x = 0;
-pdraw-y = 0;
 pdraw-w = 0;
 pdraw-h = 0;
-pdraw-numClipRects = 0;
-pdraw-numBackClipRects = 0;
-pdraw-pClipRects = NULL;
-pdraw-pBackClipRects = NULL;
 pdraw-vblSeq = 0;
 pdraw-vblFlags = 0;
 
@@ -201,9 +195,6 @@ dri2CreateNewDrawable(__DRIscreen *screen,
  */
 pdraw-swap_interval = (unsigned)-1;
 
-pdraw-pClipRects = pdraw-dri2.clipRect;
-pdraw-pBackClipRects = pdraw-dri2.clipRect;
-
 pdraw-pStamp = pdraw-dri2.stamp;
 *pdraw-pStamp = pdraw-lastStamp + 1;
 
@@ -277,14 +268,6 @@ static void dri_put_drawable(__DRIdrawable *pdp)
 
psp = pdp-driScreenPriv;
 (*psp-DriverAPI.DestroyBuffer)(pdp);
-   if (pdp-pClipRects  pdp-pClipRects != pdp-dri2.clipRect) {
-   free(pdp-pClipRects);
-   pdp-pClipRects = NULL;
-   }
-   if (pdp-pBackClipRects  pdp-pClipRects != pdp-dri2.clipRect) {
-   free(pdp-pBackClipRects);
-   pdp-pBackClipRects = NULL;
-   }
free(pdp);
 }
 }
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index 817d77d..e4dc623 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -218,32 +218,7 @@ struct __DRIdrawableRec {
  */
 unsigned int lastStamp;
 
-/**
- * \name Drawable 
- *
- * Drawable information used in software fallbacks.
- */
-/*@{*/
-int x;
-int y;
-int w;
-int h;
-int numClipRects;
-drm_clip_rect_t *pClipRects;
-/*@}*/
-
-/**
- * \name Back and depthbuffer
- *
- * Information about the back and depthbuffer where different from above.
- */
-/*@{*/
-int backX;
-int backY;
-int backClipRectType;
-int numBackClipRects;
-drm_clip_rect_t *pBackClipRects;
-/*@}*/
+int w, h;
 
 /**
  * \name Vertical blank tracking information
@@ -289,7 +264,6 @@ struct __DRIdrawableRec {
 
 struct {
unsigned int stamp;
-   drm_clip_rect_t clipRect;
 } dri2;
 };
 
diff --git a/src/mesa/drivers/dri/common/spantmp_common.h 
b/src/mesa/drivers/dri/common/spantmp_common.h
index a4509a5..8916e7b 100644
--- a/src/mesa/drivers/dri/common/spantmp_common.h
+++ b/src/mesa/drivers/dri/common/spantmp_common.h
@@ -49,17 +49,14 @@
 #ifndef HW_CLIPLOOP
 #define HW_CLIPLOOP()  \
do {
\
-  int _nc = dPriv-numClipRects;   \
-  while ( _nc-- ) {
\
-int minx = dPriv-pClipRects[_nc].x1 - dPriv-x;   \
-int miny = dPriv-pClipRects[_nc].y1 - dPriv-y;   \
-int maxx = 

[Mesa-dev] [PATCH 15/27] dri: Remove remaining DRI1 vblank code

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/Makefile.sources   |1 -
 src/mesa/drivers/dri/common/vblank.c   |  434 
 src/mesa/drivers/dri/common/vblank.h   |   71 
 src/mesa/drivers/dri/r200/r200_ioctl.c |2 -
 src/mesa/drivers/dri/radeon/radeon_common.c|2 -
 .../drivers/dri/radeon/radeon_common_context.c |   10 -
 src/mesa/drivers/dri/radeon/radeon_ioctl.c |2 -
 src/mesa/drivers/dri/radeon/radeon_screen.c|1 -
 8 files changed, 0 insertions(+), 523 deletions(-)
 delete mode 100644 src/mesa/drivers/dri/common/vblank.c
 delete mode 100644 src/mesa/drivers/dri/common/vblank.h

diff --git a/src/mesa/drivers/dri/common/Makefile.sources 
b/src/mesa/drivers/dri/common/Makefile.sources
index 3432dda..f21bf86 100644
--- a/src/mesa/drivers/dri/common/Makefile.sources
+++ b/src/mesa/drivers/dri/common/Makefile.sources
@@ -1,6 +1,5 @@
 mesa_dri_common_gallium_SOURCES := \
utils.c \
-   vblank.c \
dri_util.c \
xmlconfig.c
 
diff --git a/src/mesa/drivers/dri/common/vblank.c 
b/src/mesa/drivers/dri/common/vblank.c
deleted file mode 100644
index cb98dd0..000
--- a/src/mesa/drivers/dri/common/vblank.c
+++ /dev/null
@@ -1,434 +0,0 @@
-/* -*- mode: c; c-basic-offset: 3 -*- */
-/*
- * (c) Copyright IBM Corporation 2002
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the Software),
- * to deal in the Software without restriction, including without limitation
- * 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
- * VA LINUX SYSTEM, IBM 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.
- *
- * Authors:
- *Ian Romanick i...@us.ibm.com
- */
-
-#include main/glheader.h
-#include xf86drm.h
-#include main/mtypes.h
-#include main/macros.h
-#include main/dd.h
-#include vblank.h
-#include xmlpool.h
-
-static unsigned int msc_to_vblank(__DRIdrawable * dPriv, int64_t msc)
-{
-   return (unsigned int)(msc - dPriv-msc_base + dPriv-vblank_base);
-}
-
-static int64_t vblank_to_msc(__DRIdrawable * dPriv, unsigned int vblank)
-{
-   return (int64_t)(vblank - dPriv-vblank_base + dPriv-msc_base);
-}
-
-
-//
-/**
- * Get the current MSC refresh counter.
- *
- * Stores the 64-bit count of vertical refreshes since some (arbitrary)
- * point in time in \c count.  Unless the value wraps around, which it
- * may, it will never decrease for a given drawable.
- *
- * \warning This function is called from \c glXGetVideoSyncSGI, which expects
- * a \c count of type \c unsigned (32-bit), and \c glXGetSyncValuesOML, which 
- * expects a \c count of type \c int64_t (signed 64-bit).  The kernel ioctl 
- * currently always returns a \c sequence of type \c unsigned.
- *
- * \param priv   Pointer to the DRI screen private struct.
- * \param dPriv  Pointer to the DRI drawable private struct
- * \param count  Storage to hold MSC counter.
- * \return   Zero is returned on success.  A negative errno value
- *   is returned on failure.
- */
-int driDrawableGetMSC32( __DRIscreen * priv,
-__DRIdrawable * dPriv,
-int64_t * count)
-{
-   drmVBlank vbl;
-   int ret;
-
-   /* Don't wait for anything.  Just get the current refresh count. */
-
-   vbl.request.type = DRM_VBLANK_RELATIVE;
-   vbl.request.sequence = 0;
-   if ( dPriv  dPriv-vblFlags  VBLANK_FLAG_SECONDARY )
-  vbl.request.type |= DRM_VBLANK_SECONDARY;
-
-   ret = drmWaitVBlank( priv-fd, vbl );
-
-   if (dPriv) {
-  *count = vblank_to_msc(dPriv, vbl.reply.sequence);
-   } else {
-  /* Old driver (no knowledge of drawable MSC callback) */
-  *count = vbl.reply.sequence;
-   }
-
-   return ret;
-}
-
-//
-/**
- * Wait for a specified refresh count.  This implements most of the
- * functionality of \c glXWaitForMscOML from the GLX_OML_sync_control spec.
- * Waits for the \c target_msc refresh.  If that has already passed, it
- * waits until \f$(MSC \bmod divisor)\f$ is equal 

[Mesa-dev] [PATCH 16/27] dri: Remove DRI1 fields from DRI structs

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.c |   29 +-
 src/mesa/drivers/dri/common/dri_util.h |  105 
 .../drivers/dri/radeon/radeon_common_context.c |6 -
 3 files changed, 2 insertions(+), 138 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 6d78f82..e42bc84 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -170,16 +170,11 @@ dri2CreateNewDrawable(__DRIscreen *screen,
 
 pdraw-driContextPriv = NULL;
 pdraw-loaderPrivate = loaderPrivate;
-pdraw-hHWDrawable = 0;
 pdraw-refcount = 1;
 pdraw-pStamp = NULL;
 pdraw-lastStamp = 0;
-pdraw-index = 0;
 pdraw-w = 0;
 pdraw-h = 0;
-pdraw-vblSeq = 0;
-pdraw-vblFlags = 0;
-
 pdraw-driScreenPriv = screen;
 
 if (!(*screen-DriverAPI.CreateBuffer)(screen, pdraw, config-modes, 0)) {
@@ -187,14 +182,6 @@ dri2CreateNewDrawable(__DRIscreen *screen,
return NULL;
 }
 
-pdraw-msc_base = 0;
-
-/* This special default value is replaced with the configured
- * default value when the drawable is first bound to a direct
- * rendering context. 
- */
-pdraw-swap_interval = (unsigned)-1;
-
 pdraw-pStamp = pdraw-dri2.stamp;
 *pdraw-pStamp = pdraw-lastStamp + 1;
 
@@ -398,14 +385,8 @@ static void driDestroyScreen(__DRIscreen *psp)
if (psp-DriverAPI.DestroyScreen)
(*psp-DriverAPI.DestroyScreen)(psp);
 
-   if (!psp-dri2.enabled) {
-  (void)drmUnmap((drmAddress)psp-pSAREA, SAREA_MAX);
-  (void)drmUnmap((drmAddress)psp-pFB, psp-fbSize);
-  (void)drmCloseOnce(psp-fd);
-   } else {
-  driDestroyOptionCache(psp-optionCache);
-  driDestroyOptionInfo(psp-optionInfo);
-   }
+   driDestroyOptionCache(psp-optionCache);
+   driDestroyOptionInfo(psp-optionInfo);
 
free(psp);
 }
@@ -418,12 +399,6 @@ setupLoaderExtensions(__DRIscreen *psp,
 int i;
 
 for (i = 0; extensions[i]; i++) {
-   if (strcmp(extensions[i]-name, __DRI_GET_DRAWABLE_INFO) == 0)
-   psp-getDrawableInfo = (__DRIgetDrawableInfoExtension *) 
extensions[i];
-   if (strcmp(extensions[i]-name, __DRI_DAMAGE) == 0)
-   psp-damage = (__DRIdamageExtension *) extensions[i];
-   if (strcmp(extensions[i]-name, __DRI_SYSTEM_TIME) == 0)
-   psp-systemTime = (__DRIsystemTimeExtension *) extensions[i];
if (strcmp(extensions[i]-name, __DRI_DRI2_LOADER) == 0)
psp-dri2.loader = (__DRIdri2LoaderExtension *) extensions[i];
if (strcmp(extensions[i]-name, __DRI_IMAGE_LOOKUP) == 0)
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index e4dc623..e016a23 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -171,11 +171,6 @@ extern const struct __DriverAPIRec driDriverAPI;
  */
 struct __DRIdrawableRec {
 /**
- * Kernel drawable handle
- */
-drm_drawable_t hHWDrawable;
-
-/**
  * Driver's private drawable information.  
  *
  * This structure is opaque.
@@ -199,11 +194,6 @@ struct __DRIdrawableRec {
 int refcount;
 
 /**
- * Index of this drawable information in the SAREA.
- */
-unsigned int index;
-
-/**
  * Pointer to the drawable has changed ID stamp in the SAREA (or
  * to dri2.stamp if DRI2 is being used).
  */
@@ -221,32 +211,6 @@ struct __DRIdrawableRec {
 int w, h;
 
 /**
- * \name Vertical blank tracking information
- * Used for waiting on vertical blank events.
- */
-/*@{*/
-unsigned int vblSeq;
-unsigned int vblFlags;
-/*@}*/
-
-/**
- * \name Monotonic MSC tracking
- *
- * Low level driver is responsible for updating msc_base and
- * vblSeq values so that higher level code can calculate
- * a new msc value or msc target for a WaitMSC call.  The new value
- * will be:
- *   msc = msc_base + get_vblank_count() - vblank_base;
- *
- * And for waiting on a value, core code will use:
- *   actual_target = target_msc - msc_base + vblank_base;
- */
-/*@{*/
-int64_t vblank_base;
-int64_t msc_base;
-/*@}*/
-
-/**
  * Pointer to context to which this drawable is currently bound.
  */
 __DRIcontext *driContextPriv;
@@ -256,12 +220,6 @@ struct __DRIdrawableRec {
  */
 __DRIscreen *driScreenPriv;
 
-/**
- * Controls swap interval as used by GLX_SGI_swap_control and
- * GLX_MESA_swap_control.
- */
-unsigned int swap_interval;
-
 struct {
unsigned int stamp;
 } dri2;
@@ -272,11 +230,6 @@ struct __DRIdrawableRec {
  */
 struct __DRIcontextRec {
 /**
- * Kernel context handle used to access the device lock.
- */
-drm_context_t hHWContext;
-
-/**
  * Device driver's private context data.  This structure is 

[Mesa-dev] [PATCH 17/27] dri: Remove dri2.enabled flag

2011-10-28 Thread Kristian Høgsberg
DRI2 is always enabled now.
---
 src/mesa/drivers/dri/common/dri_util.c |1 -
 src/mesa/drivers/dri/common/dri_util.h |1 -
 src/mesa/drivers/dri/radeon/radeon_common.c|3 -
 .../drivers/dri/radeon/radeon_common_context.c |   80 ++-
 src/mesa/drivers/dri/radeon/radeon_dma.c   |4 +-
 src/mesa/drivers/dri/radeon/radeon_screen.c|2 -
 6 files changed, 10 insertions(+), 81 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index e42bc84..aa095d8 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -440,7 +440,6 @@ dri2CreateNewScreen(int scrn, int fd,
 psp-extensions = emptyExtensionList;
 psp-fd = fd;
 psp-myNum = scrn;
-psp-dri2.enabled = GL_TRUE;
 
 psp-DriverAPI = driDriverAPI;
 psp-api_mask = (1  __DRI_API_OPENGL);
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index e016a23..ac0cef0 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -305,7 +305,6 @@ struct __DRIscreenRec {
 struct {
/* Flag to indicate that this is a DRI2 screen.  Many of the above
 * fields will not be valid or initializaed in that case. */
-   int enabled;
__DRIdri2LoaderExtension *loader;
__DRIimageLookupExtension *image;
__DRIuseInvalidateExtension *useInvalidate;
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c 
b/src/mesa/drivers/dri/radeon/radeon_common.c
index a628486..f7a704d 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -467,9 +467,6 @@ void radeon_viewport(struct gl_context *ctx, GLint x, GLint 
y, GLsizei width, GL
void (*old_viewport)(struct gl_context *ctx, GLint x, GLint y,
 GLsizei w, GLsizei h);
 
-   if (!driContext-driScreenPriv-dri2.enabled)
-   return;
-
if (ctx-DrawBuffer-Name == 0) {
if (radeon-is_front_buffer_rendering) {
ctx-Driver.Flush(ctx);
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c 
b/src/mesa/drivers/dri/radeon/radeon_common_context.c
index d88f8a7..5c2623b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c
@@ -159,8 +159,7 @@ static const GLubyte *radeonGetString(struct gl_context * 
ctx, GLenum name)
?  : NO-);
}
 
-   if (radeon-radeonScreen-driScreen-dri2.enabled)
-   strcat(buffer,  DRI2);
+   strcat(buffer,  DRI2);
 
return (GLubyte *) buffer;
}
@@ -364,63 +363,6 @@ GLboolean radeonUnbindContext(__DRIcontext * 
driContextPriv)
 }
 
 
-static void
-radeon_make_renderbuffer_current(radeonContextPtr radeon,
-   struct gl_framebuffer *draw)
-{
-   /* if radeon-fake */
-   struct radeon_renderbuffer *rb;
-
-   if ((rb = (void *)draw-Attachment[BUFFER_FRONT_LEFT].Renderbuffer)) {
-   if (!rb-bo) {
-   rb-bo = radeon_bo_open(radeon-radeonScreen-bom,
-   
radeon-radeonScreen-frontOffset,
-   0,
-   0,
-   RADEON_GEM_DOMAIN_VRAM,
-   0);
-   }
-   rb-cpp = radeon-radeonScreen-cpp;
-   rb-pitch = radeon-radeonScreen-frontPitch * rb-cpp;
-   }
-   if ((rb = (void *)draw-Attachment[BUFFER_BACK_LEFT].Renderbuffer)) {
-   if (!rb-bo) {
-   rb-bo = radeon_bo_open(radeon-radeonScreen-bom,
-   
radeon-radeonScreen-backOffset,
-   0,
-   0,
-   RADEON_GEM_DOMAIN_VRAM,
-   0);
-   }
-   rb-cpp = radeon-radeonScreen-cpp;
-   rb-pitch = radeon-radeonScreen-backPitch * rb-cpp;
-   }
-   if ((rb = (void *)draw-Attachment[BUFFER_DEPTH].Renderbuffer)) {
-   if (!rb-bo) {
-   rb-bo = radeon_bo_open(radeon-radeonScreen-bom,
-   
radeon-radeonScreen-depthOffset,
-   0,
-   0,
-   RADEON_GEM_DOMAIN_VRAM,
-   0);
-   }
-   rb-cpp = radeon-radeonScreen-cpp;
-   rb-pitch = 

[Mesa-dev] [PATCH 18/27] dri: Remove unused fields from __DriverAPIRec

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.h |   34 
 1 files changed, 0 insertions(+), 34 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index ac0cef0..ab11d45 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -76,8 +76,6 @@ extern const __DRI2configQueryExtension 
dri2ConfigQueryExtension;
  * this structure.
  */
 struct __DriverAPIRec {
-const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
-
 /**
  * Screen destruction callback
  */
@@ -110,11 +108,6 @@ struct __DriverAPIRec {
 void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
 
 /**
- * Buffer swapping callback 
- */
-void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
-
-/**
  * Context activation callback
  */
 GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
@@ -125,33 +118,6 @@ struct __DriverAPIRec {
  * Context unbinding callback
  */
 GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
-  
-/**
- * These are required if GLX_OML_sync_control is supported.
- */
-/*@{*/
-int (*WaitForMSC)( __DRIdrawable *priv, int64_t target_msc, 
-  int64_t divisor, int64_t remainder,
-  int64_t * msc );
-int (*WaitForSBC)( __DRIdrawable *priv, int64_t target_sbc,
-  int64_t * msc, int64_t * sbc );
-
-int64_t (*SwapBuffersMSC)( __DRIdrawable *priv, int64_t target_msc,
-  int64_t divisor, int64_t remainder );
-/*@}*/
-void (*CopySubBuffer)(__DRIdrawable *driDrawPriv,
- int x, int y, int w, int h);
-
-/**
- * New version of GetMSC so we can pass drawable data to the low
- * level DRM driver (e.g. pipe info).  Required if
- * GLX_SGI_video_sync or GLX_OML_sync_control is supported.
- */
-int (*GetDrawableMSC) ( __DRIscreen * priv,
-   __DRIdrawable *drawablePrivate,
-   int64_t *count);
-
-
 
 /* DRI2 Entry point */
 const __DRIconfig **(*InitScreen2) (__DRIscreen * priv);
-- 
1.7.7

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


[Mesa-dev] [PATCH 19/27] dri: Remove unnecessary timestamp pointer indirection

2011-10-28 Thread Kristian Høgsberg
---
 .../state_trackers/dri/common/dri_drawable.c   |6 +++---
 src/gallium/state_trackers/dri/drm/dri2.c  |2 +-
 src/gallium/state_trackers/dri/sw/dri_drawable.c   |6 +++---
 src/mesa/drivers/dri/common/dri_util.c |4 +---
 src/mesa/drivers/dri/common/dri_util.h |   11 ---
 src/mesa/drivers/dri/nouveau/nouveau_context.c |8 
 6 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c 
b/src/gallium/state_trackers/dri/common/dri_drawable.c
index 340404e..7bfce1b 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
@@ -62,9 +62,9 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface 
*stfbi,
new_mask = (statt_mask  ~drawable-texture_mask);
 
/*
-* dPriv-pStamp is the server stamp.  It should be accessed with a lock, at
-* least for DRI1.  dPriv-lastStamp is the client stamp.  It has the value
-* of the server stamp when last checked.
+* dPriv-dri2.stamp is the server stamp.  dPriv-lastStamp is the
+* client stamp.  It has the value of the server stamp when last
+* checked.
 */
new_stamp = (drawable-texture_stamp != drawable-dPriv-lastStamp);
 
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 710a61a..6113f43 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -65,7 +65,7 @@ dri2_invalidate_drawable(__DRIdrawable *dPriv)
struct dri_drawable *drawable = dri_drawable(dPriv);
 
dri2InvalidateDrawable(dPriv);
-   drawable-dPriv-lastStamp = *drawable-dPriv-pStamp;
+   drawable-dPriv-lastStamp = drawable-dPriv-dri2.stamp;
 
p_atomic_inc(drawable-base.stamp);
 }
diff --git a/src/gallium/state_trackers/dri/sw/dri_drawable.c 
b/src/gallium/state_trackers/dri/sw/dri_drawable.c
index 05c64b6..c53706e 100644
--- a/src/gallium/state_trackers/dri/sw/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/sw/dri_drawable.c
@@ -61,9 +61,9 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface 
*stfbi,
new_mask = (statt_mask  ~drawable-texture_mask);
 
/*
-* dPriv-pStamp is the server stamp.  It should be accessed with a lock, at
-* least for DRI1.  dPriv-lastStamp is the client stamp.  It has the value
-* of the server stamp when last checked.
+* dPriv-dri2.stamp is the server stamp.  dPriv-lastStamp is the
+* client stamp.  It has the value of the server stamp when last
+* checked.
 */
new_stamp = (drawable-texture_stamp != drawable-dPriv-lastStamp);
 
diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index aa095d8..9deb997 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -171,7 +171,6 @@ dri2CreateNewDrawable(__DRIscreen *screen,
 pdraw-driContextPriv = NULL;
 pdraw-loaderPrivate = loaderPrivate;
 pdraw-refcount = 1;
-pdraw-pStamp = NULL;
 pdraw-lastStamp = 0;
 pdraw-w = 0;
 pdraw-h = 0;
@@ -182,8 +181,7 @@ dri2CreateNewDrawable(__DRIscreen *screen,
return NULL;
 }
 
-pdraw-pStamp = pdraw-dri2.stamp;
-*pdraw-pStamp = pdraw-lastStamp + 1;
+pdraw-dri2.stamp = pdraw-lastStamp + 1;
 
 return pdraw;
 }
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index ab11d45..38394a7 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -160,15 +160,9 @@ struct __DRIdrawableRec {
 int refcount;
 
 /**
- * Pointer to the drawable has changed ID stamp in the SAREA (or
- * to dri2.stamp if DRI2 is being used).
- */
-unsigned int *pStamp;
-
-/**
  * Last value of the stamp.
  *
- * If this differs from the value stored at __DRIdrawable::pStamp,
+ * If this differs from the value stored at __DRIdrawable::dri2.stamp,
  * then the drawable information has been modified by the X server, and the
  * drawable information (below) should be retrieved from the X server.
  */
@@ -186,6 +180,9 @@ struct __DRIdrawableRec {
  */
 __DRIscreen *driScreenPriv;
 
+/**
+ * Drawable timestamp.  Increased when the loader calls invalidate.
+ */
 struct {
unsigned int stamp;
 } dri2;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c 
b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index 65cbc41..2b9507c 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -177,9 +177,9 @@ nouveau_update_renderbuffers(__DRIcontext *dri_ctx, 
__DRIdrawable *draw)
__DRIbuffer *buffers = NULL;
int i = 0, count, ret;
 
-   if (draw-lastStamp == *draw-pStamp)
+   if (draw-lastStamp == draw-dri2.stamp)
return;
-   draw-lastStamp = 

[Mesa-dev] [PATCH 20/27] dri: Remove unnecessary #defines and #includes

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/dri_util.c |8 
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 9deb997..7ffa860 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -17,19 +17,11 @@
 
 #include assert.h
 #include stdarg.h
-#include unistd.h
-#include sys/mman.h
 #include stdio.h
 
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
 #include main/imports.h
-#define None 0
 
 #include dri_util.h
-#include drm_sarea.h
 #include utils.h
 #include xmlpool.h
 #include ../glsl/glsl_parser_extras.h
-- 
1.7.7

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


[Mesa-dev] [PATCH 21/27] dri: Stop using driUpdateFramebufferSize() wrapper function

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/intel/intel_context.c |3 +--
 .../drivers/dri/radeon/radeon_common_context.c |   10 ++
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_context.c 
b/src/mesa/drivers/dri/intel/intel_context.c
index 6190396..476f9dc 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -54,7 +54,6 @@
 #include intel_bufmgr.h
 #include intel_screen.h
 
-#include drirenderbuffer.h
 #include utils.h
 #include ../glsl/ralloc.h
 
@@ -377,7 +376,7 @@ intel_update_renderbuffers(__DRIcontext *context, 
__DRIdrawable *drawable)
if (attachments)
   free(attachments);
 
-   driUpdateFramebufferSize(intel-ctx, drawable);
+   intel-ctx.Driver.ResizeBuffers(intel-ctx, fb, drawable-w, drawable-h);
 }
 
 /**
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c 
b/src/mesa/drivers/dri/radeon/radeon_common_context.c
index 5c2623b..d421685 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c
@@ -35,7 +35,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
 #include radeon_common.h
 #include xmlpool.h   /* for symbolic values of enum-type options */
 #include utils.h
-#include drirenderbuffer.h
 #include drivers/common/meta.h
 #include main/context.h
 #include main/framebuffer.h
@@ -625,7 +624,8 @@ radeon_update_renderbuffers(__DRIcontext *context, 
__DRIdrawable *drawable,
}
}
 
-   driUpdateFramebufferSize(radeon-glCtx, drawable);
+   radeon-glCtx-Driver.ResizeBuffers(radeon-glCtx,
+   draw-base, drawable-w, 
drawable-h);
 }
 
 /* Force the context `c' to be the current context and associate with it
@@ -669,9 +669,11 @@ GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv,
 fprintf(stderr, %s ctx %p dfb %p rfb %p\n, __FUNCTION__, 
radeon-glCtx, drfb, readfb);
 
if(driDrawPriv)
-   driUpdateFramebufferSize(radeon-glCtx, driDrawPriv);
+  radeon-glCtx-Driver.ResizeBuffers(radeon-glCtx,
+  drfb, driDrawPriv-w, 
driDrawPriv-h);
if (driReadPriv != driDrawPriv)
-   driUpdateFramebufferSize(radeon-glCtx, driReadPriv);
+  radeon-glCtx-Driver.ResizeBuffers(radeon-glCtx,
+  readfb, driReadPriv-w, 
driReadPriv-h);
 
_mesa_make_current(radeon-glCtx, drfb, readfb);
if (driDrawPriv == NULL  driReadPriv == NULL)
-- 
1.7.7

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


[Mesa-dev] [PATCH 22/27] dri: Drop unused dri renderbuffer helper functions

2011-10-28 Thread Kristian Høgsberg
---
 src/gallium/state_trackers/dri/drm/Makefile   |3 +-
 src/gallium/targets/Makefile.dri  |3 +-
 src/mesa/drivers/dri/common/Makefile.sources  |1 -
 src/mesa/drivers/dri/common/drirenderbuffer.c |  200 -
 src/mesa/drivers/dri/common/drirenderbuffer.h |   71 -
 5 files changed, 2 insertions(+), 276 deletions(-)
 delete mode 100644 src/mesa/drivers/dri/common/drirenderbuffer.c
 delete mode 100644 src/mesa/drivers/dri/common/drirenderbuffer.h

diff --git a/src/gallium/state_trackers/dri/drm/Makefile 
b/src/gallium/state_trackers/dri/drm/Makefile
index 695dc0c..54f1db3 100644
--- a/src/gallium/state_trackers/dri/drm/Makefile
+++ b/src/gallium/state_trackers/dri/drm/Makefile
@@ -24,7 +24,6 @@ C_SOURCES = \
$(TOP)/src/mesa/drivers/dri/common/dri_util.c \
$(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \
$(TOP)/src/mesa/drivers/common/driverfuncs.c \
-   $(TOP)/src/mesa/drivers/dri/common/texmem.c \
-   $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c
+   $(TOP)/src/mesa/drivers/dri/common/texmem.c
 
 include ../../../Makefile.template
diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri
index a26b3ee..941122b 100644
--- a/src/gallium/targets/Makefile.dri
+++ b/src/gallium/targets/Makefile.dri
@@ -18,8 +18,7 @@ COMMON_GALLIUM_SOURCES = \
 
 COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \
 $(TOP)/src/mesa/drivers/common/driverfuncs.c \
-$(TOP)/src/mesa/drivers/dri/common/texmem.c \
-$(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c
+$(TOP)/src/mesa/drivers/dri/common/texmem.c
 
 COMMON_BM_SOURCES = \
$(TOP)/src/mesa/drivers/dri/common/dri_bufmgr.c \
diff --git a/src/mesa/drivers/dri/common/Makefile.sources 
b/src/mesa/drivers/dri/common/Makefile.sources
index f21bf86..5529e47 100644
--- a/src/mesa/drivers/dri/common/Makefile.sources
+++ b/src/mesa/drivers/dri/common/Makefile.sources
@@ -6,7 +6,6 @@ mesa_dri_common_gallium_SOURCES := \
 mesa_dri_common_SOURCES := \
$(mesa_dri_common_gallium_SOURCES) \
 texmem.c \
-drirenderbuffer.c
 
 # Paths are relative to MESA_TOP.
 mesa_dri_common_INCLUDES := \
diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.c 
b/src/mesa/drivers/dri/common/drirenderbuffer.c
deleted file mode 100644
index 7ac1ab1..000
--- a/src/mesa/drivers/dri/common/drirenderbuffer.c
+++ /dev/null
@@ -1,200 +0,0 @@
-
-#include main/mtypes.h
-#include main/formats.h
-#include main/renderbuffer.h
-#include main/imports.h
-#include drirenderbuffer.h
-
-
-/**
- * This will get called when a window (gl_framebuffer) is resized (probably
- * via driUpdateFramebufferSize(), below).
- * Just update width, height and internal format fields for now.
- * There's usually no memory allocation above because the present
- * DRI drivers use statically-allocated full-screen buffers. If that's not
- * the case for a DRI driver, a different AllocStorage method should
- * be used.
- */
-static GLboolean
-driRenderbufferStorage(struct gl_context *ctx, struct gl_renderbuffer *rb,
-   GLenum internalFormat, GLuint width, GLuint height)
-{
-   rb-Width = width;
-   rb-Height = height;
-   rb-InternalFormat = internalFormat;
-   return GL_TRUE;
-}
-
-
-static void
-driDeleteRenderbuffer(struct gl_renderbuffer *rb)
-{
-   /* don't free rb-Data  Chances are it's a memory mapped region for
-* the dri drivers.
-*/
-   free(rb);
-}
-
-
-/**
- * Allocate a new driRenderbuffer object.
- * Individual drivers are free to implement different versions of
- * this function.
- *
- * At this time, this function can only be used for window-system
- * renderbuffers, not user-created RBOs.
- *
- * \param format  Either GL_RGBA, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24,
- *GL_DEPTH_COMPONENT32, or GL_STENCIL_INDEX8_EXT (for now).
- * \param addr  address in main memory of the buffer.  Probably a memory
- *  mapped region.
- * \param cpp  chars or bytes per pixel
- * \param offset  start of renderbuffer with respect to start of framebuffer
- * \param pitch   pixels per row
- */
-driRenderbuffer *
-driNewRenderbuffer(gl_format format, GLvoid *addr,
-   GLint cpp, GLint offset, GLint pitch,
-   __DRIdrawable *dPriv)
-{
-   driRenderbuffer *drb;
-
-   assert(cpp  0);
-   assert(pitch  0);
-
-   drb = calloc(1, sizeof(driRenderbuffer));
-   if (drb) {
-  const GLuint name = 0;
-
-  _mesa_init_renderbuffer(drb-Base, name);
-
-  /* Make sure we're using a null-valued GetPointer routine */
-  assert(drb-Base.GetPointer(NULL, drb-Base, 0, 0) == NULL);
-
-  switch (format) {
-  case MESA_FORMAT_ARGB:
- if (cpp == 2) {
-/* override format */
-format = MESA_FORMAT_RGB565;
- }
- drb-Base.DataType = GL_UNSIGNED_BYTE;
- break;
-  case MESA_FORMAT_Z16:
- /* Depth */
- /* we 

[Mesa-dev] [PATCH 23/27] r200: Don't use driIsTextureResident helper

2011-10-28 Thread Kristian Høgsberg
With DRI2, textures are always resident and using the DRI texmem helper
here is broken anyway, since nothing else uses it.
---
 src/mesa/drivers/dri/r200/r200_tex.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_tex.c 
b/src/mesa/drivers/dri/r200/r200_tex.c
index 2be8390..fe7c977 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.c
+++ b/src/mesa/drivers/dri/r200/r200_tex.c
@@ -502,7 +502,6 @@ void r200InitTextureFuncs( radeonContextPtr radeon, struct 
dd_function_table *fu
functions-NewTextureObject = r200NewTextureObject;
//   functions-BindTexture = r200BindTexture;
functions-DeleteTexture= r200DeleteTexture;
-   functions-IsTextureResident= driIsTextureResident;
 
functions-TexEnv   = r200TexEnv;
functions-TexParameter = r200TexParameter;
-- 
1.7.7

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


[Mesa-dev] [PATCH 24/27] dri: Move _dri_texformat_* to radeon_texture.c

2011-10-28 Thread Kristian Høgsberg
They are only used by the r200 driver now.
---
 src/mesa/drivers/dri/radeon/radeon_fbo.c |6 +-
 src/mesa/drivers/dri/radeon/radeon_texture.c |   78 ++
 src/mesa/drivers/dri/radeon/radeon_texture.h |8 +++
 3 files changed, 65 insertions(+), 27 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c 
b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 4b64cac..fee4c20 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -104,7 +104,7 @@ radeon_alloc_renderbuffer_storage(struct gl_context * ctx, 
struct gl_renderbuffe
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
-  rb-Format = _dri_texformat_rgb565;
+  rb-Format = _radeon_texformat_rgb565;
   rb-DataType = GL_UNSIGNED_BYTE;
   cpp = 2;
   break;
@@ -113,7 +113,7 @@ radeon_alloc_renderbuffer_storage(struct gl_context * ctx, 
struct gl_renderbuffe
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
-  rb-Format = _dri_texformat_argb;
+  rb-Format = _radeon_texformat_argb;
   rb-DataType = GL_UNSIGNED_BYTE;
   cpp = 4;
   break;
@@ -125,7 +125,7 @@ radeon_alloc_renderbuffer_storage(struct gl_context * ctx, 
struct gl_renderbuffe
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
-  rb-Format = _dri_texformat_argb;
+  rb-Format = _radeon_texformat_argb;
   rb-DataType = GL_UNSIGNED_BYTE;
   cpp = 4;
   break;
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c 
b/src/mesa/drivers/dri/radeon/radeon_texture.c
index d840045..6b597c8 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -342,7 +342,7 @@ static gl_format radeonChooseTexFormat(radeonContextPtr 
rmesa,
 
/* r100 can only do this */
if (IS_R100_CLASS(rmesa-radeonScreen) || fbo)
- return _dri_texformat_argb;
+ return _radeon_texformat_argb;
 
if ((srcFormat == GL_RGBA  srcType == GL_UNSIGNED_INT_8_8_8_8) ||
(srcFormat == GL_RGBA  srcType == GL_UNSIGNED_BYTE  
!littleEndian) ||
@@ -355,7 +355,7 @@ static gl_format radeonChooseTexFormat(radeonContextPtr 
rmesa,
   (srcFormat == GL_ABGR_EXT  srcType == GL_UNSIGNED_BYTE  
!littleEndian)) {
return MESA_FORMAT_RGBA_REV;
} else if (IS_R200_CLASS(rmesa-radeonScreen)) {
-   return _dri_texformat_argb;
+   return _radeon_texformat_argb;
} else if (srcFormat == GL_BGRA  ((srcType == GL_UNSIGNED_BYTE  
!littleEndian) ||
srcType == 
GL_UNSIGNED_INT_8_8_8_8)) {
return MESA_FORMAT_ARGB_REV;
@@ -363,7 +363,7 @@ static gl_format radeonChooseTexFormat(radeonContextPtr 
rmesa,
srcType == 
GL_UNSIGNED_INT_8_8_8_8_REV)) {
return MESA_FORMAT_ARGB;
} else
-   return _dri_texformat_argb;
+   return _radeon_texformat_argb;
 }
 
 gl_format radeonChooseTextureFormat_mesa(struct gl_context * ctx,
@@ -403,17 +403,17 @@ gl_format radeonChooseTextureFormat(struct gl_context * 
ctx,
switch (type) {
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
-   return do32bpt ? _dri_texformat_argb :
-   _dri_texformat_argb1555;
+   return do32bpt ? _radeon_texformat_argb :
+   _radeon_texformat_argb1555;
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-   return _dri_texformat_argb;
+   return _radeon_texformat_argb;
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-   return _dri_texformat_argb1555;
+   return _radeon_texformat_argb1555;
default:
return do32bpt ? radeonChooseTexFormat(rmesa, 
format, type, fbo) :
-   _dri_texformat_argb;
+   _radeon_texformat_argb;
}
 
case 3:
@@ -422,16 +422,16 @@ gl_format radeonChooseTextureFormat(struct gl_context * 
ctx,
switch (type) {
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-   return _dri_texformat_argb;
+   return _radeon_texformat_argb;
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-   return _dri_texformat_argb1555;
+   return _radeon_texformat_argb1555;
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
-   return 

[Mesa-dev] [PATCH 25/27] dri: Remove unused dri texmem.c

2011-10-28 Thread Kristian Høgsberg
---
 src/gallium/state_trackers/dri/drm/Makefile|3 +-
 src/gallium/targets/Makefile.dri   |3 +-
 src/mesa/drivers/dri/common/Makefile.sources   |3 +-
 src/mesa/drivers/dri/common/texmem.c   | 1338 
 src/mesa/drivers/dri/common/texmem.h   |  330 -
 src/mesa/drivers/dri/i915/i830_state.c |2 -
 src/mesa/drivers/dri/i915/i915_state.c |2 -
 src/mesa/drivers/dri/r200/r200_context.h   |1 -
 .../drivers/dri/radeon/radeon_common_context.h |1 -
 src/mesa/drivers/dri/radeon/radeon_context.h   |1 -
 10 files changed, 3 insertions(+), 1681 deletions(-)
 delete mode 100644 src/mesa/drivers/dri/common/texmem.c
 delete mode 100644 src/mesa/drivers/dri/common/texmem.h

diff --git a/src/gallium/state_trackers/dri/drm/Makefile 
b/src/gallium/state_trackers/dri/drm/Makefile
index 54f1db3..1f24bf0 100644
--- a/src/gallium/state_trackers/dri/drm/Makefile
+++ b/src/gallium/state_trackers/dri/drm/Makefile
@@ -23,7 +23,6 @@ C_SOURCES = \
$(TOP)/src/mesa/drivers/dri/common/vblank.c \
$(TOP)/src/mesa/drivers/dri/common/dri_util.c \
$(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \
-   $(TOP)/src/mesa/drivers/common/driverfuncs.c \
-   $(TOP)/src/mesa/drivers/dri/common/texmem.c
+   $(TOP)/src/mesa/drivers/common/driverfuncs.c
 
 include ../../../Makefile.template
diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri
index 941122b..eb2d66c 100644
--- a/src/gallium/targets/Makefile.dri
+++ b/src/gallium/targets/Makefile.dri
@@ -17,8 +17,7 @@ COMMON_GALLIUM_SOURCES = \
 $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c
 
 COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \
-$(TOP)/src/mesa/drivers/common/driverfuncs.c \
-$(TOP)/src/mesa/drivers/dri/common/texmem.c
+$(TOP)/src/mesa/drivers/common/driverfuncs.c
 
 COMMON_BM_SOURCES = \
$(TOP)/src/mesa/drivers/dri/common/dri_bufmgr.c \
diff --git a/src/mesa/drivers/dri/common/Makefile.sources 
b/src/mesa/drivers/dri/common/Makefile.sources
index 5529e47..040b717 100644
--- a/src/mesa/drivers/dri/common/Makefile.sources
+++ b/src/mesa/drivers/dri/common/Makefile.sources
@@ -4,8 +4,7 @@ mesa_dri_common_gallium_SOURCES := \
xmlconfig.c
 
 mesa_dri_common_SOURCES := \
-   $(mesa_dri_common_gallium_SOURCES) \
-texmem.c \
+   $(mesa_dri_common_gallium_SOURCES)
 
 # Paths are relative to MESA_TOP.
 mesa_dri_common_INCLUDES := \
diff --git a/src/mesa/drivers/dri/common/texmem.c 
b/src/mesa/drivers/dri/common/texmem.c
deleted file mode 100644
index b36dcdc..000
--- a/src/mesa/drivers/dri/common/texmem.c
+++ /dev/null
@@ -1,1338 +0,0 @@
-/*
- * Copyright 2000-2001 VA Linux Systems, Inc.
- * (C) Copyright IBM Corporation 2002, 2003
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the Software),
- * to deal in the Software without restriction, including without limitation
- * 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
- * VA LINUX SYSTEM, IBM 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.
- *
- * Authors:
- *Ian Romanick i...@us.ibm.com
- *Keith Whitwell kei...@tungstengraphics.com
- *Kevin E. Martin k...@users.sourceforge.net
- *Gareth Hughes gar...@nvidia.com
- */
-
-/** \file texmem.c
- * Implements all of the device-independent texture memory management.
- * 
- * Currently, only a simple LRU texture memory management policy is
- * implemented.  In the (hopefully very near) future, better policies will be
- * implemented.  The idea is that the DRI should be able to run in one of two
- * modes.  In the default mode the DRI will dynamically attempt to discover
- * the best texture management policy for the running application.  In the
- * other mode, the user (via some sort of as yet TBD mechanism) will select
- * a texture management policy that is known to work well with the
- * application.
- */
-
-#include main/imports.h
-#include main/macros.h
-#include main/simple_list.h
-#include texmem.h
-
-
-static unsigned 

[Mesa-dev] [PATCH 26/27] dri: Remove a few unused dri helper functions

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/utils.c |  118 ---
 1 files changed, 0 insertions(+), 118 deletions(-)

diff --git a/src/mesa/drivers/dri/common/utils.c 
b/src/mesa/drivers/dri/common/utils.c
index 54156d3..d8656a7 100644
--- a/src/mesa/drivers/dri/common/utils.c
+++ b/src/mesa/drivers/dri/common/utils.c
@@ -138,124 +138,6 @@ driGetRendererString( char * buffer, const char * 
hardware_name,
 
 
 /**
- * Utility function used by drivers to test the verions of other components.
- *
- * \param driver_name  Name of the driver.  Used in error messages.
- * \param driActualActual DRI version supplied __driCreateNewScreen.
- * \param driExpected  Minimum DRI version required by the driver.
- * \param ddxActualActual DDX version supplied __driCreateNewScreen.
- * \param ddxExpected  Minimum DDX minor and range of DDX major version 
required by the driver.
- * \param drmActualActual DRM version supplied __driCreateNewScreen.
- * \param drmExpected  Minimum DRM version required by the driver.
- * 
- * \returns \c GL_TRUE if all version requirements are met.  Otherwise,
- *  \c GL_FALSE is returned.
- * 
- * \sa __driCreateNewScreen, driCheckDriDdxDrmVersions2
- *
- * \todo
- * Now that the old \c driCheckDriDdxDrmVersions function is gone, this
- * function and \c driCheckDriDdxDrmVersions2 should be renamed.
- */
-GLboolean
-driCheckDriDdxDrmVersions3(const char * driver_name,
-  const __DRIversion * driActual,
-  const __DRIversion * driExpected,
-  const __DRIversion * ddxActual,
-  const __DRIutilversion2 * ddxExpected,
-  const __DRIversion * drmActual,
-  const __DRIversion * drmExpected)
-{
-   static const char format[] = %s DRI driver expected %s version %d.%d.x 
-   but got version %d.%d.%d\n;
-   static const char format2[] = %s DRI driver expected %s version %d-%d.%d.x 

-   but got version %d.%d.%d\n;
-
-
-   /* Check the DRI version */
-   if ( (driActual-major != driExpected-major)
-   || (driActual-minor  driExpected-minor) ) {
-  fprintf(stderr, format, driver_name, DRI,
-  driExpected-major, driExpected-minor,
-  driActual-major, driActual-minor, driActual-patch);
-  return GL_FALSE;
-   }
-
-   /* Check that the DDX driver version is compatible */
-   if ( (ddxActual-major  ddxExpected-major_min)
-   || (ddxActual-major  ddxExpected-major_max)
-   || (ddxActual-minor  ddxExpected-minor) ) {
-  fprintf(stderr, format2, driver_name, DDX,
-  ddxExpected-major_min, ddxExpected-major_max, 
ddxExpected-minor,
-  ddxActual-major, ddxActual-minor, ddxActual-patch);
-  return GL_FALSE;
-   }
-   
-   /* Check that the DRM driver version is compatible */
-   if ( (drmActual-major != drmExpected-major)
-   || (drmActual-minor  drmExpected-minor) ) {
-  fprintf(stderr, format, driver_name, DRM,
-  drmExpected-major, drmExpected-minor,
-  drmActual-major, drmActual-minor, drmActual-patch);
-  return GL_FALSE;
-   }
-
-   return GL_TRUE;
-}
-
-GLboolean
-driCheckDriDdxDrmVersions2(const char * driver_name,
-  const __DRIversion * driActual,
-  const __DRIversion * driExpected,
-  const __DRIversion * ddxActual,
-  const __DRIversion * ddxExpected,
-  const __DRIversion * drmActual,
-  const __DRIversion * drmExpected)
-{
-   __DRIutilversion2 ddx_expected;
-   ddx_expected.major_min = ddxExpected-major;
-   ddx_expected.major_max = ddxExpected-major;
-   ddx_expected.minor = ddxExpected-minor;
-   ddx_expected.patch = ddxExpected-patch;
-   return driCheckDriDdxDrmVersions3(driver_name, driActual,
-   driExpected, ddxActual,  ddx_expected,
-   drmActual, drmExpected);
-}
-
-GLboolean driClipRectToFramebuffer( const struct gl_framebuffer *buffer,
-   GLint *x, GLint *y,
-   GLsizei *width, GLsizei *height )
-{
-   /* left clipping */
-   if (*x  buffer-_Xmin) {
-  *width -= (buffer-_Xmin - *x);
-  *x = buffer-_Xmin;
-   }
-
-   /* right clipping */
-   if (*x + *width  buffer-_Xmax)
-  *width -= (*x + *width - buffer-_Xmax - 1);
-
-   if (*width = 0)
-  return GL_FALSE;
-
-   /* bottom clipping */
-   if (*y  buffer-_Ymin) {
-  *height -= (buffer-_Ymin - *y);
-  *y = buffer-_Ymin;
-   }
-
-   /* top clipping */
-   if (*y + *height  buffer-_Ymax)
-  *height -= (*y + *height - buffer-_Ymax - 1);
-
-   if (*height = 0)
-  return GL_FALSE;
-
-   return GL_TRUE;
-}
-
-/**
  * Creates a set of \c struct gl_config that a driver will expose.
  * 
  * A set of \c struct 

[Mesa-dev] [PATCH 27/27] dri: Remove unused memops.h

2011-10-28 Thread Kristian Høgsberg
---
 src/mesa/drivers/dri/common/memops.h |   17 -
 src/mesa/drivers/dri/common/utils.h  |   25 -
 2 files changed, 0 insertions(+), 42 deletions(-)
 delete mode 100644 src/mesa/drivers/dri/common/memops.h

diff --git a/src/mesa/drivers/dri/common/memops.h 
b/src/mesa/drivers/dri/common/memops.h
deleted file mode 100644
index 9cd1d8e..000
--- a/src/mesa/drivers/dri/common/memops.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef DRIMEMSETIO_H
-#define DRIMEMSETIO_H
-/*
-* memset an area in I/O space
-* We need to be careful about this on some archs
-*/
-static INLINE void drimemsetio(void* address, int c, int size)
-{
-#if defined(__powerpc__) || defined(__ia64__)
- int i;
- for(i=0;isize;i++)
-*((char *)address + i)=c;
-#else
- memset(address,c,size);
-#endif
-}
-#endif
diff --git a/src/mesa/drivers/dri/common/utils.h 
b/src/mesa/drivers/dri/common/utils.h
index 100d0dd..c2302de 100644
--- a/src/mesa/drivers/dri/common/utils.h
+++ b/src/mesa/drivers/dri/common/utils.h
@@ -39,17 +39,6 @@ struct dri_debug_control {
 unsigned flag;
 };
 
-/**
- * Used to store a version which includes a major range instead of a single
- * major version number.
- */
-struct __DRIutilversionRec2 {
-intmajor_min;/** min allowed Major version number. */
-intmajor_max;/** max allowed Major version number. */
-intminor;/** Minor version number. */
-intpatch;/** Patch-level. */
-};
-
 extern void
 __driUtilMessage(const char *f, ...);
 
@@ -59,20 +48,6 @@ extern unsigned driParseDebugString( const char * debug,
 extern unsigned driGetRendererString( char * buffer,
 const char * hardware_name, GLuint agp_mode );
 
-extern GLboolean driCheckDriDdxDrmVersions2(const char * driver_name,
-const __DRIversion * driActual, const __DRIversion * driExpected,
-const __DRIversion * ddxActual, const __DRIversion * ddxExpected,
-const __DRIversion * drmActual, const __DRIversion * drmExpected);
-
-extern GLboolean driCheckDriDdxDrmVersions3(const char * driver_name,
-const __DRIversion * driActual, const __DRIversion * driExpected,
-const __DRIversion * ddxActual, const __DRIutilversion2 * ddxExpected,
-const __DRIversion * drmActual, const __DRIversion * drmExpected);
-
-extern GLboolean driClipRectToFramebuffer( const struct gl_framebuffer *buffer,
-  GLint *x, GLint *y,
-  GLsizei *width, GLsizei *height );
-
 struct __DRIconfigRec {
 struct gl_config modes;
 };
-- 
1.7.7

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


[Mesa-dev] intel GPU freeze with master, with apitrace log

2011-10-28 Thread tom fogal
Hi all,

Our application has a render mode which is causing a Sandybridge-based
system to hang for a second with Mesa master.  In dmesg I see:

  [drm:i915_hangcheck_elapsed] *ERROR* Hangcheck timer elapsed... GPU hung
  [drm:i915:do_wait_request] *ERROR* i915_do_wait_request returns -11 (awaiting 
23347 at 23343, next 23348)

and on my terminal I get

  intel_do_flush_locked failed: Input/output error

A few seconds before X server does not seem to receive/process updates
(i.e. mouse movements).  Then the screen flickers once and after that
mouse movements are processed as normal.  I've made multiple traces,
and sometimes this appears to happen twice per run, other times it just
occurs once... might be a timing thing with how quickly I can close the
window after the first hang.

I've generated an apitrace (! really great tool!) log for it, but it's
a bit big (~3mb) to attach to a mailing list posting so I put it on the
web:

  http://www.sci.utah.edu/~tfogal/tmp/iv3d.trace

If I 'glretrace' that on the Intel system, things freeze for a second
just like when I run my application.  If I copy it to my nvidia-blob
system, the program displays a black window quickly and then ends; no
flickers / freezes / etc.

I'm a little stuck debugging... the GPU hang really screws up gdb.
Thoughts/ideas?

Thanks,

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


Re: [Mesa-dev] [PATCH] r600g: remove one pointless flush

2011-10-28 Thread Vadim Girlin
On Sat, 2011-10-29 at 01:29 +0400, Vadim Girlin wrote:
 On Fri, 2011-10-28 at 23:16 +0200, Marek Olšák wrote:
  On Fri, Oct 28, 2011 at 10:52 PM, Vadim Girlin vadimgir...@gmail.com 
  wrote:
   On Fri, 2011-10-28 at 19:47 +0200, Marek Olšák wrote:
   I've got no idea what the flush was good for, but it's useless from
   the looks of it. The rest of the patch is just a cleanup resulting
   from some of the variables being no longer used for anything useful.
  
   There are no piglit regressions.
  
   It was intended to handle multiple interleaved query and conditional
   render calls with single query object (in this case in theory we may
   have multiple outstanding queries in current CS and separate data block
   in the buffer for each query, with possible buffer overflow). I wasn't
  
  Do you mean this?
  
  while (1) {
begin_query(q);
draw();
end_query(q);
render_condition(q);
draw();
render_condition(NULL);
  }
  
  begin_query always resets query results to 0 anyway, so in theory, we
  could re-use the same data block over and over again. 
 
 I think it's possible to run this loop without flushes, so we'll have
 multiple queries queued in current cs. From the driver point of view
 these queries will be executed simultaneously after flush, that's why we
 need to reserve and initialize separate data blocks for them.
 

Probably we also need to use PIPE_TRANSFER_UNSYCHRONIZED to avoid the
flush when mapping the buffer for data block initialization in the
r600_query_begin. It seems I missed this, or the mapping semantics were
changed with winsys change. 

Vadim

 Vadim
 
  I think the only
  case where buffer overflow may happen is:
  
  begin_query(q);
  while (1) {
draw();
suspend_queries(); // flush or u_blitter
resume_queries();
  }
  end_query(q);
  
  Correct?
  
  Marek
 
 
 



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


Re: [Mesa-dev] [PATCH 04/24] intel: Use MapRenderbuffer in spans setup.

2011-10-28 Thread Chad Versace
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

This patch will break depthstencil renderbuffers on gen7. Comments below.

On 10/28/2011 12:49 PM, Eric Anholt wrote:
 ---
  src/mesa/drivers/dri/intel/intel_span.c |   33 +-
  1 files changed, 10 insertions(+), 23 deletions(-)
 
 diff --git a/src/mesa/drivers/dri/intel/intel_span.c 
 b/src/mesa/drivers/dri/intel/intel_span.c
 index bdc4a0e..ecccd30 100644
 --- a/src/mesa/drivers/dri/intel/intel_span.c
 +++ b/src/mesa/drivers/dri/intel/intel_span.c
 @@ -221,7 +221,10 @@ intel_offset_S8(uint32_t stride, uint32_t x, uint32_t y)
  void
  intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer 
 *rb)
  {
 +   struct gl_context *ctx = intel-ctx;
 struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 +   GLubyte *map;
 +   int stride;
  
 if (!irb)
return;
 @@ -231,25 +234,11 @@ intel_renderbuffer_map(struct intel_context *intel, 
 struct gl_renderbuffer *rb)
 if (irb-wrapped_depth)
intel_renderbuffer_map(intel, irb-wrapped_depth);
 if (irb-wrapped_stencil)
intel_renderbuffer_map(intel, irb-wrapped_stencil);

Here we map the real depth and stencil renderbuffers individually.

[snip]
 +   ctx-Driver.MapRenderbuffer(ctx, rb, 0, 0, rb-Width, rb-Height,
 +GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
 +map, stride);
 +   rb-Data = map;

And here, the mappings done above are ignored and we set rb-Data = NULL.

To avoid regressing gen7, we need to copy the s8 bits in
irb-wrapped_stencil-Data into irb-wrapped_depth-Data, then unmap
irb-wrapped_stencil and set rb-Data = irb-wrapped_depth-Data.

- -- 
Chad Versace
c...@chad-versace.us
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOq0HCAAoJEAIvNt057x8iRcgP/2MO6cCyqO4DJmireTzUF+s/
3bb5psTo5KcPLGJAWj5ILRUQ38XVP6zyNYvBwSjYFa5BgY4He/rudsPNVyd+l12u
LSmn7910wvWIwdLRr0XlGBfnXh29yOhaC+mou7Km3uuiBL8hPrwUvU6P/RSO/FPv
YpeNMJlYvmr2OUWaWNG388s0EDwbvn9B/uDJZu1VUbyJiXBdZgB4CyYH1RExJ93O
2BI4DyzzicgxSXdHO+nDh3LI/8GP+30DqNZP6tpXNm/oRC/3tEPyNfiZzNemS64E
qnIPsQwfX84W/BAp9DbrVmWR7Ikylvp44IeVih62DuiqX3KV5aUteZHRriSCcgbJ
xiUKaPR0M99Dm3Rflg1qlcKXqQZs0oEVkCBD/UzANXFNSembgC9Lk/5E1ovUMFST
9nveKeytP06xVvvYbUJS0tw6TNoNAjwlGZEPn6C9KSXW4nclCXJrwaVP6UbdHULe
l2U+3Vyl32Mrh14SziblKGk4JpcyYijRzG8jQbh34xEMjz22tjAF4ipC2ld6k9v3
A3nY2J4gF7fi9sZHuBRXqMNh0UpD/abKnHp0N7HW8fRL7gTGgvWCtsliQnNMgN4f
niIaAb9dMBxDMKBkrrgxB4NGZZHxD0bQmI+PzdHQw9F56iLYIk4PARZesYwmICss
ydwp/fqevXzfqyf0IA84
=TeYG
-END PGP SIGNATURE-
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600g: remove one pointless flush

2011-10-28 Thread Marek Olšák
On Sat, Oct 29, 2011 at 12:58 AM, Vadim Girlin vadimgir...@gmail.com wrote:
 On Sat, 2011-10-29 at 01:29 +0400, Vadim Girlin wrote:
 On Fri, 2011-10-28 at 23:16 +0200, Marek Olšák wrote:
  On Fri, Oct 28, 2011 at 10:52 PM, Vadim Girlin vadimgir...@gmail.com 
  wrote:
   On Fri, 2011-10-28 at 19:47 +0200, Marek Olšák wrote:
   I've got no idea what the flush was good for, but it's useless from
   the looks of it. The rest of the patch is just a cleanup resulting
   from some of the variables being no longer used for anything useful.
  
   There are no piglit regressions.
  
   It was intended to handle multiple interleaved query and conditional
   render calls with single query object (in this case in theory we may
   have multiple outstanding queries in current CS and separate data block
   in the buffer for each query, with possible buffer overflow). I wasn't
 
  Do you mean this?
 
  while (1) {
    begin_query(q);
    draw();
    end_query(q);
    render_condition(q);
    draw();
    render_condition(NULL);
  }
 
  begin_query always resets query results to 0 anyway, so in theory, we
  could re-use the same data block over and over again.

 I think it's possible to run this loop without flushes, so we'll have
 multiple queries queued in current cs. From the driver point of view
 these queries will be executed simultaneously after flush, that's why we
 need to reserve and initialize separate data blocks for them.


 Probably we also need to use PIPE_TRANSFER_UNSYCHRONIZED to avoid the
 flush when mapping the buffer for data block initialization in the
 r600_query_begin. It seems I missed this, or the mapping semantics were
 changed with winsys change.

Ah I see. I entirely missed the map/unmap part. Of course there is an
implicit sync in the winsys (the flush is not so expensive, but the
sync is). UNSYCHRONIZED would be dangerous in this particular case,
because the GPU may still use the previous buffer data. UNSYCHRONIZED
can only be used if we're 100% sure the GPU doesn't use the buffer
range we're going to change. I see only two ways out of this:

1) If the buffer is full, we can allocate another one and use that. I
don't think we have any other choice with current Mesa master.

2) We can program the GPU to memset the buffer. This would be very
easy with transform feedback.

I prefer (2).

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


Re: [Mesa-dev] [PATCH 04/24] intel: Use MapRenderbuffer in spans setup.

2011-10-28 Thread Chad Versace
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/28/2011 04:58 PM, Chad Versace wrote:
 This patch will break depthstencil renderbuffers on gen7. Comments below.
 
 On 10/28/2011 12:49 PM, Eric Anholt wrote:
 ---
  src/mesa/drivers/dri/intel/intel_span.c |   33
  +-
  1 files changed, 10 insertions(+), 23 deletions(-)
 
 diff --git a/src/mesa/drivers/dri/intel/intel_span.c
 b/src/mesa/drivers/dri/intel/intel_span.c
 index bdc4a0e..ecccd30 100644
 --- a/src/mesa/drivers/dri/intel/intel_span.c
 +++ b/src/mesa/drivers/dri/intel/intel_span.c
 @@ -221,7 +221,10 @@ intel_offset_S8(uint32_t stride, uint32_t x, uint32_t
 y)
  void
  intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer
  *rb)
  {
 +   struct gl_context *ctx = intel-ctx;
 struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 +   GLubyte *map;
 +   int stride;
 
 if (!irb)
return;
 @@ -231,25 +234,11 @@ intel_renderbuffer_map(struct intel_context *intel,
 struct gl_renderbuffer *rb)
 if (irb-wrapped_depth)
intel_renderbuffer_map(intel, irb-wrapped_depth);
 if (irb-wrapped_stencil)
intel_renderbuffer_map(intel, irb-wrapped_stencil);
 
 Here we map the real depth and stencil renderbuffers individually.
 
 [snip]
 +   ctx-Driver.MapRenderbuffer(ctx, rb, 0, 0, rb-Width, rb-Height,
 +   GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
 +   map, stride);
 +   rb-Data = map;
 
 And here, the mappings done above are ignored and we set rb-Data = NULL.
 
 To avoid regressing gen7, we need to copy the s8 bits in
 irb-wrapped_stencil-Data into irb-wrapped_depth-Data, then unmap
 irb-wrapped_stencil and set rb-Data = irb-wrapped_depth-Data.

Oops. I commented before I read the patch for
fast_read_depth_stencil_pixels_separate. I assume that function voids
my comments above.

Still, stencil buffer mapping is broken. See the crazy stencil values printed
by hiz-stencil-read-fbo-d24-s8 on gen7. 

I'm sure you're aware of what I'm about to say... For stencil buffers,
intel_map_renderbuffer will need to malloc a temporary buffer at rb-Data into
which the stencil pixels get detiled and copied. And, just in case
GL_MAP_WRITE_BIT was set, intel_unmap_renderbuffer will need to tile and write
back the pixels. So intel_renderbuffer will need to track the mapping mode for
this case.

- -- 
Chad Versace
c...@chad-versace.us

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOq0nvAAoJEAIvNt057x8iKVQQAKaqEOH1nA83BgTFFvWCdY00
HzoUKiSw2lCjf6ishe/aeMLvIIOpXmIYV5Cx9T5nwg6ZZKgdw1Sqt/gy3r8ytdHR
cabMcaPBLjhtZCeX9Sx4JpoSLOz53OYQxHIk1uB7ONT4P9Y4S5hsjjKaErNOhKHn
h52qL4tC+KgA3797r4w3e8bfNwLAf7ee4wvVnaQiTk8X2E0se2xNaDP1mz2Li0we
XcAH7K0HCYRQo9ZRR8OFHVeoWq0DqfAy3p9wPeQjt9KbPiJyOHD1OoozvQ/XVxGM
jupHCSRaHctRq3GyoVNQDLFiOl0dNStl1NQOIafgjYr4YzaFgZvVsB1lRKmlmqrg
QLnhwN+mo9AsoQPf6FCP1k6zVdXfiXNXKEoPzeXpEMgeZVSVhrb1x/cPJ0OvyaTm
elrYFJw4ROwNEHG7+VMAp2sHT8kZEv2eJbN9BCwjNjryR50O/z1ytr5gAZ8caUXt
gH4C8Duq/IKnUNWCRZKh1cDWinKb+J1DxWU/0wjjy4U/zTA3oAgaFqdN4BXnuW8B
6Wu85NjsoogANVWbzPwadm9fUmuncTVGk9Mzn78HWId8NBFDyFiDH3/OL//eKn6Z
Ed5H7pPF0p6gpWwcIcWHXZK8tQew2ccp8AYdj5oK0YR8yxEQXdXV139C4E/mYIuW
+hR7QAyK1sqtfHhKWOma
=JXfp
-END PGP SIGNATURE-
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev