Re: [Mesa-dev] [PATCH v4] glsl: update the extensions that are enabled for 460

2017-08-04 Thread Samuel Pitoiset



On 08/03/2017 07:36 PM, Ilia Mirkin wrote:

On Thu, Aug 3, 2017 at 5:24 AM, Samuel Pitoiset
 wrote:

Other ones are either unsupported or don't have any helper
function checks.

v4: - drop ARB suffix for shader_group_vote/arb_shader_atomic_counter_ops
v3: - always add gl_BaseVertex & co when 460 is enabled
v2: - fix ARB_shader_draw_parameters system value names

Signed-off-by: Samuel Pitoiset 
---
  src/compiler/glsl/builtin_functions.cpp | 81 +
  src/compiler/glsl/builtin_variables.cpp |  5 ++
  2 files changed, 78 insertions(+), 8 deletions(-)

diff --git a/src/compiler/glsl/builtin_functions.cpp 
b/src/compiler/glsl/builtin_functions.cpp
index 84833bdd7d..bbb60b4e64 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -151,6 +151,12 @@ v130_desktop(const _mesa_glsl_parse_state *state)
  }

  static bool
+v460_desktop(const _mesa_glsl_parse_state *state)
+{
+   return state->is_version(460, 0);
+}
+
+static bool
  v130_fs_only(const _mesa_glsl_parse_state *state)
  {
 return state->is_version(130, 300) &&
@@ -483,7 +489,7 @@ shader_atomic_counters(const _mesa_glsl_parse_state *state)
  static bool
  shader_atomic_counter_ops(const _mesa_glsl_parse_state *state)
  {
-   return state->ARB_shader_atomic_counter_ops_enable;
+   return v460_desktop(state) || state->ARB_shader_atomic_counter_ops_enable;
  }

  static bool
@@ -606,7 +612,7 @@ barrier_supported(const _mesa_glsl_parse_state *state)
  static bool
  vote(const _mesa_glsl_parse_state *state)
  {
-   return state->ARB_shader_group_vote_enable;
+   return v460_desktop(state) || state->ARB_shader_group_vote_enable;
  }

  static bool
@@ -962,7 +968,8 @@ private:

 ir_function_signature *_vote_intrinsic(builtin_available_predicate avail,
enum ir_intrinsic_id id);
-   ir_function_signature *_vote(const char *intrinsic_name);
+   ir_function_signature *_vote(const char *intrinsic_name,
+builtin_available_predicate avail);

  #undef B0
  #undef B1
@@ -3031,6 +3038,43 @@ builtin_builder::create_builtins()
  shader_atomic_counter_ops),
  NULL);

+   add_function("atomicCounterAdd",
+_atomic_counter_op1("__intrinsic_atomic_add",
+v460_desktop),
+NULL);
+   add_function("atomicCounterSubtract",
+_atomic_counter_op1("__intrinsic_atomic_sub",
+v460_desktop),
+NULL);
+   add_function("atomicCounterMin",
+_atomic_counter_op1("__intrinsic_atomic_min",
+v460_desktop),
+NULL);
+   add_function("atomicCounterMax",
+_atomic_counter_op1("__intrinsic_atomic_max",
+v460_desktop),
+NULL);
+   add_function("atomicCounterAnd",
+_atomic_counter_op1("__intrinsic_atomic_and",
+v460_desktop),
+NULL);
+   add_function("atomicCounterOr",
+_atomic_counter_op1("__intrinsic_atomic_or",
+v460_desktop),
+NULL);
+   add_function("atomicCounterXor",
+_atomic_counter_op1("__intrinsic_atomic_xor",
+v460_desktop),
+NULL);
+   add_function("atomicCounterExchange",
+_atomic_counter_op1("__intrinsic_atomic_exchange",
+v460_desktop),
+NULL);
+   add_function("atomicCounterCompSwap",
+_atomic_counter_op2("__intrinsic_atomic_comp_swap",
+v460_desktop),
+NULL);
+


So all of these reference the __intrinsic_atomic_max functions. Do
those ned to be fixed up too? Specifically,

add_function("__intrinsic_atomic_max",
 _atomic_intrinsic2(buffer_atomics_supported,
glsl_type::uint_type,
ir_intrinsic_generic_atomic_max),
 _atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type,
ir_intrinsic_generic_atomic_max),
 _atomic_counter_intrinsic1(shader_atomic_counter_ops,
ir_intrinsic_atomic_counter_max),
 NULL);

I believe the latter one needs to have its availability function
adjusted to be a||b.


Yes, but it's already adjusted in this patch:

@@ -483,7 +489,7 @@ shader_atomic_counters(const _mesa_glsl_parse_state 
*state)

 static bool
 shader_atomic_counter_ops(const _mesa_glsl_parse_state *state)
 {
-   return state->ARB_shader_atomic_counter_ops_enable;
+   return v460_desktop(state) || 
state->ARB_shader_atomic_counter_ops_enabl

[Mesa-dev] [PATCH 2/3] glsl: clone builtin function constants

2017-08-04 Thread Timothy Arceri
f81ede469910d fixed a problem with shaders including IR that was
owned by builtins. However the approach of cloning the whole
function each time we referenced it lead to a significant
reduction in the GLSL IR compiler performance.

Everything was already cloned when inlining the function, as
far as I can tell this is the only place where we are grabbing
IR owned by the builtins without cloning it.

The double free can be easily reproduced by compiling the
Deus Ex: Mankind Divided shaders with shader db, and then
compiling them again after deleting mesa's shader cache
index file. This will cause optimisations to never be performed
on the IR and which presumably caused this issue to be hidden
under normal circumstances.

Cc: Kenneth Graunke 
Cc: Lionel Landwerlin 
---
 src/compiler/glsl/ast_function.cpp | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/ast_function.cpp 
b/src/compiler/glsl/ast_function.cpp
index f7e90fba5b..73c4c0df7b 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -514,21 +514,29 @@ generate_call(exec_list *instructions, 
ir_function_signature *sig,
 *   return 0 when evaluated inside an initializer with an argument
 *   that is a constant expression."
 *
 * If the function call is a constant expression, don't generate any
 * instructions; just generate an ir_constant.
 */
if (state->is_version(120, 100)) {
   ir_constant *value = sig->constant_expression_value(actual_parameters,
   NULL);
   if (value != NULL) {
- return value;
+ if (sig->is_builtin()) {
+/* This value belongs to a builtin so we must clone it to avoid
+ * race conditions when freeing shaders and destorying the
+ * context.
+ */
+return value->clone(ctx, NULL);
+ } else {
+return value;
+ }
   }
}
 
ir_dereference_variable *deref = NULL;
if (!sig->return_type->is_void()) {
   /* Create a new temporary to hold the return value. */
   char *const name = ir_variable::temporaries_allocate_names
  ? ralloc_asprintf(ctx, "%s_retval", sig->function_name())
  : NULL;
 
-- 
2.13.3

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


[Mesa-dev] [PATCH 3/3] glsl: stop cloning builtin fuctions _mesa_glsl_find_builtin_function()

2017-08-04 Thread Timothy Arceri
The cloning was introduced in f81ede469910d to fixed a problem with
shaders including IR that was owned by builtins.

However the approach of cloning the whole function each time we
reference a builtin lead to a significant reduction in the GLSL
IR compilers performance.

The previous patch fixes the ownership problem in a more precise
way. So we can now remove this cloning.

Testing on a Ryzan 7 1800X shows a ~15% decreases in compiling the
Deus Ex: Mankind Divided shaders on radeonsi (which take 5min+ on
some machines). Looking just at the GLSL IR compiler the speed up
is ~40%.

Cc: Kenneth Graunke 
Cc: Lionel Landwerlin 
---
 src/compiler/glsl/builtin_functions.cpp | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/src/compiler/glsl/builtin_functions.cpp 
b/src/compiler/glsl/builtin_functions.cpp
index 84833bdd7d..1393087cc6 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -6207,30 +6207,21 @@ _mesa_glsl_release_builtin_functions()
 
 ir_function_signature *
 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
  const char *name, exec_list 
*actual_parameters)
 {
ir_function_signature *s;
mtx_lock(&builtins_lock);
s = builtins.find(state, name, actual_parameters);
mtx_unlock(&builtins_lock);
 
-   if (s == NULL)
-  return NULL;
-
-   struct hash_table *ht =
-  _mesa_hash_table_create(NULL, _mesa_hash_pointer, 
_mesa_key_pointer_equal);
-   void *mem_ctx = state;
-   ir_function *f = s->function()->clone(mem_ctx, ht);
-   _mesa_hash_table_destroy(ht, NULL);
-
-   return f->matching_signature(state, actual_parameters, true);
+   return s;
 }
 
 bool
 _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, const char 
*name)
 {
ir_function *f;
bool ret = false;
mtx_lock(&builtins_lock);
f = builtins.shader->symbols->get_function(name);
if (f != NULL) {
-- 
2.13.3

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


[Mesa-dev] [PATCH 1/3] glsl: remove unused field from ir_call

2017-08-04 Thread Timothy Arceri
---
 src/compiler/glsl/ir.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 40f3338470..d425b97aca 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -1595,32 +1595,30 @@ public:
  */
 class ir_call : public ir_instruction {
 public:
ir_call(ir_function_signature *callee,
   ir_dereference_variable *return_deref,
   exec_list *actual_parameters)
   : ir_instruction(ir_type_call), return_deref(return_deref), 
callee(callee), sub_var(NULL), array_idx(NULL)
{
   assert(callee->return_type != NULL);
   actual_parameters->move_nodes_to(& this->actual_parameters);
-  this->use_builtin = callee->is_builtin();
}
 
ir_call(ir_function_signature *callee,
   ir_dereference_variable *return_deref,
   exec_list *actual_parameters,
   ir_variable *var, ir_rvalue *array_idx)
   : ir_instruction(ir_type_call), return_deref(return_deref), 
callee(callee), sub_var(var), array_idx(array_idx)
{
   assert(callee->return_type != NULL);
   actual_parameters->move_nodes_to(& this->actual_parameters);
-  this->use_builtin = callee->is_builtin();
}
 
virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const;
 
virtual ir_constant *constant_expression_value(struct hash_table 
*variable_context = NULL);
 
virtual void accept(ir_visitor *v)
{
   v->visit(this);
}
@@ -1648,23 +1646,20 @@ public:
ir_dereference_variable *return_deref;
 
/**
 * The specific function signature being called.
 */
ir_function_signature *callee;
 
/* List of ir_rvalue of paramaters passed in this call. */
exec_list actual_parameters;
 
-   /** Should this call only bind to a built-in function? */
-   bool use_builtin;
-
/*
 * ARB_shader_subroutine support -
 * the subroutine uniform variable and array index
 * rvalue to be used in the lowering pass later.
 */
ir_variable *sub_var;
ir_rvalue *array_idx;
 };
 
 
-- 
2.13.3

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


Re: [Mesa-dev] [PATCH] radv: avoid GPU hangs if someone does a resolve with non-multisample src (v2)

2017-08-04 Thread Bas Nieuwenhuizen
Reviewed-by: Bas Nieuwenhuizen 

On Fri, Aug 4, 2017 at 4:51 AM, Dave Airlie  wrote:
> From: Dave Airlie 
>
> This is a bug in the app, but I'd rather avoid hanging the GPU,
> esp if someone is running in validation and it takes out their
> development environment.
>
> v2: get it right, reverse the polarity.
>
> Signed-off-by: Dave Airlie 
> ---
>  src/amd/vulkan/radv_meta_resolve.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/amd/vulkan/radv_meta_resolve.c 
> b/src/amd/vulkan/radv_meta_resolve.c
> index 6cd0c38..6023e0f 100644
> --- a/src/amd/vulkan/radv_meta_resolve.c
> +++ b/src/amd/vulkan/radv_meta_resolve.c
> @@ -382,6 +382,11 @@ void radv_CmdResolveImage(
> radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, 
> cmd_buffer);
>
> assert(src_image->info.samples > 1);
> +   if (src_image->info.samples <= 1) {
> +   /* this causes GPU hangs if we get past here */
> +   fprintf(stderr, "radv: Illegal resolve operation (src not 
> multisampled), will hang GPU.");
> +   return;
> +   }
> assert(dest_image->info.samples == 1);
>
> if (src_image->info.samples >= 16) {
> --
> 2.9.4
>
> ___
> 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] LLVM build issue on r299777

2017-08-04 Thread Juan A. Suarez Romero
On Thu, 2017-08-03 at 21:19 +0200, Marek Olšák wrote:
> On Thu, Aug 3, 2017 at 7:54 PM, Juan A. Suarez Romero
>  wrote:
> > On Fri, 2017-04-28 at 14:15 +0200, Nicolai Hähnle wrote:
> > > On 28.04.2017 13:08, Eric Engestrom wrote:
> > > > Hi,
> > > > 
> > > > I'm currently running llvm r299777 but I have no idea when this
> > > > was
> > > > changed.
> > > 
> > > Yeah, you'll just have to upgrade LLVM (or downgrade to LLVM
> > > 4.0).
> > > This
> > > sort of thing unfortunately happens occasionally when running
> > > LLVM
> > > trunk
> > > and Mesa master. I currently have r301197 here, and I'm not aware
> > > of
> > > any
> > > brokenness.
> > > 
> > 
> > 
> > I hit this same error when building using LLVM 5.0.
> 
> Note that Mesa only supports LLVM release branches and the tip of
> LLVM
> master. Older versions of LLVM master are unsupported. If you want to
> stay on Mesa master, you either need to switch to a release branch of
> LLVM or keep updating LLVM master.
> 

Right! It was my fault. I thought that LLVM 5.0 were already released
(there's a package in LLVM's apt repository which make me to think it
was already release).

Sorry! 


J.A.


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


Re: [Mesa-dev] [Mesa-stable] [PATCH] radv: Fix decompression on multisampled depth buffers

2017-08-04 Thread Alex Smith
On 3 August 2017 at 23:44, Bas Nieuwenhuizen 
wrote:

> On Fri, Aug 4, 2017 at 12:26 AM, Marek Olšák  wrote:
> > Hi Alex,
> >
> > Which game uses texturing from MSAA depth buffers?
>
> They don't necessarily have to do that, radv could also be doing some
> superfluous layout transitions that might mess the texture up due to
> not taking the samples into account.
>

This is for an unreleased game, and yes, it is sampling from an MSAA depth
buffer. Even better, sometimes it samples it at the same time it's bound as
the current (read-only) depth target.

Alex


>
> - Bas
>
> >
> > Thanks,
> > Marek
> >
> > On Thu, Aug 3, 2017 at 4:32 PM, Alex Smith 
> wrote:
> >> Need to take the sample count into account in the depth decompress and
> >> resummarize pipelines and render pass.
> >>
> >> Fixes: f4e499ec791 ("radv: add initial non-conformant radv vulkan
> driver")
> >> Signed-off-by: Alex Smith 
> >> Cc: "17.2" 
> >> ---
> >> Possibly a little late, but I'd really like to get this into 17.2 if
> >> possible - fixes a bunch of corruption we're seeing when using MSAA.
> >> ---
> >>  src/amd/vulkan/radv_meta_decompress.c | 102
> ++
> >>  src/amd/vulkan/radv_private.h |   2 +-
> >>  2 files changed, 69 insertions(+), 35 deletions(-)
> >>
> >> diff --git a/src/amd/vulkan/radv_meta_decompress.c
> b/src/amd/vulkan/radv_meta_decompress.c
> >> index 7afe08fbdb..f68ce8d2b0 100644
> >> --- a/src/amd/vulkan/radv_meta_decompress.c
> >> +++ b/src/amd/vulkan/radv_meta_decompress.c
> >> @@ -29,7 +29,9 @@
> >>  #include "sid.h"
> >>
> >>  static VkResult
> >> -create_pass(struct radv_device *device)
> >> +create_pass(struct radv_device *device,
> >> +   uint32_t samples,
> >> +   VkRenderPass *pass)
> >>  {
> >> VkResult result;
> >> VkDevice device_h = radv_device_to_handle(device);
> >> @@ -37,7 +39,7 @@ create_pass(struct radv_device *device)
> >> VkAttachmentDescription attachment;
> >>
> >> attachment.format = VK_FORMAT_D32_SFLOAT_S8_UINT;
> >> -   attachment.samples = 1;
> >> +   attachment.samples = samples;
> >> attachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
> >> attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
> >> attachment.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_
> ATTACHMENT_OPTIMAL;
> >> @@ -65,14 +67,18 @@ create_pass(struct radv_device *device)
> >>
>  .dependencyCount = 0,
> >>},
> >>alloc,
> >> -  &device->meta_state.depth_
> decomp.pass);
> >> +  pass);
> >>
> >> return result;
> >>  }
> >>
> >>  static VkResult
> >>  create_pipeline(struct radv_device *device,
> >> -VkShaderModule vs_module_h)
> >> +VkShaderModule vs_module_h,
> >> +   uint32_t samples,
> >> +   VkRenderPass pass,
> >> +   VkPipeline *decompress_pipeline,
> >> +   VkPipeline *resummarize_pipeline)
> >>  {
> >> VkResult result;
> >> VkDevice device_h = radv_device_to_handle(device);
> >> @@ -129,7 +135,7 @@ create_pipeline(struct radv_device *device,
> >> },
> >> .pMultisampleState = 
> >> &(VkPipelineMultisampleStateCreateInfo)
> {
> >> .sType = VK_STRUCTURE_TYPE_PIPELINE_
> MULTISAMPLE_STATE_CREATE_INFO,
> >> -   .rasterizationSamples = 1,
> >> +   .rasterizationSamples = samples,
> >> .sampleShadingEnable = false,
> >> .pSampleMask = NULL,
> >> .alphaToCoverageEnable = false,
> >> @@ -156,7 +162,7 @@ create_pipeline(struct radv_device *device,
> >> VK_DYNAMIC_STATE_SCISSOR,
> >> },
> >> },
> >> -   .renderPass = device->meta_state.depth_decomp.pass,
> >> +   .renderPass = pass,
> >> .subpass = 0,
> >> };
> >>
> >> @@ -169,7 +175,7 @@ create_pipeline(struct radv_device *device,
> >>
>  .db_flush_stencil_inplace = true,
> >>},
> >>
> &device->meta_state.alloc,
> >> -
> &device->meta_state.depth_decomp.decompress_pipeline);
> >> +  decompress_pipeline);
> >> if (result != VK_SUCCESS)
> >> goto cleanup;
> >>
> >> @@ -183,7 +189,7 @@ create_pipeline(struct radv_device *device,
> >> .db_resummarize
> = true,
> >>},
> >>
> &device->meta_state.alloc,
> >> -
> &device->meta_state.depth_decomp.resummarize_pipeline);
> >> +  resummarize_pipeline);
> >> if (result != VK_SUCCESS)
> >>   

Re: [Mesa-dev] [PATCH v2 6/6] radeonsi: try to re-use previously deleted bindless descriptor slots

2017-08-04 Thread Samuel Pitoiset



On 08/01/2017 09:54 PM, Marek Olšák wrote:

Hi Samuel,

Can you move this slot allocator into a util module? It seems generic
enough that it could be reused for "handle" and "ID" allocations.

Some additional notes:
- a bit array of uin32_t would be better. bool is too large (1 byte).
- "free" is the inverse of "used", so the "used" array is redundant.


Yeah, but we have to keep track of two different arrays. When a texture 
handle is destroyed, the ID can be re-used but not right now, because 
the GPU can still use the descriptor. The names are probably bad, maybe 
bindless_free_slots and bindless_deleted_slots is better?




Thanks,
Marek

On Wed, Jul 26, 2017 at 4:21 PM, Samuel Pitoiset
 wrote:

Currently, when the array is full it is resized but it can grow
over and over because we don't try to re-use descriptor slots.

The idea is to maintain two simple lists which keep track of
which slots is used and which ones have been deleted. When the
array is resized, previously deleted slots can be marked as
free because we are going to upload a new fresh buffer.

Signed-off-by: Samuel Pitoiset 
---
  src/gallium/drivers/radeonsi/si_descriptors.c | 85 +++
  src/gallium/drivers/radeonsi/si_pipe.h|  2 +
  2 files changed, 75 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 543a19ba1e..95f0479be7 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2299,11 +2299,72 @@ static void si_init_bindless_descriptors(struct 
si_context *sctx,
  * considered to be a valid handle.
  */
 sctx->num_bindless_descriptors = 1;
+
+   /* Allocate two simple arrays for re-using previously deleted slots. */
+   sctx->bindless_used_slots = CALLOC(num_elements, sizeof(bool));
+   sctx->bindless_free_slots = CALLOC(num_elements, sizeof(bool));
  }

  static inline void si_release_bindless_descriptors(struct si_context *sctx)
  {
 si_release_descriptors(&sctx->bindless_descriptors);
+   FREE(sctx->bindless_used_slots);
+   FREE(sctx->bindless_free_slots);
+}
+
+static unsigned si_get_next_free_bindless_slot(struct si_context *sctx)
+{
+   struct si_descriptors *desc = &sctx->bindless_descriptors;
+   unsigned i;
+
+   for (i = 1; i < desc->num_elements; i++) {
+   if (!sctx->bindless_used_slots[i]) {
+   /* Lock this descriptor slot. */
+   sctx->bindless_used_slots[i] = true;
+   return i;
+   }
+   }
+
+   /* No available descriptor slots. */
+   return 0;
+}
+
+static void si_resize_bindless_descriptor(struct si_context *sctx)
+{
+   struct si_descriptors *desc = &sctx->bindless_descriptors;
+   unsigned slot_size = desc->element_dw_size * 4;
+   unsigned old_num_elements = desc->num_elements;
+   unsigned new_num_elements = old_num_elements * 2;
+   unsigned i;
+
+   /* All previously deleted slots can now be re-used because we are going
+* to upload a new buffer.
+*/
+   for (i = 1; i < old_num_elements; i++) {
+   if (sctx->bindless_free_slots[i]) {
+   /* Unlock this descriptor slot. */
+   sctx->bindless_used_slots[i] = false;
+   }
+   sctx->bindless_free_slots[i] = false;
+   }
+
+   /* Resize the array of descriptors. */
+   desc->list = REALLOC(desc->list, desc->num_elements * slot_size,
+new_num_elements * slot_size);
+   desc->num_elements = new_num_elements;
+   desc->num_active_slots = new_num_elements;
+
+   /* Resize the two simple arrays and mark all slots as free. */
+   sctx->bindless_used_slots = REALLOC(sctx->bindless_used_slots,
+   old_num_elements,
+   new_num_elements);
+   sctx->bindless_free_slots = REALLOC(sctx->bindless_free_slots,
+   old_num_elements,
+   new_num_elements);
+   for (i = old_num_elements; i < new_num_elements; i++) {
+   sctx->bindless_used_slots[i] = false;
+   sctx->bindless_free_slots[i] = false;
+   }
  }

  static unsigned
@@ -2315,19 +2376,16 @@ si_create_bindless_descriptor(struct si_context *sctx, 
uint32_t *desc_list,
 unsigned desc_slot, desc_slot_offset;
 bool resized = false;

-   /* Reserve a new slot for this bindless descriptor. */
-   desc_slot = sctx->num_bindless_descriptors++;
-
-   if (desc_slot >= desc->num_elements) {
-   /* The array of bindless descriptors is full, resize it. */
-   unsigned slot_size = desc->element_dw_size * 4;
-   unsigned new_num_elements = desc->num_elements * 2;
-
- 

Re: [Mesa-dev] [PATCH] anv/formats: Allow sampling on depth-only formats on gen7

2017-08-04 Thread Juan A. Suarez Romero
On Thu, 2017-08-03 at 20:00 -0700, Jason Ekstrand wrote:
> We can't sample from depth-stencil formats but on gen7 but we can
> sample
> from depth-only formats.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102024
> ---


Reviewed-by: Juan A. Suarez Romero 

>  src/intel/vulkan/anv_formats.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/intel/vulkan/anv_formats.c
> b/src/intel/vulkan/anv_formats.c
> index c656d7e..9808508 100644
> --- a/src/intel/vulkan/anv_formats.c
> +++ b/src/intel/vulkan/anv_formats.c
> @@ -395,7 +395,8 @@ anv_physical_device_get_format_properties(struct
> anv_physical_device *physical_d
>/* Nothing to do here */
> } else if (vk_format_is_depth_or_stencil(format)) {
>tiled |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
> -  if (physical_device->info.gen >= 8)
> +  if (vk_format_aspects(format) == VK_IMAGE_ASPECT_DEPTH_BIT ||
> +  physical_device->info.gen >= 8)
>   tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
>  
>tiled |= VK_FORMAT_FEATURE_BLIT_SRC_BIT |
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallium/clover: Remove libxmlconfig.la from targets/clover/Makefile.am

2017-08-04 Thread Nicolai Hähnle

On 04.08.2017 06:24, Aaron Watry wrote:

Gets rid of a bunch of errors like the following:

make[4]: Entering directory '/home/me/src/mesa/build/src/gallium/targets/opencl'
   CXXLDlibOpenCL.la
../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o): In 
function `driParseOptionInfo':
/home/me/src/mesa/src/util/xmlconfig.c:719: multiple definition of 
`driParseOptionInfo'
../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:719:
 first defined here
../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o): In 
function `driParseConfigFiles':
/home/me/src/mesa/src/util/xmlconfig.c:990: multiple definition of 
`driParseConfigFiles'
../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:990:
 first defined here

Fixes: 33f7d71d5358337f ("pipe-loader: fix build of dynamic pipe-drivers")
Cc: Nicolai Hähnle 
Cc: Emil Velikov 
---
  src/gallium/targets/opencl/Makefile.am | 1 -
  1 file changed, 1 deletion(-)

diff --git a/src/gallium/targets/opencl/Makefile.am 
b/src/gallium/targets/opencl/Makefile.am
index e88fa0fd38..c9d2be7afd 100644
--- a/src/gallium/targets/opencl/Makefile.am
+++ b/src/gallium/targets/opencl/Makefile.am
@@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
$(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
$(top_builddir)/src/util/libmesautil.la \
-   $(top_builddir)/src/util/libxmlconfig.la \


So, this is weird because I added this line to make one of the Travis CI 
builds pass. What are your ./configure options?


Thanks,
Nicolai


$(EXPAT_LIBS) \
$(LIBELF_LIBS) \
$(DLOPEN_LIBS) \



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


Re: [Mesa-dev] [PATCH v2 6/6] radeonsi: try to re-use previously deleted bindless descriptor slots

2017-08-04 Thread Marek Olšák
On Fri, Aug 4, 2017 at 10:06 AM, Samuel Pitoiset
 wrote:
>
>
> On 08/01/2017 09:54 PM, Marek Olšák wrote:
>>
>> Hi Samuel,
>>
>> Can you move this slot allocator into a util module? It seems generic
>> enough that it could be reused for "handle" and "ID" allocations.
>>
>> Some additional notes:
>> - a bit array of uin32_t would be better. bool is too large (1 byte).
>> - "free" is the inverse of "used", so the "used" array is redundant.
>
>
> Yeah, but we have to keep track of two different arrays. When a texture
> handle is destroyed, the ID can be re-used but not right now, because the
> GPU can still use the descriptor.

Not true. You can reuse all freed slots immediately if you re-upload
the whole array instead of using WRITE_DATA.

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


Re: [Mesa-dev] [PATCH 02/23] mesa: add support for memory object creation/import/delete

2017-08-04 Thread Samuel Pitoiset



On 08/04/2017 03:54 AM, Timothy Arceri wrote:

From: Andres Rodriguez 

Used by EXT_external_objects and EXT_external_objects_fd

V2 (Timothy Arceri):
  - Throw GL_OUT_OF_MEMORY error if CreateMemoryObjectsEXT()
fails.
  - C99 tidy ups
  - remove void cast (Constantine Kharlamov)

V3 (Timothy Arceri):
  - rename mo -> memObj
  - check that the object is not NULL before initializing
  - add missing "EXT" in function error message

V4 (Timothy Arceri):
  - remove checks for (memory objecy id == 0) and catch in
_mesa_lookup_memory_object() instead.

Signed-off-by: Andres Rodriguez 
Reviewed-by: Timothy Arceri 
Reviewed-by: Samuel Pitoiset  (v3)
---
  src/mesa/drivers/common/driverfuncs.c |   4 +
  src/mesa/main/dd.h|  36 +
  src/mesa/main/externalobjects.c   | 138 +-
  src/mesa/main/externalobjects.h   |  31 
  src/mesa/main/mtypes.h|   9 +++
  src/mesa/main/shared.c|  17 +
  6 files changed, 233 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 5008ae8fea..ddb4bb6d6a 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -42,20 +42,21 @@
  #include "main/teximage.h"
  #include "main/texobj.h"
  #include "main/texstorage.h"
  #include "main/texstore.h"
  #include "main/bufferobj.h"
  #include "main/fbobject.h"
  #include "main/samplerobj.h"
  #include "main/syncobj.h"
  #include "main/barrier.h"
  #include "main/transformfeedback.h"
+#include "main/externalobjects.h"
  
  #include "program/program.h"

  #include "tnl/tnl.h"
  #include "swrast/swrast.h"
  #include "swrast/s_renderbuffer.h"
  
  #include "driverfuncs.h"

  #include "meta.h"
  
  
@@ -159,20 +160,23 @@ _mesa_init_driver_functions(struct dd_function_table *driver)

 driver->Viewport = NULL;
  
 /* buffer objects */

 _mesa_init_buffer_object_functions(driver);
  
 /* query objects */

 _mesa_init_query_object_functions(driver);
  
 _mesa_init_sync_object_functions(driver);
  
+   /* memory objects */

+   _mesa_init_memory_object_functions(driver);
+
 driver->NewFramebuffer = _mesa_new_framebuffer;
 driver->NewRenderbuffer = _swrast_new_soft_renderbuffer;
 driver->MapRenderbuffer = _swrast_map_soft_renderbuffer;
 driver->UnmapRenderbuffer = _swrast_unmap_soft_renderbuffer;
 driver->RenderTexture = _swrast_render_texture;
 driver->FinishRenderTexture = _swrast_finish_render_texture;
 driver->FramebufferRenderbuffer = _mesa_FramebufferRenderbuffer_sw;
 driver->ValidateFramebuffer = _mesa_validate_framebuffer;
  
 driver->BlitFramebuffer = _swrast_BlitFramebuffer;

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 462829d755..6d6bdecb4d 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1062,20 +1062,56 @@ struct dd_function_table {
  struct gl_sampler_object *sampObj);
 void (*DeleteTextureHandle)(struct gl_context *ctx, GLuint64 handle);
 void (*MakeTextureHandleResident)(struct gl_context *ctx, GLuint64 handle,
   bool resident);
 GLuint64 (*NewImageHandle)(struct gl_context *ctx,
struct gl_image_unit *imgObj);
 void (*DeleteImageHandle)(struct gl_context *ctx, GLuint64 handle);
 void (*MakeImageHandleResident)(struct gl_context *ctx, GLuint64 handle,
 GLenum access, bool resident);
 /*@}*/
+
+
+   /**
+* \name GL_EXT_external_objects interface
+*/
+   /*@{*/
+  /**
+* Called to allocate a new memory object.  Drivers will usually
+* allocate/return a subclass of gl_memory_object.
+*/
+   struct gl_memory_object * (*NewMemoryObject)(struct gl_context *ctx,
+GLuint name);
+   /**
+* Called to delete/free a memory object.  Drivers should free the
+* object and any image data it contains.
+*/
+   void (*DeleteMemoryObject)(struct gl_context *ctx,
+  struct gl_memory_object *memObj);
+   /*@}*/
+
+   /**
+* \name GL_EXT_external_objects_fd interface
+*/
+   /*@{*/
+   /**
+* Called to import a memory object. The caller relinquishes ownership
+* of fd after the call returns.
+*
+* Accessing fd after ImportMemoryObjectFd returns results in undefined
+* behaviour. This is consistent with EXT_external_object_fd.
+*/
+   void (*ImportMemoryObjectFd)(struct gl_context *ctx,
+struct gl_memory_object *memObj,
+GLuint64 size,
+int fd);
+   /*@}*/
  };
  
  
  /**

   * Per-vertex functions.
   *
   * These are the functions which can appear between glBegin and glEnd.
   * Depending on whether we're inside or outside a glBegin/End pair
   * and whether we

Re: [Mesa-dev] [PATCH 04/23] gallium: introduce memory object

2017-08-04 Thread Samuel Pitoiset



On 08/04/2017 03:54 AM, Timothy Arceri wrote:

From: Dave Airlie 

v2: fix comment regarding fd ownership, define pipe_memory_object
v3: remove stray return
v4 (Timothy Arceri): update trace
v5 (Timothy Arceri): actually dump the params in trace

Reviewed-by: Marek Olšák  (v3)
---
  src/gallium/drivers/ddebug/dd_screen.c | 40 +++
  src/gallium/drivers/trace/tr_screen.c  | 72 ++
  src/gallium/include/pipe/p_screen.h| 36 +
  src/gallium/include/pipe/p_state.h |  8 
  4 files changed, 156 insertions(+)

diff --git a/src/gallium/drivers/ddebug/dd_screen.c 
b/src/gallium/drivers/ddebug/dd_screen.c
index 14e6f6b011..51382da1d7 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ b/src/gallium/drivers/ddebug/dd_screen.c
@@ -238,20 +238,36 @@ dd_screen_resource_from_user_memory(struct pipe_screen 
*_screen,
 struct pipe_screen *screen = dd_screen(_screen)->screen;
 struct pipe_resource *res =
screen->resource_from_user_memory(screen, templ, user_memory);
  
 if (!res)

return NULL;
 res->screen = _screen;
 return res;
  }
  
+static struct pipe_resource *

+dd_screen_resource_from_memobj(struct pipe_screen *_screen,
+   const struct pipe_resource *templ,
+   struct pipe_memory_object *memobj,
+   uint64_t offset)
+{
+   struct pipe_screen *screen = dd_screen(_screen)->screen;
+   struct pipe_resource *res =
+  screen->resource_from_memobj(screen, templ, memobj, offset);
+
+   if (!res)
+  return NULL;
+   res->screen = _screen;
+   return res;
+}
+
  static void
  dd_screen_resource_changed(struct pipe_screen *_screen,
 struct pipe_resource *res)
  {
 struct pipe_screen *screen = dd_screen(_screen)->screen;
  
 screen->resource_changed(screen, res);

  }
  
  static void

@@ -296,21 +312,42 @@ dd_screen_fence_finish(struct pipe_screen *_screen,
 struct pipe_context *_ctx,
 struct pipe_fence_handle *fence,
 uint64_t timeout)
  {
 struct pipe_screen *screen = dd_screen(_screen)->screen;
 struct pipe_context *ctx = _ctx ? dd_context(_ctx)->pipe : NULL;
  
 return screen->fence_finish(screen, ctx, fence, timeout);

  }
  
+/

+ * memobj
+ */
+
+static struct pipe_memory_object *
+dd_screen_memobj_create_from_handle(struct pipe_screen *_screen,
+struct winsys_handle *handle,
+bool dedicated)
+{
+   struct pipe_screen *screen = dd_screen(_screen)->screen;
+
+   return screen->memobj_create_from_handle(screen, handle, dedicated);
+}
+
+static void
+dd_screen_memobj_destroy(struct pipe_screen *_screen,
+ struct pipe_memory_object *memobj)
+{
+   struct pipe_screen *screen = dd_screen(_screen)->screen;
  
+   screen->memobj_destroy(screen, memobj);

+}
  /
   * screen
   */
  
  static void

  dd_screen_destroy(struct pipe_screen *_screen)
  {
 struct dd_screen *dscreen = dd_screen(_screen);
 struct pipe_screen *screen = dscreen->screen;
  
@@ -405,27 +442,30 @@ ddebug_screen_create(struct pipe_screen *screen)

 dscreen->base.query_memory_info = dd_screen_query_memory_info;
 /* get_video_param */
 /* get_compute_param */
 SCR_INIT(get_timestamp);
 dscreen->base.context_create = dd_screen_context_create;
 dscreen->base.is_format_supported = dd_screen_is_format_supported;
 /* is_video_format_supported */
 SCR_INIT(can_create_resource);
 dscreen->base.resource_create = dd_screen_resource_create;
 dscreen->base.resource_from_handle = dd_screen_resource_from_handle;
+   SCR_INIT(resource_from_memobj);
 SCR_INIT(resource_from_user_memory);
 dscreen->base.resource_get_handle = dd_screen_resource_get_handle;
 SCR_INIT(resource_changed);
 dscreen->base.resource_destroy = dd_screen_resource_destroy;
 SCR_INIT(flush_frontbuffer);
 SCR_INIT(fence_reference);
 SCR_INIT(fence_finish);
+   SCR_INIT(memobj_create_from_handle);
+   SCR_INIT(memobj_destroy);
 SCR_INIT(get_driver_query_info);
 SCR_INIT(get_driver_query_group_info);
 SCR_INIT(get_compiler_options);
  
  #undef SCR_INIT
  
 dscreen->screen = screen;

 dscreen->timeout_ms = timeout;
 dscreen->mode = mode;
 dscreen->no_flush = no_flush;
diff --git a/src/gallium/drivers/trace/tr_screen.c 
b/src/gallium/drivers/trace/tr_screen.c
index e56434c5bd..7c4c05b4c3 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -360,20 +360,47 @@ trace_screen_resource_get_handle(struct pipe_screen 
*_screen,
 struct trace_screen *tr_screen = trace_screen(_screen);
 struct trace_context *tr_pipe

Re: [Mesa-dev] [PATCH v2 2/9] anv: Submit a dummy batch when only semaphores are provided.

2017-08-04 Thread Chris Wilson
Quoting Jason Ekstrand (2017-08-04 02:25:21)
> Vulkan allows you to do a submit whose only job is to wait on and
> trigger semaphores.  The easiest way for us to support that right
> now is to insert a dummy execbuf.
> ---
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 793e519..0f0aa22 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -1014,6 +1014,28 @@ anv_device_init_border_colors(struct anv_device 
> *device)
>  border_colors);
>  }
>  
> +static void
> +anv_device_init_trivial_batch(struct anv_device *device)
> +{
> +   anv_bo_init_new(&device->trivial_batch_bo, device, 4096);

Is this created with ASYNC? Just thinking that you only want the
external ordering constraints on this bo, and not accidentally serialize
between contexts.

> +   void *map = anv_gem_mmap(device, device->trivial_batch_bo.gem_handle,
> +0, 4096, 0);
> +
> +   struct anv_batch batch = {
> +  .start = map,
> +  .next = map,
> +  .end = map + 4096,
> +   };
> +
> +   anv_batch_emit(&batch, GEN7_MI_BATCH_BUFFER_END, bbe);
> +   anv_batch_emit(&batch, GEN7_MI_NOOP, noop);
> +
> +   if (!device->info.has_llc)
> +  gen_clflush_range(map, batch.next - map);
> +
> +   anv_gem_munmap(map, device->trivial_batch_bo.size);
> +}

> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
> index b599db3..bc67bb6 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -745,6 +745,7 @@ struct anv_device {
>  struct anv_state_pool   surface_state_pool;
>  
>  struct anv_bo   workaround_bo;
> +struct anv_bo   trivial_batch_bo;

Do you use all 4096 bytes of the workaround_bo, or could you spare 64?
;)

> diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
> index 446c3de..9934fef 100644
> --- a/src/intel/vulkan/anv_queue.c
> +++ b/src/intel/vulkan/anv_queue.c
> @@ -159,6 +159,23 @@ VkResult anv_QueueSubmit(
> pthread_mutex_lock(&device->mutex);
>  
> for (uint32_t i = 0; i < submitCount; i++) {
> +  if (pSubmits[i].commandBufferCount == 0) {
> + /* If we don't have any command buffers, we need to submit a dummy
> +  * batch to give GEM something to wait on.  We could, potentially,
> +  * come up with something more efficient but this shouldn't be a
> +  * common case.
> +  */
> + result = anv_cmd_buffer_execbuf(device, NULL,
> + pSubmits[i].pWaitSemaphores,
> + pSubmits[i].waitSemaphoreCount,
> + pSubmits[i].pSignalSemaphores,
> + pSubmits[i].signalSemaphoreCount);

Might as well just pass &pSubmits[i] along?
-Chris
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/23] mesa: hook up memoryobject tex(ture)storage api

2017-08-04 Thread Samuel Pitoiset



On 08/04/2017 03:54 AM, Timothy Arceri wrote:

From: Andres Rodriguez 

V2 (Timothy Arceri):
  - formating fixes

V3 (Timothy):
  - error check memory == 0 before lookup

Signed-off-by: Andres Rodriguez 
Reviewed-by: Samuel Pitoiset  (v2)
---
  src/mesa/main/dd.h  |  10 
  src/mesa/main/externalobjects.c | 128 
  src/mesa/main/texstorage.c  |  76 +---
  src/mesa/main/texstorage.h  |   9 +++
  4 files changed, 191 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 6d6bdecb4d..fbe70cdfab 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1080,20 +1080,30 @@ struct dd_function_table {
  * allocate/return a subclass of gl_memory_object.
  */
 struct gl_memory_object * (*NewMemoryObject)(struct gl_context *ctx,
  GLuint name);
 /**
  * Called to delete/free a memory object.  Drivers should free the
  * object and any image data it contains.
  */
 void (*DeleteMemoryObject)(struct gl_context *ctx,
struct gl_memory_object *memObj);
+
+   /**
+* Set the given memory object as the texture's storage.
+*/
+   GLboolean (*SetTextureStorageForMemoryObject)(struct gl_context *ctx,
+ struct gl_texture_object 
*tex_obj,
+ struct gl_memory_object 
*mem_obj,
+ GLsizei levels, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLuint64 offset);
 /*@}*/
  
 /**

  * \name GL_EXT_external_objects_fd interface
  */
 /*@{*/
 /**
  * Called to import a memory object. The caller relinquishes ownership
  * of fd after the call returns.
  *
diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c
index c0c97f645c..d10d414f02 100644
--- a/src/mesa/main/externalobjects.c
+++ b/src/mesa/main/externalobjects.c
@@ -17,20 +17,24 @@
   * 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 "macros.h"

  #include "mtypes.h"
  #include "externalobjects.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "glformats.h"
+#include "texstorage.h"
  
  /**

   * Allocate and initialize a new memory object.  But don't put it into the
   * memory object hash table.
   *
   * Called via ctx->Driver.NewMemoryObject, unless overridden by a device
   * driver.
   *
   * \return pointer to new memory object.
   */
@@ -221,144 +225,248 @@ _mesa_GetMemoryObjectParameterivEXT(GLuint memoryObject,
default:
   goto invalid_pname;
 }
 return;
  
  invalid_pname:

 _mesa_error(ctx, GL_INVALID_ENUM,
 "glGetMemoryObjectParameterivEXT(pname=0x%x)", pname);
  }
  
+static struct gl_memory_object *

+lookup_memory_object_err(struct gl_context *ctx, unsigned memory,
+ const char* func)
+{
+   if (memory == 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(memory=0)", func);
+  return NULL;
+   }
+
+   struct gl_memory_object *memObj = _mesa_lookup_memory_object(ctx, memory);
+   if (!memObj)
+  return NULL;
+
+   if (!memObj->Immutable) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(no associated memory)",
+  func);
+  return NULL;
+   }


I haven't read the spec carefully, but do all memory objects have to be 
immutable?



+
+   return memObj;
+}
+
+/**
+ * Helper used by _mesa_TexStorageMem1/2/3DEXT().
+ */
+static void
+texstorage_memory(GLuint dims, GLenum target, GLsizei levels,
+  GLenum internalFormat, GLsizei width, GLsizei height,
+  GLsizei depth, GLuint memory, GLuint64 offset,
+  const char *func)
+{
+   struct gl_texture_object *texObj;
+   struct gl_memory_object *memObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+  return;
+
+   memObj = lookup_memory_object_err(ctx, memory, func);
+   if (!memObj)
+  return;
+
+   _mesa_texture_storage_memory(ctx, dims, texObj, memObj, target,
+levels, internalFormat,
+width, height, depth, offset, false);
+}
+
+static void
+texstorage_memory_ms(GLuint dims, GLenum target, GLsizei samples,
+ GLenum internalFormat, GLsizei width, GLsizei height,
+ GLsizei depth, GLboolean fixedSampleLocations,
+ GLuint memory, GLuint64 offset)
+{
+
+}

Re: [Mesa-dev] [PATCH 07/23] mesa: hook up memory object multisamples tex(ture)storage api

2017-08-04 Thread Samuel Pitoiset

Reviewed-by: Samuel Pitoiset 

On 08/04/2017 03:54 AM, Timothy Arceri wrote:

From: Andres Rodriguez 

V2 (Timothy):
  - error check memory == 0 before lookup

Signed-off-by: Andres Rodriguez 
Reviewed-by: Samuel Pitoiset  (v1)
---
  src/mesa/main/externalobjects.c | 46 +
  src/mesa/main/teximage.c| 75 +
  src/mesa/main/teximage.h| 10 ++
  3 files changed, 103 insertions(+), 28 deletions(-)

diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c
index d10d414f02..3dd325ca0d 100644
--- a/src/mesa/main/externalobjects.c
+++ b/src/mesa/main/externalobjects.c
@@ -278,23 +278,38 @@ texstorage_memory(GLuint dims, GLenum target, GLsizei 
levels,
  
 _mesa_texture_storage_memory(ctx, dims, texObj, memObj, target,

  levels, internalFormat,
  width, height, depth, offset, false);
  }
  
  static void

  texstorage_memory_ms(GLuint dims, GLenum target, GLsizei samples,
   GLenum internalFormat, GLsizei width, GLsizei height,
   GLsizei depth, GLboolean fixedSampleLocations,
- GLuint memory, GLuint64 offset)
+ GLuint memory, GLuint64 offset, const char* func)
  {
+   struct gl_texture_object *texObj;
+   struct gl_memory_object *memObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+  return;
+
+   memObj = lookup_memory_object_err(ctx, memory, func);
+   if (!memObj)
+  return;
  
+   _mesa_texture_storage_ms_memory(ctx, dims, texObj, memObj, target, samples,

+   internalFormat, width, height, depth,
+   fixedSampleLocations, offset, func);
  }
  
  /**

   * Helper used by _mesa_TextureStorageMem1/2/3DEXT().
   */
  static void
  texturestorage_memory(GLuint dims, GLuint texture, GLsizei levels,
GLenum internalFormat, GLsizei width, GLsizei height,
GLsizei depth, GLuint memory, GLuint64 offset,
const char *func)
@@ -314,23 +329,38 @@ texturestorage_memory(GLuint dims, GLuint texture, 
GLsizei levels,
  
 _mesa_texture_storage_memory(ctx, dims, texObj, memObj, texObj->Target,

  levels, internalFormat,
  width, height, depth, offset, true);
  }
  
  static void

  texturestorage_memory_ms(GLuint dims, GLuint texture, GLsizei samples,
   GLenum internalFormat, GLsizei width, GLsizei height,
   GLsizei depth, GLboolean fixedSampleLocations,
- GLuint memory, GLuint64 offset)
+ GLuint memory, GLuint64 offset, const char* func)
  {
+   struct gl_texture_object *texObj;
+   struct gl_memory_object *memObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_texture(ctx, texture);
+   if (!texObj)
+  return;
+
+   memObj = lookup_memory_object_err(ctx, memory, func);
+   if (!memObj)
+  return;
  
+   _mesa_texture_storage_ms_memory(ctx, dims, texObj, memObj, texObj->Target,

+   samples, internalFormat, width, height,
+   depth, fixedSampleLocations, offset, func);
  }
  
  void GLAPIENTRY

  _mesa_TexStorageMem2DEXT(GLenum target,
   GLsizei levels,
   GLenum internalFormat,
   GLsizei width,
   GLsizei height,
   GLuint memory,
   GLuint64 offset)
