Mesa (master): winsys/amdgpu: request high addresses

2018-02-28 Thread Christian König
Module: Mesa
Branch: master
Commit: 33633690aa51ff5c79909146d6453b50e37dbad0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=33633690aa51ff5c79909146d6453b50e37dbad0

Author: Christian König <christian.koe...@amd.com>
Date:   Mon Feb 26 14:13:28 2018 +0100

winsys/amdgpu: request high addresses

We now have hopefully fixed all bugs regarding high addresses on Vega10 and
Raven. Start to use the high range to make room for SVM in the low
range.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 19f6fedf7c..12d497d292 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -38,6 +38,10 @@
 #define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)
 #endif
 
+#ifndef AMDGPU_VA_RANGE_HIGH
+#define AMDGPU_VA_RANGE_HIGH   0x2
+#endif
+
 /* Set to 1 for verbose output showing committed sparse buffer ranges. */
 #define DEBUG_SPARSE_COMMITS 0
 
@@ -438,7 +442,8 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct 
amdgpu_winsys *ws,
   alignment = MAX2(alignment, ws->info.pte_fragment_size);
r = amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
  size + va_gap_size, alignment, 0, , _handle,
- flags & RADEON_FLAG_32BIT ? 
AMDGPU_VA_RANGE_32_BIT : 0);
+ (flags & RADEON_FLAG_32BIT ? 
AMDGPU_VA_RANGE_32_BIT : 0) |
+AMDGPU_VA_RANGE_HIGH);
if (r)
   goto error_va_alloc;
 
@@ -896,7 +901,8 @@ amdgpu_bo_sparse_create(struct amdgpu_winsys *ws, uint64_t 
size,
va_gap_size = ws->check_vm ? 4 * RADEON_SPARSE_PAGE_SIZE : 0;
r = amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
  map_size + va_gap_size, RADEON_SPARSE_PAGE_SIZE,
- 0, >va, >u.sparse.va_handle, 0);
+ 0, >va, >u.sparse.va_handle,
+AMDGPU_VA_RANGE_HIGH);
if (r)
   goto error_va_alloc;
 
@@ -1290,7 +1296,8 @@ static struct pb_buffer *amdgpu_bo_from_handle(struct 
radeon_winsys *rws,
   goto error_query;
 
r = amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
- result.alloc_size, 1 << 20, 0, , _handle, 
0);
+ result.alloc_size, 1 << 20, 0, , _handle,
+AMDGPU_VA_RANGE_HIGH);
if (r)
   goto error_query;
 
@@ -1401,7 +1408,8 @@ static struct pb_buffer *amdgpu_bo_from_ptr(struct 
radeon_winsys *rws,
 goto error;
 
 if (amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
-  aligned_size, 1 << 12, 0, , _handle, 0))
+  aligned_size, 1 << 12, 0, , _handle,
+ AMDGPU_VA_RANGE_HIGH))
 goto error_va_alloc;
 
 if (amdgpu_bo_va_op(buf_handle, 0, aligned_size, va, 0, AMDGPU_VA_OP_MAP))

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


Mesa (master): st/va: Enable vaExportSurfaceHandle()

2018-02-09 Thread Christian König
Module: Mesa
Branch: master
Commit: 768f1487b0c084507ba5e2641e0bbf4ec789ec85
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=768f1487b0c084507ba5e2641e0bbf4ec789ec85

Author: Mark Thompson <s...@jkqxz.net>
Date:   Wed Feb  7 23:10:15 2018 +

st/va: Enable vaExportSurfaceHandle()

It is present from libva 2.1 (VAAPI 1.1.0 or higher).

Signed-off-by: Mark Thompson <s...@jkqxz.net>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/context.c | 8 +++-
 src/gallium/state_trackers/va/surface.c | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index f567f544fd..189d361ff3 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -89,7 +89,13 @@ static struct VADriverVTable vtable =
,
,
,
-#if 0
+#if VA_CHECK_VERSION(1, 1, 0)
+   NULL, /* vaCreateMFContext */
+   NULL, /* vaMFAddContext */
+   NULL, /* vaMFReleaseContext */
+   NULL, /* vaMFSubmit */
+   NULL, /* vaCreateBuffer2 */
+   NULL, /* vaQueryProcessingRate */
,
 #endif
 };
diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 9823232413..8604136944 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -926,7 +926,7 @@ vlVaQueryVideoProcPipelineCaps(VADriverContextP ctx, 
VAContextID context,
return VA_STATUS_SUCCESS;
 }
 
