Re: [Mesa-dev] [PATCH] glsl/gallium: add a remove_output lowering pass

2012-01-02 Thread Kenneth Graunke
On 12/31/2011 03:52 PM, Vincent Lejeune wrote:
> Current glsl_to_tgsi::remove_output_read pass did not work properly when
> indirect addressing was involved ; this commit replaces it with
> a lowering pass that occurs before glsl_to_tgsi visitor is called.
> This patch fix varying-array related piglit test.
> ---
>  src/glsl/Makefile.sources  |1 +
>  src/glsl/lower_remove_output_read.cpp  |   97 
> 
>  src/glsl/lower_remove_output_read.h|   62 ++
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   20 --
>  4 files changed, 172 insertions(+), 8 deletions(-)
>  create mode 100644 src/glsl/lower_remove_output_read.cpp
>  create mode 100644 src/glsl/lower_remove_output_read.h

Vincent,

I like this!  I have a couple of comments below.  To save some trouble,
I've actually gone ahead and made the changes, and will send out a
proposed v2 of this patch shortly.

> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index c65bfe4..6c80089 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -60,6 +60,7 @@ LIBGLSL_CXX_SOURCES := \
>   lower_vec_index_to_cond_assign.cpp \
>   lower_vec_index_to_swizzle.cpp \
>   lower_vector.cpp \
> + lower_remove_output_read.cpp \
>   opt_algebraic.cpp \
>   opt_constant_folding.cpp \
>   opt_constant_propagation.cpp \
> diff --git a/src/glsl/lower_remove_output_read.cpp 
> b/src/glsl/lower_remove_output_read.cpp
> new file mode 100644
> index 000..8150580
> --- /dev/null
> +++ b/src/glsl/lower_remove_output_read.cpp
> @@ -0,0 +1,97 @@
> +/*
> + * Copyright © 2010 Intel Corporation
> + * Copyright © 2012 Vincent Lejeune
> + *
> + * 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.
> + */
> +
> +#include "lower_remove_output_read.h"
> +#include "ir.h"
> +
> +
> +void
> +output_read_remover::add_replacement_pair(ir_variable *output, ir_variable 
> *temp)
> +{
> +   if (replacements_count == 0) {
> +  replacements_array = (struct replacement_pair *) 
> ralloc_array_size(mem_ctx, sizeof(struct replacement_pair),1);
> +   }
> +   else {
> +  replacements_array = (struct replacement_pair *) 
> reralloc_array_size(mem_ctx,replacements_array, sizeof(struct 
> replacement_pair), replacements_count + 1);
> +   }

reralloc_array_size actually does an initial allocation if the pointer
you pass is NULL, so you don't need a special case for zero.  Plus, you
could use the handy "reralloc" macro which does the typecast and sizeof
for you.  This could just be:

   replacements_array = reralloc(mem_ctx, replacements_array, struct
replacement_pair, replacements_count + 1);

However, you probably ought to avoid reallocating the array each time
you encounter a new shader output.  (It's probably not _critical_ since
there aren't typically many outputs, but still worth fixing.)  The
typical solution is to maintain the array size as a second counter and
double the size of the array each time.

> +   hash_table_insert(replacements,temp,output);
> +   replacements_array[replacements_count].output = output;
> +   replacements_array[replacements_count].temp = temp;
> +   replacements_count++;
> +}
> +
> +output_read_remover::output_read_remover():ir_hierarchical_visitor(), 
> replacements_count(0)

No need to call the parent class constructor explicitly; C++ just does
that for you.

> +{
> +   replacements = 
> hash_table_ctor(0,hash_table_pointer_hash,hash_table_pointer_compare);

Probably want to initialize replacements_array here.

> +   mem_ctx = ralloc_context(NULL);
> +}
> +
> +output_read_remover::~output_read_remover()
> +{
> +   hash_table_dtor(replacements);
> +   ralloc_free(mem_ctx);
> +}
> +
> +ir_visitor_status
> +output_read_remover::visit(ir_dereference_variable *ir)
> +{
> +   ir_variable* temp = (ir_variable*) hash_table_find(replacements, ir->var);

[Mesa-dev] [PATCH 1/3] glsl: Add a lowering pass to remove reads of shader output variables.

2012-01-02 Thread Kenneth Graunke
From: Vincent Lejeune 

This is similar to Gallium's existing glsl_to_tgsi::remove_output_read
lowering pass, but done entirely inside the GLSL compiler.

Signed-off-by: Vincent Lejeune 
Signed-off-by: Kenneth Graunke 
---
 src/glsl/Makefile.sources   |1 +
 src/glsl/ir_optimization.h  |1 +
 src/glsl/lower_output_reads.cpp |  152 +++
 3 files changed, 154 insertions(+), 0 deletions(-)
 create mode 100644 src/glsl/lower_output_reads.cpp

v2 [Kayden]:
 - Don't reallocate the array for every shader output.
 - Move the class into the .cpp file and create a lower_output_reads() wrapper
 - Simplify the logic in visit(ir_deference_variable *)
 - Fold add_replacement_pair into the only caller.
 - Use visit_leave(ir_return *) instead of enter (for paranoia, in case the
   return value references shader outputs)
 - Visit signatures rather than functions, to avoid pattern matching to find
   the actual void main() signature.
 - Add some comments
 - Whitespace fixes

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index c65bfe4..5e80af2 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -60,6 +60,7 @@ LIBGLSL_CXX_SOURCES := \
lower_vec_index_to_cond_assign.cpp \
lower_vec_index_to_swizzle.cpp \
lower_vector.cpp \
+   lower_output_reads.cpp \
opt_algebraic.cpp \
opt_constant_folding.cpp \
opt_constant_propagation.cpp \
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index 7b32e84..085b969 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -72,6 +72,7 @@ bool lower_variable_index_to_cond_assign(exec_list 
*instructions,
 bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
 bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
 bool lower_clip_distance(exec_list *instructions);
+void lower_output_reads(exec_list *instructions);
 bool optimize_redundant_jumps(exec_list *instructions);
 
 ir_rvalue *
diff --git a/src/glsl/lower_output_reads.cpp b/src/glsl/lower_output_reads.cpp
new file mode 100644
index 000..f8de16f
--- /dev/null
+++ b/src/glsl/lower_output_reads.cpp
@@ -0,0 +1,152 @@
+/*
+ * Copyright © 2012 Vincent Lejeune
+ * Copyright © 2012 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.
+ */
+
+#include "ir.h"
+#include "program/hash_table.h"
+
+/**
+ * \file lower_output_reads.cpp
+ *
+ * In GLSL, shader output variables (such as varyings) can be both read and
+ * written.  However, on some hardware, reading an output register causes
+ * trouble.
+ *
+ * This pass creates temporary shadow copies of every (used) shader output,
+ * and replaces all accesses to use those instead.  It also adds code to the
+ * main() function to copy the final values to the actual shader outputs.
+ */
+
+class output_read_remover : public ir_hierarchical_visitor {
+protected:
+   struct replacement_pair {
+  ir_variable *output;
+  ir_variable *temp;
+   };
+
+   /**
+* A hash table mapping from the original ir_variable shader outputs
+* (ir_var_out mode) to the new temporaries to be used instead.
+*/
+   hash_table *replacements;
+
+   /**
+* An array of tuples containing both the output and temporary variables.
+* This is necessary because we can't iterate over the hash table.
+*/
+   struct replacement_pair *replacements_array;
+   unsigned replacements_count;
+   unsigned replacements_array_size;
+
+   void *mem_ctx;
+public:
+   output_read_remover();
+   ~output_read_remover();
+   virtual ir_visitor_status visit(class ir_dereference_variable *);
+   virtual ir_visitor_status visit_leave(class ir_return *);
+   virtual ir_visitor_status visit_leave(class ir_function_signature *);
+};
+
+output_read_remover::output_read_remover()
+{
+   mem_ctx = ralloc_context(NULL);
+
+   replacements

[Mesa-dev] [PATCH 2/3] glsl_to_tgsi: Use the GLSL compiler's new remove-output-reads pass.

2012-01-02 Thread Kenneth Graunke
From: Vincent Lejeune 

The existing glsl_to_tgsi::remove_output_read pass did not work properly
when indirect addressing was involved; this commit replaces it with a
lowering pass that occurs before TGSI code generation.

Fixes varying-array related piglit tests.

Signed-off-by: Vincent Lejeune 
Signed-off-by: Kenneth Graunke 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   15 +++
 1 files changed, 7 insertions(+), 8 deletions(-)

v2: Split out into separate patch; use new wrapper function.

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 77aa0d1..10dbefa 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4850,6 +4850,13 @@ get_mesa_program(struct gl_context *ctx,
_mesa_generate_parameters_list_for_uniforms(shader_program, shader,
   prog->Parameters);
 
+   if (!screen->get_shader_param(screen, pipe_shader_type,
+ PIPE_SHADER_CAP_OUTPUT_READ)) {
+  /* Remove reads to output registers, and to varyings in vertex shaders. 
*/
+  lower_output_reads(shader->ir);
+   }
+
+
/* Emit intermediate IR for main(). */
visit_exec_list(shader->ir, v);
 
@@ -4896,14 +4903,6 @@ get_mesa_program(struct gl_context *ctx,
}
 #endif
 
-   if (!screen->get_shader_param(screen, pipe_shader_type,
- PIPE_SHADER_CAP_OUTPUT_READ)) {
-  /* Remove reads to output registers, and to varyings in vertex shaders. 
*/
-  v->remove_output_reads(PROGRAM_OUTPUT);
-  if (target == GL_VERTEX_PROGRAM_ARB)
- v->remove_output_reads(PROGRAM_VARYING);
-   }
-   
/* Perform optimizations on the instructions in the glsl_to_tgsi_visitor. */
v->simplify_cmp();
v->copy_propagate();
-- 
1.7.8.1

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


[Mesa-dev] [PATCH 3/3] glsl_to_tgsi: Remove the obsolete remove_output_reads pass.

2012-01-02 Thread Kenneth Graunke
This is now handled by the GLSL compiler, so this code is dead.
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   84 
 1 files changed, 0 insertions(+), 84 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 10dbefa..f08fea9 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -413,7 +413,6 @@ public:
 
bool process_move_condition(ir_rvalue *ir);
 
-   void remove_output_reads(gl_register_file type);
void simplify_cmp(void);
 
void rename_temp_register(int index, int new_index);
@@ -2920,89 +2919,6 @@ set_uniform_initializer(struct gl_context *ctx, void 
*mem_ctx,
}
 }
 
-/*
- * Scan/rewrite program to remove reads of custom (output) registers.
- * The passed type has to be either PROGRAM_OUTPUT or PROGRAM_VARYING
- * (for vertex shaders).
- * In GLSL shaders, varying vars can be read and written.
- * On some hardware, trying to read an output register causes trouble.
- * So, rewrite the program to use a temporary register in this case.
- * 
- * Based on _mesa_remove_output_reads from programopt.c.
- */
-void
-glsl_to_tgsi_visitor::remove_output_reads(gl_register_file type)
-{
-   GLuint i;
-   GLint outputMap[VERT_RESULT_MAX];
-   GLint outputTypes[VERT_RESULT_MAX];
-   GLuint numVaryingReads = 0;
-   GLboolean *usedTemps;
-   GLuint firstTemp = 0;
-
-   usedTemps = new GLboolean[MAX_TEMPS];
-   if (!usedTemps) {
-  return;
-   }
-   _mesa_find_used_registers(prog, PROGRAM_TEMPORARY,
- usedTemps, MAX_TEMPS);
-
-   assert(type == PROGRAM_VARYING || type == PROGRAM_OUTPUT);
-   assert(prog->Target == GL_VERTEX_PROGRAM_ARB || type != PROGRAM_VARYING);
-
-   for (i = 0; i < VERT_RESULT_MAX; i++)
-  outputMap[i] = -1;
-
-   /* look for instructions which read from varying vars */
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-  glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
-  const GLuint numSrc = num_inst_src_regs(inst->op);
-  GLuint j;
-  for (j = 0; j < numSrc; j++) {
- if (inst->src[j].file == type) {
-/* replace the read with a temp reg */
-const GLuint var = inst->src[j].index;
-if (outputMap[var] == -1) {
-   numVaryingReads++;
-   outputMap[var] = _mesa_find_free_register(usedTemps,
- MAX_TEMPS,
- firstTemp);
-   outputTypes[var] = inst->src[j].type;
-   firstTemp = outputMap[var] + 1;
-}
-inst->src[j].file = PROGRAM_TEMPORARY;
-inst->src[j].index = outputMap[var];
- }
-  }
-   }
-
-   delete [] usedTemps;
-
-   if (numVaryingReads == 0)
-  return; /* nothing to be done */
-
-   /* look for instructions which write to the varying vars identified above */
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-  glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
-  if (inst->dst.file == type && outputMap[inst->dst.index] >= 0) {
- /* change inst to write to the temp reg, instead of the varying */
- inst->dst.file = PROGRAM_TEMPORARY;
- inst->dst.index = outputMap[inst->dst.index];
-  }
-   }
-   
-   /* insert new MOV instructions at the end */
-   for (i = 0; i < VERT_RESULT_MAX; i++) {
-  if (outputMap[i] >= 0) {
- /* MOV VAR[i], TEMP[tmp]; */
- st_src_reg src = st_src_reg(PROGRAM_TEMPORARY, outputMap[i], 
outputTypes[i]);
- st_dst_reg dst = st_dst_reg(type, WRITEMASK_XYZW, outputTypes[i]);
- dst.index = i;
- this->emit(NULL, TGSI_OPCODE_MOV, dst, src);
-  }
-   }
-}
-
 /**
  * Returns the mask of channels (bitmask of WRITEMASK_X,Y,Z,W) which
  * are read from the given src in this instruction
-- 
1.7.8.1

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


Re: [Mesa-dev] [PATCH 1/3] intel: Fix bad read/write flags on self-copies for glCopyBufferSubData().

2012-01-02 Thread Kenneth Graunke
On 12/28/2011 11:14 AM, Eric Anholt wrote:
> We didn't consume these flags in any way that would produce a
> functional difference, but we might have some day.
> ---
>  src/mesa/drivers/dri/intel/intel_buffer_objects.c |4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c 
> b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
> index 4a1a816..9b1f642 100644
> --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
> +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
> @@ -663,7 +663,9 @@ intel_bufferobj_copy_subdata(struct gl_context *ctx,
> */
>if (src == dst) {
>char *ptr = intel_bufferobj_map_range(ctx, 0, dst->Size,
> -GL_MAP_READ_BIT, dst);
> +GL_MAP_READ_BIT |
> +GL_MAP_WRITE_BIT,
> +dst);
>memmove(ptr + write_offset, ptr + read_offset, size);
>intel_bufferobj_unmap(ctx, dst);
>} else {

For the series (1-3):
Reviewed-by: Kenneth Graunke 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] vbo: Clean up recalculate_input_bindings.

2012-01-02 Thread Kenneth Graunke
On 12/26/2011 11:51 PM, Mathias Fröhlich wrote:
> 
> Hi,
> 
> On Tuesday, December 27, 2011 00:17:09 Brian Paul wrote:
>> LGTM.  I presume you've done a piglit run and tested with a few other
>> things?
> I have run piglit quick with classic swrast an piglit r600g on gallium rv670 
> with this change. Also I am pretty sure that I have started osgviewer and 
> probably flightgear on this. The full piglit runs are just too heavy running 
> with valgrind. I never had the patience to wait for that to finish.

For future reference, I would use quick.tests.  The difference is:
- it only runs tests on one visual, rather than all of them
- it doesn't run valgrind
It should only take 10-15 minutes or so.

I would like to split out valgrind from all.tests into a separate
valgrind.tests at some point.  That said, running with all.tests and the
"-x valgrind" pattern also accomplishes that.

> So, I have leared from the past series that classic swrast serves as a good 
> testbed for tnl drivers like the intel one - where I do not have hardware at 
> hand. I did not do this in former times.
> In this case the swrast test is probably my best bet to catch changes in the 
> classic paths anyway.
> 
> When we are at this, what tests would you recommend?
> 
> Thanks
> 
> Mathias
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] gallium: add flag PIPE_TRANSFER_MAP_PERMANENTLY