@@ -343,21 +373,22 @@ void GLAPIENTRY
  _mesa_TexStorageMem2DMultisampleEXT(GLenum target,
  GLsizei samples,
  GLenum internalFormat,
  GLsizei width,
  GLsizei height,
  GLboolean fixedSampleLocations,
  GLuint memory,
  GLuint64 offset)
  {
 texstorage_memory_ms(2, target, samples, internalFormat, width, height, 1,
-fixedSampleLocations, memory, offset);
+fixedSampleLocations, memory, offset,
+"glTexStorageMem2DMultisampleEXT");
  }
  
  void GLAPIENTRY

  _mesa_TexStorageMem3DEXT(GLenum target,
   GLsizei levels,
   GLenum internalFormat,
   GLsizei width,
   GLsizei height,
   GLsizei depth,
   GLuint memory,
@@ -372,21 +403,22 @@ _mesa_TexStorageMem3DMultisampleEXT(GLenum target,
  GLsizei samples,
  GL

Re: [Mesa-dev] [PATCH 13/23] mesa: hook up (Named)BufferStorageMem api

2017-08-04 Thread Samuel Pitoiset



On 08/04/2017 03:54 AM, Timothy Arceri wrote:

Include no_error variants as well.

v2 (Timothy Arceri):
  - reduced code churn by squashing some changes into
previous commits

v3 (Timothy Arceri):
  - drop unused function declaration

v4 (Timothy Arceri):
  - fix Driver function assert()
  - add missing GL errors

Signed-off-by: Andres Rodriguez 
---
  src/mesa/main/bufferobj.c | 86 ---
  1 file changed, 66 insertions(+), 20 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 05c15661b2..6c5943d3b9 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -32,20 +32,21 @@
  
  #include 

  #include   /* for PRId64 macro */
  #include "util/debug.h"
  #include "glheader.h"
  #include "enums.h"
  #include "hash.h"
  #include "imports.h"
  #include "context.h"
  #include "bufferobj.h"
+#include "externalobjects.h"
  #include "mtypes.h"
  #include "teximage.h"
  #include "glformats.h"
  #include "texstore.h"
  #include "transformfeedback.h"
  #include "varray.h"
  
  
  /* Debug flags */

  /*#define VBO_DEBUG*/
@@ -1813,56 +1814,97 @@ validate_buffer_storage(struct gl_context *ctx,
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func);
return false;
 }
  
 return true;

  }
  
  
  static void

  buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
-   GLenum target, GLsizeiptr size, const GLvoid *data,
-   GLbitfield flags, const char *func)
+   struct gl_memory_object *memObj, GLenum target,
+   GLsizeiptr size, const GLvoid *data, GLbitfield flags,
+   GLuint64 offset, const char *func)
  {
+   GLboolean err;
+
 /* Unmap the existing buffer.  We'll replace it now.  Not an error. */
 _mesa_buffer_unmap_all_mappings(ctx, bufObj);
  
 FLUSH_VERTICES(ctx, 0);
  
 bufObj->Written = GL_TRUE;

 bufObj->Immutable = GL_TRUE;
 bufObj->MinMaxCacheDirty = true;
  
-   assert(ctx->Driver.BufferData);

-   if (!ctx->Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW,
-   flags, bufObj)) {
+   if (memObj) {
+  assert(ctx->Driver.BufferDataMem);
+  err = ctx->Driver.BufferDataMem(ctx, target, size, memObj, offset,
+  GL_DYNAMIC_DRAW, bufObj);
+   }
+   else {
+  assert(ctx->Driver.BufferData);
+  err = ctx->Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW,
+   flags, bufObj);
+   }
+
+   if (err) {
if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
   /* Even though the interaction between AMD_pinned_memory and
* glBufferStorage is not described in the spec, Graham Sellers
* said that it should behave the same as glBufferData.
*/
   _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func);
}
else {
   _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
}
 }
  }
  
  
  static ALWAYS_INLINE void

  inlined_buffer_storage(GLenum target, GLuint buffer, GLsizeiptr size,
-   const GLvoid *data, GLbitfield flags, bool dsa,
-   bool no_error, const char *func)
+   const GLvoid *data, GLbitfield flags,
+   GLuint memory, GLuint64 offset,
+   bool dsa, bool mem, bool no_error, const char *func)
  {
 GET_CURRENT_CONTEXT(ctx);
 struct gl_buffer_object *bufObj;
+   struct gl_memory_object *memObj = NULL;
+
+   if (mem) {
+  /* From the EXT_external_objects spec:
+   *
+   *   "An INVALID_VALUE error is generated by BufferStorageMemEXT and
+   *   NamedBufferStorageMemEXT if  is 0, or if  + 
+   *   is greater than the size of the specified memory object."


Because you don't check the second condition yet (maybe add a TODO?), I 
think you can remove it.


With this fixed, patch is:

Reviewed-by: Samuel Pitoiset 


+   */
+  if (!no_error && memory == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(memory == 0)", func);
+  }
+
+  memObj = _mesa_lookup_memory_object(ctx, memory);
+  if (!memObj)
+ return;
+
+  /* From the EXT_external_objects spec:
+   *
+   *   "An INVALID_OPERATION error is generated if  names a
+   *   valid memory object which has no associated memory."
+   */
+  if (!no_error && !memObj->Immutable) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(no associated memory)",
+ func);
+ return;
+  }
+   }
  
 if (dsa) {

if (no_error) {
   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
} else {
   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
   if (!bufObj)
  return;
}
 } else {
@@ -1870,94 +1912,98 @@ inlined_buffer_storage(GLenum target, GLuint buffer, 
GLsizeiptr size,
   

Re: [Mesa-dev] [PATCH 16/23] gallium: introduce device/driver UUID queries

2017-08-04 Thread Samuel Pitoiset

Reviewed-by: Samuel Pitoiset 

On 08/04/2017 03:54 AM, Timothy Arceri wrote:

From: Andres Rodriguez 

v2: remove unnecessary returns
v3 (Timothy Arceri): updated trace
v4 (Timothy Arceri): actually dump the params in trace

Signed-off-by: Andres Rodriguez 
Reviewed-by: Marek Olšák  (v2)
---
  src/gallium/drivers/ddebug/dd_screen.c | 18 ++
  src/gallium/drivers/trace/tr_screen.c  | 31 +++
  src/gallium/include/pipe/p_defines.h   |  1 +
  src/gallium/include/pipe/p_screen.h| 13 +
  4 files changed, 63 insertions(+)

diff --git a/src/gallium/drivers/ddebug/dd_screen.c 
b/src/gallium/drivers/ddebug/dd_screen.c
index 51382da1d7..c518f5f9e9 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ b/src/gallium/drivers/ddebug/dd_screen.c
@@ -190,20 +190,36 @@ static int
  dd_screen_get_driver_query_group_info(struct pipe_screen *_screen,
unsigned index,
struct pipe_driver_query_group_info 
*info)
  {
 struct pipe_screen *screen = dd_screen(_screen)->screen;
  
 return screen->get_driver_query_group_info(screen, index, info);

  }
  
  
+static void

+dd_screen_get_driver_uuid(struct pipe_screen *_screen, char *uuid)
+{
+   struct pipe_screen *screen = dd_screen(_screen)->screen;
+
+   screen->get_driver_uuid(screen, uuid);
+}
+
+static void
+dd_screen_get_device_uuid(struct pipe_screen *_screen, char *uuid)
+{
+   struct pipe_screen *screen = dd_screen(_screen)->screen;
+
+   screen->get_device_uuid(screen, uuid);
+}
+
  /
   * resource
   */
  
  static struct pipe_resource *

  dd_screen_resource_create(struct pipe_screen *_screen,
const struct pipe_resource *templat)
  {
 struct pipe_screen *screen = dd_screen(_screen)->screen;
 struct pipe_resource *res = screen->resource_create(screen, templat);
@@ -455,20 +471,22 @@ ddebug_screen_create(struct pipe_screen *screen)
 SCR_INIT(resource_changed);
 dscreen->base.resource_destroy = dd_screen_resource_destroy;
 SCR_INIT(flush_frontbuffer);
 SCR_INIT(fence_reference);
 SCR_INIT(fence_finish);
 SCR_INIT(memobj_create_from_handle);
 SCR_INIT(memobj_destroy);
 SCR_INIT(get_driver_query_info);
 SCR_INIT(get_driver_query_group_info);
 SCR_INIT(get_compiler_options);
+   SCR_INIT(get_driver_uuid);
+   SCR_INIT(get_device_uuid);
  
  #undef SCR_INIT
  
 dscreen->screen = screen;

 dscreen->timeout_ms = timeout;
 dscreen->mode = mode;
 dscreen->no_flush = no_flush;
 dscreen->verbose = strstr(option, "verbose") != NULL;
 dscreen->apitrace_dump_call = apitrace_dump_call;
  
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c

index 7c4c05b4c3..8802f3a737 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -295,20 +295,49 @@ trace_screen_flush_frontbuffer(struct pipe_screen 
*_screen,
 /* XXX: hide, as there is nothing we can do with this
 trace_dump_arg(ptr, context_private);
 */
  
 screen->flush_frontbuffer(screen, resource, level, layer, context_private, sub_box);
  
 trace_dump_call_end();

  }
  
  
+static void

+trace_screen_get_driver_uuid(struct pipe_screen *_screen, char *uuid)
+{
+   struct pipe_screen *screen = trace_screen(_screen)->screen;
+
+   trace_dump_call_begin("pipe_screen", "get_driver_uuid");
+   trace_dump_arg(ptr, screen);
+
+   screen->get_driver_uuid(screen, uuid);
+
+   trace_dump_ret(string, uuid);
+   trace_dump_call_end();
+}
+
+static void
+trace_screen_get_device_uuid(struct pipe_screen *_screen, char *uuid)
+{
+   struct pipe_screen *screen = trace_screen(_screen)->screen;
+
+   trace_dump_call_begin("pipe_screen", "get_device_uuid");
+   trace_dump_arg(ptr, screen);
+
+   screen->get_device_uuid(screen, uuid);
+
+   trace_dump_ret(string, uuid);
+   trace_dump_call_end();
+}
+
+
  /
   * texture
   */
  
  
  static struct pipe_resource *

  trace_screen_resource_create(struct pipe_screen *_screen,
  const struct pipe_resource *templat)
  {
 struct trace_screen *tr_scr = trace_screen(_screen);
@@ -613,20 +642,22 @@ trace_screen_create(struct pipe_screen *screen)
 tr_scr->base.resource_get_handle = trace_screen_resource_get_handle;
 SCR_INIT(resource_from_memobj);
 SCR_INIT(resource_changed);
 tr_scr->base.resource_destroy = trace_screen_resource_destroy;
 tr_scr->base.fence_reference = trace_screen_fence_reference;
 tr_scr->base.fence_finish = trace_screen_fence_finish;
 SCR_INIT(memobj_create_from_handle);
 SCR_INIT(memobj_destroy);
 tr_scr->base.flush_frontbuffer = trace_screen_flush_frontbuffer;
 tr_scr->base.get_timestamp = trace_screen_get_timestamp;
+   SCR_INIT(get_driver_uuid);
+  

Re: [Mesa-dev] [PATCH v2 6/6] radeonsi: try to re-use previously deleted bindless descriptor slots

2017-08-04 Thread Samuel Pitoiset



On 08/04/2017 10:33 AM, Marek Olšák wrote:

On Fri, Aug 4, 2017 at 10:06 AM, Samuel Pitoiset
 wrote:



On 08/01/2017 09:54 PM, Marek Olšák wrote:


Hi Samuel,

Can you move this slot allocator into a util module? It seems generic
enough that it could be reused for "handle" and "ID" allocations.

Some additional notes:
- a bit array of uin32_t would be better. bool is too large (1 byte).
- "free" is the inverse of "used", so the "used" array is redundant.



Yeah, but we have to keep track of two different arrays. When a texture
handle is destroyed, the ID can be re-used but not right now, because the
GPU can still use the descriptor.


Not true. You can reuse all freed slots immediately if you re-upload
the whole array instead of using WRITE_DATA.


Well, this is true, but re-uploading the whole array is costly...



Marek


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


Re: [Mesa-dev] [PATCH] radv: avoid GPU hangs if someone does a resolve with non-multisample src (v2)

2017-08-04 Thread Nicolai Hähnle

On 04.08.2017 04:51, Dave Airlie wrote:

From: Dave Airlie 

This is a bug in the app, but I'd rather avoid hanging the GPU,
esp if someone is running in validation and it takes out their
development environment.

v2: get it right, reverse the polarity.

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

diff --git a/src/amd/vulkan/radv_meta_resolve.c 
b/src/amd/vulkan/radv_meta_resolve.c
index 6cd0c38..6023e0f 100644
--- a/src/amd/vulkan/radv_meta_resolve.c
+++ b/src/amd/vulkan/radv_meta_resolve.c
@@ -382,6 +382,11 @@ void radv_CmdResolveImage(
radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, 
cmd_buffer);
  
  	assert(src_image->info.samples > 1);

+   if (src_image->info.samples <= 1) {
+   /* this causes GPU hangs if we get past here */
+   fprintf(stderr, "radv: Illegal resolve operation (src not 
multisampled), will hang GPU.");
+   return;


If you really want to make sure developers get this right, you should 
probably abort(); here? Although that might then bug users... maybe an 
abort() that can be skipped by explicitly setting an environment variable?


That's the usual problem with Vulkan, I guess...

Cheers,
Nicolai



+   }
assert(dest_image->info.samples == 1);
  
  	if (src_image->info.samples >= 16) {





--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Avoids loop for buffer object availability in add_exec_bo

2017-08-04 Thread Muthukumar, Aravindan
Hi Chris,

> -Original Message-
> From: Chris Wilson [mailto:ch...@chris-wilson.co.uk]
> Sent: Tuesday, August 1, 2017 2:35 PM
> To: Marathe, Yogesh ; mesa-
> d...@lists.freedesktop.org
> Cc: Muthukumar, Aravindan 
> Subject: RE: [Mesa-dev] [PATCH] i965: Avoids loop for buffer object 
> availability
> in add_exec_bo
> 
> Quoting Marathe, Yogesh (2017-08-01 09:21:51)
> > > > -Original Message-
> > > > From: Chris Wilson [mailto:ch...@chris-wilson.co.uk]
> > > > Sent: Friday, July 28, 2017 2:30 PM
> > > > To: Muthukumar, Aravindan ; mesa-
> > > > d...@lists.freedesktop.org
> > > > Cc: Marathe, Yogesh ; Muthukumar,
> > > > Aravindan 
> > > > Subject: Re: [Mesa-dev] [PATCH] i965: Avoids loop for buffer
> > > > object availability in add_exec_bo
> > > >
> > > > Quoting aravindan.muthuku...@intel.com (2017-07-28 09:37:01)
> > > > > From: Aravindan Muthukumar 
> > > > >
> > > > > Original logic loops over the list for every buffer object.
> > > > > Maintained a flag to identify whether bo is already there in list.
> > > >
> > > > No. brw_bo is shared between many contexts, and so you are marking
> > > > it as available in every one. May I suggest looking for issues in
> > > > https://patchwork.freedesktop.org/series/27719/ and help bring
> > > > that series to fruition.
> > >
> > > Thanks Chris, we'll get back.
> >
> > Agreed. The patch series you have pointed out covers it, patch can be
> dropped.
> > We tried applying series on master but it didn't apply cleanly, is
> > there a base commit/branch on which this was tested / expected to work?
> 
> The tip of https://cgit.freedesktop.org/~ickle/mesa/log/?h=qbo
> i.e.
> https://cgit.freedesktop.org/~ickle/mesa/commit/?h=qbo&id=b40fa6633bdac9
> 4cef2fd5f56360dfdb5eeb3738

I tested the patch series with mesa demos which seems functionally fine. 
Is there any specific functional/perf issue that needs to be looked at?

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


Re: [Mesa-dev] [PATCH v2 7/9] anv/allocator: Add a syncobj cache

2017-08-04 Thread Chris Wilson
Quoting Jason Ekstrand (2017-08-04 02:25:26)
> This is mostly a copy+paste of the BO cache but it's a bit simpler
> because syncobjs don't have actual backing storage so we don't need to
> check sizes or anything like that.  Also, we put the refcount directly
> in anv_syncobj because they will always be heap pointers.

Ok, but why do we need one at all? Some part of the Vk spec, some bad
behaviour you noticed? Or just that it is more elegant to be minimalist?

> ---
>  src/intel/vulkan/anv_allocator.c | 194 
> +++
>  src/intel/vulkan/anv_device.c|   9 +-
>  src/intel/vulkan/anv_private.h   |  40 
>  3 files changed, 242 insertions(+), 1 deletion(-)
> 
> diff --git a/src/intel/vulkan/anv_allocator.c 
> b/src/intel/vulkan/anv_allocator.c
> index efaaebc..204c466 100644
> --- a/src/intel/vulkan/anv_allocator.c
> +++ b/src/intel/vulkan/anv_allocator.c
> @@ -1422,3 +1422,197 @@ anv_bo_cache_release(struct anv_device *device,
>  
> vk_free(&device->alloc, bo);
>  }
> +
> +VkResult
> +anv_syncobj_cache_init(struct anv_syncobj_cache *cache)
> +{
> +   cache->map = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
> +_mesa_key_pointer_equal);

Not hash_uint for u32? Bah, for the number of ht mesa creates for
looking up u32 names, you would think it would have an ultra-specialised
data struct for it. :(
-Chris
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 8/9] anv: Use DRM sync objects for external semaphores when available

2017-08-04 Thread Chris Wilson
Quoting Jason Ekstrand (2017-08-04 02:25:27)
> @@ -1497,6 +1569,12 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
>setup_empty_execbuf(&execbuf, device);
> }
>  
> +   if (execbuf.fence_count > 0) {

For sanity, since I just had to check, assert(device->has_syncobj);

> +  execbuf.execbuf.flags |= I915_EXEC_FENCE_ARRAY;
> +  execbuf.execbuf.num_cliprects = execbuf.fence_count;
> +  execbuf.execbuf.cliprects_ptr = (uintptr_t) execbuf.fences;
> +   }
> +
> if (in_fence != -1) {
>execbuf.execbuf.flags |= I915_EXEC_FENCE_IN;
>execbuf.execbuf.rsvd2 |= (uint32_t)in_fence;
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v4] glsl: update the extensions that are enabled for 460

2017-08-04 Thread Nicolai Hähnle

On 03.08.2017 11:24, Samuel Pitoiset wrote:

Other ones are either unsupported or don't have any helper
function checks.

v4: - drop ARB suffix for shader_group_vote/arb_shader_atomic_counter_ops
v3: - always add gl_BaseVertex & co when 460 is enabled
v2: - fix ARB_shader_draw_parameters system value names

Signed-off-by: Samuel Pitoiset 


Reviewed-by: Nicolai Hähnle 



---
  src/compiler/glsl/builtin_functions.cpp | 81 +
  src/compiler/glsl/builtin_variables.cpp |  5 ++
  2 files changed, 78 insertions(+), 8 deletions(-)

diff --git a/src/compiler/glsl/builtin_functions.cpp 
b/src/compiler/glsl/builtin_functions.cpp
index 84833bdd7d..bbb60b4e64 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -151,6 +151,12 @@ v130_desktop(const _mesa_glsl_parse_state *state)
  }
  
  static bool

+v460_desktop(const _mesa_glsl_parse_state *state)
+{
+   return state->is_version(460, 0);
+}
+
+static bool
  v130_fs_only(const _mesa_glsl_parse_state *state)
  {
 return state->is_version(130, 300) &&
@@ -483,7 +489,7 @@ shader_atomic_counters(const _mesa_glsl_parse_state *state)
  static bool
  shader_atomic_counter_ops(const _mesa_glsl_parse_state *state)
  {
-   return state->ARB_shader_atomic_counter_ops_enable;
+   return v460_desktop(state) || state->ARB_shader_atomic_counter_ops_enable;
  }
  
  static bool

@@ -606,7 +612,7 @@ barrier_supported(const _mesa_glsl_parse_state *state)
  static bool
  vote(const _mesa_glsl_parse_state *state)
  {
-   return state->ARB_shader_group_vote_enable;
+   return v460_desktop(state) || state->ARB_shader_group_vote_enable;
  }
  
  static bool

@@ -962,7 +968,8 @@ private:
  
 ir_function_signature *_vote_intrinsic(builtin_available_predicate avail,

enum ir_intrinsic_id id);
-   ir_function_signature *_vote(const char *intrinsic_name);
+   ir_function_signature *_vote(const char *intrinsic_name,
+builtin_available_predicate avail);
  
  #undef B0

  #undef B1
@@ -3031,6 +3038,43 @@ builtin_builder::create_builtins()
  shader_atomic_counter_ops),
  NULL);
  
+   add_function("atomicCounterAdd",

+_atomic_counter_op1("__intrinsic_atomic_add",
+v460_desktop),
+NULL);
+   add_function("atomicCounterSubtract",
+_atomic_counter_op1("__intrinsic_atomic_sub",
+v460_desktop),
+NULL);
+   add_function("atomicCounterMin",
+_atomic_counter_op1("__intrinsic_atomic_min",
+v460_desktop),
+NULL);
+   add_function("atomicCounterMax",
+_atomic_counter_op1("__intrinsic_atomic_max",
+v460_desktop),
+NULL);
+   add_function("atomicCounterAnd",
+_atomic_counter_op1("__intrinsic_atomic_and",
+v460_desktop),
+NULL);
+   add_function("atomicCounterOr",
+_atomic_counter_op1("__intrinsic_atomic_or",
+v460_desktop),
+NULL);
+   add_function("atomicCounterXor",
+_atomic_counter_op1("__intrinsic_atomic_xor",
+v460_desktop),
+NULL);
+   add_function("atomicCounterExchange",
+_atomic_counter_op1("__intrinsic_atomic_exchange",
+v460_desktop),
+NULL);
+   add_function("atomicCounterCompSwap",
+_atomic_counter_op2("__intrinsic_atomic_comp_swap",
+v460_desktop),
+NULL);
+
 add_function("atomicAdd",
  _atomic_op2("__intrinsic_atomic_add",
  buffer_atomics_supported,
@@ -3220,9 +3264,29 @@ builtin_builder::create_builtins()
glsl_type::uint64_t_type),
  NULL);
  
-   add_function("anyInvocationARB", _vote("__intrinsic_vote_any"), NULL);

-   add_function("allInvocationsARB", _vote("__intrinsic_vote_all"), NULL);
-   add_function("allInvocationsEqualARB", _vote("__intrinsic_vote_eq"), NULL);
+   add_function("anyInvocationARB",
+_vote("__intrinsic_vote_any", vote),
+NULL);
+
+   add_function("allInvocationsARB",
+_vote("__intrinsic_vote_all", vote),
+NULL);
+
+   add_function("allInvocationsEqualARB",
+_vote("__intrinsic_vote_eq", vote),
+NULL);
+
+   add_function("anyInvocation",
+_vote("__intrinsic_vote_any", v460_desktop),
+NULL);
+
+   add_function("allInvocations",
+_vote("__intrinsic_vote_all", v460_desktop),
+NULL);
+
+   add_function("allInv

Re: [Mesa-dev] [PATCH] i965: Avoids loop for buffer object availability in add_exec_bo

2017-08-04 Thread Chris Wilson
Quoting Muthukumar, Aravindan (2017-08-04 09:53:57)
> > The tip of https://cgit.freedesktop.org/~ickle/mesa/log/?h=qbo
> > i.e.
> > https://cgit.freedesktop.org/~ickle/mesa/commit/?h=qbo&id=b40fa6633bdac9
> > 4cef2fd5f56360dfdb5eeb3738
> 
> I tested the patch series with mesa demos which seems functionally fine. 
> Is there any specific functional/perf issue that needs to be looked at?

If you have a target workload, finding any potential regressions would
be very useful. Not that I expect there to be any, but scrutiny from an
unbiased perspective is vital.

Speaking of which, back to ezbench...
-Chris
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallium/clover: Remove libxmlconfig.la from targets/clover/Makefile.am

2017-08-04 Thread Nicolai Hähnle

On 04.08.2017 10:27, Nicolai Hähnle wrote:

On 04.08.2017 06:24, Aaron Watry wrote:

Gets rid of a bunch of errors like the following:

make[4]: Entering directory 
'/home/me/src/mesa/build/src/gallium/targets/opencl'

   CXXLDlibOpenCL.la
../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o): In 
function `driParseOptionInfo':
/home/me/src/mesa/src/util/xmlconfig.c:719: multiple definition of 
`driParseOptionInfo'
../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:719: 
first defined here
../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o): In 
function `driParseConfigFiles':
/home/me/src/mesa/src/util/xmlconfig.c:990: multiple definition of 
`driParseConfigFiles'
../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:990: 
first defined here


Fixes: 33f7d71d5358337f ("pipe-loader: fix build of dynamic 
pipe-drivers")

Cc: Nicolai Hähnle 
Cc: Emil Velikov 
---
  src/gallium/targets/opencl/Makefile.am | 1 -
  1 file changed, 1 deletion(-)

diff --git a/src/gallium/targets/opencl/Makefile.am 
b/src/gallium/targets/opencl/Makefile.am

index e88fa0fd38..c9d2be7afd 100644
--- a/src/gallium/targets/opencl/Makefile.am
+++ b/src/gallium/targets/opencl/Makefile.am
@@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
  $(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
  $(top_builddir)/src/gallium/auxiliary/libgallium.la \
  $(top_builddir)/src/util/libmesautil.la \
-$(top_builddir)/src/util/libxmlconfig.la \


So, this is weird because I added this line to make one of the Travis CI 
builds pass. What are your ./configure options?


Okay, so the difference is HAVE_CLOVER_ICD. Apparently there's no Travis 
CI build with that set to false. We need to figure out a way to make 
both options happy.


Cheers,
Nicolai




Thanks,
Nicolai


  $(EXPAT_LIBS) \
  $(LIBELF_LIBS) \
  $(DLOPEN_LIBS) \



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



--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/23] mesa: hook up memoryobject tex(ture)storage api

2017-08-04 Thread Timothy Arceri



On 04/08/17 18:45, Samuel Pitoiset wrote:



On 08/04/2017 03:54 AM, Timothy Arceri wrote:

From: Andres Rodriguez 

V2 (Timothy Arceri):
  - formating fixes

V3 (Timothy):
  - error check memory == 0 before lookup

Signed-off-by: Andres Rodriguez 
Reviewed-by: Samuel Pitoiset  (v2)
---
  src/mesa/main/dd.h  |  10 
  src/mesa/main/externalobjects.c | 128 


  src/mesa/main/texstorage.c  |  76 +---
  src/mesa/main/texstorage.h  |   9 +++
  4 files changed, 191 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 6d6bdecb4d..fbe70cdfab 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1080,20 +1080,30 @@ struct dd_function_table {
  * allocate/return a subclass of gl_memory_object.
  */
 struct gl_memory_object * (*NewMemoryObject)(struct gl_context *ctx,
  GLuint name);
 /**
  * Called to delete/free a memory object.  Drivers should free the
  * object and any image data it contains.
  */
 void (*DeleteMemoryObject)(struct gl_context *ctx,
struct gl_memory_object *memObj);
+
+   /**
+* Set the given memory object as the texture's storage.
+*/
+   GLboolean (*SetTextureStorageForMemoryObject)(struct gl_context *ctx,
+ struct 
gl_texture_object *tex_obj,
+ struct 
gl_memory_object *mem_obj,
+ GLsizei levels, 
GLsizei width,
+ GLsizei height, 
GLsizei depth,

+ GLuint64 offset);
 /*@}*/
 /**
  * \name GL_EXT_external_objects_fd interface
  */
 /*@{*/
 /**
  * Called to import a memory object. The caller relinquishes 
ownership

  * of fd after the call returns.
  *
diff --git a/src/mesa/main/externalobjects.c 
b/src/mesa/main/externalobjects.c

index c0c97f645c..d10d414f02 100644
--- a/src/mesa/main/externalobjects.c
+++ b/src/mesa/main/externalobjects.c
@@ -17,20 +17,24 @@
   * 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 "macros.h"
  #include "mtypes.h"
  #include "externalobjects.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "glformats.h"
+#include "texstorage.h"
  /**
   * Allocate and initialize a new memory object.  But don't put it 
into the

   * memory object hash table.
   *
   * Called via ctx->Driver.NewMemoryObject, unless overridden by a 
device

   * driver.
   *
   * \return pointer to new memory object.
   */
@@ -221,144 +225,248 @@ _mesa_GetMemoryObjectParameterivEXT(GLuint 
memoryObject,

default:
   goto invalid_pname;
 }
 return;
  invalid_pname:
 _mesa_error(ctx, GL_INVALID_ENUM,
 "glGetMemoryObjectParameterivEXT(pname=0x%x)", pname);
  }
+static struct gl_memory_object *
+lookup_memory_object_err(struct gl_context *ctx, unsigned memory,
+ const char* func)
+{
+   if (memory == 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(memory=0)", func);
+  return NULL;
+   }
+
+   struct gl_memory_object *memObj = _mesa_lookup_memory_object(ctx, 
memory);

+   if (!memObj)
+  return NULL;
+
+   if (!memObj->Immutable) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(no associated memory)",
+  func);
+  return NULL;
+   }


I haven't read the spec carefully, but do all memory objects have to be 
immutable?


From the EXT_external_objects_fd spec:

A successful import operation transfers ownership of  to the GL 
implementation, and performing any operation on  in the application 
after an import results in undefined behavior.





+
+   return memObj;
+}
+
+/**
+ * Helper used by _mesa_TexStorageMem1/2/3DEXT().
+ */
+static void
+texstorage_memory(GLuint dims, GLenum target, GLsizei levels,
+  GLenum internalFormat, GLsizei width, GLsizei height,
+  GLsizei depth, GLuint memory, GLuint64 offset,
+  const char *func)
+{
+   struct gl_texture_object *texObj;
+   struct gl_memory_object *memObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+  return;
+
+   memObj = lookup_memory_object_err(ctx, memory, func);
+   if (!memObj)
+  return;
+
+   _mesa_texture_storage_memory(ctx, dims, texObj, memObj, target,
+levels, internalFormat,
+width, height, depth, offset, false);
+}
+
+static void
+t

