From 15bc635499589dc3490e5bdc198dfd376ce6fb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 14 Jul 2010 00:30:46 +0200 Subject: [PATCH 01/36] added surface.c and made some changes in device.c --- src/gallium/state_trackers/vdpau/surface.c | 161 +++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 src/gallium/state_trackers/vdpau/surface.c diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c new file mode 100644 index 00000000000..1f481098ede --- /dev/null +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -0,0 +1,161 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "vdpau_private.h" +#include +#include +#include + +VdpStatus +vlVdpVideoSurfaceCreate(VdpDevice device, + VdpChromaType chroma_type, + uint32_t width, + uint32_t height, + VdpVideoSurface *surface) +{ + vlVdpSurface *p_surf; + VdpStatus ret; + + if (!(width && height)) + { + ret = VDP_STATUS_INVALID_SIZE; + goto inv_size; + } + + + if (!vlCreateHTAB()) { + ret = VDP_STATUS_RESOURCES; + goto no_htab; + } + + p_surf = CALLOC(0, sizeof(p_surf)); + if (!p_surf) { + ret = VDP_STATUS_RESOURCES; + goto no_res; + } + + p_surf->psurface = CALLOC(0,sizeof(struct pipe_surface)); + if (!p_surf->psurface) { + ret = VDP_STATUS_RESOURCES; + goto no_surf; + } + + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) { + ret = VDP_STATUS_INVALID_HANDLE; + goto inv_device; + } + + if (!dev->vlscreen) + dev->vlscreen = vl_screen_create(dev->display, dev->screen); + if (!dev->vlscreen) { + ret = VDP_STATUS_RESOURCES; + goto inv_device; + } + + p_surf->psurface->height = height; + p_surf->psurface->width = width; + p_surf->psurface->level = 0; + p_surf->psurface->usage = PIPE_USAGE_DEFAULT; + p_surf->chroma_format = FormatToPipe(chroma_type); + p_surf->vlscreen = dev->vlscreen; + + *surface = vlAddDataHTAB(p_surf); + if (*surface == 0) { + ret = VDP_STATUS_ERROR; + goto no_handle; + } + + return VDP_STATUS_OK; + +no_handle: + FREE(p_surf->psurface); +no_surf: + FREE(p_surf); +no_res: + // vlDestroyHTAB(); XXX: Do not destroy this tab, I think. +no_htab: +inv_size: + return ret; +} + +VdpStatus +vlVdpVideoSurfaceDestroy ( VdpVideoSurface surface ) +{ + vlVdpSurface *p_surf; + + p_surf = (vlVdpSurface *)vlGetDataHTAB((vlHandle)surface); + if (!p_surf) + return VDP_STATUS_INVALID_HANDLE; + + if (p_surf->psurface) + p_surf->vlscreen->pscreen->tex_surface_destroy(p_surf->psurface); + + FREE(p_surf); + return VDP_STATUS_OK; +} + +VdpStatus +vlVdpVideoSurfaceGetParameters ( VdpVideoSurface surface, + VdpChromaType *chroma_type, + uint32_t *width, + uint32_t *height +) +{ + if (!(width && height && chroma_type)) + return VDP_STATUS_INVALID_POINTER; + + + if (!vlCreateHTAB()) + return VDP_STATUS_RESOURCES; + + + vlVdpSurface *p_surf = vlGetDataHTAB(surface); + if (!p_surf) + return VDP_STATUS_INVALID_HANDLE; + + + if (!(p_surf->psurface && p_surf->chroma_format)) + return VDP_STATUS_INVALID_HANDLE; + + *width = p_surf->psurface->width; + *height = p_surf->psurface->height; + *chroma_type = PipeToType(p_surf->chroma_format); + + return VDP_STATUS_OK; +} + +VdpStatus +vlVdpVideoSurfaceGetBitsYCbCr ( VdpVideoSurface surface, + VdpYCbCrFormat destination_ycbcr_format, + void *const *destination_data, + uint32_t const *destination_pitches +) +{ + + +} From 3299997bcc5a672617095adb560b3834dced39a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 14 Jul 2010 00:34:56 +0200 Subject: [PATCH 02/36] vdpau changes --- configs/autoconf.in | 3 + configs/linux-dri | 7 +- configs/linux-dri-x86-64 | 2 +- configure.ac | 25 +- src/gallium/state_trackers/vdpau/Makefile | 9 +- src/gallium/state_trackers/vdpau/device.c | 8 +- src/gallium/state_trackers/vdpau/ftab.c | 2 +- src/gallium/state_trackers/vdpau/query.c | 57 +- .../state_trackers/vdpau/vdpau_private.h | 107 ++- src/gallium/targets/Makefile.vdpau | 9 +- src/gallium/tests/python/retrace/README | 17 - src/gallium/tests/python/retrace/format.py | 173 ----- src/gallium/tests/python/retrace/model.py | 213 ------ src/gallium/tests/python/retrace/parse.py | 392 ---------- src/gallium/tests/python/retrace/parser.py | 34 - src/gallium/tests/python/samples/gs.py | 254 ------- src/gallium/tests/python/samples/tri.py | 233 ------ src/gallium/tests/python/tests/.gitignore | 3 - src/gallium/tests/python/tests/base.py | 399 ---------- .../tests/regress/fragment-shader/.gitignore | 1 - .../tests/regress/fragment-shader/frag-abs.sh | 13 - .../tests/regress/fragment-shader/frag-add.sh | 8 - .../regress/fragment-shader/frag-cb-1d.sh | 13 - .../tests/regress/fragment-shader/frag-dp3.sh | 8 - .../tests/regress/fragment-shader/frag-dp4.sh | 8 - .../tests/regress/fragment-shader/frag-dst.sh | 8 - .../tests/regress/fragment-shader/frag-ex2.sh | 11 - .../tests/regress/fragment-shader/frag-flr.sh | 15 - .../tests/regress/fragment-shader/frag-frc.sh | 13 - .../tests/regress/fragment-shader/frag-lg2.sh | 15 - .../tests/regress/fragment-shader/frag-lit.sh | 8 - .../tests/regress/fragment-shader/frag-lrp.sh | 11 - .../tests/regress/fragment-shader/frag-mad.sh | 11 - .../tests/regress/fragment-shader/frag-max.sh | 10 - .../tests/regress/fragment-shader/frag-min.sh | 10 - .../tests/regress/fragment-shader/frag-mov.sh | 8 - .../tests/regress/fragment-shader/frag-mul.sh | 10 - .../tests/regress/fragment-shader/frag-rcp.sh | 15 - .../tests/regress/fragment-shader/frag-rsq.sh | 15 - .../tests/regress/fragment-shader/frag-sge.sh | 13 - .../tests/regress/fragment-shader/frag-slt.sh | 13 - .../fragment-shader/frag-srcmod-abs.sh | 13 - .../fragment-shader/frag-srcmod-absneg.sh | 15 - .../fragment-shader/frag-srcmod-neg.sh | 11 - .../fragment-shader/frag-srcmod-swz.sh | 8 - .../tests/regress/fragment-shader/frag-sub.sh | 8 - .../tests/regress/fragment-shader/frag-xpd.sh | 8 - .../fragment-shader/fragment-shader.py | 257 ------- .../tests/regress/vertex-shader/.gitignore | 1 - .../regress/vertex-shader/vertex-shader.py | 287 ------- .../tests/python/tests/texture_render.py | 320 -------- src/gallium/tests/python/tests/tree.py | 23 - src/gallium/tests/trivial/.gitignore | 3 - src/gallium/tests/trivial/Makefile | 44 -- src/gallium/tests/unit/Makefile | 47 -- src/gallium/tests/unit/SConscript | 25 - src/gallium/tests/unit/pipe_barrier_test.c | 86 --- src/gallium/tests/unit/u_cache_test.c | 121 --- src/gallium/tests/unit/u_format_test.c | 708 ------------------ src/gallium/tests/unit/u_half_test.c | 32 - 60 files changed, 208 insertions(+), 3993 deletions(-) delete mode 100644 src/gallium/tests/python/retrace/README delete mode 100755 src/gallium/tests/python/retrace/format.py delete mode 100755 src/gallium/tests/python/retrace/model.py delete mode 100755 src/gallium/tests/python/retrace/parse.py delete mode 100755 src/gallium/tests/python/retrace/parser.py delete mode 100644 src/gallium/tests/python/samples/gs.py delete mode 100644 src/gallium/tests/python/samples/tri.py delete mode 100644 src/gallium/tests/python/tests/.gitignore delete mode 100755 src/gallium/tests/python/tests/base.py delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/.gitignore delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-abs.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-add.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-cb-1d.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-dp3.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-dp4.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-dst.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-ex2.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-flr.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-frc.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-lg2.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-lit.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-lrp.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-mad.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-max.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-min.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-mov.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-mul.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-rcp.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-rsq.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-sge.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-slt.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-abs.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-neg.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-swz.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-sub.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/frag-xpd.sh delete mode 100644 src/gallium/tests/python/tests/regress/fragment-shader/fragment-shader.py delete mode 100644 src/gallium/tests/python/tests/regress/vertex-shader/.gitignore delete mode 100644 src/gallium/tests/python/tests/regress/vertex-shader/vertex-shader.py delete mode 100755 src/gallium/tests/python/tests/texture_render.py delete mode 100755 src/gallium/tests/python/tests/tree.py delete mode 100644 src/gallium/tests/trivial/.gitignore delete mode 100644 src/gallium/tests/trivial/Makefile delete mode 100644 src/gallium/tests/unit/Makefile delete mode 100644 src/gallium/tests/unit/SConscript delete mode 100644 src/gallium/tests/unit/pipe_barrier_test.c delete mode 100644 src/gallium/tests/unit/u_cache_test.c delete mode 100644 src/gallium/tests/unit/u_format_test.c delete mode 100644 src/gallium/tests/unit/u_half_test.c diff --git a/configs/autoconf.in b/configs/autoconf.in index 3ef385a8a66..9abf1618024 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -138,6 +138,9 @@ DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@ # EGL driver install directory EGL_DRIVER_INSTALL_DIR = @EGL_DRIVER_INSTALL_DIR@ +# VDPAU library install directory +VDPAU_LIB_INSTALL_DIR=@VDPAU_LIB_INSTALL_DIR@ + # Xorg driver install directory (for xorg state-tracker) XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@ diff --git a/configs/linux-dri b/configs/linux-dri index 49e35790463..eca321bc6ac 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -58,12 +58,11 @@ PROGRAM_DIRS := egl/eglut egl/opengl $(PROGRAM_DIRS) EGL_DRIVERS_DIRS = glx DRIVER_DIRS = dri -GALLIUM_WINSYS_DIRS = sw sw/xlib drm/vmware drm/intel drm/i965 +GALLIUM_WINSYS_DIRS = sw sw/xlib GALLIUM_TARGET_DIRS = egl-swrast -GALLIUM_STATE_TRACKERS_DIRS = egl +GALLIUM_STATE_TRACKERS_DIRS = egl vdpau -DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \ - savage sis tdfx unichrome swrast +DRI_DIRS = r300 radeon swrast INTEL_LIBS = `pkg-config --libs libdrm_intel` INTEL_CFLAGS = `pkg-config --cflags libdrm_intel` diff --git a/configs/linux-dri-x86-64 b/configs/linux-dri-x86-64 index 656cf6140d7..90e6c215adb 100644 --- a/configs/linux-dri-x86-64 +++ b/configs/linux-dri-x86-64 @@ -20,5 +20,5 @@ EXTRA_LIB_PATH=-L/usr/X11R6/lib64 # the new interface. i810 are missing because there is no x86-64 # system where they could *ever* be used. # -DRI_DIRS = i915 i965 mach64 mga r128 r200 r300 radeon savage tdfx unichrome +DRI_DIRS = swrast diff --git a/configure.ac b/configure.ac index 757bc1e8e78..c5b2d670456 100644 --- a/configure.ac +++ b/configure.ac @@ -1255,13 +1255,20 @@ yes) # mesa/es is required to build es state tracker CORE_DIRS="$CORE_DIRS mesa/es" ;; - xorg/xvmc) - # Check for libXvMC? + xorg/xvmc) + # Check for xvmc? if test "x$enable_gallium_g3dvl" != xyes; then AC_MSG_ERROR([cannot build XvMC state tracker without --enable-gallium-g3dvl]) fi HAVE_ST_XVMC="yes" ;; + vdpau) + # Check for libvdpau? + if test "x$enable_gallium_g3dvl" != xyes; then + AC_MSG_ERROR([cannot build vdpau state tracker without --enable-gallium-g3dvl]) + fi + HAVE_ST_VDPAU="yes" + ;; esac done GALLIUM_STATE_TRACKERS_DIRS="$state_trackers" @@ -1365,7 +1372,7 @@ dnl dnl Gallium helper functions dnl gallium_check_st() { - if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_EGL" = xyes || test "x$HAVE_ST_XORG" = xyes || test "x$HAVE_ST_XVMC" = xyes; then + if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_EGL" = xyes || test "x$HAVE_ST_XORG" = xyes || test "x$HAVE_ST_XVMC" = xyes || test "x$HAVE_ST_VDPAU" = xyes; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1" fi if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then @@ -1380,6 +1387,9 @@ gallium_check_st() { if test "x$HAVE_ST_XVMC" = xyes && test "x$5" != x; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $5" fi + if test "x$HAVE_ST_VDPAU" = xyes && test "x$6" != x; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $6" + fi } @@ -1454,13 +1464,20 @@ AC_ARG_ENABLE([gallium-g3dvl], if test "x$enable_gallium_g3dvl" = xyes; then case "$mesa_driver" in xlib) - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xvmc-softpipe" + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS vdpau-softpipe" ;; dri) GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS g3dvl/dri" ;; esac fi +dnl Directory for VDPAU libs +AC_ARG_WITH([vdpau-libdir], + [AS_HELP_STRING([--with-vdpau-libdir=DIR], + [directory for the VDPAU libraries @<:@default=${libdir}/vdpau@:>@])], + [VDPAU_LIB_INSTALL_DIR="$withval"], + [VDPAU_LIB_INSTALL_DIR='${libdir}/vdpau']) +AC_SUBST([VDPAU_LIB_INSTALL_DIR]) dnl dnl Gallium swrast configuration diff --git a/src/gallium/state_trackers/vdpau/Makefile b/src/gallium/state_trackers/vdpau/Makefile index 346cce9d43b..53378a9c1ff 100644 --- a/src/gallium/state_trackers/vdpau/Makefile +++ b/src/gallium/state_trackers/vdpau/Makefile @@ -3,6 +3,10 @@ include $(TOP)/configs/current LIBNAME = vdpautracker +VDPAU_MAJOR = 1 +VDPAU_MINOR = 0 +LIBRARY_DEFINES = -DVER_MAJOR=$(VDPAU_MAJOR) -DVER_MINOR=$(VDPAU_MINOR) $(STATE_TRACKER_DEFINES) + LIBRARY_INCLUDES = \ $(shell pkg-config --cflags-only-I vdpau) \ -I$(TOP)/src/gallium/winsys/g3dvl @@ -10,6 +14,9 @@ LIBRARY_INCLUDES = \ C_SOURCES = htab.c \ ftab.c \ device.c \ - query.c + query.c \ + surface.c + include ../../Makefile.template + diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c index 83fcaff0282..ba91e16a43f 100644 --- a/src/gallium/state_trackers/vdpau/device.c +++ b/src/gallium/state_trackers/vdpau/device.c @@ -37,7 +37,8 @@ PUBLIC VdpStatus vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGetProcAddress **get_proc_address) { VdpStatus ret; - vlVdpDevice *dev; + vlVdpDevice *dev = NULL; + struct vl_screen *vlscreen = NULL; if (!(display && device && get_proc_address)) return VDP_STATUS_INVALID_POINTER; @@ -47,11 +48,14 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGe goto no_htab; } - dev = CALLOC(1, sizeof(vlVdpDevice)); + dev = CALLOC(0, sizeof(vlVdpDevice)); if (!dev) { ret = VDP_STATUS_RESOURCES; goto no_dev; } + dev->display = display; + dev->screen = screen; + *device = vlAddDataHTAB(dev); if (*device == 0) { diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c index a8a29857df7..7e476e5ee28 100644 --- a/src/gallium/state_trackers/vdpau/ftab.c +++ b/src/gallium/state_trackers/vdpau/ftab.c @@ -39,7 +39,7 @@ static void* ftab[67] = 0, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */ &vlVdpVideoSurfaceQueryCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES */ &vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES */ - 0, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */ + &vlVdpVideoSurfaceCreate, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */ 0, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */ 0, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */ 0, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */ diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c index 57bd7fb7526..71793cc8ad5 100644 --- a/src/gallium/state_trackers/vdpau/query.c +++ b/src/gallium/state_trackers/vdpau/query.c @@ -26,6 +26,11 @@ **************************************************************************/ #include "vdpau_private.h" +#include +#include +#include +#include + VdpStatus vlVdpGetApiVersion(uint32_t *api_version) @@ -43,7 +48,7 @@ vlVdpGetInformationString(char const **information_string) if (!information_string) return VDP_STATUS_INVALID_POINTER; - *information_string = "VDPAU-G3DVL"; + *information_string = INFORMATION_STRING; return VDP_STATUS_OK; } @@ -51,10 +56,40 @@ VdpStatus vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type, VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) { + uint32_t max_2d_texture_level; + VdpStatus ret; + if (!(is_supported && max_width && max_height)) return VDP_STATUS_INVALID_POINTER; - return VDP_STATUS_NO_IMPLEMENTATION; + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) + return VDP_STATUS_INVALID_HANDLE; + + if (!dev->vlscreen) + dev->vlscreen = vl_screen_create(dev->display, dev->screen); + if (!dev->vlscreen) + return VDP_STATUS_RESOURCES; + + /* XXX: Current limits */ + *is_supported = true; + if (surface_chroma_type != VDP_CHROMA_TYPE_420) { + *is_supported = false; + goto no_sup; + } + + max_2d_texture_level = dev->vlscreen->pscreen->get_param( dev->vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS ); + if (!max_2d_texture_level) { + ret = VDP_STATUS_RESOURCES; + goto no_sup; + } + + /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */ + *max_width = *max_height = pow(2,max_2d_texture_level-1); + + return VDP_STATUS_OK; + no_sup: + return ret; } VdpStatus @@ -65,7 +100,23 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp if (!is_supported) return VDP_STATUS_INVALID_POINTER; - return VDP_STATUS_NO_IMPLEMENTATION; + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) + return VDP_STATUS_INVALID_HANDLE; + + if (!dev->vlscreen) + dev->vlscreen = vl_screen_create(dev->display, dev->screen); + if (!dev->vlscreen) + return VDP_STATUS_RESOURCES; + + if (bits_ycbcr_format != VDP_YCBCR_FORMAT_Y8U8V8A8) + *is_supported = dev->vlscreen->pscreen->is_format_supported(dev->vlscreen->pscreen, + FormatToPipe(bits_ycbcr_format), + PIPE_TEXTURE_2D, + PIPE_BIND_RENDER_TARGET, + PIPE_TEXTURE_GEOM_NON_SQUARE ); + + return VDP_STATUS_OK; } VdpStatus diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index 8f54ae657ce..27793892185 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -25,14 +25,112 @@ * **************************************************************************/ +#ifndef VDPAU_PRIVATE_H +#define VDPAU_PRIVATE_H + + #include #include +#include +#include + +#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR +#define QUOTEME(x) #x +#define TOSTRING(x) QUOTEME(x) +#define INFORMATION_STRING TOSTRING(INFORMATION) +#define VL_HANDLES + +static enum pipe_video_chroma_format TypeToPipe(VdpChromaType vdpau_type) +{ + switch (vdpau_type) { + case VDP_CHROMA_TYPE_420: + return PIPE_VIDEO_CHROMA_FORMAT_420; + case VDP_CHROMA_TYPE_422: + return PIPE_VIDEO_CHROMA_FORMAT_422; + case VDP_CHROMA_TYPE_444: + return PIPE_VIDEO_CHROMA_FORMAT_444; + default: + assert(0); + } + + return -1; +} + +static VdpChromaType PipeToType(enum pipe_video_chroma_format pipe_type) +{ + switch (pipe_type) { + case PIPE_VIDEO_CHROMA_FORMAT_420: + return VDP_CHROMA_TYPE_420; + case PIPE_VIDEO_CHROMA_FORMAT_422: + return VDP_CHROMA_TYPE_422; + case PIPE_VIDEO_CHROMA_FORMAT_444: + return VDP_CHROMA_TYPE_444; + default: + assert(0); + } + + return -1; +} + +static enum pipe_format FormatToPipe(VdpYCbCrFormat vdpau_format) +{ + switch (vdpau_format) { + case VDP_YCBCR_FORMAT_NV12: + return PIPE_FORMAT_NV12; + case VDP_YCBCR_FORMAT_YV12: + return PIPE_FORMAT_YV12; + case VDP_YCBCR_FORMAT_UYVY: + return PIPE_FORMAT_UYVY; + case VDP_YCBCR_FORMAT_YUYV: + return PIPE_FORMAT_YUYV; + case VDP_YCBCR_FORMAT_Y8U8V8A8: /* Not defined in p_format.h */ + return 0; + case VDP_YCBCR_FORMAT_V8U8Y8A8: + return PIPE_FORMAT_VUYA; + default: + assert(0); + } + + return -1; +} + +static VdpYCbCrFormat PipeToFormat(enum pipe_format p_format) +{ + switch (p_format) { + case PIPE_FORMAT_NV12: + return VDP_YCBCR_FORMAT_NV12; + case PIPE_FORMAT_YV12: + return VDP_YCBCR_FORMAT_YV12; + case PIPE_FORMAT_UYVY: + return VDP_YCBCR_FORMAT_UYVY; + case PIPE_FORMAT_YUYV: + return VDP_YCBCR_FORMAT_YUYV; + //case PIPE_FORMAT_YUVA: + // return VDP_YCBCR_FORMAT_Y8U8V8A8; + case PIPE_FORMAT_VUYA: + return VDP_YCBCR_FORMAT_V8U8Y8A8; + default: + assert(0); + } + + return -1; +} typedef struct { - int dummy; + void *display; + int screen; + struct vl_screen *vlscreen; + struct vl_context *vctx; } vlVdpDevice; +typedef struct +{ + struct vl_screen *vlscreen; + struct pipe_surface *psurface; + enum pipe_video_chroma_format chroma_format; +} vlVdpSurface; + typedef uint32_t vlHandle; boolean vlCreateHTAB(void); @@ -57,3 +155,10 @@ VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport; VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange; VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport; VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange; +VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate; +VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy; +VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters; +VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr; +VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr; + +#endif // VDPAU_PRIVATE_H \ No newline at end of file diff --git a/src/gallium/targets/Makefile.vdpau b/src/gallium/targets/Makefile.vdpau index e5c3dad7dad..2accbeb702e 100644 --- a/src/gallium/targets/Makefile.vdpau +++ b/src/gallium/targets/Makefile.vdpau @@ -2,6 +2,7 @@ LIBBASENAME = vdpau_g3dvl LIBNAME = lib$(LIBBASENAME).so +VDPAU_LIB_GLOB=lib$(LIBBASENAME).*so* VDPAU_MAJOR = 1 VDPAU_MINOR = 0 INCLUDES = -I$(TOP)/src/gallium/include \ @@ -9,7 +10,7 @@ INCLUDES = -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ -I$(TOP)/src/gallium/winsys/g3dvl \ $(DRIVER_INCLUDES) -DEFINES = -DGALLIUM_TRACE $(DRIVER_DEFINES) +DEFINES = -DGALLIUM_TRACE -DVER_MAJOR=$(VDPAU_MAJOR) -DVER_MINOR=$(VDPAU_MINOR) $(DRIVER_DEFINES) LIBS = $(EXTRA_LIB_PATH) $(DRIVER_LIBS) -lvdpau -lXext -lX11 -lm STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/vdpau/libvdpautracker.a @@ -54,8 +55,8 @@ clean: -rm -f *.o *~ *.so $(SYMLINKS) -rm -f depend depend.bak -#install: $(LIBNAME) -# $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) -# $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) +install: default + $(INSTALL) -d $(DESTDIR)$(VDPAU_LIB_INSTALL_DIR) + $(MINSTALL) -m 755 $(TOP)/$(LIB_DIR)/gallium/$(VDPAU_LIB_GLOB) $(DESTDIR)$(VDPAU_LIB_INSTALL_DIR) include depend diff --git a/src/gallium/tests/python/retrace/README b/src/gallium/tests/python/retrace/README deleted file mode 100644 index 822cd114044..00000000000 --- a/src/gallium/tests/python/retrace/README +++ /dev/null @@ -1,17 +0,0 @@ -This is an application written in python to replay the traces captured by the - trace pipe driver. - - -To use it follow the instructions in src/gallium/drivers/trace/README and -src/gallium/state_trackers/python/README, and then do - - python src/gallium/state_trackers/python/samples/retrace/interpreter.py filename.trace - - -This is still work in progress: -- not everything is captured/replayed - - surface/textures contents -- any tiny error will result in a crash - --- -Jose Fonseca diff --git a/src/gallium/tests/python/retrace/format.py b/src/gallium/tests/python/retrace/format.py deleted file mode 100755 index a4285bfe075..00000000000 --- a/src/gallium/tests/python/retrace/format.py +++ /dev/null @@ -1,173 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -import sys - - -class Formatter: - '''Plain formatter''' - - def __init__(self, stream): - self.stream = stream - - def text(self, text): - self.stream.write(text) - - def newline(self): - self.text('\n') - - def function(self, name): - self.text(name) - - def variable(self, name): - self.text(name) - - def literal(self, value): - self.text(str(value)) - - def address(self, addr): - self.text(str(addr)) - - -class AnsiFormatter(Formatter): - '''Formatter for plain-text files which outputs ANSI escape codes. See - http://en.wikipedia.org/wiki/ANSI_escape_code for more information - concerning ANSI escape codes. - ''' - - _csi = '\33[' - - _normal = '0m' - _bold = '1m' - _italic = '3m' - _red = '31m' - _green = '32m' - _blue = '34m' - - def _escape(self, code): - self.text(self._csi + code) - - def function(self, name): - self._escape(self._bold) - Formatter.function(self, name) - self._escape(self._normal) - - def variable(self, name): - self._escape(self._italic) - Formatter.variable(self, name) - self._escape(self._normal) - - def literal(self, value): - self._escape(self._blue) - Formatter.literal(self, value) - self._escape(self._normal) - - def address(self, value): - self._escape(self._green) - Formatter.address(self, value) - self._escape(self._normal) - - -class WindowsConsoleFormatter(Formatter): - '''Formatter for the Windows Console. See - http://code.activestate.com/recipes/496901/ for more information. - ''' - - STD_INPUT_HANDLE = -10 - STD_OUTPUT_HANDLE = -11 - STD_ERROR_HANDLE = -12 - - FOREGROUND_BLUE = 0x01 - FOREGROUND_GREEN = 0x02 - FOREGROUND_RED = 0x04 - FOREGROUND_INTENSITY = 0x08 - BACKGROUND_BLUE = 0x10 - BACKGROUND_GREEN = 0x20 - BACKGROUND_RED = 0x40 - BACKGROUND_INTENSITY = 0x80 - - _normal = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED - _bold = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY - _italic = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED - _red = FOREGROUND_RED | FOREGROUND_INTENSITY - _green = FOREGROUND_GREEN | FOREGROUND_INTENSITY - _blue = FOREGROUND_BLUE | FOREGROUND_INTENSITY - - def __init__(self, stream): - Formatter.__init__(self, stream) - - if stream is sys.stdin: - nStdHandle = self.STD_INPUT_HANDLE - elif stream is sys.stdout: - nStdHandle = self.STD_OUTPUT_HANDLE - elif stream is sys.stderr: - nStdHandle = self.STD_ERROR_HANDLE - else: - nStdHandle = None - - if nStdHandle: - import ctypes - self.handle = ctypes.windll.kernel32.GetStdHandle(nStdHandle) - else: - self.handle = None - - def _attribute(self, attr): - if self.handle: - import ctypes - ctypes.windll.kernel32.SetConsoleTextAttribute(self.handle, attr) - - def function(self, name): - self._attribute(self._bold) - Formatter.function(self, name) - self._attribute(self._normal) - - def variable(self, name): - self._attribute(self._italic) - Formatter.variable(self, name) - self._attribute(self._normal) - - def literal(self, value): - self._attribute(self._blue) - Formatter.literal(self, value) - self._attribute(self._normal) - - def address(self, value): - self._attribute(self._green) - Formatter.address(self, value) - self._attribute(self._normal) - - -def DefaultFormatter(stream): - if sys.platform in ('linux2', 'cygwin'): - return AnsiFormatter(stream) - elif sys.platform in ('win32',): - return WindowsConsoleFormatter(stream) - else: - return Formatter(stream) - diff --git a/src/gallium/tests/python/retrace/model.py b/src/gallium/tests/python/retrace/model.py deleted file mode 100755 index d4a079fb1e5..00000000000 --- a/src/gallium/tests/python/retrace/model.py +++ /dev/null @@ -1,213 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -'''Trace data model.''' - - -import sys -import string -import format - -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO - - -class Node: - - def visit(self, visitor): - raise NotImplementedError - - def __str__(self): - stream = StringIO() - formatter = format.DefaultFormatter(stream) - pretty_printer = PrettyPrinter(formatter) - self.visit(pretty_printer) - return stream.getvalue() - - -class Literal(Node): - - def __init__(self, value): - self.value = value - - def visit(self, visitor): - visitor.visit_literal(self) - - -class NamedConstant(Node): - - def __init__(self, name): - self.name = name - - def visit(self, visitor): - visitor.visit_named_constant(self) - - -class Array(Node): - - def __init__(self, elements): - self.elements = elements - - def visit(self, visitor): - visitor.visit_array(self) - - -class Struct(Node): - - def __init__(self, name, members): - self.name = name - self.members = members - - def visit(self, visitor): - visitor.visit_struct(self) - - -class Pointer(Node): - - def __init__(self, address): - self.address = address - - def visit(self, visitor): - visitor.visit_pointer(self) - - -class Call: - - def __init__(self, no, klass, method, args, ret): - self.no = no - self.klass = klass - self.method = method - self.args = args - self.ret = ret - - def visit(self, visitor): - visitor.visit_call(self) - - -class Trace: - - def __init__(self, calls): - self.calls = calls - - def visit(self, visitor): - visitor.visit_trace(self) - - -class Visitor: - - def visit_literal(self, node): - raise NotImplementedError - - def visit_named_constant(self, node): - raise NotImplementedError - - def visit_array(self, node): - raise NotImplementedError - - def visit_struct(self, node): - raise NotImplementedError - - def visit_pointer(self, node): - raise NotImplementedError - - def visit_call(self, node): - raise NotImplementedError - - def visit_trace(self, node): - raise NotImplementedError - - -class PrettyPrinter: - - def __init__(self, formatter): - self.formatter = formatter - - def visit_literal(self, node): - if isinstance(node.value, basestring): - if len(node.value) >= 4096 or node.value.strip(string.printable): - self.formatter.text('...') - return - - self.formatter.literal('"' + node.value + '"') - return - - self.formatter.literal(repr(node.value)) - - def visit_named_constant(self, node): - self.formatter.literal(node.name) - - def visit_array(self, node): - self.formatter.text('{') - sep = '' - for value in node.elements: - self.formatter.text(sep) - value.visit(self) - sep = ', ' - self.formatter.text('}') - - def visit_struct(self, node): - self.formatter.text('{') - sep = '' - for name, value in node.members: - self.formatter.text(sep) - self.formatter.variable(name) - self.formatter.text(' = ') - value.visit(self) - sep = ', ' - self.formatter.text('}') - - def visit_pointer(self, node): - self.formatter.address(node.address) - - def visit_call(self, node): - self.formatter.text('%s ' % node.no) - if node.klass is not None: - self.formatter.function(node.klass + '::' + node.method) - else: - self.formatter.function(node.method) - self.formatter.text('(') - sep = '' - for name, value in node.args: - self.formatter.text(sep) - self.formatter.variable(name) - self.formatter.text(' = ') - value.visit(self) - sep = ', ' - self.formatter.text(')') - if node.ret is not None: - self.formatter.text(' = ') - node.ret.visit(self) - - def visit_trace(self, node): - for call in node.calls: - call.visit(self) - self.formatter.newline() - diff --git a/src/gallium/tests/python/retrace/parse.py b/src/gallium/tests/python/retrace/parse.py deleted file mode 100755 index b08d3686715..00000000000 --- a/src/gallium/tests/python/retrace/parse.py +++ /dev/null @@ -1,392 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -import sys -import xml.parsers.expat -import binascii -import optparse - -from model import * - - -ELEMENT_START, ELEMENT_END, CHARACTER_DATA, EOF = range(4) - - -class XmlToken: - - def __init__(self, type, name_or_data, attrs = None, line = None, column = None): - assert type in (ELEMENT_START, ELEMENT_END, CHARACTER_DATA, EOF) - self.type = type - self.name_or_data = name_or_data - self.attrs = attrs - self.line = line - self.column = column - - def __str__(self): - if self.type == ELEMENT_START: - return '<' + self.name_or_data + ' ...>' - if self.type == ELEMENT_END: - return '' - if self.type == CHARACTER_DATA: - return self.name_or_data - if self.type == EOF: - return 'end of file' - assert 0 - - -class XmlTokenizer: - """Expat based XML tokenizer.""" - - def __init__(self, fp, skip_ws = True): - self.fp = fp - self.tokens = [] - self.index = 0 - self.final = False - self.skip_ws = skip_ws - - self.character_pos = 0, 0 - self.character_data = '' - - self.parser = xml.parsers.expat.ParserCreate() - self.parser.StartElementHandler = self.handle_element_start - self.parser.EndElementHandler = self.handle_element_end - self.parser.CharacterDataHandler = self.handle_character_data - - def handle_element_start(self, name, attributes): - self.finish_character_data() - line, column = self.pos() - token = XmlToken(ELEMENT_START, name, attributes, line, column) - self.tokens.append(token) - - def handle_element_end(self, name): - self.finish_character_data() - line, column = self.pos() - token = XmlToken(ELEMENT_END, name, None, line, column) - self.tokens.append(token) - - def handle_character_data(self, data): - if not self.character_data: - self.character_pos = self.pos() - self.character_data += data - - def finish_character_data(self): - if self.character_data: - if not self.skip_ws or not self.character_data.isspace(): - line, column = self.character_pos - token = XmlToken(CHARACTER_DATA, self.character_data, None, line, column) - self.tokens.append(token) - self.character_data = '' - - def next(self): - size = 16*1024 - while self.index >= len(self.tokens) and not self.final: - self.tokens = [] - self.index = 0 - data = self.fp.read(size) - self.final = len(data) < size - data = data.rstrip('\0') - try: - self.parser.Parse(data, self.final) - except xml.parsers.expat.ExpatError, e: - #if e.code == xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS: - if e.code == 3: - pass - else: - raise e - if self.index >= len(self.tokens): - line, column = self.pos() - token = XmlToken(EOF, None, None, line, column) - else: - token = self.tokens[self.index] - self.index += 1 - return token - - def pos(self): - return self.parser.CurrentLineNumber, self.parser.CurrentColumnNumber - - -class TokenMismatch(Exception): - - def __init__(self, expected, found): - self.expected = expected - self.found = found - - def __str__(self): - return '%u:%u: %s expected, %s found' % (self.found.line, self.found.column, str(self.expected), str(self.found)) - - - -class XmlParser: - """Base XML document parser.""" - - def __init__(self, fp): - self.tokenizer = XmlTokenizer(fp) - self.consume() - - def consume(self): - self.token = self.tokenizer.next() - - def match_element_start(self, name): - return self.token.type == ELEMENT_START and self.token.name_or_data == name - - def match_element_end(self, name): - return self.token.type == ELEMENT_END and self.token.name_or_data == name - - def element_start(self, name): - while self.token.type == CHARACTER_DATA: - self.consume() - if self.token.type != ELEMENT_START: - raise TokenMismatch(XmlToken(ELEMENT_START, name), self.token) - if self.token.name_or_data != name: - raise TokenMismatch(XmlToken(ELEMENT_START, name), self.token) - attrs = self.token.attrs - self.consume() - return attrs - - def element_end(self, name): - while self.token.type == CHARACTER_DATA: - self.consume() - if self.token.type != ELEMENT_END: - raise TokenMismatch(XmlToken(ELEMENT_END, name), self.token) - if self.token.name_or_data != name: - raise TokenMismatch(XmlToken(ELEMENT_END, name), self.token) - self.consume() - - def character_data(self, strip = True): - data = '' - while self.token.type == CHARACTER_DATA: - data += self.token.name_or_data - self.consume() - if strip: - data = data.strip() - return data - - -class TraceParser(XmlParser): - - def __init__(self, fp): - XmlParser.__init__(self, fp) - self.last_call_no = 0 - - def parse(self): - self.element_start('trace') - while self.token.type not in (ELEMENT_END, EOF): - call = self.parse_call() - self.handle_call(call) - if self.token.type != EOF: - self.element_end('trace') - - def parse_call(self): - attrs = self.element_start('call') - try: - no = int(attrs['no']) - except KeyError: - self.last_call_no += 1 - no = self.last_call_no - else: - self.last_call_no = no - klass = attrs['class'] - method = attrs['method'] - args = [] - ret = None - while self.token.type == ELEMENT_START: - if self.token.name_or_data == 'arg': - arg = self.parse_arg() - args.append(arg) - elif self.token.name_or_data == 'ret': - ret = self.parse_ret() - elif self.token.name_or_data == 'call': - # ignore nested function calls - self.parse_call() - else: - raise TokenMismatch(" or ", self.token) - self.element_end('call') - - return Call(no, klass, method, args, ret) - - def parse_arg(self): - attrs = self.element_start('arg') - name = attrs['name'] - value = self.parse_value() - self.element_end('arg') - - return name, value - - def parse_ret(self): - attrs = self.element_start('ret') - value = self.parse_value() - self.element_end('ret') - - return value - - def parse_value(self): - expected_tokens = ('null', 'bool', 'int', 'uint', 'float', 'string', 'enum', 'array', 'struct', 'ptr', 'bytes') - if self.token.type == ELEMENT_START: - if self.token.name_or_data in expected_tokens: - method = getattr(self, 'parse_' + self.token.name_or_data) - return method() - raise TokenMismatch(" or " .join(expected_tokens), self.token) - - def parse_null(self): - self.element_start('null') - self.element_end('null') - return Literal(None) - - def parse_bool(self): - self.element_start('bool') - value = int(self.character_data()) - self.element_end('bool') - return Literal(value) - - def parse_int(self): - self.element_start('int') - value = int(self.character_data()) - self.element_end('int') - return Literal(value) - - def parse_uint(self): - self.element_start('uint') - value = int(self.character_data()) - self.element_end('uint') - return Literal(value) - - def parse_float(self): - self.element_start('float') - value = float(self.character_data()) - self.element_end('float') - return Literal(value) - - def parse_enum(self): - self.element_start('enum') - name = self.character_data() - self.element_end('enum') - return NamedConstant(name) - - def parse_string(self): - self.element_start('string') - value = self.character_data() - self.element_end('string') - return Literal(value) - - def parse_bytes(self): - self.element_start('bytes') - value = binascii.a2b_hex(self.character_data()) - self.element_end('bytes') - return Literal(value) - - def parse_array(self): - self.element_start('array') - elems = [] - while self.token.type != ELEMENT_END: - elems.append(self.parse_elem()) - self.element_end('array') - return Array(elems) - - def parse_elem(self): - self.element_start('elem') - value = self.parse_value() - self.element_end('elem') - return value - - def parse_struct(self): - attrs = self.element_start('struct') - name = attrs['name'] - members = [] - while self.token.type != ELEMENT_END: - members.append(self.parse_member()) - self.element_end('struct') - return Struct(name, members) - - def parse_member(self): - attrs = self.element_start('member') - name = attrs['name'] - value = self.parse_value() - self.element_end('member') - - return name, value - - def parse_ptr(self): - self.element_start('ptr') - address = self.character_data() - self.element_end('ptr') - - return Pointer(address) - - def handle_call(self, call): - pass - - -class TraceDumper(TraceParser): - - def __init__(self, fp): - TraceParser.__init__(self, fp) - self.formatter = format.DefaultFormatter(sys.stdout) - self.pretty_printer = PrettyPrinter(self.formatter) - - def handle_call(self, call): - call.visit(self.pretty_printer) - self.formatter.newline() - - -class Main: - '''Common main class for all retrace command line utilities.''' - - def __init__(self): - pass - - def main(self): - optparser = self.get_optparser() - (options, args) = optparser.parse_args(sys.argv[1:]) - - if args: - for arg in args: - if arg.endswith('.gz'): - from gzip import GzipFile - stream = GzipFile(arg, 'rt') - elif arg.endswith('.bz2'): - from bz2 import BZ2File - stream = BZ2File(arg, 'rU') - else: - stream = open(arg, 'rt') - self.process_arg(stream, options) - else: - self.process_arg(stream, options) - - def get_optparser(self): - optparser = optparse.OptionParser( - usage="\n\t%prog [options] [traces] ...") - return optparser - - def process_arg(self, stream, options): - parser = TraceDumper(stream) - parser.parse() - - -if __name__ == '__main__': - Main().main() diff --git a/src/gallium/tests/python/retrace/parser.py b/src/gallium/tests/python/retrace/parser.py deleted file mode 100755 index bd47c9a6b06..00000000000 --- a/src/gallium/tests/python/retrace/parser.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -from parse import * - - -if __name__ == '__main__': - Main().main() diff --git a/src/gallium/tests/python/samples/gs.py b/src/gallium/tests/python/samples/gs.py deleted file mode 100644 index 936c0b3f33a..00000000000 --- a/src/gallium/tests/python/samples/gs.py +++ /dev/null @@ -1,254 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -from gallium import * - - -def make_image(surface): - data = surface.get_tile_rgba8(0, 0, surface.width, surface.height) - - import Image - outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) - return outimage - -def save_image(filename, surface): - outimage = make_image(surface) - outimage.save(filename, "PNG") - -def show_image(surface): - outimage = make_image(surface) - - import Tkinter as tk - from PIL import Image, ImageTk - root = tk.Tk() - - root.title('background image') - - image1 = ImageTk.PhotoImage(outimage) - w = image1.width() - h = image1.height() - x = 100 - y = 100 - root.geometry("%dx%d+%d+%d" % (w, h, x, y)) - panel1 = tk.Label(root, image=image1) - panel1.pack(side='top', fill='both', expand='yes') - panel1.image = image1 - root.mainloop() - - -def test(dev): - ctx = dev.context_create() - - width = 255 - height = 255 - minz = 0.0 - maxz = 1.0 - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - depth_stencil_alpha.depth.enabled = 1 - depth_stencil_alpha.depth.writemask = 1 - depth_stencil_alpha.depth.func = PIPE_FUNC_LESS - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.scissor = 1 - ctx.set_rasterizer(rasterizer) - - # viewport - viewport = Viewport() - scale = FloatArray(4) - scale[0] = width / 2.0 - scale[1] = -height / 2.0 - scale[2] = (maxz - minz) / 2.0 - scale[3] = 1.0 - viewport.scale = scale - translate = FloatArray(4) - translate[0] = width / 2.0 - translate[1] = height / 2.0 - translate[2] = (maxz - minz) / 2.0 - translate[3] = 0.0 - viewport.translate = translate - ctx.set_viewport(viewport) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - ctx.set_sampler(0, sampler) - - # scissor - scissor = Scissor() - scissor.minx = 0 - scissor.miny = 0 - scissor.maxx = width - scissor.maxy = height - ctx.set_scissor(scissor) - - clip = Clip() - clip.nr = 0 - ctx.set_clip(clip) - - # framebuffer - cbuf = dev.resource_create( - PIPE_FORMAT_B8G8R8X8_UNORM, - width, height, - bind=PIPE_BIND_RENDER_TARGET, - ).get_surface() - zbuf = dev.resource_create( - PIPE_FORMAT_Z32_UNORM, - width, height, - bind=PIPE_BIND_DEPTH_STENCIL, - ).get_surface() - fb = Framebuffer() - fb.width = width - fb.height = height - fb.nr_cbufs = 1 - fb.set_cbuf(0, cbuf) - fb.set_zsbuf(zbuf) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.0 - rgba[1] = 0.0 - rgba[2] = 0.0 - rgba[3] = 0.0 - ctx.clear(PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL, rgba, 1.0, 0xff) - - # vertex shader - vs = Shader(''' - VERT - DCL IN[0], POSITION, CONSTANT - DCL IN[1], COLOR, CONSTANT - DCL OUT[0], POSITION, CONSTANT - DCL OUT[1], COLOR, CONSTANT - 0:MOV OUT[0], IN[0] - 1:MOV OUT[1], IN[1] - 2:END - ''') - ctx.set_vertex_shader(vs) - - gs = Shader(''' - GEOM - PROPERTY GS_INPUT_PRIMITIVE TRIANGLES - PROPERTY GS_OUTPUT_PRIMITIVE TRIANGLE_STRIP - DCL IN[][0], POSITION, CONSTANT - DCL IN[][1], COLOR, CONSTANT - DCL OUT[0], POSITION, CONSTANT - DCL OUT[1], COLOR, CONSTANT - 0:MOV OUT[0], IN[0][0] - 1:MOV OUT[1], IN[0][1] - 2:EMIT - 3:MOV OUT[0], IN[1][0] - 4:MOV OUT[1], IN[1][1] - 5:EMIT - 6:MOV OUT[0], IN[2][0] - 7:MOV OUT[1], IN[2][1] - 8:EMIT - 9:ENDPRIM - 10:END - ''') - ctx.set_geometry_shader(gs) - - # fragment shader - fs = Shader(''' - FRAG - DCL IN[0], COLOR, LINEAR - DCL OUT[0], COLOR, CONSTANT - 0:MOV OUT[0], IN[0] - 1:END - ''') - ctx.set_fragment_shader(fs) - - nverts = 3 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - verts[ 0] = 0.0 # x1 - verts[ 1] = 0.8 # y1 - verts[ 2] = 0.2 # z1 - verts[ 3] = 1.0 # w1 - verts[ 4] = 1.0 # r1 - verts[ 5] = 0.0 # g1 - verts[ 6] = 0.0 # b1 - verts[ 7] = 1.0 # a1 - verts[ 8] = -0.8 # x2 - verts[ 9] = -0.8 # y2 - verts[10] = 0.5 # z2 - verts[11] = 1.0 # w2 - verts[12] = 0.0 # r2 - verts[13] = 1.0 # g2 - verts[14] = 0.0 # b2 - verts[15] = 1.0 # a2 - verts[16] = 0.8 # x3 - verts[17] = -0.8 # y3 - verts[18] = 0.8 # z3 - verts[19] = 1.0 # w3 - verts[20] = 0.0 # r3 - verts[21] = 0.0 # g3 - verts[22] = 1.0 # b3 - verts[23] = 1.0 # a3 - - ctx.draw_vertices(PIPE_PRIM_TRIANGLES, - nverts, - nattrs, - verts) - - ctx.flush() - - show_image(cbuf) - #show_image(zbuf) - #save_image('cbuf.png', cbuf) - #save_image('zbuf.png', zbuf) - - - -def main(): - dev = Device() - test(dev) - - -if __name__ == '__main__': - main() diff --git a/src/gallium/tests/python/samples/tri.py b/src/gallium/tests/python/samples/tri.py deleted file mode 100644 index fed929d4200..00000000000 --- a/src/gallium/tests/python/samples/tri.py +++ /dev/null @@ -1,233 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -from gallium import * - - -def make_image(ctx, surface): - data = ctx.surface_read_rgba8(surface, 0, 0, surface.width, surface.height) - - import Image - outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) - return outimage - -def save_image(ctx, surface, filename): - outimage = make_image(ctx, surface) - outimage.save(filename, "PNG") - -def show_image(ctx, surface): - outimage = make_image(ctx, surface) - - import Tkinter as tk - from PIL import Image, ImageTk - root = tk.Tk() - - root.title('background image') - - image1 = ImageTk.PhotoImage(outimage) - w = image1.width() - h = image1.height() - x = 100 - y = 100 - root.geometry("%dx%d+%d+%d" % (w, h, x, y)) - panel1 = tk.Label(root, image=image1) - panel1.pack(side='top', fill='both', expand='yes') - panel1.image = image1 - root.mainloop() - - -def test(dev): - ctx = dev.context_create() - - width = 255 - height = 255 - minz = 0.0 - maxz = 1.0 - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - depth_stencil_alpha.depth.enabled = 1 - depth_stencil_alpha.depth.writemask = 1 - depth_stencil_alpha.depth.func = PIPE_FUNC_LESS - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.scissor = 1 - ctx.set_rasterizer(rasterizer) - - # viewport - viewport = Viewport() - scale = FloatArray(4) - scale[0] = width / 2.0 - scale[1] = -height / 2.0 - scale[2] = (maxz - minz) / 2.0 - scale[3] = 1.0 - viewport.scale = scale - translate = FloatArray(4) - translate[0] = width / 2.0 - translate[1] = height / 2.0 - translate[2] = (maxz - minz) / 2.0 - translate[3] = 0.0 - viewport.translate = translate - ctx.set_viewport(viewport) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - ctx.set_fragment_sampler(0, sampler) - - # scissor - scissor = Scissor() - scissor.minx = 0 - scissor.miny = 0 - scissor.maxx = width - scissor.maxy = height - ctx.set_scissor(scissor) - - # clip - clip = Clip() - clip.nr = 0 - ctx.set_clip(clip) - - # framebuffer - cbuf = dev.resource_create( - PIPE_FORMAT_B8G8R8X8_UNORM, - width, height, - bind=PIPE_BIND_RENDER_TARGET, - ).get_surface() - zbuf = dev.resource_create( - PIPE_FORMAT_Z32_UNORM, - width, height, - bind=PIPE_BIND_DEPTH_STENCIL, - ).get_surface() - fb = Framebuffer() - fb.width = width - fb.height = height - fb.nr_cbufs = 1 - fb.set_cbuf(0, cbuf) - fb.set_zsbuf(zbuf) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.0 - rgba[1] = 0.0 - rgba[2] = 0.0 - rgba[3] = 0.0 - ctx.clear(PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL, rgba, 1.0, 0xff) - - # vertex shader - vs = Shader(''' - VERT - DCL IN[0], POSITION, CONSTANT - DCL IN[1], COLOR, CONSTANT - DCL OUT[0], POSITION, CONSTANT - DCL OUT[1], COLOR, CONSTANT - 0:MOV OUT[0], IN[0] - 1:MOV OUT[1], IN[1] - 2:END - ''') - ctx.set_vertex_shader(vs) - - # fragment shader - fs = Shader(''' - FRAG - DCL IN[0], COLOR, LINEAR - DCL OUT[0], COLOR, CONSTANT - 0:MOV OUT[0], IN[0] - 1:END - ''') - ctx.set_fragment_shader(fs) - - nverts = 3 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - verts[ 0] = 0.0 # x1 - verts[ 1] = 0.8 # y1 - verts[ 2] = 0.2 # z1 - verts[ 3] = 1.0 # w1 - verts[ 4] = 1.0 # r1 - verts[ 5] = 0.0 # g1 - verts[ 6] = 0.0 # b1 - verts[ 7] = 1.0 # a1 - verts[ 8] = -0.8 # x2 - verts[ 9] = -0.8 # y2 - verts[10] = 0.5 # z2 - verts[11] = 1.0 # w2 - verts[12] = 0.0 # r2 - verts[13] = 1.0 # g2 - verts[14] = 0.0 # b2 - verts[15] = 1.0 # a2 - verts[16] = 0.8 # x3 - verts[17] = -0.8 # y3 - verts[18] = 0.8 # z3 - verts[19] = 1.0 # w3 - verts[20] = 0.0 # r3 - verts[21] = 0.0 # g3 - verts[22] = 1.0 # b3 - verts[23] = 1.0 # a3 - - ctx.draw_vertices(PIPE_PRIM_TRIANGLES, - nverts, - nattrs, - verts) - - ctx.flush() - - show_image(ctx, cbuf) - show_image(ctx, zbuf) - save_image(ctx, cbuf, 'cbuf.png') - save_image(ctx, zbuf, 'zbuf.png') - - - -def main(): - dev = Device() - test(dev) - - -if __name__ == '__main__': - main() diff --git a/src/gallium/tests/python/tests/.gitignore b/src/gallium/tests/python/tests/.gitignore deleted file mode 100644 index 0dbbaeea16b..00000000000 --- a/src/gallium/tests/python/tests/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.txt -*.tsv -*.dot diff --git a/src/gallium/tests/python/tests/base.py b/src/gallium/tests/python/tests/base.py deleted file mode 100755 index d8cf84db363..00000000000 --- a/src/gallium/tests/python/tests/base.py +++ /dev/null @@ -1,399 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -"""Base classes for tests. - -Loosely inspired on Python's unittest module. -""" - - -import os.path -import sys - -from gallium import * - - -# Enumerate all pixel formats -formats = {} -for name, value in globals().items(): - if name.startswith("PIPE_FORMAT_") and isinstance(value, int) and name not in ("PIPE_FORMAT_NONE", "PIPE_FORMAT_COUNT"): - formats[value] = name - -def make_image(width, height, rgba): - import Image - outimage = Image.new( - mode='RGB', - size=(width, height), - color=(0,0,0)) - outpixels = outimage.load() - for y in range(0, height): - for x in range(0, width): - offset = (y*width + x)*4 - r, g, b, a = [int(min(max(rgba[offset + ch], 0.0), 1.0)*255) for ch in range(4)] - outpixels[x, y] = r, g, b - return outimage - -def save_image(width, height, rgba, filename): - outimage = make_image(width, height, rgba) - outimage.save(filename, "PNG") - -def show_image(width, height, **rgbas): - import Tkinter as tk - from PIL import Image, ImageTk - - root = tk.Tk() - - x = 64 - y = 64 - - labels = rgbas.keys() - labels.sort() - for i in range(len(labels)): - label = labels[i] - outimage = make_image(width, height, rgbas[label]) - - if i: - window = tk.Toplevel(root) - else: - window = root - window.title(label) - image1 = ImageTk.PhotoImage(outimage) - w = image1.width() - h = image1.height() - window.geometry("%dx%d+%d+%d" % (w, h, x, y)) - panel1 = tk.Label(window, image=image1) - panel1.pack(side='top', fill='both', expand='yes') - panel1.image = image1 - x += w + 2 - - root.mainloop() - - -class TestFailure(Exception): - - pass - -class TestSkip(Exception): - - pass - - -class Test: - - def __init__(self): - pass - - def _run(self, result): - raise NotImplementedError - - def run(self): - result = TestResult() - self._run(result) - result.report() - - def assert_rgba(self, ctx, surface, x, y, w, h, expected_rgba, pixel_tol=4.0/256, surface_tol=0.85): - total = h*w - different = ctx.surface_compare_rgba(surface, x, y, w, h, expected_rgba, tol=pixel_tol) - if different: - sys.stderr.write("%u out of %u pixels differ\n" % (different, total)) - - if float(total - different)/float(total) < surface_tol: - if 0: - rgba = FloatArray(h*w*4) - ctx.surface_read_rgba(surface, x, y, w, h, rgba) - show_image(w, h, Result=rgba, Expected=expected_rgba) - save_image(w, h, rgba, "result.png") - save_image(w, h, expected_rgba, "expected.png") - #sys.exit(0) - - raise TestFailure - - -class TestCase(Test): - - tags = () - - def __init__(self, dev, **kargs): - Test.__init__(self) - self.dev = dev - self.__dict__.update(kargs) - - def description(self): - descriptions = [] - for tag in self.tags: - value = self.get(tag) - if value is not None and value != '': - descriptions.append(tag + '=' + str(value)) - return ' '.join(descriptions) - - def get(self, tag): - try: - method = getattr(self, '_get_' + tag) - except AttributeError: - return getattr(self, tag, None) - else: - return method() - - def _get_target(self): - return { - PIPE_TEXTURE_1D: "1d", - PIPE_TEXTURE_2D: "2d", - PIPE_TEXTURE_3D: "3d", - PIPE_TEXTURE_CUBE: "cube", - }[self.target] - - def _get_format(self): - name = formats[self.format] - if name.startswith('PIPE_FORMAT_'): - name = name[12:] - name = name.lower() - return name - - def _get_face(self): - if self.target == PIPE_TEXTURE_CUBE: - return { - PIPE_TEX_FACE_POS_X: "+x", - PIPE_TEX_FACE_NEG_X: "-x", - PIPE_TEX_FACE_POS_Y: "+y", - PIPE_TEX_FACE_NEG_Y: "-y", - PIPE_TEX_FACE_POS_Z: "+z", - PIPE_TEX_FACE_NEG_Z: "-z", - }[self.face] - else: - return '' - - def test(self): - raise NotImplementedError - - def _run(self, result): - result.test_start(self) - try: - self.test() - except KeyboardInterrupt: - raise - except TestSkip: - result.test_skipped(self) - except TestFailure: - result.test_failed(self) - else: - result.test_passed(self) - - -class TestSuite(Test): - - def __init__(self, tests = None): - Test.__init__(self) - if tests is None: - self.tests = [] - else: - self.tests = tests - - def add_test(self, test): - self.tests.append(test) - - def _run(self, result): - for test in self.tests: - test._run(result) - - -class TestResult: - - def __init__(self): - self.tests = 0 - self.passed = 0 - self.skipped = 0 - self.failed = 0 - - self.names = ['result'] - self.types = ['pass skip fail'] - self.rows = [] - - def test_start(self, test): - sys.stdout.write("Running %s...\n" % test.description()) - sys.stdout.flush() - self.tests += 1 - - def test_passed(self, test): - sys.stdout.write("PASS\n") - sys.stdout.flush() - self.passed += 1 - self.log_result(test, 'pass') - - def test_skipped(self, test): - sys.stdout.write("SKIP\n") - sys.stdout.flush() - self.skipped += 1 - self.log_result(test, 'skip') - - def test_failed(self, test): - sys.stdout.write("FAIL\n") - sys.stdout.flush() - self.failed += 1 - self.log_result(test, 'fail') - - def log_result(self, test, result): - row = ['']*len(self.names) - - # add result - assert self.names[0] == 'result' - assert result in ('pass', 'skip', 'fail') - row[0] = result - - # add tags - for tag in test.tags: - value = test.get(tag) - - # infer type - if value is None: - continue - elif isinstance(value, (int, float)): - value = str(value) - type = 'c' # continous - elif isinstance(value, basestring): - type = 'd' # discrete - else: - assert False - value = str(value) - type = 'd' # discrete - - # insert value - try: - col = self.names.index(tag, 1) - except ValueError: - self.names.append(tag) - self.types.append(type) - row.append(value) - else: - row[col] = value - assert self.types[col] == type - - self.rows.append(row) - - def report(self): - sys.stdout.write("%u tests, %u passed, %u skipped, %u failed\n\n" % (self.tests, self.passed, self.skipped, self.failed)) - sys.stdout.flush() - - name, ext = os.path.splitext(os.path.basename(sys.argv[0])) - - tree = self.report_tree(name) - self.report_junit(name, stdout=tree) - - def report_tree(self, name): - filename = name + '.tsv' - stream = file(filename, 'wt') - - # header - stream.write('\t'.join(self.names) + '\n') - stream.write('\t'.join(self.types) + '\n') - stream.write('class\n') - - # rows - for row in self.rows: - if row[0] == 'skip': - continue - row += ['']*(len(self.names) - len(row)) - stream.write('\t'.join(row) + '\n') - - stream.close() - - # See http://www.ailab.si/orange/doc/ofb/c_otherclass.htm - try: - import orange - import orngTree - except ImportError: - sys.stderr.write('Install Orange from http://www.ailab.si/orange/ for a classification tree.\n') - return None - - data = orange.ExampleTable(filename) - - tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) - - orngTree.printTxt(tree, maxDepth=4) - - text_tree = orngTree.dumpTree(tree) - - file(name + '.txt', 'wt').write(text_tree) - - orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') - - return text_tree - - def report_junit(self, name, stdout=None, stderr=None): - """Write test results in ANT's junit XML format, to use with Hudson CI. - - See also: - - http://fisheye.hudson-ci.org/browse/Hudson/trunk/hudson/main/core/src/test/resources/hudson/tasks/junit - - http://www.junit.org/node/399 - - http://wiki.apache.org/ant/Proposals/EnhancedTestReports - """ - - stream = file(name + '.xml', 'wt') - - stream.write('\n') - stream.write('\n' % self.escape_xml(name)) - stream.write(' \n') - stream.write(' \n') - - names = self.names[1:] - - for row in self.rows: - - test_name = ' '.join(['%s=%s' % pair for pair in zip(self.names[1:], row[1:])]) - - stream.write(' \n' % (self.escape_xml(test_name))) - - result = row[0] - if result == 'pass': - pass - elif result == 'skip': - stream.write(' \n') - else: - stream.write(' \n') - - stream.write(' \n') - - if stdout: - stream.write(' %s\n' % self.escape_xml(stdout)) - if stderr: - stream.write(' %s\n' % self.escape_xml(stderr)) - - stream.write('\n') - - stream.close() - - def escape_xml(self, s): - '''Escape a XML string.''' - s = s.replace('&', '&') - s = s.replace('<', '<') - s = s.replace('>', '>') - s = s.replace('"', '"') - s = s.replace("'", ''') - return s - diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/.gitignore b/src/gallium/tests/python/tests/regress/fragment-shader/.gitignore deleted file mode 100644 index e33609d251c..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.png diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-abs.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-abs.sh deleted file mode 100644 index 103d7497f48..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-abs.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { -0.5, -0.4, -0.6, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -ABS OUT[0], TEMP[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-add.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-add.sh deleted file mode 100644 index bcb94205963..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-add.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -ADD OUT[0], IN[0], IN[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-cb-1d.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-cb-1d.sh deleted file mode 100644 index 85fb9ea4e7f..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-cb-1d.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR -DCL CONST[1] -DCL CONST[3] -DCL TEMP[0..1] - -ADD TEMP[0], IN[0], CONST[1] -RCP TEMP[1], CONST[3].xxxx -MUL OUT[0], TEMP[0], TEMP[1] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-dp3.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-dp3.sh deleted file mode 100644 index b5281975d4a..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-dp3.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DP3 OUT[0], IN[0], IN[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-dp4.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-dp4.sh deleted file mode 100644 index d59df76e70b..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-dp4.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DP4 OUT[0], IN[0].xyzx, IN[0].xyzx - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-dst.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-dst.sh deleted file mode 100644 index fbb20fa9f62..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-dst.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DST OUT[0], IN[0], IN[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-ex2.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-ex2.sh deleted file mode 100644 index b511288f4b6..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-ex2.sh +++ /dev/null @@ -1,11 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -EX2 TEMP[0], IN[0].xxxx -MUL OUT[0], TEMP[0], IN[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-flr.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-flr.sh deleted file mode 100644 index 99a2f96103a..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-flr.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 2.5, 4.0, 2.0, 1.0 } -IMM FLT32 { 0.4, 0.25, 0.5, 1.0 } - -MUL TEMP[0], IN[0], IMM[0] -FLR TEMP[0], TEMP[0] -MUL OUT[0], TEMP[0], IMM[1] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-frc.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-frc.sh deleted file mode 100644 index a54c2623b0a..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-frc.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 2.7, 3.1, 4.5, 1.0 } - -MUL TEMP[0], IN[0], IMM[0] -FRC OUT[0], TEMP[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-lg2.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-lg2.sh deleted file mode 100644 index 5f5b4be1092..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-lg2.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } -IMM FLT32 { 0.5, 0.0, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -LG2 TEMP[0].x, TEMP[0].xxxx -ADD OUT[0], TEMP[0], IMM[1] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-lit.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-lit.sh deleted file mode 100644 index 6323c4712dc..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-lit.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -LIT OUT[0], IN[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-lrp.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-lrp.sh deleted file mode 100644 index 740809d22e0..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-lrp.sh +++ /dev/null @@ -1,11 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -ABS TEMP[0], IN[0] -LRP OUT[0], TEMP[0], IN[0].xxxx, IN[0].yyyy - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-mad.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-mad.sh deleted file mode 100644 index 413b9dc3916..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-mad.sh +++ /dev/null @@ -1,11 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -IMM FLT32 { 0.5, 0.4, 0.6, 1.0 } -IMM FLT32 { 0.5, 0.4, 0.6, 0.0 } - -MAD OUT[0], IN[0], IMM[0], IMM[1] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-max.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-max.sh deleted file mode 100644 index b69f2132612..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-max.sh +++ /dev/null @@ -1,10 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -IMM FLT32 { 0.4, 0.4, 0.4, 0.0 } - -MAX OUT[0], IN[0], IMM[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-min.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-min.sh deleted file mode 100644 index df284f49e71..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-min.sh +++ /dev/null @@ -1,10 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -IMM FLT32 { 0.6, 0.6, 0.6, 1.0 } - -MIN OUT[0], IN[0], IMM[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-mov.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-mov.sh deleted file mode 100644 index 64af72f381b..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-mov.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -MOV OUT[0], IN[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-mul.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-mul.sh deleted file mode 100644 index bdd0b0026b9..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-mul.sh +++ /dev/null @@ -1,10 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -IMM FLT32 { 0.5, 0.6, 0.7, 1.0 } - -MUL OUT[0], IN[0], IMM[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-rcp.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-rcp.sh deleted file mode 100644 index f4b611b26ab..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-rcp.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } -IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -RCP TEMP[0].x, TEMP[0].xxxx -SUB OUT[0], TEMP[0], IMM[1] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-rsq.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-rsq.sh deleted file mode 100644 index d1e9b0b53be..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-rsq.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } -IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -RSQ TEMP[0].x, TEMP[0].xxxx -SUB OUT[0], TEMP[0], IMM[1] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-sge.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-sge.sh deleted file mode 100644 index 1f33fac4727..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-sge.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 0.6, 0.6, 0.6, 0.0 } - -SGE TEMP[0], IN[0], IMM[0] -MUL OUT[0], IN[0], TEMP[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-slt.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-slt.sh deleted file mode 100644 index d58b7886a12..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-slt.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 0.6, 0.6, 0.6, 0.0 } - -SLT TEMP[0], IN[0], IMM[0] -MUL OUT[0], IN[0], TEMP[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-abs.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-abs.sh deleted file mode 100644 index ecd19248c64..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-abs.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { -0.3, -0.5, -0.4, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -MOV OUT[0], |TEMP[0]| - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh deleted file mode 100644 index c2d99ddd15b..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { -0.2, -0.3, -0.4, 0.0 } -IMM FLT32 { -1.0, -1.0, -1.0, -1.0 } - -ADD TEMP[0], IN[0], IMM[0] -MOV TEMP[0], -|TEMP[0]| -MUL OUT[0], TEMP[0], IMM[1] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-neg.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-neg.sh deleted file mode 100644 index a08ab6d2dcb..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-neg.sh +++ /dev/null @@ -1,11 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -SUB TEMP[0], IN[0], IN[0].yzxw -MOV OUT[0], -TEMP[0] - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-swz.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-swz.sh deleted file mode 100644 index 6110647d979..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-srcmod-swz.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -MOV OUT[0], IN[0].yxzw - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-sub.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-sub.sh deleted file mode 100644 index 673fca139aa..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-sub.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -SUB OUT[0], IN[0], IN[0].yzxw - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-xpd.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-xpd.sh deleted file mode 100644 index 6ec8b1184cc..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-xpd.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -XPD OUT[0], IN[0], IN[0].yzxw - -END diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/tests/python/tests/regress/fragment-shader/fragment-shader.py deleted file mode 100644 index ef65a9c5a1b..00000000000 --- a/src/gallium/tests/python/tests/regress/fragment-shader/fragment-shader.py +++ /dev/null @@ -1,257 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - -import struct - -from gallium import * - -def make_image(surface): - data = surface.get_tile_rgba8(0, 0, surface.width, surface.height) - - import Image - outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) - return outimage - -def save_image(filename, surface): - outimage = make_image(surface) - outimage.save(filename, "PNG") - -def test(dev, name): - ctx = dev.context_create() - - width = 320 - height = 320 - minz = 0.0 - maxz = 1.0 - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - depth_stencil_alpha.depth.enabled = 0 - depth_stencil_alpha.depth.writemask = 1 - depth_stencil_alpha.depth.func = PIPE_FUNC_LESS - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.scissor = 1 - ctx.set_rasterizer(rasterizer) - - # viewport - viewport = Viewport() - scale = FloatArray(4) - scale[0] = width / 2.0 - scale[1] = -height / 2.0 - scale[2] = (maxz - minz) / 2.0 - scale[3] = 1.0 - viewport.scale = scale - translate = FloatArray(4) - translate[0] = width / 2.0 - translate[1] = height / 2.0 - translate[2] = (maxz - minz) / 2.0 - translate[3] = 0.0 - viewport.translate = translate - ctx.set_viewport(viewport) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - ctx.set_fragment_sampler(0, sampler) - - # scissor - scissor = Scissor() - scissor.minx = 0 - scissor.miny = 0 - scissor.maxx = width - scissor.maxy = height - ctx.set_scissor(scissor) - - clip = Clip() - clip.nr = 0 - ctx.set_clip(clip) - - # framebuffer - cbuf = dev.resource_create( - PIPE_FORMAT_B8G8R8X8_UNORM, - width, height, - bind=PIPE_BIND_RENDER_TARGET, - ).get_surface() - fb = Framebuffer() - fb.width = width - fb.height = height - fb.nr_cbufs = 1 - fb.set_cbuf(0, cbuf) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.5 - rgba[1] = 0.5 - rgba[2] = 0.5 - rgba[3] = 0.5 - ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) - - # vertex shader - vs = Shader(''' - VERT - DCL IN[0], POSITION - DCL IN[1], COLOR - DCL OUT[0], POSITION - DCL OUT[1], COLOR - MOV OUT[0], IN[0] - MOV OUT[1], IN[1] - END - ''') - ctx.set_vertex_shader(vs) - - # fragment shader - fs = Shader(file('frag-' + name + '.sh', 'rt').read()) - ctx.set_fragment_shader(fs) - - constbuf0 = dev.buffer_create(64, - (PIPE_BUFFER_USAGE_CONSTANT | - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE), - 4 * 4 * 4) - - cbdata = '' - cbdata += struct.pack('4f', 0.4, 0.0, 0.0, 1.0) - cbdata += struct.pack('4f', 1.0, 1.0, 1.0, 1.0) - cbdata += struct.pack('4f', 2.0, 2.0, 2.0, 2.0) - cbdata += struct.pack('4f', 4.0, 8.0, 16.0, 32.0) - - constbuf0.write(cbdata, 0) - - ctx.set_constant_buffer(PIPE_SHADER_FRAGMENT, - 0, - constbuf0) - - constbuf1 = dev.buffer_create(64, - (PIPE_BUFFER_USAGE_CONSTANT | - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE), - 4 * 4 * 4) - - cbdata = '' - cbdata += struct.pack('4f', 0.1, 0.1, 0.1, 0.1) - cbdata += struct.pack('4f', 0.25, 0.25, 0.25, 0.25) - cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) - cbdata += struct.pack('4f', 0.75, 0.75, 0.75, 0.75) - - constbuf1.write(cbdata, 0) - - ctx.set_constant_buffer(PIPE_SHADER_FRAGMENT, - 1, - constbuf1) - - xy = [ - -0.8, -0.8, - 0.8, -0.8, - 0.0, 0.8, - ] - color = [ - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0, - ] - - nverts = 3 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - for i in range(0, nverts): - verts[i * nattrs * 4 + 0] = xy[i * 2 + 0] # x - verts[i * nattrs * 4 + 1] = xy[i * 2 + 1] # y - verts[i * nattrs * 4 + 2] = 0.5 # z - verts[i * nattrs * 4 + 3] = 1.0 # w - verts[i * nattrs * 4 + 4] = color[i * 3 + 0] # r - verts[i * nattrs * 4 + 5] = color[i * 3 + 1] # g - verts[i * nattrs * 4 + 6] = color[i * 3 + 2] # b - verts[i * nattrs * 4 + 7] = 1.0 # a - - ctx.draw_vertices(PIPE_PRIM_TRIANGLES, - nverts, - nattrs, - verts) - - ctx.flush() - - save_image('frag-' + name + '.png', cbuf) - -def main(): - tests = [ - 'abs', - 'add', - 'cb-1d', - 'cb-2d', - 'dp3', - 'dp4', - 'dst', - 'ex2', - 'flr', - 'frc', - 'lg2', - 'lit', - 'lrp', - 'mad', - 'max', - 'min', - 'mov', - 'mul', - 'rcp', - 'rsq', - 'sge', - 'slt', - 'srcmod-abs', - 'srcmod-absneg', - 'srcmod-neg', - 'srcmod-swz', - 'sub', - 'xpd', - ] - - dev = Device() - for t in tests: - test(dev, t) - -if __name__ == '__main__': - main() diff --git a/src/gallium/tests/python/tests/regress/vertex-shader/.gitignore b/src/gallium/tests/python/tests/regress/vertex-shader/.gitignore deleted file mode 100644 index e33609d251c..00000000000 --- a/src/gallium/tests/python/tests/regress/vertex-shader/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.png diff --git a/src/gallium/tests/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/tests/python/tests/regress/vertex-shader/vertex-shader.py deleted file mode 100644 index 05e40dbd5f1..00000000000 --- a/src/gallium/tests/python/tests/regress/vertex-shader/vertex-shader.py +++ /dev/null @@ -1,287 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -import struct - -from gallium import * - -def make_image(surface): - data = surface.get_tile_rgba8(0, 0, surface.width, surface.height) - - import Image - outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) - return outimage - -def save_image(filename, surface): - outimage = make_image(surface) - outimage.save(filename, "PNG") - -def test(dev, name): - ctx = dev.context_create() - - width = 320 - height = 320 - minz = 0.0 - maxz = 1.0 - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - depth_stencil_alpha.depth.enabled = 0 - depth_stencil_alpha.depth.writemask = 1 - depth_stencil_alpha.depth.func = PIPE_FUNC_LESS - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.scissor = 1 - ctx.set_rasterizer(rasterizer) - - # viewport - viewport = Viewport() - scale = FloatArray(4) - scale[0] = width / 2.0 - scale[1] = -height / 2.0 - scale[2] = (maxz - minz) / 2.0 - scale[3] = 1.0 - viewport.scale = scale - translate = FloatArray(4) - translate[0] = width / 2.0 - translate[1] = height / 2.0 - translate[2] = (maxz - minz) / 2.0 - translate[3] = 0.0 - viewport.translate = translate - ctx.set_viewport(viewport) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - ctx.set_fragment_sampler(0, sampler) - - # scissor - scissor = Scissor() - scissor.minx = 0 - scissor.miny = 0 - scissor.maxx = width - scissor.maxy = height - ctx.set_scissor(scissor) - - clip = Clip() - clip.nr = 0 - ctx.set_clip(clip) - - # framebuffer - cbuf = dev.resource_create( - PIPE_FORMAT_B8G8R8X8_UNORM, - width, height, - bind=PIPE_BIND_RENDER_TARGET, - ).get_surface() - fb = Framebuffer() - fb.width = width - fb.height = height - fb.nr_cbufs = 1 - fb.set_cbuf(0, cbuf) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.5 - rgba[1] = 0.5 - rgba[2] = 0.5 - rgba[3] = 0.5 - ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) - - # vertex shader - vs = Shader(file('vert-' + name + '.sh', 'rt').read()) - ctx.set_vertex_shader(vs) - - # fragment shader - fs = Shader(''' - FRAG - DCL IN[0], COLOR, LINEAR - DCL OUT[0], COLOR, CONSTANT - 0:MOV OUT[0], IN[0] - 1:END - ''') - ctx.set_fragment_shader(fs) - - constbuf0 = dev.buffer_create(64, - (PIPE_BUFFER_USAGE_CONSTANT | - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE), - 4 * 4 * 4) - - cbdata = '' - cbdata += struct.pack('4f', 0.4, 0.0, 0.0, 1.0) - cbdata += struct.pack('4f', 1.0, 1.0, 1.0, 1.0) - cbdata += struct.pack('4f', 2.0, 2.0, 2.0, 2.0) - cbdata += struct.pack('4f', 4.0, 8.0, 16.0, 32.0) - - constbuf0.write(cbdata, 0) - - ctx.set_constant_buffer(PIPE_SHADER_VERTEX, - 0, - constbuf0) - - constbuf1 = dev.buffer_create(64, - (PIPE_BUFFER_USAGE_CONSTANT | - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE), - 4 * 4 * 4) - - cbdata = '' - cbdata += struct.pack('4f', 0.1, 0.1, 0.1, 0.1) - cbdata += struct.pack('4f', 0.25, 0.25, 0.25, 0.25) - cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) - cbdata += struct.pack('4f', 0.75, 0.75, 0.75, 0.75) - - constbuf1.write(cbdata, 0) - - ctx.set_constant_buffer(PIPE_SHADER_VERTEX, - 1, - constbuf1) - - xy = [ - 0.0, 0.8, - -0.2, 0.4, - 0.2, 0.4, - -0.4, 0.0, - 0.0, 0.0, - 0.4, 0.0, - -0.6, -0.4, - -0.2, -0.4, - 0.2, -0.4, - 0.6, -0.4, - -0.8, -0.8, - -0.4, -0.8, - 0.0, -0.8, - 0.4, -0.8, - 0.8, -0.8, - ] - color = [ - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0, - ] - tri = [ - 1, 2, 0, - 3, 4, 1, - 4, 2, 1, - 4, 5, 2, - 6, 7, 3, - 7, 4, 3, - 7, 8, 4, - 8, 5, 4, - 8, 9, 5, - 10, 11, 6, - 11, 7, 6, - 11, 12, 7, - 12, 8, 7, - 12, 13, 8, - 13, 9, 8, - 13, 14, 9, - ] - - nverts = 16 * 3 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - for i in range(0, nverts): - verts[i * nattrs * 4 + 0] = xy[tri[i] * 2 + 0] # x - verts[i * nattrs * 4 + 1] = xy[tri[i] * 2 + 1] # y - verts[i * nattrs * 4 + 2] = 0.5 # z - verts[i * nattrs * 4 + 3] = 1.0 # w - verts[i * nattrs * 4 + 4] = color[(i % 3) * 3 + 0] # r - verts[i * nattrs * 4 + 5] = color[(i % 3) * 3 + 1] # g - verts[i * nattrs * 4 + 6] = color[(i % 3) * 3 + 2] # b - verts[i * nattrs * 4 + 7] = 1.0 # a - - ctx.draw_vertices(PIPE_PRIM_TRIANGLES, - nverts, - nattrs, - verts) - - ctx.flush() - - save_image('vert-' + name + '.png', cbuf) - -def main(): - tests = [ - 'abs', - 'add', - 'arl', - 'arr', - 'cb-1d', - 'cb-2d', - 'dp3', - 'dp4', - 'dst', - 'ex2', - 'flr', - 'frc', - 'lg2', - 'lit', - 'lrp', - 'mad', - 'max', - 'min', - 'mov', - 'mul', - 'rcp', - 'rsq', - 'sge', - 'slt', - 'srcmod-abs', - 'srcmod-absneg', - 'srcmod-neg', - 'srcmod-swz', - 'sub', - 'xpd', - ] - - dev = Device() - for t in tests: - test(dev, t) - -if __name__ == '__main__': - main() diff --git a/src/gallium/tests/python/tests/texture_render.py b/src/gallium/tests/python/tests/texture_render.py deleted file mode 100755 index 23f3d2a57de..00000000000 --- a/src/gallium/tests/python/tests/texture_render.py +++ /dev/null @@ -1,320 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -from gallium import * -from base import * - - -def lods(*dims): - size = max(dims) - lods = 0 - while size: - lods += 1 - size >>= 1 - return lods - - -class TextureTest(TestCase): - - tags = ( - 'target', - 'format', - 'width', - 'height', - 'depth', - 'last_level', - 'face', - 'level', - 'zslice', - ) - - def test(self): - dev = self.dev - - target = self.target - format = self.format - width = self.width - height = self.height - depth = self.depth - last_level = self.last_level - face = self.face - level = self.level - zslice = self.zslice - - # textures - dst_texture = dev.resource_create( - target = target, - format = format, - width = width, - height = height, - depth = depth, - last_level = last_level, - bind = PIPE_BIND_RENDER_TARGET, - ) - if dst_texture is None: - raise TestSkip - - dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice) - - ref_texture = dev.resource_create( - target = target, - format = format, - width = dst_surface.width, - height = dst_surface.height, - depth = 1, - last_level = 0, - bind = PIPE_BIND_SAMPLER_VIEW, - ) - - ref_surface = ref_texture.get_surface() - - src_texture = dev.resource_create( - target = target, - format = PIPE_FORMAT_B8G8R8A8_UNORM, - width = dst_surface.width, - height = dst_surface.height, - depth = 1, - last_level = 0, - bind = PIPE_BIND_SAMPLER_VIEW, - ) - - src_surface = src_texture.get_surface() - - expected_rgba = FloatArray(height*width*4) - ref_surface.sample_rgba(expected_rgba) - - src_surface.put_tile_rgba(0, 0, src_surface.width, src_surface.height, expected_rgba) - - ctx = self.dev.context_create() - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # no-op depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.bypass_vs_clip_and_viewport = 1 - ctx.set_rasterizer(rasterizer) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - sampler.min_lod = 0 - sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1 - ctx.set_fragment_sampler(0, sampler) - ctx.set_fragment_sampler_texture(0, src_texture) - - # framebuffer - cbuf_tex = dev.resource_create( - PIPE_FORMAT_B8G8R8A8_UNORM, - width, - height, - bind = PIPE_BIND_RENDER_TARGET, - ) - - fb = Framebuffer() - fb.width = dst_surface.width - fb.height = dst_surface.height - fb.nr_cbufs = 1 - fb.set_cbuf(0, dst_surface) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.0 - rgba[1] = 0.0 - rgba[2] = 0.0 - rgba[3] = 0.0 - ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) - del fb - - # vertex shader - vs = Shader(''' - VERT - DCL IN[0], POSITION, CONSTANT - DCL IN[1], GENERIC, CONSTANT - DCL OUT[0], POSITION, CONSTANT - DCL OUT[1], GENERIC, CONSTANT - 0:MOV OUT[0], IN[0] - 1:MOV OUT[1], IN[1] - 2:END - ''') - #vs.dump() - ctx.set_vertex_shader(vs) - - # fragment shader - fs = Shader(''' - FRAG - DCL IN[0], GENERIC[0], LINEAR - DCL OUT[0], COLOR, CONSTANT - DCL SAMP[0], CONSTANT - 0:TEX OUT[0], IN[0], SAMP[0], 2D - 1:END - ''') - #fs.dump() - ctx.set_fragment_shader(fs) - - nverts = 4 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - x = 0 - y = 0 - w = dst_surface.width - h = dst_surface.height - - pos = [ - [x, y], - [x+w, y], - [x+w, y+h], - [x, y+h], - ] - - tex = [ - [0.0, 0.0], - [1.0, 0.0], - [1.0, 1.0], - [0.0, 1.0], - ] - - for i in range(0, 4): - j = 8*i - verts[j + 0] = pos[i][0] # x - verts[j + 1] = pos[i][1] # y - verts[j + 2] = 0.0 # z - verts[j + 3] = 1.0 # w - verts[j + 4] = tex[i][0] # s - verts[j + 5] = tex[i][1] # r - verts[j + 6] = 0.0 - verts[j + 7] = 1.0 - - ctx.draw_vertices(PIPE_PRIM_TRIANGLE_FAN, - nverts, - nattrs, - verts) - - ctx.flush() - - self.assert_rgba(dst_surface, x, y, w, h, expected_rgba, 4.0/256, 0.85) - - - -def main(): - dev = Device() - suite = TestSuite() - - targets = [ - PIPE_TEXTURE_2D, - PIPE_TEXTURE_CUBE, - #PIPE_TEXTURE_3D, - ] - - formats = [ - PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_B8G8R8X8_UNORM, - #PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_FORMAT_B5G6R5_UNORM, - PIPE_FORMAT_B5G5R5A1_UNORM, - PIPE_FORMAT_B4G4R4A4_UNORM, - #PIPE_FORMAT_Z32_UNORM, - #PIPE_FORMAT_S8_USCALED_Z24_UNORM, - #PIPE_FORMAT_X8Z24_UNORM, - #PIPE_FORMAT_Z16_UNORM, - #PIPE_FORMAT_S8_USCALED, - PIPE_FORMAT_A8_UNORM, - PIPE_FORMAT_L8_UNORM, - #PIPE_FORMAT_DXT1_RGB, - #PIPE_FORMAT_DXT1_RGBA, - #PIPE_FORMAT_DXT3_RGBA, - #PIPE_FORMAT_DXT5_RGBA, - ] - - sizes = [64, 32, 16, 8, 4, 2, 1] - #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] - #sizes = [64] - #sizes = [63] - - faces = [ - PIPE_TEX_FACE_POS_X, - PIPE_TEX_FACE_NEG_X, - PIPE_TEX_FACE_POS_Y, - PIPE_TEX_FACE_NEG_Y, - PIPE_TEX_FACE_POS_Z, - PIPE_TEX_FACE_NEG_Z, - ] - - for target in targets: - for format in formats: - for size in sizes: - if target == PIPE_TEXTURE_3D: - depth = size - else: - depth = 1 - for face in faces: - if target != PIPE_TEXTURE_CUBE and face: - continue - levels = lods(size) - for last_level in range(levels): - for level in range(0, last_level + 1): - zslice = 0 - while zslice < depth >> level: - test = TextureTest( - dev = dev, - target = target, - format = format, - width = size, - height = size, - depth = depth, - last_level = last_level, - face = face, - level = level, - zslice = zslice, - ) - suite.add_test(test) - zslice = (zslice + 1)*2 - 1 - suite.run() - - -if __name__ == '__main__': - main() diff --git a/src/gallium/tests/python/tests/tree.py b/src/gallium/tests/python/tests/tree.py deleted file mode 100755 index 0c1bcda4cf2..00000000000 --- a/src/gallium/tests/python/tests/tree.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -# -# See also: -# http://www.ailab.si/orange/doc/ofb/c_otherclass.htm - -import os.path -import sys - -import orange -import orngTree - -for arg in sys.argv[1:]: - name, ext = os.path.splitext(arg) - - data = orange.ExampleTable(arg) - - tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) - - orngTree.printTxt(tree) - - file(name+'.txt', 'wt').write(orngTree.dumpTree(tree) + '\n') - - orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') diff --git a/src/gallium/tests/trivial/.gitignore b/src/gallium/tests/trivial/.gitignore deleted file mode 100644 index af6cdedbeba..00000000000 --- a/src/gallium/tests/trivial/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -tri -quad-tex -result.bmp diff --git a/src/gallium/tests/trivial/Makefile b/src/gallium/tests/trivial/Makefile deleted file mode 100644 index bfcbdd9712d..00000000000 --- a/src/gallium/tests/trivial/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# progs/gallium/simple/Makefile - -TOP = ../../../.. -include $(TOP)/configs/current - -INCLUDES = \ - -I. \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/auxiliary \ - -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/gallium/winsys \ - $(PROG_INCLUDES) - -LINKS = \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/winsys/sw/null/libws_null.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(GALLIUM_AUXILIARIES) \ - $(PROG_LINKS) - -SOURCES = \ - tri.c \ - quad-tex.c - -OBJECTS = $(SOURCES:.c=.o) - -PROGS = $(OBJECTS:.o=) - -##### TARGETS ##### - -default: $(PROGS) - -clean: - -rm -f $(PROGS) - -rm -f *.o - -rm -f result.bmp - -##### RULES ##### - -$(OBJECTS): %.o: %.c - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(PROG_DEFINES) $< -o $@ - -$(PROGS): %: %.o $(LINKS) - $(CC) $(LDFLAGS) $< $(LINKS) -lm -lpthread -ldl -o $@ diff --git a/src/gallium/tests/unit/Makefile b/src/gallium/tests/unit/Makefile deleted file mode 100644 index f65958dadd5..00000000000 --- a/src/gallium/tests/unit/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# progs/gallium/simple/Makefile - -TOP = ../../../.. -include $(TOP)/configs/current - -INCLUDES = \ - -I. \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/auxiliary \ - -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/gallium/winsys \ - $(PROG_INCLUDES) - -LINKS = \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/winsys/sw/null/libws_null.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(GALLIUM_AUXILIARIES) \ - $(PROG_LINKS) - -SOURCES = \ - pipe_barrier_test.c \ - u_cache_test.c \ - u_half_test.c \ - u_format_test.c - - -OBJECTS = $(SOURCES:.c=.o) - -PROGS = $(OBJECTS:.o=) - -##### TARGETS ##### - -default: $(PROGS) - -clean: - -rm -f $(PROGS) - -rm -f *.o - -rm -f result.bmp - -##### RULES ##### - -$(OBJECTS): %.o: %.c - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(PROG_DEFINES) $< -o $@ - -$(PROGS): %: %.o - $(CC) $(LDFLAGS) $< $(LINKS) -lm -lpthread -ldl -o $@ diff --git a/src/gallium/tests/unit/SConscript b/src/gallium/tests/unit/SConscript deleted file mode 100644 index 8a9f3504c75..00000000000 --- a/src/gallium/tests/unit/SConscript +++ /dev/null @@ -1,25 +0,0 @@ -Import('*') - -env = env.Clone() - -env.Prepend(LIBS = [gallium]) - -progs = [ - 'pipe_barrier_test', - 'u_cache_test', - 'u_format_test', - 'u_half_test' -] - -for prog in progs: - prog = env.Program( - target = prog, - source = prog + '.c', - ) - - env.InstallProgram(prog) - - # http://www.scons.org/wiki/UnitTests - test_alias = env.Alias('unit', [prog], prog[0].abspath) - AlwaysBuild(test_alias) - diff --git a/src/gallium/tests/unit/pipe_barrier_test.c b/src/gallium/tests/unit/pipe_barrier_test.c deleted file mode 100644 index f5d72b0abae..00000000000 --- a/src/gallium/tests/unit/pipe_barrier_test.c +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************** - * - * Copyright 2009-2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -/* - * Test case for pipe_barrier. - * - * The test succeeds if no thread exits before all the other threads reach - * the barrier. - */ - - -#include - -#include "os/os_thread.h" -#include "os/os_time.h" - - -#define NUM_THREADS 10 - -static pipe_thread threads[NUM_THREADS]; -static pipe_barrier barrier; -static int thread_ids[NUM_THREADS]; - - -static PIPE_THREAD_ROUTINE(thread_function, thread_data) -{ - int thread_id = *((int *) thread_data); - - printf("thread %d starting\n", thread_id); - os_time_sleep(thread_id * 1000 * 1000); - printf("thread %d before barrier\n", thread_id); - pipe_barrier_wait(&barrier); - printf("thread %d exiting\n", thread_id); - - return NULL; -} - - -int main() -{ - int i; - - printf("pipe_barrier_test starting\n"); - - pipe_barrier_init(&barrier, NUM_THREADS); - - for (i = 0; i < NUM_THREADS; i++) { - thread_ids[i] = i; - threads[i] = pipe_thread_create(thread_function, (void *) &thread_ids[i]); - } - - for (i = 0; i < NUM_THREADS; i++ ) { - pipe_thread_wait(threads[i]); - } - - pipe_barrier_destroy(&barrier); - - printf("pipe_barrier_test exiting\n"); - - return 0; -} diff --git a/src/gallium/tests/unit/u_cache_test.c b/src/gallium/tests/unit/u_cache_test.c deleted file mode 100644 index 0b62a765230..00000000000 --- a/src/gallium/tests/unit/u_cache_test.c +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -/* - * Test case for u_cache. - */ - - -#include -#include - -#include "util/u_cache.h" -#include "util/u_hash.h" - - -typedef uint32_t cache_test_key; -typedef uint32_t cache_test_value; - - -static uint32_t -cache_test_hash(const void *key) -{ - return util_hash_crc32(key, sizeof(cache_test_key)); -} - - -static void -cache_test_destroy(void *key, void *value) -{ - free(key); - free(value); -} - - -static int -cache_test_compare(const void *key1, const void *key2) { - return !(key1 == key2); -} - - -int main() { - unsigned cache_size; - unsigned cache_count; - - for (cache_size = 2; cache_size < (1 << 15); cache_size *= 2) { - for (cache_count = (cache_size << 5); cache_count < (cache_size << 10); cache_count *= 2) { - struct util_cache * cache; - cache_test_key *key; - cache_test_value *value_in; - cache_test_value *value_out; - int i; - - printf("Testing cache size of %d with %d values.\n", cache_size, cache_count); - - cache = util_cache_create(cache_test_hash, - cache_test_compare, - cache_test_destroy, - cache_size); - - /* - * Retrieve a value from an empty cache. - */ - key = malloc(sizeof(cache_test_key)); - *key = 0xdeadbeef; - value_out = (cache_test_value *) util_cache_get(cache, key); - assert(value_out == NULL); - free(key); - - - /* - * Repeatedly insert into and retrieve values from the cache. - */ - for (i = 0; i < cache_count; i++) { - key = malloc(sizeof(cache_test_key)); - value_in = malloc(sizeof(cache_test_value)); - - *key = rand(); - *value_in = rand(); - util_cache_set(cache, key, value_in); - - value_out = util_cache_get(cache, key); - assert(value_out != NULL); - assert(value_in == value_out); - assert(*value_in == *value_out); - } - - /* - * In debug builds, this will trigger a self-check by the cache of - * the distribution of hits in its internal cache entries. - */ - util_cache_destroy(cache); - } - } - - return 0; -} diff --git a/src/gallium/tests/unit/u_format_test.c b/src/gallium/tests/unit/u_format_test.c deleted file mode 100644 index cfde6af75e0..00000000000 --- a/src/gallium/tests/unit/u_format_test.c +++ /dev/null @@ -1,708 +0,0 @@ -/************************************************************************** - * - * Copyright 2009-2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#include -#include -#include - -#include "util/u_half.h" -#include "util/u_format.h" -#include "util/u_format_tests.h" -#include "util/u_format_s3tc.h" - - -static boolean -compare_float(float x, float y) -{ - float error = y - x; - - if (error < 0.0f) - error = -error; - - if (error > FLT_EPSILON) { - return FALSE; - } - - return TRUE; -} - - -static void -print_packed(const struct util_format_description *format_desc, - const char *prefix, - const uint8_t *packed, - const char *suffix) -{ - unsigned i; - const char *sep = ""; - - printf("%s", prefix); - for (i = 0; i < format_desc->block.bits/8; ++i) { - printf("%s%02x", sep, packed[i]); - sep = " "; - } - printf("%s", suffix); -} - - -static void -print_unpacked_rgba_doubl(const struct util_format_description *format_desc, - const char *prefix, - const double unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4], - const char *suffix) -{ - unsigned i, j; - const char *sep = ""; - - printf("%s", prefix); - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - printf("%s{%f, %f, %f, %f}", sep, unpacked[i][j][0], unpacked[i][j][1], unpacked[i][j][2], unpacked[i][j][3]); - sep = ", "; - } - sep = ",\n"; - } - printf("%s", suffix); -} - - -static void -print_unpacked_rgba_float(const struct util_format_description *format_desc, - const char *prefix, - float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4], - const char *suffix) -{ - unsigned i, j; - const char *sep = ""; - - printf("%s", prefix); - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - printf("%s{%f, %f, %f, %f}", sep, unpacked[i][j][0], unpacked[i][j][1], unpacked[i][j][2], unpacked[i][j][3]); - sep = ", "; - } - sep = ",\n"; - } - printf("%s", suffix); -} - - -static void -print_unpacked_rgba_8unorm(const struct util_format_description *format_desc, - const char *prefix, - uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4], - const char *suffix) -{ - unsigned i, j; - const char *sep = ""; - - printf("%s", prefix); - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - printf("%s{0x%02x, 0x%02x, 0x%02x, 0x%02x}", sep, unpacked[i][j][0], unpacked[i][j][1], unpacked[i][j][2], unpacked[i][j][3]); - sep = ", "; - } - } - printf("%s", suffix); -} - - -static void -print_unpacked_z_float(const struct util_format_description *format_desc, - const char *prefix, - float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH], - const char *suffix) -{ - unsigned i, j; - const char *sep = ""; - - printf("%s", prefix); - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - printf("%s%f", sep, unpacked[i][j]); - sep = ", "; - } - sep = ",\n"; - } - printf("%s", suffix); -} - - -static void -print_unpacked_z_32unorm(const struct util_format_description *format_desc, - const char *prefix, - uint32_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH], - const char *suffix) -{ - unsigned i, j; - const char *sep = ""; - - printf("%s", prefix); - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - printf("%s0x%08x", sep, unpacked[i][j]); - sep = ", "; - } - } - printf("%s", suffix); -} - - -static void -print_unpacked_s_8uscaled(const struct util_format_description *format_desc, - const char *prefix, - uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH], - const char *suffix) -{ - unsigned i, j; - const char *sep = ""; - - printf("%s", prefix); - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - printf("%s0x%02x", sep, unpacked[i][j]); - sep = ", "; - } - } - printf("%s", suffix); -} - - -static boolean -test_format_fetch_rgba_float(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } }; - unsigned i, j, k; - boolean success; - - success = TRUE; - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - format_desc->fetch_rgba_float(unpacked[i][j], test->packed, j, i); - for (k = 0; k < 4; ++k) { - if (!compare_float(test->unpacked[i][j][k], unpacked[i][j][k])) { - success = FALSE; - } - } - } - } - - if (!success) { - print_unpacked_rgba_float(format_desc, "FAILED: ", unpacked, " obtained\n"); - print_unpacked_rgba_doubl(format_desc, " ", test->unpacked, " expected\n"); - } - - return success; -} - - -static boolean -test_format_unpack_rgba_float(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } }; - unsigned i, j, k; - boolean success; - - format_desc->unpack_rgba_float(&unpacked[0][0][0], sizeof unpacked[0], - test->packed, 0, - format_desc->block.width, format_desc->block.height); - - success = TRUE; - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - for (k = 0; k < 4; ++k) { - if (!compare_float(test->unpacked[i][j][k], unpacked[i][j][k])) { - success = FALSE; - } - } - } - } - - if (!success) { - print_unpacked_rgba_float(format_desc, "FAILED: ", unpacked, " obtained\n"); - print_unpacked_rgba_doubl(format_desc, " ", test->unpacked, " expected\n"); - } - - return success; -} - - -static boolean -test_format_pack_rgba_float(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4]; - uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; - unsigned i, j, k; - boolean success; - - if (test->format == PIPE_FORMAT_DXT1_RGBA) { - /* - * Skip S3TC as packed representation is not canonical. - * - * TODO: Do a round trip conversion. - */ - return TRUE; - } - - memset(packed, 0, sizeof packed); - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - for (k = 0; k < 4; ++k) { - unpacked[i][j][k] = (float) test->unpacked[i][j][k]; - } - } - } - - format_desc->pack_rgba_float(packed, 0, - &unpacked[0][0][0], sizeof unpacked[0], - format_desc->block.width, format_desc->block.height); - - success = TRUE; - for (i = 0; i < format_desc->block.bits/8; ++i) - if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i])) - success = FALSE; - - if (!success) { - print_packed(format_desc, "FAILED: ", packed, " obtained\n"); - print_packed(format_desc, " ", test->packed, " expected\n"); - } - - return success; -} - - -static boolean -convert_float_to_8unorm(uint8_t *dst, const double *src) -{ - unsigned i; - boolean accurate = TRUE; - - for (i = 0; i < UTIL_FORMAT_MAX_UNPACKED_HEIGHT*UTIL_FORMAT_MAX_UNPACKED_WIDTH*4; ++i) { - if (src[i] < 0.0) { - accurate = FALSE; - dst[i] = 0; - } - else if (src[i] > 1.0) { - accurate = FALSE; - dst[i] = 255; - } - else { - dst[i] = src[i] * 255.0; - } - } - - return accurate; -} - - -static boolean -test_format_unpack_rgba_8unorm(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } }; - uint8_t expected[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } }; - unsigned i, j, k; - boolean success; - - format_desc->unpack_rgba_8unorm(&unpacked[0][0][0], sizeof unpacked[0], - test->packed, 0, - format_desc->block.width, format_desc->block.height); - - convert_float_to_8unorm(&expected[0][0][0], &test->unpacked[0][0][0]); - - success = TRUE; - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - for (k = 0; k < 4; ++k) { - if (expected[i][j][k] != unpacked[i][j][k]) { - success = FALSE; - } - } - } - } - - if (!success) { - print_unpacked_rgba_8unorm(format_desc, "FAILED: ", unpacked, " obtained\n"); - print_unpacked_rgba_8unorm(format_desc, " ", expected, " expected\n"); - } - - return success; -} - - -static boolean -test_format_pack_rgba_8unorm(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4]; - uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; - unsigned i; - boolean success; - - if (test->format == PIPE_FORMAT_DXT1_RGBA) { - /* - * Skip S3TC as packed representation is not canonical. - * - * TODO: Do a round trip conversion. - */ - return TRUE; - } - - if (!convert_float_to_8unorm(&unpacked[0][0][0], &test->unpacked[0][0][0])) { - /* - * Skip test cases which cannot be represented by four unorm bytes. - */ - return TRUE; - } - - memset(packed, 0, sizeof packed); - - format_desc->pack_rgba_8unorm(packed, 0, - &unpacked[0][0][0], sizeof unpacked[0], - format_desc->block.width, format_desc->block.height); - - success = TRUE; - for (i = 0; i < format_desc->block.bits/8; ++i) - if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i])) - success = FALSE; - - if (!success) { - print_packed(format_desc, "FAILED: ", packed, " obtained\n"); - print_packed(format_desc, " ", test->packed, " expected\n"); - } - - return success; -} - - -static boolean -test_format_unpack_z_float(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } }; - unsigned i, j; - boolean success; - - format_desc->unpack_z_float(&unpacked[0][0], sizeof unpacked[0], - test->packed, 0, - format_desc->block.width, format_desc->block.height); - - success = TRUE; - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - if (!compare_float(test->unpacked[i][j][0], unpacked[i][j])) { - success = FALSE; - } - } - } - - if (!success) { - print_unpacked_z_float(format_desc, "FAILED: ", unpacked, " obtained\n"); - print_unpacked_rgba_doubl(format_desc, " ", test->unpacked, " expected\n"); - } - - return success; -} - - -static boolean -test_format_pack_z_float(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH]; - uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; - unsigned i, j; - boolean success; - - memset(packed, 0, sizeof packed); - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - unpacked[i][j] = (float) test->unpacked[i][j][0]; - if (test->unpacked[i][j][1]) { - return TRUE; - } - } - } - - format_desc->pack_z_float(packed, 0, - &unpacked[0][0], sizeof unpacked[0], - format_desc->block.width, format_desc->block.height); - - success = TRUE; - for (i = 0; i < format_desc->block.bits/8; ++i) - if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i])) - success = FALSE; - - if (!success) { - print_packed(format_desc, "FAILED: ", packed, " obtained\n"); - print_packed(format_desc, " ", test->packed, " expected\n"); - } - - return success; -} - - -static boolean -test_format_unpack_z_32unorm(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - uint32_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } }; - uint32_t expected[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } }; - unsigned i, j; - boolean success; - - format_desc->unpack_z_32unorm(&unpacked[0][0], sizeof unpacked[0], - test->packed, 0, - format_desc->block.width, format_desc->block.height); - - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - expected[i][j] = test->unpacked[i][j][0] * 0xffffffff; - } - } - - success = TRUE; - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - if (expected[i][j] != unpacked[i][j]) { - success = FALSE; - } - } - } - - if (!success) { - print_unpacked_z_32unorm(format_desc, "FAILED: ", unpacked, " obtained\n"); - print_unpacked_z_32unorm(format_desc, " ", expected, " expected\n"); - } - - return success; -} - - -static boolean -test_format_pack_z_32unorm(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - uint32_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH]; - uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; - unsigned i, j; - boolean success; - - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - unpacked[i][j] = test->unpacked[i][j][0] * 0xffffffff; - if (test->unpacked[i][j][1]) { - return TRUE; - } - } - } - - memset(packed, 0, sizeof packed); - - format_desc->pack_z_32unorm(packed, 0, - &unpacked[0][0], sizeof unpacked[0], - format_desc->block.width, format_desc->block.height); - - success = TRUE; - for (i = 0; i < format_desc->block.bits/8; ++i) - if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i])) - success = FALSE; - - if (!success) { - print_packed(format_desc, "FAILED: ", packed, " obtained\n"); - print_packed(format_desc, " ", test->packed, " expected\n"); - } - - return success; -} - - -static boolean -test_format_unpack_s_8uscaled(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } }; - uint8_t expected[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } }; - unsigned i, j; - boolean success; - - format_desc->unpack_s_8uscaled(&unpacked[0][0], sizeof unpacked[0], - test->packed, 0, - format_desc->block.width, format_desc->block.height); - - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - expected[i][j] = test->unpacked[i][j][1]; - } - } - - success = TRUE; - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - if (expected[i][j] != unpacked[i][j]) { - success = FALSE; - } - } - } - - if (!success) { - print_unpacked_s_8uscaled(format_desc, "FAILED: ", unpacked, " obtained\n"); - print_unpacked_s_8uscaled(format_desc, " ", expected, " expected\n"); - } - - return success; -} - - -static boolean -test_format_pack_s_8uscaled(const struct util_format_description *format_desc, - const struct util_format_test_case *test) -{ - uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH]; - uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; - unsigned i, j; - boolean success; - - for (i = 0; i < format_desc->block.height; ++i) { - for (j = 0; j < format_desc->block.width; ++j) { - unpacked[i][j] = test->unpacked[i][j][1]; - if (test->unpacked[i][j][0]) { - return TRUE; - } - } - } - - memset(packed, 0, sizeof packed); - - format_desc->pack_s_8uscaled(packed, 0, - &unpacked[0][0], sizeof unpacked[0], - format_desc->block.width, format_desc->block.height); - - success = TRUE; - for (i = 0; i < format_desc->block.bits/8; ++i) - if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i])) - success = FALSE; - - if (!success) { - print_packed(format_desc, "FAILED: ", packed, " obtained\n"); - print_packed(format_desc, " ", test->packed, " expected\n"); - } - - return success; -} - - -typedef boolean -(*test_func_t)(const struct util_format_description *format_desc, - const struct util_format_test_case *test); - - -static boolean -test_one_func(const struct util_format_description *format_desc, - test_func_t func, - const char *suffix) -{ - unsigned i; - bool success = TRUE; - - printf("Testing util_format_%s_%s ...\n", - format_desc->short_name, suffix); - - for (i = 0; i < util_format_nr_test_cases; ++i) { - const struct util_format_test_case *test = &util_format_test_cases[i]; - - if (test->format == format_desc->format) { - if (!func(format_desc, &util_format_test_cases[i])) { - success = FALSE; - } - } - } - - return success; -} - - -static boolean -test_all(void) -{ - enum pipe_format format; - bool success = TRUE; - - for (format = 1; format < PIPE_FORMAT_COUNT; ++format) { - const struct util_format_description *format_desc; - - format_desc = util_format_description(format); - if (!format_desc) { - continue; - } - - if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC && - !util_format_s3tc_enabled) { - continue; - } - -# define TEST_ONE_FUNC(name) \ - if (format_desc->name) { \ - if (!test_one_func(format_desc, &test_format_##name, #name)) { \ - success = FALSE; \ - } \ - } - - TEST_ONE_FUNC(fetch_rgba_float); - TEST_ONE_FUNC(pack_rgba_float); - TEST_ONE_FUNC(unpack_rgba_float); - TEST_ONE_FUNC(pack_rgba_8unorm); - TEST_ONE_FUNC(unpack_rgba_8unorm); - - TEST_ONE_FUNC(unpack_z_32unorm); - TEST_ONE_FUNC(pack_z_32unorm); - TEST_ONE_FUNC(unpack_z_float); - TEST_ONE_FUNC(pack_z_float); - TEST_ONE_FUNC(unpack_s_8uscaled); - TEST_ONE_FUNC(pack_s_8uscaled); - -# undef TEST_ONE_FUNC - } - - return success; -} - - -int main(int argc, char **argv) -{ - boolean success; - - util_format_s3tc_init(); - - success = test_all(); - - return success ? 0 : 1; -} diff --git a/src/gallium/tests/unit/u_half_test.c b/src/gallium/tests/unit/u_half_test.c deleted file mode 100644 index 00bda7f50a6..00000000000 --- a/src/gallium/tests/unit/u_half_test.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -#include "util/u_math.h" -#include "util/u_half.h" - -int -main(int argc, char **argv) -{ - unsigned i; - unsigned roundtrip_fails = 0; - for(i = 0; i < 1 << 16; ++i) - { - uint16_t h = (uint16_t) i; - union fi f; - uint16_t rh; - f.ui = util_half_to_floatui(h); - rh = util_floatui_to_half(f.ui); - if(h != rh) - { - printf("Roundtrip failed: %x -> %x = %f -> %x\n", h, f.ui, f.f, rh); - ++roundtrip_fails; - } - } - - if(roundtrip_fails) - printf("Failure! %u/65536 half floats failed a conversion to float and back.\n", roundtrip_fails); - else - printf("Success!\n"); - return 0; -} From 06a49b18729890417094aa9602c1cc1ea8b970e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 14 Jul 2010 00:51:18 +0200 Subject: [PATCH 03/36] fixed compilation --- src/gallium/state_trackers/vdpau/surface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c index 1f481098ede..2de2ee222c1 100644 --- a/src/gallium/state_trackers/vdpau/surface.c +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -94,6 +94,7 @@ vlVdpVideoSurfaceCreate(VdpDevice device, no_handle: FREE(p_surf->psurface); +inv_device: no_surf: FREE(p_surf); no_res: From c97ccc33531d4bf3f3154515317255645ada2afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Sun, 18 Jul 2010 23:42:49 +0200 Subject: [PATCH 04/36] Added decode.c --- src/gallium/state_trackers/vdpau/decode.c | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/gallium/state_trackers/vdpau/decode.c diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c new file mode 100644 index 00000000000..b85185d0ad0 --- /dev/null +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -0,0 +1,29 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "vdpau_private.h" + From 725e4ada3062c80623abf51477dfdc73fe294f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 20 Jul 2010 14:25:28 +0200 Subject: [PATCH 05/36] Made some decoding function for mpeg2-decoding --- src/gallium/auxiliary/vl/vl_compositor.c | 4 +- src/gallium/include/pipe/p_defines.h | 1 + src/gallium/include/pipe/p_video_state.h | 1 + src/gallium/state_trackers/vdpau/Makefile | 3 +- src/gallium/state_trackers/vdpau/decode.c | 185 ++++++++++++++++++ src/gallium/state_trackers/vdpau/device.c | 2 +- src/gallium/state_trackers/vdpau/query.c | 63 +++++- src/gallium/state_trackers/vdpau/surface.c | 89 ++++++--- .../state_trackers/vdpau/vdpau_private.h | 45 ++++- 9 files changed, 345 insertions(+), 48 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index 0640b1a4565..415dc92555f 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -627,8 +627,8 @@ void vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float pipe_buffer_map(compositor->pipe, compositor->fs_const_buf, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, &buf_transfer), - mat, - sizeof(struct fragment_shader_consts) + mat, + sizeof(struct fragment_shader_consts) ); pipe_buffer_unmap(compositor->pipe, compositor->fs_const_buf, diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 28318183183..26ba7b8002a 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -474,6 +474,7 @@ enum pipe_video_codec enum pipe_video_profile { + PIPE_VIDEO_PROFILE_UNKNOWN, PIPE_VIDEO_PROFILE_MPEG1, PIPE_VIDEO_PROFILE_MPEG2_SIMPLE, PIPE_VIDEO_PROFILE_MPEG2_MAIN, diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index 5eb96352139..1450f3488f9 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -74,6 +74,7 @@ enum pipe_mpeg12_dct_type PIPE_MPEG12_DCT_TYPE_FRAME }; + struct pipe_macroblock { enum pipe_video_codec codec; diff --git a/src/gallium/state_trackers/vdpau/Makefile b/src/gallium/state_trackers/vdpau/Makefile index 53378a9c1ff..a1b83abc6dd 100644 --- a/src/gallium/state_trackers/vdpau/Makefile +++ b/src/gallium/state_trackers/vdpau/Makefile @@ -15,7 +15,8 @@ C_SOURCES = htab.c \ ftab.c \ device.c \ query.c \ - surface.c + surface.c \ + decode.c include ../../Makefile.template diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index b85185d0ad0..8daf7a47f97 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -26,4 +26,189 @@ **************************************************************************/ #include "vdpau_private.h" +#include +#include +VdpStatus +vlVdpDecoderCreate ( VdpDevice device, + VdpDecoderProfile profile, + uint32_t width, uint32_t height, + uint32_t max_references, + VdpDecoder *decoder +) +{ + enum pipe_video_profile p_profile; + VdpStatus ret; + vlVdpDecoder *vldecoder; + + if (!decoder) + return VDP_STATUS_INVALID_POINTER; + + if (!(width && height)) + return VDP_STATUS_INVALID_VALUE; + + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) { + ret = VDP_STATUS_INVALID_HANDLE; + goto inv_device; + } + + vldecoder = CALLOC(1,sizeof(vlVdpDecoder)); + if (!vldecoder) { + ret = VDP_STATUS_RESOURCES; + goto no_decoder; + } + + vldecoder->vlscreen = vl_screen_create(dev->display, dev->screen); + if (!vldecoder->vlscreen) + ret = VDP_STATUS_RESOURCES; + goto no_screen; + + + p_profile = ProfileToPipe(profile); + if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) { + ret = VDP_STATUS_INVALID_DECODER_PROFILE; + goto inv_profile; + } + + // TODO: Define max_references. Used mainly for H264 + + vldecoder->chroma_format = p_profile; + vldecoder->device = dev; + + *decoder = vlAddDataHTAB(vldecoder); + if (*decoder == 0) { + ret = VDP_STATUS_ERROR; + goto no_handle; + } + + return VDP_STATUS_OK; + + no_handle: + FREE(vldecoder); + inv_profile: + no_screen: + no_decoder: + inv_device: + return ret; +} + +VdpStatus +vlVdpDecoderDestroy (VdpDecoder decoder +) +{ + vlVdpDecoder *vldecoder; + + vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder); + if (!vldecoder) { + return VDP_STATUS_INVALID_HANDLE; + } + + if (vldecoder->vctx) + vl_video_destroy(vldecoder->vctx); + + if (vldecoder->vlscreen) + vl_screen_destroy(vldecoder->vlscreen); + + FREE(vldecoder); + + return VDP_STATUS_OK; +} + +VdpStatus +vlVdpCreateSurface (vlVdpDecoder *vldecoder, + vlVdpSurface *vlsurf +) +{ + + return VDP_STATUS_OK; +} + +VdpStatus +vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, + vlVdpSurface *vlsurf, + VdpPictureInfoMPEG1Or2 *picture_info, + uint32_t bitstream_buffer_count, + VdpBitstreamBuffer const *bitstream_buffers + ) +{ + struct pipe_video_context *vpipe; + vlVdpSurface *t_vdp_surf; + vlVdpSurface *p_vdp_surf; + vlVdpSurface *f_vdp_surf; + struct pipe_surface *t_surf; + struct pipe_surface *p_surf; + struct pipe_surface *f_surf; + uint32_t num_macroblocks; + + vpipe = vldecoder->vctx->vpipe; + t_vdp_surf = vlsurf; + p_vdp_surf = (vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference); + if (p_vdp_surf) + return VDP_STATUS_INVALID_HANDLE; + + f_vdp_surf = (vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference); + if (f_vdp_surf) + return VDP_STATUS_INVALID_HANDLE; + + /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */ + if (p_vdp_surf == VDP_INVALID_HANDLE) p_vdp_surf = NULL; + if (f_vdp_surf == VDP_INVALID_HANDLE) f_vdp_surf = NULL; + + vlVdpCreateSurface(vldecoder,t_vdp_surf); + + num_macroblocks = picture_info->slice_count; + struct pipe_mpeg12_macroblock pipe_macroblocks[num_macroblocks]; + + /*VdpMacroBlocksToPipe(vpipe->screen, macroblocks, blocks, first_macroblock, + num_macroblocks, pipe_macroblocks);*/ + + vpipe->set_decode_target(vpipe,t_surf); + /*vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, + &pipe_macroblocks->base, &target_surface_priv->render_fence);*/ +} + +VdpStatus +vlVdpDecoderRender (VdpDecoder decoder, + VdpVideoSurface target, + VdpPictureInfo const *picture_info, + uint32_t bitstream_buffer_count, + VdpBitstreamBuffer const *bitstream_buffers +) +{ + vlVdpDecoder *vldecoder; + vlVdpSurface *vlsurf; + VdpStatus ret; + + if (!(picture_info && bitstream_buffers)) + return VDP_STATUS_INVALID_POINTER; + + + vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder); + if (!vldecoder) + return VDP_STATUS_INVALID_HANDLE; + + vlsurf = (vlVdpSurface *)vlGetDataHTAB(target); + if (!vlsurf) + return VDP_STATUS_INVALID_HANDLE; + + if (vlsurf->device != vldecoder->device) + return VDP_STATUS_HANDLE_DEVICE_MISMATCH; + + if (vlsurf->chroma_format != vldecoder->chroma_format) + return VDP_STATUS_INVALID_CHROMA_TYPE; + + // TODO: Right now only mpeg2 is supported. + switch (vldecoder->vctx->vpipe->profile) { + case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE: + case PIPE_VIDEO_PROFILE_MPEG2_MAIN: + ret = vlVdpDecoderRenderMpeg2(vldecoder,vlsurf,(VdpPictureInfoMPEG1Or2 *)picture_info, + bitstream_buffer_count,bitstream_buffers); + break; + default: + return VDP_STATUS_INVALID_DECODER_PROFILE; + } + assert(0); + + return ret; +} \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c index ba91e16a43f..111b15c619f 100644 --- a/src/gallium/state_trackers/vdpau/device.c +++ b/src/gallium/state_trackers/vdpau/device.c @@ -48,7 +48,7 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGe goto no_htab; } - dev = CALLOC(0, sizeof(vlVdpDevice)); + dev = CALLOC(1, sizeof(vlVdpDevice)); if (!dev) { ret = VDP_STATUS_RESOURCES; goto no_dev; diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c index 71793cc8ad5..eb7cfbcdd36 100644 --- a/src/gallium/state_trackers/vdpau/query.c +++ b/src/gallium/state_trackers/vdpau/query.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -56,6 +57,7 @@ VdpStatus vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type, VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) { + struct vl_screen *vlscreen; uint32_t max_2d_texture_level; VdpStatus ret; @@ -66,9 +68,8 @@ vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chrom if (!dev) return VDP_STATUS_INVALID_HANDLE; - if (!dev->vlscreen) - dev->vlscreen = vl_screen_create(dev->display, dev->screen); - if (!dev->vlscreen) + vlscreen = vl_screen_create(dev->display, dev->screen); + if (!vlscreen) return VDP_STATUS_RESOURCES; /* XXX: Current limits */ @@ -78,7 +79,7 @@ vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chrom goto no_sup; } - max_2d_texture_level = dev->vlscreen->pscreen->get_param( dev->vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS ); + max_2d_texture_level = vlscreen->pscreen->get_param( vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS ); if (!max_2d_texture_level) { ret = VDP_STATUS_RESOURCES; goto no_sup; @@ -87,6 +88,8 @@ vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chrom /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */ *max_width = *max_height = pow(2,max_2d_texture_level-1); + vl_screen_destroy(vlscreen); + return VDP_STATUS_OK; no_sup: return ret; @@ -97,6 +100,8 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp VdpYCbCrFormat bits_ycbcr_format, VdpBool *is_supported) { + struct vl_screen *vlscreen; + if (!is_supported) return VDP_STATUS_INVALID_POINTER; @@ -104,18 +109,19 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp if (!dev) return VDP_STATUS_INVALID_HANDLE; - if (!dev->vlscreen) - dev->vlscreen = vl_screen_create(dev->display, dev->screen); - if (!dev->vlscreen) + vlscreen = vl_screen_create(dev->display, dev->screen); + if (!vlscreen) return VDP_STATUS_RESOURCES; if (bits_ycbcr_format != VDP_YCBCR_FORMAT_Y8U8V8A8) - *is_supported = dev->vlscreen->pscreen->is_format_supported(dev->vlscreen->pscreen, + *is_supported = vlscreen->pscreen->is_format_supported(vlscreen->pscreen, FormatToPipe(bits_ycbcr_format), PIPE_TEXTURE_2D, PIPE_BIND_RENDER_TARGET, PIPE_TEXTURE_GEOM_NON_SQUARE ); + vl_screen_destroy(vlscreen); + return VDP_STATUS_OK; } @@ -124,10 +130,49 @@ vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile, VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks, uint32_t *max_width, uint32_t *max_height) { + enum pipe_video_profile p_profile; + uint32_t max_decode_width; + uint32_t max_decode_height; + uint32_t max_2d_texture_level; + struct vl_screen *vlscreen; + if (!(is_supported && max_level && max_macroblocks && max_width && max_height)) return VDP_STATUS_INVALID_POINTER; + + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) + return VDP_STATUS_INVALID_HANDLE; + + vlscreen = vl_screen_create(dev->display, dev->screen); + if (!vlscreen) + return VDP_STATUS_RESOURCES; - return VDP_STATUS_NO_IMPLEMENTATION; + p_profile = ProfileToPipe(profile); + if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) { + *is_supported = false; + return VDP_STATUS_OK; + } + + if (p_profile != PIPE_VIDEO_PROFILE_MPEG2_SIMPLE && p_profile != PIPE_VIDEO_PROFILE_MPEG2_MAIN) { + *is_supported = false; + return VDP_STATUS_OK; + } + + /* XXX hack, need to implement something more sane when the decoders have been implemented */ + max_2d_texture_level = vlscreen->pscreen->get_param( vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS ); + max_decode_width = max_decode_height = pow(2,max_2d_texture_level-2); + if (!(max_decode_width && max_decode_height)) + return VDP_STATUS_RESOURCES; + + *is_supported = true; + *max_width = max_decode_width; + *max_height = max_decode_height; + *max_level = 16; + *max_macroblocks = (max_decode_width/16) * (max_decode_height/16); + + vl_screen_destroy(vlscreen); + + return VDP_STATUS_OK; } VdpStatus diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c index 2de2ee222c1..18fe788f870 100644 --- a/src/gallium/state_trackers/vdpau/surface.c +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -29,6 +29,7 @@ #include #include #include +#include VdpStatus vlVdpVideoSurfaceCreate(VdpDevice device, @@ -52,37 +53,20 @@ vlVdpVideoSurfaceCreate(VdpDevice device, goto no_htab; } - p_surf = CALLOC(0, sizeof(p_surf)); + p_surf = CALLOC(1, sizeof(p_surf)); if (!p_surf) { ret = VDP_STATUS_RESOURCES; goto no_res; } - p_surf->psurface = CALLOC(0,sizeof(struct pipe_surface)); - if (!p_surf->psurface) { - ret = VDP_STATUS_RESOURCES; - goto no_surf; - } - vlVdpDevice *dev = vlGetDataHTAB(device); if (!dev) { ret = VDP_STATUS_INVALID_HANDLE; goto inv_device; } - if (!dev->vlscreen) - dev->vlscreen = vl_screen_create(dev->display, dev->screen); - if (!dev->vlscreen) { - ret = VDP_STATUS_RESOURCES; - goto inv_device; - } - - p_surf->psurface->height = height; - p_surf->psurface->width = width; - p_surf->psurface->level = 0; - p_surf->psurface->usage = PIPE_USAGE_DEFAULT; p_surf->chroma_format = FormatToPipe(chroma_type); - p_surf->vlscreen = dev->vlscreen; + p_surf->device = dev; *surface = vlAddDataHTAB(p_surf); if (*surface == 0) { @@ -113,9 +97,12 @@ vlVdpVideoSurfaceDestroy ( VdpVideoSurface surface ) if (!p_surf) return VDP_STATUS_INVALID_HANDLE; - if (p_surf->psurface) - p_surf->vlscreen->pscreen->tex_surface_destroy(p_surf->psurface); - + if (p_surf->psurface) { + if (p_surf->psurface->texture) { + if (p_surf->psurface->texture->screen) + p_surf->psurface->texture->screen->tex_surface_destroy(p_surf->psurface); + } + } FREE(p_surf); return VDP_STATUS_OK; } @@ -130,21 +117,17 @@ vlVdpVideoSurfaceGetParameters ( VdpVideoSurface surface, if (!(width && height && chroma_type)) return VDP_STATUS_INVALID_POINTER; - - if (!vlCreateHTAB()) - return VDP_STATUS_RESOURCES; - - + vlVdpSurface *p_surf = vlGetDataHTAB(surface); if (!p_surf) return VDP_STATUS_INVALID_HANDLE; - if (!(p_surf->psurface && p_surf->chroma_format)) - return VDP_STATUS_INVALID_HANDLE; + if (!(p_surf->chroma_format > 0 && p_surf->chroma_format < 3)) + return VDP_STATUS_INVALID_CHROMA_TYPE; - *width = p_surf->psurface->width; - *height = p_surf->psurface->height; + *width = p_surf->width; + *height = p_surf->height; *chroma_type = PipeToType(p_surf->chroma_format); return VDP_STATUS_OK; @@ -157,6 +140,50 @@ vlVdpVideoSurfaceGetBitsYCbCr ( VdpVideoSurface surface, uint32_t const *destination_pitches ) { + if (!vlCreateHTAB()) + return VDP_STATUS_RESOURCES; + + + vlVdpSurface *p_surf = vlGetDataHTAB(surface); + if (!p_surf) + return VDP_STATUS_INVALID_HANDLE; + + if (!p_surf->psurface) + return VDP_STATUS_RESOURCES; + + return VDP_STATUS_OK; +} + +VdpStatus +vlVdpVideoSurfacePutBitsYCbCr ( VdpVideoSurface surface, + VdpYCbCrFormat source_ycbcr_format, + void const *const *source_data, + uint32_t const *source_pitches +) +{ + uint32_t size_surface_bytes; + const struct util_format_description *format_desc; + enum pipe_format pformat = FormatToPipe(source_ycbcr_format); + + if (!vlCreateHTAB()) + return VDP_STATUS_RESOURCES; + + + vlVdpSurface *p_surf = vlGetDataHTAB(surface); + if (!p_surf) + return VDP_STATUS_INVALID_HANDLE; + + + //size_surface_bytes = ( source_pitches[0] * p_surf->height util_format_get_blockheight(pformat) ); + /*util_format_translate(enum pipe_format dst_format, + void *dst, unsigned dst_stride, + unsigned dst_x, unsigned dst_y, + enum pipe_format src_format, + const void *src, unsigned src_stride, + unsigned src_x, unsigned src_y, + unsigned width, unsigned height);*/ + + return VDP_STATUS_NO_IMPLEMENTATION; } diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index 27793892185..566c99266ed 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -116,21 +117,54 @@ static VdpYCbCrFormat PipeToFormat(enum pipe_format p_format) return -1; } +static enum pipe_video_profile ProfileToPipe(VdpDecoderProfile vdpau_profile) +{ + switch (vdpau_profile) { + case VDP_DECODER_PROFILE_MPEG1: + return PIPE_VIDEO_PROFILE_MPEG1; + case VDP_DECODER_PROFILE_MPEG2_SIMPLE: + return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE; + case VDP_DECODER_PROFILE_MPEG2_MAIN: + return PIPE_VIDEO_PROFILE_MPEG2_MAIN; + case VDP_DECODER_PROFILE_H264_BASELINE: + return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE; + case VDP_DECODER_PROFILE_H264_MAIN: /* Not defined in p_format.h */ + return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN; + case VDP_DECODER_PROFILE_H264_HIGH: + return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; + default: + PIPE_VIDEO_PROFILE_UNKNOWN; + } + + return -1; +} + typedef struct { void *display; int screen; - struct vl_screen *vlscreen; - struct vl_context *vctx; } vlVdpDevice; typedef struct { - struct vl_screen *vlscreen; + vlVdpDevice *device; + uint32_t width; + uint32_t height; + uint32_t pitch; struct pipe_surface *psurface; - enum pipe_video_chroma_format chroma_format; + enum pipe_format format; + enum pipe_video_chroma_format chroma_format; + uint8_t *data; } vlVdpSurface; +typedef struct +{ + vlVdpDevice *device; + struct vl_screen *vlscreen; + struct vl_context *vctx; + enum pipe_video_chroma_format chroma_format; +} vlVdpDecoder; + typedef uint32_t vlHandle; boolean vlCreateHTAB(void); @@ -160,5 +194,8 @@ VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy; VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters; VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr; VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr; +VdpDecoderCreate vlVdpDecoderCreate; +VdpDecoderDestroy vlVdpDecoderDestroy; +VdpDecoderRender vlVdpDecoderRender; #endif // VDPAU_PRIVATE_H \ No newline at end of file From 6ada38d29a9b6eb01ad21e9b1ec089bf42d497da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Thu, 22 Jul 2010 01:46:40 +0200 Subject: [PATCH 06/36] Added stubs for the rest of the vdpau interface --- src/gallium/state_trackers/vdpau/bitmap.c | 75 +++++++++++ src/gallium/state_trackers/vdpau/color.c | 0 src/gallium/state_trackers/vdpau/decode.c | 125 ++++++++++++++---- src/gallium/state_trackers/vdpau/device.c | 59 ++++++++- src/gallium/state_trackers/vdpau/ftab.c | 46 +++---- src/gallium/state_trackers/vdpau/mixer.c | 0 src/gallium/state_trackers/vdpau/output.c | 43 ++++++ src/gallium/state_trackers/vdpau/preemption.c | 0 .../state_trackers/vdpau/presentation.c | 121 +++++++++++++++++ src/gallium/state_trackers/vdpau/query.c | 18 ++- src/gallium/state_trackers/vdpau/render.c | 0 src/gallium/state_trackers/vdpau/surface.c | 3 + 12 files changed, 436 insertions(+), 54 deletions(-) create mode 100644 src/gallium/state_trackers/vdpau/bitmap.c create mode 100644 src/gallium/state_trackers/vdpau/color.c create mode 100644 src/gallium/state_trackers/vdpau/mixer.c create mode 100644 src/gallium/state_trackers/vdpau/output.c create mode 100644 src/gallium/state_trackers/vdpau/preemption.c create mode 100644 src/gallium/state_trackers/vdpau/presentation.c create mode 100644 src/gallium/state_trackers/vdpau/render.c diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c new file mode 100644 index 00000000000..f1a9d9a6828 --- /dev/null +++ b/src/gallium/state_trackers/vdpau/bitmap.c @@ -0,0 +1,75 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include +#include "vdpau_private.h" +#include + +VdpStatus +vlVdpBitmapSurfaceCreate( VdpDevice device, + VdpRGBAFormat rgba_format, + uint32_t width, uint32_t height, + VdpBool frequently_accessed, + VdpBitmapSurface *surface) +{ + debug_printf("[VDPAU] Creating a bitmap surface\n"); + if (!surface) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpBitmapSurfaceDestroy ( VdpBitmapSurface surface ) +{ + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpBitmapSurfaceGetParameters ( VdpBitmapSurface surface, + VdpRGBAFormat *rgba_format, + uint32_t *width, uint32_t *height, + VdpBool *frequently_accessed) +{ + if (!(rgba_format && width && height && frequently_accessed)) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpBitmapSurfacePutBitsNative ( VdpBitmapSurface surface, + void const *const *source_data, + uint32_t const *source_pitches, + VdpRect const *destination_rect ) +{ + if (!(source_data && source_pitches && destination_rect)) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/color.c b/src/gallium/state_trackers/vdpau/color.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index 8daf7a47f97..ec3995b98db 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -27,7 +27,9 @@ #include "vdpau_private.h" #include +#include #include +#include VdpStatus vlVdpDecoderCreate ( VdpDevice device, @@ -37,10 +39,13 @@ vlVdpDecoderCreate ( VdpDevice device, VdpDecoder *decoder ) { + struct vl_screen *vscreen; enum pipe_video_profile p_profile; VdpStatus ret; vlVdpDecoder *vldecoder; + debug_printf("[VDPAU] Creating decoder\n"); + if (!decoder) return VDP_STATUS_INVALID_POINTER; @@ -58,12 +63,6 @@ vlVdpDecoderCreate ( VdpDevice device, ret = VDP_STATUS_RESOURCES; goto no_decoder; } - - vldecoder->vlscreen = vl_screen_create(dev->display, dev->screen); - if (!vldecoder->vlscreen) - ret = VDP_STATUS_RESOURCES; - goto no_screen; - p_profile = ProfileToPipe(profile); if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) { @@ -73,7 +72,7 @@ vlVdpDecoderCreate ( VdpDevice device, // TODO: Define max_references. Used mainly for H264 - vldecoder->chroma_format = p_profile; + vldecoder->profile = p_profile; vldecoder->device = dev; *decoder = vlAddDataHTAB(vldecoder); @@ -81,6 +80,7 @@ vlVdpDecoderCreate ( VdpDevice device, ret = VDP_STATUS_ERROR; goto no_handle; } + debug_printf("[VDPAU] Decoder created succesfully\n"); return VDP_STATUS_OK; @@ -104,26 +104,76 @@ vlVdpDecoderDestroy (VdpDecoder decoder return VDP_STATUS_INVALID_HANDLE; } + if (vldecoder->vctx->vscreen) + vl_screen_destroy(vldecoder->vctx->vscreen); + if (vldecoder->vctx) vl_video_destroy(vldecoder->vctx); - if (vldecoder->vlscreen) - vl_screen_destroy(vldecoder->vlscreen); - FREE(vldecoder); return VDP_STATUS_OK; } VdpStatus -vlVdpCreateSurface (vlVdpDecoder *vldecoder, +vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder, vlVdpSurface *vlsurf ) { + struct pipe_resource tmplt; + struct pipe_resource *surf_tex; + struct pipe_video_context *vpipe; + + if(!(vldecoder && vlsurf)) + return VDP_STATUS_INVALID_POINTER; + + vpipe = vldecoder->vctx; + + memset(&tmplt, 0, sizeof(struct pipe_resource)); + tmplt.target = PIPE_TEXTURE_2D; + tmplt.format = vlsurf->format; + tmplt.last_level = 0; + if (vpipe->is_format_supported(vpipe, tmplt.format, + PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET, + PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO)) { + tmplt.width0 = vlsurf->width; + tmplt.height0 = vlsurf->height; + } + else { + assert(vpipe->is_format_supported(vpipe, tmplt.format, + PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET, + PIPE_TEXTURE_GEOM_NON_SQUARE)); + tmplt.width0 = util_next_power_of_two(vlsurf->width); + tmplt.height0 = util_next_power_of_two(vlsurf->height); + } + tmplt.depth0 = 1; + tmplt.usage = PIPE_USAGE_DEFAULT; + tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; + tmplt.flags = 0; + + surf_tex = vpipe->screen->resource_create(vpipe->screen, &tmplt); + + vlsurf->psurface = vpipe->screen->get_tex_surface(vpipe->screen, surf_tex, 0, 0, 0, + PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET); + + pipe_resource_reference(&surf_tex, NULL); + + if (!vlsurf->psurface) + return VDP_STATUS_RESOURCES; + return VDP_STATUS_OK; } +static void +vlVdpMacroBlocksToPipe(struct pipe_screen *screen, + VdpBitstreamBuffer const *bitstream_buffers, + unsigned int num_macroblocks, + struct pipe_mpeg12_macroblock *pipe_macroblocks) +{ + debug_printf("NAF!\n"); +} + VdpStatus vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, vlVdpSurface *vlsurf, @@ -140,32 +190,43 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, struct pipe_surface *p_surf; struct pipe_surface *f_surf; uint32_t num_macroblocks; + VdpStatus ret; + vpipe = vldecoder->vctx->vpipe; t_vdp_surf = vlsurf; - p_vdp_surf = (vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference); - if (p_vdp_surf) - return VDP_STATUS_INVALID_HANDLE; - - f_vdp_surf = (vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference); - if (f_vdp_surf) - return VDP_STATUS_INVALID_HANDLE; - + /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */ - if (p_vdp_surf == VDP_INVALID_HANDLE) p_vdp_surf = NULL; + if (picture_info->backward_reference == VDP_INVALID_HANDLE) + p_vdp_surf = NULL; + else { + p_vdp_surf = (vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference); + if (!p_vdp_surf) + return VDP_STATUS_INVALID_HANDLE; + } + + if (picture_info->forward_reference == VDP_INVALID_HANDLE) + f_vdp_surf = NULL; + else { + f_vdp_surf = (vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference); + if (!f_vdp_surf) + return VDP_STATUS_INVALID_HANDLE; + } + + if (f_vdp_surf == VDP_INVALID_HANDLE) f_vdp_surf = NULL; - vlVdpCreateSurface(vldecoder,t_vdp_surf); + ret = vlVdpCreateSurfaceTarget(vldecoder,t_vdp_surf); - num_macroblocks = picture_info->slice_count; + num_macroblocks = bitstream_buffer_count; struct pipe_mpeg12_macroblock pipe_macroblocks[num_macroblocks]; - /*VdpMacroBlocksToPipe(vpipe->screen, macroblocks, blocks, first_macroblock, - num_macroblocks, pipe_macroblocks);*/ + vlVdpMacroBlocksToPipe(vpipe->screen, bitstream_buffers, + num_macroblocks, pipe_macroblocks); vpipe->set_decode_target(vpipe,t_surf); - /*vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, - &pipe_macroblocks->base, &target_surface_priv->render_fence);*/ + vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, &pipe_macroblocks->base, NULL); + return ret; } VdpStatus @@ -178,7 +239,9 @@ vlVdpDecoderRender (VdpDecoder decoder, { vlVdpDecoder *vldecoder; vlVdpSurface *vlsurf; + struct vl_screen *vscreen; VdpStatus ret; + debug_printf("[VDPAU] Decoding\n"); if (!(picture_info && bitstream_buffers)) return VDP_STATUS_INVALID_POINTER; @@ -198,6 +261,16 @@ vlVdpDecoderRender (VdpDecoder decoder, if (vlsurf->chroma_format != vldecoder->chroma_format) return VDP_STATUS_INVALID_CHROMA_TYPE; + vscreen = vl_screen_create(vldecoder->device->display, vldecoder->device->screen); + if (!vscreen) + return VDP_STATUS_RESOURCES; + + vldecoder->vctx = vl_video_create(vscreen, vldecoder->profile, vlsurf->format, vlsurf->width, vlsurf->height); + if (!vldecoder->vctx) + return VDP_STATUS_RESOURCES; + + vldecoder->vctx->vscreen = vscreen; + // TODO: Right now only mpeg2 is supported. switch (vldecoder->vctx->vpipe->profile) { case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE: diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c index 111b15c619f..d370d1c6610 100644 --- a/src/gallium/state_trackers/vdpau/device.c +++ b/src/gallium/state_trackers/vdpau/device.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "vdpau_private.h" VdpDeviceCreateX11 vdp_imp_device_create_x11; @@ -56,7 +57,6 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGe dev->display = display; dev->screen = screen; - *device = vlAddDataHTAB(dev); if (*device == 0) { ret = VDP_STATUS_ERROR; @@ -64,6 +64,8 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGe } *get_proc_address = &vlVdpGetProcAddress; + + debug_printf("[VDPAU] Device created succesfully\n"); return VDP_STATUS_OK; @@ -75,7 +77,8 @@ no_htab: return ret; } -VdpStatus vlVdpDeviceDestroy(VdpDevice device) +VdpStatus +vlVdpDeviceDestroy(VdpDevice device) { vlVdpDevice *dev = vlGetDataHTAB(device); if (!dev) @@ -83,10 +86,13 @@ VdpStatus vlVdpDeviceDestroy(VdpDevice device) FREE(dev); vlDestroyHTAB(); + debug_printf("[VDPAU] Device destroyed succesfully\n"); + return VDP_STATUS_OK; } -VdpStatus vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer) +VdpStatus +vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer) { vlVdpDevice *dev = vlGetDataHTAB(device); if (!dev) @@ -100,3 +106,50 @@ VdpStatus vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **fu return VDP_STATUS_OK; } + +#define _ERROR_TYPE(TYPE,STRING) \ + case TYPE: \ + return STRING; \ + break + +char const * +vlVdpGetErrorString ( +VdpStatus status) +{ + switch (status) + { + _ERROR_TYPE(VDP_STATUS_OK,"The operation completed successfully; no error."); + _ERROR_TYPE(VDP_STATUS_NO_IMPLEMENTATION,"No backend implementation could be loaded."); + _ERROR_TYPE(VDP_STATUS_DISPLAY_PREEMPTED,"The display was preempted, or a fatal error occurred. The application must re-initialize VDPAU."); + _ERROR_TYPE(VDP_STATUS_INVALID_HANDLE,"An invalid handle value was provided. Either the handle does not exist at all, or refers to an object of an incorrect type."); + _ERROR_TYPE(VDP_STATUS_INVALID_POINTER ,"An invalid pointer was provided. Typically, this means that a NULL pointer was provided for an 'output' parameter."); + _ERROR_TYPE(VDP_STATUS_INVALID_CHROMA_TYPE ,"An invalid/unsupported VdpChromaType value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_Y_CB_CR_FORMAT,"An invalid/unsupported VdpYCbCrFormat value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_RGBA_FORMAT,"An invalid/unsupported VdpRGBAFormat value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_INDEXED_FORMAT,"An invalid/unsupported VdpIndexedFormat value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_STANDARD,"An invalid/unsupported VdpColorStandard value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_TABLE_FORMAT,"An invalid/unsupported VdpColorTableFormat value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_FACTOR,"An invalid/unsupported VdpOutputSurfaceRenderBlendFactor value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_EQUATION,"An invalid/unsupported VdpOutputSurfaceRenderBlendEquation value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_FLAG,"An invalid/unsupported flag value/combination was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_DECODER_PROFILE,"An invalid/unsupported VdpDecoderProfile value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE,"An invalid/unsupported VdpVideoMixerFeature value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER ,"An invalid/unsupported VdpVideoMixerParameter value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE,"An invalid/unsupported VdpVideoMixerAttribute value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE,"An invalid/unsupported VdpVideoMixerPictureStructure value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_FUNC_ID,"An invalid/unsupported VdpFuncId value was supplied."); + _ERROR_TYPE(VDP_STATUS_INVALID_SIZE,"The size of a supplied object does not match the object it is being used with.\ + For example, a VdpVideoMixer is configured to process VdpVideoSurface objects of a specific size.\ + If presented with a VdpVideoSurface of a different size, this error will be raised."); + _ERROR_TYPE(VDP_STATUS_INVALID_VALUE,"An invalid/unsupported value was supplied.\ + This is a catch-all error code for values of type other than those with a specific error code."); + _ERROR_TYPE(VDP_STATUS_INVALID_STRUCT_VERSION,"An invalid/unsupported structure version was specified in a versioned structure. \ + This implies that the implementation is older than the header file the application was built against."); + _ERROR_TYPE(VDP_STATUS_RESOURCES,"The system does not have enough resources to complete the requested operation at this time."); + _ERROR_TYPE(VDP_STATUS_HANDLE_DEVICE_MISMATCH,"The set of handles supplied are not all related to the same VdpDevice.When performing operations \ + that operate on multiple surfaces, such as VdpOutputSurfaceRenderOutputSurface or VdpVideoMixerRender, \ + all supplied surfaces must have been created within the context of the same VdpDevice object. \ + This error is raised if they were not."); + _ERROR_TYPE(VDP_STATUS_ERROR,"A catch-all error, used when no other error code applies."); + } +} diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c index 7e476e5ee28..1842c4da0ea 100644 --- a/src/gallium/state_trackers/vdpau/ftab.c +++ b/src/gallium/state_trackers/vdpau/ftab.c @@ -30,8 +30,8 @@ static void* ftab[67] = { - 0, /* VDP_FUNC_ID_GET_ERROR_STRING */ - 0, /* VDP_FUNC_ID_GET_PROC_ADDRESS */ + &vlVdpGetErrorString, /* VDP_FUNC_ID_GET_ERROR_STRING */ + &vlVdpGetProcAddress, /* VDP_FUNC_ID_GET_PROC_ADDRESS */ &vlVdpGetApiVersion, /* VDP_FUNC_ID_GET_API_VERSION */ 0, &vlVdpGetInformationString, /* VDP_FUNC_ID_GET_INFORMATION_STRING */ @@ -40,15 +40,15 @@ static void* ftab[67] = &vlVdpVideoSurfaceQueryCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES */ &vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES */ &vlVdpVideoSurfaceCreate, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */ - 0, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */ - 0, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */ - 0, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */ - 0, /* VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR */ + &vlVdpVideoSurfaceDestroy, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */ + &vlVdpVideoSurfaceGetParameters, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */ + &vlVdpVideoSurfaceGetBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */ + &vlVdpVideoSurfacePutBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR */ &vlVdpOutputSurfaceQueryCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES */ &vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES */ 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES */ &vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_CREATE */ + &vlVdpOutputSurfaceCreate, /* VDP_FUNC_ID_OUTPUT_SURFACE_CREATE */ 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY */ 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS */ 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE */ @@ -56,10 +56,10 @@ static void* ftab[67] = 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED */ 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR */ &vlVdpBitmapSurfaceQueryCapabilities, /* VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES */ - 0, /* VDP_FUNC_ID_BITMAP_SURFACE_CREATE */ - 0, /* VDP_FUNC_ID_BITMAP_SURFACE_DESTROY */ - 0, /* VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS */ - 0, /* VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE */ + &vlVdpBitmapSurfaceCreate, /* VDP_FUNC_ID_BITMAP_SURFACE_CREATE */ + &vlVdpBitmapSurfaceDestroy, /* VDP_FUNC_ID_BITMAP_SURFACE_DESTROY */ + &vlVdpBitmapSurfaceGetParameters, /* VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS */ + &vlVdpBitmapSurfacePutBitsNative, /* VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE */ 0, 0, 0, @@ -67,10 +67,10 @@ static void* ftab[67] = 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE */ 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_VIDEO_SURFACE_LUMA */ &vlVdpDecoderQueryCapabilities, /* VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES */ - 0, /* VDP_FUNC_ID_DECODER_CREATE */ - 0, /* VDP_FUNC_ID_DECODER_DESTROY */ + &vlVdpDecoderCreate, /* VDP_FUNC_ID_DECODER_CREATE */ + &vlVdpDecoderDestroy, /* VDP_FUNC_ID_DECODER_DESTROY */ 0, /* VDP_FUNC_ID_DECODER_GET_PARAMETERS */ - 0, /* VDP_FUNC_ID_DECODER_RENDER */ + &vlVdpDecoderRender, /* VDP_FUNC_ID_DECODER_RENDER */ &vlVdpVideoMixerQueryFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT */ &vlVdpVideoMixerQueryParameterSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT */ &vlVdpVideoMixerQueryAttributeSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT */ @@ -85,17 +85,17 @@ static void* ftab[67] = 0, /* VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES */ 0, /* VDP_FUNC_ID_VIDEO_MIXER_DESTROY */ 0, /* VDP_FUNC_ID_VIDEO_MIXER_RENDER */ - 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY */ - 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE */ - 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY */ - 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR */ - 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR */ + &vlVdpPresentationQueueTargetDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY */ + &vlVdpPresentationQueueCreate, /* VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE */ + &vlVdpPresentationQueueDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY */ + &vlVdpPresentationQueueSetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR */ + &vlVdpPresentationQueueGetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR */ 0, 0, - 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME */ - 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY */ - 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE */ - 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS */ + &vlVdpPresentationQueueGetTime, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME */ + &vlVdpPresentationQueueDisplay, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY */ + &vlVdpPresentationQueueBlockUntilSurfaceIdle, /* VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE */ + &vlVdpPresentationQueueQuerySurfaceStatus, /* VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS */ 0 /* VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER */ }; diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c new file mode 100644 index 00000000000..c5f06896c58 --- /dev/null +++ b/src/gallium/state_trackers/vdpau/output.c @@ -0,0 +1,43 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "vdpau_private.h" +#include +#include + +VdpStatus +vlVdpOutputSurfaceCreate ( VdpDevice device, + VdpRGBAFormat rgba_format, + uint32_t width, uint32_t height, + VdpOutputSurface *surface) +{ + debug_printf("[VDPAU] Creating output surface\n"); + if (!(width && height)) + return VDP_STATUS_INVALID_SIZE; + + return VDP_STATUS_NO_IMPLEMENTATION; +} \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/preemption.c b/src/gallium/state_trackers/vdpau/preemption.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c new file mode 100644 index 00000000000..8200cf04326 --- /dev/null +++ b/src/gallium/state_trackers/vdpau/presentation.c @@ -0,0 +1,121 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "vdpau_private.h" +#include +#include + +VdpStatus +vlVdpPresentationQueueTargetDestroy (VdpPresentationQueueTarget presentation_queue_target) +{ + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpPresentationQueueCreate ( VdpDevice device, + VdpPresentationQueueTarget presentation_queue_target, + VdpPresentationQueue *presentation_queue) +{ + debug_printf("[VDPAU] Creating presentation queue\n"); + + if (!presentation_queue) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpPresentationQueueDestroy (VdpPresentationQueue presentation_queue) +{ + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpPresentationQueueSetBackgroundColor ( VdpPresentationQueue presentation_queue, + VdpColor *const background_color) +{ + if (!background_color) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpPresentationQueueGetBackgroundColor ( VdpPresentationQueue presentation_queue, + VdpColor *const background_color) +{ + if (!background_color) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpPresentationQueueGetTime ( VdpPresentationQueue presentation_queue, + VdpTime *current_time) +{ + if (!current_time) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpPresentationQueueDisplay ( VdpPresentationQueue presentation_queue, + VdpOutputSurface surface, + uint32_t clip_width, + uint32_t clip_height, + VdpTime earliest_presentation_time) +{ + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpPresentationQueueBlockUntilSurfaceIdle ( VdpPresentationQueue presentation_queue, + VdpOutputSurface surface, + VdpTime *first_presentation_time) +{ + if (!first_presentation_time) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpPresentationQueueQuerySurfaceStatus ( VdpPresentationQueue presentation_queue, + VdpOutputSurface surface, + VdpPresentationQueueStatus *status, + VdpTime *first_presentation_time) +{ + if (!(status && first_presentation_time)) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c index eb7cfbcdd36..86b5098f178 100644 --- a/src/gallium/state_trackers/vdpau/query.c +++ b/src/gallium/state_trackers/vdpau/query.c @@ -31,6 +31,7 @@ #include #include #include +#include VdpStatus @@ -60,6 +61,8 @@ vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chrom struct vl_screen *vlscreen; uint32_t max_2d_texture_level; VdpStatus ret; + + debug_printf("[VDPAU] Querying video surfaces\n"); if (!(is_supported && max_width && max_height)) return VDP_STATUS_INVALID_POINTER; @@ -102,6 +105,8 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp { struct vl_screen *vlscreen; + debug_printf("[VDPAU] Querying get put video surfaces\n"); + if (!is_supported) return VDP_STATUS_INVALID_POINTER; @@ -113,7 +118,7 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp if (!vlscreen) return VDP_STATUS_RESOURCES; - if (bits_ycbcr_format != VDP_YCBCR_FORMAT_Y8U8V8A8) + if (bits_ycbcr_format != VDP_YCBCR_FORMAT_Y8U8V8A8 && bits_ycbcr_format != VDP_YCBCR_FORMAT_V8U8Y8A8) *is_supported = vlscreen->pscreen->is_format_supported(vlscreen->pscreen, FormatToPipe(bits_ycbcr_format), PIPE_TEXTURE_2D, @@ -135,6 +140,8 @@ vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile, uint32_t max_decode_height; uint32_t max_2d_texture_level; struct vl_screen *vlscreen; + + debug_printf("[VDPAU] Querying decoder\n"); if (!(is_supported && max_level && max_macroblocks && max_width && max_height)) return VDP_STATUS_INVALID_POINTER; @@ -178,9 +185,11 @@ vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile, VdpStatus vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) -{ +{ if (!(is_supported && max_width && max_height)) return VDP_STATUS_INVALID_POINTER; + + debug_printf("[VDPAU] Querying ouput surfaces\n"); return VDP_STATUS_NO_IMPLEMENTATION; } @@ -189,6 +198,8 @@ VdpStatus vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, VdpBool *is_supported) { + debug_printf("[VDPAU] Querying output surfaces get put native cap\n"); + if (!is_supported) return VDP_STATUS_INVALID_POINTER; @@ -200,6 +211,7 @@ vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat VdpYCbCrFormat bits_ycbcr_format, VdpBool *is_supported) { + debug_printf("[VDPAU] Querying output surfaces put ycrcb cap\n"); if (!is_supported) return VDP_STATUS_INVALID_POINTER; @@ -210,6 +222,7 @@ VdpStatus vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) { + debug_printf("[VDPAU] Querying bitmap surfaces\n"); if (!(is_supported && max_width && max_height)) return VDP_STATUS_INVALID_POINTER; @@ -220,6 +233,7 @@ VdpStatus vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature, VdpBool *is_supported) { + debug_printf("[VDPAU] Querying mixer feature support\n"); if (!is_supported) return VDP_STATUS_INVALID_POINTER; diff --git a/src/gallium/state_trackers/vdpau/render.c b/src/gallium/state_trackers/vdpau/render.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c index 18fe788f870..89437c89e44 100644 --- a/src/gallium/state_trackers/vdpau/surface.c +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -30,6 +30,7 @@ #include #include #include +#include VdpStatus vlVdpVideoSurfaceCreate(VdpDevice device, @@ -38,6 +39,8 @@ vlVdpVideoSurfaceCreate(VdpDevice device, uint32_t height, VdpVideoSurface *surface) { + printf("[VDPAU] Creating a surface\n"); + vlVdpSurface *p_surf; VdpStatus ret; From 966b836e2d5142e01b0286c864ca4a6f1be5b706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Sun, 1 Aug 2010 11:10:19 +0200 Subject: [PATCH 07/36] Stubs for the bitstream mpeg2 decoder --- .../vdpau/mpeg2_bitstream_parser.c | 0 .../vdpau/mpeg2_bitstream_parser.h | 33 +++ src/gallium/state_trackers/vdpau/surface.c | 192 ------------------ 3 files changed, 33 insertions(+), 192 deletions(-) create mode 100644 src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c create mode 100644 src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h delete mode 100644 src/gallium/state_trackers/vdpau/surface.c diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h new file mode 100644 index 00000000000..85a4b2fdf01 --- /dev/null +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h @@ -0,0 +1,33 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef MPEG2_BITSTREAM_PARSER_H +#define MPEG2_BITSTREAM_PARSER_H + + + +#endif // MPEG2_BITSTREAM_PARSER_H diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c deleted file mode 100644 index 89437c89e44..00000000000 --- a/src/gallium/state_trackers/vdpau/surface.c +++ /dev/null @@ -1,192 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Thomas Balling Sørensen. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "vdpau_private.h" -#include -#include -#include -#include -#include - -VdpStatus -vlVdpVideoSurfaceCreate(VdpDevice device, - VdpChromaType chroma_type, - uint32_t width, - uint32_t height, - VdpVideoSurface *surface) -{ - printf("[VDPAU] Creating a surface\n"); - - vlVdpSurface *p_surf; - VdpStatus ret; - - if (!(width && height)) - { - ret = VDP_STATUS_INVALID_SIZE; - goto inv_size; - } - - - if (!vlCreateHTAB()) { - ret = VDP_STATUS_RESOURCES; - goto no_htab; - } - - p_surf = CALLOC(1, sizeof(p_surf)); - if (!p_surf) { - ret = VDP_STATUS_RESOURCES; - goto no_res; - } - - vlVdpDevice *dev = vlGetDataHTAB(device); - if (!dev) { - ret = VDP_STATUS_INVALID_HANDLE; - goto inv_device; - } - - p_surf->chroma_format = FormatToPipe(chroma_type); - p_surf->device = dev; - - *surface = vlAddDataHTAB(p_surf); - if (*surface == 0) { - ret = VDP_STATUS_ERROR; - goto no_handle; - } - - return VDP_STATUS_OK; - -no_handle: - FREE(p_surf->psurface); -inv_device: -no_surf: - FREE(p_surf); -no_res: - // vlDestroyHTAB(); XXX: Do not destroy this tab, I think. -no_htab: -inv_size: - return ret; -} - -VdpStatus -vlVdpVideoSurfaceDestroy ( VdpVideoSurface surface ) -{ - vlVdpSurface *p_surf; - - p_surf = (vlVdpSurface *)vlGetDataHTAB((vlHandle)surface); - if (!p_surf) - return VDP_STATUS_INVALID_HANDLE; - - if (p_surf->psurface) { - if (p_surf->psurface->texture) { - if (p_surf->psurface->texture->screen) - p_surf->psurface->texture->screen->tex_surface_destroy(p_surf->psurface); - } - } - FREE(p_surf); - return VDP_STATUS_OK; -} - -VdpStatus -vlVdpVideoSurfaceGetParameters ( VdpVideoSurface surface, - VdpChromaType *chroma_type, - uint32_t *width, - uint32_t *height -) -{ - if (!(width && height && chroma_type)) - return VDP_STATUS_INVALID_POINTER; - - - vlVdpSurface *p_surf = vlGetDataHTAB(surface); - if (!p_surf) - return VDP_STATUS_INVALID_HANDLE; - - - if (!(p_surf->chroma_format > 0 && p_surf->chroma_format < 3)) - return VDP_STATUS_INVALID_CHROMA_TYPE; - - *width = p_surf->width; - *height = p_surf->height; - *chroma_type = PipeToType(p_surf->chroma_format); - - return VDP_STATUS_OK; -} - -VdpStatus -vlVdpVideoSurfaceGetBitsYCbCr ( VdpVideoSurface surface, - VdpYCbCrFormat destination_ycbcr_format, - void *const *destination_data, - uint32_t const *destination_pitches -) -{ - if (!vlCreateHTAB()) - return VDP_STATUS_RESOURCES; - - - vlVdpSurface *p_surf = vlGetDataHTAB(surface); - if (!p_surf) - return VDP_STATUS_INVALID_HANDLE; - - if (!p_surf->psurface) - return VDP_STATUS_RESOURCES; - - - return VDP_STATUS_OK; -} - -VdpStatus -vlVdpVideoSurfacePutBitsYCbCr ( VdpVideoSurface surface, - VdpYCbCrFormat source_ycbcr_format, - void const *const *source_data, - uint32_t const *source_pitches -) -{ - uint32_t size_surface_bytes; - const struct util_format_description *format_desc; - enum pipe_format pformat = FormatToPipe(source_ycbcr_format); - - if (!vlCreateHTAB()) - return VDP_STATUS_RESOURCES; - - - vlVdpSurface *p_surf = vlGetDataHTAB(surface); - if (!p_surf) - return VDP_STATUS_INVALID_HANDLE; - - - //size_surface_bytes = ( source_pitches[0] * p_surf->height util_format_get_blockheight(pformat) ); - /*util_format_translate(enum pipe_format dst_format, - void *dst, unsigned dst_stride, - unsigned dst_x, unsigned dst_y, - enum pipe_format src_format, - const void *src, unsigned src_stride, - unsigned src_x, unsigned src_y, - unsigned width, unsigned height);*/ - - return VDP_STATUS_NO_IMPLEMENTATION; - -} From 09a10be4db1e5605cb93a6e54d1475d4ebbaa3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 4 Aug 2010 11:07:26 +0200 Subject: [PATCH 08/36] Fixed an endianproblem --- .../auxiliary/vl/vl_bitstream_parser.c | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_bitstream_parser.c b/src/gallium/auxiliary/vl/vl_bitstream_parser.c index 3193ea5f41c..f07b3443b92 100644 --- a/src/gallium/auxiliary/vl/vl_bitstream_parser.c +++ b/src/gallium/auxiliary/vl/vl_bitstream_parser.c @@ -29,17 +29,58 @@ #include #include #include +#include + +inline void endian_swap_ushort(unsigned short *x) +{ + x[0] = (x[0]>>8) | + (x[0]<<8); +} + +inline void endian_swap_uint(unsigned int *x) +{ + x[0] = (x[0]>>24) | + ((x[0]<<8) & 0x00FF0000) | + ((x[0]>>8) & 0x0000FF00) | + (x[0]<<24); +} + +inline void endian_swap_ulonglong(unsigned long long *x) +{ + x[0] = (x[0]>>56) | + ((x[0]<<40) & 0x00FF000000000000) | + ((x[0]<<24) & 0x0000FF0000000000) | + ((x[0]<<8) & 0x000000FF00000000) | + ((x[0]>>8) & 0x00000000FF000000) | + ((x[0]>>24) & 0x0000000000FF0000) | + ((x[0]>>40) & 0x000000000000FF00) | + (x[0]<<56); +} static unsigned grab_bits(unsigned cursor, unsigned how_many_bits, unsigned bitstream_elt) { - unsigned excess_bits = sizeof(unsigned) * CHAR_BIT - how_many_bits - cursor; + unsigned excess_bits = sizeof(unsigned) * CHAR_BIT - how_many_bits; assert(cursor < sizeof(unsigned) * CHAR_BIT); assert(how_many_bits > 0 && how_many_bits <= sizeof(unsigned) * CHAR_BIT); assert(cursor + how_many_bits <= sizeof(unsigned) * CHAR_BIT); - - return (bitstream_elt << excess_bits) >> (excess_bits + cursor); + + #ifndef PIPE_ARCH_BIG_ENDIAN + switch (sizeof(unsigned)) { + case 2: + endian_swap_ushort(&bitstream_elt); + break; + case 4: + endian_swap_uint(&bitstream_elt); + break; + case 8: + endian_swap_ulonglong(&bitstream_elt); + break; + } + #endif // !PIPE_ARCH_BIG_ENDIAN + + return (bitstream_elt << cursor) >> (excess_bits); } static unsigned From 5386a8a2e012aafa8a2a02df83e2c4c19ec1f8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 21 Sep 2010 15:23:52 +0200 Subject: [PATCH 09/36] vl: Various cleanups. Need to start from scratch with bitstream parser --- src/gallium/state_trackers/vdpau/header.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/gallium/state_trackers/vdpau/header.c diff --git a/src/gallium/state_trackers/vdpau/header.c b/src/gallium/state_trackers/vdpau/header.c new file mode 100644 index 00000000000..e69de29bb2d From c5b6f7d16699cfda696538890a9c1744847bb434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 21 Sep 2010 19:20:00 +0200 Subject: [PATCH 10/36] vl: Made the project compile again. --- src/gallium/state_trackers/vdpau/Makefile | 4 +- src/gallium/state_trackers/vdpau/surface.c | 192 ++++++++++++++++++ .../state_trackers/vdpau/vdpau_private.h | 21 +- 3 files changed, 213 insertions(+), 4 deletions(-) create mode 100644 src/gallium/state_trackers/vdpau/surface.c diff --git a/src/gallium/state_trackers/vdpau/Makefile b/src/gallium/state_trackers/vdpau/Makefile index a1b83abc6dd..6313ef34b38 100644 --- a/src/gallium/state_trackers/vdpau/Makefile +++ b/src/gallium/state_trackers/vdpau/Makefile @@ -16,7 +16,9 @@ C_SOURCES = htab.c \ device.c \ query.c \ surface.c \ - decode.c + decode.c \ + presentation.c \ + bitmap.c include ../../Makefile.template diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c new file mode 100644 index 00000000000..f957d94bdf7 --- /dev/null +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -0,0 +1,192 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "vdpau_private.h" +#include +#include +#include +#include +#include + +VdpStatus +vlVdpVideoSurfaceCreate(VdpDevice device, + VdpChromaType chroma_type, + uint32_t width, + uint32_t height, + VdpVideoSurface *surface) +{ + printf("[VDPAU] Creating a surface\n"); + + vlVdpSurface *p_surf; + VdpStatus ret; + + if (!(width && height)) + { + ret = VDP_STATUS_INVALID_SIZE; + goto inv_size; + } + + + if (!vlCreateHTAB()) { + ret = VDP_STATUS_RESOURCES; + goto no_htab; + } + + p_surf = CALLOC(1, sizeof(p_surf)); + if (!p_surf) { + ret = VDP_STATUS_RESOURCES; + goto no_res; + } + + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) { + ret = VDP_STATUS_INVALID_HANDLE; + goto inv_device; + } + + p_surf->chroma_format = FormatToPipe(chroma_type); + p_surf->device = dev; + + *surface = vlAddDataHTAB(p_surf); + if (*surface == 0) { + ret = VDP_STATUS_ERROR; + goto no_handle; + } + + return VDP_STATUS_OK; + +no_handle: + FREE(p_surf->psurface); +inv_device: +no_surf: + FREE(p_surf); +no_res: + // vlDestroyHTAB(); XXX: Do not destroy this tab, I think. +no_htab: +inv_size: + return ret; +} + +VdpStatus +vlVdpVideoSurfaceDestroy ( VdpVideoSurface surface ) +{ + vlVdpSurface *p_surf; + + p_surf = (vlVdpSurface *)vlGetDataHTAB((vlHandle)surface); + if (!p_surf) + return VDP_STATUS_INVALID_HANDLE; + + if (p_surf->psurface) { + if (p_surf->psurface->texture) { + if (p_surf->psurface->texture->screen) + p_surf->psurface->texture->screen->tex_surface_destroy(p_surf->psurface); + } + } + FREE(p_surf); + return VDP_STATUS_OK; +} + +VdpStatus +vlVdpVideoSurfaceGetParameters ( VdpVideoSurface surface, + VdpChromaType *chroma_type, + uint32_t *width, + uint32_t *height +) +{ + if (!(width && height && chroma_type)) + return VDP_STATUS_INVALID_POINTER; + + + vlVdpSurface *p_surf = vlGetDataHTAB(surface); + if (!p_surf) + return VDP_STATUS_INVALID_HANDLE; + + + if (!(p_surf->chroma_format > 0 && p_surf->chroma_format < 3)) + return VDP_STATUS_INVALID_CHROMA_TYPE; + + *width = p_surf->width; + *height = p_surf->height; + *chroma_type = PipeToType(p_surf->chroma_format); + + return VDP_STATUS_OK; +} + +VdpStatus +vlVdpVideoSurfaceGetBitsYCbCr ( VdpVideoSurface surface, + VdpYCbCrFormat destination_ycbcr_format, + void *const *destination_data, + uint32_t const *destination_pitches +) +{ + if (!vlCreateHTAB()) + return VDP_STATUS_RESOURCES; + + + vlVdpSurface *p_surf = vlGetDataHTAB(surface); + if (!p_surf) + return VDP_STATUS_INVALID_HANDLE; + + if (!p_surf->psurface) + return VDP_STATUS_RESOURCES; + + + return VDP_STATUS_OK; +} + +VdpStatus +vlVdpVideoSurfacePutBitsYCbCr ( VdpVideoSurface surface, + VdpYCbCrFormat source_ycbcr_format, + void const *const *source_data, + uint32_t const *source_pitches +) +{ + uint32_t size_surface_bytes; + const struct util_format_description *format_desc; + enum pipe_format pformat = FormatToPipe(source_ycbcr_format); + + if (!vlCreateHTAB()) + return VDP_STATUS_RESOURCES; + + + vlVdpSurface *p_surf = vlGetDataHTAB(surface); + if (!p_surf) + return VDP_STATUS_INVALID_HANDLE; + + + //size_surface_bytes = ( source_pitches[0] * p_surf->height util_format_get_blockheight(pformat) ); + /*util_format_translate(enum pipe_format dst_format, + void *dst, unsigned dst_stride, + unsigned dst_x, unsigned dst_y, + enum pipe_format src_format, + const void *src, unsigned src_stride, + unsigned src_x, unsigned src_y, + unsigned width, unsigned height);*/ + + return VDP_STATUS_NO_IMPLEMENTATION; + +} diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index 566c99266ed..635d6c8acdb 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -161,8 +161,9 @@ typedef struct { vlVdpDevice *device; struct vl_screen *vlscreen; - struct vl_context *vctx; + struct vl_context *vctx; enum pipe_video_chroma_format chroma_format; + enum pipe_video_profile profile; } vlVdpDecoder; typedef uint32_t vlHandle; @@ -173,6 +174,7 @@ vlHandle vlAddDataHTAB(void *data); void* vlGetDataHTAB(vlHandle handle); boolean vlGetFuncFTAB(VdpFuncId function_id, void **func); +VdpGetErrorString vlVdpGetErrorString; VdpDeviceDestroy vlVdpDeviceDestroy; VdpGetProcAddress vlVdpGetProcAddress; VdpGetApiVersion vlVdpGetApiVersion; @@ -197,5 +199,18 @@ VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr; VdpDecoderCreate vlVdpDecoderCreate; VdpDecoderDestroy vlVdpDecoderDestroy; VdpDecoderRender vlVdpDecoderRender; - -#endif // VDPAU_PRIVATE_H \ No newline at end of file +VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate; +VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate; +VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy; +VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters; +VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative; +VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy; +VdpPresentationQueueCreate vlVdpPresentationQueueCreate; +VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy; +VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor; +VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor; +VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime; +VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay; +VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle; +VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus; +#endif // VDPAU_PRIVATE_H From a90bdd09b6b342c3ff8d2c80480805f9614fabb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 21 Sep 2010 19:44:30 +0200 Subject: [PATCH 11/36] vl: Made vdpauinfo run again --- src/gallium/state_trackers/vdpau/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/vdpau/Makefile b/src/gallium/state_trackers/vdpau/Makefile index 6313ef34b38..ae54ae6a7ef 100644 --- a/src/gallium/state_trackers/vdpau/Makefile +++ b/src/gallium/state_trackers/vdpau/Makefile @@ -18,7 +18,8 @@ C_SOURCES = htab.c \ surface.c \ decode.c \ presentation.c \ - bitmap.c + bitmap.c \ + output.c include ../../Makefile.template From 8291db1cdb9d8e8d02a9c1a7ce34e6a23b8238ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Mon, 27 Sep 2010 22:45:05 +0200 Subject: [PATCH 12/36] vl: Renamed function to appropriate name. --- src/gallium/state_trackers/vdpau/decode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index ec3995b98db..e03bc35ed68 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -166,7 +166,7 @@ vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder, } static void -vlVdpMacroBlocksToPipe(struct pipe_screen *screen, +vlVdpBitstreamToMacroblocks(struct pipe_screen *screen, VdpBitstreamBuffer const *bitstream_buffers, unsigned int num_macroblocks, struct pipe_mpeg12_macroblock *pipe_macroblocks) @@ -221,7 +221,7 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, num_macroblocks = bitstream_buffer_count; struct pipe_mpeg12_macroblock pipe_macroblocks[num_macroblocks]; - vlVdpMacroBlocksToPipe(vpipe->screen, bitstream_buffers, + vlVdpBitstreamToMacroblocks(vpipe->screen, bitstream_buffers, num_macroblocks, pipe_macroblocks); vpipe->set_decode_target(vpipe,t_surf); From cac5e60fd3fa7b756bcd4174db8096335c70e145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Thu, 30 Sep 2010 15:58:57 +0200 Subject: [PATCH 13/36] vl: moved some functions to more appropriate places --- src/gallium/state_trackers/vdpau/Makefile | 1 + src/gallium/state_trackers/vdpau/decode.c | 24 ++++------- .../vdpau/mpeg2_bitstream_parser.c | 42 +++++++++++++++++++ .../vdpau/mpeg2_bitstream_parser.h | 8 ++++ 4 files changed, 58 insertions(+), 17 deletions(-) diff --git a/src/gallium/state_trackers/vdpau/Makefile b/src/gallium/state_trackers/vdpau/Makefile index ae54ae6a7ef..ad37676b95e 100644 --- a/src/gallium/state_trackers/vdpau/Makefile +++ b/src/gallium/state_trackers/vdpau/Makefile @@ -19,6 +19,7 @@ C_SOURCES = htab.c \ decode.c \ presentation.c \ bitmap.c \ + mpeg2_bitstream_parser.c \ output.c diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index e03bc35ed68..3e7cb4a3cab 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -26,6 +26,7 @@ **************************************************************************/ #include "vdpau_private.h" +#include "mpeg2_bitstream_parser.h" #include #include #include @@ -165,15 +166,6 @@ vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder, return VDP_STATUS_OK; } -static void -vlVdpBitstreamToMacroblocks(struct pipe_screen *screen, - VdpBitstreamBuffer const *bitstream_buffers, - unsigned int num_macroblocks, - struct pipe_mpeg12_macroblock *pipe_macroblocks) -{ - debug_printf("NAF!\n"); -} - VdpStatus vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, vlVdpSurface *vlsurf, @@ -190,6 +182,7 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, struct pipe_surface *p_surf; struct pipe_surface *f_surf; uint32_t num_macroblocks; + struct pipe_mpeg12_macroblock *pipe_macroblocks; VdpStatus ret; @@ -217,15 +210,12 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, if (f_vdp_surf == VDP_INVALID_HANDLE) f_vdp_surf = NULL; ret = vlVdpCreateSurfaceTarget(vldecoder,t_vdp_surf); - - num_macroblocks = bitstream_buffer_count; - struct pipe_mpeg12_macroblock pipe_macroblocks[num_macroblocks]; - - vlVdpBitstreamToMacroblocks(vpipe->screen, bitstream_buffers, - num_macroblocks, pipe_macroblocks); + + vlVdpBitstreamToMacroblock(vpipe->screen, bitstream_buffers, + &num_macroblocks, &pipe_macroblocks); vpipe->set_decode_target(vpipe,t_surf); - vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, &pipe_macroblocks->base, NULL); + vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, pipe_macroblocks, NULL); return ret; } @@ -284,4 +274,4 @@ vlVdpDecoderRender (VdpDecoder decoder, assert(0); return ret; -} \ No newline at end of file +} diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c index e69de29bb2d..c6d5846be52 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c @@ -0,0 +1,42 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "mpeg2_bitstream_parser.h" + +void +vlVdpBitstreamToMacroblock ( + struct pipe_screen *screen, + VdpBitstreamBuffer const *bitstream_buffers, + unsigned int *num_macroblocks, + struct pipe_mpeg12_macroblock **pipe_macroblocks) +{ + debug_printf("[VDPAU] BitstreamToMacroblock not implemented yet"); + assert(0); + + return; +} + diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h index 85a4b2fdf01..534503df53f 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h @@ -28,6 +28,14 @@ #ifndef MPEG2_BITSTREAM_PARSER_H #define MPEG2_BITSTREAM_PARSER_H +#include +#include +#include "vdpau_private.h" +void +vlVdpBitstreamToMacroblock(struct pipe_screen *screen, + VdpBitstreamBuffer const *bitstream_buffers, + unsigned int *num_macroblocks, + struct pipe_mpeg12_macroblock **pipe_macroblocks); #endif // MPEG2_BITSTREAM_PARSER_H From 63b1525cf0a50e3d31328c3b56355a86056e4c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 5 Oct 2010 11:06:02 +0200 Subject: [PATCH 14/36] vl: ... --- src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c index c6d5846be52..39019660edd 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c @@ -30,13 +30,15 @@ void vlVdpBitstreamToMacroblock ( struct pipe_screen *screen, - VdpBitstreamBuffer const *bitstream_buffers, - unsigned int *num_macroblocks, - struct pipe_mpeg12_macroblock **pipe_macroblocks) + VdpBitstreamBuffer const *bitstream_buffers, + unsigned int *num_macroblocks, + struct pipe_mpeg12_macroblock **pipe_macroblocks) { debug_printf("[VDPAU] BitstreamToMacroblock not implemented yet"); assert(0); + + return; } From d64d6f7712e5e8d8f962de3455a71fce8b2a8f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 5 Oct 2010 14:25:29 +0200 Subject: [PATCH 15/36] vl: changed video pipe to use the new gallium API within master --- .../auxiliary/vl/vl_bitstream_parser.h | 4 + src/gallium/auxiliary/vl/vl_compositor.c | 4 +- .../auxiliary/vl/vl_mpeg12_mc_renderer.c | 30 +-- .../drivers/softpipe/sp_video_context.c | 72 +++--- src/gallium/include/pipe/p_video_context.h | 18 +- src/gallium/state_trackers/vdpau/query.c | 1 + src/gallium/winsys/g3dvl/xlib/xsp_winsys.c | 2 +- src/glsl/glcpp/glcpp-parse.c | 234 +++++++++--------- src/glsl/glcpp/glcpp-parse.h | 7 +- 9 files changed, 189 insertions(+), 183 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_bitstream_parser.h b/src/gallium/auxiliary/vl/vl_bitstream_parser.h index 30ec743fa75..eeb51dd4295 100644 --- a/src/gallium/auxiliary/vl/vl_bitstream_parser.h +++ b/src/gallium/auxiliary/vl/vl_bitstream_parser.h @@ -39,6 +39,10 @@ struct vl_bitstream_parser unsigned cursor; }; +inline void endian_swap_ushort(unsigned short *x); +inline void endian_swap_uint(unsigned int *x); +inline void endian_swap_ulonglong(unsigned long long *x); + bool vl_bitstream_parser_init(struct vl_bitstream_parser *parser, unsigned num_bitstreams, const void **bitstreams, diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index 415dc92555f..ee7bf070037 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -555,7 +555,9 @@ static void draw_layers(struct vl_compositor *c, c->pipe->bind_fs_state(c->pipe, frag_shaders[i]); c->pipe->set_fragment_sampler_views(c->pipe, 1, &surface_view); - c->pipe->draw_arrays(c->pipe, PIPE_PRIM_TRIANGLES, i * 6, 6); + + + util_draw_arrays(c->pipe,PIPE_PRIM_TRIANGLES,i * 6,6); if (delete_view) { pipe_sampler_view_reference(&surface_view, NULL); diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index e9024e4a409..8a8c155e8ec 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -1039,6 +1039,7 @@ flush(struct vl_mpeg12_mc_renderer *r) unsigned vb_start = 0; struct vertex_shader_consts *vs_consts; struct pipe_transfer *buf_transfer; + unsigned i; assert(r); @@ -1065,6 +1066,7 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_VERTEX, 0, r->vs_const_buf); + if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) { r->pipe->set_vertex_buffers(r->pipe, 1, r->vertex_bufs.all); @@ -1074,8 +1076,8 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->i_vs); r->pipe->bind_fs_state(r->pipe, r->i_fs); - r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_INTRA] * 24); + util_draw_arrays(r->pipe,PIPE_PRIM_TRIANGLES,vb_start,num_macroblocks[MACROBLOCK_TYPE_INTRA] * 24); + vb_start += num_macroblocks[MACROBLOCK_TYPE_INTRA] * 24; } @@ -1089,8 +1091,8 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->p_vs[0]); r->pipe->bind_fs_state(r->pipe, r->p_fs[0]); - r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 24); + util_draw_arrays(r->pipe,PIPE_PRIM_TRIANGLES,vb_start,num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 24); + vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 24; } @@ -1104,8 +1106,8 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->p_vs[1]); r->pipe->bind_fs_state(r->pipe, r->p_fs[1]); - r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 24); + util_draw_arrays(r->pipe,PIPE_PRIM_TRIANGLES,vb_start,num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 24); + vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 24; } @@ -1119,8 +1121,8 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->p_vs[0]); r->pipe->bind_fs_state(r->pipe, r->p_fs[0]); - r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 24); + util_draw_arrays(r->pipe,PIPE_PRIM_TRIANGLES,vb_start,num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 24); + vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 24; } @@ -1134,8 +1136,8 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->p_vs[1]); r->pipe->bind_fs_state(r->pipe, r->p_fs[1]); - r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 24); + util_draw_arrays(r->pipe,PIPE_PRIM_TRIANGLES,vb_start,num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 24); + vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 24; } @@ -1151,8 +1153,8 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->b_vs[0]); r->pipe->bind_fs_state(r->pipe, r->b_fs[0]); - r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 24); + util_draw_arrays(r->pipe,PIPE_PRIM_TRIANGLES,vb_start,num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 24); + vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 24; } @@ -1168,8 +1170,8 @@ flush(struct vl_mpeg12_mc_renderer *r) r->pipe->bind_vs_state(r->pipe, r->b_vs[1]); r->pipe->bind_fs_state(r->pipe, r->b_fs[1]); - r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start, - num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 24); + util_draw_arrays(r->pipe,PIPE_PRIM_TRIANGLES,vb_start,num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 24); + vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 24; } diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c index 44df00e0b78..419ba946b89 100644 --- a/src/gallium/drivers/softpipe/sp_video_context.c +++ b/src/gallium/drivers/softpipe/sp_video_context.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "sp_public.h" #include "sp_texture.h" @@ -97,8 +98,8 @@ sp_mpeg12_is_format_supported(struct pipe_video_context *vpipe, if (geom & PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO) return FALSE; - return ctx->pipe->screen->is_format_supported(ctx->pipe->screen, PIPE_TEXTURE_2D, - format, usage, geom); + return ctx->pipe->screen->is_format_supported(ctx->pipe->screen, format, PIPE_TEXTURE_2D, 1, + usage, geom); } static void @@ -125,29 +126,10 @@ sp_mpeg12_decode_macroblocks(struct pipe_video_context *vpipe, } static void -sp_mpeg12_surface_fill(struct pipe_video_context *vpipe, +sp_mpeg12_clear_render_target(struct pipe_video_context *vpipe, struct pipe_surface *dst, unsigned dstx, unsigned dsty, - unsigned width, unsigned height, - unsigned value) -{ - struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; - - assert(vpipe); - assert(dst); - - if (ctx->pipe->surface_fill) - ctx->pipe->surface_fill(ctx->pipe, dst, dstx, dsty, width, height, value); - else - util_surface_fill(ctx->pipe, dst, dstx, dsty, width, height, value); -} - -static void -sp_mpeg12_surface_copy(struct pipe_video_context *vpipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - struct pipe_surface *src, - unsigned srcx, unsigned srcy, + const float *rgba, unsigned width, unsigned height) { struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; @@ -155,10 +137,31 @@ sp_mpeg12_surface_copy(struct pipe_video_context *vpipe, assert(vpipe); assert(dst); - if (ctx->pipe->surface_copy) - ctx->pipe->surface_copy(ctx->pipe, dst, dstx, dsty, src, srcx, srcy, width, height); + if (ctx->pipe->clear_render_target) + ctx->pipe->clear_render_target(ctx->pipe, dst, rgba, dstx, dsty, width, height); else - util_surface_copy(ctx->pipe, FALSE, dst, dstx, dsty, src, srcx, srcy, width, height); + util_clear_render_target(ctx->pipe, dst, rgba, dstx, dsty, width, height); +} + +static void +sp_mpeg12_resource_copy_region(struct pipe_video_context *vpipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, + struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, + unsigned width, unsigned height) +{ + struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; + + assert(vpipe); + assert(dst); + + if (ctx->pipe->resource_copy_region) + ctx->pipe->resource_copy_region(ctx->pipe, dst, subdst, dstx, dsty, dstz, src, subsrc, srcx, srcy, srcz, width, height); + else + util_resource_copy_region(ctx->pipe, dst, subdst, dstx, dsty, dstz, src, subsrc, srcx, srcy, srcz, width, height); } static struct pipe_transfer* @@ -339,12 +342,9 @@ init_pipe_state(struct sp_mpeg12_context *ctx) rast.flatshade = 1; rast.flatshade_first = 0; rast.light_twoside = 0; - rast.front_winding = PIPE_WINDING_CCW; - rast.cull_mode = PIPE_WINDING_CW; - rast.fill_cw = PIPE_POLYGON_MODE_FILL; - rast.fill_ccw = PIPE_POLYGON_MODE_FILL; - rast.offset_cw = 0; - rast.offset_ccw = 0; + rast.cull_face = PIPE_FACE_FRONT; + rast.fill_front = PIPE_POLYGON_MODE_FILL; + rast.fill_back = PIPE_POLYGON_MODE_FILL; rast.scissor = 0; rast.poly_smooth = 0; rast.poly_stipple_enable = 0; @@ -359,13 +359,15 @@ init_pipe_state(struct sp_mpeg12_context *ctx) rast.line_width = 1; rast.point_smooth = 0; rast.point_quad_rasterization = 0; - rast.point_size = 1; + rast.point_size_per_vertex = 1; rast.offset_units = 1; rast.offset_scale = 1; rast.gl_rasterization_rules = 1; + ctx->rast = ctx->pipe->create_rasterizer_state(ctx->pipe, &rast); ctx->pipe->bind_rasterizer_state(ctx->pipe, ctx->rast); + blend.independent_blend_enable = 0; blend.rt[0].blend_enable = 0; blend.rt[0].rgb_func = PIPE_BLEND_ADD; @@ -432,8 +434,8 @@ sp_mpeg12_create(struct pipe_context *pipe, enum pipe_video_profile profile, ctx->base.is_format_supported = sp_mpeg12_is_format_supported; ctx->base.decode_macroblocks = sp_mpeg12_decode_macroblocks; ctx->base.render_picture = sp_mpeg12_render_picture; - ctx->base.surface_fill = sp_mpeg12_surface_fill; - ctx->base.surface_copy = sp_mpeg12_surface_copy; + ctx->base.clear_render_target = sp_mpeg12_clear_render_target; + ctx->base.resource_copy_region = sp_mpeg12_resource_copy_region; ctx->base.get_transfer = sp_mpeg12_get_transfer; ctx->base.transfer_destroy = sp_mpeg12_transfer_destroy; ctx->base.transfer_map = sp_mpeg12_transfer_map; diff --git a/src/gallium/include/pipe/p_video_context.h b/src/gallium/include/pipe/p_video_context.h index 294dc464c36..21ed4d579cf 100644 --- a/src/gallium/include/pipe/p_video_context.h +++ b/src/gallium/include/pipe/p_video_context.h @@ -101,17 +101,19 @@ struct pipe_video_context struct pipe_video_rect *dst_area, struct pipe_fence_handle **fence); - void (*surface_fill)(struct pipe_video_context *vpipe, + void (*clear_render_target)(struct pipe_video_context *vpipe, struct pipe_surface *dst, unsigned dstx, unsigned dsty, - unsigned width, unsigned height, - unsigned value); + const float *rgba, + unsigned width, unsigned height); - void (*surface_copy)(struct pipe_video_context *vpipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - struct pipe_surface *src, - unsigned srcx, unsigned srcy, + void (*resource_copy_region)(struct pipe_video_context *vpipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, + struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, unsigned width, unsigned height); struct pipe_transfer *(*get_transfer)(struct pipe_video_context *vpipe, diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c index 86b5098f178..a3a8500a6f7 100644 --- a/src/gallium/state_trackers/vdpau/query.c +++ b/src/gallium/state_trackers/vdpau/query.c @@ -122,6 +122,7 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp *is_supported = vlscreen->pscreen->is_format_supported(vlscreen->pscreen, FormatToPipe(bits_ycbcr_format), PIPE_TEXTURE_2D, + 1, PIPE_BIND_RENDER_TARGET, PIPE_TEXTURE_GEOM_NON_SQUARE ); diff --git a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c index 0a7f324a77c..cc80583f088 100644 --- a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c +++ b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c @@ -82,7 +82,7 @@ vl_drawable_surface_get(struct vl_screen *vscreen, Drawable drawable) templat.height0 = height; templat.depth0 = 1; templat.usage = PIPE_USAGE_DEFAULT; - templat.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_BLIT_SOURCE; + templat.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET; templat.flags = 0; drawable_tex = vscreen->pscreen->resource_create(vscreen->pscreen, &templat); diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 1773ca5c13d..899e7841b3d 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -1,9 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -219,7 +220,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* Line 189 of yacc.c */ -#line 223 "glcpp/glcpp-parse.c" +#line 224 "glcpp/glcpp-parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -307,7 +308,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 311 "glcpp/glcpp-parse.c" +#line 312 "glcpp/glcpp-parse.c" #ifdef short # undef short @@ -357,7 +358,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -945,18 +946,9 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -1013,7 +1005,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1555,7 +1547,7 @@ YYLTYPE yylloc; YYLTYPE *yylsp; /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3]; + YYLTYPE yyerror_range[2]; YYSIZE_T yystacksize; @@ -1602,7 +1594,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -1610,7 +1602,7 @@ YYLTYPE yylloc; /* User initialization code. */ -/* Line 1251 of yacc.c */ +/* Line 1242 of yacc.c */ #line 155 "glcpp/glcpp-parse.y" { yylloc.first_line = 1; @@ -1620,8 +1612,8 @@ YYLTYPE yylloc; yylloc.source = 0; } -/* Line 1251 of yacc.c */ -#line 1625 "glcpp/glcpp-parse.c" +/* Line 1242 of yacc.c */ +#line 1617 "glcpp/glcpp-parse.c" yylsp[0] = yylloc; goto yysetstate; @@ -1808,7 +1800,7 @@ yyreduce: { case 4: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 194 "glcpp/glcpp-parse.y" { glcpp_print(parser->output, "\n"); @@ -1817,7 +1809,7 @@ yyreduce: case 5: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 197 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); @@ -1828,7 +1820,7 @@ yyreduce: case 8: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 207 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); @@ -1837,7 +1829,7 @@ yyreduce: case 9: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 210 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); @@ -1846,7 +1838,7 @@ yyreduce: case 10: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 216 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); @@ -1855,7 +1847,7 @@ yyreduce: case 11: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 219 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); @@ -1864,7 +1856,7 @@ yyreduce: case 12: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 222 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); @@ -1873,7 +1865,7 @@ yyreduce: case 13: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 225 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); @@ -1887,7 +1879,7 @@ yyreduce: case 14: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 233 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'if' expression if @@ -1912,7 +1904,7 @@ yyreduce: case 15: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 252 "glcpp/glcpp-parse.y" { /* #if without an expression is only an error if we @@ -1928,7 +1920,7 @@ yyreduce: case 16: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 262 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); @@ -1939,7 +1931,7 @@ yyreduce: case 17: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 267 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); @@ -1950,7 +1942,7 @@ yyreduce: case 18: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 272 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'elif' expression @@ -1975,7 +1967,7 @@ yyreduce: case 19: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 291 "glcpp/glcpp-parse.y" { /* #elif without an expression is an error unless we @@ -1996,7 +1988,7 @@ yyreduce: case 20: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 306 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); @@ -2005,7 +1997,7 @@ yyreduce: case 21: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 309 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); @@ -2014,7 +2006,7 @@ yyreduce: case 22: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 312 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); @@ -2033,7 +2025,7 @@ yyreduce: case 24: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 329 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { @@ -2048,7 +2040,7 @@ yyreduce: case 25: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 338 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); @@ -2057,7 +2049,7 @@ yyreduce: case 27: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 344 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); @@ -2066,7 +2058,7 @@ yyreduce: case 28: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 347 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); @@ -2075,7 +2067,7 @@ yyreduce: case 29: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 350 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); @@ -2084,7 +2076,7 @@ yyreduce: case 30: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 353 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); @@ -2093,7 +2085,7 @@ yyreduce: case 31: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 356 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); @@ -2102,7 +2094,7 @@ yyreduce: case 32: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 359 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); @@ -2111,7 +2103,7 @@ yyreduce: case 33: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 362 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); @@ -2120,7 +2112,7 @@ yyreduce: case 34: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 365 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); @@ -2129,7 +2121,7 @@ yyreduce: case 35: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 368 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); @@ -2138,7 +2130,7 @@ yyreduce: case 36: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 371 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); @@ -2147,7 +2139,7 @@ yyreduce: case 37: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 374 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); @@ -2156,7 +2148,7 @@ yyreduce: case 38: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 377 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); @@ -2165,7 +2157,7 @@ yyreduce: case 39: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 380 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); @@ -2174,7 +2166,7 @@ yyreduce: case 40: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 383 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); @@ -2183,7 +2175,7 @@ yyreduce: case 41: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 386 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); @@ -2192,7 +2184,7 @@ yyreduce: case 42: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 389 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); @@ -2201,7 +2193,7 @@ yyreduce: case 43: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 392 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); @@ -2210,7 +2202,7 @@ yyreduce: case 44: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 395 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); @@ -2219,7 +2211,7 @@ yyreduce: case 45: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 398 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); @@ -2228,7 +2220,7 @@ yyreduce: case 46: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 401 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); @@ -2237,7 +2229,7 @@ yyreduce: case 47: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 404 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); @@ -2246,7 +2238,7 @@ yyreduce: case 48: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 407 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); @@ -2255,7 +2247,7 @@ yyreduce: case 49: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 410 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); @@ -2264,7 +2256,7 @@ yyreduce: case 50: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 416 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); @@ -2275,7 +2267,7 @@ yyreduce: case 51: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 421 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); @@ -2286,14 +2278,14 @@ yyreduce: case 52: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 429 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 54: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 434 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); @@ -2302,14 +2294,14 @@ yyreduce: case 55: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 440 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 58: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 446 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); @@ -2318,7 +2310,7 @@ yyreduce: case 59: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 453 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; @@ -2328,7 +2320,7 @@ yyreduce: case 60: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 457 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; @@ -2338,7 +2330,7 @@ yyreduce: case 62: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 466 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; @@ -2350,7 +2342,7 @@ yyreduce: case 63: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 472 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); @@ -2361,7 +2353,7 @@ yyreduce: case 64: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 480 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; @@ -2373,7 +2365,7 @@ yyreduce: case 65: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 486 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); @@ -2384,7 +2376,7 @@ yyreduce: case 66: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 494 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); @@ -2394,7 +2386,7 @@ yyreduce: case 67: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 498 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); @@ -2404,7 +2396,7 @@ yyreduce: case 68: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 502 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); @@ -2414,7 +2406,7 @@ yyreduce: case 69: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 506 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); @@ -2424,7 +2416,7 @@ yyreduce: case 70: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 510 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); @@ -2434,225 +2426,225 @@ yyreduce: case 71: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 517 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 72: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 518 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 73: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 519 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 74: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 520 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 75: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 521 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 76: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 522 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 77: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 523 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 78: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 524 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 79: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 525 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 80: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 526 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 81: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 527 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 82: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 528 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 83: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 529 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 84: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 530 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 85: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 531 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 86: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 532 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 87: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 533 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 88: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 534 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 89: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 535 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 90: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 536 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 91: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 537 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 92: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 538 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 93: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 539 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 94: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 540 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 95: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 541 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 96: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 542 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 97: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 543 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 98: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 544 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 99: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 545 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 100: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 546 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 101: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 547 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; -/* Line 1464 of yacc.c */ -#line 2656 "glcpp/glcpp-parse.c" +/* Line 1455 of yacc.c */ +#line 2648 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2724,7 +2716,7 @@ yyerrlab: #endif } - yyerror_range[1] = yylloc; + yyerror_range[0] = yylloc; if (yyerrstatus == 3) { @@ -2761,7 +2753,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[1] = yylsp[1-yylen]; + yyerror_range[0] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -2795,7 +2787,7 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - yyerror_range[1] = *yylsp; + yyerror_range[0] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp, parser); YYPOPSTACK (1); @@ -2805,10 +2797,10 @@ yyerrlab1: *++yyvsp = yylval; - yyerror_range[2] = yylloc; + yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; /* Shift the error token. */ @@ -2870,7 +2862,7 @@ yyreturn: -/* Line 1684 of yacc.c */ +/* Line 1675 of yacc.c */ #line 550 "glcpp/glcpp-parse.y" diff --git a/src/glsl/glcpp/glcpp-parse.h b/src/glsl/glcpp/glcpp-parse.h index 40556854f38..50758930e9c 100644 --- a/src/glsl/glcpp/glcpp-parse.h +++ b/src/glsl/glcpp/glcpp-parse.h @@ -1,9 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From cd114a92b996c246bb35080bca611fca3f375e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 5 Oct 2010 15:18:29 +0200 Subject: [PATCH 16/36] vl: change the xvmc state_tracker to the new gallium API --- src/gallium/state_trackers/xorg/xvmc/subpicture.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xvmc/subpicture.c b/src/gallium/state_trackers/xorg/xvmc/subpicture.c index e0c9e303817..4f6c80d4bee 100644 --- a/src/gallium/state_trackers/xorg/xvmc/subpicture.c +++ b/src/gallium/state_trackers/xorg/xvmc/subpicture.c @@ -211,18 +211,27 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh { XvMCSubpicturePrivate *subpicture_priv; XvMCContextPrivate *context_priv; + unsigned int tmp_color; + float color_f[4]; assert(dpy); if (!subpicture) return XvMCBadSubpicture; + + /* Convert color to */ + util_format_read_4f(PIPE_FORMAT_B8G8R8A8_UNORM, + color_f, 1, + &color, 4, + 0, 0, 1, 1); subpicture_priv = subpicture->privData; context_priv = subpicture_priv->context->privData; /* TODO: Assert clear rect is within bounds? Or clip? */ - context_priv->vctx->vpipe->surface_fill(context_priv->vctx->vpipe, + context_priv->vctx->vpipe->clear_render_target(context_priv->vctx->vpipe, subpicture_priv->sfc, x, y, - width, height, color); + color_f, + width, height); return Success; } From d0e203f1f00b0f760acc7fab07cd7ce8cca34000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 6 Oct 2010 00:19:53 +0200 Subject: [PATCH 17/36] vl: initial commit of the bitstream parser --- src/gallium/state_trackers/vdpau/decode.c | 14 +++- .../vdpau/mpeg2_bitstream_parser.c | 83 +++++++++++++++++-- .../vdpau/mpeg2_bitstream_parser.h | 21 ++++- .../state_trackers/xorg/xvmc/subpicture.c | 2 +- 4 files changed, 108 insertions(+), 12 deletions(-) diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index 3e7cb4a3cab..03764a7f33d 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -211,11 +211,19 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, ret = vlVdpCreateSurfaceTarget(vldecoder,t_vdp_surf); - vlVdpBitstreamToMacroblock(vpipe->screen, bitstream_buffers, - &num_macroblocks, &pipe_macroblocks); + if (vlVdpMPEG2BitstreamToMacroblock(vpipe->screen, bitstream_buffers, bitstream_buffer_count, + &num_macroblocks, &pipe_macroblocks)) + { + debug_printf("[VDPAU] Error in frame-header. Skipping.\n"); + + ret = VDP_STATUS_OK; + goto skip_frame; + } vpipe->set_decode_target(vpipe,t_surf); - vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, pipe_macroblocks, NULL); + vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, (struct pipe_macroblock *)pipe_macroblocks, NULL); + + skip_frame: return ret; } diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c index 39019660edd..d88afb495f7 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c @@ -27,18 +27,89 @@ #include "mpeg2_bitstream_parser.h" -void -vlVdpBitstreamToMacroblock ( +int +vlVdpMPEG2NextStartCode(struct vdpMPEG2BitstreamParser *parser) +{ + uint32_t integer = 0; + uint32_t bytes_to_end; + + /* Move cursor to the start of a byte */ + while(parser->cursor % 8) + parser->cursor++; + + bytes_to_end = parser->cur_bitstream_length - parser->cursor/8 - 1; + + /* Read byte after byte, until startcode is found */ + while(integer != 0x00000100) + { + if (bytes_to_end < 0) + { + parser->state = MPEG2_HEADER_DONE; + return 1; + } + + integer << 8; + integer = integer & (unsigned char)(parser->ptr_bitstream + parser->cursor/8)[0]; + + bytes_to_end--; + parser->cursor += 8; + + } + + /* start_code found. rewind cursor a byte */ + parser->cursor -= 8; + + return 0; +} + +int +vlVdpMPEG2BitstreamToMacroblock ( struct pipe_screen *screen, VdpBitstreamBuffer const *bitstream_buffers, + uint32_t bitstream_buffer_count, unsigned int *num_macroblocks, struct pipe_mpeg12_macroblock **pipe_macroblocks) { - debug_printf("[VDPAU] BitstreamToMacroblock not implemented yet"); - assert(0); - + bool b_header_done = false; + struct vdpMPEG2BitstreamParser parser; + + num_macroblocks[0] = 0; + + memset(&parser,0,sizeof(parser)); + parser.state = MPEG2_HEADER_START_CODE; + parser.cur_bitstream_length = bitstream_buffers[0].bitstream_bytes; + parser.ptr_bitstream = (unsigned char *)bitstream_buffers[0].bitstream; + + /* Main header parser loop */ + while(!b_header_done) + { + switch (parser.state) + { + case MPEG2_HEADER_START_CODE: + if (vlVdpMPEG2NextStartCode(&parser)) + continue; + + /* Start_code found */ + switch ((parser.ptr_bitstream + parser.cursor/8)[0]) + { + /* sequence_header_code */ + case 0xB3: + debug_printf("[VDPAU][Bitstream parser] Sequence header code found at cursor pos: %d\n", parser.cursor); + exit(1); + break; + } + + break; + case MPEG2_HEADER_DONE: + debug_printf("[VDPAU][Bitstream parser] Done parsing current header\n"); + break; + + } + + + } - return; + return 0; } diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h index 534503df53f..74a216a4d81 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h @@ -32,10 +32,27 @@ #include #include "vdpau_private.h" -void -vlVdpBitstreamToMacroblock(struct pipe_screen *screen, +enum vdpMPEG2States +{ + MPEG2_HEADER_START_CODE, + MPEG2_HEADER_DONE +}; + +struct vdpMPEG2BitstreamParser +{ + enum vdpMPEG2States state; + uint32_t cursor; // current bit cursor + uint32_t cur_bitstream; + uint32_t cur_bitstream_length; + unsigned char *ptr_bitstream; +}; + +int +vlVdpMPEG2BitstreamToMacroblock(struct pipe_screen *screen, VdpBitstreamBuffer const *bitstream_buffers, + uint32_t bitstream_buffer_count, unsigned int *num_macroblocks, struct pipe_mpeg12_macroblock **pipe_macroblocks); + #endif // MPEG2_BITSTREAM_PARSER_H diff --git a/src/gallium/state_trackers/xorg/xvmc/subpicture.c b/src/gallium/state_trackers/xorg/xvmc/subpicture.c index 4f6c80d4bee..7e82cd17288 100644 --- a/src/gallium/state_trackers/xorg/xvmc/subpicture.c +++ b/src/gallium/state_trackers/xorg/xvmc/subpicture.c @@ -219,7 +219,7 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh if (!subpicture) return XvMCBadSubpicture; - /* Convert color to */ + /* Convert color to float */ util_format_read_4f(PIPE_FORMAT_B8G8R8A8_UNORM, color_f, 1, &color, 4, From 65fe0866aec7b5608419f6d184cb1fa4fe1dc45a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 6 Oct 2010 23:30:08 +0200 Subject: [PATCH 18/36] vl: implemented a few functions and made stubs to get mplayer running --- src/gallium/auxiliary/vl/vl_compositor.c | 1 + .../auxiliary/vl/vl_mpeg12_mc_renderer.c | 1 + src/gallium/state_trackers/vdpau/Makefile | 4 +- src/gallium/state_trackers/vdpau/decode.c | 26 +++- src/gallium/state_trackers/vdpau/device.c | 45 +++++- src/gallium/state_trackers/vdpau/ftab.c | 60 ++++---- src/gallium/state_trackers/vdpau/header.c | 0 src/gallium/state_trackers/vdpau/mixer.c | 135 ++++++++++++++++++ .../vdpau/mpeg2_bitstream_parser.c | 2 + src/gallium/state_trackers/vdpau/output.c | 23 ++- src/gallium/state_trackers/vdpau/preemption.c | 39 +++++ .../state_trackers/vdpau/presentation.c | 34 ++++- src/gallium/state_trackers/vdpau/render.c | 0 .../state_trackers/vdpau/vdpau_private.h | 61 ++++++++ 14 files changed, 387 insertions(+), 44 deletions(-) delete mode 100644 src/gallium/state_trackers/vdpau/header.c delete mode 100644 src/gallium/state_trackers/vdpau/render.c diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index ee7bf070037..1dbf14ee7b9 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include "vl_csc.h" diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index 8a8c155e8ec..264ab3d4566 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #define DEFAULT_BUF_ALIGNMENT 1 diff --git a/src/gallium/state_trackers/vdpau/Makefile b/src/gallium/state_trackers/vdpau/Makefile index ad37676b95e..0e68d4fe007 100644 --- a/src/gallium/state_trackers/vdpau/Makefile +++ b/src/gallium/state_trackers/vdpau/Makefile @@ -20,7 +20,9 @@ C_SOURCES = htab.c \ presentation.c \ bitmap.c \ mpeg2_bitstream_parser.c \ - output.c + output.c \ + preemption.c \ + mixer.c include ../../Makefile.template diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index 03764a7f33d..f6003304668 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -98,6 +98,7 @@ VdpStatus vlVdpDecoderDestroy (VdpDecoder decoder ) { + debug_printf("[VDPAU] Destroying decoder\n"); vlVdpDecoder *vldecoder; vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder); @@ -105,8 +106,11 @@ vlVdpDecoderDestroy (VdpDecoder decoder return VDP_STATUS_INVALID_HANDLE; } - if (vldecoder->vctx->vscreen) - vl_screen_destroy(vldecoder->vctx->vscreen); + if (vldecoder->vctx) + { + if (vldecoder->vctx->vscreen) + vl_screen_destroy(vldecoder->vctx->vscreen); + } if (vldecoder->vctx) vl_video_destroy(vldecoder->vctx); @@ -124,6 +128,8 @@ vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder, struct pipe_resource tmplt; struct pipe_resource *surf_tex; struct pipe_video_context *vpipe; + + debug_printf("[VDPAU] Creating surface\n"); if(!(vldecoder && vlsurf)) return VDP_STATUS_INVALID_POINTER; @@ -185,6 +191,7 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, struct pipe_mpeg12_macroblock *pipe_macroblocks; VdpStatus ret; + debug_printf("[VDPAU] Decoding MPEG2\n"); vpipe = vldecoder->vctx->vpipe; t_vdp_surf = vlsurf; @@ -221,7 +228,7 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, } vpipe->set_decode_target(vpipe,t_surf); - vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, (struct pipe_macroblock *)pipe_macroblocks, NULL); + //vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, (struct pipe_macroblock *)pipe_macroblocks, NULL); skip_frame: return ret; @@ -283,3 +290,16 @@ vlVdpDecoderRender (VdpDecoder decoder, return ret; } + +VdpStatus +vlVdpGenerateCSCMatrix( + VdpProcamp *procamp, + VdpColorStandard standard, + VdpCSCMatrix *csc_matrix) +{ + debug_printf("[VDPAU] Generating CSCMatrix\n"); + if (!(csc_matrix && procamp)) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_OK; +} \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c index d370d1c6610..4ca198e874d 100644 --- a/src/gallium/state_trackers/vdpau/device.c +++ b/src/gallium/state_trackers/vdpau/device.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2010 Younes Manton. + * Copyright 2010 Younes Manton og Thomas Balling Sørensen. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -25,21 +25,18 @@ * **************************************************************************/ -#include #include #include #include #include #include "vdpau_private.h" -VdpDeviceCreateX11 vdp_imp_device_create_x11; PUBLIC VdpStatus vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGetProcAddress **get_proc_address) { VdpStatus ret; vlVdpDevice *dev = NULL; - struct vl_screen *vlscreen = NULL; if (!(display && device && get_proc_address)) return VDP_STATUS_INVALID_POINTER; @@ -62,9 +59,8 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGe ret = VDP_STATUS_ERROR; goto no_handle; } - + *get_proc_address = &vlVdpGetProcAddress; - debug_printf("[VDPAU] Device created succesfully\n"); return VDP_STATUS_OK; @@ -77,9 +73,46 @@ no_htab: return ret; } +PUBLIC VdpStatus +vlVdpPresentationQueueTargetCreateX11(VdpDevice device, Drawable drawable,VdpPresentationQueueTarget *target) +{ + VdpStatus ret; + vlVdpPresentationQueueTarget *pqt = NULL; + + debug_printf("[VDPAU] Creating PresentationQueueTarget\n"); + + if (!drawable) + return VDP_STATUS_INVALID_HANDLE; + + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) + return VDP_STATUS_INVALID_HANDLE; + + pqt = CALLOC(1, sizeof(vlVdpPresentationQueue)); + if (!pqt) + return VDP_STATUS_RESOURCES; + + pqt->device = dev; + pqt->drawable = drawable; + + *target = vlAddDataHTAB(pqt); + if (*target == 0) { + ret = VDP_STATUS_ERROR; + goto no_handle; + } + + + return VDP_STATUS_OK; + no_handle: + FREE(dev); + return ret; +} + VdpStatus vlVdpDeviceDestroy(VdpDevice device) { + debug_printf("[VDPAU] Destroying destroy\n"); + vlVdpDevice *dev = vlGetDataHTAB(device); if (!dev) return VDP_STATUS_INVALID_HANDLE; diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c index 1842c4da0ea..2142dcd4f6a 100644 --- a/src/gallium/state_trackers/vdpau/ftab.c +++ b/src/gallium/state_trackers/vdpau/ftab.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2010 Younes Manton. + * Copyright 2010 Younes Manton & Thomas Balling Sørensen. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -33,10 +33,10 @@ static void* ftab[67] = &vlVdpGetErrorString, /* VDP_FUNC_ID_GET_ERROR_STRING */ &vlVdpGetProcAddress, /* VDP_FUNC_ID_GET_PROC_ADDRESS */ &vlVdpGetApiVersion, /* VDP_FUNC_ID_GET_API_VERSION */ - 0, + 0x555, /* DUMMY */ &vlVdpGetInformationString, /* VDP_FUNC_ID_GET_INFORMATION_STRING */ &vlVdpDeviceDestroy, /* VDP_FUNC_ID_DEVICE_DESTROY */ - 0, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */ + &vlVdpGenerateCSCMatrix, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */ &vlVdpVideoSurfaceQueryCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES */ &vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES */ &vlVdpVideoSurfaceCreate, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */ @@ -46,62 +46,62 @@ static void* ftab[67] = &vlVdpVideoSurfacePutBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR */ &vlVdpOutputSurfaceQueryCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES */ &vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES */ + 0x2, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES */ &vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES */ &vlVdpOutputSurfaceCreate, /* VDP_FUNC_ID_OUTPUT_SURFACE_CREATE */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR */ + 0x3, /* VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY */ + 0x4, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS */ + 0x5, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE */ + 0x6, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE */ + 0x7, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED */ + 0x8, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR */ &vlVdpBitmapSurfaceQueryCapabilities, /* VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES */ &vlVdpBitmapSurfaceCreate, /* VDP_FUNC_ID_BITMAP_SURFACE_CREATE */ &vlVdpBitmapSurfaceDestroy, /* VDP_FUNC_ID_BITMAP_SURFACE_DESTROY */ &vlVdpBitmapSurfaceGetParameters, /* VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS */ &vlVdpBitmapSurfacePutBitsNative, /* VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE */ - 0, - 0, - 0, - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE */ - 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_VIDEO_SURFACE_LUMA */ + 0x55, /* DUMMY */ + 0x55, /* DUMMY */ + 0x55, /* DUMMY */ + 0x9, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE */ + 0x10, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE */ + 0x11, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_VIDEO_SURFACE_LUMA */ &vlVdpDecoderQueryCapabilities, /* VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES */ &vlVdpDecoderCreate, /* VDP_FUNC_ID_DECODER_CREATE */ &vlVdpDecoderDestroy, /* VDP_FUNC_ID_DECODER_DESTROY */ - 0, /* VDP_FUNC_ID_DECODER_GET_PARAMETERS */ + 0x12, /* VDP_FUNC_ID_DECODER_GET_PARAMETERS */ &vlVdpDecoderRender, /* VDP_FUNC_ID_DECODER_RENDER */ &vlVdpVideoMixerQueryFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT */ &vlVdpVideoMixerQueryParameterSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT */ &vlVdpVideoMixerQueryAttributeSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT */ &vlVdpVideoMixerQueryParameterValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_VALUE_RANGE */ &vlVdpVideoMixerQueryAttributeValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_VALUE_RANGE */ - 0, /* VDP_FUNC_ID_VIDEO_MIXER_CREATE */ - 0, /* VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES */ - 0, /* VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES */ - 0, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT */ - 0, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES */ - 0, /* VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES */ - 0, /* VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES */ - 0, /* VDP_FUNC_ID_VIDEO_MIXER_DESTROY */ - 0, /* VDP_FUNC_ID_VIDEO_MIXER_RENDER */ + &vlVdpVideoMixerCreate, /* VDP_FUNC_ID_VIDEO_MIXER_CREATE */ + &vlVdpVideoMixerSetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES */ + &vlVdpVideoMixerSetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES */ + 0x16, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT */ + 0x17, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES */ + 0x18, /* VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES */ + 0x19, /* VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES */ + 0x20, /* VDP_FUNC_ID_VIDEO_MIXER_DESTROY */ + &vlVdpVideoMixerRender, /* VDP_FUNC_ID_VIDEO_MIXER_RENDER */ &vlVdpPresentationQueueTargetDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY */ &vlVdpPresentationQueueCreate, /* VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE */ &vlVdpPresentationQueueDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY */ &vlVdpPresentationQueueSetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR */ &vlVdpPresentationQueueGetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR */ - 0, - 0, + 0x55, /* DUMMY */ + 0x55, /* DUMMY */ &vlVdpPresentationQueueGetTime, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME */ &vlVdpPresentationQueueDisplay, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY */ &vlVdpPresentationQueueBlockUntilSurfaceIdle, /* VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE */ &vlVdpPresentationQueueQuerySurfaceStatus, /* VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS */ - 0 /* VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER */ + &vlVdpPreemptionCallbackRegister /* VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER */ }; static void* ftab_winsys[1] = { - 0 /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */ + &vlVdpPresentationQueueTargetCreateX11 /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */ }; boolean vlGetFuncFTAB(VdpFuncId function_id, void **func) diff --git a/src/gallium/state_trackers/vdpau/header.c b/src/gallium/state_trackers/vdpau/header.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c index e69de29bb2d..8bf42f53ff2 100644 --- a/src/gallium/state_trackers/vdpau/mixer.c +++ b/src/gallium/state_trackers/vdpau/mixer.c @@ -0,0 +1,135 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + #include + #include + #include + #include "vdpau_private.h" + + + VdpStatus + vlVdpVideoMixerCreate (VdpDevice device, + uint32_t feature_count, + VdpVideoMixerFeature const *features, + uint32_t parameter_count, + VdpVideoMixerParameter const *parameters, + void const *const *parameter_values, + VdpVideoMixer *mixer) +{ + VdpStatus ret; + vlVdpVideoMixer *vmixer = NULL; + + debug_printf("[VDPAU] Creating VideoMixer\n"); + + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) + return VDP_STATUS_INVALID_HANDLE; + + vmixer = CALLOC(1, sizeof(vlVdpVideoMixer)); + if (!vmixer) + return VDP_STATUS_RESOURCES; + + vmixer->device = dev; + /* + * TODO: Handle features and parameters + * */ + + *mixer = vlAddDataHTAB(vmixer); + if (*mixer == 0) { + ret = VDP_STATUS_ERROR; + goto no_handle; + } + + + return VDP_STATUS_OK; + no_handle: + return ret; +} + +VdpStatus +vlVdpVideoMixerSetFeatureEnables ( + VdpVideoMixer mixer, + uint32_t feature_count, + VdpVideoMixerFeature const *features, + VdpBool const *feature_enables) +{ + debug_printf("[VDPAU] Setting VideoMixer features\n"); + + if (!(features && feature_enables)) + return VDP_STATUS_INVALID_POINTER; + + vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); + if (!vmixer) + return VDP_STATUS_INVALID_HANDLE; + + /* + * TODO: Set features + * */ + + + return VDP_STATUS_OK; +} + +VdpStatus vlVdpVideoMixerRender ( + VdpVideoMixer mixer, + VdpOutputSurface background_surface, + VdpRect const *background_source_rect, + VdpVideoMixerPictureStructure current_picture_structure, + uint32_t video_surface_past_count, + VdpVideoSurface const *video_surface_past, + VdpVideoSurface video_surface_current, + uint32_t video_surface_future_count, + VdpVideoSurface const *video_surface_future, + VdpRect const *video_source_rect, + VdpOutputSurface destination_surface, + VdpRect const *destination_rect, + VdpRect const *destination_video_rect, + uint32_t layer_count, + VdpLayer const *layers) +{ + if (!(background_source_rect && video_surface_past && video_surface_future && video_source_rect && destination_rect && destination_video_rect && layers)) + return VDP_STATUS_INVALID_POINTER; + + return VDP_STATUS_NO_IMPLEMENTATION; +} + +VdpStatus +vlVdpVideoMixerSetAttributeValues ( + VdpVideoMixer mixer, + uint32_t attribute_count, + VdpVideoMixerAttribute const *attributes, + void const *const *attribute_values) +{ + if (!(attributes && attribute_values)) + return VDP_STATUS_INVALID_POINTER; + + vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); + if (!vmixer) + return VDP_STATUS_INVALID_HANDLE; + + return VDP_STATUS_OK; +} \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c index d88afb495f7..3c456a07ca1 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c @@ -73,6 +73,8 @@ vlVdpMPEG2BitstreamToMacroblock ( bool b_header_done = false; struct vdpMPEG2BitstreamParser parser; + debug_printf("[VDPAU] Starting decoding MPEG2 stream"); + num_macroblocks[0] = 0; memset(&parser,0,sizeof(parser)); diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c index c5f06896c58..20097eaf98c 100644 --- a/src/gallium/state_trackers/vdpau/output.c +++ b/src/gallium/state_trackers/vdpau/output.c @@ -28,6 +28,7 @@ #include "vdpau_private.h" #include #include +#include VdpStatus vlVdpOutputSurfaceCreate ( VdpDevice device, @@ -35,9 +36,29 @@ vlVdpOutputSurfaceCreate ( VdpDevice device, uint32_t width, uint32_t height, VdpOutputSurface *surface) { + vlVdpOutputSurface *vlsurface = NULL; + debug_printf("[VDPAU] Creating output surface\n"); if (!(width && height)) return VDP_STATUS_INVALID_SIZE; + + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) + return VDP_STATUS_INVALID_HANDLE; + + vlsurface = CALLOC(1, sizeof(vlVdpOutputSurface)); + if (!vlsurface) + return VDP_STATUS_RESOURCES; + + vlsurface->width = width; + vlsurface->height = height; + vlsurface->format = FormatRGBAToPipe(rgba_format); + + *surface = vlAddDataHTAB(vlsurface); + if (*surface == 0) { + FREE(dev); + return VDP_STATUS_ERROR; + } - return VDP_STATUS_NO_IMPLEMENTATION; + return VDP_STATUS_OK; } \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/preemption.c b/src/gallium/state_trackers/vdpau/preemption.c index e69de29bb2d..4572bdcfe6d 100644 --- a/src/gallium/state_trackers/vdpau/preemption.c +++ b/src/gallium/state_trackers/vdpau/preemption.c @@ -0,0 +1,39 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + #include + + void vlVdpPreemptionCallback (VdpDevice device, void *context) + { + /* TODO: Implement preemption */ + } + + VdpStatus vlVdpPreemptionCallbackRegister (VdpDevice device, VdpPreemptionCallback callback, void *context) + { + + return VDP_STATUS_OK; + } \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c index 8200cf04326..5f545d0bb27 100644 --- a/src/gallium/state_trackers/vdpau/presentation.c +++ b/src/gallium/state_trackers/vdpau/presentation.c @@ -28,6 +28,7 @@ #include "vdpau_private.h" #include #include +#include VdpStatus vlVdpPresentationQueueTargetDestroy (VdpPresentationQueueTarget presentation_queue_target) @@ -41,12 +42,39 @@ vlVdpPresentationQueueCreate ( VdpDevice device, VdpPresentationQueueTarget presentation_queue_target, VdpPresentationQueue *presentation_queue) { - debug_printf("[VDPAU] Creating presentation queue\n"); + debug_printf("[VDPAU] Creating PresentationQueue\n"); + VdpStatus ret; + vlVdpPresentationQueue *pq = NULL; if (!presentation_queue) return VDP_STATUS_INVALID_POINTER; - - return VDP_STATUS_NO_IMPLEMENTATION; + + vlVdpDevice *dev = vlGetDataHTAB(device); + if (!dev) + return VDP_STATUS_INVALID_HANDLE; + + vlVdpPresentationQueueTarget *pqt = vlGetDataHTAB(presentation_queue_target); + if (!pqt) + return VDP_STATUS_INVALID_HANDLE; + + if (dev != pqt->device) + return VDP_STATUS_HANDLE_DEVICE_MISMATCH; + + pq = CALLOC(1, sizeof(vlVdpPresentationQueue)); + if (!pq) + return VDP_STATUS_RESOURCES; + + *presentation_queue = vlAddDataHTAB(pq); + if (*presentation_queue == 0) { + ret = VDP_STATUS_ERROR; + goto no_handle; + } + + + return VDP_STATUS_OK; + no_handle: + FREE(pq); + return ret; } VdpStatus diff --git a/src/gallium/state_trackers/vdpau/render.c b/src/gallium/state_trackers/vdpau/render.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index 635d6c8acdb..36ef124c13d 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -30,6 +30,7 @@ #include +#include #include #include #include @@ -73,6 +74,7 @@ static VdpChromaType PipeToType(enum pipe_video_chroma_format pipe_type) return -1; } + static enum pipe_format FormatToPipe(VdpYCbCrFormat vdpau_format) { switch (vdpau_format) { @@ -95,6 +97,26 @@ static enum pipe_format FormatToPipe(VdpYCbCrFormat vdpau_format) return -1; } +static enum pipe_format FormatRGBAToPipe(VdpRGBAFormat vdpau_format) +{ + switch (vdpau_format) { + case VDP_RGBA_FORMAT_A8: + return PIPE_FORMAT_A8_UNORM; + case VDP_RGBA_FORMAT_B10G10R10A2: + return PIPE_FORMAT_B10G10R10A2_UNORM; + case VDP_RGBA_FORMAT_B8G8R8A8: + return PIPE_FORMAT_B8G8R8A8_UNORM; + case VDP_RGBA_FORMAT_R10G10B10A2: + return PIPE_FORMAT_R10G10B10A2_UNORM; + case VDP_RGBA_FORMAT_R8G8B8A8: + return PIPE_FORMAT_R8G8B8A8_UNORM; + default: + assert(0); + } + + return -1; +} + static VdpYCbCrFormat PipeToFormat(enum pipe_format p_format) { switch (p_format) { @@ -145,6 +167,23 @@ typedef struct int screen; } vlVdpDevice; +typedef struct +{ + vlVdpDevice *device; + Drawable drawable; +} vlVdpPresentationQueueTarget; + +typedef struct +{ + vlVdpDevice *device; + Drawable drawable; +} vlVdpPresentationQueue; + +typedef struct +{ + vlVdpDevice *device; +} vlVdpVideoMixer; + typedef struct { vlVdpDevice *device; @@ -157,6 +196,14 @@ typedef struct uint8_t *data; } vlVdpSurface; +typedef struct +{ + vlVdpDevice *device; + uint32_t width; + uint32_t height; + enum pipe_format format; +} vlVdpOutputSurface; + typedef struct { vlVdpDevice *device; @@ -174,6 +221,11 @@ vlHandle vlAddDataHTAB(void *data); void* vlGetDataHTAB(vlHandle handle); boolean vlGetFuncFTAB(VdpFuncId function_id, void **func); +/* Public functions */ +VdpDeviceCreateX11 vdp_imp_device_create_x11; +VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11; + +/* Internal function pointers */ VdpGetErrorString vlVdpGetErrorString; VdpDeviceDestroy vlVdpDeviceDestroy; VdpGetProcAddress vlVdpGetProcAddress; @@ -213,4 +265,13 @@ VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime; VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay; VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle; VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus; +VdpPreemptionCallback vlVdpPreemptionCallback; +VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister; +VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables; +VdpVideoMixerCreate vlVdpVideoMixerCreate; +VdpVideoMixerRender vlVdpVideoMixerRender; +VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues; +VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix; + + #endif // VDPAU_PRIVATE_H From bff1ac875c2c62ba5045bb953f800253c49361cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Thu, 7 Oct 2010 00:26:46 +0200 Subject: [PATCH 19/36] vl: some more fixes and addition to the decoder handling --- src/gallium/state_trackers/vdpau/decode.c | 27 +++++++++++-------- src/gallium/state_trackers/vdpau/device.c | 10 +++++++ src/gallium/state_trackers/vdpau/mixer.c | 5 ++++ .../state_trackers/vdpau/vdpau_private.h | 8 +++--- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index f6003304668..1b49b4b2520 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -74,7 +74,10 @@ vlVdpDecoderCreate ( VdpDevice device, // TODO: Define max_references. Used mainly for H264 vldecoder->profile = p_profile; + vldecoder->height = height; + vldecoder->width = width; vldecoder->device = dev; + vldecoder->vctx = NULL; *decoder = vlAddDataHTAB(vldecoder); if (*decoder == 0) { @@ -127,27 +130,27 @@ vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder, { struct pipe_resource tmplt; struct pipe_resource *surf_tex; - struct pipe_video_context *vpipe; + struct pipe_video_context *vctx; debug_printf("[VDPAU] Creating surface\n"); if(!(vldecoder && vlsurf)) return VDP_STATUS_INVALID_POINTER; - vpipe = vldecoder->vctx; + vctx = vldecoder->vctx; memset(&tmplt, 0, sizeof(struct pipe_resource)); tmplt.target = PIPE_TEXTURE_2D; tmplt.format = vlsurf->format; tmplt.last_level = 0; - if (vpipe->is_format_supported(vpipe, tmplt.format, + if (vctx->is_format_supported(vctx, tmplt.format, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET, PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO)) { tmplt.width0 = vlsurf->width; tmplt.height0 = vlsurf->height; } else { - assert(vpipe->is_format_supported(vpipe, tmplt.format, + assert(vctx->is_format_supported(vctx, tmplt.format, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET, PIPE_TEXTURE_GEOM_NON_SQUARE)); tmplt.width0 = util_next_power_of_two(vlsurf->width); @@ -158,9 +161,9 @@ vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder, tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; tmplt.flags = 0; - surf_tex = vpipe->screen->resource_create(vpipe->screen, &tmplt); + surf_tex = vctx->screen->resource_create(vctx->screen, &tmplt); - vlsurf->psurface = vpipe->screen->get_tex_surface(vpipe->screen, surf_tex, 0, 0, 0, + vlsurf->psurface = vctx->screen->get_tex_surface(vctx->screen, surf_tex, 0, 0, 0, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET); pipe_resource_reference(&surf_tex, NULL); @@ -193,7 +196,6 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, debug_printf("[VDPAU] Decoding MPEG2\n"); - vpipe = vldecoder->vctx->vpipe; t_vdp_surf = vlsurf; /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */ @@ -218,6 +220,8 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, ret = vlVdpCreateSurfaceTarget(vldecoder,t_vdp_surf); + vpipe = vldecoder->vctx->vpipe; + if (vlVdpMPEG2BitstreamToMacroblock(vpipe->screen, bitstream_buffers, bitstream_buffer_count, &num_macroblocks, &pipe_macroblocks)) { @@ -228,7 +232,7 @@ vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder, } vpipe->set_decode_target(vpipe,t_surf); - //vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, (struct pipe_macroblock *)pipe_macroblocks, NULL); + vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, (struct pipe_macroblock *)pipe_macroblocks, NULL); skip_frame: return ret; @@ -263,14 +267,15 @@ vlVdpDecoderRender (VdpDecoder decoder, if (vlsurf->device != vldecoder->device) return VDP_STATUS_HANDLE_DEVICE_MISMATCH; - if (vlsurf->chroma_format != vldecoder->chroma_format) - return VDP_STATUS_INVALID_CHROMA_TYPE; + /* Test doesn't make sence */ + /*if (vlsurf->chroma_format != vldecoder->chroma_format) + return VDP_STATUS_INVALID_CHROMA_TYPE;*/ vscreen = vl_screen_create(vldecoder->device->display, vldecoder->device->screen); if (!vscreen) return VDP_STATUS_RESOURCES; - vldecoder->vctx = vl_video_create(vscreen, vldecoder->profile, vlsurf->format, vlsurf->width, vlsurf->height); + vldecoder->vctx = vl_video_create(vscreen, vldecoder->profile, vlsurf->format, vldecoder->width, vldecoder->height); if (!vldecoder->vctx) return VDP_STATUS_RESOURCES; diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c index 4ca198e874d..496e2b8def0 100644 --- a/src/gallium/state_trackers/vdpau/device.c +++ b/src/gallium/state_trackers/vdpau/device.c @@ -26,6 +26,7 @@ **************************************************************************/ #include +#include #include #include #include @@ -51,8 +52,15 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGe ret = VDP_STATUS_RESOURCES; goto no_dev; } + dev->display = display; dev->screen = screen; + dev->vscreen = vl_screen_create(display, screen); + if (!dev->vscreen) + { + ret = VDP_STATUS_RESOURCES; + goto no_vscreen; + } *device = vlAddDataHTAB(dev); if (*device == 0) { @@ -66,6 +74,8 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGe return VDP_STATUS_OK; no_handle: + /* Destroy vscreen */ +no_vscreen: FREE(dev); no_dev: vlDestroyHTAB(); diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c index 8bf42f53ff2..124125ebaad 100644 --- a/src/gallium/state_trackers/vdpau/mixer.c +++ b/src/gallium/state_trackers/vdpau/mixer.c @@ -130,6 +130,11 @@ vlVdpVideoMixerSetAttributeValues ( vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); if (!vmixer) return VDP_STATUS_INVALID_HANDLE; + + /* + * TODO: Implement the function + * + * */ return VDP_STATUS_OK; } \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index 36ef124c13d..de206365ce2 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -163,8 +163,9 @@ static enum pipe_video_profile ProfileToPipe(VdpDecoderProfile vdpau_profile) typedef struct { - void *display; + Display *display; int screen; + struct vl_screen *vscreen; } vlVdpDevice; typedef struct @@ -207,10 +208,11 @@ typedef struct typedef struct { vlVdpDevice *device; - struct vl_screen *vlscreen; - struct vl_context *vctx; + struct vl_context *vctx; enum pipe_video_chroma_format chroma_format; enum pipe_video_profile profile; + uint32_t width; + uint32_t height; } vlVdpDecoder; typedef uint32_t vlHandle; From 7d2bdc2d4db8321a72edcc921a0fcfa4e4d41ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Fri, 8 Oct 2010 13:59:31 +0200 Subject: [PATCH 20/36] vl: bitstream decoder finds startcodes --- .../drivers/softpipe/sp_video_context.c | 1 + src/gallium/state_trackers/vdpau/decode.c | 19 +++++++++---------- src/gallium/state_trackers/vdpau/ftab.c | 2 +- .../vdpau/mpeg2_bitstream_parser.c | 17 +++++++++-------- .../vdpau/mpeg2_bitstream_parser.h | 6 +++++- src/gallium/state_trackers/vdpau/surface.c | 5 +++-- .../state_trackers/vdpau/vdpau_private.h | 1 - 7 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c index 419ba946b89..a8c1b14428f 100644 --- a/src/gallium/drivers/softpipe/sp_video_context.c +++ b/src/gallium/drivers/softpipe/sp_video_context.c @@ -429,6 +429,7 @@ sp_mpeg12_create(struct pipe_context *pipe, enum pipe_video_profile profile, ctx->base.height = height; ctx->base.screen = pipe->screen; + ctx->base.destroy = sp_mpeg12_destroy; ctx->base.get_param = sp_mpeg12_get_param; ctx->base.is_format_supported = sp_mpeg12_is_format_supported; diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index 1b49b4b2520..5d3674c5eb2 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -40,10 +40,9 @@ vlVdpDecoderCreate ( VdpDevice device, VdpDecoder *decoder ) { - struct vl_screen *vscreen; - enum pipe_video_profile p_profile; - VdpStatus ret; - vlVdpDecoder *vldecoder; + enum pipe_video_profile p_profile = PIPE_VIDEO_PROFILE_UNKNOWN; + VdpStatus ret = VDP_STATUS_OK; + vlVdpDecoder *vldecoder = NULL; debug_printf("[VDPAU] Creating decoder\n"); @@ -137,12 +136,13 @@ vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder, if(!(vldecoder && vlsurf)) return VDP_STATUS_INVALID_POINTER; - vctx = vldecoder->vctx; + vctx = vldecoder->vctx->vpipe; memset(&tmplt, 0, sizeof(struct pipe_resource)); tmplt.target = PIPE_TEXTURE_2D; - tmplt.format = vlsurf->format; + tmplt.format = vctx->get_param(vctx,PIPE_CAP_DECODE_TARGET_PREFERRED_FORMAT); tmplt.last_level = 0; + if (vctx->is_format_supported(vctx, tmplt.format, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET, PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO)) { @@ -156,6 +156,7 @@ vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder, tmplt.width0 = util_next_power_of_two(vlsurf->width); tmplt.height0 = util_next_power_of_two(vlsurf->height); } + tmplt.depth0 = 1; tmplt.usage = PIPE_USAGE_DEFAULT; tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; @@ -170,7 +171,7 @@ vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder, if (!vlsurf->psurface) return VDP_STATUS_RESOURCES; - + debug_printf("[VDPAU] Done creating surface\n"); return VDP_STATUS_OK; } @@ -275,12 +276,10 @@ vlVdpDecoderRender (VdpDecoder decoder, if (!vscreen) return VDP_STATUS_RESOURCES; - vldecoder->vctx = vl_video_create(vscreen, vldecoder->profile, vlsurf->format, vldecoder->width, vldecoder->height); + vldecoder->vctx = vl_video_create(vscreen, vldecoder->profile, vlsurf->chroma_format, vldecoder->width, vldecoder->height); if (!vldecoder->vctx) return VDP_STATUS_RESOURCES; - vldecoder->vctx->vscreen = vscreen; - // TODO: Right now only mpeg2 is supported. switch (vldecoder->vctx->vpipe->profile) { case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE: diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c index 2142dcd4f6a..de08b810268 100644 --- a/src/gallium/state_trackers/vdpau/ftab.c +++ b/src/gallium/state_trackers/vdpau/ftab.c @@ -33,7 +33,7 @@ static void* ftab[67] = &vlVdpGetErrorString, /* VDP_FUNC_ID_GET_ERROR_STRING */ &vlVdpGetProcAddress, /* VDP_FUNC_ID_GET_PROC_ADDRESS */ &vlVdpGetApiVersion, /* VDP_FUNC_ID_GET_API_VERSION */ - 0x555, /* DUMMY */ + 0x55, /* DUMMY */ &vlVdpGetInformationString, /* VDP_FUNC_ID_GET_INFORMATION_STRING */ &vlVdpDeviceDestroy, /* VDP_FUNC_ID_DEVICE_DESTROY */ &vlVdpGenerateCSCMatrix, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */ diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c index 3c456a07ca1..436e7908e5b 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c @@ -30,8 +30,9 @@ int vlVdpMPEG2NextStartCode(struct vdpMPEG2BitstreamParser *parser) { - uint32_t integer = 0; - uint32_t bytes_to_end; + uint32_t integer = 0xffffff00; + uint8_t * ptr_read = parser->ptr_bitstream; + int32_t bytes_to_end; /* Move cursor to the start of a byte */ while(parser->cursor % 8) @@ -47,9 +48,9 @@ vlVdpMPEG2NextStartCode(struct vdpMPEG2BitstreamParser *parser) parser->state = MPEG2_HEADER_DONE; return 1; } - - integer << 8; - integer = integer & (unsigned char)(parser->ptr_bitstream + parser->cursor/8)[0]; + integer = ( integer | *ptr_read++ ) << 8; + + debug_printf("[VDPAU][Bitstream parser] Current read uint32_t: %08x .. Bytes to end: %d\n", integer,bytes_to_end); bytes_to_end--; parser->cursor += 8; @@ -57,7 +58,7 @@ vlVdpMPEG2NextStartCode(struct vdpMPEG2BitstreamParser *parser) } /* start_code found. rewind cursor a byte */ - parser->cursor -= 8; + //parser->cursor -= 8; return 0; } @@ -89,8 +90,8 @@ vlVdpMPEG2BitstreamToMacroblock ( { case MPEG2_HEADER_START_CODE: if (vlVdpMPEG2NextStartCode(&parser)) - continue; - + exit(1); + debug_printf("[VDPAU] START_CODE: %02x\n",(parser.ptr_bitstream + parser.cursor/8)[0]); /* Start_code found */ switch ((parser.ptr_bitstream + parser.cursor/8)[0]) { diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h index 74a216a4d81..b7e778f780b 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h @@ -44,7 +44,11 @@ struct vdpMPEG2BitstreamParser uint32_t cursor; // current bit cursor uint32_t cur_bitstream; uint32_t cur_bitstream_length; - unsigned char *ptr_bitstream; + uint8_t *ptr_bitstream; + + /* The decoded bitstream goes here: */ + /* Sequence_header_info */ + uint32_t horizontal_size_value; }; int diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c index f957d94bdf7..9b6dac9c3f4 100644 --- a/src/gallium/state_trackers/vdpau/surface.c +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -30,7 +30,6 @@ #include #include #include -#include VdpStatus vlVdpVideoSurfaceCreate(VdpDevice device, @@ -68,8 +67,10 @@ vlVdpVideoSurfaceCreate(VdpDevice device, goto inv_device; } - p_surf->chroma_format = FormatToPipe(chroma_type); + p_surf->chroma_format = TypeToPipe(chroma_type); p_surf->device = dev; + p_surf->width = width; + p_surf->height = height; *surface = vlAddDataHTAB(p_surf); if (*surface == 0) { diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index de206365ce2..d582b8e6c29 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -192,7 +192,6 @@ typedef struct uint32_t height; uint32_t pitch; struct pipe_surface *psurface; - enum pipe_format format; enum pipe_video_chroma_format chroma_format; uint8_t *data; } vlVdpSurface; From 2990292f0fdf36ae55c909da84f8927dc1aa9ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 13 Oct 2010 11:27:07 +0200 Subject: [PATCH 21/36] vl: more work on the bitstream_parser --- .../vdpau/mpeg2_bitstream_parser.c | 83 +++++++++++++------ .../vdpau/mpeg2_bitstream_parser.h | 18 ++-- 2 files changed, 70 insertions(+), 31 deletions(-) diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c index 436e7908e5b..90936584893 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c @@ -24,7 +24,8 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - +#include +#include #include "mpeg2_bitstream_parser.h" int @@ -32,31 +33,24 @@ vlVdpMPEG2NextStartCode(struct vdpMPEG2BitstreamParser *parser) { uint32_t integer = 0xffffff00; uint8_t * ptr_read = parser->ptr_bitstream; - int32_t bytes_to_end; - - /* Move cursor to the start of a byte */ - while(parser->cursor % 8) - parser->cursor++; + int8_t * bytes_to_end; - bytes_to_end = parser->cur_bitstream_length - parser->cursor/8 - 1; + bytes_to_end = parser->ptr_bitstream_end - parser->ptr_bitstream; /* Read byte after byte, until startcode is found */ while(integer != 0x00000100) { - if (bytes_to_end < 0) + if (bytes_to_end <= 0) { - parser->state = MPEG2_HEADER_DONE; - return 1; + parser->state = MPEG2_BITSTREAM_DONE; + parser->code = 0; + return 0; } integer = ( integer | *ptr_read++ ) << 8; - - debug_printf("[VDPAU][Bitstream parser] Current read uint32_t: %08x .. Bytes to end: %d\n", integer,bytes_to_end); - - bytes_to_end--; - parser->cursor += 8; - + bytes_to_end--; } - + parser->ptr_bitstream = ptr_read; + parser->code = parser->ptr_bitstream; /* start_code found. rewind cursor a byte */ //parser->cursor -= 8; @@ -74,37 +68,74 @@ vlVdpMPEG2BitstreamToMacroblock ( bool b_header_done = false; struct vdpMPEG2BitstreamParser parser; - debug_printf("[VDPAU] Starting decoding MPEG2 stream"); + #if(1) + FILE *fp; + + if ((fp = fopen("binout", "w"))==NULL) { + printf("Cannot open file.\n"); + exit(1); + } + fwrite(bitstream_buffers[0].bitstream, 1, bitstream_buffers[0].bitstream_bytes, fp); + fclose(fp); + + #endif + + + debug_printf("[VDPAU] Starting decoding MPEG2 stream\n"); num_macroblocks[0] = 0; memset(&parser,0,sizeof(parser)); parser.state = MPEG2_HEADER_START_CODE; - parser.cur_bitstream_length = bitstream_buffers[0].bitstream_bytes; parser.ptr_bitstream = (unsigned char *)bitstream_buffers[0].bitstream; + parser.ptr_bitstream_end = parser.ptr_bitstream + bitstream_buffers[0].bitstream_bytes; /* Main header parser loop */ while(!b_header_done) { switch (parser.state) { - case MPEG2_HEADER_START_CODE: + case MPEG2_SEEK_HEADER: if (vlVdpMPEG2NextStartCode(&parser)) exit(1); - debug_printf("[VDPAU] START_CODE: %02x\n",(parser.ptr_bitstream + parser.cursor/8)[0]); + break; /* Start_code found */ - switch ((parser.ptr_bitstream + parser.cursor/8)[0]) + switch (parser.code) { /* sequence_header_code */ case 0xB3: - debug_printf("[VDPAU][Bitstream parser] Sequence header code found at cursor pos: %d\n", parser.cursor); - exit(1); + debug_printf("[VDPAU][Bitstream parser] Sequence header code found\n"); + + /* We dont need to read this, because we already have this information */ break; + case 0xB5: + debug_printf("[VDPAU][Bitstream parser] Extension start code found\n"); + //exit(1); + break; + + case 0xB8: + debug_printf("[VDPAU][Bitstream parser] Extension start code found\n"); + //exit(1); + break; + } break; - case MPEG2_HEADER_DONE: - debug_printf("[VDPAU][Bitstream parser] Done parsing current header\n"); + case MPEG2_BITSTREAM_DONE: + if (parser.cur_bitstream < bitstream_buffer_count - 1) + { + debug_printf("[VDPAU][Bitstream parser] Done parsing current bitstream. Moving to the next\n"); + parser.cur_bitstream++; + parser.ptr_bitstream = (unsigned char *)bitstream_buffers[parser.cur_bitstream].bitstream; + parser.ptr_bitstream_end = parser.ptr_bitstream + bitstream_buffers[parser.cur_bitstream].bitstream_bytes; + parser.state = MPEG2_HEADER_START_CODE; + } + else + { + debug_printf("[VDPAU][Bitstream parser] Done with frame\n"); + exit(0); + // return 0; + } break; } diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h index b7e778f780b..414d6597c6c 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h @@ -34,17 +34,25 @@ enum vdpMPEG2States { - MPEG2_HEADER_START_CODE, - MPEG2_HEADER_DONE + MPEG2_SEEK_HEADER, + MPEG2_HEADER_DONE, + MPEG2_BITSTREAM_DONE + MPEG2 +}; + +enum vdpMPEG2Action +{ + MPEG2_ }; struct vdpMPEG2BitstreamParser { enum vdpMPEG2States state; - uint32_t cursor; // current bit cursor + enum vdpMPEG2Actions action; uint32_t cur_bitstream; - uint32_t cur_bitstream_length; - uint8_t *ptr_bitstream; + const uint8_t *ptr_bitstream_end; + const uint8_t *ptr_bitstream; + uint8_t code; /* The decoded bitstream goes here: */ /* Sequence_header_info */ From b122e50c3eabf157f8b7a3647590a37abd276c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Sat, 23 Oct 2010 15:59:45 +0200 Subject: [PATCH 22/36] vl: initial va-api implementation --- src/gallium/state_trackers/va/Makefile | 19 +++ src/gallium/state_trackers/va/ftab.c | 131 +++++++++++++++++++++ src/gallium/state_trackers/va/htab.c | 94 +++++++++++++++ src/gallium/state_trackers/va/va_private.h | 0 4 files changed, 244 insertions(+) create mode 100644 src/gallium/state_trackers/va/Makefile create mode 100644 src/gallium/state_trackers/va/ftab.c create mode 100644 src/gallium/state_trackers/va/htab.c create mode 100644 src/gallium/state_trackers/va/va_private.h diff --git a/src/gallium/state_trackers/va/Makefile b/src/gallium/state_trackers/va/Makefile new file mode 100644 index 00000000000..28fe5d09694 --- /dev/null +++ b/src/gallium/state_trackers/va/Makefile @@ -0,0 +1,19 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = vatracker + +VA_MAJOR = 0 +VA_MINOR = 3 +LIBRARY_DEFINES = -DVER_MAJOR=$(VA_MAJOR) -DVER_MINOR=$(VA_MINOR) $(STATE_TRACKER_DEFINES) + +LIBRARY_INCLUDES = \ + $(shell pkg-config --cflags-only-I vdpau) \ + -I$(TOP)/src/gallium/winsys/g3dvl + +C_SOURCES = htab.c \ + ftab.c + + +include ../../Makefile.template + diff --git a/src/gallium/state_trackers/va/ftab.c b/src/gallium/state_trackers/va/ftab.c new file mode 100644 index 00000000000..694390b3464 --- /dev/null +++ b/src/gallium/state_trackers/va/ftab.c @@ -0,0 +1,131 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include +#include + +const struct VADriverVTable vtable = +{ + 0, /* VAStatus (*vaTerminate) ( VADriverContextP ctx ); */ + 0, /* VAStatus (*vaQueryConfigProfiles) ( VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); */ + 0, /* VAStatus (*vaQueryConfigEntrypoints) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints ); */ + 0, /* VAStatus (*vaGetConfigAttributes) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs ); */ + 0, /* VAStatus (*vaCreateConfig) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); */ + 0, /* VAStatus (*vaDestroyConfig) ( VADriverContextP ctx, VAConfigID config_id); */ + 0, /* VAStatus (*vaQueryConfigAttributes) ( VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs); */ + 0, /* VAStatus (*vaCreateConfig) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); */ + 0, /* VAStatus (*vaDestroyConfig) ( VADriverContextP ctx, VAConfigID config_id ); */ + 0, /* VAStatus (*vaQueryConfigAttributes) (VADriverContextP ctx,VAConfigID config_id,VAProfile *profile,VAEntrypoint *entrypoint,VAConfigAttrib *attrib_list,int *num_attribs); */ + 0, /* VAStatus (*vaCreateSurfaces) ( VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces); */ + 0, /* VAStatus (*vaDestroySurfaces) ( VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces ); */ + 0, /* VAStatus (*vaCreateContext) (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context); */ + 0, /* VAStatus (*vaDestroyContext) (VADriverContextP ctx,VAContextID context); */ + 0, /* VAStatus (*vaCreateBuffer) (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id); */ + 0, /* VAStatus (*vaBufferSetNumElements) (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); */ + 0, /* VAStatus (*vaMapBuffer) (VADriverContextP ctx,VABufferID buf_id,void **pbuf); */ + 0, /* VAStatus (*vaUnmapBuffer) (VADriverContextP ctx,VABufferID buf_id); */ + 0, /* VAStatus (*vaDestroyBuffer) (VADriverContextP ctx,VABufferID buffer_id); */ + 0, /* VAStatus (*vaBeginPicture) (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); */ + 0, /* VAStatus (*vaRenderPicture) (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); */ + 0, /* VAStatus (*vaEndPicture) (VADriverContextP ctx,VAContextID context); */ + 0, /* VAStatus (*vaSyncSurface) (VADriverContextP ctx,VASurfaceID render_target); */ + 0, /* VAStatus (*vaQuerySurfaceStatus) (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status); */ + 0, /* VAStatus (*vaPutSurface) ( + VADriverContextP ctx, + VASurfaceID surface, + void* draw, + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth, + VARectangle *cliprects, + unsigned int number_cliprects, + unsigned int flags); */ + 0, /* VAStatus (*vaQueryImageFormats) ( VADriverContextP ctx, VAImageFormat *format_list,int *num_formats); */ + 0, /* VAStatus (*vaCreateImage) (VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); */ + 0, /* VAStatus (*vaDeriveImage) (VADriverContextP ctx,VASurfaceID surface,VAImage *image); */ + 0, /* VAStatus (*vaDestroyImage) (VADriverContextP ctx,VAImageID image); */ + 0, /* VAStatus (*vaSetImagePalette) (VADriverContextP ctx,VAImageID image, unsigned char *palette); */ + 0, /* VAStatus (*vaGetImage) (VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image); */ + 0, /* VAStatus (*vaPutImage) ( + VADriverContextP ctx, + VASurfaceID surface, + VAImageID image, + int src_x, + int src_y, + unsigned int src_width, + unsigned int src_height, + int dest_x, + int dest_y, + unsigned int dest_width, + unsigned int dest_height + ); */ + 0, /* VAStatus (*vaQuerySubpictureFormats) (VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); */ + 0, /* VAStatus (*vaCreateSubpicture) (VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture); */ + 0, /* VAStatus (*vaDestroySubpicture) (VADriverContextP ctx,VASubpictureID subpicture); */ + 0, /* VAStatus (*vaSetSubpictureImage) (VADriverContextP ctx,VASubpictureID subpicture,VAImageID image); */ + 0, /* VAStatus (*vaSetSubpictureChromakey) (VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask); */ + 0, /* VAStatus (*vaSetSubpictureGlobalAlpha) (VADriverContextP ctx,VASubpictureID subpicture,float global_alpha); */ + 0, /* VAStatus (*vaAssociateSubpicture) ( + VADriverContextP ctx, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces, + short src_x, + short src_y, + unsigned short src_width, + unsigned short src_height, + short dest_x, + short dest_y, + unsigned short dest_width, + unsigned short dest_height, + unsigned int flags); */ + 0, /* VAStatus (*vaDeassociateSubpicture) (VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces); */ + 0, /* VAStatus (*vaQueryDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes); */ + 0, /* VAStatus (*vaGetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ + 0, /* VAStatus (*vaSetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ + 0, /* VAStatus (*vaBufferInfo) (VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements); */ + 0, /* VAStatus (*vaLockSurface) ( + VADriverContextP ctx, + VASurfaceID surface, + unsigned int *fourcc, + unsigned int *luma_stride, + unsigned int *chroma_u_stride, + unsigned int *chroma_v_stride, + unsigned int *luma_offset, + unsigned int *chroma_u_offset, + unsigned int *chroma_v_offset, + unsigned int *buffer_name, + void **buffer); */ + 0, /* VAStatus (*vaUnlockSurface) (VADriverContextP ctx,VASurfaceID surface); */ + 0 /* struct VADriverVTableGLX *glx; "Optional" */ +}; + diff --git a/src/gallium/state_trackers/va/htab.c b/src/gallium/state_trackers/va/htab.c new file mode 100644 index 00000000000..7b7c111a4be --- /dev/null +++ b/src/gallium/state_trackers/va/htab.c @@ -0,0 +1,94 @@ +/************************************************************************** + * + * Copyright 2010 Younes Manton. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include +#include +#include "va_private.h" + +#ifdef VL_HANDLES +static struct handle_table *htab = NULL; +pipe_static_mutex(htab_lock); +#endif + +boolean vlCreateHTAB(void) +{ +#ifdef VL_HANDLES + boolean ret; + /* Make sure handle table handles match VDPAU handles. */ + assert(sizeof(unsigned) <= sizeof(vlHandle)); + pipe_mutex_lock(htab_lock); + if (!htab) + htab = handle_table_create(); + ret = htab != NULL; + pipe_mutex_unlock(htab_lock); + return ret; +#else + return TRUE; +#endif +} + +void vlDestroyHTAB(void) +{ +#ifdef VL_HANDLES + pipe_mutex_lock(htab_lock); + if (htab) { + handle_table_destroy(htab); + htab = NULL; + } + pipe_mutex_unlock(htab_lock); +#endif +} + +vlHandle vlAddDataHTAB(void *data) +{ + assert(data); +#ifdef VL_HANDLES + vlHandle handle = 0; + pipe_mutex_lock(htab_lock); + if (htab) + handle = handle_table_add(htab, data); + pipe_mutex_unlock(htab_lock); + return handle; +#else + return (vlHandle)data; +#endif +} + +void* vlGetDataHTAB(vlHandle handle) +{ + assert(handle); +#ifdef VL_HANDLES + void *data = NULL; + pipe_mutex_lock(htab_lock); + if (htab) + data = handle_table_get(htab, handle); + pipe_mutex_unlock(htab_lock); + return data; +#else + return (void*)handle; +#endif +} diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h new file mode 100644 index 00000000000..e69de29bb2d From 501ac572c604ef248ed41311a065bc5f4746fcb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Sun, 24 Oct 2010 19:27:29 +0200 Subject: [PATCH 23/36] vl: va state-tracker configuration scripts --- configs/autoconf.in | 3 ++ configure.ac | 27 ++++++++++++++-- src/gallium/state_trackers/va/Makefile | 2 +- src/gallium/state_trackers/va/ftab.c | 2 +- src/gallium/state_trackers/va/htab.c | 4 +++ src/gallium/state_trackers/va/va_private.h | 32 +++++++++++++++++++ .../vdpau/mpeg2_bitstream_parser.h | 9 ++---- .../state_trackers/vdpau/vdpau_private.h | 2 +- 8 files changed, 69 insertions(+), 12 deletions(-) diff --git a/configs/autoconf.in b/configs/autoconf.in index d7eb162b684..df52b3f42f6 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -160,6 +160,9 @@ EGL_DRIVER_INSTALL_DIR = @EGL_DRIVER_INSTALL_DIR@ # VDPAU library install directory VDPAU_LIB_INSTALL_DIR=@VDPAU_LIB_INSTALL_DIR@ +# VA library install directory +VA_LIB_INSTALL_DIR=@VA_LIB_INSTALL_DIR@ + # Xorg driver install directory (for xorg state-tracker) XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@ diff --git a/configure.ac b/configure.ac index 0344be00703..59c2eb157b7 100644 --- a/configure.ac +++ b/configure.ac @@ -1345,6 +1345,13 @@ yes) fi HAVE_ST_VDPAU="yes" ;; + va) + # Check for libva? + if test "x$enable_gallium_g3dvl" != xyes; then + AC_MSG_ERROR([cannot build va state tracker without --enable-gallium-g3dvl]) + fi + HAVE_ST_VA="yes" + ;; esac if test -n "$tracker"; then @@ -1479,7 +1486,7 @@ dnl dnl Gallium helper functions dnl gallium_check_st() { - if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_EGL" = xyes || test "x$HAVE_ST_XORG" = xyes || test "x$HAVE_ST_XVMC" = xyes || test "x$HAVE_ST_VDPAU" = xyes; then + if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_EGL" = xyes || test "x$HAVE_ST_XORG" = xyes || test "x$HAVE_ST_XVMC" = xyes || test "x$HAVE_ST_VDPAU" = xyes || test "x$HAVE_ST_VA" = xyes; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1" fi if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then @@ -1497,6 +1504,9 @@ gallium_check_st() { if test "x$HAVE_ST_VDPAU" = xyes && test "x$6" != x; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $6" fi + if test "x$HAVE_ST_VA" = xyes && test "x$7" != x; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $7" + fi } @@ -1613,8 +1623,13 @@ AC_ARG_ENABLE([gallium-g3dvl], if test "x$enable_gallium_g3dvl" = xyes; then case "$mesa_driver" in xlib) + if test "x$HAVE_ST_VDPAU" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS vdpau-softpipe" - ;; + fi + if test "x$HAVE_ST_VA" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS va-softpipe" + fi + ;; dri) GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS g3dvl/dri" ;; @@ -1628,6 +1643,14 @@ AC_ARG_WITH([vdpau-libdir], [VDPAU_LIB_INSTALL_DIR='${libdir}/vdpau']) AC_SUBST([VDPAU_LIB_INSTALL_DIR]) +dnl Directory for VA libs +AC_ARG_WITH([va-libdir], + [AS_HELP_STRING([--with-va-libdir=DIR], + [directory for the VA libraries @<:@default=${libdir}/va@:>@])], + [VA_LIB_INSTALL_DIR="$withval"], + [VA_LIB_INSTALL_DIR='${libdir}/va']) +AC_SUBST([VA_LIB_INSTALL_DIR]) + dnl dnl Gallium swrast configuration dnl diff --git a/src/gallium/state_trackers/va/Makefile b/src/gallium/state_trackers/va/Makefile index 28fe5d09694..15c6ee0ef6d 100644 --- a/src/gallium/state_trackers/va/Makefile +++ b/src/gallium/state_trackers/va/Makefile @@ -8,7 +8,7 @@ VA_MINOR = 3 LIBRARY_DEFINES = -DVER_MAJOR=$(VA_MAJOR) -DVER_MINOR=$(VA_MINOR) $(STATE_TRACKER_DEFINES) LIBRARY_INCLUDES = \ - $(shell pkg-config --cflags-only-I vdpau) \ + $(shell pkg-config --cflags-only-I va) \ -I$(TOP)/src/gallium/winsys/g3dvl C_SOURCES = htab.c \ diff --git a/src/gallium/state_trackers/va/ftab.c b/src/gallium/state_trackers/va/ftab.c index 694390b3464..034424cdee7 100644 --- a/src/gallium/state_trackers/va/ftab.c +++ b/src/gallium/state_trackers/va/ftab.c @@ -26,7 +26,7 @@ **************************************************************************/ #include -#include +#include const struct VADriverVTable vtable = { diff --git a/src/gallium/state_trackers/va/htab.c b/src/gallium/state_trackers/va/htab.c index 7b7c111a4be..069c7930927 100644 --- a/src/gallium/state_trackers/va/htab.c +++ b/src/gallium/state_trackers/va/htab.c @@ -29,6 +29,10 @@ #include #include "va_private.h" +#define VL_HANDLES + +typedef uint32_t vlHandle; + #ifdef VL_HANDLES static struct handle_table *htab = NULL; pipe_static_mutex(htab_lock); diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index e69de29bb2d..8264c259ed1 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -0,0 +1,32 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + #ifndef VA_PRIVATE_H + #define VA_PRIVATE_H + + + #endif // VA_PRIVATE_H \ No newline at end of file diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h index 414d6597c6c..25f3516f821 100644 --- a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h +++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h @@ -36,19 +36,14 @@ enum vdpMPEG2States { MPEG2_SEEK_HEADER, MPEG2_HEADER_DONE, - MPEG2_BITSTREAM_DONE - MPEG2 + MPEG2_BITSTREAM_DONE, + MPEG2_HEADER_START_CODE }; -enum vdpMPEG2Action -{ - MPEG2_ -}; struct vdpMPEG2BitstreamParser { enum vdpMPEG2States state; - enum vdpMPEG2Actions action; uint32_t cur_bitstream; const uint8_t *ptr_bitstream_end; const uint8_t *ptr_bitstream; diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index d582b8e6c29..1deea3a67d3 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2010 Younes Manton. + * Copyright 2010 Younes Manton & Thomas Balling Sørensen. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a From aea4d004d2781ebb9cf437c9125ca232dd2d0aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Mon, 25 Oct 2010 20:52:02 +0200 Subject: [PATCH 24/36] vl: more stub work for a va implementation --- src/gallium/state_trackers/va/Makefile | 6 +- src/gallium/state_trackers/va/ftab.c | 99 ++++++++++--------- src/gallium/state_trackers/va/va_context.c | 57 +++++++++++ src/gallium/state_trackers/va/va_image.c | 41 ++++++++ src/gallium/state_trackers/va/va_private.h | 16 ++- src/gallium/state_trackers/va/va_subpicture.c | 40 ++++++++ 6 files changed, 209 insertions(+), 50 deletions(-) create mode 100644 src/gallium/state_trackers/va/va_context.c create mode 100644 src/gallium/state_trackers/va/va_image.c create mode 100644 src/gallium/state_trackers/va/va_subpicture.c diff --git a/src/gallium/state_trackers/va/Makefile b/src/gallium/state_trackers/va/Makefile index 15c6ee0ef6d..1d6e303a4f1 100644 --- a/src/gallium/state_trackers/va/Makefile +++ b/src/gallium/state_trackers/va/Makefile @@ -12,7 +12,11 @@ LIBRARY_INCLUDES = \ -I$(TOP)/src/gallium/winsys/g3dvl C_SOURCES = htab.c \ - ftab.c + ftab.c \ + va_context.c \ + va_image.c \ + va_subpicture.c + include ../../Makefile.template diff --git a/src/gallium/state_trackers/va/ftab.c b/src/gallium/state_trackers/va/ftab.c index 034424cdee7..4b9dc576511 100644 --- a/src/gallium/state_trackers/va/ftab.c +++ b/src/gallium/state_trackers/va/ftab.c @@ -26,35 +26,34 @@ **************************************************************************/ #include +#include #include +#include "va_private.h" -const struct VADriverVTable vtable = +static struct VADriverVTable vtable = { - 0, /* VAStatus (*vaTerminate) ( VADriverContextP ctx ); */ - 0, /* VAStatus (*vaQueryConfigProfiles) ( VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); */ - 0, /* VAStatus (*vaQueryConfigEntrypoints) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints ); */ - 0, /* VAStatus (*vaGetConfigAttributes) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs ); */ - 0, /* VAStatus (*vaCreateConfig) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); */ - 0, /* VAStatus (*vaDestroyConfig) ( VADriverContextP ctx, VAConfigID config_id); */ - 0, /* VAStatus (*vaQueryConfigAttributes) ( VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs); */ - 0, /* VAStatus (*vaCreateConfig) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); */ - 0, /* VAStatus (*vaDestroyConfig) ( VADriverContextP ctx, VAConfigID config_id ); */ - 0, /* VAStatus (*vaQueryConfigAttributes) (VADriverContextP ctx,VAConfigID config_id,VAProfile *profile,VAEntrypoint *entrypoint,VAConfigAttrib *attrib_list,int *num_attribs); */ - 0, /* VAStatus (*vaCreateSurfaces) ( VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces); */ - 0, /* VAStatus (*vaDestroySurfaces) ( VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces ); */ - 0, /* VAStatus (*vaCreateContext) (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context); */ - 0, /* VAStatus (*vaDestroyContext) (VADriverContextP ctx,VAContextID context); */ - 0, /* VAStatus (*vaCreateBuffer) (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id); */ - 0, /* VAStatus (*vaBufferSetNumElements) (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); */ - 0, /* VAStatus (*vaMapBuffer) (VADriverContextP ctx,VABufferID buf_id,void **pbuf); */ - 0, /* VAStatus (*vaUnmapBuffer) (VADriverContextP ctx,VABufferID buf_id); */ - 0, /* VAStatus (*vaDestroyBuffer) (VADriverContextP ctx,VABufferID buffer_id); */ - 0, /* VAStatus (*vaBeginPicture) (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); */ - 0, /* VAStatus (*vaRenderPicture) (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); */ - 0, /* VAStatus (*vaEndPicture) (VADriverContextP ctx,VAContextID context); */ - 0, /* VAStatus (*vaSyncSurface) (VADriverContextP ctx,VASurfaceID render_target); */ - 0, /* VAStatus (*vaQuerySurfaceStatus) (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status); */ - 0, /* VAStatus (*vaPutSurface) ( + 0x1, /* VAStatus (*vaTerminate) ( VADriverContextP ctx ); */ + 0x2, /* VAStatus (*vaQueryConfigProfiles) ( VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); */ + 0x3, /* VAStatus (*vaQueryConfigEntrypoints) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints ); */ + 0x4, /* VAStatus (*vaGetConfigAttributes) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs ); */ + 0x5, /* VAStatus (*vaCreateConfig) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); */ + 0x6, /* VAStatus (*vaDestroyConfig) ( VADriverContextP ctx, VAConfigID config_id); */ + 0x7, /* VAStatus (*vaQueryConfigAttributes) ( VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs); */ + 0x8, /* VAStatus (*vaCreateSurfaces) ( VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces); */ + 0x9, /* VAStatus (*vaDestroySurfaces) ( VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces ); */ + 0x10, /* VAStatus (*vaCreateContext) (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context); */ + 0x11, /* VAStatus (*vaDestroyContext) (VADriverContextP ctx,VAContextID context); */ + 0x12, /* VAStatus (*vaCreateBuffer) (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id); */ + 0x13, /* VAStatus (*vaBufferSetNumElements) (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); */ + 0x14, /* VAStatus (*vaMapBuffer) (VADriverContextP ctx,VABufferID buf_id,void **pbuf); */ + 0x15, /* VAStatus (*vaUnmapBuffer) (VADriverContextP ctx,VABufferID buf_id); */ + 0x16, /* VAStatus (*vaDestroyBuffer) (VADriverContextP ctx,VABufferID buffer_id); */ + 0x17, /* VAStatus (*vaBeginPicture) (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); */ + 0x18, /* VAStatus (*vaRenderPicture) (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); */ + 0x19, /* VAStatus (*vaEndPicture) (VADriverContextP ctx,VAContextID context); */ + 0x20, /* VAStatus (*vaSyncSurface) (VADriverContextP ctx,VASurfaceID render_target); */ + 0x21, /* VAStatus (*vaQuerySurfaceStatus) (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status); */ + 0x22, /* VAStatus (*vaPutSurface) ( VADriverContextP ctx, VASurfaceID surface, void* draw, @@ -69,13 +68,13 @@ const struct VADriverVTable vtable = VARectangle *cliprects, unsigned int number_cliprects, unsigned int flags); */ - 0, /* VAStatus (*vaQueryImageFormats) ( VADriverContextP ctx, VAImageFormat *format_list,int *num_formats); */ - 0, /* VAStatus (*vaCreateImage) (VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); */ - 0, /* VAStatus (*vaDeriveImage) (VADriverContextP ctx,VASurfaceID surface,VAImage *image); */ - 0, /* VAStatus (*vaDestroyImage) (VADriverContextP ctx,VAImageID image); */ - 0, /* VAStatus (*vaSetImagePalette) (VADriverContextP ctx,VAImageID image, unsigned char *palette); */ - 0, /* VAStatus (*vaGetImage) (VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image); */ - 0, /* VAStatus (*vaPutImage) ( + &vlVaQueryImageFormats, /* VAStatus (*vaQueryImageFormats) ( VADriverContextP ctx, VAImageFormat *format_list,int *num_formats); */ + 0x24, /* VAStatus (*vaCreateImage) (VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); */ + 0x25, /* VAStatus (*vaDeriveImage) (VADriverContextP ctx,VASurfaceID surface,VAImage *image); */ + 0x26, /* VAStatus (*vaDestroyImage) (VADriverContextP ctx,VAImageID image); */ + 0x27, /* VAStatus (*vaSetImagePalette) (VADriverContextP ctx,VAImageID image, unsigned char *palette); */ + 0x28, /* VAStatus (*vaGetImage) (VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image); */ + 0x29, /* VAStatus (*vaPutImage) ( VADriverContextP ctx, VASurfaceID surface, VAImageID image, @@ -88,13 +87,13 @@ const struct VADriverVTable vtable = unsigned int dest_width, unsigned int dest_height ); */ - 0, /* VAStatus (*vaQuerySubpictureFormats) (VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); */ - 0, /* VAStatus (*vaCreateSubpicture) (VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture); */ - 0, /* VAStatus (*vaDestroySubpicture) (VADriverContextP ctx,VASubpictureID subpicture); */ - 0, /* VAStatus (*vaSetSubpictureImage) (VADriverContextP ctx,VASubpictureID subpicture,VAImageID image); */ - 0, /* VAStatus (*vaSetSubpictureChromakey) (VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask); */ - 0, /* VAStatus (*vaSetSubpictureGlobalAlpha) (VADriverContextP ctx,VASubpictureID subpicture,float global_alpha); */ - 0, /* VAStatus (*vaAssociateSubpicture) ( + &vlVaQuerySubpictureFormats, /* VAStatus (*vaQuerySubpictureFormats) (VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); */ + 0x31, /* VAStatus (*vaCreateSubpicture) (VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture); */ + 0x32, /* VAStatus (*vaDestroySubpicture) (VADriverContextP ctx,VASubpictureID subpicture); */ + 0x33, /* VAStatus (*vaSetSubpictureImage) (VADriverContextP ctx,VASubpictureID subpicture,VAImageID image); */ + 0x34, /* VAStatus (*vaSetSubpictureChromakey) (VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask); */ + 0x35, /* VAStatus (*vaSetSubpictureGlobalAlpha) (VADriverContextP ctx,VASubpictureID subpicture,float global_alpha); */ + 0x36, /* VAStatus (*vaAssociateSubpicture) ( VADriverContextP ctx, VASubpictureID subpicture, VASurfaceID *target_surfaces, @@ -108,12 +107,12 @@ const struct VADriverVTable vtable = unsigned short dest_width, unsigned short dest_height, unsigned int flags); */ - 0, /* VAStatus (*vaDeassociateSubpicture) (VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces); */ - 0, /* VAStatus (*vaQueryDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes); */ - 0, /* VAStatus (*vaGetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ - 0, /* VAStatus (*vaSetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ - 0, /* VAStatus (*vaBufferInfo) (VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements); */ - 0, /* VAStatus (*vaLockSurface) ( + 0x37, /* VAStatus (*vaDeassociateSubpicture) (VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces); */ + 0x38, /* VAStatus (*vaQueryDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes); */ + 0x39, /* VAStatus (*vaGetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ + 0x40, /* VAStatus (*vaSetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ + 0x41, /* VAStatus (*vaBufferInfo) (VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements); */ + 0x42, /* VAStatus (*vaLockSurface) ( VADriverContextP ctx, VASurfaceID surface, unsigned int *fourcc, @@ -125,7 +124,11 @@ const struct VADriverVTable vtable = unsigned int *chroma_v_offset, unsigned int *buffer_name, void **buffer); */ - 0, /* VAStatus (*vaUnlockSurface) (VADriverContextP ctx,VASurfaceID surface); */ - 0 /* struct VADriverVTableGLX *glx; "Optional" */ + 0x43, /* VAStatus (*vaUnlockSurface) (VADriverContextP ctx,VASurfaceID surface); */ + 0x44 /* struct VADriverVTableGLX *glx; "Optional" */ }; +struct VADriverVTable vlVaGetVtable() +{ + return vtable; +} \ No newline at end of file diff --git a/src/gallium/state_trackers/va/va_context.c b/src/gallium/state_trackers/va/va_context.c new file mode 100644 index 00000000000..0b8d7865f73 --- /dev/null +++ b/src/gallium/state_trackers/va/va_context.c @@ -0,0 +1,57 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include +#include +#include +#include +#include +#include "va_private.h" + +//struct VADriverVTable vlVaGetVtable(); + +PUBLIC +VAStatus __vaDriverInit_0_31 (VADriverContextP ctx) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + ctx->str_vendor = "mesa gallium vaapi"; + ctx->vtable = vlVaGetVtable(); + ctx->max_attributes = 1; + ctx->max_display_attributes = 1; + ctx->max_entrypoints = 1; + ctx->max_image_formats = 1; + ctx->max_profiles = 1; + ctx->max_subpic_formats = 1; + ctx->version_major = 3; + ctx->version_minor = 1; + + VA_INFO("vl_screen_pointer %p\n",ctx->native_dpy); + + return VA_STATUS_SUCCESS; +} \ No newline at end of file diff --git a/src/gallium/state_trackers/va/va_image.c b/src/gallium/state_trackers/va/va_image.c new file mode 100644 index 00000000000..05b3ffcf403 --- /dev/null +++ b/src/gallium/state_trackers/va/va_image.c @@ -0,0 +1,41 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + #include + #include + #include + #include + #include "va_private.h" + + VAStatus + vlVaQueryImageFormats ( VADriverContextP ctx, + VAImageFormat *format_list, + int *num_formats) +{ + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} \ No newline at end of file diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 8264c259ed1..9688097098a 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -28,5 +28,19 @@ #ifndef VA_PRIVATE_H #define VA_PRIVATE_H + #include + #include + #define VA_DEBUG(_str,...) debug_printf("[Gallium VA backend]: " _str,__VA_ARGS__) + #define VA_INFO(_str,...) VA_DEBUG("INFO: " _str,__VA_ARGS__) + #define VA_WARNING(_str,...) VA_DEBUG("WARNING: " _str,__VA_ARGS__) + #define VA_ERROR(_str,...) VA_DEBUG("ERROR: " _str,__VA_ARGS__) + +// Public functions: +VAStatus __vaDriverInit_0_31 (VADriverContextP ctx); + +// Private functions: +struct VADriverVTable vlVaGetVtable(); +VAStatus vlVaQueryImageFormats (VADriverContextP ctx,VAImageFormat *format_list,int *num_formats); +VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); - #endif // VA_PRIVATE_H \ No newline at end of file + #endif // VA_PRIVATE_H diff --git a/src/gallium/state_trackers/va/va_subpicture.c b/src/gallium/state_trackers/va/va_subpicture.c new file mode 100644 index 00000000000..211970913fa --- /dev/null +++ b/src/gallium/state_trackers/va/va_subpicture.c @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include +#include +#include "va_private.h" + +VAStatus +vlVaQuerySubpictureFormats( VADriverContextP ctx, + VAImageFormat *format_list, + unsigned int *flags, + unsigned int *num_formats) +{ + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} \ No newline at end of file From 1dccc4cfaa423f15ab582d2a0253a84a0ae0b9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Mon, 25 Oct 2010 21:38:08 +0200 Subject: [PATCH 25/36] vl: add'ed stub for VaCreateImage --- src/gallium/state_trackers/va/ftab.c | 2 +- src/gallium/state_trackers/va/va_image.c | 15 +++++++++++++++ src/gallium/state_trackers/va/va_private.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/ftab.c b/src/gallium/state_trackers/va/ftab.c index 4b9dc576511..651b7660964 100644 --- a/src/gallium/state_trackers/va/ftab.c +++ b/src/gallium/state_trackers/va/ftab.c @@ -69,7 +69,7 @@ static struct VADriverVTable vtable = unsigned int number_cliprects, unsigned int flags); */ &vlVaQueryImageFormats, /* VAStatus (*vaQueryImageFormats) ( VADriverContextP ctx, VAImageFormat *format_list,int *num_formats); */ - 0x24, /* VAStatus (*vaCreateImage) (VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); */ + &vlVaCreateImage, /* VAStatus (*vaCreateImage) (VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); */ 0x25, /* VAStatus (*vaDeriveImage) (VADriverContextP ctx,VASurfaceID surface,VAImage *image); */ 0x26, /* VAStatus (*vaDestroyImage) (VADriverContextP ctx,VAImageID image); */ 0x27, /* VAStatus (*vaSetImagePalette) (VADriverContextP ctx,VAImageID image, unsigned char *palette); */ diff --git a/src/gallium/state_trackers/va/va_image.c b/src/gallium/state_trackers/va/va_image.c index 05b3ffcf403..b7e1320a4e8 100644 --- a/src/gallium/state_trackers/va/va_image.c +++ b/src/gallium/state_trackers/va/va_image.c @@ -36,6 +36,21 @@ VAImageFormat *format_list, int *num_formats) { + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaCreateImage( VADriverContextP ctx, + VAImageFormat *format, + int width, + int height, + VAImage *image) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + return VA_STATUS_ERROR_UNIMPLEMENTED; } \ No newline at end of file diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 9688097098a..ccaa5c053ea 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -42,5 +42,6 @@ VAStatus __vaDriverInit_0_31 (VADriverContextP ctx); struct VADriverVTable vlVaGetVtable(); VAStatus vlVaQueryImageFormats (VADriverContextP ctx,VAImageFormat *format_list,int *num_formats); VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); +VAStatus vlVaCreateImage(VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); #endif // VA_PRIVATE_H From 6ac1bbe21a978e326e6361426343b61d10140aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 26 Oct 2010 13:44:19 +0200 Subject: [PATCH 26/36] =?UTF-8?q?vl:=20pipe-video=20branch=20merged=20with?= =?UTF-8?q?=20K=C3=B6nigs=20pipe-video=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configure.ac | 25 ++----------- .../drivers/softpipe/sp_video_context.c | 37 ++++--------------- src/gallium/include/pipe/p_defines.h | 10 ----- src/gallium/include/pipe/p_format.h | 6 +-- src/gallium/include/pipe/p_screen.h | 8 ---- 5 files changed, 14 insertions(+), 72 deletions(-) diff --git a/configure.ac b/configure.ac index c9daffbb3ae..5edd935920d 100644 --- a/configure.ac +++ b/configure.ac @@ -1486,11 +1486,7 @@ dnl dnl Gallium helper functions dnl gallium_check_st() { -<<<<<<< HEAD - if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_EGL" = xyes || test "x$HAVE_ST_XORG" = xyes || test "x$HAVE_ST_XVMC" = xyes || test "x$HAVE_ST_VDPAU" = xyes || test "x$HAVE_ST_VA" = xyes; then -======= - if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes || test "x$HAVE_ST_XVMC" = xyes; then ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 + if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes || test "x$HAVE_ST_XVMC" = xyes || test "x$HAVE_ST_VDPAU" = xyes || test "x$HAVE_ST_VA" = xyes; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1" fi if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then @@ -1499,24 +1495,15 @@ gallium_check_st() { if test "x$HAVE_ST_XORG" = xyes && test "x$3" != x; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3" fi -<<<<<<< HEAD - if test "x$HAVE_ST_XORG" = xyes && test "x$4" != x; then + if test "x$HAVE_ST_XVMC" = xyes && test "x$4" != x; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $4" fi - if test "x$HAVE_ST_XVMC" = xyes && test "x$5" != x; then + if test "x$HAVE_ST_VDPAU" = xyes && test "x$5" != x; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $5" fi - if test "x$HAVE_ST_VDPAU" = xyes && test "x$6" != x; then + if test "x$HAVE_ST_VA" = xyes && test "x$6" != x; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $6" fi - if test "x$HAVE_ST_VA" = xyes && test "x$7" != x; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $7" - fi -======= - if test "x$HAVE_ST_XVMC" = xyes && test "x$5" != x; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $5" - fi ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 } @@ -1619,11 +1606,7 @@ AC_ARG_ENABLE([gallium-nouveau], [enable_gallium_nouveau=no]) if test "x$enable_gallium_nouveau" = xyes; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50" -<<<<<<< HEAD - gallium_check_st "nouveau/drm" "dri-nouveau" "egl-nouveau" "xorg-nouveau" "xvmc-nouveau" -======= gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" "xvmc-nouveau" ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 fi dnl diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c index f39c46e596c..9acf7171e5a 100644 --- a/src/gallium/drivers/softpipe/sp_video_context.c +++ b/src/gallium/drivers/softpipe/sp_video_context.c @@ -98,13 +98,9 @@ sp_mpeg12_is_format_supported(struct pipe_video_context *vpipe, if (geom & PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO) return FALSE; -<<<<<<< HEAD - return ctx->pipe->screen->is_format_supported(ctx->pipe->screen, format, PIPE_TEXTURE_2D, 1, - usage, geom); -======= + return ctx->pipe->screen->is_format_supported(ctx->pipe->screen, format, PIPE_TEXTURE_2D, 0, usage, geom); ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 } static void @@ -134,7 +130,6 @@ static void sp_mpeg12_clear_render_target(struct pipe_video_context *vpipe, struct pipe_surface *dst, unsigned dstx, unsigned dsty, - const float *rgba, unsigned width, unsigned height) { struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; @@ -151,12 +146,10 @@ sp_mpeg12_clear_render_target(struct pipe_video_context *vpipe, static void sp_mpeg12_resource_copy_region(struct pipe_video_context *vpipe, - struct pipe_resource *dst, - struct pipe_subresource subdst, - unsigned dstx, unsigned dsty, unsigned dstz, - struct pipe_resource *src, - struct pipe_subresource subsrc, - unsigned srcx, unsigned srcy, unsigned srcz, + struct pipe_surface *dst, + unsigned dstx, unsigned dsty, + struct pipe_surface *src, + unsigned srcx, unsigned srcy, unsigned width, unsigned height) { struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; @@ -164,13 +157,7 @@ sp_mpeg12_resource_copy_region(struct pipe_video_context *vpipe, assert(vpipe); assert(dst); -<<<<<<< HEAD - if (ctx->pipe->resource_copy_region) - ctx->pipe->resource_copy_region(ctx->pipe, dst, subdst, dstx, dsty, dstz, src, subsrc, srcx, srcy, srcz, width, height); - else - util_resource_copy_region(ctx->pipe, dst, subdst, dstx, dsty, dstz, src, subsrc, srcx, srcy, srcz, width, height); -======= - struct pipe_subresource subdst, subsrc; + struct pipe_subresource subdst,subsrc; subdst.face = dst->face; subdst.level = dst->level; subsrc.face = src->face; @@ -184,7 +171,6 @@ sp_mpeg12_resource_copy_region(struct pipe_video_context *vpipe, util_resource_copy_region(ctx->pipe, dst->texture, subdst, dstx, dsty, dst->zslice, src->texture, subsrc, srcx, srcy, src->zslice, width, height); ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 } static struct pipe_transfer* @@ -366,18 +352,12 @@ init_pipe_state(struct sp_mpeg12_context *ctx) rast.flatshade = 1; rast.flatshade_first = 0; rast.light_twoside = 0; -<<<<<<< HEAD - rast.cull_face = PIPE_FACE_FRONT; - rast.fill_front = PIPE_POLYGON_MODE_FILL; - rast.fill_back = PIPE_POLYGON_MODE_FILL; -======= rast.front_ccw = 1; rast.cull_face = PIPE_FACE_NONE; rast.fill_back = PIPE_POLYGON_MODE_FILL; rast.fill_front = PIPE_POLYGON_MODE_FILL; rast.offset_point = 0; rast.offset_line = 0; ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 rast.scissor = 0; rast.poly_smooth = 0; rast.poly_stipple_enable = 0; @@ -400,11 +380,8 @@ init_pipe_state(struct sp_mpeg12_context *ctx) ctx->rast = ctx->pipe->create_rasterizer_state(ctx->pipe, &rast); ctx->pipe->bind_rasterizer_state(ctx->pipe, ctx->rast); -<<<<<<< HEAD - -======= memset(&blend, 0, sizeof blend); ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 + blend.independent_blend_enable = 0; blend.rt[0].blend_enable = 0; blend.rt[0].rgb_func = PIPE_BLEND_ADD; diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index f8eeebf6a71..8bd509c88c2 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -494,10 +494,6 @@ enum pipe_shader_cap #define PIPE_REFERENCED_FOR_READ (1 << 0) #define PIPE_REFERENCED_FOR_WRITE (1 << 1) -<<<<<<< HEAD - -======= ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 enum pipe_video_codec { PIPE_VIDEO_CODEC_UNKNOWN = 0, @@ -523,10 +519,7 @@ enum pipe_video_profile PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH }; -<<<<<<< HEAD -======= ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 /** * Composite query types */ @@ -540,10 +533,7 @@ struct pipe_query_data_timestamp_disjoint uint64_t frequency; boolean disjoint; }; -<<<<<<< HEAD -======= ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 #ifdef __cplusplus } diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 9a59c9f9ea0..119d304d927 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -199,9 +199,9 @@ enum pipe_format { PIPE_FORMAT_AI44 = 142, /* some stencil samplers formats */ - PIPE_FORMAT_X24S8_USCALED = 136, - PIPE_FORMAT_S8X24_USCALED = 137, - PIPE_FORMAT_X32_S8X24_USCALED = 138, + PIPE_FORMAT_X24S8_USCALED = 143, + PIPE_FORMAT_S8X24_USCALED = 144, + PIPE_FORMAT_X32_S8X24_USCALED = 145, PIPE_FORMAT_COUNT }; diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 0303c5b2ea9..75eeaeba1f7 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -92,21 +92,13 @@ struct pipe_screen { */ int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param ); -<<<<<<< HEAD struct pipe_context * (*context_create)( struct pipe_screen *, void *priv ); -======= - struct pipe_context * (*context_create)( struct pipe_screen *, - void *priv ); ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 struct pipe_video_context * (*video_context_create)( struct pipe_screen *screen, enum pipe_video_profile profile, enum pipe_video_chroma_format chroma_format, unsigned width, unsigned height, void *priv ); -<<<<<<< HEAD -======= ->>>>>>> 97a7cf230a70c64fff300931ae7c00aa00449c97 /** * Check if the given pipe_format is supported as a texture or From 050dfe9caf364fdaac91db1313988275774a7eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 26 Oct 2010 13:58:19 +0200 Subject: [PATCH 27/36] vl: fix some build issues after the merge --- src/gallium/targets/Makefile.xvmc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gallium/targets/Makefile.xvmc b/src/gallium/targets/Makefile.xvmc index 08529b38b70..d5d33bde42e 100644 --- a/src/gallium/targets/Makefile.xvmc +++ b/src/gallium/targets/Makefile.xvmc @@ -2,6 +2,7 @@ LIBBASENAME = XvMCg3dvl LIBNAME = lib$(LIBBASENAME).so +LIB_GLOB=lib$(LIBBASENAME).*so* XVMC_MAJOR = 1 XVMC_MINOR = 0 INCLUDES = -I$(TOP)/src/gallium/include \ @@ -11,7 +12,7 @@ INCLUDES = -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/winsys/g3dvl \ $(DRIVER_INCLUDES) DEFINES = -DGALLIUM_TRACE $(DRIVER_DEFINES) -LIBS = $(EXTRA_LIB_PATH) $(DRIVER_LIBS) -lXvMC -lXv -lX11 -lm +LIBS = $(EXTRA_LIB_PATH) $(DRIVER_LIBS) -lXv -lX11 -lm STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/xorg/xvmc/libxvmctracker.a # XXX: Hack, XvMC public funcs aren't exported if we link to libxvmctracker.a :( @@ -55,8 +56,8 @@ clean: -rm -f *.o *~ *.so $(SYMLINKS) -rm -f depend depend.bak -#install: $(LIBNAME) -# $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) -# $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) +install: default + $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(TOP)/$(LIB_DIR)/gallium/$(LIB_GLOB) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) include depend From 17ea7d16bd3477361d32091f445beca625703f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Tue, 26 Oct 2010 14:06:01 +0200 Subject: [PATCH 28/36] vl: creating cleaner way of naming libraries --- src/gallium/targets/Makefile.xvmc | 5 ++--- src/gallium/targets/xvmc-nouveau/Makefile | 2 +- src/gallium/targets/xvmc-r600/Makefile | 2 +- src/gallium/targets/xvmc-softpipe/Makefile | 2 ++ 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gallium/targets/Makefile.xvmc b/src/gallium/targets/Makefile.xvmc index d5d33bde42e..6abe7f6b062 100644 --- a/src/gallium/targets/Makefile.xvmc +++ b/src/gallium/targets/Makefile.xvmc @@ -1,6 +1,5 @@ # This makefile template is used to build libXvMCg3dvl.so -LIBBASENAME = XvMCg3dvl LIBNAME = lib$(LIBBASENAME).so LIB_GLOB=lib$(LIBBASENAME).*so* XVMC_MAJOR = 1 @@ -57,7 +56,7 @@ clean: -rm -f depend depend.bak install: default - $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - $(MINSTALL) -m 755 $(TOP)/$(LIB_DIR)/gallium/$(LIB_GLOB) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(MINSTALL) -m 755 $(TOP)/$(LIB_DIR)/gallium/$(LIB_GLOB) $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) include depend diff --git a/src/gallium/targets/xvmc-nouveau/Makefile b/src/gallium/targets/xvmc-nouveau/Makefile index fe418b07681..4384eeaeadf 100644 --- a/src/gallium/targets/xvmc-nouveau/Makefile +++ b/src/gallium/targets/xvmc-nouveau/Makefile @@ -1,7 +1,7 @@ TOP = ../../../.. include $(TOP)/configs/current -#LIBNAME = +LIBBASENAME = XvMCnouveau PIPE_DRIVERS = \ $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \ diff --git a/src/gallium/targets/xvmc-r600/Makefile b/src/gallium/targets/xvmc-r600/Makefile index 25aeb65059f..62e47b53851 100644 --- a/src/gallium/targets/xvmc-r600/Makefile +++ b/src/gallium/targets/xvmc-r600/Makefile @@ -1,7 +1,7 @@ TOP = ../../../.. include $(TOP)/configs/current -#LIBNAME = +LIBBASENAME = XvMCr600 PIPE_DRIVERS = \ $(TOP)/src/gallium/drivers/r600/libr600.a \ diff --git a/src/gallium/targets/xvmc-softpipe/Makefile b/src/gallium/targets/xvmc-softpipe/Makefile index 1e3ff8ac89c..5b60bede589 100644 --- a/src/gallium/targets/xvmc-softpipe/Makefile +++ b/src/gallium/targets/xvmc-softpipe/Makefile @@ -1,6 +1,8 @@ TOP = ../../../.. include $(TOP)/configs/current +LIBBASENAME = XvMCsoftpipe + DRIVER_DEFINES = -DGALLIUM_SOFTPIPE DRIVER_INCLUDES = From 990cb6296351a41a2e728f181c0dc096eaddaeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 27 Oct 2010 11:00:11 +0200 Subject: [PATCH 29/36] vl: commited Orasanu Lucian's patch containing va stubs. --- configure.ac | 3 + src/gallium/state_trackers/va/Makefile | 6 +- src/gallium/state_trackers/va/ftab.c | 96 +++++++-------- src/gallium/state_trackers/va/va_context.c | 42 ++++++- src/gallium/state_trackers/va/va_image.c | 104 +++++++++++++--- src/gallium/state_trackers/va/va_private.h | 112 ++++++++++++++++-- src/gallium/state_trackers/va/va_subpicture.c | 103 ++++++++++++++-- .../state_trackers/xorg/xvmc/context.c | 2 +- 8 files changed, 372 insertions(+), 96 deletions(-) diff --git a/configure.ac b/configure.ac index 5edd935920d..eac293f56aa 100644 --- a/configure.ac +++ b/configure.ac @@ -1623,6 +1623,9 @@ if test "x$enable_gallium_g3dvl" = xyes; then if test "x$HAVE_ST_VDPAU" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS vdpau-softpipe" fi + if test "x$HAVE_ST_XVMC" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xvmc-softpipe" + fi if test "x$HAVE_ST_VA" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS va-softpipe" fi diff --git a/src/gallium/state_trackers/va/Makefile b/src/gallium/state_trackers/va/Makefile index 1d6e303a4f1..1e22bb50d1d 100644 --- a/src/gallium/state_trackers/va/Makefile +++ b/src/gallium/state_trackers/va/Makefile @@ -15,7 +15,11 @@ C_SOURCES = htab.c \ ftab.c \ va_context.c \ va_image.c \ - va_subpicture.c + va_subpicture.c \ + va_buffer.c \ + va_config.c \ + va_picture.c \ + va_surface.c diff --git a/src/gallium/state_trackers/va/ftab.c b/src/gallium/state_trackers/va/ftab.c index 651b7660964..010c04a7d28 100644 --- a/src/gallium/state_trackers/va/ftab.c +++ b/src/gallium/state_trackers/va/ftab.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2010 Thomas Balling Sørensen. + * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -32,28 +32,28 @@ static struct VADriverVTable vtable = { - 0x1, /* VAStatus (*vaTerminate) ( VADriverContextP ctx ); */ - 0x2, /* VAStatus (*vaQueryConfigProfiles) ( VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); */ - 0x3, /* VAStatus (*vaQueryConfigEntrypoints) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints ); */ - 0x4, /* VAStatus (*vaGetConfigAttributes) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs ); */ - 0x5, /* VAStatus (*vaCreateConfig) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); */ - 0x6, /* VAStatus (*vaDestroyConfig) ( VADriverContextP ctx, VAConfigID config_id); */ - 0x7, /* VAStatus (*vaQueryConfigAttributes) ( VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs); */ - 0x8, /* VAStatus (*vaCreateSurfaces) ( VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces); */ - 0x9, /* VAStatus (*vaDestroySurfaces) ( VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces ); */ - 0x10, /* VAStatus (*vaCreateContext) (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context); */ - 0x11, /* VAStatus (*vaDestroyContext) (VADriverContextP ctx,VAContextID context); */ - 0x12, /* VAStatus (*vaCreateBuffer) (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id); */ - 0x13, /* VAStatus (*vaBufferSetNumElements) (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); */ - 0x14, /* VAStatus (*vaMapBuffer) (VADriverContextP ctx,VABufferID buf_id,void **pbuf); */ - 0x15, /* VAStatus (*vaUnmapBuffer) (VADriverContextP ctx,VABufferID buf_id); */ - 0x16, /* VAStatus (*vaDestroyBuffer) (VADriverContextP ctx,VABufferID buffer_id); */ - 0x17, /* VAStatus (*vaBeginPicture) (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); */ - 0x18, /* VAStatus (*vaRenderPicture) (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); */ - 0x19, /* VAStatus (*vaEndPicture) (VADriverContextP ctx,VAContextID context); */ - 0x20, /* VAStatus (*vaSyncSurface) (VADriverContextP ctx,VASurfaceID render_target); */ - 0x21, /* VAStatus (*vaQuerySurfaceStatus) (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status); */ - 0x22, /* VAStatus (*vaPutSurface) ( + &vlVaTerminate, /* VAStatus (*vaTerminate) ( VADriverContextP ctx ); */ + &vlVaQueryConfigProfiles, /* VAStatus (*vaQueryConfigProfiles) ( VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); */ + &vlVaQueryConfigEntrypoints, /* VAStatus (*vaQueryConfigEntrypoints) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints ); */ + &vlVaGetConfigAttributes, /* VAStatus (*vaGetConfigAttributes) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs ); */ + &vlVaCreateConfig, /* VAStatus (*vaCreateConfig) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); */ + &vlVaDestroyConfig, /* VAStatus (*vaDestroyConfig) ( VADriverContextP ctx, VAConfigID config_id); */ + &vlVaQueryConfigAttributes, /* VAStatus (*vaQueryConfigAttributes) ( VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs); */ + &vlVaCreateSurfaces, /* VAStatus (*vaCreateSurfaces) ( VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces); */ + &vlVaDestroySurfaces, /* VAStatus (*vaDestroySurfaces) ( VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces ); */ + &vlVaCreateContext, /* VAStatus (*vaCreateContext) (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context); */ + &vlVaDestroyContext, /* VAStatus (*vaDestroyContext) (VADriverContextP ctx,VAContextID context); */ + &vlVaCreateBuffer, /* VAStatus (*vaCreateBuffer) (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id); */ + &vlVaBufferSetNumElements, /* VAStatus (*vaBufferSetNumElements) (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); */ + &vlVaMapBuffer, /* VAStatus (*vaMapBuffer) (VADriverContextP ctx,VABufferID buf_id,void **pbuf); */ + &vlVaUnmapBuffer, /* VAStatus (*vaUnmapBuffer) (VADriverContextP ctx,VABufferID buf_id); */ + &vlVaDestroyBuffers, /* VAStatus (*vaDestroyBuffer) (VADriverContextP ctx,VABufferID buffer_id); */ + &vlVaBeginPicture, /* VAStatus (*vaBeginPicture) (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); */ + &vlVaRenderPicture, /* VAStatus (*vaRenderPicture) (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); */ + &vlVaEndPicture, /* VAStatus (*vaEndPicture) (VADriverContextP ctx,VAContextID context); */ + &vlVaSyncSurface, /* VAStatus (*vaSyncSurface) (VADriverContextP ctx,VASurfaceID render_target); */ + &vlVaQuerySurfaceStatus, /* VAStatus (*vaQuerySurfaceStatus) (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status); */ + &vlVaPutSurface, /* VAStatus (*vaPutSurface) ( VADriverContextP ctx, VASurfaceID surface, void* draw, @@ -65,16 +65,16 @@ static struct VADriverVTable vtable = short desty, unsigned short destw, unsigned short desth, - VARectangle *cliprects, - unsigned int number_cliprects, + VARectangle *cliprects, + unsigned int number_cliprects, unsigned int flags); */ - &vlVaQueryImageFormats, /* VAStatus (*vaQueryImageFormats) ( VADriverContextP ctx, VAImageFormat *format_list,int *num_formats); */ - &vlVaCreateImage, /* VAStatus (*vaCreateImage) (VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); */ - 0x25, /* VAStatus (*vaDeriveImage) (VADriverContextP ctx,VASurfaceID surface,VAImage *image); */ - 0x26, /* VAStatus (*vaDestroyImage) (VADriverContextP ctx,VAImageID image); */ - 0x27, /* VAStatus (*vaSetImagePalette) (VADriverContextP ctx,VAImageID image, unsigned char *palette); */ - 0x28, /* VAStatus (*vaGetImage) (VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image); */ - 0x29, /* VAStatus (*vaPutImage) ( + &vlVaQueryImageFormats, /* VAStatus (*vaQueryImageFormats) ( VADriverContextP ctx, VAImageFormat *format_list,int *num_formats); */ + &vlVaCreateImage, /* VAStatus (*vaCreateImage) (VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); */ + &vlVaDeriveImage, /* VAStatus (*vaDeriveImage) (VADriverContextP ctx,VASurfaceID surface,VAImage *image); */ + &vlVaDestroyImage, /* VAStatus (*vaDestroyImage) (VADriverContextP ctx,VAImageID image); */ + &vlVaSetImagePalette, /* VAStatus (*vaSetImagePalette) (VADriverContextP ctx,VAImageID image, unsigned char *palette); */ + &vlVaGetImage, /* VAStatus (*vaGetImage) (VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image); */ + &vlVaPutImage, /* VAStatus (*vaPutImage) ( VADriverContextP ctx, VASurfaceID surface, VAImageID image, @@ -87,13 +87,13 @@ static struct VADriverVTable vtable = unsigned int dest_width, unsigned int dest_height ); */ - &vlVaQuerySubpictureFormats, /* VAStatus (*vaQuerySubpictureFormats) (VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); */ - 0x31, /* VAStatus (*vaCreateSubpicture) (VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture); */ - 0x32, /* VAStatus (*vaDestroySubpicture) (VADriverContextP ctx,VASubpictureID subpicture); */ - 0x33, /* VAStatus (*vaSetSubpictureImage) (VADriverContextP ctx,VASubpictureID subpicture,VAImageID image); */ - 0x34, /* VAStatus (*vaSetSubpictureChromakey) (VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask); */ - 0x35, /* VAStatus (*vaSetSubpictureGlobalAlpha) (VADriverContextP ctx,VASubpictureID subpicture,float global_alpha); */ - 0x36, /* VAStatus (*vaAssociateSubpicture) ( + &vlVaQuerySubpictureFormats, /* VAStatus (*vaQuerySubpictureFormats) (VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); */ + &vlVaCreateSubpicture, /* VAStatus (*vaCreateSubpicture) (VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture); */ + &vlVaDestroySubpicture, /* VAStatus (*vaDestroySubpicture) (VADriverContextP ctx,VASubpictureID subpicture); */ + &vlVaSubpictureImage, /* VAStatus (*vaSetSubpictureImage) (VADriverContextP ctx,VASubpictureID subpicture,VAImageID image); */ + &vlVaSetSubpictureChromakey, /* VAStatus (*vaSetSubpictureChromakey) (VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask); */ + &vlVaSetSubpictureGlobalAlpha, /* VAStatus (*vaSetSubpictureGlobalAlpha) (VADriverContextP ctx,VASubpictureID subpicture,float global_alpha); */ + &vlVaAssociateSubpicture, /* VAStatus (*vaAssociateSubpicture) ( VADriverContextP ctx, VASubpictureID subpicture, VASurfaceID *target_surfaces, @@ -107,12 +107,12 @@ static struct VADriverVTable vtable = unsigned short dest_width, unsigned short dest_height, unsigned int flags); */ - 0x37, /* VAStatus (*vaDeassociateSubpicture) (VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces); */ - 0x38, /* VAStatus (*vaQueryDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes); */ - 0x39, /* VAStatus (*vaGetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ - 0x40, /* VAStatus (*vaSetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ - 0x41, /* VAStatus (*vaBufferInfo) (VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements); */ - 0x42, /* VAStatus (*vaLockSurface) ( + &vlVaDeassociateSubpicture, /* VAStatus (*vaDeassociateSubpicture) (VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces); */ + &vlVaQueryDisplayAttributes, /* VAStatus (*vaQueryDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes); */ + &vlVaGetDisplayAttributes, /* VAStatus (*vaGetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ + &vlVaSetDisplayAttributes, /* VAStatus (*vaSetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */ + &vlVaBufferInfo, /* VAStatus (*vaBufferInfo) (VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements); */ + &vlVaLockSurface, /* VAStatus (*vaLockSurface) ( VADriverContextP ctx, VASurfaceID surface, unsigned int *fourcc, @@ -124,11 +124,11 @@ static struct VADriverVTable vtable = unsigned int *chroma_v_offset, unsigned int *buffer_name, void **buffer); */ - 0x43, /* VAStatus (*vaUnlockSurface) (VADriverContextP ctx,VASurfaceID surface); */ - 0x44 /* struct VADriverVTableGLX *glx; "Optional" */ + &vlVaUnlockSurface, /* VAStatus (*vaUnlockSurface) (VADriverContextP ctx,VASurfaceID surface); */ + 0x44 /* struct VADriverVTableGLX *glx; "Optional" */ }; struct VADriverVTable vlVaGetVtable() { return vtable; -} \ No newline at end of file +} diff --git a/src/gallium/state_trackers/va/va_context.c b/src/gallium/state_trackers/va/va_context.c index 0b8d7865f73..7ef84606305 100644 --- a/src/gallium/state_trackers/va/va_context.c +++ b/src/gallium/state_trackers/va/va_context.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2010 Thomas Balling Sørensen. + * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - + #include #include #include @@ -39,7 +39,7 @@ VAStatus __vaDriverInit_0_31 (VADriverContextP ctx) { if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - + ctx->str_vendor = "mesa gallium vaapi"; ctx->vtable = vlVaGetVtable(); ctx->max_attributes = 1; @@ -50,8 +50,40 @@ VAStatus __vaDriverInit_0_31 (VADriverContextP ctx) ctx->max_subpic_formats = 1; ctx->version_major = 3; ctx->version_minor = 1; - + VA_INFO("vl_screen_pointer %p\n",ctx->native_dpy); return VA_STATUS_SUCCESS; -} \ No newline at end of file +} + +VAStatus vlVaCreateContext( VADriverContextP ctx, + VAConfigID config_id, + int picture_width, + int picture_height, + int flag, + VASurfaceID *render_targets, + int num_render_targets, + VAContextID *conext) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaDestroyContext( VADriverContextP ctx, + VAContextID context) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaTerminate( VADriverContextP ctx) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} diff --git a/src/gallium/state_trackers/va/va_image.c b/src/gallium/state_trackers/va/va_image.c index b7e1320a4e8..b1f990a15eb 100644 --- a/src/gallium/state_trackers/va/va_image.c +++ b/src/gallium/state_trackers/va/va_image.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2010 Thomas Balling Sørensen. + * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,33 +24,99 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - - #include - #include - #include - #include - #include "va_private.h" - - VAStatus - vlVaQueryImageFormats ( VADriverContextP ctx, - VAImageFormat *format_list, - int *num_formats) + +#include +#include +#include +#include +#include "va_private.h" + +VAStatus +vlVaQueryImageFormats ( VADriverContextP ctx, + VAImageFormat *format_list, + int *num_formats) { if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - + return VA_STATUS_ERROR_UNIMPLEMENTED; } VAStatus vlVaCreateImage( VADriverContextP ctx, - VAImageFormat *format, - int width, - int height, - VAImage *image) + VAImageFormat *format, + int width, + int height, + VAImage *image) { if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - + return VA_STATUS_ERROR_UNIMPLEMENTED; -} \ No newline at end of file +} + +VAStatus vlVaDeriveImage( VADriverContextP ctx, + VASurfaceID surface, + VAImage *image) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlDestroyImage( VADriverContextP ctx, + VAImageID image) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlSetImagePalette( VADriverContextP ctx, + VAImageID image, + unsigned char *palette) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaGetImage( VADriverContextP ctx, + VASurfaceID surface, + int x, + int y, + unsigned int width, + unsigned int height, + VAImageID image) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaPutImage( VADriverContextP ctx, + VASurfaceID surface, + VAImageID image, + int src_x, + int src_y, + unsigned int src_width, + unsigned int src_height, + int dest_x, + int dest_y, + unsigned int dest_width, + unsigned int dest_height) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index ccaa5c053ea..3c9922e64fc 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2010 Thomas Balling Sørensen. + * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,24 +24,110 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - - #ifndef VA_PRIVATE_H - #define VA_PRIVATE_H - - #include - #include - #define VA_DEBUG(_str,...) debug_printf("[Gallium VA backend]: " _str,__VA_ARGS__) - #define VA_INFO(_str,...) VA_DEBUG("INFO: " _str,__VA_ARGS__) - #define VA_WARNING(_str,...) VA_DEBUG("WARNING: " _str,__VA_ARGS__) - #define VA_ERROR(_str,...) VA_DEBUG("ERROR: " _str,__VA_ARGS__) + +#ifndef VA_PRIVATE_H +#define VA_PRIVATE_H + +#include +#include +#define VA_DEBUG(_str,...) debug_printf("[Gallium VA backend]: " _str,__VA_ARGS__) +#define VA_INFO(_str,...) VA_DEBUG("INFO: " _str,__VA_ARGS__) +#define VA_WARNING(_str,...) VA_DEBUG("WARNING: " _str,__VA_ARGS__) +#define VA_ERROR(_str,...) VA_DEBUG("ERROR: " _str,__VA_ARGS__) // Public functions: VAStatus __vaDriverInit_0_31 (VADriverContextP ctx); // Private functions: struct VADriverVTable vlVaGetVtable(); +VAStatus vlVaTerminate (VADriverContextP ctx); +VAStatus vlVaQueryConfigProfiles (VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); +VAStatus vlVaQueryConfigEntrypoints (VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints); +VAStatus vlVaGetConfigAttributes (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs); +VAStatus vlVaCreateConfig (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); +VAStatus vlVaDestroyConfig (VADriverContextP ctx, VAConfigID config_id); +VAStatus vlVaQueryConfigAttributes (VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs); +VAStatus vlVaCreateSurfaces (VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces); +VAStatus vlVaDestroySurfaces (VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces); +VAStatus vlVaCreateContext (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context); +VAStatus vlVaDestroyContext (VADriverContextP ctx,VAContextID context); +VAStatus vlVaCreateBuffer (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id); +VAStatus vlVaBufferSetNumElements (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); +VAStatus vlVaMapBuffer (VADriverContextP ctx,VABufferID buf_id,void **pbuf); +VAStatus vlVaUnmapBuffer (VADriverContextP ctx,VABufferID buf_id); +VAStatus vlVaDestroyBuffers (VADriverContextP ctx,VABufferID buffer_id); +VAStatus vlVaBeginPicture (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); +VAStatus vlVaRenderPicture (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); +VAStatus vlVaEndPicture (VADriverContextP ctx,VAContextID context); +VAStatus vlVaSyncSurface (VADriverContextP ctx,VASurfaceID render_target); +VAStatus vlVaQuerySurfaceStatus (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status); +VAStatus vlVaPutSurface (VADriverContextP ctx, + VASurfaceID surface, + void* draw, + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth, + VARectangle *cliprects, + unsigned int number_cliprects, + unsigned int flags); VAStatus vlVaQueryImageFormats (VADriverContextP ctx,VAImageFormat *format_list,int *num_formats); VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); VAStatus vlVaCreateImage(VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); - - #endif // VA_PRIVATE_H +VAStatus vlVaDeriveImage(VADriverContextP ctx,VASurfaceID surface,VAImage *image); +VAStatus vlVaDestroyImage(VADriverContextP ctx,VAImageID image); +VAStatus vlVaSetImagePalette(VADriverContextP ctx,VAImageID image, unsigned char *palette); +VAStatus vlVaGetImage(VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image); +VAStatus vlVaPutImage(VADriverContextP ctx, + VASurfaceID surface, + VAImageID image, + int src_x, + int src_y, + unsigned int src_width, + unsigned int src_height, + int dest_x, + int dest_y, + unsigned int dest_width, + unsigned int dest_height); +VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); +VAStatus vlVaCreateSubpicture(VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture); +VAStatus vlVaDestroySubpicture(VADriverContextP ctx,VASubpictureID subpicture); +VAStatus vlVaSubpictureImage(VADriverContextP ctx,VASubpictureID subpicture,VAImageID image); +VAStatus vlVaSetSubpictureChromakey(VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask); +VAStatus vlVaSetSubpictureGlobalAlpha(VADriverContextP ctx,VASubpictureID subpicture,float global_alpha); +VAStatus vlVaAssociateSubpicture(VADriverContextP ctx, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces, + short src_x, + short src_y, + unsigned short src_width, + unsigned short src_height, + short dest_x, + short dest_y, + unsigned short dest_width, + unsigned short dest_height, + unsigned int flags); +VAStatus vlVaDeassociateSubpicture(VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces); +VAStatus vlVaQueryDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes); +VAStatus vlVaGetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); +VAStatus vlVaSetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); +VAStatus vlVaBufferInfo(VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements); +VAStatus vlVaLockSurface(VADriverContextP ctx, + VASurfaceID surface, + unsigned int *fourcc, + unsigned int *luma_stride, + unsigned int *chroma_u_stride, + unsigned int *chroma_v_stride, + unsigned int *luma_offset, + unsigned int *chroma_u_offset, + unsigned int *chroma_v_offset, + unsigned int *buffer_name, + void **buffer); +VAStatus vlVaUnlockSurface(VADriverContextP ctx,VASurfaceID surface); + +#endif //VA_PRIVATE_H diff --git a/src/gallium/state_trackers/va/va_subpicture.c b/src/gallium/state_trackers/va/va_subpicture.c index 211970913fa..9317d313c65 100644 --- a/src/gallium/state_trackers/va/va_subpicture.c +++ b/src/gallium/state_trackers/va/va_subpicture.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2010 Thomas Balling Sørensen. + * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,17 +24,102 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - + #include #include #include "va_private.h" - -VAStatus -vlVaQuerySubpictureFormats( VADriverContextP ctx, - VAImageFormat *format_list, - unsigned int *flags, - unsigned int *num_formats) + +VAStatus +vlVaQuerySubpictureFormats( VADriverContextP ctx, + VAImageFormat *format_list, + unsigned int *flags, + unsigned int *num_formats) { + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; return VA_STATUS_ERROR_UNIMPLEMENTED; -} \ No newline at end of file +} + + +VAStatus vlVaCreateSubpicture( VADriverContextP ctx, + VAImageID image, + VASubpictureID *subpicture) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaDestroySubpicture( VADriverContextP ctx, + VASubpictureID subpicture) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaSubpictureImage( VADriverContextP ctx, + VASubpictureID subpicture, + VAImageID image) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaSetSubpictureChromakey( VADriverContextP ctx, + VASubpictureID subpicture, + unsigned int chromakey_min, + unsigned int chromakey_max, + unsigned int chromakey_mask) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaSetSubpictureGlobalAlpha( VADriverContextP ctx, + VASubpictureID subpicture, + float global_alpha) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaAssociateSubpicture( VADriverContextP ctx, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces, + short src_x, + short src_y, + unsigned short src_width, + unsigned short src_height, + short dest_x, + short dest_y, + unsigned short dest_width, + unsigned short dest_height, + unsigned int flags) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaDeassociateSubpicture( VADriverContextP ctx, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} diff --git a/src/gallium/state_trackers/xorg/xvmc/context.c b/src/gallium/state_trackers/xorg/xvmc/context.c index 5e4af9e555a..688d68b6ea7 100644 --- a/src/gallium/state_trackers/xorg/xvmc/context.c +++ b/src/gallium/state_trackers/xorg/xvmc/context.c @@ -210,7 +210,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, return BadImplementation; } if (mc_type != (XVMC_MOCOMP | XVMC_MPEG_2)) { - XVMC_MSG(XVMC_ERR, "[XvMC] Cannot decode requested surface type. Non-MPEG2/Mocomp acceleration unsupported.\n"); + XVMC_MSG(XVMC_ERR, "[XvMC] Cannot decode requested surface type. Non-MPEG2 acceleration unsupported.\n"); return BadImplementation; } if (!(surface_flags & XVMC_INTRA_UNSIGNED)) { From 664f10625a74a7e0ed1bfd44b2fb6f44bd8828a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 27 Oct 2010 13:01:18 +0200 Subject: [PATCH 30/36] vl: rest of Luc's patch --- src/gallium/state_trackers/va/va_buffer.c | 96 +++++++++++++++++ src/gallium/state_trackers/va/va_config.c | 100 +++++++++++++++++ src/gallium/state_trackers/va/va_display.c | 66 ++++++++++++ src/gallium/state_trackers/va/va_picture.c | 60 +++++++++++ src/gallium/state_trackers/va/va_surface.c | 120 +++++++++++++++++++++ 5 files changed, 442 insertions(+) create mode 100644 src/gallium/state_trackers/va/va_buffer.c create mode 100644 src/gallium/state_trackers/va/va_config.c create mode 100644 src/gallium/state_trackers/va/va_display.c create mode 100644 src/gallium/state_trackers/va/va_picture.c create mode 100644 src/gallium/state_trackers/va/va_surface.c diff --git a/src/gallium/state_trackers/va/va_buffer.c b/src/gallium/state_trackers/va/va_buffer.c new file mode 100644 index 00000000000..19afd7b2a30 --- /dev/null +++ b/src/gallium/state_trackers/va/va_buffer.c @@ -0,0 +1,96 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include +#include +#include "va_private.h" + + +VAStatus vlVaCreateBuffer( VADriverContextP ctx, + VAContextID context, + VABufferType type, + unsigned int size, + unsigned int num_elements, + void *data, + VABufferID *buf_id) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaBufferSetNumElements( VADriverContextP ctx, + VABufferID buf_id, + unsigned int num_elements) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaMapBuffer( VADriverContextP ctx, + VABufferID buf_id, + void **pbuff) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaUnmapBuffer( VADriverContextP ctx, + VABufferID buf_id) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaDestroyBuffers( VADriverContextP ctx, + VABufferID buffer_id) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaBufferInfo( VADriverContextP ctx, + VAContextID context, + VABufferID buf_id, + VABufferType *type, + unsigned int *size, + unsigned int *num_elements) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} diff --git a/src/gallium/state_trackers/va/va_config.c b/src/gallium/state_trackers/va/va_config.c new file mode 100644 index 00000000000..1bec28c29a2 --- /dev/null +++ b/src/gallium/state_trackers/va/va_config.c @@ -0,0 +1,100 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include +#include +#include "va_private.h" + +VAStatus vlVaConfigProfiles( VADriverContextP ctx, + VAProfile *profile_list, + int *num_profiles) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + + +VAStatus vlVaConfigEntrypoints( VADriverContextP ctx, + VAProfile profile, + VAEntypoint *entypoint_list, + int *num_entrypoints) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + + +VAStatus vlVaGetConfigAttributes( VADriverContextP ctx, + VAProfile profile, + VAEntrypoint entrypoint, + VAConfigAttrib *attrib_list, + int num_attribs) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaCreateConfig( VADriverContextP ctx, + VAProfile profile, + VAEntrypoint entrypoint, + VAConfigAttrib *attrib_list, + int num_attribs, + VAConfigID *config_id) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaDestroyConfig( VADriverContextP ctx, + VAConfigID config_id) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaQueryConfigAttributes( VADriverContextP ctx, + VAConfigID config_id, + VAProfile *profile, + VAEntrypoint *entrypoint, + VAConfigAttrib *attrib_list, + int *num_attribs) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} diff --git a/src/gallium/state_trackers/va/va_display.c b/src/gallium/state_trackers/va/va_display.c new file mode 100644 index 00000000000..d50d712d4e0 --- /dev/null +++ b/src/gallium/state_trackers/va/va_display.c @@ -0,0 +1,66 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + #include + #include + #include "va_private.h" + + +VAStatus vlVaQueryDisplayAttributes( VADriverContextP ctx, + VADisplayAttribute *attr_list, + int *num_attributes) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaGetDisplayAttributes( VADriverContextP ctx, + VADisplayAttribute *attr_list, + int num_attributes) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaSetDisplayAttributes( VADriverContextP ctx, + VADisplayAttribute *attr_list, + int num_attributes) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + + diff --git a/src/gallium/state_trackers/va/va_picture.c b/src/gallium/state_trackers/va/va_picture.c new file mode 100644 index 00000000000..cf7d844a780 --- /dev/null +++ b/src/gallium/state_trackers/va/va_picture.c @@ -0,0 +1,60 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include +#include +#include "va_private.h" + +VAStatus vlVaBeginPicture( VADriverContextP ctx, + VAContextID context, + VASurfaceID render_target) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaRenderPicture( VADriverContextP ctx, + VAContextID context, + VABufferID *buffers, + int num_buffers) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaEndPicture( VADriverContextP ctx, + VAContextID context) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} diff --git a/src/gallium/state_trackers/va/va_surface.c b/src/gallium/state_trackers/va/va_surface.c new file mode 100644 index 00000000000..7d234bd51b4 --- /dev/null +++ b/src/gallium/state_trackers/va/va_surface.c @@ -0,0 +1,120 @@ +/************************************************************************** + * + * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include +#include +#include "va_private.h" + +VAStatus vlVaCreateSurfaces( VADriverContextP ctx, + int width, + int height, + int format, + int num_surfaces + VASurfaceID *surfaces) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaDestroySurfaces( VADriverContextP ctx, + VASurfaceID *surface_list, + int num_surfaces) + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaSyncSurface( VADriverContextP ctx, + VASurfaceID render_target) + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaQuerySurfaceStatus( VADriverContextP ctx, + VASurfaceID render_target, + VASurfaceStatus *status) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaPutSurface( VADriverContextP ctx, + VADriverContextP ctx, + VASurfaceID surface, + void* draw, + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth, + VARectangle *cliprects, + unsigned int number_cliprects, + unsigned int flags) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaLockSurface( VADriverContextP ctx, + VASurfaceID surface, + unsigned int *fourcc, + unsigned int *luma_stride, + unsigned int *chroma_u_stride, + unsigned int *chroma_v_stride, + unsigned int *luma_offset, + unsigned int *chroma_u_offset, + unsigned int *chroma_v_offset, + unsigned int *buffer_name, + void **buffer) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + +VAStatus vlVaUnlockSurface( VADriverContextP ctx, + VASurfaceID surface) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + return VA_STATUS_ERROR_UNIMPLEMENTED; +} + From 6b6310e67ce1d2c5729d91c704302282998ed35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Wed, 27 Oct 2010 20:27:11 +0200 Subject: [PATCH 31/36] vl: morefixes to Luc's patch --- src/gallium/state_trackers/va/ftab.c | 2 +- src/gallium/state_trackers/va/va_buffer.c | 2 +- src/gallium/state_trackers/va/va_surface.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/va/ftab.c b/src/gallium/state_trackers/va/ftab.c index 010c04a7d28..a567eee9dd1 100644 --- a/src/gallium/state_trackers/va/ftab.c +++ b/src/gallium/state_trackers/va/ftab.c @@ -47,7 +47,7 @@ static struct VADriverVTable vtable = &vlVaBufferSetNumElements, /* VAStatus (*vaBufferSetNumElements) (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); */ &vlVaMapBuffer, /* VAStatus (*vaMapBuffer) (VADriverContextP ctx,VABufferID buf_id,void **pbuf); */ &vlVaUnmapBuffer, /* VAStatus (*vaUnmapBuffer) (VADriverContextP ctx,VABufferID buf_id); */ - &vlVaDestroyBuffers, /* VAStatus (*vaDestroyBuffer) (VADriverContextP ctx,VABufferID buffer_id); */ + &vlVaDestroyBuffer, /* VAStatus (*vaDestroyBuffer) (VADriverContextP ctx,VABufferID buffer_id); */ &vlVaBeginPicture, /* VAStatus (*vaBeginPicture) (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); */ &vlVaRenderPicture, /* VAStatus (*vaRenderPicture) (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); */ &vlVaEndPicture, /* VAStatus (*vaEndPicture) (VADriverContextP ctx,VAContextID context); */ diff --git a/src/gallium/state_trackers/va/va_buffer.c b/src/gallium/state_trackers/va/va_buffer.c index 19afd7b2a30..7608a4264ff 100644 --- a/src/gallium/state_trackers/va/va_buffer.c +++ b/src/gallium/state_trackers/va/va_buffer.c @@ -73,7 +73,7 @@ VAStatus vlVaUnmapBuffer( VADriverContextP ctx, return VA_STATUS_ERROR_UNIMPLEMENTED; } -VAStatus vlVaDestroyBuffers( VADriverContextP ctx, +VAStatus vlVaDestroyBuffer( VADriverContextP ctx, VABufferID buffer_id) { if (!ctx) diff --git a/src/gallium/state_trackers/va/va_surface.c b/src/gallium/state_trackers/va/va_surface.c index 7d234bd51b4..314aa7c3d96 100644 --- a/src/gallium/state_trackers/va/va_surface.c +++ b/src/gallium/state_trackers/va/va_surface.c @@ -33,7 +33,7 @@ VAStatus vlVaCreateSurfaces( VADriverContextP ctx, int width, int height, int format, - int num_surfaces + int num_surfaces, VASurfaceID *surfaces) { if (!ctx) @@ -53,6 +53,7 @@ VAStatus vlVaDestroySurfaces( VADriverContextP ctx, VAStatus vlVaSyncSurface( VADriverContextP ctx, VASurfaceID render_target) +{ if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -70,7 +71,6 @@ VAStatus vlVaQuerySurfaceStatus( VADriverContextP ctx, } VAStatus vlVaPutSurface( VADriverContextP ctx, - VADriverContextP ctx, VASurfaceID surface, void* draw, short srcx, From fd2cbe94dfaa98b79c16fb81d7bac84c5c683249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Thu, 28 Oct 2010 09:40:25 +0200 Subject: [PATCH 32/36] vl: small typos and stuff --- src/gallium/state_trackers/va/va_config.c | 2 +- src/gallium/state_trackers/va/va_private.h | 4 +- src/gallium/state_trackers/va/va_surface.c | 112 ++++++++++----------- 3 files changed, 60 insertions(+), 58 deletions(-) diff --git a/src/gallium/state_trackers/va/va_config.c b/src/gallium/state_trackers/va/va_config.c index 1bec28c29a2..5756c2f155d 100644 --- a/src/gallium/state_trackers/va/va_config.c +++ b/src/gallium/state_trackers/va/va_config.c @@ -42,7 +42,7 @@ VAStatus vlVaConfigProfiles( VADriverContextP ctx, VAStatus vlVaConfigEntrypoints( VADriverContextP ctx, VAProfile profile, - VAEntypoint *entypoint_list, + VAEntrypoint *entypoint_list, int *num_entrypoints) { if (!ctx) diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 3c9922e64fc..bd037c89606 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -40,6 +40,8 @@ VAStatus __vaDriverInit_0_31 (VADriverContextP ctx); // Private functions: struct VADriverVTable vlVaGetVtable(); + +// Vtable functions: VAStatus vlVaTerminate (VADriverContextP ctx); VAStatus vlVaQueryConfigProfiles (VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); VAStatus vlVaQueryConfigEntrypoints (VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints); @@ -55,7 +57,7 @@ VAStatus vlVaCreateBuffer (VADriverContextP ctx,VAContextID context,VABufferType VAStatus vlVaBufferSetNumElements (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); VAStatus vlVaMapBuffer (VADriverContextP ctx,VABufferID buf_id,void **pbuf); VAStatus vlVaUnmapBuffer (VADriverContextP ctx,VABufferID buf_id); -VAStatus vlVaDestroyBuffers (VADriverContextP ctx,VABufferID buffer_id); +VAStatus vlVaDestroyBuffer (VADriverContextP ctx,VABufferID buffer_id); VAStatus vlVaBeginPicture (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); VAStatus vlVaRenderPicture (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); VAStatus vlVaEndPicture (VADriverContextP ctx,VAContextID context); diff --git a/src/gallium/state_trackers/va/va_surface.c b/src/gallium/state_trackers/va/va_surface.c index 314aa7c3d96..ad241adaf41 100644 --- a/src/gallium/state_trackers/va/va_surface.c +++ b/src/gallium/state_trackers/va/va_surface.c @@ -30,91 +30,91 @@ #include "va_private.h" VAStatus vlVaCreateSurfaces( VADriverContextP ctx, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces) + int width, + int height, + int format, + int num_surfaces, + VASurfaceID *surfaces) { - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNIMPLEMENTED; } VAStatus vlVaDestroySurfaces( VADriverContextP ctx, - VASurfaceID *surface_list, - int num_surfaces) - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; + VASurfaceID *surface_list, + int num_surfaces) +{ + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNIMPLEMENTED; } VAStatus vlVaSyncSurface( VADriverContextP ctx, - VASurfaceID render_target) + VASurfaceID render_target) { - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNIMPLEMENTED; } VAStatus vlVaQuerySurfaceStatus( VADriverContextP ctx, - VASurfaceID render_target, - VASurfaceStatus *status) + VASurfaceID render_target, + VASurfaceStatus *status) { - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNIMPLEMENTED; } VAStatus vlVaPutSurface( VADriverContextP ctx, - VASurfaceID surface, - void* draw, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth, - VARectangle *cliprects, - unsigned int number_cliprects, - unsigned int flags) + VASurfaceID surface, + void* draw, + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth, + VARectangle *cliprects, + unsigned int number_cliprects, + unsigned int flags) { - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNIMPLEMENTED; } VAStatus vlVaLockSurface( VADriverContextP ctx, - VASurfaceID surface, - unsigned int *fourcc, - unsigned int *luma_stride, - unsigned int *chroma_u_stride, - unsigned int *chroma_v_stride, - unsigned int *luma_offset, - unsigned int *chroma_u_offset, - unsigned int *chroma_v_offset, - unsigned int *buffer_name, - void **buffer) + VASurfaceID surface, + unsigned int *fourcc, + unsigned int *luma_stride, + unsigned int *chroma_u_stride, + unsigned int *chroma_v_stride, + unsigned int *luma_offset, + unsigned int *chroma_u_offset, + unsigned int *chroma_v_offset, + unsigned int *buffer_name, + void **buffer) { - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNIMPLEMENTED; } VAStatus vlVaUnlockSurface( VADriverContextP ctx, - VASurfaceID surface) + VASurfaceID surface) { - if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNIMPLEMENTED; } - From 3fac09ad873b8a5239f84d07dc12e8b08a117561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Thu, 28 Oct 2010 12:51:35 +0200 Subject: [PATCH 33/36] vl: Initial implementation of vlVaQuerySubpictureFormats. --- src/gallium/state_trackers/va/va_subpicture.c | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/va_subpicture.c b/src/gallium/state_trackers/va/va_subpicture.c index 9317d313c65..442b1acea5a 100644 --- a/src/gallium/state_trackers/va/va_subpicture.c +++ b/src/gallium/state_trackers/va/va_subpicture.c @@ -27,8 +27,29 @@ #include #include +#include #include "va_private.h" +#define NUM_FORMAT_SUPPORTED 2 + +typedef struct { + enum pipe_format; + VAImageFormat va_format; + unsigned int va_flags; +} va_subpicture_formats_supported_t; + +static const va_subpicture_formats_supported_t va_subpicture_formats_supported[NUM_FORMAT_SUPPORTED] = +{ + { PIPE_FORMAT_B8G8R8A8_UNORM, + { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, + 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }, + 0 }, + { PIPE_FORMAT_R8G8B8A8_UNORM, + { VA_FOURCC('R','G','B','A'), VA_LSB_FIRST, 32, + 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }, + 0 } +}; + VAStatus vlVaQuerySubpictureFormats( VADriverContextP ctx, VAImageFormat *format_list, @@ -37,8 +58,19 @@ vlVaQuerySubpictureFormats( VADriverContextP ctx, { if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + + if (!(format_list && flags && num_formats)) + return VA_STATUS_ERROR_UNKNOWN; + + int n = 0; + /* Query supported formats */ + for (n = 0; n < NUM_FORMAT_SUPPORTED; n++) + { + flags[n] = va_subpicture_formats_supported[n].va_flags; + format_list[n] = va_subpicture_formats_supported[n].va_format; + } - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_SUCCESS; } From a565f58edaad646942f2174e66ef1343f56ae679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Thu, 28 Oct 2010 13:40:59 +0200 Subject: [PATCH 34/36] vl: enable target va-r600 --- configure.ac | 2 +- src/gallium/state_trackers/va/va_subpicture.c | 6 +- src/gallium/targets/Makefile.va | 62 +++++++++++++++++++ src/gallium/targets/va-softpipe/Makefile | 21 +++++++ 4 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 src/gallium/targets/Makefile.va create mode 100644 src/gallium/targets/va-softpipe/Makefile diff --git a/configure.ac b/configure.ac index eac293f56aa..8544c5f0a91 100644 --- a/configure.ac +++ b/configure.ac @@ -1590,7 +1590,7 @@ AC_ARG_ENABLE([gallium-r600], if test "x$enable_gallium_r600" = xyes; then if test "x$HAVE_LIBDRM_RADEON" = xyes; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600" - gallium_check_st "r600/drm" "dri-r600" "xvmc-r600" + gallium_check_st "r600/drm" "dri-r600" "xvmc-r600" "va-r600" else AC_MSG_ERROR([libdrm_radeon is missing, cannot build gallium-r600]) fi diff --git a/src/gallium/state_trackers/va/va_subpicture.c b/src/gallium/state_trackers/va/va_subpicture.c index 442b1acea5a..a6d2960e7e5 100644 --- a/src/gallium/state_trackers/va/va_subpicture.c +++ b/src/gallium/state_trackers/va/va_subpicture.c @@ -30,7 +30,7 @@ #include #include "va_private.h" -#define NUM_FORMAT_SUPPORTED 2 +#define NUM_FORMATS_SUPPORTED 2 typedef struct { enum pipe_format; @@ -38,7 +38,7 @@ typedef struct { unsigned int va_flags; } va_subpicture_formats_supported_t; -static const va_subpicture_formats_supported_t va_subpicture_formats_supported[NUM_FORMAT_SUPPORTED] = +static const va_subpicture_formats_supported_t va_subpicture_formats_supported[NUM_FORMATS_SUPPORTED] = { { PIPE_FORMAT_B8G8R8A8_UNORM, { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, @@ -64,7 +64,7 @@ vlVaQuerySubpictureFormats( VADriverContextP ctx, int n = 0; /* Query supported formats */ - for (n = 0; n < NUM_FORMAT_SUPPORTED; n++) + for (n = 0; n < NUM_FORMATS_SUPPORTED; n++) { flags[n] = va_subpicture_formats_supported[n].va_flags; format_list[n] = va_subpicture_formats_supported[n].va_format; diff --git a/src/gallium/targets/Makefile.va b/src/gallium/targets/Makefile.va new file mode 100644 index 00000000000..efb0a59522a --- /dev/null +++ b/src/gallium/targets/Makefile.va @@ -0,0 +1,62 @@ +# This makefile template is used to build "driver"_drv_video.so + +LIBNAME = lib$(LIBBASENAME).so +VA_LIB_GLOB= lib$(LIBBASENAME).*so* +VA_MAJOR = 0 +VA_MINOR = 3 +INCLUDES = -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/gallium/winsys \ + -I$(TOP)/src/gallium/winsys/g3dvl \ + $(DRIVER_INCLUDES) +DEFINES = -DGALLIUM_TRACE -DVER_MAJOR=$(VA_MAJOR) -DVER_MINOR=$(VA_MINOR) $(DRIVER_DEFINES) +LIBS = $(EXTRA_LIB_PATH) $(DRIVER_LIBS) -lva -lXext -lX11 -lm +STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/va/libvatracker.a + +# XXX: Hack, VA public funcs aren't exported +OBJECTS = $(C_SOURCES:.c=.o) \ + $(ASM_SOURCES:.S=.o) \ + $(TOP)/src/gallium/state_trackers/va/*.o + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +##### TARGETS ##### + +default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME) + +$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(OBJECTS) $(PIPE_DRIVERS) $(STATE_TRACKER_LIB) $(TOP)/$(LIB_DIR)/gallium Makefile + $(MKLIB) -o $(LIBBASENAME) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + -major $(VA_MAJOR) -minor $(VA_MINOR) $(MKLIB_OPTIONS) \ + -install $(TOP)/$(LIB_DIR)/gallium \ + $(OBJECTS) $(STATE_TRACKER_LIB) $(PIPE_DRIVERS) $(LIBS) + +$(TOP)/$(LIB_DIR)/gallium: + mkdir -p $@ + +depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS) + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDES) $(C_SOURCES) \ + $(ASM_SOURCES) 2> /dev/null + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` + +# Remove .o and backup files +clean: + -rm -f *.o *~ *.so $(SYMLINKS) + -rm -f depend depend.bak + +install: default + $(INSTALL) -d $(DESTDIR)$(VA_LIB_INSTALL_DIR) + $(MINSTALL) -m 755 $(TOP)/$(LIB_DIR)/gallium/$(VA_LIB_GLOB) $(DESTDIR)$(VA_LIB_INSTALL_DIR) + +include depend diff --git a/src/gallium/targets/va-softpipe/Makefile b/src/gallium/targets/va-softpipe/Makefile new file mode 100644 index 00000000000..a58df36a966 --- /dev/null +++ b/src/gallium/targets/va-softpipe/Makefile @@ -0,0 +1,21 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBBASENAME = softpipe_drv_video + +DRIVER_DEFINES = -DGALLIUM_SOFTPIPE +DRIVER_INCLUDES = + +PIPE_DRIVERS = \ + $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/auxiliary/libgallium.a + +C_SOURCES = \ + $(TOP)/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c + +DRIVER_LIBS = + +include ../Makefile.va + +symlinks: From 8ba4c96f8204003ff0d5247d71c0855827810560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Thu, 28 Oct 2010 14:32:54 +0200 Subject: [PATCH 35/36] vl: rest of va stubs --- src/gallium/state_trackers/va/Makefile | 3 ++- src/gallium/state_trackers/va/va_config.c | 5 +++-- src/gallium/state_trackers/va/va_context.c | 1 - src/gallium/state_trackers/va/va_image.c | 4 ++-- src/gallium/targets/va-r600/Makefile | 26 ++++++++++++++++++++++ src/gallium/targets/va-r600/target.c | 24 ++++++++++++++++++++ 6 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 src/gallium/targets/va-r600/Makefile create mode 100644 src/gallium/targets/va-r600/target.c diff --git a/src/gallium/state_trackers/va/Makefile b/src/gallium/state_trackers/va/Makefile index 1e22bb50d1d..dd303ebace9 100644 --- a/src/gallium/state_trackers/va/Makefile +++ b/src/gallium/state_trackers/va/Makefile @@ -19,7 +19,8 @@ C_SOURCES = htab.c \ va_buffer.c \ va_config.c \ va_picture.c \ - va_surface.c + va_surface.c \ + va_display.c diff --git a/src/gallium/state_trackers/va/va_config.c b/src/gallium/state_trackers/va/va_config.c index 5756c2f155d..591d113a916 100644 --- a/src/gallium/state_trackers/va/va_config.c +++ b/src/gallium/state_trackers/va/va_config.c @@ -29,7 +29,7 @@ #include #include "va_private.h" -VAStatus vlVaConfigProfiles( VADriverContextP ctx, +VAStatus vlVaQueryConfigProfiles( VADriverContextP ctx, VAProfile *profile_list, int *num_profiles) { @@ -40,7 +40,7 @@ VAStatus vlVaConfigProfiles( VADriverContextP ctx, } -VAStatus vlVaConfigEntrypoints( VADriverContextP ctx, +VAStatus vlVaQueryConfigEntrypoints( VADriverContextP ctx, VAProfile profile, VAEntrypoint *entypoint_list, int *num_entrypoints) @@ -98,3 +98,4 @@ VAStatus vlVaQueryConfigAttributes( VADriverContextP ctx, return VA_STATUS_ERROR_UNIMPLEMENTED; } + diff --git a/src/gallium/state_trackers/va/va_context.c b/src/gallium/state_trackers/va/va_context.c index 7ef84606305..1e3ab9cb22e 100644 --- a/src/gallium/state_trackers/va/va_context.c +++ b/src/gallium/state_trackers/va/va_context.c @@ -84,6 +84,5 @@ VAStatus vlVaTerminate( VADriverContextP ctx) { if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; } diff --git a/src/gallium/state_trackers/va/va_image.c b/src/gallium/state_trackers/va/va_image.c index b1f990a15eb..40a96d3ea48 100644 --- a/src/gallium/state_trackers/va/va_image.c +++ b/src/gallium/state_trackers/va/va_image.c @@ -66,7 +66,7 @@ VAStatus vlVaDeriveImage( VADriverContextP ctx, return VA_STATUS_ERROR_UNIMPLEMENTED; } -VAStatus vlDestroyImage( VADriverContextP ctx, +VAStatus vlVaDestroyImage( VADriverContextP ctx, VAImageID image) { if (!ctx) @@ -76,7 +76,7 @@ VAStatus vlDestroyImage( VADriverContextP ctx, return VA_STATUS_ERROR_UNIMPLEMENTED; } -VAStatus vlSetImagePalette( VADriverContextP ctx, +VAStatus vlVaSetImagePalette( VADriverContextP ctx, VAImageID image, unsigned char *palette) { diff --git a/src/gallium/targets/va-r600/Makefile b/src/gallium/targets/va-r600/Makefile new file mode 100644 index 00000000000..03ca8edaf25 --- /dev/null +++ b/src/gallium/targets/va-r600/Makefile @@ -0,0 +1,26 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBBASENAME = r600_drv_video + +DRIVER_DEFINES = -DGALLIUM_SOFTPIPE +DRIVER_INCLUDES = + +PIPE_DRIVERS = \ + $(TOP)/src/gallium/drivers/r600/libr600.a \ + $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \ + $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/auxiliary/libgallium.a + +C_SOURCES = \ + target.c \ + $(COMMON_GALLIUM_SOURCES) \ + $(DRIVER_SOURCES) + +DRIVER_LIBS = $(shell pkg-config libdrm_radeon --libs) -lXfixes + +include ../Makefile.va + +symlinks: diff --git a/src/gallium/targets/va-r600/target.c b/src/gallium/targets/va-r600/target.c new file mode 100644 index 00000000000..8753e2bab17 --- /dev/null +++ b/src/gallium/targets/va-r600/target.c @@ -0,0 +1,24 @@ +#include "state_tracker/drm_driver.h" +#include "target-helpers/inline_debug_helper.h" +#include "r600/drm/r600_drm_public.h" +#include "r600/r600_public.h" + +static struct pipe_screen *create_screen(int fd) +{ + struct radeon *radeon; + struct pipe_screen *screen; + + radeon = r600_drm_winsys_create(fd); + if (!radeon) + return NULL; + + screen = r600_screen_create(radeon); + if (!screen) + return NULL; + + screen = debug_screen_wrap(screen); + + return screen; +} + +DRM_DRIVER_DESCRIPTOR("r600", "radeon", create_screen) From 2b296ec77c2b95e7632b45100de5a0878ac2a294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Balling=20S=C3=B8rensen?= Date: Thu, 28 Oct 2010 22:46:28 +0200 Subject: [PATCH 36/36] vl: initial implementation of vlVaQueryImageFormats(), vlVaCreateImage(), vlVaQuerySubpictureFormats(), vlVaCreateSurfaces(), vlVaQueryConfigEntrypoints(), vlVaQueryConfigProfiles() --- src/gallium/state_trackers/va/ftab.c | 4 +- src/gallium/state_trackers/va/htab.c | 7 ++- src/gallium/state_trackers/va/va_config.c | 36 ++++++++++- src/gallium/state_trackers/va/va_context.c | 27 +++++++-- src/gallium/state_trackers/va/va_display.c | 6 +- src/gallium/state_trackers/va/va_image.c | 60 ++++++++++++++++++- src/gallium/state_trackers/va/va_picture.c | 1 + src/gallium/state_trackers/va/va_private.h | 24 ++++++++ src/gallium/state_trackers/va/va_subpicture.c | 20 +++---- src/gallium/state_trackers/va/va_surface.c | 49 ++++++++++++++- 10 files changed, 209 insertions(+), 25 deletions(-) diff --git a/src/gallium/state_trackers/va/ftab.c b/src/gallium/state_trackers/va/ftab.c index a567eee9dd1..999287e7a7e 100644 --- a/src/gallium/state_trackers/va/ftab.c +++ b/src/gallium/state_trackers/va/ftab.c @@ -30,6 +30,8 @@ #include #include "va_private.h" +struct VADriverVTable vlVaGetVtable(); + static struct VADriverVTable vtable = { &vlVaTerminate, /* VAStatus (*vaTerminate) ( VADriverContextP ctx ); */ @@ -125,7 +127,7 @@ static struct VADriverVTable vtable = unsigned int *buffer_name, void **buffer); */ &vlVaUnlockSurface, /* VAStatus (*vaUnlockSurface) (VADriverContextP ctx,VASurfaceID surface); */ - 0x44 /* struct VADriverVTableGLX *glx; "Optional" */ + NULL /* struct VADriverVTableGLX *glx; "Optional" */ }; struct VADriverVTable vlVaGetVtable() diff --git a/src/gallium/state_trackers/va/htab.c b/src/gallium/state_trackers/va/htab.c index 069c7930927..2187507c6a4 100644 --- a/src/gallium/state_trackers/va/htab.c +++ b/src/gallium/state_trackers/va/htab.c @@ -29,9 +29,10 @@ #include #include "va_private.h" -#define VL_HANDLES - -typedef uint32_t vlHandle; +boolean vlCreateHTAB(void); +void vlDestroyHTAB(void); +vlHandle vlAddDataHTAB(void *data); +void* vlGetDataHTAB(vlHandle handle); #ifdef VL_HANDLES static struct handle_table *htab = NULL; diff --git a/src/gallium/state_trackers/va/va_config.c b/src/gallium/state_trackers/va/va_config.c index 591d113a916..1589abf7cfa 100644 --- a/src/gallium/state_trackers/va/va_config.c +++ b/src/gallium/state_trackers/va/va_config.c @@ -27,6 +27,7 @@ #include #include +#include #include "va_private.h" VAStatus vlVaQueryConfigProfiles( VADriverContextP ctx, @@ -36,19 +37,48 @@ VAStatus vlVaQueryConfigProfiles( VADriverContextP ctx, if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + int i = 0; + + profile_list[i++] = VAProfileMPEG2Simple; + *num_profiles = i; + + return VA_STATUS_SUCCESS; } VAStatus vlVaQueryConfigEntrypoints( VADriverContextP ctx, VAProfile profile, - VAEntrypoint *entypoint_list, + VAEntrypoint *entrypoint_list, int *num_entrypoints) { if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + + VAStatus vaStatus = VA_STATUS_SUCCESS; - return VA_STATUS_ERROR_UNIMPLEMENTED; + switch (profile) { + case VAProfileMPEG2Simple: + case VAProfileMPEG2Main: + VA_INFO("Using profile %08x\n",profile); + *num_entrypoints = 1; + entrypoint_list[0] = VAEntrypointMoComp; + break; + + case VAProfileH264Baseline: + case VAProfileH264Main: + case VAProfileH264High: + vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; + *num_entrypoints = 0; + break; + + default: + VA_ERROR("Unsupported profile %08x\n",profile); + vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; + *num_entrypoints = 0; + break; + } + + return vaStatus; } diff --git a/src/gallium/state_trackers/va/va_context.c b/src/gallium/state_trackers/va/va_context.c index 1e3ab9cb22e..cdb20cc0eb2 100644 --- a/src/gallium/state_trackers/va/va_context.c +++ b/src/gallium/state_trackers/va/va_context.c @@ -27,7 +27,10 @@ #include #include +#include +#include #include +#include #include #include #include "va_private.h" @@ -37,19 +40,35 @@ PUBLIC VAStatus __vaDriverInit_0_31 (VADriverContextP ctx) { + vlVaDriverContextPriv *driver_context = NULL; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - + + + /* Create private driver context */ + driver_context = CALLOC(1,sizeof(vlVaDriverContextPriv)); + if (!driver_context) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + + driver_context->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); + if (!driver_context->vscreen) + { + FREE(driver_context); + return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + ctx->str_vendor = "mesa gallium vaapi"; ctx->vtable = vlVaGetVtable(); ctx->max_attributes = 1; ctx->max_display_attributes = 1; - ctx->max_entrypoints = 1; - ctx->max_image_formats = 1; + ctx->max_entrypoints = VA_MAX_ENTRYPOINTS; + ctx->max_image_formats = VA_MAX_IMAGE_FORMATS_SUPPORTED; ctx->max_profiles = 1; - ctx->max_subpic_formats = 1; + ctx->max_subpic_formats = VA_MAX_SUBPIC_FORMATS_SUPPORTED; ctx->version_major = 3; ctx->version_minor = 1; + ctx->pDriverData = (void *)driver_context; VA_INFO("vl_screen_pointer %p\n",ctx->native_dpy); diff --git a/src/gallium/state_trackers/va/va_display.c b/src/gallium/state_trackers/va/va_display.c index d50d712d4e0..1aaaf7ccc53 100644 --- a/src/gallium/state_trackers/va/va_display.c +++ b/src/gallium/state_trackers/va/va_display.c @@ -37,8 +37,12 @@ VAStatus vlVaQueryDisplayAttributes( VADriverContextP ctx, if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!(attr_list && num_attributes)) + return VA_STATUS_ERROR_UNKNOWN; - return VA_STATUS_ERROR_UNIMPLEMENTED; + *num_attributes = 0; + + return VA_STATUS_SUCCESS; } VAStatus vlVaGetDisplayAttributes( VADriverContextP ctx, diff --git a/src/gallium/state_trackers/va/va_image.c b/src/gallium/state_trackers/va/va_image.c index 40a96d3ea48..8d20bfa9174 100644 --- a/src/gallium/state_trackers/va/va_image.c +++ b/src/gallium/state_trackers/va/va_image.c @@ -27,10 +27,30 @@ #include #include +#include +#include #include #include #include "va_private.h" +typedef struct { + enum pipe_format pipe_format; + VAImageFormat va_format; +} va_image_formats_supported_t; + +static const va_image_formats_supported_t va_image_formats_supported[VA_MAX_IMAGE_FORMATS_SUPPORTED] = +{ + { PIPE_FORMAT_B8G8R8A8_UNORM, + { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }}, + { PIPE_FORMAT_R8G8B8A8_UNORM, + { VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }} +}; + +boolean vlCreateHTAB(void); +void vlDestroyHTAB(void); +vlHandle vlAddDataHTAB(void *data); +void* vlGetDataHTAB(vlHandle handle); + VAStatus vlVaQueryImageFormats ( VADriverContextP ctx, VAImageFormat *format_list, @@ -39,8 +59,20 @@ vlVaQueryImageFormats ( VADriverContextP ctx, if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!(format_list && num_formats)) + return VA_STATUS_ERROR_UNKNOWN; + + int n = 0; + + num_formats[0] = VA_MAX_IMAGE_FORMATS_SUPPORTED; + + /* Query supported formats */ + for (n = 0; n < VA_MAX_IMAGE_FORMATS_SUPPORTED; n++) + { + format_list[n] = va_image_formats_supported[n].va_format; + } - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_SUCCESS; } VAStatus vlVaCreateImage( VADriverContextP ctx, @@ -52,7 +84,31 @@ VAStatus vlVaCreateImage( VADriverContextP ctx, if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + if(!format) + return VA_STATUS_ERROR_UNKNOWN; + + if (!(width && height)) + return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; + + if (!vlCreateHTAB()) + return VA_STATUS_ERROR_UNKNOWN; + + switch (format->fourcc) { + case VA_FOURCC('B','G','R','A'): + VA_INFO("Creating BGRA image of size %dx%d\n",width,height); + break; + case VA_FOURCC_RGBA: + VA_INFO("Creating RGBA image of size %dx%d\n",width,height); + break; + default: + VA_ERROR("Couldn't create image of type %0x08\n",format->fourcc); + return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; + break; + } + + VA_INFO("Image %p created successfully\n",format); + + return VA_STATUS_SUCCESS; } VAStatus vlVaDeriveImage( VADriverContextP ctx, diff --git a/src/gallium/state_trackers/va/va_picture.c b/src/gallium/state_trackers/va/va_picture.c index cf7d844a780..3603dfb6fed 100644 --- a/src/gallium/state_trackers/va/va_picture.c +++ b/src/gallium/state_trackers/va/va_picture.c @@ -27,6 +27,7 @@ #include #include +#include #include "va_private.h" VAStatus vlVaBeginPicture( VADriverContextP ctx, diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index bd037c89606..625c6cdbe1b 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -30,17 +30,41 @@ #include #include +#include +#include + #define VA_DEBUG(_str,...) debug_printf("[Gallium VA backend]: " _str,__VA_ARGS__) #define VA_INFO(_str,...) VA_DEBUG("INFO: " _str,__VA_ARGS__) #define VA_WARNING(_str,...) VA_DEBUG("WARNING: " _str,__VA_ARGS__) #define VA_ERROR(_str,...) VA_DEBUG("ERROR: " _str,__VA_ARGS__) +#define VA_MAX_IMAGE_FORMATS_SUPPORTED 2 +#define VA_MAX_SUBPIC_FORMATS_SUPPORTED 2 +#define VA_MAX_ENTRYPOINTS 1 + +#define VL_HANDLES + +typedef unsigned int vlHandle; + +typedef struct { + struct vl_screen *vscreen; + struct pipe_surface *backbuffer; +} vlVaDriverContextPriv; + +typedef struct { + unsigned int width; + unsigned int height; + enum pipe_video_chroma_format format; + VADriverContextP ctx; +} vlVaSurfacePriv; + // Public functions: VAStatus __vaDriverInit_0_31 (VADriverContextP ctx); // Private functions: struct VADriverVTable vlVaGetVtable(); + // Vtable functions: VAStatus vlVaTerminate (VADriverContextP ctx); VAStatus vlVaQueryConfigProfiles (VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); diff --git a/src/gallium/state_trackers/va/va_subpicture.c b/src/gallium/state_trackers/va/va_subpicture.c index a6d2960e7e5..910e5bd7b70 100644 --- a/src/gallium/state_trackers/va/va_subpicture.c +++ b/src/gallium/state_trackers/va/va_subpicture.c @@ -30,23 +30,20 @@ #include #include "va_private.h" -#define NUM_FORMATS_SUPPORTED 2 typedef struct { - enum pipe_format; + enum pipe_format pipe_format; VAImageFormat va_format; unsigned int va_flags; } va_subpicture_formats_supported_t; -static const va_subpicture_formats_supported_t va_subpicture_formats_supported[NUM_FORMATS_SUPPORTED] = +static const va_subpicture_formats_supported_t va_subpicture_formats_supported[VA_MAX_SUBPIC_FORMATS_SUPPORTED + 1] = { { PIPE_FORMAT_B8G8R8A8_UNORM, - { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, - 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }, + { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }, 0 }, { PIPE_FORMAT_R8G8B8A8_UNORM, - { VA_FOURCC('R','G','B','A'), VA_LSB_FIRST, 32, - 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }, + { VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }, 0 } }; @@ -62,12 +59,15 @@ vlVaQuerySubpictureFormats( VADriverContextP ctx, if (!(format_list && flags && num_formats)) return VA_STATUS_ERROR_UNKNOWN; + num_formats[0] = VA_MAX_SUBPIC_FORMATS_SUPPORTED; + int n = 0; /* Query supported formats */ - for (n = 0; n < NUM_FORMATS_SUPPORTED; n++) + for (n = 0; n < VA_MAX_SUBPIC_FORMATS_SUPPORTED ; n++) { - flags[n] = va_subpicture_formats_supported[n].va_flags; - format_list[n] = va_subpicture_formats_supported[n].va_format; + const va_subpicture_formats_supported_t * const format_map = &va_subpicture_formats_supported[n]; + flags[n] = format_map->va_flags; + format_list[n] = format_map->va_format; } return VA_STATUS_SUCCESS; diff --git a/src/gallium/state_trackers/va/va_surface.c b/src/gallium/state_trackers/va/va_surface.c index ad241adaf41..a86c806248a 100644 --- a/src/gallium/state_trackers/va/va_surface.c +++ b/src/gallium/state_trackers/va/va_surface.c @@ -27,8 +27,31 @@ #include #include +#include +#include #include "va_private.h" +boolean vlCreateHTAB(void); +void vlDestroyHTAB(void); +vlHandle vlAddDataHTAB(void *data); +void* vlGetDataHTAB(vlHandle handle); + +static enum pipe_video_chroma_format VaRTFormatToPipe(unsigned int va_type) +{ + switch (va_type) { + case VA_RT_FORMAT_YUV420: + return PIPE_VIDEO_CHROMA_FORMAT_420; + case VA_RT_FORMAT_YUV422: + return PIPE_VIDEO_CHROMA_FORMAT_422; + case VA_RT_FORMAT_YUV444: + return PIPE_VIDEO_CHROMA_FORMAT_444; + default: + assert(0); + } + + return -1; +} + VAStatus vlVaCreateSurfaces( VADriverContextP ctx, int width, int height, @@ -39,7 +62,31 @@ VAStatus vlVaCreateSurfaces( VADriverContextP ctx, if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + /* We only support one format */ + if (VA_RT_FORMAT_YUV420 != format) + return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; + + if (!(width && height)) + return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; + + if (!vlCreateHTAB()) + return VA_STATUS_ERROR_UNKNOWN; + + vlVaSurfacePriv *va_surface = (vlVaSurfacePriv *)CALLOC(num_surfaces,sizeof(vlVaSurfacePriv)); + if (!va_surface) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + + int n = 0; + for (n = 0; n < num_surfaces; n++) + { + va_surface[n].width = width; + va_surface[n].height = height; + va_surface[n].format = VaRTFormatToPipe(format); + va_surface[n].ctx = ctx; + surfaces[n] = (VASurfaceID *)vlAddDataHTAB((void *)(va_surface + n)); + } + + return VA_STATUS_SUCCESS; } VAStatus vlVaDestroySurfaces( VADriverContextP ctx,