[Mesa-dev] [PATCH 2/5] applegl: Provide requirements of _SET_DrawBuffers
From: Jon TURNEY _SET_DrawBuffers requires driDispatchRemapTable, so we need to link with libmesa for remap.c. libmesa requires the C++ linker. Also need to arrange to call _mesa_init_remap_table() to initialize the remap table. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90311 Signed-off-by: Jon TURNEY --- src/glx/Makefile.am | 5 - src/glx/apple/apple_glapi.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/glx/Makefile.am b/src/glx/Makefile.am index 6e50e09..de24496 100644 --- a/src/glx/Makefile.am +++ b/src/glx/Makefile.am @@ -139,7 +139,10 @@ libglx_la_SOURCES += \ applegl_glx.c SUBDIRS += apple -libglx_la_LIBADD += $(builddir)/apple/libappleglx.la +libglx_la_LIBADD += \ + $(builddir)/apple/libappleglx.la \ + $(top_builddir)/src/mesa/libmesa.la +nodist_EXTRA_lib@GL_LIB@_la_SOURCES = dummy.cpp endif GL_LIBS = \ diff --git a/src/glx/apple/apple_glapi.c b/src/glx/apple/apple_glapi.c index 4d19f7f..849044b 100644 --- a/src/glx/apple/apple_glapi.c +++ b/src/glx/apple/apple_glapi.c @@ -39,6 +39,7 @@ #include #include "main/glheader.h" +#include "main/remap.h" #include "glapi.h" #include "glapitable.h" #include "main/dispatch.h" @@ -54,6 +55,8 @@ static void _apple_glapi_create_table(void) { if (__applegl_api) return; +_mesa_init_remap_table(); + __ogl_framework_api = _glapi_create_table_from_handle(apple_cgl_get_dl_handle(), "gl"); assert(__ogl_framework_api); -- 1.9.5 (Apple Git-50.3) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 5/5] osx: fix asm support on darwin
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90908 Signed-off-by: Julien Isorce --- configure.ac | 2 +- src/mesa/x86-64/xform4.S | 53 +--- src/mesa/x86/assyntax.h | 2 +- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index ae6d83d..6d699d5 100644 --- a/configure.ac +++ b/configure.ac @@ -615,7 +615,7 @@ if test "x$enable_asm" = xyes; then ;; x86_64|amd64) case "$host_os" in -linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*) +linux* | *freebsd* | dragonfly* | *netbsd* | openbsd* | darwin*) asm_arch=x86_64 ;; esac diff --git a/src/mesa/x86-64/xform4.S b/src/mesa/x86-64/xform4.S index c185f62..17eb7fa 100644 --- a/src/mesa/x86-64/xform4.S +++ b/src/mesa/x86-64/xform4.S @@ -24,14 +24,15 @@ #ifdef USE_X86_64_ASM +#include "x86/assyntax.h" #include "matypes.h" .text .align 16 -.globl _mesa_x86_64_cpuid -.hidden _mesa_x86_64_cpuid -_mesa_x86_64_cpuid: +GLOBL GLNAME(_mesa_x86_64_cpuid) +HIDDEN(_mesa_x86_64_cpuid) +GLNAME(_mesa_x86_64_cpuid): pushq %rbx movl(%rdi), %eax movl8(%rdi), %ecx @@ -46,9 +47,9 @@ _mesa_x86_64_cpuid: ret .align 16 -.globl _mesa_x86_64_transform_points4_general -.hidden _mesa_x86_64_transform_points4_general -_mesa_x86_64_transform_points4_general: +GLOBL GLNAME(_mesa_x86_64_transform_points4_general) +HIDDEN(_mesa_x86_64_transform_points4_general) +GLNAME(_mesa_x86_64_transform_points4_general): /* * rdi = dest * rsi = matrix @@ -105,8 +106,10 @@ p4_general_loop: p4_general_done: .byte 0xf3 ret - + +#if defined (__ELF__) && defined (__linux__) .section .rodata +#endif .align 16 p4_constants: @@ -122,13 +125,13 @@ p4_constants: .text .align 16 -.globl _mesa_x86_64_transform_points4_3d -.hidden _mesa_x86_64_transform_points4_3d +GLOBL GLNAME(_mesa_x86_64_transform_points4_3d) +HIDDEN(_mesa_x86_64_transform_points4_3d) /* * this is slower than _mesa_x86_64_transform_points4_general * because it ensures that the last matrix row (or is it column?) is 0,0,0,1 */ -_mesa_x86_64_transform_points4_3d: +GLNAME(_mesa_x86_64_transform_points4_3d): leaq p4_constants(%rip), %rax @@ -194,9 +197,9 @@ p4_3d_done: .align 16 -.globl _mesa_x86_64_transform_points4_identity -.hidden _mesa_x86_64_transform_points4_identity -_mesa_x86_64_transform_points4_identity: +GLOBL GLNAME(_mesa_x86_64_transform_points4_identity) +HIDDEN(_mesa_x86_64_transform_points4_identitiy) +GLNAME(_mesa_x86_64_transform_points4_identity): movl V4F_COUNT(%rdx), %ecx /* count */ movzbl V4F_STRIDE(%rdx), %eax /* stride */ @@ -223,9 +226,9 @@ p4_identity_done: .align 16 -.globl _mesa_3dnow_transform_points4_3d_no_rot -.hidden _mesa_3dnow_transform_points4_3d_no_rot -_mesa_3dnow_transform_points4_3d_no_rot: +GLOBL GLNAME(_mesa_3dnow_transform_points4_3d_no_rot) +HIDDEN(_mesa_3dnow_transform_points4_3d_no_rot) +GLNAME(_mesa_3dnow_transform_points4_3d_no_rot): movl V4F_COUNT(%rdx), %ecx /* count */ movzbl V4F_STRIDE(%rdx), %eax /* stride */ @@ -288,9 +291,9 @@ p4_3d_no_rot_done: .align 16 -.globl _mesa_3dnow_transform_points4_perspective -.hidden _mesa_3dnow_transform_points4_perspective -_mesa_3dnow_transform_points4_perspective: +GLOBL GLNAME(_mesa_3dnow_transform_points4_perspective) +HIDDEN(_mesa_3dnow_transform_points4_perspective) +GLNAME(_mesa_3dnow_transform_points4_perspective): movl V4F_COUNT(%rdx), %ecx /* count */ movzbl V4F_STRIDE(%rdx), %eax /* stride */ @@ -355,9 +358,9 @@ p4_perspective_done: ret .align 16 -.globl _mesa_3dnow_transform_points4_2d_no_rot -.hidden _mesa_3dnow_transform_points4_2d_no_rot -_mesa_3dnow_transform_points4_2d_no_rot: +GLOBL GLNAME(_mesa_3dnow_transform_points4_2d_no_rot) +HIDDEN(_mesa_3dnow_transform_points4_2d_no_rot) +GLNAME(_mesa_3dnow_transform_points4_2d_no_rot): movl V4F_COUNT(%rdx), %ecx /* count */ movzbl V4F_STRIDE(%rdx), %eax /* stride */ @@ -411,9 +414,9 @@ p4_2d_no_rot_done: .align 16 -.globl _mesa_3dnow_transform_points4_2d -.hidden _mesa_3dnow_transform_points4_2d -_mesa_3dnow_transform_points4_2d: +GLOBL GLNAME(_mesa_3dnow_transform_points4_2d) +HIDDEN(_mesa_3dnow_transform_points4_2d) +GLNAME(_mesa_3dnow_transform_points4_2d): movl V4F_COUNT(%rdx), %ecx /* count */ movzbl V4F_STRIDE(%rdx), %eax /* stride */ diff --git a/src/mesa/x86/assyntax.h b/src/mesa/x86/assyntax.h index 67867bd..8ba7e50 100644 --- a/src/mesa/x86/assyntax.h +++ b/src/mesa/x86/assyntax.h @@ -255,7 +255,7 @@ #endif /* ACK_ASSEMBLER */ -#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || define
[Mesa-dev] [PATCH 1/5] darwin: Suppress type conversion warnings for GLhandleARB
From: Jon TURNEY On darwin, GLhandleARB is defined as a void *, not the unsigned int it is on linux. For the moment, apply a cast to supress the warning Possibly this is safe, as for the mesa software renderer the shader program handle is not a real pointer, but a integer handle Probably this is not the right thing to do, and we should pay closer attention to how the GLhandlerARB type is used. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66346 Signed-off-by: Jon TURNEY --- src/mesa/main/shader_query.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index a6246a3..e3a1213 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -69,7 +69,7 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index, GET_CURRENT_CONTEXT(ctx); struct gl_shader_program *const shProg = - _mesa_lookup_shader_program_err(ctx, program, "glBindAttribLocation"); + _mesa_lookup_shader_program_err(ctx, (uintptr_t)program, "glBindAttribLocation"); if (!shProg) return; @@ -137,7 +137,7 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index, return; } - shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); + shProg = _mesa_lookup_shader_program_err(ctx, (uintptr_t)program, "glGetActiveAttrib"); if (!shProg) return; @@ -251,7 +251,7 @@ _mesa_GetAttribLocation(GLhandleARB program, const GLcharARB * name) { GET_CURRENT_CONTEXT(ctx); struct gl_shader_program *const shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetAttribLocation"); + _mesa_lookup_shader_program_err(ctx, (uintptr_t)program, "glGetAttribLocation"); if (!shProg) { return -1; -- 1.9.5 (Apple Git-50.3) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/5] egl: use unix defines on osx with clang
CC egl_dri2.lo include/EGL/eglplatform.h:135:2: error: "Platform not recognized" include/EGL/eglplatform.h:140:9: error: unknown type name 'EGLNativeDisplayType' typedef EGLNativeDisplayType NativeDisplayType; Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90249 Signed-off-by: Julien Isorce --- include/EGL/eglplatform.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/EGL/eglplatform.h b/include/EGL/eglplatform.h index 7802542..b376e64 100644 --- a/include/EGL/eglplatform.h +++ b/include/EGL/eglplatform.h @@ -77,7 +77,7 @@ typedef HDC EGLNativeDisplayType; typedef HBITMAP EGLNativePixmapType; typedef HWNDEGLNativeWindowType; -#elif defined(__APPLE__) || defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ typedef int EGLNativeDisplayType; typedef void *EGLNativeWindowType; @@ -105,7 +105,7 @@ typedef struct ANativeWindow* EGLNativeWindowType; typedef struct egl_native_pixmap_t* EGLNativePixmapType; typedef void* EGLNativeDisplayType; -#elif defined(__unix__) +#elif defined(__unix__) || defined(__APPLE__) #if defined(MESA_EGL_NO_X11_HEADERS) -- 1.9.5 (Apple Git-50.3) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/5] egl/dri2: load libglapi.0.dylib on osx
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90903 Signed-off-by: Julien Isorce --- src/egl/drivers/dri2/egl_dri2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index a1cbd43..90b9648 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -2354,6 +2354,8 @@ dri2_load(_EGLDriver *drv) #ifdef HAVE_SHARED_GLAPI #ifdef HAVE_ANDROID_PLATFORM const char *libname = "libglapi.so"; +#elif defined(__APPLE__) + const char *libname = "libglapi.0.dylib"; #else const char *libname = "libglapi.so.0"; #endif -- 1.9.5 (Apple Git-50.3) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/5] darwin: Suppress type conversion warnings for GLhandleARB
Hi Emil, Do you mean adding the cast only if __APPLE__ is defined ? Actually when reading comment #2 we should get the build error for src/mesa/main/uniform_query.cpp too but it is not the case anymore. So with git blame I can see that the build error has been fixed by commit d96ed5c0 for the file uniform_query.cpp only. But can we apply the same for _mesa_BindAttribLocation in shader_query.cpp ? I can see in the spec that non-ARB version of glBindAttribLocation 's first param is GLuint https://www.opengl.org/sdk/docs/man3/xhtml/glBindAttribLocation.xml (gles2: https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBindAttribLocation.xml ) What is the purpose of src/mapi/glapi/gen/ARB_robustness.xml ? Thx Julien On 18 June 2015 at 19:16, Emil Velikov wrote: > On 18 June 2015 at 06:53, Julien Isorce wrote: > > From: Jon TURNEY > > > > On darwin, GLhandleARB is defined as a void *, not the unsigned int it > is on > > linux. > > > > For the moment, apply a cast to supress the warning > > > > Possibly this is safe, as for the mesa software renderer the shader > program > > handle is not a real pointer, but a integer handle > > > > Probably this is not the right thing to do, and we should pay closer > attention > > to how the GLhandlerARB type is used. > > > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66346 > Imho one's goal should not be to find the quickest solution to shut > warnings up, but to understand them. > As mentioned by Jeremy Huddleston in comment 11, this approach only > masks the issue. > > There was a lengthy discussion(s) on the topic a while back and one of > the objections on the proposed fixes (from Ian iirc) was that it will > break the libglapi ABI. As Jeremy did not see that as a concern > perhaps we can revive them and make sure that the ABI change does not > happen in the non-Mac world. > > -Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/5] applegl: Provide requirements of _SET_DrawBuffers
Sorry for removing the XXX line. Original message is here: https://bugs.freedesktop.org/attachment.cgi?id=115539 At the time src/glx/apple/apple_glapi.c has been developed this patch was not needed I guess so I wonder which change made the regression. Cheers Julien On 18 June 2015 at 19:23, Emil Velikov wrote: > On 18 June 2015 at 06:53, Julien Isorce wrote: > > From: Jon TURNEY > > > > _SET_DrawBuffers requires driDispatchRemapTable, > > so we need to link with libmesa for remap.c. > > libmesa requires the C++ linker. > > > > Also need to arrange to call _mesa_init_remap_table() > > to initialize the remap table. > > > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90311 > > Signed-off-by: Jon TURNEY > > --- > > src/glx/Makefile.am | 5 - > > src/glx/apple/apple_glapi.c | 3 +++ > > 2 files changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/src/glx/Makefile.am b/src/glx/Makefile.am > > index 6e50e09..de24496 100644 > > --- a/src/glx/Makefile.am > > +++ b/src/glx/Makefile.am > > @@ -139,7 +139,10 @@ libglx_la_SOURCES += \ > > applegl_glx.c > > > > SUBDIRS += apple > > -libglx_la_LIBADD += $(builddir)/apple/libappleglx.la > > +libglx_la_LIBADD += \ > > + $(builddir)/apple/libappleglx.la \ > > + $(top_builddir)/src/mesa/libmesa.la > > +nodist_EXTRA_lib@GL_LIB@_la_SOURCES = dummy.cpp > Pulling hunks of mesa into libGL does not sounds like a reasonable > thing. There is a reason why Jon had that XXX: in the original commit > message. > > Cheers, > Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/5] egl/dri2: load libglapi.0.dylib on osx
On 18 June 2015 at 19:29, Emil Velikov wrote: > On 18 June 2015 at 06:53, Julien Isorce wrote: > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90903 > > Signed-off-by: Julien Isorce > > --- > > src/egl/drivers/dri2/egl_dri2.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/src/egl/drivers/dri2/egl_dri2.c > b/src/egl/drivers/dri2/egl_dri2.c > > index a1cbd43..90b9648 100644 > > --- a/src/egl/drivers/dri2/egl_dri2.c > > +++ b/src/egl/drivers/dri2/egl_dri2.c > > @@ -2354,6 +2354,8 @@ dri2_load(_EGLDriver *drv) > > #ifdef HAVE_SHARED_GLAPI > > #ifdef HAVE_ANDROID_PLATFORM > > const char *libname = "libglapi.so"; > > +#elif defined(__APPLE__) > > + const char *libname = "libglapi.0.dylib"; > > #else > Is this enough to get dri modules (suspecting only swrast atm) working > with EGL ? > Well at least es2_info and es2gears_x11 are working (with both GALLIUM_DRIVER=softpipe and llvmpipe). I have attached a screenshot: https://bugs.freedesktop.org/attachment.cgi?id=116583 > > Note that currently libEGL already explicitly links against libglapi, > so imho we can just drop the whole thing. Haven't really looked but do > we use glFlush() as a workaround or it's something required by the EGL > standard ? > No idea but without the patch you get: EGL_LOG_LEVEL=debug es2_info libEGL debug: Native platform type: x11 (autodetected) libEGL debug: added egl_dri2 to module array libEGL warning: DRI2: failed to find _glapi_get_proc_address libEGL debug: EGL user error 0x3001 (EGL_NOT_INITIALIZED) in eglInitialize Error: eglInitialize() failed Cheers Julien > > Thanks > Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/5] egl: use unix defines on osx with clang
On 18 June 2015 at 19:33, Emil Velikov wrote: > On 18 June 2015 at 19:29, Emil Velikov wrote: > Sorry about that. Unintentionally hit send ;-\ > > > On 18 June 2015 at 06:53, Julien Isorce wrote: > >> CC egl_dri2.lo > >> include/EGL/eglplatform.h:135:2: > >> error: "Platform not recognized" > >> include/EGL/eglplatform.h:140:9: > >> error: unknown type name 'EGLNativeDisplayType' > >> typedef EGLNativeDisplayType NativeDisplayType; > >> > You should not longer see this message. Did you try building things, > with the updated eglplatform.h ? > You are right I forgot to update the new error message with current eglplatform.h. > >> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90249 > >> Signed-off-by: Julien Isorce > >> --- > >> include/EGL/eglplatform.h | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/include/EGL/eglplatform.h b/include/EGL/eglplatform.h > >> index 7802542..b376e64 100644 > >> --- a/include/EGL/eglplatform.h > >> +++ b/include/EGL/eglplatform.h > >> @@ -77,7 +77,7 @@ typedef HDC EGLNativeDisplayType; > >> typedef HBITMAP EGLNativePixmapType; > >> typedef HWNDEGLNativeWindowType; > >> > >> -#elif defined(__APPLE__) || defined(__WINSCW__) || > defined(__SYMBIAN32__) /* Symbian */ > >> +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ > >> > The above "defined(__APPLE__))" comes from Khronos, so if it's wrong > perhaps it should be reported to them ? Afaict with current mesa this > patch is not needed, and things will just work. > I remember that with the latest eglplatform.h I had to manually include #include / #include where they are used (because not hitting their inclusion by eglplatform.h) But then build was complaining about converting int to Display*, and void* to Pixmap/Window. A naive cast could silenced the build error but then it was crashing at runtime. I'll have another try. Cheers Julien > > Cheers, > Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 5/5] osx: fix asm support on darwin
On 18 June 2015 at 19:46, Emil Velikov wrote: > On 18 June 2015 at 06:53, Julien Isorce wrote: > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90908 > > Signed-off-by: Julien Isorce > > --- > > configure.ac | 2 +- > > src/mesa/x86-64/xform4.S | 53 > +--- > > src/mesa/x86/assyntax.h | 2 +- > > 3 files changed, 30 insertions(+), 27 deletions(-) > > > > diff --git a/configure.ac b/configure.ac > > index ae6d83d..6d699d5 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -615,7 +615,7 @@ if test "x$enable_asm" = xyes; then > > ;; > > x86_64|amd64) > > case "$host_os" in > > -linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*) > > +linux* | *freebsd* | dragonfly* | *netbsd* | openbsd* | darwin*) > > asm_arch=x86_64 > > ;; > > esac > > diff --git a/src/mesa/x86-64/xform4.S b/src/mesa/x86-64/xform4.S > > index c185f62..17eb7fa 100644 > > --- a/src/mesa/x86-64/xform4.S > > +++ b/src/mesa/x86-64/xform4.S > > @@ -24,14 +24,15 @@ > > > > #ifdef USE_X86_64_ASM > > > > +#include "x86/assyntax.h" > > #include "matypes.h" > > > > .text > > > > .align 16 > > -.globl _mesa_x86_64_cpuid > > -.hidden _mesa_x86_64_cpuid > > -_mesa_x86_64_cpuid: > > +GLOBL GLNAME(_mesa_x86_64_cpuid) > > +HIDDEN(_mesa_x86_64_cpuid) > > +GLNAME(_mesa_x86_64_cpuid): > > pushq %rbx > > movl(%rdi), %eax > > movl8(%rdi), %ecx > > @@ -46,9 +47,9 @@ _mesa_x86_64_cpuid: > > ret > > > > .align 16 > > -.globl _mesa_x86_64_transform_points4_general > > -.hidden _mesa_x86_64_transform_points4_general > > -_mesa_x86_64_transform_points4_general: > > +GLOBL GLNAME(_mesa_x86_64_transform_points4_general) > > +HIDDEN(_mesa_x86_64_transform_points4_general) > > +GLNAME(_mesa_x86_64_transform_points4_general): > > /* > > * rdi = dest > > * rsi = matrix > > @@ -105,8 +106,10 @@ p4_general_loop: > > p4_general_done: > > .byte 0xf3 > > ret > > - > > + > > +#if defined (__ELF__) && defined (__linux__) > > .section .rodata > > +#endif > > > > .align 16 > > p4_constants: > > @@ -122,13 +125,13 @@ p4_constants: > > > > .text > > .align 16 > > -.globl _mesa_x86_64_transform_points4_3d > > -.hidden _mesa_x86_64_transform_points4_3d > > +GLOBL GLNAME(_mesa_x86_64_transform_points4_3d) > > +HIDDEN(_mesa_x86_64_transform_points4_3d) > > /* > > * this is slower than _mesa_x86_64_transform_points4_general > > * because it ensures that the last matrix row (or is it column?) is > 0,0,0,1 > > */ > > -_mesa_x86_64_transform_points4_3d: > > +GLNAME(_mesa_x86_64_transform_points4_3d): > > > > leaq p4_constants(%rip), %rax > > > > @@ -194,9 +197,9 @@ p4_3d_done: > > > > > > .align 16 > > -.globl _mesa_x86_64_transform_points4_identity > > -.hidden _mesa_x86_64_transform_points4_identity > > -_mesa_x86_64_transform_points4_identity: > > +GLOBL GLNAME(_mesa_x86_64_transform_points4_identity) > > +HIDDEN(_mesa_x86_64_transform_points4_identitiy) > > +GLNAME(_mesa_x86_64_transform_points4_identity): > > > > movl V4F_COUNT(%rdx), %ecx /* count */ > > movzbl V4F_STRIDE(%rdx), %eax /* stride */ > > @@ -223,9 +226,9 @@ p4_identity_done: > > > > > > .align 16 > > -.globl _mesa_3dnow_transform_points4_3d_no_rot > > -.hidden _mesa_3dnow_transform_points4_3d_no_rot > > -_mesa_3dnow_transform_points4_3d_no_rot: > > +GLOBL GLNAME(_mesa_3dnow_transform_points4_3d_no_rot) > > +HIDDEN(_mesa_3dnow_transform_points4_3d_no_rot) > > +GLNAME(_mesa_3dnow_transform_points4_3d_no_rot): > > > > movl V4F_COUNT(%rdx), %ecx /* count */ > > movzbl V4F_STRIDE(%rdx), %eax /* stride */ > > @@ -288,9 +291,9 @@ p4_3d_no_rot_done: > > > > > > .align 16 > > -.globl _mesa_3dnow_transform_points4_perspective > > -.hidden _mesa_3dnow_transform_points4_perspective > > -_mesa_3dnow_transform_points4_perspective: > > +GLOBL GLNAME(_mesa_3dnow_transform_points4_perspective) > > +HIDDEN(_mesa_3dnow_transform_points4_perspective) > > +GLNAME(_mesa_3dnow_transform_points4_perspective): > > > > movl V4F_COUNT(%rdx), %ecx
[Mesa-dev] [PATCH] loader: move loader_open_device out of HAVE_LIBUDEV block
Fixes: CCLD libGL.la ./.libs/libglx.a(dri2_glx.o): In function `dri2CreateScreen': src/glx/dri2_glx.c:1186: undefined reference to `loader_open_device' collect2: ld returned 1 exit status CCLD libEGL.la Undefined symbols for architecture x86_64: "_loader_open_device", referenced from: _dri2_initialize_x11_dri2 in libegl_dri2.a(platform_x11.o) https://bugs.freedesktop.org/show_bug.cgi?id=91077 Signed-off-by: Julien Isorce --- src/loader/loader.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/loader/loader.c b/src/loader/loader.c index fc46815..8452cd3 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -64,6 +64,8 @@ *Rob Clark */ +#include +#include #include #include #include @@ -71,10 +73,8 @@ #ifdef HAVE_LIBUDEV #include #include -#include #include #include -#include #ifdef USE_DRICONF #include "xmlconfig.h" #include "xmlpool.h" @@ -104,6 +104,22 @@ static void default_logger(int level, const char *fmt, ...) static void (*log_)(int level, const char *fmt, ...) = default_logger; +int +loader_open_device(const char *device_name) +{ + int fd; +#ifdef O_CLOEXEC + fd = open(device_name, O_RDWR | O_CLOEXEC); + if (fd == -1 && errno == EINVAL) +#endif + { + fd = open(device_name, O_RDWR); + if (fd != -1) + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); + } + return fd; +} + #ifdef HAVE_LIBUDEV #include @@ -314,22 +330,6 @@ get_id_path_tag_from_fd(struct udev *udev, int fd) return id_path_tag; } -int -loader_open_device(const char *device_name) -{ - int fd; -#ifdef O_CLOEXEC - fd = open(device_name, O_RDWR | O_CLOEXEC); - if (fd == -1 && errno == EINVAL) -#endif - { - fd = open(device_name, O_RDWR); - if (fd != -1) - fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); - } - return fd; -} - #ifdef USE_DRICONF const char __driConfigOptionsLoader[] = DRI_CONF_BEGIN -- 1.9.5 (Apple Git-50.3) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/5] darwin: Suppress type conversion warnings for GLhandleARB
On 19 June 2015 at 10:24, Jose Fonseca wrote: > On 19/06/15 04:46, Ian Romanick wrote: > >> On 06/17/2015 10:53 PM, Julien Isorce wrote: >> >>> From: Jon TURNEY >>> >>> On darwin, GLhandleARB is defined as a void *, not the unsigned int it >>> is on >>> linux. >>> >>> For the moment, apply a cast to supress the warning >>> >>> Possibly this is safe, as for the mesa software renderer the shader >>> program >>> handle is not a real pointer, but a integer handle >>> >>> Probably this is not the right thing to do, and we should pay closer >>> attention >>> to how the GLhandlerARB type is used. >>> >> >> In Mesa, glBindAttribLocation (which takes GLuint) and >> glBindAttribLocationARB (which takes GLhandleARB) are *the same >> function*. The same applies to pretty much all the other GLhandleARB >> functions. >> > > > Properly fixing this is a nightmare, but I think that short term > workaround is feasible. > > This is the generated glapitemp.h: > > KEYWORD1 void KEYWORD2 NAME(BindAttribLocationARB)(GLhandleARB program, > GLuint index, const GLcharARB * name) > { > (void) program; (void) index; (void) name; > DISPATCH(BindAttribLocation, (program, index, name), (F, > "glBindAttribLocationARB(%d, %d, %p);\n", program, index, (const void *) > name)); > } > > Provided that GLhandlerARB is defined as `unsigned long` during Mesa build > on MacOSX Hi, where exactly ? or do you mean we just need to apply the patch [1] you pointed ? > (to avoid these int<->void *) conversions [1], the compiler should > implicitly cast the 64bits GLhandlerARB program to an 32-bits GLuint. > > So, when an app calls glBindAttribLocationARB it will be dispatched to > _mesa_BindAttribLocation, and the program truncated. So it should all just > work. > > Ditto for when GLhandleARB appears as return value. > > > The only problem is when GLhandleARB appears as a pointer, as there is > only one such instance: > > GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, > GLsizei maxCount, GLsizei *count, GLhandleARB *obj); > > But we do have a separate entry-point for this > (_mesa_GetAttachedObjectsARB) so again, we're all good. > > > So, Jon/Julien's patch seems perfectly workable -- all really left to do > is to silence GLhandleARB <-> GLuint conversions. > That's a good news. So Jose concretely what needs to be done ? Just apply the patch [1] you pointed or apply cast everywhere ? All conversions are in the 3 files, src/mesa/main/dlist.c, src/mesa/main/shaderapi.c and src/mesa/main/shader_query.cpp, am I right ? I did not notice before, but without any change on upstream code, it gives an error only when compiling c++ files. For c files it is a warning: main/shaderapi.*c*:1148:23: warning: incompatible pointer to integer conversion passing 'GLhandleARB' (aka 'void *') to parameter of type 'GLuint' (aka 'unsigned int') [-Wint-conversion] attach_shader(ctx, program, shader); main/shader_query.*cpp*:72:7: error: no matching function for call to '_mesa_lookup_shader_program_err' "glBindAttribLocation");../../src/mesa/main/shaderobj.h:89:1: note: candidate function not viable: cannot convert argument of incomplete type 'GLhandleARB' (aka 'void *') to 'GLuint' (aka 'unsigned int')_mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name, Thx > > > Jose > > > [1] Apitrace also defines GLhandleARB as unsigned long internally to avoid > this > https://github.com/apitrace/apitrace/blob/master/thirdparty/khronos/GL/glext.patch > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2] darwin: Suppress type conversion warnings for GLhandleARB
darwin: silence GLhandleARB convertions from and to GLuint This patch and its description are inspired from Jose Fonseca explanations and suggestions. With this patch the following logic applies and only if __APPLE__: When building mesa, GLhandleARB is defined as unsigned long and at some point casted to GLuint in gl fuction implementations. These exact points are where these errors and warnings appear. When building an application GLhandleARB is defined as void*. Later when calling a gl function, for example glBindAttribLocationARB, it will be dispatched to _mesa_BindAttribLocation. So internally void* will be treated as unsigned long which has the same size. So the same truncation happens when casting it to GLuint. Same when GLhandleARB appears as return value. For mesa it will be GLuint -> unsigned long. For an application it will be GLuint -> unsigned long -> void*. Note that the value will be preserved when casting back to GLuint. When GLhandleARB appears as a pointer there are also separate entry-points, i.e. _mesa_FuncNameARB. So the same logic can be applied. https://bugs.freedesktop.org/show_bug.cgi?id=66346 Signed-off-by: Julien Isorce --- configure.ac | 2 +- include/GL/glext.h | 5 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7661bd9..1cd8e77 100644 --- a/configure.ac +++ b/configure.ac @@ -1357,7 +1357,7 @@ if test "x$enable_dri" = xyes; then fi ;; darwin*) -DEFINES="$DEFINES -DGLX_ALIAS_UNSUPPORTED" +DEFINES="$DEFINES -DGLX_ALIAS_UNSUPPORTED -DBUILDING_MESA" if test "x$with_dri_drivers" = "xyes"; then with_dri_drivers="swrast" fi diff --git a/include/GL/glext.h b/include/GL/glext.h index a3873a6..e5f1d89 100644 --- a/include/GL/glext.h +++ b/include/GL/glext.h @@ -3879,7 +3879,12 @@ GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #ifndef GL_ARB_shader_objects #define GL_ARB_shader_objects 1 #ifdef __APPLE__ +#ifdef BUILDING_MESA +/* Avoid uint <-> void* warnings */ +typedef unsigned long GLhandleARB; +#else typedef void *GLhandleARB; +#endif #else typedef unsigned int GLhandleARB; #endif -- 1.9.5 (Apple Git-50.3) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2] egl: use unix defines on osx with clang
From: Julien Isorce I also created an bug in Khronos 's bugzilla as you suggested: https://www.khronos.org/bugzilla/show_bug.cgi?id=1356 I'll let you know if I get feedback from this bug or else where. Patch with updated error messages: [PATCH] eglplatform: treat __APPLE__ the same way as __unix__ to handle X11 types CC eglapi.lo ./egldisplay.h:258:19: error: unknown type name 'Display' _eglGetX11Display(Display *native_display, const EGLint *attrib_list); eglapi.c:290:4: error: array size is negative STATIC_ASSERT(sizeof(void*) == sizeof(nativeDisplay)); eglapi.c:291:25: warning: cast to 'void *' from smaller integer type 'EGLNativeDisplayType' (aka 'int') [-Wint-to-void-pointer-cast] native_display_ptr = (void*) nativeDisplay; eglapi.c:307:32: error: use of undeclared identifier 'Display' dpy = _eglGetX11Display((Display*) native_display, attrib_list); eglapi.c:776:35: error: use of undeclared identifier 'Window' native_window = (void*) (* (Window*) native_window); eglapi.c:847:35: error: use of undeclared identifier 'Pixmap' native_pixmap = (void*) (* (Pixmap*) native_pixmap); Bugzilla Mesa: https://bugs.freedesktop.org/show_bug.cgi?id=90249 Bugzilla Khronos: https://www.khronos.org/bugzilla/show_bug.cgi?id=1356 Signed-off-by: Julien Isorce --- include/EGL/eglplatform.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/EGL/eglplatform.h b/include/EGL/eglplatform.h index 7802542..b376e64 100644 --- a/include/EGL/eglplatform.h +++ b/include/EGL/eglplatform.h @@ -77,7 +77,7 @@ typedef HDC EGLNativeDisplayType; typedef HBITMAP EGLNativePixmapType; typedef HWNDEGLNativeWindowType; -#elif defined(__APPLE__) || defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ typedef int EGLNativeDisplayType; typedef void *EGLNativeWindowType; @@ -105,7 +105,7 @@ typedef struct ANativeWindow* EGLNativeWindowType; typedef struct egl_native_pixmap_t* EGLNativePixmapType; typedef void* EGLNativeDisplayType; -#elif defined(__unix__) +#elif defined(__unix__) || defined(__APPLE__) #if defined(MESA_EGL_NO_X11_HEADERS) -- 1.9.5 (Apple Git-50.3) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC] loader: libudev vs sysfs vs libdrm
>> - libdrm: used as a last resource fall-back after the above two. the >> sole option used by *BSD, MacOS and Android. Hi, Unless I am missing something, libdrm is not used on MacOS. On osx, EGL_PLATFORM=x11 eglGetDisplay(NULL) calls dri2_initialize_x11 which fallback to dri2_initialize_x11_swrast. Though libdrm can be built and then EGL_PLATFORM=drm eglGetDisplay(NULL) calls dri2_initialize_drm which fallback to swrast . But not sure how gbm surfaces are useful. And there is no kernel side for drm on darwin right ? Speaking about egl, on linux+x11, the driver name is retrieved with xcb_dri2_connect_driver_name (except swrast which is harcoded) and then loaded with dri2_open_driver (= dlopen of %s_dri.so) So this mechanism is not either libudev, sysfs or libdrm. Am I missing something (or is it part of sysfs) ? Or the X server internally will use one of these 3 ? Also any plan to support eglQueryDevicesEXT ( https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_device_enumeration.txt) ? On 9 July 2015 at 22:00, Emil Velikov wrote: > On 09/07/15 15:40, Axel Davy wrote: > > On 09/07/2015 15:33, Emil Velikov wrote : > >> > >> Yakes forgot about that one. From a quick look we can (I know it feels > >> durty) use readlink( > >> /sys/dev/char/$(major):$(minor)). > >> > >> Everything seems to be there - bus type and exact location of the > >> device on the bus. It's limited to sysfs users, but they are more than > >> the libudev ones (perhaps not by much). How does that sound ? > >> > >> Cheers, > >> Emil > >> > > The idea behind using udev for the tag was that arbitrary tag could be > > used, > > especially to identify usb devices. > > > So avoid breaking peoples' setup the above example can be used to > produce the very same tag(s). Regardles if it's a device on the pci or > usb bus. Speaking of usb, are there any devices supported with upstream > mesa ? > > -Emil > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 0/6] nouveau: add support for vaapi
On 18 September 2015 at 21:34, Ilia Mirkin wrote: > On Fri, Sep 18, 2015 at 4:29 PM, Julien Isorce > wrote: > > > > > > On 17 September 2015 at 17:52, Ilia Mirkin wrote: > >> > >> On Wed, Sep 16, 2015 at 8:22 AM, Julien Isorce > >> wrote: > >> > I added below version4 updates. It works for all codecs expect h264. > >> > Video is visible but lot of blockiness. > >> > Can someone with a Radeon confirm that "LIBVA_DRIVER_NAME=gallium mpv > >> > --hwdec=vaapi" > >> > is working on h264 videos ? > >> > I want to make sure it is not a bug in st/va. > >> > >> The sad reality is that h264 is the only thing that matters (at least > >> from this list of supported codecs). My concern is that this series > >> will regress the situation for people who want to use VA-API -- right > >> now they can use the vdpau <-> vaapi adapter, whereas with this patch > >> series, they will end up with a va-api driver that doesn't work. So I > >> can't merge this as-is. > > > > > > Make perfectly sense. > > > >> > >> > >> Are the various lengths (for inter-bo size/etc) being computed > >> properly > > > > > > In the past I compared the final content of the nouveau_bo buffer at each > > endFrame step , with the content using vdpau. There were the same. > > I will re-check. > > Does it make sense to do that actually ? > > Is there anything else I could compare with vdpau ? > > If you're feeding the exact same stuff and everything is exactly the > same, then the results would also be the same. Clearly there's SOME > difference SOMEWHERE :) > Indeed I compared only dec->bsp_bo, not dec->inter_bo :) I'll check that. But in the first place I do not see where dec->inter_bo is filled. Could you point out where this is done ? > > > > >> > >> Are you writing stuff to the correct inter bo? IIRC we flip > >> between two of them, perhaps that logic got upset? > > > > > > Probably I missed something. Does the flip happen at each endFrame ? > > Could you point out where this flip is in the current upstream code > exactly > > ? > > I mean stuff like this: > >struct nouveau_bo *bsp_bo = dec->bsp_bo[comm_seq % > NOUVEAU_VP3_VIDEO_QDEPTH]; > I see what you meant by flip now. > > src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c: bo_refs[1].bo > = dec->inter_bo[comm_seq & 1] = inter_bo = tmp_bo; > > and so on. Make sure that comm_seq is incremented once per frame, not > once per chunk :) > Yes it is incremented just once per frame, not per chunk. See "nvc0_decoder_begin_frame" in "[PATCH v4 2/6] nvc0: add support for st/va" Thx for your comments Julien > > -ilia > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/7] st/va: in VaPutImage only destroy previous buffer if pipe->create_video_buffer succeeds
If formats are not the same it seems to re-create the video buffer with the right format. But if the creation of this new video buffer fails the surface loose its video buffer. Let's just destroy the previous buffer on success. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/image.c | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index c7fbe1a..d3b0cd5 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -338,13 +338,22 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, if (format == PIPE_FORMAT_NONE) return VA_STATUS_ERROR_OPERATION_FAILED; - if (surf->buffer == NULL || format != surf->buffer->buffer_format) { + if (format != surf->buffer->buffer_format) { + struct pipe_video_buffer *tmp_buf = NULL; + enum pipe_format old_surf_format = surf->templat.buffer_format; + + surf->templat.buffer_format = format; + tmp_buf = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); + + if (!tmp_buf) { + surf->templat.buffer_format = old_surf_format; + return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + if (surf->buffer) surf->buffer->destroy(surf->buffer); - surf->templat.buffer_format = format; - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); - if (!surf->buffer) - return VA_STATUS_ERROR_ALLOCATION_FAILED; + + surf->buffer = tmp_buf; } views = surf->buffer->get_sampler_view_planes(surf->buffer); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/7] st/va: properly defines VAImageFormat formats and improve VaCreateImage
Also add RGBA, RGBX and BGRX. Also extend ChromaToPipe and implement PipeToYCbCr. Note that gstreamer-vaapi check all the VAImageFormat fields. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/image.c | 10 ++-- src/gallium/state_trackers/va/va_private.h | 38 +- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index 022240d..c7fbe1a 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -44,7 +44,10 @@ static const VAImageFormat formats[VL_VA_MAX_IMAGE_FORMATS] = {VA_FOURCC('Y','V','1','2')}, {VA_FOURCC('Y','U','Y','V')}, {VA_FOURCC('U','Y','V','Y')}, - {VA_FOURCC('B','G','R','A')} + {.fourcc = VA_FOURCC('B','G','R','A'), .byte_order = VA_LSB_FIRST, 32, 32, 0x00ff, 0xff00, 0x00ff, 0xff00}, + {.fourcc = VA_FOURCC('R','G','B','A'), .byte_order = VA_LSB_FIRST, 32, 32, 0x00ff, 0xff00, 0x00ff, 0xff00}, + {.fourcc = VA_FOURCC('B','G','R','X'), .byte_order = VA_LSB_FIRST, 32, 24, 0x00ff, 0xff00, 0x00ff, 0x}, + {.fourcc = VA_FOURCC('R','G','B','X'), .byte_order = VA_LSB_FIRST, 32, 24, 0x00ff, 0xff00, 0x00ff, 0x} }; static void @@ -116,7 +119,7 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig img->width = width; img->height = height; w = align(width, 2); - h = align(width, 2); + h = align(height, 2); switch (format->fourcc) { case VA_FOURCC('N','V','1','2'): @@ -149,6 +152,9 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig break; case VA_FOURCC('B','G','R','A'): + case VA_FOURCC('R','G','B','A'): + case VA_FOURCC('B','G','R','X'): + case VA_FOURCC('R','G','B','X'): img->num_planes = 1; img->pitches[0] = w * 4; img->offsets[0] = 0; diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 1ea7be7..3479156 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -46,7 +46,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 6 +#define VL_VA_MAX_IMAGE_FORMATS 9 static inline enum pipe_video_chroma_format ChromaToPipe(int format) @@ -58,6 +58,8 @@ ChromaToPipe(int format) return PIPE_VIDEO_CHROMA_FORMAT_422; case VA_RT_FORMAT_YUV444: return PIPE_VIDEO_CHROMA_FORMAT_444; + case VA_RT_FORMAT_RGB32: + return 0; default: assert(0); return PIPE_VIDEO_CHROMA_FORMAT_420; @@ -80,12 +82,46 @@ YCbCrToPipe(unsigned format) return PIPE_FORMAT_UYVY; case VA_FOURCC('B','G','R','A'): return PIPE_FORMAT_B8G8R8A8_UNORM; + case VA_FOURCC('R','G','B','A'): + return PIPE_FORMAT_R8G8B8A8_UNORM; + case VA_FOURCC('B','G','R','X'): + return PIPE_FORMAT_B8G8R8X8_UNORM; + case VA_FOURCC('R','G','B','X'): + return PIPE_FORMAT_R8G8B8X8_UNORM; default: assert(0); return PIPE_FORMAT_NONE; } } +static inline unsigned +PipeToYCbCr(enum pipe_format p_format) +{ + switch (p_format) { + case PIPE_FORMAT_NV12: + return VA_FOURCC('N','V','1','2'); + case PIPE_FORMAT_IYUV: + return VA_FOURCC('I','4','2','0'); + case PIPE_FORMAT_YV12: + return VA_FOURCC('Y','V','1','2'); + case PIPE_FORMAT_UYVY: + return VA_FOURCC('U','Y','V','Y'); + case PIPE_FORMAT_YUYV: + return VA_FOURCC('Y','U','Y','V'); + case PIPE_FORMAT_B8G8R8A8_UNORM: + return VA_FOURCC('B','G','R','A'); + case PIPE_FORMAT_R8G8B8A8_UNORM: + return VA_FOURCC('R','G','B','A'); + case PIPE_FORMAT_B8G8R8X8_UNORM: + return VA_FOURCC('B','G','R','X'); + case PIPE_FORMAT_R8G8B8X8_UNORM: + return VA_FOURCC('R','G','B','X'); + default: + assert(0); + return -1; + } +} + static inline VAProfile PipeToProfile(enum pipe_video_profile profile) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/7] st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes
Inspired from http://cgit.freedesktop.org/vaapi/intel-driver/tree/src/i965_drv_video.c Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/context.c| 5 +- src/gallium/state_trackers/va/surface.c| 288 - src/gallium/state_trackers/va/va_private.h | 7 + 3 files changed, 249 insertions(+), 51 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 8b003ae..8949d42 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -81,7 +81,10 @@ static struct VADriverVTable vtable = &vlVaSetDisplayAttributes, &vlVaBufferInfo, &vlVaLockSurface, - &vlVaUnlockSurface + &vlVaUnlockSurface, + &vlVaGetSurfaceAttributes, + &vlVaCreateSurfaces2, + &vlVaQuerySurfaceAttributes }; PUBLIC VAStatus diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 8d4487b..be435cb 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -29,6 +29,8 @@ #include "pipe/p_screen.h" #include "pipe/p_video_codec.h" +#include "state_tracker/drm_driver.h" + #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_rect.h" @@ -36,6 +38,7 @@ #include "util/u_surface.h" #include "vl/vl_compositor.h" +#include "vl/vl_video_buffer.h" #include "vl/vl_winsys.h" #include "va_private.h" @@ -44,56 +47,8 @@ VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) { - struct pipe_video_buffer templat = {}; - struct pipe_screen *pscreen; - vlVaDriver *drv; - int i; - - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; - - if (!(width && height)) - return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; - - drv = VL_VA_DRIVER(ctx); - pscreen = VL_VA_PSCREEN(ctx); - - templat.buffer_format = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERED_FORMAT - ); - templat.chroma_format = ChromaToPipe(format); - templat.width = width; - templat.height = height; - templat.interlaced = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERS_INTERLACED - ); - - for (i = 0; i < num_surfaces; ++i) { - vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface)); - if (!surf) - goto no_res; - - surf->templat = templat; - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat); - util_dynarray_init(&surf->subpics); - surfaces[i] = handle_table_add(drv->htab, surf); - } - - return VA_STATUS_SUCCESS; - -no_res: - if (i) - vlVaDestroySurfaces(ctx, surfaces, i); - - return VA_STATUS_ERROR_ALLOCATION_FAILED; +return vlVaCreateSurfaces2(ctx, format, width, height, surfaces, num_surfaces, + NULL, 0); } VAStatus @@ -349,3 +304,236 @@ vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID surface) return VA_STATUS_ERROR_UNIMPLEMENTED; } + +VAStatus +vlVaGetSurfaceAttributes(VADriverContextP ctx, VAConfigID config, + VASurfaceAttrib *attrib_list, unsigned int num_attribs) +{ +return VA_STATUS_ERROR_UNIMPLEMENTED; /* DEPRECATED */ +} + +VAStatus +vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, + VASurfaceAttrib *attrib_list, unsigned int *num_attribs) +{ +VAStatus vaStatus = VA_STATUS_SUCCESS; +vlVaDriver *drv = NULL; +VASurfaceAttrib *attribs = NULL; +struct pipe_screen *pscreen = NULL; +int i = 0; + +if (config == VA_INVALID_ID) +return VA_STATUS_ERROR_INVALID_CONFIG; + +if (!attrib_list && !num_attribs) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +if (attrib_list == NULL) { +*num_attribs = VASurfaceAttribCount; +return VA_STATUS_SUCCESS; +} + +attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + +if (attribs == NULL) +return VA_STATUS_ERROR_ALLOCATION_FAILED; + +if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +drv = VL_VA_DRIVER(ctx); + +if (!drv) +return VA_STATUS_ERROR_INVALID_CONTEXT; + +pscreen = VL_VA_PSCREEN(ctx); + +if (!pscreen) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { + /* Assume VAEntrypointVideoProc for now. */ + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFAC
[Mesa-dev] [PATCH 0/7] st/va: VPP, dmabuf import and headless.
This patch serie adds initial support for Video Post Processing. It also implements VaCreateSurfaces2 for common purpose and also to import a dmabuf. Finally it adds support for headless mode, i.e. using DRM instead of X11 for device setup. Julien Isorce (7): nvc0: fix crash when nv50_miptree_from_handle fails st/va: properly defines VAImageFormat formats and improve VaCreateImage st/va: in VaPutImage only destroy previous buffer if pipe->create_video_buffer succeeds st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes st/va: implement dmabuf import for VaCreateSurfaces2 st/va: add initial Video Post Processing support st/va: add headless support, i.e. VA_DISPLAY_DRM src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 3 +- src/gallium/state_trackers/va/Makefile.am| 9 + src/gallium/state_trackers/va/config.c | 20 + src/gallium/state_trackers/va/context.c | 148 ++-- src/gallium/state_trackers/va/image.c| 29 +- src/gallium/state_trackers/va/picture.c | 89 - src/gallium/state_trackers/va/surface.c | 449 --- src/gallium/state_trackers/va/va_private.h | 59 ++- 8 files changed, 706 insertions(+), 100 deletions(-) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM
This patch allows to use gallium vaapi without requiring a X server running for your second graphic card. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/Makefile.am | 9 ++ src/gallium/state_trackers/va/context.c | 49 +++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/va/Makefile.am b/src/gallium/state_trackers/va/Makefile.am index 2a93a90..348cfe1 100644 --- a/src/gallium/state_trackers/va/Makefile.am +++ b/src/gallium/state_trackers/va/Makefile.am @@ -30,6 +30,15 @@ AM_CFLAGS = \ $(VA_CFLAGS) \ -DVA_DRIVER_INIT_FUNC="__vaDriverInit_$(VA_MAJOR)_$(VA_MINOR)" +AM_CFLAGS += \ + $(GALLIUM_PIPE_LOADER_DEFINES) \ + -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" + +if HAVE_GALLIUM_STATIC_TARGETS +AM_CFLAGS += \ + -DGALLIUM_STATIC_TARGETS=1 +endif + AM_CPPFLAGS = \ -I$(top_srcdir)/include diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index ddc863b..9ab2710 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -28,7 +28,8 @@ #include "pipe/p_screen.h" #include "pipe/p_video_codec.h" - +#include "pipe-loader/pipe_loader.h" +#include "state_tracker/drm_driver.h" #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_video.h" @@ -98,7 +99,7 @@ static struct VADriverVTableVPP vtable_vpp = PUBLIC VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx) { - vlVaDriver *drv; + vlVaDriver *drv = NULL; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -107,8 +108,40 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) if (!drv) return VA_STATUS_ERROR_ALLOCATION_FAILED; - drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); - if (!drv->vscreen) + drv->vscreen = NULL; + + switch (ctx->display_type) { + case VA_DISPLAY_X11: + drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); + if (!drv->vscreen) + goto error_screen; + break; + + case VA_DISPLAY_DRM: + case VA_DISPLAY_DRM_RENDERNODES: { + struct drm_state *drm_info = (struct drm_state *) ctx->drm_state; + if (!drm_info) + goto error_screen; + + drv->vscreen = CALLOC_STRUCT(vl_screen); + +#if GALLIUM_STATIC_TARGETS + drv->vscreen->pscreen = dd_create_screen(drm_info->fd); +#else + int loader_fd = dup(drm_info->fd); + if (loader_fd == -1) + goto error_screen; + + if (pipe_loader_drm_probe_fd(&drv->dev, loader_fd)) + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, PIPE_SEARCH_DIR); +#endif + } + break; + default: + goto error_screen; + } + + if (!drv->vscreen->pscreen) goto error_screen; drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen, @@ -146,8 +179,11 @@ error_htab: error_pipe: vl_screen_destroy(drv->vscreen); + drv->vscreen = NULL; error_screen: + if (drv->vscreen) + FREE(drv->vscreen); FREE(drv); return VA_STATUS_ERROR_ALLOCATION_FAILED; } @@ -266,7 +302,10 @@ vlVaTerminate(VADriverContextP ctx) vl_compositor_cleanup_state(&drv->cstate); vl_compositor_cleanup(&drv->compositor); drv->pipe->destroy(drv->pipe); - vl_screen_destroy(drv->vscreen); + if (ctx->display_type == VA_DISPLAY_X11) + vl_screen_destroy(drv->vscreen); + else + FREE(drv->vscreen); handle_table_destroy(drv->htab); FREE(drv); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/7] st/va: add initial Video Post Processing support
Improve following functions to support VA_PROFILE_NONE profile (vpp): vlVaQueryConfigProfiles vlVaQueryConfigEntrypoints vlVaCreateConfig vlVaQueryConfigAttributes Add VADriverVTableVPP and improve following functions to support vpp: vlVaCreateContext vlVaDestroyContext vlVaBeginPicture vlVaRenderPicture vlVaEndPicture Add handleVAProcPipelineParameterBufferType helper. One of the application is: VASurfaceNV12 -> gstvaapipostproc -> VASurfaceRGBA Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/config.c | 20 +++ src/gallium/state_trackers/va/context.c| 94 +++--- src/gallium/state_trackers/va/picture.c| 89 +++- src/gallium/state_trackers/va/surface.c| 73 +++ src/gallium/state_trackers/va/va_private.h | 13 - 5 files changed, 254 insertions(+), 35 deletions(-) diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index cfb0b25..bde6615 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -52,6 +52,9 @@ vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, int *num_ profile_list[(*num_profiles)++] = vap; } + /* Support postprocessing through vl_compositor */ + profile_list[(*num_profiles)++] = VAProfileNone; + return VA_STATUS_SUCCESS; } @@ -67,6 +70,11 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile, *num_entrypoints = 0; + if (profile == VAProfileNone) { + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; + return VA_STATUS_SUCCESS; + } + p = ProfileToPipe(profile); if (p == PIPE_VIDEO_PROFILE_UNKNOWN) return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; @@ -118,6 +126,11 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) { + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; + return VA_STATUS_SUCCESS; + } + p = ProfileToPipe(profile); if (p == PIPE_VIDEO_PROFILE_UNKNOWN) return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; @@ -151,6 +164,13 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile return VA_STATUS_ERROR_INVALID_CONTEXT; *profile = PipeToProfile(config_id); + + if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { + *entrypoint = VAEntrypointVideoProc; + *num_attribs = 0; + return VA_STATUS_SUCCESS; + } + *entrypoint = VAEntrypointVLD; *num_attribs = 1; diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 8949d42..ddc863b 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -87,6 +87,14 @@ static struct VADriverVTable vtable = &vlVaQuerySurfaceAttributes }; +static struct VADriverVTableVPP vtable_vpp = +{ + VA_DRIVER_VTABLE_VPP_VERSION, + &vlVaQueryVideoProcFilters, + &vlVaQueryVideoProcFilterCaps, + &vlVaQueryVideoProcPipelineCaps +}; + PUBLIC VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx) { @@ -122,6 +130,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) ctx->version_major = 0; ctx->version_minor = 1; *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_attributes = 1; @@ -151,11 +160,16 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, struct pipe_video_codec templat = {}; vlVaDriver *drv; vlVaContext *context; + int is_vpp = 0; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - if (!(picture_width && picture_height)) + is_vpp = config_id == PIPE_VIDEO_PROFILE_UNKNOWN && + picture_width == 0 && picture_height == 0 && flag ==0 && !render_targets + && num_render_targets == 0; + + if (!(picture_width && picture_height) && !is_vpp) return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; drv = VL_VA_DRIVER(ctx); @@ -163,38 +177,48 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, if (!context) return VA_STATUS_ERROR_ALLOCATION_FAILED; - templat.profile = config_id; - templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; - templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; - templat.width = picture_width; - templat.height = picture_height; - templat.max_references = num_render_targets; - templat.expect_chunked_decode = true; - - if (u_reduce_video_profile(templat.profile) == - PIPE_VIDEO_FORMAT_MPEG4_AVC) - templat.level = u_get_h264_level(templat.width, templat.height, -&
[Mesa-dev] [PATCH 5/7] st/va: implement dmabuf import for VaCreateSurfaces2
For now it is limited to RGBA, BGRA, RGBX, BGRX surfaces. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/surface.c| 90 +- src/gallium/state_trackers/va/va_private.h | 1 + 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index be435cb..eb5b8ca 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -376,7 +376,8 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, attribs[i].type = VASurfaceAttribMemoryType; attribs[i].value.type = VAGenericValueTypeInteger; attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; -attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA; +attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | +VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; i++; attribs[i].type = VASurfaceAttribExternalBufferDescriptor; @@ -410,6 +411,82 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, return vaStatus; } +static VAStatus +suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, +VASurfaceAttribExternalBuffers *memory_attibute, +int index, VASurfaceID *surfaces, +struct pipe_video_buffer *templat) +{ +vlVaDriver *drv = NULL; +struct pipe_screen *pscreen = NULL; +struct pipe_resource *resource = NULL; +struct pipe_resource res_templ; +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); + +if (!memory_attibute || !memory_attibute->buffers || index > memory_attibute->num_buffers) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +if (surface->templat.width != memory_attibute->width || +surface->templat.height != memory_attibute->height || +memory_attibute->num_planes < 1) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +switch (memory_attibute->pixel_format) { +case VA_FOURCC_RGBA: +case VA_FOURCC_RGBX: +case VA_FOURCC_BGRA: +case VA_FOURCC_BGRX: +if (memory_attibute->num_planes != 1) +return VA_STATUS_ERROR_INVALID_PARAMETER; +break; +default: +return VA_STATUS_ERROR_INVALID_PARAMETER; +} + +memset(&res_templ, 0, sizeof(res_templ)); +res_templ.target = PIPE_TEXTURE_2D; +res_templ.last_level = 0; +res_templ.depth0 = 1; +res_templ.array_size = 1; +res_templ.width0 = memory_attibute->width; +res_templ.height0 = memory_attibute->height; +res_templ.format = surface->templat.buffer_format; +res_templ.bind = PIPE_BIND_SAMPLER_VIEW; +res_templ.usage = PIPE_USAGE_DEFAULT; + +memset(&whandle, 0, sizeof(struct winsys_handle)); +whandle.type = DRM_API_HANDLE_TYPE_FD; +whandle.handle = memory_attibute->buffers[index]; +whandle.stride = memory_attibute->pitches[index]; + +resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle); + +if (!resource) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + +memset(resources, 0, sizeof resources); +resources[0] = resource; + +surface->buffer = vl_video_buffer_create_ex2(drv->pipe, templat, resources); +if (!surface->buffer) +return VA_STATUS_ERROR_ALLOCATION_FAILED; + +util_dynarray_init(&surface->subpics); +surfaces[index] = handle_table_add(drv->htab, surface); + +if (!surfaces[index]) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + +return VA_STATUS_SUCCESS; +} + VAStatus vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, unsigned int width, unsigned int height, @@ -450,6 +527,9 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, switch (attrib_list[i].value.value.i) { case VA_SURFACE_ATTRIB_MEM_TYPE_VA: +case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: +memory_type = attrib_list[i].value.value.i; +break; default:{ return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE;} } @@ -477,6 +557,9 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, switch (memory_type) { case VA_SURFACE_ATTRIB_MEM_TYPE_VA: break; +case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: +expected_fourcc = memory_attibute->pixel_format; +break; default: assert(0); } @@ -522,6 +605,11 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, util_dynarray_init(&surf->subpics);
[Mesa-dev] [PATCH 1/7] nvc0: fix crash when nv50_miptree_from_handle fails
Signed-off-by: Julien Isorce --- src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c index 12b5a02..15c803c 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c @@ -26,7 +26,8 @@ nvc0_resource_from_handle(struct pipe_screen * screen, } else { struct pipe_resource *res = nv50_miptree_from_handle(screen, templ, whandle); - nv04_resource(res)->vtbl = &nvc0_miptree_vtbl; + if (res) + nv04_resource(res)->vtbl = &nvc0_miptree_vtbl; return res; } } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/7] nvc0: fix crash when nv50_miptree_from_handle fails
Thx for the review. I experienced the crash when testing patch 5/7 of this patch series, around "resource = pscreen->resource_from_handle" in the new vaCreateSurface2 function. Julien On 19 October 2015 at 16:59, Emil Velikov wrote: > On 17 October 2015 at 00:14, Julien Isorce > wrote: > > Signed-off-by: Julien Isorce > > --- > > src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c > b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c > > index 12b5a02..15c803c 100644 > > --- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c > > +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c > > @@ -26,7 +26,8 @@ nvc0_resource_from_handle(struct pipe_screen * screen, > > } else { > >struct pipe_resource *res = nv50_miptree_from_handle(screen, > > templ, > whandle); > > - nv04_resource(res)->vtbl = &nvc0_miptree_vtbl; > > + if (res) > > + nv04_resource(res)->vtbl = &nvc0_miptree_vtbl; > Did you actually experience the crash or did you notice this while > browsing through ? > > Either way - abeit unlikely we can return NULL, so let's avoid the crash. > Cc: "11.0" > Reviewed-by: Emil Velikov > > Thanks > Emil > g > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/7] st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes
On 19 October 2015 at 16:55, Emil Velikov wrote: > On 17 October 2015 at 00:14, Julien Isorce > wrote: > > Inspired from > http://cgit.freedesktop.org/vaapi/intel-driver/tree/src/i965_drv_video.c > > > Please mention the actual usecase here and/or how you've tested this. > Thx for the review. All right I'll amend commit message that this is to support gstreamer-vaapi. Also the first advantage to use VaCreateSurfaces2 over existing VaCreateSurfaces, is that you can select which pixel format you want for the surface. Pixel format that you can query with new function: vlVaQuerySurfaceAttributes > > > Signed-off-by: Julien Isorce > > --- > > src/gallium/state_trackers/va/context.c| 5 +- > > src/gallium/state_trackers/va/surface.c| 288 > - > > src/gallium/state_trackers/va/va_private.h | 7 + > > 3 files changed, 249 insertions(+), 51 deletions(-) > > > > diff --git a/src/gallium/state_trackers/va/context.c > b/src/gallium/state_trackers/va/context.c > > index 8b003ae..8949d42 100644 > > --- a/src/gallium/state_trackers/va/context.c > > +++ b/src/gallium/state_trackers/va/context.c > > @@ -81,7 +81,10 @@ static struct VADriverVTable vtable = > > &vlVaSetDisplayAttributes, > > &vlVaBufferInfo, > > &vlVaLockSurface, > > - &vlVaUnlockSurface > > + &vlVaUnlockSurface, > > + &vlVaGetSurfaceAttributes, > > + &vlVaCreateSurfaces2, > > + &vlVaQuerySurfaceAttributes > > }; > > > > PUBLIC VAStatus > > diff --git a/src/gallium/state_trackers/va/surface.c > b/src/gallium/state_trackers/va/surface.c > > index 8d4487b..be435cb 100644 > > --- a/src/gallium/state_trackers/va/surface.c > > +++ b/src/gallium/state_trackers/va/surface.c > > @@ -29,6 +29,8 @@ > > #include "pipe/p_screen.h" > > #include "pipe/p_video_codec.h" > > > > +#include "state_tracker/drm_driver.h" > > + > > #include "util/u_memory.h" > > #include "util/u_handle_table.h" > > #include "util/u_rect.h" > > @@ -36,6 +38,7 @@ > > #include "util/u_surface.h" > > > > #include "vl/vl_compositor.h" > > +#include "vl/vl_video_buffer.h" > > #include "vl/vl_winsys.h" > > > > #include "va_private.h" > > @@ -44,56 +47,8 @@ VAStatus > > vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int > format, > > int num_surfaces, VASurfaceID *surfaces) > > { > > - struct pipe_video_buffer templat = {}; > > - struct pipe_screen *pscreen; > > - vlVaDriver *drv; > > - int i; > > - > > - if (!ctx) > > - return VA_STATUS_ERROR_INVALID_CONTEXT; > > - > > - if (!(width && height)) > > - return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; > > - > > - drv = VL_VA_DRIVER(ctx); > > - pscreen = VL_VA_PSCREEN(ctx); > > - > > - templat.buffer_format = pscreen->get_video_param > > - ( > > - pscreen, > > - PIPE_VIDEO_PROFILE_UNKNOWN, > > - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, > > - PIPE_VIDEO_CAP_PREFERED_FORMAT > > - ); > > - templat.chroma_format = ChromaToPipe(format); > > - templat.width = width; > > - templat.height = height; > > - templat.interlaced = pscreen->get_video_param > > - ( > > - pscreen, > > - PIPE_VIDEO_PROFILE_UNKNOWN, > > - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, > > - PIPE_VIDEO_CAP_PREFERS_INTERLACED > > - ); > > - > > - for (i = 0; i < num_surfaces; ++i) { > > - vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface)); > > - if (!surf) > > - goto no_res; > > - > > - surf->templat = templat; > > - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, > &templat); > > - util_dynarray_init(&surf->subpics); > > - surfaces[i] = handle_table_add(drv->htab, surf); > > - } > > - > > - return VA_STATUS_SUCCESS; > > - > > -no_res: > > - if (i) > > - vlVaDestroySurfaces(ctx, surfaces, i); > > - > > - return VA_STATUS_ERROR_ALLOCATION_FAILED; > > +return vlVaCreateSurfaces2(ctx, format, width, height, surfaces, > num_surfaces, > > + NULL, 0); > > } > > > > VAStatus > > @@ -349,3 +304,236 @@ vlVaUnlockSurface(VADriverContextP ctx, > VASurfaceID surface) >
Re: [Mesa-dev] [PATCH 2/7] st/va: properly defines VAImageFormat formats and improve VaCreateImage
On 17 October 2015 at 00:25, Ilia Mirkin wrote: > Not sure how VA specifies things, but if the RGBA8 stuff is supposed > to be in CPU-endian as packed 32-bit ints, I think you're meant to use > PIPE_FORMAT_RGBA_UNORM and so on. However if it's always supposed > to be little-endian or array-based, then the way you have it is fine. > Great question. >From what I can read, I think in VA there is no fixed assumption, for example VA_FOURCC('A','B','G','R') exists, I think currently mesa st/va just only supports VA_LSB_FIRST (but VA_MSB_FIRST exists in libva headers). Initially I just extended existing code: case VA_FOURCC('B','G','R','A'): return PIPE_FORMAT_B8G8R8A8_UNORM; I also compared with intel vaapi driver: http://cgit.freedesktop.org/vaapi/intel-driver/tree/src/i965_drv_video.c#n291 It seems they only use LSB case. Though MSB is handled in unmaintained vaapi driver bridge for vdpau: http://cgit.freedesktop.org/vaapi/vdpau-driver/tree/src/vdpau_image.c#n57 As you raised the question, I decided to ask on libva irc channel to poke some maintainers. But actually you replied to me :) (for the record, you replied there is not a ton of big endian intel cpu). Well in any case libva defines for example VA_FOURCC('A','B','G','R') and VA_FOURCC('B','G','R','A'), so I guess it means I should not use PIPE_FORMAT_RGBA_UNORM-likes so I guess the patch is ok. I think for now mesa st/va does not work on big endian cpu when it is about using "RGBs" formats. And after my patch it still does not. Though I can add them if you want but it will be untested :) Julien > > -ilia > > On Fri, Oct 16, 2015 at 7:14 PM, Julien Isorce > wrote: > > Also add RGBA, RGBX and BGRX. > > Also extend ChromaToPipe and implement PipeToYCbCr. > > > > Note that gstreamer-vaapi check all the VAImageFormat fields. > > > > Signed-off-by: Julien Isorce > > --- > > src/gallium/state_trackers/va/image.c | 10 ++-- > > src/gallium/state_trackers/va/va_private.h | 38 > +- > > 2 files changed, 45 insertions(+), 3 deletions(-) > > > > diff --git a/src/gallium/state_trackers/va/image.c > b/src/gallium/state_trackers/va/image.c > > index 022240d..c7fbe1a 100644 > > --- a/src/gallium/state_trackers/va/image.c > > +++ b/src/gallium/state_trackers/va/image.c > > @@ -44,7 +44,10 @@ static const VAImageFormat > formats[VL_VA_MAX_IMAGE_FORMATS] = > > {VA_FOURCC('Y','V','1','2')}, > > {VA_FOURCC('Y','U','Y','V')}, > > {VA_FOURCC('U','Y','V','Y')}, > > - {VA_FOURCC('B','G','R','A')} > > + {.fourcc = VA_FOURCC('B','G','R','A'), .byte_order = VA_LSB_FIRST, > 32, 32, 0x00ff, 0xff00, 0x00ff, 0xff00}, > > + {.fourcc = VA_FOURCC('R','G','B','A'), .byte_order = VA_LSB_FIRST, > 32, 32, 0x00ff, 0xff00, 0x00ff, 0xff00}, > > + {.fourcc = VA_FOURCC('B','G','R','X'), .byte_order = VA_LSB_FIRST, > 32, 24, 0x00ff, 0xff00, 0x00ff, 0x}, > > + {.fourcc = VA_FOURCC('R','G','B','X'), .byte_order = VA_LSB_FIRST, > 32, 24, 0x00ff, 0xff00, 0x00ff, 0x} > > }; > > > > static void > > @@ -116,7 +119,7 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat > *format, int width, int heig > > img->width = width; > > img->height = height; > > w = align(width, 2); > > - h = align(width, 2); > > + h = align(height, 2); > > > > switch (format->fourcc) { > > case VA_FOURCC('N','V','1','2'): > > @@ -149,6 +152,9 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat > *format, int width, int heig > >break; > > > > case VA_FOURCC('B','G','R','A'): > > + case VA_FOURCC('R','G','B','A'): > > + case VA_FOURCC('B','G','R','X'): > > + case VA_FOURCC('R','G','B','X'): > >img->num_planes = 1; > >img->pitches[0] = w * 4; > >img->offsets[0] = 0; > > diff --git a/src/gallium/state_trackers/va/va_private.h > b/src/gallium/state_tra
Re: [Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM
On 19 October 2015 at 17:16, Emil Velikov wrote: > On 17 October 2015 at 00:14, Julien Isorce > wrote: > > This patch allows to use gallium vaapi without requiring > > a X server running for your second graphic card. > > > I've sent a lengthy series which should mitigate the need of some hunks. > Ok I'll wait for your patches to land before going further on this patch. Should I expect vl_winsy_drm.c in your patches ? Not sure do understood that part. Actually I though about having "vl_screen_create_drm" and renames vl_screen_create to vl_screen_create_x11 (because it takes XDisplay in params) but then I got confused because vl_winsys.h includes Xlib.h. Should future vl_screen_create_drm be in another header, vl_drm.h ? Thx Julien > > Signed-off-by: Julien Isorce > > --- > > src/gallium/state_trackers/va/Makefile.am | 9 ++ > > src/gallium/state_trackers/va/context.c | 49 > +++ > > 2 files changed, 53 insertions(+), 5 deletions(-) > > > > diff --git a/src/gallium/state_trackers/va/Makefile.am > b/src/gallium/state_trackers/va/Makefile.am > > index 2a93a90..348cfe1 100644 > > --- a/src/gallium/state_trackers/va/Makefile.am > > +++ b/src/gallium/state_trackers/va/Makefile.am > > @@ -30,6 +30,15 @@ AM_CFLAGS = \ > > $(VA_CFLAGS) \ > > -DVA_DRIVER_INIT_FUNC="__vaDriverInit_$(VA_MAJOR)_$(VA_MINOR)" > > > > +AM_CFLAGS += \ > > + $(GALLIUM_PIPE_LOADER_DEFINES) \ > > + -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" > > + > > +if HAVE_GALLIUM_STATIC_TARGETS > > +AM_CFLAGS += \ > > + -DGALLIUM_STATIC_TARGETS=1 > > +endif > > + > Like this one. > > > AM_CPPFLAGS = \ > > -I$(top_srcdir)/include > > > > diff --git a/src/gallium/state_trackers/va/context.c > b/src/gallium/state_trackers/va/context.c > > index ddc863b..9ab2710 100644 > > --- a/src/gallium/state_trackers/va/context.c > > +++ b/src/gallium/state_trackers/va/context.c > > @@ -28,7 +28,8 @@ > > > > #include "pipe/p_screen.h" > > #include "pipe/p_video_codec.h" > > - > > +#include "pipe-loader/pipe_loader.h" > > +#include "state_tracker/drm_driver.h" > > #include "util/u_memory.h" > > #include "util/u_handle_table.h" > > #include "util/u_video.h" > > @@ -98,7 +99,7 @@ static struct VADriverVTableVPP vtable_vpp = > > PUBLIC VAStatus > > VA_DRIVER_INIT_FUNC(VADriverContextP ctx) > > { > > - vlVaDriver *drv; > > + vlVaDriver *drv = NULL; > Unnecessary change. > > > > > if (!ctx) > >return VA_STATUS_ERROR_INVALID_CONTEXT; > > @@ -107,8 +108,40 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) > > if (!drv) > >return VA_STATUS_ERROR_ALLOCATION_FAILED; > > > > - drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); > > - if (!drv->vscreen) > > + drv->vscreen = NULL; > DItto. > > > + > > + switch (ctx->display_type) { > > + case VA_DISPLAY_X11: > > + drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); > > + if (!drv->vscreen) > > + goto error_screen; > > + break; > > + > > + case VA_DISPLAY_DRM: > > + case VA_DISPLAY_DRM_RENDERNODES: { > > + struct drm_state *drm_info = (struct drm_state *) ctx->drm_state; > > + if (!drm_info) > > + goto error_screen; > > + > > + drv->vscreen = CALLOC_STRUCT(vl_screen); > > + > > +#if GALLIUM_STATIC_TARGETS > > + drv->vscreen->pscreen = dd_create_screen(drm_info->fd); > > +#else > > + int loader_fd = dup(drm_info->fd); > > + if (loader_fd == -1) > > + goto error_screen; > > + > > + if (pipe_loader_drm_probe_fd(&drv->dev, loader_fd)) > > + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, > PIPE_SEARCH_DIR); > > +#endif > And much of this. > > Having this around feels rather abusive. I'm leaning that ideally we > need vl_winsy_drm.c, but I'll let others decide. At the very least the > error paths looks quite funky. Please use the same approach as in > vlVaTerminate() > > -Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 5/7] st/va: implement dmabuf import for VaCreateSurfaces2
For now it is limited to RGBA, BGRA, RGBX, BGRX surfaces. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/surface.c | 97 - 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 62fdf3c..6b5a1f5 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -29,6 +29,8 @@ #include "pipe/p_screen.h" #include "pipe/p_video_codec.h" +#include "state_tracker/drm_driver.h" + #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_rect.h" @@ -41,6 +43,8 @@ #include "va_private.h" +#include + VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) @@ -368,7 +372,8 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, attribs[i].type = VASurfaceAttribMemoryType; attribs[i].value.type = VAGenericValueTypeInteger; attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; -attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA; +attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | +VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; i++; attribs[i].type = VASurfaceAttribExternalBufferDescriptor; @@ -402,6 +407,83 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, return VA_STATUS_SUCCESS; } +static VAStatus +suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, +VASurfaceAttribExternalBuffers *memory_attibute, +int index, VASurfaceID *surfaces, +struct pipe_video_buffer *templat) +{ +vlVaDriver *drv; +struct pipe_screen *pscreen; +struct pipe_resource *resource; +struct pipe_resource res_templ; +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); + +if (!memory_attibute || !memory_attibute->buffers || +index > memory_attibute->num_buffers) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +if (surface->templat.width != memory_attibute->width || +surface->templat.height != memory_attibute->height || +memory_attibute->num_planes < 1) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +switch (memory_attibute->pixel_format) { +case VA_FOURCC_RGBA: +case VA_FOURCC_RGBX: +case VA_FOURCC_BGRA: +case VA_FOURCC_BGRX: +if (memory_attibute->num_planes != 1) +return VA_STATUS_ERROR_INVALID_PARAMETER; +break; +default: +return VA_STATUS_ERROR_INVALID_PARAMETER; +} + +memset(&res_templ, 0, sizeof(res_templ)); +res_templ.target = PIPE_TEXTURE_2D; +res_templ.last_level = 0; +res_templ.depth0 = 1; +res_templ.array_size = 1; +res_templ.width0 = memory_attibute->width; +res_templ.height0 = memory_attibute->height; +res_templ.format = surface->templat.buffer_format; +res_templ.bind = PIPE_BIND_SAMPLER_VIEW; +res_templ.usage = PIPE_USAGE_DEFAULT; + +memset(&whandle, 0, sizeof(struct winsys_handle)); +whandle.type = DRM_API_HANDLE_TYPE_FD; +whandle.handle = memory_attibute->buffers[index]; +whandle.stride = memory_attibute->pitches[index]; + +resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle); + +if (!resource) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + +memset(resources, 0, sizeof resources); +resources[0] = resource; + +surface->buffer = vl_video_buffer_create_ex2(drv->pipe, templat, resources); +if (!surface->buffer) +return VA_STATUS_ERROR_ALLOCATION_FAILED; + +util_dynarray_init(&surface->subpics); +surfaces[index] = handle_table_add(drv->htab, surface); + +if (!surfaces[index]) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + +return VA_STATUS_SUCCESS; +} + VAStatus vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, unsigned int width, unsigned int height, @@ -415,6 +497,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, int i; int memory_type; int expected_fourcc; +VAStatus vaStatus; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -453,6 +536,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, switch (attrib_list[i].value.value.i) { case VA_SURFACE_ATTRIB_MEM_TYPE_VA: +case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: memory_type = attrib_list[i].value.value.i;
[Mesa-dev] [PATCH v2 2/7] st/va: properly defines VAImageFormat formats and improve VaCreateImage
Also add RGBA, RGBX and BGRX. Also extend ChromaToPipe and implement PipeToYCbCr. Note that gstreamer-vaapi check all the VAImageFormat fields. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/image.c | 18 +++--- src/gallium/state_trackers/va/va_private.h | 38 +- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index b37a971..84d94c8 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -37,14 +37,21 @@ #include "va_private.h" -static const VAImageFormat formats[VL_VA_MAX_IMAGE_FORMATS] = +static const VAImageFormat formats[] = { {VA_FOURCC('N','V','1','2')}, {VA_FOURCC('I','4','2','0')}, {VA_FOURCC('Y','V','1','2')}, {VA_FOURCC('Y','U','Y','V')}, {VA_FOURCC('U','Y','V','Y')}, - {VA_FOURCC('B','G','R','A')} + {.fourcc = VA_FOURCC('B','G','R','A'), .byte_order = VA_LSB_FIRST, 32, 32, +0x00ff, 0xff00, 0x00ff, 0xff00}, + {.fourcc = VA_FOURCC('R','G','B','A'), .byte_order = VA_LSB_FIRST, 32, 32, +0x00ff, 0xff00, 0x00ff, 0xff00}, + {.fourcc = VA_FOURCC('B','G','R','X'), .byte_order = VA_LSB_FIRST, 32, 24, +0x00ff, 0xff00, 0x00ff, 0x}, + {.fourcc = VA_FOURCC('R','G','B','X'), .byte_order = VA_LSB_FIRST, 32, 24, +0x00ff, 0xff00, 0x00ff, 0x} }; static void @@ -72,6 +79,8 @@ vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num enum pipe_format format; int i; + STATIC_ASSERT(ARRAY_SIZE(formats) == VL_VA_MAX_IMAGE_FORMATS); + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -80,7 +89,7 @@ vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num *num_formats = 0; pscreen = VL_VA_PSCREEN(ctx); - for (i = 0; i < VL_VA_MAX_IMAGE_FORMATS; ++i) { + for (i = 0; i < ARRAY_SIZE(formats); ++i) { format = YCbCrToPipe(formats[i].fourcc); if (pscreen->is_video_format_supported(pscreen, format, PIPE_VIDEO_PROFILE_UNKNOWN, @@ -149,6 +158,9 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig break; case VA_FOURCC('B','G','R','A'): + case VA_FOURCC('R','G','B','A'): + case VA_FOURCC('B','G','R','X'): + case VA_FOURCC('R','G','B','X'): img->num_planes = 1; img->pitches[0] = w * 4; img->offsets[0] = 0; diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 1ea7be7..303b0c6 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -46,12 +46,14 @@ #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 6 +#define VL_VA_MAX_IMAGE_FORMATS 9 static inline enum pipe_video_chroma_format ChromaToPipe(int format) { switch (format) { + case VA_RT_FORMAT_YUV400: + return PIPE_VIDEO_CHROMA_FORMAT_400; case VA_RT_FORMAT_YUV420: return PIPE_VIDEO_CHROMA_FORMAT_420; case VA_RT_FORMAT_YUV422: @@ -80,12 +82,46 @@ YCbCrToPipe(unsigned format) return PIPE_FORMAT_UYVY; case VA_FOURCC('B','G','R','A'): return PIPE_FORMAT_B8G8R8A8_UNORM; + case VA_FOURCC('R','G','B','A'): + return PIPE_FORMAT_R8G8B8A8_UNORM; + case VA_FOURCC('B','G','R','X'): + return PIPE_FORMAT_B8G8R8X8_UNORM; + case VA_FOURCC('R','G','B','X'): + return PIPE_FORMAT_R8G8B8X8_UNORM; default: assert(0); return PIPE_FORMAT_NONE; } } +static inline unsigned +PipeToYCbCr(enum pipe_format p_format) +{ + switch (p_format) { + case PIPE_FORMAT_NV12: + return VA_FOURCC('N','V','1','2'); + case PIPE_FORMAT_IYUV: + return VA_FOURCC('I','4','2','0'); + case PIPE_FORMAT_YV12: + return VA_FOURCC('Y','V','1','2'); + case PIPE_FORMAT_UYVY: + return VA_FOURCC('U','Y','V','Y'); + case PIPE_FORMAT_YUYV: + return VA_FOURCC('Y','U','Y','V'); + case PIPE_FORMAT_B8G8R8A8_UNORM: + return VA_FOURCC('B','G','R','A'); + case PIPE_FORMAT_R8G8B8A8_UNORM: + return VA_FOURCC('R','G','B','A'); + case PIPE_FORMAT_B8G8R8X8_UNORM: + return VA_FOURCC('B','G','R','X'); + case PIPE_FORMAT_R8G8B8X8_UNORM: + return VA_FOURCC('R','G','B','X'); + default: + assert(0); + return -1; + } +} + static inline VAProfile PipeToProfile(enum pipe_video_profile profile) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 3/7] st/va: do not destroy old buffer when new one failed
If formats are not the same vlVaPutImage re-creates the video buffer with the right format. But if the creation of this new video buffer fails then the surface looses its current buffer. Let's just destroy the previous buffer on success. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/image.c | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index 84d94c8..8e64673 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -346,13 +346,20 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, if (format == PIPE_FORMAT_NONE) return VA_STATUS_ERROR_OPERATION_FAILED; - if (surf->buffer == NULL || format != surf->buffer->buffer_format) { - if (surf->buffer) - surf->buffer->destroy(surf->buffer); + if (format != surf->buffer->buffer_format) { + struct pipe_video_buffer *tmp_buf; + enum pipe_format old_surf_format = surf->templat.buffer_format; + surf->templat.buffer_format = format; - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); - if (!surf->buffer) - return VA_STATUS_ERROR_ALLOCATION_FAILED; + tmp_buf = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); + + if (!tmp_buf) { + surf->templat.buffer_format = old_surf_format; + return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + + surf->buffer->destroy(surf->buffer); + surf->buffer = tmp_buf; } views = surf->buffer->get_sampler_view_planes(surf->buffer); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 1/7] nvc0: fix crash when nv50_miptree_from_handle fails
Signed-off-by: Julien Isorce --- src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c index 12b5a02..15c803c 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c @@ -26,7 +26,8 @@ nvc0_resource_from_handle(struct pipe_screen * screen, } else { struct pipe_resource *res = nv50_miptree_from_handle(screen, templ, whandle); - nv04_resource(res)->vtbl = &nvc0_miptree_vtbl; + if (res) + nv04_resource(res)->vtbl = &nvc0_miptree_vtbl; return res; } } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 4/7] st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes
Inspired from http://cgit.freedesktop.org/vaapi/intel-driver/ especially src/i965_drv_video.c::i965_CreateSurfaces2. This patch is mainly to support gstreamer-vaapi and tools that uses this newer libva API. The first advantage of using VaCreateSurfaces2 over existing VaCreateSurfaces, is that it is possible to select which the pixel format for the surface. Indeed with the simple VaCreateSurfaces function it is only possible to create a NV12 surface. It can be useful to create a RGBA surface to use with video post processing. The avaible pixel formats can be query with VaQuerySurfaceAttributes. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/context.c| 5 +- src/gallium/state_trackers/va/surface.c| 294 - src/gallium/state_trackers/va/va_private.h | 6 +- 3 files changed, 253 insertions(+), 52 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 8b003ae..9be9085 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -81,7 +81,10 @@ static struct VADriverVTable vtable = &vlVaSetDisplayAttributes, &vlVaBufferInfo, &vlVaLockSurface, - &vlVaUnlockSurface + &vlVaUnlockSurface, + NULL, /* DEPRECATED VaGetSurfaceAttributes */ + &vlVaCreateSurfaces2, + &vlVaQuerySurfaceAttributes }; PUBLIC VAStatus diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 8d4487b..62fdf3c 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -36,6 +36,7 @@ #include "util/u_surface.h" #include "vl/vl_compositor.h" +#include "vl/vl_video_buffer.h" #include "vl/vl_winsys.h" #include "va_private.h" @@ -44,56 +45,8 @@ VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) { - struct pipe_video_buffer templat = {}; - struct pipe_screen *pscreen; - vlVaDriver *drv; - int i; - - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; - - if (!(width && height)) - return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; - - drv = VL_VA_DRIVER(ctx); - pscreen = VL_VA_PSCREEN(ctx); - - templat.buffer_format = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERED_FORMAT - ); - templat.chroma_format = ChromaToPipe(format); - templat.width = width; - templat.height = height; - templat.interlaced = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERS_INTERLACED - ); - - for (i = 0; i < num_surfaces; ++i) { - vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface)); - if (!surf) - goto no_res; - - surf->templat = templat; - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat); - util_dynarray_init(&surf->subpics); - surfaces[i] = handle_table_add(drv->htab, surf); - } - - return VA_STATUS_SUCCESS; - -no_res: - if (i) - vlVaDestroySurfaces(ctx, surfaces, i); - - return VA_STATUS_ERROR_ALLOCATION_FAILED; + return vlVaCreateSurfaces2(ctx, format, width, height, surfaces, num_surfaces, + NULL, 0); } VAStatus @@ -349,3 +302,244 @@ vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID surface) return VA_STATUS_ERROR_UNIMPLEMENTED; } + +VAStatus +vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, + VASurfaceAttrib *attrib_list, unsigned int *num_attribs) +{ +vlVaDriver *drv; +VASurfaceAttrib *attribs; +struct pipe_screen *pscreen; +int i; + +if (config == VA_INVALID_ID) +return VA_STATUS_ERROR_INVALID_CONFIG; + +if (!attrib_list && !num_attribs) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +if (!attrib_list) { +*num_attribs = VASurfaceAttribCount; +return VA_STATUS_SUCCESS; +} + +if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +drv = VL_VA_DRIVER(ctx); + +if (!drv) +return VA_STATUS_ERROR_INVALID_CONTEXT; + +pscreen = VL_VA_PSCREEN(ctx); + +if (!pscreen) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + +if (!attribs) +return VA_STATUS_ERROR_ALLOCATION_FAILED; + +i = 0; + +if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { + /* Assume VAEntrypointVideoProc for now. */ + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[i
Re: [Mesa-dev] [PATCH v2 1/7] nvc0: fix crash when nv50_miptree_from_handle fails
Sorry this patch should not have gone in the v2 since it has been already reviewed by Emil. But thx for your review. I experienced the crash when testing patch 5/7 of this patch series, around "resource = pscreen->resource_from_handle" in the new vaCreateSurface2 function. Just passing a wrong fd. I checked your remark for nv50 and nv30 and they don't make this step. From what I can see, nvc0 re-use nv50_miptree_from_handle from nv50 but still has its own nvc0_miptree_vtbl. But that's just a guess :) Cheers Julien On 20 October 2015 at 18:04, samuel.pitoiset wrote: > Is there a particular situation where nv50_miptree_from_handle() fails? > And did you check nv50? > > Anyway, this patch is: > Reviewed-by: Samuel Pitoiset > > On 20/10/2015 18:34, Julien Isorce wrote: > >> Signed-off-by: Julien Isorce >> --- >> src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c >> b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c >> index 12b5a02..15c803c 100644 >> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c >> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c >> @@ -26,7 +26,8 @@ nvc0_resource_from_handle(struct pipe_screen * screen, >> } else { >> struct pipe_resource *res = nv50_miptree_from_handle(screen, >> templ, >> whandle); >> - nv04_resource(res)->vtbl = &nvc0_miptree_vtbl; >> + if (res) >> + nv04_resource(res)->vtbl = &nvc0_miptree_vtbl; >> return res; >> } >> } >> > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] nouveau: fix double free when screen_create fails
The real fix is in nouveau_drm_winsys.c by setting dev to 0. Which means dev's ownership has been passed to previous call. Other changes are there to be consistent with what the screen_create functions already do on errors. Encountered this crash because nvc0_screen_create sometimes fails with: nvc0_screen_create:717 - Error allocating PGRAPH context for M2MF: -16 Also see: https://bugs.freedesktop.org/show_bug.cgi?id=70354 Signed-off-by: Julien Isorce --- src/gallium/drivers/nouveau/nv30/nv30_screen.c | 5 - src/gallium/drivers/nouveau/nv50/nv50_screen.c | 4 +++- src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c index 0330164..9b8ddac 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c @@ -425,8 +425,10 @@ nv30_screen_create(struct nouveau_device *dev) unsigned oclass = 0; int ret, i; - if (!screen) + if (!screen) { + nouveau_device_del(&dev); return NULL; + } switch (dev->chipset & 0xf0) { case 0x30: @@ -456,6 +458,7 @@ nv30_screen_create(struct nouveau_device *dev) if (!oclass) { NOUVEAU_ERR("unknown 3d class for 0x%02x\n", dev->chipset); + nouveau_device_del(&dev); FREE(screen); return NULL; } diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index ec51d00..e9604d5 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -711,8 +711,10 @@ nv50_screen_create(struct nouveau_device *dev) int ret; screen = CALLOC_STRUCT(nv50_screen); - if (!screen) + if (!screen) { + nouveau_device_del(&dev); return NULL; + } pscreen = &screen->base.base; ret = nouveau_screen_init(&screen->base, dev); diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c index c6603e3..bd1d761 100644 --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c @@ -117,6 +117,8 @@ nouveau_drm_screen_create(int fd) } screen = (struct nouveau_screen*)init(dev); + /* Previous init func took ownership of dev */ + dev = 0; if (!screen) goto err; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/7] st/va: add initial Video Post Processing support
Hi, Thx for your review. I'll submit a new version of the patch. Just replying here first to answer your questions: On 19 October 2015 at 18:10, Emil Velikov wrote: > On 17 October 2015 at 00:14, Julien Isorce > wrote: > > Improve following functions to support VA_PROFILE_NONE profile (vpp): > > vlVaQueryConfigProfiles > > vlVaQueryConfigEntrypoints > > vlVaCreateConfig > > vlVaQueryConfigAttributes > > > > Add VADriverVTableVPP and improve following functions to support vpp: > > vlVaCreateContext > > vlVaDestroyContext > > vlVaBeginPicture > > vlVaRenderPicture > > vlVaEndPicture > > > Please split into two patches - roughly as per above grouping or > otherwise you feel is appropriate. > oki I'll split as above. > > > Add handleVAProcPipelineParameterBufferType helper. > > > > One of the application is: > > VASurfaceNV12 -> gstvaapipostproc -> VASurfaceRGBA > > > > Signed-off-by: Julien Isorce > > --- > > src/gallium/state_trackers/va/config.c | 20 +++ > > src/gallium/state_trackers/va/context.c| 94 > +++--- > > src/gallium/state_trackers/va/picture.c| 89 > +++- > > src/gallium/state_trackers/va/surface.c| 73 +++ > > src/gallium/state_trackers/va/va_private.h | 13 - > > 5 files changed, 254 insertions(+), 35 deletions(-) > > > > diff --git a/src/gallium/state_trackers/va/config.c > b/src/gallium/state_trackers/va/config.c > > index cfb0b25..bde6615 100644 > > --- a/src/gallium/state_trackers/va/config.c > > +++ b/src/gallium/state_trackers/va/config.c > > @@ -52,6 +52,9 @@ vlVaQueryConfigProfiles(VADriverContextP ctx, > VAProfile *profile_list, int *num_ > > profile_list[(*num_profiles)++] = vap; > >} > > > > + /* Support postprocessing through vl_compositor */ > > + profile_list[(*num_profiles)++] = VAProfileNone; > > + > > return VA_STATUS_SUCCESS; > > } > > > > @@ -67,6 +70,11 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, > VAProfile profile, > > > > *num_entrypoints = 0; > > > > + if (profile == VAProfileNone) { > > + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; > > + return VA_STATUS_SUCCESS; > > + } > > + > > p = ProfileToPipe(profile); > > if (p == PIPE_VIDEO_PROFILE_UNKNOWN) > >return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; > > @@ -118,6 +126,11 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile > profile, VAEntrypoint entrypoin > > if (!ctx) > >return VA_STATUS_ERROR_INVALID_CONTEXT; > > > > + if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) > { > > + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; > > + return VA_STATUS_SUCCESS; > > + } > > + > > p = ProfileToPipe(profile); > > if (p == PIPE_VIDEO_PROFILE_UNKNOWN) > >return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; > > @@ -151,6 +164,13 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, > VAConfigID config_id, VAProfile > >return VA_STATUS_ERROR_INVALID_CONTEXT; > > > > *profile = PipeToProfile(config_id); > > + > > + if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { > > + *entrypoint = VAEntrypointVideoProc; > > + *num_attribs = 0; > > + return VA_STATUS_SUCCESS; > > + } > > + > > *entrypoint = VAEntrypointVLD; > > > > *num_attribs = 1; > > diff --git a/src/gallium/state_trackers/va/context.c > b/src/gallium/state_trackers/va/context.c > > index 8949d42..ddc863b 100644 > > --- a/src/gallium/state_trackers/va/context.c > > +++ b/src/gallium/state_trackers/va/context.c > > @@ -87,6 +87,14 @@ static struct VADriverVTable vtable = > > &vlVaQuerySurfaceAttributes > > }; > > > > +static struct VADriverVTableVPP vtable_vpp = > > +{ > > + VA_DRIVER_VTABLE_VPP_VERSION, > Please _never_ do such a thing. Afaict the define provides the VERSION > currently defined in the API, rather than the one implemented here. > They might align now, but things will break badly as the API gets > updated. > oki I'll put just 1 then. > > > + &vlVaQueryVideoProcFilters, > > + &vlVaQueryVideoProcFilterCaps, > > + &vlVaQueryVideoProcPipelineCaps > > +}; > > + > > PUBLIC VAStatus > > VA_DRIVER_INIT_FUNC(VADriverContextP ctx) > > { > > @@ -122,6 +130,7 @@ VA_DRIVER_INIT_FUNC(VADriverCon
Re: [Mesa-dev] [PATCH 6/7] st/va: add initial Video Post Processing support
On 19 October 2015 at 18:10, Emil Velikov wrote: > On 17 October 2015 at 00:14, Julien Isorce > wrote: > > + > > + if (!(picture_width && picture_height) && !is_vpp) > >return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; > > > > drv = VL_VA_DRIVER(ctx); > > @@ -163,38 +177,48 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID > config_id, int picture_width, > > if (!context) > >return VA_STATUS_ERROR_ALLOCATION_FAILED; > > > > - templat.profile = config_id; > > - templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; > > - templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; > > - templat.width = picture_width; > > - templat.height = picture_height; > > - templat.max_references = num_render_targets; > > - templat.expect_chunked_decode = true; > > - > > - if (u_reduce_video_profile(templat.profile) == > > - PIPE_VIDEO_FORMAT_MPEG4_AVC) > > - templat.level = u_get_h264_level(templat.width, templat.height, > > -&templat.max_references); > > - > > - context->decoder = drv->pipe->create_video_codec(drv->pipe, > &templat); > > - if (!context->decoder) { > > - FREE(context); > > - return VA_STATUS_ERROR_ALLOCATION_FAILED; > > - } > > - > > - if (u_reduce_video_profile(context->decoder->profile) == > > - PIPE_VIDEO_FORMAT_MPEG4_AVC) { > > - context->desc.h264.pps = CALLOC_STRUCT(pipe_h264_pps); > > - if (!context->desc.h264.pps) { > > + if (is_vpp) { > > + context->decoder = NULL; > > + if (!drv->compositor.upload) { > > FREE(context); > > - return VA_STATUS_ERROR_ALLOCATION_FAILED; > > + return VA_STATUS_ERROR_INVALID_CONTEXT; > >} > > - context->desc.h264.pps->sps = CALLOC_STRUCT(pipe_h264_sps); > > - if (!context->desc.h264.pps->sps) { > > - FREE(context->desc.h264.pps); > > + } else { > > + templat.profile = config_id; > > + templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; > > + templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; > > + templat.width = picture_width; > > + templat.height = picture_height; > > + templat.max_references = 2; > > + templat.expect_chunked_decode = true; > > + > > + if (u_reduce_video_profile(templat.profile) == > > +PIPE_VIDEO_FORMAT_MPEG4_AVC) { > > +templat.max_references = 16; > > +templat.level = u_get_h264_level(templat.width, templat.height, > > + &templat.max_references); > > + } > > + > Why the max_references changes ? Shouldn't those be a separate patch ? > Ah thx, I think I messed up a rebase, this patch was originally on top of "[PATCH v4 4/6] st/va: properly set max number of ref frames" already submited but not reviewed . And I forgot about it :) I'll remove the dependency. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 7/8] st/va: add colospace conversion through Video Post Processing
Add support for VPP in the following functions: vlVaCreateContext vlVaDestroyContext vlVaBeginPicture vlVaRenderPicture vlVaEndPicture Add support for VAProcFilterNone in: vlVaQueryVideoProcFilters vlVaQueryVideoProcFilterCaps vlVaQueryVideoProcPipelineCaps Add handleVAProcPipelineParameterBufferType helper. One application is: VASurfaceNV12 -> gstvaapipostproc -> VASurfaceRGBA Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/context.c| 91 +-- src/gallium/state_trackers/va/picture.c| 86 +- src/gallium/state_trackers/va/surface.c| 98 +- src/gallium/state_trackers/va/va_private.h | 8 +++ 4 files changed, 248 insertions(+), 35 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 9be9085..170e9d6 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -87,6 +87,14 @@ static struct VADriverVTable vtable = &vlVaQuerySurfaceAttributes }; +static struct VADriverVTableVPP vtable_vpp = +{ + 1, + &vlVaQueryVideoProcFilters, + &vlVaQueryVideoProcFilterCaps, + &vlVaQueryVideoProcPipelineCaps +}; + PUBLIC VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx) { @@ -122,6 +130,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) ctx->version_major = 0; ctx->version_minor = 1; *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_attributes = 1; @@ -151,11 +160,15 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, struct pipe_video_codec templat = {}; vlVaDriver *drv; vlVaContext *context; + int is_vpp; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - if (!(picture_width && picture_height)) + is_vpp = config_id == PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width && +!picture_height && !flag && !render_targets && !num_render_targets; + + if (!(picture_width && picture_height) && !is_vpp) return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; drv = VL_VA_DRIVER(ctx); @@ -163,38 +176,46 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, if (!context) return VA_STATUS_ERROR_ALLOCATION_FAILED; - templat.profile = config_id; - templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; - templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; - templat.width = picture_width; - templat.height = picture_height; - templat.max_references = num_render_targets; - templat.expect_chunked_decode = true; - - if (u_reduce_video_profile(templat.profile) == - PIPE_VIDEO_FORMAT_MPEG4_AVC) - templat.level = u_get_h264_level(templat.width, templat.height, -&templat.max_references); - - context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat); - if (!context->decoder) { - FREE(context); - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } - - if (u_reduce_video_profile(context->decoder->profile) == - PIPE_VIDEO_FORMAT_MPEG4_AVC) { - context->desc.h264.pps = CALLOC_STRUCT(pipe_h264_pps); - if (!context->desc.h264.pps) { + if (is_vpp) { + context->decoder = NULL; + if (!drv->compositor.upload) { FREE(context); - return VA_STATUS_ERROR_ALLOCATION_FAILED; + return VA_STATUS_ERROR_INVALID_CONTEXT; } - context->desc.h264.pps->sps = CALLOC_STRUCT(pipe_h264_sps); - if (!context->desc.h264.pps->sps) { - FREE(context->desc.h264.pps); + } else { + templat.profile = config_id; + templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; + templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; + templat.width = picture_width; + templat.height = picture_height; + templat.max_references = num_render_targets; + templat.expect_chunked_decode = true; + + if (u_reduce_video_profile(templat.profile) == +PIPE_VIDEO_FORMAT_MPEG4_AVC) +templat.level = u_get_h264_level(templat.width, templat.height, + &templat.max_references); + + context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat); + if (!context->decoder) { FREE(context); return VA_STATUS_ERROR_ALLOCATION_FAILED; } + + if (u_reduce_video_profile(context->decoder->profile) == + PIPE_VIDEO_FORMAT_MPEG4_AVC) { + context->desc.h264.pps = CALLOC_STRUCT(pipe_h264_pps); + if (!context->desc.h264.pps) { +FREE(context); +return VA_STATUS_ERROR_ALLOCATION_FAILED; + } +
[Mesa-dev] [PATCH v2 6/8] st/va: handle Video Post Processing for configs
Add support for VA_PROFILE_NONE and VAEntrypointVideoProc in the 4 following functions: vlVaQueryConfigProfiles vlVaQueryConfigEntrypoints vlVaCreateConfig vlVaQueryConfigAttributes Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/config.c | 20 src/gallium/state_trackers/va/va_private.h | 5 - 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index cfb0b25..bde6615 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -52,6 +52,9 @@ vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, int *num_ profile_list[(*num_profiles)++] = vap; } + /* Support postprocessing through vl_compositor */ + profile_list[(*num_profiles)++] = VAProfileNone; + return VA_STATUS_SUCCESS; } @@ -67,6 +70,11 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile, *num_entrypoints = 0; + if (profile == VAProfileNone) { + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; + return VA_STATUS_SUCCESS; + } + p = ProfileToPipe(profile); if (p == PIPE_VIDEO_PROFILE_UNKNOWN) return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; @@ -118,6 +126,11 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) { + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; + return VA_STATUS_SUCCESS; + } + p = ProfileToPipe(profile); if (p == PIPE_VIDEO_PROFILE_UNKNOWN) return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; @@ -151,6 +164,13 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile return VA_STATUS_ERROR_INVALID_CONTEXT; *profile = PipeToProfile(config_id); + + if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { + *entrypoint = VAEntrypointVideoProc; + *num_attribs = 0; + return VA_STATUS_SUCCESS; + } + *entrypoint = VAEntrypointVLD; *num_attribs = 1; diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index c0287e7..770c7dd 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -147,7 +147,8 @@ PipeToProfile(enum pipe_video_profile profile) case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: return VAProfileH264High; case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: - return VAProfileNone; + case PIPE_VIDEO_PROFILE_UNKNOWN: + return VAProfileNone; default: assert(0); return -1; @@ -178,6 +179,8 @@ ProfileToPipe(VAProfile profile) return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN; case VAProfileH264High: return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; + case VAProfileNone: + return PIPE_VIDEO_PROFILE_UNKNOWN; default: return PIPE_VIDEO_PROFILE_UNKNOWN; } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 4/7] st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes
This patch is missing "memset(&templat, 0, sizeof(templat));" so I am going to submit a v3 for this one. On 20 October 2015 at 17:34, Julien Isorce wrote: > Inspired from http://cgit.freedesktop.org/vaapi/intel-driver/ > especially src/i965_drv_video.c::i965_CreateSurfaces2. > > This patch is mainly to support gstreamer-vaapi and tools that uses > this newer libva API. The first advantage of using VaCreateSurfaces2 > over existing VaCreateSurfaces, is that it is possible to select which > the pixel format for the surface. Indeed with the simple VaCreateSurfaces > function it is only possible to create a NV12 surface. It can be useful > to create a RGBA surface to use with video post processing. > > The avaible pixel formats can be query with VaQuerySurfaceAttributes. > > Signed-off-by: Julien Isorce > --- > src/gallium/state_trackers/va/context.c| 5 +- > src/gallium/state_trackers/va/surface.c| 294 > - > src/gallium/state_trackers/va/va_private.h | 6 +- > 3 files changed, 253 insertions(+), 52 deletions(-) > > diff --git a/src/gallium/state_trackers/va/context.c > b/src/gallium/state_trackers/va/context.c > index 8b003ae..9be9085 100644 > --- a/src/gallium/state_trackers/va/context.c > +++ b/src/gallium/state_trackers/va/context.c > @@ -81,7 +81,10 @@ static struct VADriverVTable vtable = > &vlVaSetDisplayAttributes, > &vlVaBufferInfo, > &vlVaLockSurface, > - &vlVaUnlockSurface > + &vlVaUnlockSurface, > + NULL, /* DEPRECATED VaGetSurfaceAttributes */ > + &vlVaCreateSurfaces2, > + &vlVaQuerySurfaceAttributes > }; > > PUBLIC VAStatus > diff --git a/src/gallium/state_trackers/va/surface.c > b/src/gallium/state_trackers/va/surface.c > index 8d4487b..62fdf3c 100644 > --- a/src/gallium/state_trackers/va/surface.c > +++ b/src/gallium/state_trackers/va/surface.c > @@ -36,6 +36,7 @@ > #include "util/u_surface.h" > > #include "vl/vl_compositor.h" > +#include "vl/vl_video_buffer.h" > #include "vl/vl_winsys.h" > > #include "va_private.h" > @@ -44,56 +45,8 @@ VAStatus > vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int > format, > int num_surfaces, VASurfaceID *surfaces) > { > - struct pipe_video_buffer templat = {}; > - struct pipe_screen *pscreen; > - vlVaDriver *drv; > - int i; > - > - if (!ctx) > - return VA_STATUS_ERROR_INVALID_CONTEXT; > - > - if (!(width && height)) > - return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; > - > - drv = VL_VA_DRIVER(ctx); > - pscreen = VL_VA_PSCREEN(ctx); > - > - templat.buffer_format = pscreen->get_video_param > - ( > - pscreen, > - PIPE_VIDEO_PROFILE_UNKNOWN, > - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, > - PIPE_VIDEO_CAP_PREFERED_FORMAT > - ); > - templat.chroma_format = ChromaToPipe(format); > - templat.width = width; > - templat.height = height; > - templat.interlaced = pscreen->get_video_param > - ( > - pscreen, > - PIPE_VIDEO_PROFILE_UNKNOWN, > - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, > - PIPE_VIDEO_CAP_PREFERS_INTERLACED > - ); > - > - for (i = 0; i < num_surfaces; ++i) { > - vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface)); > - if (!surf) > - goto no_res; > - > - surf->templat = templat; > - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat); > - util_dynarray_init(&surf->subpics); > - surfaces[i] = handle_table_add(drv->htab, surf); > - } > - > - return VA_STATUS_SUCCESS; > - > -no_res: > - if (i) > - vlVaDestroySurfaces(ctx, surfaces, i); > - > - return VA_STATUS_ERROR_ALLOCATION_FAILED; > + return vlVaCreateSurfaces2(ctx, format, width, height, surfaces, > num_surfaces, > + NULL, 0); > } > > VAStatus > @@ -349,3 +302,244 @@ vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID > surface) > > return VA_STATUS_ERROR_UNIMPLEMENTED; > } > + > +VAStatus > +vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, > + VASurfaceAttrib *attrib_list, unsigned int > *num_attribs) > +{ > +vlVaDriver *drv; > +VASurfaceAttrib *attribs; > +struct pipe_screen *pscreen; > +int i; > + > +if (config == VA_INVALID_ID) > +return VA_STATUS_ERROR_INVALID_CONFIG; > + > +if (!attrib_list && !num_attribs) > +return VA_STATUS_ERROR_INVALID_PARAMETER; > + > +if (!attrib_list) { > +
[Mesa-dev] [PATCH v3 4/7] st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes
Inspired from http://cgit.freedesktop.org/vaapi/intel-driver/ especially src/i965_drv_video.c::i965_CreateSurfaces2. This patch is mainly to support gstreamer-vaapi and tools that uses this newer libva API. The first advantage of using VaCreateSurfaces2 over existing VaCreateSurfaces, is that it is possible to select which the pixel format for the surface. Indeed with the simple VaCreateSurfaces function it is only possible to create a NV12 surface. It can be useful to create a RGBA surface to use with video post processing. The avaible pixel formats can be query with VaQuerySurfaceAttributes. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/context.c| 5 +- src/gallium/state_trackers/va/surface.c| 296 - src/gallium/state_trackers/va/va_private.h | 6 +- 3 files changed, 255 insertions(+), 52 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 6357c28..b586dcb 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -81,7 +81,10 @@ static struct VADriverVTable vtable = &vlVaSetDisplayAttributes, &vlVaBufferInfo, &vlVaLockSurface, - &vlVaUnlockSurface + &vlVaUnlockSurface, + NULL, /* DEPRECATED VaGetSurfaceAttributes */ + &vlVaCreateSurfaces2, + &vlVaQuerySurfaceAttributes }; PUBLIC VAStatus diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 8d4487b..e406f37 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -36,6 +36,7 @@ #include "util/u_surface.h" #include "vl/vl_compositor.h" +#include "vl/vl_video_buffer.h" #include "vl/vl_winsys.h" #include "va_private.h" @@ -44,56 +45,8 @@ VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) { - struct pipe_video_buffer templat = {}; - struct pipe_screen *pscreen; - vlVaDriver *drv; - int i; - - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; - - if (!(width && height)) - return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; - - drv = VL_VA_DRIVER(ctx); - pscreen = VL_VA_PSCREEN(ctx); - - templat.buffer_format = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERED_FORMAT - ); - templat.chroma_format = ChromaToPipe(format); - templat.width = width; - templat.height = height; - templat.interlaced = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERS_INTERLACED - ); - - for (i = 0; i < num_surfaces; ++i) { - vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface)); - if (!surf) - goto no_res; - - surf->templat = templat; - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat); - util_dynarray_init(&surf->subpics); - surfaces[i] = handle_table_add(drv->htab, surf); - } - - return VA_STATUS_SUCCESS; - -no_res: - if (i) - vlVaDestroySurfaces(ctx, surfaces, i); - - return VA_STATUS_ERROR_ALLOCATION_FAILED; + return vlVaCreateSurfaces2(ctx, format, width, height, surfaces, num_surfaces, + NULL, 0); } VAStatus @@ -349,3 +302,246 @@ vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID surface) return VA_STATUS_ERROR_UNIMPLEMENTED; } + +VAStatus +vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, + VASurfaceAttrib *attrib_list, unsigned int *num_attribs) +{ +vlVaDriver *drv; +VASurfaceAttrib *attribs; +struct pipe_screen *pscreen; +int i; + +if (config == VA_INVALID_ID) +return VA_STATUS_ERROR_INVALID_CONFIG; + +if (!attrib_list && !num_attribs) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +if (!attrib_list) { +*num_attribs = VASurfaceAttribCount; +return VA_STATUS_SUCCESS; +} + +if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +drv = VL_VA_DRIVER(ctx); + +if (!drv) +return VA_STATUS_ERROR_INVALID_CONTEXT; + +pscreen = VL_VA_PSCREEN(ctx); + +if (!pscreen) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + +if (!attribs) +return VA_STATUS_ERROR_ALLOCATION_FAILED; + +i = 0; + +if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { + /* Assume VAEntrypointVideoProc for now. */ + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[i
[Mesa-dev] [PATCH] st/va: pass picture desc to begin and decode
At least vl_mpeg12_decoder uses the picture desc in begin_frame and decode_bitstream. https://bugs.freedesktop.org/show_bug.cgi?id=92634 Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/picture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 9b94b39..a0d530b 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -58,7 +58,7 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende return VA_STATUS_ERROR_INVALID_SURFACE; context->target = surf->buffer; - context->decoder->begin_frame(context->decoder, context->target, NULL); + context->decoder->begin_frame(context->decoder, context->target, &context->desc.base); return VA_STATUS_SUCCESS; } @@ -517,7 +517,7 @@ handleVASliceDataBufferType(vlVaContext *context, vlVaBuffer *buf) buffers[num_buffers] = buf->data; sizes[num_buffers] = buf->size; ++num_buffers; - context->decoder->decode_bitstream(context->decoder, context->target, NULL, + context->decoder->decode_bitstream(context->decoder, context->target, &context->desc.base, num_buffers, (const void * const*)buffers, sizes); } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 1/7] nvc0: fix crash when nv50_miptree_from_handle fails
On 25 October 2015 at 21:38, Samuel Pitoiset wrote: > > Do you need someone to push this patch? > Yes please ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/va: pass picture desc to begin and decode
Hi Christian, Would you mind to push this patch ? Thx Cheers Julien On 23 October 2015 at 14:33, Christian König wrote: > On 23.10.2015 14:25, Julien Isorce wrote: > >> At least vl_mpeg12_decoder uses the picture >> desc in begin_frame and decode_bitstream. >> >> https://bugs.freedesktop.org/show_bug.cgi?id=92634 >> >> Signed-off-by: Julien Isorce >> > > Reviewed-by: Christian König > > --- >> src/gallium/state_trackers/va/picture.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/src/gallium/state_trackers/va/picture.c >> b/src/gallium/state_trackers/va/picture.c >> index 9b94b39..a0d530b 100644 >> --- a/src/gallium/state_trackers/va/picture.c >> +++ b/src/gallium/state_trackers/va/picture.c >> @@ -58,7 +58,7 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID >> context_id, VASurfaceID rende >> return VA_STATUS_ERROR_INVALID_SURFACE; >>context->target = surf->buffer; >> - context->decoder->begin_frame(context->decoder, context->target, >> NULL); >> + context->decoder->begin_frame(context->decoder, context->target, >> &context->desc.base); >>return VA_STATUS_SUCCESS; >> } >> @@ -517,7 +517,7 @@ handleVASliceDataBufferType(vlVaContext *context, >> vlVaBuffer *buf) >> buffers[num_buffers] = buf->data; >> sizes[num_buffers] = buf->size; >> ++num_buffers; >> - context->decoder->decode_bitstream(context->decoder, context->target, >> NULL, >> + context->decoder->decode_bitstream(context->decoder, context->target, >> &context->desc.base, >> num_buffers, (const void * const*)buffers, sizes); >> } >> >> > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] nouveau: fix double free when screen_create fails
On 25 October 2015 at 21:56, Samuel Pitoiset wrote: > > > On 10/22/2015 01:16 AM, Julien Isorce wrote: > >> The real fix is in nouveau_drm_winsys.c by setting dev to 0. >> Which means dev's ownership has been passed to previous call. >> Other changes are there to be consistent with what the >> screen_create functions already do on errors. >> > > This actually happens because nouveau_device_del() is (sometimes) called > twice > when nvXX_screen_create() fails. > > I don't really like this solution but I don't have a better one for now, > I'll think about > that in the next few days. :) > Yeah and it is certainly hard to maintain. Ideally it should take ownership of the device only on success. I'll send another patch to compare with the other way around. > > Note that you forgot to call nouveau_device_del() in nvc0_screen_create(). Ah right, I missed it on the first return, thx. > > > >> Encountered this crash because nvc0_screen_create sometimes fails with: >> nvc0_screen_create:717 - Error allocating PGRAPH context for M2MF: -16 >> Also see: https://bugs.freedesktop.org/show_bug.cgi?id=70354 >> >> Signed-off-by: Julien Isorce >> --- >> src/gallium/drivers/nouveau/nv30/nv30_screen.c | 5 - >> src/gallium/drivers/nouveau/nv50/nv50_screen.c | 4 +++- >> src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c | 2 ++ >> 3 files changed, 9 insertions(+), 2 deletions(-) >> >> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c >> b/src/gallium/drivers/nouveau/nv30/nv30_screen.c >> index 0330164..9b8ddac 100644 >> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c >> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c >> @@ -425,8 +425,10 @@ nv30_screen_create(struct nouveau_device *dev) >> unsigned oclass = 0; >> int ret, i; >> - if (!screen) >> + if (!screen) { >> + nouveau_device_del(&dev); >> return NULL; >> + } >>switch (dev->chipset & 0xf0) { >> case 0x30: >> @@ -456,6 +458,7 @@ nv30_screen_create(struct nouveau_device *dev) >>if (!oclass) { >> NOUVEAU_ERR("unknown 3d class for 0x%02x\n", dev->chipset); >> + nouveau_device_del(&dev); >> FREE(screen); >> return NULL; >> } >> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c >> b/src/gallium/drivers/nouveau/nv50/nv50_screen.c >> index ec51d00..e9604d5 100644 >> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c >> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c >> @@ -711,8 +711,10 @@ nv50_screen_create(struct nouveau_device *dev) >> int ret; >>screen = CALLOC_STRUCT(nv50_screen); >> - if (!screen) >> + if (!screen) { >> + nouveau_device_del(&dev); >> return NULL; >> + } >> pscreen = &screen->base.base; >>ret = nouveau_screen_init(&screen->base, dev); >> diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c >> b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c >> index c6603e3..bd1d761 100644 >> --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c >> +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c >> @@ -117,6 +117,8 @@ nouveau_drm_screen_create(int fd) >> } >> screen = (struct nouveau_screen*)init(dev); >> + /* Previous init func took ownership of dev */ >> + dev = 0; >> if (!screen) >> goto err; >> >> > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2] nouveau: fix double free when screen_create fails
This patch prevents to call nouveau_device_del twice on the same device. Encountered this case when nvc0_screen_create fails with: nvc0_screen_create:717 - Error allocating PGRAPH context for M2MF: -16 https://bugs.freedesktop.org/show_bug.cgi?id=70354 Signed-off-by: Julien Isorce --- src/gallium/drivers/nouveau/nouveau_screen.c | 8 ++-- src/gallium/drivers/nouveau/nv30/nv30_screen.c | 1 + src/gallium/drivers/nouveau/nv50/nv50_screen.c | 1 + src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index b2290e7..2bd6d4f 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -177,13 +177,17 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) screen->device = dev; ret = nouveau_client_new(screen->device, &screen->client); - if (ret) + if (ret) { + screen->device = 0; return ret; + } ret = nouveau_pushbuf_new(screen->client, screen->channel, 4, 512 * 1024, 1, &screen->pushbuf); - if (ret) + if (ret) { + screen->device = 0; return ret; + } /* getting CPU time first appears to be more accurate */ screen->cpu_gpu_time_delta = os_time_get(); diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c index 0330164..54af655 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c @@ -411,6 +411,7 @@ nv30_screen_destroy(struct pipe_screen *pscreen) #define FAIL_SCREEN_INIT(str, err)\ do { \ NOUVEAU_ERR(str, err); \ + screen->base.device = 0;\ nv30_screen_destroy(pscreen); \ return NULL;\ } while(0) diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index ec51d00..a1fad42 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -905,6 +905,7 @@ nv50_screen_create(struct nouveau_device *dev) return pscreen; fail: + screen->base.device = 0; nv50_screen_destroy(pscreen); return NULL; } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index af8e5f7..28fee35 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -609,6 +609,7 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen, #define FAIL_SCREEN_INIT(str, err)\ do { \ NOUVEAU_ERR(str, err); \ + screen->base.device = 0;\ nvc0_screen_destroy(pscreen); \ return NULL;\ } while(0) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2] nouveau: fix double free when screen_create fails
Looks good though what happened to the del around if (!oclass) in nv30_screen_create ? Also it seems to fix the other problem around else if (dupfd) which was not closed on failure. On 27 October 2015 at 09:10, samuel.pitoiset wrote: > What about this one http://hastebin.com/uboruxicof.coffee ? > > This patch is loosely based on your first attempt, except that I removed > the call > to nouveau_device_del() in nouveau_drm_screen_create(). > > > On 27/10/2015 09:52, Julien Isorce wrote: > >> This patch prevents to call nouveau_device_del twice on the same device. >> >> Encountered this case when nvc0_screen_create fails with: >> nvc0_screen_create:717 - Error allocating PGRAPH context for M2MF: -16 >> >> https://bugs.freedesktop.org/show_bug.cgi?id=70354 >> >> Signed-off-by: Julien Isorce >> --- >> src/gallium/drivers/nouveau/nouveau_screen.c | 8 ++-- >> src/gallium/drivers/nouveau/nv30/nv30_screen.c | 1 + >> src/gallium/drivers/nouveau/nv50/nv50_screen.c | 1 + >> src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 + >> 4 files changed, 9 insertions(+), 2 deletions(-) >> >> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c >> b/src/gallium/drivers/nouveau/nouveau_screen.c >> index b2290e7..2bd6d4f 100644 >> --- a/src/gallium/drivers/nouveau/nouveau_screen.c >> +++ b/src/gallium/drivers/nouveau/nouveau_screen.c >> @@ -177,13 +177,17 @@ nouveau_screen_init(struct nouveau_screen *screen, >> struct nouveau_device *dev) >> screen->device = dev; >> ret = nouveau_client_new(screen->device, &screen->client); >> - if (ret) >> + if (ret) { >> + screen->device = 0; >> return ret; >> + } >> ret = nouveau_pushbuf_new(screen->client, screen->channel, >> 4, 512 * 1024, 1, >> &screen->pushbuf); >> - if (ret) >> + if (ret) { >> + screen->device = 0; >> return ret; >> + } >> /* getting CPU time first appears to be more accurate */ >> screen->cpu_gpu_time_delta = os_time_get(); >> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c >> b/src/gallium/drivers/nouveau/nv30/nv30_screen.c >> index 0330164..54af655 100644 >> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c >> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c >> @@ -411,6 +411,7 @@ nv30_screen_destroy(struct pipe_screen *pscreen) >> #define FAIL_SCREEN_INIT(str, err)\ >> do { \ >> NOUVEAU_ERR(str, err); \ >> + screen->base.device = 0;\ >> nv30_screen_destroy(pscreen); \ >> return NULL;\ >> } while(0) >> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c >> b/src/gallium/drivers/nouveau/nv50/nv50_screen.c >> index ec51d00..a1fad42 100644 >> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c >> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c >> @@ -905,6 +905,7 @@ nv50_screen_create(struct nouveau_device *dev) >> return pscreen; >> fail: >> + screen->base.device = 0; >> nv50_screen_destroy(pscreen); >> return NULL; >> } >> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c >> b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c >> index af8e5f7..28fee35 100644 >> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c >> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c >> @@ -609,6 +609,7 @@ nvc0_screen_resize_tls_area(struct nvc0_screen >> *screen, >> #define FAIL_SCREEN_INIT(str, err)\ >> do { \ >> NOUVEAU_ERR(str, err); \ >> + screen->base.device = 0;\ >> nvc0_screen_destroy(pscreen); \ >> return NULL;\ >> } while(0) >> > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 07/13] st/va: add headless support, i.e. VA_DISPLAY_DRM
This patch allows to use gallium vaapi without requiring a X server running for your second graphic card. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/Makefile.am | 9 src/gallium/state_trackers/va/context.c | 70 --- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/va/Makefile.am b/src/gallium/state_trackers/va/Makefile.am index 2a93a90..348cfe1 100644 --- a/src/gallium/state_trackers/va/Makefile.am +++ b/src/gallium/state_trackers/va/Makefile.am @@ -30,6 +30,15 @@ AM_CFLAGS = \ $(VA_CFLAGS) \ -DVA_DRIVER_INIT_FUNC="__vaDriverInit_$(VA_MAJOR)_$(VA_MINOR)" +AM_CFLAGS += \ + $(GALLIUM_PIPE_LOADER_DEFINES) \ + -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" + +if HAVE_GALLIUM_STATIC_TARGETS +AM_CFLAGS += \ + -DGALLIUM_STATIC_TARGETS=1 +endif + AM_CPPFLAGS = \ -I$(top_srcdir)/include diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 7ff5dcd..c70120e 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -28,7 +28,8 @@ #include "pipe/p_screen.h" #include "pipe/p_video_codec.h" - +#include "pipe-loader/pipe_loader.h" +#include "state_tracker/drm_driver.h" #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_video.h" @@ -36,6 +37,8 @@ #include "va_private.h" +#include + static struct VADriverVTable vtable = { &vlVaTerminate, @@ -99,6 +102,8 @@ PUBLIC VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx) { vlVaDriver *drv; + int drm_fd; + struct drm_state *drm_info; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -107,9 +112,56 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) if (!drv) return VA_STATUS_ERROR_ALLOCATION_FAILED; - drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); - if (!drv->vscreen) - goto error_screen; + switch (ctx->display_type) { + case VA_DISPLAY_ANDROID: + case VA_DISPLAY_WAYLAND: + FREE(drv); + return VA_STATUS_ERROR_UNIMPLEMENTED; + case VA_DISPLAY_GLX: + case VA_DISPLAY_X11: + drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); + if (!drv->vscreen) + goto error_screen; + break; + case VA_DISPLAY_DRM: + case VA_DISPLAY_DRM_RENDERNODES: { + drm_info = (struct drm_state *) ctx->drm_state; + if (!drm_info) { + FREE(drv); + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + +#if GALLIUM_STATIC_TARGETS + drm_fd = drm_info->fd; +#else + drm_fd = dup(drm_info->fd); +#endif + + if (drm_fd < 0) { + FREE(drv); + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + + drv->vscreen = CALLOC_STRUCT(vl_screen); + if (!drv->vscreen) + goto error_screen; + +#if GALLIUM_STATIC_TARGETS + drv->vscreen->pscreen = dd_create_screen(drm_fd); +#else + if (pipe_loader_drm_probe_fd(&drv->dev, drm_fd)) + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, PIPE_SEARCH_DIR); +#endif + + if (!drv->vscreen->pscreen) + goto error_pipe; + + } + break; + default: + FREE(drv); + return VA_STATUS_ERROR_INVALID_DISPLAY; + } drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen, drv->vscreen, 0); @@ -145,7 +197,10 @@ error_htab: drv->pipe->destroy(drv->pipe); error_pipe: - vl_screen_destroy(drv->vscreen); + if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == VA_DISPLAY_X11) + vl_screen_destroy(drv->vscreen); + else + FREE(drv->vscreen); error_screen: FREE(drv); @@ -282,7 +337,10 @@ vlVaTerminate(VADriverContextP ctx) vl_compositor_cleanup_state(&drv->cstate); vl_compositor_cleanup(&drv->compositor); drv->pipe->destroy(drv->pipe); - vl_screen_destroy(drv->vscreen); + if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == VA_DISPLAY_X11) + vl_screen_destroy(drv->vscreen); + else + FREE(drv->vscreen); handle_table_destroy(drv->htab); FREE(drv); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] st/va: implement VaDeriveImage
And apply relatives change to: vlVaBufferSetNumElements vlVaCreateBuffer vlVaMapBuffer vlVaUnmapBuffer vlVaDestroyBuffer vlVaPutImage It is unfortunate that there is no proper va buffer type and struct for this. Only possible to use VAImageBufferType which is normally used for normal user data array. On of the consequences is that it is only possible VaDeriveImage is only useful on surfaces backed with contiguous planes. Implementation inspired from cgit.freedesktop.org/vaapi/intel-driver Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 47 +-- src/gallium/state_trackers/va/image.c | 92 +- src/gallium/state_trackers/va/va_private.h | 5 ++ 3 files changed, 138 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 8f9ba44..b619d0b 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -26,8 +26,11 @@ * **/ +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_handle_table.h" +#include "util/u_transfer.h" +#include "vl/vl_winsys.h" #include "va_private.h" @@ -73,6 +76,10 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, return VA_STATUS_ERROR_INVALID_CONTEXT; buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + + if (!buf || buf->derived_surface.resource) + return VA_STATUS_ERROR_INVALID_BUFFER; + buf->data = REALLOC(buf->data, buf->size * buf->num_elements, buf->size * num_elements); buf->num_elements = num_elements; @@ -86,16 +93,32 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, VAStatus vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) { + vlVaDriver *drv; vlVaBuffer *buf; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + if (!pbuff) + return VA_STATUS_ERROR_INVALID_BUFFER; + + drv = VL_VA_DRIVER(ctx); + + buf = handle_table_get(drv->htab, buf_id); if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; - *pbuff = buf->data; + if (buf->derived_surface.resource) { + *pbuff = pipe_buffer_map(drv->pipe, buf->derived_surface.resource, + PIPE_TRANSFER_WRITE, + &buf->derived_surface.transfer); + + if (!buf->derived_surface.transfer || !*pbuff) + return VA_STATUS_ERROR_INVALID_BUFFER; + + } else { + *pbuff = buf->data; + } return VA_STATUS_SUCCESS; } @@ -103,16 +126,25 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) VAStatus vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) { + vlVaDriver *drv; vlVaBuffer *buf; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + drv = VL_VA_DRIVER(ctx); + + buf = handle_table_get(drv->htab, buf_id); if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; - /* Nothing to do here */ + if (buf->derived_surface.resource) { + if (!buf->derived_surface.transfer) +return VA_STATUS_ERROR_INVALID_BUFFER; + + pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); + buf->derived_surface.transfer = NULL; + } return VA_STATUS_SUCCESS; } @@ -129,7 +161,12 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; - FREE(buf->data); + if (buf->data) + FREE(buf->data); + + if (buf->derived_surface.resource) + pipe_resource_reference(&buf->derived_surface.resource, NULL); + FREE(buf); handle_table_remove(VL_VA_DRIVER(ctx)->htab, buf_id); diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index 8e64673..f266ce8 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -184,10 +184,95 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig VAStatus vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image) { + vlVaDriver *drv; + vlVaSurface *surf; + vlVaBuffer *img_buf; + VAImage *img; + struct pipe_surface **surfaces; + int w; + int h; + int i; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + surf = handle_table_get(drv->htab, surface); + + if (!surf || !surf->buffer || surf->buffer->interlaced) + return VA_STATUS_ERROR_INVALID_SURFACE; + + surfaces = s
[Mesa-dev] [PATCH 2/2] st/va: add support to export a surface as dmabuf
I.e. implements: VaAcquireBufferHandle VaReleaseBufferHandle for memory of type VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME And apply relatives change to: vlVaMapBuffer vlVaUnMapBuffer vlVaDestroyBuffer Implementation inspired from cgit.freedesktop.org/vaapi/intel-driver Tested with gstreamer-vaapi with nouveau driver. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 136 - src/gallium/state_trackers/va/context.c| 4 +- src/gallium/state_trackers/va/va_private.h | 6 ++ 3 files changed, 144 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index b619d0b..4ad20d2 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -27,6 +27,7 @@ **/ #include "pipe/p_screen.h" +#include "state_tracker/drm_driver.h" #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_transfer.h" @@ -108,6 +109,9 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->derived_surface.resource) { *pbuff = pipe_buffer_map(drv->pipe, buf->derived_surface.resource, PIPE_TRANSFER_WRITE, @@ -138,6 +142,9 @@ vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->derived_surface.resource) { if (!buf->derived_surface.transfer) return VA_STATUS_ERROR_INVALID_BUFFER; @@ -164,8 +171,12 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) if (buf->data) FREE(buf->data); - if (buf->derived_surface.resource) + if (buf->derived_surface.resource) { + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; + pipe_resource_reference(&buf->derived_surface.resource, NULL); + } FREE(buf); handle_table_remove(VL_VA_DRIVER(ctx)->htab, buf_id); @@ -192,3 +203,126 @@ vlVaBufferInfo(VADriverContextP ctx, VABufferID buf_id, VABufferType *type, return VA_STATUS_SUCCESS; } + +VAStatus +vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, +VABufferInfo *out_buf_info) +{ + uint32_t i; + uint32_t mem_type; + vlVaBuffer *buf ; + struct pipe_screen *screen; + + /* List of supported memory types, in preferred order. */ + static const uint32_t mem_types[] = { + VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, + 0 + }; + + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + + if (!buf) + return VA_STATUS_ERROR_INVALID_BUFFER; + + /* Only VA surface|image like buffers are supported for now .*/ + if (buf->type != VAImageBufferType) + return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; + + if (!out_buf_info) + return VA_STATUS_ERROR_INVALID_PARAMETER; + + if (!out_buf_info->mem_type) + mem_type = mem_types[0]; + else { + mem_type = 0; + for (i = 0; mem_types[i] != 0; i++) { + if (out_buf_info->mem_type & mem_types[i]) { +mem_type = out_buf_info->mem_type; +break; + } + } + if (!mem_type) + return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; + } + + if (!buf->derived_surface.resource) + return VA_STATUS_ERROR_INVALID_BUFFER; + + screen = VL_VA_PSCREEN(ctx); + + if (buf->derived_surface.fence) { + screen->fence_finish(screen, buf->derived_surface.fence, PIPE_TIMEOUT_INFINITE); + screen->fence_reference(screen, &buf->derived_surface.fence, NULL); + } + + if (buf->export_refcount > 0) { + if (buf->export_state.mem_type != mem_type) + return VA_STATUS_ERROR_INVALID_PARAMETER; + } else { + VABufferInfo * const buf_info = &buf->export_state; + + switch (mem_type) { + case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: { + struct winsys_handle whandle; + + memset(&whandle, 0, sizeof(whandle)); + whandle.type = DRM_API_HANDLE_TYPE_FD; + + if (!screen->resource_get_handle(screen, buf->derived_surface.resource, &whandle)) +return VA_STATUS_ERROR_INVALID_BUFFER; + + buf_info->handle = (intptr_t)whandle.handle; + break; + default: + return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; + } + } + + buf_info->type = buf->type; + buf_info->mem_type = mem_type; + buf_info->mem_size = buf->num_elements * buf->size; + + } + +
[Mesa-dev] [PATCH 0/2] vaapi: add support for dmabuf export
This 2 patches allow to derive a va surface as a va image. Which one can be exported as dmabuf by calling VaAcquireBufferHandle. I have tested these patches with gstreamer-vaapi and nouveau driver. The pipeline looks like: gstvaapidecode:(vasurface, NV12) -> gstvaapipostproc:(dmabuf, RGBA) -> glimagesink(EGL_EXT_image_dma_buf_import) I even went further by doing export and import in separate processes, i.e. exporting the surface in a process A, and importing in an EGLImage in a process B. The concrete use case is the GStreamer backend for the Chromium browser: https://github.com/Samsung/ChromiumGStreamerBackend The VA surface is exported as dmabuf in the new Media Process. Then this dmabuf is imported into an EGLImage in the GPU Process. Julien Isorce (2): st/va: implement VaDeriveImage st/va: add support to export a surface as dmabuf src/gallium/state_trackers/va/buffer.c | 181 - src/gallium/state_trackers/va/context.c| 4 +- src/gallium/state_trackers/va/image.c | 92 ++- src/gallium/state_trackers/va/va_private.h | 11 ++ 4 files changed, 281 insertions(+), 7 deletions(-) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 7/8] st/va: add colospace conversion through Video Post Processing
Ack. I confirm it still works without it. So I'll remove it. Thx -Original Message- From: Christian König [mailto:deathsim...@vodafone.de] Sent: 29 October 2015 14:02 To: Julien Isorce; mesa-dev@lists.freedesktop.org Cc: emil.l.veli...@gmail.com Subject: Re: [Mesa-dev] [PATCH v2 7/8] st/va: add colospace conversion through Video Post Processing > +if(src_surface->fence) { > + screen->fence_finish(screen, src_surface->fence, > PIPE_TIMEOUT_INFINITE); > + screen->fence_reference(screen, &src_surface->fence, NULL); > +} That shouldn't be necessary cause all render operations to the same surface are pipelined anyway. Regards, Christian. On 22.10.2015 18:37, Julien Isorce wrote: > Add support for VPP in the following functions: > vlVaCreateContext > vlVaDestroyContext > vlVaBeginPicture > vlVaRenderPicture > vlVaEndPicture > > Add support for VAProcFilterNone in: > vlVaQueryVideoProcFilters > vlVaQueryVideoProcFilterCaps > vlVaQueryVideoProcPipelineCaps > > Add handleVAProcPipelineParameterBufferType helper. > > One application is: > VASurfaceNV12 -> gstvaapipostproc -> VASurfaceRGBA > > Signed-off-by: Julien Isorce > --- > src/gallium/state_trackers/va/context.c| 91 +-- > src/gallium/state_trackers/va/picture.c| 86 +- > src/gallium/state_trackers/va/surface.c| 98 > +- > src/gallium/state_trackers/va/va_private.h | 8 +++ > 4 files changed, 248 insertions(+), 35 deletions(-) > > diff --git a/src/gallium/state_trackers/va/context.c > b/src/gallium/state_trackers/va/context.c > index 9be9085..170e9d6 100644 > --- a/src/gallium/state_trackers/va/context.c > +++ b/src/gallium/state_trackers/va/context.c > @@ -87,6 +87,14 @@ static struct VADriverVTable vtable = > &vlVaQuerySurfaceAttributes > }; > > +static struct VADriverVTableVPP vtable_vpp = { > + 1, > + &vlVaQueryVideoProcFilters, > + &vlVaQueryVideoProcFilterCaps, > + &vlVaQueryVideoProcPipelineCaps > +}; > + > PUBLIC VAStatus > VA_DRIVER_INIT_FUNC(VADriverContextP ctx) > { > @@ -122,6 +130,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) > ctx->version_major = 0; > ctx->version_minor = 1; > *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_attributes = 1; > @@ -151,11 +160,15 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID > config_id, int picture_width, > struct pipe_video_codec templat = {}; > vlVaDriver *drv; > vlVaContext *context; > + int is_vpp; > > if (!ctx) > return VA_STATUS_ERROR_INVALID_CONTEXT; > > - if (!(picture_width && picture_height)) > + is_vpp = config_id == PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width && > +!picture_height && !flag && !render_targets && > + !num_render_targets; > + > + if (!(picture_width && picture_height) && !is_vpp) > return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; > > drv = VL_VA_DRIVER(ctx); > @@ -163,38 +176,46 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID > config_id, int picture_width, > if (!context) > return VA_STATUS_ERROR_ALLOCATION_FAILED; > > - templat.profile = config_id; > - templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; > - templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; > - templat.width = picture_width; > - templat.height = picture_height; > - templat.max_references = num_render_targets; > - templat.expect_chunked_decode = true; > - > - if (u_reduce_video_profile(templat.profile) == > - PIPE_VIDEO_FORMAT_MPEG4_AVC) > - templat.level = u_get_h264_level(templat.width, templat.height, > -&templat.max_references); > - > - context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat); > - if (!context->decoder) { > - FREE(context); > - return VA_STATUS_ERROR_ALLOCATION_FAILED; > - } > - > - if (u_reduce_video_profile(context->decoder->profile) == > - PIPE_VIDEO_FORMAT_MPEG4_AVC) { > - context->desc.h264.pps = CALLOC_STRUCT(pipe_h264_pps); > - if (!context->desc.h264.pps) { > + if (is_vpp) { > + context->decoder = NULL; > + if (!drv->compositor.upload) { >FREE(context); > - return VA_STATUS_ERROR_ALLOCATION_FAILED; > + return V
Re: [Mesa-dev] [PATCH 1/2] st/va: implement VaDeriveImage
Ack. And I'll move this bit at the end just before the other FREE. Thx -Original Message- From: Christian König [mailto:deathsim...@vodafone.de] Sent: 29 October 2015 12:22 To: Julien Isorce; mesa-dev@lists.freedesktop.org Subject: Re: [Mesa-dev] [PATCH 1/2] st/va: implement VaDeriveImage Patch #1: > + if (buf->data) > + FREE(buf->data); FREE() usually does a NULL check anyway. Apart from that minor nitpick the patch is Reviewed-by: Christian König Regards, Christian. On 29.10.2015 12:47, Julien Isorce wrote: > And apply relatives change to: > vlVaBufferSetNumElements > vlVaCreateBuffer > vlVaMapBuffer > vlVaUnmapBuffer > vlVaDestroyBuffer > vlVaPutImage > > It is unfortunate that there is no proper va buffer type and struct > for this. Only possible to use VAImageBufferType which is normally > used for normal user data array. > On of the consequences is that it is only possible VaDeriveImage is > only useful on surfaces backed with contiguous planes. > Implementation inspired from cgit.freedesktop.org/vaapi/intel-driver > > Signed-off-by: Julien Isorce > --- > src/gallium/state_trackers/va/buffer.c | 47 +-- > src/gallium/state_trackers/va/image.c | 92 > +- > src/gallium/state_trackers/va/va_private.h | 5 ++ > 3 files changed, 138 insertions(+), 6 deletions(-) > > diff --git a/src/gallium/state_trackers/va/buffer.c > b/src/gallium/state_trackers/va/buffer.c > index 8f9ba44..b619d0b 100644 > --- a/src/gallium/state_trackers/va/buffer.c > +++ b/src/gallium/state_trackers/va/buffer.c > @@ -26,8 +26,11 @@ >* > > ** > / > > +#include "pipe/p_screen.h" > #include "util/u_memory.h" > #include "util/u_handle_table.h" > +#include "util/u_transfer.h" > +#include "vl/vl_winsys.h" > > #include "va_private.h" > > @@ -73,6 +76,10 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID > buf_id, > return VA_STATUS_ERROR_INVALID_CONTEXT; > > buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); > + > + if (!buf || buf->derived_surface.resource) > + return VA_STATUS_ERROR_INVALID_BUFFER; > + > buf->data = REALLOC(buf->data, buf->size * buf->num_elements, > buf->size * num_elements); > buf->num_elements = num_elements; @@ -86,16 +93,32 @@ > vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, > VAStatus > vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) > { > + vlVaDriver *drv; > vlVaBuffer *buf; > > if (!ctx) > return VA_STATUS_ERROR_INVALID_CONTEXT; > > - buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); > + if (!pbuff) > + return VA_STATUS_ERROR_INVALID_BUFFER; > + > + drv = VL_VA_DRIVER(ctx); > + > + buf = handle_table_get(drv->htab, buf_id); > if (!buf) > return VA_STATUS_ERROR_INVALID_BUFFER; > > - *pbuff = buf->data; > + if (buf->derived_surface.resource) { > + *pbuff = pipe_buffer_map(drv->pipe, buf->derived_surface.resource, > + PIPE_TRANSFER_WRITE, > + &buf->derived_surface.transfer); > + > + if (!buf->derived_surface.transfer || !*pbuff) > + return VA_STATUS_ERROR_INVALID_BUFFER; > + > + } else { > + *pbuff = buf->data; > + } > > return VA_STATUS_SUCCESS; > } > @@ -103,16 +126,25 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, > void **pbuff) > VAStatus > vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) > { > + vlVaDriver *drv; > vlVaBuffer *buf; > > if (!ctx) > return VA_STATUS_ERROR_INVALID_CONTEXT; > > - buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); > + drv = VL_VA_DRIVER(ctx); > + > + buf = handle_table_get(drv->htab, buf_id); > if (!buf) > return VA_STATUS_ERROR_INVALID_BUFFER; > > - /* Nothing to do here */ > + if (buf->derived_surface.resource) { > + if (!buf->derived_surface.transfer) > +return VA_STATUS_ERROR_INVALID_BUFFER; > + > + pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); > + buf->derived_surface.transfer = NULL; > + } > > return VA_STATUS_SUCCESS; > } > @@ -129,7 +161,12 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID > buf_id) > if (!buf) > return VA_STATUS_ERROR_INVALID_BUFFER;
Re: [Mesa-dev] [PATCH 2/2] st/va: add support to export a surface as dmabuf
-Original Message- From: Christian König [mailto:deathsim...@vodafone.de] Sent: 29 October 2015 12:29 To: Julien Isorce; mesa-dev@lists.freedesktop.org Subject: Re: [Mesa-dev] [PATCH 2/2] st/va: add support to export a surface as dmabuf > @@ -108,6 +109,9 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, > void **pbuff) > if (!buf) > return VA_STATUS_ERROR_INVALID_BUFFER; > > + if (buf->export_refcount > 0) > + return VA_STATUS_ERROR_INVALID_BUFFER; >>Why it is illegal to CPU map a buffer which is exported? Hi, I think it is to prevent someone to write into the buffer while someone else is using the exported handle. Either the user call VaMapBuffer or VaAcquireBufferHandle. It seems to be exclusive. Also I took example here: http://cgit.freedesktop.org/vaapi/intel-driver/tree/src/i965_drv_video.c#n2447 > + switch (buf_info->mem_type) { > + case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: > + close((intptr_t)buf_info->handle); > + break; >>Seriously? Are you sure this is correct? The VA-API driver is supposed to >>close the prime handle? Not the application? Good point actually. I think they assume the application can still call "dup" if it wants extra owner ship of the handle. And this is what gstreamer-vaapi does in fact: https://github.com/01org/gstreamer-vaapi/blob/master/gst/vaapi/gstvaapivideomemory.c#L839 But again I started this impl from intel vaapi driver: http://cgit.freedesktop.org/vaapi/intel-driver/tree/src/i965_drv_video.c#n5731 And for me it is fine since "importers" do not call close. For example when importing the dmabuf into an EGLIMage, eglCreateImage does not take ownership of the handle. Thx Julien >>Regards, >>Christian. On 29.10.2015 12:47, Julien Isorce wrote: > I.e. implements: > VaAcquireBufferHandle > VaReleaseBufferHandle > for memory of type VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME > > And apply relatives change to: > vlVaMapBuffer > vlVaUnMapBuffer > vlVaDestroyBuffer > > Implementation inspired from cgit.freedesktop.org/vaapi/intel-driver > > Tested with gstreamer-vaapi with nouveau driver. > > Signed-off-by: Julien Isorce > --- > src/gallium/state_trackers/va/buffer.c | 136 > - > src/gallium/state_trackers/va/context.c| 4 +- > src/gallium/state_trackers/va/va_private.h | 6 ++ > 3 files changed, 144 insertions(+), 2 deletions(-) > > diff --git a/src/gallium/state_trackers/va/buffer.c > b/src/gallium/state_trackers/va/buffer.c > index b619d0b..4ad20d2 100644 > --- a/src/gallium/state_trackers/va/buffer.c > +++ b/src/gallium/state_trackers/va/buffer.c > @@ -27,6 +27,7 @@ > > ** > / > > #include "pipe/p_screen.h" > +#include "state_tracker/drm_driver.h" > #include "util/u_memory.h" > #include "util/u_handle_table.h" > #include "util/u_transfer.h" > @@ -108,6 +109,9 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, > void **pbuff) > if (!buf) > return VA_STATUS_ERROR_INVALID_BUFFER; > > + if (buf->export_refcount > 0) > + return VA_STATUS_ERROR_INVALID_BUFFER; > + > if (buf->derived_surface.resource) { > *pbuff = pipe_buffer_map(drv->pipe, buf->derived_surface.resource, > PIPE_TRANSFER_WRITE, @@ -138,6 +142,9 > @@ vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) > if (!buf) > return VA_STATUS_ERROR_INVALID_BUFFER; > > + if (buf->export_refcount > 0) > + return VA_STATUS_ERROR_INVALID_BUFFER; > + > if (buf->derived_surface.resource) { >if (!buf->derived_surface.transfer) > return VA_STATUS_ERROR_INVALID_BUFFER; @@ -164,8 +171,12 @@ > vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) > if (buf->data) >FREE(buf->data); > > - if (buf->derived_surface.resource) > + if (buf->derived_surface.resource) { > + if (buf->export_refcount > 0) > + return VA_STATUS_ERROR_INVALID_BUFFER; > + >pipe_resource_reference(&buf->derived_surface.resource, NULL); > + } > > FREE(buf); > handle_table_remove(VL_VA_DRIVER(ctx)->htab, buf_id); @@ -192,3 > +203,126 @@ vlVaBufferInfo(VADriverContextP ctx, VABufferID buf_id, > VABufferType *type, > > return VA_STATUS_SUCCESS; > } > + > +VAStatus > +vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, > +VABufferInfo *out_buf_info) { > + uint32_t i; > + uint32_t
Re: [Mesa-dev] [PATCH 0/7] st/va: VPP, dmabuf import and headless.
Hi Christian, Ok I'll send all of it including last 2 patches about dmabuf export. I addressed all remarks already in my local branch and I did some round of testing, so it should be ok. Cheers Julien On 29 October 2015 at 12:10, Christian König wrote: > Hi Julien, > > if Emil or Ilia have no further comments please send out your full set of > patches once more I would like to get this pusched upstream. > > Best regards, > Christian. > > > On 17.10.2015 01:14, Julien Isorce wrote: > >> This patch serie adds initial support for Video Post Processing. >> It also implements VaCreateSurfaces2 for common purpose and >> also to import a dmabuf. >> Finally it adds support for headless mode, i.e. using DRM >> instead of X11 for device setup. >> >> Julien Isorce (7): >>nvc0: fix crash when nv50_miptree_from_handle fails >>st/va: properly defines VAImageFormat formats and improve >> VaCreateImage >>st/va: in VaPutImage only destroy previous buffer if >> pipe->create_video_buffer succeeds >>st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes >>st/va: implement dmabuf import for VaCreateSurfaces2 >>st/va: add initial Video Post Processing support >>st/va: add headless support, i.e. VA_DISPLAY_DRM >> >> src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 3 +- >> src/gallium/state_trackers/va/Makefile.am| 9 + >> src/gallium/state_trackers/va/config.c | 20 + >> src/gallium/state_trackers/va/context.c | 148 ++-- >> src/gallium/state_trackers/va/image.c| 29 +- >> src/gallium/state_trackers/va/picture.c | 89 - >> src/gallium/state_trackers/va/surface.c | 449 >> --- >> src/gallium/state_trackers/va/va_private.h | 59 ++- >> 8 files changed, 706 insertions(+), 100 deletions(-) >> >> > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 9/9] st/va: add support to export a surface as dmabuf
I.e. implements: VaAcquireBufferHandle VaReleaseBufferHandle for memory of type VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME And apply relatives change to: vlVaMapBuffer vlVaUnMapBuffer vlVaDestroyBuffer Implementation inspired from cgit.freedesktop.org/vaapi/intel-driver Tested with gstreamer-vaapi with nouveau driver. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 136 - src/gallium/state_trackers/va/context.c| 4 +- src/gallium/state_trackers/va/va_private.h | 6 ++ 3 files changed, 144 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 6e32541..8f8f22a 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -27,6 +27,7 @@ **/ #include "pipe/p_screen.h" +#include "state_tracker/drm_driver.h" #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_transfer.h" @@ -108,6 +109,9 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->derived_surface.resource) { *pbuff = pipe_buffer_map(drv->pipe, buf->derived_surface.resource, PIPE_TRANSFER_WRITE, @@ -138,6 +142,9 @@ vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->derived_surface.resource) { if (!buf->derived_surface.transfer) return VA_STATUS_ERROR_INVALID_BUFFER; @@ -161,8 +168,12 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; - if (buf->derived_surface.resource) + if (buf->derived_surface.resource) { + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; + pipe_resource_reference(&buf->derived_surface.resource, NULL); + } FREE(buf->data); FREE(buf); @@ -190,3 +201,126 @@ vlVaBufferInfo(VADriverContextP ctx, VABufferID buf_id, VABufferType *type, return VA_STATUS_SUCCESS; } + +VAStatus +vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, +VABufferInfo *out_buf_info) +{ + uint32_t i; + uint32_t mem_type; + vlVaBuffer *buf ; + struct pipe_screen *screen; + + /* List of supported memory types, in preferred order. */ + static const uint32_t mem_types[] = { + VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, + 0 + }; + + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + + if (!buf) + return VA_STATUS_ERROR_INVALID_BUFFER; + + /* Only VA surface|image like buffers are supported for now .*/ + if (buf->type != VAImageBufferType) + return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; + + if (!out_buf_info) + return VA_STATUS_ERROR_INVALID_PARAMETER; + + if (!out_buf_info->mem_type) + mem_type = mem_types[0]; + else { + mem_type = 0; + for (i = 0; mem_types[i] != 0; i++) { + if (out_buf_info->mem_type & mem_types[i]) { +mem_type = out_buf_info->mem_type; +break; + } + } + if (!mem_type) + return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; + } + + if (!buf->derived_surface.resource) + return VA_STATUS_ERROR_INVALID_BUFFER; + + screen = VL_VA_PSCREEN(ctx); + + if (buf->derived_surface.fence) { + screen->fence_finish(screen, buf->derived_surface.fence, PIPE_TIMEOUT_INFINITE); + screen->fence_reference(screen, &buf->derived_surface.fence, NULL); + } + + if (buf->export_refcount > 0) { + if (buf->export_state.mem_type != mem_type) + return VA_STATUS_ERROR_INVALID_PARAMETER; + } else { + VABufferInfo * const buf_info = &buf->export_state; + + switch (mem_type) { + case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: { + struct winsys_handle whandle; + + memset(&whandle, 0, sizeof(whandle)); + whandle.type = DRM_API_HANDLE_TYPE_FD; + + if (!screen->resource_get_handle(screen, buf->derived_surface.resource, &whandle)) +return VA_STATUS_ERROR_INVALID_BUFFER; + + buf_info->handle = (intptr_t)whandle.handle; + break; + default: + return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; + } + } + + buf_info->type = buf->type; + buf_info->mem_type = mem_type; + buf_info->mem_size = buf->num_elements * buf->size; + + } + + buf->export_refcount++
[Mesa-dev] [PATCH v4 4/9] st/va: implement dmabuf import for VaCreateSurfaces2
For now it is limited to RGBA, BGRA, RGBX, BGRX surfaces. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/surface.c | 97 - 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index c3c015e..c1f7182 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -29,6 +29,8 @@ #include "pipe/p_screen.h" #include "pipe/p_video_codec.h" +#include "state_tracker/drm_driver.h" + #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_rect.h" @@ -41,6 +43,8 @@ #include "va_private.h" +#include + VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) @@ -368,7 +372,8 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, attribs[i].type = VASurfaceAttribMemoryType; attribs[i].value.type = VAGenericValueTypeInteger; attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; -attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA; +attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | +VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; i++; attribs[i].type = VASurfaceAttribExternalBufferDescriptor; @@ -402,6 +407,83 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, return VA_STATUS_SUCCESS; } +static VAStatus +suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, +VASurfaceAttribExternalBuffers *memory_attibute, +int index, VASurfaceID *surfaces, +struct pipe_video_buffer *templat) +{ +vlVaDriver *drv; +struct pipe_screen *pscreen; +struct pipe_resource *resource; +struct pipe_resource res_templ; +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); + +if (!memory_attibute || !memory_attibute->buffers || +index > memory_attibute->num_buffers) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +if (surface->templat.width != memory_attibute->width || +surface->templat.height != memory_attibute->height || +memory_attibute->num_planes < 1) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +switch (memory_attibute->pixel_format) { +case VA_FOURCC_RGBA: +case VA_FOURCC_RGBX: +case VA_FOURCC_BGRA: +case VA_FOURCC_BGRX: +if (memory_attibute->num_planes != 1) +return VA_STATUS_ERROR_INVALID_PARAMETER; +break; +default: +return VA_STATUS_ERROR_INVALID_PARAMETER; +} + +memset(&res_templ, 0, sizeof(res_templ)); +res_templ.target = PIPE_TEXTURE_2D; +res_templ.last_level = 0; +res_templ.depth0 = 1; +res_templ.array_size = 1; +res_templ.width0 = memory_attibute->width; +res_templ.height0 = memory_attibute->height; +res_templ.format = surface->templat.buffer_format; +res_templ.bind = PIPE_BIND_SAMPLER_VIEW; +res_templ.usage = PIPE_USAGE_DEFAULT; + +memset(&whandle, 0, sizeof(struct winsys_handle)); +whandle.type = DRM_API_HANDLE_TYPE_FD; +whandle.handle = memory_attibute->buffers[index]; +whandle.stride = memory_attibute->pitches[index]; + +resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle); + +if (!resource) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + +memset(resources, 0, sizeof resources); +resources[0] = resource; + +surface->buffer = vl_video_buffer_create_ex2(drv->pipe, templat, resources); +if (!surface->buffer) +return VA_STATUS_ERROR_ALLOCATION_FAILED; + +util_dynarray_init(&surface->subpics); +surfaces[index] = handle_table_add(drv->htab, surface); + +if (!surfaces[index]) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + +return VA_STATUS_SUCCESS; +} + VAStatus vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, unsigned int width, unsigned int height, @@ -415,6 +497,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, int i; int memory_type; int expected_fourcc; +VAStatus vaStatus; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -453,6 +536,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, switch (attrib_list[i].value.value.i) { case VA_SURFACE_ATTRIB_MEM_TYPE_VA: +case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: memory_type = attrib_list[i].value.value.i; bre
[Mesa-dev] [PATCH v4 3/9] st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes
Inspired from http://cgit.freedesktop.org/vaapi/intel-driver/ especially src/i965_drv_video.c::i965_CreateSurfaces2. This patch is mainly to support gstreamer-vaapi and tools that uses this newer libva API. The first advantage of using VaCreateSurfaces2 over existing VaCreateSurfaces, is that it is possible to select which the pixel format for the surface. Indeed with the simple VaCreateSurfaces function it is only possible to create a NV12 surface. It can be useful to create a RGBA surface to use with video post processing. The avaible pixel formats can be query with VaQuerySurfaceAttributes. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/context.c| 5 +- src/gallium/state_trackers/va/surface.c| 294 - src/gallium/state_trackers/va/va_private.h | 6 +- 3 files changed, 253 insertions(+), 52 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 5adbe76..9cc402e 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -81,7 +81,10 @@ static struct VADriverVTable vtable = &vlVaSetDisplayAttributes, &vlVaBufferInfo, &vlVaLockSurface, - &vlVaUnlockSurface + &vlVaUnlockSurface, + NULL, /* DEPRECATED VaGetSurfaceAttributes */ + &vlVaCreateSurfaces2, + &vlVaQuerySurfaceAttributes }; PUBLIC VAStatus diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 8d4487b..c3c015e 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -36,6 +36,7 @@ #include "util/u_surface.h" #include "vl/vl_compositor.h" +#include "vl/vl_video_buffer.h" #include "vl/vl_winsys.h" #include "va_private.h" @@ -44,56 +45,8 @@ VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) { - struct pipe_video_buffer templat = {}; - struct pipe_screen *pscreen; - vlVaDriver *drv; - int i; - - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; - - if (!(width && height)) - return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; - - drv = VL_VA_DRIVER(ctx); - pscreen = VL_VA_PSCREEN(ctx); - - templat.buffer_format = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERED_FORMAT - ); - templat.chroma_format = ChromaToPipe(format); - templat.width = width; - templat.height = height; - templat.interlaced = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERS_INTERLACED - ); - - for (i = 0; i < num_surfaces; ++i) { - vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface)); - if (!surf) - goto no_res; - - surf->templat = templat; - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat); - util_dynarray_init(&surf->subpics); - surfaces[i] = handle_table_add(drv->htab, surf); - } - - return VA_STATUS_SUCCESS; - -no_res: - if (i) - vlVaDestroySurfaces(ctx, surfaces, i); - - return VA_STATUS_ERROR_ALLOCATION_FAILED; + return vlVaCreateSurfaces2(ctx, format, width, height, surfaces, num_surfaces, + NULL, 0); } VAStatus @@ -349,3 +302,244 @@ vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID surface) return VA_STATUS_ERROR_UNIMPLEMENTED; } + +VAStatus +vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, + VASurfaceAttrib *attrib_list, unsigned int *num_attribs) +{ +vlVaDriver *drv; +VASurfaceAttrib *attribs; +struct pipe_screen *pscreen; +int i; + +if (config == VA_INVALID_ID) +return VA_STATUS_ERROR_INVALID_CONFIG; + +if (!attrib_list && !num_attribs) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +if (!attrib_list) { +*num_attribs = VASurfaceAttribCount; +return VA_STATUS_SUCCESS; +} + +if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +drv = VL_VA_DRIVER(ctx); + +if (!drv) +return VA_STATUS_ERROR_INVALID_CONTEXT; + +pscreen = VL_VA_PSCREEN(ctx); + +if (!pscreen) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + +if (!attribs) +return VA_STATUS_ERROR_ALLOCATION_FAILED; + +i = 0; + +if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { + /* Assume VAEntrypointVideoProc for now. */ + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[i
[Mesa-dev] [PATCH v4 8/9] st/va: implement VaDeriveImage
And apply relatives change to: vlVaBufferSetNumElements vlVaCreateBuffer vlVaMapBuffer vlVaUnmapBuffer vlVaDestroyBuffer vlVaPutImage It is unfortunate that there is no proper va buffer type and struct for this. Only possible to use VAImageBufferType which is normally used for normal user data array. On of the consequences is that it is only possible VaDeriveImage is only useful on surfaces backed with contiguous planes. Implementation inspired from cgit.freedesktop.org/vaapi/intel-driver Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 43 -- src/gallium/state_trackers/va/image.c | 92 +- src/gallium/state_trackers/va/va_private.h | 5 ++ 3 files changed, 135 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 8f9ba44..6e32541 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -26,8 +26,11 @@ * **/ +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_handle_table.h" +#include "util/u_transfer.h" +#include "vl/vl_winsys.h" #include "va_private.h" @@ -73,6 +76,10 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, return VA_STATUS_ERROR_INVALID_CONTEXT; buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + + if (!buf || buf->derived_surface.resource) + return VA_STATUS_ERROR_INVALID_BUFFER; + buf->data = REALLOC(buf->data, buf->size * buf->num_elements, buf->size * num_elements); buf->num_elements = num_elements; @@ -86,16 +93,32 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, VAStatus vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) { + vlVaDriver *drv; vlVaBuffer *buf; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + if (!pbuff) + return VA_STATUS_ERROR_INVALID_BUFFER; + + drv = VL_VA_DRIVER(ctx); + + buf = handle_table_get(drv->htab, buf_id); if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; - *pbuff = buf->data; + if (buf->derived_surface.resource) { + *pbuff = pipe_buffer_map(drv->pipe, buf->derived_surface.resource, + PIPE_TRANSFER_WRITE, + &buf->derived_surface.transfer); + + if (!buf->derived_surface.transfer || !*pbuff) + return VA_STATUS_ERROR_INVALID_BUFFER; + + } else { + *pbuff = buf->data; + } return VA_STATUS_SUCCESS; } @@ -103,16 +126,25 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) VAStatus vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) { + vlVaDriver *drv; vlVaBuffer *buf; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + drv = VL_VA_DRIVER(ctx); + + buf = handle_table_get(drv->htab, buf_id); if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; - /* Nothing to do here */ + if (buf->derived_surface.resource) { + if (!buf->derived_surface.transfer) +return VA_STATUS_ERROR_INVALID_BUFFER; + + pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); + buf->derived_surface.transfer = NULL; + } return VA_STATUS_SUCCESS; } @@ -129,6 +161,9 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->derived_surface.resource) + pipe_resource_reference(&buf->derived_surface.resource, NULL); + FREE(buf->data); FREE(buf); handle_table_remove(VL_VA_DRIVER(ctx)->htab, buf_id); diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index 8e64673..f266ce8 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -184,10 +184,95 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig VAStatus vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image) { + vlVaDriver *drv; + vlVaSurface *surf; + vlVaBuffer *img_buf; + VAImage *img; + struct pipe_surface **surfaces; + int w; + int h; + int i; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + surf = handle_table_get(drv->htab, surface); + + if (!surf || !surf->buffer || surf->buffer->interlaced) + return VA_STATUS_ERROR_INVALID_SURFACE; + + surfaces = surf->buffer->get_surfaces(surf-
[Mesa-dev] [PATCH v4 7/9] st/va: add headless support, i.e. VA_DISPLAY_DRM
This patch allows to use gallium vaapi without requiring a X server running for your second graphic card. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/Makefile.am | 9 src/gallium/state_trackers/va/context.c | 70 --- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/va/Makefile.am b/src/gallium/state_trackers/va/Makefile.am index 2a93a90..348cfe1 100644 --- a/src/gallium/state_trackers/va/Makefile.am +++ b/src/gallium/state_trackers/va/Makefile.am @@ -30,6 +30,15 @@ AM_CFLAGS = \ $(VA_CFLAGS) \ -DVA_DRIVER_INIT_FUNC="__vaDriverInit_$(VA_MAJOR)_$(VA_MINOR)" +AM_CFLAGS += \ + $(GALLIUM_PIPE_LOADER_DEFINES) \ + -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" + +if HAVE_GALLIUM_STATIC_TARGETS +AM_CFLAGS += \ + -DGALLIUM_STATIC_TARGETS=1 +endif + AM_CPPFLAGS = \ -I$(top_srcdir)/include diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index a107cc4..bd533c4 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -28,7 +28,8 @@ #include "pipe/p_screen.h" #include "pipe/p_video_codec.h" - +#include "pipe-loader/pipe_loader.h" +#include "state_tracker/drm_driver.h" #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_video.h" @@ -36,6 +37,8 @@ #include "va_private.h" +#include + static struct VADriverVTable vtable = { &vlVaTerminate, @@ -99,6 +102,8 @@ PUBLIC VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx) { vlVaDriver *drv; + int drm_fd; + struct drm_state *drm_info; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -107,9 +112,56 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) if (!drv) return VA_STATUS_ERROR_ALLOCATION_FAILED; - drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); - if (!drv->vscreen) - goto error_screen; + switch (ctx->display_type) { + case VA_DISPLAY_ANDROID: + case VA_DISPLAY_WAYLAND: + FREE(drv); + return VA_STATUS_ERROR_UNIMPLEMENTED; + case VA_DISPLAY_GLX: + case VA_DISPLAY_X11: + drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); + if (!drv->vscreen) + goto error_screen; + break; + case VA_DISPLAY_DRM: + case VA_DISPLAY_DRM_RENDERNODES: { + drm_info = (struct drm_state *) ctx->drm_state; + if (!drm_info) { + FREE(drv); + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + +#if GALLIUM_STATIC_TARGETS + drm_fd = drm_info->fd; +#else + drm_fd = dup(drm_info->fd); +#endif + + if (drm_fd < 0) { + FREE(drv); + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + + drv->vscreen = CALLOC_STRUCT(vl_screen); + if (!drv->vscreen) + goto error_screen; + +#if GALLIUM_STATIC_TARGETS + drv->vscreen->pscreen = dd_create_screen(drm_fd); +#else + if (pipe_loader_drm_probe_fd(&drv->dev, drm_fd)) + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, PIPE_SEARCH_DIR); +#endif + + if (!drv->vscreen->pscreen) + goto error_pipe; + + } + break; + default: + FREE(drv); + return VA_STATUS_ERROR_INVALID_DISPLAY; + } drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen, drv->vscreen, 0); @@ -145,7 +197,10 @@ error_htab: drv->pipe->destroy(drv->pipe); error_pipe: - vl_screen_destroy(drv->vscreen); + if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == VA_DISPLAY_X11) + vl_screen_destroy(drv->vscreen); + else + FREE(drv->vscreen); error_screen: FREE(drv); @@ -282,7 +337,10 @@ vlVaTerminate(VADriverContextP ctx) vl_compositor_cleanup_state(&drv->cstate); vl_compositor_cleanup(&drv->compositor); drv->pipe->destroy(drv->pipe); - vl_screen_destroy(drv->vscreen); + if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == VA_DISPLAY_X11) + vl_screen_destroy(drv->vscreen); + else + FREE(drv->vscreen); handle_table_destroy(drv->htab); FREE(drv); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 6/9] st/va: add colospace conversion through Video Post Processing
Add support for VPP in the following functions: vlVaCreateContext vlVaDestroyContext vlVaBeginPicture vlVaRenderPicture vlVaEndPicture Add support for VAProcFilterNone in: vlVaQueryVideoProcFilters vlVaQueryVideoProcFilterCaps vlVaQueryVideoProcPipelineCaps Add handleVAProcPipelineParameterBufferType helper. One application is: VASurfaceNV12 -> gstvaapipostproc -> VASurfaceRGBA Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/context.c| 124 + src/gallium/state_trackers/va/picture.c| 81 ++- src/gallium/state_trackers/va/surface.c| 98 ++- src/gallium/state_trackers/va/va_private.h | 8 ++ 4 files changed, 259 insertions(+), 52 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 9cc402e..a107cc4 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -87,6 +87,14 @@ static struct VADriverVTable vtable = &vlVaQuerySurfaceAttributes }; +static struct VADriverVTableVPP vtable_vpp = +{ + 1, + &vlVaQueryVideoProcFilters, + &vlVaQueryVideoProcFilterCaps, + &vlVaQueryVideoProcPipelineCaps +}; + PUBLIC VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx) { @@ -122,6 +130,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) ctx->version_major = 0; ctx->version_minor = 1; *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_attributes = 1; @@ -151,11 +160,15 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, struct pipe_video_codec templat = {}; vlVaDriver *drv; vlVaContext *context; + int is_vpp; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - if (!(picture_width && picture_height)) + is_vpp = config_id == PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width && +!picture_height && !flag && !render_targets && !num_render_targets; + + if (!(picture_width && picture_height) && !is_vpp) return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; drv = VL_VA_DRIVER(ctx); @@ -163,52 +176,60 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, if (!context) return VA_STATUS_ERROR_ALLOCATION_FAILED; - templat.profile = config_id; - templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; - templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; - templat.width = picture_width; - templat.height = picture_height; - templat.max_references = num_render_targets; - templat.expect_chunked_decode = true; - - if (u_reduce_video_profile(templat.profile) == - PIPE_VIDEO_FORMAT_MPEG4_AVC) - templat.level = u_get_h264_level(templat.width, templat.height, -&templat.max_references); - - context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat); - if (!context->decoder) { - FREE(context); - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } - - if (u_reduce_video_profile(context->decoder->profile) == - PIPE_VIDEO_FORMAT_MPEG4_AVC) { - context->desc.h264.pps = CALLOC_STRUCT(pipe_h264_pps); - if (!context->desc.h264.pps) { + if (is_vpp) { + context->decoder = NULL; + if (!drv->compositor.upload) { FREE(context); - return VA_STATUS_ERROR_ALLOCATION_FAILED; + return VA_STATUS_ERROR_INVALID_CONTEXT; } - context->desc.h264.pps->sps = CALLOC_STRUCT(pipe_h264_sps); - if (!context->desc.h264.pps->sps) { - FREE(context->desc.h264.pps); + } else { + templat.profile = config_id; + templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; + templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; + templat.width = picture_width; + templat.height = picture_height; + templat.max_references = num_render_targets; + templat.expect_chunked_decode = true; + + if (u_reduce_video_profile(templat.profile) == +PIPE_VIDEO_FORMAT_MPEG4_AVC) +templat.level = u_get_h264_level(templat.width, templat.height, + &templat.max_references); + + context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat); + if (!context->decoder) { FREE(context); return VA_STATUS_ERROR_ALLOCATION_FAILED; } - } - if (u_reduce_video_profile(context->decoder->profile) == - PIPE_VIDEO_FORMAT_HEVC) { - context->desc.h265.pps = CALLOC_STRUCT(pipe_h265_pps); - if (!context->desc.h265.pps) { - FREE(context); - return VA_STATUS_ERROR_ALLOCATION_FAILED; + if (u_reduce_video_profile(cont
[Mesa-dev] [PATCH v4 2/9] st/va: do not destroy old buffer when new one failed
If formats are not the same vlVaPutImage re-creates the video buffer with the right format. But if the creation of this new video buffer fails then the surface looses its current buffer. Let's just destroy the previous buffer on success. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/image.c | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index 84d94c8..8e64673 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -346,13 +346,20 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, if (format == PIPE_FORMAT_NONE) return VA_STATUS_ERROR_OPERATION_FAILED; - if (surf->buffer == NULL || format != surf->buffer->buffer_format) { - if (surf->buffer) - surf->buffer->destroy(surf->buffer); + if (format != surf->buffer->buffer_format) { + struct pipe_video_buffer *tmp_buf; + enum pipe_format old_surf_format = surf->templat.buffer_format; + surf->templat.buffer_format = format; - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); - if (!surf->buffer) - return VA_STATUS_ERROR_ALLOCATION_FAILED; + tmp_buf = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); + + if (!tmp_buf) { + surf->templat.buffer_format = old_surf_format; + return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + + surf->buffer->destroy(surf->buffer); + surf->buffer = tmp_buf; } views = surf->buffer->get_sampler_view_planes(surf->buffer); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 5/9] st/va: handle Video Post Processing for configs
Add support for VA_PROFILE_NONE and VAEntrypointVideoProc in the 4 following functions: vlVaQueryConfigProfiles vlVaQueryConfigEntrypoints vlVaCreateConfig vlVaQueryConfigAttributes Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/config.c | 20 src/gallium/state_trackers/va/va_private.h | 7 +-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index 5030f9e..0f47aac 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -52,6 +52,9 @@ vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, int *num_ profile_list[(*num_profiles)++] = vap; } + /* Support postprocessing through vl_compositor */ + profile_list[(*num_profiles)++] = VAProfileNone; + return VA_STATUS_SUCCESS; } @@ -67,6 +70,11 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile, *num_entrypoints = 0; + if (profile == VAProfileNone) { + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; + return VA_STATUS_SUCCESS; + } + p = ProfileToPipe(profile); if (p == PIPE_VIDEO_PROFILE_UNKNOWN) return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; @@ -118,6 +126,11 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) { + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; + return VA_STATUS_SUCCESS; + } + p = ProfileToPipe(profile); if (p == PIPE_VIDEO_PROFILE_UNKNOWN) return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; @@ -151,6 +164,13 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile return VA_STATUS_ERROR_INVALID_CONTEXT; *profile = PipeToProfile(config_id); + + if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { + *entrypoint = VAEntrypointVideoProc; + *num_attribs = 0; + return VA_STATUS_SUCCESS; + } + *entrypoint = VAEntrypointVLD; *num_attribs = 1; diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 68cb703..3a02e58 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -146,10 +146,11 @@ PipeToProfile(enum pipe_video_profile profile) return VAProfileH264Main; case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: return VAProfileH264High; - case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: - return VAProfileNone; case PIPE_VIDEO_PROFILE_HEVC_MAIN: return VAProfileHEVCMain; + case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: + case PIPE_VIDEO_PROFILE_UNKNOWN: + return VAProfileNone; default: assert(0); return -1; @@ -182,6 +183,8 @@ ProfileToPipe(VAProfile profile) return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; case VAProfileHEVCMain: return PIPE_VIDEO_PROFILE_HEVC_MAIN; + case VAProfileNone: + return PIPE_VIDEO_PROFILE_UNKNOWN; default: return PIPE_VIDEO_PROFILE_UNKNOWN; } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 1/9] st/va: properly defines VAImageFormat formats and improve VaCreateImage
Also add RGBA, RGBX and BGRX. Also extend ChromaToPipe and implement PipeToYCbCr. Note that gstreamer-vaapi check all the VAImageFormat fields. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/image.c | 18 +++--- src/gallium/state_trackers/va/va_private.h | 38 +- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index b37a971..84d94c8 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -37,14 +37,21 @@ #include "va_private.h" -static const VAImageFormat formats[VL_VA_MAX_IMAGE_FORMATS] = +static const VAImageFormat formats[] = { {VA_FOURCC('N','V','1','2')}, {VA_FOURCC('I','4','2','0')}, {VA_FOURCC('Y','V','1','2')}, {VA_FOURCC('Y','U','Y','V')}, {VA_FOURCC('U','Y','V','Y')}, - {VA_FOURCC('B','G','R','A')} + {.fourcc = VA_FOURCC('B','G','R','A'), .byte_order = VA_LSB_FIRST, 32, 32, +0x00ff, 0xff00, 0x00ff, 0xff00}, + {.fourcc = VA_FOURCC('R','G','B','A'), .byte_order = VA_LSB_FIRST, 32, 32, +0x00ff, 0xff00, 0x00ff, 0xff00}, + {.fourcc = VA_FOURCC('B','G','R','X'), .byte_order = VA_LSB_FIRST, 32, 24, +0x00ff, 0xff00, 0x00ff, 0x}, + {.fourcc = VA_FOURCC('R','G','B','X'), .byte_order = VA_LSB_FIRST, 32, 24, +0x00ff, 0xff00, 0x00ff, 0x} }; static void @@ -72,6 +79,8 @@ vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num enum pipe_format format; int i; + STATIC_ASSERT(ARRAY_SIZE(formats) == VL_VA_MAX_IMAGE_FORMATS); + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -80,7 +89,7 @@ vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num *num_formats = 0; pscreen = VL_VA_PSCREEN(ctx); - for (i = 0; i < VL_VA_MAX_IMAGE_FORMATS; ++i) { + for (i = 0; i < ARRAY_SIZE(formats); ++i) { format = YCbCrToPipe(formats[i].fourcc); if (pscreen->is_video_format_supported(pscreen, format, PIPE_VIDEO_PROFILE_UNKNOWN, @@ -149,6 +158,9 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig break; case VA_FOURCC('B','G','R','A'): + case VA_FOURCC('R','G','B','A'): + case VA_FOURCC('B','G','R','X'): + case VA_FOURCC('R','G','B','X'): img->num_planes = 1; img->pitches[0] = w * 4; img->offsets[0] = 0; diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 93af1be..6a0bd41 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -46,12 +46,14 @@ #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 6 +#define VL_VA_MAX_IMAGE_FORMATS 9 static inline enum pipe_video_chroma_format ChromaToPipe(int format) { switch (format) { + case VA_RT_FORMAT_YUV400: + return PIPE_VIDEO_CHROMA_FORMAT_400; case VA_RT_FORMAT_YUV420: return PIPE_VIDEO_CHROMA_FORMAT_420; case VA_RT_FORMAT_YUV422: @@ -80,12 +82,46 @@ YCbCrToPipe(unsigned format) return PIPE_FORMAT_UYVY; case VA_FOURCC('B','G','R','A'): return PIPE_FORMAT_B8G8R8A8_UNORM; + case VA_FOURCC('R','G','B','A'): + return PIPE_FORMAT_R8G8B8A8_UNORM; + case VA_FOURCC('B','G','R','X'): + return PIPE_FORMAT_B8G8R8X8_UNORM; + case VA_FOURCC('R','G','B','X'): + return PIPE_FORMAT_R8G8B8X8_UNORM; default: assert(0); return PIPE_FORMAT_NONE; } } +static inline unsigned +PipeToYCbCr(enum pipe_format p_format) +{ + switch (p_format) { + case PIPE_FORMAT_NV12: + return VA_FOURCC('N','V','1','2'); + case PIPE_FORMAT_IYUV: + return VA_FOURCC('I','4','2','0'); + case PIPE_FORMAT_YV12: + return VA_FOURCC('Y','V','1','2'); + case PIPE_FORMAT_UYVY: + return VA_FOURCC('U','Y','V','Y'); + case PIPE_FORMAT_YUYV: + return VA_FOURCC('Y','U','Y','V'); + case PIPE_FORMAT_B8G8R8A8_UNORM: + return VA_FOURCC('B','G','R','A'); + case PIPE_FORMAT_R8G8B8A8_UNORM: + return VA_FOURCC('R','G','B','A'); + case PIPE_FORMAT_B8G8R8X8_UNORM: + return VA_FOURCC('B','G','R','X'); + case PIPE_FORMAT_R8G8B8X8_UNORM: + return VA_FOURCC('R','G','B','X'); + default: + assert(0); + return -1; + } +} + static inline VAProfile PipeToProfile(enum pipe_video_profile profile) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 2/9] st/va: do not destroy old buffer when new one failed
Yes please. Thx Julien On 29 October 2015 at 19:12, Christian König wrote: > On 29.10.2015 18:40, Julien Isorce wrote: > >> If formats are not the same vlVaPutImage re-creates the video >> buffer with the right format. But if the creation of this new >> video buffer fails then the surface looses its current buffer. >> Let's just destroy the previous buffer on success. >> >> Signed-off-by: Julien Isorce >> > > Reviewed-by: Christian König > > Should I push the patches already reviewed? > > Regards, > Christian. > > > --- >> src/gallium/state_trackers/va/image.c | 19 +-- >> 1 file changed, 13 insertions(+), 6 deletions(-) >> >> diff --git a/src/gallium/state_trackers/va/image.c >> b/src/gallium/state_trackers/va/image.c >> index 84d94c8..8e64673 100644 >> --- a/src/gallium/state_trackers/va/image.c >> +++ b/src/gallium/state_trackers/va/image.c >> @@ -346,13 +346,20 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID >> surface, VAImageID image, >> if (format == PIPE_FORMAT_NONE) >> return VA_STATUS_ERROR_OPERATION_FAILED; >> - if (surf->buffer == NULL || format != surf->buffer->buffer_format) { >> - if (surf->buffer) >> - surf->buffer->destroy(surf->buffer); >> + if (format != surf->buffer->buffer_format) { >> + struct pipe_video_buffer *tmp_buf; >> + enum pipe_format old_surf_format = surf->templat.buffer_format; >> + >> surf->templat.buffer_format = format; >> - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, >> &surf->templat); >> - if (!surf->buffer) >> - return VA_STATUS_ERROR_ALLOCATION_FAILED; >> + tmp_buf = drv->pipe->create_video_buffer(drv->pipe, >> &surf->templat); >> + >> + if (!tmp_buf) { >> + surf->templat.buffer_format = old_surf_format; >> + return VA_STATUS_ERROR_ALLOCATION_FAILED; >> + } >> + >> + surf->buffer->destroy(surf->buffer); >> + surf->buffer = tmp_buf; >> } >>views = surf->buffer->get_sampler_view_planes(surf->buffer); >> > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 3/9] st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes
-Original Message- From: Emil Velikov [mailto:emil.l.veli...@gmail.com] Sent: 29 October 2015 19:04 To: Julien Isorce Cc: ML mesa-dev Subject: Re: [Mesa-dev] [PATCH v4 3/9] st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes On 29 October 2015 at 17:40, Julien Isorce wrote: > + > +VAStatus > +vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, > +unsigned int width, unsigned int height, > +VASurfaceID *surfaces, unsigned int num_surfaces, > +VASurfaceAttrib *attrib_list, unsigned int > +num_attribs) { [snip] > +if (VA_RT_FORMAT_YUV400 != format && >>Please drop this format. ok > +VA_RT_FORMAT_YUV420 != format && > +VA_RT_FORMAT_YUV422 != format && > +VA_RT_FORMAT_YUV444 != format && > +VA_RT_FORMAT_RGB32 != format) { >>Whereas RGB32, if it works, is by sheer luck. Because ... [snip] > + > +memset(&templat, 0, sizeof(templat)); > + [snip] > +if (format != VA_RT_FORMAT_RGB32) > + templat.chroma_format = ChromaToPipe(format); > + >>chroma_format defaults to 0 (thanks to memset above) which likely maps to >>PIPE_VIDEO_CHROMA_FORMAT_400 from the pipe_video_chroma_format enum. With >>>>most drivers (incl the 'software implementation' in aux/vl) only handle >>420/422/444. For nouveau it works because: it reaches: nouveau_vp3_video_buffer_create if (templat->buffer_format != PIPE_FORMAT_NV12) then vl_video_buffer_create (by chance does not rely on chroma 400 :) ) but mostly relies on "pipe_format" (instead of chroma_format) and support PIPE_FORMAT_YV12, NV12, RGBA, BGRA, YUYV, UYVY. What should I do then because: enum pipe_video_chroma_format { PIPE_VIDEO_CHROMA_FORMAT_400, PIPE_VIDEO_CHROMA_FORMAT_420, PIPE_VIDEO_CHROMA_FORMAT_422, PIPE_VIDEO_CHROMA_FORMAT_444 }; --- Should I add PIPE_VIDEO_CHROMA_FORMAT_NONE ? --- Also to compare with libva: /** attribute value for VAConfigAttribRTFormat */ #define VA_RT_FORMAT_YUV420 0x0001 #define VA_RT_FORMAT_YUV422 0x0002 #define VA_RT_FORMAT_YUV444 0x0004 #define VA_RT_FORMAT_YUV411 0x0008 #define VA_RT_FORMAT_YUV400 0x0010 #define VA_RT_FORMAT_RGB16 0x0001 #define VA_RT_FORMAT_RGB32 0x0002 /* RGBP covers RGBP and BGRP fourcc */ #define VA_RT_FORMAT_RGBP 0x0010 #define VA_RT_FORMAT_PROTECTED 0x8000 [snip] > +no_res: > + for (i = 0; i < num_surfaces; i++) { > + if (surfaces[i] != VA_INVALID_ID) >>Should have caught this one sooner - this looks odd for couple of reasons. >> - vlVaDestroySurfaces removes a total of i surfaces. Thus we don't need a >> loop here. >> - handle_table_add() returns 0 on error and 0x >>(VA_INVALID_ID) is a valid handle. Ah right thx a lot ! (Actually the existing code was ok) Julien >>-Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 1/9] st/va: properly defines VAImageFormat formats and improve VaCreateImage
-Original Message- From: Christian König [mailto:deathsim...@vodafone.de] Sent: 29 October 2015 19:07 To: Julien Isorce; mesa-dev@lists.freedesktop.org Subject: Re: [PATCH v4 1/9] st/va: properly defines VAImageFormat formats and improve VaCreateImage > @@ -80,12 +82,46 @@ YCbCrToPipe(unsigned format) ... > +PipeToYCbCr(enum pipe_format p_format) >>You should probably rename those two functions as well, cause when we start to handle RGB formats as well the name doesn't match any more. Ok I'll rename to PipeFormatToVaFourcc and VaFourccToPipeFormat >>BTW when do you use PipeToYCbCr? In vlVaDeriveImage Cheers Julien >>Regards, >>Christian. On 29.10.2015 18:40, Julien Isorce wrote: > Also add RGBA, RGBX and BGRX. > Also extend ChromaToPipe and implement PipeToYCbCr. > > Note that gstreamer-vaapi check all the VAImageFormat fields. > > Signed-off-by: Julien Isorce > --- > src/gallium/state_trackers/va/image.c | 18 +++--- > src/gallium/state_trackers/va/va_private.h | 38 +- > 2 files changed, 52 insertions(+), 4 deletions(-) > > diff --git a/src/gallium/state_trackers/va/image.c > b/src/gallium/state_trackers/va/image.c > index b37a971..84d94c8 100644 > --- a/src/gallium/state_trackers/va/image.c > +++ b/src/gallium/state_trackers/va/image.c > @@ -37,14 +37,21 @@ > > #include "va_private.h" > > -static const VAImageFormat formats[VL_VA_MAX_IMAGE_FORMATS] = > +static const VAImageFormat formats[] = > { > {VA_FOURCC('N','V','1','2')}, > {VA_FOURCC('I','4','2','0')}, > {VA_FOURCC('Y','V','1','2')}, > {VA_FOURCC('Y','U','Y','V')}, > {VA_FOURCC('U','Y','V','Y')}, > - {VA_FOURCC('B','G','R','A')} > + {.fourcc = VA_FOURCC('B','G','R','A'), .byte_order = VA_LSB_FIRST, 32, 32, > +0x00ff, 0xff00, 0x00ff, 0xff00}, > + {.fourcc = VA_FOURCC('R','G','B','A'), .byte_order = VA_LSB_FIRST, 32, 32, > +0x00ff, 0xff00, 0x00ff, 0xff00}, > + {.fourcc = VA_FOURCC('B','G','R','X'), .byte_order = VA_LSB_FIRST, 32, 24, > +0x00ff, 0xff00, 0x00ff, 0x}, > + {.fourcc = VA_FOURCC('R','G','B','X'), .byte_order = VA_LSB_FIRST, 32, 24, > +0x00ff, 0xff00, 0x00ff, 0x} > }; > > static void > @@ -72,6 +79,8 @@ vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num > enum pipe_format format; > int i; > > + STATIC_ASSERT(ARRAY_SIZE(formats) == VL_VA_MAX_IMAGE_FORMATS); > + > if (!ctx) > return VA_STATUS_ERROR_INVALID_CONTEXT; > > @@ -80,7 +89,7 @@ vlVaQueryImageFormats(VADriverContextP ctx, > VAImageFormat *format_list, int *num > > *num_formats = 0; > pscreen = VL_VA_PSCREEN(ctx); > - for (i = 0; i < VL_VA_MAX_IMAGE_FORMATS; ++i) { > + for (i = 0; i < ARRAY_SIZE(formats); ++i) { > format = YCbCrToPipe(formats[i].fourcc); > if (pscreen->is_video_format_supported(pscreen, format, > PIPE_VIDEO_PROFILE_UNKNOWN, @@ -149,6 +158,9 @@ > vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig > break; > > case VA_FOURCC('B','G','R','A'): > + case VA_FOURCC('R','G','B','A'): > + case VA_FOURCC('B','G','R','X'): > + case VA_FOURCC('R','G','B','X'): > img->num_planes = 1; > img->pitches[0] = w * 4; > img->offsets[0] = 0; > diff --git a/src/gallium/state_trackers/va/va_private.h > b/src/gallium/state_trackers/va/va_private.h > index 93af1be..6a0bd41 100644 > --- a/src/gallium/state_trackers/va/va_private.h > +++ b/src/gallium/state_trackers/va/va_private.h > @@ -46,12 +46,14 @@ > #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 6 > +#define VL_VA_MAX_IMAGE_FORMATS 9 > > static inline enum pipe_video_chroma_format > ChromaToPipe(int format) > { > switch (format) { > + case VA_RT_FORMAT_YUV400: > + return PIPE_VIDEO_CHROMA_FORMAT_400; > case VA_RT_FORMAT_YU
Re: [Mesa-dev] [PATCH v4 5/9] st/va: handle Video Post Processing for configs
Ok I will reorder, make sense. -Original Message- From: Christian König [mailto:deathsim...@vodafone.de] Sent: 29 October 2015 19:26 To: Julien Isorce; mesa-dev@lists.freedesktop.org Subject: Re: [PATCH v4 5/9] st/va: handle Video Post Processing for configs On 29.10.2015 18:40, Julien Isorce wrote: > Add support for VA_PROFILE_NONE and VAEntrypointVideoProc in the 4 > following functions: > > vlVaQueryConfigProfiles > vlVaQueryConfigEntrypoints > vlVaCreateConfig > vlVaQueryConfigAttributes > > Signed-off-by: Julien Isorce Reviewed-by: Christian König But you should reorder the patch, e.g. commit patch #6 first and then patch #5. Otherwise we have a state where the state tracker claims to support post processing but doesn't. Christian. > --- > src/gallium/state_trackers/va/config.c | 20 > src/gallium/state_trackers/va/va_private.h | 7 +-- > 2 files changed, 25 insertions(+), 2 deletions(-) > > diff --git a/src/gallium/state_trackers/va/config.c > b/src/gallium/state_trackers/va/config.c > index 5030f9e..0f47aac 100644 > --- a/src/gallium/state_trackers/va/config.c > +++ b/src/gallium/state_trackers/va/config.c > @@ -52,6 +52,9 @@ vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, int *num_ > profile_list[(*num_profiles)++] = vap; > } > > + /* Support postprocessing through vl_compositor */ > + profile_list[(*num_profiles)++] = VAProfileNone; > + > return VA_STATUS_SUCCESS; > } > > @@ -67,6 +70,11 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, > VAProfile profile, > > *num_entrypoints = 0; > > + if (profile == VAProfileNone) { > + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; > + return VA_STATUS_SUCCESS; > + } > + > p = ProfileToPipe(profile); > if (p == PIPE_VIDEO_PROFILE_UNKNOWN) > return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; > @@ -118,6 +126,11 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin > if (!ctx) > return VA_STATUS_ERROR_INVALID_CONTEXT; > > + if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) { > + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; > + return VA_STATUS_SUCCESS; > + } > + > p = ProfileToPipe(profile); > if (p == PIPE_VIDEO_PROFILE_UNKNOWN) > return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; > @@ -151,6 +164,13 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile > return VA_STATUS_ERROR_INVALID_CONTEXT; > > *profile = PipeToProfile(config_id); > + > + if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { > + *entrypoint = VAEntrypointVideoProc; > + *num_attribs = 0; > + return VA_STATUS_SUCCESS; > + } > + > *entrypoint = VAEntrypointVLD; > > *num_attribs = 1; > diff --git a/src/gallium/state_trackers/va/va_private.h > b/src/gallium/state_trackers/va/va_private.h > index 68cb703..3a02e58 100644 > --- a/src/gallium/state_trackers/va/va_private.h > +++ b/src/gallium/state_trackers/va/va_private.h > @@ -146,10 +146,11 @@ PipeToProfile(enum pipe_video_profile profile) > return VAProfileH264Main; > case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: > return VAProfileH264High; > - case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: > - return VAProfileNone; > case PIPE_VIDEO_PROFILE_HEVC_MAIN: > return VAProfileHEVCMain; > + case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: > + case PIPE_VIDEO_PROFILE_UNKNOWN: > + return VAProfileNone; > default: > assert(0); > return -1; > @@ -182,6 +183,8 @@ ProfileToPipe(VAProfile profile) > return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; > case VAProfileHEVCMain: > return PIPE_VIDEO_PROFILE_HEVC_MAIN; > + case VAProfileNone: > + return PIPE_VIDEO_PROFILE_UNKNOWN; > default: > return PIPE_VIDEO_PROFILE_UNKNOWN; > } ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 5/9] st/va: handle Video Post Processing for configs
-Original Message- From: Christian König [mailto:deathsim...@vodafone.de] Sent: 29 October 2015 19:26 To: Julien Isorce; mesa-dev@lists.freedesktop.org Subject: Re: [PATCH v4 5/9] st/va: handle Video Post Processing for configs On 29.10.2015 18:40, Julien Isorce wrote: > Add support for VA_PROFILE_NONE and VAEntrypointVideoProc in the 4 > following functions: > > vlVaQueryConfigProfiles > vlVaQueryConfigEntrypoints > vlVaCreateConfig > vlVaQueryConfigAttributes > > Signed-off-by: Julien Isorce Reviewed-by: Christian König >> But you should reorder the patch, e.g. commit patch #6 first and then patch #5. Otherwise we have a state where the state tracker claims to support post processing but doesn't. Ack >>Christian. > --- > src/gallium/state_trackers/va/config.c | 20 > src/gallium/state_trackers/va/va_private.h | 7 +-- > 2 files changed, 25 insertions(+), 2 deletions(-) > > diff --git a/src/gallium/state_trackers/va/config.c > b/src/gallium/state_trackers/va/config.c > index 5030f9e..0f47aac 100644 > --- a/src/gallium/state_trackers/va/config.c > +++ b/src/gallium/state_trackers/va/config.c > @@ -52,6 +52,9 @@ vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, int *num_ > profile_list[(*num_profiles)++] = vap; > } > > + /* Support postprocessing through vl_compositor */ > + profile_list[(*num_profiles)++] = VAProfileNone; > + > return VA_STATUS_SUCCESS; > } > > @@ -67,6 +70,11 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, > VAProfile profile, > > *num_entrypoints = 0; > > + if (profile == VAProfileNone) { > + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; > + return VA_STATUS_SUCCESS; > + } > + > p = ProfileToPipe(profile); > if (p == PIPE_VIDEO_PROFILE_UNKNOWN) > return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; > @@ -118,6 +126,11 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin > if (!ctx) > return VA_STATUS_ERROR_INVALID_CONTEXT; > > + if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) { > + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; > + return VA_STATUS_SUCCESS; > + } > + > p = ProfileToPipe(profile); > if (p == PIPE_VIDEO_PROFILE_UNKNOWN) > return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; > @@ -151,6 +164,13 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile > return VA_STATUS_ERROR_INVALID_CONTEXT; > > *profile = PipeToProfile(config_id); > + > + if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { > + *entrypoint = VAEntrypointVideoProc; > + *num_attribs = 0; > + return VA_STATUS_SUCCESS; > + } > + > *entrypoint = VAEntrypointVLD; > > *num_attribs = 1; > diff --git a/src/gallium/state_trackers/va/va_private.h > b/src/gallium/state_trackers/va/va_private.h > index 68cb703..3a02e58 100644 > --- a/src/gallium/state_trackers/va/va_private.h > +++ b/src/gallium/state_trackers/va/va_private.h > @@ -146,10 +146,11 @@ PipeToProfile(enum pipe_video_profile profile) > return VAProfileH264Main; > case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: > return VAProfileH264High; > - case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: > - return VAProfileNone; > case PIPE_VIDEO_PROFILE_HEVC_MAIN: > return VAProfileHEVCMain; > + case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: > + case PIPE_VIDEO_PROFILE_UNKNOWN: > + return VAProfileNone; > default: > assert(0); > return -1; > @@ -182,6 +183,8 @@ ProfileToPipe(VAProfile profile) > return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; > case VAProfileHEVCMain: > return PIPE_VIDEO_PROFILE_HEVC_MAIN; > + case VAProfileNone: > + return PIPE_VIDEO_PROFILE_UNKNOWN; > default: > return PIPE_VIDEO_PROFILE_UNKNOWN; > } ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 4/9] st/va: implement dmabuf import for VaCreateSurfaces2
-Original Message- From: Christian König [mailto:deathsim...@vodafone.de] Sent: 29 October 2015 19:24 To: Julien Isorce; mesa-dev@lists.freedesktop.org Subject: Re: [PATCH v4 4/9] st/va: implement dmabuf import for VaCreateSurfaces2 On 29.10.2015 18:40, Julien Isorce wrote: > For now it is limited to RGBA, BGRA, RGBX, BGRX surfaces. > > Signed-off-by: Julien Isorce > --- > src/gallium/state_trackers/va/surface.c | 97 - > 1 file changed, 96 insertions(+), 1 deletion(-) > > diff --git a/src/gallium/state_trackers/va/surface.c > b/src/gallium/state_trackers/va/surface.c > index c3c015e..c1f7182 100644 > --- a/src/gallium/state_trackers/va/surface.c > +++ b/src/gallium/state_trackers/va/surface.c > @@ -29,6 +29,8 @@ > #include "pipe/p_screen.h" > #include "pipe/p_video_codec.h" > > +#include "state_tracker/drm_driver.h" > + > #include "util/u_memory.h" > #include "util/u_handle_table.h" > #include "util/u_rect.h" > @@ -41,6 +43,8 @@ > > #include "va_private.h" > > +#include > + > VAStatus > vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, > int num_surfaces, VASurfaceID *surfaces) @@ > -368,7 +372,8 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, > attribs[i].type = VASurfaceAttribMemoryType; > attribs[i].value.type = VAGenericValueTypeInteger; > attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; > -attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA; > +attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | > +VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; > i++; > > attribs[i].type = VASurfaceAttribExternalBufferDescriptor; > @@ -402,6 +407,83 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, > return VA_STATUS_SUCCESS; > } > > +static VAStatus > +suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, > +VASurfaceAttribExternalBuffers *memory_attibute, > +int index, VASurfaceID *surfaces, > +struct pipe_video_buffer *templat) { > +vlVaDriver *drv; > +struct pipe_screen *pscreen; > +struct pipe_resource *resource; > +struct pipe_resource res_templ; > +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); > + > +if (!memory_attibute || !memory_attibute->buffers || > +index > memory_attibute->num_buffers) > +return VA_STATUS_ERROR_INVALID_PARAMETER; > + > +if (surface->templat.width != memory_attibute->width || > +surface->templat.height != memory_attibute->height || > +memory_attibute->num_planes < 1) > +return VA_STATUS_ERROR_INVALID_PARAMETER; > + > +switch (memory_attibute->pixel_format) { > +case VA_FOURCC_RGBA: > +case VA_FOURCC_RGBX: > +case VA_FOURCC_BGRA: > +case VA_FOURCC_BGRX: > +if (memory_attibute->num_planes != 1) > +return VA_STATUS_ERROR_INVALID_PARAMETER; > +break; > +default: > +return VA_STATUS_ERROR_INVALID_PARAMETER; > +} > + > +memset(&res_templ, 0, sizeof(res_templ)); > +res_templ.target = PIPE_TEXTURE_2D; > +res_templ.last_level = 0; > +res_templ.depth0 = 1; > +res_templ.array_size = 1; > +res_templ.width0 = memory_attibute->width; > +res_templ.height0 = memory_attibute->height; > +res_templ.format = surface->templat.buffer_format; > +res_templ.bind = PIPE_BIND_SAMPLER_VIEW; > +res_templ.usage = PIPE_USAGE_DEFAULT; > + > +memset(&whandle, 0, sizeof(struct winsys_handle)); > +whandle.type = DRM_API_HANDLE_TYPE_FD; > +whandle.handle = memory_attibute->buffers[index]; > +whandle.stride = memory_attibute->pitches[index]; > + > +resource = pscreen->resource_from_handle(pscreen, &res_templ, > + &whandle); > + > +if (!resource) > + return VA_STATUS_ERROR_ALLOCATION_FAILED; > + > +memset(resources, 0, sizeof resources); > +resources[0] = resource; > + > +surface->buffer = vl_video_buffer_create_ex2(drv->pipe, templat, > + resources); >>That's a bit tricky. At least the memory layout UVD uses isn't shareable using DMA-buf. >>So after importing this buffer you can't
Re: [Mesa-dev] [PATCH v4 8/9] st/va: implement VaDeriveImage
Ok I'll make a separate patch for the add of errors checks and add the break in the loop. Thx Julien -Original Message- From: Emil Velikov [mailto:emil.l.veli...@gmail.com] Sent: 29 October 2015 22:03 To: Julien Isorce Cc: ML mesa-dev Subject: Re: [Mesa-dev] [PATCH v4 8/9] st/va: implement VaDeriveImage Hi Julien, One can separate the errors checks and get those separately (+stable). I'll let others be the judge of that - I'm just going to point the sections I have in mind. On 29 October 2015 at 17:40, Julien Isorce wrote: > @@ -73,6 +76,10 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID > buf_id, >return VA_STATUS_ERROR_INVALID_CONTEXT; > > buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); > + > + if (!buf || buf->derived_surface.resource) > + return VA_STATUS_ERROR_INVALID_BUFFER; > + Here ... > @@ -86,16 +93,32 @@ vlVaBufferSetNumElements(VADriverContextP ctx, > VABufferID buf_id, VAStatus vlVaMapBuffer(VADriverContextP ctx, > VABufferID buf_id, void **pbuff) { > + vlVaDriver *drv; > vlVaBuffer *buf; > > if (!ctx) >return VA_STATUS_ERROR_INVALID_CONTEXT; > > - buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); > + if (!pbuff) > + return VA_STATUS_ERROR_INVALID_BUFFER; > + > + drv = VL_VA_DRIVER(ctx); > + > + buf = handle_table_get(drv->htab, buf_id); ... and these two. > diff --git a/src/gallium/state_trackers/va/image.c > b/src/gallium/state_trackers/va/image.c > index 8e64673..f266ce8 100644 > --- a/src/gallium/state_trackers/va/image.c > +++ b/src/gallium/state_trackers/va/image.c > @@ -184,10 +184,95 @@ vlVaCreateImage(VADriverContextP ctx, > VAImageFormat *format, int width, int heig VAStatus > vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage > *image) { > + vlVaDriver *drv; > + vlVaSurface *surf; > + vlVaBuffer *img_buf; > + VAImage *img; > + struct pipe_surface **surfaces; > + int w; > + int h; > + int i; > + > if (!ctx) >return VA_STATUS_ERROR_INVALID_CONTEXT; > > - return VA_STATUS_ERROR_UNIMPLEMENTED; > + drv = VL_VA_DRIVER(ctx); > + > + if (!drv) > + return VA_STATUS_ERROR_INVALID_CONTEXT; > + > + surf = handle_table_get(drv->htab, surface); > + > + if (!surf || !surf->buffer || surf->buffer->interlaced) > + return VA_STATUS_ERROR_INVALID_SURFACE; > + > + surfaces = surf->buffer->get_surfaces(surf->buffer); > + if (!surfaces || !surfaces[0]->texture) > + return VA_STATUS_ERROR_ALLOCATION_FAILED; > + > + img = CALLOC(1, sizeof(VAImage)); > + if (!img) > + return VA_STATUS_ERROR_ALLOCATION_FAILED; > + > + img->format.fourcc = PipeToYCbCr(surf->buffer->buffer_format); > + img->buf = VA_INVALID_ID; > + img->width = surf->buffer->width; > + img->height = surf->buffer->height; > + img->num_palette_entries = 0; > + img->entry_bytes = 0; > + w = align(surf->buffer->width, 2); > + h = align(surf->buffer->height, 2); > + > + for (i = 0; i < ARRAY_SIZE(formats); ++i) { > + if (img->format.fourcc == formats[i].fourcc) > + img->format = formats[i]; Break out of the loop ? Not a big deal either way. -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 07/13] st/va: add headless support, i.e. VA_DISPLAY_DRM
-Original Message- From: Emil Velikov [mailto:emil.l.veli...@gmail.com] Sent: 29 October 2015 22:21 To: Christian König Cc: Julien Isorce; ML mesa-dev Subject: Re: [Mesa-dev] [PATCH v2 07/13] st/va: add headless support, i.e. VA_DISPLAY_DRM >>With the VA_RT_FORMAT_YUV400 handling dropped, and the >>VA_RT_FORMAT_RGB32 + vlVaDestroySurfaces comments in "st/va: >>implement VaCreateSurfaces2 and VaQuerySurfaceAttributes" the whole 9 patches >>look great. Fwiw >>Reviewed-by: Emil Velikov >>Thank you for sticking around and addressing with all the comments Julien ! Great. No problem. I'll submit a v5 again with all of it . >>Christian, you are definitely more authoritative person on the topic, so I'd >>leave the final decision up-to you. > Did you static target cleanup already land? I would like to get at > least quite a bunch of the patches upstream sooner than later. > >>Most people value their sanity and haven't looked at the static target >>patches :( That said, none of that work is not a blocker for landing these. >>Cheers, >>Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 7/9] st/va: add headless support, i.e. VA_DISPLAY_DRM
Hi Daniel, Thx for pointing this out. Where are the files related to winsys/presentation :) ? Is your remark a blocker for landing the patches I submitted ? Maybe we can still land them and then if you could guide me what I should change to use newer api that would be great. Cheers Julien On 30 October 2015 at 08:47, Daniel Stone wrote: > Hi, > I know this isn't your fault, but I really really don't see any reason > why the vl winsys bits should continue to exist. We already have a > winsys/presentation layer in Mesa ... > > Cheers, > Daniel > > On 29 October 2015 at 17:40, Julien Isorce wrote: > > This patch allows to use gallium vaapi without requiring > > a X server running for your second graphic card. > > > > Signed-off-by: Julien Isorce > > --- > > src/gallium/state_trackers/va/Makefile.am | 9 > > src/gallium/state_trackers/va/context.c | 70 > --- > > 2 files changed, 73 insertions(+), 6 deletions(-) > > > > diff --git a/src/gallium/state_trackers/va/Makefile.am > b/src/gallium/state_trackers/va/Makefile.am > > index 2a93a90..348cfe1 100644 > > --- a/src/gallium/state_trackers/va/Makefile.am > > +++ b/src/gallium/state_trackers/va/Makefile.am > > @@ -30,6 +30,15 @@ AM_CFLAGS = \ > > $(VA_CFLAGS) \ > > -DVA_DRIVER_INIT_FUNC="__vaDriverInit_$(VA_MAJOR)_$(VA_MINOR)" > > > > +AM_CFLAGS += \ > > + $(GALLIUM_PIPE_LOADER_DEFINES) \ > > + -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" > > + > > +if HAVE_GALLIUM_STATIC_TARGETS > > +AM_CFLAGS += \ > > + -DGALLIUM_STATIC_TARGETS=1 > > +endif > > + > > AM_CPPFLAGS = \ > > -I$(top_srcdir)/include > > > > diff --git a/src/gallium/state_trackers/va/context.c > b/src/gallium/state_trackers/va/context.c > > index a107cc4..bd533c4 100644 > > --- a/src/gallium/state_trackers/va/context.c > > +++ b/src/gallium/state_trackers/va/context.c > > @@ -28,7 +28,8 @@ > > > > #include "pipe/p_screen.h" > > #include "pipe/p_video_codec.h" > > - > > +#include "pipe-loader/pipe_loader.h" > > +#include "state_tracker/drm_driver.h" > > #include "util/u_memory.h" > > #include "util/u_handle_table.h" > > #include "util/u_video.h" > > @@ -36,6 +37,8 @@ > > > > #include "va_private.h" > > > > +#include > > + > > static struct VADriverVTable vtable = > > { > > &vlVaTerminate, > > @@ -99,6 +102,8 @@ PUBLIC VAStatus > > VA_DRIVER_INIT_FUNC(VADriverContextP ctx) > > { > > vlVaDriver *drv; > > + int drm_fd; > > + struct drm_state *drm_info; > > > > if (!ctx) > >return VA_STATUS_ERROR_INVALID_CONTEXT; > > @@ -107,9 +112,56 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) > > if (!drv) > >return VA_STATUS_ERROR_ALLOCATION_FAILED; > > > > - drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); > > - if (!drv->vscreen) > > - goto error_screen; > > + switch (ctx->display_type) { > > + case VA_DISPLAY_ANDROID: > > + case VA_DISPLAY_WAYLAND: > > + FREE(drv); > > + return VA_STATUS_ERROR_UNIMPLEMENTED; > > + case VA_DISPLAY_GLX: > > + case VA_DISPLAY_X11: > > + drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); > > + if (!drv->vscreen) > > + goto error_screen; > > + break; > > + case VA_DISPLAY_DRM: > > + case VA_DISPLAY_DRM_RENDERNODES: { > > + drm_info = (struct drm_state *) ctx->drm_state; > > + if (!drm_info) { > > + FREE(drv); > > + return VA_STATUS_ERROR_INVALID_PARAMETER; > > + } > > + > > +#if GALLIUM_STATIC_TARGETS > > + drm_fd = drm_info->fd; > > +#else > > + drm_fd = dup(drm_info->fd); > > +#endif > > + > > + if (drm_fd < 0) { > > + FREE(drv); > > + return VA_STATUS_ERROR_INVALID_PARAMETER; > > + } > > + > > + drv->vscreen = CALLOC_STRUCT(vl_screen); > > + if (!drv->vscreen) > > + goto error_screen; > > + > > +#if GALLIUM_STATIC_TARGETS > > + drv->vscreen->pscreen = dd_create_screen(drm_fd); > > +#else > > + if (pipe_loader_drm_probe_fd(&drv->dev, drm_fd)) > > + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, > PIP
[Mesa-dev] [PATCH v5 10/10] st/va: add support to export a surface as dmabuf
I.e. implements: VaAcquireBufferHandle VaReleaseBufferHandle for memory of type VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME And apply relatives change to: vlVaMapBuffer vlVaUnMapBuffer vlVaDestroyBuffer Implementation inspired from cgit.freedesktop.org/vaapi/intel-driver Tested with gstreamer-vaapi with nouveau driver. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 136 - src/gallium/state_trackers/va/context.c| 4 +- src/gallium/state_trackers/va/va_private.h | 6 ++ 3 files changed, 144 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index d3a7c5d..71a6503 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -27,6 +27,7 @@ **/ #include "pipe/p_screen.h" +#include "state_tracker/drm_driver.h" #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_transfer.h" @@ -112,6 +113,9 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->derived_surface.resource) { *pbuff = pipe_buffer_map(drv->pipe, buf->derived_surface.resource, PIPE_TRANSFER_WRITE, @@ -144,6 +148,9 @@ vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->derived_surface.resource) { if (!buf->derived_surface.transfer) return VA_STATUS_ERROR_INVALID_BUFFER; @@ -167,8 +174,12 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; - if (buf->derived_surface.resource) + if (buf->derived_surface.resource) { + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; + pipe_resource_reference(&buf->derived_surface.resource, NULL); + } FREE(buf->data); FREE(buf); @@ -196,3 +207,126 @@ vlVaBufferInfo(VADriverContextP ctx, VABufferID buf_id, VABufferType *type, return VA_STATUS_SUCCESS; } + +VAStatus +vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, +VABufferInfo *out_buf_info) +{ + uint32_t i; + uint32_t mem_type; + vlVaBuffer *buf ; + struct pipe_screen *screen; + + /* List of supported memory types, in preferred order. */ + static const uint32_t mem_types[] = { + VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, + 0 + }; + + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + + if (!buf) + return VA_STATUS_ERROR_INVALID_BUFFER; + + /* Only VA surface|image like buffers are supported for now .*/ + if (buf->type != VAImageBufferType) + return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; + + if (!out_buf_info) + return VA_STATUS_ERROR_INVALID_PARAMETER; + + if (!out_buf_info->mem_type) + mem_type = mem_types[0]; + else { + mem_type = 0; + for (i = 0; mem_types[i] != 0; i++) { + if (out_buf_info->mem_type & mem_types[i]) { +mem_type = out_buf_info->mem_type; +break; + } + } + if (!mem_type) + return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; + } + + if (!buf->derived_surface.resource) + return VA_STATUS_ERROR_INVALID_BUFFER; + + screen = VL_VA_PSCREEN(ctx); + + if (buf->derived_surface.fence) { + screen->fence_finish(screen, buf->derived_surface.fence, PIPE_TIMEOUT_INFINITE); + screen->fence_reference(screen, &buf->derived_surface.fence, NULL); + } + + if (buf->export_refcount > 0) { + if (buf->export_state.mem_type != mem_type) + return VA_STATUS_ERROR_INVALID_PARAMETER; + } else { + VABufferInfo * const buf_info = &buf->export_state; + + switch (mem_type) { + case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: { + struct winsys_handle whandle; + + memset(&whandle, 0, sizeof(whandle)); + whandle.type = DRM_API_HANDLE_TYPE_FD; + + if (!screen->resource_get_handle(screen, buf->derived_surface.resource, &whandle)) +return VA_STATUS_ERROR_INVALID_BUFFER; + + buf_info->handle = (intptr_t)whandle.handle; + break; + default: + return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; + } + } + + buf_info->type = buf->type; + buf_info->mem_type = mem_type; + buf_info->mem_size = buf->num_elements * buf->size; + + } + + buf->export_refcount++
[Mesa-dev] [PATCH v5 04/10] st/va: implement dmabuf import for VaCreateSurfaces2
For now it is limited to RGBA, BGRA, RGBX, BGRX surfaces. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/surface.c | 97 - 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 0e489c1..12112d2 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -29,6 +29,8 @@ #include "pipe/p_screen.h" #include "pipe/p_video_codec.h" +#include "state_tracker/drm_driver.h" + #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_rect.h" @@ -41,6 +43,8 @@ #include "va_private.h" +#include + VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) @@ -368,7 +372,8 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, attribs[i].type = VASurfaceAttribMemoryType; attribs[i].value.type = VAGenericValueTypeInteger; attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; -attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA; +attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | +VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; i++; attribs[i].type = VASurfaceAttribExternalBufferDescriptor; @@ -402,6 +407,83 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, return VA_STATUS_SUCCESS; } +static VAStatus +suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, +VASurfaceAttribExternalBuffers *memory_attibute, +int index, VASurfaceID *surfaces, +struct pipe_video_buffer *templat) +{ +vlVaDriver *drv; +struct pipe_screen *pscreen; +struct pipe_resource *resource; +struct pipe_resource res_templ; +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); + +if (!memory_attibute || !memory_attibute->buffers || +index > memory_attibute->num_buffers) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +if (surface->templat.width != memory_attibute->width || +surface->templat.height != memory_attibute->height || +memory_attibute->num_planes < 1) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +switch (memory_attibute->pixel_format) { +case VA_FOURCC_RGBA: +case VA_FOURCC_RGBX: +case VA_FOURCC_BGRA: +case VA_FOURCC_BGRX: +if (memory_attibute->num_planes != 1) +return VA_STATUS_ERROR_INVALID_PARAMETER; +break; +default: +return VA_STATUS_ERROR_INVALID_PARAMETER; +} + +memset(&res_templ, 0, sizeof(res_templ)); +res_templ.target = PIPE_TEXTURE_2D; +res_templ.last_level = 0; +res_templ.depth0 = 1; +res_templ.array_size = 1; +res_templ.width0 = memory_attibute->width; +res_templ.height0 = memory_attibute->height; +res_templ.format = surface->templat.buffer_format; +res_templ.bind = PIPE_BIND_SAMPLER_VIEW; +res_templ.usage = PIPE_USAGE_DEFAULT; + +memset(&whandle, 0, sizeof(struct winsys_handle)); +whandle.type = DRM_API_HANDLE_TYPE_FD; +whandle.handle = memory_attibute->buffers[index]; +whandle.stride = memory_attibute->pitches[index]; + +resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle); + +if (!resource) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + +memset(resources, 0, sizeof resources); +resources[0] = resource; + +surface->buffer = vl_video_buffer_create_ex2(drv->pipe, templat, resources); +if (!surface->buffer) +return VA_STATUS_ERROR_ALLOCATION_FAILED; + +util_dynarray_init(&surface->subpics); +surfaces[index] = handle_table_add(drv->htab, surface); + +if (!surfaces[index]) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + +return VA_STATUS_SUCCESS; +} + VAStatus vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, unsigned int width, unsigned int height, @@ -415,6 +497,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, int i; int memory_type; int expected_fourcc; +VAStatus vaStatus; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -453,6 +536,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, switch (attrib_list[i].value.value.i) { case VA_SURFACE_ATTRIB_MEM_TYPE_VA: +case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: memory_type = attrib_list[i].value.value.i; bre
[Mesa-dev] [PATCH v5 06/10] st/va: handle Video Post Processing for configs
Add support for VA_PROFILE_NONE and VAEntrypointVideoProc in the 4 following functions: vlVaQueryConfigProfiles vlVaQueryConfigEntrypoints vlVaCreateConfig vlVaQueryConfigAttributes Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/config.c | 20 src/gallium/state_trackers/va/va_private.h | 7 +-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index 5030f9e..0f47aac 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -52,6 +52,9 @@ vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, int *num_ profile_list[(*num_profiles)++] = vap; } + /* Support postprocessing through vl_compositor */ + profile_list[(*num_profiles)++] = VAProfileNone; + return VA_STATUS_SUCCESS; } @@ -67,6 +70,11 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile, *num_entrypoints = 0; + if (profile == VAProfileNone) { + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; + return VA_STATUS_SUCCESS; + } + p = ProfileToPipe(profile); if (p == PIPE_VIDEO_PROFILE_UNKNOWN) return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; @@ -118,6 +126,11 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) { + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; + return VA_STATUS_SUCCESS; + } + p = ProfileToPipe(profile); if (p == PIPE_VIDEO_PROFILE_UNKNOWN) return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; @@ -151,6 +164,13 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile return VA_STATUS_ERROR_INVALID_CONTEXT; *profile = PipeToProfile(config_id); + + if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { + *entrypoint = VAEntrypointVideoProc; + *num_attribs = 0; + return VA_STATUS_SUCCESS; + } + *entrypoint = VAEntrypointVLD; *num_attribs = 1; diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 1e37740..60e9669 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -144,10 +144,11 @@ PipeToProfile(enum pipe_video_profile profile) return VAProfileH264Main; case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: return VAProfileH264High; - case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: - return VAProfileNone; case PIPE_VIDEO_PROFILE_HEVC_MAIN: return VAProfileHEVCMain; + case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED: + case PIPE_VIDEO_PROFILE_UNKNOWN: + return VAProfileNone; default: assert(0); return -1; @@ -180,6 +181,8 @@ ProfileToPipe(VAProfile profile) return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; case VAProfileHEVCMain: return PIPE_VIDEO_PROFILE_HEVC_MAIN; + case VAProfileNone: + return PIPE_VIDEO_PROFILE_UNKNOWN; default: return PIPE_VIDEO_PROFILE_UNKNOWN; } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 09/10] st/va: implement VaDeriveImage
And apply relatives change to: vlVaBufferSetNumElements vlVaCreateBuffer vlVaMapBuffer vlVaUnmapBuffer vlVaDestroyBuffer vlVaPutImage It is unfortunate that there is no proper va buffer type and struct for this. Only possible to use VAImageBufferType which is normally used for normal user data array. On of the consequences is that it is only possible VaDeriveImage is only useful on surfaces backed with contiguous planes. Implementation inspired from cgit.freedesktop.org/vaapi/intel-driver Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 43 -- src/gallium/state_trackers/va/image.c | 95 +- src/gallium/state_trackers/va/va_private.h | 5 ++ 3 files changed, 138 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index f5b9e81..d3a7c5d 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -26,8 +26,11 @@ * **/ +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_handle_table.h" +#include "util/u_transfer.h" +#include "vl/vl_winsys.h" #include "va_private.h" @@ -76,6 +79,9 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->derived_surface.resource) + return VA_STATUS_ERROR_INVALID_BUFFER; + buf->data = REALLOC(buf->data, buf->size * buf->num_elements, buf->size * num_elements); buf->num_elements = num_elements; @@ -89,19 +95,34 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, VAStatus vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) { + vlVaDriver *drv; vlVaBuffer *buf; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + drv = VL_VA_DRIVER(ctx); + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!pbuff) return VA_STATUS_ERROR_INVALID_PARAMETER; - buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + buf = handle_table_get(drv->htab, buf_id); if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; - *pbuff = buf->data; + if (buf->derived_surface.resource) { + *pbuff = pipe_buffer_map(drv->pipe, buf->derived_surface.resource, + PIPE_TRANSFER_WRITE, + &buf->derived_surface.transfer); + + if (!buf->derived_surface.transfer || !*pbuff) + return VA_STATUS_ERROR_INVALID_BUFFER; + + } else { + *pbuff = buf->data; + } return VA_STATUS_SUCCESS; } @@ -109,16 +130,27 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) VAStatus vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) { + vlVaDriver *drv; vlVaBuffer *buf; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + drv = VL_VA_DRIVER(ctx); + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + buf = handle_table_get(drv->htab, buf_id); if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; - /* Nothing to do here */ + if (buf->derived_surface.resource) { + if (!buf->derived_surface.transfer) +return VA_STATUS_ERROR_INVALID_BUFFER; + + pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); + buf->derived_surface.transfer = NULL; + } return VA_STATUS_SUCCESS; } @@ -135,6 +167,9 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->derived_surface.resource) + pipe_resource_reference(&buf->derived_surface.resource, NULL); + FREE(buf->data); FREE(buf); handle_table_remove(VL_VA_DRIVER(ctx)->htab, buf_id); diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index b0c720d..c6d0c5a 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -184,10 +184,97 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig VAStatus vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image) { + vlVaDriver *drv; + vlVaSurface *surf; + vlVaBuffer *img_buf; + VAImage *img; + struct pipe_surface **surfaces; + int w; + int h; + int i; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + surf = handle_table_get(drv->htab, surface); + + if (!surf || !surf->buffer || surf->buffer->interlaced) + return VA_STATUS_ERROR_INVALID_SURFACE; + + surfa
[Mesa-dev] [PATCH v5 01/10] st/va: properly defines VAImageFormat formats and improve VaCreateImage
Added PIPE_VIDEO_CHROMA_FORMAT_NONE in p_format.h and return it by default in ChromaToPipe. Renamed YCbCrToPipe to VaFourccToPipeFormat because it now contains RGB. Implemented PipeFormatToVaFourcc which will be used later in VlVaDeriveImage. Note that gstreamer-vaapi check all the VAImageFormat fields. Signed-off-by: Julien Isorce --- src/gallium/include/pipe/p_format.h| 3 ++- src/gallium/state_trackers/va/image.c | 24 - src/gallium/state_trackers/va/va_private.h | 41 +++--- 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index b2646d4..5f0690e 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -444,7 +444,8 @@ enum pipe_video_chroma_format PIPE_VIDEO_CHROMA_FORMAT_400, PIPE_VIDEO_CHROMA_FORMAT_420, PIPE_VIDEO_CHROMA_FORMAT_422, - PIPE_VIDEO_CHROMA_FORMAT_444 + PIPE_VIDEO_CHROMA_FORMAT_444, + PIPE_VIDEO_CHROMA_FORMAT_NONE }; #ifdef __cplusplus diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index b37a971..0d961b1 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -37,14 +37,21 @@ #include "va_private.h" -static const VAImageFormat formats[VL_VA_MAX_IMAGE_FORMATS] = +static const VAImageFormat formats[] = { {VA_FOURCC('N','V','1','2')}, {VA_FOURCC('I','4','2','0')}, {VA_FOURCC('Y','V','1','2')}, {VA_FOURCC('Y','U','Y','V')}, {VA_FOURCC('U','Y','V','Y')}, - {VA_FOURCC('B','G','R','A')} + {.fourcc = VA_FOURCC('B','G','R','A'), .byte_order = VA_LSB_FIRST, 32, 32, +0x00ff, 0xff00, 0x00ff, 0xff00}, + {.fourcc = VA_FOURCC('R','G','B','A'), .byte_order = VA_LSB_FIRST, 32, 32, +0x00ff, 0xff00, 0x00ff, 0xff00}, + {.fourcc = VA_FOURCC('B','G','R','X'), .byte_order = VA_LSB_FIRST, 32, 24, +0x00ff, 0xff00, 0x00ff, 0x}, + {.fourcc = VA_FOURCC('R','G','B','X'), .byte_order = VA_LSB_FIRST, 32, 24, +0x00ff, 0xff00, 0x00ff, 0x} }; static void @@ -72,6 +79,8 @@ vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num enum pipe_format format; int i; + STATIC_ASSERT(ARRAY_SIZE(formats) == VL_VA_MAX_IMAGE_FORMATS); + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -80,8 +89,8 @@ vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num *num_formats = 0; pscreen = VL_VA_PSCREEN(ctx); - for (i = 0; i < VL_VA_MAX_IMAGE_FORMATS; ++i) { - format = YCbCrToPipe(formats[i].fourcc); + for (i = 0; i < ARRAY_SIZE(formats); ++i) { + format = VaFourccToPipeFormat(formats[i].fourcc); if (pscreen->is_video_format_supported(pscreen, format, PIPE_VIDEO_PROFILE_UNKNOWN, PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) @@ -149,6 +158,9 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig break; case VA_FOURCC('B','G','R','A'): + case VA_FOURCC('R','G','B','A'): + case VA_FOURCC('B','G','R','X'): + case VA_FOURCC('R','G','B','X'): img->num_planes = 1; img->pitches[0] = w * 4; img->offsets[0] = 0; @@ -235,7 +247,7 @@ vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y, if (!img_buf) return VA_STATUS_ERROR_INVALID_BUFFER; - format = YCbCrToPipe(vaimage->format.fourcc); + format = VaFourccToPipeFormat(vaimage->format.fourcc); if (format == PIPE_FORMAT_NONE) return VA_STATUS_ERROR_OPERATION_FAILED; @@ -330,7 +342,7 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, if (!img_buf) return VA_STATUS_ERROR_INVALID_BUFFER; - format = YCbCrToPipe(vaimage->format.fourcc); + format = VaFourccToPipeFormat(vaimage->format.fourcc); if (format == PIPE_FORMAT_NONE) return VA_STATUS_ERROR_OPERATION_FAILED; diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 93af1be..56c6b02 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -46,7 +46,7 @@ #define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData) #define VL_VA_PSCREEN(ctx) (VL_VA_D
[Mesa-dev] [PATCH v5 08/10] st/va: add more errors checks in vlVaBufferSetNumElements and vlVaMapBuffer
Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 8f9ba44..f5b9e81 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -73,6 +73,9 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, return VA_STATUS_ERROR_INVALID_CONTEXT; buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + if (!buf) + return VA_STATUS_ERROR_INVALID_BUFFER; + buf->data = REALLOC(buf->data, buf->size * buf->num_elements, buf->size * num_elements); buf->num_elements = num_elements; @@ -91,6 +94,9 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!pbuff) + return VA_STATUS_ERROR_INVALID_PARAMETER; + buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); if (!buf) return VA_STATUS_ERROR_INVALID_BUFFER; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 03/10] st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes
Inspired from http://cgit.freedesktop.org/vaapi/intel-driver/ especially src/i965_drv_video.c::i965_CreateSurfaces2. This patch is mainly to support gstreamer-vaapi and tools that uses this newer libva API. The first advantage of using VaCreateSurfaces2 over existing VaCreateSurfaces, is that it is possible to select which the pixel format for the surface. Indeed with the simple VaCreateSurfaces function it is only possible to create a NV12 surface. It can be useful to create a RGBA surface to use with video post processing. The avaible pixel formats can be query with VaQuerySurfaceAttributes. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/context.c| 5 +- src/gallium/state_trackers/va/surface.c| 290 - src/gallium/state_trackers/va/va_private.h | 6 +- 3 files changed, 249 insertions(+), 52 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 5adbe76..9cc402e 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -81,7 +81,10 @@ static struct VADriverVTable vtable = &vlVaSetDisplayAttributes, &vlVaBufferInfo, &vlVaLockSurface, - &vlVaUnlockSurface + &vlVaUnlockSurface, + NULL, /* DEPRECATED VaGetSurfaceAttributes */ + &vlVaCreateSurfaces2, + &vlVaQuerySurfaceAttributes }; PUBLIC VAStatus diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 8d4487b..0e489c1 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -36,6 +36,7 @@ #include "util/u_surface.h" #include "vl/vl_compositor.h" +#include "vl/vl_video_buffer.h" #include "vl/vl_winsys.h" #include "va_private.h" @@ -44,56 +45,8 @@ VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) { - struct pipe_video_buffer templat = {}; - struct pipe_screen *pscreen; - vlVaDriver *drv; - int i; - - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; - - if (!(width && height)) - return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; - - drv = VL_VA_DRIVER(ctx); - pscreen = VL_VA_PSCREEN(ctx); - - templat.buffer_format = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERED_FORMAT - ); - templat.chroma_format = ChromaToPipe(format); - templat.width = width; - templat.height = height; - templat.interlaced = pscreen->get_video_param - ( - pscreen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERS_INTERLACED - ); - - for (i = 0; i < num_surfaces; ++i) { - vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface)); - if (!surf) - goto no_res; - - surf->templat = templat; - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat); - util_dynarray_init(&surf->subpics); - surfaces[i] = handle_table_add(drv->htab, surf); - } - - return VA_STATUS_SUCCESS; - -no_res: - if (i) - vlVaDestroySurfaces(ctx, surfaces, i); - - return VA_STATUS_ERROR_ALLOCATION_FAILED; + return vlVaCreateSurfaces2(ctx, format, width, height, surfaces, num_surfaces, + NULL, 0); } VAStatus @@ -349,3 +302,240 @@ vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID surface) return VA_STATUS_ERROR_UNIMPLEMENTED; } + +VAStatus +vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, + VASurfaceAttrib *attrib_list, unsigned int *num_attribs) +{ +vlVaDriver *drv; +VASurfaceAttrib *attribs; +struct pipe_screen *pscreen; +int i; + +if (config == VA_INVALID_ID) +return VA_STATUS_ERROR_INVALID_CONFIG; + +if (!attrib_list && !num_attribs) +return VA_STATUS_ERROR_INVALID_PARAMETER; + +if (!attrib_list) { +*num_attribs = VASurfaceAttribCount; +return VA_STATUS_SUCCESS; +} + +if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +drv = VL_VA_DRIVER(ctx); + +if (!drv) +return VA_STATUS_ERROR_INVALID_CONTEXT; + +pscreen = VL_VA_PSCREEN(ctx); + +if (!pscreen) + return VA_STATUS_ERROR_INVALID_CONTEXT; + +attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + +if (!attribs) +return VA_STATUS_ERROR_ALLOCATION_FAILED; + +i = 0; + +if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { + /* Assume VAEntrypointVideoProc for now. */ + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[i
[Mesa-dev] [PATCH v5 00/10] st/va: add support for VPP, headless and dmabuf
All these patches have been already reviewed by Emil Velikov. And are now under review by Christian Koenig. This patch serie adds initial support for Video Post Processing. It also implements VaCreateSurfaces2 for common purpose and also to import a dmabuf. It also adds support for headless mode, i.e. using DRM instead of X11. This 2 last patches allow to derive a va surface as a va image. Which one can be exported as dmabuf by calling VaAcquireBufferHandle. I have tested these patches with gstreamer-vaapi and nouveau driver. The pipeline looks like: gstvaapidecode:(vasurface, NV12) -> gstvaapipostproc:(dmabuf, RGBA) -> glimagesink(EGL_EXT_image_dma_buf_import) I even went further by doing export and import in separate processes, i.e. exporting the surface in a process A, and importing in an EGLImage in a process B. The concrete use case is the GStreamer backend for the Chromium browser: https://github.com/Samsung/ChromiumGStreamerBackend The VA surface is exported as dmabuf in the new Media Process. Then this dmabuf is imported into an EGLImage in the GPU Process. Julien Isorce (10): st/va: properly defines VAImageFormat formats and improve VaCreateImage st/va: do not destroy old buffer when new one failed st/va: implement VaCreateSurfaces2 and VaQuerySurfaceAttributes st/va: implement dmabuf import for VaCreateSurfaces2 st/va: add colospace conversion through Video Post Processing st/va: handle Video Post Processing for configs st/va: add headless support, i.e. VA_DISPLAY_DRM st/va: add more errors checks in vlVaBufferSetNumElements and vlVaMapBuffer st/va: implement VaDeriveImage st/va: add support to export a surface as dmabuf src/gallium/include/pipe/p_format.h| 3 +- src/gallium/state_trackers/va/Makefile.am | 9 + src/gallium/state_trackers/va/buffer.c | 183 ++- src/gallium/state_trackers/va/config.c | 20 ++ src/gallium/state_trackers/va/context.c| 201 src/gallium/state_trackers/va/image.c | 138 - src/gallium/state_trackers/va/picture.c| 81 - src/gallium/state_trackers/va/surface.c| 481 ++--- src/gallium/state_trackers/va/va_private.h | 71 - 9 files changed, 1055 insertions(+), 132 deletions(-) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 05/10] st/va: add colospace conversion through Video Post Processing
Add support for VPP in the following functions: vlVaCreateContext vlVaDestroyContext vlVaBeginPicture vlVaRenderPicture vlVaEndPicture Add support for VAProcFilterNone in: vlVaQueryVideoProcFilters vlVaQueryVideoProcFilterCaps vlVaQueryVideoProcPipelineCaps Add handleVAProcPipelineParameterBufferType helper. One application is: VASurfaceNV12 -> gstvaapipostproc -> VASurfaceRGBA Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/context.c| 124 + src/gallium/state_trackers/va/picture.c| 81 ++- src/gallium/state_trackers/va/surface.c| 98 ++- src/gallium/state_trackers/va/va_private.h | 8 ++ 4 files changed, 259 insertions(+), 52 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 9cc402e..a107cc4 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -87,6 +87,14 @@ static struct VADriverVTable vtable = &vlVaQuerySurfaceAttributes }; +static struct VADriverVTableVPP vtable_vpp = +{ + 1, + &vlVaQueryVideoProcFilters, + &vlVaQueryVideoProcFilterCaps, + &vlVaQueryVideoProcPipelineCaps +}; + PUBLIC VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx) { @@ -122,6 +130,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) ctx->version_major = 0; ctx->version_minor = 1; *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_attributes = 1; @@ -151,11 +160,15 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, struct pipe_video_codec templat = {}; vlVaDriver *drv; vlVaContext *context; + int is_vpp; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - if (!(picture_width && picture_height)) + is_vpp = config_id == PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width && +!picture_height && !flag && !render_targets && !num_render_targets; + + if (!(picture_width && picture_height) && !is_vpp) return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; drv = VL_VA_DRIVER(ctx); @@ -163,52 +176,60 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, if (!context) return VA_STATUS_ERROR_ALLOCATION_FAILED; - templat.profile = config_id; - templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; - templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; - templat.width = picture_width; - templat.height = picture_height; - templat.max_references = num_render_targets; - templat.expect_chunked_decode = true; - - if (u_reduce_video_profile(templat.profile) == - PIPE_VIDEO_FORMAT_MPEG4_AVC) - templat.level = u_get_h264_level(templat.width, templat.height, -&templat.max_references); - - context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat); - if (!context->decoder) { - FREE(context); - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } - - if (u_reduce_video_profile(context->decoder->profile) == - PIPE_VIDEO_FORMAT_MPEG4_AVC) { - context->desc.h264.pps = CALLOC_STRUCT(pipe_h264_pps); - if (!context->desc.h264.pps) { + if (is_vpp) { + context->decoder = NULL; + if (!drv->compositor.upload) { FREE(context); - return VA_STATUS_ERROR_ALLOCATION_FAILED; + return VA_STATUS_ERROR_INVALID_CONTEXT; } - context->desc.h264.pps->sps = CALLOC_STRUCT(pipe_h264_sps); - if (!context->desc.h264.pps->sps) { - FREE(context->desc.h264.pps); + } else { + templat.profile = config_id; + templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; + templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; + templat.width = picture_width; + templat.height = picture_height; + templat.max_references = num_render_targets; + templat.expect_chunked_decode = true; + + if (u_reduce_video_profile(templat.profile) == +PIPE_VIDEO_FORMAT_MPEG4_AVC) +templat.level = u_get_h264_level(templat.width, templat.height, + &templat.max_references); + + context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat); + if (!context->decoder) { FREE(context); return VA_STATUS_ERROR_ALLOCATION_FAILED; } - } - if (u_reduce_video_profile(context->decoder->profile) == - PIPE_VIDEO_FORMAT_HEVC) { - context->desc.h265.pps = CALLOC_STRUCT(pipe_h265_pps); - if (!context->desc.h265.pps) { - FREE(context); - return VA_STATUS_ERROR_ALLOCATION_FAILED; + if (u_reduce_video_profile(cont
[Mesa-dev] [PATCH v5 07/10] st/va: add headless support, i.e. VA_DISPLAY_DRM
This patch allows to use gallium vaapi without requiring a X server running for your second graphic card. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/Makefile.am | 9 src/gallium/state_trackers/va/context.c | 70 --- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/va/Makefile.am b/src/gallium/state_trackers/va/Makefile.am index 2a93a90..348cfe1 100644 --- a/src/gallium/state_trackers/va/Makefile.am +++ b/src/gallium/state_trackers/va/Makefile.am @@ -30,6 +30,15 @@ AM_CFLAGS = \ $(VA_CFLAGS) \ -DVA_DRIVER_INIT_FUNC="__vaDriverInit_$(VA_MAJOR)_$(VA_MINOR)" +AM_CFLAGS += \ + $(GALLIUM_PIPE_LOADER_DEFINES) \ + -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" + +if HAVE_GALLIUM_STATIC_TARGETS +AM_CFLAGS += \ + -DGALLIUM_STATIC_TARGETS=1 +endif + AM_CPPFLAGS = \ -I$(top_srcdir)/include diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index a107cc4..bd533c4 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -28,7 +28,8 @@ #include "pipe/p_screen.h" #include "pipe/p_video_codec.h" - +#include "pipe-loader/pipe_loader.h" +#include "state_tracker/drm_driver.h" #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_video.h" @@ -36,6 +37,8 @@ #include "va_private.h" +#include + static struct VADriverVTable vtable = { &vlVaTerminate, @@ -99,6 +102,8 @@ PUBLIC VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx) { vlVaDriver *drv; + int drm_fd; + struct drm_state *drm_info; if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -107,9 +112,56 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) if (!drv) return VA_STATUS_ERROR_ALLOCATION_FAILED; - drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); - if (!drv->vscreen) - goto error_screen; + switch (ctx->display_type) { + case VA_DISPLAY_ANDROID: + case VA_DISPLAY_WAYLAND: + FREE(drv); + return VA_STATUS_ERROR_UNIMPLEMENTED; + case VA_DISPLAY_GLX: + case VA_DISPLAY_X11: + drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); + if (!drv->vscreen) + goto error_screen; + break; + case VA_DISPLAY_DRM: + case VA_DISPLAY_DRM_RENDERNODES: { + drm_info = (struct drm_state *) ctx->drm_state; + if (!drm_info) { + FREE(drv); + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + +#if GALLIUM_STATIC_TARGETS + drm_fd = drm_info->fd; +#else + drm_fd = dup(drm_info->fd); +#endif + + if (drm_fd < 0) { + FREE(drv); + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + + drv->vscreen = CALLOC_STRUCT(vl_screen); + if (!drv->vscreen) + goto error_screen; + +#if GALLIUM_STATIC_TARGETS + drv->vscreen->pscreen = dd_create_screen(drm_fd); +#else + if (pipe_loader_drm_probe_fd(&drv->dev, drm_fd)) + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, PIPE_SEARCH_DIR); +#endif + + if (!drv->vscreen->pscreen) + goto error_pipe; + + } + break; + default: + FREE(drv); + return VA_STATUS_ERROR_INVALID_DISPLAY; + } drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen, drv->vscreen, 0); @@ -145,7 +197,10 @@ error_htab: drv->pipe->destroy(drv->pipe); error_pipe: - vl_screen_destroy(drv->vscreen); + if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == VA_DISPLAY_X11) + vl_screen_destroy(drv->vscreen); + else + FREE(drv->vscreen); error_screen: FREE(drv); @@ -282,7 +337,10 @@ vlVaTerminate(VADriverContextP ctx) vl_compositor_cleanup_state(&drv->cstate); vl_compositor_cleanup(&drv->compositor); drv->pipe->destroy(drv->pipe); - vl_screen_destroy(drv->vscreen); + if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == VA_DISPLAY_X11) + vl_screen_destroy(drv->vscreen); + else + FREE(drv->vscreen); handle_table_destroy(drv->htab); FREE(drv); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 02/10] st/va: do not destroy old buffer when new one failed
If formats are not the same vlVaPutImage re-creates the video buffer with the right format. But if the creation of this new video buffer fails then the surface looses its current buffer. Let's just destroy the previous buffer on success. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/image.c | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index 0d961b1..b0c720d 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -346,13 +346,20 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, if (format == PIPE_FORMAT_NONE) return VA_STATUS_ERROR_OPERATION_FAILED; - if (surf->buffer == NULL || format != surf->buffer->buffer_format) { - if (surf->buffer) - surf->buffer->destroy(surf->buffer); + if (format != surf->buffer->buffer_format) { + struct pipe_video_buffer *tmp_buf; + enum pipe_format old_surf_format = surf->templat.buffer_format; + surf->templat.buffer_format = format; - surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); - if (!surf->buffer) - return VA_STATUS_ERROR_ALLOCATION_FAILED; + tmp_buf = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); + + if (!tmp_buf) { + surf->templat.buffer_format = old_surf_format; + return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + + surf->buffer->destroy(surf->buffer); + surf->buffer = tmp_buf; } views = surf->buffer->get_sampler_view_planes(surf->buffer); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 6/9] st/va: add colospace conversion through Video Post Processing
On 30 October 2015 at 11:54, Christian König wrote: > On 29.10.2015 18:40, Julien Isorce wrote: > >> Add support for VPP in the following functions: >> vlVaCreateContext >> vlVaDestroyContext >> vlVaBeginPicture >> vlVaRenderPicture >> vlVaEndPicture >> >> Add support for VAProcFilterNone in: >> vlVaQueryVideoProcFilters >> vlVaQueryVideoProcFilterCaps >> vlVaQueryVideoProcPipelineCaps >> >> Add handleVAProcPipelineParameterBufferType helper. >> >> One application is: >> VASurfaceNV12 -> gstvaapipostproc -> VASurfaceRGBA >> >> Signed-off-by: Julien Isorce >> > > Reviewed-by: Christian König > > Are you planning to implement the different filters as well? Most of the > shaders for those are already present. > No plan at the moment. But I'll let you know before starting something to avoid duplication. But I'll check regularly for regressions with what just landed and with ChromiumGStreamerBackend. I'll try first to finish st/va chunk decoding with nouveau driver, Last blocker was a pb with h264. Maybe some plan to experiment mesa-st/omx + Tizonia + gst-omx on desktop, will see if I have some time to spend there. Cheers Julien ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4] st/va: fix memory leak on error in vlVaCreateSurfaces2
Found by coverity: CID #1337953 Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/surface.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 59815aa..3db21c3 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -479,8 +479,10 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, util_dynarray_init(&surface->subpics); surfaces[index] = handle_table_add(drv->htab, surface); - if (!surfaces[index]) + if (!surfaces[index]) { + surface->buffer->destroy(surface->buffer); return VA_STATUS_ERROR_ALLOCATION_FAILED; + } return VA_STATUS_SUCCESS; } @@ -612,15 +614,19 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, switch (memory_type) { case VA_SURFACE_ATTRIB_MEM_TYPE_VA: surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat); - if (!surf->buffer) + if (!surf->buffer) { +FREE(surf); goto no_res; + } util_dynarray_init(&surf->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, &templat); - if (vaStatus != VA_STATUS_SUCCESS) + if (vaStatus != VA_STATUS_SUCCESS) { +FREE(surf); goto no_res; + } break; default: assert(0); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4] st/va: add support for RGBX and BGRX in VPP
Before it was only possible to convert a NV12 surface to RGBA or BGRA. This patch uses the same post processing function, "handleVAProcPipelineParameterBufferType", but add definitions for RGBX and BGRX. This patch also makes vlVaQuerySurfaceAttributes more generic. Signed-off-by: Julien Isorce --- src/gallium/auxiliary/vl/vl_video_buffer.c | 18 +++ src/gallium/state_trackers/va/picture.c| 5 +++-- src/gallium/state_trackers/va/surface.c| 36 +- src/gallium/state_trackers/va/va_private.h | 1 + 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c index 5e0ae0e..6cd2557 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -62,6 +62,18 @@ const enum pipe_format const_resource_formats_VUYA[3] = { PIPE_FORMAT_NONE }; +const enum pipe_format const_resource_formats_YUVX[3] = { + PIPE_FORMAT_R8G8B8X8_UNORM, + PIPE_FORMAT_NONE, + PIPE_FORMAT_NONE +}; + +const enum pipe_format const_resource_formats_VUYX[3] = { + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_NONE, + PIPE_FORMAT_NONE +}; + const enum pipe_format const_resource_formats_YUYV[3] = { PIPE_FORMAT_R8G8_R8B8_UNORM, PIPE_FORMAT_NONE, @@ -102,6 +114,12 @@ vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format) case PIPE_FORMAT_B8G8R8A8_UNORM: return const_resource_formats_VUYA; + case PIPE_FORMAT_R8G8B8X8_UNORM: + return const_resource_formats_VUYX; + + case PIPE_FORMAT_B8G8R8X8_UNORM: + return const_resource_formats_VUYX; + case PIPE_FORMAT_YUYV: return const_resource_formats_YUYV; diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 644b848..d6cdbea 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -59,11 +59,12 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende return VA_STATUS_ERROR_INVALID_SURFACE; context->target = surf->buffer; - if (!context->decoder) { /* VPP */ if ((context->target->buffer_format != PIPE_FORMAT_B8G8R8A8_UNORM && - context->target->buffer_format != PIPE_FORMAT_R8G8B8A8_UNORM) || + 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->interlaced) return VA_STATUS_ERROR_UNIMPLEMENTED; return VA_STATUS_SUCCESS; diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 3db21c3..589d686 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -45,6 +45,11 @@ #include +static const enum pipe_format vpp_surface_formats[] = { + PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_R8G8B8A8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_FORMAT_R8G8B8X8_UNORM +}; + VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) @@ -314,7 +319,9 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, vlVaDriver *drv; VASurfaceAttrib *attribs; struct pipe_screen *pscreen; - int i; + int i, j; + + STATIC_ASSERT(ARRAY_SIZE(vpp_surface_formats) <= VL_VA_MAX_IMAGE_FORMATS); if (config == VA_INVALID_ID) return VA_STATUS_ERROR_INVALID_CONFIG; @@ -323,7 +330,7 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, return VA_STATUS_ERROR_INVALID_PARAMETER; if (!attrib_list) { - *num_attribs = VASurfaceAttribCount; + *num_attribs = VL_VA_MAX_IMAGE_FORMATS + VASurfaceAttribCount; return VA_STATUS_SUCCESS; } @@ -340,27 +347,24 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, if (!pscreen) return VA_STATUS_ERROR_INVALID_CONTEXT; - attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + attribs = CALLOC(VL_VA_MAX_IMAGE_FORMATS + VASurfaceAttribCount, +sizeof(VASurfaceAttrib)); if (!attribs) return VA_STATUS_ERROR_ALLOCATION_FAILED; i = 0; + /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN +* only for VAEntrypointVideoProc. */ if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { - /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN - only for VAEntrypointVideoProc. */ - 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_BGRA; - i++; -
[Mesa-dev] [PATCH 0/4] st/va: indent, leak fix and RGBx/BGRx for vpp
A few fixes and small improvement from recent changes in st/va: * Indentation was wrong for some functions. * Coverity reported a memory leak. (thx to Ilia for pointing this) * More color formats convertion for Video Post Processing Julien Isorce (4): st/va: indent vlVaQuerySurfaceAttributes and vlVaCreateSurfaces2 st/va: fix memory leak on error in vlVaCreateSurfaces2 st/va: properly indent buffer.c, config.c, image.c and picture.c st/va: add support for RGBX and BGRX in VPP src/gallium/auxiliary/vl/vl_video_buffer.c | 18 + src/gallium/state_trackers/va/buffer.c | 23 +- src/gallium/state_trackers/va/config.c | 12 +- src/gallium/state_trackers/va/image.c | 4 +- src/gallium/state_trackers/va/picture.c| 87 ++--- src/gallium/state_trackers/va/surface.c| 602 +++-- src/gallium/state_trackers/va/va_private.h | 1 + 7 files changed, 388 insertions(+), 359 deletions(-) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4] st/va: indent vlVaQuerySurfaceAttributes and vlVaCreateSurfaces2
Some lines were using 4 indentation spaces instead of 3. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/surface.c | 566 1 file changed, 283 insertions(+), 283 deletions(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 8f406e0..59815aa 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -311,101 +311,101 @@ VAStatus vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, VASurfaceAttrib *attrib_list, unsigned int *num_attribs) { -vlVaDriver *drv; -VASurfaceAttrib *attribs; -struct pipe_screen *pscreen; -int i; + vlVaDriver *drv; + VASurfaceAttrib *attribs; + struct pipe_screen *pscreen; + int i; -if (config == VA_INVALID_ID) -return VA_STATUS_ERROR_INVALID_CONFIG; + if (config == VA_INVALID_ID) + return VA_STATUS_ERROR_INVALID_CONFIG; -if (!attrib_list && !num_attribs) -return VA_STATUS_ERROR_INVALID_PARAMETER; + if (!attrib_list && !num_attribs) + return VA_STATUS_ERROR_INVALID_PARAMETER; -if (!attrib_list) { -*num_attribs = VASurfaceAttribCount; -return VA_STATUS_SUCCESS; -} + if (!attrib_list) { + *num_attribs = VASurfaceAttribCount; + return VA_STATUS_SUCCESS; + } -if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; -drv = VL_VA_DRIVER(ctx); + drv = VL_VA_DRIVER(ctx); -if (!drv) -return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; -pscreen = VL_VA_PSCREEN(ctx); + pscreen = VL_VA_PSCREEN(ctx); -if (!pscreen) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!pscreen) + return VA_STATUS_ERROR_INVALID_CONTEXT; -attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); -if (!attribs) -return VA_STATUS_ERROR_ALLOCATION_FAILED; + if (!attribs) + return VA_STATUS_ERROR_ALLOCATION_FAILED; -i = 0; + i = 0; -if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { - /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN + if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { + /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN only for VAEntrypointVideoProc. */ - 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_BGRA; - 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_RGBA; - i++; -} else { - /* Assume VAEntrypointVLD for now. */ - 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++; -} - -attribs[i].type = VASurfaceAttribMemoryType; -attribs[i].value.type = VAGenericValueTypeInteger; -attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; -attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | -VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; -i++; - -attribs[i].type = VASurfaceAttribExternalBufferDescriptor; -attribs[i].value.type = VAGenericValueTypePointer; -attribs[i].flags = VA_SURFACE_ATTRIB_SETTABLE; -attribs[i].value.value.p = NULL; /* ignore */ -i++; - -attribs[i].type = VASurfaceAttribMaxWidth; -attribs[i].value.type = VAGenericValueTypeInteger; -attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; -attribs[i].value.value.i = vl_video_buffer_max_size(pscreen); -i++; - -attribs[i].type = VASurfaceAttribMaxHeight; -attribs[i].value.type = VAGenericValueTypeInteger; -attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; -attribs[i].value.value.i = vl_video_buffer_max_size(pscreen); -i++; - -if (i > *num_attribs) { -*num_attribs = i; -FREE(attribs); -return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; -} - -*num_attribs = i; -memcpy(attrib_list, attribs, i * sizeof(VASurfaceAttrib)); -FREE(attribs); - -return VA_STATUS_SUCCESS; + 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_BGRA; + i++; + + attribs[i].type = VASurfaceAttribPixelFormat; + at
[Mesa-dev] [PATCH 3/4] st/va: properly indent buffer.c, config.c, image.c and picture.c
Some lines were using 4 indentation spaces instead of 3. The switch in vlVaAcquireBufferHandle actually had wrong brackets surrounding case+default. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 23 + src/gallium/state_trackers/va/config.c | 12 ++--- src/gallium/state_trackers/va/image.c | 4 +- src/gallium/state_trackers/va/picture.c | 82 - 4 files changed, 60 insertions(+), 61 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 71a6503..769305e 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -152,11 +152,11 @@ vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) return VA_STATUS_ERROR_INVALID_BUFFER; if (buf->derived_surface.resource) { - if (!buf->derived_surface.transfer) -return VA_STATUS_ERROR_INVALID_BUFFER; + if (!buf->derived_surface.transfer) + return VA_STATUS_ERROR_INVALID_BUFFER; - pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); - buf->derived_surface.transfer = NULL; + pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); + buf->derived_surface.transfer = NULL; } return VA_STATUS_SUCCESS; @@ -175,10 +175,10 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) return VA_STATUS_ERROR_INVALID_BUFFER; if (buf->derived_surface.resource) { - if (buf->export_refcount > 0) - return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; - pipe_resource_reference(&buf->derived_surface.resource, NULL); + pipe_resource_reference(&buf->derived_surface.resource, NULL); } FREE(buf->data); @@ -280,15 +280,14 @@ vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, buf_info->handle = (intptr_t)whandle.handle; break; + } default: return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; } - } - - buf_info->type = buf->type; - buf_info->mem_type = mem_type; - buf_info->mem_size = buf->num_elements * buf->size; + buf_info->type = buf->type; + buf_info->mem_type = mem_type; + buf_info->mem_size = buf->num_elements * buf->size; } buf->export_refcount++; diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index 0f47aac..a545a18 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -71,8 +71,8 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile, *num_entrypoints = 0; if (profile == VAProfileNone) { - entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; - return VA_STATUS_SUCCESS; + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; + return VA_STATUS_SUCCESS; } p = ProfileToPipe(profile); @@ -104,7 +104,7 @@ vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint en value = VA_RT_FORMAT_YUV420; break; case VAConfigAttribRateControl: -value = VA_RC_NONE; + value = VA_RC_NONE; break; default: value = VA_ATTRIB_NOT_SUPPORTED; @@ -127,8 +127,8 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin return VA_STATUS_ERROR_INVALID_CONTEXT; if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) { - *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; - return VA_STATUS_SUCCESS; + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; + return VA_STATUS_SUCCESS; } p = ProfileToPipe(profile); @@ -167,7 +167,7 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { *entrypoint = VAEntrypointVideoProc; - *num_attribs = 0; + *num_attribs = 0; return VA_STATUS_SUCCESS; } diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index c6d0c5a..ae07da8 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -447,8 +447,8 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, tmp_buf = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); if (!tmp_buf) { - surf->templat.buffer_format = old_surf_format; - return VA_STATUS_ERROR_ALLOCATION_FAILED; + surf->templat.buffer_format = old_surf_format; + return VA_STATUS_ERROR_ALLOCATION_FAILED; } surf->buffer->destroy(surf->buffer); diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index e850689..644b848 100644 --- a/src/gallium/st
Re: [Mesa-dev] [PATCH 3/4] st/va: properly indent buffer.c, config.c, image.c and picture.c
On 5 November 2015 at 16:28, Emil Velikov wrote: > On 5 November 2015 at 08:24, Julien Isorce > wrote: > > Some lines were using 4 indentation spaces instead of 3. > > > > The switch in vlVaAcquireBufferHandle actually had wrong brackets > > surrounding case+default. > > > Please don't mix whitespace (trivial) patches and bugfixes. > > -Emil > Right, I'll split it. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/4] st/va: add support for RGBX and BGRX in VPP
On 5 November 2015 at 16:27, Emil Velikov wrote: > Hi Julien, > > On 5 November 2015 at 08:24, Julien Isorce > wrote: > > Before it was only possible to convert a NV12 surface to > > RGBA or BGRA. This patch uses the same post processing > > function, "handleVAProcPipelineParameterBufferType", but > > add definitions for RGBX and BGRX. > > > > This patch also makes vlVaQuerySurfaceAttributes more generic. > > > > Signed-off-by: Julien Isorce > > --- > > src/gallium/auxiliary/vl/vl_video_buffer.c | 18 +++ > > src/gallium/state_trackers/va/picture.c| 5 +++-- > > src/gallium/state_trackers/va/surface.c| 36 > +- > > src/gallium/state_trackers/va/va_private.h | 1 + > > 4 files changed, 42 insertions(+), 18 deletions(-) > > > As the diffstat suggests - two different areas, thus this should be > different patches. > > Ok I'll split it. > > > @@ -314,7 +319,9 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, > VAConfigID config, > > vlVaDriver *drv; > > VASurfaceAttrib *attribs; > > struct pipe_screen *pscreen; > > - int i; > > + int i, j; > > + > > + STATIC_ASSERT(ARRAY_SIZE(vpp_surface_formats) <= > VL_VA_MAX_IMAGE_FORMATS); > > > Nice, thank you ! > no pb :) > > > > --- a/src/gallium/state_trackers/va/va_private.h > > +++ b/src/gallium/state_trackers/va/va_private.h > > @@ -49,6 +49,7 @@ > > #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen) > > > > #define VL_VA_MAX_IMAGE_FORMATS 9 > > +#define VL_VA_MAX_SURFACE_ATTRIBUTES 24 > > > Unused define ? > Thx I'll remove this residual from a previous attempt. > > Cheers, > Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/4] st/va: indent, leak fix and RGBx/BGRx for vpp
On 5 November 2015 at 14:22, Christian König wrote: > Patches #1-#3 are Reviewed-by: Christian König > > Please split patch #4 in two with first adding the new vl_video_buffer > formats and then using them in the state tracker. > Makes sense, I'll split it. > > Should I commit that for you as well or do you now have an account? > I requested the account few minutes ago but please push #1 and #2. Tomorrow I'll send a v2 about #3 and #4 after addressing remarks + split. Thx Julien > > Regards, > Christian. > > > On 05.11.2015 09:24, Julien Isorce wrote: > >> A few fixes and small improvement from recent changes in st/va: >> * Indentation was wrong for some functions. >> * Coverity reported a memory leak. (thx to Ilia for pointing this) >> * More color formats convertion for Video Post Processing >> >> Julien Isorce (4): >>st/va: indent vlVaQuerySurfaceAttributes and vlVaCreateSurfaces2 >>st/va: fix memory leak on error in vlVaCreateSurfaces2 >>st/va: properly indent buffer.c, config.c, image.c and picture.c >>st/va: add support for RGBX and BGRX in VPP >> >> src/gallium/auxiliary/vl/vl_video_buffer.c | 18 + >> src/gallium/state_trackers/va/buffer.c | 23 +- >> src/gallium/state_trackers/va/config.c | 12 +- >> src/gallium/state_trackers/va/image.c | 4 +- >> src/gallium/state_trackers/va/picture.c| 87 ++--- >> src/gallium/state_trackers/va/surface.c| 602 >> +++-- >> src/gallium/state_trackers/va/va_private.h | 1 + >> 7 files changed, 388 insertions(+), 359 deletions(-) >> >> > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 3/4] vl/buffers: add RGBX and BGRX to the supported formats
Useful is one wants to create RGBX or BGRX surfaces. The infrastructure is such that it required just a few definitions to support these formats. Signed-off-by: Julien Isorce --- src/gallium/auxiliary/vl/vl_video_buffer.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c index 5e0ae0e..6cd2557 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -62,6 +62,18 @@ const enum pipe_format const_resource_formats_VUYA[3] = { PIPE_FORMAT_NONE }; +const enum pipe_format const_resource_formats_YUVX[3] = { + PIPE_FORMAT_R8G8B8X8_UNORM, + PIPE_FORMAT_NONE, + PIPE_FORMAT_NONE +}; + +const enum pipe_format const_resource_formats_VUYX[3] = { + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_NONE, + PIPE_FORMAT_NONE +}; + const enum pipe_format const_resource_formats_YUYV[3] = { PIPE_FORMAT_R8G8_R8B8_UNORM, PIPE_FORMAT_NONE, @@ -102,6 +114,12 @@ vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format) case PIPE_FORMAT_B8G8R8A8_UNORM: return const_resource_formats_VUYA; + case PIPE_FORMAT_R8G8B8X8_UNORM: + return const_resource_formats_VUYX; + + case PIPE_FORMAT_B8G8R8X8_UNORM: + return const_resource_formats_VUYX; + case PIPE_FORMAT_YUYV: return const_resource_formats_YUYV; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 2/4] st/va: properly use brackets in vlVaAcquireBufferHandle's switch
In "switch (mem_type)" the brackets were surrounding "case+default" instead of "case" only. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 47bf35a..769305e 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -280,15 +280,14 @@ vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, buf_info->handle = (intptr_t)whandle.handle; break; + } default: return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; } - } - - buf_info->type = buf->type; - buf_info->mem_type = mem_type; - buf_info->mem_size = buf->num_elements * buf->size; + buf_info->type = buf->type; + buf_info->mem_type = mem_type; + buf_info->mem_size = buf->num_elements * buf->size; } buf->export_refcount++; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 1/4] st/va: properly indent buffer.c, config.c, image.c and picture.c
Some lines were using 4 indentation spaces instead of 3. The switch in vlVaAcquireBufferHandle actually had wrong brackets surrounding case+default. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/buffer.c | 14 +++--- src/gallium/state_trackers/va/config.c | 12 ++--- src/gallium/state_trackers/va/image.c | 4 +- src/gallium/state_trackers/va/picture.c | 82 - 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 71a6503..47bf35a 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -152,11 +152,11 @@ vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) return VA_STATUS_ERROR_INVALID_BUFFER; if (buf->derived_surface.resource) { - if (!buf->derived_surface.transfer) -return VA_STATUS_ERROR_INVALID_BUFFER; + if (!buf->derived_surface.transfer) + return VA_STATUS_ERROR_INVALID_BUFFER; - pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); - buf->derived_surface.transfer = NULL; + pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); + buf->derived_surface.transfer = NULL; } return VA_STATUS_SUCCESS; @@ -175,10 +175,10 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) return VA_STATUS_ERROR_INVALID_BUFFER; if (buf->derived_surface.resource) { - if (buf->export_refcount > 0) - return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; - pipe_resource_reference(&buf->derived_surface.resource, NULL); + pipe_resource_reference(&buf->derived_surface.resource, NULL); } FREE(buf->data); diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index 0f47aac..a545a18 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -71,8 +71,8 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile, *num_entrypoints = 0; if (profile == VAProfileNone) { - entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; - return VA_STATUS_SUCCESS; + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; + return VA_STATUS_SUCCESS; } p = ProfileToPipe(profile); @@ -104,7 +104,7 @@ vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint en value = VA_RT_FORMAT_YUV420; break; case VAConfigAttribRateControl: -value = VA_RC_NONE; + value = VA_RC_NONE; break; default: value = VA_ATTRIB_NOT_SUPPORTED; @@ -127,8 +127,8 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin return VA_STATUS_ERROR_INVALID_CONTEXT; if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) { - *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; - return VA_STATUS_SUCCESS; + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; + return VA_STATUS_SUCCESS; } p = ProfileToPipe(profile); @@ -167,7 +167,7 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { *entrypoint = VAEntrypointVideoProc; - *num_attribs = 0; + *num_attribs = 0; return VA_STATUS_SUCCESS; } diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index c6d0c5a..ae07da8 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -447,8 +447,8 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, tmp_buf = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); if (!tmp_buf) { - surf->templat.buffer_format = old_surf_format; - return VA_STATUS_ERROR_ALLOCATION_FAILED; + surf->templat.buffer_format = old_surf_format; + return VA_STATUS_ERROR_ALLOCATION_FAILED; } surf->buffer->destroy(surf->buffer); diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index e850689..644b848 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -65,7 +65,7 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende if ((context->target->buffer_format != PIPE_FORMAT_B8G8R8A8_UNORM && context->target->buffer_format != PIPE_FORMAT_R8G8B8A8_UNORM) || context->target->interlaced) - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNIMPLEMENTED; return VA_STATUS_SUCCESS; } @@ -717,60 +717,60 @@ handleVASliceDataBufferType(vlVaContext
[Mesa-dev] [PATCH v2 4/4] st/va: add support for RGBX and BGRX in VPP
Before it was only possible to convert a NV12 surface to RGBA or BGRA. This patch uses the same post processing function, "handleVAProcPipelineParameterBufferType", but add definitions for RGBX and BGRX. This patch also makes vlVaQuerySurfaceAttributes more generic to avoid copy and pasting the same lines. Signed-off-by: Julien Isorce --- src/gallium/state_trackers/va/picture.c | 5 +++-- src/gallium/state_trackers/va/surface.c | 36 ++--- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 644b848..d6cdbea 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -59,11 +59,12 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende return VA_STATUS_ERROR_INVALID_SURFACE; context->target = surf->buffer; - if (!context->decoder) { /* VPP */ if ((context->target->buffer_format != PIPE_FORMAT_B8G8R8A8_UNORM && - context->target->buffer_format != PIPE_FORMAT_R8G8B8A8_UNORM) || + 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->interlaced) return VA_STATUS_ERROR_UNIMPLEMENTED; return VA_STATUS_SUCCESS; diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 3db21c3..589d686 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -45,6 +45,11 @@ #include +static const enum pipe_format vpp_surface_formats[] = { + PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_R8G8B8A8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_FORMAT_R8G8B8X8_UNORM +}; + VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) @@ -314,7 +319,9 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, vlVaDriver *drv; VASurfaceAttrib *attribs; struct pipe_screen *pscreen; - int i; + int i, j; + + STATIC_ASSERT(ARRAY_SIZE(vpp_surface_formats) <= VL_VA_MAX_IMAGE_FORMATS); if (config == VA_INVALID_ID) return VA_STATUS_ERROR_INVALID_CONFIG; @@ -323,7 +330,7 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, return VA_STATUS_ERROR_INVALID_PARAMETER; if (!attrib_list) { - *num_attribs = VASurfaceAttribCount; + *num_attribs = VL_VA_MAX_IMAGE_FORMATS + VASurfaceAttribCount; return VA_STATUS_SUCCESS; } @@ -340,27 +347,24 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, if (!pscreen) return VA_STATUS_ERROR_INVALID_CONTEXT; - attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + attribs = CALLOC(VL_VA_MAX_IMAGE_FORMATS + VASurfaceAttribCount, +sizeof(VASurfaceAttrib)); if (!attribs) return VA_STATUS_ERROR_ALLOCATION_FAILED; i = 0; + /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN +* only for VAEntrypointVideoProc. */ if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { - /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN - only for VAEntrypointVideoProc. */ - 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_BGRA; - 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_RGBA; - i++; + 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 { /* Assume VAEntrypointVLD for now. */ attribs[i].type = VASurfaceAttribPixelFormat; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 0/6] nouveau: add support for vaapi
Hi, I found some difference in the content of dec->bsp_bo[i], for h264 when using st/vdpau (ok) and st/vaapi (ko). In src/gallium/state_trackers/va/picture.c, at least the reference frames are not set. At minimum it is missing something like the following though still not enough: @@ -193,7 +194,23 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer * context->desc.h264.pps->redundant_pic_cnt_present_flag = h264->pic_fields.bits.redundant_pic_cnt_present_flag; /*reference_pic_flag*/ + context->desc.h264.is_reference = h264->pic_fields.bits.reference_pic_flag; context->desc.h264.frame_num = h264->frame_num; + + for (i = 0; i < 16; ++i) { + if ((h264->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID) || + (h264->ReferenceFrames[i].picture_id == VA_INVALID_SURFACE)) +break; + + getReferenceFrame(drv, h264->ReferenceFrames[i].picture_id, &context->desc.h264.ref[i]); + + context->desc.h264.field_order_cnt_list[i][0] = h264->ReferenceFrames[i].TopFieldOrderCnt; + context->desc.h264.field_order_cnt_list[i][1] = h264->ReferenceFrames[i].BottomFieldOrderCnt; + context->desc.h264.frame_num_list[i] = h264->ReferenceFrames[i].frame_idx; + } I am surprised that "getReferenceFrame" is not called at all in the h264 case. Cheers Julien On 16 October 2015 at 23:18, Ilia Mirkin wrote: > On Fri, Oct 16, 2015 at 6:13 PM, Julien Isorce > wrote: > > > > > > On 18 September 2015 at 21:34, Ilia Mirkin wrote: > >> > >> On Fri, Sep 18, 2015 at 4:29 PM, Julien Isorce > > >> wrote: > >> > > >> > > >> > On 17 September 2015 at 17:52, Ilia Mirkin > wrote: > >> >> > >> >> On Wed, Sep 16, 2015 at 8:22 AM, Julien Isorce > > >> >> wrote: > >> >> > I added below version4 updates. It works for all codecs expect > h264. > >> >> > Video is visible but lot of blockiness. > >> >> > Can someone with a Radeon confirm that "LIBVA_DRIVER_NAME=gallium > mpv > >> >> > --hwdec=vaapi" > >> >> > is working on h264 videos ? > >> >> > I want to make sure it is not a bug in st/va. > >> >> > >> >> The sad reality is that h264 is the only thing that matters (at least > >> >> from this list of supported codecs). My concern is that this series > >> >> will regress the situation for people who want to use VA-API -- right > >> >> now they can use the vdpau <-> vaapi adapter, whereas with this patch > >> >> series, they will end up with a va-api driver that doesn't work. So I > >> >> can't merge this as-is. > >> > > >> > > >> > Make perfectly sense. > >> > > >> >> > >> >> > >> >> Are the various lengths (for inter-bo size/etc) being computed > >> >> properly > >> > > >> > > >> > In the past I compared the final content of the nouveau_bo buffer at > >> > each > >> > endFrame step , with the content using vdpau. There were the same. > >> > I will re-check. > >> > Does it make sense to do that actually ? > >> > Is there anything else I could compare with vdpau ? > >> > >> If you're feeding the exact same stuff and everything is exactly the > >> same, then the results would also be the same. Clearly there's SOME > >> difference SOMEWHERE :) > > > > > > Indeed I compared only dec->bsp_bo, not dec->inter_bo :) I'll check that. > > But in the first place I do not see where dec->inter_bo is filled. Could > you > > point out where this is done ? > > nouveau doesn't fill inter_bo -- it's a bo shared between the VLD and > VDEC engines iirc. > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] question about container_of
Hi, Since 2012 commit ccff74971203b533bf16b46b49a9e61753f75e6c it is said: "sample must be initialized, or else the result is undefined" in the description of mesa/src/util/list.h::container_of . But I can find a few places where it is used without initializing that second parameter, i.e. like: struct A a; container_of(ptr, a, member); Then I can add the "= NULL" but should it be just container_of(ptr, struct A, member); like in the kernel and some other places in mesa ? Thx Julien ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] vlVaQueryImageFormats and vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities also return unsupported formats
Hi, vlVaQueryImageFormats (or vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities) implementation call pscreen->is_video_format_supported with input profile equal to PIPE_VIDEO_PROFILE_UNKNOWN. Problem is that "nouveau_vp3_screen_video_supported" or "rvid_is_format_supported" will returns several formats: NV12, YV12, YUYV, UYVY, BGRA because it fallback to call vl_video_buffer_is_format_supported. Whereas these 2 functions would have return PIPE_FORMAT_NV12 if input profile is not PIPE_VIDEO_PROFILE_UNKNOWN. So I wonder if nouveau_vp3_screen_video_supported should just return PIPE_FORMAT_NV12 in all cases. (same for rvid_is_format_supported) Am I missing something ? What is the purpose of checking PIPE_VIDEO_PROFILE_UNKNOWN : http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/nouveau/nouveau_vp3_video.c#n486 and http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/radeon/radeon_video.c#n323 ? Thx Julien vaapi spec for vaQueryImageFormats: http://cgit.freedesktop.org/libva/tree/va/va.h#n2349 vdpau spec for vdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities: http://cgit.freedesktop.org/~aplattner/libvdpau/tree/include/vdpau/vdpau.h#n1526 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev