[Mesa-dev] [PATCH 2/3] mesa/glthread: enable immediate mode

2018-11-09 Thread Marek Olšák
From: Marek Olšák 

---
 src/mapi/glapi/gen/gl_API.xml |  2 +-
 src/mesa/vbo/vbo_exec_api.c   | 14 ++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index aae9a5835db..929e5f6b024 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -1141,21 +1141,21 @@
 
 
 
 
 
 
 
 
 
 
-
+
 
 
 
 
 
 
 
 
 
 
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 24bd1f0ba14..e46922ef859 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -796,25 +796,28 @@ vbo_exec_Begin(GLenum mode)
exec->vtx.prim[i].pad = 0;
exec->vtx.prim[i].start = exec->vtx.vert_count;
exec->vtx.prim[i].count = 0;
exec->vtx.prim[i].num_instances = 1;
exec->vtx.prim[i].base_instance = 0;
exec->vtx.prim[i].is_indirect = 0;
 
ctx->Driver.CurrentExecPrimitive = mode;
 
ctx->Exec = ctx->BeginEnd;
+
/* We may have been called from a display list, in which case we should
 * leave dlist.c's dispatch table in place.
 */
-   if (ctx->CurrentClientDispatch == ctx->OutsideBeginEnd) {
-  ctx->CurrentClientDispatch = ctx->BeginEnd;
+   if (ctx->CurrentClientDispatch == ctx->MarshalExec) {
+  ctx->CurrentServerDispatch = ctx->Exec;
+   } else if (ctx->CurrentClientDispatch == ctx->OutsideBeginEnd) {
+  ctx->CurrentClientDispatch = ctx->Exec;
   _glapi_set_dispatch(ctx->CurrentClientDispatch);
} else {
   assert(ctx->CurrentClientDispatch == ctx->Save);
}
 }
 
 
 /**
  * Try to merge / concatenate the two most recent VBO primitives.
  */
@@ -851,22 +854,25 @@ vbo_exec_End(void)
 {
GET_CURRENT_CONTEXT(ctx);
struct vbo_exec_context *exec = _context(ctx)->exec;
 
if (!_mesa_inside_begin_end(ctx)) {
   _mesa_error(ctx, GL_INVALID_OPERATION, "glEnd");
   return;
}
 
ctx->Exec = ctx->OutsideBeginEnd;
-   if (ctx->CurrentClientDispatch == ctx->BeginEnd) {
-  ctx->CurrentClientDispatch = ctx->OutsideBeginEnd;
+
+   if (ctx->CurrentClientDispatch == ctx->MarshalExec) {
+  ctx->CurrentServerDispatch = ctx->Exec;
+   } else if (ctx->CurrentClientDispatch == ctx->BeginEnd) {
+  ctx->CurrentClientDispatch = ctx->Exec;
   _glapi_set_dispatch(ctx->CurrentClientDispatch);
}
 
if (exec->vtx.prim_count > 0) {
   /* close off current primitive */
   struct _mesa_prim *last_prim = >vtx.prim[exec->vtx.prim_count - 1];
 
   last_prim->end = 1;
   last_prim->count = exec->vtx.vert_count - last_prim->start;
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 3/3] drirc: enable glthread for Talos Principle

2018-11-09 Thread Marek Olšák
From: Marek Olšák 

Immediate mode was needed.
---
 src/util/00-mesa-defaults.conf | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf
index a148c87a882..99eb2eb42bc 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -317,20 +317,27 @@ TODO: document the other workarounds.
 
 
 
 
 
 
 
 
 
 
+
+
+
+
+
+
+
 
 
 
 
 
 
 
 
 
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 1/3] mesa/glthread: pass the function name to _mesa_glthread_restore_dispatch

2018-11-09 Thread Marek Olšák
From: Marek Olšák 

If you insert printf there, you'll know why glthread was disabled.
---
 src/mapi/glapi/gen/gl_marshal.py | 2 +-
 src/mesa/main/glthread.c | 4 ++--
 src/mesa/main/glthread.h | 2 +-
 src/mesa/main/marshal.c  | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py
index 5b35357ac54..4fd2bc2a5b9 100644
--- a/src/mapi/glapi/gen/gl_marshal.py
+++ b/src/mapi/glapi/gen/gl_marshal.py
@@ -242,21 +242,21 @@ class PrintCode(gl_XML.gl_print_base):
 out('{0} *cmd;'.format(struct))
 
 out('debug_print_marshal("{0}");'.format(func.name))
 
 need_fallback_sync = self.validate_count_or_fallback(func)
 
 if func.marshal_fail:
 out('if ({0}) {{'.format(func.marshal_fail))
 with indent():
 out('_mesa_glthread_finish(ctx);')
-out('_mesa_glthread_restore_dispatch(ctx);')
+out('_mesa_glthread_restore_dispatch(ctx, __func__);')
 self.print_sync_dispatch(func)
 out('return;')
 out('}')
 
 out('if (cmd_size <= MARSHAL_MAX_CMD_SIZE) {')
 with indent():
 self.print_async_dispatch(func)
 out('return;')
 out('}')
 
diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c
index 18a83bb9be4..8610d1ef933 100644
--- a/src/mesa/main/glthread.c
+++ b/src/mesa/main/glthread.c
@@ -114,25 +114,25 @@ _mesa_glthread_destroy(struct gl_context *ctx)
 
_mesa_glthread_finish(ctx);
util_queue_destroy(>queue);
 
for (unsigned i = 0; i < MARSHAL_MAX_BATCHES; i++)
   util_queue_fence_destroy(>batches[i].fence);
 
free(glthread);
ctx->GLThread = NULL;
 
-   _mesa_glthread_restore_dispatch(ctx);
+   _mesa_glthread_restore_dispatch(ctx, "destroy");
 }
 
 void
-_mesa_glthread_restore_dispatch(struct gl_context *ctx)
+_mesa_glthread_restore_dispatch(struct gl_context *ctx, const char *func)
 {
/* Remove ourselves from the dispatch table except if another ctx/thread
 * already installed a new dispatch table.
 *
 * Typically glxMakeCurrent will bind a new context (install new table) then
 * old context might be deleted.
 */
if (_glapi_get_dispatch() == ctx->MarshalExec) {
ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
_glapi_set_dispatch(ctx->CurrentClientDispatch);
diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h
index 8cd5d022674..59cb95feb4a 100644
--- a/src/mesa/main/glthread.h
+++ b/src/mesa/main/glthread.h
@@ -92,15 +92,15 @@ struct glthread_state
/**
 * Tracks on the main thread side whether the current element array (index
 * buffer) binding is in a VBO.
 */
bool element_array_is_vbo;
 };
 
 void _mesa_glthread_init(struct gl_context *ctx);
 void _mesa_glthread_destroy(struct gl_context *ctx);
 
-void _mesa_glthread_restore_dispatch(struct gl_context *ctx);
+void _mesa_glthread_restore_dispatch(struct gl_context *ctx, const char *func);
 void _mesa_glthread_flush_batch(struct gl_context *ctx);
 void _mesa_glthread_finish(struct gl_context *ctx);
 
 #endif /* _GLTHREAD_H*/
diff --git a/src/mesa/main/marshal.c b/src/mesa/main/marshal.c
index 8f8e8c78ed2..1827585ef0a 100644
--- a/src/mesa/main/marshal.c
+++ b/src/mesa/main/marshal.c
@@ -82,21 +82,21 @@ _mesa_unmarshal_Enable(struct gl_context *ctx,
 
 void GLAPIENTRY
 _mesa_marshal_Enable(GLenum cap)
 {
GET_CURRENT_CONTEXT(ctx);
struct marshal_cmd_Enable *cmd;
debug_print_marshal("Enable");
 
if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) {
   _mesa_glthread_finish(ctx);
-  _mesa_glthread_restore_dispatch(ctx);
+  _mesa_glthread_restore_dispatch(ctx, "Enable(DEBUG_OUTPUT_SYNCHRONOUS)");
} else {
   cmd = _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_Enable,
 sizeof(*cmd));
   cmd->cap = cap;
   _mesa_post_marshal_hook(ctx);
   return;
}
 
_mesa_glthread_finish(ctx);
debug_print_sync_fallback("Enable");
-- 
2.17.1

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


Re: [Mesa-dev] [PATCH 1/3 v2] glsl: prevent qualifiers modification of predeclared variables

2018-11-09 Thread Timothy Arceri

Nice! Series is:

Reviewed-by: Timothy Arceri 

On 10/10/18 9:07 am, Ian Romanick wrote:

From: Ian Romanick 

Section 3.7 (Identifiers) of the GLSL spec says:

 However, as noted in the specification, there are some cases where
 previously declared variables can be redeclared to change or add
 some property, and predeclared "gl_" names are allowed to be
 redeclared in a shader only for these specific purposes.  More
 generally, it is an error to redeclare a variable, including those
 starting "gl_".

This patch should fix piglit tests:
clip-distance-redeclare-without-inout.frag
clip-distance-redeclare-without-inout.vert

However, this causes a regression in
clip-distance-out-values.shader_test.  A fix for that test has been sent
to the piglit list for review:

 https://patchwork.freedesktop.org/patch/255201/

As far as I understood following mailing thread:
https://lists.freedesktop.org/archives/piglit/2013-October/007935.html
looks like we have accepted to remove an ability to change qualifiers
but have not done it yet. Unless I missed something)

v2 (idr): Move 'earlier->data.mode != var->data.mode' test much earlier
in the function.  Add special handling for gl_LastFragData.