2012-01-02 Thread Christian König
Looks good on first sign. I'm waiting for this for quite some time now, 
cause it makes XvMC state tracker implementation more cleaner and faster.


Acked-by: Christian König 

On 02.01.2012 01:22, Marek Olšák wrote:

Please see the diff for further info.

This paves the way for moving user buffer uploads out of drivers and should
allow to clean up the mess in u_upload_mgr in the meantime.

For now only allowed for buffers on r300 and r600.
---
  src/gallium/drivers/i915/i915_resource_buffer.c  |7 ++-
  src/gallium/drivers/i915/i915_resource_texture.c |7 ++-
  src/gallium/drivers/llvmpipe/lp_texture.c|4 
  src/gallium/drivers/nouveau/nouveau_buffer.c |8 +++-
  src/gallium/drivers/nv50/nv50_transfer.c |2 +-
  src/gallium/drivers/nvc0/nvc0_transfer.c |2 +-
  src/gallium/drivers/nvfx/nvfx_transfer.c |3 +++
  src/gallium/drivers/r300/r300_transfer.c |4 
  src/gallium/drivers/r600/r600_texture.c  |4 
  src/gallium/drivers/svga/svga_resource_buffer.c  |4 
  src/gallium/drivers/svga/svga_resource_texture.c |2 +-
  src/gallium/include/pipe/p_defines.h |   16 
  12 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c 
