[Mesa-dev] [PATCH] glsl: Dont call mark_whole_array_access() unless we are dealing with arrays

2013-12-17 Thread Timothy Arceri
Signed-off-by: Timothy Arceri 
---
 src/glsl/ast_to_hir.cpp | 45 -
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 3bc181e..a7aa4c7 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -805,33 +805,36 @@ do_assignment(exec_list *instructions, struct 
_mesa_glsl_parse_state *state,
if (new_rhs != NULL) {
   rhs = new_rhs;
 
-  /* If the LHS array was not declared with a size, it takes it size from
-   * the RHS.  If the LHS is an l-value and a whole array, it must be a
-   * dereference of a variable.  Any other case would require that the LHS
-   * is either not an l-value or not a whole array.
-   */
-  if (lhs->type->is_unsized_array()) {
-ir_dereference *const d = lhs->as_dereference();
+  if (lhs->type->is_array()) {
+ /* If the LHS array was not declared with a size, it takes it size
+  * from the RHS.  If the LHS is an l-value and a whole array, it must
+  * be a dereference of a variable.  Any other case would require that
+  * the LHS is either not an l-value or not a whole array.
+  */
+ if (lhs->type->is_unsized_array()) {
+   ir_dereference *const d = lhs->as_dereference();
 
-assert(d != NULL);
+   assert(d != NULL);
 
-ir_variable *const var = d->variable_referenced();
+   ir_variable *const var = d->variable_referenced();
 
-assert(var != NULL);
+   assert(var != NULL);
 
-if (var->data.max_array_access >= unsigned(rhs->type->array_size())) {
-   /* FINISHME: This should actually log the location of the RHS. */
-   _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to "
-"previous access",
-var->data.max_array_access);
-}
+   if (var->data.max_array_access >=
+unsigned(rhs->type->array_size())) {
+  /* FINISHME: This should actually log the location of the RHS.*/
+  _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due"
+   " to previous access",
+   var->data.max_array_access);
+   }
 
-var->type = glsl_type::get_array_instance(lhs->type->element_type(),
-  rhs->type->array_size());
-d->type = var->type;
+   var->type = glsl_type::get_array_instance(lhs->type->element_type(),
+ rhs->type->array_size());
+   d->type = var->type;
+ }
+ mark_whole_array_access(rhs);
+ mark_whole_array_access(lhs);
   }
-  mark_whole_array_access(rhs);
-  mark_whole_array_access(lhs);
}
 
/* Most callers of do_assignment (assign, add_assign, pre_inc/dec,
-- 
1.8.3.1

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


Re: [Mesa-dev] [PATCH 3/8] i965: Add a new representation for Broadwell shader instructions.

2013-12-17 Thread Kenneth Graunke
On 12/10/2013 11:25 PM, Kenneth Graunke wrote:
[snip]
> +static inline void
> +gen8_set_src1_3src_subreg_nr(struct gen8_instruction *inst, unsigned v)
> +{
> +   assert((v & ~0x7) == 0);
> +
> +   gen8_instruction_set_bits(inst, 95, 94, v & 0x3f);
> +   gen8_instruction_set_bits(inst, 96, 96, v >> 2);
> +}

0x3f is crazy...6 bits.  There are only two bits here, so clearly I
want 0x3.  Thankfully, the assertion Eric suggested I add caught this!

I've fixed this locally and will squash the change with this patch
before pushing.

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


Re: [Mesa-dev] [PATCH 5/8] i965: Add a new infrastructure for generating Broadwell shader assembly.

2013-12-17 Thread Kenneth Graunke
On 12/10/2013 11:25 PM, Kenneth Graunke wrote:
> This replaces the brw_eu_emit.c layer for Broadwell.  It will be
> used by both the vector and scalar shader backends.
> 
> v2: Port to use the C-based instruction representation.
> 
> Signed-off-by: Kenneth Graunke 
> ---
>  src/mesa/drivers/dri/i965/Makefile.sources   |   1 +
>  src/mesa/drivers/dri/i965/gen8_generator.cpp | 650 
> +++
>  src/mesa/drivers/dri/i965/gen8_generator.h   | 198 
>  3 files changed, 849 insertions(+)
>  create mode 100644 src/mesa/drivers/dri/i965/gen8_generator.cpp
>  create mode 100644 src/mesa/drivers/dri/i965/gen8_generator.h
> 
> diff --git a/src/mesa/drivers/dri/i965/Makefile.sources 
> b/src/mesa/drivers/dri/i965/Makefile.sources
> index 4c629cc..ade40ed 100644
> --- a/src/mesa/drivers/dri/i965/Makefile.sources
> +++ b/src/mesa/drivers/dri/i965/Makefile.sources
> @@ -140,5 +140,6 @@ i965_FILES = \
>   gen7_wm_state.c \
>   gen7_wm_surface_state.c \
>   gen8_disasm.c \
> + gen8_generator.cpp \
>   gen8_instruction.c \
>  $()
> diff --git a/src/mesa/drivers/dri/i965/gen8_generator.cpp 
> b/src/mesa/drivers/dri/i965/gen8_generator.cpp
> new file mode 100644
> index 000..555656d
> --- /dev/null
> +++ b/src/mesa/drivers/dri/i965/gen8_generator.cpp
> @@ -0,0 +1,650 @@
> +/*
> + * 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.
> + */
> +
> +/** @file gen8_generator.cpp
> + *
> + * Code generation for Gen8+ hardware, replacing the brw_eu_emit.c layer.
> + */
> +
> +extern "C" {
> +#include "main/compiler.h"
> +#include "main/macros.h"
> +#include "brw_context.h"
> +} /* extern "C" */
> +
> +#include "glsl/ralloc.h"
> +#include "brw_eu.h"
> +#include "brw_reg.h"
> +#include "gen8_generator.h"
> +
> +gen8_generator::gen8_generator(struct brw_context *brw,
> +   struct gl_shader_program *shader_prog,
> +   struct gl_program *prog,
> +   void *mem_ctx)
> +   : shader_prog(shader_prog), prog(prog), brw(brw), mem_ctx(mem_ctx)
> +{
> +   ctx = &brw->ctx;
> +
> +   memset(&default_state, 0, sizeof(default_state));
> +   default_state.mask_control = BRW_MASK_ENABLE;
> +
> +   store_size = 1024;
> +   store = rzalloc_array(mem_ctx, gen8_instruction, store_size);
> +   nr_inst = 0;
> +   next_inst_offset = 0;
> +
> +   /* Set up the control flow stacks. */
> +   if_stack_depth = 0;
> +   if_stack_array_size = 16;
> +   if_stack = rzalloc_array(mem_ctx, int, if_stack_array_size);
> +
> +   loop_stack_depth = 0;
> +   loop_stack_array_size = 16;
> +   loop_stack = rzalloc_array(mem_ctx, int, loop_stack_array_size);
> +}
> +
> +gen8_generator::~gen8_generator()
> +{
> +}
> +
> +gen8_instruction *
> +gen8_generator::next_inst(unsigned opcode)
> +{
> +   gen8_instruction *inst;
> +
> +   if (nr_inst + 1 > unsigned(store_size)) {
> +  store_size <<= 1;
> +  store = reralloc(mem_ctx, store, gen8_instruction, store_size);
> +  assert(store);
> +   }
> +
> +   next_inst_offset += 16;
> +   inst = &store[nr_inst++];
> +
> +   memset(inst, 0, sizeof(gen8_instruction));
> +
> +   gen8_set_opcode(inst, opcode);
> +   gen8_set_exec_size(inst, default_state.exec_size);
> +   gen8_set_access_mode(inst, default_state.access_mode);
> +   gen8_set_mask_control(inst, default_state.mask_control);
> +   gen8_set_cond_modifier(inst, default_state.conditional_mod);
> +   gen8_set_pred_control(inst, default_state.predicate);
> +   gen8_set_pred_inv(inst, default_state.predicate_inverse);
> +   gen8_set_saturate(inst, default_state.saturate);
> +   gen8_set_flag_subreg_nr(inst, default_state.flag_subreg_nr);
> +   return inst;
> +}
> +
> +#define ALU1(OP)   \
> +gen8_instruction * \
> +gen8_gener

Re: [Mesa-dev] [PATCH 1/2] mesa: Add gl_formats to cover all GLUser provided format/type combinations

2013-12-17 Thread Kenneth Graunke
On 12/17/2013 06:50 PM, Mark Mueller wrote:
> 
> 
> 
> On Tue, Dec 17, 2013 at 12:19 PM, Mark Mueller  > wrote:
> 
> 
> 
> 
> On Sat, Nov 23, 2013 at 4:10 PM, Marek Olšák  > wrote:
> 
> On Sat, Nov 23, 2013 at 10:23 PM, Mark Mueller
> mailto:markkmuel...@gmail.com>> wrote:
> >
> >
> >
> > On Sat, Nov 23, 2013 at 2:26 AM, Marek Olšák  > wrote:
> >>
> 
> 
> [...]
>  
> 
> >>
> >> >MESA_FORMAT_RGBA1555_REV,
> >>
> >> I don't think you can have R with 1 bit.
> >>
> >> >
> >> >/* Blue Green Red Alpha */
> >> >MESA_FORMAT_BGRA_INT8,
> >> >MESA_FORMAT_BGRA_INT8_REV,
> >> >MESA_FORMAT_BGRA_UINT8,
> >> >MESA_FORMAT_BGRA_INT16,
> >> >MESA_FORMAT_BGRA_UINT16,
> >> >MESA_FORMAT_BGRA_FLOAT16,
> >> >MESA_FORMAT_BGRA_INT32,
> >> >MESA_FORMAT_BGRA_UINT32,
> >> >MESA_FORMAT_BGRA_FLOAT32,
> >> >MESA_FORMAT_BGRA,
> >> >MESA_FORMAT_BGRA_REV,
> >> >MESA_FORMAT_BGRA5551,
> >>
> >> All these look good.
> >>
> >> >MESA_FORMAT_BGRA1555_REV,
> >>
> >> I don't think you can have B with 1 bit.
> 
>  
> Doesn't the _REV force A to be the first component, i.e. 1 bit? This
> format is listed as valid in
> http://www.opengl.org/wiki/Pixel_Transfer - see below.
>  
> 
> >>
> >> >MESA_FORMAT_BGRA1010102,
> >>
> >> This one looks good.
> >>
> >> >MESA_FORMAT_BGRA2101010_REV,
> >>
> >> I don't think you can have B with 2 bits.
> 
> 
> Same as above.
>  
> 
> >>
> >> >MESA_FORMAT_BGRA5999_REV,
> >>
> >> This one doesn't exist either and cannot be specified by
> TexImage.
> 
> 
> You are correct according to the Pixel_Transfer spec, thanks.
>  
> 
> >
> >
> > BGRAs and RGBAs were based on this from the spec:
> > "GL_INVALID_OPERATION is generated if type is one of
> > GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
> > GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
> > GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,
> > GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV, or
> > GL_UNSIGNED_INT_5_9_9_9_REV, and format is neither GL_RGBA nor
> GL_BGRA."
> 
> Nowhere can I see that B has 1 or 2 bits. Also the occurence of
> GL_UNSIGNED_INT_5_9_9_9_REV seems to be a spec bug, because it
> should
> be GL_RGB (the 5 bits contain a shared exponent).
> 
> 
> It does appear to be a spec bug. Here is a quote from
> http://www.opengl.org/wiki/Pixel_Transfer which addresses that an
> other issues above:
> 
> "OpenGL restricts the possible sizes. They are:
> * 3_3_2 (2_3_3_REV): unsigned bytes. Only used with GL_RGB.
> 
> * 5_6_5 (5_6_5_REV): unsigned shorts. Only used with GL_RGB.
> 
> * 4_4_4_4 (4_4_4_4_REV): unsigned shorts.
> 
> * 5_5_5_1 (1_5_5_5_REV): unsigned shorts.
> 
> * 8_8_8_8 (8_8_8_8_REV): unsigned ints.
> 
> * 10_10_10_2 (2_10_10_10_REV): unsigned ints.
> 
> * 24_8 (no _REV): unsigned ints. Only used with GL_DEPTH_STENCIL​.
> 
> * 10F_11F_11F_REV (no non-REV): unsigned ints. These represent
> floats, and can only be used with GL_RGB​. This should only be used
> with images that have the GL_R11F_G11F_B10F​ image format.
> 
> * 5_9_9_9_REV (no non-REV): unsigned ints. Only used with GL_RGB​;
> the last component (the 5. It's REV) does not directly map to a
> color value. It is a shared exponent. Only use this with images that
> have the GL_RGB9_E5​ image format."
> 
>  
> I'm working on V2 of this patch with incorporation of Marek,
> Brian's, and Roland's feedback. I have also made changes as a result
> of further development and testing on the i965 GPU texture upload
> work. I will be posting that shortly.
> 
> Thanks Marek.
> 
> 
> OK, I think I've realized why this is so difficult. There are some
> MESA_FORMAT component orders that are counter to their OGL counterparts
> in name, and the same appears true for the bit count numberings. For
> example these two cases in _mesa_choose_tex_format:
> 
>case GL_BGRA:
>   RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB);
> 
> vs.
> 
>case GL_RGBA32F_ARB:
>   RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
> 
> 
> and Mesa defines these:
> 
>MESA_FORMAT_ARGB1555,/* ARRR RRGG GGGB  */
>MESA_FORMAT_ARGB1555_REV,/* GGGB  ARRR RRGG */
> 
> while in OGL it's this way:
> GL_UNSIGNED_SHORT_5_5_5_1
> GL_UNSIGNED_SHORT_1_5_5_5_REV
> 
> I'

Re: [Mesa-dev] [PATCH 1/2] mesa: Add gl_formats to cover all GLUser provided format/type combinations

2013-12-17 Thread Mark Mueller
On Tue, Dec 17, 2013 at 12:19 PM, Mark Mueller wrote:

>
>
>
> On Sat, Nov 23, 2013 at 4:10 PM, Marek Olšák  wrote:
>
>> On Sat, Nov 23, 2013 at 10:23 PM, Mark Mueller 
>> wrote:
>> >
>> >
>> >
>> > On Sat, Nov 23, 2013 at 2:26 AM, Marek Olšák  wrote:
>> >>
>>
>
> [...]
>
>
>> >>
>>  >> >MESA_FORMAT_RGBA1555_REV,
>> >>
>> >> I don't think you can have R with 1 bit.
>> >>
>> >> >
>> >> >/* Blue Green Red Alpha */
>> >> >MESA_FORMAT_BGRA_INT8,
>> >> >MESA_FORMAT_BGRA_INT8_REV,
>> >> >MESA_FORMAT_BGRA_UINT8,
>> >> >MESA_FORMAT_BGRA_INT16,
>> >> >MESA_FORMAT_BGRA_UINT16,
>> >> >MESA_FORMAT_BGRA_FLOAT16,
>> >> >MESA_FORMAT_BGRA_INT32,
>> >> >MESA_FORMAT_BGRA_UINT32,
>> >> >MESA_FORMAT_BGRA_FLOAT32,
>> >> >MESA_FORMAT_BGRA,
>> >> >MESA_FORMAT_BGRA_REV,
>> >> >MESA_FORMAT_BGRA5551,
>> >>
>> >> All these look good.
>> >>
>> >> >MESA_FORMAT_BGRA1555_REV,
>> >>
>> >> I don't think you can have B with 1 bit.
>>
>
> Doesn't the _REV force A to be the first component, i.e. 1 bit? This
> format is listed as valid in http://www.opengl.org/wiki/Pixel_Transfer -
> see below.
>
>
>> >>
>> >> >MESA_FORMAT_BGRA1010102,
>> >>
>> >> This one looks good.
>> >>
>> >> >MESA_FORMAT_BGRA2101010_REV,
>> >>
>> >> I don't think you can have B with 2 bits.
>>
>
> Same as above.
>
>
>>  >>
>> >> >MESA_FORMAT_BGRA5999_REV,
>> >>
>> >> This one doesn't exist either and cannot be specified by TexImage.
>>
>
> You are correct according to the Pixel_Transfer spec, thanks.
>
>
>>  >
>> >
>> > BGRAs and RGBAs were based on this from the spec:
>> > "GL_INVALID_OPERATION is generated if type is one of
>> > GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
>> > GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
>> > GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,
>> > GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV, or
>> > GL_UNSIGNED_INT_5_9_9_9_REV, and format is neither GL_RGBA nor GL_BGRA."
>>
>> Nowhere can I see that B has 1 or 2 bits. Also the occurence of
>> GL_UNSIGNED_INT_5_9_9_9_REV seems to be a spec bug, because it should
>> be GL_RGB (the 5 bits contain a shared exponent).
>>
>
> It does appear to be a spec bug. Here is a quote from
> http://www.opengl.org/wiki/Pixel_Transfer which addresses that an other
> issues above:
>
> "OpenGL restricts the possible sizes. They are:
> * 3_3_2 (2_3_3_REV): unsigned bytes. Only used with GL_RGB.
>
> * 5_6_5 (5_6_5_REV): unsigned shorts. Only used with GL_RGB.
>
> * 4_4_4_4 (4_4_4_4_REV): unsigned shorts.
>
> * 5_5_5_1 (1_5_5_5_REV): unsigned shorts.
>
> * 8_8_8_8 (8_8_8_8_REV): unsigned ints.
>
> * 10_10_10_2 (2_10_10_10_REV): unsigned ints.
>
> * 24_8 (no _REV): unsigned ints. Only used with GL_DEPTH_STENCIL​.
>
> * 10F_11F_11F_REV (no non-REV): unsigned ints. These represent floats, and
> can only be used with GL_RGB​. This should only be used with images that
> have the GL_R11F_G11F_B10F​ image format.
>
> * 5_9_9_9_REV (no non-REV): unsigned ints. Only used with GL_RGB​; the
> last component (the 5. It's REV) does not directly map to a color value. It
> is a shared exponent. Only use this with images that have the GL_RGB9_E5​
> image format."
>
>
> I'm working on V2 of this patch with incorporation of Marek, Brian's, and
> Roland's feedback. I have also made changes as a result of further
> development and testing on the i965 GPU texture upload work. I will be
> posting that shortly.
>
> Thanks Marek.
>
>
OK, I think I've realized why this is so difficult. There are some
MESA_FORMAT component orders that are counter to their OGL counterparts in
name, and the same appears true for the bit count numberings. For example
these two cases in _mesa_choose_tex_format:

   case GL_BGRA:
  RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB);

