Re: [Mesa-dev] [PATCH 2/2] i965: fix unused var warnings in release build

2017-10-24 Thread Jordan Justen
On 2017-10-24 21:15:45, Matt Turner wrote:
> I would suggest just marking the devinfo variables as UNUSED.

Or, MAYBE_UNUSED? :)

I considered that suggestion, since you recently suggested it to me. I
noticed that in all but one case the local variable was only
referenced 1 time, by the assert. There was one case where two asserts
used the variable. Therefore, removing the variable seemed reasonable.

Tim, You can keep my r-b if you decide to make use of *UNUSED.

> I really wish we didn't have to deal with this triviality :(

It does seem like someone would have a trick. I'm guessing they've all
been ruled out, such as: https://stackoverflow.com/a/985807

gcc probably will have figured out that the variable is not actually
read, so consider it unreferenced. :)

Or, maybe that trick would still cause a potential call to something
with side effects? (Which would probably be a bug anyway.)

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


Re: [Mesa-dev] [PATCH 2/2] i965: fix unused var warnings in release build

2017-10-24 Thread Matt Turner
I would suggest just marking the devinfo variables as UNUSED.

I really wish we didn't have to deal with this triviality :(
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 8/8] glsl/linker: validate explicit locations for SSO programs

2017-10-24 Thread Ilia Mirkin
For all the patches in the series that I didn't have comments on,

Reviewed-by: Ilia Mirkin 

On Tue, Oct 24, 2017 at 5:28 AM, Iago Toral Quiroga  wrote:
> v2:
> - we only need to validate inputs to the first stage and outputs
>   from the last stage, everything else has already been validated
>   during cross_validate_outputs_to_inputs (Timothy).
> - Use MAX_VARYING instead of MAX_VARYINGS_INCL_PATCH (Illia)
> ---
>  src/compiler/glsl/link_varyings.cpp | 55 
> +
>  src/compiler/glsl/link_varyings.h   |  6 
>  src/compiler/glsl/linker.cpp| 10 +++
>  3 files changed, 71 insertions(+)
>
> diff --git a/src/compiler/glsl/link_varyings.cpp 
> b/src/compiler/glsl/link_varyings.cpp
> index 02a48f7199..e80736fb38 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -600,6 +600,61 @@ validate_explicit_variable_location(struct gl_context 
> *ctx,
>  }
>
>  /**
> + * Validate explicit locations for the inputs to the first stage and the
> + * outputs of the last stage in an SSO program (everything in between is
> + * validated in cross_validate_outputs_to_inputs).
> + */
> +void
> +validate_sso_explicit_locations(struct gl_context *ctx,
> +struct gl_shader_program *prog,
> +gl_shader_stage first_stage,
> +gl_shader_stage last_stage)
> +{
> +   assert(prog->SeparateShader);
> +
> +   /* VS inputs and FS outputs are validated in
> +* assign_attribute_or_color_locations()
> +*/
> +   bool validate_first_stage = first_stage != MESA_SHADER_VERTEX;
> +   bool validate_last_stage = last_stage != MESA_SHADER_FRAGMENT;
> +   if (!validate_first_stage && !validate_last_stage)
> +  return;
> +
> +   struct explicit_location_info explicit_locations[MAX_VARYING][4];
> +
> +   gl_shader_stage stages[2] = { first_stage, last_stage };
> +   bool validate_stage[2] = { validate_first_stage, validate_last_stage };
> +   ir_variable_mode var_direction[2] = { ir_var_shader_in, ir_var_shader_out 
> };
> +
> +   for (unsigned i = 0; i < 2; i++) {
> +  if (!validate_stage[i])
> + continue;
> +
> +  gl_shader_stage stage = stages[i];
> +
> +  gl_linked_shader *sh = prog->_LinkedShaders[stage];
> +  assert(sh);
> +
> +  memset(explicit_locations, 0, sizeof(explicit_locations));
> +
> +  foreach_in_list(ir_instruction, node, sh->ir) {
> + ir_variable *const var = node->as_variable();
> +
> + if (var == NULL ||
> + !var->data.explicit_location ||
> + var->data.location < VARYING_SLOT_VAR0 ||
> + var->data.mode != var_direction[i])
> +continue;
> +
> + if (!validate_explicit_variable_location(
> +   ctx, explicit_locations, var, prog, sh)) {
> +return;
> + }
> +  }
> +   }
> +}
> +
> +/**
>   * Validate that outputs from one stage match inputs of another
>   */
>  void
> diff --git a/src/compiler/glsl/link_varyings.h 
> b/src/compiler/glsl/link_varyings.h
> index 081b04ea38..e052a2b3e5 100644
> --- a/src/compiler/glsl/link_varyings.h
> +++ b/src/compiler/glsl/link_varyings.h
> @@ -300,6 +300,12 @@ link_varyings(struct gl_shader_program *prog, unsigned 
> first, unsigned last,
>struct gl_context *ctx, void *mem_ctx);
>
>  void
> +validate_sso_explicit_locations(struct gl_context *ctx,
> +struct gl_shader_program *prog,
> +gl_shader_stage first,
> +gl_shader_stage last);
> +
> +void
>  cross_validate_outputs_to_inputs(struct gl_context *ctx,
>   struct gl_shader_program *prog,
>   gl_linked_shader *producer,
> diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
> index 3798309678..8c610df9bf 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -4938,6 +4938,16 @@ link_shaders(struct gl_context *ctx, struct 
> gl_shader_program *prog)
>prev = i;
> }
>
> +   /* The cross validation of outputs/inputs above validates explicit 
> locations
> +* but for SSO programs we need to do this also for the inputs in the
> +* first stage and outputs of the last stage included in the program, 
> since
> +* there is no cross validation for these.
> +*/
> +   if (prog->SeparateShader)
> +  validate_sso_explicit_locations(ctx, prog,
> +  (gl_shader_stage) first,
> +  (gl_shader_stage) last);
> +
> /* Cross-validate uniform blocks between shader stages */
> validate_interstage_uniform_blocks(prog, prog->_LinkedShaders);
> if (!prog->data->LinkStatus)
> --
> 2.11.0
>
___
mesa-dev mailing list

Re: [Mesa-dev] [PATCH v2 4/8] glsl/linker: outputs in the same location must share interpolation