b/src/gallium/drivers/i915/i915_resource_buffer.c
index 77c0345..c54e481 100644
--- a/src/gallium/drivers/i915/i915_resource_buffer.c
+++ b/src/gallium/drivers/i915/i915_resource_buffer.c
@@ -68,8 +68,13 @@ i915_get_transfer(struct pipe_context *pipe,
const struct pipe_box *box)
  {
 struct i915_context *i915 = i915_context(pipe);
-   struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
+   struct pipe_transfer *transfer;

+   if (usage&  PIPE_TRANSFER_MAP_PERMANENTLY) {
+  return NULL;
+   }
+
+   transfer = util_slab_alloc(&i915->transfer_pool);
 if (transfer == NULL)
return NULL;

diff --git a/src/gallium/drivers/i915/i915_resource_texture.c 
b/src/gallium/drivers/i915/i915_resource_texture.c
index 8ff733a..64d071c 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -720,9 +720,14 @@ i915_texture_get_transfer(struct pipe_context *pipe,
  {
 struct i915_context *i915 = i915_context(pipe);
 struct i915_texture *tex = i915_texture(resource);
-   struct i915_transfer *transfer = 
util_slab_alloc(&i915->texture_transfer_pool);
+   struct i915_transfer *transfer;
 boolean use_staging_texture = FALSE;

+   if (usage&  PIPE_TRANSFER_MAP_PERMANENTLY) {
+  return NULL;
+   }
+
+   transfer = util_slab_alloc(&i915->texture_transfer_pool);
 if (transfer == NULL)
return NULL;

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index ca38571..d86d493 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -587,6 +587,10 @@ llvmpipe_get_transfer(struct pipe_context *pipe,
 assert(resource);
 assert(level<= resource->last_level);

+   if (usage&  PIPE_TRANSFER_MAP_PERMANENTLY) {
+  return NULL;
+   }
+
 /*
  * Transfers, like other pipe operations, must happen in order, so flush 
the
  * context if necessary.
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c 
b/src/gallium/drivers/nouveau/nouveau_buffer.c
index f822625..02186ba 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -172,7 +172,13 @@ nouveau_buffer_transfer_get(struct pipe_context *pipe,
  {
 struct nv04_resource *buf = nv04_resource(resource);
 struct nouveau_context *nv = nouveau_context(pipe);
-   struct nouveau_transfer *xfr = CALLOC_STRUCT(nouveau_transfer);
+   struct nouveau_transfer *xfr;
+
+   if (usage&  PIPE_TRANSFER_MAP_PERMANENTLY) {
+  return NULL;
+   }
+
+   xfr = CALLOC_STRUCT(nouveau_transfer);
 if (!xfr)
return NULL;

diff --git a/src/gallium/drivers/nv50/nv50_transfer.c 
b/src/gallium/drivers/nv50/nv50_transfer.c
index 6f860e7..8ddebeb 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -243,7 +243,7 @@ nv50_miptree_transfer_new(struct pipe_context *pctx,
 uint32_t size;
 int ret;

-   if (usage&  PIPE_TRANSFER_MAP_DIRECTLY)
+   if (usage&  (PIPE_TRANSFER_MAP_DIRECTLY | PIPE_TRANSFER_MAP_PERMANENTLY))
return NULL;

 tx = CALLOC_STRUCT(nv50_transfer);
diff --git a/src/gallium/drivers/nvc0/nvc0_transfer.c 
b/src/gallium/drivers/nvc0/nvc0_transfer.c
index f168637..c04f41f 100644
--- a/src/gallium/drivers/nvc0/nvc0_transfer.c
+++ b/src/gallium/drivers/nvc0/nvc0_transfer.c
@@ -243,7 +243,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
 uint32_t size;
 int ret;

-   if (usage&  PIPE_TRANSFER_MAP_DIRECTLY)
+   if (usage&  (PIPE_TRANSFER_MAP_DIRECTLY | PIPE_TRANSFER_MAP_PERMANENTLY))

Re: [Mesa-dev] [PATCH 3/3] vl: replace decode_buffers with auxiliary data field

2012-01-02 Thread Christian König

Hi Maarten,

first of all: Happy new Year and sorry for the late reply, have been on 
vacation for the last week.


On 29.12.2011 16:41, Maarten Lankhorst wrote:

Hey Christian,

Op 26-12-11 14:00, Christian König schreef:

Based on patches from Maarten Lankhorst

Signed-off-by: Christian König

diff --git a/src/gallium/include/pipe/p_context.h 
b/src/gallium/include/pipe/p_context.h
index de79a9b..f7ee522 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -410,7 +410,8 @@ struct pipe_context {
 enum 
pipe_video_profile profile,
 enum 
pipe_video_entrypoint entrypoint,
 enum 
pipe_video_chroma_format chroma_format,
-   unsigned width, 
unsigned height, unsigned max_references );
+   unsigned width, 
unsigned height, unsigned max_references,
+   bool 
expect_chunked_decode);


I really don't like this part, isn't it implied from entrypoint>= 
PIPE_VIDEO_ENTRYPOINT_IDCT?
Not necessarily, I'm still trying to give this interface a more general 
look and feel.


So for the current use case it can be deduced from the fact that XvMC 
only supports entry-points IDCT and MC, while VDPAU only supports 
bitstream, but that doesn't necessary have to be always the case.


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


[Mesa-dev] [PATCH 1/3] u_format: implement fetch_rgba_uint and fetch_rgba_sint for integer formats

2012-01-02 Thread Marek Olšák
Fetching int as float and vice versa is not allowed.
Fetching unsigned int as signed int and vice versa is not allowed either.
Doing conversions like that isn't allowed in OpenGL.

The three hooks could be consolidated into one fetch hook, which would fetch
uint as uint32, sint as sint32, and everything else as float. The receiving
parameter would be void*. This would be useful for implementing vertex fetches
for shader model 4.0, which has untyped registers.
---
 src/gallium/auxiliary/util/u_format.h|   22 +-
 src/gallium/auxiliary/util/u_format_pack.py  |2 ++
 src/gallium/auxiliary/util/u_format_table.py |   12 +---
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format.h 
b/src/gallium/auxiliary/util/u_format.h
index 9694c90..874ea7e 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -254,7 +254,7 @@ struct util_format_description
/**
 * Fetch a single pixel (i, j) from a block.
 *
-* Only defined for non-depth-stencil formats.
+* Only defined for non-depth-stencil and non-integer formats.
 */
void
(*fetch_rgba_float)(float *dst,
@@ -358,6 +358,26 @@ struct util_format_description
(*pack_rgba_sint)(uint8_t *dst, unsigned dst_stride,
  const int *src, unsigned src_stride,
  unsigned width, unsigned height);
+
+   /**
+* Fetch a single pixel (i, j) from a block.
+*
+* Only defined for unsigned (pure) integer formats.
+*/
+   void
+   (*fetch_rgba_uint)(uint32_t *dst,
+  const uint8_t *src,
+  unsigned i, unsigned j);
+
+   /**
+* Fetch a single pixel (i, j) from a block.
+*
+* Only defined for signed (pure) integer formats.
+*/
+   void
+   (*fetch_rgba_sint)(int32_t *dst,
+  const uint8_t *src,
+  unsigned i, unsigned j);
 };
 
 
diff --git a/src/gallium/auxiliary/util/u_format_pack.py 
b/src/gallium/auxiliary/util/u_format_pack.py
index fff409f..0b3a890 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -686,6 +686,7 @@ def generate(formats):
 
 generate_format_unpack(format, channel, native_type, suffix)
 generate_format_pack(format, channel, native_type, suffix)
+generate_format_fetch(format, channel, native_type, suffix)
 
 channel = Channel(SIGNED, False, True, 32)
 native_type = 'int'
@@ -699,6 +700,7 @@ def generate(formats):
 
 generate_format_unpack(format, channel, native_type, suffix)
 generate_format_pack(format, channel, native_type, suffix)   
+generate_format_fetch(format, channel, native_type, suffix)
 
 native_type = 'unsigned'
 suffix = 'unsigned'
diff --git a/src/gallium/auxiliary/util/u_format_table.py 
b/src/gallium/auxiliary/util/u_format_table.py
index 07beb38..8edb505 100755
--- a/src/gallium/auxiliary/util/u_format_table.py
+++ b/src/gallium/auxiliary/util/u_format_table.py
@@ -169,17 +169,23 @@ def write_format_table(formats):
 print "   &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" 
% format.short_name() 
 print "   &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % 
format.short_name()
 print "   &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % 
format.short_name()
-print "   &util_format_%s_pack_signed  /* pack_rgba_sint */" % 
format.short_name()
+print "   &util_format_%s_pack_signed,  /* pack_rgba_sint */" % 
format.short_name()
+print "   &util_format_%s_fetch_unsigned,  /* fetch_rgba_uint */" 
% format.short_name()
+print "   NULL  /* fetch_rgba_sint */"
 elif format.colorspace != ZS and format.channels[0].pure == True and 
format.channels[0].type == SIGNED:
 print "   &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" 
% format.short_name()
 print "   &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % 
format.short_name()
 print "   &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % 
format.short_name()
-print "   &util_format_%s_pack_signed  /* pack_rgba_sint */" % 
format.short_name()
+print "   &util_format_%s_pack_signed,  /* pack_rgba_sint */" % 
format.short_name()
+print "   NULL,  /* fetch_rgba_uint */"
+print "   &util_format_%s_fetch_signed  /* fetch_rgba_sint */" % 
format.short_name()
 else:
 print "   NULL, /* unpack_rgba_uint */" 
 print "   NULL, /* pack_rgba_uint */" 
 print "   NULL, /* unpack_rgba_sint */" 
-print "   NULL  /* pack_rgba_sint */" 
+print "   NULL, /* pack_rgba_sint */"
+print "   NULL, /* fetch_rgba_uint */"
+

[Mesa-dev] [PATCH 2/3] translate: implement translation of (pure) integer formats

2012-01-02 Thread Marek Olšák
The conversion is limited to only a few cases, because converting to any other
type shouldn't happen in any driver.
---
 .../auxiliary/translate/translate_generic.c|  346 ++--
 1 files changed, 252 insertions(+), 94 deletions(-)

diff --git a/src/gallium/auxiliary/translate/translate_generic.c 
b/src/gallium/auxiliary/translate/translate_generic.c
index 516a1ef..9df4aff 100644
--- a/src/gallium/auxiliary/translate/translate_generic.c
+++ b/src/gallium/auxiliary/translate/translate_generic.c
@@ -40,10 +40,10 @@
 
 #define DRAW_DBG 0
 
-typedef void (*fetch_func)(float *dst,
+typedef void (*fetch_func)(void *dst,
const uint8_t *src,
unsigned i, unsigned j);
-typedef void (*emit_func)(const float *attrib, void *ptr);
+typedef void (*emit_func)(const void *attrib, void *ptr);
 
 
 
@@ -85,21 +85,22 @@ static struct translate_generic *translate_generic( struct 
translate *translate
 }
 
 /**
- * Fetch a float[4] vertex attribute from memory, doing format/type
+ * Fetch a dword[4] vertex attribute from memory, doing format/type
  * conversion as needed.
  *
  * This is probably needed/dupliocated elsewhere, eg format
  * conversion, texture sampling etc.
  */
-#define ATTRIB( NAME, SZ, TYPE, TO )   \
+#define ATTRIB( NAME, SZ, SRCTYPE, DSTTYPE, TO )\
 static void\
-emit_##NAME(const float *attrib, void *ptr)\
+emit_##NAME(const void *attrib, void *ptr) \
 {  \
unsigned i; \
-   TYPE *out = (TYPE *)ptr;\
+   SRCTYPE *in = (SRCTYPE *)attrib; \
+   DSTTYPE *out = (DSTTYPE *)ptr;  \
\
for (i = 0; i < SZ; i++) {  \
-  out[i] = TO(attrib[i]);  \
+  out[i] = TO(in[i]);  \
}   \
 }
 
@@ -126,104 +127,138 @@ emit_##NAME(const float *attrib, void *ptr) 
\
 
 #define TO_32_FIXED(x)   ((int) (x * 65536.0f))
 
-
-ATTRIB( R64G64B64A64_FLOAT,   4, double, TO_64_FLOAT )
-ATTRIB( R64G64B64_FLOAT,  3, double, TO_64_FLOAT )
-ATTRIB( R64G64_FLOAT, 2, double, TO_64_FLOAT )
-ATTRIB( R64_FLOAT,1, double, TO_64_FLOAT )
-
-ATTRIB( R32G32B32A32_FLOAT,   4, float, TO_32_FLOAT )
-ATTRIB( R32G32B32_FLOAT,  3, float, TO_32_FLOAT )
-ATTRIB( R32G32_FLOAT, 2, float, TO_32_FLOAT )
-ATTRIB( R32_FLOAT,1, float, TO_32_FLOAT )
-
-ATTRIB( R16G16B16A16_FLOAT,   4, ushort, TO_16_FLOAT )
-ATTRIB( R16G16B16_FLOAT,  3, ushort, TO_16_FLOAT )
-ATTRIB( R16G16_FLOAT, 2, ushort, TO_16_FLOAT )
-ATTRIB( R16_FLOAT,1, ushort, TO_16_FLOAT )
-
-ATTRIB( R32G32B32A32_USCALED, 4, unsigned, TO_32_USCALED )
-ATTRIB( R32G32B32_USCALED,3, unsigned, TO_32_USCALED )
-ATTRIB( R32G32_USCALED,   2, unsigned, TO_32_USCALED )
-ATTRIB( R32_USCALED,  1, unsigned, TO_32_USCALED )
-
-ATTRIB( R32G32B32A32_SSCALED, 4, int, TO_32_SSCALED )
-ATTRIB( R32G32B32_SSCALED,3, int, TO_32_SSCALED )
-ATTRIB( R32G32_SSCALED,   2, int, TO_32_SSCALED )
-ATTRIB( R32_SSCALED,  1, int, TO_32_SSCALED )
-
-ATTRIB( R32G32B32A32_UNORM, 4, unsigned, TO_32_UNORM )
-ATTRIB( R32G32B32_UNORM,3, unsigned, TO_32_UNORM )
-ATTRIB( R32G32_UNORM,   2, unsigned, TO_32_UNORM )
-ATTRIB( R32_UNORM,  1, unsigned, TO_32_UNORM )
-
-ATTRIB( R32G32B32A32_SNORM, 4, int, TO_32_SNORM )
-ATTRIB( R32G32B32_SNORM,3, int, TO_32_SNORM )
-ATTRIB( R32G32_SNORM,   2, int, TO_32_SNORM )
-ATTRIB( R32_SNORM,  1, int, TO_32_SNORM )
-
-ATTRIB( R16G16B16A16_USCALED, 4, ushort, TO_16_USCALED )
-ATTRIB( R16G16B16_USCALED,3, ushort, TO_16_USCALED )
-ATTRIB( R16G16_USCALED,   2, ushort, TO_16_USCALED )
-ATTRIB( R16_USCALED,  1, ushort, TO_16_USCALED )
-
-ATTRIB( R16G16B16A16_SSCALED, 4, short, TO_16_SSCALED )
-ATTRIB( R16G16B16_SSCALED,3, short, TO_16_SSCALED )
-ATTRIB( R16G16_SSCALED,   2, short, TO_16_SSCALED )
-ATTRIB( R16_SSCALED,  1, short, TO_16_SSCALED )
-
-ATTRIB( R16G16B16A16_UNORM, 4, ushort, TO_16_UNORM )
-ATTRIB( R16G16B16_UNORM,3, ushort, TO_16_UNORM )
-ATTRIB( R16G16_UNORM,   2, ushort, TO_16_UNORM )
-ATTRIB( R16_UNORM,  1, ushort, TO_16_UNORM )
-
-ATTRIB( R16G16B16A16_SNORM, 4, short, TO_16_SNORM )
-ATTRIB( R16G16B16_SNORM,3, short, TO_16_SNORM )
-ATTRIB( R16G16_SNORM,   2, short, TO_16_SNORM )
-ATTRIB( R16_SNORM,  1, short, TO_16_SNORM )
-
-ATTRIB( R8G8B8A8_USCALED,   4, ubyte, TO_8_USCALED )
-ATTRIB( R8G8B8_USCALED, 3, ubyte, TO_8_USCALED )
-ATTRIB( R8G8_USCALED,   2, ubyte, TO_8_USCALED )
-ATTRIB( R8_USCALED, 1, ubyte, TO_8_USCALED )
-
-ATTRIB( R8G8B8A8_SSCALED,  4, char, TO_8_SSCALED )
-ATTRIB( R8G8B8_SSCALED,3, char, TO_8_SSCALE

[Mesa-dev] [PATCH 3/3] translate: implement translation of 10_10_10_2 types

2012-01-02 Thread Marek Olšák
This is for GL_ARB_vertex_type_2_10_10_10_rev.
I just took the code from u_format_table.c. It's based on pack_rgba_float.
I had no other choice. The u_format hooks are not exactly compatible
with translate. The cleanup of it is left for future work.
---
 .../auxiliary/translate/translate_generic.c|  148 
 1 files changed, 148 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/translate/translate_generic.c 
b/src/gallium/auxiliary/translate/translate_generic.c
index 9df4aff..0b6ebf5 100644
--- a/src/gallium/auxiliary/translate/translate_generic.c
+++ b/src/gallium/auxiliary/translate/translate_generic.c
@@ -257,6 +257,126 @@ emit_B8G8R8A8_UNORM( const void *attrib, void *ptr)
out[3] = TO_8_UNORM(in[3]);
 }
 
+static void
+emit_B10G10R10A2_UNORM( const void *attrib, void *ptr )
+{
+   float *src = (float *)ptr;
+   uint32_t value = 0;
+   value |= ((uint32_t)(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff;
+   value |= (((uint32_t)(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10;
+   value |= (((uint32_t)(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff) << 20;
+   value |= ((uint32_t)(CLAMP(src[3], 0, 1) * 0x3)) << 30;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+   value = util_bswap32(value);
+#endif
+   *(uint32_t *)attrib = value;
+}
+
+static void
+emit_B10G10R10A2_USCALED( const void *attrib, void *ptr )
+{
+   float *src = (float *)ptr;
+   uint32_t value = 0;
+   value |= ((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff;
+   value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10;
+   value |= (((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff) << 20;
+   value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+   value = util_bswap32(value);
+#endif
+   *(uint32_t *)attrib = value;
+}
+
+static void
+emit_B10G10R10A2_SNORM( const void *attrib, void *ptr )
+{
+   float *src = (float *)ptr;
+   uint32_t value = 0;
+   value |= (uint32_t)(((uint32_t)(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) ;
+   value |= (uint32_t)uint32_t)(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 
10) ;
+   value |= (uint32_t)uint32_t)(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) << 
20) ;
+   value |= (uint32_t)(((uint32_t)(CLAMP(src[3], -1, 1) * 0x1)) << 30) ;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+   value = util_bswap32(value);
+#endif
+   *(uint32_t *)attrib = value;
+}
+
+static void
+emit_B10G10R10A2_SSCALED( const void *attrib, void *ptr )
+{
+   float *src = (float *)ptr;
+   uint32_t value = 0;
+   value |= (uint32_t)(((uint32_t)CLAMP(src[2], -512, 511)) & 0x3ff) ;
+   value |= (uint32_t)uint32_t)CLAMP(src[1], -512, 511)) & 0x3ff) << 10) ;
+   value |= (uint32_t)uint32_t)CLAMP(src[0], -512, 511)) & 0x3ff) << 20) ;
+   value |= (uint32_t)(((uint32_t)CLAMP(src[3], -2, 1)) << 30) ;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+   value = util_bswap32(value);
+#endif
+   *(uint32_t *)attrib = value;
+}
+
+static void
+emit_R10G10B10A2_UNORM( const void *attrib, void *ptr )
+{
+   float *src = (float *)ptr;
+   uint32_t value = 0;
+   value |= ((uint32_t)(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff;
+   value |= (((uint32_t)(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10;
+   value |= (((uint32_t)(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff) << 20;
+   value |= ((uint32_t)(CLAMP(src[3], 0, 1) * 0x3)) << 30;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+   value = util_bswap32(value);
+#endif
+   *(uint32_t *)attrib = value;
+}
+
+static void
+emit_R10G10B10A2_USCALED( const void *attrib, void *ptr )
+{
+   float *src = (float *)ptr;
+   uint32_t value = 0;
+   value |= ((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff;
+   value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10;
+   value |= (((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff) << 20;
+   value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+   value = util_bswap32(value);
+#endif
+   *(uint32_t *)attrib = value;
+}
+
+static void
+emit_R10G10B10A2_SNORM( const void *attrib, void *ptr )
+{
+   float *src = (float *)ptr;
+   uint32_t value = 0;
+   value |= (uint32_t)(((uint32_t)(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) ;
+   value |= (uint32_t)uint32_t)(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 
10) ;
+   value |= (uint32_t)uint32_t)(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 
20) ;
+   value |= (uint32_t)(((uint32_t)(CLAMP(src[3], -1, 1) * 0x1)) << 30) ;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+   value = util_bswap32(value);
+#endif
+   *(uint32_t *)attrib = value;
+}
+
+static void
+emit_R10G10B10A2_SSCALED( const void *attrib, void *ptr)
+{
+   float *src = (float *)ptr;
+   uint32_t value = 0;
+   value |= (uint32_t)(((uint32_t)CLAMP(src[0], -512, 511)) & 0x3ff) ;
+   value |= (uint32_t)uint32_t)CLAMP(src[1], -512, 511)) & 0x3ff) << 10) ;
+   value |= (uint32_t)uint32_t)CLAMP(src[2], -512, 511)) & 0x3ff) << 20) ;
+   value |= (uint32_t)(((uint32_t)CLAMP(src[3], -2, 1)) << 30) ;
+#ifdef PIPE_ARCH_BIG_ENDIAN
+   value = util_bswap32(value);
+#endif
+   *(uint32_t *)attrib = value;
+}
+
 static void 
 emit_NULL( const void *attrib, void *ptr )
 {
@@ -461,6 +581,24

Re: [Mesa-dev] [PATCH 1/3] u_format: implement fetch_rgba_uint and fetch_rgba_sint for integer formats

2012-01-02 Thread Dave Airlie
On Mon, Jan 2, 2012 at 1:07 PM, Marek Olšák  wrote:
> Fetching int as float and vice versa is not allowed.
> Fetching unsigned int as signed int and vice versa is not allowed either.

The first is true, the second isn't, otherwise I'd have implemented
this that way.

> Doing conversions like that isn't allowed in OpenGL.

I don't have chapter/verse but EXT_texture_integer doesn't seem to
disallow this.

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


[Mesa-dev] State of xcb-glx integration

2012-01-02 Thread Ingo Krabbe
Hey,

in the last two weeks I did some experiments with xcb, glx and mesa
gallium drivers (nouveau).

Is there any work group that takes care for this part of mesa. There
still seem to be some very basic problems using that configuration.

cheers, ingo

-- 
i don't do signatures
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl_to_tgsi: v2 Invalidate and revalidate uniform backing storage

2012-01-02 Thread Alex Deucher
On Thu, Dec 22, 2011 at 9:35 AM, Vadim Girlin  wrote:
> If glUniform1i and friends are going to dump data directly in
> driver-allocated, the pointers have to be updated when the storage
> moves.  This should fix the regressions seen with commit 7199096.
>
> I'm not sure if this is the only place that needs this treatment.  I'm
> a little uncertain about the various functions in st_glsl_to_tgsi that
> modify the TGSI IR and try to propagate changes about that up to the
> gl_program.  That seems sketchy to me.
>
> Signed-off-by: Ian Romanick 
>
> v2:
>
> Revalidate when shader_program is not NULL.
> Update the pointers for all _LinkedShaders.
> Init glsl_to_tgsi_visitor::shader_program to NULL in the
> get_pixel_transfer_visitor & get_bitmap_visitor.
>
> Signed-off-by: Vadim Girlin 
> ---
>
> Based on the patch from Ian Romanick:
> http://lists.freedesktop.org/archives/mesa-dev/2011-November/014675.html
>
> Fixes uniform regressions with r600g (and probably other drivers)
> after commit 719909698c67c287a393d2380278e7b7495ae018


Are there any objections to pushing this patch?

Alex

>
> Tested on evergreen with r600.tests: no regressions.
>
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   25 +
>  1 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 77aa0d1..fce92bb 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -3708,6 +3708,7 @@ get_pixel_transfer_visitor(struct st_fragment_program 
> *fp,
>    /* Copy attributes of the glsl_to_tgsi_visitor in the original shader. */
>    v->ctx = original->ctx;
>    v->prog = prog;
> +   v->shader_program = NULL;
>    v->glsl_version = original->glsl_version;
>    v->native_integers = original->native_integers;
>    v->options = original->options;
> @@ -3837,6 +3838,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
>    /* Copy attributes of the glsl_to_tgsi_visitor in the original shader. */
>    v->ctx = original->ctx;
>    v->prog = prog;
> +   v->shader_program = NULL;
>    v->glsl_version = original->glsl_version;
>    v->native_integers = original->native_integers;
>    v->options = original->options;
> @@ -4550,6 +4552,15 @@ st_translate_program(
>    t->pointSizeOutIndex = -1;
>    t->prevInstWrotePointSize = GL_FALSE;
>
> +   if (program->shader_program) {
> +      for (i = 0; i < program->shader_program->NumUserUniformStorage; i++) {
> +         struct gl_uniform_storage *const storage =
> +               &program->shader_program->UniformStorage[i];
> +
> +         _mesa_uniform_detach_all_driver_storage(storage);
> +      }
> +   }
> +
>    /*
>     * Declare input attributes.
>     */
> @@ -4776,6 +4787,20 @@ st_translate_program(
>                        t->insn[t->labels[i].branch_target]);
>    }
>
> +   if (program->shader_program) {
> +      /* This has to be done last.  Any operation the can cause
> +       * prog->ParameterValues to get reallocated (e.g., anything that adds a
> +       * program constant) has to happen before creating this linkage.
> +       */
> +      for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
> +         if (program->shader_program->_LinkedShaders[i] == NULL)
> +            continue;
> +
> +         _mesa_associate_uniform_storage(ctx, program->shader_program,
> +               
> program->shader_program->_LinkedShaders[i]->Program->Parameters);
> +      }
> +   }
> +
>  out:
>    if (t) {
>       FREE(t->insn);
> --
> 1.7.7.4
>
> ___
> 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] [RFC PATCH] mesa/gl3: introduce a new option to the gl3 version enable.

2012-01-02 Thread Dave Airlie
From: Dave Airlie 

EXT_texture_integer isn't strictly equivalent to GL3, the L/I/A integer
formats are not required in GL3, and some drivers may not require them.

I've no idea if we have any hw that requires it, just sending the patch along
after discussion on irc.

Signed-off-by: Dave Airlie 
---
 src/mesa/main/mtypes.h  |2 ++
 src/mesa/main/version.c |2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 107371e..6191026 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2832,6 +2832,8 @@ struct gl_constants
 */
GLboolean GLSLSkipStrictMaxVaryingLimitCheck;
GLboolean GLSLSkipStrictMaxUniformLimitCheck;
+
+   GLboolean GL3TextureInteger; /* does the driver support GL3 TextureInteger 
support as opposed to the full EXT_texture_integer */
 };
 
 
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 49cdc30..3b548e5 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -142,7 +142,7 @@ compute_version(struct gl_context *ctx)
   ctx->Extensions.EXT_packed_depth_stencil &&
   ctx->Extensions.EXT_packed_float &&
   ctx->Extensions.EXT_texture_array &&
-  ctx->Extensions.EXT_texture_integer &&
+  (ctx->Const.GL3TextureInteger || 
ctx->Extensions.EXT_texture_integer) &&
   ctx->Extensions.EXT_texture_shared_exponent &&
   ctx->Extensions.EXT_transform_feedback &&
   ctx->Extensions.NV_conditional_render);
-- 
1.7.7.4

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


Re: [Mesa-dev] [RFC PATCH] mesa/gl3: introduce a new option to the gl3 version enable.

2012-01-02 Thread Dave Airlie
>
> EXT_texture_integer isn't strictly equivalent to GL3, the L/I/A integer
> formats are not required in GL3, and some drivers may not require them.
>
> I've no idea if we have any hw that requires it, just sending the patch along
> after discussion on irc.

Another reason was mentioned on irc, EXT_texture_integer claims to
require EXT_gpu_shader4 in its specification, so I'm not sure we
should be exposing it without EXT_gpu_shader4 even in the presence of
GL3.

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


Re: [Mesa-dev] [PATCH 1/3] u_format: implement fetch_rgba_uint and fetch_rgba_sint for integer formats

2012-01-02 Thread Marek Olšák
On Mon, Jan 2, 2012 at 3:31 PM, Dave Airlie  wrote:
> On Mon, Jan 2, 2012 at 1:07 PM, Marek Olšák  wrote:
>> Fetching int as float and vice versa is not allowed.
>> Fetching unsigned int as signed int and vice versa is not allowed either.
>
> The first is true, the second isn't, otherwise I'd have implemented
> this that way.
>
>> Doing conversions like that isn't allowed in OpenGL.
>
> I don't have chapter/verse but EXT_texture_integer doesn't seem to
> disallow this.

EXT_texture_integer doesn't, but that extension doesn't define the new
GLSL samplers, it only requires EXT_gpu_shader4.

See this part from EXT_gpu_shader4 (modifications to section 8.7 of
the GLSL spec):

Table 8.xxx lists the supported combinations of sampler types and
texture internal formats.

  texture
  internal  default (float) integer unsigned integer
  formatsampler sampler sampler
  float vec4n/a  n/a
  normalizedvec4n/a  n/a
  signed intn/a ivec4n/a
  unsigned int  n/a n/a  uvec4

That is, no conversions are allowed. The pack/unpack stuff is
different, because it doesn't involve shaders. I have no opinion on
whether we should be that strict in u_format or not. Being strict may
later prevent making programming mistakes though.

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


Re: [Mesa-dev] [PATCH 1/3] u_format: implement fetch_rgba_uint and fetch_rgba_sint for integer formats

2012-01-02 Thread Dave Airlie
On Mon, Jan 2, 2012 at 4:40 PM, Marek Olšák  wrote:
> On Mon, Jan 2, 2012 at 3:31 PM, Dave Airlie  wrote:
>> On Mon, Jan 2, 2012 at 1:07 PM, Marek Olšák  wrote:
>>> Fetching int as float and vice versa is not allowed.
>>> Fetching unsigned int as signed int and vice versa is not allowed either.
>>
>> The first is true, the second isn't, otherwise I'd have implemented
>> this that way.
>>
>>> Doing conversions like that isn't allowed in OpenGL.
>>
>> I don't have chapter/verse but EXT_texture_integer doesn't seem to
>> disallow this.
>
> EXT_texture_integer doesn't, but that extension doesn't define the new
> GLSL samplers, it only requires EXT_gpu_shader4.
>
> See this part from EXT_gpu_shader4 (modifications to section 8.7 of
> the GLSL spec):
>
> Table 8.xxx lists the supported combinations of sampler types and
> texture internal formats.
>
>      texture
>      internal      default (float) integer     unsigned integer
>      format        sampler         sampler     sampler
>      float         vec4            n/a          n/a
>      normalized    vec4            n/a          n/a
>      signed int    n/a             ivec4        n/a
>      unsigned int  n/a             n/a          uvec4
>
> That is, no conversions are allowed. The pack/unpack stuff is
> different, because it doesn't involve shaders. I have no opinion on
> whether we should be that strict in u_format or not. Being strict may
> later prevent making programming mistakes though.

Did you mean samplers instead of shaders in that sentence? if so I
probably agree that its fine then.

Also I'd agree with starting simple and only enabling the conversions
if something comes up later, so with that,

Reviewed-by: Dave Airlie 

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


Re: [Mesa-dev] [RFC PATCH] mesa/gl3: introduce a new option to the gl3 version enable.

2012-01-02 Thread Marek Olšák
I agree that we shouldn't be exposing EXT_texture_integer.

I think it would be cleaner to just say that if GLSL 1.3 is supported,
all the other features which are part of it are supported too. I would
simplify the code like this (see below), and most of the checks for
EXT_texture_integer should also check for the exposed GL version.

diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 49cdc30..7826f82 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -127,6 +127,7 @@ compute_version(struct gl_context *ctx)
   ctx->Const.GLSLVersion >= 130 &&
   ctx->Extensions.ARB_color_buffer_float &&
   ctx->Extensions.ARB_depth_buffer_float &&
+  ctx->Extensions.ARB_framebuffer_object &&
   ctx->Extensions.ARB_half_float_pixel &&
   ctx->Extensions.ARB_half_float_vertex &&
   ctx->Extensions.ARB_map_buffer_range &&
@@ -135,14 +136,10 @@ compute_version(struct gl_context *ctx)
   ctx->Extensions.ARB_texture_compression_rgtc &&
   ctx->Extensions.APPLE_vertex_array_object &&
   ctx->Extensions.EXT_draw_buffers2 &&
-  ctx->Extensions.EXT_framebuffer_blit &&
-  ctx->Extensions.EXT_framebuffer_multisample &&
-  ctx->Extensions.EXT_framebuffer_object &&
   ctx->Extensions.EXT_framebuffer_sRGB &&
-  ctx->Extensions.EXT_packed_depth_stencil &&
   ctx->Extensions.EXT_packed_float &&
-  ctx->Extensions.EXT_texture_array &&
-  ctx->Extensions.EXT_texture_integer &&
+  /* implied by GLSLVersion >= 130: */
+  /*ctx->Extensions.EXT_texture_array &&*/
   ctx->Extensions.EXT_texture_shared_exponent &&
   ctx->Extensions.EXT_transform_feedback &&
   ctx->Extensions.NV_conditional_render);

Marek

On Mon, Jan 2, 2012 at 5:38 PM, Dave Airlie  wrote:
>>
>> EXT_texture_integer isn't strictly equivalent to GL3, the L/I/A integer
>> formats are not required in GL3, and some drivers may not require them.
>>
>> I've no idea if we have any hw that requires it, just sending the patch along
>> after discussion on irc.
>
> Another reason was mentioned on irc, EXT_texture_integer claims to
> require EXT_gpu_shader4 in its specification, so I'm not sure we
> should be exposing it without EXT_gpu_shader4 even in the presence of
> GL3.
>
> Dave.
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] u_format: implement fetch_rgba_uint and fetch_rgba_sint for integer formats

2012-01-02 Thread Marek Olšák
On Mon, Jan 2, 2012 at 5:56 PM, Dave Airlie  wrote:
> On Mon, Jan 2, 2012 at 4:40 PM, Marek Olšák  wrote:
>> On Mon, Jan 2, 2012 at 3:31 PM, Dave Airlie  wrote:
>>> On Mon, Jan 2, 2012 at 1:07 PM, Marek Olšák  wrote:
 Fetching int as float and vice versa is not allowed.
 Fetching unsigned int as signed int and vice versa is not allowed either.
>>>
>>> The first is true, the second isn't, otherwise I'd have implemented
>>> this that way.
>>>
 Doing conversions like that isn't allowed in OpenGL.
>>>
>>> I don't have chapter/verse but EXT_texture_integer doesn't seem to
>>> disallow this.
>>
>> EXT_texture_integer doesn't, but that extension doesn't define the new
>> GLSL samplers, it only requires EXT_gpu_shader4.
>>
>> See this part from EXT_gpu_shader4 (modifications to section 8.7 of
>> the GLSL spec):
>>
>> Table 8.xxx lists the supported combinations of sampler types and
>> texture internal formats.
>>
>>      texture
>>      internal      default (float) integer     unsigned integer
>>      format        sampler         sampler     sampler
>>      float         vec4            n/a          n/a
>>      normalized    vec4            n/a          n/a
>>      signed int    n/a             ivec4        n/a
>>      unsigned int  n/a             n/a          uvec4
>>
>> That is, no conversions are allowed. The pack/unpack stuff is
>> different, because it doesn't involve shaders. I have no opinion on
>> whether we should be that strict in u_format or not. Being strict may
>> later prevent making programming mistakes though.
>
> Did you mean samplers instead of shaders in that sentence? if so I
> probably agree that its fine then.

I am not sure right now what the restrictions on vertex attribs are,
so yes, I meant samplers.

Marek

>
> Also I'd agree with starting simple and only enabling the conversions
> if something comes up later, so with that,
>
> Reviewed-by: Dave Airlie 
>
> Dave.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] draw: fix piglit base vertex + user vertex array tests

2012-01-02 Thread Dave Airlie
From: Dave Airlie 

This fixes
draw-elements-base-vertex user_varrays
draw-elements-instanced-base-vertex user_varrays
for softpipe with no llvm support (DRAW_USE_LLVM=false)

I'm not sure if this is the correct answer, but these tests were showing
a max_index of 7, then trying to fetch up to 43, maybe it should be fixing
max_index earlier somewhere to take care of this.

Signed-off-by: Dave Airlie 
---
 src/gallium/auxiliary/draw/draw_pt_fetch.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c 
b/src/gallium/auxiliary/draw/draw_pt_fetch.c
index 5589a82..81c7ec7 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c
@@ -166,7 +166,7 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch,
((char *)draw->pt.user.vbuffer[i] +
 draw->pt.vertex_buffer[i].buffer_offset),
draw->pt.vertex_buffer[i].stride,
-   draw->pt.user.max_index);
+   draw->pt.user.max_index + draw->pt.user.eltBias);
}
 
translate->run( translate,
-- 
1.7.7.4

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


Re: [Mesa-dev] softpipe and tgsi_exec.c FAST_MATH

2012-01-02 Thread Brian Paul

On 12/31/2011 09:46 AM, Dave Airlie wrote:

Hi,

So in the interest of correctness>  perf wrt softpipe, flicking
tgsi_exec.c FAST_MATH to 0 fixes 15 piglit tests with 0 regressions,

I could probably be persuaded to make a SOFTPIPE_FAST_MATH run time
set to 0 by default, anyone care one way or another?


I'm OK with turning off FAST_MATH.

-Brian

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


[Mesa-dev] glsl lowering pass

2012-01-02 Thread Vincent Lejeune
Hi,

thank for your review, your tips about ralloc, and your fixed patches. 
I spotted a tab indent instead of a 3 whitespace indent in 
lower_output_read.cpp. Other than that, your patch is fine for me.
I don't know how many reviews are needed before a patch is merged so I'm 
sending your patches to the ML.

Regards, Vincent

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


[Mesa-dev] [PATCH 1/2] glsl: Add a lowering pass to remove reads of shader output variables.

2012-01-02 Thread Vincent Lejeune
This is similar to Gallium's existing glsl_to_tgsi::remove_output_read
lowering pass, but done entirely inside the GLSL compiler.

Signed-off-by: Vincent Lejeune 
Signed-off-by: Kenneth Graunke 

v2 [Kayden]:
 - Don't reallocate the array for every shader output.
 - Move the class into the .cpp file and create a lower_output_reads() wrapper
 - Simplify the logic in visit(ir_deference_variable *)
 - Fold add_replacement_pair into the only caller.
 - Use visit_leave(ir_return *) instead of enter (for paranoia, in case the
   return value references shader outputs)
 - Visit signatures rather than functions, to avoid pattern matching to find
   the actual void main() signature.
 - Add some comments
 - Whitespace fixes

v3 [Vincent]:
 - Fix tab indent
---
 src/glsl/Makefile.sources   |1 +
 src/glsl/ir_optimization.h  |1 +
 src/glsl/lower_output_reads.cpp |  152 +++
 3 files changed, 154 insertions(+), 0 deletions(-)
 create mode 100644 src/glsl/lower_output_reads.cpp

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index c65bfe4..5e80af2 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -60,6 +60,7 @@ LIBGLSL_CXX_SOURCES := \
lower_vec_index_to_cond_assign.cpp \
lower_vec_index_to_swizzle.cpp \
lower_vector.cpp \
+   lower_output_reads.cpp \
opt_algebraic.cpp \
opt_constant_folding.cpp \
opt_constant_propagation.cpp \
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index 7b32e84..085b969 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -72,6 +72,7 @@ bool lower_variable_index_to_cond_assign(exec_list 
*instructions,
 bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
 bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
 bool lower_clip_distance(exec_list *instructions);
+void lower_output_reads(exec_list *instructions);
 bool optimize_redundant_jumps(exec_list *instructions);
 
 ir_rvalue *
diff --git a/src/glsl/lower_output_reads.cpp b/src/glsl/lower_output_reads.cpp
new file mode 100644
index 000..4b3f91c
--- /dev/null
+++ b/src/glsl/lower_output_reads.cpp
@@ -0,0 +1,152 @@
+/*
+ * Copyright © 2012 Vincent Lejeune
+ * Copyright © 2012 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.
+ */
+
+#include "ir.h"
+#include "program/hash_table.h"
+
+/**
+ * \file lower_output_reads.cpp
+ *
+ * In GLSL, shader output variables (such as varyings) can be both read and
+ * written.  However, on some hardware, reading an output register causes
+ * trouble.
+ *
+ * This pass creates temporary shadow copies of every (used) shader output,
+ * and replaces all accesses to use those instead.  It also adds code to the
+ * main() function to copy the final values to the actual shader outputs.
+ */
+
+class output_read_remover : public ir_hierarchical_visitor {
+protected:
+   struct replacement_pair {
+  ir_variable *output;
+  ir_variable *temp;
+   };
+
+   /**
+* A hash table mapping from the original ir_variable shader outputs
+* (ir_var_out mode) to the new temporaries to be used instead.
+*/
+   hash_table *replacements;
+
+   /**
+* An array of tuples containing both the output and temporary variables.
+* This is necessary because we can't iterate over the hash table.
+*/
+   struct replacement_pair *replacements_array;
+   unsigned replacements_count;
+   unsigned replacements_array_size;
+
+   void *mem_ctx;
+public:
+   output_read_remover();
+   ~output_read_remover();
+   virtual ir_visitor_status visit(class ir_dereference_variable *);
+   virtual ir_visitor_status visit_leave(class ir_return *);
+   virtual ir_visitor_status visit_leave(class ir_function_signature *);
+};
+
+output_read_remover::output_read_remover()
+{
+   mem_ctx = ralloc_context(NULL);
+
+   rep

[Mesa-dev] [PATCH 2/2] glsl_to_tgsi: Use the GLSL compiler's new remove-output-reads pass.

2012-01-02 Thread Vincent Lejeune
The existing glsl_to_tgsi::remove_output_read pass did not work properly
when indirect addressing was involved; this commit replaces it with a
lowering pass that occurs before TGSI code generation.

Fixes varying-array related piglit tests.

Signed-off-by: Vincent Lejeune 
Signed-off-by: Kenneth Graunke 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   15 +++
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 600f783..91a1ef2 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5123,6 +5123,13 @@ get_mesa_program(struct gl_context *ctx,
_mesa_generate_parameters_list_for_uniforms(shader_program, shader,
   prog->Parameters);
 
+   if (!screen->get_shader_param(screen, pipe_shader_type,
+ PIPE_SHADER_CAP_OUTPUT_READ)) {
+  /* Remove reads to output registers, and to varyings in vertex shaders. 
*/
+  lower_output_reads(shader->ir);
+   }
+
+
/* Emit intermediate IR for main(). */
visit_exec_list(shader->ir, v);
 
@@ -5169,14 +5176,6 @@ get_mesa_program(struct gl_context *ctx,
}
 #endif
 
-   if (!screen->get_shader_param(screen, pipe_shader_type,
- PIPE_SHADER_CAP_OUTPUT_READ)) {
-  /* Remove reads to output registers, and to varyings in vertex shaders. 
*/
-  v->remove_output_reads(PROGRAM_OUTPUT);
-  if (target == GL_VERTEX_PROGRAM_ARB)
- v->remove_output_reads(PROGRAM_VARYING);
-   }
-   
/* Perform optimizations on the instructions in the glsl_to_tgsi_visitor. */
v->simplify_cmp();
v->copy_propagate();
-- 
1.7.7

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


[Mesa-dev] [PATCH 1/4] i965/gen7: Use the updated interface for SO write pointer resetting.

2012-01-02 Thread Eric Anholt
The new kernel patch I submitted makes the interface opt-in, so all
batchbuffers aren't preceded by the 4 MI_LOAD_REGISTER_IMMs.
---
 src/mesa/drivers/dri/i965/gen7_sol_state.c |2 ++
 src/mesa/drivers/dri/intel/intel_batchbuffer.c |   13 +
 src/mesa/drivers/dri/intel/intel_context.h |1 +
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c 
b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 7346866..6cf68e2 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -231,6 +231,8 @@ upload_sol_state(struct brw_context *brw)
if (active) {
   upload_3dstate_so_buffers(brw);
   upload_3dstate_so_decl_list(brw, &vue_map);
+
+  intel->batch.needs_sol_reset = true;
}
 
/* Finally, set up the SOL stage.  This command must always follow updates 
to
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c 
b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index cb23dbc..90effd2 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -85,6 +85,7 @@ intel_batchbuffer_reset(struct intel_context *intel)
intel->batch.reserved_space = BATCH_RESERVED;
intel->batch.state_batch_offset = intel->batch.bo->size;
intel->batch.used = 0;
+   intel->batch.needs_sol_reset = false;
 }
 
 void
@@ -135,16 +136,20 @@ do_flush_locked(struct intel_context *intel)
}
 
if (!intel->intelScreen->no_hw) {
-  int ring;
+  int flags;
 
   if (intel->gen < 6 || !batch->is_blit) {
-ring = I915_EXEC_RENDER;
+flags = I915_EXEC_RENDER;
   } else {
-ring = I915_EXEC_BLT;
+flags = I915_EXEC_BLT;
   }
 
+  if (batch->needs_sol_reset)
+flags |= I915_EXEC_GEN7_SOL_RESET;
+
   if (ret == 0)
-ret = drm_intel_bo_mrb_exec(batch->bo, 4*batch->used, NULL, 0, 0, 
ring);
+ret = drm_intel_bo_mrb_exec(batch->bo, 4*batch->used, NULL, 0, 0,
+flags);
}
 
if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) {
diff --git a/src/mesa/drivers/dri/intel/intel_context.h 
b/src/mesa/drivers/dri/intel/intel_context.h
index 5fe8e24..9fb2902 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -233,6 +233,7 @@ struct intel_context
 
   uint32_t state_batch_offset;
   bool is_blit;
+  bool needs_sol_reset;
 
   struct {
 uint16_t used;
-- 
1.7.7.3

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


[Mesa-dev] [PATCH 3/4] i965/gen7: Fix up the transform feedback buffer pointers on later batches.

2012-01-02 Thread Eric Anholt
Fixes piglit EXT_transform_feedback/intervening-read
---
 src/mesa/drivers/dri/i965/brw_context.h|1 +
 src/mesa/drivers/dri/i965/brw_vtbl.c   |6 ++
 src/mesa/drivers/dri/i965/gen6_sol.c   |1 +
 src/mesa/drivers/dri/i965/gen7_sol_state.c |   13 ++---
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 873e172..9f9b113 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -988,6 +988,7 @@ struct brw_context
struct brw_sol_state {
   uint32_t svbi_0_starting_index;
   uint32_t svbi_0_max_index;
+  uint32_t offset_0_batch_start;
   uint32_t primitives_generated;
   uint32_t primitives_written;
} sol;
diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c 
b/src/mesa/drivers/dri/i965/brw_vtbl.c
index d348806..be975d1 100644
--- a/src/mesa/drivers/dri/i965/brw_vtbl.c
+++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
@@ -177,6 +177,12 @@ static void brw_new_batch( struct intel_context *intel )
 
brw->state_batch_count = 0;
 
+   /* Gen7 needs to track what the real transform feedback vertex count was at
+* the start of the batch, since the kernel will be resetting the offset to
+* 0.
+*/
+   brw->sol.offset_0_batch_start = brw->sol.svbi_0_starting_index;
+
brw->vb.nr_current_buffers = 0;
brw->ib.type = -1;
 
diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c 
b/src/mesa/drivers/dri/i965/gen6_sol.c
index f724802..41923b7 100644
--- a/src/mesa/drivers/dri/i965/gen6_sol.c
+++ b/src/mesa/drivers/dri/i965/gen6_sol.c
@@ -132,6 +132,7 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum 
mode,
brw->state.dirty.brw |= BRW_NEW_SOL_INDICES;
brw->sol.svbi_0_starting_index = 0;
brw->sol.svbi_0_max_index = max_index;
+   brw->sol.offset_0_batch_start = 0;
 }
 
 void
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c 
b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index ba9fb67..eb52930 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -56,6 +56,7 @@ upload_3dstate_so_buffers(struct brw_context *brw)
   struct gl_buffer_object *bufferobj = xfb_obj->Buffers[i];
   drm_intel_bo *bo;
   uint32_t start, end;
+  uint32_t stride;
 
   if (!xfb_obj->Buffers[i]) {
 /* The pitch of 0 in this command indicates that the buffer is
@@ -72,17 +73,23 @@ upload_3dstate_so_buffers(struct brw_context *brw)
   }
 
   bo = intel_buffer_object(bufferobj)->buffer;
+  stride = linked_xfb_info->BufferStride[i] * 4;
 
   start = xfb_obj->Offset[i];
   assert(start % 4 == 0);
   end = ALIGN(start + xfb_obj->Size[i], 4);
   assert(end <= bo->size);
 
+  /* Offset the starting offset by the current vertex index into the
+   * feedback buffer, offset register is always set to 0 at the start of 
the
+   * batchbuffer.
+   */
+  start += brw->sol.offset_0_batch_start * stride;
+  assert(start <= end);
+
   BEGIN_BATCH(4);
   OUT_BATCH(_3DSTATE_SO_BUFFER << 16 | (4 - 2));
-  OUT_BATCH((i << SO_BUFFER_INDEX_SHIFT) |
-   ((linked_xfb_info->BufferStride[i] * 4) <<
-SO_BUFFER_PITCH_SHIFT));
+  OUT_BATCH((i << SO_BUFFER_INDEX_SHIFT) | stride);
   OUT_RELOC(bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, start);
   OUT_RELOC(bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, end);
   ADVANCE_BATCH();
-- 
1.7.7.3

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


[Mesa-dev] [PATCH 2/4] i965/gen7: Flush the batch between transform feedbacks.

2012-01-02 Thread Eric Anholt
We need the kernel to reset our pointers to 0 in between.  Note that
the initialization of function pointer had to move to after
InitContext since we didn't have intel->gen set up yet.

Fixes piglit EXT_transform_feedback/immediate-reuse
---
 src/mesa/drivers/dri/i965/brw_context.c|   13 ++---
 src/mesa/drivers/dri/i965/brw_context.h|5 +
 src/mesa/drivers/dri/i965/gen7_sol_state.c |   16 
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index f5c9d7a..48c141c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -109,7 +109,8 @@ static void brwPrepareExecBegin(struct gl_context *ctx)
}
 }
 
-static void brwInitDriverFunctions( struct dd_function_table *functions )
+static void brwInitDriverFunctions(struct intel_screen *screen,
+  struct dd_function_table *functions)
 {
intelInitDriverFunctions( functions );
 
@@ -118,7 +119,11 @@ static void brwInitDriverFunctions( struct 
dd_function_table *functions )
 
functions->PrepareExecBegin = brwPrepareExecBegin;
functions->BeginTransformFeedback = brw_begin_transform_feedback;
-   functions->EndTransformFeedback = brw_end_transform_feedback;
+
+   if (screen->gen >= 7)
+  functions->EndTransformFeedback = gen7_end_transform_feedback;
+   else
+  functions->EndTransformFeedback = brw_end_transform_feedback;
 }
 
 bool
@@ -127,6 +132,8 @@ brwCreateContext(int api,
 __DRIcontext *driContextPriv,
 void *sharedContextPrivate)
 {
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
+   struct intel_screen *screen = sPriv->driverPrivate;
struct dd_function_table functions;
struct brw_context *brw = rzalloc(NULL, struct brw_context);
struct intel_context *intel = &brw->intel;
@@ -138,7 +145,7 @@ brwCreateContext(int api,
   return false;
}
 
-   brwInitDriverFunctions( &functions );
+   brwInitDriverFunctions(screen, &functions);
 
if (!intelInitContext( intel, api, mesaVis, driContextPriv,
  sharedContextPrivate, &functions )) {
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index fb41fd1..873e172 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1093,6 +1093,11 @@ void
 brw_end_transform_feedback(struct gl_context *ctx,
struct gl_transform_feedback_object *obj);
 
+/* gen7_sol_state.c */
+void
+gen7_end_transform_feedback(struct gl_context *ctx,
+   struct gl_transform_feedback_object *obj);
+
 
 
 /*==
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c 
b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 6cf68e2..ba9fb67 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -255,3 +255,19 @@ const struct brw_tracked_state gen7_sol_state = {
},
.emit = upload_sol_state,
 };
+
+void
+gen7_end_transform_feedback(struct gl_context *ctx,
+   struct gl_transform_feedback_object *obj)
+{
+   /* Because we have to rely on the kernel to reset our SO write offsets, and
+* we only get to do it once per batchbuffer, flush the batch after feedback
+* so another transform feedback can get the write offset reset it needs.
+*
+* This also covers any cache flushing required.
+*/
+   struct brw_context *brw = brw_context(ctx);
+   struct intel_context *intel = &brw->intel;
+
+   intel_batchbuffer_flush(intel);
+}
-- 
1.7.7.3

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


[Mesa-dev] Finishing gen7 transform feedback.

2012-01-02 Thread Eric Anholt
Here's my patch series for finishing off gen7 transform feedback.
It's not quite ready because it relies on new libdrm, which relies on
the kernel patch landing, so I won't push without requiring a new
libdrm release.

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


[Mesa-dev] [PATCH 4/4] i965/gen7: Enable transform feedback as long as kernel support is present.

2012-01-02 Thread Eric Anholt
The last major issue (intervening-read) is fixed, so let's turn this
on for real.  The only other known issue is a hardware limitation for
tesselation with flat shading.
---
 src/mesa/drivers/dri/intel/intel_extensions.c |3 ++-
 src/mesa/drivers/dri/intel/intel_screen.c |4 
 src/mesa/drivers/dri/intel/intel_screen.h |2 ++
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c 
b/src/mesa/drivers/dri/intel/intel_extensions.c
index 09ee9ba..d3c497c 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -104,7 +104,8 @@ intelInitExtensions(struct gl_context *ctx)
   ctx->Const.GLSLVersion = 120;
_mesa_override_glsl_version(ctx);
 
-   if (intel->gen == 6 || (intel->gen == 7 && override_version >= 30))
+   if (intel->gen == 6 ||
+   (intel->gen == 7 && intel->intelScreen->kernel_has_gen7_sol_reset))
   ctx->Extensions.EXT_transform_feedback = true;
 
if (intel->gen >= 5)
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c 
b/src/mesa/drivers/dri/intel/intel_screen.c
index e4cc5b0..ecc08fd 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -671,6 +671,10 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
   intelScreen->deviceID = strtod(devid_override, NULL);
}
 
+   intelScreen->kernel_has_gen7_sol_reset =
+  intel_get_boolean(intelScreen->driScrnPriv,
+   I915_PARAM_HAS_GEN7_SOL_RESET);
+
if (IS_GEN7(intelScreen->deviceID)) {
   intelScreen->gen = 7;
} else if (IS_GEN6(intelScreen->deviceID)) {
diff --git a/src/mesa/drivers/dri/intel/intel_screen.h 
b/src/mesa/drivers/dri/intel/intel_screen.h
index 63c58df..6c6b516 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.h
+++ b/src/mesa/drivers/dri/intel/intel_screen.h
@@ -114,6 +114,8 @@ struct intel_screen
bool hw_has_hiz;
enum intel_dri2_has_hiz dri2_has_hiz;
 
+   bool kernel_has_gen7_sol_reset;
+
bool no_vbo;
dri_bufmgr *bufmgr;
struct _mesa_HashTable *named_regions;
-- 
1.7.7.3

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


Re: [Mesa-dev] [PATCH] st/mesa: use SINT/UINT formats for VertexAttribIPointer

2012-01-02 Thread Dave Airlie
On Sun, Jan 1, 2012 at 5:46 PM, Christoph Bumiller
 wrote:
> Ping ...
>
Reviewed-by: Dave Airlie 

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


[Mesa-dev] [PATCH 0/2 v4] Add support for clip distances in Gallium

2012-01-02 Thread Bryan Cain
This is the fourth revision of my changes to add support for gl_ClipDistance
with Gallium.  The first three revisions were sent in closer succession about
two weeks ago.  This revision is identical to v3 except for the inclusion of
the changes suggested by Brian Paul in reply to the v3 patches.

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


[Mesa-dev] [PATCH 1/2] gallium: add support for clip distances

2012-01-02 Thread Bryan Cain
---
 src/gallium/auxiliary/tgsi/tgsi_dump.c |3 +-
 src/gallium/auxiliary/tgsi/tgsi_text.c |3 +-
 src/gallium/auxiliary/tgsi/tgsi_ureg.c |   38 +--
 src/gallium/auxiliary/tgsi/tgsi_ureg.h |6 
 src/gallium/include/pipe/p_shader_tokens.h |3 +-
 5 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c 
b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index e830aa5..bd299b0 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -129,7 +129,8 @@ static const char *semantic_names[] =
"PRIM_ID",
"INSTANCEID",
"VERTEXID",
-   "STENCIL"
+   "STENCIL",
+   "CLIPDIST"
 };
 
 static const char *immediate_type_names[] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c 
b/src/gallium/auxiliary/tgsi/tgsi_text.c
index eb9190c..f46ba19 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -1024,7 +1024,8 @@ static const char *semantic_names[TGSI_SEMANTIC_COUNT] =
"PRIM_ID",
"INSTANCEID",
"VERTEXID",
-   "STENCIL"
+   "STENCIL",
+   "CLIPDIST"
 };
 
 static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 17f9ce2..0f9aa3a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -122,6 +122,7 @@ struct ureg_program
struct {
   unsigned semantic_name;
   unsigned semantic_index;
+  unsigned usage_mask; /* = TGSI_WRITEMASK_* */
} output[UREG_MAX_OUTPUT];
unsigned nr_outputs;
 
@@ -396,21 +397,27 @@ ureg_DECL_system_value(struct ureg_program *ureg,
 
 
 struct ureg_dst 
-ureg_DECL_output( struct ureg_program *ureg,
-  unsigned name,
-  unsigned index )
+ureg_DECL_output_masked( struct ureg_program *ureg,
+ unsigned name,
+ unsigned index,
+ unsigned usage_mask )
 {
unsigned i;
 
+   assert(usage_mask != 0);
+
for (i = 0; i < ureg->nr_outputs; i++) {
   if (ureg->output[i].semantic_name == name &&
-  ureg->output[i].semantic_index == index) 
+  ureg->output[i].semantic_index == index) { 
+ ureg->output[i].usage_mask |= usage_mask;
  goto out;
+  }
}
 
if (ureg->nr_outputs < UREG_MAX_OUTPUT) {
   ureg->output[i].semantic_name = name;
   ureg->output[i].semantic_index = index;
+  ureg->output[i].usage_mask = usage_mask;
   ureg->nr_outputs++;
}
else {
@@ -422,6 +429,15 @@ out:
 }
 
 
+struct ureg_dst 
+ureg_DECL_output( struct ureg_program *ureg,
+  unsigned name,
+  unsigned index )
+{
+   return ureg_DECL_output_masked(ureg, name, index, TGSI_WRITEMASK_XYZW);
+}
+
+
 /* Returns a new constant register.  Keep track of which have been
  * referred to so that we can emit decls later.
  *
@@ -1181,7 +1197,8 @@ emit_decl_semantic(struct ureg_program *ureg,
unsigned file,
unsigned index,
unsigned semantic_name,
-   unsigned semantic_index)
+   unsigned semantic_index,
+   unsigned usage_mask)
 {
union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3);
 
@@ -1189,7 +1206,7 @@ emit_decl_semantic(struct ureg_program *ureg,
out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION;
out[0].decl.NrTokens = 3;
out[0].decl.File = file;
-   out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; /* FIXME! */
+   out[0].decl.UsageMask = usage_mask;
out[0].decl.Semantic = 1;
 
out[1].value = 0;
@@ -1427,7 +1444,8 @@ static void emit_decls( struct ureg_program *ureg )
 TGSI_FILE_INPUT,
 ureg->gs_input[i].index,
 ureg->gs_input[i].semantic_name,
-ureg->gs_input[i].semantic_index);
+ureg->gs_input[i].semantic_index,
+TGSI_WRITEMASK_XYZW);
   }
}
 
@@ -1436,7 +1454,8 @@ static void emit_decls( struct ureg_program *ureg )
  TGSI_FILE_SYSTEM_VALUE,
  ureg->system_value[i].index,
  ureg->system_value[i].semantic_name,
- ureg->system_value[i].semantic_index);
+ ureg->system_value[i].semantic_index,
+ TGSI_WRITEMASK_XYZW);
}
 