-#if 0
+#if VA_CHECK_VERSION(1, 1, 0)
 VAStatus
 vlVaExportSurfaceHandle(VADriverContextP ctx,
 VASurfaceID surface_id,

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


Mesa (master): st/va: Make the vendor string more descriptive

2018-02-09 Thread Christian König
Module: Mesa
Branch: master
Commit: 5db29d62ce1fefa3f2ee6e4a4688576fde4bde4a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5db29d62ce1fefa3f2ee6e4a4688576fde4bde4a

Author: Mark Thompson <s...@jkqxz.net>
Date:   Wed Feb  7 23:15:05 2018 +

st/va: Make the vendor string more descriptive

Include the Mesa version and detail about the platform.

Signed-off-by: Mark Thompson <s...@jkqxz.net>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/context.c| 6 +-
 src/gallium/state_trackers/va/va_private.h | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index 189d361ff3..836aa77c36 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -181,7 +181,11 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
ctx->max_image_formats = VL_VA_MAX_IMAGE_FORMATS;
ctx->max_subpic_formats = 1;
ctx->max_display_attributes = 1;
-   ctx->str_vendor = "mesa gallium vaapi";
+
+   snprintf(drv->vendor_string, sizeof(drv->vendor_string),
+"Mesa Gallium driver " PACKAGE_VERSION " for %s",
+drv->vscreen->pscreen->get_name(drv->vscreen->pscreen));
+   ctx->str_vendor = drv->vendor_string;
 
return VA_STATUS_SUCCESS;
 
diff --git a/src/gallium/state_trackers/va/va_private.h 
b/src/gallium/state_trackers/va/va_private.h
index 11b208c4b3..4396abb586 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -233,6 +233,7 @@ typedef struct {
struct vl_compositor_state cstate;
vl_csc_matrix csc;
mtx_t mutex;
+   char vendor_string[256];
 } vlVaDriver;
 
 typedef struct {

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


Mesa (master): radeon/uvd: update quantiser matrices only when requested

2018-01-16 Thread Christian König
Module: Mesa
Branch: master
Commit: 38dee62c9a0ced17fb1f25256f9da3b163a16f81
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=38dee62c9a0ced17fb1f25256f9da3b163a16f81

Author: Indrajit Das <indrajit-kumar@amd.com>
Date:   Wed Jan 10 15:28:17 2018 +0530

radeon/uvd: update quantiser matrices only when requested

Only upload them when the pointers are valid.

Signed-off-by: Indrajit Das <indrajit-kumar@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/drivers/radeon/radeon_uvd.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_uvd.c 
b/src/gallium/drivers/radeon/radeon_uvd.c
index b46ee6e3c4..78ced179bb 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -871,12 +871,17 @@ static struct ruvd_mpeg2 get_mpeg2_msg(struct 
ruvd_decoder *dec,
for (i = 0; i < 2; ++i)
result.ref_pic_idx[i] = get_ref_pic_idx(dec, pic->ref[i]);
 
-   result.load_intra_quantiser_matrix = 1;
-   result.load_nonintra_quantiser_matrix = 1;
-
-   for (i = 0; i < 64; ++i) {
-   result.intra_quantiser_matrix[i] = pic->intra_matrix[zscan[i]];
-   result.nonintra_quantiser_matrix[i] = 
pic->non_intra_matrix[zscan[i]];
+   if(pic->intra_matrix) {
+   result.load_intra_quantiser_matrix = 1;
+   for (i = 0; i < 64; ++i) {
+   result.intra_quantiser_matrix[i] = 
pic->intra_matrix[zscan[i]];
+   }
+   }
+   if(pic->non_intra_matrix) {
+   result.load_nonintra_quantiser_matrix = 1;
+   for (i = 0; i < 64; ++i) {
+   result.nonintra_quantiser_matrix[i] = 
pic->non_intra_matrix[zscan[i]];
+   }
}
 
result.profile_and_level_indication = 0;

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


Mesa (master): st/va: clear pointers for mpeg2 quantiser matrices

2018-01-16 Thread Christian König
Module: Mesa
Branch: master
Commit: 338638a8afc9f330bacc1cdd7e6392a3ea9d828a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=338638a8afc9f330bacc1cdd7e6392a3ea9d828a

Author: Indrajit Das <indrajit-kumar@amd.com>
Date:   Wed Jan 10 15:31:37 2018 +0530

st/va: clear pointers for mpeg2 quantiser matrices

This is to fix VA-API issues with GStreamer and MPEG2.
Since gstreamer does not pass quantiser matrices with each frame, invalid
pointers were being passed to the driver. This patch addresses the same.

Signed-off-by: Indrajit Das <indrajit-kumar@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/picture.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 895157375a..23a4b524d7 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -57,6 +57,11 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID 
context_id, VASurfaceID rende
   return VA_STATUS_ERROR_INVALID_CONTEXT;
}
 
+   if (u_reduce_video_profile(context->templat.profile) == 
PIPE_VIDEO_FORMAT_MPEG12) {
+  context->desc.mpeg12.intra_matrix = NULL;
+  context->desc.mpeg12.non_intra_matrix = NULL;
+   }
+
surf = handle_table_get(drv->htab, render_target);
mtx_unlock(>mutex);
if (!surf || !surf->buffer)

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


Mesa (master): radeon/vcn: update quantiser matrices only when requested

2018-01-16 Thread Christian König
Module: Mesa
Branch: master
Commit: f5277e84925b69b0bf01340122684becd45c1f7d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f5277e84925b69b0bf01340122684becd45c1f7d

Author: Indrajit Das <indrajit-kumar@amd.com>
Date:   Wed Jan 10 15:30:44 2018 +0530

radeon/vcn: update quantiser matrices only when requested

Only update them when the pointers are valid.

Signed-off-by: Indrajit Das <indrajit-kumar@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/drivers/radeon/radeon_vcn_dec.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_vcn_dec.c 
b/src/gallium/drivers/radeon/radeon_vcn_dec.c
index 8be95382cc..d51eb6e394 100644
--- a/src/gallium/drivers/radeon/radeon_vcn_dec.c
+++ b/src/gallium/drivers/radeon/radeon_vcn_dec.c
@@ -498,12 +498,17 @@ static rvcn_dec_message_mpeg2_vld_t get_mpeg2_msg(struct 
radeon_decoder *dec,
result.forward_ref_pic_idx = get_ref_pic_idx(dec, pic->ref[0]);
result.backward_ref_pic_idx = get_ref_pic_idx(dec, pic->ref[1]);
 
-   result.load_intra_quantiser_matrix = 1;
-   result.load_nonintra_quantiser_matrix = 1;
-
-   for (i = 0; i < 64; ++i) {
-   result.intra_quantiser_matrix[i] = pic->intra_matrix[zscan[i]];
-   result.nonintra_quantiser_matrix[i] = 
pic->non_intra_matrix[zscan[i]];
+   if(pic->intra_matrix) {
+   result.load_intra_quantiser_matrix = 1;
+   for (i = 0; i < 64; ++i) {
+   result.intra_quantiser_matrix[i] = 
pic->intra_matrix[zscan[i]];
+   }
+   }
+   if(pic->non_intra_matrix) {
+   result.load_nonintra_quantiser_matrix = 1;
+   for (i = 0; i < 64; ++i) {
+   result.nonintra_quantiser_matrix[i] = 
pic->non_intra_matrix[zscan[i]];
+   }
}
 
result.profile_and_level_indication = 0;

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


Mesa (master): st/omx_bellagio: Rename state tracker and option

2017-09-15 Thread Christian König
Module: Mesa
Branch: master
Commit: 6a8aa11c207b99920b9306b209f071a0e3fe8b43
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6a8aa11c207b99920b9306b209f071a0e3fe8b43

Author: Gurkirpal Singh <gurkirpal...@gmail.com>
Date:   Sat Aug 12 21:55:15 2017 +0530

st/omx_bellagio: Rename state tracker and option

Changes --enable-omx option to --enable-omx-bellagio

Signed-off-by: Gurkirpal Singh <gurkirpal...@gmail.com>
Reviewed-and-Tested-by: Julien Isorce <julien.iso...@gmail.com>
Acked-by: Christian König <christian.koe...@amd.com>

---

 configure.ac   | 49 --
 src/gallium/Makefile.am|  4 +-
 .../{omx => omx_bellagio}/Makefile.am  |  2 +-
 .../{omx => omx_bellagio}/Makefile.sources |  0
 .../{omx => omx_bellagio}/entrypoint.c |  0
 .../{omx => omx_bellagio}/entrypoint.h |  0
 .../state_trackers/{omx => omx_bellagio}/vid_dec.c |  0
 .../state_trackers/{omx => omx_bellagio}/vid_dec.h |  0
 .../{omx => omx_bellagio}/vid_dec_h264.c   |  0
 .../{omx => omx_bellagio}/vid_dec_h265.c   |  0
 .../{omx => omx_bellagio}/vid_dec_mpeg12.c |  0
 .../state_trackers/{omx => omx_bellagio}/vid_enc.c |  0
 .../state_trackers/{omx => omx_bellagio}/vid_enc.h |  0
 .../targets/{omx => omx-bellagio}/Makefile.am  |  8 ++--
 src/gallium/targets/{omx => omx-bellagio}/omx.sym  |  0
 src/gallium/targets/{omx => omx-bellagio}/target.c |  0
 16 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/configure.ac b/configure.ac
index d0d4c0dfd1..605c9b4e99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1228,9 +1228,14 @@ AC_ARG_ENABLE([vdpau],
[enable_vdpau=auto])
 AC_ARG_ENABLE([omx],
[AS_HELP_STRING([--enable-omx],
- [enable OpenMAX library @<:@default=disabled@:>@])],
-   [enable_omx="$enableval"],
-   [enable_omx=no])
+ [DEPRECATED: Use --enable-omx-bellagio instead 
@<:@default=auto@:>@])],
+   [AC_MSG_ERROR([--enable-omx is deprecated. Use --enable-omx-bellagio 
instead.])],
+   [])
+AC_ARG_ENABLE([omx-bellagio],
+   [AS_HELP_STRING([--enable-omx-bellagio],
+ [enable OpenMAX Bellagio library @<:@default=disabled@:>@])],
+   [enable_omx_bellagio="$enableval"],
+   [enable_omx_bellagio=no])
 AC_ARG_ENABLE([va],
[AS_HELP_STRING([--enable-va],
  [enable va library @<:@default=auto@:>@])],
@@ -1281,7 +1286,7 @@ if test "x$enable_opengl" = xno -a \
 "x$enable_xa" = xno -a \
 "x$enable_xvmc" = xno -a \
 "x$enable_vdpau" = xno -a \
-"x$enable_omx" = xno -a \
+"x$enable_omx_bellagio" = xno -a \
 "x$enable_va" = xno -a \
 "x$enable_opencl" = xno; then
 AC_MSG_ERROR([at least one API should be enabled])
@@ -2126,8 +2131,8 @@ if test -n "$with_gallium_drivers" -a 
"x$with_gallium_drivers" != xswrast; then
 PKG_CHECK_EXISTS([vdpau >= $VDPAU_REQUIRED], [enable_vdpau=yes], 
[enable_vdpau=no])
 fi
 
-if test "x$enable_omx" = xauto -a "x$have_omx_platform" = xyes; then
-PKG_CHECK_EXISTS([libomxil-bellagio >= $LIBOMXIL_BELLAGIO_REQUIRED], 
[enable_omx=yes], [enable_omx=no])
+if test "x$enable_omx_bellagio" = xauto -a "x$have_omx_platform" = xyes; 
then
+PKG_CHECK_EXISTS([libomxil-bellagio >= $LIBOMXIL_BELLAGIO_REQUIRED], 
[enable_omx_bellagio=yes], [enable_omx_bellagio=no])
 fi
 
 if test "x$enable_va" = xauto -a "x$have_va_platform" = xyes; then
@@ -2138,7 +2143,7 @@ fi
 if test "x$enable_dri" = xyes -o \
 "x$enable_xvmc" = xyes -o \
 "x$enable_vdpau" = xyes -o \
-"x$enable_omx" = xyes -o \
+"x$enable_omx_bellagio" = xyes -o \
 "x$enable_va" = xyes; then
 need_gallium_vl=yes
 fi
@@ -2146,7 +2151,7 @@ AM_CONDITIONAL(NEED_GALLIUM_VL, test "x$need_gallium_vl" 
= xyes)
 
 if test "x$enable_xvmc" = xyes -o \
 "x$enable_vdpau" = xyes -o \
-"x$enable_omx" = xyes -o \
+"x$enable_omx_bellagio" = xyes -o \
 "x$enable_va" = xyes; then
 PKG_CHECK_MODULES([VL], [x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED])
 need_gallium_vl_winsys=yes
@@ -2172,14 +2177,14 @@ if test "x$enable_vdpau" = xyes; then
 fi
 AM_CONDITIONAL(HAVE_ST_VDPAU, test "x$enable_vdpau" = xyes)
 
-if test "x$enable_omx" = xyes; then
+if test "x$enable_omx_bellagio" = xyes; then
 if test "x$have_omx_platform" != xyes; then
 AC_MSG_ERROR([OMX requires at least one of the x11 or drm platforms])
 fi
-PKG_CHECK_MODULES([OMX], [libomxil-be

Mesa (master): radeonsi: set a per-buffer flag that disables inter-process sharing (v4)

2017-08-31 Thread Christian König
Module: Mesa
Branch: master
Commit: 8b3a257851905ff444d981e52938cbf2b36ba830
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b3a257851905ff444d981e52938cbf2b36ba830

Author: Marek Olšák 
Date:   Tue Jul 18 16:08:44 2017 -0400

radeonsi: set a per-buffer flag that disables inter-process sharing (v4)

For lower overhead in the CS ioctl.
Winsys allocators are not used with interprocess-sharable resources.

v2: It shouldn't crash anymore, but the kernel will reject the new flag.
v3 (christian): Rename the flag, avoid sending those buffers in the BO list.
v4 (christian): Remove setting the kernel flag for now

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeon/r600_buffer_common.c |  7 ++
 src/gallium/drivers/radeon/radeon_winsys.h  | 20 +
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c   | 30 ++---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c   | 27 +-
 4 files changed, 56 insertions(+), 28 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c 
b/src/gallium/drivers/radeon/r600_buffer_common.c
index 076faa9330..4f5e17d5c8 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -167,6 +167,13 @@ void r600_init_resource_fields(struct r600_common_screen 
*rscreen,
 RADEON_FLAG_GTT_WC;
}
 
+   /* Only displayable single-sample textures can be shared between
+* processes. */
+   if (res->b.b.target == PIPE_BUFFER ||
+   res->b.b.nr_samples >= 2 ||
+   rtex->surface.micro_tile_mode != RADEON_MICRO_MODE_DISPLAY)
+   res->flags |= RADEON_FLAG_NO_INTERPROCESS_SHARING;
+
/* If VRAM is just stolen system memory, allow both VRAM and
 * GTT, whichever has free space. If a buffer is evicted from
 * VRAM to GTT, it will stay there.
diff --git a/src/gallium/drivers/radeon/radeon_winsys.h 
b/src/gallium/drivers/radeon/radeon_winsys.h
index b00b1443e7..f0a0a922a1 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -54,6 +54,7 @@ enum radeon_bo_flag { /* bitfield */
 RADEON_FLAG_NO_CPU_ACCESS = (1 << 1),
 RADEON_FLAG_NO_SUBALLOC =   (1 << 2),
 RADEON_FLAG_SPARSE =(1 << 3),
+RADEON_FLAG_NO_INTERPROCESS_SHARING = (1 << 4),
 };
 
 enum radeon_bo_usage { /* bitfield */
@@ -661,14 +662,19 @@ static inline unsigned radeon_flags_from_heap(enum 
radeon_heap heap)
 {
 switch (heap) {
 case RADEON_HEAP_VRAM_NO_CPU_ACCESS:
-return RADEON_FLAG_GTT_WC | RADEON_FLAG_NO_CPU_ACCESS;
+return RADEON_FLAG_GTT_WC |
+   RADEON_FLAG_NO_CPU_ACCESS |
+   RADEON_FLAG_NO_INTERPROCESS_SHARING;
+
 case RADEON_HEAP_VRAM:
 case RADEON_HEAP_VRAM_GTT:
 case RADEON_HEAP_GTT_WC:
-return RADEON_FLAG_GTT_WC;
+return RADEON_FLAG_GTT_WC |
+   RADEON_FLAG_NO_INTERPROCESS_SHARING;
+
 case RADEON_HEAP_GTT:
 default:
-return 0;
+return RADEON_FLAG_NO_INTERPROCESS_SHARING;
 }
 }
 
@@ -700,8 +706,14 @@ static inline int radeon_get_heap_index(enum 
radeon_bo_domain domain,
 /* NO_CPU_ACCESS implies VRAM only. */
 assert(!(flags & RADEON_FLAG_NO_CPU_ACCESS) || domain == 
RADEON_DOMAIN_VRAM);
 
+/* Resources with interprocess sharing don't use any winsys allocators. */
+if (!(flags & RADEON_FLAG_NO_INTERPROCESS_SHARING))
+return -1;
+
 /* Unsupported flags: NO_SUBALLOC, SPARSE. */
-if (flags & ~(RADEON_FLAG_GTT_WC | RADEON_FLAG_NO_CPU_ACCESS))
+if (flags & ~(RADEON_FLAG_GTT_WC |
+  RADEON_FLAG_NO_CPU_ACCESS |
+  RADEON_FLAG_NO_INTERPROCESS_SHARING))
 return -1;
 
 switch (domain) {
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 1323be8356..883a7c18e3 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -1138,7 +1138,7 @@ amdgpu_bo_create(struct radeon_winsys *rws,
 {
struct amdgpu_winsys *ws = amdgpu_winsys(rws);
struct amdgpu_winsys_bo *bo;
-   unsigned usage = 0, pb_cache_bucket;
+   unsigned usage = 0, pb_cache_bucket = 0;
 
/* VRAM implies WC. This is not optional. */
assert(!(domain & RADEON_DOMAIN_VRAM) || flags & RADEON_FLAG_GTT_WC);
@@ -1193,19 +1193,23 @@ no_slab:
size = align64(size, ws->info.gart_page_size);
alignment = align(alignment, ws->info.gart_page_size);
 
-   int heap = radeon_get_heap_index(domain, flags);
-   assert(heap >= 0 && heap < RADEON_MAX_CACHED_HEAPS);
-   usage = 1 << heap; /* Only set one usage bit for each heap. */
+   bool use_reusable_pool = flags & RADEON_FLAG_NO_INTERPROCESS_SHARING;
 
-   pb_cache_bucket = radeon_get_pb_cache_bucket_index(heap);
-   assert(pb_cache_bucket < ARRAY_SIZE(ws->bo_cache.buckets));
+   if 

Mesa (master): winsys/amdgpu: set AMDGPU_GEM_CREATE_VM_ALWAYS_VALID if possible v2

2017-08-31 Thread Christian König
Module: Mesa
Branch: master
Commit: 214b565bc28bc4419f3eec29ab7bbe34080459fe
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=214b565bc28bc4419f3eec29ab7bbe34080459fe

Author: Christian König <christian.koe...@amd.com>
Date:   Tue Aug 29 16:45:46 2017 +0200

winsys/amdgpu: set AMDGPU_GEM_CREATE_VM_ALWAYS_VALID if possible v2

When the kernel supports it set the local flag and
stop adding those BOs to the BO list.

Can probably be optimized much more.

v2: rename new flag to AMDGPU_GEM_CREATE_VM_ALWAYS_VALID

Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c |  8 
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.h |  2 ++
 src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 22 +-
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 883a7c18e3..897b4f0596 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -38,6 +38,10 @@
 #include 
 #include 
 
+#ifndef AMDGPU_GEM_CREATE_VM_ALWAYS_VALID
+#define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)
+#endif
+
 /* Set to 1 for verbose output showing committed sparse buffer ranges. */
 #define DEBUG_SPARSE_COMMITS 0
 
@@ -406,6 +410,9 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct 
amdgpu_winsys *ws,
   request.flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
if (flags & RADEON_FLAG_GTT_WC)
   request.flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC;
+   if (flags & RADEON_FLAG_NO_INTERPROCESS_SHARING &&
+   ws->info.drm_minor >= 20)
+  request.flags |= AMDGPU_GEM_CREATE_VM_ALWAYS_VALID;
 
r = amdgpu_bo_alloc(ws->dev, , _handle);
if (r) {
@@ -439,6 +446,7 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct 
amdgpu_winsys *ws,
bo->u.real.va_handle = va_handle;
bo->initial_domain = initial_domain;
bo->unique_id = __sync_fetch_and_add(>next_bo_unique_id, 1);
+   bo->is_local = !!(request.flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID);
 
if (initial_domain & RADEON_DOMAIN_VRAM)
   ws->allocated_vram += align64(size, ws->info.gart_page_size);
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
index 1311344b81..10b095d7a1 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
@@ -115,6 +115,8 @@ struct amdgpu_winsys_bo {
unsigned num_fences;
unsigned max_fences;
struct pipe_fence_handle **fences;
+
+   bool is_local;
 };
 
 struct amdgpu_slab {
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
index 5ddde8e794..f68071abc8 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
@@ -1121,6 +1121,8 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
   free(handles);
   mtx_unlock(>global_bo_list_lock);
} else {
+  unsigned num_handles;
+
   if (!amdgpu_add_sparse_backing_buffers(cs)) {
  r = -ENOMEM;
  goto bo_list_error;
@@ -1140,21 +1142,31 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
  }
   }
 
+  num_handles = 0;
   for (i = 0; i < cs->num_real_buffers; ++i) {
  struct amdgpu_cs_buffer *buffer = >real_buffers[i];
 
+if (buffer->bo->is_local)
+continue;
+
  assert(buffer->u.real.priority_usage != 0);
 
- cs->handles[i] = buffer->bo->bo;
- cs->flags[i] = (util_last_bit64(buffer->u.real.priority_usage) - 1) / 
4;
+ cs->handles[num_handles] = buffer->bo->bo;
+ cs->flags[num_handles] = 
(util_last_bit64(buffer->u.real.priority_usage) - 1) / 4;
+++num_handles;
   }
 
   if (acs->ring_type == RING_GFX)
  ws->gfx_bo_list_counter += cs->num_real_buffers;
 
-  r = amdgpu_bo_list_create(ws->dev, cs->num_real_buffers,
-cs->handles, cs->flags,
->request.resources);
+  if (num_handles) {
+ r = amdgpu_bo_list_create(ws->dev, num_handles,
+   cs->handles, cs->flags,
+   >request.resources);
+  } else {
+ r = 0;
+cs->request.resources = 0;
+  }
}
 bo_list_error:
 

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


Mesa (master): change va max_entrypoints

2017-06-22 Thread Christian König
Module: Mesa
Branch: master
Commit: 1d4cbcdf285730d8e692e10c44cb5dc7e683efc1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d4cbcdf285730d8e692e10c44cb5dc7e683efc1

Author: Chandu Babu N <mailto:cha...@amd.com>
Date:   Sat Jun 17 11:49:13 2017 +

change va max_entrypoints

As encode support is added along with decode, increase max_entrypoints to two.
vaMaxNumEntrypoints was returning incorrect value and causing
memory corruption before this commit

v2: assert when max_entrypoints needs to be bigger

CC: mesa-sta...@lists.freedesktop.org
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/config.c  | 2 ++
 src/gallium/state_trackers/va/context.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index c5d69bdc97..7d3bd648d9 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -102,6 +102,8 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile 
profile,
if (num_entrypoints == 0)
   return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
 
+   assert(*num_entrypoints <= ctx->max_entrypoints);
+
return VA_STATUS_SUCCESS;
 }
 
diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index 6e7a58da68..186f5066bd 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -167,7 +167,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
*ctx->vtable = vtable;
*ctx->vtable_vpp = vtable_vpp;
ctx->max_profiles = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH - 
PIPE_VIDEO_PROFILE_UNKNOWN;
-   ctx->max_entrypoints = 1;
+   ctx->max_entrypoints = 2;
ctx->max_attributes = 1;
ctx->max_image_formats = VL_VA_MAX_IMAGE_FORMATS;
ctx->max_subpic_formats = 1;

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


Mesa (master): st/va: Fix leak in VAAPI subpictures

2017-06-22 Thread Christian König
Module: Mesa
Branch: master
Commit: b1a359b7d8a0559412d253101e930a6a45d9af7a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b1a359b7d8a0559412d253101e930a6a45d9af7a

Author: Chandu Babu N <cha...@amd.com>
Date:   Thu Jun 22 11:06:41 2017 +0530

st/va: Fix leak in VAAPI subpictures

sampler view allocated in vaAssociateSubpicture is not cleared
in vaiDeassociateSubpicture.

Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/subpicture.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/state_trackers/va/subpicture.c 
b/src/gallium/state_trackers/va/subpicture.c
index 15d52b941c..981a99cec5 100644
--- a/src/gallium/state_trackers/va/subpicture.c
+++ b/src/gallium/state_trackers/va/subpicture.c
@@ -283,6 +283,7 @@ vlVaDeassociateSubpicture(VADriverContextP ctx, 
VASubpictureID subpicture,
   while (surf->subpics.size && util_dynarray_top(>subpics, 
vlVaSubpicture *) == NULL)
  (void)util_dynarray_pop(>subpics, vlVaSubpicture *);
}
+   pipe_sampler_view_reference(>sampler,NULL);
mtx_unlock(>mutex);
 
return VA_STATUS_SUCCESS;

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


Mesa (master): winsys/amdgpu: align VA allocations to fragment size v2

2017-05-24 Thread Christian König
Module: Mesa
Branch: master
Commit: 5318870f5457104aae87d7cd81b347e1aea231ea
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5318870f5457104aae87d7cd81b347e1aea231ea

Author: Christian König <christian.koe...@amd.com>
Date:   Tue May 23 18:40:18 2017 +0200

winsys/amdgpu: align VA allocations to fragment size v2

BOs larger than the minimum fragment size should have their VA
alignet to at least the fragment size for optimal performance.

v2: drop unused leftover from initial implementation

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/amd/common/ac_gpu_info.c  | 1 +
 src/amd/common/ac_gpu_info.h  | 1 +
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/src/amd/common/ac_gpu_info.c b/src/amd/common/ac_gpu_info.c
index cf5d6e1d8c..0b4933e174 100644
--- a/src/amd/common/ac_gpu_info.c
+++ b/src/amd/common/ac_gpu_info.c
@@ -281,6 +281,7 @@ bool ac_query_gpu_info(int fd, amdgpu_device_handle dev,
memcpy(info->cik_macrotile_mode_array, amdinfo->gb_macro_tile_mode,
sizeof(amdinfo->gb_macro_tile_mode));
 
+   info->pte_fragment_size = alignment_info.size_local;
info->gart_page_size = alignment_info.size_remote;
 
if (info->chip_class == SI)
diff --git a/src/amd/common/ac_gpu_info.h b/src/amd/common/ac_gpu_info.h
index d8029ef175..3785eb4d16 100644
--- a/src/amd/common/ac_gpu_info.h
+++ b/src/amd/common/ac_gpu_info.h
@@ -45,6 +45,7 @@ struct radeon_info {
uint32_tpci_id;
enum radeon_family  family;
enum chip_class chip_class;
+   uint32_tpte_fragment_size;
uint32_tgart_page_size;
uint64_tgart_size;
uint64_tvram_size;
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 6bdcce53dc..401741167a 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -415,6 +415,8 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct 
amdgpu_winsys *ws,
}
 
va_gap_size = ws->check_vm ? MAX2(4 * alignment, 64 * 1024) : 0;
+   if (size > ws->info.pte_fragment_size)
+  alignment = MAX2(alignment, ws->info.pte_fragment_size);
r = amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
  size + va_gap_size, alignment, 0, , 
_handle, 0);
if (r)

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


Mesa (master): st/va: remove assert for single slice

2017-03-28 Thread Christian König
Module: Mesa
Branch: master
Commit: 3472be2bfd8b9cbc931342cc99d0e1abdc48350b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3472be2bfd8b9cbc931342cc99d0e1abdc48350b

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Tue Mar 21 14:02:27 2017 +0530

st/va: remove assert for single slice

we anyway allow for multiple slices

v2: do not remove assert to check for buf->size

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/picture_mpeg12.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/picture_mpeg12.c 
b/src/gallium/state_trackers/va/picture_mpeg12.c
index 812e9e5b2a..1e5a9c7428 100644
--- a/src/gallium/state_trackers/va/picture_mpeg12.c
+++ b/src/gallium/state_trackers/va/picture_mpeg12.c
@@ -81,6 +81,6 @@ void vlVaHandleIQMatrixBufferMPEG12(vlVaContext *context, 
vlVaBuffer *buf)
 
 void vlVaHandleSliceParameterBufferMPEG12(vlVaContext *context, vlVaBuffer 
*buf)
 {
-   assert(buf->size >= sizeof(VASliceParameterBufferMPEG2) && 
buf->num_elements == 1);
+   assert(buf->size >= sizeof(VASliceParameterBufferMPEG2));
context->desc.mpeg12.num_slices += buf->num_elements;
 }

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


Mesa (master): svga: handle P016 format as well

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: 8dee325752daf1850a1f497c82b30d0574a5b612
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8dee325752daf1850a1f497c82b30d0574a5b612

Author: Christian König <christian.koe...@amd.com>
Date:   Mon Mar 13 12:43:18 2017 +0100

svga: handle P016 format as well

Fixes: 62cff793785 ("gallium: add P016 format")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100180
Reviewed-by: Emil Velikov <emil.veli...@collabora.com>

---

 src/gallium/drivers/svga/svga_format.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/svga/svga_format.c 
b/src/gallium/drivers/svga/svga_format.c
index 948b276..2969259 100644
--- a/src/gallium/drivers/svga/svga_format.c
+++ b/src/gallium/drivers/svga/svga_format.c
@@ -354,6 +354,7 @@ static const struct vgpu10_format_entry 
format_conversion_table[] =
{ PIPE_FORMAT_ASTC_10x10_SRGB,   SVGA3D_FORMAT_INVALID,  
SVGA3D_FORMAT_INVALID,   0 },
{ PIPE_FORMAT_ASTC_12x10_SRGB,   SVGA3D_FORMAT_INVALID,  
SVGA3D_FORMAT_INVALID,   0 },
{ PIPE_FORMAT_ASTC_12x12_SRGB,   SVGA3D_FORMAT_INVALID,  
SVGA3D_FORMAT_INVALID,   0 },
+   { PIPE_FORMAT_P016,  SVGA3D_FORMAT_INVALID,  
SVGA3D_FORMAT_INVALID,   0 },
 };
 
 

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


Mesa (master): st/va: add support for P010 and P016 formats v3

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: e58a1e8f68b3b740d915468012573a4d7befb875
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e58a1e8f68b3b740d915468012573a4d7befb875

Author: Christian König <christian.koe...@amd.com>
Date:   Mon Mar  6 17:53:04 2017 +0100

st/va: add support for P010 and P016 formats v3

No hardware I know off can actually support P010 natively. But we can easily
support P016 and as long as nobody decodes anything into the lower 6bits it
doesn't make any difference to P010.

v2: allow P0160 for post processing as well
v3: fix post processing once more

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Mark Thompson <s...@jkqxz.net>

---

 src/gallium/state_trackers/va/image.c  | 12 
 src/gallium/state_trackers/va/picture.c|  3 ++-
 src/gallium/state_trackers/va/postproc.c   |  3 ++-
 src/gallium/state_trackers/va/va_private.h |  7 ++-
 4 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/va/image.c 
b/src/gallium/state_trackers/va/image.c
index 2ce22ce..f87de8e 100644
--- a/src/gallium/state_trackers/va/image.c
+++ b/src/gallium/state_trackers/va/image.c
@@ -41,6 +41,8 @@
 static const VAImageFormat formats[] =
 {
{VA_FOURCC('N','V','1','2')},
+   {VA_FOURCC('P','0','1','0')},
+   {VA_FOURCC('P','0','1','6')},
{VA_FOURCC('I','4','2','0')},
{VA_FOURCC('Y','V','1','2')},
{VA_FOURCC('Y','U','Y','V')},
@@ -134,6 +136,16 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat 
*format, int width, int heig
   img->data_size  = w * h * 3 / 2;
   break;
 
+   case VA_FOURCC('P','0','1','0'):
+   case VA_FOURCC('P','0','1','6'):
+  img->num_planes = 2;
+  img->pitches[0] = w * 2;
+  img->offsets[0] = 0;
+  img->pitches[1] = w * 2;
+  img->offsets[1] = w * h * 2;
+  img->data_size  = w * h * 3;
+  break;
+
case VA_FOURCC('I','4','2','0'):
case VA_FOURCC('Y','V','1','2'):
   img->num_planes = 3;
diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 62a6878..20fe750 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -74,7 +74,8 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID 
context_id, VASurfaceID rende
   context->target->buffer_format != PIPE_FORMAT_R8G8B8A8_UNORM &&
   context->target->buffer_format != PIPE_FORMAT_B8G8R8X8_UNORM &&
   context->target->buffer_format != PIPE_FORMAT_R8G8B8X8_UNORM &&
-  context->target->buffer_format != PIPE_FORMAT_NV12)
+  context->target->buffer_format != PIPE_FORMAT_NV12 &&
+  context->target->buffer_format != PIPE_FORMAT_P016)
  return VA_STATUS_ERROR_UNIMPLEMENTED;
 
   return VA_STATUS_SUCCESS;
diff --git a/src/gallium/state_trackers/va/postproc.c 
b/src/gallium/state_trackers/va/postproc.c
index fbec69a..8467b0e 100644
--- a/src/gallium/state_trackers/va/postproc.c
+++ b/src/gallium/state_trackers/va/postproc.c
@@ -292,7 +292,8 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver 
*drv, vlVaContext *contex
src_region = vlVaRegionDefault(param->surface_region, src_surface->buffer, 
_src_region);
dst_region = vlVaRegionDefault(param->output_region, context->target, 
_dst_region);
 
-   if (context->target->buffer_format != PIPE_FORMAT_NV12)
+   if (context->target->buffer_format != PIPE_FORMAT_NV12 &&
+   context->target->buffer_format != PIPE_FORMAT_P016)
   return vlVaPostProcCompositor(drv, context, src_region, dst_region,
 src, context->target, deinterlace);
else
diff --git a/src/gallium/state_trackers/va/va_private.h 
b/src/gallium/state_trackers/va/va_private.h
index a7cedae..7216aba4 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -49,7 +49,7 @@
 #define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData)
 #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen)
 
-#define VL_VA_MAX_IMAGE_FORMATS 9
+#define VL_VA_MAX_IMAGE_FORMATS 11
 #define VL_VA_ENC_GOP_COEFF 16
 
 static inline enum pipe_video_chroma_format
@@ -73,6 +73,9 @@ VaFourccToPipeFormat(unsigned format)
switch(format) {
case VA_FOURCC('N','V','1','2'):
   return PIPE_FORMAT_NV12;
+   case VA_FOURCC('P','0','1','0'):
+   case VA_FOURCC('P','0','1','6'):
+  return PIPE_FORMAT_P016;
case VA_FOURCC('I','4','2','0'):
   return PIPE_FORMAT_IYUV;
case VA_FOURCC('Y','V','1','2'):
@@ -101,6 +104,8 @@ PipeFormatToVaFourcc(enum pipe_format p_format)
switch (p_format) {
case PIPE_FORMAT_NV12:
   return VA_FOURCC('N','V','1','2');
+   case PIPE_FORMAT_P016:
+  return VA_FOURCC('P','0','1','6');
case PIPE_FORMAT_IYUV:
   return VA_FOURC

Mesa (master): st/va: cleanup error handling in vlVaCreateSurfaces2

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: 1ce68af07b38f6f9c9f8c7b42d30b0c3026b1ceb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ce68af07b38f6f9c9f8c7b42d30b0c3026b1ceb

Author: Christian König <christian.koe...@amd.com>
Date:   Wed Jan 25 14:46:53 2017 +0100

st/va: cleanup error handling in vlVaCreateSurfaces2

No need to have that twice.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Mark Thompson <s...@jkqxz.net>

---

 src/gallium/state_trackers/va/surface.c | 52 +
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 1d8d981..3561117 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -488,8 +488,7 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID 
config_id,
 static VAStatus
 suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
 VASurfaceAttribExternalBuffers *memory_attibute,
-int index, VASurfaceID *surfaces,
-struct pipe_video_buffer *templat)
+unsigned index, struct pipe_video_buffer *templat)
 {
vlVaDriver *drv;
struct pipe_screen *pscreen;
@@ -498,9 +497,6 @@ suface_from_external_memory(VADriverContextP ctx, 
vlVaSurface *surface,
struct winsys_handle whandle;
struct pipe_resource *resources[VL_NUM_COMPONENTS];
 
-   if (!ctx)
-  return VA_STATUS_ERROR_INVALID_PARAMETER;
-
pscreen = VL_VA_PSCREEN(ctx);
drv = VL_VA_DRIVER(ctx);
 
@@ -554,14 +550,6 @@ suface_from_external_memory(VADriverContextP ctx, 
vlVaSurface *surface,
if (!surface->buffer)
   return VA_STATUS_ERROR_ALLOCATION_FAILED;
 
-   util_dynarray_init(>subpics);
-   surfaces[index] = handle_table_add(drv->htab, surface);
-
-   if (!surfaces[index]) {
-  surface->buffer->destroy(surface->buffer);
-  return VA_STATUS_ERROR_ALLOCATION_FAILED;
-   }
-
return VA_STATUS_SUCCESS;
 }
 
@@ -579,6 +567,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int 
format,
int memory_type;
int expected_fourcc;
VAStatus vaStatus;
+   vlVaSurface *surf;
 
if (!ctx)
   return VA_STATUS_ERROR_INVALID_CONTEXT;
@@ -688,9 +677,11 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int 
format,
 
mtx_lock(>mutex);
for (i = 0; i < num_surfaces; i++) {
-  vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface));
-  if (!surf)
+  surf = CALLOC(1, sizeof(vlVaSurface));
+  if (!surf) {
+ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
  goto no_res;
+  }
 
   surf->templat = templat;
 
@@ -706,33 +697,44 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int 
format,
 
  surf->buffer = drv->pipe->create_video_buffer(drv->pipe, );
  if (!surf->buffer) {
-FREE(surf);
-goto no_res;
+vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
+goto free_surf;
  }
- util_dynarray_init(>subpics);
- surfaces[i] = handle_table_add(drv->htab, surf);
  break;
+
   case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME:
- vaStatus = suface_from_external_memory(ctx, surf, memory_attibute, i, 
surfaces, );
- if (vaStatus != VA_STATUS_SUCCESS) {
-FREE(surf);
-goto no_res;
- }
+ vaStatus = suface_from_external_memory(ctx, surf, memory_attibute, i, 
);
+ if (vaStatus != VA_STATUS_SUCCESS)
+goto free_surf;
  break;
+
   default:
  assert(0);
   }
+
+  util_dynarray_init(>subpics);
+  surfaces[i] = handle_table_add(drv->htab, surf);
+  if (!surfaces[i]) {
+ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
+ goto destroy_surf;
+  }
}
mtx_unlock(>mutex);
 
return VA_STATUS_SUCCESS;
 
+destroy_surf:
+   surf->buffer->destroy(surf->buffer);
+
+free_surf:
+   FREE(surf);
+
 no_res:
mtx_unlock(>mutex);
if (i)
   vlVaDestroySurfaces(ctx, surfaces, i);
 
-   return VA_STATUS_ERROR_ALLOCATION_FAILED;
+   return vaStatus;
 }
 
 VAStatus

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


Mesa (master): radeon/uvd: enable 10bit HEVC decode v2

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: 88f34510832d4468fe887b6383d2006d9b85fb9b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=88f34510832d4468fe887b6383d2006d9b85fb9b

Author: Christian König <christian.koe...@amd.com>
Date:   Mon Jan 16 15:04:47 2017 +0100

radeon/uvd: enable 10bit HEVC decode v2

Just use whatever the state tracker allocated.

v2: fix msb mode

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Mark Thompson <s...@jkqxz.net>

---

 src/gallium/drivers/radeon/radeon_uvd.c   | 17 ++---
 src/gallium/drivers/radeon/radeon_video.c | 11 ++-
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_uvd.c 
b/src/gallium/drivers/radeon/radeon_uvd.c
index 7a08c81..610416b 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -704,13 +704,16 @@ static struct ruvd_h265 get_h265_msg(struct ruvd_decoder 
*dec, struct pipe_video
result.direct_reflist[i][j] = pic->RefPicList[i][j];
}
 
-   if ((pic->base.profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10) &&
-   (target->buffer_format == PIPE_FORMAT_NV12)) {
-   result.p010_mode = 0;
-   result.luma_10to8 = 5;
-   result.chroma_10to8 = 5;
-   result.sclr_luma10to8 = 4;
-   result.sclr_chroma10to8 = 4;
+   if (pic->base.profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10) {
+   if (target->buffer_format == PIPE_FORMAT_P016) {
+   result.p010_mode = 1;
+   result.msb_mode = 1;
+   } else {
+   result.luma_10to8 = 5;
+   result.chroma_10to8 = 5;
+   result.sclr_luma10to8 = 4;
+   result.sclr_chroma10to8 = 4;
+   }
}
 
/* TODO
diff --git a/src/gallium/drivers/radeon/radeon_video.c 
b/src/gallium/drivers/radeon/radeon_video.c
index ecafaf8..605a2c7 100644
--- a/src/gallium/drivers/radeon/radeon_video.c
+++ b/src/gallium/drivers/radeon/radeon_video.c
@@ -279,7 +279,11 @@ int rvid_get_video_param(struct pipe_screen *screen,
case PIPE_VIDEO_CAP_MAX_HEIGHT:
return (rscreen->family < CHIP_TONGA) ? 1152 : 4096;
case PIPE_VIDEO_CAP_PREFERED_FORMAT:
-   return PIPE_FORMAT_NV12;
+   if (profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10)
+   return PIPE_FORMAT_P016;
+   else
+   return PIPE_FORMAT_NV12;
+
case PIPE_VIDEO_CAP_PREFERS_INTERLACED:
case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED:
if (rscreen->family < CHIP_PALM) {
@@ -331,6 +335,11 @@ boolean rvid_is_format_supported(struct pipe_screen 
*screen,
 enum pipe_video_profile profile,
 enum pipe_video_entrypoint entrypoint)
 {
+   /* HEVC 10 bit decoding should use P016 instead of NV12 if possible */
+   if (profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10)
+   return (format == PIPE_FORMAT_NV12) ||
+   (format == PIPE_FORMAT_P016);
+
/* we can only handle this one with UVD */
if (profile != PIPE_VIDEO_PROFILE_UNKNOWN)
return format == PIPE_FORMAT_NV12;

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


Mesa (master): vl/video_buffer: add support for P016

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: cee591a224466f344cf6ab504c66f527d4f95b6d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cee591a224466f344cf6ab504c66f527d4f95b6d

Author: Christian König <christian.koe...@amd.com>
Date:   Sat Jan 14 13:57:02 2017 +0100

vl/video_buffer: add support for P016

Just simply the description of the planes.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Mark Thompson <s...@jkqxz.net>

---

 src/gallium/auxiliary/vl/vl_video_buffer.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c 
b/src/gallium/auxiliary/vl/vl_video_buffer.c
index fdc9598..f6b3cb5 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.c
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.c
@@ -86,6 +86,12 @@ const enum pipe_format const_resource_formats_UYVY[3] = {
PIPE_FORMAT_NONE
 };
 
+const enum pipe_format const_resource_formats_P016[3] = {
+   PIPE_FORMAT_R16_UNORM,
+   PIPE_FORMAT_R16G16_UNORM,
+   PIPE_FORMAT_NONE
+};
+
 const unsigned const_resource_plane_order_YUV[3] = {
0,
1,
@@ -126,6 +132,9 @@ vl_video_buffer_formats(struct pipe_screen *screen, enum 
pipe_format format)
case PIPE_FORMAT_UYVY:
   return const_resource_formats_UYVY;
 
+   case PIPE_FORMAT_P016:
+  return const_resource_formats_P016;
+
default:
   return NULL;
}
@@ -143,6 +152,7 @@ vl_video_buffer_plane_order(enum pipe_format format)
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_YUYV:
case PIPE_FORMAT_UYVY:
+   case PIPE_FORMAT_P016:
   return const_resource_plane_order_YUV;
 
default:

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


Mesa (master): st/va: add config support for 10bit decoding v2

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: 5369b5a91dea392d3aea6f3438b77ee9b4d2a653
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5369b5a91dea392d3aea6f3438b77ee9b4d2a653

Author: Christian König <christian.koe...@amd.com>
Date:   Mon Mar  6 17:36:29 2017 +0100

st/va: add config support for 10bit decoding v2

Advertise 10bpp support if the driver supports decoding to a P016 surface.

v2: Advertise 10bpp for the decoder as well.

Signed-off-by: Christian König <christian.koe...@amd.com>
Signed-off-by: Mark Thompson <s...@jkqxz.net>

---

 src/gallium/state_trackers/va/config.c | 24 
 src/gallium/state_trackers/va/va_private.h |  1 +
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index 15beb6c..05f97a01 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -108,17 +108,24 @@ VAStatus
 vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint 
entrypoint,
 VAConfigAttrib *attrib_list, int num_attribs)
 {
+   struct pipe_screen *pscreen;
int i;
 
if (!ctx)
   return VA_STATUS_ERROR_INVALID_CONTEXT;
 
+   pscreen = VL_VA_PSCREEN(ctx);
+
for (i = 0; i < num_attribs; ++i) {
   unsigned int value;
   if (entrypoint == VAEntrypointVLD) {
  switch (attrib_list[i].type) {
  case VAConfigAttribRTFormat:
 value = VA_RT_FORMAT_YUV420;
+   if (pscreen->is_video_format_supported(pscreen, PIPE_FORMAT_P016,
+   ProfileToPipe(profile),
+   
PIPE_VIDEO_ENTRYPOINT_BITSTREAM))
+   value |= VA_RT_FORMAT_YUV420_10BPP;
 break;
  default:
 value = VA_ATTRIB_NOT_SUPPORTED;
@@ -146,6 +153,7 @@ vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile 
profile, VAEntrypoint en
  switch (attrib_list[i].type) {
  case VAConfigAttribRTFormat:
 value = (VA_RT_FORMAT_YUV420 |
+ VA_RT_FORMAT_YUV420_10BPP |
  VA_RT_FORMAT_RGB32);
 break;
  default:
@@ -169,6 +177,7 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
vlVaConfig *config;
struct pipe_screen *pscreen;
enum pipe_video_profile p;
+   unsigned int supported_rt_formats;
 
if (!ctx)
   return VA_STATUS_ERROR_INVALID_CONTEXT;
@@ -185,9 +194,12 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) {
   config->entrypoint = VAEntrypointVideoProc;
   config->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
+  supported_rt_formats = VA_RT_FORMAT_YUV420 |
+ VA_RT_FORMAT_YUV420_10BPP |
+ VA_RT_FORMAT_RGB32;
   for (int i = 0; i < num_attribs; i++) {
  if (attrib_list[i].type == VAConfigAttribRTFormat) {
-if (attrib_list[i].value & (VA_RT_FORMAT_YUV420 | 
VA_RT_FORMAT_RGB32)) {
+if (attrib_list[i].value & supported_rt_formats) {
config->rt_format = attrib_list[i].value;
 } else {
FREE(config);
@@ -198,7 +210,7 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
 
   /* Default value if not specified in the input attributes. */
   if (!config->rt_format)
- config->rt_format = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_RGB32;
+ config->rt_format = supported_rt_formats;
 
   mtx_lock(>mutex);
   *config_id = handle_table_add(drv->htab, config);
@@ -241,6 +253,10 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
}
 
config->profile = p;
+   supported_rt_formats = VA_RT_FORMAT_YUV420;
+   if (pscreen->is_video_format_supported(pscreen, PIPE_FORMAT_P016, p,
+ config->entrypoint))
+  supported_rt_formats |= VA_RT_FORMAT_YUV420_10BPP;
 
for (int i = 0; i rc = PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE;
   }
   if (attrib_list[i].type == VAConfigAttribRTFormat) {
- if (attrib_list[i].value == VA_RT_FORMAT_YUV420) {
+ if (attrib_list[i].value & supported_rt_formats) {
 config->rt_format = attrib_list[i].value;
  } else {
 FREE(config);
@@ -263,7 +279,7 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
 
/* Default value if not specified in the input attributes. */
if (!config->rt_format)
-  config->rt_format = VA_RT_FORMAT_YUV420;
+  config->rt_format = supported_rt_formats;
 
mtx_lock(>mutex);
*config_id = handle_table_add(drv->htab, config);
diff --gi

Mesa (master): radeon/UVD: fix the decoding target pitch calculation

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: 3e1e441aa05069e3eee906144cf96898e0b802e2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3e1e441aa05069e3eee906144cf96898e0b802e2

Author: Christian König <christian.koe...@amd.com>
Date:   Wed Mar  8 12:51:13 2017 +0100

radeon/UVD: fix the decoding target pitch calculation

The firmware expects the value in pixel not bytes. Didn't made a difference
so far because we only used 8bpp surfaces.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Mark Thompson <s...@jkqxz.net>

---

 src/gallium/drivers/radeon/radeon_uvd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/radeon_uvd.c 
b/src/gallium/drivers/radeon/radeon_uvd.c
index f1339d1..7a08c81 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -1354,7 +1354,7 @@ static unsigned bank_wh(unsigned bankwh)
 void ruvd_set_dt_surfaces(struct ruvd_msg *msg, struct radeon_surf *luma,
  struct radeon_surf *chroma)
 {
-   msg->body.decode.dt_pitch = luma->level[0].nblk_x * luma->bpe;
+   msg->body.decode.dt_pitch = luma->level[0].nblk_x;
switch (luma->level[0].mode) {
case RADEON_SURF_MODE_LINEAR_ALIGNED:
msg->body.decode.dt_tiling_mode = RUVD_TILE_LINEAR;

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


Mesa (master): st/va: add support for allocating 10bpp surfaces

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: e9d3e29bb3225e1f6e8fdf56702979e86d92e675
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e9d3e29bb3225e1f6e8fdf56702979e86d92e675

Author: Christian König <christian.koe...@amd.com>
Date:   Tue Mar  7 15:23:39 2017 +0100

st/va: add support for allocating 10bpp surfaces

We support P010 and P016 as targets for 10bpp video decoding.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Mark Thompson <s...@jkqxz.net>

---

 src/gallium/state_trackers/va/surface.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 543a00a..c7d6ef7 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -431,21 +431,26 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, 
VAConfigID config_id,
 i++;
  }
   }
-  if (config->rt_format & VA_RT_FORMAT_YUV420) {
- attribs[i].type = VASurfaceAttribPixelFormat;
- attribs[i].value.type = VAGenericValueTypeInteger;
- attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | 
VA_SURFACE_ATTRIB_SETTABLE;
- attribs[i].value.value.i = VA_FOURCC_NV12;
- i++;
-  }
-   } else {
-  /* Assume VAEntrypointVLD for now. */
+   }
+   if (config->rt_format & VA_RT_FORMAT_YUV420) {
   attribs[i].type = VASurfaceAttribPixelFormat;
   attribs[i].value.type = VAGenericValueTypeInteger;
   attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | 
VA_SURFACE_ATTRIB_SETTABLE;
   attribs[i].value.value.i = VA_FOURCC_NV12;
   i++;
}
+   if (config->rt_format & VA_RT_FORMAT_YUV420_10BPP) {
+  attribs[i].type = VASurfaceAttribPixelFormat;
+  attribs[i].value.type = VAGenericValueTypeInteger;
+  attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | 
VA_SURFACE_ATTRIB_SETTABLE;
+  attribs[i].value.value.i = VA_FOURCC_P010;
+  i++;
+  attribs[i].type = VASurfaceAttribPixelFormat;
+  attribs[i].value.type = VAGenericValueTypeInteger;
+  attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | 
VA_SURFACE_ATTRIB_SETTABLE;
+  attribs[i].value.value.i = VA_FOURCC_P016;
+  i++;
+   }
 
attribs[i].type = VASurfaceAttribMemoryType;
attribs[i].value.type = VAGenericValueTypeInteger;
@@ -658,6 +663,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int 
format,
if (VA_RT_FORMAT_YUV420 != format &&
VA_RT_FORMAT_YUV422 != format &&
VA_RT_FORMAT_YUV444 != format &&
+   VA_RT_FORMAT_YUV420_10BPP != format &&
VA_RT_FORMAT_RGB32  != format) {
   return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
}

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


Mesa (master): st/va: clear the video surface on allocation

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: f1d1deb0157fd011daa60d439157bb16f30566ca
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1d1deb0157fd011daa60d439157bb16f30566ca

Author: Christian König <christian.koe...@amd.com>
Date:   Tue Mar  7 15:20:08 2017 +0100

st/va: clear the video surface on allocation

This makes debugging of decoding problems quite a bit easier.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Mark Thompson <s...@jkqxz.net>

---

 src/gallium/state_trackers/va/surface.c | 39 +
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 3561117..543a00a 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -553,6 +553,39 @@ suface_from_external_memory(VADriverContextP ctx, 
vlVaSurface *surface,
return VA_STATUS_SUCCESS;
 }
 
+static VAStatus
+surface_allocate(VADriverContextP ctx, vlVaSurface *surface,
+struct pipe_video_buffer *templat)
+{
+   vlVaDriver *drv;
+   struct pipe_surface **surfaces;
+   unsigned i;
+
+   drv = VL_VA_DRIVER(ctx);
+
+   surface->buffer = drv->pipe->create_video_buffer(drv->pipe, templat);
+   if (!surface->buffer)
+  return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+   surfaces = surface->buffer->get_surfaces(surface->buffer);
+   for (i = 0; i < VL_MAX_SURFACES; ++i) {
+  union pipe_color_union c = {};
+
+  if (!surfaces[i])
+ continue;
+
+  if (i > !!surface->buffer->interlaced)
+ c.f[0] = c.f[1] = c.f[2] = c.f[3] = 0.5f;
+
+  drv->pipe->clear_render_target(drv->pipe, surfaces[i], , 0, 0,
+surfaces[i]->width, surfaces[i]->height,
+false);
+   }
+   drv->pipe->flush(drv->pipe, NULL, 0);
+
+   return VA_STATUS_SUCCESS;
+}
+
 VAStatus
 vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
 unsigned int width, unsigned int height,
@@ -695,11 +728,9 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int 
format,
  !(memory_attibute->flags & VA_SURFACE_EXTBUF_DESC_ENABLE_TILING))
 templat.bind = PIPE_BIND_LINEAR | PIPE_BIND_SHARED;
 
- surf->buffer = drv->pipe->create_video_buffer(drv->pipe, );
- if (!surf->buffer) {
-vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
+vaStatus = surface_allocate(ctx, surf, );
+ if (vaStatus != VA_STATUS_SUCCESS)
 goto free_surf;
- }
  break;
 
   case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME:

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


Mesa (master): gallium: add P016 format

2017-03-13 Thread Christian König
Module: Mesa
Branch: master
Commit: 62cff793785ee203b086e4895bae0f78cc0748d7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=62cff793785ee203b086e4895bae0f78cc0748d7

Author: Christian König <christian.koe...@amd.com>
Date:   Fri Jan 13 19:11:43 2017 +0100

gallium: add P016 format

Same layout as NV12, but 16bit per channel instead of 8.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Mark Thompson <s...@jkqxz.net>

---

 src/gallium/auxiliary/util/u_format.csv   |  2 ++
 src/gallium/auxiliary/util/u_format_yuv.c | 19 +++
 src/gallium/auxiliary/util/u_format_yuv.h | 19 +++
 src/gallium/include/pipe/p_format.h   |  2 ++
 4 files changed, 42 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_format.csv 
b/src/gallium/auxiliary/util/u_format.csv
index c26d733..cef530a 100644
--- a/src/gallium/auxiliary/util/u_format.csv
+++ b/src/gallium/auxiliary/util/u_format.csv
@@ -320,6 +320,8 @@ PIPE_FORMAT_IYUV  , other, 1, 1, x8  , x8  
, x8  , x8  , xyzw, y
 PIPE_FORMAT_NV12  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, 
yuv
 PIPE_FORMAT_NV21  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, 
yuv
 
+PIPE_FORMAT_P016  , other, 1, 1, x16 , x16 , , , xyzw, 
yuv
+
 # Usually used to implement IA44 and AI44 formats in video decoding
 PIPE_FORMAT_A4R4_UNORM, plain, 1, 1, un4 , un4 , , , y00x, 
rgb, un4, un4 , , , x00y
 PIPE_FORMAT_R4A4_UNORM, plain, 1, 1, un4 , un4 , , , x00y, 
rgb, un4, un4 , , , y00x
diff --git a/src/gallium/auxiliary/util/u_format_yuv.c 
b/src/gallium/auxiliary/util/u_format_yuv.c
index 16ed8af..55f8ad6 100644
--- a/src/gallium/auxiliary/util/u_format_yuv.c
+++ b/src/gallium/auxiliary/util/u_format_yuv.c
@@ -1015,6 +1015,25 @@ util_format_nv21_pack_rgba_float(uint8_t *dst_row, 
unsigned dst_stride,
 void
 util_format_nv21_fetch_rgba_float(float *dst, const uint8_t *src,
  unsigned i, unsigned j) {}
+void
+util_format_p016_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_p016_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_p016_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_p016_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_p016_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j) {}
 
 void
 util_format_r8g8_r8b8_unorm_unpack_rgba_float(float *dst_row, unsigned 
dst_stride,
diff --git a/src/gallium/auxiliary/util/u_format_yuv.h 
b/src/gallium/auxiliary/util/u_format_yuv.h
index 41524d6..d8e67b4 100644
--- a/src/gallium/auxiliary/util/u_format_yuv.h
+++ b/src/gallium/auxiliary/util/u_format_yuv.h
@@ -266,6 +266,25 @@ void
 util_format_nv21_fetch_rgba_float(float *dst, const uint8_t *src,
  unsigned i, unsigned j);
 void
+util_format_p016_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_p016_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_p016_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_p016_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_p016_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+void
 util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned 
dst_stride,
  const uint8_t *src_row, unsigned 
src_stride,
  unsigned width, unsigned height);
diff --git a/src/gallium/include/pipe/p_format.h 
b/src/gallium/include/pipe/p_format.h
index b22baa9..e4e09d8 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/ga

Mesa (master): st/va: Support fractional framerate in misc parameter

2017-03-06 Thread Christian König
Module: Mesa
Branch: master
Commit: c93a157078591847a226265edf1c701d81635fc1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c93a157078591847a226265edf1c701d81635fc1

Author: Mark Thompson <s...@jkqxz.net>
Date:   Fri Jan 27 22:03:10 2017 +

st/va: Support fractional framerate in misc parameter

Signed-off-by: Mark Thompson <s...@jkqxz.net>
Acked-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/picture.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 53bb9eb..ef8b57a 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -348,7 +348,13 @@ static VAStatus
 handleVAEncMiscParameterTypeFrameRate(vlVaContext *context, 
VAEncMiscParameterBuffer *misc)
 {
VAEncMiscParameterFrameRate *fr = (VAEncMiscParameterFrameRate *)misc->data;
-   context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate;
+   if (fr->framerate & 0x) {
+  context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate   & 
0x;
+  context->desc.h264enc.rate_ctrl.frame_rate_den = fr->framerate >> 16 & 
0x;
+   } else {
+  context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate;
+  context->desc.h264enc.rate_ctrl.frame_rate_den = 1;
+   }
return VA_STATUS_SUCCESS;
 }
 

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


Mesa (master): st/omx: Set end-of-frame flag on bitstream output buffers

2017-03-06 Thread Christian König
Module: Mesa
Branch: master
Commit: 6398a092131ab0c9cb47f2a6f78ae1d8ba0ea65c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6398a092131ab0c9cb47f2a6f78ae1d8ba0ea65c

Author: Mark Thompson <s...@jkqxz.net>
Date:   Sun Mar  5 23:18:11 2017 +

st/omx: Set end-of-frame flag on bitstream output buffers

Since all output buffers are whole frames, this should always be set.

Technically, setting this flag is is optional (see OpenMAX IL section
3.1.2.7.1), but some clients assume that it will be used and
therefore buffer indefinitely thinking that all output buffers are
fragments of the first frame when it is not set.

Signed-off-by: Mark Thompson <s...@jkqxz.net>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/omx/vid_enc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/state_trackers/omx/vid_enc.c 
b/src/gallium/state_trackers/omx/vid_enc.c
index b2970a5..b58063e 100644
--- a/src/gallium/state_trackers/omx/vid_enc.c
+++ b/src/gallium/state_trackers/omx/vid_enc.c
@@ -1271,4 +1271,7 @@ static void vid_enc_BufferEncoded(OMX_COMPONENTTYPE 
*comp, OMX_BUFFERHEADERTYPE*
 
output->nOffset = 0;
output->nFilledLen = size; /* mark buffer as full */
+
+   /* all output buffers contain exactly one frame */
+   output->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
 }

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


Mesa (master): st/va encode handle ntsc framerate rate control

2017-03-06 Thread Christian König
Module: Mesa
Branch: master
Commit: 012b6d3fe7937d1624f906351b2ba555d9e7e112
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=012b6d3fe7937d1624f906351b2ba555d9e7e112

Author: Andy Furniss <adf.li...@gmail.com>
Date:   Sun Jan 29 14:22:31 2017 +

st/va encode handle ntsc framerate rate control

Tested with ffmpeg and gst-vaapi. Without this bits per
frame is set way too low for fractional framerates.

v2: Mark Thompson: simplify calculation.
Use float.

Signed-off-by: Andy Furniss <adf.li...@gmail.com>
Acked-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/picture.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 82584ea..53bb9eb 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -119,14 +119,21 @@ getEncParamPreset(vlVaContext *context)
context->desc.h264enc.rate_ctrl.fill_data_enable = 1;
context->desc.h264enc.rate_ctrl.enforce_hrd = 1;
context->desc.h264enc.enable_vui = false;
-   if (context->desc.h264enc.rate_ctrl.frame_rate_num == 0)
-  context->desc.h264enc.rate_ctrl.frame_rate_num = 30;
+   if (context->desc.h264enc.rate_ctrl.frame_rate_num == 0 ||
+   context->desc.h264enc.rate_ctrl.frame_rate_den == 0) {
+ context->desc.h264enc.rate_ctrl.frame_rate_num = 30;
+ context->desc.h264enc.rate_ctrl.frame_rate_den = 1;
+   }
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.target_bitrate *
+  ((float)context->desc.h264enc.rate_ctrl.frame_rate_den /
+  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;
+  context->desc.h264enc.rate_ctrl.peak_bitrate *
+  ((float)context->desc.h264enc.rate_ctrl.frame_rate_den /
+  context->desc.h264enc.rate_ctrl.frame_rate_num);
 
+   context->desc.h264enc.rate_ctrl.peak_bits_picture_fraction = 0;
context->desc.h264enc.ref_pic_mode = 0x0201;
 }
 
@@ -362,7 +369,7 @@ handleVAEncSequenceParameterBufferType(vlVaDriver *drv, 
vlVaContext *context, vl
   context->gop_coeff = VL_VA_ENC_GOP_COEFF;
context->desc.h264enc.gop_size = h264->intra_idr_period * 
context->gop_coeff;
context->desc.h264enc.rate_ctrl.frame_rate_num = h264->time_scale / 2;
-   context->desc.h264enc.rate_ctrl.frame_rate_den = 1;
+   context->desc.h264enc.rate_ctrl.frame_rate_den = h264->num_units_in_tick;
return VA_STATUS_SUCCESS;
 }
 

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


Mesa (master): st/va: Fix forward/backward referencing for deinterlacing

2017-03-06 Thread Christian König
Module: Mesa
Branch: master
Commit: 0798fddb5000f2b1edffc693ec65236a680ce61f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0798fddb5000f2b1edffc693ec65236a680ce61f

Author: Mark Thompson <s...@jkqxz.net>
Date:   Wed Mar  1 20:07:09 2017 +

st/va: Fix forward/backward referencing for deinterlacing

The VAAPI documentation is not very clear here, but the intent
appears to be that a forward reference is forward from a frame in the
past, not forward to a frame in the future (that is, forward as in
forward prediction, not as in a forward reference in source code).
This interpretation is derived from other implementations, in
particular the i965 driver and the gstreamer client.

In order to match those other implementations, this patch swaps the
meaning of forward and backward references as they currently appear
for motion-adaptive deinterlacing.

Signed-off-by: Mark Thompson <s...@jkqxz.net>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/postproc.c | 10 +-
 src/gallium/state_trackers/va/surface.c  |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/va/postproc.c 
b/src/gallium/state_trackers/va/postproc.c
index 01e240f..fbec69a 100644
--- a/src/gallium/state_trackers/va/postproc.c
+++ b/src/gallium/state_trackers/va/postproc.c
@@ -184,13 +184,13 @@ vlVaApplyDeint(vlVaDriver *drv, vlVaContext *context,
 {
vlVaSurface *prevprev, *prev, *next;
 
-   if (param->num_forward_references < 1 ||
-   param->num_backward_references < 2)
+   if (param->num_forward_references < 2 ||
+   param->num_backward_references < 1)
   return current;
 
-   prevprev = handle_table_get(drv->htab, param->backward_references[1]);
-   prev = handle_table_get(drv->htab, param->backward_references[0]);
-   next = handle_table_get(drv->htab, param->forward_references[0]);
+   prevprev = handle_table_get(drv->htab, param->forward_references[1]);
+   prev = handle_table_get(drv->htab, param->forward_references[0]);
+   next = handle_table_get(drv->htab, param->backward_references[0]);
 
if (!prevprev || !prev || !next)
   return current;
diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 0e1dbe0..b129e6c 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -845,8 +845,8 @@ vlVaQueryVideoProcPipelineCaps(VADriverContextP ctx, 
VAContextID context,
   case VAProcFilterDeinterlacing: {
  VAProcFilterParameterBufferDeinterlacing *deint = buf->data;
  if (deint->algorithm == VAProcDeinterlacingMotionAdaptive) {
-pipeline_cap->num_forward_references = 1;
-pipeline_cap->num_backward_references = 2;
+pipeline_cap->num_forward_references = 2;
+pipeline_cap->num_backward_references = 1;
  }
  break;
   }

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


Mesa (master): st/omx: Fix port format enumeration

2017-03-06 Thread Christian König
Module: Mesa
Branch: master
Commit: 6d95358aacc184b8927ff138e90d5920885365e7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d95358aacc184b8927ff138e90d5920885365e7

Author: Mark Thompson <s...@jkqxz.net>
Date:   Sun Mar  5 22:10:14 2017 +

st/omx: Fix port format enumeration

From OpenMAX IL section 4.3.5:
"The value of nIndex is the range 0 to N-1, where N is the number of
formats supported by the port.  There is no need for the port to
report N, as the caller can determine N by enumerating all the
formats supported by the port.  Each port shall support at least one
format.  If there are no more formats, OMX_GetParameter returns
OMX_ErrorNoMore (i.e., nIndex is supplied where the value is N or
greater)."

Only one format is supported, so N = 1 and OMX_ErrorNoMore should be
returned if nIndex >= 1.  The previous code here would return the
same format for all values of nIndex, resulting in an infinite loop
when a client attempts to enumerate all formats.

Signed-off-by: Mark Thompson <s...@jkqxz.net>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/omx/vid_enc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/state_trackers/omx/vid_enc.c 
b/src/gallium/state_trackers/omx/vid_enc.c
index 07f6799..b2970a5 100644
--- a/src/gallium/state_trackers/omx/vid_enc.c
+++ b/src/gallium/state_trackers/omx/vid_enc.c
@@ -473,6 +473,8 @@ static OMX_ERRORTYPE vid_enc_GetParameter(OMX_HANDLETYPE 
handle, OMX_INDEXTYPE i
 
   if (format->nPortIndex > 1)
  return OMX_ErrorBadPortIndex;
+  if (format->nIndex >= 1)
+ return OMX_ErrorNoMore;
 
   port = (omx_base_video_PortType *)priv->ports[format->nPortIndex];
   memcpy(format, >sVideoParam, 
sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));

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


Mesa (master): st/va: make sure that we call begin_frame() only once v2

2017-01-23 Thread Christian König
Module: Mesa
Branch: master
Commit: 1338d912f52b69f76ef75d1ad313893db77d4da8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1338d912f52b69f76ef75d1ad313893db77d4da8

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jan 19 13:44:34 2017 +0100

st/va: make sure that we call begin_frame() only once v2

This fixes "st/va: delay calling begin_frame until we have all parameters".

v2: call begin frame after decoder (re)creation as well.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Tested-by: Andy Furniss <adf.li...@gmail.com>

---

 src/gallium/state_trackers/va/picture.c| 11 ---
 src/gallium/state_trackers/va/va_private.h |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index dc7121c..82584ea 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -81,7 +81,7 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID 
context_id, VASurfaceID rende
}
 
if (context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE)
-  context->decoder->begin_frame(context->decoder, context->target, 
>desc.base);
+  context->needs_begin_frame = true;
 
return VA_STATUS_SUCCESS;
 }
@@ -178,6 +178,8 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext 
*context, vlVaBuffer *
 
   if (!context->decoder)
  return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+  context->needs_begin_frame = true;
}
 
return vaStatus;
@@ -308,8 +310,11 @@ handleVASliceDataBufferType(vlVaContext *context, 
vlVaBuffer *buf)
sizes[num_buffers] = buf->size;
++num_buffers;
 
-   context->decoder->begin_frame(context->decoder, context->target,
-  >desc.base);
+   if (context->needs_begin_frame) {
+  context->decoder->begin_frame(context->decoder, context->target,
+ >desc.base);
+  context->needs_begin_frame = false;
+   }
context->decoder->decode_bitstream(context->decoder, context->target, 
>desc.base,
   num_buffers, (const void * const*)buffers, sizes);
 }
diff --git a/src/gallium/state_trackers/va/va_private.h 
b/src/gallium/state_trackers/va/va_private.h
index 8faec10..0877236 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -261,6 +261,7 @@ typedef struct {
int target_id;
bool first_single_submitted;
int gop_coeff;
+   bool needs_begin_frame;
 } vlVaContext;
 
 typedef struct {

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


Mesa (master): st/vdpau: only send buffers with B8G8R8A8 format to X

2017-01-19 Thread Christian König
Module: Mesa
Branch: master
Commit: 31908d6a4a3309f4cd4b953d6eecdf41595b1299
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=31908d6a4a3309f4cd4b953d6eecdf41595b1299

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Thu Jan 19 15:17:28 2017 +0530

st/vdpau: only send buffers with B8G8R8A8 format to X

PresentPixmap only works if the pixmap depth matches with the
window depth, otherwise it returns a BadMatch protocol error.
Even if the depths match, the result won't look correctly
if the VDPAU RGB component order doesn't match the X11 one so
we only allow the X11 format.
For other buffers we copy them to a buffer which is send to X.

v2: only send buffers with format VDP_RGBA_FORMAT_B8G8R8A8
v3: reword commit message
v4: add comment explaining the code

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/output.c| 7 +++
 src/gallium/state_trackers/vdpau/presentation.c  | 6 +++---
 src/gallium/state_trackers/vdpau/vdpau_private.h | 1 +
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index 98a8011..8b26f7a 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -75,6 +75,13 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
 
memset(_tmpl, 0, sizeof(res_tmpl));
 
+   /*
+* The output won't look correctly when this buffer is send to X,
+* if the VDPAU RGB component order doesn't match the X11 one so
+* we only allow the X11 format
+*/
+   vlsurface->send_to_X = rgba_format == VDP_RGBA_FORMAT_B8G8R8A8;
+
res_tmpl.target = PIPE_TEXTURE_2D;
res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
res_tmpl.width0 = width;
diff --git a/src/gallium/state_trackers/vdpau/presentation.c 
b/src/gallium/state_trackers/vdpau/presentation.c
index d479369..78cafc8 100644
--- a/src/gallium/state_trackers/vdpau/presentation.c
+++ b/src/gallium/state_trackers/vdpau/presentation.c
@@ -231,7 +231,7 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue 
presentation_queue,
vscreen = pq->device->vscreen;
 
pipe_mutex_lock(pq->device->mutex);
-   if (vscreen->set_back_texture_from_output)
+   if (vscreen->set_back_texture_from_output && surf->send_to_X)
   vscreen->set_back_texture_from_output(vscreen, surf->surface->texture, 
clip_width, clip_height);
tex = vscreen->texture_from_drawable(vscreen, (void *)pq->drawable);
if (!tex) {
@@ -239,7 +239,7 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue 
presentation_queue,
   return VDP_STATUS_INVALID_HANDLE;
}
 
-   if (!vscreen->set_back_texture_from_output) {
+   if (!vscreen->set_back_texture_from_output || !surf->send_to_X) {
   dirty_area = vscreen->get_dirty_area(vscreen);
 
   memset(_templ, 0, sizeof(surf_templ));
@@ -289,7 +289,7 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue 
presentation_queue,
   framenum++;
}
 
-   if (!vscreen->set_back_texture_from_output) {
+   if (!vscreen->set_back_texture_from_output || !surf->send_to_X) {
   pipe_resource_reference(, NULL);
   pipe_surface_reference(_draw, NULL);
}
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h 
b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 490a0bd..8356608 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -415,6 +415,7 @@ typedef struct
struct pipe_fence_handle *fence;
struct vl_compositor_state cstate;
struct u_rect dirty_area;
+   bool send_to_X;
 } vlVdpOutputSurface;
 
 typedef struct

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


Mesa (master): st/vdpau: remove the delayed rendering hack(v1.1)

2017-01-17 Thread Christian König
Module: Mesa
Branch: master
Commit: 3a8f316e7b7f7dc5d913d117ec47e26587ce8177
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a8f316e7b7f7dc5d913d117ec47e26587ce8177

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Wed Jan 11 22:45:15 2017 +0530

st/vdpau: remove the delayed rendering hack(v1.1)

the hack was introduced to avoid an extra copying
but now with dri3 we don't need it anymore

v1.1: rebasing

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Acked-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/bitmap.c|  2 -
 src/gallium/state_trackers/vdpau/device.c| 50 -
 src/gallium/state_trackers/vdpau/mixer.c | 93 +++-
 src/gallium/state_trackers/vdpau/output.c|  9 ---
 src/gallium/state_trackers/vdpau/presentation.c  | 30 +++-
 src/gallium/state_trackers/vdpau/vdpau_private.h |  9 ---
 6 files changed, 52 insertions(+), 141 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/bitmap.c 
b/src/gallium/state_trackers/vdpau/bitmap.c
index fd67a98..d9ec60d 100644
--- a/src/gallium/state_trackers/vdpau/bitmap.c
+++ b/src/gallium/state_trackers/vdpau/bitmap.c
@@ -198,8 +198,6 @@ vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface,
 
pipe_mutex_lock(vlsurface->device->mutex);
 
-   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
-
dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
  PIPE_TRANSFER_WRITE, _box, *source_data,
diff --git a/src/gallium/state_trackers/vdpau/device.c 
b/src/gallium/state_trackers/vdpau/device.c
index 8bae064..4f4ffdf 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -327,53 +327,3 @@ vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view 
*templ, struct pipe_res
if (desc->swizzle[3] == PIPE_SWIZZLE_0)
   templ->swizzle_a = PIPE_SWIZZLE_1;
 }
-
-void
-vlVdpResolveDelayedRendering(vlVdpDevice *dev, struct pipe_surface *surface, 
struct u_rect *dirty_area)
-{
-   struct vl_compositor_state *cstate;
-   vlVdpOutputSurface *vlsurface;
-
-   assert(dev);
-
-   cstate = dev->delayed_rendering.cstate;
-   if (!cstate)
-  return;
-
-   vlsurface = vlGetDataHTAB(dev->delayed_rendering.surface);
-   if (!vlsurface)
-  return;
-
-   if (!surface) {
-  surface = vlsurface->surface;
-  dirty_area = >dirty_area;
-   }
-
-   vl_compositor_render(cstate, >compositor, surface, dirty_area, true);
-
-   dev->delayed_rendering.surface = VDP_INVALID_HANDLE;
-   dev->delayed_rendering.cstate = NULL;
-
-   /* test if we need to create a new sampler for the just filled texture */
-   if (surface->texture != vlsurface->sampler_view->texture) {
-  struct pipe_resource *res = surface->texture;
-  struct pipe_sampler_view sv_templ;
-
-  vlVdpDefaultSamplerViewTemplate(_templ, res);
-  pipe_sampler_view_reference(>sampler_view, NULL);
-  vlsurface->sampler_view = 
dev->context->create_sampler_view(dev->context, res, _templ);
-   }
-
-   return;
-}
-
-void
-vlVdpSave4DelayedRendering(vlVdpDevice *dev, VdpOutputSurface surface, struct 
vl_compositor_state *cstate)
-{
-   assert(dev);
-
-   vlVdpResolveDelayedRendering(dev, NULL, NULL);
-
-   dev->delayed_rendering.surface = surface;
-   dev->delayed_rendering.cstate = cstate;
-}
diff --git a/src/gallium/state_trackers/vdpau/mixer.c 
b/src/gallium/state_trackers/vdpau/mixer.c
index 1014174..37a6fcd 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -193,8 +193,6 @@ vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
 
pipe_mutex_lock(vmixer->device->mutex);
 
-   vlVdpResolveDelayedRendering(vmixer->device, NULL, NULL);
-
vlRemoveDataHTAB(mixer);
 
vl_compositor_cleanup_state(>cstate);
@@ -293,7 +291,6 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
}
 
pipe_mutex_lock(vmixer->device->mutex);
-   vlVdpResolveDelayedRendering(vmixer->device, NULL, NULL);
 
vl_compositor_clear_layers(>cstate);
 
@@ -403,64 +400,60 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
   ++layers;
}
 
-   if (!vmixer->noise_reduction.filter && !vmixer->sharpness.filter && 
!vmixer->bicubic.filter)
-  vlVdpSave4DelayedRendering(vmixer->device, destination_surface, 
>cstate);
-   else {
-  vl_compositor_render(>cstate, compositor, surface, _area, 
true);
-
-  if (vmixer->noise_reduction.filter) {
- if (!vmixer->sharpness.filter && !vmixer->bicubic.filter) {
-vl_median_filter_render(vmixer->noise_reduction.filter,
-sampler_view, dst->surface);
- } else {
-

Mesa (master): vl/dri3: use external texture as back buffers(v4)

2017-01-17 Thread Christian König
Module: Mesa
Branch: master
Commit: 0ef17d76bbbc9506d50138f1b4d79db8ef08ad6d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ef17d76bbbc9506d50138f1b4d79db8ef08ad6d

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Wed Jan 11 22:45:13 2017 +0530

vl/dri3: use external texture as back buffers(v4)

dri3 allows us to send handle of a texture directly to X
so this patch allows a state tracker to directly send its
texture to X to be used as back buffer and avoids extra
copying

v2: use clip width/height to display a portion of the surface
v3: remove redundant variables, fix wrapping, rename variables
handle vaapi path
v3.1: we need clip_width/height for every frame so we don't need
  to maintain it for each buffer instead use a global variable
v4: In case of single gpu we can cache the buffers as applications
use constant number of buffer and we can avoid calls to present
extension for every frame

Reviewed and Suggested-by: Leo Liu <leo@amd.com>
Acked-by: Christian König <christian.koe...@amd.com>
Tested-by: Andy Furniss <adf.li...@gmail.com>
Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>

---

 configure.ac  |   2 +-
 src/gallium/auxiliary/vl/vl_winsys.h  |   5 ++
 src/gallium/auxiliary/vl/vl_winsys_dri3.c | 126 ++
 3 files changed, 115 insertions(+), 18 deletions(-)

diff --git a/configure.ac b/configure.ac
index 459f3e8..3e2d79a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2081,7 +2081,7 @@ if test "x$enable_xvmc" = xyes -o \
 "x$enable_va" = xyes; then
 if test x"$enable_dri3" = xyes; then
 PKG_CHECK_MODULES([VL], [xcb-dri3 xcb-present xcb-sync xshmfence >= 
$XSHMFENCE_REQUIRED
- x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED])
+ xcb-xfixes x11-xcb xcb xcb-dri2 >= 
$XCBDRI2_REQUIRED])
 else
 PKG_CHECK_MODULES([VL], [x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED])
 fi
diff --git a/src/gallium/auxiliary/vl/vl_winsys.h 
b/src/gallium/auxiliary/vl/vl_winsys.h
index 26db9f2..e1f9b27 100644
--- a/src/gallium/auxiliary/vl/vl_winsys.h
+++ b/src/gallium/auxiliary/vl/vl_winsys.h
@@ -59,6 +59,11 @@ struct vl_screen
void *
(*get_private)(struct vl_screen *vscreen);
 
+   void
+   (*set_back_texture_from_output)(struct vl_screen *vscreen,
+   struct pipe_resource *buffer,
+   uint32_t width, uint32_t height);
+
struct pipe_screen *pscreen;
struct pipe_loader_device *dev;
 };
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 2929928..a810dea 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "loader.h"
 
@@ -71,9 +72,12 @@ struct vl_dri3_screen
xcb_special_event_t *special_event;
 
struct pipe_context *pipe;
+   struct pipe_resource *output_texture;
+   uint32_t clip_width, clip_height;
 
struct vl_dri3_buffer *back_buffers[BACK_BUFFER_NUM];
int cur_back;
+   int next_back;
 
struct u_rect dirty_areas[BACK_BUFFER_NUM];
 
@@ -105,7 +109,8 @@ dri3_free_back_buffer(struct vl_dri3_screen *scrn,
xcb_free_pixmap(scrn->conn, buffer->pixmap);
xcb_sync_destroy_fence(scrn->conn, buffer->sync_fence);
xshmfence_unmap_shm(buffer->shm_fence);
-   pipe_resource_reference(>texture, NULL);
+   if (!scrn->output_texture)
+  pipe_resource_reference(>texture, NULL);
if (buffer->linear_texture)
pipe_resource_reference(>linear_texture, NULL);
FREE(buffer);
@@ -236,29 +241,31 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
templ.format = PIPE_FORMAT_B8G8R8X8_UNORM;
templ.target = PIPE_TEXTURE_2D;
templ.last_level = 0;
-   templ.width0 = scrn->width;
-   templ.height0 = scrn->height;
+   templ.width0 = (scrn->output_texture) ?
+  scrn->output_texture->width0 : scrn->width;
+   templ.height0 = (scrn->output_texture) ?
+   scrn->output_texture->height0 : scrn->height;
templ.depth0 = 1;
templ.array_size = 1;
 
if (scrn->is_different_gpu) {
-  buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
-);
+  buffer->texture = (scrn->output_texture) ? scrn->output_texture :
+
scrn->base.pscreen->resource_create(scrn->base.pscreen, );
   if (!buffer->texture)
  goto unmap_shm;
 
   templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED |
 PIPE_BIND_LINEAR;
-  buffer->linear_texture = 
scrn->base.pscreen->resource_create(

Mesa (master): st/vdpau: use dri3 to directly send the buffer to X(v2)

2017-01-17 Thread Christian König
Module: Mesa
Branch: master
Commit: 15bfdea99c7b487d2c38d6dd7b88fb44810ef75a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=15bfdea99c7b487d2c38d6dd7b88fb44810ef75a

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Wed Jan 11 22:45:14 2017 +0530

st/vdpau: use dri3 to directly send the buffer to X(v2)

this avoids an extra copy which occurs in case of dri2

v1.1: fallback to dri2 if dri3 fails to initialize
v2: add PIPE_BIND_SCANOUT to output buffers as they will
be send to X server directly (Michel)

Suggested-by: Christian König <christian.koe...@amd.com>
Tested-by: Andy Furniss <adf.li...@gmail.com>
Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>

---

 src/gallium/state_trackers/vdpau/output.c   |  2 +-
 src/gallium/state_trackers/vdpau/presentation.c | 58 ++---
 2 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index d67ead8..8ddf2c1 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -82,7 +82,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
res_tmpl.depth0 = 1;
res_tmpl.array_size = 1;
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
-   PIPE_BIND_SHARED;
+   PIPE_BIND_SHARED | PIPE_BIND_SCANOUT;
res_tmpl.usage = PIPE_USAGE_DEFAULT;
 
pipe_mutex_lock(dev->mutex);
diff --git a/src/gallium/state_trackers/vdpau/presentation.c 
b/src/gallium/state_trackers/vdpau/presentation.c
index f35d73a..b2c8aea 100644
--- a/src/gallium/state_trackers/vdpau/presentation.c
+++ b/src/gallium/state_trackers/vdpau/presentation.c
@@ -231,43 +231,47 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue 
presentation_queue,
vscreen = pq->device->vscreen;
 
pipe_mutex_lock(pq->device->mutex);
+   if (vscreen->set_back_texture_from_output)
+  vscreen->set_back_texture_from_output(vscreen, surf->surface->texture, 
clip_width, clip_height);
tex = vscreen->texture_from_drawable(vscreen, (void *)pq->drawable);
if (!tex) {
   pipe_mutex_unlock(pq->device->mutex);
   return VDP_STATUS_INVALID_HANDLE;
}
 
-   dirty_area = vscreen->get_dirty_area(vscreen);
+   if (!vscreen->set_back_texture_from_output) {
+  dirty_area = vscreen->get_dirty_area(vscreen);
 
-   memset(_templ, 0, sizeof(surf_templ));
-   surf_templ.format = tex->format;
-   surf_draw = pipe->create_surface(pipe, tex, _templ);
+  memset(_templ, 0, sizeof(surf_templ));
+  surf_templ.format = tex->format;
+  surf_draw = pipe->create_surface(pipe, tex, _templ);
 
-   dst_clip.x0 = 0;
-   dst_clip.y0 = 0;
-   dst_clip.x1 = clip_width ? clip_width : surf_draw->width;
-   dst_clip.y1 = clip_height ? clip_height : surf_draw->height;
+  dst_clip.x0 = 0;
+  dst_clip.y0 = 0;
+  dst_clip.x1 = clip_width ? clip_width : surf_draw->width;
+  dst_clip.y1 = clip_height ? clip_height : surf_draw->height;
 
-   if (pq->device->delayed_rendering.surface == surface &&
-   dst_clip.x1 == surf_draw->width && dst_clip.y1 == surf_draw->height) {
+  if (pq->device->delayed_rendering.surface == surface &&
+  dst_clip.x1 == surf_draw->width && dst_clip.y1 == surf_draw->height) 
{
 
-  // TODO: we correctly support the clipping here, but not the pq 
background color in the clipped area
-  cstate = pq->device->delayed_rendering.cstate;
-  vl_compositor_set_dst_clip(cstate, _clip);
-  vlVdpResolveDelayedRendering(pq->device, surf_draw, dirty_area);
+ // TODO: we correctly support the clipping here, but not the pq 
background color in the clipped area
+ cstate = pq->device->delayed_rendering.cstate;
+ vl_compositor_set_dst_clip(cstate, _clip);
+ vlVdpResolveDelayedRendering(pq->device, surf_draw, dirty_area);
 
-   } else {
-  vlVdpResolveDelayedRendering(pq->device, NULL, NULL);
+  } else {
+ vlVdpResolveDelayedRendering(pq->device, NULL, NULL);
 
-  src_rect.x0 = 0;
-  src_rect.y0 = 0;
-  src_rect.x1 = surf_draw->width;
-  src_rect.y1 = surf_draw->height;
+ src_rect.x0 = 0;
+ src_rect.y0 = 0;
+ src_rect.x1 = surf_draw->width;
+ src_rect.y1 = surf_draw->height;
 
-  vl_compositor_clear_layers(cstate);
-  vl_compositor_set_rgba_layer(cstate, compositor, 0, surf->sampler_view, 
_rect, NULL, NULL);
-  vl_compositor_set_dst_clip(cstate, _clip);
-  vl_compositor_render(cstate, compositor, surf_draw, dirty_area, true);
+ vl_compositor_clear_layers(cstate);
+ vl_compositor_set_rgba_layer(cstate, compositor, 0, 
surf->sampler_view, _rect, NULL, NULL);
+ vl_compositor_set_dst_clip(cstate,

Mesa (master): st/va: delay calling begin_frame until we have all parameters

2017-01-16 Thread Christian König
Module: Mesa
Branch: master
Commit: 4b0e9babc673bc4dd834127086982e290b2a3a42
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b0e9babc673bc4dd834127086982e290b2a3a42

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Fri Jan 13 19:03:31 2017 +0530

st/va: delay calling begin_frame until we have all parameters

If begin_frame is called before setting intra_matrix and
non_intra_matrix it leads to segmentation faults when
vl_mpeg12_decoder.c is used.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92634
Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/picture.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index b5b9a83..dc7121c 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -178,9 +178,6 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext 
*context, vlVaBuffer *
 
   if (!context->decoder)
  return VA_STATUS_ERROR_ALLOCATION_FAILED;
-
-  context->decoder->begin_frame(context->decoder, context->target,
- >desc.base);
}
 
return vaStatus;
@@ -310,6 +307,9 @@ handleVASliceDataBufferType(vlVaContext *context, 
vlVaBuffer *buf)
buffers[num_buffers] = buf->data;
sizes[num_buffers] = buf->size;
++num_buffers;
+
+   context->decoder->begin_frame(context->decoder, context->target,
+  >desc.base);
context->decoder->decode_bitstream(context->decoder, context->target, 
>desc.base,
   num_buffers, (const void * const*)buffers, sizes);
 }

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


Mesa (master): st/va: flush pipeline after post processing

2017-01-13 Thread Christian König
Module: Mesa
Branch: master
Commit: 9b14a828db76dcc27302059ff5504170540c6e2f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b14a828db76dcc27302059ff5504170540c6e2f

Author: sguttula <suresh.gutt...@amd.com>
Date:   Thu Nov 10 00:59:53 2016 -0500

st/va: flush pipeline after post processing

This will flush the pipeline,which will allow to share dma-buf based
buffers.

Signed-off-by: Suresh Guttula <suresh.gutt...@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/postproc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/state_trackers/va/postproc.c 
b/src/gallium/state_trackers/va/postproc.c
index d06f016..01e240f 100644
--- a/src/gallium/state_trackers/va/postproc.c
+++ b/src/gallium/state_trackers/va/postproc.c
@@ -80,6 +80,7 @@ vlVaPostProcCompositor(vlVaDriver *drv, vlVaContext *context,
vl_compositor_set_layer_dst_area(>cstate, 0, _rect);
vl_compositor_render(>cstate, >compositor, surfaces[0], NULL, 
false);
 
+   drv->pipe->flush(drv->pipe, NULL, 0);
return VA_STATUS_SUCCESS;
 }
 

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


Mesa (master): st/va: fix incorrect argument in vl_compositor_cleanup

2017-01-05 Thread Christian König
Module: Mesa
Branch: master
Commit: ee4b4791abe8236caaf70b7cb0170f1dfd625587
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee4b4791abe8236caaf70b7cb0170f1dfd625587

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Thu Jan  5 20:18:41 2017 +0530

st/va: fix incorrect argument in vl_compositor_cleanup

This fixes the mistake introduced in commit
b6737a8bcd03ea68952799144c0c6e6e6679bee9

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index 884b794..357c9be 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -184,7 +184,7 @@ error_csc_matrix:
vl_compositor_cleanup_state(>cstate);
 
 error_compositor_state:
-   vl_compositor_cleanup(>cstate);
+   vl_compositor_cleanup(>compositor);
 
 error_compositor:
handle_table_destroy(drv->htab);

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


Mesa (master): vl/zscan: fix "Fix trivial sign compare warnings"

2017-01-03 Thread Christian König
Module: Mesa
Branch: master
Commit: ac57bcda1e0e6dcfa81e24468d5b682686120649
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac57bcda1e0e6dcfa81e24468d5b682686120649

Author: Christian König <christian.koe...@amd.com>
Date:   Wed Dec 14 15:03:35 2016 +0100

vl/zscan: fix "Fix trivial sign compare warnings"

The variable actually needs to be signed, otherwise converting it to a
float doesn't work as expected.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=98914
Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Cc: "13.0" <mesa-sta...@lists.freedesktop.org>
Fixes: 1fb4179f927 ("vl: Fix trivial sign compare warnings")

---

 src/gallium/auxiliary/vl/vl_zscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/vl/vl_zscan.c 
b/src/gallium/auxiliary/vl/vl_zscan.c
index ef05af4..24d6452 100644
--- a/src/gallium/auxiliary/vl/vl_zscan.c
+++ b/src/gallium/auxiliary/vl/vl_zscan.c
@@ -152,7 +152,7 @@ create_vert_shader(struct vl_zscan *zscan)
for (i = 0; i < zscan->num_channels; ++i) {
   ureg_ADD(shader, ureg_writemask(tmp, TGSI_WRITEMASK_X), 
ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y),
ureg_imm1f(shader, 1.0f / (zscan->blocks_per_line * 
VL_BLOCK_WIDTH)
-* (i - (signed)zscan->num_channels / 2)));
+* ((signed)i - (signed)zscan->num_channels / 2)));
 
   ureg_MAD(shader, ureg_writemask(o_vtex[i], TGSI_WRITEMASK_X), vrect,
ureg_imm1f(shader, 1.0f / zscan->blocks_per_line), 
ureg_src(tmp));

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


Mesa (master): vl/compositor: implement error handling

2017-01-03 Thread Christian König
Module: Mesa
Branch: master
Commit: cee5af93ee5ea9e3c4dd19047952fec6bcfed2b6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cee5af93ee5ea9e3c4dd19047952fec6bcfed2b6

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Tue Jan  3 16:35:45 2017 +0530

vl/compositor: implement error handling

pipe_buffer_map and pipe_buffer_create may return NULL

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/auxiliary/vl/vl_compositor.c | 13 +++--
 src/gallium/auxiliary/vl/vl_compositor.h |  2 +-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_compositor.c 
b/src/gallium/auxiliary/vl/vl_compositor.c
index 03a0a64..297c3ab 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -919,7 +919,7 @@ vl_compositor_cleanup(struct vl_compositor *c)
cleanup_pipe_state(c);
 }
 
-void
+bool
 vl_compositor_set_csc_matrix(struct vl_compositor_state *s,
  vl_csc_matrix const *matrix,
  float luma_min, float luma_max)
@@ -932,6 +932,9 @@ vl_compositor_set_csc_matrix(struct vl_compositor_state *s,
PIPE_TRANSFER_WRITE | 
PIPE_TRANSFER_DISCARD_RANGE,
_transfer);
 
+   if (!ptr)
+  return false;
+
memcpy(ptr, matrix, sizeof(vl_csc_matrix));
 
ptr += sizeof(vl_csc_matrix)/sizeof(float);
@@ -939,6 +942,8 @@ vl_compositor_set_csc_matrix(struct vl_compositor_state *s,
ptr[1] = luma_max;
 
pipe_buffer_unmap(s->pipe, buf_transfer);
+
+   return true;
 }
 
 void
@@ -1246,10 +1251,14 @@ vl_compositor_init_state(struct vl_compositor_state *s, 
struct pipe_context *pip
   sizeof(csc_matrix) + 2*sizeof(float)
);
 
+   if (!s->csc_matrix)
+  return false;
+
vl_compositor_clear_layers(s);
 
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, _matrix);
-   vl_compositor_set_csc_matrix(s, (const vl_csc_matrix *)_matrix, 1.0f, 
0.0f);
+   if (!vl_compositor_set_csc_matrix(s, (const vl_csc_matrix *)_matrix, 
1.0f, 0.0f))
+  return false;
 
return true;
 }
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h 
b/src/gallium/auxiliary/vl/vl_compositor.h
index ceab5e0..5460619 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/src/gallium/auxiliary/vl/vl_compositor.h
@@ -142,7 +142,7 @@ vl_compositor_init_state(struct vl_compositor_state *state, 
struct pipe_context
 /**
  * set yuv -> rgba conversion matrix
  */
-void
+bool
 vl_compositor_set_csc_matrix(struct vl_compositor_state *settings,
  const vl_csc_matrix *matrix,
  float luma_min, float luma_max);

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


Mesa (master): st/va: error handling

2017-01-03 Thread Christian König
Module: Mesa
Branch: master
Commit: b6737a8bcd03ea68952799144c0c6e6e6679bee9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b6737a8bcd03ea68952799144c0c6e6e6679bee9

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Tue Jan  3 16:35:47 2017 +0530

st/va: error handling

handle the cases when vl_compositor_set_csc_matrix(),
vl_compositor_init_state() and vl_compositor_init() fail

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/context.c | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index 65ba7db..884b794 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -155,11 +155,14 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
if (!drv->htab)
   goto error_htab;
 
-   vl_compositor_init(>compositor, drv->pipe);
-   vl_compositor_init_state(>cstate, drv->pipe);
+   if (!vl_compositor_init(>compositor, drv->pipe))
+  goto error_compositor;
+   if (!vl_compositor_init_state(>cstate, drv->pipe))
+  goto error_compositor_state;
 
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, >csc);
-   vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc, 1.0f, 0.0f);
+   if (!vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc, 1.0f, 0.0f))
+  goto error_csc_matrix;
pipe_mutex_init(drv->mutex);
 
ctx->pDriverData = (void *)drv;
@@ -177,6 +180,15 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
 
return VA_STATUS_SUCCESS;
 
+error_csc_matrix:
+   vl_compositor_cleanup_state(>cstate);
+
+error_compositor_state:
+   vl_compositor_cleanup(>cstate);
+
+error_compositor:
+   handle_table_destroy(drv->htab);
+
 error_htab:
drv->pipe->destroy(drv->pipe);
 

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


Mesa (master): st/vdpau: error handling

2017-01-03 Thread Christian König
Module: Mesa
Branch: master
Commit: 29aad4e8bd72fc022ade03f49bc8aa25419a3773
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=29aad4e8bd72fc022ade03f49bc8aa25419a3773

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Tue Jan  3 16:35:46 2017 +0530

st/vdpau: error handling

handle the cases when vl_compositor_set_csc_matrix(),
vl_compositor_init_state() and vl_compositor_init() fail

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/device.c |  8 +-
 src/gallium/state_trackers/vdpau/mixer.c  | 43 +++
 src/gallium/state_trackers/vdpau/output.c | 14 +++---
 3 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/device.c 
b/src/gallium/state_trackers/vdpau/device.c
index 81b7582..8bae064 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -128,13 +128,19 @@ vdp_imp_device_create_x11(Display *display, int screen, 
VdpDevice *device,
   goto no_handle;
}
 
-   vl_compositor_init(>compositor, dev->context);
+   if (!vl_compositor_init(>compositor, dev->context)) {
+   ret = VDP_STATUS_ERROR;
+   goto no_compositor;
+   }
+
pipe_mutex_init(dev->mutex);
 
*get_proc_address = 
 
return VDP_STATUS_OK;
 
+no_compositor:
+   vlRemoveDataHTAB(*device);
 no_handle:
pipe_sampler_view_reference(>dummy_sv, NULL);
 no_resource:
diff --git a/src/gallium/state_trackers/vdpau/mixer.c 
b/src/gallium/state_trackers/vdpau/mixer.c
index aca43c1..1014174 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -65,11 +65,18 @@ vlVdpVideoMixerCreate(VdpDevice device,
 
pipe_mutex_lock(dev->mutex);
 
-   vl_compositor_init_state(>cstate, dev->context);
+   if (!vl_compositor_init_state(>cstate, dev->context)) {
+  ret = VDP_STATUS_ERROR;
+  goto no_compositor_state;
+   }
 
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, >csc);
-   if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
-  vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc, 1.0f, 0.0f);
+   if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE)) {
+  if (!vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc, 1.0f, 0.0f)) {
+ ret = VDP_STATUS_ERROR;
+ goto err_csc_matrix;
+  }
+   }
 
*mixer = vlAddDataHTAB(vmixer);
if (*mixer == 0) {
@@ -163,7 +170,9 @@ no_params:
vlRemoveDataHTAB(*mixer);
 
 no_handle:
+err_csc_matrix:
vl_compositor_cleanup_state(>cstate);
+no_compositor_state:
pipe_mutex_unlock(dev->mutex);
DeviceReference(>device, NULL);
FREE(vmixer);
@@ -690,8 +699,11 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
   case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
  vmixer->luma_key.enabled = feature_enables[i];
  if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
-vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc,
- vmixer->luma_key.luma_min, 
vmixer->luma_key.luma_max);
+if (!vl_compositor_set_csc_matrix(>cstate, (const 
vl_csc_matrix *)>csc,
+vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) 
{
+   pipe_mutex_unlock(vmixer->device->mutex);
+   return VDP_STATUS_ERROR;
+}
  break;
 
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
@@ -810,8 +822,11 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
  else
 memcpy(vmixer->csc, vdp_csc, sizeof(vl_csc_matrix));
  if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
-vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc,
- vmixer->luma_key.luma_min, 
vmixer->luma_key.luma_max);
+if (!vl_compositor_set_csc_matrix(>cstate, (const 
vl_csc_matrix *)>csc,
+ vmixer->luma_key.luma_min, 
vmixer->luma_key.luma_max)) {
+   ret = VDP_STATUS_ERROR;
+   goto fail;
+}
  break;
 
   case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
@@ -834,8 +849,11 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
  }
  vmixer->luma_key.luma_min = val;
  if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
-vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc,
- vmixer->luma_key.luma_min, 
vmixer->luma_key.luma_max);
+if (!vl_compositor_set_csc_matrix(>cstate, (const 
vl_csc_matrix *)>csc,
+vmixer-&

Mesa (master): st/vdpau: fix compiler warning in vlVdpVideoMixerRender

2016-12-05 Thread Christian König
Module: Mesa
Branch: master
Commit: 7b811c362a0b0cfb9a8c503cacf9be57d1ed2c7a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b811c362a0b0cfb9a8c503cacf9be57d1ed2c7a

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Mon Dec  5 11:13:17 2016 +0530

st/vdpau: fix compiler warning in vlVdpVideoMixerRender

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/mixer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/vdpau/mixer.c 
b/src/gallium/state_trackers/vdpau/mixer.c
index c205427..aca43c1 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -242,7 +242,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
struct pipe_video_buffer *video_buffer;
struct pipe_sampler_view *sampler_view, sv_templ;
struct pipe_surface *surface, surf_templ;
-   struct pipe_context *pipe;
+   struct pipe_context *pipe = NULL;
struct pipe_resource res_tmpl, *res;
 
vlVdpVideoMixer *vmixer;

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


Mesa (master): st/va: Return surface formats depending on config chroma format

2016-10-14 Thread Christian König
Module: Mesa
Branch: master
Commit: e0604eed9f0cd6e65dde0e2d96c031b8db2c4fe5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e0604eed9f0cd6e65dde0e2d96c031b8db2c4fe5

Author: Mark Thompson <s...@jkqxz.net>
Date:   Wed Oct 12 23:53:01 2016 +0100

st/va: Return surface formats depending on config chroma format

This makes the supported format actually match the configuration, and
allows the user to observe that NV12 is supported for video processing
where previously they couldn't (though it did always work if they
blindly tried to use it anyway).

Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/surface.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 173e7d9..5e92980 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -419,11 +419,19 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, 
VAConfigID config_id,
/* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN
 * only for VAEntrypointVideoProc. */
if (config->profile == PIPE_VIDEO_PROFILE_UNKNOWN) {
-  for (j = 0; j < ARRAY_SIZE(vpp_surface_formats); ++j) {
+  if (config->rt_format == VA_RT_FORMAT_RGB32) {
+ for (j = 0; j < ARRAY_SIZE(vpp_surface_formats); ++j) {
+attribs[i].type = VASurfaceAttribPixelFormat;
+attribs[i].value.type = VAGenericValueTypeInteger;
+attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | 
VA_SURFACE_ATTRIB_SETTABLE;
+attribs[i].value.value.i = 
PipeFormatToVaFourcc(vpp_surface_formats[j]);
+i++;
+ }
+  } else if (config->rt_format == VA_RT_FORMAT_YUV420) {
  attribs[i].type = VASurfaceAttribPixelFormat;
  attribs[i].value.type = VAGenericValueTypeInteger;
  attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | 
VA_SURFACE_ATTRIB_SETTABLE;
- attribs[i].value.value.i = 
PipeFormatToVaFourcc(vpp_surface_formats[j]);
+ attribs[i].value.value.i = VA_FOURCC_NV12;
  i++;
   }
} else {

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


Mesa (master): st/va: Save surface chroma format in config

2016-10-14 Thread Christian König
Module: Mesa
Branch: master
Commit: e7c7ef36250d17dfcde3504aeafe7de7088479ba
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7c7ef36250d17dfcde3504aeafe7de7088479ba

Author: Mark Thompson <s...@jkqxz.net>
Date:   Wed Oct 12 23:52:30 2016 +0100

st/va: Save surface chroma format in config

Both YUV420 and RGB32 configurations are supported, so we need to be
able to distinguish which is being used.

Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/config.c | 20 +++-
 src/gallium/state_trackers/va/va_private.h |  1 +
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index 72f68ba..2f96eb6 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -185,6 +185,16 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) {
   config->entrypoint = VAEntrypointVideoProc;
   config->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
+  for (int i = 0; i < num_attribs; i++) {
+ if (attrib_list[i].type == VAConfigAttribRTFormat) {
+if (attrib_list[i].value & (VA_RT_FORMAT_YUV420 | 
VA_RT_FORMAT_RGB32)) {
+   config->rt_format = attrib_list[i].value;
+} else {
+   FREE(config);
+   return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
+}
+ }
+  }
   pipe_mutex_lock(drv->mutex);
   *config_id = handle_table_add(drv->htab, config);
   pipe_mutex_unlock(drv->mutex);
@@ -236,6 +246,14 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
  else
 config->rc = PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE;
   }
+  if (attrib_list[i].type == VAConfigAttribRTFormat) {
+ if (attrib_list[i].value == VA_RT_FORMAT_YUV420) {
+config->rt_format = attrib_list[i].value;
+ } else {
+FREE(config);
+return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
+ }
+  }
}
 
pipe_mutex_lock(drv->mutex);
@@ -306,7 +324,7 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID 
config_id, VAProfile
 
*num_attribs = 1;
attrib_list[0].type = VAConfigAttribRTFormat;
-   attrib_list[0].value = VA_RT_FORMAT_YUV420;
+   attrib_list[0].value = config->rt_format;
 
return VA_STATUS_SUCCESS;
 }
diff --git a/src/gallium/state_trackers/va/va_private.h 
b/src/gallium/state_trackers/va/va_private.h
index e9ccdbf..7562e14 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -250,6 +250,7 @@ typedef struct {
enum pipe_video_profile profile;
enum pipe_video_entrypoint entrypoint;
enum pipe_h264_enc_rate_control_method rc;
+   unsigned int rt_format;
 } vlVaConfig;
 
 typedef struct {

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


Mesa (master): st/va: Return more useful config attributes

2016-10-14 Thread Christian König
Module: Mesa
Branch: master
Commit: 8a931c83bafbf768ffa520af32740df4c5a765e9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a931c83bafbf768ffa520af32740df4c5a765e9

Author: Mark Thompson <s...@jkqxz.net>
Date:   Wed Oct 12 23:52:01 2016 +0100

st/va: Return more useful config attributes

The encoder attributes are needed for a user of the encoder to be
able to configure it sensibly without internal knowledge.

Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/config.c | 47 +++---
 1 file changed, 38 insertions(+), 9 deletions(-)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index 4052316..72f68ba 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -115,16 +115,45 @@ vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile 
profile, VAEntrypoint en
 
for (i = 0; i < num_attribs; ++i) {
   unsigned int value;
-  switch (attrib_list[i].type) {
-  case VAConfigAttribRTFormat:
- value = VA_RT_FORMAT_YUV420;
- break;
-  case VAConfigAttribRateControl:
- value = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR;
- break;
-  default:
+  if (entrypoint == VAEntrypointVLD) {
+ switch (attrib_list[i].type) {
+ case VAConfigAttribRTFormat:
+value = VA_RT_FORMAT_YUV420;
+break;
+ default:
+value = VA_ATTRIB_NOT_SUPPORTED;
+break;
+ }
+  } else if (entrypoint == VAEntrypointEncSlice) {
+ switch (attrib_list[i].type) {
+ case VAConfigAttribRTFormat:
+value = VA_RT_FORMAT_YUV420;
+break;
+ case VAConfigAttribRateControl:
+value = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR;
+break;
+ case VAConfigAttribEncPackedHeaders:
+value = 0;
+break;
+ case VAConfigAttribEncMaxRefFrames:
+value = 1;
+break;
+ default:
+value = VA_ATTRIB_NOT_SUPPORTED;
+break;
+ }
+  } else if (entrypoint == VAEntrypointVideoProc) {
+ switch (attrib_list[i].type) {
+ case VAConfigAttribRTFormat:
+value = (VA_RT_FORMAT_YUV420 |
+ VA_RT_FORMAT_RGB32);
+break;
+ default:
+value = VA_ATTRIB_NOT_SUPPORTED;
+break;
+ }
+  } else {
  value = VA_ATTRIB_NOT_SUPPORTED;
- break;
   }
   attrib_list[i].value = value;
}

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


Mesa (master): st/va: Baseline profile is not supported

2016-10-14 Thread Christian König
Module: Mesa
Branch: master
Commit: 1edaa33135feffe1082bf491e098224121615b08
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1edaa33135feffe1082bf491e098224121615b08

Author: Mark Thompson <s...@jkqxz.net>
Date:   Wed Oct 12 23:53:35 2016 +0100

st/va: Baseline profile is not supported

Constrained baseline profile is supported, so use that instead.  This
matches what the encoder already does (constraint_set1_flag is always
set in the output bitstream).

Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/va_private.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/va/va_private.h 
b/src/gallium/state_trackers/va/va_private.h
index 7562e14..c9a6a41 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -141,7 +141,7 @@ PipeToProfile(enum pipe_video_profile profile)
case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
   return VAProfileVC1Advanced;
case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
-  return VAProfileH264Baseline;
+  return VAProfileH264ConstrainedBaseline;
case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
   return VAProfileH264Main;
case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
@@ -183,7 +183,7 @@ ProfileToPipe(VAProfile profile)
   return PIPE_VIDEO_PROFILE_VC1_MAIN;
case VAProfileVC1Advanced:
   return PIPE_VIDEO_PROFILE_VC1_ADVANCED;
-   case VAProfileH264Baseline:
+   case VAProfileH264ConstrainedBaseline:
   return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
case VAProfileH264Main:
   return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;

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


Mesa (master): st/va: Fix H.264 PicOrderCnt value

2016-10-14 Thread Christian König
Module: Mesa
Branch: master
Commit: 0b241b7717b688c75c3d5d1571f195a6d2fc1d63
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b241b7717b688c75c3d5d1571f195a6d2fc1d63

Author: Mark Thompson <s...@jkqxz.net>
Date:   Wed Oct 12 23:54:03 2016 +0100

st/va: Fix H.264 PicOrderCnt value

TopFieldPicOrderCnt is exactly the PicOrderCnt value for a frame - see
H.264 section 8.2.1.

Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/picture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 399667f..66e6e0d 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -390,7 +390,7 @@ handleVAEncPictureParameterBufferType(vlVaDriver *drv, 
vlVaContext *context, vlV
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->CurrPic.TopFieldOrderCnt / 2;
+   context->desc.h264enc.pic_order_cnt = h264->CurrPic.TopFieldOrderCnt;
if (context->desc.h264enc.is_idr)
   context->desc.h264enc.i_remain = 1;
else

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


Mesa (master): st/va: Fix vaSyncSurface with no outstanding operation

2016-09-27 Thread Christian König
Module: Mesa
Branch: master
Commit: a543f231d712dbdfd309ff589766179c5cb32b20
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a543f231d712dbdfd309ff589766179c5cb32b20

Author: Mark Thompson <s...@jkqxz.net>
Date:   Mon Sep 26 23:22:31 2016 +0100

st/va: Fix vaSyncSurface with no outstanding operation

Fixes crash if the application doesn't do what the state tracker expects.

Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/surface.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 115db43..173e7d9 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -111,6 +111,12 @@ vlVaSyncSurface(VADriverContextP ctx, VASurfaceID 
render_target)
   return VA_STATUS_ERROR_INVALID_SURFACE;
}
 
+   if (!surf->feedback) {
+  // No outstanding operation: nothing to do.
+  pipe_mutex_unlock(drv->mutex);
+  return VA_STATUS_SUCCESS;
+   }
+
context = handle_table_get(drv->htab, surf->ctx);
if (!context) {
   pipe_mutex_unlock(drv->mutex);
@@ -126,6 +132,7 @@ vlVaSyncSurface(VADriverContextP ctx, VASurfaceID 
render_target)
   if (frame_diff < 2)
  context->decoder->flush(context->decoder);
   context->decoder->get_feedback(context->decoder, surf->feedback, 
&(surf->coded_buf->coded_size));
+  surf->feedback = NULL;
}
pipe_mutex_unlock(drv->mutex);
return VA_STATUS_SUCCESS;

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


Mesa (master): st/va Avoid VBR bitrate calculation overflow v2

2016-09-27 Thread Christian König
Module: Mesa
Branch: master
Commit: a5993022275c20061ac025d9adc26c5f9d02afee
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a5993022275c20061ac025d9adc26c5f9d02afee

Author: Andy Furniss <adf.li...@gmail.com>
Date:   Mon Sep 26 10:44:35 2016 +0100

st/va Avoid VBR bitrate calculation overflow v2

VBR bitrate calc needs 64 bits at high rates.

v2: use float.

Signed-off-by: Andy Furniss <adf.li...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>
Cc: mesa-sta...@lists.freedesktop.org

---

 src/gallium/state_trackers/va/picture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 7f3d96d..399667f 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -322,7 +322,7 @@ handleVAEncMiscParameterTypeRateControl(vlVaContext 
*context, VAEncMiscParameter
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 / 100;
+  context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second * 
(rc->target_percentage / 100.0);
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);

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


Mesa (master): vl/dri3: handle the case of different GPU(v4.2)

2016-09-20 Thread Christian König
Module: Mesa
Branch: master
Commit: 853e80f5a09f85477167aac2789a91a2755e23f0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=853e80f5a09f85477167aac2789a91a2755e23f0

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Tue Sep 20 10:40:10 2016 +0530

vl/dri3: handle the case of different GPU(v4.2)

In case of prime when rendering is done on GPU other then the
server GPU, use a seprate linear buffer for each back buffer
which will be displayed using present extension.

v2: Use a seprate linear buffer for each back buffer (Michel)
v3: Change variable names and fix coding style (Leo and Emil)
v4: Use PIPE_BIND_SAMPLER_VIEW for back buffer in case when
a seprate linear buffer is used (Michel)
v4.1: remove empty line
v4.2: destroy the context and handle the case when
  create_context fails (Emil)

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Leo Liu <leo@amd.com>
Acked-by: Michel Dänzer <michel.daen...@amd.com>
Acked-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/auxiliary/vl/vl_winsys_dri3.c | 66 +--
 1 file changed, 53 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 3d596a6..191a64b 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -49,6 +49,7 @@
 struct vl_dri3_buffer
 {
struct pipe_resource *texture;
+   struct pipe_resource *linear_texture;
 
uint32_t pixmap;
uint32_t sync_fence;
@@ -69,6 +70,8 @@ struct vl_dri3_screen
xcb_present_event_t eid;
xcb_special_event_t *special_event;
 
+   struct pipe_context *pipe;
+
struct vl_dri3_buffer *back_buffers[BACK_BUFFER_NUM];
int cur_back;
 
@@ -82,6 +85,7 @@ struct vl_dri3_screen
int64_t last_ust, ns_frame, last_msc, next_msc;
 
bool flushed;
+   bool is_different_gpu;
 };
 
 static void
@@ -102,6 +106,8 @@ dri3_free_back_buffer(struct vl_dri3_screen *scrn,
xcb_sync_destroy_fence(scrn->conn, buffer->sync_fence);
xshmfence_unmap_shm(buffer->shm_fence);
pipe_resource_reference(>texture, NULL);
+   if (buffer->linear_texture)
+   pipe_resource_reference(>linear_texture, NULL);
FREE(buffer);
 }
 
@@ -209,7 +215,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
xcb_sync_fence_t sync_fence;
struct xshmfence *shm_fence;
int buffer_fd, fence_fd;
-   struct pipe_resource templ;
+   struct pipe_resource templ, *pixmap_buffer_texture;
struct winsys_handle whandle;
unsigned usage;
 
@@ -226,8 +232,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
   goto close_fd;
 
memset(, 0, sizeof(templ));
-   templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW |
-PIPE_BIND_SCANOUT | PIPE_BIND_SHARED;
+   templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
templ.format = PIPE_FORMAT_B8G8R8X8_UNORM;
templ.target = PIPE_TEXTURE_2D;
templ.last_level = 0;
@@ -235,16 +240,34 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
templ.height0 = scrn->height;
templ.depth0 = 1;
templ.array_size = 1;
-   buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
- );
-   if (!buffer->texture)
-  goto unmap_shm;
 
+   if (scrn->is_different_gpu) {
+  buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
+);
+  if (!buffer->texture)
+ goto unmap_shm;
+
+  templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED |
+PIPE_BIND_LINEAR;
+  buffer->linear_texture = 
scrn->base.pscreen->resource_create(scrn->base.pscreen,
+  );
+  pixmap_buffer_texture = buffer->linear_texture;
+
+  if (!buffer->linear_texture)
+ goto no_linear_texture;
+   } else {
+  templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED;
+  buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
+);
+  if (!buffer->texture)
+ goto unmap_shm;
+  pixmap_buffer_texture = buffer->texture;
+   }
memset(, 0, sizeof(whandle));
whandle.type= DRM_API_HANDLE_TYPE_FD;
usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL,
-   buffer->texture, ,
+   pixmap_buffer_texture, ,
usage);
buffer_fd = whandle.handle;
buffer->pitch = whandle.stride;
@@ -271,6 +294,8 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
 