2017-10-24 Thread Ilia Mirkin
On Tue, Oct 24, 2017 at 5:28 AM, Iago Toral Quiroga  wrote:
> From ARB_enhanced_layouts:
>
> "[...]when location aliasing, the aliases sharing the location
>  must have the same underlying numerical type (floating-point or
>  integer) and the same auxiliary storage and
>  interpolation qualification.[...]"
>
> Add code to the linker to validate that aliased locations do
> have the same interpolation.
>
> Fixes:
> KHR-GL45.enhanced_layouts.varying_location_aliasing_with_mixed_interpolation
>
> Reviewed-by: Timothy Arceri 
> ---
>  src/compiler/glsl/link_varyings.cpp | 45 
> +
>  1 file changed, 41 insertions(+), 4 deletions(-)
>
> diff --git a/src/compiler/glsl/link_varyings.cpp 
> b/src/compiler/glsl/link_varyings.cpp
> index 1db851b7e9..9542754600 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -406,6 +406,7 @@ compute_variable_location_slot(ir_variable *var, 
> gl_shader_stage stage)
>  struct explicit_location_info {
> ir_variable *var;
> unsigned base_type;
> +   unsigned interpolation;
>  };
>
>  static bool
> @@ -415,6 +416,7 @@ check_location_aliasing(struct explicit_location_info 
> explicit_locations[][4],
>  unsigned component,
>  unsigned location_limit,
>  const glsl_type *type,
> +unsigned interpolation,
>  gl_shader_program *prog,
>  gl_shader_stage stage)
>  {
> @@ -431,6 +433,38 @@ check_location_aliasing(struct explicit_location_info 
> explicit_locations[][4],
>
> while (location < location_limit) {
>unsigned i = component;
> +
> +  /* If there are other outputs assigned to the same location
> +   * they must have the same interpolation
> +   */
> +  unsigned comp = 0;
> +  while (comp < 4) {
> + /* Skip the components used by this output, we only care about
> + * other outputs in the same location

IMHO this should get combined with the type compatibility check --
it's doing fundamentally the same thing.

> +  */
> + if (comp == i) {
> +comp = last_comp;
> +continue;
> + }
> +
> + struct explicit_location_info *info =
> +_locations[location][comp];
> +
> + if (info->var) {
> +if (info->interpolation != interpolation) {
> +   linker_error(prog,
> +"%s shader has multiple outputs at explicit "
> +"location %u with different interpolation "
> +"settings\n",
> +_mesa_shader_stage_to_string(stage), location);
> +   return false;
> +}
> + }
> +
> + comp++;
> +  }
> +
> +  /* Component aliasing is not allowed */
>while (i < last_comp) {
>   if (explicit_locations[location][i].var != NULL) {
>  linker_error(prog,
> @@ -458,6 +492,7 @@ check_location_aliasing(struct explicit_location_info 
> explicit_locations[][4],
>   explicit_locations[location][i].var = var;
>   explicit_locations[location][i].base_type =
>  type->without_array()->base_type;
> + explicit_locations[location][i].interpolation = interpolation;
>   i++;
>
>   /* We need to do some special handling for doubles as dvec3 and
> @@ -526,18 +561,20 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
> unsigned field_location = type->fields.structure[i].location -
>(type->fields.structure[i].patch ? VARYING_SLOT_PATCH0 :
>   VARYING_SLOT_VAR0);
> +   unsigned interpolation = 
> type->fields.structure[i].interpolation;
> if (!check_location_aliasing(explicit_locations, var,
>  field_location,
>  0, field_location + 1,
> -field_type, prog,
> -producer->Stage)) {
> +field_type, interpolation,
> +prog, producer->Stage)) {
>return;
> }
>  }
>   } else if (!check_location_aliasing(explicit_locations, var,
>   idx, var->data.location_frac,
> - slot_limit, type, prog,
> - producer->Stage)) {
> + slot_limit, type,
> + var->data.interpolation,
> + prog, producer->Stage)) {
>  

Re: [Mesa-dev] [PATCH v2 2/8] glsl/linker: refactor link-time validation of output locations

2017-10-24 Thread Ilia Mirkin
On Tue, Oct 24, 2017 at 5:28 AM, Iago Toral Quiroga  wrote:
> Move the checks for explicit locations to a separate function. We
> will use this in a follow-up patch to validate locations for interface
> variables where we need to validate each interface member rather than
> the interface variable itself.
>
> Reviewed-by: Timothy Arceri 
> ---
>  src/compiler/glsl/link_varyings.cpp | 128 
> 
>  1 file changed, 73 insertions(+), 55 deletions(-)
>
> diff --git a/src/compiler/glsl/link_varyings.cpp 
> b/src/compiler/glsl/link_varyings.cpp
> index cb9091d86b..d394488ab9 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -403,6 +403,75 @@ compute_variable_location_slot(ir_variable *var, 
> gl_shader_stage stage)
> return var->data.location - location_start;
>  }
>
> +static bool
> +check_location_aliasing(ir_variable *explicit_locations[][4],

It's also checking component aliasing. Maybe just check_aliasing() ?

> +ir_variable *var,
> +unsigned location,
> +unsigned component,
> +unsigned location_limit,
> +const glsl_type *type,
> +gl_shader_program *prog,
> +gl_shader_stage stage)
> +{
> +   unsigned last_comp;
> +   if (type->without_array()->is_record()) {
> +  /* The component qualifier can't be used on structs so just treat
> +   * all component slots as used.
> +   */
> +  last_comp = 4;
> +   } else {
> +  unsigned dmul = type->without_array()->is_64bit() ? 2 : 1;
> +  last_comp = component + type->without_array()->vector_elements * dmul;
> +   }
> +
> +   while (location < location_limit) {
> +  unsigned i = component;
> +  while (i < last_comp) {
> + if (explicit_locations[location][i] != NULL) {
> +linker_error(prog,
> + "%s shader has multiple outputs explicitly "
> + "assigned to location %d and component %d\n",
> + _mesa_shader_stage_to_string(stage),
> + location, component);
> +return false;
> + }
> +
> + /* Make sure all component at this location have the same type.
> +  */
> + for (unsigned j = 0; j < 4; j++) {
> +if (explicit_locations[location][j] &&
> +(explicit_locations[location][j]->type->without_array()
> + ->base_type != type->without_array()->base_type)) {

I believe this is too strict. e.g. one is allowed to have int and uint
be shared in the same slot, even though they'll have different base
types.

Also you appear to be doing this for each and every variable, which is
inefficient. This check should just be done once at the end. (Perhaps
there's a later patch which fixes these concerns. If that's the case,
then this one is fine as it's just moving code around.)

> +   linker_error(prog,
> +"Varyings sharing the same location must "
> +"have the same underlying numerical type. "
> +"Location %u component %u\n", location, 
> component);
> +   return false;
> +}
> + }
> +
> + explicit_locations[location][i] = var;
> + i++;
> +
> + /* We need to do some special handling for doubles as dvec3 and
> +  * dvec4 consume two consecutive locations. We don't need to
> +  * worry about components beginning at anything other than 0 as
> +  * the spec does not allow this for dvec3 and dvec4.
> +  */
> + if (i == 4 && last_comp > 4) {
> +last_comp = last_comp - 4;
> +/* Bump location index and reset the component index */
> +location++;
> +i = 0;
> + }
> +  }
> +
> +  location++;
> +   }
> +
> +   return true;
> +}
> +
>  /**
>   * Validate that outputs from one stage match inputs of another
>   */
> @@ -435,7 +504,6 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
>   unsigned num_elements = type->count_attribute_slots(false);
>   unsigned idx = compute_variable_location_slot(var, producer->Stage);
>   unsigned slot_limit = idx + num_elements;
> - unsigned last_comp;
>
>   unsigned slot_max =
>  ctx->Const.Program[producer->Stage].MaxOutputComponents / 4;
> @@ -446,60 +514,10 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
>  return;
>   }
>
> - if (type->without_array()->is_record()) {
> -/* The component qualifier can't be used on structs so just treat
> - * all component slots as used.
> - */
> -last_comp = 4;
> - } else {
> -unsigned dmul = 

Re: [Mesa-dev] [PATCH 2/2] i965: fix unused var warnings in release build

2017-10-24 Thread Jordan Justen
Reviewed-by: Jordan Justen 

On 2017-10-22 18:26:12, Timothy Arceri wrote:
> ---
>  src/mesa/drivers/dri/i965/gen6_sol.c   |  3 +--
>  src/mesa/drivers/dri/i965/gen7_sol_state.c |  9 +++--
>  src/mesa/drivers/dri/i965/intel_batchbuffer.c  | 16 
>  src/mesa/drivers/dri/i965/intel_blit.c |  4 +---
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c  | 10 +++---
>  src/mesa/drivers/dri/i965/intel_tex_validate.c |  3 +--
>  6 files changed, 13 insertions(+), 32 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c 
> b/src/mesa/drivers/dri/i965/gen6_sol.c
> index 53e4fd1c144..7a510940c8e 100644
> --- a/src/mesa/drivers/dri/i965/gen6_sol.c
> +++ b/src/mesa/drivers/dri/i965/gen6_sol.c
> @@ -386,7 +386,6 @@ brw_begin_transform_feedback(struct gl_context *ctx, 
> GLenum mode,
>  struct gl_transform_feedback_object *obj)
>  {
> struct brw_context *brw = brw_context(ctx);
> -   const struct gen_device_info *devinfo = >screen->devinfo;
> const struct gl_program *prog;
> const struct gl_transform_feedback_info *linked_xfb_info;
> struct gl_transform_feedback_object *xfb_obj =
> @@ -394,7 +393,7 @@ brw_begin_transform_feedback(struct gl_context *ctx, 
> GLenum mode,
> struct brw_transform_feedback_object *brw_obj =
>(struct brw_transform_feedback_object *) xfb_obj;
>  
> -   assert(devinfo->gen == 6);
> +   assert(brw->screen->devinfo.gen == 6);
>  
> if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) {
>/* BRW_NEW_GEOMETRY_PROGRAM */
> diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c 
> b/src/mesa/drivers/dri/i965/gen7_sol_state.c
> index 7d20c267565..299e650731e 100644
> --- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
> @@ -42,9 +42,8 @@ gen7_begin_transform_feedback(struct gl_context *ctx, 
> GLenum mode,
> struct brw_context *brw = brw_context(ctx);
> struct brw_transform_feedback_object *brw_obj =
>(struct brw_transform_feedback_object *) obj;
> -   const struct gen_device_info *devinfo = >screen->devinfo;
>  
> -   assert(devinfo->gen == 7);
> +   assert(brw->screen->devinfo.gen == 7);
>  
> /* We're about to lose the information needed to compute the number of
>  * vertices written during the last Begin/EndTransformFeedback section,
> @@ -110,12 +109,11 @@ gen7_pause_transform_feedback(struct gl_context *ctx,
> struct brw_context *brw = brw_context(ctx);
> struct brw_transform_feedback_object *brw_obj =
>(struct brw_transform_feedback_object *) obj;
> -   const struct gen_device_info *devinfo = >screen->devinfo;
>  
> /* Flush any drawing so that the counters have the right values. */
> brw_emit_mi_flush(brw);
>  
> -   assert(devinfo->gen == 7);
> +   assert(brw->screen->devinfo.gen == 7);
>  
> /* Save the SOL buffer offset register values. */
> for (int i = 0; i < 4; i++) {
> @@ -141,9 +139,8 @@ gen7_resume_transform_feedback(struct gl_context *ctx,
> struct brw_context *brw = brw_context(ctx);
> struct brw_transform_feedback_object *brw_obj =
>(struct brw_transform_feedback_object *) obj;
> -   const struct gen_device_info *devinfo = >screen->devinfo;
>  
> -   assert(devinfo->gen == 7);
> +   assert(brw->screen->devinfo.gen == 7);
>  
> /* Reload the SOL buffer offset registers. */
> for (int i = 0; i < 4; i++) {
> diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c 
> b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> index c96e2827f28..1a366c78b00 100644
> --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> @@ -1200,9 +1200,7 @@ brw_store_register_mem64(struct brw_context *brw,
>  void
>  brw_load_register_imm32(struct brw_context *brw, uint32_t reg, uint32_t imm)
>  {
> -   const struct gen_device_info *devinfo = >screen->devinfo;
> -
> -   assert(devinfo->gen >= 6);
> +   assert(brw->screen->devinfo.gen >= 6);
>  
> BEGIN_BATCH(3);
> OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2));
> @@ -1217,9 +1215,7 @@ brw_load_register_imm32(struct brw_context *brw, 
> uint32_t reg, uint32_t imm)
>  void
>  brw_load_register_imm64(struct brw_context *brw, uint32_t reg, uint64_t imm)
>  {
> -   const struct gen_device_info *devinfo = >screen->devinfo;
> -
> -   assert(devinfo->gen >= 6);
> +   assert(brw->screen->devinfo.gen >= 6);
>  
> BEGIN_BATCH(5);
> OUT_BATCH(MI_LOAD_REGISTER_IMM | (5 - 2));
> @@ -1236,9 +1232,7 @@ brw_load_register_imm64(struct brw_context *brw, 
> uint32_t reg, uint64_t imm)
>  void
>  brw_load_register_reg(struct brw_context *brw, uint32_t src, uint32_t dest)
>  {
> -   const struct gen_device_info *devinfo = >screen->devinfo;
> -
> -   assert(devinfo->gen >= 8 || devinfo->is_haswell);
> +   assert(brw->screen->devinfo.gen >= 8 || brw->screen->devinfo.is_haswell);
>  
> BEGIN_BATCH(3);
> OUT_BATCH(MI_LOAD_REGISTER_REG | (3 

Re: [Mesa-dev] [PATCH 3/3] radv: Compute ac keys from pipeline key.

2017-10-24 Thread Timothy Arceri

Thanks! This is a good start, much cleaner.

Series:

Reviewed-by: Timothy Arceri 

On 25/10/17 09:17, Bas Nieuwenhuizen wrote:

The beginning of the end for the shader keys. Not entirely sure
what I'm going to replace them with for the compiler though, so this
is the first step.
---
  src/amd/vulkan/radv_pipeline.c | 113 +++--
  1 file changed, 41 insertions(+), 72 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 74d536f2d68..085919e73f6 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -1140,26 +1140,6 @@ radv_pipeline_init_dynamic_state(struct radv_pipeline 
*pipeline,
pipeline->dynamic_state_mask = states;
  }
  
-static struct ac_shader_variant_key

-radv_compute_vs_key(const VkGraphicsPipelineCreateInfo *pCreateInfo)
-{
-   struct ac_shader_variant_key key;
-   const VkPipelineVertexInputStateCreateInfo *input_state =
-pCreateInfo->pVertexInputState;
-
-   memset(, 0, sizeof(key));
-   key.vs.instance_rate_inputs = 0;
-
-   for (unsigned i = 0; i < input_state->vertexAttributeDescriptionCount; 
++i) {
-   unsigned binding;
-   binding = input_state->pVertexAttributeDescriptions[i].binding;
-   if (input_state->pVertexBindingDescriptions[binding].inputRate)
-   key.vs.instance_rate_inputs |= 1u << 
input_state->pVertexAttributeDescriptions[i].location;
-   }
-   return key;
-}
-
-
  static void calculate_gfx9_gs_info(const VkGraphicsPipelineCreateInfo 
*pCreateInfo,
 struct radv_pipeline *pipeline)
  {
@@ -1738,11 +1718,41 @@ radv_generate_graphics_pipeline_key(struct 
radv_pipeline *pipeline,
return key;
  }
  
+static void

+radv_fill_shader_keys(struct ac_shader_variant_key *keys,
+  const struct radv_pipeline_key *key,
+  nir_shader **nir)
+{
+   keys[MESA_SHADER_VERTEX].vs.instance_rate_inputs = 
key->instance_rate_inputs;
+
+   if (nir[MESA_SHADER_TESS_CTRL]) {
+   keys[MESA_SHADER_VERTEX].vs.as_ls = true;
+   keys[MESA_SHADER_TESS_CTRL].tcs.input_vertices = 
key->tess_input_vertices;
+   keys[MESA_SHADER_TESS_CTRL].tcs.primitive_mode = 
nir[MESA_SHADER_TESS_EVAL]->info.tess.primitive_mode;
+
+   keys[MESA_SHADER_TESS_CTRL].tcs.tes_reads_tess_factors = 
!!(nir[MESA_SHADER_TESS_EVAL]->info.inputs_read & (VARYING_BIT_TESS_LEVEL_INNER 
| VARYING_BIT_TESS_LEVEL_OUTER));
+   }
+
+   if (nir[MESA_SHADER_GEOMETRY]) {
+   if (nir[MESA_SHADER_TESS_CTRL])
+   keys[MESA_SHADER_TESS_EVAL].tes.as_es = true;
+   else
+   keys[MESA_SHADER_VERTEX].vs.as_es = true;
+   }
+
+   for(int i = 0; i < MESA_SHADER_STAGES; ++i)
+   keys[i].has_multiview_view_index = 
key->has_multiview_view_index;
+
+   keys[MESA_SHADER_FRAGMENT].fs.multisample = key->multisample;
+   keys[MESA_SHADER_FRAGMENT].fs.col_format = key->col_format;
+   keys[MESA_SHADER_FRAGMENT].fs.is_int8 = key->is_int8;
+   keys[MESA_SHADER_FRAGMENT].fs.is_int10 = key->is_int10;
+}
+
  static
  void radv_create_shaders(struct radv_pipeline *pipeline,
   struct radv_device *device,
   struct radv_pipeline_cache *cache,
- struct ac_shader_variant_key *keys,
   struct radv_pipeline_key key,
   const VkPipelineShaderStageCreateInfo **pStages)
  {
@@ -1751,6 +1761,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
nir_shader *nir[MESA_SHADER_STAGES] = {0};
void *codes[MESA_SHADER_STAGES] = {0};
unsigned code_sizes[MESA_SHADER_STAGES] = {0};
+   struct ac_shader_variant_key keys[MESA_SHADER_STAGES] = 0;
unsigned char hash[20], gs_copy_hash[20];
  
  	for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {

@@ -1803,40 +1814,26 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
}
  
  	if (nir[MESA_SHADER_TESS_CTRL]) {

-   /* TODO: This is no longer used as a key we should refactor 
this */
-   if (keys)
-   keys[MESA_SHADER_TESS_CTRL].tcs.primitive_mode = 
nir[MESA_SHADER_TESS_EVAL]->info.tess.primitive_mode;
-
-   keys[MESA_SHADER_TESS_CTRL].tcs.tes_reads_tess_factors = 
!!(nir[MESA_SHADER_TESS_EVAL]->info.inputs_read & (VARYING_BIT_TESS_LEVEL_INNER 
| VARYING_BIT_TESS_LEVEL_OUTER));
nir_lower_tes_patch_vertices(nir[MESA_SHADER_TESS_EVAL], 
nir[MESA_SHADER_TESS_CTRL]->info.tess.tcs_vertices_out);
}
  
  	radv_link_shaders(pipeline, nir);
  
-	if (keys && nir[MESA_SHADER_TESS_CTRL])

-   keys[MESA_SHADER_VERTEX].vs.as_ls = true;
-   if (keys && 

[Mesa-dev] [PATCH] radv: Fix truncation issue hexifying the cache uuid for the disk cache.

2017-10-24 Thread Bas Nieuwenhuizen
Going from binary to hex has a 2x blowup.

Fixes: 14216252923 'radv: create on-disk shader cache'
---
 src/amd/vulkan/radv_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index c4e25222eaf..6cc793654c7 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -168,8 +168,8 @@ radv_physical_device_init(struct radv_physical_device 
*device,
/* The gpu id is already embeded in the uuid so we just pass "radv"
 * when creating the cache.
 */
-   char buf[VK_UUID_SIZE + 1];
-   disk_cache_format_hex_id(buf, device->cache_uuid, VK_UUID_SIZE);
+   char buf[VK_UUID_SIZE * 2 + 1];
+   disk_cache_format_hex_id(buf, device->cache_uuid, VK_UUID_SIZE * 2);
device->disk_cache = disk_cache_create("radv", buf, shader_env_flags);
 
fprintf(stderr, "WARNING: radv is not a conformant vulkan 
implementation, testing use only.\n");
-- 
2.14.2

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


Re: [Mesa-dev] [PATCH] radv: use device name in cache creation like radeonsi.

2017-10-24 Thread Bas Nieuwenhuizen
Reviewed-by: Bas Nieuwenhuizen 

On Wed, Oct 25, 2017 at 3:24 AM, Dave Airlie  wrote:
> From: Dave Airlie 
>
> Not sure how useful this is, but it makes it more consistent.
>
> Signed-off-by: Dave Airlie 
> ---
>  src/amd/vulkan/radv_device.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index c4e25222eaf..ebc74fbadef 100644
> --- a/src/amd/vulkan/radv_device.c
> +++ b/src/amd/vulkan/radv_device.c
> @@ -152,6 +152,8 @@ radv_physical_device_init(struct radv_physical_device 
> *device,
> goto fail;
> }
>
> +   device->name = get_chip_name(device->rad_info.family);
> +
> if (radv_device_get_cache_uuid(device->rad_info.family, 
> device->cache_uuid)) {
> radv_finish_wsi(device);
> device->ws->destroy(device->ws);
> @@ -170,10 +172,9 @@ radv_physical_device_init(struct radv_physical_device 
> *device,
>  */
> char buf[VK_UUID_SIZE + 1];
> disk_cache_format_hex_id(buf, device->cache_uuid, VK_UUID_SIZE);
> -   device->disk_cache = disk_cache_create("radv", buf, shader_env_flags);
> +   device->disk_cache = disk_cache_create(device->name, buf, 
> shader_env_flags);
>
> fprintf(stderr, "WARNING: radv is not a conformant vulkan 
> implementation, testing use only.\n");
> -   device->name = get_chip_name(device->rad_info.family);
>
> radv_get_driver_uuid(>device_uuid);
> radv_get_device_uuid(>rad_info, >device_uuid);
> --
> 2.14.2
>
> ___
> 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] radv: use device name in cache creation like radeonsi.

2017-10-24 Thread Dave Airlie
From: Dave Airlie 

Not sure how useful this is, but it makes it more consistent.

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_device.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index c4e25222eaf..ebc74fbadef 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -152,6 +152,8 @@ radv_physical_device_init(struct radv_physical_device 
*device,
goto fail;
}
 
+   device->name = get_chip_name(device->rad_info.family);
+
if (radv_device_get_cache_uuid(device->rad_info.family, 
device->cache_uuid)) {
radv_finish_wsi(device);
device->ws->destroy(device->ws);
@@ -170,10 +172,9 @@ radv_physical_device_init(struct radv_physical_device 
*device,
 */
char buf[VK_UUID_SIZE + 1];
disk_cache_format_hex_id(buf, device->cache_uuid, VK_UUID_SIZE);
-   device->disk_cache = disk_cache_create("radv", buf, shader_env_flags);
+   device->disk_cache = disk_cache_create(device->name, buf, 
shader_env_flags);
 
fprintf(stderr, "WARNING: radv is not a conformant vulkan 
implementation, testing use only.\n");
-   device->name = get_chip_name(device->rad_info.family);
 
radv_get_driver_uuid(>device_uuid);
radv_get_device_uuid(>rad_info, >device_uuid);
-- 
2.14.2

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


[Mesa-dev] [PATCH] gallium/util: remove some block alignment assertions

2017-10-24 Thread sroland
From: Roland Scheidegger 

These assertions were revisited a couple of times in the past, and they
still weren't quite right.
The problem I was seeing (with some other state tracker) was a copy between
two 512x512 s3tc textures, but from mip level 0 to mip level 8. Therefore,
the destination has only size 2x2 (not a full block), so the box width/height
was only 2, causing the assertion to trigger for src alignment.
As far as I can tell, such a copy is completely legal, and because a correct
assertion would get ridiculously complicated just get rid of it for good.
---
 src/gallium/auxiliary/util/u_surface.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_surface.c 
b/src/gallium/auxiliary/util/u_surface.c
index 5abf966..0a79a25 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -324,16 +324,8 @@ util_resource_copy_region(struct pipe_context *pipe,
/* check that region boxes are block aligned */
assert(src_box.x % src_bw == 0);
assert(src_box.y % src_bh == 0);
-   assert(src_box.width % src_bw == 0 ||
-  src_box.x + src_box.width == u_minify(src->width0, src_level));
-   assert(src_box.height % src_bh == 0 ||
-  src_box.y + src_box.height == u_minify(src->height0, src_level));
assert(dst_box.x % dst_bw == 0);
assert(dst_box.y % dst_bh == 0);
-   assert(dst_box.width % dst_bw == 0 ||
-  dst_box.x + dst_box.width == u_minify(dst->width0, dst_level));
-   assert(dst_box.height % dst_bh == 0 ||
-  dst_box.y + dst_box.height == u_minify(dst->height0, dst_level));
 
/* check that region boxes are not out of bounds */
assert(src_box.x + src_box.width <= u_minify(src->width0, src_level));
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH v2] clover: Fix compilation after clang r315871

2017-10-24 Thread Francisco Jerez
Jan Vesely  writes:

> On Sun, 2017-10-22 at 20:40 -0700, Francisco Jerez wrote:
>> Jan Vesely  writes:
>> 
>> > From: Jan Vesely 
>> > 
>> > v2: use a more generic compat function
>> > 
>> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103388
>> > Signed-off-by: Jan Vesely 
>> > ---
>> >  src/gallium/state_trackers/clover/llvm/codegen/common.cpp |  5 ++---
>> >  src/gallium/state_trackers/clover/llvm/compat.hpp | 12 
>> > ++--
>> >  2 files changed, 12 insertions(+), 5 deletions(-)
>> > 
>> > diff --git a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp 
>> > b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
>> > index 075183400a..dd9d02ab11 100644
>> > --- a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
>> > +++ b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
>> > @@ -70,7 +70,6 @@ namespace {
>> > make_kernel_args(const Module , const std::string _name,
>> >  const clang::CompilerInstance ) {
>> >std::vector args;
>> > -  const auto address_spaces = c.getTarget().getAddressSpaceMap();
>> >const Function  = *mod.getFunction(kernel_name);
>> >::llvm::DataLayout dl();
>> >const auto size_type =
>> > @@ -128,8 +127,8 @@ namespace {
>> > const unsigned address_space =
>> >cast< 
>> > ::llvm::PointerType>(actual_type)->getAddressSpace();
>> >  
>> > -   if (address_space == 
>> > address_spaces[clang::LangAS::opencl_local
>> > -   - 
>> > compat::lang_as_offset]) {
>> > +   if (address_space == compat::target_lang_address_space(
>> > +  c.getTarget(), 
>> > clang::LangAS::opencl_local)) {
>> >args.emplace_back(module::argument::local, arg_api_size,
>> >  target_size, target_align,
>> >  module::argument::zero_ext);
>> > diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp 
>> > b/src/gallium/state_trackers/clover/llvm/compat.hpp
>> > index f8b56516d5..3e34f0dd94 100644
>> > --- a/src/gallium/state_trackers/clover/llvm/compat.hpp
>> > +++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
>> > @@ -69,11 +69,19 @@ namespace clover {
>> >   typedef ::llvm::TargetLibraryInfo target_library_info;
>> >  #endif
>> >  
>> > + template
>> > + unsigned target_lang_address_space(const T& target, const AS 
>> > lang_as) {
>> 
>> Can you name this "target_address_space" (to me lang address space means
>> the LangAS enum, i.e. the non-target-dependent representation, which is
>> not what you get as result from this function), and place the '&' sign
>> consistently in the argument declaration? 
>
> Does this refer only to whitespace around "T& target", or would you
> prefer to pass lang_as as reference as well? (it's an integral type so
> I did not consider it necessary).
>

Nope, I was referring to the target argument only, there's no use in
passing lang_as by reference.

Thanks.

> Jan
>
>>  With that cleaned up patch
>> is:
>> 
>> Reviewed-by: Francisco Jerez 
>> 
>> Thanks!
>> 
>> > +const auto  = target.getAddressSpaceMap();
>> > +#if HAVE_LLVM >= 0x0500
>> > +return map[static_cast(lang_as)];
>> > +#else
>> > +return map[lang_as - clang::LangAS::Offset];
>> > +#endif
>> > + }
>> > +
>> >  #if HAVE_LLVM >= 0x0500
>> > - const auto lang_as_offset = 0;
>> >   const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
>> >  #else
>> > - const auto lang_as_offset = clang::LangAS::Offset;
>> >   const clang::InputKind ik_opencl = clang::IK_OpenCL;
>> >  #endif
>> >  
>> > -- 
>> > 2.13.6


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


Re: [Mesa-dev] [PATCH 5/7] radv: enable lower to scalar nir pass

2017-10-24 Thread Bas Nieuwenhuizen
On Mon, Oct 23, 2017 at 2:10 AM, Timothy Arceri  wrote:
> This will allow dead components of varyings to be removed.
> ---
>  src/amd/vulkan/radv_pipeline.c | 24 
>  1 file changed, 24 insertions(+)
>
> diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
> index 669d9a4858..2a25a423a2 100644
> --- a/src/amd/vulkan/radv_pipeline.c
> +++ b/src/amd/vulkan/radv_pipeline.c
> @@ -1722,20 +1722,31 @@ void radv_create_shaders(struct radv_pipeline 
> *pipeline,
> for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
> if (pStages[i]) {
> modules[i] = 
> radv_shader_module_from_handle(pStages[i]->module);
> if (modules[i]->nir)
> _mesa_sha1_compute(modules[i]->nir->info.name,
>
> strlen(modules[i]->nir->info.name),
>modules[i]->sha1);
> }
> }
>
> +   /* Determine first and last stage. */
> +   unsigned first = MESA_SHADER_STAGES;
> +   unsigned last = 0;
> +   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> +   if (!pStages[i])
> +   continue;
> +   if (first == MESA_SHADER_STAGES)
> +   first = i;
> +   last = i;
> +   }
> +

Can we move this till after checking the cache? Otherwise

Reviewed-by: Bas Nieuwenhuizen 


> radv_hash_shaders(hash, pStages, pipeline->layout, keys, 
> get_hash_flags(device));
> memcpy(gs_copy_hash, hash, 20);
> gs_copy_hash[0] ^= 1;
>
> if (modules[MESA_SHADER_GEOMETRY]) {
> struct radv_shader_variant *variants[MESA_SHADER_STAGES] = 
> {0};
> radv_create_shader_variants_from_pipeline_cache(device, 
> cache, gs_copy_hash, variants);
> pipeline->gs_copy_shader = variants[MESA_SHADER_GEOMETRY];
> }
>
> @@ -1759,20 +1770,33 @@ void radv_create_shaders(struct radv_pipeline 
> *pipeline,
> for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
> const VkPipelineShaderStageCreateInfo *stage = pStages[i];
>
> if (!modules[i])
> continue;
>
> nir[i] = radv_shader_compile_to_nir(device, modules[i],
> stage ? stage->pName : 
> "main", i,
> stage ? 
> stage->pSpecializationInfo : NULL);
> pipeline->active_stages |= mesa_to_vk_shader_stage(i);
> +
> +   if (first != last) {
> +   nir_variable_mode mask = 0;
> +
> +   if (i != first)
> +   mask = mask | nir_var_shader_in;
> +
> +   if (i != last)
> +   mask = mask | nir_var_shader_out;
> +
> +   nir_lower_io_to_scalar_early(nir[i], mask);
> +   radv_optimize_nir(nir[i]);
> +   }
> }
>
> if (nir[MESA_SHADER_TESS_CTRL]) {
> /* TODO: This is no longer used as a key we should refactor 
> this */
> if (keys)
> keys[MESA_SHADER_TESS_CTRL].tcs.primitive_mode = 
> nir[MESA_SHADER_TESS_EVAL]->info.tess.primitive_mode;
>
> keys[MESA_SHADER_TESS_CTRL].tcs.tes_reads_tess_factors = 
> !!(nir[MESA_SHADER_TESS_EVAL]->info.inputs_read & 
> (VARYING_BIT_TESS_LEVEL_INNER | VARYING_BIT_TESS_LEVEL_OUTER));
> nir_lower_tes_patch_vertices(nir[MESA_SHADER_TESS_EVAL], 
> nir[MESA_SHADER_TESS_CTRL]->info.tess.tcs_vertices_out);
> }
> --
> 2.13.6
>
> ___
> 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 4/7] ac: add support for explicit component packing

2017-10-24 Thread Bas Nieuwenhuizen
On Wed, Oct 25, 2017 at 1:04 AM, Timothy Arceri  wrote:
> This is needed for RADV to support explicit component packing.
>
> This is also required to use the new NIR component splitting /
> packing passes.
>
> V2:
>  - add commponent packing support for interpolate_at* intrinsics
>  - improve store packing support when not all varyings are scalar
>as spotted by Bas the store source was incorrectly offset.
> ---
>  src/amd/common/ac_nir_to_llvm.c | 68 
> +++--
>  1 file changed, 52 insertions(+), 16 deletions(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 2e50e50b12..5d9c5be7d2 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -1060,21 +1060,20 @@ static int get_llvm_num_components(LLVMValueRef value)
>   : 1;
> return num_components;
>  }
>
>  static LLVMValueRef llvm_extract_elem(struct ac_llvm_context *ac,
>   LLVMValueRef value,
>   int index)
>  {
> int count = get_llvm_num_components(value);
>
> -   assert(index < count);
> if (count == 1)
> return value;
>
> return LLVMBuildExtractElement(ac->builder, value,
>LLVMConstInt(ac->i32, index, false), 
> "");
>  }
>
>  static LLVMValueRef trim_vector(struct ac_llvm_context *ctx,
>  LLVMValueRef value, unsigned count)
>  {
> @@ -2811,20 +2810,42 @@ get_dw_address(struct nir_to_llvm_context *ctx,
> dw_addr = LLVMBuildAdd(ctx->builder, dw_addr,
>LLVMConstInt(ctx->i32, param * 4, false), "");
>
> if (const_index && compact_const_index)
> dw_addr = LLVMBuildAdd(ctx->builder, dw_addr,
>LLVMConstInt(ctx->i32, const_index, 
> false), "");
> return dw_addr;
>  }
>
>  static LLVMValueRef
> +build_varying_gather_values(struct ac_llvm_context *ctx, LLVMValueRef 
> *values,
> +   unsigned value_count, unsigned component)
> +{
> +   LLVMValueRef vec = NULL;
> +
> +   if (value_count == 1) {
> +   return values[component];
> +   } else if (!value_count)
> +   unreachable("value_count is 0");
> +
> +   for (unsigned i = component; i < value_count + component; i++) {
> +   LLVMValueRef value = values[i];
> +
> +   if (!i)
> +   vec = LLVMGetUndef( LLVMVectorType(LLVMTypeOf(value), 
> value_count));
> +   LLVMValueRef index = LLVMConstInt(ctx->i32, i, false);

Doesn't this need to be i - component to get a range of [0, value_count)?

Otherwise

Reviewed-by: Bas Nieuwenhuizen 



> +   vec = LLVMBuildInsertElement(ctx->builder, vec, value, index, 
> "");
> +   }
> +   return vec;
> +}
> +
> +static LLVMValueRef
>  load_tcs_input(struct nir_to_llvm_context *ctx,
>nir_intrinsic_instr *instr)
>  {
> LLVMValueRef dw_addr, stride;
> unsigned const_index;
> LLVMValueRef vertex_index;
> LLVMValueRef indir_index;
> unsigned param;
> LLVMValueRef value[4], result;
> const bool per_vertex = 
> nir_is_per_vertex_io(instr->variables[0]->var, ctx->stage);
> @@ -2832,26 +2853,27 @@ load_tcs_input(struct nir_to_llvm_context *ctx,
> param = 
> shader_io_get_unique_index(instr->variables[0]->var->data.location);
> get_deref_offset(ctx->nir, instr->variables[0],
>  false, NULL, per_vertex ? _index : NULL,
>  _index, _index);
>
> stride = unpack_param(>ac, ctx->tcs_in_layout, 13, 8);
> dw_addr = get_tcs_in_current_patch_offset(ctx);
> dw_addr = get_dw_address(ctx, dw_addr, param, const_index, 
> is_compact, vertex_index, stride,
>  indir_index);
>
> -   for (unsigned i = 0; i < instr->num_components; i++) {
> +   unsigned comp = instr->variables[0]->var->data.location_frac;
> +   for (unsigned i = 0; i < instr->num_components + comp; i++) {
> value[i] = lds_load(ctx, dw_addr);
> dw_addr = LLVMBuildAdd(ctx->builder, dw_addr,
>ctx->i32one, "");
> }
> -   result = ac_build_gather_values(>ac, value, 
> instr->num_components);
> +   result = build_varying_gather_values(>ac, value, 
> instr->num_components, comp);
> result = LLVMBuildBitCast(ctx->builder, result, 
> get_def_type(ctx->nir, >dest.ssa), "");
> return result;
>  }
>
>  static LLVMValueRef
>  load_tcs_output(struct nir_to_llvm_context *ctx,
>nir_intrinsic_instr *instr)
>  {
> LLVMValueRef dw_addr;
> LLVMValueRef stride = NULL;
> @@ -2870,43 +2892,45 @@ 

[Mesa-dev] [PATCH V2 4/7] ac: add support for explicit component packing

2017-10-24 Thread Timothy Arceri
This is needed for RADV to support explicit component packing.

This is also required to use the new NIR component splitting /
packing passes.

V2:
 - add commponent packing support for interpolate_at* intrinsics
 - improve store packing support when not all varyings are scalar
   as spotted by Bas the store source was incorrectly offset.
---
 src/amd/common/ac_nir_to_llvm.c | 68 +++--
 1 file changed, 52 insertions(+), 16 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 2e50e50b12..5d9c5be7d2 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -1060,21 +1060,20 @@ static int get_llvm_num_components(LLVMValueRef value)
  : 1;
return num_components;
 }
 
 static LLVMValueRef llvm_extract_elem(struct ac_llvm_context *ac,
  LLVMValueRef value,
  int index)
 {
int count = get_llvm_num_components(value);
 
-   assert(index < count);
if (count == 1)
return value;
 
return LLVMBuildExtractElement(ac->builder, value,
   LLVMConstInt(ac->i32, index, false), "");
 }
 
 static LLVMValueRef trim_vector(struct ac_llvm_context *ctx,
 LLVMValueRef value, unsigned count)
 {
@@ -2811,20 +2810,42 @@ get_dw_address(struct nir_to_llvm_context *ctx,
dw_addr = LLVMBuildAdd(ctx->builder, dw_addr,
   LLVMConstInt(ctx->i32, param * 4, false), "");
 
if (const_index && compact_const_index)
dw_addr = LLVMBuildAdd(ctx->builder, dw_addr,
   LLVMConstInt(ctx->i32, const_index, 
false), "");
return dw_addr;
 }
 
 static LLVMValueRef
+build_varying_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values,
+   unsigned value_count, unsigned component)
+{
+   LLVMValueRef vec = NULL;
+
+   if (value_count == 1) {
+   return values[component];
+   } else if (!value_count)
+   unreachable("value_count is 0");
+
+   for (unsigned i = component; i < value_count + component; i++) {
+   LLVMValueRef value = values[i];
+
+   if (!i)
+   vec = LLVMGetUndef( LLVMVectorType(LLVMTypeOf(value), 
value_count));
+   LLVMValueRef index = LLVMConstInt(ctx->i32, i, false);
+   vec = LLVMBuildInsertElement(ctx->builder, vec, value, index, 
"");
+   }
+   return vec;
+}
+
+static LLVMValueRef
 load_tcs_input(struct nir_to_llvm_context *ctx,
   nir_intrinsic_instr *instr)
 {
LLVMValueRef dw_addr, stride;
unsigned const_index;
LLVMValueRef vertex_index;
LLVMValueRef indir_index;
unsigned param;
LLVMValueRef value[4], result;
const bool per_vertex = nir_is_per_vertex_io(instr->variables[0]->var, 
ctx->stage);
@@ -2832,26 +2853,27 @@ load_tcs_input(struct nir_to_llvm_context *ctx,
param = 
shader_io_get_unique_index(instr->variables[0]->var->data.location);
get_deref_offset(ctx->nir, instr->variables[0],
 false, NULL, per_vertex ? _index : NULL,
 _index, _index);
 
stride = unpack_param(>ac, ctx->tcs_in_layout, 13, 8);
dw_addr = get_tcs_in_current_patch_offset(ctx);
dw_addr = get_dw_address(ctx, dw_addr, param, const_index, is_compact, 
vertex_index, stride,
 indir_index);
 
-   for (unsigned i = 0; i < instr->num_components; i++) {
+   unsigned comp = instr->variables[0]->var->data.location_frac;
+   for (unsigned i = 0; i < instr->num_components + comp; i++) {
value[i] = lds_load(ctx, dw_addr);
dw_addr = LLVMBuildAdd(ctx->builder, dw_addr,
   ctx->i32one, "");
}
-   result = ac_build_gather_values(>ac, value, instr->num_components);
+   result = build_varying_gather_values(>ac, value, 
instr->num_components, comp);
result = LLVMBuildBitCast(ctx->builder, result, get_def_type(ctx->nir, 
>dest.ssa), "");
return result;
 }
 
 static LLVMValueRef
 load_tcs_output(struct nir_to_llvm_context *ctx,
   nir_intrinsic_instr *instr)
 {
LLVMValueRef dw_addr;
LLVMValueRef stride = NULL;
@@ -2870,43 +2892,45 @@ load_tcs_output(struct nir_to_llvm_context *ctx,
if (!instr->variables[0]->var->data.patch) {
stride = unpack_param(>ac, ctx->tcs_out_layout, 13, 8);
dw_addr = get_tcs_out_current_patch_offset(ctx);
} else {
dw_addr = get_tcs_out_current_patch_data_offset(ctx);
}
 
dw_addr = get_dw_address(ctx, dw_addr, param, const_index, is_compact, 
vertex_index, stride,
  

Re: [Mesa-dev] [PATCH] radv: use a define for the transition point between cp and compute shader

2017-10-24 Thread Samuel Pitoiset

Reviewed-by: Samuel Pitoiset 

On 10/25/2017 12:06 AM, Dave Airlie wrote:

From: Dave Airlie 

For certain buffer meta ops we can use the CP or a compute shader,
we should use a define to rather than hardcoding 4096, allows
for easier testing and more consistency.

Signed-off-by: Dave Airlie 
---
  src/amd/vulkan/radv_meta_buffer.c | 12 +---
  1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_buffer.c 
b/src/amd/vulkan/radv_meta_buffer.c
index e009234..a737dbe 100644
--- a/src/amd/vulkan/radv_meta_buffer.c
+++ b/src/amd/vulkan/radv_meta_buffer.c
@@ -4,6 +4,12 @@
  #include "sid.h"
  #include "radv_cs.h"
  
+/*

+ * This is the point we switch from using CP to compute shader
+ * for certain buffer operations.
+ */
+#define RADV_BUFFER_OPS_CS_THRESHOLD 4096
+
  static nir_shader *
  build_buffer_fill_shader(struct radv_device *dev)
  {
@@ -405,7 +411,7 @@ void radv_fill_buffer(struct radv_cmd_buffer *cmd_buffer,
assert(!(offset & 3));
assert(!(size & 3));
  
-	if (size >= 4096)

+   if (size >= RADV_BUFFER_OPS_CS_THRESHOLD)
fill_buffer_shader(cmd_buffer, bo, offset, size, value);
else if (size) {
uint64_t va = radv_buffer_get_va(bo);
@@ -422,7 +428,7 @@ void radv_copy_buffer(struct radv_cmd_buffer *cmd_buffer,
  uint64_t src_offset, uint64_t dst_offset,
  uint64_t size)
  {
-   if (size >= 4096 && !(size & 3) && !(src_offset & 3) && !(dst_offset & 
3))
+   if (size >= RADV_BUFFER_OPS_CS_THRESHOLD && !(size & 3) && !(src_offset & 3) 
&& !(dst_offset & 3))
copy_buffer_shader(cmd_buffer, src_bo, dst_bo,
   src_offset, dst_offset, size);
else if (size) {
@@ -496,7 +502,7 @@ void radv_CmdUpdateBuffer(
if (!dataSize)
return;
  
-	if (dataSize < 4096) {

+   if (dataSize < RADV_BUFFER_OPS_CS_THRESHOLD) {
si_emit_cache_flush(cmd_buffer);
  
  		cmd_buffer->device->ws->cs_add_buffer(cmd_buffer->cs, dst_buffer->bo, 8);



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


Re: [Mesa-dev] [PATCH] radv: use a define for the transition point between cp and compute shader

2017-10-24 Thread Bas Nieuwenhuizen
r-b

On Wed, Oct 25, 2017 at 12:06 AM, Dave Airlie  wrote:
> From: Dave Airlie 
>
> For certain buffer meta ops we can use the CP or a compute shader,
> we should use a define to rather than hardcoding 4096, allows
> for easier testing and more consistency.
>
> Signed-off-by: Dave Airlie 
> ---
>  src/amd/vulkan/radv_meta_buffer.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_meta_buffer.c 
> b/src/amd/vulkan/radv_meta_buffer.c
> index e009234..a737dbe 100644
> --- a/src/amd/vulkan/radv_meta_buffer.c
> +++ b/src/amd/vulkan/radv_meta_buffer.c
> @@ -4,6 +4,12 @@
>  #include "sid.h"
>  #include "radv_cs.h"
>
> +/*
> + * This is the point we switch from using CP to compute shader
> + * for certain buffer operations.
> + */
> +#define RADV_BUFFER_OPS_CS_THRESHOLD 4096
> +
>  static nir_shader *
>  build_buffer_fill_shader(struct radv_device *dev)
>  {
> @@ -405,7 +411,7 @@ void radv_fill_buffer(struct radv_cmd_buffer *cmd_buffer,
> assert(!(offset & 3));
> assert(!(size & 3));
>
> -   if (size >= 4096)
> +   if (size >= RADV_BUFFER_OPS_CS_THRESHOLD)
> fill_buffer_shader(cmd_buffer, bo, offset, size, value);
> else if (size) {
> uint64_t va = radv_buffer_get_va(bo);
> @@ -422,7 +428,7 @@ void radv_copy_buffer(struct radv_cmd_buffer *cmd_buffer,
>   uint64_t src_offset, uint64_t dst_offset,
>   uint64_t size)
>  {
> -   if (size >= 4096 && !(size & 3) && !(src_offset & 3) && !(dst_offset 
> & 3))
> +   if (size >= RADV_BUFFER_OPS_CS_THRESHOLD && !(size & 3) && 
> !(src_offset & 3) && !(dst_offset & 3))
> copy_buffer_shader(cmd_buffer, src_bo, dst_bo,
>src_offset, dst_offset, size);
> else if (size) {
> @@ -496,7 +502,7 @@ void radv_CmdUpdateBuffer(
> if (!dataSize)
> return;
>
> -   if (dataSize < 4096) {
> +   if (dataSize < RADV_BUFFER_OPS_CS_THRESHOLD) {
> si_emit_cache_flush(cmd_buffer);
>
> cmd_buffer->device->ws->cs_add_buffer(cmd_buffer->cs, 
> dst_buffer->bo, 8);
> --
> 2.9.5
>
> ___
> 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 2/3] radv: Add single pipeline cache key.

2017-10-24 Thread Bas Nieuwenhuizen
To decouple the key used for info gathering and the cache from
whatever we pass to the compiler.
---
 src/amd/vulkan/radv_pipeline.c   | 44 +---
 src/amd/vulkan/radv_pipeline_cache.c |  6 ++---
 src/amd/vulkan/radv_private.h| 13 +--
 3 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 1d7ebfb85e8..74d536f2d68 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -1703,11 +1703,47 @@ radv_link_shaders(struct radv_pipeline *pipeline, 
nir_shader **shaders)
}
 }
 
+
+static struct radv_pipeline_key
+radv_generate_graphics_pipeline_key(struct radv_pipeline *pipeline,
+const VkGraphicsPipelineCreateInfo 
*pCreateInfo,
+bool has_view_index)
+{
+   const VkPipelineVertexInputStateCreateInfo *input_state =
+pCreateInfo->pVertexInputState;
+   struct radv_pipeline_key key;
+   memset(, 0, sizeof(key));
+
+   key.has_multiview_view_index = has_view_index;
+
+   for (unsigned i = 0; i < input_state->vertexAttributeDescriptionCount; 
++i) {
+   unsigned binding;
+   binding = input_state->pVertexAttributeDescriptions[i].binding;
+   if (input_state->pVertexBindingDescriptions[binding].inputRate)
+   key.instance_rate_inputs |= 1u << 
input_state->pVertexAttributeDescriptions[i].location;
+   }
+
+   if (pCreateInfo->pTessellationState)
+   key.tess_input_vertices = 
pCreateInfo->pTessellationState->patchControlPoints;
+
+
+   if (pCreateInfo->pMultisampleState &&
+   pCreateInfo->pMultisampleState->rasterizationSamples > 1)
+   key.multisample = true;
+
+   key.col_format = pipeline->graphics.blend.spi_shader_col_format;
+   if (pipeline->device->physical_device->rad_info.chip_class < VI)
+   radv_pipeline_compute_get_int_clamp(pCreateInfo, _int8, 
_int10);
+
+   return key;
+}
+
 static
 void radv_create_shaders(struct radv_pipeline *pipeline,
  struct radv_device *device,
  struct radv_pipeline_cache *cache,
  struct ac_shader_variant_key *keys,
+ struct radv_pipeline_key key,
  const VkPipelineShaderStageCreateInfo **pStages)
 {
struct radv_shader_module fs_m = {0};
@@ -1727,7 +1763,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
}
}
 
-   radv_hash_shaders(hash, pStages, pipeline->layout, keys, 
get_hash_flags(device));
+   radv_hash_shaders(hash, pStages, pipeline->layout, , 
get_hash_flags(device));
memcpy(gs_copy_hash, hash, 20);
gs_copy_hash[0] ^= 1;
 
@@ -1936,7 +1972,9 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
if (pipeline->device->physical_device->rad_info.chip_class < VI)
radv_pipeline_compute_get_int_clamp(pCreateInfo, 
[MESA_SHADER_FRAGMENT].fs.is_int8, 
[MESA_SHADER_FRAGMENT].fs.is_int10);
 
-   radv_create_shaders(pipeline, device, cache, keys, pStages);
+   radv_create_shaders(pipeline, device, cache, keys, 
+   radv_generate_graphics_pipeline_key(pipeline, 
pCreateInfo, has_view_index),
+   pStages);
 
radv_pipeline_init_depth_stencil_state(pipeline, pCreateInfo, extra);
radv_pipeline_init_raster_state(pipeline, pCreateInfo);
@@ -2272,7 +2310,7 @@ static VkResult radv_compute_pipeline_create(
pipeline->layout = 
radv_pipeline_layout_from_handle(pCreateInfo->layout);
 
pStages[MESA_SHADER_COMPUTE] = >stage;
-   radv_create_shaders(pipeline, device, cache, NULL, pStages);
+   radv_create_shaders(pipeline, device, cache, NULL, (struct 
radv_pipeline_key) {0}, pStages);
 
 
pipeline->need_indirect_descriptor_sets |= 
pipeline->shaders[MESA_SHADER_COMPUTE]->info.need_indirect_descriptor_sets;
diff --git a/src/amd/vulkan/radv_pipeline_cache.c 
b/src/amd/vulkan/radv_pipeline_cache.c
index 9ba9a3b61ba..5dee1147491 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -100,14 +100,14 @@ void
 radv_hash_shaders(unsigned char *hash,
  const VkPipelineShaderStageCreateInfo **stages,
  const struct radv_pipeline_layout *layout,
- const struct ac_shader_variant_key *keys,
+ const struct radv_pipeline_key *key,
  uint32_t flags)
 {
struct mesa_sha1 ctx;
 
_mesa_sha1_init();
-   if (keys)
-   _mesa_sha1_update(, keys, sizeof(*keys) * 
MESA_SHADER_STAGES);
+   if (key)
+   _mesa_sha1_update(, key, sizeof(*key));
if (layout)
_mesa_sha1_update(, layout->sha1, 

[Mesa-dev] [PATCH 1/3] Don't compute as_ls/as_es before hashing.

2017-10-24 Thread Bas Nieuwenhuizen
---
 src/amd/vulkan/radv_pipeline.c | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 669d9a4858e..1d7ebfb85e8 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -1141,7 +1141,7 @@ radv_pipeline_init_dynamic_state(struct radv_pipeline 
*pipeline,
 }
 
 static struct ac_shader_variant_key
-radv_compute_vs_key(const VkGraphicsPipelineCreateInfo *pCreateInfo, bool 
as_es, bool as_ls)
+radv_compute_vs_key(const VkGraphicsPipelineCreateInfo *pCreateInfo)
 {
struct ac_shader_variant_key key;
const VkPipelineVertexInputStateCreateInfo *input_state =
@@ -1149,8 +1149,6 @@ radv_compute_vs_key(const VkGraphicsPipelineCreateInfo 
*pCreateInfo, bool as_es,
 
memset(, 0, sizeof(key));
key.vs.instance_rate_inputs = 0;
-   key.vs.as_es = as_es;
-   key.vs.as_ls = as_ls;
 
for (unsigned i = 0; i < input_state->vertexAttributeDescriptionCount; 
++i) {
unsigned binding;
@@ -1779,6 +1777,15 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
 
radv_link_shaders(pipeline, nir);
 
+   if (keys && nir[MESA_SHADER_TESS_CTRL])
+   keys[MESA_SHADER_VERTEX].vs.as_ls = true;
+   if (keys && nir[MESA_SHADER_GEOMETRY]) {
+   if (nir[MESA_SHADER_TESS_CTRL])
+   keys[MESA_SHADER_TESS_EVAL].tes.as_es = true;
+   else
+   keys[MESA_SHADER_VERTEX].vs.as_es = true;
+   }
+
if (nir[MESA_SHADER_FRAGMENT]) {
if (!pipeline->shaders[MESA_SHADER_FRAGMENT]) {
pipeline->shaders[MESA_SHADER_FRAGMENT] =
@@ -1905,28 +1912,19 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
memset(keys, 0, sizeof(keys));
 
if (pStages[MESA_SHADER_VERTEX]) {
-   bool as_es = false;
-   bool as_ls = false;
-   if (pStages[MESA_SHADER_TESS_CTRL])
-   as_ls = true;
-   else if (pStages[MESA_SHADER_GEOMETRY])
-   as_es = true;
-
-   keys[MESA_SHADER_VERTEX] = radv_compute_vs_key(pCreateInfo, 
as_es, as_ls);
+   keys[MESA_SHADER_VERTEX] = radv_compute_vs_key(pCreateInfo);
keys[MESA_SHADER_VERTEX].has_multiview_view_index = 
has_view_index;
}
 
if (pStages[MESA_SHADER_TESS_EVAL]) {
keys[MESA_SHADER_TESS_EVAL].has_multiview_view_index = 
has_view_index;
-   if (pStages[MESA_SHADER_GEOMETRY])
-   keys[MESA_SHADER_TESS_EVAL].tes.as_es = true;
}
 
if (pCreateInfo->pTessellationState)
keys[MESA_SHADER_TESS_CTRL].tcs.input_vertices = 
pCreateInfo->pTessellationState->patchControlPoints;
 
if (pStages[MESA_SHADER_GEOMETRY]) {
-   keys[MESA_SHADER_GEOMETRY] = radv_compute_vs_key(pCreateInfo, 
false, false);
+   keys[MESA_SHADER_GEOMETRY] = radv_compute_vs_key(pCreateInfo);
keys[MESA_SHADER_GEOMETRY].has_multiview_view_index = 
has_view_index;
}
 
-- 
2.14.2

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


[Mesa-dev] [PATCH 3/3] radv: Compute ac keys from pipeline key.

2017-10-24 Thread Bas Nieuwenhuizen
The beginning of the end for the shader keys. Not entirely sure
what I'm going to replace them with for the compiler though, so this
is the first step.
---
 src/amd/vulkan/radv_pipeline.c | 113 +++--
 1 file changed, 41 insertions(+), 72 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 74d536f2d68..085919e73f6 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -1140,26 +1140,6 @@ radv_pipeline_init_dynamic_state(struct radv_pipeline 
*pipeline,
pipeline->dynamic_state_mask = states;
 }
 
-static struct ac_shader_variant_key
-radv_compute_vs_key(const VkGraphicsPipelineCreateInfo *pCreateInfo)
-{
-   struct ac_shader_variant_key key;
-   const VkPipelineVertexInputStateCreateInfo *input_state =
-pCreateInfo->pVertexInputState;
-
-   memset(, 0, sizeof(key));
-   key.vs.instance_rate_inputs = 0;
-
-   for (unsigned i = 0; i < input_state->vertexAttributeDescriptionCount; 
++i) {
-   unsigned binding;
-   binding = input_state->pVertexAttributeDescriptions[i].binding;
-   if (input_state->pVertexBindingDescriptions[binding].inputRate)
-   key.vs.instance_rate_inputs |= 1u << 
input_state->pVertexAttributeDescriptions[i].location;
-   }
-   return key;
-}
-
-
 static void calculate_gfx9_gs_info(const VkGraphicsPipelineCreateInfo 
*pCreateInfo,
struct radv_pipeline *pipeline)
 {
@@ -1738,11 +1718,41 @@ radv_generate_graphics_pipeline_key(struct 
radv_pipeline *pipeline,
return key;
 }
 
+static void
+radv_fill_shader_keys(struct ac_shader_variant_key *keys,
+  const struct radv_pipeline_key *key,
+  nir_shader **nir)
+{
+   keys[MESA_SHADER_VERTEX].vs.instance_rate_inputs = 
key->instance_rate_inputs;
+
+   if (nir[MESA_SHADER_TESS_CTRL]) {
+   keys[MESA_SHADER_VERTEX].vs.as_ls = true;
+   keys[MESA_SHADER_TESS_CTRL].tcs.input_vertices = 
key->tess_input_vertices;
+   keys[MESA_SHADER_TESS_CTRL].tcs.primitive_mode = 
nir[MESA_SHADER_TESS_EVAL]->info.tess.primitive_mode;
+
+   keys[MESA_SHADER_TESS_CTRL].tcs.tes_reads_tess_factors = 
!!(nir[MESA_SHADER_TESS_EVAL]->info.inputs_read & (VARYING_BIT_TESS_LEVEL_INNER 
| VARYING_BIT_TESS_LEVEL_OUTER));
+   }
+
+   if (nir[MESA_SHADER_GEOMETRY]) {
+   if (nir[MESA_SHADER_TESS_CTRL])
+   keys[MESA_SHADER_TESS_EVAL].tes.as_es = true;
+   else
+   keys[MESA_SHADER_VERTEX].vs.as_es = true;
+   }
+
+   for(int i = 0; i < MESA_SHADER_STAGES; ++i)
+   keys[i].has_multiview_view_index = 
key->has_multiview_view_index;
+
+   keys[MESA_SHADER_FRAGMENT].fs.multisample = key->multisample;
+   keys[MESA_SHADER_FRAGMENT].fs.col_format = key->col_format;
+   keys[MESA_SHADER_FRAGMENT].fs.is_int8 = key->is_int8;
+   keys[MESA_SHADER_FRAGMENT].fs.is_int10 = key->is_int10;
+}
+
 static
 void radv_create_shaders(struct radv_pipeline *pipeline,
  struct radv_device *device,
  struct radv_pipeline_cache *cache,
- struct ac_shader_variant_key *keys,
  struct radv_pipeline_key key,
  const VkPipelineShaderStageCreateInfo **pStages)
 {
@@ -1751,6 +1761,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
nir_shader *nir[MESA_SHADER_STAGES] = {0};
void *codes[MESA_SHADER_STAGES] = {0};
unsigned code_sizes[MESA_SHADER_STAGES] = {0};
+   struct ac_shader_variant_key keys[MESA_SHADER_STAGES] = 0;
unsigned char hash[20], gs_copy_hash[20];
 
for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
@@ -1803,40 +1814,26 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
}
 
if (nir[MESA_SHADER_TESS_CTRL]) {
-   /* TODO: This is no longer used as a key we should refactor 
this */
-   if (keys)
-   keys[MESA_SHADER_TESS_CTRL].tcs.primitive_mode = 
nir[MESA_SHADER_TESS_EVAL]->info.tess.primitive_mode;
-
-   keys[MESA_SHADER_TESS_CTRL].tcs.tes_reads_tess_factors = 
!!(nir[MESA_SHADER_TESS_EVAL]->info.inputs_read & (VARYING_BIT_TESS_LEVEL_INNER 
| VARYING_BIT_TESS_LEVEL_OUTER));
nir_lower_tes_patch_vertices(nir[MESA_SHADER_TESS_EVAL], 
nir[MESA_SHADER_TESS_CTRL]->info.tess.tcs_vertices_out);
}
 
radv_link_shaders(pipeline, nir);
 
-   if (keys && nir[MESA_SHADER_TESS_CTRL])
-   keys[MESA_SHADER_VERTEX].vs.as_ls = true;
-   if (keys && nir[MESA_SHADER_GEOMETRY]) {
-   if (nir[MESA_SHADER_TESS_CTRL])
-   keys[MESA_SHADER_TESS_EVAL].tes.as_es = true;
-   else
-  

[Mesa-dev] [PATCH] radv: use a define for the transition point between cp and compute shader

2017-10-24 Thread Dave Airlie
From: Dave Airlie 

For certain buffer meta ops we can use the CP or a compute shader,
we should use a define to rather than hardcoding 4096, allows
for easier testing and more consistency.

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_meta_buffer.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_buffer.c 
b/src/amd/vulkan/radv_meta_buffer.c
index e009234..a737dbe 100644
--- a/src/amd/vulkan/radv_meta_buffer.c
+++ b/src/amd/vulkan/radv_meta_buffer.c
@@ -4,6 +4,12 @@
 #include "sid.h"
 #include "radv_cs.h"
 
+/*
+ * This is the point we switch from using CP to compute shader
+ * for certain buffer operations.
+ */
+#define RADV_BUFFER_OPS_CS_THRESHOLD 4096
+
 static nir_shader *
 build_buffer_fill_shader(struct radv_device *dev)
 {
@@ -405,7 +411,7 @@ void radv_fill_buffer(struct radv_cmd_buffer *cmd_buffer,
assert(!(offset & 3));
assert(!(size & 3));
 
-   if (size >= 4096)
+   if (size >= RADV_BUFFER_OPS_CS_THRESHOLD)
fill_buffer_shader(cmd_buffer, bo, offset, size, value);
else if (size) {
uint64_t va = radv_buffer_get_va(bo);
@@ -422,7 +428,7 @@ void radv_copy_buffer(struct radv_cmd_buffer *cmd_buffer,
  uint64_t src_offset, uint64_t dst_offset,
  uint64_t size)
 {
-   if (size >= 4096 && !(size & 3) && !(src_offset & 3) && !(dst_offset & 
3))
+   if (size >= RADV_BUFFER_OPS_CS_THRESHOLD && !(size & 3) && !(src_offset 
& 3) && !(dst_offset & 3))
copy_buffer_shader(cmd_buffer, src_bo, dst_bo,
   src_offset, dst_offset, size);
else if (size) {
@@ -496,7 +502,7 @@ void radv_CmdUpdateBuffer(
if (!dataSize)
return;
 
-   if (dataSize < 4096) {
+   if (dataSize < RADV_BUFFER_OPS_CS_THRESHOLD) {
si_emit_cache_flush(cmd_buffer);
 
cmd_buffer->device->ws->cs_add_buffer(cmd_buffer->cs, 
dst_buffer->bo, 8);
-- 
2.9.5

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


[Mesa-dev] [PATCH mesa] meson: bring MESA_GIT_SHA1 in line with other build systems

2017-10-24 Thread Eric Engestrom
Meson's vcs_tag() uses the output of `git describe`, eg.
  17.3-branchpoint-5-gfbf29c3cd15ae831e249+

Whereas the other build systems used a script that outputs only the sha1
of the HEAD commit, eg.
  fbf29c3cd1

Given that this information is used by printing it next to the version
number, there's some redundancy here, and inconsistency between build
systems.

Bring Meson in line by making it use the same script, with the added
advantage of now supporting the MESA_GIT_SHA1_OVERRIDE env var.

Downside is, files using MESA_GIT_SHA1 now have to be rebuilt every
time.

Signed-off-by: Eric Engestrom 
---
I don't like this solution because of the downside mentioned; I'm not
sure the redundant information is really an issue, and the inconsistency
aspect will go away once Meson becomes The One True Build System, and
the env var fallback can be implemented with a meson option instead,
although I don't like that because if you set the git version once, it
will be carried over across git pulls, but if we make it clear that such
an option is only to be used by build scripts it should be fine.

I'm leaning towards "let's accept `git describe` as the new information
printed with the version", and implement the meson option fallback.
Thoughts?
---
 bin/meson.build | 21 +
 meson.build |  1 +
 src/meson.build |  6 +-
 3 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 bin/meson.build

diff --git a/bin/meson.build b/bin/meson.build
new file mode 100644
index 00..b8b44baf7d
--- /dev/null
+++ b/bin/meson.build
@@ -0,0 +1,21 @@
+# Copyright © 2017 Eric Engestrom
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+git_sha1_gen_py = files('git_sha1_gen.py')
diff --git a/meson.build b/meson.build
index 09e4615a14..8a92ddc9a9 100644
--- a/meson.build
+++ b/meson.build
@@ -834,4 +834,5 @@ endif
 pkg = import('pkgconfig')
 
 subdir('include')
+subdir('bin')
 subdir('src')
diff --git a/src/meson.build b/src/meson.build
index 9b1b0ae594..b35295e9d3 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -34,9 +34,13 @@ libglsl_util = static_library(
   build_by_default : false,
 )
 
-sha1_h = vcs_tag(
+sha1_h = custom_target(
+  'git_sha1.h',
   input : 'git_sha1.h.in',
   output : 'git_sha1.h',
+  command : [prog_python2, git_sha1_gen_py],
+  capture : true,
+  build_always : true,
 )
 
 subdir('gtest')
-- 
Cheers,
  Eric

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


Re: [Mesa-dev] [PATCH mesa] meson: be explicit about the version required

2017-10-24 Thread Dylan Baker
Quoting Eric Engestrom (2017-10-24 10:32:36)
> On Tuesday, 2017-10-24 09:40:22 -0700, Dylan Baker wrote:
> > This seems reasonable, could you wrap the hanging indent like meson_options 
> > with
> > the closing brace on it's own line and with each option on its own line?
> > ie:
> > project(
> >   mesa
> >   ...
> > )
> 
> Done
> 
> > 
> > With that:
> > Reviewed-by: Dylan Baker 
> 
> Thanks :)
> 
> Before I push it, there was an implied question, let's make it explicit:
> Which version do we want here? How far back do we want to support Meson?
> 
> I don't know much about the history of Meson and of its features, so
> I have no idea how much effort it would be to support some previous
> version.

Well, it's an interesting question. I have tested back to 0.42 now (that's
what's in our CI). If you're using a LLVM and LLVM is in a standard system
location (say /usr/lib) (which is every Linux distro except Debian) and you want
to use PKG_CONFIG_PATH or similar, then you need 0.43.1 (which isn't out yet).
If you want static LLVM linking you'll need 0.44 (all of the LLVM stuff is my
fault, sorry). We have some hacks that could be replaced with standard features
in 0.43.0, but requiring the latest version of meson is kinda mean.

0.41.0 is the absolute oldest we can realistically support. LLVM support landed
in 0.41.0 and there are enough drivers that need LLVM I don't think it's worth
supporting older versions.

I think 0.42 is nice compromise for now. I think we'll ultimately want/need to
bump that requirement.

Dylan


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 04/10] egl: add a missed initialization of buffer age.

2017-10-24 Thread Gwan-gyeong Mun
It add an initialization of buffer age on dri2_surface_set_back_buffer().

Fixes from Emil's review
 - Split out separated patch for adding of missed initialization of buffer
   age. [1]

[1] https://lists.freedesktop.org/archives/mesa-dev/2017-October/173129.html

Signed-off-by: Mun Gwan-gyeong 
---
 src/egl/drivers/dri2/egl_dri2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 2063d1ca56..edb692c7e5 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1104,6 +1104,7 @@ dri2_surface_set_back_buffer(_EGLSurface *surf, void 
*buffer)
for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
   if (!dri2_surf->color_buffers[i].native_buffer) {
  dri2_surf->color_buffers[i].native_buffer = buffer;
+ dri2_surf->color_buffers[i].age = 0;
   }
   if (dri2_surf->color_buffers[i].native_buffer == buffer) {
  dri2_surf->back = _surf->color_buffers[i];
-- 
2.14.2

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


[Mesa-dev] [PATCH v3 09/10] egl: add dri2_surface_get_front_image() helper (v3)

2017-10-24 Thread Gwan-gyeong Mun
To share common get and create dri_image_front code.

In preparation to adding of new platform which uses this helper.

v2:
 - Remove unneeded ifdef magic
 - Fixes from Eric's review:
   a) Split out series of refactor for helpers to a separate series.
   b) Add the new helper function and use them to replace the old code in the
  same patch.

v3: Fixes from Emil and Gurchetan's review
  - Follow the naming convention which prevents too verbose name of functions.
a) use a dri2_surface_$action_$object naming convention
b) change a first argument type "struct dri2_egl_surface" to "_EGLSurface".

Signed-off-by: Mun Gwan-gyeong 
Reviewed-by: Emil Velikov 
---
 src/egl/drivers/dri2/egl_dri2.c | 33 +++
 src/egl/drivers/dri2/egl_dri2.h |  3 +++
 src/egl/drivers/dri2/platform_android.c | 35 +
 3 files changed, 37 insertions(+), 34 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index ed0fff199d..e4ecd4ec09 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1166,6 +1166,39 @@ dri2_surface_destroy_front_image(_EGLSurface *surf)
}
 }
 
+int
+dri2_surface_get_front_image(_EGLSurface *surf, unsigned int format)
+{
+   struct dri2_egl_display *dri2_dpy = 
dri2_egl_display(surf->Resource.Display);
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+   if (dri2_surf->dri_image_front)
+  return 0;
+
+   if (surf->Type == EGL_WINDOW_BIT) {
+  /* According current EGL spec, front buffer rendering
+   * for window surface is not supported now.
+   * and mesa doesn't have the implementation of this case.
+   * Add warning message, but not treat it as error.
+   */
+  _eglLog(_EGL_DEBUG, "DRI driver requested unsupported front buffer for 
window surface");
+   } else if (surf->Type == EGL_PBUFFER_BIT) {
+  dri2_surf->dri_image_front =
+ dri2_dpy->image->createImage(dri2_dpy->dri_screen,
+  surf->Width,
+  surf->Height,
+  format,
+  0,
+  dri2_surf);
+  if (!dri2_surf->dri_image_front) {
+ _eglLog(_EGL_WARNING, "dri2_image_front allocation failed");
+ return -1;
+  }
+   }
+
+   return 0;
+}
+
 /**
  * Called via eglTerminate(), drv->API.Terminate().
  *
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 6415fb22e6..26d0ee986e 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -467,6 +467,9 @@ dri2_surface_destroy_back_image(_EGLSurface *surf);
 void
 dri2_surface_destroy_front_image(_EGLSurface *surf);
 
+int
+dri2_surface_get_front_image(_EGLSurface *surf, unsigned int format);
+
 EGLBoolean
 dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
 _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean 
enable_out_fence);
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 0b84f7221d..3bb85ab4cd 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -386,39 +386,6 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
return 0;
 }
 
-static int
-get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
-{
-   struct dri2_egl_display *dri2_dpy =
-  dri2_egl_display(dri2_surf->base.Resource.Display);
-
-   if (dri2_surf->dri_image_front)
-  return 0;
-
-   if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
-  /* According current EGL spec, front buffer rendering
-   * for window surface is not supported now.
-   * and mesa doesn't have the implementation of this case.
-   * Add warning message, but not treat it as error.
-   */
-  _eglLog(_EGL_DEBUG, "DRI driver requested unsupported front buffer for 
window surface");
-   } else if (dri2_surf->base.Type == EGL_PBUFFER_BIT) {
-  dri2_surf->dri_image_front =
-  dri2_dpy->image->createImage(dri2_dpy->dri_screen,
-  dri2_surf->base.Width,
-  dri2_surf->base.Height,
-  format,
-  0,
-  dri2_surf);
-  if (!dri2_surf->dri_image_front) {
- _eglLog(_EGL_WARNING, "dri2_image_front allocation failed");
- return -1;
-  }
-   }
-
-   return 0;
-}
-
 static int
 get_back_bo(struct dri2_egl_surface *dri2_surf)
 {
@@ -510,7 +477,7 @@ droid_image_get_buffers(__DRIdrawable *driDrawable,
   return 0;
 
if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
-  if (get_front_bo(dri2_surf, format) < 0)
+  if 

[Mesa-dev] [PATCH v3 10/10] egl/wayland: add dri2_wl_free_buffers() helper (v2)

2017-10-24 Thread Gwan-gyeong Mun
This deduplicates free routines of color_buffers array.

v2:
 - Add clear_all argument to check clearing all of color_buffers or not.
 - Fixes from Eric's review:
   a) polish check routine of check_lock and color_buffers[i].locked
   b) move 'native_buffer = NULL' to avoid leaking locked buffers
 - Fixes from Emil's review:
   a) drop the unneeded cast
   b) apply dri2_wl_free_buffers to update_buffers() and swrast_update_buffers()

Signed-off-by: Mun Gwan-gyeong 
---
 src/egl/drivers/dri2/platform_wayland.c | 92 ++---
 1 file changed, 38 insertions(+), 54 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 21037b4547..ad72641478 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -252,6 +252,40 @@ dri2_wl_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay 
*disp,
return NULL;
 }
 
+static void
+dri2_wl_free_buffers(struct dri2_egl_surface *dri2_surf, bool check_lock,
+ bool clear_all)
+{
+   struct dri2_egl_display *dri2_dpy =
+  dri2_egl_display(dri2_surf->base.Resource.Display);
+
+   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+  bool clear_buffer = false;
+
+  if (dri2_surf->color_buffers[i].native_buffer &&
+  (!check_lock || !dri2_surf->color_buffers[i].locked)) {
+ wl_buffer_destroy(dri2_surf->color_buffers[i].native_buffer);
+ dri2_surf->color_buffers[i].native_buffer = NULL;
+ dri2_surf->color_buffers[i].locked = false;
+ clear_buffer = true;
+  }
+
+  if (clear_all || clear_buffer) {
+ if (dri2_surf->color_buffers[i].dri_image)
+
dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].dri_image);
+ if (dri2_surf->color_buffers[i].linear_copy)
+
dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].linear_copy);
+ if (dri2_surf->color_buffers[i].data)
+munmap(dri2_surf->color_buffers[i].data,
+   dri2_surf->color_buffers[i].data_size);
+
+ dri2_surf->color_buffers[i].dri_image = NULL;
+ dri2_surf->color_buffers[i].linear_copy = NULL;
+ dri2_surf->color_buffers[i].data = NULL;
+  }
+   }
+}
+
 /**
  * Called via eglDestroySurface(), drv->API.DestroySurface().
  */
@@ -265,17 +299,7 @@ dri2_wl_destroy_surface(_EGLDriver *drv, _EGLDisplay 
*disp, _EGLSurface *surf)
 
dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable);
 
-   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
-  if (dri2_surf->color_buffers[i].native_buffer)
- wl_buffer_destroy(dri2_surf->color_buffers[i].native_buffer);
-  if (dri2_surf->color_buffers[i].dri_image)
- dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].dri_image);
-  if (dri2_surf->color_buffers[i].linear_copy)
- 
dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].linear_copy);
-  if (dri2_surf->color_buffers[i].data)
- munmap(dri2_surf->color_buffers[i].data,
-dri2_surf->color_buffers[i].data_size);
-   }
+   dri2_wl_free_buffers(dri2_surf, false, true);
 
if (dri2_dpy->dri2)
   dri2_egl_surface_free_local_buffers(dri2_surf);
@@ -307,24 +331,7 @@ dri2_wl_release_buffers(struct dri2_egl_surface *dri2_surf)
struct dri2_egl_display *dri2_dpy =
   dri2_egl_display(dri2_surf->base.Resource.Display);
 
-   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
-  if (dri2_surf->color_buffers[i].native_buffer &&
-  !dri2_surf->color_buffers[i].locked)
- wl_buffer_destroy(dri2_surf->color_buffers[i].native_buffer);
-  if (dri2_surf->color_buffers[i].dri_image)
- dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].dri_image);
-  if (dri2_surf->color_buffers[i].linear_copy)
- 
dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].linear_copy);
-  if (dri2_surf->color_buffers[i].data)
- munmap(dri2_surf->color_buffers[i].data,
-dri2_surf->color_buffers[i].data_size);
-
-  dri2_surf->color_buffers[i].native_buffer = NULL;
-  dri2_surf->color_buffers[i].dri_image = NULL;
-  dri2_surf->color_buffers[i].linear_copy = NULL;
-  dri2_surf->color_buffers[i].data = NULL;
-  dri2_surf->color_buffers[i].locked = false;
-   }
+   dri2_wl_free_buffers(dri2_surf, true, true);
 
if (dri2_dpy->dri2)
   dri2_egl_surface_free_local_buffers(dri2_surf);
@@ -489,9 +496,6 @@ back_bo_to_dri_buffer(struct dri2_egl_surface *dri2_surf, 
__DRIbuffer *buffer)
 static int
 update_buffers(struct dri2_egl_surface *dri2_surf)
 {
-   struct dri2_egl_display *dri2_dpy =
-  dri2_egl_display(dri2_surf->base.Resource.Display);
-
if (dri2_surf->base.Width != dri2_surf->wl_win->width ||
dri2_surf->base.Height != dri2_surf->wl_win->height) {
 
@@ -511,18 +515,7 @@ update_buffers(struct 

[Mesa-dev] [PATCH v3 08/10] egl: add dri2_surface_destroy_front_image() helper (v3)

2017-10-24 Thread Gwan-gyeong Mun
To share common destroy dri_image_front code.

In preparation to adding of new platform which uses this helper.

v2:
 - Move dri_image_front to outside of android ifdef block for removing of
   ifdef magic on dri2_egl_surface_destroy_image_front().
 - Fixes from Eric's review:
   a) Split out series of refactor for helpers to a separate series.
   b) Add the new helper function and use them to replace the old code in the
  same patch.

v3: Fixes from Emil and Gurchetan's review
  - Follow the naming convention which prevents too verbose name of functions.
a) use a dri2_surface_$action_$object naming convention
b) change a first argument type "struct dri2_egl_surface" to "_EGLSurface".

Signed-off-by: Mun Gwan-gyeong 
Reviewed-by: Emil Velikov 
---
 src/egl/drivers/dri2/egl_dri2.c | 12 
 src/egl/drivers/dri2/egl_dri2.h |  5 -
 src/egl/drivers/dri2/platform_android.c |  7 +--
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index dc2aecef88..ed0fff199d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1154,6 +1154,18 @@ dri2_surface_destroy_back_image(_EGLSurface *surf)
}
 }
 
+void
+dri2_surface_destroy_front_image(_EGLSurface *surf)
+{
+   struct dri2_egl_display *dri2_dpy = 
dri2_egl_display(surf->Resource.Display);
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+   if (dri2_surf->dri_image_front) {
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
+  dri2_surf->dri_image_front = NULL;
+   }
+}
+
 /**
  * Called via eglTerminate(), drv->API.Terminate().
  *
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index f13bdb6d12..6415fb22e6 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -304,11 +304,11 @@ struct dri2_egl_surface
} color_buffers[COLOR_BUFFERS_SIZE], *back, *current;
 
__DRIimage *dri_image_back;
+   __DRIimage *dri_image_front;
 
 #ifdef HAVE_ANDROID_PLATFORM
struct ANativeWindow *window;
struct ANativeWindowBuffer *buffer;
-   __DRIimage *dri_image_front;
 #endif
 
 #if defined(HAVE_SURFACELESS_PLATFORM)
@@ -464,6 +464,9 @@ dri2_surface_update_age(_EGLSurface *surf);
 void
 dri2_surface_destroy_back_image(_EGLSurface *surf);
 
+void
+dri2_surface_destroy_front_image(_EGLSurface *surf);
+
 EGLBoolean
 dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
 _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean 
enable_out_fence);
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index e0896ed1a0..0b84f7221d 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -353,12 +353,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surf)
}
 
dri2_surface_destroy_back_image(surf);
-
-   if (dri2_surf->dri_image_front) {
-  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, 
__LINE__);
-  dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
-  dri2_surf->dri_image_front = NULL;
-   }
+   dri2_surface_destroy_front_image(surf);
 
dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable);
 
-- 
2.14.2

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


[Mesa-dev] [PATCH v3 03/10] egl: add dri2_surface_set_back_buffer() helper (v3)

2017-10-24 Thread Gwan-gyeong Mun
To share common record buffers and update back buffer code.
This records all the buffers created by each platform's native window and
update back buffer for updating buffer's age in swap_buffers.

In preparation to adding of new platform which uses this helper.

v2:
 - Remove unneeded ifdef magic
 - Fixes from Eric's review:
   a) Split out series of refactor for helpers to a separate series.
   b) Add the new helper function and use them to replace the old code in the
  same patch.

v3:
  - Fixes from Emil and Gurchetan's review:
Follow the naming convention which prevents too verbose name of functions.
a) use a dri2_surface_$action_$object naming convention
b) change a first argument type "struct dri2_egl_surface" to "_EGLSurface".
  - Fixes from Emil's review:
a) fix typo
b) drop the addition of initialization of buffer age.

Signed-off-by: Mun Gwan-gyeong 
Reviewed-by: Emil Velikov 
---
 src/egl/drivers/dri2/egl_dri2.c | 31 +++
 src/egl/drivers/dri2/egl_dri2.h |  3 +++
 src/egl/drivers/dri2/platform_android.c | 24 +---
 3 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 238e299aed..2063d1ca56 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1092,6 +1092,37 @@ dri2_surface_fixup(_EGLSurface *surf, int width, int 
height)
}
 }
 
+void
+dri2_surface_set_back_buffer(_EGLSurface *surf, void *buffer)
+{
+   /* Record all the buffers created by each platform's native window and
+* update back buffer for updating buffer's age in swap_buffers.
+*/
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+   EGLBoolean updated = EGL_FALSE;
+
+   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+  if (!dri2_surf->color_buffers[i].native_buffer) {
+ dri2_surf->color_buffers[i].native_buffer = buffer;
+  }
+  if (dri2_surf->color_buffers[i].native_buffer == buffer) {
+ dri2_surf->back = _surf->color_buffers[i];
+ updated = EGL_TRUE;
+ break;
+  }
+   }
+
+   if (!updated) {
+  /* In case of all the buffers were recreated, reset the color_buffers */
+  for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ dri2_surf->color_buffers[i].native_buffer = NULL;
+ dri2_surf->color_buffers[i].age = 0;
+  }
+  dri2_surf->color_buffers[0].native_buffer = buffer;
+  dri2_surf->back = _surf->color_buffers[0];
+   }
+}
+
 /**
  * Called via eglTerminate(), drv->API.Terminate().
  *
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 6a218b49aa..4c01959324 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -454,6 +454,9 @@ dri2_egl_surface_free_local_buffers(struct dri2_egl_surface 
*dri2_surf);
 void
 dri2_surface_fixup(_EGLSurface *surf, int width, int height);
 
+void
+dri2_surface_set_back_buffer(_EGLSurface *surf, void *buffer);
+
 EGLBoolean
 dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
 _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean 
enable_out_fence);
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index c254173690..559672ff21 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -191,29 +191,7 @@ droid_window_dequeue_buffer(struct dri2_egl_surface 
*dri2_surf)
/* Record all the buffers created by ANativeWindow and update back buffer
 * for updating buffer's age in swap_buffers.
 */
-   EGLBoolean updated = EGL_FALSE;
-   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
-  if (!dri2_surf->color_buffers[i].native_buffer) {
- dri2_surf->color_buffers[i].native_buffer = dri2_surf->buffer;
-  }
-  if (dri2_surf->color_buffers[i].native_buffer == dri2_surf->buffer) {
- dri2_surf->back = _surf->color_buffers[i];
- updated = EGL_TRUE;
- break;
-  }
-   }
-
-   if (!updated) {
-  /* In case of all the buffers were recreated by ANativeWindow, reset
-   * the color_buffers
-   */
-  for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
- dri2_surf->color_buffers[i].native_buffer = NULL;
- dri2_surf->color_buffers[i].age = 0;
-  }
-  dri2_surf->color_buffers[0].native_buffer = dri2_surf->buffer;
-  dri2_surf->back = _surf->color_buffers[0];
-   }
+   dri2_surface_set_back_buffer(_surf->base, dri2_surf->buffer);
 
return EGL_TRUE;
 }
-- 
2.14.2

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


[Mesa-dev] [PATCH v3 07/10] egl: add dri2_surface_destroy_back_image() helper (v3)

2017-10-24 Thread Gwan-gyeong Mun
To share common destroy dri_image_back code.

In preparation to adding of new platform which uses this helper.

v2:
 - Move dri_image_back to outside of android ifdef block for removing of
   ifdef magic on dri2_egl_surface_destroy_image_back().
 - Fixes from Eric's review:
   a) Split out series of refactor for helpers to a separate series.
   b) Add the new helper function and use them to replace the old code in the
  same patch.

v3: Fixes from Emil and Gurchetan's review
  - Follow the naming convention which prevents too verbose name of functions.
a) use a dri2_surface_$action_$object naming convention
b) change a first argument type "struct dri2_egl_surface" to "_EGLSurface".

Signed-off-by: Mun Gwan-gyeong 
Reviewed-by: Emil Velikov 
---
 src/egl/drivers/dri2/egl_dri2.c | 12 
 src/egl/drivers/dri2/egl_dri2.h |  6 +-
 src/egl/drivers/dri2/platform_android.c | 11 ++-
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d381e52e86..dc2aecef88 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1142,6 +1142,18 @@ dri2_surface_update_age(_EGLSurface *surf)
   dri2_surf->back->age = 1;
 }
 
+void
+dri2_surface_destroy_back_image(_EGLSurface *surf)
+{
+   struct dri2_egl_display *dri2_dpy = 
dri2_egl_display(surf->Resource.Display);
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+   if (dri2_surf->dri_image_back) {
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
+  dri2_surf->dri_image_back = NULL;
+   }
+}
+
 /**
  * Called via eglTerminate(), drv->API.Terminate().
  *
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 58f8082509..f13bdb6d12 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -303,10 +303,11 @@ struct dri2_egl_surface
   int age;
} color_buffers[COLOR_BUFFERS_SIZE], *back, *current;
 
+   __DRIimage *dri_image_back;
+
 #ifdef HAVE_ANDROID_PLATFORM
struct ANativeWindow *window;
struct ANativeWindowBuffer *buffer;
-   __DRIimage *dri_image_back;
__DRIimage *dri_image_front;
 #endif
 
@@ -460,6 +461,9 @@ dri2_surface_set_back_buffer(_EGLSurface *surf, void 
*buffer);
 void
 dri2_surface_update_age(_EGLSurface *surf);
 
+void
+dri2_surface_destroy_back_image(_EGLSurface *surf);
+
 EGLBoolean
 dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
 _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean 
enable_out_fence);
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 45af871555..e0896ed1a0 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -228,10 +228,7 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct 
dri2_egl_surface *dri2_sur
 
mtx_lock(>Mutex);
 
-   if (dri2_surf->dri_image_back) {
-  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
-  dri2_surf->dri_image_back = NULL;
-   }
+   dri2_surface_destroy_back_image(_surf->base);
 
return EGL_TRUE;
 }
@@ -355,11 +352,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surf)
   dri2_surf->window->common.decRef(_surf->window->common);
}
 
-   if (dri2_surf->dri_image_back) {
-  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_back", __func__, 
__LINE__);
-  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
-  dri2_surf->dri_image_back = NULL;
-   }
+   dri2_surface_destroy_back_image(surf);
 
if (dri2_surf->dri_image_front) {
   _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, 
__LINE__);
-- 
2.14.2

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


[Mesa-dev] [PATCH v3 02/10] egl: refactor color_buffers structure for deduplicating (v2)

2017-10-24 Thread Gwan-gyeong Mun
From: "Mun, Gwan-gyeong" 

This is added for preventing adding of new color buffers structure and back*
when new platform backend is added.
This refactoring separates out the common and platform specific bits.
This makes odd casting in the platform_foo.c but it prevents adding of new
ifdef magic.
Because of color_buffers array size is different on android and wayland /drm,
it adds COLOR_BUFFERS_SIZE macro.
 - android's color buffers array size is 3.
   drm & wayland's color buffers array size is 4.

Fixes from Rob's review:
 - refactor to separate out the common and platform specific bits.

Fixes from Emil's review:
 - use suggested color buffers structure shape.
   it makes a buffer pointer of each platform to void pointer type.

v2: Fixes from Emil's review
  a) change ifdef macro of "HAVE_WAYLAND_PLATFORM or HAVE_DRM_PLATFORM" to
 "HAVE_ANDROID_PLATFORM" for COLOR_BUFFERS_SIZE.
  b) drop the unneeded indentation of comment.
  c) drop ifdef macro of HAVE_WAYLAND_PLATFORM from color_buffers structure
 for more generic and widespread helpers.
  d) drop unneeded $native_type -> void * cast and viceversa.
  e) create the local native_buffer of $native_type and cast on assignment.

Signed-off-by: Mun Gwan-gyeong 
---
 src/egl/drivers/dri2/egl_dri2.h | 32 --
 src/egl/drivers/dri2/platform_android.c | 10 +++---
 src/egl/drivers/dri2/platform_drm.c | 60 ++---
 src/egl/drivers/dri2/platform_wayland.c | 41 +++---
 4 files changed, 73 insertions(+), 70 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 208a03d73a..6a218b49aa 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -65,6 +65,15 @@ struct zwp_linux_dmabuf_v1;
 
 #endif /* HAVE_ANDROID_PLATFORM */
 
+#ifdef HAVE_ANDROID_PLATFORM
+/* Usually Android uses at most triple buffers in ANativeWindow so hardcode
+ * the number of color_buffers to 3.
+ */
+#define COLOR_BUFFERS_SIZE 3
+#else
+#define COLOR_BUFFERS_SIZE 4
+#endif
+
 #include "eglconfig.h"
 #include "eglcontext.h"
 #include "egldisplay.h"
@@ -279,39 +288,26 @@ struct dri2_egl_surface
/* EGL-owned buffers */
__DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
 
-#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
+   /* Used to record all the buffers created by each platform's native window
+* and their ages.
+*/
struct {
-#ifdef HAVE_WAYLAND_PLATFORM
-  struct wl_buffer   *wl_buffer;
+  void *native_buffer; // aka wl_buffer/gbm_bo/ANativeWindowBuffer
   __DRIimage *dri_image;
   /* for is_different_gpu case. NULL else */
   __DRIimage *linear_copy;
   /* for swrast */
   void *data;
   int data_size;
-#endif
-#ifdef HAVE_DRM_PLATFORM
-  struct gbm_bo   *bo;
-#endif
   boollocked;
   int age;
-   } color_buffers[4], *back, *current;
-#endif
+   } color_buffers[COLOR_BUFFERS_SIZE], *back, *current;
 
 #ifdef HAVE_ANDROID_PLATFORM
struct ANativeWindow *window;
struct ANativeWindowBuffer *buffer;
__DRIimage *dri_image_back;
__DRIimage *dri_image_front;
-
-   /* Used to record all the buffers created by ANativeWindow and their ages.
-* Usually Android uses at most triple buffers in ANativeWindow
-* so hardcode the number of color_buffers to 3.
-*/
-   struct {
-  struct ANativeWindowBuffer *buffer;
-  int age;
-   } color_buffers[3], *back;
 #endif
 
 #if defined(HAVE_SURFACELESS_PLATFORM)
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index d00aa2..c254173690 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -193,10 +193,10 @@ droid_window_dequeue_buffer(struct dri2_egl_surface 
*dri2_surf)
 */
EGLBoolean updated = EGL_FALSE;
for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
-  if (!dri2_surf->color_buffers[i].buffer) {
- dri2_surf->color_buffers[i].buffer = dri2_surf->buffer;
+  if (!dri2_surf->color_buffers[i].native_buffer) {
+ dri2_surf->color_buffers[i].native_buffer = dri2_surf->buffer;
   }
-  if (dri2_surf->color_buffers[i].buffer == dri2_surf->buffer) {
+  if (dri2_surf->color_buffers[i].native_buffer == dri2_surf->buffer) {
  dri2_surf->back = _surf->color_buffers[i];
  updated = EGL_TRUE;
  break;
@@ -208,10 +208,10 @@ droid_window_dequeue_buffer(struct dri2_egl_surface 
*dri2_surf)
* the color_buffers
*/
   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
- dri2_surf->color_buffers[i].buffer = NULL;
+ dri2_surf->color_buffers[i].native_buffer = NULL;
  dri2_surf->color_buffers[i].age = 0;
   }
-  dri2_surf->color_buffers[0].buffer = dri2_surf->buffer;
+  

[Mesa-dev] [PATCH v3 06/10] egl: add dri2_surface_update_age() helper (v3)

2017-10-24 Thread Gwan-gyeong Mun
To share common update buffer age code.
This updates old buffer's age and sets current back buffer's age to 1.

In preparation to adding of new platform which uses this helper.

v2:
 - Fixes from Eric's review:
   a) Split out series of refactor for helpers to a separate series.
   b) Add the new helper function and use them to replace the old code in the
  same patch.
 - Fixes from Rob's review:
   Remove unneeded ifdef block

v3: Fixes from Emil and Gurchetan's review
  - Follow the naming convention which prevents too verbose name of functions.
a) use a dri2_surface_$action_$object naming convention
b) change a first argument type "struct dri2_egl_surface" to "_EGLSurface".

Signed-off-by: Mun Gwan-gyeong 
Reviewed-by: Emil Velikov 
---
 src/egl/drivers/dri2/egl_dri2.c | 16 
 src/egl/drivers/dri2/egl_dri2.h |  3 +++
 src/egl/drivers/dri2/platform_android.c | 11 +--
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index a504978fda..d381e52e86 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1126,6 +1126,22 @@ dri2_surface_set_back_buffer(_EGLSurface *surf, void 
*buffer)
}
 }
 
+void
+dri2_surface_update_age(_EGLSurface *surf)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+  if (dri2_surf->color_buffers[i].age > 0)
+ dri2_surf->color_buffers[i].age++;
+   }
+
+   /* "XXX: we don't use get_back_bo() since it causes regressions in
+* several dEQP tests.
+*/
+   if (dri2_surf->back)
+  dri2_surf->back->age = 1;
+}
+
 /**
  * Called via eglTerminate(), drv->API.Terminate().
  *
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 4c01959324..58f8082509 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -457,6 +457,9 @@ dri2_surface_fixup(_EGLSurface *surf, int width, int 
height);
 void
 dri2_surface_set_back_buffer(_EGLSurface *surf, void *buffer);
 
+void
+dri2_surface_update_age(_EGLSurface *surf);
+
 EGLBoolean
 dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
 _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean 
enable_out_fence);
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 559672ff21..45af871555 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -567,16 +567,7 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *draw)
if (dri2_surf->base.Type != EGL_WINDOW_BIT)
   return EGL_TRUE;
 
-   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
-  if (dri2_surf->color_buffers[i].age > 0)
- dri2_surf->color_buffers[i].age++;
-   }
-
-   /* "XXX: we don't use get_back_bo() since it causes regressions in
-* several dEQP tests.
-*/
-   if (dri2_surf->back)
-  dri2_surf->back->age = 1;
+   dri2_surface_update_age(draw);
 
dri2_flush_drawable_for_swapbuffers(disp, draw);
 
-- 
2.14.2

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


[Mesa-dev] [PATCH v3 05/10] egl: add going out of the loop when color_buffer is set.

2017-10-24 Thread Gwan-gyeong Mun
If color_buffer is set once, we don't need to set a same native buffer to
remained free slot of color_buffers. So we can go out of the loop when
color_buffer is set first.

Fixes from Emil's review
 - Add setting "updated" and bailing out when the color_buffer is set.[1]

[1] https://lists.freedesktop.org/archives/mesa-dev/2017-October/173129.html

Signed-off-by: Mun Gwan-gyeong 
---
 src/egl/drivers/dri2/egl_dri2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index edb692c7e5..a504978fda 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1105,6 +1105,8 @@ dri2_surface_set_back_buffer(_EGLSurface *surf, void 
*buffer)
   if (!dri2_surf->color_buffers[i].native_buffer) {
  dri2_surf->color_buffers[i].native_buffer = buffer;
  dri2_surf->color_buffers[i].age = 0;
+ updated = EGL_TRUE;
+ break;
   }
   if (dri2_surf->color_buffers[i].native_buffer == buffer) {
  dri2_surf->back = _surf->color_buffers[i];
-- 
2.14.2

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


[Mesa-dev] [PATCH v3 01/10] egl: add dri2_surface_fixup() helper (v3)

2017-10-24 Thread Gwan-gyeong Mun
From: "Mun, Gwan-gyeong" 

To share common free outdated buffers and update size code.
This compares width and height arguments with current egl surface dimension,
if the compared surface dimension is differ, then it free local buffers and
updates dimension.

In preparation to adding of new platform which uses this helper.

v2: Fixes from Eric's review:
   a) Split out series of refactor for helpers to a separate series.
   b) Add the new helper function and use them to replace the old code in the
  same patch.

v3: Fixes from Emil and Gurchetan's review
  - Follow the naming convention which prevents too verbose name of functions.
a) use a dri2_surface_$action_$object naming convention
b) change a first argument type "struct dri2_egl_surface" to "_EGLSurface".

Signed-off-by: Mun Gwan-gyeong 
Reviewed-by: Emil Velikov 
---
 src/egl/drivers/dri2/egl_dri2.c | 13 +
 src/egl/drivers/dri2/egl_dri2.h |  3 +++
 src/egl/drivers/dri2/platform_android.c |  8 ++--
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 503450542e..238e299aed 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1079,6 +1079,19 @@ dri2_egl_surface_free_local_buffers(struct 
dri2_egl_surface *dri2_surf)
}
 }
 
+void
+dri2_surface_fixup(_EGLSurface *surf, int width, int height)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+   /* free outdated buffers and update the surface size */
+   if (surf->Width != width || surf->Height != height) {
+  dri2_egl_surface_free_local_buffers(dri2_surf);
+  surf->Width = width;
+  surf->Height = height;
+   }
+}
+
 /**
  * Called via eglTerminate(), drv->API.Terminate().
  *
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index cd2487ab22..208a03d73a 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -455,6 +455,9 @@ dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface 
*dri2_surf,
 void
 dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf);
 
+void
+dri2_surface_fixup(_EGLSurface *surf, int width, int height);
+
 EGLBoolean
 dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
 _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean 
enable_out_fence);
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index e390365b8b..d00aa2 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -414,12 +414,8 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
}
 
/* free outdated buffers and update the surface size */
-   if (dri2_surf->base.Width != dri2_surf->buffer->width ||
-   dri2_surf->base.Height != dri2_surf->buffer->height) {
-  dri2_egl_surface_free_local_buffers(dri2_surf);
-  dri2_surf->base.Width = dri2_surf->buffer->width;
-  dri2_surf->base.Height = dri2_surf->buffer->height;
-   }
+   dri2_surface_fixup(_surf->base, dri2_surf->buffer->width,
+  dri2_surf->buffer->height);
 
return 0;
 }
-- 
2.14.2

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


Re: [Mesa-dev] [PATCH] i965: Disable L3 cache allocation for external buffers

2017-10-24 Thread Jason Ekstrand
On Tue, Oct 24, 2017 at 2:10 PM, Chris Wilson 
wrote:

> Quoting Jason Ekstrand (2017-10-24 22:03:36)
> > On Tue, Oct 24, 2017 at 9:06 AM, Chris Wilson 
> wrote:
> >
> > Through the use of mocs, we can define the cache usage for any
> surface
> > used by the GPU. In particular, we can request that L3 cache be
> > allocated for either a read/write miss so that subsequent reads can
> be
> > fetched from cache rather than memory. A consequence of this is that
> if
> > we allocate a L3/LLC cacheline for a read and the object is changed
> in
> > main memory (e.g. a PCIe write bypassing the CPU) then the next read
> > will be serviced from the stale cache and not from the new data in
> > memory. This is an issue for external PRIME buffers where we may miss
> > the updates entirely if the image is small enough to fit within our
> > cache.
> >
> > Currently, we have a single bit to mark all external buffers so use
> that
> > to tell us when it is unsafe to use a cache override in mocs and
> > fallback to the PTE value instead (which should be set to the correct
> > cache level to be coherent amongst all active parties: PRIME,
> scanout and
> > render). This may be refined in future to limit the override to
> buffers
> > outside the control of mesa; as buffers being shared between mesa
> > clients should be able to coordinate themselves without resolves.
> >
> > Why are we throwing away L3 caching here and in gen7 above?  We should
> be able
> > to handle L3 caching with manual texture/render cache
> invalidates/flushes.  Our
> > performance is already going to be not great with linear buffers with no
> LLC,
> > we shouldn't kill it completely.
>
> Because the L3 is shadowing the updates in memory (that bypass the
> ring/system-agent entirely) and not being invalidated. When you then
> read back from the L3/LLC you get stale data.
>

I'm having a bit of trouble parsing that.  Are you saying that the L3 is
trying to pull from the LLC even though we've disabled it through the PTE?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Disable L3 cache allocation for external buffers

2017-10-24 Thread Chris Wilson
Quoting Jason Ekstrand (2017-10-24 22:03:36)
> On Tue, Oct 24, 2017 at 9:06 AM, Chris Wilson  
> wrote:
> 
> Through the use of mocs, we can define the cache usage for any surface
> used by the GPU. In particular, we can request that L3 cache be
> allocated for either a read/write miss so that subsequent reads can be
> fetched from cache rather than memory. A consequence of this is that if
> we allocate a L3/LLC cacheline for a read and the object is changed in
> main memory (e.g. a PCIe write bypassing the CPU) then the next read
> will be serviced from the stale cache and not from the new data in
> memory. This is an issue for external PRIME buffers where we may miss
> the updates entirely if the image is small enough to fit within our
> cache.
> 
> Currently, we have a single bit to mark all external buffers so use that
> to tell us when it is unsafe to use a cache override in mocs and
> fallback to the PTE value instead (which should be set to the correct
> cache level to be coherent amongst all active parties: PRIME, scanout and
> render). This may be refined in future to limit the override to buffers
> outside the control of mesa; as buffers being shared between mesa
> clients should be able to coordinate themselves without resolves.
> 
> Why are we throwing away L3 caching here and in gen7 above?  We should be able
> to handle L3 caching with manual texture/render cache invalidates/flushes.  
> Our
> performance is already going to be not great with linear buffers with no LLC,
> we shouldn't kill it completely.

Because the L3 is shadowing the updates in memory (that bypass the
ring/system-agent entirely) and not being invalidated. When you then
read back from the L3/LLC you get stale data.
-Chris
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Disable L3 cache allocation for external buffers

2017-10-24 Thread Jason Ekstrand
On Tue, Oct 24, 2017 at 9:06 AM, Chris Wilson 
wrote:

> Through the use of mocs, we can define the cache usage for any surface
> used by the GPU. In particular, we can request that L3 cache be
> allocated for either a read/write miss so that subsequent reads can be
> fetched from cache rather than memory. A consequence of this is that if
> we allocate a L3/LLC cacheline for a read and the object is changed in
> main memory (e.g. a PCIe write bypassing the CPU) then the next read
> will be serviced from the stale cache and not from the new data in
> memory. This is an issue for external PRIME buffers where we may miss
> the updates entirely if the image is small enough to fit within our
> cache.
>
> Currently, we have a single bit to mark all external buffers so use that
> to tell us when it is unsafe to use a cache override in mocs and
> fallback to the PTE value instead (which should be set to the correct
> cache level to be coherent amongst all active parties: PRIME, scanout and
> render). This may be refined in future to limit the override to buffers
> outside the control of mesa; as buffers being shared between mesa
> clients should be able to coordinate themselves without resolves.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101691
> Cc: Kenneth Graunke 
> Cc: Jason Ekstrand 
> Cc: Lyude Paul 
> Cc: Timo Aalton 
> Cc: Ben Widawsky 
> Cc: Daniel Vetter 
> ---
>  src/intel/blorp/blorp.c  |  1 +
>  src/intel/blorp/blorp.h  |  1 +
>  src/intel/blorp/blorp_genX_exec.h|  2 +-
>  src/intel/blorp/blorp_priv.h |  1 +
>  src/mesa/drivers/dri/i965/brw_blorp.c|  1 +
>  src/mesa/drivers/dri/i965/brw_state.h|  3 ++-
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 16 +++-
>  7 files changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/src/intel/blorp/blorp.c b/src/intel/blorp/blorp.c
> index 7cc6335f2f..459ad66652 100644
> --- a/src/intel/blorp/blorp.c
> +++ b/src/intel/blorp/blorp.c
> @@ -71,6 +71,7 @@ brw_blorp_surface_info_init(struct blorp_context *blorp,
> surf->surf->logical_level0_px.array_len));
>
> info->enabled = true;
> +   info->external = surf->external;
>
> if (format == ISL_FORMAT_UNSUPPORTED)
>format = surf->surf->format;
> diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h
> index 9716c66302..af056c9d52 100644
> --- a/src/intel/blorp/blorp.h
> +++ b/src/intel/blorp/blorp.h
> @@ -106,6 +106,7 @@ struct blorp_surf
> enum isl_aux_usage aux_usage;
>
> union isl_color_value clear_color;
> +   bool external;
>  };
>
>  void
> diff --git a/src/intel/blorp/blorp_genX_exec.h
> b/src/intel/blorp/blorp_genX_exec.h
> index 5389262098..18715788ff 100644
> --- a/src/intel/blorp/blorp_genX_exec.h
> +++ b/src/intel/blorp/blorp_genX_exec.h
> @@ -1328,7 +1328,7 @@ blorp_emit_surface_states(struct blorp_batch *batch,
>   blorp_emit_surface_state(batch, >src,
>surface_maps[BLORP_TEXTURE_BT_INDEX],
>surface_offsets[BLORP_TEXTURE_
> BT_INDEX],
> -  NULL, false);
> +  NULL, params->src.external);
>}
> }
>
> diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
> index c7d5d308da..f841aa7cdc 100644
> --- a/src/intel/blorp/blorp_priv.h
> +++ b/src/intel/blorp/blorp_priv.h
> @@ -47,6 +47,7 @@ enum {
>  struct brw_blorp_surface_info
>  {
> bool enabled;
> +   bool external;
>
> struct isl_surf surf;
> struct blorp_address addr;
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c
> b/src/mesa/drivers/dri/i965/brw_blorp.c
> index ed4f9870f2..563d13a037 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp.c
> +++ b/src/mesa/drivers/dri/i965/brw_blorp.c
> @@ -160,6 +160,7 @@ blorp_surf_for_miptree(struct brw_context *brw,
>.offset = mt->offset,
>.reloc_flags = is_render_target ? EXEC_OBJECT_WRITE : 0,
> };
> +   surf->external = mt->bo->external;
>
> surf->aux_usage = aux_usage;
>
> diff --git a/src/mesa/drivers/dri/i965/brw_state.h
> b/src/mesa/drivers/dri/i965/brw_state.h
> index 8db354cf23..01c0cd12cb 100644
> --- a/src/mesa/drivers/dri/i965/brw_state.h
> +++ b/src/mesa/drivers/dri/i965/brw_state.h
> @@ -342,6 +342,7 @@ void gen10_init_atoms(struct brw_context *brw);
>   * may still respect that.
>   */
>  #define GEN7_MOCS_L31
> +#define GEN7_MOCS_PTE   0
>
>  /* Ivybridge only: cache in LLC.
>   * Specifying zero here means to use the PTE values set by the kernel;
> @@ -367,7 +368,7 @@ void gen10_init_atoms(struct brw_context *brw);
>   */
>  #define BDW_MOCS_WB  0x78
>  #define BDW_MOCS_WT  0x58
> -#define BDW_MOCS_PTE 0x18
> 

Re: [Mesa-dev] [PATCH 2/3] freedreno: context priority support

2017-10-24 Thread Rob Clark
On Tue, Oct 24, 2017 at 3:34 PM, Emil Velikov  wrote:
> On 24 October 2017 at 19:48, Rob Clark  wrote:
>> For devices (and kernels) which support different priority ringbuffers,
>> expose context priority support.
>>
>> Signed-off-by: Rob Clark 
>> ---
>>  src/gallium/drivers/freedreno/freedreno_context.c |  9 -
>>  src/gallium/drivers/freedreno/freedreno_screen.c  | 12 +++-
>>  src/gallium/drivers/freedreno/freedreno_screen.h  |  1 +
>>  3 files changed, 20 insertions(+), 2 deletions(-)
>>
>
>> ctx->screen = screen;
>> -   ctx->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D);
>> +   ctx->pipe = fd_pipe_new2(screen->dev, FD_PIPE_3D, prio);
>>
> Would imagine you want to get the libdrm_freedreno bits out and bump
> the required version in configure/meson.
> Right? Did the kernel bits already land?
>

Right, sorry, I should have mentioned the freedreno part of this isn't
ready to push, but I'm posting these patches to go along with kernel
patches that I'm lining up for 4.15.

fwiw, the libdrm bits are here:

  https://github.com/freedreno/libdrm/commits/context-priority

The final version would need configure and meson version bumps to a
libdrm version from the future ;-)

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


Re: [Mesa-dev] [PATCH 2/3] freedreno: context priority support

2017-10-24 Thread Emil Velikov
On 24 October 2017 at 19:48, Rob Clark  wrote:
> For devices (and kernels) which support different priority ringbuffers,
> expose context priority support.
>
> Signed-off-by: Rob Clark 
> ---
>  src/gallium/drivers/freedreno/freedreno_context.c |  9 -
>  src/gallium/drivers/freedreno/freedreno_screen.c  | 12 +++-
>  src/gallium/drivers/freedreno/freedreno_screen.h  |  1 +
>  3 files changed, 20 insertions(+), 2 deletions(-)
>

> ctx->screen = screen;
> -   ctx->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D);
> +   ctx->pipe = fd_pipe_new2(screen->dev, FD_PIPE_3D, prio);
>
Would imagine you want to get the libdrm_freedreno bits out and bump
the required version in configure/meson.
Right? Did the kernel bits already land?

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


Re: [Mesa-dev] [Mesa-stable] [PATCH 2/2] auxiliary: use vl_drm_screen_create method for surfaceless

2017-10-24 Thread Emil Velikov
On 24 October 2017 at 02:26, Sharma, Deepak  wrote:
> Hi Emil,
>
> Is your suggestion is to build mesa in chrome using --with-platforms=drm and 
> --with-platforms=surfaceless both ? I am not sure if that is required for 
> chrome.
> The approach we are taking here is to build mesa only with 
> --with-platforms=surfaceless and leverage existing
> VA_DISPLAY_DRM* to get VAAPI working on Chrome for platform.
>
My suggestion is to fix the problem instead of working around it.

> Thus the solution here really is:
>  - decouple the link-time dependency to a (once-off) runtime one
>  - and(?) demote the configure error to a warning ;-) Right?
>
The goal ^^

Note I'm talking about the GBM link-time dependency in EGL.
Just use a dlopen(RTLD_LOCAL | RTLD_NOW) /dlsym/dlclose.

> While we're there we could/should:
>  - drop the (first_pointer == gbm_create_device) hack Replace with 
> dladdr(first_pointer, ) + strcmp(info.dli_sname,
> "gbm_create_device") combo
>  - make egl_dri2.c free of calls into gbm - only gbm_device_destroy remains 
> Move the remaining gbm_device_destroy to platform_drm.c
>
^^ some implementation suggestions, although you can handle it otherwise.

> Bonus points:
>  - Add ABI and/or version check for Mesa GBM <> EGL interop.
>
^^ completely optional, related work.

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


Re: [Mesa-dev] [PATCH] radv: allow to use a compute shader for resetting the query pool

2017-10-24 Thread Samuel Pitoiset



On 10/24/2017 09:00 PM, Bas Nieuwenhuizen wrote:

Can you run this through CTS? Kind of worried about cache flushes when
using a compute shader.


Yeah, I will try to run CTS during the night. Thanks.



Otherwise r-b

On Tue, Oct 24, 2017 at 2:02 PM, Samuel Pitoiset
 wrote:

Serious Sam Fusion 2017 uses a huge number of occlusion queries,
and the allocated query pool buffer is greater than 4096 bytes.

This slightly improves performance (tested in Ultra) from
117.2 FPS to 119.7 FPS (~+2%) on my RX480.

Signed-off-by: Samuel Pitoiset 
---
  src/amd/vulkan/radv_query.c | 11 +--
  1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/amd/vulkan/radv_query.c b/src/amd/vulkan/radv_query.c
index 06045d6b41..1711f604a6 100644
--- a/src/amd/vulkan/radv_query.c
+++ b/src/amd/vulkan/radv_query.c
@@ -1058,16 +1058,15 @@ void radv_CmdResetQueryPool(
  {
 RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
 RADV_FROM_HANDLE(radv_query_pool, pool, queryPool);
-   uint64_t va = radv_buffer_get_va(pool->bo);

-   cmd_buffer->device->ws->cs_add_buffer(cmd_buffer->cs, pool->bo, 8);
+   radv_fill_buffer(cmd_buffer, pool->bo, firstQuery * pool->stride,
+queryCount * pool->stride, 0);

-   si_cp_dma_clear_buffer(cmd_buffer, va + firstQuery * pool->stride,
-  queryCount * pool->stride, 0);
 if (pool->type == VK_QUERY_TYPE_TIMESTAMP ||
 pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS)
-   si_cp_dma_clear_buffer(cmd_buffer, va + 
pool->availability_offset + firstQuery * 4,
-  queryCount * 4, 0);
+   radv_fill_buffer(cmd_buffer, pool->bo,
+pool->availability_offset + firstQuery * 4,
+queryCount * 4, 0);
  }

  void radv_CmdBeginQuery(
--
2.14.2

___
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] radv: allow to use a compute shader for resetting the query pool

2017-10-24 Thread Bas Nieuwenhuizen
Can you run this through CTS? Kind of worried about cache flushes when
using a compute shader.

Otherwise r-b

On Tue, Oct 24, 2017 at 2:02 PM, Samuel Pitoiset
 wrote:
> Serious Sam Fusion 2017 uses a huge number of occlusion queries,
> and the allocated query pool buffer is greater than 4096 bytes.
>
> This slightly improves performance (tested in Ultra) from
> 117.2 FPS to 119.7 FPS (~+2%) on my RX480.
>
> Signed-off-by: Samuel Pitoiset 
> ---
>  src/amd/vulkan/radv_query.c | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_query.c b/src/amd/vulkan/radv_query.c
> index 06045d6b41..1711f604a6 100644
> --- a/src/amd/vulkan/radv_query.c
> +++ b/src/amd/vulkan/radv_query.c
> @@ -1058,16 +1058,15 @@ void radv_CmdResetQueryPool(
>  {
> RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
> RADV_FROM_HANDLE(radv_query_pool, pool, queryPool);
> -   uint64_t va = radv_buffer_get_va(pool->bo);
>
> -   cmd_buffer->device->ws->cs_add_buffer(cmd_buffer->cs, pool->bo, 8);
> +   radv_fill_buffer(cmd_buffer, pool->bo, firstQuery * pool->stride,
> +queryCount * pool->stride, 0);
>
> -   si_cp_dma_clear_buffer(cmd_buffer, va + firstQuery * pool->stride,
> -  queryCount * pool->stride, 0);
> if (pool->type == VK_QUERY_TYPE_TIMESTAMP ||
> pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS)
> -   si_cp_dma_clear_buffer(cmd_buffer, va + 
> pool->availability_offset + firstQuery * 4,
> -  queryCount * 4, 0);
> +   radv_fill_buffer(cmd_buffer, pool->bo,
> +pool->availability_offset + firstQuery * 4,
> +queryCount * 4, 0);
>  }
>
>  void radv_CmdBeginQuery(
> --
> 2.14.2
>
> ___
> 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] radv: print NIR before LLVM IR and disassembly

2017-10-24 Thread Bas Nieuwenhuizen
yay, bikeshedding. Fair enough though, r-b.

On Tue, Oct 24, 2017 at 5:23 PM, Samuel Pitoiset
 wrote:
> It's still printed after linking, but it makes more sense to
> have SPIRV->NIR->LLVM IR->ASM.
>
> Fixes: f0a2bbd1a4 (radv: move nir print after linking is done)
> Signed-off-by: Samuel Pitoiset 
> ---
>  src/amd/vulkan/radv_pipeline.c | 17 ++---
>  1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
> index d6b33a5327..7ad09cec83 100644
> --- a/src/amd/vulkan/radv_pipeline.c
> +++ b/src/amd/vulkan/radv_pipeline.c
> @@ -1786,6 +1786,14 @@ void radv_create_shaders(struct radv_pipeline 
> *pipeline,
>
> radv_link_shaders(pipeline, nir);
>
> +   for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
> +   if (!(device->instance->debug_flags & 
> RADV_DEBUG_DUMP_SHADERS))
> +   continue;
> +
> +   if (modules[i])
> +   nir_print_shader(nir[i], stderr);
> +   }
> +
> if (nir[MESA_SHADER_FRAGMENT]) {
> if (!pipeline->shaders[MESA_SHADER_FRAGMENT]) {
> pipeline->shaders[MESA_SHADER_FRAGMENT] =
> @@ -1870,13 +1878,8 @@ void radv_create_shaders(struct radv_pipeline 
> *pipeline,
>
> for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
> free(codes[i]);
> -   if (modules[i]) {
> -   if (device->instance->debug_flags & 
> RADV_DEBUG_DUMP_SHADERS)
> -   nir_print_shader(nir[i], stderr);
> -
> -   if (!pipeline->device->trace_bo)
> -   ralloc_free(nir[i]);
> -   }
> +   if (modules[i] && !pipeline->device->trace_bo)
> +   ralloc_free(nir[i]);
> }
>
> if (fs_m.nir)
> --
> 2.14.2
>
> ___
> 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 1/2] mesa: enum checks for GL_EXT_occlusion_query_boolean

2017-10-24 Thread Eric Anholt
Tapani Pälli  writes:

> Some of the checks are valid for generic ES 3.2 as well.
>
> Signed-off-by: Tapani Pälli 
> ---
>  src/mesa/main/queryobj.c | 44 
>  1 file changed, 44 insertions(+)
>
> diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
> index 46535d7b4c..d966814a76 100644
> --- a/src/mesa/main/queryobj.c
> +++ b/src/mesa/main/queryobj.c
> @@ -165,6 +165,20 @@ get_pipe_stats_binding_point(struct gl_context *ctx,
>  static struct gl_query_object **
>  get_query_binding_point(struct gl_context *ctx, GLenum target, GLuint index)
>  {
> +
> +   /* From GL_EXT_occlusion_query_boolean spec:
> +*
> +*"Accepted by the  parameter of BeginQueryEXT, EndQueryEXT,
> +*and GetQueryivEXT:
> +*
> +*   ANY_SAMPLES_PASSED_EXT 0x8C2F
> +*   ANY_SAMPLES_PASSED_CONSERVATIVE_EXT0x8D6A"
> +*/
> +   if ((_mesa_is_gles(ctx) && ctx->Version == 20) &&
> +   (target != GL_ANY_SAMPLES_PASSED &&
> +target != GL_ANY_SAMPLES_PASSED_CONSERVATIVE))
> +  return NULL;
> +
> switch (target) {
> case GL_SAMPLES_PASSED_ARB:
>if (ctx->Extensions.ARB_occlusion_query)
> @@ -649,6 +663,19 @@ _mesa_GetQueryIndexediv(GLenum target, GLuint index, 
> GLenum pname,
> if (!query_error_check_index(ctx, target, index))
>return;
>  
> +   /* From the GL_EXT_occlusion_query_boolean spec:
> +*
> +* "The error INVALID_ENUM is generated if GetQueryivEXT is called where
> +*  is not CURRENT_QUERY_EXT."
> +*
> +* Same rule is present also in ES 3.2 spec.
> +*/
> +   if (_mesa_is_gles(ctx) && pname != GL_CURRENT_QUERY) {
> +  _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivEXT(%s)",
> +  _mesa_enum_to_string(pname));
> +  return;
> +   }

Huh, apparently QUERY_COUNTER_BITS isn't valid on GLES at all until
disjoint_timer_query shows up!

Reviewed-by: Eric Anholt 


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


Re: [Mesa-dev] [PATCH 2/2] gles2: support for GL_EXT_occlusion_query_boolean

2017-10-24 Thread Eric Anholt
Tapani Pälli  writes:

> From: Harish Krupo 
>
> Following test checking entrypoints passes:
>
> dEQP-EGL.functional.get_proc_address.extension.gl_ext_occlusion_query_boolean
>
> Piglit test 'ext_occlusion_query_boolean-any-samples' passes with these 
> changes.
>
> No changes/regression observed in WebGL occlusion tests or Intel CI.
>
> v2: add es2="2.0" for glapi entrypoints, clean up xml
> dispatch_sanity changes (fix 'make check')
>
> Signed-off-by: Harish Krupo 
> Signed-off-by: Tapani Pälli 
> ---
>  src/mapi/glapi/gen/es_EXT.xml   | 51 
> +
>  src/mesa/main/extensions_table.h|  1 +
>  src/mesa/main/tests/dispatch_sanity.cpp | 31 +++-
>  3 files changed, 76 insertions(+), 7 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml
> index 3a2bdb2fdc..a09ff969c6 100644
> --- a/src/mapi/glapi/gen/es_EXT.xml
> +++ b/src/mapi/glapi/gen/es_EXT.xml
> @@ -751,6 +751,57 @@
>  
>  
>  
> +
> +

I think you want number="100"

Other than that, this patch is:

Reviewed-by: Eric Anholt 


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


[Mesa-dev] [Bug 103388] Linking libcltgsi.la (llvm/codegen/libclllvm_la-common.lo) fails with "error: no match for 'operator-'" with GCC-7, Mesa from Git and current LLVM revisions

2017-10-24 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103388

LoneVVolf  changed:

   What|Removed |Added

 CC||lonew...@xs4all.nl

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


[Mesa-dev] [PATCH 3/3] freedreno: add debug flag to force high priority context

2017-10-24 Thread Rob Clark
Mainly for testing, FD_MESA_DEBUG=hiprio will force high priority
contexts.

Signed-off-by: Rob Clark 
---
 src/gallium/drivers/freedreno/freedreno_context.c | 4 +++-
 src/gallium/drivers/freedreno/freedreno_screen.c  | 1 +
 src/gallium/drivers/freedreno/freedreno_util.h| 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_context.c 
b/src/gallium/drivers/freedreno/freedreno_context.c
index 7fdb848f380..fe46f710b87 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -253,7 +253,9 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen 
*pscreen,
int i;
 
/* lower numerical value == higher priority: */
-   if (flags & PIPE_CONTEXT_HIGH_PRIORITY)
+   if (fd_mesa_debug & FD_DBG_HIPRIO)
+   prio = 0;
+   else if (flags & PIPE_CONTEXT_HIGH_PRIORITY)
prio = 0;
else if (flags & PIPE_CONTEXT_LOW_PRIORITY)
prio = 2;
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 02b7a3795ba..fbfac9350e5 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -79,6 +79,7 @@ static const struct debug_named_value debug_options[] = {
{"bstat", FD_DBG_BSTAT,  "Print batch stats at context 
destroy"},
{"nogrow",FD_DBG_NOGROW, "Disable \"growable\" cmdstream 
buffers, even if kernel supports it"},
{"lrz",   FD_DBG_LRZ,"Enable experimental LRZ support 
(a5xx+)"},
+   {"hiprio",FD_DBG_HIPRIO, "Force high-priority context"},
DEBUG_NAMED_VALUE_END
 };
 
diff --git a/src/gallium/drivers/freedreno/freedreno_util.h 
b/src/gallium/drivers/freedreno/freedreno_util.h
index 14fcf1d6725..3ef669ca861 100644
--- a/src/gallium/drivers/freedreno/freedreno_util.h
+++ b/src/gallium/drivers/freedreno/freedreno_util.h
@@ -80,6 +80,7 @@ enum adreno_stencil_op fd_stencil_op(unsigned op);
 #define FD_DBG_BSTAT0x8000
 #define FD_DBG_NOGROW  0x1
 #define FD_DBG_LRZ 0x2
+#define FD_DBG_HIPRIO  0x4
 
 extern int fd_mesa_debug;
 extern bool fd_binning_enabled;
-- 
2.13.6

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


[Mesa-dev] [PATCH 2/3] freedreno: context priority support

2017-10-24 Thread Rob Clark
For devices (and kernels) which support different priority ringbuffers,
expose context priority support.

Signed-off-by: Rob Clark 
---
 src/gallium/drivers/freedreno/freedreno_context.c |  9 -
 src/gallium/drivers/freedreno/freedreno_screen.c  | 12 +++-
 src/gallium/drivers/freedreno/freedreno_screen.h  |  1 +
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_context.c 
b/src/gallium/drivers/freedreno/freedreno_context.c
index 20480f4f8c1..7fdb848f380 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -249,10 +249,17 @@ fd_context_init(struct fd_context *ctx, struct 
pipe_screen *pscreen,
 {
struct fd_screen *screen = fd_screen(pscreen);
struct pipe_context *pctx;
+   unsigned prio = 1;
int i;
 
+   /* lower numerical value == higher priority: */
+   if (flags & PIPE_CONTEXT_HIGH_PRIORITY)
+   prio = 0;
+   else if (flags & PIPE_CONTEXT_LOW_PRIORITY)
+   prio = 2;
+
ctx->screen = screen;
-   ctx->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D);
+   ctx->pipe = fd_pipe_new2(screen->dev, FD_PIPE_3D, prio);
 
ctx->primtypes = primtypes;
ctx->primtype_mask = 0;
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 6eed09dc09f..02b7a3795ba 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -327,9 +327,11 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_LOAD_CONSTBUF:
case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
case PIPE_CAP_TILE_RASTER_ORDER:
-   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
return 0;
 
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
+   return screen->priority_mask;
+
case PIPE_CAP_MAX_VIEWPORTS:
return 1;
 
@@ -805,6 +807,14 @@ fd_screen_create(struct fd_device *dev)
}
screen->chip_id = val;
 
+   if (fd_pipe_get_param(screen->pipe, FD_NR_RINGS, )) {
+   DBG("could not get # of rings");
+   screen->priority_mask = 0;
+   } else {
+   /* # of rings equates to number of unique priority values: */
+   screen->priority_mask = (1 << val) - 1;
+   }
+
DBG("Pipe Info:");
DBG(" GPU-id:  %d", screen->gpu_id);
DBG(" Chip-id: 0x%08x", screen->chip_id);
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h 
b/src/gallium/drivers/freedreno/freedreno_screen.h
index 68518ef721b..d5e497d4f65 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.h
+++ b/src/gallium/drivers/freedreno/freedreno_screen.h
@@ -67,6 +67,7 @@ struct fd_screen {
uint32_t max_rts;/* max # of render targets */
uint32_t gmem_alignw, gmem_alignh;
uint32_t num_vsc_pipes;
+   uint32_t priority_mask;
bool has_timestamp;
 
void *compiler;  /* currently unused for a2xx */
-- 
2.13.6

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


[Mesa-dev] [PATCH 1/3] gallium: plumb context priority through to driver

2017-10-24 Thread Rob Clark
Signed-off-by: Rob Clark 
Reviewed-by: Roland Scheidegger 
Reviewed-by: Marek Olšák 
Reviewed-by: Andres Rodriguez 
Reviewed-by: Wladimir J. van der Laan 
---
Sorry, it took me a while to get back to this..

v2: add docs blurb, fix si_get_param(), rebase

 src/gallium/docs/source/screen.rst  |  4 
 src/gallium/drivers/etnaviv/etnaviv_screen.c|  1 +
 src/gallium/drivers/freedreno/freedreno_screen.c|  1 +
 src/gallium/drivers/i915/i915_screen.c  |  1 +
 src/gallium/drivers/llvmpipe/lp_screen.c|  1 +
 src/gallium/drivers/nouveau/nv30/nv30_screen.c  |  1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.c  |  1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c  |  1 +
 src/gallium/drivers/r300/r300_screen.c  |  1 +
 src/gallium/drivers/r600/r600_pipe.c|  1 +
 src/gallium/drivers/radeonsi/si_pipe.c  |  1 +
 src/gallium/drivers/softpipe/sp_screen.c|  1 +
 src/gallium/drivers/svga/svga_screen.c  |  1 +
 src/gallium/drivers/swr/swr_screen.cpp  |  1 +
 src/gallium/drivers/vc4/vc4_screen.c|  1 +
 src/gallium/drivers/vc5/vc5_screen.c|  1 +
 src/gallium/drivers/virgl/virgl_screen.c|  1 +
 src/gallium/include/pipe/p_defines.h| 21 +
 src/gallium/include/state_tracker/st_api.h  |  2 ++
 src/gallium/state_trackers/dri/dri_context.c| 11 +++
 src/gallium/state_trackers/dri/dri_query_renderer.c |  8 +++-
 src/mesa/state_tracker/st_manager.c |  5 +
 22 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index bc0db429b38..cc938266b2c 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -411,6 +411,10 @@ The integer capabilities:
 * ``PIPE_CAP_TILE_RASTER_ORDER``: Whether the driver supports
   GL_MESA_tile_raster_order, using the tile_raster_order_* fields in
   pipe_rasterizer_state.
+* ``PIPE_CAP_CONTEXT_PRIORITY_MASK``: For drivers that support per-context
+  priorities, this returns a bitmask of PIPE_CONTEXT_PRIORITY_x for the
+  supported priority levels.  A driver that does not support prioritized
+  contexts can return 0.
 
 
 .. _pipe_capf:
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index 009bc73c14a..25eab8d40c7 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -266,6 +266,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_LOAD_CONSTBUF:
case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
case PIPE_CAP_TILE_RASTER_ORDER:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
   return 0;
 
/* Stream output. */
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 6de381c8fb8..6eed09dc09f 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -327,6 +327,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_LOAD_CONSTBUF:
case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
case PIPE_CAP_TILE_RASTER_ORDER:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
return 0;
 
case PIPE_CAP_MAX_VIEWPORTS:
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 8b9574e1415..f8751d4cf22 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -319,6 +319,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_LOAD_CONSTBUF:
case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
case PIPE_CAP_TILE_RASTER_ORDER:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
   return 0;
 
case PIPE_CAP_MAX_VIEWPORTS:
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index bffc6b52792..6ebd0238a2a 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -362,6 +362,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_LOAD_CONSTBUF:
case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
case PIPE_CAP_TILE_RASTER_ORDER:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
   return 0;
}
/* should only get here on unhandled cases */
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index fedd3c142fb..95bf274d3eb 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -226,6 +226,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case 

Re: [Mesa-dev] [PATCH v3 19/34] intel/compiler: Add union types for prog_data and prog_key stages

2017-10-24 Thread Kenneth Graunke
On Monday, October 23, 2017 11:33:44 PM PDT Jordan Justen wrote:
> On 2017-10-23 23:23:27, Kenneth Graunke wrote:
> > On Sunday, October 22, 2017 1:01:27 PM PDT Jordan Justen wrote:
> > > Signed-off-by: Jordan Justen 
> > > ---
> > >  src/intel/compiler/brw_compiler.h | 18 ++
> > >  1 file changed, 18 insertions(+)
> > > 
> > > diff --git a/src/intel/compiler/brw_compiler.h 
> > > b/src/intel/compiler/brw_compiler.h
> > > index 701b4a80bf1..9359b767e35 100644
> > > --- a/src/intel/compiler/brw_compiler.h
> > > +++ b/src/intel/compiler/brw_compiler.h
> > > @@ -403,6 +403,15 @@ struct brw_cs_prog_key {
> > > struct brw_sampler_prog_key_data tex;
> > >  };
> > >  
> > > +typedef union {
> > > +   struct brw_vs_prog_key vs;
> > > +   struct brw_tcs_prog_key tcs;
> > > +   struct brw_tes_prog_key tes;
> > > +   struct brw_gs_prog_key gs;
> > > +   struct brw_wm_prog_key wm;
> > > +   struct brw_cs_prog_key cs;
> > > +} brw_any_prog_key;
> > > +
> > >  /*
> > >   * Image metadata structure as laid out in the shader parameter
> > >   * buffer.  Entries have to be 16B-aligned for the vec4 back-end to be
> > > @@ -1066,6 +1075,15 @@ struct brw_clip_prog_data {
> > > uint32_t total_grf;
> > >  };
> > >  
> > > +typedef union {
> > > +   struct brw_vs_prog_data vs;
> > > +   struct brw_tcs_prog_data tcs;
> > > +   struct brw_tes_prog_data tes;
> > > +   struct brw_gs_prog_data gs;
> > > +   struct brw_wm_prog_data wm;
> > > +   struct brw_cs_prog_data cs;
> > > +} brw_any_prog_data;
> > > +
> > >  #define DEFINE_PROG_DATA_DOWNCAST(stage)   \
> > >  static inline struct brw_##stage##_prog_data * \
> > >  brw_##stage##_prog_data(struct brw_stage_prog_data *prog_data) \
> > > 
> > 
> > Might be worth leaving a comment that this aren't usable for SF, Clip,
> > BLORP blit, or BLORP clear programs.  It's...most any :)
> 
> Would brw_any_stage_prog_key and brw_any_stage_prog_data help, or just
> cause confusion with brw_stage_prog_data?
> 
> I not too happy with 'any' here as well. :\
> 
> -Jordan

I think 'any' is fine, with a comment.

--Ken


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] vulkan/wsi: Avoid waiting indefinitely for present completion in x11_manage_fifo_queues().

2017-10-24 Thread Henri Verbeet
On 24 October 2017 at 20:13, Fredrik Höglund  wrote:
> On Tuesday 24 October 2017, Henri Verbeet wrote:
>> On 24 October 2017 at 16:11, Fredrik Höglund  wrote:
>> >> @@ -934,9 +938,18 @@ x11_manage_fifo_queues(void *state)
>> >>
>> >>while (chain->last_present_msc < target_msc) {
>> >>   xcb_generic_event_t *event =
>> >> -xcb_wait_for_special_event(chain->conn, 
>> >> chain->special_event);
>> >> - if (!event)
>> >> -goto fail;
>> >> +xcb_poll_for_special_event(chain->conn, 
>> >> chain->special_event);
>> >> + if (!event) {
>> >> +int ret = poll(, 1, 100);
>> >
>> > There is a race condition here where another thread can read the event
>> > from the file descriptor in the time between the calls to
>> > xcb_poll_for_special_event() and poll().
>> >
>> Is that a scenario we care about? Unless I'm misunderstanding
>> something, the same kind of thing could happen between
>> x11_present_to_x11() and xcb_wait_for_special_event().
>
> It cannot, because if another thread reads a special event, xcb will
> insert it into the corresponding special event queue and wake the
> waiting thread. That's the point of having special event queues.
>
> But the reason I know this to be a problem is that I have tried to fix
> this bug in the same way, and I noticed that it resulted in frequent
> random stutters in some apps because poll() was timing out.
>
Oh, I think I see what you mean. The event wouldn't get lost, but we'd
have to wait for the poll to timeout to get to it because it's already
read from the fd into the queue.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] mesa: final changes to expose OpenGL 3.1 with ARB_compatibility

2017-10-24 Thread Eric Anholt
Marek Olšák  writes:

> From: Marek Olšák 

Do we have tests that the compatibility parts of GLSL are properly
enabled when you have GL_ARB_compatibility enabled?  I see a bunch of
negative tests for them, but we should get some positive ones.


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


Re: [Mesa-dev] [PATCH 2/3] mesa: enable ARB_texture_buffer_* extensions in the Compatibility profile

2017-10-24 Thread Eric Anholt
Marek Olšák  writes:

> From: Marek Olšák 
>
> We already have piglit tests testing alpha, luminance, and intensity
> formats. They were skipped by piglit until now.
>
> Additionally, I'm enabling one ARB_texture_buffer_range piglit test to run
> with the compat profile.

Reviewed-by: Eric Anholt 


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


Re: [Mesa-dev] [PATCH] vulkan/wsi: Avoid waiting indefinitely for present completion in x11_manage_fifo_queues().

2017-10-24 Thread Fredrik Höglund
On Tuesday 24 October 2017, Henri Verbeet wrote:
> On 24 October 2017 at 16:11, Fredrik Höglund  wrote:
> >> @@ -934,9 +938,18 @@ x11_manage_fifo_queues(void *state)
> >>
> >>while (chain->last_present_msc < target_msc) {
> >>   xcb_generic_event_t *event =
> >> -xcb_wait_for_special_event(chain->conn, chain->special_event);
> >> - if (!event)
> >> -goto fail;
> >> +xcb_poll_for_special_event(chain->conn, chain->special_event);
> >> + if (!event) {
> >> +int ret = poll(, 1, 100);
> >
> > There is a race condition here where another thread can read the event
> > from the file descriptor in the time between the calls to
> > xcb_poll_for_special_event() and poll().
> >
> Is that a scenario we care about? Unless I'm misunderstanding
> something, the same kind of thing could happen between
> x11_present_to_x11() and xcb_wait_for_special_event().

It cannot, because if another thread reads a special event, xcb will
insert it into the corresponding special event queue and wake the
waiting thread. That's the point of having special event queues.

But the reason I know this to be a problem is that I have tried to fix
this bug in the same way, and I noticed that it resulted in frequent
random stutters in some apps because poll() was timing out.

Fredrik

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


Re: [Mesa-dev] [PATCH v3] egl/wayland: Support for KHR_partial_update

2017-10-24 Thread Eric Engestrom


On 24 October 2017 18:12:00 BST, Emil Velikov  wrote:
> On 24 October 2017 at 02:10, Harish Krupo 
> wrote:
> > Hi Emil,
> >
> > Emil Velikov  writes:
> >
> >> On 23 October 2017 at 11:50, Harish Krupo
>  wrote:
> >>> This passes 33/37 deqp tests related to partial_update, 4 are not
> >>> supported. Tests not supported:
> >>> dEQP-EGL.functional.negative_partial_update.not_postable_surface
> >>> dEQP-EGL.functional.negative_partial_update.not_current_surface
> >>> dEQP-EGL.functional.negative_partial_update.buffer_preserved
> >>> dEQP-EGL.functional.negative_partial_update.not_current_surface2
> >>> Reason: No matching egl config found.
> >>>
> >>> v2: Remove unnecessary return statement. Keep function names
> >>> consistent.  (Emil Velikov)
> >>> Add not supported list to commit message. (Eric Engestrom)
> >>>
> >>> v3: Remove explicit with_damage variable. (Eric Engestrom)
> >>>
> >> Did you send the wrong version by any chance?
> >> The summary does not reflect the actual changes.
> >>
> >
> > Sorry, should have actually been:
> > v3: Remove explicit with_damage variable and swap_buffers_common
> > function. Make SwapBuffers and SwapBuffersWithDamage(NULL,0)
> > equivalent in behavior. Fix called via comment for
> > swap_buffers_with_damage. (Eric Engestrom)
> > Rework try_buffer_damage into set_damage_region as it is being
> > called only from set_damage_region.
> >
> >> Why did you rework try_damage_buffer into
> dri2_wl_set_damage_region?
> >> It seems harder to follow over the previous patches.
> >>
> >
> > As try_damage_buffer was being used only in
> dri2_wl_set_damage_region
> > and swap_buffers_with_damage was calling set_damage_region so I
> removed
> > the unnecessary (extra) call to try_damage_region from
> set_damage_region
> > and reworked try_damage_region to set_damage_region. Do we need to
> keep
> > try_damage_region? If so, I will break them into two separate
> functions.
> >
> It wasn't suggested/mentioned by anyone so it's a bit of a surprise.
> See what others say, but personally I'd keep try_damage_region
> separate.
> The compiler will be smart enough to inline as applicable.

Indeed, it wasn't mentioned anywhere, making it a surprise, and
it results in a very messy diff, but I don't mind either way.
I actually kinda like the code simplification, I guess I would've
just done it as a separate patch.

I'll send a couple comments on the patch itself later tonight or tomorrow
(commuting right now), but overall it looks rather good to me.

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


Re: [Mesa-dev] Build mesa-dev on Windows with AVX instruction set problem

2017-10-24 Thread Roland Scheidegger
Am 24.10.2017 um 18:26 schrieb Fabrício Ceolin:
> Hi,
> 
> I am trying to build mesa-dev on windows.
> 
> I am learning how to do it, through the
> project https://github.com/pal1000/mesa-dist-win/tree/master/buildscript
> 
> 
> I tried to use the binaries from pal1000, but I got an illegal
> instruction problem in opengl32.dll when I tried to run my application
> (VTK based).
> 
> 7FF96252B0CF  cmp         qword ptr [rdx+18h],10h  
> 7FF96252B0D4  mov         rbp,qword ptr [rdx+10h]  
> 7FF96252B0D8  jb         
> std::basic_string>::basic_string+2Dh
> (07FF96252B0DDh)  
> 7FF96252B0DA  mov         rsi,qword ptr [rdx]  
> 7FF96252B0DD  cmp         rbp,10h  
> 7FF96252B0E1  jae       
>  std::basic_string>::basic_string+5Ah
> (07FF96252B10Ah)  
> *7FF96252B0E3  vmovups     xmm0,xmmword ptr [rsi]  *
> 7FF96252B0E7  vmovups     xmmword ptr [rcx],xmm0  
> 7FF96252B0EB  mov         qword ptr [rcx+10h],rbp  
> 
> I tried to build everything on a target machine, but the problem was not
> solved.
> 
> I saw here that movups is in avx instruction set here
> http://www.felixcloutier.com/x86/MOVUPS.html
> 
> 
> My target machine has the following cpuinfo (inside msys64):
> 
> cat /proc/cpuinfo
> processor       : 0
> vendor_id       : GenuineIntel
> cpu family      : 6
> model           : 6
> model name      : QEMU Virtual CPU version 2.0.0
> stepping        : 3
> cpu MHz         : 2993.000
> cache size      : 4096 KB
> fpu             : yes
> fpu_exception   : yes
> cpuid level     : 4
> wp              : yes
> flags           : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca
> cmov pat pse36 clflush mmx fxsr sse sse2 pni vmx cx16 x2apic popcnt
> hypervisor lahf_lm epb dtherm fsgsbase tsc_adjust bmi1 hle avx2 clflushopt
> clflush size    : 64
> cache_alignment : 64
> address sizes   : 40 bits physical, 48 bits virtual
> power management:
> 
> How can I compile opengl32.dll without use the avx instruction set?
> 
> My compilation command was (from mesa-dist-win):
> 
> python c:\Python27\Scripts\scons.py build=release platform=windows
> machine=x86_64 swr=1 libgl-gdi osmesa graw-gdi

Generally, generic x86_64 target should only use sse2.
If you're running llvmpipe though, the code will use runtime detection
of features for generated code. I have no idea if that code there
causing the crash was runtime-compiled by llvm or not. If yes, it could
mean there's still bugs with llvm and cpu detection features (detecting
this is quite a mess due to the OS having to support it). Albeit your
cpu features make no sense at all, you cannot have avx2 but not avx (and
you don't have the newer sse flags neither, even for a virtual cpu that
is pretty odd supporting avx2 but not these...).
Interestingly, xsave isn't listed neither, which is necessary for avx to
indicate the OS supports it, suggesting your OS does not. No idea why...

Roland



> 
> Thanks
> 
> 
> MiningMath Associates
> 
> *Fabrício Ceolin*
> +55 (31) 98675-1359
> MiningMath Associates 
> www.miningmath.com 
> 
> 
> 
> 
> 
> ___
> 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] docs: Mark GL_KHR_no_error as done.

2017-10-24 Thread Samuel Pitoiset

That's quite right. :)

Reviewed-by: Samuel Pitoiset 

Though, we still need GLX_ARB_create_context_no_error. Here's the 
pending series https://patchwork.freedesktop.org/patch/170204/ (in case 
someone more familiar with the code can give some feedbacks). Thanks!


On 10/24/2017 07:38 PM, Kenneth Graunke wrote:

Drivers have supported KHR_no_error for a while.  We'd been leaving it
marked as "in progress" because there's a zillion places that could get
slightly more optimized.  But, Timothy and Samuel have already done
piles of work, and I think we have a solid implementation at this point.

Let's check it off the list.
---
  docs/features.txt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/features.txt b/docs/features.txt
index 338a22c6c68..d228a0207b3 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -233,7 +233,7 @@ GL 4.6, GLSL 4.60
GL_ARB_spirv_extensions   in progress (Nicolai 
Hähnle, Ian Romanick)
GL_ARB_texture_filter_anisotropic DONE (i965, nv50, 
nvc0, r600, radeonsi, softpipe (*), llvmpipe (*))
GL_ARB_transform_feedback_overflow_query  DONE (i965/gen6+, 
radeonsi, llvmpipe, softpipe)
-  GL_KHR_no_error   started (Timothy 
Arceri)
+  GL_KHR_no_error   DONE (all drivers)
  
  (*) softpipe and llvmpipe advertise 16x anisotropy but simply ignore the setting
  


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


[Mesa-dev] [PATCH] docs: Mark GL_KHR_no_error as done.

2017-10-24 Thread Kenneth Graunke
Drivers have supported KHR_no_error for a while.  We'd been leaving it
marked as "in progress" because there's a zillion places that could get
slightly more optimized.  But, Timothy and Samuel have already done
piles of work, and I think we have a solid implementation at this point.

Let's check it off the list.
---
 docs/features.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/features.txt b/docs/features.txt
index 338a22c6c68..d228a0207b3 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -233,7 +233,7 @@ GL 4.6, GLSL 4.60
   GL_ARB_spirv_extensions   in progress (Nicolai 
Hähnle, Ian Romanick)
   GL_ARB_texture_filter_anisotropic DONE (i965, nv50, 
nvc0, r600, radeonsi, softpipe (*), llvmpipe (*))
   GL_ARB_transform_feedback_overflow_query  DONE (i965/gen6+, 
radeonsi, llvmpipe, softpipe)
-  GL_KHR_no_error   started (Timothy 
Arceri)
+  GL_KHR_no_error   DONE (all drivers)
 
 (*) softpipe and llvmpipe advertise 16x anisotropy but simply ignore the 
setting
 
-- 
2.14.2

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


Re: [Mesa-dev] [PATCH mesa] meson: be explicit about the version required

2017-10-24 Thread Eric Engestrom
On Tuesday, 2017-10-24 09:40:22 -0700, Dylan Baker wrote:
> This seems reasonable, could you wrap the hanging indent like meson_options 
> with
> the closing brace on it's own line and with each option on its own line?
> ie:
> project(
>   mesa
>   ...
> )

Done

> 
> With that:
> Reviewed-by: Dylan Baker 

Thanks :)

Before I push it, there was an implied question, let's make it explicit:
Which version do we want here? How far back do we want to support Meson?

I don't know much about the history of Meson and of its features, so
I have no idea how much effort it would be to support some previous
version.

> 
> Quoting Eric Engestrom (2017-10-24 07:04:01)
> > This way, we know what we're allowed to use (no nested include lists
> > for instance) and users get immediate feedback when trying to use
> > unsupported versions, rather than a cryptic crash or things being
> > silently not built correctly.
> > 
> > Cc: Dylan Baker 
> > Signed-off-by: Eric Engestrom 
> > ---
> >  meson.build | 6 +-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/meson.build b/meson.build
> > index 9f4812258236d6dfd72d..38038c322082f03236f2 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -18,7 +18,11 @@
> >  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
> > IN THE
> >  # SOFTWARE.
> >  
> > -project('mesa', ['c', 'cpp'], version : '17.3.0-devel', license : 'MIT',
> > +project('mesa',
> > +['c', 'cpp'],
> > +version : '17.3.0-devel',
> > +license : 'MIT',
> > +meson_version : '>= 0.42',
> >  default_options : ['c_std=c99', 'cpp_std=c++11'])
> >  
> >  # Arguments for the preprocessor, put these in a separate array from the C 
> > and
> > -- 
> > Cheers,
> >   Eric
> > 


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


Re: [Mesa-dev] [PATCH 5/6] freedreno: context priority support

2017-10-24 Thread Rob Clark
On Wed, Oct 4, 2017 at 3:37 PM, Roland Scheidegger  wrote:
> Am 04.10.2017 um 17:44 schrieb Rob Clark:
>> For devices (and kernels) which support different priority ringbuffers,
>> expose context priority support.
>>
>> Signed-off-by: Rob Clark 
>> ---
>>  src/gallium/drivers/freedreno/freedreno_context.c |  9 -
>>  src/gallium/drivers/freedreno/freedreno_screen.c  | 12 +++-
>>  src/gallium/drivers/freedreno/freedreno_screen.h  |  1 +
>>  3 files changed, 20 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/gallium/drivers/freedreno/freedreno_context.c 
>> b/src/gallium/drivers/freedreno/freedreno_context.c
>> index 20480f4f8c1..7fdb848f380 100644
>> --- a/src/gallium/drivers/freedreno/freedreno_context.c
>> +++ b/src/gallium/drivers/freedreno/freedreno_context.c
>> @@ -249,10 +249,17 @@ fd_context_init(struct fd_context *ctx, struct 
>> pipe_screen *pscreen,
>>  {
>>   struct fd_screen *screen = fd_screen(pscreen);
>>   struct pipe_context *pctx;
>> + unsigned prio = 1;
>>   int i;
>>
>> + /* lower numerical value == higher priority: */
>> + if (flags & PIPE_CONTEXT_HIGH_PRIORITY)
>> + prio = 0;
>> + else if (flags & PIPE_CONTEXT_LOW_PRIORITY)
>> + prio = 2;
>> +
>>   ctx->screen = screen;
>> - ctx->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D);
>> + ctx->pipe = fd_pipe_new2(screen->dev, FD_PIPE_3D, prio);
>>
>>   ctx->primtypes = primtypes;
>>   ctx->primtype_mask = 0;
>> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
>> b/src/gallium/drivers/freedreno/freedreno_screen.c
>> index 96866d656be..aa451f501ff 100644
>> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
>> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
>> @@ -325,9 +325,11 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum 
>> pipe_cap param)
>>   case PIPE_CAP_QUERY_SO_OVERFLOW:
>>   case PIPE_CAP_MEMOBJ:
>>   case PIPE_CAP_LOAD_CONSTBUF:
>> - case PIPE_CAP_CONTEXT_PRIORITY_MASK:
>>   return 0;
>>
>> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
>> + return screen->priority_mask;
>> +
>>   case PIPE_CAP_MAX_VIEWPORTS:
>>   return 1;
>>
>> @@ -803,6 +805,14 @@ fd_screen_create(struct fd_device *dev)
>>   }
>>   screen->chip_id = val;
>>
>> + if (fd_pipe_get_param(screen->pipe, FD_NR_RINGS, )) {
>> + DBG("could not get # of rings");
>> + screen->priority_mask = 0;
>> + } else {
>> + /* # of rings equates to number of unique priority values: */
>> + screen->priority_mask = (1 << val) - 1;
>> + }
> This doesn't quite seem to guarantee you only return valid values for
> the cap,
> unless your number of rings doesn't exceed 3. Maybe that's always the case,
> but I think should either mention that in the comment or explicitly mask
> off invalid bits.
>

Actually, it would be four rings for the GPUs which support preemption
(currently, although the limit is semi arbitrary and could easily be
increased later)..  So this would set more bits than are currently
used.  I'm undecided whether that is good or bad.  If we decide later
to support more priorities in gallium, then I'd have to remember to
remove the masking out of extra bits.  But otoh I think the extra bits
as it is now are harmless.

BR,
-R

>
>>   DBG("Pipe Info:");
>>   DBG(" GPU-id:  %d", screen->gpu_id);
>>   DBG(" Chip-id: 0x%08x", screen->chip_id);
>> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h 
>> b/src/gallium/drivers/freedreno/freedreno_screen.h
>> index 68518ef721b..d5e497d4f65 100644
>> --- a/src/gallium/drivers/freedreno/freedreno_screen.h
>> +++ b/src/gallium/drivers/freedreno/freedreno_screen.h
>> @@ -67,6 +67,7 @@ struct fd_screen {
>>   uint32_t max_rts;/* max # of render targets */
>>   uint32_t gmem_alignw, gmem_alignh;
>>   uint32_t num_vsc_pipes;
>> + uint32_t priority_mask;
>>   bool has_timestamp;
>>
>>   void *compiler;  /* currently unused for a2xx */
>>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 03/25] threads: update for late C11 changes

2017-10-24 Thread Emil Velikov
On 23 October 2017 at 12:20, Nicolai Hähnle  wrote:

>>> -#ifndef _MSC_VER
>>> -struct xtime {
>>> -time_t sec;
>>> -long nsec;
>>> -};
>>> -typedef struct xtime xtime;
>>> -#endif
>>> -
>>
>>
>> We don't have a fall-back declaration of the struct, yet we use it
>> below and provide a timespec_get() implementation.
>> I'd imagine you haven't tested this on Windows (hence Jose in CC)?
>
>
> Right on both counts, as I don't really have a way of testing on Windows.
>
There's an Appveyour integration similar to Travis. One should be able
to select the MSVC/toolchain version, but I'm not versed enough for
examples :-\
Let's see what Jose will say on the topic.

>
>> Quick search suggests that MSVC 2015 was the first one that introduces
>> the struct and timespec_get.
>>
>> If we're safe as-is, please add a comment with some details - I'd
>> imagine Jose had better knowledge in the area.
>>
>>
>>>   /* 7.25.7 Time functions */
>>>   // 7.25.6.1
>>> +#if 0
>>
>> I'd just drop the hunk mentioning that timespec_get() is part of time.h
>
>
> I wasn't sure when timespec_get was introduced, so I thought it safer to
> keep it around for a while in case we run into systems where time.h doesn't
> provide it.
>
> I can add a comment, or remove it entirely if you think that's not a
> concern.
>
Valid point - I'd assumed it was available everywhere (tm). I'd leave
it for now, thus we can toggle based on $heuristics if applicable.

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


Re: [Mesa-dev] [PATCH 1/5] anv: add ETIME fallback define

2017-10-24 Thread Dylan Baker
Quoting Greg V (2017-10-23 13:20:39)
> FreeBSD only has ETIMEDOUT, not ETIME
> ---
>  src/intel/vulkan/anv_device.c | 4 
>  src/intel/vulkan/anv_gem.c| 4 
>  src/intel/vulkan/anv_queue.c  | 4 
>  3 files changed, 12 insertions(+)
> 
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 67028e8da9..fab2a394ca 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -39,6 +39,10 @@
>  
>  #include "genxml/gen7_pack.h"
>  

I would add a comment here that this is for FreeBSD. Alternatively you might
consider #ifdef __FreeBSD__ since it's self documenting.

Dylan

> +#ifndef ETIME
> +#define ETIME ETIMEDOUT
> +#endif
> +
>  static void
>  compiler_debug_log(void *data, const char *fmt, ...)
>  { }
> diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
> index 34c0989108..4a885617ab 100644
> --- a/src/intel/vulkan/anv_gem.c
> +++ b/src/intel/vulkan/anv_gem.c
> @@ -31,6 +31,10 @@
>  
>  #include "anv_private.h"
>  
> +#ifndef ETIME
> +#define ETIME ETIMEDOUT
> +#endif
> +
>  static int
>  anv_ioctl(int fd, unsigned long request, void *arg)
>  {
> diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
> index c6b2e01c62..b1662c1720 100644
> --- a/src/intel/vulkan/anv_queue.c
> +++ b/src/intel/vulkan/anv_queue.c
> @@ -34,6 +34,10 @@
>  
>  #include "genxml/gen7_pack.h"
>  
> +#ifndef ETIME
> +#define ETIME ETIMEDOUT
> +#endif
> +
>  VkResult
>  anv_device_execbuf(struct anv_device *device,
> struct drm_i915_gem_execbuffer2 *execbuf,
> -- 
> 2.14.2
> 
> ___
> 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] vulkan/wsi: Avoid waiting indefinitely for present completion in x11_manage_fifo_queues().

2017-10-24 Thread Henri Verbeet
On 24 October 2017 at 20:31, Emil Velikov  wrote:
> On 17 October 2017 at 15:18, Henri Verbeet  wrote:
>> Note that the usage of xcb_poll_for_special_event() requires a version
>> of libxcb that includes commit fad81b63422105f9345215ab2716c4b804ec7986
>> to work properly.
>>
> What should we expect if we're using xcb w/o said commit? It's worth
> mentioning in the commit message.

For reference, 
https://cgit.freedesktop.org/xcb/libxcb/commit/?id=fad81b63422105f9345215ab2716c4b804ec7986

What happens without that commit is that xcb_poll_for_special_event()
will fail to read the event, effectively preventing any subsequent
presents. That's obviously bad. As mentioned in the libxcb commit, a
similar issue exists for x11_acquire_next_image_poll_x11() with a
timeout, although I suppose that scenario is less common.

> it seems like there's no release with the commit, should we bribe Uli
> to roll one ;-)
>
Probably.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3] egl/wayland: Support for KHR_partial_update

2017-10-24 Thread Emil Velikov
On 24 October 2017 at 02:10, Harish Krupo  wrote:
> Hi Emil,
>
> Emil Velikov  writes:
>
>> On 23 October 2017 at 11:50, Harish Krupo  wrote:
>>> This passes 33/37 deqp tests related to partial_update, 4 are not
>>> supported. Tests not supported:
>>> dEQP-EGL.functional.negative_partial_update.not_postable_surface
>>> dEQP-EGL.functional.negative_partial_update.not_current_surface
>>> dEQP-EGL.functional.negative_partial_update.buffer_preserved
>>> dEQP-EGL.functional.negative_partial_update.not_current_surface2
>>> Reason: No matching egl config found.
>>>
>>> v2: Remove unnecessary return statement. Keep function names
>>> consistent.  (Emil Velikov)
>>> Add not supported list to commit message. (Eric Engestrom)
>>>
>>> v3: Remove explicit with_damage variable. (Eric Engestrom)
>>>
>> Did you send the wrong version by any chance?
>> The summary does not reflect the actual changes.
>>
>
> Sorry, should have actually been:
> v3: Remove explicit with_damage variable and swap_buffers_common
> function. Make SwapBuffers and SwapBuffersWithDamage(NULL,0)
> equivalent in behavior. Fix called via comment for
> swap_buffers_with_damage. (Eric Engestrom)
> Rework try_buffer_damage into set_damage_region as it is being
> called only from set_damage_region.
>
>> Why did you rework try_damage_buffer into dri2_wl_set_damage_region?
>> It seems harder to follow over the previous patches.
>>
>
> As try_damage_buffer was being used only in dri2_wl_set_damage_region
> and swap_buffers_with_damage was calling set_damage_region so I removed
> the unnecessary (extra) call to try_damage_region from set_damage_region
> and reworked try_damage_region to set_damage_region. Do we need to keep
> try_damage_region? If so, I will break them into two separate functions.
>
It wasn't suggested/mentioned by anyone so it's a bit of a surprise.
See what others say, but personally I'd keep try_damage_region
separate.
The compiler will be smart enough to inline as applicable.

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


Re: [Mesa-dev] [PATCH] meson: add opt-out of libunwind

2017-10-24 Thread Dylan Baker
Reviewed-by: Dylan Baker 

Quoting Erik Faye-Lund (2017-10-24 07:44:21)
> Libunwind has some issues on some platforms, so let's allow people
> who have issues to opt-out. This is similar to what we do in automake,
> and the implementation is modelled after our opt-out for valgrind.
> 
> Signed-off-by: Erik Faye-Lund 
> ---
> 
> This fixes a build-problem for me on Arch Linux for ARM. I've always
> needed to do the same using autotools also.
> 
>  meson.build   | 3 ++-
>  meson_options.txt | 6 ++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index 9f48122582..e842bb1652 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -37,6 +37,7 @@ pre_args = [
>  with_vulkan_icd_dir = get_option('vulkan-icd-dir')
>  with_tests = get_option('build-tests')
>  with_valgrind = get_option('valgrind')
> +with_libunwind = get_option('libunwind')
>  with_asm = get_option('asm')
>  with_llvm = get_option('llvm')
>  if get_option('texture-float')
> @@ -681,7 +682,7 @@ dep_selinux = []
>  # TODO: llvm-prefix and llvm-shared-libs
>  
>  dep_unwind = dependency('libunwind', required : false)
> -if dep_unwind.found()
> +if dep_unwind.found() and with_libunwind
>pre_args += '-DHAVE_LIBUNWIND'
>  endif
>  
> diff --git a/meson_options.txt b/meson_options.txt
> index be93871d61..85b1cdaff6 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -143,6 +143,12 @@ option(
>description : 'Build with valgrind support if possible'
>  )
>  option(
> +  'libunwind',
> +  type : 'boolean',
> +  value : true,
> +  description : 'Use libunwind for stack-traces if possible'
> +)
> +option(
>'build-tests',
>type : 'boolean',
>value : false,
> -- 
> 2.11.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] configure: Allow android as an EGL platform

2017-10-24 Thread Emil Velikov
On 23 October 2017 at 18:10, Eric Engestrom  wrote:
> On Friday, 2017-10-20 15:34:57 -0600, Benjamin Gordon wrote:
>> I'm working on radeonsi support in the Chrome OS Android container
>> (ARC++).  Mesa in ARC++ uses autotools instead of Android.mk, but all
>> the necessary EGL bits are there, so the existing check is too strict.
>>
>> Signed-off-by: Benjamin Gordon 
>
> Didn't double-check that all the android bits are wired, but I don't
> think this can break anything outside android, so:
> Reviewed-by: Eric Engestrom 
>
> Do you need someone to push this for you?
>
It would be great if we can drop require_basic_egl around the time
someone else comes to extend it ;-)
it's a bit of a workaround, for the old days where surfaceless did not
exist and neither it nor drm were enabled by default.

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


Re: [Mesa-dev] [PATCH] vulkan/wsi: Avoid waiting indefinitely for present completion in x11_manage_fifo_queues().

2017-10-24 Thread Emil Velikov
On 17 October 2017 at 15:18, Henri Verbeet  wrote:
> In particular, if the window was destroyed before the present request
> completed, xcb_wait_for_special_event() may never return.
>
> Note that the usage of xcb_poll_for_special_event() requires a version
> of libxcb that includes commit fad81b63422105f9345215ab2716c4b804ec7986
> to work properly.
>
What should we expect if we're using xcb w/o said commit? It's worth
mentioning in the commit message.
it seems like there's no release with the commit, should we bribe Uli
to roll one ;-)

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


Re: [Mesa-dev] [PATCH 1/3] freedreno/ir3: use a flag instead of setting PYTHONPATH

2017-10-24 Thread Emil Velikov
On 24 October 2017 at 16:12, Rob Clark  wrote:
> Similar to 848da662224326ccfbe6647bc82f4f89ca22c762, pass an arg to
> ir3_nir_trig.py to add to python path, rather than using $PYTHONPATH,
> to prep for meson build support.
>
> Signed-off-by: Rob Clark 
> ---
>  src/gallium/drivers/freedreno/Android.gen.mk  |  2 +-
>  src/gallium/drivers/freedreno/Makefile.am |  2 +-
>  src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py | 25 
> +++
>  3 files changed, 23 insertions(+), 6 deletions(-)
>
Please mention the Android squash/fixup.
Reviewed-by: Emil Velikov 

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


Re: [Mesa-dev] [PATCH] Haiku: convert to autotools

2017-10-24 Thread Emil Velikov
Hi Jerome,

On 23 October 2017 at 16:58, Jerome Duval  wrote:
> * configure.ac:
>   -pthread is not available on Haiku.
>   Haiku doesn't require --enable-dri
>   build hgl on Haiku
> * egl/Makefile.am: define backendfiles for Haiku
> * src/gallium/Makefile.am: build winsys/sw/hgl, state_trackers/hgl and
> targets/haiku-softpipe on Haiku.
> * src/gallium/targets/haiku-softpipe: add Makefile.am
> * src/gallium/state_trackers/hgl: add Makefile.am
> * winsys/sw/hgl: add Makefile.am
> * src/hgl/Makefile.am: add Makefile.am
> ---
Thanks for the patch. I think Eric has a point regarding splitting this up.
Here is one way to handle it:
 - patch 1 - the driver, aka st/hgl + sw/hgl + targets/haiku
 - 2 - src/egl
 - 3 - src/hgl
 - 4 misc fixes (the SoftwareRenderer.cpp hunk?)
 - 5 toggle - configure.ac + src/Makefile.am

Couple of small suggestions:
 - keep all the sources and headers in the sources lists in Makefile.sources
 - how do you guys manage pthreads - please mention that in the commit message.
If I'm reading this correctly, you strip out -pthread and there's no
pthread-stubs on Haiku.

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


[Mesa-dev] [PATCH v2] clover/llvm: Drop support for LLVM < 3.9.

2017-10-24 Thread Vedran Miletić
v2: remove/inline compat stuff

Reviewed-by: Francisco Jerez 
---
 .../state_trackers/clover/llvm/codegen/native.cpp  |   8 +-
 src/gallium/state_trackers/clover/llvm/compat.hpp  | 109 +
 .../state_trackers/clover/llvm/invocation.cpp  |  22 +++--
 .../state_trackers/clover/llvm/metadata.hpp|  30 +-
 4 files changed, 20 insertions(+), 149 deletions(-)

diff --git a/src/gallium/state_trackers/clover/llvm/codegen/native.cpp 
b/src/gallium/state_trackers/clover/llvm/codegen/native.cpp
index 12c83a92b6..38028597a3 100644
--- a/src/gallium/state_trackers/clover/llvm/codegen/native.cpp
+++ b/src/gallium/state_trackers/clover/llvm/codegen/native.cpp
@@ -114,7 +114,7 @@ namespace {
 
   std::unique_ptr tm {
  t->createTargetMachine(target.triple, target.cpu, "", {},
-compat::default_reloc_model,
+::llvm::None,
 compat::default_code_model,
 ::llvm::CodeGenOpt::Default) };
   if (!tm)
@@ -124,11 +124,11 @@ namespace {
   ::llvm::SmallVector data;
 
   {
- compat::pass_manager pm;
+ ::llvm::legacy::PassManager pm;
  ::llvm::raw_svector_ostream os { data };
- compat::raw_ostream_to_emit_file fos(os);
+ ::llvm::raw_svector_ostream (os);
 
- mod.setDataLayout(compat::get_data_layout(*tm));
+ mod.setDataLayout(tm->createDataLayout());
  tm->Options.MCOptions.AsmVerbose =
 (ft == TargetMachine::CGFT_AssemblyFile);
 
diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp 
b/src/gallium/state_trackers/clover/llvm/compat.hpp
index f8b56516d5..ce3a29f7d5 100644
--- a/src/gallium/state_trackers/clover/llvm/compat.hpp
+++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
@@ -36,6 +36,8 @@
 
 #include "util/algorithm.hpp"
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -46,16 +48,6 @@
 #include 
 #endif
 
-#if HAVE_LLVM >= 0x0307
-#include 
-#include 
-#else
-#include 
-#include 
-#include 
-#include 
-#endif
-
 #include 
 #include 
 #include 
@@ -63,12 +55,6 @@
 namespace clover {
namespace llvm {
   namespace compat {
-#if HAVE_LLVM >= 0x0307
- typedef ::llvm::TargetLibraryInfoImpl target_library_info;
-#else
- typedef ::llvm::TargetLibraryInfo target_library_info;
-#endif
-
 #if HAVE_LLVM >= 0x0500
  const auto lang_as_offset = 0;
  const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
@@ -77,19 +63,6 @@ namespace clover {
  const clang::InputKind ik_opencl = clang::IK_OpenCL;
 #endif
 
- inline void
- set_lang_defaults(clang::CompilerInvocation ,
-   clang::LangOptions , clang::InputKind ik,
-   const ::llvm::Triple ,
-   clang::PreprocessorOptions ,
-   clang::LangStandard::Kind std) {
-#if HAVE_LLVM >= 0x0309
-inv.setLangDefaults(lopts, ik, t, ppopts, std);
-#else
-inv.setLangDefaults(lopts, ik, std);
-#endif
- }
-
  inline void
  add_link_bitcode_file(clang::CodeGenOptions ,
const std::string ) {
@@ -100,78 +73,8 @@ namespace clover {
 F.PropagateAttrs = true;
 F.LinkFlags = ::llvm::Linker::Flags::None;
 opts.LinkBitcodeFiles.emplace_back(F);
-#elif HAVE_LLVM >= 0x0308
-opts.LinkBitcodeFiles.emplace_back(::llvm::Linker::Flags::None, 
path);
-#else
-opts.LinkBitcodeFile = path;
-#endif
- }
-
-#if HAVE_LLVM >= 0x0307
- typedef ::llvm::legacy::PassManager pass_manager;
-#else
- typedef ::llvm::PassManager pass_manager;
-#endif
-
- inline void
- add_data_layout_pass(pass_manager ) {
-#if HAVE_LLVM < 0x0307
-pm.add(new ::llvm::DataLayoutPass());
-#endif
- }
-
- inline void
- add_internalize_pass(pass_manager ,
-  const std::vector ) {
-#if HAVE_LLVM >= 0x0309
-pm.add(::llvm::createInternalizePass(
-  [=](const ::llvm::GlobalValue ) {
- return std::find(names.begin(), names.end(),
-  gv.getName()) != names.end();
-  }));
-#else
-pm.add(::llvm::createInternalizePass(std::vector(
-  map(std::mem_fn(::string::data), names;
-#endif
- }
-
- inline std::unique_ptr< ::llvm::Linker>
- create_linker(::llvm::Module ) {
-#if HAVE_LLVM >= 0x0308
-return std::unique_ptr< ::llvm::Linker>(new ::llvm::Linker(mod));
 #else
-return std::unique_ptr< ::llvm::Linker>(new ::llvm::Linker());
-#endif
- }
-
- inline bool
- link_in_module(::llvm::Linker ,
-std::unique_ptr< ::llvm::Module> 

Re: [Mesa-dev] [PATCH mesa] meson: be explicit about the version required

2017-10-24 Thread Dylan Baker
This seems reasonable, could you wrap the hanging indent like meson_options with
the closing brace on it's own line and with each option on its own line?
ie:
project(
  mesa
  ...
)

With that:
Reviewed-by: Dylan Baker 

Quoting Eric Engestrom (2017-10-24 07:04:01)
> This way, we know what we're allowed to use (no nested include lists
> for instance) and users get immediate feedback when trying to use
> unsupported versions, rather than a cryptic crash or things being
> silently not built correctly.
> 
> Cc: Dylan Baker 
> Signed-off-by: Eric Engestrom 
> ---
>  meson.build | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index 9f4812258236d6dfd72d..38038c322082f03236f2 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -18,7 +18,11 @@
>  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
> THE
>  # SOFTWARE.
>  
> -project('mesa', ['c', 'cpp'], version : '17.3.0-devel', license : 'MIT',
> +project('mesa',
> +['c', 'cpp'],
> +version : '17.3.0-devel',
> +license : 'MIT',
> +meson_version : '>= 0.42',
>  default_options : ['c_std=c99', 'cpp_std=c++11'])
>  
>  # Arguments for the preprocessor, put these in a separate array from the C 
> and
> -- 
> Cheers,
>   Eric
> 


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 3/3] meson: build freedreno

2017-10-24 Thread Dylan Baker
Reviewed-by: Dylan Baker 

Quoting Rob Clark (2017-10-24 08:12:50)
> Mostly copy/pasta from Dylan Baker's conversion of nouveau and i965.
> 
> Signed-off-by: Rob Clark 
> ---
>  meson.build  |   6 +
>  meson_options.txt|   2 +-
>  src/gallium/drivers/freedreno/meson.build| 221 
> +++
>  src/gallium/meson.build  |   3 +-
>  src/gallium/targets/dri/meson.build  |   6 +
>  src/gallium/winsys/freedreno/drm/meson.build |  30 
>  6 files changed, 266 insertions(+), 2 deletions(-)
>  create mode 100644 src/gallium/drivers/freedreno/meson.build
>  create mode 100644 src/gallium/winsys/freedreno/drm/meson.build
> 
> diff --git a/meson.build b/meson.build
> index 9f481225823..8db4699ec5c 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -94,6 +94,7 @@ with_gallium = false
>  with_gallium_pl111 = false
>  with_gallium_radeonsi = false
>  with_gallium_nouveau = false
> +with_gallium_freedreno = false
>  with_gallium_softpipe = false
>  with_gallium_vc4 = false
>  with_gallium_vc5 = false
> @@ -105,6 +106,7 @@ if _drivers != ''
>with_gallium_pl111 = _split.contains('pl111')
>with_gallium_radeonsi = _split.contains('radeonsi')
>with_gallium_nouveau = _split.contains('nouveau')
> +  with_gallium_freedreno = _split.contains('freedreno')
>with_gallium_softpipe = _split.contains('swrast')
>with_gallium_vc4 = _split.contains('vc4')
>with_gallium_vc5 = _split.contains('vc5')
> @@ -614,6 +616,7 @@ dep_libdrm_amdgpu = []
>  dep_libdrm_radeon = []
>  dep_libdrm_nouveau = []
>  dep_libdrm_etnaviv = []
> +dep_libdrm_freedreno = []
>  if with_amd_vk or with_gallium_radeonsi
>dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.85')
>  endif
> @@ -626,6 +629,9 @@ endif
>  if with_gallium_etnaviv
>dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
>  endif
> +if with_gallium_freedreno
> +  dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 
> 2.4.74')
> +endif
>  
>  llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
>  if with_amd_vk
> diff --git a/meson_options.txt b/meson_options.txt
> index be93871d614..1b90f5ced88 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -46,7 +46,7 @@ option(
>  option(
>'gallium-drivers',
>type : 'string',
> -  value : 'pl111,radeonsi,nouveau,swrast,vc4,etnaviv,imx',
> +  value : 'pl111,radeonsi,nouveau,freedreno,swrast,vc4,etnaviv,imx',
>description : 'comma separated list of gallium drivers to build.'
>  )
>  option(
> diff --git a/src/gallium/drivers/freedreno/meson.build 
> b/src/gallium/drivers/freedreno/meson.build
> new file mode 100644
> index 000..e7f3becf9e6
> --- /dev/null
> +++ b/src/gallium/drivers/freedreno/meson.build
> @@ -0,0 +1,221 @@
> +# Copyright © 2017 Rob Clark
> +
> +# Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> +# of this software and associated documentation files (the "Software"), to 
> deal
> +# in the Software without restriction, including without limitation the 
> rights
> +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> +# copies of the Software, and to permit persons to whom the Software is
> +# furnished to do so, subject to the following conditions:
> +
> +# The above copyright notice and this permission notice shall be included in
> +# all copies or substantial portions of the Software.
> +
> +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
> THE
> +# SOFTWARE.
> +
> +ir3_nir_trig_c = custom_target(
> +  'ir3_nir_trig.c',
> +  input : 'ir3/ir3_nir_trig.py',
> +  output : 'ir3_nir_trig.c',
> +  command : [prog_python2, '@INPUT@', '-p',
> + join_paths(meson.source_root(), 'src/compiler/nir/')],
> +  capture : true,
> +  depend_files : files(
> +'ir3/ir3_nir_trig.py',
> +nir_algebraic_py,
> +  ),
> +)
> +
> +files_libfreedreno = files(
> +  'adreno_common.xml.h',
> +  'adreno_pm4.xml.h',
> +  'disasm.h',
> +  'freedreno_batch.c',
> +  'freedreno_batch.h',
> +  'freedreno_batch_cache.c',
> +  'freedreno_batch_cache.h',
> +  'freedreno_context.c',
> +  'freedreno_context.h',
> +  'freedreno_draw.c',
> +  'freedreno_draw.h',
> +  'freedreno_fence.c',
> +  'freedreno_fence.h',
> +  'freedreno_gmem.c',
> +  'freedreno_gmem.h',
> +  'freedreno_program.c',
> +  'freedreno_program.h',
> +  'freedreno_query.c',
> +  'freedreno_query.h',
> +  'freedreno_query_acc.c',
> +  

Re: [Mesa-dev] [PATCH 3/3] mesa: final changes to expose OpenGL 3.1 with ARB_compatibility

2017-10-24 Thread Emil Velikov
On 21 October 2017 at 13:54, Marek Olšák  wrote:
> From: Marek Olšák 
>
> ---
>  src/mesa/main/extensions_table.h |  1 +
>  src/mesa/main/mtypes.h   |  1 +
>  src/mesa/main/version.c  | 13 -
>  3 files changed, 10 insertions(+), 5 deletions(-)
>
Do we want to update src/mesa/drivers/dri/common/dri_util.c as well.
See the GL_ARB_compatibilty hunk in driCreateContextAttribs.

Can you please update docs/relnotes/17.4.0.html?

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


Re: [Mesa-dev] [PATCH 1/3] freedreno/ir3: use a flag instead of setting PYTHONPATH

2017-10-24 Thread Dylan Baker
The python is correct, and I believe that the autotools is correct,
Reviewed-by: Dylan Baker 

Quoting Rob Clark (2017-10-24 08:12:48)
> Similar to 848da662224326ccfbe6647bc82f4f89ca22c762, pass an arg to
> ir3_nir_trig.py to add to python path, rather than using $PYTHONPATH,
> to prep for meson build support.
> 
> Signed-off-by: Rob Clark 
> ---
>  src/gallium/drivers/freedreno/Android.gen.mk  |  2 +-
>  src/gallium/drivers/freedreno/Makefile.am |  2 +-
>  src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py | 25 
> +++
>  3 files changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/src/gallium/drivers/freedreno/Android.gen.mk 
> b/src/gallium/drivers/freedreno/Android.gen.mk
> index 072cf998aed..17b6fbe1b7e 100644
> --- a/src/gallium/drivers/freedreno/Android.gen.mk
> +++ b/src/gallium/drivers/freedreno/Android.gen.mk
> @@ -32,7 +32,7 @@ intermediates := $(call local-generated-sources-dir)
>  
>  $(intermediates)/ir3/ir3_nir_trig.c: $(ir3_nir_trig_deps)
> @mkdir -p $(dir $@)
> -   $(hide) PYTHONPATH=$(MESA_TOP)/src/compiler/nir $(MESA_PYTHON2) $< > 
> $@
> +   $(hide) $(MESA_PYTHON2) $< -p $(MESA_TOP)/src/compiler/nir > $@
>  
>  LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/, \
> $(ir3_GENERATED_FILES))
> diff --git a/src/gallium/drivers/freedreno/Makefile.am 
> b/src/gallium/drivers/freedreno/Makefile.am
> index 128c7fb5990..5cb4c74cb68 100644
> --- a/src/gallium/drivers/freedreno/Makefile.am
> +++ b/src/gallium/drivers/freedreno/Makefile.am
> @@ -12,7 +12,7 @@ AM_CFLAGS = \
>  MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
>  ir3/ir3_nir_trig.c: ir3/ir3_nir_trig.py 
> $(top_srcdir)/src/compiler/nir/nir_algebraic.py
> $(MKDIR_GEN)
> -   $(AM_V_GEN) PYTHONPATH=$(top_srcdir)/src/compiler/nir $(PYTHON2) 
> $(PYTHON_FLAGS) $(srcdir)/ir3/ir3_nir_trig.py > $@ || ($(RM) $@; false)
> +   $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/ir3/ir3_nir_trig.py 
> -p $(top_srcdir)/src/compiler/nir > $@ || ($(RM) $@; false)
>  
>  noinst_LTLIBRARIES = libfreedreno.la
>  
> diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py 
> b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
> index f358f4d6bc4..a0ab9d01903 100644
> --- a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
> +++ b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
> @@ -20,13 +20,30 @@
>  # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
>  # IN THE SOFTWARE.
>  
> -import nir_algebraic
> +import argparse
> +import sys
>  
>  trig_workarounds = [
> (('fsin', 'x'), ('fsin', ('fsub', ('fmul', 6.283185, ('ffract', ('fadd', 
> ('fmul', 0.159155, 'x'), 0.5))), 3.141593))),
> (('fcos', 'x'), ('fcos', ('fsub', ('fmul', 6.283185, ('ffract', ('fadd', 
> ('fmul', 0.159155, 'x'), 0.5))), 3.141593))),
>  ]
>  
> -print '#include "ir3_nir.h"'
> -print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
> -  trig_workarounds).render()
> +
> +def main():
> +parser = argparse.ArgumentParser()
> +parser.add_argument('-p', '--import-path', required=True)
> +args = parser.parse_args()
> +sys.path.insert(0, args.import_path)
> +run()
> +
> +
> +def run():
> +import nir_algebraic  # pylint: disable=import-error
> +
> +print '#include "ir3_nir.h"'
> +print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
> +  trig_workarounds).render()
> +
> +
> +if __name__ == '__main__':
> +main()
> -- 
> 2.13.6
> 


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] Haiku: convert to autotools

2017-10-24 Thread Jérôme Duval
Hi,

2017-10-24 14:46 GMT+02:00 Eric Engestrom :
> I had a quick glance, but there's too much at once.
>
> On Monday, 2017-10-23 17:58:46 +0200, Jerome Duval wrote:
>> * configure.ac:
>>   -pthread is not available on Haiku.
>>   Haiku doesn't require --enable-dri
>>   build hgl on Haiku
>> * egl/Makefile.am: define backendfiles for Haiku
>> * src/gallium/Makefile.am: build winsys/sw/hgl, state_trackers/hgl and
>> targets/haiku-softpipe on Haiku.
>> * src/gallium/targets/haiku-softpipe: add Makefile.am
>> * src/gallium/state_trackers/hgl: add Makefile.am
>> * winsys/sw/hgl: add Makefile.am
>> * src/hgl/Makefile.am: add Makefile.am
>
> This list should be a hint: you're doing many things at once :P
> Please split this into a series, roughly one patch per item in your
> list.

Well that's a patch for a platform, which usually enable components
all over the place.

>
> When doing that, please pay attention to the order of your patches, so
> that you don't break anything in the middle (configure.ac probably needs
> to be the last patch for instance).

I resent as v2. Please consider reviewing.

>
> Side note: is Meson supported on Haiku? If it is, can you also wire it
> up? Or would you be willing to test patches that do?

Meson is supported on Haiku (ATM 0.42.1), not my area of expertise though.
But sure, I can test patches for Meson.

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


Re: [Mesa-dev] [PATCH 2/3] meson: extract out variable for nir_algebraic.py

2017-10-24 Thread Dylan Baker
Quoting Eric Engestrom (2017-10-24 08:24:39)
> On Tuesday, 2017-10-24 11:12:49 -0400, Rob Clark wrote:
> > Also needed in freedreno/ir3.
> > 
> > Signed-off-by: Rob Clark 
> > ---
> >  src/compiler/nir/meson.build   | 2 ++
> >  src/intel/compiler/meson.build | 2 +-
> >  2 files changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
> > index 144cf01d2c4..4a75c5c8b0d 100644
> > --- a/src/compiler/nir/meson.build
> > +++ b/src/compiler/nir/meson.build
> > @@ -193,6 +193,8 @@ libnir = static_library(
> >build_by_default : false,
> >  )
> >  
> > +nir_algebraic_py = join_paths(meson.source_root(), 
> > 'src/compiler/nir/nir_algebraic.py')
> 
> This can be a simple:
> nir_algebraic_py = files('nir_algebraic.py')
> 
> > +
> >  if with_tests
> >nir_control_flow_test = executable(
> >  'nir_control_flow_test',
> > diff --git a/src/intel/compiler/meson.build b/src/intel/compiler/meson.build
> > index e29e1d39e2a..6a4f016d726 100644
> > --- a/src/intel/compiler/meson.build
> > +++ b/src/intel/compiler/meson.build
> > @@ -122,7 +122,7 @@ brw_nir_trig = custom_target(
> >output : 'brw_nir_trig_workarounds.c',
> >command : [prog_python2, '@INPUT@', '-p',
> >   join_paths(meson.source_root(), 'src/compiler/nir/')],
> > -  depend_files : files('../../compiler/nir/nir_algebraic.py'),
> > +  depend_files : files(nir_algebraic_py),
> 
> And this becomes:
> depend_files : nir_algebraic_py,
> 
> With that changed:
> Reviewed-by: Eric Engestrom 

I prefer Eric's suggestion as well, with it:
Reviewed-by: Dylan Baker 

> 
> >capture : true,
> >  )
> >  
> > -- 
> > 2.13.6
> > 
> ___
> 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 3/3] meson: build freedreno

2017-10-24 Thread Eric Engestrom
On Tuesday, 2017-10-24 11:12:50 -0400, Rob Clark wrote:
> Mostly copy/pasta from Dylan Baker's conversion of nouveau and i965.
> 
> Signed-off-by: Rob Clark 
> ---
>  meson.build  |   6 +
>  meson_options.txt|   2 +-
>  src/gallium/drivers/freedreno/meson.build| 221 
> +++
>  src/gallium/meson.build  |   3 +-
>  src/gallium/targets/dri/meson.build  |   6 +
>  src/gallium/winsys/freedreno/drm/meson.build |  30 
>  6 files changed, 266 insertions(+), 2 deletions(-)
>  create mode 100644 src/gallium/drivers/freedreno/meson.build
>  create mode 100644 src/gallium/winsys/freedreno/drm/meson.build
> 
> diff --git a/meson.build b/meson.build
> index 9f481225823..8db4699ec5c 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -94,6 +94,7 @@ with_gallium = false
>  with_gallium_pl111 = false
>  with_gallium_radeonsi = false
>  with_gallium_nouveau = false
> +with_gallium_freedreno = false
>  with_gallium_softpipe = false
>  with_gallium_vc4 = false
>  with_gallium_vc5 = false
> @@ -105,6 +106,7 @@ if _drivers != ''
>with_gallium_pl111 = _split.contains('pl111')
>with_gallium_radeonsi = _split.contains('radeonsi')
>with_gallium_nouveau = _split.contains('nouveau')
> +  with_gallium_freedreno = _split.contains('freedreno')
>with_gallium_softpipe = _split.contains('swrast')
>with_gallium_vc4 = _split.contains('vc4')
>with_gallium_vc5 = _split.contains('vc5')
> @@ -614,6 +616,7 @@ dep_libdrm_amdgpu = []
>  dep_libdrm_radeon = []
>  dep_libdrm_nouveau = []
>  dep_libdrm_etnaviv = []
> +dep_libdrm_freedreno = []
>  if with_amd_vk or with_gallium_radeonsi
>dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.85')
>  endif
> @@ -626,6 +629,9 @@ endif
>  if with_gallium_etnaviv
>dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
>  endif
> +if with_gallium_freedreno
> +  dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 
> 2.4.74')
> +endif
>  
>  llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
>  if with_amd_vk
> diff --git a/meson_options.txt b/meson_options.txt
> index be93871d614..1b90f5ced88 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -46,7 +46,7 @@ option(
>  option(
>'gallium-drivers',
>type : 'string',
> -  value : 'pl111,radeonsi,nouveau,swrast,vc4,etnaviv,imx',
> +  value : 'pl111,radeonsi,nouveau,freedreno,swrast,vc4,etnaviv,imx',
>description : 'comma separated list of gallium drivers to build.'
>  )
>  option(
> diff --git a/src/gallium/drivers/freedreno/meson.build 
> b/src/gallium/drivers/freedreno/meson.build
> new file mode 100644
> index 000..e7f3becf9e6
> --- /dev/null
> +++ b/src/gallium/drivers/freedreno/meson.build
> @@ -0,0 +1,221 @@
> +# Copyright © 2017 Rob Clark
> +
> +# Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> +# of this software and associated documentation files (the "Software"), to 
> deal
> +# in the Software without restriction, including without limitation the 
> rights
> +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> +# copies of the Software, and to permit persons to whom the Software is
> +# furnished to do so, subject to the following conditions:
> +
> +# The above copyright notice and this permission notice shall be included in
> +# all copies or substantial portions of the Software.
> +
> +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
> THE
> +# SOFTWARE.
> +
> +ir3_nir_trig_c = custom_target(
> +  'ir3_nir_trig.c',
> +  input : 'ir3/ir3_nir_trig.py',
> +  output : 'ir3_nir_trig.c',
> +  command : [prog_python2, '@INPUT@', '-p',
> + join_paths(meson.source_root(), 'src/compiler/nir/')],

This is kind of ugly, but I don't think there's a better way of doing
this :(

> +  capture : true,
> +  depend_files : files(
> +'ir3/ir3_nir_trig.py',
> +nir_algebraic_py,
> +  ),

With my suggestion on the previous patch, this becomes:

  depend_files : [
files('ir3/ir3_nir_trig.py'),
nir_algebraic_py,
  ],

That said, I think the `input` array gets tracked automatically, no need
to add it to the `depend_files`.

Other than that, this patch looks good to me
Reviewed-by: Eric Engestrom 

> +)
> +
> +files_libfreedreno = files(
> +  'adreno_common.xml.h',
> +  'adreno_pm4.xml.h',
> +  'disasm.h',
> +  'freedreno_batch.c',
> +  'freedreno_batch.h',
> +  

Re: [Mesa-dev] [PATCH 2/3] mesa: enable ARB_texture_buffer_* extensions in the Compatibility profile

2017-10-24 Thread Emil Velikov
Hi Marek,

On 21 October 2017 at 13:54, Marek Olšák  wrote:
> From: Marek Olšák 
>
> We already have piglit tests testing alpha, luminance, and intensity
> formats. They were skipped by piglit until now.
>
> Additionally, I'm enabling one ARB_texture_buffer_range piglit test to run
> with the compat profile.

Can you please mention that ARB_texture_buffer_* on i965 is unchanged
- aka still enabled only for core profiles.
Out of curiosity - can you tried the series with anything more than piglit?

The Intel guys can run the lot through CTS, dEQP... admittedly only on
Intel hardware.
Still it should help catch if a piece is missing somewhere.


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


[Mesa-dev] [Bug 103427] VK_ERROR_INITIALIZATION_FAILED with 280x: vkEnumeratePhysicalDevices(vk->inst, , NULL): VK_ERROR_INITIALIZATION_FAILED

2017-10-24 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103427

--- Comment #7 from Vedran Miletić  ---
(In reply to Cris from comment #6)
> Apparently beginning with linux 4.13 you have to append "radeon.si_support=0
> radeon.cik_support=0 amdgpu.si_support=1 amdgpu.cik_support=1" to the kernel
> command line. I did, and everything's working just fine.

Glad to hear!

-- 
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] Build mesa-dev on Windows with AVX instruction set problem

2017-10-24 Thread Fabrício Ceolin
Hi,

I am trying to build mesa-dev on windows.

I am learning how to do it, through the project https://github.com/
pal1000/mesa-dist-win/tree/master/buildscript

I tried to use the binaries from pal1000, but I got an illegal instruction
problem in opengl32.dll when I tried to run my application (VTK based).

7FF96252B0CF  cmp qword ptr [rdx+18h],10h
7FF96252B0D4  mov rbp,qword ptr [rdx+10h]
7FF96252B0D8  jb
std::basic_string::basic_string+2Dh
(07FF96252B0DDh)
7FF96252B0DA  mov rsi,qword ptr [rdx]
7FF96252B0DD  cmp rbp,10h
7FF96252B0E1  jae
 std::basic_string::basic_string+5Ah
(07FF96252B10Ah)
*7FF96252B0E3  vmovups xmm0,xmmword ptr [rsi]  *
7FF96252B0E7  vmovups xmmword ptr [rcx],xmm0
7FF96252B0EB  mov qword ptr [rcx+10h],rbp

I tried to build everything on a target machine, but the problem was not
solved.

I saw here that movups is in avx instruction set here
http://www.felixcloutier.com/x86/MOVUPS.html

My target machine has the following cpuinfo (inside msys64):

cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model   : 6
model name  : QEMU Virtual CPU version 2.0.0
stepping: 3
cpu MHz : 2993.000
cache size  : 4096 KB
fpu : yes
fpu_exception   : yes
cpuid level : 4
wp  : yes
flags   : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush mmx fxsr sse sse2 pni vmx cx16 x2apic popcnt hypervisor
lahf_lm epb dtherm fsgsbase tsc_adjust bmi1 hle avx2 clflushopt
clflush size: 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

How can I compile opengl32.dll without use the avx instruction set?

My compilation command was (from mesa-dist-win):

python c:\Python27\Scripts\scons.py build=release platform=windows
machine=x86_64 swr=1 libgl-gdi osmesa graw-gdi

Thanks


[image: MiningMath Associates]

*Fabrício
Ceolin*
+55 (31) 98675-1359
MiningMath Associates 
www.miningmath.com 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] wayland-drm: static inline wayland_drm_buffer_get

2017-10-24 Thread Emil Velikov
From: Emil Velikov 

The function is effectively a direct function call into
libwayland-server.so.

Thus GBM no longer depends on the wayland-drm static library, making the
build more straight forward. And the resulting binary is a bit smaller.

Note: we need to move struct wayland_drm_callbacks further up,
otherwise we'll get an error since the type is incomplete.

v2: Rebase, beef-up commit message, update meson, move struct
wayland_drm_callbacks.

Cc: Dylan Baker 
Cc: Daniel Stone 
Signed-off-by: Emil Velikov 
Reviewed-by: Daniel Stone  (v1)
---
Dylan can you check the meson bits? Can one say to meson, build object X 
while only using the depA CFLAGS? It seems to me that it currently links 
against depA even when you don't want it to.

 src/Makefile.am   |  2 +-
 src/egl/wayland/wayland-drm/wayland-drm.c | 26 -
 src/egl/wayland/wayland-drm/wayland-drm.h | 48 +++
 src/gbm/Makefile.am   |  2 +-
 src/gbm/meson.build   |  4 +--
 5 files changed, 39 insertions(+), 43 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 5ef2d4f55ea..20e90c3d0b8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,7 +64,7 @@ endif
 # include only conditionally ?
 SUBDIRS += compiler
 
-## Optionally required by GBM, EGL
+## Optionally required by EGL
 if HAVE_PLATFORM_WAYLAND
 SUBDIRS += egl/wayland/wayland-drm
 endif
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c 
b/src/egl/wayland/wayland-drm/wayland-drm.c
index 73dfba9600e..81f6f528527 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -39,19 +39,6 @@
 
 #define MIN(x,y) (((x)<(y))?(x):(y))
 
-struct wl_drm {
-   struct wl_display *display;
-   struct wl_global *wl_drm_global;
-
-   void *user_data;
-   char *device_name;
-uint32_t flags;
-
-   struct wayland_drm_callbacks callbacks;
-
-struct wl_buffer_interface buffer_interface;
-};
-
 static void
 destroy_buffer(struct wl_resource *resource)
 {
@@ -244,19 +231,6 @@ bind_drm(struct wl_client *client, void *data, uint32_t 
version, uint32_t id)
wl_resource_post_event(resource, WL_DRM_CAPABILITIES, capabilities);
 }
 
-struct wl_drm_buffer *
-wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
-{
-   if (resource == NULL)
-   return NULL;
-
-if (wl_resource_instance_of(resource, _buffer_interface,
->buffer_interface))
-   return wl_resource_get_user_data(resource);
-else
-   return NULL;
-}
-
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
  const struct wayland_drm_callbacks *callbacks, void 
*user_data,
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.h 
b/src/egl/wayland/wayland-drm/wayland-drm.h
index 111383ff1d6..36e5bf042a7 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.h
+++ b/src/egl/wayland/wayland-drm/wayland-drm.h
@@ -4,8 +4,31 @@
 #include 
 
 struct wl_display;
-struct wl_drm;
 struct wl_resource;
+struct wl_drm_buffer;
+
+struct wayland_drm_callbacks {
+   int (*authenticate)(void *user_data, uint32_t id);
+
+   void (*reference_buffer)(void *user_data, uint32_t name, int fd,
+ struct wl_drm_buffer *buffer);
+
+   void (*release_buffer)(void *user_data, struct wl_drm_buffer *buffer);
+};
+
+
+struct wl_drm {
+   struct wl_display *display;
+   struct wl_global *wl_drm_global;
+
+   void *user_data;
+   char *device_name;
+   uint32_t flags;
+
+   struct wayland_drm_callbacks callbacks;
+
+   struct wl_buffer_interface buffer_interface;
+};
 
 struct wl_drm_buffer {
struct wl_resource *resource;
@@ -18,19 +41,20 @@ struct wl_drm_buffer {
void *driver_buffer;
 };
 
-struct wayland_drm_callbacks {
-   int (*authenticate)(void *user_data, uint32_t id);
-
-void (*reference_buffer)(void *user_data, uint32_t name, int fd,
- struct wl_drm_buffer *buffer);
-
-   void (*release_buffer)(void *user_data, struct wl_drm_buffer *buffer);
-};
-
 enum { WAYLAND_DRM_PRIME = 0x01 };
 
-struct wl_drm_buffer *
-wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource);
+static inline struct wl_drm_buffer *
+wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
+{
+   if (resource == NULL)
+   return NULL;
+
+   if (wl_resource_instance_of(resource, _buffer_interface,
+   >buffer_interface))
+   return wl_resource_get_user_data(resource);
+   else
+   return NULL;
+}
 
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
diff --git 

[Mesa-dev] [PATCH v2 2/8] Haiku: add src/hgl/Makefile.am to the build

2017-10-24 Thread Jerome Duval
From: Jérôme Duval 

---
 src/Makefile.am | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/Makefile.am b/src/Makefile.am
index 5ef2d4f..7ef63f7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -108,6 +108,10 @@ if HAVE_PLATFORM_WAYLAND
 SUBDIRS += egl/wayland/wayland-egl
 endif
 
+if HAVE_HAIKU
+SUBDIRS += hgl
+endif
+
 if HAVE_EGL
 SUBDIRS += egl
 endif
-- 
2.7.4

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


[Mesa-dev] [PATCH v2 3/8] Haiku: add support in src/egl/Makefile.am

2017-10-24 Thread Jerome Duval
From: Jérôme Duval 

---
 src/egl/Makefile.am | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
index eeb745f..9b8528645 100644
--- a/src/egl/Makefile.am
+++ b/src/egl/Makefile.am
@@ -52,6 +52,7 @@ libEGL_common_la_LIBADD = \
 
 dri2_backend_FILES =
 dri3_backend_FILES =
+haiku_backend_FILES =
 
 if HAVE_PLATFORM_X11
 AM_CFLAGS += $(XCB_DRI2_CFLAGS)
@@ -108,6 +109,22 @@ libEGL_common_la_LIBADD += $(ANDROID_LIBS)
 dri2_backend_FILES += drivers/dri2/platform_android.c
 endif
 
+if HAVE_HAIKU
+AM_CPPFLAGS = \
+   -I$(top_srcdir)/include \
+   -I$(top_srcdir)/include/HaikuGL \
+   -I$(top_srcdir)/src/egl/main \
+   -I$(top_srcdir)/src/ \
+   -D_EGL_BUILT_IN_DRIVER_HAIKU \
+   -D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM)
+haiku_backend_FILES += drivers/haiku/egl_haiku.cpp
+libEGL_common_la_LIBADD += $(top_builddir)/src/hgl/libGL.la
+libEGL_common_la_SOURCES += \
+   $(haiku_backend_FILES)
+
+endif
+
+if !HAVE_HAIKU
 AM_CFLAGS += \
-I$(top_srcdir)/src/loader \
-I$(top_builddir)/src/egl/drivers/dri2 \
@@ -151,6 +168,8 @@ g_egldispatchstubs.h: $(GLVND_GEN_DEPS)
 BUILT_SOURCES += g_egldispatchstubs.c g_egldispatchstubs.h
 CLEANFILES = $(BUILT_SOURCES)
 
+endif
+
 if USE_LIBGLVND
 AM_CFLAGS += \
$(GLVND_CFLAGS)
@@ -207,7 +226,6 @@ TESTS = egl-symbols-check \
 EXTRA_DIST = \
$(TESTS) \
SConscript \
-   drivers/haiku \
main/egl.def \
main/README.txt \
$(GLVND_GEN_DEPS) \
-- 
2.7.4

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


[Mesa-dev] [PATCH v2 8/8] Haiku: convert to autotools

2017-10-24 Thread Jerome Duval
From: Jérôme Duval 

* -pthread is not available on Haiku.
* Haiku doesn't require --enable-dri
---
 configure.ac | 30 +++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9aa02f5..58795e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -272,6 +272,9 @@ case "$host_os" in
 *-android*)
 android=yes
 ;;
+*haiku)
+haiku=yes
+;;
 linux*|*-gnu*|gnu*|cygwin*)
 DEFINES="$DEFINES -D_GNU_SOURCE"
 ;;
@@ -281,6 +284,7 @@ solaris*)
 esac
 
 AM_CONDITIONAL(HAVE_ANDROID, test "x$android" = xyes)
+AM_CONDITIONAL(HAVE_HAIKU, test "x$haiku" = xyes)
 
 dnl
 dnl Check compiler flags
@@ -863,12 +867,18 @@ dnl According to the manual when using pthreads, one 
should add -pthread to
 dnl both compile and link-time arguments.
 dnl In practise that should be sufficient for all platforms, since any
 dnl platforms build with GCC and Clang support the flag.
-PTHREAD_LIBS="$PTHREAD_LIBS -pthread"
+case "$host_os" in
+haiku*)
+;;
+* )
+PTHREAD_LIBS="$PTHREAD_LIBS -pthread"
+;;
+esac
 
 dnl pthread-stubs is mandatory on BSD platforms, due to the nature of the
 dnl project. Even then there's a notable issue as described in the project 
README
 case "$host_os" in
-linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu*)
+linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu* | haiku*)
 pthread_stubs_possible="no"
 ;;
 * )
@@ -1518,7 +1528,12 @@ require_dri_shared_libs_and_glapi() {
 if test "x$enable_dri" != xyes; then
 # There is only a single backend which won't be build/used otherwise.
 # XXX: Revisit this as the egl/haiku is a thing.
-AC_MSG_ERROR([$1 requires --enable-dri])
+case "$host_os" in
+haiku*)
+;;
+*)
+AC_MSG_ERROR([$1 requires --enable-dri]) ;;
+   esac
 fi
 
 if test "x$enable_shared_glapi" != xyes; then
@@ -1748,6 +1763,10 @@ for plat in $platforms; do
 DEFINES="$DEFINES -DHAVE_ANDROID_PLATFORM"
 ;;
 
+haiku)
+DEFINES="$DEFINES -DHAVE_HAIKU_PLATFORM"
+;;
+
 *)
 AC_MSG_ERROR([platform '$plat' does not exist])
 ;;
@@ -2892,6 +2911,7 @@ AC_CONFIG_FILES([Makefile
  src/gallium/state_trackers/clover/Makefile
  src/gallium/state_trackers/dri/Makefile
  src/gallium/state_trackers/glx/xlib/Makefile
+ src/gallium/state_trackers/hgl/Makefile
  src/gallium/state_trackers/nine/Makefile
  src/gallium/state_trackers/omx_bellagio/Makefile
  src/gallium/state_trackers/osmesa/Makefile
@@ -2902,6 +2922,7 @@ AC_CONFIG_FILES([Makefile
  src/gallium/targets/d3dadapter9/Makefile
  src/gallium/targets/d3dadapter9/d3d.pc
  src/gallium/targets/dri/Makefile
+ src/gallium/targets/haiku-softpipe/Makefile
  src/gallium/targets/libgl-xlib/Makefile
  src/gallium/targets/omx-bellagio/Makefile
  src/gallium/targets/opencl/Makefile
@@ -2926,6 +2947,7 @@ AC_CONFIG_FILES([Makefile
  src/gallium/winsys/amdgpu/drm/Makefile
  src/gallium/winsys/svga/drm/Makefile
  src/gallium/winsys/sw/dri/Makefile
+ src/gallium/winsys/sw/hgl/Makefile
  src/gallium/winsys/sw/kms-dri/Makefile
  src/gallium/winsys/sw/null/Makefile
  src/gallium/winsys/sw/wrapper/Makefile
@@ -2942,6 +2964,8 @@ AC_CONFIG_FILES([Makefile
  src/glx/windows/Makefile
  src/glx/windows/windowsdriproto.pc
  src/gtest/Makefile
+ src/hgl/Makefile
+ src/hgl/gl.pc
  src/intel/Makefile
  src/loader/Makefile
  src/mapi/Makefile
-- 
2.7.4

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


[Mesa-dev] [PATCH v2 4/8] Haiku: add src/gallium/state_trackers/hgl/Makefile.am

2017-10-24 Thread Jerome Duval
From: Jérôme Duval 

---
 src/gallium/state_trackers/hgl/Makefile.am  | 39 +
 src/gallium/state_trackers/hgl/Makefile.sources |  3 ++
 2 files changed, 42 insertions(+)
 create mode 100644 src/gallium/state_trackers/hgl/Makefile.am
 create mode 100644 src/gallium/state_trackers/hgl/Makefile.sources

diff --git a/src/gallium/state_trackers/hgl/Makefile.am 
b/src/gallium/state_trackers/hgl/Makefile.am
new file mode 100644
index 000..5b55be8
--- /dev/null
+++ b/src/gallium/state_trackers/hgl/Makefile.am
@@ -0,0 +1,39 @@
+# Copyright © 2017 Haiku, Inc. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+include Makefile.sources
+include $(top_srcdir)/src/gallium/Automake.inc
+
+
+AM_CPPFLAGS = \
+   -I$(top_srcdir)/src \
+   -I$(top_srcdir)/src/mapi \
+   -I$(top_srcdir)/src/mesa \
+   -I$(top_srcdir)/include/HaikuGL \
+   $(GALLIUM_CFLAGS)
+
+noinst_LTLIBRARIES = libhgl.la
+libhgl_la_LIBADD = -ltranslation
+libhgl_la_SOURCES = $(common_SOURCES)
+
+
+EXTRA_DIST = SConscript
diff --git a/src/gallium/state_trackers/hgl/Makefile.sources 
b/src/gallium/state_trackers/hgl/Makefile.sources
new file mode 100644
index 000..3076ba3
--- /dev/null
+++ b/src/gallium/state_trackers/hgl/Makefile.sources
@@ -0,0 +1,3 @@
+common_SOURCES := \
+   hgl.c \
+   bitmap_wrapper.cpp
-- 
2.7.4

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


[Mesa-dev] [PATCH v2 6/8] Haiku: add src/gallium/targets/haiku-softpipe/Makefile.am

2017-10-24 Thread Jerome Duval
From: Jérôme Duval 

---
 src/gallium/targets/haiku-softpipe/Makefile.am | 69 ++
 .../targets/haiku-softpipe/SoftwareRenderer.cpp|  2 +
 2 files changed, 71 insertions(+)
 create mode 100644 src/gallium/targets/haiku-softpipe/Makefile.am

diff --git a/src/gallium/targets/haiku-softpipe/Makefile.am 
b/src/gallium/targets/haiku-softpipe/Makefile.am
new file mode 100644
index 000..94599a3
--- /dev/null
+++ b/src/gallium/targets/haiku-softpipe/Makefile.am
@@ -0,0 +1,69 @@
+include $(top_srcdir)/src/gallium/Automake.inc
+
+AM_CPPFLAGS = \
+   -I$(top_srcdir)/src/mapi \
+   -I$(top_srcdir)/src/mesa \
+   -I$(top_srcdir)/src/mesa/main \
+   -I$(top_srcdir)/include/HaikuGL \
+   -I$(top_srcdir)/src/gallium/include \
+   -I$(top_srcdir)/src/gallium/winsys \
+   -I$(top_srcdir)/src/gallium/state_trackers/hgl \
+   -I/boot/system/develop/headers/private \
+   $(GALLIUM_TARGET_CFLAGS) \
+   $(DEFINES) \
+   -DGALLIUM_SOFTPIPE \
+   -DGALLIUM_RBUG \
+   -DGALLIUM_TRACE
+
+hswpipedir = ${libdir}/haiku
+hswpipe_LTLIBRARIES = libswpipe.la
+
+libswpipe_la_SOURCES = \
+   GalliumContext.cpp \
+   SoftwareRenderer.cpp
+
+libswpipe_la_LDFLAGS = \
+   -shared \
+   -shrext .so \
+   -module \
+   -avoid-version \
+   $(GC_SECTIONS)
+
+libswpipe_la_LIBADD = \
+   $(top_builddir)/src/hgl/libGL.la \
+   $(top_builddir)/src/gallium/winsys/sw/hgl/libswhgl.la \
+   $(top_builddir)/src/gallium/state_trackers/hgl/libhgl.la \
+   $(top_builddir)/src/gallium/drivers/rbug/librbug.la \
+   $(top_builddir)/src/gallium/drivers/trace/libtrace.la \
+   $(top_builddir)/src/gallium/auxiliary/libgallium.la \
+   $(top_builddir)/src/mesa/libmesagallium.la \
+   $(top_builddir)/src/gallium/drivers/softpipe/libsoftpipe.la \
+   $(GALLIUM_COMMON_LIB_DEPS) \
+   -lnetwork
+
+EXTRA_DIST = \
+   SConscript
+
+TARGET_DRIVERS =
+TARGET_CPPFLAGS =
+TARGET_LIB_DEPS =
+
+include $(top_srcdir)/src/gallium/drivers/softpipe/Automake.inc
+include $(top_srcdir)/src/gallium/drivers/llvmpipe/Automake.inc
+include $(top_srcdir)/src/gallium/drivers/swr/Automake.inc
+
+
+if HAVE_GALLIUM_LLVM
+AM_CPPFLAGS += -DGALLIUM_LLVMPIPE
+
+libswpipe_la_LIBADD += $(LLVM_LIBS) \
+   $(top_builddir)/src/gallium/drivers/llvmpipe/libllvmpipe.la
+libswpipe_la_LDFLAGS += $(LLVM_LDFLAGS)
+endif
+
+if HAVE_GALLIUM_SWR
+AM_CPPFLAGS += -DGALLIUM_SWR
+
+libswpipe_la_LIBADD += \
+$(top_builddir)/src/gallium/drivers/swr/libmesaswr.la
+endif
diff --git a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp 
b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp
index 18cb1ac..4e4888a 100644
--- a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp
+++ b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp
@@ -33,6 +33,8 @@
 
 extern const char* color_space_name(color_space space);
 
+#undef _EXPORT
+#define _EXPORT __attribute__((__visibility__("default")))
 
 extern "C" _EXPORT BGLRenderer*
 instantiate_gl_renderer(BGLView *view, ulong opts, BGLDispatcher *dispatcher)
-- 
2.7.4

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


[Mesa-dev] [PATCH v2 7/8] Haiku: add gallium Haiku components to the build.

2017-10-24 Thread Jerome Duval
From: Jérôme Duval 

---
 src/gallium/Makefile.am | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am
index ea20799..37800b9 100644
--- a/src/gallium/Makefile.am
+++ b/src/gallium/Makefile.am
@@ -119,6 +119,10 @@ if HAVE_DRISW_KMS
 SUBDIRS += winsys/sw/kms-dri
 endif
 
+if HAVE_HAIKU
+SUBDIRS += winsys/sw/hgl
+endif
+
 SUBDIRS += winsys/sw/wrapper
 
 ##
@@ -182,6 +186,10 @@ if HAVE_ST_NINE
 SUBDIRS += state_trackers/nine targets/d3dadapter9
 endif
 
+if HAVE_HAIKU
+SUBDIRS += state_trackers/hgl targets/haiku-softpipe
+endif
+
 ##
 ## Don't forget to bundle the remaining (non autotools) state-trackers/targets
 ##
@@ -191,7 +199,6 @@ EXTRA_DIST += \
state_trackers/README \
state_trackers/wgl targets/libgl-gdi \
targets/graw-gdi targets/graw-null  targets/graw-xlib \
-   state_trackers/hgl targets/haiku-softpipe \
tools
 
 
-- 
2.7.4

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


[Mesa-dev] [PATCH v2 0/8] Haiku: convert to autotools

2017-10-24 Thread Jerome Duval
From: Jérôme Duval 

Resend as a patch series as requested by Eric Engestrom.

Jérôme Duval (8):
  Haiku: add src/hgl/Makefile.am and its pkgconfig file
  Haiku: add src/hgl/Makefile.am to the build
  Haiku: add support in src/egl/Makefile.am
  Haiku: add src/gallium/state_trackers/hgl/Makefile.am
  Haiku: add src/gallium/winsys/sw/hgl/Makefile.am
  Haiku: add src/gallium/targets/haiku-softpipe/Makefile.am
  Haiku: add gallium Haiku components to the build.
  Haiku: convert to autotools

 configure.ac   | 30 +-
 src/Makefile.am|  4 ++
 src/egl/Makefile.am| 20 ++-
 src/gallium/Makefile.am|  9 ++-
 src/gallium/state_trackers/hgl/Makefile.am | 39 
 src/gallium/state_trackers/hgl/Makefile.sources|  3 +
 src/gallium/targets/haiku-softpipe/Makefile.am | 69 ++
 .../targets/haiku-softpipe/SoftwareRenderer.cpp|  2 +
 src/gallium/winsys/sw/hgl/Makefile.am  | 34 +++
 src/gallium/winsys/sw/hgl/Makefile.sources |  3 +
 src/hgl/Makefile.am| 50 
 src/hgl/Makefile.sources   |  8 +++
 src/hgl/gl.pc.in   | 11 
 13 files changed, 277 insertions(+), 5 deletions(-)
 create mode 100644 src/gallium/state_trackers/hgl/Makefile.am
 create mode 100644 src/gallium/state_trackers/hgl/Makefile.sources
 create mode 100644 src/gallium/targets/haiku-softpipe/Makefile.am
 create mode 100644 src/gallium/winsys/sw/hgl/Makefile.am
 create mode 100644 src/gallium/winsys/sw/hgl/Makefile.sources
 create mode 100644 src/hgl/Makefile.am
 create mode 100644 src/hgl/Makefile.sources
 create mode 100644 src/hgl/gl.pc.in

-- 
2.7.4

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


[Mesa-dev] [PATCH v2 1/8] Haiku: add src/hgl/Makefile.am and its pkgconfig file

2017-10-24 Thread Jerome Duval
From: Jérôme Duval 

---
 src/hgl/Makefile.am  | 50 
 src/hgl/Makefile.sources |  8 
 src/hgl/gl.pc.in | 11 +++
 3 files changed, 69 insertions(+)
 create mode 100644 src/hgl/Makefile.am
 create mode 100644 src/hgl/Makefile.sources
 create mode 100644 src/hgl/gl.pc.in

diff --git a/src/hgl/Makefile.am b/src/hgl/Makefile.am
new file mode 100644
index 000..f82602a
--- /dev/null
+++ b/src/hgl/Makefile.am
@@ -0,0 +1,50 @@
+# Copyright © 2017 Haiku, Inc. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+include Makefile.sources
+
+AM_CPPFLAGS = \
+   -I$(top_srcdir)/src \
+   -I$(top_srcdir)/src/mapi \
+   -I$(top_srcdir)/src/mesa \
+   -I$(top_srcdir)/src/mesa/main \
+   -I$(top_srcdir)/include/ \
+   -I$(top_srcdir)/include/HaikuGL \
+   -I/system/develop/headers/private \
+   -I$(top_builddir)/src/mapi \
+   $(DEFINES)
+
+
+lib_LTLIBRARIES = libGL.la
+
+libGL_la_LIBADD = $(top_builddir)/src/mapi/glapi/libglapi.la -lbe
+libGL_la_SOURCES = $(COMMON_SOURCES)
+libGL_la_LDFLAGS = \
+   -no-undefined \
+   -version-number 1:0 \
+   $(BSYMBOLIC) \
+   $(GC_SECTIONS) \
+   $(LD_NO_UNDEFINED)
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = gl.pc
+
+EXTRA_DIST =
diff --git a/src/hgl/Makefile.sources b/src/hgl/Makefile.sources
new file mode 100644
index 000..5df230b
--- /dev/null
+++ b/src/hgl/Makefile.sources
@@ -0,0 +1,8 @@
+COMMON_SOURCES := \
+GLView.cpp \
+GLRenderer.cpp \
+GLRendererRoster.cpp \
+GLRendererRoster.h \
+GLDispatcher.cpp \
+GLDispatcher.h
+
diff --git a/src/hgl/gl.pc.in b/src/hgl/gl.pc.in
new file mode 100644
index 000..7577bae
--- /dev/null
+++ b/src/hgl/gl.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=@includedir@
+
+Name: gl
+Description: Mesa OpenGL library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lGL
+Libs.private: @GL_PC_LIB_PRIV@
+Cflags: -I${includedir} @GL_PC_CFLAGS@
-- 
2.7.4

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


[Mesa-dev] [PATCH v2 5/8] Haiku: add src/gallium/winsys/sw/hgl/Makefile.am

2017-10-24 Thread Jerome Duval
From: Jérôme Duval 

---
 src/gallium/winsys/sw/hgl/Makefile.am  | 34 ++
 src/gallium/winsys/sw/hgl/Makefile.sources |  3 +++
 2 files changed, 37 insertions(+)
 create mode 100644 src/gallium/winsys/sw/hgl/Makefile.am
 create mode 100644 src/gallium/winsys/sw/hgl/Makefile.sources

diff --git a/src/gallium/winsys/sw/hgl/Makefile.am 
b/src/gallium/winsys/sw/hgl/Makefile.am
new file mode 100644
index 000..8e5d403
--- /dev/null
+++ b/src/gallium/winsys/sw/hgl/Makefile.am
@@ -0,0 +1,34 @@
+# Copyright © 2017 Haiku, Inc. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+include Makefile.sources
+include $(top_srcdir)/src/gallium/Automake.inc
+
+AM_CFLAGS = \
+   -I$(top_srcdir)/src/gallium/state_trackers/hgl \
+   $(GALLIUM_WINSYS_CFLAGS)
+
+noinst_LTLIBRARIES = libswhgl.la
+
+libswhgl_la_SOURCES = $(C_SOURCES)
+
+EXTRA_DIST = SConscript
diff --git a/src/gallium/winsys/sw/hgl/Makefile.sources 
b/src/gallium/winsys/sw/hgl/Makefile.sources
new file mode 100644
index 000..52bfc88
--- /dev/null
+++ b/src/gallium/winsys/sw/hgl/Makefile.sources
@@ -0,0 +1,3 @@
+C_SOURCES := \
+   hgl_sw_winsys.c \
+   hgl_sw_winsys.h
-- 
2.7.4

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


[Mesa-dev] [PATCH] i965: Disable L3 cache allocation for external buffers

2017-10-24 Thread Chris Wilson
Through the use of mocs, we can define the cache usage for any surface
used by the GPU. In particular, we can request that L3 cache be
allocated for either a read/write miss so that subsequent reads can be
fetched from cache rather than memory. A consequence of this is that if
we allocate a L3/LLC cacheline for a read and the object is changed in
main memory (e.g. a PCIe write bypassing the CPU) then the next read
will be serviced from the stale cache and not from the new data in
memory. This is an issue for external PRIME buffers where we may miss
the updates entirely if the image is small enough to fit within our
cache.

Currently, we have a single bit to mark all external buffers so use that
to tell us when it is unsafe to use a cache override in mocs and
fallback to the PTE value instead (which should be set to the correct
cache level to be coherent amongst all active parties: PRIME, scanout and
render). This may be refined in future to limit the override to buffers
outside the control of mesa; as buffers being shared between mesa
clients should be able to coordinate themselves without resolves.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101691
Cc: Kenneth Graunke 
Cc: Jason Ekstrand 
Cc: Lyude Paul 
Cc: Timo Aalton 
Cc: Ben Widawsky 
Cc: Daniel Vetter 
---
 src/intel/blorp/blorp.c  |  1 +
 src/intel/blorp/blorp.h  |  1 +
 src/intel/blorp/blorp_genX_exec.h|  2 +-
 src/intel/blorp/blorp_priv.h |  1 +
 src/mesa/drivers/dri/i965/brw_blorp.c|  1 +
 src/mesa/drivers/dri/i965/brw_state.h|  3 ++-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 16 +++-
 7 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/intel/blorp/blorp.c b/src/intel/blorp/blorp.c
index 7cc6335f2f..459ad66652 100644
--- a/src/intel/blorp/blorp.c
+++ b/src/intel/blorp/blorp.c
@@ -71,6 +71,7 @@ brw_blorp_surface_info_init(struct blorp_context *blorp,
surf->surf->logical_level0_px.array_len));
 
info->enabled = true;
+   info->external = surf->external;
 
if (format == ISL_FORMAT_UNSUPPORTED)
   format = surf->surf->format;
diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h
index 9716c66302..af056c9d52 100644
--- a/src/intel/blorp/blorp.h
+++ b/src/intel/blorp/blorp.h
@@ -106,6 +106,7 @@ struct blorp_surf
enum isl_aux_usage aux_usage;
 
union isl_color_value clear_color;
+   bool external;
 };
 
 void
diff --git a/src/intel/blorp/blorp_genX_exec.h 
b/src/intel/blorp/blorp_genX_exec.h
index 5389262098..18715788ff 100644
--- a/src/intel/blorp/blorp_genX_exec.h
+++ b/src/intel/blorp/blorp_genX_exec.h
@@ -1328,7 +1328,7 @@ blorp_emit_surface_states(struct blorp_batch *batch,
  blorp_emit_surface_state(batch, >src,
   surface_maps[BLORP_TEXTURE_BT_INDEX],
   surface_offsets[BLORP_TEXTURE_BT_INDEX],
-  NULL, false);
+  NULL, params->src.external);
   }
}
 
diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
index c7d5d308da..f841aa7cdc 100644
--- a/src/intel/blorp/blorp_priv.h
+++ b/src/intel/blorp/blorp_priv.h
@@ -47,6 +47,7 @@ enum {
 struct brw_blorp_surface_info
 {
bool enabled;
+   bool external;
 
struct isl_surf surf;
struct blorp_address addr;
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c 
b/src/mesa/drivers/dri/i965/brw_blorp.c
index ed4f9870f2..563d13a037 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.c
+++ b/src/mesa/drivers/dri/i965/brw_blorp.c
@@ -160,6 +160,7 @@ blorp_surf_for_miptree(struct brw_context *brw,
   .offset = mt->offset,
   .reloc_flags = is_render_target ? EXEC_OBJECT_WRITE : 0,
};
+   surf->external = mt->bo->external;
 
surf->aux_usage = aux_usage;
 
diff --git a/src/mesa/drivers/dri/i965/brw_state.h 
b/src/mesa/drivers/dri/i965/brw_state.h
index 8db354cf23..01c0cd12cb 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -342,6 +342,7 @@ void gen10_init_atoms(struct brw_context *brw);
  * may still respect that.
  */
 #define GEN7_MOCS_L31
+#define GEN7_MOCS_PTE   0
 
 /* Ivybridge only: cache in LLC.
  * Specifying zero here means to use the PTE values set by the kernel;
@@ -367,7 +368,7 @@ void gen10_init_atoms(struct brw_context *brw);
  */
 #define BDW_MOCS_WB  0x78
 #define BDW_MOCS_WT  0x58
-#define BDW_MOCS_PTE 0x18
+#define BDW_MOCS_PTE 0x08
 
 /* Skylake: MOCS is now an index into an array of 62 different caching
  * configurations programmed by the kernel.
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 f4e9cf48c6..50a3682efc 100644

Re: [Mesa-dev] [PATCH v3 21/34] i965: add initial implementation of on disk shader cache

2017-10-24 Thread Jason Ekstrand
looks good

On Tue, Oct 24, 2017 at 12:06 AM, Jordan Justen 
wrote:

> On 2017-10-23 19:48:51, Jason Ekstrand wrote:
> >
> > On Sun, Oct 22, 2017 at 1:01 PM, Jordan Justen <
> jordan.l.jus...@intel.com>
> > wrote:
> >
> > > +   #define SET_UPLOAD_PARAMS(sh, sh_caps, prog)  \
> > > +  do {   \
> > > + prog_key.sh.program_string_id = prog->id;   \
> > > + cache_id = BRW_CACHE_##sh_caps##_PROG;  \
> > > + max_threads = devinfo->max_##sh##_threads;  \
> > > + stage_state = >sh.base;\
> > > +  } while(0)
> > > +
> > > +   switch (stage) {
> > > +   case MESA_SHADER_VERTEX: {
> > > +  struct brw_program *vp = (struct brw_program *) prog;
> > >
> >
> > I think you can move the cast inside the macro.  It's all brw_program as
> > far as I can see.
> >
> >
> > > +  SET_UPLOAD_PARAMS(vs, VS, vp);
> > > +  break;
> > > +   }
>
> Yeah, it looks like it can be simplified:
>
> diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c
> b/src/mesa/drivers/dri/i965/brw_disk_cache.c
> index 9b5e0c3e078..f3b2a6f9b51 100644
> --- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
> +++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
> @@ -228,45 +228,33 @@ read_and_upload(struct brw_context *brw, struct
> disk_cache *cache,
> unsigned max_threads;
> struct brw_stage_state *stage_state;
>
> -   #define SET_UPLOAD_PARAMS(sh, sh_caps, prog)  \
> +   #define SET_UPLOAD_PARAMS(sh, sh_caps)\
>do {   \
> - prog_key.sh.program_string_id = prog->id;   \
> + prog_key.sh.program_string_id = brw_program(prog)->id;  \
>   cache_id = BRW_CACHE_##sh_caps##_PROG;  \
>   max_threads = devinfo->max_##sh##_threads;  \
>   stage_state = >sh.base;\
>} while(0)
>
> switch (stage) {
> -   case MESA_SHADER_VERTEX: {
> -  struct brw_program *vp = (struct brw_program *) prog;
> -  SET_UPLOAD_PARAMS(vs, VS, vp);
> +   case MESA_SHADER_VERTEX:
> +  SET_UPLOAD_PARAMS(vs, VS);
>break;
> -   }
> -   case MESA_SHADER_TESS_CTRL: {
> -  struct brw_program *tcp = (struct brw_program *) prog;
> -  SET_UPLOAD_PARAMS(tcs, TCS, tcp);
> +   case MESA_SHADER_TESS_CTRL:
> +  SET_UPLOAD_PARAMS(tcs, TCS);
>break;
> -   }
> -   case MESA_SHADER_TESS_EVAL: {
> -  struct brw_program *tep = (struct brw_program *) prog;
> -  SET_UPLOAD_PARAMS(tes, TES, tep);
> +   case MESA_SHADER_TESS_EVAL:
> +  SET_UPLOAD_PARAMS(tes, TES);
>break;
> -   }
> -   case MESA_SHADER_GEOMETRY: {
> -  struct brw_program *gp = (struct brw_program *) prog;
> -  SET_UPLOAD_PARAMS(gs, GS, gp);
> +   case MESA_SHADER_GEOMETRY:
> +  SET_UPLOAD_PARAMS(gs, GS);
>break;
> -   }
> -   case MESA_SHADER_FRAGMENT: {
> -  struct brw_program *wp = (struct brw_program *) prog;
> -  SET_UPLOAD_PARAMS(wm, FS, wp);
> +   case MESA_SHADER_FRAGMENT:
> +  SET_UPLOAD_PARAMS(wm, FS);
>break;
> -   }
> -   case MESA_SHADER_COMPUTE: {
> -  struct brw_program *cp = (struct brw_program *) prog;
> -  SET_UPLOAD_PARAMS(cs, CS, cp);
> +   case MESA_SHADER_COMPUTE:
> +  SET_UPLOAD_PARAMS(cs, CS);
>break;
> -   }
> default:
>unreachable("Unsupported stage!");
> }
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 6/8] egl: add dri2_egl_surface_destroy_image_front() helper (v2)

2017-10-24 Thread Gurchetan Singh
Hi Gwan-gyeong,

You should use dri2_surface_free_image in the next patchset you send out
(should be pretty easy to implement), but can save the polishing of struct
dri2_egl_surface for later.

On Mon, Oct 23, 2017 at 1:46 PM, Mun, Gwan-gyeong 
wrote:

> Hi Gurchetan,
>
> 2017-10-18 6:02 GMT+09:00 Gurchetan Singh :
> > dri2_egl_surface_destroy_image_front and dri2_egl_surface_destroy_
> image_back
> > are almost identical.  Why don't you just create a
> > dri2_surface_free_image(struct dri2_egl_surface *dri2_surf, __DRIimage
> > **img) that you will call with both the front and back images?  In
> addition,
>
> As your opinion, we can rafactor more for dri2_surface_free_image.
>
> Nevertheless however, I'd suggest keeping that as separate series.
> these patches started as a way to minimise the duplication we have in
> drivers/dri2.
> So that new platforms such as Tizen do not need to copy the lot. [1]
>
> > only platform_android has dri_image_back and dri_image_front -- please
> keep
>
> In this patch, dri2_egl_surface_destroy_image_front() helper is only
> used for android
> however it will also be used for new platform (Tizen). [2]
>
> [1] https://lists.freedesktop.org/archives/mesa-dev/2017-
> October/173269.html
> [2] https://lists.freedesktop.org/archives/mesa-dev/2017-
> October/172007.html
>
>
> Thanks,
>
> Gwan-gyeong
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] meson: extract out variable for nir_algebraic.py

2017-10-24 Thread Eric Engestrom
On Tuesday, 2017-10-24 11:12:49 -0400, Rob Clark wrote:
> Also needed in freedreno/ir3.
> 
> Signed-off-by: Rob Clark 
> ---
>  src/compiler/nir/meson.build   | 2 ++
>  src/intel/compiler/meson.build | 2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
> index 144cf01d2c4..4a75c5c8b0d 100644
> --- a/src/compiler/nir/meson.build
> +++ b/src/compiler/nir/meson.build
> @@ -193,6 +193,8 @@ libnir = static_library(
>build_by_default : false,
>  )
>  
> +nir_algebraic_py = join_paths(meson.source_root(), 
> 'src/compiler/nir/nir_algebraic.py')

This can be a simple:
nir_algebraic_py = files('nir_algebraic.py')

> +
>  if with_tests
>nir_control_flow_test = executable(
>  'nir_control_flow_test',
> diff --git a/src/intel/compiler/meson.build b/src/intel/compiler/meson.build
> index e29e1d39e2a..6a4f016d726 100644
> --- a/src/intel/compiler/meson.build
> +++ b/src/intel/compiler/meson.build
> @@ -122,7 +122,7 @@ brw_nir_trig = custom_target(
>output : 'brw_nir_trig_workarounds.c',
>command : [prog_python2, '@INPUT@', '-p',
>   join_paths(meson.source_root(), 'src/compiler/nir/')],
> -  depend_files : files('../../compiler/nir/nir_algebraic.py'),
> +  depend_files : files(nir_algebraic_py),

And this becomes:
depend_files : nir_algebraic_py,

With that changed:
Reviewed-by: Eric Engestrom 

>capture : true,
>  )
>  
> -- 
> 2.13.6
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] radv: print NIR before LLVM IR and disassembly

2017-10-24 Thread Samuel Pitoiset
It's still printed after linking, but it makes more sense to
have SPIRV->NIR->LLVM IR->ASM.

Fixes: f0a2bbd1a4 (radv: move nir print after linking is done)
Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_pipeline.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index d6b33a5327..7ad09cec83 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -1786,6 +1786,14 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
 
radv_link_shaders(pipeline, nir);
 
+   for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
+   if (!(device->instance->debug_flags & RADV_DEBUG_DUMP_SHADERS))
+   continue;
+
+   if (modules[i])
+   nir_print_shader(nir[i], stderr);
+   }
+
if (nir[MESA_SHADER_FRAGMENT]) {
if (!pipeline->shaders[MESA_SHADER_FRAGMENT]) {
pipeline->shaders[MESA_SHADER_FRAGMENT] =
@@ -1870,13 +1878,8 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
 
for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
free(codes[i]);
-   if (modules[i]) {
-   if (device->instance->debug_flags & 
RADV_DEBUG_DUMP_SHADERS)
-   nir_print_shader(nir[i], stderr);
-
-   if (!pipeline->device->trace_bo)
-   ralloc_free(nir[i]);
-   }
+   if (modules[i] && !pipeline->device->trace_bo)
+   ralloc_free(nir[i]);
}
 
if (fs_m.nir)
-- 
2.14.2

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


Re: [Mesa-dev] [PATCH 1/3] freedreno/ir3: use a flag instead of setting PYTHONPATH

2017-10-24 Thread Eric Engestrom
On Tuesday, 2017-10-24 11:12:48 -0400, Rob Clark wrote:
> Similar to 848da662224326ccfbe6647bc82f4f89ca22c762, pass an arg to
> ir3_nir_trig.py to add to python path, rather than using $PYTHONPATH,
> to prep for meson build support.
> 
> Signed-off-by: Rob Clark 

Reviewed-by: Eric Engestrom 

> ---
>  src/gallium/drivers/freedreno/Android.gen.mk  |  2 +-
>  src/gallium/drivers/freedreno/Makefile.am |  2 +-
>  src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py | 25 
> +++
>  3 files changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/src/gallium/drivers/freedreno/Android.gen.mk 
> b/src/gallium/drivers/freedreno/Android.gen.mk
> index 072cf998aed..17b6fbe1b7e 100644
> --- a/src/gallium/drivers/freedreno/Android.gen.mk
> +++ b/src/gallium/drivers/freedreno/Android.gen.mk
> @@ -32,7 +32,7 @@ intermediates := $(call local-generated-sources-dir)
>  
>  $(intermediates)/ir3/ir3_nir_trig.c: $(ir3_nir_trig_deps)
>   @mkdir -p $(dir $@)
> - $(hide) PYTHONPATH=$(MESA_TOP)/src/compiler/nir $(MESA_PYTHON2) $< > $@
> + $(hide) $(MESA_PYTHON2) $< -p $(MESA_TOP)/src/compiler/nir > $@
>  
>  LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/, \
>   $(ir3_GENERATED_FILES))
> diff --git a/src/gallium/drivers/freedreno/Makefile.am 
> b/src/gallium/drivers/freedreno/Makefile.am
> index 128c7fb5990..5cb4c74cb68 100644
> --- a/src/gallium/drivers/freedreno/Makefile.am
> +++ b/src/gallium/drivers/freedreno/Makefile.am
> @@ -12,7 +12,7 @@ AM_CFLAGS = \
>  MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
>  ir3/ir3_nir_trig.c: ir3/ir3_nir_trig.py 
> $(top_srcdir)/src/compiler/nir/nir_algebraic.py
>   $(MKDIR_GEN)
> - $(AM_V_GEN) PYTHONPATH=$(top_srcdir)/src/compiler/nir $(PYTHON2) 
> $(PYTHON_FLAGS) $(srcdir)/ir3/ir3_nir_trig.py > $@ || ($(RM) $@; false)
> + $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/ir3/ir3_nir_trig.py -p 
> $(top_srcdir)/src/compiler/nir > $@ || ($(RM) $@; false)
>  
>  noinst_LTLIBRARIES = libfreedreno.la
>  
> diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py 
> b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
> index f358f4d6bc4..a0ab9d01903 100644
> --- a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
> +++ b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
> @@ -20,13 +20,30 @@
>  # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
>  # IN THE SOFTWARE.
>  
> -import nir_algebraic
> +import argparse
> +import sys
>  
>  trig_workarounds = [
> (('fsin', 'x'), ('fsin', ('fsub', ('fmul', 6.283185, ('ffract', ('fadd', 
> ('fmul', 0.159155, 'x'), 0.5))), 3.141593))),
> (('fcos', 'x'), ('fcos', ('fsub', ('fmul', 6.283185, ('ffract', ('fadd', 
> ('fmul', 0.159155, 'x'), 0.5))), 3.141593))),
>  ]
>  
> -print '#include "ir3_nir.h"'
> -print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
> -  trig_workarounds).render()
> +
> +def main():
> +parser = argparse.ArgumentParser()
> +parser.add_argument('-p', '--import-path', required=True)
> +args = parser.parse_args()
> +sys.path.insert(0, args.import_path)
> +run()
> +
> +
> +def run():
> +import nir_algebraic  # pylint: disable=import-error
> +
> +print '#include "ir3_nir.h"'
> +print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
> +  trig_workarounds).render()
> +
> +
> +if __name__ == '__main__':
> +main()
> -- 
> 2.13.6
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/8] egl: add dri2_egl_surface_free_outdated_buffers_and_update_size() helper (v2)

2017-10-24 Thread Gurchetan Singh
Hi Gwan-yeong,

I'm fine with the conventions you suggested -- my main nit was with the
verbosity.  The downside is you're going to have to downcast every single
time.  Your call ..

On Mon, Oct 23, 2017 at 1:22 PM, Mun, Gwan-gyeong 
wrote:

> Hi Emil and Gurchetan,
>
> Thank you for  reviewing the patches.
>
> 2017-10-20 6:18 GMT+09:00 Gurchetan Singh :
> > De-duplicating and then trimming down works for me.
> >
> > On Thu, Oct 19, 2017 at 3:31 AM, Emil Velikov 
> > wrote:
> >>
> >> On 18 October 2017 at 23:36, Gurchetan Singh
> >>  wrote:
> >> >> Then again, I'd suggest keeping that as separate series. These
> patches
> >> >> started as a way to minimise the duplication we have in drivers/dri2.
> >> >
> >> > I'm fine with dri2_$action_$object.  We can modify the existing
> >> > functions
> >> > later, but I recommend adopting more concise conventions in this
> >> > patchset,
> >> > i.e:
> >> >
> >> > dri2_egl_surface_record_buffers_and_update_back_buffer -->
> >> > dri2_set_back_buffer_surface
> >> > dri2_egl_surface_free_outdated_buffers_and_update_size -->
> >> > dri2_fixup_surface
> >> > dri2_egl_surface_update_buffer_age --> dri2_update_age_surface
> >> > dri2_egl_surface_get_image_front --> dri2_get_front_image_surface
> >> >
> >> Sure thing, let's use consistent names with this series.
> >>
>
> It seems great with your suggested helper function names.
>
> nevertheless, egl/driver/dri3/ codes also use such as
> dri2_surface_$action_$object naming conventions.
>
> (ie.
>   __DRIdrawable *dri2_surface_get_dri_drawable(_EGLSurface *surf)
>   void dri2_surface_set_out_fence_fd(_EGLSurface *surf, int fence_fd)
> )
>
> If you are fine with dri2_surface_$action_$object naming convention, I
> suggest these function prototype.
> These have dri2_surface_$action_$object naming convention and change
> type of first argument.
>  (struct dri2_egl_surface => _EGLSurface )
>
> ie.
>   void dri2_egl_surface_record_buffers_and_update_back_buffer(struct
> dri2_egl_surface *dri2_surf, void *buffer)
>=> void dri2_surface_set_back_buffer(_EGLSurface *surf, void *buffer)
>
>   void dri2_egl_surface_free_outdated_buffers_and_update_size(struct
> dri2_egl_surface *dri2_surf, int width, int height)
>=> void dri2_surface_fixup(_EGLSurface *surf, int width, int height)
>
>   void dri2_egl_surface_update_buffer_age(struct dri2_egl_surface
> *dri2_surf)
>=> void dri2_surface_update_age(_EGLSurface *surf)
>
>   int dri2_egl_surface_get_image_front(struct dri2_egl_surface
> *dri2_surf, unsigned int format)
>=> int dri2_surface_get_front_image(_EGLSurface *surf, unsigned int
> format)
>
>
> What do you think about this?
>
> Thanks,
>
> Gwan-gyeong.
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] vulkan/wsi: Avoid waiting indefinitely for present completion in x11_manage_fifo_queues().

2017-10-24 Thread Henri Verbeet
On 24 October 2017 at 16:11, Fredrik Höglund  wrote:
>> @@ -934,9 +938,18 @@ x11_manage_fifo_queues(void *state)
>>
>>while (chain->last_present_msc < target_msc) {
>>   xcb_generic_event_t *event =
>> -xcb_wait_for_special_event(chain->conn, chain->special_event);
>> - if (!event)
>> -goto fail;
>> +xcb_poll_for_special_event(chain->conn, chain->special_event);
>> + if (!event) {
>> +int ret = poll(, 1, 100);
>
> There is a race condition here where another thread can read the event
> from the file descriptor in the time between the calls to
> xcb_poll_for_special_event() and poll().
>
Is that a scenario we care about? Unless I'm misunderstanding
something, the same kind of thing could happen between
x11_present_to_x11() and xcb_wait_for_special_event().
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/3] meson: extract out variable for nir_algebraic.py

2017-10-24 Thread Rob Clark
Also needed in freedreno/ir3.

Signed-off-by: Rob Clark 
---
 src/compiler/nir/meson.build   | 2 ++
 src/intel/compiler/meson.build | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
index 144cf01d2c4..4a75c5c8b0d 100644
--- a/src/compiler/nir/meson.build
+++ b/src/compiler/nir/meson.build
@@ -193,6 +193,8 @@ libnir = static_library(
   build_by_default : false,
 )
 
+nir_algebraic_py = join_paths(meson.source_root(), 
'src/compiler/nir/nir_algebraic.py')
+
 if with_tests
   nir_control_flow_test = executable(
 'nir_control_flow_test',
diff --git a/src/intel/compiler/meson.build b/src/intel/compiler/meson.build
index e29e1d39e2a..6a4f016d726 100644
--- a/src/intel/compiler/meson.build
+++ b/src/intel/compiler/meson.build
@@ -122,7 +122,7 @@ brw_nir_trig = custom_target(
   output : 'brw_nir_trig_workarounds.c',
   command : [prog_python2, '@INPUT@', '-p',
  join_paths(meson.source_root(), 'src/compiler/nir/')],
-  depend_files : files('../../compiler/nir/nir_algebraic.py'),
+  depend_files : files(nir_algebraic_py),
   capture : true,
 )
 
-- 
2.13.6

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


[Mesa-dev] [PATCH 1/3] freedreno/ir3: use a flag instead of setting PYTHONPATH

2017-10-24 Thread Rob Clark
Similar to 848da662224326ccfbe6647bc82f4f89ca22c762, pass an arg to
ir3_nir_trig.py to add to python path, rather than using $PYTHONPATH,
to prep for meson build support.

Signed-off-by: Rob Clark 
---
 src/gallium/drivers/freedreno/Android.gen.mk  |  2 +-
 src/gallium/drivers/freedreno/Makefile.am |  2 +-
 src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py | 25 +++
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/freedreno/Android.gen.mk 
b/src/gallium/drivers/freedreno/Android.gen.mk
index 072cf998aed..17b6fbe1b7e 100644
--- a/src/gallium/drivers/freedreno/Android.gen.mk
+++ b/src/gallium/drivers/freedreno/Android.gen.mk
@@ -32,7 +32,7 @@ intermediates := $(call local-generated-sources-dir)
 
 $(intermediates)/ir3/ir3_nir_trig.c: $(ir3_nir_trig_deps)
@mkdir -p $(dir $@)
-   $(hide) PYTHONPATH=$(MESA_TOP)/src/compiler/nir $(MESA_PYTHON2) $< > $@
+   $(hide) $(MESA_PYTHON2) $< -p $(MESA_TOP)/src/compiler/nir > $@
 
 LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/, \
$(ir3_GENERATED_FILES))
diff --git a/src/gallium/drivers/freedreno/Makefile.am 
b/src/gallium/drivers/freedreno/Makefile.am
index 128c7fb5990..5cb4c74cb68 100644
--- a/src/gallium/drivers/freedreno/Makefile.am
+++ b/src/gallium/drivers/freedreno/Makefile.am
@@ -12,7 +12,7 @@ AM_CFLAGS = \
 MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
 ir3/ir3_nir_trig.c: ir3/ir3_nir_trig.py 
$(top_srcdir)/src/compiler/nir/nir_algebraic.py
$(MKDIR_GEN)
-   $(AM_V_GEN) PYTHONPATH=$(top_srcdir)/src/compiler/nir $(PYTHON2) 
$(PYTHON_FLAGS) $(srcdir)/ir3/ir3_nir_trig.py > $@ || ($(RM) $@; false)
+   $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/ir3/ir3_nir_trig.py -p 
$(top_srcdir)/src/compiler/nir > $@ || ($(RM) $@; false)
 
 noinst_LTLIBRARIES = libfreedreno.la
 
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py 
b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
index f358f4d6bc4..a0ab9d01903 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
@@ -20,13 +20,30 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-import nir_algebraic
+import argparse
+import sys
 
 trig_workarounds = [
(('fsin', 'x'), ('fsin', ('fsub', ('fmul', 6.283185, ('ffract', ('fadd', 
('fmul', 0.159155, 'x'), 0.5))), 3.141593))),
(('fcos', 'x'), ('fcos', ('fsub', ('fmul', 6.283185, ('ffract', ('fadd', 
('fmul', 0.159155, 'x'), 0.5))), 3.141593))),
 ]
 
-print '#include "ir3_nir.h"'
-print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
-  trig_workarounds).render()
+
+def main():
+parser = argparse.ArgumentParser()
+parser.add_argument('-p', '--import-path', required=True)
+args = parser.parse_args()
+sys.path.insert(0, args.import_path)
+run()
+
+
+def run():
+import nir_algebraic  # pylint: disable=import-error
+
+print '#include "ir3_nir.h"'
+print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
+  trig_workarounds).render()
+
+
+if __name__ == '__main__':
+main()
-- 
2.13.6

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


[Mesa-dev] [PATCH 3/3] meson: build freedreno

2017-10-24 Thread Rob Clark
Mostly copy/pasta from Dylan Baker's conversion of nouveau and i965.

Signed-off-by: Rob Clark 
---
 meson.build  |   6 +
 meson_options.txt|   2 +-
 src/gallium/drivers/freedreno/meson.build| 221 +++
 src/gallium/meson.build  |   3 +-
 src/gallium/targets/dri/meson.build  |   6 +
 src/gallium/winsys/freedreno/drm/meson.build |  30 
 6 files changed, 266 insertions(+), 2 deletions(-)
 create mode 100644 src/gallium/drivers/freedreno/meson.build
 create mode 100644 src/gallium/winsys/freedreno/drm/meson.build

diff --git a/meson.build b/meson.build
index 9f481225823..8db4699ec5c 100644
--- a/meson.build
+++ b/meson.build
@@ -94,6 +94,7 @@ with_gallium = false
 with_gallium_pl111 = false
 with_gallium_radeonsi = false
 with_gallium_nouveau = false
+with_gallium_freedreno = false
 with_gallium_softpipe = false
 with_gallium_vc4 = false
 with_gallium_vc5 = false
@@ -105,6 +106,7 @@ if _drivers != ''
   with_gallium_pl111 = _split.contains('pl111')
   with_gallium_radeonsi = _split.contains('radeonsi')
   with_gallium_nouveau = _split.contains('nouveau')
+  with_gallium_freedreno = _split.contains('freedreno')
   with_gallium_softpipe = _split.contains('swrast')
   with_gallium_vc4 = _split.contains('vc4')
   with_gallium_vc5 = _split.contains('vc5')
@@ -614,6 +616,7 @@ dep_libdrm_amdgpu = []
 dep_libdrm_radeon = []
 dep_libdrm_nouveau = []
 dep_libdrm_etnaviv = []
+dep_libdrm_freedreno = []
 if with_amd_vk or with_gallium_radeonsi
   dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.85')
 endif
@@ -626,6 +629,9 @@ endif
 if with_gallium_etnaviv
   dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
 endif
+if with_gallium_freedreno
+  dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.74')
+endif
 
 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
 if with_amd_vk
diff --git a/meson_options.txt b/meson_options.txt
index be93871d614..1b90f5ced88 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -46,7 +46,7 @@ option(
 option(
   'gallium-drivers',
   type : 'string',
-  value : 'pl111,radeonsi,nouveau,swrast,vc4,etnaviv,imx',
+  value : 'pl111,radeonsi,nouveau,freedreno,swrast,vc4,etnaviv,imx',
   description : 'comma separated list of gallium drivers to build.'
 )
 option(
diff --git a/src/gallium/drivers/freedreno/meson.build 
b/src/gallium/drivers/freedreno/meson.build
new file mode 100644
index 000..e7f3becf9e6
--- /dev/null
+++ b/src/gallium/drivers/freedreno/meson.build
@@ -0,0 +1,221 @@
+# Copyright © 2017 Rob Clark
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+ir3_nir_trig_c = custom_target(
+  'ir3_nir_trig.c',
+  input : 'ir3/ir3_nir_trig.py',
+  output : 'ir3_nir_trig.c',
+  command : [prog_python2, '@INPUT@', '-p',
+ join_paths(meson.source_root(), 'src/compiler/nir/')],
+  capture : true,
+  depend_files : files(
+'ir3/ir3_nir_trig.py',
+nir_algebraic_py,
+  ),
+)
+
+files_libfreedreno = files(
+  'adreno_common.xml.h',
+  'adreno_pm4.xml.h',
+  'disasm.h',
+  'freedreno_batch.c',
+  'freedreno_batch.h',
+  'freedreno_batch_cache.c',
+  'freedreno_batch_cache.h',
+  'freedreno_context.c',
+  'freedreno_context.h',
+  'freedreno_draw.c',
+  'freedreno_draw.h',
+  'freedreno_fence.c',
+  'freedreno_fence.h',
+  'freedreno_gmem.c',
+  'freedreno_gmem.h',
+  'freedreno_program.c',
+  'freedreno_program.h',
+  'freedreno_query.c',
+  'freedreno_query.h',
+  'freedreno_query_acc.c',
+  'freedreno_query_acc.h',
+  'freedreno_query_hw.c',
+  'freedreno_query_hw.h',
+  'freedreno_query_sw.c',
+  'freedreno_query_sw.h',
+  'freedreno_resource.c',
+  'freedreno_resource.h',
+  'freedreno_screen.c',
+  'freedreno_screen.h',
+  'freedreno_state.c',
+  'freedreno_state.h',
+  'freedreno_surface.c',
+  'freedreno_surface.h',
+  'freedreno_texture.c',
+  

  1   2   >