for (i = 0; i < ureg->nr_outputs; i++) {
@@ -1444,7 +1463,8 @@ static void emit_decls( struct ureg_program *ureg )
  TGSI_FILE_OUTPUT,
  i,
  ureg->output[i].semantic_name,
- ureg->output[i].semantic_index);
+ ureg->output[i].semantic_index,
+ ureg->output[i].us

[Mesa-dev] [PATCH 2/2] st/mesa: add support for gl_ClipDistance

2012-01-02 Thread Bryan Cain
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   48 +---
 src/mesa/state_tracker/st_program.c|   18 ++
 2 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 1515fc1..bc3005e 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -304,6 +304,7 @@ public:
int samplers_used;
bool indirect_addr_temps;
bool indirect_addr_consts;
+   int num_clip_distances;

int glsl_version;
bool native_integers;
@@ -4627,9 +4628,17 @@ st_translate_program(
   }
 
   for (i = 0; i < numOutputs; i++) {
- t->outputs[i] = ureg_DECL_output(ureg,
-  outputSemanticName[i],
-  outputSemanticIndex[i]);
+ if (outputSemanticName[i] == TGSI_SEMANTIC_CLIPDIST) {
+int mask = ((1 << (program->num_clip_distances - 
4*outputSemanticIndex[i])) - 1) & TGSI_WRITEMASK_XYZW;
+t->outputs[i] = ureg_DECL_output_masked(ureg,
+outputSemanticName[i],
+outputSemanticIndex[i],
+mask);
+ } else {
+t->outputs[i] = ureg_DECL_output(ureg,
+ outputSemanticName[i],
+ outputSemanticIndex[i]);
+ }
  if ((outputSemanticName[i] == TGSI_SEMANTIC_PSIZE) && proginfo->Id) {
 /* Writing to the point size result register requires special
  * handling to implement clamping.
@@ -4806,7 +4815,8 @@ out:
 static struct gl_program *
 get_mesa_program(struct gl_context *ctx,
  struct gl_shader_program *shader_program,
-struct gl_shader *shader)
+ struct gl_shader *shader,
+ int num_clip_distances)
 {
glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor();
struct gl_program *prog;
@@ -4851,6 +4861,7 @@ get_mesa_program(struct gl_context *ctx,
v->options = options;
v->glsl_version = ctx->Const.GLSLVersion;
v->native_integers = ctx->Const.NativeIntegers;
+   v->num_clip_distances = num_clip_distances;
 
_mesa_generate_parameters_list_for_uniforms(shader_program, shader,
   prog->Parameters);
@@ -4980,6 +4991,25 @@ get_mesa_program(struct gl_context *ctx,
return prog;
 }
 
+/**
+ * Searches through the IR for a declaration of gl_ClipDistance and returns the
+ * declared size of the gl_ClipDistance array.  Returns 0 if gl_ClipDistance is
+ * not declared in the IR.
+ */
+int get_clip_distance_size(exec_list *ir)
+{
+   foreach_iter (exec_list_iterator, iter, *ir) {
+  ir_instruction *inst = (ir_instruction *)iter.get();
+  ir_variable *var = inst->as_variable();
+  if (var == NULL) continue;
+  if (!strcmp(var->name, "gl_ClipDistance")) {
+ return var->type->length;
+  }
+   }
+   
+   return 0;
+}
+
 extern "C" {
 
 struct gl_shader *
@@ -5018,6 +5048,7 @@ st_new_shader_program(struct gl_context *ctx, GLuint name)
 GLboolean
 st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
 {
+   int num_clip_distances[MESA_SHADER_TYPES];
assert(prog->LinkStatus);
 
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
@@ -5029,6 +5060,11 @@ st_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
   const struct gl_shader_compiler_options *options =
 
&ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)];
 
+  /* We have to determine the length of the gl_ClipDistance array before
+   * the array is lowered to two vec4s by lower_clip_distance().
+   */
+  num_clip_distances[i] = get_clip_distance_size(ir);
+
   do {
  progress = false;
 
@@ -5045,6 +5081,7 @@ st_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
   || progress;
 
  progress = lower_quadop_vector(ir, false) || progress;
+ progress = lower_clip_distance(ir) || progress;
 
  if (options->MaxIfDepth == 0)
 progress = lower_discard(ir) || progress;
@@ -5079,7 +5116,8 @@ st_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
   if (prog->_LinkedShaders[i] == NULL)
  continue;
 
-  linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
+  linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i],
+ num_clip_distances[i]);
 
   if (linked_prog) {
 static const GLenum targets[] = {
diff --git a/src/mesa/state_tracker/st_program.c 
b/src/mesa/state_tracker/st_program.c
index d62bfcd..aceaaf8 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/s

Re: [Mesa-dev] Finishing gen7 transform feedback.

2012-01-02 Thread Kenneth Graunke
On 01/02/2012 11:37 AM, Eric Anholt wrote:
> Here's my patch series for finishing off gen7 transform feedback.
> It's not quite ready because it relies on new libdrm, which relies on
> the kernel patch landing, so I won't push without requiring a new
> libdrm release.

LGTM.

Reviewed-by: Kenneth Graunke 


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


[Mesa-dev] glx / xcb versioning

2012-01-02 Thread Brian Paul

Ian,

I'm getting some warnings/errors with the latest GLX changes:

clientinfo.c: In function ‘__glX_send_client_info’:
clientinfo.c:128:7: warning: implicit declaration of function 
‘xcb_glx_set_client_info_2arb’
clientinfo.c:139:7: warning: implicit declaration of function 
‘xcb_glx_set_client_info_arb’


[...]

create_context.c: In function ‘glXCreateContextAttribsARB’:
create_context.c:98:7: warning: implicit declaration of function 
‘xcb_glx_create_context_attribs_arb_checked’
create_context.c:97:11: error: incompatible types when assigning to 
type ‘xcb_void_cookie_t’ from type ‘int’



My xcb/glx.h header isn't the latest version so it doesn't have your 
recent create-context additions.


Can we add some #ifdefs to the code to fix this?

I grabbed the latest xcb/proto from git but I haven't figured out how 
to generate the glx.h header yet.  Any tips?


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


[Mesa-dev] [Bug 43317] swrast: glean basic sanity fails

2012-01-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=43317

Brian Paul  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||DUPLICATE

--- Comment #5 from Brian Paul  2012-01-02 14:53:17 PST ---


*** This bug has been marked as a duplicate of bug 44247 ***

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


Re: [Mesa-dev] [PATCH 4/4] i965/gen7: Enable transform feedback as long as kernel support is present.

2012-01-02 Thread Eugeni Dodonov
On Mon, Jan 2, 2012 at 17:37, Eric Anholt  wrote:

> -   if (intel->gen == 6 || (intel->gen == 7 && override_version >= 30))
> +   if (intel->gen == 6 ||
> +   (intel->gen == 7 && intel->intelScreen->kernel_has_gen7_sol_reset))
>   ctx->Extensions.EXT_transform_feedback = true;
>

If the kernel patch in previous series would return
...
value = IS_GEN7(dev);
...

the line above could be simplified to:
   if (intel->gen == 6 || intel->intelScreen->kernel_has_gen7_sol_reset)

But on the other hand, it would work either way. The check for GEN7 in
kernel looks cleaner and more logically correct to me, but in any case:
Reviewed-by: Eugeni Dodonov 

-- 
Eugeni Dodonov

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


[Mesa-dev] [PATCH 1/2] mesa: XCB is no longer optional for GLX or DRI

2012-01-02 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 configure.ac |   28 ++--
 1 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/configure.ac b/configure.ac
index c29b0bb..e526d17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -940,16 +940,8 @@ if test "x$enable_glx" = xyes -a "x$no_x" = xyes; then
 AC_MSG_ERROR([X11 development libraries needed for GLX])
 fi
 
-dnl XCB - this is only used for GLX right now
-AC_ARG_ENABLE([xcb],
-[AS_HELP_STRING([--enable-xcb],
-[use XCB for GLX @<:@default=disabled@:>@])],
-[enable_xcb="$enableval"],
-[enable_xcb=no])
-if test "x$enable_xcb" = xyes; then
+if test "x$enable_glx" = xyes; then
 DEFINES="$DEFINES -DUSE_XCB"
-else
-enable_xcb=no
 fi
 
 dnl Direct rendering or just indirect rendering
@@ -1008,7 +1000,7 @@ xyesno)
 
 # find the DRI deps for libGL
 if test "$x11_pkgconfig" = yes; then
-dri_modules="x11 xext xdamage xfixes"
+dri_modules="x11 xext xdamage xfixes x11-xcb xcb-glx"
 
 # add xf86vidmode if available
 PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, 
HAVE_XF86VIDMODE=no)
@@ -1016,11 +1008,6 @@ xyesno)
 dri_modules="$dri_modules xxf86vm"
 fi
 