retu

Mesa (master): st/va: flush the context before calling flush_frontbuffer( v2)

2016-09-20 Thread Christian König
Module: Mesa
Branch: master
Commit: 0301858a316af7d831655778cf69bc49b12ee6ac
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0301858a316af7d831655778cf69bc49b12ee6ac

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Tue Sep 20 10:40:12 2016 +0530

st/va: flush the context before calling flush_frontbuffer(v2)

so that the texture is rendered to back buffer before calling
flush_frontbuffer and can be copied to a different buffer in
the function

v2: change comment style

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Michel Dänzer <michel.daen...@amd.com>
Acked-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/surface.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 00df69d..115db43 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -321,10 +321,14 @@ vlVaPutSurface(VADriverContextP ctx, VASurfaceID 
surface_id, void* draw, short s
   return status;
}
 
+   /* flush before calling flush_frontbuffer so that rendering is flushed
+* to back buffer so the texture can be copied in flush_frontbuffer
+*/
+   drv->pipe->flush(drv->pipe, NULL, 0);
+
screen->flush_frontbuffer(screen, tex, 0, 0,
  vscreen->get_private(vscreen), NULL);
 
-   drv->pipe->flush(drv->pipe, NULL, 0);
 
pipe_resource_reference(, NULL);
pipe_surface_reference(_draw, NULL);

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


Mesa (master): st/vdpau: flush the context before calling flush_frontbuffer

2016-09-20 Thread Christian König
Module: Mesa
Branch: master
Commit: e4cc2276c1fce9bce81834c348c3fc7e97ed6321
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e4cc2276c1fce9bce81834c348c3fc7e97ed6321

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Tue Sep 20 10:40:11 2016 +0530

st/vdpau: flush the context before calling flush_frontbuffer

so that the texture is rendered to back buffer before calling
flush_frontbuffer and can be copied to a different buffer in
the function

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Michel Dänzer <michel.daen...@amd.com>
Acked-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/presentation.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/presentation.c 
b/src/gallium/state_trackers/vdpau/presentation.c
index 2862eaf..f35d73a 100644
--- a/src/gallium/state_trackers/vdpau/presentation.c
+++ b/src/gallium/state_trackers/vdpau/presentation.c
@@ -271,11 +271,14 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue 
presentation_queue,
}
 
vscreen->set_next_timestamp(vscreen, earliest_presentation_time);
-   pipe->screen->flush_frontbuffer(pipe->screen, tex, 0, 0,
-   vscreen->get_private(vscreen), NULL);
 
+   // flush before calling flush_frontbuffer so that rendering is flushed
+   //  to back buffer so the texture can be copied in flush_frontbuffer
pipe->screen->fence_reference(pipe->screen, >fence, NULL);
pipe->flush(pipe, >fence, 0);
+   pipe->screen->flush_frontbuffer(pipe->screen, tex, 0, 0,
+   vscreen->get_private(vscreen), NULL);
+
pq->last_surf = surf;
 
