Re: [Mesa-dev] [PATCH v2 1/3] i965/miptree: Enforce that height == 1 for 1-D array textures

2016-07-20 Thread Iago Toral
All 4 patches are:
Reviewed-by: Iago Toral Quiroga 

On Tue, 2016-07-19 at 08:26 -0700, Jason Ekstrand wrote:
> The GL API and mesa internals do this differently than we do.  In GL,
> there
> is no depth parameter for 1-D arrays and height is used.  In the i965
> miptree code we do the sane thing and make height == 1 and use depth
> for
> number of slices.  This makes for a mismatch every time we create a
> 1-D
> array texture from GL.  Instead of actually solving this problem, we
> just
> said "1-D is hard, let's make sure it works no matter which way we
> pass the
> parameters" and called it a day.
> 
> This commit fixes the one GL -> i965 transition point where we
> weren't
> already handling 1-D array textures to do the right thing and then
> replaces
> the magic fixup code with an assert that you're doing the right
> thing.
> 
> Signed-off-by: Jason Ekstrand 
> Cc: "12.0 11.2 11.1" 
> ---
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 22 +++
> ---
>  src/mesa/drivers/dri/i965/intel_tex.c |  2 ++
>  2 files changed, 5 insertions(+), 19 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index c705c98..10158fe 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -364,25 +364,8 @@ intel_miptree_create_layout(struct brw_context
> *brw,
> _mesa_get_format_name(format),
> first_level, last_level, depth0, mt);
>  
> -   if (target == GL_TEXTURE_1D_ARRAY) {
> -  /* For a 1D Array texture the OpenGL API will treat the
> height0
> -   * parameter as the number of array slices. For Intel
> hardware, we treat
> -   * the 1D array as a 2D Array with a height of 1.
> -   *
> -   * So, when we first come through this path to create a 1D
> Array
> -   * texture, height0 stores the number of slices, and depth0 is
> 1. In
> -   * this case, we want to swap height0 and depth0.
> -   *
> -   * Since some miptrees will be created based on the base
> miptree, we may
> -   * come through this path and see height0 as 1 and depth0
> being the
> -   * number of slices. In this case we don't need to do the
> swap.
> -   */
> -  assert(height0 == 1 || depth0 == 1);
> -  if (height0 > 1) {
> - depth0 = height0;
> - height0 = 1;
> -  }
> -   }
> +   if (target == GL_TEXTURE_1D_ARRAY)
> +  assert(height0 == 1);
>  
> mt->target = target;
> mt->format = format;
> @@ -1048,6 +1031,7 @@ intel_get_image_dims(struct gl_texture_image
> *image,
> * as a 2D Array with a height of 1. So, here we want to swap
> image
> * height and depth.
> */
> +  assert(image->Depth == 1);
>    *width = image->Width;
>    *height = 1;
>    *depth = image->Height;
> diff --git a/src/mesa/drivers/dri/i965/intel_tex.c
> b/src/mesa/drivers/dri/i965/intel_tex.c
> index 8c32fe3..d3e24f4 100644
> --- a/src/mesa/drivers/dri/i965/intel_tex.c
> +++ b/src/mesa/drivers/dri/i965/intel_tex.c
> @@ -141,6 +141,8 @@ intel_alloc_texture_storage(struct gl_context
> *ctx,
> !intel_miptree_match_image(intel_texobj->mt, first_image) ||
> intel_texobj->mt->last_level != levels - 1) {
>    intel_miptree_release(&intel_texobj->mt);
> +
> +  intel_get_image_dims(first_image, &width, &height, &depth);
>    intel_texobj->mt = intel_miptree_create(brw, texobj->Target,
>    first_image-
> >TexFormat,
>    0, levels - 1,
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/56] glsl: Pull operator_strs out to its own file

2016-07-20 Thread Eero Tamminen

Hi,

When you put arrays to headers they get duplicated in every object file 
that includes the header.  If they're not static, you get conflict, if 
they're static, you rely on linker being able to de-duplicate them 
(which isn't given with every linker).


Wouldn't just a separate C/C++ file be OK for them (+ header declaring 
the array)?



- Eero

On 19.07.2016 22:24, Ian Romanick wrote:

From: Ian Romanick 

No change except to the copyright symbol.  The next patch will generate
this file with Python, and Unicode + Python = pure rage.

v2: Massive rebase.

Signed-off-by: Ian Romanick 
---
 src/compiler/Makefile.sources  |   1 +
 src/compiler/glsl/ir.cpp   | 116 +
 .../glsl/ir_expression_operation_strings.h | 138 +
 3 files changed, 140 insertions(+), 115 deletions(-)
 create mode 100644 src/compiler/glsl/ir_expression_operation_strings.h

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index f645173..ce42df2 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -39,6 +39,7 @@ LIBGLSL_FILES = \
glsl/ir_equals.cpp \
glsl/ir_expression_flattening.cpp \
glsl/ir_expression_flattening.h \
+   glsl/ir_expression_operation_strings.h \
glsl/ir_function_can_inline.cpp \
glsl/ir_function_detect_recursion.cpp \
glsl/ir_function_inlining.h \
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index b049fda..62061d6 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -498,121 +498,7 @@ ir_expression::get_num_operands(ir_expression_operation 
op)
return 0;
 }

-static const char *const operator_strs[] = {
-   "~",
-   "!",
-   "neg",
-   "abs",
-   "sign",
-   "rcp",
-   "rsq",
-   "sqrt",
-   "exp",
-   "log",
-   "exp2",
-   "log2",
-   "f2i",
-   "f2u",
-   "i2f",
-   "f2b",
-   "b2f",
-   "i2b",
-   "b2i",
-   "u2f",
-   "i2u",
-   "u2i",
-   "d2f",
-   "f2d",
-   "d2i",
-   "i2d",
-   "d2u",
-   "u2d",
-   "d2b",
-   "bitcast_i2f",
-   "bitcast_f2i",
-   "bitcast_u2f",
-   "bitcast_f2u",
-   "trunc",
-   "ceil",
-   "floor",
-   "fract",
-   "round_even",
-   "sin",
-   "cos",
-   "dFdx",
-   "dFdxCoarse",
-   "dFdxFine",
-   "dFdy",
-   "dFdyCoarse",
-   "dFdyFine",
-   "packSnorm2x16",
-   "packSnorm4x8",
-   "packUnorm2x16",
-   "packUnorm4x8",
-   "packHalf2x16",
-   "unpackSnorm2x16",
-   "unpackSnorm4x8",
-   "unpackUnorm2x16",
-   "unpackUnorm4x8",
-   "unpackHalf2x16",
-   "bitfield_reverse",
-   "bit_count",
-   "find_msb",
-   "find_lsb",
-   "sat",
-   "packDouble2x32",
-   "unpackDouble2x32",
-   "frexp_sig",
-   "frexp_exp",
-   "noise",
-   "subroutine_to_int",
-   "interpolate_at_centroid",
-   "get_buffer_size",
-   "ssbo_unsized_array_length",
-   "vote_any",
-   "vote_all",
-   "vote_eq",
-   "+",
-   "-",
-   "*",
-   "imul_high",
-   "/",
-   "carry",
-   "borrow",
-   "%",
-   "<",
-   ">",
-   "<=",
-   ">=",
-   "==",
-   "!=",
-   "all_equal",
-   "any_nequal",
-   "<<",
-   ">>",
-   "&",
-   "^",
-   "|",
-   "&&",
-   "^^",
-   "||",
-   "dot",
-   "min",
-   "max",
-   "pow",
-   "ubo_load",
-   "ldexp",
-   "vector_extract",
-   "interpolate_at_offset",
-   "interpolate_at_sample",
-   "fma",
-   "lrp",
-   "csel",
-   "bitfield_extract",
-   "vector_insert",
-   "bitfield_insert",
-   "vector",
-};
+#include "ir_expression_operation_strings.h"

 const char *ir_expression::operator_string(ir_expression_operation op)
 {
diff --git a/src/compiler/glsl/ir_expression_operation_strings.h 
b/src/compiler/glsl/ir_expression_operation_strings.h
new file mode 100644
index 000..3fbbae9
--- /dev/null
+++ b/src/compiler/glsl/ir_expression_operation_strings.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+static const char *

[Mesa-dev] [PATCH 1/4] glsl: Add missing braces in initializer

2016-07-20 Thread Francesco Ansanelli
---
 src/compiler/glsl/ast_to_hir.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 8ddc084..b82e693 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -4700,7 +4700,7 @@ ast_declarator_list::hir(exec_list *instructions,
   if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_temporary)
   && (var->type->is_numeric() || var->type->is_boolean())
   && state->zero_init) {
- const ir_constant_data data = {0};
+ const ir_constant_data data = {{0}};
  var->data.has_initializer = true;
  var->constant_initializer = new(var) ir_constant(var->type, &data);
   }
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 2/4] i965: Add missing braces in initializer

2016-07-20 Thread Francesco Ansanelli
---
 .../drivers/dri/i965/brw_fs_vector_splitting.cpp   |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
index 5c05586..0e16415 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
@@ -373,7 +373,7 @@ brw_do_vector_splitting(exec_list *instructions)
  ralloc_free(name);
 
  if (entry->var->constant_initializer) {
-ir_constant_data data = {0};
+ir_constant_data data = {{0}};
 assert(entry->var->data.has_initializer);
 if (entry->var->type->is_double()) {
data.d[0] = entry->var->constant_initializer->value.d[i];
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 4/4] mesa/st: Add missing braces in initializer

2016-07-20 Thread Francesco Ansanelli
---
 src/mesa/state_tracker/st_glsl_to_nir.cpp |2 +-
 src/mesa/state_tracker/st_program.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 73a692a..6470fae 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -234,7 +234,7 @@ st_glsl_to_nir(struct st_context *st, struct gl_program 
*prog,
   static const gl_state_index wposTransformState[STATE_LENGTH] = {
  STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
   };
-  nir_lower_wpos_ytransform_options wpos_options = {0};
+  nir_lower_wpos_ytransform_options wpos_options = {{0}};
   struct pipe_screen *pscreen = st->pipe->screen;
 
   memcpy(wpos_options.state_tokens, wposTransformState,
diff --git a/src/mesa/state_tracker/st_program.c 
b/src/mesa/state_tracker/st_program.c
index 57b0935..4960853 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -954,7 +954,7 @@ st_create_fp_variant(struct st_context *st,
 
   /* glDrawPixels (color only) */
   if (key->drawpixels) {
- nir_lower_drawpixels_options options = {0};
+ nir_lower_drawpixels_options options = {{0}};
  unsigned samplers_used = stfp->Base.Base.SamplersUsed;
 
  /* Find the first unused slot. */
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 3/4] freedreno/ir3: Add missing braces in initializer

2016-07-20 Thread Francesco Ansanelli
---
 src/gallium/drivers/freedreno/ir3/ir3_shader.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c 
b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
index 9f39f9f..5d57c0b 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
@@ -309,7 +309,7 @@ ir3_shader_create(struct ir3_compiler *compiler,
 * (as otherwise nothing will trigger the shader to be
 * actually compiled)
 */
-   static struct ir3_shader_key key = {0};
+   static struct ir3_shader_key key = {{0}};
ir3_shader_variant(shader, key, debug);
}
return shader;
-- 
1.7.9.5

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


Re: [Mesa-dev] [PATCH 1/2] clover: Add missing include

2016-07-20 Thread Michel Dänzer
On 20.07.2016 04:15, Jan Vesely wrote:
> On Tue, 2016-07-19 at 12:49 -0400, Ilia Mirkin wrote:
>> On Tue, Jul 19, 2016 at 11:13 AM, Tom Stellard > om> wrote:
>>>
>>> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp
>>> b/src/gallium/state_trackers/clover/llvm/invocation.cpp
>>> index 4b7de26..437d75e 100644
>>> --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
>>> +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
>>> @@ -39,6 +39,8 @@
>>>  #include 
>>>
>>>  #include 
>>> +#include "clang/Lex/PreprocessorOptions.h"
>>
>> Any reason that the rest of the includes use < > while this one uses
>> "
>> "? I believe the style decides whether system paths are used first or
>> not. Or something along those lines...
> 
> I believe we use llvm-config to get include dirs and put them on
> commandline, so both should work. For consistency sake <> is better.

Indeed. AFAIK, the main (only?) difference between "" and <> is that the
former implicitly adds the directory of the file containing the #include
directive to the search path (as the very first entry), which isn't
needed in this case.


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



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


[Mesa-dev] [PATCH] egl/dri2: Add reference count for dri2_egl_display

2016-07-20 Thread Nicolas Boichat
android.opengl.cts.WrapperTest#testGetIntegerv1 CTS test calls
eglTerminate, followed by eglReleaseThread. A similar case is
observed in this bug: https://bugs.freedesktop.org/show_bug.cgi?id=69622,
where the test calls eglTerminate, then eglMakeCurrent(dpy, NULL, NULL, NULL).

With the current code, dri2_dpy structure is freed on eglTerminate
call, so the display is not initialized when eglReleaseThread calls
MakeCurrent with NULL parameters, to unbind the context, which
causes a a segfault in drv->API.MakeCurrent (dri2_make_current),
either in glFlush or in a latter call.

eglTerminate specifies that "If contexts or surfaces associated
with display is current to any thread, they are not released until
they are no longer current as a result of eglMakeCurrent."

However, to properly free the current context/surface (i.e., call
glFlush, unbindContext, driDestroyContext), we still need the
display vtbl (and possibly an active dri dpy connection). Therefore,
we add some reference counter to dri2_egl_display, to make sure
the structure is kept allocated as long as it is required.

Signed-off-by: Nicolas Boichat 
---

Replaces https://patchwork.freedesktop.org/patch/98874/.

 src/egl/drivers/dri2/egl_dri2.c | 96 -
 src/egl/drivers/dri2/egl_dri2.h |  4 ++
 2 files changed, 80 insertions(+), 20 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index ac2be86..00269d3 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -761,6 +761,14 @@ dri2_create_screen(_EGLDisplay *disp)
 static EGLBoolean
 dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
 {
+   EGLBoolean ret = EGL_FALSE;
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+
+   if (dri2_dpy) {
+  dri2_dpy->ref_count++;
+  return EGL_TRUE;
+   }
+
/* not until swrast_dri is supported */
if (disp->Options.UseFallback)
   return EGL_FALSE;
@@ -769,52 +777,75 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
 #ifdef HAVE_SURFACELESS_PLATFORM
case _EGL_PLATFORM_SURFACELESS:
   if (disp->Options.TestOnly)
- return EGL_TRUE;
-  return dri2_initialize_surfaceless(drv, disp);
+ ret = EGL_TRUE;
+  else
+ ret = dri2_initialize_surfaceless(drv, disp);
+  break;
 #endif
-
 #ifdef HAVE_X11_PLATFORM
case _EGL_PLATFORM_X11:
   if (disp->Options.TestOnly)
- return EGL_TRUE;
-  return dri2_initialize_x11(drv, disp);
+ ret = EGL_TRUE;
+  else
+ ret = dri2_initialize_x11(drv, disp);
+  break;
 #endif
-
 #ifdef HAVE_DRM_PLATFORM
case _EGL_PLATFORM_DRM:
   if (disp->Options.TestOnly)
- return EGL_TRUE;
-  return dri2_initialize_drm(drv, disp);
+ ret = EGL_TRUE;
+  else
+ ret = dri2_initialize_drm(drv, disp);
+  break;
 #endif
 #ifdef HAVE_WAYLAND_PLATFORM
case _EGL_PLATFORM_WAYLAND:
   if (disp->Options.TestOnly)
- return EGL_TRUE;
-  return dri2_initialize_wayland(drv, disp);
+ ret = EGL_TRUE;
+  else
+ ret = dri2_initialize_wayland(drv, disp);
+  break;
 #endif
 #ifdef HAVE_ANDROID_PLATFORM
case _EGL_PLATFORM_ANDROID:
   if (disp->Options.TestOnly)
- return EGL_TRUE;
-  return dri2_initialize_android(drv, disp);
+ ret = EGL_TRUE;
+  else
+ ret = dri2_initialize_android(drv, disp);
+  break;
 #endif
-
default:
   _eglLog(_EGL_WARNING, "No EGL platform enabled.");
   return EGL_FALSE;
}
+
+   if (ret) {
+  dri2_dpy = dri2_egl_display(disp);
+
+  if (!dri2_dpy) {
+ return EGL_FALSE;
+  }
+
+  dri2_dpy->ref_count++;
+   }
+
+   return ret;
 }
 
 /**
- * Called via eglTerminate(), drv->API.Terminate().
+ * Decrement display reference count, and free up display if necessary.
  */
-static EGLBoolean
-dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
-{
+static void
+dri2_display_release(_EGLDisplay *disp) {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
unsigned i;
 
-   _eglReleaseDisplayResources(drv, disp);
+   assert(dri2_dpy->ref_count > 0);
+   dri2_dpy->ref_count--;
+
+   if (dri2_dpy->ref_count > 0)
+  return;
+
_eglCleanupDisplay(disp);
 
if (dri2_dpy->own_dri_screen)
@@ -869,6 +900,21 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
}
free(dri2_dpy);
disp->DriverData = NULL;
+}
+
+/**
+ * Called via eglTerminate(), drv->API.Terminate().
+ *
+ * This must be guaranteed to be called exactly once, even if eglTerminate is
+ * called many times.
+ */
+static EGLBoolean
+dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
+{
+   /* Release all non-current Context/Surfaces. */
+   _eglReleaseDisplayResources(drv, disp);
+
+   dri2_display_release(disp);
 
return EGL_TRUE;
 }
@@ -1188,6 +1234,10 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *dsurf,
_EGLSurface *tmp_dsurf, *tmp_rsurf;
__DRIdr

Re: [Mesa-dev] introducing radv - proof of concept vulkan driver for AMD VI chipsets

2016-07-20 Thread Christian König
Nice :) Not sure if that is going to fly but it at least adds some more 
pressure on the issue of open sourcing AMDs internal vulkan implementation.


Christian.

Am 19.07.2016 um 21:59 schrieb Dave Airlie:

I was waiting for an open source driver to appear when I realised I
should really just write one myself, some talking with Bas later, and
we decided to see where we could get.

This is the point at which we were willing to show it to others, it's
not really a vulkan driver yet, so far it's a vulkan triangle demos
driver.

It renders the tri and cube demos from the vulkan loader,
and the triangle demo from Sascha Willems demos
and the Vulkan CTS smoke tests (all 4 of them one of which draws a triangle).

There is a lot of work to do, and it's at the stage where we are
seeing if anyone else wants to join in at the start, before we make
too many serious design decisions or take a path we really don't want
to.

So far it's only been run on Tonga and Fiji chips I think, we are
hoping to support radeon kernel driver for SI/CIK at some point, but I
think we need to get things a bit further on VI chips first.

The code is currently here:
https://github.com/airlied/mesa/tree/semi-interesting

There is a not-interesting branch which contains all the pre-history
which might be useful for someone else bringing up a vulkan driver on
other hardware.

The code is pretty much based on the Intel anv driver, with the winsys
ported from gallium driver,
and most of the state setup from there. Bas wrote the code to connect
NIR<->LLVM IR so we could reuse it in the future for SPIR-V in GL if
required. It also copies AMD addrlib over, (this should be shared).

Also we don't do SPIR-V->LLVM direct. We use NIR as it has the best
chance for inter shader stage optimisations (vertex/fragment combined)
which neither SPIR-V or LLVM handles for us, (nir doesn't do it yet
but it can).

If you want to submit bug reports, they will only be taken seriously
if accompanied by working patches at this stage, and we've no plans to
merge to master yet, but open to discussion on when we could do that
and what would be required.

Dave.
___
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 05/12] st/va: add encode entrypoint

2016-07-20 Thread Christian König

Am 20.07.2016 um 06:12 schrieb Zhang, Boyuan:


>> @@ -150,7 +167,16 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile 
profile, VAEntrypoint entrypoin

>>if (entrypoint != VAEntrypointVLD)
>> return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
>>
>> -   *config_id = p;
>> +   if (entrypoint == VAEntrypointEncSlice || entrypoint == 
VAEntrypointEncPicture)

>> +  config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
>> +   else
>> +  config->entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;

>Well that doesn't make much sense here.

>First we return and error if the entrypoint isn't VAEntrypointVLD and
>then check if it's an encoding entry point.

>Additional to that I already wondered if we are really going to support
>slice level as well as picture level encoding.

>I think that it should only be one of the two.

>Regards,
>Christian.


Hi Christian,


Sorry for the confusion, The first 2 lines of codes

>>if (entrypoint != VAEntrypointVLD)
>> return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;

will actually be removed in the last patch where we enable the VAAPI 
Encode (Patch 12/12). In other word, we don't accept VAEncode 
entrypoint until the time we enable VAAPI Encode. Therefore, we still 
only accept VAEntrypointVLD at this patch.




Makes sense, but I suggest that in this case we should add at least a 
comment why this is still disabled.


And it would look better if we have an "#if 0" or something like this in 
the code which gets explicitly removed with the last patch.




And we need to accept both picture level and slice level entrypoint. 
For some application, e.g. libva h264encode test, if we don't enable 
slice level encode, it will fail the call and report h264 encode is 
not supported. If we enable both, it will still use picture level 
encode. That's why I put both here.




The problem with slice level encoding is that we haven't fully 
implemented it. E.g. the last time I checked the h264encode test it 
would try to add an SPS and PPS in front of the slice data returned from 
our VA-API driver.


Since our VA-API driver doesn't return slice data, but rather a full 
blown elementary stream you end up with a complete mess which looks 
something like this:


SPS (added by the application), PPS (added by the application), Slice 
Header, SPS (added by the driver), PPS(added by the driver), Slice 
Header/Slice Data.


That might work in some if not most cases, but is certainly not 
complaint to the VA-API specification.


Christian.



Regards,

Boyuan


*From:* Christian König 
*Sent:* July 19, 2016 4:52 AM
*To:* Zhang, Boyuan; mesa-dev@lists.freedesktop.org
*Cc:* adf.li...@gmail.com
*Subject:* Re: [PATCH 05/12] st/va: add encode entrypoint
Am 19.07.2016 um 00:43 schrieb Boyuan Zhang:
> VAAPI passes PIPE_VIDEO_ENTRYPOINT_ENCODE as entry point for 
encoding case. We will save this encode entry point in config. 
config_id was used as profile previously. Now, config has both profile 
and entrypoint field, and config_id is used to get the config object. 
Later on, we pass this entrypoint to context->templat.entrypoint 
instead of always hardcoded to PIPE_VIDEO_ENTRYPOINT_BITSTREAM for 
decoding case previously.

>
> Signed-off-by: Boyuan Zhang 
> ---
>   src/gallium/state_trackers/va/config.c | 69 
+++---
>   src/gallium/state_trackers/va/context.c| 59 
++---

>   src/gallium/state_trackers/va/surface.c| 14 --
>   src/gallium/state_trackers/va/va_private.h |  5 +++
>   4 files changed, 115 insertions(+), 32 deletions(-)
>
> diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c

> index 9ca0aa8..7ea7e24 100644
> --- a/src/gallium/state_trackers/va/config.c
> +++ b/src/gallium/state_trackers/va/config.c
> @@ -34,6 +34,8 @@
>
>   #include "va_private.h"
>
> +#include "util/u_handle_table.h"
> +
>   DEBUG_GET_ONCE_BOOL_OPTION(mpeg4, "VAAPI_MPEG4_ENABLED", false)
>
>   VAStatus
> @@ -128,14 +130,29 @@ VAStatus
>   vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoint,
>VAConfigAttrib *attrib_list, int num_attribs, 
VAConfigID *config_id)

>   {
> +   vlVaDriver *drv;
> +   vlVaConfig *config;
>  struct pipe_screen *pscreen;
>  enum pipe_video_profile p;
>
>  if (!ctx)
> return VA_STATUS_ERROR_INVALID_CONTEXT;
>
> +   drv = VL_VA_DRIVER(ctx);
> +
> +   if (!drv)
> +  return VA_STATUS_ERROR_INVALID_CONTEXT;
> +
> +   config = CALLOC(1, sizeof(vlVaConfig));
> +   if (!config)
> +  return VA_STATUS_ERROR_ALLOCATION_FAILED;
> +
>  if (profile == VAProfileNone && entrypoint == 
VAEntrypointVideoProc) {

> -  *config_id = PIPE_VIDEO_PROFILE_UNKNOWN;
> +  config->entrypoint = VAEntrypointVideoProc;
> +  config->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
> +  pipe_mutex_lock(drv->mutex);
> +  *config_id = handle_table_add(drv->htab, 

Re: [Mesa-dev] [PATCH 09/12] st/va: add functions for VAAPI encode

2016-07-20 Thread Christian König

Am 20.07.2016 um 06:21 schrieb Zhang, Boyuan:


>> - context->decoder->begin_frame(context->decoder, context->target, 
&context->desc.base);

>> +   if (context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE)
>> + context->decoder->begin_frame(context->decoder, context->target, 
&context->desc.base);



>Why do we do so here? Could we avoid that?

>I would rather like to keep the begin_frame()/end_frame() handling as 
it is.


>Christian.


This is on purpose. Based on my testing, application will call 
begin_frame first, then call PictureParameter/SequenceParameter/... to 
pass us all picture related parameters. However, some of those values 
are actually required by begin_picture call in radeon_vce. So we have 
to delay the call until we receive all the parameters that needed. 
Same applies to encode_bitstream call. That's why I delay both calls 
to end_frame where we get all necessary values.




We can keep it like this for now, but I would prefer that we clean this 
up and change the radeon_vce so that it matches the begin/encode/end 
calls from VA-API.


We should probably work on this together with the performance improvements.

Regards,
Christian.



Regards,

Boyuan


*From:* Christian König 
*Sent:* July 19, 2016 4:55:43 AM
*To:* Zhang, Boyuan; mesa-dev@lists.freedesktop.org
*Cc:* adf.li...@gmail.com
*Subject:* Re: [PATCH 09/12] st/va: add functions for VAAPI encode
Am 19.07.2016 um 00:43 schrieb Boyuan Zhang:
> Add necessary functions/changes for VAAPI encoding to buffer and 
picture. These changes will allow driver to handle all Vaapi encode 
related operations. This patch doesn't change the Vaapi decode behaviour.

>
> Signed-off-by: Boyuan Zhang 
> ---
>   src/gallium/state_trackers/va/buffer.c |   6 +
>   src/gallium/state_trackers/va/picture.c| 169 
-

>   src/gallium/state_trackers/va/va_private.h |   3 +
>   3 files changed, 176 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/state_trackers/va/buffer.c 
b/src/gallium/state_trackers/va/buffer.c

> index 7d3167b..dfcebbe 100644
> --- a/src/gallium/state_trackers/va/buffer.c
> +++ b/src/gallium/state_trackers/va/buffer.c
> @@ -133,6 +133,12 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID 
buf_id, void **pbuff)

> if (!buf->derived_surface.transfer || !*pbuff)
>return VA_STATUS_ERROR_INVALID_BUFFER;
>
> +  if (buf->type == VAEncCodedBufferType) {
> + ((VACodedBufferSegment*)buf->data)->buf = *pbuff;
> + ((VACodedBufferSegment*)buf->data)->size = buf->coded_size;
> + ((VACodedBufferSegment*)buf->data)->next = NULL;
> + *pbuff = buf->data;
> +  }
>  } else {
> pipe_mutex_unlock(drv->mutex);
> *pbuff = buf->data;
> diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c

> index 89ac024..4793194 100644
> --- a/src/gallium/state_trackers/va/picture.c
> +++ b/src/gallium/state_trackers/va/picture.c
> @@ -78,7 +78,8 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID 
context_id, VASurfaceID rende

> return VA_STATUS_SUCCESS;
>  }
>
> - context->decoder->begin_frame(context->decoder, context->target, 
&context->desc.base);

> +   if (context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE)
> + context->decoder->begin_frame(context->decoder, context->target, 
&context->desc.base);


Why do we do so here? Could we avoid that?

I would rather like to keep the begin_frame()/end_frame() handling as 
it is.


Christian.

>
>  return VA_STATUS_SUCCESS;
>   }
> @@ -278,6 +279,139 @@ handleVASliceDataBufferType(vlVaContext 
*context, vlVaBuffer *buf)

> num_buffers, (const void * const*)buffers, sizes);
>   }
>
> +static VAStatus
> +handleVAEncMiscParameterTypeRateControl(vlVaContext *context, 
VAEncMiscParameterBuffer *misc)

> +{
> +   VAEncMiscParameterRateControl *rc = 
(VAEncMiscParameterRateControl *)misc->data;

> +   if (context->desc.h264enc.rate_ctrl.rate_ctrl_method ==
> +   PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT)
> + context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second;
> +   else
> + context->desc.h264enc.rate_ctrl.target_bitrate = 
rc->bits_per_second * rc->target_percentage;

> +   context->desc.h264enc.rate_ctrl.peak_bitrate = rc->bits_per_second;
> +   if (context->desc.h264enc.rate_ctrl.target_bitrate < 200)
> + context->desc.h264enc.rate_ctrl.vbv_buffer_size = 
MIN2((context->desc.h264enc.rate_ctrl.target_bitrate * 2.75), 200);

> +   else
> + context->desc.h264enc.rate_ctrl.vbv_buffer_size = 
context->desc.h264enc.rate_ctrl.target_bitrate;

> + context->desc.h264enc.rate_ctrl.target_bits_picture =
> + context->desc.h264enc.rate_ctrl.target_bitrate / 
context->desc.h264enc.rate_ctrl.frame_rate_num;

> + context->desc.h264enc.rate_ctrl.peak_bits_picture_integer =
> + context->desc.h264enc.rate_ctrl.peak_bitrate / 
context->desc.h264enc.rate_ctrl.fram

Re: [Mesa-dev] [PATCH v1 8/8] nvc0: disable MS images on GM107+

2016-07-20 Thread Samuel Pitoiset



On 07/20/2016 04:03 AM, Ilia Mirkin wrote:

Series is

Reviewed-by: Ilia Mirkin 

Note that you'll start using PBO downloads via images as a result of
this change, please run some of the deqp pbo tests (might be in gles3,
not gles31) to double-check that all's well.


./piglit-run.py -1 --dmesg tests/deqp_gles3.py -t pbo gm107-pbo
[504/504] pass: 504 |
Thank you for running Piglit!

I think it's not bad! :)



  -ilia

On Tue, Jul 19, 2016 at 4:15 PM, Samuel Pitoiset
 wrote:

MS images have to be handled explicitly and I don't plan to implement
them for now.

v1: - check that sample_count > 1

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index f681631..a3cd046 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -90,6 +90,13 @@ nvc0_screen_is_format_supported(struct pipe_screen *pscreen,
  PIPE_BIND_LINEAR |
  PIPE_BIND_SHARED);

+   if (bindings & PIPE_BIND_SHADER_IMAGE && sample_count > 1 &&
+   nouveau_screen(pscreen)->class_3d >= GM107_3D_CLASS) {
+  /* MS images are currently unsupported on Maxwell because they have to
+   * be handled explicitly. */
+  return false;
+   }
+
return (( nvc0_format_table[format].usage |
 nvc0_vertex_format[format].usage) & bindings) == bindings;
 }
--
2.9.0

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

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


[Mesa-dev] [PATCH] build: Remove unused AX_CHECK_COMPILE_FLAG macro

2016-07-20 Thread Andreas Boll
Unused since 1a6ae840413d7fb6d2e83f6a83081d5246c7ac9e

Signed-off-by: Andreas Boll 
---
 m4/ax_check_compile_flag.m4 | 72 -
 1 file changed, 72 deletions(-)
 delete mode 100644 m4/ax_check_compile_flag.m4

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

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


Re: [Mesa-dev] [PATCH 06/11] vl/util: add copy func for yv12image to nv12surface

2016-07-20 Thread Andy Furniss

Zhang, Boyuan wrote:

Hi Andy,


Thanks for the confirmation. It seems like all basic functionality is
working now.


I will look into the cqp issue. And for the speed related issue, we
understand the reason and have already planned to work on it after
this bring-up. However, it will be a separate patch in future, and
won't be included in this bring-up patch set.


OK, though I didn't list it as remaining below due to sending a separate
mail - the I420 issue is still present. I don't know what other s/w
decoders output, but ffmpeg (so  avdec_h264 in a gatreamer pipeline)
always seem to use I420 (yuv420p) rather than YV12 which the conversion
assumes.

So far I've been testing with gstreamer. ffmpeg needs patches from libav
and always had some issues.

I tried again, and there's a possible further regression - though I have
no idea whether it's ffmpeg or the newer patches here.

Just thought I would mention it, as I haven't had time to look into it
further yet.

The regression is that when asking for a bitrate there is now a
floating point exception, -qp still works (comes out at 0 like gst).

andy [vce-tests]$ gdb /mnt/sdb1/Gits/ffmpeg/ffmpeg_g
GNU gdb (GDB) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 


This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /mnt/sdb1/Gits/ffmpeg/ffmpeg_g...done.
(gdb) run -vaapi_device /dev/dri/renderD128 -f rawvideo -framerate 50 -s 
2560x1440 -pix_fmt nv12 -i /mnt/ramdisk/trees-1440p50.nv12 -vf 
'hwupload' -c:v h264_vaapi -profile:v 66 -b:v 40M  -bf 0 -y 
/mnt/ramdisk/ffm-40M.264
Starting program: /mnt/sdb1/Gits/ffmpeg/ffmpeg_g -vaapi_device 
/dev/dri/renderD128 -f rawvideo -framerate 50 -s 2560x1440 -pix_fmt nv12 
-i /mnt/ramdisk/trees-1440p50.nv12 -vf 'hwupload' -c:v h264_vaapi 
-profile:v 66 -b:v 40M  -bf 0 -y /mnt/ramdisk/ffm-40M.264

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[New Thread 0x7fffea690700 (LWP 907)]
[New Thread 0x7fffe9c8b700 (LWP 908)]
[New Thread 0x7fffe948a700 (LWP 909)]
[New Thread 0x7fffe8c89700 (LWP 910)]
[New Thread 0x7fffe8488700 (LWP 911)]
[New Thread 0x7fffe7c87700 (LWP 912)]
[New Thread 0x7fffe7486700 (LWP 913)]
[New Thread 0x7fffe6c85700 (LWP 914)]
[New Thread 0x7fffe6484700 (LWP 915)]
[Thread 0x7fffe6484700 (LWP 915) exited]
[Thread 0x7fffe6c85700 (LWP 914) exited]
[Thread 0x7fffe7486700 (LWP 913) exited]
[Thread 0x7fffe7c87700 (LWP 912) exited]
ffmpeg version N-81050-g9bf3fdc Copyright (c) 2000-2016 the FFmpeg 
developers

  built with gcc 5.3.0 (GCC)
  configuration: --prefix=/usr --disable-doc --enable-gpl --enable-omx 
--enable-opencl --enable-libzimg --enable-libvpx --enable-libx265 
--enable-libmp3lame --enable-libx264 --enable-gnutls

  libavutil  55. 28.100 / 55. 28.100
  libavcodec 57. 50.100 / 57. 50.100
  libavformat57. 43.100 / 57. 43.100
  libavdevice57.  0.102 / 57.  0.102
  libavfilter 6. 47.100 /  6. 47.100
  libswscale  4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc54.  0.100 / 54.  0.100
libva info: VA-API version 0.38.1
libva info: va_getDriverName() returns -1
libva info: User requested driver 'radeonsi'
libva info: Trying to open /usr/lib/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_0_38
[New Thread 0x7fffe6484700 (LWP 916)]
[New Thread 0x7fffe6c85700 (LWP 917)]
[New Thread 0x7fffe7486700 (LWP 918)]
[New Thread 0x7fffe7c87700 (LWP 919)]
[New Thread 0x7fffe4b03700 (LWP 920)]
libva info: va_openDriver() returns 0
[rawvideo @ 0x1f15800] Estimating duration from bitrate, this may be 
inaccurate

Input #0, rawvideo, from '/mnt/ramdisk/trees-1440p50.nv12':
  Duration: 00:00:10.00, start: 0.00, bitrate: 2211840 kb/s
Stream #0:0: Video: rawvideo (NV12 / 0x3231564E), nv12, 2560x1440, 
2211840 kb/s, 50 tbr, 50 tbn, 50 tbc

[New Thread 0x7fffd7ab8700 (LWP 921)]
[New Thread 0x7fffd72b7700 (LWP 922)]
[New Thread 0x7fffd6ab6700 (LWP 923)]
[New Thread 0x7fffd62b5700 (LWP 924)]
[New Thread 0x7fffd5ab4700 (LWP 925)]
[h264 @ 0x1e2c300] Using AVStream.codec to pass codec parameters to 
muxers is deprecated, use AVStream.codecpar instead.

Output #0, h264, to '/mnt/ramdisk/ffm-40M.264':
  Metadata:
