Re: [Mesa-dev] [PATCH v3 0/6] support config for third-party DRI driver load

2018-08-17 Thread Yu, Qiang
Thanks Emil.

> - missing include  (for PATH_MAX) in patch 1
Although I can compile without , I agree to add it explicitly.

> - added HAVE_LIBDRM guard for __driConfigOptionsLoader and
> loader_get_dri_config_driver
My thoughts are:
1. __driConfigOptionsLoader and loader_get_dri_config_driver don't
have code depend on HAVE_LIBDRM (loader_get_kernel_driver_name
does but already has HAVE_LIBDRM), so it's OK to drop HAVE_LIBDRM
2. if drop HAVE_LIBDRM, user can still use dri_driver option to change
dri driver to load even on non-libdrm env (although I'm not clear if this
kind of env need this functionality)

Regards,
Qiang
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] docs: Python 2.7 or later is required.

2018-08-17 Thread Matt Turner
Reviewed-by: Matt Turner 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/4] nir: mark *prev_block as MAYBE_UNUSED in opt_peel_loop_initial_if

2018-08-17 Thread Timothy Arceri

On 18/08/18 10:28, Timothy Arceri wrote:

Thanks I'd been meaning to do this too.

Reviewed-by: Timothy Arceri 

Do you have commit access?


Nevermind I should have read the cover letter. I'll push the first 3, 
I'll leave patch 4 for someone at AMD to comment on. I think all that 
code gets imported from a shared AMD project.




On 18/08/18 00:32, Kai Wasserbäch wrote:

Only used, when asserts are enabled.

Fixes an unused-variable warning with gcc-8:
  ../../../src/compiler/nir/nir_opt_if.c: In function 
'opt_peel_loop_initial_if':
  ../../../src/compiler/nir/nir_opt_if.c:109:15: warning: unused 
variable 'prev_block' [-Wunused-variable]

  nir_block *prev_block =
 ^~

Signed-off-by: Kai Wasserbäch 
---
  src/compiler/nir/nir_opt_if.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_opt_if.c 
b/src/compiler/nir/nir_opt_if.c