Re: [Mesa-dev] [PATCH 13/23] mesa: hook up (Named)BufferStorageMem api

2017-08-04 Thread Timothy Arceri

On 04/08/17 18:49, Samuel Pitoiset wrote:



On 08/04/2017 03:54 AM, Timothy Arceri wrote:

Include no_error variants as well.

v2 (Timothy Arceri):
  - reduced code churn by squashing some changes into
previous commits

v3 (Timothy Arceri):
  - drop unused function declaration

v4 (Timothy Arceri):
  - fix Driver function assert()
  - add missing GL errors

Signed-off-by: Andres Rodriguez 
---
  src/mesa/main/bufferobj.c | 86 
---

  1 file changed, 66 insertions(+), 20 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 05c15661b2..6c5943d3b9 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -32,20 +32,21 @@
  #include 
  #include   /* for PRId64 macro */
  #include "util/debug.h"
  #include "glheader.h"
  #include "enums.h"
  #include "hash.h"
  #include "imports.h"
  #include "context.h"
  #include "bufferobj.h"
+#include "externalobjects.h"
  #include "mtypes.h"
  #include "teximage.h"
  #include "glformats.h"
  #include "texstore.h"
  #include "transformfeedback.h"
  #include "varray.h"
  /* Debug flags */
  /*#define VBO_DEBUG*/
@@ -1813,56 +1814,97 @@ validate_buffer_storage(struct gl_context *ctx,
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func);
return false;
 }
 return true;
  }
  static void
  buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
-   GLenum target, GLsizeiptr size, const GLvoid *data,
-   GLbitfield flags, const char *func)
+   struct gl_memory_object *memObj, GLenum target,
+   GLsizeiptr size, const GLvoid *data, GLbitfield flags,
+   GLuint64 offset, const char *func)
  {
+   GLboolean err;
+
 /* Unmap the existing buffer.  We'll replace it now.  Not an 
error. */

 _mesa_buffer_unmap_all_mappings(ctx, bufObj);
 FLUSH_VERTICES(ctx, 0);
 bufObj->Written = GL_TRUE;
 bufObj->Immutable = GL_TRUE;
 bufObj->MinMaxCacheDirty = true;
-   assert(ctx->Driver.BufferData);
-   if (!ctx->Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW,
-   flags, bufObj)) {
+   if (memObj) {
+  assert(ctx->Driver.BufferDataMem);
+  err = ctx->Driver.BufferDataMem(ctx, target, size, memObj, offset,
+  GL_DYNAMIC_DRAW, bufObj);
+   }
+   else {
+  assert(ctx->Driver.BufferData);
+  err = ctx->Driver.BufferData(ctx, target, size, data, 
GL_DYNAMIC_DRAW,

+   flags, bufObj);
+   }
+
+   if (err) {
if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
   /* Even though the interaction between AMD_pinned_memory and
* glBufferStorage is not described in the spec, Graham 
Sellers

* said that it should behave the same as glBufferData.
*/
   _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func);
}
else {
   _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
}
 }
  }
  static ALWAYS_INLINE void
  inlined_buffer_storage(GLenum target, GLuint buffer, GLsizeiptr size,
-   const GLvoid *data, GLbitfield flags, bool dsa,
-   bool no_error, const char *func)
+   const GLvoid *data, GLbitfield flags,
+   GLuint memory, GLuint64 offset,
+   bool dsa, bool mem, bool no_error, const char 
*func)

  {
 GET_CURRENT_CONTEXT(ctx);
 struct gl_buffer_object *bufObj;
+   struct gl_memory_object *memObj = NULL;
+
+   if (mem) {
+  /* From the EXT_external_objects spec:
+   *
+   *   "An INVALID_VALUE error is generated by 
BufferStorageMemEXT and
+   *   NamedBufferStorageMemEXT if  is 0, or if  
+ 

+   *   is greater than the size of the specified memory object."


Because you don't check the second condition yet (maybe add a TODO?), I 
think you can remove it.


All offset checks are implementation specific as far as I understand. 
Yeah I'll remove the last part of the quote.




With this fixed, patch is:

Reviewed-by: Samuel Pitoiset 


+   */
+  if (!no_error && memory == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(memory == 0)", func);
+  }
+
+  memObj = _mesa_lookup_memory_object(ctx, memory);
+  if (!memObj)
+ return;
+
+  /* From the EXT_external_objects spec:
+   *
+   *   "An INVALID_OPERATION error is generated if  names a
+   *   valid memory object which has no associated memory."
+   */
+  if (!no_error && !memObj->Immutable) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(no associated 
memory)",

+ func);
+ return;
+  }
+   }
 if (dsa) {
if (no_error) {
   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
} else {
   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
   if (!bufObj)
  

Re: [Mesa-dev] [PATCH 06/23] mesa: hook up memoryobject tex(ture)storage api

2017-08-04 Thread Samuel Pitoiset



On 08/04/2017 11:10 AM, Timothy Arceri wrote:



On 04/08/17 18:45, Samuel Pitoiset wrote:



On 08/04/2017 03:54 AM, Timothy Arceri wrote:

From: Andres Rodriguez 

V2 (Timothy Arceri):
  - formating fixes

V3 (Timothy):
  - error check memory == 0 before lookup

Signed-off-by: Andres Rodriguez 
Reviewed-by: Samuel Pitoiset  (v2)
---
  src/mesa/main/dd.h  |  10 
  src/mesa/main/externalobjects.c | 128 


  src/mesa/main/texstorage.c  |  76 +---
  src/mesa/main/texstorage.h  |   9 +++
  4 files changed, 191 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 6d6bdecb4d..fbe70cdfab 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1080,20 +1080,30 @@ struct dd_function_table {
  * allocate/return a subclass of gl_memory_object.
  */
 struct gl_memory_object * (*NewMemoryObject)(struct gl_context 
*ctx,

  GLuint name);
 /**
  * Called to delete/free a memory object.  Drivers should free the
  * object and any image data it contains.
  */
 void (*DeleteMemoryObject)(struct gl_context *ctx,
struct gl_memory_object *memObj);
+
+   /**
+* Set the given memory object as the texture's storage.
+*/
+   GLboolean (*SetTextureStorageForMemoryObject)(struct gl_context 
*ctx,
+ struct 
gl_texture_object *tex_obj,
+ struct 
gl_memory_object *mem_obj,
+ GLsizei levels, 
GLsizei width,
+ GLsizei height, 
GLsizei depth,

+ GLuint64 offset);
 /*@}*/
 /**
  * \name GL_EXT_external_objects_fd interface
  */
 /*@{*/
 /**
  * Called to import a memory object. The caller relinquishes 
ownership

  * of fd after the call returns.
  *
diff --git a/src/mesa/main/externalobjects.c 
b/src/mesa/main/externalobjects.c

index c0c97f645c..d10d414f02 100644
--- a/src/mesa/main/externalobjects.c
+++ b/src/mesa/main/externalobjects.c
@@ -17,20 +17,24 @@
   * 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 "macros.h"
  #include "mtypes.h"
  #include "externalobjects.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "glformats.h"
+#include "texstorage.h"
  /**
   * Allocate and initialize a new memory object.  But don't put it 
into the

   * memory object hash table.
   *
   * Called via ctx->Driver.NewMemoryObject, unless overridden by a 
device

   * driver.
   *
   * \return pointer to new memory object.
   */
@@ -221,144 +225,248 @@ _mesa_GetMemoryObjectParameterivEXT(GLuint 
memoryObject,

default:
   goto invalid_pname;
 }
 return;
  invalid_pname:
 _mesa_error(ctx, GL_INVALID_ENUM,
 "glGetMemoryObjectParameterivEXT(pname=0x%x)", pname);
  }
+static struct gl_memory_object *
+lookup_memory_object_err(struct gl_context *ctx, unsigned memory,
+ const char* func)
+{
+   if (memory == 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(memory=0)", func);
+  return NULL;
+   }
+
+   struct gl_memory_object *memObj = _mesa_lookup_memory_object(ctx, 
memory);

+   if (!memObj)
+  return NULL;
+
+   if (!memObj->Immutable) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(no associated 
memory)",

+  func);
+  return NULL;
+   }


I haven't read the spec carefully, but do all memory objects have to 
be immutable?


 From the EXT_external_objects_fd spec:

A successful import operation transfers ownership of  to the GL 
implementation, and performing any operation on  in the application 
after an import results in undefined behavior.


Ah okay, is Immutable the right term? How about Imported?






+
+   return memObj;
+}
+
+/**
+ * Helper used by _mesa_TexStorageMem1/2/3DEXT().
+ */
+static void
+texstorage_memory(GLuint dims, GLenum target, GLsizei levels,
+  GLenum internalFormat, GLsizei width, GLsizei height,
+  GLsizei depth, GLuint memory, GLuint64 offset,
+  const char *func)
+{
+   struct gl_texture_object *texObj;
+   struct gl_memory_object *memObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+  return;
+
+   memObj = lookup_memory_object_err(ctx, memory, func);
+   if (!memObj)
+  return;
+
+   _mesa_texture_storage_memory(ctx, dims, texObj, memObj, target,
+   

[Mesa-dev] [PATCH] loader: always include libxmlconfig on autotools build

2017-08-04 Thread Nicolai Hähnle
From: Nicolai Hähnle 

This aligns with the fact that we also check for EXPAT_LIBS
unconditionally in configure.ac now. It should make all the
various build permutations of Clover work (whether DRI is
enabled or disabled in the build).

Cc: Aaron Watry 
Cc: Emil Velikov 
--
This change keeps everything green on Travis, and it should fix
the duplicate-symbol linker error seen by Aaron and others when
building Clover.
---
 src/gallium/targets/opencl/Makefile.am |  1 -
 src/loader/Makefile.am | 13 +
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/gallium/targets/opencl/Makefile.am 
b/src/gallium/targets/opencl/Makefile.am
index e88fa0fd382..c9d2be7afd0 100644
--- a/src/gallium/targets/opencl/Makefile.am
+++ b/src/gallium/targets/opencl/Makefile.am
@@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
$(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
$(top_builddir)/src/util/libmesautil.la \
-   $(top_builddir)/src/util/libxmlconfig.la \
$(EXPAT_LIBS) \
$(LIBELF_LIBS) \
$(DLOPEN_LIBS) \
diff --git a/src/loader/Makefile.am b/src/loader/Makefile.am
index 8b197f2995c..5ed87820664 100644
--- a/src/loader/Makefile.am
+++ b/src/loader/Makefile.am
@@ -33,21 +33,18 @@ AM_CPPFLAGS = \
$(XCB_DRI3_CFLAGS) \
$(LIBDRM_CFLAGS)
 
-libloader_la_CPPFLAGS = $(AM_CPPFLAGS)
+libloader_la_CPPFLAGS = $(AM_CPPFLAGS) \
+   -DUSE_DRICONF
 libloader_la_SOURCES = $(LOADER_C_FILES)
-libloader_la_LIBADD =
+libloader_la_LIBADD = \
+   $(top_builddir)/src/util/libxmlconfig.la
 
 if HAVE_DRICOMMON
 libloader_la_CPPFLAGS += \
-I$(top_builddir)/src/util/ \
-I$(top_srcdir)/src/mesa/drivers/dri/common/ \
-I$(top_srcdir)/src/mesa/ \
-   -I$(top_srcdir)/src/mapi/ \
-   -DUSE_DRICONF
-
-libloader_la_LIBADD += \
-   $(top_builddir)/src/util/libxmlconfig.la
-
+   -I$(top_srcdir)/src/mapi/
 endif
 
 if HAVE_LIBDRM
-- 
2.11.0

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


Re: [Mesa-dev] [PATCH 10/12] egl/drm: remove unreachable code in dri2_drm_create_surface()

2017-08-04 Thread Eric Engestrom
On Thursday, 2017-08-03 19:29:36 +0100, Emil Velikov wrote:
> From: Emil Velikov 
> 
> The function can be called only when the type is EGL_WINDOW_BIT.
> Remove the unneeded switch statement.

I take it we plan on never supporting pbuffers or pixmaps in platform_drm?

If so, I'd rather fold dri2_drm_create_surface() into
dri2_drm_create_window_surface(), as `type` is meaningless now and should
be dropped, and without it the latter is an empty pass-through function.
(can/should be a separate commit, but please send both as a single series)

Reviewed-by: Eric Engestrom 

> 
> Signed-off-by: Emil Velikov 
> ---
>  src/egl/drivers/dri2/platform_drm.c | 20 +++-
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_drm.c 
> b/src/egl/drivers/dri2/platform_drm.c
> index 7ea43e62010..8d56fcb7698 100644
> --- a/src/egl/drivers/dri2/platform_drm.c
> +++ b/src/egl/drivers/dri2/platform_drm.c
> @@ -92,13 +92,13 @@ has_free_buffers(struct gbm_surface *_surf)
>  
>  static _EGLSurface *
>  dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
> -_EGLConfig *conf, void *native_window,
> +_EGLConfig *conf, void *native_surface,
>  const EGLint *attrib_list)
>  {
> struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
> struct dri2_egl_surface *dri2_surf;
> -   struct gbm_surface *window = native_window;
> +   struct gbm_surface *window = native_surface;
> struct gbm_dri_surface *surf;
> const __DRIconfig *config;
>  
> @@ -113,17 +113,11 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay 
> *disp, EGLint type,
> if (!_eglInitSurface(&dri2_surf->base, disp, type, conf, attrib_list))
>goto cleanup_surf;
>  
> -   switch (type) {
> -   case EGL_WINDOW_BIT:
> -  surf = gbm_dri_surface(window);
> -  dri2_surf->gbm_surf = surf;
> -  dri2_surf->base.Width =  surf->base.width;
> -  dri2_surf->base.Height = surf->base.height;
> -  surf->dri_private = dri2_surf;
> -  break;
> -   default:
> -  goto cleanup_surf;
> -   }
> +   surf = gbm_dri_surface(window);
> +   dri2_surf->gbm_surf = surf;
> +   dri2_surf->base.Width =  surf->base.width;
> +   dri2_surf->base.Height = surf->base.height;
> +   surf->dri_private = dri2_surf;
>  
> config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT,
>  dri2_surf->base.GLColorspace);
> -- 
> 2.13.3
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/7] radeonsi: remove a tautology sctx->framebuffer.nr_samples >= 1

2017-08-04 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_state.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index c9bb108..11dee49 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2978,22 +2978,21 @@ static void si_emit_msaa_sample_locs(struct si_context 
*sctx,
 */
if (nr_samples <= 1 && sctx->smoothing_enabled)
nr_samples = SI_NUM_SMOOTH_AA_SAMPLES;
 
/* On Polaris, the small primitive filter uses the sample locations
 * even when MSAA is off, so we need to make sure they're set to 0.
 */
if (has_msaa_sample_loc_bug)
nr_samples = MAX2(nr_samples, 1);
 
-   if (nr_samples >= 1 &&
-   (nr_samples != sctx->msaa_sample_locs.nr_samples)) {
+   if (nr_samples != sctx->msaa_sample_locs.nr_samples) {
sctx->msaa_sample_locs.nr_samples = nr_samples;
cayman_emit_msaa_sample_locs(cs, nr_samples);
}
 
if (sctx->b.family >= CHIP_POLARIS10) {
struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
unsigned small_prim_filter_cntl =
S_028830_SMALL_PRIM_FILTER_ENABLE(1) |
/* line bug */
S_028830_LINE_FILTER_DISABLE(sctx->b.family <= 
CHIP_POLARIS12);
-- 
2.7.4

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


[Mesa-dev] [PATCH 6/7] radeonsi: use optimal packet order when doing a pipeline sync

2017-08-04 Thread Marek Olšák
From: Marek Olšák 

Process new SET packets in parallel with previous draw calls.

This decreases [CP busy / SPI busy] by a very tiny amount (verified with
GRBM perf counters), and probably increases FPS by a very tiny amount
for apps that do pipeline syncs often.
---
 src/gallium/drivers/radeonsi/si_state_draw.c | 54 
 1 file changed, 48 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
b/src/gallium/drivers/radeonsi/si_state_draw.c
index ae48115..06a18c1 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -1173,30 +1173,31 @@ static bool si_cache_flush_and_prefetch(struct 
si_context *sctx)
 */
if (!si_upload_graphics_shader_descriptors(sctx))
return false;
 
if (sctx->prefetch_L2)
cik_emit_prefetch_L2(sctx);
 
return true;
 }
 
-static void si_emit_all_states(struct si_context *sctx, const struct 
pipe_draw_info *info)
+static void si_emit_all_states(struct si_context *sctx, const struct 
pipe_draw_info *info,
+  unsigned skip_atom_mask)
 {
/* Emit state atoms. */
-   unsigned mask = sctx->dirty_atoms;
+   unsigned mask = sctx->dirty_atoms & ~skip_atom_mask;
while (mask) {
struct r600_atom *atom = sctx->atoms.array[u_bit_scan(&mask)];
 
atom->emit(&sctx->b, atom);
}
-   sctx->dirty_atoms = 0;
+   sctx->dirty_atoms &= skip_atom_mask;
 
/* Emit states. */
mask = sctx->dirty_states;
while (mask) {
unsigned i = u_bit_scan(&mask);
struct si_pm4_state *state = sctx->queued.array[i];
 
if (!state || sctx->emitted.array[i] == state)
continue;
 
@@ -1384,23 +1385,64 @@ void si_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *info)
 */
if (!si_upload_vertex_buffer_descriptors(sctx))
return;
 
/* GFX9 scissor bug workaround. There is also a more efficient but
 * more involved alternative workaround. */
if (sctx->b.chip_class == GFX9 &&
si_is_atom_dirty(sctx, &sctx->b.scissors.atom))
sctx->b.flags |= SI_CONTEXT_PS_PARTIAL_FLUSH;
 
-   if (!si_cache_flush_and_prefetch(sctx))
-   return;
-   si_emit_all_states(sctx, info);
+   /* Use an optimal packet order based on whether we need to sync the 
pipeline. */
+   if (unlikely(sctx->b.flags & (SI_CONTEXT_FLUSH_AND_INV_CB |
+ SI_CONTEXT_FLUSH_AND_INV_DB |
+ SI_CONTEXT_PS_PARTIAL_FLUSH |
+ SI_CONTEXT_CS_PARTIAL_FLUSH))) {
+   /* If we have to wait for idle, set all states first, so that 
all
+* SET packets are processed in parallel with previous draw 
calls.
+* Sequence:
+* - process SET packets except SET_SH packets for shader 
pointers
+* - flush caches and wait for previous draw calls
+* - start CE dumps (might already be ongoing if there is no 
CE-DE barrier)
+* - start prefetches
+* - process SET_SH packets for shader pointers
+* - wait for CE dumps
+* - draw
+*/
+   struct r600_atom *shader_pointers = &sctx->shader_userdata.atom;
+
+   /* Emit all states except shader pointers. */
+   si_emit_all_states(sctx, info, 1 << shader_pointers->id);
+
+   if (!si_cache_flush_and_prefetch(sctx))
+   return;
+
+   /* Set shader pointers last. */
+   if (si_is_atom_dirty(sctx, shader_pointers)) {
+   shader_pointers->emit(&sctx->b, NULL);
+   sctx->dirty_atoms = 0;
+   }
+   } else {
+   /* If we don't wait for idle, do CE dumps and start prefetches
+* first, so that they are being done in parallel with all SET
+* packets. Sequence:
+* - flush caches
+* - start CE dumps (might already be ongoing if CE is ahead)
+* - start prefetches
+* - process SET packets
+* - wait for CE dumps
+* - draw
+*/
+   if (!si_cache_flush_and_prefetch(sctx))
+   return;
+   si_emit_all_states(sctx, info, 0);
+   }
 
si_ce_pre_draw_synchronization(sctx);
si_emit_draw_packets(sctx, info, indexbuf, index_size, index_offset);
si_ce_post_draw_synchronization(sctx);
 
if (sctx->trace_buf)
si_trace_emit(sctx);
 
/* Workaround for a VGT hang when streamout is enabled.
 * It must be done after drawing. */
-- 
2.7.4

__

[Mesa-dev] [PATCH 3/7] radeonsi: align all CE dumps to L2 cache line size

2017-08-04 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_descriptors.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 02f921e..ea5b89e 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -89,20 +89,25 @@ static uint32_t null_texture_descriptor[8] = {
 
 static uint32_t null_image_descriptor[8] = {
0,
0,
0,
S_008F1C_TYPE(V_008F1C_SQ_RSRC_IMG_1D)
/* the rest must contain zeros, which is also used by the buffer
 * descriptor */
 };
 
+static uint16_t si_ce_ram_size(struct si_context *sctx)
+{
+   return sctx->b.chip_class >= GFX9 ? 4096 : 32768;
+}
+
 static void si_init_descriptor_list(uint32_t *desc_list,
unsigned element_dw_size,
unsigned num_elements,
const uint32_t *null_descriptor)
 {
int i;
 
/* Initialize the array to NULL descriptors if the element size is 8. */
if (null_descriptor) {
assert(element_dw_size % 8 == 0);
@@ -141,25 +146,32 @@ static void si_init_descriptors(struct si_context *sctx,
 static void si_release_descriptors(struct si_descriptors *desc)
 {
r600_resource_reference(&desc->buffer, NULL);
FREE(desc->list);
 }
 
 static bool si_ce_upload(struct si_context *sctx, unsigned ce_offset, unsigned 
size,
 unsigned *out_offset, struct r600_resource **out_buf)
 {
uint64_t va;
+   unsigned cache_line_size = sctx->screen->b.info.tcc_cache_line_size;
 
-   u_suballocator_alloc(sctx->ce_suballocator, size,
-si_optimal_tcc_alignment(sctx, size),
-out_offset,
-(struct pipe_resource**)out_buf);
+   /* The base and size should be aligned to the L2 cache line size
+* for optimal performance. (all dumps should rewrite whole lines)
+*/
+   size = align(size, cache_line_size);
+
+   (void)si_ce_ram_size; /* silence an "unused" warning */
+   assert(offset + size <= si_ce_ram_size(sctx));
+
+   u_suballocator_alloc(sctx->ce_suballocator, size, cache_line_size,
+out_offset, (struct pipe_resource**)out_buf);
if (!out_buf)
return false;
 
va = (*out_buf)->gpu_address + *out_offset;
 
radeon_emit(sctx->ce_ib, PKT3(PKT3_DUMP_CONST_RAM, 3, 0));
radeon_emit(sctx->ce_ib, ce_offset);
radeon_emit(sctx->ce_ib, size / 4);
radeon_emit(sctx->ce_ib, va);
radeon_emit(sctx->ce_ib, va >> 32);
@@ -2845,24 +2857,21 @@ void si_init_all_descriptors(struct si_context *sctx)
sctx->descriptors[SI_DESCS_RW_BUFFERS].num_active_slots = 
SI_NUM_RW_BUFFERS;
 
si_init_descriptors(sctx, &sctx->vertex_buffers, SI_SGPR_VERTEX_BUFFERS,
4, SI_NUM_VERTEX_BUFFERS, 0, 0, NULL);
FREE(sctx->vertex_buffers.list); /* not used */
sctx->vertex_buffers.list = NULL;
 
sctx->descriptors_dirty = u_bit_consecutive(0, SI_NUM_DESCS);
sctx->total_ce_ram_allocated = ce_offset;
 
-   if (sctx->b.chip_class >= GFX9)
-   assert(ce_offset <= 4096);
-   else
-   assert(ce_offset <= 32768);
+   assert(ce_offset <= si_ce_ram_size(sctx));
 
/* Set pipe_context functions. */
sctx->b.b.bind_sampler_states = si_bind_sampler_states;
sctx->b.b.set_shader_images = si_set_shader_images;
sctx->b.b.set_constant_buffer = si_pipe_set_constant_buffer;
sctx->b.b.set_polygon_stipple = si_set_polygon_stipple;
sctx->b.b.set_shader_buffers = si_set_shader_buffers;
sctx->b.b.set_sampler_views = si_set_sampler_views;
sctx->b.b.set_stream_output_targets = si_set_streamout_targets;
sctx->b.b.create_texture_handle = si_create_texture_handle;
-- 
2.7.4

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


[Mesa-dev] [PATCH 4/7] radeonsi: de-atomize L2 prefetch

2017-08-04 Thread Marek Olšák
From: Marek Olšák 

I'd like to be able to move the prefetch call site around.
---
 src/gallium/drivers/radeonsi/si_cp_dma.c| 7 +++
 src/gallium/drivers/radeonsi/si_descriptors.c   | 2 +-
 src/gallium/drivers/radeonsi/si_hw_context.c| 2 +-
 src/gallium/drivers/radeonsi/si_pipe.h  | 3 ++-
 src/gallium/drivers/radeonsi/si_state.h | 1 -
 src/gallium/drivers/radeonsi/si_state_draw.c| 3 +++
 src/gallium/drivers/radeonsi/si_state_shaders.c | 2 +-
 7 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_cp_dma.c 
b/src/gallium/drivers/radeonsi/si_cp_dma.c
index e42f260..9f0e506 100644
--- a/src/gallium/drivers/radeonsi/si_cp_dma.c
+++ b/src/gallium/drivers/radeonsi/si_cp_dma.c
@@ -443,21 +443,21 @@ static void cik_prefetch_shader_async(struct si_context 
*sctx,
  struct si_pm4_state *state)
 {
if (state) {
struct pipe_resource *bo = &state->bo[0]->b.b;
assert(state->nbo == 1);
 
cik_prefetch_TC_L2_async(sctx, bo, 0, bo->width0);
}
 }
 
-static void cik_emit_prefetch_L2(struct si_context *sctx, struct r600_atom 
*atom)
+void cik_emit_prefetch_L2(struct si_context *sctx)
 {
/* Prefetch shaders and VBO descriptors to TC L2. */
if (si_pm4_state_changed(sctx, ls))
cik_prefetch_shader_async(sctx, sctx->queued.named.ls);
if (si_pm4_state_changed(sctx, hs))
cik_prefetch_shader_async(sctx, sctx->queued.named.hs);
if (si_pm4_state_changed(sctx, es))
cik_prefetch_shader_async(sctx, sctx->queued.named.es);
if (si_pm4_state_changed(sctx, gs))
cik_prefetch_shader_async(sctx, sctx->queued.named.gs);
@@ -466,19 +466,18 @@ static void cik_emit_prefetch_L2(struct si_context *sctx, 
struct r600_atom *atom
 
/* Vertex buffer descriptors are uploaded uncached, so prefetch
 * them right after the VS binary. */
if (sctx->vertex_buffer_pointer_dirty) {
cik_prefetch_TC_L2_async(sctx, 
&sctx->vertex_buffers.buffer->b.b,
 sctx->vertex_buffers.buffer_offset,
 
sctx->vertex_elements->desc_list_byte_size);
}
if (si_pm4_state_changed(sctx, ps))
cik_prefetch_shader_async(sctx, sctx->queued.named.ps);
+
+   sctx->prefetch_L2 = false;
 }
 
 void si_init_cp_dma_functions(struct si_context *sctx)
 {
sctx->b.clear_buffer = si_clear_buffer;
-
-   si_init_atom(sctx, &sctx->prefetch_L2, &sctx->atoms.s.prefetch_L2,
-cik_emit_prefetch_L2);
 }
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index ea5b89e..917b0e1 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1170,21 +1170,21 @@ bool si_upload_vertex_buffer_descriptors(struct 
si_context *sctx)
  RADEON_USAGE_READ, 
RADEON_PRIO_VERTEX_BUFFER);
}
}
 
/* Don't flush the const cache. It would have a very negative effect
 * on performance (confirmed by testing). New descriptors are always
 * uploaded to a fresh new buffer, so I don't think flushing the const
 * cache is needed. */
si_mark_atom_dirty(sctx, &sctx->shader_userdata.atom);
if (sctx->b.chip_class >= CIK)
-   si_mark_atom_dirty(sctx, &sctx->prefetch_L2);
+   sctx->prefetch_L2 = true;
sctx->vertex_buffers_dirty = false;
sctx->vertex_buffer_pointer_dirty = true;
return true;
 }
 
 
 /* CONSTANT BUFFERS */
 
 static unsigned
 si_const_and_shader_buffer_descriptors_idx(unsigned shader)
diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c 
b/src/gallium/drivers/radeonsi/si_hw_context.c
index f2dfcc7..756b159 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -210,21 +210,21 @@ void si_begin_new_cs(struct si_context *ctx)
 
if (ctx->ce_preamble_ib)
si_ce_enable_loads(ctx->ce_preamble_ib);
else if (ctx->ce_ib)
si_ce_enable_loads(ctx->ce_ib);
 
if (ctx->ce_ib)
si_ce_restore_all_descriptors_at_ib_start(ctx);
 
if (ctx->b.chip_class >= CIK)
-   si_mark_atom_dirty(ctx, &ctx->prefetch_L2);
+   ctx->prefetch_L2 = true;
 
/* CLEAR_STATE disables all colorbuffers, so only enable bound ones. */
ctx->framebuffer.dirty_cbufs =
u_bit_consecutive(0, ctx->framebuffer.state.nr_cbufs);
/* CLEAR_STATE disables the zbuffer, so only enable it if it's bound. */
ctx->framebuffer.dirty_zsbuf = ctx->framebuffer.state.zsbuf != NULL;
/* This should always be marked as dirty to set the framebuffer scissor
 

[Mesa-dev] [PATCH 1/7] gallium/radeon: print all members of radeon_info with R600_DEBUG=info

2017-08-04 Thread Marek Olšák
From: Marek Olšák 

also set max_alignment on amdgpu.
---
 src/gallium/drivers/radeon/r600_pipe_common.c | 16 ++--
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c |  2 +-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index e9402f8..bab3971 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -1410,56 +1410,68 @@ bool r600_common_screen_init(struct r600_common_screen 
*rscreen,
printf("radeon: Forcing anisotropy filter to %ix\n",
   /* round down to a power of two */
   1 << util_logbase2(rscreen->force_aniso));
}
 
util_format_s3tc_init();
(void) mtx_init(&rscreen->aux_context_lock, mtx_plain);
(void) mtx_init(&rscreen->gpu_load_mutex, mtx_plain);
 
if (rscreen->debug_flags & DBG_INFO) {
+   printf("pci (domain:bus:dev.func): %04x:%02x:%02x.%x\n",
+  rscreen->info.pci_domain, rscreen->info.pci_bus,
+  rscreen->info.pci_dev, rscreen->info.pci_func);
printf("pci_id = 0x%x\n", rscreen->info.pci_id);
printf("family = %i (%s)\n", rscreen->info.family,
   r600_get_family_name(rscreen));
printf("chip_class = %i\n", rscreen->info.chip_class);
+   printf("pte_fragment_size = %u\n", 
rscreen->info.pte_fragment_size);
+   printf("gart_page_size = %u\n", rscreen->info.gart_page_size);
printf("gart_size = %i MB\n", 
(int)DIV_ROUND_UP(rscreen->info.gart_size, 1024*1024));
printf("vram_size = %i MB\n", 
(int)DIV_ROUND_UP(rscreen->info.vram_size, 1024*1024));
printf("vram_vis_size = %i MB\n", 
(int)DIV_ROUND_UP(rscreen->info.vram_vis_size, 1024*1024));
printf("max_alloc_size = %i MB\n",
   (int)DIV_ROUND_UP(rscreen->info.max_alloc_size, 
1024*1024));
+   printf("min_alloc_size = %u\n", rscreen->info.min_alloc_size);
+   printf("has_dedicated_vram = %u\n", 
rscreen->info.has_dedicated_vram);
printf("has_virtual_memory = %i\n", 
rscreen->info.has_virtual_memory);
printf("gfx_ib_pad_with_type2 = %i\n", 
rscreen->info.gfx_ib_pad_with_type2);
+   printf("has_hw_decode = %u\n", rscreen->info.has_hw_decode);
printf("num_sdma_rings = %i\n", rscreen->info.num_sdma_rings);
-   printf("has_hw_decode = %i\n", rscreen->info.has_hw_decode);
+   printf("num_compute_rings = %u\n", 
rscreen->info.num_compute_rings);
+   printf("uvd_fw_version = %u\n", rscreen->info.uvd_fw_version);
+   printf("vce_fw_version = %u\n", rscreen->info.vce_fw_version);
printf("me_fw_version = %i\n", rscreen->info.me_fw_version);
printf("pfp_fw_version = %i\n", rscreen->info.pfp_fw_version);
printf("ce_fw_version = %i\n", rscreen->info.ce_fw_version);
-   printf("vce_fw_version = %i\n", rscreen->info.vce_fw_version);
printf("vce_harvest_config = %i\n", 
rscreen->info.vce_harvest_config);
printf("clock_crystal_freq = %i\n", 
rscreen->info.clock_crystal_freq);
+   printf("tcc_cache_line_size = %u\n", 
rscreen->info.tcc_cache_line_size);
printf("drm = %i.%i.%i\n", rscreen->info.drm_major,
   rscreen->info.drm_minor, rscreen->info.drm_patchlevel);
printf("has_userptr = %i\n", rscreen->info.has_userptr);
+   printf("has_syncobj = %u\n", rscreen->info.has_syncobj);
 
printf("r600_max_quad_pipes = %i\n", 
rscreen->info.r600_max_quad_pipes);
printf("max_shader_clock = %i\n", 
rscreen->info.max_shader_clock);
printf("num_good_compute_units = %i\n", 
rscreen->info.num_good_compute_units);
printf("max_se = %i\n", rscreen->info.max_se);
printf("max_sh_per_se = %i\n", rscreen->info.max_sh_per_se);
 
printf("r600_gb_backend_map = %i\n", 
rscreen->info.r600_gb_backend_map);
printf("r600_gb_backend_map_valid = %i\n", 
rscreen->info.r600_gb_backend_map_valid);
printf("r600_num_banks = %i\n", rscreen->info.r600_num_banks);
printf("num_render_backends = %i\n", 
rscreen->info.num_render_backends);
printf("num_tile_pipes = %i\n", rscreen->info.num_tile_pipes);
printf("pipe_interleave_bytes = %i\n", 
rscreen->info.pipe_interleave_bytes);
printf("enabled_rb_mask = 0x%x\n", 
rscreen->info.enabled_rb_mask);
+   printf("max_alignment = %u\n", 
(unsigned)rscreen->info.max_alignment);
}
return true;
 }
 
 void r600_destroy_common_screen(struct r600_common_screen *rscreen)
 {
   

[Mesa-dev] [PATCH 7/7] radeonsi: rename shader_userdata -> shader_pointers where appropriate

2017-08-04 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_compute.c |  2 +-
 src/gallium/drivers/radeonsi/si_descriptors.c | 24 
 src/gallium/drivers/radeonsi/si_pipe.h|  2 +-
 src/gallium/drivers/radeonsi/si_state.h   |  6 +++---
 src/gallium/drivers/radeonsi/si_state_draw.c  |  8 
 5 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_compute.c 
b/src/gallium/drivers/radeonsi/si_compute.c
index fba02fa..5efdd39 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -804,21 +804,21 @@ static void si_launch_grid(
si_initialize_compute(sctx);
 
if (sctx->b.flags)
si_emit_cache_flush(sctx);
 
if (!si_switch_compute_shader(sctx, program, &program->shader,
code_object, info->pc))
return;
 
si_upload_compute_shader_descriptors(sctx);
-   si_emit_compute_shader_userdata(sctx);
+   si_emit_compute_shader_pointers(sctx);
 
if (si_is_atom_dirty(sctx, sctx->atoms.s.render_cond)) {
sctx->atoms.s.render_cond->emit(&sctx->b,
sctx->atoms.s.render_cond);
si_set_atom_dirty(sctx, sctx->atoms.s.render_cond, false);
}
 
if ((program->input_size ||
 program->ir_type == PIPE_SHADER_IR_NATIVE) &&
unlikely(!si_upload_compute_input(sctx, code_object, info))) {
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 917b0e1..64bb9f6 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1168,21 +1168,21 @@ bool si_upload_vertex_buffer_descriptors(struct 
si_context *sctx)
radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx,
  (struct 
r600_resource*)vb->buffer.resource,
  RADEON_USAGE_READ, 
RADEON_PRIO_VERTEX_BUFFER);
}
}
 
/* Don't flush the const cache. It would have a very negative effect
 * on performance (confirmed by testing). New descriptors are always
 * uploaded to a fresh new buffer, so I don't think flushing the const
 * cache is needed. */
-   si_mark_atom_dirty(sctx, &sctx->shader_userdata.atom);
+   si_mark_atom_dirty(sctx, &sctx->shader_pointers.atom);
if (sctx->b.chip_class >= CIK)
sctx->prefetch_L2 = true;
sctx->vertex_buffers_dirty = false;
sctx->vertex_buffer_pointer_dirty = true;
return true;
 }
 
 
 /* CONSTANT BUFFERS */
 
@@ -2091,37 +2091,37 @@ void si_update_all_texture_descriptors(struct 
si_context *sctx)
 static void si_mark_shader_pointers_dirty(struct si_context *sctx,
  unsigned shader)
 {
sctx->shader_pointers_dirty |=
u_bit_consecutive(SI_DESCS_FIRST_SHADER + shader * 
SI_NUM_SHADER_DESCS,
  SI_NUM_SHADER_DESCS);
 
if (shader == PIPE_SHADER_VERTEX)
sctx->vertex_buffer_pointer_dirty = sctx->vertex_buffers.buffer 
!= NULL;
 
-   si_mark_atom_dirty(sctx, &sctx->shader_userdata.atom);
+   si_mark_atom_dirty(sctx, &sctx->shader_pointers.atom);
 }
 
-static void si_shader_userdata_begin_new_cs(struct si_context *sctx)
+static void si_shader_pointers_begin_new_cs(struct si_context *sctx)
 {
sctx->shader_pointers_dirty = u_bit_consecutive(0, SI_NUM_DESCS);
sctx->vertex_buffer_pointer_dirty = sctx->vertex_buffers.buffer != NULL;
-   si_mark_atom_dirty(sctx, &sctx->shader_userdata.atom);
+   si_mark_atom_dirty(sctx, &sctx->shader_pointers.atom);
 }
 
 /* Set a base register address for user data constants in the given shader.
  * This assigns a mapping from PIPE_SHADER_* to SPI_SHADER_USER_DATA_*.
  */
 static void si_set_user_data_base(struct si_context *sctx,
  unsigned shader, uint32_t new_base)
 {
-   uint32_t *base = &sctx->shader_userdata.sh_base[shader];
+   uint32_t *base = &sctx->shader_pointers.sh_base[shader];
 
if (*base != new_base) {
*base = new_base;
 
if (new_base) {
si_mark_shader_pointers_dirty(sctx, shader);
 
if (shader == PIPE_SHADER_VERTEX)
sctx->last_vs_state = ~0;
}
@@ -2178,25 +2178,25 @@ static void si_emit_shader_pointer(struct si_context 
*sctx,
 
va = desc->buffer->gpu_address +
 desc->buffer_offset;
 
radeon_emit(cs, PKT3(PKT3_SET_SH_REG, 2, 0));
radeon_emit(cs, (sh_base + desc->shader_userdata_offset - 
SI_SH_REG_OFFSET) >> 2);
radeon_emit(cs, va);
radeon_emit(cs, va >> 32);
 }
 
-void si_e

[Mesa-dev] [PATCH 5/7] radeonsi: move flush+prefetch invocation and state emission into separate funcs

2017-08-04 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_state_draw.c | 97 
 1 file changed, 57 insertions(+), 40 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
b/src/gallium/drivers/radeonsi/si_state_draw.c
index 3f933fe..ae48115 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -1155,28 +1155,80 @@ void si_ce_pre_draw_synchronization(struct si_context 
*sctx)
 void si_ce_post_draw_synchronization(struct si_context *sctx)
 {
if (sctx->ce_need_synchronization) {
radeon_emit(sctx->b.gfx.cs, PKT3(PKT3_INCREMENT_DE_COUNTER, 0, 
0));
radeon_emit(sctx->b.gfx.cs, 0); /* unused */
 
sctx->ce_need_synchronization = false;
}
 }
 
+static bool si_cache_flush_and_prefetch(struct si_context *sctx)
+{
+   /* Flush caches before prefetches. */
+   if (sctx->b.flags)
+   si_emit_cache_flush(sctx);
+
+   /* Dumping from CE to L2 should be done after cache flushes, but
+* this is only guaranteed when CE is behind or in-sync with DE.
+*/
+   if (!si_upload_graphics_shader_descriptors(sctx))
+   return false;
+
+   if (sctx->prefetch_L2)
+   cik_emit_prefetch_L2(sctx);
+
+   return true;
+}
+
+static void si_emit_all_states(struct si_context *sctx, const struct 
pipe_draw_info *info)
+{
+   /* Emit state atoms. */
+   unsigned mask = sctx->dirty_atoms;
+   while (mask) {
+   struct r600_atom *atom = sctx->atoms.array[u_bit_scan(&mask)];
+
+   atom->emit(&sctx->b, atom);
+   }
+   sctx->dirty_atoms = 0;
+
+   /* Emit states. */
+   mask = sctx->dirty_states;
+   while (mask) {
+   unsigned i = u_bit_scan(&mask);
+   struct si_pm4_state *state = sctx->queued.array[i];
+
+   if (!state || sctx->emitted.array[i] == state)
+   continue;
+
+   si_pm4_emit(sctx, state);
+   sctx->emitted.array[i] = state;
+   }
+   sctx->dirty_states = 0;
+
+   /* Emit draw states. */
+   unsigned num_patches = 0;
+
+   si_emit_rasterizer_prim_state(sctx);
+   if (sctx->tes_shader.cso)
+   si_emit_derived_tess_state(sctx, info, &num_patches);
+   si_emit_vs_state(sctx, info);
+   si_emit_draw_registers(sctx, info, num_patches);
+}
+
 void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 {
struct si_context *sctx = (struct si_context *)ctx;
struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
struct pipe_resource *indexbuf = info->index.resource;
-   unsigned mask, dirty_tex_counter;
+   unsigned dirty_tex_counter;
enum pipe_prim_type rast_prim;
-   unsigned num_patches = 0;
unsigned index_size = info->index_size;
unsigned index_offset = info->indirect ? info->start * index_size : 0;
 
if (likely(!info->indirect)) {
/* SI-CI treat instance_count==0 as instance_count==1. There is
 * no workaround for indirect draws, but we can at least skip
 * direct draws.
 */
if (unlikely(!info->instance_count))
return;
@@ -1244,23 +1296,20 @@ void si_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *info)
 
if (gs_tri_strip_adj_fix != sctx->gs_tri_strip_adj_fix) {
sctx->gs_tri_strip_adj_fix = gs_tri_strip_adj_fix;
sctx->do_update_shaders = true;
}
}
 
if (sctx->do_update_shaders && !si_update_shaders(sctx))
return;
 
-   if (!si_upload_graphics_shader_descriptors(sctx))
-   return;
-
if (index_size) {
/* Translate or upload, if needed. */
/* 8-bit indices are supported on VI. */
if (sctx->b.chip_class <= CIK && index_size == 1) {
unsigned start, count, start_offset, size, offset;
void *ptr;
 
si_get_draw_start_count(sctx, info, &start, &count);
start_offset = start * 2;
size = count * 2;
@@ -1335,55 +1384,23 @@ void si_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *info)
 */
if (!si_upload_vertex_buffer_descriptors(sctx))
return;
 
/* GFX9 scissor bug workaround. There is also a more efficient but
 * more involved alternative workaround. */
if (sctx->b.chip_class == GFX9 &&
si_is_atom_dirty(sctx, &sctx->b.scissors.atom))
sctx->b.flags |= SI_CONTEXT_PS_PARTIAL_FLUSH;
 
-   /* Flush caches before the first state atom, which does L2 prefetches. 
*/
-   if (sctx->b.flags)
-   si_emit_cache_flush(sctx);
-

Re: [Mesa-dev] [EGL android: accquire fence implementation 1/2] i965: Return the last fence if the batch buffer is empty and nothing to be flushed when _intel_batchbuffer_flush_fence.

2017-08-04 Thread Marathe, Yogesh
Hi Emil,

> -Original Message-
> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf
> Of Emil Velikov
> Sent: Tuesday, July 25, 2017 8:19 PM
> To: Wu, Zhongmin 
> Cc: Gao, Shuo ; Antognolli, Rafael
> ; Timothy Arceri ;
> Marathe, Yogesh ; Tomasz Figa
> ; Kenneth Graunke ;
> Kondapally, Kalyan ; ML mesa-dev  d...@lists.freedesktop.org>
> Subject: Re: [Mesa-dev] [EGL android: accquire fence implementation 1/2] i965:
> Return the last fence if the batch buffer is empty and nothing to be flushed 
> when
> _intel_batchbuffer_flush_fence.
> 
> Hi Zhongmin,
> 
> Is the issue resolved by the EGL patch alone? Worth sticking with that for 
> now?
> 
> I think this patch will cause some noticeable overhead - see below for 
> details.
> 
> 
> On 21 July 2017 at 04:08, Zhongmin Wu  wrote:
> > Always save the last fence in the brw context when flushing buffer. If
> > the buffer is nothing to be flushed, then return the last fence when
> > asked for.
> >
> > Change-Id: Ic47035bcd1a27e402609afd9e2d1e3972548b97d
> > Signed-off-by: Zhongmin Wu 
> > ---
> >  src/mesa/drivers/dri/i965/brw_context.c   |5 +
> >  src/mesa/drivers/dri/i965/brw_context.h   |1 +
> >  src/mesa/drivers/dri/i965/intel_batchbuffer.c |   16 ++--
> >  3 files changed, 20 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> > b/src/mesa/drivers/dri/i965/brw_context.c
> > index 5433f90..ed0b056 100644
> > --- a/src/mesa/drivers/dri/i965/brw_context.c
> > +++ b/src/mesa/drivers/dri/i965/brw_context.c
> > @@ -1086,6 +1086,8 @@ brwCreateContext(gl_api api,
> > ctx->VertexProgram._MaintainTnlProgram = true;
> > ctx->FragmentProgram._MaintainTexEnvProgram = true;
> >
> > +   brw->out_fence_fd = -1;
> > +
> > brw_draw_init( brw );
> >
> > if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) { @@ -1169,6 +1171,9 @@
> > intelDestroyContext(__DRIcontext * driContextPriv)
> > brw->throttle_batch[1] = NULL;
> > brw->throttle_batch[0] = NULL;
> >
> > +   if (brw->out_fence_fd >= 0)
> > +  close(brw->out_fence_fd);
> > +
> > driDestroyOptionCache(&brw->optionCache);
> >
> > /* free the Mesa context */
> > diff --git a/src/mesa/drivers/dri/i965/brw_context.h
> > b/src/mesa/drivers/dri/i965/brw_context.h
> > index dc4bc8f..692ea2c 100644
> > --- a/src/mesa/drivers/dri/i965/brw_context.h
> > +++ b/src/mesa/drivers/dri/i965/brw_context.h
> > @@ -1217,6 +1217,7 @@ struct brw_context
> >
> > __DRIcontext *driContext;
> > struct intel_screen *screen;
> > +   int out_fence_fd;
> >  };
> >
> >  /* brw_clear.c */
> > diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > index 62d2fe8..d342e5d 100644
> > --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > @@ -648,9 +648,18 @@ do_flush_locked(struct brw_context *brw, int
> in_fence_fd, int *out_fence_fd)
> >   /* Add the batch itself to the end of the validation list */
> >   add_exec_bo(batch, batch->bo);
> >
> > + if (brw->out_fence_fd >= 0) {
> > +close(brw->out_fence_fd);
> > +brw->out_fence_fd = -1;
> > + }
> > +
> > + int fd = -1;
> >   ret = execbuffer(dri_screen->fd, batch, hw_ctx,
> >4 * USED_BATCH(*batch),
> > -  in_fence_fd, out_fence_fd, flags);
> > +  in_fence_fd, &fd, flags);
> execbuffer() creates an out fence if the "out_fence_fd" pointer is non-NULL.
> Hence with this patch we'will create a fence for each
> _intel_batchbuffer_flush_fence() invocation...
> 
> Not sure how costly that will be though :-\
> 

I see this results into 1 get_unused_fd_flags() + 1 sync_file_create() and 
operations to
store out fd in kernel for return arg. I doubt it will be very costly, the ioctl
DRM_IOCTL_I915_GEM_EXECBUFFER2 or DRM_IOCTL_I915_GEM_EXECBUFFER2_WR
was anyways there, so nothing huge additional on ioctl front.

Nonetheless, what other option do we have? This may sound absurd but is there a
way / ioctl to call  sync_file_create directly from mesa UMD and store fds 
instead of
creating at every execbuffer()? We also need a way to associate those stored 
fds to
buffers then. I know I'm adding more ioctls but intension is, if we can do this 
in some
init() we'll save these operations during execbuffer(). 

IMHO, this is separate discussion, let this patch enable functionality first 
and then
we can work on making it light. 

> -Emil
> ___
> 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 06/12] egl: add dri2_setup_swap_interval helper

2017-08-04 Thread Eric Engestrom
On Thursday, 2017-08-03 19:29:32 +0100, Emil Velikov wrote:
> From: Emil Velikov 
> 
> The current two implementations - X11 and Wayland were identical,
> barrind the upper limit.
> 
> Instead of having same code twice - introduce a helper and pass the
> limit as an argument.
> 
> Thus as Android/DRM/others get support - they only need to call the
> function ;-)
> 
> Signed-off-by: Emil Velikov 

I still haven't really looked into that extension system, I don't
understand it enough to review, so I'm skipping 1-3.

4-6, 9, 10 (with comments), 11 are
Reviewed-by: Eric Engestrom 

> ---
> FWIW I choose to keep the local wrapper since I'm too lazy to copy the
> same comments multiple times. Can fold it if people prefer.

Nah, you'd have to duplicate `arbitrary_max_interval` too, which I find meh...

> ---
>  src/egl/drivers/dri2/egl_dri2.c | 35 +++
>  src/egl/drivers/dri2/egl_dri2.h |  3 +++
>  src/egl/drivers/dri2/platform_wayland.c | 37 -
>  src/egl/drivers/dri2/platform_x11.c | 42 
> -
>  4 files changed, 48 insertions(+), 69 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 733659d547f..936b7c5199e 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -728,6 +728,41 @@ dri2_setup_screen(_EGLDisplay *disp)
> }
>  }
>  
> +void
> +dri2_setup_swap_interval(_EGLDisplay *disp, int max_swap_interval)
> +{
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> +   GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
> +
> +   /* Allow driconf to override applications.*/
> +   if (dri2_dpy->config)
> +  dri2_dpy->config->configQueryi(dri2_dpy->dri_screen,
> + "vblank_mode", &vblank_mode);
> +   switch (vblank_mode) {
> +   case DRI_CONF_VBLANK_NEVER:
> +  dri2_dpy->min_swap_interval = 0;
> +  dri2_dpy->max_swap_interval = 0;
> +  dri2_dpy->default_swap_interval = 0;
> +  break;
> +   case DRI_CONF_VBLANK_ALWAYS_SYNC:
> +  dri2_dpy->min_swap_interval = 1;
> +  dri2_dpy->max_swap_interval = max_swap_interval;
> +  dri2_dpy->default_swap_interval = 1;
> +  break;
> +   case DRI_CONF_VBLANK_DEF_INTERVAL_0:
> +  dri2_dpy->min_swap_interval = 0;
> +  dri2_dpy->max_swap_interval = max_swap_interval;
> +  dri2_dpy->default_swap_interval = 0;
> +  break;
> +   default:
> +   case DRI_CONF_VBLANK_DEF_INTERVAL_1:
> +  dri2_dpy->min_swap_interval = 0;
> +  dri2_dpy->max_swap_interval = max_swap_interval;
> +  dri2_dpy->default_swap_interval = 1;
> +  break;
> +   }
> +}
> +
>  /* All platforms but DRM call this function to create the screen and populate
>   * the driver_configs. DRM inherits that information from its display - GBM.
>   */
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index 1144ce988e1..21bbc1fd966 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -366,6 +366,9 @@ dri2_load_driver(_EGLDisplay *disp);
>  void
>  dri2_setup_screen(_EGLDisplay *disp);
>  
> +void
> +dri2_setup_swap_interval(_EGLDisplay *disp, int max_swap_interval);
> +
>  EGLBoolean
>  dri2_load_driver_swrast(_EGLDisplay *disp);
>  
> diff --git a/src/egl/drivers/dri2/platform_wayland.c 
> b/src/egl/drivers/dri2/platform_wayland.c
> index 73966b7c504..38fdfe974fa 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -925,7 +925,7 @@ dri2_wl_query_buffer_age(_EGLDriver *drv,
>  static EGLBoolean
>  dri2_wl_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
>  {
> -   return dri2_wl_swap_buffers_with_damage (drv, disp, draw, NULL, 0);
> +   return dri2_wl_swap_buffers_with_damage(drv, disp, draw, NULL, 0);
>  }
>  
>  static struct wl_buffer *
> @@ -1140,41 +1140,14 @@ static const struct wl_registry_listener 
> registry_listener_drm = {
>  };
>  
>  static void
> -dri2_wl_setup_swap_interval(struct dri2_egl_display *dri2_dpy)
> +dri2_wl_setup_swap_interval(_EGLDisplay *disp)
>  {
> -   GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
> -
> /* We can't use values greater than 1 on Wayland because we are using the
>  * frame callback to synchronise the frame and the only way we be sure to
>  * get a frame callback is to attach a new buffer. Therefore we can't just
>  * sit drawing nothing to wait until the next ‘n’ frame callbacks */
>  
> -   if (dri2_dpy->config)
> -  dri2_dpy->config->configQueryi(dri2_dpy->dri_screen,
> - "vblank_mode", &vblank_mode);
> -   switch (vblank_mode) {
> -   case DRI_CONF_VBLANK_NEVER:
> -  dri2_dpy->min_swap_interval = 0;
> -  dri2_dpy->max_swap_interval = 0;
> -  dri2_dpy->default_swap_interval = 0;
> -  break;
> -   case DRI_CONF_VBLANK_ALWAYS_SYNC:
> -  dri2_dpy->min_swap_inter

Re: [Mesa-dev] [EGL android: accquire fence implementation 1/2] i965: Return the last fence if the batch buffer is empty and nothing to be flushed when _intel_batchbuffer_flush_fence.

2017-08-04 Thread Tomasz Figa
Hi Yogesh,

On Fri, Aug 4, 2017 at 7:12 PM, Marathe, Yogesh
 wrote:
> Hi Emil,
>
>> -Original Message-
>> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf
>> Of Emil Velikov
>> Sent: Tuesday, July 25, 2017 8:19 PM
>> To: Wu, Zhongmin 
>> Cc: Gao, Shuo ; Antognolli, Rafael
>> ; Timothy Arceri ;
>> Marathe, Yogesh ; Tomasz Figa
>> ; Kenneth Graunke ;
>> Kondapally, Kalyan ; ML mesa-dev > d...@lists.freedesktop.org>
>> Subject: Re: [Mesa-dev] [EGL android: accquire fence implementation 1/2] 
>> i965:
>> Return the last fence if the batch buffer is empty and nothing to be flushed 
>> when
>> _intel_batchbuffer_flush_fence.
>>
>> Hi Zhongmin,
>>
>> Is the issue resolved by the EGL patch alone? Worth sticking with that for 
>> now?
>>
>> I think this patch will cause some noticeable overhead - see below for 
>> details.
>>
>>
>> On 21 July 2017 at 04:08, Zhongmin Wu  wrote:
>> > Always save the last fence in the brw context when flushing buffer. If
>> > the buffer is nothing to be flushed, then return the last fence when
>> > asked for.
>> >
>> > Change-Id: Ic47035bcd1a27e402609afd9e2d1e3972548b97d
>> > Signed-off-by: Zhongmin Wu 
>> > ---
>> >  src/mesa/drivers/dri/i965/brw_context.c   |5 +
>> >  src/mesa/drivers/dri/i965/brw_context.h   |1 +
>> >  src/mesa/drivers/dri/i965/intel_batchbuffer.c |   16 ++--
>> >  3 files changed, 20 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/src/mesa/drivers/dri/i965/brw_context.c
>> > b/src/mesa/drivers/dri/i965/brw_context.c
>> > index 5433f90..ed0b056 100644
>> > --- a/src/mesa/drivers/dri/i965/brw_context.c
>> > +++ b/src/mesa/drivers/dri/i965/brw_context.c
>> > @@ -1086,6 +1086,8 @@ brwCreateContext(gl_api api,
>> > ctx->VertexProgram._MaintainTnlProgram = true;
>> > ctx->FragmentProgram._MaintainTexEnvProgram = true;
>> >
>> > +   brw->out_fence_fd = -1;
>> > +
>> > brw_draw_init( brw );
>> >
>> > if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) { @@ -1169,6 +1171,9 @@
>> > intelDestroyContext(__DRIcontext * driContextPriv)
>> > brw->throttle_batch[1] = NULL;
>> > brw->throttle_batch[0] = NULL;
>> >
>> > +   if (brw->out_fence_fd >= 0)
>> > +  close(brw->out_fence_fd);
>> > +
>> > driDestroyOptionCache(&brw->optionCache);
>> >
>> > /* free the Mesa context */
>> > diff --git a/src/mesa/drivers/dri/i965/brw_context.h
>> > b/src/mesa/drivers/dri/i965/brw_context.h
>> > index dc4bc8f..692ea2c 100644
>> > --- a/src/mesa/drivers/dri/i965/brw_context.h
>> > +++ b/src/mesa/drivers/dri/i965/brw_context.h
>> > @@ -1217,6 +1217,7 @@ struct brw_context
>> >
>> > __DRIcontext *driContext;
>> > struct intel_screen *screen;
>> > +   int out_fence_fd;
>> >  };
>> >
>> >  /* brw_clear.c */
>> > diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
>> > b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
>> > index 62d2fe8..d342e5d 100644
>> > --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
>> > +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
>> > @@ -648,9 +648,18 @@ do_flush_locked(struct brw_context *brw, int
>> in_fence_fd, int *out_fence_fd)
>> >   /* Add the batch itself to the end of the validation list */
>> >   add_exec_bo(batch, batch->bo);
>> >
>> > + if (brw->out_fence_fd >= 0) {
>> > +close(brw->out_fence_fd);
>> > +brw->out_fence_fd = -1;
>> > + }
>> > +
>> > + int fd = -1;
>> >   ret = execbuffer(dri_screen->fd, batch, hw_ctx,
>> >4 * USED_BATCH(*batch),
>> > -  in_fence_fd, out_fence_fd, flags);
>> > +  in_fence_fd, &fd, flags);
>> execbuffer() creates an out fence if the "out_fence_fd" pointer is non-NULL.
>> Hence with this patch we'will create a fence for each
>> _intel_batchbuffer_flush_fence() invocation...
>>
>> Not sure how costly that will be though :-\
>>
>
> I see this results into 1 get_unused_fd_flags() + 1 sync_file_create() and 
> operations to
> store out fd in kernel for return arg. I doubt it will be very costly, the 
> ioctl
> DRM_IOCTL_I915_GEM_EXECBUFFER2 or DRM_IOCTL_I915_GEM_EXECBUFFER2_WR
> was anyways there, so nothing huge additional on ioctl front.
>
> Nonetheless, what other option do we have? This may sound absurd but is there 
> a
> way / ioctl to call  sync_file_create directly from mesa UMD and store fds 
> instead of
> creating at every execbuffer()? We also need a way to associate those stored 
> fds to
> buffers then. I know I'm adding more ioctls but intension is, if we can do 
> this in some
> init() we'll save these operations during execbuffer().
>
> IMHO, this is separate discussion, let this patch enable functionality first 
> and then
> we can work on making it light.

The question was whether the EGL patch alone solves the Flatland
issue. We need it answered first before we continue with further
discussion.

Best regards,
Tomasz
___

Re: [Mesa-dev] [PATCH] gallium/clover: Remove libxmlconfig.la from targets/clover/Makefile.am

2017-08-04 Thread Dieter Nützel

Am 04.08.2017 11:08, schrieb Nicolai Hähnle:

On 04.08.2017 10:27, Nicolai Hähnle wrote:

On 04.08.2017 06:24, Aaron Watry wrote:

Gets rid of a bunch of errors like the following:

make[4]: Entering directory 
'/home/me/src/mesa/build/src/gallium/targets/opencl'

   CXXLDlibOpenCL.la
../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o): 
In function `driParseOptionInfo':
/home/me/src/mesa/src/util/xmlconfig.c:719: multiple definition of 
`driParseOptionInfo'
../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:719: 
first defined here
../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o): 
In function `driParseConfigFiles':
/home/me/src/mesa/src/util/xmlconfig.c:990: multiple definition of 
`driParseConfigFiles'
../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:990: 
first defined here