encoder : Lavf57.43.100
Stream #0:0: Video: h264 (h264_vaapi) (Baseline), vaapi_vld, 
2560x1440, q=2-31, 4 kb/s, 50 fps, 50 tbn, 50 tbc

Metadata:
   

[Mesa-dev] [PATCH 1/2] clover: Add missing include v2

2016-07-20 Thread Tom Stellard
There was a patch committed to clang to remove unnecessary includes from
header files, so we now need to explicitly include
clang/Lex/PreprocessorOptions.h

v2:
  - Use <> instead of "" for the include path.
---
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 4b7de26..bbd66d4 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -39,6 +39,8 @@
 #include 
 
 #include 
+#include 
+
 #include 
 #include 
 #include 
-- 
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] clover: Re-order includes in invocation.cpp to fix build

2016-07-20 Thread Tom Stellard
The build was failing because the official CL headers have a few defines, like:

\# define cl_khr_gl_sharing 1

Which have the same name as some class members of clang's OpenCLOptions class.
If we include the cl headers first, this breaks the build because the member
names of this class are replaced by the literal 1.
---
 .../state_trackers/clover/llvm/invocation.cpp  | 24 +++---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index bbd66d4..7b50b02 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -24,13 +24,6 @@
 // OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#include "llvm/codegen.hpp"
-#include "llvm/compat.hpp"
-#include "llvm/invocation.hpp"
-#include "llvm/metadata.hpp"
-#include "llvm/util.hpp"
-#include "util/algorithm.hpp"
-
 #include 
 #include 
 #include 
@@ -45,6 +38,23 @@
 #include 
 #include 
 
+// We need to include internal headers last, because the internal headers
+// include CL headers which have #define's like:
+//
+//#define cl_khr_gl_sharing 1
+//#define cl_khr_icd 1
+//
+// Which will break the compilation of clang/Basic/OpenCLOptions.h
+
+#include "core/error.hpp"
+#include "llvm/codegen.hpp"
+#include "llvm/compat.hpp"
+#include "llvm/invocation.hpp"
+#include "llvm/metadata.hpp"
+#include "llvm/util.hpp"
+#include "util/algorithm.hpp"
+
+
 using namespace clover;
 using namespace clover::llvm;
 
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH 00/10] egl/android: Improve the Android EGL backend

2016-07-20 Thread Tomasz Figa
Hi Rob,

On Tue, Jul 19, 2016 at 1:29 PM, Tomasz Figa  wrote:
> On Tue, Jul 19, 2016 at 12:35 PM, Rob Herring  wrote:
>>
>> Patches 7-10 wouldn't apply. Do you have a git tree with the series?
>
> Hmm, I rebased them on Mesa master just before sending. Let me try to
> create a sandbox branch in our chromium tree.

https://chromium.googlesource.com/chromiumos/third_party/mesa tfiga/android-egl

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


Re: [Mesa-dev] [PATCH 3/3] radeonsi: advertise 8 bits subpixel precision for viewport bounds

2016-07-20 Thread Marek Olšák
Pushed the series, thanks.

Marek

On Tue, Jul 19, 2016 at 1:07 PM, Józef Kucia  wrote:
> Signed-off-by: Józef Kucia 
> ---
>  src/gallium/drivers/radeonsi/si_pipe.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
> b/src/gallium/drivers/radeonsi/si_pipe.c
> index 768dc8c..6a496c2 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.c
> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
> @@ -444,7 +444,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum 
> pipe_cap param)
> case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
> case PIPE_CAP_TGSI_VOTE:
> case PIPE_CAP_MAX_WINDOW_RECTANGLES:
> -   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
> return 0;
>
> case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
> @@ -490,6 +489,8 @@ static int si_get_param(struct pipe_screen* pscreen, enum 
> pipe_cap param)
>
> case PIPE_CAP_MAX_VIEWPORTS:
> return R600_MAX_VIEWPORTS;
> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
> +   return 8;
>
> /* Timer queries, present when the clock frequency is non zero. */
> case PIPE_CAP_QUERY_TIMESTAMP:
> --
> 2.7.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] RFC Steps towards replacing the GLSL IR optimisations with NIR

2016-07-20 Thread Timothy Arceri
Currently disabling these optimisations causes some major regressions mainly
because cross shader removal of unused varyings is done in the GLSL IR linker.

I've spent some time today attempting to insert a glsl->nir conversion just
before assigning varying locations. The idea was I could then call some nir
optimisations, check what varyings are left in nir then remove the varyings
from the producing GLSL IR stage and continue on (this happens in FS->VS order).
Ideally we would use the GLSL IR for validation and PIQ and would be able to
hold onto the nir and reuse it in the backend. We should also be able to do
the same for unused uniforms but thats not as useful.

Unfortunatly the order in which we do things currently e.g lowering UBOs
after running link_uniforms is making things difficult and I dont yet
have a solid plan to solve all the issues. However in order to create
the nir I needed to first call the drivers GLSL processing pass and this
proved to do a nice job of removing a bunch of instructions itself so
I'm sending this as a first step.

Broadwell shader-db results:

total instructions in shared programs: 8649621 -> 8642352 (-0.08%)
instructions in affected programs: 49023 -> 41754 (-14.83%)
total loops in shared programs:2087 -> 2087 (0.00%)
helped:359
HURT:  5
GAINED:0
LOST:  0

There are two piglit tests failing with these changes:

tests/spec/arb_gpu_shader5/execution/samplemaskin-indirect.shader_test
Fails because the uniform is now optimised away an can no longer be found.

tests/spec/glsl-1.50/execution/geometry/max-input-components.shader_test
Fails to link on hsw, snb and ivb. There is no error message linking just
fails, I'm still looking into the problem.

Full shader-db results bellow in case anyone wants to dig further into these 
results.

helped:   shaders/closed/steam/tropico-5/99.shader_test FS SIMD16: 591 -> 590 
(-0.17%)
helped:   shaders/closed/UnrealEngine4/VehicleGame/42.shader_test FS SIMD16: 
362 -> 361 (-0.28%)
helped:   shaders/closed/steam/dota-2-reborn/1641.shader_test FS SIMD16: 334 -> 
333 (-0.30%)
helped:   shaders/closed/steam/dota-2-reborn/1925.shader_test FS SIMD16: 327 -> 
326 (-0.31%)
helped:   shaders/closed/steam/dota-2-reborn/1933.shader_test FS SIMD16: 326 -> 
325 (-0.31%)
helped:   shaders/closed/steam/dota-2-reborn/1967.shader_test FS SIMD16: 315 -> 
314 (-0.32%)
helped:   shaders/closed/steam/dota-2-reborn/1845.shader_test FS SIMD16: 313 -> 
312 (-0.32%)
helped:   shaders/closed/steam/dota-2-reborn/1717.shader_test FS SIMD16: 304 -> 
303 (-0.33%)
helped:   shaders/closed/UnrealEngine4/ReflectionsSubwayDemo/282.shader_test FS 
SIMD16: 250 -> 249 (-0.40%)
helped:   shaders/closed/steam/metro-2033-redux/3274.shader_test VS SIMD8: 221 
-> 220 (-0.45%)
helped:   shaders/closed/steam/metro-2033-redux/6530.shader_test VS SIMD8: 215 
-> 214 (-0.47%)
helped:   shaders/closed/steam/metro-2033-redux/6528.shader_test VS SIMD8: 215 
-> 214 (-0.47%)
helped:   shaders/closed/steam/metro-2033-redux/5977.shader_test VS SIMD8: 214 
-> 213 (-0.47%)
helped:   shaders/closed/steam/metro-2033-redux/4775.shader_test VS SIMD8: 214 
-> 213 (-0.47%)
helped:   shaders/closed/steam/metro-2033-redux/5603.shader_test VS SIMD8: 214 
-> 213 (-0.47%)
helped:   shaders/closed/steam/metro-2033-redux/5605.shader_test VS SIMD8: 214 
-> 213 (-0.47%)
helped:   shaders/closed/steam/metro-2033-redux/4943.shader_test VS SIMD8: 213 
-> 212 (-0.47%)
helped:   shaders/closed/steam/metro-2033-redux/4774.shader_test VS SIMD8: 211 
-> 210 (-0.47%)
helped:   shaders/closed/steam/metro-2033-redux/4773.shader_test VS SIMD8: 211 
-> 210 (-0.47%)
helped:   shaders/closed/steam/metro-2033-redux/4648.shader_test VS SIMD8: 208 
-> 207 (-0.48%)
helped:   shaders/closed/steam/metro-2033-redux/6529.shader_test VS SIMD8: 207 
-> 206 (-0.48%)
helped:   shaders/closed/steam/metro-2033-redux/3275.shader_test VS SIMD8: 207 
-> 206 (-0.48%)
helped:   shaders/closed/steam/metro-2033-redux/2478.shader_test VS SIMD8: 206 
-> 205 (-0.49%)
helped:   shaders/closed/steam/metro-2033-redux/5604.shader_test VS SIMD8: 206 
-> 205 (-0.49%)
helped:   shaders/closed/steam/metro-2033-redux/2479.shader_test VS SIMD8: 206 
-> 205 (-0.49%)
helped:   shaders/closed/steam/metro-2033-redux/5976.shader_test VS SIMD8: 206 
-> 205 (-0.49%)
helped:   shaders/closed/steam/metro-2033-redux/4942.shader_test VS SIMD8: 205 
-> 204 (-0.49%)
helped:   shaders/closed/steam/metro-2033-redux/4941.shader_test VS SIMD8: 205 
-> 204 (-0.49%)
helped:   shaders/closed/steam/metro-2033-redux/3910.shader_test VS SIMD8: 205 
-> 204 (-0.49%)
helped:   shaders/closed/steam/metro-2033-redux/4650.shader_test VS SIMD8: 202 
-> 201 (-0.50%)
helped:   shaders/closed/steam/metro-2033-redux/5811.shader_test VS SIMD8: 201 
-> 200 (-0.50%)
helped:   shaders/closed/steam/metro-2033-redux/4649.shader_test VS SIMD8: 199 
-> 198 (-0.50

[Mesa-dev] [PATCH 1/2] mesa/i965: create Driver.ProcessGLSLIR()

2016-07-20 Thread Timothy Arceri
This allows us to do backend specific processing on GLSL IR from
the shared linker.
---
 src/mesa/drivers/dri/i965/brw_link.cpp  | 14 +++---
 src/mesa/drivers/dri/i965/brw_program.c |  1 +
 src/mesa/drivers/dri/i965/brw_shader.h  |  4 
 src/mesa/main/dd.h  |  3 +++
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp 
b/src/mesa/drivers/dri/i965/brw_link.cpp
index 5374685..523b923 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -85,13 +85,13 @@ brw_lower_packing_builtins(struct brw_context *brw,
lower_packing_builtins(ir, LOWER_PACK_HALF_2x16 | LOWER_UNPACK_HALF_2x16);
 }
 
-static void
-process_glsl_ir(gl_shader_stage stage,
-struct brw_context *brw,
-struct gl_shader_program *shader_prog,
-struct gl_linked_shader *shader)
+extern "C" void
+brw_process_glsl_ir(gl_shader_stage stage,
+struct gl_context *ctx,
+struct gl_shader_program *shader_prog,
+struct gl_linked_shader *shader)
 {
-   struct gl_context *ctx = &brw->ctx;
+   struct brw_context *brw = brw_context(ctx);
const struct brw_compiler *compiler = brw->intelScreen->compiler;
const struct gl_shader_compiler_options *options =
   &ctx->Const.ShaderCompilerOptions[shader->Stage];
@@ -220,7 +220,7 @@ brw_link_shader(struct gl_context *ctx, struct 
gl_shader_program *shProg)
 
   _mesa_copy_linked_program_data((gl_shader_stage) stage, shProg, prog);
 
-  process_glsl_ir((gl_shader_stage) stage, brw, shProg, shader);
+  brw_process_glsl_ir((gl_shader_stage) stage, ctx, shProg, shader);
 
   /* Make a pass over the IR to add state references for any built-in
* uniforms that are used.  This has to be done now (during linking).
diff --git a/src/mesa/drivers/dri/i965/brw_program.c 
b/src/mesa/drivers/dri/i965/brw_program.c
index 7785490..559bb4d 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -377,6 +377,7 @@ void brwInitFragProgFuncs( struct dd_function_table 
*functions )
 
functions->NewShader = brw_new_shader;
functions->LinkShader = brw_link_shader;
+   functions->ProcessGLSLIR = brw_process_glsl_ir;
 
functions->MemoryBarrier = brw_memory_barrier;
 }
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h 
b/src/mesa/drivers/dri/i965/brw_shader.h
index dd9eb2d..9151de8 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -290,6 +290,10 @@ bool brw_cs_precompile(struct gl_context *ctx,
 
 GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program 
*prog);
 struct gl_linked_shader *brw_new_shader(gl_shader_stage stage);
+void
+brw_process_glsl_ir(gl_shader_stage stage, struct gl_context *ctx,
+struct gl_shader_program *shader_prog,
+struct gl_linked_shader *shader);
 
 int type_size_scalar(const struct glsl_type *type);
 int type_size_vec4(const struct glsl_type *type);
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 114cbd2..fe65246 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -786,6 +786,9 @@ struct dd_function_table {
/*@{*/
struct gl_linked_shader *(*NewShader)(gl_shader_stage stage);
void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program 
*shProg);
+   void (*ProcessGLSLIR)(gl_shader_stage stage, struct gl_context *ctx,
+ struct gl_shader_program *shader_prog,
+ struct gl_linked_shader *shader);
/*@}*/
 
/**
-- 
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] glsl/i965: call backend optimisations from glsl linker

2016-07-20 Thread Timothy Arceri
Here we get the backend to do its extra GLSL IR passes before
assigning varying and uniform locations.

Broadwell shader-db results:

total instructions in shared programs: 8649621 -> 8642352 (-0.08%)
instructions in affected programs: 49023 -> 41754 (-14.83%)
helped:359
HURT:  5
---
 I attempted to reduce the amount of work required in the second
 brw_process_glsl_ir() call from brw_link_shader() but it was
 proving difficult to narrow down the requirements and didn't
 seem worth the effort as compile times of shader-db were comparable
 even now that we call this twice.

 Also if we are able to refactor link_shaders() to create nir earlier
 then this second call should go away.

 src/compiler/glsl/linker.cpp   | 14 ++
 src/mesa/drivers/dri/i965/brw_link.cpp |  7 ---
 src/mesa/drivers/dri/i965/brw_shader.h |  2 +-
 src/mesa/main/dd.h |  3 ++-
 4 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 6d45a02..012c0ea 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4799,6 +4799,20 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
/* Check and validate stream emissions in geometry shaders */
validate_geometry_shader_emissions(ctx, prog);
 
+   /* Call driver GLSL IR processing. Doing this before assigning varying
+* locations allows us to do backend specific optimisations before we
+* check for and remove usused varyings.
+*/
+   if (ctx->Driver.ProcessGLSLIR) {
+  for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ if (prog->_LinkedShaders[i] == NULL)
+   continue;
+
+ ctx->Driver.ProcessGLSLIR(prog->_LinkedShaders[i]->Stage,
+   ctx, prog, prog->_LinkedShaders[i], false);
+  }
+   }
+
/* Mark all generic shader inputs and outputs as unpaired. */
for (unsigned i = MESA_SHADER_VERTEX; i <= MESA_SHADER_FRAGMENT; i++) {
   if (prog->_LinkedShaders[i] != NULL) {
diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp 
b/src/mesa/drivers/dri/i965/brw_link.cpp
index 523b923..c34f9a0 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -89,7 +89,8 @@ extern "C" void
 brw_process_glsl_ir(gl_shader_stage stage,
 struct gl_context *ctx,
 struct gl_shader_program *shader_prog,
-struct gl_linked_shader *shader)
+struct gl_linked_shader *shader,
+bool uni_locs_assigned)
 {
struct brw_context *brw = brw_context(ctx);
const struct brw_compiler *compiler = brw->intelScreen->compiler;
@@ -163,7 +164,7 @@ brw_process_glsl_ir(gl_shader_stage stage,
 false /* loops */
 ) || progress;
 
-  progress = do_common_optimization(shader->ir, true, true,
+  progress = do_common_optimization(shader->ir, true, uni_locs_assigned,
 options, ctx->Const.NativeIntegers) || 
progress;
} while (progress);
 
@@ -220,7 +221,7 @@ brw_link_shader(struct gl_context *ctx, struct 
gl_shader_program *shProg)
 
   _mesa_copy_linked_program_data((gl_shader_stage) stage, shProg, prog);
 
-  brw_process_glsl_ir((gl_shader_stage) stage, ctx, shProg, shader);
+  brw_process_glsl_ir((gl_shader_stage) stage, ctx, shProg, shader, true);
 
   /* Make a pass over the IR to add state references for any built-in
* uniforms that are used.  This has to be done now (during linking).
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h 
b/src/mesa/drivers/dri/i965/brw_shader.h
index 9151de8..b5e0463 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -293,7 +293,7 @@ struct gl_linked_shader *brw_new_shader(gl_shader_stage 
stage);
 void
 brw_process_glsl_ir(gl_shader_stage stage, struct gl_context *ctx,
 struct gl_shader_program *shader_prog,
-struct gl_linked_shader *shader);
+struct gl_linked_shader *shader, bool uni_locs_assigned);
 
 int type_size_scalar(const struct glsl_type *type);
 int type_size_vec4(const struct glsl_type *type);
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index fe65246..778fc55 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -788,7 +788,8 @@ struct dd_function_table {
void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program 
*shProg);
void (*ProcessGLSLIR)(gl_shader_stage stage, struct gl_context *ctx,
  struct gl_shader_program *shader_prog,
- struct gl_linked_shader *shader);
+ struct gl_linked_shader *shader,
+ bool uni_locs_assigned);
/*@}*/
 
/**
-- 
2.7.4

_

Re: [Mesa-dev] [PATCH 2/2] clover: Re-order includes in invocation.cpp to fix build

2016-07-20 Thread Vedran Miletić

On 07/20/2016 11:46 AM, Tom Stellard wrote:

The build was failing because the official CL headers have a few defines, like:

\# define cl_khr_gl_sharing 1

Which have the same name as some class members of clang's OpenCLOptions class.
If we include the cl headers first, this breaks the build because the member
names of this class are replaced by the literal 1.
---
 .../state_trackers/clover/llvm/invocation.cpp  | 24 +++---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index bbd66d4..7b50b02 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -24,13 +24,6 @@
 // OTHER DEALINGS IN THE SOFTWARE.
 //

-#include "llvm/codegen.hpp"
-#include "llvm/compat.hpp"
-#include "llvm/invocation.hpp"
-#include "llvm/metadata.hpp"
-#include "llvm/util.hpp"
-#include "util/algorithm.hpp"
-
 #include 
 #include 
 #include 
@@ -45,6 +38,23 @@
 #include 
 #include 

+// We need to include internal headers last, because the internal headers
+// include CL headers which have #define's like:
+//
+//#define cl_khr_gl_sharing 1
+//#define cl_khr_icd 1
+//
+// Which will break the compilation of clang/Basic/OpenCLOptions.h
+
+#include "core/error.hpp"
+#include "llvm/codegen.hpp"
+#include "llvm/compat.hpp"
+#include "llvm/invocation.hpp"
+#include "llvm/metadata.hpp"
+#include "llvm/util.hpp"
+#include "util/algorithm.hpp"
+
+
 using namespace clover;
 using namespace clover::llvm;




The series is:

Reviewed-by: Vedran Miletić 

Regards,
Vedran

--
Vedran Miletić
vedran.miletic.net
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] gallium: split transfer_inline_write into buffer and texture callbacks

2016-07-20 Thread Marek Olšák
On Tue, Jul 19, 2016 at 4:00 PM, Nicolai Hähnle  wrote:
> On 18.07.2016 14:25, Marek Olšák wrote:
>>
>> From: Marek Olšák 
>>
>> to reduce the call indirections with u_resource_vtbl.
>>
>> The worst call tree you could get was:
>>- u_transfer_inline_write_vtbl
>>  - u_default_transfer_inline_write
>>- u_transfer_map_vtbl
>>  - driver_transfer_map
>>- u_transfer_unmap_vtbl
>>  - driver_transfer_unmap
>>
>> That's 6 indirect calls. Some drivers only had 5. The goal is to have
>> 1 indirect call for drivers that care. The resource type can be determined
>> statically at most call sites.
>>
>> The new interface is:
>>pipe_context::buffer_subdata(ctx, resource, usage, offset, size, data)
>>pipe_context::texture_subdata(ctx, resource, level, usage, box, data,
>>  stride, layer_stride)
>> ---
>
> [snip]
>
>> diff --git a/src/gallium/drivers/ilo/ilo_transfer.c
>> b/src/gallium/drivers/ilo/ilo_transfer.c
>> index 5abd3be..53029b6 100644
>> --- a/src/gallium/drivers/ilo/ilo_transfer.c
>> +++ b/src/gallium/drivers/ilo/ilo_transfer.c
>> @@ -1236,34 +1236,6 @@ ilo_transfer_map(struct pipe_context *pipe,
>>  return ptr;
>>   }
>>
>> -static void
>> -ilo_transfer_inline_write(struct pipe_context *pipe,
>> -  struct pipe_resource *res,
>> -  unsigned level,
>> -  unsigned usage,
>> -  const struct pipe_box *box,
>> -  const void *data,
>> -  unsigned stride,
>> -  unsigned layer_stride)
>> -{
>> -   if (likely(res->target == PIPE_BUFFER) &&
>> -   !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
>> -  /* they should specify just an offset and a size */
>> -  assert(level == 0);
>> -  assert(box->y == 0);
>> -  assert(box->z == 0);
>> -  assert(box->height == 1);
>> -  assert(box->depth == 1);
>> -
>> -  buf_pwrite(ilo_context(pipe), res,
>> -usage, box->x, box->width, data);
>> -   }
>> -   else {
>> -  u_default_transfer_inline_write(pipe, res,
>> -level, usage, box, data, stride, layer_stride);
>> -   }
>> -}
>> -
>>   /**
>>* Initialize transfer-related functions.
>>*/
>> @@ -1273,5 +1245,6 @@ ilo_init_transfer_functions(struct ilo_context *ilo)
>>  ilo->base.transfer_map = ilo_transfer_map;
>>  ilo->base.transfer_flush_region = ilo_transfer_flush_region;
>>  ilo->base.transfer_unmap = ilo_transfer_unmap;
>> -   ilo->base.transfer_inline_write = ilo_transfer_inline_write;
>> +   ilo->base.buffer_subdata = u_default_buffer_subdata;
>> +   ilo->base.texture_subdata = u_default_texture_subdata;
>
>
> This is a change of behavior - buffer_subdata should end up calling
> buf_pwrite in the !PIPE_TRANSFER_UNSYNCHRONIZED case. Or, if nobody cares,
> buf_pwrite should be deleted.

Or ilo can be deleted. It seems to be a dead driver.

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


Re: [Mesa-dev] Testing patches 9987 and 9988

2016-07-20 Thread
Results for Bioshock Infinite on R9 390:

 TIMEAVG   MIN   MAX
2016-05-25.15-51-53: 139.06, 9.81, 1.72, 58.78
2016-06-14.01-13-33: 100.91, 16.12, 3.06, 60.06
2016-07-07.16-44-55: 95.88, 18.45, 3.74, 68.32
2016-07-20.11-55-04: 85.97, 27.20, 4.54, 68.63 (git-0b626d7)
2016-07-20.12-17-38: 84.93, 27.72, 4.54, 71.60 (git-3c78d89)

This roughly shows how performance improved over time.

Mesa git-0b626d7 is just before http://patchwork.freedesktop.org/series/9987

Mesa git-3c78d89 is after 9987 has been merged.

The biggest performance change happened between 2016-07-07 and
2016-07-20, but I do not have enough data to tell exactly when.

---

st_validate_state() is definitely affecting performance in games as
measured by "perf stat", so I am looking forward to your rewrite.

On Tue, Jul 19, 2016 at 11:54 PM, Marek Olšák  wrote:
> The first one just landed.
>
> The second one will take some time I guess.
>
> This branch contains both, but it won't be merged in this form:
> https://cgit.freedesktop.org/~mareko/mesa/log/?h=si-mid-ib-gfx-fence
>
> Marek
>
> On Tue, Jul 19, 2016 at 3:53 PM, ⚛ <0xe2.0x9a.0...@gmail.com> wrote:
>> Hello
>>
>> I would like to test http://patchwork.freedesktop.org/series/9987/ and
>> http://patchwork.freedesktop.org/series/9988/ but the mbox patches
>> aren't compatible with mesa-git.
>>
>> Would it be possible to update 9987 and 9988 to match mesa-git?
>>
>> Do 9987 and 9988 assume additional public patches that need to be
>> applied prior to them?
>>
>> Thanks
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Testing patches 9987 and 9988

2016-07-20 Thread Martin Peres

On 20/07/16 14:35, ⚛ wrote:

Results for Bioshock Infinite on R9 390:

 TIMEAVG   MIN   MAX
2016-05-25.15-51-53: 139.06, 9.81, 1.72, 58.78
2016-06-14.01-13-33: 100.91, 16.12, 3.06, 60.06
2016-07-07.16-44-55: 95.88, 18.45, 3.74, 68.32
2016-07-20.11-55-04: 85.97, 27.20, 4.54, 68.63 (git-0b626d7)
2016-07-20.12-17-38: 84.93, 27.72, 4.54, 71.60 (git-3c78d89)

This roughly shows how performance improved over time.

Mesa git-0b626d7 is just before http://patchwork.freedesktop.org/series/9987

Mesa git-3c78d89 is after 9987 has been merged.

The biggest performance change happened between 2016-07-07 and
2016-07-20, but I do not have enough data to tell exactly when.


Ezbench can bisect these improvements for you. Join me on #ezbench if 
you need help!


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


Re: [Mesa-dev] [PATCH] anv: add function to get prime buffer from memory+image

2016-07-20 Thread Daniel Stone
Hi Jonathan,

On 19 July 2016 at 20:47, Jonathan  wrote:
> +typedef VkResult (VKAPI_PTR *PFN_vkGetDmaBufINTEL)(VkDevice device, 
> VkDeviceMemory mem, VkImage image, int *fd, uint32_t *pitch);

Some things you should consider adding to this:
  - multi-plane support for multi-buffer formats (multiple fds,
multiple pitches, per-plane offset parameter)
  - an out parameter for format, using the DRM FourCC format codes
  - out parameters for a DRM modifier per-plane, to account for tiling
etc (and no longer calling anv_gem_set_tiling)

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


Re: [Mesa-dev] [PATCH] anv: add function to get prime buffer from memory+image

2016-07-20 Thread Daniel Stone
On 20 July 2016 at 13:47, Daniel Stone  wrote:
> On 19 July 2016 at 20:47, Jonathan  wrote:
>> +typedef VkResult (VKAPI_PTR *PFN_vkGetDmaBufINTEL)(VkDevice device, 
>> VkDeviceMemory mem, VkImage image, int *fd, uint32_t *pitch);
>
> Some things you should consider adding to this:
>   - multi-plane support for multi-buffer formats (multiple fds,
> multiple pitches, per-plane offset parameter)
>   - an out parameter for format, using the DRM FourCC format codes
>   - out parameters for a DRM modifier per-plane, to account for tiling
> etc (and no longer calling anv_gem_set_tiling)

Oops, hit send too early. Being able to export a VkFence to a kernel
fence fd, as a companion, would also be incredibly helpful.

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


Re: [Mesa-dev] [PATCH] anv: add function to get prime buffer from memory+image

2016-07-20 Thread Rob Clark
On Wed, Jul 20, 2016 at 7:51 AM, Daniel Stone  wrote:
> On 20 July 2016 at 13:47, Daniel Stone  wrote:
>> On 19 July 2016 at 20:47, Jonathan  wrote:
>>> +typedef VkResult (VKAPI_PTR *PFN_vkGetDmaBufINTEL)(VkDevice device, 
>>> VkDeviceMemory mem, VkImage image, int *fd, uint32_t *pitch);
>>
>> Some things you should consider adding to this:
>>   - multi-plane support for multi-buffer formats (multiple fds,
>> multiple pitches, per-plane offset parameter)
>>   - an out parameter for format, using the DRM FourCC format codes
>>   - out parameters for a DRM modifier per-plane, to account for tiling
>> etc (and no longer calling anv_gem_set_tiling)
>
> Oops, hit send too early. Being able to export a VkFence to a kernel
> fence fd, as a companion, would also be incredibly helpful.
>

I wonder if android has already defined some extensions for this?
(Well I guess they must have already, no idea if public..)

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


Re: [Mesa-dev] [PATCH v2 1/2] vl: add a lanczos interpolation filter v2

2016-07-20 Thread Nayan Deshmukh
Hi Christian,

Thanks for the review.


On Tue, Jul 19, 2016 at 4:58 PM, Christian König 
wrote:

> Am 18.07.2016 um 21:55 schrieb Nayan Deshmukh:
>
>> v2: avoiding dividing by zero when calculating lanczos
>>
>> Signed-off-by: Nayan Deshmukh 
>>
>
> That looks much better, but there are still quite a bunch of artifacts.
>
> Take a look at the attached screenshots. good.jpg was created with
> hqscalling=0, bad with hqscalling=7.
>
> Especially on the left side we have lines from top to bottom where there
> shouldn't be any.
>
> Regards,
> Christian.
>
>
> ---
>>   src/gallium/auxiliary/Makefile.sources   |   2 +
>>   src/gallium/auxiliary/vl/vl_lanczos_filter.c | 447
>> +++
>>   src/gallium/auxiliary/vl/vl_lanczos_filter.h |  63 
>>   3 files changed, 512 insertions(+)
>>   create mode 100644 src/gallium/auxiliary/vl/vl_lanczos_filter.c
>>   create mode 100644 src/gallium/auxiliary/vl/vl_lanczos_filter.h
>>
>> diff --git a/src/gallium/auxiliary/Makefile.sources
>> b/src/gallium/auxiliary/Makefile.sources
>> index e0311bf..4eb0f65 100644
>> --- a/src/gallium/auxiliary/Makefile.sources
>> +++ b/src/gallium/auxiliary/Makefile.sources
>> @@ -330,6 +330,8 @@ VL_SOURCES := \
>> vl/vl_deint_filter.h \
>> vl/vl_idct.c \
>> vl/vl_idct.h \
>> +   vl/vl_lanczos_filter.c \
>> +   vl/vl_lanczos_filter.h \
>> vl/vl_matrix_filter.c \
>> vl/vl_matrix_filter.h \
>> vl/vl_mc.c \
>> diff --git a/src/gallium/auxiliary/vl/vl_lanczos_filter.c
>> b/src/gallium/auxiliary/vl/vl_lanczos_filter.c
>> new file mode 100644
>> index 000..7c69555
>> --- /dev/null
>> +++ b/src/gallium/auxiliary/vl/vl_lanczos_filter.c
>> @@ -0,0 +1,447 @@
>>
>> +/**
>> + *
>> + * Copyright 2016 Nayan Deshmukh.
>> + * 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, sub license, and/or sell copies of the Software, and to
>> + * permit persons to whom the Software is furnished to do so, subject to
>> + * the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the
>> + * next paragraph) shall be included in all copies or substantial
>> portions
>> + * of the Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>> EXPRESS
>> + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
>> NON-INFRINGEMENT.
>> + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 "pipe/p_context.h"
>> +
>> +#include "tgsi/tgsi_ureg.h"
>> +
>> +#include "util/u_draw.h"
>> +#include "util/u_memory.h"
>> +#include "util/u_math.h"
>> +#include "util/u_rect.h"
>> +
>> +#include "vl_types.h"
>> +#include "vl_vertex_buffers.h"
>> +#include "vl_lanczos_filter.h"
>> +
>> +enum VS_OUTPUT
>> +{
>> +   VS_O_VPOS = 0,
>> +   VS_O_VTEX = 0
>> +};
>> +
>> +static void *
>> +create_vert_shader(struct vl_lanczos_filter *filter)
>> +{
>> +   struct ureg_program *shader;
>> +   struct ureg_src i_vpos;
>> +   struct ureg_dst o_vpos, o_vtex;
>> +
>> +   shader = ureg_create(PIPE_SHADER_VERTEX);
>> +   if (!shader)
>> +  return NULL;
>> +
>> +   i_vpos = ureg_DECL_vs_input(shader, 0);
>> +   o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS);
>> +   o_vtex = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX);
>> +
>> +   ureg_MOV(shader, o_vpos, i_vpos);
>> +   ureg_MOV(shader, o_vtex, i_vpos);
>> +
>> +   ureg_END(shader);
>> +
>> +   return ureg_create_shader_and_destroy(shader, filter->pipe);
>> +}
>> +
>> +static void
>> +create_frag_shader_lanczos(struct ureg_program *shader, struct ureg_src
>> a,
>> +   struct ureg_src x, struct ureg_dst o_fragment)
>> +{
>> +   struct ureg_dst temp[8];
>> +   unsigned i;
>> +
>> +   for(i = 0; i < 8; ++i)
>> +   temp[i] = ureg_DECL_temporary(shader);
>> +
>> +   /*
>> +* temp[0] = (x == 0) ? 1.0f : x
>> +* temp[7] = (sin(pi * x) * sin ((pi * x)/a)) / x^2
>> +* o_fragment = (x == 0) ? 1.0f : temp[7]
>> +*/
>> +   ureg_MOV(shader, temp[0], x);
>> +   ureg_SEQ(shader, temp[1], x, ureg_imm1f(shader, 0.0f));
>> +
>> +   ureg_LRP(shader, temp[0], ureg_src(temp[1]),
>> +ureg_imm1f(shader, 1.0f), ureg_src(temp[0]));
>> +
>> +   ureg_MUL

Re: [Mesa-dev] [PATCH] gallium/os: use CLOCK_MONOTONIC for sleeps (v2)

2016-07-20 Thread Eric Engestrom
On Tue, Jul 19, 2016 at 06:29:20PM +0200, Marek Olšák wrote:
> From: Marek Olšák 
> 
> v2: handle EINTR, remove backslashes

I was a bit surprised by the way you use clock_nanosleep(), but
I checked the man and you're right :)
Reviewed-by: Eric Engestrom 