Signed-off-by: Andrii Simiklit 
Signed-off-by: Ian Romanick 
---
  src/compiler/glsl/ast_to_hir.cpp | 51 +---
  1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 1082d6c91cf..2e4c9ef6776 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -4238,6 +4238,29 @@ get_variable_being_redeclared(ir_variable **var_ptr, 
YYLTYPE loc,
  
 *is_redeclaration = true;
  
+   if (earlier->data.how_declared == ir_var_declared_implicitly) {

+  /* Verify that the redeclaration of a built-in does not change the
+   * storage qualifier.  There are a couple special cases.
+   *
+   * 1. Some built-in variables that are defined as 'in' in the
+   *specification are implemented as system values.  Allow
+   *ir_var_system_value -> ir_var_shader_in.
+   *
+   * 2. gl_LastFragData is implemented as a ir_var_shader_out, but the
+   *specification requires that redeclarations omit any qualifier.
+   *Allow ir_var_shader_out -> ir_var_auto for this one variable.
+   */
+  if (earlier->data.mode != var->data.mode &&
+  !(earlier->data.mode == ir_var_system_value &&
+var->data.mode == ir_var_shader_in) &&
+  !(strcmp(var->name, "gl_LastFragData") == 0 &&
+var->data.mode == ir_var_auto)) {
+ _mesa_glsl_error(, state,
+  "redeclaration cannot change qualification of `%s'",
+  var->name);
+  }
+   }
+
 /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec,
  *
  * "It is legal to declare an array without a size and then
@@ -4246,11 +4269,6 @@ get_variable_being_redeclared(ir_variable **var_ptr, 
YYLTYPE loc,
  */
 if (earlier->type->is_unsized_array() && var->type->is_array()
 && (var->type->fields.array == earlier->type->fields.array)) {
-  /* FINISHME: This doesn't match the qualifiers on the two
-   * FINISHME: declarations.  It's not 100% clear whether this is
-   * FINISHME: required or not.
-   */
-
const int size = var->type->array_size();
check_builtin_array_max_size(var->name, size, loc, state);
if ((size > 0) && (size <= earlier->data.max_array_access)) {
@@ -4342,28 +4360,13 @@ get_variable_being_redeclared(ir_variable **var_ptr, 
YYLTYPE loc,
earlier->data.precision = var->data.precision;
earlier->data.memory_coherent = var->data.memory_coherent;
  
-   } else if (earlier->data.how_declared == ir_var_declared_implicitly &&

-  state->allow_builtin_variable_redeclaration) {
+   } else if ((earlier->data.how_declared == ir_var_declared_implicitly &&
+   state->allow_builtin_variable_redeclaration) ||
+  allow_all_redeclarations) {
/* Allow verbatim redeclarations of built-in variables. Not explicitly
 * valid, but some applications do it.
 */
-  if (earlier->data.mode != var->data.mode &&
-  !(earlier->data.mode == ir_var_system_value &&
-var->data.mode == ir_var_shader_in)) {
- _mesa_glsl_error(, state,
-  "redeclaration of `%s' with incorrect qualifiers",
-  var->name);
-  } else if (earlier->type != var->type) {
- _mesa_glsl_error(, state,
-  "redeclaration of `%s' has incorrect type",
-  var->name);
-  }
-   } else if (allow_all_redeclarations) {
-  if (earlier->data.mode != var->data.mode) {
- _mesa_glsl_error(, state,
-  "redeclaration of `%s' with incorrect qualifiers",
-   

[Mesa-dev] [PATCH 2/5] nir: Inline lower_clip_vs() into nir_lower_clip_vs().

2018-11-09 Thread Kenneth Graunke
It's now called exactly once, and there's not really any distinction.
---
 src/compiler/nir/nir_lower_clip.c | 76 ++-
 1 file changed, 34 insertions(+), 42 deletions(-)

diff --git a/src/compiler/nir/nir_lower_clip.c 
b/src/compiler/nir/nir_lower_clip.c
index 013645101f2..ced6d31c117 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -150,12 +150,23 @@ find_output(nir_shader *shader, unsigned drvloc)
  * VS lowering
  */
 
-static void
-lower_clip_vs(nir_function_impl *impl, unsigned ucp_enables,
-  nir_ssa_def *cv, nir_variable **out)
+/* ucp_enables is bitmask of enabled ucps.  Actual ucp values are
+ * passed in to shader via user_clip_plane system-values
+ */
+bool
+nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
 {
+   nir_function_impl *impl = nir_shader_get_entrypoint(shader);
nir_ssa_def *clipdist[MAX_CLIP_PLANES];
nir_builder b;
+   int clipvertex = -1;
+   int position = -1;
+   int maxloc = -1;
+   nir_ssa_def *cv;
+   nir_variable *out[2] = { NULL };
+
+   if (!ucp_enables)
+  return false;
 
nir_builder_init(, impl);
 
@@ -171,44 +182,6 @@ lower_clip_vs(nir_function_impl *impl, unsigned 
ucp_enables,
assert(impl->end_block->predecessors->entries == 1);
b.cursor = nir_after_cf_list(>body);
 
-   for (int plane = 0; plane < MAX_CLIP_PLANES; plane++) {
-  if (ucp_enables & (1 << plane)) {
- nir_ssa_def *ucp =
-nir_load_system_value(, nir_intrinsic_load_user_clip_plane, 
plane);
-
- /* calculate clipdist[plane] - dot(ucp, cv): */
- clipdist[plane] = nir_fdot4(, ucp, cv);
-  }
-  else {
- /* 0.0 == don't-clip == disabled: */
- clipdist[plane] = nir_imm_float(, 0.0);
-  }
-   }
-
-   if (ucp_enables & 0x0f)
-  store_clipdist_output(, out[0], [0]);
-   if (ucp_enables & 0xf0)
-  store_clipdist_output(, out[1], [4]);
-
-   nir_metadata_preserve(impl, nir_metadata_dominance);
-}
-
-/* ucp_enables is bitmask of enabled ucps.  Actual ucp values are
- * passed in to shader via user_clip_plane system-values
- */
-bool
-nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
-{
-   nir_function_impl *impl = nir_shader_get_entrypoint(shader);
-   int clipvertex = -1;
-   int position = -1;
-   int maxloc = -1;
-   nir_ssa_def *cv;
-   nir_variable *out[2] = { NULL };
-
-   if (!ucp_enables)
-  return false;
-
/* find clipvertex/position outputs: */
nir_foreach_variable(var, >outputs) {
   int loc = var->data.driver_location;
@@ -251,7 +224,26 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
   out[1] =
  create_clipdist_var(shader, ++maxloc, true, VARYING_SLOT_CLIP_DIST1);
 
-   lower_clip_vs(impl, ucp_enables, cv, out);
+   for (int plane = 0; plane < MAX_CLIP_PLANES; plane++) {
+  if (ucp_enables & (1 << plane)) {
+ nir_ssa_def *ucp =
+nir_load_system_value(, nir_intrinsic_load_user_clip_plane, 
plane);
+
+ /* calculate clipdist[plane] - dot(ucp, cv): */
+ clipdist[plane] = nir_fdot4(, ucp, cv);
+  }
+  else {
+ /* 0.0 == don't-clip == disabled: */
+ clipdist[plane] = nir_imm_float(, 0.0);
+  }
+   }
+
+   if (ucp_enables & 0x0f)
+  store_clipdist_output(, out[0], [0]);
+   if (ucp_enables & 0xf0)
+  store_clipdist_output(, out[1], [4]);
+
+   nir_metadata_preserve(impl, nir_metadata_dominance);
 
return true;
 }
-- 
2.19.1

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


[Mesa-dev] [PATCH 5/5] i965: Allow only one slot of clip distances to be set on Gen4-5.

2018-11-09 Thread Kenneth Graunke
The existing backend code assumed that if VARYING_SLOT_CLIP_DIST0
was written, then VARYING_SLOT_CLIP_DIST1 would be as well.  That's
true with the current lowering, but not necessary if there are 4 or
fewer clip distances.  Separate out the checks to allow this.

The new NIR-based lowering will trigger this case, which would have
caused backend validation errors (src is null) without this patch.
---
 src/intel/compiler/brw_vec4_visitor.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_vec4_visitor.cpp 
b/src/intel/compiler/brw_vec4_visitor.cpp
index b2bb2c6b82a..aea64c5b54d 100644
--- a/src/intel/compiler/brw_vec4_visitor.cpp
+++ b/src/intel/compiler/brw_vec4_visitor.cpp
@@ -1201,12 +1201,14 @@ vec4_visitor::emit_psiz_and_flags(dst_reg reg)
   if (output_reg[VARYING_SLOT_CLIP_DIST0][0].file != BAD_FILE) {
  current_annotation = "Clipping flags";
  dst_reg flags0 = dst_reg(this, glsl_type::uint_type);
- dst_reg flags1 = dst_reg(this, glsl_type::uint_type);
 
  emit(CMP(dst_null_f(), 
src_reg(output_reg[VARYING_SLOT_CLIP_DIST0][0]), brw_imm_f(0.0f), 
BRW_CONDITIONAL_L));
  emit(VS_OPCODE_UNPACK_FLAGS_SIMD4X2, flags0, brw_imm_d(0));
  emit(OR(header1_w, src_reg(header1_w), src_reg(flags0)));
+  }
 
+  if (output_reg[VARYING_SLOT_CLIP_DIST1][0].file != BAD_FILE) {
+ dst_reg flags1 = dst_reg(this, glsl_type::uint_type);
  emit(CMP(dst_null_f(), 
src_reg(output_reg[VARYING_SLOT_CLIP_DIST1][0]), brw_imm_f(0.0f), 
BRW_CONDITIONAL_L));
  emit(VS_OPCODE_UNPACK_FLAGS_SIMD4X2, flags1, brw_imm_d(0));
  emit(SHL(flags1, src_reg(flags1), brw_imm_d(4)));
-- 
2.19.1

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


[Mesa-dev] [PATCH 3/5] nir: Save nir_variable pointers in nir_lower_clip_vs rather than locs.

2018-11-09 Thread Kenneth Graunke
I'll want the variables in the next patch.
---
 src/compiler/nir/nir_lower_clip.c | 24 
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/compiler/nir/nir_lower_clip.c 
b/src/compiler/nir/nir_lower_clip.c
index ced6d31c117..2299f746305 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -159,9 +159,9 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
nir_ssa_def *clipdist[MAX_CLIP_PLANES];
nir_builder b;
-   int clipvertex = -1;
-   int position = -1;
int maxloc = -1;
+   nir_variable *position = NULL;
+   nir_variable *clipvertex = NULL;
nir_ssa_def *cv;
nir_variable *out[2] = { NULL };
 
@@ -184,20 +184,12 @@ nir_lower_clip_vs(nir_shader *shader, unsigned 
ucp_enables)
 
/* find clipvertex/position outputs: */
nir_foreach_variable(var, >outputs) {
-  int loc = var->data.driver_location;
-
-  /* keep track of last used driver-location.. we'll be
-   * appending CLIP_DIST0/CLIP_DIST1 after last existing
-   * output:
-   */
-  maxloc = MAX2(maxloc, loc);
-
   switch (var->data.location) {
   case VARYING_SLOT_POS:
- position = loc;
+ position = var;
  break;
   case VARYING_SLOT_CLIP_VERTEX:
- clipvertex = loc;
+ clipvertex = var;
  break;
   case VARYING_SLOT_CLIP_DIST0:
   case VARYING_SLOT_CLIP_DIST1:
@@ -209,10 +201,10 @@ nir_lower_clip_vs(nir_shader *shader, unsigned 
ucp_enables)
   }
}
 
-   if (clipvertex != -1)
-  cv = find_output(shader, clipvertex);
-   else if (position != -1)
-  cv = find_output(shader, position);
+   if (clipvertex)
+  cv = find_output(shader, clipvertex->data.driver_location);
+   else if (position)
+  cv = find_output(shader, position->data.driver_location);
else
   return false;
 
-- 
2.19.1

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


[Mesa-dev] [PATCH 4/5] nir: Make nir_lower_clip_vs optionally work with variables.

2018-11-09 Thread Kenneth Graunke
The way nir_lower_clip_vs() works with store_output intrinsics makes a
ton of assumptions about the driver_location field.

In i965, I'd rather do this lowering early and work with variables.
ir3 and vc4 could probably do that as well, but I'm not sure exactly
what paths would need updating, so for now, handle both methods.
---
 src/compiler/nir/nir.h  |  2 +-
 src/compiler/nir/nir_lower_clip.c   | 45 -
 src/gallium/drivers/freedreno/ir3/ir3_nir.c |  2 +-
 src/gallium/drivers/vc4/vc4_program.c   |  3 +-
 4 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f4f6b106505..9c12837ef01 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2967,7 +2967,7 @@ bool nir_lower_tex(nir_shader *shader,
 
 bool nir_lower_idiv(nir_shader *shader);
 
-bool nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables);
+bool nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables, bool 
use_vars);
 bool nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables);
 bool nir_lower_clip_cull_distance_arrays(nir_shader *nir);
 
diff --git a/src/compiler/nir/nir_lower_clip.c 
b/src/compiler/nir/nir_lower_clip.c
index 2299f746305..4caaf20af8c 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -152,9 +152,12 @@ find_output(nir_shader *shader, unsigned drvloc)
 
 /* ucp_enables is bitmask of enabled ucps.  Actual ucp values are
  * passed in to shader via user_clip_plane system-values
+ *
+ * If use_vars is true, the pass will use variable loads and stores instead
+ * of working with store_output intrinsics.
  */
 bool
-nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
+nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables, bool use_vars)
 {
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
nir_ssa_def *clipdist[MAX_CLIP_PLANES];
@@ -196,17 +199,30 @@ nir_lower_clip_vs(nir_shader *shader, unsigned 
ucp_enables)
  /* if shader is already writing CLIPDIST, then
   * there should be no user-clip-planes to deal
   * with.
+  *
+  * We assume nir_remove_dead_variables has removed the clipdist
+  * variables if they're not written.
   */
  return false;
   }
}
 
-   if (clipvertex)
-  cv = find_output(shader, clipvertex->data.driver_location);
-   else if (position)
-  cv = find_output(shader, position->data.driver_location);
-   else
-  return false;
+   if (use_vars) {
+  cv = nir_load_var(, clipvertex ? clipvertex : position);
+
+  if (clipvertex) {
+ exec_node_remove(>node);
+ clipvertex->data.mode = nir_var_global;
+ exec_list_push_tail(>globals, >node);
+  }
+   } else {
+  if (clipvertex)
+ cv = find_output(shader, clipvertex->data.driver_location);
+  else if (position)
+ cv = find_output(shader, position->data.driver_location);
+  else
+ return false;
+   }
 
/* insert CLIPDIST outputs: */
if (ucp_enables & 0x0f)
@@ -230,10 +246,17 @@ nir_lower_clip_vs(nir_shader *shader, unsigned 
ucp_enables)
   }
}
 
-   if (ucp_enables & 0x0f)
-  store_clipdist_output(, out[0], [0]);
-   if (ucp_enables & 0xf0)
-  store_clipdist_output(, out[1], [4]);
+   if (use_vars) {
+  if (ucp_enables & 0x0f)
+ nir_store_var(, out[0], nir_vec(, clipdist, 4), 0xf);
+  if (ucp_enables & 0xf0)
+ nir_store_var(, out[1], nir_vec(, [4], 4), 0xf);
+   } else {
+  if (ucp_enables & 0x0f)
+ store_clipdist_output(, out[0], [0]);
+  if (ucp_enables & 0xf0)
+ store_clipdist_output(, out[1], [4]);
+   }
 
nir_metadata_preserve(impl, nir_metadata_dominance);
 
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.c 
b/src/gallium/drivers/freedreno/ir3/ir3_nir.c
index 63866ae4d01..7c2a8f83b62 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.c
@@ -172,7 +172,7 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,
 
if (key) {
if (s->info.stage == MESA_SHADER_VERTEX) {
-   OPT_V(s, nir_lower_clip_vs, key->ucp_enables);
+   OPT_V(s, nir_lower_clip_vs, key->ucp_enables, false);
if (key->vclamp_color)
OPT_V(s, nir_lower_clamp_color_outputs);
} else if (s->info.stage == MESA_SHADER_FRAGMENT) {
diff --git a/src/gallium/drivers/vc4/vc4_program.c 
b/src/gallium/drivers/vc4/vc4_program.c
index bc9bd76ae95..b98baca30cf 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2363,7 +2363,8 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
 if (stage == QSTAGE_FRAG) {
 NIR_PASS_V(c->s, nir_lower_clip_fs, 
c->key->ucp_enables);
 } else {
- 

[Mesa-dev] [PATCH 1/5] nir: Use nir_shader_get_entrypoint in nir_lower_clip_vs().

2018-11-09 Thread Kenneth Graunke
---
 src/compiler/nir/nir_lower_clip.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_lower_clip.c 
b/src/compiler/nir/nir_lower_clip.c
index 7081295a500..013645101f2 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -199,6 +199,7 @@ lower_clip_vs(nir_function_impl *impl, unsigned ucp_enables,
 bool
 nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
 {
+   nir_function_impl *impl = nir_shader_get_entrypoint(shader);
int clipvertex = -1;
int position = -1;
int maxloc = -1;
@@ -250,10 +251,7 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
   out[1] =
  create_clipdist_var(shader, ++maxloc, true, VARYING_SLOT_CLIP_DIST1);
 
-   nir_foreach_function(function, shader) {
-  if (!strcmp(function->name, "main"))
- lower_clip_vs(function->impl, ucp_enables, cv, out);
-   }
+   lower_clip_vs(impl, ucp_enables, cv, out);
 
return true;
 }
-- 
2.19.1

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


Re: [Mesa-dev] [PATCH 22/28] util: promote u_memory to src/util

2018-11-09 Thread Rob Clark
On Fri, Nov 9, 2018 at 7:28 PM Dylan Baker  wrote:
>
> Quoting Rob Clark (2018-11-09 14:27:35)
> > On Fri, Nov 9, 2018 at 1:41 PM Dylan Baker  wrote:
> > >
> > > as well as os_memory*
> >
> > Thanks, I think this will be useful for me to extract freedreno/ir3
> > out to src/compiler :-)
>
> Shouldn't that be src/qualcomm? :)

maybe?  I'm still getting to the point where I can actually move code,
so I've postponed on the hard part of naming
(qcom/adreno/freedreno/???)

but I guess you are right, it should be src/$something/ir3 (or
something roughly along those lines)

BR,
-R


>
> >
> > Reviewed-by: Rob Clark 
>
> Thanks!
>
> >
> > > ---
> > >  src/gallium/auxiliary/Makefile.sources | 5 -
> > >  src/gallium/auxiliary/meson.build  | 5 -
> > >  src/gallium/auxiliary/util/u_debug_memory.c| 4 ++--
> > >  src/gallium/auxiliary/util/u_format.c  | 2 +-
> > >  src/gallium/auxiliary/util/u_format_tests.c| 2 +-
> > >  src/gallium/auxiliary/util/u_log.c | 2 +-
> > >  src/gallium/auxiliary/util/u_prim_restart.c| 2 +-
> > >  src/util/Makefile.sources  | 5 +
> > >  src/{gallium/auxiliary/os => util}/os_memory.h | 0
> > >  src/{gallium/auxiliary/os => util}/os_memory_aligned.h | 0
> > >  src/{gallium/auxiliary/os => util}/os_memory_debug.h   | 0
> > >  src/{gallium/auxiliary/os => util}/os_memory_stdc.h| 0
> > >  src/{gallium/auxiliary => }/util/u_memory.h| 3 +--
> > >  13 files changed, 12 insertions(+), 18 deletions(-)
> > >  rename src/{gallium/auxiliary/os => util}/os_memory.h (100%)
> > >  rename src/{gallium/auxiliary/os => util}/os_memory_aligned.h (100%)
> > >  rename src/{gallium/auxiliary/os => util}/os_memory_debug.h (100%)
> > >  rename src/{gallium/auxiliary/os => util}/os_memory_stdc.h (100%)
> > >  rename src/{gallium/auxiliary => }/util/u_memory.h (98%)
> > >
> > > diff --git a/src/gallium/auxiliary/Makefile.sources 
> > > b/src/gallium/auxiliary/Makefile.sources
> > > index b60b25a0e4c..87a490e555d 100644
> > > --- a/src/gallium/auxiliary/Makefile.sources
> > > +++ b/src/gallium/auxiliary/Makefile.sources
> > > @@ -102,10 +102,6 @@ C_SOURCES := \
> > > indices/u_indices_priv.h \
> > > indices/u_primconvert.c \
> > > indices/u_primconvert.h \
> > > -   os/os_memory_aligned.h \
> > > -   os/os_memory_debug.h \
> > > -   os/os_memory_stdc.h \
> > > -   os/os_memory.h \
> > > os/os_mman.h \
> > > os/os_process.c \
> > > os/os_process.h \
> > > @@ -290,7 +286,6 @@ C_SOURCES := \
> > > util/u_linear.h \
> > > util/u_log.c \
> > > util/u_log.h \
> > > -   util/u_memory.h \
> > > util/u_mm.c \
> > > util/u_mm.h \
> > > util/u_network.c \
> > > diff --git a/src/gallium/auxiliary/meson.build 
> > > b/src/gallium/auxiliary/meson.build
> > > index e1497992b17..a4dbcf7b4ca 100644
> > > --- a/src/gallium/auxiliary/meson.build
> > > +++ b/src/gallium/auxiliary/meson.build
> > > @@ -122,10 +122,6 @@ files_libgallium = files(
> > >'indices/u_indices_priv.h',
> > >'indices/u_primconvert.c',
> > >'indices/u_primconvert.h',
> > > -  'os/os_memory_aligned.h',
> > > -  'os/os_memory_debug.h',
> > > -  'os/os_memory_stdc.h',
> > > -  'os/os_memory.h',
> > >'os/os_mman.h',
> > >'os/os_process.c',
> > >'os/os_process.h',
> > > @@ -310,7 +306,6 @@ files_libgallium = files(
> > >'util/u_linear.h',
> > >'util/u_log.c',
> > >'util/u_log.h',
> > > -  'util/u_memory.h',
> > >'util/u_mm.c',
> > >'util/u_mm.h',
> > >'util/u_network.c',
> > > diff --git a/src/gallium/auxiliary/util/u_debug_memory.c 
> > > b/src/gallium/auxiliary/util/u_debug_memory.c
> > > index 0c822369a00..42e29dd6b2a 100644
> > > --- a/src/gallium/auxiliary/util/u_debug_memory.c
> > > +++ b/src/gallium/auxiliary/util/u_debug_memory.c
> > > @@ -36,14 +36,14 @@
> > >
> > >  #define DEBUG_MEMORY_IMPLEMENTATION
> > >
> > > -#include "os/os_memory.h"
> > > -#include "os/os_memory_debug.h"
> > >  #include "os/os_thread.h"
> > >
> > >  #include "util/u_debug.h"
> > >  #include "util/u_debug_gallium.h"
> > >  #include "util/u_debug_stack.h"
> > >  #include "util/list.h"
> > > +#include "util/os_memory.h"
> > > +#include "util/os_memory_debug.h"
> > >
> > >
> > >  #define DEBUG_MEMORY_MAGIC 0x6e34090aU
> > > diff --git a/src/gallium/auxiliary/util/u_format.c 
> > > b/src/gallium/auxiliary/util/u_format.c
> > > index 6445f2647cf..e43a619313e 100644
> > > --- a/src/gallium/auxiliary/util/u_format.c
> > > +++ b/src/gallium/auxiliary/util/u_format.c
> > > @@ -32,7 +32,7 @@
> > >   * @author Jose Fonseca 
> > >   */
> > >
> > > -#include "u_memory.h"
> > > +#include "util/u_memory.h"
> > >  #include "u_format.h"
> > >  #include "u_format_s3tc.h"
> > >  #include "u_surface.h"
> > > diff --git a/src/gallium/auxiliary/util/u_format_tests.c 
> > > 

Re: [Mesa-dev] [PATCH] st/mesa: make use of nir_link_constant_varyings()

2018-11-09 Thread Eric Anholt
Timothy Arceri  writes:

> Shader-db results radeonsi (VEGA):
>
> Totals from affected shaders:
> SGPRS: 161464 -> 161368 (-0.06 %)
> VGPRS: 86904 -> 86292 (-0.70 %)
> Spilled SGPRs: 296 -> 314 (6.08 %)
> Spilled VGPRs: 0 -> 0 (0.00 %)
> Private memory VGPRs: 0 -> 0 (0.00 %)
> Scratch size: 0 -> 0 (0.00 %) dwords per thread
> Code Size: 3618596 -> 3573852 (-1.24 %) bytes
> LDS: 0 -> 0 (0.00 %) blocks
> Max Waves: 26189 -> 26276 (0.33 %)
> Wait states: 0 -> 0 (0.00 %)

I was thinking I wanted to write this patch.

Reviewed-by: Eric Anholt 


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


Re: [Mesa-dev] [PATCH 22/28] util: promote u_memory to src/util

2018-11-09 Thread Dylan Baker
Quoting Rob Clark (2018-11-09 14:27:35)
> On Fri, Nov 9, 2018 at 1:41 PM Dylan Baker  wrote:
> >
> > as well as os_memory*
> 
> Thanks, I think this will be useful for me to extract freedreno/ir3
> out to src/compiler :-)

Shouldn't that be src/qualcomm? :)

> 
> Reviewed-by: Rob Clark 

Thanks!

> 
> > ---
> >  src/gallium/auxiliary/Makefile.sources | 5 -
> >  src/gallium/auxiliary/meson.build  | 5 -
> >  src/gallium/auxiliary/util/u_debug_memory.c| 4 ++--
> >  src/gallium/auxiliary/util/u_format.c  | 2 +-
> >  src/gallium/auxiliary/util/u_format_tests.c| 2 +-
> >  src/gallium/auxiliary/util/u_log.c | 2 +-
> >  src/gallium/auxiliary/util/u_prim_restart.c| 2 +-
> >  src/util/Makefile.sources  | 5 +
> >  src/{gallium/auxiliary/os => util}/os_memory.h | 0
> >  src/{gallium/auxiliary/os => util}/os_memory_aligned.h | 0
> >  src/{gallium/auxiliary/os => util}/os_memory_debug.h   | 0
> >  src/{gallium/auxiliary/os => util}/os_memory_stdc.h| 0
> >  src/{gallium/auxiliary => }/util/u_memory.h| 3 +--
> >  13 files changed, 12 insertions(+), 18 deletions(-)
> >  rename src/{gallium/auxiliary/os => util}/os_memory.h (100%)
> >  rename src/{gallium/auxiliary/os => util}/os_memory_aligned.h (100%)
> >  rename src/{gallium/auxiliary/os => util}/os_memory_debug.h (100%)
> >  rename src/{gallium/auxiliary/os => util}/os_memory_stdc.h (100%)
> >  rename src/{gallium/auxiliary => }/util/u_memory.h (98%)
> >
> > diff --git a/src/gallium/auxiliary/Makefile.sources 
> > b/src/gallium/auxiliary/Makefile.sources
> > index b60b25a0e4c..87a490e555d 100644
> > --- a/src/gallium/auxiliary/Makefile.sources
> > +++ b/src/gallium/auxiliary/Makefile.sources
> > @@ -102,10 +102,6 @@ C_SOURCES := \
> > indices/u_indices_priv.h \
> > indices/u_primconvert.c \
> > indices/u_primconvert.h \
> > -   os/os_memory_aligned.h \
> > -   os/os_memory_debug.h \
> > -   os/os_memory_stdc.h \
> > -   os/os_memory.h \
> > os/os_mman.h \
> > os/os_process.c \
> > os/os_process.h \
> > @@ -290,7 +286,6 @@ C_SOURCES := \
> > util/u_linear.h \
> > util/u_log.c \
> > util/u_log.h \
> > -   util/u_memory.h \
> > util/u_mm.c \
> > util/u_mm.h \
> > util/u_network.c \
> > diff --git a/src/gallium/auxiliary/meson.build 
> > b/src/gallium/auxiliary/meson.build
> > index e1497992b17..a4dbcf7b4ca 100644
> > --- a/src/gallium/auxiliary/meson.build
> > +++ b/src/gallium/auxiliary/meson.build
> > @@ -122,10 +122,6 @@ files_libgallium = files(
> >'indices/u_indices_priv.h',
> >'indices/u_primconvert.c',
> >'indices/u_primconvert.h',
> > -  'os/os_memory_aligned.h',
> > -  'os/os_memory_debug.h',
> > -  'os/os_memory_stdc.h',
> > -  'os/os_memory.h',
> >'os/os_mman.h',
> >'os/os_process.c',
> >'os/os_process.h',
> > @@ -310,7 +306,6 @@ files_libgallium = files(
> >'util/u_linear.h',
> >'util/u_log.c',
> >'util/u_log.h',
> > -  'util/u_memory.h',
> >'util/u_mm.c',
> >'util/u_mm.h',
> >'util/u_network.c',
> > diff --git a/src/gallium/auxiliary/util/u_debug_memory.c 
> > b/src/gallium/auxiliary/util/u_debug_memory.c
> > index 0c822369a00..42e29dd6b2a 100644
> > --- a/src/gallium/auxiliary/util/u_debug_memory.c
> > +++ b/src/gallium/auxiliary/util/u_debug_memory.c
> > @@ -36,14 +36,14 @@
> >
> >  #define DEBUG_MEMORY_IMPLEMENTATION
> >
> > -#include "os/os_memory.h"
> > -#include "os/os_memory_debug.h"
> >  #include "os/os_thread.h"
> >
> >  #include "util/u_debug.h"
> >  #include "util/u_debug_gallium.h"
> >  #include "util/u_debug_stack.h"
> >  #include "util/list.h"
> > +#include "util/os_memory.h"
> > +#include "util/os_memory_debug.h"
> >
> >
> >  #define DEBUG_MEMORY_MAGIC 0x6e34090aU
> > diff --git a/src/gallium/auxiliary/util/u_format.c 
> > b/src/gallium/auxiliary/util/u_format.c
> > index 6445f2647cf..e43a619313e 100644
> > --- a/src/gallium/auxiliary/util/u_format.c
> > +++ b/src/gallium/auxiliary/util/u_format.c
> > @@ -32,7 +32,7 @@
> >   * @author Jose Fonseca 
> >   */
> >
> > -#include "u_memory.h"
> > +#include "util/u_memory.h"
> >  #include "u_format.h"
> >  #include "u_format_s3tc.h"
> >  #include "u_surface.h"
> > diff --git a/src/gallium/auxiliary/util/u_format_tests.c 
> > b/src/gallium/auxiliary/util/u_format_tests.c
> > index dee52533c15..94bea2363d0 100644
> > --- a/src/gallium/auxiliary/util/u_format_tests.c
> > +++ b/src/gallium/auxiliary/util/u_format_tests.c
> > @@ -30,7 +30,7 @@
> >  #include 
> >
> >  #include "pipe/p_config.h"
> > -#include "u_memory.h"
> > +#include "util/u_memory.h"
> >  #include "u_format_tests.h"
> >
> >
> > diff --git a/src/gallium/auxiliary/util/u_log.c 
> > b/src/gallium/auxiliary/util/u_log.c
> > index dacbe0505e1..90fd24ca394 100644
> > --- a/src/gallium/auxiliary/util/u_log.c
> > 

Re: [Mesa-dev] [PATCH 04/28] r200: use preprocessor for big vs little endian checks

2018-11-09 Thread Dylan Baker
Quoting Dylan Baker (2018-11-09 15:52:05)
> Quoting Timothy Arceri (2018-11-09 13:45:27)
> > On 10/11/18 5:39 am, Dylan Baker wrote:
> > > Instead of using a function at runtime we can just build the right code
> > > for the right platform.
> > > ---
> > >   src/mesa/drivers/dri/r200/r200_blit.c | 76 ++-
> > >   src/mesa/drivers/dri/r200/r200_texstate.c |  7 ++-
> > >   2 files changed, 38 insertions(+), 45 deletions(-)
> > > 
> > > diff --git a/src/mesa/drivers/dri/r200/r200_blit.c 
> > > b/src/mesa/drivers/dri/r200/r200_blit.c
> > > index d68a53e67f7..90a88bddff8 100644
> > > --- a/src/mesa/drivers/dri/r200/r200_blit.c
> > > +++ b/src/mesa/drivers/dri/r200/r200_blit.c
> > > @@ -42,41 +42,29 @@ static inline uint32_t cmdpacket0(struct 
> > > radeon_screen *rscrn,
> > >   unsigned r200_check_blit(mesa_format mesa_format, uint32_t dst_pitch)
> > >   {
> > >   /* XXX others? */
> > > -if (_mesa_little_endian()) {
> > > - switch (mesa_format) {
> > > - case MESA_FORMAT_B8G8R8A8_UNORM:
> > > - case MESA_FORMAT_B8G8R8X8_UNORM:
> > > - case MESA_FORMAT_B5G6R5_UNORM:
> > > - case MESA_FORMAT_B4G4R4A4_UNORM:
> > > - case MESA_FORMAT_B5G5R5A1_UNORM:
> > > - case MESA_FORMAT_A_UNORM8:
> > > - case MESA_FORMAT_L_UNORM8:
> > > - case MESA_FORMAT_I_UNORM8:
> > > - /* swizzled - probably can't happen with the disabled 
> > > ChooseTexFormat code */
> > > - case MESA_FORMAT_A8B8G8R8_UNORM:
> > > - case MESA_FORMAT_R8G8B8A8_UNORM:
> > > - break;
> > > - default:
> > > - return 0;
> > > - }
> > > -}
> > > -else {
> > > - switch (mesa_format) {
> > > - case MESA_FORMAT_A8R8G8B8_UNORM:
> > > - case MESA_FORMAT_X8R8G8B8_UNORM:
> > > - case MESA_FORMAT_R5G6B5_UNORM:
> > > - case MESA_FORMAT_A4R4G4B4_UNORM:
> > > - case MESA_FORMAT_A1R5G5B5_UNORM:
> > > - case MESA_FORMAT_A_UNORM8:
> > > - case MESA_FORMAT_L_UNORM8:
> > > - case MESA_FORMAT_I_UNORM8:
> > > - /* swizzled  - probably can't happen with the disabled 
> > > ChooseTexFormat code */
> > > - case MESA_FORMAT_R8G8B8A8_UNORM:
> > > - case MESA_FORMAT_A8B8G8R8_UNORM:
> > > -break;
> > > - default:
> > > -return 0;
> > > - }
> > > +switch (mesa_format) {
> > > +#ifdef PIPE_ARCH_LITTLE_ENDIAN
> > 
> > I know this is an existing thing but PIPE_ is a galliumisim. IMO we 
> > should probably rename this before using it more generally:
> > 
> >PIPE_ARCH_LITTLE_ENDIAN -> UTIL_ARCH_LITTLE_ENDIAN ???
> 
> Honestly I don't know why we're using a header to figure out our endianness. 
> GCC
> has a builtin declaration for this, and the build system should be able to 
> fill
> it in otherwise.
> 
> I think I'll just respin with that.
> 

Changed my mind, that looks hard on android.mk (not hard with meson, scons, or
autotools though). I'll just rename it. Since u_endian was pulled into src/utils
by Dave in 2016 I'll just add that change as a new patch on the end.

Dylan


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


Re: [Mesa-dev] [PATCH 04/28] r200: use preprocessor for big vs little endian checks

2018-11-09 Thread Dylan Baker
Quoting Timothy Arceri (2018-11-09 13:45:27)
> On 10/11/18 5:39 am, Dylan Baker wrote:
> > Instead of using a function at runtime we can just build the right code
> > for the right platform.
> > ---
> >   src/mesa/drivers/dri/r200/r200_blit.c | 76 ++-
> >   src/mesa/drivers/dri/r200/r200_texstate.c |  7 ++-
> >   2 files changed, 38 insertions(+), 45 deletions(-)
> > 
> > diff --git a/src/mesa/drivers/dri/r200/r200_blit.c 
> > b/src/mesa/drivers/dri/r200/r200_blit.c
> > index d68a53e67f7..90a88bddff8 100644
> > --- a/src/mesa/drivers/dri/r200/r200_blit.c
> > +++ b/src/mesa/drivers/dri/r200/r200_blit.c
> > @@ -42,41 +42,29 @@ static inline uint32_t cmdpacket0(struct radeon_screen 
> > *rscrn,
> >   unsigned r200_check_blit(mesa_format mesa_format, uint32_t dst_pitch)
> >   {
> >   /* XXX others? */
> > -if (_mesa_little_endian()) {
> > - switch (mesa_format) {
> > - case MESA_FORMAT_B8G8R8A8_UNORM:
> > - case MESA_FORMAT_B8G8R8X8_UNORM:
> > - case MESA_FORMAT_B5G6R5_UNORM:
> > - case MESA_FORMAT_B4G4R4A4_UNORM:
> > - case MESA_FORMAT_B5G5R5A1_UNORM:
> > - case MESA_FORMAT_A_UNORM8:
> > - case MESA_FORMAT_L_UNORM8:
> > - case MESA_FORMAT_I_UNORM8:
> > - /* swizzled - probably can't happen with the disabled 
> > ChooseTexFormat code */
> > - case MESA_FORMAT_A8B8G8R8_UNORM:
> > - case MESA_FORMAT_R8G8B8A8_UNORM:
> > - break;
> > - default:
> > - return 0;
> > - }
> > -}
> > -else {
> > - switch (mesa_format) {
> > - case MESA_FORMAT_A8R8G8B8_UNORM:
> > - case MESA_FORMAT_X8R8G8B8_UNORM:
> > - case MESA_FORMAT_R5G6B5_UNORM:
> > - case MESA_FORMAT_A4R4G4B4_UNORM:
> > - case MESA_FORMAT_A1R5G5B5_UNORM:
> > - case MESA_FORMAT_A_UNORM8:
> > - case MESA_FORMAT_L_UNORM8:
> > - case MESA_FORMAT_I_UNORM8:
> > - /* swizzled  - probably can't happen with the disabled 
> > ChooseTexFormat code */
> > - case MESA_FORMAT_R8G8B8A8_UNORM:
> > - case MESA_FORMAT_A8B8G8R8_UNORM:
> > -break;
> > - default:
> > -return 0;
> > - }
> > +switch (mesa_format) {
> > +#ifdef PIPE_ARCH_LITTLE_ENDIAN
> 
> I know this is an existing thing but PIPE_ is a galliumisim. IMO we 
> should probably rename this before using it more generally:
> 
>PIPE_ARCH_LITTLE_ENDIAN -> UTIL_ARCH_LITTLE_ENDIAN ???

Honestly I don't know why we're using a header to figure out our endianness. GCC
has a builtin declaration for this, and the build system should be able to fill
it in otherwise.

I think I'll just respin with that.

> 
> 
> > +case MESA_FORMAT_B8G8R8A8_UNORM:
> > +case MESA_FORMAT_B8G8R8X8_UNORM:
> > +case MESA_FORMAT_B5G6R5_UNORM:
> > +case MESA_FORMAT_B4G4R4A4_UNORM:
> > +case MESA_FORMAT_B5G5R5A1_UNORM:
> > +#else
> > +case MESA_FORMAT_A8R8G8B8_UNORM:
> > +case MESA_FORMAT_X8R8G8B8_UNORM:
> > +case MESA_FORMAT_R5G6B5_UNORM:
> > +case MESA_FORMAT_A4R4G4B4_UNORM:
> > +case MESA_FORMAT_A1R5G5B5_UNORM:
> > +#endif
> > +case MESA_FORMAT_A_UNORM8:
> > +case MESA_FORMAT_L_UNORM8:
> > +case MESA_FORMAT_I_UNORM8:
> > +/* swizzled - probably can't happen with the disabled 
> > ChooseTexFormat code */
> > +case MESA_FORMAT_A8B8G8R8_UNORM:
> > +case MESA_FORMAT_R8G8B8A8_UNORM:
> > +break;
> > +default:
> > +return 0;
> >   }
> >   
> >   /* Rendering to small buffer doesn't work.
> > @@ -133,12 +121,11 @@ static void inline emit_tx_setup(struct r200_context 
> > *r200,
> >   assert(height <= 2048);
> >   assert(offset % 32 == 0);
> >   
> > -if (_mesa_little_endian()) {
> > - txformat |= tx_table_le[src_mesa_format].format;
> > -}
> > -else {
> > - txformat |= tx_table_be[src_mesa_format].format;
> > -}
> > +#ifdef PIPE_ARCH_LITTLE_ENDIAN
> > +txformat |= tx_table_le[src_mesa_format].format;
> > +#else
> > +txformat |= tx_table_be[src_mesa_format].format;
> > +#endif
> >   
> >   if (bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
> >   offset |= R200_TXO_MACRO_TILE;
> > @@ -183,8 +170,11 @@ static void inline emit_tx_setup(struct r200_context 
> > *r200,
> >   break;
> >   case MESA_FORMAT_A8B8G8R8_UNORM:
> >   case MESA_FORMAT_R8G8B8A8_UNORM:
> > -   if ((dst_mesa_format == MESA_FORMAT_A8B8G8R8_UNORM && 
> > _mesa_little_endian()) ||
> > -(dst_mesa_format == MESA_FORMAT_R8G8B8A8_UNORM && 
> > !_mesa_little_endian())) {
> > +#ifdef PIPE_ARCH_LITTLE_ENDIAN
> > +   if (dst_mesa_format == MESA_FORMAT_A8B8G8R8_UNORM) {
> > +#else
> > +   if (dst_mesa_format == MESA_FORMAT_R8G8B8A8_UNORM) {
> > +#endif
> >   BEGIN_BATCH(10);
> >   OUT_BATCH_REGVAL(RADEON_PP_CNTL, (RADEON_TEX_0_ENABLE |
> > RADEON_TEX_BLEND_0_ENABLE));
> > diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c 
> > b/src/mesa/drivers/dri/r200/r200_texstate.c
> > index 

Re: [Mesa-dev] [PATCH] meson: fix libatomic tests

2018-11-09 Thread Dylan Baker
Quoting Matt Turner (2018-11-09 15:26:50)
> The underscore change alone is enough to fix the build on 32-bit ppc
> and sparc. It's unclear to me if the dep_atomic even changes anything.
> Without it I still see -latomic in the command to build
> src/util/u_atomic_test. I would just drop that part.
> 
> Reviewed-and-Tested-by: Matt Turner 
> 
> Thanks!

That addition of -latomic is for the confiugre test, not for u_atomic_test. If
we don't need it we should drop it from the autotools build, as autotools does
use -latomic for that test (if the previous test used it)

Dylan


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


Re: [Mesa-dev] [PATCH] meson: fix libatomic tests

2018-11-09 Thread Matt Turner
The underscore change alone is enough to fix the build on 32-bit ppc
and sparc. It's unclear to me if the dep_atomic even changes anything.
Without it I still see -latomic in the command to build
src/util/u_atomic_test. I would just drop that part.

Reviewed-and-Tested-by: Matt Turner 

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


[Mesa-dev] [Bug 108640] [Regression] Starcraft II broken graphics

2018-11-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108640

Travis  changed:

   What|Removed |Added

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

--- Comment #2 from Travis  ---
Was having issues running renderdoc, but issue seems to be resolved as of
gitb55af39.

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


Re: [Mesa-dev] [PATCH 22/28] util: promote u_memory to src/util

2018-11-09 Thread Rob Clark
On Fri, Nov 9, 2018 at 1:41 PM Dylan Baker  wrote:
>
> as well as os_memory*

Thanks, I think this will be useful for me to extract freedreno/ir3
out to src/compiler :-)

Reviewed-by: Rob Clark 

> ---
>  src/gallium/auxiliary/Makefile.sources | 5 -
>  src/gallium/auxiliary/meson.build  | 5 -
>  src/gallium/auxiliary/util/u_debug_memory.c| 4 ++--
>  src/gallium/auxiliary/util/u_format.c  | 2 +-
>  src/gallium/auxiliary/util/u_format_tests.c| 2 +-
>  src/gallium/auxiliary/util/u_log.c | 2 +-
>  src/gallium/auxiliary/util/u_prim_restart.c| 2 +-
>  src/util/Makefile.sources  | 5 +
>  src/{gallium/auxiliary/os => util}/os_memory.h | 0
>  src/{gallium/auxiliary/os => util}/os_memory_aligned.h | 0
>  src/{gallium/auxiliary/os => util}/os_memory_debug.h   | 0
>  src/{gallium/auxiliary/os => util}/os_memory_stdc.h| 0
>  src/{gallium/auxiliary => }/util/u_memory.h| 3 +--
>  13 files changed, 12 insertions(+), 18 deletions(-)
>  rename src/{gallium/auxiliary/os => util}/os_memory.h (100%)
>  rename src/{gallium/auxiliary/os => util}/os_memory_aligned.h (100%)
>  rename src/{gallium/auxiliary/os => util}/os_memory_debug.h (100%)
>  rename src/{gallium/auxiliary/os => util}/os_memory_stdc.h (100%)
>  rename src/{gallium/auxiliary => }/util/u_memory.h (98%)
>
> diff --git a/src/gallium/auxiliary/Makefile.sources 
> b/src/gallium/auxiliary/Makefile.sources
> index b60b25a0e4c..87a490e555d 100644
> --- a/src/gallium/auxiliary/Makefile.sources
> +++ b/src/gallium/auxiliary/Makefile.sources
> @@ -102,10 +102,6 @@ C_SOURCES := \
> indices/u_indices_priv.h \
> indices/u_primconvert.c \
> indices/u_primconvert.h \
> -   os/os_memory_aligned.h \
> -   os/os_memory_debug.h \
> -   os/os_memory_stdc.h \
> -   os/os_memory.h \
> os/os_mman.h \
> os/os_process.c \
> os/os_process.h \
> @@ -290,7 +286,6 @@ C_SOURCES := \
> util/u_linear.h \
> util/u_log.c \
> util/u_log.h \
> -   util/u_memory.h \
> util/u_mm.c \
> util/u_mm.h \
> util/u_network.c \
> diff --git a/src/gallium/auxiliary/meson.build 
> b/src/gallium/auxiliary/meson.build
> index e1497992b17..a4dbcf7b4ca 100644
> --- a/src/gallium/auxiliary/meson.build
> +++ b/src/gallium/auxiliary/meson.build
> @@ -122,10 +122,6 @@ files_libgallium = files(
>'indices/u_indices_priv.h',
>'indices/u_primconvert.c',
>'indices/u_primconvert.h',
> -  'os/os_memory_aligned.h',
> -  'os/os_memory_debug.h',
> -  'os/os_memory_stdc.h',
> -  'os/os_memory.h',
>'os/os_mman.h',
>'os/os_process.c',
>'os/os_process.h',
> @@ -310,7 +306,6 @@ files_libgallium = files(
>'util/u_linear.h',
>'util/u_log.c',
>'util/u_log.h',
> -  'util/u_memory.h',
>'util/u_mm.c',
>'util/u_mm.h',
>'util/u_network.c',
> diff --git a/src/gallium/auxiliary/util/u_debug_memory.c 
> b/src/gallium/auxiliary/util/u_debug_memory.c
> index 0c822369a00..42e29dd6b2a 100644
> --- a/src/gallium/auxiliary/util/u_debug_memory.c
> +++ b/src/gallium/auxiliary/util/u_debug_memory.c
> @@ -36,14 +36,14 @@
>
>  #define DEBUG_MEMORY_IMPLEMENTATION
>
> -#include "os/os_memory.h"
> -#include "os/os_memory_debug.h"
>  #include "os/os_thread.h"
>
>  #include "util/u_debug.h"
>  #include "util/u_debug_gallium.h"
>  #include "util/u_debug_stack.h"
>  #include "util/list.h"
> +#include "util/os_memory.h"
> +#include "util/os_memory_debug.h"
>
>
>  #define DEBUG_MEMORY_MAGIC 0x6e34090aU
> diff --git a/src/gallium/auxiliary/util/u_format.c 
> b/src/gallium/auxiliary/util/u_format.c
> index 6445f2647cf..e43a619313e 100644
> --- a/src/gallium/auxiliary/util/u_format.c
> +++ b/src/gallium/auxiliary/util/u_format.c
> @@ -32,7 +32,7 @@
>   * @author Jose Fonseca 
>   */
>
> -#include "u_memory.h"
> +#include "util/u_memory.h"
>  #include "u_format.h"
>  #include "u_format_s3tc.h"
>  #include "u_surface.h"
> diff --git a/src/gallium/auxiliary/util/u_format_tests.c 
> b/src/gallium/auxiliary/util/u_format_tests.c
> index dee52533c15..94bea2363d0 100644
> --- a/src/gallium/auxiliary/util/u_format_tests.c
> +++ b/src/gallium/auxiliary/util/u_format_tests.c
> @@ -30,7 +30,7 @@
>  #include 
>
>  #include "pipe/p_config.h"
> -#include "u_memory.h"
> +#include "util/u_memory.h"
>  #include "u_format_tests.h"
>
>
> diff --git a/src/gallium/auxiliary/util/u_log.c 
> b/src/gallium/auxiliary/util/u_log.c
> index dacbe0505e1..90fd24ca394 100644
> --- a/src/gallium/auxiliary/util/u_log.c
> +++ b/src/gallium/auxiliary/util/u_log.c
> @@ -23,7 +23,7 @@
>
>  #include "u_log.h"
>
> -#include "u_memory.h"
> +#include "util/u_memory.h"
>  #include "util/u_string.h"
>
>  struct page_entry {
> diff --git a/src/gallium/auxiliary/util/u_prim_restart.c 
> b/src/gallium/auxiliary/util/u_prim_restart.c
> index 9ff93a7f669..10e39e240db 100644
> --- 

[Mesa-dev] [PATCH] st/mesa: make use of nir_link_constant_varyings()

2018-11-09 Thread Timothy Arceri
Shader-db results radeonsi (VEGA):

Totals from affected shaders:
SGPRS: 161464 -> 161368 (-0.06 %)
VGPRS: 86904 -> 86292 (-0.70 %)
Spilled SGPRs: 296 -> 314 (6.08 %)
Spilled VGPRs: 0 -> 0 (0.00 %)
Private memory VGPRs: 0 -> 0 (0.00 %)
Scratch size: 0 -> 0 (0.00 %) dwords per thread
Code Size: 3618596 -> 3573852 (-1.24 %) bytes
LDS: 0 -> 0 (0.00 %) blocks
Max Waves: 26189 -> 26276 (0.33 %)
Wait states: 0 -> 0 (0.00 %)
---
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index dcf8c2b638e..d0475fb538a 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -588,6 +588,9 @@ st_nir_link_shaders(nir_shader **producer, nir_shader 
**consumer, bool scalar)
 {
nir_lower_io_arrays_to_elements(*producer, *consumer);
 
+   if (nir_link_constant_varyings(*producer, *consumer))
+  st_nir_opts(*consumer, scalar);
+
NIR_PASS_V(*producer, nir_remove_dead_variables, nir_var_shader_out);
NIR_PASS_V(*consumer, nir_remove_dead_variables, nir_var_shader_in);
 
-- 
2.19.1

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


Re: [Mesa-dev] [PATCH] mesa: mark GL_SR8_EXT non-renderable on GLES

2018-11-09 Thread Ilia Mirkin
Reviewed-by: Ilia Mirkin 
On Fri, Nov 9, 2018 at 4:48 PM Marek Olšák  wrote:
>
> From: Marek Olšák 
>
> Fixes: 
> dEQP-GLES3.functional.fbo.completeness.renderable.texture.color0.sr8_ext
> ---
>  src/mesa/main/fbobject.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index c3dded6b928..68e0daf3423 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -743,20 +743,21 @@ is_format_color_renderable(const struct gl_context 
> *ctx, mesa_format format,
> case GL_RGB32UI:
> case GL_RGB16F:
> case GL_RGB16I:
> case GL_RGB16UI:
> case GL_RGB8_SNORM:
> case GL_RGB8I:
> case GL_RGB8UI:
> case GL_SRGB8:
> case GL_RGB10:
> case GL_RGB9_E5:
> +   case GL_SR8_EXT:
>return GL_FALSE;
> default:
>break;
> }
>
> if (internalFormat != GL_RGB10_A2 &&
> (format == MESA_FORMAT_B10G10R10A2_UNORM ||
>  format == MESA_FORMAT_B10G10R10X2_UNORM ||
>  format == MESA_FORMAT_R10G10B10A2_UNORM ||
>  format == MESA_FORMAT_R10G10B10X2_UNORM)) {
> --
> 2.17.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: mark GL_SR8_EXT non-renderable on GLES

2018-11-09 Thread Marek Olšák
From: Marek Olšák 

Fixes: dEQP-GLES3.functional.fbo.completeness.renderable.texture.color0.sr8_ext
---
 src/mesa/main/fbobject.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index c3dded6b928..68e0daf3423 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -743,20 +743,21 @@ is_format_color_renderable(const struct gl_context *ctx, 
mesa_format format,
case GL_RGB32UI:
case GL_RGB16F:
case GL_RGB16I:
case GL_RGB16UI:
case GL_RGB8_SNORM:
case GL_RGB8I:
case GL_RGB8UI:
case GL_SRGB8:
case GL_RGB10:
case GL_RGB9_E5:
+   case GL_SR8_EXT:
   return GL_FALSE;
default:
   break;
}
 
if (internalFormat != GL_RGB10_A2 &&
(format == MESA_FORMAT_B10G10R10A2_UNORM ||
 format == MESA_FORMAT_B10G10R10X2_UNORM ||
 format == MESA_FORMAT_R10G10B10A2_UNORM ||
 format == MESA_FORMAT_R10G10B10X2_UNORM)) {
-- 
2.17.1

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


Re: [Mesa-dev] [PATCH 04/28] r200: use preprocessor for big vs little endian checks

2018-11-09 Thread Timothy Arceri

On 10/11/18 5:39 am, Dylan Baker wrote:

Instead of using a function at runtime we can just build the right code
for the right platform.
---
  src/mesa/drivers/dri/r200/r200_blit.c | 76 ++-
  src/mesa/drivers/dri/r200/r200_texstate.c |  7 ++-
  2 files changed, 38 insertions(+), 45 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_blit.c 
b/src/mesa/drivers/dri/r200/r200_blit.c
index d68a53e67f7..90a88bddff8 100644
--- a/src/mesa/drivers/dri/r200/r200_blit.c
+++ b/src/mesa/drivers/dri/r200/r200_blit.c
@@ -42,41 +42,29 @@ static inline uint32_t cmdpacket0(struct radeon_screen 
*rscrn,
  unsigned r200_check_blit(mesa_format mesa_format, uint32_t dst_pitch)
  {
  /* XXX others? */
-if (_mesa_little_endian()) {
-   switch (mesa_format) {
-   case MESA_FORMAT_B8G8R8A8_UNORM:
-   case MESA_FORMAT_B8G8R8X8_UNORM:
-   case MESA_FORMAT_B5G6R5_UNORM:
-   case MESA_FORMAT_B4G4R4A4_UNORM:
-   case MESA_FORMAT_B5G5R5A1_UNORM:
-   case MESA_FORMAT_A_UNORM8:
-   case MESA_FORMAT_L_UNORM8:
-   case MESA_FORMAT_I_UNORM8:
-   /* swizzled - probably can't happen with the disabled 
ChooseTexFormat code */
-   case MESA_FORMAT_A8B8G8R8_UNORM:
-   case MESA_FORMAT_R8G8B8A8_UNORM:
-   break;
-   default:
-   return 0;
-   }
-}
-else {
-   switch (mesa_format) {
-   case MESA_FORMAT_A8R8G8B8_UNORM:
-   case MESA_FORMAT_X8R8G8B8_UNORM:
-   case MESA_FORMAT_R5G6B5_UNORM:
-   case MESA_FORMAT_A4R4G4B4_UNORM:
-   case MESA_FORMAT_A1R5G5B5_UNORM:
-   case MESA_FORMAT_A_UNORM8:
-   case MESA_FORMAT_L_UNORM8:
-   case MESA_FORMAT_I_UNORM8:
-   /* swizzled  - probably can't happen with the disabled 
ChooseTexFormat code */
-   case MESA_FORMAT_R8G8B8A8_UNORM:
-   case MESA_FORMAT_A8B8G8R8_UNORM:
-  break;
-   default:
-  return 0;
-   }
+switch (mesa_format) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN


I know this is an existing thing but PIPE_ is a galliumisim. IMO we 
should probably rename this before using it more generally:


  PIPE_ARCH_LITTLE_ENDIAN -> UTIL_ARCH_LITTLE_ENDIAN ???



+case MESA_FORMAT_B8G8R8A8_UNORM:
+case MESA_FORMAT_B8G8R8X8_UNORM:
+case MESA_FORMAT_B5G6R5_UNORM:
+case MESA_FORMAT_B4G4R4A4_UNORM:
+case MESA_FORMAT_B5G5R5A1_UNORM:
+#else
+case MESA_FORMAT_A8R8G8B8_UNORM:
+case MESA_FORMAT_X8R8G8B8_UNORM:
+case MESA_FORMAT_R5G6B5_UNORM:
+case MESA_FORMAT_A4R4G4B4_UNORM:
+case MESA_FORMAT_A1R5G5B5_UNORM:
+#endif
+case MESA_FORMAT_A_UNORM8:
+case MESA_FORMAT_L_UNORM8:
+case MESA_FORMAT_I_UNORM8:
+/* swizzled - probably can't happen with the disabled ChooseTexFormat 
code */
+case MESA_FORMAT_A8B8G8R8_UNORM:
+case MESA_FORMAT_R8G8B8A8_UNORM:
+break;
+default:
+return 0;
  }
  
  /* Rendering to small buffer doesn't work.

@@ -133,12 +121,11 @@ static void inline emit_tx_setup(struct r200_context 
*r200,
  assert(height <= 2048);
  assert(offset % 32 == 0);
  
-if (_mesa_little_endian()) {

-   txformat |= tx_table_le[src_mesa_format].format;
-}
-else {
-   txformat |= tx_table_be[src_mesa_format].format;
-}
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+txformat |= tx_table_le[src_mesa_format].format;
+#else
+txformat |= tx_table_be[src_mesa_format].format;
+#endif
  
  if (bo->flags & RADEON_BO_FLAGS_MACRO_TILE)

offset |= R200_TXO_MACRO_TILE;
@@ -183,8 +170,11 @@ static void inline emit_tx_setup(struct r200_context *r200,
break;
  case MESA_FORMAT_A8B8G8R8_UNORM:
  case MESA_FORMAT_R8G8B8A8_UNORM:
-   if ((dst_mesa_format == MESA_FORMAT_A8B8G8R8_UNORM && 
_mesa_little_endian()) ||
-  (dst_mesa_format == MESA_FORMAT_R8G8B8A8_UNORM && 
!_mesa_little_endian())) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+   if (dst_mesa_format == MESA_FORMAT_A8B8G8R8_UNORM) {
+#else
+   if (dst_mesa_format == MESA_FORMAT_R8G8B8A8_UNORM) {
+#endif
BEGIN_BATCH(10);
OUT_BATCH_REGVAL(RADEON_PP_CNTL, (RADEON_TEX_0_ENABLE |
  RADEON_TEX_BLEND_0_ENABLE));
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c 
b/src/mesa/drivers/dri/r200/r200_texstate.c
index 60a20071d97..4718d3f4d25 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -1314,8 +1314,11 @@ static void setup_hardware_state(r200ContextPtr rmesa, 
radeonTexObj *t)
  
 if (!t->image_override) {

if (VALID_FORMAT(firstImage->TexFormat)) {
-const struct tx_table *table = _mesa_little_endian() ? tx_table_le :
-   tx_table_be;
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+const struct tx_table *table = tx_table_le;
+#else
+const struct tx_table *table = tx_table_be;
+#endif

 t->pp_txformat &= ~(R200_TXFORMAT_FORMAT_MASK |
 

[Mesa-dev] [PATCH] meson: Don't set -Wall

2018-11-09 Thread Dylan Baker
meson does this for you with it's warn levels, so we don't need to set
it ourselves.

Fixes: d1992255bb29054fa51763376d125183a9f602f3
   ("meson: Add build Intel "anv" vulkan driver")
---
 meson.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 18667988bac..dabfb9abddd 100644
--- a/meson.build
+++ b/meson.build
@@ -787,7 +787,7 @@ endif
 
 # Check for generic C arguments
 c_args = []
-foreach a : ['-Wall', '-Werror=implicit-function-declaration',
+foreach a : ['-Werror=implicit-function-declaration',
  '-Werror=missing-prototypes', '-Werror=return-type',
  '-fno-math-errno',
  '-fno-trapping-math', '-Qunused-arguments']
@@ -809,7 +809,7 @@ endif
 
 # Check for generic C++ arguments
 cpp_args = []
-foreach a : ['-Wall', '-Werror=return-type',
+foreach a : ['-Werror=return-type',
  '-fno-math-errno', '-fno-trapping-math',
  '-Qunused-arguments']
   if cpp.has_argument(a)
-- 
2.19.1

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


[Mesa-dev] [PATCH] meson: fix libatomic tests

2018-11-09 Thread Dylan Baker
There are two problems:
1) the extra underscore in MISSING_64BIT_ATOMICS
2) we should ink with libatomic if the previous test decided we needed
   it

CC: Matt Turner 
Fixes: d1992255bb29054fa51763376d125183a9f602f3
   ("meson: Add build Intel "anv" vulkan driver")
---
 meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 18667988bac..4e6107b857f 100644
--- a/meson.build
+++ b/meson.build
@@ -905,8 +905,9 @@ if not cc.links('''#include 
int main() {
  return __sync_add_and_fetch(, (uint64_t)1);
}''',
+dependencies : dep_atomic,
 name : 'GCC 64bit atomics')
-  pre_args += '-DMISSING_64_BIT_ATOMICS'
+  pre_args += '-DMISSING_64BIT_ATOMICS'
 endif
 
 # TODO: shared/static? Is this even worth doing?
-- 
2.19.1

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


Re: [Mesa-dev] [PATCH 1/3 v2] glsl: prevent qualifiers modification of predeclared variables

2018-11-09 Thread Ian Romanick
bump

On 10/09/2018 03:07 PM, Ian Romanick wrote:
> From: Ian Romanick 
> 
> Section 3.7 (Identifiers) of the GLSL spec says:
> 
> However, as noted in the specification, there are some cases where
> previously declared variables can be redeclared to change or add
> some property, and predeclared "gl_" names are allowed to be
> redeclared in a shader only for these specific purposes.  More
> generally, it is an error to redeclare a variable, including those
> starting "gl_".
> 
> This patch should fix piglit tests:
> clip-distance-redeclare-without-inout.frag
> clip-distance-redeclare-without-inout.vert
> 
> However, this causes a regression in
> clip-distance-out-values.shader_test.  A fix for that test has been sent
> to the piglit list for review:
> 
> https://patchwork.freedesktop.org/patch/255201/
> 
> As far as I understood following mailing thread:
> https://lists.freedesktop.org/archives/piglit/2013-October/007935.html
> looks like we have accepted to remove an ability to change qualifiers
> but have not done it yet. Unless I missed something)
> 
> v2 (idr): Move 'earlier->data.mode != var->data.mode' test much earlier
> in the function.  Add special handling for gl_LastFragData.
> 
> Signed-off-by: Andrii Simiklit 
> Signed-off-by: Ian Romanick 
> ---
>  src/compiler/glsl/ast_to_hir.cpp | 51 
> +---
>  1 file changed, 27 insertions(+), 24 deletions(-)
> 
> diff --git a/src/compiler/glsl/ast_to_hir.cpp 
> b/src/compiler/glsl/ast_to_hir.cpp
> index 1082d6c91cf..2e4c9ef6776 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -4238,6 +4238,29 @@ get_variable_being_redeclared(ir_variable **var_ptr, 
> YYLTYPE loc,
>  
> *is_redeclaration = true;
>  
> +   if (earlier->data.how_declared == ir_var_declared_implicitly) {
> +  /* Verify that the redeclaration of a built-in does not change the
> +   * storage qualifier.  There are a couple special cases.
> +   *
> +   * 1. Some built-in variables that are defined as 'in' in the
> +   *specification are implemented as system values.  Allow
> +   *ir_var_system_value -> ir_var_shader_in.
> +   *
> +   * 2. gl_LastFragData is implemented as a ir_var_shader_out, but the
> +   *specification requires that redeclarations omit any qualifier.
> +   *Allow ir_var_shader_out -> ir_var_auto for this one variable.
> +   */
> +  if (earlier->data.mode != var->data.mode &&
> +  !(earlier->data.mode == ir_var_system_value &&
> +var->data.mode == ir_var_shader_in) &&
> +  !(strcmp(var->name, "gl_LastFragData") == 0 &&
> +var->data.mode == ir_var_auto)) {
> + _mesa_glsl_error(, state,
> +  "redeclaration cannot change qualification of 
> `%s'",
> +  var->name);
> +  }
> +   }
> +
> /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec,
>  *
>  * "It is legal to declare an array without a size and then
> @@ -4246,11 +4269,6 @@ get_variable_being_redeclared(ir_variable **var_ptr, 
> YYLTYPE loc,
>  */
> if (earlier->type->is_unsized_array() && var->type->is_array()
> && (var->type->fields.array == earlier->type->fields.array)) {
> -  /* FINISHME: This doesn't match the qualifiers on the two
> -   * FINISHME: declarations.  It's not 100% clear whether this is
> -   * FINISHME: required or not.
> -   */
> -
>const int size = var->type->array_size();
>check_builtin_array_max_size(var->name, size, loc, state);
>if ((size > 0) && (size <= earlier->data.max_array_access)) {
> @@ -4342,28 +4360,13 @@ get_variable_being_redeclared(ir_variable **var_ptr, 
> YYLTYPE loc,
>earlier->data.precision = var->data.precision;
>earlier->data.memory_coherent = var->data.memory_coherent;
>  
> -   } else if (earlier->data.how_declared == ir_var_declared_implicitly &&
> -  state->allow_builtin_variable_redeclaration) {
> +   } else if ((earlier->data.how_declared == ir_var_declared_implicitly &&
> +   state->allow_builtin_variable_redeclaration) ||
> +  allow_all_redeclarations) {
>/* Allow verbatim redeclarations of built-in variables. Not explicitly
> * valid, but some applications do it.
> */
> -  if (earlier->data.mode != var->data.mode &&
> -  !(earlier->data.mode == ir_var_system_value &&
> -var->data.mode == ir_var_shader_in)) {
> - _mesa_glsl_error(, state,
> -  "redeclaration of `%s' with incorrect qualifiers",
> -  var->name);
> -  } else if (earlier->type != var->type) {
> - _mesa_glsl_error(, state,
> -  "redeclaration of `%s' has incorrect type",
> -  var->name);
> -  }
> -   } else if (allow_all_redeclarations) {
> -  if 

[Mesa-dev] [PATCH 28/28] remove final imports.h bits

2018-11-09 Thread Dylan Baker
This moves the fi_types to a new mesa_private.h and removes the
imports.c file. The vast majority of this patch is just removing
pound includes of imports.h and fixing up the recursive includes.
---
 src/Makefile.am   |  1 -
 src/compiler/glsl/glsl_to_nir.cpp |  1 -
 src/compiler/glsl/linker.cpp  |  1 -
 src/compiler/nir/nir_opt_copy_propagate.c |  1 -
 src/gallium/state_trackers/glx/xlib/glx_api.c |  1 -
 src/gallium/state_trackers/glx/xlib/xm_api.c  |  1 -
 src/mapi/glapi/gen/gl_genexec.py  |  2 +-
 src/mapi/glapi/gen/gl_table.py|  1 +
 src/mesa/Makefile.sources |  3 +-
 src/mesa/drivers/common/driverfuncs.c |  1 -
 src/mesa/drivers/common/meta_blit.c   |  1 -
 src/mesa/drivers/dri/i915/i830_context.c  |  1 -
 src/mesa/drivers/dri/i915/i915_context.c  |  1 -
 src/mesa/drivers/dri/i915/i915_debug_fp.c |  4 +-
 src/mesa/drivers/dri/i915/i915_vtbl.c |  1 -
 src/mesa/drivers/dri/i915/intel_context.c |  1 -
 src/mesa/drivers/dri/i915/intel_fbo.c |  1 -
 src/mesa/drivers/dri/i915/intel_render.c  |  1 -
 src/mesa/drivers/dri/i915/intel_syncobj.c |  2 -
 .../drivers/dri/i965/brw_conditional_render.c |  1 -
 src/mesa/drivers/dri/i965/brw_context.c   |  1 -
 .../drivers/dri/i965/brw_object_purgeable.c   |  1 -
 .../drivers/dri/i965/brw_primitive_restart.c  |  1 -
 src/mesa/drivers/dri/i965/brw_program.c   |  1 -
 src/mesa/drivers/dri/i965/brw_program_cache.c |  1 -
 src/mesa/drivers/dri/i965/brw_queryobj.c  |  2 -
 src/mesa/drivers/dri/i965/brw_sync.c  |  2 -
 src/mesa/drivers/dri/i965/gen6_queryobj.c |  2 -
 src/mesa/drivers/dri/i965/hsw_queryobj.c  |  2 -
 .../drivers/dri/i965/intel_buffer_objects.c   |  1 -
 src/mesa/drivers/dri/i965/intel_fbo.c |  1 -
 src/mesa/drivers/dri/i965/intel_upload.c  |  1 -
 src/mesa/drivers/dri/nouveau/nouveau_driver.h |  1 -
 src/mesa/drivers/dri/r200/r200_cmdbuf.c   |  1 -
 src/mesa/drivers/dri/r200/r200_context.c  |  1 -
 src/mesa/drivers/dri/r200/r200_ioctl.c|  1 -
 src/mesa/drivers/dri/r200/r200_maos_arrays.c  |  1 -
 src/mesa/drivers/dri/r200/r200_sanity.c   |  1 -
 src/mesa/drivers/dri/r200/r200_state.c|  1 -
 src/mesa/drivers/dri/r200/r200_state_init.c   |  1 -
 src/mesa/drivers/dri/r200/r200_swtcl.c|  1 -
 src/mesa/drivers/dri/r200/r200_tcl.c  |  1 -
 src/mesa/drivers/dri/r200/r200_tex.c  |  1 -
 src/mesa/drivers/dri/r200/r200_texstate.c |  1 -
 .../dri/radeon/radeon_buffer_objects.c|  1 -
 src/mesa/drivers/dri/radeon/radeon_common.c   |  1 -
 src/mesa/drivers/dri/radeon/radeon_context.c  |  1 -
 src/mesa/drivers/dri/radeon/radeon_fbo.c  |  1 -
 src/mesa/drivers/dri/radeon/radeon_fog.c  |  1 -
 src/mesa/drivers/dri/radeon/radeon_ioctl.c|  1 -
 .../drivers/dri/radeon/radeon_maos_arrays.c   |  1 -
 .../drivers/dri/radeon/radeon_maos_verts.c|  1 -
 src/mesa/drivers/dri/radeon/radeon_queryobj.c |  2 -
 src/mesa/drivers/dri/radeon/radeon_queryobj.h |  1 -
 src/mesa/drivers/dri/radeon/radeon_screen.c   |  1 -
 src/mesa/drivers/dri/radeon/radeon_state.c|  1 -
 .../drivers/dri/radeon/radeon_state_init.c|  1 -
 src/mesa/drivers/dri/radeon/radeon_swtcl.c|  1 -
 src/mesa/drivers/dri/radeon/radeon_tcl.c  |  1 -
 src/mesa/drivers/dri/radeon/radeon_tex.c  |  1 -
 src/mesa/drivers/dri/radeon/radeon_texstate.c |  1 -
 src/mesa/drivers/dri/radeon/radeon_texture.c  |  1 -
 src/mesa/drivers/dri/swrast/swrast.c  |  1 -
 src/mesa/drivers/osmesa/osmesa.c  |  1 -
 src/mesa/drivers/x11/fakeglx.c|  1 -
 src/mesa/drivers/x11/xfonts.c |  1 -
 src/mesa/drivers/x11/xm_api.c |  1 -
 src/mesa/drivers/x11/xm_buffer.c  |  1 -
 src/mesa/drivers/x11/xm_dd.c  |  1 -
 src/mesa/drivers/x11/xm_tri.c |  1 -
 src/mesa/main/accum.c |  1 -
 src/mesa/main/api_arrayelt.c  |  1 -
 src/mesa/main/arbprogram.c|  1 -
 src/mesa/main/arrayobj.c  |  1 -
 src/mesa/main/atifragshader.c |  1 -
 src/mesa/main/attrib.c|  1 -
 src/mesa/main/context.c   |  1 -
 src/mesa/main/context.h   |  1 -
 src/mesa/main/cpuinfo.c   |  5 +-
 src/mesa/main/debug_output.c  |  1 -
 src/mesa/main/depth.c |  1 -
 src/mesa/main/draw_validate.c |  1 -
 src/mesa/main/drawtex.c   |  1 -
 src/mesa/main/es1_conversion.c|  1 -
 src/mesa/main/execmem.c   |  1 -
 src/mesa/main/execmem.h   |  1 +
 src/mesa/main/extensions.c|  1 -
 src/mesa/main/ff_fragment_shader.cpp  |  1 -
 src/mesa/main/format_utils.h   

[Mesa-dev] [PATCH 24/28] replace malloc macros in imports.h with u_memory.h versions

2018-11-09 Thread Dylan Baker
---
 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c   |  1 +
 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c   |  2 ++
 src/gallium/state_trackers/dri/dri_context.c|  2 ++
 src/gallium/state_trackers/glx/xlib/glx_api.c   |  1 +
 src/gallium/state_trackers/glx/xlib/xm_api.c|  1 +
 src/mesa/drivers/common/meta.c  |  1 +
 src/mesa/drivers/dri/i915/intel_buffer_objects.c|  1 +
 src/mesa/drivers/dri/i915/intel_fbo.c   |  1 +
 src/mesa/drivers/dri/i915/intel_screen.c|  1 +
 src/mesa/drivers/dri/i915/intel_tex.c   |  1 +
 src/mesa/drivers/dri/i965/brw_program_cache.c   |  1 +
 src/mesa/drivers/dri/i965/gen6_sol.c|  1 +
 src/mesa/drivers/dri/i965/intel_buffer_objects.c|  1 +
 src/mesa/drivers/dri/i965/intel_fbo.c   |  1 +
 src/mesa/drivers/dri/i965/intel_screen.c|  1 +
 src/mesa/drivers/dri/i965/intel_tex.c   |  1 +
 src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c|  1 +
 src/mesa/drivers/dri/nouveau/nouveau_fbo.c  |  1 +
 src/mesa/drivers/dri/nouveau/nouveau_screen.c   |  1 +
 src/mesa/drivers/dri/nouveau/nouveau_texture.c  |  1 +
 src/mesa/drivers/dri/nouveau/nv04_context.c |  1 +
 src/mesa/drivers/dri/nouveau/nv10_context.c |  1 +
 src/mesa/drivers/dri/nouveau/nv20_context.c |  1 +
 src/mesa/drivers/dri/r200/r200_tex.c|  1 +
 src/mesa/drivers/dri/radeon/radeon_buffer_objects.c |  1 +
 src/mesa/drivers/dri/radeon/radeon_dma.c|  1 +
 src/mesa/drivers/dri/radeon/radeon_fbo.c|  1 +
 src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c|  1 +
 src/mesa/drivers/dri/radeon/radeon_screen.c |  1 +
 src/mesa/drivers/dri/radeon/radeon_tex.c|  1 +
 src/mesa/drivers/dri/swrast/swrast.c|  1 +
 src/mesa/drivers/osmesa/osmesa.c|  1 +
 src/mesa/drivers/x11/xm_api.c   |  1 +
 src/mesa/drivers/x11/xm_buffer.c|  1 +
 src/mesa/drivers/x11/xm_dd.c|  1 +
 src/mesa/main/arrayobj.c|  1 +
 src/mesa/main/atifragshader.c   |  1 +
 src/mesa/main/attrib.c  |  1 +
 src/mesa/main/bufferobj.c   |  1 +
 src/mesa/main/context.c |  1 +
 src/mesa/main/debug_output.c|  1 +
 src/mesa/main/dlist.c   |  1 +
 src/mesa/main/externalobjects.c |  1 +
 src/mesa/main/framebuffer.c |  1 +
 src/mesa/main/hash.c|  1 +
 src/mesa/main/imports.h | 13 -
 src/mesa/main/queryobj.c|  1 +
 src/mesa/main/renderbuffer.c|  1 +
 src/mesa/main/samplerobj.c  |  1 +
 src/mesa/main/shared.c  |  1 +
 src/mesa/main/syncobj.c |  1 +
 src/mesa/main/texobj.c  |  1 +
 src/mesa/main/texturebindless.c |  1 +
 src/mesa/main/transformfeedback.c   |  2 ++
 src/mesa/main/vdpau.c   |  1 +
 src/mesa/program/prog_cache.c   |  1 +
 src/mesa/program/prog_parameter.c   |  1 +
 src/mesa/program/program_parse.y|  1 +
 src/mesa/state_tracker/st_cb_syncobj.c  |  1 +
 src/mesa/state_tracker/st_cb_xformfb.c  |  1 +
 src/mesa/state_tracker/st_manager.c |  1 +
 src/mesa/state_tracker/st_program.c |  2 ++
 src/mesa/swrast/s_renderbuffer.c|  1 +
 src/mesa/swrast/s_texture.c |  1 +
 src/mesa/tnl/t_context.c|  1 +
 src/mesa/tnl/t_vertex.c |  1 +
 src/mesa/vbo/vbo_context.c  |  1 +
 src/mesa/vbo/vbo_minmax_index.c |  1 +
 src/mesa/vbo/vbo_save_api.c |  1 +
 src/util/hash_table.c   |  1 +
 70 files changed, 73 insertions(+), 13 deletions(-)

diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c 
b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
index 8f901e11d26..c8805de54b8 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
@@ -37,6 +37,7 @@
 #include 
 
 #include "util/u_atomic.h"
+#include "util/u_memory.h"
 
 static void radv_amdgpu_winsys_bo_destroy(struct radeon_winsys_bo *_bo);
 
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c 
b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
index cd8b13813d2..213ee3196e5 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
@@ -29,6 +29,8 @@
 #include 
 #include 
 
+#include 

[Mesa-dev] [PATCH 01/28] replace _mesa_is_pow_two with util_is_power_of_two_*

2018-11-09 Thread Dylan Baker
mostly this uses util_is_power_of_two_or_zero, which has the same
behavior as _mesa_is_pow_two when the input is zero. In cases where the
value is known to be != 0 ahead of time I used the _nonzero variant as
it may be faster on some platforms.
---
 src/intel/compiler/brw_reg.h  |  2 +-
 src/intel/compiler/brw_vec4_generator.cpp |  3 +--
 src/mesa/drivers/common/meta_blit.c   |  6 ++---
 src/mesa/drivers/dri/i915/i915_texstate.c |  2 +-
 src/mesa/drivers/dri/nouveau/nv04_surface.c   |  4 +--
 .../drivers/dri/radeon/radeon_mipmap_tree.c   |  2 +-
 src/mesa/main/imports.h   | 10 ---
 src/mesa/main/macros.h|  4 +--
 src/mesa/main/pixel.c |  6 ++---
 src/mesa/main/teximage.c  | 26 +--
 src/mesa/swrast/s_texture.c   |  6 ++---
 src/mesa/tnl/t_vb_light.c |  2 +-
 12 files changed, 31 insertions(+), 42 deletions(-)

diff --git a/src/intel/compiler/brw_reg.h b/src/intel/compiler/brw_reg.h
index 46d66198a1d..b39aa1cd8e8 100644
--- a/src/intel/compiler/brw_reg.h
+++ b/src/intel/compiler/brw_reg.h
@@ -986,7 +986,7 @@ static inline struct brw_reg
 spread(struct brw_reg reg, unsigned s)
 {
if (s) {
-  assert(_mesa_is_pow_two(s));
+  assert(util_is_power_of_two_or_zero(s));
 
   if (reg.hstride)
  reg.hstride += cvt(s) - 1;
diff --git a/src/intel/compiler/brw_vec4_generator.cpp 
b/src/intel/compiler/brw_vec4_generator.cpp
index 888cb358fd1..30a85b923ce 100644
--- a/src/intel/compiler/brw_vec4_generator.cpp
+++ b/src/intel/compiler/brw_vec4_generator.cpp
@@ -2057,8 +2057,7 @@ generate_code(struct brw_codegen *p,
   *
   * where they pack the four bytes from the low and high four DW.
   */
- assert(_mesa_is_pow_two(dst.writemask) &&
-dst.writemask != 0);
+ assert(util_is_power_of_two_nonzero(dst.writemask));
  unsigned offset = __builtin_ctz(dst.writemask);
 
  dst.type = BRW_REGISTER_TYPE_UB;
diff --git a/src/mesa/drivers/common/meta_blit.c 
b/src/mesa/drivers/common/meta_blit.c
index 496ef285d02..54ad72bae53 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -85,7 +85,7 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
y_scale = samples / x_scale;
 
/* We expect only power of 2 samples in source multisample buffer. */
-   assert(samples > 0 && _mesa_is_pow_two(samples));
+   assert(samples > 0 && util_is_power_of_two_nonzero(samples));
while (samples >> (shader_offset + 1)) {
   shader_offset++;
}
@@ -278,7 +278,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
}
 
/* We expect only power of 2 samples in source multisample buffer. */
-   assert(samples > 0 && _mesa_is_pow_two(samples));
+   assert(samples > 0 && util_is_power_of_two_nonzero(samples));
while (samples >> (shader_offset + 1)) {
   shader_offset++;
}
@@ -482,7 +482,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
   * (so the floating point exponent just gets increased), rather than
   * doing a naive sum and dividing.
   */
- assert(_mesa_is_pow_two(samples));
+ assert(util_is_power_of_two_or_zero(samples));
  /* Fetch each individual sample. */
  sample_resolve = rzalloc_size(mem_ctx, 1);
  for (i = 0; i < samples; i++) {
diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c 
b/src/mesa/drivers/dri/i915/i915_texstate.c
index f653f441ad8..d24256c81f0 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -342,7 +342,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint 
unit, GLuint ss3)
* Thus, I guess we need do this for other platforms as well.
*/
   if (tObj->Target == GL_TEXTURE_CUBE_MAP_ARB &&
-  !_mesa_is_pow_two(firstImage->Height))
+  !util_is_power_of_two_or_zero(firstImage->Height))
  return false;
 
   state[I915_TEXREG_SS3] = ss3; /* SS3_NORMALIZED_COORDS */
diff --git a/src/mesa/drivers/dri/nouveau/nv04_surface.c 
b/src/mesa/drivers/dri/nouveau/nv04_surface.c
index b1f0ea0a983..eca53ff7147 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_surface.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_surface.c
@@ -212,8 +212,8 @@ nv04_surface_copy_swizzle(struct gl_context *ctx,
unsigned x, y;
 
 /* Swizzled surfaces must be POT  */
-   assert(_mesa_is_pow_two(dst->width) &&
-  _mesa_is_pow_two(dst->height));
+   assert(util_is_power_of_two_or_zero(dst->width) &&
+  util_is_power_of_two_or_zero(dst->height));
 
if (context_chipset(ctx) < 0x10) {
BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1);
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c 
b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index 19e62969e5c..c4b3c61cbf4 100644

[Mesa-dev] [PATCH 22/28] util: promote u_memory to src/util

2018-11-09 Thread Dylan Baker
as well as os_memory*
---
 src/gallium/auxiliary/Makefile.sources | 5 -
 src/gallium/auxiliary/meson.build  | 5 -
 src/gallium/auxiliary/util/u_debug_memory.c| 4 ++--
 src/gallium/auxiliary/util/u_format.c  | 2 +-
 src/gallium/auxiliary/util/u_format_tests.c| 2 +-
 src/gallium/auxiliary/util/u_log.c | 2 +-
 src/gallium/auxiliary/util/u_prim_restart.c| 2 +-
 src/util/Makefile.sources  | 5 +
 src/{gallium/auxiliary/os => util}/os_memory.h | 0
 src/{gallium/auxiliary/os => util}/os_memory_aligned.h | 0
 src/{gallium/auxiliary/os => util}/os_memory_debug.h   | 0
 src/{gallium/auxiliary/os => util}/os_memory_stdc.h| 0
 src/{gallium/auxiliary => }/util/u_memory.h| 3 +--
 13 files changed, 12 insertions(+), 18 deletions(-)
 rename src/{gallium/auxiliary/os => util}/os_memory.h (100%)
 rename src/{gallium/auxiliary/os => util}/os_memory_aligned.h (100%)
 rename src/{gallium/auxiliary/os => util}/os_memory_debug.h (100%)
 rename src/{gallium/auxiliary/os => util}/os_memory_stdc.h (100%)
 rename src/{gallium/auxiliary => }/util/u_memory.h (98%)

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index b60b25a0e4c..87a490e555d 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -102,10 +102,6 @@ C_SOURCES := \
indices/u_indices_priv.h \
indices/u_primconvert.c \
indices/u_primconvert.h \
-   os/os_memory_aligned.h \
-   os/os_memory_debug.h \
-   os/os_memory_stdc.h \
-   os/os_memory.h \
os/os_mman.h \
os/os_process.c \
os/os_process.h \
@@ -290,7 +286,6 @@ C_SOURCES := \
util/u_linear.h \
util/u_log.c \
util/u_log.h \
-   util/u_memory.h \
util/u_mm.c \
util/u_mm.h \
util/u_network.c \
diff --git a/src/gallium/auxiliary/meson.build 
b/src/gallium/auxiliary/meson.build
index e1497992b17..a4dbcf7b4ca 100644
--- a/src/gallium/auxiliary/meson.build
+++ b/src/gallium/auxiliary/meson.build
@@ -122,10 +122,6 @@ files_libgallium = files(
   'indices/u_indices_priv.h',
   'indices/u_primconvert.c',
   'indices/u_primconvert.h',
-  'os/os_memory_aligned.h',
-  'os/os_memory_debug.h',
-  'os/os_memory_stdc.h',
-  'os/os_memory.h',
   'os/os_mman.h',
   'os/os_process.c',
   'os/os_process.h',
@@ -310,7 +306,6 @@ files_libgallium = files(
   'util/u_linear.h',
   'util/u_log.c',
   'util/u_log.h',
-  'util/u_memory.h',
   'util/u_mm.c',
   'util/u_mm.h',
   'util/u_network.c',
diff --git a/src/gallium/auxiliary/util/u_debug_memory.c 
b/src/gallium/auxiliary/util/u_debug_memory.c
index 0c822369a00..42e29dd6b2a 100644
--- a/src/gallium/auxiliary/util/u_debug_memory.c
+++ b/src/gallium/auxiliary/util/u_debug_memory.c
@@ -36,14 +36,14 @@
 
 #define DEBUG_MEMORY_IMPLEMENTATION
 
-#include "os/os_memory.h"
-#include "os/os_memory_debug.h"
 #include "os/os_thread.h"
 
 #include "util/u_debug.h"
 #include "util/u_debug_gallium.h"
 #include "util/u_debug_stack.h"
 #include "util/list.h"
+#include "util/os_memory.h"
+#include "util/os_memory_debug.h"
 
 
 #define DEBUG_MEMORY_MAGIC 0x6e34090aU
diff --git a/src/gallium/auxiliary/util/u_format.c 
b/src/gallium/auxiliary/util/u_format.c
index 6445f2647cf..e43a619313e 100644
--- a/src/gallium/auxiliary/util/u_format.c
+++ b/src/gallium/auxiliary/util/u_format.c
@@ -32,7 +32,7 @@
  * @author Jose Fonseca 
  */
 
-#include "u_memory.h"
+#include "util/u_memory.h"
 #include "u_format.h"
 #include "u_format_s3tc.h"
 #include "u_surface.h"
diff --git a/src/gallium/auxiliary/util/u_format_tests.c 
b/src/gallium/auxiliary/util/u_format_tests.c
index dee52533c15..94bea2363d0 100644
--- a/src/gallium/auxiliary/util/u_format_tests.c
+++ b/src/gallium/auxiliary/util/u_format_tests.c
@@ -30,7 +30,7 @@
 #include 
 
 #include "pipe/p_config.h"
-#include "u_memory.h"
+#include "util/u_memory.h"
 #include "u_format_tests.h"
 
 
diff --git a/src/gallium/auxiliary/util/u_log.c 
b/src/gallium/auxiliary/util/u_log.c
index dacbe0505e1..90fd24ca394 100644
--- a/src/gallium/auxiliary/util/u_log.c
+++ b/src/gallium/auxiliary/util/u_log.c
@@ -23,7 +23,7 @@
 
 #include "u_log.h"
 
-#include "u_memory.h"
+#include "util/u_memory.h"
 #include "util/u_string.h"
 
 struct page_entry {
diff --git a/src/gallium/auxiliary/util/u_prim_restart.c 
b/src/gallium/auxiliary/util/u_prim_restart.c
index 9ff93a7f669..10e39e240db 100644
--- a/src/gallium/auxiliary/util/u_prim_restart.c
+++ b/src/gallium/auxiliary/util/u_prim_restart.c
@@ -26,7 +26,7 @@
 
 
 #include "u_inlines.h"
-#include "u_memory.h"
+#include "util/u_memory.h"
 #include "u_prim_restart.h"
 
 
diff --git a/src/util/Makefile.sources b/src/util/Makefile.sources
index b4d23947ab7..f09b89b3be5 100644
--- a/src/util/Makefile.sources
+++ b/src/util/Makefile.sources
@@ -72,6 +72,11 @@ 

[Mesa-dev] [PATCH 15/28] replace _mesa_snprintf with util_snprintf

2018-11-09 Thread Dylan Baker
---
 src/mapi/glapi/gen/gl_enums.py  |  4 ++--
 src/mesa/drivers/common/meta.c  |  6 +++---
 src/mesa/main/debug.c   |  8 
 src/mesa/main/dlist.c   |  5 +++--
 src/mesa/main/errors.c  |  7 +++
 src/mesa/main/imports.c | 14 --
 src/mesa/main/imports.h |  3 ---
 src/mesa/main/teximage.c| 16 
 src/mesa/main/uniform_query.cpp |  7 ---
 src/mesa/main/version.c | 18 +-
 src/mesa/program/prog_instruction.c |  5 +++--
 src/mesa/program/prog_print.c   |  9 +
 src/mesa/program/program_parse.y| 17 +
 13 files changed, 53 insertions(+), 66 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py
index 00f8134bae2..4f4feaf3f88 100644
--- a/src/mapi/glapi/gen/gl_enums.py
+++ b/src/mapi/glapi/gen/gl_enums.py
@@ -52,8 +52,8 @@ class PrintGlEnums(gl_XML.gl_print_base):
 def printRealHeader(self):
 print('#include "main/glheader.h"')
 print('#include "main/enums.h"')
-print('#include "main/imports.h"')
 print('#include "main/mtypes.h"')
+print('#include "util/u_string.h"')
 print('')
 print('typedef struct PACKED {')
 print('   uint32_t offset;')
@@ -103,7 +103,7 @@ _mesa_enum_to_string(int nr)
}
else {
   /* this is not re-entrant safe, no big deal here */
-  _mesa_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr);
+  util_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr);
   token_tmp[sizeof(token_tmp) - 1] = '\\0';
   return token_tmp;
}
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 4392c4bbd88..89dc8b26d52 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -33,7 +33,6 @@
 
 #include "main/glheader.h"
 #include "main/mtypes.h"
-#include "main/imports.h"
 #include "main/arbprogram.h"
 #include "main/arrayobj.h"
 #include "main/blend.h"
@@ -90,6 +89,7 @@
 #include "util/ralloc.h"
 #include "compiler/nir/nir.h"
 #include "util/u_math.h"
+#include "util/u_string.h"
 
 /** Return offset in bytes of the field within a vertex struct */
 #define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
@@ -2047,7 +2047,7 @@ init_draw_stencil_pixels(struct gl_context *ctx)
   texTarget = "RECT";
else
   texTarget = "2D";
-   _mesa_snprintf(program2, sizeof(program2), program, texTarget);
+   util_snprintf(program2, sizeof(program2), program, texTarget);
 
_mesa_GenProgramsARB(1, >StencilFP);
_mesa_BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, drawpix->StencilFP);
@@ -2081,7 +2081,7 @@ init_draw_depth_pixels(struct gl_context *ctx)
   texTarget = "RECT";
else
   texTarget = "2D";
-   _mesa_snprintf(program2, sizeof(program2), program, texTarget);
+   util_snprintf(program2, sizeof(program2), program, texTarget);
 
_mesa_GenProgramsARB(1, >DepthFP);
_mesa_BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, drawpix->DepthFP);
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index b1fa1f067ff..a3905c2b4ab 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -30,13 +30,13 @@
 #include "enums.h"
 #include "formats.h"
 #include "hash.h"
-#include "imports.h"
 #include "macros.h"
 #include "debug.h"
 #include "get.h"
 #include "pixelstore.h"
 #include "readpix.h"
 #include "texobj.h"
+#include "util/u_string.h"
 
 
 static const char *
@@ -285,7 +285,7 @@ write_texture_image(struct gl_texture_object *texObj,
  GL_RGBA, GL_UNSIGNED_BYTE, buffer, img);
 
   /* make filename */
-  _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, 
level, face);
+  util_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, 
level, face);
 
   printf("  Writing image level %u to %s\n", level, s);
   write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE);
@@ -331,8 +331,8 @@ _mesa_write_renderbuffer_image(const struct gl_renderbuffer 
*rb)
   format, type, >DefaultPacking, buffer);
 
/* make filename */
-   _mesa_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name);
-   _mesa_snprintf(s, sizeof(s), "C:\\renderbuffer%u.ppm", rb->Name);
+   util_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name);
+   util_snprintf(s, sizeof(s), "C:\\renderbuffer%u.ppm", rb->Name);
 
printf("  Writing renderbuffer image to %s\n", s);
 
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 97461cede34..c530e118dd3 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -31,7 +31,6 @@
 
 #include "c99_math.h"
 #include "glheader.h"
-#include "imports.h"
 #include "api_arrayelt.h"
 #include "api_exec.h"
 #include "api_loopback.h"
@@ -71,6 +70,8 @@
 
 #include "vbo/vbo.h"
 
+#include "util/u_string.h"
+
 
 #define USE_BITMAP_ATLAS 1
 
@@ -10736,7 +10737,7 @@ execute_list(struct 

[Mesa-dev] [PATCH 21/28] Replace IS_INF_OR_NAN with util_is_inf_or_nan

2018-11-09 Thread Dylan Baker
---
 src/mesa/main/draw.c|  4 ++--
 src/mesa/main/imports.h | 23 ---
 src/mesa/program/prog_execute.c | 28 ++--
 src/mesa/swrast/s_aalinetemp.h  |  2 +-
 src/mesa/swrast/s_aatritemp.h   |  2 +-
 src/mesa/swrast/s_linetemp.h|  2 +-
 src/mesa/swrast/s_points.c  |  2 +-
 src/mesa/swrast/s_tritemp.h |  3 ++-
 src/mesa/tnl/t_split_copy.c |  2 +-
 src/mesa/tnl/t_vb_cliptmp.h |  8 
 src/mesa/tnl/t_vb_program.c |  2 +-
 11 files changed, 28 insertions(+), 50 deletions(-)

diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index 99ea4d928be..d22cdc4eff6 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -88,7 +88,7 @@ check_array_data(struct gl_context *ctx, struct 
gl_vertex_array_object *vao,
 GLfloat *f = (GLfloat *) ((GLubyte *) data + binding->Stride * j);
 GLint k;
 for (k = 0; k < array->Size; k++) {
-   if (IS_INF_OR_NAN(f[k]) || f[k] >= 1.0e20F || f[k] <= -1.0e10F) 
{
+   if (util_is_inf_or_nan(f[k]) || f[k] >= 1.0e20F || f[k] <= 
-1.0e10F) {
   printf("Bad array data:\n");
   printf("  Element[%u].%u = %f\n", j, k, f[k]);
   printf("  Array %u at %p\n", attrib, (void *) array);
@@ -98,7 +98,7 @@ check_array_data(struct gl_context *ctx, struct 
gl_vertex_array_object *vao,
  array->Ptr, bo->Name);
   f[k] = 1.0F;  /* XXX replace the bad value! */
}
-   /*assert(!IS_INF_OR_NAN(f[k])); */
+   /*assert(!util_is_inf_or_nan(f[k])); */
 }
  }
  break;
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 555abda6983..1aaa9d88294 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -84,29 +84,6 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
 /*@}*/
 
 
-
-/**
- * finite macro.
- */
-#if defined(_MSC_VER)
-#  define finite _finite
-#endif
-
-
-/***
- *** IS_INF_OR_NAN: test if float is infinite or NaN
- ***/
-#if defined(isfinite)
-#define IS_INF_OR_NAN(x)(!isfinite(x))
-#elif defined(finite)
-#define IS_INF_OR_NAN(x)(!finite(x))
-#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#define IS_INF_OR_NAN(x)(!isfinite(x))
-#else
-#define IS_INF_OR_NAN(x)(!finite(x))
-#endif
-
-
 /**
  * Functions
  */
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index 6ada78565cc..956b84a20d6 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -213,10 +213,10 @@ fetch_vector4(const struct prog_src_register *source,
}
 
 #ifdef NAN_CHECK
-   assert(!IS_INF_OR_NAN(result[0]));
-   assert(!IS_INF_OR_NAN(result[0]));
-   assert(!IS_INF_OR_NAN(result[0]));
-   assert(!IS_INF_OR_NAN(result[0]));
+   assert(!util_is_inf_or_nan(result[0]));
+   assert(!util_is_inf_or_nan(result[0]));
+   assert(!util_is_inf_or_nan(result[0]));
+   assert(!util_is_inf_or_nan(result[0]));
 #endif
 }
 
@@ -332,9 +332,9 @@ store_vector4(const struct prog_instruction *inst,
 
 #if 0
if (value[0] > 1.0e10 ||
-   IS_INF_OR_NAN(value[0]) ||
-   IS_INF_OR_NAN(value[1]) ||
-   IS_INF_OR_NAN(value[2]) || IS_INF_OR_NAN(value[3]))
+   util_is_inf_or_nan(value[0]) ||
+   util_is_inf_or_nan(value[1]) ||
+   util_is_inf_or_nan(value[2]) || util_is_inf_or_nan(value[3]))
   printf("store %g %g %g %g\n", value[0], value[1], value[2], value[3]);
 #endif
 
@@ -347,10 +347,10 @@ store_vector4(const struct prog_instruction *inst,
}
 
 #ifdef NAN_CHECK
-   assert(!IS_INF_OR_NAN(value[0]));
-   assert(!IS_INF_OR_NAN(value[0]));
-   assert(!IS_INF_OR_NAN(value[0]));
-   assert(!IS_INF_OR_NAN(value[0]));
+   assert(!util_is_inf_or_nan(value[0]));
+   assert(!util_is_inf_or_nan(value[0]));
+   assert(!util_is_inf_or_nan(value[0]));
+   assert(!util_is_inf_or_nan(value[0]));
 #endif
 
if (writeMask & WRITEMASK_X)
@@ -614,7 +614,7 @@ _mesa_execute_program(struct gl_context * ctx,
 fetch_vector1(>SrcReg[0], machine, a);
 val = exp2f(a[0]);
 /*
-if (IS_INF_OR_NAN(val))
+if (util_is_inf_or_nan(val))
val = 1.0e10;
 */
 result[0] = result[1] = result[2] = result[3] = val;
@@ -744,7 +744,7 @@ _mesa_execute_program(struct gl_context * ctx,
 fetch_vector1(>SrcReg[0], machine, t);
 abs_t0 = fabsf(t[0]);
 if (abs_t0 != 0.0F) {
-   if (IS_INF_OR_NAN(abs_t0))
+   if (util_is_inf_or_nan(abs_t0))
{
   SET_POS_INFINITY(q[0]);
   q[1] = 1.0F;
@@ -931,7 +931,7 @@ _mesa_execute_program(struct gl_context * ctx,
 if (DEBUG_PROG) {
if (a[0] == 0)
   printf("RCP(0)\n");
- 

[Mesa-dev] [PATCH 20/28] move windows strtok_r define to u_string

2018-11-09 Thread Dylan Baker
This makes more sense for it, it's only used in the glsl compiler
currently, so we could probably move it there, but this seems fine for a
header only #define.
---
 src/mesa/main/imports.h | 4 
 src/util/u_string.h | 4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index b2f6fe22bc9..555abda6983 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -125,10 +125,6 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, 
size_t newSize,
 unsigned long alignment);
 
 
-#if defined(_WIN32) && !defined(strtok_r)
-#define strtok_r strtok_s
-#endif
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/util/u_string.h b/src/util/u_string.h
index e4081466459..e3ac3a5879f 100644
--- a/src/util/u_string.h
+++ b/src/util/u_string.h
@@ -206,6 +206,10 @@ util_strstr(const char *haystack, const char *needle)
 #define util_strcasecmp stricmp
 #define util_strdup _strdup
 
+#if !defined(strtok_r)
+#define strtok_r strtok_s
+#endif
+
 #else
 
 #define util_vsnprintf vsnprintf
-- 
2.19.1

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


[Mesa-dev] [PATCH 26/28] replace imports memory functions with utils memory functions

2018-11-09 Thread Dylan Baker
---
 src/compiler/SConscript.glsl  |   2 -
 src/mesa/Android.libmesa_glsl_utils.mk|   2 -
 .../drivers/dri/i915/intel_buffer_objects.c   |  19 ++-
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c |   9 +-
 src/mesa/main/bufferobj.c |   7 +-
 src/mesa/main/imports.c   | 148 --
 src/mesa/main/imports.h   |  18 ---
 src/mesa/math/m_debug_norm.c  |   5 +-
 src/mesa/math/m_debug_xform.c |   5 +-
 src/mesa/math/m_matrix.c  |  11 +-
 src/mesa/math/m_vector.c  |   7 +-
 src/mesa/program/prog_parameter.c |  15 +-
 src/mesa/swrast/s_texture.c   |   4 +-
 src/mesa/tnl/t_vb_program.c   |   6 +-
 src/mesa/tnl/t_vb_vertex.c|   6 +-
 src/mesa/tnl/t_vertex.c   |   4 +-
 src/mesa/vbo/vbo_exec_api.c   |   7 +-
 17 files changed, 52 insertions(+), 223 deletions(-)

diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl
index a25374fce3d..8154aa6d9e8 100644
--- a/src/compiler/SConscript.glsl
+++ b/src/compiler/SConscript.glsl
@@ -69,7 +69,6 @@ if env['msvc']:
 
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/main'])
-env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', 
'$SOURCE'))
 env.Command('glsl/extensions_table.c', '#src/mesa/main/extensions_table.c', 
Copy('$TARGET', '$SOURCE'))
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/program'])
@@ -80,7 +79,6 @@ compiler_objs = 
env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
 
 mesa_objs = env.StaticObject([
 'glsl/extensions_table.c',
-'glsl/imports.c',
 'glsl/symbol_table.c',
 'glsl/dummy_errors.c',
 ])
diff --git a/src/mesa/Android.libmesa_glsl_utils.mk 
b/src/mesa/Android.libmesa_glsl_utils.mk
index 0d83cd5a9bf..66b6ef13a61 100644
--- a/src/mesa/Android.libmesa_glsl_utils.mk
+++ b/src/mesa/Android.libmesa_glsl_utils.mk
@@ -43,7 +43,6 @@ LOCAL_C_INCLUDES := \
 
 LOCAL_SRC_FILES := \
main/extensions_table.c \
-   main/imports.c \
program/symbol_table.c \
program/dummy_errors.c
 
@@ -68,7 +67,6 @@ LOCAL_C_INCLUDES := \
 
 LOCAL_SRC_FILES := \
main/extensions_table.c \
-   main/imports.c \
program/symbol_table.c \
program/dummy_errors.c
 
diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c 
b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
index f4e9fcfefee..a1b47134865 100644
--- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
@@ -26,7 +26,6 @@
  **/
 
 
-#include "main/imports.h"
 #include "main/mtypes.h"
 #include "main/macros.h"
 #include "main/bufferobj.h"
@@ -97,7 +96,7 @@ intel_bufferobj_free(struct gl_context * ctx, struct 
gl_buffer_object *obj)
 */
_mesa_buffer_unmap_all_mappings(ctx, obj);
 
-   _mesa_align_free(intel_obj->sys_buffer);
+   align_free(intel_obj->sys_buffer);
 
drm_intel_bo_unreference(intel_obj->buffer);
_mesa_delete_buffer_object(ctx, obj);
@@ -134,7 +133,7 @@ intel_bufferobj_data(struct gl_context * ctx,
if (intel_obj->buffer != NULL)
   release_buffer(intel_obj);
 
-   _mesa_align_free(intel_obj->sys_buffer);
+   align_free(intel_obj->sys_buffer);
intel_obj->sys_buffer = NULL;
 
if (size != 0) {
@@ -143,7 +142,7 @@ intel_bufferobj_data(struct gl_context * ctx,
*/
   if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
 intel_obj->sys_buffer =
-_mesa_align_malloc(size, ctx->Const.MinMapBufferAlignment);
+align_malloc(size, ctx->Const.MinMapBufferAlignment);
 if (intel_obj->sys_buffer != NULL) {
if (data != NULL)
   memcpy(intel_obj->sys_buffer, data, size);
@@ -194,7 +193,7 @@ intel_bufferobj_subdata(struct gl_context * ctx,
 return;
   }
 
-  _mesa_align_free(intel_obj->sys_buffer);
+  align_free(intel_obj->sys_buffer);
   intel_obj->sys_buffer = NULL;
}
 
@@ -302,7 +301,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 return obj->Mappings[index].Pointer;
   }
 
-  _mesa_align_free(intel_obj->sys_buffer);
+  align_free(intel_obj->sys_buffer);
   intel_obj->sys_buffer = NULL;
}
 
@@ -351,7 +350,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 
   if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {
  intel_obj->range_map_buffer[index] =
-_mesa_align_malloc(length + extra, alignment);
+align_malloc(length + extra, alignment);
  obj->Mappings[index].Pointer =
 intel_obj->range_map_buffer[index] + extra;
   } else {
@@ -446,7 +445,7 @@ intel_bufferobj_unmap(struct 

[Mesa-dev] [PATCH 06/28] dri/osmesa: use preprocessor for selecting endian code paths

2018-11-09 Thread Dylan Baker
---
 src/mesa/drivers/osmesa/osmesa.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 44374a2e917..9f25f4f9a47 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -455,10 +455,11 @@ osmesa_renderbuffer_storage(struct gl_context *ctx, 
struct gl_renderbuffer *rb,
 */
if (osmesa->format == OSMESA_RGBA) {
   if (osmesa->DataType == GL_UNSIGNED_BYTE) {
- if (_mesa_little_endian())
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
 rb->Format = MESA_FORMAT_R8G8B8A8_UNORM;
- else
+#else
 rb->Format = MESA_FORMAT_A8B8G8R8_UNORM;
+#endif
   }
   else if (osmesa->DataType == GL_UNSIGNED_SHORT) {
  rb->Format = MESA_FORMAT_RGBA_UNORM16;
@@ -469,10 +470,11 @@ osmesa_renderbuffer_storage(struct gl_context *ctx, 
struct gl_renderbuffer *rb,
}
else if (osmesa->format == OSMESA_BGRA) {
   if (osmesa->DataType == GL_UNSIGNED_BYTE) {
- if (_mesa_little_endian())
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
 rb->Format = MESA_FORMAT_B8G8R8A8_UNORM;
- else
+#else
 rb->Format = MESA_FORMAT_A8R8G8B8_UNORM;
+#endif
   }
   else if (osmesa->DataType == GL_UNSIGNED_SHORT) {
  _mesa_warning(ctx, "Unsupported OSMesa format BGRA/GLushort");
@@ -485,10 +487,11 @@ osmesa_renderbuffer_storage(struct gl_context *ctx, 
struct gl_renderbuffer *rb,
}
else if (osmesa->format == OSMESA_ARGB) {
   if (osmesa->DataType == GL_UNSIGNED_BYTE) {
- if (_mesa_little_endian())
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
 rb->Format = MESA_FORMAT_A8R8G8B8_UNORM;
- else
+#else
 rb->Format = MESA_FORMAT_B8G8R8A8_UNORM;
+#endif
   }
   else if (osmesa->DataType == GL_UNSIGNED_SHORT) {
  _mesa_warning(ctx, "Unsupported OSMesa format ARGB/GLushort");
-- 
2.19.1

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


[Mesa-dev] [PATCH 17/28] mesa/main: remove unused IROUNDD

2018-11-09 Thread Dylan Baker
---
 src/mesa/main/imports.h | 8 
 1 file changed, 8 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index fbb7e59ca06..165a9ce05e1 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -119,14 +119,6 @@ static inline int IROUND(float f)
return (int) ((f >= 0.0F) ? (f + 0.5F) : (f - 0.5F));
 }
 
-/**
- * Convert double to int by rounding to nearest integer, away from zero.
- */
-static inline int IROUNDD(double d)
-{
-   return (int) ((d >= 0.0) ? (d + 0.5) : (d - 0.5));
-}
-
 /**
  * Convert float to int64 by rounding to nearest integer.
  */
-- 
2.19.1

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


[Mesa-dev] [PATCH 11/28] replace LOG2 with util_fast_log2

2018-11-09 Thread Dylan Baker
The implementation is somewhat different, although if you go back in
time far enough they're the same, but the one in u_math was changed a
long time back to be faster.
---
 src/mesa/main/imports.h   | 29 -
 src/mesa/swrast/s_span.c  |  4 ++--
 src/mesa/swrast/s_texfilter.c |  2 +-
 3 files changed, 3 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 7e067dd23e3..461e801bc31 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -88,35 +88,6 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
 /*@}*/
 
 
-/***
- *** LOG2: Log base 2 of float
- ***/
-static inline GLfloat LOG2(GLfloat x)
-{
-#if 0
-   /* This is pretty fast, but not accurate enough (only 2 fractional bits).
-* Based on code from http://www.stereopsis.com/log2.html
-*/
-   const GLfloat y = x * x * x * x;
-   const GLuint ix = *((GLuint *) );
-   const GLuint exp = (ix >> 23) & 0xFF;
-   const GLint log2 = ((GLint) exp) - 127;
-   return (GLfloat) log2 * (1.0 / 4.0);  /* 4, because of x^4 above */
-#endif
-   /* Pretty fast, and accurate.
-* Based on code from http://www.flipcode.com/totd/
-*/
-   fi_type num;
-   GLint log_2;
-   num.f = x;
-   log_2 = ((num.i >> 23) & 255) - 128;
-   num.i &= ~(255 << 23);
-   num.i += 127 << 23;
-   num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
-   return num.f + log_2;
-}
-
-
 
 /**
  * finite macro.
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index f50b549a97f..e0d60deea7b 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -426,7 +426,7 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat 
dtdx, GLfloat dtdy,
GLfloat x = sqrtf(dudx * dudx + dvdx * dvdx);
GLfloat y = sqrtf(dudy * dudy + dvdy * dvdy);
GLfloat rho = MAX2(x, y);
-   GLfloat lambda = LOG2(rho);
+   GLfloat lambda = util_fast_log2(rho);
return lambda;
 }
 
@@ -453,7 +453,7 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat 
dtdx, GLfloat dtdy,
maxU = MAX2(dsdx2, dsdy2) * texW;
maxV = MAX2(dtdx2, dtdy2) * texH;
rho = MAX2(maxU, maxV);
-   lambda = LOG2(rho);
+   lambda = util_fast_log2(rho);
return lambda;
 }
 #endif
diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index 314170fc751..acc470f46ef 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -1961,7 +1961,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
   /* note: we need to have Pmin=sqrt(Pmin2) here, but we can avoid
* this since 0.5*log(x) = log(sqrt(x))
*/
-  lod = 0.5f * LOG2(Pmin2);
+  lod = 0.5f * util_fast_log2(Pmin2);
   
   if (adjustLOD) {
  /* from swrast/s_texcombine.c _swrast_texture_span */
-- 
2.19.1

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


[Mesa-dev] [PATCH 09/28] mesa/swrast: replace instances of _mesa_little_endian with preprocessor

2018-11-09 Thread Dylan Baker
---
 src/mesa/swrast/s_renderbuffer.c | 9 -
 src/mesa/swrast/s_triangle.c | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c
index 8c97e4e11b4..ab4932728a9 100644
--- a/src/mesa/swrast/s_renderbuffer.c
+++ b/src/mesa/swrast/s_renderbuffer.c
@@ -76,14 +76,13 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct 
gl_renderbuffer *rb,
case GL_RGBA4:
case GL_RGB5_A1:
case GL_RGBA8:
-#if 1
case GL_RGB10_A2:
case GL_RGBA12:
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+  rb->Format = MESA_FORMAT_R8G8B8A8_UNORM;
+#else
+  rb->Format = MESA_FORMAT_A8B8G8R8_UNORM;
 #endif
-  if (_mesa_little_endian())
- rb->Format = MESA_FORMAT_R8G8B8A8_UNORM;
-  else
- rb->Format = MESA_FORMAT_A8B8G8R8_UNORM;
   break;
case GL_RGBA16:
case GL_RGBA16_SNORM:
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index d80ab180bac..cd0897d5e5c 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1108,7 +1108,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
 #if CHAN_BITS != 8
   USE(general_triangle);
 #else
-  if (format == MESA_FORMAT_A8B8G8R8_UNORM && 
!_mesa_little_endian()) {
+  if (format == MESA_FORMAT_A8B8G8R8_UNORM && 
!PIPE_ARCH_LITTLE_ENDIAN) {
  /* We only handle RGBA correctly on little endian
   * in the optimized code above.
   */
-- 
2.19.1

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


[Mesa-dev] [PATCH 12/28] u_math: add x86 optimized version of ifloor

2018-11-09 Thread Dylan Baker
This is copied from the one in src/mesa/main/imports.h, which is the
same otherwise.
---
 src/util/u_math.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/src/util/u_math.h b/src/util/u_math.h
index e7dbbe5ca22..fcd3054060b 100644
--- a/src/util/u_math.h
+++ b/src/util/u_math.h
@@ -186,6 +186,23 @@ util_fast_pow(float x, float y)
 static inline int
 util_ifloor(float f)
 {
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+   /*
+* IEEE floor for computers that round to nearest or even.
+* 'f' must be between -4194304 and 4194303.
+* This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
+* but uses some IEEE specific tricks for better speed.
+* Contributed by Josh Vanderhoof
+*/
+   int ai, bi;
+   double af, bf;
+   af = (3 << 22) + 0.5 + (double)f;
+   bf = (3 << 22) + 0.5 - (double)f;
+   /* GCC generates an extra fstp/fld without this. */
+   __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
+   __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
+   return (ai - bi) >> 1;
+#else
int ai, bi;
double af, bf;
union fi u;
@@ -194,6 +211,7 @@ util_ifloor(float f)
u.f = (float) af;  ai = u.i;
u.f = (float) bf;  bi = u.i;
return (ai - bi) >> 1;
+#endif
 }
 
 
-- 
2.19.1

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


[Mesa-dev] [PATCH 25/28] util: Add an aligned realloc function

2018-11-09 Thread Dylan Baker
Mesa has one of these in imports.h, so u_memory needs one as well. This
is the version from mesa ported.
---
 src/util/os_memory.h |  3 +++
 src/util/os_memory_aligned.h | 35 +++
 src/util/os_memory_stdc.h| 18 ++
 src/util/u_memory.h  |  1 +
 4 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/src/util/os_memory.h b/src/util/os_memory.h
index 46a6b6e4572..681369a77b6 100644
--- a/src/util/os_memory.h
+++ b/src/util/os_memory.h
@@ -63,6 +63,9 @@ os_malloc_aligned(size_t size, size_t alignment);
 void
 os_free_aligned(void *ptr);
 
+void *
+os_realloc_aligned(void *ptr, size_t oldsize, size_t newsize, size_t 
alignemnt);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/util/os_memory_aligned.h b/src/util/os_memory_aligned.h
index df398a32bfd..578e347d297 100644
--- a/src/util/os_memory_aligned.h
+++ b/src/util/os_memory_aligned.h
@@ -37,6 +37,7 @@
 
 
 #include "pipe/p_compiler.h"
+#include "util/macros.h"
 
 
 
@@ -52,6 +53,22 @@ add_overflow_size_t(size_t a, size_t b, size_t *res)
 }
 
 
+#if defined(HAVE_POSIX_MEMALIGN)
+
+static inline void *
+os_malloc_aligned(size_t size, size_t alignment)
+{
+   void *ptr;
+   alignment = (alignment + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
+   if(posix_memalign(, alignment, size) != 0)
+  return NULL;
+   return ptr;
+}
+
+#define os_free_aligned(_ptr) free(_ptr)
+
+#else
+
 /**
  * Return memory on given byte alignment
  */
@@ -96,3 +113,21 @@ os_free_aligned(void *ptr)
   os_free(realAddr);
}
 }
+
+#endif
+
+/**
+ * Reallocate memeory, with alignment
+ */
+static inline void *
+os_realloc_aligned(void *ptr, size_t oldsize, size_t newsize, size_t alignment)
+{
+   const size_t copySize = MIN2(oldsize, newsize);
+   void *newBuf = os_malloc_aligned(newsize, alignment);
+   if (newBuf && ptr && copySize > 0) {
+  memcpy(newBuf, ptr, copySize);
+   }
+
+   os_free_aligned(ptr);
+   return newBuf;
+}
diff --git a/src/util/os_memory_stdc.h b/src/util/os_memory_stdc.h
index c9fde06d8ac..95e330d83d2 100644
--- a/src/util/os_memory_stdc.h
+++ b/src/util/os_memory_stdc.h
@@ -47,27 +47,13 @@
 #define os_realloc( _old_ptr, _old_size, _new_size) \
realloc(_old_ptr, _new_size + 0*(_old_size))
 
-
-#if defined(HAVE_POSIX_MEMALIGN)
-
-static inline void *
-os_malloc_aligned(size_t size, size_t alignment)
-{
-   void *ptr;
-   alignment = (alignment + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
-   if(posix_memalign(, alignment, size) != 0)
-  return NULL;
-   return ptr;
-}
-
-#define os_free_aligned(_ptr) free(_ptr)
-
-#elif defined(PIPE_OS_WINDOWS)
+#if defined(PIPE_OS_WINDOWS)
 
 #include 
 
 #define os_malloc_aligned(_size, _align) _aligned_malloc(_size, _align)
 #define os_free_aligned(_ptr) _aligned_free(_ptr)
+#define os_realloc_aligned(_ptr, _oldsize, _newsize, _alignment) 
_aligned_realloc(_ptr, _newsize, _alignment)
 
 #else
 
diff --git a/src/util/u_memory.h b/src/util/u_memory.h
index dc22ab0fd1a..8b27ebb00b7 100644
--- a/src/util/u_memory.h
+++ b/src/util/u_memory.h
@@ -61,6 +61,7 @@ extern "C" {
 
 #define align_malloc(_size, _alignment) os_malloc_aligned(_size, _alignment)
 #define align_free(_ptr) os_free_aligned(_ptr)
+#define align_realloc(_ptr, _oldsize, _newsize, _alignment) 
os_realloc_aligned(_ptr, _oldsize, _newsize, _alignment)
 
 static inline void *
 align_calloc(size_t size, unsigned long alignment)
-- 
2.19.1

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


[Mesa-dev] [PATCH 27/28] mesa: move ADD_POINTERS to macros.h

2018-11-09 Thread Dylan Baker
I'm not really sure where else to put it. Since imports.h only has two
things left in it (neither of which are abstractions for smoothing away
libc differences) I'd like to get them out of there. macros.h is the
only place I can think of to put this macro.
---
 src/mesa/main/imports.h| 9 -
 src/mesa/main/macros.h | 9 +
 src/mesa/main/pbo.c| 2 +-
 src/mesa/tnl/t_rebase.c| 2 +-
 src/mesa/vbo/vbo_private.h | 1 +
 5 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index f51e9d9b7a6..a357cd84992 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -47,15 +47,6 @@
 extern "C" {
 #endif
 
-/*
- * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers
- * as offsets into buffer stores.  Since the vertex array pointer and
- * buffer store pointer are both pointers and we need to add them, we use
- * this macro.
- * Both pointers/offsets are expressed in bytes.
- */
-#define ADD_POINTERS(A, B)  ( (GLubyte *) (A) + (uintptr_t) (B) )
-
 
 /**
  * Sometimes we treat GLfloats as GLints.  On x86 systems, moving a float
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 6547706b6fe..97d48c42df4 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -808,4 +808,13 @@ DIFFERENT_SIGNS(GLfloat x, GLfloat y)
 /* Stringify */
 #define STRINGIFY(x) #x
 
+/*
+ * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers
+ * as offsets into buffer stores.  Since the vertex array pointer and
+ * buffer store pointer are both pointers and we need to add them, we use
+ * this macro.
+ * Both pointers/offsets are expressed in bytes.
+ */
+#define ADD_POINTERS(A, B)  ( (GLubyte *) (A) + (uintptr_t) (B) )
+
 #endif
diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c
index cea55f2a0d2..0f74d326d03 100644
--- a/src/mesa/main/pbo.c
+++ b/src/mesa/main/pbo.c
@@ -36,8 +36,8 @@
 #include "bufferobj.h"
 #include "glformats.h"
 #include "image.h"
-#include "imports.h"
 #include "mtypes.h"
+#include "macros.h"
 #include "pbo.h"
 
 
diff --git a/src/mesa/tnl/t_rebase.c b/src/mesa/tnl/t_rebase.c
index b6950e04fec..242fef2ee1a 100644
--- a/src/mesa/tnl/t_rebase.c
+++ b/src/mesa/tnl/t_rebase.c
@@ -50,7 +50,7 @@
 #include "main/bufferobj.h"
 #include "main/errors.h"
 #include "main/glheader.h"
-#include "main/imports.h"
+#include "main/macros.h"
 #include "main/mtypes.h"
 #include "vbo/vbo.h"
 
diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h
index 86f6b41b793..4cbadbdef16 100644
--- a/src/mesa/vbo/vbo_private.h
+++ b/src/mesa/vbo/vbo_private.h
@@ -36,6 +36,7 @@
 #include "vbo/vbo_exec.h"
 #include "vbo/vbo_save.h"
 #include "main/varray.h"
+#include "main/macros.h"
 
 
 struct _glapi_table;
-- 
2.19.1

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


[Mesa-dev] [PATCH 14/28] replace _mesa_vsnprtinf with util_vsnprtinf

2018-11-09 Thread Dylan Baker
---
 src/mesa/main/errors.c  | 13 +++--
 src/mesa/main/imports.c |  8 
 src/mesa/main/imports.h |  3 ---
 3 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index a9687913627..18dff1ce3cc 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -35,6 +35,7 @@
 #include "imports.h"
 #include "context.h"
 #include "debug_output.h"
+#include "util/u_string.h"
 
 
 static FILE *LogFile = NULL;
@@ -140,7 +141,7 @@ _mesa_warning( struct gl_context *ctx, const char 
*fmtString, ... )
char str[MAX_DEBUG_MESSAGE_LENGTH];
va_list args;
va_start( args, fmtString );
-   (void) _mesa_vsnprintf( str, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args );
+   (void) util_vsnprintf( str, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args );
va_end( args );
 
if (ctx)
@@ -170,7 +171,7 @@ _mesa_problem( const struct gl_context *ctx, const char 
*fmtString, ... )
   numCalls++;
 
   va_start( args, fmtString );
-  _mesa_vsnprintf( str, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args );
+  util_vsnprintf( str, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args );
   va_end( args );
   fprintf(stderr, "Mesa " PACKAGE_VERSION " implementation error: %s\n",
   str);
@@ -230,7 +231,7 @@ _mesa_gl_vdebug(struct gl_context *ctx,
 
_mesa_debug_get_id(id);
 
-   len = _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
+   len = util_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
 
_mesa_log_msg(ctx, source, type, *id, severity, len, s);
 }
@@ -295,7 +296,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const 
char *fmtString, ... )
   va_list args;
 
   va_start(args, fmtString);
-  len = _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
+  len = util_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
   va_end(args);
 
   if (len >= MAX_DEBUG_MESSAGE_LENGTH) {
@@ -352,7 +353,7 @@ _mesa_debug( const struct gl_context *ctx, const char 
*fmtString, ... )
char s[MAX_DEBUG_MESSAGE_LENGTH];
va_list args;
va_start(args, fmtString);
-   _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
+   util_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
va_end(args);
output_if_debug("Mesa", s, GL_FALSE);
 #endif /* DEBUG */
@@ -367,7 +368,7 @@ _mesa_log(const char *fmtString, ...)
char s[MAX_DEBUG_MESSAGE_LENGTH];
va_list args;
va_start(args, fmtString);
-   _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
+   util_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
va_end(args);
output_if_debug("", s, GL_FALSE);
 }
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 566aac1d385..edb5f8fde4e 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -212,14 +212,6 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, 
size_t newSize,
 
 /*@}*/
 
-
-/** Needed due to #ifdef's, above. */
-int
-_mesa_vsnprintf(char *str, size_t size, const char *fmt, va_list args)
-{
-   return vsnprintf( str, size, fmt, args);
-}
-
 /** Wrapper around vsnprintf() */
 int
 _mesa_snprintf( char *str, size_t size, const char *fmt, ... )
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 59fffd5aa1d..2535dd23ba8 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -166,9 +166,6 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t 
newSize,
 extern int
 _mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 
4);
 
-extern int
-_mesa_vsnprintf(char *str, size_t size, const char *fmt, va_list arg);
-
 
 #if defined(_WIN32) && !defined(strtok_r)
 #define strtok_r strtok_s
-- 
2.19.1

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


[Mesa-dev] [PATCH 18/28] use util_strcasecmp in places that may be compiled on msvc

2018-11-09 Thread Dylan Baker
This is the same as the one defined in imports.h, but from utils.

XXX: needs to be compiled with msvc
---
 src/compiler/glsl/glsl_parser.yy | 3 ++-
 src/mesa/main/imports.h  | 4 
 src/util/debug.c | 9 +
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
index ddb54f4a4d6..d295ceece92 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -33,6 +33,7 @@
 #include "glsl_parser_extras.h"
 #include "compiler/glsl_types.h"
 #include "main/context.h"
+#include "util/u_string.h"
 
 #ifdef _MSC_VER
 #pragma warning( disable : 4065 ) // switch statement contains 'default' but 
no 'case' labels
@@ -74,7 +75,7 @@ static bool match_layout_qualifier(const char *s1, const char 
*s2,
if (state->es_shader)
   return strcmp(s1, s2);
else
-  return strcasecmp(s1, s2);
+  return util_strcasecmp(s1, s2);
 }
 %}
 
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 165a9ce05e1..7d210fd752e 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -81,10 +81,6 @@ extern "C" {
 typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
 
 
-
-#if defined(_MSC_VER)
-#define strcasecmp(s1, s2) _stricmp(s1, s2)
-#endif
 /*@}*/
 
 
diff --git a/src/util/debug.c b/src/util/debug.c
index 98b1853325d..e6424ff6376 100644
--- a/src/util/debug.c
+++ b/src/util/debug.c
@@ -24,6 +24,7 @@
 #include 
 #include "main/macros.h"
 #include "debug.h"
+#include "util/u_string.h"
 
 uint64_t
 parse_debug_string(const char *debug,
@@ -65,12 +66,12 @@ env_var_as_boolean(const char *var_name, bool default_value)
   return default_value;
 
if (strcmp(str, "1") == 0 ||
-   strcasecmp(str, "true") == 0 ||
-   strcasecmp(str, "yes") == 0) {
+   util_strcasecmp(str, "true") == 0 ||
+   util_strcasecmp(str, "yes") == 0) {
   return true;
} else if (strcmp(str, "0") == 0 ||
-  strcasecmp(str, "false") == 0 ||
-  strcasecmp(str, "no") == 0) {
+  util_strcasecmp(str, "false") == 0 ||
+  util_strcasecmp(str, "no") == 0) {
   return false;
} else {
   return default_value;
-- 
2.19.1

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


[Mesa-dev] [PATCH 04/28] r200: use preprocessor for big vs little endian checks

2018-11-09 Thread Dylan Baker
Instead of using a function at runtime we can just build the right code
for the right platform.
---
 src/mesa/drivers/dri/r200/r200_blit.c | 76 ++-
 src/mesa/drivers/dri/r200/r200_texstate.c |  7 ++-
 2 files changed, 38 insertions(+), 45 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_blit.c 
b/src/mesa/drivers/dri/r200/r200_blit.c
index d68a53e67f7..90a88bddff8 100644
--- a/src/mesa/drivers/dri/r200/r200_blit.c
+++ b/src/mesa/drivers/dri/r200/r200_blit.c
@@ -42,41 +42,29 @@ static inline uint32_t cmdpacket0(struct radeon_screen 
*rscrn,
 unsigned r200_check_blit(mesa_format mesa_format, uint32_t dst_pitch)
 {
 /* XXX others? */
-if (_mesa_little_endian()) {
-   switch (mesa_format) {
-   case MESA_FORMAT_B8G8R8A8_UNORM:
-   case MESA_FORMAT_B8G8R8X8_UNORM:
-   case MESA_FORMAT_B5G6R5_UNORM:
-   case MESA_FORMAT_B4G4R4A4_UNORM:
-   case MESA_FORMAT_B5G5R5A1_UNORM:
-   case MESA_FORMAT_A_UNORM8:
-   case MESA_FORMAT_L_UNORM8:
-   case MESA_FORMAT_I_UNORM8:
-   /* swizzled - probably can't happen with the disabled 
ChooseTexFormat code */
-   case MESA_FORMAT_A8B8G8R8_UNORM:
-   case MESA_FORMAT_R8G8B8A8_UNORM:
-   break;
-   default:
-   return 0;
-   }
-}
-else {
-   switch (mesa_format) {
-   case MESA_FORMAT_A8R8G8B8_UNORM:
-   case MESA_FORMAT_X8R8G8B8_UNORM:
-   case MESA_FORMAT_R5G6B5_UNORM:
-   case MESA_FORMAT_A4R4G4B4_UNORM:
-   case MESA_FORMAT_A1R5G5B5_UNORM:
-   case MESA_FORMAT_A_UNORM8:
-   case MESA_FORMAT_L_UNORM8:
-   case MESA_FORMAT_I_UNORM8:
-   /* swizzled  - probably can't happen with the disabled 
ChooseTexFormat code */
-   case MESA_FORMAT_R8G8B8A8_UNORM:
-   case MESA_FORMAT_A8B8G8R8_UNORM:
-  break;
-   default:
-  return 0;
-   }
+switch (mesa_format) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+case MESA_FORMAT_B8G8R8A8_UNORM:
+case MESA_FORMAT_B8G8R8X8_UNORM:
+case MESA_FORMAT_B5G6R5_UNORM:
+case MESA_FORMAT_B4G4R4A4_UNORM:
+case MESA_FORMAT_B5G5R5A1_UNORM:
+#else
+case MESA_FORMAT_A8R8G8B8_UNORM:
+case MESA_FORMAT_X8R8G8B8_UNORM:
+case MESA_FORMAT_R5G6B5_UNORM:
+case MESA_FORMAT_A4R4G4B4_UNORM:
+case MESA_FORMAT_A1R5G5B5_UNORM:
+#endif
+case MESA_FORMAT_A_UNORM8:
+case MESA_FORMAT_L_UNORM8:
+case MESA_FORMAT_I_UNORM8:
+/* swizzled - probably can't happen with the disabled ChooseTexFormat 
code */
+case MESA_FORMAT_A8B8G8R8_UNORM:
+case MESA_FORMAT_R8G8B8A8_UNORM:
+break;
+default:
+return 0;
 }
 
 /* Rendering to small buffer doesn't work.
@@ -133,12 +121,11 @@ static void inline emit_tx_setup(struct r200_context 
*r200,
 assert(height <= 2048);
 assert(offset % 32 == 0);
 
-if (_mesa_little_endian()) {
-   txformat |= tx_table_le[src_mesa_format].format;
-}
-else {
-   txformat |= tx_table_be[src_mesa_format].format;
-}
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+txformat |= tx_table_le[src_mesa_format].format;
+#else
+txformat |= tx_table_be[src_mesa_format].format;
+#endif
 
 if (bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
offset |= R200_TXO_MACRO_TILE;
@@ -183,8 +170,11 @@ static void inline emit_tx_setup(struct r200_context *r200,
break;
 case MESA_FORMAT_A8B8G8R8_UNORM:
 case MESA_FORMAT_R8G8B8A8_UNORM:
-   if ((dst_mesa_format == MESA_FORMAT_A8B8G8R8_UNORM && 
_mesa_little_endian()) ||
-  (dst_mesa_format == MESA_FORMAT_R8G8B8A8_UNORM && 
!_mesa_little_endian())) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+   if (dst_mesa_format == MESA_FORMAT_A8B8G8R8_UNORM) {
+#else
+   if (dst_mesa_format == MESA_FORMAT_R8G8B8A8_UNORM) {
+#endif
BEGIN_BATCH(10);
OUT_BATCH_REGVAL(RADEON_PP_CNTL, (RADEON_TEX_0_ENABLE |
  RADEON_TEX_BLEND_0_ENABLE));
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c 
b/src/mesa/drivers/dri/r200/r200_texstate.c
index 60a20071d97..4718d3f4d25 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -1314,8 +1314,11 @@ static void setup_hardware_state(r200ContextPtr rmesa, 
radeonTexObj *t)
 
if (!t->image_override) {
   if (VALID_FORMAT(firstImage->TexFormat)) {
-const struct tx_table *table = _mesa_little_endian() ? tx_table_le :
-   tx_table_be;
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+const struct tx_table *table = tx_table_le;
+#else
+const struct tx_table *table = tx_table_be;
+#endif
 
 t->pp_txformat &= ~(R200_TXFORMAT_FORMAT_MASK |
 R200_TXFORMAT_ALPHA_IN_MAP);
-- 
2.19.1

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


[Mesa-dev] [PATCH 07/28] util/u_endian: set PIPE_ARCH_*_ENDIAN to 1

2018-11-09 Thread Dylan Baker
This will allow it to be used as a drop in replacement for
_mesa_little_endian in a number of cases.
---
 src/util/u_endian.h | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/util/u_endian.h b/src/util/u_endian.h
index e11b381588d..2f424a96600 100644
--- a/src/util/u_endian.h
+++ b/src/util/u_endian.h
@@ -31,27 +31,27 @@
 #include 
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
-# define PIPE_ARCH_LITTLE_ENDIAN
+# define PIPE_ARCH_LITTLE_ENDIAN 1
 #elif __BYTE_ORDER == __BIG_ENDIAN
-# define PIPE_ARCH_BIG_ENDIAN
+# define PIPE_ARCH_BIG_ENDIAN 1
 #endif
 
 #elif defined(__APPLE__)
 #include 
 
 #if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
-# define PIPE_ARCH_LITTLE_ENDIAN
+# define PIPE_ARCH_LITTLE_ENDIAN 1
 #elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
-# define PIPE_ARCH_BIG_ENDIAN
+# define PIPE_ARCH_BIG_ENDIAN 1
 #endif
 
 #elif defined(__sun)
 #include 
 
 #if defined(_LITTLE_ENDIAN)
-# define PIPE_ARCH_LITTLE_ENDIAN
+# define PIPE_ARCH_LITTLE_ENDIAN 1
 #elif defined(_BIG_ENDIAN)
-# define PIPE_ARCH_BIG_ENDIAN
+# define PIPE_ARCH_BIG_ENDIAN 1
 #endif
 
 #elif defined(__OpenBSD__) || defined(__NetBSD__) || \
@@ -60,14 +60,14 @@
 #include 
 
 #if _BYTE_ORDER == _LITTLE_ENDIAN
-# define PIPE_ARCH_LITTLE_ENDIAN
+# define PIPE_ARCH_LITTLE_ENDIAN 1
 #elif _BYTE_ORDER == _BIG_ENDIAN
-# define PIPE_ARCH_BIG_ENDIAN
+# define PIPE_ARCH_BIG_ENDIAN 1
 #endif
 
 #elif defined(_MSC_VER)
 
-#define PIPE_ARCH_LITTLE_ENDIAN
+#define PIPE_ARCH_LITTLE_ENDIAN 1
 
 #endif
 
-- 
2.19.1

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


[Mesa-dev] [PATCH 23/28] amd/vulkan: Remove FREE alias for free

2018-11-09 Thread Dylan Baker
Even within this directory free and FREE are used interchangeably, and
u_memory has a FREE macro already
---
 src/amd/vulkan/radv_radeon_winsys.h   | 2 --
 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c | 8 
 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c | 6 +++---
 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c | 2 +-
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/amd/vulkan/radv_radeon_winsys.h 
b/src/amd/vulkan/radv_radeon_winsys.h
index 7977d46229e..ba3943bf797 100644
--- a/src/amd/vulkan/radv_radeon_winsys.h
+++ b/src/amd/vulkan/radv_radeon_winsys.h
@@ -40,8 +40,6 @@ struct radeon_info;
 struct ac_surf_info;
 struct radeon_surf;
 
-#define FREE(x) free(x)
-
 enum radeon_bo_domain { /* bitfield */
RADEON_DOMAIN_GTT  = 2,
RADEON_DOMAIN_VRAM = 4,
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c 
b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
index 25764d93f6a..8f901e11d26 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
@@ -270,7 +270,7 @@ static void radv_amdgpu_winsys_bo_destroy(struct 
radeon_winsys_bo *_bo)
amdgpu_bo_free(bo->bo);
}
amdgpu_va_range_free(bo->va_handle);
-   FREE(bo);
+   free(bo);
 }
 
 static void radv_amdgpu_add_buffer_to_global_list(struct radv_amdgpu_winsys_bo 
*bo)
@@ -383,7 +383,7 @@ error_bo_alloc:
amdgpu_va_range_free(va_handle);
 
 error_va_alloc:
-   FREE(bo);
+   free(bo);
return NULL;
 }
 
@@ -451,7 +451,7 @@ error_va_alloc:
amdgpu_bo_free(buf_handle);
 
 error:
-   FREE(bo);
+   free(bo);
return NULL;
 }
 
@@ -514,7 +514,7 @@ error_query:
amdgpu_bo_free(result.buf_handle);
 
 error:
-   FREE(bo);
+   free(bo);
return NULL;
 }
 
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c 
b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
index abc4f3903d3..cd8b13813d2 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
@@ -1238,7 +1238,7 @@ static struct radeon_winsys_ctx 
*radv_amdgpu_ctx_create(struct radeon_winsys *_w
memset(ctx->fence_map, 0, 4096);
return (struct radeon_winsys_ctx *)ctx;
 error_create:
-   FREE(ctx);
+   free(ctx);
return NULL;
 }
 
@@ -1247,7 +1247,7 @@ static void radv_amdgpu_ctx_destroy(struct 
radeon_winsys_ctx *rwctx)
struct radv_amdgpu_ctx *ctx = (struct radv_amdgpu_ctx *)rwctx;
ctx->ws->base.buffer_destroy(ctx->fence_bo);
amdgpu_cs_ctx_free(ctx->ctx);
-   FREE(ctx);
+   free(ctx);
 }
 
 static bool radv_amdgpu_ctx_wait_idle(struct radeon_winsys_ctx *rwctx,
@@ -1280,7 +1280,7 @@ static struct radeon_winsys_sem 
*radv_amdgpu_create_sem(struct radeon_winsys *_w
 static void radv_amdgpu_destroy_sem(struct radeon_winsys_sem *_sem)
 {
struct amdgpu_cs_fence *sem = (struct amdgpu_cs_fence *)_sem;
-   FREE(sem);
+   free(sem);
 }
 
 static int radv_amdgpu_signal_sems(struct radv_amdgpu_ctx *ctx,
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c 
b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
index 9706c04e8cd..9311d8ecba7 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
@@ -142,7 +142,7 @@ static void radv_amdgpu_winsys_destroy(struct radeon_winsys 
*rws)
 
AddrDestroy(ws->addrlib);
amdgpu_device_deinitialize(ws->dev);
-   FREE(rws);
+   free(rws);
 }
 
 struct radeon_winsys *
-- 
2.19.1

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


[Mesa-dev] [PATCH 02/28] replace _mesa_next_pow_two_* with util_next_power_of_two_*

2018-11-09 Thread Dylan Baker
The 64 bit variant in imports.h isn't even used.
---
 .../drivers/dri/radeon/radeon_mipmap_tree.c   |  2 +-
 src/mesa/main/imports.h   | 52 ---
 2 files changed, 1 insertion(+), 53 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c 
b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index c4b3c61cbf4..7f02143e08a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -129,7 +129,7 @@ static void compute_tex_image_offset(radeonContextPtr 
rmesa, radeon_mipmap_tree
radeon_mipmap_level *lvl = >levels[level];
GLuint height;
 
-   height = _mesa_next_pow_two_32(lvl->height);
+   height = util_next_power_of_two(lvl->height);
 
lvl->rowstride = get_texture_image_row_stride(rmesa, mt->mesaFormat, 
lvl->width, mt->tilebits, mt->target);
lvl->size = get_texture_image_size(mt->mesaFormat, lvl->rowstride, 
height, lvl->depth, mt->tilebits);
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 6193a83396f..3ed2c5edb07 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -205,58 +205,6 @@ static inline int IFLOOR(float f)
 #endif
 }
 
-/**
- * Round given integer to next higer power of two
- * If X is zero result is undefined.
- *
- * Source for the fallback implementation is
- * Sean Eron Anderson's webpage "Bit Twiddling Hacks"
- * http://graphics.stanford.edu/~seander/bithacks.html
- *
- * When using builtin function have to do some work
- * for case when passed values 1 to prevent hiting
- * undefined result from __builtin_clz. Undefined
- * results would be different depending on optimization
- * level used for build.
- */
-static inline int32_t
-_mesa_next_pow_two_32(uint32_t x)
-{
-#ifdef HAVE___BUILTIN_CLZ
-   uint32_t y = (x != 1);
-   return (1 + y) << ((__builtin_clz(x - y) ^ 31) );
-#else
-   x--;
-   x |= x >> 1;
-   x |= x >> 2;
-   x |= x >> 4;
-   x |= x >> 8;
-   x |= x >> 16;
-   x++;
-   return x;
-#endif
-}
-
-static inline int64_t
-_mesa_next_pow_two_64(uint64_t x)
-{
-#ifdef HAVE___BUILTIN_CLZLL
-   uint64_t y = (x != 1);
-   STATIC_ASSERT(sizeof(x) == sizeof(long long));
-   return (1 + y) << ((__builtin_clzll(x - y) ^ 63));
-#else
-   x--;
-   x |= x >> 1;
-   x |= x >> 2;
-   x |= x >> 4;
-   x |= x >> 8;
-   x |= x >> 16;
-   x |= x >> 32;
-   x++;
-   return x;
-#endif
-}
-
 
 /*
  * Returns the floor form of binary logarithm for a 32-bit integer.
-- 
2.19.1

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


[Mesa-dev] [PATCH 03/28] replace _mesa_logbase2 with util_logbase2

2018-11-09 Thread Dylan Baker
---
 src/intel/compiler/brw_eu_emit.c |  4 ++--
 src/intel/compiler/brw_fs.cpp|  2 +-
 src/intel/compiler/brw_fs_generator.cpp  |  2 +-
 src/intel/compiler/brw_fs_reg_allocate.cpp   |  4 ++--
 src/intel/compiler/brw_ir_fs.h   |  4 ++--
 src/mesa/drivers/dri/i965/brw_clip.c |  2 +-
 src/mesa/drivers/dri/i965/brw_vs.c   |  2 +-
 src/mesa/drivers/dri/radeon/radeon_texture.c |  2 +-
 src/mesa/main/imports.h  | 20 
 src/mesa/main/teximage.c | 12 ++--
 src/mesa/state_tracker/st_cb_texture.c   |  2 +-
 11 files changed, 18 insertions(+), 38 deletions(-)

diff --git a/src/intel/compiler/brw_eu_emit.c b/src/intel/compiler/brw_eu_emit.c
index 4630b83b1a0..fe497f6dfc3 100644
--- a/src/intel/compiler/brw_eu_emit.c
+++ b/src/intel/compiler/brw_eu_emit.c
@@ -505,7 +505,7 @@ gen7_set_dp_scratch_message(struct brw_codegen *p,
const struct gen_device_info *devinfo = p->devinfo;
assert(num_regs == 1 || num_regs == 2 || num_regs == 4 ||
   (devinfo->gen >= 8 && num_regs == 8));
-   const unsigned block_size = (devinfo->gen >= 8 ? _mesa_logbase2(num_regs) :
+   const unsigned block_size = (devinfo->gen >= 8 ? util_logbase2(num_regs) :
 num_regs - 1);
 
brw_set_desc(p, inst, brw_message_desc(
@@ -3455,7 +3455,7 @@ brw_broadcast(struct brw_codegen *p,
  /* Take into account the component size and horizontal stride. */
  assert(src.vstride == src.hstride + src.width);
  brw_SHL(p, addr, vec1(idx),
- brw_imm_ud(_mesa_logbase2(type_sz(src.type)) +
+ brw_imm_ud(util_logbase2(type_sz(src.type)) +
 src.hstride - 1));
 
  /* We can only address up to limit bytes using the indirect
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 3e083723471..1ae97578190 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -5241,7 +5241,7 @@ get_fpu_lowered_simd_width(const struct gen_device_info 
*devinfo,
/* Only power-of-two execution sizes are representable in the instruction
 * control fields.
 */
-   return 1 << _mesa_logbase2(max_width);
+   return 1 << util_logbase2(max_width);
 }
 
 /**
diff --git a/src/intel/compiler/brw_fs_generator.cpp 
b/src/intel/compiler/brw_fs_generator.cpp
index 08dd83dded7..a3d22642887 100644
--- a/src/intel/compiler/brw_fs_generator.cpp
+++ b/src/intel/compiler/brw_fs_generator.cpp
@@ -542,7 +542,7 @@ fs_generator::generate_shuffle(fs_inst *inst,
  /* Take into account the component size and horizontal stride. */
  assert(src.vstride == src.hstride + src.width);
  brw_SHL(p, addr, group_idx,
- brw_imm_uw(_mesa_logbase2(type_sz(src.type)) +
+ brw_imm_uw(util_logbase2(type_sz(src.type)) +
 src.hstride - 1));
 
  /* Add on the register start offset */
diff --git a/src/intel/compiler/brw_fs_reg_allocate.cpp 
b/src/intel/compiler/brw_fs_reg_allocate.cpp
index 73b8b7841f5..bbb629752e2 100644
--- a/src/intel/compiler/brw_fs_reg_allocate.cpp
+++ b/src/intel/compiler/brw_fs_reg_allocate.cpp
@@ -77,7 +77,7 @@ brw_alloc_reg_set(struct brw_compiler *compiler, int 
dispatch_width)
 {
const struct gen_device_info *devinfo = compiler->devinfo;
int base_reg_count = BRW_MAX_GRF;
-   const int index = _mesa_logbase2(dispatch_width / 8);
+   const int index = util_logbase2(dispatch_width / 8);
 
if (dispatch_width > 8 && devinfo->gen >= 7) {
   /* For IVB+, we don't need the PLN hacks or the even-reg alignment in
@@ -539,7 +539,7 @@ fs_visitor::assign_regs(bool allow_spilling, bool spill_all)
int reg_width = dispatch_width / 8;
unsigned hw_reg_mapping[this->alloc.count];
int payload_node_count = ALIGN(this->first_non_payload_grf, reg_width);
-   int rsi = _mesa_logbase2(reg_width); /* Which compiler->fs_reg_sets[] to 
use */
+   int rsi = util_logbase2(reg_width); /* Which compiler->fs_reg_sets[] to use 
*/
calculate_live_intervals();
 
int node_count = this->alloc.count;
diff --git a/src/intel/compiler/brw_ir_fs.h b/src/intel/compiler/brw_ir_fs.h
index 07e7224e0f8..599aea74153 100644
--- a/src/intel/compiler/brw_ir_fs.h
+++ b/src/intel/compiler/brw_ir_fs.h
@@ -298,8 +298,8 @@ subscript(fs_reg reg, brw_reg_type type, unsigned i)
   /* The stride is encoded inconsistently for fixed GRF and ARF registers
* as the log2 of the actual vertical and horizontal strides.
*/
-  const int delta = _mesa_logbase2(type_sz(reg.type)) -
-_mesa_logbase2(type_sz(type));
+  const int delta = util_logbase2(type_sz(reg.type)) -
+util_logbase2(type_sz(type));
   reg.hstride += (reg.hstride ? delta : 0);
   reg.vstride += (reg.vstride ? delta : 0);
 
diff --git a/src/mesa/drivers/dri/i965/brw_clip.c 

[Mesa-dev] [PATCH 05/28] r100: Use preprocessor to select big vs little endian paths

2018-11-09 Thread Dylan Baker
---
 src/mesa/drivers/dri/radeon/radeon_blit.c| 49 
 src/mesa/drivers/dri/radeon/radeon_screen.c  | 21 +++--
 src/mesa/drivers/dri/radeon/radeon_texture.c | 31 ++---
 3 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c 
b/src/mesa/drivers/dri/radeon/radeon_blit.c
index 0b0f06f0edb..de2baee76c1 100644
--- a/src/mesa/drivers/dri/radeon/radeon_blit.c
+++ b/src/mesa/drivers/dri/radeon/radeon_blit.c
@@ -42,35 +42,26 @@ static inline uint32_t cmdpacket0(struct radeon_screen 
*rscrn,
 unsigned r100_check_blit(mesa_format mesa_format, uint32_t dst_pitch)
 {
 /* XXX others?  */
-if (_mesa_little_endian()) {
-   switch (mesa_format) {
-   case MESA_FORMAT_B8G8R8A8_UNORM:
-   case MESA_FORMAT_B8G8R8X8_UNORM:
-   case MESA_FORMAT_B5G6R5_UNORM:
-   case MESA_FORMAT_B4G4R4A4_UNORM:
-   case MESA_FORMAT_B5G5R5A1_UNORM:
-   case MESA_FORMAT_A_UNORM8:
-   case MESA_FORMAT_L_UNORM8:
-   case MESA_FORMAT_I_UNORM8:
-   break;
-   default:
-   return 0;
-   }
-}
-else {
-   switch (mesa_format) {
-   case MESA_FORMAT_A8R8G8B8_UNORM:
-   case MESA_FORMAT_X8R8G8B8_UNORM:
-   case MESA_FORMAT_R5G6B5_UNORM:
-   case MESA_FORMAT_A4R4G4B4_UNORM:
-   case MESA_FORMAT_A1R5G5B5_UNORM:
-   case MESA_FORMAT_A_UNORM8:
-   case MESA_FORMAT_L_UNORM8:
-   case MESA_FORMAT_I_UNORM8:
-   break;
-   default:
-   return 0;
-   }
+switch (mesa_format) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+case MESA_FORMAT_B8G8R8A8_UNORM:
+case MESA_FORMAT_B8G8R8X8_UNORM:
+case MESA_FORMAT_B5G6R5_UNORM:
+case MESA_FORMAT_B4G4R4A4_UNORM:
+case MESA_FORMAT_B5G5R5A1_UNORM:
+#else
+case MESA_FORMAT_A8R8G8B8_UNORM:
+case MESA_FORMAT_X8R8G8B8_UNORM:
+case MESA_FORMAT_R5G6B5_UNORM:
+case MESA_FORMAT_A4R4G4B4_UNORM:
+case MESA_FORMAT_A1R5G5B5_UNORM:
+#endif
+case MESA_FORMAT_A_UNORM8:
+case MESA_FORMAT_L_UNORM8:
+case MESA_FORMAT_I_UNORM8:
+break;
+default:
+return 0;
 }
 
 /* Rendering to small buffer doesn't work.
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 6345f2ce661..9e7887de769 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -696,11 +696,26 @@ radeonCreateBuffer( __DRIscreen *driScrnPriv,
 _mesa_initialize_window_framebuffer(>base, mesaVis);
 
 if (mesaVis->redBits == 5)
-rgbFormat = _mesa_little_endian() ? MESA_FORMAT_B5G6R5_UNORM : 
MESA_FORMAT_R5G6B5_UNORM;
+rgbFormat =
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+   MESA_FORMAT_B5G6R5_UNORM;
+#else
+   MESA_FORMAT_R5G6B5_UNORM;
+#endif
 else if (mesaVis->alphaBits == 0)
-rgbFormat = _mesa_little_endian() ? MESA_FORMAT_B8G8R8X8_UNORM : 
MESA_FORMAT_X8R8G8B8_UNORM;
+rgbFormat =
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+   MESA_FORMAT_B8G8R8X8_UNORM;
+#else
+   MESA_FORMAT_X8R8G8B8_UNORM;
+#endif
 else
-rgbFormat = _mesa_little_endian() ? MESA_FORMAT_B8G8R8A8_UNORM : 
MESA_FORMAT_A8R8G8B8_UNORM;
+rgbFormat = 
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+   MESA_FORMAT_B8G8R8A8_UNORM;
+#else
+   MESA_FORMAT_A8R8G8B8_UNORM;
+#endif
 
 /* front color renderbuffer */
 rfb->color_rb[0] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c 
b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 6639c7ed65e..f7f2adedd89 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -603,22 +603,21 @@ mesa_format _radeon_texformat_al88 = MESA_FORMAT_NONE;
 static void
 radeonInitTextureFormats(void)
 {
-   if (_mesa_little_endian()) {
-  _radeon_texformat_rgba   = MESA_FORMAT_A8B8G8R8_UNORM;
-  _radeon_texformat_argb   = MESA_FORMAT_B8G8R8A8_UNORM;
-  _radeon_texformat_rgb565 = MESA_FORMAT_B5G6R5_UNORM;
-  _radeon_texformat_argb   = MESA_FORMAT_B4G4R4A4_UNORM;
-  _radeon_texformat_argb1555   = MESA_FORMAT_B5G5R5A1_UNORM;
-  _radeon_texformat_al88   = MESA_FORMAT_L8A8_UNORM;
-   }
-   else {
-  _radeon_texformat_rgba   = MESA_FORMAT_R8G8B8A8_UNORM;
-  _radeon_texformat_argb   = MESA_FORMAT_A8R8G8B8_UNORM;
-  _radeon_texformat_rgb565 = MESA_FORMAT_R5G6B5_UNORM;
-  _radeon_texformat_argb   = MESA_FORMAT_A4R4G4B4_UNORM;
-  _radeon_texformat_argb1555   = MESA_FORMAT_A1R5G5B5_UNORM;
-  _radeon_texformat_al88   = MESA_FORMAT_A8L8_UNORM;
-   }
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+   _radeon_texformat_rgba  = MESA_FORMAT_A8B8G8R8_UNORM;
+   _radeon_texformat_argb  = MESA_FORMAT_B8G8R8A8_UNORM;
+   _radeon_texformat_rgb565= MESA_FORMAT_B5G6R5_UNORM;
+   

[Mesa-dev] [PATCH 08/28] mesa/main: replace uses of _mesa_little_endian with preprocessor

2018-11-09 Thread Dylan Baker
---
 src/mesa/main/format_utils.c | 24 ---
 src/mesa/main/formats.c  | 68 
 src/mesa/main/texcompress_bptc.c |  7 +++-
 src/mesa/main/texcompress_fxt1.c |  7 +++-
 src/mesa/main/texcompress_rgtc.c | 14 +--
 src/mesa/main/texcompress_s3tc.c | 21 +++---
 src/mesa/main/texstore.c |  4 +-
 7 files changed, 88 insertions(+), 57 deletions(-)

diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
index 6959bf062a1..7802dbe3ff7 100644
--- a/src/mesa/main/format_utils.c
+++ b/src/mesa/main/format_utils.c
@@ -647,9 +647,9 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, 
size_t dst_stride,
}
 }
 
-static const uint8_t map_identity[7] = { 0, 1, 2, 3, 4, 5, 6 };
-static const uint8_t map_3210[7] = { 3, 2, 1, 0, 4, 5, 6 };
-static const uint8_t map_1032[7] = { 1, 0, 3, 2, 4, 5, 6 };
+MAYBE_UNUSED static const uint8_t map_identity[7] = { 0, 1, 2, 3, 4, 5, 6 };
+MAYBE_UNUSED static const uint8_t map_3210[7] = { 3, 2, 1, 0, 4, 5, 6 };
+MAYBE_UNUSED static const uint8_t map_1032[7] = { 1, 0, 3, 2, 4, 5, 6 };
 
 /**
  * Describes a format as an array format, if possible
@@ -700,10 +700,18 @@ _mesa_format_to_array(mesa_format format, GLenum *type, 
int *num_components,
 endian = map_identity;
 break;
  case 2:
-endian = _mesa_little_endian() ? map_identity : map_1032;
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+endian = map_identity;
+#else
+endian = map_1032;
+#endif
 break;
  case 4:
-endian = _mesa_little_endian() ? map_identity : map_3210;
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+endian = map_identity;
+#else
+endian = map_3210;
+#endif
 break;
  default:
 endian = map_identity;
@@ -721,7 +729,11 @@ _mesa_format_to_array(mesa_format format, GLenum *type, 
int *num_components,
 endian = map_identity;
 break;
  case 2:
-endian = _mesa_little_endian() ? map_identity : map_1032;
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+endian = map_identity;
+#else
+endian = map_1032;
+#endif
 break;
  default:
 endian = map_identity;
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index cf2d2bc555a..494844c08be 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -415,10 +415,11 @@ uint32_t
 _mesa_format_to_array_format(mesa_format format)
 {
const struct gl_format_info *info = _mesa_get_format_info(format);
-   if (info->ArrayFormat && !_mesa_little_endian() &&
-   info->Layout == MESA_FORMAT_LAYOUT_PACKED)
+#ifdef PIPE_ARCH_BIG_ENDIAN
+   if (info->ArrayFormat && info->Layout == MESA_FORMAT_LAYOUT_PACKED)
   return _mesa_array_format_flip_channels(info->ArrayFormat);
else
+#endif
   return info->ArrayFormat;
 }
 
@@ -451,11 +452,11 @@ format_array_format_table_init(void)
   if (!info->ArrayFormat)
  continue;
 
-  if (_mesa_little_endian()) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
  array_format = info->ArrayFormat;
-  } else {
+#else
  array_format = _mesa_array_format_flip_channels(info->ArrayFormat);
-  }
+#endif
 
   /* This can happen and does for some of the BGR formats.  Let's take
* the first one in the list.
@@ -1442,7 +1443,6 @@ _mesa_format_matches_format_and_type(mesa_format 
mesa_format,
 GLenum format, GLenum type,
 GLboolean swapBytes, GLenum *error)
 {
-   const GLboolean littleEndian = _mesa_little_endian();
if (error)
   *error = GL_NO_ERROR;
 
@@ -1471,7 +1471,7 @@ _mesa_format_matches_format_and_type(mesa_format 
mesa_format,
   if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV && 
swapBytes)
  return GL_TRUE;
 
-  if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !littleEndian)
+  if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && 
!PIPE_ARCH_LITTLE_ENDIAN)
  return GL_TRUE;
 
   if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8_REV
@@ -1482,7 +1482,7 @@ _mesa_format_matches_format_and_type(mesa_format 
mesa_format,
   && swapBytes)
  return GL_TRUE;
 
-  if (format == GL_ABGR_EXT && type == GL_UNSIGNED_BYTE && littleEndian)
+  if (format == GL_ABGR_EXT && type == GL_UNSIGNED_BYTE && 
PIPE_ARCH_LITTLE_ENDIAN)
  return GL_TRUE;
 
   return GL_FALSE;
@@ -1496,7 +1496,7 @@ _mesa_format_matches_format_and_type(mesa_format 
mesa_format,
   if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8 && swapBytes)
  return GL_TRUE;
 
-  if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && littleEndian)
+  if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && 
PIPE_ARCH_LITTLE_ENDIAN)
  return GL_TRUE;
 
   if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8 &&
@@ -1507,7 +1507,7 @@ 

[Mesa-dev] [PATCH 13/28] replace IFLOOR with util_ifloor

2018-11-09 Thread Dylan Baker
which are exactly the same function with exactly the same implementation
---
 src/mesa/main/drawpix.c   |  5 ++-
 src/mesa/main/imports.h   | 31 -
 src/mesa/program/prog_execute.c   |  2 +-
 src/mesa/state_tracker/st_cb_bitmap.c |  4 +-
 src/mesa/swrast/s_blit.c  | 14 +++---
 src/mesa/swrast/s_texfilter.c | 64 +--
 src/mesa/swrast/s_triangle.c  |  4 +-
 7 files changed, 47 insertions(+), 77 deletions(-)

diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 2f55dde7b80..b62a22d68f2 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -36,6 +36,7 @@
 #include "state.h"
 #include "glformats.h"
 #include "fbobject.h"
+#include "util/u_math.h"
 
 
 /*
@@ -323,8 +324,8 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
   /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
   if (width > 0 && height > 0) {
  const GLfloat epsilon = 0.0001F;
- GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig);
- GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig);
+ GLint x = util_ifloor(ctx->Current.RasterPos[0] + epsilon - xorig);
+ GLint y = util_ifloor(ctx->Current.RasterPos[1] + epsilon - yorig);
 
  if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) {
 /* unpack from PBO */
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 461e801bc31..59fffd5aa1d 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -145,37 +145,6 @@ static inline int IROUND_POS(float f)
return (int) (f + 0.5F);
 }
 
-/** Return (as an integer) floor of float */
-static inline int IFLOOR(float f)
-{
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
-   /*
-* IEEE floor for computers that round to nearest or even.
-* 'f' must be between -4194304 and 4194303.
-* This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
-* but uses some IEEE specific tricks for better speed.
-* Contributed by Josh Vanderhoof
-*/
-   int ai, bi;
-   double af, bf;
-   af = (3 << 22) + 0.5 + (double)f;
-   bf = (3 << 22) + 0.5 - (double)f;
-   /* GCC generates an extra fstp/fld without this. */
-   __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
-   __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
-   return (ai - bi) >> 1;
-#else
-   int ai, bi;
-   double af, bf;
-   fi_type u;
-   af = (3 << 22) + 0.5 + (double)f;
-   bf = (3 << 22) + 0.5 - (double)f;
-   u.f = (float) af;  ai = u.i;
-   u.f = (float) bf;  bi = u.i;
-   return (ai - bi) >> 1;
-#endif
-}
-
 
 /**
  * Functions
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index c50465dfc49..6ada78565cc 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -434,7 +434,7 @@ _mesa_execute_program(struct gl_context * ctx,
  {
 GLfloat t[4];
 fetch_vector4(>SrcReg[0], machine, t);
-machine->AddressReg[0][0] = IFLOOR(t[0]);
+machine->AddressReg[0][0] = util_ifloor(t[0]);
 if (DEBUG_PROG) {
printf("ARL %d\n", machine->AddressReg[0][0]);
 }
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c 
b/src/mesa/state_tracker/st_cb_bitmap.c
index a73d6c7e062..53433b943d7 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -712,8 +712,8 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
   const float xorig = g->xorig, yorig = g->yorig;
   const float s0 = g->x, t0 = g->y;
   const float s1 = s0 + g->w, t1 = t0 + g->h;
-  const float x0 = IFLOOR(ctx->Current.RasterPos[0] - xorig + epsilon);
-  const float y0 = IFLOOR(ctx->Current.RasterPos[1] - yorig + epsilon);
+  const float x0 = util_ifloor(ctx->Current.RasterPos[0] - xorig + 
epsilon);
+  const float y0 = util_ifloor(ctx->Current.RasterPos[1] - yorig + 
epsilon);
   const float x1 = x0 + g->w, y1 = y0 + g->h;
   const float clip_x0 = x0 * clip_x_scale - 1.0f;
   const float clip_y0 = y0 * clip_y_scale - 1.0f;
diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c
index 107e41307ee..8c06013d785 100644
--- a/src/mesa/swrast/s_blit.c
+++ b/src/mesa/swrast/s_blit.c
@@ -409,7 +409,7 @@ resample_linear_row_ub(GLint srcWidth, GLint dstWidth,
 
for (dstCol = 0; dstCol < dstWidth; dstCol++) {
   const GLfloat srcCol = (dstCol + 0.5F) / dstWidth * srcWidth - 0.5F;
-  GLint srcCol0 = MAX2(0, IFLOOR(srcCol));
+  GLint srcCol0 = MAX2(0, util_ifloor(srcCol));
   GLint srcCol1 = srcCol0 + 1;
   GLfloat colWeight = srcCol - srcCol0; /* fractional part of srcCol */
   GLfloat red, green, blue, alpha;
@@ -441,10 +441,10 @@ resample_linear_row_ub(GLint srcWidth, GLint dstWidth,
 srcColor0[srcCol0][ACOMP], 

[Mesa-dev] [PATCH 10/28] mesa/main: delete now unused _mesa_little_endian

2018-11-09 Thread Dylan Baker
---
 src/mesa/main/imports.h | 12 
 1 file changed, 12 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 863ac56f535..7e067dd23e3 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -206,18 +206,6 @@ static inline int IFLOOR(float f)
 }
 
 
-/**
- * Return 1 if this is a little endian machine, 0 if big endian.
- */
-static inline GLboolean
-_mesa_little_endian(void)
-{
-   const GLuint ui = 1; /* intentionally not static */
-   return *((const GLubyte *) );
-}
-
-
-
 /**
  * Functions
  */
-- 
2.19.1

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


[Mesa-dev] [PATCH 16/28] Replace IROUND_POS with _mesa_roundevenf

2018-11-09 Thread Dylan Baker
Which has the same behavior.
---
 src/mesa/drivers/x11/xm_api.c  |  2 +-
 src/mesa/main/imports.h| 10 --
 src/mesa/swrast/s_aaline.c |  3 +--
 src/mesa/swrast/s_aatriangle.c |  3 +--
 4 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index e8405950656..6ff1269d07d 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -151,7 +151,7 @@ gamma_adjust( GLfloat gamma, GLint value, GLint max )
}
else {
   double x = (double) value / (double) max;
-  return IROUND_POS((GLfloat) max * pow(x, 1.0F/gamma));
+  return _mesa_roundevenf((GLfloat) max * pow(x, 1.0F/gamma));
}
 }
 
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 59133643442..fbb7e59ca06 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -136,16 +136,6 @@ static inline GLint64 IROUND64(float f)
 }
 
 
-/**
- * Convert positive float to int by rounding to nearest integer.
- */
-static inline int IROUND_POS(float f)
-{
-   assert(f >= 0.0F);
-   return (int) (f + 0.5F);
-}
-
-
 /**
  * Functions
  */
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index de5b42b9f6b..e86d0b5015c 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -25,7 +25,6 @@
 
 #include "c99_math.h"
 #include "main/glheader.h"
-#include "main/imports.h"
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/teximage.h"
@@ -181,7 +180,7 @@ solve_plane_chan(GLfloat x, GLfloat y, const GLfloat 
plane[4])
   return 0;
else if (z > CHAN_MAX)
   return CHAN_MAX;
-   return (GLchan) IROUND_POS(z);
+   return (GLchan) _mesa_roundevenf(z);
 #endif
 }
 
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index b5109870437..20d0a9d3043 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -31,7 +31,6 @@
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "main/imports.h"
 #include "main/state.h"
 #include "s_aatriangle.h"
 #include "s_context.h"
@@ -124,7 +123,7 @@ solve_plane_chan(GLfloat x, GLfloat y, const GLfloat 
plane[4])
   return 0;
else if (z > CHAN_MAX)
   return CHAN_MAX;
-   return (GLchan) IROUND_POS(z);
+   return (GLchan) _mesa_roundevenf(z);
 #endif
 }
 
-- 
2.19.1

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


[Mesa-dev] [PATCH 00/28] Make use of utils functions more

2018-11-09 Thread Dylan Baker
Mesa has a lot of internal code duplication, sometimes it's exactly the same
code in two different places, sometimes it's code where one copy has a fast path
and the other doesn't.

After I imported u_math into src/utils I realized just how much of this
duplication there was, and started looking at cleaning it up. In the process I
managed to delete about 500 lines of code and completely delete imports.c and
imports.h from mesa. There's more work to be done, but this is already a pretty
big chunk, so I'll send this out for review.

I've put this through our CI, I've also built some other configurations like
class swrast and osmesa, and built the mingw target with scons.

Dylan Baker (28):
  replace _mesa_is_pow_two with util_is_power_of_two_*
  replace _mesa_next_pow_two_* with util_next_power_of_two_*
  replace _mesa_logbase2 with util_logbase2
  r200: use preprocessor for big vs little endian checks
  r100: Use preprocessor to select big vs little endian paths
  dri/osmesa: use preprocessor for selecting endian code paths
  util/u_endian: set PIPE_ARCH_*_ENDIAN to 1
  mesa/main: replace uses of _mesa_little_endian with preprocessor
  mesa/swrast: replace instances of _mesa_little_endian with
preprocessor
  mesa/main: delete now unused _mesa_little_endian
  replace LOG2 with util_fast_log2
  u_math: add x86 optimized version of ifloor
  replace IFLOOR with util_ifloor
  replace _mesa_vsnprtinf with util_vsnprtinf
  replace _mesa_snprintf with util_snprintf
  Replace IROUND_POS with _mesa_roundevenf
  mesa/main: remove unused IROUNDD
  use util_strcasecmp in places that may be compiled on msvc
  replace IROUND with util functions
  move windows strtok_r define to u_string
  Replace IS_INF_OR_NAN with util_is_inf_or_nan
  util: promote u_memory to src/util
  amd/vulkan: Remove FREE alias for free
  replace malloc macros in imports.h with u_memory.h versions
  util: Add an aligned realloc function
  replace imports memory functions with utils memory functions
  mesa: move ADD_POINTERS to macros.h
  remove final imports.h bits

 src/Makefile.am   |   1 -
 src/amd/vulkan/radv_radeon_winsys.h   |   2 -
 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c |   9 +-
 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c |   8 +-
 .../vulkan/winsys/amdgpu/radv_amdgpu_winsys.c |   2 +-
 src/compiler/SConscript.glsl  |   2 -
 src/compiler/glsl/glsl_parser.yy  |   3 +-
 src/compiler/glsl/glsl_to_nir.cpp |   1 -
 src/compiler/glsl/linker.cpp  |   1 -
 src/compiler/nir/nir_opt_copy_propagate.c |   1 -
 src/gallium/auxiliary/Makefile.sources|   5 -
 src/gallium/auxiliary/meson.build |   5 -
 src/gallium/auxiliary/util/u_debug_memory.c   |   4 +-
 src/gallium/auxiliary/util/u_format.c |   2 +-
 src/gallium/auxiliary/util/u_format_tests.c   |   2 +-
 src/gallium/auxiliary/util/u_log.c|   2 +-
 src/gallium/auxiliary/util/u_prim_restart.c   |   2 +-
 src/gallium/state_trackers/dri/dri_context.c  |   2 +
 src/gallium/state_trackers/glx/xlib/glx_api.c |   2 +-
 src/gallium/state_trackers/glx/xlib/xm_api.c  |   2 +-
 src/intel/compiler/brw_eu_emit.c  |   4 +-
 src/intel/compiler/brw_fs.cpp |   2 +-
 src/intel/compiler/brw_fs_generator.cpp   |   2 +-
 src/intel/compiler/brw_fs_reg_allocate.cpp|   4 +-
 src/intel/compiler/brw_ir_fs.h|   4 +-
 src/intel/compiler/brw_reg.h  |   2 +-
 src/intel/compiler/brw_vec4_generator.cpp |   3 +-
 src/mapi/glapi/gen/gl_enums.py|   4 +-
 src/mapi/glapi/gen/gl_genexec.py  |   2 +-
 src/mapi/glapi/gen/gl_table.py|   1 +
 src/mesa/Android.libmesa_glsl_utils.mk|   2 -
 src/mesa/Makefile.sources |   3 +-
 src/mesa/drivers/common/driverfuncs.c |   1 -
 src/mesa/drivers/common/meta.c|   7 +-
 src/mesa/drivers/common/meta_blit.c   |   7 +-
 src/mesa/drivers/dri/i915/i830_context.c  |   1 -
 src/mesa/drivers/dri/i915/i915_context.c  |   1 -
 src/mesa/drivers/dri/i915/i915_debug_fp.c |   4 +-
 src/mesa/drivers/dri/i915/i915_texstate.c |   2 +-
 src/mesa/drivers/dri/i915/i915_vtbl.c |   1 -
 .../drivers/dri/i915/intel_buffer_objects.c   |  20 +-
 src/mesa/drivers/dri/i915/intel_context.c |   1 -
 src/mesa/drivers/dri/i915/intel_fbo.c |   2 +-
 src/mesa/drivers/dri/i915/intel_render.c  |   1 -
 src/mesa/drivers/dri/i915/intel_screen.c  |   1 +
 src/mesa/drivers/dri/i915/intel_syncobj.c |   2 -
 src/mesa/drivers/dri/i915/intel_tex.c |   1 +
 src/mesa/drivers/dri/i965/brw_clip.c  |   2 +-
 .../drivers/dri/i965/brw_conditional_render.c |   1 -
 src/mesa/drivers/dri/i965/brw_context.c   |   1 -
 .../drivers/dri/i965/brw_object_purgeable.c   |   1 -
 .../drivers/dri/i965/brw_primitive_restart.c  |   1 -
 src/mesa/drivers/dri/i965/brw_program.c   

[Mesa-dev] [PATCH 19/28] replace IROUND with util functions

2018-11-09 Thread Dylan Baker
This adds two new util functions to rounding.h, _mesa_iroundf and
mesa_lround, which are just wrappers around roundf and round, that cast
to int and long int respectively. This is possible since mesa recently
dropped support for VC2013, since 2015 and 2017 support roundf.
---
 src/mesa/main/drawpix.c | 18 +++
 src/mesa/main/eval.c| 15 ++---
 src/mesa/main/get.c | 44 ++---
 src/mesa/main/imports.h | 17 --
 src/mesa/main/light.c   |  9 
 src/mesa/main/pixel.c   |  3 ++-
 src/mesa/main/pixelstore.c  |  5 +++--
 src/mesa/main/samplerobj.c  |  8 +++
 src/mesa/main/texparam.c|  8 +++
 src/mesa/swrast/s_blit.c|  2 +-
 src/mesa/swrast/s_context.h |  3 ++-
 src/util/rounding.h | 10 +
 12 files changed, 68 insertions(+), 74 deletions(-)

diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index b62a22d68f2..a5549d811aa 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -23,7 +23,6 @@
  */
 
 #include "glheader.h"
-#include "imports.h"
 #include "draw_validate.h"
 #include "bufferobj.h"
 #include "context.h"
@@ -37,6 +36,7 @@
 #include "glformats.h"
 #include "fbobject.h"
 #include "util/u_math.h"
+#include "util/rounding.h"
 
 
 /*
@@ -58,8 +58,8 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
   _mesa_enum_to_string(type),
   pixels,
   _mesa_enum_to_string(ctx->DrawBuffer->ColorDrawBuffer[0]),
-  IROUND(ctx->Current.RasterPos[0]),
-  IROUND(ctx->Current.RasterPos[1]));
+  _mesa_iroundf(ctx->Current.RasterPos[0]),
+  _mesa_iroundf(ctx->Current.RasterPos[1]));
 
 
if (width < 0 || height < 0) {
@@ -141,8 +141,8 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
if (ctx->RenderMode == GL_RENDER) {
   if (width > 0 && height > 0) {
  /* Round, to satisfy conformance tests (matches SGI's OpenGL) */
- GLint x = IROUND(ctx->Current.RasterPos[0]);
- GLint y = IROUND(ctx->Current.RasterPos[1]);
+ GLint x = _mesa_iroundf(ctx->Current.RasterPos[0]);
+ GLint y = _mesa_iroundf(ctx->Current.RasterPos[1]);
 
  if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) {
 /* unpack from PBO */
@@ -202,8 +202,8 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, 
GLsizei height,
   _mesa_enum_to_string(type),
   _mesa_enum_to_string(ctx->ReadBuffer->ColorReadBuffer),
   _mesa_enum_to_string(ctx->DrawBuffer->ColorDrawBuffer[0]),
-  IROUND(ctx->Current.RasterPos[0]),
-  IROUND(ctx->Current.RasterPos[1]));
+  _mesa_iroundf(ctx->Current.RasterPos[0]),
+  _mesa_iroundf(ctx->Current.RasterPos[1]));
 
if (width < 0 || height < 0) {
   _mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)");
@@ -265,8 +265,8 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, 
GLsizei height,
if (ctx->RenderMode == GL_RENDER) {
   /* Round to satisfy conformance tests (matches SGI's OpenGL) */
   if (width > 0 && height > 0) {
- GLint destx = IROUND(ctx->Current.RasterPos[0]);
- GLint desty = IROUND(ctx->Current.RasterPos[1]);
+ GLint destx = _mesa_iroundf(ctx->Current.RasterPos[0]);
+ GLint desty = _mesa_iroundf(ctx->Current.RasterPos[1]);
  ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty,
  type );
   }
diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
index 86c8f75a1d2..fd24cb541fd 100644
--- a/src/mesa/main/eval.c
+++ b/src/mesa/main/eval.c
@@ -38,7 +38,6 @@
 
 
 #include "glheader.h"
-#include "imports.h"
 #include "context.h"
 #include "eval.h"
 #include "macros.h"
@@ -704,7 +703,7 @@ _mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei 
bufSize, GLint *v )
 if (bufSize < numBytes)
goto overflow;
for (i=0;iu1);
-v[1] = IROUND(map1d->u2);
+v[0] = _mesa_iroundf(map1d->u1);
+v[1] = _mesa_iroundf(map1d->u2);
  }
  else {
 numBytes = 4 * sizeof *v;
 if (bufSize < numBytes)
goto overflow;
-v[0] = IROUND(map2d->u1);
-v[1] = IROUND(map2d->u2);
-v[2] = IROUND(map2d->v1);
-v[3] = IROUND(map2d->v2);
+v[0] = _mesa_iroundf(map2d->u1);
+v[1] = _mesa_iroundf(map2d->u2);
+v[2] = _mesa_iroundf(map2d->v1);
+v[3] = _mesa_iroundf(map2d->v2);
  }
  break;
   default:
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 1b1679e8bf7..3761b2db999 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1853,18 +1853,18 @@ _mesa_GetIntegerv(GLenum pname, GLint *params)
   break;
 
case TYPE_FLOAT_8:
- 

[Mesa-dev] [PATCH 1/2] egl: introduce a log level getter function

2018-11-09 Thread Silvestrs Timofejevs
Being able to retrieve the log level can be useful to enable/disable
debug code. The alternative, which is calling 'getenv' function every
time to retrieve the log level, is more "expensive".

Signed-off-by: Silvestrs Timofejevs 
---
 src/egl/main/egllog.c | 9 +
 src/egl/main/egllog.h | 4 
 2 files changed, 13 insertions(+)

diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
index c223f49..42bae01 100644
--- a/src/egl/main/egllog.c
+++ b/src/egl/main/egllog.c
@@ -133,6 +133,15 @@ _eglInitLogger(void)
}
 }
 
+/**
+ * Return the log level.
+ */
+EGLint
+_eglGetLogLevel(void)
+{
+   return logging.level;
+}
+
 
 /**
  * Log a message with message logger.
diff --git a/src/egl/main/egllog.h b/src/egl/main/egllog.h
index 2a06a34..a1cf977 100644
--- a/src/egl/main/egllog.h
+++ b/src/egl/main/egllog.h
@@ -44,6 +44,10 @@ extern "C" {
 #define _EGL_DEBUG   3   /* useful info for debugging */
 
 
+extern EGLint
+_eglGetLogLevel(void);
+
+
 extern void
 _eglLog(EGLint level, const char *fmtStr, ...);
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 0/2] debug feature to dump "get configs" and "chosen configs"

2018-11-09 Thread Silvestrs Timofejevs
This patch series provides an easy way to see what configs
have been returned by the 'eglGetConfigs' and 'eglChooseConfig'
functions, and give an overview of config attributes.

Silvestrs Timofejevs (2):
  egl: introduce a log level getter function
  egl: add config debug printout

 src/egl/Makefile.sources  |   4 +-
 src/egl/main/eglconfig.c  |  20 ++-
 src/egl/main/eglconfigdebug.c | 277 ++
 src/egl/main/eglconfigdebug.h |  55 +
 src/egl/main/egllog.c |   9 ++
 src/egl/main/egllog.h |   4 +
 src/egl/meson.build   |   2 +
 7 files changed, 366 insertions(+), 5 deletions(-)
 create mode 100644 src/egl/main/eglconfigdebug.c
 create mode 100644 src/egl/main/eglconfigdebug.h

-- 
2.7.4

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


[Mesa-dev] [PATCH 2/2] egl: add config debug printout

2018-11-09 Thread Silvestrs Timofejevs
Feature to print out EGL returned configs for debug purposes.

'eglChooseConfig' and 'eglGetConfigs' debug information printout is
enabled when the log level equals '_EGL_DEBUG'. The configs are
printed, and if any of them are "chosen" they are marked with their
index in the chosen configs array.

Signed-off-by: Silvestrs Timofejevs 
---
 src/egl/Makefile.sources  |   4 +-
 src/egl/main/eglconfig.c  |  20 ++-
 src/egl/main/eglconfigdebug.c | 277 ++
 src/egl/main/eglconfigdebug.h |  55 +
 src/egl/meson.build   |   2 +
 5 files changed, 353 insertions(+), 5 deletions(-)
 create mode 100644 src/egl/main/eglconfigdebug.c
 create mode 100644 src/egl/main/eglconfigdebug.h

diff --git a/src/egl/Makefile.sources b/src/egl/Makefile.sources
index 0cc5f1b..353a848 100644
--- a/src/egl/Makefile.sources
+++ b/src/egl/Makefile.sources
@@ -28,7 +28,9 @@ LIBEGL_C_FILES := \
main/eglsync.c \
main/eglsync.h \
main/eglentrypoint.h \
-   main/egltypedefs.h
+   main/egltypedefs.h \
+   main/eglconfigdebug.h \
+   main/eglconfigdebug.c
 
 dri2_backend_core_FILES := \
drivers/dri2/egl_dri2.c \
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index a346f93..0095dc2 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -40,6 +40,7 @@
 #include "util/macros.h"
 
 #include "eglconfig.h"
+#include "eglconfigdebug.h"
 #include "egldisplay.h"
 #include "eglcurrent.h"
 #include "egllog.h"
@@ -797,14 +798,21 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, 
const EGLint *attrib_list,
  EGLConfig *configs, EGLint config_size, EGLint *num_configs)
 {
_EGLConfig criteria;
+   EGLBoolean result;
 
if (!_eglParseConfigAttribList(, disp, attrib_list))
   return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
 
-   return _eglFilterConfigArray(disp->Configs,
- configs, config_size, num_configs,
- _eglFallbackMatch, _eglFallbackCompare,
- (void *) );
+   result = _eglFilterConfigArray(disp->Configs,
+  configs, config_size, num_configs,
+  _eglFallbackMatch, _eglFallbackCompare,
+  (void *) );
+
+   if (result && (_eglGetLogLevel() == _EGL_DEBUG))
+  eglPrintConfigDebug(drv, disp, configs, *num_configs,
+  EGL_CONFIG_DEBUG_CHOOSE);
+
+   return result;
 }
 
 
@@ -857,5 +865,9 @@ _eglGetConfigs(_EGLDriver *drv, _EGLDisplay *disp, 
EGLConfig *configs,
*num_config = _eglFlattenArray(disp->Configs, (void *) configs,
  sizeof(configs[0]), config_size, _eglFlattenConfig);
 
+   if (_eglGetLogLevel() == _EGL_DEBUG)
+  eglPrintConfigDebug(drv, disp, configs, *num_config,
+  EGL_CONFIG_DEBUG_GET);
+
return EGL_TRUE;
 }
diff --git a/src/egl/main/eglconfigdebug.c b/src/egl/main/eglconfigdebug.c
new file mode 100644
index 000..67d6b22
--- /dev/null
+++ b/src/egl/main/eglconfigdebug.c
@@ -0,0 +1,277 @@
+/*
+ * Copyright 2017 Imagination Technologies.
+ * All Rights Reserved.
+ *
+ * Based on eglinfo, which has copyright:
+ * Copyright (C) 2005  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL 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 
+#include 
+#include 
+#include 
+
+#include "eglarray.h"
+#include "eglconfig.h"
+#include "eglconfigdebug.h"
+#include "egldisplay.h"
+#include "egllog.h"
+#include "egltypedefs.h"
+
+/* Max debug message length */
+#define CONFIG_DEBUG_MSG_MAX 1000
+
+/*
+ * These are X visual types, so if you're running eglinfo under
+ * something not X, they probably don't make sense.
+ */
+static const char *const vnames[] = { "SG", "GS", "SC", "PC", "TC", "DC" };
+
+struct _printAttributes {
+   EGLint id, size, level;
+   EGLint red, green, blue, alpha;
+   EGLint depth, stencil;
+   EGLint renderable, surfaces;
+   EGLint vid, vtype, caveat, bindRgb, 

Re: [Mesa-dev] [PATCH] intel/fs: Prevent emission of IR instructions not aligned to their own execution size.

2018-11-09 Thread Sagar Ghuge

Tested-by: Sagar Ghuge 


On 11/8/18 5:26 PM, Francisco Jerez wrote:
> This can occur during payload setup of SIMD-split send message
> instructions, which can lead to the emission of header setup
> instructions with a non-zero channel group and fixed SIMD width.  Such
> instructions could end up using undefined channel enable signals
> except they don't care since they're always marked force_writemask_all.
> 
> Not known to affect correctness of any workload at this point, but it
> would be trivial to back-port to stable if something comes up.
> 
> Reported-by: Sagar Ghuge 
> ---
>  src/intel/compiler/brw_fs_builder.h | 20 +---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/src/intel/compiler/brw_fs_builder.h 
> b/src/intel/compiler/brw_fs_builder.h
> index 0cafaf50e56..4846820722c 100644
> --- a/src/intel/compiler/brw_fs_builder.h
> +++ b/src/intel/compiler/brw_fs_builder.h
> @@ -114,11 +114,25 @@ namespace brw {
>fs_builder
>group(unsigned n, unsigned i) const
>{
> - assert(force_writemask_all ||
> -(n <= dispatch_width() && i < dispatch_width() / n));
>   fs_builder bld = *this;
> +
> + if (n <= dispatch_width() && i < dispatch_width() / n) {
> +bld._group += i * n;
> + } else {
> +/* The requested channel group isn't a subset of the channel 
> group
> + * of this builder, which means that the resulting instructions
> + * would use (potentially undefined) channel enable signals not
> + * specified by the parent builder.  That's only valid if the
> + * instruction doesn't have per-channel semantics, in which case
> + * we should clear off the default group index in order to 
> prevent
> + * emitting instructions with channel group not aligned to their
> + * own execution size.
> + */
> +assert(force_writemask_all);
> +bld._group = 0;
> + }
> +
>   bld._dispatch_width = n;
> - bld._group += i * n;
>   return bld;
>}
>  
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/3] specs: Bump GLX_MESA_query_renderer to version 9

2018-11-09 Thread Adam Jackson
Note that we have an official GL extension number, pick the appropriate
section of the GLX spec to modify, and add changelog.

Signed-off-by: Adam Jackson 
---
 docs/specs/MESA_query_renderer.spec | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/docs/specs/MESA_query_renderer.spec 
b/docs/specs/MESA_query_renderer.spec
index 0209efa1148..10f68ecc5dd 100644
--- a/docs/specs/MESA_query_renderer.spec
+++ b/docs/specs/MESA_query_renderer.spec
@@ -20,11 +20,11 @@ Status
 
 Version
 
-Version 8, 14-February-2014
+Version 9, 09 November 2018
 
 Number
 
-TBD.
+OpenGL Extension #446
 
 Dependencies
 
@@ -98,7 +98,7 @@ Additions to the OpenGL / WGL Specifications
 
 Additions to the GLX 1.4 Specification
 
-[Add the following to Section X.Y.Z of the GLX Specification]
+[Add to Section 3.3.2 "GLX Versioning" of the GLX Specification]
 
 To obtain information about the available renderers for a particular
 display and screen,
@@ -377,3 +377,9 @@ Revision History
 read GLX_RENDERER_ID_MESA. The VENDOR/DEVICE_ID
 example given in issue #17 should be 0x5143 and
 0x respectively.
+
+Version 9, 2018/11/09 - Remove GLX_RENDERER_ID_MESA, which has never been
+implemented. Remove the unnecessary interactions
+with the GLX GLES profile extensions. Note the
+official GL extension number. Specify the section
+of the GLX spec to modify.
-- 
2.19.1

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


[Mesa-dev] [PATCH 1/3] specs: Remove GLES profile interaction text from GLX_MESA_query_renderer

2018-11-09 Thread Adam Jackson
In one place we say, if GLES isn't supported then the profile version
will be 0.0. Then later we say, if the GLES profile extension isn't
supported then GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA is not
mentioned in the spec. A strict reading of the latter would mean that
GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA is not a recognized token,
and the query should instead return False.

The implementation does not check for the GLES profile extensions, and
the additional complexity doesn't seem worth it. Removing the
interaction text makes the spec match the implementation.

Signed-off-by: Adam Jackson 
---
 docs/specs/MESA_query_renderer.spec | 12 
 1 file changed, 12 deletions(-)

diff --git a/docs/specs/MESA_query_renderer.spec 
b/docs/specs/MESA_query_renderer.spec
index dd45e02ba50..3b4a445cf88 100644
--- a/docs/specs/MESA_query_renderer.spec
+++ b/docs/specs/MESA_query_renderer.spec
@@ -32,9 +32,6 @@ Dependencies
 
 GLX_ARB_create_context and GLX_ARB_create_context_profile are required.
 
-This extension interacts with GLX_EXT_create_context_es2_profile and
-GLX_EXT_create_context_es_profile.
-
 Overview
 
 In many situations, applications want to detect characteristics of a
@@ -220,15 +217,6 @@ Additions to the GLX 1.4 Specification
   * If the value of GLX_RENDERER_ID_MESA specifies a non-existent
 renderer, BadMatch is generated.
 
-Dependencies on GLX_EXT_create_context_es_profile and
-GLX_EXT_create_context_es2_profile
-
-If neither extension is supported, remove all mention of
-GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA from the spec.
-
-If GLX_EXT_create_context_es_profile is not supported, remove all mention 
of
-GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA from the spec.
-
 Issues
 
 1) How should the difference between on-card and GART memory be exposed?
-- 
2.19.1

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


[Mesa-dev] [PATCH 0/3] Update GLX_MESA_query_renderer spec

2018-11-09 Thread Adam Jackson
No functional change, just making the text match the implementation.
Will sync this to the Khronos registry once merged.

- ajax


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


[Mesa-dev] [PATCH 2/3] specs: Remove GLX_RENDERER_ID_MESA from GLX_MESA_query_renderer

2018-11-09 Thread Adam Jackson
This has not even had an attempt at implementation. If you asked for
renderer 0 - which, the spec implies, should always work - then
dri2_convert_glx_attribs would fail, we'd silently fall back to creating
an indirect context, and xserver would also not recognize the attribute
and would throw BadValue at you.

The API would be difficult to use in any case, since there's no way to
enumerate how many renderers the screen has. I'd be tempted to add that
by defining:

glXQueryRendererIntegerMESA(dpy, screen,
/* renderer = */ -1,
0, );

to return the number of renderers, but a new entrypoint might be
cleaner. Still, better to not specify it at all than to lie about it.

Signed-off-by: Adam Jackson 
---
 docs/specs/MESA_query_renderer.spec | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/docs/specs/MESA_query_renderer.spec 
b/docs/specs/MESA_query_renderer.spec
index 3b4a445cf88..0209efa1148 100644
--- a/docs/specs/MESA_query_renderer.spec
+++ b/docs/specs/MESA_query_renderer.spec
@@ -92,11 +92,6 @@ New Tokens
 GLX_RENDERER_VENDOR_ID_MESA
 GLX_RENDERER_DEVICE_ID_MESA
 
-Accepted as an attribute name in <*attrib_list> in
-glXCreateContextAttribsARB:
-
-GLX_RENDERER_ID_MESA 0x818E
-
 Additions to the OpenGL / WGL Specifications
 
 None. This specification is written for GLX.
@@ -203,20 +198,6 @@ Additions to the GLX 1.4 Specification
 format as the string that would be returned by glGetString of GL_RENDERER.
 It may, however, have a different value.
 
-
-[Add to section section 3.3.7 "Rendering Contexts"]
-
-The attribute name GLX_RENDERER_ID_MESA specified the index of the render
-against which the context should be created.  The default value of
-GLX_RENDERER_ID_MESA is 0.
-
-
-[Add to list of errors for glXCreateContextAttribsARB in section section
-3.3.7 "Rendering Contexts"]
-
-  * If the value of GLX_RENDERER_ID_MESA specifies a non-existent
-renderer, BadMatch is generated.
-
 Issues
 
 1) How should the difference between on-card and GART memory be exposed?
-- 
2.19.1

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


Re: [Mesa-dev] [PATCH 2/4] compiler: avoid 'unused variable' and 'may be used uninitialized' warnings

2018-11-09 Thread Eric Engestrom
On Friday, 2018-11-09 16:15:12 +0200, andrey simiklit wrote:
> Hello,
> 
> Thanks for review.
> Please find my comments below:
> 
> On Fri, Nov 9, 2018 at 2:52 PM Eric Engestrom 
> wrote:
> 
> > On Tuesday, 2018-09-11 15:42:05 +0300, asimiklit.w...@gmail.com wrote:
> > > From: Andrii Simiklit 
> > >
> > > 1. nir/nir_lower_vars_to_ssa.c:691:21: warning:
> > >unused variable ‘var’
> > >nir_variable *var = path->path[0]->var;
> > >
> > > 2. nir_types.cpp:558:31: warning:
> > > ‘elem_align’ may be used uninitialized in this function
> > >unsigned elem_size, elem_align;
> > >nir_types.cpp:558:20: warning:
> > >‘elem_size’ may be used uninitialized in this function
> > >unsigned elem_size, elem_align;
> > >
> > > Signed-off-by: Andrii Simiklit 
> > > ---
> > >  src/compiler/nir/nir_lower_vars_to_ssa.c | 2 +-
> > >  src/compiler/nir_types.cpp   | 4 ++--
> > >  2 files changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c
> > b/src/compiler/nir/nir_lower_vars_to_ssa.c
> > > index cd679be..96de261 100644
> > > --- a/src/compiler/nir/nir_lower_vars_to_ssa.c
> > > +++ b/src/compiler/nir/nir_lower_vars_to_ssa.c
> > > @@ -688,7 +688,7 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl)
> > >nir_deref_path *path = >path;
> > >
> > >assert(path->path[0]->deref_type == nir_deref_type_var);
> > > -  nir_variable *var = path->path[0]->var;
> > > +  MAYBE_UNUSED nir_variable *var = path->path[0]->var;
> > >
> > >/* We don't build deref nodes for non-local variables */
> > >assert(var->data.mode == nir_var_local);
> >
> > Sure, or you could simply remove the single-use extra local variable and
> > just fold it into the assert :)
> >
> 
> I agree,will fix :)
> 
> 
> >
> > > diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
> > > index d24f094..d39d87b 100644
> > > --- a/src/compiler/nir_types.cpp
> > > +++ b/src/compiler/nir_types.cpp
> > > @@ -542,7 +542,7 @@ glsl_get_natural_size_align_bytes(const struct
> > glsl_type *type,
> > > }
> > >
> > > case GLSL_TYPE_ARRAY: {
> > > -  unsigned elem_size, elem_align;
> > > +  unsigned elem_size = 0, elem_align = 0;
> >
> > Not really keen on these ones; it looks like your compiler is ignoring the
> > unreachable() in glsl_get_natural_size_align_bytes() and mis-computing the
> > possible code-paths, resulting in it wrongly printing a warning.
> >
> 
> You are right when I added the 'default:' case to the switch the warning is
> disappeared:
> 
> case GLSL_TYPE_INTERFACE:
> case GLSL_TYPE_FUNCTION:
> +default:
>unreachable("type does not have a natural size");
> 
> What do you think about such solution? Is it acceptable for you?

Is there any possible value of `enum glsl_base_type` that is not handled
by the switch? If so, they should be added. Otherwise, this is
a compiler bug, not a code bug :)

> 
> 
> > I'd prefer to keep these two hunks as is, so that real issue in
> > glsl_get_natural_size_align_bytes() would get flagged appropriately.
> >
> > >glsl_get_natural_size_align_bytes(type->fields.array,
> > >  _size, _align);
> > >*align = elem_align;
> > > @@ -554,7 +554,7 @@ glsl_get_natural_size_align_bytes(const struct
> > glsl_type *type,
> > >*size = 0;
> > >*align = 0;
> > >for (unsigned i = 0; i < type->length; i++) {
> > > - unsigned elem_size, elem_align;
> > > + unsigned elem_size = 0, elem_align = 0;
> > >
> >  glsl_get_natural_size_align_bytes(type->fields.structure[i].type,
> > > _size, _align);
> > >   *align = MAX2(*align, elem_align);
> > > --
> > > 2.7.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] [PATCH 3/5] intel/aubinator: fix ring buffer pointer

2018-11-09 Thread Toni Lönnberg
Reviewed-by: Toni Lönnberg 

On Fri, Nov 09, 2018 at 04:49:11PM +, Lionel Landwerlin wrote:
> We can only start parsing commands from the head pointer. This was
> working fine up to now because we only dealt with a "made up" ring
> buffer (generated by aub_write) which always had its head at 0.
> 
> Signed-off-by: Lionel Landwerlin 
> ---
>  src/intel/tools/aubinator.c  | 4 ++--
>  src/intel/tools/aubinator_viewer.cpp | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
> index 04d920d98e5..5fed5f11389 100644
> --- a/src/intel/tools/aubinator.c
> +++ b/src/intel/tools/aubinator.c
> @@ -151,7 +151,7 @@ handle_execlist_write(void *user_data, enum gen_engine 
> engine, uint64_t context_
> struct gen_batch_decode_bo ring_bo = aub_mem_get_ggtt_bo(,
>  
> ring_buffer_start);
> assert(ring_bo.size > 0);
> -   void *commands = (uint8_t *)ring_bo.map + (ring_buffer_start - 
> ring_bo.addr);
> +   void *commands = (uint8_t *)ring_bo.map + (ring_buffer_start - 
> ring_bo.addr) + ring_buffer_head;
>  
> if (context_descriptor & 0x100 /* ppgtt */) {
>batch_ctx.get_bo = aub_mem_get_ppgtt_bo;
> @@ -162,7 +162,7 @@ handle_execlist_write(void *user_data, enum gen_engine 
> engine, uint64_t context_
> (void)engine; /* TODO */
> gen_print_batch(_ctx, commands,
> MIN2(ring_buffer_tail - ring_buffer_head, 
> ring_buffer_length),
> -   0);
> +   ring_bo.addr + ring_buffer_head);
> aub_mem_clear_bo_maps();
>  }
>  
> diff --git a/src/intel/tools/aubinator_viewer.cpp 
> b/src/intel/tools/aubinator_viewer.cpp
> index dac03472153..5242edf86fc 100644
> --- a/src/intel/tools/aubinator_viewer.cpp
> +++ b/src/intel/tools/aubinator_viewer.cpp
> @@ -729,13 +729,13 @@ display_batch_execlist_write(void *user_data, enum 
> gen_engine engine,
> struct gen_batch_decode_bo ring_bo =
>aub_mem_get_ggtt_bo(>mem, ring_buffer_start);
> assert(ring_bo.size > 0);
> -   void *commands = (uint8_t *)ring_bo.map + (ring_buffer_start - 
> ring_bo.addr);
> +   void *commands = (uint8_t *)ring_bo.map + (ring_buffer_start - 
> ring_bo.addr) + ring_buffer_head;
>  
> window->uses_ppgtt = true;
>  
> aub_viewer_render_batch(>decode_ctx, commands,
> MIN2(ring_buffer_tail - ring_buffer_head, 
> ring_buffer_length),
> -   ring_buffer_start);
> +   ring_buffer_start + ring_buffer_head);
>  }
>  
>  static void
> -- 
> 2.19.1
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/5] intel/aub_read: remove useless breaks

2018-11-09 Thread Eric Engestrom
On Friday, 2018-11-09 16:49:09 +, Lionel Landwerlin wrote:
> Signed-off-by: Lionel Landwerlin 

`return` in indeed the one we need to keep here.
Reviewed-by: Eric Engestrom 

> ---
>  src/intel/tools/aub_read.c | 6 --
>  1 file changed, 6 deletions(-)
> 
> diff --git a/src/intel/tools/aub_read.c b/src/intel/tools/aub_read.c
> index d83e88ddced..cde6cb4ba03 100644
> --- a/src/intel/tools/aub_read.c
> +++ b/src/intel/tools/aub_read.c
> @@ -219,27 +219,21 @@ handle_memtrace_reg_write(struct aub_read *read, const 
> uint32_t *p)
> case 0x2510: /* render elsq0 lo */
>read->render_elsp[3] = value;
>return;
> -  break;
> case 0x2514: /* render elsq0 hi */
>read->render_elsp[2] = value;
>return;
> -  break;
> case 0x12510: /* video elsq0 lo */
>read->video_elsp[3] = value;
>return;
> -  break;
> case 0x12514: /* video elsq0 hi */
>read->video_elsp[2] = value;
>return;
> -  break;
> case 0x22510: /* blitter elsq0 lo */
>read->blitter_elsp[3] = value;
>return;
> -  break;
> case 0x22514: /* blitter elsq0 hi */
>read->blitter_elsp[2] = value;
>return;
> -  break;
> case 0x2550: /* render elsc */
>engine = GEN_ENGINE_RENDER;
>context_descriptor = (uint64_t)read->render_elsp[2] << 32 |
> -- 
> 2.19.1
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/15] nir: Rework boolean (and maybe all?) conversions

2018-11-09 Thread Jason Ekstrand
In case anyone is wondering my opinion based on my experience writing both
patch series, I think it's decidedly in the version B camp.  The code
changes required to nir_algebraic and nir_search are almost identical
between the two besides the whole virtual opcode thing and the changes to
front-end NIR producers are basically the same as well due to having to put
32 suffixes on some things.  However, the changes to other parts of NIR
aren't required and I feel they're very dirty and special-casey in version
A.

--Jason

On Thu, Nov 8, 2018 at 9:45 PM Jason Ekstrand  wrote:

> Welcome to this choose-your-own-adventure patch series!  The first six
> patches are good-to-go regardless of choices made later.  However, starting
> with patch 7, we have a choice to make.
>
> Version A of this series reworks NIR conversion opcodes to not have sizes
> and instead simply accept any source and destination size regardless of
> whether or not they match.  This is something that Connor and I talked
> about some time ago when we were first adding bit sizes.  With most
> opcodes, if they have any variable-size sources or a variable size
> destination, all variable sized things must match.  This series changes the
> rules so that, for conversion ops, they have a variable size source and
> destination which DO NOT have to match.  The upside to this is that we get
> to throw away piles of opcodes.  The downside is that it makes a number of
> things: validation, nir_search, constant folding, etc. more complicated
> because they now have to deal with a new set of rules.
>
> Version B of the series, reworks boolean conversions to be like the current
> conversions and also have bit sizes.  Unfortunately, this makes hash of
> opt_algebraic because, thanks to some applications love of re-inventing
> Boolean operations, we have piles of optimizations that contain b2f, f2b,
> b2i and i2b.  To deal with that problem (and make opt_algebraic easier to
> use in general), version B adds virtual unsized conversion opcodes to
> nir_search so that you can make an expression that matches any i2f opcode
> regardless of size.  From the perspective of opt_algebraic, then, the two
> series are nearly identical.  The downside of this approach is that the
> nir_search changes are kind-of hacky and we still have piles of conversion
> opcodes.  The upside, however, is that we don't have the extra mental
> overhead in constant folding, validation, and elsewhere of having this
> opcode special-case.
>
> What is the fate of NIR?  That's up to the people to decide!
>
> Cc: Ian Romanick 
> Cc: Connor Abbott 
>
> Jason Ekstrand COMMON (6):
>   nir/opcodes: Pull in the type helpers from constant_expressions
>   nir/opcodes: Rename tbool to tbool32
>   nir/algebraic: Improve a couple error messages
>   nir/algebraic: Set variable classes to the explicit bit size
>   nir/algebraic: Clean up some __str__ cruft
>   nir/algebraic: Improve error messages for replace expressions
>
> Jason Ekstrand VERSION A (9):
>   nir: Add a concept of an unsized conversion opcode
>   nir/builder: Create sized helpers for unsized conversion opcodes
>   nir/constant_expressions: Handle unsized conversion ops
>   nir/algebraic: Add support for unsized conversion opcodes
>   nir: Switch conversions to unsized opcodes
>   FIXUP: Fix NIR producers and consumers to use unsized conversions
>   FIXUP: nir/opt_algebraic: Drop bit-size suffixes from conversions
>   nir/algebraic: Add 32-bit specifiers to a bunch of booleans
>   nir: Make boolean conversions unsized like other types
>
> Jason Ekstrand VERSION B (8):
>   nir/algebraic: Refactor codegen a bit
>   nir/algebraic: Add support for unsized conversion opcodes
>   nir/opt_algebraic: Simplify an optimization using the new search ops
>   nir/opt_algebraic: Drop bit-size suffixes from conversions
>   nir/opt_algebraic: Add 32-bit specifiers to a bunch of booleans
>   nir: Make boolean conversions sized just like the others
>   FIXUP: nir/opt_algebraic: Add suffixes to some x2b opcodes
>   FIXUP: Fix NIR producers and consumers to use unsized conversions
>
>  src/amd/common/ac_nir_to_llvm.c   |  32 +--
>  src/compiler/glsl/glsl_to_nir.cpp |   2 +-
>  src/compiler/nir/nir.c|  67 ++
>  src/compiler/nir/nir.h|   7 +
>  src/compiler/nir/nir_algebraic.py | 174 +++
>  src/compiler/nir/nir_builder.h|  30 ++-
>  src/compiler/nir/nir_builder_opcodes_h.py |  16 +-
>  src/compiler/nir/nir_constant_expressions.h   |   3 +-
>  src/compiler/nir/nir_constant_expressions.py  |  59 +++---
>  src/compiler/nir/nir_loop_analyze.c   |   7 +-
>  src/compiler/nir/nir_lower_idiv.c |   2 +-
>  src/compiler/nir/nir_lower_int64.c|   2 +-
>  src/compiler/nir/nir_opcodes.py   | 152 +++--
>  src/compiler/nir/nir_opcodes_c.py |  89 +---
>  src/compiler/nir/nir_opt_algebraic.py  

[Mesa-dev] [PATCH 3/5] intel/aubinator: fix ring buffer pointer

2018-11-09 Thread Lionel Landwerlin
We can only start parsing commands from the head pointer. This was
working fine up to now because we only dealt with a "made up" ring
buffer (generated by aub_write) which always had its head at 0.

Signed-off-by: Lionel Landwerlin 
---
 src/intel/tools/aubinator.c  | 4 ++--
 src/intel/tools/aubinator_viewer.cpp | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index 04d920d98e5..5fed5f11389 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -151,7 +151,7 @@ handle_execlist_write(void *user_data, enum gen_engine 
engine, uint64_t context_
struct gen_batch_decode_bo ring_bo = aub_mem_get_ggtt_bo(,
 ring_buffer_start);
assert(ring_bo.size > 0);
-   void *commands = (uint8_t *)ring_bo.map + (ring_buffer_start - 
ring_bo.addr);
+   void *commands = (uint8_t *)ring_bo.map + (ring_buffer_start - 
ring_bo.addr) + ring_buffer_head;
 
if (context_descriptor & 0x100 /* ppgtt */) {
   batch_ctx.get_bo = aub_mem_get_ppgtt_bo;
@@ -162,7 +162,7 @@ handle_execlist_write(void *user_data, enum gen_engine 
engine, uint64_t context_
(void)engine; /* TODO */
gen_print_batch(_ctx, commands,
MIN2(ring_buffer_tail - ring_buffer_head, 
ring_buffer_length),
-   0);
+   ring_bo.addr + ring_buffer_head);
aub_mem_clear_bo_maps();
 }
 
diff --git a/src/intel/tools/aubinator_viewer.cpp 
b/src/intel/tools/aubinator_viewer.cpp
index dac03472153..5242edf86fc 100644
--- a/src/intel/tools/aubinator_viewer.cpp
+++ b/src/intel/tools/aubinator_viewer.cpp
@@ -729,13 +729,13 @@ display_batch_execlist_write(void *user_data, enum 
gen_engine engine,
struct gen_batch_decode_bo ring_bo =
   aub_mem_get_ggtt_bo(>mem, ring_buffer_start);
assert(ring_bo.size > 0);
-   void *commands = (uint8_t *)ring_bo.map + (ring_buffer_start - 
ring_bo.addr);
+   void *commands = (uint8_t *)ring_bo.map + (ring_buffer_start - 
ring_bo.addr) + ring_buffer_head;
 
window->uses_ppgtt = true;
 
aub_viewer_render_batch(>decode_ctx, commands,
MIN2(ring_buffer_tail - ring_buffer_head, 
ring_buffer_length),
-   ring_buffer_start);
+   ring_buffer_start + ring_buffer_head);
 }
 
 static void
-- 
2.19.1

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


[Mesa-dev] [PATCH 1/5] intel/aub_read: remove useless breaks

2018-11-09 Thread Lionel Landwerlin
Signed-off-by: Lionel Landwerlin 
---
 src/intel/tools/aub_read.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/src/intel/tools/aub_read.c b/src/intel/tools/aub_read.c
index d83e88ddced..cde6cb4ba03 100644
--- a/src/intel/tools/aub_read.c
+++ b/src/intel/tools/aub_read.c
@@ -219,27 +219,21 @@ handle_memtrace_reg_write(struct aub_read *read, const 
uint32_t *p)
case 0x2510: /* render elsq0 lo */
   read->render_elsp[3] = value;
   return;
-  break;
case 0x2514: /* render elsq0 hi */
   read->render_elsp[2] = value;
   return;
-  break;
case 0x12510: /* video elsq0 lo */
   read->video_elsp[3] = value;
   return;
-  break;
case 0x12514: /* video elsq0 hi */
   read->video_elsp[2] = value;
   return;
-  break;
case 0x22510: /* blitter elsq0 lo */
   read->blitter_elsp[3] = value;
   return;
-  break;
case 0x22514: /* blitter elsq0 hi */
   read->blitter_elsp[2] = value;
   return;
-  break;
case 0x2550: /* render elsc */
   engine = GEN_ENGINE_RENDER;
   context_descriptor = (uint64_t)read->render_elsp[2] << 32 |
-- 
2.19.1

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


[Mesa-dev] [PATCH 2/5] intel/decoders: read ring buffer length

2018-11-09 Thread Lionel Landwerlin
Use this value to limit reading the ring buffer.

Signed-off-by: Lionel Landwerlin 
---
 src/intel/tools/aubinator.c  | 4 +++-
 src/intel/tools/aubinator_viewer.cpp | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index 1458875a313..04d920d98e5 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -143,6 +143,7 @@ handle_execlist_write(void *user_data, enum gen_engine 
engine, uint64_t context_
uint32_t ring_buffer_head = context[5];
uint32_t ring_buffer_tail = context[7];
uint32_t ring_buffer_start = context[9];
+   uint32_t ring_buffer_length = (context[11] & 0x1ff000) + 4096;
 
mem.pml4 = (uint64_t)context[49] << 32 | context[51];
batch_ctx.user_data = 
@@ -159,7 +160,8 @@ handle_execlist_write(void *user_data, enum gen_engine 
engine, uint64_t context_
}
 
(void)engine; /* TODO */
-   gen_print_batch(_ctx, commands, ring_buffer_tail - ring_buffer_head,
+   gen_print_batch(_ctx, commands,
+   MIN2(ring_buffer_tail - ring_buffer_head, 
ring_buffer_length),
0);
aub_mem_clear_bo_maps();
 }
diff --git a/src/intel/tools/aubinator_viewer.cpp 
b/src/intel/tools/aubinator_viewer.cpp
index 27ef4f7e99b..dac03472153 100644
--- a/src/intel/tools/aubinator_viewer.cpp
+++ b/src/intel/tools/aubinator_viewer.cpp
@@ -722,6 +722,7 @@ display_batch_execlist_write(void *user_data, enum 
gen_engine engine,
uint32_t ring_buffer_head = context_img[5];
uint32_t ring_buffer_tail = context_img[7];
uint32_t ring_buffer_start = context_img[9];
+   uint32_t ring_buffer_length = (context_img[11] & 0x1ff000) + 4096;
 
window->mem.pml4 = (uint64_t)context_img[49] << 32 | context_img[51];
 
@@ -733,7 +734,7 @@ display_batch_execlist_write(void *user_data, enum 
gen_engine engine,
window->uses_ppgtt = true;
 
aub_viewer_render_batch(>decode_ctx, commands,
-   ring_buffer_tail - ring_buffer_head,
+   MIN2(ring_buffer_tail - ring_buffer_head, 
ring_buffer_length),
ring_buffer_start);
 }
 
-- 
2.19.1

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


[Mesa-dev] [PATCH 4/5] intel/aub_viewer: fix dynamic state printing

2018-11-09 Thread Lionel Landwerlin
Identical fix to :

commit cbd4bc1346f7397242e157bb66099b950a8c5643
Author: Jason Ekstrand 
Date:   Fri Aug 24 16:04:03 2018 -0500

intel/batch_decoder: Fix dynamic state printing

Signed-off-by: Lionel Landwerlin 
---
 src/intel/tools/aubinator_viewer_decoder.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/tools/aubinator_viewer_decoder.cpp 
b/src/intel/tools/aubinator_viewer_decoder.cpp
index 59cde530409..a9e78bf04a6 100644
--- a/src/intel/tools/aubinator_viewer_decoder.cpp
+++ b/src/intel/tools/aubinator_viewer_decoder.cpp
@@ -650,10 +650,10 @@ decode_dynamic_state_pointers(struct 
aub_viewer_decode_ctx *ctx,
 
for (int i = 0; i < count; i++) {
   ImGui::Text("%s %d", struct_type, i);
-  aub_viewer_print_group(ctx, state, state_offset, state_map);
+  aub_viewer_print_group(ctx, state, state_addr, state_map);
 
   state_addr += state->dw_length * 4;
-  state_map += state->dw_length;
+  state_map += state->dw_length * 4;
}
 }
 
-- 
2.19.1

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


[Mesa-dev] [PATCH 5/5] intel/aub_viewer: Print blend states properly

2018-11-09 Thread Lionel Landwerlin
Identical fix to :

commit 70de31d0c106f58d6b7e6d5b79b8d90c1c112a3b
Author: Jason Ekstrand 
Date:   Fri Aug 24 16:05:08 2018 -0500

intel/batch_decoder: Print blend states properly

Signed-off-by: Lionel Landwerlin 
---
 src/intel/tools/aubinator_viewer_decoder.cpp | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/intel/tools/aubinator_viewer_decoder.cpp 
b/src/intel/tools/aubinator_viewer_decoder.cpp
index a9e78bf04a6..adf0ac1f58d 100644
--- a/src/intel/tools/aubinator_viewer_decoder.cpp
+++ b/src/intel/tools/aubinator_viewer_decoder.cpp
@@ -624,8 +624,6 @@ decode_dynamic_state_pointers(struct aub_viewer_decode_ctx 
*ctx,
   struct gen_group *inst, const uint32_t *p,
   const char *struct_type,  int count)
 {
-   struct gen_group *state = gen_spec_find_struct(ctx->spec, struct_type);
-
uint32_t state_offset = 0;
 
struct gen_field_iterator iter;
@@ -648,6 +646,22 @@ decode_dynamic_state_pointers(struct aub_viewer_decode_ctx 
*ctx,
   return;
}
 
+   struct gen_group *state = gen_spec_find_struct(ctx->spec, struct_type);
+   if (strcmp(struct_type, "BLEND_STATE") == 0) {
+  /* Blend states are different from the others because they have a header
+   * struct called BLEND_STATE which is followed by a variable number of
+   * BLEND_STATE_ENTRY structs.
+   */
+  ImGui::Text("%s", struct_type);
+  aub_viewer_print_group(ctx, state, state_addr, state_map);
+
+  state_addr += state->dw_length * 4;
+  state_map += state->dw_length * 4;
+
+  struct_type = "BLEND_STATE_ENTRY";
+  state = gen_spec_find_struct(ctx->spec, struct_type);
+   }
+
for (int i = 0; i < count; i++) {
   ImGui::Text("%s %d", struct_type, i);
   aub_viewer_print_group(ctx, state, state_addr, state_map);
-- 
2.19.1

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


[Mesa-dev] [PATCH 0/5] intel/aubinators: fixes

2018-11-09 Thread Lionel Landwerlin
Hi all,

Here are a few cleanups/fixes I have in a pretty long branch. I
figured this would be easier to review on its own.

Thanks for your time,

Lionel Landwerlin (5):
  intel/aub_read: remove useless breaks
  intel/decoders: read ring buffer length
  intel/aubinator: fix ring buffer pointer
  intel/aub_viewer: fix dynamic state printing
  intel/aub_viewer: Print blend states properly

 src/intel/tools/aub_read.c   |  6 --
 src/intel/tools/aubinator.c  |  8 ---
 src/intel/tools/aubinator_viewer.cpp |  7 ---
 src/intel/tools/aubinator_viewer_decoder.cpp | 22 
 4 files changed, 27 insertions(+), 16 deletions(-)

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


Re: [Mesa-dev] [PATCH] mesa/main: fixup make check after NV_conditional_render for gles

2018-11-09 Thread Ilia Mirkin
On Fri, Nov 9, 2018 at 11:43 AM Erik Faye-Lund
 wrote:
>
> On Fri, 2018-11-09 at 11:17 -0500, Ilia Mirkin wrote:
> > On Fri, Nov 9, 2018 at 10:51 AM Erik Faye-Lund
> >  wrote:
> > > On Fri, 2018-11-09 at 10:44 -0500, Ilia Mirkin wrote:
> > > > Errr ... why are these being added to the ABI now? Extensions are
> > > > generally not added in. Some are grandfathered in, but this one
> > > > would
> > > > be new.
> > > >
> > > > Or is this due to the fact that it's grandfathered in for GL, and
> > > > making that and GLES different would be tricky?
> > >
> > > I'm not sure, really. This feature missed the 18.3 release anyway,
> > > so
> > > we have time to fix this up, if anyone knows for sure.
> > >
> > > I don't think there's a good reason to cement this in the GLES ABI,
> > > so
> > > I think we should remove it, if that's possible. I don't really
> > > know
> > > what makes this appear in the ABI, though. If someone can explain,
> > > I'd
> > > be happy to fix things up.
> > >
> > > Anyway, I pushed the test-fixes for now; the ABI change seems to
> > > already have happened.
> >
> > That cements it as an OK thing to do.
>
> Please explain.
>
> > When you push a buggy change,
> > the solution isn't "make the test ignore the bug". The solution is to
> > either fix the bug or revert the offending change.
>
> Yes, and I thought I fixed the bug. I didn't see your message until
> *after* I pushed the fixup commit. I just thought I could fix this up

Ah OK. I wasn't checking the actual commits, just looking at email.

> further after the weekend, because I have dinner on the stove and
> guests about to arrive. Surely applications won't magically start
> depending on this symbol being visible until then.

Seems unlikely. And even the revert could have easily waited a day or
two. The problem happens when after a day or two you forget all about
it -- there's no indication of any failure, etc, so it's easy to let
it slip through. And now we've effectively expanded our ABI by
accident, and will never remember to fix it.

>
> Anyway, I've reverted both commits, and I'll retry this whole thing
> next week.

Thanks!

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


Re: [Mesa-dev] [PATCH] mesa/main: fixup make check after NV_conditional_render for gles

2018-11-09 Thread Erik Faye-Lund
On Fri, 2018-11-09 at 11:17 -0500, Ilia Mirkin wrote:
> On Fri, Nov 9, 2018 at 10:51 AM Erik Faye-Lund
>  wrote:
> > On Fri, 2018-11-09 at 10:44 -0500, Ilia Mirkin wrote:
> > > Errr ... why are these being added to the ABI now? Extensions are
> > > generally not added in. Some are grandfathered in, but this one
> > > would
> > > be new.
> > > 
> > > Or is this due to the fact that it's grandfathered in for GL, and
> > > making that and GLES different would be tricky?
> > 
> > I'm not sure, really. This feature missed the 18.3 release anyway,
> > so
> > we have time to fix this up, if anyone knows for sure.
> > 
> > I don't think there's a good reason to cement this in the GLES ABI,
> > so
> > I think we should remove it, if that's possible. I don't really
> > know
> > what makes this appear in the ABI, though. If someone can explain,
> > I'd
> > be happy to fix things up.
> > 
> > Anyway, I pushed the test-fixes for now; the ABI change seems to
> > already have happened.
> 
> That cements it as an OK thing to do.

Please explain.

> When you push a buggy change,
> the solution isn't "make the test ignore the bug". The solution is to
> either fix the bug or revert the offending change.

Yes, and I thought I fixed the bug. I didn't see your message until
*after* I pushed the fixup commit. I just thought I could fix this up
further after the weekend, because I have dinner on the stove and
guests about to arrive. Surely applications won't magically start
depending on this symbol being visible until then.

Anyway, I've reverted both commits, and I'll retry this whole thing
next week.

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


Re: [Mesa-dev] [PATCH] intel/fs: Prevent emission of IR instructions not aligned to their own execution size.

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


Re: [Mesa-dev] [PATCH] mesa/main: fixup make check after NV_conditional_render for gles

2018-11-09 Thread Ilia Mirkin
On Fri, Nov 9, 2018 at 10:51 AM Erik Faye-Lund
 wrote:
>
> On Fri, 2018-11-09 at 10:44 -0500, Ilia Mirkin wrote:
> > Errr ... why are these being added to the ABI now? Extensions are
> > generally not added in. Some are grandfathered in, but this one would
> > be new.
> >
> > Or is this due to the fact that it's grandfathered in for GL, and
> > making that and GLES different would be tricky?
>
> I'm not sure, really. This feature missed the 18.3 release anyway, so
> we have time to fix this up, if anyone knows for sure.
>
> I don't think there's a good reason to cement this in the GLES ABI, so
> I think we should remove it, if that's possible. I don't really know
> what makes this appear in the ABI, though. If someone can explain, I'd
> be happy to fix things up.
>
> Anyway, I pushed the test-fixes for now; the ABI change seems to
> already have happened.

That cements it as an OK thing to do. When you push a buggy change,
the solution isn't "make the test ignore the bug". The solution is to
either fix the bug or revert the offending change.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2] nir: fix output offset compute for dvec3/4

2018-11-09 Thread Jason Ekstrand
Cool.  1-3 are

Reviewed-by: Jason Ekstrand 

On Fri, Nov 9, 2018 at 7:09 AM Alejandro Piñeiro 
wrote:

> The offset compute was working fine for the case of attrib_slots=1,
> and updating the offset for the following varying.
>
> But in the case of attrib_slots=2 (so dvec3/4), we are basically
> splitting the comp_slots needed in two outputs. In that case we can't
> add to the offset the full size of the type.
>
> v2: added assert and some parenthesis to improve readability (Jason)
> ---
>  src/compiler/nir/nir_gather_xfb_info.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/compiler/nir/nir_gather_xfb_info.c
> b/src/compiler/nir/nir_gather_xfb_info.c
> index f8d4cd833c7..f4f597da4f5 100644
> --- a/src/compiler/nir/nir_gather_xfb_info.c
> +++ b/src/compiler/nir/nir_gather_xfb_info.c
> @@ -81,7 +81,12 @@ add_var_xfb_outputs(nir_xfb_info *xfb,
>   output->component_mask = (comp_mask >> (s * 4)) & 0xf;
>
>   (*location)++;
> - *offset += comp_slots * 4;
> + /* attrib_slots would be only > 1 for doubles. On that case
> +  * comp_slots will be a multiple of 2, so the following doesn't
> need
> +  * to use DIV_ROUND_UP or similar
> +  */
> + assert(comp_slots % attrib_slots == 0);
> + *offset += (comp_slots / attrib_slots) * 4;
>}
> }
>  }
> --
> 2.14.1
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 6/7] RFC: nir/xfb_info: arrays of basic types adds just one varying

2018-11-09 Thread Jason Ekstrand

On November 9, 2018 06:39:25 Alejandro Piñeiro  wrote:

On 08/11/18 23:14, Jason Ekstrand wrote:



On Thu, Nov 8, 2018 at 7:22 AM Alejandro Piñeiro  wrote:

On OpenGL, a array of a simple type adds just one varying. So
gl_transform_feedback_varying_info struct defined at mtypes.h includes
the parameters Type (base_type) and Size (number of elements).

This commit checks this when the recursive add_var_xfb_outputs call
handles arrays, to ensure that just one is addded.

RFC: Until this point, all changes were reasonable, but this change is
(imho) ugly. My idea was introducing as less as possible changes on
the code, specially on its logic/flow. But this commit is almost a
hack. The ideal solution would be to change the focus of the recursive
function, focusing on varyings, and at each varying, recursively add
outputs. But that seems like an overkill for a pass that was
originally intended for consumers only caring about the outputs. So
perhaps ARB_gl_spirv should keep their own gathering pass, with
vayings and outputs, and let this one untouched for those that only
care on outputs.
---
 src/compiler/nir/nir_gather_xfb_info.c | 52 --
 1 file changed, 43 insertions(+), 9 deletions(-)

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

index 948b802a815..cb0e2724cab 100644
--- a/src/compiler/nir/nir_gather_xfb_info.c
+++ b/src/compiler/nir/nir_gather_xfb_info.c
@@ -36,23 +36,59 @@ nir_gather_xfb_info_create(void *mem_ctx, uint16_t 
output_count, uint16_t varyin

return xfb;
 }

+static bool
+glsl_type_is_leaf(const struct glsl_type *type)
+{
+   if (glsl_type_is_struct(type) ||
+   (glsl_type_is_array(type) &&
+(glsl_type_is_array(glsl_get_array_element(type)) ||
+ glsl_type_is_struct(glsl_get_array_element(type) {



I'm trying to understand exactly what this means.  From what you wrote here 
it looks like the following are all one varying:



float var[3];
vec2 var[3];
mat4 var[3];



Yes, GLSL returns one varying per each one (Size 3).


Just to be clear, a matrix it array of matrices is one varying?








but the following are not


struct S {
  float f;
  vec4 v;

};


S var[3];





float var[3][5];



I guess that you are asking for thos two cases because this code is  not 
handling it properly. You are right. For the array of structs, our code is 
crashing. For the array of arrays, it is enumerating four varyings. One 
with three GL_FLOAT components, and three with five GL_FLOAT components, 
instead of just three varyings with five components. In my defense, I 
already mentioned that it was wip code, but preferred to agree on the way 
to go before keep working on it.




For the GLSL case, the array of struct returns 6 varyings. And funny thing, 
for the array of arrays, GLSL is handling the situation even worse. It 
returns the following link error: "Failed to link: error: Transform 
feedback varying var[0] undeclared." Just a quick skim on the spec, I 
didn't see anything preventing using aoa with transform feedback varyings, 
so I guess that this is a bug due all the rules OpenGL has in relation with 
variable names.








Is this correct?



Yes. FWIW, I will give you another two examples, from the tests Im using as 
reference.




## example 1 ##

struct Array {

float x2_out;

};

struct AoA {

Array x2_Array[2];

};

struct S {

float x1_out;

AoA x2_AoA[2];

float x3_out;

};

layout(xfb_offset = 0) out S s1;

layout(xfb_offset = 0, xfb_buffer = 2) out struct S2 {

float y1_out;

vec4 y2_out;

} s2;



GLSL returns the following varyings (on ARB_gl_spirv we target to get the 
same, although without the names)


NumVarying=8, (Offset, Type, BufferIndex, Size, Name)

0:( 0,GL_FLOAT,  0,  1, s1.x1_out)

1:( 4,GL_FLOAT,  0,  1, s1.x2_AoA[0].x2_Array[0].x2_out)

2:( 8,GL_FLOAT,  0,  1, s1.x2_AoA[0].x2_Array[1].x2_out)

3:(12,GL_FLOAT,  0,  1, s1.x2_AoA[1].x2_Array[0].x2_out)

4:(16,GL_FLOAT,  0,  1, s1.x2_AoA[1].x2_Array[1].x2_out)

5:(20,GL_FLOAT,  0,  1, s1.x3_out)

6:( 0,GL_FLOAT,  1,  1, s2.y1_out)

7:( 4,   GL_FLOAT_VEC4,  1,  1, s2.y2_out)



## example 2 ##

layout(xfb_offset = 0) out float x1_out;

layout(xfb_offset = 4) out float x2_out[2];

layout(xfb_offset = 12) out vec3 x3_out;

layout(xfb_buffer = 2) out;

layout(xfb_offset = 0, xfb_buffer = 2) out float y1_out;

layout(xfb_offset = 4) out vec4 y2_out



GLSL returns the following varyings (on ARB_gl_spirv we target to get the 
same, although without the names)


NumVarying=5, (Offset, Type, BufferIndex, Size, Name)

0:( 0,GL_FLOAT,  0,  1, x1_out)

1:( 4,GL_FLOAT,  0,  2, x2_out)

2:(12,   GL_FLOAT_VEC3,  0,  1, x3_out)

3:( 0,GL_FLOAT,  1,  1, y1_out)

4:( 4,   GL_FLOAT_VEC4,  1,  1, y2_out)






+  return false;
+   } else {
+  return true;
+   }
+}
+
+static void
+add_var_xfb_varying(nir_xfb_info *xfb,
+nir_variable 

Re: [Mesa-dev] [PATCH] mesa/main: fixup make check after NV_conditional_render for gles

2018-11-09 Thread Erik Faye-Lund
On Fri, 2018-11-09 at 10:44 -0500, Ilia Mirkin wrote:
> Errr ... why are these being added to the ABI now? Extensions are
> generally not added in. Some are grandfathered in, but this one would
> be new.
> 
> Or is this due to the fact that it's grandfathered in for GL, and
> making that and GLES different would be tricky?

I'm not sure, really. This feature missed the 18.3 release anyway, so
we have time to fix this up, if anyone knows for sure.

I don't think there's a good reason to cement this in the GLES ABI, so
I think we should remove it, if that's possible. I don't really know
what makes this appear in the ABI, though. If someone can explain, I'd
be happy to fix things up.

Anyway, I pushed the test-fixes for now; the ABI change seems to
already have happened.

> On Fri, Nov 9, 2018 at 10:20 AM Erik Faye-Lund
>  wrote:
> > It seems I missed some details when exposing NV_conditional_render
> > on GLES; this fixes up "make check".
> > 
> > Fixes: 5213be9fab7 ("mesa: expose NV_conditional_render on GLES")
> > Signed-off-by: Erik Faye-Lund 
> > ---
> > Caught by the Intel CI system. Sorry about this!
> > 
> >  src/mapi/es2api/ABI-check   | 2 ++
> >  src/mesa/main/tests/dispatch_sanity.cpp | 4 
> >  2 files changed, 6 insertions(+)
> > 
> > diff --git a/src/mapi/es2api/ABI-check b/src/mapi/es2api/ABI-check
> > index a04b03d7d60..8f601a0603c 100755
> > --- a/src/mapi/es2api/ABI-check
> > +++ b/src/mapi/es2api/ABI-check
> > @@ -28,6 +28,7 @@ FUNCS=$($NM -D --defined-only $LIB | grep -o 'T
> > gl.*' | cut -c 3- | while read f
> >  glActiveShaderProgram
> >  glActiveTexture
> >  glAttachShader
> > +glBeginConditionalRenderNV
> >  glBeginQuery
> >  glBeginTransformFeedback
> >  glBindAttribLocation
> > @@ -123,6 +124,7 @@ glEGLImageTargetTexture2DOES
> >  glEnable
> >  glEnableVertexAttribArray
> >  glEnablei
> > +glEndConditionalRenderNV
> >  glEndQuery
> >  glEndTransformFeedback
> >  glFenceSync
> > diff --git a/src/mesa/main/tests/dispatch_sanity.cpp
> > b/src/mesa/main/tests/dispatch_sanity.cpp
> > index fb2acfbdeea..c5d75f9683e 100644
> > --- a/src/mesa/main/tests/dispatch_sanity.cpp
> > +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> > @@ -2236,6 +2236,10 @@ const struct function
> > gles2_functions_possible[] = {
> > /* GL_NV_conservative_raster_pre_snap_triangles */
> > { "glConservativeRasterParameteriNV", 20, -1 },
> > 
> > +   /* GL_NV_conditional_render */
> > +   { "glBeginConditionalRenderNV", 20, -1 },
> > +   { "glEndConditionalRenderNV", 20, -1 },
> > +
> > { NULL, 0, -1 }
> >  };
> > 
> > --
> > 2.19.1
> > 
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

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


Re: [Mesa-dev] [PATCH] mesa/main: fixup make check after NV_conditional_render for gles

2018-11-09 Thread Ilia Mirkin
Errr ... why are these being added to the ABI now? Extensions are
generally not added in. Some are grandfathered in, but this one would
be new.

Or is this due to the fact that it's grandfathered in for GL, and
making that and GLES different would be tricky?
On Fri, Nov 9, 2018 at 10:20 AM Erik Faye-Lund
 wrote:
>
> It seems I missed some details when exposing NV_conditional_render
> on GLES; this fixes up "make check".
>
> Fixes: 5213be9fab7 ("mesa: expose NV_conditional_render on GLES")
> Signed-off-by: Erik Faye-Lund 
> ---
> Caught by the Intel CI system. Sorry about this!
>
>  src/mapi/es2api/ABI-check   | 2 ++
>  src/mesa/main/tests/dispatch_sanity.cpp | 4 
>  2 files changed, 6 insertions(+)
>
> diff --git a/src/mapi/es2api/ABI-check b/src/mapi/es2api/ABI-check
> index a04b03d7d60..8f601a0603c 100755
> --- a/src/mapi/es2api/ABI-check
> +++ b/src/mapi/es2api/ABI-check
> @@ -28,6 +28,7 @@ FUNCS=$($NM -D --defined-only $LIB | grep -o 'T gl.*' | cut 
> -c 3- | while read f
>  glActiveShaderProgram
>  glActiveTexture
>  glAttachShader
> +glBeginConditionalRenderNV
>  glBeginQuery
>  glBeginTransformFeedback
>  glBindAttribLocation
> @@ -123,6 +124,7 @@ glEGLImageTargetTexture2DOES
>  glEnable
>  glEnableVertexAttribArray
>  glEnablei
> +glEndConditionalRenderNV
>  glEndQuery
>  glEndTransformFeedback
>  glFenceSync
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
> b/src/mesa/main/tests/dispatch_sanity.cpp
> index fb2acfbdeea..c5d75f9683e 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -2236,6 +2236,10 @@ const struct function gles2_functions_possible[] = {
> /* GL_NV_conservative_raster_pre_snap_triangles */
> { "glConservativeRasterParameteriNV", 20, -1 },
>
> +   /* GL_NV_conditional_render */
> +   { "glBeginConditionalRenderNV", 20, -1 },
> +   { "glEndConditionalRenderNV", 20, -1 },
> +
> { NULL, 0, -1 }
>  };
>
> --
> 2.19.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa/main: fixup make check after NV_conditional_render for gles

2018-11-09 Thread Eric Engestrom
On Friday, 2018-11-09 16:20:39 +0100, Erik Faye-Lund wrote:
> It seems I missed some details when exposing NV_conditional_render
> on GLES; this fixes up "make check".
> 
> Fixes: 5213be9fab7 ("mesa: expose NV_conditional_render on GLES")
> Signed-off-by: Erik Faye-Lund 

Thanks for the quick fix!
Reviewed-and-Tested-by: Eric Engestrom 

> ---
> Caught by the Intel CI system. Sorry about this!
> 
>  src/mapi/es2api/ABI-check   | 2 ++
>  src/mesa/main/tests/dispatch_sanity.cpp | 4 
>  2 files changed, 6 insertions(+)
> 
> diff --git a/src/mapi/es2api/ABI-check b/src/mapi/es2api/ABI-check
> index a04b03d7d60..8f601a0603c 100755
> --- a/src/mapi/es2api/ABI-check
> +++ b/src/mapi/es2api/ABI-check
> @@ -28,6 +28,7 @@ FUNCS=$($NM -D --defined-only $LIB | grep -o 'T gl.*' | cut 
> -c 3- | while read f
>  glActiveShaderProgram
>  glActiveTexture
>  glAttachShader
> +glBeginConditionalRenderNV
>  glBeginQuery
>  glBeginTransformFeedback
>  glBindAttribLocation
> @@ -123,6 +124,7 @@ glEGLImageTargetTexture2DOES
>  glEnable
>  glEnableVertexAttribArray
>  glEnablei
> +glEndConditionalRenderNV
>  glEndQuery
>  glEndTransformFeedback
>  glFenceSync
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
> b/src/mesa/main/tests/dispatch_sanity.cpp
> index fb2acfbdeea..c5d75f9683e 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -2236,6 +2236,10 @@ const struct function gles2_functions_possible[] = {
> /* GL_NV_conservative_raster_pre_snap_triangles */
> { "glConservativeRasterParameteriNV", 20, -1 },
>  
> +   /* GL_NV_conditional_render */
> +   { "glBeginConditionalRenderNV", 20, -1 },
> +   { "glEndConditionalRenderNV", 20, -1 },
> +
> { NULL, 0, -1 }
>  };
>  
> -- 
> 2.19.1
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa/main: fixup make check after NV_conditional_render for gles

2018-11-09 Thread Erik Faye-Lund
It seems I missed some details when exposing NV_conditional_render
on GLES; this fixes up "make check".

Fixes: 5213be9fab7 ("mesa: expose NV_conditional_render on GLES")
Signed-off-by: Erik Faye-Lund 
---
Caught by the Intel CI system. Sorry about this!

 src/mapi/es2api/ABI-check   | 2 ++
 src/mesa/main/tests/dispatch_sanity.cpp | 4 
 2 files changed, 6 insertions(+)

diff --git a/src/mapi/es2api/ABI-check b/src/mapi/es2api/ABI-check
index a04b03d7d60..8f601a0603c 100755
--- a/src/mapi/es2api/ABI-check
+++ b/src/mapi/es2api/ABI-check
@@ -28,6 +28,7 @@ FUNCS=$($NM -D --defined-only $LIB | grep -o 'T gl.*' | cut 
-c 3- | while read f
 glActiveShaderProgram
 glActiveTexture
 glAttachShader
+glBeginConditionalRenderNV
 glBeginQuery
 glBeginTransformFeedback
 glBindAttribLocation
@@ -123,6 +124,7 @@ glEGLImageTargetTexture2DOES
 glEnable
 glEnableVertexAttribArray
 glEnablei
+glEndConditionalRenderNV
 glEndQuery
 glEndTransformFeedback
 glFenceSync
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index fb2acfbdeea..c5d75f9683e 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -2236,6 +2236,10 @@ const struct function gles2_functions_possible[] = {
/* GL_NV_conservative_raster_pre_snap_triangles */
{ "glConservativeRasterParameteriNV", 20, -1 },
 
+   /* GL_NV_conditional_render */
+   { "glBeginConditionalRenderNV", 20, -1 },
+   { "glEndConditionalRenderNV", 20, -1 },
+
{ NULL, 0, -1 }
 };
 
-- 
2.19.1

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


Re: [Mesa-dev] [PATCH 2/4] compiler: avoid 'unused variable' and 'may be used uninitialized' warnings

2018-11-09 Thread andrey simiklit
Hello,

Thanks for review.
Please find my comments below:

On Fri, Nov 9, 2018 at 2:52 PM Eric Engestrom 
wrote:

> On Tuesday, 2018-09-11 15:42:05 +0300, asimiklit.w...@gmail.com wrote:
> > From: Andrii Simiklit 
> >
> > 1. nir/nir_lower_vars_to_ssa.c:691:21: warning:
> >unused variable ‘var’
> >nir_variable *var = path->path[0]->var;
> >
> > 2. nir_types.cpp:558:31: warning:
> > ‘elem_align’ may be used uninitialized in this function
> >unsigned elem_size, elem_align;
> >nir_types.cpp:558:20: warning:
> >‘elem_size’ may be used uninitialized in this function
> >unsigned elem_size, elem_align;
> >
> > Signed-off-by: Andrii Simiklit 
> > ---
> >  src/compiler/nir/nir_lower_vars_to_ssa.c | 2 +-
> >  src/compiler/nir_types.cpp   | 4 ++--
> >  2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c
> b/src/compiler/nir/nir_lower_vars_to_ssa.c
> > index cd679be..96de261 100644
> > --- a/src/compiler/nir/nir_lower_vars_to_ssa.c
> > +++ b/src/compiler/nir/nir_lower_vars_to_ssa.c
> > @@ -688,7 +688,7 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl)
> >nir_deref_path *path = >path;
> >
> >assert(path->path[0]->deref_type == nir_deref_type_var);
> > -  nir_variable *var = path->path[0]->var;
> > +  MAYBE_UNUSED nir_variable *var = path->path[0]->var;
> >
> >/* We don't build deref nodes for non-local variables */
> >assert(var->data.mode == nir_var_local);
>
> Sure, or you could simply remove the single-use extra local variable and
> just fold it into the assert :)
>

I agree,will fix :)


>
> > diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
> > index d24f094..d39d87b 100644
> > --- a/src/compiler/nir_types.cpp
> > +++ b/src/compiler/nir_types.cpp
> > @@ -542,7 +542,7 @@ glsl_get_natural_size_align_bytes(const struct
> glsl_type *type,
> > }
> >
> > case GLSL_TYPE_ARRAY: {
> > -  unsigned elem_size, elem_align;
> > +  unsigned elem_size = 0, elem_align = 0;
>
> Not really keen on these ones; it looks like your compiler is ignoring the
> unreachable() in glsl_get_natural_size_align_bytes() and mis-computing the
> possible code-paths, resulting in it wrongly printing a warning.
>

You are right when I added the 'default:' case to the switch the warning is
disappeared:

case GLSL_TYPE_INTERFACE:
case GLSL_TYPE_FUNCTION:
+default:
   unreachable("type does not have a natural size");

What do you think about such solution? Is it acceptable for you?


> I'd prefer to keep these two hunks as is, so that real issue in
> glsl_get_natural_size_align_bytes() would get flagged appropriately.
>
> >glsl_get_natural_size_align_bytes(type->fields.array,
> >  _size, _align);
> >*align = elem_align;
> > @@ -554,7 +554,7 @@ glsl_get_natural_size_align_bytes(const struct
> glsl_type *type,
> >*size = 0;
> >*align = 0;
> >for (unsigned i = 0; i < type->length; i++) {
> > - unsigned elem_size, elem_align;
> > + unsigned elem_size = 0, elem_align = 0;
> >
>  glsl_get_natural_size_align_bytes(type->fields.structure[i].type,
> > _size, _align);
> >   *align = MAX2(*align, elem_align);
> > --
> > 2.7.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] [PATCH] radv: include LLVM IR in the VK_AMD_shader_info "disassembly"

2018-11-09 Thread Samuel Pitoiset



On 11/9/18 2:53 PM, Haehnle, Nicolai wrote:

On 08.11.18 20:39, Samuel Pitoiset wrote:



On 11/8/18 4:15 PM, Nicolai Hähnle wrote:

From: Nicolai Hähnle 

Helpful for debugging compiler backend problems: this allows us to
easily retrieve the LLVM IR from RenderDoc.
--
For the peanut gallery: AMD's official stance on radv hasn't changed.
But we take regressions for radv caused by our changes in LLVM seriously.
After all, they might just as well affect anything else using the same
compiler backend...


Thanks a lot for looking at those regressions. Your help is highly
appreciated.

One comment below.


---
   src/amd/vulkan/radv_shader.c | 1 +
   1 file changed, 1 insertion(+)

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index f98ca6b4edd..1c51297d202 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -855,20 +855,21 @@ radv_GetShaderInfoAMD(VkDevice _device,
   result = VK_INCOMPLETE;
   }
   break;
   case VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD:
   buf = _mesa_string_buffer_create(NULL, 1024);
   _mesa_string_buffer_printf(buf, "%s:\n",
radv_get_shader_name(variant, stage));
   _mesa_string_buffer_printf(buf, "%s\n\n",
variant->disasm_string);
   generate_shader_stats(device, variant, stage, buf);
+    _mesa_string_buffer_printf(buf, "\n\n%s\n\n",
variant->llvm_ir_string);


I would prefer to put the LLVM IR just before the assembly to be
consistent with the output of RADV_DEBUG=shaders.


Sure, I can do that. I chose this order simply because I ran into this
from the RenderDoc use case, where I'd expect people are more interested
in the GCN assembly upfront. But it doesn't really matter, so I'll
change it :)


Yeah, it doesn't really matter much. :)



Cheers,
Nicolai



Other than that, patch is:

Reviewed-by: Samuel Pitoiset 


   /* Need to include the null terminator. */
   size_t length = buf->length + 1;
   if (!pInfo) {
   *pInfoSize = length;
   } else {
   size_t size = *pInfoSize;
   *pInfoSize = length;


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


Re: [Mesa-dev] [PATCH] radv: include LLVM IR in the VK_AMD_shader_info "disassembly"

2018-11-09 Thread Haehnle, Nicolai
On 08.11.18 20:39, Samuel Pitoiset wrote:
> 
> 
> On 11/8/18 4:15 PM, Nicolai Hähnle wrote:
>> From: Nicolai Hähnle 
>>
>> Helpful for debugging compiler backend problems: this allows us to
>> easily retrieve the LLVM IR from RenderDoc.
>> -- 
>> For the peanut gallery: AMD's official stance on radv hasn't changed.
>> But we take regressions for radv caused by our changes in LLVM seriously.
>> After all, they might just as well affect anything else using the same
>> compiler backend...
> 
> Thanks a lot for looking at those regressions. Your help is highly 
> appreciated.
> 
> One comment below.
> 
>> ---
>>   src/amd/vulkan/radv_shader.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
>> index f98ca6b4edd..1c51297d202 100644
>> --- a/src/amd/vulkan/radv_shader.c
>> +++ b/src/amd/vulkan/radv_shader.c
>> @@ -855,20 +855,21 @@ radv_GetShaderInfoAMD(VkDevice _device,
>>   result = VK_INCOMPLETE;
>>   }
>>   break;
>>   case VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD:
>>   buf = _mesa_string_buffer_create(NULL, 1024);
>>   _mesa_string_buffer_printf(buf, "%s:\n", 
>> radv_get_shader_name(variant, stage));
>>   _mesa_string_buffer_printf(buf, "%s\n\n", 
>> variant->disasm_string);
>>   generate_shader_stats(device, variant, stage, buf);
>> +    _mesa_string_buffer_printf(buf, "\n\n%s\n\n", 
>> variant->llvm_ir_string);
> 
> I would prefer to put the LLVM IR just before the assembly to be 
> consistent with the output of RADV_DEBUG=shaders.

Sure, I can do that. I chose this order simply because I ran into this 
from the RenderDoc use case, where I'd expect people are more interested 
in the GCN assembly upfront. But it doesn't really matter, so I'll 
change it :)

Cheers,
Nicolai


> Other than that, patch is:
> 
> Reviewed-by: Samuel Pitoiset 
> 
>>   /* Need to include the null terminator. */
>>   size_t length = buf->length + 1;
>>   if (!pInfo) {
>>   *pInfoSize = length;
>>   } else {
>>   size_t size = *pInfoSize;
>>   *pInfoSize = length;
>>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/4] main: avoid 'may be used uninitialized' warnings

2018-11-09 Thread Eric Engestrom
On Tuesday, 2018-09-11 15:42:07 +0300, asimiklit.w...@gmail.com wrote:
> From: Andrii Simiklit 
> 
> 1. main/texcompress_etc.c:1314:12:
> warning: ‘*((void *)+2)’ may be used uninitialized in this function
> 2. main/texcompress_etc.c:1354:12:
> warning: ‘*((void *)+2)’ may be used uninitialized in this function
> 3. main/texcompress_etc.c:1293:12:
> warning: ‘dst’ may be used uninitialized in this function
> 4. main/texcompress_etc.c:1335:12:
> warning: ‘dst’ may be used uninitialized in this function
> 5. main/texcompress_etc.c:1460:12:
> warning: ‘*((void *)+1)’ may be used uninitialized in this function
> 6. main/texcompress_s3tc_tmp.h:262:39:
> warning: ‘pixerrorcolorbest[2]’ may be used uninitialized in this function
> 
> Signed-off-by: Andrii Simiklit 
> ---
>  src/mesa/main/texcompress_etc.c  | 12 ++--
>  src/mesa/main/texcompress_s3tc_tmp.h |  2 +-
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c
> index b39ab33..b192708 100644
> --- a/src/mesa/main/texcompress_etc.c
> +++ b/src/mesa/main/texcompress_etc.c
> @@ -1290,7 +1290,7 @@ fetch_etc2_rgb8(const GLubyte *map,
>  GLint rowStride, GLint i, GLint j, GLfloat *texel)
>  {
> struct etc2_block block;
> -   uint8_t dst[3];
> +   uint8_t dst[3] = { 0 };
> const uint8_t *src;
>  
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
> @@ -1311,7 +1311,7 @@ fetch_etc2_srgb8(const GLubyte *map,
>   GLint rowStride, GLint i, GLint j, GLfloat *texel)
>  {
> struct etc2_block block;
> -   uint8_t dst[3];
> +   uint8_t dst[3] = { 0 };
> const uint8_t *src;
>  
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
> @@ -1332,7 +1332,7 @@ fetch_etc2_rgba8_eac(const GLubyte *map,
>   GLint rowStride, GLint i, GLint j, GLfloat *texel)
>  {
> struct etc2_block block;
> -   uint8_t dst[4];
> +   uint8_t dst[4] = { 0 };
> const uint8_t *src;
>  
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
> @@ -1351,7 +1351,7 @@ fetch_etc2_srgb8_alpha8_eac(const GLubyte *map,
>  GLint rowStride, GLint i, GLint j, GLfloat 
> *texel)
>  {
> struct etc2_block block;
> -   uint8_t dst[4];
> +   uint8_t dst[4] = { 0 };
> const uint8_t *src;
>  
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
> @@ -1457,7 +1457,7 @@ fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte *map,
>  GLfloat *texel)
>  {
> struct etc2_block block;
> -   uint8_t dst[4];
> +   uint8_t dst[4] = { 0 };
> const uint8_t *src;
>  
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
> @@ -1478,7 +1478,7 @@ fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte *map,
>   GLint i, GLint j, GLfloat *texel)
>  {
> struct etc2_block block;
> -   uint8_t dst[4];
> +   uint8_t dst[4] = { 0 };
> const uint8_t *src;
>  
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;

These should be fixed by adding `else unreachable();` at the end of
etc2_rgb8_fetch_texel() (and maybe other places).

> diff --git a/src/mesa/main/texcompress_s3tc_tmp.h 
> b/src/mesa/main/texcompress_s3tc_tmp.h
> index 92316a7..bb1e37c 100644
> --- a/src/mesa/main/texcompress_s3tc_tmp.h
> +++ b/src/mesa/main/texcompress_s3tc_tmp.h
> @@ -194,7 +194,7 @@ static void fancybasecolorsearch( UNUSED GLubyte 
> *blkaddr, GLubyte srccolors[4][
> GLuint pixerror, pixerrorred, pixerrorgreen, pixerrorblue, pixerrorbest;
> GLint colordist, blockerrlin[2][3];
> GLubyte nrcolor[2];
> -   GLint pixerrorcolorbest[3];
> +   GLint pixerrorcolorbest[3] = { 0 };
> GLubyte enc = 0;
> GLubyte cv[4][4];
> GLubyte testcolor[2][3];

This one is a bit too complicated for me so I'll abstain, but
simply initialising it is probably not the right thing to do.

> -- 
> 2.7.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] [PATCH 3/4] i965: avoid 'unused variable' and 'may be used uninitialized' warnings

2018-11-09 Thread Eric Engestrom
On Tuesday, 2018-09-11 15:42:06 +0300, asimiklit.w...@gmail.com wrote:
> From: Andrii Simiklit 
> 
> 1. brw_blorp.c:1502:4: warning:
> ‘num_layers’ may be used uninitialized in this function
> 2. brw_blorp.c:1502:4: warning:
> ‘start_layer’ may be used uninitialized in this function
> 3. brw_blorp.c:1502:4: warning:
> ‘level’ may be used uninitialized in this function
> 4. brw_pipe_control.c:311:34: warning:
> unused variable ‘devinfo’
> 5. brw_program_binary.c:209:19: warning:
> unused variable ‘gen_size’
> 6. brw_program_binary.c:216:19: warning:
> unused variable ‘nir_size’
> 7. intel_mipmap_tree.c:1698:10: warning:
> ‘initial_state’ may be used uninitialized in this function
> 
> Signed-off-by: Andrii Simiklit 
> ---
>  src/mesa/drivers/dri/i965/brw_blorp.c  | 2 +-
>  src/mesa/drivers/dri/i965/brw_pipe_control.c   | 2 +-
>  src/mesa/drivers/dri/i965/brw_program_binary.c | 4 ++--
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c  | 4 ++--
>  4 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c 
> b/src/mesa/drivers/dri/i965/brw_blorp.c
> index ad747e0..a6e0f02 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp.c
> +++ b/src/mesa/drivers/dri/i965/brw_blorp.c
> @@ -1443,7 +1443,7 @@ brw_blorp_clear_depth_stencil(struct brw_context *brw,
> if (x0 == x1 || y0 == y1)
>return;
>  
> -   uint32_t level, start_layer, num_layers;
> +   uint32_t level = 0, start_layer = 0, num_layers = 0;

It would be cleaner to promote the assert() a few lines below into assume():
  assert((mask & BUFFER_BIT_DEPTH) || stencil_mask);

> struct isl_surf isl_tmp[4];
> struct blorp_surf depth_surf, stencil_surf;
>  
> diff --git a/src/mesa/drivers/dri/i965/brw_pipe_control.c 
> b/src/mesa/drivers/dri/i965/brw_pipe_control.c
> index 122ac26..a3f521b 100644
> --- a/src/mesa/drivers/dri/i965/brw_pipe_control.c
> +++ b/src/mesa/drivers/dri/i965/brw_pipe_control.c
> @@ -308,7 +308,7 @@ brw_emit_depth_stall_flushes(struct brw_context *brw)
>  void
>  gen7_emit_vs_workaround_flush(struct brw_context *brw)
>  {
> -   const struct gen_device_info *devinfo = >screen->devinfo;
> +   MAYBE_UNUSED const struct gen_device_info *devinfo = 
> >screen->devinfo;
>  
> assert(devinfo->gen == 7);
> brw_emit_pipe_control_write(brw,
> diff --git a/src/mesa/drivers/dri/i965/brw_program_binary.c 
> b/src/mesa/drivers/dri/i965/brw_program_binary.c
> index db03332..1298d9e 100644
> --- a/src/mesa/drivers/dri/i965/brw_program_binary.c
> +++ b/src/mesa/drivers/dri/i965/brw_program_binary.c
> @@ -206,14 +206,14 @@ brw_program_deserialize_driver_blob(struct gl_context 
> *ctx,
>   break;
>switch ((enum driver_cache_blob_part)part_type) {
>case GEN_PART: {
> - uint32_t gen_size = blob_read_uint32();
> + MAYBE_UNUSED uint32_t gen_size = blob_read_uint32();
>   assert(!reader.overrun &&
>  (uintptr_t)(reader.end - reader.current) > gen_size);
>   deserialize_gen_program(, ctx, prog, stage);
>   break;
>}
>case NIR_PART: {
> - uint32_t nir_size = blob_read_uint32();
> + MAYBE_UNUSED uint32_t nir_size = blob_read_uint32();
>   assert(!reader.overrun &&
>  (uintptr_t)(reader.end - reader.current) > nir_size);
>   const struct nir_shader_compiler_options *options =

R-b on this two MAYBE_UNUSED hunks.

> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 3668135..31e8122 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -1769,8 +1769,8 @@ intel_miptree_alloc_aux(struct brw_context *brw,
> assert(mt->aux_buf == NULL);
>  
> /* Get the aux buf allocation parameters for this miptree. */
> -   enum isl_aux_state initial_state;
> -   uint8_t memset_value;
> +   enum isl_aux_state initial_state = ISL_AUX_STATE_AUX_INVALID;
> +   uint8_t memset_value = 0;

Again, maybe promote assert(aux_surf_ok); to assume(), but this just
would just hide issues if there ever were any added.

> struct isl_surf aux_surf;
> MAYBE_UNUSED bool aux_surf_ok = false;
>  
> -- 
> 2.7.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


[Mesa-dev] [PATCH v2] nir: fix output offset compute for dvec3/4

2018-11-09 Thread Alejandro Piñeiro
The offset compute was working fine for the case of attrib_slots=1,
and updating the offset for the following varying.

But in the case of attrib_slots=2 (so dvec3/4), we are basically
splitting the comp_slots needed in two outputs. In that case we can't
add to the offset the full size of the type.

v2: added assert and some parenthesis to improve readability (Jason)
---
 src/compiler/nir/nir_gather_xfb_info.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_gather_xfb_info.c 
b/src/compiler/nir/nir_gather_xfb_info.c
index f8d4cd833c7..f4f597da4f5 100644
--- a/src/compiler/nir/nir_gather_xfb_info.c
+++ b/src/compiler/nir/nir_gather_xfb_info.c
@@ -81,7 +81,12 @@ add_var_xfb_outputs(nir_xfb_info *xfb,
  output->component_mask = (comp_mask >> (s * 4)) & 0xf;
 
  (*location)++;
- *offset += comp_slots * 4;
+ /* attrib_slots would be only > 1 for doubles. On that case
+  * comp_slots will be a multiple of 2, so the following doesn't need
+  * to use DIV_ROUND_UP or similar
+  */
+ assert(comp_slots % attrib_slots == 0);
+ *offset += (comp_slots / attrib_slots) * 4;
   }
}
 }
-- 
2.14.1

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


Re: [Mesa-dev] [PATCH 2/7] nir: don't assert when xfb_buffer/stride is present but not xfb_offset

2018-11-09 Thread Alejandro Piñeiro
On 08/11/18 22:42, Jason Ekstrand wrote:
> On Thu, Nov 8, 2018 at 7:22 AM Alejandro Piñeiro  > wrote:
>
> In order to allow nir_gather_xfb_info to be used on OpenGL,
> specifically ARB_gl_spirv.
>
> So, from OpenGL 4.6 spec, section 11.1.2.1, "Output Variables":
>
>     "outputs specifying both an *XfbBuffer* and an *Offset* are
>      captured, while outputs not specifying both of these are not
>      captured. Values are captured each time the shader writes to such
>      a decorated object."
>
> This implies that are captured if both are present, and not if one of
> those are lacking. Technically, it doesn't explicitly point that
> having just one or the other is a mistake. In some cases, glslang is
> adding some extra XfbBuffer without XfbOffset around, and mentioning
> that technically that is not a bug (see issue#1526)
>
> And for the case of Vulkan, as the same glslang issue mentions, it is
> not clear if that should be a mistake or not. But even if it is a
> mistake, it is not really needed to be checked on the driver, and we
> can let the validation layers to check that.
> ---
>  src/compiler/nir/nir_gather_xfb_info.c | 23 ---
>  1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/src/compiler/nir/nir_gather_xfb_info.c
> b/src/compiler/nir/nir_gather_xfb_info.c
> index e282bba0081..f5d831c6567 100644
> --- a/src/compiler/nir/nir_gather_xfb_info.c
> +++ b/src/compiler/nir/nir_gather_xfb_info.c
> @@ -109,9 +109,16 @@ nir_gather_xfb_info(const nir_shader *shader,
> void *mem_ctx)
>     nir_foreach_variable(var, >outputs) {
>        if (var->data.explicit_xfb_buffer ||
>            var->data.explicit_xfb_stride) {
> -         assert(var->data.explicit_xfb_buffer &&
> -                var->data.explicit_xfb_stride &&
> -                var->data.explicit_offset);
> +
> +         /* OpenGL points that both are needed to capture the
> output, but
> +          * doesn't direcly imply that it is a mistake having one
> but not the
> +          * other.
> +          */
> +         if (!var->data.explicit_xfb_buffer ||
> +             !var->data.explicit_offset) {
>
>
> Why not just change the check above to "var->data.explicit_xfb_buffer
> && var->data.explicit_offset" and not bother with two checks?

True. Change done locally.

>  
>
> +            continue;
> +         }
> +
>           num_outputs += glsl_count_attribute_slots(var->type, false);
>        }
>     }
> @@ -124,6 +131,16 @@ nir_gather_xfb_info(const nir_shader *shader,
> void *mem_ctx)
>     nir_foreach_variable(var, >outputs) {
>        if (var->data.explicit_xfb_buffer ||
>            var->data.explicit_xfb_stride) {
> +
> +         /* OpenGL points that both are needed to capture the
> output, but
> +          * doesn't direcly imply that it is a mistake having one
> but not the
> +          * other.
> +          */
> +         if (!var->data.explicit_xfb_buffer ||
> +             !var->data.explicit_offset) {
>
>
> Same here.
>  
>
> +            continue;
> +         }
> +
>           unsigned location = var->data.location;
>           unsigned offset = var->data.offset;
>           add_var_xfb_outputs(xfb, var, , ,
> var->type);
> -- 
> 2.14.1
>

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


Re: [Mesa-dev] [PATCH 2/4] compiler: avoid 'unused variable' and 'may be used uninitialized' warnings

2018-11-09 Thread Eric Engestrom
On Tuesday, 2018-09-11 15:42:05 +0300, asimiklit.w...@gmail.com wrote:
> From: Andrii Simiklit 
> 
> 1. nir/nir_lower_vars_to_ssa.c:691:21: warning:
>unused variable ‘var’
>nir_variable *var = path->path[0]->var;
> 
> 2. nir_types.cpp:558:31: warning:
> ‘elem_align’ may be used uninitialized in this function
>unsigned elem_size, elem_align;
>nir_types.cpp:558:20: warning:
>‘elem_size’ may be used uninitialized in this function
>unsigned elem_size, elem_align;
> 
> Signed-off-by: Andrii Simiklit 
> ---
>  src/compiler/nir/nir_lower_vars_to_ssa.c | 2 +-
>  src/compiler/nir_types.cpp   | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c 
> b/src/compiler/nir/nir_lower_vars_to_ssa.c
> index cd679be..96de261 100644
> --- a/src/compiler/nir/nir_lower_vars_to_ssa.c
> +++ b/src/compiler/nir/nir_lower_vars_to_ssa.c
> @@ -688,7 +688,7 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl)
>nir_deref_path *path = >path;
>  
>assert(path->path[0]->deref_type == nir_deref_type_var);
> -  nir_variable *var = path->path[0]->var;
> +  MAYBE_UNUSED nir_variable *var = path->path[0]->var;
>  
>/* We don't build deref nodes for non-local variables */
>assert(var->data.mode == nir_var_local);

Sure, or you could simply remove the single-use extra local variable and
just fold it into the assert :)

> diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
> index d24f094..d39d87b 100644
> --- a/src/compiler/nir_types.cpp
> +++ b/src/compiler/nir_types.cpp
> @@ -542,7 +542,7 @@ glsl_get_natural_size_align_bytes(const struct glsl_type 
> *type,
> }
>  
> case GLSL_TYPE_ARRAY: {
> -  unsigned elem_size, elem_align;
> +  unsigned elem_size = 0, elem_align = 0;

Not really keen on these ones; it looks like your compiler is ignoring the
unreachable() in glsl_get_natural_size_align_bytes() and mis-computing the
possible code-paths, resulting in it wrongly printing a warning.

I'd prefer to keep these two hunks as is, so that real issue in
glsl_get_natural_size_align_bytes() would get flagged appropriately.

>glsl_get_natural_size_align_bytes(type->fields.array,
>  _size, _align);
>*align = elem_align;
> @@ -554,7 +554,7 @@ glsl_get_natural_size_align_bytes(const struct glsl_type 
> *type,
>*size = 0;
>*align = 0;
>for (unsigned i = 0; i < type->length; i++) {
> - unsigned elem_size, elem_align;
> + unsigned elem_size = 0, elem_align = 0;
>   glsl_get_natural_size_align_bytes(type->fields.structure[i].type,
> _size, _align);
>   *align = MAX2(*align, elem_align);
> -- 
> 2.7.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] [PATCH 1/4] intel/tools: avoid 'ignoring return value' and 'unused variable' warnings

2018-11-09 Thread Eric Engestrom
On Tuesday, 2018-09-11 15:42:04 +0300, asimiklit.w...@gmail.com wrote:
> From: Andrii Simiklit 
> 
> 1. tools/i965_disasm.c:58:4: warning:
> ignoring return value of ‘fread’,
> declared with attribute warn_unused_result
> fread(assembly, *end, 1, fp);
> 
> 2. tools/aub_read.c:271:31: warning: unused variable ‘end’
> const uint32_t *p = data, *end = data + data_len, *next;
> 
> 3. tools/aub_mem.c:292:13: warning: unused variable ‘res’
>void *res = mmap((uint8_t *)bo.map + map_offset, 4096, PROT_READ,
>tools/aub_mem.c:357:13: warning: unused variable ‘res’
>void *res = mmap((uint8_t *)bo.map + (page - bo.addr), 4096, PROT_READ,
> 
> Signed-off-by: Andrii Simiklit 
> ---
>  src/intel/tools/aub_mem.c | 10 ++
>  src/intel/tools/aub_read.c|  2 +-
>  src/intel/tools/i965_disasm.c |  3 ++-
>  3 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/src/intel/tools/aub_mem.c b/src/intel/tools/aub_mem.c
> index 58b51b7..98e1421 100644
> --- a/src/intel/tools/aub_mem.c
> +++ b/src/intel/tools/aub_mem.c
> @@ -289,8 +289,9 @@ aub_mem_get_ggtt_bo(void *_mem, uint64_t address)
>   continue;
>  
>uint32_t map_offset = i->virt_addr - address;
> -  void *res = mmap((uint8_t *)bo.map + map_offset, 4096, PROT_READ,
> -   MAP_SHARED | MAP_FIXED, mem->mem_fd, 
> phys_mem->fd_offset);
> +  MAYBE_UNUSED void *res =
> +mmap((uint8_t *)bo.map + map_offset, 4096, PROT_READ,
> +  MAP_SHARED | MAP_FIXED, mem->mem_fd, phys_mem->fd_offset);
>assert(res != MAP_FAILED);
> }
>  
> @@ -354,8 +355,9 @@ aub_mem_get_ppgtt_bo(void *_mem, uint64_t address)
> for (uint64_t page = address; page < end; page += 4096) {
>struct phys_mem *phys_mem = ppgtt_walk(mem, mem->pml4, page);
>  
> -  void *res = mmap((uint8_t *)bo.map + (page - bo.addr), 4096, PROT_READ,
> -   MAP_SHARED | MAP_FIXED, mem->mem_fd, 
> phys_mem->fd_offset);
> +  MAYBE_UNUSED void *res =
> +mmap((uint8_t *)bo.map + (page - bo.addr), 4096, PROT_READ,
> +  MAP_SHARED | MAP_FIXED, mem->mem_fd, phys_mem->fd_offset);
>assert(res != MAP_FAILED);
> }
>  

R-b on the above

> diff --git a/src/intel/tools/aub_read.c b/src/intel/tools/aub_read.c
> index 5b704e8..0a1f84a 100644
> --- a/src/intel/tools/aub_read.c
> +++ b/src/intel/tools/aub_read.c
> @@ -268,7 +268,7 @@ handle_memtrace_mem_write(struct aub_read *read, const 
> uint32_t *p)
>  int
>  aub_read_command(struct aub_read *read, const void *data, uint32_t data_len)
>  {
> -   const uint32_t *p = data, *end = data + data_len, *next;
> +   MAYBE_UNUSED const uint32_t *p = data, *end = data + data_len, *next;

You're flagging all of them as MAYBE_UNUSED; please split out the one
variable for which it applies?

> uint32_t h, header_length, bias;
>  
> assert(data_len >= 4);
> diff --git a/src/intel/tools/i965_disasm.c b/src/intel/tools/i965_disasm.c
> index 73a6760..e207def 100644
> --- a/src/intel/tools/i965_disasm.c
> +++ b/src/intel/tools/i965_disasm.c
> @@ -55,7 +55,8 @@ i965_disasm_read_binary(FILE *fp, size_t *end)
> if (assembly == NULL)
>return NULL;
>  
> -   fread(assembly, *end, 1, fp);
> +   MAYBE_UNUSED size_t size = fread(assembly, *end, 1, fp);
> +   assert((size == *end) && "error: unable to read all elements!");

Please split this out in a separate patch, and I don't think this
`size == *end` is right

From `man 3 fread`:
> On success, fread() and fwrite() return the number of items read or
> written. This number equals the number of bytes transferred only when
> size is 1.

but here, size is `*end` and nmemb is `1`, so I would expect fread to
return 1 on success and 0 on failure.
Have you tested this? What value did you see?

You can test the complete EOF failure path by adding this just before
fread():
  fseek(fp, 0, SEEK_END);

And the more insidious "just a bit too short" failure path with:
  fseek(fp, 1, SEEK_CUR);

> fclose(fp);
>  
> return assembly;
> -- 
> 2.7.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] [PATCH 6/7] RFC: nir/xfb_info: arrays of basic types adds just one varying

2018-11-09 Thread Alejandro Piñeiro
On 08/11/18 23:14, Jason Ekstrand wrote:
> On Thu, Nov 8, 2018 at 7:22 AM Alejandro Piñeiro  > wrote:
>
> On OpenGL, a array of a simple type adds just one varying. So
> gl_transform_feedback_varying_info struct defined at mtypes.h includes
> the parameters Type (base_type) and Size (number of elements).
>
> This commit checks this when the recursive add_var_xfb_outputs call
> handles arrays, to ensure that just one is addded.
>
> RFC: Until this point, all changes were reasonable, but this change is
> (imho) ugly. My idea was introducing as less as possible changes on
> the code, specially on its logic/flow. But this commit is almost a
> hack. The ideal solution would be to change the focus of the recursive
> function, focusing on varyings, and at each varying, recursively add
> outputs. But that seems like an overkill for a pass that was
> originally intended for consumers only caring about the outputs. So
> perhaps ARB_gl_spirv should keep their own gathering pass, with
> vayings and outputs, and let this one untouched for those that only
> care on outputs.
> ---
>  src/compiler/nir/nir_gather_xfb_info.c | 52
> --
>  1 file changed, 43 insertions(+), 9 deletions(-)
>
> diff --git a/src/compiler/nir/nir_gather_xfb_info.c
> b/src/compiler/nir/nir_gather_xfb_info.c
> index 948b802a815..cb0e2724cab 100644
> --- a/src/compiler/nir/nir_gather_xfb_info.c
> +++ b/src/compiler/nir/nir_gather_xfb_info.c
> @@ -36,23 +36,59 @@ nir_gather_xfb_info_create(void *mem_ctx,
> uint16_t output_count, uint16_t varyin
>     return xfb;
>  }
>
> +static bool
> +glsl_type_is_leaf(const struct glsl_type *type)
> +{
> +   if (glsl_type_is_struct(type) ||
> +       (glsl_type_is_array(type) &&
> +        (glsl_type_is_array(glsl_get_array_element(type)) ||
> +         glsl_type_is_struct(glsl_get_array_element(type) {
>
>
> I'm trying to understand exactly what this means.  From what you wrote
> here it looks like the following are all one varying:
>
> float var[3];
> vec2 var[3];
> mat4 var[3];

Yes, GLSL returns one varying per each one (Size 3).

>
> but the following are not
>
> struct S {
>    float f;
>    vec4 v;
> };
>
> S var[3];

> float var[3][5];

I guess that you are asking for thos two cases because this code is  not
handling it properly. You are right. For the array of structs, our code
is crashing. For the array of arrays, it is enumerating four varyings.
One with three GL_FLOAT components, and three with five GL_FLOAT
components, instead of just three varyings with five components. In my
defense, I already mentioned that it was wip code, but preferred to
agree on the way to go before keep working on it.

For the GLSL case, the array of struct returns 6 varyings. And funny
thing, for the array of arrays, GLSL is handling the situation even
worse. It returns the following link error: "Failed to link: error:
Transform feedback varying var[0] undeclared." Just a quick skim on the
spec, I didn't see anything preventing using aoa with transform feedback
varyings, so I guess that this is a bug due all the rules OpenGL has in
relation with variable names.

>
> Is this correct?

Yes. FWIW, I will give you another two examples, from the tests Im using
as reference.

## example 1 ##
  struct Array {
    float x2_out;
   };
   struct AoA {
 Array x2_Array[2];
   };
   struct S {
 float x1_out;
     AoA x2_AoA[2];
 float x3_out;
    };
   layout(xfb_offset = 0) out S s1;
   layout(xfb_offset = 0, xfb_buffer = 2) out struct S2 {
 float y1_out;
 vec4 y2_out;
   } s2;

GLSL returns the following varyings (on ARB_gl_spirv we target to get
the same, although without the names)
       NumVarying=8, (Offset, Type, BufferIndex, Size, Name)
            0:( 0,    GL_FLOAT,  0,  1, s1.x1_out)
            1:( 4,    GL_FLOAT,  0,  1, s1.x2_AoA[0].x2_Array[0].x2_out)
            2:( 8,    GL_FLOAT,  0,  1, s1.x2_AoA[0].x2_Array[1].x2_out)
            3:(12,    GL_FLOAT,  0,  1, s1.x2_AoA[1].x2_Array[0].x2_out)
            4:(16,    GL_FLOAT,  0,  1, s1.x2_AoA[1].x2_Array[1].x2_out)
            5:(20,    GL_FLOAT,  0,  1, s1.x3_out)
            6:( 0,    GL_FLOAT,  1,  1, s2.y1_out)
            7:( 4,   GL_FLOAT_VEC4,  1,  1, s2.y2_out)

## example 2 ##
layout(xfb_offset = 0) out float x1_out;
layout(xfb_offset = 4) out float x2_out[2];
layout(xfb_offset = 12) out vec3 x3_out;
layout(xfb_buffer = 2) out;
layout(xfb_offset = 0, xfb_buffer = 2) out float y1_out;
layout(xfb_offset = 4) out vec4 y2_out

GLSL returns the following varyings (on ARB_gl_spirv we target to get
the same, although without the names)
    NumVarying=5, (Offset, Type, BufferIndex, Size, Name)
            0:( 0,    GL_FLOAT,  0,  1, x1_out)
            1:( 4,    GL_FLOAT,  0,  2, x2_out)
            2:(12,   

Re: [Mesa-dev] [PATCH v2 0/4] i965: add support for sampling from AYUV images

2018-11-09 Thread Eric Engestrom
On Friday, 2018-11-09 10:55:47 +, Lionel Landwerlin wrote:
> Hi all,
> 
> This v2 just splits the nir commit in 2 for readability and adds an
> entry into the android backend.
> 
> Many thanks to Tapani for the review.
> 
> Cheers,
> 
> Lionel Landwerlin (4):
>   nir/lower_tex: add alpha channel parameter for yuv lowering
>   nir/lower_tex: Add AYUV lowering support
>   dri: add AYUV format
>   i965: add support for sampling from AYUV

Patch 1, 3 & 4 are:
Reviewed-by: Eric Engestrom 

Patch 2 is:
Acked-by: Eric Engestrom 

> 
>  include/GL/internal/dri_interface.h  |  2 ++
>  src/compiler/nir/nir.h   |  1 +
>  src/compiler/nir/nir_lower_tex.c | 36 
>  src/egl/drivers/dri2/egl_dri2.c  |  1 +
>  src/egl/drivers/dri2/platform_android.c  |  1 +
>  src/intel/compiler/brw_compiler.h|  1 +
>  src/intel/compiler/brw_nir.c |  1 +
>  src/mesa/drivers/dri/i965/brw_wm.c   |  6 
>  src/mesa/drivers/dri/i965/intel_screen.c |  3 ++
>  9 files changed, 46 insertions(+), 6 deletions(-)
> 
> --
> 2.19.1
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH] mapi: avoid text relocation in x86 tsd stubs

2018-11-09 Thread Jonathan Gray
On Thu, Nov 08, 2018 at 03:54:20PM +, Emil Velikov wrote:
> On Fri, 2 Nov 2018 at 00:02, Jonathan Gray  wrote:
> >
> > On Thu, Nov 01, 2018 at 12:26:34PM -0700, Ian Romanick wrote:
> > > On 10/31/2018 09:08 PM, Jonathan Gray wrote:
> > > > Make similiar changes to libglvnd to avoid a text relocation in
> > > > x86 tsd stubs fixing the build with lld.
> > > >
> > > > Signed-off-by: Jonathan Gray 
> > > > Cc: mesa-sta...@lists.freedesktop.org
> > > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108541
> > > > ---
> > > >  src/mapi/entry_x86_tsd.h | 14 +-
> > > >  1 file changed, 9 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/src/mapi/entry_x86_tsd.h b/src/mapi/entry_x86_tsd.h
> > > > index 0c28c8ff068..e08a02f3db2 100644
> > > > --- a/src/mapi/entry_x86_tsd.h
> > > > +++ b/src/mapi/entry_x86_tsd.h
> > > > @@ -31,7 +31,7 @@
> > > >  #define HIDDEN
> > > >  #endif
> > > >
> > > > -#define X86_ENTRY_SIZE 32
> > > > +#define X86_ENTRY_SIZE 64
> > > >
> > > >  __asm__(".text\n"
> > > >  ".balign 32\n"
> > > > @@ -44,12 +44,16 @@ __asm__(".text\n"
> > > > func ":"
> > > >
> > > >  #define STUB_ASM_CODE(slot) \
> > > > -   "movl " ENTRY_CURRENT_TABLE ", %eax\n\t" \
> > > > +   "call 1f\n\t"\
> > > > +   "1:\n\t" \
> > > > +   "popl %eax\n\t"  \
> > > > +   "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" \
> > > > +   "movl " ENTRY_CURRENT_TABLE "@GOT(%eax), %eax\n\t" \
> > > > +   "mov (%eax), %eax\n\t"   \
> > > > "testl %eax, %eax\n\t"   \
> > > > -   "je 1f\n\t"  \
> > > > -   "jmp *(4 * " slot ")(%eax)\n"\
> > > > +   "jne 1f\n\t" \
> > > > +   "call " ENTRY_CURRENT_TABLE_GET "@PLT\n\t" \
> > > > "1:\n\t" \
> > > > -   "call " ENTRY_CURRENT_TABLE_GET "\n\t" \
> > > > "jmp *(4 * " slot ")(%eax)"
> > >
> > > After this change, the code is:
> > >
> > > #define STUB_ASM_CODE(slot) \
> > >"call 1f\n\t"\
> > >"1:\n\t" \
> > >"popl %eax\n\t"  \
> > >"addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" \
> > >"movl " ENTRY_CURRENT_TABLE "@GOT(%eax), %eax\n\t" \
> > >"mov (%eax), %eax\n\t"   \
> > >"testl %eax, %eax\n\t"   \
> > >"jne 1f\n\t" \
> > >"call " ENTRY_CURRENT_TABLE_GET "@PLT\n\t" \
> > >"1:\n\t" \
> > >"jmp *(4 * " slot ")(%eax)"
> > >
> > > So there's going to be two labels "1:".  Does that even assemble?
> >
> > Yes, the call/jmp is always forward as it is '1f'.
> > This also runs glxinfo, glxgears etc on a pentium m running OpenBSD/i386.
> >
> > https://github.com/NVIDIA/libglvnd/blob/master/src/GLdispatch/vnd-glapi/entry_x86_tsd.c#L58
> >
> > libglvnd has two labels like this as well, the ebx use there isn't needed.
> 
> Hi all, did this get stuck or it's superseded/obsolete?

This is still the latest version of the patch.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] freedreno/drm: Move drm_msm.h to include/drm-uapi

2018-11-09 Thread Eric Engestrom
On Thursday, 2018-11-08 13:31:27 -0800, Chad Versace wrote:
> So the future Vulkan driver can share it.

:) :) :)

> 
> I tested Meson, but not Autotools nor Android.mk.

Not sure how useful this is then, but the meson side of this patch is:
Reviewed-by: Eric Engestrom 

and the rest looks reasonable enough :)

> 
> Signed-off-by: Chad Versace 
> ---
>  Makefile.am| 1 +
>  .../drivers/freedreno/drm => include/drm-uapi}/msm_drm.h   | 0
>  src/gallium/drivers/freedreno/Android.mk   | 1 +
>  src/gallium/drivers/freedreno/Makefile.am  | 1 +
>  src/gallium/drivers/freedreno/Makefile.sources | 1 -
>  src/gallium/drivers/freedreno/meson.build  | 3 +--
>  6 files changed, 4 insertions(+), 3 deletions(-)
>  rename {src/gallium/drivers/freedreno/drm => include/drm-uapi}/msm_drm.h 
> (100%)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 9e27db046e5..99234a4af58 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -76,6 +76,7 @@ noinst_HEADERS = \
>   include/drm-uapi/drm_fourcc.h \
>   include/drm-uapi/drm_mode.h \
>   include/drm-uapi/i915_drm.h \
> + include/drm-uapi/msm_drm.h \
>   include/drm-uapi/tegra_drm.h \
>   include/drm-uapi/v3d_drm.h \
>   include/drm-uapi/vc4_drm.h \
> diff --git a/src/gallium/drivers/freedreno/drm/msm_drm.h 
> b/include/drm-uapi/msm_drm.h
> similarity index 100%
> rename from src/gallium/drivers/freedreno/drm/msm_drm.h
> rename to include/drm-uapi/msm_drm.h
> diff --git a/src/gallium/drivers/freedreno/Android.mk 
> b/src/gallium/drivers/freedreno/Android.mk
> index 9c9d0707ba9..9cf036d0472 100644
> --- a/src/gallium/drivers/freedreno/Android.mk
> +++ b/src/gallium/drivers/freedreno/Android.mk
> @@ -39,6 +39,7 @@ LOCAL_SRC_FILES := \
>  #-Wno-packed-bitfield-compat
>  
>  LOCAL_C_INCLUDES := \
> + $(MESA_TOP)/include/drm-uapi \
>   $(LOCAL_PATH)/ir3
>  
>  LOCAL_GENERATED_SOURCES := $(MESA_GEN_NIR_H)
> diff --git a/src/gallium/drivers/freedreno/Makefile.am 
> b/src/gallium/drivers/freedreno/Makefile.am
> index 5690b6ec884..a6b336ec720 100644
> --- a/src/gallium/drivers/freedreno/Makefile.am
> +++ b/src/gallium/drivers/freedreno/Makefile.am
> @@ -3,6 +3,7 @@ include $(top_srcdir)/src/gallium/Automake.inc
>  
>  AM_CFLAGS = \
>   -Wno-packed-bitfield-compat \
> + -I$(top_srcdir)/include/drm-uapi \
>   -I$(top_srcdir)/src/gallium/drivers/freedreno/ir3 \
>   -I$(top_builddir)/src/compiler/nir \
>   -I$(top_srcdir)/src/compiler/nir \
> diff --git a/src/gallium/drivers/freedreno/Makefile.sources 
> b/src/gallium/drivers/freedreno/Makefile.sources
> index 8b4d61c9884..a03f55d53e6 100644
> --- a/src/gallium/drivers/freedreno/Makefile.sources
> +++ b/src/gallium/drivers/freedreno/Makefile.sources
> @@ -51,7 +51,6 @@ drm_SOURCES := \
>   drm/freedreno_ringbuffer.h \
>   drm/msm_bo.c \
>   drm/msm_device.c \
> - drm/msm_drm.h \
>   drm/msm_pipe.c \
>   drm/msm_priv.h \
>   drm/msm_ringbuffer.c \
> diff --git a/src/gallium/drivers/freedreno/meson.build 
> b/src/gallium/drivers/freedreno/meson.build
> index 4024d2fa99f..122eb53b797 100644
> --- a/src/gallium/drivers/freedreno/meson.build
> +++ b/src/gallium/drivers/freedreno/meson.build
> @@ -81,7 +81,6 @@ files_libfreedreno = files(
>'drm/freedreno_ringbuffer.h',
>'drm/msm_bo.c',
>'drm/msm_device.c',
> -  'drm/msm_drm.h',
>'drm/msm_pipe.c',
>'drm/msm_priv.h',
>'drm/msm_ringbuffer.c',
> @@ -254,7 +253,7 @@ files_libfreedreno = files(
>  )
>  
>  freedreno_includes = [
> -  inc_src, inc_include, inc_gallium, inc_gallium_aux,
> +  inc_src, inc_include, inc_drm_uapi, inc_gallium, inc_gallium_aux,
>include_directories('ir3')
>  ]
>  
> -- 
> 2.19.1.930.g4563a0d9d0-goog
> 
> ___
> 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] [ANNOUNCE] mesa 18.3.0-rc2

2018-11-09 Thread Emil Velikov
The second release candidate for Mesa 18.3.0 is now available.

Dave Airlie (2):
  radv: apply xfb buffer offset at buffer binding time not later. (v2)
  radv: fix begin/end transform feedback with 0 counter buffers.

Dylan Baker (1):
  meson: link gallium nine with pthreads

Emil Velikov (2):
  docs: document the staging branch and add reference to it
  Update version to 18.3.0-rc2

Eric Engestrom (2):
  wsi/wayland: use proper VkResult type
  wsi/wayland: only finish() a successfully init()ed display

Erik Faye-Lund (1):
  glsl: do not allow implicit casts of unsized array initializers

Gert Wollny (1):
  virgl/vtest-winsys: Use virgl version of bind flags

Lionel Landwerlin (2):
  intel/decoders: fix instruction base address parsing
  anv/android: mark gralloc allocated BOs as external

Marek Olšák (1):
  st/va: fix incorrect use of resource_destroy

Mauro Rossi (2):
  android: gallium/auxiliary: add include to get u_debug.h header
  android: radv: add libmesa_git_sha1 static dependency

Olivier Fourdan (1):
  wayland/egl: Resize EGL surface on update buffer for swrast

Samuel Pitoiset (2):
  radv: add missing TFB queries support to CmdCopyQueryPoolsResults()
  radv: disable conditional rendering for vkCmdCopyQueryPoolResults()

Sergii Romantsov (1):
  autotools: library-dependency when no sse and 32-bit

Timothy Arceri (3):
  nir: allow propagation of if evaluation for bcsel
  nir: fix condition propagation when src has a swizzle
  ac/nir_to_llvm: fix b2f for f64

Vinson Lee (1):
  r600/sb: Fix constant logical operand in assert.

git tag: mesa-18.3.0-rc2

https://mesa.freedesktop.org/archive/mesa-18.3.0-rc2.tar.gz
MD5:  caa27465187d44d66af5109a06f804eb  mesa-18.3.0-rc2.tar.gz
SHA1: 37764d63857e082e61d5a8c1f4923ef80935  mesa-18.3.0-rc2.tar.gz
SHA256: 3500d9067e736a4425845988172cb602d399a91d3686f02da11193b6b15b
 mesa-18.3.0-rc2.tar.gz
SHA512: 
c03c4c1c6ac09326897d0f4148b001c26aeae5e6e30a6add61ab462afac28e3ac2a2a2803ae90da35cf950a7102dfefbbdd64928dd691b2728893d43a79a966e
 mesa-18.3.0-rc2.tar.gz
PGP:  https://mesa.freedesktop.org/archive/mesa-18.3.0-rc2.tar.gz.sig

https://mesa.freedesktop.org/archive/mesa-18.3.0-rc2.tar.xz
MD5:  ff064ec87413b7e84740213cbf7ddfb4  mesa-18.3.0-rc2.tar.xz
SHA1: 3c41c8d6c61da2317c88a7545ff94b63f2435801  mesa-18.3.0-rc2.tar.xz
SHA256: b6fe79ce3aaabc7b7b52f83d01dae746e2d8c9665c121ac2adee8f4b7397bc64
 mesa-18.3.0-rc2.tar.xz
SHA512: 
af12adafbeac33f1ee527a0c7f61c24251912b5ee0a9e55d46f0133e6897b0ca91486ae2b3236159e43addef4de474a7b71ec3932083e68b9e94e480ee91c9fa
 mesa-18.3.0-rc2.tar.xz
PGP:  https://mesa.freedesktop.org/archive/mesa-18.3.0-rc2.tar.xz.sig
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Fix -Wswitch on INTEL_COPY_STREAMING_LOAD

2018-11-09 Thread Eric Engestrom
On Thursday, 2018-11-08 12:55:35 -0800, Chad Versace wrote:
> The warning is emitted when building without INLINE_SSE41.

I sent https://patchwork.freedesktop.org/patch/259015/ a couple of
weeks ago, but your patch gives a more specific error message, so:
Reviewed-by: Eric Engestrom 

> ---
>  src/mesa/drivers/dri/i965/intel_tiled_memcpy.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c 
> b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c
> index 836f83d4a43..f9cc020d338 100644
> --- a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c
> +++ b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c
> @@ -599,9 +599,11 @@ choose_copy_function(mem_copy_fn_type copy_type)
>return memcpy;
> case INTEL_COPY_RGBA8:
>return rgba8_copy;
> -#if defined(INLINE_SSE41)
> case INTEL_COPY_STREAMING_LOAD:
> +#if defined(INLINE_SSE41)
>return _memcpy_streaming_load;
> +#else
> +  unreachable("INTEL_COPY_STREAMING_LOAD requires sse4.1");
>  #endif
> case INTEL_COPY_INVALID:
>unreachable("invalid copy_type");
> -- 
> 2.19.1.930.g4563a0d9d0-goog
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] gbm: Introduce a helper function for printing GBM format names.

2018-11-09 Thread Eric Engestrom
On Thursday, 2018-11-08 10:01:37 -0800, Eric Anholt wrote:
> This requires that the caller make a little (stack) allocation to store
> the string.
> 
> v2: Use gbm_format_canonicalize (suggested by Daniel)

Yep, fixes it. Series is
Reviewed-by: Eric Engestrom 

> ---
>  src/gbm/main/gbm.c | 20 
>  src/gbm/main/gbm.h |  6 ++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
> index d301661b48ee..2e2014205cb8 100644
> --- a/src/gbm/main/gbm.c
> +++ b/src/gbm/main/gbm.c
> @@ -711,3 +711,23 @@ gbm_format_canonicalize(uint32_t gbm_format)
>return gbm_format;
> }
>  }
> +
> +/**
> + * Returns a string representing the fourcc format name.
> + *
> + * \param desc Caller-provided storage for the format name string.
> + * \return String containing the fourcc of the format.
> + */
> +GBM_EXPORT char *
> +gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc)
> +{
> +   gbm_format = gbm_format_canonicalize(gbm_format);
> +
> +   desc->name[0] = gbm_format;
> +   desc->name[1] = gbm_format >> 8;
> +   desc->name[2] = gbm_format >> 16;
> +   desc->name[3] = gbm_format >> 24;
> +   desc->name[4] = 0;
> +
> +   return desc->name;
> +}
> diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
> index e95f9e34960b..9b5288710a5b 100644
> --- a/src/gbm/main/gbm.h
> +++ b/src/gbm/main/gbm.h
> @@ -190,6 +190,9 @@ enum gbm_bo_format {
>  #define GBM_FORMAT_YUV444__gbm_fourcc_code('Y', 'U', '2', '4') /* 
> non-subsampled Cb (1) and Cr (2) planes */
>  #define GBM_FORMAT_YVU444__gbm_fourcc_code('Y', 'V', '2', '4') /* 
> non-subsampled Cr (1) and Cb (2) planes */
>  
> +struct gbm_format_name_desc {
> +   char name[5];
> +};
>  
>  /**
>   * Flags to indicate the intended use for the buffer - these are passed into
> @@ -399,6 +402,9 @@ gbm_surface_has_free_buffers(struct gbm_surface *surface);
>  void
>  gbm_surface_destroy(struct gbm_surface *surface);
>  
> +char *
> +gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> -- 
> 2.19.1
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 3/4] dri: add AYUV format

2018-11-09 Thread Lionel Landwerlin
v2: Add a AYUV entry android in the android backend (Tapani)

Signed-off-by: Lionel Landwerlin 
Reviewed-by: Tapani Pälli 
---
 include/GL/internal/dri_interface.h | 2 ++
 src/egl/drivers/dri2/egl_dri2.c | 1 +
 src/egl/drivers/dri2/platform_android.c | 1 +
 3 files changed, 4 insertions(+)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index 6f9c2c8b8cf..072f3799eac 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1327,6 +1327,7 @@ struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_FOURCC_NV160x3631564e
 #define __DRI_IMAGE_FOURCC_YUYV0x56595559
 #define __DRI_IMAGE_FOURCC_UYVY0x59565955
+#define __DRI_IMAGE_FOURCC_AYUV0x56555941
 
 #define __DRI_IMAGE_FOURCC_YVU410  0x39555659
 #define __DRI_IMAGE_FOURCC_YVU411  0x31315659
@@ -1353,6 +1354,7 @@ struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_COMPONENTS_Y_UV0x3004
 #define __DRI_IMAGE_COMPONENTS_Y_XUXV  0x3005
 #define __DRI_IMAGE_COMPONENTS_Y_UXVX  0x3008
+#define __DRI_IMAGE_COMPONENTS_AYUV0x3009
 #define __DRI_IMAGE_COMPONENTS_R   0x3006
 #define __DRI_IMAGE_COMPONENTS_RG  0x3007
 
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 87e1a704c6e..3b63aebbf9a 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2278,6 +2278,7 @@ dri2_num_fourcc_format_planes(EGLint format)
case DRM_FORMAT_YVYU:
case DRM_FORMAT_UYVY:
case DRM_FORMAT_VYUY:
+   case DRM_FORMAT_AYUV:
   return 1;
 
case DRM_FORMAT_NV12:
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 1e93ab4d4d2..b3ef5589611 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -72,6 +72,7 @@ static const struct droid_yuv_format droid_yuv_formats[] = {
{ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,   0, 2, __DRI_IMAGE_FOURCC_NV12 
},
{ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,   0, 1, 
__DRI_IMAGE_FOURCC_YUV420 },
{ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,   1, 1, 
__DRI_IMAGE_FOURCC_YVU420 },
+   { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,   1, 1, __DRI_IMAGE_FOURCC_AYUV 
},
 };
 
 static int
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 2/4] nir/lower_tex: Add AYUV lowering support

2018-11-09 Thread Lionel Landwerlin
Byte ordering is :

0: V
1: U
2: Y
3: A

v2: Split refactoring of alpha channel (Lionel)

Signed-off-by: Lionel Landwerlin 
Reviewed-by: Tapani Pälli 
---
 src/compiler/nir/nir.h   |  1 +
 src/compiler/nir/nir_lower_tex.c | 19 +++
 2 files changed, 20 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f4f6b106505..2a843de8ae1 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2904,6 +2904,7 @@ typedef struct nir_lower_tex_options {
unsigned lower_y_u_v_external;
unsigned lower_yx_xuxv_external;
unsigned lower_xy_uxvx_external;
+   unsigned lower_ayuv_external;
 
/**
 * To emulate certain texture wrap modes, this can be used
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index c16a32f54e8..e10d4ea62f6 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -348,6 +348,20 @@ lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex)
  nir_imm_float(b, 1.0f));
 }
 
+static void
+lower_ayuv_external(nir_builder *b, nir_tex_instr *tex)
+{
+  b->cursor = nir_after_instr(>instr);
+
+  nir_ssa_def *ayuv = sample_plane(b, tex, 0);
+
+  convert_yuv_to_rgb(b, tex,
+ nir_channel(b, ayuv, 2),
+ nir_channel(b, ayuv, 1),
+ nir_channel(b, ayuv, 0),
+ nir_channel(b, ayuv, 3));
+}
+
 /*
  * Emits a textureLod operation used to replace an existing
  * textureGrad instruction.
@@ -793,6 +807,11 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
  progress = true;
   }
 
+  if ((1 << tex->texture_index) & options->lower_ayuv_external) {
+ lower_ayuv_external(b, tex);
+ progress = true;
+  }
+
   if (sat_mask) {
  saturate_src(b, tex, sat_mask);
  progress = true;
-- 
2.19.1

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


  1   2   >