if (dump_window == -1) {

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


Mesa (master): st/vdpau: fix argument type to vlVdpOutputSurfaceDMABuf

2016-09-20 Thread Christian König
Module: Mesa
Branch: master
Commit: 40d787ab05784bf2cc1443805d7fde56c68ba025
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=40d787ab05784bf2cc1443805d7fde56c68ba025

Author: Ilia Mirkin <imir...@alum.mit.edu>
Date:   Wed Sep 14 19:16:43 2016 -0400

st/vdpau: fix argument type to vlVdpOutputSurfaceDMABuf

Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/include/state_tracker/vdpau_dmabuf.h | 2 +-
 src/gallium/state_trackers/vdpau/output.c| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/include/state_tracker/vdpau_dmabuf.h 
b/src/gallium/include/state_tracker/vdpau_dmabuf.h
index 886c344..f838c92 100644
--- a/src/gallium/include/state_tracker/vdpau_dmabuf.h
+++ b/src/gallium/include/state_tracker/vdpau_dmabuf.h
@@ -87,7 +87,7 @@ typedef VdpStatus VdpVideoSurfaceDMABuf(
 );
 
 typedef VdpStatus VdpOutputSurfaceDMABuf(
-   VdpVideoSurface   surface,
+   VdpOutputSurface  surface,
struct VdpSurfaceDMABufDesc * result
 );
 
diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index 85751ea..f4d62a3 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -773,7 +773,7 @@ struct pipe_resource 
*vlVdpOutputSurfaceGallium(VdpOutputSurface surface)
return vlsurface->surface->texture;
 }
 
-VdpStatus vlVdpOutputSurfaceDMABuf(VdpVideoSurface surface,
+VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface,
struct VdpSurfaceDMABufDesc *result)
 {
vlVdpOutputSurface *vlsurface;

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


Mesa (master): st/vdpau: Revert " change the order in which filters are applied(v3)"

2016-08-29 Thread Christian König
Module: Mesa
Branch: master
Commit: 77e4424106290208ebf33eb021766c50741c55e0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=77e4424106290208ebf33eb021766c50741c55e0

Author: Christian König <christian.koe...@amd.com>
Date:   Fri Aug 26 09:56:18 2016 +0200

st/vdpau: Revert "change the order in which filters are applied(v3)"

This reverts commit 09dff7ae2e179d5a3490481762c6bd3d50430c9f.

Turned out this can cause some artifacts in the output. Let's revert
it for now until we have sorted out all issues.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Nayan Deshmukh <nayan26deshm...@gmail.com>

---

 src/gallium/state_trackers/vdpau/mixer.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/mixer.c 
b/src/gallium/state_trackers/vdpau/mixer.c
index 56b667d..cb0ef03 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -240,8 +240,8 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
struct u_rect rect, clip, *prect, dirty_area;
unsigned i, layer = 0;
struct pipe_video_buffer *video_buffer;
-   struct pipe_sampler_view *sampler_view, **sampler_views;
-   struct pipe_surface *surface, **surfaces;
+   struct pipe_sampler_view *sampler_view;
+   struct pipe_surface *surface;
 
vlVdpVideoMixer *vmixer;
vlVdpSurface *surf;
@@ -325,22 +325,6 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
   }
}
 
-   surfaces = video_buffer->get_surfaces(video_buffer);
-   sampler_views = video_buffer->get_sampler_view_planes(video_buffer);
-
-   for(i = 0; i < VL_MAX_SURFACES; ++i) {
-  if(sampler_views[i] != NULL && surfaces[i] != NULL) {
- if (vmixer->noise_reduction.filter)
-vl_median_filter_render(vmixer->noise_reduction.filter,
-sampler_views[i], surfaces[i]);
-
- if (vmixer->sharpness.filter)
-vl_matrix_filter_render(vmixer->sharpness.filter,
-sampler_views[i], surfaces[i]);
-
-  }
-   }
-
prect = RectToPipe(video_source_rect, );
if (!prect) {
   rect.x0 = 0;
@@ -410,6 +394,14 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
else {
   vl_compositor_render(>cstate, compositor, surface, _area, 
true);
 
+  if (vmixer->noise_reduction.filter)
+ vl_median_filter_render(vmixer->noise_reduction.filter,
+ sampler_view, surface);
+
+  if (vmixer->sharpness.filter)
+ vl_matrix_filter_render(vmixer->sharpness.filter,
+ sampler_view, surface);
+
   if (vmixer->bicubic.filter)
  vl_bicubic_filter_render(vmixer->bicubic.filter,
  sampler_view, dst->surface,

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


Mesa (master): st/vdpau: use temporary buffers while applying filters

2016-08-29 Thread Christian König
Module: Mesa
Branch: master
Commit: 5f0ea3db16706968278da99511e5b53e190d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f0ea3db16706968278da99511e5b53e190d

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Fri Aug 26 15:41:11 2016 +0530

st/vdpau: use temporary buffers while applying filters

Use temporary buffers so that we don't read and write to the
same surface at the same time. We don't need to use linear
layout now.

v2: rebase the patch against reverted change

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/mixer.c | 75 
 1 file changed, 57 insertions(+), 18 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/mixer.c 
b/src/gallium/state_trackers/vdpau/mixer.c
index cb0ef03..c205427 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -240,8 +240,10 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
struct u_rect rect, clip, *prect, dirty_area;
unsigned i, layer = 0;
struct pipe_video_buffer *video_buffer;
-   struct pipe_sampler_view *sampler_view;
-   struct pipe_surface *surface;
+   struct pipe_sampler_view *sampler_view, sv_templ;
+   struct pipe_surface *surface, surf_templ;
+   struct pipe_context *pipe;
+   struct pipe_resource res_tmpl, *res;
 
vlVdpVideoMixer *vmixer;
vlVdpSurface *surf;
@@ -335,25 +337,25 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
}
vl_compositor_set_buffer_layer(>cstate, compositor, layer, 
video_buffer, prect, NULL, deinterlace);
 
-   if(vmixer->bicubic.filter) {
-  struct pipe_context *pipe;
-  struct pipe_resource res_tmpl, *res;
-  struct pipe_sampler_view sv_templ;
-  struct pipe_surface surf_templ;
-
+   if (vmixer->bicubic.filter || vmixer->sharpness.filter || 
vmixer->noise_reduction.filter) {
   pipe = vmixer->device->context;
   memset(_tmpl, 0, sizeof(res_tmpl));
 
   res_tmpl.target = PIPE_TEXTURE_2D;
-  res_tmpl.width0 = surf->templat.width;
-  res_tmpl.height0 = surf->templat.height;
   res_tmpl.format = dst->sampler_view->format;
   res_tmpl.depth0 = 1;
   res_tmpl.array_size = 1;
-  res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
-  PIPE_BIND_LINEAR;
+  res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
   res_tmpl.usage = PIPE_USAGE_DEFAULT;
 
+  if (!vmixer->bicubic.filter) {
+ res_tmpl.width0 = dst->surface->width;
+ res_tmpl.height0 = dst->surface->height;
+  } else {
+ res_tmpl.width0 = surf->templat.width;
+ res_tmpl.height0 = surf->templat.height;
+  }
+
   res = pipe->screen->resource_create(pipe->screen, _tmpl);
 
   vlVdpDefaultSamplerViewTemplate(_templ, res);
@@ -369,6 +371,9 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
   surface = dst->surface;
   sampler_view = dst->sampler_view;
   dirty_area = dst->dirty_area;
+   }
+
+   if (!vmixer->bicubic.filter) {
   vl_compositor_set_layer_dst_area(>cstate, layer++, 
RectToPipe(destination_video_rect, ));
   vl_compositor_set_dst_clip(>cstate, RectToPipe(destination_rect, 
));
}
@@ -394,13 +399,47 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
else {
   vl_compositor_render(>cstate, compositor, surface, _area, 
true);
 
-  if (vmixer->noise_reduction.filter)
- vl_median_filter_render(vmixer->noise_reduction.filter,
- sampler_view, surface);
+  if (vmixer->noise_reduction.filter) {
+ if (!vmixer->sharpness.filter && !vmixer->bicubic.filter) {
+vl_median_filter_render(vmixer->noise_reduction.filter,
+sampler_view, dst->surface);
+ } else {
+res = pipe->screen->resource_create(pipe->screen, _tmpl);
+struct pipe_sampler_view *sampler_view_temp = 
pipe->create_sampler_view(pipe, res, _templ);
+struct pipe_surface *surface_temp = pipe->create_surface(pipe, 
res, _templ);
+pipe_resource_reference(, NULL);
+
+vl_median_filter_render(vmixer->noise_reduction.filter,
+sampler_view, surface_temp);
+
+pipe_sampler_view_reference(_view, NULL);
+pipe_surface_reference(, NULL);
 
-  if (vmixer->sharpness.filter)
- vl_matrix_filter_render(vmixer->sharpness.filter,
- sampler_view, surface);
+sampler_view = sampler_view_temp;
+surface = surface_temp;
+ }
+  }
+
+  if (vmixer->sharpness.filter) {
+ if (!vmixer->bicubic.filter) {
+vl_ma

Mesa (master): st/va: Remove unused variable coded_size from vlVaEndPicture()

2016-08-24 Thread Christian König
Module: Mesa
Branch: master
Commit: f033d971557082ce716f5b722df0d923a265678e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f033d971557082ce716f5b722df0d923a265678e

Author: Kai Wasserbäch <k...@dev.carbon-project.org>
Date:   Sat Aug 20 18:14:54 2016 +0200

st/va: Remove unused variable coded_size from vlVaEndPicture()

Removes the following GCC warning:
 ../../../../../src/gallium/state_trackers/va/picture.c:542:17: warning:
  unused variable 'coded_size' [-Wunused-variable]
unsigned int coded_size;
 ^~

Signed-off-by: Kai Wasserbäch <k...@dev.carbon-project.org>
Reviewed-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Boyuan Zhang <boyuan.zh...@amd.com>

---

 src/gallium/state_trackers/va/picture.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index bbb5595..a283e83 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -539,7 +539,6 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
vlVaContext *context;
vlVaBuffer *coded_buf;
vlVaSurface *surf;
-   unsigned int coded_size;
void *feedback;
 
if (!ctx)

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


Mesa (master): st/va: Remove else case in vlVaEndPicture() made superfluous by c59628d11b

2016-08-24 Thread Christian König
Module: Mesa
Branch: master
Commit: 83d08d4cab1cd6577dd304e6f8acead4076ccf5d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=83d08d4cab1cd6577dd304e6f8acead4076ccf5d

Author: Kai Wasserbäch <k...@dev.carbon-project.org>
Date:   Sat Aug 20 18:14:53 2016 +0200

st/va: Remove else case in vlVaEndPicture() made superfluous by c59628d11b

Commit c59628d11b134fc016388a170880f7646e100d6f made the else statement
and duplication of the context->decoder->end_frame() call superfluous.

Cc: Boyuan Zhang <boyuan.zh...@amd.com>
Signed-off-by: Kai Wasserbäch <k...@dev.carbon-project.org>
Reviewed-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Boyuan Zhang <boyuan.zh...@amd.com>

---

 src/gallium/state_trackers/va/picture.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 87567be..bbb5595 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -576,11 +576,9 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID 
context_id)
   surf->frame_num_cnt = context->desc.h264enc.frame_num_cnt;
   surf->feedback = feedback;
   surf->coded_buf = coded_buf;
-  context->decoder->end_frame(context->decoder, context->target, 
>desc.base);
}
-   else
-  context->decoder->end_frame(context->decoder, context->target, 
>desc.base);
 
+   context->decoder->end_frame(context->decoder, context->target, 
>desc.base);
pipe_mutex_unlock(drv->mutex);
return VA_STATUS_SUCCESS;
 }

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


Mesa (master): st/va: add missing mutex_unlock

2016-08-24 Thread Christian König
Module: Mesa
Branch: master
Commit: cd340052adf4246284311f5262664ab8867396e2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd340052adf4246284311f5262664ab8867396e2

Author: Eric Engestrom <e...@engestrom.ch>
Date:   Sun Aug 21 22:11:48 2016 +0100

st/va: add missing mutex_unlock

Fixes: c59628d11b134fc01638 ("st/va: enable dual instances encode by sync 
surface")

Signed-off-by: Eric Engestrom <e...@engestrom.ch>
Reviewed-by: Boyuan Zhang <boyuan.zh...@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/surface.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/surface.c 
b/src/gallium/state_trackers/va/surface.c
index 012e48e..3ee1cdd 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -106,8 +106,10 @@ vlVaSyncSurface(VADriverContextP ctx, VASurfaceID 
render_target)
pipe_mutex_lock(drv->mutex);
surf = handle_table_get(drv->htab, render_target);
 
-   if (!surf || !surf->buffer)
+   if (!surf || !surf->buffer) {
+  pipe_mutex_unlock(drv->mutex);
   return VA_STATUS_ERROR_INVALID_SURFACE;
+   }
 
context = handle_table_get(drv->htab, surf->ctx);
if (!context) {

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


Mesa (master): st/vdpau: change the order in which filters are applied(v3)

2016-08-16 Thread Christian König
Module: Mesa
Branch: master
Commit: 09dff7ae2e179d5a3490481762c6bd3d50430c9f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=09dff7ae2e179d5a3490481762c6bd3d50430c9f

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Fri Aug 12 19:50:51 2016 +0530

st/vdpau: change the order in which filters are applied(v3)

Apply the median and matrix filter before the compostioning
we apply the deinterlacing first to avoid the extra overhead
in processing the past and the future surfaces in deinterlacing.

v2: apply the filters on all the surfaces (Christian)
v3: use get_sampler_view_planes() instead of
get_sampler_view_components() and iterate over
VL_MAX_SURFACES (Christian)

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/mixer.c | 28 ++--
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/mixer.c 
b/src/gallium/state_trackers/vdpau/mixer.c
index cb0ef03..56b667d 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -240,8 +240,8 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
struct u_rect rect, clip, *prect, dirty_area;
unsigned i, layer = 0;
struct pipe_video_buffer *video_buffer;
-   struct pipe_sampler_view *sampler_view;
-   struct pipe_surface *surface;
+   struct pipe_sampler_view *sampler_view, **sampler_views;
+   struct pipe_surface *surface, **surfaces;
 
vlVdpVideoMixer *vmixer;
vlVdpSurface *surf;
@@ -325,6 +325,22 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
   }
}
 
+   surfaces = video_buffer->get_surfaces(video_buffer);
+   sampler_views = video_buffer->get_sampler_view_planes(video_buffer);
+
+   for(i = 0; i < VL_MAX_SURFACES; ++i) {
+  if(sampler_views[i] != NULL && surfaces[i] != NULL) {
+ if (vmixer->noise_reduction.filter)
+vl_median_filter_render(vmixer->noise_reduction.filter,
+sampler_views[i], surfaces[i]);
+
+ if (vmixer->sharpness.filter)
+vl_matrix_filter_render(vmixer->sharpness.filter,
+sampler_views[i], surfaces[i]);
+
+  }
+   }
+
prect = RectToPipe(video_source_rect, );
if (!prect) {
   rect.x0 = 0;
@@ -394,14 +410,6 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
else {
   vl_compositor_render(>cstate, compositor, surface, _area, 
true);
 
-  if (vmixer->noise_reduction.filter)
- vl_median_filter_render(vmixer->noise_reduction.filter,
- sampler_view, surface);
-
-  if (vmixer->sharpness.filter)
- vl_matrix_filter_render(vmixer->sharpness.filter,
- sampler_view, surface);
-
   if (vmixer->bicubic.filter)
  vl_bicubic_filter_render(vmixer->bicubic.filter,
  sampler_view, dst->surface,

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


Mesa (master): st/omx/dec/h264: pass default scaling lists in raster format

2016-08-11 Thread Christian König
Module: Mesa
Branch: master
Commit: 8074c6b6eab9f864a5d0bf3123677ffc3edc5cd2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8074c6b6eab9f864a5d0bf3123677ffc3edc5cd2

Author: Indrajit Das <indrajit-kumar@amd.com>
Date:   Tue Aug  9 11:01:13 2016 +0530

st/omx/dec/h264: pass default scaling lists in raster format

Tested-by: Leo Liu <leo@amd.com>
Acked-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/omx/vid_dec_h264.c | 40 +--
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/gallium/state_trackers/omx/vid_dec_h264.c 
b/src/gallium/state_trackers/omx/vid_dec_h264.c
index bc7feaa..10f2959 100644
--- a/src/gallium/state_trackers/omx/vid_dec_h264.c
+++ b/src/gallium/state_trackers/omx/vid_dec_h264.c
@@ -50,35 +50,35 @@ struct dpb_list {
 };
 
 static const uint8_t Default_4x4_Intra[16] = {
-6, 13, 13, 20, 20, 20, 28, 28,
-   28, 28, 32, 32, 32, 37, 37, 42
+6, 13, 20, 28, 13, 20, 28, 32,
+   20, 28, 32, 37, 28, 32, 37, 42
 };
 
 static const uint8_t Default_4x4_Inter[16] = {
-   10, 14, 14, 20, 20, 20, 24, 24,
-   24, 24, 27, 27, 27, 30, 30, 34
+   10, 14, 20, 24, 14, 20, 24, 27,
+   20, 24, 27, 30, 24, 27, 30, 34
 };
 
 static const uint8_t Default_8x8_Intra[64] = {
-6, 10, 10, 13, 11, 13, 16, 16,
-   16, 16, 18, 18, 18, 18, 18, 23,
-   23, 23, 23, 23, 23, 25, 25, 25,
-   25, 25, 25, 25, 27, 27, 27, 27,
-   27, 27, 27, 27, 29, 29, 29, 29,
-   29, 29, 29, 31, 31, 31, 31, 31,
-   31, 33, 33, 33, 33, 33, 36, 36,
-   36, 36, 38, 38, 38, 40, 40, 42
+6, 10, 13, 16, 18, 23, 25, 27,
+   10, 11, 16, 18, 23, 25, 27, 29,
+   13, 16, 18, 23, 25, 27, 29, 31,
+   16, 18, 23, 25, 27, 29, 31, 33,
+   18, 23, 25, 27, 29, 31, 33, 36,
+   23, 25, 27, 29, 31, 33, 36, 38,
+   25, 27, 29, 31, 33, 36, 38, 40,
+   27, 29, 31, 33, 36, 38, 40, 42
 };
 
 static const uint8_t Default_8x8_Inter[64] = {
-9, 13, 13, 15, 13, 15, 17, 17,
-   17, 17, 19, 19, 19, 19, 19, 21,
-   21, 21, 21, 21, 21, 22, 22, 22,
-   22, 22, 22, 22, 24, 24, 24, 24,
-   24, 24, 24, 24, 25, 25, 25, 25,
-   25, 25, 25, 27, 27, 27, 27, 27,
-   27, 28, 28, 28, 28, 28, 30, 30,
-   30, 30, 32, 32, 32, 33, 33, 35
+9, 13, 15, 17, 19, 21, 22, 24,
+   13, 13, 17, 19, 21, 22, 24, 25,
+   15, 17, 19, 21, 22, 24, 25, 27,
+   17, 19, 21, 22, 24, 25, 27, 28,
+   19, 21, 22, 24, 25, 27, 28, 30,
+   21, 22, 24, 25, 27, 28, 30, 32,
+   22, 24, 25, 27, 28, 30, 32, 33,
+   24, 25, 27, 28, 30, 32, 33, 35
 };
 
 static void vid_dec_h264_Decode(vid_dec_PrivateType *priv, struct vl_vlc *vlc, 
unsigned min_bits_left);

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


Mesa (master): st/va: add conversion for yv12 to nv12in putimage v2

2016-07-25 Thread Christian König
Module: Mesa
Branch: master
Commit: 34f46348438b29e20d06cca312616cfba8ee05f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=34f46348438b29e20d06cca312616cfba8ee05f6

Author: Boyuan Zhang <boyuan.zh...@amd.com>
Date:   Thu Jul 21 19:40:16 2016 -0400

st/va: add conversion for yv12 to nv12in putimage v2

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.

v2 (chk): fix some compiler warnings and commit message

Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>
Signed-off-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/image.c | 34 +++---
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/va/image.c 
b/src/gallium/state_trackers/va/image.c
index 36b2469..bd60d3e 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,30 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, 
VAImageID image,
   unsigned width, height;
   if (!views[i]) continue;
   vlVaVideoSurfaceSize(surf, i, , );
-  for (j = 0; j < views[i]->texture->array_size; ++j) {
- struct pipe_box dst_box = {0, 0, j, width, height, 1};
- drv->pipe->texture_subdata(drv->pipe, views[i]->texture, 0,
-PIPE_TRANSFER_WRITE, _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,
+   _box_1, );
+ if (map == NULL)
+return VA_STATUS_ERROR_OPERATION_FAILED;
+
+ u_copy_yv12_img_to_nv12_surf ((ubyte * const*)data, map, width, 
height,
+  pitches[i], transfer->stride, 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->texture_subdata(drv->pipe, views[i]->texture, 0,
+   PIPE_TRANSFER_WRITE, _box,
+   data[i] + pitches[i] * j,
+   pitches[i] * 
views[i]->texture->array_size, 0);
+ }
   }
}
pipe_mutex_unlock(drv->mutex);

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


Mesa (master): st/va: enable h264 VAAPI encode

2016-07-25 Thread Christian König
Module: Mesa
Branch: master
Commit: dd208ea006c3c66bf64f21ecc1eaffdc0e57db5e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dd208ea006c3c66bf64f21ecc1eaffdc0e57db5e

Author: Boyuan Zhang 
Date:   Thu Jul 21 19:40:22 2016 -0400

st/va: enable h264 VAAPI encode

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 | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index 889ce38..84bf913 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -94,11 +94,9 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile 
profile,
PIPE_VIDEO_CAP_SUPPORTED))
   entrypoint_list[(*num_entrypoints)++] = VAEntrypointVLD;
 
-#if 0
if (pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE,
PIPE_VIDEO_CAP_SUPPORTED))
   entrypoint_list[(*num_entrypoints)++] = VAEntrypointEncSlice;
-#endif
 
if (num_entrypoints == 0)
   return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
@@ -122,7 +120,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;
@@ -183,7 +181,6 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
   config->entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
   break;
 
-#if 0
case VAEntrypointEncSlice:
   if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE,
PIPE_VIDEO_CAP_SUPPORTED)) {
@@ -193,7 +190,6 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, 
VAEntrypoint entrypoin
 
   config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
   break;
-#endif
 
default:
   FREE(config);

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


Mesa (master): vl/util: add copy func for yv12image to nv12surface v2

2016-07-25 Thread Christian König
Module: Mesa
Branch: master
Commit: 23b4ab1738f0f4470449c848b37b43568df4a60c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=23b4ab1738f0f4470449c848b37b43568df4a60c

Author: Boyuan Zhang <boyuan.zh...@amd.com>
Date:   Thu Jul 21 19:40:15 2016 -0400

vl/util: add copy func for yv12image to nv12surface v2

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.

v2: cleanup variable types and commit message

Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>
Signed-off-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/auxiliary/util/u_video.h | 37 
 1 file changed, 37 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_video.h 
b/src/gallium/auxiliary/util/u_video.h
index 9196afc..7e743de 100644
--- a/src/gallium/auxiliary/util/u_video.h
+++ b/src/gallium/auxiliary/util/u_video.h
@@ -130,6 +130,43 @@ u_copy_yv12_to_nv12(void *const *destination_data,
 }
 
 static inline void
+u_copy_yv12_img_to_nv12_surf(ubyte *const *src,
+ ubyte *dst,
+ unsigned width,
+ unsigned height,
+ unsigned src_stride,
+ unsigned dst_stride,
+ int field)
+{
+   if (field == 0) {
+  ubyte *src_0 = src[field];
+  for (int i = 0; i < height ; i++) {
+ memcpy(dst, src_0, width);
+ dst += dst_stride;
+ src_0 += src_stride;
+  }
+   } else if (field == 1) {
+  const ubyte *src_1 = src[field];
+  const ubyte *src_2 = src[field+1];
+  bool odd = false;
+  for (unsigned i = 0; i < height ; i++) {
+ for (unsigned j = 0; j < width*2 ; j++) {
+if (odd == false) {
+   dst[j] = src_1[j/2];
+   odd = true;
+} else {
+   dst[j] = src_2[j/2];
+   odd = false;
+}
+ }
+ dst += dst_stride;
+ src_1 += src_stride;
+ src_2 += src_stride;
+  }
+   }
+}
+
+static inline void
 u_copy_swap422_packed(void *const *destination_data,
uint32_t const *destination_pitches,
int src_plane, int src_field,

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


Mesa (master): st/va: add functions for VAAPI encode

2016-07-25 Thread Christian König
Module: Mesa
Branch: master
Commit: 85d807f2e04eb4f096fa619bc61c65cdcef446c8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=85d807f2e04eb4f096fa619bc61c65cdcef446c8

Author: Boyuan Zhang 
Date:   Thu Jul 21 19:40:18 2016 -0400

st/va: add functions for VAAPI encode

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 |   2 +
 3 files changed, 178 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, 
>desc.base);
+   if (context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE)
+  context->decoder->begin_frame(context->decoder, context->target, 
>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, 
>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)
+{
+   

Mesa (master): st/va: add function to handle misc param type frame rate

2016-07-25 Thread Christian König
Module: Mesa
Branch: master
Commit: 71da1354d7ce836af5081b109e1487b32348f7f4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=71da1354d7ce836af5081b109e1487b32348f7f4

Author: Boyuan Zhang 
Date:   Thu Jul 21 19:40:21 2016 -0400

st/va: add function to handle misc param type frame rate

Frame rate can be passed to driver either through 
VAEncSequenceParameterBufferType or VAEncMiscParameterTypeFrameRate. Previous 
code only implement the former one, which is used by Gstreamer-Vaapi. Now 
adding implementation for VAEncMiscParameterTypeFrameRate. Also adding default 
frame rate as 30 just in case application never provides frame rate information 
to driver.

Signed-off-by: Boyuan Zhang 

---

 src/gallium/state_trackers/va/picture.c | 24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/va/picture.c 
b/src/gallium/state_trackers/va/picture.c
index 4abf155..b187452 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -117,6 +117,13 @@ getEncParamPreset(vlVaContext *context)
context->desc.h264enc.rate_ctrl.fill_data_enable = 1;
context->desc.h264enc.rate_ctrl.enforce_hrd = 1;
context->desc.h264enc.enable_vui = false;
+   if (context->desc.h264enc.rate_ctrl.frame_rate_num == 0)
+  context->desc.h264enc.rate_ctrl.frame_rate_num = 30;
+   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;
 
context->desc.h264enc.ref_pic_mode = 0x0201;
 }
@@ -319,16 +326,19 @@ handleVAEncMiscParameterTypeRateControl(vlVaContext 
*context, VAEncMiscParameter
   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
+handleVAEncMiscParameterTypeFrameRate(vlVaContext *context, 
VAEncMiscParameterBuffer *misc)
+{
+   VAEncMiscParameterFrameRate *fr = (VAEncMiscParameterFrameRate *)misc->data;
+   context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate;
+   return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
 handleVAEncSequenceParameterBufferType(vlVaDriver *drv, vlVaContext *context, 
vlVaBuffer *buf)
 {
VAEncSequenceParameterBufferH264 *h264 = (VAEncSequenceParameterBufferH264 
*)buf->data;
@@ -357,6 +367,10 @@ handleVAEncMiscParameterBufferType(vlVaContext *context, 
vlVaBuffer *buf)
   vaStatus = handleVAEncMiscParameterTypeRateControl(context, misc);
   break;
 
+   case VAEncMiscParameterTypeFrameRate:
+  vaStatus = handleVAEncMiscParameterTypeFrameRate(context, misc);
+  break;
+
default:
   break;
}

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


Mesa (master): st/va: get rate control method from configattrib v2

2016-07-25 Thread Christian König
Module: Mesa
Branch: master
Commit: 10c1cc47a6adba9ea83d4df5c154c07f95ac3a40
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=10c1cc47a6adba9ea83d4df5c154c07f95ac3a40

Author: Boyuan Zhang <boyuan.zh...@amd.com>
Date:   Thu Jul 21 19:40:17 2016 -0400

st/va: get rate control method from configattrib v2

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.

v2 (chk): fix broken build and commit message

Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>
Signed-off-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/config.c | 11 +++
 src/gallium/state_trackers/va/context.c|  2 ++
 src/gallium/state_trackers/va/va_private.h |  2 ++
 3 files changed, 15 insertions(+)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index 7742087..889ce38 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -202,6 +202,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 520db46..1addd87 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -229,6 +229,7 @@ typedef struct {
   struct pipe_vc1_picture_desc vc1;
   struct pipe_h264_picture_desc h264;
   struct pipe_h265_picture_desc h265;
+  struct pipe_h264_enc_picture_desc h264enc;
} desc;
 
struct {
@@ -246,6 +247,7 @@ typedef struct {
 typedef struct {
enum pipe_video_profile profile;
enum pipe_video_entrypoint entrypoint;
+   enum pipe_h264_enc_rate_control_method rc;
 } vlVaConfig;
 
 typedef struct {

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


Mesa (master): st/va: add preset values for VAAPI encode

2016-07-25 Thread Christian König
Module: Mesa
Branch: master
Commit: b0ceb4cc4862f3d751973e230569c97e0119aa19
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0ceb4cc4862f3d751973e230569c97e0119aa19

Author: Boyuan Zhang 
Date:   Thu Jul 21 19:40:19 2016 -0400

st/va: add preset values for VAAPI encode

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, 
>desc.base);
   context->decoder->encode_bitstream(context->decoder, context->target,
  coded_buf->derived_surface.resource, 
);

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


Mesa (master): st/va: add enviromental variable to disable interlace

2016-07-25 Thread Christian König
Module: Mesa
Branch: master
Commit: 10dec2de2d9f568675d66d736b48701fa26f7b50
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=10dec2de2d9f568675d66d736b48701fa26f7b50

Author: Boyuan Zhang 
Date:   Thu Jul 21 19:40:20 2016 -0400

st/va: add enviromental variable to disable interlace

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

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


Mesa (master): st/va: add encode entrypoint v2

2016-07-25 Thread Christian König
Module: Mesa
Branch: master
Commit: 5bcaa1b9e9707aea7be73b406345bb9e46f92a18
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5bcaa1b9e9707aea7be73b406345bb9e46f92a18

Author: Boyuan Zhang <boyuan.zh...@amd.com>
Date:   Thu Jul 21 19:40:14 2016 -0400

st/va: add encode entrypoint v2

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.

v2 (chk): fix commit message to match 80 chars, use switch instead of ifs,
  fix memory leaks in the error path, implement 
vlVaQueryConfigEntrypoints
  as well, drop VAEntrypointEncPicture (only used for JPEG).

Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>
Signed-off-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/config.c | 111 +
 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, 150 insertions(+), 39 deletions(-)

diff --git a/src/gallium/state_trackers/va/config.c 
b/src/gallium/state_trackers/va/config.c
index 9ca0aa8..7742087 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
@@ -88,10 +90,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;
+   if (pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+   PIPE_VIDEO_CAP_SUPPORTED))
+  entrypoint_list[(*num_entrypoints)++] = VAEntrypointVLD;
 
-   entrypoint_list[(*num_entrypoints)++] = VAEntrypointVLD;
+#if 0
+   if (pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE,
+   PIPE_VIDEO_CAP_SUPPORTED))
+  entrypoint_list[(*num_entrypoints)++] = VAEntrypointEncSlice;
+#endif
+
+   if (num_entrypoints == 0)
+  return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
 
return VA_STATUS_SUCCESS;
 }
@@ -128,29 +138,73 @@ 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;
}
 
p = ProfileToPipe(profile);
-   if (p == PIPE_VIDEO_PROFILE_UNKNOWN)
+   if (p == PIPE_VIDEO_PROFILE_UNKNOWN) {
+  FREE(config);
   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)
+   switch (entrypoint) {
+   case VAEntrypointVLD:
+  if (!pscreen->get_video_param(pscreen, p, 
PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+   PIPE_VIDEO_CAP_SUPPORTED)) {
+ FREE(config);
+ return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+  }
+
+  config->entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
+  break;
+
+#if 0
+   case VAEntrypointEncSlice:
+  if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE,
+   PIPE_VIDEO_CAP_SUPPORTED)) {
+ FREE(config);
+ return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+  }
+
+  config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
+  break

Mesa (master): vl: fix memory leak

2016-07-19 Thread Christian König
Module: Mesa
Branch: master
Commit: 8ba46fbd9ec7a1214882bcfd3de1835a6237b6d1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8ba46fbd9ec7a1214882bcfd3de1835a6237b6d1

Author: Eric Engestrom <e...@engestrom.ch>
Date:   Wed Jul 13 22:50:54 2016 +0100

vl: fix memory leak

CovID: 1363008
Signed-off-by: Eric Engestrom <e...@engestrom.ch>
Reviewed-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/auxiliary/vl/vl_bicubic_filter.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_bicubic_filter.c 
b/src/gallium/auxiliary/vl/vl_bicubic_filter.c
index 25bc58c..51a0019 100644
--- a/src/gallium/auxiliary/vl/vl_bicubic_filter.c
+++ b/src/gallium/auxiliary/vl/vl_bicubic_filter.c
@@ -242,7 +242,7 @@ vl_bicubic_filter_init(struct vl_bicubic_filter *filter, 
struct pipe_context *pi
 {
struct pipe_rasterizer_state rs_state;
struct pipe_blend_state blend;
-   struct vertex2f *offsets = NULL;
+   struct vertex2f offsets[16];
struct pipe_sampler_state sampler;
struct pipe_vertex_element ve;
unsigned i;
@@ -301,10 +301,6 @@ vl_bicubic_filter_init(struct vl_bicubic_filter *filter, 
struct pipe_context *pi
if (!filter->ves)
   goto error_ves;
 
-   offsets = MALLOC(sizeof(struct vertex2f) * 16);
-   if (!offsets)
-  goto error_offsets;
-
offsets[0].x = -1.0f; offsets[0].y = -1.0f;
offsets[1].x = 0.0f; offsets[1].y = -1.0f;
offsets[2].x = 1.0f; offsets[2].y = -1.0f;
@@ -344,8 +340,6 @@ error_fs:
pipe->delete_vs_state(pipe, filter->vs);
 
 error_vs:
-
-error_offsets:
pipe->delete_vertex_elements_state(pipe, filter->ves);
 
 error_ves:

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


Mesa (master): vl: add entry point

2016-07-19 Thread Christian König
Module: Mesa
Branch: master
Commit: 60c7450f16b8275c896103da27a5d4a25ce9be9e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=60c7450f16b8275c896103da27a5d4a25ce9be9e

Author: Boyuan Zhang <boyuan.zh...@amd.com>
Date:   Mon Jul 18 18:43:37 2016 -0400

vl: add entry point

Add entrypoint to distinguish H.264 decode and encode. For example, in patch
5/11 when is calling "VaCreateContext", "pps" and "sps" shouldn't be allocated
for H.264 encoding. So we need to use the entry_point to determine this is
H.264 decode or H.264 encode. We can use config to determine the entrypoint
since config_id is passed to us for VaCreateContext call. However, for
VaDestoyContext call, only context_id is passed to us. So we need to know the
entrypoint in order to not free the pps/sps for encoding case.

Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/include/pipe/p_video_state.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/include/pipe/p_video_state.h 
b/src/gallium/include/pipe/p_video_state.h
index 754d013..39b3905 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -131,6 +131,7 @@ enum pipe_h264_enc_rate_control_method
 struct pipe_picture_desc
 {
enum pipe_video_profile profile;
+   enum pipe_video_entrypoint entry_point;
 };
 
 struct pipe_quant_matrix

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


Mesa (master): radeon/uvd: add session context buffer for polaris 10/11 v2

2016-07-18 Thread Christian König
Module: Mesa
Branch: master
Commit: 3e1ad846f9c2f3516861d03ba99c4cb22f5f1b6e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3e1ad846f9c2f3516861d03ba99c4cb22f5f1b6e

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jul  7 14:28:06 2016 +0200

radeon/uvd: add session context buffer for polaris 10/11 v2

This way we have unlimited UVD sessions.

v2: only enable it when kernel supports it as well.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Leo Liu <leo@amd.com>

---

 src/gallium/drivers/radeon/radeon_uvd.c | 20 
 src/gallium/drivers/radeon/radeon_uvd.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/src/gallium/drivers/radeon/radeon_uvd.c 
b/src/gallium/drivers/radeon/radeon_uvd.c
index 10bed7c..d5d654a 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -59,6 +59,7 @@
 #define FB_BUFFER_SIZE 2048
 #define FB_BUFFER_SIZE_TONGA (2048 * 64)
 #define IT_SCALING_TABLE_SIZE 992
+#define UVD_SESSION_CONTEXT_SIZE (128 * 1024)
 
 /* UVD decoder representation */
 struct ruvd_decoder {
@@ -89,6 +90,7 @@ struct ruvd_decoder {
struct rvid_buffer  dpb;
booluse_legacy;
struct rvid_buffer  ctx;
+   struct rvid_buffer  sessionctx;
 };
 
 /* flush IB to the hardware */
@@ -170,6 +172,12 @@ static void send_msg_buf(struct ruvd_decoder *dec)
dec->fb = NULL;
dec->it = NULL;
 
+
+   if (dec->sessionctx.res)
+   send_cmd(dec, RUVD_CMD_SESSION_CONTEXT_BUFFER,
+dec->sessionctx.res->buf, 0, RADEON_USAGE_READWRITE,
+RADEON_DOMAIN_VRAM);
+
/* and send it to the hardware */
send_cmd(dec, RUVD_CMD_MSG_BUFFER, buf->res->buf, 0,
 RADEON_USAGE_READ, RADEON_DOMAIN_GTT);
@@ -938,6 +946,7 @@ static void ruvd_destroy(struct pipe_video_codec *decoder)
 
rvid_destroy_buffer(>dpb);
rvid_destroy_buffer(>ctx);
+   rvid_destroy_buffer(>sessionctx);
 
FREE(dec);
 }
@@ -1259,6 +1268,16 @@ struct pipe_video_codec *ruvd_create_decoder(struct 
pipe_context *context,
rvid_clear_buffer(context, >ctx);
}
 
+   if (info.family >= CHIP_POLARIS10 && info.drm_minor >= 3) {
+   if (!rvid_create_buffer(dec->screen, >sessionctx,
+   UVD_SESSION_CONTEXT_SIZE,
+   PIPE_USAGE_DEFAULT)) {
+   RVID_ERR("Can't allocated session ctx.\n");
+   goto error;
+   }
+   rvid_clear_buffer(context, >sessionctx);
+   }
+
map_msg_fb_it_buf(dec);
dec->msg->size = sizeof(*dec->msg);
dec->msg->msg_type = RUVD_MSG_CREATE;
@@ -1286,6 +1305,7 @@ error:
 
rvid_destroy_buffer(>dpb);
rvid_destroy_buffer(>ctx);
+   rvid_destroy_buffer(>sessionctx);
 
FREE(dec);
 
diff --git a/src/gallium/drivers/radeon/radeon_uvd.h 
b/src/gallium/drivers/radeon/radeon_uvd.h
index bb1782a..e3f8504 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.h
+++ b/src/gallium/drivers/radeon/radeon_uvd.h
@@ -61,6 +61,7 @@
 #define RUVD_CMD_DPB_BUFFER0x0001
 #define RUVD_CMD_DECODING_TARGET_BUFFER0x0002
 #define RUVD_CMD_FEEDBACK_BUFFER   0x0003
+#define RUVD_CMD_SESSION_CONTEXT_BUFFER0x0005
 #define RUVD_CMD_BITSTREAM_BUFFER  0x0100
 #define RUVD_CMD_ITSCALING_TABLE_BUFFER0x0204
 #define RUVD_CMD_CONTEXT_BUFFER0x0206

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


Mesa (master): radeon/vce: handle newly added parameters

2016-07-14 Thread Christian König
Module: Mesa
Branch: master
Commit: 23c5e8bc58cd5955151e30aa95e138031d1dad4f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=23c5e8bc58cd5955151e30aa95e138031d1dad4f

Author: Boyuan Zhang <boyuan.zh...@amd.com>
Date:   Wed Jul 13 18:51:14 2016 -0400

radeon/vce: handle newly added parameters

Replace the previous hardcoded value with newly defined parameters

Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/drivers/radeon/radeon_vce_52.c | 33 ++
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_vce_52.c 
b/src/gallium/drivers/radeon/radeon_vce_52.c
index 869b29b..136f080 100644
--- a/src/gallium/drivers/radeon/radeon_vce_52.c
+++ b/src/gallium/drivers/radeon/radeon_vce_52.c
@@ -48,13 +48,14 @@ static void get_rate_control_param(struct rvce_encoder 
*enc, struct pipe_h264_en
enc->enc_pic.rc.quant_i_frames = pic->quant_i_frames;
enc->enc_pic.rc.quant_p_frames = pic->quant_p_frames;
enc->enc_pic.rc.quant_b_frames = pic->quant_b_frames;
+   enc->enc_pic.rc.gop_size = pic->gop_size;
enc->enc_pic.rc.frame_rate_num = pic->rate_ctrl.frame_rate_num;
enc->enc_pic.rc.frame_rate_den = pic->rate_ctrl.frame_rate_den;
enc->enc_pic.rc.max_qp = 51;
enc->enc_pic.rc.vbv_buffer_size = pic->rate_ctrl.vbv_buffer_size;
-   enc->enc_pic.rc.vbv_buf_lv = 0;
-   enc->enc_pic.rc.fill_data_enable = 0;
-   enc->enc_pic.rc.enforce_hrd = 0;
+   enc->enc_pic.rc.vbv_buf_lv = pic->rate_ctrl.vbv_buf_lv;
+   enc->enc_pic.rc.fill_data_enable = pic->rate_ctrl.fill_data_enable;
+   enc->enc_pic.rc.enforce_hrd = pic->rate_ctrl.enforce_hrd;
enc->enc_pic.rc.target_bits_picture = 
pic->rate_ctrl.target_bits_picture;
enc->enc_pic.rc.peak_bits_picture_integer = 
pic->rate_ctrl.peak_bits_picture_integer;
enc->enc_pic.rc.peak_bits_picture_fraction = 
pic->rate_ctrl.peak_bits_picture_fraction;
@@ -62,13 +63,13 @@ static void get_rate_control_param(struct rvce_encoder 
*enc, struct pipe_h264_en
 
 static void get_motion_estimation_param(struct rvce_encoder *enc, struct 
pipe_h264_enc_picture_desc *pic)
 {
-   enc->enc_pic.me.motion_est_quarter_pixel = 0x;
-   enc->enc_pic.me.enc_disable_sub_mode = 0x00fe;
-   enc->enc_pic.me.lsmvert = 0x;
-   enc->enc_pic.me.enc_en_ime_overw_dis_subm = 0x;
-   enc->enc_pic.me.enc_ime_overw_dis_subm_no = 0x;
-   enc->enc_pic.me.enc_ime2_search_range_x = 0x0001;
-   enc->enc_pic.me.enc_ime2_search_range_y = 0x0001;
+   enc->enc_pic.me.motion_est_quarter_pixel = 
pic->motion_est.motion_est_quarter_pixel;
+   enc->enc_pic.me.enc_disable_sub_mode = 
pic->motion_est.enc_disable_sub_mode;
+   enc->enc_pic.me.lsmvert = pic->motion_est.lsmvert;
+   enc->enc_pic.me.enc_en_ime_overw_dis_subm = 
pic->motion_est.enc_en_ime_overw_dis_subm;
+   enc->enc_pic.me.enc_ime_overw_dis_subm_no = 
pic->motion_est.enc_ime_overw_dis_subm_no;
+   enc->enc_pic.me.enc_ime2_search_range_x = 
pic->motion_est.enc_ime2_search_range_x;
+   enc->enc_pic.me.enc_ime2_search_range_y = 
pic->motion_est.enc_ime2_search_range_y;
enc->enc_pic.me.enc_ime_decimation_search = 0x0001;
enc->enc_pic.me.motion_est_half_pixel = 0x0001;
enc->enc_pic.me.enc_search_range_x = 0x0010;
@@ -90,8 +91,8 @@ static void get_pic_control_param(struct rvce_encoder *enc, 
struct pipe_h264_enc
enc->enc_pic.pc.enc_max_num_ref_frames = enc->base.max_references + 1;
enc->enc_pic.pc.enc_num_default_active_ref_l0 = 0x0001;
enc->enc_pic.pc.enc_num_default_active_ref_l1 = 0x0001;
-   enc->enc_pic.pc.enc_cabac_enable = 0x;
-   enc->enc_pic.pc.enc_constraint_set_flags = 0x0040;
+   enc->enc_pic.pc.enc_cabac_enable = pic->pic_ctrl.enc_cabac_enable;
+   enc->enc_pic.pc.enc_constraint_set_flags = 
pic->pic_ctrl.enc_constraint_set_flags;
enc->enc_pic.pc.enc_num_default_active_ref_l0 = 0x0001;
enc->enc_pic.pc.enc_num_default_active_ref_l1 = 0x0001;
 }
@@ -113,7 +114,7 @@ static void get_config_ext_param(struct rvce_encoder *enc)
 
 static void get_vui_param(struct rvce_encoder *enc, struct 
pipe_h264_enc_picture_desc *pic)
 {
-   enc->enc_pic.enable_vui = (pic->rate_ctrl.frame_rate_num != 0);
+   enc->enc_pic.enable_vui = pic->enable_vui;
enc->enc_pic.vui.video_format = 0x0005;
enc->enc_pic.vui.color_prim = 0x0002;
enc->enc_pic.vui.transfer_char = 0x0002;
@@ -149,10 +150,16 @@ void radeon_vce_52_get_param(struct rvce_encoder *enc

Mesa (master): vl: add parameters for VAAPI encode

2016-07-14 Thread Christian König
Module: Mesa
Branch: master
Commit: b86bf4b568634b4bf11c645c60025840a0dcab5c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b86bf4b568634b4bf11c645c60025840a0dcab5c

Author: Boyuan Zhang <boyuan.zh...@amd.com>
Date:   Wed Jul 13 18:51:11 2016 -0400

vl: add parameters for VAAPI encode

Allow to specify more parameters in the encoding interface
which previously just hardcoded in the encoder

Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/include/pipe/p_video_state.h | 33 
 1 file changed, 33 insertions(+)

diff --git a/src/gallium/include/pipe/p_video_state.h 
b/src/gallium/include/pipe/p_video_state.h
index d353be6..754d013 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -352,9 +352,29 @@ struct pipe_h264_enc_rate_control
unsigned frame_rate_num;
unsigned frame_rate_den;
unsigned vbv_buffer_size;
+   unsigned vbv_buf_lv;
unsigned target_bits_picture;
unsigned peak_bits_picture_integer;
unsigned peak_bits_picture_fraction;
+   unsigned fill_data_enable;
+   unsigned enforce_hrd;
+};
+
+struct pipe_h264_enc_motion_estimation
+{
+   unsigned motion_est_quarter_pixel;
+   unsigned enc_disable_sub_mode;
+   unsigned lsmvert;
+   unsigned enc_en_ime_overw_dis_subm;
+   unsigned enc_ime_overw_dis_subm_no;
+   unsigned enc_ime2_search_range_x;
+   unsigned enc_ime2_search_range_y;
+};
+
+struct pipe_h264_enc_pic_control
+{
+   unsigned enc_cabac_enable;
+   unsigned enc_constraint_set_flags;
 };
 
 struct pipe_h264_enc_picture_desc
@@ -363,17 +383,30 @@ struct pipe_h264_enc_picture_desc
 
struct pipe_h264_enc_rate_control rate_ctrl;
 
+   struct pipe_h264_enc_motion_estimation motion_est;
+   struct pipe_h264_enc_pic_control pic_ctrl;
+
unsigned quant_i_frames;
unsigned quant_p_frames;
unsigned quant_b_frames;
 
enum pipe_h264_enc_picture_type picture_type;
unsigned frame_num;
+   unsigned frame_num_cnt;
+   unsigned p_remain;
+   unsigned i_remain;
+   unsigned idr_pic_id;
+   unsigned gop_cnt;
unsigned pic_order_cnt;
unsigned ref_idx_l0;
unsigned ref_idx_l1;
+   unsigned gop_size;
+   unsigned ref_pic_mode;
 
bool not_referenced;
+   bool is_idr;
+   bool enable_vui;
+   unsigned int frame_idx[32];
 };
 
 struct pipe_h265_sps

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


Mesa (master): st/omx: assign previous values to new structure

2016-07-14 Thread Christian König
Module: Mesa
Branch: master
Commit: 5490068fb146dc2d391cf7f7c4eb875ac6973e88
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5490068fb146dc2d391cf7f7c4eb875ac6973e88

Author: Boyuan Zhang <boyuan.zh...@amd.com>
Date:   Wed Jul 13 18:51:13 2016 -0400

st/omx: assign previous values to new structure

Assign previously hardcoded values for OMX to newly defined
structure. As a result, OMX behaviour will not change at all.

Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/omx/vid_enc.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/gallium/state_trackers/omx/vid_enc.c 
b/src/gallium/state_trackers/omx/vid_enc.c
index d70439a..bbc7941 100644
--- a/src/gallium/state_trackers/omx/vid_enc.c
+++ b/src/gallium/state_trackers/omx/vid_enc.c
@@ -1006,6 +1006,14 @@ static void enc_ScaleInput(omx_base_PortType *port, 
struct pipe_video_buffer **v
priv->current_scale_buffer %= OMX_VID_ENC_NUM_SCALING_BUFFERS;
 }
 
+static void enc_GetPictureParamPreset(struct pipe_h264_enc_picture_desc 
*picture)
+{
+   picture->motion_est.enc_disable_sub_mode = 0x00fe;
+   picture->motion_est.enc_ime2_search_range_x = 0x0001;
+   picture->motion_est.enc_ime2_search_range_y = 0x0001;
+   picture->pic_ctrl.enc_constraint_set_flags = 0x0040;
+}
+
 static void enc_ControlPicture(omx_base_PortType *port, struct 
pipe_h264_enc_picture_desc *picture)
 {
OMX_COMPONENTTYPE* comp = port->standCompContainer;
@@ -1064,6 +1072,8 @@ static void enc_ControlPicture(omx_base_PortType *port, 
struct pipe_h264_enc_pic
picture->frame_num = priv->frame_num;
picture->ref_idx_l0 = priv->ref_idx_l0;
picture->ref_idx_l1 = priv->ref_idx_l1;
+   picture->enable_vui = (picture->rate_ctrl.frame_rate_num != 0);
+   enc_GetPictureParamPreset(picture);
 }
 
 static void enc_HandleTask(omx_base_PortType *port, struct encode_task *task,

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


Mesa (master): st/mesa: fix reference counting bug in st_vdpau

2016-07-14 Thread Christian König
Module: Mesa
Branch: master
Commit: 9ce52baf7f479d506bcea17a371dcf2fad92f139
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9ce52baf7f479d506bcea17a371dcf2fad92f139

Author: Christian König <christian.koe...@amd.com>
Date:   Wed Jul 13 14:54:31 2016 +0200

st/mesa: fix reference counting bug in st_vdpau

Otherwise we leak the resources created for the DMA-buf descriptors.

Signed-off-by: Christian König <christian.koe...@amd.com>
Cc: 12.0 <mesa-sta...@lists.freedesktop.org>
Tested-and-Reviewed by: Leo Liu <leo@amd.com>
Ack-by: Tom St Denis <tom.stde...@amd.com>

---

 src/mesa/state_tracker/st_vdpau.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_vdpau.c 
b/src/mesa/state_tracker/st_vdpau.c
index dffa52f..4f599dd 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -65,6 +65,7 @@ st_vdpau_video_surface_gallium(struct gl_context *ctx, const 
void *vdpSurface,
 
struct pipe_video_buffer *buffer;
struct pipe_sampler_view **samplers;
+   struct pipe_resource *res = NULL;
 
getProcAddr = (void *)ctx->vdpGetProcAddress;
if (getProcAddr(device, VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM, (void**)))
@@ -82,7 +83,8 @@ st_vdpau_video_surface_gallium(struct gl_context *ctx, const 
void *vdpSurface,
if (!sv)
   return NULL;
 
-   return sv->texture;
+   pipe_resource_reference(, sv->texture);
+   return res;
 }
 
 static struct pipe_resource *
@@ -90,13 +92,15 @@ st_vdpau_output_surface_gallium(struct gl_context *ctx, 
const void *vdpSurface)
 {
int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
uint32_t device = (uintptr_t)ctx->vdpDevice;
+   struct pipe_resource *res = NULL;
VdpOutputSurfaceGallium *f;
 
getProcAddr = (void *)ctx->vdpGetProcAddress;
if (getProcAddr(device, VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM, (void**)))
   return NULL;
 
-   return f((uintptr_t)vdpSurface);
+   pipe_resource_reference(, f((uintptr_t)vdpSurface));
+   return res;
 }
 
 static struct pipe_resource *
@@ -208,6 +212,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, 
GLenum access,
/* do we have different screen objects ? */
if (res->screen != st->pipe->screen) {
   _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV");
+  pipe_resource_reference(, NULL);
   return;
}
 
@@ -241,6 +246,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, 
GLenum access,
stObj->surface_format = res->format;
 
_mesa_dirty_texobj(ctx, texObj);
+   pipe_resource_reference(, NULL);
 }
 
 static void

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


Mesa (master): radeon/uvd: fix overflow error while calculating bit stream buffer size

2016-07-04 Thread Christian König
Module: Mesa
Branch: master
Commit: 51227b41c6b026f5b0a3925093b91800cdfcc923
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=51227b41c6b026f5b0a3925093b91800cdfcc923

Author: Indrajit Das <indrajit-kumar@amd.com>
Date:   Fri May 27 18:45:15 2016 +0530

radeon/uvd: fix overflow error while calculating bit stream buffer size

Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/drivers/radeon/radeon_uvd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/radeon_uvd.c 
b/src/gallium/drivers/radeon/radeon_uvd.c
index 97765da..7223417 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -1233,7 +1233,7 @@ struct pipe_video_codec *ruvd_create_decoder(struct 
pipe_context *context,
 
dec->fb_size = (info.family == CHIP_TONGA) ? FB_BUFFER_SIZE_TONGA :
FB_BUFFER_SIZE;
-   bs_buf_size = width * height * 512 / (16 * 16);
+   bs_buf_size = width * height * (512 / (16 * 16));
for (i = 0; i < NUM_BUFFERS; ++i) {
unsigned msg_fb_it_size = FB_BUFFER_OFFSET + dec->fb_size;
STATIC_ASSERT(sizeof(struct ruvd_msg) <= FB_BUFFER_OFFSET);

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


Mesa (master): st/vdpau: use bicubic filter for scaling(v6.1)

2016-07-01 Thread Christian König
Module: Mesa
Branch: master
Commit: de772bc060fb401e30cfbfa4ae3973fb025865e5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=de772bc060fb401e30cfbfa4ae3973fb025865e5

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Wed Jun 29 19:12:01 2016 +0530

st/vdpau: use bicubic filter for scaling(v6.1)

use bicubic filtering as high quality scaling L1.

v2: fix a typo and add a newline to code
v3: -render the unscaled image on a temporary surface (Christian)
-apply noise reduction and sharpness filter on
 unscaled surface
-render the final scaled surface using bicubic
 interpolation
v4: support high quality scaling
v5: set dst_area and dst_clip in bicubic filter
v6: set buffer layer before setting dst_area
v6.1: add PIPE_BIND_LINEAR when creating resource

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/mixer.c | 113 ---
 src/gallium/state_trackers/vdpau/query.c |   1 +
 src/gallium/state_trackers/vdpau/vdpau_private.h |   6 ++
 3 files changed, 106 insertions(+), 14 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/mixer.c 
b/src/gallium/state_trackers/vdpau/mixer.c
index 65c3ce2..cb0ef03 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -82,7 +82,6 @@ vlVdpVideoMixerCreate(VdpDevice device,
   switch (features[i]) {
   /* they are valid, but we doesn't support them */
   case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
-  case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
@@ -110,6 +109,9 @@ vlVdpVideoMixerCreate(VdpDevice device,
  vmixer->luma_key.supported = true;
  break;
 
+  case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
+ vmixer->bicubic.supported = true;
+ break;
   default: goto no_params;
   }
}
@@ -202,6 +204,11 @@ vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
   vl_matrix_filter_cleanup(vmixer->sharpness.filter);
   FREE(vmixer->sharpness.filter);
}
+
+   if (vmixer->bicubic.filter) {
+  vl_bicubic_filter_cleanup(vmixer->bicubic.filter);
+  FREE(vmixer->bicubic.filter);
+   }
pipe_mutex_unlock(vmixer->device->mutex);
DeviceReference(>device, NULL);
 
@@ -230,9 +237,11 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
 VdpLayer const *layers)
 {
enum vl_compositor_deinterlace deinterlace;
-   struct u_rect rect, clip, *prect;
+   struct u_rect rect, clip, *prect, dirty_area;
unsigned i, layer = 0;
struct pipe_video_buffer *video_buffer;
+   struct pipe_sampler_view *sampler_view;
+   struct pipe_surface *surface;
 
vlVdpVideoMixer *vmixer;
vlVdpSurface *surf;
@@ -325,7 +334,44 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
   prect = 
}
vl_compositor_set_buffer_layer(>cstate, compositor, layer, 
video_buffer, prect, NULL, deinterlace);
-   vl_compositor_set_layer_dst_area(>cstate, layer++, 
RectToPipe(destination_video_rect, ));
+
+   if(vmixer->bicubic.filter) {
+  struct pipe_context *pipe;
+  struct pipe_resource res_tmpl, *res;
+  struct pipe_sampler_view sv_templ;
+  struct pipe_surface surf_templ;
+
+  pipe = vmixer->device->context;
+  memset(_tmpl, 0, sizeof(res_tmpl));
+
+  res_tmpl.target = PIPE_TEXTURE_2D;
+  res_tmpl.width0 = surf->templat.width;
+  res_tmpl.height0 = surf->templat.height;
+  res_tmpl.format = dst->sampler_view->format;
+  res_tmpl.depth0 = 1;
+  res_tmpl.array_size = 1;
+  res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
+  PIPE_BIND_LINEAR;
+  res_tmpl.usage = PIPE_USAGE_DEFAULT;
+
+  res = pipe->screen->resource_create(pipe->screen, _tmpl);
+
+  vlVdpDefaultSamplerViewTemplate(_templ, res);
+  sampler_view = pipe->create_sampler_view(pipe, res, _templ);
+
+  memset(_templ, 0, sizeof(surf_templ));
+  surf_templ.format = res->format;
+  surface = pipe->create_surface(pipe, res, _templ);
+
+  vl_compositor_reset_dirty_area(_area);
+  pipe_resource_reference(, NULL);
+   } else {
+  surface = dst->surface;
+  sampler_view = dst->sampler_view;
+  dirty_area = dst->dirty_area;
+  vl_compositor_set_layer_dst_area(>cstate, layer++, 
RectToPipe(destination_video_rect, ));
+  vl_compositor_set_dst_clip(>cstate, RectToPipe(destination_rect, 
));
+   }
 
for (i = 0; i < layer_count; ++i) {
   vlVdpOutputSurface *src = vlGetDataHTAB(layers->source_surface);
@@ -343,22 +389,29 @@ VdpStatus vlVdpVideoMixerRender

Mesa (master): vl: add a bicubic interpolation filter(v5)

2016-07-01 Thread Christian König
Module: Mesa
Branch: master
Commit: 872dd9ad154b0ef9c91486640f73232a60074292
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=872dd9ad154b0ef9c91486640f73232a60074292

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Wed Jun 29 19:12:00 2016 +0530

vl: add a bicubic interpolation filter(v5)

This is a shader based bicubic interpolater which uses cubic
Hermite spline algorithm.

v2: set dst_area and dst_clip during scaling (Christian)
v3: clear the render target before rendering
v4: intialize offsets while initializing shaders
use a constant buffer to send dst_size to frag shader
small changes to reduce calculation in shader
v5: send half pixel offset instead of sending dst_size

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/auxiliary/Makefile.sources   |   2 +
 src/gallium/auxiliary/vl/vl_bicubic_filter.c | 463 +++
 src/gallium/auxiliary/vl/vl_bicubic_filter.h |  63 
 3 files changed, 528 insertions(+)

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index ab58358..e0311bf 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -317,6 +317,8 @@ NIR_SOURCES := \
nir/tgsi_to_nir.h
 
 VL_SOURCES := \
+   vl/vl_bicubic_filter.c \
+   vl/vl_bicubic_filter.h \
vl/vl_compositor.c \
vl/vl_compositor.h \
vl/vl_csc.c \
diff --git a/src/gallium/auxiliary/vl/vl_bicubic_filter.c 
b/src/gallium/auxiliary/vl/vl_bicubic_filter.c
new file mode 100644
index 000..ca9f882
--- /dev/null
+++ b/src/gallium/auxiliary/vl/vl_bicubic_filter.c
@@ -0,0 +1,463 @@
+/**
+ *
+ * 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_bicubic_filter.h"
+
+enum VS_OUTPUT
+{
+   VS_O_VPOS = 0,
+   VS_O_VTEX = 0
+};
+
+static void *
+create_vert_shader(struct vl_bicubic_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_cubic_interpolater(struct ureg_program *shader, struct 
ureg_src tex_a,
+  struct ureg_src tex_b, struct ureg_src 
tex_c,
+  struct ureg_src tex_d, struct ureg_src t,
+  struct ureg_dst o_fragment)
+{
+   struct ureg_dst temp[11];
+   struct ureg_dst t_2;
+   unsigned i;
+
+   for(i = 0; i < 11; ++i)
+   temp[i] = ureg_DECL_temporary(shader);
+   t_2 = ureg_DECL_temporary(shader);
+
+   /*
+* |temp[0]|   |  0  2  0  0 |  |tex_a|
+* |temp[1]| = | -1  0  1  0 |* |tex_b|
+* |temp[2]|   |  2 -5  4 -1 |  |tex_c|
+* |temp[3]|   | -1  3 -3  1 |  |tex_d|
+*/
+   ureg_MUL(shader, temp[0], tex_b, ureg_imm1f(shader, 2.0f));
+
+   ureg_MUL(shader, t

Mesa (master): st/vdpau: we support lumakeying now

2016-06-16 Thread Christian König
Module: Mesa
Branch: master
Commit: 6d877d7121fdf16c91897b99ffd40d549d06d3a9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d877d7121fdf16c91897b99ffd40d549d06d3a9

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jun  9 14:44:39 2016 +0200

st/vdpau: we support lumakeying now

Signed-off-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/query.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/state_trackers/vdpau/query.c 
b/src/gallium/state_trackers/vdpau/query.c
index 6e9cdd9..c3decc0 100644
--- a/src/gallium/state_trackers/vdpau/query.c
+++ b/src/gallium/state_trackers/vdpau/query.c
@@ -470,6 +470,7 @@ vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, 
VdpVideoMixerFeature featur
case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
+   case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
   *is_supported = VDP_TRUE;
   break;
default:

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


Mesa (master): vl: support luma keying for interlaced surfaces as well

2016-06-16 Thread Christian König
Module: Mesa
Branch: master
Commit: bf89e672cff432a5e2ace72c0fb73eb8f120ff7a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf89e672cff432a5e2ace72c0fb73eb8f120ff7a

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jun  9 14:43:10 2016 +0200

vl: support luma keying for interlaced surfaces as well

We had the CSC code twice in there, factor it out into a separate function.

Signed-off-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/auxiliary/vl/vl_compositor.c | 76 +---
 1 file changed, 41 insertions(+), 35 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_compositor.c 
b/src/gallium/auxiliary/vl/vl_compositor.c
index 1a383f2..77fc92e 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -125,17 +125,51 @@ create_vert_shader(struct vl_compositor *c)
return ureg_create_shader_and_destroy(shader, c->pipe);
 }
 
+static void
+create_frag_shader_csc(struct ureg_program *shader, struct ureg_dst texel,
+  struct ureg_dst fragment)
+{
+   struct ureg_src csc[3];
+   struct ureg_src lumakey;
+   struct ureg_dst temp[2];
+   unsigned i;
+
+   for (i = 0; i < 3; ++i)
+  csc[i] = ureg_DECL_constant(shader, i);
+
+   lumakey = ureg_DECL_constant(shader, 3);
+
+   for (i = 0; i < 2; ++i)
+  temp[i] = ureg_DECL_temporary(shader);
+
+   ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_W),
+   ureg_imm1f(shader, 1.0f));
+
+   for (i = 0; i < 3; ++i)
+  ureg_DP4(shader, ureg_writemask(fragment, TGSI_WRITEMASK_X << i), csc[i],
+  ureg_src(texel));
+
+   ureg_MOV(shader, ureg_writemask(temp[0], TGSI_WRITEMASK_W),
+ureg_scalar(ureg_src(texel), TGSI_SWIZZLE_Z));
+   ureg_SLE(shader, ureg_writemask(temp[1],TGSI_WRITEMASK_W),
+ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_X));
+   ureg_SGT(shader, ureg_writemask(temp[0],TGSI_WRITEMASK_W),
+ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_Y));
+   ureg_MAX(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W),
+ureg_src(temp[0]), ureg_src(temp[1]));
+
+   for (i = 0; i < 2; ++i)
+   ureg_release_temporary(shader, temp[i]);
+}
+
 static void *
 create_frag_shader_video_buffer(struct vl_compositor *c)
 {
struct ureg_program *shader;
struct ureg_src tc;
-   struct ureg_src csc[3];
struct ureg_src sampler[3];
-   struct ureg_src lumakey;
struct ureg_dst texel;
struct ureg_dst fragment;
-   struct ureg_dst temp[2];
unsigned i;
 
shader = ureg_create(PIPE_SHADER_FRAGMENT);
@@ -143,15 +177,9 @@ create_frag_shader_video_buffer(struct vl_compositor *c)
   return false;
 
tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX, 
TGSI_INTERPOLATE_LINEAR);
-   for (i = 0; i < 3; ++i) {
-  csc[i] = ureg_DECL_constant(shader, i);
+   for (i = 0; i < 3; ++i)
   sampler[i] = ureg_DECL_sampler(shader, i);
-   }
-
-   for (i = 0; i < 2; ++i)
-  temp[i] = ureg_DECL_temporary(shader);
 
-   lumakey = ureg_DECL_constant(shader, 3);
texel = ureg_DECL_temporary(shader);
fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
 
@@ -162,22 +190,7 @@ create_frag_shader_video_buffer(struct vl_compositor *c)
for (i = 0; i < 3; ++i)
   ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), 
TGSI_TEXTURE_2D_ARRAY, tc, sampler[i]);
 
-   ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_W), 
ureg_imm1f(shader, 1.0f));
-
-   for (i = 0; i < 3; ++i)
-  ureg_DP4(shader, ureg_writemask(fragment, TGSI_WRITEMASK_X << i), 
csc[i], ureg_src(texel));
-
-   ureg_MOV(shader, ureg_writemask(temp[0], TGSI_WRITEMASK_W),
-ureg_scalar(ureg_src(texel), TGSI_SWIZZLE_Z));
-   ureg_SLE(shader, ureg_writemask(temp[1],TGSI_WRITEMASK_W),
-ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_X));
-   ureg_SGT(shader, ureg_writemask(temp[0],TGSI_WRITEMASK_W),
-ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_Y));
-   ureg_MAX(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W),
-ureg_src(temp[0]), ureg_src(temp[1]));
-
-   for (i = 0; i < 2; ++i)
-   ureg_release_temporary(shader, temp[i]);
+   create_frag_shader_csc(shader, texel, fragment);
 