> ---
>  src/gallium/auxiliary/os/os_time.c | 16 ++--
>  src/gallium/auxiliary/os/os_time.h |  4 
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/os/os_time.c 
> b/src/gallium/auxiliary/os/os_time.c
> index 3d2e416..e169139 100644
> --- a/src/gallium/auxiliary/os/os_time.c
> +++ b/src/gallium/auxiliary/os/os_time.c
> @@ -40,6 +40,7 @@
>  #  include  /* timeval */
>  #  include  /* timeval */
>  #  include  /* sched_yield */
> +#  include 
>  #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
>  #  include 
>  #else
> @@ -81,19 +82,30 @@ os_time_get_nano(void)
>  }
>  
>  
> -#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
>  
>  void
>  os_time_sleep(int64_t usecs)
>  {
> +#if defined(PIPE_OS_LINUX)
> +   struct timespec time;
> +   time.tv_sec = usecs / 100;
> +   time.tv_nsec = (usecs % 100) * 1000;
> +   while (clock_nanosleep(CLOCK_MONOTONIC, 0, &time, &time) == EINTR);
> +
> +#elif defined(PIPE_OS_UNIX)
> +   usleep(usecs);
> +
> +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
> DWORD dwMilliseconds = (DWORD) ((usecs + 999) / 1000);
> /* Avoid Sleep(O) as that would cause to sleep for an undetermined 
> duration */
> if (dwMilliseconds) {
>Sleep(dwMilliseconds);
> }
> +#else
> +#  error Unsupported OS
> +#endif
>  }
>  
> -#endif
>  
>  
>  int64_t
> diff --git a/src/gallium/auxiliary/os/os_time.h 
> b/src/gallium/auxiliary/os/os_time.h
> index 9312e02..ca0bdd5 100644
> --- a/src/gallium/auxiliary/os/os_time.h
> +++ b/src/gallium/auxiliary/os/os_time.h
> @@ -70,12 +70,8 @@ os_time_get(void)
>  /*
>   * Sleep.
>   */
> -#if defined(PIPE_OS_UNIX)
> -#define os_time_sleep(_usecs) usleep(_usecs)
> -#else
>  void
>  os_time_sleep(int64_t usecs);
> -#endif
>  
>  
>  /*
> -- 
> 2.7.4
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/4] st/omx/dec: make decoder video buffer progressive

2016-07-20 Thread Emil Velikov
On 7 July 2016 at 18:16, Leo Liu  wrote:
> Hi Emil,
>
> Have a look again, I think the logic is nothing wrong.
>
I did not mention that it's doing something "wrong" :-)

> reason In lines
>
>
> On 07/07/2016 11:39 AM, Emil Velikov wrote:
>>
>> On 6 July 2016 at 19:03, Leo Liu  wrote:
>>>
>>> The idea of encode tunneling is to use video buffer directly for encoder,
>>> but currently the encoder doesn’t support interlaced surface, the OMX
>>> decoder set progressive surface before on that purpose.
>>>
>>> Since now we are polling the driver for interlacing information for
>>> decoder, we got the interlaced as preferred as other APIs(VDPAU, VA-API),
>>> thus breaking the transcode with tunneling.
>>>
>>> The solution is when with tunnel detected, re-allocate progressive target
>>> buffers, and then converting the interlaced decoder results to there.
>>>
>>> This has been tested with transcode results bit to bit matching as before
>>> with surface from progressive to progressive.
>>>
>>> Signed-off-by: Leo Liu 
>>> ---
>>>   src/gallium/state_trackers/omx/vid_dec.c | 65
>>> +++-
>>>   src/gallium/state_trackers/omx/vid_dec.h |  6 ++-
>>>   2 files changed, 68 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/src/gallium/state_trackers/omx/vid_dec.c
>>> b/src/gallium/state_trackers/omx/vid_dec.c
>>> index a989c10..7842966 100644
>>> --- a/src/gallium/state_trackers/omx/vid_dec.c
>>> +++ b/src/gallium/state_trackers/omx/vid_dec.c
>>> @@ -167,6 +167,19 @@ static OMX_ERRORTYPE
>>> vid_dec_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam
>>>  if (!priv->pipe)
>>> return OMX_ErrorInsufficientResources;
>>>
>>> +   if (!vl_compositor_init(&priv->compositor, priv->pipe)) {
>>> +  priv->pipe->destroy(priv->pipe);
>>> +  priv->pipe = NULL;
>>> +  return OMX_ErrorInsufficientResources;
>>> +   }
>>> +
>>> +   if (!vl_compositor_init_state(&priv->cstate, priv->pipe)) {
>>> +  vl_compositor_cleanup(&priv->compositor);
>>> +  priv->pipe->destroy(priv->pipe);
>>> +  priv->pipe = NULL;
>>> +  return OMX_ErrorInsufficientResources;
>>> +   }
>>> +()
>>
>> IIRC as vid_dec_Constructor() fails, the caller (bellagio?) explicitly
>> calls the destructor vid_dec_Destructor(). Thus the above teardown
>> should not be needed.
>
>
>
> We take reference of the structure of priv->compositor, and priv->cstate for
> init.
> the init return true or false, and there is no clear flag from compositor
> and cstate to reflect on the success of the init function.
> so we use priv->pipe as a clear flag in order to clean them up at the
> destructor.
>
One could use vl_compositor::pipe and/or ::upload,
vl_compositor_init() was a little more diligent making sure those the
struct is in a consistent state upon error. Same suggestion(s) apply
for vl_compositor_init_state().

Yes, updating(fixing?) those is not the goal is here, yet having
::compositor/::cstate teardown dependant on ::pipe is ambiguous and
error prone.  Something like the following is better imho,

if (priv->cstate.pipe)
  vl_compositor_cleanup_state(&priv->cstate);

As said before - the current code is not wrong by any means, it just
need some minor polish.

>
>>>  priv->sPortTypesParam[OMX_PortDomainVideo].nStartPortNumber = 0;
>>>  priv->sPortTypesParam[OMX_PortDomainVideo].nPorts = 2;
>>>  priv->ports = CALLOC(2, sizeof(omx_base_PortType *));
>>> @@ -218,8 +231,11 @@ static OMX_ERRORTYPE
>>> vid_dec_Destructor(OMX_COMPONENTTYPE *comp)
>>> priv->ports=NULL;
>>>  }
>>>
>>> -   if (priv->pipe)
>>> +   if (priv->pipe) {
>>> +  vl_compositor_cleanup_state(&priv->cstate);
>>> +  vl_compositor_cleanup(&priv->compositor);
>>
>> Neither vl_compositor_cleanup_state() nor vl_compositor_cleanup() is
>> happy if upon deref. the value (pointer again) is NULL.
>>
>> omx/vid_enc.c could use similar cleanups ?
>
> so, if priv->pipe is true,
> it won't be NULL, the cstate and compositor is for sure there.
>
>
> Are I right?
>
Almost. Neither one of ::composuitor nor ::cstate is a pointer, thus
one cannot get a deref in the cleanup funcs. Regardless of the
priv->pipe value.

Thanks for confirming/dismissing my concerns :-)

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


Re: [Mesa-dev] Testing patches 9987 and 9988

2016-07-20 Thread Marek Olšák
On Wed, Jul 20, 2016 at 1:35 PM, ⚛ <0xe2.0x9a.0...@gmail.com> wrote:
> Results for Bioshock Infinite on R9 390:
>
>  TIMEAVG   MIN   MAX
> 2016-05-25.15-51-53: 139.06, 9.81, 1.72, 58.78
> 2016-06-14.01-13-33: 100.91, 16.12, 3.06, 60.06
> 2016-07-07.16-44-55: 95.88, 18.45, 3.74, 68.32
> 2016-07-20.11-55-04: 85.97, 27.20, 4.54, 68.63 (git-0b626d7)
> 2016-07-20.12-17-38: 84.93, 27.72, 4.54, 71.60 (git-3c78d89)
>
> This roughly shows how performance improved over time.
>
> Mesa git-0b626d7 is just before http://patchwork.freedesktop.org/series/9987
>
> Mesa git-3c78d89 is after 9987 has been merged.
>
> The biggest performance change happened between 2016-07-07 and
> 2016-07-20, but I do not have enough data to tell exactly when.

Did you test this?
https://cgit.freedesktop.org/~mareko/mesa/commit/?h=si-mid-ib-gfx-fence&id=a993d93a16da86ef1ead4a55aed969752ad3965a

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


Re: [Mesa-dev] [Mesa-stable] [PATCH] mapi: Export all GLES 3.1 functions in libGLESv2.so

2016-07-20 Thread Andreas Boll
2016-07-19 13:20 GMT+02:00 Emil Velikov :
> On 19 July 2016 at 09:55, Andreas Boll  wrote:
>> Hi,
>>
>> sorry for being late but this patch doesn't mention that all those
>> symbols should be exported in libGL.so too [1].
>> If you look at the history of static_data.py it was mentioned that
>> this list of functions should never grow [2].
>>
> I believe this is a side effect from our mapi python code. Although to
> be perfectly honest, I'm not sure if any of these matter, since
> libglvnd's libGL exports "the world" and my suggestions against doing
> that fell on deaf ears [0].
>
> Thanks
> Emil
>
> [0] https://github.com/NVIDIA/libglvnd/issues/62

Ugh that sounds awful.

Ian, what do you think about this?

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


Re: [Mesa-dev] [PATCH] build: Remove unused AX_CHECK_COMPILE_FLAG macro

2016-07-20 Thread Eric Engestrom
On Wed, Jul 20, 2016 at 11:19:47AM +0200, Andreas Boll wrote:
> Unused since 1a6ae840413d7fb6d2e83f6a83081d5246c7ac9e

Double-checked, and you're right, no reason to leave it in :)
Reviewed-by: Eric Engestrom 

> 
> Signed-off-by: Andreas Boll 
> ---
>  m4/ax_check_compile_flag.m4 | 72 
> -
>  1 file changed, 72 deletions(-)
>  delete mode 100644 m4/ax_check_compile_flag.m4
> 
> diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4
> deleted file mode 100644
> index c3a8d69..000
> --- a/m4/ax_check_compile_flag.m4
> +++ /dev/null
> @@ -1,72 +0,0 @@
> -# ===
> -#   http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
> -# ===
> -#
> -# SYNOPSIS
> -#
> -#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], 
> [EXTRA-FLAGS])
> -#
> -# DESCRIPTION
> -#
> -#   Check whether the given FLAG works with the current language's compiler
> -#   or gives an error.  (Warnings, however, are ignored)
> -#
> -#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
> -#   success/failure.
> -#
> -#   If EXTRA-FLAGS is defined, it is added to the current language's default
> -#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
> -#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
> -#   force the compiler to issue an error when a bad flag is given.
> -#
> -#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
> -#   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
> -#
> -# LICENSE
> -#
> -#   Copyright (c) 2008 Guido U. Draheim 
> -#   Copyright (c) 2011 Maarten Bosmans 
> -#
> -#   This program is free software: you can redistribute it and/or modify it
> -#   under the terms of the GNU General Public License as published by the
> -#   Free Software Foundation, either version 3 of the License, or (at your
> -#   option) any later version.
> -#
> -#   This program is distributed in the hope that it will be useful, but
> -#   WITHOUT ANY WARRANTY; without even the implied warranty of
> -#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
> -#   Public License for more details.
> -#
> -#   You should have received a copy of the GNU General Public License along
> -#   with this program. If not, see .
> -#
> -#   As a special exception, the respective Autoconf Macro's copyright owner
> -#   gives unlimited permission to copy, distribute and modify the configure
> -#   scripts that are the output of Autoconf when processing the Macro. You
> -#   need not follow the terms of the GNU General Public License when using
> -#   or distributing such scripts, even though portions of the text of the
> -#   Macro appear in them. The GNU General Public License (GPL) does govern
> -#   all other use of the material that constitutes the Autoconf Macro.
> -#
> -#   This special exception to the GPL applies to versions of the Autoconf
> -#   Macro released by the Autoconf Archive. When you make and distribute a
> -#   modified version of the Autoconf Macro, you may extend this special
> -#   exception to the GPL to apply to your modified version as well.
> -
> -#serial 2
> -
> -AC_DEFUN([AX_CHECK_COMPILE_FLAG],
> -[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
> -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
> -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
> -  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
> -  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
> -  AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
> -[AS_VAR_SET(CACHEVAR,[yes])],
> -[AS_VAR_SET(CACHEVAR,[no])])
> -  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
> -AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
> -  [m4_default([$2], :)],
> -  [m4_default([$3], :)])
> -AS_VAR_POPDEF([CACHEVAR])dnl
> -])dnl AX_CHECK_COMPILE_FLAGS
> -- 
> 2.1.4
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/10] egl/android: Add fallback to kms_swrast driver

2016-07-20 Thread Rob Herring
On Wed, Jul 20, 2016 at 12:53 AM, Tomasz Figa  wrote:
> On Wed, Jul 20, 2016 at 7:40 AM, Rob Herring  wrote:
>> On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa  wrote:
>>> If no hardware driver is present, it is possible to fall back to
>>> the kms_swrast driver with any DRI node that supports dumb GEM create
>>> and mmap IOCTLs with softpipe/llvmpipe drivers. This patch makes the
>>> Android EGL platform code retry probe with kms_swrast if hardware-only
>>> probe fails.
>>
>> Presumably, you need a gralloc that supports this too? It would be
>> nice to have access to it to reproduce this setup.
>
> Our use case is running the system in Qemu with vgem driver, so our
> gralloc has a backend for vgem. However it should work with any
> available card or render node (more about render nodes below), no
> special support in gralloc really needed. It's just using kms_swrast
> instead of the native driver.

Okay, interesting. I've not really looked at vgem. GBM also has a path
for allocating dumb buffers which I was intending to try and get
working with s/w rendering. Sadly, I've found s/w rendering harder to
get working than h/w rendering.

>> [...]
>>
>>>  #define DRM_RENDER_DEV_NAME  "%s/renderD%d"
>>>
>>>  static int
>>> -droid_open_device(_EGLDisplay *dpy)
>>> +droid_open_device(_EGLDisplay *dpy, int swrast)
>>>  {
>>> struct dri2_egl_display *dri2_dpy = dpy->DriverData;
>>> const int limit = 64;
>>> @@ -933,7 +936,7 @@ droid_open_device(_EGLDisplay *dpy)
>>>if (fd < 0)
>>>   continue;
>>>
>>> -  if (!droid_probe_device(dpy, fd))
>>> +  if (!droid_probe_device(dpy, fd, swrast))
>>
>> This only gets here if a render node is present and successfully
>> opened.
>
> This is the case when HAS_GRALLOC_HEADERS is not defined, which means
> only render nodes are supported. If you look at the other case, it
> will use whatever FD was provided by gralloc using that private
> perform call.
>
>> I would think in the sw rendering case, we want this to work
>> when there's only a card node present. Furthermore, you can't do dumb
>> allocs on a render node, so I don't see how this can work at all.
>
> This is only because the dumb alloc ioctl is not allowed, but that's
> the only thing preventing it from working. We had similar restriction
> put on mmap, but now everyone can just mmap the PRIME FD directly. We
> actually have a patch allowing dumb alloc and mmap ioctls for render
> nodes in our tree, because it makes things like swrast fallback much,
> much easier and doesn't seem to be harmful at all. It might be worth
> discussing this again on dri-devel mailing list.

Yes, bypassing permissions is an easy hack, but I believe what's in
place is by design and you are unlikely to change that. The answer
always seems to be don't use dumb buffers...

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


Re: [Mesa-dev] [PATCH 00/10] egl/android: Improve the Android EGL backend

2016-07-20 Thread Rob Herring
On Mon, Jul 18, 2016 at 11:29 PM, Tomasz Figa  wrote:
> On Tue, Jul 19, 2016 at 12:35 PM, Rob Herring  wrote:
>> On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa  wrote:
>>> Hi,
>>>
>>> This series is a collection of various fixes and extensions we came up
>>> with during our attempt to use Mesa for Android.
>>>
>>> Fixes included in this series:
>>>  - added mandatory EGL_MAX_PBUFFER_WIDTH and _HEIGHT attributes to EGL
>>>configs,
>>>  - fixed multiple issues with handling pbuffers in the backend,
>>>  - found and fixed a DRI image leak,
>>>  - made the implementation of DRI image loader .getBuffers callback
>>>conform better to the extension semantics.
>>>
>>> New features added by this series:
>>>  - possibility to build the Android EGL platform without drm_gralloc
>>>headers,
>>>  - support for creating EGL images from Android native buffers with
>>>YV12 pixel format (prime-only),
>>>  - fallback to kms_swrast driver when no hardware driver can be loaded
>>>but there is still some usable DRI node present in the system.
>>>  - more logging in case of errors to help diagnosing problems.
>>>
>>> Testing was done using classic i965 (gen 8) and gallium softpipe drivers
>>> on an internal build of Android, based on gralloc backed by a DRM render
>>> node and sharing buffers by PRIME FDs.
>>
>> I've tested out patches 1-6 with virgl and I don't get anything
>> displayed. I get this message:
>>
>> EGL-DRI2: Front buffer is not supported for window surfaces
>>
>> That's as far as I investigated. I'll look into it some more tomorrow.
>
> Thanks a lot for testing!
>
> It looks like somehow your driver (or gallium) is triggering a call to
> DRI image loader getBuffers() callback with front buffer bit set in
> the image mask, but window surfaces on Android provide only back
> buffers.

I've debugged this a bit more, but still am not sure what's going on.
Reverting #6 fixes things though. I don't see how a specific driver
would cause the issue here. Here's the call stack for where the
warning is printed:

07-19 21:30:37.750  2153  2153 F DEBUG   : #00 pc fc8d
 /system/lib64/egl/libGLES_mesa.so (droid_image_get_buffers+77)
07-19 21:30:37.750  2153  2153 F DEBUG   : #01 pc 00319554
 /system/lib64/dri/gallium_dri.so (dri2_allocate_textures+660)
07-19 21:30:37.750  2153  2153 F DEBUG   : #02 pc 003157c6
 /system/lib64/dri/gallium_dri.so (dri_st_framebuffer_validate+566)
07-19 21:30:37.750  2153  2153 F DEBUG   : #03 pc 004eadf3
 /system/lib64/dri/gallium_dri.so (st_framebuffer_validate+115)
07-19 21:30:37.750  2153  2153 F DEBUG   : #04 pc 004ead4e
 /system/lib64/dri/gallium_dri.so
(st_manager_validate_framebuffers+78)
07-19 21:30:37.750  2153  2153 F DEBUG   : #05 pc 004c7450
 /system/lib64/dri/gallium_dri.so (st_validate_state+352)
07-19 21:30:37.750  2153  2153 F DEBUG   : #06 pc 004e6d5c
 /system/lib64/dri/gallium_dri.so (st_draw_vbo+172)
07-19 21:30:37.750  2153  2153 F DEBUG   : #07 pc 004acc31
 /system/lib64/dri/gallium_dri.so (vbo_draw_arrays+289)
07-19 21:30:37.750  2153  2153 F DEBUG   : #08 pc 00044dce
 /system/lib64/libsurfaceflinger.so
(android::GLES20RenderEngine::drawMesh(android::Mesh const&)+254)
07-19 21:30:37.750  2153  2153 F DEBUG   : #09 pc 00025af9
 /system/lib64/libsurfaceflinger.so
(android::Layer::drawWithOpenGL(android::sp const&, android::Region const&, bool) const+329)

> My understanding of the semantics was that the callback should deny
> such requests, so that's how I implemented it. However it isn't really
> well documented, so potentially it should only provide buffers that
> are available and ignore the rest without bailing out. Could someone
> more familiar with this extension comment on this?
>
>>
>> Patches 7-10 wouldn't apply. Do you have a git tree with the series?
>
> Hmm, I rebased them on Mesa master just before sending. Let me try to
> create a sandbox branch in our chromium tree.

Turns out to be something in my tree...

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


Re: [Mesa-dev] [PATCH] egl/dri2: Add reference count for dri2_egl_display

2016-07-20 Thread Eric Engestrom
On Wed, Jul 20, 2016 at 04:26:50PM +0800, Nicolas Boichat wrote:
> android.opengl.cts.WrapperTest#testGetIntegerv1 CTS test calls
> eglTerminate, followed by eglReleaseThread. A similar case is
> observed in this bug: https://bugs.freedesktop.org/show_bug.cgi?id=69622,
> where the test calls eglTerminate, then eglMakeCurrent(dpy, NULL, NULL, NULL).
> 
> With the current code, dri2_dpy structure is freed on eglTerminate
> call, so the display is not initialized when eglReleaseThread calls
> MakeCurrent with NULL parameters, to unbind the context, which
> causes a a segfault in drv->API.MakeCurrent (dri2_make_current),
> either in glFlush or in a latter call.
> 
> eglTerminate specifies that "If contexts or surfaces associated
> with display is current to any thread, they are not released until
> they are no longer current as a result of eglMakeCurrent."
> 
> However, to properly free the current context/surface (i.e., call
> glFlush, unbindContext, driDestroyContext), we still need the
> display vtbl (and possibly an active dri dpy connection). Therefore,
> we add some reference counter to dri2_egl_display, to make sure
> the structure is kept allocated as long as it is required.
> 
> Signed-off-by: Nicolas Boichat 

Looks good to me :)
Reviewed-by: Eric Engestrom 

> ---
> 
> Replaces https://patchwork.freedesktop.org/patch/98874/.
> 
>  src/egl/drivers/dri2/egl_dri2.c | 96 
> -
>  src/egl/drivers/dri2/egl_dri2.h |  4 ++
>  2 files changed, 80 insertions(+), 20 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index ac2be86..00269d3 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -761,6 +761,14 @@ dri2_create_screen(_EGLDisplay *disp)
>  static EGLBoolean
>  dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
>  {
> +   EGLBoolean ret = EGL_FALSE;
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> +
> +   if (dri2_dpy) {
> +  dri2_dpy->ref_count++;
> +  return EGL_TRUE;
> +   }
> +
> /* not until swrast_dri is supported */
> if (disp->Options.UseFallback)
>return EGL_FALSE;
> @@ -769,52 +777,75 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
>  #ifdef HAVE_SURFACELESS_PLATFORM
> case _EGL_PLATFORM_SURFACELESS:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_surfaceless(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_surfaceless(drv, disp);
> +  break;
>  #endif
> -
>  #ifdef HAVE_X11_PLATFORM
> case _EGL_PLATFORM_X11:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_x11(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_x11(drv, disp);
> +  break;
>  #endif
> -
>  #ifdef HAVE_DRM_PLATFORM
> case _EGL_PLATFORM_DRM:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_drm(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_drm(drv, disp);
> +  break;
>  #endif
>  #ifdef HAVE_WAYLAND_PLATFORM
> case _EGL_PLATFORM_WAYLAND:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_wayland(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_wayland(drv, disp);
> +  break;
>  #endif
>  #ifdef HAVE_ANDROID_PLATFORM
> case _EGL_PLATFORM_ANDROID:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_android(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_android(drv, disp);
> +  break;
>  #endif
> -
> default:
>_eglLog(_EGL_WARNING, "No EGL platform enabled.");
>return EGL_FALSE;
> }
> +
> +   if (ret) {
> +  dri2_dpy = dri2_egl_display(disp);
> +
> +  if (!dri2_dpy) {
> + return EGL_FALSE;
> +  }
> +
> +  dri2_dpy->ref_count++;
> +   }
> +
> +   return ret;
>  }
>  
>  /**
> - * Called via eglTerminate(), drv->API.Terminate().
> + * Decrement display reference count, and free up display if necessary.
>   */
> -static EGLBoolean
> -dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
> -{
> +static void
> +dri2_display_release(_EGLDisplay *disp) {
> struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> unsigned i;
>  
> -   _eglReleaseDisplayResources(drv, disp);
> +   assert(dri2_dpy->ref_count > 0);
> +   dri2_dpy->ref_count--;
> +
> +   if (dri2_dpy->ref_count > 0)
> +  return;
> +
> _eglCleanupDisplay(disp);
>  
> if (dri2_dpy->own_dri_screen)
> @@ -869,6 +900,21 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
> }
> free(dri2_dpy);
> disp->DriverData = NULL;
> +}
> +
> +/**
> + * Called via eglTerminate(), drv->API.Terminate().
> + *
> + * This must be guaranteed to be called exactly once, even i

Re: [Mesa-dev] [PATCH] egl/dri2: Add reference count for dri2_egl_display

2016-07-20 Thread Emil Velikov
On 20 July 2016 at 09:26, Nicolas Boichat  wrote:
> android.opengl.cts.WrapperTest#testGetIntegerv1 CTS test calls
> eglTerminate, followed by eglReleaseThread. A similar case is
> observed in this bug: https://bugs.freedesktop.org/show_bug.cgi?id=69622,
> where the test calls eglTerminate, then eglMakeCurrent(dpy, NULL, NULL, NULL).
>
> With the current code, dri2_dpy structure is freed on eglTerminate
> call, so the display is not initialized when eglReleaseThread calls
> MakeCurrent with NULL parameters, to unbind the context, which
> causes a a segfault in drv->API.MakeCurrent (dri2_make_current),
> either in glFlush or in a latter call.
>
> eglTerminate specifies that "If contexts or surfaces associated
> with display is current to any thread, they are not released until
> they are no longer current as a result of eglMakeCurrent."
>
> However, to properly free the current context/surface (i.e., call
> glFlush, unbindContext, driDestroyContext), we still need the
> display vtbl (and possibly an active dri dpy connection). Therefore,
> we add some reference counter to dri2_egl_display, to make sure
> the structure is kept allocated as long as it is required.
>
Looks very, just a couple of suggestions below.

> Signed-off-by: Nicolas Boichat 
> ---
>
> Replaces https://patchwork.freedesktop.org/patch/98874/.
>
>  src/egl/drivers/dri2/egl_dri2.c | 96 
> -
>  src/egl/drivers/dri2/egl_dri2.h |  4 ++
>  2 files changed, 80 insertions(+), 20 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index ac2be86..00269d3 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -761,6 +761,14 @@ dri2_create_screen(_EGLDisplay *disp)
>  static EGLBoolean
>  dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
>  {
> +   EGLBoolean ret = EGL_FALSE;
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> +
> +   if (dri2_dpy) {
> +  dri2_dpy->ref_count++;
> +  return EGL_TRUE;
> +   }
> +
I'm not sure that reusing the dpy is what we want here. IMHO we should
either call dri2_display_release (to release existing resources) or
simply error out.

> /* not until swrast_dri is supported */
> if (disp->Options.UseFallback)
>return EGL_FALSE;
> @@ -769,52 +777,75 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
>  #ifdef HAVE_SURFACELESS_PLATFORM
> case _EGL_PLATFORM_SURFACELESS:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_surfaceless(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_surfaceless(drv, disp);
> +  break;
>  #endif
> -
>  #ifdef HAVE_X11_PLATFORM
> case _EGL_PLATFORM_X11:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_x11(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_x11(drv, disp);
> +  break;
>  #endif
> -
>  #ifdef HAVE_DRM_PLATFORM
> case _EGL_PLATFORM_DRM:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_drm(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_drm(drv, disp);
> +  break;
>  #endif
>  #ifdef HAVE_WAYLAND_PLATFORM
> case _EGL_PLATFORM_WAYLAND:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_wayland(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_wayland(drv, disp);
> +  break;
>  #endif
>  #ifdef HAVE_ANDROID_PLATFORM
> case _EGL_PLATFORM_ANDROID:
>if (disp->Options.TestOnly)
> - return EGL_TRUE;
> -  return dri2_initialize_android(drv, disp);
> + ret = EGL_TRUE;
> +  else
> + ret = dri2_initialize_android(drv, disp);
> +  break;
>  #endif
> -
> default:
>_eglLog(_EGL_WARNING, "No EGL platform enabled.");
>return EGL_FALSE;
> }
> +
> +   if (ret) {
> +  dri2_dpy = dri2_egl_display(disp);
> +
> +  if (!dri2_dpy) {
> + return EGL_FALSE;
> +  }
> +
> +  dri2_dpy->ref_count++;
> +   }
> +
This should really be part of a dri2_initialize_screen or similar
helper and we ought to fix our dri2_initialize_$platform functions to
leave the base struct _EGLdisplay unchanged upon error. Atm, the
latter can return a non-null dri2_dpy, thus above (new code) will
crash.

^^ Just an idea for follow-up patch(es).

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


Re: [Mesa-dev] [PATCH] build: Remove unused AX_CHECK_COMPILE_FLAG macro

2016-07-20 Thread Emil Velikov
On 20 July 2016 at 10:19, Andreas Boll  wrote:
> Unused since 1a6ae840413d7fb6d2e83f6a83081d5246c7ac9e
>

Indeed it is. Thanks !
Reviewed-by: Emil Velikov 

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


Re: [Mesa-dev] [PATCH] gallium/util: Fix debug_printf under Haiku

2016-07-20 Thread Emil Velikov
On 19 July 2016 at 03:12, Alexander von Gluck IV  wrote:
> July 18 2016 1:10 PM, "Emil Velikov"  wrote:
>> On 18 July 2016 at 16:28, Alexander von Gluck IV  
>> wrote:
>>
>>> July 18 2016 9:20 AM, "Emil Velikov"  wrote:
 On 18 July 2016 at 14:39, Alexander von Gluck IV  
 wrote:

> July 18 2016 3:29 AM, "Nicolai Hähnle"  wrote:
>> A comment further up in the same file says
>>
>> /* Haiku provides debug_printf in libroot with OS.h */
>>
>> Is that no longer true?
>>
>> Nicolai
>>
>> On 16.07.2016 16:27, Alexander von Gluck IV wrote:
>>
>>> ---
>>> src/gallium/auxiliary/util/u_debug.h | 5 -
>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/gallium/auxiliary/util/u_debug.h 
>>> b/src/gallium/auxiliary/util/u_debug.h
>>> index 7da7f53..7dc4ce8 100644
>>> --- a/src/gallium/auxiliary/util/u_debug.h
>>> +++ b/src/gallium/auxiliary/util/u_debug.h
>>> @@ -83,7 +83,10 @@ _debug_printf(const char *format, ...)
>>> * - avoid outputing large strings (512 bytes is the current maximum 
>>> length
>>> * that is guaranteed to be printed in all platforms)
>>> */
>>> -#if !defined(PIPE_OS_HAIKU)
>>> +#if defined(PIPE_OS_HAIKU)
>>> +void
>>> +debug_printf(const char *format, ...) _util_printf_format(1,2);
>>> +#else
>>> static inline void
>>> debug_printf(const char *format, ...) _util_printf_format(1,2);

 Hmm I moved the include further up with commit
 373f118c6c750d717fd0727fc3fc191828714c6f although that should not have
 made any difference, barring fragile include file order. Can you check
 if reverting the u_debug.h gets you up and running ? If so can you
 please:
 - Please add the stable tag Cc: 
 - Attempt to straighten the includes (it might be mesa, llvm and/or
 Haiku that is getting confused)

> It's still true, however without the _util_printf_format I get odd llvm
> symbol errors.

 I would suspect that the above is in play, but without details
 (build/error log) little to no one will be able to tell you if this is
 the correct fix, I'm afraid.
>>>
>>> gcc 5.4.0 / llvm 3.8.0
>>> Sorry, I wasn't near the machine, here is the error without any changes:
>>>
>>> src/gallium/auxiliary/gallivm/lp_bld_assert.c: In function 'lp_assert':
>>> src/gallium/auxiliary/gallivm/lp_bld_assert.c:43:7: warning: implicit 
>>> declaration of function
>>> 'debug_printf' [-Wimplicit-function-declaration]
>>> debug_printf("LLVM assertion '%s' failed!\n", msg);
>>> ^
>>
>> Ok, this happens as PIPE_OS_HAIKU isn't defined that early in
>> u_debug.h, thus the header is not included
>>
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_const.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_conv.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_debug.cpp ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_flow.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_format_aos.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_format_cached.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_format_float.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_format.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_format_soa.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_format_srgb.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_format_yuv.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_gather.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_init.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_intr.c ...
>>> src/gallium/auxiliary/gallivm/lp_bld_intr.c: In function 
>>> 'lp_build_intrinsic_binary_anylength':
>>> src/gallium/auxiliary/gallivm/lp_bld_intr.c:252:10: warning: implicit 
>>> declaration of function
>>> 'debug_printf' [-Wimplicit-function-declaration]
>>> debug_printf("%s: should handle arbitrary vector size\n",
>>> ^
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_logic.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_misc.cpp ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_pack.c ...
>>> Compiling src/gallium/auxiliary/gallivm/lp_bld_printf.c ...
>>> src/gallium/auxiliary/gallivm/lp_bld_printf.c: In function 
>>> 'lp_build_print_args':
>>> src/gallium/auxiliary/gallivm/lp_bld_printf.c:68:84: error: 'debug_printf' 
>>> undeclared (first use in
>>> this function)
>>> func_printf = lp_build_const_int_pointer(gallivm, 
>>> func_to_pointer((func_pointer)debug_printf));
>>> ^
>>> src/gallium/auxiliary/gallivm/lp_bld_printf.c:68:84: note: each undeclared 
>>> identifier is reported
>>> only once for each function it appears in
>>> scons: *** 
>>> [build/haiku-x86_64-debug/gallium/auxiliary/gallivm/lp_bld_printf.os] Error 
>>> 1
>>>
>>> debug_printf is definitely declared however (and it should be all c code, 
>>> no C++ thus no mang

Re: [Mesa-dev] Mesa (master): Revert "radeon/llvm: Use alloca instructions for larger arrays"

2016-07-20 Thread Michel Dänzer
On 15.07.2016 05:15, Marek =?UNKNOWN?B?T2zFocOhaw==?= wrote:
> Module: Mesa
> Branch: master
> Commit: f84e9d749fbb6da73a60fb70e6725db773c9b8f8
> URL:
> http://cgit.freedesktop.org/mesa/mesa/commit/?id=f84e9d749fbb6da73a60fb70e6725db773c9b8f8
> 
> Author: Marek Olšák 
> Date:   Thu Jul 14 22:07:46 2016 +0200
> 
> Revert "radeon/llvm: Use alloca instructions for larger arrays"
> 
> This reverts commit 513fccdfb68e6a71180e21827f071617c93fd09b.
> 
> Bioshock Infinite hangs with that.

Unfortunately, this change caused the piglit test
shaders@glsl-fs-vec4-indexing-temp-dst-in-loop (and possibly others) to
hang my Kaveri. Any ideas for how we can get out of this conundrum?


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/15] i965: bring back type_size_vec4_times_4()

2016-07-20 Thread Alejandro Piñeiro
Reviewed-by: Alejandro Piñeiro 


On 19/07/16 08:33, Timothy Arceri wrote:
> We will use this for output varyings. To make component
> packing simpler we will just treat all varyings as vec4s.
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp   | 13 +
>  src/mesa/drivers/dri/i965/brw_shader.h |  1 +
>  2 files changed, 14 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 120d6dd..547a0c2 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -506,6 +506,19 @@ type_size_scalar(const struct glsl_type *type)
> return 0;
>  }
>  
> +/**
> + * Returns the number of scalar components needed to store type, assuming
> + * that vectors are padded out to vec4.
> + *
> + * This has the packing rules of type_size_vec4(), but counts components
> + * similar to type_size_scalar().
> + */
> +extern "C" int
> +type_size_vec4_times_4(const struct glsl_type *type)
> +{
> + return 4 * type_size_vec4(type);
> +}
> +
>  /* Attribute arrays are loaded as one vec4 per element (or matrix column),
>   * except for double-precision types, which are loaded as one dvec4.
>   */
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.h 
> b/src/mesa/drivers/dri/i965/brw_shader.h
> index dd9eb2d..e61c080 100644
> --- a/src/mesa/drivers/dri/i965/brw_shader.h
> +++ b/src/mesa/drivers/dri/i965/brw_shader.h
> @@ -294,6 +294,7 @@ struct gl_linked_shader *brw_new_shader(gl_shader_stage 
> stage);
>  int type_size_scalar(const struct glsl_type *type);
>  int type_size_vec4(const struct glsl_type *type);
>  int type_size_dvec4(const struct glsl_type *type);
> +int type_size_vec4_times_4(const struct glsl_type *type);
>  int type_size_vs_input(const struct glsl_type *type);
>  
>  unsigned tesslevel_outer_components(GLenum tes_primitive_mode);

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


Re: [Mesa-dev] [PATCH 02/15] i965: enable component packing for vs and fs

2016-07-20 Thread Alejandro Piñeiro
On 19/07/16 08:33, Timothy Arceri wrote:
> Rather than trying to work out the total number of components
> used at a location we simply treat all outputs as vec4s.

Probably it would be good to explain a little the why on the commit
message, and not just the what. In either case:
Reviewed-by: Alejandro Piñeiro 

> ---
>  src/mesa/drivers/dri/i965/brw_fs.h   |  1 -
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 22 ++
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 10 ++
>  src/mesa/drivers/dri/i965/brw_nir.c  |  8 
>  4 files changed, 16 insertions(+), 25 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
> b/src/mesa/drivers/dri/i965/brw_fs.h
> index 574475f..fc1e1c4 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.h
> +++ b/src/mesa/drivers/dri/i965/brw_fs.h
> @@ -317,7 +317,6 @@ public:
> fs_reg frag_stencil;
> fs_reg sample_mask;
> fs_reg outputs[VARYING_SLOT_MAX];
> -   unsigned output_components[VARYING_SLOT_MAX];
> fs_reg dual_src_output;
> bool do_dual_src;
> int first_non_payload_grf;
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> index 610c151..395594f 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -67,13 +67,12 @@ fs_visitor::nir_setup_single_output_varying(fs_reg *reg,
>}
> } else {
>assert(type->is_scalar() || type->is_vector());
> -  unsigned num_elements = type->vector_elements;
> +  unsigned num_iter = 1;
>if (type->is_double())
> - num_elements *= 2;
> -  for (unsigned count = 0; count < num_elements; count += 4) {
> + num_iter = 2;
> +  for (unsigned count = 0; count < num_iter; count++) {
>   this->outputs[*location] = *reg;
> - this->output_components[*location] = MIN2(4, num_elements - count);
> - *reg = offset(*reg, bld, this->output_components[*location]);
> + *reg = offset(*reg, bld, 4);
>   (*location)++;
>}
> }
> @@ -114,7 +113,6 @@ fs_visitor::nir_setup_outputs()
>  /* Writing gl_FragColor outputs to all color regions. */
>  for (unsigned int i = 0; i < MAX2(key->nr_color_regions, 1); 
> i++) {
> this->outputs[i] = reg;
> -   this->output_components[i] = 4;
>  }
>   } else if (var->data.location == FRAG_RESULT_DEPTH) {
>  this->frag_depth = reg;
> @@ -123,8 +121,6 @@ fs_visitor::nir_setup_outputs()
>   } else if (var->data.location == FRAG_RESULT_SAMPLE_MASK) {
>  this->sample_mask = reg;
>   } else {
> -int vector_elements = 
> var->type->without_array()->vector_elements;
> -
>  /* gl_FragData or a user-defined FS output */
>  assert(var->data.location >= FRAG_RESULT_DATA0 &&
> var->data.location < 
> FRAG_RESULT_DATA0+BRW_MAX_DRAW_BUFFERS);
> @@ -132,8 +128,7 @@ fs_visitor::nir_setup_outputs()
>  /* General color output. */
>  for (unsigned int i = 0; i < MAX2(1, var->type->length); i++) {
> int output = var->data.location - FRAG_RESULT_DATA0 + i;
> -   this->outputs[output] = offset(reg, bld, vector_elements * i);
> -   this->output_components[output] = vector_elements;
> +   this->outputs[output] = offset(reg, bld, 4 * i);
>  }
>   }
>   break;
> @@ -3892,6 +3887,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, 
> nir_intrinsic_instr *instr
>  
> case nir_intrinsic_load_input: {
>fs_reg src = fs_reg(ATTR, instr->const_index[0], dest.type);
> +  unsigned first_component = nir_intrinsic_component(instr);
>unsigned num_components = instr->num_components;
>enum brw_reg_type type = dest.type;
>  
> @@ -3900,7 +3896,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, 
> nir_intrinsic_instr *instr
>src = offset(src, bld, const_offset->u32[0]);
>  
>for (unsigned j = 0; j < num_components; j++) {
> - bld.MOV(offset(dest, bld, j), offset(src, bld, j));
> + bld.MOV(offset(dest, bld, j), offset(src, bld, j + 
> first_component));
>}
>  
>if (type == BRW_REGISTER_TYPE_DF) {
> @@ -4026,6 +4022,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, 
> nir_intrinsic_instr *instr
>new_dest = offset(new_dest, bld, const_offset->u32[0]);
>  
>unsigned num_components = instr->num_components;
> +  unsigned first_component = nir_intrinsic_component(instr);
>unsigned bit_size = instr->src[0].is_ssa ?
>   instr->src[0].ssa->bit_size : instr->src[0].reg.reg->bit_size;
>if (bit_size == 64) {
> @@ -4039,7 +4036,8 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, 
> nir_intrinsic_instr *instr
>}
>  
>for (unsigned j = 0; j < num_components; j++) {
> -

Re: [Mesa-dev] [PATCH 03/15] i965: add component packing support for load_output intrinsics

2016-07-20 Thread Alejandro Piñeiro
I miss a little explanation on the commit message (like on commit 8),
but that is just personal preference (and in general I personally tend
to be too verbose on the commit messages).

Either if you add a little explanation or not:

Reviewed-by: Alejandro Piñeiro 


On 19/07/16 08:33, Timothy Arceri wrote:
> ---
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 38 
> +++-
>  1 file changed, 33 insertions(+), 5 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> index 395594f..e75e7f7 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -2481,6 +2481,7 @@ fs_visitor::nir_emit_tcs_intrinsic(const fs_builder 
> &bld,
> case nir_intrinsic_load_per_vertex_output: {
>fs_reg indirect_offset = get_indirect_offset(instr);
>unsigned imm_offset = instr->const_index[0];
> +  unsigned first_component = nir_intrinsic_component(instr);
>  
>fs_inst *inst;
>if (indirect_offset.file == BAD_FILE) {
> @@ -2561,10 +2562,24 @@ fs_visitor::nir_emit_tcs_intrinsic(const fs_builder 
> &bld,
>  }
>  bld.LOAD_PAYLOAD(dst, srcs, num_components, 0);
>   } else {
> -inst = bld.emit(SHADER_OPCODE_URB_READ_SIMD8, dst, patch_handle);
> +if (first_component != 0) {
> +   unsigned read_components =
> +  instr->num_components + first_component;
> +   fs_reg tmp = bld.vgrf(dst.type, read_components);
> +   inst = bld.emit(SHADER_OPCODE_URB_READ_SIMD8, tmp,
> +   patch_handle);
> +   inst->regs_written = read_components;
> +   for (unsigned i = 0; i < instr->num_components; i++) {
> +  bld.MOV(offset(dst, bld, i),
> +  offset(tmp, bld, i + first_component));
> +   }
> +} else {
> +   inst = bld.emit(SHADER_OPCODE_URB_READ_SIMD8, dst,
> +   patch_handle);
> +   inst->regs_written = instr->num_components;
> +}
>  inst->offset = imm_offset;
>  inst->mlen = 1;
> -inst->regs_written = instr->num_components;
>   }
>} else {
>   /* Indirect indexing - use per-slot offsets as well. */
> @@ -2574,11 +2589,24 @@ fs_visitor::nir_emit_tcs_intrinsic(const fs_builder 
> &bld,
>   };
>   fs_reg payload = bld.vgrf(BRW_REGISTER_TYPE_UD, 2);
>   bld.LOAD_PAYLOAD(payload, srcs, ARRAY_SIZE(srcs), 0);
> -
> - inst = bld.emit(SHADER_OPCODE_URB_READ_SIMD8_PER_SLOT, dst, 
> payload);
> + if (first_component != 0) {
> +unsigned read_components =
> +   instr->num_components + first_component;
> +fs_reg tmp = bld.vgrf(dst.type, read_components);
> +inst = bld.emit(SHADER_OPCODE_URB_READ_SIMD8_PER_SLOT, tmp,
> +payload);
> +inst->regs_written = read_components;
> +for (unsigned i = 0; i < instr->num_components; i++) {
> +   bld.MOV(offset(dst, bld, i),
> +   offset(tmp, bld, i + first_component));
> +}
> + } else {
> +inst = bld.emit(SHADER_OPCODE_URB_READ_SIMD8_PER_SLOT, dst,
> +payload);
> +inst->regs_written = instr->num_components;
> + }
>   inst->offset = imm_offset;
>   inst->mlen = 2;
> - inst->regs_written = instr->num_components;
>}
>break;
> }

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


Re: [Mesa-dev] [PATCH 00/10] egl/android: Improve the Android EGL backend

2016-07-20 Thread Emil Velikov
On 15 July 2016 at 08:53, Tomasz Figa  wrote:
> Hi,
>
> This series is a collection of various fixes and extensions we came up
> with during our attempt to use Mesa for Android.
>
> Fixes included in this series:
>  - added mandatory EGL_MAX_PBUFFER_WIDTH and _HEIGHT attributes to EGL
>configs,
>  - fixed multiple issues with handling pbuffers in the backend,
>  - found and fixed a DRI image leak,
>  - made the implementation of DRI image loader .getBuffers callback
>conform better to the extension semantics.
>
> New features added by this series:
>  - possibility to build the Android EGL platform without drm_gralloc
>headers,
>  - support for creating EGL images from Android native buffers with
>YV12 pixel format (prime-only),
>  - fallback to kms_swrast driver when no hardware driver can be loaded
>but there is still some usable DRI node present in the system.
>  - more logging in case of errors to help diagnosing problems.
>
> Testing was done using classic i965 (gen 8) and gallium softpipe drivers
> on an internal build of Android, based on gralloc backed by a DRM render
> node and sharing buffers by PRIME FDs.
>
> Haixia Shi (1):
>   egl/android: Set EGL_MAX_PBUFFER_WIDTH and EGL_MAX_PBUFFER_HEIGHT
>
> Nicolas Boichat (1):
>   egl/android: Fix support for pbuffers
>
> Tomasz Figa (8):
>   egl/android: Check return value of dri2_get_dri_config()
>   egl/android: Add some useful error messages
>   egl/android: Stop leaking DRI images
I've pushed the above three from this series as the rest either cause
issues or might need a bit of polish.
Thanks for sending these, and huge shout out to Eric for having a look :-)

Btw, I've also pushed your earlier (standalone) patches:
 gallium/dri: Add shared glapi to LIBADD on Android
 egl/android: Remove unused variables
 i965: store reference to the context within struct brw_fence (v2)

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


Re: [Mesa-dev] [PATCH] egl/dri2: Add reference count for dri2_egl_display

2016-07-20 Thread Emil Velikov
On 20 July 2016 at 15:42, Emil Velikov  wrote:
> On 20 July 2016 at 09:26, Nicolas Boichat  wrote:
>> android.opengl.cts.WrapperTest#testGetIntegerv1 CTS test calls
>> eglTerminate, followed by eglReleaseThread. A similar case is
>> observed in this bug: https://bugs.freedesktop.org/show_bug.cgi?id=69622,
>> where the test calls eglTerminate, then eglMakeCurrent(dpy, NULL, NULL, 
>> NULL).
>>
>> With the current code, dri2_dpy structure is freed on eglTerminate
>> call, so the display is not initialized when eglReleaseThread calls
>> MakeCurrent with NULL parameters, to unbind the context, which
>> causes a a segfault in drv->API.MakeCurrent (dri2_make_current),
>> either in glFlush or in a latter call.
>>
>> eglTerminate specifies that "If contexts or surfaces associated
>> with display is current to any thread, they are not released until
>> they are no longer current as a result of eglMakeCurrent."
>>
>> However, to properly free the current context/surface (i.e., call
>> glFlush, unbindContext, driDestroyContext), we still need the
>> display vtbl (and possibly an active dri dpy connection). Therefore,
>> we add some reference counter to dri2_egl_display, to make sure
>> the structure is kept allocated as long as it is required.
>>
> Looks very, just a couple of suggestions below.
>
>> Signed-off-by: Nicolas Boichat 
>> ---
>>
>> Replaces https://patchwork.freedesktop.org/patch/98874/.
>>
>>  src/egl/drivers/dri2/egl_dri2.c | 96 
>> -
>>  src/egl/drivers/dri2/egl_dri2.h |  4 ++
>>  2 files changed, 80 insertions(+), 20 deletions(-)
>>
>> diff --git a/src/egl/drivers/dri2/egl_dri2.c 
>> b/src/egl/drivers/dri2/egl_dri2.c
>> index ac2be86..00269d3 100644
>> --- a/src/egl/drivers/dri2/egl_dri2.c
>> +++ b/src/egl/drivers/dri2/egl_dri2.c
>> @@ -761,6 +761,14 @@ dri2_create_screen(_EGLDisplay *disp)
>>  static EGLBoolean
>>  dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
>>  {
>> +   EGLBoolean ret = EGL_FALSE;
>> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
>> +
>> +   if (dri2_dpy) {
>> +  dri2_dpy->ref_count++;
>> +  return EGL_TRUE;
>> +   }
>> +
> I'm not sure that reusing the dpy is what we want here. IMHO we should
> either call dri2_display_release (to release existing resources) or
> simply error out.
>
A bit more meat to it:
Upper layer(s) will ensure that upon second call to eglInitialize
(without a eglTerminate in between) we won't get here. Thus only case
we get this is on user misuse/leak  - missing explicit/implicit
eglMakeCurrent(...NULL, NULL) call while having called eglTerminate.

If we ref count we exacerbate the leak. At the same time, returning
error in case of a user leak sounds silly, so dri2_display_release
might be like the better option ?

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


Re: [Mesa-dev] [PATCH 04/15] nir: add doubles component packing support

2016-07-20 Thread Alejandro Piñeiro
On 19/07/16 08:33, Timothy Arceri wrote:
> This makes sure we give the correct driver location
> for doubles when using component packing.

Taking into account that the commit is about give the correct location
for the dvec3 case, probably it is worth to mention on the commit message.

> ---
>  src/compiler/nir/nir_lower_io.c | 16 
>  1 file changed, 16 insertions(+)
>
> diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
> index e480264..7a72e69 100644
> --- a/src/compiler/nir/nir_lower_io.c
> +++ b/src/compiler/nir/nir_lower_io.c
> @@ -75,6 +75,22 @@ nir_assign_var_locations(struct exec_list *var_list, 
> unsigned *size,
>   if (locations[idx][var->data.index] == -1) {
>  var->data.driver_location = location;
>  locations[idx][var->data.index] = location;
> +
> +/* A dvec3 can be packed with a double we need special handling
> + * for this as we are packing across two locations.
> + */
> +if (glsl_get_base_type(var->type) == GLSL_TYPE_DOUBLE &&
> +glsl_get_vector_elements(var->type) == 3) {
> +   /* Hack around type_size functions that expect vectors to be
> +* padded out to vec4.
> +*/
> +   unsigned dsize = type_size(glsl_double_type());
> +   unsigned offset =
> +  dsize == type_size(glsl_float_type()) ? dsize : dsize * 2;

This is hackish indeed, and somewhat complex to understand (assuming
that Im properly understanding it).  Assuming that there isn't a better
way to express this on code, and in the risk of becoming an
add-more-comments-pain-in-the-neck, probably it is worth to expand a
little the comment below.

> +
> +   locations[idx + 1][var->data.index] = location + offset;
> +}
> +
>  location += type_size(var->type);
>   } else {
>  var->data.driver_location = locations[idx][var->data.index];

In any case:
Reviewed-by: Alejandro Piñeiro 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 08/15] i965/vec4: add support for packing vs/gs/tes outputs

2016-07-20 Thread Alejandro Piñeiro
Reviewed-by: Alejandro Piñeiro 


On 19/07/16 08:33, Timothy Arceri wrote:
> Here we create a new output_generic_reg array with the ability to
> store the dst_reg for each component of user defined varyings.
> This is needed as the previous code only stored the dst_reg based
> on the varying location which meant packed varyings would overwrite
> each other.
> ---
>  src/mesa/drivers/dri/i965/brw_vec4.h   |  3 +++
>  src/mesa/drivers/dri/i965/brw_vec4_nir.cpp |  9 ++-
>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 37 
> +++---
>  3 files changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
> b/src/mesa/drivers/dri/i965/brw_vec4.h
> index 3043147..4236b51 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4.h
> +++ b/src/mesa/drivers/dri/i965/brw_vec4.h
> @@ -114,6 +114,8 @@ public:
>  * for the ir->location's used.
>  */
> dst_reg output_reg[BRW_VARYING_SLOT_COUNT];
> +   dst_reg output_generic_reg[MAX_VARYINGS_INCL_PATCH][4];
> +   unsigned output_generic_num_components[MAX_VARYINGS_INCL_PATCH][4];
> const char *output_reg_annotation[BRW_VARYING_SLOT_COUNT];
> int uniforms;
>  
> @@ -270,6 +272,7 @@ public:
> void emit_ndc_computation();
> void emit_psiz_and_flags(dst_reg reg);
> vec4_instruction *emit_generic_urb_slot(dst_reg reg, int varying);
> +   void emit_generic_urb_slot(dst_reg reg, int varying, int component);
> virtual void emit_urb_slot(dst_reg reg, int varying);
>  
> void emit_shader_time_begin();
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp 
> b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> index 33ad852..e5a091d 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> @@ -416,7 +416,14 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr 
> *instr)
>src = get_nir_src(instr->src[0], BRW_REGISTER_TYPE_F,
>  instr->num_components);
>  
> -  output_reg[varying] = dst_reg(src);
> +  if (varying >= VARYING_SLOT_VAR0) {
> + unsigned c = nir_intrinsic_component(instr);
> + unsigned v = varying - VARYING_SLOT_VAR0;
> + output_generic_reg[v][c] = dst_reg(src);
> + output_generic_num_components[v][c] = instr->num_components;
> +  } else {
> + output_reg[varying] = dst_reg(src);
> +  }
>break;
> }
>  
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
> b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> index 652b453..e6eea69 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> @@ -1279,13 +1279,35 @@ vec4_visitor::emit_generic_urb_slot(dst_reg reg, int 
> varying)
> assert(varying < VARYING_SLOT_MAX);
> assert(output_reg[varying].type == reg.type);
> current_annotation = output_reg_annotation[varying];
> -   if (output_reg[varying].file != BAD_FILE)
> +   if (output_reg[varying].file != BAD_FILE) {
>return emit(MOV(reg, src_reg(output_reg[varying])));
> -   else
> +   } else
>return NULL;
>  }
>  
>  void
> +vec4_visitor::emit_generic_urb_slot(dst_reg reg, int varying, int component)
> +{
> +   assert(varying < VARYING_SLOT_MAX);
> +   assert(varying >= VARYING_SLOT_VAR0);
> +   varying = varying - VARYING_SLOT_VAR0;
> +
> +   unsigned num_comps = output_generic_num_components[varying][component];
> +   if (num_comps == 0)
> +  return;
> +
> +   assert(output_generic_reg[varying][component].type == reg.type);
> +   current_annotation = output_reg_annotation[varying];
> +   if (output_generic_reg[varying][component].file != BAD_FILE) {
> +  src_reg src = src_reg(output_generic_reg[varying][component]);
> +  src.swizzle = BRW_SWZ_COMP_OUTPUT(component);
> +  reg.writemask =
> + brw_writemask_for_component_packing(num_comps, component);
> +  emit(MOV(reg, src));
> +   }
> +}
> +
> +void
>  vec4_visitor::emit_urb_slot(dst_reg reg, int varying)
>  {
> reg.type = BRW_REGISTER_TYPE_F;
> @@ -1324,7 +1346,13 @@ vec4_visitor::emit_urb_slot(dst_reg reg, int varying)
>/* No need to write to this slot */
>break;
> default:
> -  emit_generic_urb_slot(reg, varying);
> +  if (varying >= VARYING_SLOT_VAR0) {
> + for (int i = 0; i < 4; i++) {
> +emit_generic_urb_slot(reg, varying, i);
> + }
> +  } else {
> + emit_generic_urb_slot(reg, varying);
> +  }
>break;
> }
>  }
> @@ -1772,6 +1800,9 @@ vec4_visitor::vec4_visitor(const struct brw_compiler 
> *compiler,
> this->current_annotation = NULL;
> memset(this->output_reg_annotation, 0, 
> sizeof(this->output_reg_annotation));
>  
> +   memset(this->output_generic_num_components, 0,
> +  sizeof(this->output_generic_num_components));
> +
> this->virtual_grf_start = NULL;
> this->virtual_grf_end = NULL;
> this->live_intervals = NULL;

___

Re: [Mesa-dev] [PATCH 12/15] i965/vec4: add support for packing tes inputs

2016-07-20 Thread Alejandro Piñeiro
Reviewed-by: Alejandro Piñeiro 


On 19/07/16 08:33, Timothy Arceri wrote:
> ---
>  src/mesa/drivers/dri/i965/brw_vec4_tes.cpp | 14 ++
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_tes.cpp 
> b/src/mesa/drivers/dri/i965/brw_vec4_tes.cpp
> index 6639c86..8266a9d 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_tes.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_tes.cpp
> @@ -177,7 +177,9 @@ vec4_tes_visitor::nir_emit_intrinsic(nir_intrinsic_instr 
> *instr)
> case nir_intrinsic_load_input:
> case nir_intrinsic_load_per_vertex_input: {
>src_reg indirect_offset = get_indirect_offset(instr);
> +  dst_reg dst = get_nir_dest(instr->dest, BRW_REGISTER_TYPE_D);
>unsigned imm_offset = instr->const_index[0];
> +  unsigned fist_component = nir_intrinsic_component(instr);
>src_reg header = input_read_header;
>  
>if (indirect_offset.file != BAD_FILE) {
> @@ -190,8 +192,10 @@ vec4_tes_visitor::nir_emit_intrinsic(nir_intrinsic_instr 
> *instr)
>*/
>   const unsigned max_push_slots = 24;
>   if (imm_offset < max_push_slots) {
> -emit(MOV(get_nir_dest(instr->dest, BRW_REGISTER_TYPE_D),
> - src_reg(ATTR, imm_offset, glsl_type::ivec4_type)));
> +src_reg src = src_reg(ATTR, imm_offset, glsl_type::ivec4_type);
> +src.swizzle = BRW_SWZ_COMP_INPUT(fist_component);
> +
> +emit(MOV(dst, src));
>  prog_data->urb_read_length =
> MAX2(prog_data->urb_read_length,
>  DIV_ROUND_UP(imm_offset + 1, 2));
> @@ -205,12 +209,14 @@ 
> vec4_tes_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
>read->offset = imm_offset;
>read->urb_write_flags = BRW_URB_WRITE_PER_SLOT_OFFSET;
>  
> +  src_reg src = src_reg(temp);
> +  src.swizzle = BRW_SWZ_COMP_INPUT(fist_component);
> +
>/* Copy to target.  We might end up with some funky writemasks landing
> * in here, but we really don't want them in the above pseudo-ops.
> */
> -  dst_reg dst = get_nir_dest(instr->dest, BRW_REGISTER_TYPE_D);
>dst.writemask = brw_writemask_for_size(instr->num_components);
> -  emit(MOV(dst, src_reg(temp)));
> +  emit(MOV(dst, src));
>break;
> }
> default:

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


Re: [Mesa-dev] V5 ARB_enhanced_layouts packing support for i965 Gen6+

2016-07-20 Thread Alejandro Piñeiro
On 19/07/16 08:33, Timothy Arceri wrote:
> V5:
>  - rebase on Ken's interpolation clean-ups [1]
>
> V4:
>  - add vec4 backend support and enable for Gen6+
>  
>  V3:
> - Rewrite patch 9 (add support for packing arrays) to not add
>  hacks to the type_size() functions.
>  - Add packing support for the load_output intrinsics (patch 12)
>  - Add glsl_dvec_type() helper (patch 8)
>  
>  V2:
>  - validation fixes patches 1-2
>  - added support for packing doubles now that explicit location
>   fixes have landed.
>  - fix various issues with intel debug output with new COMPONENT const
>  index.
>  
>  This adds component packing support for Gen6+.
>  
>  Series can be found in my component_packing_gen6+_v2 branch:
>  
>  https://github.com/tarceri/Mesa_arrays_of_arrays.git 
>
> [1] https://patchwork.freedesktop.org/series/1/
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

With some minor comments, I have just reviewed the patches that had
pending a review (I just skimmed those that were already reviewed by
Edward).

Having said so, I made a run of the enhanced_layouts piglit tests*, and
I got the following:

Haswell:
[240/240] skip: 31, pass: 209

(Most of the skips are related with double support, as haswell support
is not still on master, was sent to review just yesterday).

Broadwell and Skylake:
[240/240] skip: 14, pass: 225, fail: 1 |

Being the failing one:
spec/arb_enhanced_layouts/compiler/transform-feedback-layout-qualifiers/xfb_offset/invalid-block-with-double.vert

In any case, I think that this series could be pushed as it is. Just
saying in the case that you didn't notice it.

* Run as: ./piglit run tests/all.py -t arb_enhanced_layouts
results/enhanced_layouts

BR

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


Re: [Mesa-dev] Testing patches 9987 and 9988

2016-07-20 Thread
On Wed, Jul 20, 2016 at 3:10 PM, Marek Olšák  wrote:
> Did you test this?
> https://cgit.freedesktop.org/~mareko/mesa/commit/?h=si-mid-ib-gfx-fence&id=a993d93a16da86ef1ead4a55aed969752ad3965a

I compiled your git branch and tested some games.

Bioshock Infinite benchmark on Ultra settings goes from 27.72 to 34.44
FPS. Gameplay on Ultra settings is 20-50 FPS.

Other Steam games I tested are unaffected, or show a slight
improvement which is within error bounds of measurement. I didn't
notice any performance regressions.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/56] glsl: Pull operator_strs out to its own file

2016-07-20 Thread Ian Romanick
On 07/20/2016 12:22 AM, Eero Tamminen wrote:
> Hi,
> 
> When you put arrays to headers they get duplicated in every object file
> that includes the header.  If they're not static, you get conflict, if
> they're static, you rely on linker being able to de-duplicate them
> (which isn't given with every linker).
> 
> Wouldn't just a separate C/C++ file be OK for them (+ header declaring
> the array)?

This .h file is included in only one place.  At this point in the
series, that place declares the array as static, so this patch and the
next want the table to be instantiated in ir.cpp for minimal impact.
Starting with patch 12 the table could be its own .cpp file.  Hmm...

> - Eero
> 
> On 19.07.2016 22:24, Ian Romanick wrote:
>> From: Ian Romanick 
>>
>> No change except to the copyright symbol.  The next patch will generate
>> this file with Python, and Unicode + Python = pure rage.
>>
>> v2: Massive rebase.
>>
>> Signed-off-by: Ian Romanick 
>> ---
>>  src/compiler/Makefile.sources  |   1 +
>>  src/compiler/glsl/ir.cpp   | 116
>> +
>>  .../glsl/ir_expression_operation_strings.h | 138
>> +
>>  3 files changed, 140 insertions(+), 115 deletions(-)
>>  create mode 100644 src/compiler/glsl/ir_expression_operation_strings.h
>>
>> diff --git a/src/compiler/Makefile.sources
>> b/src/compiler/Makefile.sources
>> index f645173..ce42df2 100644
>> --- a/src/compiler/Makefile.sources
>> +++ b/src/compiler/Makefile.sources
>> @@ -39,6 +39,7 @@ LIBGLSL_FILES = \
>>  glsl/ir_equals.cpp \
>>  glsl/ir_expression_flattening.cpp \
>>  glsl/ir_expression_flattening.h \
>> +glsl/ir_expression_operation_strings.h \
>>  glsl/ir_function_can_inline.cpp \
>>  glsl/ir_function_detect_recursion.cpp \
>>  glsl/ir_function_inlining.h \
>> diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
>> index b049fda..62061d6 100644
>> --- a/src/compiler/glsl/ir.cpp
>> +++ b/src/compiler/glsl/ir.cpp
>> @@ -498,121 +498,7 @@
>> ir_expression::get_num_operands(ir_expression_operation op)
>> return 0;
>>  }
>>
>> -static const char *const operator_strs[] = {
>> -   "~",
>> -   "!",
>> -   "neg",
>> -   "abs",
>> -   "sign",
>> -   "rcp",
>> -   "rsq",
>> -   "sqrt",
>> -   "exp",
>> -   "log",
>> -   "exp2",
>> -   "log2",
>> -   "f2i",
>> -   "f2u",
>> -   "i2f",
>> -   "f2b",
>> -   "b2f",
>> -   "i2b",
>> -   "b2i",
>> -   "u2f",
>> -   "i2u",
>> -   "u2i",
>> -   "d2f",
>> -   "f2d",
>> -   "d2i",
>> -   "i2d",
>> -   "d2u",
>> -   "u2d",
>> -   "d2b",
>> -   "bitcast_i2f",
>> -   "bitcast_f2i",
>> -   "bitcast_u2f",
>> -   "bitcast_f2u",
>> -   "trunc",
>> -   "ceil",
>> -   "floor",
>> -   "fract",
>> -   "round_even",
>> -   "sin",
>> -   "cos",
>> -   "dFdx",
>> -   "dFdxCoarse",
>> -   "dFdxFine",
>> -   "dFdy",
>> -   "dFdyCoarse",
>> -   "dFdyFine",
>> -   "packSnorm2x16",
>> -   "packSnorm4x8",
>> -   "packUnorm2x16",
>> -   "packUnorm4x8",
>> -   "packHalf2x16",
>> -   "unpackSnorm2x16",
>> -   "unpackSnorm4x8",
>> -   "unpackUnorm2x16",
>> -   "unpackUnorm4x8",
>> -   "unpackHalf2x16",
>> -   "bitfield_reverse",
>> -   "bit_count",
>> -   "find_msb",
>> -   "find_lsb",
>> -   "sat",
>> -   "packDouble2x32",
>> -   "unpackDouble2x32",
>> -   "frexp_sig",
>> -   "frexp_exp",
>> -   "noise",
>> -   "subroutine_to_int",
>> -   "interpolate_at_centroid",
>> -   "get_buffer_size",
>> -   "ssbo_unsized_array_length",
>> -   "vote_any",
>> -   "vote_all",
>> -   "vote_eq",
>> -   "+",
>> -   "-",
>> -   "*",
>> -   "imul_high",
>> -   "/",
>> -   "carry",
>> -   "borrow",
>> -   "%",
>> -   "<",
>> -   ">",
>> -   "<=",
>> -   ">=",
>> -   "==",
>> -   "!=",
>> -   "all_equal",
>> -   "any_nequal",
>> -   "<<",
>> -   ">>",
>> -   "&",
>> -   "^",
>> -   "|",
>> -   "&&",
>> -   "^^",
>> -   "||",
>> -   "dot",
>> -   "min",
>> -   "max",
>> -   "pow",
>> -   "ubo_load",
>> -   "ldexp",
>> -   "vector_extract",
>> -   "interpolate_at_offset",
>> -   "interpolate_at_sample",
>> -   "fma",
>> -   "lrp",
>> -   "csel",
>> -   "bitfield_extract",
>> -   "vector_insert",
>> -   "bitfield_insert",
>> -   "vector",
>> -};
>> +#include "ir_expression_operation_strings.h"
>>
>>  const char *ir_expression::operator_string(ir_expression_operation op)
>>  {
>> diff --git a/src/compiler/glsl/ir_expression_operation_strings.h
>> b/src/compiler/glsl/ir_expression_operation_strings.h
>> new file mode 100644
>> index 000..3fbbae9
>> --- /dev/null
>> +++ b/src/compiler/glsl/ir_expression_operation_strings.h
>> @@ -0,0 +1,138 @@
>> +/*
>> + * Copyright (C) 2010 Intel Corporation
>> + *
>> + * Permission is hereby granted, free of charge, to any person
>> obtaining a
>> + * copy of this software and associated documentation files (the
>> "Software"),
>> + * to deal in the Software without restriction, including without
>> limitation
>> + * the rights to use, copy, modify, merge, publish, distribute,
>> sublicense,
>> + * and/

Re: [Mesa-dev] [PATCH 2/2] nir/inline: Constant-initialize local variables in the callee if needed

2016-07-20 Thread Kenneth Graunke
On Friday, July 15, 2016 3:47:40 PM PDT Jason Ekstrand wrote:
> Signed-off-by: Jason Ekstrand 
> Cc: "12.0" 
> Cc: Connor Abbott 
> ---
>  src/compiler/nir/nir_inline_functions.c | 41 
> +++--
>  1 file changed, 39 insertions(+), 2 deletions(-)
> 
> diff --git a/src/compiler/nir/nir_inline_functions.c 
> b/src/compiler/nir/nir_inline_functions.c
> index c36748d..5e7382a 100644
> --- a/src/compiler/nir/nir_inline_functions.c
> +++ b/src/compiler/nir/nir_inline_functions.c
> @@ -25,6 +25,19 @@
>  #include "nir_builder.h"
>  #include "nir_control_flow.h"
>  
> +static bool
> +deref_apply_constant_initializer(nir_deref_var *deref, void *state)
> +{
> +   struct nir_builder *b = state;
> +
> +   nir_load_const_instr *initializer =
> +  nir_deref_get_const_initializer_load(b->shader, deref);

With the load_const properly added to the instruction list, this is:
Reviewed-by: Kenneth Graunke 

(Jason actually found this bug and already fixed it locally...I didn't
catch it.)


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


Re: [Mesa-dev] [PATCH 1/2] nir: Add a nir_deref_foreach_leaf helper

2016-07-20 Thread Kenneth Graunke
On Friday, July 15, 2016 3:47:39 PM PDT Jason Ekstrand wrote:
> Signed-off-by: Jason Ekstrand 
> Cc: "12.0" 
> Cc: Connor Abbott 
> ---
>  src/compiler/nir/nir.c   | 107 
> +++
>  src/compiler/nir/nir.h   |   4 ++
>  src/compiler/nir/nir_lower_returns.c |   9 +--
>  3 files changed, 116 insertions(+), 4 deletions(-)
> 
> diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
> index 3c8b4e0..a4a28a3 100644
> --- a/src/compiler/nir/nir.c
> +++ b/src/compiler/nir/nir.c
> @@ -659,6 +659,113 @@ nir_copy_deref(void *mem_ctx, nir_deref *deref)
> return NULL;
>  }
>  
> +/* This is the second step in the recursion.  We've found the tail and made a
> + * copy.  Now we need to iterate over all possible leaves and call the
> + * callback on each one.
> + */
> +static bool
> +deref_foreach_leaf_build_recur(nir_deref_var *deref, nir_deref *tail,
> +   nir_deref_foreach_leaf_cb cb, void *state)
> +{
> +   unsigned length;
> +   union {
> +  nir_deref_array arr;
> +  nir_deref_struct str;
> +   } tmp;
> +
> +   assert(tail->child == NULL);
> +   switch (glsl_get_base_type(tail->type)) {
> +   case GLSL_TYPE_ARRAY:
> +  tmp.arr.deref.deref_type = nir_deref_type_array;
> +  tmp.arr.deref.child = NULL;
> +  tmp.arr.deref.type = glsl_get_array_element(tail->type);
> +  tmp.arr.deref_array_type = nir_deref_array_type_direct;
> +  tmp.arr.indirect = NIR_SRC_INIT;
> +  tail->child = &tmp.arr.deref;
> +
> +  length = glsl_get_length(tail->type);
> +  for (unsigned i = 0; i < length; i++) {
> + tmp.arr.base_offset = i;
> + if (!deref_foreach_leaf_build_recur(deref, &tmp.arr.deref, cb, 
> state))
> +return false;
> +  }
> +  return true;
> +
> +   case GLSL_TYPE_STRUCT:
> +  tmp.str.deref.deref_type = nir_deref_type_struct;
> +  tmp.str.deref.child = NULL;
> +  tail->child = &tmp.str.deref;
> +
> +  length = glsl_get_length(tail->type);
> +  for (unsigned i = 0; i < length; i++) {
> + tmp.str.deref.type = glsl_get_struct_field(tail->type, i);
> + tmp.str.index = i;
> + if (!deref_foreach_leaf_build_recur(deref, &tmp.arr.deref, cb, 
> state))
> +return false;
> +  }
> +  return true;
> +
> +   default:
> +  return cb(deref, state);
> +   }
> +}
> +
> +/* This is the first step of the foreach_leaf recursion.  In this step we are
> + * walking to the end of the deref chain and making a copy in the stack as we
> + * go.  This is because we don't want to mutate the deref chain that was
> + * passed in by the caller.  The downside is that this deref chain is on the
> + * stack and , if the caller wants to do anything with it, they will have to
> + * make their own copy because this one will go away.
> + */
> +static bool
> +deref_foreach_leaf_copy_recur(nir_deref_var *deref, nir_deref *tail,
> +  nir_deref_foreach_leaf_cb cb, void *state)
> +{
> +   union {
> +  nir_deref_array arr;
> +  nir_deref_struct str;
> +   } c;
> +
> +   if (tail->child) {
> +  switch (tail->child->deref_type) {
> +  case nir_deref_type_array:
> + c.arr = *nir_deref_as_array(tail->child);
> + tail->child = &c.arr.deref;
> + return deref_foreach_leaf_copy_recur(deref, &c.arr.deref, cb, 
> state);
> +
> +  case nir_deref_type_struct:
> + c.str = *nir_deref_as_struct(tail->child);
> + tail->child = &c.str.deref;
> + return deref_foreach_leaf_copy_recur(deref, &c.str.deref, cb, 
> state);
> +
> +  case nir_deref_type_var:
> +  default:
> + unreachable("Invalid deref type for a child");
> +  }
> +   } else {
> +  /* We've gotten to the end of the original deref.  Time to start
> +   * building our own derefs.
> +   */
> +  return deref_foreach_leaf_build_recur(deref, tail, cb, state);
> +   }
> +}
> +
> +/**
> + * This function iterates over all of the possible derefs that can be created
> + * with the given deref as the head.  It then calls the provided callback 
> with
> + * a full deref for each one.
> + *
> + * The deref passed to the callback will be allocated on the stack.  You will
> + * need to make a copy if you want it to hang around.
> + */
> +bool
> +nir_deref_foreach_leaf(nir_deref_var *deref,
> +   nir_deref_foreach_leaf_cb cb, void *state)
> +{
> +   nir_deref_var copy = *deref;
> +   return deref_foreach_leaf_copy_recur(©, ©.deref, cb, state);
> +}
> +
>  /* Returns a load_const instruction that represents the constant
>   * initializer for the given deref chain.  The caller is responsible for
>   * ensuring that there actually is a constant initializer.
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index a7921ee..79716b1 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -1929,6 +1929,10 @@ nir_deref_struct *nir_deref_struct

Re: [Mesa-dev] [PATCH 05/12] st/va: add encode entrypoint

2016-07-20 Thread Zhang, Boyuan
>Makes sense, but I suggest that in this case we should add at least a comment 
>why this is still disabled.
>And it would look better if we have an "#if 0" or something like this in the 
>code which gets explicitly removed with the last patch.

Sure, I agree. I will submit a new patch set to add this and other minor 
changes.

>The problem with slice level encoding is that we haven't fully implemented it. 
>E.g. the last time I checked the h264encode test it would try to add an SPS 
>and PPS in front of the slice data returned from our VA-API driver.
>Since our VA-API driver doesn't return slice data, but rather a full blown 
>elementary stream you end up with a complete mess which looks something like 
>this:
>SPS (added by the application), PPS (added by the application), Slice Header, 
>SPS (added by the driver), PPS(added by the driver), Slice Header/Slice Data.
>That might work in some if not most cases, but is certainly not complaint to 
>the VA-API specification.
>
>Christian.

I just tried to disable slice encoding support, and even Gstreamer is not 
working. It will give error message saying "unsupported HW profile".
On the other hand, by exposing slice encoding, Gstreamer will still work as 
"Frame-in, Frame-out" mode. I didn't see that Gstreamer will add extra headers. 
And by dumping the output 264 output, it seems gstreamer is using picture 
encoding. However, as my test shown, gstreamer will not work at all if we don't 
expose slice encoding. Do you have any suggestions how we should do for this 
situation?

Regards,
Boyuan

From: Christian König [mailto:deathsim...@vodafone.de]
Sent: July-20-16 4:48 AM
To: Zhang, Boyuan; mesa-dev@lists.freedesktop.org
Cc: adf.li...@gmail.com
Subject: Re: [PATCH 05/12] st/va: add encode entrypoint

Am 20.07.2016 um 06:12 schrieb Zhang, Boyuan:

>> @@ -150,7 +167,16 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile 
>> profile, VAEntrypoint entrypoin
>>  if (entrypoint != VAEntrypointVLD)
>> return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
>>
>> -   *config_id = p;
>> +   if (entrypoint == VAEntrypointEncSlice || entrypoint == 
>> VAEntrypointEncPicture)
>> +  config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
>> +   else
>> +  config->entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;

>Well that doesn't make much sense here.

>First we return and error if the entrypoint isn't VAEntrypointVLD and
>then check if it's an encoding entry point.

>Additional to that I already wondered if we are really going to support
>slice level as well as picture level encoding.

>I think that it should only be one of the two.

>Regards,
>Christian.



Hi Christian,



Sorry for the confusion, The first 2 lines of codes

>>  if (entrypoint != VAEntrypointVLD)
>> return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;

will actually be removed in the last patch where we enable the VAAPI Encode 
(Patch 12/12). In other word, we don't accept VAEncode entrypoint until the 
time we enable VAAPI Encode. Therefore, we still only accept VAEntrypointVLD at 
this patch.

Makes sense, but I suggest that in this case we should add at least a comment 
why this is still disabled.

And it would look better if we have an "#if 0" or something like this in the 
code which gets explicitly removed with the last patch.





And we need to accept both picture level and slice level entrypoint. For some 
application, e.g. libva h264encode test, if we don't enable slice level encode, 
it will fail the call and report h264 encode is not supported. If we enable 
both, it will still use picture level encode. That's why I put both here.

The problem with slice level encoding is that we haven't fully implemented it. 
E.g. the last time I checked the h264encode test it would try to add an SPS and 
PPS in front of the slice data returned from our VA-API driver.

Since our VA-API driver doesn't return slice data, but rather a full blown 
elementary stream you end up with a complete mess which looks something like 
this:

SPS (added by the application), PPS (added by the application), Slice Header, 
SPS (added by the driver), PPS(added by the driver), Slice Header/Slice Data.

That might work in some if not most cases, but is certainly not complaint to 
the VA-API specification.

Christian.





Regards,

Boyuan


From: Christian König 
Sent: July 19, 2016 4:52 AM
To: Zhang, Boyuan; 
mesa-dev@lists.freedesktop.org
Cc: adf.li...@gmail.com
Subject: Re: [PATCH 05/12] st/va: add encode entrypoint

Am 19.07.2016 um 00:43 schrieb Boyuan Zhang:
> VAAPI passes PIPE_VIDEO_ENTRYPOINT_ENCODE as entry point for encoding case. 
> We will save this encode entry point in config. config_id was used as profile 
> previously. Now, config has both profile and entrypoint field, and config_id 
> is used to get the config object. Later on, we pass this entrypoint to 
> context->templat

Re: [Mesa-dev] [PATCH 01/15] i965: bring back type_size_vec4_times_4()

2016-07-20 Thread Kenneth Graunke
On Tuesday, July 19, 2016 4:33:13 PM PDT Timothy Arceri wrote:
> We will use this for output varyings. To make component
> packing simpler we will just treat all varyings as vec4s.
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp   | 13 +
>  src/mesa/drivers/dri/i965/brw_shader.h |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 120d6dd..547a0c2 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -506,6 +506,19 @@ type_size_scalar(const struct glsl_type *type)
> return 0;
>  }
>  
> +/**
> + * Returns the number of scalar components needed to store type, assuming
> + * that vectors are padded out to vec4.
> + *
> + * This has the packing rules of type_size_vec4(), but counts components
> + * similar to type_size_scalar().
> + */
> +extern "C" int
> +type_size_vec4_times_4(const struct glsl_type *type)
> +{
> + return 4 * type_size_vec4(type);

Should be three spaces here.


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


[Mesa-dev] [PATCH] anv: add function to get prime buffer from memory+image

2016-07-20 Thread Jonathan
I followed your suggestions and changed the prototype, although the 
implementation only supports basic formats
---
 include/vulkan/vulkan_intel.h | 17 +++
 src/intel/vulkan/anv_intel.c  | 49 +++
 2 files changed, 66 insertions(+)

diff --git a/include/vulkan/vulkan_intel.h b/include/vulkan/vulkan_intel.h
index 8ede61b..b483877 100644
--- a/include/vulkan/vulkan_intel.h
+++ b/include/vulkan/vulkan_intel.h
@@ -44,6 +44,17 @@ typedef struct VkDmaBufImageCreateInfo_
 
 typedef VkResult (VKAPI_PTR *PFN_vkCreateDmaBufImageINTEL)(VkDevice device, 
const VkDmaBufImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* 
pAllocator, VkDeviceMemory* pMem, VkImage* pImage);
 
+typedef struct VkDmaBufINTEL {
+int fd; /* device fd */
+uint32_t format;/* fourcc code */
+uint32_t handles[4]; /* prime handles (not fd) */
+uint32_t pitches[4];
+uint32_t offsets[4];
+uint64_t modifiers[4]; /* tiling */
+} VkDmaBufINTEL;
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetDmaBufINTEL)(VkDevice device, 
VkDeviceMemory mem, VkImage image, VkDmaBufINTEL *out);
+
 #ifndef VK_NO_PROTOTYPES
 
 VKAPI_ATTR VkResult VKAPI_CALL vkCreateDmaBufImageINTEL(
@@ -53,6 +64,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDmaBufImageINTEL(
 VkDeviceMemory* pMem,
 VkImage*pImage);
 
+VKAPI_ATTR VkResult VKAPI_CALL vkGetDmaBufINTEL(
+VkDevice_device,
+VkDeviceMemory  _mem,
+VkImage _image,
+VkDmaBufINTEL*  out);
+
 #endif
 
 #ifdef __cplusplus
diff --git a/src/intel/vulkan/anv_intel.c b/src/intel/vulkan/anv_intel.c
index d95d9af..d8b95c7 100644
--- a/src/intel/vulkan/anv_intel.c
+++ b/src/intel/vulkan/anv_intel.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "anv_private.h"
 
@@ -98,3 +99,51 @@ VkResult anv_CreateDmaBufImageINTEL(
 
return result;
 }
+
+static uint64_t isl_tiling_to_modifier(int tiling)
+{
+switch (tiling) {
+case ISL_TILING_LINEAR:
+return 0;
+case ISL_TILING_X:
+return I915_FORMAT_MOD_X_TILED;
+case ISL_TILING_Y0:
+return I915_FORMAT_MOD_Y_TILED;
+case ISL_TILING_Yf:
+return I915_FORMAT_MOD_Yf_TILED;
+}
+assert(!"no isl_tiling -> modifier conversion");
+}
+
+static uint32_t isl_format_to_drm_format(int format)
+{
+switch (format) {
+case ISL_FORMAT_R8G8B8A8_UNORM:
+return DRM_FORMAT_RGBA;
+case ISL_FORMAT_B8G8R8A8_UNORM:
+return DRM_FORMAT_BGRA;
+}
+assert(!"no isl_format -> drm_format conversion");
+}
+
+VkResult anv_GetDmaBufINTEL(
+VkDevice_device,
+VkDeviceMemory  _mem,
+VkImage _image,
+VkDmaBufINTEL*  out)
+{
+   ANV_FROM_HANDLE(anv_device, device, _device);
+   ANV_FROM_HANDLE(anv_device_memory, mem, _mem);
+   ANV_FROM_HANDLE(anv_image, image, _image);
+
+   struct anv_surface *surface = &image->color_surface;
+
+   memset(out, 0, sizeof(*out));
+   out->fd = device->fd;
+   out->format = isl_format_to_drm_format(surface->isl.format);
+   out->handles[0] = mem->bo.gem_handle;
+   out->pitches[0] = surface->isl.row_pitch;
+   out->modifiers[0] = isl_tiling_to_modifier(surface->isl.tiling);
+
+   return VK_SUCCESS;
+}
-- 
2.8.1

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


Re: [Mesa-dev] [PATCH 2/2] clover: Re-order includes in invocation.cpp to fix build

2016-07-20 Thread Francisco Jerez
Tom Stellard  writes:

> The build was failing because the official CL headers have a few defines, 
> like:
>
> \# define cl_khr_gl_sharing 1
>
> Which have the same name as some class members of clang's OpenCLOptions class.
> If we include the cl headers first, this breaks the build because the member
> names of this class are replaced by the literal 1.

Reviewed-by: Francisco Jerez 

> ---
>  .../state_trackers/clover/llvm/invocation.cpp  | 24 
> +++---
>  1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
> b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> index bbd66d4..7b50b02 100644
> --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
> +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> @@ -24,13 +24,6 @@
>  // OTHER DEALINGS IN THE SOFTWARE.
>  //
>  
> -#include "llvm/codegen.hpp"
> -#include "llvm/compat.hpp"
> -#include "llvm/invocation.hpp"
> -#include "llvm/metadata.hpp"
> -#include "llvm/util.hpp"
> -#include "util/algorithm.hpp"
> -
>  #include 
>  #include 
>  #include 
> @@ -45,6 +38,23 @@
>  #include 
>  #include 
>  
> +// We need to include internal headers last, because the internal headers
> +// include CL headers which have #define's like:
> +//
> +//#define cl_khr_gl_sharing 1
> +//#define cl_khr_icd 1
> +//
> +// Which will break the compilation of clang/Basic/OpenCLOptions.h
> +
> +#include "core/error.hpp"
> +#include "llvm/codegen.hpp"
> +#include "llvm/compat.hpp"
> +#include "llvm/invocation.hpp"
> +#include "llvm/metadata.hpp"
> +#include "llvm/util.hpp"
> +#include "util/algorithm.hpp"
> +
> +
>  using namespace clover;
>  using namespace clover::llvm;
>  
> -- 
> 2.7.4


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 1/2] clover: Add missing include v2

2016-07-20 Thread Francisco Jerez
Tom Stellard  writes:

> There was a patch committed to clang to remove unnecessary includes from
> header files, so we now need to explicitly include
> clang/Lex/PreprocessorOptions.h
>
> v2:
>   - Use <> instead of "" for the include path.
> ---
>  src/gallium/state_trackers/clover/llvm/invocation.cpp | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
> b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> index 4b7de26..bbd66d4 100644
> --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
> +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> @@ -39,6 +39,8 @@
>  #include 
>  
>  #include 
> +#include 
> +

Redundant whitespace, with that removed:

Reviewed-by: Francisco Jerez 

>  #include 
>  #include 
>  #include 
> -- 
> 2.7.4


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 06/15] i965: add helper for creating packing writemask

2016-07-20 Thread Kenneth Graunke
On Tuesday, July 19, 2016 4:33:18 PM PDT Timothy Arceri wrote:
> For example where n=3 first_component=1 this will give us
> 0xE (WRITEMASK_YZW).
> 
> Reviewed-by: Edward O'Callaghan 
> ---
>  src/mesa/drivers/dri/i965/brw_reg.h | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_reg.h 
> b/src/mesa/drivers/dri/i965/brw_reg.h
> index 7eab7b5..abd63e4 100644
> --- a/src/mesa/drivers/dri/i965/brw_reg.h
> +++ b/src/mesa/drivers/dri/i965/brw_reg.h
> @@ -972,6 +972,12 @@ brw_writemask_for_size(unsigned n)
> return (1 << n) - 1;
>  }
>  
> +static inline unsigned
> +brw_writemask_for_component_packing(unsigned n, unsigned first_component)
> +{
> +   return (((1 << n) - 1) << first_component);
> +}
> +
>  static inline struct brw_reg
>  negate(struct brw_reg reg)
>  {
> 

It would be nice to include an assert that first_component + n < 4,
or equivalently, that (result & WRITEMASK_XYZW) == result.


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


Re: [Mesa-dev] [PATCH 02/15] i965: enable component packing for vs and fs

2016-07-20 Thread Kenneth Graunke
On Tuesday, July 19, 2016 4:33:14 PM PDT Timothy Arceri wrote:
> Rather than trying to work out the total number of components
> used at a location we simply treat all outputs as vec4s.
> ---
>  src/mesa/drivers/dri/i965/brw_fs.h   |  1 -
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 22 ++
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 10 ++
>  src/mesa/drivers/dri/i965/brw_nir.c  |  8 
>  4 files changed, 16 insertions(+), 25 deletions(-)

I ran this through shader-db on Broadwell and got:

total instructions in shared programs: 9071398 -> 9071272 (-0.00%)
instructions in affected programs: 2554 -> 2428 (-4.93%)
helped: 26
HURT: 0

Patches 1-3 are
Reviewed-by: Kenneth Graunke 

Patch 4 is
Acked-by: Kenneth Graunke 

Feel free to turn it on for Broadwell and up!


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


Re: [Mesa-dev] [PATCH 06/10] egl/android: Fix support for pbuffers

2016-07-20 Thread Rob Herring
On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa  wrote:
> From: Nicolas Boichat 
>
> Existing image loader code supports creating images only for window
> surfaces. Moreover droid_create_surface() passes wrong surface type to
> dri2_get_dri_config(), resulting in incorrect configs being returned for
> pbuffers. This patch fixes these issues.
>
> In addition, the config generation code is fixed to include single
> buffered contexts required for pbuffers and make sure that generated
> configs support only surfaces which can handle their supported buffering
> modes.
>
> Signed-off-by: Nicolas Boichat 
> Signed-off-by: Tomasz Figa 
> ---
>  src/egl/drivers/dri2/egl_dri2.h |  1 +
>  src/egl/drivers/dri2/platform_android.c | 61 
> +++--
>  2 files changed, 51 insertions(+), 11 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index 317de06..3ffc177 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -287,6 +287,7 @@ struct dri2_egl_surface
> struct ANativeWindow *window;
> struct ANativeWindowBuffer *buffer;
> __DRIimage *dri_image;
> +   __DRIimage *dri_front_image;
>
> /* EGL-owned buffers */
> __DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
> diff --git a/src/egl/drivers/dri2/platform_android.c 
> b/src/egl/drivers/dri2/platform_android.c
> index 7495445..0f707dd 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -286,7 +286,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
> EGLint type,
>window->query(window, NATIVE_WINDOW_HEIGHT, &dri2_surf->base.Height);
> }
>
> -   config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT,
> +   config = dri2_get_dri_config(dri2_conf, type,
>  dri2_surf->base.GLColorspace);
> if (!config)
>goto cleanup_surface;
> @@ -347,6 +347,9 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
> _EGLSurface *surf)
>dri2_surf->window->common.decRef(&dri2_surf->window->common);
> }
>
> +   if (dri2_surf->dri_front_image)
> +  dri2_dpy->image->destroyImage(dri2_surf->dri_front_image);
> +
> (*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable);
>
> free(dri2_surf);
> @@ -378,6 +381,29 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
>  }
>
>  static int
> +get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
> +{
> +   struct dri2_egl_display *dri2_dpy =
> +  dri2_egl_display(dri2_surf->base.Resource.Display);
> +
> +   if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
> +  _eglLog(_EGL_WARNING, "Front buffer is not supported for window 
> surfaces");
> +  return -1;
> +   }
> +
> +   if (dri2_surf->dri_front_image)
> +  return 0;
> +
> +   dri2_surf->dri_front_image =
> +  dri2_dpy->image->createImage(dri2_dpy->dri_screen,
> +   dri2_surf->base.Width,
> +   dri2_surf->base.Height,
> +   format, 0, dri2_surf);
> +
> +   return dri2_surf->dri_front_image ? 0 : -1;
> +}
> +
> +static int
>  get_back_bo(struct dri2_egl_surface *dri2_surf)
>  {
> struct dri2_egl_display *dri2_dpy =
> @@ -385,6 +411,11 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
> int fourcc, pitch;
> int offset = 0, fd;
>
> +   if (dri2_surf->base.Type != EGL_WINDOW_BIT) {
> +  _eglLog(_EGL_WARNING, "Back buffer is not supported for pbuffer 
> surfaces");
> +  return -1;
> +   }
> +
> if (dri2_surf->dri_image)
>return 0;
>
> @@ -440,8 +471,11 @@ droid_image_get_buffers(__DRIdrawable *driDrawable,
>return 0;
>
> if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
> -  _eglLog(_EGL_WARNING, "Front buffer is not supported for window 
> surfaces");
> -  return 0;
> +  if (get_front_bo(dri2_surf, format) < 0)
> + return 0;
> +
> +  images->front = dri2_surf->dri_front_image;
> +  images->image_mask |= __DRI_IMAGE_BUFFER_FRONT;
> }
>
> if (buffer_mask & __DRI_IMAGE_BUFFER_BACK) {
> @@ -698,14 +732,6 @@ droid_add_configs_for_visuals(_EGLDriver *drv, 
> _EGLDisplay *dpy)
>for (j = 0; dri2_dpy->driver_configs[j]; j++) {
>   const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
>   struct dri2_egl_config *dri2_conf;
> - unsigned int double_buffered = 0;
> -
> - dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[j],
> -__DRI_ATTRIB_DOUBLE_BUFFER, &double_buffered);
> -
> - /* support only double buffered configs */
> - if (!double_buffered)
> -continue;
>
>   dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[j],
> count + 1, surface_type, config_attrs, visuals[i].rgba_masks);
> @@ -728,6 +754,19 @@ droid_add_configs_for_visuals(_EGLDriver *drv, 
> _EGLDisplay *dpy)
>/* there is no

[Mesa-dev] [PATCH 00/11] *** S

2016-07-20 Thread Rob Herring
*** BLURB HERE ***

Rob Herring (11):
  gallium: move pipe_screen destroy into pipe-loader
  pipe-loader-drm: protect create_screen() calls with a mutex
  gallium: add common pipe_screen reference counting functions
  pipe-loader-drm: use pipe_screen_unreference to destroy screen
  nouveau: use common screen ref counting
  freedreno: use common screen ref counting
  amdgpu: use common screen ref counting
  radeon: use common screen ref counting
  vmwgfx: use common screen ref counting
  vc4: use common screen ref counting
  virgl: use common screen ref counting

 src/gallium/auxiliary/Makefile.sources |   2 +
 src/gallium/auxiliary/pipe-loader/pipe_loader.h|   1 +
 .../auxiliary/pipe-loader/pipe_loader_drm.c|  15 ++-
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c |   6 ++
 src/gallium/auxiliary/util/u_screen.c  | 114 +
 src/gallium/auxiliary/util/u_screen.h  |  32 ++
 src/gallium/auxiliary/vl/vl_winsys_dri.c   |   1 -
 src/gallium/auxiliary/vl/vl_winsys_dri3.c  |   1 -
 src/gallium/auxiliary/vl/vl_winsys_drm.c   |   1 -
 src/gallium/drivers/freedreno/freedreno_screen.c   |   1 -
 src/gallium/drivers/freedreno/freedreno_screen.h   |  10 --
 src/gallium/drivers/nouveau/nouveau_screen.c   |   6 --
 src/gallium/drivers/nouveau/nouveau_screen.h   |   4 -
 src/gallium/drivers/nouveau/nv30/nv30_screen.c |   3 -
 src/gallium/drivers/nouveau/nv50/nv50_screen.c |   3 -
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |   3 -
 src/gallium/drivers/r300/r300_screen.c |   3 -
 src/gallium/drivers/r600/r600_pipe.c   |   6 --
 src/gallium/drivers/radeon/radeon_winsys.h |   8 --
 src/gallium/drivers/radeonsi/si_pipe.c |   6 --
 src/gallium/include/pipe/p_screen.h|   3 +
 src/gallium/state_trackers/clover/core/device.cpp  |   4 +-
 src/gallium/state_trackers/dri/dri_screen.c|   3 -
 src/gallium/state_trackers/xa/xa_tracker.c |   2 -
 src/gallium/tests/trivial/compute.c|   1 -
 src/gallium/tests/trivial/quad-tex.c   |   1 -
 src/gallium/tests/trivial/tri.c|   1 -
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c  |  45 ++--
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h  |   1 -
 .../winsys/freedreno/drm/freedreno_drm_winsys.c|  94 ++---
 .../winsys/nouveau/drm/nouveau_drm_winsys.c|  89 ++--
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c  |  84 ++-
 src/gallium/winsys/svga/drm/vmw_screen.c   |  51 ++---
 src/gallium/winsys/svga/drm/vmw_screen.h   |   6 --
 src/gallium/winsys/vc4/drm/vc4_drm_winsys.c|   9 +-
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c|  86 ++--
 36 files changed, 221 insertions(+), 485 deletions(-)
 create mode 100644 src/gallium/auxiliary/util/u_screen.c
 create mode 100644 src/gallium/auxiliary/util/u_screen.h

-- 
2.9.2

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


[Mesa-dev] [PATCH 01/11] gallium: move pipe_screen destroy into pipe-loader

2016-07-20 Thread Rob Herring
In preparation to add reference counting of pipe_screen in the pipe-loader,
pipe_loader_release needs to destroy the pipe_screen instead of state
trackers.

Signed-off-by: Rob Herring 
Cc: Emil Velikov 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader.h | 1 +
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 9 -
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c  | 6 ++
 src/gallium/auxiliary/vl/vl_winsys_dri.c| 1 -
 src/gallium/auxiliary/vl/vl_winsys_dri3.c   | 1 -
 src/gallium/auxiliary/vl/vl_winsys_drm.c| 1 -
 src/gallium/state_trackers/clover/core/device.cpp   | 4 +---
 src/gallium/state_trackers/dri/dri_screen.c | 3 ---
 src/gallium/state_trackers/xa/xa_tracker.c  | 2 --
 src/gallium/tests/trivial/compute.c | 1 -
 src/gallium/tests/trivial/quad-tex.c| 1 -
 src/gallium/tests/trivial/tri.c | 1 -
 12 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h 
b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index 690d088..25cd4d1 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -65,6 +65,7 @@ struct pipe_loader_device {
 
char *driver_name;
const struct pipe_loader_ops *ops;
+   struct pipe_screen *pscreen;
 };
 
 /**
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 994a284..7bdd2ec 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -39,6 +39,7 @@
 #include "target-helpers/drm_helper_public.h"
 #include "state_tracker/drm_driver.h"
 #include "pipe_loader_priv.h"
+#include "pipe/p_screen.h"
 
 #include "util/u_memory.h"
 #include "util/u_dl.h"
@@ -269,6 +270,9 @@ static void
 pipe_loader_drm_release(struct pipe_loader_device **dev)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev);
+   struct pipe_screen *pscreen = ddev->base.pscreen;
+
+   pscreen->destroy(pscreen);
 
 #ifndef GALLIUM_STATIC_TARGETS
if (ddev->lib)
@@ -297,8 +301,11 @@ static struct pipe_screen *
 pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
+   struct pipe_screen *pscreen;
 
-   return ddev->dd->create_screen(ddev->fd);
+   pscreen = ddev->dd->create_screen(ddev->fd);
+   ddev->base.pscreen = pscreen;
+   return pscreen;
 }
 
 static const struct pipe_loader_ops pipe_loader_drm_ops = {
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index e7fa974..ce5c2b3 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -27,6 +27,7 @@
 
 #include "pipe_loader_priv.h"
 
+#include "pipe/p_screen.h"
 #include "util/u_memory.h"
 #include "util/u_dl.h"
 #include "sw/dri/dri_sw_winsys.h"
@@ -271,6 +272,9 @@ static void
 pipe_loader_sw_release(struct pipe_loader_device **dev)
 {
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
+   struct pipe_screen *pscreen = sdev->base.pscreen;
+
+   pscreen->destroy(pscreen);
 
 #ifndef GALLIUM_STATIC_TARGETS
if (sdev->lib)
@@ -301,6 +305,8 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev)
if (!screen)
   sdev->ws->destroy(sdev->ws);
 
+   sdev->base.pscreen = screen;
+
return screen;
 }
 
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 9ecc216..db90c54 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -461,7 +461,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen)
}
 
vl_dri2_destroy_drawable(scrn);
-   scrn->base.pscreen->destroy(scrn->base.pscreen);
pipe_loader_release(&scrn->base.dev, 1);
FREE(scrn);
 }
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 493e645..c8c0198 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -611,7 +611,6 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen)
 
if (scrn->special_event)
   xcb_unregister_for_special_event(scrn->conn, scrn->special_event);
-   scrn->base.pscreen->destroy(scrn->base.pscreen);
pipe_loader_release(&scrn->base.dev, 1);
FREE(scrn);
 
diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c 
b/src/gallium/auxiliary/vl/vl_winsys_drm.c
index 6a759ae..aa690a2 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_drm.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c
@@ -80,7 +80,6 @@ vl_drm_screen_destroy(struct vl_screen *vscreen)
 {
assert(vscreen);
 
-   vscreen->pscreen->destroy(vscreen->pscreen);
pipe_loader_release(&vscreen->dev, 1);
FREE(vscreen);
 }
diff --git a/src/gallium/state_trackers/clover/core/devic

[Mesa-dev] [PATCH 03/11] gallium: add common pipe_screen reference counting functions

2016-07-20 Thread Rob Herring
In order to prevent multiple pipe_screens being created in the same
process, lookup of the DRM FD and reference counting of the pipe_screen
are needed. Several implementations of this exist in various gallium
drivers/winsys already. This creates a common version which is opt-in
for winsys implementations.

Signed-off-by: Rob Herring 
---
 src/gallium/auxiliary/Makefile.sources |   2 +
 src/gallium/auxiliary/util/u_screen.c  | 114 +
 src/gallium/auxiliary/util/u_screen.h  |  32 +
 src/gallium/include/pipe/p_screen.h|   3 +
 4 files changed, 151 insertions(+)
 create mode 100644 src/gallium/auxiliary/util/u_screen.c
 create mode 100644 src/gallium/auxiliary/util/u_screen.h

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index e0311bf..197ed36 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -284,6 +284,8 @@ C_SOURCES := \
util/u_ringbuffer.h \
util/u_sampler.c \
util/u_sampler.h \
+   util/u_screen.c \
+   util/u_screen.h \
util/u_simple_shaders.c \
util/u_simple_shaders.h \
util/u_slab.c \
diff --git a/src/gallium/auxiliary/util/u_screen.c 
b/src/gallium/auxiliary/util/u_screen.c
new file mode 100644
index 000..14be569
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 Linaro, Ltd., Rob Herring 
+ *
+ * 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, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
+ */
+
+/**
+ * Functions for managing pipe_screen's
+ */
+
+#include 
+
+#include "os/os_thread.h"
+
+#include "pipe/p_screen.h"
+#include "util/u_hash_table.h"
+#include "util/u_inlines.h"
+#include "util/u_pointer.h"
+#include "util/u_screen.h"
+
+static struct util_hash_table *fd_tab = NULL;
+pipe_static_mutex(fd_tab_mutex);
+
+static unsigned hash_fd(void *key)
+{
+   int fd = pointer_to_intptr(key);
+   struct stat stat;
+   fstat(fd, &stat);
+
+   return stat.st_dev ^ stat.st_ino ^ stat.st_rdev;
+}
+
+static int compare_fd(void *key1, void *key2)
+{
+   int fd1 = pointer_to_intptr(key1);
+   int fd2 = pointer_to_intptr(key2);
+   struct stat stat1, stat2;
+   fstat(fd1, &stat1);
+   fstat(fd2, &stat2);
+
+   return stat1.st_dev != stat2.st_dev ||
+ stat1.st_ino != stat2.st_ino ||
+ stat1.st_rdev != stat2.st_rdev;
+}
+
+struct pipe_screen *
+pipe_screen_reference(int fd)
+{
+   struct pipe_screen *pscreen;
+
+   if (!fd_tab) {
+  fd_tab = util_hash_table_create(hash_fd, compare_fd);
+  return NULL;
+   }
+
+   pipe_mutex_lock(fd_tab_mutex);
+   pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
+   if (pscreen)
+  pipe_reference(NULL, &pscreen->reference);
+   pipe_mutex_unlock(fd_tab_mutex);
+
+   return pscreen;
+}
+
+boolean
+pipe_screen_unreference(struct pipe_screen *pscreen)
+{
+   boolean destroy;
+
+   if (!pscreen)
+  return FALSE;
+
+   /* Work-around until all pipe_screens have ref counting */
+   if (!pipe_is_referenced(&pscreen->reference)) {
+  pscreen->destroy(pscreen);
+  return TRUE;
+   }
+
+   pipe_mutex_lock(fd_tab_mutex);
+   destroy = pipe_reference(&pscreen->reference, NULL);
+   if (destroy) {
+  pscreen->destroy(pscreen);
+  util_hash_table_remove(fd_tab, intptr_to_pointer(pscreen->fd));
+  close(pscreen->fd);
+   }
+   pipe_mutex_unlock(fd_tab_mutex);
+   return destroy;
+}
+
+
+void pipe_screen_reference_init(struct pipe_screen *pscreen, int fd)
+{
+   pscreen->fd = dup(fd);
+   pipe_reference_init(&pscreen->reference, 1);
+   util_hash_table_set(fd_tab, intptr_to_pointer(pscreen->fd), pscreen);
+}
diff --git a/src/gallium/auxiliary/util/u_screen.h 
b/src/gallium/auxiliary/util/u_screen.h
new file mode 100644
index 000..fc91782
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_screen.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016 Linaro, Ltd., Rob Herring 
+ *
+ * Permiss

[Mesa-dev] [PATCH 02/11] pipe-loader-drm: protect create_screen() calls with a mutex

2016-07-20 Thread Rob Herring
Creating a screen needs to be serialized in order to support reusing
existing screen. With this, driver private mutexes in create_screen()
functions can be removed.

Signed-off-by: Rob Herring 
Cc: Emil Velikov 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 7bdd2ec..554e59a 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -41,6 +41,7 @@
 #include "pipe_loader_priv.h"
 #include "pipe/p_screen.h"
 
+#include "os/os_thread.h"
 #include "util/u_memory.h"
 #include "util/u_dl.h"
 #include "util/u_debug.h"
@@ -63,6 +64,8 @@ struct pipe_loader_drm_device {
 
 static const struct pipe_loader_ops pipe_loader_drm_ops;
 
+pipe_static_mutex(loader_mutex);
+
 #ifdef GALLIUM_STATIC_TARGETS
 static const struct drm_conf_ret throttle_ret = {
DRM_CONF_INT,
@@ -303,8 +306,10 @@ pipe_loader_drm_create_screen(struct pipe_loader_device 
*dev)
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
struct pipe_screen *pscreen;
 
+   pipe_mutex_lock(loader_mutex);
pscreen = ddev->dd->create_screen(ddev->fd);
ddev->base.pscreen = pscreen;
+   pipe_mutex_unlock(loader_mutex);
return pscreen;
 }
 
-- 
2.9.2

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


[Mesa-dev] [PATCH 07/12] st/va: add conversion for yv12 to nv12in putimage

2016-07-20 Thread Boyuan Zhang
For putimage call, if image format is yv12 (or IYUV with U V field swap) and 
surface format is nv12, then we need to convert yv12 to nv12 and then copy the 
converted data from image to surface. We can't use the existing logic where 
surface is destroyed and re-created with yv12 format.

Signed-off-by: Boyuan Zhang 
---
 src/gallium/state_trackers/va/image.c | 33 ++---
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/va/image.c 
b/src/gallium/state_trackers/va/image.c
index 1b956e3..47895ee 100644
--- a/src/gallium/state_trackers/va/image.c
+++ b/src/gallium/state_trackers/va/image.c
@@ -471,7 +471,9 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, 
VAImageID image,
   return VA_STATUS_ERROR_OPERATION_FAILED;
}
 
-   if (format != surf->buffer->buffer_format) {
+   if ((format != surf->buffer->buffer_format) &&
+ ((format != PIPE_FORMAT_YV12) || (surf->buffer->buffer_format != 
PIPE_FORMAT_NV12)) &&
+ ((format != PIPE_FORMAT_IYUV) || (surf->buffer->buffer_format != 
PIPE_FORMAT_NV12))) {
   struct pipe_video_buffer *tmp_buf;
   struct pipe_video_buffer templat = surf->templat;
 
@@ -513,12 +515,29 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, 
VAImageID image,
   unsigned width, height;
   if (!views[i]) continue;
   vlVaVideoSurfaceSize(surf, i, &width, &height);
-  for (j = 0; j < views[i]->texture->array_size; ++j) {
- struct pipe_box dst_box = {0, 0, j, width, height, 1};
- drv->pipe->transfer_inline_write(drv->pipe, views[i]->texture, 0,
-PIPE_TRANSFER_WRITE, &dst_box,
-data[i] + pitches[i] * j,
-pitches[i] * views[i]->texture->array_size, 0);
+  if ((format == PIPE_FORMAT_YV12) || (format == PIPE_FORMAT_IYUV) &&
+(surf->buffer->buffer_format == PIPE_FORMAT_NV12)) {
+ struct pipe_transfer *transfer = NULL;
+ uint8_t *map = NULL;
+ struct pipe_box dst_box_1 = {0, 0, 0, width, height, 1};
+ map = drv->pipe->transfer_map(drv->pipe,
+   views[i]->texture,
+   0,
+   PIPE_TRANSFER_DISCARD_RANGE,
+   &dst_box_1, &transfer);
+ if (map == NULL)
+return VA_STATUS_ERROR_OPERATION_FAILED;
+
+ u_copy_yv12_img_to_nv12_surf (data, map, vaimage->offsets, i);
+ pipe_transfer_unmap(drv->pipe, transfer);
+  } else {
+ for (j = 0; j < views[i]->texture->array_size; ++j) {
+struct pipe_box dst_box = {0, 0, j, width, height, 1};
+drv->pipe->transfer_inline_write(drv->pipe, views[i]->texture, 0,
+ PIPE_TRANSFER_WRITE, &dst_box,
+ data[i] + pitches[i] * j,
+ pitches[i] * 
views[i]->texture->array_size, 0);
+ }
   }
}
pipe_mutex_unlock(drv->mutex);
-- 
2.7.4

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


[Mesa-dev] [PATCH 06/12] vl/util: add copy func for yv12image to nv12surface

2016-07-20 Thread Boyuan Zhang
Add function to copy from yv12 image to nv12 surface for VAAPI putimage call. 
We need this function in VaPutImage call where copying from yv12 image to nv12 
surface for encoding. Existing function can't be used because it only work for 
copying from yv12 surface to nv12 image in Vaapi.

Signed-off-by: Boyuan Zhang 
---
 src/gallium/auxiliary/util/u_video.h | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_video.h 
b/src/gallium/auxiliary/util/u_video.h
index 9196afc..d147295 100644
--- a/src/gallium/auxiliary/util/u_video.h
+++ b/src/gallium/auxiliary/util/u_video.h
@@ -130,6 +130,29 @@ u_copy_yv12_to_nv12(void *const *destination_data,
 }
 
 static inline void
+u_copy_yv12_img_to_nv12_surf(uint8_t *const *src,
+ uint8_t *dest,
+ int *offset,
+ int field)
+{
+   if (field == 0) {
+  for (int i = 0; i < offset[1] ; i++)
+ dest[i] = src[field][i];
+   } else if (field == 1) {
+  bool odd = false;
+  for (int i = 0; i < (offset[1]/2) ; i++){
+ if (odd == false) {
+dest[i] = src[field][i/2];
+odd = true;
+ } else {
+dest[i] = src[field+1][i/2];
+odd = false;
+ }
+  }
+   }
+}
+
+static inline void
 u_copy_swap422_packed(void *const *destination_data,
uint32_t const *destination_pitches,
int src_plane, int src_field,
-- 
2.7.4

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


[Mesa-dev] [PATCH 11/12] st/va: add enviromental variable to disable interlace

2016-07-20 Thread Boyuan Zhang
Add environmental variable to disable interlace mode. At VAAPI decoding stage, 
driver can not distinguish b/w pure decoding case and transcoding case. And 
since interlace encoding is not supported, we have to disable interlace for 
transcoding case. The temporary solution is to use enviromental variable to 
disable interlace mode.

Signed-off-by: Boyuan Zhang 
---
 src/gallium/state_trackers/va/surface.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 8ce4143..63727b6 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -43,6 +43,8 @@
 
 #include "va_private.h"
 
+DEBUG_GET_ONCE_BOOL_OPTION(nointerlace, "VAAPI_DISABLE_INTERLACE", FALSE);
+
 #include 
 
 static const enum pipe_format vpp_surface_formats[] = {
@@ -620,6 +622,8 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int 
format,
 
templat.width = width;
templat.height = height;
+   if (debug_get_option_nointerlace())
+  templat.interlaced = false;
 
memset(surfaces, VA_INVALID_ID, num_surfaces * sizeof(VASurfaceID));
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 09/12] st/va: add functions for VAAPI encode

2016-07-20 Thread Boyuan Zhang
Add necessary functions/changes for VAAPI encoding to buffer and picture. These 
changes will allow driver to handle all Vaapi encode related operations. This 
patch doesn't change the Vaapi decode behaviour.

Signed-off-by: Boyuan Zhang 
---
 src/gallium/state_trackers/va/buffer.c |   6 +
 src/gallium/state_trackers/va/picture.c| 172 -
 src/gallium/state_trackers/va/va_private.h |   3 +
 3 files changed, 179 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/va/buffer.c 
b/src/gallium/state_trackers/va/buffer.c
index 7d3167b..dfcebbe 100644
--- a/src/gallium/state_trackers/va/buffer.c
+++ b/src/gallium/state_trackers/va/buffer.c
@@ -133,6 +133,12 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, 
void **pbuff)
   if (!buf->derived_surface.transfer || !*pbuff)
  return VA_STATUS_ERROR_INVALID_BUFFER;
 
+  if (buf->type == VAEncCodedBufferType) {
+ ((VACodedBufferSegment*)buf->data)->buf = *pbuff;
+ ((VACodedBufferSegment*)buf->data)->size = buf->coded_size;
+ ((VACodedBufferSegment*)buf->data)->next = NULL;
+ *pbuff = buf->data;
+  }
} else {
   pipe_mutex_unlock(drv->mutex);
   *pbuff = buf->data;
diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 89ac024..4bb60f2 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -78,7 +78,8 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID 
context_id, VASurfaceID rende
   return VA_STATUS_SUCCESS;
}
 
-   context->decoder->begin_frame(context->decoder, context->target, 
&context->desc.base);
+   if (context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE)
+  context->decoder->begin_frame(context->decoder, context->target, 
&context->desc.base);
 
return VA_STATUS_SUCCESS;
 }
@@ -278,6 +279,142 @@ handleVASliceDataBufferType(vlVaContext *context, 
vlVaBuffer *buf)
   num_buffers, (const void * const*)buffers, sizes);
 }
 
+static VAStatus
+handleVAEncMiscParameterTypeRateControl(vlVaContext *context, 
VAEncMiscParameterBuffer *misc)
+{
+   VAEncMiscParameterRateControl *rc = (VAEncMiscParameterRateControl 
*)misc->data;
+   if (context->desc.h264enc.rate_ctrl.rate_ctrl_method ==
+   PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT)
+  context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second;
+   else
+  context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second * 
rc->target_percentage;
+   context->desc.h264enc.rate_ctrl.peak_bitrate = rc->bits_per_second;
+   if (context->desc.h264enc.rate_ctrl.target_bitrate < 200)
+  context->desc.h264enc.rate_ctrl.vbv_buffer_size = 
MIN2((context->desc.h264enc.rate_ctrl.target_bitrate * 2.75), 200);
+   else
+  context->desc.h264enc.rate_ctrl.vbv_buffer_size = 
context->desc.h264enc.rate_ctrl.target_bitrate;
+   context->desc.h264enc.rate_ctrl.target_bits_picture =
+  context->desc.h264enc.rate_ctrl.target_bitrate / 
context->desc.h264enc.rate_ctrl.frame_rate_num;
+   context->desc.h264enc.rate_ctrl.peak_bits_picture_integer =
+  context->desc.h264enc.rate_ctrl.peak_bitrate / 
context->desc.h264enc.rate_ctrl.frame_rate_num;
+   context->desc.h264enc.rate_ctrl.peak_bits_picture_fraction = 0;
+
+   return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
+handleVAEncSequenceParameterBufferType(vlVaDriver *drv, vlVaContext *context, 
vlVaBuffer *buf)
+{
+   VAEncSequenceParameterBufferH264 *h264 = (VAEncSequenceParameterBufferH264 
*)buf->data;
+   if (!context->decoder) {
+  context->templat.max_references = h264->max_num_ref_frames;
+  context->templat.level = h264->level_idc;
+  context->decoder = drv->pipe->create_video_codec(drv->pipe, 
&context->templat);
+  if (!context->decoder)
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+   }
+   context->desc.h264enc.gop_size = h264->intra_idr_period;
+   context->desc.h264enc.rate_ctrl.frame_rate_num = h264->time_scale / 2;
+   context->desc.h264enc.rate_ctrl.frame_rate_den = 1;
+   return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
+handleVAEncMiscParameterBufferType(vlVaContext *context, vlVaBuffer *buf)
+{
+   VAStatus vaStatus = VA_STATUS_SUCCESS;
+   VAEncMiscParameterBuffer *misc;
+   misc = buf->data;
+
+   switch (misc->type) {
+   case VAEncMiscParameterTypeRateControl:
+  vaStatus = handleVAEncMiscParameterTypeRateControl(context, misc);
+  break;
+
+   default:
+  break;
+   }
+
+   return vaStatus;
+}
+
+static VAStatus
+handleVAEncPictureParameterBufferType(vlVaDriver *drv, vlVaContext *context, 
vlVaBuffer *buf)
+{
+   VAEncPictureParameterBufferH264 *h264;
+   vlVaBuffer *coded_buf;
+
+   h264 = buf->data;
+   context->desc.h264enc.frame_num = h264->frame_num;
+   context->desc.h264enc.not_referenced = false;
+   context->desc.h264enc.is_idr = (h264->pic_fields.bits.idr_pic_flag == 1);
+   context->desc.h264enc.pic_order_cnt = h264->CurrP

[Mesa-dev] [PATCH 10/12] st/va: add preset values for VAAPI encode

2016-07-20 Thread Boyuan Zhang
Add some hardcoded values hardware needs mainly for rate control purpose. With 
previously hardcoded values for OMX, the rate control result is not correct. 
This change fixed the rate control result by setting correct values for Vaapi.

Signed-off-by: Boyuan Zhang 
---
 src/gallium/state_trackers/va/picture.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 4bb60f2..4abf155 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -95,6 +95,32 @@ vlVaGetReferenceFrame(vlVaDriver *drv, VASurfaceID 
surface_id,
   *ref_frame = NULL;
 }
 
+static void
+getEncParamPreset(vlVaContext *context)
+{
+   //motion estimation preset
+   context->desc.h264enc.motion_est.motion_est_quarter_pixel = 0x0001;
+   context->desc.h264enc.motion_est.lsmvert = 0x0002;
+   context->desc.h264enc.motion_est.enc_disable_sub_mode = 0x0078;
+   context->desc.h264enc.motion_est.enc_en_ime_overw_dis_subm = 0x0001;
+   context->desc.h264enc.motion_est.enc_ime_overw_dis_subm_no = 0x0001;
+   context->desc.h264enc.motion_est.enc_ime2_search_range_x = 0x0004;
+   context->desc.h264enc.motion_est.enc_ime2_search_range_y = 0x0004;
+
+   //pic control preset
+   context->desc.h264enc.pic_ctrl.enc_cabac_enable = 0x0001;
+   context->desc.h264enc.pic_ctrl.enc_constraint_set_flags = 0x0040;
+
+   //rate control
+   context->desc.h264enc.rate_ctrl.vbv_buffer_size = 2000;
+   context->desc.h264enc.rate_ctrl.vbv_buf_lv = 48;
+   context->desc.h264enc.rate_ctrl.fill_data_enable = 1;
+   context->desc.h264enc.rate_ctrl.enforce_hrd = 1;
+   context->desc.h264enc.enable_vui = false;
+
+   context->desc.h264enc.ref_pic_mode = 0x0201;
+}
+
 static VAStatus
 handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer 
*buf)
 {
@@ -524,6 +550,7 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
 
if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
   coded_buf = context->coded_buf;
+  getEncParamPreset(context);
   context->decoder->begin_frame(context->decoder, context->target, 
&context->desc.base);
   context->decoder->encode_bitstream(context->decoder, context->target,
  coded_buf->derived_surface.resource, 
&feedback);
-- 
2.7.4

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


[Mesa-dev] [PATCH 12/12] st/va: enable h264 VAAPI encode

2016-07-20 Thread Boyuan Zhang
Enable H.264 VAAPI encoding through config. Currently only H.264 baseline is 
supported. Encode entrypoint is not accepted by driver.

Signed-off-by: Boyuan Zhang 
---
 src/gallium/state_trackers/va/config.c | 34 ++
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index be151c8..aab01a0 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -74,6 +74,7 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile 
profile,
 {
struct pipe_screen *pscreen;
enum pipe_video_profile p;
+   int va_status = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
 
if (!ctx)
   return VA_STATUS_ERROR_INVALID_CONTEXT;
@@ -90,12 +91,18 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile 
profile,
   return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
 
pscreen = VL_VA_PSCREEN(ctx);
-   if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, 
PIPE_VIDEO_CAP_SUPPORTED))
-  return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
-
-   entrypoint_list[(*num_entrypoints)++] = VAEntrypointVLD;
+   if (pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, 
PIPE_VIDEO_CAP_SUPPORTED)) {
+  entrypoint_list[(*num_entrypoints)++] = VAEntrypointVLD;
+  va_status = VA_STATUS_SUCCESS;
+   }
+   if (pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE, 
PIPE_VIDEO_CAP_SUPPORTED) &&
+   p == PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE) {
+  entrypoint_list[(*num_entrypoints)++] = VAEntrypointEncSlice;
+  entrypoint_list[(*num_entrypoints)++] = VAEntrypointEncPicture;
+  va_status = VA_STATUS_SUCCESS;
+   }
 
-   return VA_STATUS_SUCCESS;
+   return va_status;;
 }
 
 VAStatus
@@ -114,7 +121,7 @@ vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile 
profile, VAEntrypoint en
  value = VA_RT_FORMAT_YUV420;
  break;
   case VAConfigAttribRateControl:
- value = VA_RC_NONE;
+ value = VA_RC_CQP | VA_RC_CBR;
  break;
   default:
  value = VA_ATTRIB_NOT_SUPPORTED;
@@ -161,17 +168,20 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
   return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
 
pscreen = VL_VA_PSCREEN(ctx);
-   if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, 
PIPE_VIDEO_CAP_SUPPORTED))
-  return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
-
-   if (entrypoint != VAEntrypointVLD)
+   if (entrypoint == VAEntrypointVLD) {
+  if (!pscreen->get_video_param(pscreen, p, 
PIPE_VIDEO_ENTRYPOINT_BITSTREAM, PIPE_VIDEO_CAP_SUPPORTED))
+ return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+   }
+   else if (entrypoint == VAEntrypointEncSlice) {
+  if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE, 
PIPE_VIDEO_CAP_SUPPORTED))
+ return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+   }
+   else
   return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
 