Fixes: 33f7d71d5358337f ("pipe-loader: fix build of dynamic 
pipe-drivers")

Cc: Nicolai Hähnle 
Cc: Emil Velikov 
---
  src/gallium/targets/opencl/Makefile.am | 1 -
  1 file changed, 1 deletion(-)

diff --git a/src/gallium/targets/opencl/Makefile.am 
b/src/gallium/targets/opencl/Makefile.am

index e88fa0fd38..c9d2be7afd 100644
--- a/src/gallium/targets/opencl/Makefile.am
+++ b/src/gallium/targets/opencl/Makefile.am
@@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
  $(top_builddir)/src/gallium/state_trackers/clover/libclover.la 
\

  $(top_builddir)/src/gallium/auxiliary/libgallium.la \
  $(top_builddir)/src/util/libmesautil.la \
-$(top_builddir)/src/util/libxmlconfig.la \


So, this is weird because I added this line to make one of the Travis 
CI builds pass. What are your ./configure options?


Okay, so the difference is HAVE_CLOVER_ICD. Apparently there's no
Travis CI build with that set to false. We need to figure out a way to
make both options happy.

Cheers,
Nicolai


This is the same for me (like I posted with my latest Tested-by: for 
you)...;-)


./autogen.sh --prefix=/usr/local --with-dri-drivers="" 
--with-gallium-drivers=r600,radeonsi,swrast --with-platforms=drm,x11 
--enable-nine --enable-texture-float --enable-opencl 
--with-vulkan-drivers=radeon


With OpenCL.

So this is

Tested-by: Dieter Nützel 

Greetings,
Dieter



Thanks,
Nicolai


  $(EXPAT_LIBS) \
  $(LIBELF_LIBS) \
  $(DLOPEN_LIBS) \



___
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 08/12] egl: handle BAD_NATIVE_WINDOW/PIXMAP further up the stack

2017-08-04 Thread Eric Engestrom
On Thursday, 2017-08-03 19:29:34 +0100, Emil Velikov wrote:
> From: Emil Velikov 
> 
> The basic (null) check is identical across all backends.
> Just move it to the top.
> 
> Note that eglCreateWindowSurface* already has a guard in the *Common
> helper.

Read the code, checked that, was going to comment then saw the commit msg ^^
Anyway, I'd do 2 commits here: move x11's !pixmap check, then drop the
redundant !window checks separately.

> 
> Cc: Eric Engestrom 
> Signed-off-by: Emil Velikov 
> ---
> Eric, the X11 hunk was changed/introduced by Frank with commit
> 2900e8ca9077d20c5b29bb5a4171ac59ea9d1767

You could have Cc'ed him directly :P

> 
> If you guys had a usecase that hit the path, can you please check this
> commit does not break it.

Digging through our logs, the issue was highlighted by one (or more) of:
dEQP-EGL.functional.create_surface.pbuffer.*
dEQP-EGL.functional.image.api.*
dEQP-EGL.functional.image.create.*
dEQP-EGL.functional.image.modify.*
dEQP-EGL.functional.image.render_multiple_contexts.*
dEQP-EGL.functional.negative_api.*

If these pass for pixmaps with your patch then it should be fine :)

> ---
>  src/egl/drivers/dri2/platform_android.c | 2 +-
>  src/egl/drivers/dri2/platform_drm.c | 5 -
>  src/egl/drivers/dri2/platform_wayland.c | 5 -
>  src/egl/drivers/dri2/platform_x11.c | 7 ---
>  src/egl/main/eglapi.c   | 3 +++
>  5 files changed, 4 insertions(+), 18 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_android.c 
> b/src/egl/drivers/dri2/platform_android.c
> index 342f57dd94c..a04e934c597 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -329,7 +329,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
> EGLint type,
> if (type == EGL_WINDOW_BIT) {
>int format;
>  
> -  if (!window || window->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
> +  if (window->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
>   _eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
>   goto cleanup_surface;
>}
> diff --git a/src/egl/drivers/dri2/platform_drm.c 
> b/src/egl/drivers/dri2/platform_drm.c
> index a952aa54560..7ea43e62010 100644
> --- a/src/egl/drivers/dri2/platform_drm.c
> +++ b/src/egl/drivers/dri2/platform_drm.c
> @@ -115,11 +115,6 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay 
> *disp, EGLint type,
>  
> switch (type) {
> case EGL_WINDOW_BIT:
> -  if (!window) {
> - _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
> - goto cleanup_surf;
> -  }
> -
>surf = gbm_dri_surface(window);
>dri2_surf->gbm_surf = surf;
>dri2_surf->base.Width =  surf->base.width;
> diff --git a/src/egl/drivers/dri2/platform_wayland.c 
> b/src/egl/drivers/dri2/platform_wayland.c
> index 67be9683aca..7753f0f2c50 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -162,11 +162,6 @@ dri2_wl_create_window_surface(_EGLDriver *drv, 
> _EGLDisplay *disp,
>   dri2_surf->format = WL_SHM_FORMAT_ARGB;
> }
>  
> -   if (!window) {
> -  _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
> -  goto cleanup_surf;
> -   }
> -
> dri2_surf->wl_win = window;
> dri2_surf->wl_queue = wl_display_create_queue(dri2_dpy->wl_dpy);
> if (!dri2_surf->wl_queue) {
> diff --git a/src/egl/drivers/dri2/platform_x11.c 
> b/src/egl/drivers/dri2/platform_x11.c
> index 111c478b9de..6634c9900c4 100644
> --- a/src/egl/drivers/dri2/platform_x11.c
> +++ b/src/egl/drivers/dri2/platform_x11.c
> @@ -234,13 +234,6 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay 
> *disp, EGLint type,
> dri2_surf->drawable, dri2_dpy->screen->root,
>   dri2_surf->base.Width, dri2_surf->base.Height);
> } else {
> -  if (!drawable) {
> - if (type == EGL_WINDOW_BIT)
> -_eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
> - else
> -_eglError(EGL_BAD_NATIVE_PIXMAP, "dri2_create_surface");
> - goto cleanup_surf;
> -  }
>dri2_surf->drawable = drawable;
> }
>  
> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> index c5e3955c48c..9e836303c22 100644
> --- a/src/egl/main/eglapi.c
> +++ b/src/egl/main/eglapi.c
> @@ -1000,6 +1000,9 @@ _eglCreatePixmapSurfaceCommon(_EGLDisplay *disp, 
> EGLConfig config,
> _EGLSurface *surf;
> EGLSurface ret;
>  
> +   if (native_pixmap == NULL)
> +  RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE);
> +
>  #if HAVE_SURFACELESS_PLATFORM
> if (disp && disp->Platform == _EGL_PLATFORM_SURFACELESS) {
>/* From the EGL_MESA_platform_surfaceless spec (v1):
> -- 
> 2.13.3
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] loader/dri3: Use dri3_find_back in loader_dri3_swap_buffers_msc

2017-08-04 Thread Thomas Hellstrom

On 08/04/2017 04:47 AM, Michel Dänzer wrote:

On 03/08/17 11:25 PM, Thomas Hellstrom wrote:

Hi, Michel.

Thanks for doing this.

No worries, thank you for coming up with the fix in the first place. :)



Was there a follow-up st/mesa fix to this. I remember someone posting
about a problem about the new backbuffer always being NULL?

Yeah, there was

to fix that.



Thanks!

Thomas


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


Re: [Mesa-dev] [PATCH 1/3] glsl: remove unused field from ir_call

2017-08-04 Thread Thomas Helland
This patch is:

Reviewed-by: Thomas Helland 

2017-08-04 7:25 GMT+00:00 Timothy Arceri :
> ---
>  src/compiler/glsl/ir.h | 5 -
>  1 file changed, 5 deletions(-)
>
> diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
> index 40f3338470..d425b97aca 100644
> --- a/src/compiler/glsl/ir.h
> +++ b/src/compiler/glsl/ir.h
> @@ -1595,32 +1595,30 @@ public:
>   */
>  class ir_call : public ir_instruction {
>  public:
> ir_call(ir_function_signature *callee,
>ir_dereference_variable *return_deref,
>exec_list *actual_parameters)
>: ir_instruction(ir_type_call), return_deref(return_deref), 
> callee(callee), sub_var(NULL), array_idx(NULL)
> {
>assert(callee->return_type != NULL);
>actual_parameters->move_nodes_to(& this->actual_parameters);
> -  this->use_builtin = callee->is_builtin();
> }
>
> ir_call(ir_function_signature *callee,
>ir_dereference_variable *return_deref,
>exec_list *actual_parameters,
>ir_variable *var, ir_rvalue *array_idx)
>: ir_instruction(ir_type_call), return_deref(return_deref), 
> callee(callee), sub_var(var), array_idx(array_idx)
> {
>assert(callee->return_type != NULL);
>actual_parameters->move_nodes_to(& this->actual_parameters);
> -  this->use_builtin = callee->is_builtin();
> }
>
> virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const;
>
> virtual ir_constant *constant_expression_value(struct hash_table 
> *variable_context = NULL);
>
> virtual void accept(ir_visitor *v)
> {
>v->visit(this);
> }
> @@ -1648,23 +1646,20 @@ public:
> ir_dereference_variable *return_deref;
>
> /**
>  * The specific function signature being called.
>  */
> ir_function_signature *callee;
>
> /* List of ir_rvalue of paramaters passed in this call. */
> exec_list actual_parameters;
>
> -   /** Should this call only bind to a built-in function? */
> -   bool use_builtin;
> -
> /*
>  * ARB_shader_subroutine support -
>  * the subroutine uniform variable and array index
>  * rvalue to be used in the lowering pass later.
>  */
> ir_variable *sub_var;
> ir_rvalue *array_idx;
>  };
>
>
> --
> 2.13.3
>
> ___
> 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 3/3] glsl: stop cloning builtin fuctions _mesa_glsl_find_builtin_function()

2017-08-04 Thread Thomas Helland
2017-08-04 7:25 GMT+00:00 Timothy Arceri :
> The cloning was introduced in f81ede469910d to fixed a problem with
> shaders including IR that was owned by builtins.
>
> However the approach of cloning the whole function each time we
> reference a builtin lead to a significant reduction in the GLSL
> IR compilers performance.
>
> The previous patch fixes the ownership problem in a more precise
> way. So we can now remove this cloning.
>
> Testing on a Ryzan 7 1800X shows a ~15% decreases in compiling the
> Deus Ex: Mankind Divided shaders on radeonsi (which take 5min+ on
> some machines). Looking just at the GLSL IR compiler the speed up
> is ~40%.
>

While I haven't looked at patch 2 closely enough to give you an RB,
these performance numbers seem quite in line with what I observed
when profiling this back in June. Nice one =)

> Cc: Kenneth Graunke 
> Cc: Lionel Landwerlin 
> ---
>  src/compiler/glsl/builtin_functions.cpp | 11 +--
>  1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/src/compiler/glsl/builtin_functions.cpp 
> b/src/compiler/glsl/builtin_functions.cpp
> index 84833bdd7d..1393087cc6 100644
> --- a/src/compiler/glsl/builtin_functions.cpp
> +++ b/src/compiler/glsl/builtin_functions.cpp
> @@ -6207,30 +6207,21 @@ _mesa_glsl_release_builtin_functions()
>
>  ir_function_signature *
>  _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
>   const char *name, exec_list 
> *actual_parameters)
>  {
> ir_function_signature *s;
> mtx_lock(&builtins_lock);
> s = builtins.find(state, name, actual_parameters);
> mtx_unlock(&builtins_lock);
>
> -   if (s == NULL)
> -  return NULL;
> -
> -   struct hash_table *ht =
> -  _mesa_hash_table_create(NULL, _mesa_hash_pointer, 
> _mesa_key_pointer_equal);
> -   void *mem_ctx = state;
> -   ir_function *f = s->function()->clone(mem_ctx, ht);
> -   _mesa_hash_table_destroy(ht, NULL);
> -
> -   return f->matching_signature(state, actual_parameters, true);
> +   return s;
>  }
>
>  bool
>  _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, const char 
> *name)
>  {
> ir_function *f;
> bool ret = false;
> mtx_lock(&builtins_lock);
> f = builtins.shader->symbols->get_function(name);
> if (f != NULL) {
> --
> 2.13.3
>
> ___
> 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 6/6] radeonsi: try to re-use previously deleted bindless descriptor slots

2017-08-04 Thread Marek Olšák
On Fri, Aug 4, 2017 at 10:52 AM, Samuel Pitoiset
 wrote:
>
>
> On 08/04/2017 10:33 AM, Marek Olšák wrote:
>>
>> On Fri, Aug 4, 2017 at 10:06 AM, Samuel Pitoiset
>>  wrote:
>>>
>>>
>>>
>>> On 08/01/2017 09:54 PM, Marek Olšák wrote:


 Hi Samuel,

 Can you move this slot allocator into a util module? It seems generic
 enough that it could be reused for "handle" and "ID" allocations.

 Some additional notes:
 - a bit array of uin32_t would be better. bool is too large (1 byte).
 - "free" is the inverse of "used", so the "used" array is redundant.
>>>
>>>
>>>
>>> Yeah, but we have to keep track of two different arrays. When a texture
>>> handle is destroyed, the ID can be re-used but not right now, because the
>>> GPU can still use the descriptor.
>>
>>
>> Not true. You can reuse all freed slots immediately if you re-upload
>> the whole array instead of using WRITE_DATA.
>
>
> Well, this is true, but re-uploading the whole array is costly...

Right. I don't know the the cost of the uploading.

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


Re: [Mesa-dev] GALLIUM_HUD issue with Android

2017-08-04 Thread Rob Clark
afaict this is more or less the case w/ android.. top/bottom bar,
search bar, wallpaper, etc, are all pushed to surface-flinger as
separate "windows"..

Try "adb shell dumpsys SurfaceFlinger" with an android device.  (I'm
not 100% sure if you need root to do that.)

And with android forking everything (or at least nearly everything)
from zygote process, I'm not entirely sure how target environment
variables to specific processes. :-/

BR,
-R

On Thu, Aug 3, 2017 at 6:24 PM, Marek Olšák  wrote:
> Hi Chris,
>
> The HUD is drawn inside SwapBuffers. It shouldn't be in every widget
> unless every widget is a separate double-buffered GL window.
>
> Marek
>
>
> On Thu, Aug 3, 2017 at 6:50 PM, Chris Healy  wrote:
>> Running Android on top of Mesa has exposed an issue with the
>> GALLIUM_HUD where we get the HUD graphs rendered to each of the
>> surfaces that Android is working with, so there is one with the top
>> bar, one with the bottom bar, one with the main surface, and even one
>> with popups.
>>
>> I'm looking to get some insight into how best to address this issue
>> with the HUD code when working on Android systems as the HUD is still
>> quite useful when running Android.
>> ___
>> 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 mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a sync fence for Android OS

2017-08-04 Thread Emil Velikov
On 3 August 2017 at 17:55, Marathe, Yogesh  wrote:
> Adding folks who were CCed for earlier versions.
>
> Hi Emil, few doubts and comments below.
>
>> -Original Message-
>> From: Tomasz Figa [mailto:tf...@chromium.org]
>> Sent: Thursday, August 3, 2017 7:19 PM
>> To: Marathe, Yogesh 
>> Cc: Emil Velikov ; Antognolli, Rafael
>> ; ML mesa-dev > d...@lists.freedesktop.org>; Wu, Zhongmin 
>> Subject: Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a sync 
>> fence
>> for Android OS
>>
>> On Thu, Aug 3, 2017 at 10:11 PM, Marathe, Yogesh
>>  wrote:
>> > Emil,
>> >
>> >> -Original Message-
>> >> From: Emil Velikov [mailto:emil.l.veli...@gmail.com]
>> >> Sent: Thursday, August 3, 2017 4:06 PM
>> >> To: Marathe, Yogesh 
>> >> Cc: ML mesa-dev ; Wu, Zhongmin
>> >> 
>> >> Subject: Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a
>> >> sync fence for Android OS
>> >>
>> >> On 2 August 2017 at 20:01,   wrote:
>> >> > From: Zhongmin Wu 
>> >> >
>> >> > Before we queued the buffer with a invalid fence (-1), it causes
>> >> > benchmarks such as flatland to fail. This patch enables explicit
>> >> > sync feature on android.
>> >> >
>> >> > Now we get the out fence during the flushing buffer and then pass
>> >> > it to SurfaceFlinger in eglSwapbuffer function.
>> >> >
>> >> > v2: a) Also implement the fence in cancelBuffer.
>> >> > b) The last sync fence is stored in drawable object
>> >> >rather than brw context.
>> >> > c) format clear.
>> >> >
>> >> > v3: a) Save the last fence fd in DRI Context object.
>> >> > b) Return the last fence if the batch buffer is empty and
>> >> >nothing to be flushed when _intel_batchbuffer_flush_fence
>> >> > c) Add the new interface in vbtl to set the retrieve fence
>> >> >
>> >> > v3.1 a) close fd in the new vbtl interface on none Android platform
>> >> >
>> >> > v4: a) The last fence is saved in brw context.
>> >> > b) The retrieve fd is for all the platform but not just Android
>> >> > c) Add a uniform dri2 interface to initialize the surface.
>> >> >
>> >> > v4.1: a) make some changes of variable name.
>> >> >   b) the patch is broken into two patches.
>> >> >
>> >> > v4.2: a) Add a deinit interface for surface to clear the out fence
>> >> >
>> >> > v5: a) Add enable_out_fence to init, platform sets it true or
>> >> >false
>> >> > b) Change get fd to update fd and check for fence
>> >> > c) Commit description updated
>> >> >
>> >> Seems like most suggestions in last version did not get addressed.
>> >> Please comment if you disagree (it can be that we've
>> >> misread/misremember
>> >> something) before posting another version.
>> >>
>> >> To reiterate:
>> >>  - add blank line between variable declarations and code
>
> Done.
>
>> >>  - use more consistent function names
>
> Do you want any specific functioned to be renamed?
>
s/dri2_surf_init/dri2_init_surface/
s/dri2_surf_deinit/dri2_fini_surface/
s/dri2_surface_set_out_fence/dri2_surface_set_out_fence_fd/