vs.

   case GL_RGBA32F_ARB:
  RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);


and Mesa defines these:

   MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB  */
   MESA_FORMAT_ARGB1555_REV, /* GGGB  ARRR RRGG */

while in OGL it's this way:
GL_UNSIGNED_SHORT_5_5_5_1
GL_UNSIGNED_SHORT_1_5_5_5_REV

I'll modify my additions to better match Mesa's convention and hopefully
that will clear a few things up. Or would it be better to fix this dilemma
once and for all? I've heard Ken suggesting that that be done. It has been
causing me so much grief that I'd _love_ to eliminate the problem but would
rather move on if I can't get buy in.

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


Re: [Mesa-dev] [PATCH 1/9] st/mesa: always prefer pipe->clear over clear_with_quad

2013-12-17 Thread Marek Olšák
José, is it really worth adding a new cap? The only way to hit both
pipe->clear and clear_with_quad for depth and stencil, respectively,
is to have a partial stencil writemask.

Marek

On Fri, Dec 13, 2013 at 5:46 PM, Jose Fonseca  wrote:
>
> So, if this provides a significant performance difference, then I think the 
> only option to have everybody happy is to have cap to choose the optimal 
> behavior.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] st/dri: move fourcc->format conversion to a common place

2013-12-17 Thread Dave Airlie
From: Dave Airlie 

Before I cut-n-paste this a 3rd time lets consolidate it.

Signed-off-by: Dave Airlie 
---
 src/gallium/state_trackers/dri/drm/dri2.c | 81 +--
 1 file changed, 35 insertions(+), 46 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 8ff77b3..2d713aa 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -42,6 +42,37 @@
 #include "dri_drawable.h"
 #include "dri2_buffer.h"
 
+static int convert_fourcc(int format, int *dri_components_p)
+{
+   int dri_components;
+   switch(format) {
+   case __DRI_IMAGE_FOURCC_RGB565:
+  format = __DRI_IMAGE_FORMAT_RGB565;
+  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
+  break;
+   case __DRI_IMAGE_FOURCC_ARGB:
+  format = __DRI_IMAGE_FORMAT_ARGB;
+  dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
+  break;
+   case __DRI_IMAGE_FOURCC_XRGB:
+  format = __DRI_IMAGE_FORMAT_XRGB;
+  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
+  break;
+   case __DRI_IMAGE_FOURCC_ABGR:
+  format = __DRI_IMAGE_FORMAT_ABGR;
+  dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
+  break;
+   case __DRI_IMAGE_FOURCC_XBGR:
+  format = __DRI_IMAGE_FORMAT_XBGR;
+  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
+  break;
+   default:
+  return -1;
+   }
+   *dri_components_p = dri_components;
+   return format;
+}
+
 /**
  * DRI2 flush extension.
  */