-#if 0
if (entrypoint == VAEntrypointEncSlice || entrypoint == 
VAEntrypointEncPicture)
   config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
else
-#endif
   config->entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
 
config->profile = p;
-- 
2.7.4

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


[Mesa-dev] [PATCH 08/12] st/va: get rate control method from configattrib

2016-07-20 Thread Boyuan Zhang
Rate control method is passed from app to driver through config attrib list. 
That is why we need to store this rate control method to config. And later on, 
we will pass this value to context->desc.h264enc.rate_ctrl.rate_ctrl_method.

Signed-off-by: Boyuan Zhang 
---
 src/gallium/state_trackers/va/config.c | 11 +++
 src/gallium/state_trackers/va/context.c|  2 ++
 src/gallium/state_trackers/va/va_private.h |  1 +
 3 files changed, 14 insertions(+)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index 3aacc63..be151c8 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -176,6 +176,17 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
 
config->profile = p;
 
+   for (int i = 0; i rc = PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT;
+ else if (attrib_list[i].value == VA_RC_VBR)
+config->rc = PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE;
+ else
+config->rc = PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE;
+  }
+   }
+
pipe_mutex_lock(drv->mutex);
*config_id = handle_table_add(drv->htab, config);
pipe_mutex_unlock(drv->mutex);
diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index 8882cba..65ba7db 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -276,6 +276,8 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID 
config_id, int picture_width,
 