>> >>  - comment above queueBuffer needs fixing
>
> It reads as below now.
>/* Queue the buffer with stored out fence fd. The ANativeWindow or buffer
> * consumer may choose to wait for the fence to signal before accessing
> * it. If fence fd value is -1, buffer can be accessed by consumer
> * immediately. Consumer or application shouldn't rely on timestamp
> * associated with fence if the fence fd is -1.
> *
> * Ownership of fd is transferred to consumer after queueBuffer and the
> * consumer is responsible for closing it. Caller must not use the fd
> * after passing it to queueBuffer.
> */
>
> Looks ok?
>
A lot better than I was thinking.

>> >>  - version check (2+) the fence extension, calling .create_fence_fd()
>> >> only when
>> >> .get_capabilities() advertises __DRI_FENCE_CAP_NATIVE_FD
>
> The check looks like below now, this is in dri2_surf_update_fence_fd() before 
> create_fence_fd is called.
>
> if (dri2_surf->enable_out_fence && dri2_dpy->fence) {
>if(__DRI_FENCE_CAP_NATIVE_FD | 
> dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen)) {
>   //create_fence_fd call
>}
> }
>
Close but no cigar.

if (dri2_surf->enable_out_fence && dri2_dpy->fence &&
dri2_dpy->fence->base.version >= 2 && dri2_dpy->fence->get_capabilities) {

   if (dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen) &
__DRI_FENCE_CAP_NATIVE_FD) {
//create_fence_fd call
   }
}

> Overall, if I further go ahead and check, actually get_capabilities() 
> ultimately returns based on
> has_exec_fence which depends on  I915_PARAM_HAS_EXEC_FENCE. This is always 
> set to
> true for i915 in kernel drv unless forced to false!! I'm not sure if that 
> inner check of get_capabilities
> still makes sense. Isn't the first one sufficient?
>
Not sure what you mean with "first one", but consider the following example:
 - old kernel which does not support (or has force disabled)
I915_PARAM_HAS_EXEC_

Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a sync fence for Android OS

2017-08-04 Thread Emil Velikov
On 4 August 2017 at 04:21, Marathe, Yogesh  wrote:

>> > The check looks like below now, this is in dri2_surf_update_fence_fd() 
>> > before
>> create_fence_fd is called.
>> >
>> > if (dri2_surf->enable_out_fence && dri2_dpy->fence) {
>> >if(__DRI_FENCE_CAP_NATIVE_FD |
>> > dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen)) {
>>
>> This doesn't make any sense, because non-zero OR whatever is always true. Did
>> you by any chance meant to use AND instead? Also please just extend the
>> condition of the first if, instead of nesting another under it for no reason.
>>
>
> Right. It must be '&', thanks for pointing out.
>
> On the nesting, I want to check dri2_dpy->fence is valid first before 
> dri2_dpy->fence->(anything())
> can be called, so I believe that nesting can still be there. Rafael had that 
> review comment.
> Do you still want to combine conditions in a single 'if'?
>
In my example (just a second ago) I've kept the conditionals separate
since they're quite large.
Squashing them in a single if () block is fine with me.

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


Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a sync fence for Android OS

2017-08-04 Thread Tomasz Figa
On Fri, Aug 4, 2017 at 12:21 PM, Marathe, Yogesh
 wrote:
>> >> >>  - version check (2+) the fence extension, calling
>> >> >> .create_fence_fd() only when
>> >> >> .get_capabilities() advertises __DRI_FENCE_CAP_NATIVE_FD
>> >
>> > The check looks like below now, this is in dri2_surf_update_fence_fd() 
>> > before
>> create_fence_fd is called.
>> >
>> > if (dri2_surf->enable_out_fence && dri2_dpy->fence) {
>> >if(__DRI_FENCE_CAP_NATIVE_FD |
>> > dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen)) {
>>
>> This doesn't make any sense, because non-zero OR whatever is always true. Did
>> you by any chance meant to use AND instead? Also please just extend the
>> condition of the first if, instead of nesting another under it for no reason.
>>
>
> Right. It must be '&', thanks for pointing out.
>
> On the nesting, I want to check dri2_dpy->fence is valid first before 
> dri2_dpy->fence->(anything())
> can be called, so I believe that nesting can still be there. Rafael had that 
> review comment.
> Do you still want to combine conditions in a single 'if'?

I'm not sure what's the problem with single if. The order of
evaluating conditions is strictly defined by C standard.

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


Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a sync fence for Android OS

2017-08-04 Thread Tomasz Figa
On Fri, Aug 4, 2017 at 9:55 PM, Emil Velikov  wrote:
>>> >>  - version check (2+) the fence extension, calling .create_fence_fd()
>>> >> only when
>>> >> .get_capabilities() advertises __DRI_FENCE_CAP_NATIVE_FD
>>
>> The check looks like below now, this is in dri2_surf_update_fence_fd() 
>> before create_fence_fd is called.
>>
>> if (dri2_surf->enable_out_fence && dri2_dpy->fence) {
>>if(__DRI_FENCE_CAP_NATIVE_FD | 
>> dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen)) {
>>   //create_fence_fd call
>>}
>> }
>>
> Close but no cigar.
>
> if (dri2_surf->enable_out_fence && dri2_dpy->fence &&
> dri2_dpy->fence->base.version >= 2 && dri2_dpy->fence->get_capabilities) {
>
>if (dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen) &
> __DRI_FENCE_CAP_NATIVE_FD) {
> //create_fence_fd call
>}
> }

If this needs so complicated series of checks, maybe it would make
more sense to just set enable_out_fence based on availability of the
capability at initialization time?

>
>> Overall, if I further go ahead and check, actually get_capabilities() 
>> ultimately returns based on
>> has_exec_fence which depends on  I915_PARAM_HAS_EXEC_FENCE. This is always 
>> set to
>> true for i915 in kernel drv unless forced to false!! I'm not sure if that 
>> inner check of get_capabilities
>> still makes sense. Isn't the first one sufficient?
>>
> Not sure what you mean with "first one", but consider the following example:
>  - old kernel which does not support (or has force disabled)
> I915_PARAM_HAS_EXEC_FENCE.
>  - new userspace which unconditionally advertises the fence v2 extension
> IIRC one may tweak that things to only conditionally advertise it, but
> IMHO it's not worth the hassle.
>
> Even then, Mesa can produce 20 DRI drivers (used by the EGL module) so
> focusing on one doesn't quite work.
>
>>> >>  - don't introduce unused variables (in make_current)
>>
>> Done.
>>
>>> >>  - the create fd for the old display surface (in make_current) seems
>>> >> bogus
>>
>> Done.
>>
> Did you drop it all together or changed to use some other surface?
> Would be nice to hear the reason why it was added - perhaps I'm
> missing something.

We have to keep it, otherwise there would be no fence available at the
time of surface destruction, while, at least for Android, a fence can
be passed to window's cancelBuffer callback.

>
> I think that we want a fence/fd for the new draw surface. Since
> otherwise one won't get created up until the first SwapBuffers call.

I might be missing something, but wouldn't that insert a fence at the
beginning of command stream, before even doing anything? At least in
Android use cases, the only places we need the fence is in SwapBuffers
and DestroySurface and the fence should be inserted after all the
commands for rendering into given surface.

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


Re: [Mesa-dev] [PATCH 1/3] android: radeonsi: add nir include paths

2017-08-04 Thread Mauro Rossi
2017-08-03 20:50 GMT+02:00 Rob Herring :
> On Thu, Aug 3, 2017 at 11:12 AM, Mauro Rossi  wrote:
>> 2017-08-03 16:52 GMT+02:00 Emil Velikov :
>>> On 3 August 2017 at 13:24, Mauro Rossi  wrote:
 2017-08-03 11:57 GMT+02:00 Emil Velikov :
> Hi Mauro,
>
> Thanks for the series. I'll pull 2&3 in a second - there's a minor
> suggestion in this patch.
>
> On 3 August 2017 at 01:55, Mauro Rossi  wrote:
>> Android build changes to avoid the following building error:
>>
>> target  C: libmesa_pipe_radeonsi <= 
>> external/mesa/src/gallium/drivers/radeonsi/si_pipe.c
>> ...
>> In file included from 
>> external/mesa/src/gallium/drivers/radeonsi/si_pipe.c:38:
>> external/mesa/src/compiler/nir/nir.h:48:10: fatal error: 'nir_opcodes.h' 
>> file not found
>> #include "nir_opcodes.h"
>>  ^
>> 1 error generated.
>>
>> Fixes: da62a31c5b "radeonsi: add nir include paths"
>> ---
>>  src/gallium/drivers/radeonsi/Android.mk | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/drivers/radeonsi/Android.mk 
>> b/src/gallium/drivers/radeonsi/Android.mk
>> index 6fff91f6f7..452bba3af8 100644
>> --- a/src/gallium/drivers/radeonsi/Android.mk
>> +++ b/src/gallium/drivers/radeonsi/Android.mk
>> @@ -36,7 +36,8 @@ LOCAL_MODULE_CLASS := STATIC_LIBRARIES
>>
>>  LOCAL_C_INCLUDES := \
>> $(MESA_TOP)/src/amd/common \
>> -   $(call 
>> generated-sources-dir-for,STATIC_LIBRARIES,libmesa_amd_common,,)/common
>> +   $(call 
>> generated-sources-dir-for,STATIC_LIBRARIES,libmesa_amd_common,,)/common \
>> +   $(call 
>> generated-sources-dir-for,STATIC_LIBRARIES,libmesa_nir,,)/nir
> The more robust solution is to add LOCAL_EXPORT_C_INCLUDE_DIRS for 
> libmesa_nir.
>
> With that in place we can drop the existing four instances of the
> $(call generated-sources-dir-for... libmesa_nir... from the codebase.
>
> -Emil

 The current patch proposed is in principle already robust and mimiking
 automake, but if you prefer other way, I would propose doing this:

  LOCAL_C_INCLUDES := \
 -   $(call 
 generated-sources-dir-for,STATIC_LIBRARIES,libmesa_amd_common,,)/common
 +   $(call 
 generated-sources-dir-for,STATIC_LIBRARIES,libmesa_amd_common,,)/common
 \
 +   $(dir $(MESA_GEN_NIR_H))

 because LOCAL_EXPORT_C_INCLUDE_DIRS in Android.nir.mk would then
 require static linking of libmesa_nir and we would get double symbols
 at whole static linking in gallium_dri target due the current
 dri/target building rules.
>
> Can't you link against the libmesa_nir (i.e. add to
> LOCAL_STATIC_LIBRARIES) and not add it to GALLIUM_LIBS?

As we speak GALLIUM_LIBS adds LOCAL_STATIC_LIBRARIES,
so a different approach would be required.

>

>>> Was under the impression that there'll be symbol problems if both
>>> places use WHOLE_STATIC.
>>
>> The issue would happen if libmesa_nir added to GALLIUM_LIBS in
>> gallium/drivers/radeonsi/Android.mk, after Rob Herring simplifications
>> to driver building rules and then libmesa_nir being listed twice in
>> WHOLE_STATIC in gallium/targets/dri/Android.mk
>
> The fix is to either simply sort the whole
> LOCAL_WHOLE_STATIC_LIBRARIES (not just GALLIUM_LIBS) or push the
> libmesa_nir inclusion into the drivers that need it. The latter is the
> better fix IMO. Probably the same thing should be done for
> libmesa_glsl and libmesa_compiler. Additionally, the need for the rest
> of the libs (not in GALLIUM_LIBS) could be moved to
> LOCAL_STATIC_LIBRARIES.
>
> Rob

We can do it with further patch,
I would suggest to continue as Emil said to un-break the build,
with macro that are anyway canonic for Android.

Then we can have (afterwards) a look on the options:

- LOCAL_EXPORT_C_INCLUDE_DIRS in libmesa_nir
- or add  $(dir $(MESA_GEN_NIR_H)) in LOCAL_C_INCLUDES as done for
MESA_GEN_GLSL_H.
- or add LOCAL_GENERATED_SOURCES += MESA_GEN_NIR_H as done in other places

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


Re: [Mesa-dev] [PATCH 08/12] egl: handle BAD_NATIVE_WINDOW/PIXMAP further up the stack