index b3d0bf1dec..dacf2d6c66 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -106,7 +106,7 @@ static bool
  opt_peel_loop_initial_if(nir_loop *loop)
  {
 nir_block *header_block = nir_loop_first_block(loop);
-   nir_block *prev_block =
+   MAYBE_UNUSED nir_block *prev_block =
    nir_cf_node_as_block(nir_cf_node_prev(&loop->cf_node));
 /* It would be insane if this were not true */


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

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


Re: [Mesa-dev] [PATCH 2/4] nir: mark *prev_block as MAYBE_UNUSED in opt_peel_loop_initial_if

2018-08-17 Thread Timothy Arceri

Thanks I'd been meaning to do this too.

Reviewed-by: Timothy Arceri 

Do you have commit access?

On 18/08/18 00:32, Kai Wasserbäch wrote:

Only used, when asserts are enabled.

Fixes an unused-variable warning with gcc-8:
  ../../../src/compiler/nir/nir_opt_if.c: In function 
'opt_peel_loop_initial_if':
  ../../../src/compiler/nir/nir_opt_if.c:109:15: warning: unused variable 
'prev_block' [-Wunused-variable]
  nir_block *prev_block =
 ^~

Signed-off-by: Kai Wasserbäch 
---
  src/compiler/nir/nir_opt_if.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
index b3d0bf1dec..dacf2d6c66 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -106,7 +106,7 @@ static bool
  opt_peel_loop_initial_if(nir_loop *loop)
  {
 nir_block *header_block = nir_loop_first_block(loop);
-   nir_block *prev_block =
+   MAYBE_UNUSED nir_block *prev_block =
nir_cf_node_as_block(nir_cf_node_prev(&loop->cf_node));
  
 /* It would be insane if this were not true */



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


[Mesa-dev] [PATCH] anv/icl: Allow headerless sampler messages for pre-emptable contexts

2018-08-17 Thread Anuj Phogat
It fixes simulator warnings in vulkancts tests complaining about missing
support for headerless sampler messages for pre-emptable contexts.
Bit 5 in SAMPLER MODE register is newly introduced for ICLLP.

Signed-off-by: Anuj Phogat 
---
 src/intel/genxml/gen11.xml|  5 +
 src/intel/vulkan/genX_state.c | 17 +
 2 files changed, 22 insertions(+)

diff --git a/src/intel/genxml/gen11.xml b/src/intel/genxml/gen11.xml
index bd3800e4b79..1b3befbbfc9 100644
--- a/src/intel/genxml/gen11.xml
+++ b/src/intel/genxml/gen11.xml
@@ -3635,4 +3635,9 @@
 
   
 
+  
+
+
+  
+
 
diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c
index b1014d9e797..5b1b084a580 100644
--- a/src/intel/vulkan/genX_state.c
+++ b/src/intel/vulkan/genX_state.c
@@ -157,6 +157,23 @@ genX(init_device_state)(struct anv_device *device)
gen10_emit_wa_lri_to_cache_mode_zero(&batch);
 #endif
 
+#if GEN_GEN == 11
+   /*  The default behavior of bit 5 "Headerless Message for Pre-emptable
+*  Contexts" in SAMPLER MODE register is set to 0, which means
+*  headerless sampler messages are not allowed for pre-emptable
+*  contexts. Set the bit 5 to 1 to allow them.
+*/
+   uint32_t sampler_mode;
+   anv_pack_struct(&sampler_mode, GENX(SAMPLER_MODE),
+   .HeaderlessMessageforPreemptableContexts = true,
+   .HeaderlessMessageforPreemptableContextsMask = true);
+
+anv_batch_emit(&batch, GENX(MI_LOAD_REGISTER_IMM), lri) {
+  lri.RegisterOffset = GENX(SAMPLER_MODE_num);
+  lri.DataDWord  = sampler_mode;
+   }
+#endif
+
/* Set the "CONSTANT_BUFFER Address Offset Disable" bit, so
 * 3DSTATE_CONSTANT_XS buffer 0 is an absolute address.
 *
-- 
2.17.0

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


[Mesa-dev] [PATCH] anv/icl: Disable binding table prefetching

2018-08-17 Thread Anuj Phogat
Gen 11 workarounds table #2056 WABTPPrefetchDisable suggests to
disable prefetching of binding tables for ICLLP A0 and B0
steppings. We have a similar patch for i965 driver in  Mesa
commit a5889d70.

Signed-off-by: Anuj Phogat 
---
 src/intel/vulkan/genX_pipeline.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index ec47360764c..078fb14e954 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -1136,7 +1136,11 @@ emit_3dstate_vs(struct anv_pipeline *pipeline)
 #endif
   vs.VectorMaskEnable   = false;
   vs.SamplerCount   = get_sampler_count(vs_bin);
-  vs.BindingTableEntryCount = get_binding_table_entry_count(vs_bin);
+ /* Gen 11 workarounds table #2056 WABTPPrefetchDisable suggests to
+  * disable prefetching of binding tables on A0 and B0 steppings.
+  * TODO: Revisit this WA on newer steppings.
+  */
+  vs.BindingTableEntryCount = GEN_GEN == 11 ? 0 : 
get_binding_table_entry_count(vs_bin);
   vs.FloatingPointMode  = IEEE754;
   vs.IllegalOpcodeExceptionEnable = false;
   vs.SoftwareExceptionEnable= false;
@@ -1187,7 +1191,8 @@ emit_3dstate_hs_te_ds(struct anv_pipeline *pipeline,
   hs.KernelStartPointer = tcs_bin->kernel.offset;
 
   hs.SamplerCount = get_sampler_count(tcs_bin);
-  hs.BindingTableEntryCount = get_binding_table_entry_count(tcs_bin);
+  /* Gen 11 workarounds table #2056 WABTPPrefetchDisable */
+  hs.BindingTableEntryCount = GEN_GEN == 11 ? 0 : 
get_binding_table_entry_count(tcs_bin);
   hs.MaximumNumberofThreads = devinfo->max_tcs_threads - 1;
   hs.IncludeVertexHandles = true;
   hs.InstanceCount = tcs_prog_data->instances - 1;
@@ -1237,7 +1242,8 @@ emit_3dstate_hs_te_ds(struct anv_pipeline *pipeline,
   ds.KernelStartPointer = tes_bin->kernel.offset;
 
   ds.SamplerCount = get_sampler_count(tes_bin);
-  ds.BindingTableEntryCount = get_binding_table_entry_count(tes_bin);
+  /* Gen 11 workarounds table #2056 WABTPPrefetchDisable */
+  ds.BindingTableEntryCount = GEN_GEN == 11 ? 0 : 
get_binding_table_entry_count(tes_bin);
   ds.MaximumNumberofThreads = devinfo->max_tes_threads - 1;
 
   ds.ComputeWCoordinateEnable =
@@ -1294,7 +1300,8 @@ emit_3dstate_gs(struct anv_pipeline *pipeline)
   gs.SingleProgramFlow   = false;
   gs.VectorMaskEnable= false;
   gs.SamplerCount= get_sampler_count(gs_bin);
-  gs.BindingTableEntryCount  = get_binding_table_entry_count(gs_bin);
+  /* Gen 11 workarounds table #2056 WABTPPrefetchDisable */
+  gs.BindingTableEntryCount  = GEN_GEN == 11 ? 0 : 
get_binding_table_entry_count(gs_bin);
   gs.IncludeVertexHandles= gs_prog_data->base.include_vue_handles;
   gs.IncludePrimitiveID  = gs_prog_data->include_primitive_id;
 
@@ -1535,7 +1542,8 @@ emit_3dstate_ps(struct anv_pipeline *pipeline,
   ps.SingleProgramFlow  = false;
   ps.VectorMaskEnable   = true;
   ps.SamplerCount   = get_sampler_count(fs_bin);
-  ps.BindingTableEntryCount = get_binding_table_entry_count(fs_bin);
+  /* Gen 11 workarounds table #2056 WABTPPrefetchDisable */
+  ps.BindingTableEntryCount = GEN_GEN == 11 ? 0 : 
get_binding_table_entry_count(fs_bin);
   ps.PushConstantEnable = wm_prog_data->base.nr_params > 0 ||
   wm_prog_data->base.ubo_ranges[0].length;
   ps.PositionXYOffsetSelect = wm_prog_data->uses_pos_offset ?
@@ -1868,7 +1876,8 @@ compute_pipeline_create(
   .KernelStartPointer = cs_bin->kernel.offset,
 
   .SamplerCount   = get_sampler_count(cs_bin),
-  .BindingTableEntryCount = get_binding_table_entry_count(cs_bin),
+  /* Gen 11 workarounds table #2056 WABTPPrefetchDisable */
+  .BindingTableEntryCount = GEN_GEN == 11 ? 0 : 
get_binding_table_entry_count(cs_bin),
   .BarrierEnable  = cs_prog_data->uses_barrier,
   .SharedLocalMemorySize  =
  encode_slm_size(GEN_GEN, cs_prog_data->base.total_shared),
-- 
2.17.0

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


[Mesa-dev] [PATCH] i965/icl: Allow headerless sampler messages for pre-emptable contexts

2018-08-17 Thread Anuj Phogat
It fixes simulator warnings in piglit tests complaining about missing
support for headerless sampler messages for pre-emptable contexts.
Bit 5 in SAMPLER MODE register is newly introduced for ICLLP.

Signed-off-by: Anuj Phogat 
---
 src/mesa/drivers/dri/i965/brw_defines.h  |  4 
 src/mesa/drivers/dri/i965/brw_state_upload.c | 11 +++
 2 files changed, 15 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_defines.h 
b/src/mesa/drivers/dri/i965/brw_defines.h
index 855f1c7d744..433314115b1 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -1673,4 +1673,8 @@ enum brw_pixel_shader_coverage_mask_mode {
 # define GLK_SCEC_BARRIER_MODE_3D_HULL (1 << 7)
 # define GLK_SCEC_BARRIER_MODE_MASKREG_MASK(1 << 7)
 
+#define GEN11_SAMPLER_MODE  0xE18C
+# define HEADERLESS_MESSAGE_FOR_PREEMPTABLE_CONTEXTS(1 << 5)
+# define HEADERLESS_MESSAGE_FOR_PREEMPTABLE_CONTEXTS_MASK   REG_MASK(1 << 5)
+
 #endif
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c 
b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 757426407c3..5a334b48892 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -63,6 +63,17 @@ brw_upload_initial_gpu_state(struct brw_context *brw)
 
brw_upload_invariant_state(brw);
 
+   if (devinfo->gen == 11) {
+  /*  The default behavior of bit 5 "Headerless Message for Pre-emptable
+   *  Contexts" in SAMPLER MODE register is set to 0, which means
+   *  headerless sampler messages are not allowed for pre-emptable
+   *  contexts. Set the bit 5 to 1 to allow them.
+   */
+  brw_load_register_imm32(brw, GEN11_SAMPLER_MODE,
+  HEADERLESS_MESSAGE_FOR_PREEMPTABLE_CONTEXTS_MASK 
|
+  HEADERLESS_MESSAGE_FOR_PREEMPTABLE_CONTEXTS);
+   }
+
if (devinfo->gen == 10 || devinfo->gen == 11) {
   /* From gen10 workaround table in h/w specs:
*
-- 
2.17.0

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


Re: [Mesa-dev] [PATCH 09/13] nir: Add floating point atomic min, max, and compare-swap instrinsics

2018-08-17 Thread Caio Marcelo de Oliveira Filho
On Fri, Jun 22, 2018 at 10:03:54PM -0700, Ian Romanick wrote:
> From: Ian Romanick 
> 
> Signed-off-by: Ian Romanick 
> ---
>  src/compiler/glsl/glsl_to_nir.cpp| 32 
> ++--
>  src/compiler/nir/nir_intrinsics.py   | 11 +-
>  src/compiler/nir/nir_lower_atomics_to_ssbo.c |  6 +-
>  src/compiler/nir/nir_lower_io.c  |  9 
>  4 files changed, 50 insertions(+), 8 deletions(-)
> 
> diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
> b/src/compiler/glsl/glsl_to_nir.cpp
> index 90e960592a0..4d6f826f72f 100644
> --- a/src/compiler/glsl/glsl_to_nir.cpp
> +++ b/src/compiler/glsl/glsl_to_nir.cpp
> @@ -735,6 +735,8 @@ nir_visitor::visit(ir_call *ir)
>  op = nir_intrinsic_ssbo_atomic_imin;
>   else if (ir->return_deref->type == glsl_type::uint_type)
>  op = nir_intrinsic_ssbo_atomic_umin;
> + else if (ir->return_deref->type == glsl_type::float_type)
> +op = nir_intrinsic_ssbo_atomic_fmin;
>   else
>  unreachable("Invalid type");
>   break;
> @@ -744,6 +746,8 @@ nir_visitor::visit(ir_call *ir)
>  op = nir_intrinsic_ssbo_atomic_imax;
>   else if (ir->return_deref->type == glsl_type::uint_type)
>  op = nir_intrinsic_ssbo_atomic_umax;
> + else if (ir->return_deref->type == glsl_type::float_type)
> +op = nir_intrinsic_ssbo_atomic_fmax;
>   else
>  unreachable("Invalid type");
>   break;
> @@ -751,7 +755,9 @@ nir_visitor::visit(ir_call *ir)
>   op = nir_intrinsic_ssbo_atomic_exchange;
>   break;
>case ir_intrinsic_ssbo_atomic_comp_swap:
> - op = nir_intrinsic_ssbo_atomic_comp_swap;
> + op = ir->return_deref->type->is_integer_32_64()
> +? nir_intrinsic_ssbo_atomic_comp_swap
> +: nir_intrinsic_ssbo_atomic_fcomp_swap;

Why not compare to glsl_type::float_type?


>   break;
>case ir_intrinsic_shader_clock:
>   op = nir_intrinsic_shader_clock;
> @@ -803,6 +809,8 @@ nir_visitor::visit(ir_call *ir)
>  op = nir_intrinsic_shared_atomic_imin;
>   else if (ir->return_deref->type == glsl_type::uint_type)
>  op = nir_intrinsic_shared_atomic_umin;
> + else if (ir->return_deref->type == glsl_type::float_type)
> +op = nir_intrinsic_shared_atomic_fmin;
>   else
>  unreachable("Invalid type");
>   break;
> @@ -812,6 +820,8 @@ nir_visitor::visit(ir_call *ir)
>  op = nir_intrinsic_shared_atomic_imax;
>   else if (ir->return_deref->type == glsl_type::uint_type)
>  op = nir_intrinsic_shared_atomic_umax;
> + else if (ir->return_deref->type == glsl_type::float_type)
> +op = nir_intrinsic_shared_atomic_fmax;
>   else
>  unreachable("Invalid type");
>   break;
> @@ -819,7 +829,9 @@ nir_visitor::visit(ir_call *ir)
>   op = nir_intrinsic_shared_atomic_exchange;
>   break;
>case ir_intrinsic_shared_atomic_comp_swap:
> - op = nir_intrinsic_shared_atomic_comp_swap;
> + op = ir->return_deref->type->is_integer_32_64()
> +? nir_intrinsic_shared_atomic_comp_swap
> +: nir_intrinsic_shared_atomic_fcomp_swap;
>   break;
>case ir_intrinsic_vote_any:
>   op = nir_intrinsic_vote_any;
> @@ -1068,7 +1080,10 @@ nir_visitor::visit(ir_call *ir)
>case nir_intrinsic_ssbo_atomic_xor:
>case nir_intrinsic_ssbo_atomic_exchange:
>case nir_intrinsic_ssbo_atomic_comp_swap:
> -  case nir_intrinsic_ssbo_atomic_fadd: {
> +  case nir_intrinsic_ssbo_atomic_fadd:
> +  case nir_intrinsic_ssbo_atomic_fmin:
> +  case nir_intrinsic_ssbo_atomic_fmax:
> +  case nir_intrinsic_ssbo_atomic_fcomp_swap: {
>   int param_count = ir->actual_parameters.length();
>   assert(param_count == 3 || param_count == 4);
>  
> @@ -1089,7 +1104,8 @@ nir_visitor::visit(ir_call *ir)
>  
>   /* data2 parameter (only with atomic_comp_swap) */
>   if (param_count == 4) {
> -assert(op == nir_intrinsic_ssbo_atomic_comp_swap);
> +assert(op == nir_intrinsic_ssbo_atomic_comp_swap ||
> +   op == nir_intrinsic_ssbo_atomic_fcomp_swap);
>  param = param->get_next();
>  inst = (ir_instruction *) param;
>  instr->src[3] = 
> nir_src_for_ssa(evaluate_rvalue(inst->as_rvalue()));
> @@ -1152,7 +1168,10 @@ nir_visitor::visit(ir_call *ir)
>case nir_intrinsic_shared_atomic_xor:
>case nir_intrinsic_shared_atomic_exchange:
>case nir_intrinsic_shared_atomic_comp_swap:
> -  case nir_intrinsic_shared_atomic_fadd: {
> +  case nir_intrinsic_shared_atomic_fadd:
> +  case nir_intrinsic_shared_atomic_fmin:
> +  case nir_intrinsic_shared_atomic_fmax:
> +  case nir_intrinsic_shared_atomic_fcomp_s

Re: [Mesa-dev] [PATCH 12/13] i965: Sort Gen9+ extension enables

2018-08-17 Thread Caio Marcelo de Oliveira Filho
This patch is

Reviewed-by: Caio Marcelo de Oliveira Filho 



On Fri, Jun 22, 2018 at 10:03:57PM -0700, Ian Romanick wrote:
> From: Ian Romanick 
> 
> This is a strictly alphabetic sort, as is done in extensions_table.h
> There are other options.  We should pick one and document it.  Right
> now, this file is chaos.

It seems part of the chaos comes from the various individual blocks /
conditions. Maybe doing the other way around would be better,
i.e. having a list of extensions in alphabetical order, set to the
conditions they need to meet.

ctx->Extensions.ARB_shader_viewport_layer_array = devinfo->gen >= 7 && 
ctx->API == API_OPENGL_CORE;

possibly using a local macro and/or variables (for common conditions) to
make things less noisy.  Just a random example to show the potential:

e->ARB_shader_viewport_layer_array = gen >= 7 && api_opengl_core;


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


Re: [Mesa-dev] [PATCH 10/13] intel/compiler: Silence unused parameter warnings

2018-08-17 Thread Caio Marcelo de Oliveira Filho
You've fixed the warnings in "generate_*" functions in another patch
that landed.  I guess this commit also fixed and the rebase was clean,
but the commit message remained.

With that update to the commit message, this patch is

Reviewed-by: Caio Marcelo de Oliveira Filho 


On Fri, Jun 22, 2018 at 10:03:55PM -0700, Ian Romanick wrote:
> From: Ian Romanick 
> 
> src/intel/compiler/brw_disasm_info.c: In function ‘nir_print_instr’:
> src/intel/compiler/brw_disasm_info.c:30:61: warning: unused parameter ‘instr’ 
> [-Wunused-parameter]
>  __attribute__((weak)) void nir_print_instr(const nir_instr *instr, FILE *fp) 
> {}
>  ^
> src/intel/compiler/brw_disasm_info.c:30:74: warning: unused parameter ‘fp’ 
> [-Wunused-parameter]
>  __attribute__((weak)) void nir_print_instr(const nir_instr *instr, FILE *fp) 
> {}
>   ^~
> src/intel/compiler/brw_disasm.c: In function ‘src_ia1’:
> src/intel/compiler/brw_disasm.c:850:18: warning: unused parameter ‘_reg_file’ 
> [-Wunused-parameter]
>  unsigned _reg_file,
>   ^
> src/intel/compiler/brw_fs_surface_builder.cpp: In function ‘void 
> brw::surface_access::emit_byte_scattered_write(const brw::fs_builder&, const 
> fs_reg&, const fs_reg&, const fs_reg&, unsigned int, unsigned int, unsigned 
> int, brw_predicate)’:
> src/intel/compiler/brw_fs_surface_builder.cpp:193:57: warning: unused 
> parameter ‘size’ [-Wunused-parameter]
>  unsigned dims, unsigned size,
>  ^~~~
> src/intel/compiler/brw_fs_generator.cpp: In member function ‘void 
> fs_generator::generate_barrier(fs_inst*, brw_reg)’:
> src/intel/compiler/brw_fs_generator.cpp:743:41: warning: unused parameter 
> ‘inst’ [-Wunused-parameter]
>  fs_generator::generate_barrier(fs_inst *inst, struct brw_reg src)
>  ^~~~
> src/intel/compiler/brw_fs_generator.cpp: In member function ‘void 
> fs_generator::generate_discard_jump(fs_inst*)’:
> src/intel/compiler/brw_fs_generator.cpp:1326:46: warning: unused parameter 
> ‘inst’ [-Wunused-parameter]
>  fs_generator::generate_discard_jump(fs_inst *inst)
>   ^~~~
> src/intel/compiler/brw_fs_generator.cpp: In member function ‘void 
> fs_generator::generate_pack_half_2x16_split(fs_inst*, brw_reg, brw_reg, 
> brw_reg)’:
> src/intel/compiler/brw_fs_generator.cpp:1675:54: warning: unused parameter 
> ‘inst’ [-Wunused-parameter]
>  fs_generator::generate_pack_half_2x16_split(fs_inst *inst,
>   ^~~~
> src/intel/compiler/brw_fs_generator.cpp: In member function ‘void 
> fs_generator::generate_shader_time_add(fs_inst*, brw_reg, brw_reg, brw_reg)’:
> src/intel/compiler/brw_fs_generator.cpp:1743:49: warning: unused parameter 
> ‘inst’ [-Wunused-parameter]
>  fs_generator::generate_shader_time_add(fs_inst *inst,
>  ^~~~
> 
> Signed-off-by: Ian Romanick 
> ---
>  src/intel/compiler/brw_disasm.c   | 3 ---
>  src/intel/compiler/brw_disasm_info.c  | 3 ++-
>  src/intel/compiler/brw_fs_nir.cpp | 2 +-
>  src/intel/compiler/brw_fs_surface_builder.cpp | 2 +-
>  src/intel/compiler/brw_fs_surface_builder.h   | 2 +-
>  5 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/src/intel/compiler/brw_disasm.c b/src/intel/compiler/brw_disasm.c
> index 5f75c67942e..e45762afb07 100644
> --- a/src/intel/compiler/brw_disasm.c
> +++ b/src/intel/compiler/brw_disasm.c
> @@ -846,7 +846,6 @@ src_ia1(FILE *file,
>  const struct gen_device_info *devinfo,
>  unsigned opcode,
>  enum brw_reg_type type,
> -unsigned _reg_file,
>  int _addr_imm,
>  unsigned _addr_subreg_nr,
>  unsigned _negate,
> @@ -1326,7 +1325,6 @@ src0(FILE *file, const struct gen_device_info *devinfo, 
> const brw_inst *inst)
>  devinfo,
>  brw_inst_opcode(devinfo, inst),
>  brw_inst_src0_type(devinfo, inst),
> -brw_inst_src0_reg_file(devinfo, inst),
>  brw_inst_src0_ia1_addr_imm(devinfo, inst),
>  brw_inst_src0_ia_subreg_nr(devinfo, inst),
>  brw_inst_src0_negate(devinfo, inst),
> @@ -1382,7 +1380,6 @@ src1(FILE *file, const struct gen_device_info *devinfo, 
> const brw_inst *inst)
>  devinfo,
>  brw_inst_opcode(devinfo, inst),
>  brw_inst_src1_type(devinfo, inst),
> -brw_inst_src1_reg_file(devinfo, inst),
>  brw_inst_src1_ia1_addr_imm(devinfo, inst),
>  brw_inst_src1_ia_subreg_nr(devinfo, inst),
>  br

Re: [Mesa-dev] [PATCH 11/13] intel/compiler: Implement untyped atomic float min, max, and compare-swap dataport messages

2018-08-17 Thread Caio Marcelo de Oliveira Filho
On Fri, Jun 22, 2018 at 10:03:56PM -0700, Ian Romanick wrote:
> From: Ian Romanick 
> 
> Also expand the message type field by a single bit.  This is necessary
> for this Gen9 message type, but there are also Gen8 message types that
> need the extra bit (mostly for bindless).

I'd consider splitting this particular change in its own commit, but
not a strong opinion.


> Signed-off-by: Ian Romanick 
> ---
>  src/intel/compiler/brw_disasm.c   |  15 +++-
>  src/intel/compiler/brw_eu.h   |  11 +++
>  src/intel/compiler/brw_eu_defines.h   |  12 ++-
>  src/intel/compiler/brw_eu_emit.c  |  48 ++
>  src/intel/compiler/brw_fs.cpp |  23 +
>  src/intel/compiler/brw_fs.h   |   4 +
>  src/intel/compiler/brw_fs_copy_propagation.cpp|   2 +
>  src/intel/compiler/brw_fs_dead_code_eliminate.cpp |   2 +
>  src/intel/compiler/brw_fs_generator.cpp   |   7 ++
>  src/intel/compiler/brw_fs_nir.cpp | 103 
> ++
>  src/intel/compiler/brw_fs_surface_builder.cpp |  24 +
>  src/intel/compiler/brw_fs_surface_builder.h   |   7 ++
>  src/intel/compiler/brw_inst.h |   2 +-
>  src/intel/compiler/brw_schedule_instructions.cpp  |   1 +
>  src/intel/compiler/brw_shader.cpp |   6 ++
>  15 files changed, 264 insertions(+), 3 deletions(-)


Regardless of the suggestion above, this patch is

Reviewed-by: Caio Marcelo de Oliveira Filho 


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


[Mesa-dev] [PATCH] docs: Python 2.7 or later is required.

2018-08-17 Thread Vinson Lee
Signed-off-by: Vinson Lee 
---
 docs/install.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/install.html b/docs/install.html
index 08081944cfcc..f6094671cf9f 100644
--- a/docs/install.html
+++ b/docs/install.html
@@ -72,7 +72,7 @@ you think you've spotted a bug let developers know by filing a
 
 
 https://www.python.org/";>Python - Python is required.
-Version 2.6.4 or later should work.
+Version 2.7 or later should work.
 
 http://www.makotemplates.org/";>Python Mako module -
 Python Mako module is required. Version 0.3.4 or later should work.
-- 
2.17.1

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


Re: [Mesa-dev] [PATCH v2 7/8] nir: add loop unroll support for wrapper loops

2018-08-17 Thread Timothy Arceri

On 18/08/18 07:14, Jason Ekstrand wrote:
On Mon, Jul 23, 2018 at 3:02 AM Timothy Arceri > wrote:


This adds support for unrolling the classic

     do {
         // ...
     } while (false)

that is used to wrap multi-line macros. GLSL IR also wraps switch
statements in a loop like this.

shader-db results IVB:

total loops in shared programs: 2515 -> 2512 (-0.12%)
loops in affected programs: 33 -> 30 (-9.09%)
helped: 3
HURT: 0
---
  src/compiler/nir/nir_opt_loop_unroll.c | 77 ++
  1 file changed, 77 insertions(+)

diff --git a/src/compiler/nir/nir_opt_loop_unroll.c
b/src/compiler/nir/nir_opt_loop_unroll.c
index e0e0b754716..9c33267cb72 100644
--- a/src/compiler/nir/nir_opt_loop_unroll.c
+++ b/src/compiler/nir/nir_opt_loop_unroll.c
@@ -465,6 +465,65 @@ complex_unroll(nir_loop *loop,
nir_loop_terminator *unlimit_term,
     _mesa_hash_table_destroy(remap_table, NULL);
  }

+/* Unrolls the classic wrapper loops e.g
+ *
+ *    do {
+ *        // ...
+ *    } while (false)
+ */
+static bool
+wrapper_unroll(nir_loop *loop)
+{
+   bool progress = false;
+
+   nir_block *blk_after_loop =
+      nir_cursor_current_block(nir_after_cf_node(&loop->cf_node));
+
+   /* There may still be some single src phis following the loop that
+    * have not yet been cleaned up by another pass. Tidy those up
before
+    * unrolling the loop.
+    */
+   nir_foreach_instr_safe(instr, blk_after_loop) {
+      if (instr->type != nir_instr_type_phi)
+         break;
+
+      nir_phi_instr *phi = nir_instr_as_phi(instr);
+      assert(exec_list_length(&phi->srcs) == 1);
+
+      nir_phi_src *phi_src = exec_node_data(nir_phi_src,
+   
exec_list_get_head(&phi->srcs),

+                                            node);
+
+      nir_ssa_def_rewrite_uses(&phi->dest.ssa, phi_src->src);
+      nir_instr_remove(instr);
+
+      progress = true;
+   }
+
+   nir_block *last_loop_blk = nir_loop_last_block(loop);
+   if (nir_block_ends_in_break(last_loop_blk)) {
+
+      /* Remove break at end of the loop */
+      nir_instr *break_instr = nir_block_last_instr(last_loop_blk);
+      nir_instr_remove(break_instr);
+
+      /* Pluck out the loop body. */
+      nir_cf_list loop_body;
+      nir_cf_extract(&loop_body,
nir_before_block(nir_loop_first_block(loop)),
+                     nir_after_block(nir_loop_last_block(loop)));
+
+      /* Reinsert loop body after the loop */
+      nir_cf_reinsert(&loop_body, nir_after_cf_node(&loop->cf_node));
+
+      /* The loop has been unrolled so remove it. */
+      nir_cf_node_remove(&loop->cf_node);
+
+      progress = true;
+   }
+
+   return progress;
+}
+
  static bool
  is_loop_small_enough_to_unroll(nir_shader *shader, nir_loop_info *li)
  {
@@ -516,6 +575,24 @@ process_loops(nir_shader *sh, nir_cf_node
*cf_node, bool *has_nested_loop_out)
      */
     if (!progress) {

+      /* Check for the classic
+       *
+       *    do {
+       *        // ...
+       *    } while (false)
+       *
+       * that is used to wrap multi-line macros. GLSL IR also wraps
switch
+       * statements in a loop like this.
+       */
+      if (loop->info->limiting_terminator == NULL &&
+          list_empty(&loop->info->loop_terminator_list) &&
+          !loop->info->complex_loop) {


What does this do with "do { } while (true)"?  Would those also hit this 
path?  If they do, unrolling them is probably ok since it's a GPU hang 
if we don't but I thought it was worth asking.


No this should leave them as is. There is a check in wrapper_unroll() to 
make sure the loop has a break in the last block.





+
+         progress = wrapper_unroll(loop);
+
+         goto exit;
+      }
+
        if (has_nested_loop || loop->info->limiting_terminator == NULL)
           goto exit;

-- 
2.17.1


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


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


Re: [Mesa-dev] [PATCH 01/22] nir/algebraic: Be more careful converting ushr to extract_u8/16

2018-08-17 Thread Jason Ekstrand
On Fri, Aug 17, 2018 at 5:27 PM Bas Nieuwenhuizen 
wrote:

> On Fri, Aug 17, 2018 at 10:06 PM, Jason Ekstrand 
> wrote:
> > If it's not the right bit-size, it may not actually be the correct
> > extraction.  For now, we'll only worry about 32-bit versions.
> >
> > Fixes: 905ff8619824 "nir: Recognize open-coded extract_u16"
> > Fixes: 76289fbfa84a "nir: Recognize open-coded extract_u8"
> > ---
> >  src/compiler/nir/nir_opt_algebraic.py | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/compiler/nir/nir_opt_algebraic.py
> b/src/compiler/nir/nir_opt_algebraic.py
> > index e770a61d9ff..28090d069cd 100644
> > --- a/src/compiler/nir/nir_opt_algebraic.py
> > +++ b/src/compiler/nir/nir_opt_algebraic.py
> > @@ -543,13 +543,13 @@ optimizations = [
> > ('unpack_64_2x32_split_y', a)), a),
> >
> > # Byte extraction
> > -   (('ushr', a, 24), ('extract_u8', a, 3),
> '!options->lower_extract_byte'),
> > +   (('ushr', 'a@32', 24), ('extract_u8', a, 3),
> '!options->lower_extract_byte'),
> > (('iand', 0xff, ('ushr', a, 16)), ('extract_u8', a, 2),
> '!options->lower_extract_byte'),
> > (('iand', 0xff, ('ushr', a,  8)), ('extract_u8', a, 1),
> '!options->lower_extract_byte'),
> > (('iand', 0xff, a), ('extract_u8', a, 0),
> '!options->lower_extract_byte'),
> >
> >  # Word extraction
> > -   (('ushr', a, 16), ('extract_u16', a, 1),
> '!options->lower_extract_word'),
> > +   (('ushr', 'a@16', 16), ('extract_u16', a, 1),
> '!options->lower_extract_word'),
>
> This @16 is the argument size here right? a (uint16_t) shifted right b
> 16 is 0, are you sure this does not need to be @32?
>

Right.  I'll fix it quick.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 03/22] nir/algebraic: Add some max/min optimizations

2018-08-17 Thread Bas Nieuwenhuizen
Reviewed-by: Bas Nieuwenhuizen 

On Fri, Aug 17, 2018 at 10:06 PM, Jason Ekstrand  wrote:
> Found by inspection.  This doesn't help much now but we'll see this
> pattern with images if you load UNORM and then store UNORM.
>
> Shader-db results on Kaby Lake:
>
> total instructions in shared programs: 15166916 -> 15166910 (<.01%)
> instructions in affected programs: 761 -> 755 (-0.79%)
> helped: 6
> HURT: 0
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py 
> b/src/compiler/nir/nir_opt_algebraic.py
> index 07fbb161a4e..55a1feeaf47 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -302,6 +302,12 @@ optimizations = [
> (('imax', a, a), a),
> (('umin', a, a), a),
> (('umax', a, a), a),
> +   (('fmax', ('fmax', a, b), b), ('fmax', a, b)),
> +   (('umax', ('umax', a, b), b), ('umax', a, b)),
> +   (('imax', ('imax', a, b), b), ('imax', a, b)),
> +   (('fmin', ('fmin', a, b), b), ('fmin', a, b)),
> +   (('umin', ('umin', a, b), b), ('umin', a, b)),
> +   (('imin', ('imin', a, b), b), ('imin', a, b)),
> (('fmax', a, ('fneg', a)), ('fabs', a)),
> (('imax', a, ('ineg', a)), ('iabs', a)),
> (('fmin', a, ('fneg', a)), ('fneg', ('fabs', a))),
> --
> 2.17.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 02/22] nir/algebraic: Add more extract_[iu](8|16) optimizations

2018-08-17 Thread Bas Nieuwenhuizen
On Fri, Aug 17, 2018 at 10:06 PM, Jason Ekstrand  wrote:
> This adds the "(a << N) >> M" family of mask or sign-extensions.  Not a
> huge win right now but this pattern will soon be generated by NIR format
> lowering code.
>
> Shader-db results on Kaby Lake:
>
> total instructions in shared programs: 15166918 -> 15166916 (<.01%)
> instructions in affected programs: 36 -> 34 (-5.56%)
> helped: 2
> HURT: 0
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py 
> b/src/compiler/nir/nir_opt_algebraic.py
> index 28090d069cd..07fbb161a4e 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -543,13 +543,23 @@ optimizations = [
> ('unpack_64_2x32_split_y', a)), a),
>
> # Byte extraction
> +   (('ushr', ('ishl', 'a@32', 24), 24), ('extract_u8', a, 0), 
> '!options->lower_extract_byte'),
> +   (('ushr', ('ishl', 'a@32', 16), 24), ('extract_u8', a, 1), 
> '!options->lower_extract_byte'),
> +   (('ushr', ('ishl', 'a@32', 8), 24), ('extract_u8', a, 2), 
> '!options->lower_extract_byte'),
> (('ushr', 'a@32', 24), ('extract_u8', a, 3), 
> '!options->lower_extract_byte'),
> +   (('ishr', ('ishl', 'a@32', 24), 24), ('extract_i8', a, 0), 
> '!options->lower_extract_byte'),
> +   (('ishr', ('ishl', 'a@32', 16), 24), ('extract_i8', a, 1), 
> '!options->lower_extract_byte'),
> +   (('ishr', ('ishl', 'a@32', 8), 24), ('extract_i8', a, 2), 
> '!options->lower_extract_byte'),
> +   (('ishr', 'a@32', 24), ('extract_i8', a, 3), 
> '!options->lower_extract_byte'),
> (('iand', 0xff, ('ushr', a, 16)), ('extract_u8', a, 2), 
> '!options->lower_extract_byte'),
> (('iand', 0xff, ('ushr', a,  8)), ('extract_u8', a, 1), 
> '!options->lower_extract_byte'),
> (('iand', 0xff, a), ('extract_u8', a, 0), '!options->lower_extract_byte'),
>
>  # Word extraction
> +   (('ushr', ('ishl', 'a@16', 16), 16), ('extract_u16', a, 0), 
> '!options->lower_extract_word'),
> (('ushr', 'a@16', 16), ('extract_u16', a, 1), 
> '!options->lower_extract_word'),
> +   (('ishr', ('ishl', 'a@16', 16), 16), ('extract_i16', a, 0), 
> '!options->lower_extract_word'),
> +   (('ishr', 'a@16', 16), ('extract_i16', a, 1), 
> '!options->lower_extract_word'),
> (('iand', 0x, a), ('extract_u16', a, 0), 
> '!options->lower_extract_word'),

I think this all should be @32 too. With that patch 1-2 are

Reviewed-by: Bas Nieuwenhuizen 

>
> # Subtracts
> --
> 2.17.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/22] nir/algebraic: Be more careful converting ushr to extract_u8/16

2018-08-17 Thread Bas Nieuwenhuizen
On Fri, Aug 17, 2018 at 10:06 PM, Jason Ekstrand  wrote:
> If it's not the right bit-size, it may not actually be the correct
> extraction.  For now, we'll only worry about 32-bit versions.
>
> Fixes: 905ff8619824 "nir: Recognize open-coded extract_u16"
> Fixes: 76289fbfa84a "nir: Recognize open-coded extract_u8"
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py 
> b/src/compiler/nir/nir_opt_algebraic.py
> index e770a61d9ff..28090d069cd 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -543,13 +543,13 @@ optimizations = [
> ('unpack_64_2x32_split_y', a)), a),
>
> # Byte extraction
> -   (('ushr', a, 24), ('extract_u8', a, 3), '!options->lower_extract_byte'),
> +   (('ushr', 'a@32', 24), ('extract_u8', a, 3), 
> '!options->lower_extract_byte'),
> (('iand', 0xff, ('ushr', a, 16)), ('extract_u8', a, 2), 
> '!options->lower_extract_byte'),
> (('iand', 0xff, ('ushr', a,  8)), ('extract_u8', a, 1), 
> '!options->lower_extract_byte'),
> (('iand', 0xff, a), ('extract_u8', a, 0), '!options->lower_extract_byte'),
>
>  # Word extraction
> -   (('ushr', a, 16), ('extract_u16', a, 1), '!options->lower_extract_word'),
> +   (('ushr', 'a@16', 16), ('extract_u16', a, 1), 
> '!options->lower_extract_word'),

This @16 is the argument size here right? a (uint16_t) shifted right b
16 is 0, are you sure this does not need to be @32?

> (('iand', 0x, a), ('extract_u16', a, 0), 
> '!options->lower_extract_word'),
>
> # Subtracts
> --
> 2.17.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 09/22] nir/format_convert: Rename pack_r11g11b10f to pack_11f11f10f

2018-08-17 Thread Jason Ekstrand
On Fri, Aug 17, 2018 at 4:26 PM Roland Scheidegger 
wrote:

> Am 17.08.2018 um 22:06 schrieb Jason Ekstrand:
> > This matches the unpack function.
> > ---
> >  src/compiler/nir/nir_format_convert.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/compiler/nir/nir_format_convert.h
> b/src/compiler/nir/nir_format_convert.h
> > index 75793733ea6..c79001a50aa 100644
> > --- a/src/compiler/nir/nir_format_convert.h
> > +++ b/src/compiler/nir/nir_format_convert.h
> > @@ -298,7 +298,7 @@ nir_format_unpack_11f11f10f(nir_builder *b,
> nir_ssa_def *packed)
> >  }
> >
> >  static inline nir_ssa_def *
> > -nir_format_pack_r11g11b10f(nir_builder *b, nir_ssa_def *color)
> > +nir_format_pack_11f11f10f(nir_builder *b, nir_ssa_def *color)
> >  {
> > /* 10 and 11-bit floats are unsigned.  Clamp to non-negative */
> > nir_ssa_def *clamped = nir_fmax(b, color, nir_imm_float(b, 0));
> >
>
> Not that this is actually changing with this patch, I just saw it by
> accident - but fmax will kill off NaNs, despite that this format can
> encode them easily.
>

True.  If we're concerned about that, we could always replace it with
"color = color <= 0 ? 0 : color" then a NaN would be propagated.  At
current, I think the optimizer is likely to detect that and replace it with
fmax though


> I suppose though that's ok for GL...
>

Yeah.  Thanks for pointing it out though!

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


Re: [Mesa-dev] [PATCH 09/22] nir/format_convert: Rename pack_r11g11b10f to pack_11f11f10f

2018-08-17 Thread Roland Scheidegger
Am 17.08.2018 um 22:06 schrieb Jason Ekstrand:
> This matches the unpack function.
> ---
>  src/compiler/nir/nir_format_convert.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/compiler/nir/nir_format_convert.h 
> b/src/compiler/nir/nir_format_convert.h
> index 75793733ea6..c79001a50aa 100644
> --- a/src/compiler/nir/nir_format_convert.h
> +++ b/src/compiler/nir/nir_format_convert.h
> @@ -298,7 +298,7 @@ nir_format_unpack_11f11f10f(nir_builder *b, nir_ssa_def 
> *packed)
>  }
>  
>  static inline nir_ssa_def *
> -nir_format_pack_r11g11b10f(nir_builder *b, nir_ssa_def *color)
> +nir_format_pack_11f11f10f(nir_builder *b, nir_ssa_def *color)
>  {
> /* 10 and 11-bit floats are unsigned.  Clamp to non-negative */
> nir_ssa_def *clamped = nir_fmax(b, color, nir_imm_float(b, 0));
> 

Not that this is actually changing with this patch, I just saw it by
accident - but fmax will kill off NaNs, despite that this format can
encode them easily.
I suppose though that's ok for GL...

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


Re: [Mesa-dev] [PATCH v2 7/8] nir: add loop unroll support for wrapper loops

2018-08-17 Thread Jason Ekstrand
On Mon, Jul 23, 2018 at 3:02 AM Timothy Arceri 
wrote:

> This adds support for unrolling the classic
>
> do {
> // ...
> } while (false)
>
> that is used to wrap multi-line macros. GLSL IR also wraps switch
> statements in a loop like this.
>
> shader-db results IVB:
>
> total loops in shared programs: 2515 -> 2512 (-0.12%)
> loops in affected programs: 33 -> 30 (-9.09%)
> helped: 3
> HURT: 0
> ---
>  src/compiler/nir/nir_opt_loop_unroll.c | 77 ++
>  1 file changed, 77 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_loop_unroll.c
> b/src/compiler/nir/nir_opt_loop_unroll.c
> index e0e0b754716..9c33267cb72 100644
> --- a/src/compiler/nir/nir_opt_loop_unroll.c
> +++ b/src/compiler/nir/nir_opt_loop_unroll.c
> @@ -465,6 +465,65 @@ complex_unroll(nir_loop *loop, nir_loop_terminator
> *unlimit_term,
> _mesa_hash_table_destroy(remap_table, NULL);
>  }
>
> +/* Unrolls the classic wrapper loops e.g
> + *
> + *do {
> + *// ...
> + *} while (false)
> + */
> +static bool
> +wrapper_unroll(nir_loop *loop)
> +{
> +   bool progress = false;
> +
> +   nir_block *blk_after_loop =
> +  nir_cursor_current_block(nir_after_cf_node(&loop->cf_node));
> +
> +   /* There may still be some single src phis following the loop that
> +* have not yet been cleaned up by another pass. Tidy those up before
> +* unrolling the loop.
> +*/
> +   nir_foreach_instr_safe(instr, blk_after_loop) {
> +  if (instr->type != nir_instr_type_phi)
> + break;
> +
> +  nir_phi_instr *phi = nir_instr_as_phi(instr);
> +  assert(exec_list_length(&phi->srcs) == 1);
> +
> +  nir_phi_src *phi_src = exec_node_data(nir_phi_src,
> +
> exec_list_get_head(&phi->srcs),
> +node);
> +
> +  nir_ssa_def_rewrite_uses(&phi->dest.ssa, phi_src->src);
> +  nir_instr_remove(instr);
> +
> +  progress = true;
> +   }
> +
> +   nir_block *last_loop_blk = nir_loop_last_block(loop);
> +   if (nir_block_ends_in_break(last_loop_blk)) {
> +
> +  /* Remove break at end of the loop */
> +  nir_instr *break_instr = nir_block_last_instr(last_loop_blk);
> +  nir_instr_remove(break_instr);
> +
> +  /* Pluck out the loop body. */
> +  nir_cf_list loop_body;
> +  nir_cf_extract(&loop_body,
> nir_before_block(nir_loop_first_block(loop)),
> + nir_after_block(nir_loop_last_block(loop)));
> +
> +  /* Reinsert loop body after the loop */
> +  nir_cf_reinsert(&loop_body, nir_after_cf_node(&loop->cf_node));
> +
> +  /* The loop has been unrolled so remove it. */
> +  nir_cf_node_remove(&loop->cf_node);
> +
> +  progress = true;
> +   }
> +
> +   return progress;
> +}
> +
>  static bool
>  is_loop_small_enough_to_unroll(nir_shader *shader, nir_loop_info *li)
>  {
> @@ -516,6 +575,24 @@ process_loops(nir_shader *sh, nir_cf_node *cf_node,
> bool *has_nested_loop_out)
>  */
> if (!progress) {
>
> +  /* Check for the classic
> +   *
> +   *do {
> +   *// ...
> +   *} while (false)
> +   *
> +   * that is used to wrap multi-line macros. GLSL IR also wraps switch
> +   * statements in a loop like this.
> +   */
> +  if (loop->info->limiting_terminator == NULL &&
> +  list_empty(&loop->info->loop_terminator_list) &&
> +  !loop->info->complex_loop) {
>

What does this do with "do { } while (true)"?  Would those also hit this
path?  If they do, unrolling them is probably ok since it's a GPU hang if
we don't but I thought it was worth asking.


> +
> + progress = wrapper_unroll(loop);
> +
> + goto exit;
> +  }
> +
>if (has_nested_loop || loop->info->limiting_terminator == NULL)
>   goto exit;
>
> --
> 2.17.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 5/8] nir: add complex_loop bool to loop info

2018-08-17 Thread Jason Ekstrand
4 and 5 are

Reviewed-by: Jason Ekstrand 

On Mon, Jul 23, 2018 at 3:03 AM Timothy Arceri 
wrote:

> In order to be sure loop_terminator_list is an accurate
> representation of all the jumps in the loop we need to be sure we
> didn't encounter any other complex behaviour such as continues,
> nested breaks, etc during analysis.
>
> This will be used in the following patch.
> ---
>  src/compiler/nir/nir.h  | 6 ++
>  src/compiler/nir/nir_loop_analyze.c | 8 ++--
>  2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 3bfe7d7f7bf..336a2ca5ac4 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -1745,6 +1745,12 @@ typedef struct {
> /* Unroll the loop regardless of its size */
> bool force_unroll;
>
> +   /* Does the loop contain complex loop terminators, continues or other
> +* complex behaviours? If this is true we can't rely on
> +* loop_terminator_list to be complete or accurate.
> +*/
> +   bool complex_loop;
> +
> nir_loop_terminator *limiting_terminator;
>
> /* A list of loop_terminators terminating this loop. */
> diff --git a/src/compiler/nir/nir_loop_analyze.c
> b/src/compiler/nir/nir_loop_analyze.c
> index 5454b7691ba..9c3fd2f286f 100644
> --- a/src/compiler/nir/nir_loop_analyze.c
> +++ b/src/compiler/nir/nir_loop_analyze.c
> @@ -317,15 +317,19 @@ find_loop_terminators(loop_info_state *state)
>* not find a loop terminator, but there is a break-statement
> then
>* we should return false so that we do not try to find
> trip-count
>*/
> - if (!nir_is_trivial_loop_if(nif, break_blk))
> + if (!nir_is_trivial_loop_if(nif, break_blk)) {
> +state->loop->info->complex_loop = true;
>  return false;
> + }
>
>   /* Continue if the if contained no jumps at all */
>   if (!break_blk)
>  continue;
>
> - if (nif->condition.ssa->parent_instr->type == nir_instr_type_phi)
> + if (nif->condition.ssa->parent_instr->type ==
> nir_instr_type_phi) {
> +state->loop->info->complex_loop = true;
>  return false;
> + }
>
>   nir_loop_terminator *terminator =
>  rzalloc(state->loop->info, nir_loop_terminator);
> --
> 2.17.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 16/22] intel/compiler: Use two components for 1D array image sizes

2018-08-17 Thread Jason Ekstrand
Having the array length component stored in .z was a small convenience
for the ISL image param filling code and an annoyance in the NIR
lowering code.  The only convenience of treating 1D arrays like 2D
arrays in the lowering code is in the address calculation code so let's
put all the complexity there as well.
---
 .../compiler/brw_nir_lower_image_load_store.c | 37 +++
 src/intel/isl/isl_storage_image.c | 12 +++---
 2 files changed, 20 insertions(+), 29 deletions(-)

diff --git a/src/intel/compiler/brw_nir_lower_image_load_store.c 
b/src/intel/compiler/brw_nir_lower_image_load_store.c
index 45a30a041be..a4bd37fc1e5 100644
--- a/src/intel/compiler/brw_nir_lower_image_load_store.c
+++ b/src/intel/compiler/brw_nir_lower_image_load_store.c
@@ -118,31 +118,16 @@ _load_image_param(nir_builder *b, nir_deref_instr *deref, 
unsigned offset)
 #define load_image_param(b, d, o) \
_load_image_param(b, d, BRW_IMAGE_PARAM_##o##_OFFSET)
 
-static nir_ssa_def *
-sanitize_image_coord(nir_builder *b, nir_deref_instr *deref, nir_ssa_def 
*coord)
-{
-   if (glsl_get_sampler_dim(deref->type) == GLSL_SAMPLER_DIM_1D &&
-   glsl_sampler_type_is_array(deref->type)) {
-  /* It's easier if 1D arrays are treated like 2D arrays */
-  return nir_vec3(b, nir_channel(b, coord, 0),
- nir_imm_int(b, 0),
- nir_channel(b, coord, 1));
-   } else {
-  unsigned dims = glsl_get_sampler_coordinate_components(deref->type);
-  return nir_channels(b, coord, (1 << dims) - 1);
-   }
-}
-
 static nir_ssa_def *
 image_coord_is_in_bounds(nir_builder *b, const struct gen_device_info *devinfo,
  nir_deref_instr *deref, nir_ssa_def *coord)
 {
-   coord = sanitize_image_coord(b, deref, coord);
nir_ssa_def *size = load_image_param(b, deref, SIZE);
-
nir_ssa_def *cmp = nir_ilt(b, coord, size);
+
+   unsigned coord_comps = glsl_get_sampler_coordinate_components(deref->type);
nir_ssa_def *in_bounds = nir_imm_int(b, NIR_TRUE);
-   for (unsigned i = 0; i < coord->num_components; i++)
+   for (unsigned i = 0; i < coord_comps; i++)
   in_bounds = nir_iand(b, in_bounds, nir_channel(b, cmp, i));
 
return in_bounds;
@@ -164,7 +149,16 @@ static nir_ssa_def *
 image_address(nir_builder *b, const struct gen_device_info *devinfo,
   nir_deref_instr *deref, nir_ssa_def *coord)
 {
-   coord = sanitize_image_coord(b, deref, coord);
+   if (glsl_get_sampler_dim(deref->type) == GLSL_SAMPLER_DIM_1D &&
+   glsl_sampler_type_is_array(deref->type)) {
+  /* It's easier if 1D arrays are treated like 2D arrays */
+  coord = nir_vec3(b, nir_channel(b, coord, 0),
+  nir_imm_int(b, 0),
+  nir_channel(b, coord, 1));
+   } else {
+  unsigned dims = glsl_get_sampler_coordinate_components(deref->type);
+  coord = nir_channels(b, coord, (1 << dims) - 1);
+   }
 
nir_ssa_def *offset = load_image_param(b, deref, OFFSET);
nir_ssa_def *tiling = load_image_param(b, deref, TILING);
@@ -743,10 +737,7 @@ lower_image_size_instr(nir_builder *b,
enum glsl_sampler_dim dim = glsl_get_sampler_dim(deref->type);
unsigned coord_comps = glsl_get_sampler_coordinate_components(deref->type);
for (unsigned c = 0; c < coord_comps; c++) {
-  if (c == 1 && dim == GLSL_SAMPLER_DIM_1D) {
- /* The array length for 1D arrays is in .z */
- comps[1] = nir_channel(b, size, 2);
-  } else if (c == 2 && dim == GLSL_SAMPLER_DIM_CUBE) {
+  if (c == 2 && dim == GLSL_SAMPLER_DIM_CUBE) {
  comps[2] = nir_idiv(b, nir_channel(b, size, 2), nir_imm_int(b, 6));
   } else {
  comps[c] = nir_channel(b, size, c);
diff --git a/src/intel/isl/isl_storage_image.c 
b/src/intel/isl/isl_storage_image.c
index 43398e8a020..c36985af127 100644
--- a/src/intel/isl/isl_storage_image.c
+++ b/src/intel/isl/isl_storage_image.c
@@ -233,12 +233,12 @@ isl_surf_fill_image_param(const struct isl_device *dev,
  surf->logical_level0_px.array_len);
}
param->size[0] = isl_minify(surf->logical_level0_px.w, view->base_level);
-   param->size[1] = isl_minify(surf->logical_level0_px.h, view->base_level);
-   if (surf->dim == ISL_SURF_DIM_3D) {
-  param->size[2] = isl_minify(surf->logical_level0_px.d, view->base_level);
-   } else {
-  param->size[2] = view->array_len;
-   }
+   param->size[1] = surf->dim == ISL_SURF_DIM_1D ?
+view->array_len :
+isl_minify(surf->logical_level0_px.h, view->base_level);
+   param->size[2] = surf->dim == ISL_SURF_DIM_2D ?
+view->array_len :
+isl_minify(surf->logical_level0_px.d, view->base_level);
 
isl_surf_get_image_offset_el(surf, view->base_level,
 surf->dim == ISL_SURF_DIM_3D ?
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.fre

[Mesa-dev] [PATCH 20/22] nir: Add handle/index-based image intrinsics

2018-08-17 Thread Jason Ekstrand
---
 src/compiler/nir/nir.h | 30 +--
 src/compiler/nir/nir_intrinsics.py | 48 +++---
 src/compiler/nir/nir_print.c   | 22 ++
 3 files changed, 81 insertions(+), 19 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 55e48bbb693..b88e6fc5834 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1049,7 +1049,7 @@ typedef struct {
 
 #include "nir_intrinsics.h"
 
-#define NIR_INTRINSIC_MAX_CONST_INDEX 3
+#define NIR_INTRINSIC_MAX_CONST_INDEX 4
 
 /** Represents an intrinsic
  *
@@ -1197,6 +1197,28 @@ typedef enum {
 */
NIR_INTRINSIC_PARAM_IDX = 12,
 
+   /**
+* Image dimensionality for image intrinsics
+*
+* One of GLSL_SAMPLER_DIM_*
+*/
+   NIR_INTRINSIC_IMAGE_DIM = 13,
+
+   /**
+* Non-zero if we are accessing an array image
+*/
+   NIR_INTRINSIC_IMAGE_ARRAY = 14,
+
+   /**
+* Image format for image intrinsics
+*/
+   NIR_INTRINSIC_FORMAT = 15,
+
+   /**
+* Access qualifiers for image intrinsics
+*/
+   NIR_INTRINSIC_ACCESS = 16,
+
NIR_INTRINSIC_NUM_INDEX_FLAGS,
 
 } nir_intrinsic_index_flag;
@@ -1265,7 +1287,7 @@ nir_intrinsic_##name(const nir_intrinsic_instr *instr)
\
 { \
const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic];   \
assert(info->index_map[NIR_INTRINSIC_##flag] > 0); \
-   return instr->const_index[info->index_map[NIR_INTRINSIC_##flag] - 1];  \
+   return (type)instr->const_index[info->index_map[NIR_INTRINSIC_##flag] - 1]; 
\
 } \
 static inline void\
 nir_intrinsic_set_##name(nir_intrinsic_instr *instr, type val)\
@@ -1287,6 +1309,10 @@ INTRINSIC_IDX_ACCESSORS(interp_mode, INTERP_MODE, 
unsigned)
 INTRINSIC_IDX_ACCESSORS(reduction_op, REDUCTION_OP, unsigned)
 INTRINSIC_IDX_ACCESSORS(cluster_size, CLUSTER_SIZE, unsigned)
 INTRINSIC_IDX_ACCESSORS(param_idx, PARAM_IDX, unsigned)
+INTRINSIC_IDX_ACCESSORS(image_dim, IMAGE_DIM, enum glsl_sampler_dim)
+INTRINSIC_IDX_ACCESSORS(image_array, IMAGE_ARRAY, bool)
+INTRINSIC_IDX_ACCESSORS(access, ACCESS, enum gl_access_qualifier)
+INTRINSIC_IDX_ACCESSORS(format, FORMAT, unsigned)
 
 /**
  * \group texture information
diff --git a/src/compiler/nir/nir_intrinsics.py 
b/src/compiler/nir/nir_intrinsics.py
index 45872e00c55..0dae37ae886 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -101,6 +101,14 @@ REDUCTION_OP = "NIR_INTRINSIC_REDUCTION_OP"
 CLUSTER_SIZE = "NIR_INTRINSIC_CLUSTER_SIZE"
 # Parameter index for a load_param intrinsic
 PARAM_IDX = "NIR_INTRINSIC_PARAM_IDX"
+# Image dimensionality for image intrinsics
+IMAGE_DIM = "NIR_INTRINSIC_IMAGE_DIM"
+# Non-zero if we are accessing an array image
+IMAGE_ARRAY = "NIR_INTRINSIC_IMAGE_ARRAY"
+# Access qualifiers for image intrinsics
+ACCESS = "NIR_INTRINSIC_ACCESS"
+# Image format for image intrinsics
+FORMAT = "NIR_INTRINSIC_FORMAT"
 
 #
 # Possible flags:
@@ -284,10 +292,12 @@ atomic3("atomic_counter_comp_swap")
 
 # Image load, store and atomic intrinsics.
 #
-# All image intrinsics take an image target passed as a nir_variable.  The
-# variable is passed in using a chain of nir_deref_instr with as the first
-# source of the image intrinsic.  Image variables contain a number of memory
-# and layout qualifiers that influence the semantics of the intrinsic.
+# All image intrinsics come in two versions.  One which take an image target
+# passed as a deref chain as the first source and one which takes an index or
+# handle as the first source.  In the first version, the image variable
+# contains the memory and layout qualifiers that influence the semantics of
+# the intrinsic.  In the second, the image format and access qualifiers are
+# provided as constant indices.
 #
 # All image intrinsics take a four-coordinate vector and a sample index as
 # 2nd and 3rd sources, determining the location within the image that will be
@@ -296,19 +306,23 @@ atomic3("atomic_counter_comp_swap")
 # argument with the value to be written, and image atomic operations take
 # either one or two additional scalar arguments with the same meaning as in
 # the ARB_shader_image_load_store specification.
-intrinsic("image_deref_load", src_comp=[1, 4, 1], dest_comp=0,
-  flags=[CAN_ELIMINATE])
-intrinsic("image_deref_store", src_comp=[1, 4, 1, 0])
-intrinsic("image_deref_atomic_add",  src_comp=[1, 4, 1, 1], dest_comp=1)
-intrinsic("image_deref_atomic_min",  src_comp=[1, 4, 1, 1], dest_comp=1)
-intrinsic("image_deref_atomic_max",  src_comp=[1, 4, 1, 1], dest_comp=1)
-intrinsic("image_deref_atomic_and",  src_comp=[1, 4, 1, 1], dest_comp=1)
-intrinsic("image_deref_atomic_or",   src_comp=[1, 4, 1, 1], dest_comp=1)
-intrinsic("im

[Mesa-dev] [PATCH 19/22] nir: Use a bitfield for image access qualifiers

2018-08-17 Thread Jason Ekstrand
This commit expands the current memory access enum to contain the extra
two bits provided for images.  We choose to follow the SPIR-V convention
of NonReadable and NonWriteable because readonly implies that you *can*
read so readonly + writeonly doesn't make as much sense as NonReadable +
NonWriteable.
---
 src/amd/common/ac_nir_to_llvm.c   |  4 ++--
 src/compiler/glsl/gl_nir_link_uniforms.c  | 12 +++-
 src/compiler/glsl/glsl_to_nir.cpp | 19 ++-
 src/compiler/nir/nir.h|  6 +-
 src/compiler/nir/nir_print.c  | 11 ++-
 src/compiler/shader_enums.h   | 10 ++
 src/compiler/spirv/vtn_variables.c| 10 +-
 .../compiler/brw_nir_lower_image_load_store.c |  4 ++--
 .../vulkan/anv_nir_apply_pipeline_layout.c|  3 ++-
 9 files changed, 45 insertions(+), 34 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index cffc980e51f..ac66cbcb39c 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2348,7 +2348,7 @@ static LLVMValueRef visit_image_load(struct 
ac_nir_context *ctx,
glsl_sampler_type_is_array(type));
args.dmask = 15;
args.attributes = AC_FUNC_ATTR_READONLY;
-   if (var->data.image._volatile || var->data.image.coherent)
+   if (var->data.image.access & (ACCESS_VOLATILE | 
ACCESS_COHERENT))
args.cache_policy |= ac_glc;
 
res = ac_build_image_opcode(&ctx->ac, &args);
@@ -2389,7 +2389,7 @@ static void visit_image_store(struct ac_nir_context *ctx,
args.dim = get_ac_image_dim(&ctx->ac, 
glsl_get_sampler_dim(type),
glsl_sampler_type_is_array(type));
args.dmask = 15;
-   if (force_glc || var->data.image._volatile || 
var->data.image.coherent)
+   if (force_glc || (var->data.image.access & (ACCESS_VOLATILE | 
ACCESS_COHERENT)))
args.cache_policy |= ac_glc;
 
ac_build_image_opcode(&ctx->ac, &args);
diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c 
b/src/compiler/glsl/gl_nir_link_uniforms.c
index 159dfeca59f..1a491dc2e5d 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -424,12 +424,14 @@ nir_link_uniform(struct gl_context *ctx,
  uniform->opaque[stage].index = image_index;
 
  /* Set image access qualifiers */
+ enum gl_access_qualifier image_access =
+state->current_var->data.image.access;
  const GLenum access =
-state->current_var->data.image.read_only ?
-(state->current_var->data.image.write_only ? GL_NONE :
- GL_READ_ONLY) :
-(state->current_var->data.image.write_only ? GL_WRITE_ONLY :
- GL_READ_WRITE);
+(image_access & ACCESS_NON_WRITEABLE) ?
+((image_access & ACCESS_NON_READABLE) ? GL_NONE :
+GL_READ_ONLY) :
+((image_access & ACCESS_NON_READABLE) ? GL_WRITE_ONLY :
+GL_READ_WRITE);
  for (unsigned i = image_index;
   i < MIN2(state->next_image_index, MAX_IMAGE_UNIFORMS);
   i++) {
diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index fbe25dcc5a4..2535beef8dc 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -416,12 +416,21 @@ nir_visitor::visit(ir_variable *ir)
var->data.explicit_binding = ir->data.explicit_binding;
var->data.bindless = ir->data.bindless;
var->data.offset = ir->data.offset;
-   var->data.image.read_only = ir->data.memory_read_only;
-   var->data.image.write_only = ir->data.memory_write_only;
-   var->data.image.coherent = ir->data.memory_coherent;
-   var->data.image._volatile = ir->data.memory_volatile;
-   var->data.image.restrict_flag = ir->data.memory_restrict;
+
+   unsigned image_access = 0;
+   if (ir->data.memory_read_only)
+  image_access |= ACCESS_NON_WRITEABLE;
+   if (ir->data.memory_write_only)
+  image_access |= ACCESS_NON_READABLE;
+   if (ir->data.memory_coherent)
+  image_access |= ACCESS_COHERENT;
+   if (ir->data.memory_volatile)
+  image_access |= ACCESS_VOLATILE;
+   if (ir->data.memory_restrict)
+  image_access |= ACCESS_RESTRICT;
+   var->data.image.access = (gl_access_qualifier)image_access;
var->data.image.format = ir->data.image_format;
+
var->data.fb_fetch_output = ir->data.fb_fetch_output;
var->data.explicit_xfb_buffer = ir->data.explicit_xfb_buffer;
var->data.explicit_xfb_stride = ir->data.explicit_xfb_stride;
diff --git a/src/compiler/nir/n

[Mesa-dev] [PATCH 09/22] nir/format_convert: Rename pack_r11g11b10f to pack_11f11f10f

2018-08-17 Thread Jason Ekstrand
This matches the unpack function.
---
 src/compiler/nir/nir_format_convert.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_format_convert.h 
b/src/compiler/nir/nir_format_convert.h
index 75793733ea6..c79001a50aa 100644
--- a/src/compiler/nir/nir_format_convert.h
+++ b/src/compiler/nir/nir_format_convert.h
@@ -298,7 +298,7 @@ nir_format_unpack_11f11f10f(nir_builder *b, nir_ssa_def 
*packed)
 }
 
 static inline nir_ssa_def *
-nir_format_pack_r11g11b10f(nir_builder *b, nir_ssa_def *color)
+nir_format_pack_11f11f10f(nir_builder *b, nir_ssa_def *color)
 {
/* 10 and 11-bit floats are unsigned.  Clamp to non-negative */
nir_ssa_def *clamped = nir_fmax(b, color, nir_imm_float(b, 0));
-- 
2.17.1

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


[Mesa-dev] [PATCH 21/22] anv, i965: Lower away image derefs in the driver

2018-08-17 Thread Jason Ekstrand
Previously, the back-end compiler turn image access into magic uniform
reads and there was a complex contract between back-end compiler and
driver about setting up and filling out those params.  As of this
commit, both drivers now lower image_deref_load_param_intel intrinsics
to load_uniform intrinsics controlled by the driver and lower the other
image_deref_* intrinsics to image_* intrinsics which take an actual
binding table index.  There are still "magic" uniforms but they are now
added and controlled entirely by the driver and that contract no longer
spans components.

This also has the side-effect of making most image use compile-time
binding table indices.  Previously, all image access pulled the binding
table index from a uniform.  Part of the reason for this was that the
magic uniforms made it difficult to decouple binding table indices from
the uniforms and, since they are indexed completely differently
(especially in Vulkan), it was hard to pull them apart.  Now that the
driver is handling both, it's trivial to decouple the two and provide
actual binding table indices.

Shader-db results on Kaby Lake:

total instructions in shared programs: 15166872 -> 15164293 (-0.02%)
instructions in affected programs: 115834 -> 113255 (-2.23%)
helped: 191
HURT: 0

total cycles in shared programs: 571311495 -> 571196465 (-0.02%)
cycles in affected programs: 4757115 -> 4642085 (-2.42%)
helped: 73
HURT: 67

total spills in shared programs: 10951 -> 10926 (-0.23%)
spills in affected programs: 742 -> 717 (-3.37%)
helped: 7
HURT: 0

total fills in shared programs: 6 -> 22201 (-0.11%)
fills in affected programs: 1146 -> 1121 (-2.18%)
helped: 7
HURT: 0
---
 src/compiler/nir/nir_intrinsics.py|   6 +-
 src/intel/compiler/brw_fs.cpp |  10 +-
 src/intel/compiler/brw_fs.h   |   3 +-
 src/intel/compiler/brw_fs_nir.cpp | 211 +++---
 src/intel/compiler/brw_nir.h  |   5 +
 .../compiler/brw_nir_lower_image_load_store.c |  40 
 .../vulkan/anv_nir_apply_pipeline_layout.c| 159 +
 src/intel/vulkan/anv_pipeline.c   |   4 +-
 .../drivers/dri/i965/brw_nir_uniforms.cpp | 130 +++
 src/mesa/drivers/dri/i965/brw_program.c   |   1 +
 10 files changed, 375 insertions(+), 194 deletions(-)

diff --git a/src/compiler/nir/nir_intrinsics.py 
b/src/compiler/nir/nir_intrinsics.py
index 0dae37ae886..ffcd2c0b83f 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -329,9 +329,9 @@ image("samples", dest_comp=1, flags=[CAN_ELIMINATE, 
CAN_REORDER])
 # variable. The const index specifies which of the six parameters to load.
 intrinsic("image_deref_load_param_intel", src_comp=[1], dest_comp=0,
   indices=[BASE], flags=[CAN_ELIMINATE, CAN_REORDER])
-intrinsic("image_deref_load_raw_intel", src_comp=[1, 1], dest_comp=0,
-  flags=[CAN_ELIMINATE, CAN_REORDER])
-intrinsic("image_deref_store_raw_intel", src_comp=[1, 1, 0])
+image("load_raw_intel", src_comp=[1], dest_comp=0,
+  flags=[CAN_ELIMINATE, CAN_REORDER])
+image("store_raw_intel", src_comp=[1, 0])
 
 # Vulkan descriptor set intrinsics
 #
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 1e1954270e8..2afc1c946ab 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -493,16 +493,14 @@ type_size_scalar(const struct glsl_type *type)
   }
   return size;
case GLSL_TYPE_SAMPLER:
-  /* Samplers take up no register space, since they're baked in at
-   * link time.
-   */
-  return 0;
case GLSL_TYPE_ATOMIC_UINT:
+   case GLSL_TYPE_IMAGE:
+  /* Samplers, atomics, and images take up no register space, since
+   * they're baked in at link time.
+   */
   return 0;
case GLSL_TYPE_SUBROUTINE:
   return 1;
-   case GLSL_TYPE_IMAGE:
-  return BRW_IMAGE_PARAM_SIZE;
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
case GLSL_TYPE_INTERFACE:
diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h
index d56e33715ee..22e8ae5bff0 100644
--- a/src/intel/compiler/brw_fs.h
+++ b/src/intel/compiler/brw_fs.h
@@ -216,6 +216,8 @@ public:
   nir_intrinsic_instr *instr);
void nir_emit_cs_intrinsic(const brw::fs_builder &bld,
   nir_intrinsic_instr *instr);
+   fs_reg get_nir_image_intrinsic_image(const brw::fs_builder &bld,
+nir_intrinsic_instr *instr);
void nir_emit_intrinsic(const brw::fs_builder &bld,
nir_intrinsic_instr *instr);
void nir_emit_tes_intrinsic(const brw::fs_builder &bld,
@@ -231,7 +233,6 @@ public:
fs_reg get_nir_src(const nir_src &src);
fs_reg get_nir_src_imm(const nir_src &src);
fs_reg get_nir_dest(const nir_dest &dest);
-   fs_reg get_nir_image_deref(nir_deref_instr *deref);
   

[Mesa-dev] [PATCH 18/22] intel: Use TXQ for image_size when we have a typed surface

2018-08-17 Thread Jason Ekstrand
---
 src/intel/compiler/brw_eu_defines.h   |  3 +++
 src/intel/compiler/brw_fs.cpp |  8 ++
 src/intel/compiler/brw_fs_generator.cpp   | 26 ---
 src/intel/compiler/brw_fs_nir.cpp | 26 +++
 .../compiler/brw_nir_lower_image_load_store.c | 15 +++
 src/intel/compiler/brw_shader.cpp |  5 
 6 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/src/intel/compiler/brw_eu_defines.h 
b/src/intel/compiler/brw_eu_defines.h
index 2289fc9be70..c36699d7676 100644
--- a/src/intel/compiler/brw_eu_defines.h
+++ b/src/intel/compiler/brw_eu_defines.h
@@ -354,6 +354,9 @@ enum opcode {
SHADER_OPCODE_SAMPLEINFO,
SHADER_OPCODE_SAMPLEINFO_LOGICAL,
 
+   SHADER_OPCODE_IMAGE_SIZE,
+   SHADER_OPCODE_IMAGE_SIZE_LOGICAL,
+
/**
 * Combines multiple sources of size 1 into a larger virtual GRF.
 * For example, parameters for a send-from-GRF message.  Or, updating
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 5b87991652d..1e1954270e8 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -4946,6 +4946,14 @@ fs_visitor::lower_logical_sends()
  lower_sampler_logical_send(ibld, inst, SHADER_OPCODE_SAMPLEINFO);
  break;
 
+  case SHADER_OPCODE_IMAGE_SIZE_LOGICAL:
+ /* Nothing needs to be done except changing the opcode and setting a
+  * message length.
+  */
+ inst->opcode = SHADER_OPCODE_IMAGE_SIZE;
+ inst->mlen = inst->exec_size / 8;
+ break;
+
   case SHADER_OPCODE_UNTYPED_SURFACE_READ_LOGICAL:
  lower_surface_logical_send(ibld, inst,
 SHADER_OPCODE_UNTYPED_SURFACE_READ,
diff --git a/src/intel/compiler/brw_fs_generator.cpp 
b/src/intel/compiler/brw_fs_generator.cpp
index e265d59ccbe..13293d7efbd 100644
--- a/src/intel/compiler/brw_fs_generator.cpp
+++ b/src/intel/compiler/brw_fs_generator.cpp
@@ -1017,6 +1017,9 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg 
dst, struct brw_reg src
   case SHADER_OPCODE_SAMPLEINFO:
  msg_type = GEN6_SAMPLER_MESSAGE_SAMPLE_SAMPLEINFO;
  break;
+  case SHADER_OPCODE_IMAGE_SIZE:
+msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO;
+break;
   default:
 unreachable("not reached");
   }
@@ -1126,10 +1129,20 @@ fs_generator::generate_tex(fs_inst *inst, struct 
brw_reg dst, struct brw_reg src
   }
}
 
-   uint32_t base_binding_table_index = (inst->opcode == SHADER_OPCODE_TG4 ||
- inst->opcode == SHADER_OPCODE_TG4_OFFSET)
- ? prog_data->binding_table.gather_texture_start
- : prog_data->binding_table.texture_start;
+   uint32_t base_binding_table_index;
+   switch (inst->opcode) {
+   case SHADER_OPCODE_TG4:
+   case SHADER_OPCODE_TG4_OFFSET:
+  base_binding_table_index = prog_data->binding_table.gather_texture_start;
+  break;
+   case SHADER_OPCODE_IMAGE_SIZE:
+  /* Image binding table indices are absolute */
+  base_binding_table_index = 0;
+  break;
+   default:
+  base_binding_table_index = prog_data->binding_table.texture_start;
+  break;
+   }
 
if (surface_index.file == BRW_IMMEDIATE_VALUE &&
sampler_index.file == BRW_IMMEDIATE_VALUE) {
@@ -2114,6 +2127,11 @@ fs_generator::generate_code(const cfg_t *cfg, int 
dispatch_width)
   case SHADER_OPCODE_SAMPLEINFO:
 generate_tex(inst, dst, src[0], src[1], src[2]);
 break;
+
+  case SHADER_OPCODE_IMAGE_SIZE:
+generate_tex(inst, dst, src[0], src[1], brw_imm_ud(0));
+break;
+
   case FS_OPCODE_DDX_COARSE:
   case FS_OPCODE_DDX_FINE:
  generate_ddx(inst, dst, src[0]);
diff --git a/src/intel/compiler/brw_fs_nir.cpp 
b/src/intel/compiler/brw_fs_nir.cpp
index 021a31d069c..ac45b559830 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -3914,6 +3914,32 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, 
nir_intrinsic_instr *instr
   break;
}
 
+   case nir_intrinsic_image_deref_size: {
+  nir_deref_instr *deref = nir_src_as_deref(instr->src[0]);
+  const fs_reg image = get_nir_image_deref(deref);
+
+  /* The LOD also serves as the message payload */
+  fs_reg lod = bld.vgrf(BRW_REGISTER_TYPE_UD);
+  bld.MOV(lod, brw_imm_ud(0));
+
+  fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_UD, 4);
+  fs_inst *inst = bld.emit(SHADER_OPCODE_IMAGE_SIZE_LOGICAL,
+   tmp, lod, image);
+  inst->size_written = type_sz(tmp.type) * bld.dispatch_width() * 4;
+
+  for (unsigned c = 0; c < instr->dest.ssa.num_components; ++c) {
+ if (c == 2 && glsl_get_sampler_dim(deref->type) == 
GLSL_SAMPLER_DIM_CUBE) {
+bld.emit(SHADER_OPCODE_INT_QUOTIENT,
+ offset(retype(dest, tmp.type), bld, c),
+ offset(tmp, bld, c), brw_imm_ud(6));
+ } else 

[Mesa-dev] [PATCH 22/22] intel/compiler: Remove surface_idx from brw_image_param

2018-08-17 Thread Jason Ekstrand
Now that the drivers are lowering to surface indices themselves, we no
longer need to push the surface index into the shader.
---
 src/intel/compiler/brw_compiler.h| 16 ++--
 .../compiler/brw_nir_lower_image_load_store.c|  3 ---
 src/intel/vulkan/anv_nir_apply_pipeline_layout.c |  2 --
 src/intel/vulkan/genX_cmd_buffer.c   |  2 --
 src/mesa/drivers/dri/i965/brw_nir_uniforms.cpp   |  3 ---
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 12 +++-
 6 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/src/intel/compiler/brw_compiler.h 
b/src/intel/compiler/brw_compiler.h
index c510d34ce2e..d8c9499065f 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -434,18 +434,14 @@ union brw_any_prog_key {
  * entries [most of them except when we're doing untyped surface
  * access] will be removed by the uniform packing pass.
  */
-#define BRW_IMAGE_PARAM_SURFACE_IDX_OFFSET  0
-#define BRW_IMAGE_PARAM_OFFSET_OFFSET   4
-#define BRW_IMAGE_PARAM_SIZE_OFFSET 8
-#define BRW_IMAGE_PARAM_STRIDE_OFFSET   12
-#define BRW_IMAGE_PARAM_TILING_OFFSET   16
-#define BRW_IMAGE_PARAM_SWIZZLING_OFFSET20
-#define BRW_IMAGE_PARAM_SIZE24
+#define BRW_IMAGE_PARAM_OFFSET_OFFSET   0
+#define BRW_IMAGE_PARAM_SIZE_OFFSET 4
+#define BRW_IMAGE_PARAM_STRIDE_OFFSET   8
+#define BRW_IMAGE_PARAM_TILING_OFFSET   12
+#define BRW_IMAGE_PARAM_SWIZZLING_OFFSET16
+#define BRW_IMAGE_PARAM_SIZE20
 
 struct brw_image_param {
-   /** Surface binding table index. */
-   uint32_t surface_idx;
-
/** Offset applied to the X and Y surface coordinates. */
uint32_t offset[2];
 
diff --git a/src/intel/compiler/brw_nir_lower_image_load_store.c 
b/src/intel/compiler/brw_nir_lower_image_load_store.c
index f888e6fb00f..065b11ab10a 100644
--- a/src/intel/compiler/brw_nir_lower_image_load_store.c
+++ b/src/intel/compiler/brw_nir_lower_image_load_store.c
@@ -91,9 +91,6 @@ _load_image_param(nir_builder *b, nir_deref_instr *deref, 
unsigned offset)
nir_intrinsic_set_base(load, offset / 4);
 
switch (offset) {
-   case BRW_IMAGE_PARAM_SURFACE_IDX_OFFSET:
-  load->num_components = 1;
-  break;
case BRW_IMAGE_PARAM_OFFSET_OFFSET:
case BRW_IMAGE_PARAM_SWIZZLING_OFFSET:
   load->num_components = 2;
diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c 
b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
index 583b5a17cc6..856101cc2ff 100644
--- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
+++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
@@ -527,8 +527,6 @@ anv_nir_apply_pipeline_layout(struct anv_pipeline *pipeline,
   struct anv_push_constants *null_data = NULL;
   const struct brw_image_param *image_param = null_data->images;
   for (uint32_t i = 0; i < map->image_count; i++) {
- setup_vec4_uniform_value(param + BRW_IMAGE_PARAM_SURFACE_IDX_OFFSET,
-  (uintptr_t)&image_param->surface_idx, 1);
  setup_vec4_uniform_value(param + BRW_IMAGE_PARAM_OFFSET_OFFSET,
   (uintptr_t)image_param->offset, 2);
  setup_vec4_uniform_value(param + BRW_IMAGE_PARAM_SIZE_OFFSET,
diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
b/src/intel/vulkan/genX_cmd_buffer.c
index b7ed817d3a0..16168d415c3 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2109,7 +2109,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
 &cmd_buffer->state.push_constants[stage]->images[image++];
 
  *image_param = 
desc->image_view->planes[binding->plane].storage_image_param;
- image_param->surface_idx = bias + s;
  break;
   }
 
@@ -2159,7 +2158,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
 &cmd_buffer->state.push_constants[stage]->images[image++];
 
  *image_param = desc->buffer_view->storage_image_param;
- image_param->surface_idx = bias + s;
  break;
 
   default:
diff --git a/src/mesa/drivers/dri/i965/brw_nir_uniforms.cpp 
b/src/mesa/drivers/dri/i965/brw_nir_uniforms.cpp
index 8a560d9bac1..0b028afdce7 100644
--- a/src/mesa/drivers/dri/i965/brw_nir_uniforms.cpp
+++ b/src/mesa/drivers/dri/i965/brw_nir_uniforms.cpp
@@ -93,9 +93,6 @@ brw_setup_image_uniform_values(gl_shader_stage stage,
   /* Upload the brw_image_param structure.  The order is expected to match
* the BRW_IMAGE_PARAM_*_OFFSET defines.
*/
-  setup_vec4_image_param(param + BRW_IMAGE_PARAM_SURFACE_IDX_OFFSET,
- image_idx,
- offsetof(brw_image_param, surface_idx), 1);
   setup_vec4_image_param(param + BRW_IMAGE_PARAM_OFFSET_OFFSET,
  image_idx,
  offsetof(brw_image_param, offset), 2);
diff --git a/src/mesa/

[Mesa-dev] [PATCH 13/22] nir/types: Add a wrapper for coordinate_components

2018-08-17 Thread Jason Ekstrand
---
 src/compiler/nir_types.cpp | 7 +++
 src/compiler/nir_types.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index c8a29404969..c00712f48b6 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -163,6 +163,13 @@ glsl_get_sampler_target(const struct glsl_type *type)
return type->sampler_index();
 }
 
+int
+glsl_get_sampler_coordinate_components(const struct glsl_type *type)
+{
+   assert(glsl_type_is_sampler(type) || glsl_type_is_image(type));
+   return type->coordinate_components();
+}
+
 unsigned
 glsl_get_record_location_offset(const struct glsl_type *type,
 unsigned length)
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index db3a4dee2d9..3bea0db6293 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -83,6 +83,7 @@ const char *glsl_get_struct_elem_name(const struct glsl_type 
*type,
 enum glsl_sampler_dim glsl_get_sampler_dim(const struct glsl_type *type);
 enum glsl_base_type glsl_get_sampler_result_type(const struct glsl_type *type);
 unsigned glsl_get_sampler_target(const struct glsl_type *type);
+int glsl_get_sampler_coordinate_components(const struct glsl_type *type);
 
 unsigned glsl_get_record_location_offset(const struct glsl_type *type,
  unsigned length);
-- 
2.17.1

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


[Mesa-dev] [PATCH 17/22] glsl/link, i965: Make ImageAccess four-state

2018-08-17 Thread Jason Ekstrand
The GLSL spec allows you to set both the "readonly" and "writeonly"
qualifiers on images to indicate that it can only be used with
imageSize.  However, we had no way of representing this int he linked
shader and flagged it as GL_READ_ONLY.  This is good from a "does it use
this buffer?" perspective but not from a format and access lowering
perspective.  By using GL_NONE for if "readonly" and "writeonly" are
both set, we can detect this case in the driver and handle it correctly.

Nothing currently relies on the type of surface in the "readonly" +
"writeonly" case but that's about to change.  i965 is the only drier
which uses the ImageAccess field and gl_bindless_image::access is
currently unused.
---
 src/compiler/glsl/gl_nir_link_uniforms.c |  8 +---
 src/compiler/glsl/link_uniforms.cpp  |  8 +---
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 12 ++--
 src/mesa/main/mtypes.h   |  9 ++---
 4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c 
b/src/compiler/glsl/gl_nir_link_uniforms.c
index 1573e30c41e..159dfeca59f 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -425,9 +425,11 @@ nir_link_uniform(struct gl_context *ctx,
 
  /* Set image access qualifiers */
  const GLenum access =
-(state->current_var->data.image.read_only ? GL_READ_ONLY :
- state->current_var->data.image.write_only ? GL_WRITE_ONLY :
- GL_READ_WRITE);
+state->current_var->data.image.read_only ?
+(state->current_var->data.image.write_only ? GL_NONE :
+ GL_READ_ONLY) :
+(state->current_var->data.image.write_only ? GL_WRITE_ONLY :
+ GL_READ_WRITE);
  for (unsigned i = image_index;
   i < MIN2(state->next_image_index, MAX_IMAGE_UNIFORMS);
   i++) {
diff --git a/src/compiler/glsl/link_uniforms.cpp 
b/src/compiler/glsl/link_uniforms.cpp
index 8d3f95fe114..f86d354c437 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -690,9 +690,11 @@ private:
 
  /* Set image access qualifiers */
  const GLenum access =
-(current_var->data.memory_read_only ? GL_READ_ONLY :
- current_var->data.memory_write_only ? GL_WRITE_ONLY :
-GL_READ_WRITE);
+current_var->data.memory_read_only ?
+(current_var->data.memory_write_only ? GL_NONE :
+   GL_READ_ONLY) :
+(current_var->data.memory_write_only ? GL_WRITE_ONLY :
+   GL_READ_WRITE);
 
  if (current_var->data.bindless) {
 if (!set_opaque_indices(base_type, uniform, name,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 2aef0ef59f7..35bb49f30f2 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1455,7 +1455,7 @@ get_image_format(struct brw_context *brw, mesa_format 
format, GLenum access)
 {
const struct gen_device_info *devinfo = &brw->screen->devinfo;
enum isl_format hw_format = brw_isl_format_for_mesa_format(format);
-   if (access == GL_WRITE_ONLY) {
+   if (access == GL_WRITE_ONLY || access == GL_NONE) {
   return hw_format;
} else if (isl_has_matching_typed_storage_image_format(devinfo, hw_format)) 
{
   /* Typed surface reads support a very limited subset of the shader
@@ -1523,6 +1523,7 @@ update_image_surface(struct brw_context *brw,
if (_mesa_is_image_unit_valid(&brw->ctx, u)) {
   struct gl_texture_object *obj = u->TexObj;
   const unsigned format = get_image_format(brw, u->_ActualFormat, access);
+  const bool written = (access != GL_READ_ONLY && access != GL_NONE);
 
   if (obj->Target == GL_TEXTURE_BUFFER) {
  const unsigned texel_size = (format == ISL_FORMAT_RAW ? 1 :
@@ -1530,13 +1531,12 @@ update_image_surface(struct brw_context *brw,
  const unsigned buffer_size = buffer_texture_range_size(brw, obj);
  struct brw_bo *const bo = !obj->BufferObject ? NULL :
 intel_bufferobj_buffer(brw, intel_buffer_object(obj->BufferObject),
-   obj->BufferOffset, buffer_size,
-   access != GL_READ_ONLY);
+   obj->BufferOffset, buffer_size, written);
 
  brw_emit_buffer_surface_state(
 brw, surf_offset, bo, obj->BufferOffset,
 format, buffer_size, texel_size,
-access != GL_READ_ONLY ? RELOC_WRITE : 0);
+written ? RELOC_WRITE : 0);
 
  update_buffer_image_param(brw, u, surface_idx, param);
 
@@ -1560,7 +1

[Mesa-dev] [PATCH 12/22] anv/pipeline: Remove dead image loads in lower_input_attacnments

2018-08-17 Thread Jason Ekstrand
Dead code will get rid of them eventually but it's better if they're
just gone so we guarantee they won't trip up later passes.
---
 src/intel/vulkan/anv_nir_lower_input_attachments.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/anv_nir_lower_input_attachments.c 
b/src/intel/vulkan/anv_nir_lower_input_attachments.c
index 81e5ad53eaa..97e1f48936a 100644
--- a/src/intel/vulkan/anv_nir_lower_input_attachments.c
+++ b/src/intel/vulkan/anv_nir_lower_input_attachments.c
@@ -55,7 +55,7 @@ try_lower_input_load(nir_function_impl *impl, 
nir_intrinsic_instr *load)
 
nir_builder b;
nir_builder_init(&b, impl);
-   b.cursor = nir_before_instr(&load->instr);
+   b.cursor = nir_instr_remove(&load->instr);
 
nir_ssa_def *frag_coord = nir_f2i32(&b, load_frag_coord(&b));
nir_ssa_def *offset = nir_ssa_for_src(&b, load->src[1], 2);
@@ -122,7 +122,7 @@ anv_nir_lower_input_attachments(nir_shader *shader)
  continue;
 
   nir_foreach_block(block, function->impl) {
- nir_foreach_instr(instr, block) {
+ nir_foreach_instr_safe(instr, block) {
 if (instr->type != nir_instr_type_intrinsic)
continue;
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 10/22] nir/format_convert: Fix a bitmask in unpack_11f11f10f

2018-08-17 Thread Jason Ekstrand
Fixes: 4e337b42f9a2 "nir/format_convert: Add pack/unpack for R11F_G11F_B10F"
---
 src/compiler/nir/nir_format_convert.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_format_convert.h 
b/src/compiler/nir/nir_format_convert.h
index c79001a50aa..27a8ac08d49 100644
--- a/src/compiler/nir/nir_format_convert.h
+++ b/src/compiler/nir/nir_format_convert.h
@@ -288,7 +288,7 @@ nir_format_unpack_11f11f10f(nir_builder *b, nir_ssa_def 
*packed)
 {
nir_ssa_def *chans[3];
chans[0] = nir_mask_shift(b, packed, 0x07ff, 4);
-   chans[1] = nir_mask_shift(b, packed, 0x003ff100, -7);
+   chans[1] = nir_mask_shift(b, packed, 0x003ff800, -7);
chans[2] = nir_mask_shift(b, packed, 0xffc0, -17);
 
for (unsigned i = 0; i < 3; i++)
-- 
2.17.1

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


[Mesa-dev] [PATCH 14/22] intel/compiler: Do image load/store lowering to NIR

2018-08-17 Thread Jason Ekstrand
This commit moves our storage image format conversion codegen into NIR
instead of doing it in the back-end.  This has the advantage of letting
us run it through NIR's optimizer which is pretty effective at shrinking
things down.  In the common case of rgba8, the number of instructions
emitted after NIR is done with it is half of what it was with the
lowering happening in the back-end.  On the downside, the back-end's
lowering is able to directly use predicates and the NIR lowering has to
use IFs.

Shader-db results on Kaby Lake:

total instructions in shared programs: 15166910 -> 15166872 (<.01%)
instructions in affected programs: 5895 -> 5857 (-0.64%)
helped: 15
HURT: 0

Clearly, we don't have that much image_load_store happening in the
shaders in shader-db
---
 src/compiler/nir/nir_intrinsics.py|9 +
 src/intel/Makefile.sources|1 +
 src/intel/compiler/brw_fs_nir.cpp |  128 +-
 src/intel/compiler/brw_fs_surface_builder.cpp | 1030 -
 src/intel/compiler/brw_fs_surface_builder.h   |   20 -
 src/intel/compiler/brw_nir.h  |3 +
 .../compiler/brw_nir_lower_image_load_store.c |  824 +
 src/intel/compiler/meson.build|1 +
 src/intel/vulkan/anv_pipeline.c   |2 +
 src/mesa/drivers/dri/i965/brw_program.c   |2 +
 10 files changed, 899 insertions(+), 1121 deletions(-)
 create mode 100644 src/intel/compiler/brw_nir_lower_image_load_store.c

diff --git a/src/compiler/nir/nir_intrinsics.py 
b/src/compiler/nir/nir_intrinsics.py
index 63c602c8874..45872e00c55 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -310,6 +310,15 @@ intrinsic("image_deref_atomic_comp_swap", src_comp=[1, 4, 
1, 1, 1], dest_comp=1)
 intrinsic("image_deref_size",src_comp=[1], dest_comp=0, 
flags=[CAN_ELIMINATE, CAN_REORDER])
 intrinsic("image_deref_samples", src_comp=[1], dest_comp=1, 
flags=[CAN_ELIMINATE, CAN_REORDER])
 
+# Intel-specific query for loading from the brw_image_param struct passed
+# into the shader as a uniform.  The variable is a deref to the image
+# variable. The const index specifies which of the six parameters to load.
+intrinsic("image_deref_load_param_intel", src_comp=[1], dest_comp=0,
+  indices=[BASE], flags=[CAN_ELIMINATE, CAN_REORDER])
+intrinsic("image_deref_load_raw_intel", src_comp=[1, 1], dest_comp=0,
+  flags=[CAN_ELIMINATE, CAN_REORDER])
+intrinsic("image_deref_store_raw_intel", src_comp=[1, 1, 0])
+
 # Vulkan descriptor set intrinsics
 #
 # The Vulkan API uses a different binding model from GL.  In the Vulkan
diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources
index 5f6cd96825b..d10c4511734 100644
--- a/src/intel/Makefile.sources
+++ b/src/intel/Makefile.sources
@@ -84,6 +84,7 @@ COMPILER_FILES = \
compiler/brw_nir_analyze_ubo_ranges.c \
compiler/brw_nir_attribute_workarounds.c \
compiler/brw_nir_lower_cs_intrinsics.c \
+   compiler/brw_nir_lower_image_load_store.c \
compiler/brw_nir_opt_peephole_ffma.c \
compiler/brw_nir_tcs_workarounds.c \
compiler/brw_packed_float.c \
diff --git a/src/intel/compiler/brw_fs_nir.cpp 
b/src/intel/compiler/brw_fs_nir.cpp
index 6e9a5829d3b..021a31d069c 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -3871,58 +3871,89 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, 
nir_intrinsic_instr *instr
case nir_intrinsic_image_deref_atomic_xor:
case nir_intrinsic_image_deref_atomic_exchange:
case nir_intrinsic_image_deref_atomic_comp_swap: {
-  using namespace image_access;
-
   if (stage == MESA_SHADER_FRAGMENT &&
   instr->intrinsic != nir_intrinsic_image_deref_load)
  brw_wm_prog_data(prog_data)->has_side_effects = true;
 
   /* Get the referenced image variable and type. */
   nir_deref_instr *deref = nir_src_as_deref(instr->src[0]);
-  const nir_variable *var = nir_deref_instr_get_variable(deref);
-  const glsl_type *type = var->type->without_array();
-  const brw_reg_type base_type = get_image_base_type(type);
+  const glsl_type *type = deref->type;
 
   /* Get some metadata from the image intrinsic. */
   const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic];
-  const unsigned arr_dims = type->sampler_array ? 1 : 0;
-  const unsigned surf_dims = type->coordinate_components() - arr_dims;
-  const unsigned format = var->data.image.format;
+  const unsigned dims = type->coordinate_components();
   const unsigned dest_components = nir_intrinsic_dest_components(instr);
 
   /* Get the arguments of the image intrinsic. */
   const fs_reg image = get_nir_image_deref(deref);
-  const fs_reg addr = retype(get_nir_src(instr->src[1]),
- BRW_REGISTER_TYPE_UD);
+  const fs_reg coords = retype(get_nir_src(instr->s

[Mesa-dev] [PATCH 05/22] nir/format_convert: Add support for unpacking signed integers

2018-08-17 Thread Jason Ekstrand
---
 src/compiler/nir/nir_format_convert.h | 37 +--
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/src/compiler/nir/nir_format_convert.h 
b/src/compiler/nir/nir_format_convert.h
index 45532b74884..b1345f7263b 100644
--- a/src/compiler/nir/nir_format_convert.h
+++ b/src/compiler/nir/nir_format_convert.h
@@ -51,30 +51,51 @@ nir_mask_shift_or(struct nir_builder *b, nir_ssa_def *dst, 
nir_ssa_def *src,
 }
 
 static inline nir_ssa_def *
-nir_format_unpack_uint(nir_builder *b, nir_ssa_def *packed,
-   const unsigned *bits, unsigned num_components)
+nir_format_unpack_int(nir_builder *b, nir_ssa_def *packed,
+  const unsigned *bits, unsigned num_components,
+  bool sign_extend)
 {
assert(num_components >= 1 && num_components <= 4);
+   const unsigned bit_size = packed->bit_size;
nir_ssa_def *comps[4];
 
-   if (bits[0] >= packed->bit_size) {
-  assert(bits[0] == packed->bit_size);
+   if (bits[0] >= bit_size) {
+  assert(bits[0] == bit_size);
   assert(num_components == 1);
   return packed;
}
 
unsigned offset = 0;
for (unsigned i = 0; i < num_components; i++) {
-  assert(bits[i] < 32);
-  nir_ssa_def *mask = nir_imm_int(b, (1u << bits[i]) - 1);
-  comps[i] = nir_iand(b, nir_shift(b, packed, -offset), mask);
+  assert(bits[i] < bit_size);
+  assert(offset + bits[i] <= bit_size);
+  nir_ssa_def *lshift = nir_imm_int(b, bit_size - (offset + bits[i]));
+  nir_ssa_def *rshift = nir_imm_int(b, bit_size - bits[i]);
+  if (sign_extend)
+ comps[i] = nir_ishr(b, nir_ishl(b, packed, lshift), rshift);
+  else
+ comps[i] = nir_ushr(b, nir_ishl(b, packed, lshift), rshift);
   offset += bits[i];
}
-   assert(offset <= packed->bit_size);
+   assert(offset <= bit_size);
 
return nir_vec(b, comps, num_components);
 }
 
+static inline nir_ssa_def *
+nir_format_unpack_uint(nir_builder *b, nir_ssa_def *packed,
+   const unsigned *bits, unsigned num_components)
+{
+   return nir_format_unpack_int(b, packed, bits, num_components, false);
+}
+
+static inline nir_ssa_def *
+nir_format_unpack_sint(nir_builder *b, nir_ssa_def *packed,
+   const unsigned *bits, unsigned num_components)
+{
+   return nir_format_unpack_int(b, packed, bits, num_components, true);
+}
+
 static inline nir_ssa_def *
 nir_format_pack_uint_unmasked(nir_builder *b, nir_ssa_def *color,
   const unsigned *bits, unsigned num_components)
-- 
2.17.1

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


[Mesa-dev] [PATCH 08/22] nir/format_convert: Add [us]norm conversion helpers

2018-08-17 Thread Jason Ekstrand
---
 src/compiler/nir/nir_format_convert.h | 56 +++
 1 file changed, 56 insertions(+)

diff --git a/src/compiler/nir/nir_format_convert.h 
b/src/compiler/nir/nir_format_convert.h
index f2eafcbf5b4..75793733ea6 100644
--- a/src/compiler/nir/nir_format_convert.h
+++ b/src/compiler/nir/nir_format_convert.h
@@ -201,6 +201,62 @@ nir_format_bitcast_uvec_unmasked(nir_builder *b, 
nir_ssa_def *src,
return nir_vec(b, dst_chan, dst_components);
 }
 
+static inline nir_ssa_def *
+_nir_format_norm_factor(nir_builder *b, unsigned *bits,
+unsigned num_components,
+bool is_signed)
+{
+   nir_const_value factor;
+   for (unsigned i = 0; i < num_components; i++) {
+  assert(bits[i] < 32);
+  factor.f32[i] = (1ul << (bits[i] - is_signed)) - 1;
+   }
+   return nir_build_imm(b, num_components, 32, factor);
+}
+
+static inline nir_ssa_def *
+nir_format_unorm_to_float(nir_builder *b, nir_ssa_def *u, unsigned *bits)
+{
+   nir_ssa_def *factor =
+  _nir_format_norm_factor(b, bits, u->num_components, false);
+
+   return nir_fdiv(b, nir_u2f32(b, u), factor);
+}
+
+static inline nir_ssa_def *
+nir_format_snorm_to_float(nir_builder *b, nir_ssa_def *s, unsigned *bits)
+{
+   nir_ssa_def *factor =
+  _nir_format_norm_factor(b, bits, s->num_components, true);
+
+   return nir_fmax(b, nir_fdiv(b, nir_i2f32(b, s), factor),
+  nir_imm_float(b, -1.0f));
+}
+
+static inline nir_ssa_def *
+nir_format_float_to_unorm(nir_builder *b, nir_ssa_def *f, unsigned *bits)
+{
+   nir_ssa_def *factor =
+  _nir_format_norm_factor(b, bits, f->num_components, false);
+
+   /* Clamp to the range [0, 1] */
+   f = nir_fsat(b, f);
+
+   return nir_f2u32(b, nir_fround_even(b, nir_fmul(b, f, factor)));
+}
+
+static inline nir_ssa_def *
+nir_format_float_to_snorm(nir_builder *b, nir_ssa_def *f, unsigned *bits)
+{
+   nir_ssa_def *factor =
+  _nir_format_norm_factor(b, bits, f->num_components, true);
+
+   /* Clamp to the range [0, 1] */
+   f = nir_fmin(b, nir_fmax(b, f, nir_imm_float(b, -1)), nir_imm_float(b, 1));
+
+   return nir_f2i32(b, nir_fround_even(b, nir_fmul(b, f, factor)));
+}
+
 static inline nir_ssa_def *
 nir_format_linear_to_srgb(nir_builder *b, nir_ssa_def *c)
 {
-- 
2.17.1

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


[Mesa-dev] [PATCH 07/22] nir/format_convert: Rename nir_format_bitcast_uint_vec

2018-08-17 Thread Jason Ekstrand
We have a name for that, it's called a uvec.  This just makes the
function name a bit shorter.  While we're here, we also add an assert
for one of the assumptions this function makes.
---
 src/compiler/nir/nir_format_convert.h | 5 +++--
 src/intel/blorp/blorp_blit.c  | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/nir_format_convert.h 
b/src/compiler/nir/nir_format_convert.h
index 305273cdfdd..f2eafcbf5b4 100644
--- a/src/compiler/nir/nir_format_convert.h
+++ b/src/compiler/nir/nir_format_convert.h
@@ -148,9 +148,10 @@ nir_format_pack_uint(nir_builder *b, nir_ssa_def *color,
 }
 
 static inline nir_ssa_def *
-nir_format_bitcast_uint_vec_unmasked(nir_builder *b, nir_ssa_def *src,
- unsigned src_bits, unsigned dst_bits)
+nir_format_bitcast_uvec_unmasked(nir_builder *b, nir_ssa_def *src,
+ unsigned src_bits, unsigned dst_bits)
 {
+   assert(src->bit_size >= src_bits && src->bit_size >= dst_bits);
assert(src_bits == 8 || src_bits == 16 || src_bits == 32);
assert(dst_bits == 8 || dst_bits == 16 || dst_bits == 32);
 
diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
index 7cc580abd06..60cb32641d6 100644
--- a/src/intel/blorp/blorp_blit.c
+++ b/src/intel/blorp/blorp_blit.c
@@ -939,7 +939,7 @@ bit_cast_color(struct nir_builder *b, nir_ssa_def *color,
  isl_format_get_num_channels(key->src_format);
   color = nir_channels(b, color, (1 << src_channels) - 1);
 
-  color = nir_format_bitcast_uint_vec_unmasked(b, color, src_bpc, dst_bpc);
+  color = nir_format_bitcast_uvec_unmasked(b, color, src_bpc, dst_bpc);
}
 
/* Blorp likes to assume that colors are vec4s */
-- 
2.17.1

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


[Mesa-dev] [PATCH 15/22] isl: Use the view array length for the image size

2018-08-17 Thread Jason Ekstrand
---
 src/intel/isl/isl_storage_image.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/intel/isl/isl_storage_image.c 
b/src/intel/isl/isl_storage_image.c
index e2bd4ddebad..43398e8a020 100644
--- a/src/intel/isl/isl_storage_image.c
+++ b/src/intel/isl/isl_storage_image.c
@@ -228,13 +228,16 @@ isl_surf_fill_image_param(const struct isl_device *dev,
 {
*param = image_param_defaults;
 
+   if (surf->dim != ISL_SURF_DIM_3D) {
+  assert(view->base_array_layer + view->array_len <=
+ surf->logical_level0_px.array_len);
+   }
param->size[0] = isl_minify(surf->logical_level0_px.w, view->base_level);
param->size[1] = isl_minify(surf->logical_level0_px.h, view->base_level);
if (surf->dim == ISL_SURF_DIM_3D) {
   param->size[2] = isl_minify(surf->logical_level0_px.d, view->base_level);
} else {
-  param->size[2] = surf->logical_level0_px.array_len -
-   view->base_array_layer;
+  param->size[2] = view->array_len;
}
 
isl_surf_get_image_offset_el(surf, view->base_level,
-- 
2.17.1

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


[Mesa-dev] [PATCH 04/22] nir/opcodes: Make unpack_half_2x16_split_* variable-width

2018-08-17 Thread Jason Ekstrand
There is nothing inherent about these opcodes that requires them to only
take scalars.  It's very convenient if we let them take vectors as well.
---
 src/compiler/nir/nir_opcodes.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index ed8e0ae9f39..4ef4ecc6f22 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -304,10 +304,10 @@ unop_horiz("unpack_32_2x16", 2, tuint16, 1, tuint32,
 # Lowered floating point unpacking operations.
 
 
-unop_horiz("unpack_half_2x16_split_x", 1, tfloat32, 1, tuint32,
-   "unpack_half_1x16((uint16_t)(src0.x & 0x))")
-unop_horiz("unpack_half_2x16_split_y", 1, tfloat32, 1, tuint32,
-   "unpack_half_1x16((uint16_t)(src0.x >> 16))")
+unop_convert("unpack_half_2x16_split_x", tfloat32, tuint32,
+ "unpack_half_1x16((uint16_t)(src0 & 0x))")
+unop_convert("unpack_half_2x16_split_y", tfloat32, tuint32,
+ "unpack_half_1x16((uint16_t)(src0 >> 16))")
 
 unop_convert("unpack_32_2x16_split_x", tuint16, tuint32, "src0")
 unop_convert("unpack_32_2x16_split_y", tuint16, tuint32, "src0 >> 16")
-- 
2.17.1

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


[Mesa-dev] [PATCH 11/22] nir: Make image load/store intrinsics variable-width

2018-08-17 Thread Jason Ekstrand
Instead of requiring 4 components, this allows them to potentially use
fewer.  Both the SPIR-V and GLSL paths still generate vec4 intrinsics so
drivers which assume 4 components should be safe.  However, we want to
be able to shrink them for i965.
---
 src/compiler/glsl/glsl_to_nir.cpp  | 9 +++--
 src/compiler/nir/nir_intrinsics.py | 4 ++--
 src/compiler/spirv/spirv_to_nir.c  | 2 ++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index b1d1da89111..fbe25dcc5a4 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -883,12 +883,17 @@ nir_visitor::visit(ir_call *ir)
  /* Set the intrinsic destination. */
  if (ir->return_deref) {
 unsigned num_components = ir->return_deref->type->vector_elements;
-if (instr->intrinsic == nir_intrinsic_image_deref_size)
-   instr->num_components = num_components;
 nir_ssa_dest_init(&instr->instr, &instr->dest,
   num_components, 32, NULL);
  }
 
+ if (op == nir_intrinsic_image_deref_size) {
+instr->num_components = instr->dest.ssa.num_components;
+ } else if (op == nir_intrinsic_image_deref_load ||
+op == nir_intrinsic_image_deref_store) {
+instr->num_components = 4;
+ }
+
  if (op == nir_intrinsic_image_deref_size ||
  op == nir_intrinsic_image_deref_samples) {
 nir_builder_instr_insert(&b, &instr->instr);
diff --git a/src/compiler/nir/nir_intrinsics.py 
b/src/compiler/nir/nir_intrinsics.py
index d688a57181b..63c602c8874 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -296,9 +296,9 @@ atomic3("atomic_counter_comp_swap")
 # argument with the value to be written, and image atomic operations take
 # either one or two additional scalar arguments with the same meaning as in
 # the ARB_shader_image_load_store specification.
-intrinsic("image_deref_load", src_comp=[1, 4, 1], dest_comp=4,
+intrinsic("image_deref_load", src_comp=[1, 4, 1], dest_comp=0,
   flags=[CAN_ELIMINATE])
-intrinsic("image_deref_store", src_comp=[1, 4, 1, 4])
+intrinsic("image_deref_store", src_comp=[1, 4, 1, 0])
 intrinsic("image_deref_atomic_add",  src_comp=[1, 4, 1, 1], dest_comp=1)
 intrinsic("image_deref_atomic_min",  src_comp=[1, 4, 1, 1], dest_comp=1)
 intrinsic("image_deref_atomic_max",  src_comp=[1, 4, 1, 1], dest_comp=1)
diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index b5ec2de7bf9..96224354057 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -2467,6 +2467,8 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
   const uint32_t value_id = opcode == SpvOpAtomicStore ? w[4] : w[3];
   nir_ssa_def *value = vtn_ssa_value(b, value_id)->def;
   /* nir_intrinsic_image_deref_store always takes a vec4 value */
+  assert(op == nir_intrinsic_image_deref_store);
+  intrin->num_components = 4;
   intrin->src[3] = nir_src_for_ssa(expand_to_vec4(&b->nb, value));
   break;
}
-- 
2.17.1

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


[Mesa-dev] [PATCH 03/22] nir/algebraic: Add some max/min optimizations

2018-08-17 Thread Jason Ekstrand
Found by inspection.  This doesn't help much now but we'll see this
pattern with images if you load UNORM and then store UNORM.

Shader-db results on Kaby Lake:

total instructions in shared programs: 15166916 -> 15166910 (<.01%)
instructions in affected programs: 761 -> 755 (-0.79%)
helped: 6
HURT: 0
---
 src/compiler/nir/nir_opt_algebraic.py | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index 07fbb161a4e..55a1feeaf47 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -302,6 +302,12 @@ optimizations = [
(('imax', a, a), a),
(('umin', a, a), a),
(('umax', a, a), a),
+   (('fmax', ('fmax', a, b), b), ('fmax', a, b)),
+   (('umax', ('umax', a, b), b), ('umax', a, b)),
+   (('imax', ('imax', a, b), b), ('imax', a, b)),
+   (('fmin', ('fmin', a, b), b), ('fmin', a, b)),
+   (('umin', ('umin', a, b), b), ('umin', a, b)),
+   (('imin', ('imin', a, b), b), ('imin', a, b)),
(('fmax', a, ('fneg', a)), ('fabs', a)),
(('imax', a, ('ineg', a)), ('iabs', a)),
(('fmin', a, ('fneg', a)), ('fneg', ('fabs', a))),
-- 
2.17.1

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


[Mesa-dev] [PATCH 02/22] nir/algebraic: Add more extract_[iu](8|16) optimizations

2018-08-17 Thread Jason Ekstrand
This adds the "(a << N) >> M" family of mask or sign-extensions.  Not a
huge win right now but this pattern will soon be generated by NIR format
lowering code.

Shader-db results on Kaby Lake:

total instructions in shared programs: 15166918 -> 15166916 (<.01%)
instructions in affected programs: 36 -> 34 (-5.56%)
helped: 2
HURT: 0
---
 src/compiler/nir/nir_opt_algebraic.py | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index 28090d069cd..07fbb161a4e 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -543,13 +543,23 @@ optimizations = [
('unpack_64_2x32_split_y', a)), a),
 
# Byte extraction
+   (('ushr', ('ishl', 'a@32', 24), 24), ('extract_u8', a, 0), 
'!options->lower_extract_byte'),
+   (('ushr', ('ishl', 'a@32', 16), 24), ('extract_u8', a, 1), 
'!options->lower_extract_byte'),
+   (('ushr', ('ishl', 'a@32', 8), 24), ('extract_u8', a, 2), 
'!options->lower_extract_byte'),
(('ushr', 'a@32', 24), ('extract_u8', a, 3), 
'!options->lower_extract_byte'),
+   (('ishr', ('ishl', 'a@32', 24), 24), ('extract_i8', a, 0), 
'!options->lower_extract_byte'),
+   (('ishr', ('ishl', 'a@32', 16), 24), ('extract_i8', a, 1), 
'!options->lower_extract_byte'),
+   (('ishr', ('ishl', 'a@32', 8), 24), ('extract_i8', a, 2), 
'!options->lower_extract_byte'),
+   (('ishr', 'a@32', 24), ('extract_i8', a, 3), 
'!options->lower_extract_byte'),
(('iand', 0xff, ('ushr', a, 16)), ('extract_u8', a, 2), 
'!options->lower_extract_byte'),
(('iand', 0xff, ('ushr', a,  8)), ('extract_u8', a, 1), 
'!options->lower_extract_byte'),
(('iand', 0xff, a), ('extract_u8', a, 0), '!options->lower_extract_byte'),
 
 # Word extraction
+   (('ushr', ('ishl', 'a@16', 16), 16), ('extract_u16', a, 0), 
'!options->lower_extract_word'),
(('ushr', 'a@16', 16), ('extract_u16', a, 1), 
'!options->lower_extract_word'),
+   (('ishr', ('ishl', 'a@16', 16), 16), ('extract_i16', a, 0), 
'!options->lower_extract_word'),
+   (('ishr', 'a@16', 16), ('extract_i16', a, 1), 
'!options->lower_extract_word'),
(('iand', 0x, a), ('extract_u16', a, 0), 
'!options->lower_extract_word'),
 
# Subtracts
-- 
2.17.1

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


[Mesa-dev] [PATCH 06/22] nir/format_convert: Add vec mask and sign-extend helpers

2018-08-17 Thread Jason Ekstrand
---
 src/compiler/nir/nir_format_convert.h | 35 +--
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/compiler/nir/nir_format_convert.h 
b/src/compiler/nir/nir_format_convert.h
index b1345f7263b..305273cdfdd 100644
--- a/src/compiler/nir/nir_format_convert.h
+++ b/src/compiler/nir/nir_format_convert.h
@@ -50,6 +50,32 @@ nir_mask_shift_or(struct nir_builder *b, nir_ssa_def *dst, 
nir_ssa_def *src,
return nir_ior(b, nir_mask_shift(b, src, src_mask, src_left_shift), dst);
 }
 
+static inline nir_ssa_def *
+nir_format_mask_uvec(nir_builder *b, nir_ssa_def *src,
+ const unsigned *bits)
+{
+   nir_const_value mask;
+   for (unsigned i = 0; i < src->num_components; i++) {
+  assert(bits[i] < 32);
+  mask.u32[i] = (1u << bits[i]) - 1;
+   }
+   return nir_iand(b, src, nir_build_imm(b, src->num_components, 32, mask));
+}
+
+static inline nir_ssa_def *
+nir_format_sign_extend_ivec(nir_builder *b, nir_ssa_def *src,
+const unsigned *bits)
+{
+   assert(src->num_components <= 4);
+   nir_ssa_def *comps[4];
+   for (unsigned i = 0; i < src->num_components; i++) {
+  nir_ssa_def *shift = nir_imm_int(b, src->bit_size - bits[i]);
+  comps[i] = nir_ishr(b, nir_ishl(b, nir_channel(b, src, i), shift), 
shift);
+   }
+   return nir_vec(b, comps, src->num_components);
+}
+
+
 static inline nir_ssa_def *
 nir_format_unpack_int(nir_builder *b, nir_ssa_def *packed,
   const unsigned *bits, unsigned num_components,
@@ -117,14 +143,7 @@ static inline nir_ssa_def *
 nir_format_pack_uint(nir_builder *b, nir_ssa_def *color,
  const unsigned *bits, unsigned num_components)
 {
-   nir_const_value mask;
-   for (unsigned i = 0; i < num_components; i++) {
-  assert(bits[i] < 32);
-  mask.u32[i] = (1u << bits[i]) - 1;
-   }
-   nir_ssa_def *mask_imm = nir_build_imm(b, num_components, 32, mask);
-
-   return nir_format_pack_uint_unmasked(b, nir_iand(b, color, mask_imm),
+   return nir_format_pack_uint_unmasked(b, nir_format_mask_uvec(b, color, 
bits),
 bits, num_components);
 }
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 01/22] nir/algebraic: Be more careful converting ushr to extract_u8/16

2018-08-17 Thread Jason Ekstrand
If it's not the right bit-size, it may not actually be the correct
extraction.  For now, we'll only worry about 32-bit versions.

Fixes: 905ff8619824 "nir: Recognize open-coded extract_u16"
Fixes: 76289fbfa84a "nir: Recognize open-coded extract_u8"
---
 src/compiler/nir/nir_opt_algebraic.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index e770a61d9ff..28090d069cd 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -543,13 +543,13 @@ optimizations = [
('unpack_64_2x32_split_y', a)), a),
 
# Byte extraction
-   (('ushr', a, 24), ('extract_u8', a, 3), '!options->lower_extract_byte'),
+   (('ushr', 'a@32', 24), ('extract_u8', a, 3), 
'!options->lower_extract_byte'),
(('iand', 0xff, ('ushr', a, 16)), ('extract_u8', a, 2), 
'!options->lower_extract_byte'),
(('iand', 0xff, ('ushr', a,  8)), ('extract_u8', a, 1), 
'!options->lower_extract_byte'),
(('iand', 0xff, a), ('extract_u8', a, 0), '!options->lower_extract_byte'),
 
 # Word extraction
-   (('ushr', a, 16), ('extract_u16', a, 1), '!options->lower_extract_word'),
+   (('ushr', 'a@16', 16), ('extract_u16', a, 1), 
'!options->lower_extract_word'),
(('iand', 0x, a), ('extract_u16', a, 0), 
'!options->lower_extract_word'),
 
# Subtracts
-- 
2.17.1

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


[Mesa-dev] [PATCH 00/22] intel: Do storage image lowering in NIR

2018-08-17 Thread Jason Ekstrand
This patch series has been on my mind to write for a very long time now.
It moves the storage image lowering we have to do for Intel hardware into
NIR.  This series makes several improvements:

 1) The NIR optimizer can go to town on it and we can just improve the
optimizer instead of spending time carefully tuning our code-gen.

 2) It also provides a nice separation between the image references
themselves and the parameters  we have to push into the shader for
address calculations on BDW and earlier.  This has always bothered me
in Vulkan because there we don't have a contiguous array of image slots
like in GL.

 3) After this series, the binding table indices are passed directly into
the dataport messages instead of being pulled from a uniform.  This
should be more efficient and makes shaders easier to read.  It's also a
good step in the direction of being able to start using bindless for
images.

 4) On Sky Lake and above, brw_image_param is no longer needed at all.
This will make Ken's life way easier as he tries to hook up images in
the new Gallium driver.

This series is also available as a branch on GitLab:

https://gitlab.freedesktop.org/jekstrand/mesa/commits/review/nir-image-load-store


Jason Ekstrand (22):
  nir/algebraic: Be more careful converting ushr to extract_u8/16
  nir/algebraic: Add more extract_[iu](8|16) optimizations
  nir/algebraic: Add some max/min optimizations
  nir/opcodes: Make unpack_half_2x16_split_* variable-width
  nir/format_convert: Add support for unpacking signed integers
  nir/format_convert: Add vec mask and sign-extend helpers
  nir/format_convert: Rename nir_format_bitcast_uint_vec
  nir/format_convert: Add [us]norm conversion helpers
  nir/format_convert: Rename pack_r11g11b10f to pack_11f11f10f
  nir/format_convert: Fix a bitmask in unpack_11f11f10f
  nir: Make image load/store intrinsics variable-width
  anv/pipeline: Remove dead image loads in lower_input_attacnments
  nir/types: Add a wrapper for coordinate_components
  intel/compiler: Do image load/store lowering to NIR
  isl: Use the view array length for the image size
  intel/compiler: Use two components for 1D array image sizes
  glsl/link,i965: Make ImageAccess four-state
  intel: Use TXQ for image_size when we have a typed surface
  nir: Use a bitfield for image access qualifiers
  nir: Add handle/index-based image intrinsics
  anv,i965: Lower away image derefs in the driver
  intel/compiler: Remove surface_idx from brw_image_param

 src/amd/common/ac_nir_to_llvm.c   |4 +-
 src/compiler/glsl/gl_nir_link_uniforms.c  |   10 +-
 src/compiler/glsl/glsl_to_nir.cpp |   28 +-
 src/compiler/glsl/link_uniforms.cpp   |8 +-
 src/compiler/nir/nir.h|   36 +-
 src/compiler/nir/nir_format_convert.h |  137 ++-
 src/compiler/nir/nir_intrinsics.py|   57 +-
 src/compiler/nir/nir_opcodes.py   |8 +-
 src/compiler/nir/nir_opt_algebraic.py |   20 +-
 src/compiler/nir/nir_print.c  |   33 +-
 src/compiler/nir_types.cpp|7 +
 src/compiler/nir_types.h  |1 +
 src/compiler/shader_enums.h   |   10 +-
 src/compiler/spirv/spirv_to_nir.c |2 +
 src/compiler/spirv/vtn_variables.c|   10 +-
 src/intel/Makefile.sources|1 +
 src/intel/blorp/blorp_blit.c  |2 +-
 src/intel/compiler/brw_compiler.h |   16 +-
 src/intel/compiler/brw_eu_defines.h   |3 +
 src/intel/compiler/brw_fs.cpp |   18 +-
 src/intel/compiler/brw_fs.h   |3 +-
 src/intel/compiler/brw_fs_generator.cpp   |   26 +-
 src/intel/compiler/brw_fs_nir.cpp |  319 +++--
 src/intel/compiler/brw_fs_surface_builder.cpp | 1030 -
 src/intel/compiler/brw_fs_surface_builder.h   |   20 -
 src/intel/compiler/brw_nir.h  |8 +
 .../compiler/brw_nir_lower_image_load_store.c |  867 ++
 src/intel/compiler/brw_shader.cpp |5 +
 src/intel/compiler/meson.build|1 +
 src/intel/isl/isl_storage_image.c |   17 +-
 .../vulkan/anv_nir_apply_pipeline_layout.c|  160 ++-
 .../vulkan/anv_nir_lower_input_attachments.c  |4 +-
 src/intel/vulkan/anv_pipeline.c   |2 +
 src/intel/vulkan/genX_cmd_buffer.c|2 -
 .../drivers/dri/i965/brw_nir_uniforms.cpp |  133 ++-
 src/mesa/drivers/dri/i965/brw_program.c   |3 +
 .../drivers/dri/i965/brw_wm_surface_state.c   |   24 +-
 src/mesa/main/mtypes.h|9 +-
 38 files changed, 1630 insertions(+), 1414 deletions(-)
 create mode 100644 src/intel/compiler/brw_nir_lower_image_load_store.c

-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listin

Re: [Mesa-dev] [PATCH 3/3] meson: Run the test with Python 3

2018-08-17 Thread Mathieu Bridon
On Fri, 2018-08-17 at 12:54 -0700, Dylan Baker wrote:
> Quoting Mathieu Bridon (2018-08-17 12:32:18)
> > ---
> >  src/compiler/glsl/glcpp/meson.build | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/compiler/glsl/glcpp/meson.build
> > b/src/compiler/glsl/glcpp/meson.build
> > index 09d44ddd687..769406f5331 100644
> > --- a/src/compiler/glsl/glcpp/meson.build
> > +++ b/src/compiler/glsl/glcpp/meson.build
> > @@ -64,8 +64,9 @@ if with_tests
> >foreach m : modes
> >  test(
> >'glcpp test (@0@)'.format(m),
> > -  find_program('tests/glcpp_test.py'),
> > +  prog_python,
> >args : [
> > +join_paths(meson.current_source_dir(),
> > 'tests/glcpp_test.py'),
> >  glcpp, join_paths(meson.current_source_dir(), 'tests'),
> >  '--@0@'.format(m),
> >],
> > -- 
> > 2.17.1
> > 
> 
> Is it okay with you if I just squash this patch and the one in my
> series into a
> single patch?

Sure, no problem.


-- 
Mathieu

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


Re: [Mesa-dev] [PATCH 3/3] meson: Run the test with Python 3

2018-08-17 Thread Dylan Baker
Quoting Mathieu Bridon (2018-08-17 12:32:18)
> ---
>  src/compiler/glsl/glcpp/meson.build | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/compiler/glsl/glcpp/meson.build 
> b/src/compiler/glsl/glcpp/meson.build
> index 09d44ddd687..769406f5331 100644
> --- a/src/compiler/glsl/glcpp/meson.build
> +++ b/src/compiler/glsl/glcpp/meson.build
> @@ -64,8 +64,9 @@ if with_tests
>foreach m : modes
>  test(
>'glcpp test (@0@)'.format(m),
> -  find_program('tests/glcpp_test.py'),
> +  prog_python,
>args : [
> +join_paths(meson.current_source_dir(), 'tests/glcpp_test.py'),
>  glcpp, join_paths(meson.current_source_dir(), 'tests'),
>  '--@0@'.format(m),
>],
> -- 
> 2.17.1
> 

Is it okay with you if I just squash this patch and the one in my series into a
single patch?

Dylan


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] python: difflib prefers unicode strings

2018-08-17 Thread Dylan Baker
for the series:
Reviewed-by: Dylan Baker 

Quoting Mathieu Bridon (2018-08-17 12:32:16)
> Python 3 does not automatically convert from bytes to unicode strings
> like Python 2 used to do.
> 
> This commit makes sure we pass unicode strings to difflib.unified_diff,
> so that the script works on both Python 2 and 3.
> ---
>  src/compiler/glsl/glcpp/tests/glcpp_test.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/compiler/glsl/glcpp/tests/glcpp_test.py 
> b/src/compiler/glsl/glcpp/tests/glcpp_test.py
> index 8ac5d7cb0a1..e27391093cf 100755
> --- a/src/compiler/glsl/glcpp/tests/glcpp_test.py
> +++ b/src/compiler/glsl/glcpp/tests/glcpp_test.py
> @@ -64,8 +64,9 @@ def test_output(glcpp, filename, expfile, nl_format='\n'):
>  stderr=subprocess.STDOUT,
>  stdin=subprocess.PIPE)
>  actual, _ = proc.communicate(f.read())
> +actual = actual.decode('utf-8')
>  
> -with open(expfile, 'rb') as f:
> +with open(expfile, 'r') as f:
>  expected = f.read()
>  
>  if actual == expected:
> -- 
> 2.17.1
> 


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 2/8] nir: propagates if condition evaluation down some alu chains

2018-08-17 Thread Jason Ekstrand
Ugh... Now that I think about it more, my suggestions on the previous patch
conflict quite a bit. :(  Let me think some more.

On Fri, Aug 17, 2018 at 2:27 PM Jason Ekstrand  wrote:

> It took me a while to figure out what you're doing here but, once I've
> grokked it, I like it.  That said, I'd like to see your response to my
> comments on patch 1 as that would cause this to get restructured a good
> bit.  (I think it will be much improved for it.)
>
> --Jason
>
> On Mon, Jul 23, 2018 at 3:02 AM Timothy Arceri 
> wrote:
>
>> shader-db IVB results:
>>
>> total instructions in shared programs: 9993483 -> 9993472 (-0.00%)
>> instructions in affected programs: 1300 -> 1289 (-0.85%)
>> helped: 11
>> HURT: 0
>>
>> total cycles in shared programs: 219476091 -> 219476059 (-0.00%)
>> cycles in affected programs: 7675 -> 7643 (-0.42%)
>> helped: 10
>> HURT: 1
>> ---
>>  src/compiler/nir/nir_opt_if.c | 155 --
>>  1 file changed, 149 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
>> index b3d5046a76e..c9e50cec1fe 100644
>> --- a/src/compiler/nir/nir_opt_if.c
>> +++ b/src/compiler/nir/nir_opt_if.c
>> @@ -404,9 +404,134 @@ replace_if_condition_use_with_const(nir_src *use,
>> unsigned nir_boolean,
>>nir_instr_rewrite_src(use->parent_instr, use, new_src);
>>  }
>>
>> +/*
>> + * This propagates if condition evaluation down the chain of some alu
>> + * instructions. For example by checking the use of some of the
>> following alu
>> + * instruction we can eventually replace ssa_107 with NIR_TRUE.
>> + *
>> + *   loop {
>> + *  block block_1:
>> + *  vec1 32 ssa_85 = load_const (0x0002)
>> + *  vec1 32 ssa_86 = ieq ssa_48, ssa_85
>> + *  vec1 32 ssa_87 = load_const (0x0001)
>> + *  vec1 32 ssa_88 = ieq ssa_48, ssa_87
>> + *  vec1 32 ssa_89 = ior ssa_86, ssa_88
>> + *  vec1 32 ssa_90 = ieq ssa_48, ssa_0
>> + *  vec1 32 ssa_91 = ior ssa_89, ssa_90
>> + *  if ssa_86 {
>> + * block block_2:
>> + * ...
>> + *break
>> + *  } else {
>> + *block block_3:
>> + *  }
>> + *  block block_4:
>> + *  if ssa_88 {
>> + *block block_5:
>> + * ...
>> + *break
>> + *  } else {
>> + *block block_6:
>> + *  }
>> + *  block block_7:
>> + *  if ssa_90 {
>> + *block block_8:
>> + * ...
>> + *break
>> + *  } else {
>> + *block block_9:
>> + *  }
>> + *  block block_10:
>> + *  vec1 32 ssa_107 = inot ssa_91
>> + *  if ssa_107 {
>> + *block block_11:
>> + *break
>> + *  } else {
>> + *block block_12:
>> + *  }
>> + *   }
>> + */
>> +static bool
>> +propagate_condition_eval(nir_builder *b, nir_if *nif, nir_src *use_src,
>> + nir_src *alu_use, nir_alu_instr *alu, void
>> *mem_ctx,
>> + bool if_condition)
>> +{
>> +   bool progress = false;
>> +
>> +   nir_block *use_block;
>> +   if (if_condition) {
>> +  use_block =
>> +
>>  nir_cf_node_as_block(nir_cf_node_prev(&alu_use->parent_if->cf_node));
>> +   } else {
>> +  use_block = alu_use->parent_instr->block;
>> +   }
>> +
>> +   if (nir_op_infos[alu->op].num_inputs == 1) {
>> +  if (nir_block_dominates(nir_if_first_then_block(nif), use_block)) {
>> + replace_if_condition_use_with_const(alu_use, NIR_TRUE, mem_ctx,
>> + if_condition);
>> + progress = true;
>> +  } else if (nir_block_dominates(nir_if_first_else_block(nif),
>> + use_block)) {
>> + replace_if_condition_use_with_const(alu_use, NIR_FALSE, mem_ctx,
>> + if_condition);
>> + progress = true;
>> +  }
>> +   } else {
>> +  assert(alu->op == nir_op_ior || alu->op == nir_op_iand);
>> +
>> +  bool found = false;
>> +  unsigned nir_boolean = 0;
>> +  if (nir_block_dominates(nir_if_first_then_block(nif), use_block)) {
>> + nir_boolean = NIR_TRUE;
>> + found = true;
>> +  } else if (nir_block_dominates(nir_if_first_else_block(nif),
>> + use_block)) {
>> + nir_boolean = NIR_FALSE;
>> + found = true;
>> +  }
>> +
>> +  if (found) {
>> + nir_ssa_def *def[2];
>> + for (unsigned i = 0; i < 2; i++) {
>> +if (alu->src[i].src.ssa == use_src->ssa) {
>> +   if (if_condition) {
>> +  b->cursor =
>> + nir_before_cf_node(&alu_use->parent_if->cf_node);
>> +   } else {
>> +  b->cursor = nir_before_instr(alu_use->parent_instr);
>> +   }
>> +
>> +   nir_const_value value;
>> +   value.u32[0] = nir_boolean;
>> +
>> +   def[i] = nir_b

Re: [Mesa-dev] [PATCH v2 3/8] nir: allow more nested loops to be unrolled

2018-08-17 Thread Jason Ekstrand
Thanks for the explanation and fixing the boolean mess

Reviewed-by: Jason Ekstrand 

On Mon, Jul 23, 2018 at 3:02 AM Timothy Arceri 
wrote:

> The innermost check was added to stop us from unrolling multiple
> loops in a single pass, and to stop outer loops from unrolling.
>
> When we successfully unroll a loop we need to run the analysis
> pass again before deciding if we want to go ahead an unroll a
> second loop.
>
> However the logic was flawed because it never tried to unroll any
> nested loops other than the first innermost loop it found.
> If this innermost loop is not unrolled we end up skipping all
> other nested loops.
>
> This unrolls a loop in a Deus Ex: MD shader on ultra settings and
> also unrolls a loop in a shader from the game Prey when running
> on DXVK.
> ---
>  src/compiler/nir/nir_opt_loop_unroll.c | 31 ++
>  1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_loop_unroll.c
> b/src/compiler/nir/nir_opt_loop_unroll.c
> index 955dfede694..a1ad0e59814 100644
> --- a/src/compiler/nir/nir_opt_loop_unroll.c
> +++ b/src/compiler/nir/nir_opt_loop_unroll.c
> @@ -483,9 +483,10 @@ is_loop_small_enough_to_unroll(nir_shader *shader,
> nir_loop_info *li)
>  }
>
>  static bool
> -process_loops(nir_shader *sh, nir_cf_node *cf_node, bool *innermost_loop)
> +process_loops(nir_shader *sh, nir_cf_node *cf_node, bool
> *has_nested_loop_out)
>  {
> bool progress = false;
> +   bool has_nested_loop = false;
> nir_loop *loop;
>
> switch (cf_node->type) {
> @@ -494,32 +495,32 @@ process_loops(nir_shader *sh, nir_cf_node *cf_node,
> bool *innermost_loop)
> case nir_cf_node_if: {
>nir_if *if_stmt = nir_cf_node_as_if(cf_node);
>foreach_list_typed_safe(nir_cf_node, nested_node, node,
> &if_stmt->then_list)
> - progress |= process_loops(sh, nested_node, innermost_loop);
> + progress |= process_loops(sh, nested_node, has_nested_loop_out);
>foreach_list_typed_safe(nir_cf_node, nested_node, node,
> &if_stmt->else_list)
> - progress |= process_loops(sh, nested_node, innermost_loop);
> + progress |= process_loops(sh, nested_node, has_nested_loop_out);
>return progress;
> }
> case nir_cf_node_loop: {
>loop = nir_cf_node_as_loop(cf_node);
>foreach_list_typed_safe(nir_cf_node, nested_node, node, &loop->body)
> - progress |= process_loops(sh, nested_node, innermost_loop);
> + progress |= process_loops(sh, nested_node, &has_nested_loop);
> +
>break;
> }
> default:
>unreachable("unknown cf node type");
> }
>
> -   if (*innermost_loop) {
> -  /* Don't attempt to unroll outer loops or a second inner loop in
> -   * this pass wait until the next pass as we have altered the cf.
> -   */
> -  *innermost_loop = false;
> +   /* Don't attempt to unroll a second inner loop in this pass, wait
> until the
> +* next pass as we have altered the cf.
> +*/
> +   if (!progress) {
>
> -  if (loop->info->limiting_terminator == NULL)
> - return progress;
> +  if (has_nested_loop || loop->info->limiting_terminator == NULL)
> + goto exit;
>
>if (!is_loop_small_enough_to_unroll(sh, loop->info))
> - return progress;
> + goto exit;
>
>if (loop->info->is_trip_count_known) {
>   simple_unroll(loop);
> @@ -555,6 +556,8 @@ process_loops(nir_shader *sh, nir_cf_node *cf_node,
> bool *innermost_loop)
>}
> }
>
> +exit:
> +   *has_nested_loop_out = true;
> return progress;
>  }
>
> @@ -567,9 +570,9 @@ nir_opt_loop_unroll_impl(nir_function_impl *impl,
> nir_metadata_require(impl, nir_metadata_block_index);
>
> foreach_list_typed_safe(nir_cf_node, node, node, &impl->body) {
> -  bool innermost_loop = true;
> +  bool has_nested_loop = false;
>progress |= process_loops(impl->function->shader, node,
> -&innermost_loop);
> +&has_nested_loop);
> }
>
> if (progress)
> --
> 2.17.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/3] meson: Run the test with Python 3

2018-08-17 Thread Mathieu Bridon
---
 src/compiler/glsl/glcpp/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/glcpp/meson.build 
b/src/compiler/glsl/glcpp/meson.build
index 09d44ddd687..769406f5331 100644
--- a/src/compiler/glsl/glcpp/meson.build
+++ b/src/compiler/glsl/glcpp/meson.build
@@ -64,8 +64,9 @@ if with_tests
   foreach m : modes
 test(
   'glcpp test (@0@)'.format(m),
-  find_program('tests/glcpp_test.py'),
+  prog_python,
   args : [
+join_paths(meson.current_source_dir(), 'tests/glcpp_test.py'),
 glcpp, join_paths(meson.current_source_dir(), 'tests'),
 '--@0@'.format(m),
   ],
-- 
2.17.1

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


[Mesa-dev] [PATCH 2/3] python: Disable universal newlines

2018-08-17 Thread Mathieu Bridon
We are testing the behaviour of a tool, for different input files, each
one using a different newline sequence. ('\n' on UNIX, '\r\n' on
Windows, …)

Unfortunately, when opening a file in text mode, Python 3 will by
default enable the "universal newlines" mode, which means it replaces
all the known newline sequences by '\n'.

This (usually useful) behaviour breaks the tests, which are specifically
trying to handle files with newline sequences different from '\n'.

Disabling the universal newlines mode fixes the tests.

However, to keep the script compatible with both Python 2 and 3, we must
use the io.open() function instead of the open() builtin, as the latter
only knows about the `newline` argument on Python 3.
---
 src/compiler/glsl/glcpp/tests/glcpp_test.py | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/glcpp/tests/glcpp_test.py 
b/src/compiler/glsl/glcpp/tests/glcpp_test.py
index e27391093cf..1481eed6188 100755
--- a/src/compiler/glsl/glcpp/tests/glcpp_test.py
+++ b/src/compiler/glsl/glcpp/tests/glcpp_test.py
@@ -46,7 +46,10 @@ def arg_parser():
 
 def parse_test_file(filename, nl_format):
 """Check for any special arguments and return them as a list."""
-with open(filename) as f:
+# Disable "universal newlines" mode; we can't directly use `nl_format` as
+# the `newline` argument, because the "bizarro" test uses something Python
+# considers invalid.
+with io.open(filename, newline='') as f:
 for l in f.read().split(nl_format):
 if 'glcpp-args:' in l:
 return l.split('glcpp-args:')[1].strip().split()
-- 
2.17.1

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


[Mesa-dev] [PATCH 1/3] python: difflib prefers unicode strings

2018-08-17 Thread Mathieu Bridon
Python 3 does not automatically convert from bytes to unicode strings
like Python 2 used to do.

This commit makes sure we pass unicode strings to difflib.unified_diff,
so that the script works on both Python 2 and 3.
---
 src/compiler/glsl/glcpp/tests/glcpp_test.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/glcpp/tests/glcpp_test.py 
b/src/compiler/glsl/glcpp/tests/glcpp_test.py
index 8ac5d7cb0a1..e27391093cf 100755
--- a/src/compiler/glsl/glcpp/tests/glcpp_test.py
+++ b/src/compiler/glsl/glcpp/tests/glcpp_test.py
@@ -64,8 +64,9 @@ def test_output(glcpp, filename, expfile, nl_format='\n'):
 stderr=subprocess.STDOUT,
 stdin=subprocess.PIPE)
 actual, _ = proc.communicate(f.read())
+actual = actual.decode('utf-8')
 
-with open(expfile, 'rb') as f:
+with open(expfile, 'r') as f:
 expected = f.read()
 
 if actual == expected:
-- 
2.17.1

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


Re: [Mesa-dev] [PATCH v2 2/8] nir: propagates if condition evaluation down some alu chains

2018-08-17 Thread Jason Ekstrand
It took me a while to figure out what you're doing here but, once I've
grokked it, I like it.  That said, I'd like to see your response to my
comments on patch 1 as that would cause this to get restructured a good
bit.  (I think it will be much improved for it.)

--Jason

On Mon, Jul 23, 2018 at 3:02 AM Timothy Arceri 
wrote:

> shader-db IVB results:
>
> total instructions in shared programs: 9993483 -> 9993472 (-0.00%)
> instructions in affected programs: 1300 -> 1289 (-0.85%)
> helped: 11
> HURT: 0
>
> total cycles in shared programs: 219476091 -> 219476059 (-0.00%)
> cycles in affected programs: 7675 -> 7643 (-0.42%)
> helped: 10
> HURT: 1
> ---
>  src/compiler/nir/nir_opt_if.c | 155 --
>  1 file changed, 149 insertions(+), 6 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
> index b3d5046a76e..c9e50cec1fe 100644
> --- a/src/compiler/nir/nir_opt_if.c
> +++ b/src/compiler/nir/nir_opt_if.c
> @@ -404,9 +404,134 @@ replace_if_condition_use_with_const(nir_src *use,
> unsigned nir_boolean,
>nir_instr_rewrite_src(use->parent_instr, use, new_src);
>  }
>
> +/*
> + * This propagates if condition evaluation down the chain of some alu
> + * instructions. For example by checking the use of some of the following
> alu
> + * instruction we can eventually replace ssa_107 with NIR_TRUE.
> + *
> + *   loop {
> + *  block block_1:
> + *  vec1 32 ssa_85 = load_const (0x0002)
> + *  vec1 32 ssa_86 = ieq ssa_48, ssa_85
> + *  vec1 32 ssa_87 = load_const (0x0001)
> + *  vec1 32 ssa_88 = ieq ssa_48, ssa_87
> + *  vec1 32 ssa_89 = ior ssa_86, ssa_88
> + *  vec1 32 ssa_90 = ieq ssa_48, ssa_0
> + *  vec1 32 ssa_91 = ior ssa_89, ssa_90
> + *  if ssa_86 {
> + * block block_2:
> + * ...
> + *break
> + *  } else {
> + *block block_3:
> + *  }
> + *  block block_4:
> + *  if ssa_88 {
> + *block block_5:
> + * ...
> + *break
> + *  } else {
> + *block block_6:
> + *  }
> + *  block block_7:
> + *  if ssa_90 {
> + *block block_8:
> + * ...
> + *break
> + *  } else {
> + *block block_9:
> + *  }
> + *  block block_10:
> + *  vec1 32 ssa_107 = inot ssa_91
> + *  if ssa_107 {
> + *block block_11:
> + *break
> + *  } else {
> + *block block_12:
> + *  }
> + *   }
> + */
> +static bool
> +propagate_condition_eval(nir_builder *b, nir_if *nif, nir_src *use_src,
> + nir_src *alu_use, nir_alu_instr *alu, void
> *mem_ctx,
> + bool if_condition)
> +{
> +   bool progress = false;
> +
> +   nir_block *use_block;
> +   if (if_condition) {
> +  use_block =
> +
>  nir_cf_node_as_block(nir_cf_node_prev(&alu_use->parent_if->cf_node));
> +   } else {
> +  use_block = alu_use->parent_instr->block;
> +   }
> +
> +   if (nir_op_infos[alu->op].num_inputs == 1) {
> +  if (nir_block_dominates(nir_if_first_then_block(nif), use_block)) {
> + replace_if_condition_use_with_const(alu_use, NIR_TRUE, mem_ctx,
> + if_condition);
> + progress = true;
> +  } else if (nir_block_dominates(nir_if_first_else_block(nif),
> + use_block)) {
> + replace_if_condition_use_with_const(alu_use, NIR_FALSE, mem_ctx,
> + if_condition);
> + progress = true;
> +  }
> +   } else {
> +  assert(alu->op == nir_op_ior || alu->op == nir_op_iand);
> +
> +  bool found = false;
> +  unsigned nir_boolean = 0;
> +  if (nir_block_dominates(nir_if_first_then_block(nif), use_block)) {
> + nir_boolean = NIR_TRUE;
> + found = true;
> +  } else if (nir_block_dominates(nir_if_first_else_block(nif),
> + use_block)) {
> + nir_boolean = NIR_FALSE;
> + found = true;
> +  }
> +
> +  if (found) {
> + nir_ssa_def *def[2];
> + for (unsigned i = 0; i < 2; i++) {
> +if (alu->src[i].src.ssa == use_src->ssa) {
> +   if (if_condition) {
> +  b->cursor =
> + nir_before_cf_node(&alu_use->parent_if->cf_node);
> +   } else {
> +  b->cursor = nir_before_instr(alu_use->parent_instr);
> +   }
> +
> +   nir_const_value value;
> +   value.u32[0] = nir_boolean;
> +
> +   def[i] = nir_build_imm(b, 1, 32, value);
> +} else {
> +   def[i] = alu->src[i].src.ssa;
> +}
> + }
> +
> + nir_ssa_def *nalu =
> +nir_build_alu(b, alu->op, def[0], def[1], NULL, NULL);
> +
> + /* Rewrite use to use new alu instruction */
> + nir_src new_src = ni

Re: [Mesa-dev] [PATCH v3] anv: add VK_EXT_sampler_filter_minmax support

2018-08-17 Thread He, Yunchao
Thanks for your review, Lionel. 
The reduction mode in Intel bspec has the 4th option (COMPARISON), in addition 
to 3 options in Vulkan spec: standard/min/max sampling. 
I disabled reduction mode when compare mode in sampler state is enabled. It 
looks like the hardware can set appropriate reduction mode (comparison 
sampling) when reductionEnable is false. But the Vulkan spec says that if 
(depth/stencil) compare mode is enabled, the reduction should be standard 
filtering. But that doesn't work on Intel devices. It seems to me that it is a 
conflict between IA devices and Vulkan spec. 

I submitted a new patch set. PTAL when you have time.

-Original Message-
From: Landwerlin, Lionel G 
Sent: Thursday, August 16, 2018 3:25 AM
To: He, Yunchao ; mesa-dev@lists.freedesktop.org
Subject: Re: [Mesa-dev] [PATCH v3] anv: add VK_EXT_sampler_filter_minmax support

Hey Yunchao,

This patch seems to fail a number of tests on CI like 
dEQP-VK.glsl.texture_gather.offset_dynamic.min_required_offset.2d.depth32f.size_npot.compare_greater.clamp_to_edge_repeat

They pass if I set the default to :

unsigned sampler_reduction_mode = COMPARISON;

Maybe we don't want to enabled reduction if the extension is unspecified in the 
CreateInfo?
Not quite sure what's the correct programming here.

Thanks,

-
Lionel

On 15/08/18 21:10, Yunchao He wrote:
> This extension can be supported on SKL+. With this patch, all 
> corresponding tests (6K+) in CTS can pass. No test fails.
>
> I verified CTS with the command below:
> deqp-vk --deqp-case=dEQP-VK.pipeline.sampler.view_type.*reduce*
>
> v2: 1) support all depth formats, not depth-only formats, 2) fix a 
> wrong indention (Jason).
>
> v3: fix a few nits (Lionel).
> ---
>   src/intel/vulkan/anv_device.c  |  8 
>   src/intel/vulkan/anv_extensions.py |  1 +
>   src/intel/vulkan/anv_formats.c |  6 ++
>   src/intel/vulkan/genX_state.c  | 26 ++
>   4 files changed, 41 insertions(+)
>
> diff --git a/src/intel/vulkan/anv_device.c 
> b/src/intel/vulkan/anv_device.c index 04fd6a829e..e45ba4b3af 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -1116,6 +1116,14 @@ void anv_GetPhysicalDeviceProperties2(
>break;
> }
>   
> +  case 
> VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT: {
> + VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *properties =
> +(VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *)ext;
> + properties->filterMinmaxImageComponentMapping = pdevice->info.gen 
> >= 9;
> + properties->filterMinmaxSingleComponentFormats = true;
> + break;
> +  }
> +
> case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES: {
>VkPhysicalDeviceSubgroupProperties *properties = (void 
> *)ext;
>   
> diff --git a/src/intel/vulkan/anv_extensions.py 
> b/src/intel/vulkan/anv_extensions.py
> index ea837744b4..e165bd371d 100644
> --- a/src/intel/vulkan/anv_extensions.py
> +++ b/src/intel/vulkan/anv_extensions.py
> @@ -125,6 +125,7 @@ EXTENSIONS = [
>   Extension('VK_EXT_shader_stencil_export', 1, 
> 'device->info.gen >= 9'),
>   Extension('VK_EXT_vertex_attribute_divisor',  2, True),
>   Extension('VK_EXT_post_depth_coverage',   1, 
> 'device->info.gen >= 9'),
> +Extension('VK_EXT_sampler_filter_minmax', 1, 
> 'device->info.gen >= 9'),
>   ]
>   
>   class VkVersion:
> diff --git a/src/intel/vulkan/anv_formats.c 
> b/src/intel/vulkan/anv_formats.c index 815b320a82..33faf7cc37 100644
> --- a/src/intel/vulkan/anv_formats.c
> +++ b/src/intel/vulkan/anv_formats.c
> @@ -489,6 +489,9 @@ get_image_format_features(const struct gen_device_info 
> *devinfo,
> if (aspects == VK_IMAGE_ASPECT_DEPTH_BIT || devinfo->gen >= 8)
>flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
>   
> +  if ((aspects & VK_IMAGE_ASPECT_DEPTH_BIT) && devinfo->gen >= 9)
> + flags |= 
> + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT;
> +
> flags |= VK_FORMAT_FEATURE_BLIT_SRC_BIT |
>  VK_FORMAT_FEATURE_BLIT_DST_BIT |
>  VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR | @@ -521,6 
> +524,9 @@ get_image_format_features(const struct gen_device_info *devinfo,
>  if (isl_format_supports_sampling(devinfo, plane_format.isl_format)) {
> flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
>   
> +  if (devinfo->gen >= 9)
> + flags |= 
> + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT;
> +
> if (isl_format_supports_filtering(devinfo, plane_format.isl_format))
>flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
>  }
> diff --git a/src/intel/vulkan/genX_state.c 
> b/src/intel/vulkan/genX_state.c index b1014d9e79..f075272acd 100644
> --- a/src/intel/vulkan/genX_state.c
> +++ b/src/intel/vulkan/genX_state.c
> @@ -245,6 +245,14 @@ static const uint32_t vk_to_gen_shado

Re: [Mesa-dev] [PATCH v2 1/8] nir: evaluate if condition uses inside the if branches

2018-08-17 Thread Jason Ekstrand
On Mon, Jul 23, 2018 at 3:03 AM Timothy Arceri 
wrote:

> Since we know what side of the branch we ended up on we can just
> replace the use with a constant.
>
> All the spill changes in shader-db are from Dolphin uber shaders,
> despite some small regressions the change is clearly positive.
>
> shader-db results IVB:
>
> total instructions in shared programs: 201 -> 9993483 (-0.06%)
> instructions in affected programs: 163235 -> 157517 (-3.50%)
> helped: 132
> HURT: 2
>
> total cycles in shared programs: 231670754 -> 219476091 (-5.26%)
> cycles in affected programs: 143424120 -> 131229457 (-8.50%)
> helped: 115
> HURT: 24
>
> total spills in shared programs: 4383 -> 4370 (-0.30%)
> spills in affected programs: 1656 -> 1643 (-0.79%)
> helped: 9
> HURT: 18
>
> total fills in shared programs: 4610 -> 4581 (-0.63%)
> fills in affected programs: 374 -> 345 (-7.75%)
> helped: 6
> HURT: 0
> ---
>  src/compiler/nir/nir_opt_if.c | 124 ++
>  1 file changed, 124 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
> index b3d0bf1decb..b3d5046a76e 100644
> --- a/src/compiler/nir/nir_opt_if.c
> +++ b/src/compiler/nir/nir_opt_if.c
> @@ -369,6 +369,87 @@ opt_if_loop_terminator(nir_if *nif)
> return true;
>  }
>
> +static void
> +replace_if_condition_use_with_const(nir_src *use, unsigned nir_boolean,
> +void *mem_ctx, bool if_condition)
> +{
> +   /* Create const */
> +   nir_load_const_instr *load = nir_load_const_instr_create(mem_ctx, 1,
> 32);
> +   load->value.u32[0] = nir_boolean;
> +
> +   if (if_condition) {
> +  nir_instr_insert_before_cf(&use->parent_if->cf_node,  &load->instr);
>

If it was me, I'd probably use the builder but I think it's a wash in this
case.


> +   } else if (use->parent_instr->type == nir_instr_type_phi) {
> +  nir_phi_instr *cond_phi = nir_instr_as_phi(use->parent_instr);
> +
> +  bool UNUSED found = false;
> +  nir_foreach_phi_src(phi_src, cond_phi) {
> + if (phi_src->src.ssa == use->ssa) {
>

You could also just use some sort of container_of macro to cast from the
src to a phi_src.  It's a bit sneaky so maybe not a good idea for the tiny
bit of perf.


> +nir_instr_insert_before_block(phi_src->pred, &load->instr);
>

after_block_before_jump would work just as well and would put the
load_const closer to its use.


> +found = true;
> +break;
> + }
> +  }
> +  assert(found);
> +   } else {
> +  nir_instr_insert_before(use->parent_instr,  &load->instr);
> +   }
> +
> +   /* Rewrite use to use const */
> +   nir_src new_src = nir_src_for_ssa(&load->def);
>

Is there a good reason for the temporary variable?


> +
> +   if (if_condition)
> +  nir_if_rewrite_condition(use->parent_if, new_src);
> +   else
> +  nir_instr_rewrite_src(use->parent_instr, use, new_src);
> +}
>

Ok, enough nitpicking.  None of the above things are actually problems.


> +
> +static bool
> +evaluate_condition_use(nir_if *nif, nir_src *use_src, void *mem_ctx,
> +   bool if_condition)
> +{
> +   bool progress = false;
> +
> +   nir_block *use_block;
> +   if (if_condition) {
> +  use_block =
> +
>  nir_cf_node_as_block(nir_cf_node_prev(&use_src->parent_if->cf_node));
> +   } else {
> +  use_block = use_src->parent_instr->block;
>

Not true for phis!


> +   }
> +
> +   if (nir_block_dominates(nir_if_first_then_block(nif), use_block)) {
> +  replace_if_condition_use_with_const(use_src, NIR_TRUE, mem_ctx,
> +  if_condition);
> +  progress = true;
> +   } else if (nir_block_dominates(nir_if_first_else_block(nif),
> use_block)) {
> +  replace_if_condition_use_with_const(use_src, NIR_FALSE, mem_ctx,
> +  if_condition);
> +  progress = true;
> +   }
> +
> +   return progress;
> +}
>

I think things would be more straightforward (and correct!) if you merged
the above two functions and restructured them a bit as follows:

static bool
try_rewrite_if_use(nir_builder *b, nir_if *nif, nir_src *src, bool
if_condition)
{
   if (if_condition) {
  b->cursor = nir_before_cf_node(&nif->cf_node);
   } else if (src->parent_instr->type == nir_instr_type_phi) {
  // Set the cursor and use_block to the predecessor block
   } else {
  b->cursor = nir_before_instr(src->parent_instr);
   }
   nir_block *use_block = nir_cursor_current_block(b->cursor);

   nir_ssa_def *const_val;
   if (nir_block_dominates(nir_if_first_then_block(nif), use_block))
  const_value = nir_imm_int(b, NIR_TRUE);
   else if (nir_block_dominates(nir_if_first_else_block(nif), use_block)
  const_value = nir_imm_int(b, NIR_FALSE);
   else
  return false;

   // Rewrite the source

   return true;
}

Other than the phi issue I pointed out above (which would be fixed by that
refactor), everything looks good to me.

--Jason


> +
> +

Re: [Mesa-dev] [PATCH mesa] util/xmlpool: make indentation coherent

2018-08-17 Thread Dylan Baker
Reviewed-by: Dylan Baker 

Quoting Eric Engestrom (2018-08-16 08:03:23)
> Signed-off-by: Eric Engestrom 
> ---
>  src/util/xmlpool/t_options.h | 26 +-
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/src/util/xmlpool/t_options.h b/src/util/xmlpool/t_options.h
> index f0537e965b8a3cda894c..a31fafac14c6ffb55bb2 100644
> --- a/src/util/xmlpool/t_options.h
> +++ b/src/util/xmlpool/t_options.h
> @@ -53,7 +53,7 @@
>   */
>  #define DRI_CONF_SECTION_DEBUG \
>  DRI_CONF_SECTION_BEGIN \
> -   DRI_CONF_DESC(en,gettext("Debugging"))
> +DRI_CONF_DESC(en,gettext("Debugging"))
>  
>  #define DRI_CONF_NO_RAST(def) \
>  DRI_CONF_OPT_BEGIN_B(no_rast, def) \
> @@ -77,7 +77,7 @@ DRI_CONF_OPT_END
>  
>  #define DRI_CONF_DISABLE_THROTTLING(def) \
>  DRI_CONF_OPT_BEGIN_B(disable_throttling, def) \
> -   DRI_CONF_DESC(en,gettext("Disable throttling on first batch after 
> flush")) \
> +DRI_CONF_DESC(en,gettext("Disable throttling on first batch after 
> flush")) \
>  DRI_CONF_OPT_END
>  
>  #define DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN(def) \
> @@ -155,11 +155,11 @@ DRI_CONF_OPT_END
>   */
>  #define DRI_CONF_SECTION_QUALITY \
>  DRI_CONF_SECTION_BEGIN \
> -   DRI_CONF_DESC(en,gettext("Image Quality"))
> +DRI_CONF_DESC(en,gettext("Image Quality"))
>  
>  #define DRI_CONF_EXCESS_MIPMAP(def) \
>  DRI_CONF_OPT_BEGIN_B(excess_mipmap, def) \
> -   DRI_CONF_DESC(en,"Enable extra mipmap level") \
> +DRI_CONF_DESC(en,"Enable extra mipmap level") \
>  DRI_CONF_OPT_END
>  
>  #define DRI_CONF_TEXTURE_DEPTH_FB   0
> @@ -168,7 +168,7 @@ DRI_CONF_OPT_END
>  #define DRI_CONF_TEXTURE_DEPTH_FORCE_16 3
>  #define DRI_CONF_TEXTURE_DEPTH(def) \
>  DRI_CONF_OPT_BEGIN_V(texture_depth,enum,def,"0:3") \
> -   DRI_CONF_DESC_BEGIN(en,gettext("Texture color depth")) \
> +DRI_CONF_DESC_BEGIN(en,gettext("Texture color depth")) \
>  DRI_CONF_ENUM(0,gettext("Prefer frame buffer color depth")) \
>  DRI_CONF_ENUM(1,gettext("Prefer 32 bits per texel")) \
>  DRI_CONF_ENUM(2,gettext("Prefer 16 bits per texel")) \
> @@ -205,7 +205,7 @@ DRI_CONF_OPT_END
>  #define DRI_CONF_ROUND_ROUND 1
>  #define DRI_CONF_ROUND_MODE(def) \
>  DRI_CONF_OPT_BEGIN_V(round_mode,enum,def,"0:1") \
> -   DRI_CONF_DESC_BEGIN(en,gettext("Color rounding method")) \
> +DRI_CONF_DESC_BEGIN(en,gettext("Color rounding method")) \
>  DRI_CONF_ENUM(0,gettext("Round color components downward")) \
>  DRI_CONF_ENUM(1,gettext("Round to nearest color")) \
>  DRI_CONF_DESC_END \
> @@ -216,7 +216,7 @@ DRI_CONF_OPT_END
>  #define DRI_CONF_DITHER_ORDERED 2
>  #define DRI_CONF_DITHER_MODE(def) \
>  DRI_CONF_OPT_BEGIN_V(dither_mode,enum,def,"0:2") \
> -   DRI_CONF_DESC_BEGIN(en,gettext("Color dithering method")) \
> +DRI_CONF_DESC_BEGIN(en,gettext("Color dithering method")) \
>  DRI_CONF_ENUM(0,gettext("Horizontal error diffusion")) \
>  DRI_CONF_ENUM(1,gettext("Horizontal error diffusion, reset 
> error at line start")) \
>  DRI_CONF_ENUM(2,gettext("Ordered 2D color dithering")) \
> @@ -321,7 +321,7 @@ DRI_CONF_OPT_END
>  
>  #define DRI_CONF_TEXTURE_BLEND_QUALITY(def,range) \
>  DRI_CONF_OPT_BEGIN_V(texture_blend_quality,float,def,range) \
> -   DRI_CONF_DESC(en,gettext("Texture filtering quality vs. speed, AKA 
> “brilinear” texture filtering")) \
> +DRI_CONF_DESC(en,gettext("Texture filtering quality vs. speed, AKA 
> “brilinear” texture filtering")) \
>  DRI_CONF_OPT_END
>  
>  #define DRI_CONF_TEXTURE_HEAPS_ALL 0
> @@ -329,11 +329,11 @@ DRI_CONF_OPT_END
>  #define DRI_CONF_TEXTURE_HEAPS_GART 2
>  #define DRI_CONF_TEXTURE_HEAPS(def) \
>  DRI_CONF_OPT_BEGIN_V(texture_heaps,enum,def,"0:2") \
> -   DRI_CONF_DESC_BEGIN(en,gettext("Used types of texture memory")) \
> -   DRI_CONF_ENUM(0,gettext("All available memory")) \
> -   DRI_CONF_ENUM(1,gettext("Only card memory (if available)")) \
> -   DRI_CONF_ENUM(2,gettext("Only GART (AGP/PCIE) memory (if 
> available)")) \
> -   DRI_CONF_DESC_END \
> +DRI_CONF_DESC_BEGIN(en,gettext("Used types of texture memory")) \
> +DRI_CONF_ENUM(0,gettext("All available memory")) \
> +DRI_CONF_ENUM(1,gettext("Only card memory (if available)")) \
> +DRI_CONF_ENUM(2,gettext("Only GART (AGP/PCIE) memory (if 
> available)")) \
> +DRI_CONF_DESC_END \
>  DRI_CONF_OPT_END
>  
>  #define DRI_CONF_MESA_GLTHREAD(def) \
> -- 
> Cheers,
>   Eric
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] docs: update required mako version

2018-08-17 Thread Dylan Baker
Reviewed-by: Dylan Baker 

Quoting Emil Velikov (2018-08-16 09:58:53)
> From: Emil Velikov 
> 
> The requirement was bumped a while back, but we forgot to update the
> docs.
> 
> Fixes: ed871af91c2 ("configure.ac: raise Mako required version to
> 0.8.0")
> Cc: Eric Engestrom 
> Signed-off-by: Emil Velikov 
> ---
>  docs/install.html | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/docs/install.html b/docs/install.html
> index f6094671cf9..d3c53d174a3 100644
> --- a/docs/install.html
> +++ b/docs/install.html
> @@ -75,7 +75,7 @@ you think you've spotted a bug let developers know by 
> filing a
>  Version 2.7 or later should work.
>  
>  http://www.makotemplates.org/";>Python Mako module -
> -Python Mako module is required. Version 0.3.4 or later should work.
> +Python Mako module is required. Version 0.8.0 or later should work.
>  
>  lex / yacc - for building the Mesa IR and GLSL compiler.
>  
> -- 
> 2.18.0
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] compiler/glsl/tests: Make tests python3 safe

2018-08-17 Thread Dylan Baker
Quoting Mathieu Bridon (2018-08-17 11:01:23)
> On Fri, 2018-08-17 at 10:45 -0700, Dylan Baker wrote:
> > Quoting Mathieu Bridon (2018-08-16 15:00:39)
> > > On Thu, 2018-08-16 at 14:21 -0700, Dylan Baker wrote:
> > > > ---
> > > > 
> > > > I didn't see any patches from anyone else, so I wrote some real
> > > > quick. Please
> > > > point to them if other patches already exist.
> > > 
> > > I was about to send mine, but you were faster. >_<
> > > 
> > > They ar every similar though, except that you missed glcpp_test.py,
> > > which requires a few more changes. (I have them ready, and can send
> > > them separately)
> > > 
> > > > diff --git a/src/compiler/glsl/tests/optimization_test.py
> > > > b/src/compiler/glsl/tests/optimization_test.py
> > > > index 577d2dfc20f..f40d0cee6bd 100755
> > > > --- a/src/compiler/glsl/tests/optimization_test.py
> > > > +++ b/src/compiler/glsl/tests/optimization_test.py
> > > > @@ -1,4 +1,4 @@
> > > > -#!/usr/bin/env python2
> > > > +#!/usr/bin/env python
> > > >  # encoding=utf-8
> > > >  # Copyright © 2018 Intel Corporation
> > > >  
> > > > @@ -71,7 +71,9 @@ def main():
> > > >  stdout=subprocess.PIPE,
> > > >  stderr=subprocess.PIPE,
> > > >  stdin=subprocess.PIPE)
> > > > -out, err = proc.communicate(source)
> > > > +out, err = proc.communicate(source.encode())
> > > > +out = out.decode()
> > > > +err = err.decode()
> > > 
> > > I usually find it too unpredictable to use the default encoding,
> > > and
> > > prefer always specifying 'utf-8'. (even on Python 3, you can't be
> > > sure
> > > that will always be the default)
> > 
> > That's true I guess. I've never seen anyone build python with utf-8
> > as not the default, but they can so we should do the right thing.
> 
> That's not a build-time thing though:
> 
>   $ python3 -c 'print("é".encode())'
>   b'\xc3\xa9'
>   $ LC_ALL=C python3 -c 'print("é".encode())'
>   Unable to decode the command from the command line:
>   UnicodeEncodeError: 'utf-8' codec can't encode characters in position 7-8: 
> surrogates not allowed
> 
> This happens regularly in some containers-like environment or SSH-ing
> to a server which doesn't have your client locale.
> 
> 
> -- 
> Mathieu
> 

Ah, I always have some kind of utf-8 encoding on machines I have access to, and
never need containers. I guess that explains why I've never seen that.


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 2/2] meson: Use python3 to run glsl tests

2018-08-17 Thread Dylan Baker
---
 src/compiler/glsl/tests/meson.build | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/tests/meson.build 
b/src/compiler/glsl/tests/meson.build
index fc7b863a278..2a41e30a28d 100644
--- a/src/compiler/glsl/tests/meson.build
+++ b/src/compiler/glsl/tests/meson.build
@@ -84,8 +84,10 @@ test(
 )
 
 test(
-  'glsl compiler warnings', find_program('warnings_test.py'),
+  'glsl compiler warnings',
+  prog_python,
   args : [
+join_paths(meson.current_source_dir(), 'warnings_test.py'),
 '--glsl-compiler', glsl_compiler,
 '--test-directory', join_paths(
   meson.source_root(), 'src', 'compiler', 'glsl', 'tests', 'warnings'
@@ -94,6 +96,9 @@ test(
 )
 test(
   'glsl optimization',
-  find_program('optimization_test.py'),
-  args : ['--test-runner', glsl_test],
+  prog_python,
+  args : [
+join_paths(meson.current_source_dir(), 'optimization_test.py'),
+'--test-runner', glsl_test
+  ],
 )
-- 
2.18.0

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


[Mesa-dev] [PATCH v3 1/2] compiler/glsl/tests: Make tests python3 safe

2018-08-17 Thread Dylan Baker
v2: - explicitly decode the output of subprocesses
- handle bytes and string types consistently rather than relying on
  python 2's coercion for bytes and ignoring them in python 3
v3: - explicitly set encode as well as decode
- python 2.7 and 3.x `bytes` instead of defining an alias
---
 src/compiler/glsl/tests/lower_jump_cases.py  |  2 +-
 src/compiler/glsl/tests/optimization_test.py |  6 --
 src/compiler/glsl/tests/sexps.py | 11 +--
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/compiler/glsl/tests/lower_jump_cases.py 
b/src/compiler/glsl/tests/lower_jump_cases.py
index b50ab734798..1977f3a9b4f 100644
--- a/src/compiler/glsl/tests/lower_jump_cases.py
+++ b/src/compiler/glsl/tests/lower_jump_cases.py
@@ -54,7 +54,7 @@ def make_test_case(f_name, ret_type, body):
 else:
 make_declarations(s, already_declared)
 make_declarations(body)
-return declarations.values() + \
+return list(declarations.values()) + \
 [['function', f_name, ['signature', ret_type, ['parameters'], body]]]
 
 
diff --git a/src/compiler/glsl/tests/optimization_test.py 
b/src/compiler/glsl/tests/optimization_test.py
index 577d2dfc20f..b3147ed08fc 100755
--- a/src/compiler/glsl/tests/optimization_test.py
+++ b/src/compiler/glsl/tests/optimization_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
 # encoding=utf-8
 # Copyright © 2018 Intel Corporation
 
@@ -71,7 +71,9 @@ def main():
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE,
 stdin=subprocess.PIPE)
-out, err = proc.communicate(source)
+out, err = proc.communicate(source.encode('utf-8'))
+out = out.decode('utf-8')
+err = err.decode('utf-8')
 if err:
 print('FAIL')
 print('Unexpected output on stderr: {}'.format(err),
diff --git a/src/compiler/glsl/tests/sexps.py b/src/compiler/glsl/tests/sexps.py
index a714af8d236..7939b42f9a2 100644
--- a/src/compiler/glsl/tests/sexps.py
+++ b/src/compiler/glsl/tests/sexps.py
@@ -28,6 +28,11 @@
 # as ['constant', 'float', ['1.00']].
 
 import re
+import sys
+if sys.version_info >= (3, 0, 0):
+STRING_TYPE = str
+else:
+STRING_TYPE = unicode
 
 def check_sexp(sexp):
 """Verify that the argument is a proper sexp.
@@ -39,7 +44,7 @@ def check_sexp(sexp):
 if isinstance(sexp, list):
 for s in sexp:
 check_sexp(s)
-elif not isinstance(sexp, basestring):
+elif not isinstance(sexp, (STRING_TYPE, bytes)):
 raise Exception('Not a sexp: {0!r}'.format(sexp))
 
 def parse_sexp(sexp):
@@ -70,8 +75,10 @@ def sexp_to_string(sexp):
 """Convert a sexp, represented as nested lists containing strings,
 into a single string of the form parseable by mesa.
 """
-if isinstance(sexp, basestring):
+if isinstance(sexp, STRING_TYPE):
 return sexp
+if isinstance(sexp, bytes):
+return sexp.encode('utf-8')
 assert isinstance(sexp, list)
 result = ''
 for s in sexp:
-- 
2.18.0

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


Re: [Mesa-dev] [PATCH 3/7] dri: Define DRI_MutableRenderBuffer extensions

2018-08-17 Thread Chad Versace
On Tue 14 Aug 2018, Tapani Pälli wrote:
> Hi Chad;
> 
> On 08/08/2018 06:53 PM, Tapani Pälli wrote:
> > 
> > 
> > On 07.08.2018 21:16, Chad Versace wrote:
> > > On Mon 06 Aug 2018, Chad Versace wrote:
> > > > On Fri 03 Aug 2018, Tapani Pälli wrote:
> > > > > One tiny nit below but for patches 3,4 and 5:
> > > > > 
> > > > > Reviewed-by: Tapani Pälli 
> > > > > 
> > > > > Special thanks for the documentation. I want to go through
> > > > > rest of changes
> > > > > within Android but I'm currently experiencing some horrible
> > > > > issues with the
> > > > > image building. I'm hoping to resolve those soon and get
> > > > > back to business.
> > > 
> > > Any luck with the Android patches?
> > 
> > I have the build working (for O) now but can test stuff only tomorrow,
> > will get back to you then.
> > 
> > > btw, I plan to start working on and/or reviewing
> > > VK_ANDROID_external_memory_android_hardware_buffer this week.
> > > I'll coordinate with you when I start.
> > 
> > OK cool, Celadon is in process of migrating to P and when that is
> > successfully done I'll get back to looking at this too.
> > 
> 
> As an update, I have P building and running fine now. I've run dEQP tests
> and noticed at least these 3 things I've missed and require
> changes/implementation:
> 
> * vkGetPhysicalDeviceImageFormatProperties2
> * vkGetPhysicalDeviceExternalBufferProperties
> * usage of AHardwareBuffer as backing store for VkBuffer objects
> 
> I'm going to work on these areas and try to get dEQP happier. My test app
> using the extension still seems to work fine, it does not use any APIs above
> but just import/export AHardwareBuffer in context of vkImage.

Great! Thanks for the update. (I will be travelling to Europe all next
week, and was out for most of this week. So, I'm behind on reviewing
everything, and may remain behind until I return from Europe).
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/2] compiler/glsl/tests: Make tests python3 safe

2018-08-17 Thread Dylan Baker
Quoting Mathieu Bridon (2018-08-17 10:58:38)
> On Fri, 2018-08-17 at 10:51 -0700, Dylan Baker wrote:
> > diff --git a/src/compiler/glsl/tests/optimization_test.py
> > b/src/compiler/glsl/tests/optimization_test.py
> > index 577d2dfc20f..65bac676963 100755
> > --- a/src/compiler/glsl/tests/optimization_test.py
> > +++ b/src/compiler/glsl/tests/optimization_test.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python2
> > +#!/usr/bin/env python
> >  # encoding=utf-8
> >  # Copyright © 2018 Intel Corporation
> >  
> > @@ -71,7 +71,9 @@ def main():
> >  stdout=subprocess.PIPE,
> >  stderr=subprocess.PIPE,
> >  stdin=subprocess.PIPE)
> > -out, err = proc.communicate(source)
> > +out, err = proc.communicate(source.encode())
> > +out = out.decode('utf-8')
> > +err = err.decode('utf-8')
> 
> Shouldn't you also specify the encoding for the source.encode() bit?

Yes

> 
> > diff --git a/src/compiler/glsl/tests/sexps.py
> > b/src/compiler/glsl/tests/sexps.py
> > index a714af8d236..09ca96e3be5 100644
> > --- a/src/compiler/glsl/tests/sexps.py
> > +++ b/src/compiler/glsl/tests/sexps.py
> > @@ -28,6 +28,13 @@
> >  # as ['constant', 'float', ['1.00']].
> >  
> >  import re
> > +import sys
> > +if sys.version_info >= (3, 0, 0):
> > +STRING_TYPE = str
> > +BYTES_TYPE = bytes
> > +else:
> > +STRING_TYPE = unicode
> > +BYTES_TYPE = str
> 
> Note that "bytes" exists on Python 2 and is an alias to "str":
> 
>   >>> bytes
>   
> 
> So you don't actually need BYTES_TYPE at all. :)

Despite all of the projects I've ported I did not know that. :)


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] compiler/glsl/tests: Make tests python3 safe

2018-08-17 Thread Mathieu Bridon
On Fri, 2018-08-17 at 10:45 -0700, Dylan Baker wrote:
> Quoting Mathieu Bridon (2018-08-16 15:00:39)
> > On Thu, 2018-08-16 at 14:21 -0700, Dylan Baker wrote:
> > > ---
> > > 
> > > I didn't see any patches from anyone else, so I wrote some real
> > > quick. Please
> > > point to them if other patches already exist.
> > 
> > I was about to send mine, but you were faster. >_<
> > 
> > They ar every similar though, except that you missed glcpp_test.py,
> > which requires a few more changes. (I have them ready, and can send
> > them separately)
> > 
> > > diff --git a/src/compiler/glsl/tests/optimization_test.py
> > > b/src/compiler/glsl/tests/optimization_test.py
> > > index 577d2dfc20f..f40d0cee6bd 100755
> > > --- a/src/compiler/glsl/tests/optimization_test.py
> > > +++ b/src/compiler/glsl/tests/optimization_test.py
> > > @@ -1,4 +1,4 @@
> > > -#!/usr/bin/env python2
> > > +#!/usr/bin/env python
> > >  # encoding=utf-8
> > >  # Copyright © 2018 Intel Corporation
> > >  
> > > @@ -71,7 +71,9 @@ def main():
> > >  stdout=subprocess.PIPE,
> > >  stderr=subprocess.PIPE,
> > >  stdin=subprocess.PIPE)
> > > -out, err = proc.communicate(source)
> > > +out, err = proc.communicate(source.encode())
> > > +out = out.decode()
> > > +err = err.decode()
> > 
> > I usually find it too unpredictable to use the default encoding,
> > and
> > prefer always specifying 'utf-8'. (even on Python 3, you can't be
> > sure
> > that will always be the default)
> 
> That's true I guess. I've never seen anyone build python with utf-8
> as not the default, but they can so we should do the right thing.

That's not a build-time thing though:

  $ python3 -c 'print("é".encode())'
  b'\xc3\xa9'
  $ LC_ALL=C python3 -c 'print("é".encode())'
  Unable to decode the command from the command line:
  UnicodeEncodeError: 'utf-8' codec can't encode characters in position 7-8: 
surrogates not allowed

This happens regularly in some containers-like environment or SSH-ing
to a server which doesn't have your client locale.


-- 
Mathieu

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


Re: [Mesa-dev] [PATCHv2 1/2] meson: Use python to run glsl tests

2018-08-17 Thread Dylan Baker
Quoting Emil Velikov (2018-08-17 04:11:32)
> From: Dylan Baker 
> 
> There are multiple reasons why the python scripts are executed
> explicitly via $PYTHON or equivalent. In random order:
> 
>  - env is rarely a thing on Windows

windows does something completely different based on file extensions, however
IUC, the python loader for windows does actually read the shbang to decide
whether to invoke python 2 or python 3, so that might not be a problem

>  - env can be outside of /usr/bin/

Ah Haiku. :)

>  - the python executable varies across platforms - pythonX.Y, python
>  - we want to use the same python version everywhere in Mesa
>  - executing the scripts manually, doesn't ensure all the dependencies
> are built and up-to date

This is not true for meson, meson runs tests all at once after all
building/re-building is complete.

>  - last but not least - it hinders python 2/3 compatibility
> 
> Fixes: 877d250ea14 ("meson: enable optimization-test")
> Fixes: ad9c2f20181 ("meson: run glsl compiler warnings test")
> Cc: Dylan Baker 
> Reviewed-by: Emil Velikov 
> [Emil: commit message, fixes tags, add glcpp test]
> Signed-off-by: Emil Velikov 
> ---
> Dylan,
> 
> I _may_ have gone overboard with the list above. Dropping to 1-2 is
> perfectly fine - let me know if your preference.
> 
> Either way, lets drop the execute bit/shebang. Running the scripts
> manually is cool, but not something anyone should do.
> ---
>  src/compiler/glsl/glcpp/meson.build |  3 ++-
>  src/compiler/glsl/tests/meson.build | 11 ---
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/src/compiler/glsl/glcpp/meson.build 
> b/src/compiler/glsl/glcpp/meson.build
> index 09d44ddd687..769406f5331 100644
> --- a/src/compiler/glsl/glcpp/meson.build
> +++ b/src/compiler/glsl/glcpp/meson.build
> @@ -64,8 +64,9 @@ if with_tests
>foreach m : modes
>  test(
>'glcpp test (@0@)'.format(m),
> -  find_program('tests/glcpp_test.py'),
> +  prog_python,
>args : [
> +join_paths(meson.current_source_dir(), 'tests/glcpp_test.py'),
>  glcpp, join_paths(meson.current_source_dir(), 'tests'),
>  '--@0@'.format(m),
>],
> diff --git a/src/compiler/glsl/tests/meson.build 
> b/src/compiler/glsl/tests/meson.build
> index fc7b863a278..2a41e30a28d 100644
> --- a/src/compiler/glsl/tests/meson.build
> +++ b/src/compiler/glsl/tests/meson.build
> @@ -84,8 +84,10 @@ test(
>  )
>  
>  test(
> -  'glsl compiler warnings', find_program('warnings_test.py'),
> +  'glsl compiler warnings',
> +  prog_python,
>args : [
> +join_paths(meson.current_source_dir(), 'warnings_test.py'),
>  '--glsl-compiler', glsl_compiler,
>  '--test-directory', join_paths(
>meson.source_root(), 'src', 'compiler', 'glsl', 'tests', 'warnings'
> @@ -94,6 +96,9 @@ test(
>  )
>  test(
>'glsl optimization',
> -  find_program('optimization_test.py'),
> -  args : ['--test-runner', glsl_test],
> +  prog_python,
> +  args : [
> +join_paths(meson.current_source_dir(), 'optimization_test.py'),
> +'--test-runner', glsl_test
> +  ],
>  )
> -- 
> 2.18.0
> 


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/2] compiler/glsl/tests: Make tests python3 safe

2018-08-17 Thread Mathieu Bridon
On Fri, 2018-08-17 at 10:51 -0700, Dylan Baker wrote:
> diff --git a/src/compiler/glsl/tests/optimization_test.py
> b/src/compiler/glsl/tests/optimization_test.py
> index 577d2dfc20f..65bac676963 100755
> --- a/src/compiler/glsl/tests/optimization_test.py
> +++ b/src/compiler/glsl/tests/optimization_test.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python2
> +#!/usr/bin/env python
>  # encoding=utf-8
>  # Copyright © 2018 Intel Corporation
>  
> @@ -71,7 +71,9 @@ def main():
>  stdout=subprocess.PIPE,
>  stderr=subprocess.PIPE,
>  stdin=subprocess.PIPE)
> -out, err = proc.communicate(source)
> +out, err = proc.communicate(source.encode())
> +out = out.decode('utf-8')
> +err = err.decode('utf-8')

Shouldn't you also specify the encoding for the source.encode() bit?

> diff --git a/src/compiler/glsl/tests/sexps.py
> b/src/compiler/glsl/tests/sexps.py
> index a714af8d236..09ca96e3be5 100644
> --- a/src/compiler/glsl/tests/sexps.py
> +++ b/src/compiler/glsl/tests/sexps.py
> @@ -28,6 +28,13 @@
>  # as ['constant', 'float', ['1.00']].
>  
>  import re
> +import sys
> +if sys.version_info >= (3, 0, 0):
> +STRING_TYPE = str
> +BYTES_TYPE = bytes
> +else:
> +STRING_TYPE = unicode
> +BYTES_TYPE = str

Note that "bytes" exists on Python 2 and is an alias to "str":

  >>> bytes
  

So you don't actually need BYTES_TYPE at all. :)
 

-- 
Mathieu

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


[Mesa-dev] [PATCH v4] anv: add VK_EXT_sampler_filter_minmax support

2018-08-17 Thread Yunchao He
This extension can be supported on SKL+. With this patch,
all corresponding tests (6K+) in CTS can pass. No test fails.

I verified CTS with the command below:
deqp-vk --deqp-case=dEQP-VK.pipeline.sampler.view_type.*reduce*

v2: 1) support all depth formats, not depth-only formats, 2) fix
a wrong indention (Jason).

v3: fix a few nits (Lionel).

v4: fix failures in CI: disable sampler reduction mode when compare
mode in sampler state is enabled (Lionel).
---
 src/intel/vulkan/anv_device.c  |  8 
 src/intel/vulkan/anv_extensions.py |  1 +
 src/intel/vulkan/anv_formats.c |  6 ++
 src/intel/vulkan/genX_state.c  | 26 ++
 4 files changed, 41 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 04fd6a829e..e45ba4b3af 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1116,6 +1116,14 @@ void anv_GetPhysicalDeviceProperties2(
  break;
   }
 
+  case 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT: {
+ VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *properties =
+(VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *)ext;
+ properties->filterMinmaxImageComponentMapping = pdevice->info.gen >= 
9;
+ properties->filterMinmaxSingleComponentFormats = true;
+ break;
+  }
+
   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES: {
  VkPhysicalDeviceSubgroupProperties *properties = (void *)ext;
 
diff --git a/src/intel/vulkan/anv_extensions.py 
b/src/intel/vulkan/anv_extensions.py
index ea837744b4..e165bd371d 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -125,6 +125,7 @@ EXTENSIONS = [
 Extension('VK_EXT_shader_stencil_export', 1, 'device->info.gen 
>= 9'),
 Extension('VK_EXT_vertex_attribute_divisor',  2, True),
 Extension('VK_EXT_post_depth_coverage',   1, 'device->info.gen 
>= 9'),
+Extension('VK_EXT_sampler_filter_minmax', 1, 'device->info.gen 
>= 9'),
 ]
 
 class VkVersion:
diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 815b320a82..33faf7cc37 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -489,6 +489,9 @@ get_image_format_features(const struct gen_device_info 
*devinfo,
   if (aspects == VK_IMAGE_ASPECT_DEPTH_BIT || devinfo->gen >= 8)
  flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
 
+  if ((aspects & VK_IMAGE_ASPECT_DEPTH_BIT) && devinfo->gen >= 9)
+ flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT;
+
   flags |= VK_FORMAT_FEATURE_BLIT_SRC_BIT |
VK_FORMAT_FEATURE_BLIT_DST_BIT |
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR |
@@ -521,6 +524,9 @@ get_image_format_features(const struct gen_device_info 
*devinfo,
if (isl_format_supports_sampling(devinfo, plane_format.isl_format)) {
   flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
 
+  if (devinfo->gen >= 9)
+ flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT;
+
   if (isl_format_supports_filtering(devinfo, plane_format.isl_format))
  flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
}
diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c
index b1014d9e79..cc64fe6d4a 100644
--- a/src/intel/vulkan/genX_state.c
+++ b/src/intel/vulkan/genX_state.c
@@ -245,6 +245,14 @@ static const uint32_t vk_to_gen_shadow_compare_op[] = {
[VK_COMPARE_OP_ALWAYS]   = PREFILTEROPNEVER,
 };
 
+#if GEN_GEN >= 9
+static const uint32_t vk_to_gen_sampler_reduction_mode[] = {
+   [VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT] = STD_FILTER,
+   [VK_SAMPLER_REDUCTION_MODE_MIN_EXT]  = MINIMUM,
+   [VK_SAMPLER_REDUCTION_MODE_MAX_EXT]  = MAXIMUM,
+};
+#endif
+
 VkResult genX(CreateSampler)(
 VkDevice_device,
 const VkSamplerCreateInfo*  pCreateInfo,
@@ -266,6 +274,10 @@ VkResult genX(CreateSampler)(
uint32_t border_color_offset = device->border_colors.offset +
   pCreateInfo->borderColor * 64;
 
+#if GEN_GEN >= 9
+   unsigned sampler_reduction_mode = STD_FILTER;
+#endif
+
vk_foreach_struct(ext, pCreateInfo->pNext) {
   switch (ext->sType) {
   case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO: {
@@ -281,6 +293,15 @@ VkResult genX(CreateSampler)(
  sampler->conversion = conversion;
  break;
   }
+#if GEN_GEN >= 9
+  case VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT: {
+ struct VkSamplerReductionModeCreateInfoEXT *sampler_reduction =
+(struct VkSamplerReductionModeCreateInfoEXT *) ext;
+ sampler_reduction_mode =
+vk_to_gen_sampler_reduction_mode[sampler_reduction->reductionMode];
+ break;
+  }
+#endif
   default:

Re: [Mesa-dev] [PATCH 2/2] glsl: remove execute bit and shebang from python tests

2018-08-17 Thread Dylan Baker
I don't care one way or the other on this, but it needs to wait for the series I
have to make two of the test cases py 3 ready, and for a patch from Mathieu to
make another py 3 ready.

Just for reference, it is convention (though I don't care to keep it) to use
such a shebang to mark whether a script is python2, python3, or both (using
python is supposed to mean python 2 and 3 compatible.)

You have my r-b, but please wait to push thisfor the other patches to land or
you'll break the meson build and make Mark and Clayton grumpy:
Reviewed-by: Dylan Baker 

Quoting Emil Velikov (2018-08-17 04:11:33)
> From: Emil Velikov 
> 
> Just like the rest of the tree - these should be run either as part of
> the build system check target, or at the very least with an explicitly
> versioned python executable.
> 
> Cc: Dylan Baker 
> Fixes: db8cd8e3677 ("glcpp/tests: Convert shell scripts to a python script")
> Fixes: 97c28cb0823 ("glsl/tests: Convert optimization-test.sh to pure python")
> Fixes: 3b52d292273 ("glsl/tests: reimplement warnings-test in python")
> Signed-off-by: Emil Velikov 
> ---
>  src/compiler/glsl/glcpp/tests/glcpp_test.py  | 1 -
>  src/compiler/glsl/tests/optimization_test.py | 1 -
>  src/compiler/glsl/tests/warnings_test.py | 1 -
>  3 files changed, 3 deletions(-)
>  mode change 100755 => 100644 src/compiler/glsl/glcpp/tests/glcpp_test.py
>  mode change 100755 => 100644 src/compiler/glsl/tests/optimization_test.py
>  mode change 100755 => 100644 src/compiler/glsl/tests/warnings_test.py
> 
> diff --git a/src/compiler/glsl/glcpp/tests/glcpp_test.py 
> b/src/compiler/glsl/glcpp/tests/glcpp_test.py
> old mode 100755
> new mode 100644
> index 8ac5d7cb0a1..8c7552124a6
> --- a/src/compiler/glsl/glcpp/tests/glcpp_test.py
> +++ b/src/compiler/glsl/glcpp/tests/glcpp_test.py
> @@ -1,4 +1,3 @@
> -#!/usr/bin/env python2
>  # encoding=utf-8
>  # Copyright © 2018 Intel Corporation
>  
> diff --git a/src/compiler/glsl/tests/optimization_test.py 
> b/src/compiler/glsl/tests/optimization_test.py
> old mode 100755
> new mode 100644
> index 577d2dfc20f..f8518a168e0
> --- a/src/compiler/glsl/tests/optimization_test.py
> +++ b/src/compiler/glsl/tests/optimization_test.py
> @@ -1,4 +1,3 @@
> -#!/usr/bin/env python2
>  # encoding=utf-8
>  # Copyright © 2018 Intel Corporation
>  
> diff --git a/src/compiler/glsl/tests/warnings_test.py 
> b/src/compiler/glsl/tests/warnings_test.py
> old mode 100755
> new mode 100644
> index 2e0f23180f3..2c4fa5a0d5a
> --- a/src/compiler/glsl/tests/warnings_test.py
> +++ b/src/compiler/glsl/tests/warnings_test.py
> @@ -1,4 +1,3 @@
> -#!/usr/bin/env python
>  # encoding=utf-8
>  # Copyright © 2017 Intel Corporation
>  
> -- 
> 2.18.0
> 


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 2/2] meson: Use python3 to run glsl tests

2018-08-17 Thread Dylan Baker
---
 src/compiler/glsl/tests/meson.build | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/tests/meson.build 
b/src/compiler/glsl/tests/meson.build
index fc7b863a278..2a41e30a28d 100644
--- a/src/compiler/glsl/tests/meson.build
+++ b/src/compiler/glsl/tests/meson.build
@@ -84,8 +84,10 @@ test(
 )
 
 test(
-  'glsl compiler warnings', find_program('warnings_test.py'),
+  'glsl compiler warnings',
+  prog_python,
   args : [
+join_paths(meson.current_source_dir(), 'warnings_test.py'),
 '--glsl-compiler', glsl_compiler,
 '--test-directory', join_paths(
   meson.source_root(), 'src', 'compiler', 'glsl', 'tests', 'warnings'
@@ -94,6 +96,9 @@ test(
 )
 test(
   'glsl optimization',
-  find_program('optimization_test.py'),
-  args : ['--test-runner', glsl_test],
+  prog_python,
+  args : [
+join_paths(meson.current_source_dir(), 'optimization_test.py'),
+'--test-runner', glsl_test
+  ],
 )
-- 
2.18.0

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


[Mesa-dev] [PATCH v2 1/2] compiler/glsl/tests: Make tests python3 safe

2018-08-17 Thread Dylan Baker
v2: - explicitly decode the output of subprocesses
- handle bytes and string types consistently rather than relying on
  python 2's coercion for bytes and ignoring them in python 3
---
 src/compiler/glsl/tests/lower_jump_cases.py  |  2 +-
 src/compiler/glsl/tests/optimization_test.py |  6 --
 src/compiler/glsl/tests/sexps.py | 13 +++--
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/compiler/glsl/tests/lower_jump_cases.py 
b/src/compiler/glsl/tests/lower_jump_cases.py
index b50ab734798..1977f3a9b4f 100644
--- a/src/compiler/glsl/tests/lower_jump_cases.py
+++ b/src/compiler/glsl/tests/lower_jump_cases.py
@@ -54,7 +54,7 @@ def make_test_case(f_name, ret_type, body):
 else:
 make_declarations(s, already_declared)
 make_declarations(body)
-return declarations.values() + \
+return list(declarations.values()) + \
 [['function', f_name, ['signature', ret_type, ['parameters'], body]]]
 
 
diff --git a/src/compiler/glsl/tests/optimization_test.py 
b/src/compiler/glsl/tests/optimization_test.py
index 577d2dfc20f..65bac676963 100755
--- a/src/compiler/glsl/tests/optimization_test.py
+++ b/src/compiler/glsl/tests/optimization_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
 # encoding=utf-8
 # Copyright © 2018 Intel Corporation
 
@@ -71,7 +71,9 @@ def main():
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE,
 stdin=subprocess.PIPE)
-out, err = proc.communicate(source)
+out, err = proc.communicate(source.encode())
+out = out.decode('utf-8')
+err = err.decode('utf-8')
 if err:
 print('FAIL')
 print('Unexpected output on stderr: {}'.format(err),
diff --git a/src/compiler/glsl/tests/sexps.py b/src/compiler/glsl/tests/sexps.py
index a714af8d236..09ca96e3be5 100644
--- a/src/compiler/glsl/tests/sexps.py
+++ b/src/compiler/glsl/tests/sexps.py
@@ -28,6 +28,13 @@
 # as ['constant', 'float', ['1.00']].
 
 import re
+import sys
+if sys.version_info >= (3, 0, 0):
+STRING_TYPE = str
+BYTES_TYPE = bytes
+else:
+STRING_TYPE = unicode
+BYTES_TYPE = str
 
 def check_sexp(sexp):
 """Verify that the argument is a proper sexp.
@@ -39,7 +46,7 @@ def check_sexp(sexp):
 if isinstance(sexp, list):
 for s in sexp:
 check_sexp(s)
-elif not isinstance(sexp, basestring):
+elif not isinstance(sexp, (STRING_TYPE, BYTES_TYPE)):
 raise Exception('Not a sexp: {0!r}'.format(sexp))
 
 def parse_sexp(sexp):
@@ -70,8 +77,10 @@ def sexp_to_string(sexp):
 """Convert a sexp, represented as nested lists containing strings,
 into a single string of the form parseable by mesa.
 """
-if isinstance(sexp, basestring):
+if isinstance(sexp, STRING_TYPE):
 return sexp
+if isinstance(sexp, BYTES_TYPE):
+return sexp.encode('utf-8')
 assert isinstance(sexp, list)
 result = ''
 for s in sexp:
-- 
2.18.0

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


Re: [Mesa-dev] [PATCH 1/2] compiler/glsl/tests: Make tests python3 safe

2018-08-17 Thread Dylan Baker
Quoting Mathieu Bridon (2018-08-16 15:00:39)
> On Thu, 2018-08-16 at 14:21 -0700, Dylan Baker wrote:
> > ---
> > 
> > I didn't see any patches from anyone else, so I wrote some real
> > quick. Please
> > point to them if other patches already exist.
> 
> I was about to send mine, but you were faster. >_<
> 
> They ar every similar though, except that you missed glcpp_test.py,
> which requires a few more changes. (I have them ready, and can send
> them separately)
> 

Can you send your glcpp fixes as well? Please CC me on them.

Dylan


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] compiler/glsl/tests: Make tests python3 safe

2018-08-17 Thread Dylan Baker
Quoting Mathieu Bridon (2018-08-16 15:00:39)
> On Thu, 2018-08-16 at 14:21 -0700, Dylan Baker wrote:
> > ---
> > 
> > I didn't see any patches from anyone else, so I wrote some real
> > quick. Please
> > point to them if other patches already exist.
> 
> I was about to send mine, but you were faster. >_<
> 
> They ar every similar though, except that you missed glcpp_test.py,
> which requires a few more changes. (I have them ready, and can send
> them separately)
> 
> > diff --git a/src/compiler/glsl/tests/optimization_test.py
> > b/src/compiler/glsl/tests/optimization_test.py
> > index 577d2dfc20f..f40d0cee6bd 100755
> > --- a/src/compiler/glsl/tests/optimization_test.py
> > +++ b/src/compiler/glsl/tests/optimization_test.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python2
> > +#!/usr/bin/env python
> >  # encoding=utf-8
> >  # Copyright © 2018 Intel Corporation
> >  
> > @@ -71,7 +71,9 @@ def main():
> >  stdout=subprocess.PIPE,
> >  stderr=subprocess.PIPE,
> >  stdin=subprocess.PIPE)
> > -out, err = proc.communicate(source)
> > +out, err = proc.communicate(source.encode())
> > +out = out.decode()
> > +err = err.decode()
> 
> I usually find it too unpredictable to use the default encoding, and
> prefer always specifying 'utf-8'. (even on Python 3, you can't be sure
> that will always be the default)

That's true I guess. I've never seen anyone build python with utf-8 as not the
default, but they can so we should do the right thing.

> 
> > diff --git a/src/compiler/glsl/tests/sexps.py
> > b/src/compiler/glsl/tests/sexps.py
> > index a714af8d236..b69d3a5e5d7 100644
> > --- a/src/compiler/glsl/tests/sexps.py
> > +++ b/src/compiler/glsl/tests/sexps.py
> > @@ -28,6 +28,11 @@
> >  # as ['constant', 'float', ['1.00']].
> >  
> >  import re
> > +import sys
> > +if sys.version_info >= (3, 0, 0):
> > +STRINGS = str
> > +else:
> > +STRINGS = (str, unicode)
> >  
> >  def check_sexp(sexp):
> >  """Verify that the argument is a proper sexp.
> > @@ -39,7 +44,7 @@ def check_sexp(sexp):
> >  if isinstance(sexp, list):
> >  for s in sexp:
> >  check_sexp(s)
> > -elif not isinstance(sexp, basestring):
> > +elif not isinstance(sexp, STRINGS):
> >  raise Exception('Not a sexp: {0!r}'.format(sexp))
> >  
> >  def parse_sexp(sexp):
> > @@ -70,7 +75,7 @@ def sexp_to_string(sexp):
> >  """Convert a sexp, represented as nested lists containing
> > strings,
> >  into a single string of the form parseable by mesa.
> >  """
> > -if isinstance(sexp, basestring):
> > +if isinstance(sexp, STRINGS):
> >  return sexp
> 
> Someone on this list ( :P ) once told me to avoid mising bytes and
> strings.
> 
> In this case, I believe the patch would be better as follows:
> 
> -if isinstance(sexp, basestring):
> +if isinstance(sexp, bytes):
> +return sexp.decode('utf-8')
> +if isinstance(sexp, string_type):
>  return sexp
> 
> And then the previous hunks can be:
> 
> +if sys.version_info < (3, 0):
> +string_type = unicode
> +else:
> +string_type = str
> \u2026
> -elif not isinstance(sexp, basestring):
> +elif not isinstance(sexp, (string_type, bytes)):

Yeah, you're right.

I really want to just remove the s-expression stuff and replace it with json,
since you can represent all s-expressions with json, and then we wouldn't need a
special module in python. But I'll probably never do it, so...

> 
> 
> -- 
> Mathieu
> 


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure: use AM_PATH_PYTHON to look for the python version

2018-08-17 Thread Dylan Baker
Quoting Emil Velikov (2018-08-17 03:12:56)
> On 16 August 2018 at 21:28, Dylan Baker  wrote:
> > Quoting Eric Engestrom (2018-08-16 09:52:05)
> >> On Thursday, 2018-08-16 17:18:56 +0100, Emil Velikov wrote:
> >> > From: Emil Velikov 
> >> >
> >> > Currently we use AC_CHECK_PROGS looking for python2.7, python2 and
> >> > finally python. That is due to the varying names used across the
> >> > different OS.
> >> >
> >> > Use the handy AM_PATH_PYTHON which finds the correct name and checks for
> >> > the version.
> >> >
> >> > Note: python2.7 has been an unofficial requirement for quite some time.
> >> > Update the docs to reflect that.
> >> >
> >> > Cc: Dylan Baker 
> >> > Signed-off-by: Emil Velikov 
> >> > ---
> >> >  configure.ac  | 7 +--
> >> >  docs/install.html | 2 +-
> >> >  2 files changed, 6 insertions(+), 3 deletions(-)
> >> >
> >> > diff --git a/configure.ac b/configure.ac
> >> > index c2155a541b0..57fddb927ce 100644
> >> > --- a/configure.ac
> >> > +++ b/configure.ac
> >> > @@ -125,7 +125,10 @@ AC_PROG_GREP
> >> >  AC_PROG_NM
> >> >  AM_PROG_AS
> >> >  AX_CHECK_GNU_MAKE
> >> > -AC_CHECK_PROGS([PYTHON2], [python2.7 python2 python])
> >> > +AM_PATH_PYTHON([2.7],, [:])
> >> > +PYTHON2=$PYTHON
> >> > +AC_SUBST([PYTHON2])
> >> > +
> >> >  AC_PROG_SED
> >> >  AC_PROG_MKDIR_P
> >> >
> >> > @@ -157,7 +160,7 @@ fi
> >> >
> >> >  AX_CHECK_PYTHON_MAKO_MODULE($PYTHON_MAKO_REQUIRED)
> >> >
> >> > -if test -z "$PYTHON2"; then
> >> > +if test "$PYTHON2" = ":"; then
> >> >  if test ! -f "$srcdir/src/util/format_srgb.c"; then
> >> >  AC_MSG_ERROR([Python not found - unable to generate sources])
> >> >  fi
> >> > diff --git a/docs/install.html b/docs/install.html
> >> > index 08081944cfc..f6094671cf9 100644
> >> > --- a/docs/install.html
> >> > +++ b/docs/install.html
> >> > @@ -72,7 +72,7 @@ you think you've spotted a bug let developers know by 
> >> > filing a
> >> >
> >> >  
> >> >  https://www.python.org/";>Python - Python is required.
> >> > -Version 2.6.4 or later should work.
> >> > +Version 2.7 or later should work.
> >
> > Is this just the autotools build, or is this for all builds? For meson 3.4+ 
> > is
> > required.
> >
> With a 1-2 line change one could use python 2.7 there, not sure if
> that's a good idea though ;-)

For meson I don't think it makes any sense to allow using python 2.7 for the
generators since meson itself requires 3.x; in the same way I don't think it's
worthwhile to allow python 3.x with the current scons build since it requires
2.7

> Since there is no mention about build systems lets leave that as
> follow-up patch?

That seems fine.

> 
> >> >  
> >> >  http://www.makotemplates.org/";>Python Mako module -
> >> >  Python Mako module is required. Version 0.3.4 or later should work.
> >> Side note: I think this is also wrong  ^
> >> Should be 0.8.0 I believe.
> >
> > Yes, it should be 0.8.0, good catch.
> >
> Agreed. Separate patch is out [1] having a correct documentation in
> stable is nice.
> 
> Thanks
> Emil
> 
> [1] https://patchwork.freedesktop.org/patch/244951/


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 107098] Segfault after munmap(kms_sw_dt->ro_mapped)

2018-08-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=107098

Emil Velikov  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #4 from Emil Velikov  ---
Should be fixed with the commit 9baff597ce021f7691187b0d1d1bbc16d07b13e1.
Fix will find it's route to stable in due time.

Thanks for the work everyone!

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 0/6] support config for third-party DRI driver load

2018-08-17 Thread Emil Velikov
On 15 August 2018 at 13:29, Emil Velikov  wrote:
> On 6 August 2018 at 04:19, Qiang Yu  wrote:
>> This patch series is discussed in thread:
>> https://lists.freedesktop.org/archives/mesa-dev/2018-July/201348.html
>>
>> amdgpu-pro driver can use drirc config to override the mesa radeonsi
>> dri driver so that it can use the mesa libgbm instead of maintain
>> a customized one.
>>
>> We also expand drirc config file location to some directory for the
>> ease of driver and application to add their own config files.
>>
>> v3:
>>   1. split more patches
>>   2. fix dirent mem leak
>>
>> v2:
>>   1. remove /etc/drirc.d
>>   2. move orginal /etc/drirc to /usr/share/drirc.d
>>   3. add kernel_driver device attribute
>>
>> Qiang Yu (6):
>>   xmlconfig: refine driParseConfigFiles to use parseOneConfigFile
>>   xmlconfig: read more config files from drirc.d/
>>   driconf: move ${sysconfdir}/drirc to
>> ${datadir}/drirc.d/00-mesa-defaults.conf
>>   loader: abstract loader_get_kernel_driver_name for reuse
>>   xmlconfig: add kernel_driver device attribute
>>   loader: add dri_driver option to override dri driver to load
>>
> Pardon for the delay, Qiang Yu  Series looks good and is
> Reviewed-by: Emil Velikov 
>
> The series has been on the list for a while, Michel seems happy with
> it, so I'm inclined to merge this late today/early tomorrow.
> Please keep an eye open for any bug reports - just a gut feeling.
>
So instead of waiting for reports I've spun this in Travis/Appveyour
and addressed:
- missing include  (for PATH_MAX) in patch 1
- added HAVE_LIBDRM guard for __driConfigOptionsLoader and
loader_get_dri_config_driver

In theory, one should be able to build with driconf and w/o libdrm,
and vice-versa.
If you have some time, please have a look - is it possible, would it
make sense, etc.

Thanks
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [AppVeyor] mesa master #8635 completed

2018-08-17 Thread AppVeyor


Build mesa 8635 completed



Commit d9ea015ced by Jason Ekstrand on 8/7/2018 10:47 PM:

anv/pipeline: Lower pipeline layouts etc. after linking\n\nThis allows us to use the link-optimized shader for determining binding\ntable layouts and, more importantly, URB layouts.  For apps running on\nDXVK, this is extremely important as DXVK likes to declare max-size\ninputs and outputs and this lets is massively shrink our URB space\nrequirements.\n\nVkPipeline-db results (Batman pipelines only) on KBL:\n\ntotal instructions in shared programs: 820403 -> 790008 (-3.70%)\ninstructions in affected programs: 273759 -> 243364 (-11.10%)\nhelped: 622\nHURT: 42\n\ntotal spills in shared programs: 8449 -> 5212 (-38.31%)\nspills in affected programs: 3427 -> 190 (-94.46%)\nhelped: 607\nHURT: 2\n\ntotal fills in shared programs: 11638 -> 6067 (-47.87%)\nfills in affected programs: 5879 -> 308 (-94.76%)\nhelped: 606\nHURT: 3\n\nLooking at shaders by hand, it makes the URB between TCS and TES go from\ncontaining 32 per-vertex varyings per tessellation shader pair to a more\nreasonable 8-12.  For a 3-vertex patch, that's at least half the URB\nspace no matter how big the patch section is.\n\nReviewed-by: Timothy Arceri 


Configure your notification preferences

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


[Mesa-dev] [AppVeyor] mesa appveyor #8634 failed

2018-08-17 Thread AppVeyor



Build mesa 8634 failed


Commit 0a8cf88172 by Jose Fonseca on 8/17/2018 3:39 PM:

Debug git CRLF


Configure your notification preferences

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


Re: [Mesa-dev] [PATCH] python: Help Python 2 print the line

2018-08-17 Thread Brian Paul

On 08/17/2018 09:32 AM, Jose Fonseca wrote:

On 17/08/18 16:08, Jose Fonseca wrote:

On 17/08/18 15:49, Mathieu Bridon wrote:

On Fri, 2018-08-17 at 15:30 +0100, Jose Fonseca wrote:

On 17/08/18 15:26, Mathieu Bridon wrote:

On Fri, 2018-08-17 at 15:08 +0100, Jose Fonseca wrote:

On 17/08/18 15:06, Jose Fonseca wrote:

On 17/08/18 14:52, Jose Fonseca wrote:

On 17/08/18 14:30, Jose Fonseca wrote:

On 17/08/18 14:22, Mathieu Bridon wrote:

---
Jose, can you test whether this patch fixes your build
issues?

I don't have access to a Windows machine, and I can't
reproduce your
problem on Linux.

    src/util/xmlpool/gen_xmlpool.py | 5 +
    1 file changed, 5 insertions(+)

diff --git a/src/util/xmlpool/gen_xmlpool.py
b/src/util/xmlpool/gen_xmlpool.py
index 327709c7f8d..12177dc50f5 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -218,6 +218,11 @@ for line in template:
    assert len(descMatches) == 0
    descMatches = [matchDESC_BEGIN]
    else:
+    # In Python 2, stdout expects encoded byte
strings,
or else
it will
+    # encode them with the ascii 'codec'
+    if sys.version_info.major == 2:
+    line = line.encode('utf-8')
+
    print(line, end='')
    template.close()



It fixes the UnicodeEncodeError.  I need to do more testing
to
see if
it fixes all errors.


I think we should fix the print(end ..) statemet.   In
fact, it
might
be easier to have an helper function (e.g., write()
)  which
does the
sys.version check , utf8 encoding, and print, and use it
everywhere
print is used now.


Jose



Unfortunately I still get build failures with your change:

 Compiling src\gallium\auxiliary\pipe-loader\pipe_loader.c
...
pipe_loader.c
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2146: syntax error: missing ';' before identifier
'gettext'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2143: syntax error: missing ')' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2143: syntax error: missing '{' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2059: syntax error: 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2059: syntax error: ')'

whereas if I just revert your
bd27203f4d808763ac24ac94eb677cacf3e7cb99
change these errors go away.

I compared the generated options.h, before/after your change,
and
it
seems the problem is that we're now emitting `gettext(...)`
function
calls which don't exist on Windows:

--- options.h.old   2018-08-17 14:48:09.0 +0100
+++ options.h.new   2018-08-17 14:41:36.0 +0100
@@ -57,101 +57,101 @@
 */
    #define DRI_CONF_SECTION_DEBUG \
    DRI_CONF_SECTION_BEGIN \
-   DRI_CONF_DESC(en,"Debugging")
+   DRI_CONF_DESC(en,gettext("Debugging"))

    #define DRI_CONF_NO_RAST(def) \
    DRI_CONF_OPT_BEGIN_B(no_rast, def) \

[...]


Jose



Ok, I have a strong hunch to what's the problem, with your
change
you're
reading the input as bytes

  template = open (template_header_path, "rb")  <=

which means that on Windows the lines will have "\r\n" which
then
causes
all regular expressions to fail (as $ won't match)

And this finally explains why this afeccts some systems but not
others:
it depends on whether git clones t_options.h with CRLF or
LF


The thing is, the old code would do:

    template = open (template_header_path, "r")
    for line in template:
    …

In my testing, with Python 2 the lines **already** end with "\r\n",
so
I don't see how this could have worked before. :-/


That's because you're testing on Linux.  On Linux "b" has no effect.
But on Windows the default is "t" and "b" makes it binary.  That's
why
this worked before.


See 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.python.org%2F2%2Flibrary%2Ffunctions.html%23open&data=02%7C01%7Cjfonseca%40vmware.com%7Ca7bc6963b38b491115e908d60450ac4b%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636701141882257685&sdata=JDdi%2FrNCkD0UyBMKsNQwVF42a0eNp3r6137u%2FJ99YmA%3D&reserved=0 
which says:


   Append 'b' to the mode to open the file in binary mode, on
systems
that differentiate between binary and text files; on systems that
don’t
have this distinction, adding the 'b' has no effect.


Can you try this branch?

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fbochecha%2Fmesa%2Ftree%2Fpython2-windows-scons&data=02%7C01%7Cjfonseca%40vmware.com%7Ca7bc6963b38b491115e908d60450ac4b%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636701141882257685&sdata=wkWAs3fUgfbleKPvygfJdC4kroaaqxbFUZrjkb9G8R0%3D&reserved=0 



It should fix the problem.




Yes, it doesn indeed.  And in a much more elegant way.  Change is

   Reviewed-by: Jose Fonseca 

Thanks!

I didn't

Re: [Mesa-dev] [PATCH] python: Help Python 2 print the line

2018-08-17 Thread Jose Fonseca

On 17/08/18 16:08, Jose Fonseca wrote:

On 17/08/18 15:49, Mathieu Bridon wrote:

On Fri, 2018-08-17 at 15:30 +0100, Jose Fonseca wrote:

On 17/08/18 15:26, Mathieu Bridon wrote:

On Fri, 2018-08-17 at 15:08 +0100, Jose Fonseca wrote:

On 17/08/18 15:06, Jose Fonseca wrote:

On 17/08/18 14:52, Jose Fonseca wrote:

On 17/08/18 14:30, Jose Fonseca wrote:

On 17/08/18 14:22, Mathieu Bridon wrote:

---
Jose, can you test whether this patch fixes your build
issues?

I don't have access to a Windows machine, and I can't
reproduce your
problem on Linux.

    src/util/xmlpool/gen_xmlpool.py | 5 +
    1 file changed, 5 insertions(+)

diff --git a/src/util/xmlpool/gen_xmlpool.py
b/src/util/xmlpool/gen_xmlpool.py
index 327709c7f8d..12177dc50f5 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -218,6 +218,11 @@ for line in template:
    assert len(descMatches) == 0
    descMatches = [matchDESC_BEGIN]
    else:
+    # In Python 2, stdout expects encoded byte
strings,
or else
it will
+    # encode them with the ascii 'codec'
+    if sys.version_info.major == 2:
+    line = line.encode('utf-8')
+
    print(line, end='')
    template.close()



It fixes the UnicodeEncodeError.  I need to do more testing
to
see if
it fixes all errors.


I think we should fix the print(end ..) statemet.   In
fact, it
might
be easier to have an helper function (e.g., write()
)  which
does the
sys.version check , utf8 encoding, and print, and use it
everywhere
print is used now.


Jose



Unfortunately I still get build failures with your change:

 Compiling src\gallium\auxiliary\pipe-loader\pipe_loader.c
...
pipe_loader.c
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2146: syntax error: missing ';' before identifier
'gettext'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2143: syntax error: missing ')' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2143: syntax error: missing '{' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2059: syntax error: 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2059: syntax error: ')'

whereas if I just revert your
bd27203f4d808763ac24ac94eb677cacf3e7cb99
change these errors go away.

I compared the generated options.h, before/after your change,
and
it
seems the problem is that we're now emitting `gettext(...)`
function
calls which don't exist on Windows:

--- options.h.old   2018-08-17 14:48:09.0 +0100
+++ options.h.new   2018-08-17 14:41:36.0 +0100
@@ -57,101 +57,101 @@
 */
    #define DRI_CONF_SECTION_DEBUG \
    DRI_CONF_SECTION_BEGIN \
-   DRI_CONF_DESC(en,"Debugging")
+   DRI_CONF_DESC(en,gettext("Debugging"))

    #define DRI_CONF_NO_RAST(def) \
    DRI_CONF_OPT_BEGIN_B(no_rast, def) \

[...]


Jose



Ok, I have a strong hunch to what's the problem, with your
change
you're
reading the input as bytes

  template = open (template_header_path, "rb")  <=

which means that on Windows the lines will have "\r\n" which
then
causes
all regular expressions to fail (as $ won't match)

And this finally explains why this afeccts some systems but not
others:
it depends on whether git clones t_options.h with CRLF or
LF


The thing is, the old code would do:

    template = open (template_header_path, "r")
    for line in template:
    …

In my testing, with Python 2 the lines **already** end with "\r\n",
so
I don't see how this could have worked before. :-/


That's because you're testing on Linux.  On Linux "b" has no effect.
But on Windows the default is "t" and "b" makes it binary.  That's
why
this worked before.


See 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.python.org%2F2%2Flibrary%2Ffunctions.html%23open&data=02%7C01%7Cjfonseca%40vmware.com%7Ca7bc6963b38b491115e908d60450ac4b%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636701141882257685&sdata=JDdi%2FrNCkD0UyBMKsNQwVF42a0eNp3r6137u%2FJ99YmA%3D&reserved=0 
which says:


   Append 'b' to the mode to open the file in binary mode, on
systems
that differentiate between binary and text files; on systems that
don’t
have this distinction, adding the 'b' has no effect.


Can you try this branch?

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fbochecha%2Fmesa%2Ftree%2Fpython2-windows-scons&data=02%7C01%7Cjfonseca%40vmware.com%7Ca7bc6963b38b491115e908d60450ac4b%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636701141882257685&sdata=wkWAs3fUgfbleKPvygfJdC4kroaaqxbFUZrjkb9G8R0%3D&reserved=0 



It should fix the problem.




Yes, it doesn indeed.  And in a much more elegant way.  Change is

   Reviewed-by: Jose Fonseca 

Thanks!

I didn't know about io module -- it seems quite handy

Re: [Mesa-dev] Fix the build on Windows

2018-08-17 Thread Mathieu Bridon
On Fri, 2018-08-17 at 09:23 -0600, Brian Paul wrote:
> On 08/17/2018 09:16 AM, Mathieu Bridon wrote:
> > This is follow up to my recent patches which made the Python build
> > scripts compatible with both Python 2 and 3, then moved the Meson
> > build
> > system to using Python 3 for them.
> > 
> > Unfortunately, one thing I hadn't tested was running them on
> > Windows,
> > where the changes broke the build.
> > 
> > See the exchange with Jose for the details:
> > 
> > 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Farchives%2Fmesa-dev%2F2018-August%2F202847.html&data=02%7C01%7Cbrianp%40vmware.com%7C01cd239cdd5b4b9c156608d604547cd7%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636701158254371166&sdata=nLN%2FkP37AyHSV3z4XwjdhUN3suDGUlfZDxWRWn39WhI%3D&reserved=0
> > 
> > These 2 patches have already been tested by Jose, who confirms they
> > fix
> > the issue he countered.
> 
> Do you need one of us to push the patches for you?

I do, yes.


-- 
Mathieu

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


Re: [Mesa-dev] Fix the build on Windows

2018-08-17 Thread Brian Paul

On 08/17/2018 09:16 AM, Mathieu Bridon wrote:

This is follow up to my recent patches which made the Python build
scripts compatible with both Python 2 and 3, then moved the Meson build
system to using Python 3 for them.

Unfortunately, one thing I hadn't tested was running them on Windows,
where the changes broke the build.

See the exchange with Jose for the details:

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Farchives%2Fmesa-dev%2F2018-August%2F202847.html&data=02%7C01%7Cbrianp%40vmware.com%7C01cd239cdd5b4b9c156608d604547cd7%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636701158254371166&sdata=nLN%2FkP37AyHSV3z4XwjdhUN3suDGUlfZDxWRWn39WhI%3D&reserved=0

These 2 patches have already been tested by Jose, who confirms they fix
the issue he countered.


Do you need one of us to push the patches for you?

-Brian


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


Re: [Mesa-dev] [PATCH 3/5] anv/pipeline: Use more fields from stage in compile_cs

2018-08-17 Thread Lionel Landwerlin

Reviewed-by: Lionel Landwerlin 

On 08/08/18 09:12, Jason Ekstrand wrote:

---
  src/intel/vulkan/anv_pipeline.c | 37 +++--
  1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 23af0f1c924..e6a97aa8ca7 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1115,6 +1115,9 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
.module = module,
.entrypoint = entrypoint,
.spec_info = spec_info,
+  .cache_key = {
+ .stage = MESA_SHADER_COMPUTE,
+  }
 };
  
 struct anv_shader_bin *bin = NULL;

@@ -1123,13 +1126,11 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
  
 ANV_FROM_HANDLE(anv_pipeline_layout, layout, info->layout);
  
-   unsigned char sha1[20];

-   anv_pipeline_hash_compute(pipeline, layout, &stage, sha1);
-   bin = anv_device_search_for_kernel(pipeline->device, cache, sha1, 20);
+   anv_pipeline_hash_compute(pipeline, layout, &stage, stage.cache_key.sha1);
+   bin = anv_device_search_for_kernel(pipeline->device, cache, 
&stage.cache_key,
+  sizeof(stage.cache_key));
  
 if (bin == NULL) {

-  struct brw_cs_prog_data prog_data = {};
-
stage.bind_map = (struct anv_pipeline_bind_map) {
   .surface_to_descriptor = stage.surface_to_descriptor,
   .sampler_to_descriptor = stage.sampler_to_descriptor
@@ -1137,31 +1138,35 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
  
void *mem_ctx = ralloc_context(NULL);
  
-  nir_shader *nir = anv_pipeline_compile(pipeline, mem_ctx, layout, &stage,

- &prog_data.base, &stage.bind_map);
-  if (nir == NULL) {
+  stage.nir = anv_pipeline_compile(pipeline, mem_ctx, layout, &stage,
+   &stage.prog_data.base,
+   &stage.bind_map);
+  if (stage.nir == NULL) {
   ralloc_free(mem_ctx);
   return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
  
-  NIR_PASS_V(nir, anv_nir_add_base_work_group_id, &prog_data);

+  NIR_PASS_V(stage.nir, anv_nir_add_base_work_group_id,
+ &stage.prog_data.cs);
  
-  anv_fill_binding_table(&prog_data.base, 1);

+  anv_fill_binding_table(&stage.prog_data.cs.base, 1);
  
const unsigned *shader_code =

   brw_compile_cs(compiler, NULL, mem_ctx, &stage.key.cs,
-&prog_data, nir, -1, NULL);
+&stage.prog_data.cs, stage.nir, -1, NULL);
if (shader_code == NULL) {
   ralloc_free(mem_ctx);
   return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
  
-  const unsigned code_size = prog_data.base.program_size;

-  bin = anv_device_upload_kernel(pipeline->device, cache, sha1, 20,
+  const unsigned code_size = stage.prog_data.base.program_size;
+  bin = anv_device_upload_kernel(pipeline->device, cache,
+ &stage.cache_key, sizeof(stage.cache_key),
   shader_code, code_size,
- nir->constant_data,
- nir->constant_data_size,
- &prog_data.base, sizeof(prog_data),
+ stage.nir->constant_data,
+ stage.nir->constant_data_size,
+ &stage.prog_data.base,
+ sizeof(stage.prog_data.cs),
   &stage.bind_map);
if (!bin) {
   ralloc_free(mem_ctx);



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


Re: [Mesa-dev] [PATCH 2/5] anv/apply_pipeline_layout: Add to the bind map instead of replacing it

2018-08-17 Thread Lionel Landwerlin

On 08/08/18 09:12, Jason Ekstrand wrote:

This commit makes three changes.  One is to only walk the descriptors once
and set bind map sizes at the same time as filling out the entries.  The
second is to make the pass additive so that we can put stuff in the bind
map before applying the pipeline layout.  Third, we switch to using
designated initializers.


Nice cleanup :)

Reviewed-by: Lionel Landwerlin 


---
  src/intel/vulkan/anv_descriptor_set.c | 13 
  .../vulkan/anv_nir_apply_pipeline_layout.c| 64 ++-
  src/intel/vulkan/anv_private.h|  3 -
  3 files changed, 21 insertions(+), 59 deletions(-)

diff --git a/src/intel/vulkan/anv_descriptor_set.c 
b/src/intel/vulkan/anv_descriptor_set.c
index 66ed28292b0..2bd1d86f4d4 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -491,19 +491,6 @@ anv_descriptor_set_layout_size(const struct 
anv_descriptor_set_layout *layout)
layout->buffer_count * sizeof(struct anv_buffer_view);
  }
  
-size_t

-anv_descriptor_set_binding_layout_get_hw_size(const struct 
anv_descriptor_set_binding_layout *binding)
-{
-   if (!binding->immutable_samplers)
-  return binding->array_size;
-
-   uint32_t total_plane_count = 0;
-   for (uint32_t i = 0; i < binding->array_size; i++)
-  total_plane_count += binding->immutable_samplers[i]->n_planes;
-
-   return total_plane_count;
-}
-
  struct surface_state_free_list_entry {
 void *next;
 struct anv_state state;
diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c 
b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
index c287a005bd6..67ebaa6ce6c 100644
--- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
+++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
@@ -379,37 +379,11 @@ anv_nir_apply_pipeline_layout(struct anv_pipeline 
*pipeline,
   get_used_bindings_block(block, &state);
 }
  
-   if (state.uses_constants)

-  map->surface_count++;
-
-   for (uint32_t set = 0; set < layout->num_sets; set++) {
-  struct anv_descriptor_set_layout *set_layout = layout->set[set].layout;
-
-  BITSET_WORD b, _tmp;
-  BITSET_FOREACH_SET(b, _tmp, state.set[set].used,
- set_layout->binding_count) {
- if (set_layout->binding[b].stage[stage].surface_index >= 0) {
-map->surface_count +=
-   
anv_descriptor_set_binding_layout_get_hw_size(&set_layout->binding[b]);
- }
- if (set_layout->binding[b].stage[stage].sampler_index >= 0) {
-map->sampler_count +=
-   
anv_descriptor_set_binding_layout_get_hw_size(&set_layout->binding[b]);
- }
- if (set_layout->binding[b].stage[stage].image_index >= 0)
-map->image_count += set_layout->binding[b].array_size;
-  }
-   }
-
-   unsigned surface = 0;
-   unsigned sampler = 0;
-   unsigned image = 0;
-
 if (state.uses_constants) {
-  state.constants_offset = surface;
-  map->surface_to_descriptor[surface].set =
+  state.constants_offset = map->surface_count;
+  map->surface_to_descriptor[map->surface_count].set =
   ANV_DESCRIPTOR_SET_SHADER_CONSTANTS;
-  surface++;
+  map->surface_count++;
 }
  
 for (uint32_t set = 0; set < layout->num_sets; set++) {

@@ -422,38 +396,42 @@ anv_nir_apply_pipeline_layout(struct anv_pipeline 
*pipeline,
  &set_layout->binding[b];
  
   if (binding->stage[stage].surface_index >= 0) {

-state.set[set].surface_offsets[b] = surface;
+state.set[set].surface_offsets[b] = map->surface_count;
  struct anv_sampler **samplers = binding->immutable_samplers;
  for (unsigned i = 0; i < binding->array_size; i++) {
 uint8_t planes = samplers ? samplers[i]->n_planes : 1;
 for (uint8_t p = 0; p < planes; p++) {
-  map->surface_to_descriptor[surface].set = set;
-  map->surface_to_descriptor[surface].binding = b;
-  map->surface_to_descriptor[surface].index = i;
-  map->surface_to_descriptor[surface].plane = p;
-  surface++;
+  map->surface_to_descriptor[map->surface_count++] =
+ (struct anv_pipeline_binding) {
+.set = set,
+.binding = b,
+.index = i,
+.plane = p,
+ };
 }
  }
   }
  
   if (binding->stage[stage].sampler_index >= 0) {

-state.set[set].sampler_offsets[b] = sampler;
+state.set[set].sampler_offsets[b] = map->sampler_count;
  struct anv_sampler **samplers = binding->immutable_samplers;
  for (unsigned i = 0; i < binding->array_size; i++) {
 uint8_t planes = samplers ? samplers[i]->n_planes : 1;
 for (uint8_t p = 0; p < planes; p+

Re: [Mesa-dev] [PATCH 1/5] anv/lower_ycbcr: Use the binding array size for bounds checks

2018-08-17 Thread Lionel Landwerlin

On 08/08/18 09:12, Jason Ekstrand wrote:

Because lower_ycbcr gets called before apply_pipeline_layout, the
indices are all logical and the binding layout HW size is actually too
big for the bounds check.  We should just use the regular logical array
size instead.

Fixes: f3e91e78a33 "anv: add nir lowering pass for ycbcr textures"


Thanks,

Reviewed-by: Lionel Landwerlin 


---
  src/intel/vulkan/anv_nir_lower_ycbcr_textures.c | 10 --
  1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c 
b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
index 5a971d9be39..71e511f34b7 100644
--- a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
+++ b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
@@ -340,18 +340,16 @@ try_lower_tex_ycbcr(struct anv_pipeline_layout *layout,
 if (binding->immutable_samplers == NULL)
return false;
  
-   unsigned texture_index = tex->texture_index;

+   assert(tex->texture_index == 0);
+   unsigned array_index = 0;
 if (deref->deref_type != nir_deref_type_var) {
assert(deref->deref_type == nir_deref_type_array);
nir_const_value *const_index = nir_src_as_const_value(deref->arr.index);
if (!const_index)
   return false;
-  size_t hw_binding_size =
- anv_descriptor_set_binding_layout_get_hw_size(binding);
-  texture_index += MIN2(const_index->u32[0], hw_binding_size - 1);
+  array_index = MIN2(const_index->u32[0], binding->array_size - 1);
 }
-   const struct anv_sampler *sampler =
-  binding->immutable_samplers[texture_index];
+   const struct anv_sampler *sampler = 
binding->immutable_samplers[array_index];
  
 if (sampler->conversion == NULL)

return false;



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


[Mesa-dev] [PATCH 1/2] python: Help Python 2 print the line

2018-08-17 Thread Mathieu Bridon
Reviewed-by: Jose Fonseca 
---
 src/util/xmlpool/gen_xmlpool.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/util/xmlpool/gen_xmlpool.py b/src/util/xmlpool/gen_xmlpool.py
index 327709c7f8d..12177dc50f5 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -218,6 +218,11 @@ for line in template:
 assert len(descMatches) == 0
 descMatches = [matchDESC_BEGIN]
 else:
+# In Python 2, stdout expects encoded byte strings, or else it will
+# encode them with the ascii 'codec'
+if sys.version_info.major == 2:
+line = line.encode('utf-8')
+
 print(line, end='')
 
 template.close()
-- 
2.17.1

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


[Mesa-dev] [PATCH 2/2] python: Open the template as text, with an explicit encoding

2018-08-17 Thread Mathieu Bridon
In commit bd27203f4d808763ac24ac94eb677cacf3e7cb99 we changed this to
open in binary mode, to then explicitly decode the lines with the right
encoding.

Unfortunately, that broke the build on Windows, where the template file
can have '\r\n' as line terminators: opening in binary mode would keep
those terminators and break the regexp.

We need to go back to text mode, where the "universal newlines" mode
takes care of this.

However, to fix the initial issue, let's specify the encoding explicitly
when opening the file, and make sure it is open in text mode, so we only
get unicode strings.

Reviewed-by: Jose Fonseca 
---
 src/util/xmlpool/gen_xmlpool.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/util/xmlpool/gen_xmlpool.py b/src/util/xmlpool/gen_xmlpool.py
index 12177dc50f5..b85df234e70 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -9,6 +9,7 @@
 
 from __future__ import print_function
 
+import io
 import sys
 import gettext
 import re
@@ -187,11 +188,9 @@ 
print("/***\
 
 # Process the options template and generate options.h with all
 # translations.
-template = open (template_header_path, "rb")
+template = io.open (template_header_path, mode="rt", encoding='utf-8')
 descMatches = []
 for line in template:
-line = line.decode('utf-8')
-
 if len(descMatches) > 0:
 matchENUM = reENUM.match (line)
 matchDESC_END = reDESC_END.match (line)
-- 
2.17.1

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


[Mesa-dev] Fix the build on Windows

2018-08-17 Thread Mathieu Bridon
This is follow up to my recent patches which made the Python build
scripts compatible with both Python 2 and 3, then moved the Meson build
system to using Python 3 for them.

Unfortunately, one thing I hadn't tested was running them on Windows,
where the changes broke the build.

See the exchange with Jose for the details:

https://lists.freedesktop.org/archives/mesa-dev/2018-August/202847.html

These 2 patches have already been tested by Jose, who confirms they fix
the issue he countered.


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


Re: [Mesa-dev] [PATCH] python: Help Python 2 print the line

2018-08-17 Thread Jose Fonseca

On 17/08/18 15:49, Mathieu Bridon wrote:

On Fri, 2018-08-17 at 15:30 +0100, Jose Fonseca wrote:

On 17/08/18 15:26, Mathieu Bridon wrote:

On Fri, 2018-08-17 at 15:08 +0100, Jose Fonseca wrote:

On 17/08/18 15:06, Jose Fonseca wrote:

On 17/08/18 14:52, Jose Fonseca wrote:

On 17/08/18 14:30, Jose Fonseca wrote:

On 17/08/18 14:22, Mathieu Bridon wrote:

---
Jose, can you test whether this patch fixes your build
issues?

I don't have access to a Windows machine, and I can't
reproduce your
problem on Linux.

src/util/xmlpool/gen_xmlpool.py | 5 +
1 file changed, 5 insertions(+)

diff --git a/src/util/xmlpool/gen_xmlpool.py
b/src/util/xmlpool/gen_xmlpool.py
index 327709c7f8d..12177dc50f5 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -218,6 +218,11 @@ for line in template:
assert len(descMatches) == 0
descMatches = [matchDESC_BEGIN]
else:
+# In Python 2, stdout expects encoded byte
strings,
or else
it will
+# encode them with the ascii 'codec'
+if sys.version_info.major == 2:
+line = line.encode('utf-8')
+
print(line, end='')
template.close()



It fixes the UnicodeEncodeError.  I need to do more testing
to
see if
it fixes all errors.


I think we should fix the print(end ..) statemet.   In
fact, it
might
be easier to have an helper function (e.g., write()
)  which
does the
sys.version check , utf8 encoding, and print, and use it
everywhere
print is used now.


Jose



Unfortunately I still get build failures with your change:

 Compiling src\gallium\auxiliary\pipe-loader\pipe_loader.c
...
pipe_loader.c
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2146: syntax error: missing ';' before identifier
'gettext'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2143: syntax error: missing ')' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2143: syntax error: missing '{' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2059: syntax error: 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2059: syntax error: ')'

whereas if I just revert your
bd27203f4d808763ac24ac94eb677cacf3e7cb99
change these errors go away.

I compared the generated options.h, before/after your change,
and
it
seems the problem is that we're now emitting `gettext(...)`
function
calls which don't exist on Windows:

--- options.h.old   2018-08-17 14:48:09.0 +0100
+++ options.h.new   2018-08-17 14:41:36.0 +0100
@@ -57,101 +57,101 @@
 */
#define DRI_CONF_SECTION_DEBUG \
DRI_CONF_SECTION_BEGIN \
-   DRI_CONF_DESC(en,"Debugging")
+   DRI_CONF_DESC(en,gettext("Debugging"))

#define DRI_CONF_NO_RAST(def) \
DRI_CONF_OPT_BEGIN_B(no_rast, def) \

[...]


Jose



Ok, I have a strong hunch to what's the problem, with your
change
you're
reading the input as bytes

  template = open (template_header_path, "rb")  <=

which means that on Windows the lines will have "\r\n" which
then
causes
all regular expressions to fail (as $ won't match)

And this finally explains why this afeccts some systems but not
others:
it depends on whether git clones t_options.h with CRLF or
LF


The thing is, the old code would do:

template = open (template_header_path, "r")
for line in template:
…

In my testing, with Python 2 the lines **already** end with "\r\n",
so
I don't see how this could have worked before. :-/


That's because you're testing on Linux.  On Linux "b" has no effect.
But on Windows the default is "t" and "b" makes it binary.  That's
why
this worked before.


See 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.python.org%2F2%2Flibrary%2Ffunctions.html%23open&data=02%7C01%7Cjfonseca%40vmware.com%7Ca7bc6963b38b491115e908d60450ac4b%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636701141882257685&sdata=JDdi%2FrNCkD0UyBMKsNQwVF42a0eNp3r6137u%2FJ99YmA%3D&reserved=0
 which says:

   Append 'b' to the mode to open the file in binary mode, on
systems
that differentiate between binary and text files; on systems that
don’t
have this distinction, adding the 'b' has no effect.


Can you try this branch?

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fbochecha%2Fmesa%2Ftree%2Fpython2-windows-scons&data=02%7C01%7Cjfonseca%40vmware.com%7Ca7bc6963b38b491115e908d60450ac4b%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636701141882257685&sdata=wkWAs3fUgfbleKPvygfJdC4kroaaqxbFUZrjkb9G8R0%3D&reserved=0

It should fix the problem.




Yes, it doesn indeed.  And in a much more elegant way.  Change is

  Reviewed-by: Jose Fonseca 

Thanks!

I didn't know about io module -- it seems quite handy for Python 2/3 
migration.


Jose
__

Re: [Mesa-dev] [PATCH] python: Help Python 2 print the line

2018-08-17 Thread Mathieu Bridon
On Fri, 2018-08-17 at 15:30 +0100, Jose Fonseca wrote:
> On 17/08/18 15:26, Mathieu Bridon wrote:
> > On Fri, 2018-08-17 at 15:08 +0100, Jose Fonseca wrote:
> > > On 17/08/18 15:06, Jose Fonseca wrote:
> > > > On 17/08/18 14:52, Jose Fonseca wrote:
> > > > > On 17/08/18 14:30, Jose Fonseca wrote:
> > > > > > On 17/08/18 14:22, Mathieu Bridon wrote:
> > > > > > > ---
> > > > > > > Jose, can you test whether this patch fixes your build
> > > > > > > issues?
> > > > > > > 
> > > > > > > I don't have access to a Windows machine, and I can't
> > > > > > > reproduce your
> > > > > > > problem on Linux.
> > > > > > > 
> > > > > > >src/util/xmlpool/gen_xmlpool.py | 5 +
> > > > > > >1 file changed, 5 insertions(+)
> > > > > > > 
> > > > > > > diff --git a/src/util/xmlpool/gen_xmlpool.py
> > > > > > > b/src/util/xmlpool/gen_xmlpool.py
> > > > > > > index 327709c7f8d..12177dc50f5 100644
> > > > > > > --- a/src/util/xmlpool/gen_xmlpool.py
> > > > > > > +++ b/src/util/xmlpool/gen_xmlpool.py
> > > > > > > @@ -218,6 +218,11 @@ for line in template:
> > > > > > >assert len(descMatches) == 0
> > > > > > >descMatches = [matchDESC_BEGIN]
> > > > > > >else:
> > > > > > > +# In Python 2, stdout expects encoded byte
> > > > > > > strings,
> > > > > > > or else
> > > > > > > it will
> > > > > > > +# encode them with the ascii 'codec'
> > > > > > > +if sys.version_info.major == 2:
> > > > > > > +line = line.encode('utf-8')
> > > > > > > +
> > > > > > >print(line, end='')
> > > > > > >template.close()
> > > > > > > 
> > > > > > 
> > > > > > It fixes the UnicodeEncodeError.  I need to do more testing
> > > > > > to
> > > > > > see if
> > > > > > it fixes all errors.
> > > > > > 
> > > > > > 
> > > > > > I think we should fix the print(end ..) statemet.   In
> > > > > > fact, it
> > > > > > might
> > > > > > be easier to have an helper function (e.g., write()
> > > > > > )  which
> > > > > > does the
> > > > > > sys.version check , utf8 encoding, and print, and use it
> > > > > > everywhere
> > > > > > print is used now.
> > > > > > 
> > > > > > 
> > > > > > Jose
> > > > > 
> > > > > 
> > > > > Unfortunately I still get build failures with your change:
> > > > > 
> > > > > Compiling src\gallium\auxiliary\pipe-loader\pipe_loader.c 
> > > > > ...
> > > > > pipe_loader.c
> > > > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > > > loader\driinfo_gallium.h(2):
> > > > > error C2146: syntax error: missing ';' before identifier
> > > > > 'gettext'
> > > > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > > > loader\driinfo_gallium.h(2):
> > > > > error C2143: syntax error: missing ')' before 'string'
> > > > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > > > loader\driinfo_gallium.h(2):
> > > > > error C2143: syntax error: missing '{' before 'string'
> > > > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > > > loader\driinfo_gallium.h(2):
> > > > > error C2059: syntax error: 'string'
> > > > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > > > loader\driinfo_gallium.h(2):
> > > > > error C2059: syntax error: ')'
> > > > > 
> > > > > whereas if I just revert your
> > > > > bd27203f4d808763ac24ac94eb677cacf3e7cb99
> > > > > change these errors go away.
> > > > > 
> > > > > I compared the generated options.h, before/after your change,
> > > > > and
> > > > > it
> > > > > seems the problem is that we're now emitting `gettext(...)`
> > > > > function
> > > > > calls which don't exist on Windows:
> > > > > 
> > > > > --- options.h.old   2018-08-17 14:48:09.0 +0100
> > > > > +++ options.h.new   2018-08-17 14:41:36.0 +0100
> > > > > @@ -57,101 +57,101 @@
> > > > > */
> > > > >#define DRI_CONF_SECTION_DEBUG \
> > > > >DRI_CONF_SECTION_BEGIN \
> > > > > -   DRI_CONF_DESC(en,"Debugging")
> > > > > +   DRI_CONF_DESC(en,gettext("Debugging"))
> > > > > 
> > > > >#define DRI_CONF_NO_RAST(def) \
> > > > >DRI_CONF_OPT_BEGIN_B(no_rast, def) \
> > > > > 
> > > > > [...]
> > > > > 
> > > > > 
> > > > > Jose
> > > > 
> > > > 
> > > > Ok, I have a strong hunch to what's the problem, with your
> > > > change
> > > > you're
> > > > reading the input as bytes
> > > > 
> > > >  template = open (template_header_path, "rb")  <=
> > > > 
> > > > which means that on Windows the lines will have "\r\n" which
> > > > then
> > > > causes
> > > > all regular expressions to fail (as $ won't match)
> > > > 
> > > > And this finally explains why this afeccts some systems but not
> > > > others:
> > > > it depends on whether git clones t_options.h with CRLF or
> > > > LF
> > 
> > The thing is, the old code would do:
> > 
> >template = open (template_header_path, "r")
> >for line in template:
> >…
> > 
> > In my testing, with Python 2 the lines **already** end with "\r\n",
> > so
> > I don't see how this could ha

Re: [Mesa-dev] [PATCH 3/4] vulkan/wsi: initialise image_index to 0 in x11_manage_fifo_queues

2018-08-17 Thread Bas Nieuwenhuizen
Reviewed-by: Bas Nieuwenhuizen 

for this patch.

On Fri, Aug 17, 2018 at 4:32 PM, Kai Wasserbäch
 wrote:
> Supresses a maybe-uninitialized warning with GCC 8.
>
> Note: image_index should always be initialised due to the result check,
>   but the compiler doesn't see that.
> Signed-off-by: Kai Wasserbäch 
> ---
>  src/vulkan/wsi/wsi_common_x11.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
> index 7e7b3a94e4..7b930884b4 100644
> --- a/src/vulkan/wsi/wsi_common_x11.c
> +++ b/src/vulkan/wsi/wsi_common_x11.c
> @@ -991,7 +991,7 @@ x11_manage_fifo_queues(void *state)
> * before that point so the client should be able to acquire any image
> * other than the currently presented one.
> */
> -  uint32_t image_index;
> +  uint32_t image_index = 0;
>result = wsi_queue_pull(&chain->present_queue, &image_index, 
> INT64_MAX);
>assert(result != VK_TIMEOUT);
>if (result < 0) {
> --
> 2.18.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/4] amd/addrlib: mark returnCode as MAYBE_UNUSED in ElemGetExportNorm

2018-08-17 Thread Kai Wasserbäch
Only used, when asserts are enabled.

Fixes an unused-but-set-variable warning with GCC 8:
 ../../../src/amd/addrlib/addrinterface.cpp: In function 'int 
ElemGetExportNorm(ADDR_HANDLE, const ELEM_GETEXPORTNORM_INPUT*)':
 ../../../src/amd/addrlib/addrinterface.cpp:835:23: warning: variable 
'returnCode' set but not used [-Wunused-but-set-variable]
  ADDR_E_RETURNCODE returnCode = ADDR_OK;
^~

Signed-off-by: Kai Wasserbäch 
---
 src/amd/Makefile.addrlib.am   | 1 +
 src/amd/addrlib/addrinterface.cpp | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/amd/Makefile.addrlib.am b/src/amd/Makefile.addrlib.am
index 75ff7fbcf7..af0daf907d 100644
--- a/src/amd/Makefile.addrlib.am
+++ b/src/amd/Makefile.addrlib.am
@@ -24,6 +24,7 @@ ADDRLIB_LIBS = addrlib/libamdgpu_addrlib.la
 addrlib_libamdgpu_addrlib_la_CPPFLAGS = \
$(DEFINES) \
-I$(top_srcdir)/src/ \
+   -I$(top_srcdir)/include \
-I$(srcdir)/common \
-I$(srcdir)/addrlib \
-I$(srcdir)/addrlib/core \
diff --git a/src/amd/addrlib/addrinterface.cpp 
b/src/amd/addrlib/addrinterface.cpp
index 112431e2cb..9cbeba41d9 100644
--- a/src/amd/addrlib/addrinterface.cpp
+++ b/src/amd/addrlib/addrinterface.cpp
@@ -36,6 +36,8 @@
 
 #include "addrcommon.h"
 
+#include "util/macros.h"
+
 using namespace Addr;
 
 

@@ -832,7 +834,7 @@ BOOL_32 ADDR_API ElemGetExportNorm(
 Addr::Lib* pLib = Lib::GetLib(hLib);
 BOOL_32 enabled = FALSE;
 
-ADDR_E_RETURNCODE returnCode = ADDR_OK;
+MAYBE_UNUSED ADDR_E_RETURNCODE returnCode = ADDR_OK;
 
 if (pLib != NULL)
 {
-- 
2.18.0

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


[Mesa-dev] [PATCH 2/4] nir: mark *prev_block as MAYBE_UNUSED in opt_peel_loop_initial_if

2018-08-17 Thread Kai Wasserbäch
Only used, when asserts are enabled.

Fixes an unused-variable warning with gcc-8:
 ../../../src/compiler/nir/nir_opt_if.c: In function 'opt_peel_loop_initial_if':
 ../../../src/compiler/nir/nir_opt_if.c:109:15: warning: unused variable 
'prev_block' [-Wunused-variable]
 nir_block *prev_block =
^~

Signed-off-by: Kai Wasserbäch 
---
 src/compiler/nir/nir_opt_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
index b3d0bf1dec..dacf2d6c66 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -106,7 +106,7 @@ static bool
 opt_peel_loop_initial_if(nir_loop *loop)
 {
nir_block *header_block = nir_loop_first_block(loop);
-   nir_block *prev_block =
+   MAYBE_UNUSED nir_block *prev_block =
   nir_cf_node_as_block(nir_cf_node_prev(&loop->cf_node));
 
/* It would be insane if this were not true */
-- 
2.18.0

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


[Mesa-dev] [PATCH 1/4] util: mark s as MAYBE_UNUSED in _mesa_half_to_unorm8

2018-08-17 Thread Kai Wasserbäch
Only used, when asserts are enabled.

Fixes an unused-variable warning with gcc-8:
 ../../../src/util/half_float.c: In function '_mesa_half_to_unorm8':
 ../../../src/util/half_float.c:189:14: warning: unused variable 's' 
[-Wunused-variable]
 const int s = (val >> 15) & 0x1;
   ^

Signed-off-by: Kai Wasserbäch 
---
 src/util/half_float.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/half_float.c b/src/util/half_float.c
index 2eff2c84f5..63aec5c5c1 100644
--- a/src/util/half_float.c
+++ b/src/util/half_float.c
@@ -28,6 +28,7 @@
 #include 
 #include "half_float.h"
 #include "rounding.h"
+#include "macros.h"
 
 typedef union { float f; int32_t i; uint32_t u; } fi_type;
 
@@ -186,7 +187,7 @@ uint8_t _mesa_half_to_unorm8(uint16_t val)
 {
const int m = val & 0x3ff;
const int e = (val >> 10) & 0x1f;
-   const int s = (val >> 15) & 0x1;
+   MAYBE_UNUSED const int s = (val >> 15) & 0x1;
 
/* v = round_to_nearest(1.mm * 2^(e-15) * 255)
 *   = round_to_nearest((1.mm * 255) * 2^(e-15))
-- 
2.18.0

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


[Mesa-dev] [PATCH 3/4] vulkan/wsi: initialise image_index to 0 in x11_manage_fifo_queues

2018-08-17 Thread Kai Wasserbäch
Supresses a maybe-uninitialized warning with GCC 8.

Note: image_index should always be initialised due to the result check,
  but the compiler doesn't see that.
Signed-off-by: Kai Wasserbäch 
---
 src/vulkan/wsi/wsi_common_x11.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 7e7b3a94e4..7b930884b4 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -991,7 +991,7 @@ x11_manage_fifo_queues(void *state)
* before that point so the client should be able to acquire any image
* other than the currently presented one.
*/
-  uint32_t image_index;
+  uint32_t image_index = 0;
   result = wsi_queue_pull(&chain->present_queue, &image_index, INT64_MAX);
   assert(result != VK_TIMEOUT);
   if (result < 0) {
-- 
2.18.0

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


[Mesa-dev] [PATCH 0/4] Fix some compile warnings

2018-08-17 Thread Kai Wasserbäch
Hey,
while building Mesa I saw several warnings scroll by and this series
addresses the first four I saw in my build log.

The changes have been compile-tested in a clean chroot (pbuilder)
environment.

If you accept the patches, please apply them for me, as I don't have
commit access for Mesa. The commits can also be found on GitLab
.

Cheers,
Kai


Kai Wasserbäch (4):
  util: mark s as MAYBE_UNUSED in _mesa_half_to_unorm8
  nir: mark *prev_block as MAYBE_UNUSED in opt_peel_loop_initial_if
  vulkan/wsi: initialise image_index to 0 in x11_manage_fifo_queues
  amd/addrlib: mark returnCode as MAYBE_UNUSED in ElemGetExportNorm

 src/amd/Makefile.addrlib.am   | 1 +
 src/amd/addrlib/addrinterface.cpp | 4 +++-
 src/compiler/nir/nir_opt_if.c | 2 +-
 src/util/half_float.c | 3 ++-
 src/vulkan/wsi/wsi_common_x11.c   | 2 +-
 5 files changed, 8 insertions(+), 4 deletions(-)

-- 
2.18.0

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


Re: [Mesa-dev] [PATCH] python: Help Python 2 print the line

2018-08-17 Thread Jose Fonseca

On 17/08/18 15:26, Mathieu Bridon wrote:

On Fri, 2018-08-17 at 15:08 +0100, Jose Fonseca wrote:

On 17/08/18 15:06, Jose Fonseca wrote:

On 17/08/18 14:52, Jose Fonseca wrote:

On 17/08/18 14:30, Jose Fonseca wrote:

On 17/08/18 14:22, Mathieu Bridon wrote:

---
Jose, can you test whether this patch fixes your build
issues?

I don't have access to a Windows machine, and I can't
reproduce your
problem on Linux.

   src/util/xmlpool/gen_xmlpool.py | 5 +
   1 file changed, 5 insertions(+)

diff --git a/src/util/xmlpool/gen_xmlpool.py
b/src/util/xmlpool/gen_xmlpool.py
index 327709c7f8d..12177dc50f5 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -218,6 +218,11 @@ for line in template:
   assert len(descMatches) == 0
   descMatches = [matchDESC_BEGIN]
   else:
+# In Python 2, stdout expects encoded byte strings,
or else
it will
+# encode them with the ascii 'codec'
+if sys.version_info.major == 2:
+line = line.encode('utf-8')
+
   print(line, end='')
   template.close()



It fixes the UnicodeEncodeError.  I need to do more testing to
see if
it fixes all errors.


I think we should fix the print(end ..) statemet.   In fact, it
might
be easier to have an helper function (e.g., write() )  which
does the
sys.version check , utf8 encoding, and print, and use it
everywhere
print is used now.


Jose



Unfortunately I still get build failures with your change:

Compiling src\gallium\auxiliary\pipe-loader\pipe_loader.c ...
pipe_loader.c
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2146: syntax error: missing ';' before identifier
'gettext'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2143: syntax error: missing ')' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2143: syntax error: missing '{' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2059: syntax error: 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
loader\driinfo_gallium.h(2):
error C2059: syntax error: ')'

whereas if I just revert your
bd27203f4d808763ac24ac94eb677cacf3e7cb99
change these errors go away.

I compared the generated options.h, before/after your change, and
it
seems the problem is that we're now emitting `gettext(...)`
function
calls which don't exist on Windows:

--- options.h.old   2018-08-17 14:48:09.0 +0100
+++ options.h.new   2018-08-17 14:41:36.0 +0100
@@ -57,101 +57,101 @@
*/
   #define DRI_CONF_SECTION_DEBUG \
   DRI_CONF_SECTION_BEGIN \
-   DRI_CONF_DESC(en,"Debugging")
+   DRI_CONF_DESC(en,gettext("Debugging"))

   #define DRI_CONF_NO_RAST(def) \
   DRI_CONF_OPT_BEGIN_B(no_rast, def) \

[...]


Jose



Ok, I have a strong hunch to what's the problem, with your change
you're
reading the input as bytes

 template = open (template_header_path, "rb")  <=

which means that on Windows the lines will have "\r\n" which then
causes
all regular expressions to fail (as $ won't match)

And this finally explains why this afeccts some systems but not
others:
it depends on whether git clones t_options.h with CRLF or LF


The thing is, the old code would do:

   template = open (template_header_path, "r")
   for line in template:
   …

In my testing, with Python 2 the lines **already** end with "\r\n", so
I don't see how this could have worked before. :-/


That's because you're testing on Linux.  On Linux "b" has no effect. 
But on Windows the default is "t" and "b" makes it binary.  That's why 
this worked before.



See https://docs.python.org/2/library/functions.html#open which says:

 Append 'b' to the mode to open the file in binary mode, on systems 
that differentiate between binary and text files; on systems that don’t 
have this distinction, adding the 'b' has no effect.



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


Re: [Mesa-dev] [PATCH] python: Help Python 2 print the line

2018-08-17 Thread Mathieu Bridon
On Fri, 2018-08-17 at 15:08 +0100, Jose Fonseca wrote:
> On 17/08/18 15:06, Jose Fonseca wrote:
> > On 17/08/18 14:52, Jose Fonseca wrote:
> > > On 17/08/18 14:30, Jose Fonseca wrote:
> > > > On 17/08/18 14:22, Mathieu Bridon wrote:
> > > > > ---
> > > > > Jose, can you test whether this patch fixes your build
> > > > > issues?
> > > > > 
> > > > > I don't have access to a Windows machine, and I can't
> > > > > reproduce your
> > > > > problem on Linux.
> > > > > 
> > > > >   src/util/xmlpool/gen_xmlpool.py | 5 +
> > > > >   1 file changed, 5 insertions(+)
> > > > > 
> > > > > diff --git a/src/util/xmlpool/gen_xmlpool.py 
> > > > > b/src/util/xmlpool/gen_xmlpool.py
> > > > > index 327709c7f8d..12177dc50f5 100644
> > > > > --- a/src/util/xmlpool/gen_xmlpool.py
> > > > > +++ b/src/util/xmlpool/gen_xmlpool.py
> > > > > @@ -218,6 +218,11 @@ for line in template:
> > > > >   assert len(descMatches) == 0
> > > > >   descMatches = [matchDESC_BEGIN]
> > > > >   else:
> > > > > +# In Python 2, stdout expects encoded byte strings,
> > > > > or else 
> > > > > it will
> > > > > +# encode them with the ascii 'codec'
> > > > > +if sys.version_info.major == 2:
> > > > > +line = line.encode('utf-8')
> > > > > +
> > > > >   print(line, end='')
> > > > >   template.close()
> > > > > 
> > > > 
> > > > It fixes the UnicodeEncodeError.  I need to do more testing to
> > > > see if 
> > > > it fixes all errors.
> > > > 
> > > > 
> > > > I think we should fix the print(end ..) statemet.   In fact, it
> > > > might 
> > > > be easier to have an helper function (e.g., write() )  which
> > > > does the 
> > > > sys.version check , utf8 encoding, and print, and use it
> > > > everywhere 
> > > > print is used now.
> > > > 
> > > > 
> > > > Jose
> > > 
> > > 
> > > Unfortunately I still get build failures with your change:
> > > 
> > >Compiling src\gallium\auxiliary\pipe-loader\pipe_loader.c ...
> > > pipe_loader.c
> > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > loader\driinfo_gallium.h(2): 
> > > error C2146: syntax error: missing ';' before identifier
> > > 'gettext'
> > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > loader\driinfo_gallium.h(2): 
> > > error C2143: syntax error: missing ')' before 'string'
> > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > loader\driinfo_gallium.h(2): 
> > > error C2143: syntax error: missing '{' before 'string'
> > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > loader\driinfo_gallium.h(2): 
> > > error C2059: syntax error: 'string'
> > > c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-
> > > loader\driinfo_gallium.h(2): 
> > > error C2059: syntax error: ')'
> > > 
> > > whereas if I just revert your
> > > bd27203f4d808763ac24ac94eb677cacf3e7cb99 
> > > change these errors go away.
> > > 
> > > I compared the generated options.h, before/after your change, and
> > > it 
> > > seems the problem is that we're now emitting `gettext(...)`
> > > function 
> > > calls which don't exist on Windows:
> > > 
> > > --- options.h.old   2018-08-17 14:48:09.0 +0100
> > > +++ options.h.new   2018-08-17 14:41:36.0 +0100
> > > @@ -57,101 +57,101 @@
> > >*/
> > >   #define DRI_CONF_SECTION_DEBUG \
> > >   DRI_CONF_SECTION_BEGIN \
> > > -   DRI_CONF_DESC(en,"Debugging")
> > > +   DRI_CONF_DESC(en,gettext("Debugging"))
> > > 
> > >   #define DRI_CONF_NO_RAST(def) \
> > >   DRI_CONF_OPT_BEGIN_B(no_rast, def) \
> > > 
> > > [...]
> > > 
> > > 
> > > Jose
> > 
> > 
> > Ok, I have a strong hunch to what's the problem, with your change
> > you're 
> > reading the input as bytes
> > 
> > template = open (template_header_path, "rb")  <=
> > 
> > which means that on Windows the lines will have "\r\n" which then
> > causes 
> > all regular expressions to fail (as $ won't match)
> > 
> > And this finally explains why this afeccts some systems but not
> > others: 
> > it depends on whether git clones t_options.h with CRLF or LF

The thing is, the old code would do:

  template = open (template_header_path, "r")
  for line in template:
  …

In my testing, with Python 2 the lines **already** end with "\r\n", so
I don't see how this could have worked before. :-/


-- 
Mathieu


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


Re: [Mesa-dev] [PATCH 08/13] radeon/uvd: remove get mjpeg slice header

2018-08-17 Thread Leo Liu

These 3 patches are:

Reviewed-by: Leo Liu 


On 2018-08-16 04:56 PM, boyuan.zh...@amd.com wrote:

From: Boyuan Zhang 

Move the previous get_mjpeg_slice_heaeder function and eoi from
"radeon/vcn" to "st/va".

Signed-off-by: Boyuan Zhang 
---
  src/gallium/drivers/radeon/radeon_uvd.c | 147 
  1 file changed, 147 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_uvd.c 
b/src/gallium/drivers/radeon/radeon_uvd.c
index 78ced17..bff48ad 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -965,139 +965,6 @@ static struct ruvd_mpeg4 get_mpeg4_msg(struct 
ruvd_decoder *dec,
return result;
  }
  
-static void get_mjpeg_slice_header(struct ruvd_decoder *dec, struct pipe_mjpeg_picture_desc *pic)

-{
-   int size = 0, saved_size, len_pos, i;
-   uint16_t *bs;
-   uint8_t *buf = dec->bs_ptr;
-
-   /* SOI */
-   buf[size++] = 0xff;
-   buf[size++] = 0xd8;
-
-   /* DQT */
-   buf[size++] = 0xff;
-   buf[size++] = 0xdb;
-
-   len_pos = size++;
-   size++;
-
-   for (i = 0; i < 4; ++i) {
-   if (pic->quantization_table.load_quantiser_table[i] == 0)
-   continue;
-
-   buf[size++] = i;
-   memcpy((buf + size), 
&pic->quantization_table.quantiser_table[i], 64);
-   size += 64;
-   }
-
-   bs = (uint16_t*)&buf[len_pos];
-   *bs = util_bswap16(size - 4);
-
-   saved_size = size;
-
-   /* DHT */
-   buf[size++] = 0xff;
-   buf[size++] = 0xc4;
-
-   len_pos = size++;
-   size++;
-
-   for (i = 0; i < 2; ++i) {
-   if (pic->huffman_table.load_huffman_table[i] == 0)
-   continue;
-
-   buf[size++] = 0x00 | i;
-   memcpy((buf + size), &pic->huffman_table.table[i].num_dc_codes, 
16);
-   size += 16;
-   memcpy((buf + size), &pic->huffman_table.table[i].dc_values, 
12);
-   size += 12;
-   }
-
-   for (i = 0; i < 2; ++i) {
-   if (pic->huffman_table.load_huffman_table[i] == 0)
-   continue;
-
-   buf[size++] = 0x10 | i;
-   memcpy((buf + size), &pic->huffman_table.table[i].num_ac_codes, 
16);
-   size += 16;
-   memcpy((buf + size), &pic->huffman_table.table[i].ac_values, 
162);
-   size += 162;
-   }
-
-   bs = (uint16_t*)&buf[len_pos];
-   *bs = util_bswap16(size - saved_size - 2);
-
-   saved_size = size;
-
-   /* DRI */
-   if (pic->slice_parameter.restart_interval) {
-   buf[size++] = 0xff;
-   buf[size++] = 0xdd;
-   buf[size++] = 0x00;
-   buf[size++] = 0x04;
-   bs = (uint16_t*)&buf[size++];
-   *bs = util_bswap16(pic->slice_parameter.restart_interval);
-   saved_size = ++size;
-   }
-
-   /* SOF */
-   buf[size++] = 0xff;
-   buf[size++] = 0xc0;
-
-   len_pos = size++;
-   size++;
-
-   buf[size++] = 0x08;
-
-   bs = (uint16_t*)&buf[size++];
-   *bs = util_bswap16(pic->picture_parameter.picture_height);
-   size++;
-
-   bs = (uint16_t*)&buf[size++];
-   *bs = util_bswap16(pic->picture_parameter.picture_width);
-   size++;
-
-   buf[size++] = pic->picture_parameter.num_components;
-
-   for (i = 0; i < pic->picture_parameter.num_components; ++i) {
-   buf[size++] = pic->picture_parameter.components[i].component_id;
-   buf[size++] = pic->picture_parameter.components[i].h_sampling_factor 
<< 4 |
-   pic->picture_parameter.components[i].v_sampling_factor;
-   buf[size++] = 
pic->picture_parameter.components[i].quantiser_table_selector;
-   }
-
-   bs = (uint16_t*)&buf[len_pos];
-   *bs = util_bswap16(size - saved_size - 2);
-
-   saved_size = size;
-
-   /* SOS */
-   buf[size++] = 0xff;
-   buf[size++] = 0xda;
-
-   len_pos = size++;
-   size++;
-
-   buf[size++] = pic->slice_parameter.num_components;
-
-   for (i = 0; i < pic->slice_parameter.num_components; ++i) {
-   buf[size++] = 
pic->slice_parameter.components[i].component_selector;
-   buf[size++] = pic->slice_parameter.components[i].dc_table_selector 
<< 4 |
-   pic->slice_parameter.components[i].ac_table_selector;
-   }
-
-   buf[size++] = 0x00;
-   buf[size++] = 0x3f;
-   buf[size++] = 0x00;
-
-   bs = (uint16_t*)&buf[len_pos];
-   *bs = util_bswap16(size - saved_size - 2);
-
-   dec->bs_ptr += size;
-   dec->bs_size += size;
-}
-
  /**
   * destroy this video decoder
   */
@@ -1176,7 +1043,6 @@ static void ruvd_decode_bitstream(struct pipe_video_codec 
*decoder,
  const unsigned *sizes)
  {
struct ruvd_decoder *dec = (struct ruvd_decoder*)decoder;

Re: [Mesa-dev] [PATCH] python: Help Python 2 print the line

2018-08-17 Thread Jose Fonseca

On 17/08/18 15:06, Jose Fonseca wrote:

On 17/08/18 14:52, Jose Fonseca wrote:

On 17/08/18 14:30, Jose Fonseca wrote:

On 17/08/18 14:22, Mathieu Bridon wrote:

---
Jose, can you test whether this patch fixes your build issues?

I don't have access to a Windows machine, and I can't reproduce your
problem on Linux.

  src/util/xmlpool/gen_xmlpool.py | 5 +
  1 file changed, 5 insertions(+)

diff --git a/src/util/xmlpool/gen_xmlpool.py 
b/src/util/xmlpool/gen_xmlpool.py

index 327709c7f8d..12177dc50f5 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -218,6 +218,11 @@ for line in template:
  assert len(descMatches) == 0
  descMatches = [matchDESC_BEGIN]
  else:
+    # In Python 2, stdout expects encoded byte strings, or else 
it will

+    # encode them with the ascii 'codec'
+    if sys.version_info.major == 2:
+    line = line.encode('utf-8')
+
  print(line, end='')
  template.close()



It fixes the UnicodeEncodeError.  I need to do more testing to see if 
it fixes all errors.



I think we should fix the print(end ..) statemet.   In fact, it might 
be easier to have an helper function (e.g., write() )  which does the 
sys.version check , utf8 encoding, and print, and use it everywhere 
print is used now.



Jose



Unfortunately I still get build failures with your change:

   Compiling src\gallium\auxiliary\pipe-loader\pipe_loader.c ...
pipe_loader.c
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2146: syntax error: missing ';' before identifier 'gettext'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2143: syntax error: missing ')' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2143: syntax error: missing '{' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2059: syntax error: 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2059: syntax error: ')'


whereas if I just revert your bd27203f4d808763ac24ac94eb677cacf3e7cb99 
change these errors go away.


I compared the generated options.h, before/after your change, and it 
seems the problem is that we're now emitting `gettext(...)` function 
calls which don't exist on Windows:


--- options.h.old   2018-08-17 14:48:09.0 +0100
+++ options.h.new   2018-08-17 14:41:36.0 +0100
@@ -57,101 +57,101 @@
   */
  #define DRI_CONF_SECTION_DEBUG \
  DRI_CONF_SECTION_BEGIN \
-   DRI_CONF_DESC(en,"Debugging")
+   DRI_CONF_DESC(en,gettext("Debugging"))

  #define DRI_CONF_NO_RAST(def) \
  DRI_CONF_OPT_BEGIN_B(no_rast, def) \

[...]


Jose



Ok, I have a strong hunch to what's the problem, with your change you're 
reading the input as bytes


    template = open (template_header_path, "rb")  <=

which means that on Windows the lines will have "\r\n" which then causes 
all regular expressions to fail (as $ won't match)


And this finally explains why this afeccts some systems but not others: 
it depends on whether git clones t_options.h with CRLF or LF


*ufh*

I'm not sure what's the best way to deal with this.  I think reading 
text as binary is not a great idea.


I think we should do

   if PYTHON_3:
  f = open ("rt", encoding='UTF-8')
   else:
  f = open("rt")

   for line  in f:
  if PYTHON_2:
     line = line.decode('UTF-8')





Jose




One last comment, it's trivial for you to reproduce this.  Just convert 
t_options.h to DOS line endings


   $ apt-get install tofrodos
   $ todos src/util/xmlpool/t_options.h
   $ python2 src/util/xmlpool/gen_xmlpool.py 
src/util/xmlpool/t_options.h src/util/xmlpool


and you'll start seeing all gettext() comming out.

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


Re: [Mesa-dev] [PATCH] python: Help Python 2 print the line

2018-08-17 Thread Jose Fonseca

On 17/08/18 14:52, Jose Fonseca wrote:

On 17/08/18 14:30, Jose Fonseca wrote:

On 17/08/18 14:22, Mathieu Bridon wrote:

---
Jose, can you test whether this patch fixes your build issues?

I don't have access to a Windows machine, and I can't reproduce your
problem on Linux.

  src/util/xmlpool/gen_xmlpool.py | 5 +
  1 file changed, 5 insertions(+)

diff --git a/src/util/xmlpool/gen_xmlpool.py 
b/src/util/xmlpool/gen_xmlpool.py

index 327709c7f8d..12177dc50f5 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -218,6 +218,11 @@ for line in template:
  assert len(descMatches) == 0
  descMatches = [matchDESC_BEGIN]
  else:
+    # In Python 2, stdout expects encoded byte strings, or else 
it will

+    # encode them with the ascii 'codec'
+    if sys.version_info.major == 2:
+    line = line.encode('utf-8')
+
  print(line, end='')
  template.close()



It fixes the UnicodeEncodeError.  I need to do more testing to see if 
it fixes all errors.



I think we should fix the print(end ..) statemet.   In fact, it might 
be easier to have an helper function (e.g., write() )  which does the 
sys.version check , utf8 encoding, and print, and use it everywhere 
print is used now.



Jose



Unfortunately I still get build failures with your change:

   Compiling src\gallium\auxiliary\pipe-loader\pipe_loader.c ...
pipe_loader.c
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2146: syntax error: missing ';' before identifier 'gettext'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2143: syntax error: missing ')' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2143: syntax error: missing '{' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2059: syntax error: 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2059: syntax error: ')'


whereas if I just revert your bd27203f4d808763ac24ac94eb677cacf3e7cb99 
change these errors go away.


I compared the generated options.h, before/after your change, and it 
seems the problem is that we're now emitting `gettext(...)` function 
calls which don't exist on Windows:


--- options.h.old   2018-08-17 14:48:09.0 +0100
+++ options.h.new   2018-08-17 14:41:36.0 +0100
@@ -57,101 +57,101 @@
   */
  #define DRI_CONF_SECTION_DEBUG \
  DRI_CONF_SECTION_BEGIN \
-   DRI_CONF_DESC(en,"Debugging")
+   DRI_CONF_DESC(en,gettext("Debugging"))

  #define DRI_CONF_NO_RAST(def) \
  DRI_CONF_OPT_BEGIN_B(no_rast, def) \

[...]


Jose



Ok, I have a strong hunch to what's the problem, with your change you're 
reading the input as bytes


   template = open (template_header_path, "rb")  <=

which means that on Windows the lines will have "\r\n" which then causes 
all regular expressions to fail (as $ won't match)


And this finally explains why this afeccts some systems but not others: 
it depends on whether git clones t_options.h with CRLF or LF


*ufh*

I'm not sure what's the best way to deal with this.  I think reading 
text as binary is not a great idea.


I think we should do

  if PYTHON_3:
 f = open ("rt", encoding='UTF-8')
  else:
 f = open("rt")

  for line  in f:
 if PYTHON_2:
line = line.decode('UTF-8')





Jose


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


Re: [Mesa-dev] [PATCH] python: Help Python 2 print the line

2018-08-17 Thread Jose Fonseca

On 17/08/18 14:30, Jose Fonseca wrote:

On 17/08/18 14:22, Mathieu Bridon wrote:

---
Jose, can you test whether this patch fixes your build issues?

I don't have access to a Windows machine, and I can't reproduce your
problem on Linux.

  src/util/xmlpool/gen_xmlpool.py | 5 +
  1 file changed, 5 insertions(+)

diff --git a/src/util/xmlpool/gen_xmlpool.py 
b/src/util/xmlpool/gen_xmlpool.py

index 327709c7f8d..12177dc50f5 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -218,6 +218,11 @@ for line in template:
  assert len(descMatches) == 0
  descMatches = [matchDESC_BEGIN]
  else:
+    # In Python 2, stdout expects encoded byte strings, or else 
it will

+    # encode them with the ascii 'codec'
+    if sys.version_info.major == 2:
+    line = line.encode('utf-8')
+
  print(line, end='')
  template.close()



It fixes the UnicodeEncodeError.  I need to do more testing to see if it 
fixes all errors.



I think we should fix the print(end ..) statemet.   In fact, it might be 
easier to have an helper function (e.g., write() )  which does the 
sys.version check , utf8 encoding, and print, and use it everywhere 
print is used now.



Jose



Unfortunately I still get build failures with your change:

  Compiling src\gallium\auxiliary\pipe-loader\pipe_loader.c ...
pipe_loader.c
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2146: syntax error: missing ';' before identifier 'gettext'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2143: syntax error: missing ')' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2143: syntax error: missing '{' before 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2059: syntax error: 'string'
c:\hudson\workspace\mesa-msvc\src\gallium\auxiliary\pipe-loader\driinfo_gallium.h(2): 
error C2059: syntax error: ')'


whereas if I just revert your bd27203f4d808763ac24ac94eb677cacf3e7cb99 
change these errors go away.


I compared the generated options.h, before/after your change, and it 
seems the problem is that we're now emitting `gettext(...)` function 
calls which don't exist on Windows:


--- options.h.old   2018-08-17 14:48:09.0 +0100
+++ options.h.new   2018-08-17 14:41:36.0 +0100
@@ -57,101 +57,101 @@
  */
 #define DRI_CONF_SECTION_DEBUG \
 DRI_CONF_SECTION_BEGIN \
-   DRI_CONF_DESC(en,"Debugging")
+   DRI_CONF_DESC(en,gettext("Debugging"))

 #define DRI_CONF_NO_RAST(def) \
 DRI_CONF_OPT_BEGIN_B(no_rast, def) \

[...]


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


  1   2   >