-# add xcb modules if necessary
-if test "$enable_xcb" = yes; then
-dri_modules="$dri_modules x11-xcb xcb-glx"
-fi
-
 PKG_CHECK_MODULES([DRIGL], [$dri_modules])
 GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
 X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
@@ -1037,12 +1024,10 @@ xyesno)
 GL_PC_CFLAGS="$X11_INCLUDES"
 
 # XCB can only be used from pkg-config
-if test "$enable_xcb" = yes; then
-PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
-GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
-X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
-GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
-fi
+PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
+GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
+X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
+GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
 fi
 
 # need DRM libs, -lpthread, etc.
@@ -1981,7 +1966,6 @@ xyesyes)
 ;;
 xyesno)
 echo "GLX: DRI-based"
-echo "Use XCB: $enable_xcb"
 ;;
 *)
 echo "GLX: $enable_glx"
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 2/2] glx: Hack around versions of XCB that lack GLX_ARB_create_context support

2012-01-02 Thread Ian Romanick
From: Ian Romanick 

A lot of tests in 'make check' will fail under these circumstances,
but at least the build should work.

Signed-off-by: Ian Romanick 
---
 src/glx/create_context.c |   14 ++
 src/glx/glxextensions.c  |9 +
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/glx/create_context.c b/src/glx/create_context.c
index 41f0805..11f9340 100644
--- a/src/glx/create_context.c
+++ b/src/glx/create_context.c
@@ -94,6 +94,7 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
 * the protocol error and handle it.  Part of handling the error is freeing
 * the possibly non-NULL value returned by this function.
 */
+#ifdef XCB_GLX_CREATE_CONTEXT_ATTRIBS_ARB
cookie =
   xcb_glx_create_context_attribs_arb_checked(c,
 gc->xid,
@@ -105,6 +106,19 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig 
config,
 (const uint32_t *)
 attrib_list);
err = xcb_request_check(c, cookie);
+#else
+   /* This is a hugely ugly hack to make things compile on systems that lack
+* the proper XCB version.
+*/
+   memset(&cookie, 0, sizeof(cookie));
+
+   err = calloc(1, sizeof(*err));
+   err->error_code = BadRequest;
+   err->sequence = dpy->request;
+   err->resource_id = gc->xid;
+   err->minor_code = gc->majorOpcode;
+   err->major_code = 34;
+#endif
if (err != NULL) {
   gc->vtable->destroy(gc);
   gc = NULL;
diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
index 73b84dc..0fcd8a9 100644
--- a/src/glx/glxextensions.c
+++ b/src/glx/glxextensions.c
@@ -71,8 +71,13 @@ struct extension_info
 
 /* *INDENT-OFF* */
 static const struct extension_info known_glx_extensions[] = {
+#ifdef XCB_GLX_CREATE_CONTEXT_ATTRIBS_ARB
{ GLX(ARB_create_context),  VER(0,0), Y, N, N, N },
{ GLX(ARB_create_context_profile),  VER(0,0), Y, N, N, N },
+#else
+   { GLX(ARB_create_context),  VER(0,0), N, N, N, N },
+   { GLX(ARB_create_context_profile),  VER(0,0), N, N, N, N },
+#endif
{ GLX(ARB_get_proc_address),VER(1,4), Y, N, Y, N },
{ GLX(ARB_multisample), VER(1,4), Y, Y, N, N },
{ GLX(ATI_pixel_format_float),  VER(0,0), N, N, N, N },
@@ -80,7 +85,11 @@ static const struct extension_info known_glx_extensions[] = {
{ GLX(EXT_visual_info), VER(0,0), Y, Y, N, N },
{ GLX(EXT_visual_rating),   VER(0,0), Y, Y, N, N },
{ GLX(EXT_framebuffer_sRGB),VER(0,0), Y, Y, N, N },
+#ifdef XCB_GLX_CREATE_CONTEXT_ATTRIBS_ARB
{ GLX(EXT_create_context_es2_profile), VER(0,0), Y, N, N, Y },
+#else
+   { GLX(EXT_create_context_es2_profile), VER(0,0), N, N, N, N },
+#endif
{ GLX(MESA_copy_sub_buffer),VER(0,0), Y, N, N, N },
{ GLX(MESA_multithread_makecurrent),VER(0,0), Y, N, Y, N },
{ GLX(MESA_swap_control),   VER(0,0), Y, N, N, Y },
-- 
1.7.6.4

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


[Mesa-dev] Recent mesa changes are causing tinderbox to fail

2012-01-02 Thread Jeremy Huddleston
xdriinfo is failing to build in tinderbox (through no change of its own).  The 
relevant changes in mesa were bce506f..7705833.  My guess is that this was 
caused by one of:

glx: Add __glX_send_client_info super function
glx: Initial implementation of glXCreateContextAttribsARB

Here's the tinderbox failure:
http://tinderbox.x.org/builds/2012-01-02-0028/logs/xdriinfo/#configure

Here's the relevant section from config.log:
configure:9243: gcc -std=gnu99 -o conftest -O0 -pipe -Wall -Wextra 
-Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers 
-Wformat=2  -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_GNU_SOURCE 
-I/var/tmp/jhbuild/include 
-I/home/jeremy/src/freedesktop/jhbuild/external/build/include 
-L/var/tmp/jhbuild/lib  conftest.c -lGL -L/var/tmp/jhbuild/lib -lX11>&5
/var/tmp/jhbuild/lib/libGL.so: undefined reference to 
`xcb_glx_create_context_attribs_arb_checked'
/var/tmp/jhbuild/lib/libGL.so: undefined reference to 
`xcb_glx_set_client_info_2arb'
/var/tmp/jhbuild/lib/libGL.so: undefined reference to `XGetXCBConnection'
/var/tmp/jhbuild/lib/libGL.so: undefined reference to 
`xcb_glx_set_client_info_arb'
/var/tmp/jhbuild/lib/libGL.so: undefined reference to `xcb_glx_client_info'
collect2: ld returned 1 exit status

So it looks like libGL.so isn't linked against libxcb-glx.so and libX11-xcb.so:

$ ldd /var/tmp/jhbuild/lib/libGL.so
linux-vdso32.so.1 =>  (0x0010)
libX11.so.6 => /usr/lib/powerpc-linux-gnu/libX11.so.6 (0x6fdc5000)
libXext.so.6 => /usr/lib/powerpc-linux-gnu/libXext.so.6 (0x6fd91000)
libXdamage.so.1 => /usr/lib/powerpc-linux-gnu/libXdamage.so.1 
(0x6fd6e000)
libXfixes.so.3 => /usr/lib/powerpc-linux-gnu/libXfixes.so.3 (0x6fd48000)
libXxf86vm.so.1 => /usr/lib/powerpc-linux-gnu/libXxf86vm.so.1 
(0x6fd22000)
libdrm.so.2 => /usr/lib/powerpc-linux-gnu/libdrm.so.2 (0x6fcf7000)
libpthread.so.0 => /lib/powerpc-linux-gnu/libpthread.so.0 (0x6fcbd000)
libdl.so.2 => /lib/powerpc-linux-gnu/libdl.so.2 (0x6fc99000)
libc.so.6 => /lib/powerpc-linux-gnu/libc.so.6 (0x6fb14000)
libxcb.so.1 => /usr/lib/powerpc-linux-gnu/libxcb.so.1 (0x6fada000)
librt.so.1 => /lib/powerpc-linux-gnu/librt.so.1 (0x6fab1000)
/lib/ld.so.1 (0x2020f000)
libXau.so.6 => /usr/lib/powerpc-linux-gnu/libXau.so.6 (0x6fa8e000)
libXdmcp.so.6 => /usr/lib/powerpc-linux-gnu/libXdmcp.so.6 (0x6fa68000)


It looks like you need to add x11-xcb and xcb-glx to libGL's pkg-config 
dependencies.



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


[Mesa-dev] [Bug 44407] New: git mesa/src/glx fails to compile

2012-01-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=44407

 Bug #: 44407
   Summary: git mesa/src/glx fails to compile
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: x86-64 (AMD64)
OS/Version: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: GLX
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: wol...@onsneteindhoven.nl


latest git version of mesa fails to compile showing the following error:
---
create_context.c: In function ‘glXCreateContextAttribsARB’:
create_context.c:98:7: warning: implicit declaration of function
‘xcb_glx_create_context_attribs_arb_checked’ [-Wimplicit-function-declaration]
create_context.c:97:11: error: incompatible types when assigning to type
‘xcb_void_cookie_t’ from type ‘int’
make[2]: *** [create_context.o] Error 1
make[2]: Leaving directory `/home/jos/src/xorg/git-master/mesa/src/glx'
make[1]: *** [subdirs] Error 1
make[1]: Leaving directory `/home/jos/src/xorg/git-master/mesa/src'
make: *** [default] Error 1
---

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


Re: [Mesa-dev] Recent mesa changes are causing tinderbox to fail

2012-01-02 Thread Ian Romanick

On 01/02/2012 06:18 PM, Jeremy Huddleston wrote:

xdriinfo is failing to build in tinderbox (through no change of its own).  The 
relevant changes in mesa were bce506f..7705833.  My guess is that this was 
caused by one of:

glx: Add __glX_send_client_info super function
glx: Initial implementation of glXCreateContextAttribsARB

Here's the tinderbox failure:
http://tinderbox.x.org/builds/2012-01-02-0028/logs/xdriinfo/#configure

Here's the relevant section from config.log:
configure:9243: gcc -std=gnu99 -o conftest -O0 -pipe -Wall -Wextra -Wno-sign-compare 
-Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2  -D_XOPEN_SOURCE=700 
-D_BSD_SOURCE -D_GNU_SOURCE -I/var/tmp/jhbuild/include 
-I/home/jeremy/src/freedesktop/jhbuild/external/build/include -L/var/tmp/jhbuild/lib  
conftest.c -lGL -L/var/tmp/jhbuild/lib -lX11>&5
/var/tmp/jhbuild/lib/libGL.so: undefined reference to 
`xcb_glx_create_context_attribs_arb_checked'
/var/tmp/jhbuild/lib/libGL.so: undefined reference to 
`xcb_glx_set_client_info_2arb'
/var/tmp/jhbuild/lib/libGL.so: undefined reference to `XGetXCBConnection'
/var/tmp/jhbuild/lib/libGL.so: undefined reference to 
`xcb_glx_set_client_info_arb'
/var/tmp/jhbuild/lib/libGL.so: undefined reference to `xcb_glx_client_info'
collect2: ld returned 1 exit status

So it looks like libGL.so isn't linked against libxcb-glx.so and libX11-xcb.so:


I think this is because Mesa wasn't built with --enable-xcb.  This used 
to be optional, but it is not now.  There's a patch on the mesa-dev list 
that should fix.



$ ldd /var/tmp/jhbuild/lib/libGL.so
linux-vdso32.so.1 =>   (0x0010)
libX11.so.6 =>  /usr/lib/powerpc-linux-gnu/libX11.so.6 (0x6fdc5000)
libXext.so.6 =>  /usr/lib/powerpc-linux-gnu/libXext.so.6 (0x6fd91000)
libXdamage.so.1 =>  /usr/lib/powerpc-linux-gnu/libXdamage.so.1 
(0x6fd6e000)
libXfixes.so.3 =>  /usr/lib/powerpc-linux-gnu/libXfixes.so.3 
(0x6fd48000)
libXxf86vm.so.1 =>  /usr/lib/powerpc-linux-gnu/libXxf86vm.so.1 
(0x6fd22000)
libdrm.so.2 =>  /usr/lib/powerpc-linux-gnu/libdrm.so.2 (0x6fcf7000)
libpthread.so.0 =>  /lib/powerpc-linux-gnu/libpthread.so.0 (0x6fcbd000)
libdl.so.2 =>  /lib/powerpc-linux-gnu/libdl.so.2 (0x6fc99000)
libc.so.6 =>  /lib/powerpc-linux-gnu/libc.so.6 (0x6fb14000)
libxcb.so.1 =>  /usr/lib/powerpc-linux-gnu/libxcb.so.1 (0x6fada000)
librt.so.1 =>  /lib/powerpc-linux-gnu/librt.so.1 (0x6fab1000)
/lib/ld.so.1 (0x2020f000)
libXau.so.6 =>  /usr/lib/powerpc-linux-gnu/libXau.so.6 (0x6fa8e000)
libXdmcp.so.6 =>  /usr/lib/powerpc-linux-gnu/libXdmcp.so.6 (0x6fa68000)


It looks like you need to add x11-xcb and xcb-glx to libGL's pkg-config 
dependencies.



___
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] [Bug 44407] git mesa/src/glx fails to compile

2012-01-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=44407

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||WORKSFORME

--- Comment #1 from Ian Romanick  2012-01-02 19:07:36 PST 
---
You need xcb git.

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


Re: [Mesa-dev] [PATCH] ff_fragment_shader: Don't generate swizzles for scalar combiner inputs

2012-01-02 Thread Ian Romanick

On 12/23/2011 10:35 PM, Eric Anholt wrote:

On Thu, 22 Dec 2011 17:43:57 -0800, "Ian Romanick"  wrote:

From: Ian Romanick

There are a couple scenarios where the source could be zero and the
operand could be either SRC_ALPHA or ONE_MINUS_SRC_ALPHA.  For
example, if the source was ZERO.  This would result in something like
(0).w, and a later call to ir_validate would get angry.

Signed-off-by: Ian Romanick
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42517


In other cases of handling this in the code, I was using the little
smear() helper function.  I'd tend towards using that here as well, but
no strong feeling.


smear replicates the X component to all four components of a vec4.

This code either extracts the W component from a vec4 and returns it as 
a scalar, or it returns the scalar unmodified.


Do you think there should be a new helper function for this case?


There's also a "bump = get_source(...)" in the bumpmap handling that
looks like it could use the same treatment.


Technically, yes.  However, I don't think that can actually happen.  The 
(du, dv) value should always be obtained by reading a texture (via 
load_texenv_source a few lines earlier).  If we ever get something other 
than a vec4 as that source, there's a significant bug elsewhere.


Since this would cause another sort of failure, I'm not even sure an 
assertion is in order.  What do you think?



I think I've reviewed all the other swizzles in the code now.


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


Re: [Mesa-dev] [PATCH 1/3] u_format: implement fetch_rgba_uint and fetch_rgba_sint for integer formats

2012-01-02 Thread Ian Romanick

On 01/02/2012 09:18 AM, Marek Olšák wrote:

On Mon, Jan 2, 2012 at 5:56 PM, Dave Airlie  wrote:

On Mon, Jan 2, 2012 at 4:40 PM, Marek Olšák  wrote:

On Mon, Jan 2, 2012 at 3:31 PM, Dave Airlie  wrote:

On Mon, Jan 2, 2012 at 1:07 PM, Marek Olšák  wrote:

Fetching int as float and vice versa is not allowed.
Fetching unsigned int as signed int and vice versa is not allowed either.


The first is true, the second isn't, otherwise I'd have implemented
this that way.


Doing conversions like that isn't allowed in OpenGL.


I don't have chapter/verse but EXT_texture_integer doesn't seem to
disallow this.


EXT_texture_integer doesn't, but that extension doesn't define the new
GLSL samplers, it only requires EXT_gpu_shader4.

See this part from EXT_gpu_shader4 (modifications to section 8.7 of
the GLSL spec):

Table 8.xxx lists the supported combinations of sampler types and
texture internal formats.

  texture
  internal  default (float) integer unsigned integer
  formatsampler sampler sampler
  float vec4n/a  n/a
  normalizedvec4n/a  n/a
  signed intn/a ivec4n/a
  unsigned int  n/a n/a  uvec4

That is, no conversions are allowed. The pack/unpack stuff is
different, because it doesn't involve shaders. I have no opinion on
whether we should be that strict in u_format or not. Being strict may
later prevent making programming mistakes though.


Did you mean samplers instead of shaders in that sentence? if so I
probably agree that its fine then.


I am not sure right now what the restrictions on vertex attribs are,
so yes, I meant samplers.


Signed and unsigned integer data can be supplied to float attributes via 
glVertexAttribPointer.  Whether the data is interpreted as normalized or 
not depends on a parameter to that function.


Signed and unsigned integer data can be supplied to int and uint 
attributes via glVertexAttribIPointer.  If the signedness of the data 
doesn't match that of the attribute, the result is undefined.  There's a 
bit about that in the description of glVertexAttribI in the GL3 spec.


So, I think it should work the same as for textures.


Marek



Also I'd agree with starting simple and only enabling the conversions
if something comes up later, so with that,

Reviewed-by: Dave Airlie

Dave.

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

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


Re: [Mesa-dev] [PATCH] glsl_to_tgsi: v2 Invalidate and revalidate uniform backing storage

2012-01-02 Thread Ian Romanick

On 01/02/2012 08:27 AM, Alex Deucher wrote:

On Thu, Dec 22, 2011 at 9:35 AM, Vadim Girlin  wrote:

If glUniform1i and friends are going to dump data directly in
driver-allocated, the pointers have to be updated when the storage
moves.  This should fix the regressions seen with commit 7199096.

I'm not sure if this is the only place that needs this treatment.  I'm
a little uncertain about the various functions in st_glsl_to_tgsi that
modify the TGSI IR and try to propagate changes about that up to the
gl_program.  That seems sketchy to me.

Signed-off-by: Ian Romanick

v2:

Revalidate when shader_program is not NULL.
Update the pointers for all _LinkedShaders.
Init glsl_to_tgsi_visitor::shader_program to NULL in the
get_pixel_transfer_visitor&  get_bitmap_visitor.

Signed-off-by: Vadim Girlin
---

Based on the patch from Ian Romanick:
http://lists.freedesktop.org/archives/mesa-dev/2011-November/014675.html

Fixes uniform regressions with r600g (and probably other drivers)
after commit 719909698c67c287a393d2380278e7b7495ae018



Are there any objections to pushing this patch?


It seems okay to me.  I'll assume that it has received some testing and 
fixes things? :)



Alex



Tested on evergreen with r600.tests: no regressions.

  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   25 +
  1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 77aa0d1..fce92bb 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3708,6 +3708,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
/* Copy attributes of the glsl_to_tgsi_visitor in the original shader. */
v->ctx = original->ctx;
v->prog = prog;
+   v->shader_program = NULL;
v->glsl_version = original->glsl_version;
v->native_integers = original->native_integers;
v->options = original->options;
@@ -3837,6 +3838,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
/* Copy attributes of the glsl_to_tgsi_visitor in the original shader. */
v->ctx = original->ctx;
v->prog = prog;
+   v->shader_program = NULL;
v->glsl_version = original->glsl_version;
v->native_integers = original->native_integers;
v->options = original->options;
@@ -4550,6 +4552,15 @@ st_translate_program(
t->pointSizeOutIndex = -1;
t->prevInstWrotePointSize = GL_FALSE;

+   if (program->shader_program) {
+  for (i = 0; i<  program->shader_program->NumUserUniformStorage; i++) {
+ struct gl_uniform_storage *const storage =
+&program->shader_program->UniformStorage[i];
+
+ _mesa_uniform_detach_all_driver_storage(storage);
+  }
+   }
+
/*
 * Declare input attributes.
 */
@@ -4776,6 +4787,20 @@ st_translate_program(
t->insn[t->labels[i].branch_target]);
}

+   if (program->shader_program) {
+  /* This has to be done last.  Any operation the can cause
+   * prog->ParameterValues to get reallocated (e.g., anything that adds a
+   * program constant) has to happen before creating this linkage.
+   */
+  for (unsigned i = 0; i<  MESA_SHADER_TYPES; i++) {
+ if (program->shader_program->_LinkedShaders[i] == NULL)
+continue;
+
+ _mesa_associate_uniform_storage(ctx, program->shader_program,
+   
program->shader_program->_LinkedShaders[i]->Program->Parameters);
+  }
+   }
+
  out:
if (t) {
   FREE(t->insn);
--
1.7.7.4

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

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


Re: [Mesa-dev] [PATCH 1/2] glsl: Add a lowering pass to remove reads of shader output variables.

2012-01-02 Thread Ian Romanick

On 01/02/2012 11:17 AM, Vincent Lejeune wrote:

This is similar to Gallium's existing glsl_to_tgsi::remove_output_read
lowering pass, but done entirely inside the GLSL compiler.

Signed-off-by: Vincent Lejeune
Signed-off-by: Kenneth Graunke

v2 [Kayden]:
  - Don't reallocate the array for every shader output.
  - Move the class into the .cpp file and create a lower_output_reads() wrapper
  - Simplify the logic in visit(ir_deference_variable *)
  - Fold add_replacement_pair into the only caller.
  - Use visit_leave(ir_return *) instead of enter (for paranoia, in case the
return value references shader outputs)
  - Visit signatures rather than functions, to avoid pattern matching to find
the actual void main() signature.
  - Add some comments
  - Whitespace fixes

v3 [Vincent]:
  - Fix tab indent
---
  src/glsl/Makefile.sources   |1 +
  src/glsl/ir_optimization.h  |1 +
  src/glsl/lower_output_reads.cpp |  152 +++
  3 files changed, 154 insertions(+), 0 deletions(-)
  create mode 100644 src/glsl/lower_output_reads.cpp

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index c65bfe4..5e80af2 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -60,6 +60,7 @@ LIBGLSL_CXX_SOURCES := \
lower_vec_index_to_cond_assign.cpp \
lower_vec_index_to_swizzle.cpp \
lower_vector.cpp \
+   lower_output_reads.cpp \
opt_algebraic.cpp \
opt_constant_folding.cpp \
opt_constant_propagation.cpp \
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index 7b32e84..085b969 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -72,6 +72,7 @@ bool lower_variable_index_to_cond_assign(exec_list 
*instructions,
  bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
  bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
  bool lower_clip_distance(exec_list *instructions);
+void lower_output_reads(exec_list *instructions);
  bool optimize_redundant_jumps(exec_list *instructions);

  ir_rvalue *
diff --git a/src/glsl/lower_output_reads.cpp b/src/glsl/lower_output_reads.cpp
new file mode 100644
index 000..4b3f91c
--- /dev/null
+++ b/src/glsl/lower_output_reads.cpp
@@ -0,0 +1,152 @@
+/*
+ * Copyright © 2012 Vincent Lejeune
+ * Copyright © 2012 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.
+ */
+
+#include "ir.h"
+#include "program/hash_table.h"
+
+/**
+ * \file lower_output_reads.cpp
+ *
+ * In GLSL, shader output variables (such as varyings) can be both read and
+ * written.  However, on some hardware, reading an output register causes
+ * trouble.
+ *
+ * This pass creates temporary shadow copies of every (used) shader output,
+ * and replaces all accesses to use those instead.  It also adds code to the
+ * main() function to copy the final values to the actual shader outputs.
+ */
+
+class output_read_remover : public ir_hierarchical_visitor {
+protected:
+   struct replacement_pair {
+  ir_variable *output;
+  ir_variable *temp;
+   };
+
+   /**
+* A hash table mapping from the original ir_variable shader outputs
+* (ir_var_out mode) to the new temporaries to be used instead.
+*/
+   hash_table *replacements;
+
+   /**
+* An array of tuples containing both the output and temporary variables.
+* This is necessary because we can't iterate over the hash table.
+*/


I believe Eric added hash_table_call_foreach for just this sort of 
situation.



+   struct replacement_pair *replacements_array;
+   unsigned replacements_count;
+   unsigned replacements_array_size;
+
+   void *mem_ctx;
+public:
+   output_read_remover();
+   ~output_read_remover();
+   virtual ir_visitor_status visit(class ir_dereference_variable *);
+   virtual ir_visitor_status visit_leave(class ir_return *);
+   virtual ir_visito

[Mesa-dev] [Bug 44407] git mesa/src/glx fails to compile

2012-01-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=44407

Jos van Wolput  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|WORKSFORME  |

--- Comment #2 from Jos van Wolput  2012-01-02 
20:14:18 UTC ---
(In reply to comment #1)
> You need xcb git.

I installed git://anongit.freedesktop.org/xcb/proto
but compiling mesa still shows the same error.

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


Re: [Mesa-dev] [PATCH] glsl_to_tgsi: v2 Invalidate and revalidate uniform backing storage

2012-01-02 Thread Alex Deucher
On Mon, Jan 2, 2012 at 10:59 PM, Ian Romanick  wrote:
> On 01/02/2012 08:27 AM, Alex Deucher wrote:
>>
>> On Thu, Dec 22, 2011 at 9:35 AM, Vadim Girlin
>>  wrote:
>>>
>>> If glUniform1i and friends are going to dump data directly in
>>> driver-allocated, the pointers have to be updated when the storage
>>> moves.  This should fix the regressions seen with commit 7199096.
>>>
>>> I'm not sure if this is the only place that needs this treatment.  I'm
>>> a little uncertain about the various functions in st_glsl_to_tgsi that
>>> modify the TGSI IR and try to propagate changes about that up to the
>>> gl_program.  That seems sketchy to me.
>>>
>>> Signed-off-by: Ian Romanick
>>>
>>> v2:
>>>
>>> Revalidate when shader_program is not NULL.
>>> Update the pointers for all _LinkedShaders.
>>> Init glsl_to_tgsi_visitor::shader_program to NULL in the
>>> get_pixel_transfer_visitor&  get_bitmap_visitor.
>>>
>>>
>>> Signed-off-by: Vadim Girlin
>>> ---
>>>
>>> Based on the patch from Ian Romanick:
>>> http://lists.freedesktop.org/archives/mesa-dev/2011-November/014675.html
>>>
>>> Fixes uniform regressions with r600g (and probably other drivers)
>>> after commit 719909698c67c287a393d2380278e7b7495ae018
>>
>>
>>
>> Are there any objections to pushing this patch?
>
>
> It seems okay to me.  I'll assume that it has received some testing and
> fixes things? :)
>

Indeed:
https://bugs.freedesktop.org/show_bug.cgi?id=43125

Alex

>> Alex
>>
>>>
>>> Tested on evergreen with r600.tests: no regressions.
>>>
>>>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   25
>>> +
>>>  1 files changed, 25 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> index 77aa0d1..fce92bb 100644
>>> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> @@ -3708,6 +3708,7 @@ get_pixel_transfer_visitor(struct
>>> st_fragment_program *fp,
>>>    /* Copy attributes of the glsl_to_tgsi_visitor in the original shader.
>>> */
>>>    v->ctx = original->ctx;
>>>    v->prog = prog;
>>> +   v->shader_program = NULL;
>>>    v->glsl_version = original->glsl_version;
>>>    v->native_integers = original->native_integers;
>>>    v->options = original->options;
>>> @@ -3837,6 +3838,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
>>>    /* Copy attributes of the glsl_to_tgsi_visitor in the original shader.
>>> */
>>>    v->ctx = original->ctx;
>>>    v->prog = prog;
>>> +   v->shader_program = NULL;
>>>    v->glsl_version = original->glsl_version;
>>>    v->native_integers = original->native_integers;
>>>    v->options = original->options;
>>> @@ -4550,6 +4552,15 @@ st_translate_program(
>>>    t->pointSizeOutIndex = -1;
>>>    t->prevInstWrotePointSize = GL_FALSE;
>>>
>>> +   if (program->shader_program) {
>>> +      for (i = 0; i<  program->shader_program->NumUserUniformStorage;
>>> i++) {
>>> +         struct gl_uniform_storage *const storage =
>>> +&program->shader_program->UniformStorage[i];
>>>
>>> +
>>> +         _mesa_uniform_detach_all_driver_storage(storage);
>>> +      }
>>> +   }
>>> +
>>>    /*
>>>     * Declare input attributes.
>>>     */
>>> @@ -4776,6 +4787,20 @@ st_translate_program(
>>>                        t->insn[t->labels[i].branch_target]);
>>>    }
>>>
>>> +   if (program->shader_program) {
>>> +      /* This has to be done last.  Any operation the can cause
>>> +       * prog->ParameterValues to get reallocated (e.g., anything that
>>> adds a
>>> +       * program constant) has to happen before creating this linkage.
>>> +       */
>>> +      for (unsigned i = 0; i<  MESA_SHADER_TYPES; i++) {
>>> +         if (program->shader_program->_LinkedShaders[i] == NULL)
>>> +            continue;
>>> +
>>> +         _mesa_associate_uniform_storage(ctx, program->shader_program,
>>> +
>>> program->shader_program->_LinkedShaders[i]->Program->Parameters);
>>> +      }
>>> +   }
>>> +
>>>  out:
>>>    if (t) {
>>>       FREE(t->insn);
>>> --
>>> 1.7.7.4
>>>
>>> ___
>>> 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 1/3] mesa: Fix typos in transform feedback error messages.

2012-01-02 Thread Paul Berry
---
 src/mesa/main/shaderapi.c |2 +-
 src/mesa/main/transformfeedback.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index b71b44b..52a9bd4 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -751,7 +751,7 @@ link_program(struct gl_context *ctx, GLuint program)
   || shProg == ctx->Shader.CurrentGeometryProgram
   || shProg == ctx->Shader.CurrentFragmentProgram)) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
-  "glLinkProgram(transform feedback active");
+  "glLinkProgram(transform feedback active)");
   return;
}
 
diff --git a/src/mesa/main/transformfeedback.c 
b/src/mesa/main/transformfeedback.c
index be0d0ff..305589d 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -461,7 +461,7 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
 
if ((size <= 0) || (size & 0x3)) {
   /* must be positive and multiple of four */
-  _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size%d)", (int) 
size);
+  _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)", (int) 
size);
   return;
}  
 
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 2/3] mesa: Check that all buffers are bound in BeginTransformFeedback.

2012-01-02 Thread Paul Berry
>From the EXT_transform_feedback spec:

The error INVALID_OPERATION is generated by
BeginTransformFeedbackEXT if any transform feedback buffer object
binding point used in transform feedback mode does not have a
buffer object bound.

This required adding a new NumBuffers field to the
gl_transform_feedback_info struct, to keep track of how many transform
feedback buffers are required by the current program.

Fixes Piglit tests:
- EXT_transform_feedback/api-errors interleaved_unbound
- EXT_transform_feedback/api-errors separate_unbound_0_1
- EXT_transform_feedback/api-errors separate_unbound_0_2
- EXT_transform_feedback/api-errors separate_unbound_1_2
---
 src/glsl/linker.cpp   |7 +--
 src/mesa/main/mtypes.h|5 +
 src/mesa/main/transformfeedback.c |   12 
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index ed9a5d7..43be205 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1889,11 +1889,14 @@ store_tfeedback_info(struct gl_context *ctx, struct 
gl_shader_program *prog,
  tfeedback_decl *tfeedback_decls)
 {
unsigned total_tfeedback_components = 0;
+   bool separate_attribs_mode =
+  prog->TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS;
memset(&prog->LinkedTransformFeedback, 0,
   sizeof(prog->LinkedTransformFeedback));
+   prog->LinkedTransformFeedback.NumBuffers =
+  separate_attribs_mode ? num_tfeedback_decls : 1;
for (unsigned i = 0; i < num_tfeedback_decls; ++i) {
-  unsigned buffer =
- prog->TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS ? i : 0;
+  unsigned buffer = separate_attribs_mode ? i : 0;
   if (!tfeedback_decls[i].store(prog, &prog->LinkedTransformFeedback,
 buffer))
  return false;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d520f98..456131f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1821,6 +1821,11 @@ struct gl_uniform_list;
 struct gl_transform_feedback_info {
unsigned NumOutputs;
 
+   /**
+* Number of transform feedback buffers in use by this program.
+*/
+   unsigned NumBuffers;
+
struct {
   unsigned OutputRegister;
   unsigned OutputBuffer;
diff --git a/src/mesa/main/transformfeedback.c 
b/src/mesa/main/transformfeedback.c
index 305589d..6e93b3b 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -342,9 +342,12 @@ void GLAPIENTRY
 _mesa_BeginTransformFeedback(GLenum mode)
 {
struct gl_transform_feedback_object *obj;
+   struct gl_transform_feedback_info *info;
+   int i;
GET_CURRENT_CONTEXT(ctx);
 
obj = ctx->TransformFeedback.CurrentObject;
+   info = &ctx->Shader.CurrentVertexProgram->LinkedTransformFeedback;
 
switch (mode) {
case GL_POINTS:
@@ -363,6 +366,15 @@ _mesa_BeginTransformFeedback(GLenum mode)
   return;
}
 
+   for (i = 0; i < info->NumBuffers; ++i) {
+  if (obj->BufferNames[i] == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBeginTransformFeedback(binding point %d does not have "
+ "a buffer object bound)", i);
+ return;
+  }
+   }
+
FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);
obj->Active = GL_TRUE;
ctx->TransformFeedback.Mode = mode;
-- 
1.7.6.4

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


[Mesa-dev] [PATCH 3/3] mesa: Additional error checks for transform feedback.

2012-01-02 Thread Paul Berry
>From the EXT_transform_feedback spec:

The error INVALID_OPERATION is also generated by BeginTransformFeedbackEXT
if no binding points would be used, either because no program object is
active or because the active program object has specified no varying
variables to record.

...

The error INVALID_VALUE is generated by BindBufferRangeEXT or
BindBufferOffsetEXT if  is not word-aligned.

Fixes Piglit tests:
- EXT_transform_feedback/api-errors no_prog_active
- EXT_transform_feedback/api-errors interleaved_no_varyings
- EXT_transform_feedback/api-errors separate_no_varyings
- EXT_transform_feedback/api-errors bind_offset_offset_1
- EXT_transform_feedback/api-errors bind_offset_offset_2
- EXT_transform_feedback/api-errors bind_offset_offset_3
- EXT_transform_feedback/api-errors bind_offset_offset_5
---
 src/mesa/main/transformfeedback.c |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/transformfeedback.c 
b/src/mesa/main/transformfeedback.c
index 6e93b3b..02681c6 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -347,8 +347,21 @@ _mesa_BeginTransformFeedback(GLenum mode)
GET_CURRENT_CONTEXT(ctx);
 
obj = ctx->TransformFeedback.CurrentObject;
+
+   if (ctx->Shader.CurrentVertexProgram == NULL) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glBeginTransformFeedback(no program active)");
+  return;
+   }
+
info = &ctx->Shader.CurrentVertexProgram->LinkedTransformFeedback;
 
+   if (info->NumOutputs == 0) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glBeginTransformFeedback(no varyings to record)");
+  return;
+   }
+
switch (mode) {
case GL_POINTS:
case GL_LINES:
@@ -581,6 +594,13 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, 
GLuint buffer,
   return;
}
 
+   if (offset & 0x3) {
+  /* must be multiple of four */
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  "glBindBufferOffsetEXT(offset=%d)", (int) offset);
+  return;
+   }
+
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
if (!bufObj) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
-- 
1.7.6.4

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