2017-08-04 Thread Emil Velikov
On 4 August 2017 at 11:38, Eric Engestrom  wrote:
> On Thursday, 2017-08-03 19:29:34 +0100, Emil Velikov wrote:
>> From: Emil Velikov 
>>
>> The basic (null) check is identical across all backends.
>> Just move it to the top.
>>
>> Note that eglCreateWindowSurface* already has a guard in the *Common
>> helper.
>
> Read the code, checked that, was going to comment then saw the commit msg ^^
> Anyway, I'd do 2 commits here: move x11's !pixmap check, then drop the
> redundant !window checks separately.
>
As I make [non trivial[ unrelated changes, I make sure they're documented ;-)
Dully noted - spit will be the better route.

>>
>> Cc: Eric Engestrom 
>> Signed-off-by: Emil Velikov 
>> ---
>> Eric, the X11 hunk was changed/introduced by Frank with commit
>> 2900e8ca9077d20c5b29bb5a4171ac59ea9d1767
>
> You could have Cc'ed him directly :P
>
>>
>> If you guys had a usecase that hit the path, can you please check this
>> commit does not break it.
>
> Digging through our logs, the issue was highlighted by one (or more) of:
> dEQP-EGL.functional.create_surface.pbuffer.*
> dEQP-EGL.functional.image.api.*
> dEQP-EGL.functional.image.create.*
> dEQP-EGL.functional.image.modify.*
> dEQP-EGL.functional.image.render_multiple_contexts.*
> dEQP-EGL.functional.negative_api.*
>
> If these pass for pixmaps with your patch then it should be fine :)
>
The Intel CI threw a fail on the negative_api test, which
interestingly enough ... also fails on 17.1.x
Updating dEQP drops the problematic test, so I'm a bit split.

Will give it a closer look.
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallium/clover: Remove libxmlconfig.la from targets/clover/Makefile.am

2017-08-04 Thread Emil Velikov
On 4 August 2017 at 11:36, Dieter Nützel  wrote:
> Am 04.08.2017 11:08, schrieb Nicolai Hähnle:
>>
>> On 04.08.2017 10:27, Nicolai Hähnle wrote:
>>>
>>> On 04.08.2017 06:24, Aaron Watry wrote:

 Gets rid of a bunch of errors like the following:

 make[4]: Entering directory
 '/home/me/src/mesa/build/src/gallium/targets/opencl'
CXXLDlibOpenCL.la
 ../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
 In function `driParseOptionInfo':
 /home/me/src/mesa/src/util/xmlconfig.c:719: multiple definition of
 `driParseOptionInfo'

 ../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:719:
 first defined here
 ../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
 In function `driParseConfigFiles':
 /home/me/src/mesa/src/util/xmlconfig.c:990: multiple definition of
 `driParseConfigFiles'

 ../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:990:
 first defined here

 Fixes: 33f7d71d5358337f ("pipe-loader: fix build of dynamic
 pipe-drivers")
 Cc: Nicolai Hähnle 
 Cc: Emil Velikov 
 ---
   src/gallium/targets/opencl/Makefile.am | 1 -
   1 file changed, 1 deletion(-)

 diff --git a/src/gallium/targets/opencl/Makefile.am
 b/src/gallium/targets/opencl/Makefile.am
 index e88fa0fd38..c9d2be7afd 100644
 --- a/src/gallium/targets/opencl/Makefile.am
 +++ b/src/gallium/targets/opencl/Makefile.am
 @@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
   $(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
   $(top_builddir)/src/gallium/auxiliary/libgallium.la \
   $(top_builddir)/src/util/libmesautil.la \
 -$(top_builddir)/src/util/libxmlconfig.la \
>>>
>>>
>>> So, this is weird because I added this line to make one of the Travis CI
>>> builds pass. What are your ./configure options?
>>
>>
>> Okay, so the difference is HAVE_CLOVER_ICD. Apparently there's no
>> Travis CI build with that set to false. We need to figure out a way to
>> make both options happy.
>>
>> Cheers,
>> Nicolai
>
>
> This is the same for me (like I posted with my latest Tested-by: for
> you)...;-)
>
> ./autogen.sh --prefix=/usr/local --with-dri-drivers=""
> --with-gallium-drivers=r600,radeonsi,swrast --with-platforms=drm,x11
> --enable-nine --enable-texture-float --enable-opencl
> --with-vulkan-drivers=radeon
>
> With OpenCL.
>
> So this is
>
> Tested-by: Dieter Nützel 
>
I'm not too sure that this is the right solution.
If I'm reading things correctly this will cause a break if one toggles
dri --disable-dri.

AFAICT the thing that gets us is the transient inclusion of
xmlconfig.la in loader.la.

I'm testing some patches to untangling this properly.

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


Re: [Mesa-dev] [PATCH] gallium/clover: Remove libxmlconfig.la from targets/clover/Makefile.am

2017-08-04 Thread Dieter Nützel

Am 04.08.2017 16:02, schrieb Emil Velikov:

On 4 August 2017 at 11:36, Dieter Nützel  wrote:

Am 04.08.2017 11:08, schrieb Nicolai Hähnle:


On 04.08.2017 10:27, Nicolai Hähnle wrote:


On 04.08.2017 06:24, Aaron Watry wrote:


Gets rid of a bunch of errors like the following:

make[4]: Entering directory
'/home/me/src/mesa/build/src/gallium/targets/opencl'
   CXXLDlibOpenCL.la
../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
In function `driParseOptionInfo':
/home/me/src/mesa/src/util/xmlconfig.c:719: multiple definition of
`driParseOptionInfo'

../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:719:
first defined here
../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
In function `driParseConfigFiles':
/home/me/src/mesa/src/util/xmlconfig.c:990: multiple definition of
`driParseConfigFiles'

../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:990:
first defined here

Fixes: 33f7d71d5358337f ("pipe-loader: fix build of dynamic
pipe-drivers")
Cc: Nicolai Hähnle 
Cc: Emil Velikov 
---
  src/gallium/targets/opencl/Makefile.am | 1 -
  1 file changed, 1 deletion(-)

diff --git a/src/gallium/targets/opencl/Makefile.am
b/src/gallium/targets/opencl/Makefile.am
index e88fa0fd38..c9d2be7afd 100644
--- a/src/gallium/targets/opencl/Makefile.am
+++ b/src/gallium/targets/opencl/Makefile.am
@@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
  
$(top_builddir)/src/gallium/state_trackers/clover/libclover.la \

  $(top_builddir)/src/gallium/auxiliary/libgallium.la \
  $(top_builddir)/src/util/libmesautil.la \
-$(top_builddir)/src/util/libxmlconfig.la \



So, this is weird because I added this line to make one of the 
Travis CI

builds pass. What are your ./configure options?



Okay, so the difference is HAVE_CLOVER_ICD. Apparently there's no
Travis CI build with that set to false. We need to figure out a way 
to

make both options happy.

Cheers,
Nicolai



This is the same for me (like I posted with my latest Tested-by: for
you)...;-)

./autogen.sh --prefix=/usr/local --with-dri-drivers=""
--with-gallium-drivers=r600,radeonsi,swrast --with-platforms=drm,x11
--enable-nine --enable-texture-float --enable-opencl
--with-vulkan-drivers=radeon

With OpenCL.

So this is

Tested-by: Dieter Nützel 


I'm not too sure that this is the right solution.
If I'm reading things correctly this will cause a break if one toggles
dri --disable-dri.

AFAICT the thing that gets us is the transient inclusion of
xmlconfig.la in loader.la.

I'm testing some patches to untangling this properly.

-Emil


Hi Emil,

while your at it, is Nicolai's other approach the right/better way, 
then?


[Mesa-dev] [PATCH] loader: always include libxmlconfig on autotools 
build

https://lists.freedesktop.org/archives/mesa-dev/2017-August/165482.html

I'm compiling it during this write...

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


Re: [Mesa-dev] [PATCH v4] glsl: update the extensions that are enabled for 460

2017-08-04 Thread Ilia Mirkin
On Aug 4, 2017 02:02, "Samuel Pitoiset"  wrote:



On 08/03/2017 07:36 PM, Ilia Mirkin wrote:

> On Thu, Aug 3, 2017 at 5:24 AM, Samuel Pitoiset
>  wrote:
>
>> Other ones are either unsupported or don't have any helper
>> function checks.
>>
>> v4: - drop ARB suffix for shader_group_vote/arb_shader_atomic_counter_ops
>> v3: - always add gl_BaseVertex & co when 460 is enabled
>> v2: - fix ARB_shader_draw_parameters system value names
>>
>> Signed-off-by: Samuel Pitoiset 
>> ---
>>   src/compiler/glsl/builtin_functions.cpp | 81
>> +
>>   src/compiler/glsl/builtin_variables.cpp |  5 ++
>>   2 files changed, 78 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/compiler/glsl/builtin_functions.cpp
>> b/src/compiler/glsl/builtin_functions.cpp
>> index 84833bdd7d..bbb60b4e64 100644
>> --- a/src/compiler/glsl/builtin_functions.cpp
>> +++ b/src/compiler/glsl/builtin_functions.cpp
>> @@ -151,6 +151,12 @@ v130_desktop(const _mesa_glsl_parse_state *state)
>>   }
>>
>>   static bool
>> +v460_desktop(const _mesa_glsl_parse_state *state)
>> +{
>> +   return state->is_version(460, 0);
>> +}
>> +
>> +static bool
>>   v130_fs_only(const _mesa_glsl_parse_state *state)
>>   {
>>  return state->is_version(130, 300) &&
>> @@ -483,7 +489,7 @@ shader_atomic_counters(const _mesa_glsl_parse_state
>> *state)
>>   static bool
>>   shader_atomic_counter_ops(const _mesa_glsl_parse_state *state)
>>   {
>> -   return state->ARB_shader_atomic_counter_ops_enable;
>> +   return v460_desktop(state) || state->ARB_shader_atomic_count
>> er_ops_enable;
>>   }
>>
>>   static bool
>> @@ -606,7 +612,7 @@ barrier_supported(const _mesa_glsl_parse_state *state)
>>   static bool
>>   vote(const _mesa_glsl_parse_state *state)
>>   {
>> -   return state->ARB_shader_group_vote_enable;
>> +   return v460_desktop(state) || state->ARB_shader_group_vote_enable;
>>   }
>>
>>   static bool
>> @@ -962,7 +968,8 @@ private:
>>
>>  ir_function_signature *_vote_intrinsic(builtin_available_predicate
>> avail,
>> enum ir_intrinsic_id id);
>> -   ir_function_signature *_vote(const char *intrinsic_name);
>> +   ir_function_signature *_vote(const char *intrinsic_name,
>> +builtin_available_predicate avail);
>>
>>   #undef B0
>>   #undef B1
>> @@ -3031,6 +3038,43 @@ builtin_builder::create_builtins()
>>   shader_atomic_counter_ops),
>>   NULL);
>>
>> +   add_function("atomicCounterAdd",
>> +_atomic_counter_op1("__intrinsic_atomic_add",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterSubtract",
>> +_atomic_counter_op1("__intrinsic_atomic_sub",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterMin",
>> +_atomic_counter_op1("__intrinsic_atomic_min",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterMax",
>> +_atomic_counter_op1("__intrinsic_atomic_max",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterAnd",
>> +_atomic_counter_op1("__intrinsic_atomic_and",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterOr",
>> +_atomic_counter_op1("__intrinsic_atomic_or",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterXor",
>> +_atomic_counter_op1("__intrinsic_atomic_xor",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterExchange",
>> +_atomic_counter_op1("__intrinsic_atomic_exchange",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterCompSwap",
>> +_atomic_counter_op2("__intrinsic_atomic_comp_swap",
>> +v460_desktop),
>> +NULL);
>> +
>>
>
> So all of these reference the __intrinsic_atomic_max functions. Do
> those ned to be fixed up too? Specifically,
>
> add_function("__intrinsic_atomic_max",
>  _atomic_intrinsic2(buffer_atomics_supported,
> glsl_type::uint_type,
> ir_intrinsic_generic_atomic_max),
>  _atomic_intrinsic2(buffer_atomics_supported,
> glsl_type::int_type,
> ir_intrinsic_generic_atomic_max),
>  _atomic_counter_intrinsic1(shader_atomic_counter_ops,
> ir_intrinsic_atomic_counter_ma
> x),
>  NULL);
>
> I believe the latter one needs to have i

Re: [Mesa-dev] [PATCH] gallium/clover: Remove libxmlconfig.la from targets/clover/Makefile.am

2017-08-04 Thread Jan Vesely
On Fri, 2017-08-04 at 15:02 +0100, Emil Velikov wrote:
> On 4 August 2017 at 11:36, Dieter Nützel  wrote:
> > Am 04.08.2017 11:08, schrieb Nicolai Hähnle:
> > > 
> > > On 04.08.2017 10:27, Nicolai Hähnle wrote:
> > > > 
> > > > On 04.08.2017 06:24, Aaron Watry wrote:
> > > > > 
> > > > > Gets rid of a bunch of errors like the following:
> > > > > 
> > > > > make[4]: Entering directory
> > > > > '/home/me/src/mesa/build/src/gallium/targets/opencl'
> > > > >CXXLDlibOpenCL.la
> > > > > ../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
> > > > > In function `driParseOptionInfo':
> > > > > /home/me/src/mesa/src/util/xmlconfig.c:719: multiple definition of
> > > > > `driParseOptionInfo'
> > > > > 
> > > > > ../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:719:
> > > > > first defined here
> > > > > ../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
> > > > > In function `driParseConfigFiles':
> > > > > /home/me/src/mesa/src/util/xmlconfig.c:990: multiple definition of
> > > > > `driParseConfigFiles'
> > > > > 
> > > > > ../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:990:
> > > > > first defined here
> > > > > 
> > > > > Fixes: 33f7d71d5358337f ("pipe-loader: fix build of dynamic
> > > > > pipe-drivers")
> > > > > Cc: Nicolai Hähnle 
> > > > > Cc: Emil Velikov 
> > > > > ---
> > > > >   src/gallium/targets/opencl/Makefile.am | 1 -
> > > > >   1 file changed, 1 deletion(-)
> > > > > 
> > > > > diff --git a/src/gallium/targets/opencl/Makefile.am
> > > > > b/src/gallium/targets/opencl/Makefile.am
> > > > > index e88fa0fd38..c9d2be7afd 100644
> > > > > --- a/src/gallium/targets/opencl/Makefile.am
> > > > > +++ b/src/gallium/targets/opencl/Makefile.am
> > > > > @@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
> > > > >   $(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
> > > > >   $(top_builddir)/src/gallium/auxiliary/libgallium.la \
> > > > >   $(top_builddir)/src/util/libmesautil.la \
> > > > > -$(top_builddir)/src/util/libxmlconfig.la \
> > > > 
> > > > 
> > > > So, this is weird because I added this line to make one of the Travis CI
> > > > builds pass. What are your ./configure options?
> > > 
> > > 
> > > Okay, so the difference is HAVE_CLOVER_ICD. Apparently there's no
> > > Travis CI build with that set to false. We need to figure out a way to
> > > make both options happy.

I don't think that's the case, I use --enable-opencl_icd and I still
need to remove that line to fix the build.

> > > 
> > > Cheers,
> > > Nicolai
> > 
> > 
> > This is the same for me (like I posted with my latest Tested-by: for
> > you)...;-)
> > 
> > ./autogen.sh --prefix=/usr/local --with-dri-drivers=""
> > --with-gallium-drivers=r600,radeonsi,swrast --with-platforms=drm,x11
> > --enable-nine --enable-texture-float --enable-opencl
> > --with-vulkan-drivers=radeon
> > 
> > With OpenCL.
> > 
> > So this is
> > 
> > Tested-by: Dieter Nützel 
> > 
> 
> I'm not too sure that this is the right solution.
> If I'm reading things correctly this will cause a break if one toggles
> dri --disable-dri.

does it need to depend on HAVE_DRICOMMON? can't we just unconditionally
add libxmlconfig.la?

Jan

> 
> AFAICT the thing that gets us is the transient inclusion of
> xmlconfig.la in loader.la.
> 
> I'm testing some patches to untangling this properly.
> 
> -Emil
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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 6/7] radeonsi: use optimal packet order when doing a pipeline sync

2017-08-04 Thread Marek Olšák
There is an ugly bug here: prefetches are skipped, because
emit_all_states clears all dirty bits. Expect v2...

Marek

On Fri, Aug 4, 2017 at 12:05 PM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> Process new SET packets in parallel with previous draw calls.
>
> This decreases [CP busy / SPI busy] by a very tiny amount (verified with
> GRBM perf counters), and probably increases FPS by a very tiny amount
> for apps that do pipeline syncs often.
> ---
>  src/gallium/drivers/radeonsi/si_state_draw.c | 54 
> 
>  1 file changed, 48 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
> b/src/gallium/drivers/radeonsi/si_state_draw.c
> index ae48115..06a18c1 100644
> --- a/src/gallium/drivers/radeonsi/si_state_draw.c
> +++ b/src/gallium/drivers/radeonsi/si_state_draw.c
> @@ -1173,30 +1173,31 @@ static bool si_cache_flush_and_prefetch(struct 
> si_context *sctx)
>  */
> if (!si_upload_graphics_shader_descriptors(sctx))
> return false;
>
> if (sctx->prefetch_L2)
> cik_emit_prefetch_L2(sctx);
>
> return true;
>  }
>
> -static void si_emit_all_states(struct si_context *sctx, const struct 
> pipe_draw_info *info)
> +static void si_emit_all_states(struct si_context *sctx, const struct 
> pipe_draw_info *info,
> +  unsigned skip_atom_mask)
>  {
> /* Emit state atoms. */
> -   unsigned mask = sctx->dirty_atoms;
> +   unsigned mask = sctx->dirty_atoms & ~skip_atom_mask;
> while (mask) {
> struct r600_atom *atom = sctx->atoms.array[u_bit_scan(&mask)];
>
> atom->emit(&sctx->b, atom);
> }
> -   sctx->dirty_atoms = 0;
> +   sctx->dirty_atoms &= skip_atom_mask;
>
> /* Emit states. */
> mask = sctx->dirty_states;
> while (mask) {
> unsigned i = u_bit_scan(&mask);
> struct si_pm4_state *state = sctx->queued.array[i];
>
> if (!state || sctx->emitted.array[i] == state)
> continue;
>
> @@ -1384,23 +1385,64 @@ void si_draw_vbo(struct pipe_context *ctx, const 
> struct pipe_draw_info *info)
>  */
> if (!si_upload_vertex_buffer_descriptors(sctx))
> return;
>
> /* GFX9 scissor bug workaround. There is also a more efficient but
>  * more involved alternative workaround. */
> if (sctx->b.chip_class == GFX9 &&
> si_is_atom_dirty(sctx, &sctx->b.scissors.atom))
> sctx->b.flags |= SI_CONTEXT_PS_PARTIAL_FLUSH;
>
> -   if (!si_cache_flush_and_prefetch(sctx))
> -   return;
> -   si_emit_all_states(sctx, info);
> +   /* Use an optimal packet order based on whether we need to sync the 
> pipeline. */
> +   if (unlikely(sctx->b.flags & (SI_CONTEXT_FLUSH_AND_INV_CB |
> + SI_CONTEXT_FLUSH_AND_INV_DB |
> + SI_CONTEXT_PS_PARTIAL_FLUSH |
> + SI_CONTEXT_CS_PARTIAL_FLUSH))) {
> +   /* If we have to wait for idle, set all states first, so that 
> all
> +* SET packets are processed in parallel with previous draw 
> calls.
> +* Sequence:
> +* - process SET packets except SET_SH packets for shader 
> pointers
> +* - flush caches and wait for previous draw calls
> +* - start CE dumps (might already be ongoing if there is no 
> CE-DE barrier)
> +* - start prefetches
> +* - process SET_SH packets for shader pointers
> +* - wait for CE dumps
> +* - draw
> +*/
> +   struct r600_atom *shader_pointers = 
> &sctx->shader_userdata.atom;
> +
> +   /* Emit all states except shader pointers. */
> +   si_emit_all_states(sctx, info, 1 << shader_pointers->id);
> +
> +   if (!si_cache_flush_and_prefetch(sctx))
> +   return;
> +
> +   /* Set shader pointers last. */
> +   if (si_is_atom_dirty(sctx, shader_pointers)) {
> +   shader_pointers->emit(&sctx->b, NULL);
> +   sctx->dirty_atoms = 0;
> +   }
> +   } else {
> +   /* If we don't wait for idle, do CE dumps and start prefetches
> +* first, so that they are being done in parallel with all SET
> +* packets. Sequence:
> +* - flush caches
> +* - start CE dumps (might already be ongoing if CE is ahead)
> +* - start prefetches
> +* - process SET packets
> +* - wait for CE dumps
> +* - draw
> +*/
> +   if (!si_cache_flush_and_prefetch(sctx))
> +   return;
> +   si_emit_all_states(

Re: [Mesa-dev] [PATCH] gallium/clover: Remove libxmlconfig.la from targets/clover/Makefile.am

2017-08-04 Thread Dieter Nützel

Am 04.08.2017 16:29, schrieb Jan Vesely:

On Fri, 2017-08-04 at 15:02 +0100, Emil Velikov wrote:

On 4 August 2017 at 11:36, Dieter Nützel  wrote:
> Am 04.08.2017 11:08, schrieb Nicolai Hähnle:
> >
> > On 04.08.2017 10:27, Nicolai Hähnle wrote:
> > >
> > > On 04.08.2017 06:24, Aaron Watry wrote:
> > > >
> > > > Gets rid of a bunch of errors like the following:
> > > >
> > > > make[4]: Entering directory
> > > > '/home/me/src/mesa/build/src/gallium/targets/opencl'
> > > >CXXLDlibOpenCL.la
> > > > ../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
> > > > In function `driParseOptionInfo':
> > > > /home/me/src/mesa/src/util/xmlconfig.c:719: multiple definition of
> > > > `driParseOptionInfo'
> > > >
> > > > 
../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:719:
> > > > first defined here
> > > > ../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
> > > > In function `driParseConfigFiles':
> > > > /home/me/src/mesa/src/util/xmlconfig.c:990: multiple definition of
> > > > `driParseConfigFiles'
> > > >
> > > > 
../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:990:
> > > > first defined here
> > > >
> > > > Fixes: 33f7d71d5358337f ("pipe-loader: fix build of dynamic
> > > > pipe-drivers")
> > > > Cc: Nicolai Hähnle 
> > > > Cc: Emil Velikov 
> > > > ---
> > > >   src/gallium/targets/opencl/Makefile.am | 1 -
> > > >   1 file changed, 1 deletion(-)
> > > >
> > > > diff --git a/src/gallium/targets/opencl/Makefile.am
> > > > b/src/gallium/targets/opencl/Makefile.am
> > > > index e88fa0fd38..c9d2be7afd 100644
> > > > --- a/src/gallium/targets/opencl/Makefile.am
> > > > +++ b/src/gallium/targets/opencl/Makefile.am
> > > > @@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
> > > >   $(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
> > > >   $(top_builddir)/src/gallium/auxiliary/libgallium.la \
> > > >   $(top_builddir)/src/util/libmesautil.la \
> > > > -$(top_builddir)/src/util/libxmlconfig.la \
> > >
> > >
> > > So, this is weird because I added this line to make one of the Travis CI
> > > builds pass. What are your ./configure options?
> >
> >
> > Okay, so the difference is HAVE_CLOVER_ICD. Apparently there's no
> > Travis CI build with that set to false. We need to figure out a way to
> > make both options happy.


I don't think that's the case, I use --enable-opencl_icd and I still
need to remove that line to fix the build.


Me too, even after Emil's latest commits
# 6f9298dbde63049da6f530ba4f4693ba78b01448 and
# 5c007203b73da88b9e76ce28027c6d27661e45b1
with --enable-nine --enable-opencl

Dieter


> >
> > Cheers,
> > Nicolai
>
>
> This is the same for me (like I posted with my latest Tested-by: for
> you)...;-)
>
> ./autogen.sh --prefix=/usr/local --with-dri-drivers=""
> --with-gallium-drivers=r600,radeonsi,swrast --with-platforms=drm,x11
> --enable-nine --enable-texture-float --enable-opencl
> --with-vulkan-drivers=radeon
>
> With OpenCL.
>
> So this is
>
> Tested-by: Dieter Nützel 
>

I'm not too sure that this is the right solution.
If I'm reading things correctly this will cause a break if one toggles
dri --disable-dri.


does it need to depend on HAVE_DRICOMMON? can't we just unconditionally
add libxmlconfig.la?

Jan



AFAICT the thing that gets us is the transient inclusion of
xmlconfig.la in loader.la.

I'm testing some patches to untangling this properly.

-Emil
___
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 v4] glsl: update the extensions that are enabled for 460

2017-08-04 Thread Samuel Pitoiset



On 08/04/2017 04:27 PM, Ilia Mirkin wrote:



On Aug 4, 2017 02:02, "Samuel Pitoiset" > wrote:




On 08/03/2017 07:36 PM, Ilia Mirkin wrote:

On Thu, Aug 3, 2017 at 5:24 AM, Samuel Pitoiset
mailto:samuel.pitoi...@gmail.com>>
wrote:

Other ones are either unsupported or don't have any helper
function checks.

v4: - drop ARB suffix for
shader_group_vote/arb_shader_atomic_counter_ops
v3: - always add gl_BaseVertex & co when 460 is enabled
v2: - fix ARB_shader_draw_parameters system value names

Signed-off-by: Samuel Pitoiset mailto:samuel.pitoi...@gmail.com>>
---
   src/compiler/glsl/builtin_functions.cpp | 81
+
   src/compiler/glsl/builtin_variables.cpp |  5 ++
   2 files changed, 78 insertions(+), 8 deletions(-)

diff --git a/src/compiler/glsl/builtin_functions.cpp
b/src/compiler/glsl/builtin_functions.cpp
index 84833bdd7d..bbb60b4e64 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -151,6 +151,12 @@ v130_desktop(const
_mesa_glsl_parse_state *state)
   }

   static bool
+v460_desktop(const _mesa_glsl_parse_state *state)
+{
+   return state->is_version(460, 0);
+}
+
+static bool
   v130_fs_only(const _mesa_glsl_parse_state *state)
   {
  return state->is_version(130, 300) &&
@@ -483,7 +489,7 @@ shader_atomic_counters(const
_mesa_glsl_parse_state *state)
   static bool
   shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state)
   {
-   return state->ARB_shader_atomic_counter_ops_enable;
+   return v460_desktop(state) ||
state->ARB_shader_atomic_counter_ops_enable;
   }

   static bool
@@ -606,7 +612,7 @@ barrier_supported(const
_mesa_glsl_parse_state *state)
   static bool
   vote(const _mesa_glsl_parse_state *state)
   {
-   return state->ARB_shader_group_vote_enable;
+   return v460_desktop(state) ||
state->ARB_shader_group_vote_enable;
   }

   static bool
@@ -962,7 +968,8 @@ private:

  ir_function_signature
*_vote_intrinsic(builtin_available_predicate avail,
 enum
ir_intrinsic_id id);
-   ir_function_signature *_vote(const char *intrinsic_name);
+   ir_function_signature *_vote(const char *intrinsic_name,
+builtin_available_predicate
avail);

   #undef B0
   #undef B1
@@ -3031,6 +3038,43 @@ builtin_builder::create_builtins()
  
shader_atomic_counter_ops),

   NULL);

+   add_function("atomicCounterAdd",
+_atomic_counter_op1("__intrinsic_atomic_add",
+v460_desktop),
+NULL);
+   add_function("atomicCounterSubtract",
+_atomic_counter_op1("__intrinsic_atomic_sub",
+v460_desktop),
+NULL);
+   add_function("atomicCounterMin",
+_atomic_counter_op1("__intrinsic_atomic_min",
+v460_desktop),
+NULL);
+   add_function("atomicCounterMax",
+_atomic_counter_op1("__intrinsic_atomic_max",
+v460_desktop),
+NULL);
+   add_function("atomicCounterAnd",
+_atomic_counter_op1("__intrinsic_atomic_and",
+v460_desktop),
+NULL);
+   add_function("atomicCounterOr",
+_atomic_counter_op1("__intrinsic_atomic_or",
+v460_desktop),
+NULL);
+   add_function("atomicCounterXor",
+_atomic_counter_op1("__intrinsic_atomic_xor",
+v460_desktop),
+NULL);
+   add_function("atomicCounterExchange",
+   
_atomic_counter_op1("__intrinsic_atomic

[Mesa-dev] [PATCH 1/2] etnaviv: fix etna_bo_from_name

2017-08-04 Thread Philipp Zabel
Look up BOs from the name table using the name parameter instead of
req.handle (which at this point is always zero).

Signed-off-by: Philipp Zabel 
---
 etnaviv/etnaviv_bo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etnaviv/etnaviv_bo.c b/etnaviv/etnaviv_bo.c
index 4ad0434..4fe877f 100644
--- a/etnaviv/etnaviv_bo.c
+++ b/etnaviv/etnaviv_bo.c
@@ -173,7 +173,7 @@ struct etna_bo *etna_bo_from_name(struct etna_device *dev, 
uint32_t name)
pthread_mutex_lock(&table_lock);
 
/* check name table first, to see if bo is already open: */
-   bo = lookup_bo(dev->name_table, req.handle);
+   bo = lookup_bo(dev->name_table, name);
if (bo)
goto out_unlock;
 
-- 
2.1.4

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


[Mesa-dev] [PATCH 2/2] etnaviv: add etna_bo_from_handle

2017-08-04 Thread Philipp Zabel
Although etnaviv_drmif.h declared etna_bo_from_handle from the start,
there was no implementation.

Signed-off-by: Philipp Zabel 
---
 etnaviv/etnaviv_bo.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/etnaviv/etnaviv_bo.c b/etnaviv/etnaviv_bo.c
index 4fe877f..7566957 100644
--- a/etnaviv/etnaviv_bo.c
+++ b/etnaviv/etnaviv_bo.c
@@ -135,6 +135,25 @@ struct etna_bo *etna_bo_new(struct etna_device *dev, 
uint32_t size,
return bo;
 }
 
+struct etna_bo *
+etna_bo_from_handle(struct etna_device *dev, uint32_t handle, uint32_t size)
+{
+   struct etna_bo *bo = NULL;
+
+   pthread_mutex_lock(&table_lock);
+
+   bo = lookup_bo(dev->handle_table, handle);
+   if (bo)
+   goto out_unlock;
+
+   bo = bo_from_handle(dev, size, handle, 0);
+
+out_unlock:
+   pthread_mutex_unlock(&table_lock);
+
+   return bo;
+}
+
 struct etna_bo *etna_bo_ref(struct etna_bo *bo)
 {
atomic_inc(&bo->refcnt);
-- 
2.1.4

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


[Mesa-dev] [PATCH] egl: deduplicate allocations of local buffer over each platform backend (v2)

2017-08-04 Thread Gwan-gyeong Mun
platform_drm, platform_wayland and platform_android have similiar local buffer
allocation routines. For deduplicating, it unifies dri2_egl_surface's
local buffer allocation routines. And it polishes inconsistent indentations.

Note that as dri2_wl_get_buffers_with_format() have not make a 
__DRI_BUFFER_BACK_LEFT
attachment buffer for local_buffers, new helper function, 
dri2_egl_surface_free_local_buffers(),
will drop the __DRI_BUFFER_BACK_LEFT check.
So if other platforms use new helper functions, we have to ensure not to make
__DRI_BUFFER_BACK_LEFT attachment buffer for local_buffers.

v2: Fixes from Emil's review:
   a) Make local_buffers variable, dri2_egl_surface_alloc_local_buffer() and
  dri2_egl_surface_free_local_buffers() unconditionally.
   b) Preserve the original codeflow for error_path and normal_path.
   c) Add note on commit messages for dropping of __DRI_BUFFER_BACK_LEFT check.
   c) Rollback the unrelated whitespace changes.
   d) Add a missing blank line.

Signed-off-by: Mun Gwan-gyeong 
Reviewed-by: Emil Velikov 
---
 src/egl/drivers/dri2/egl_dri2.c | 34 +
 src/egl/drivers/dri2/egl_dri2.h | 14 ++---
 src/egl/drivers/dri2/platform_android.c | 40 ++---
 src/egl/drivers/dri2/platform_drm.c | 46 -
 src/egl/drivers/dri2/platform_wayland.c | 52 -
 5 files changed, 71 insertions(+), 115 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 733659d547..129cc35872 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -972,6 +972,40 @@ dri2_display_destroy(_EGLDisplay *disp)
disp->DriverData = NULL;
 }
 
+__DRIbuffer *
+dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf,
+unsigned int att, unsigned int format)
+{
+   struct dri2_egl_display *dri2_dpy =
+  dri2_egl_display(dri2_surf->base.Resource.Display);
+
+   if (att >= ARRAY_SIZE(dri2_surf->local_buffers))
+  return NULL;
+
+   if (!dri2_surf->local_buffers[att]) {
+  dri2_surf->local_buffers[att] =
+ dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen, att, format,
+dri2_surf->base.Width, 
dri2_surf->base.Height);
+   }
+
+   return dri2_surf->local_buffers[att];
+}
+
+void
+dri2_egl_surface_free_local_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->local_buffers); i++) {
+  if (dri2_surf->local_buffers[i]) {
+ dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
+   dri2_surf->local_buffers[i]);
+ dri2_surf->local_buffers[i] = 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 ccfefef61f..6c7d75587a 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -283,8 +283,10 @@ struct dri2_egl_surface
struct gbm_dri_surface *gbm_surf;
 #endif
 
+   /* EGL-owned buffers */
+   __DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
+
 #if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
-   __DRIbuffer   *dri_buffers[__DRI_BUFFER_COUNT];
struct {
 #ifdef HAVE_WAYLAND_PLATFORM
   struct wl_buffer   *wl_buffer;
@@ -309,9 +311,6 @@ struct dri2_egl_surface
__DRIimage *dri_image_back;
__DRIimage *dri_image_front;
 
-   /* EGL-owned buffers */
-   __DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
-
/* 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.
@@ -451,4 +450,11 @@ dri2_set_WL_bind_wayland_display(_EGLDriver *drv, 
_EGLDisplay *disp)
 void
 dri2_display_destroy(_EGLDisplay *disp);
 
+__DRIbuffer *
+dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf,
+unsigned int att, unsigned int format);
+
+void
+dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf);
+
 #endif /* EGL_DRI2_INCLUDED */
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 50a8248695..71dd1594c7 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -271,40 +271,6 @@ droid_window_cancel_buffer(struct dri2_egl_surface 
*dri2_surf)
}
 }
 
-static __DRIbuffer *
-droid_alloc_local_buffer(struct dri2_egl_surface *dri2_surf,
- unsigned int att, unsigned int format)
-{
-   struct dri2_egl_display *dri2_dpy =
-  dri2_egl_display(dri2_surf->base.Resource.Display);
-
-   if (att >= ARRAY_SIZE(dri2_surf->local_buffers))
-  return NUL

Re: [Mesa-dev] [PATCH 1/2] etnaviv: fix etna_bo_from_name

2017-08-04 Thread Eric Engestrom
On Friday, 2017-08-04 17:07:54 +0200, Philipp Zabel wrote:
> Look up BOs from the name table using the name parameter instead of
> req.handle (which at this point is always zero).
> 
> Signed-off-by: Philipp Zabel 

Reviewed-by: Eric Engestrom 

> ---
>  etnaviv/etnaviv_bo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/etnaviv/etnaviv_bo.c b/etnaviv/etnaviv_bo.c
> index 4ad0434..4fe877f 100644
> --- a/etnaviv/etnaviv_bo.c
> +++ b/etnaviv/etnaviv_bo.c
> @@ -173,7 +173,7 @@ struct etna_bo *etna_bo_from_name(struct etna_device 
> *dev, uint32_t name)
>   pthread_mutex_lock(&table_lock);
>  
>   /* check name table first, to see if bo is already open: */
> - bo = lookup_bo(dev->name_table, req.handle);
> + bo = lookup_bo(dev->name_table, name);
>   if (bo)
>   goto out_unlock;
>  
> -- 
> 2.1.4
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallium/clover: Remove libxmlconfig.la from targets/clover/Makefile.am

2017-08-04 Thread Aaron Watry
On Fri, Aug 4, 2017 at 4:08 AM, Nicolai Hähnle  wrote:
> On 04.08.2017 10:27, Nicolai Hähnle wrote:
>>
>> On 04.08.2017 06:24, Aaron Watry wrote:
>>>
>>> Gets rid of a bunch of errors like the following:
>>>
>>> make[4]: Entering directory
>>> '/home/me/src/mesa/build/src/gallium/targets/opencl'
>>>CXXLDlibOpenCL.la
>>> ../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
>>> In function `driParseOptionInfo':
>>> /home/me/src/mesa/src/util/xmlconfig.c:719: multiple definition of
>>> `driParseOptionInfo'
>>>
>>> ../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:719:
>>> first defined here
>>> ../../../../src/util/.libs/libxmlconfig.a(libxmlconfig_la-xmlconfig.o):
>>> In function `driParseConfigFiles':
>>> /home/me/src/mesa/src/util/xmlconfig.c:990: multiple definition of
>>> `driParseConfigFiles'
>>>
>>> ../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_dynamic.a(libxmlconfig_la-xmlconfig.o):/home/me/src/mesa/src/util/xmlconfig.c:990:
>>> first defined here
>>>
>>> Fixes: 33f7d71d5358337f ("pipe-loader: fix build of dynamic
>>> pipe-drivers")
>>> Cc: Nicolai Hähnle 
>>> Cc: Emil Velikov 
>>> ---
>>>   src/gallium/targets/opencl/Makefile.am | 1 -
>>>   1 file changed, 1 deletion(-)
>>>
>>> diff --git a/src/gallium/targets/opencl/Makefile.am
>>> b/src/gallium/targets/opencl/Makefile.am
>>> index e88fa0fd38..c9d2be7afd 100644
>>> --- a/src/gallium/targets/opencl/Makefile.am
>>> +++ b/src/gallium/targets/opencl/Makefile.am
>>> @@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
>>>   $(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
>>>   $(top_builddir)/src/gallium/auxiliary/libgallium.la \
>>>   $(top_builddir)/src/util/libmesautil.la \
>>> -$(top_builddir)/src/util/libxmlconfig.la \
>>
>>
>> So, this is weird because I added this line to make one of the Travis CI
>> builds pass. What are your ./configure options?
>
>
> Okay, so the difference is HAVE_CLOVER_ICD. Apparently there's no Travis CI
> build with that set to false. We need to figure out a way to make both
> options happy.

I'm completely ok with an alternative approach, what I sent last night
was just what got the build working for me again, and I wanted to
start a conversation about how to fix this issue.  Probably should've
RFC'd this patch.

Nicolai/Emil: For reference, my r600g (Thuban + Barts) system is
currently built with the following configure line:

CXXFLAGS=' -O0 -g' CFLAGS=' -O0  -g' LD='ld.gold' LDFLAGS='' CC='gcc'
CXX='g++' \
/home/awatry/src/mesa/configure --prefix=/usr/local
--with-dri-drivers= --with-dri-driverdir=/usr/local/lib/dri
--enable-debug --enable-dri3 --with-llvm-prefix=/usr/local
--enable-opencl --enable-glx-tls --with-platforms=drm,x11
--enable-texture-float --enable-va --enable-gallium-tests
--with-gallium-drivers=r600,swrast

My RadeonSI system (Ryzen R7 1700 + PITCAIRN) is currently built with:
CXXFLAGS=' -O0 -g' CFLAGS=' -O0 -march=native -g' LD='ld.gold'
LDFLAGS='' CC='gcc' CXX='g++' /home/awatry/src/mesa/autogen.sh
--prefix=/usr/local --with-dri-drivers=
--with-dri-driverdir=/usr/local/lib/dri --enable-debug --enable-dri3
--enable-nine --with-llvm-prefix=/usr/local --enable-opencl
--enable-opencl-icd=yes --enable-glx-tls --with-platforms=drm,x11
--enable-gles1 --enable-gles2 --enable-texture-float --enable-va
--enable-gallium-tests --with-gallium-drivers=radeonsi,r600,swrast
--with-vulkan-drivers=radeon

--Aaron

>
> Cheers,
> Nicolai
>
>
>>
>> Thanks,
>> Nicolai
>>
>>>   $(EXPAT_LIBS) \
>>>   $(LIBELF_LIBS) \
>>>   $(DLOPEN_LIBS) \
>>>
>>
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
>
> --
> Lerne, wie die Welt wirklich ist,
> Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 102038] assertion failure in update_framebuffer_size

2017-08-04 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102038

Bug ID: 102038
   Summary: assertion failure in update_framebuffer_size
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Gallium/swr
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: brad.k...@kitware.com
QA Contact: mesa-dev@lists.freedesktop.org

Created attachment 133247
  --> https://bugs.freedesktop.org/attachment.cgi?id=133247&action=edit
apitrace of test that crashes

Since commit 6839d33699 (st/mesa: fix handling of NumSamples=1 (v2),
2017-08-01) many of VTK's tests crash with Mesa with an assertion failure. 
I've attached an apitrace of one of the tests.

The test aborts with an assertion failure:

```
state_tracker/st_atom_framebuffer.c:62: update_framebuffer_size: Assertion
`surface' failed.
```

The backtrace in gdb is

```
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x77a6e3fa in __GI_abort () at abort.c:89
#2  0x77a65e37 in __assert_fail_base (fmt=, 
assertion=assertion@entry=0x7fffec7516a4 "surface", 
file=file@entry=0x7fffec751680 "state_tracker/st_atom_framebuffer.c", 
line=line@entry=62, 
function=function@entry=0x7fffec7517a0 <__PRETTY_FUNCTION__.39021>
"update_framebuffer_size") at assert.c:92
#3  0x77a65ee2 in __GI___assert_fail (
assertion=0x7fffec7516a4 "surface", 
file=0x7fffec751680 "state_tracker/st_atom_framebuffer.c", line=62, 
function=0x7fffec7517a0 <__PRETTY_FUNCTION__.39021>
"update_framebuffer_size") at assert.c:101
#4  0x7fffec336bad in update_framebuffer_size (framebuffer=0x7fffce70, 
surface=0x0) at state_tracker/st_atom_framebuffer.c:62
#5  0x7fffec336f3e in st_update_framebuffer_state (st=0x55ae3b90)
at state_tracker/st_atom_framebuffer.c:181
#6  0x7fffec33538c in st_validate_state (st=0x55ae3b90, 
pipeline=ST_PIPELINE_CLEAR) at state_tracker/st_atom.c:251
#7  0x7fffec3428ea in st_Clear (ctx=0x55abeb30, mask=18)
at state_tracker/st_cb_clear.c:411
#8  0x7fffec0a2b4a in clear (no_error=false, mask=16640,
ctx=0x55abeb30)
at main/clear.c:221
#9  _mesa_Clear (mask=16640) at main/clear.c:242
...(vtk code)...
```

For reference, I'm building Mesa as follows:

./autogen.sh \
  --prefix="$prefix" \
  --enable-debug \
  --disable-dri \
  --disable-egl \
  --disable-gbm \
  --disable-gles1 \
  --disable-gles2 \
  --disable-shared-glapi \
  --with-platforms=x11 \
  --enable-glx=gallium-xlib \
  --enable-gallium-osmesa \
  --with-gallium-drivers=swrast \
  --enable-gallium-llvm=yes \
LLVM_CONFIG=/usr/bin/llvm-config-3.8 \
  --enable-llvm-shared-libs \
  --with-gl-lib-name=MesaGL \
  --with-osmesa-lib-name=MesaOSMesa

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


Re: [Mesa-dev] [PATCH] egl: deduplicate allocations of local buffer over each platform backend (v2)

2017-08-04 Thread Eric Engestrom
On Saturday, 2017-08-05 00:16:11 +0900, Gwan-gyeong Mun wrote:
> platform_drm, platform_wayland and platform_android have similiar local buffer
> allocation routines. For deduplicating, it unifies dri2_egl_surface's
> local buffer allocation routines. And it polishes inconsistent indentations.
> 
> Note that as dri2_wl_get_buffers_with_format() have not make a 
> __DRI_BUFFER_BACK_LEFT
> attachment buffer for local_buffers, new helper function, 
> dri2_egl_surface_free_local_buffers(),
> will drop the __DRI_BUFFER_BACK_LEFT check.
> So if other platforms use new helper functions, we have to ensure not to make
> __DRI_BUFFER_BACK_LEFT attachment buffer for local_buffers.
> 
> v2: Fixes from Emil's review:
>a) Make local_buffers variable, dri2_egl_surface_alloc_local_buffer() and
>   dri2_egl_surface_free_local_buffers() unconditionally.
>b) Preserve the original codeflow for error_path and normal_path.
>c) Add note on commit messages for dropping of __DRI_BUFFER_BACK_LEFT 
> check.
>c) Rollback the unrelated whitespace changes.

The dri2_drm_get_buffers_with_format() unrelated whitespace change is
still here :P
(don't bother unless you need to do a v3 for some other reason)

Once this lands, platform_drm (and probably others) could use
a full whitespace cleanup pass, if you want :)

>d) Add a missing blank line.
> 
> Signed-off-by: Mun Gwan-gyeong 
> Reviewed-by: Emil Velikov 

v2 looks good to me.
Reviewed-by: Eric Engestrom 

Thanks!

> ---
>  src/egl/drivers/dri2/egl_dri2.c | 34 +
>  src/egl/drivers/dri2/egl_dri2.h | 14 ++---
>  src/egl/drivers/dri2/platform_android.c | 40 ++---
>  src/egl/drivers/dri2/platform_drm.c | 46 -
>  src/egl/drivers/dri2/platform_wayland.c | 52 
> -
>  5 files changed, 71 insertions(+), 115 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 733659d547..129cc35872 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -972,6 +972,40 @@ dri2_display_destroy(_EGLDisplay *disp)
> disp->DriverData = NULL;
>  }
>  
> +__DRIbuffer *
> +dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf,
> +unsigned int att, unsigned int format)
> +{
> +   struct dri2_egl_display *dri2_dpy =
> +  dri2_egl_display(dri2_surf->base.Resource.Display);
> +
> +   if (att >= ARRAY_SIZE(dri2_surf->local_buffers))
> +  return NULL;
> +
> +   if (!dri2_surf->local_buffers[att]) {
> +  dri2_surf->local_buffers[att] =
> + dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen, att, format,
> +dri2_surf->base.Width, 
> dri2_surf->base.Height);
> +   }
> +
> +   return dri2_surf->local_buffers[att];
> +}
> +
> +void
> +dri2_egl_surface_free_local_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->local_buffers); i++) {
> +  if (dri2_surf->local_buffers[i]) {
> + dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
> +   dri2_surf->local_buffers[i]);
> + dri2_surf->local_buffers[i] = 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 ccfefef61f..6c7d75587a 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -283,8 +283,10 @@ struct dri2_egl_surface
> struct gbm_dri_surface *gbm_surf;
>  #endif
>  
> +   /* EGL-owned buffers */
> +   __DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
> +
>  #if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
> -   __DRIbuffer   *dri_buffers[__DRI_BUFFER_COUNT];
> struct {
>  #ifdef HAVE_WAYLAND_PLATFORM
>struct wl_buffer   *wl_buffer;
> @@ -309,9 +311,6 @@ struct dri2_egl_surface
> __DRIimage *dri_image_back;
> __DRIimage *dri_image_front;
>  
> -   /* EGL-owned buffers */
> -   __DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
> -
> /* 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.
> @@ -451,4 +450,11 @@ dri2_set_WL_bind_wayland_display(_EGLDriver *drv, 
> _EGLDisplay *disp)
>  void
>  dri2_display_destroy(_EGLDisplay *disp);
>  
> +__DRIbuffer *
> +dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf,
> +unsigned int att, unsigned int format);
> +
> +void
> +dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf);
> +
>  #endif /* EGL_DRI2_INCLUDED */
> diff --git a/src/egl/

Re: [Mesa-dev] [PATCH v4] glsl: update the extensions that are enabled for 460

2017-08-04 Thread Ilia Mirkin
On Fri, Aug 4, 2017 at 10:49 AM, Samuel Pitoiset
 wrote:
>
>
> On 08/04/2017 04:27 PM, Ilia Mirkin wrote:
>>
>>
>>
>> On Aug 4, 2017 02:02, "Samuel Pitoiset" > > wrote:
>>
>>
>>
>> On 08/03/2017 07:36 PM, Ilia Mirkin wrote:
>>
>> On Thu, Aug 3, 2017 at 5:24 AM, Samuel Pitoiset
>> mailto:samuel.pitoi...@gmail.com>>
>> wrote:
>>
>> Other ones are either unsupported or don't have any helper
>> function checks.
>>
>> v4: - drop ARB suffix for
>> shader_group_vote/arb_shader_atomic_counter_ops
>> v3: - always add gl_BaseVertex & co when 460 is enabled
>> v2: - fix ARB_shader_draw_parameters system value names
>>
>> Signed-off-by: Samuel Pitoiset > >
>>
>> ---
>>src/compiler/glsl/builtin_functions.cpp | 81
>> +
>>src/compiler/glsl/builtin_variables.cpp |  5 ++
>>2 files changed, 78 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/compiler/glsl/builtin_functions.cpp
>> b/src/compiler/glsl/builtin_functions.cpp
>> index 84833bdd7d..bbb60b4e64 100644
>> --- a/src/compiler/glsl/builtin_functions.cpp
>> +++ b/src/compiler/glsl/builtin_functions.cpp
>> @@ -151,6 +151,12 @@ v130_desktop(const
>> _mesa_glsl_parse_state *state)
>>}
>>
>>static bool
>> +v460_desktop(const _mesa_glsl_parse_state *state)
>> +{
>> +   return state->is_version(460, 0);
>> +}
>> +
>> +static bool
>>v130_fs_only(const _mesa_glsl_parse_state *state)
>>{
>>   return state->is_version(130, 300) &&
>> @@ -483,7 +489,7 @@ shader_atomic_counters(const
>> _mesa_glsl_parse_state *state)
>>static bool
>>shader_atomic_counter_ops(const _mesa_glsl_parse_state
>> *state)
>>{
>> -   return state->ARB_shader_atomic_counter_ops_enable;
>> +   return v460_desktop(state) ||
>> state->ARB_shader_atomic_counter_ops_enable;
>>}
>>
>>static bool
>> @@ -606,7 +612,7 @@ barrier_supported(const
>> _mesa_glsl_parse_state *state)
>>static bool
>>vote(const _mesa_glsl_parse_state *state)
>>{
>> -   return state->ARB_shader_group_vote_enable;
>> +   return v460_desktop(state) ||
>> state->ARB_shader_group_vote_enable;
>>}
>>
>>static bool
>> @@ -962,7 +968,8 @@ private:
>>
>>   ir_function_signature
>> *_vote_intrinsic(builtin_available_predicate avail,
>>  enum
>> ir_intrinsic_id id);
>> -   ir_function_signature *_vote(const char *intrinsic_name);
>> +   ir_function_signature *_vote(const char *intrinsic_name,
>> +builtin_available_predicate
>> avail);
>>
>>#undef B0
>>#undef B1
>> @@ -3031,6 +3038,43 @@ builtin_builder::create_builtins()
>>
>> shader_atomic_counter_ops),
>>NULL);
>>
>> +   add_function("atomicCounterAdd",
>> +_atomic_counter_op1("__intrinsic_atomic_add",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterSubtract",
>> +_atomic_counter_op1("__intrinsic_atomic_sub",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterMin",
>> +_atomic_counter_op1("__intrinsic_atomic_min",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterMax",
>> +_atomic_counter_op1("__intrinsic_atomic_max",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterAnd",
>> +_atomic_counter_op1("__intrinsic_atomic_and",
>> +v460_desktop),
>> +NULL);
>> +   add_function("atomicCounterOr",
>> +_atomic_counter_op1("__intrinsic_atomic_or",
>> +v460_desktop),
>> +NULL);
>> +   add_f

Re: [Mesa-dev] [EGL android: accquire fence implementation 1/2] i965: Return the last fence if the batch buffer is empty and nothing to be flushed when _intel_batchbuffer_flush_fence.

2017-08-04 Thread Marathe, Yogesh
Tomasz,

> -Original Message-
> From: Tomasz Figa [mailto:tf...@chromium.org]
> Sent: Friday, August 4, 2017 3:48 PM
> To: Marathe, Yogesh 
> Cc: Emil Velikov ; Wu, Zhongmin
> ; Gao, Shuo ; Antognolli,
> Rafael ; Timothy Arceri
> ; Kenneth Graunke ;
> Kondapally, Kalyan ; ML mesa-dev  d...@lists.freedesktop.org>
> Subject: Re: [Mesa-dev] [EGL android: accquire fence implementation 1/2] i965:
> Return the last fence if the batch buffer is empty and nothing to be flushed 
> when
> _intel_batchbuffer_flush_fence.
> 
> Hi Yogesh,
> 
> On Fri, Aug 4, 2017 at 7:12 PM, Marathe, Yogesh 
> wrote:
> > Hi Emil,
> >
> >> -Original Message-
> >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> >> Behalf Of Emil Velikov
> >> Sent: Tuesday, July 25, 2017 8:19 PM
> >> To: Wu, Zhongmin 
> >> Cc: Gao, Shuo ; Antognolli, Rafael
> >> ; Timothy Arceri
> >> ; Marathe, Yogesh ;
> >> Tomasz Figa ; Kenneth Graunke
> >> ; Kondapally, Kalyan
> >> ; ML mesa-dev  >> d...@lists.freedesktop.org>
> >> Subject: Re: [Mesa-dev] [EGL android: accquire fence implementation 1/2]
> i965:
> >> Return the last fence if the batch buffer is empty and nothing to be
> >> flushed when _intel_batchbuffer_flush_fence.
> >>
> >> Hi Zhongmin,
> >>
> >> Is the issue resolved by the EGL patch alone? Worth sticking with that for
> now?
> >>
> >> I think this patch will cause some noticeable overhead - see below for 
> >> details.
> >>
> >>
> >> On 21 July 2017 at 04:08, Zhongmin Wu  wrote:
> >> > Always save the last fence in the brw context when flushing buffer.
> >> > If the buffer is nothing to be flushed, then return the last fence
> >> > when asked for.
> >> >
> >> > Change-Id: Ic47035bcd1a27e402609afd9e2d1e3972548b97d
> >> > Signed-off-by: Zhongmin Wu 
> >> > ---
> >> >  src/mesa/drivers/dri/i965/brw_context.c   |5 +
> >> >  src/mesa/drivers/dri/i965/brw_context.h   |1 +
> >> >  src/mesa/drivers/dri/i965/intel_batchbuffer.c |   16 ++--
> >> >  3 files changed, 20 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> >> > b/src/mesa/drivers/dri/i965/brw_context.c
> >> > index 5433f90..ed0b056 100644
> >> > --- a/src/mesa/drivers/dri/i965/brw_context.c
> >> > +++ b/src/mesa/drivers/dri/i965/brw_context.c
> >> > @@ -1086,6 +1086,8 @@ brwCreateContext(gl_api api,
> >> > ctx->VertexProgram._MaintainTnlProgram = true;
> >> > ctx->FragmentProgram._MaintainTexEnvProgram = true;
> >> >
> >> > +   brw->out_fence_fd = -1;
> >> > +
> >> > brw_draw_init( brw );
> >> >
> >> > if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) { @@ -1169,6 +1171,9
> >> > @@ intelDestroyContext(__DRIcontext * driContextPriv)
> >> > brw->throttle_batch[1] = NULL;
> >> > brw->throttle_batch[0] = NULL;
> >> >
> >> > +   if (brw->out_fence_fd >= 0)
> >> > +  close(brw->out_fence_fd);
> >> > +
> >> > driDestroyOptionCache(&brw->optionCache);
> >> >
> >> > /* free the Mesa context */
> >> > diff --git a/src/mesa/drivers/dri/i965/brw_context.h
> >> > b/src/mesa/drivers/dri/i965/brw_context.h
> >> > index dc4bc8f..692ea2c 100644
> >> > --- a/src/mesa/drivers/dri/i965/brw_context.h
> >> > +++ b/src/mesa/drivers/dri/i965/brw_context.h
> >> > @@ -1217,6 +1217,7 @@ struct brw_context
> >> >
> >> > __DRIcontext *driContext;
> >> > struct intel_screen *screen;
> >> > +   int out_fence_fd;
> >> >  };
> >> >
> >> >  /* brw_clear.c */
> >> > diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> >> > b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> >> > index 62d2fe8..d342e5d 100644
> >> > --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> >> > +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> >> > @@ -648,9 +648,18 @@ do_flush_locked(struct brw_context *brw, int
> >> in_fence_fd, int *out_fence_fd)
> >> >   /* Add the batch itself to the end of the validation list */
> >> >   add_exec_bo(batch, batch->bo);
> >> >
> >> > + if (brw->out_fence_fd >= 0) {
> >> > +close(brw->out_fence_fd);
> >> > +brw->out_fence_fd = -1;
> >> > + }
> >> > +
> >> > + int fd = -1;
> >> >   ret = execbuffer(dri_screen->fd, batch, hw_ctx,
> >> >4 * USED_BATCH(*batch),
> >> > -  in_fence_fd, out_fence_fd, flags);
> >> > +  in_fence_fd, &fd, flags);
> >> execbuffer() creates an out fence if the "out_fence_fd" pointer is 
> >> non-NULL.
> >> Hence with this patch we'will create a fence for each
> >> _intel_batchbuffer_flush_fence() invocation...
> >>
> >> Not sure how costly that will be though :-\
> >>
> >
> > I see this results into 1 get_unused_fd_flags() + 1 sync_file_create()
> > and operations to store out fd in kernel for return arg. I doubt it
> > will be very costly, the ioctl
> > DRM_IOCTL_I915_GEM_EXECBUFFER2 or
> DRM_IOCTL_I915_GEM_EXECBUFFER2_WR
> > was anyways there, so nothing huge additional on ioctl front.
> >

Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a sync fence for Android OS

2017-08-04 Thread Marathe, Yogesh
Tomasz, Emil,

> -Original Message-
> From: Tomasz Figa [mailto:tf...@chromium.org]
> Sent: Friday, August 4, 2017 6:54 PM
> To: Emil Velikov 
> Cc: Marathe, Yogesh ; Antognolli, Rafael
> ; ML mesa-dev  d...@lists.freedesktop.org>; Wu, Zhongmin ; Gao,
> Shuo ; Liu, Zhiquan ; Daniel
> Stone ; Timothy Arceri ; Eric
> Engestrom ; Kenneth Graunke ;
> Kondapally, Kalyan ; Varad Gautam
> ; Rainer Hochecker ;
> Nicolai Hähnle 
> Subject: Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a sync 
> fence
> for Android OS
> 
> On Fri, Aug 4, 2017 at 9:55 PM, Emil Velikov  wrote:
> >>> >>  - version check (2+) the fence extension, calling
> >>> >> .create_fence_fd() only when
> >>> >> .get_capabilities() advertises __DRI_FENCE_CAP_NATIVE_FD
> >>
> >> The check looks like below now, this is in dri2_surf_update_fence_fd() 
> >> before
> create_fence_fd is called.
> >>
> >> if (dri2_surf->enable_out_fence && dri2_dpy->fence) {
> >>if(__DRI_FENCE_CAP_NATIVE_FD | dri2_dpy->fence-
> >get_capabilities(dri2_dpy->dri_screen)) {
> >>   //create_fence_fd call
> >>}
> >> }
> >>
> > Close but no cigar.
> >
> > if (dri2_surf->enable_out_fence && dri2_dpy->fence &&
> > dri2_dpy->fence->base.version >= 2 &&
> > dri2_dpy->fence->get_capabilities) {
> >
> >if (dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen) &
> > __DRI_FENCE_CAP_NATIVE_FD) {
> > //create_fence_fd call
> >}
> > }
> 
> If this needs so complicated series of checks, maybe it would make more sense
> to just set enable_out_fence based on availability of the capability at
> initialization time?

I liked this one compared to nested ifs in dri2_surf_update_fence_fd().

> 
> >
> >> Overall, if I further go ahead and check, actually get_capabilities()
> >> ultimately returns based on has_exec_fence which depends on
> >> I915_PARAM_HAS_EXEC_FENCE. This is always set to true for i915 in
> >> kernel drv unless forced to false!! I'm not sure if that inner check of
> get_capabilities still makes sense. Isn't the first one sufficient?
> >>
> > Not sure what you mean with "first one", but consider the following example:
> >  - old kernel which does not support (or has force disabled)
> > I915_PARAM_HAS_EXEC_FENCE.
> >  - new userspace which unconditionally advertises the fence v2
> > extension IIRC one may tweak that things to only conditionally
> > advertise it, but IMHO it's not worth the hassle.
> >
> > Even then, Mesa can produce 20 DRI drivers (used by the EGL module) so
> > focusing on one doesn't quite work.
> >
> >>> >>  - don't introduce unused variables (in make_current)
> >>
> >> Done.
> >>
> >>> >>  - the create fd for the old display surface (in make_current)
> >>> >> seems bogus
> >>
> >> Done.
> >>
> > Did you drop it all together or changed to use some other surface?
> > Would be nice to hear the reason why it was added - perhaps I'm
> > missing something.
> 
> We have to keep it, otherwise there would be no fence available at the time of
> surface destruction, while, at least for Android, a fence can be passed to
> window's cancelBuffer callback.
> 
> >
> > I think that we want a fence/fd for the new draw surface. Since
> > otherwise one won't get created up until the first SwapBuffers call.
> 
> I might be missing something, but wouldn't that insert a fence at the 
> beginning
> of command stream, before even doing anything? At least in Android use cases,
> the only places we need the fence is in SwapBuffers and DestroySurface and the
> fence should be inserted after all the commands for rendering into given
> surface.
> 

Emil,

Tomasz sounds convincing to me here, I just went ahead with the comment to try 
out and
flatland worked even after removing that. Zhongmin can explain better but I 
think in earlier
revisions this was done for cancelBuffer to match with queueBuffer, I mean we 
are passing
valid fd for queueBuffer by doing this we would have a valid fd during 
cancelBuffer.  Not
sure if this is the reason / one of the reason.

I will go ahead with rest of your comments if we are ok to keep fd for old 
display surface 
in make_current.

> Best regards,
> Tomasz
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] loader: always include libxmlconfig on autotools build

2017-08-04 Thread Jan Vesely
On Fri, 2017-08-04 at 11:53 +0200, Nicolai Hähnle wrote:
> From: Nicolai Hähnle 
> 
> This aligns with the fact that we also check for EXPAT_LIBS
> unconditionally in configure.ac now. It should make all the
> various build permutations of Clover work (whether DRI is
> enabled or disabled in the build).
> 
> Cc: Aaron Watry 
> Cc: Emil Velikov 
> --
> This change keeps everything green on Travis, and it should fix
> the duplicate-symbol linker error seen by Aaron and others when
> building Clover.

It does. This patch fixes last of the problems I had since the driconf
changes.
Tested-by: Jan Vesely 

thanks,
Jan

> ---
>  src/gallium/targets/opencl/Makefile.am |  1 -
>  src/loader/Makefile.am | 13 +
>  2 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/src/gallium/targets/opencl/Makefile.am 
> b/src/gallium/targets/opencl/Makefile.am
> index e88fa0fd382..c9d2be7afd0 100644
> --- a/src/gallium/targets/opencl/Makefile.am
> +++ b/src/gallium/targets/opencl/Makefile.am
> @@ -19,7 +19,6 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
>   $(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
>   $(top_builddir)/src/gallium/auxiliary/libgallium.la \
>   $(top_builddir)/src/util/libmesautil.la \
> - $(top_builddir)/src/util/libxmlconfig.la \
>   $(EXPAT_LIBS) \
>   $(LIBELF_LIBS) \
>   $(DLOPEN_LIBS) \
> diff --git a/src/loader/Makefile.am b/src/loader/Makefile.am
> index 8b197f2995c..5ed87820664 100644
> --- a/src/loader/Makefile.am
> +++ b/src/loader/Makefile.am
> @@ -33,21 +33,18 @@ AM_CPPFLAGS = \
>   $(XCB_DRI3_CFLAGS) \
>   $(LIBDRM_CFLAGS)
>  
> -libloader_la_CPPFLAGS = $(AM_CPPFLAGS)
> +libloader_la_CPPFLAGS = $(AM_CPPFLAGS) \
> + -DUSE_DRICONF
>  libloader_la_SOURCES = $(LOADER_C_FILES)
> -libloader_la_LIBADD =
> +libloader_la_LIBADD = \
> + $(top_builddir)/src/util/libxmlconfig.la
>  
>  if HAVE_DRICOMMON
>  libloader_la_CPPFLAGS += \
>   -I$(top_builddir)/src/util/ \
>   -I$(top_srcdir)/src/mesa/drivers/dri/common/ \
>   -I$(top_srcdir)/src/mesa/ \
> - -I$(top_srcdir)/src/mapi/ \
> - -DUSE_DRICONF
> -
> -libloader_la_LIBADD += \
> - $(top_builddir)/src/util/libxmlconfig.la
> -
> + -I$(top_srcdir)/src/mapi/
>  endif
>  
>  if HAVE_LIBDRM


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 v5 2/2] i965: Queue the buffer with a sync fence for Android OS

2017-08-04 Thread Tomasz Figa
On Sat, Aug 5, 2017 at 12:53 AM, Marathe, Yogesh
 wrote:
> Tomasz, Emil,
>
>> -Original Message-
>> From: Tomasz Figa [mailto:tf...@chromium.org]
>> Sent: Friday, August 4, 2017 6:54 PM
>> To: Emil Velikov 
>> Cc: Marathe, Yogesh ; Antognolli, Rafael
>> ; ML mesa-dev > d...@lists.freedesktop.org>; Wu, Zhongmin ; Gao,
>> Shuo ; Liu, Zhiquan ; Daniel
>> Stone ; Timothy Arceri ; Eric
>> Engestrom ; Kenneth Graunke ;
>> Kondapally, Kalyan ; Varad Gautam
>> ; Rainer Hochecker ;
>> Nicolai Hähnle 
>> Subject: Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a sync 
>> fence
>> for Android OS
>>
>> On Fri, Aug 4, 2017 at 9:55 PM, Emil Velikov  
>> wrote:
>> >>> >>  - version check (2+) the fence extension, calling
>> >>> >> .create_fence_fd() only when
>> >>> >> .get_capabilities() advertises __DRI_FENCE_CAP_NATIVE_FD
>> >>
>> >> The check looks like below now, this is in dri2_surf_update_fence_fd() 
>> >> before
>> create_fence_fd is called.
>> >>
>> >> if (dri2_surf->enable_out_fence && dri2_dpy->fence) {
>> >>if(__DRI_FENCE_CAP_NATIVE_FD | dri2_dpy->fence-
>> >get_capabilities(dri2_dpy->dri_screen)) {
>> >>   //create_fence_fd call
>> >>}
>> >> }
>> >>
>> > Close but no cigar.
>> >
>> > if (dri2_surf->enable_out_fence && dri2_dpy->fence &&
>> > dri2_dpy->fence->base.version >= 2 &&
>> > dri2_dpy->fence->get_capabilities) {
>> >
>> >if (dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen) &
>> > __DRI_FENCE_CAP_NATIVE_FD) {
>> > //create_fence_fd call
>> >}
>> > }
>>
>> If this needs so complicated series of checks, maybe it would make more sense
>> to just set enable_out_fence based on availability of the capability at
>> initialization time?
>
> I liked this one compared to nested ifs in dri2_surf_update_fence_fd().
>
>>
>> >
>> >> Overall, if I further go ahead and check, actually get_capabilities()
>> >> ultimately returns based on has_exec_fence which depends on
>> >> I915_PARAM_HAS_EXEC_FENCE. This is always set to true for i915 in
>> >> kernel drv unless forced to false!! I'm not sure if that inner check of
>> get_capabilities still makes sense. Isn't the first one sufficient?
>> >>
>> > Not sure what you mean with "first one", but consider the following 
>> > example:
>> >  - old kernel which does not support (or has force disabled)
>> > I915_PARAM_HAS_EXEC_FENCE.
>> >  - new userspace which unconditionally advertises the fence v2
>> > extension IIRC one may tweak that things to only conditionally
>> > advertise it, but IMHO it's not worth the hassle.
>> >
>> > Even then, Mesa can produce 20 DRI drivers (used by the EGL module) so
>> > focusing on one doesn't quite work.
>> >
>> >>> >>  - don't introduce unused variables (in make_current)
>> >>
>> >> Done.
>> >>
>> >>> >>  - the create fd for the old display surface (in make_current)
>> >>> >> seems bogus
>> >>
>> >> Done.
>> >>
>> > Did you drop it all together or changed to use some other surface?
>> > Would be nice to hear the reason why it was added - perhaps I'm
>> > missing something.
>>
>> We have to keep it, otherwise there would be no fence available at the time 
>> of
>> surface destruction, while, at least for Android, a fence can be passed to
>> window's cancelBuffer callback.
>>
>> >
>> > I think that we want a fence/fd for the new draw surface. Since
>> > otherwise one won't get created up until the first SwapBuffers call.
>>
>> I might be missing something, but wouldn't that insert a fence at the 
>> beginning
>> of command stream, before even doing anything? At least in Android use cases,
>> the only places we need the fence is in SwapBuffers and DestroySurface and 
>> the
>> fence should be inserted after all the commands for rendering into given
>> surface.
>>
>
> Emil,
>
> Tomasz sounds convincing to me here, I just went ahead with the comment to 
> try out and
> flatland worked even after removing that. Zhongmin can explain better but I 
> think in earlier
> revisions this was done for cancelBuffer to match with queueBuffer, I mean we 
> are passing
> valid fd for queueBuffer by doing this we would have a valid fd during 
> cancelBuffer.  Not
> sure if this is the reason / one of the reason.
>
> I will go ahead with rest of your comments if we are ok to keep fd for old 
> display surface
> in make_current.

My understanding is that nobody actually cares about the fence that
cancelBuffer returns, because the contents of the buffer are going to
be discarded anyway and the buffer doesn't go to the consumer (e.g.
flatland code that reads the timestamp). I even suspect that typically
destroySurface would be called directly after swapBuffers and the
surface wouldn't have a buffer to cancel. You can easily check this by
adding a print before cancelBuffer call happens. So we might actually
be fine with simpler code that gets fence only for swapBuffers.

Changing the topic, the patch doesn't seem to change the
implementation of swapBuffers to stop doing a flush on the buffer,
whi

Re: [Mesa-dev] [PATCH 1/2] etnaviv: fix etna_bo_from_name

2017-08-04 Thread Wladimir J. van der Laan
On Fri, Aug 04, 2017 at 05:07:54PM +0200, Philipp Zabel wrote:
> Look up BOs from the name table using the name parameter instead of
> req.handle (which at this point is always zero).

Good catch.

Just out of interest: when is this used, what problems does this cause?

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


Re: [Mesa-dev] [PATCH v2 2/9] anv: Submit a dummy batch when only semaphores are provided.

2017-08-04 Thread Jason Ekstrand
On Fri, Aug 4, 2017 at 1:43 AM, Chris Wilson 
wrote:

> Quoting Jason Ekstrand (2017-08-04 02:25:21)
> > Vulkan allows you to do a submit whose only job is to wait on and
> > trigger semaphores.  The easiest way for us to support that right
> > now is to insert a dummy execbuf.
> > ---
> > diff --git a/src/intel/vulkan/anv_device.c
> b/src/intel/vulkan/anv_device.c
> > index 793e519..0f0aa22 100644
> > --- a/src/intel/vulkan/anv_device.c
> > +++ b/src/intel/vulkan/anv_device.c
> > @@ -1014,6 +1014,28 @@ anv_device_init_border_colors(struct anv_device
> *device)
> >  border_colors);
> >  }
> >
> > +static void
> > +anv_device_init_trivial_batch(struct anv_device *device)
> > +{
> > +   anv_bo_init_new(&device->trivial_batch_bo, device, 4096);
>
> Is this created with ASYNC?


No, it isn't but I'm happy to set the flag.  This patch predates the ASYNC
stuff, I believe.

Just thinking that you only want the
> external ordering constraints on this bo, and not accidentally serialize
> between contexts.
>

Is this really an issue?  No other process will ever see this BO.  I
suppose the kernel is still doing unneeded flushing but this shouldn't
cause cross-context synchronization.


> > +   void *map = anv_gem_mmap(device, device->trivial_batch_bo.gem_
> handle,
> > +0, 4096, 0);
> > +
> > +   struct anv_batch batch = {
> > +  .start = map,
> > +  .next = map,
> > +  .end = map + 4096,
> > +   };
> > +
> > +   anv_batch_emit(&batch, GEN7_MI_BATCH_BUFFER_END, bbe);
> > +   anv_batch_emit(&batch, GEN7_MI_NOOP, noop);
> > +
> > +   if (!device->info.has_llc)
> > +  gen_clflush_range(map, batch.next - map);
> > +
> > +   anv_gem_munmap(map, device->trivial_batch_bo.size);
> > +}
>
> > diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_
> private.h
> > index b599db3..bc67bb6 100644
> > --- a/src/intel/vulkan/anv_private.h
> > +++ b/src/intel/vulkan/anv_private.h
> > @@ -745,6 +745,7 @@ struct anv_device {
> >  struct anv_state_pool   surface_state_pool;
> >
> >  struct anv_bo   workaround_bo;
> > +struct anv_bo   trivial_batch_bo;
>
> Do you use all 4096 bytes of the workaround_bo, or could you spare 64?
> ;)
>

I could... Then again, I can also easily spare a single 4K page per context
and prevent myself from accidentally overwriting my little batch. :-)


> > diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
> > index 446c3de..9934fef 100644
> > --- a/src/intel/vulkan/anv_queue.c
> > +++ b/src/intel/vulkan/anv_queue.c
> > @@ -159,6 +159,23 @@ VkResult anv_QueueSubmit(
> > pthread_mutex_lock(&device->mutex);
> >
> > for (uint32_t i = 0; i < submitCount; i++) {
> > +  if (pSubmits[i].commandBufferCount == 0) {
> > + /* If we don't have any command buffers, we need to submit a
> dummy
> > +  * batch to give GEM something to wait on.  We could,
> potentially,
> > +  * come up with something more efficient but this shouldn't be
> a
> > +  * common case.
> > +  */
> > + result = anv_cmd_buffer_execbuf(device, NULL,
> > + pSubmits[i].pWaitSemaphores,
> > + pSubmits[i].
> waitSemaphoreCount,
> > + pSubmits[i].pSignalSemaphores,
> > + pSubmits[i].
> signalSemaphoreCount);
>
> Might as well just pass &pSubmits[i] along?
>

I can't.  See below where we only pass the wait semaphores to the first
execbuf in the batch and only pass the signal semaphores to the last.

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


Re: [Mesa-dev] [PATCH v5 2/2] i965: Queue the buffer with a sync fence for Android OS

2017-08-04 Thread Marathe, Yogesh
> -Original Message-
> From: Tomasz Figa [mailto:tf...@chromium.org]
> Sent: Friday, August 4, 2017 9:39 PM
> On Sat, Aug 5, 2017 at 12:53 AM, Marathe, Yogesh
>  wrote:
> > Tomasz, Emil,
> >
> >> -Original Message-
> >> From: Tomasz Figa [mailto:tf...@chromium.org]
> >> On Fri, Aug 4, 2017 at 9:55 PM, Emil Velikov 
> wrote:
> >> >>> >>  - version check (2+) the fence extension, calling
> >> >>> >> .create_fence_fd() only when
> >> >>> >> .get_capabilities() advertises __DRI_FENCE_CAP_NATIVE_FD
> >> >>
> >> >> The check looks like below now, this is in
> >> >> dri2_surf_update_fence_fd() before
> >> create_fence_fd is called.
> >> >>
> >> >> if (dri2_surf->enable_out_fence && dri2_dpy->fence) {
> >> >>if(__DRI_FENCE_CAP_NATIVE_FD | dri2_dpy->fence-
> >> >get_capabilities(dri2_dpy->dri_screen)) {
> >> >>   //create_fence_fd call
> >> >>}
> >> >> }
> >> >>
> >> > Close but no cigar.
> >> >
> >> > if (dri2_surf->enable_out_fence && dri2_dpy->fence &&
> >> > dri2_dpy->fence->base.version >= 2 &&
> >> > dri2_dpy->fence->get_capabilities) {
> >> >
> >> >if (dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen) &
> >> > __DRI_FENCE_CAP_NATIVE_FD) {
> >> > //create_fence_fd call
> >> >}
> >> > }
> >>
> >> If this needs so complicated series of checks, maybe it would make
> >> more sense to just set enable_out_fence based on availability of the
> >> capability at initialization time?
> >
> > I liked this one compared to nested ifs in dri2_surf_update_fence_fd().
> >
> >>
> >> >
> >> >> Overall, if I further go ahead and check, actually
> >> >> get_capabilities() ultimately returns based on has_exec_fence
> >> >> which depends on I915_PARAM_HAS_EXEC_FENCE. This is always set to
> >> >> true for i915 in kernel drv unless forced to false!! I'm not sure
> >> >> if that inner check of
> >> get_capabilities still makes sense. Isn't the first one sufficient?
> >> >>
> >> > Not sure what you mean with "first one", but consider the following
> example:
> >> >  - old kernel which does not support (or has force disabled)
> >> > I915_PARAM_HAS_EXEC_FENCE.
> >> >  - new userspace which unconditionally advertises the fence v2
> >> > extension IIRC one may tweak that things to only conditionally
> >> > advertise it, but IMHO it's not worth the hassle.
> >> >
> >> > Even then, Mesa can produce 20 DRI drivers (used by the EGL module)
> >> > so focusing on one doesn't quite work.
> >> >
> >> >>> >>  - don't introduce unused variables (in make_current)
> >> >>
> >> >> Done.
> >> >>
> >> >>> >>  - the create fd for the old display surface (in make_current)
> >> >>> >> seems bogus
> >> >>
> >> >> Done.
> >> >>
> >> > Did you drop it all together or changed to use some other surface?
> >> > Would be nice to hear the reason why it was added - perhaps I'm
> >> > missing something.
> >>
> >> We have to keep it, otherwise there would be no fence available at
> >> the time of surface destruction, while, at least for Android, a fence
> >> can be passed to window's cancelBuffer callback.
> >>
> >> >
> >> > I think that we want a fence/fd for the new draw surface. Since
> >> > otherwise one won't get created up until the first SwapBuffers call.
> >>
> >> I might be missing something, but wouldn't that insert a fence at the
> >> beginning of command stream, before even doing anything? At least in
> >> Android use cases, the only places we need the fence is in
> >> SwapBuffers and DestroySurface and the fence should be inserted after
> >> all the commands for rendering into given surface.
> >>
> >
> > Emil,
> >
> > Tomasz sounds convincing to me here, I just went ahead with the
> > comment to try out and flatland worked even after removing that.
> > Zhongmin can explain better but I think in earlier revisions this was
> > done for cancelBuffer to match with queueBuffer, I mean we are passing
> > valid fd for queueBuffer by doing this we would have a valid fd during
> cancelBuffer.  Not sure if this is the reason / one of the reason.
> >
> > I will go ahead with rest of your comments if we are ok to keep fd for
> > old display surface in make_current.
> 
> My understanding is that nobody actually cares about the fence that
> cancelBuffer returns, because the contents of the buffer are going to be
> discarded anyway and the buffer doesn't go to the consumer (e.g.
> flatland code that reads the timestamp). I even suspect that typically
> destroySurface would be called directly after swapBuffers and the surface
> wouldn't have a buffer to cancel. You can easily check this by adding a print
> before cancelBuffer call happens. So we might actually be fine with simpler 
> code
> that gets fence only for swapBuffers.
> 

Sure. I can confirm this.

> Changing the topic, the patch doesn't seem to change the implementation of
> swapBuffers to stop doing a flush on the buffer, which defeats the purpose of
> the fence, as the it is likely already signaled at the time it is passed to
> queueBuffer. S

Re: [Mesa-dev] [PATCH 1/5] clover/memory: Copy data when creating buffers with CL_MEM_USE_HOST_PTR

2017-08-04 Thread Grigori Goronzy

On 2017-08-03 22:26, Alex Deucher wrote:


IIRC, user_ptrs require page alignment.

Alex



I didn't follow the whole discussion (sorry if I'm saying something 
redundant), but AMD's older OpenCL Optimization Guide [1] has some notes 
regarding the implementation of the USE_HOST_PTR flag.
It initially recommends 4KB (aka page) alignment but also supports 
arbitrary alignment (with additional overhead, I suppose it pins an 
extra page for bad alignments). It also does some optimizations to 
minimize mapping/unmapping operations, called "pre-pinning". Not sure if 
that is applicable to Mesa/Clover, aren't (GTT) buffers usually mapped 
forever?


Grigori

[1] 
http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/12/AMD_OpenCL_Programming_Optimization_Guide.pdf




Right now it's hard-coded to R600_MAP_BUFFER_ALIGNMENT in si_pipe.c
and r600_pipe.c which has a value of 64 (bytes, I believe).





And also change si_pipe.c:si_get_param's switch statement value to 
return:

  case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
return sscreen->b.info.gart_page_size;


I'm not sure what the correct value is here. AFAIK, EG uses 256B 
cache

lines so I'd expect the value of to be at least that


Depending on how the weather works out tonight, I might be able to at
least find out what NI reports for gart page sizes and compare that to
my SI.  I haven't tried to test user pointer support on r600g yet, so
either it's working alright with the existing 64-byte alignment, or
it's broken when we allocate pointers using the actual alignments
reported by clGetDeviceInfo. If it's broken, I'll try 256B, then keep
bumping it up until it either starts working or I hit GART page size.

--Aaron



Both NI and GCN should be able to use 4K pages (which is what
gart_page_size is set to), but we might want higher alignment for
better performance[0]

[0]https://lists.freedesktop.org/archives/dri-devel/2014-May/058858.htm
l


Then I can successfully create buffers from user pointers on my SI 
card.


I'm a bit fuzzy on what alignment restrictions exist for SI/GCN 
cards,

but the winsys seems to indicate we should align things to gart page
size, which makes sense on the surface at least.

If the alignment restrictions have changed between R600 and GCN, 
that
might explain why what's broken for me is working for you/Grigori 
(on

r600).


I remember there was a buffer alignment patch form AMD recently for
SI/CI vs. VI+, but I can't find it.
It looks like a separate issue however. if incorrect alignment makes
user_ptr fail, and the test still fails, it looks like the 
no-user_ptr

fallback is broken.

Jan



--Aaron

>
> Jan
>
>
> >
> > Signed-off-by: Aaron Watry 
> > CC: Francisco Jerez 
> > ---
> >  src/gallium/state_trackers/clover/core/memory.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/gallium/state_trackers/clover/core/memory.cpp 
b/src/gallium/state_trackers/clover/core/memory.cpp
> > index b852e6896f..912d74830a 100644
> > --- a/src/gallium/state_trackers/clover/core/memory.cpp
> > +++ b/src/gallium/state_trackers/clover/core/memory.cpp
> > @@ -30,7 +30,7 @@ memory_obj::memory_obj(clover::context &ctx, cl_mem_flags 
flags,
> > size_t size, void *host_ptr) :
> > context(ctx), _flags(flags),
> > _size(size), _host_ptr(host_ptr) {
> > -   if (flags & CL_MEM_COPY_HOST_PTR)
> > +   if (flags & (CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR))
> >data.append((char *)host_ptr, size);
> >  }
> >
>
> --
> Jan Vesely 

___
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 mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 7/9] anv/allocator: Add a syncobj cache

2017-08-04 Thread Jason Ekstrand
On Fri, Aug 4, 2017 at 1:59 AM, Chris Wilson 
wrote:

> Quoting Jason Ekstrand (2017-08-04 02:25:26)
> > This is mostly a copy+paste of the BO cache but it's a bit simpler
> > because syncobjs don't have actual backing storage so we don't need to
> > check sizes or anything like that.  Also, we put the refcount directly
> > in anv_syncobj because they will always be heap pointers.
>
> Ok, but why do we need one at all? Some part of the Vk spec, some bad
> behaviour you noticed? Or just that it is more elegant to be minimalist?
>

Gah!  I thought I saw a real-world problem and decided the kernel must be
de-duplicating for me.  But now I remember that it doesn't and just looked
at the kernel code and confirmed that it gives you a new idr entry on every
fd_to_handle.  I'll delete all this garbage and go back to doing it the way
I was before.  Thanks for pointing that out!


> > ---
> >  src/intel/vulkan/anv_allocator.c | 194 ++
> +
> >  src/intel/vulkan/anv_device.c|   9 +-
> >  src/intel/vulkan/anv_private.h   |  40 
> >  3 files changed, 242 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_
> allocator.c
> > index efaaebc..204c466 100644
> > --- a/src/intel/vulkan/anv_allocator.c
> > +++ b/src/intel/vulkan/anv_allocator.c
> > @@ -1422,3 +1422,197 @@ anv_bo_cache_release(struct anv_device *device,
> >
> > vk_free(&device->alloc, bo);
> >  }
> > +
> > +VkResult
> > +anv_syncobj_cache_init(struct anv_syncobj_cache *cache)
> > +{
> > +   cache->map = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
> > +_mesa_key_pointer_equal);
>
> Not hash_uint for u32? Bah, for the number of ht mesa creates for
> looking up u32 names, you would think it would have an ultra-specialised
> data struct for it. :(
> -Chris
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 8/9] anv: Use DRM sync objects for external semaphores when available

2017-08-04 Thread Jason Ekstrand
On Fri, Aug 4, 2017 at 2:03 AM, Chris Wilson 
wrote:

> Quoting Jason Ekstrand (2017-08-04 02:25:27)
> > @@ -1497,6 +1569,12 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
> >setup_empty_execbuf(&execbuf, device);
> > }
> >
> > +   if (execbuf.fence_count > 0) {
>
> For sanity, since I just had to check, assert(device->has_syncobj);
>

Good call.


> > +  execbuf.execbuf.flags |= I915_EXEC_FENCE_ARRAY;
> > +  execbuf.execbuf.num_cliprects = execbuf.fence_count;
> > +  execbuf.execbuf.cliprects_ptr = (uintptr_t) execbuf.fences;
> > +   }
> > +
> > if (in_fence != -1) {
> >execbuf.execbuf.flags |= I915_EXEC_FENCE_IN;
> >execbuf.execbuf.rsvd2 |= (uint32_t)in_fence;
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] etnaviv: fix etna_bo_from_name

2017-08-04 Thread Philipp Zabel
On Fri, 2017-08-04 at 18:15 +0200, Wladimir J. van der Laan wrote:
> On Fri, Aug 04, 2017 at 05:07:54PM +0200, Philipp Zabel wrote:
> > Look up BOs from the name table using the name parameter instead of
> > req.handle (which at this point is always zero).
> 
> Good catch.
> 
> Just out of interest: when is this used, what problems does this cause?

It is used by the etnaviv gallium driver in etna_screen_bo_from_handle
for DRM_API_HANDLE_TYPE_SHARED handles. Since this just falls back to
asking the kernel to DRM_IOCTL_GEM_OPEN if the BO is not found in the
name_table already, this bug caused no problems.

regards
Philipp

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


[Mesa-dev] [Bug 102038] assertion failure in update_framebuffer_size

2017-08-04 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102038

--- Comment #1 from Brian Paul  ---
Sorry for the breakage, Brad.

I'll try to investigate ASAP, but I'm about to leave town for a week.

I can't repro with llmvpipe, fwiw.  I suspect it may be an issue in the swr
driver.  I'm building it now, but may run out of time.

-- 
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


[Mesa-dev] [Bug 102038] assertion failure in update_framebuffer_size

2017-08-04 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102038

--- Comment #2 from Brian Paul  ---
Hmm, swr isn't working at all for me.  It's hanging in a swr_fence_finish()
call with everything I've tried.  Even glxinfo hangs (but elsewhere).

Maybe one of the swr developers can take a look.

-- 
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


[Mesa-dev] [PATCH] egl: Clean up native_type vs drawable mess

2017-08-04 Thread Matt Turner
The next patch is going to stop passing XCB_WINDOW_NONE (of type
xcb_window_enum_t) as an argument where these functions expect a void *,
which clang does not appreciate.

This patch cleans things up to better convince me and reviewers that
it's safe to do that.
---
 src/egl/drivers/dri2/platform_x11.c  | 10 --
 src/egl/drivers/dri2/platform_x11_dri3.c |  6 +++---
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index c10cd84fce..063c50bcce 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -210,12 +210,8 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay 
*disp, EGLint type,
xcb_get_geometry_cookie_t cookie;
xcb_get_geometry_reply_t *reply;
xcb_generic_error_t *error;
-   xcb_drawable_t drawable;
const __DRIconfig *config;
 
-   STATIC_ASSERT(sizeof(uintptr_t) == sizeof(native_surface));
-   drawable = (uintptr_t) native_surface;
-
(void) drv;
 
dri2_surf = malloc(sizeof *dri2_surf);
@@ -234,14 +230,16 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay 
*disp, EGLint type,
dri2_surf->drawable, dri2_dpy->screen->root,
dri2_surf->base.Width, dri2_surf->base.Height);
} else {
-  if (!drawable) {
+  if (!native_surface) {
  if (type == EGL_WINDOW_BIT)
 _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
  else
 _eglError(EGL_BAD_NATIVE_PIXMAP, "dri2_create_surface");
  goto cleanup_surf;
   }
-  dri2_surf->drawable = drawable;
+
+  STATIC_ASSERT(sizeof(uintptr_t) == sizeof(native_surface));
+  dri2_surf->drawable = (uintptr_t) native_surface;
}
 
config = dri2_get_dri_config(dri2_conf, type,
diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c 
b/src/egl/drivers/dri2/platform_x11_dri3.c
index 515be27e20..df17cfa7aa 100644
--- a/src/egl/drivers/dri2/platform_x11_dri3.c
+++ b/src/egl/drivers/dri2/platform_x11_dri3.c
@@ -172,9 +172,6 @@ dri3_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
EGLint type,
const __DRIconfig *dri_config;
xcb_drawable_t drawable;
 
-   STATIC_ASSERT(sizeof(uintptr_t) == sizeof(native_surface));
-   drawable = (uintptr_t) native_surface;
-
(void) drv;
 
dri3_surf = calloc(1, sizeof *dri3_surf);
@@ -191,6 +188,9 @@ dri3_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
EGLint type,
   xcb_create_pixmap(dri2_dpy->conn, conf->BufferSize,
 drawable, dri2_dpy->screen->root,
 dri3_surf->base.Width, dri3_surf->base.Height);
+   } else {
+  STATIC_ASSERT(sizeof(uintptr_t) == sizeof(native_surface));
+  drawable = (uintptr_t) native_surface;
}
 
dri_config = dri2_get_dri_config(dri2_conf, type,
-- 
2.13.0

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


Re: [Mesa-dev] [PATCH 09/12] egl/x11: pass NULL instead of XCB_WINDOW_NONE as native_surface

2017-08-04 Thread Matt Turner
Thanks. I wrote the same patch some time ago, but never had a chance
to send it out. I'll send you another patch that I wrote to clear up
some of this confusion. I put it in my series immediately before this
patch. Feel free to add it to yours.

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


[Mesa-dev] [PATCH] docs: removed the '--with-sha1' requirement from shading.html

2017-08-04 Thread Eleni Maria Stea
The configuration option --with-sha1 is no longer required for the
MESA_SHADER_READ_PATH, MESA_SHADER_DUMP_PATH environment variables
to take effect.

1- removed the "--with-sha1" sentence from docs/shading.html
2- added an extra note: that the corresponding dumped and replacement
shaders must have the same filenames for the feature to take effect.
---
 docs/shading.html | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/shading.html b/docs/shading.html
index c789102e64..8b4cfb36a1 100644
--- a/docs/shading.html
+++ b/docs/shading.html
@@ -65,8 +65,7 @@ Example:  export MESA_GLSL=dump,nopt
 
 
 
-Shaders can be dumped and replaced on runtime for debugging purposes. Mesa 
-needs to be configured with '--with-sha1' to enable this functionality. This 
+Shaders can be dumped and replaced on runtime for debugging purposes. This
 feature is not currently supported by SCons build.
 
 This is controlled via following environment variables:
@@ -76,7 +75,8 @@ This is controlled via following environment variables:
 
 Note, path set must exist before running for dumping or replacing to work. 
 When both are set, these paths should be different so the dumped shaders do 
-not clobber the replacement shaders.
+not clobber the replacement shaders. Also, the filenames of the replacement 
shaders
+should match the filenames of the corresponding dumped shaders.
 
 
 GLSL Version
-- 
2.13.3

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


[Mesa-dev] [PATCH v3 0/8] anv: Implement VK_KHR_external_semaphore

2017-08-04 Thread Jason Ekstrand
This series is a quick re-spin of the v2 sent yesterday to address review
feedback from Chris.  In particular, we now set EXEC_ASYNC on the trivial
batch and I deleted the syncobj cache.  Somehow, when I was working on this
yesterday, I got it into my head that the kernel deduplicates syncobj
handles and that we needed a cache to handle them correctly.  This is not
true.  Every call to SYNCOBJ_FD_TO_HANDLE produces a new handle and the
kernel does the reference counting for us.

Cc: Chad Versace 
Cc: Kristian H. Kristensen 
Cc: Chris Wilson 

Jason Ekstrand (8):
  anv: Add a basic implementation of VK_KHX_external_semaphore
  anv: Submit a dummy batch when only semaphores are provided.
  anv/gem: Use EXECBUFFER2_WR when the FENCE_OUT flag is set
  anv: Implement support for exporting semaphores as FENCE_FD
  intel/drm: Pull in the i916 fence array API
  anv/gem: Add a drm syncobj support
  anv: Use DRM sync objects for external semaphores when available
  anv: Advertise VK_KHR_external_semaphore

 include/drm-uapi/i915_drm.h|  30 +++-
 src/intel/vulkan/anv_batch_chain.c | 175 +++-
 src/intel/vulkan/anv_device.c  |  32 +
 src/intel/vulkan/anv_extensions.py |   3 +
 src/intel/vulkan/anv_gem.c |  93 -
 src/intel/vulkan/anv_gem_stubs.c   |  24 
 src/intel/vulkan/anv_private.h |  39 +-
 src/intel/vulkan/anv_queue.c   | 271 -
 8 files changed, 646 insertions(+), 21 deletions(-)

-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH v3 4/8] anv: Implement support for exporting semaphores as FENCE_FD

2017-08-04 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_batch_chain.c | 57 +--
 src/intel/vulkan/anv_device.c  |  1 +
 src/intel/vulkan/anv_gem.c | 36 
 src/intel/vulkan/anv_private.h | 23 +
 src/intel/vulkan/anv_queue.c   | 69 --
 5 files changed, 175 insertions(+), 11 deletions(-)

diff --git a/src/intel/vulkan/anv_batch_chain.c 
b/src/intel/vulkan/anv_batch_chain.c
index 65fe366..7a84bbd 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -1416,11 +1416,13 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
struct anv_execbuf execbuf;
anv_execbuf_init(&execbuf);
 
+   int in_fence = -1;
VkResult result = VK_SUCCESS;
for (uint32_t i = 0; i < num_in_semaphores; i++) {
   ANV_FROM_HANDLE(anv_semaphore, semaphore, in_semaphores[i]);
-  assert(semaphore->temporary.type == ANV_SEMAPHORE_TYPE_NONE);
-  struct anv_semaphore_impl *impl = &semaphore->permanent;
+  struct anv_semaphore_impl *impl =
+ semaphore->temporary.type != ANV_SEMAPHORE_TYPE_NONE ?
+ &semaphore->temporary : &semaphore->permanent;
 
   switch (impl->type) {
   case ANV_SEMAPHORE_TYPE_BO:
@@ -1429,11 +1431,29 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
  if (result != VK_SUCCESS)
 return result;
  break;
+
+  case ANV_SEMAPHORE_TYPE_SYNC_FILE:
+ if (in_fence == -1) {
+in_fence = impl->fd;
+ } else {
+int merge = anv_gem_sync_file_merge(device, in_fence, impl->fd);
+if (merge == -1)
+   return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
+
+close(impl->fd);
+close(in_fence);
+in_fence = merge;
+ }
+
+ impl->fd = -1;
+ break;
+
   default:
  break;
   }
}
 
+   bool need_out_fence = false;
for (uint32_t i = 0; i < num_out_semaphores; i++) {
   ANV_FROM_HANDLE(anv_semaphore, semaphore, out_semaphores[i]);
 
@@ -1459,6 +1479,11 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
  if (result != VK_SUCCESS)
 return result;
  break;
+
+  case ANV_SEMAPHORE_TYPE_SYNC_FILE:
+ need_out_fence = true;
+ break;
+
   default:
  break;
   }
@@ -1472,9 +1497,19 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
   setup_empty_execbuf(&execbuf, device);
}
 
+   if (in_fence != -1) {
+  execbuf.execbuf.flags |= I915_EXEC_FENCE_IN;
+  execbuf.execbuf.rsvd2 |= (uint32_t)in_fence;
+   }
+
+   if (need_out_fence)
+  execbuf.execbuf.flags |= I915_EXEC_FENCE_OUT;
 
result = anv_device_execbuf(device, &execbuf.execbuf, execbuf.bos);
 
+   /* Execbuf does not consume the in_fence.  It's our job to close it. */
+   close(in_fence);
+
for (uint32_t i = 0; i < num_in_semaphores; i++) {
   ANV_FROM_HANDLE(anv_semaphore, semaphore, in_semaphores[i]);
   /* From the Vulkan 1.0.53 spec:
@@ -1489,6 +1524,24 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
   anv_semaphore_reset_temporary(device, semaphore);
}
 
+   if (result == VK_SUCCESS && need_out_fence) {
+  int out_fence = execbuf.execbuf.rsvd2 >> 32;
+  for (uint32_t i = 0; i < num_out_semaphores; i++) {
+ ANV_FROM_HANDLE(anv_semaphore, semaphore, out_semaphores[i]);
+ /* Out fences can't have temporary state because that would imply
+  * that we imported a sync file and are trying to signal it.
+  */
+ assert(semaphore->temporary.type == ANV_SEMAPHORE_TYPE_NONE);
+ struct anv_semaphore_impl *impl = &semaphore->permanent;
+
+ if (impl->type == ANV_SEMAPHORE_TYPE_SYNC_FILE) {
+assert(impl->fd == -1);
+impl->fd = dup(out_fence);
+ }
+  }
+  close(out_fence);
+   }
+
anv_execbuf_finish(&execbuf, &device->alloc);
 
return result;
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index e82e1e9..3c5f78c 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -337,6 +337,7 @@ anv_physical_device_init(struct anv_physical_device *device,
   goto fail;
 
device->has_exec_async = anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_ASYNC);
+   device->has_exec_fence = anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_FENCE);
 
bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X);
 
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 36692f5..5b68e9b 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -22,6 +22,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -400,3 +401,38 @@ anv_gem_fd_to_handle(struct anv_device *device, int fd)
 
return args.handle;
 }
+
+#ifndef SYNC_IOC_MAGIC
+/* duplicated from linux/sync_file.h to avoid build-time depnedency
+ * on new (v4.7) kernel headers.  Once distro's are mostly using
+

[Mesa-dev] [PATCH v3 2/8] anv: Submit a dummy batch when only semaphores are provided.

2017-08-04 Thread Jason Ekstrand
Vulkan allows you to do a submit whose only job is to wait on and
trigger semaphores.  The easiest way for us to support that right
now is to insert a dummy execbuf.
---
 src/intel/vulkan/anv_batch_chain.c | 28 +---
 src/intel/vulkan/anv_device.c  | 30 ++
 src/intel/vulkan/anv_private.h |  1 +
 src/intel/vulkan/anv_queue.c   | 17 +
 4 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_batch_chain.c 
b/src/intel/vulkan/anv_batch_chain.c
index 94e7a7d..65fe366 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -1388,6 +1388,23 @@ setup_execbuf_for_cmd_buffer(struct anv_execbuf *execbuf,
return VK_SUCCESS;
 }
 
+static void
+setup_empty_execbuf(struct anv_execbuf *execbuf, struct anv_device *device)
+{
+   anv_execbuf_add_bo(execbuf, &device->trivial_batch_bo, NULL, 0,
+  &device->alloc);
+
+   execbuf->execbuf = (struct drm_i915_gem_execbuffer2) {
+  .buffers_ptr = (uintptr_t) execbuf->objects,
+  .buffer_count = execbuf->bo_count,
+  .batch_start_offset = 0,
+  .batch_len = 8, /* GEN8_MI_BATCH_BUFFER_END and NOOP */
+  .flags = I915_EXEC_HANDLE_LUT | I915_EXEC_RENDER,
+  .rsvd1 = device->context_id,
+  .rsvd2 = 0,
+   };
+}
+
 VkResult
 anv_cmd_buffer_execbuf(struct anv_device *device,
struct anv_cmd_buffer *cmd_buffer,
@@ -1447,9 +1464,14 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
   }
}
 
-   result = setup_execbuf_for_cmd_buffer(&execbuf, cmd_buffer);
-   if (result != VK_SUCCESS)
-  return result;
+   if (cmd_buffer) {
+  result = setup_execbuf_for_cmd_buffer(&execbuf, cmd_buffer);
+  if (result != VK_SUCCESS)
+ return result;
+   } else {
+  setup_empty_execbuf(&execbuf, device);
+   }
+
 
result = anv_device_execbuf(device, &execbuf.execbuf, execbuf.bos);
 
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 793e519..e82e1e9 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1014,6 +1014,32 @@ anv_device_init_border_colors(struct anv_device *device)
 border_colors);
 }
 
+static void
+anv_device_init_trivial_batch(struct anv_device *device)
+{
+   anv_bo_init_new(&device->trivial_batch_bo, device, 4096);
+
+   if (device->instance->physicalDevice.has_exec_async)
+  device->trivial_batch_bo.flags |= EXEC_OBJECT_ASYNC;
+
+   void *map = anv_gem_mmap(device, device->trivial_batch_bo.gem_handle,
+0, 4096, 0);
+
+   struct anv_batch batch = {
+  .start = map,
+  .next = map,
+  .end = map + 4096,
+   };
+
+   anv_batch_emit(&batch, GEN7_MI_BATCH_BUFFER_END, bbe);
+   anv_batch_emit(&batch, GEN7_MI_NOOP, noop);
+
+   if (!device->info.has_llc)
+  gen_clflush_range(map, batch.next - map);
+
+   anv_gem_munmap(map, device->trivial_batch_bo.size);
+}
+
 VkResult anv_CreateDevice(
 VkPhysicalDevicephysicalDevice,
 const VkDeviceCreateInfo*   pCreateInfo,
@@ -1131,6 +1157,8 @@ VkResult anv_CreateDevice(
if (result != VK_SUCCESS)
   goto fail_surface_state_pool;
 
+   anv_device_init_trivial_batch(device);
+
anv_scratch_pool_init(device, &device->scratch_pool);
 
anv_queue_init(device, &device->queue);
@@ -1220,6 +1248,8 @@ void anv_DestroyDevice(
anv_gem_munmap(device->workaround_bo.map, device->workaround_bo.size);
anv_gem_close(device, device->workaround_bo.gem_handle);
 
+   anv_gem_close(device, device->trivial_batch_bo.gem_handle);
+
anv_state_pool_finish(&device->surface_state_pool);
anv_state_pool_finish(&device->instruction_state_pool);
anv_state_pool_finish(&device->dynamic_state_pool);
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index b599db3..bc67bb6 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -745,6 +745,7 @@ struct anv_device {
 struct anv_state_pool   surface_state_pool;
 
 struct anv_bo   workaround_bo;
+struct anv_bo   trivial_batch_bo;
 
 struct anv_pipeline_cache   blorp_shader_cache;
 struct blorp_contextblorp;
diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
index 9a0789c..039dfd7 100644
--- a/src/intel/vulkan/anv_queue.c
+++ b/src/intel/vulkan/anv_queue.c
@@ -159,6 +159,23 @@ VkResult anv_QueueSubmit(
pthread_mutex_lock(&device->mutex);
 
for (uint32_t i = 0; i < submitCount; i++) {
+  if (pSubmits[i].commandBufferCount == 0) {
+ /* If we don't have any command buffers, we need to submit a dummy
+  * batch to give GEM something to wait on.  We could, potentially,
+  * come up with something more efficient but this

[Mesa-dev] [PATCH v3 1/8] anv: Add a basic implementation of VK_KHX_external_semaphore

2017-08-04 Thread Jason Ekstrand
This patch adds an implementation based on DRM BOs.  We don't actually
advertise the extension yet because we want to add a couple more paths
first.
---
 src/intel/vulkan/anv_batch_chain.c |  31 +++-
 src/intel/vulkan/anv_extensions.py |   3 +
 src/intel/vulkan/anv_private.h |   3 +
 src/intel/vulkan/anv_queue.c   | 154 +++--
 4 files changed, 184 insertions(+), 7 deletions(-)

diff --git a/src/intel/vulkan/anv_batch_chain.c 
b/src/intel/vulkan/anv_batch_chain.c
index ad76dc1..94e7a7d 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -1419,8 +1419,21 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
 
for (uint32_t i = 0; i < num_out_semaphores; i++) {
   ANV_FROM_HANDLE(anv_semaphore, semaphore, out_semaphores[i]);
-  assert(semaphore->temporary.type == ANV_SEMAPHORE_TYPE_NONE);
-  struct anv_semaphore_impl *impl = &semaphore->permanent;
+
+  /* Under most circumstances, out fences won't be temporary.  However,
+   * the spec does allow it for opaque_fd.  From the Vulkan 1.0.53 spec:
+   *
+   *"If the import is temporary, the implementation must restore the
+   *semaphore to its prior permanent state after submitting the next
+   *semaphore wait operation."
+   *
+   * The spec says nothing whatsoever about signal operations on
+   * temporarily imported semaphores so it appears they are allowed.
+   * There are also CTS tests that require this to work.
+   */
+  struct anv_semaphore_impl *impl =
+ semaphore->temporary.type != ANV_SEMAPHORE_TYPE_NONE ?
+ &semaphore->temporary : &semaphore->permanent;
 
   switch (impl->type) {
   case ANV_SEMAPHORE_TYPE_BO:
@@ -1440,6 +1453,20 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
 
result = anv_device_execbuf(device, &execbuf.execbuf, execbuf.bos);
 
+   for (uint32_t i = 0; i < num_in_semaphores; i++) {
+  ANV_FROM_HANDLE(anv_semaphore, semaphore, in_semaphores[i]);
+  /* From the Vulkan 1.0.53 spec:
+   *
+   *"If the import is temporary, the implementation must restore the
+   *semaphore to its prior permanent state after submitting the next
+   *semaphore wait operation."
+   *
+   * This has to happen after the execbuf in case we close any syncobjs in
+   * the process.
+   */
+  anv_semaphore_reset_temporary(device, semaphore);
+   }
+
anv_execbuf_finish(&execbuf, &device->alloc);
 
return result;
diff --git a/src/intel/vulkan/anv_extensions.py 
b/src/intel/vulkan/anv_extensions.py
index ae22249..00186bc 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -50,6 +50,9 @@ EXTENSIONS = [
 Extension('VK_KHR_external_memory',   1, True),
 Extension('VK_KHR_external_memory_capabilities',  1, True),
 Extension('VK_KHR_external_memory_fd',1, True),
+Extension('VK_KHR_external_semaphore',1, False),
+Extension('VK_KHR_external_semaphore_capabilities',   1, False),
+Extension('VK_KHR_external_semaphore_fd', 1, False),
 Extension('VK_KHR_get_memory_requirements2',  1, True),
 Extension('VK_KHR_get_physical_device_properties2',   1, True),
 Extension('VK_KHR_get_surface_capabilities2', 1, True),
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index c364491..b599db3 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1765,6 +1765,9 @@ struct anv_semaphore {
struct anv_semaphore_impl temporary;
 };
 
+void anv_semaphore_reset_temporary(struct anv_device *device,
+   struct anv_semaphore *semaphore);
+
 struct anv_shader_module {
unsigned charsha1[20];
uint32_t size;
diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
index 2c10e9d..9a0789c 100644
--- a/src/intel/vulkan/anv_queue.c
+++ b/src/intel/vulkan/anv_queue.c
@@ -528,11 +528,38 @@ VkResult anv_CreateSemaphore(
if (semaphore == NULL)
   return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-   /* The DRM execbuffer ioctl always execute in-oder so long as you stay
-* on the same ring.  Since we don't expose the blit engine as a DMA
-* queue, a dummy no-op semaphore is a perfectly valid implementation.
-*/
-   semaphore->permanent.type = ANV_SEMAPHORE_TYPE_DUMMY;
+   const VkExportSemaphoreCreateInfoKHR *export =
+  vk_find_struct_const(pCreateInfo->pNext, 
EXPORT_SEMAPHORE_CREATE_INFO_KHR);
+VkExternalSemaphoreHandleTypeFlagsKHR handleTypes =
+  export ? export->handleTypes : 0;
+
+   if (handleTypes == 0) {
+  /* The DRM execbuffer ioctl always execute in-oder so long as you stay
+   * on the same ring.  Since we don't expose the blit engine as a DMA
+   * queue, a dummy no-o

[Mesa-dev] [PATCH v3 3/8] anv/gem: Use EXECBUFFER2_WR when the FENCE_OUT flag is set

2017-08-04 Thread Jason Ekstrand
Reviewed-by: Chad Versace 
---
 src/intel/vulkan/anv_gem.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index ac47da4..36692f5 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -185,7 +185,10 @@ int
 anv_gem_execbuffer(struct anv_device *device,
struct drm_i915_gem_execbuffer2 *execbuf)
 {
-   return anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
+   if (execbuf->flags & I915_EXEC_FENCE_OUT)
+  return anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf);
+   else
+  return anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
 }
 
 int
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH v3 5/8] intel/drm: Pull in the i916 fence array API

2017-08-04 Thread Jason Ekstrand
---
 include/drm-uapi/i915_drm.h | 30 --
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/include/drm-uapi/i915_drm.h b/include/drm-uapi/i915_drm.h
index c26bf7c..338c8c2 100644
--- a/include/drm-uapi/i915_drm.h
+++ b/include/drm-uapi/i915_drm.h
@@ -431,6 +431,11 @@ typedef struct drm_i915_irq_wait {
  */
 #define I915_PARAM_HAS_EXEC_BATCH_FIRST 48
 
+/* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of
+ * drm_i915_gem_exec_fence structures.  See I915_EXEC_FENCE_ARRAY.
+ */
+#define I915_PARAM_HAS_EXEC_FENCE_ARRAY  49
+
 typedef struct drm_i915_getparam {
__s32 param;
/*
@@ -812,6 +817,17 @@ struct drm_i915_gem_exec_object2 {
__u64 rsvd2;
 };
 
+struct drm_i915_gem_exec_fence {
+   /**
+* User's handle for a dma-fence to wait on or signal.
+*/
+   __u32 handle;
+
+#define I915_EXEC_FENCE_WAIT(1<<0)
+#define I915_EXEC_FENCE_SIGNAL  (1<<1)
+   __u32 flags;
+};
+
 struct drm_i915_gem_execbuffer2 {
/**
 * List of gem_exec_object2 structs
@@ -826,7 +842,10 @@ struct drm_i915_gem_execbuffer2 {
__u32 DR1;
__u32 DR4;
__u32 num_cliprects;
-   /** This is a struct drm_clip_rect *cliprects */
+   /** This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY
+ * is not set.  If I915_EXEC_FENCE_ARRAY is set, then this is a
+ * struct drm_i915_gem_exec_fence *fences.
+ */
__u64 cliprects_ptr;
 #define I915_EXEC_RING_MASK  (7<<0)
 #define I915_EXEC_DEFAULT(0<<0)
@@ -927,7 +946,14 @@ struct drm_i915_gem_execbuffer2 {
  * element).
  */
 #define I915_EXEC_BATCH_FIRST  (1<<18)
-#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_BATCH_FIRST<<1))
+
+/* Setting I915_FENCE_ARRAY implies that num_cliprects and cliprects_ptr
+ * define an array of i915_gem_exec_fence structures which specify a set of
+ * dma fences to wait upon or signal.
+ */
+#define I915_EXEC_FENCE_ARRAY   (1<<19)
+
+#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_ARRAY<<1))
 
 #define I915_EXEC_CONTEXT_ID_MASK  (0x)
 #define i915_execbuffer2_set_context_id(eb2, context) \
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH v3 8/8] anv: Advertise VK_KHR_external_semaphore

2017-08-04 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_extensions.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_extensions.py 
b/src/intel/vulkan/anv_extensions.py
index 00186bc..3252e0f 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -50,9 +50,9 @@ EXTENSIONS = [
 Extension('VK_KHR_external_memory',   1, True),
 Extension('VK_KHR_external_memory_capabilities',  1, True),
 Extension('VK_KHR_external_memory_fd',1, True),
-Extension('VK_KHR_external_semaphore',1, False),
-Extension('VK_KHR_external_semaphore_capabilities',   1, False),
-Extension('VK_KHR_external_semaphore_fd', 1, False),
+Extension('VK_KHR_external_semaphore',1, True),
+Extension('VK_KHR_external_semaphore_capabilities',   1, True),
+Extension('VK_KHR_external_semaphore_fd', 1, True),
 Extension('VK_KHR_get_memory_requirements2',  1, True),
 Extension('VK_KHR_get_physical_device_properties2',   1, True),
 Extension('VK_KHR_get_surface_capabilities2', 1, True),
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH v3 6/8] anv/gem: Add a drm syncobj support

2017-08-04 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_gem.c   | 52 
 src/intel/vulkan/anv_gem_stubs.c | 24 +++
 src/intel/vulkan/anv_private.h   |  4 
 3 files changed, 80 insertions(+)

diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 5b68e9b..9e6b2bb 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -436,3 +436,55 @@ anv_gem_sync_file_merge(struct anv_device *device, int 
fd1, int fd2)
 
return args.fence;
 }
+
+uint32_t
+anv_gem_syncobj_create(struct anv_device *device)
+{
+   struct drm_syncobj_create args = {
+  .flags = 0,
+   };
+
+   int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
+   if (ret)
+  return 0;
+
+   return args.handle;
+}
+
+void
+anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
+{
+   struct drm_syncobj_destroy args = {
+  .handle = handle,
+   };
+
+   anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
+}
+
+int
+anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
+{
+   struct drm_syncobj_handle args = {
+  .handle = handle,
+   };
+
+   int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
+   if (ret)
+  return -1;
+
+   return args.fd;
+}
+
+uint32_t
+anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
+{
+   struct drm_syncobj_handle args = {
+  .fd = fd,
+   };
+
+   int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
+   if (ret)
+  return 0;
+
+   return args.handle;
+}
diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c
index 8d81eb5..842efb3 100644
--- a/src/intel/vulkan/anv_gem_stubs.c
+++ b/src/intel/vulkan/anv_gem_stubs.c
@@ -180,3 +180,27 @@ anv_gem_fd_to_handle(struct anv_device *device, int fd)
 {
unreachable("Unused");
 }
+
+uint32_t
+anv_gem_syncobj_create(struct anv_device *device)
+{
+   unreachable("Unused");
+}
+
+void
+anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
+{
+   unreachable("Unused");
+}
+
+int
+anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
+{
+   unreachable("Unused");
+}
+
+uint32_t
+anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
+{
+   unreachable("Unused");
+}
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 5c7b3b4..b451fa5 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -812,6 +812,10 @@ int anv_gem_set_caching(struct anv_device *device, 
uint32_t gem_handle, uint32_t
 int anv_gem_set_domain(struct anv_device *device, uint32_t gem_handle,
uint32_t read_domains, uint32_t write_domain);
 int anv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2);
+uint32_t anv_gem_syncobj_create(struct anv_device *device);
+void anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle);
+int anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle);
+uint32_t anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd);
 
 VkResult anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, 
uint64_t size);
 
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH v3 7/8] anv: Use DRM sync objects for external semaphores when available

2017-08-04 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_batch_chain.c | 59 +++
 src/intel/vulkan/anv_device.c  |  1 +
 src/intel/vulkan/anv_private.h |  8 
 src/intel/vulkan/anv_queue.c   | 83 +++---
 4 files changed, 128 insertions(+), 23 deletions(-)

diff --git a/src/intel/vulkan/anv_batch_chain.c 
b/src/intel/vulkan/anv_batch_chain.c
index 7a84bbd..e670ad7 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -957,6 +957,11 @@ struct anv_execbuf {
 
/* Allocated length of the 'objects' and 'bos' arrays */
uint32_t  array_length;
+
+   uint32_t  fence_count;
+   uint32_t  fence_array_length;
+   struct drm_i915_gem_exec_fence *  fences;
+   struct anv_syncobj ** syncobjs;
 };
 
 static void
@@ -971,6 +976,8 @@ anv_execbuf_finish(struct anv_execbuf *exec,
 {
vk_free(alloc, exec->objects);
vk_free(alloc, exec->bos);
+   vk_free(alloc, exec->fences);
+   vk_free(alloc, exec->syncobjs);
 }
 
 static VkResult
@@ -1061,6 +1068,35 @@ anv_execbuf_add_bo(struct anv_execbuf *exec,
return VK_SUCCESS;
 }
 
+static VkResult
+anv_execbuf_add_syncobj(struct anv_execbuf *exec,
+uint32_t handle, uint32_t flags,
+const VkAllocationCallbacks *alloc)
+{
+   assert(flags != 0);
+
+   if (exec->fence_count >= exec->fence_array_length) {
+  uint32_t new_len = MAX2(exec->fence_array_length * 2, 64);
+
+  exec->fences = vk_realloc(alloc, exec->fences,
+new_len * sizeof(*exec->fences),
+8, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
+  if (exec->fences == NULL)
+ return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+
+  exec->fence_array_length = new_len;
+   }
+
+   exec->fences[exec->fence_count] = (struct drm_i915_gem_exec_fence) {
+  .handle = handle,
+  .flags = flags,
+   };
+
+   exec->fence_count++;
+
+   return VK_SUCCESS;
+}
+
 static void
 anv_cmd_buffer_process_relocs(struct anv_cmd_buffer *cmd_buffer,
   struct anv_reloc_list *list)
@@ -1448,6 +1484,14 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
  impl->fd = -1;
  break;
 
+  case ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ:
+ result = anv_execbuf_add_syncobj(&execbuf, impl->syncobj,
+  I915_EXEC_FENCE_WAIT,
+  &device->alloc);
+ if (result != VK_SUCCESS)
+return result;
+ break;
+
   default:
  break;
   }
@@ -1484,6 +1528,14 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
  need_out_fence = true;
  break;
 
+  case ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ:
+ result = anv_execbuf_add_syncobj(&execbuf, impl->syncobj,
+  I915_EXEC_FENCE_SIGNAL,
+  &device->alloc);
+ if (result != VK_SUCCESS)
+return result;
+ break;
+
   default:
  break;
   }
@@ -1497,6 +1549,13 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
   setup_empty_execbuf(&execbuf, device);
}
 
+   if (execbuf.fence_count > 0) {
+  assert(device->instance->physicalDevice.has_syncobj);
+  execbuf.execbuf.flags |= I915_EXEC_FENCE_ARRAY;
+  execbuf.execbuf.num_cliprects = execbuf.fence_count;
+  execbuf.execbuf.cliprects_ptr = (uintptr_t) execbuf.fences;
+   }
+
if (in_fence != -1) {
   execbuf.execbuf.flags |= I915_EXEC_FENCE_IN;
   execbuf.execbuf.rsvd2 |= (uint32_t)in_fence;
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 3c5f78c..a6d5215 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -338,6 +338,7 @@ anv_physical_device_init(struct anv_physical_device *device,
 
device->has_exec_async = anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_ASYNC);
device->has_exec_fence = anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_FENCE);
+   device->has_syncobj = anv_gem_get_param(fd, 
I915_PARAM_HAS_EXEC_FENCE_ARRAY);
 
bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X);
 
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index b451fa5..de74637 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -653,6 +653,7 @@ struct anv_physical_device {
 int cmd_parser_version;
 boolhas_exec_async;
 boolhas_exec_fence;
+boolhas_syncobj;
 
 uint32_teu_total;
 uint32_tsubslice_total;
@@ -1742,6 +1743,7 @@ enum anv_semaphore_type {
ANV_SEMAPHOR

[Mesa-dev] [PATCH 02/25] i965: Move compaction "prepass" into brw_eu_compact.c

2017-08-04 Thread Matt Turner
---
 src/intel/compiler/brw_eu_compact.c | 82 -
 src/intel/compiler/brw_eu_emit.c| 72 +---
 2 files changed, 82 insertions(+), 72 deletions(-)

diff --git a/src/intel/compiler/brw_eu_compact.c 
b/src/intel/compiler/brw_eu_compact.c
index a940e214f2..bf57ddf85c 100644
--- a/src/intel/compiler/brw_eu_compact.c
+++ b/src/intel/compiler/brw_eu_compact.c
@@ -956,6 +956,83 @@ is_compactable_immediate(unsigned imm)
 }
 
 /**
+ * Applies some small changes to instruction types to increase chances of
+ * compaction.
+ */
+static brw_inst
+precompact(const struct gen_device_info *devinfo, brw_inst inst)
+{
+   if (brw_inst_src0_reg_file(devinfo, &inst) != BRW_IMMEDIATE_VALUE)
+  return inst;
+
+   /* The Bspec's section titled "Non-present Operands" claims that if src0
+* is an immediate that src1's type must be the same as that of src0.
+*
+* The SNB+ DataTypeIndex instruction compaction tables contain mappings
+* that do not follow this rule. E.g., from the IVB/HSW table:
+*
+*  DataTypeIndex   18-Bit Mapping   Mapped Meaning
+*3 0010101101   r:f | i:vf | a:ud | <1> | dir |
+*
+* And from the SNB table:
+*
+*  DataTypeIndex   18-Bit Mapping   Mapped Meaning
+*8 0010001100   a:w | i:w | a:ud | <1> | dir |
+*
+* Neither of these cause warnings from the simulator when used,
+* compacted or otherwise. In fact, all compaction mappings that have an
+* immediate in src0 use a:ud for src1.
+*
+* The GM45 instruction compaction tables do not contain mapped meanings
+* so it's not clear whether it has the restriction. We'll assume it was
+* lifted on SNB. (FINISHME: decode the GM45 tables and check.)
+*
+* Don't do any of this for 64-bit immediates, since the src1 fields
+* overlap with the immediate and setting them would overwrite the
+* immediate we set.
+*/
+   if (devinfo->gen >= 6 &&
+   !(devinfo->is_haswell &&
+ brw_inst_opcode(devinfo, &inst) == BRW_OPCODE_DIM) &&
+   !(devinfo->gen >= 8 &&
+ (brw_inst_src0_reg_type(devinfo, &inst) == GEN8_HW_REG_IMM_TYPE_DF ||
+  brw_inst_src0_reg_type(devinfo, &inst) == GEN8_HW_REG_TYPE_UQ ||
+  brw_inst_src0_reg_type(devinfo, &inst) == GEN8_HW_REG_TYPE_Q))) {
+  brw_inst_set_src1_reg_type(devinfo, &inst, BRW_HW_REG_TYPE_UD);
+   }
+
+   /* Compacted instructions only have 12-bits (plus 1 for the other 20)
+* for immediate values. Presumably the hardware engineers realized
+* that the only useful floating-point value that could be represented
+* in this format is 0.0, which can also be represented as a VF-typed
+* immediate, so they gave us the previously mentioned mapping on IVB+.
+*
+* Strangely, we do have a mapping for imm:f in src1, so we don't need
+* to do this there.
+*
+* If we see a 0.0:F, change the type to VF so that it can be compacted.
+*/
+   if (brw_inst_imm_ud(devinfo, &inst) == 0x0 &&
+   brw_inst_src0_reg_type(devinfo, &inst) == BRW_HW_REG_TYPE_F &&
+   brw_inst_dst_reg_type(devinfo, &inst) != GEN7_HW_REG_NON_IMM_TYPE_DF) {
+  brw_inst_set_src0_reg_type(devinfo, &inst, BRW_HW_REG_IMM_TYPE_VF);
+   }
+
+   /* There are no mappings for dst:d | i:d, so if the immediate is suitable
+* set the types to :UD so the instruction can be compacted.
+*/
+   if (is_compactable_immediate(brw_inst_imm_ud(devinfo, &inst)) &&
+   brw_inst_cond_modifier(devinfo, &inst) == BRW_CONDITIONAL_NONE &&
+   brw_inst_src0_reg_type(devinfo, &inst) == BRW_HW_REG_TYPE_D &&
+   brw_inst_dst_reg_type(devinfo, &inst) == BRW_HW_REG_TYPE_D) {
+  brw_inst_set_src0_reg_type(devinfo, &inst, BRW_HW_REG_TYPE_UD);
+  brw_inst_set_dst_reg_type(devinfo, &inst, BRW_HW_REG_TYPE_UD);
+   }
+
+   return inst;
+}
+
+/**
  * Tries to compact instruction src into dst.
  *
  * It doesn't modify dst unless src is compactable, which is relied on by
@@ -1427,9 +1504,10 @@ brw_compact_instructions(struct brw_codegen *p, int 
start_offset,
   old_ip[offset / sizeof(brw_compact_inst)] = src_offset / 
sizeof(brw_inst);
   compacted_counts[src_offset / sizeof(brw_inst)] = compacted_count;
 
-  brw_inst saved = *src;
+  brw_inst inst = precompact(devinfo, *src);
+  brw_inst saved = inst;
 
-  if (brw_try_compact_instruction(devinfo, dst, src)) {
+  if (brw_try_compact_instruction(devinfo, dst, &inst)) {
  compacted_count++;
 
  if (INTEL_DEBUG) {
diff --git a/src/intel/compiler/brw_eu_emit.c b/src/intel/compiler/brw_eu_emit.c
index 0b0d67a5c5..8a6ec035cc 100644
--- a/src/intel/compiler/brw_eu_emit.c
+++ b/src/intel/compiler/brw_eu_emit.c
@@ -356,16 +356,6 @@ validate_reg(const struct gen_device_info *devinfo,
/* 10. Check destination issues. */
 }
 
-static bool
-is_compactable_immediate(unsigned imm)
-{
-   /* We get the low 1

[Mesa-dev] [PATCH 03/25] i965: Silence signed/unsigned comparison warning

2017-08-04 Thread Matt Turner
---
 src/intel/compiler/test_eu_compact.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/compiler/test_eu_compact.cpp 
b/src/intel/compiler/test_eu_compact.cpp
index 39e7f1a27c..1ef7e5ae7f 100644
--- a/src/intel/compiler/test_eu_compact.cpp
+++ b/src/intel/compiler/test_eu_compact.cpp
@@ -254,7 +254,7 @@ run_tests(const struct gen_device_info *devinfo)
brw_init_compaction_tables(devinfo);
bool fail = false;
 
-   for (int i = 0; i < ARRAY_SIZE(tests); i++) {
+   for (unsigned i = 0; i < ARRAY_SIZE(tests); i++) {
   for (int align_16 = 0; align_16 <= 1; align_16++) {
 struct brw_codegen *p = rzalloc(NULL, struct brw_codegen);
 brw_init_codegen(devinfo, p, p);
-- 
2.13.0

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


[Mesa-dev] [PATCH 00/25] i965: Switch to always using logical register types

2017-08-04 Thread Matt Turner
The mixture of hardware encodings and logical types has caused lots of
confusion. It's time to fix that.

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


[Mesa-dev] [PATCH 04/25] i965: Test instruction compaction on all supported Gens

2017-08-04 Thread Matt Turner
Note that there's no point in testing on G45, since its compaction is
the same as Gen5. Same logic applies to Gen7 variants and low-power
parts.
---
 src/intel/compiler/test_eu_compact.cpp | 50 --
 1 file changed, 42 insertions(+), 8 deletions(-)

diff --git a/src/intel/compiler/test_eu_compact.cpp 
b/src/intel/compiler/test_eu_compact.cpp
index 1ef7e5ae7f..668a972bfa 100644
--- a/src/intel/compiler/test_eu_compact.cpp
+++ b/src/intel/compiler/test_eu_compact.cpp
@@ -74,6 +74,13 @@ clear_pad_bits(const struct gen_device_info *devinfo, 
brw_inst *inst)
brw_inst_src1_reg_file(devinfo, inst) != BRW_IMMEDIATE_VALUE) {
   brw_inst_set_bits(inst, 127, 111, 0);
}
+
+   if (devinfo->gen == 8 && !devinfo->is_cherryview &&
+   is_3src(devinfo, (opcode)brw_inst_opcode(devinfo, inst))) {
+  brw_inst_set_bits(inst, 105, 105, 0);
+  brw_inst_set_bits(inst, 84, 84, 0);
+  brw_inst_set_bits(inst, 36, 35, 0);
+   }
 }
 
 static bool
@@ -87,13 +94,41 @@ skip_bit(const struct gen_device_info *devinfo, brw_inst 
*src, int bit)
if (bit == 29)
   return true;
 
-   /* pad bit */
-   if (bit == 47)
-  return true;
+   if (is_3src(devinfo, (opcode)brw_inst_opcode(devinfo, src))) {
+  if (devinfo->gen >= 9 || devinfo->is_cherryview) {
+ if (bit == 127)
+return true;
+  } else {
+ if (bit >= 126 && bit <= 127)
+return true;
 
-   /* pad bits */
-   if (bit >= 90 && bit <= 95)
-  return true;
+ if (bit == 105)
+return true;
+
+ if (bit == 84)
+return true;
+
+ if (bit >= 35 && bit <= 36)
+return true;
+  }
+   } else {
+  if (bit == 47)
+ return true;
+
+  if (devinfo->gen >= 8) {
+ if (bit == 11)
+return true;
+
+ if (bit == 95)
+return true;
+  } else {
+ if (devinfo->gen < 7 && bit == 90)
+return true;
+
+ if (bit >= 91 && bit <= 95)
+return true;
+  }
+   }
 
/* sometimes these are pad bits. */
if (brw_inst_opcode(devinfo, src) != BRW_OPCODE_SEND &&
@@ -289,10 +324,9 @@ int
 main(int argc, char **argv)
 {
struct gen_device_info *devinfo = (struct gen_device_info *)calloc(1, 
sizeof(*devinfo));
-   devinfo->gen = 6;
bool fail = false;
 
-   for (devinfo->gen = 6; devinfo->gen <= 7; devinfo->gen++) {
+   for (devinfo->gen = 5; devinfo->gen <= 9; devinfo->gen++) {
   fail |= run_tests(devinfo);
}
 
-- 
2.13.0

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


[Mesa-dev] [PATCH 01/25] i965: Mark src inst pointer const in compaction code

2017-08-04 Thread Matt Turner
---
 src/intel/compiler/brw_eu.h |  2 +-
 src/intel/compiler/brw_eu_compact.c | 23 ---
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h
index a3a9c63239..8e597b212a 100644
--- a/src/intel/compiler/brw_eu.h
+++ b/src/intel/compiler/brw_eu.h
@@ -542,7 +542,7 @@ void brw_compact_instructions(struct brw_codegen *p, int 
start_offset,
 void brw_uncompact_instruction(const struct gen_device_info *devinfo,
brw_inst *dst, brw_compact_inst *src);
 bool brw_try_compact_instruction(const struct gen_device_info *devinfo,
- brw_compact_inst *dst, brw_inst *src);
+ brw_compact_inst *dst, const brw_inst *src);
 
 void brw_debug_compact_uncompact(const struct gen_device_info *devinfo,
  brw_inst *orig, brw_inst *uncompacted);
diff --git a/src/intel/compiler/brw_eu_compact.c 
b/src/intel/compiler/brw_eu_compact.c
index 740a395f78..a940e214f2 100644
--- a/src/intel/compiler/brw_eu_compact.c
+++ b/src/intel/compiler/brw_eu_compact.c
@@ -671,7 +671,7 @@ static const uint16_t *src_index_table;
 
 static bool
 set_control_index(const struct gen_device_info *devinfo,
-  brw_compact_inst *dst, brw_inst *src)
+  brw_compact_inst *dst, const brw_inst *src)
 {
uint32_t uncompacted = devinfo->gen >= 8  /* 17b/G45; 19b/IVB+ */
   ? (brw_inst_bits(src, 33, 31) << 16) | /*  3b */
@@ -700,7 +700,7 @@ set_control_index(const struct gen_device_info *devinfo,
 
 static bool
 set_datatype_index(const struct gen_device_info *devinfo, brw_compact_inst 
*dst,
-   brw_inst *src)
+   const brw_inst *src)
 {
uint32_t uncompacted = devinfo->gen >= 8  /* 18b/G45+; 21b/BDW+ */
   ? (brw_inst_bits(src, 63, 61) << 18) | /*  3b */
@@ -721,7 +721,7 @@ set_datatype_index(const struct gen_device_info *devinfo, 
brw_compact_inst *dst,
 
 static bool
 set_subreg_index(const struct gen_device_info *devinfo, brw_compact_inst *dst,
- brw_inst *src, bool is_immediate)
+ const brw_inst *src, bool is_immediate)
 {
uint16_t uncompacted = /* 15b */
   (brw_inst_bits(src, 52, 48) << 0) | /*  5b */
@@ -756,7 +756,7 @@ get_src_index(uint16_t uncompacted,
 
 static bool
 set_src0_index(const struct gen_device_info *devinfo,
-   brw_compact_inst *dst, brw_inst *src)
+   brw_compact_inst *dst, const brw_inst *src)
 {
uint16_t compacted;
uint16_t uncompacted = brw_inst_bits(src, 88, 77); /* 12b */
@@ -771,7 +771,7 @@ set_src0_index(const struct gen_device_info *devinfo,
 
 static bool
 set_src1_index(const struct gen_device_info *devinfo, brw_compact_inst *dst,
-   brw_inst *src, bool is_immediate)
+   const brw_inst *src, bool is_immediate)
 {
uint16_t compacted;
 
@@ -791,7 +791,7 @@ set_src1_index(const struct gen_device_info *devinfo, 
brw_compact_inst *dst,
 
 static bool
 set_3src_control_index(const struct gen_device_info *devinfo,
-   brw_compact_inst *dst, brw_inst *src)
+   brw_compact_inst *dst, const brw_inst *src)
 {
assert(devinfo->gen >= 8);
 
@@ -814,7 +814,7 @@ set_3src_control_index(const struct gen_device_info 
*devinfo,
 
 static bool
 set_3src_source_index(const struct gen_device_info *devinfo,
-  brw_compact_inst *dst, brw_inst *src)
+  brw_compact_inst *dst, const brw_inst *src)
 {
assert(devinfo->gen >= 8);
 
@@ -847,7 +847,7 @@ set_3src_source_index(const struct gen_device_info *devinfo,
 }
 
 static bool
-has_unmapped_bits(const struct gen_device_info *devinfo, brw_inst *src)
+has_unmapped_bits(const struct gen_device_info *devinfo, const brw_inst *src)
 {
/* EOT can only be mapped on a send if the src1 is an immediate */
if ((brw_inst_opcode(devinfo, src) == BRW_OPCODE_SENDC ||
@@ -878,7 +878,8 @@ has_unmapped_bits(const struct gen_device_info *devinfo, 
brw_inst *src)
 }
 
 static bool
-has_3src_unmapped_bits(const struct gen_device_info *devinfo, brw_inst *src)
+has_3src_unmapped_bits(const struct gen_device_info *devinfo,
+   const brw_inst *src)
 {
/* Check for three-source instruction bits that don't map to any of the
 * fields of the compacted instruction.  All of them seem to be reserved
@@ -901,7 +902,7 @@ has_3src_unmapped_bits(const struct gen_device_info 
*devinfo, brw_inst *src)
 
 static bool
 brw_try_compact_3src_instruction(const struct gen_device_info *devinfo,
- brw_compact_inst *dst, brw_inst *src)
+ brw_compact_inst *dst, const brw_inst *src)
 {
assert(devinfo->gen >= 8);
 
@@ -962,7 +963,7 @@ is_compactable_immediate(unsigned imm)
  */
 bool
 brw_try_compact_instruction(const struct gen_device_info *devinfo,
-  

[Mesa-dev] [PATCH 08/25] i965: Validate destination restrictions with vector immediates

2017-08-04 Thread Matt Turner
---
 src/intel/compiler/brw_eu_emit.c| 13 +-
 src/intel/compiler/brw_eu_validate.c| 61 +
 src/intel/compiler/test_eu_validate.cpp | 79 +
 3 files changed, 141 insertions(+), 12 deletions(-)

diff --git a/src/intel/compiler/brw_eu_emit.c b/src/intel/compiler/brw_eu_emit.c
index 8a6ec035cc..6673e0741a 100644
--- a/src/intel/compiler/brw_eu_emit.c
+++ b/src/intel/compiler/brw_eu_emit.c
@@ -279,19 +279,8 @@ validate_reg(const struct gen_device_info *devinfo,
const int execsize_for_reg[] = {1, 2, 4, 8, 16, 32};
int width, hstride, vstride, execsize;
 
-   if (reg.file == BRW_IMMEDIATE_VALUE) {
-  /* 3.3.6: Region Parameters.  Restriction: Immediate vectors
-   * mean the destination has to be 128-bit aligned and the
-   * destination horiz stride has to be a word.
-   */
-  if (reg.type == BRW_REGISTER_TYPE_V) {
- unsigned UNUSED elem_size = brw_element_size(devinfo, inst, dst);
- assert(hstride_for_reg[brw_inst_dst_hstride(devinfo, inst)] *
-elem_size == 2);
-  }
-
+   if (reg.file == BRW_IMMEDIATE_VALUE)
   return;
-   }
 
if (reg.file == BRW_ARCHITECTURE_REGISTER_FILE &&
reg.file == BRW_ARF_NULL)
diff --git a/src/intel/compiler/brw_eu_validate.c 
b/src/intel/compiler/brw_eu_validate.c
index 827cd707c7..7f0595e6f8 100644
--- a/src/intel/compiler/brw_eu_validate.c
+++ b/src/intel/compiler/brw_eu_validate.c
@@ -1036,6 +1036,66 @@ region_alignment_rules(const struct gen_device_info 
*devinfo,
return error_msg;
 }
 
+static struct string
+vector_immediate_restrictions(const struct gen_device_info *devinfo,
+  const brw_inst *inst)
+{
+   unsigned num_sources = num_sources_from_inst(devinfo, inst);
+   struct string error_msg = { .str = NULL, .len = 0 };
+
+   if (num_sources == 3 || num_sources == 0)
+  return (struct string){};
+
+   unsigned file = num_sources == 1 ?
+   brw_inst_src0_reg_file(devinfo, inst) :
+   brw_inst_src1_reg_file(devinfo, inst);
+   if (file != BRW_IMMEDIATE_VALUE)
+  return (struct string){};
+
+   unsigned dst_type_size = brw_element_size(devinfo, inst, dst);
+   unsigned dst_subreg = brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1 ?
+ brw_inst_dst_da1_subreg_nr(devinfo, inst) : 0;
+   unsigned dst_stride = 1 << (brw_inst_dst_hstride(devinfo, inst) - 1);
+   unsigned type = num_sources == 1 ?
+   brw_inst_src0_reg_type(devinfo, inst) :
+   brw_inst_src1_reg_type(devinfo, inst);
+
+   /* The PRMs say:
+*
+*When an immediate vector is used in an instruction, the destination
+*must be 128-bit aligned with destination horizontal stride equivalent
+*to a word for an immediate integer vector (v) and equivalent to a
+*DWord for an immediate float vector (vf).
+*
+* The text has not been updated for the addition of the immediate unsigned
+* integer vector type (uv) on SNB, but presumably the same restriction
+* applies.
+*/
+   switch (type) {
+   case BRW_HW_REG_IMM_TYPE_V:
+   case BRW_HW_REG_IMM_TYPE_UV:
+   case BRW_HW_REG_IMM_TYPE_VF:
+  ERROR_IF(dst_subreg % (128 / 8) != 0,
+   "Destination must be 128-bit aligned in order to use immediate "
+   "vector types");
+
+  if (type == BRW_HW_REG_IMM_TYPE_VF) {
+ ERROR_IF(dst_type_size * dst_stride != 4,
+  "Destination must have stride equivalent to dword in order "
+  "to use the VF type");
+  } else {
+ ERROR_IF(dst_type_size * dst_stride != 2,
+  "Destination must have stride equivalent to word in order "
+  "to use the V or UV type");
+  }
+  break;
+   default:
+  break;
+   }
+
+   return error_msg;
+}
+
 bool
 brw_validate_instructions(const struct gen_device_info *devinfo,
   void *assembly, int start_offset, int end_offset,
@@ -1063,6 +1123,7 @@ brw_validate_instructions(const struct gen_device_info 
*devinfo,
  CHECK(general_restrictions_based_on_operand_types);
  CHECK(general_restrictions_on_region_parameters);
  CHECK(region_alignment_rules);
+ CHECK(vector_immediate_restrictions);
   }
 
   if (error_msg.str && annotation) {
diff --git a/src/intel/compiler/test_eu_validate.cpp 
b/src/intel/compiler/test_eu_validate.cpp
index 09f4cc142a..b43c41704b 100644
--- a/src/intel/compiler/test_eu_validate.cpp
+++ b/src/intel/compiler/test_eu_validate.cpp
@@ -132,6 +132,7 @@ validate(struct brw_codegen *p)
 #define last_inst(&p->store[p->nr_insn - 1])
 #define g0   brw_vec8_grf(0, 0)
 #define null brw_null_reg()
+#define zero brw_imm_f(0.0f)
 
 static void
 clear_instructions(struct brw_codegen *p)
@@ -844,5 +845,83 @@ TEST_P(validation_test, byte_destination_relaxed_alignment)
} else {
 

  1   2   >