context->desc.base.profile = config->profile;
context->desc.base.entry_point = config->entrypoint;
+   if (config->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE)
+  context->desc.h264enc.rate_ctrl.rate_ctrl_method = config->rc;
 
pipe_mutex_lock(drv->mutex);
*context_id = handle_table_add(drv->htab, context);
diff --git a/src/gallium/state_trackers/va/va_private.h 
b/src/gallium/state_trackers/va/va_private.h
index 723983d..ad9010a 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -246,6 +246,7 @@ typedef struct {
 typedef struct {
VAEntrypoint entrypoint;
enum pipe_video_profile profile;
+   enum pipe_h264_enc_rate_control_method rc;
 } vlVaConfig;
 
 typedef struct {
-- 
2.7.4

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


[Mesa-dev] [PATCH 05/12] st/va: add encode entrypoint

2016-07-20 Thread Boyuan Zhang
VAAPI passes PIPE_VIDEO_ENTRYPOINT_ENCODE as entry point for encoding case. We 
will save this encode entry point in config. config_id was used as profile 
previously. Now, config has both profile and entrypoint field, and config_id is 
used to get the config object. Later on, we pass this entrypoint to 
context->templat.entrypoint instead of always hardcoded to 
PIPE_VIDEO_ENTRYPOINT_BITSTREAM for decoding case previously. Encode entrypoint 
is not accepted by driver until we enable Vaapi encode in later patch.

Signed-off-by: Boyuan Zhang 
---
 src/gallium/state_trackers/va/config.c | 71 +++---
 src/gallium/state_trackers/va/context.c| 59 +++--
 src/gallium/state_trackers/va/surface.c| 14 --
 src/gallium/state_trackers/va/va_private.h |  5 +++
 4 files changed, 117 insertions(+), 32 deletions(-)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index 9ca0aa8..3aacc63 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -34,6 +34,8 @@
 
 #include "va_private.h"
 
+#include "util/u_handle_table.h"
+
 DEBUG_GET_ONCE_BOOL_OPTION(mpeg4, "VAAPI_MPEG4_ENABLED", false)
 
 VAStatus
@@ -128,14 +130,29 @@ VAStatus
 vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint 
entrypoint,
  VAConfigAttrib *attrib_list, int num_attribs, VAConfigID 
*config_id)
 {
+   vlVaDriver *drv;
+   vlVaConfig *config;
struct pipe_screen *pscreen;
enum pipe_video_profile p;
 
if (!ctx)
   return VA_STATUS_ERROR_INVALID_CONTEXT;
 
+   drv = VL_VA_DRIVER(ctx);
+
+   if (!drv)
+  return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   config = CALLOC(1, sizeof(vlVaConfig));
+   if (!config)
+  return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) {
-  *config_id = PIPE_VIDEO_PROFILE_UNKNOWN;
+  config->entrypoint = VAEntrypointVideoProc;
+  config->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
+  pipe_mutex_lock(drv->mutex);
+  *config_id = handle_table_add(drv->htab, config);
+  pipe_mutex_unlock(drv->mutex);
   return VA_STATUS_SUCCESS;
}
 
@@ -150,7 +167,18 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
if (entrypoint != VAEntrypointVLD)
   return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
 
-   *config_id = p;
+#if 0
+   if (entrypoint == VAEntrypointEncSlice || entrypoint == 
VAEntrypointEncPicture)
+  config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
+   else
+#endif
+  config->entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
+
+   config->profile = p;
+
+   pipe_mutex_lock(drv->mutex);
+   *config_id = handle_table_add(drv->htab, config);
+   pipe_mutex_unlock(drv->mutex);
 
return VA_STATUS_SUCCESS;
 }