@@ -810,30 +841,9 @@ dri2_from_names(__DRIscreen *screen, int width, int 
height, int format,
if (offsets[0] != 0)
   return NULL;
 
-   switch(format) {
-   case __DRI_IMAGE_FOURCC_RGB565:
-  format = __DRI_IMAGE_FORMAT_RGB565;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
-  break;
-   case __DRI_IMAGE_FOURCC_ARGB:
-  format = __DRI_IMAGE_FORMAT_ARGB;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
-  break;
-   case __DRI_IMAGE_FOURCC_XRGB:
-  format = __DRI_IMAGE_FORMAT_XRGB;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
-  break;
-   case __DRI_IMAGE_FOURCC_ABGR:
-  format = __DRI_IMAGE_FORMAT_ABGR;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
-  break;
-   case __DRI_IMAGE_FOURCC_XBGR:
-  format = __DRI_IMAGE_FORMAT_XBGR;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
-  break;
-   default:
+   format = convert_fourcc(format, &dri_components);
+   if (format == -1)
   return NULL;
-   }
 
/* Strides are in bytes not pixels. */
stride = strides[0] /4;
@@ -946,30 +956,9 @@ dri2_from_fds(__DRIscreen *screen, int width, int height, 
int fourcc,
if (offsets[0] != 0)
   return NULL;
 
-   switch(fourcc) {
-   case __DRI_IMAGE_FOURCC_RGB565:
-  format = __DRI_IMAGE_FORMAT_RGB565;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
-  break;
-   case __DRI_IMAGE_FOURCC_ARGB:
-  format = __DRI_IMAGE_FORMAT_ARGB;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
-  break;
-   case __DRI_IMAGE_FOURCC_XRGB:
-  format = __DRI_IMAGE_FORMAT_XRGB;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
-  break;
-   case __DRI_IMAGE_FOURCC_ABGR:
-  format = __DRI_IMAGE_FORMAT_ABGR;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
-  break;
-   case __DRI_IMAGE_FOURCC_XBGR:
-  format = __DRI_IMAGE_FORMAT_XBGR;
-  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
-  break;
-   default:
+   format = convert_fourcc(fourcc, &dri_components);
+   if (format == -1)
   return NULL;
-   }
 
/* Strides are in bytes not pixels. */
stride = strides[0] /4;
-- 
1.8.3.1

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


[Mesa-dev] [PATCH 2/2] st/dri: add support for dma-buf importer (DRIimage v8)

2013-12-17 Thread Dave Airlie
From: Dave Airlie 

This is just a simple implementation that stores the extra values into the 
DRIimage
struct and just uses the fd importer. I haven't looked into what is required
to import YUV or deal with the extra parameters.

Signed-off-by: Dave Airlie 
---
 src/gallium/state_trackers/dri/common/dri_screen.h |  9 
 src/gallium/state_trackers/dri/drm/dri2.c  | 50 +-
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h 
b/src/gallium/state_trackers/dri/common/dri_screen.h
index f263a90..7c8e582 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.h
+++ b/src/gallium/state_trackers/dri/common/dri_screen.h
@@ -95,6 +95,15 @@ struct __DRIimageRec {
uint32_t dri_components;
 
void *loader_private;
+
+   /**
+* Provided by EGL_EXT_image_dma_buf_import.
+*/
+   enum __DRIYUVColorSpace yuv_color_space;
+   enum __DRISampleRange sample_range;
+   enum __DRIChromaSiting horizontal_siting;
+   enum __DRIChromaSiting vertical_siting;
+
 };
 
 #ifndef __NOT_HAVE_DRM_H
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 2d713aa..2ffaf34 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -972,6 +972,52 @@ dri2_from_fds(__DRIscreen *screen, int width, int height, 
int fourcc,
return img;
 }
 
+static __DRIimage *
+dri2_from_dma_bufs(__DRIscreen *screen,
+   int width, int height, int fourcc,
+   int *fds, int num_fds,
+   int *strides, int *offsets,
+   enum __DRIYUVColorSpace yuv_color_space,
+   enum __DRISampleRange sample_range,
+   enum __DRIChromaSiting horizontal_siting,
+   enum __DRIChromaSiting vertical_siting,
+   unsigned *error,
+   void *loaderPrivate)
+{
+   __DRIimage *img;
+   int format, stride, dri_components;
+
+   if (num_fds != 1 || offsets[0] != 0) {
+  *error = __DRI_IMAGE_ERROR_BAD_MATCH;
+  return NULL;
+   }
+
+   format = convert_fourcc(fourcc, &dri_components);
+   if (format == -1) {
+  *error = __DRI_IMAGE_ERROR_BAD_MATCH;
+  return NULL;
+   }
+
+   /* Strides are in bytes not pixels. */
+   stride = strides[0] /4;
+
+   img = dri2_create_image_from_fd(screen, width, height, format,
+   fds[0], stride, loaderPrivate);
+   if (img == NULL) {
+  *error = __DRI_IMAGE_ERROR_BAD_ALLOC;
+  return NULL;
+   }
+
+   img->yuv_color_space = yuv_color_space;
+   img->sample_range = sample_range;
+   img->horizontal_siting = horizontal_siting;
+   img->vertical_siting = vertical_siting;
+   img->dri_components = dri_components;
+
+   *error = __DRI_IMAGE_ERROR_SUCCESS;
+   return img;
+}
+
 static void
 dri2_destroy_image(__DRIimage *img)
 {
@@ -1041,8 +1087,10 @@ dri2_init_screen(__DRIscreen * sPriv)
}
 
if (dmabuf_ret && dmabuf_ret->val.val_bool) {
-  dri2ImageExtension.base.version = 7;
+  dri2ImageExtension.base.version = 8;
   dri2ImageExtension.createImageFromFds = dri2_from_fds;
+  dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
+
}
 
sPriv->extensions = dri_screen_extensions;
-- 
1.8.3.1

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


[Mesa-dev] [PATCH] i965: Fix the region's pitch condition to use blitter

2013-12-17 Thread Anuj Phogat
intelEmitCopyBlit uses a signed 16-bit integer to represent
buffer pitch, so it can only handle buffer pitches < 32k.

This patch fixes assertion failure in depth_texture_mipmap.test
in Khronos' OpenGL CTS. But, the test still fails due to
GL_OUT_OF_MEMORY error in glTexImage2D().

Cc: mesa-sta...@lists.freedesktop.org
Signed-off-by: Anuj Phogat 
---
 src/mesa/drivers/dri/i965/intel_blit.c| 6 +++---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_blit.c 
b/src/mesa/drivers/dri/i965/intel_blit.c
index 7bc289f..32431b9 100644
--- a/src/mesa/drivers/dri/i965/intel_blit.c
+++ b/src/mesa/drivers/dri/i965/intel_blit.c
@@ -199,9 +199,9 @@ intel_miptree_blit(struct brw_context *brw,
 * As a result of these two limitations, we can only use the blitter to do
 * this copy when the region's pitch is less than 32k.
 */
-   if (src_mt->region->pitch > 32768 ||
-   dst_mt->region->pitch > 32768) {
-  perf_debug("Falling back due to >32k pitch\n");
+   if (src_mt->region->pitch >= 32768 ||
+   dst_mt->region->pitch >= 32768) {
+  perf_debug("Falling back due to >=32k pitch\n");
   return false;
}
 
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index ed55cf1..3118b8c 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -2291,8 +2291,8 @@ intel_miptree_map_singlesample(struct brw_context *brw,
 mt->region->pitch < 32768) {
   intel_miptree_map_blit(brw, mt, map, level, slice);
} else if (mt->region->tiling != I915_TILING_NONE &&
-  mt->region->bo->size >= brw->max_gtt_map_object_size) {
-  assert(mt->region->pitch < 32768);
+  mt->region->bo->size >= brw->max_gtt_map_object_size &&
+  mt->region->pitch < 32768) {
   intel_miptree_map_blit(brw, mt, map, level, slice);
 #ifdef __SSE4_1__
} else if (!(mode & GL_MAP_WRITE_BIT) && !mt->compressed) {
-- 
1.8.3.1

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


[Mesa-dev] [PATCH] mesa: minor simplification in _mesa_es3_error_check_format_and_type()

2013-12-17 Thread Brian Paul
The type_valid local was set to true and never changed.
---
 src/mesa/main/glformats.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 740faa8..1ab8b23 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1694,8 +1694,6 @@ GLenum
 _mesa_es3_error_check_format_and_type(GLenum format, GLenum type,
   GLenum internalFormat)
 {
-   GLboolean type_valid = GL_TRUE;
-
switch (format) {
case GL_RGBA:
   switch (type) {
@@ -2116,5 +2114,5 @@ _mesa_es3_error_check_format_and_type(GLenum format, 
GLenum type,
   break;
}
 
-   return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION;
+   return GL_NO_ERROR;
 }
-- 
1.7.10.4

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


Re: [Mesa-dev] [PATCH] Rename overloads of _mesa_glsl_shader_target_name().

2013-12-17 Thread Brian Paul

On 12/17/2013 02:32 PM, Paul Berry wrote:

Previously, _mesa_glsl_shader_target_name() had an overload for GLenum
and an overload for the gl_shader_type enum, each of which behaved
differently.  However, since GLenum is a synonym for unsigned int, and
unsigned ints are often used in place of gl_shader_type (e.g. in loop
indices), there was a big risk of calling the wrong overload by
mistake.  This patch gives the two overloads different names so that
it's always clear which one we mean to call.
---
  src/glsl/ast_to_hir.cpp| 10 +-
  src/glsl/glsl_parser_extras.cpp| 17 -
  src/glsl/glsl_parser_extras.h  |  7 ---
  src/glsl/link_varyings.cpp | 24 
  src/glsl/linker.cpp|  2 +-
  src/mesa/drivers/dri/i965/brw_shader.cpp   |  4 ++--
  src/mesa/main/shaderapi.c  |  6 +++---
  src/mesa/main/uniform_query.cpp|  2 +-
  src/mesa/program/ir_to_mesa.cpp|  2 +-
  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  2 +-
  10 files changed, 38 insertions(+), 38 deletions(-)




Reviewed-by: Brian Paul 

Nice clean-ups, Paul.

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


[Mesa-dev] [PATCH 6/8] radeon/llvm: Free target data at end of optimization

2013-12-17 Thread Aaron Watry
Reviewed-by: Tom Stellard 

CC: "10.0" 
---
 src/gallium/drivers/radeon/radeon_llvm_util.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c 
b/src/gallium/drivers/radeon/radeon_llvm_util.c
index cf6d21e..2ace91f 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_util.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_util.c
@@ -84,6 +84,7 @@ static void radeon_llvm_optimize(LLVMModuleRef mod)
LLVMRunPassManager(pass_manager, mod);
LLVMPassManagerBuilderDispose(builder);
LLVMDisposePassManager(pass_manager);
+   LLVMDisposeTargetData(TD);
 }
 
 LLVMModuleRef radeon_llvm_get_kernel_module(LLVMContextRef ctx, unsigned index,
-- 
1.8.3.2

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


[Mesa-dev] [PATCH 7/8] st/vdpau: Destroy context when initialization fails

2013-12-17 Thread Aaron Watry
Prevents a potential memory leak found when tracking down something else.

Reviewed-by: Christian König 
Reviewed-by: Tom Stellard 

CC: "10.0" 
---
 src/gallium/state_trackers/vdpau/device.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/state_trackers/vdpau/device.c 
b/src/gallium/state_trackers/vdpau/device.c
index 309fee4..fb9c68c 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -86,6 +86,7 @@ vdp_imp_device_create_x11(Display *display, int screen, 
VdpDevice *device,
return VDP_STATUS_OK;
 
 no_handle:
+   dev->context->destroy(dev->context);
/* Destroy vscreen */
 no_context:
vl_screen_destroy(dev->vscreen);
-- 
1.8.3.2

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


[Mesa-dev] [PATCH 5/8] r600/compute: Use the correct FREE macro when deleting compute state

2013-12-17 Thread Aaron Watry
Reviewed-by: Tom Stellard 

CC: "10.0" 
---
 src/gallium/drivers/r600/evergreen_compute.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index caac599..251021c 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -246,7 +246,7 @@ void evergreen_delete_compute_state(struct pipe_context 
*ctx, void* state)
}
 #endif
 
-   free(shader);
+   FREE(shader);
 }
 
 static void evergreen_bind_compute_state(struct pipe_context *ctx_, void 
*state)
-- 
1.8.3.2

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


[Mesa-dev] [PATCH 2/8] pipe_loader/sw: close dev->lib when initialization fails

2013-12-17 Thread Aaron Watry
Prevents a memory leak.

Reviewed-by: Tom Stellard 

CC: "10.0" 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index c2b78c6..382e116 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -95,8 +95,11 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev,
   return NULL;
 
init = (void *)util_dl_get_proc_address(sdev->lib, "swrast_create_screen");
-   if (!init)
+   if (!init){
+  util_dl_close(sdev->lib);
+  sdev->lib = NULL;
   return NULL;
+   }
 
return init(sdev->ws);
 }
-- 
1.8.3.2

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


[Mesa-dev] [PATCH 3/8] radeon/compute: Stop leaking LLVMContexts in radeon_llvm_parse_bitcode

2013-12-17 Thread Aaron Watry
Previously we were creating a new LLVMContext every time that we called
radeon_llvm_parse_bitcode, which caused us to leak the context every time
that we compiled a CL program.

Sadly, we can't dispose of the LLVMContext at the point that it was being
created because evergreen_launch_grid (and possibly the SI equivalent) was
assuming that the context used to compile the kernels was still available.

Now, we'll create a new LLVMContext when creating EG/SI compute state, store
it there, and pass it to all of the places that need it.

The LLVM Context gets destroyed when we delete the EG/SI compute state.

Reviewed-by: Tom Stellard 

CC: "10.0" 
---
 src/gallium/drivers/r600/evergreen_compute.c  | 18 +++---
 src/gallium/drivers/r600/evergreen_compute_internal.h |  4 
 src/gallium/drivers/radeon/radeon_llvm_util.c | 15 +++
 src/gallium/drivers/radeon/radeon_llvm_util.h |  9 +
 src/gallium/drivers/radeonsi/radeonsi_compute.c   | 13 ++---
 5 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index d668c8e..f0f537c 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -204,6 +204,8 @@ void *evergreen_create_compute_state(
const unsigned char * code;
unsigned i;
 
+   shader->llvm_ctx = LLVMContextCreate();
+
COMPUTE_DBG(ctx->screen, "*** evergreen_create_compute_state\n");
 
header = cso->prog;
@@ -216,13 +218,14 @@ void *evergreen_create_compute_state(
shader->input_size = cso->req_input_mem;
 
 #ifdef HAVE_OPENCL 
-   shader->num_kernels = radeon_llvm_get_num_kernels(code, 
header->num_bytes);
+   shader->num_kernels = radeon_llvm_get_num_kernels(shader->llvm_ctx, 
code,
+   header->num_bytes);
shader->kernels = CALLOC(sizeof(struct r600_kernel), 
shader->num_kernels);
 
for (i = 0; i < shader->num_kernels; i++) {
struct r600_kernel *kernel = &shader->kernels[i];
-   kernel->llvm_module = radeon_llvm_get_kernel_module(i, code,
-   header->num_bytes);
+   kernel->llvm_module = 
radeon_llvm_get_kernel_module(shader->llvm_ctx, i,
+   code, 
header->num_bytes);
}
 #endif
return shader;
@@ -232,6 +235,15 @@ void evergreen_delete_compute_state(struct pipe_context 
*ctx, void* state)
 {
struct r600_pipe_compute *shader = (struct r600_pipe_compute *)state;
 
+   if (!shader)
+   return;
+
+#ifdef HAVE_OPENCL
+   if (shader->llvm_ctx){
+   LLVMContextDispose(shader->llvm_ctx);
+   }
+#endif
+
free(shader);
 }
 
diff --git a/src/gallium/drivers/r600/evergreen_compute_internal.h 
b/src/gallium/drivers/r600/evergreen_compute_internal.h
index c524da2..0929d8d 100644
--- a/src/gallium/drivers/r600/evergreen_compute_internal.h
+++ b/src/gallium/drivers/r600/evergreen_compute_internal.h
@@ -47,6 +47,10 @@ struct r600_pipe_compute {
unsigned private_size;
unsigned input_size;
struct r600_resource *kernel_param;
+
+#ifdef HAVE_OPENCL
+   LLVMContextRef llvm_ctx;
+#endif
 };
 
 struct r600_resource* r600_compute_buffer_alloc_vram(struct r600_screen 
*screen, unsigned size);
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c 
b/src/gallium/drivers/radeon/radeon_llvm_util.c
index 3ba0acc..cf6d21e 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_util.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_util.c
@@ -33,11 +33,10 @@
 #include 
 #include 
 
-LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode,
-   unsigned bitcode_len)
+LLVMModuleRef radeon_llvm_parse_bitcode(LLVMContextRef ctx,
+   const unsigned char * 
bitcode, unsigned bitcode_len)
 {
LLVMMemoryBufferRef buf;
-   LLVMContextRef ctx = LLVMContextCreate();
LLVMModuleRef module;
 
buf = LLVMCreateMemoryBufferWithMemoryRangeCopy((const char*)bitcode,
@@ -47,10 +46,10 @@ LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char 
* bitcode,
return module;
 }
 
-unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode,
-   unsigned bitcode_len)
+unsigned radeon_llvm_get_num_kernels(LLVMContextRef ctx,
+   const unsigned char *bitcode, unsigned 
bitcode_len)
 {
-   LLVMModuleRef mod = radeon_llvm_parse_bitcode(bitcode, bitcode_len);
+   LLVMModuleRef mod = radeon_llvm_parse_bitcode(ctx, bitcode, 
bitcode_len);
return LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels");
 }
 
@@ -87,7 +86,7 @@ static void radeon_llvm_optimize(LLVMModuleRef mod)

[Mesa-dev] [PATCH 1/8] clover: Remove unused variable

2013-12-17 Thread Aaron Watry
Reviewed-by: Tom Stellard 

CC: "10.0" 
---
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 3f50317..e826669 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -117,7 +117,6 @@ namespace {
const std::string &opts, clang::LangAS::Map& address_spaces) {
 
   clang::CompilerInstance c;
-  clang::CompilerInvocation invocation;
   clang::EmitLLVMOnlyAction act(&llvm::getGlobalContext());
   std::string log;
   llvm::raw_string_ostream s_log(log);
-- 
1.8.3.2

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


[Mesa-dev] [PATCH 8/8] r600/pipe: Stop leaking context->start_compute_cs_cmd.buf on EG/CM

2013-12-17 Thread Aaron Watry
Found while tracking down memory leaks in VDPAU playback

Reviewed-by: Tom Stellard 

CC: "10.0" 
---
 src/gallium/drivers/r600/r600_pipe.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/r600/r600_pipe.c 
b/src/gallium/drivers/r600/r600_pipe.c
index 4016bbe..74e007b 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -192,6 +192,8 @@ static void r600_destroy_context(struct pipe_context 
*context)
rctx->b.ws->cs_destroy(rctx->b.rings.dma.cs);
}
 
+   FREE(rctx->start_compute_cs_cmd.buf);
+
r600_common_context_cleanup(&rctx->b);
FREE(rctx);
 }
-- 
1.8.3.2

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


[Mesa-dev] [PATCH 0/8 v2] Fix multiple memory leaks

2013-12-17 Thread Aaron Watry
Most of these fixes target radeon (both EG and SI), but some also help
generic clover and also vdpau playback.

v2: Remove an unnecessary null check in patch 4 of 8

CC: "10.0" 

Aaron Watry (8):
  clover: Remove unused variable
  pipe_loader/sw: close dev->lib when initialization fails.
  radeon/compute: Stop leaking LLVMContexts in radeon_llvm_parse_bitcode
  r600/compute: Free compiled kernels when deleting compute state
  r600/compute: Use the correct FREE macro when deleting compute state.
  radeon/llvm: Free target data at end of optimization
  st/vdpau: Destroy context when initialization fails
  r600/pipe: Stop leaking context->start_compute_cs_cmd.buf on EG/CM

 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c |  5 -
 src/gallium/drivers/r600/evergreen_compute.c   | 22 
 .../drivers/r600/evergreen_compute_internal.h  |  4 
 src/gallium/drivers/r600/r600_pipe.c   |  2 ++
 src/gallium/drivers/radeon/radeon_llvm_util.c  | 16 +++
 src/gallium/drivers/radeon/radeon_llvm_util.h  |  9 
 src/gallium/drivers/radeonsi/radeonsi_compute.c| 13 +---
 .../state_trackers/clover/llvm/invocation.cpp  |  1 -
 src/gallium/state_trackers/vdpau/device.c  |  1 +
 9 files changed, 52 insertions(+), 21 deletions(-)

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


[Mesa-dev] [PATCH 4/8] r600/compute: Free compiled kernels when deleting compute state

2013-12-17 Thread Aaron Watry
v2: Remove unnecessary null pointer check

CC: "10.0" 
---
 src/gallium/drivers/r600/evergreen_compute.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index f0f537c..caac599 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -238,6 +238,8 @@ void evergreen_delete_compute_state(struct pipe_context 
*ctx, void* state)
if (!shader)
return;
 
+   FREE(shader->kernels);
+
 #ifdef HAVE_OPENCL
if (shader->llvm_ctx){
LLVMContextDispose(shader->llvm_ctx);
-- 
1.8.3.2

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


Re: [Mesa-dev] [PATCH 04/23] i965: Move up duplicated fields from stage-specific prog_data to brw_stage_prog_data.

2013-12-17 Thread Paul Berry
On 2 December 2013 11:31, Francisco Jerez  wrote:

> diff --git a/src/mesa/drivers/dri/i965/brw_program.c
> b/src/mesa/drivers/dri/i965/brw_program.c
> index 9a517be..a494bc2 100644
> --- a/src/mesa/drivers/dri/i965/brw_program.c
> +++ b/src/mesa/drivers/dri/i965/brw_program.c
> @@ -525,3 +525,31 @@ brw_destroy_shader_time(struct brw_context *brw)
> drm_intel_bo_unreference(brw->shader_time.bo);
> brw->shader_time.bo = NULL;
>  }
> +
> +bool
> +brw_stage_prog_data_compare(const void *in_a, const void *in_b)
> +{
> +   const struct brw_stage_prog_data *a = in_a;
> +   const struct brw_stage_prog_data *b = in_b;
>

Since this function is only called from the derived class compare funcs, it
doesn't have to match the signature of cache_aux_compare_func.  I'd prefer
if we made the parameters const brw_stage_prog_data *'s and got a little
extra type safety.

But I won't be a stickler about it.  With or without the change, this patch
is:

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


[Mesa-dev] [PATCH 5/5] mesa: Add an assertion to _mesa_program_index_to_target().

2013-12-17 Thread Paul Berry
Only a Mesa bug could cause this function to be called with an
out-of-range index, so raise an assertion if that ever happens.
---
 src/mesa/program/program.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 135271c..baff473 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -216,9 +216,10 @@ _mesa_program_index_to_target(GLuint i)
   GL_FRAGMENT_PROGRAM_ARB
};
STATIC_ASSERT(Elements(enums) == MESA_SHADER_TYPES);
-   if(i >= MESA_SHADER_TYPES)
+   if(i >= MESA_SHADER_TYPES) {
+  assert(!"Unexpected program index");
   return 0;
-   else
+   } else
   return enums[i];
 }
 
-- 
1.8.4.2

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


[Mesa-dev] [PATCH 2/5] glsl: Get rid of hardcoded arrays of shader target names.

2013-12-17 Thread Paul Berry
We already have a function for converting a shader type index to a
string: _mesa_glsl_shader_target_name().
---
 src/glsl/link_atomics.cpp |  8 +++-
 src/glsl/linker.cpp   | 16 ++--
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp
index 33903ad..cac5615 100644
--- a/src/glsl/link_atomics.cpp
+++ b/src/glsl/link_atomics.cpp
@@ -21,6 +21,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include "glsl_parser_extras.h"
 #include "ir.h"
 #include "ir_uniform.h"
 #include "linker.h"
@@ -214,9 +215,6 @@ link_check_atomic_counter_resources(struct gl_context *ctx,
 struct gl_shader_program *prog)
 {
STATIC_ASSERT(MESA_SHADER_TYPES == 3);
-   static const char *shader_names[MESA_SHADER_TYPES] = {
-  "vertex", "geometry", "fragment"
-   };
const unsigned max_atomic_counters[MESA_SHADER_TYPES] = {
   ctx->Const.VertexProgram.MaxAtomicCounters,
   ctx->Const.GeometryProgram.MaxAtomicCounters,
@@ -260,11 +258,11 @@ link_check_atomic_counter_resources(struct gl_context 
*ctx,
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
   if (atomic_counters[i] > max_atomic_counters[i])
  linker_error(prog, "Too many %s shader atomic counters",
-  shader_names[i]);
+  _mesa_glsl_shader_target_name((gl_shader_type) i));
 
   if (atomic_buffers[i] > max_atomic_buffers[i])
  linker_error(prog, "Too many %s shader atomic counter buffers",
-  shader_names[i]);
+  _mesa_glsl_shader_target_name((gl_shader_type) i));
}
 
if (total_atomic_counters > ctx->Const.MaxCombinedAtomicCounters)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index a6133ea..1406f13 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1893,10 +1893,6 @@ store_fragdepth_layout(struct gl_shader_program *prog)
 static void
 check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
 {
-   static const char *const shader_names[MESA_SHADER_TYPES] = {
-  "vertex", "geometry", "fragment"
-   };
-
const unsigned max_samplers[MESA_SHADER_TYPES] = {
   ctx->Const.VertexProgram.MaxTextureImageUnits,
   ctx->Const.GeometryProgram.MaxTextureImageUnits,
@@ -1929,7 +1925,7 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
 
   if (sh->num_samplers > max_samplers[i]) {
 linker_error(prog, "Too many %s shader texture samplers",
- shader_names[i]);
+ _mesa_glsl_shader_target_name((gl_shader_type) i));
   }
 
   if (sh->num_uniform_components > max_default_uniform_components[i]) {
@@ -1938,11 +1934,11 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
"components, but the driver will try to optimize "
"them out; this is non-portable out-of-spec "
   "behavior\n",
-   shader_names[i]);
+   _mesa_glsl_shader_target_name((gl_shader_type) i));
  } else {
 linker_error(prog, "Too many %s shader default uniform block "
 "components",
- shader_names[i]);
+ _mesa_glsl_shader_target_name((gl_shader_type) i));
  }
   }
 
@@ -1952,10 +1948,10 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
 linker_warning(prog, "Too many %s shader uniform components, "
"but the driver will try to optimize them out; "
"this is non-portable out-of-spec behavior\n",
-   shader_names[i]);
+   _mesa_glsl_shader_target_name((gl_shader_type) i));
  } else {
 linker_error(prog, "Too many %s shader uniform components",
- shader_names[i]);
+ _mesa_glsl_shader_target_name((gl_shader_type) i));
  }
   }
}
@@ -1979,7 +1975,7 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
 for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