ureg_release_temporary(shader, texel);
ureg_END(shader);
@@ -190,7 +203,6 @@ create_frag_shader_weave(struct vl_compositor *c)
 {
struct ureg_program *shader;
struct ureg_src i_tc[2];
-   struct ureg_src csc[3];
struct ureg_src sampler[3];
struct ureg_dst t_tc[2];
struct ureg_dst t_texel[2];
@@ -204,10 +216,8 @@ create_frag_shader_weave(struct vl_compositor *c)
i_tc[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTOP, 
TGSI_INTERPOLATE_LINEAR);
i_tc[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VBOTTOM, 
TGSI_INTERPOLATE_LINEAR);
 
-   for (i = 0; i < 3; ++i) {
-  

Mesa (master): st/vdpau: implement luma keying

2016-06-09 Thread Christian König
Module: Mesa
Branch: master
Commit: 2d140ae70ac6ad69f39d427d95bd622d5640a1b7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d140ae70ac6ad69f39d427d95bd622d5640a1b7

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Wed Jun  8 15:24:25 2016 +0530

st/vdpau: implement luma keying

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/mixer.c | 45 ++--
 src/gallium/state_trackers/vdpau/vdpau_private.h |  6 +++-
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/mixer.c 
b/src/gallium/state_trackers/vdpau/mixer.c
index 1070e96..b12a580 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -92,7 +92,6 @@ vlVdpVideoMixerCreate(VdpDevice device,
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
   case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
-  case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
  break;
 
   case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
@@ -107,6 +106,10 @@ vlVdpVideoMixerCreate(VdpDevice device,
  vmixer->noise_reduction.supported = true;
  break;
 
+  case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
+ vmixer->luma_key.supported = true;
+ break;
+
   default: goto no_params;
   }
}
@@ -148,8 +151,8 @@ vlVdpVideoMixerCreate(VdpDevice device,
 vmixer->video_height, max_size);
   goto no_params;
}
-   vmixer->luma_key_min = 0.f;
-   vmixer->luma_key_max = 1.f;
+   vmixer->luma_key.luma_min = 1.0f;
+   vmixer->luma_key.luma_max = 0.0f;
pipe_mutex_unlock(dev->mutex);
 
return VDP_STATUS_OK;
@@ -490,7 +493,6 @@ vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
   case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
-  case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
  feature_supports[i] = false;
  break;
 
@@ -506,6 +508,10 @@ vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
  feature_supports[i] = vmixer->noise_reduction.supported;
  break;
 
+  case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
+ feature_supports[i] = vmixer->luma_key.supported;
+ break;
+
   default:
  return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
   }
@@ -548,7 +554,6 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
   case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
-  case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
  break;
 
   case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
@@ -566,6 +571,13 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
  vlVdpVideoMixerUpdateNoiseReductionFilter(vmixer);
  break;
 
+  case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
+ vmixer->luma_key.enabled = feature_enables[i];
+ if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
+vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc,
+ vmixer->luma_key.luma_min, 
vmixer->luma_key.luma_max);
+ break;
+
   default:
  pipe_mutex_unlock(vmixer->device->mutex);
  return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
@@ -610,7 +622,6 @@ vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
   case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
-  case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
  break;
 
   case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
@@ -621,6 +632,10 @@ vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,
  feature_enables[i] = vmixer->noise_reduction.enabled;
  break;
 
+  case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
+ feature_enables[i] = vmixer->luma_key.enabled;
+ break;
+
   default:
  return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
   }
@@ -671,7 +686,8 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
  else
 memcpy(vmixer->csc, vdp_csc, sizeof(vl_csc_matrix));
  if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
-vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc, 1.0f, 0.0f);
+vl_compositor_set_csc_matrix(>cstate, (const vl_csc_matrix 
*)>csc,
+ vmixer->luma_key.luma_min, 
vmixer->luma_key.luma_max);
  break;
 
   case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
@@ -692,15 +708,22 @@ v

Mesa (master): vl: Apply luma key filter before CSC conversion

2016-06-09 Thread Christian König
Module: Mesa
Branch: master
Commit: f24eb5a17830b8137045a626dbd55e75ed5e708d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f24eb5a17830b8137045a626dbd55e75ed5e708d

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Wed Jun  8 15:10:48 2016 +0530

vl: Apply luma key filter before CSC conversion

Apply the luma key filter to the YCbCr values during the CSC conversion
in video buffer shader. The initial values of max and min luma are set
to opposite values to disable the filter initially and will be set when
enabling it.

Add extra parmeters min and max luma for the luma key filter in
vl_compositor_set_csc_matrix in va, xvmc. Setting them
to opposite value 1.f and 0.f respectively won't effect the CSC
conversion

v2: -Squash 1,2 and 3 into one patch to avoid breaking build of
other components. (Christian)
-use ureg_swizzle. (Christian)
-change name of the variables. (Christian)

v3: -Squash all patches in one to avoid breaking of build. (Emil)
-wrap functions properly. (Emil)
-use 0.0f and 1.0f instead of 0.f and 1.f respectively. (Emil)

v4: -Divide it in two patches one which introduces the functionality
 and assigs dummy values to the changed functions and second which
 implements the lumakey filter. (Christian)
-use ureg_scalar instead ureg_swizzle. (Christian)

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/auxiliary/vl/vl_compositor.c | 44 
 src/gallium/auxiliary/vl/vl_compositor.h |  4 ++-
 src/gallium/state_trackers/va/context.c  |  2 +-
 src/gallium/state_trackers/vdpau/mixer.c |  4 +--
 src/gallium/state_trackers/vdpau/output.c|  4 +--
 src/gallium/state_trackers/xvmc/attributes.c |  2 +-
 src/gallium/state_trackers/xvmc/context.c|  2 +-
 7 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_compositor.c 
b/src/gallium/auxiliary/vl/vl_compositor.c
index acb2f4f..1a383f2 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -132,8 +132,10 @@ create_frag_shader_video_buffer(struct vl_compositor *c)
struct ureg_src tc;
struct ureg_src csc[3];
struct ureg_src sampler[3];
+   struct ureg_src lumakey;
struct ureg_dst texel;
struct ureg_dst fragment;
+   struct ureg_dst temp[2];
unsigned i;
 
shader = ureg_create(PIPE_SHADER_FRAGMENT);
@@ -145,6 +147,11 @@ create_frag_shader_video_buffer(struct vl_compositor *c)
   csc[i] = ureg_DECL_constant(shader, i);
   sampler[i] = ureg_DECL_sampler(shader, i);
}
+
+   for (i = 0; i < 2; ++i)
+  temp[i] = ureg_DECL_temporary(shader);
+
+   lumakey = ureg_DECL_constant(shader, 3);
texel = ureg_DECL_temporary(shader);
fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
 
@@ -160,7 +167,17 @@ create_frag_shader_video_buffer(struct vl_compositor *c)
for (i = 0; i < 3; ++i)
   ureg_DP4(shader, ureg_writemask(fragment, TGSI_WRITEMASK_X << i), 
csc[i], ureg_src(texel));
 
-   ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), 
ureg_imm1f(shader, 1.0f));
+   ureg_MOV(shader, ureg_writemask(temp[0], TGSI_WRITEMASK_W),
+ureg_scalar(ureg_src(texel), TGSI_SWIZZLE_Z));
+   ureg_SLE(shader, ureg_writemask(temp[1],TGSI_WRITEMASK_W),
+ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_X));
+   ureg_SGT(shader, ureg_writemask(temp[0],TGSI_WRITEMASK_W),
+ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_Y));
+   ureg_MAX(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W),
+ureg_src(temp[0]), ureg_src(temp[1]));
+
+   for (i = 0; i < 2; ++i)
+   ureg_release_temporary(shader, temp[i]);
 
ureg_release_temporary(shader, texel);
ureg_END(shader);
@@ -852,20 +869,23 @@ vl_compositor_cleanup(struct vl_compositor *c)
 }
 
 void
-vl_compositor_set_csc_matrix(struct vl_compositor_state *s, vl_csc_matrix 
const *matrix)
+vl_compositor_set_csc_matrix(struct vl_compositor_state *s,
+ vl_csc_matrix const *matrix,
+ float luma_min, float luma_max)
 {
struct pipe_transfer *buf_transfer;
 
assert(s);
 
-   memcpy
-   (
-  pipe_buffer_map(s->pipe, s->csc_matrix,
-  PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
-  _transfer),
-  matrix,
-  sizeof(vl_csc_matrix)
-   );
+   float *ptr = pipe_buffer_map(s->pipe, s->csc_matrix,
+   PIPE_TRANSFER_WRITE | 
PIPE_TRANSFER_DISCARD_RANGE,
+   _transfer);
+
+   memcpy(ptr, matrix, sizeof(vl_csc_matrix));
+
+   ptr += sizeof(vl_csc_matrix)/sizeof(float);
+   ptr[0] = luma_min;
+   ptr[1] = luma_max;
 
pipe_buffer_unmap(s->pipe, buf_transfer);
 }

Mesa (master): radeon/uvd: fix the H264 level for Tonga v2

2016-06-02 Thread Christian König
Module: Mesa
Branch: master
Commit: b3e75c39976c03f73128ffd802465799ac0e4ef5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b3e75c39976c03f73128ffd802465799ac0e4ef5

Author: Christian König <christian.koe...@amd.com>
Date:   Wed May 25 16:55:48 2016 +0200

radeon/uvd: fix the H264 level for Tonga v2

We support 5.2 for a while now.

v2: we even support 5.2 for H264, 5.1 is for HEVC.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
Cc: <mesa-sta...@lists.freedesktop.org>

---

 src/gallium/drivers/radeon/radeon_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/radeon_video.c 