@@ -158,9 +186,27 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
 VAStatus
 vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id)
 {
+   vlVaDriver *drv;
+   vlVaConfig *config;
+
if (!ctx)
   return VA_STATUS_ERROR_INVALID_CONTEXT;
 
+   drv = VL_VA_DRIVER(ctx);
+
+   if (!drv)
+  return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   pipe_mutex_lock(drv->mutex);
+   config = handle_table_get(drv->htab, config_id);
+
+   if (!config)
+  return VA_STATUS_ERROR_INVALID_CONFIG;
+
+   FREE(config);
+   handle_table_remove(drv->htab, config_id);
+   pipe_mutex_unlock(drv->mutex);
+
return VA_STATUS_SUCCESS;
 }
 
@@ -168,18 +214,33 @@ VAStatus
 vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, 
VAProfile *profile,
   VAEntrypoint *entrypoint, VAConfigAttrib 
*attrib_list, int *num_attribs)
 {
+   vlVaDriver *drv;
+   vlVaConfig *config;
+
if (!ctx)
   return VA_STATUS_ERROR_INVALID_CONTEXT;
 
-   *profile = PipeToProfile(config_id);
+   drv = VL_VA_DRIVER(ctx);
+
+   if (!drv)
+  return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   pipe_mutex_lock(drv->mutex);
+   config = handle_table_get(drv->htab, config_id);
+   pipe_mutex_unlock(drv->mutex);
+
+   if (!config)
+  return VA_STATUS_ERROR_INVALID_CONFIG;
+
+   *profile = PipeToProfile(config->profile);
 
-   if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) {
+   if (config->profile == PIPE_VIDEO_PROFILE_UNKNOWN) {
   *entrypoint = VAEntrypointVideoProc;
   *num_attribs = 0;
   return VA_STATUS_SUCCESS;
}
 
-   *entrypoint = VAEntrypointVLD;
+   *entrypoint = config->entrypoint;
 
*num_attribs = 1;
attrib_list[0].type = VAConfigAttribRTFormat;
diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index 402fbb2..8882cba 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -195,18 +195,23 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID 
config_id, int picture_width,
 {
vlVaDriver *drv;
vlVaContext *context;
+   vlVaConfig *co

[Mesa-dev] [PATCH 1/2] ttn: Update shader->info as we generate code.

2016-07-20 Thread Eric Anholt
We could use the nir_shader_gather_info() pass to update it after the
fact, but this is what glsl_to_nir and prog_to_nir do.

Note that this doesn't update all the fields (num_textures, num_ubos
are still missing, for example).
---
 src/gallium/auxiliary/nir/tgsi_to_nir.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c 
b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index e1d7c682bf62..65eca6f9e864 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -364,6 +364,10 @@ ttn_emit_declaration(struct ttn_compile *c)
 }
 
 exec_list_push_tail(&b->shader->inputs, &var->node);
+
+for (int i = 0; i < array_size; i++)
+   b->shader->info.inputs_read |= 1 << (var->data.location + i);
+
 break;
  case TGSI_FILE_OUTPUT: {
 int semantic_name = decl->Semantic.Name;
@@ -426,6 +430,9 @@ ttn_emit_declaration(struct ttn_compile *c)
 }
 
 exec_list_push_tail(&b->shader->outputs, &var->node);
+
+for (int i = 0; i < array_size; i++)
+   b->shader->info.outputs_written |= 1 << (var->data.location + 
i);
  }
 break;
  case TGSI_FILE_CONSTANT:
@@ -571,6 +578,10 @@ ttn_src_for_file_and_index(struct ttn_compile *c, unsigned 
file, unsigned index,
   nir_builder_instr_insert(b, &load->instr);
 
   src = nir_src_for_ssa(&load->dest.ssa);
+
+  b->shader->info.system_values_read |=
+ (1 << nir_system_value_from_intrinsic(op));
+
   break;
}
 
@@ -1036,6 +1047,7 @@ ttn_kill(nir_builder *b, nir_op op, nir_alu_dest dest, 
nir_ssa_def **src)
nir_intrinsic_instr *discard =
   nir_intrinsic_instr_create(b->shader, nir_intrinsic_discard);
nir_builder_instr_insert(b, &discard->instr);
+   b->shader->info.fs.uses_discard = true;
 }
 
 static void
@@ -1048,6 +1060,7 @@ ttn_kill_if(nir_builder *b, nir_op op, nir_alu_dest dest, 
nir_ssa_def **src)
   nir_intrinsic_instr_create(b->shader, nir_intrinsic_discard_if);
discard->src[0] = nir_src_for_ssa(cmp);
nir_builder_instr_insert(b, &discard->instr);
+   b->shader->info.fs.uses_discard = true;
 }
 
 static void
-- 
2.8.1

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


[Mesa-dev] [PATCH 2/2] vc4: Disable early Z with computed depth.

2016-07-20 Thread Eric Anholt
We don't tell the hardware whether we're computing depth, so we need
to manage early Z state manually.  Fixes piglit early-z.
---
 src/gallium/drivers/vc4/vc4_context.h | 2 ++
 src/gallium/drivers/vc4/vc4_emit.c| 6 --
 src/gallium/drivers/vc4/vc4_program.c | 5 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_context.h 