if (blocks[i] > max_uniform_blocks[i]) {
   linker_error(prog, "Too many %s uniform blocks (%d/%d)",
-   shader_names[i],
+   _mesa_glsl_shader_target_name((gl_shader_type) i),
blocks[i],
max_uniform_blocks[i]);
   break;
-- 
1.8.4.2

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


Re: [Mesa-dev] [PATCH 02/23] i965/fs: Allocate the param_size array dynamically.

2013-12-17 Thread Paul Berry
On 2 December 2013 11:31, Francisco Jerez  wrote:

> diff --git a/src/mesa/drivers/dri/i965/brw_wm.c
> b/src/mesa/drivers/dri/i965/brw_wm.c
> index bc1480c..b745d8f 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm.c
> @@ -165,6 +165,7 @@ bool do_wm_prog(struct brw_context *brw,
> param_count += 2 * BRW_MAX_TEX_UNIT;
> c->prog_data.param = rzalloc_array(NULL, const float *, param_count);
> c->prog_data.pull_param = rzalloc_array(NULL, const float *,
> param_count);
> +   c->prog_data.nr_params = param_count;
>

I believe this belongs in patch 1.

With that fixed, patches 1 and 2 are:

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


Re: [Mesa-dev] [PATCH] i965: Store QPitch in intel_mipmap_tree.

2013-12-17 Thread Paul Berry
On 17 December 2013 13:05, Kenneth Graunke  wrote:

> Broadwell allows us to specify an arbitrary value for QPitch, rather
> than baking a specific formula into the hardware and requiring software
> to lay things out to match.  The only restriction is that the software
> provided QPitch needs to be large enough so successive array slices do
> not overlap.
>
> In order to support this flexibility, software needs to specify QPitch
> in a bunch of packets.  Storing QPitch makes that easy, and allows us to
> adjust it in a single place should we wish to change it in the future.
>
> Signed-off-by: Kenneth Graunke 
> Cc: Eric Anholt 
>

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


[Mesa-dev] [PATCH] Rename overloads of _mesa_glsl_shader_target_name().

2013-12-17 Thread Paul Berry
Previously, _mesa_glsl_shader_target_name() had an overload for GLenum
and an overload for the gl_shader_type enum, each of which behaved
differently.  However, since GLenum is a synonym for unsigned int, and
unsigned ints are often used in place of gl_shader_type (e.g. in loop
indices), there was a big risk of calling the wrong overload by
mistake.  This patch gives the two overloads different names so that
it's always clear which one we mean to call.
---
 src/glsl/ast_to_hir.cpp| 10 +-
 src/glsl/glsl_parser_extras.cpp| 17 -
 src/glsl/glsl_parser_extras.h  |  7 ---
 src/glsl/link_varyings.cpp | 24 
 src/glsl/linker.cpp|  2 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp   |  4 ++--
 src/mesa/main/shaderapi.c  |  6 +++---
 src/mesa/main/uniform_query.cpp|  2 +-
 src/mesa/program/ir_to_mesa.cpp|  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  2 +-
 10 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 3bc181e..91810f9 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2110,7 +2110,7 @@ validate_explicit_location(const struct 
ast_type_qualifier *qual,
   _mesa_glsl_error(loc, state,
"%s cannot be given an explicit location in %s shader",
mode_string(var),
-  _mesa_glsl_shader_target_name(state->target));
+  _mesa_shader_type_to_string(state->target));
} else {
   var->data.explicit_location = true;
 
@@ -2188,7 +2188,7 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
   _mesa_glsl_error(loc, state,
   "`attribute' variables may not be declared in the "
   "%s shader",
-  _mesa_glsl_shader_target_name(state->target));
+  _mesa_shader_type_to_string(state->target));
}
 
/* Section 6.1.1 (Function Calling Conventions) of the GLSL 1.10 spec says:
@@ -2599,7 +2599,7 @@ process_initializer(ir_variable *var, ast_declaration 
*decl,
if ((var->data.mode == ir_var_shader_in) && (state->current_function == 
NULL)) {
   _mesa_glsl_error(& initializer_loc, state,
   "cannot initialize %s shader input / %s",
-  _mesa_glsl_shader_target_name(state->target),
+  _mesa_shader_type_to_string(state->target),
   (state->target == MESA_SHADER_VERTEX)
   ? "attribute" : "varying");
}
@@ -4890,7 +4890,7 @@ ast_interface_block::hir(exec_list *instructions,
 _mesa_glsl_error(&loc, state,
  "redeclaration of gl_PerVertex input not allowed "
  "in the %s shader",
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
  }
  if (this->instance_name == NULL ||
  strcmp(this->instance_name, "gl_in") != 0 || !this->is_array) {
@@ -4907,7 +4907,7 @@ ast_interface_block::hir(exec_list *instructions,
 _mesa_glsl_error(&loc, state,
  "redeclaration of gl_PerVertex output not "
  "allowed in the %s shader",
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
  }
  if (this->instance_name != NULL) {
 _mesa_glsl_error(&loc, state,
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 5f19368..fc9a8b2 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -334,16 +334,15 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE 
*locp, int version,
 extern "C" {
 
 /**
- * The most common use of _mesa_glsl_shader_target_name(), which is
- * shared with C code in Mesa core to translate a GLenum to a short
- * shader stage name in debug printouts.
+ * Translate a GLenum to a short shader stage name for debug printouts and
+ * error messages.
  *
  * It recognizes the PROGRAM variants of the names so it can be used
  * with a struct gl_program->Target, not just a struct
  * gl_shader->Type.
  */
 const char *
-_mesa_glsl_shader_target_name(GLenum type)
+_mesa_shader_enum_to_string(GLenum type)
 {
switch (type) {
case GL_VERTEX_SHADER:
@@ -363,11 +362,11 @@ _mesa_glsl_shader_target_name(GLenum type)
 } /* extern "C" */
 
 /**
- * Overloaded C++ variant usable within the compiler for translating
- * our internal enum into short stage names.
+ * Translate a gl_shader_type to a short shader stage name for debug printouts
+ * and error messages.
  */
 const char *
-_mesa_glsl_shader_target_name(gl_shader_type target)

Re: [Mesa-dev] Testing optimizer

2013-12-17 Thread Patrick Baggett
On Tue, Dec 17, 2013 at 10:59 AM, Paul Berry wrote:

> On 17 December 2013 08:46, Tom Stellard  wrote:
>
>> On Tue, Dec 17, 2013 at 09:57:31AM -0600, Patrick Baggett wrote:
>> > Hi all,
>> >
>> > Is there a way to see the machine code that is generated by the GLSL
>> > compiler for all GPU instruction sets? For example, I would like to
>> know if
>> > the optimizer optimizes certain (equivalent) constructs (or not), and
>> avoid
>> > them if possible. I know there is a lot to optimization on GPUs that I
>> > don't know, but I'd still like to get some ballpark estimates. For
>> example,
>> > I'm curious whether:
>>
>> Each driver has its own environment variable for dumping machine code.
>>
>> llvmpipe: GALLIVM_DEBUG=asm (I think you need to build mesa
>>  with --enable-debug for this to work)
>> r300g: RADEON_DEBUG=fp,vp
>> r600g, radeonsi: R600_DEBUG=ps,vs
>>
>> I'm not sure what the other drivers use.
>>
>> -Tom
>>
>
> I believe every driver also supports MESA_GLSL=dump, which prints out the
> IR both before and after linking (you'll want to look at the version after
> linking to see what optimizations have been applied, since some
> optimizations happen at link time).  Looking at the IR rather than the
> machine code is more likely to give you the information you need, since
> Mesa performs the same IR-level optimizations on all architectures, whereas
> the optimizations that happen at machine code level are vastly different
> from one driver to the next.
>
>
I do want to see both, actually. For example, if a driver implements a
specific optimization (machine code level) and another driver clearly does
not, then that would be considered "interesting" to me.



> Another thing which might be useful to you is Aras Pranckevičius's
> "glsl-optimizer" project (https://github.com/aras-p/glsl-optimizer),
> which performs Mesa's IR-level optimizations on a shader and then
> translates it from IR back to GLSL.
>
> Paul
>
>
Thanks to everyone for the great tips!


>
>> >
>> > //let p1, p2, p3 be vec2 uniforms
>> >
>> > vec4(p1, 0, 0) + vec4(p2, 0, 0) + vec4(p3, 0, 1)
>> >
>> > produces identical machine code as:
>> >
>> > vec4(p1+p2+p3, 0, 1);
>> >
>> > for all architectures supported by Mesa.
>>
>> > ___
>> > 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 mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/5] main: Remove unused function _mesa_shader_index_to_type().

2013-12-17 Thread Brian Paul

On 12/17/2013 11:23 AM, Paul Berry wrote:

---
  src/mesa/main/shaderobj.h | 15 ---
  1 file changed, 15 deletions(-)

diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index de1c9fc..7245c5e 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -118,21 +118,6 @@ _mesa_shader_type_to_index(GLenum v)
  }


-static inline GLenum
-_mesa_shader_index_to_type(GLuint i)
-{
-   static const GLenum enums[MESA_SHADER_TYPES] = {
-  GL_VERTEX_SHADER,
-  GL_GEOMETRY_SHADER,
-  GL_FRAGMENT_SHADER
-   };
-   if (i >= MESA_SHADER_TYPES)
-  return 0;
-   else
-  return enums[i];
-}
-
-
  #ifdef __cplusplus
  }
  #endif



For 1, 3, 4, 5:  Reviewed-by: Brian Paul 

Just had a small question on patch 2, but looks OK otherwise.

-Brian

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


[Mesa-dev] [PATCH] i965: Store QPitch in intel_mipmap_tree.

2013-12-17 Thread Kenneth Graunke
Broadwell allows us to specify an arbitrary value for QPitch, rather
than baking a specific formula into the hardware and requiring software
to lay things out to match.  The only restriction is that the software
provided QPitch needs to be large enough so successive array slices do
not overlap.

In order to support this flexibility, software needs to specify QPitch
in a bunch of packets.  Storing QPitch makes that easy, and allows us to
adjust it in a single place should we wish to change it in the future.

Signed-off-by: Kenneth Graunke 
Cc: Eric Anholt 
---
 src/mesa/drivers/dri/i965/brw_tex_layout.c| 11 +--
 src/mesa/drivers/dri/i965/intel_mipmap_tree.h |  5 +
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c 
b/src/mesa/drivers/dri/i965/brw_tex_layout.c
index 16af19f..a0f584b 100644
--- a/src/mesa/drivers/dri/i965/brw_tex_layout.c
+++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c
@@ -238,26 +238,25 @@ static void
 brw_miptree_layout_texture_array(struct brw_context *brw,
 struct intel_mipmap_tree *mt)
 {
-   unsigned qpitch = 0;
int h0, h1;
 
h0 = ALIGN(mt->physical_height0, mt->align_h);
h1 = ALIGN(minify(mt->physical_height0, 1), mt->align_h);
if (mt->array_spacing_lod0)
-  qpitch = h0;
+  mt->qpitch = h0;
else
-  qpitch = (h0 + h1 + (brw->gen >= 7 ? 12 : 11) * mt->align_h);
+  mt->qpitch = (h0 + h1 + (brw->gen >= 7 ? 12 : 11) * mt->align_h);
if (mt->compressed)
-  qpitch /= 4;
+  mt->qpitch /= 4;
 
brw_miptree_layout_2d(mt);
 
for (unsigned level = mt->first_level; level <= mt->last_level; level++) {
   for (int q = 0; q < mt->physical_depth0; q++) {
-intel_miptree_set_image_offset(mt, level, q, 0, q * qpitch);
+intel_miptree_set_image_offset(mt, level, q, 0, q * mt->qpitch);
   }
}
-   mt->total_height = qpitch * mt->physical_depth0;
+   mt->total_height = mt->qpitch * mt->physical_depth0;
 
align_cube(mt);
 }
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index cde702c..329eeb0 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -334,6 +334,11 @@ struct intel_mipmap_tree
bool array_spacing_lod0;
 
/**
+* The distance in rows between array slices.
+*/
+   uint32_t qpitch;
+
+   /**
 * MSAA layout used by this buffer.
 */
enum intel_msaa_layout msaa_layout;
-- 
1.8.4.4

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


Re: [Mesa-dev] [PATCH 2/5] glsl: Get rid of hardcoded arrays of shader target names.

2013-12-17 Thread Brian Paul

On 12/17/2013 11:23 AM, Paul Berry wrote:

We already have a function for converting a shader type index to a
string: _mesa_glsl_shader_target_name().
---
  src/glsl/link_atomics.cpp |  8 +++-
  src/glsl/linker.cpp   | 16 ++--
  2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp
index 33903ad..cac5615 100644
--- a/src/glsl/link_atomics.cpp
+++ b/src/glsl/link_atomics.cpp
@@ -21,6 +21,7 @@
   * DEALINGS IN THE SOFTWARE.
   */

+#include "glsl_parser_extras.h"
  #include "ir.h"
  #include "ir_uniform.h"
  #include "linker.h"
@@ -214,9 +215,6 @@ link_check_atomic_counter_resources(struct gl_context *ctx,
  struct gl_shader_program *prog)
  {
 STATIC_ASSERT(MESA_SHADER_TYPES == 3);
-   static const char *shader_names[MESA_SHADER_TYPES] = {
-  "vertex", "geometry", "fragment"
-   };
 const unsigned max_atomic_counters[MESA_SHADER_TYPES] = {
ctx->Const.VertexProgram.MaxAtomicCounters,
ctx->Const.GeometryProgram.MaxAtomicCounters,
@@ -260,11 +258,11 @@ link_check_atomic_counter_resources(struct gl_context 
*ctx,
 for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
if (atomic_counters[i] > max_atomic_counters[i])
   linker_error(prog, "Too many %s shader atomic counters",
-  shader_names[i]);
+  _mesa_glsl_shader_target_name((gl_shader_type) i));

if (atomic_buffers[i] > max_atomic_buffers[i])
   linker_error(prog, "Too many %s shader atomic counter buffers",
-  shader_names[i]);
+  _mesa_glsl_shader_target_name((gl_shader_type) i));
 }

 if (total_atomic_counters > ctx->Const.MaxCombinedAtomicCounters)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index a6133ea..1406f13 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1893,10 +1893,6 @@ store_fragdepth_layout(struct gl_shader_program *prog)
  static void
  check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
  {
-   static const char *const shader_names[MESA_SHADER_TYPES] = {
-  "vertex", "geometry", "fragment"
-   };
-
 const unsigned max_samplers[MESA_SHADER_TYPES] = {
ctx->Const.VertexProgram.MaxTextureImageUnits,
ctx->Const.GeometryProgram.MaxTextureImageUnits,
@@ -1929,7 +1925,7 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)

if (sh->num_samplers > max_samplers[i]) {
 linker_error(prog, "Too many %s shader texture samplers",
- shader_names[i]);
+ _mesa_glsl_shader_target_name((gl_shader_type) i));
}

if (sh->num_uniform_components > max_default_uniform_components[i]) {
@@ -1938,11 +1934,11 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
 "components, but the driver will try to optimize "
 "them out; this is non-portable out-of-spec "
   "behavior\n",
-   shader_names[i]);
+   _mesa_glsl_shader_target_name((gl_shader_type) i));
   } else {
  linker_error(prog, "Too many %s shader default uniform block "
 "components",
- shader_names[i]);
+ _mesa_glsl_shader_target_name((gl_shader_type) i));
   }
}

@@ -1952,10 +1948,10 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
  linker_warning(prog, "Too many %s shader uniform components, "
 "but the driver will try to optimize them out; "
 "this is non-portable out-of-spec behavior\n",
-   shader_names[i]);
+   _mesa_glsl_shader_target_name((gl_shader_type) i));
   } else {
  linker_error(prog, "Too many %s shader uniform components",
- shader_names[i]);
+ _mesa_glsl_shader_target_name((gl_shader_type) i));
   }
}
 }
@@ -1979,7 +1975,7 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
 for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