b/src/gallium/drivers/radeon/radeon_video.c
index da65ce8..aba1404 100644
--- a/src/gallium/drivers/radeon/radeon_video.c
+++ b/src/gallium/drivers/radeon/radeon_video.c
@@ -298,7 +298,7 @@ int rvid_get_video_param(struct pipe_screen *screen,
case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
-   return 41;
+   return (rscreen->family < CHIP_TONGA) ? 41 : 52;
case PIPE_VIDEO_PROFILE_HEVC_MAIN:
case PIPE_VIDEO_PROFILE_HEVC_MAIN_10:
return 186;

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


Mesa (master): st/vdpau: check for null pointer in get/put bits.

2016-06-02 Thread Christian König
Module: Mesa
Branch: master
Commit: 6c9a352d79e215b545b5d400ae946a27d56e4abd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6c9a352d79e215b545b5d400ae946a27d56e4abd

Author: Nayan Deshmukh <nayan26deshm...@gmail.com>
Date:   Thu Jun  2 12:29:58 2016 +0530

st/vdpau: check for null pointer in get/put bits.

Check for null pointer before accessing arrays in get/put bits
native/YCbCr/Indexed in VdpOutputSurface and VdpVideoSurface.

Signed-off-by: Nayan Deshmukh <nayan26deshm...@gmail.com>
Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/output.c  | 6 ++
 src/gallium/state_trackers/vdpau/surface.c | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index c644cc8..2192f71 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -205,6 +205,9 @@ vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
if (!pipe)
   return VDP_STATUS_INVALID_HANDLE;
 
+   if (!destination_data || !destination_pitches)
+   return VDP_STATUS_INVALID_POINTER;
+
pipe_mutex_lock(vlsurface->device->mutex);
vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
 
@@ -247,6 +250,9 @@ vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface,
if (!pipe)
   return VDP_STATUS_INVALID_HANDLE;
 
+   if (!source_data || !source_pitches)
+   return VDP_STATUS_INVALID_POINTER;
+
pipe_mutex_lock(vlsurface->device->mutex);
vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
 
diff --git a/src/gallium/state_trackers/vdpau/surface.c 
b/src/gallium/state_trackers/vdpau/surface.c
index d418d56..7998527 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -215,6 +215,9 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
if (!pipe)
   return VDP_STATUS_INVALID_HANDLE;
 
+   if (!destination_data || !destination_pitches)
+   return VDP_STATUS_INVALID_POINTER;
+
format = FormatYCBCRToPipe(destination_ycbcr_format);
if (format == PIPE_FORMAT_NONE)
   return VDP_STATUS_INVALID_Y_CB_CR_FORMAT;
@@ -313,6 +316,9 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
if (!pipe)
   return VDP_STATUS_INVALID_HANDLE;
 
+   if (!source_data || !source_pitches)
+   return VDP_STATUS_INVALID_POINTER;
+
pipe_mutex_lock(p_surf->device->mutex);
if (p_surf->video_buffer == NULL || pformat != 
p_surf->video_buffer->buffer_format) {
 

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


Mesa (master): st/vdpau: correct null check

2016-03-30 Thread Christian König
Module: Mesa
Branch: master
Commit: 9a73f5728e9b834c51128e34317854702281bf3e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a73f5728e9b834c51128e34317854702281bf3e

Author: Thomas Hindoe Paaboel Andersen <pho...@gmail.com>
Date:   Wed Mar 30 08:13:24 2016 +0200

st/vdpau: correct null check

The null check of result was the wrong way around. Also, move memset
and dereference of result after the null check.

Reviewed-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/vdpau/surface.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/surface.c 
b/src/gallium/state_trackers/vdpau/surface.c
index 0550141..d418d56 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -426,18 +426,18 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
 
struct pipe_surface *surf;
 
-   memset(result, 0, sizeof(*result));
-   result->handle = -1;
-
if (!p_surf)
   return VDP_STATUS_INVALID_HANDLE;
 
if (plane > 3)
   return VDP_STATUS_INVALID_VALUE;
 
-   if (result)
+   if (!result)
   return VDP_STATUS_INVALID_POINTER;
 
+   memset(result, 0, sizeof(*result));
+   result->handle = -1;
+
pipe_mutex_lock(p_surf->device->mutex);
if (p_surf->video_buffer == NULL) {
   struct pipe_context *pipe = p_surf->device->context;

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


Mesa (master): r600: ignore PIPE_BIND_LINEAR in *_is_format_supported

2016-03-30 Thread Christian König
Module: Mesa
Branch: master
Commit: 1faca438bdbf11d85a6158d41ea91cab40fc2033
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1faca438bdbf11d85a6158d41ea91cab40fc2033

Author: Christian König <christian.koe...@amd.com>
Date:   Wed Mar 30 15:38:29 2016 +0200

r600: ignore PIPE_BIND_LINEAR in *_is_format_supported

Similar to radeonsi linear layout should work for all not compressed
or depth/stencil formats. Fixes issues with VDPAU on r600.

Signed-off-by: Christian König <christian.koe...@amd.com>
Tested-by: Dieter Nützel <die...@nuetzel-hh.de>

---

 src/gallium/drivers/r600/evergreen_state.c | 5 +
 src/gallium/drivers/r600/r600_state.c  | 5 +
 2 files changed, 10 insertions(+)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 83313cb..6595267 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -299,6 +299,11 @@ boolean evergreen_is_format_supported(struct pipe_screen 
*screen,
if (usage & PIPE_BIND_TRANSFER_WRITE)
retval |= PIPE_BIND_TRANSFER_WRITE;
 
+   if ((usage & PIPE_BIND_LINEAR) &&
+   !util_format_is_compressed(format) &&
+   !(usage & PIPE_BIND_DEPTH_STENCIL))
+   retval |= PIPE_BIND_LINEAR;
+
return retval == usage;
 }
 
diff --git a/src/gallium/drivers/r600/r600_state.c 
b/src/gallium/drivers/r600/r600_state.c
index f902619..3189a13 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -239,6 +239,11 @@ boolean r600_is_format_supported(struct pipe_screen 
*screen,
if (usage & PIPE_BIND_TRANSFER_WRITE)
retval |= PIPE_BIND_TRANSFER_WRITE;
 
+   if ((usage & PIPE_BIND_LINEAR) &&
+   !util_format_is_compressed(format) &&
+   !(usage & PIPE_BIND_DEPTH_STENCIL))
+   retval |= PIPE_BIND_LINEAR;
+
return retval == usage;
 }
 

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


Mesa (master): st/vdpau: add new interop interface

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: faba96bc60bfcf28678781f20ee0a42eb1950018
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=faba96bc60bfcf28678781f20ee0a42eb1950018

Author: Christian König <christian.koe...@amd.com>
Date:   Tue Jan 12 16:07:58 2016 +0100

st/vdpau: add new interop interface

Use DMA-buf for the VDPAU interop interface instead of using
internal structures.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Leo Liu <leo@amd.com>

---

 src/gallium/include/state_tracker/vdpau_dmabuf.h  | 94 +++
 src/gallium/include/state_tracker/vdpau_interop.h |  7 +-
 2 files changed, 100 insertions(+), 1 deletion(-)

diff --git a/src/gallium/include/state_tracker/vdpau_dmabuf.h 
b/src/gallium/include/state_tracker/vdpau_dmabuf.h
new file mode 100644
index 000..886c344
--- /dev/null
+++ b/src/gallium/include/state_tracker/vdpau_dmabuf.h
@@ -0,0 +1,94 @@
+/**
+ *
+ * Copyright 2016 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, 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 THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ **/
+
+/*
+ * Authors:
+ *  Christian König <christian.koe...@amd.com>
+ *
+ */
+
+#ifndef _VDPAU_DMABUF_H_
+#define _VDPAU_DMABUF_H_
+
+#include 
+
+/* driver specific functions for NV_vdpau_interop */
+#ifndef VDP_FUNC_ID_BASE_DRIVER
+#define VDP_FUNC_ID_BASE_DRIVER 0x2000
+#endif
+
+/* New DMA-buf based implementation */
+#define VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 2)
+#define VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 3)
+
+/* Define some more internal RGBA formats for more
+ * robust handling of Video Surfaces
+ */
+#define VDP_RGBA_FORMAT_R8  (-1)
+#define VDP_RGBA_FORMAT_R8G8(-2)
+
+struct VdpSurfaceDMABufDesc {
+   /* DMA-buf file descriptor */
+   uint32_t handle;
+   /* Width in pixel */
+   uint32_t width;
+   /* Height in pixel */
+   uint32_t height;
+   /* Offset in bytes */
+   uint32_t offset;
+   /* Stride in bytes */
+   uint32_t stride;
+   /* VDP_RGBA_FORMAT_* as defined in the VDPAU spec and above. */
+   uint32_t format;
+};
+
+/**
+ * \brief Video surface planes
+ */
+typedef uint32_t VdpVideoSurfacePlane;
+
+/** \hideinitializer \brief Luma top field */
+#define VDP_VIDEO_SURFACE_PLANE_LUMA_TOP  ((VdpVideoSurfacePlane)0)
+/** \hideinitializer \brief Luma bottom field */
+#define VDP_VIDEO_SURFACE_PLANE_LUMA_BOTTOM   ((VdpVideoSurfacePlane)1)
+/** \hideinitializer \brief Chroma top field */
+#define VDP_VIDEO_SURFACE_PLANE_CHROMA_TOP((VdpVideoSurfacePlane)2)
+/** \hideinitializer \brief Chroma bottom field */
+#define VDP_VIDEO_SURFACE_PLANE_CHROMA_BOTTOM ((VdpVideoSurfacePlane)3)
+
+typedef VdpStatus VdpVideoSurfaceDMABuf(
+   VdpVideoSurface   surface,
+   VdpVideoSurfacePlane  plane,
+   struct VdpSurfaceDMABufDesc * result
+);
+
+typedef VdpStatus VdpOutputSurfaceDMABuf(
+   VdpVideoSurface   surface,
+   struct VdpSurfaceDMABufDesc * result
+);
+
+#endif /* _VDPAU_DMABUF_H_ */
diff --git a/src/gallium/include/state_tracker/vdpau_interop.h 
b/src/gallium/include/state_tracker/vdpau_interop.h
index 3ca7c9d..04d455a 100644
--- a/src/gallium/include/state_tracker/vdpau_interop.h
+++ b/src/gallium/include/state_tracker/vdpau_interop.h
@@ -35,8 +35,13 @@
 #define _VDPAU_INTEROP_H_
 
 /* driver specific functions for NV_vdpau_interop */
-
+#ifndef VDP_FUNC_ID_BASE_DRIVER
 #define VDP_FUNC_ID_BASE_DRIVER 0x2000
+#endif
+
+/* Older implementation relying on passing pipe_video_buffer and
+ * pipe_resources around. Deprecated and shouldn't be used for new things.
+ */
 #define VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 0)
 #define VDP_FUNC_ID_OUTPUT_

Mesa (master): st/mesa: implement new DMA-buf based VDPAU interop v2

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: cc68dc2b5e3c603580f70d682b0772d179b28ce3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc68dc2b5e3c603580f70d682b0772d179b28ce3

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jan 14 16:46:57 2016 +0100

st/mesa: implement new DMA-buf based VDPAU interop v2

Avoid using internal structures from another API.

v2: rebase and moved includes so they don't cause problem when VDPAU isn't 
installed.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Marek Olšák <marek.ol...@amd.com> (v1)
Reviewed-by: Leo Liu <leo@amd.com>

---

 src/mesa/state_tracker/st_vdpau.c | 181 +++---
 1 file changed, 132 insertions(+), 49 deletions(-)

diff --git a/src/mesa/state_tracker/st_vdpau.c 
b/src/mesa/state_tracker/st_vdpau.c
index 71dd15b..b9abebf 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -39,8 +39,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_video_codec.h"
 
-#include "state_tracker/vdpau_interop.h"
-
 #include "util/u_inlines.h"
 
 #include "st_vdpau.h"
@@ -51,70 +49,155 @@
 
 #ifdef HAVE_ST_VDPAU
 
+#include "state_tracker/vdpau_interop.h"
+#include "state_tracker/vdpau_dmabuf.h"
+#include "state_tracker/vdpau_funcs.h"
+#include "state_tracker/drm_driver.h"
+
+static struct pipe_resource *
+st_vdpau_video_surface_gallium(struct gl_context *ctx, const GLvoid 
*vdpSurface,
+   GLuint index)
+{
+   int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
+   uint32_t device = (uintptr_t)ctx->vdpDevice;
+   struct pipe_sampler_view *sv;
+   VdpVideoSurfaceGallium *f;
+
+   struct pipe_video_buffer *buffer;
+   struct pipe_sampler_view **samplers;
+
+   getProcAddr = (void *)ctx->vdpGetProcAddress;
+   if (getProcAddr(device, VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM, (void**)))
+  return NULL;
+
+   buffer = f((uintptr_t)vdpSurface);
+   if (!buffer)
+  return NULL;
+
+   samplers = buffer->get_sampler_view_planes(buffer);
+   if (!samplers)
+  return NULL;
+
+   sv = samplers[index >> 1];
+   if (!sv)
+  return NULL;
+
+   return sv->texture;
+}
+
+static struct pipe_resource *
+st_vdpau_output_surface_gallium(struct gl_context *ctx, const GLvoid 
*vdpSurface)
+{
+   int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
+   uint32_t device = (uintptr_t)ctx->vdpDevice;
+   VdpOutputSurfaceGallium *f;
+
+   getProcAddr = (void *)ctx->vdpGetProcAddress;
+   if (getProcAddr(device, VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM, (void**)))
+  return NULL;
+
+   return f((uintptr_t)vdpSurface);
+}
+
+static struct pipe_resource *
+st_vdpau_resource_from_description(struct gl_context *ctx,
+   const struct VdpSurfaceDMABufDesc *desc)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_resource templ, *res;
+   struct winsys_handle whandle;
+
+   if (desc->handle == -1)
+  return NULL;
+
+   memset(, 0, sizeof(templ));
+   templ.target = PIPE_TEXTURE_2D;
+   templ.last_level = 0;
+   templ.depth0 = 1;
+   templ.array_size = 1;
+   templ.width0 = desc->width;
+   templ.height0 = desc->height;
+   templ.format = VdpFormatRGBAToPipe(desc->format);
+   templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+   templ.usage = PIPE_USAGE_DEFAULT;
+
+   memset(, 0, sizeof(whandle));
+   whandle.type = DRM_API_HANDLE_TYPE_FD;
+   whandle.handle = desc->handle;
+   whandle.offset = desc->offset;
+   whandle.stride = desc->stride;
+
+   res = st->pipe->screen->resource_from_handle(st->pipe->screen, , 
,
+   PIPE_HANDLE_USAGE_READ_WRITE);
+   close(desc->handle);
+
+   return res;
+}
+
+static struct pipe_resource *
+st_vdpau_output_surface_dma_buf(struct gl_context *ctx, const GLvoid 
*vdpSurface)
+{
+   int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
+   uint32_t device = (uintptr_t)ctx->vdpDevice;
+
+   struct VdpSurfaceDMABufDesc desc;
+   VdpOutputSurfaceDMABuf *f;
+
+   getProcAddr = (void *)ctx->vdpGetProcAddress;
+   if (getProcAddr(device, VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF, (void**)))
+  return NULL;
+
+   if (f((uintptr_t)vdpSurface, ) != VDP_STATUS_OK)
+  return NULL;
+
+   return st_vdpau_resource_from_description(ctx, );
+}
+
+static struct pipe_resource *
+st_vdpau_video_surface_dma_buf(struct gl_context *ctx, const GLvoid 
*vdpSurface,
+   GLuint index)
+{
+   int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
+   uint32_t device = (uintptr_t)ctx->vdpDevice;
+
+   struct VdpSurfaceDMABufDesc desc;
+   VdpVideoSurfaceDMABuf *f;
+
+   getProcAddr = (void *)ctx->vdpGetProcAddress;
+   if (getProcAddr(device, VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF, (void**)))
+  return N

Mesa (master): st/vdpau: move FormatRGBAToPipe into the interop

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: 0042aa508e19bb920d0ab385894cd3e03b9eafde
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0042aa508e19bb920d0ab385894cd3e03b9eafde

Author: Christian König <christian.koe...@amd.com>
Date:   Wed Jan 13 16:42:44 2016 +0100

st/vdpau: move FormatRGBAToPipe into the interop

We are going to need that in the Mesa state tracker as well.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Leo Liu <leo@amd.com>

---

 src/gallium/include/state_tracker/vdpau_funcs.h  | 65 
 src/gallium/state_trackers/vdpau/bitmap.c|  2 +-
 src/gallium/state_trackers/vdpau/output.c|  2 +-
 src/gallium/state_trackers/vdpau/query.c | 10 ++--
 src/gallium/state_trackers/vdpau/vdpau_private.h | 22 +---
 5 files changed, 73 insertions(+), 28 deletions(-)

diff --git a/src/gallium/include/state_tracker/vdpau_funcs.h 
b/src/gallium/include/state_tracker/vdpau_funcs.h
new file mode 100644
index 000..66e3c23
--- /dev/null
+++ b/src/gallium/include/state_tracker/vdpau_funcs.h
@@ -0,0 +1,65 @@
+/**
+ *
+ * Copyright 2016 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, 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 THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ **/
+
+/*
+ * Authors:
+ *  Christian König <christian.koe...@amd.com>
+ *
+ */
+
+#ifndef _VDPAU_FUNCS_H_
+#define _VDPAU_FUNCS_H_
+
+#include "vdpau_dmabuf.h"
+
+/* Used for implementing NV_vdpau_interop */
+static inline enum pipe_format
+VdpFormatRGBAToPipe(uint32_t vdpau_format)
+{
+   switch (vdpau_format) {
+   case VDP_RGBA_FORMAT_R8:
+  return PIPE_FORMAT_R8_UNORM;
+   case VDP_RGBA_FORMAT_R8G8:
+  return PIPE_FORMAT_R8G8_UNORM;
+   case VDP_RGBA_FORMAT_A8:
+  return PIPE_FORMAT_A8_UNORM;
+   case VDP_RGBA_FORMAT_B10G10R10A2:
+  return PIPE_FORMAT_B10G10R10A2_UNORM;
+   case VDP_RGBA_FORMAT_B8G8R8A8:
+  return PIPE_FORMAT_B8G8R8A8_UNORM;
+   case VDP_RGBA_FORMAT_R10G10B10A2:
+  return PIPE_FORMAT_R10G10B10A2_UNORM;
+   case VDP_RGBA_FORMAT_R8G8B8A8:
+  return PIPE_FORMAT_R8G8B8A8_UNORM;
+   default:
+  assert(0);
+   }
+
+   return PIPE_FORMAT_NONE;
+}
+
+#endif /* _VDPAU_FUNCS_H_ */
diff --git a/src/gallium/state_trackers/vdpau/bitmap.c 
b/src/gallium/state_trackers/vdpau/bitmap.c
index 97a4287..35c8820 100644
--- a/src/gallium/state_trackers/vdpau/bitmap.c
+++ b/src/gallium/state_trackers/vdpau/bitmap.c
@@ -71,7 +71,7 @@ vlVdpBitmapSurfaceCreate(VdpDevice device,
 
memset(_tmpl, 0, sizeof(res_tmpl));
res_tmpl.target = PIPE_TEXTURE_2D;
-   res_tmpl.format = FormatRGBAToPipe(rgba_format);
+   res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
res_tmpl.width0 = width;
res_tmpl.height0 = height;
res_tmpl.depth0 = 1;
diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index 95f15cb..738e7c7 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -74,7 +74,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
memset(_tmpl, 0, sizeof(res_tmpl));
 
res_tmpl.target = PIPE_TEXTURE_2D;
-   res_tmpl.format = FormatRGBAToPipe(rgba_format);
+   res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
res_tmpl.width0 = width;
res_tmpl.height0 = height;
res_tmpl.depth0 = 1;
diff --git a/src/gallium/state_trackers/vdpau/query.c 
b/src/gallium/state_trackers/vdpau/query.c
index d41e6d9..a279ad3 100644
--- a/src/gallium/state_trackers/vdpau/query.c
+++ b/src/gallium/state_trackers/vdpau/query.c
@@ -224,7 +224,7 @@ vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, 
VdpRGBAFormat surface_rgba
if (!pscreen)
   return VDP_STATUS_RESOURCES;
 
-   format = FormatRGBAToPipe(

Mesa (master): st/vdpau: use linear layout for output surfaces

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: d180de35320eafa3df3d76f0e82b332656530126
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d180de35320eafa3df3d76f0e82b332656530126

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jan 14 13:40:25 2016 +0100

st/vdpau: use linear layout for output surfaces

Works around a bug in radeonsi and tiling is actually
not very beneficial in this use case.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Leo Liu <leo@amd.com>

---

 src/gallium/state_trackers/vdpau/output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index 3248f76..95f15cb 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -79,7 +79,8 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
res_tmpl.height0 = height;
res_tmpl.depth0 = 1;
res_tmpl.array_size = 1;
-   res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+   res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
+   PIPE_BIND_LINEAR;
res_tmpl.usage = PIPE_USAGE_DEFAULT;
 
pipe_mutex_lock(dev->mutex);

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


Mesa (master): st/vdpau: implement the new DMA-buf based interop v2

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: bdeb22b7b6204cf7a0eaab123118e2522a9abcd7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bdeb22b7b6204cf7a0eaab123118e2522a9abcd7

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jan 14 16:45:29 2016 +0100

st/vdpau: implement the new DMA-buf based interop v2

That should allow us to get away from passing internal structures around.

v2: rebased

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Leo Liu <leo@amd.com>

---

 src/gallium/state_trackers/vdpau/ftab.c  |  6 ++-
 src/gallium/state_trackers/vdpau/output.c| 41 +-
 src/gallium/state_trackers/vdpau/surface.c   | 69 
 src/gallium/state_trackers/vdpau/vdpau_private.h |  3 ++
 4 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/ftab.c 
b/src/gallium/state_trackers/vdpau/ftab.c
index add4659..901a444 100644
--- a/src/gallium/state_trackers/vdpau/ftab.c
+++ b/src/gallium/state_trackers/vdpau/ftab.c
@@ -107,10 +107,12 @@ static void* ftab_winsys[1] =
  /* 
VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */
 };
 
-static void* ftab_driver[2] =
+static void* ftab_driver[4] =
 {
, /* VDP_FUNC_ID_SURFACE_GALLIUM */
-/* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */
+   , /* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */
+   , /* VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF */
+/* VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF */
 };
 
 boolean vlGetFuncFTAB(VdpFuncId function_id, void **func)
diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index 738e7c7..c644cc8 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -36,6 +36,8 @@
 
 #include "vl/vl_csc.h"
 
+#include "state_tracker/drm_driver.h"
+
 #include "vdpau_private.h"
 
 /**
@@ -80,7 +82,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
res_tmpl.depth0 = 1;
res_tmpl.array_size = 1;
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
-   PIPE_BIND_LINEAR;
+   PIPE_BIND_LINEAR | PIPE_BIND_SHARED;
res_tmpl.usage = PIPE_USAGE_DEFAULT;
 
pipe_mutex_lock(dev->mutex);
@@ -764,3 +766,40 @@ struct pipe_resource 
*vlVdpOutputSurfaceGallium(VdpOutputSurface surface)
 
return vlsurface->surface->texture;
 }
+
+VdpStatus vlVdpOutputSurfaceDMABuf(VdpVideoSurface surface,
+   struct VdpSurfaceDMABufDesc *result)
+{
+   vlVdpOutputSurface *vlsurface;
+   struct pipe_screen *pscreen;
+   struct winsys_handle whandle;
+
+   memset(result, 0, sizeof(*result));
+   result->handle = -1;
+
+   vlsurface = vlGetDataHTAB(surface);
+   if (!vlsurface || !vlsurface->surface)
+  return VDP_STATUS_INVALID_HANDLE;
+
+   pipe_mutex_lock(vlsurface->device->mutex);
+   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
+   vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
+   pipe_mutex_unlock(vlsurface->device->mutex);
+
+   memset(, 0, sizeof(struct winsys_handle));
+   whandle.type = DRM_API_HANDLE_TYPE_FD;
+
+   pscreen = vlsurface->surface->texture->screen;
+   if (!pscreen->resource_get_handle(pscreen, vlsurface->surface->texture, 
,
+PIPE_HANDLE_USAGE_READ_WRITE))
+  return VDP_STATUS_NO_IMPLEMENTATION;
+
+   result->handle = whandle.handle;
+   result->width = vlsurface->surface->width;
+   result->height = vlsurface->surface->height;
+   result->offset = whandle.offset;
+   result->stride = whandle.stride;
+   result->format = PipeToFormatRGBA(vlsurface->surface->format);
+
+   return VDP_STATUS_OK;
+}
diff --git a/src/gallium/state_trackers/vdpau/surface.c 
b/src/gallium/state_trackers/vdpau/surface.c
index ffcedc1..0550141 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -37,6 +37,8 @@
 #include "util/u_video.h"
 #include "vl/vl_defines.h"
 
+#include "state_tracker/drm_driver.h"
+
 #include "vdpau_private.h"
 
 enum getbits_conversion {
@@ -412,3 +414,70 @@ struct pipe_video_buffer 
*vlVdpVideoSurfaceGallium(VdpVideoSurface surface)
 
return p_surf->video_buffer;
 }
+
+VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
+  VdpVideoSurfacePlane plane,
+  struct VdpSurfaceDMABufDesc *result)
+{
+   vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+
+   struct pipe_screen *pscreen;
+   struct winsys_handle whandle;
+
+   struct pipe_surface *surf;
+
+   memset(result, 0, sizeof(*result));
+   result->handle = -1;
+
+   if (!p_surf)
+  return VDP_STATUS_INVALID_HANDLE;
+
+   if (plane > 3)
+  return VDP_STATUS_INVALID_VALUE;
+
+   if (result)
+  

Mesa (master): radeonsi: ignore PIPE_BIND_LINEAR in si_is_format_supported v2

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: 7eb5e5b8b4ae51be367050df48d3a9398694d3bc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7eb5e5b8b4ae51be367050df48d3a9398694d3bc

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jan 14 13:38:10 2016 +0100

radeonsi: ignore PIPE_BIND_LINEAR in si_is_format_supported v2

Linear layout should work for all not compressed or depth/stencil formats.

v2: restrict it a bit more

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/gallium/drivers/radeonsi/si_state.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index a2b0da9..10d691a 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2046,6 +2046,11 @@ boolean si_is_format_supported(struct pipe_screen 
*screen,
if (usage & PIPE_BIND_TRANSFER_WRITE)
retval |= PIPE_BIND_TRANSFER_WRITE;
 
+   if ((usage & PIPE_BIND_LINEAR) &&
+   !util_format_is_compressed(format) &&
+   !(usage & PIPE_BIND_DEPTH_STENCIL))
+   retval |= PIPE_BIND_LINEAR;
+
return retval == usage;
 }
 

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


Mesa (master): radeon/winsys: add layer support for BO export

2016-03-19 Thread Christian König
Module: Mesa
Branch: master
Commit: 5aea0d691988af945e09e1d7cca28ca0759cc309
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5aea0d691988af945e09e1d7cca28ca0759cc309

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jan 14 15:01:39 2016 +0100

radeon/winsys: add layer support for BO export

Add layer support to export individual array layers.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/gallium/drivers/radeon/r600_texture.c | 1 +
 src/gallium/drivers/radeon/radeon_winsys.h| 1 +
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 2 ++
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 3 +++
 4 files changed, 7 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_texture.c 
b/src/gallium/drivers/radeon/r600_texture.c
index 15818aa..1ad7076 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -374,6 +374,7 @@ static boolean r600_texture_get_handle(struct pipe_screen* 
screen,
return rscreen->ws->buffer_get_handle(res->buf,
  
rtex->surface.level[0].pitch_bytes,
  rtex->surface.level[0].offset,
+ rtex->surface.level[0].slice_size,
  whandle);
 }
 
diff --git a/src/gallium/drivers/radeon/radeon_winsys.h 
b/src/gallium/drivers/radeon/radeon_winsys.h
index fb3f051..daa15db 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -547,6 +547,7 @@ struct radeon_winsys {
  */
 boolean (*buffer_get_handle)(struct pb_buffer *buf,
  unsigned stride, unsigned offset,
+ unsigned slice_size,
  struct winsys_handle *whandle);
 
 /**
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 3f74dd7..c79bed4 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -613,6 +613,7 @@ error:
 
 static boolean amdgpu_bo_get_handle(struct pb_buffer *buffer,
 unsigned stride, unsigned offset,
+unsigned slice_size,
 struct winsys_handle *whandle)
 {
struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(buffer);
@@ -641,6 +642,7 @@ static boolean amdgpu_bo_get_handle(struct pb_buffer 
*buffer,
 
whandle->stride = stride;
whandle->offset = offset;
+   whandle->offset += slice_size * whandle->layer;
bo->is_shared = true;
return TRUE;
 }
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 3f39827..08856df 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -995,6 +995,7 @@ fail:
 
 static boolean radeon_winsys_bo_get_handle(struct pb_buffer *buffer,
unsigned stride, unsigned offset,
+   unsigned slice_size,
struct winsys_handle *whandle)
 {
 struct drm_gem_flink flink;
@@ -1029,6 +1030,8 @@ static boolean radeon_winsys_bo_get_handle(struct 
pb_buffer *buffer,
 
 whandle->stride = stride;
 whandle->offset = offset;
+whandle->offset += slice_size * whandle->layer;
+
 return TRUE;
 }
 

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


Mesa (master): gallium/winsys/drm: add layer to struct winsys_handle

2016-03-19 Thread Christian König
Module: Mesa
Branch: master
Commit: f1e78a48f2ec2645eb87d134c6961815dc89a307
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1e78a48f2ec2645eb87d134c6961815dc89a307

Author: Christian König <christian.koe...@amd.com>
Date:   Thu Jan 14 13:51:18 2016 +0100

gallium/winsys/drm: add layer to struct winsys_handle

For exporting a specific layer of an array texture.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/gallium/include/state_tracker/drm_driver.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/include/state_tracker/drm_driver.h 
b/src/gallium/include/state_tracker/drm_driver.h
index d81da89..fefab11 100644
--- a/src/gallium/include/state_tracker/drm_driver.h
+++ b/src/gallium/include/state_tracker/drm_driver.h
@@ -26,6 +26,11 @@ struct winsys_handle
 */
unsigned type;
/**
+* Input for texture_get_handle, allows to export the offset
+* of a specific layer of an array texture.
+*/
+   unsigned layer;
+   /**
 * Input to texture_from_handle.
 * Output for texture_get_handle.
 */

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


Mesa (master): radeon/winsys: add offset support for BO import/export

2016-03-18 Thread Christian König
Module: Mesa
Branch: master
Commit: 04bc082f6a8bfc3b3774bb102d3200317609432e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=04bc082f6a8bfc3b3774bb102d3200317609432e

Author: Christian König <christian.koe...@amd.com>
Date:   Tue Jan 12 15:59:11 2016 +0100

radeon/winsys: add offset support for BO import/export

Add offset support to handle NV12 offsets as well.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/gallium/drivers/r300/r300_texture.c   |  6 +++---
 src/gallium/drivers/radeon/r600_texture.c | 23 ---
 src/gallium/drivers/radeon/radeon_winsys.h|  4 ++--
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c |  9 ++---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |  9 ++---
 5 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_texture.c 
b/src/gallium/drivers/r300/r300_texture.c
index 57456c6..22a613f 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -981,8 +981,8 @@ boolean r300_resource_get_handle(struct pipe_screen* screen,
 return FALSE;
 }
 
-return rws->buffer_get_handle(tex->buf,
-  tex->tex.stride_in_bytes[0], whandle);
+return rws->buffer_get_handle(tex->buf, tex->tex.stride_in_bytes[0],
+  0, whandle);
 }
 
 static const struct u_resource_vtbl r300_texture_vtbl =
@@ -1116,7 +1116,7 @@ struct pipe_resource *r300_texture_from_handle(struct 
pipe_screen *screen,
 return NULL;
 }
 
-buffer = rws->buffer_from_handle(rws, whandle, );
+buffer = rws->buffer_from_handle(rws, whandle, , NULL);
 if (!buffer)
 return NULL;
 
diff --git a/src/gallium/drivers/radeon/r600_texture.c 
b/src/gallium/drivers/radeon/r600_texture.c
index 115c728..15818aa 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -201,9 +201,11 @@ static int r600_init_surface(struct r600_common_screen 
*rscreen,
 
 static int r600_setup_surface(struct pipe_screen *screen,
  struct r600_texture *rtex,
- unsigned pitch_in_bytes_override)
+ unsigned pitch_in_bytes_override,
+ unsigned offset)
 {
struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
+   unsigned i;
int r;
 
r = rscreen->ws->surface_init(rscreen->ws, >surface);
@@ -225,6 +227,11 @@ static int r600_setup_surface(struct pipe_screen *screen,
rtex->surface.stencil_level[0].offset = 
rtex->surface.level[0].slice_size;
}
}
+
+   if (offset) {
+   for (i = 0; i < Elements(rtex->surface.level); ++i)
+   rtex->surface.level[i].offset += offset;
+   }
return 0;
 }
 
@@ -366,6 +373,7 @@ static boolean r600_texture_get_handle(struct pipe_screen* 
screen,
 
return rscreen->ws->buffer_get_handle(res->buf,
  
rtex->surface.level[0].pitch_bytes,
+ rtex->surface.level[0].offset,
  whandle);
 }
 
@@ -791,6 +799,7 @@ static struct r600_texture *
 r600_texture_create_object(struct pipe_screen *screen,
   const struct pipe_resource *base,
   unsigned pitch_in_bytes_override,
+  unsigned offset,
   struct pb_buffer *buf,
   struct radeon_surf *surface)
 {
@@ -812,7 +821,7 @@ r600_texture_create_object(struct pipe_screen *screen,
rtex->is_depth = 
util_format_has_depth(util_format_description(rtex->resource.b.b.format));
 
rtex->surface = *surface;
-   if (r600_setup_surface(screen, rtex, pitch_in_bytes_override)) {
+   if (r600_setup_surface(screen, rtex, pitch_in_bytes_override, offset)) {
FREE(rtex);
return NULL;
}
@@ -979,7 +988,7 @@ struct pipe_resource *r600_texture_create(struct 
pipe_screen *screen,
if (r) {
return NULL;
}
-   return (struct pipe_resource *)r600_texture_create_object(screen, templ,
+   return (struct pipe_resource *)r600_texture_create_object(screen, 
templ, 0,
  0, NULL, 
);
 }
 
@@ -990,7 +999,7 @@ static struct pipe_resource 
*r600_texture_from_handle(struct pipe_screen *screen
 {
struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
struct pb_buffer *buf = NULL;
-   unsigned stride = 0;
+   unsigned stride = 0, offset = 0;
unsigned array_mode;
struct radeon_surf surface;
 

Mesa (master): st/mesa: conditionally enable GL_NV_vdpau_interop

2016-03-08 Thread Christian König
Module: Mesa
Branch: master
Commit: 37402aa4c6216eec5f60ebef8a8f24fcbd61f646
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=37402aa4c6216eec5f60ebef8a8f24fcbd61f646

Author: Christian König <christian.koe...@amd.com>
Date:   Wed Jan 20 16:19:08 2016 +0100

st/mesa: conditionally enable GL_NV_vdpau_interop

Only enable it when we compile the state tracker as well.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Ilia Mirkin <imir...@alum.mit.edu>

---

 configure.ac   | 1 +
 src/mesa/state_tracker/st_extensions.c | 2 ++
 src/mesa/state_tracker/st_vdpau.c  | 6 ++
 3 files changed, 9 insertions(+)

diff --git a/configure.ac b/configure.ac
index 3b77030..49be147 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1735,6 +1735,7 @@ AM_CONDITIONAL(HAVE_ST_XVMC, test "x$enable_xvmc" = xyes)
 if test "x$enable_vdpau" = xyes; then
 PKG_CHECK_MODULES([VDPAU], [vdpau >= $VDPAU_REQUIRED])
 gallium_st="$gallium_st vdpau"
+DEFINES="$DEFINES -DHAVE_ST_VDPAU"
 fi
 AM_CONDITIONAL(HAVE_ST_VDPAU, test "x$enable_vdpau" = xyes)
 
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 063daae..42d347c 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1067,12 +1067,14 @@ void st_init_extensions(struct pipe_screen *screen,
   extensions->ARB_ES3_compatibility = GL_TRUE;
}
 
+#ifdef HAVE_ST_VDPAU
if (screen->get_video_param &&
screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN,
PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
PIPE_VIDEO_CAP_SUPPORTS_INTERLACED)) {
   extensions->NV_vdpau_interop = GL_TRUE;
}
+#endif
 
if (screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
 PIPE_SHADER_CAP_DOUBLES) &&
diff --git a/src/mesa/state_tracker/st_vdpau.c 
b/src/mesa/state_tracker/st_vdpau.c
index 63af119..71dd15b 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -49,6 +49,8 @@
 #include "st_format.h"
 #include "st_cb_flush.h"
 
+#ifdef HAVE_ST_VDPAU
+
 static void
 st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
  GLboolean output, struct gl_texture_object *texObj,
@@ -180,9 +182,13 @@ st_vdpau_unmap_surface(struct gl_context *ctx, GLenum 
target, GLenum access,
st_flush(st, NULL, 0);
 }
 
+#endif
+
 void
 st_init_vdpau_functions(struct dd_function_table *functions)
 {
+#ifdef HAVE_ST_VDPAU
functions->VDPAUMapSurface = st_vdpau_map_surface;
functions->VDPAUUnmapSurface = st_vdpau_unmap_surface;
+#endif
 }

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


Mesa (master): radeon/uvd: disable MPEG1

2016-03-08 Thread Christian König
Module: Mesa
Branch: master
Commit: e148a3b6e9e5c5cd941b70edb67e82058a8187a5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e148a3b6e9e5c5cd941b70edb67e82058a8187a5

Author: Christian König <christian.koe...@amd.com>
Date:   Fri Feb  5 09:25:59 2016 +0100

radeon/uvd: disable MPEG1

The hardware simply doesn't support that correctly.

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
Cc: "11.1 11.2" <mesa-sta...@lists.freedesktop.org>

---

 src/gallium/drivers/radeon/radeon_video.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/radeon/radeon_video.c 
b/src/gallium/drivers/radeon/radeon_video.c
index ec29d8c..4b3e2cf 100644
--- a/src/gallium/drivers/radeon/radeon_video.c
+++ b/src/gallium/drivers/radeon/radeon_video.c
@@ -237,6 +237,7 @@ int rvid_get_video_param(struct pipe_screen *screen,
case PIPE_VIDEO_CAP_SUPPORTED:
switch (codec) {
case PIPE_VIDEO_FORMAT_MPEG12:
+   return profile != PIPE_VIDEO_PROFILE_MPEG1;
case PIPE_VIDEO_FORMAT_MPEG4:
case PIPE_VIDEO_FORMAT_MPEG4_AVC:
if (rscreen->family < CHIP_PALM)

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


Mesa (master): st/va: fix motion adaptive deinterlacing

2016-01-19 Thread Christian König
Module: Mesa
Branch: master
Commit: f3b067af8656b1d3e0fda3e50bf80dbda5f4c1f8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3b067af8656b1d3e0fda3e50bf80dbda5f4c1f8

Author: Christian König <christian.koe...@amd.com>
Date:   Mon Jan 18 20:56:06 2016 +0100

st/va: fix motion adaptive deinterlacing

Signed-off-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/postproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/postproc.c 
b/src/gallium/state_trackers/va/postproc.c
index f541f7c..d06f016 100644
--- a/src/gallium/state_trackers/va/postproc.c
+++ b/src/gallium/state_trackers/va/postproc.c
@@ -273,7 +273,7 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver 
*drv, vlVaContext *contex
 
  case VAProcDeinterlacingMotionAdaptive:
 src = vlVaApplyDeint(drv, context, param, src,
-deint->flags & VA_DEINTERLACING_BOTTOM_FIELD);
+!!(deint->flags & 
VA_DEINTERLACING_BOTTOM_FIELD));
 break;
 
  default:

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): st/va: add motion adaptive deinterlacing v2

2016-01-18 Thread Christian König
Module: Mesa
Branch: master
Commit: eaf7ec9cfc5165f461bddc365aaaf6cb25c2d9bd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eaf7ec9cfc5165f461bddc365aaaf6cb25c2d9bd

Author: Christian König <christian.koe...@amd.com>
Date:   Sun Dec 13 11:44:13 2015 +0100

st/va: add motion adaptive deinterlacing v2

v2: minor cleanup

Signed-off-by: Christian König <christian.koe...@amd.com>

---

 src/gallium/state_trackers/va/context.c|  5 +++
 src/gallium/state_trackers/va/postproc.c   | 60 --
 src/gallium/state_trackers/va/surface.c| 22 +--
 src/gallium/state_trackers/va/va_private.h |  2 +
 4 files changed, 82 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index 37a0117..b25c381 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -31,6 +31,7 @@
 #include "util/u_memory.h"
 #include "util/u_handle_table.h"
 #include "util/u_video.h"
+#include "vl/vl_deint_filter.h"
 #include "vl/vl_winsys.h"
 
 #include "va_private.h"
@@ -296,6 +297,10 @@ vlVaDestroyContext(VADriverContextP ctx, VAContextID 
context_id)
   }
   context->decoder->destroy(context->decoder);
}
+   if (context->deint) {
+  vl_deint_filter_cleanup(context->deint);
+  FREE(context->deint);
+   }
FREE(context);
handle_table_remove(drv->htab, context_id);
pipe_mutex_unlock(drv->mutex);
diff --git a/src/gallium/state_trackers/va/postproc.c 
b/src/gallium/state_trackers/va/postproc.c
index 0cec0c8..f541f7c 100644
--- a/src/gallium/state_trackers/va/postproc.c
+++ b/src/gallium/state_trackers/va/postproc.c
@@ -29,6 +29,7 @@
 
 #include "vl/vl_defines.h"
 #include "vl/vl_video_buffer.h"
+#include "vl/vl_deint_filter.h"
 
 #include "va_private.h"
 
@@ -174,6 +175,51 @@ static VAStatus vlVaPostProcBlit(vlVaDriver *drv, 
vlVaContext *context,
return VA_STATUS_SUCCESS;
 }
 
+static struct pipe_video_buffer *
+vlVaApplyDeint(vlVaDriver *drv, vlVaContext *context,
+   VAProcPipelineParameterBuffer *param,
+   struct pipe_video_buffer *current,
+   unsigned field)
+{
+   vlVaSurface *prevprev, *prev, *next;
+
+   if (param->num_forward_references < 1 ||
+   param->num_backward_references < 2)
+  return current;
+
+   prevprev = handle_table_get(drv->htab, param->backward_references[1]);
+   prev = handle_table_get(drv->htab, param->backward_references[0]);
+   next = handle_table_get(drv->htab, param->forward_references[0]);
+
+   if (!prevprev || !prev || !next)
+  return current;
+
+   if (context->deint && (context->deint->video_width != current->width ||
+   context->deint->video_height != current->height)) {
+  vl_deint_filter_cleanup(context->deint);
+  FREE(context->deint);
+  context->deint = NULL;
+   }
+
+   if (!context->deint) {
+  context->deint = MALLOC(sizeof(struct vl_deint_filter));
+  if (!vl_deint_filter_init(context->deint, drv->pipe, current->width,
+current->height, false, false)) {
+ FREE(context->deint);
+ context->deint = NULL;
+ return current;
+  }
+   }
+
+   if (!vl_deint_filter_check_buffers(context->deint, prevprev->buffer,
+  prev->buffer, current, next->buffer))
+  return current;
+
+   vl_deint_filter_render(context->deint, prevprev->buffer, prev->buffer,
+  current, next->buffer, field);
+   return context->deint->video_buffer;
+}
+
 VAStatus
 vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext 
*context, vlVaBuffer *buf)
 {
@@ -181,6 +227,7 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver 
*drv, vlVaContext *contex
VARectangle def_src_region, def_dst_region;
const VARectangle *src_region, *dst_region;
VAProcPipelineParameterBuffer *param;
+   struct pipe_video_buffer *src;
vlVaSurface *src_surface;
unsigned i;
 
@@ -199,6 +246,8 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver 
*drv, vlVaContext *contex
if (!src_surface || !src_surface->buffer)
   return VA_STATUS_ERROR_INVALID_SURFACE;
 
+   src = src_surface->buffer;
+
for (i = 0; i < param->num_filters; i++) {
   vlVaBuffer *buf = handle_table_get(drv->htab, param->filters[i]);
   VAProcFilterParameterBufferBase *filter;
@@ -222,6 +271,11 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver 
*drv, vlVaContext *contex
 deinterlace = VL_COMPOSITOR_WEAVE;
 break;
 
+ case VAProcDeinterlacingMotionAdaptive:
+src = vlVaApplyDeint(drv, context, param, src,
+ 

Mesa (master): vl: use preferred format for deinterlacing

2016-01-12 Thread Christian König
Module: Mesa
Branch: master
Commit: 6f898f740c4932f3d34f5f69d60b9b9b6b3a9327
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f898f740c4932f3d34f5f69d60b9b9b6b3a9327

Author: Christian König <christian.koe...@amd.com>
Date:   Wed Dec 16 14:19:41 2015 +0100

vl: use preferred format for deinterlacing

Signed-off-by: Christian König <christian.koe...@amd.com>
Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com>

---

 src/gallium/auxiliary/vl/vl_deint_filter.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/vl/vl_deint_filter.c 
b/src/gallium/auxiliary/vl/vl_deint_filter.c
index f919867..9e782e5 100644
--- a/src/gallium/auxiliary/vl/vl_deint_filter.c
+++ b/src/gallium/auxiliary/vl/vl_deint_filter.c
@@ -255,7 +255,13 @@ vl_deint_filter_init(struct vl_deint_filter *filter, 
struct pipe_context *pipe,
 
/* TODO: handle other than 4:2:0 subsampling */
memset(, 0, sizeof(templ));
-   templ.buffer_format = PIPE_FORMAT_YV12;
+   templ.buffer_format = pipe->screen->get_video_param
+   (
+  pipe->screen,
+  PIPE_VIDEO_PROFILE_UNKNOWN,
+  PIPE_VIDEO_ENTRYPOINT_UNKNOWN,
+  PIPE_VIDEO_CAP_PREFERED_FORMAT
+   );
templ.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
templ.width = video_width;
templ.height = video_height;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


  1   2   3   4   5   6   7   >