diff options
author | Ben Skeggs <skeggsb@gmail.com> | 2008-10-27 15:40:40 +1100 |
---|---|---|
committer | Ben Skeggs <skeggsb@gmail.com> | 2008-10-27 15:40:40 +1100 |
commit | ee35de2dfb12415416817d417f59e676b34ea81b (patch) | |
tree | 14fc6e43eb0be509fc53694f8289a3675fcbbf75 | |
parent | 70a06e03d45f3d2e1cd1d430ba83c4b22471373c (diff) | |
parent | 3354e668f0d4eb7ad1d92607031c1fc2e785e8d1 (diff) |
Merge remote branch 'nouveau/gallium-0.1' into gallium-0.2
56 files changed, 1081 insertions, 1417 deletions
diff --git a/src/driclient/src/.gitignore b/src/driclient/src/.gitignore deleted file mode 100644 index 9daeafb986..0000000000 --- a/src/driclient/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/src/driclient/src/Makefile b/src/driclient/src/Makefile index 5d913ad5fa..34435a2086 100644 --- a/src/driclient/src/Makefile +++ b/src/driclient/src/Makefile @@ -8,16 +8,12 @@ CFLAGS += -g -Wall -fPIC -I../include -I${DRMDIR}/include -I${DRMDIR}/include/d .PHONY = all clean -all: ${TARGET} test +all: ${TARGET} ${TARGET}: ${OBJECTS} ar rcs $@ $^ if ! test -d ../lib; then mkdir ../lib; fi cp ${TARGET} ../lib -test: test.o - $(CC) -L../lib -L${DRMDIR}/lib ${LDFLAGS} -o $@ $^ -ldriclient -lX11 -lXext -ldrm - clean: - rm -rf ${OBJECTS} ${TARGET} ../lib/${TARGET} test test.o - + rm -rf ${OBJECTS} ${TARGET} ../lib/${TARGET} diff --git a/src/driclient/src/test.c b/src/driclient/src/test.c deleted file mode 100644 index 15f75d928b..0000000000 --- a/src/driclient/src/test.c +++ /dev/null @@ -1,41 +0,0 @@ -#include <assert.h> -#include <stdio.h> -#include "driclient.h" - -int main(int argc, char **argv) -{ - Display *dpy; - Window root, window; - - dri_screen_t *screen; - dri_drawable_t *dri_drawable; - dri_context_t *context; - - dpy = XOpenDisplay(NULL); - root = XDefaultRootWindow(dpy); - window = XCreateSimpleWindow(dpy, root, 0, 0, 100, 100, 0, 0, 0); - - XSelectInput(dpy, window, 0); - XMapWindow(dpy, window); - XSync(dpy, 0); - - assert(driCreateScreen(dpy, 0, &screen, NULL) == 0); - assert(driCreateDrawable(screen, window, &dri_drawable) == 0); - assert(driCreateContext(screen, XDefaultVisual(dpy, 0), &context) == 0); - assert(driUpdateDrawableInfo(dri_drawable) == 0); - - DRI_VALIDATE_DRAWABLE_INFO(screen, dri_drawable); - - assert(drmGetLock(screen->fd, context->drm_context, 0) == 0); - assert(drmUnlock(screen->fd, context->drm_context) == 0); - - assert(driDestroyContext(context) == 0); - assert(driDestroyDrawable(dri_drawable) == 0); - assert(driDestroyScreen(screen) == 0); - - XDestroyWindow(dpy, window); - XCloseDisplay(dpy); - - return 0; -} - diff --git a/src/driclient/src/xf86dri.h b/src/driclient/src/xf86dri.h deleted file mode 100644 index baf80a7a9d..0000000000 --- a/src/driclient/src/xf86dri.h +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, 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 PRECISION INSIGHT 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. - -**************************************************************************/ - -/** - * \file xf86dri.h - * Protocol numbers and function prototypes for DRI X protocol. - * - * \author Kevin E. Martin <martin@valinux.com> - * \author Jens Owen <jens@tungstengraphics.com> - * \author Rickard E. (Rik) Faith <faith@valinux.com> - */ - -#ifndef _XF86DRI_H_ -#define _XF86DRI_H_ - -#include <X11/Xfuncproto.h> -#include <xf86drm.h> - -#define X_XF86DRIQueryVersion 0 -#define X_XF86DRIQueryDirectRenderingCapable 1 -#define X_XF86DRIOpenConnection 2 -#define X_XF86DRICloseConnection 3 -#define X_XF86DRIGetClientDriverName 4 -#define X_XF86DRICreateContext 5 -#define X_XF86DRIDestroyContext 6 -#define X_XF86DRICreateDrawable 7 -#define X_XF86DRIDestroyDrawable 8 -#define X_XF86DRIGetDrawableInfo 9 -#define X_XF86DRIGetDeviceInfo 10 -#define X_XF86DRIAuthConnection 11 -#define X_XF86DRIOpenFullScreen 12 /* Deprecated */ -#define X_XF86DRICloseFullScreen 13 /* Deprecated */ - -#define XF86DRINumberEvents 0 - -#define XF86DRIClientNotLocal 0 -#define XF86DRIOperationNotSupported 1 -#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1) - -#ifndef _XF86DRI_SERVER_ - -_XFUNCPROTOBEGIN - -Bool XF86DRIQueryExtension( Display *dpy, int *event_base, int *error_base ); - -Bool XF86DRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion, - int *patchVersion ); - -Bool XF86DRIQueryDirectRenderingCapable( Display *dpy, int screen, - Bool *isCapable ); - -Bool XF86DRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA, - char **busIDString ); - -Bool XF86DRIAuthConnection( Display *dpy, int screen, drm_magic_t magic ); - -Bool XF86DRICloseConnection( Display *dpy, int screen ); - -Bool XF86DRIGetClientDriverName( Display *dpy, int screen, - int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, char **clientDriverName ); - -Bool XF86DRICreateContext( Display *dpy, int screen, Visual *visual, - XID *ptr_to_returned_context_id, drm_context_t *hHWContext ); - -Bool XF86DRICreateContextWithConfig( Display *dpy, int screen, int configID, - XID *ptr_to_returned_context_id, drm_context_t *hHWContext ); - -Bool XF86DRIDestroyContext( Display *dpy, int screen, - XID context_id ); - -Bool XF86DRICreateDrawable( Display *dpy, int screen, - Drawable drawable, drm_drawable_t *hHWDrawable ); - -Bool XF86DRIDestroyDrawable( Display *dpy, int screen, - Drawable drawable); - -Bool XF86DRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, drm_clip_rect_t **pBackClipRects ); - -Bool XF86DRIGetDeviceInfo( Display *dpy, int screen, - drm_handle_t *hFrameBuffer, int *fbOrigin, int *fbSize, - int *fbStride, int *devPrivateSize, void **pDevPrivate ); - -_XFUNCPROTOEND - -#endif /* _XF86DRI_SERVER_ */ - -#endif /* _XF86DRI_H_ */ - diff --git a/src/gallium/drivers/nouveau/nouveau_bo.h b/src/gallium/drivers/nouveau/nouveau_bo.h index 65b138283c..0ed3367815 100644 --- a/src/gallium/drivers/nouveau/nouveau_bo.h +++ b/src/gallium/drivers/nouveau/nouveau_bo.h @@ -37,6 +37,7 @@ #define NOUVEAU_BO_LOCAL (1 << 9) #define NOUVEAU_BO_TILED (1 << 10) #define NOUVEAU_BO_ZTILE (1 << 11) +#define NOUVEAU_BO_SWIZZLED (1 << 12) #define NOUVEAU_BO_DUMMY (1 << 31) struct nouveau_bo { diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c index 91246f5ca0..9e6f746a42 100644 --- a/src/gallium/drivers/nv30/nv30_fragtex.c +++ b/src/gallium/drivers/nv30/nv30_fragtex.c @@ -26,7 +26,7 @@ static INLINE int log2i(int i) return r; } -#define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w) \ +#define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w,swsurf) \ { \ TRUE, \ PIPE_FORMAT_##m, \ @@ -35,6 +35,7 @@ static INLINE int log2i(int i) NV34TCL_TX_SWIZZLE_S0_Z_##ts0z | NV34TCL_TX_SWIZZLE_S0_W_##ts0w | \ NV34TCL_TX_SWIZZLE_S1_X_##ts1x | NV34TCL_TX_SWIZZLE_S1_Y_##ts1y | \ NV34TCL_TX_SWIZZLE_S1_Z_##ts1z | NV34TCL_TX_SWIZZLE_S1_W_##ts1w), \ + swsurf \ } struct nv30_texture_format { @@ -42,24 +43,25 @@ struct nv30_texture_format { uint pipe; int format; int swizzle; + int swizzled_surface; }; static struct nv30_texture_format nv30_texture_formats[] = { - _(A8R8G8B8_UNORM, A8R8G8B8, S1, S1, S1, S1, X, Y, Z, W), - _(A1R5G5B5_UNORM, A1R5G5B5, S1, S1, S1, S1, X, Y, Z, W), - _(A4R4G4B4_UNORM, A4R4G4B4, S1, S1, S1, S1, X, Y, Z, W), - _(R5G6B5_UNORM , R5G6B5 , S1, S1, S1, ONE, X, Y, Z, W), - _(L8_UNORM , L8 , S1, S1, S1, ONE, X, X, X, X), - _(A8_UNORM , L8 , ZERO, ZERO, ZERO, S1, X, X, X, X), - _(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X), - _(A8L8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y), -// _(Z16_UNORM , Z16 , S1, S1, S1, ONE, X, X, X, X), -// _(Z24S8_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X), - _(DXT1_RGB , DXT1 , S1, S1, S1, ONE, X, Y, Z, W), - _(DXT1_RGBA , DXT1 , S1, S1, S1, S1, X, Y, Z, W), - _(DXT3_RGBA , DXT3 , S1, S1, S1, S1, X, Y, Z, W), - _(DXT5_RGBA , DXT5 , S1, S1, S1, S1, X, Y, Z, W), + _(A8R8G8B8_UNORM, A8R8G8B8, S1, S1, S1, S1, X, Y, Z, W, 1), + _(A1R5G5B5_UNORM, A1R5G5B5, S1, S1, S1, S1, X, Y, Z, W, 1), + _(A4R4G4B4_UNORM, A4R4G4B4, S1, S1, S1, S1, X, Y, Z, W, 1), + _(R5G6B5_UNORM , R5G6B5 , S1, S1, S1, ONE, X, Y, Z, W, 1), + _(L8_UNORM , L8 , S1, S1, S1, ONE, X, X, X, X, 1), + _(A8_UNORM , L8 , ZERO, ZERO, ZERO, S1, X, X, X, X, 1), + _(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X, 1), + _(A8L8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y, 1), +// _(Z16_UNORM , Z16 , S1, S1, S1, ONE, X, X, X, X, 0), +// _(Z24S8_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X, 0), + _(DXT1_RGB , DXT1 , S1, S1, S1, ONE, X, Y, Z, W, 0), + _(DXT1_RGBA , DXT1 , S1, S1, S1, S1, X, Y, Z, W, 0), + _(DXT3_RGBA , DXT3 , S1, S1, S1, S1, X, Y, Z, W, 0), + _(DXT5_RGBA , DXT5 , S1, S1, S1, S1, X, Y, Z, W, 0), {}, }; @@ -96,6 +98,8 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit) if (!tf) assert(0); + tex_flags |= (tf->swizzled_surface ? NOUVEAU_BO_SWIZZLED : 0); + txf = tf->format; txf |= ((pt->last_level>0) ? NV34TCL_TX_FORMAT_MIPMAP : 0); txf |= log2i(pt->width[0]) << 20; diff --git a/src/gallium/drivers/nv50/nv50_clear.c b/src/gallium/drivers/nv50/nv50_clear.c index fbc6cd09ce..a31a42d6b5 100644 --- a/src/gallium/drivers/nv50/nv50_clear.c +++ b/src/gallium/drivers/nv50/nv50_clear.c @@ -30,6 +30,61 @@ void nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps, unsigned clearValue) { - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); + struct nv50_context *nv50 = nv50_context(pipe); + struct pipe_framebuffer_state fb, s_fb = nv50->framebuffer; + struct pipe_scissor_state sc, s_sc = nv50->scissor; + unsigned dirty = nv50->dirty; + + nv50->dirty = 0; + + if (ps->format == PIPE_FORMAT_Z24S8_UNORM || + ps->format == PIPE_FORMAT_Z16_UNORM) { + fb.num_cbufs = 0; + fb.zsbuf = ps; + } else { + fb.num_cbufs = 1; + fb.cbufs[0] = ps; + fb.zsbuf = NULL; + } + fb.width = ps->width; + fb.height = ps->height; + pipe->set_framebuffer_state(pipe, &fb); + + sc.minx = sc.miny = 0; + sc.maxx = fb.width; + sc.maxy = fb.height; + pipe->set_scissor_state(pipe, &sc); + + nv50_state_validate(nv50); + + switch (ps->format) { + case PIPE_FORMAT_A8R8G8B8_UNORM: + BEGIN_RING(tesla, 0x0d80, 4); + OUT_RINGf (ubyte_to_float((clearValue >> 16) & 0xff)); + OUT_RINGf (ubyte_to_float((clearValue >> 8) & 0xff)); + OUT_RINGf (ubyte_to_float((clearValue >> 0) & 0xff)); + OUT_RINGf (ubyte_to_float((clearValue >> 24) & 0xff)); + BEGIN_RING(tesla, 0x19d0, 1); + OUT_RING (0x3c); + break; + case PIPE_FORMAT_Z24S8_UNORM: + BEGIN_RING(tesla, 0x0d90, 1); + OUT_RINGf ((float)(clearValue >> 8) * (1.0 / 16777215.0)); + BEGIN_RING(tesla, 0x0da0, 1); + OUT_RING (clearValue & 0xff); + BEGIN_RING(tesla, 0x19d0, 1); + OUT_RING (0x03); + break; + default: + pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, + clearValue); + break; + } + + pipe->set_framebuffer_state(pipe, &s_fb); + pipe->set_scissor_state(pipe, &s_sc); + nv50->dirty |= dirty; + ps->status = PIPE_SURFACE_STATUS_CLEAR; } + diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c index b0e8fe2f0b..28a8bdc0fa 100644 --- a/src/gallium/drivers/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nv50/nv50_miptree.c @@ -48,6 +48,8 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt) } pitch = ((pt->width[0] + 63) & ~63) * pt->block.size; + /*XXX*/ + pitch *= 2; mt->buffer = ws->buffer_create(ws, 256, usage, pitch * pt->height[0]); if (!mt->buffer) { diff --git a/src/gallium/state_trackers/g3dvl/tests/.gitignore b/src/gallium/state_trackers/g3dvl/tests/.gitignore deleted file mode 100644 index 9b1ec4e212..0000000000 --- a/src/gallium/state_trackers/g3dvl/tests/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -test_context -test_surface -test_i_rendering -test_p_rendering -test_pf_rendering -test_b_rendering diff --git a/src/gallium/state_trackers/g3dvl/tests/Makefile b/src/gallium/state_trackers/g3dvl/tests/Makefile deleted file mode 100644 index 45cefa2e57..0000000000 --- a/src/gallium/state_trackers/g3dvl/tests/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -GALLIUMDIR = ../../.. - -CFLAGS += -g -Wall -Werror \ - -I${GALLIUMDIR}/state_trackers/g3dvl \ - -I${GALLIUMDIR}/winsys/g3dvl \ - -I${GALLIUMDIR}/include \ - -I${GALLIUMDIR}/auxiliary \ - -I${GALLIUMDIR}/drivers -LDFLAGS += -L${GALLIUMDIR}/state_trackers/g3dvl \ - -L${GALLIUMDIR}/drivers/softpipe \ - -L${GALLIUMDIR}/auxiliary/tgsi \ - -L${GALLIUMDIR}/auxiliary/draw \ - -L${GALLIUMDIR}/auxiliary/util \ - -L${GALLIUMDIR}/auxiliary/translate \ - -L${GALLIUMDIR}/auxiliary/cso_cache \ - -L${GALLIUMDIR}/auxiliary/rtasm -LIBS += -lg3dvl -lsoftpipe -ldraw -ltgsi -ltranslate -lrtasm -lcso_cache -lutil -lX11 -lm - -############################################# - -.PHONY = all clean - -all: test_context test_surface test_i_rendering test_p_rendering test_pf_rendering test_b_rendering - -test_context: test_context.o ${GALLIUMDIR}/winsys/g3dvl/xsp_winsys.o - $(CC) ${LDFLAGS} -o $@ $^ ${LIBS} - -test_surface: test_surface.o ${GALLIUMDIR}/winsys/g3dvl/xsp_winsys.o - $(CC) ${LDFLAGS} -o $@ $^ ${LIBS} - -test_i_rendering: test_i_rendering.o ${GALLIUMDIR}/winsys/g3dvl/xsp_winsys.o - $(CC) ${LDFLAGS} -o $@ $^ ${LIBS} - -test_p_rendering: test_p_rendering.o ${GALLIUMDIR}/winsys/g3dvl/xsp_winsys.o - $(CC) ${LDFLAGS} -o $@ $^ ${LIBS} - -test_pf_rendering: test_pf_rendering.o ${GALLIUMDIR}/winsys/g3dvl/xsp_winsys.o - $(CC) ${LDFLAGS} -o $@ $^ ${LIBS} - -test_b_rendering: test_b_rendering.o ${GALLIUMDIR}/winsys/g3dvl/xsp_winsys.o - $(CC) ${LDFLAGS} -o $@ $^ ${LIBS} - -clean: - rm -rf *.o test_context test_surface test_i_rendering test_p_rendering test_pf_rendering test_b_rendering - diff --git a/src/gallium/state_trackers/g3dvl/tests/test_b_rendering.c b/src/gallium/state_trackers/g3dvl/tests/test_b_rendering.c deleted file mode 100644 index b78cc851ae..0000000000 --- a/src/gallium/state_trackers/g3dvl/tests/test_b_rendering.c +++ /dev/null @@ -1,226 +0,0 @@ -#include <stdio.h> -#include <X11/Xlib.h> -#include <vl_context.h> -#include <vl_surface.h> -#include <xsp_winsys.h> - -static const unsigned short ycbcr16x16_420[8*8*6] = -{ - 0x00A5,0x00A5,0x00A5,0x0072,0x00A5,0x0072,0x0072,0x0072, - 0x0072,0x00A5,0x0072,0x0072,0x00A5,0x0072,0x0072,0x0072, - 0x0072,0x00A5,0x0072,0x0072,0x00A5,0x00A5,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5,0x00A5,0x00A5, - - 0x004F,0x004F,0x004F,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x004F,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x004F, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x004F,0x004F, - - 0x003E,0x003E,0x003E,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x003E,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x003E, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x003E,0x003E -}; - -static const signed short ycbcr16x16_420_2[8*8*6] = -{ - -0x00A5,-0x00A5,-0x00A5,-0x0072,-0x00A5,-0x0072,-0x0072,-0x0072, - -0x0072,-0x00A5,-0x0072,-0x0072,-0x00A5,-0x0072,-0x0072,-0x0072, - -0x0072,-0x00A5,-0x0072,-0x0072,-0x00A5,-0x00A5,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x00A5, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x00A5,-0x00A5, - -0x0072,-0x0072,-0x0072,-0x0072,-0x0072,-0x00A5,-0x00A5,-0x00A5, - -0x0072,-0x0072,-0x0072,-0x0072,-0x00A5,-0x00A5,-0x00A5,-0x00A5, - - -0x004F,-0x004F,-0x004F,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2, - -0x00B2,-0x00B2,-0x004F,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2, - -0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2, - -0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2, - -0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2, - -0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2, - -0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x004F, - -0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x00B2,-0x004F,-0x004F, - - -0x003E,-0x003E,-0x003E,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060, - -0x0060,-0x0060,-0x003E,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060, - -0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060, - -0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060, - -0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060, - -0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060, - -0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x003E, - -0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x0060,-0x003E,-0x003E -}; - -int main(int argc, char **argv) -{ - const unsigned int video_width = 32, video_height = 32; - const unsigned int window_width = video_width * 2, window_height = video_height * 2; - int quit = 0; - Display *display; - Window root, window; - Pixmap framebuffer; - XEvent event; - struct pipe_context *pipe; - struct VL_CONTEXT *ctx; - struct VL_SURFACE *sfc, *past_sfc, *future_sfc; - struct VL_MOTION_VECTOR motion_vector[2] = - { - { - {0, 0}, {0, 0} - }, - { - {0, 0}, {0, 0} - } - }; - - display = XOpenDisplay(NULL); - root = XDefaultRootWindow(display); - window = XCreateSimpleWindow(display, root, 0, 0, window_width, window_height, 0, 0, 0); - framebuffer = XCreatePixmap(display, root, window_width, window_height, 24); - - XSelectInput(display, window, ExposureMask | KeyPressMask); - XMapWindow(display, window); - XSync(display, 0); - - pipe = create_pipe_context(display); - vlCreateContext(display, pipe, video_width, video_height, VL_FORMAT_YCBCR_420, &ctx); - vlCreateSurface(ctx, &sfc); - vlCreateSurface(ctx, &past_sfc); - vlCreateSurface(ctx, &future_sfc); - - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, past_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, past_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, past_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, past_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, future_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, future_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, future_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, future_sfc); - vlRenderBMacroBlock - ( - VL_FRAME_PICTURE, - VL_FIELD_FIRST, - 0, - 0, - VL_FRAME_MC, - motion_vector, - 0x3F, - VL_DCT_FRAME_CODED, - (short*)ycbcr16x16_420_2, - past_sfc, - future_sfc, - sfc - ); - vlPutSurface(sfc, framebuffer, 0, 0, video_width, video_height, 0, 0, window_width, window_height, VL_FRAME_PICTURE); - - puts("Press any key to continue..."); - - while (!quit) - { - XNextEvent(display, &event); - switch (event.type) - { - case Expose: - { - XCopyArea - ( - display, - framebuffer, - window, - XDefaultGC(display, XDefaultScreen(display)), - 0, - 0, - window_width, - window_height, - 0, - 0 - ); - break; - } - case KeyPress: - { - quit = 1; - break; - } - } - } - - vlDestroySurface(sfc); - vlDestroySurface(past_sfc); - vlDestroySurface(future_sfc); - vlDestroyContext(ctx); - - XFreePixmap(display, framebuffer); - XDestroyWindow(display, window); - XCloseDisplay(display); - - return 0; -} - diff --git a/src/gallium/state_trackers/g3dvl/tests/test_context.c b/src/gallium/state_trackers/g3dvl/tests/test_context.c deleted file mode 100644 index 2002977ee2..0000000000 --- a/src/gallium/state_trackers/g3dvl/tests/test_context.c +++ /dev/null @@ -1,22 +0,0 @@ -#include <vl_context.h> -#include <xsp_winsys.h> - -int main(int argc, char **argv) -{ - const unsigned int video_width = 32, video_height = 32; - - Display *display; - struct pipe_context *pipe; - struct VL_CONTEXT *ctx; - - display = XOpenDisplay(NULL); - pipe = create_pipe_context(display); - - vlCreateContext(display, pipe, video_width, video_height, VL_FORMAT_YCBCR_420, &ctx); - vlDestroyContext(ctx); - - XCloseDisplay(display); - - return 0; -} - diff --git a/src/gallium/state_trackers/g3dvl/tests/test_i_rendering.c b/src/gallium/state_trackers/g3dvl/tests/test_i_rendering.c deleted file mode 100644 index 1f96471130..0000000000 --- a/src/gallium/state_trackers/g3dvl/tests/test_i_rendering.c +++ /dev/null @@ -1,137 +0,0 @@ -#include <stdio.h> -#include <X11/Xlib.h> -#include <vl_context.h> -#include <vl_surface.h> -#include <xsp_winsys.h> - -static const unsigned short ycbcr16x16_420[8*8*6] = -{ - 0x00A5,0x00A5,0x00A5,0x0072,0x00A5,0x0072,0x0072,0x0072, - 0x0072,0x00A5,0x0072,0x0072,0x00A5,0x0072,0x0072,0x0072, - 0x0072,0x00A5,0x0072,0x0072,0x00A5,0x00A5,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5,0x00A5,0x00A5, - - 0x004F,0x004F,0x004F,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x004F,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x004F, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x004F,0x004F, - - 0x003E,0x003E,0x003E,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x003E,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x003E, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x003E,0x003E -}; - -int main(int argc, char **argv) -{ - const unsigned int video_width = 32, video_height = 32; - const unsigned int window_width = video_width * 2, window_height = video_height * 2; - int quit = 0; - Display *display; - Window root, window; - Pixmap framebuffer; - XEvent event; - struct pipe_context *pipe; - struct VL_CONTEXT *ctx; - struct VL_SURFACE *sfc; - - display = XOpenDisplay(NULL); - root = XDefaultRootWindow(display); - window = XCreateSimpleWindow(display, root, 0, 0, window_width, window_height, 0, 0, 0); - framebuffer = XCreatePixmap(display, root, window_width, window_height, 24); - - XSelectInput(display, window, ExposureMask | KeyPressMask); - XMapWindow(display, window); - XSync(display, 0); - - pipe = create_pipe_context(display); - vlCreateContext(display, pipe, video_width, video_height, VL_FORMAT_YCBCR_420, &ctx); - vlCreateSurface(ctx, &sfc); - - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, sfc); - vlPutSurface(sfc, framebuffer, 0, 0, video_width, video_height, 0, 0, window_width, window_height, VL_FRAME_PICTURE); - - puts("Press any key to continue..."); - - while (!quit) - { - XNextEvent(display, &event); - switch (event.type) - { - case Expose: - { - XCopyArea - ( - display, - framebuffer, - window, - XDefaultGC(display, XDefaultScreen(display)), - 0, - 0, - window_width, - window_height, - 0, - 0 - ); - break; - } - case KeyPress: - { - quit = 1; - break; - } - } - } - - vlDestroySurface(sfc); - vlDestroyContext(ctx); - - XFreePixmap(display, framebuffer); - XDestroyWindow(display, window); - XCloseDisplay(display); - - return 0; -} - diff --git a/src/gallium/state_trackers/g3dvl/tests/test_p_rendering.c b/src/gallium/state_trackers/g3dvl/tests/test_p_rendering.c deleted file mode 100644 index 2203349784..0000000000 --- a/src/gallium/state_trackers/g3dvl/tests/test_p_rendering.c +++ /dev/null @@ -1,214 +0,0 @@ -#include <stdio.h> -#include <X11/Xlib.h> -#include <vl_context.h> -#include <vl_surface.h> -#include <xsp_winsys.h> - -static const unsigned short ycbcr16x16_420[8*8*6] = -{ - 0x00A5,0x00A5,0x00A5,0x0072,0x00A5,0x0072,0x0072,0x0072, - 0x0072,0x00A5,0x0072,0x0072,0x00A5,0x0072,0x0072,0x0072, - 0x0072,0x00A5,0x0072,0x0072,0x00A5,0x00A5,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5,0x00A5,0x00A5, - - 0x004F,0x004F,0x004F,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x004F,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x004F, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x004F,0x004F, - - 0x003E,0x003E,0x003E,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x003E,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x003E, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x003E,0x003E -}; - -static const signed short ycbcr16x16_420_2[8*8*6] = -{ - -51,-51,-51, 0,-51, 0, 0, 0, - 0,-51, 0, 0,-51, 0, 0, 0, - 0,-51, 0, 0,-51,-51, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 99, 99, 99, 0, 0, 0, 0, 0, - 0, 0, 99, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 33, 33, 33, 0, 0, 0, 0, 0, - 0, 0, 33, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -int main(int argc, char **argv) -{ - const unsigned int video_width = 32, video_height = 32; - const unsigned int window_width = video_width * 2, window_height = video_height * 2; - int quit = 0; - Display *display; - Window root, window; - Pixmap framebuffer; - XEvent event; - struct pipe_context *pipe; - struct VL_CONTEXT *ctx; - struct VL_SURFACE *sfc, *ref_sfc; - struct VL_MOTION_VECTOR motion_vector = - { - {0, 0}, {0, 0} - }; - - display = XOpenDisplay(NULL); - root = XDefaultRootWindow(display); - window = XCreateSimpleWindow(display, root, 0, 0, window_width, window_height, 0, 0, 0); - framebuffer = XCreatePixmap(display, root, window_width, window_height, 24); - - XSelectInput(display, window, ExposureMask | KeyPressMask); - XMapWindow(display, window); - XSync(display, 0); - - pipe = create_pipe_context(display); - vlCreateContext(display, pipe, video_width, video_height, VL_FORMAT_YCBCR_420, &ctx); - vlCreateSurface(ctx, &sfc); - vlCreateSurface(ctx, &ref_sfc); - - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, ref_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, ref_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, ref_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, ref_sfc); - vlRenderPMacroBlock - ( - VL_FRAME_PICTURE, - VL_FIELD_FIRST, - 0, - 0, - VL_FRAME_MC, - &motion_vector, - 0x3F, - VL_DCT_FRAME_CODED, - (short*)ycbcr16x16_420_2, - ref_sfc, - sfc - ); - vlPutSurface(sfc, framebuffer, 0, 0, video_width, video_height, 0, 0, window_width, window_height, VL_FRAME_PICTURE); - - puts("Press any key to continue..."); - - while (!quit) - { - XNextEvent(display, &event); - switch (event.type) - { - case Expose: - { - XCopyArea - ( - display, - framebuffer, - window, - XDefaultGC(display, XDefaultScreen(display)), - 0, - 0, - window_width, - window_height, - 0, - 0 - ); - break; - } - case KeyPress: - { - quit = 1; - break; - } - } - } - - vlDestroySurface(sfc); - vlDestroySurface(ref_sfc); - vlDestroyContext(ctx); - - XFreePixmap(display, framebuffer); - XDestroyWindow(display, window); - XCloseDisplay(display); - - return 0; -} - diff --git a/src/gallium/state_trackers/g3dvl/tests/test_pf_rendering.c b/src/gallium/state_trackers/g3dvl/tests/test_pf_rendering.c deleted file mode 100644 index 43586fc553..0000000000 --- a/src/gallium/state_trackers/g3dvl/tests/test_pf_rendering.c +++ /dev/null @@ -1,214 +0,0 @@ -#include <stdio.h> -#include <X11/Xlib.h> -#include <vl_context.h> -#include <vl_surface.h> -#include <xsp_winsys.h> - -static const unsigned short ycbcr16x16_420[8*8*6] = -{ - 0x00A5,0x00A5,0x00A5,0x0072,0x00A5,0x0072,0x0072,0x0072, - 0x0072,0x00A5,0x0072,0x0072,0x00A5,0x0072,0x0072,0x0072, - 0x0072,0x00A5,0x0072,0x0072,0x00A5,0x00A5,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5,0x00A5, - 0x0072,0x0072,0x0072,0x0072,0x00A5,0x00A5,0x00A5,0x00A5, - - 0x004F,0x004F,0x004F,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x004F,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x004F, - 0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x00B2,0x004F,0x004F, - - 0x003E,0x003E,0x003E,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x003E,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x003E, - 0x0060,0x0060,0x0060,0x0060,0x0060,0x0060,0x003E,0x003E -}; - -static const signed short ycbcr16x16_420_2[8*8*6] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -int main(int argc, char **argv) -{ - const unsigned int video_width = 32, video_height = 32; - const unsigned int window_width = video_width * 2, window_height = video_height * 2; - int quit = 0; - Display *display; - Window root, window; - Pixmap framebuffer; - XEvent event; - struct pipe_context *pipe; - struct VL_CONTEXT *ctx; - struct VL_SURFACE *sfc, *ref_sfc; - struct VL_MOTION_VECTOR motion_vector = - { - {0, 0}, {32, 32} - }; - - display = XOpenDisplay(NULL); - root = XDefaultRootWindow(display); - window = XCreateSimpleWindow(display, root, 0, 0, window_width, window_height, 0, 0, 0); - framebuffer = XCreatePixmap(display, root, window_width, window_height, 24); - - XSelectInput(display, window, ExposureMask | KeyPressMask); - XMapWindow(display, window); - XSync(display, 0); - - pipe = create_pipe_context(display); - vlCreateContext(display, pipe, video_width, video_height, VL_FORMAT_YCBCR_420, &ctx); - vlCreateSurface(ctx, &sfc); - vlCreateSurface(ctx, &ref_sfc); - - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, ref_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 0, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, ref_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 0, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, ref_sfc); - vlRenderIMacroBlock(VL_FRAME_PICTURE, VL_FIELD_FIRST, 1, 1, 0x3F, VL_DCT_FRAME_CODED, (short*)ycbcr16x16_420, ref_sfc); - vlRenderPMacroBlock - ( - VL_FRAME_PICTURE, - VL_FIELD_FIRST, - 0, - 0, - VL_FIELD_MC, - &motion_vector, - 0x3F, - VL_DCT_FRAME_CODED, - (short*)ycbcr16x16_420_2, - ref_sfc, - sfc - ); - vlPutSurface(sfc, framebuffer, 0, 0, video_width, video_height, 0, 0, window_width, window_height, VL_FRAME_PICTURE); - - puts("Press any key to continue..."); - - while (!quit) - { - XNextEvent(display, &event); - switch (event.type) - { - case Expose: - { - XCopyArea - ( - display, - framebuffer, - window, - XDefaultGC(display, XDefaultScreen(display)), - 0, - 0, - window_width, - window_height, - 0, - 0 - ); - break; - } - case KeyPress: - { - quit = 1; - break; - } - } - } - - vlDestroySurface(sfc); - vlDestroySurface(ref_sfc); - vlDestroyContext(ctx); - - XFreePixmap(display, framebuffer); - XDestroyWindow(display, window); - XCloseDisplay(display); - - return 0; -} - diff --git a/src/gallium/state_trackers/g3dvl/tests/test_surface.c b/src/gallium/state_trackers/g3dvl/tests/test_surface.c deleted file mode 100644 index 4d1946396a..0000000000 --- a/src/gallium/state_trackers/g3dvl/tests/test_surface.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <vl_context.h> -#include <vl_surface.h> -#include <xsp_winsys.h> - -int main(int argc, char **argv) -{ - const unsigned int video_width = 32, video_height = 32; - - Display *display; - struct pipe_context *pipe; - struct VL_CONTEXT *ctx; - struct VL_SURFACE *sfc; - - display = XOpenDisplay(NULL); - pipe = create_pipe_context(display); - - vlCreateContext(display, pipe, video_width, video_height, VL_FORMAT_YCBCR_420, &ctx); - vlCreateSurface(ctx, &sfc); - vlDestroySurface(sfc); - vlDestroyContext(ctx); - - XCloseDisplay(display); - - return 0; -} - diff --git a/src/gallium/state_trackers/g3dvl/vl_basic_csc.c b/src/gallium/state_trackers/g3dvl/vl_basic_csc.c index ea003a31d1..9f9dafc8a9 100644 --- a/src/gallium/state_trackers/g3dvl/vl_basic_csc.c +++ b/src/gallium/state_trackers/g3dvl/vl_basic_csc.c @@ -14,6 +14,8 @@ struct vlVertexShaderConsts { + struct vlVertex4f dst_scale; + struct vlVertex4f dst_trans; struct vlVertex4f src_scale; struct vlVertex4f src_trans; }; @@ -87,6 +89,9 @@ static int vlResizeFrameBuffer 0 ); + /* Clear to black, in case video doesn't fill the entire window */ + pipe->clear(pipe, basic_csc->framebuffer.cbufs[0], 0); + return 0; } @@ -149,6 +154,15 @@ static int vlPutPictureCSC PIPE_BUFFER_USAGE_CPU_WRITE ); + vs_consts->dst_scale.x = destw / (float)basic_csc->framebuffer.cbufs[0]->width; + vs_consts->dst_scale.y = desth / (float)basic_csc->framebuffer.cbufs[0]->height; + vs_consts->dst_scale.z = 1; + vs_consts->dst_scale.w = 1; + vs_consts->dst_trans.x = destx / (float)basic_csc->framebuffer.cbufs[0]->width; + vs_consts->dst_trans.y = desty / (float)basic_csc->framebuffer.cbufs[0]->height; + vs_consts->dst_trans.z = 0; + vs_consts->dst_trans.w = 0; + vs_consts->src_scale.x = srcw / (float)surface->texture->width[0]; vs_consts->src_scale.y = srch / (float)surface->texture->height[0]; vs_consts->src_scale.z = 1; @@ -376,10 +390,12 @@ static int vlCreateVertexShader } /* - * decl c0 ; Scaling vector to scale texcoord rect to source size - * decl c1 ; Translation vector to move texcoord rect into position + * decl c0 ; Scaling vector to scale vertex pos rect to destination size + * decl c1 ; Translation vector to move vertex pos rect into position + * decl c2 ; Scaling vector to scale texcoord rect to source size + * decl c3 ; Translation vector to move texcoord rect into position */ - decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 1); + decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 3); ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); /* @@ -392,21 +408,19 @@ static int vlCreateVertexShader ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); } - /* decl t0 */ - decl = vl_decl_temps(0, 0); + /* decl t0, t1 */ + decl = vl_decl_temps(0, 1); ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); - /* mov o0, i0 ; Move pos in to pos out */ - inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_OUTPUT, 0, TGSI_FILE_INPUT, 0); - ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti); - - /* mul t0, i1, c0 ; Scale unit texcoord rect to source size */ - inst = vl_inst3(TGSI_OPCODE_MUL, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_INPUT, 1, TGSI_FILE_CONSTANT, 0); - ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti); - - /* add o1, t0, c1 ; Translate texcoord rect into position */ - inst = vl_inst3(TGSI_OPCODE_ADD, TGSI_FILE_OUTPUT, 1, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, 1); - ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti); + /* + * madd o0, i0, c0, c1 ; Scale and translate unit output rect to destination size and pos + * madd o1, i1, c2, c3 ; Scale and translate unit texcoord rect to source size and pos + */ + for (i = 0; i < 2; ++i) + { + inst = vl_inst4(TGSI_OPCODE_MADD, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i, TGSI_FILE_CONSTANT, i * 2, TGSI_FILE_CONSTANT, i * 2 + 1); + ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti); + } /* end */ inst = vl_end(); @@ -487,9 +501,8 @@ static int vlCreateFragmentShader * dp4 o0.x, t0, c1 ; Multiply pixel by the color conversion matrix * dp4 o0.y, t0, c2 * dp4 o0.z, t0, c3 - * dp4 o0.w, t0, c4 ; XXX: Don't need 4th coefficient */ - for (i = 0; i < 4; ++i) + for (i = 0; i < 3; ++i) { inst = vl_inst3(TGSI_OPCODE_DP4, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, i + 1); inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i; @@ -519,11 +532,11 @@ static int vlCreateDataBufs pipe = csc->pipe; /* - Create our vertex buffer and vertex buffer element - VB contains 4 vertices that render a quad covering the entire window - to display a rendered surface - Quad is rendered as a tri strip - */ + * Create our vertex buffer and vertex buffer element + * VB contains 4 vertices that render a quad covering the entire window + * to display a rendered surface + * Quad is rendered as a tri strip + */ csc->vertex_bufs[0].pitch = sizeof(struct vlVertex2f); csc->vertex_bufs[0].max_index = 3; csc->vertex_bufs[0].buffer_offset = 0; @@ -550,9 +563,9 @@ static int vlCreateDataBufs csc->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT; /* - Create our texcoord buffer and texcoord buffer element - Texcoord buffer contains the TCs for mapping the rendered surface to the 4 vertices - */ + * Create our texcoord buffer and texcoord buffer element + * Texcoord buffer contains the TCs for mapping the rendered surface to the 4 vertices + */ csc->vertex_bufs[1].pitch = sizeof(struct vlVertex2f); csc->vertex_bufs[1].max_index = 3; csc->vertex_bufs[1].buffer_offset = 0; @@ -579,9 +592,9 @@ static int vlCreateDataBufs csc->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT; /* - Create our vertex shader's constant buffer - Const buffer contains scaling and translation vectors - */ + * Create our vertex shader's constant buffer + * Const buffer contains scaling and translation vectors + */ csc->vs_const_buf.size = sizeof(struct vlVertexShaderConsts); csc->vs_const_buf.buffer = pipe->winsys->buffer_create ( @@ -592,9 +605,9 @@ static int vlCreateDataBufs ); /* - Create our fragment shader's constant buffer - Const buffer contains the color conversion matrix and bias vectors - */ + * Create our fragment shader's constant buffer + * Const buffer contains the color conversion matrix and bias vectors + */ csc->fs_const_buf.size = sizeof(struct vlFragmentShaderConsts); csc->fs_const_buf.buffer = pipe->winsys->buffer_create ( @@ -605,9 +618,9 @@ static int vlCreateDataBufs ); /* - TODO: Refactor this into a seperate function, - allow changing the CSC matrix at runtime to switch between regular & full versions - */ + * TODO: Refactor this into a seperate function, + * allow changing the CSC matrix at runtime to switch between regular & full versions + */ memcpy ( pipe->winsys->buffer_map(pipe->winsys, csc->fs_const_buf.buffer, PIPE_BUFFER_USAGE_CPU_WRITE), diff --git a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c index 93839e8aa9..e7a070ef4d 100644 --- a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c +++ b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c @@ -6,10 +6,10 @@ #include <pipe/p_winsys.h> #include <pipe/p_screen.h> #include <pipe/p_state.h> -#include <pipe/p_util.h> #include <pipe/p_inlines.h> #include <tgsi/tgsi_parse.h> #include <tgsi/tgsi_build.h> +#include <util/u_math.h> #include "vl_render.h" #include "vl_shader_build.h" #include "vl_surface.h" @@ -108,17 +108,7 @@ static inline int vlGrabFieldCodedBlock(short *src, short *dst, unsigned int dst { unsigned int y; - for (y = 0; y < VL_BLOCK_HEIGHT / 2; ++y) - memcpy - ( - dst + y * dst_pitch * 2, - src + y * VL_BLOCK_WIDTH, - VL_BLOCK_WIDTH * 2 - ); - - dst += VL_BLOCK_HEIGHT * dst_pitch; - - for (; y < VL_BLOCK_HEIGHT; ++y) + for (y = 0; y < VL_BLOCK_HEIGHT; ++y) memcpy ( dst + y * dst_pitch * 2, @@ -586,11 +576,25 @@ static int vlFlush unsigned int num_macroblocks[vlNumMacroBlockExTypes] = {0}; unsigned int offset[vlNumMacroBlockExTypes]; unsigned int vb_start = 0; + unsigned int mbw; + unsigned int mbh; + unsigned int num_mb_per_frame; unsigned int i; assert(render); mc = (struct vlR16SnormBufferedMC*)render; + + if (!mc->buffered_surface) + return 0; + + mbw = align(mc->picture_width, VL_MACROBLOCK_WIDTH) / VL_MACROBLOCK_WIDTH; + mbh = align(mc->picture_height, VL_MACROBLOCK_HEIGHT) / VL_MACROBLOCK_HEIGHT; + num_mb_per_frame = mbw * mbh; + + if (mc->num_macroblocks < num_mb_per_frame) + return 0; + pipe = mc->pipe; for (i = 0; i < mc->num_macroblocks; ++i) @@ -736,8 +740,12 @@ static int vlFlush vb_start += num_macroblocks[vlMacroBlockExTypeBiPredictedField] * 24; } + pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, &mc->buffered_surface->render_fence); + for (i = 0; i < 3; ++i) mc->zero_block[i].x = -1.0f; + + mc->buffered_surface = NULL; mc->num_macroblocks = 0; mc->cur_buf++; @@ -760,12 +768,7 @@ static int vlRenderMacroBlocksMpeg2R16SnormBuffered if (mc->buffered_surface) { - if - ( - mc->buffered_surface != surface /*|| - mc->past_surface != batch->past_surface || - mc->future_surface != batch->future_surface*/ - ) + if (mc->buffered_surface != surface) { vlFlush(&mc->base); mc->buffered_surface = surface; @@ -981,7 +984,7 @@ static int vlCreateFragmentShaderIMB */ for (i = 0; i < 3; ++i) { - decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, 1, i, i, TGSI_INTERPOLATE_LINEAR); + decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, i + 1, i, i, TGSI_INTERPOLATE_LINEAR); ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); } @@ -1027,7 +1030,6 @@ static int vlCreateFragmentShaderIMB inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X; inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i; ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti); - } /* mul o0, t0, c0 ; Rescale texel to correct range */ @@ -1179,7 +1181,7 @@ static int vlCreateVertexShaderFieldPMB ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); } - /* decl c0 ; Texcoord denorm coefficients */ + /* decl c0 ; Render target dimensions */ decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 0); ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); @@ -1194,7 +1196,7 @@ static int vlCreateVertexShaderFieldPMB */ for (i = 0; i < 7; i++) { - decl = vl_decl_output((i == 0 || i == 6) ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i); + decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i); ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); } @@ -1323,7 +1325,6 @@ static int vlCreateFragmentShaderFramePMB inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X; inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i; ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti); - } /* mul t0, t0, c0 ; Rescale texel to correct range */ @@ -1442,7 +1443,6 @@ static int vlCreateFragmentShaderFieldPMB inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X; inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i; ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti); - } /* mul t0, t0, c0 ; Rescale texel to correct range */ @@ -1661,8 +1661,8 @@ static int vlCreateVertexShaderFieldBMB ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); } - /* decl c0 ; Denorm coefficients */ - decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 6); + /* decl c0 ; Render target dimensions */ + decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 0); ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); /* @@ -1678,7 +1678,7 @@ static int vlCreateVertexShaderFieldBMB */ for (i = 0; i < 9; i++) { - decl = vl_decl_output((i == 0 || i == 8) ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i); + decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i); ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti); } @@ -1818,7 +1818,6 @@ static int vlCreateFragmentShaderFrameBMB inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X; inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i; ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti); - } /* mul t0, t0, c0 ; Rescale texel to correct range */ @@ -1955,7 +1954,6 @@ static int vlCreateFragmentShaderFieldBMB inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X; inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i; ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti); - } /* mul t0, t0, c0 ; Rescale texel to correct range */ diff --git a/src/gallium/state_trackers/g3dvl/vl_surface.c b/src/gallium/state_trackers/g3dvl/vl_surface.c index 687fd1ec29..076bd40d41 100644 --- a/src/gallium/state_trackers/g3dvl/vl_surface.c +++ b/src/gallium/state_trackers/g3dvl/vl_surface.c @@ -77,6 +77,7 @@ int vlRenderMacroBlocksMpeg2 { assert(batch); assert(surface); + assert(surface->context); surface->context->render->vlBegin(surface->context->render); @@ -104,6 +105,8 @@ int vlPutPicture int desty, int destw, int desth, + int drawable_w, + int drawable_h, enum vlPictureType picture_type ) { @@ -118,7 +121,7 @@ int vlPutPicture csc = surface->context->csc; pipe = surface->context->pipe; - csc->vlResizeFrameBuffer(csc, destw, desth); + csc->vlResizeFrameBuffer(csc, drawable_w, drawable_h); csc->vlBegin(csc); @@ -139,9 +142,10 @@ int vlPutPicture csc->vlEnd(csc); - pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, &surface->disp_fence); + bind_pipe_drawable(pipe, drawable); - /* TODO: Need to take destx, desty into consideration */ + pipe->winsys->flush_frontbuffer ( pipe->winsys, @@ -152,6 +156,60 @@ int vlPutPicture return 0; } +int vlSurfaceGetStatus +( + struct vlSurface *surface, + enum vlResourceStatus *status +) +{ + assert(surface); + assert(surface->context); + assert(status); + + if (surface->render_fence && !surface->context->pipe->winsys->fence_signalled(surface->context->pipe->winsys, surface->render_fence, 0)) + { + *status = vlResourceStatusRendering; + return 0; + } + + if (surface->disp_fence && !surface->context->pipe->winsys->fence_signalled(surface->context->pipe->winsys, surface->disp_fence, 0)) + { + *status = vlResourceStatusDisplaying; + return 0; + } + + *status = vlResourceStatusFree; + + return 0; +} + +int vlSurfaceFlush +( + struct vlSurface *surface +) +{ + assert(surface); + assert(surface->context); + + surface->context->render->vlFlush(surface->context->render); + + return 0; +} + +int vlSurfaceSync +( + struct vlSurface *surface +) +{ + assert(surface); + assert(surface->context); + assert(surface->render_fence); + + surface->context->pipe->winsys->fence_finish(surface->context->pipe->winsys, surface->render_fence, 0); + + return 0; +} + struct vlScreen* vlSurfaceGetScreen ( struct vlSurface *surface diff --git a/src/gallium/state_trackers/g3dvl/vl_surface.h b/src/gallium/state_trackers/g3dvl/vl_surface.h index b975e131fa..133e1515ef 100644 --- a/src/gallium/state_trackers/g3dvl/vl_surface.h +++ b/src/gallium/state_trackers/g3dvl/vl_surface.h @@ -8,12 +8,14 @@ struct pipe_texture; struct vlSurface { - struct vlScreen *screen; - struct vlContext *context; - unsigned int width; - unsigned int height; - enum vlFormat format; - struct pipe_texture *texture; + struct vlScreen *screen; + struct vlContext *context; + unsigned int width; + unsigned int height; + enum vlFormat format; + struct pipe_texture *texture; + struct pipe_fence_handle *render_fence; + struct pipe_fence_handle *disp_fence; }; #endif @@ -49,9 +51,27 @@ int vlPutPicture int desty, int destw, int desth, + int drawable_w, + int drawable_h, enum vlPictureType picture_type ); +int vlSurfaceGetStatus +( + struct vlSurface *surface, + enum vlResourceStatus *status +); + +int vlSurfaceFlush +( + struct vlSurface *surface +); + +int vlSurfaceSync +( + struct vlSurface *surface +); + struct vlScreen* vlSurfaceGetScreen ( struct vlSurface *surface diff --git a/src/gallium/state_trackers/g3dvl/vl_types.h b/src/gallium/state_trackers/g3dvl/vl_types.h index b432bfde93..274e1f7437 100644 --- a/src/gallium/state_trackers/g3dvl/vl_types.h +++ b/src/gallium/state_trackers/g3dvl/vl_types.h @@ -13,6 +13,13 @@ struct vlScreen; struct vlContext; struct vlSurface; +enum vlResourceStatus +{ + vlResourceStatusFree, + vlResourceStatusRendering, + vlResourceStatusDisplaying +}; + enum vlProfile { vlProfileMpeg2Simple, diff --git a/src/gallium/winsys/drm/nouveau/nv04_surface.c b/src/gallium/winsys/drm/nouveau/nv04_surface.c index 8fa3d106c8..5bf89e1952 100644 --- a/src/gallium/winsys/drm/nouveau/nv04_surface.c +++ b/src/gallium/winsys/drm/nouveau/nv04_surface.c @@ -3,6 +3,32 @@ #include "nouveau_context.h" +static INLINE int log2i(int i) +{ + int r = 0; + + if (i & 0xffff0000) { + i >>= 16; + r += 16; + } + if (i & 0x0000ff00) { + i >>= 8; + r += 8; + } + if (i & 0x000000f0) { + i >>= 4; + r += 4; + } + if (i & 0x0000000c) { + i >>= 2; + r += 2; + } + if (i & 0x00000002) { + r += 1; + } + return r; +} + static INLINE int nv04_surface_format(enum pipe_format format) { @@ -82,6 +108,56 @@ nv04_surface_copy_blit(struct nouveau_context *nv, unsigned dx, unsigned dy, } static int +nv04_surface_copy_prep_swizzled(struct nouveau_context *nv, + struct pipe_surface *dst, + struct pipe_surface *src) +{ + struct nouveau_channel *chan = nv->nvc->channel; + + BEGIN_RING(chan, nv->nvc->NvSwzSurf, + NV04_SWIZZLED_SURFACE_FORMAT, 2); + /* FIXME: read destination format from somewhere */ + OUT_RING (chan, + NV04_SWIZZLED_SURFACE_FORMAT_COLOR_A8R8G8B8 + | (log2i(dst->width)<<NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT) + | (log2i(dst->height)<<NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT) ); + OUT_RELOCo(chan, nouveau_buffer(dst->buffer)->bo, + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + + BEGIN_RING(chan, nv->nvc->NvSIFM, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 13); + OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE); + /* FIXME: read source format from somewhere */ + OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8); + OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY); + OUT_RING (chan, 0); + OUT_RING (chan, (src->height<<16) | src->width); + OUT_RING (chan, 0); + OUT_RING (chan, (src->height<<16) | src->width); + OUT_RING (chan, 1<<20); + OUT_RING (chan, 1<<20); + OUT_RING (chan, (src->height<<16) | src->width); + OUT_RING (chan, + src->stride + | NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER + | NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE); + OUT_RELOCo(chan, nouveau_buffer(src->buffer)->bo, + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + OUT_RING (chan, 0); + + BEGIN_RING(chan, nv->nvc->NvM2MF, + NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2); + OUT_RELOCo(chan, nouveau_buffer(src->buffer)->bo, + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RELOCo(chan, nouveau_buffer(dst->buffer)->bo, + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + + nv->surface_copy = nv04_surface_copy_m2mf; + nv->surf_dst = dst; + nv->surf_src = src; + return 0; +} + +static int nv04_surface_copy_prep(struct nouveau_context *nv, struct pipe_surface *dst, struct pipe_surface *src) { @@ -91,6 +167,13 @@ nv04_surface_copy_prep(struct nouveau_context *nv, struct pipe_surface *dst, if (src->format != dst->format) return 1; + /* Setup transfer to swizzle the texture to vram if needed */ + /* FIXME/TODO: check proper limits of this operation */ + if (nouveau_buffer(dst->buffer)->bo->flags & NOUVEAU_BO_SWIZZLED) { + /* FIXME: Disable it for the moment */ + /*return nv04_surface_copy_prep_swizzled(nv, dst, src);*/ + } + /* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback * to NV_MEMORY_TO_MEMORY_FORMAT in this case. */ @@ -298,6 +381,22 @@ nouveau_surface_channel_create_nv04(struct nouveau_channel_context *nvc) } BIND_RING (chan, nvc->NvSIFM, nvc->next_subchannel++); + BEGIN_RING(chan, nvc->NvSIFM, NV04_SCALED_IMAGE_FROM_MEMORY_DMA_NOTIFY, 1); + OUT_RING (chan, 0); + BEGIN_RING(chan, nvc->NvSIFM, NV04_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1); + OUT_RING (chan, nvc->channel->vram->handle); + BEGIN_RING(chan, nvc->NvSIFM, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1); + OUT_RING (chan, nvc->NvSwzSurf); + BEGIN_RING(chan, nvc->NvSIFM, NV04_SCALED_IMAGE_FROM_MEMORY_PATTERN, 1); + OUT_RING (chan, 0); + BEGIN_RING(chan, nvc->NvSIFM, NV04_SCALED_IMAGE_FROM_MEMORY_ROP, 1); + OUT_RING (chan, 0); + BEGIN_RING(chan, nvc->NvSIFM, NV04_SCALED_IMAGE_FROM_MEMORY_BETA1, 1); + OUT_RING (chan, 0); + BEGIN_RING(chan, nvc->NvSIFM, NV04_SCALED_IMAGE_FROM_MEMORY_BETA4, 1); + OUT_RING (chan, 0); + BEGIN_RING(chan, nvc->NvSIFM, NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION, 1); + OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY); return 0; } diff --git a/src/gallium/winsys/g3dvl/nouveau/Makefile b/src/gallium/winsys/g3dvl/nouveau/Makefile index 7fa29d2f5f..5d11bde322 100644 --- a/src/gallium/winsys/g3dvl/nouveau/Makefile +++ b/src/gallium/winsys/g3dvl/nouveau/Makefile @@ -34,15 +34,16 @@ LIBS += -ldriclient -ldrm -lnv10 -lnv30 -lnv40 -lnv50 -ldraw -ltgsi -ltranslate ############################################# -.PHONY = all clean +.PHONY = all clean libdriclient all: ${TARGET} -${TARGET}: ${OBJECTS} +${TARGET}: ${OBJECTS} libdriclient + $(CC) ${LDFLAGS} -shared -o $@ ${OBJECTS} ${LIBS} + +libdriclient: cd ${DRIDIR}/src; ${MAKE} - $(CC) ${LDFLAGS} -shared -o $@ $^ ${LIBS} clean: cd ${DRIDIR}/src; ${MAKE} clean rm -rf ${OBJECTS} ${TARGET} - diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_bo.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_bo.c index 73ac4a4171..1005282dd4 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_bo.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_bo.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_bo.c
\ No newline at end of file +../../drm/nouveau/nouveau_bo.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_channel.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_channel.c index 6c9b2c48d8..5af8202950 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_channel.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_channel.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_channel.c
\ No newline at end of file +../../drm/nouveau/nouveau_channel.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_context.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_context.c index 5e173c7672..06a61fcda3 100644 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_context.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_context.c @@ -1,7 +1,7 @@ #include "pipe/p_defines.h" #include "pipe/p_context.h" #include "pipe/p_screen.h" -#include "pipe/p_util.h" +#include "util/u_memory.h" #include "nouveau_context.h" #include "nouveau_dri.h" @@ -150,7 +150,7 @@ nouveau_context_create(dri_context_t *dri_context) fb_bo = calloc(1, sizeof(struct nouveau_bo_priv)); fb_bo->drm.offset = nv_screen->front_offset; fb_bo->drm.flags = NOUVEAU_MEM_FB; - fb_bo->drm.size = nv_screen->front_pitch * + fb_bo->drm.size = nv_screen->front_pitch * nv_screen->front_height; fb_bo->refcount = 1; fb_bo->base.flags = NOUVEAU_BO_PIN | NOUVEAU_BO_VRAM; @@ -280,7 +280,7 @@ nouveau_context_bind(struct nouveau_context *nv, dri_drawable_t *dri_drawable) { assert(nv); assert(dri_drawable); - + if (nv->dri_drawable != dri_drawable) { nv->dri_drawable = dri_drawable; @@ -294,9 +294,9 @@ int nouveau_context_unbind(struct nouveau_context *nv) { assert(nv); - + nv->dri_drawable = NULL; - + return 0; } @@ -306,20 +306,20 @@ int bind_pipe_drawable(struct pipe_context *pipe, Drawable drawable) { struct nouveau_context *nv; dri_drawable_t *dri_drawable; - + nv = pipe->priv; - + driCreateDrawable(nv->nv_screen->dri_screen, drawable, &dri_drawable); - + nouveau_context_bind(nv, dri_drawable); - + return 0; } int unbind_pipe_drawable(struct pipe_context *pipe) { nouveau_context_unbind(pipe->priv); - + return 0; } @@ -329,15 +329,15 @@ struct pipe_context* create_pipe_context(Display *display, int screen) dri_framebuffer_t dri_framebuf; dri_context_t *dri_context; struct nouveau_context *nv; - + driCreateScreen(display, screen, &dri_screen, &dri_framebuf); driCreateContext(dri_screen, XDefaultVisual(display, screen), &dri_context); - + nouveau_screen_create(dri_screen, &dri_framebuf); nouveau_context_create(dri_context); - + nv = dri_context->private; - + return nv->nvc->pctx[nv->pctx_id]; } @@ -348,15 +348,15 @@ int destroy_pipe_context(struct pipe_context *pipe) struct nouveau_context *nv; dri_screen_t *dri_screen; dri_context_t *dri_context; - + assert(pipe); - + screen = pipe->screen; winsys = pipe->winsys; nv = pipe->priv; dri_context = nv->dri_context; dri_screen = dri_context->dri_screen; - + pipe->destroy(pipe); screen->destroy(screen); free(winsys); @@ -365,7 +365,6 @@ int destroy_pipe_context(struct pipe_context *pipe) nouveau_screen_destroy(dri_screen); driDestroyContext(dri_context); driDestroyScreen(dri_screen); - + return 0; } - diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_device.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_device.c index 47d52dafa8..63f1fa040c 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_device.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_device.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_device.c
\ No newline at end of file +../../drm/nouveau/nouveau_device.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_dma.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_dma.c index 45078c964f..cd0d32e537 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_dma.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_dma.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_dma.c
\ No newline at end of file +../../drm/nouveau/nouveau_dma.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_dma.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_dma.h index 6b9ec77741..e6c7d4bc96 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_dma.h +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_dma.h @@ -1 +1 @@ -../../dri/nouveau/nouveau_dma.h
\ No newline at end of file +../../drm/nouveau/nouveau_dma.h
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_dri.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_dri.h index 0e6c9fce35..c8f9dbdc3a 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_dri.h +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_dri.h @@ -1 +1 @@ -../../dri/nouveau/nouveau_dri.h
\ No newline at end of file +../../drm/nouveau/nouveau_dri.h
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_drmif.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_drmif.h index 473b7d4812..27082c9d34 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_drmif.h +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_drmif.h @@ -1 +1 @@ -../../dri/nouveau/nouveau_drmif.h
\ No newline at end of file +../../drm/nouveau/nouveau_drmif.h
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_fence.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_fence.c index ef1f0c6afe..51a50527e6 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_fence.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_fence.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_fence.c
\ No newline at end of file +../../drm/nouveau/nouveau_fence.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_grobj.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_grobj.c index 428186544c..db17c72e6d 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_grobj.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_grobj.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_grobj.c
\ No newline at end of file +../../drm/nouveau/nouveau_grobj.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_local.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_local.h index 6b878aad22..4e9d3042cb 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_local.h +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_local.h @@ -1 +1 @@ -../../dri/nouveau/nouveau_local.h
\ No newline at end of file +../../drm/nouveau/nouveau_local.h
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_notifier.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_notifier.c index 3024a612a7..703bc3ce4a 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_notifier.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_notifier.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_notifier.c
\ No newline at end of file +../../drm/nouveau/nouveau_notifier.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_pushbuf.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_pushbuf.c index dae31d9799..4ac137cada 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_pushbuf.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_pushbuf.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_pushbuf.c
\ No newline at end of file +../../drm/nouveau/nouveau_pushbuf.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_resource.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_resource.c index e0d71e9d2b..2241af328f 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_resource.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_resource.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_resource.c
\ No newline at end of file +../../drm/nouveau/nouveau_resource.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_screen.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_screen.c index daea3fff68..f80d00050c 100644 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_screen.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_screen.c @@ -1,5 +1,5 @@ #include "pipe/p_context.h" -#include "pipe/p_util.h" +#include "util/u_memory.h" #include "nouveau_context.h" #include <nouveau_drm.h> #include "nouveau_dri.h" @@ -23,11 +23,11 @@ int nouveau_check_dri_drm_ddx(dri_version_t *dri, dri_version_t *drm, dri_versio static const dri_version_t ddx_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL}; static const dri_version_t dri_expected = {4, 0, 0}; static const dri_version_t drm_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL}; - + assert(dri); assert(drm); assert(ddx); - + if (dri->major != dri_expected.major || dri->minor < dri_expected.minor) { NOUVEAU_ERR("Unexpected DRI version.\n"); @@ -43,17 +43,17 @@ int nouveau_check_dri_drm_ddx(dri_version_t *dri, dri_version_t *drm, dri_versio NOUVEAU_ERR("Unexpected DDX version.\n"); return 1; } - + return 0; } int nouveau_screen_create(dri_screen_t *dri_screen, dri_framebuffer_t *dri_framebuf) -{ +{ struct nouveau_dri *nv_dri = dri_framebuf->private; struct nouveau_screen *nv_screen; int ret; - + if (nouveau_check_dri_drm_ddx(&dri_screen->dri, &dri_screen->drm, &dri_screen->ddx)) return 1; @@ -89,4 +89,3 @@ nouveau_screen_destroy(dri_screen_t *dri_screen) FREE(nv_screen); } - diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys.c index 43de49b98b..ce4052d557 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_winsys.c
\ No newline at end of file +../../drm/nouveau/nouveau_winsys.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c index b835bd5760..4f6ac9cad0 100644 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c @@ -1,7 +1,7 @@ #include "pipe/p_winsys.h" #include "pipe/p_defines.h" -#include "pipe/p_util.h" #include "pipe/p_inlines.h" +#include "util/u_memory.h" #include "nouveau_context.h" #include "nouveau_local.h" @@ -29,7 +29,7 @@ static struct pipe_surface * nouveau_surface_alloc(struct pipe_winsys *ws) { struct pipe_surface *surf; - + surf = CALLOC_STRUCT(pipe_surface); if (!surf) return NULL; @@ -59,10 +59,10 @@ nouveau_surface_alloc_storage ) { const unsigned int ALIGNMENT = 256; - + assert(pws); assert(surface); - + surface->width = width; surface->height = height; surface->format = format; @@ -72,7 +72,7 @@ nouveau_surface_alloc_storage surface->stride = round_up(surface->nblocksx * surface->block.size, ALIGNMENT); surface->usage = flags; surface->buffer = pws->buffer_create(pws, ALIGNMENT, PIPE_BUFFER_USAGE_PIXEL, surface->stride * surface->nblocksy); - + return 0; } @@ -84,7 +84,7 @@ nouveau_surface_release(struct pipe_winsys *ws, struct pipe_surface **s) *s = NULL; if (--surf->refcount <= 0) { if (surf->buffer) - pipe_buffer_reference(ws, &surf->buffer, NULL); + winsys_buffer_reference(ws, &surf->buffer, NULL); free(surf); } } @@ -258,4 +258,3 @@ nouveau_create_pipe_winsys(struct nouveau_context *nv) return &nvpws->pws; } - diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.h index 264716fef0..9d9460883e 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.h +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.h @@ -1 +1 @@ -../../dri/nouveau/nouveau_winsys_pipe.h
\ No newline at end of file +../../drm/nouveau/nouveau_winsys_pipe.h
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_softpipe.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_softpipe.c index 83faccde96..ec613ecbf6 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_softpipe.c +++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_softpipe.c @@ -1 +1 @@ -../../dri/nouveau/nouveau_winsys_softpipe.c
\ No newline at end of file +../../drm/nouveau/nouveau_winsys_softpipe.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nv04_surface.c b/src/gallium/winsys/g3dvl/nouveau/nv04_surface.c index e05f0671d6..4455d8f924 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nv04_surface.c +++ b/src/gallium/winsys/g3dvl/nouveau/nv04_surface.c @@ -1 +1 @@ -../../dri/nouveau/nv04_surface.c
\ No newline at end of file +../../drm/nouveau/nv04_surface.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/nouveau/nv50_surface.c b/src/gallium/winsys/g3dvl/nouveau/nv50_surface.c index 3850748229..19f102001e 120000 --- a/src/gallium/winsys/g3dvl/nouveau/nv50_surface.c +++ b/src/gallium/winsys/g3dvl/nouveau/nv50_surface.c @@ -1 +1 @@ -../../dri/nouveau/nv50_surface.c
\ No newline at end of file +../../drm/nouveau/nv50_surface.c
\ No newline at end of file diff --git a/src/gallium/winsys/g3dvl/xsp_winsys.c b/src/gallium/winsys/g3dvl/xsp_winsys.c index 0100fe37bd..68be2c2ea3 100644 --- a/src/gallium/winsys/g3dvl/xsp_winsys.c +++ b/src/gallium/winsys/g3dvl/xsp_winsys.c @@ -2,8 +2,8 @@ #include <X11/Xutil.h> #include <pipe/p_winsys.h> #include <pipe/p_state.h> -#include <pipe/p_util.h> #include <pipe/p_inlines.h> +#include <util/u_memory.h> #include <softpipe/sp_winsys.h> /* pipe_winsys implementation */ @@ -33,79 +33,79 @@ struct xsp_buffer static struct pipe_buffer* xsp_buffer_create(struct pipe_winsys *pws, unsigned alignment, unsigned usage, unsigned size) { struct xsp_buffer *buffer; - + assert(pws); - + buffer = calloc(1, sizeof(struct xsp_buffer)); buffer->base.refcount = 1; buffer->base.alignment = alignment; buffer->base.usage = usage; buffer->base.size = size; buffer->data = align_malloc(size, alignment); - + return (struct pipe_buffer*)buffer; } static struct pipe_buffer* xsp_user_buffer_create(struct pipe_winsys *pws, void *data, unsigned size) { struct xsp_buffer *buffer; - + assert(pws); - + buffer = calloc(1, sizeof(struct xsp_buffer)); buffer->base.refcount = 1; buffer->base.size = size; buffer->is_user_buffer = TRUE; buffer->data = data; - + return (struct pipe_buffer*)buffer; } static void* xsp_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buffer, unsigned flags) { struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer; - + assert(pws); assert(buffer); - + xsp_buf->mapped_data = xsp_buf->data; - + return xsp_buf->mapped_data; } static void xsp_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buffer) { struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer; - + assert(pws); assert(buffer); - + xsp_buf->mapped_data = NULL; } static void xsp_buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buffer) { struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer; - + assert(pws); assert(buffer); - + if (!xsp_buf->is_user_buffer) align_free(xsp_buf->data); - + free(xsp_buf); } static struct pipe_surface* xsp_surface_alloc(struct pipe_winsys *pws) { struct pipe_surface *surface; - + assert(pws); - + surface = calloc(1, sizeof(struct pipe_surface)); surface->refcount = 1; surface->winsys = pws; - + return surface; } @@ -127,10 +127,10 @@ static int xsp_surface_alloc_storage ) { const unsigned int ALIGNMENT = 1; - + assert(pws); assert(surface); - + surface->width = width; surface->height = height; surface->format = format; @@ -140,28 +140,28 @@ static int xsp_surface_alloc_storage surface->stride = round_up(surface->nblocksx * surface->block.size, ALIGNMENT); surface->usage = flags; surface->buffer = pws->buffer_create(pws, ALIGNMENT, PIPE_BUFFER_USAGE_PIXEL, surface->stride * surface->nblocksy); - + return 0; } static void xsp_surface_release(struct pipe_winsys *pws, struct pipe_surface **surface) { struct pipe_surface *s; - + assert(pws); assert(surface); assert(*surface); - + s = *surface; - + s->refcount--; - + if (s->refcount == 0) { - pipe_buffer_reference(pws, &s->buffer, NULL); + winsys_buffer_reference(pws, &s->buffer, NULL); free(s); } - + *surface = NULL; } @@ -176,7 +176,7 @@ static int xsp_fence_signalled(struct pipe_winsys *pws, struct pipe_fence_handle { assert(pws); assert(fence); - + return 0; } @@ -184,30 +184,30 @@ static int xsp_fence_finish(struct pipe_winsys *pws, struct pipe_fence_handle *f { assert(pws); assert(fence); - + return 0; } static void xsp_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surface, void *context_private) -{ +{ struct xsp_pipe_winsys *xsp_winsys; struct xsp_context *xsp_context; - + assert(pws); assert(surface); assert(context_private); - + xsp_winsys = (struct xsp_pipe_winsys*)pws; xsp_context = (struct xsp_context*)context_private; - + if (!xsp_context->drawable_bound) return; - + xsp_winsys->fbimage.width = surface->width; xsp_winsys->fbimage.height = surface->height; xsp_winsys->fbimage.bytes_per_line = surface->width * (xsp_winsys->fbimage.bits_per_pixel >> 3); xsp_winsys->fbimage.data = pipe_surface_map(surface, 0); - + XPutImage ( xsp_context->display, @@ -236,25 +236,25 @@ static const char* xsp_get_name(struct pipe_winsys *pws) int bind_pipe_drawable(struct pipe_context *pipe, Drawable drawable) { struct xsp_context *xsp_context; - + assert(pipe); - + xsp_context = pipe->priv; xsp_context->drawable = drawable; xsp_context->drawable_bound = 1; - + return 0; } int unbind_pipe_drawable(struct pipe_context *pipe) { struct xsp_context *xsp_context; - + assert(pipe); - + xsp_context = pipe->priv; xsp_context->drawable_bound = 0; - + return 0; } @@ -264,9 +264,9 @@ struct pipe_context* create_pipe_context(Display *display, int screen) struct xsp_context *xsp_context; struct pipe_screen *sp_screen; struct pipe_context *sp_pipe; - + assert(display); - + xsp_winsys = calloc(1, sizeof(struct xsp_pipe_winsys)); xsp_winsys->base.buffer_create = xsp_buffer_create; xsp_winsys->base.user_buffer_create = xsp_user_buffer_create; @@ -281,7 +281,7 @@ struct pipe_context* create_pipe_context(Display *display, int screen) xsp_winsys->base.fence_finish = xsp_fence_finish; xsp_winsys->base.flush_frontbuffer = xsp_flush_frontbuffer; xsp_winsys->base.get_name = xsp_get_name; - + { /* XXX: Can't use the returned XImage* directly, since we don't have control over winsys destruction @@ -299,22 +299,22 @@ struct pipe_context* create_pipe_context(Display *display, int screen) 32, 0 ); - + memcpy(&xsp_winsys->fbimage, template, sizeof(XImage)); XInitImage(&xsp_winsys->fbimage); - + XDestroyImage(template); } - + sp_screen = softpipe_create_screen((struct pipe_winsys*)xsp_winsys); sp_pipe = softpipe_create(sp_screen, (struct pipe_winsys*)xsp_winsys, NULL); - + xsp_context = calloc(1, sizeof(struct xsp_context)); xsp_context->display = display; xsp_context->screen = screen; - + sp_pipe->priv = xsp_context; - + return sp_pipe; } @@ -322,16 +322,15 @@ int destroy_pipe_context(struct pipe_context *pipe) { struct pipe_screen *screen; struct pipe_winsys *winsys; - + assert(pipe); - + screen = pipe->screen; winsys = pipe->winsys; free(pipe->priv); pipe->destroy(pipe); screen->destroy(screen); free(winsys); - + return 0; } - diff --git a/src/libXvMC/Makefile b/src/libXvMC/Makefile index b72bb16efb..4de26e9620 100644 --- a/src/libXvMC/Makefile +++ b/src/libXvMC/Makefile @@ -38,27 +38,36 @@ endif ############################################# -.PHONY = all clean +ifeq (${DRIVER}, softpipe) +.PHONY = all clean g3dvl +else +.PHONY = all clean g3dvl nouveau_winsys +endif all: ${TARGET} ifeq (${DRIVER}, softpipe) -${TARGET}: ${OBJECTS} +${TARGET}: ${OBJECTS} g3dvl + $(CC) ${LDFLAGS} -shared -Wl,-soname,${SONAME} -o $@ ${OBJECTS} ${LIBS} + +g3dvl: cd ${GALLIUMDIR}/state_trackers/g3dvl; ${MAKE} - $(CC) ${LDFLAGS} -shared -Wl,-soname,${SONAME} -o $@ $^ ${LIBS} clean: cd ${GALLIUMDIR}/state_trackers/g3dvl; ${MAKE} clean rm -rf ${OBJECTS} ${TARGET} else -${TARGET}: ${OBJECTS} +${TARGET}: ${OBJECTS} g3dvl nouveau_winsys + $(CC) ${LDFLAGS} -shared -Wl,-soname,${SONAME} -o $@ ${OBJECTS} ${LIBS} + +g3dvl: cd ${GALLIUMDIR}/state_trackers/g3dvl; ${MAKE} + +nouveau_winsys: cd ${GALLIUMDIR}/winsys/g3dvl/nouveau; ${MAKE} - $(CC) ${LDFLAGS} -shared -Wl,-soname,${SONAME} -o $@ $^ ${LIBS} clean: cd ${GALLIUMDIR}/state_trackers/g3dvl; ${MAKE} clean cd ${GALLIUMDIR}/winsys/g3dvl/nouveau; ${MAKE} clean rm -rf ${OBJECTS} ${TARGET} endif - diff --git a/src/libXvMC/context.c b/src/libXvMC/context.c index 760e012d1a..698410d4c2 100644 --- a/src/libXvMC/context.c +++ b/src/libXvMC/context.c @@ -15,11 +15,11 @@ static Status Validate unsigned int width, unsigned int height, int flags, + int *found_port, int *chroma_format, int *mc_type ) { - unsigned int found_port = 0; unsigned int found_surface = 0; XvAdaptorInfo *adaptor_info; unsigned int num_adaptors; @@ -30,22 +30,24 @@ static Status Validate assert(display && chroma_format); + *found_port = 0; + ret = XvQueryAdaptors(display, XDefaultRootWindow(display), &num_adaptors, &adaptor_info); if (ret != Success) return ret; /* Scan through all adaptors looking for this port and surface */ - for (i = 0; i < num_adaptors && !found_port; ++i) + for (i = 0; i < num_adaptors && !*found_port; ++i) { /* Scan through all ports of this adaptor looking for our port */ - for (j = 0; j < adaptor_info[i].num_ports && !found_port; ++j) + for (j = 0; j < adaptor_info[i].num_ports && !*found_port; ++j) { /* If this is our port, scan through all its surfaces looking for our surface */ if (adaptor_info[i].base_id + j == port) { XvMCSurfaceInfo *surface_info; - found_port = 1; + *found_port = 1; surface_info = XvMCListSurfaceTypes(display, adaptor_info[i].base_id, &num_types); if (surface_info) @@ -75,7 +77,7 @@ static Status Validate XvFreeAdaptorInfo(adaptor_info); - if (!found_port) + if (!*found_port) return XvBadPort; if (!found_surface) return BadMatch; @@ -127,6 +129,7 @@ static enum vlFormat FormatToVL(int xvmc_format) Status XvMCCreateContext(Display *display, XvPortID port, int surface_type_id, int width, int height, int flags, XvMCContext *context) { + int found_port; int chroma_format; int mc_type; Status ret; @@ -140,8 +143,10 @@ Status XvMCCreateContext(Display *display, XvPortID port, int surface_type_id, i if (!context) return XvMCBadContext; - ret = Validate(display, port, surface_type_id, width, height, flags, &chroma_format, &mc_type); - if (ret != Success) + ret = Validate(display, port, surface_type_id, width, height, flags, &found_port, &chroma_format, &mc_type); + + /* XXX: Success and XvBadPort have the same value */ + if (ret != Success || !found_port) return ret; /* XXX: Assumes default screen, should check which screen port is on */ diff --git a/src/libXvMC/surface.c b/src/libXvMC/surface.c index 038befc297..6031b39d10 100644 --- a/src/libXvMC/surface.c +++ b/src/libXvMC/surface.c @@ -40,12 +40,12 @@ static enum vlPictureType PictureToVL(int xvmc_pic) return -1; } -static enum vlMotionType MotionToVL(int xvmc_motion_type) +static enum vlMotionType MotionToVL(int xvmc_motion_type, int xvmc_dct_type) { switch (xvmc_motion_type) { case XVMC_PREDICTION_FRAME: - return vlMotionTypeFrame; + return xvmc_dct_type == XVMC_DCT_TYPE_FIELD ? vlMotionType16x8 : vlMotionTypeFrame; case XVMC_PREDICTION_FIELD: return vlMotionTypeField; case XVMC_PREDICTION_DUAL_PRIME: @@ -171,8 +171,8 @@ Status XvMCRenderSurface batch.macroblocks[i].mby = macroblocks->macro_blocks[j].y; batch.macroblocks[i].mb_type = TypeToVL(macroblocks->macro_blocks[j].macroblock_type); if (batch.macroblocks[i].mb_type != vlMacroBlockTypeIntra) - batch.macroblocks[i].mo_type = MotionToVL(macroblocks->macro_blocks[j].motion_type); - batch.macroblocks[i].dct_type = macroblocks->macro_blocks[j].dct_type & XVMC_DCT_TYPE_FIELD ? vlDCTTypeFieldCoded : vlDCTTypeFrameCoded; + batch.macroblocks[i].mo_type = MotionToVL(macroblocks->macro_blocks[j].motion_type, macroblocks->macro_blocks[j].dct_type); + batch.macroblocks[i].dct_type = macroblocks->macro_blocks[j].dct_type == XVMC_DCT_TYPE_FIELD ? vlDCTTypeFieldCoded : vlDCTTypeFrameCoded; for (k = 0; k < 2; ++k) for (l = 0; l < 2; ++l) @@ -201,7 +201,7 @@ Status XvMCFlushSurface(Display *display, XvMCSurface *surface) assert(display == vlGetNativeDisplay(vlGetDisplay(vlSurfaceGetScreen(vl_sfc)))); - /* TODO */ + vlSurfaceFlush(vl_sfc); return Success; } @@ -219,7 +219,7 @@ Status XvMCSyncSurface(Display *display, XvMCSurface *surface) assert(display == vlGetNativeDisplay(vlGetDisplay(vlSurfaceGetScreen(vl_sfc)))); - /* TODO */ + vlSurfaceSync(vl_sfc); return Success; } @@ -266,14 +266,15 @@ Status XvMCPutSurface vl_sfc = surface->privData; - vlPutPicture(vl_sfc, drawable, srcx, srcy, srcw, srch, destx, desty, destw, desth, PictureToVL(flags)); + vlPutPicture(vl_sfc, drawable, srcx, srcy, srcw, srch, destx, desty, destw, desth, width, height, PictureToVL(flags)); return Success; } Status XvMCGetSurfaceStatus(Display *display, XvMCSurface *surface, int *status) { - struct vlSurface *vl_sfc; + struct vlSurface *vl_sfc; + enum vlResourceStatus res_status; assert(display); @@ -286,8 +287,28 @@ Status XvMCGetSurfaceStatus(Display *display, XvMCSurface *surface, int *status) assert(display == vlGetNativeDisplay(vlGetDisplay(vlSurfaceGetScreen(vl_sfc)))); - /* TODO */ - *status = 0; + vlSurfaceGetStatus(vl_sfc, &res_status); + + switch (res_status) + { + case vlResourceStatusFree: + { + *status = 0; + break; + } + case vlResourceStatusRendering: + { + *status = XVMC_RENDERING; + break; + } + case vlResourceStatusDisplaying: + { + *status = XVMC_DISPLAYING; + break; + } + default: + assert(0); + } return Success; } diff --git a/src/libXvMC/tests/.gitignore b/src/libXvMC/tests/.gitignore index eb1ef8a076..e1d2f9023d 100644 --- a/src/libXvMC/tests/.gitignore +++ b/src/libXvMC/tests/.gitignore @@ -2,4 +2,4 @@ test_context test_surface test_blocks test_rendering - +xvmc_bench diff --git a/src/libXvMC/tests/Makefile b/src/libXvMC/tests/Makefile index 2cbc97e88b..de095161d2 100644 --- a/src/libXvMC/tests/Makefile +++ b/src/libXvMC/tests/Makefile @@ -1,4 +1,4 @@ -CFLAGS += -g -Wall -Werror +CFLAGS += -g -Wall LDFLAGS += LIBS += -lXvMCW -lXvMC -lXv @@ -6,7 +6,7 @@ LIBS += -lXvMCW -lXvMC -lXv .PHONY = all clean -all: test_context test_surface test_blocks test_rendering +all: test_context test_surface test_blocks test_rendering xvmc_bench test_context: test_context.o testlib.o $(CC) ${LDFLAGS} -o $@ $^ ${LIBS} @@ -20,6 +20,8 @@ test_blocks: test_blocks.o testlib.o test_rendering: test_rendering.o testlib.o $(CC) ${LDFLAGS} -o $@ $^ ${LIBS} -clean: - rm -rf *.o test_context test_surface test_blocks test_rendering +xvmc_bench: xvmc_bench.o testlib.o + $(CC) ${LDFLAGS} -o $@ $^ ${LIBS} +clean: + rm -rf *.o test_context test_surface test_blocks test_rendering xvmc_bench diff --git a/src/libXvMC/tests/test_blocks.c b/src/libXvMC/tests/test_blocks.c index 0b895ee773..dc80adfa65 100644 --- a/src/libXvMC/tests/test_blocks.c +++ b/src/libXvMC/tests/test_blocks.c @@ -7,7 +7,7 @@ int main(int argc, char **argv) const unsigned int width = 16, height = 16; const unsigned int min_required_blocks = 1, min_required_macroblocks = 1; const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2}; - + Display *display; XvPortID port_num; int surface_type_id; @@ -17,9 +17,9 @@ int main(int argc, char **argv) XvMCSurface surface; XvMCBlockArray blocks = {0}; XvMCMacroBlockArray macroblocks = {0}; - + display = XOpenDisplay(NULL); - + if (!GetPort ( display, @@ -37,25 +37,20 @@ int main(int argc, char **argv) XCloseDisplay(display); error(1, 0, "Error, unable to find a good port.\n"); } - + if (is_overlay) { Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0); XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey); } - + assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success); assert(XvMCCreateSurface(display, &context, &surface) == Success); - + /* Test NULL context */ assert(XvMCCreateBlocks(display, NULL, 1, &blocks) == XvMCBadContext); /* Test 0 blocks */ assert(XvMCCreateBlocks(display, &context, 0, &blocks) == BadValue); - /* Test too many blocks */ - /*assert(XvMCCreateBlocks(display, &context, 16384, &blocks) == BadAlloc);*/ - - /* Note: No XvMCBadBlock(s) error in spec */ - /* Test valid params */ assert(XvMCCreateBlocks(display, &context, min_required_blocks, &blocks) == Success); /* Test context id assigned and correct */ @@ -68,11 +63,6 @@ int main(int argc, char **argv) assert(XvMCCreateMacroBlocks(display, NULL, 1, ¯oblocks) == XvMCBadContext); /* Test 0 macroblocks */ assert(XvMCCreateMacroBlocks(display, &context, 0, ¯oblocks) == BadValue); - /* Test too many macroblocks */ - /*assert(XvMCCreateMacroBlocks(display, &context, 16384, ¯oblocks) == BadAlloc);*/ - - /* Note: No XvMCBadMacroBlock(s) error in spec */ - /* Test valid params */ assert(XvMCCreateMacroBlocks(display, &context, min_required_macroblocks, ¯oblocks) == Success); /* Test context id assigned and correct */ @@ -83,13 +73,12 @@ int main(int argc, char **argv) assert(XvMCDestroyMacroBlocks(display, ¯oblocks) == Success); /* Test valid params */ assert(XvMCDestroyBlocks(display, &blocks) == Success); - + assert(XvMCDestroySurface(display, &surface) == Success); assert(XvMCDestroyContext(display, &context) == Success); - + XvUngrabPort(display, port_num, CurrentTime); XCloseDisplay(display); - + return 0; } - diff --git a/src/libXvMC/tests/test_context.c b/src/libXvMC/tests/test_context.c index 22afb7ada4..53f7449cd0 100644 --- a/src/libXvMC/tests/test_context.c +++ b/src/libXvMC/tests/test_context.c @@ -6,16 +6,16 @@ int main(int argc, char **argv) { const unsigned int width = 16, height = 16; const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2}; - + Display *display; XvPortID port_num; int surface_type_id; unsigned int is_overlay, intra_unsigned; int colorkey; XvMCContext context = {0}; - + display = XOpenDisplay(NULL); - + if (!GetPort ( display, @@ -33,22 +33,21 @@ int main(int argc, char **argv) XCloseDisplay(display); error(1, 0, "Error, unable to find a good port.\n"); } - + if (is_overlay) { Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0); XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey); } - - /* Note: XvMCBadContext not a valid return for XvMCCreateContext in the XvMC API, but openChrome driver returns it */ - /* Note: Nvidia binary driver segfaults on NULL context, halts with debug output on bad port */ - + /* Test NULL context */ + /* XXX: XvMCBadContext not a valid return for XvMCCreateContext in the XvMC API, but openChrome driver returns it */ assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, NULL) == XvMCBadContext); /* Test invalid port */ - assert(XvMCCreateContext(display, port_num + 1, surface_type_id, width, height, XVMC_DIRECT, &context) == XvBadPort); + /* XXX: Success and XvBadPort have the same value, if this call actually gets passed the validation step as of now we'll crash later */ + assert(XvMCCreateContext(display, -1, surface_type_id, width, height, XVMC_DIRECT, &context) == XvBadPort); /* Test invalid surface */ - assert(XvMCCreateContext(display, port_num, surface_type_id + 1, width, height, XVMC_DIRECT, &context) == BadMatch); + assert(XvMCCreateContext(display, port_num, -1, width, height, XVMC_DIRECT, &context) == BadMatch); /* Test invalid flags */ assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, -1, &context) == BadValue); /* Test huge width */ @@ -85,10 +84,9 @@ int main(int argc, char **argv) assert(XvMCCreateContext(display, port_num, surface_type_id, width + 1, height + 1, XVMC_DIRECT, &context) == Success); assert(context.width >= width + 1 && context.height >= height + 1); assert(XvMCDestroyContext(display, &context) == Success); - + XvUngrabPort(display, port_num, CurrentTime); XCloseDisplay(display); - + return 0; } - diff --git a/src/libXvMC/tests/test_rendering.c b/src/libXvMC/tests/test_rendering.c index 1914b1fb62..1e7467a3aa 100644 --- a/src/libXvMC/tests/test_rendering.c +++ b/src/libXvMC/tests/test_rendering.c @@ -1,38 +1,126 @@ #include <assert.h> #include <stdio.h> +#include <string.h> #include <error.h> #include "testlib.h" +#define BLOCK_WIDTH 8 +#define BLOCK_HEIGHT 8 +#define BLOCK_SIZE (BLOCK_WIDTH * BLOCK_HEIGHT) +#define MACROBLOCK_WIDTH 16 +#define MACROBLOCK_HEIGHT 16 +#define MACROBLOCK_WIDTH_IN_BLOCKS (MACROBLOCK_WIDTH / BLOCK_WIDTH) +#define MACROBLOCK_HEIGHT_IN_BLOCKS (MACROBLOCK_HEIGHT / BLOCK_HEIGHT) +#define BLOCKS_PER_MACROBLOCK 6 + +#define INPUT_WIDTH 16 +#define INPUT_HEIGHT 16 +#define INPUT_WIDTH_IN_MACROBLOCKS (INPUT_WIDTH / MACROBLOCK_WIDTH) +#define INPUT_HEIGHT_IN_MACROBLOCKS (INPUT_HEIGHT / MACROBLOCK_HEIGHT) +#define NUM_MACROBLOCKS (INPUT_WIDTH_IN_MACROBLOCKS * INPUT_HEIGHT_IN_MACROBLOCKS) + +#define DEFAULT_OUTPUT_WIDTH INPUT_WIDTH +#define DEFAULT_OUTPUT_HEIGHT INPUT_HEIGHT +#define DEFAULT_ACCEPTABLE_ERR 0.01 + +void ParseArgs(int argc, char **argv, unsigned int *output_width, unsigned int *output_height, double *acceptable_error, int *prompt) +{ + int fail = 0; + int i; + + *output_width = DEFAULT_OUTPUT_WIDTH; + *output_height = DEFAULT_OUTPUT_WIDTH; + *acceptable_error = DEFAULT_ACCEPTABLE_ERR; + *prompt = 1; + + for (i = 1; i < argc && !fail; ++i) + { + if (!strcmp(argv[i], "-w")) + { + if (sscanf(argv[++i], "%u", output_width) != 1) + fail = 1; + } + else if (!strcmp(argv[i], "-h")) + { + if (sscanf(argv[++i], "%u", output_height) != 1) + fail = 1; + } + else if (!strcmp(argv[i], "-e")) + { + if (sscanf(argv[++i], "%lf", acceptable_error) != 1) + fail = 1; + } + else if (strcmp(argv[i], "-n")) + *prompt = 0; + else + fail = 1; + } + + if (fail) + error + ( + 1, 0, + "Bad argument.\n" + "\n" + "Usage: %s [options]\n" + "\t-w <width>\tOutput width\n" + "\t-h <height>\tOutput height\n" + "\t-e <error>\tAcceptable margin of error per pixel, from 0 to 1\n" + "\t-n\tDon't prompt for quit\n", + argv[0] + ); +} + +void Gradient(short *block, unsigned int start, unsigned int stop, int horizontal) +{ + unsigned int x, y; + unsigned int range = stop - start; + + if (horizontal) + { + for (y = 0; y < BLOCK_HEIGHT; ++y) + for (x = 0; x < BLOCK_WIDTH; ++x) + block[y * BLOCK_WIDTH + x] = (short)(start + range * (x / (float)(BLOCK_WIDTH - 1))); + } + else + { + for (y = 0; y < BLOCK_HEIGHT; ++y) + for (x = 0; x < BLOCK_WIDTH; ++x) + block[y * BLOCK_WIDTH + x] = (short)(start + range * (y / (float)(BLOCK_HEIGHT - 1))); + } +} + int main(int argc, char **argv) { - const unsigned int width = 32, height = 32; - const unsigned int mwidth = width / 16, mheight = height / 16; - const unsigned int num_macroblocks = mwidth * mheight; - const unsigned int num_blocks = num_macroblocks * 6; - const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2}; - - int quit = 0; + unsigned int output_width; + unsigned int output_height; + double acceptable_error; + int prompt; Display *display; Window root, window; - Pixmap framebuffer; - XEvent event; + const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2}; XvPortID port_num; int surface_type_id; unsigned int is_overlay, intra_unsigned; int colorkey; XvMCContext context; XvMCSurface surface; - XvMCBlockArray blocks; - XvMCMacroBlockArray macroblocks; - unsigned int b, x, y; - + XvMCBlockArray block_array; + XvMCMacroBlockArray mb_array; + int mbx, mby, bx, by; + XvMCMacroBlock *mb; + short *blocks; + int quit = 0; + + ParseArgs(argc, argv, &output_width, &output_height, &acceptable_error, &prompt); + display = XOpenDisplay(NULL); - + if (!GetPort ( display, - width, - height, + INPUT_WIDTH, + INPUT_HEIGHT, XVMC_CHROMA_FORMAT_420, mc_types, 2, @@ -45,109 +133,155 @@ int main(int argc, char **argv) XCloseDisplay(display); error(1, 0, "Error, unable to find a good port.\n"); } - + if (is_overlay) { Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0); XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey); } - + root = XDefaultRootWindow(display); - window = XCreateSimpleWindow(display, root, 0, 0, width, height, 0, 0, colorkey); - framebuffer = XCreatePixmap(display, root, width, height, 24); - - XSelectInput(display, window, ExposureMask | KeyPressMask); - XMapWindow(display, window); - XSync(display, 0); - - assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success); + window = XCreateSimpleWindow(display, root, 0, 0, output_width, output_height, 0, 0, colorkey); + + assert(XvMCCreateContext(display, port_num, surface_type_id, INPUT_WIDTH, INPUT_HEIGHT, XVMC_DIRECT, &context) == Success); assert(XvMCCreateSurface(display, &context, &surface) == Success); - assert(XvMCCreateBlocks(display, &context, num_blocks, &blocks) == Success); - assert(XvMCCreateMacroBlocks(display, &context, num_macroblocks, ¯oblocks) == Success); - - for (b = 0; b < 6; ++b) - { - for (y = 0; y < 8; ++y) - { - for (x = 0; x < 8; ++x) - { - blocks.blocks[b * 64 + y * 8 + x] = 0xFFFF; - } - } - } - - for (y = 0; y < mheight; ++y) - { - for (x = 0; x < mwidth; ++x) + assert(XvMCCreateBlocks(display, &context, NUM_MACROBLOCKS * BLOCKS_PER_MACROBLOCK, &block_array) == Success); + assert(XvMCCreateMacroBlocks(display, &context, NUM_MACROBLOCKS, &mb_array) == Success); + + mb = mb_array.macro_blocks; + blocks = block_array.blocks; + + for (mby = 0; mby < INPUT_HEIGHT_IN_MACROBLOCKS; ++mby) + for (mbx = 0; mbx < INPUT_WIDTH_IN_MACROBLOCKS; ++mbx) { - macroblocks.macro_blocks[y * mwidth + x].x = x; - macroblocks.macro_blocks[y * mwidth + x].y = y; - macroblocks.macro_blocks[y * mwidth + x].index = (y * mwidth + x) * 6; - macroblocks.macro_blocks[y * mwidth + x].macroblock_type = XVMC_MB_TYPE_INTRA; - macroblocks.macro_blocks[y * mwidth + x].coded_block_pattern = 0x3F; - macroblocks.macro_blocks[y * mwidth + x].dct_type = XVMC_DCT_TYPE_FRAME; + mb->x = mbx; + mb->y = mby; + mb->macroblock_type = XVMC_MB_TYPE_INTRA; + /*mb->motion_type = ;*/ + /*mb->motion_vertical_field_select = ;*/ + mb->dct_type = XVMC_DCT_TYPE_FRAME; + /*mb->PMV[0][0][0] = ; + mb->PMV[0][0][1] = ; + mb->PMV[0][1][0] = ; + mb->PMV[0][1][1] = ; + mb->PMV[1][0][0] = ; + mb->PMV[1][0][1] = ; + mb->PMV[1][1][0] = ; + mb->PMV[1][1][1] = ;*/ + mb->index = (mby * INPUT_WIDTH_IN_MACROBLOCKS + mbx) * BLOCKS_PER_MACROBLOCK; + mb->coded_block_pattern = 0x3F; + + mb++; + + for (by = 0; by < MACROBLOCK_HEIGHT_IN_BLOCKS; ++by) + for (bx = 0; bx < MACROBLOCK_WIDTH_IN_BLOCKS; ++bx) + { + const int start = 16, stop = 235, range = stop - start; + + Gradient + ( + blocks, + (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH) / (float)(INPUT_WIDTH - 1))), + (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH + BLOCK_WIDTH - 1) / (float)(INPUT_WIDTH - 1))), + 1 + ); + + blocks += BLOCK_SIZE; + } + + for (by = 0; by < MACROBLOCK_HEIGHT_IN_BLOCKS / 2; ++by) + for (bx = 0; bx < MACROBLOCK_WIDTH_IN_BLOCKS / 2; ++bx) + { + const int start = 16, stop = 240, range = stop - start; + + Gradient + ( + blocks, + (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH) / (float)(INPUT_WIDTH - 1))), + (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH + BLOCK_WIDTH - 1) / (float)(INPUT_WIDTH - 1))), + 1 + ); + + blocks += BLOCK_SIZE; + + Gradient + ( + blocks, + (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH) / (float)(INPUT_WIDTH - 1))), + (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH + BLOCK_WIDTH - 1) / (float)(INPUT_WIDTH - 1))), + 1 + ); + + blocks += BLOCK_SIZE; + } } - } - + + XSelectInput(display, window, ExposureMask | KeyPressMask); + XMapWindow(display, window); + XSync(display, 0); + /* Test NULL context */ - assert(XvMCRenderSurface(display, NULL, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, 1, 0, ¯oblocks, &blocks) == XvMCBadContext); + assert(XvMCRenderSurface(display, NULL, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == XvMCBadContext); /* Test NULL surface */ - assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, NULL, NULL, NULL, 0, 1, 0, ¯oblocks, &blocks) == XvMCBadSurface); + assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, NULL, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == XvMCBadSurface); /* Test bad picture structure */ - assert(XvMCRenderSurface(display, &context, 0, &surface, NULL, NULL, 0, 1, 0, ¯oblocks, &blocks) == BadValue); + assert(XvMCRenderSurface(display, &context, 0, &surface, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == BadValue); /* Test valid params */ - assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, num_macroblocks, 0, ¯oblocks, &blocks) == Success); - + assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == Success); + /* Test NULL surface */ - assert(XvMCPutSurface(display, NULL, window, 0, 0, width, height, 0, 0, width, height, XVMC_FRAME_PICTURE) == XvMCBadSurface); + assert(XvMCPutSurface(display, NULL, window, 0, 0, INPUT_WIDTH, INPUT_HEIGHT, 0, 0, output_width, output_height, XVMC_FRAME_PICTURE) == XvMCBadSurface); /* Test bad window */ - /* X halts with a bad drawable for some reason, doesn't return BadDrawable as expected */ + /* XXX: X halts with a bad drawable for some reason, doesn't return BadDrawable as expected */ /*assert(XvMCPutSurface(display, &surface, 0, 0, 0, width, height, 0, 0, width, height, XVMC_FRAME_PICTURE) == BadDrawable);*/ - /* Test valid params */ - assert(XvMCPutSurface(display, &surface, framebuffer, 0, 0, width, height, 0, 0, width, height, XVMC_FRAME_PICTURE) == Success); - - puts("Press any key to continue..."); - - while (!quit) + + if (prompt) { - XNextEvent(display, &event); - switch (event.type) + puts("Press any button to quit..."); + + while (!quit) { - case Expose: - { - XCopyArea - ( - display, - framebuffer, - window, - XDefaultGC(display, XDefaultScreen(display)), - 0, - 0, - width, - height, - 0, - 0 - ); - break; - } - case KeyPress: + if (XPending(display) > 0) { - quit = 1; - break; + XEvent event; + + XNextEvent(display, &event); + + switch (event.type) + { + case Expose: + { + /* Test valid params */ + assert + ( + XvMCPutSurface + ( + display, &surface, window, + 0, 0, INPUT_WIDTH, INPUT_HEIGHT, + 0, 0, output_width, output_height, + XVMC_FRAME_PICTURE + ) == Success + ); + break; + } + case KeyPress: + { + quit = 1; + break; + } + } } } } - - assert(XvMCDestroyBlocks(display, &blocks) == Success); - assert(XvMCDestroyMacroBlocks(display, ¯oblocks) == Success); - assert(XvMCDestroySurface(display, &surface) == Success); + + assert(XvMCDestroyBlocks(display, &block_array) == Success); + assert(XvMCDestroyMacroBlocks(display, &mb_array) == Success); + assert(XvMCDestroySurface(display, &surface) == Success); assert(XvMCDestroyContext(display, &context) == Success); - - XFreePixmap(display, framebuffer); + XvUngrabPort(display, port_num, CurrentTime); XDestroyWindow(display, window); XCloseDisplay(display); - + return 0; } - diff --git a/src/libXvMC/tests/testlib.c b/src/libXvMC/tests/testlib.c index 8672aa9999..59a03ca813 100644 --- a/src/libXvMC/tests/testlib.c +++ b/src/libXvMC/tests/testlib.c @@ -32,18 +32,18 @@ int GetPort int num_types; int ev_base, err_base; unsigned int i, j, k, l; - + if (!XvMCQueryExtension(display, &ev_base, &err_base)) return 0; if (XvQueryAdaptors(display, XDefaultRootWindow(display), &num_adaptors, &adaptor_info) != Success) return 0; - + for (i = 0; i < num_adaptors && !found_port; ++i) { if (adaptor_info[i].type & XvImageMask) { XvMCSurfaceInfo *surface_info = XvMCListSurfaceTypes(display, adaptor_info[i].base_id, &num_types); - + if (surface_info) { for (j = 0; j < num_types && !found_port; ++j) @@ -74,14 +74,46 @@ int GetPort } } } - + XFree(surface_info); } } } - + XvFreeAdaptorInfo(adaptor_info); - + return found_port; } +unsigned int align(unsigned int value, unsigned int alignment) +{ + return (value + alignment - 1) & ~(alignment - 1); +} + +/* From the glibc manual */ +int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y) +{ + /* Perform the carry for the later subtraction by updating y. */ + if (x->tv_usec < y->tv_usec) + { + int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1; + y->tv_usec -= 1000000 * nsec; + y->tv_sec += nsec; + } + if (x->tv_usec - y->tv_usec > 1000000) + { + int nsec = (x->tv_usec - y->tv_usec) / 1000000; + y->tv_usec += 1000000 * nsec; + y->tv_sec -= nsec; + } + + /* + * Compute the time remaining to wait. + * tv_usec is certainly positive. + */ + result->tv_sec = x->tv_sec - y->tv_sec; + result->tv_usec = x->tv_usec - y->tv_usec; + + /* Return 1 if result is negative. */ + return x->tv_sec < y->tv_sec; +} diff --git a/src/libXvMC/tests/testlib.h b/src/libXvMC/tests/testlib.h index c73845807e..af71ad74e1 100644 --- a/src/libXvMC/tests/testlib.h +++ b/src/libXvMC/tests/testlib.h @@ -7,6 +7,7 @@ void test(int pred, const char *pred_string, const char *doc_string, const char *file, unsigned int line); */ +#include <sys/time.h> #include <X11/Xlib.h> #include <X11/extensions/XvMClib.h> @@ -34,5 +35,8 @@ int GetPort unsigned int *intra_unsigned ); -#endif +unsigned int align(unsigned int value, unsigned int alignment); + +int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y); +#endif diff --git a/src/libXvMC/tests/xvmc_bench.c b/src/libXvMC/tests/xvmc_bench.c new file mode 100644 index 0000000000..d5a39ecf17 --- /dev/null +++ b/src/libXvMC/tests/xvmc_bench.c @@ -0,0 +1,271 @@ +#include <assert.h> +#include <stdio.h> +#include <string.h> +#include <error.h> +#include <sys/time.h> +#include "testlib.h" + +#define MACROBLOCK_WIDTH 16 +#define MACROBLOCK_HEIGHT 16 +#define BLOCKS_PER_MACROBLOCK 6 + +#define DEFAULT_INPUT_WIDTH 720 +#define DEFAULT_INPUT_HEIGHT 480 +#define DEFAULT_REPS 100 + +#define PIPELINE_STEP_MC 1 +#define PIPELINE_STEP_CSC 2 +#define PIPELINE_STEP_SWAP 4 + +#define MB_TYPE_I 1 +#define MB_TYPE_P 2 +#define MB_TYPE_B 4 + +struct Config +{ + unsigned int input_width; + unsigned int input_height; + unsigned int output_width; + unsigned int output_height; + unsigned int pipeline; + unsigned int mb_types; + unsigned int reps; +}; + +void ParseArgs(int argc, char **argv, struct Config *config) +{ + int fail = 0; + int i; + + config->input_width = DEFAULT_INPUT_WIDTH; + config->input_height = DEFAULT_INPUT_HEIGHT; + config->output_width = 0; + config->output_height = 0; + config->pipeline = 0; + config->mb_types = 0; + config->reps = DEFAULT_REPS; + + for (i = 1; i < argc && !fail; ++i) + { + if (!strcmp(argv[i], "-iw")) + { + if (sscanf(argv[++i], "%u", &config->input_width) != 1) + fail = 1; + } + else if (!strcmp(argv[i], "-ih")) + { + if (sscanf(argv[++i], "%u", &config->input_height) != 1) + fail = 1; + } + else if (!strcmp(argv[i], "-ow")) + { + if (sscanf(argv[++i], "%u", &config->output_width) != 1) + fail = 1; + } + else if (!strcmp(argv[i], "-oh")) + { + if (sscanf(argv[++i], "%u", &config->output_height) != 1) + fail = 1; + } + else if (!strcmp(argv[i], "-p")) + { + char *token = strtok(argv[++i], ","); + + while (token && !fail) + { + if (!strcmp(token, "mc")) + config->pipeline |= PIPELINE_STEP_MC; + else if (!strcmp(token, "csc")) + config->pipeline |= PIPELINE_STEP_CSC; + else if (!strcmp(token, "swp")) + config->pipeline |= PIPELINE_STEP_SWAP; + else + fail = 1; + + if (!fail) + token = strtok(NULL, ","); + } + } + else if (!strcmp(argv[i], "-mb")) + { + char *token = strtok(argv[++i], ","); + + while (token && !fail) + { + if (strcmp(token, "i")) + config->mb_types |= MB_TYPE_I; + else if (strcmp(token, "p")) + config->mb_types |= MB_TYPE_P; + else if (strcmp(token, "b")) + config->mb_types |= MB_TYPE_B; + else + fail = 1; + + if (!fail) + token = strtok(NULL, ","); + } + } + else if (!strcmp(argv[i], "-r")) + { + if (sscanf(argv[++i], "%u", &config->reps) != 1) + fail = 1; + } + else + fail = 1; + } + + if (fail) + error + ( + 1, 0, + "Bad argument.\n" + "\n" + "Usage: %s [options]\n" + "\t-iw <width>\tInput width\n" + "\t-ih <height>\tInput height\n" + "\t-ow <width>\tOutput width\n" + "\t-oh <height>\tOutput height\n" + "\t-p <pipeline>\tPipeline to test\n" + "\t-mb <mb type>\tMacroBlock types to use\n" + "\t-r <reps>\tRepetitions\n\n" + "\tPipeline steps: mc,csc,swap\n" + "\tMB types: i,p,b\n", + argv[0] + ); + + if (config->output_width == 0) + config->output_width = config->input_width; + if (config->output_height == 0) + config->output_height = config->input_height; + if (!config->pipeline) + config->pipeline = PIPELINE_STEP_MC | PIPELINE_STEP_CSC | PIPELINE_STEP_SWAP; + if (!config->mb_types) + config->mb_types = MB_TYPE_I | MB_TYPE_P | MB_TYPE_B; +} + +int main(int argc, char **argv) +{ + struct Config config; + Display *display; + Window root, window; + const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2}; + XvPortID port_num; + int surface_type_id; + unsigned int is_overlay, intra_unsigned; + int colorkey; + XvMCContext context; + XvMCSurface surface; + XvMCBlockArray block_array; + XvMCMacroBlockArray mb_array; + unsigned int mbw, mbh; + unsigned int mbx, mby; + unsigned int reps; + struct timeval start, stop, diff; + double diff_secs; + + ParseArgs(argc, argv, &config); + + mbw = align(config.input_width, MACROBLOCK_WIDTH) / MACROBLOCK_WIDTH; + mbh = align(config.input_height, MACROBLOCK_HEIGHT) / MACROBLOCK_HEIGHT; + + display = XOpenDisplay(NULL); + + if (!GetPort + ( + display, + config.input_width, + config.input_height, + XVMC_CHROMA_FORMAT_420, + mc_types, + 2, + &port_num, + &surface_type_id, + &is_overlay, + &intra_unsigned + )) + { + XCloseDisplay(display); + error(1, 0, "Error, unable to find a good port.\n"); + } + + if (is_overlay) + { + Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0); + XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey); + } + + root = XDefaultRootWindow(display); + window = XCreateSimpleWindow(display, root, 0, 0, config.output_width, config.output_height, 0, 0, colorkey); + + assert(XvMCCreateContext(display, port_num, surface_type_id, config.input_width, config.input_height, XVMC_DIRECT, &context) == Success); + assert(XvMCCreateSurface(display, &context, &surface) == Success); + assert(XvMCCreateBlocks(display, &context, mbw * mbh * BLOCKS_PER_MACROBLOCK, &block_array) == Success); + assert(XvMCCreateMacroBlocks(display, &context, mbw * mbh, &mb_array) == Success); + + for (mby = 0; mby < mbh; ++mby) + for (mbx = 0; mbx < mbw; ++mbx) + { + mb_array.macro_blocks[mby * mbw + mbx].x = mbx; + mb_array.macro_blocks[mby * mbw + mbx].y = mby; + mb_array.macro_blocks[mby * mbw + mbx].macroblock_type = XVMC_MB_TYPE_INTRA; + /*mb->motion_type = ;*/ + /*mb->motion_vertical_field_select = ;*/ + mb_array.macro_blocks[mby * mbw + mbx].dct_type = XVMC_DCT_TYPE_FRAME; + /*mb->PMV[0][0][0] = ; + mb->PMV[0][0][1] = ; + mb->PMV[0][1][0] = ; + mb->PMV[0][1][1] = ; + mb->PMV[1][0][0] = ; + mb->PMV[1][0][1] = ; + mb->PMV[1][1][0] = ; + mb->PMV[1][1][1] = ;*/ + mb_array.macro_blocks[mby * mbw + mbx].index = (mby * mbw + mbx) * BLOCKS_PER_MACROBLOCK; + mb_array.macro_blocks[mby * mbw + mbx].coded_block_pattern = 0x3F; + } + + XSelectInput(display, window, ExposureMask | KeyPressMask); + XMapWindow(display, window); + XSync(display, 0); + + gettimeofday(&start, NULL); + + for (reps = 0; reps < config.reps; ++reps) + { + if (config.pipeline & PIPELINE_STEP_MC) + { + assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, mbw * mbh, 0, &mb_array, &block_array) == Success); + assert(XvMCFlushSurface(display, &surface) == Success); + } + if (config.pipeline & PIPELINE_STEP_CSC) + assert(XvMCPutSurface(display, &surface, window, 0, 0, config.input_width, config.input_height, 0, 0, config.output_width, config.output_height, XVMC_FRAME_PICTURE) == Success); + } + + gettimeofday(&stop, NULL); + + timeval_subtract(&diff, &stop, &start); + diff_secs = (double)diff.tv_sec + (double)diff.tv_usec / 1000000.0; + + printf("XvMC Benchmark\n"); + printf("Input: %u,%u\nOutput: %u,%u\n", config.input_width, config.input_height, config.output_width, config.output_height); + printf("Pipeline: "); + if (config.pipeline & PIPELINE_STEP_MC) + printf("|mc|"); + if (config.pipeline & PIPELINE_STEP_CSC) + printf("|csc|"); + if (config.pipeline & PIPELINE_STEP_SWAP) + printf("|swap|"); + printf("\n"); + printf("Reps: %u\n", config.reps); + printf("Total time: %.2lf (%.2lf reps / sec)\n", diff_secs, config.reps / diff_secs); + + assert(XvMCDestroyBlocks(display, &block_array) == Success); + assert(XvMCDestroyMacroBlocks(display, &mb_array) == Success); + assert(XvMCDestroySurface(display, &surface) == Success); + assert(XvMCDestroyContext(display, &context) == Success); + + XvUngrabPort(display, port_num, CurrentTime); + XDestroyWindow(display, window); + XCloseDisplay(display); + + return 0; +} |