if (blocks[i] > max_uniform_blocks[i]) {
   linker_error(prog, "Too many %s uniform blocks (%d/%d)",
-   shader_names[i],
+   _mesa_glsl_shader_target_name((gl_shader_type) i),
blocks[i],
max_uniform_blocks[i]);
   break;



Could the variable 'i' be declared as gl_shader_type to avoid all the 
casting?


-Brian

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


Re: [Mesa-dev] [PATCH 1/2] mesa: Add gl_formats to cover all GLUser provided format/type combinations

2013-12-17 Thread Mark Mueller
On Sat, Nov 23, 2013 at 4:10 PM, Marek Olšák  wrote:

> On Sat, Nov 23, 2013 at 10:23 PM, Mark Mueller 
> wrote:
> >
> >
> >
> > On Sat, Nov 23, 2013 at 2:26 AM, Marek Olšák  wrote:
> >>
>

[...]


> >>
>  >> >MESA_FORMAT_RGBA1555_REV,
> >>
> >> I don't think you can have R with 1 bit.
> >>
> >> >
> >> >/* Blue Green Red Alpha */
> >> >MESA_FORMAT_BGRA_INT8,
> >> >MESA_FORMAT_BGRA_INT8_REV,
> >> >MESA_FORMAT_BGRA_UINT8,
> >> >MESA_FORMAT_BGRA_INT16,
> >> >MESA_FORMAT_BGRA_UINT16,
> >> >MESA_FORMAT_BGRA_FLOAT16,
> >> >MESA_FORMAT_BGRA_INT32,
> >> >MESA_FORMAT_BGRA_UINT32,
> >> >MESA_FORMAT_BGRA_FLOAT32,
> >> >MESA_FORMAT_BGRA,
> >> >MESA_FORMAT_BGRA_REV,
> >> >MESA_FORMAT_BGRA5551,
> >>
> >> All these look good.
> >>
> >> >MESA_FORMAT_BGRA1555_REV,
> >>
> >> I don't think you can have B with 1 bit.
>

Doesn't the _REV force A to be the first component, i.e. 1 bit? This format
is listed as valid in http://www.opengl.org/wiki/Pixel_Transfer - see below.


> >>
> >> >MESA_FORMAT_BGRA1010102,
> >>
> >> This one looks good.
> >>
> >> >MESA_FORMAT_BGRA2101010_REV,
> >>
> >> I don't think you can have B with 2 bits.
>

Same as above.


> >>
> >> >MESA_FORMAT_BGRA5999_REV,
> >>
> >> This one doesn't exist either and cannot be specified by TexImage.
>

You are correct according to the Pixel_Transfer spec, thanks.


> >
> >
> > BGRAs and RGBAs were based on this from the spec:
> > "GL_INVALID_OPERATION is generated if type is one of
> > GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
> > GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
> > GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,
> > GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV, or
> > GL_UNSIGNED_INT_5_9_9_9_REV, and format is neither GL_RGBA nor GL_BGRA."
>
> Nowhere can I see that B has 1 or 2 bits. Also the occurence of
> GL_UNSIGNED_INT_5_9_9_9_REV seems to be a spec bug, because it should
> be GL_RGB (the 5 bits contain a shared exponent).
>

It does appear to be a spec bug. Here is a quote from
http://www.opengl.org/wiki/Pixel_Transfer which addresses that an other
issues above:

"OpenGL restricts the possible sizes. They are:
* 3_3_2 (2_3_3_REV): unsigned bytes. Only used with GL_RGB.

* 5_6_5 (5_6_5_REV): unsigned shorts. Only used with GL_RGB.

* 4_4_4_4 (4_4_4_4_REV): unsigned shorts.

* 5_5_5_1 (1_5_5_5_REV): unsigned shorts.

* 8_8_8_8 (8_8_8_8_REV): unsigned ints.

* 10_10_10_2 (2_10_10_10_REV): unsigned ints.

* 24_8 (no _REV): unsigned ints. Only used with GL_DEPTH_STENCIL​.

* 10F_11F_11F_REV (no non-REV): unsigned ints. These represent floats, and
can only be used with GL_RGB​. This should only be used with images that
have the GL_R11F_G11F_B10F​ image format.

* 5_9_9_9_REV (no non-REV): unsigned ints. Only used with GL_RGB​; the last
component (the 5. It's REV) does not directly map to a color value. It is a
shared exponent. Only use this with images that have the GL_RGB9_E5​ image
format."


I'm working on V2 of this patch with incorporation of Marek, Brian's, and
Roland's feedback. I have also made changes as a result of further
development and testing on the i965 GPU texture upload work. I will be
posting that shortly.

Thanks Marek.

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


Re: [Mesa-dev] [PATCH 2/5] glsl: Get rid of hardcoded arrays of shader target names.

2013-12-17 Thread Brian Paul

On 12/17/2013 12:28 PM, Paul Berry wrote:

On 17 December 2013 10:51, Brian Paul mailto:bri...@vmware.com>> wrote:

On 12/17/2013 11:23 AM, Paul Berry wrote:

We already have a function for converting a shader type index to a
string: _mesa_glsl_shader_target_name(__).
---
   src/glsl/link_atomics.cpp |  8 +++-
   src/glsl/linker.cpp   | 16 ++--
   2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp
index 33903ad..cac5615 100644
--- a/src/glsl/link_atomics.cpp
+++ b/src/glsl/link_atomics.cpp
@@ -21,6 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/

+#include "glsl_parser_extras.h"
   #include "ir.h"
   #include "ir_uniform.h"
   #include "linker.h"
@@ -214,9 +215,6 @@ link_check_atomic_counter___resources(struct
gl_context *ctx,
   struct gl_shader_program
*prog)
   {
  STATIC_ASSERT(MESA_SHADER___TYPES == 3);
-   static const char *shader_names[MESA_SHADER___TYPES] = {
-  "vertex", "geometry", "fragment"
-   };
  const unsigned max_atomic_counters[MESA___SHADER_TYPES] = {
 ctx->Const.VertexProgram.__MaxAtomicCounters,
 ctx->Const.GeometryProgram.__MaxAtomicCounters,
@@ -260,11 +258,11 @@
link_check_atomic_counter___resources(struct gl_context *ctx,
  for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
 if (atomic_counters[i] > max_atomic_counters[i])
linker_error(prog, "Too many %s shader atomic counters",
-  shader_names[i]);
+
  _mesa_glsl_shader_target_name(__(gl_shader_type) i));

 if (atomic_buffers[i] > max_atomic_buffers[i])
linker_error(prog, "Too many %s shader atomic
counter buffers",
-  shader_names[i]);
+
  _mesa_glsl_shader_target_name(__(gl_shader_type) i));
  }

  if (total_atomic_counters >
ctx->Const.__MaxCombinedAtomicCounters)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index a6133ea..1406f13 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1893,10 +1893,6 @@ store_fragdepth_layout(struct
gl_shader_program *prog)
   static void
   check_resources(struct gl_context *ctx, struct
gl_shader_program *prog)
   {
-   static const char *const shader_names[MESA_SHADER___TYPES] = {
-  "vertex", "geometry", "fragment"
-   };
-
  const unsigned max_samplers[MESA_SHADER___TYPES] = {
 ctx->Const.VertexProgram.__MaxTextureImageUnits,
 ctx->Const.GeometryProgram.__MaxTextureImageUnits,
@@ -1929,7 +1925,7 @@ check_resources(struct gl_context *ctx,
struct gl_shader_program *prog)

 if (sh->num_samplers > max_samplers[i]) {
  linker_error(prog, "Too many %s shader texture samplers",
- shader_names[i]);
+
_mesa_glsl_shader_target_name(__(gl_shader_type) i));
 }

 if (sh->num_uniform_components >
max_default_uniform___components[i]) {
@@ -1938,11 +1934,11 @@ check_resources(struct gl_context *ctx,
struct gl_shader_program *prog)
  "components, but the driver will
try to optimize "
  "them out; this is non-portable
out-of-spec "
"behavior\n",
-   shader_names[i]);
+
_mesa_glsl_shader_target_name(__(gl_shader_type) i));
} else {
   linker_error(prog, "Too many %s shader default
uniform block "
  "components",
- shader_names[i]);
+
_mesa_glsl_shader_target_name(__(gl_shader_type) i));
}
 }