b/src/gallium/drivers/vc4/vc4_context.h
index 751f0437807e..b656539611cd 100644
--- a/src/gallium/drivers/vc4/vc4_context.h
+++ b/src/gallium/drivers/vc4/vc4_context.h
@@ -142,6 +142,8 @@ struct vc4_compiled_shader {
 /** bitmask of which inputs are color inputs, for flat shade handling. 
*/
 uint32_t color_inputs;
 
+bool disable_early_z;
+
 uint8_t num_inputs;
 
 /* Byte offsets for the start of the vertex attributes 0-7, and the
diff --git a/src/gallium/drivers/vc4/vc4_emit.c 
b/src/gallium/drivers/vc4/vc4_emit.c
index 5d6479777551..8b192da47f29 100644
--- a/src/gallium/drivers/vc4/vc4_emit.c
+++ b/src/gallium/drivers/vc4/vc4_emit.c
@@ -71,7 +71,9 @@ vc4_emit_state(struct pipe_context *pctx)
 vc4->draw_max_y = MAX2(vc4->draw_max_y, maxy);
 }
 
-if (vc4->dirty & (VC4_DIRTY_RASTERIZER | VC4_DIRTY_ZSA)) {
+if (vc4->dirty & (VC4_DIRTY_RASTERIZER |
+  VC4_DIRTY_ZSA |
+  VC4_DIRTY_COMPILED_FS)) {
 uint8_t ez_enable_mask_out = ~0;
 
 /* HW-2905: If the RCL ends up doing a full-res load when
@@ -83,7 +85,7 @@ vc4_emit_state(struct pipe_context *pctx)
  * was seeing bad rendering on glxgears -samples 4 even in
  * that case.
  */
-if (vc4->msaa)
+if (vc4->msaa || vc4->prog.fs->disable_early_z)
 ez_enable_mask_out &= ~VC4_CONFIG_BITS_EARLY_Z;
 
 cl_u8(&bcl, VC4_PACKET_CONFIGURATION_BITS);
diff --git a/src/gallium/drivers/vc4/vc4_program.c 
b/src/gallium/drivers/vc4/vc4_program.c
index 4ee49a258f12..9057b86068e3 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2253,6 +2253,11 @@ vc4_get_compiled_shader(struct vc4_context *vc4, enum 
qstage stage,
 shader->input_slots[shader->num_inputs] = *slot;
 shader->num_inputs++;
 }
+
+/* Note: the temporary clone in c->s has been freed. */
+nir_shader *orig_shader = key->shader_state->base.ir.nir;
+if (orig_shader->info.outputs_written & (1 << 
FRAG_RESULT_DEPTH))
+shader->disable_early_z = true;
 } else {
 shader->num_inputs = c->num_inputs;
 
-- 
2.8.1

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


Re: [Mesa-dev] [PATCH 06/11] vl/util: add copy func for yv12image to nv12surface

2016-07-20 Thread Zhang, Boyuan
Hi Andy,

Thanks very much for providing all the information.

The I420 U V swapping issue still can't be reproduced from my side, I will try 
it again later. CQP issue is fixed in the new patch set I just submitted. 
Please use " ... vaapiencodeh264 rate-control=cqp init-qp=x ..." command, where 
x can be any value b/w 0--51. Please give a try and let me know the result. 
Other issues, e.g. encoding speed, ffmpeg, will be addressed/investigated later 
in separate patch as I mentioned. This initial patch set is to bring up VAAPI 
encode for gstreamer with basic functionality working. I will update with you 
once we make progress.

Regards,
Boyuan 



-Original Message-
From: Andy Furniss [mailto:adf.li...@gmail.com] 
Sent: July-20-16 5:31 AM
To: Zhang, Boyuan; 'Christian König'; mesa-dev@lists.freedesktop.org
Subject: Re: [PATCH 06/11] vl/util: add copy func for yv12image to nv12surface

Zhang, Boyuan wrote:
> Hi Andy,
>
>
> Thanks for the confirmation. It seems like all basic functionality is 
> working now.
>
>
> I will look into the cqp issue. And for the speed related issue, we 
> understand the reason and have already planned to work on it after 
> this bring-up. However, it will be a separate patch in future, and 
> won't be included in this bring-up patch set.

OK, though I didn't list it as remaining below due to sending a separate mail - 
the I420 issue is still present. I don't know what other s/w decoders output, 
but ffmpeg (so  avdec_h264 in a gatreamer pipeline) always seem to use I420 
(yuv420p) rather than YV12 which the conversion assumes.

So far I've been testing with gstreamer. ffmpeg needs patches from libav and 
always had some issues.

I tried again, and there's a possible further regression - though I have no 
idea whether it's ffmpeg or the newer patches here.

Just thought I would mention it, as I haven't had time to look into it further 
yet.

The regression is that when asking for a bitrate there is now a floating point 
exception, -qp still works (comes out at 0 like gst).

andy [vce-tests]$ gdb /mnt/sdb1/Gits/ffmpeg/ffmpeg_g GNU gdb (GDB) 7.10.1 
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /mnt/sdb1/Gits/ffmpeg/ffmpeg_g...done.
(gdb) run -vaapi_device /dev/dri/renderD128 -f rawvideo -framerate 50 -s
2560x1440 -pix_fmt nv12 -i /mnt/ramdisk/trees-1440p50.nv12 -vf 'hwupload' -c:v 
h264_vaapi -profile:v 66 -b:v 40M  -bf 0 -y
/mnt/ramdisk/ffm-40M.264
Starting program: /mnt/sdb1/Gits/ffmpeg/ffmpeg_g -vaapi_device
/dev/dri/renderD128 -f rawvideo -framerate 50 -s 2560x1440 -pix_fmt nv12 -i 
/mnt/ramdisk/trees-1440p50.nv12 -vf 'hwupload' -c:v h264_vaapi -profile:v 66 
-b:v 40M  -bf 0 -y /mnt/ramdisk/ffm-40M.264 [Thread debugging using 
libthread_db enabled] Using host libthread_db library "/lib/libthread_db.so.1".
[New Thread 0x7fffea690700 (LWP 907)]
[New Thread 0x7fffe9c8b700 (LWP 908)]
[New Thread 0x7fffe948a700 (LWP 909)]
[New Thread 0x7fffe8c89700 (LWP 910)]
[New Thread 0x7fffe8488700 (LWP 911)]
[New Thread 0x7fffe7c87700 (LWP 912)]
[New Thread 0x7fffe7486700 (LWP 913)]
[New Thread 0x7fffe6c85700 (LWP 914)]
[New Thread 0x7fffe6484700 (LWP 915)]
[Thread 0x7fffe6484700 (LWP 915) exited] [Thread 0x7fffe6c85700 (LWP 914) 
exited] [Thread 0x7fffe7486700 (LWP 913) exited] [Thread 0x7fffe7c87700 (LWP 
912) exited] ffmpeg version N-81050-g9bf3fdc Copyright (c) 2000-2016 the FFmpeg 
developers
   built with gcc 5.3.0 (GCC)
   configuration: --prefix=/usr --disable-doc --enable-gpl --enable-omx 
--enable-opencl --enable-libzimg --enable-libvpx --enable-libx265 
--enable-libmp3lame --enable-libx264 --enable-gnutls
   libavutil  55. 28.100 / 55. 28.100
   libavcodec 57. 50.100 / 57. 50.100
   libavformat57. 43.100 / 57. 43.100
   libavdevice57.  0.102 / 57.  0.102
   libavfilter 6. 47.100 /  6. 47.100
   libswscale  4.  1.100 /  4.  1.100
   libswresample   2.  1.100 /  2.  1.100
   libpostproc54.  0.100 / 54.  0.100
libva info: VA-API version 0.38.1
libva info: va_getDriverName() returns -1 libva info: User requested driver 
'radeonsi'
libva info: Trying to open /usr/lib/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_0_38 [New Thread 0x7fffe6484700 
(LWP 916)] [New Thread 0x7fffe6c85700 (LWP 917)] [New Thread 0x7fffe7486700 
(LWP 918)] [New Thread 0x7fffe7c87700 (LWP 9

[Mesa-dev] [PATCH v3 00/11] Common pipe screen ref counting

2016-07-20 Thread Rob Herring
Another version of common pipe_screen reference counting.

Changes in v3:
- dup() fd and store in pipe_screen as the lifetime of the 
pipe_loader_drm_device and pipe_screen are different.
- Fix leaking of pipe_loader_drm_device. Only the last one closed was 
getting freed.
- Move mutex for fd hash table into u_screen.c

Rob

Rob Herring (11):
  gallium: move pipe_screen destroy into pipe-loader
  pipe-loader-drm: protect create_screen() calls with a mutex
  gallium: add common pipe_screen reference counting functions
  pipe-loader-drm: use pipe_screen_unreference to destroy screen
  nouveau: use common screen ref counting
  freedreno: use common screen ref counting
  amdgpu: use common screen ref counting
  radeon: use common screen ref counting
  vmwgfx: use common screen ref counting
  vc4: use common screen ref counting
  virgl: use common screen ref counting

 src/gallium/auxiliary/Makefile.sources |   2 +
 src/gallium/auxiliary/pipe-loader/pipe_loader.h|   1 +
 .../auxiliary/pipe-loader/pipe_loader_drm.c|  15 ++-
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c |   6 ++
 src/gallium/auxiliary/util/u_screen.c  | 114 +
 src/gallium/auxiliary/util/u_screen.h  |  32 ++
 src/gallium/auxiliary/vl/vl_winsys_dri.c   |   1 -
 src/gallium/auxiliary/vl/vl_winsys_dri3.c  |   1 -
 src/gallium/auxiliary/vl/vl_winsys_drm.c   |   1 -
 src/gallium/drivers/freedreno/freedreno_screen.c   |   1 -
 src/gallium/drivers/freedreno/freedreno_screen.h   |  10 --
 src/gallium/drivers/nouveau/nouveau_screen.c   |   6 --
 src/gallium/drivers/nouveau/nouveau_screen.h   |   4 -
 src/gallium/drivers/nouveau/nv30/nv30_screen.c |   3 -
 src/gallium/drivers/nouveau/nv50/nv50_screen.c |   3 -
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |   3 -
 src/gallium/drivers/r300/r300_screen.c |   3 -
 src/gallium/drivers/r600/r600_pipe.c   |   6 --
 src/gallium/drivers/radeon/radeon_winsys.h |   8 --
 src/gallium/drivers/radeonsi/si_pipe.c |   6 --
 src/gallium/include/pipe/p_screen.h|   3 +
 src/gallium/state_trackers/clover/core/device.cpp  |   4 +-
 src/gallium/state_trackers/dri/dri_screen.c|   3 -
 src/gallium/state_trackers/xa/xa_tracker.c |   2 -
 src/gallium/tests/trivial/compute.c|   1 -
 src/gallium/tests/trivial/quad-tex.c   |   1 -
 src/gallium/tests/trivial/tri.c|   1 -
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c  |  45 ++--
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h  |   1 -
 .../winsys/freedreno/drm/freedreno_drm_winsys.c|  94 ++---
 .../winsys/nouveau/drm/nouveau_drm_winsys.c|  89 ++--
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c  |  84 ++-
 src/gallium/winsys/svga/drm/vmw_screen.c   |  51 ++---
 src/gallium/winsys/svga/drm/vmw_screen.h   |   6 --
 src/gallium/winsys/vc4/drm/vc4_drm_winsys.c|   9 +-
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c|  86 ++--
 36 files changed, 221 insertions(+), 485 deletions(-)
 create mode 100644 src/gallium/auxiliary/util/u_screen.c
 create mode 100644 src/gallium/auxiliary/util/u_screen.h

-- 
2.9.2

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


[Mesa-dev] [PATCH v3 08/11] radeon: use common screen ref counting

2016-07-20 Thread Rob Herring
Use the common pipe_screen ref counting and fd hashing functions. The
mutex can be dropped as the pipe loader protects the create_screen()
calls.

Signed-off-by: Rob Herring 
Cc: "Marek Olšák" 
Cc: Ilia Mirkin 
---
 src/gallium/drivers/r300/r300_screen.c|  3 -
 src/gallium/drivers/r600/r600_pipe.c  |  6 --
 src/gallium/drivers/radeon/radeon_winsys.h|  8 ---
 src/gallium/drivers/radeonsi/si_pipe.c|  6 --
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 84 ++-
 5 files changed, 7 insertions(+), 100 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_screen.c 
b/src/gallium/drivers/r300/r300_screen.c
index d47b70d..1340009 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -676,9 +676,6 @@ static void r300_destroy_screen(struct pipe_screen* pscreen)
 struct r300_screen* r300screen = r300_screen(pscreen);
 struct radeon_winsys *rws = radeon_winsys(pscreen);
 
-if (rws && !rws->unref(rws))
-  return;
-
 pipe_mutex_destroy(r300screen->cmask_mutex);
 
 if (rws)
diff --git a/src/gallium/drivers/r600/r600_pipe.c 
b/src/gallium/drivers/r600/r600_pipe.c
index f23daf9..c645295 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -570,12 +570,6 @@ static void r600_destroy_screen(struct pipe_screen* 
pscreen)
 {
struct r600_screen *rscreen = (struct r600_screen *)pscreen;
 
-   if (!rscreen)
-   return;
-
-   if (!rscreen->b.ws->unref(rscreen->b.ws))
-   return;
-
if (rscreen->global_pool) {
compute_memory_pool_delete(rscreen->global_pool);
}
diff --git a/src/gallium/drivers/radeon/radeon_winsys.h 
b/src/gallium/drivers/radeon/radeon_winsys.h
index a9c9b9e..2ca19f4 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -426,14 +426,6 @@ struct radeon_winsys {
 struct pipe_screen *screen;
 
 /**
- * Decrement the winsys reference count.
- *
- * \param ws  The winsys this function is called for.
- * \returnTrue if the winsys and screen should be destroyed.
- */
-bool (*unref)(struct radeon_winsys *ws);
-
-/**
  * Destroy this winsys.
  *
  * \param wsThe winsys this function is called from.
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index ee97bcf..1c6920c 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -657,12 +657,6 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
};
unsigned i;
 
-   if (!sscreen)
-   return;
-
-   if (!sscreen->b.ws->unref(sscreen->b.ws))
-   return;
-
if (util_queue_is_initialized(&sscreen->shader_compiler_queue))
util_queue_destroy(&sscreen->shader_compiler_queue);
 
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 1b32c37..7c2c3fc 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -38,11 +38,11 @@
 #include "pipebuffer/pb_bufmgr.h"
 #include "util/u_memory.h"
 #include "util/u_hash_table.h"
+#include "util/u_screen.h"
 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -63,9 +63,6 @@
 #define RADEON_INFO_GPU_RESET_COUNTER   0x26
 #endif
 
-static struct util_hash_table *fd_tab = NULL;
-pipe_static_mutex(fd_tab_mutex);
-
 /* Enable/disable feature access for one command stream.
  * If enable == true, return true on success.
  * Otherwise, return false.
@@ -558,9 +555,6 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws)
 pipe_mutex_destroy(ws->bo_handles_mutex);
 pipe_mutex_destroy(ws->bo_va_mutex);
 
-if (ws->fd >= 0)
-close(ws->fd);
-
 FREE(rws);
 }
 
@@ -665,49 +659,8 @@ static bool radeon_read_registers(struct radeon_winsys 
*rws,
 return true;
 }
 
-static unsigned hash_fd(void *key)
-{
-int fd = pointer_to_intptr(key);
-struct stat stat;
-fstat(fd, &stat);
-
-return stat.st_dev ^ stat.st_ino ^ stat.st_rdev;
-}
-
-static int compare_fd(void *key1, void *key2)
-{
-int fd1 = pointer_to_intptr(key1);
-int fd2 = pointer_to_intptr(key2);
-struct stat stat1, stat2;
-fstat(fd1, &stat1);
-fstat(fd2, &stat2);
-
-return stat1.st_dev != stat2.st_dev ||
-   stat1.st_ino != stat2.st_ino ||
-   stat1.st_rdev != stat2.st_rdev;
-}
-
 DEBUG_GET_ONCE_BOOL_OPTION(thread, "RADEON_THREAD", true)
 
-static bool radeon_winsys_unref(struct radeon_winsys *ws)
-{
-struct radeon_drm_winsys *rws = (struct radeon_drm_winsys*)ws;
-bool destroy;
-
-/* When the reference counter drops to zero, remove the fd from the table.
- * This must happen while the mutex is locked, so that
- * radeon_drm_winsys_

[Mesa-dev] [PATCH v3 06/11] freedreno: use common screen ref counting

2016-07-20 Thread Rob Herring
Use the common pipe_screen ref counting and fd hashing functions. The
mutex can be dropped as the pipe loader protects the create_screen()
calls.

Signed-off-by: Rob Herring 
Cc: Rob Clark 
---
 src/gallium/drivers/freedreno/freedreno_screen.c   |  1 -
 src/gallium/drivers/freedreno/freedreno_screen.h   | 10 ---
 .../winsys/freedreno/drm/freedreno_drm_winsys.c| 94 ++
 3 files changed, 6 insertions(+), 99 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 5255c10..324f712 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -565,7 +565,6 @@ fd_screen_create(struct fd_device *dev)
pscreen = &screen->base;
 
screen->dev = dev;
-   screen->refcnt = 1;
 
// maybe this should be in context?
screen->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D);
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h 
b/src/gallium/drivers/freedreno/freedreno_screen.h
index a81c778..8dcacca 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.h
+++ b/src/gallium/drivers/freedreno/freedreno_screen.h
@@ -42,16 +42,6 @@ struct fd_bo;
 struct fd_screen {
struct pipe_screen base;
 
-   /* it would be tempting to use pipe_reference here, but that
-* really doesn't work well if it isn't the first member of
-* the struct, so not quite so awesome to be adding refcnting
-* further down the inheritance hierarchy:
-*/
-   int refcnt;
-
-   /* place for winsys to stash it's own stuff: */
-   void *winsys_priv;
-
uint32_t gmemsize_bytes;
uint32_t device_id;
uint32_t gpu_id; /* 220, 305, etc */
diff --git a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c 
b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c
index e4785f8..56c021d 100644
--- a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c
+++ b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c
@@ -26,102 +26,20 @@
  *Rob Clark 
  */
 
-#include 
-
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "util/u_format.h"
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-#include "util/u_hash_table.h"
-#include "os/os_thread.h"
+#include "util/u_screen.h"
 
 #include "freedreno_drm_public.h"
 
 #include "freedreno/freedreno_screen.h"
 
-static struct util_hash_table *fd_tab = NULL;
-
-pipe_static_mutex(fd_screen_mutex);
-
-static void
-fd_drm_screen_destroy(struct pipe_screen *pscreen)
-{
-   struct fd_screen *screen = fd_screen(pscreen);
-   boolean destroy;
-
-   pipe_mutex_lock(fd_screen_mutex);
-   destroy = --screen->refcnt == 0;
-   if (destroy) {
-   int fd = fd_device_fd(screen->dev);
-   util_hash_table_remove(fd_tab, intptr_to_pointer(fd));
-   }
-   pipe_mutex_unlock(fd_screen_mutex);
-
-   if (destroy) {
-   pscreen->destroy = screen->winsys_priv;
-   pscreen->destroy(pscreen);
-   }
-}
-
-static unsigned hash_fd(void *key)
-{
-   int fd = pointer_to_intptr(key);
-   struct stat stat;
-   fstat(fd, &stat);
-
-   return stat.st_dev ^ stat.st_ino ^ stat.st_rdev;
-}
-
-static int compare_fd(void *key1, void *key2)
-{
-   int fd1 = pointer_to_intptr(key1);
-   int fd2 = pointer_to_intptr(key2);
-   struct stat stat1, stat2;
-   fstat(fd1, &stat1);
-   fstat(fd2, &stat2);
-
-   return stat1.st_dev != stat2.st_dev ||
-   stat1.st_ino != stat2.st_ino ||
-   stat1.st_rdev != stat2.st_rdev;
-}
-
 struct pipe_screen *
 fd_drm_screen_create(int fd)
 {
-   struct pipe_screen *pscreen = NULL;
-
-   pipe_mutex_lock(fd_screen_mutex);
-   if (!fd_tab) {
-   fd_tab = util_hash_table_create(hash_fd, compare_fd);
-   if (!fd_tab)
-   goto unlock;
-   }
-
-   pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
-   if (pscreen) {
-   fd_screen(pscreen)->refcnt++;
-   } else {
-   struct fd_device *dev = fd_device_new_dup(fd);
-   if (!dev)
-   goto unlock;
-
-   pscreen = fd_screen_create(dev);
-   if (pscreen) {
-   int fd = fd_device_fd(dev);
-
-   util_hash_table_set(fd_tab, intptr_to_pointer(fd), 
pscreen);
-
-   /* Bit of a hack, to avoid circular linkage dependency,
-* ie. pipe driver having to call in to winsys, we
-* override the pipe drivers screen->destroy():
-*/
-   fd_screen(pscreen)->winsys_priv = pscreen->destroy;
-   pscreen->destroy = fd_drm_screen_destroy;
-   }
-   }
+struct pipe_screen *pscreen = pipe_screen_reference(fd);

[Mesa-dev] [PATCH v3 05/11] nouveau: use common screen ref counting

2016-07-20 Thread Rob Herring
Use the common pipe_screen ref counting and fd hashing functions. The
mutex can be dropped as the pipe loader protects the create_screen()
calls.

Signed-off-by: Rob Herring 
Cc: Alexandre Courbot 
---
 src/gallium/drivers/nouveau/nouveau_screen.c   |  6 --
 src/gallium/drivers/nouveau/nouveau_screen.h   |  4 -
 src/gallium/drivers/nouveau/nv30/nv30_screen.c |  3 -
 src/gallium/drivers/nouveau/nv50/nv50_screen.c |  3 -
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |  3 -
 .../winsys/nouveau/drm/nouveau_drm_winsys.c| 89 ++
 6 files changed, 7 insertions(+), 101 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c 
b/src/gallium/drivers/nouveau/nouveau_screen.c
index 2c421cc..41d4bef 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -159,12 +159,6 @@ nouveau_screen_init(struct nouveau_screen *screen, struct 
nouveau_device *dev)
screen->drm = nouveau_drm(&dev->object);
screen->device = dev;
 
-   /*
-* this is initialized to 1 in nouveau_drm_screen_create after screen
-* is fully constructed and added to the global screen list.
-*/
-   screen->refcount = -1;
-
if (dev->chipset < 0xc0) {
   data = &nv04_data;
   size = sizeof(nv04_data);
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h 
b/src/gallium/drivers/nouveau/nouveau_screen.h
index 28c4760..55156c3 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.h
+++ b/src/gallium/drivers/nouveau/nouveau_screen.h
@@ -23,8 +23,6 @@ struct nouveau_screen {
struct nouveau_client *client;
struct nouveau_pushbuf *pushbuf;
 
-   int refcount;
-
unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is desired */
unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is desired */
unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 GiB */
@@ -119,8 +117,6 @@ nouveau_screen(struct pipe_screen *pscreen)
return (struct nouveau_screen *)pscreen;
 }
 
-bool nouveau_drm_screen_unref(struct nouveau_screen *screen);
-
 bool
 nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
  struct nouveau_bo *bo,
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 68d8317..591cf92 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -408,9 +408,6 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
 {
struct nv30_screen *screen = nv30_screen(pscreen);
 
-   if (!nouveau_drm_screen_unref(&screen->base))
-  return;
-
if (screen->base.fence.current) {
   struct nouveau_fence *current = NULL;
 
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 303ecf1..7dbf66f 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -428,9 +428,6 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
 {
struct nv50_screen *screen = nv50_screen(pscreen);
 
-   if (!nouveau_drm_screen_unref(&screen->base))
-  return;
-
if (screen->base.fence.current) {
   struct nouveau_fence *current = NULL;
 
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index f681631..f789de4 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -485,9 +485,6 @@ nvc0_screen_destroy(struct pipe_screen *pscreen)
 {
struct nvc0_screen *screen = nvc0_screen(pscreen);
 
-   if (!nouveau_drm_screen_unref(&screen->base))
-  return;
-
if (screen->base.fence.current) {
   struct nouveau_fence *current = NULL;
 
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c 
b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
index f90572f..9ad3c57 100644
--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
@@ -1,12 +1,9 @@
-#include 
 #include 
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 #include "util/u_format.h"
 #include "util/u_memory.h"
-#include "util/u_inlines.h"
-#include "util/u_hash_table.h"
-#include "os/os_thread.h"
+#include "util/u_screen.h"
 
 #include "nouveau_drm_public.h"
 
@@ -16,47 +13,6 @@
 #include 
 #include 
 
-static struct util_hash_table *fd_tab = NULL;
-
-pipe_static_mutex(nouveau_screen_mutex);
-
-bool nouveau_drm_screen_unref(struct nouveau_screen *screen)
-{
-   int ret;
-   if (screen->refcount == -1)
-   return true;
-
-   pipe_mutex_lock(nouveau_screen_mutex);
-   ret = --screen->refcount;
-   assert(ret >= 0);
-   if (ret == 0)
-   util_hash_table_remove(fd_tab, 
intptr_to_pointer(screen->drm->fd));
-   pipe_mutex_unlock(nouveau_screen_mutex);
-   return ret == 0;
-}
-
-static unsigned hash_fd(void *key)
-{
-   

[Mesa-dev] [PATCH v3 07/11] amdgpu: use common screen ref counting

2016-07-20 Thread Rob Herring
Use the common pipe_screen ref count. amdgpu is unique in its hashing
the dev pointer rather than the fd, so the common fd hashing cannot be
used. However, the same reference count can be used instead of the
private one. The mutex can be dropped as the pipe loader protects the
create_screen() calls.

Signed-off-by: Rob Herring 
Cc: "Marek Olšák" 
Cc: Ilia Mirkin 
---
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 45 ---
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h |  1 -
 2 files changed, 6 insertions(+), 40 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 9a04cbe..56a9672 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -60,8 +60,6 @@
 #define CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_16X16  17
 
 static struct util_hash_table *dev_tab = NULL;
-pipe_static_mutex(dev_tab_mutex);
-
 static unsigned cik_get_num_tile_pipes(struct amdgpu_gpu_info *info)
 {
unsigned mode2d = info->gb_tile_mode[CIK_TILE_MODE_COLOR_2D];
@@ -329,6 +327,7 @@ static void amdgpu_winsys_destroy(struct radeon_winsys *rws)
pipe_mutex_destroy(ws->global_bo_list_lock);
AddrDestroy(ws->addrlib);
amdgpu_device_deinitialize(ws->dev);
+   util_hash_table_remove(dev_tab, ws->dev);
FREE(rws);
 }
 
@@ -410,26 +409,6 @@ static int compare_dev(void *key1, void *key2)
 
 DEBUG_GET_ONCE_BOOL_OPTION(thread, "RADEON_THREAD", true)
 
-static bool amdgpu_winsys_unref(struct radeon_winsys *rws)
-{
-   struct amdgpu_winsys *ws = (struct amdgpu_winsys*)rws;
-   bool destroy;
-
-   /* When the reference counter drops to zero, remove the device pointer
-* from the table.
-* This must happen while the mutex is locked, so that
-* amdgpu_winsys_create in another thread doesn't get the winsys
-* from the table when the counter drops to 0. */
-   pipe_mutex_lock(dev_tab_mutex);
-
-   destroy = pipe_reference(&ws->reference, NULL);
-   if (destroy && dev_tab)
-  util_hash_table_remove(dev_tab, ws->dev);
-
-   pipe_mutex_unlock(dev_tab_mutex);
-   return destroy;
-}
-
 PUBLIC struct radeon_winsys *
 amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create)
 {
@@ -446,7 +425,6 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t 
screen_create)
drmFreeVersion(version);
 
/* Look up the winsys from the dev table. */
-   pipe_mutex_lock(dev_tab_mutex);
if (!dev_tab)
   dev_tab = util_hash_table_create(hash_dev, compare_dev);
 
@@ -454,7 +432,6 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t 
screen_create)
 * for the same fd. */
r = amdgpu_device_initialize(fd, &drm_major, &drm_minor, &dev);
if (r) {
-  pipe_mutex_unlock(dev_tab_mutex);
   fprintf(stderr, "amdgpu: amdgpu_device_initialize failed.\n");
   return NULL;
}
@@ -462,17 +439,14 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t 
screen_create)
/* Lookup a winsys if we have already created one for this device. */
ws = util_hash_table_get(dev_tab, dev);
if (ws) {
-  pipe_reference(NULL, &ws->reference);
-  pipe_mutex_unlock(dev_tab_mutex);
+  pipe_reference(NULL, &ws->base.screen->reference);
   return &ws->base;
}
 
/* Create a new winsys. */
ws = CALLOC_STRUCT(amdgpu_winsys);
-   if (!ws) {
-  pipe_mutex_unlock(dev_tab_mutex);
+   if (!ws)
   return NULL;
-   }
 
ws->dev = dev;
ws->info.drm_major = drm_major;
@@ -486,11 +460,7 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t 
screen_create)
  (ws->info.vram_size + ws->info.gart_size) / 8,
  amdgpu_bo_destroy, amdgpu_bo_can_reclaim);
 
-   /* init reference */
-   pipe_reference_init(&ws->reference, 1);
-
/* Set functions. */
-   ws->base.unref = amdgpu_winsys_unref;
ws->base.destroy = amdgpu_winsys_destroy;
ws->base.query_info = amdgpu_winsys_query_info;
ws->base.cs_request_feature = amdgpu_cs_request_feature;
@@ -516,21 +486,18 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t 
screen_create)
ws->base.screen = screen_create(&ws->base);
if (!ws->base.screen) {
   amdgpu_winsys_destroy(&ws->base);
-  pipe_mutex_unlock(dev_tab_mutex);
   return NULL;
}
 
util_hash_table_set(dev_tab, dev, ws);
 
-   /* We must unlock the mutex once the winsys is fully initialized, so that
-* other threads attempting to create the winsys from the same fd will
-* get a fully initialized winsys and not just half-way initialized. */
-   pipe_mutex_unlock(dev_tab_mutex);
+   /* init reference */
+   pipe_reference_init(&ws->base.screen->reference, 1);
+
 
return &ws->base;
 
 fail:
-   pipe_mutex_unlock(dev_tab_mutex);
pb_cache_deinit(&ws->bo_cache);
FREE(ws);
return NULL;
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h 
b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
index 8489530..b45c2d7 100644
--- a/src/gallium/winsys/amdgpu/drm/am

[Mesa-dev] [PATCH v3 02/11] pipe-loader-drm: protect create_screen() calls with a mutex

2016-07-20 Thread Rob Herring
Creating a screen needs to be serialized in order to support reusing
existing screen. With this, driver private mutexes in create_screen()
functions can be removed.

Signed-off-by: Rob Herring 
Cc: Emil Velikov 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 7bdd2ec..554e59a 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -41,6 +41,7 @@
 #include "pipe_loader_priv.h"
 #include "pipe/p_screen.h"
 
+#include "os/os_thread.h"
 #include "util/u_memory.h"
 #include "util/u_dl.h"
 #include "util/u_debug.h"
@@ -63,6 +64,8 @@ struct pipe_loader_drm_device {
 
 static const struct pipe_loader_ops pipe_loader_drm_ops;
 
+pipe_static_mutex(loader_mutex);
+
 #ifdef GALLIUM_STATIC_TARGETS
 static const struct drm_conf_ret throttle_ret = {
DRM_CONF_INT,
@@ -303,8 +306,10 @@ pipe_loader_drm_create_screen(struct pipe_loader_device 
*dev)
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
struct pipe_screen *pscreen;
 
+   pipe_mutex_lock(loader_mutex);
pscreen = ddev->dd->create_screen(ddev->fd);
ddev->base.pscreen = pscreen;
+   pipe_mutex_unlock(loader_mutex);
return pscreen;
 }
 
-- 
2.9.2

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


[Mesa-dev] [PATCH v3 09/11] vmwgfx: use common screen ref counting

2016-07-20 Thread Rob Herring
Use the common pipe_screen ref counting and fd hashing functions. The
mutex can be dropped as the pipe loader protects the create_screen()
calls.

Signed-off-by: Rob Herring 
---
 src/gallium/winsys/svga/drm/vmw_screen.c | 51 
 src/gallium/winsys/svga/drm/vmw_screen.h |  6 
 2 files changed, 6 insertions(+), 51 deletions(-)

diff --git a/src/gallium/winsys/svga/drm/vmw_screen.c 
b/src/gallium/winsys/svga/drm/vmw_screen.c
index 7fcb6d2..2b05012 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen.c
+++ b/src/gallium/winsys/svga/drm/vmw_screen.c
@@ -30,24 +30,9 @@
 
 #include "util/u_memory.h"
 #include "pipe/p_compiler.h"
-#include "util/u_hash_table.h"
 #include 
-#include 
 #include 
 
-static struct util_hash_table *dev_hash = NULL;
-
-static int vmw_dev_compare(void *key1, void *key2)
-{
-   return (major(*(dev_t *)key1) == major(*(dev_t *)key2) &&
-   minor(*(dev_t *)key1) == minor(*(dev_t *)key2)) ? 0 : 1;
-}
-
-static unsigned vmw_dev_hash(void *key)
-{
-   return (major(*(dev_t *) key) << 16) | minor(*(dev_t *) key);
-}
-
 /* Called from vmw_drm_create_screen(), creates and initializes the
  * vmw_winsys_screen structure, which is the main entity in this
  * module.
@@ -60,29 +45,11 @@ struct vmw_winsys_screen *
 vmw_winsys_create( int fd )
 {
struct vmw_winsys_screen *vws;
-   struct stat stat_buf;
-
-   if (dev_hash == NULL) {
-  dev_hash = util_hash_table_create(vmw_dev_hash, vmw_dev_compare);
-  if (dev_hash == NULL)
- return NULL;
-   }
-
-   if (fstat(fd, &stat_buf))
-  return NULL;
-
-   vws = util_hash_table_get(dev_hash, &stat_buf.st_rdev);
-   if (vws) {
-  vws->open_count++;
-  return vws;
-   }
 
vws = CALLOC_STRUCT(vmw_winsys_screen);
if (!vws)
   goto out_no_vws;
 
-   vws->device = stat_buf.st_rdev;
-   vws->open_count = 1;
vws->ioctl.drm_fd = dup(fd);
vws->base.have_gb_dma = TRUE;
vws->base.need_to_rebind_resources = FALSE;
@@ -100,11 +67,8 @@ vmw_winsys_create( int fd )
if (!vmw_winsys_screen_init_svga(vws))
   goto out_no_svga;
 
-   if (util_hash_table_set(dev_hash, &vws->device, vws) != PIPE_OK)
-  goto out_no_hash_insert;
-
return vws;
-out_no_hash_insert:
+
 out_no_svga:
vmw_pools_cleanup(vws);
 out_no_pools:
@@ -121,12 +85,9 @@ out_no_vws:
 void
 vmw_winsys_destroy(struct vmw_winsys_screen *vws)
 {
-   if (--vws->open_count == 0) {
-  util_hash_table_remove(dev_hash, &vws->device);
-  vmw_pools_cleanup(vws);
-  vws->fence_ops->destroy(vws->fence_ops);
-  vmw_ioctl_cleanup(vws);
-  close(vws->ioctl.drm_fd);
-  FREE(vws);
-   }
+   vmw_pools_cleanup(vws);
+   vws->fence_ops->destroy(vws->fence_ops);
+   vmw_ioctl_cleanup(vws);
+   close(vws->ioctl.drm_fd);
+   FREE(vws);
 }
diff --git a/src/gallium/winsys/svga/drm/vmw_screen.h 
b/src/gallium/winsys/svga/drm/vmw_screen.h
index 79d0949..cfde6bb 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen.h
+++ b/src/gallium/winsys/svga/drm/vmw_screen.h
@@ -93,12 +93,6 @@ struct vmw_winsys_screen
} pools;
 
struct pb_fence_ops *fence_ops;
-
-   /*
-* Screen instances
-*/
-   dev_t device;
-   int open_count;
 };
 
 
-- 
2.9.2

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


[Mesa-dev] [PATCH v3 01/11] gallium: move pipe_screen destroy into pipe-loader

2016-07-20 Thread Rob Herring
In preparation to add reference counting of pipe_screen in the pipe-loader,
pipe_loader_release needs to destroy the pipe_screen instead of state
trackers.

Signed-off-by: Rob Herring 
Cc: Emil Velikov 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader.h | 1 +
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 9 -
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c  | 6 ++
 src/gallium/auxiliary/vl/vl_winsys_dri.c| 1 -
 src/gallium/auxiliary/vl/vl_winsys_dri3.c   | 1 -
 src/gallium/auxiliary/vl/vl_winsys_drm.c| 1 -
 src/gallium/state_trackers/clover/core/device.cpp   | 4 +---
 src/gallium/state_trackers/dri/dri_screen.c | 3 ---
 src/gallium/state_trackers/xa/xa_tracker.c  | 2 --
 src/gallium/tests/trivial/compute.c | 1 -
 src/gallium/tests/trivial/quad-tex.c| 1 -
 src/gallium/tests/trivial/tri.c | 1 -
 12 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h 
b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index 690d088..25cd4d1 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -65,6 +65,7 @@ struct pipe_loader_device {
 
char *driver_name;
const struct pipe_loader_ops *ops;
+   struct pipe_screen *pscreen;
 };
 
 /**
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 994a284..7bdd2ec 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -39,6 +39,7 @@
 #include "target-helpers/drm_helper_public.h"
 #include "state_tracker/drm_driver.h"
 #include "pipe_loader_priv.h"
+#include "pipe/p_screen.h"
 
 #include "util/u_memory.h"
 #include "util/u_dl.h"
@@ -269,6 +270,9 @@ static void
 pipe_loader_drm_release(struct pipe_loader_device **dev)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev);
+   struct pipe_screen *pscreen = ddev->base.pscreen;
+
+   pscreen->destroy(pscreen);
 
 #ifndef GALLIUM_STATIC_TARGETS
if (ddev->lib)
@@ -297,8 +301,11 @@ static struct pipe_screen *
 pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
+   struct pipe_screen *pscreen;
 
-   return ddev->dd->create_screen(ddev->fd);
+   pscreen = ddev->dd->create_screen(ddev->fd);
+   ddev->base.pscreen = pscreen;
+   return pscreen;
 }
 
 static const struct pipe_loader_ops pipe_loader_drm_ops = {
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index e7fa974..ce5c2b3 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -27,6 +27,7 @@
 
 #include "pipe_loader_priv.h"
 
+#include "pipe/p_screen.h"
 #include "util/u_memory.h"
 #include "util/u_dl.h"
 #include "sw/dri/dri_sw_winsys.h"
@@ -271,6 +272,9 @@ static void
 pipe_loader_sw_release(struct pipe_loader_device **dev)
 {
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
+   struct pipe_screen *pscreen = sdev->base.pscreen;
+
+   pscreen->destroy(pscreen);
 
 #ifndef GALLIUM_STATIC_TARGETS
if (sdev->lib)
@@ -301,6 +305,8 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev)
if (!screen)
   sdev->ws->destroy(sdev->ws);
 
+   sdev->base.pscreen = screen;
+
return screen;
 }
 
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 9ecc216..db90c54 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -461,7 +461,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen)
}
 
vl_dri2_destroy_drawable(scrn);
-   scrn->base.pscreen->destroy(scrn->base.pscreen);
pipe_loader_release(&scrn->base.dev, 1);
FREE(scrn);
 }
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 493e645..c8c0198 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -611,7 +611,6 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen)
 
if (scrn->special_event)
   xcb_unregister_for_special_event(scrn->conn, scrn->special_event);
-   scrn->base.pscreen->destroy(scrn->base.pscreen);
pipe_loader_release(&scrn->base.dev, 1);
FREE(scrn);
 
diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c 
b/src/gallium/auxiliary/vl/vl_winsys_drm.c
index 6a759ae..aa690a2 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_drm.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c
@@ -80,7 +80,6 @@ vl_drm_screen_destroy(struct vl_screen *vscreen)
 {
assert(vscreen);
 
-   vscreen->pscreen->destroy(vscreen->pscreen);
pipe_loader_release(&vscreen->dev, 1);
FREE(vscreen);
 }
diff --git a/src/gallium/state_trackers/clover/core/devic

[Mesa-dev] [PATCH v3 04/11] pipe-loader-drm: use pipe_screen_unreference to destroy screen

2016-07-20 Thread Rob Herring
Use pipe_screen_unreference as it will call pipe_screen->destroy() when
the pipe_screen is no longer referenced.

The pipe_screen referencing is done within create_screen() functions
as drivers (like amdgpu) may have special needs for ref counting.

Signed-off-by: Rob Herring 
Cc: Emil Velikov 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 554e59a..2edb291 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -45,6 +45,7 @@
 #include "util/u_memory.h"
 #include "util/u_dl.h"
 #include "util/u_debug.h"
+#include "util/u_screen.h"
 
 #define DRM_RENDER_NODE_DEV_NAME_FORMAT "%s/renderD%d"
 #define DRM_RENDER_NODE_MAX_NODES 63
@@ -275,7 +276,7 @@ pipe_loader_drm_release(struct pipe_loader_device **dev)
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev);
struct pipe_screen *pscreen = ddev->base.pscreen;
 
-   pscreen->destroy(pscreen);
+   pipe_screen_unreference(pscreen);
 
 #ifndef GALLIUM_STATIC_TARGETS
if (ddev->lib)
-- 
2.9.2

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


[Mesa-dev] [PATCH v3 03/11] gallium: add common pipe_screen reference counting functions

2016-07-20 Thread Rob Herring
In order to prevent multiple pipe_screens being created in the same
process, lookup of the DRM FD and reference counting of the pipe_screen
are needed. Several implementations of this exist in various gallium
drivers/winsys already. This creates a common version which is opt-in
for winsys implementations.

Signed-off-by: Rob Herring 
---
 src/gallium/auxiliary/Makefile.sources |   2 +
 src/gallium/auxiliary/util/u_screen.c  | 114 +
 src/gallium/auxiliary/util/u_screen.h  |  32 +
 src/gallium/include/pipe/p_screen.h|   3 +
 4 files changed, 151 insertions(+)
 create mode 100644 src/gallium/auxiliary/util/u_screen.c
 create mode 100644 src/gallium/auxiliary/util/u_screen.h

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index e0311bf..197ed36 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -284,6 +284,8 @@ C_SOURCES := \
util/u_ringbuffer.h \
util/u_sampler.c \
util/u_sampler.h \
+   util/u_screen.c \
+   util/u_screen.h \
util/u_simple_shaders.c \
util/u_simple_shaders.h \
util/u_slab.c \
diff --git a/src/gallium/auxiliary/util/u_screen.c 
b/src/gallium/auxiliary/util/u_screen.c
new file mode 100644
index 000..14be569
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 Linaro, Ltd., Rob Herring 
+ *
+ * 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, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
+ */
+
+/**
+ * Functions for managing pipe_screen's
+ */
+
+#include 
+
+#include "os/os_thread.h"
+
+#include "pipe/p_screen.h"
+#include "util/u_hash_table.h"
+#include "util/u_inlines.h"
+#include "util/u_pointer.h"
+#include "util/u_screen.h"
+
+static struct util_hash_table *fd_tab = NULL;
+pipe_static_mutex(fd_tab_mutex);
+
+static unsigned hash_fd(void *key)
+{
+   int fd = pointer_to_intptr(key);
+   struct stat stat;
+   fstat(fd, &stat);
+
+   return stat.st_dev ^ stat.st_ino ^ stat.st_rdev;
+}
+
+static int compare_fd(void *key1, void *key2)
+{
+   int fd1 = pointer_to_intptr(key1);
+   int fd2 = pointer_to_intptr(key2);
+   struct stat stat1, stat2;
+   fstat(fd1, &stat1);
+   fstat(fd2, &stat2);
+
+   return stat1.st_dev != stat2.st_dev ||
+ stat1.st_ino != stat2.st_ino ||
+ stat1.st_rdev != stat2.st_rdev;
+}
+
+struct pipe_screen *
+pipe_screen_reference(int fd)
+{
+   struct pipe_screen *pscreen;
+
+   if (!fd_tab) {
+  fd_tab = util_hash_table_create(hash_fd, compare_fd);
+  return NULL;
+   }
+
+   pipe_mutex_lock(fd_tab_mutex);
+   pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
+   if (pscreen)
+  pipe_reference(NULL, &pscreen->reference);
+   pipe_mutex_unlock(fd_tab_mutex);
+
+   return pscreen;
+}
+
+boolean
+pipe_screen_unreference(struct pipe_screen *pscreen)
+{
+   boolean destroy;
+
+   if (!pscreen)
+  return FALSE;
+
+   /* Work-around until all pipe_screens have ref counting */
+   if (!pipe_is_referenced(&pscreen->reference)) {
+  pscreen->destroy(pscreen);
+  return TRUE;
+   }
+
+   pipe_mutex_lock(fd_tab_mutex);
+   destroy = pipe_reference(&pscreen->reference, NULL);
+   if (destroy) {
+  pscreen->destroy(pscreen);
+  util_hash_table_remove(fd_tab, intptr_to_pointer(pscreen->fd));
+  close(pscreen->fd);
+   }
+   pipe_mutex_unlock(fd_tab_mutex);
+   return destroy;
+}
+
+
+void pipe_screen_reference_init(struct pipe_screen *pscreen, int fd)
+{
+   pscreen->fd = dup(fd);
+   pipe_reference_init(&pscreen->reference, 1);
+   util_hash_table_set(fd_tab, intptr_to_pointer(pscreen->fd), pscreen);
+}
diff --git a/src/gallium/auxiliary/util/u_screen.h 
b/src/gallium/auxiliary/util/u_screen.h
new file mode 100644
index 000..fc91782
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_screen.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016 Linaro, Ltd., Rob Herring 
+ *
+ * Permiss

[Mesa-dev] [PATCH v3 10/11] vc4: use common screen ref counting

2016-07-20 Thread Rob Herring
Use the common pipe_screen ref counting and fd hashing functions. The
mutex can be dropped as the pipe loader protects the create_screen()
calls.

Cc: Eric Anholt 
Signed-off-by: Rob Herring 
---
 src/gallium/winsys/vc4/drm/vc4_drm_winsys.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c 
b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c
index c5434ad..acda743 100644
--- a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c
+++ b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c
@@ -22,6 +22,7 @@
  */
 
 #include 
+#include "util/u_screen.h"
 
 #include "vc4_drm_public.h"
 
@@ -30,5 +31,11 @@
 struct pipe_screen *
 vc4_drm_screen_create(int fd)
 {
-   return vc4_screen_create(dup(fd));
+struct pipe_screen *pscreen = pipe_screen_reference(fd);
+if (pscreen)
+return pscreen;
+
+   pscreen = vc4_screen_create(dup(fd));
+   pipe_screen_reference_init(pscreen, fd);
+   return pscreen;
 }
-- 
2.9.2

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


[Mesa-dev] [PATCH v3 11/11] virgl: use common screen ref counting

2016-07-20 Thread Rob Herring
Use the common pipe_screen ref counting and fd hashing functions.
The mutex can be dropped as the pipe loader protects the create_screen()
calls. The fd does not need to be dup'ed as the caller has already done
that.

Signed-off-by: Rob Herring 
Cc: Dave Airlie 
---
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 86 +++--
 1 file changed, 8 insertions(+), 78 deletions(-)

diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c 
b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index 81afa84..0f35dd0 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "os/os_mman.h"
 #include "os/os_time.h"
@@ -33,6 +32,7 @@
 #include "util/u_format.h"
 #include "util/u_hash_table.h"
 #include "util/u_inlines.h"
+#include "util/u_screen.h"
 #include "state_tracker/drm_driver.h"
 #include "virgl/virgl_screen.h"
 #include "virgl/virgl_public.h"
@@ -802,86 +802,16 @@ virgl_drm_winsys_create(int drmFD)
 
 }
 
-static struct util_hash_table *fd_tab = NULL;
-pipe_static_mutex(virgl_screen_mutex);
-
-static void
-virgl_drm_screen_destroy(struct pipe_screen *pscreen)
-{
-   struct virgl_screen *screen = virgl_screen(pscreen);
-   boolean destroy;
-
-   pipe_mutex_lock(virgl_screen_mutex);
-   destroy = --screen->refcnt == 0;
-   if (destroy) {
-  int fd = virgl_drm_winsys(screen->vws)->fd;
-  util_hash_table_remove(fd_tab, intptr_to_pointer(fd));
-   }
-   pipe_mutex_unlock(virgl_screen_mutex);
-
-   if (destroy) {
-  pscreen->destroy = screen->winsys_priv;
-  pscreen->destroy(pscreen);
-   }
-}
-
-static unsigned hash_fd(void *key)
-{
-   int fd = pointer_to_intptr(key);
-   struct stat stat;
-   fstat(fd, &stat);
-
-   return stat.st_dev ^ stat.st_ino ^ stat.st_rdev;
-}
-
-static int compare_fd(void *key1, void *key2)
-{
-   int fd1 = pointer_to_intptr(key1);
-   int fd2 = pointer_to_intptr(key2);
-   struct stat stat1, stat2;
-   fstat(fd1, &stat1);
-   fstat(fd2, &stat2);
-
-   return stat1.st_dev != stat2.st_dev ||
- stat1.st_ino != stat2.st_ino ||
- stat1.st_rdev != stat2.st_rdev;
-}
-
 struct pipe_screen *
 virgl_drm_screen_create(int fd)
 {
-   struct pipe_screen *pscreen = NULL;
-
-   pipe_mutex_lock(virgl_screen_mutex);
-   if (!fd_tab) {
-  fd_tab = util_hash_table_create(hash_fd, compare_fd);
-  if (!fd_tab)
- goto unlock;
-   }
-
-   pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
-   if (pscreen) {
-  virgl_screen(pscreen)->refcnt++;
-   } else {
-  struct virgl_winsys *vws;
-  int dup_fd = dup(fd);
-
-  vws = virgl_drm_winsys_create(dup_fd);
-
-  pscreen = virgl_create_screen(vws);
-  if (pscreen) {
- util_hash_table_set(fd_tab, intptr_to_pointer(dup_fd), pscreen);
-
- /* Bit of a hack, to avoid circular linkage dependency,
-  * ie. pipe driver having to call in to winsys, we
-  * override the pipe drivers screen->destroy():
-  */
- virgl_screen(pscreen)->winsys_priv = pscreen->destroy;
- pscreen->destroy = virgl_drm_screen_destroy;
-  }
-   }
+   struct virgl_winsys *vws;
+   struct pipe_screen *pscreen = pipe_screen_reference(fd);
+   if (pscreen)
+  return pscreen;
 
-unlock:
-   pipe_mutex_unlock(virgl_screen_mutex);
+   vws = virgl_drm_winsys_create(fd);
+   pscreen = virgl_create_screen(vws);
+   pipe_screen_reference_init(pscreen, fd);
return pscreen;
 }
-- 
2.9.2

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


[Mesa-dev] [PATCH 3/8] glsl/nir: Call nir_lower_constant_initializers

2016-07-20 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
---
 src/compiler/glsl/glsl_to_nir.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index 20302e3..e6171d9 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -143,6 +143,8 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
v2.run(sh->ir);
visit_exec_list(sh->ir, &v1);
 
+   nir_lower_constant_initializers(shader, (nir_variable_mode)~0);
+
shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
if (shader_prog->Label)
   shader->info.label = ralloc_strdup(shader, shader_prog->Label);
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 2/8] anv/pipeline: Call nir_lower_constant_initializers

2016-07-20 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
---
 src/intel/vulkan/anv_pipeline.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 3723423..df57182 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -149,6 +149,13 @@ anv_shader_compile_to_nir(struct anv_device *device,
   nir_lower_returns(nir);
   nir_validate_shader(nir);
 
+  /* We have to lower away local constant initializers right before we
+   * inline functions.  That way they get properly initialized at the top
+   * of the function and not at the top of its caller.
+   */
+  nir_lower_constant_initializers(nir, nir_var_local);
+  nir_validate_shader(nir);
+
   nir_inline_functions(nir);
   nir_validate_shader(nir);
 
@@ -165,6 +172,12 @@ anv_shader_compile_to_nir(struct anv_device *device,
   nir_remove_dead_variables(nir, nir_var_system_value);
   nir_validate_shader(nir);
 
+  /* Now that we've deleted all but the main function, we can go ahead and
+   * lower the rest of the constant initializers.
+   */
+  nir_lower_constant_initializers(nir, ~0);
+  nir_validate_shader(nir);
+
   nir_propagate_invariant(nir);
   nir_validate_shader(nir);
 
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 5/8] nir: Simplify nir_lower_gs_intrinsics

2016-07-20 Thread Jason Ekstrand
It's only ever called on single-function shaders.  At this point, there are
a lot of helpers that can make it all much simpler.

Signed-off-by: Jason Ekstrand 
---
 src/compiler/nir/nir_lower_gs_intrinsics.c | 37 +-
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/src/compiler/nir/nir_lower_gs_intrinsics.c 
b/src/compiler/nir/nir_lower_gs_intrinsics.c
index 9bbaf83..13a4399 100644
--- a/src/compiler/nir/nir_lower_gs_intrinsics.c
+++ b/src/compiler/nir/nir_lower_gs_intrinsics.c
@@ -188,32 +188,27 @@ nir_lower_gs_intrinsics(nir_shader *shader)
struct state state;
state.progress = false;
 
-   /* Create the counter variable */
-   nir_variable *var = rzalloc(shader, nir_variable);
-   var->data.mode = nir_var_global;
-   var->type = glsl_uint_type();
-   var->name = "vertex_count";
-   var->constant_initializer = rzalloc(shader, nir_constant); /* initialize to 
0 */
+   nir_function_impl *impl = nir_shader_get_entrypoint(shader)->impl;
+   assert(impl);
 
-   exec_list_push_tail(&shader->globals, &var->node);
-   state.vertex_count_var = var;
+   nir_builder b;
+   nir_builder_init(&b, impl);
+   state.builder = &b;
 
-   nir_foreach_function(function, shader) {
-  if (function->impl) {
- nir_builder b;
- nir_builder_init(&b, function->impl);
- state.builder = &b;
+   /* Create the counter variable */
+   state.vertex_count_var =
+  nir_local_variable_create(impl, glsl_uint_type(), "vertex_count");
+   /* initialize to 0 */
+   b.cursor = nir_before_cf_list(&impl->body);
+   nir_store_var(&b, state.vertex_count_var, nir_imm_int(&b, 0), 0x1);
 
- nir_foreach_block_safe(block, function->impl) {
-rewrite_intrinsics(block, &state);
- }
+   nir_foreach_block_safe(block, impl)
+  rewrite_intrinsics(block, &state);
 
- /* This only works because we have a single main() function. */
- append_set_vertex_count(function->impl->end_block, &state);
+   /* This only works because we have a single main() function. */
+   append_set_vertex_count(impl->end_block, &state);
 
- nir_metadata_preserve(function->impl, 0);
-  }
-   }
+   nir_metadata_preserve(impl, 0);
 
return state.progress;
 }
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 7/8] nir: Delete most of the constant_initializer support

2016-07-20 Thread Jason Ekstrand
Constant initializers have been a constant (ha!) pain for quite some time.
While they're useful from a language perspective, people writing passes or
backends really don't want deal with them most of the time.  This commit
removes most of the constant initializer support from NIR.  It is expected
that you call nir_lower_constant_initializers VERY EARLY to ensure that
they're gone before you do anything interesting.

Signed-off-by: Jason Ekstrand 
---
 src/compiler/nir/nir.h |  4 ++
 src/compiler/nir/nir_inline_functions.c| 42 +---
 src/compiler/nir/nir_lower_io_to_temporaries.c |  4 +-
 src/compiler/nir/nir_lower_locals_to_regs.c| 92 +-
 src/compiler/nir/nir_lower_vars_to_ssa.c   | 17 +
 5 files changed, 12 insertions(+), 147 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 99c2fc0..93b7e1e 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -324,6 +324,10 @@ typedef struct nir_variable {
 
/**
 * Constant expression assigned in the initializer of the variable
+*
+* This field should only be used temporarily by creators of NIR shaders
+* and then lower_constant_initializers can be used to get rid of them.
+* Most of the rest of NIR ignores this field or asserts that it's NULL.
 */
nir_constant *constant_initializer;
 
diff --git a/src/compiler/nir/nir_inline_functions.c 
b/src/compiler/nir/nir_inline_functions.c
index cf31e14..c36748d 100644
--- a/src/compiler/nir/nir_inline_functions.c
+++ b/src/compiler/nir/nir_inline_functions.c
@@ -25,20 +25,6 @@
 #include "nir_builder.h"
 #include "nir_control_flow.h"
 
-static bool
-deref_apply_constant_initializer(nir_deref_var *deref, void *state)
-{
-   struct nir_builder *b = state;
-
-   nir_load_const_instr *initializer =
-  nir_deref_get_const_initializer_load(b->shader, deref);
-   nir_builder_instr_insert(b, &initializer->instr);
-
-   nir_store_deref_var(b, deref, &initializer->def, 0xf);
-
-   return true;
-}
-
 static bool inline_function_impl(nir_function_impl *impl, struct set *inlined);
 
 static void
@@ -188,35 +174,11 @@ inline_functions_block(nir_block *block, nir_builder *b,
   /* Add copies of all in parameters */
   assert(call->num_params == callee_copy->num_params);
 
-  b->cursor = nir_before_instr(&call->instr);
-
-  /* Before we insert the copy of the function, we need to lower away
-   * constant initializers on local variables.  This is because constant
-   * initializers happen (effectively) at the top of the function and,
-   * since these are about to become locals of the calling function,
-   * initialization will happen at the top of the caller rather than at
-   * the top of the callee.  This isn't usually a problem, but if we are
-   * being inlined inside of a loop, it can result in the variable not
-   * getting re-initialized properly for all loop iterations.
-   */
-  nir_foreach_variable(local, &callee_copy->locals) {
- if (!local->constant_initializer)
-continue;
-
- nir_deref_var deref;
- deref.deref.deref_type = nir_deref_type_var,
- deref.deref.child = NULL;
- deref.deref.type = local->type,
- deref.var = local;
-
- nir_deref_foreach_leaf(&deref, deref_apply_constant_initializer, b);
-
- local->constant_initializer = NULL;
-  }
-
   exec_list_append(&b->impl->locals, &callee_copy->locals);
   exec_list_append(&b->impl->registers, &callee_copy->registers);
 
+  b->cursor = nir_before_instr(&call->instr);
+
   /* We now need to tie the two functions together using the
* parameters.  There are two ways we do this: One is to turn the
* parameter into a local variable and do a shadow-copy.  The other
diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c 
b/src/compiler/nir/nir_lower_io_to_temporaries.c
index 3153a49..7a72cdb 100644
--- a/src/compiler/nir/nir_lower_io_to_temporaries.c
+++ b/src/compiler/nir/nir_lower_io_to_temporaries.c
@@ -114,14 +114,12 @@ create_shadow_temp(struct lower_io_state *state, 
nir_variable *var)
/* Reparent the name to the new variable */
ralloc_steal(nvar, nvar->name);
 
-   /* Reparent the constant initializer (if any) */
-   ralloc_steal(nvar, nvar->constant_initializer);
+   assert(nvar->constant_initializer == NULL);
 
/* Give the original a new name with @-temp appended */
const char *mode = (temp->data.mode == nir_var_shader_in) ? "in" : "out";
temp->name = ralloc_asprintf(var, "%s@%s-temp", mode, nvar->name);
temp->data.mode = nir_var_global;
-   temp->constant_initializer = NULL;
 
return nvar;
 }
diff --git a/src/compiler/nir/nir_lower_locals_to_regs.c 
b/src/compiler/nir/nir_lower_locals_to_regs.c
index 61cc7fa..25a62b3 100644
--- a/src/compiler/nir/nir_lower_locals_to_regs.c
+++ b/src/compiler/nir/nir_lower_locals_to_regs.c
@@ -101,6 +1

[Mesa-dev] [PATCH 8/8] nir: Remove some unused fields from nir_variable

2016-07-20 Thread Jason Ekstrand
All of these are happily set from glsl_to_nir or spirv_to_nir but their
values are never used for anything.

Signed-off-by: Jason Ekstrand 
---
 src/compiler/glsl/glsl_to_nir.cpp  |  5 -
 src/compiler/nir/nir.h | 34 --
 src/compiler/spirv/vtn_variables.c |  4 
 3 files changed, 43 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index e6171d9..4d7c4b3 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -372,10 +372,6 @@ nir_visitor::visit(ir_variable *ir)
var->data.interpolation = ir->data.interpolation;
var->data.origin_upper_left = ir->data.origin_upper_left;
var->data.pixel_center_integer = ir->data.pixel_center_integer;
-   var->data.explicit_location = ir->data.explicit_location;
-   var->data.explicit_index = ir->data.explicit_index;
-   var->data.explicit_binding = ir->data.explicit_binding;
-   var->data.has_initializer = ir->data.has_initializer;
var->data.location_frac = ir->data.location_frac;
 
switch (ir->data.depth_layout) {
@@ -407,7 +403,6 @@ nir_visitor::visit(ir_variable *ir)
var->data.image._volatile = ir->data.image_volatile;
var->data.image.restrict_flag = ir->data.image_restrict;
var->data.image.format = ir->data.image_format;
-   var->data.max_array_access = ir->data.max_array_access;
 
var->num_state_slots = ir->get_num_state_slots();
if (var->num_state_slots > 0) {
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 93b7e1e..a30b4f0 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -192,32 +192,6 @@ typedef struct nir_variable {
   /*@}*/
 
   /**
-   * Was the location explicitly set in the shader?
-   *
-   * If the location is explicitly set in the shader, it \b cannot be 
changed
-   * by the linker or by the API (e.g., calls to \c glBindAttribLocation 
have
-   * no effect).
-   */
-  unsigned explicit_location:1;
-  unsigned explicit_index:1;
-
-  /**
-   * Was an initial binding explicitly set in the shader?
-   *
-   * If so, constant_initializer contains an integer nir_constant
-   * representing the initial binding point.
-   */
-  unsigned explicit_binding:1;
-
-  /**
-   * Does this variable have an initializer?
-   *
-   * This is used by the linker to cross-validiate initializers of global
-   * variables.
-   */
-  unsigned has_initializer:1;
-
-  /**
* If non-zero, then this variable may be packed along with other 
variables
* into a single varying slot, so this offset should be applied when
* accessing components.  For example, an offset of 1 means that the x
@@ -296,14 +270,6 @@ typedef struct nir_variable {
  /** Image internal format if specified explicitly, otherwise GL_NONE. 
*/
  GLenum format;
   } image;
-
-  /**
-   * Highest element accessed with a constant expression array index
-   *
-   * Not used for non-array variables.
-   */
-  unsigned max_array_access;
-
} data;
 
/**
diff --git a/src/compiler/spirv/vtn_variables.c 
b/src/compiler/spirv/vtn_variables.c
index 84664ad..2b374ce 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -944,7 +944,6 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value 
*val, int member,
   if (nir_var) {
  /* This handles the member and lone variable cases */
  nir_var->data.location = location;
- nir_var->data.explicit_location = true;
   } else {
  /* This handles the structure member case */
  assert(vtn_var->members);
@@ -952,7 +951,6 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value 
*val, int member,
 glsl_get_length(glsl_without_array(vtn_var->type->type));
  for (unsigned i = 0; i < length; i++) {
 vtn_var->members[i]->data.location = location;
-vtn_var->members[i]->data.explicit_location = true;
 location +=
glsl_count_attribute_slots(vtn_var->members[i]->interface_type,
   is_vertex_input);
@@ -993,7 +991,6 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value 
*val, int member,
   nir_var->data.location_frac = dec->literals[0];
   break;
case SpvDecorationIndex:
-  nir_var->data.explicit_index = true;
   nir_var->data.index = dec->literals[0];
   break;
case SpvDecorationBuiltIn: {
@@ -1014,7 +1011,6 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value 
*val, int member,
 
   nir_variable_mode mode = nir_var->data.mode;
   vtn_get_builtin_location(b, builtin, &nir_var->data.location, &mode);
-  nir_var->data.explicit_location = true;
   nir_var->data.mode = mode;
 
   if (builtin == SpvBuiltInFragCoord || builtin == 
SpvBuiltInSamplePosition)
-- 
2.5.0.40

[Mesa-dev] [PATCH 1/8] nir: Add a pass for lowering away constant initializers

2016-07-20 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
---
 src/compiler/Makefile.sources  |   1 +
 src/compiler/nir/nir.h |   2 +
 src/compiler/nir/nir_lower_constant_initializers.c | 102 +
 3 files changed, 105 insertions(+)
 create mode 100644 src/compiler/nir/nir_lower_constant_initializers.c

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 0ff9b23..127b62e 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -190,6 +190,7 @@ NIR_FILES = \
nir/nir_lower_bitmap.c \
nir/nir_lower_clamp_color_outputs.c \
nir/nir_lower_clip.c \
+   nir/nir_lower_constant_initializers.c \
nir/nir_lower_double_ops.c \
nir/nir_lower_double_packing.c \
nir/nir_lower_drawpixels.c \
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 54598a2..99c2fc0 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2330,6 +2330,8 @@ void nir_lower_io_types(nir_shader *shader);
 void nir_lower_vars_to_ssa(nir_shader *shader);
 
 bool nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes);
+bool nir_lower_constant_initializers(nir_shader *shader,
+ nir_variable_mode modes);
 
 void nir_move_vec_src_uses_to_dest(nir_shader *shader);
 bool nir_lower_vec_to_movs(nir_shader *shader);
diff --git a/src/compiler/nir/nir_lower_constant_initializers.c 
b/src/compiler/nir/nir_lower_constant_initializers.c
new file mode 100644
index 000..d0935e9
--- /dev/null
+++ b/src/compiler/nir/nir_lower_constant_initializers.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "nir.h"
+#include "nir_builder.h"
+
+static bool
+deref_apply_constant_initializer(nir_deref_var *deref, void *state)
+{
+   struct nir_builder *b = state;
+
+   nir_load_const_instr *initializer =
+  nir_deref_get_const_initializer_load(b->shader, deref);
+   nir_builder_instr_insert(b, &initializer->instr);
+
+   nir_store_deref_var(b, deref, &initializer->def, 0xf);
+
+   return true;
+}
+
+static bool
+lower_const_initializer(struct nir_builder *b, struct exec_list *var_list)
+{
+   bool progress = false;
+
+   b->cursor = nir_before_cf_list(&b->impl->body);
+
+   nir_foreach_variable(var, var_list) {
+  if (!var->constant_initializer)
+ continue;
+
+  progress = true;
+
+  nir_deref_var deref;
+  deref.deref.deref_type = nir_deref_type_var,
+  deref.deref.child = NULL;
+  deref.deref.type = var->type,
+  deref.var = var;
+
+  nir_deref_foreach_leaf(&deref, deref_apply_constant_initializer, b);
+
+  var->constant_initializer = NULL;
+   }
+
+   return progress;
+}
+
+bool
+nir_lower_constant_initializers(nir_shader *shader, nir_variable_mode modes)
+{
+   bool progress = false;
+
+   nir_builder builder;
+   if (modes & ~nir_var_local)
+  nir_builder_init(&builder, nir_shader_get_entrypoint(shader)->impl);
+
+   if (modes & nir_var_shader_out)
+  progress |= lower_const_initializer(&builder, &shader->outputs);
+
+   if (modes & nir_var_global)
+  progress |= lower_const_initializer(&builder, &shader->globals);
+
+   if (modes & nir_var_system_value)
+  progress |= lower_const_initializer(&builder, &shader->system_values);
+
+   if (modes & nir_var_local) {
+  nir_foreach_function(function, shader) {
+ if (!function->impl)
+continue;
+
+ nir_builder_init(&builder, function->impl);
+ if (lower_const_initializer(&builder, &function->impl->locals)) {
+nir_metadata_preserve(function->impl, nir_metadata_block_index |
+  nir_metadata_dominance |
+  nir_metadata_live_ssa_defs);
+progress = true;
+   

[Mesa-dev] [PATCH 6/8] i965/vec4: Make opt_vector_float reset at the top of each block

2016-07-20 Thread Jason Ekstrand
The pass isn't really control-flow aware and you can get into case where it
tries to combine instructions from different blocks.  This can actually
lead to an assertion failure when removing unneeded instructions if part of
the vector is set in one block and part in another.  This prevents
regressions in the next commit.

Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
---
 src/mesa/drivers/dri/i965/brw_vec4.cpp | 162 +
 1 file changed, 82 insertions(+), 80 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 162b481..2cf0e17 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -354,95 +354,97 @@ vec4_visitor::opt_vector_float()
 {
bool progress = false;
 
-   int last_reg = -1, last_reg_offset = -1;
-   enum brw_reg_file last_reg_file = BAD_FILE;
+   foreach_block(block, cfg) {
+  int last_reg = -1, last_reg_offset = -1;
+  enum brw_reg_file last_reg_file = BAD_FILE;
+
+  uint8_t imm[4] = { 0 };
+  int inst_count = 0;
+  vec4_instruction *imm_inst[4];
+  unsigned writemask = 0;
+  enum brw_reg_type dest_type = BRW_REGISTER_TYPE_F;
+
+  foreach_inst_in_block_safe(vec4_instruction, inst, block) {
+ int vf = -1;
+ enum brw_reg_type need_type;
+
+ /* Look for unconditional MOVs from an immediate with a partial
+  * writemask.  Skip type-conversion MOVs other than integer 0,
+  * where the type doesn't matter.  See if the immediate can be
+  * represented as a VF.
+  */
+ if (inst->opcode == BRW_OPCODE_MOV &&
+ inst->src[0].file == IMM &&
+ inst->predicate == BRW_PREDICATE_NONE &&
+ inst->dst.writemask != WRITEMASK_XYZW &&
+ (inst->src[0].type == inst->dst.type || inst->src[0].d == 0)) {
+
+vf = brw_float_to_vf(inst->src[0].d);
+need_type = BRW_REGISTER_TYPE_D;
+
+if (vf == -1) {
+   vf = brw_float_to_vf(inst->src[0].f);
+   need_type = BRW_REGISTER_TYPE_F;
+}
+ } else {
+last_reg = -1;
+ }
 
-   uint8_t imm[4] = { 0 };
-   int inst_count = 0;
-   vec4_instruction *imm_inst[4];
-   unsigned writemask = 0;
-   enum brw_reg_type dest_type = BRW_REGISTER_TYPE_F;
+ /* If this wasn't a MOV, or the destination register doesn't match,
+  * or we have to switch destination types, then this breaks our
+  * sequence.  Combine anything we've accumulated so far.
+  */
+ if (last_reg != inst->dst.nr ||
+ last_reg_offset != inst->dst.reg_offset ||
+ last_reg_file != inst->dst.file ||
+ (vf > 0 && dest_type != need_type)) {
+
+if (inst_count > 1) {
+   unsigned vf;
+   memcpy(&vf, imm, sizeof(vf));
+   vec4_instruction *mov = MOV(imm_inst[0]->dst, brw_imm_vf(vf));
+   mov->dst.type = dest_type;
+   mov->dst.writemask = writemask;
+   inst->insert_before(block, mov);
+
+   for (int i = 0; i < inst_count; i++) {
+  imm_inst[i]->remove(block);
+   }
 
-   foreach_block_and_inst_safe(block, vec4_instruction, inst, cfg) {
-  int vf = -1;
-  enum brw_reg_type need_type;
+   progress = true;
+}
 
-  /* Look for unconditional MOVs from an immediate with a partial
-   * writemask.  Skip type-conversion MOVs other than integer 0,
-   * where the type doesn't matter.  See if the immediate can be
-   * represented as a VF.
-   */
-  if (inst->opcode == BRW_OPCODE_MOV &&
-  inst->src[0].file == IMM &&
-  inst->predicate == BRW_PREDICATE_NONE &&
-  inst->dst.writemask != WRITEMASK_XYZW &&
-  (inst->src[0].type == inst->dst.type || inst->src[0].d == 0)) {
-
- vf = brw_float_to_vf(inst->src[0].d);
- need_type = BRW_REGISTER_TYPE_D;
-
- if (vf == -1) {
-vf = brw_float_to_vf(inst->src[0].f);
-need_type = BRW_REGISTER_TYPE_F;
- }
-  } else {
- last_reg = -1;
-  }
+inst_count = 0;
+last_reg = -1;
+writemask = 0;
+dest_type = BRW_REGISTER_TYPE_F;
 
-  /* If this wasn't a MOV, or the destination register doesn't match,
-   * or we have to switch destination types, then this breaks our
-   * sequence.  Combine anything we've accumulated so far.
-   */
-  if (last_reg != inst->dst.nr ||
-  last_reg_offset != inst->dst.reg_offset ||
-  last_reg_file != inst->dst.file ||
-  (vf > 0 && dest_type != need_type)) {
-
- if (inst_count > 1) {
-unsigned vf;
-memcpy(&vf, imm, sizeof(vf));
-vec4_instruction *mov = MOV(imm_inst[0]->dst, brw_imm_vf(vf));
-mov->dst.type = dest_type;
-

Re: [Mesa-dev] [PATCH 09/12] st/va: add functions for VAAPI encode

2016-07-20 Thread Zhang, Boyuan
>We can keep it like this for now, but I would prefer that we clean this up and 
>change the radeon_vce so that it matches the begin/encode/end calls from 
>VA-API.

>We should probably work on this together with the performance improvements.

>Regards,
>Christian.

Hi Christian,

Sure, I agree, we can do that together with the performance improvements.

I just submitted another patch set, which addressed all your commends, as well 
as fixed a cqp issue reported by Andy. Please review.

Regards,
Boyuan

From: Christian König [mailto:deathsim...@vodafone.de]
Sent: July-20-16 4:49 AM
To: Zhang, Boyuan; mesa-dev@lists.freedesktop.org
Cc: adf.li...@gmail.com
Subject: Re: [PATCH 09/12] st/va: add functions for VAAPI encode

Am 20.07.2016 um 06:21 schrieb Zhang, Boyuan:

>> -   context->decoder->begin_frame(context->decoder, context->target, 
>> &context->desc.base);
>> +   if (context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE)
>> +  context->decoder->begin_frame(context->decoder, context->target, 
>> &context->desc.base);

>Why do we do so here? Could we avoid that?

>I would rather like to keep the begin_frame()/end_frame() handling as it is.

>Christian.



This is on purpose. Based on my testing, application will call begin_frame 
first, then call PictureParameter/SequenceParameter/... to pass us all picture 
related parameters. However, some of those values are actually required by 
begin_picture call in radeon_vce. So we have to delay the call until we receive 
all the parameters that needed. Same applies to encode_bitstream call. That's 
why I delay both calls to end_frame where we get all necessary values.

We can keep it like this for now, but I would prefer that we clean this up and 
change the radeon_vce so that it matches the begin/encode/end calls from VA-API.

We should probably work on this together with the performance improvements.

Regards,
Christian.





Regards,

Boyuan


From: Christian König 
Sent: July 19, 2016 4:55:43 AM
To: Zhang, Boyuan; 
mesa-dev@lists.freedesktop.org
Cc: adf.li...@gmail.com
Subject: Re: [PATCH 09/12] st/va: add functions for VAAPI encode

Am 19.07.2016 um 00:43 schrieb Boyuan Zhang:
> Add necessary functions/changes for VAAPI encoding to buffer and picture. 
> These changes will allow driver to handle all Vaapi encode related 
> operations. This patch doesn't change the Vaapi decode behaviour.
>
> Signed-off-by: Boyuan Zhang 
> 
> ---
>   src/gallium/state_trackers/va/buffer.c |   6 +
>   src/gallium/state_trackers/va/picture.c| 169 
> -
>   src/gallium/state_trackers/va/va_private.h |   3 +
>   3 files changed, 176 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/state_trackers/va/buffer.c 
> b/src/gallium/state_trackers/va/buffer.c
> index 7d3167b..dfcebbe 100644
> --- a/src/gallium/state_trackers/va/buffer.c
> +++ b/src/gallium/state_trackers/va/buffer.c
> @@ -133,6 +133,12 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, 
> void **pbuff)
> if (!buf->derived_surface.transfer || !*pbuff)
>return VA_STATUS_ERROR_INVALID_BUFFER;
>
> +  if (buf->type == VAEncCodedBufferType) {
> + ((VACodedBufferSegment*)buf->data)->buf = *pbuff;
> + ((VACodedBufferSegment*)buf->data)->size = buf->coded_size;
> + ((VACodedBufferSegment*)buf->data)->next = NULL;
> + *pbuff = buf->data;
> +  }
>  } else {
> pipe_mutex_unlock(drv->mutex);
> *pbuff = buf->data;
> diff --git a/src/gallium/state_trackers/va/picture.c 
> b/src/gallium/state_trackers/va/picture.c
> index 89ac024..4793194 100644
> --- a/src/gallium/state_trackers/va/picture.c
> +++ b/src/gallium/state_trackers/va/picture.c
> @@ -78,7 +78,8 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID 
> context_id, VASurfaceID rende
> return VA_STATUS_SUCCESS;
>  }
>
> -   context->decoder->begin_frame(context->decoder, context->target, 
> &context->desc.base);
> +   if (context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE)
> +  context->decoder->begin_frame(context->decoder, context->target, 
> &context->desc.base);

Why do we do so here? Could we avoid that?

I would rather like to keep the begin_frame()/end_frame() handling as it is.

Christian.

>
>  return VA_STATUS_SUCCESS;
>   }
> @@ -278,6 +279,139 @@ handleVASliceDataBufferType(vlVaContext *context, 
> vlVaBuffer *buf)
> num_buffers, (const void * const*)buffers, sizes);
>   }
>
> +static VAStatus
> +handleVAEncMiscParameterTypeRateControl(vlVaContext *context, 
> VAEncMiscParameterBuffer *misc)
> +{
> +   VAEncMiscParameterRateControl *rc = (VAEncMiscParameterRateControl 
> *)misc->data;
> +   if (context->desc.h264enc.rate_ctrl.rate_ctrl_method ==
> +   PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT)
> +  context->desc.h264enc.rat

[Mesa-dev] [PATCH 4/8] nir/lower_returns: Stop using constant initializers

2016-07-20 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
---
 src/compiler/nir/nir_lower_returns.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_lower_returns.c 
b/src/compiler/nir/nir_lower_returns.c
index 8dbea6e..cf49d5b 100644
--- a/src/compiler/nir/nir_lower_returns.c
+++ b/src/compiler/nir/nir_lower_returns.c
@@ -147,17 +147,18 @@ lower_returns_in_block(nir_block *block, struct 
lower_returns_state *state)
nir_instr_remove(&jump->instr);
 
nir_builder *b = &state->builder;
-   b->cursor = nir_after_block(block);
 
/* Set the return flag */
if (state->return_flag == NULL) {
   state->return_flag =
  nir_local_variable_create(b->impl, glsl_bool_type(), "return");
 
-  /* Set a default value of false */
-  state->return_flag->constant_initializer =
- rzalloc(state->return_flag, nir_constant);
+  /* Initialize the variable to 0 */
+  b->cursor = nir_before_cf_list(&b->impl->body);
+  nir_store_var(b, state->return_flag, nir_imm_int(b, NIR_FALSE), 1);
}
+
+   b->cursor = nir_after_block(block);
nir_store_var(b, state->return_flag, nir_imm_int(b, NIR_TRUE), 1);
 
if (state->loop) {
-- 
2.5.0.400.gff86faf

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


Re: [Mesa-dev] [PATCH 06/11] vl/util: add copy func for yv12image to nv12surface

2016-07-20 Thread Andy Furniss

Andy Furniss wrote:



I tried again, and there's a possible further regression - though I have
no idea whether it's ffmpeg or the newer patches here.

Just thought I would mention it, as I haven't had time to look into it
further yet.


I can confirm this is a regression with the current patches, the last
set works with the same command.



The regression is that when asking for a bitrate there is now a
floating point exception, -qp still works (comes out at 0 like gst).

andy [vce-tests]$ gdb /mnt/sdb1/Gits/ffmpeg/ffmpeg_g
GNU gdb (GDB) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later

This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /mnt/sdb1/Gits/ffmpeg/ffmpeg_g...done.
(gdb) run -vaapi_device /dev/dri/renderD128 -f rawvideo -framerate 50 -s
2560x1440 -pix_fmt nv12 -i /mnt/ramdisk/trees-1440p50.nv12 -vf
'hwupload' -c:v h264_vaapi -profile:v 66 -b:v 40M  -bf 0 -y
/mnt/ramdisk/ffm-40M.264
Starting program: /mnt/sdb1/Gits/ffmpeg/ffmpeg_g -vaapi_device
/dev/dri/renderD128 -f rawvideo -framerate 50 -s 2560x1440 -pix_fmt nv12
-i /mnt/ramdisk/trees-1440p50.nv12 -vf 'hwupload' -c:v h264_vaapi
-profile:v 66 -b:v 40M  -bf 0 -y /mnt/ramdisk/ffm-40M.264
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[New Thread 0x7fffea690700 (LWP 907)]
[New Thread 0x7fffe9c8b700 (LWP 908)]
[New Thread 0x7fffe948a700 (LWP 909)]
[New Thread 0x7fffe8c89700 (LWP 910)]
[New Thread 0x7fffe8488700 (LWP 911)]
[New Thread 0x7fffe7c87700 (LWP 912)]
[New Thread 0x7fffe7486700 (LWP 913)]
[New Thread 0x7fffe6c85700 (LWP 914)]
[New Thread 0x7fffe6484700 (LWP 915)]
[Thread 0x7fffe6484700 (LWP 915) exited]
[Thread 0x7fffe6c85700 (LWP 914) exited]
[Thread 0x7fffe7486700 (LWP 913) exited]
[Thread 0x7fffe7c87700 (LWP 912) exited]
ffmpeg version N-81050-g9bf3fdc Copyright (c) 2000-2016 the FFmpeg
developers
   built with gcc 5.3.0 (GCC)
   configuration: --prefix=/usr --disable-doc --enable-gpl --enable-omx
--enable-opencl --enable-libzimg --enable-libvpx --enable-libx265
--enable-libmp3lame --enable-libx264 --enable-gnutls
   libavutil  55. 28.100 / 55. 28.100
   libavcodec 57. 50.100 / 57. 50.100
   libavformat57. 43.100 / 57. 43.100
   libavdevice57.  0.102 / 57.  0.102
   libavfilter 6. 47.100 /  6. 47.100
   libswscale  4.  1.100 /  4.  1.100
   libswresample   2.  1.100 /  2.  1.100
   libpostproc54.  0.100 / 54.  0.100
libva info: VA-API version 0.38.1
libva info: va_getDriverName() returns -1
libva info: User requested driver 'radeonsi'
libva info: Trying to open /usr/lib/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_0_38
[New Thread 0x7fffe6484700 (LWP 916)]
[New Thread 0x7fffe6c85700 (LWP 917)]
[New Thread 0x7fffe7486700 (LWP 918)]
[New Thread 0x7fffe7c87700 (LWP 919)]
[New Thread 0x7fffe4b03700 (LWP 920)]
libva info: va_openDriver() returns 0
[rawvideo @ 0x1f15800] Estimating duration from bitrate, this may be
inaccurate
Input #0, rawvideo, from '/mnt/ramdisk/trees-1440p50.nv12':
   Duration: 00:00:10.00, start: 0.00, bitrate: 2211840 kb/s
 Stream #0:0: Video: rawvideo (NV12 / 0x3231564E), nv12, 2560x1440,
2211840 kb/s, 50 tbr, 50 tbn, 50 tbc
[New Thread 0x7fffd7ab8700 (LWP 921)]
[New Thread 0x7fffd72b7700 (LWP 922)]
[New Thread 0x7fffd6ab6700 (LWP 923)]
[New Thread 0x7fffd62b5700 (LWP 924)]
[New Thread 0x7fffd5ab4700 (LWP 925)]
[h264 @ 0x1e2c300] Using AVStream.codec to pass codec parameters to
muxers is deprecated, use AVStream.codecpar instead.
Output #0, h264, to '/mnt/ramdisk/ffm-40M.264':
   Metadata:
 encoder : Lavf57.43.100
 Stream #0:0: Video: h264 (h264_vaapi) (Baseline), vaapi_vld,
2560x1440, q=2-31, 4 kb/s, 50 fps, 50 tbn, 50 tbc
 Metadata:
   encoder : Lavc57.50.100 h264_vaapi
Stream mapping:
   Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_vaapi))
Press [q] to stop, [?] for help

Program received signal SIGFPE, Arithmetic exception.
vlVaRenderPicture (ctx=, context_id=,
buffers=, num_buffers=) at picture.c:496
496  vaStatus = handleVAEncMiscParameterBufferType(context,
buf);
(gdb) bt
#0  vlVaRenderPicture (ctx=, context_id=,
buffers=, num_buffers=) at picture.c:496
#1  0x00e628ed in vaapi_encode_issue
(avctx=avctx@entry=0x1f1f780, pic=pic@entry=0x1f30820) at
libavcodec/vaapi_encode.c:374
#2  0x00e62b86 in vaapi_encode_ste

Re: [Mesa-dev] [PATCH v3 05/11] nouveau: use common screen ref counting

2016-07-20 Thread Ilia Mirkin
On Wed, Jul 20, 2016 at 6:25 PM, Rob Herring  wrote:
> Use the common pipe_screen ref counting and fd hashing functions. The
> mutex can be dropped as the pipe loader protects the create_screen()
> calls.
>
> Signed-off-by: Rob Herring 
> Cc: Alexandre Courbot 
> ---
>  src/gallium/drivers/nouveau/nouveau_screen.c   |  6 --
>  src/gallium/drivers/nouveau/nouveau_screen.h   |  4 -
>  src/gallium/drivers/nouveau/nv30/nv30_screen.c |  3 -
>  src/gallium/drivers/nouveau/nv50/nv50_screen.c |  3 -
>  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |  3 -
>  .../winsys/nouveau/drm/nouveau_drm_winsys.c| 89 
> ++
>  6 files changed, 7 insertions(+), 101 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c 
> b/src/gallium/drivers/nouveau/nouveau_screen.c
> index 2c421cc..41d4bef 100644
> --- a/src/gallium/drivers/nouveau/nouveau_screen.c
> +++ b/src/gallium/drivers/nouveau/nouveau_screen.c
> @@ -159,12 +159,6 @@ nouveau_screen_init(struct nouveau_screen *screen, 
> struct nouveau_device *dev)
> screen->drm = nouveau_drm(&dev->object);
> screen->device = dev;
>
> -   /*
> -* this is initialized to 1 in nouveau_drm_screen_create after screen
> -* is fully constructed and added to the global screen list.
> -*/
> -   screen->refcount = -1;
> -
> if (dev->chipset < 0xc0) {
>data = &nv04_data;
>size = sizeof(nv04_data);
> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h 
> b/src/gallium/drivers/nouveau/nouveau_screen.h
> index 28c4760..55156c3 100644
> --- a/src/gallium/drivers/nouveau/nouveau_screen.h
> +++ b/src/gallium/drivers/nouveau/nouveau_screen.h
> @@ -23,8 +23,6 @@ struct nouveau_screen {
> struct nouveau_client *client;
> struct nouveau_pushbuf *pushbuf;
>
> -   int refcount;
> -
> unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is desired 
> */
> unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is desired 
> */
> unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 GiB 
> */
> @@ -119,8 +117,6 @@ nouveau_screen(struct pipe_screen *pscreen)
> return (struct nouveau_screen *)pscreen;
>  }
>
> -bool nouveau_drm_screen_unref(struct nouveau_screen *screen);
> -
>  bool
>  nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
>   struct nouveau_bo *bo,
> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
> b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> index 68d8317..591cf92 100644
> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> @@ -408,9 +408,6 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
>  {
> struct nv30_screen *screen = nv30_screen(pscreen);
>
> -   if (!nouveau_drm_screen_unref(&screen->base))
> -  return;
> -
> if (screen->base.fence.current) {
>struct nouveau_fence *current = NULL;
>
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
> b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> index 303ecf1..7dbf66f 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> @@ -428,9 +428,6 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
>  {
> struct nv50_screen *screen = nv50_screen(pscreen);
>
> -   if (!nouveau_drm_screen_unref(&screen->base))
> -  return;
> -
> if (screen->base.fence.current) {
>struct nouveau_fence *current = NULL;
>
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 
> b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> index f681631..f789de4 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> @@ -485,9 +485,6 @@ nvc0_screen_destroy(struct pipe_screen *pscreen)
>  {
> struct nvc0_screen *screen = nvc0_screen(pscreen);
>
> -   if (!nouveau_drm_screen_unref(&screen->base))
> -  return;
> -
> if (screen->base.fence.current) {
>struct nouveau_fence *current = NULL;
>
> diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c 
> b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
> index f90572f..9ad3c57 100644
> --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
> +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
> @@ -1,12 +1,9 @@
> -#include 
>  #include 
>  #include "pipe/p_context.h"
>  #include "pipe/p_state.h"
>  #include "util/u_format.h"
>  #include "util/u_memory.h"
> -#include "util/u_inlines.h"
> -#include "util/u_hash_table.h"
> -#include "os/os_thread.h"
> +#include "util/u_screen.h"
>
>  #include "nouveau_drm_public.h"
>
> @@ -16,47 +13,6 @@
>  #include 
>  #include 
>
> -static struct util_hash_table *fd_tab = NULL;
> -
> -pipe_static_mutex(nouveau_screen_mutex);
> -
> -bool nouveau_drm_screen_unref(struct nouveau_screen *screen)
> -{
> -   int ret;
> -   if (screen->refcount == -1)
> -   return true;
> -
> -   pipe_mutex_lock(n

  1   2   >