@@ -1952,10 +1948,10 @@ check_resources(struct gl_context *ctx,
struct gl_shader_program *prog)
   linker_warning(prog, "Too many %s shader uniform
components, "
  "but the driver will try to
optimize them out; "
  "this is non-portable out-of-spec
behavior\n",
-   shader_names[i]);
+
_mesa_glsl_shader_target_name(__(gl_shader_type) i));
} else {
   linker_error(prog, "Too many %s shader uniform
components",
- s

Re: [Mesa-dev] [PATCH 2/5] glsl: Get rid of hardcoded arrays of shader target names.

2013-12-17 Thread Paul Berry
On 17 December 2013 10:51, Brian Paul  wrote:

> On 12/17/2013 11:23 AM, Paul Berry wrote:
>
>> We already have a function for converting a shader type index to a
>> string: _mesa_glsl_shader_target_name().
>> ---
>>   src/glsl/link_atomics.cpp |  8 +++-
>>   src/glsl/linker.cpp   | 16 ++--
>>   2 files changed, 9 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp
>> index 33903ad..cac5615 100644
>> --- a/src/glsl/link_atomics.cpp
>> +++ b/src/glsl/link_atomics.cpp
>> @@ -21,6 +21,7 @@
>>* DEALINGS IN THE SOFTWARE.
>>*/
>>
>> +#include "glsl_parser_extras.h"
>>   #include "ir.h"
>>   #include "ir_uniform.h"
>>   #include "linker.h"
>> @@ -214,9 +215,6 @@ link_check_atomic_counter_resources(struct
>> gl_context *ctx,
>>   struct gl_shader_program *prog)
>>   {
>>  STATIC_ASSERT(MESA_SHADER_TYPES == 3);
>> -   static const char *shader_names[MESA_SHADER_TYPES] = {
>> -  "vertex", "geometry", "fragment"
>> -   };
>>  const unsigned max_atomic_counters[MESA_SHADER_TYPES] = {
>> ctx->Const.VertexProgram.MaxAtomicCounters,
>> ctx->Const.GeometryProgram.MaxAtomicCounters,
>> @@ -260,11 +258,11 @@ link_check_atomic_counter_resources(struct
>> gl_context *ctx,
>>  for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
>> if (atomic_counters[i] > max_atomic_counters[i])
>>linker_error(prog, "Too many %s shader atomic counters",
>> -  shader_names[i]);
>> +  _mesa_glsl_shader_target_name((gl_shader_type)
>> i));
>>
>> if (atomic_buffers[i] > max_atomic_buffers[i])
>>linker_error(prog, "Too many %s shader atomic counter buffers",
>> -  shader_names[i]);
>> +  _mesa_glsl_shader_target_name((gl_shader_type)
>> i));
>>  }
>>
>>  if (total_atomic_counters > ctx->Const.MaxCombinedAtomicCounters)
>> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
>> index a6133ea..1406f13 100644
>> --- a/src/glsl/linker.cpp
>> +++ b/src/glsl/linker.cpp
>> @@ -1893,10 +1893,6 @@ store_fragdepth_layout(struct gl_shader_program
>> *prog)
>>   static void
>>   check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
>>   {
>> -   static const char *const shader_names[MESA_SHADER_TYPES] = {
>> -  "vertex", "geometry", "fragment"
>> -   };
>> -
>>  const unsigned max_samplers[MESA_SHADER_TYPES] = {
>> ctx->Const.VertexProgram.MaxTextureImageUnits,
>> ctx->Const.GeometryProgram.MaxTextureImageUnits,
>> @@ -1929,7 +1925,7 @@ check_resources(struct gl_context *ctx, struct
>> gl_shader_program *prog)
>>
>> if (sh->num_samplers > max_samplers[i]) {
>>  linker_error(prog, "Too many %s shader texture samplers",
>> - shader_names[i]);
>> + _mesa_glsl_shader_target_name((gl_shader_type) i));
>> }
>>
>> if (sh->num_uniform_components > max_default_uniform_components[i])
>> {
>> @@ -1938,11 +1934,11 @@ check_resources(struct gl_context *ctx, struct
>> gl_shader_program *prog)
>>  "components, but the driver will try to
>> optimize "
>>  "them out; this is non-portable out-of-spec "
>>"behavior\n",
>> -   shader_names[i]);
>> +   _mesa_glsl_shader_target_name((gl_shader_type)
>> i));
>>} else {
>>   linker_error(prog, "Too many %s shader default uniform
>> block "
>>  "components",
>> - shader_names[i]);
>> + _mesa_glsl_shader_target_name((gl_shader_type)
>> i));
>>}
>> }
>>
>> @@ -1952,10 +1948,10 @@ check_resources(struct gl_context *ctx, struct
>> gl_shader_program *prog)
>>   linker_warning(prog, "Too many %s shader uniform
>> components, "
>>  "but the driver will try to optimize them
>> out; "
>>  "this is non-portable out-of-spec
>> behavior\n",
>> -   shader_names[i]);
>> +   _mesa_glsl_shader_target_name((gl_shader_type)
>> i));
>>} else {
>>   linker_error(prog, "Too many %s shader uniform components",
>> - shader_names[i]);
>> + _mesa_glsl_shader_target_name((gl_shader_type)
>> i));
>>}
>> }
>>  }
>> @@ -1979,7 +1975,7 @@ check_resources(struct gl_context *ctx, struct
>> gl_shader_program *prog)
>>  for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
>> if (blocks[i] > max_uniform_blocks[i]) {
>>linker_error(prog, "Too many %s uniform blocks (%d/%d)",
>> -   shader_names[i],
>> +   _mesa_glsl_shader_target_name((gl_shader_type)
>> 

Re: [Mesa-dev] [PATCH 2/5] glsl: Get rid of hardcoded arrays of shader target names.

2013-12-17 Thread Kenneth Graunke
On 12/17/2013 11:50 AM, Brian Paul wrote:
> On 12/17/2013 12:28 PM, Paul Berry wrote:
[snip]
>> How about this idea instead: rather than use function overloading to
>> distinguish between the two meanings of _mesa_glsl_shader_target_name(),
>> have two functions with separate names, e.g.:
>>
>> const char *_mesa_gl_shader_type_to_string(unsigned): converts
>> MESA_SHADER_VERTEX -> "vertex", etc.
>>
>> const char *_mesa_shader_target_enum_to_string(GLenum): converts
>> GL_VERTEX_SHADER -> "vertex", etc.
>>
>> That would eliminate the need for typecasts, and it would reduce the
>> danger of someone calling the wrong function by mistake.
> 
> That sounds fine.  Though I think slightly shorter functions names could
> be used:
> 
> _mesa_shader_type_to_string(), _mesa_shader_enum_to_string()
> 
> But no big deal.
> 
> -Brian

I like the idea of renaming the functions, and prefer the shorter names.

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


Re: [Mesa-dev] Testing optimizer

2013-12-17 Thread Paul Berry
On 17 December 2013 11:07, Patrick Baggett wrote:

>
>
>
> On Tue, Dec 17, 2013 at 10:59 AM, Paul Berry wrote:
>
>> On 17 December 2013 08:46, Tom Stellard  wrote:
>>
>>> On Tue, Dec 17, 2013 at 09:57:31AM -0600, Patrick Baggett wrote:
>>> > Hi all,
>>> >
>>> > Is there a way to see the machine code that is generated by the GLSL
>>> > compiler for all GPU instruction sets? For example, I would like to
>>> know if
>>> > the optimizer optimizes certain (equivalent) constructs (or not), and
>>> avoid
>>> > them if possible. I know there is a lot to optimization on GPUs that I
>>> > don't know, but I'd still like to get some ballpark estimates. For
>>> example,
>>> > I'm curious whether:
>>>
>>> Each driver has its own environment variable for dumping machine code.
>>>
>>> llvmpipe: GALLIVM_DEBUG=asm (I think you need to build mesa
>>>  with --enable-debug for this to work)
>>> r300g: RADEON_DEBUG=fp,vp
>>> r600g, radeonsi: R600_DEBUG=ps,vs
>>>
>>> I'm not sure what the other drivers use.
>>>
>>> -Tom
>>>
>>
>> I believe every driver also supports MESA_GLSL=dump, which prints out the
>> IR both before and after linking (you'll want to look at the version after
>> linking to see what optimizations have been applied, since some
>> optimizations happen at link time).  Looking at the IR rather than the
>> machine code is more likely to give you the information you need, since
>> Mesa performs the same IR-level optimizations on all architectures, whereas
>> the optimizations that happen at machine code level are vastly different
>> from one driver to the next.
>>
>>
> I do want to see both, actually. For example, if a driver implements a
> specific optimization (machine code level) and another driver clearly does
> not, then that would be considered "interesting" to me.
>

Ok, in that case the environment variable you want for seeing the generated
assembly code for Intel is:

INTEL_DEBUG=vs,fs,gs


>
>
>
>> Another thing which might be useful to you is Aras Pranckevičius's
>> "glsl-optimizer" project (https://github.com/aras-p/glsl-optimizer),
>> which performs Mesa's IR-level optimizations on a shader and then
>> translates it from IR back to GLSL.
>>
>> Paul
>>
>>
> Thanks to everyone for the great tips!
>
>
>>
>>> >
>>> > //let p1, p2, p3 be vec2 uniforms
>>> >
>>> > vec4(p1, 0, 0) + vec4(p2, 0, 0) + vec4(p3, 0, 1)
>>> >
>>> > produces identical machine code as:
>>> >
>>> > vec4(p1+p2+p3, 0, 1);
>>> >
>>> > for all architectures supported by Mesa.
>>>
>>> > ___
>>> > 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 mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/5] mesa: Improve static error checking of arrays sized by MESA_SHADER_TYPES.

2013-12-17 Thread Paul Berry
This patch replaces the following pattern:

foo bar[MESA_SHADER_TYPES] = {
   ...
};

With:

foo bar[] = {
   ...
};
STATIC_ASSERT(Elements(bar) == MESA_SHADER_TYPES);

This way, when a new shader type is added in a future version of Mesa,
we will get a compile error to remind us that the array needs to be
updated.
---
 src/glsl/link_atomics.cpp  |  7 ---
 src/glsl/linker.cpp| 14 ++
 src/mesa/program/program.h |  3 ++-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp
index cac5615..a53d4f4 100644
--- a/src/glsl/link_atomics.cpp
+++ b/src/glsl/link_atomics.cpp
@@ -214,17 +214,18 @@ void
 link_check_atomic_counter_resources(struct gl_context *ctx,
 struct gl_shader_program *prog)
 {
-   STATIC_ASSERT(MESA_SHADER_TYPES == 3);
-   const unsigned max_atomic_counters[MESA_SHADER_TYPES] = {
+   const unsigned max_atomic_counters[] = {
   ctx->Const.VertexProgram.MaxAtomicCounters,
   ctx->Const.GeometryProgram.MaxAtomicCounters,
   ctx->Const.FragmentProgram.MaxAtomicCounters
};
-   const unsigned max_atomic_buffers[MESA_SHADER_TYPES] = {
+   STATIC_ASSERT(Elements(max_atomic_counters) == MESA_SHADER_TYPES);
+   const unsigned max_atomic_buffers[] = {
   ctx->Const.VertexProgram.MaxAtomicBuffers,
   ctx->Const.GeometryProgram.MaxAtomicBuffers,
   ctx->Const.FragmentProgram.MaxAtomicBuffers
};
+   STATIC_ASSERT(Elements(max_atomic_buffers) == MESA_SHADER_TYPES);
unsigned num_buffers;
active_atomic_buffer *const abs =
   find_active_atomic_counters(ctx, prog, &num_buffers);
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index f2e91b2..bc04b41 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1894,29 +1894,35 @@ store_fragdepth_layout(struct gl_shader_program *prog)
 static void
 check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
 {
-   const unsigned max_samplers[MESA_SHADER_TYPES] = {
+   const unsigned max_samplers[] = {
   ctx->Const.VertexProgram.MaxTextureImageUnits,
   ctx->Const.GeometryProgram.MaxTextureImageUnits,
   ctx->Const.FragmentProgram.MaxTextureImageUnits
};
+   STATIC_ASSERT(Elements(max_samplers) == MESA_SHADER_TYPES);
 
-   const unsigned max_default_uniform_components[MESA_SHADER_TYPES] = {
+   const unsigned max_default_uniform_components[] = {
   ctx->Const.VertexProgram.MaxUniformComponents,
   ctx->Const.GeometryProgram.MaxUniformComponents,
   ctx->Const.FragmentProgram.MaxUniformComponents
};
+   STATIC_ASSERT(Elements(max_default_uniform_components) ==
+ MESA_SHADER_TYPES);
 
-   const unsigned max_combined_uniform_components[MESA_SHADER_TYPES] = {
+   const unsigned max_combined_uniform_components[] = {
   ctx->Const.VertexProgram.MaxCombinedUniformComponents,
   ctx->Const.GeometryProgram.MaxCombinedUniformComponents,
   ctx->Const.FragmentProgram.MaxCombinedUniformComponents
};
+   STATIC_ASSERT(Elements(max_combined_uniform_components) ==
+ MESA_SHADER_TYPES);
 
-   const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = {
+   const unsigned max_uniform_blocks[] = {
   ctx->Const.VertexProgram.MaxUniformBlocks,
   ctx->Const.GeometryProgram.MaxUniformBlocks,
   ctx->Const.FragmentProgram.MaxUniformBlocks
};
+   STATIC_ASSERT(Elements(max_uniform_blocks) == MESA_SHADER_TYPES);
 
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
   struct gl_shader *sh = prog->_LinkedShaders[i];
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 353ccab..135271c 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -210,11 +210,12 @@ _mesa_program_target_to_index(GLenum v)
 static inline GLenum
 _mesa_program_index_to_target(GLuint i)
 {
-   static const GLenum enums[MESA_SHADER_TYPES] = {
+   static const GLenum enums[] = {
   GL_VERTEX_PROGRAM_ARB,
   GL_GEOMETRY_PROGRAM_NV,
   GL_FRAGMENT_PROGRAM_ARB
};
+   STATIC_ASSERT(Elements(enums) == MESA_SHADER_TYPES);
if(i >= MESA_SHADER_TYPES)
   return 0;
else
-- 
1.8.4.2

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


[Mesa-dev] [PATCH 1/5] main: Remove unused function _mesa_shader_index_to_type().

2013-12-17 Thread Paul Berry
---
 src/mesa/main/shaderobj.h | 15 ---
 1 file changed, 15 deletions(-)

diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index de1c9fc..7245c5e 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -118,21 +118,6 @@ _mesa_shader_type_to_index(GLenum v)
 }
 
 
-static inline GLenum
-_mesa_shader_index_to_type(GLuint i)
-{
-   static const GLenum enums[MESA_SHADER_TYPES] = {
-  GL_VERTEX_SHADER,
-  GL_GEOMETRY_SHADER,
-  GL_FRAGMENT_SHADER
-   };
-   if (i >= MESA_SHADER_TYPES)
-  return 0;
-   else
-  return enums[i];
-}
-
-
 #ifdef __cplusplus
 }
 #endif
-- 
1.8.4.2

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


[Mesa-dev] [PATCH 3/5] glsl: Remove extraneous shader_type argument from analyze_clip_usage().

2013-12-17 Thread Paul Berry
This argument was carrying the name of the shader target (as a
string).  We can get this just as easily by calling
_mesa_glsl_shader_target_name().
---
 src/glsl/linker.cpp | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 1406f13..f2e91b2 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -414,7 +414,7 @@ link_invalidate_variable_locations(exec_list *ir)
  * Return false if an error was reported.
  */
 static void
-analyze_clip_usage(const char *shader_type, struct gl_shader_program *prog,
+analyze_clip_usage(struct gl_shader_program *prog,
struct gl_shader *shader, GLboolean *UsesClipDistance,
GLuint *ClipDistanceArraySize)
 {
@@ -437,7 +437,8 @@ analyze_clip_usage(const char *shader_type, struct 
gl_shader_program *prog,
   clip_distance.run(shader->ir);
   if (clip_vertex.variable_found() && clip_distance.variable_found()) {
  linker_error(prog, "%s shader writes to both `gl_ClipVertex' "
-  "and `gl_ClipDistance'\n", shader_type);
+  "and `gl_ClipDistance'\n",
+  _mesa_glsl_shader_target_name(shader->Type));
  return;
   }
   *UsesClipDistance = clip_distance.variable_found();
@@ -501,7 +502,7 @@ validate_vertex_shader_executable(struct gl_shader_program 
*prog,
   }
}
 
-   analyze_clip_usage("vertex", prog, shader, &prog->Vert.UsesClipDistance,
+   analyze_clip_usage(prog, shader, &prog->Vert.UsesClipDistance,
   &prog->Vert.ClipDistanceArraySize);
 }
 
@@ -548,7 +549,7 @@ validate_geometry_shader_executable(struct 
gl_shader_program *prog,
unsigned num_vertices = vertices_per_prim(prog->Geom.InputType);
prog->Geom.VerticesIn = num_vertices;
 
-   analyze_clip_usage("geometry", prog, shader, &prog->Geom.UsesClipDistance,
+   analyze_clip_usage(prog, shader, &prog->Geom.UsesClipDistance,
   &prog->Geom.ClipDistanceArraySize);
 
find_end_primitive_visitor end_primitive;
-- 
1.8.4.2

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


Re: [Mesa-dev] [PATCH 0/2] code de-duplication and non-pci support

2013-12-17 Thread Erik Faye-Lund
On Sat, Dec 14, 2013 at 8:28 PM, Rob Clark  wrote:
> From: Rob Clark 
>
> It seems that over time, code related to finding driver name, dealing
> with pci-id table, etc, has been copy/pasted everywhere it was needed.
> Which is lame.  And annoying if you have a device which is not pci.
>
> This patchset refactors it out into a simple loader util lib which is
> statically linked wherever it is needed.  Perhaps there is some room
> for sharing other util bits (like _eglLog, perhaps) later.
>
> And once all this code is collected in one place, the 2nd patch only
> has to fix one place to add support for platform devices ;-)
>
> Rob Clark (2):
>   loader: refactor duplicated code into loader util lib
>   loader: fallback to drmGetVersion() for non-pci devices
>

Nice. I've replaced Thierry's patch that does the latter, but only for
GBM, and the result still works fine. So:

Tested-by: Erik Faye-Lund 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Testing optimizer

2013-12-17 Thread Marek Olšák
ST_DEBUG=tgsi ... is also useful. It dumps all shaders generated by
mesa_to_tgsi and glsl_to_tgsi and it's easier to read than the GLSL
IR.

Marek

On Tue, Dec 17, 2013 at 5:46 PM, Tom Stellard  wrote:
> On Tue, Dec 17, 2013 at 09:57:31AM -0600, Patrick Baggett wrote:
>> Hi all,
>>
>> Is there a way to see the machine code that is generated by the GLSL
>> compiler for all GPU instruction sets? For example, I would like to know if
>> the optimizer optimizes certain (equivalent) constructs (or not), and avoid
>> them if possible. I know there is a lot to optimization on GPUs that I
>> don't know, but I'd still like to get some ballpark estimates. For example,
>> I'm curious whether:
>
> Each driver has its own environment variable for dumping machine code.
>
> llvmpipe: GALLIVM_DEBUG=asm (I think you need to build mesa
>  with --enable-debug for this to work)
> r300g: RADEON_DEBUG=fp,vp
> r600g, radeonsi: R600_DEBUG=ps,vs
>
> I'm not sure what the other drivers use.
>
> -Tom
>
>>
>> //let p1, p2, p3 be vec2 uniforms
>>
>> vec4(p1, 0, 0) + vec4(p2, 0, 0) + vec4(p3, 0, 1)
>>
>> produces identical machine code as:
>>
>> vec4(p1+p2+p3, 0, 1);
>>
>> for all architectures supported by Mesa.
>
>> ___
>> 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 mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] radeonsi: set CB_DISABLE if the color mask is 0

2013-12-17 Thread Marek Olšák
I don't think so.

Marek

On Tue, Dec 17, 2013 at 5:10 PM, Sylvain BERTRAND  wrote:
>>> From: Marek Olšák 
>>>
>>> Also needed for the DB in-place decompression according to hw docs.
>
> Published hw docs?
>
> regards,
>
> --
> Sylvain
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Testing optimizer

2013-12-17 Thread Paul Berry
On 17 December 2013 08:46, Tom Stellard  wrote:

> On Tue, Dec 17, 2013 at 09:57:31AM -0600, Patrick Baggett wrote:
> > Hi all,
> >
> > Is there a way to see the machine code that is generated by the GLSL
> > compiler for all GPU instruction sets? For example, I would like to know
> if
> > the optimizer optimizes certain (equivalent) constructs (or not), and
> avoid
> > them if possible. I know there is a lot to optimization on GPUs that I
> > don't know, but I'd still like to get some ballpark estimates. For
> example,
> > I'm curious whether:
>
> Each driver has its own environment variable for dumping machine code.
>
> llvmpipe: GALLIVM_DEBUG=asm (I think you need to build mesa
>  with --enable-debug for this to work)
> r300g: RADEON_DEBUG=fp,vp
> r600g, radeonsi: R600_DEBUG=ps,vs
>
> I'm not sure what the other drivers use.
>
> -Tom
>

I believe every driver also supports MESA_GLSL=dump, which prints out the
IR both before and after linking (you'll want to look at the version after
linking to see what optimizations have been applied, since some
optimizations happen at link time).  Looking at the IR rather than the
machine code is more likely to give you the information you need, since
Mesa performs the same IR-level optimizations on all architectures, whereas
the optimizations that happen at machine code level are vastly different
from one driver to the next.

Another thing which might be useful to you is Aras Pranckevičius's
"glsl-optimizer" project (https://github.com/aras-p/glsl-optimizer), which
performs Mesa's IR-level optimizations on a shader and then translates it
from IR back to GLSL.

Paul


> >
> > //let p1, p2, p3 be vec2 uniforms
> >
> > vec4(p1, 0, 0) + vec4(p2, 0, 0) + vec4(p3, 0, 1)
> >
> > produces identical machine code as:
> >
> > vec4(p1+p2+p3, 0, 1);
> >
> > for all architectures supported by Mesa.
>
> > ___
> > 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 mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Testing optimizer

2013-12-17 Thread Tom Stellard
On Tue, Dec 17, 2013 at 09:57:31AM -0600, Patrick Baggett wrote:
> Hi all,
> 
> Is there a way to see the machine code that is generated by the GLSL
> compiler for all GPU instruction sets? For example, I would like to know if
> the optimizer optimizes certain (equivalent) constructs (or not), and avoid
> them if possible. I know there is a lot to optimization on GPUs that I
> don't know, but I'd still like to get some ballpark estimates. For example,
> I'm curious whether:

Each driver has its own environment variable for dumping machine code.

llvmpipe: GALLIVM_DEBUG=asm (I think you need to build mesa
 with --enable-debug for this to work)
r300g: RADEON_DEBUG=fp,vp
r600g, radeonsi: R600_DEBUG=ps,vs

I'm not sure what the other drivers use.

-Tom

> 
> //let p1, p2, p3 be vec2 uniforms
> 
> vec4(p1, 0, 0) + vec4(p2, 0, 0) + vec4(p3, 0, 1)
> 
> produces identical machine code as:
> 
> vec4(p1+p2+p3, 0, 1);
> 
> for all architectures supported by Mesa.

> ___
> 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 v3 19/23] glsl: Add image built-in function generator.

2013-12-17 Thread Paul Berry
On 17 December 2013 02:10, Francisco Jerez  wrote:

> Because of the combinatorial explosion of different image built-ins
> with different image dimensionalities and base data types, enumerating
> all the 242 possibilities would be annoying and a waste of .text
> space.  Instead use a special path in the built-in builder that loops
> over all the known image types.
>
> v2: Generate built-ins on GLSL version 4.20 too.  Rename
> '_has_float_data_type' to '_supports_float_data_type'.  Avoid
> duplicating enumeration of image built-ins in create_intrinsics()
> and create_builtins().
> v3: Use a more orthodox approach for passing image built-in generator
> parameters.
> ---
>  src/glsl/builtin_functions.cpp | 267
> +
>  1 file changed, 267 insertions(+)
>
> diff --git a/src/glsl/builtin_functions.cpp
> b/src/glsl/builtin_functions.cpp
> index 4251948..90a9336 100644
> --- a/src/glsl/builtin_functions.cpp
> +++ b/src/glsl/builtin_functions.cpp
> @@ -334,6 +334,13 @@ shader_atomic_counters(const _mesa_glsl_parse_state
> *state)
> return state->ARB_shader_atomic_counters_enable;
>  }
>
> +static bool
> +shader_image_load_store(const _mesa_glsl_parse_state *state)
> +{
> +   return (state->is_version(420, 0) ||
> +   state->ARB_shader_image_load_store_enable);
> +}
> +
>  /** @} */
>
>
>  
> /**/
> @@ -407,6 +414,33 @@ private:
> /** Create a new function and add the given signatures. */
> void add_function(const char *name, ...);
>
> +   enum image_function_flags {
> +  IMAGE_FUNCTION_EMIT_STUB = (1 << 0),
> +  IMAGE_FUNCTION_HAS_RETURN = (1 << 1),
> +  IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE = (1 << 2),
> +  IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE = (1 << 3),
> +  IMAGE_FUNCTION_READ_ONLY = (1 << 4),
> +  IMAGE_FUNCTION_WRITE_ONLY = (1 << 5)
> +   };
> +
> +   /**
> +* Create a new image built-in function for all known image types.
> +* \p flags is a bitfield of \c image_function_flags flags.
> +*/
> +   void add_image_function(const char *name,
> +   const char *intrinsic_name,
> +   unsigned num_arguments,
> +   unsigned flags);
> +
> +   /**
> +* Create new functions for all known image built-ins and types.
> +* If \p glsl is \c true, use the GLSL built-in names and emit code
> +* to call into the actual compiler intrinsic.  If \p glsl is
> +* false, emit a function prototype with no body for each image
> +* intrinsic name.
> +*/
> +   void add_image_functions(bool glsl);
> +
> ir_function_signature *new_sig(const glsl_type *return_type,
>builtin_available_predicate avail,
>int num_params, ...);
> @@ -570,6 +604,20 @@ private:
> ir_function_signature *_atomic_op(const char *intrinsic,
>   builtin_available_predicate avail);
>
> +   ir_function_signature *_image_prototype(const glsl_type *image_type,
> +   const char *intrinsic_name,
> +   unsigned num_arguments,
> +   unsigned flags);
> +   ir_function_signature *_image(const glsl_type *image_type,
> + const char *intrinsic_name,
> + unsigned num_arguments,
> + unsigned flags);
> +
> +   ir_function_signature *_memory_barrier_intrinsic(
> +  builtin_available_predicate avail);
> +   ir_function_signature *_memory_barrier(
> +  builtin_available_predicate avail);
> +
>  #undef B0
>  #undef B1
>  #undef B2
> @@ -684,6 +732,12 @@ builtin_builder::create_intrinsics()
> add_function("__intrinsic_atomic_predecrement",
>  _atomic_intrinsic(shader_atomic_counters),
>  NULL);
> +
> +   add_image_functions(false);
> +
> +   add_function("__intrinsic_memory_barrier",
> +_memory_barrier_intrinsic(shader_image_load_store),
> +NULL);
>  }
>
>  /**
> @@ -2106,6 +2160,12 @@ builtin_builder::create_builtins()
> shader_atomic_counters),
>  NULL);
>
> +   add_image_functions(true);
> +
> +   add_function("memoryBarrier",
> +_memory_barrier(shader_image_load_store),
> +NULL);
> +
>  #undef F
>  #undef FI
>  #undef FIU
> @@ -2139,6 +2199,120 @@ builtin_builder::add_function(const char *name,
> ...)
> shader->symbols->add_function(f);
>  }
>
> +void
> +builtin_builder::add_image_function(const char *name,
> +const char *intrinsic_name,
> +unsigned num_arguments,
> +unsigned flags)
> +{
> +   static const glsl_type *const t

Re: [Mesa-dev] [PATCH] radeonsi: set CB_DISABLE if the color mask is 0

2013-12-17 Thread Sylvain BERTRAND
>> From: Marek Olšák 
>>
>> Also needed for the DB in-place decompression according to hw docs.

Published hw docs?

regards,

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


[Mesa-dev] [PATCH v2 1/1] clover: Add parameter checks to clCreateBuffer.

2013-12-17 Thread Jan Vesely
v2: use fewer if statements and functional tricks instead of single-use method,
suggested by Francisco Jerez
squash two small patches into one

Signed-off-by: Jan Vesely 
---
Hi,

this is v2 of the first two patches incorporating Francisco's comments,
i.e. it's the code from his comments :)

I squashed the two patches into one.
This patch makes the clCreateBuffer piglit test complain a lot less.


regards,
Jan

 src/gallium/state_trackers/clover/api/memory.cpp | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/api/memory.cpp 
b/src/gallium/state_trackers/clover/api/memory.cpp
index 785a509..3320db9 100644
--- a/src/gallium/state_trackers/clover/api/memory.cpp
+++ b/src/gallium/state_trackers/clover/api/memory.cpp
@@ -20,6 +20,7 @@
 // OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#include "util/u_math.h"
 #include "api/util.hpp"
 #include "core/memory.hpp"
 #include "core/format.hpp"
@@ -35,7 +36,8 @@ clCreateBuffer(cl_context d_ctx, cl_mem_flags flags, size_t 
size,
CL_MEM_COPY_HOST_PTR)))
   throw error(CL_INVALID_HOST_PTR);
 
-   if (!size)
+   if (!size || size > fold(maximum(), 0u,
+map(std::mem_fn(&device::max_mem_alloc_size), ctx.devs(
   throw error(CL_INVALID_BUFFER_SIZE);
 
if (flags & ~(CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY |
@@ -43,6 +45,14 @@ clCreateBuffer(cl_context d_ctx, cl_mem_flags flags, size_t 
size,
  CL_MEM_COPY_HOST_PTR))
   throw error(CL_INVALID_VALUE);
 
+   if (util_bitcount(flags & (CL_MEM_READ_ONLY | CL_MEM_WRITE_ONLY |
+  CL_MEM_READ_WRITE)) > 1)
+  throw error(CL_INVALID_VALUE);
+
+   if ((flags & CL_MEM_USE_HOST_PTR) &&
+   (flags & (CL_MEM_COPY_HOST_PTR | CL_MEM_ALLOC_HOST_PTR)))
+  throw error(CL_INVALID_VALUE);
+
ret_error(r_errcode, CL_SUCCESS);
return new root_buffer(ctx, flags, size, host_ptr);
 
-- 
1.8.3.1

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


Re: [Mesa-dev] [PATCH] radeonsi: set CB_DISABLE if the color mask is 0

2013-12-17 Thread Sylvain BERTRAND
> On Tue, Dec 17, 2013 at 7:54 AM, Marek Olšák  wrote:
>> From: Marek Olšák 
>>
>> Also needed for the DB in-place decompression according to hw docs.

Published hw docs?

regards,

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


[Mesa-dev] Testing optimizer

2013-12-17 Thread Patrick Baggett
Hi all,

Is there a way to see the machine code that is generated by the GLSL
compiler for all GPU instruction sets? For example, I would like to know if
the optimizer optimizes certain (equivalent) constructs (or not), and avoid
them if possible. I know there is a lot to optimization on GPUs that I
don't know, but I'd still like to get some ballpark estimates. For example,
I'm curious whether:

//let p1, p2, p3 be vec2 uniforms

vec4(p1, 0, 0) + vec4(p2, 0, 0) + vec4(p3, 0, 1)

produces identical machine code as:

vec4(p1+p2+p3, 0, 1);

for all architectures supported by Mesa.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] glcpp: error on multiple #else/#elif directives

2013-12-17 Thread Erik Faye-Lund
The preprocessor currently accepts multiple else/elif-groups
per if-section. The GLSL-preprocessor is defined by the C++
specification, which defines the following parse-rule:

if-section:
if-group elif-groups(opt) else-group(opt) endif-line

This clearly only allows a single else-group, that has to come
after any elif-groups.

So let's modify the code to follow the specification. Add test
to prevent regressions.
---

Here's a resend of an older patch (original
<1379968503-30246-1-git-send-email-kusmab...@gmail.com>), this time
with a better commit message, and a similar treatment for elif-after-else.

 src/glsl/glcpp/glcpp-parse.y   | 23 +-
 src/glsl/glcpp/glcpp.h |  1 +
 src/glsl/glcpp/tests/118-multiple-else.c   |  6 ++
 src/glsl/glcpp/tests/118-multiple-else.c.expected  |  8 
 src/glsl/glcpp/tests/119-elif-after-else.c |  6 ++
 .../glcpp/tests/119-elif-after-else.c.expected |  8 
 6 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 src/glsl/glcpp/tests/118-multiple-else.c
 create mode 100644 src/glsl/glcpp/tests/118-multiple-else.c.expected
 create mode 100644 src/glsl/glcpp/tests/119-elif-after-else.c
 create mode 100644 src/glsl/glcpp/tests/119-elif-after-else.c.expected

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 7edc274..451b728 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -310,6 +310,11 @@ control_line:
_glcpp_parser_expand_and_lex_from (parser,
   ELIF_EXPANDED, $2);
}
+   else if (parser->skip_stack &&
+   parser->skip_stack->has_else)
+   {
+   glcpp_error(& @1, parser, "#elif after #else");
+   }
else
{
_glcpp_parser_skip_stack_change_if (parser, & @1,
@@ -324,6 +329,11 @@ control_line:
{
glcpp_error(& @1, parser, "#elif with no expression");
}
+   else if (parser->skip_stack &&
+   parser->skip_stack->has_else)
+   {
+   glcpp_error(& @1, parser, "#elif after #else");
+   }
else
{
_glcpp_parser_skip_stack_change_if (parser, & @1,
@@ -332,7 +342,17 @@ control_line:
}
}
 |  HASH_ELSE {
-   _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1);
+   if (parser->skip_stack &&
+   parser->skip_stack->has_else)
+   {
+   glcpp_error(& @1, parser, "multiple #else");
+   }
+   else
+   {
+   _glcpp_parser_skip_stack_change_if (parser, & @1, 
"else", 1);
+   if (parser->skip_stack)
+   parser->skip_stack->has_else = true;
+   }
} NEWLINE
 |  HASH_ENDIF {
_glcpp_parser_skip_stack_pop (parser, & @1);
@@ -2024,6 +2044,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, 
YYLTYPE *loc,
node->type = SKIP_TO_ENDIF;
}
 
+   node->has_else = false;
node->next = parser->skip_stack;
parser->skip_stack = node;
 }
diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h
index 8aaa551..ccae96c 100644
--- a/src/glsl/glcpp/glcpp.h
+++ b/src/glsl/glcpp/glcpp.h
@@ -153,6 +153,7 @@ typedef enum skip_type {
 
 typedef struct skip_node {
skip_type_t type;
+   bool has_else;
YYLTYPE loc; /* location of the initial #if/#elif/... */
struct skip_node *next;
 } skip_node_t;
diff --git a/src/glsl/glcpp/tests/118-multiple-else.c 
b/src/glsl/glcpp/tests/118-multiple-else.c
new file mode 100644
index 000..62ad49c
--- /dev/null
+++ b/src/glsl/glcpp/tests/118-multiple-else.c
@@ -0,0 +1,6 @@
+#if 0
+#else
+int foo;
+#else
+int bar;
+#endif
diff --git a/src/glsl/glcpp/tests/118-multiple-else.c.expected 
b/src/glsl/glcpp/tests/118-multiple-else.c.expected
new file mode 100644
index 000..eaec481
--- /dev/null
+++ b/src/glsl/glcpp/tests/118-multiple-else.c.expected
@@ -0,0 +1,8 @@
+0:4(1): preprocessor error: multiple #else
+
+
+int foo;
+
+int bar;
+
+
diff --git a/src/glsl/glcpp/tests/119-elif-after-else.c 
b/src/glsl/glcpp/tests/119-elif-after-else.c
new file mode 100644
index 000..9b9e923
--- /dev/null
+++ b/src/glsl/glcpp/tests/119-elif-after-else.c
@@ -0,0 +1,6 @@
+#if 0
+#else
+int foo;
+#elif 0
+int bar;
+#endif
diff --git a/src/glsl/glcpp/tests/119-elif-after-else.c.expected 
b/src/glsl/glcpp/tests/119-elif-after-else.c.expected
new file mode 100644
index 000..33f0513
--- /dev/null
+++ b/src/glsl/glcpp/tests/119-elif-after-else.c.expected
@@ -0,0 +1,8 @@
+0:4(1): preprocessor er

[Mesa-dev] [PATCH] mesa: Fix build to properly check for supported compiler flags

2013-12-17 Thread Lauri Kasanen
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=72708

It seems to me that the Intel code that uses this SSE4.1 function
is still buggy, as it has no runtime check - would it not crash
if built on a SSE4-capable system but used with a lower-class cpu?

i965 systems = LGA775 = Pentium4 without SSE4.

Anyway, NMI.

Signed-off-by: Lauri Kasanen 
---
 configure.ac|  6 
 m4/ax_check_compile_flag.m4 | 72 +
 src/mesa/Makefile.am|  6 +++-
 3 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 m4/ax_check_compile_flag.m4

diff --git a/configure.ac b/configure.ac
index 6481627..3944084 100644
--- a/configure.ac
+++ b/configure.ac
@@ -231,6 +231,12 @@ AC_SUBST([VISIBILITY_CFLAGS])
 AC_SUBST([VISIBILITY_CXXFLAGS])
 
 dnl
+dnl Optional flags, check for compiler support
+dnl
+AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
+AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1])
+
+dnl
 dnl Hacks to enable 32 or 64 bit build
 dnl
 AC_ARG_ENABLE([32-bit],
diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4
new file mode 100644
index 000..c3a8d69
--- /dev/null
+++ b/m4/ax_check_compile_flag.m4
@@ -0,0 +1,72 @@
+# ===
+#   http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===
+#
+# SYNOPSIS
+#
+#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], 
[EXTRA-FLAGS])
+#
+# DESCRIPTION
+#
+#   Check whether the given FLAG works with the current language's compiler
+#   or gives an error.  (Warnings, however, are ignored)
+#
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+#   success/failure.
+#
+#   If EXTRA-FLAGS is defined, it is added to the current language's default
+#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
+#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
+#   force the compiler to issue an error when a bad flag is given.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+#   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim 
+#   Copyright (c) 2011 Maarten Bosmans 
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see .
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 2
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+[AS_VAR_SET(CACHEVAR,[yes])],
+[AS_VAR_SET(CACHEVAR,[no])])
+  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
+  [m4_default([$2], :)],
+  [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am
index a60600e..8843836 100644
--- a/src/mesa/Makefile.am
+++ b/src/mesa/Makefile.am
@@ -103,7 +103,11 @@ noinst_PROGRAMS = gen_matypes
 gen_matypes_SOURCES = x86/gen_matypes.c
 BUILT_SOURCES += matypes.h
 
-ARCH_LIBS = libmesa_sse41.la
+ARCH_LIBS =
+
+if SSE41_SUPPORTED
+ARCH_LIBS += libmesa_sse41.la
+endif
 
 if HAVE_X86_64_ASM
 MESA_ASM_FILES_FOR_ARCH += $(X86_64_FILES)
-- 
1.8.3.1

_

Re: [Mesa-dev] [PATCH] radeonsi: set CB_DISABLE if the color mask is 0

2013-12-17 Thread Alex Deucher
On Tue, Dec 17, 2013 at 7:54 AM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> Also needed for the DB in-place decompression according to hw docs.

Makes sense.

Reviewed-by: Alex Deucher 

> ---
>  src/gallium/drivers/radeonsi/si_state.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state.c 
> b/src/gallium/drivers/radeonsi/si_state.c
> index 5c18538..5274eff 100644
> --- a/src/gallium/drivers/radeonsi/si_state.c
> +++ b/src/gallium/drivers/radeonsi/si_state.c
> @@ -252,20 +252,18 @@ static void *si_create_blend_state_mode(struct 
> pipe_context *ctx,
> struct si_state_blend *blend = CALLOC_STRUCT(si_state_blend);
> struct si_pm4_state *pm4 = &blend->pm4;
>
> -   uint32_t color_control;
> +   uint32_t color_control = 0;
>
> if (blend == NULL)
> return NULL;
>
> blend->alpha_to_one = state->alpha_to_one;
>
> -   color_control = S_028808_MODE(mode);
> if (state->logicop_enable) {
> color_control |= S_028808_ROP3(state->logicop_func | 
> (state->logicop_func << 4));
> } else {
> color_control |= S_028808_ROP3(0xcc);
> }
> -   si_pm4_set_reg(pm4, R_028808_CB_COLOR_CONTROL, color_control);
>
> si_pm4_set_reg(pm4, R_028B70_DB_ALPHA_TO_MASK,
>
> S_028B70_ALPHA_TO_MASK_ENABLE(state->alpha_to_coverage) |
> @@ -310,6 +308,13 @@ static void *si_create_blend_state_mode(struct 
> pipe_context *ctx,
> si_pm4_set_reg(pm4, R_028780_CB_BLEND0_CONTROL + i * 4, 
> blend_cntl);
> }
>
> +   if (blend->cb_target_mask) {
> +   color_control |= S_028808_MODE(mode);
> +   } else {
> +   color_control |= S_028808_MODE(V_028808_CB_DISABLE);
> +   }
> +   si_pm4_set_reg(pm4, R_028808_CB_COLOR_CONTROL, color_control);
> +
> return blend;
>  }
>
> --
> 1.8.3.2
>
> ___
> 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] radeonsi: add the htile buffer to the CS ioctl buffer list

2013-12-17 Thread Alex Deucher
On Tue, Dec 17, 2013 at 6:49 AM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> This may fix the GPU crashes.


Reviewed-by: Alex Deucher 

> ---
>  src/gallium/drivers/radeonsi/si_state.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state.c 
> b/src/gallium/drivers/radeonsi/si_state.c
> index c1107c6..5c18538 100644
> --- a/src/gallium/drivers/radeonsi/si_state.c
> +++ b/src/gallium/drivers/radeonsi/si_state.c
> @@ -1825,6 +1825,8 @@ static void si_db(struct r600_context *rctx, struct 
> si_pm4_state *pm4,
> uint64_t va = r600_resource_va(&rctx->screen->b.b, 
> &rtex->htile_buffer->b.b);
> db_htile_data_base = va >> 8;
> db_htile_surface = S_028ABC_FULL_CACHE(1);
> +
> +   si_pm4_add_bo(pm4, rtex->htile_buffer, 
> RADEON_USAGE_READWRITE);
> } else {
> db_htile_data_base = 0;
> db_htile_surface = 0;
> --
> 1.8.3.2
>
> ___
> 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] glcpp: error on multiple #else directives

2013-12-17 Thread Erik Faye-Lund
On Fri, Oct 11, 2013 at 10:48 PM, Ian Romanick  wrote:
> Carl,
>
> Can you look at this patch and Erik's follow-up patch?  You (still) know
> the glcpp much better than any of the rest of us.
>
> (Carl is currently out of town, so I know his response will be slow...)
>

I guess "slow" doesn't mean *this* slow? :)

Should I resend the patch, with the #elseif fix squashed in?

> On 09/23/2013 01:35 PM, Erik Faye-Lund wrote:
>> The preprocessor currently eats multiple #else directives
>> int the same #if(def) ... #endif block. While I haven't been able
>> to find anything that explicitly disallows it, it's nonsensical
>> and should probably not be allowed.
>>
>> Add checks to reject the code.
>> ---
>>
>> I'm not entirely sure why parser->skip_stack can be NULL after
>> _glcpp_parser_skip_stack_change_if, but apparently it is for at
>> least one test.
>>
>> I'm also not entirely sure if this should be an error or a warning.
>> Thoughts?
>>
>>  src/glsl/glcpp/glcpp-parse.y  | 13 -
>>  src/glsl/glcpp/glcpp.h|  1 +
>>  src/glsl/glcpp/tests/118-multiple-else.c  |  6 ++
>>  src/glsl/glcpp/tests/118-multiple-else.c.expected |  8 
>>  4 files changed, 27 insertions(+), 1 deletion(-)
>>  create mode 100644 src/glsl/glcpp/tests/118-multiple-else.c
>>  create mode 100644 src/glsl/glcpp/tests/118-multiple-else.c.expected
>>
>> diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
>> index 6eaa5f9..885c64d 100644
>> --- a/src/glsl/glcpp/glcpp-parse.y
>> +++ b/src/glsl/glcpp/glcpp-parse.y
>> @@ -332,7 +332,17 @@ control_line:
>>   }
>>   }
>>  |HASH_ELSE {
>> - _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1);
>> + if (parser->skip_stack &&
>> + parser->skip_stack->has_else)
>> + {
>> + glcpp_error(& @1, parser, "multiple #else");
>> + }
>> + else
>> + {
>> + _glcpp_parser_skip_stack_change_if (parser, & @1, 
>> "else", 1);
>> + if (parser->skip_stack)
>> + parser->skip_stack->has_else = true;
>> + }
>>   } NEWLINE
>>  |HASH_ENDIF {
>>   _glcpp_parser_skip_stack_pop (parser, & @1);
>> @@ -2012,6 +2022,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t 
>> *parser, YYLTYPE *loc,
>>   node->type = SKIP_TO_ENDIF;
>>   }
>>
>> + node->has_else = false;
>>   node->next = parser->skip_stack;
>>   parser->skip_stack = node;
>>  }
>> diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h
>> index 8aaa551..ccae96c 100644
>> --- a/src/glsl/glcpp/glcpp.h
>> +++ b/src/glsl/glcpp/glcpp.h
>> @@ -153,6 +153,7 @@ typedef enum skip_type {
>>
>>  typedef struct skip_node {
>>   skip_type_t type;
>> + bool has_else;
>>   YYLTYPE loc; /* location of the initial #if/#elif/... */
>>   struct skip_node *next;
>>  } skip_node_t;
>> diff --git a/src/glsl/glcpp/tests/118-multiple-else.c 
>> b/src/glsl/glcpp/tests/118-multiple-else.c
>> new file mode 100644
>> index 000..62ad49c
>> --- /dev/null
>> +++ b/src/glsl/glcpp/tests/118-multiple-else.c
>> @@ -0,0 +1,6 @@
>> +#if 0
>> +#else
>> +int foo;
>> +#else
>> +int bar;
>> +#endif
>> diff --git a/src/glsl/glcpp/tests/118-multiple-else.c.expected 
>> b/src/glsl/glcpp/tests/118-multiple-else.c.expected
>> new file mode 100644
>> index 000..eaec481
>> --- /dev/null
>> +++ b/src/glsl/glcpp/tests/118-multiple-else.c.expected
>> @@ -0,0 +1,8 @@
>> +0:4(1): preprocessor error: multiple #else
>> +
>> +
>> +int foo;
>> +
>> +int bar;
>> +
>> +
>>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] st/dri: Check for kernel support before enabling fd sharing

2013-12-17 Thread Thomas Hellstrom
The dri2 state tracker is checking for driver support before enabling
dri2ImageExtension version 7. This commit adds a check that also the
kernel driver supports fd sharing through prime.

Note that this adds a libdrm dependency on dri2.c.

Signed-off-by: Thomas Hellstrom 
---
 src/gallium/state_trackers/dri/drm/dri2.c |   13 +++--
 src/gallium/targets/dri-vmwgfx/target.c   |6 --
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 8ff77b3..b9f6928 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -28,6 +28,7 @@
  * Chia-I Wu 
  */
 
+#include 
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
 #include "util/u_format.h"
@@ -1051,10 +1052,18 @@ dri2_init_screen(__DRIscreen * sPriv)
   screen->default_throttle_frames = throttle_ret->val.val_int;
}
 
+#ifdef DRM_CAP_PRIME /* Old libdrm? */
if (dmabuf_ret && dmabuf_ret->val.val_bool) {
-  dri2ImageExtension.base.version = 7;
-  dri2ImageExtension.createImageFromFds = dri2_from_fds;
+  uint64_t cap;
+
+  if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
+  !!(cap & DRM_PRIME_CAP_IMPORT)) {
+
+ dri2ImageExtension.base.version = 7;
+ dri2ImageExtension.createImageFromFds = dri2_from_fds;
+  }
}
+#endif /* DRM_CAP_PRIME */
 
sPriv->extensions = dri_screen_extensions;
 
diff --git a/src/gallium/targets/dri-vmwgfx/target.c 
b/src/gallium/targets/dri-vmwgfx/target.c
index aaf37b0..e3fbda1 100644
--- a/src/gallium/targets/dri-vmwgfx/target.c
+++ b/src/gallium/targets/dri-vmwgfx/target.c
@@ -31,12 +31,6 @@ static const struct drm_conf_ret throttle_ret = {
.val.val_int = 2,
 };
 
-/* Technically this requires kernel support that is not yet
- * widespread.
- *
- * We could check for support in create_screen and return the correct
- * value, but for now just return true in all cases.
- */
 static const struct drm_conf_ret share_fd_ret = {
.type = DRM_CONF_BOOL,
.val.val_int = true,
-- 
1.7.10.4
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] radeonsi: set CB_DISABLE if the color mask is 0

2013-12-17 Thread Marek Olšák
From: Marek Olšák 

Also needed for the DB in-place decompression according to hw docs.
---
 src/gallium/drivers/radeonsi/si_state.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 5c18538..5274eff 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -252,20 +252,18 @@ static void *si_create_blend_state_mode(struct 
pipe_context *ctx,
struct si_state_blend *blend = CALLOC_STRUCT(si_state_blend);
struct si_pm4_state *pm4 = &blend->pm4;
 
-   uint32_t color_control;
+   uint32_t color_control = 0;
 
if (blend == NULL)
return NULL;
 
blend->alpha_to_one = state->alpha_to_one;
 
-   color_control = S_028808_MODE(mode);
if (state->logicop_enable) {
color_control |= S_028808_ROP3(state->logicop_func | 
(state->logicop_func << 4));
} else {
color_control |= S_028808_ROP3(0xcc);
}
-   si_pm4_set_reg(pm4, R_028808_CB_COLOR_CONTROL, color_control);
 
si_pm4_set_reg(pm4, R_028B70_DB_ALPHA_TO_MASK,
   S_028B70_ALPHA_TO_MASK_ENABLE(state->alpha_to_coverage) |
@@ -310,6 +308,13 @@ static void *si_create_blend_state_mode(struct 
pipe_context *ctx,
si_pm4_set_reg(pm4, R_028780_CB_BLEND0_CONTROL + i * 4, 
blend_cntl);
}
 
+   if (blend->cb_target_mask) {
+   color_control |= S_028808_MODE(mode);
+   } else {
+   color_control |= S_028808_MODE(V_028808_CB_DISABLE);
+   }
+   si_pm4_set_reg(pm4, R_028808_CB_COLOR_CONTROL, color_control);
+
return blend;
 }
 
-- 
1.8.3.2

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


[Mesa-dev] [PATCH] radeonsi: add the htile buffer to the CS ioctl buffer list

2013-12-17 Thread Marek Olšák
From: Marek Olšák 

This may fix the GPU crashes.
---
 src/gallium/drivers/radeonsi/si_state.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index c1107c6..5c18538 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1825,6 +1825,8 @@ static void si_db(struct r600_context *rctx, struct 
si_pm4_state *pm4,
uint64_t va = r600_resource_va(&rctx->screen->b.b, 
&rtex->htile_buffer->b.b);
db_htile_data_base = va >> 8;
db_htile_surface = S_028ABC_FULL_CACHE(1);
+
+   si_pm4_add_bo(pm4, rtex->htile_buffer, RADEON_USAGE_READWRITE);
} else {
db_htile_data_base = 0;
db_htile_surface = 0;
-- 
1.8.3.2

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


Re: [Mesa-dev] [PATCH 1/3] radeonsi: flush HTILE when appropriate

2013-12-17 Thread Marek Olšák
It doesn't fix the corruption in Sanctuary. I haven't been able to
reproduce the GPU crashes though (I don't have Serious Sam 3 or
Skyrim). I agree it should be disabled by default if we don't find a
fix quickly.

Marek

On Tue, Dec 17, 2013 at 9:44 AM, Michel Dänzer  wrote:
> On Die, 2013-12-17 at 03:31 +0100, Marek Olšák wrote:
>> From: Marek Olšák 
>
> This series is
>
> Reviewed-by: Michel Dänzer 
>
>
> Does this address bugs such as
> https://bugs.freedesktop.org/show_bug.cgi?id=72685 and
> https://bugzilla.kernel.org/show_bug.cgi?id=66981 ? If not, HyperZ
> should probably be disabled by default for now.
>
>
> --
> Earthling Michel Dänzer|  http://www.amd.com
> Libre software enthusiast  |Mesa and X developer
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 19/23] glsl: Add image built-in function generator.

2013-12-17 Thread Francisco Jerez
Because of the combinatorial explosion of different image built-ins
with different image dimensionalities and base data types, enumerating
all the 242 possibilities would be annoying and a waste of .text
space.  Instead use a special path in the built-in builder that loops
over all the known image types.

v2: Generate built-ins on GLSL version 4.20 too.  Rename
'_has_float_data_type' to '_supports_float_data_type'.  Avoid
duplicating enumeration of image built-ins in create_intrinsics()
and create_builtins().
v3: Use a more orthodox approach for passing image built-in generator
parameters.
---
 src/glsl/builtin_functions.cpp | 267 +
 1 file changed, 267 insertions(+)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 4251948..90a9336 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -334,6 +334,13 @@ shader_atomic_counters(const _mesa_glsl_parse_state *state)
return state->ARB_shader_atomic_counters_enable;
 }
 
+static bool
+shader_image_load_store(const _mesa_glsl_parse_state *state)
+{
+   return (state->is_version(420, 0) ||
+   state->ARB_shader_image_load_store_enable);
+}
+
 /** @} */
 
 
/**/
@@ -407,6 +414,33 @@ private:
/** Create a new function and add the given signatures. */
void add_function(const char *name, ...);
 
+   enum image_function_flags {
+  IMAGE_FUNCTION_EMIT_STUB = (1 << 0),
+  IMAGE_FUNCTION_HAS_RETURN = (1 << 1),
+  IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE = (1 << 2),
+  IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE = (1 << 3),
+  IMAGE_FUNCTION_READ_ONLY = (1 << 4),
+  IMAGE_FUNCTION_WRITE_ONLY = (1 << 5)
+   };
+
+   /**
+* Create a new image built-in function for all known image types.
+* \p flags is a bitfield of \c image_function_flags flags.
+*/
+   void add_image_function(const char *name,
+   const char *intrinsic_name,
+   unsigned num_arguments,
+   unsigned flags);
+
+   /**
+* Create new functions for all known image built-ins and types.
+* If \p glsl is \c true, use the GLSL built-in names and emit code
+* to call into the actual compiler intrinsic.  If \p glsl is
+* false, emit a function prototype with no body for each image
+* intrinsic name.
+*/
+   void add_image_functions(bool glsl);
+
ir_function_signature *new_sig(const glsl_type *return_type,
   builtin_available_predicate avail,
   int num_params, ...);
@@ -570,6 +604,20 @@ private:
ir_function_signature *_atomic_op(const char *intrinsic,
  builtin_available_predicate avail);
 
+   ir_function_signature *_image_prototype(const glsl_type *image_type,
+   const char *intrinsic_name,
+   unsigned num_arguments,
+   unsigned flags);
+   ir_function_signature *_image(const glsl_type *image_type,
+ const char *intrinsic_name,
+ unsigned num_arguments,
+ unsigned flags);
+
+   ir_function_signature *_memory_barrier_intrinsic(
+  builtin_available_predicate avail);
+   ir_function_signature *_memory_barrier(
+  builtin_available_predicate avail);
+
 #undef B0
 #undef B1
 #undef B2
@@ -684,6 +732,12 @@ builtin_builder::create_intrinsics()
add_function("__intrinsic_atomic_predecrement",
 _atomic_intrinsic(shader_atomic_counters),
 NULL);
+
+   add_image_functions(false);
+
+   add_function("__intrinsic_memory_barrier",
+_memory_barrier_intrinsic(shader_image_load_store),
+NULL);
 }
 
 /**
@@ -2106,6 +2160,12 @@ builtin_builder::create_builtins()
shader_atomic_counters),
 NULL);
 
+   add_image_functions(true);
+
+   add_function("memoryBarrier",
+_memory_barrier(shader_image_load_store),
+NULL);
+
 #undef F
 #undef FI
 #undef FIU
@@ -2139,6 +2199,120 @@ builtin_builder::add_function(const char *name, ...)
shader->symbols->add_function(f);
 }
 
+void
+builtin_builder::add_image_function(const char *name,
+const char *intrinsic_name,
+unsigned num_arguments,
+unsigned flags)
+{
+   static const glsl_type *const types[] = {
+  glsl_type::image1D_type,
+  glsl_type::image2D_type,
+  glsl_type::image3D_type,
+  glsl_type::image2DRect_type,
+  glsl_type::imageCube_type,
+  glsl_type::imageBuffer_type,
+  glsl_type::image1DArray_type,
+  glsl_type::image2DArray_type,
+  glsl_t

Re: [Mesa-dev] [PATCH 1/3] radeonsi: flush HTILE when appropriate

2013-12-17 Thread Michel Dänzer
On Die, 2013-12-17 at 03:31 +0100, Marek Olšák wrote:
> From: Marek Olšák 

This series is

Reviewed-by: Michel Dänzer 


Does this address bugs such as
https://bugs.freedesktop.org/show_bug.cgi?id=72685 and
https://bugzilla.kernel.org/show_bug.cgi?id=66981 ? If not, HyperZ
should probably be disabled by default for now.


-- 
Earthling Michel Dänzer|  http://www.amd.com
Libre software enthusiast  |Mesa and X developer

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


Re: [Mesa-dev] [PATCH 0/2] v3: Fix array overrun with too many uniforms

2013-12-17 Thread Petri Latvala

On 11/27/2013 03:28 PM, Petri Latvala wrote:

Third version of this patch series sent in full



Ping? Comments, NAKs, ACKs...?


--
Petri Latvala

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