diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2015-04-12 19:42:08 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2015-04-12 19:42:08 +0000 |
commit | 1594c4bc2b046e14170ca19aa151af505a6220e2 (patch) | |
tree | 1dd9502648c0696b7a511ac388c485672d76b1ac /driver/xf86-video-intel/test | |
parent | c9934e651b2fc1f3d0bce17e08b22b03ae8d374b (diff) |
Update to xf86-video-intel 2.99.916
Fixes a display bug seenby ajacoutot@, ok jsg@ and kettenis@.
newer X.Org (2.99.917 or master) version cause corruption on older
machines (X40, i965), probably caused by a bug in our kernel,
under investigation by kettenis@.
Diffstat (limited to 'driver/xf86-video-intel/test')
37 files changed, 3830 insertions, 741 deletions
diff --git a/driver/xf86-video-intel/test/Makefile.am b/driver/xf86-video-intel/test/Makefile.am index df022e28f..f9906d443 100644 --- a/driver/xf86-video-intel/test/Makefile.am +++ b/driver/xf86-video-intel/test/Makefile.am @@ -9,6 +9,7 @@ stress_TESTS = \ basic-putimage \ basic-lines \ basic-stress \ + cursor-test \ render-fill \ render-trapezoid \ render-trapezoid-image \ @@ -20,6 +21,7 @@ stress_TESTS = \ render-copyarea-size \ render-copy-alphaless \ mixed-stress \ + shm-test \ $(NULL) if DRI2 @@ -30,6 +32,12 @@ stress_TESTS += \ $(NULL) endif +if X11_DRI3 +stress_TESTS += \ + dri3-test \ + present-test \ + $(NULL) +endif check_PROGRAMS = $(stress_TESTS) noinst_PROGRAMS = lowlevel-blt-bench @@ -53,6 +61,15 @@ libtest_la_SOURCES += \ $(NULL) endif +if X11_DRI3 +libtest_la_SOURCES += \ + dri3.c \ + dri3.h \ + $(NULL) +AM_CFLAGS += $(X11_DRI3_CFLAGS) +LDADD += $(X11_DRI3_LIBS) +endif + vsync.avi: mkvsync.sh ./mkvsync.sh $@ diff --git a/driver/xf86-video-intel/test/Makefile.in b/driver/xf86-video-intel/test/Makefile.in index 7a3eed5cb..06040866b 100644 --- a/driver/xf86-video-intel/test/Makefile.in +++ b/driver/xf86-video-intel/test/Makefile.in @@ -57,13 +57,25 @@ host_triplet = @host@ @DRI2_TRUE@ dri2-test \ @DRI2_TRUE@ $(NULL) -check_PROGRAMS = $(am__EXEEXT_2) +@X11_DRI3_TRUE@am__append_2 = \ +@X11_DRI3_TRUE@ dri3-test \ +@X11_DRI3_TRUE@ present-test \ +@X11_DRI3_TRUE@ $(NULL) + +check_PROGRAMS = $(am__EXEEXT_3) noinst_PROGRAMS = lowlevel-blt-bench$(EXEEXT) -@DRI2_TRUE@am__append_2 = \ +@DRI2_TRUE@am__append_3 = \ @DRI2_TRUE@ dri2.c \ @DRI2_TRUE@ dri2.h \ @DRI2_TRUE@ $(NULL) +@X11_DRI3_TRUE@am__append_4 = \ +@X11_DRI3_TRUE@ dri3.c \ +@X11_DRI3_TRUE@ dri3.h \ +@X11_DRI3_TRUE@ $(NULL) + +@X11_DRI3_TRUE@am__append_5 = $(X11_DRI3_CFLAGS) +@X11_DRI3_TRUE@am__append_6 = $(X11_DRI3_LIBS) subdir = test DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/depcomp @@ -81,10 +93,11 @@ CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtest_la_LIBADD = am__libtest_la_SOURCES_DIST = test.h test_display.c test_image.c \ - test_log.c test_render.c dri2.c dri2.h + test_log.c test_render.c dri2.c dri2.h dri3.c dri3.h @DRI2_TRUE@am__objects_1 = dri2.lo +@X11_DRI3_TRUE@am__objects_2 = dri3.lo am_libtest_la_OBJECTS = test_display.lo test_image.lo test_log.lo \ - test_render.lo $(am__objects_1) + test_render.lo $(am__objects_1) $(am__objects_2) libtest_la_OBJECTS = $(am_libtest_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -92,147 +105,197 @@ am__v_lt_0 = --silent am__v_lt_1 = @DRI2_TRUE@am__EXEEXT_1 = dri2-race$(EXEEXT) dri2-swap$(EXEEXT) \ @DRI2_TRUE@ dri2-test$(EXEEXT) -am__EXEEXT_2 = basic-fillrect$(EXEEXT) basic-tiledrect$(EXEEXT) \ +@X11_DRI3_TRUE@am__EXEEXT_2 = dri3-test$(EXEEXT) present-test$(EXEEXT) +am__EXEEXT_3 = basic-fillrect$(EXEEXT) basic-tiledrect$(EXEEXT) \ basic-stippledrect$(EXEEXT) basic-rectangle$(EXEEXT) \ basic-string$(EXEEXT) basic-copyarea$(EXEEXT) \ basic-copyarea-size$(EXEEXT) basic-putimage$(EXEEXT) \ basic-lines$(EXEEXT) basic-stress$(EXEEXT) \ - render-fill$(EXEEXT) render-trapezoid$(EXEEXT) \ - render-trapezoid-image$(EXEEXT) render-fill-copy$(EXEEXT) \ - render-composite-solid$(EXEEXT) \ + cursor-test$(EXEEXT) render-fill$(EXEEXT) \ + render-trapezoid$(EXEEXT) render-trapezoid-image$(EXEEXT) \ + render-fill-copy$(EXEEXT) render-composite-solid$(EXEEXT) \ render-composite-solid-mask$(EXEEXT) render-copyarea$(EXEEXT) \ render-copyarea-mask$(EXEEXT) render-copyarea-size$(EXEEXT) \ render-copy-alphaless$(EXEEXT) mixed-stress$(EXEEXT) \ - $(am__EXEEXT_1) + shm-test$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) PROGRAMS = $(noinst_PROGRAMS) basic_copyarea_SOURCES = basic-copyarea.c basic_copyarea_OBJECTS = basic-copyarea.$(OBJEXT) basic_copyarea_LDADD = $(LDADD) am__DEPENDENCIES_1 = +@X11_DRI3_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) basic_copyarea_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) basic_copyarea_size_SOURCES = basic-copyarea-size.c basic_copyarea_size_OBJECTS = basic-copyarea-size.$(OBJEXT) basic_copyarea_size_LDADD = $(LDADD) basic_copyarea_size_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) basic_fillrect_SOURCES = basic-fillrect.c basic_fillrect_OBJECTS = basic-fillrect.$(OBJEXT) basic_fillrect_LDADD = $(LDADD) basic_fillrect_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) basic_lines_SOURCES = basic-lines.c basic_lines_OBJECTS = basic-lines.$(OBJEXT) basic_lines_LDADD = $(LDADD) basic_lines_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) basic_putimage_SOURCES = basic-putimage.c basic_putimage_OBJECTS = basic-putimage.$(OBJEXT) basic_putimage_LDADD = $(LDADD) basic_putimage_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) basic_rectangle_SOURCES = basic-rectangle.c basic_rectangle_OBJECTS = basic-rectangle.$(OBJEXT) basic_rectangle_LDADD = $(LDADD) basic_rectangle_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) basic_stippledrect_SOURCES = basic-stippledrect.c basic_stippledrect_OBJECTS = basic-stippledrect.$(OBJEXT) basic_stippledrect_LDADD = $(LDADD) basic_stippledrect_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) basic_stress_SOURCES = basic-stress.c basic_stress_OBJECTS = basic-stress.$(OBJEXT) basic_stress_LDADD = $(LDADD) basic_stress_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) basic_string_SOURCES = basic-string.c basic_string_OBJECTS = basic-string.$(OBJEXT) basic_string_LDADD = $(LDADD) basic_string_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) basic_tiledrect_SOURCES = basic-tiledrect.c basic_tiledrect_OBJECTS = basic-tiledrect.$(OBJEXT) basic_tiledrect_LDADD = $(LDADD) basic_tiledrect_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) +cursor_test_SOURCES = cursor-test.c +cursor_test_OBJECTS = cursor-test.$(OBJEXT) +cursor_test_LDADD = $(LDADD) +cursor_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) dri2_race_SOURCES = dri2-race.c dri2_race_OBJECTS = dri2-race.$(OBJEXT) dri2_race_LDADD = $(LDADD) dri2_race_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) dri2_swap_SOURCES = dri2-swap.c dri2_swap_OBJECTS = dri2-swap.$(OBJEXT) dri2_swap_LDADD = $(LDADD) dri2_swap_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) dri2_test_SOURCES = dri2-test.c dri2_test_OBJECTS = dri2-test.$(OBJEXT) dri2_test_LDADD = $(LDADD) dri2_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) +dri3_test_SOURCES = dri3-test.c +dri3_test_OBJECTS = dri3-test.$(OBJEXT) +dri3_test_LDADD = $(LDADD) +dri3_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) lowlevel_blt_bench_SOURCES = lowlevel-blt-bench.c lowlevel_blt_bench_OBJECTS = lowlevel-blt-bench.$(OBJEXT) lowlevel_blt_bench_LDADD = $(LDADD) lowlevel_blt_bench_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) mixed_stress_SOURCES = mixed-stress.c mixed_stress_OBJECTS = mixed-stress.$(OBJEXT) mixed_stress_LDADD = $(LDADD) mixed_stress_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) +present_test_SOURCES = present-test.c +present_test_OBJECTS = present-test.$(OBJEXT) +present_test_LDADD = $(LDADD) +present_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) render_composite_solid_SOURCES = render-composite-solid.c render_composite_solid_OBJECTS = render-composite-solid.$(OBJEXT) render_composite_solid_LDADD = $(LDADD) render_composite_solid_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) render_composite_solid_mask_SOURCES = render-composite-solid-mask.c render_composite_solid_mask_OBJECTS = \ render-composite-solid-mask.$(OBJEXT) render_composite_solid_mask_LDADD = $(LDADD) render_composite_solid_mask_DEPENDENCIES = libtest.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) render_copy_alphaless_SOURCES = render-copy-alphaless.c render_copy_alphaless_OBJECTS = render-copy-alphaless.$(OBJEXT) render_copy_alphaless_LDADD = $(LDADD) render_copy_alphaless_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) render_copyarea_SOURCES = render-copyarea.c render_copyarea_OBJECTS = render-copyarea.$(OBJEXT) render_copyarea_LDADD = $(LDADD) render_copyarea_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) render_copyarea_mask_SOURCES = render-copyarea-mask.c render_copyarea_mask_OBJECTS = render-copyarea-mask.$(OBJEXT) render_copyarea_mask_LDADD = $(LDADD) render_copyarea_mask_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) render_copyarea_size_SOURCES = render-copyarea-size.c render_copyarea_size_OBJECTS = render-copyarea-size.$(OBJEXT) render_copyarea_size_LDADD = $(LDADD) render_copyarea_size_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) render_fill_SOURCES = render-fill.c render_fill_OBJECTS = render-fill.$(OBJEXT) render_fill_LDADD = $(LDADD) render_fill_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) render_fill_copy_SOURCES = render-fill-copy.c render_fill_copy_OBJECTS = render-fill-copy.$(OBJEXT) render_fill_copy_LDADD = $(LDADD) render_fill_copy_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) render_trapezoid_SOURCES = render-trapezoid.c render_trapezoid_OBJECTS = render-trapezoid.$(OBJEXT) render_trapezoid_LDADD = $(LDADD) render_trapezoid_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) render_trapezoid_image_SOURCES = render-trapezoid-image.c render_trapezoid_image_OBJECTS = render-trapezoid-image.$(OBJEXT) render_trapezoid_image_LDADD = $(LDADD) render_trapezoid_image_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) +shm_test_SOURCES = shm-test.c +shm_test_OBJECTS = shm-test.$(OBJEXT) +shm_test_LDADD = $(LDADD) +shm_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -270,21 +333,24 @@ am__v_CCLD_1 = SOURCES = $(libtest_la_SOURCES) basic-copyarea.c basic-copyarea-size.c \ basic-fillrect.c basic-lines.c basic-putimage.c \ basic-rectangle.c basic-stippledrect.c basic-stress.c \ - basic-string.c basic-tiledrect.c dri2-race.c dri2-swap.c \ - dri2-test.c lowlevel-blt-bench.c mixed-stress.c \ - render-composite-solid.c render-composite-solid-mask.c \ - render-copy-alphaless.c render-copyarea.c \ - render-copyarea-mask.c render-copyarea-size.c render-fill.c \ - render-fill-copy.c render-trapezoid.c render-trapezoid-image.c + basic-string.c basic-tiledrect.c cursor-test.c dri2-race.c \ + dri2-swap.c dri2-test.c dri3-test.c lowlevel-blt-bench.c \ + mixed-stress.c present-test.c render-composite-solid.c \ + render-composite-solid-mask.c render-copy-alphaless.c \ + render-copyarea.c render-copyarea-mask.c \ + render-copyarea-size.c render-fill.c render-fill-copy.c \ + render-trapezoid.c render-trapezoid-image.c shm-test.c DIST_SOURCES = $(am__libtest_la_SOURCES_DIST) basic-copyarea.c \ basic-copyarea-size.c basic-fillrect.c basic-lines.c \ basic-putimage.c basic-rectangle.c basic-stippledrect.c \ - basic-stress.c basic-string.c basic-tiledrect.c dri2-race.c \ - dri2-swap.c dri2-test.c lowlevel-blt-bench.c mixed-stress.c \ + basic-stress.c basic-string.c basic-tiledrect.c cursor-test.c \ + dri2-race.c dri2-swap.c dri2-test.c dri3-test.c \ + lowlevel-blt-bench.c mixed-stress.c present-test.c \ render-composite-solid.c render-composite-solid-mask.c \ render-copy-alphaless.c render-copyarea.c \ render-copyarea-mask.c render-copyarea-size.c render-fill.c \ - render-fill-copy.c render-trapezoid.c render-trapezoid-image.c + render-fill-copy.c render-trapezoid.c render-trapezoid-image.c \ + shm-test.c am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -322,6 +388,8 @@ DRI1_CFLAGS = @DRI1_CFLAGS@ DRI1_LIBS = @DRI1_LIBS@ DRI2_CFLAGS = @DRI2_CFLAGS@ DRI2_LIBS = @DRI2_LIBS@ +DRI3_CFLAGS = @DRI3_CFLAGS@ +DRI3_LIBS = @DRI3_LIBS@ DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ DRIVER_NAME = @DRIVER_NAME@ @@ -350,8 +418,13 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTEL_GEN4ASM = @INTEL_GEN4ASM@ +IVO_CFLAGS = @IVO_CFLAGS@ +IVO_EXTRA_CFLAGS = @IVO_EXTRA_CFLAGS@ +IVO_EXTRA_LIBS = @IVO_EXTRA_LIBS@ +IVO_LIBS = @IVO_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBEXEC_PATH = @LIBEXEC_PATH@ LIBGLAMOR_CFLAGS = @LIBGLAMOR_CFLAGS@ LIBGLAMOR_EGL_CFLAGS = @LIBGLAMOR_EGL_CFLAGS@ LIBGLAMOR_EGL_LIBS = @LIBGLAMOR_EGL_LIBS@ @@ -390,23 +463,24 @@ PCIACCESS_LIBS = @PCIACCESS_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PREFIX_PATH = @PREFIX_PATH@ +PRESENT_CFLAGS = @PRESENT_CFLAGS@ +PRESENT_LIBS = @PRESENT_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRICT_CFLAGS = @STRICT_CFLAGS@ STRIP = @STRIP@ -TOOL_CFLAGS = @TOOL_CFLAGS@ -TOOL_LIBS = @TOOL_LIBS@ UDEV_CFLAGS = @UDEV_CFLAGS@ UDEV_LIBS = @UDEV_LIBS@ VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ VALGRIND_LIBS = @VALGRIND_LIBS@ VERSION = @VERSION@ X11_CFLAGS = @X11_CFLAGS@ +X11_DRI3_CFLAGS = @X11_DRI3_CFLAGS@ +X11_DRI3_LIBS = @X11_DRI3_LIBS@ X11_LIBS = @X11_LIBS@ -XCB_CFLAGS = @XCB_CFLAGS@ -XCB_LIBS = @XCB_LIBS@ XORG_CFLAGS = @XORG_CFLAGS@ XORG_LIBS = @XORG_LIBS@ XORG_MAN_PAGE = @XORG_MAN_PAGE@ @@ -468,16 +542,18 @@ top_srcdir = @top_srcdir@ stress_TESTS = basic-fillrect basic-tiledrect basic-stippledrect \ basic-rectangle basic-string basic-copyarea \ basic-copyarea-size basic-putimage basic-lines basic-stress \ - render-fill render-trapezoid render-trapezoid-image \ - render-fill-copy render-composite-solid \ + cursor-test render-fill render-trapezoid \ + render-trapezoid-image render-fill-copy render-composite-solid \ render-composite-solid-mask render-copyarea \ render-copyarea-mask render-copyarea-size \ - render-copy-alphaless mixed-stress $(NULL) $(am__append_1) -AM_CFLAGS = @CWARNFLAGS@ $(X11_CFLAGS) $(DRM_CFLAGS) -LDADD = libtest.la $(X11_LIBS) $(DRM_LIBS) $(CLOCK_GETTIME_LIBS) + render-copy-alphaless mixed-stress shm-test $(NULL) \ + $(am__append_1) $(am__append_2) +AM_CFLAGS = @CWARNFLAGS@ $(X11_CFLAGS) $(DRM_CFLAGS) $(am__append_5) +LDADD = libtest.la $(X11_LIBS) $(DRM_LIBS) $(CLOCK_GETTIME_LIBS) \ + $(am__append_6) noinst_LTLIBRARIES = libtest.la libtest_la_SOURCES = test.h test_display.c test_image.c test_log.c \ - test_render.c $(NULL) $(am__append_2) + test_render.c $(NULL) $(am__append_3) $(am__append_4) EXTRA_DIST = README mkvsync.sh tearing.mp4 virtual.conf all: all-am @@ -574,6 +650,9 @@ basic-string$(EXEEXT): $(basic_string_OBJECTS) $(basic_string_DEPENDENCIES) $(EX basic-tiledrect$(EXEEXT): $(basic_tiledrect_OBJECTS) $(basic_tiledrect_DEPENDENCIES) $(EXTRA_basic_tiledrect_DEPENDENCIES) @rm -f basic-tiledrect$(EXEEXT) $(AM_V_CCLD)$(LINK) $(basic_tiledrect_OBJECTS) $(basic_tiledrect_LDADD) $(LIBS) +cursor-test$(EXEEXT): $(cursor_test_OBJECTS) $(cursor_test_DEPENDENCIES) $(EXTRA_cursor_test_DEPENDENCIES) + @rm -f cursor-test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(cursor_test_OBJECTS) $(cursor_test_LDADD) $(LIBS) dri2-race$(EXEEXT): $(dri2_race_OBJECTS) $(dri2_race_DEPENDENCIES) $(EXTRA_dri2_race_DEPENDENCIES) @rm -f dri2-race$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dri2_race_OBJECTS) $(dri2_race_LDADD) $(LIBS) @@ -583,12 +662,18 @@ dri2-swap$(EXEEXT): $(dri2_swap_OBJECTS) $(dri2_swap_DEPENDENCIES) $(EXTRA_dri2_ dri2-test$(EXEEXT): $(dri2_test_OBJECTS) $(dri2_test_DEPENDENCIES) $(EXTRA_dri2_test_DEPENDENCIES) @rm -f dri2-test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dri2_test_OBJECTS) $(dri2_test_LDADD) $(LIBS) +dri3-test$(EXEEXT): $(dri3_test_OBJECTS) $(dri3_test_DEPENDENCIES) $(EXTRA_dri3_test_DEPENDENCIES) + @rm -f dri3-test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(dri3_test_OBJECTS) $(dri3_test_LDADD) $(LIBS) lowlevel-blt-bench$(EXEEXT): $(lowlevel_blt_bench_OBJECTS) $(lowlevel_blt_bench_DEPENDENCIES) $(EXTRA_lowlevel_blt_bench_DEPENDENCIES) @rm -f lowlevel-blt-bench$(EXEEXT) $(AM_V_CCLD)$(LINK) $(lowlevel_blt_bench_OBJECTS) $(lowlevel_blt_bench_LDADD) $(LIBS) mixed-stress$(EXEEXT): $(mixed_stress_OBJECTS) $(mixed_stress_DEPENDENCIES) $(EXTRA_mixed_stress_DEPENDENCIES) @rm -f mixed-stress$(EXEEXT) $(AM_V_CCLD)$(LINK) $(mixed_stress_OBJECTS) $(mixed_stress_LDADD) $(LIBS) +present-test$(EXEEXT): $(present_test_OBJECTS) $(present_test_DEPENDENCIES) $(EXTRA_present_test_DEPENDENCIES) + @rm -f present-test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(present_test_OBJECTS) $(present_test_LDADD) $(LIBS) render-composite-solid$(EXEEXT): $(render_composite_solid_OBJECTS) $(render_composite_solid_DEPENDENCIES) $(EXTRA_render_composite_solid_DEPENDENCIES) @rm -f render-composite-solid$(EXEEXT) $(AM_V_CCLD)$(LINK) $(render_composite_solid_OBJECTS) $(render_composite_solid_LDADD) $(LIBS) @@ -619,6 +704,9 @@ render-trapezoid$(EXEEXT): $(render_trapezoid_OBJECTS) $(render_trapezoid_DEPEND render-trapezoid-image$(EXEEXT): $(render_trapezoid_image_OBJECTS) $(render_trapezoid_image_DEPENDENCIES) $(EXTRA_render_trapezoid_image_DEPENDENCIES) @rm -f render-trapezoid-image$(EXEEXT) $(AM_V_CCLD)$(LINK) $(render_trapezoid_image_OBJECTS) $(render_trapezoid_image_LDADD) $(LIBS) +shm-test$(EXEEXT): $(shm_test_OBJECTS) $(shm_test_DEPENDENCIES) $(EXTRA_shm_test_DEPENDENCIES) + @rm -f shm-test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(shm_test_OBJECTS) $(shm_test_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -636,12 +724,16 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basic-stress.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basic-string.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basic-tiledrect.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cursor-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri2-race.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri2-swap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri2-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri2.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri3-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri3.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lowlevel-blt-bench.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mixed-stress.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/present-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/render-composite-solid-mask.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/render-composite-solid.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/render-copy-alphaless.Po@am__quote@ @@ -652,6 +744,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/render-fill.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/render-trapezoid-image.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/render-trapezoid.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shm-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_display.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_image.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_log.Plo@am__quote@ diff --git a/driver/xf86-video-intel/test/README b/driver/xf86-video-intel/test/README index 72b445084..1bb3d7df2 100644 --- a/driver/xf86-video-intel/test/README +++ b/driver/xf86-video-intel/test/README @@ -1,3 +1,11 @@ These are no substitute for xts, rendercheck and cairo-test-suite. They are intended to exercise corner cases in the batch management of long drawing commands and more explicit checking of the acceleration paths. + +Useful tools: + +# Packed YUV Xv tester +gst-launch-1.0 videotestsrc pattern=snow ! 'video/x-raw,format=UYVY,width=640,height=360' ! xvimagesink + +# Planar YUV Xv tester +gst-launch-1.0 videotestsrc pattern=snow ! 'video/x-raw,format=I420,width=640,height=360' ! xvimagesink diff --git a/driver/xf86-video-intel/test/basic-copyarea-size.c b/driver/xf86-video-intel/test/basic-copyarea-size.c index 5e3373d9e..b8e9ed031 100644 --- a/driver/xf86-video-intel/test/basic-copyarea-size.c +++ b/driver/xf86-video-intel/test/basic-copyarea-size.c @@ -45,14 +45,14 @@ static void target_fini(struct test_display *t, struct draw *tt) int main(int argc, char **argv) { struct test test; - struct draw real, ref; + struct draw out, ref; int size, i; test_init(&test, argc, argv); /* Copy back and forth betwenn two pixmaps, gradually getting larger */ for (size = 1; size <= SIZE; size = (size * 3 + 1) / 2) { - target_init(&test.real, &real, size); + target_init(&test.out, &out, size); target_init(&test.ref, &ref, size); printf("size=%d\n", size); @@ -67,10 +67,10 @@ int main(int argc, char **argv) int order = rand() & 1; - XCopyArea(test.real.dpy, - order ? real.a : real.b, - (!order) ? real.a : real.b, - real.gc, + XCopyArea(test.out.dpy, + order ? out.a : out.b, + (!order) ? out.a : out.b, + out.gc, sx, sy, size, size, dx, dy); @@ -86,17 +86,17 @@ int main(int argc, char **argv) } test_compare(&test, - real.a, real.format, + out.a, out.format, ref.a, ref.format, 0, 0, size, size, ""); test_compare(&test, - real.b, real.format, + out.b, out.format, ref.b, ref.format, 0, 0, size, size, ""); - target_fini(&test.real, &real); + target_fini(&test.out, &out); target_fini(&test.ref, &ref); } diff --git a/driver/xf86-video-intel/test/basic-copyarea.c b/driver/xf86-video-intel/test/basic-copyarea.c index d4ae0d173..a1ef34913 100644 --- a/driver/xf86-video-intel/test/basic-copyarea.c +++ b/driver/xf86-video-intel/test/basic-copyarea.c @@ -9,7 +9,7 @@ static void show_cells(char *buf, - const uint32_t *real, const uint32_t *ref, + const uint32_t *out, const uint32_t *ref, int x, int y, int w, int h) { int i, j, len = 0; @@ -22,7 +22,7 @@ show_cells(char *buf, if (i < 0 || i >= w) continue; - len += sprintf(buf+len, "%08x ", real[j*w+i]); + len += sprintf(buf+len, "%08x ", out[j*w+i]); } len += sprintf(buf+len, "\t"); @@ -85,13 +85,13 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); int r, s; - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); printf("Testing setting of single pixels (%s): ", test_target_name(target)); @@ -103,7 +103,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) int y = rand() % (tt.height - 1); uint32_t fg = rand(); - fill_rect(&t->real, tt.draw, tt.format, + fill_rect(&t->out, tt.draw, tt.format, 0, 0, 0, GXcopy, x, y, 1, 1, fg); @@ -112,14 +112,14 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) cells[y*tt.width+x] = fg; } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; uint32_t result; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -138,7 +138,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); } @@ -154,16 +154,16 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -174,7 +174,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) x = rand() % (2*tt.width) - tt.width; y = rand() % (2*tt.height) - tt.height; - fill_rect(&t->real, tt.draw, tt.format, + fill_rect(&t->out, tt.draw, tt.format, 0, 0, 0, GXcopy, x, y, w, h, fg); @@ -195,7 +195,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) pixman_fill(cells, tt.width, 32, x, y, w, h, fg); } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -223,37 +223,37 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } static void rect_tests(struct test *t, int reps, int sets, enum target target, int use_window) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s, using %s source): ", test_target_name(target), use_window ? "window" : "pixmap"); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (real.width - 1); - int y = rand() % (real.height - 1); - int w = 1 + rand() % (real.width - x - 1); - int h = 1 + rand() % (real.height - y - 1); - int tmpx = w == real.width ? 0 : rand() % (real.width - w); - int tmpy = h == real.height ? 0 : rand() % (real.height - h); + int x = rand() % (out.width - 1); + int y = rand() % (out.height - 1); + int w = 1 + rand() % (out.width - x - 1); + int h = 1 + rand() % (out.height - y - 1); + int tmpx = w == out.width ? 0 : rand() % (out.width - w); + int tmpy = h == out.height ? 0 : rand() % (out.height - h); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); - fill_rect(&t->real, real.draw, real.format, + fill_rect(&t->out, out.draw, out.format, use_window, tmpx, tmpy, alu, x, y, w, h, fg); fill_rect(&t->ref, ref.draw, ref.format, @@ -262,15 +262,15 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target, i } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/basic-fillrect.c b/driver/xf86-video-intel/test/basic-fillrect.c index a2aeec8fd..80c219c7b 100644 --- a/driver/xf86-video-intel/test/basic-fillrect.c +++ b/driver/xf86-video-intel/test/basic-fillrect.c @@ -9,7 +9,7 @@ static void show_cells(char *buf, - const uint32_t *real, const uint32_t *ref, + const uint32_t *out, const uint32_t *ref, int x, int y, int w, int h) { int i, j, len = 0; @@ -22,7 +22,7 @@ show_cells(char *buf, if (i < 0 || i >= w) continue; - len += sprintf(buf+len, "%08x ", real[j*w+i]); + len += sprintf(buf+len, "%08x ", out[j*w+i]); } len += sprintf(buf+len, "\t"); @@ -56,13 +56,13 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); int r, s; - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); printf("Testing setting of single pixels (%s): ", test_target_name(target)); @@ -74,7 +74,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) int y = rand() % (tt.height - 1); uint32_t fg = rand(); - fill_rect(&t->real, tt.draw, GXcopy, + fill_rect(&t->out, tt.draw, GXcopy, x, y, 1, 1, fg); pixels[r].x = x; @@ -82,14 +82,14 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) cells[y*tt.width+x] = fg; } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; uint32_t result; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -108,7 +108,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); } @@ -124,16 +124,16 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -144,7 +144,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) x = rand() % (2*tt.width) - tt.width; y = rand() % (2*tt.height) - tt.height; - fill_rect(&t->real, tt.draw, GXcopy, + fill_rect(&t->out, tt.draw, GXcopy, x, y, w, h, fg); if (x < 0) @@ -164,7 +164,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) pixman_fill(cells, tt.width, 32, x, y, w, h, fg); } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -192,49 +192,49 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } static void rect_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % (2*real.width); - int h = rand() % (2*real.height); + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % (2*out.width); + int h = rand() % (2*out.height); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); - fill_rect(&t->real, real.draw, alu, + fill_rect(&t->out, out.draw, alu, x, y, w, h, fg); fill_rect(&t->ref, ref.draw, alu, x, y, w, h, fg); } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/basic-lines.c b/driver/xf86-video-intel/test/basic-lines.c index b710b2484..1935cb240 100644 --- a/driver/xf86-video-intel/test/basic-lines.c +++ b/driver/xf86-video-intel/test/basic-lines.c @@ -85,14 +85,14 @@ static void draw_line(struct test_display *dpy, struct test_target *tt, static void line_tests(struct test *t, enum target target) { char buf[1024]; - struct test_target real, ref; + struct test_target out, ref; int a, b, alu, lw, style, cap; printf("Testing drawing of single line segments (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); + test_target_create_render(&t->out, target, &out); test_target_create_render(&t->ref, target, &ref); style = LineSolid; @@ -108,18 +108,18 @@ static void line_tests(struct test *t, enum target target) points[b].x, points[b].y, lw, cap, alu); - clear(&t->real, &real); + clear(&t->out, &out); clear(&t->ref, &ref); - draw_line(&t->real, &real, alu, lw, style, cap, + draw_line(&t->out, &out, alu, lw, style, cap, &points[a], &points[b], 64, 64); draw_line(&t->ref, &ref, alu, lw, style, cap, &points[a], &points[b], 64, 64); test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, buf); } } @@ -127,7 +127,7 @@ static void line_tests(struct test *t, enum target target) } } - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); printf("\n"); diff --git a/driver/xf86-video-intel/test/basic-putimage.c b/driver/xf86-video-intel/test/basic-putimage.c index d57041775..e252fe3fe 100644 --- a/driver/xf86-video-intel/test/basic-putimage.c +++ b/driver/xf86-video-intel/test/basic-putimage.c @@ -9,7 +9,7 @@ static void show_cells(char *buf, - const uint32_t *real, const uint32_t *ref, + const uint32_t *out, const uint32_t *ref, int x, int y, int w, int h) { int i, j, len = 0; @@ -22,7 +22,7 @@ show_cells(char *buf, if (i < 0 || i >= w) continue; - len += sprintf(buf+len, "%08x ", real[j*w+i]); + len += sprintf(buf+len, "%08x ", out[j*w+i]); } len += sprintf(buf+len, "\t"); @@ -69,13 +69,13 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target, { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); int r, s; - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); printf("Testing setting of single pixels (%s %s shm): ", test_target_name(target), use_shm ? "with" : "without" ); @@ -91,7 +91,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target, int alpha = rand() % 0xff; uint32_t fg = color(red, green, blue, alpha); - fill_rect(&t->real, tt.draw, tt.format, use_shm, + fill_rect(&t->out, tt.draw, tt.format, use_shm, GXcopy, x, y, 1, 1, fg); pixels[r].x = x; @@ -99,14 +99,14 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target, cells[y*tt.width+x] = fg; } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t result; uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -128,7 +128,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target, } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); } @@ -144,17 +144,17 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s %s shm): ", test_target_name(target), use_shm ? "with" : "without" ); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -170,13 +170,13 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i w = rand() % (tt.width - x); h = rand() % (tt.height - y); - fill_rect(&t->real, tt.draw, tt.format, use_shm, + fill_rect(&t->out, tt.draw, tt.format, use_shm, GXcopy, x, y, w, h, fg); pixman_fill(cells, tt.width, 32, x, y, w, h, fg); } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -205,30 +205,30 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } static void rect_tests(struct test *t, int reps, int sets, enum target target, int use_shm) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % real.width; - int y = rand() % real.height; - int w = rand() % (real.width - x); - int h = rand() % (real.height - y); + int x = rand() % out.width; + int y = rand() % out.height; + int w = rand() % (out.width - x); + int h = rand() % (out.height - y); uint8_t alu = rand() % (GXset + 1); int red = rand() % 0xff; int green = rand() % 0xff; @@ -236,22 +236,22 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target, i int alpha = rand() % 0xff; uint8_t fg = color(red, green, blue, alpha); - fill_rect(&t->real, real.draw, real.format, use_shm, + fill_rect(&t->out, out.draw, out.format, use_shm, alu, x, y, w, h, fg); fill_rect(&t->ref, ref.draw, ref.format, use_shm, alu, x, y, w, h, fg); } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } int main(int argc, char **argv) diff --git a/driver/xf86-video-intel/test/basic-rectangle.c b/driver/xf86-video-intel/test/basic-rectangle.c index 8de200c16..5cdbcd1d4 100644 --- a/driver/xf86-video-intel/test/basic-rectangle.c +++ b/driver/xf86-video-intel/test/basic-rectangle.c @@ -30,169 +30,169 @@ static void clear(struct test_display *dpy, struct test_target *tt) static void zrect_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing empty rects (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t lw = rand() % 4; - draw_rect(&t->real, real.draw, alu, + draw_rect(&t->out, out.draw, alu, x, y, 0, 0, fg, lw); draw_rect(&t->ref, ref.draw, alu, x, y, 0, 0, fg, lw); } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void hrect_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing horizontal rects (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % (2*real.width); + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % (2*out.width); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t lw = rand() % 4; - draw_rect(&t->real, real.draw, alu, + draw_rect(&t->out, out.draw, alu, x, y, w, 0, fg, lw); draw_rect(&t->ref, ref.draw, alu, x, y, w, 0, fg, lw); } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void vrect_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing vertical rects (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int h = rand() % (2*real.width); + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int h = rand() % (2*out.width); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t lw = rand() % 4; - draw_rect(&t->real, real.draw, alu, + draw_rect(&t->out, out.draw, alu, x, y, 0, h, fg, lw); draw_rect(&t->ref, ref.draw, alu, x, y, 0, h, fg, lw); } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void rect_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing general (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % (2*real.width); - int h = rand() % (2*real.height); + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % (2*out.width); + int h = rand() % (2*out.height); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t lw = rand() % 4; - draw_rect(&t->real, real.draw, alu, + draw_rect(&t->out, out.draw, alu, x, y, w, h, fg, lw); draw_rect(&t->ref, ref.draw, alu, x, y, w, h, fg, lw); } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/basic-stippledrect.c b/driver/xf86-video-intel/test/basic-stippledrect.c index 8a89efdd6..03861e21d 100644 --- a/driver/xf86-video-intel/test/basic-stippledrect.c +++ b/driver/xf86-video-intel/test/basic-stippledrect.c @@ -54,33 +54,33 @@ static void clear(struct test_target *tt) static void unclipped_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing unclipped stippled fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&real); + test_target_create_render(&t->out, target, &out); + clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % real.width; - int y = rand() % real.height; - int w = rand() % (real.width - x); - int h = rand() % (real.height - y); - int tx = rand() % (2*real.width) - real.width; - int ty = rand() % (2*real.height) - real.height; + int x = rand() % out.width; + int y = rand() % out.height; + int w = rand() % (out.width - x); + int h = rand() % (out.height - y); + int tx = rand() % (2*out.width) - out.width; + int ty = rand() % (2*out.height) - out.height; uint8_t stipple = rand() % 4; uint8_t opaque = rand() % 1; uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); - fill_rect(&real, alu, NULL, 0, + fill_rect(&out, alu, NULL, 0, stipple, opaque, tx, ty, x, y, w, h, fg, bg); @@ -91,47 +91,47 @@ static void unclipped_tests(struct test *t, int reps, int sets, enum target targ } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void simple_clip_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing simple clipped stippled fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&real); + test_target_create_render(&t->out, target, &out); + clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % (2*real.width); - int h = rand() % (2*real.height); - int tx = rand() % (2*real.width) - real.width; - int ty = rand() % (2*real.height) - real.height; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % (2*out.width); + int h = rand() % (2*out.height); + int tx = rand() % (2*out.width) - out.width; + int ty = rand() % (2*out.height) - out.height; uint8_t stipple = rand() % 4; uint8_t opaque = rand() % 1; uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); - fill_rect(&real, alu, NULL, 0, + fill_rect(&out, alu, NULL, 0, stipple, opaque, tx, ty, x, y, w, h, fg, bg); @@ -142,29 +142,29 @@ static void simple_clip_tests(struct test *t, int reps, int sets, enum target ta } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void complex_clip_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; XRectangle *clip; int nclip, r, s; printf("Testing complex clipped stippled fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&real); + test_target_create_render(&t->out, target, &out); + clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); @@ -173,26 +173,26 @@ static void complex_clip_tests(struct test *t, int reps, int sets, enum target t nclip = (rand() % 16) + 2; clip = malloc(sizeof(XRectangle)*nclip); for (r = 0; r < nclip; r++) { - clip[r].x = rand() % real.width; - clip[r].y = rand() % real.height; - clip[r].width = rand() % (real.width - clip[r].x); - clip[r].height = rand() % (real.height - clip[r].y); + clip[r].x = rand() % out.width; + clip[r].y = rand() % out.height; + clip[r].width = rand() % (out.width - clip[r].x); + clip[r].height = rand() % (out.height - clip[r].y); } for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % (2*real.width); - int h = rand() % (2*real.height); - int tx = rand() % (2*real.width) - real.width; - int ty = rand() % (2*real.height) - real.height; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % (2*out.width); + int h = rand() % (2*out.height); + int tx = rand() % (2*out.width) - out.width; + int ty = rand() % (2*out.height) - out.height; uint8_t stipple = rand() % 4; uint8_t opaque = rand() % 1; uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); - fill_rect(&real, alu, clip, nclip, + fill_rect(&out, alu, clip, nclip, stipple, opaque, tx, ty, x, y, w, h, fg, bg); @@ -203,9 +203,9 @@ static void complex_clip_tests(struct test *t, int reps, int sets, enum target t } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); free(clip); @@ -213,7 +213,7 @@ static void complex_clip_tests(struct test *t, int reps, int sets, enum target t printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/basic-stress.c b/driver/xf86-video-intel/test/basic-stress.c index 4b42865cd..94fcc3e35 100644 --- a/driver/xf86-video-intel/test/basic-stress.c +++ b/driver/xf86-video-intel/test/basic-stress.c @@ -27,36 +27,36 @@ static void clear(struct test_target *tt) 0, 0, tt->width, tt->height); } -static void fill(struct test_target *real, +static void fill(struct test_target *out, struct test_target *ref) { - int x = rand() % (2*real->width) - real->width; - int y = rand() % (2*real->height) - real->height; - int w = rand() % (2*real->width); - int h = rand() % (2*real->height); + int x = rand() % (2*out->width) - out->width; + int y = rand() % (2*out->height) - out->height; + int w = rand() % (2*out->width); + int h = rand() % (2*out->height); int color = rand(); int alu = rand() % 16; - fill_rect(real, alu, color, x, y, w, h); + fill_rect(out, alu, color, x, y, w, h); fill_rect(ref, alu, color, x, y, w, h); } -static void copy(struct test_target *real, +static void copy(struct test_target *out, struct test_target *ref) { - int sx = rand() % (2*real->width) - ref->width; - int sy = rand() % (2*real->height) - ref->height; - int dx = rand() % (2*real->width) - ref->width; - int dy = rand() % (2*real->height) - ref->height; - int w = rand() % (2*real->width); - int h = rand() % (2*real->height); + int sx = rand() % (2*out->width) - ref->width; + int sy = rand() % (2*out->height) - ref->height; + int dx = rand() % (2*out->width) - ref->width; + int dy = rand() % (2*out->height) - ref->height; + int w = rand() % (2*out->width); + int h = rand() % (2*out->height); XGCValues val; val.function = rand() % 16; - XChangeGC(real->dpy->dpy, real->gc, GCFunction, &val); - XCopyArea(real->dpy->dpy, - real->draw, real->draw, real->gc, + XChangeGC(out->dpy->dpy, out->gc, GCFunction, &val); + XCopyArea(out->dpy->dpy, + out->draw, out->draw, out->gc, sx, sy, w, h, dx, dy); XChangeGC(ref->dpy->dpy, ref->gc, GCFunction, &val); @@ -90,23 +90,23 @@ static void _put(struct test_target *tt, } } -static void put(struct test_target *real, +static void put(struct test_target *out, struct test_target *ref) { - int x = rand() % (2*real->width) - real->width; - int y = rand() % (2*real->height) - real->height; - int w = rand() % real->width; - int h = rand() % real->height; + int x = rand() % (2*out->width) - out->width; + int y = rand() % (2*out->height) - out->height; + int w = rand() % out->width; + int h = rand() % out->height; int color = rand(); int alu = rand() % 16; - _put(real, x, y, w, h, color, alu); + _put(out, x, y, w, h, color, alu); _put(ref, x, y, w, h, color, alu); } static void rect_tests(struct test *test, int iterations, enum target target) { - struct test_target real, ref; + struct test_target out, ref; void (* const ops[])(struct test_target *, struct test_target *) = { copy, fill, @@ -118,24 +118,24 @@ static void rect_tests(struct test *test, int iterations, enum target target) test_target_name(target)); fflush(stdout); - test_target_create_render(&test->real, target, &real); + test_target_create_render(&test->out, target, &out); test_target_create_render(&test->ref, target, &ref); - clear(&real); + clear(&out); clear(&ref); for (n = 0; n < iterations; n++) - ops[rand() % ARRAY_SIZE(ops)](&real, &ref); + ops[rand() % ARRAY_SIZE(ops)](&out, &ref); test_compare(test, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); printf("passed [%d iterations]\n", n); - test_target_destroy_render(&test->real, &real); + test_target_destroy_render(&test->out, &out); test_target_destroy_render(&test->ref, &ref); } diff --git a/driver/xf86-video-intel/test/basic-string.c b/driver/xf86-video-intel/test/basic-string.c index 1e24b2912..4e1dbce99 100644 --- a/driver/xf86-video-intel/test/basic-string.c +++ b/driver/xf86-video-intel/test/basic-string.c @@ -39,42 +39,42 @@ static void clear(struct test_display *dpy, struct test_target *tt) static void string_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing general (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); int str = rand(); int fill = rand() & 1; - draw_string(&t->real, real.draw, alu, x, y, fg, bg, str, fill); + draw_string(&t->out, out.draw, alu, x, y, fg, bg, str, fill); draw_string(&t->ref, ref.draw, alu, x, y, fg, bg, str, fill); } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/basic-tiledrect.c b/driver/xf86-video-intel/test/basic-tiledrect.c index 1596c4c13..9af86a9f9 100644 --- a/driver/xf86-video-intel/test/basic-tiledrect.c +++ b/driver/xf86-video-intel/test/basic-tiledrect.c @@ -4,16 +4,61 @@ #include "test.h" -static unsigned char bitmap4x4[] = { - 0x03, 0x06, 0x0c, 0x09 +static const unsigned char data[] = { + 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, + 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, + 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, + 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, }; -static unsigned char bitmap8x8[3][8] = { - { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, - { 0x00, 0xfe, 0x92, 0x92, 0xfe, 0x92, 0x92, 0xfe }, - { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }, +static struct bitmap { + int width, height; + struct cache { + Display *dpy; + Pixmap pixmap; + } cached[2]; +} bitmaps[] = { + { 1, 1, }, + { 1, 2, }, + { 2, 3, }, + { 3, 2, }, + { 4, 4, }, + { 6, 6, }, + { 8, 8, }, + { 8, 4, }, + { 8, 2, }, + { 8, 1, }, + { 4, 8, }, + { 2, 8, }, + { 1, 8, }, + { 16, 16, }, + { 15, 17, }, + { 24, 24, }, + { 32, 32, }, + { 16, 8, }, + { 16, 4, }, + { 16, 2, }, + { 16, 1, }, + { 8, 16, }, + { 4, 16, }, + { 2, 16, }, + { 1, 16, }, }; +static void reset_cache(void) +{ + int n, m; + + for (n = 0; n < sizeof(bitmaps)/sizeof(bitmaps[0]); n++) { + for (m = 0; m < 2; m++) { + if (bitmaps[n].cached[m].dpy) { + XFreePixmap(bitmaps[n].cached[m].dpy, bitmaps[n].cached[m].pixmap); + bitmaps[n].cached[m].dpy = NULL; + } + } + } +} + static void fill_rect(struct test_target *t, uint8_t alu, XRectangle *clip, int nclip, uint8_t tile, int tx, int ty, @@ -21,28 +66,48 @@ static void fill_rect(struct test_target *t, uint8_t alu, uint32_t fg, uint32_t bg) { Display *dpy = t->dpy->dpy; + struct bitmap *b = &bitmaps[(tile >> 1) % (sizeof(bitmaps)/sizeof(bitmaps[0]))]; XGCValues val; GC gc; + int n; val.function = alu; + val.function = GXcopy; val.fill_style = FillTiled; val.ts_x_origin = tx; val.ts_y_origin = ty; - if (tile == 0) { - val.tile = XCreatePixmapFromBitmapData(dpy, t->draw, (char *)bitmap4x4, 4, 4, - fg, bg, t->depth); - } else { - char *b = (char *)bitmap8x8[tile-1]; - val.tile = XCreatePixmapFromBitmapData(dpy, t->draw, b, 8, 8, + if (tile & 1) { + val.tile = 0; + for (n = 0; n < 2; n++) { + if (b->cached[n].dpy == dpy) { + val.tile = b->cached[n].pixmap; + break; + } + } + if (val.tile == 0) { + val.tile = XCreatePixmapFromBitmapData(dpy, t->draw, + (char *)data, b->width, b->height, + fg, bg, t->depth); + for (n = 0; n < 2; n++) { + if (b->cached[n].dpy == NULL) { + b->cached[n].dpy = dpy; + b->cached[n].pixmap = val.tile; + break; + } + } + } + } else + val.tile = XCreatePixmapFromBitmapData(dpy, t->draw, + (char *)data, b->width, b->height, fg, bg, t->depth); - } gc = XCreateGC(dpy, t->draw, GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin | GCTile | GCFunction, &val); if (nclip) XSetClipRectangles(dpy, gc, 0, 0, clip, nclip, Unsorted); XFillRectangle(dpy, t->draw, gc, x, y, w, h); XFreeGC(dpy, gc); - XFreePixmap(dpy, val.tile); + if ((tile & 1) == 0) + XFreePixmap(dpy, val.tile); } static void clear(struct test_target *tt) @@ -52,34 +117,107 @@ static void clear(struct test_target *tt) 0, 0, tt->width, tt->height); } +static void small_tests(struct test *t, int reps, int sets, enum target target) +{ + struct test_target out, ref; + int r, s; + + printf("Testing small tiled fills (%s): ", test_target_name(target)); + fflush(stdout); + + test_target_create_render(&t->out, target, &out); + clear(&out); + + test_target_create_render(&t->ref, target, &ref); + clear(&ref); + + for (s = 0; s < sets; s++) { + for (r = 0; r < reps; r++) { + int x = rand() % out.width; + int y = rand() % out.height; + int w = rand() % out.width; + int h = rand() % 8; + int tx = rand() % (2*out.width) - out.width; + int ty = rand() % (2*out.height) - out.height; + uint8_t tile = rand(); + uint8_t alu = rand() % (GXset + 1); + uint32_t fg = rand(); + uint32_t bg = rand(); + + fill_rect(&out, alu, NULL, 0, + tile, tx, ty, + x, y, w, h, + fg, bg); + fill_rect(&ref, alu, NULL, 0, + tile, tx, ty, + x, y, w, h, + fg, bg); + + fill_rect(&out, alu, NULL, 0, + tile, tx, ty, + x, y, h, w, + fg, bg); + fill_rect(&ref, alu, NULL, 0, + tile, tx, ty, + x, y, h, w, + fg, bg); + } + + test_compare(t, + out.draw, out.format, + ref.draw, ref.format, + 0, 0, out.width, out.height, + ""); + + if (target == CHILD) { + int x = rand() % (t->out.width-out.width); + int y = rand() % (t->out.height-out.height); + + clear(&out); + clear(&ref); + + XMoveWindow(out.dpy->dpy, out.draw, x, y); + XMoveWindow(ref.dpy->dpy, ref.draw, x, y); + + clear(&out); + clear(&ref); + } + } + + printf("passed [%d iterations x %d]\n", reps, sets); + + test_target_destroy_render(&t->out, &out); + test_target_destroy_render(&t->ref, &ref); +} + static void unclipped_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing unclipped tiled fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&real); + test_target_create_render(&t->out, target, &out); + clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % real.width; - int y = rand() % real.height; - int w = rand() % (real.width - x); - int h = rand() % (real.height - y); - int tx = rand() % (2*real.width) - real.width; - int ty = rand() % (2*real.height) - real.height; - uint8_t tile = rand() % 4; + int x = rand() % out.width; + int y = rand() % out.height; + int w = rand() % (out.width - x); + int h = rand() % (out.height - y); + int tx = rand() % (2*out.width) - out.width; + int ty = rand() % (2*out.height) - out.height; + uint8_t tile = rand(); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); - fill_rect(&real, alu, NULL, 0, + fill_rect(&out, alu, NULL, 0, tile, tx, ty, x, y, w, h, fg, bg); @@ -90,46 +228,60 @@ static void unclipped_tests(struct test *t, int reps, int sets, enum target targ } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); + + if (target == CHILD) { + int x = rand() % (t->out.width-out.width); + int y = rand() % (t->out.height-out.height); + + clear(&out); + clear(&ref); + + XMoveWindow(out.dpy->dpy, out.draw, x, y); + XMoveWindow(ref.dpy->dpy, ref.draw, x, y); + + clear(&out); + clear(&ref); + } } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void simple_clip_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing simple clipped tiled fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&real); + test_target_create_render(&t->out, target, &out); + clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % (2*real.width); - int h = rand() % (2*real.height); - int tx = rand() % (2*real.width) - real.width; - int ty = rand() % (2*real.height) - real.height; - uint8_t tile = rand() % 4; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % (2*out.width); + int h = rand() % (2*out.height); + int tx = rand() % (2*out.width) - out.width; + int ty = rand() % (2*out.height) - out.height; + uint8_t tile = rand(); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); - fill_rect(&real, alu, NULL, 0, + fill_rect(&out, alu, NULL, 0, tile, tx, ty, x, y, w, h, fg, bg); @@ -140,29 +292,43 @@ static void simple_clip_tests(struct test *t, int reps, int sets, enum target ta } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); + + if (target == CHILD) { + int x = rand() % (t->out.width-out.width); + int y = rand() % (t->out.height-out.height); + + clear(&out); + clear(&ref); + + XMoveWindow(out.dpy->dpy, out.draw, x, y); + XMoveWindow(ref.dpy->dpy, ref.draw, x, y); + + clear(&out); + clear(&ref); + } } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void complex_clip_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; XRectangle *clip; int nclip, r, s; printf("Testing complex clipped tiled fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&real); + test_target_create_render(&t->out, target, &out); + clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); @@ -171,25 +337,25 @@ static void complex_clip_tests(struct test *t, int reps, int sets, enum target t nclip = (rand() % 16) + 2; clip = malloc(sizeof(XRectangle)*nclip); for (r = 0; r < nclip; r++) { - clip[r].x = rand() % real.width; - clip[r].y = rand() % real.height; - clip[r].width = rand() % (real.width - clip[r].x); - clip[r].height = rand() % (real.height - clip[r].y); + clip[r].x = rand() % out.width; + clip[r].y = rand() % out.height; + clip[r].width = rand() % (out.width - clip[r].x); + clip[r].height = rand() % (out.height - clip[r].y); } for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % (2*real.width); - int h = rand() % (2*real.height); - int tx = rand() % (2*real.width) - real.width; - int ty = rand() % (2*real.height) - real.height; - uint8_t tile = rand() % 4; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % (2*out.width); + int h = rand() % (2*out.height); + int tx = rand() % (2*out.width) - out.width; + int ty = rand() % (2*out.height) - out.height; + uint8_t tile = rand(); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); - fill_rect(&real, alu, clip, nclip, + fill_rect(&out, alu, clip, nclip, tile, tx, ty, x, y, w, h, fg, bg); @@ -200,17 +366,31 @@ static void complex_clip_tests(struct test *t, int reps, int sets, enum target t } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); free(clip); + + if (target == CHILD) { + int x = rand() % (t->out.width-out.width); + int y = rand() % (t->out.height-out.height); + + clear(&out); + clear(&ref); + + XMoveWindow(out.dpy->dpy, out.draw, x, y); + XMoveWindow(ref.dpy->dpy, ref.draw, x, y); + + clear(&out); + clear(&ref); + } } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } @@ -226,9 +406,11 @@ int main(int argc, char **argv) enum target t; for (t = TARGET_FIRST; t <= TARGET_LAST; t++) { + small_tests(&test, reps, sets, t); unclipped_tests(&test, reps, sets, t); simple_clip_tests(&test, reps, sets, t); complex_clip_tests(&test, reps, sets, t); + reset_cache(); } } diff --git a/driver/xf86-video-intel/test/cursor-test.c b/driver/xf86-video-intel/test/cursor-test.c new file mode 100644 index 000000000..9259049fb --- /dev/null +++ b/driver/xf86-video-intel/test/cursor-test.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <cairo.h> +#include <cairo-xlib.h> +#include <cairo-xlib-xrender.h> +#include <X11/Xlib.h> +#include <X11/extensions/Xrender.h> + +#include <string.h> + +static void core_cursor(Display *dpy, int width, int height) +{ + char text[256]; + cairo_surface_t *surface; + cairo_text_extents_t extents; + cairo_t *cr; + Pixmap bitmap; + int scr = DefaultScreen(dpy); + Window root = RootWindow(dpy, scr); + XColor bg, fg; + int pitch; + char *data; + GC gc; + + sprintf(text, "%dx%d", width, height); + + pitch = (width + 31) >> 5 << 2; + data = calloc(pitch, height); + + surface = cairo_image_surface_create_for_data((unsigned char *)data, CAIRO_FORMAT_A1, width, height, pitch); + cr = cairo_create(surface); + cairo_text_extents(cr, text, &extents); + cairo_move_to(cr, 0, extents.height); + cairo_show_text(cr, text); + cairo_destroy(cr); + cairo_surface_destroy(surface); + + bitmap = XCreatePixmap(dpy, root, width, height, 1); + gc = XCreateGC(dpy, bitmap, 0, NULL); + if (gc != NULL) { + XImage ximage = { + .height = height, + .width = width, + .depth = 1, + .bits_per_pixel = 1, + .xoffset = 0, + .format = XYPixmap, + .data = data, + .byte_order = LSBFirst, + .bitmap_unit = 32, + .bitmap_bit_order = LSBFirst, + .bitmap_pad = 32, + .bytes_per_line = pitch, + }; + XPutImage(dpy, bitmap, gc, &ximage, 0, 0, 0, 0, width, height); + XFreeGC(dpy, gc); + } + free(data); + + XParseColor(dpy, DefaultColormap(dpy, scr), "green", &fg); + XParseColor(dpy, DefaultColormap(dpy, scr), "black", &bg); + + XDefineCursor(dpy, root, XCreatePixmapCursor(dpy, bitmap, bitmap, &fg, &bg, 0, 0)); + XFreePixmap(dpy, bitmap); +} + +static void render_cursor(Display *dpy, int width, int height) +{ + char text[256]; + cairo_surface_t *surface; + cairo_text_extents_t extents; + cairo_t *cr; + Pixmap pixmap; + Picture picture; + + sprintf(text, "%dx%d", width, height); + + pixmap = XCreatePixmap(dpy, DefaultRootWindow(dpy), width, height, 32); + surface = cairo_xlib_surface_create_with_xrender_format(dpy, pixmap, + DefaultScreenOfDisplay(dpy), + XRenderFindStandardFormat(dpy, PictStandardARGB32), + width, height); + cr = cairo_create(surface); + cairo_surface_destroy(surface); + + cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); + cairo_paint(cr); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + + cairo_text_extents(cr, text, &extents); + cairo_move_to(cr, 0, extents.height); + cairo_set_source_rgb(cr, 1, 0, 1); + cairo_show_text(cr, text); + cairo_destroy(cr); + + picture = XRenderCreatePicture(dpy, pixmap, XRenderFindStandardFormat(dpy, PictStandardARGB32), 0, NULL); + XFreePixmap(dpy, pixmap); + + XDefineCursor(dpy, DefaultRootWindow(dpy), XRenderCreateCursor(dpy, picture, 0, 0)); + XRenderFreePicture(dpy, picture); +} + +int main(void) +{ + Display *dpy; + int sizes[] = { 24, 32, 48, 64, 72, 128, 160, 256 }; + int x, y; + + dpy = XOpenDisplay(NULL); + if (dpy == NULL) + dpy = XOpenDisplay(":0"); /* lazy */ + if (dpy == NULL) + return 77; + + for (x = 0; x < sizeof(sizes)/sizeof(sizes[0]); x++) { + for (y = 0; y < sizeof(sizes)/sizeof(sizes[0]); y++) { + printf("Testing %dx%d (core)\n", sizes[x], sizes[y]); + core_cursor(dpy, sizes[x], sizes[y]); + XSync(dpy, True); + sleep(2); + + printf("Testing %dx%d (render)\n", sizes[x], sizes[y]); + render_cursor(dpy, sizes[x], sizes[y]); + XSync(dpy, True); + sleep(2); + } + } + + return 0; +} diff --git a/driver/xf86-video-intel/test/dri2-race.c b/driver/xf86-video-intel/test/dri2-race.c index 01b023a1b..8862c84ca 100644 --- a/driver/xf86-video-intel/test/dri2-race.c +++ b/driver/xf86-video-intel/test/dri2-race.c @@ -28,7 +28,7 @@ static int dri2_open(Display *dpy) printf ("Connecting to %s driver on %s\n", driver, device); - fd = open("/dev/dri/card0", O_RDWR); + fd = open(device, O_RDWR); if (fd < 0) return -1; diff --git a/driver/xf86-video-intel/test/dri2-swap.c b/driver/xf86-video-intel/test/dri2-swap.c index ba6b23736..1bfb7d10f 100644 --- a/driver/xf86-video-intel/test/dri2-swap.c +++ b/driver/xf86-video-intel/test/dri2-swap.c @@ -28,7 +28,7 @@ static int dri2_open(Display *dpy) printf ("Connecting to %s driver on %s\n", driver, device); - fd = open("/dev/dri/card0", O_RDWR); + fd = open(device, O_RDWR); if (fd < 0) return -1; diff --git a/driver/xf86-video-intel/test/dri2-test.c b/driver/xf86-video-intel/test/dri2-test.c index f712f125f..dd4179f33 100644 --- a/driver/xf86-video-intel/test/dri2-test.c +++ b/driver/xf86-video-intel/test/dri2-test.c @@ -52,7 +52,7 @@ static int dri2_open(Display *dpy) printf ("Connecting to %s driver on %s\n", driver, device); - fd = open("/dev/dri/card0", O_RDWR); + fd = open(device, O_RDWR); if (fd < 0) return -1; @@ -83,15 +83,6 @@ static void dri2_copy_swap(Display *dpy, Drawable d, XFixesDestroyRegion(dpy, region); } -static void xsync(Display *dpy, Window win) -{ - XImage *image; - - image = XGetImage(dpy, win, 0, 0, 1, 1, ~0, ZPixmap); - if (image) - XDestroyImage(image); -} - static double elapsed(const struct timespec *start, const struct timespec *end) { @@ -99,6 +90,17 @@ static double elapsed(const struct timespec *start, 1e-9*(end->tv_nsec - start->tv_nsec); } +static uint64_t check_msc(Display *dpy, Window win, uint64_t last_msc) +{ + uint64_t current_msc, current_ust, current_sbc; + DRI2GetMSC(dpy, win, ¤t_ust, ¤t_msc, ¤t_sbc); + if (current_msc < last_msc) { + printf("Invalid MSC: was %llu, now %llu\n", + (long long)last_msc, (long long)current_msc); + } + return current_msc; +} + static void run(Display *dpy, int width, int height, unsigned int *attachments, int nattachments, const char *name) @@ -108,6 +110,7 @@ static void run(Display *dpy, int width, int height, int count; DRI2Buffer *buffers; struct timespec start, end; + uint64_t msc; /* Be nasty and install a fullscreen window on top so that we * can guarantee we do not get clipped by children. @@ -120,29 +123,29 @@ static void run(Display *dpy, int width, int height, DefaultVisual(dpy, DefaultScreen(dpy)), CWOverrideRedirect, &attr); XMapWindow(dpy, win); - xsync(dpy, win); DRI2CreateDrawable(dpy, win); + msc = check_msc(dpy, win, 0); buffers = DRI2GetBuffers(dpy, win, &width, &height, attachments, nattachments, &count); if (count != nattachments) return; - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) DRI2SwapBuffers(dpy, win, 0, 0, 0); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) swaps in %fs.\n", count, name, width, height, elapsed(&start, &end)); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) dri2_copy_swap(dpy, win, width, height, nattachments == 2); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) blits in %fs.\n", @@ -150,11 +153,11 @@ static void run(Display *dpy, int width, int height, DRI2SwapInterval(dpy, win, 0); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) DRI2SwapBuffers(dpy, win, 0, 0, 0); - xsync(dpy, win); + msc = check_msc(dpy, win, msc); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) vblank=0 swaps in %fs.\n", count, name, width, height, elapsed(&start, &end)); @@ -174,6 +177,9 @@ int main(void) DRI2BufferFrontLeft, }; XRRScreenResources *res; + XRRCrtcInfo **original_crtc; + Window root; + uint64_t last_msc; dpy = XOpenDisplay(NULL); if (dpy == NULL) @@ -186,16 +192,23 @@ int main(void) if (fd < 0) return 1; - res = _XRRGetScreenResourcesCurrent(dpy, DefaultRootWindow(dpy)); + root = DefaultRootWindow(dpy); + DRI2CreateDrawable(dpy, root); + + res = _XRRGetScreenResourcesCurrent(dpy, root); if (res == NULL) return 1; - printf("noutput=%d, ncrtc=%d\n", res->noutput, res->ncrtc); + original_crtc = malloc(sizeof(XRRCrtcInfo *)*res->ncrtc); + for (i = 0; i < res->ncrtc; i++) + original_crtc[i] = XRRGetCrtcInfo(dpy, res, res->crtcs[i]); + printf("noutput=%d, ncrtc=%d\n", res->noutput, res->ncrtc); + last_msc = check_msc(dpy, root, 0); for (i = 0; i < res->ncrtc; i++) XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); - XSync(dpy, True); + last_msc = check_msc(dpy, root, last_msc); for (i = 0; i < res->noutput; i++) { XRROutputInfo *output; @@ -209,12 +222,17 @@ int main(void) if (res->nmode) mode = lookup_mode(res, output->modes[0]); - for (j = 0; mode && j < output->ncrtc; j++) { + for (j = 0; mode && j < 2*output->ncrtc; j++) { + int c = j; + if (c >= output->ncrtc) + c = 2*output->ncrtc - j - 1; + printf("[%d, %d] -- OUTPUT:%ld, CRTC:%ld\n", - i, j, (long)res->outputs[i], (long)output->crtcs[j]); - XRRSetCrtcConfig(dpy, res, output->crtcs[j], CurrentTime, + i, c, (long)res->outputs[i], (long)output->crtcs[c]); + last_msc = check_msc(dpy, root, last_msc); + XRRSetCrtcConfig(dpy, res, output->crtcs[c], CurrentTime, 0, 0, output->modes[0], RR_Rotate_0, &res->outputs[i], 1); - XSync(dpy, True); + last_msc = check_msc(dpy, root, last_msc); run(dpy, mode->width, mode->height, attachments, 1, "fullscreen"); run(dpy, mode->width, mode->height, attachments, 2, "fullscreen (with front)"); @@ -222,13 +240,22 @@ int main(void) run(dpy, mode->width/2, mode->height/2, attachments, 1, "windowed"); run(dpy, mode->width/2, mode->height/2, attachments, 2, "windowed (with front)"); - XRRSetCrtcConfig(dpy, res, output->crtcs[j], CurrentTime, + last_msc = check_msc(dpy, root, last_msc); + XRRSetCrtcConfig(dpy, res, output->crtcs[c], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); - XSync(dpy, True); + last_msc = check_msc(dpy, root, last_msc); } XRRFreeOutputInfo(output); } + for (i = 0; i < res->ncrtc; i++) + XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, + original_crtc[i]->x, + original_crtc[i]->y, + original_crtc[i]->mode, + original_crtc[i]->rotation, + original_crtc[i]->outputs, + original_crtc[i]->noutput); return 0; } diff --git a/driver/xf86-video-intel/test/dri3-test.c b/driver/xf86-video-intel/test/dri3-test.c new file mode 100644 index 000000000..c66da313b --- /dev/null +++ b/driver/xf86-video-intel/test/dri3-test.c @@ -0,0 +1,1112 @@ +/* + * Copyright (c) 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xlibint.h> +#include <X11/extensions/Xrender.h> +#include <X11/extensions/XShm.h> +#if HAVE_X11_EXTENSIONS_SHMPROTO_H +#include <X11/extensions/shmproto.h> +#elif HAVE_X11_EXTENSIONS_SHMSTR_H +#include <X11/extensions/shmstr.h> +#else +#error Failed to find the right header for X11 MIT-SHM protocol definitions +#endif +#include <xf86drm.h> +#include <i915_drm.h> + +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <unistd.h> +#include <assert.h> +#include <errno.h> + +#include <sys/mman.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <pciaccess.h> + +#include "dri3.h" +#include "../src/i915_pciids.h" + +#define ALIGN(x, y) (((x) + (y) - 1) & -(y)) +#define PAGE_ALIGN(x) ALIGN(x, 4096) + +#define GTT I915_GEM_DOMAIN_GTT +#define CPU I915_GEM_DOMAIN_CPU + +static int _x_error_occurred; + +static const struct pci_id_match ids[] = { + INTEL_I830_IDS(020), + INTEL_I845G_IDS(021), + INTEL_I85X_IDS(022), + INTEL_I865G_IDS(023), + + INTEL_I915G_IDS(030), + INTEL_I915GM_IDS(030), + INTEL_I945G_IDS(031), + INTEL_I945GM_IDS(031), + + INTEL_G33_IDS(033), + INTEL_PINEVIEW_IDS(033), + + INTEL_I965G_IDS(040), + INTEL_I965GM_IDS(040), + + INTEL_G45_IDS(045), + INTEL_GM45_IDS(045), + + INTEL_IRONLAKE_D_IDS(050), + INTEL_IRONLAKE_M_IDS(050), + + INTEL_SNB_D_IDS(060), + INTEL_SNB_M_IDS(060), + + INTEL_IVB_D_IDS(070), + INTEL_IVB_M_IDS(070), + + INTEL_HSW_D_IDS(075), + INTEL_HSW_M_IDS(075), + + INTEL_VLV_D_IDS(071), + INTEL_VLV_M_IDS(071), + + INTEL_BDW_D_IDS(0100), + INTEL_BDW_M_IDS(0100), +}; + +static int i915_gen(int device) +{ + struct drm_i915_getparam gp; + int devid = 0; + int n; + + gp.param = I915_PARAM_CHIPSET_ID; + gp.value = &devid; + + if (drmIoctl(device, DRM_IOCTL_I915_GETPARAM, &gp)) + return 0; + + for (n = 0; n < sizeof(ids)/sizeof(ids[0]); n++) { + if (devid == ids[n].device_id) + return ids[n].match_data; + } + + return 0; +} + +static int is_i915_device(int fd) +{ + drm_version_t version; + char name[5] = ""; + + memset(&version, 0, sizeof(version)); + version.name_len = 4; + version.name = name; + + if (drmIoctl(fd, DRM_IOCTL_VERSION, &version)) + return 0; + + return strcmp("i915", name) == 0; +} + +static int is_intel(int fd) +{ + struct drm_i915_getparam gp; + int ret; + + /* Confirm that this is a i915.ko device with GEM/KMS enabled */ + ret = is_i915_device(fd); + if (ret) { + gp.param = I915_PARAM_HAS_GEM; + gp.value = &ret; + if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) + ret = 0; + } + return ret; +} + +static uint32_t gem_create(int fd, int size) +{ + struct drm_i915_gem_create create; + + create.handle = 0; + create.size = size; + (void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create); + + return create.handle; +} + +struct local_i915_gem_caching { + uint32_t handle; + uint32_t caching; +}; + +#define LOCAL_I915_GEM_SET_CACHING 0x2f +#define LOCAL_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + LOCAL_I915_GEM_SET_CACHING, struct local_i915_gem_caching) + +static int gem_set_caching(int fd, uint32_t handle, int caching) +{ + struct local_i915_gem_caching arg; + + arg.handle = handle; + arg.caching = caching; + + return drmIoctl(fd, LOCAL_IOCTL_I915_GEM_SET_CACHING, &arg) == 0; +} + +static int gem_export(int fd, uint32_t handle) +{ + struct drm_prime_handle args; + + args.handle = handle; + args.flags = O_CLOEXEC; + + if (drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args)) + return -1; + + return args.fd; +} + +static uint32_t gem_import(int fd, int name) +{ + struct drm_prime_handle args; + + args.fd = name; + args.flags = 0; + if (drmIoctl(fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args)) + return 0; + + return args.handle; +} + +static int gem_write(int fd, uint32_t handle, int offset, void *data, int len) +{ + struct drm_i915_gem_pwrite gem_pwrite; + + gem_pwrite.handle = handle; + gem_pwrite.offset = offset; + gem_pwrite.size = len; + gem_pwrite.data_ptr = (uintptr_t)data; + return drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite); +} + +static void *gem_mmap(int fd, uint32_t handle, int size, unsigned prot, int domain) +{ + struct drm_i915_gem_set_domain set_domain; + void *ptr; + + if (domain == CPU) { + struct drm_i915_gem_mmap mmap_arg; + + mmap_arg.handle = handle; + mmap_arg.offset = 0; + mmap_arg.size = size; + if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg)) + return NULL; + + ptr = (void *)(uintptr_t)mmap_arg.addr_ptr; + } else { + struct drm_i915_gem_mmap_gtt mmap_arg; + + mmap_arg.handle = handle; + if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) + return NULL; + + ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); + if (ptr == MAP_FAILED) + return NULL; + } + + set_domain.handle = handle; + set_domain.read_domains = domain; + set_domain.write_domain = prot & PROT_WRITE ? set_domain.read_domains : 0; + if (drmIoctl(fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain)) { + munmap(ptr, size); + return NULL; + } + + return ptr; +} + +static void gem_sync(int fd, uint32_t handle, int read) +{ + struct drm_i915_gem_set_domain set_domain; + + set_domain.handle = handle; + set_domain.read_domains = read; + set_domain.write_domain = 0; + drmIoctl(fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain); +} + +static int gem_get_tiling(int fd, uint32_t handle) +{ + struct drm_i915_gem_get_tiling tiling; + + tiling.handle = handle; + tiling.tiling_mode = -1; + (void)drmIoctl(fd, DRM_IOCTL_I915_GEM_GET_TILING, &tiling); + return tiling.tiling_mode; +} + +static void gem_close(int fd, uint32_t handle) +{ + struct drm_gem_close close; + + close.handle = handle; + (void)drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &close); +} + +static void gem_fill(int fd, uint32_t handle, uint32_t pixel, uint32_t size, int domain) +{ + uint32_t *ptr, s; + + ptr = gem_mmap(fd, handle, size, PROT_READ | PROT_WRITE, domain); + if (ptr == NULL) + return; + + for (s = 0; s < size; s += 4) + ptr[s/4] = pixel; + munmap(ptr, size); +} + +static int check_pixmap(Display *dpy, Pixmap pix, + int x, int y, uint32_t expected, int bpp) +{ + XImage *image; + int w = 32 / bpp; + + image = XGetImage(dpy, pix, x - (x % w), y, w, 1, AllPlanes, ZPixmap); + if (image == NULL) + return 0; + + if (*(uint32_t *)image->data != expected) { + printf("pixmap[%d, %d]:%d = %08x\n", x, y, bpp, *(uint32_t *)image->data); + return 0; + } + XDestroyImage(image); + + return 1; +} + +static int check_pixel(int fd, uint32_t handle, uint32_t stride, uint32_t size, + int x, int y, uint32_t expected, int bpp, int domain) +{ + uint32_t *ptr; + int w = 32 / bpp; + + assert((stride & 3) == 0); + + ptr = gem_mmap(fd, handle, size, PROT_READ, domain); + if (ptr == NULL) + return 0; + + if (ptr[(y*stride + x - (x % w))/4] != expected) { + printf("pixel[%d, %d]:%d = %08x\n", x, y, bpp, ptr[(y * stride + x)/4]); + return 0; + } + munmap(ptr, size); + + return 1; +} + +static GC get_gc(Display *dpy, Drawable d, int depth) +{ + static GC gc[33]; + if (gc[depth] == NULL) { + XGCValues gcv; + + gcv.graphics_exposures = False; + gc[depth] = XCreateGC(dpy, d, GCGraphicsExposures, &gcv); + } + return gc[depth]; +} + +static int +can_use_shm(Display *dpy) +{ + int major, minor, has_pixmap; + + if (!XShmQueryExtension(dpy)) + return 0; + + XShmQueryVersion(dpy, &major, &minor, &has_pixmap); + return has_pixmap; +} + +static int gpu_fill(int device, int handle, int width, int height, int pitch, int bpp, int tiling, uint32_t pixel) +{ + struct drm_i915_gem_execbuffer2 execbuf; + struct drm_i915_gem_relocation_entry gem_reloc[2]; + struct drm_i915_gem_exec_object2 gem_exec[2]; + uint32_t batch[10]; + int gen = i915_gen(device); + int len = 0; + int ret; + + if (gen == 0) + return -ENODEV; + + batch[0] = 2 << 29 | 0x50 << 22; + batch[0] |= (gen >= 0100 ? 5 : 4); + batch[1] = pitch; + if (gen >= 040 && tiling) { + batch[0] |= 1 << 11; + batch[1] >>= 2; + } + + batch[1] |= 0xf0 << 16; + switch (bpp) { + default: assert(0); + case 32: batch[0] |= 1 << 21 | 1 << 20; + batch[1] |= 1 << 25; /* RGB8888 */ + case 16: batch[1] |= 1 << 24; /* RGB565 */ + case 8: break; + } + + batch[2] = 0; + batch[3] = height << 16 | width; + batch[4] = 0; + len = 5; + if (gen >= 0100) + batch[len++] = 0; + batch[len++] = pixel; + batch[len++] = 0xA << 23; + if (len & 1) + len++; + + gem_reloc[0].offset = 4 * sizeof(uint32_t); + gem_reloc[0].delta = 0; + gem_reloc[0].target_handle = handle; + gem_reloc[0].read_domains = I915_GEM_DOMAIN_RENDER; + gem_reloc[0].write_domain = I915_GEM_DOMAIN_RENDER; + gem_reloc[0].presumed_offset = 0; + + memset(gem_exec, 0, sizeof(gem_exec)); + gem_exec[0].handle = handle; + gem_exec[1].handle = gem_create(device, 4096); + gem_exec[1].relocation_count = 1; + gem_exec[1].relocs_ptr = (uintptr_t)gem_reloc; + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)gem_exec; + execbuf.buffer_count = 2; + execbuf.batch_len = len * sizeof(uint32_t); + execbuf.flags = gen >= 060 ? I915_EXEC_BLT : 0; + + ret = gem_write(device, gem_exec[1].handle, 0, batch, execbuf.batch_len); + if (ret == 0) + ret = drmIoctl(device, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf); + if (ret < 0) + ret = -errno; + + gem_close(device, gem_exec[1].handle); + return ret; +} + +static int test_shm(Display *dpy, int device, + int width, int height) +{ + const int x_loc[] = {0, width/2, width-1}; + const int y_loc[] = {0, height/2, height-1}; + uint32_t pixel = 0xffff00ff; + XShmSegmentInfo shm; + Pixmap pixmap; + uint32_t handle = 0; + uint32_t *ptr; + int stride, fd; + int x, y; + int line; + + if (!can_use_shm(dpy)) + return 0; + + printf("Creating %dx%d SHM pixmap\n", width, height); + _x_error_occurred = 0; + + shm.shmid = shmget(IPC_PRIVATE, height * 4*width, IPC_CREAT | 0666); + if (shm.shmid == -1) + return 0; + + shm.shmaddr = shmat(shm.shmid, 0, 0); + if (shm.shmaddr == (char *) -1) { + shmctl(shm.shmid, IPC_RMID, NULL); + return 0; + } + + shm.readOnly = False; + XShmAttach(dpy, &shm); + + pixmap = XShmCreatePixmap(dpy, DefaultRootWindow(dpy), + shm.shmaddr, &shm, width, height, 24); + XSync(dpy, False); + shmctl(shm.shmid, IPC_RMID, NULL); + + if (_x_error_occurred) { + XShmDetach(dpy, &shm); + shmdt(shm.shmaddr); + return 0; + } + + printf("Testing write of %dx%d SHM pixmap via DRI3 fd\n", width, height); + + fd = dri3_create_fd(dpy, pixmap, &stride); + if (fd < 0) { + line = __LINE__; + goto fail; + } + + handle = gem_import(device, fd); + close(fd); + if (handle == 0) { + line = __LINE__; + goto fail; + } + + if (gpu_fill(device, handle, width, height, stride, 32, I915_TILING_NONE, pixel)) { + line = __LINE__; + goto fail; + } + + gem_sync(device, handle, CPU); + ptr = (uint32_t *)shm.shmaddr; + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (ptr[y_loc[y]*width + x_loc[x]] != pixel) { + printf("pixel[%d, %d]:%d = %08x\n", x, y, 32, ptr[y_loc[y] * width + x_loc[x]]); + line = __LINE__; + goto fail; + } + + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixmap(dpy, pixmap, + x_loc[x], y_loc[y], + pixel, 32)) { + line = __LINE__; + goto fail; + } + + if (_x_error_occurred) { + line = __LINE__; + goto fail; + } + +out: + gem_close(device, handle); + XFreePixmap(dpy, pixmap); + XShmDetach(dpy, &shm); + shmdt(shm.shmaddr); + return fd != -1; + +fail: + printf("%s failed at (%dx%d), line %d\n", + __func__, width, height, line); + fd = -1; + goto out; +} + +static int test_read_after_write(Display *dpy, int device, + int width, int height, int depth, + int domain) +{ + const uint32_t pixel = 0xffff00ff; + const int x_loc[] = {0, width/2, width-1}; + const int y_loc[] = {0, height/2, height-1}; + Window root = RootWindow(dpy, DefaultScreen(dpy)); + uint32_t src, dst; + int src_fd, dst_fd; + int src_stride, src_size; + int dst_stride, dst_size; + Pixmap src_pix, dst_pix; + struct dri3_fence fence; + int x, y, bpp; + + _x_error_occurred = 0; + + switch (depth) { + case 8: bpp = 8; break; + case 16: bpp = 16; break; + case 24: bpp = 32; break; + case 32: bpp = 32; break; + default: return 0; + } + + src_stride = width * bpp/8; + src_size = PAGE_ALIGN(src_stride * height); + printf("Creating %dx%d (source stride=%d, size=%d, domain=%d)\n", + width, height, src_stride, src_size, domain); + + src = gem_create(device, src_size); + if (!src) + goto fail; + + if (domain == CPU) + gem_set_caching(device, src, 1); + + gem_fill(device, src, pixel, src_size, domain); + + src_fd = gem_export(device, src); + if (src_fd < 0) + goto fail; + + src_pix = dri3_create_pixmap(dpy, root, + width, height, depth, + src_fd, bpp, src_stride, src_size); + + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixmap(dpy, src_pix, + x_loc[x], y_loc[y], + pixel, bpp)) + goto fail; + close(src_fd); + + dst_pix = XCreatePixmap(dpy, root, width, height, depth); + if (dri3_create_fence(dpy, dst_pix, &fence)) + goto fail; + + dst_fd = dri3_create_fd(dpy, dst_pix, &dst_stride); + if (dst_fd < 0) + goto fail; + dst_size = lseek(dst_fd, 0, SEEK_END); + printf("Comparing %dx%d (destination stride=%d, size=%d)\n", + width, height, dst_stride, dst_size); + dst = gem_import(device, dst_fd); + if (dst == 0) + goto fail; + close(dst_fd); + + XCopyArea(dpy, src_pix, dst_pix, + get_gc(dpy, dst_pix, depth), + 0, 0, width, height, 0, 0); + dri3_fence_sync(dpy, &fence); + dri3_fence_free(dpy, &fence); + + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixel(device, dst, dst_stride, dst_size, + x_loc[x], y_loc[y], + pixel, bpp, GTT)) + goto fail; + + XFreePixmap(dpy, dst_pix); + XFreePixmap(dpy, src_pix); + + gem_close(device, src); + gem_close(device, dst); + + if (_x_error_occurred) + goto fail; + + return 0; + +fail: + printf("%s failed at (%dx%d), depth=%d, domain=%d\n", + __func__, width, height, depth, domain); + return 1; +} + +static XRenderPictFormat *format_for_depth(Display *dpy, int depth) +{ + switch (depth) { + case 8: return XRenderFindStandardFormat(dpy, PictStandardA8); + case 24: return XRenderFindStandardFormat(dpy, PictStandardRGB24); + case 32: return XRenderFindStandardFormat(dpy, PictStandardARGB32); + default: assert(0); return NULL; + } +} + +static int test_read(Display *dpy, int device, + int width, int height, + int domain) +{ + const uint32_t pixel = 0xffff00ff; + const XRenderColor color = { 0xffff, 0x0000, 0xffff, 0xffff }; + const int x_loc[] = {0, width/2, width-1}; + const int y_loc[] = {0, height/2, height-1}; + Window root = RootWindow(dpy, DefaultScreen(dpy)); + uint32_t dst; + int dst_stride, dst_size, dst_fd; + Pixmap src_pix, dst_pix; + Picture src_pic; + struct dri3_fence fence; + int depth = 32, bpp = 32; + int x, y; + + _x_error_occurred = 0; + + dst_stride = width * bpp/8; + dst_size = PAGE_ALIGN(dst_stride * height); + printf("Creating %dx%d (destination stride=%d, size=%d, domain=%d)\n", + width, height, dst_stride, dst_size, domain); + + dst = gem_create(device, dst_size); + if (!dst) + goto fail; + + if (domain == CPU) + gem_set_caching(device, dst, 1); + + gem_fill(device, dst, ~pixel, dst_size, domain); + + dst_fd = gem_export(device, dst); + if (dst_fd < 0) + goto fail; + + dst_pix = dri3_create_pixmap(dpy, root, + width, height, depth, + dst_fd, bpp, dst_stride, dst_size); + XSync(dpy, True); + if (_x_error_occurred) + goto fail; + if (dri3_create_fence(dpy, dst_pix, &fence)) + goto fail; + + src_pix = XCreatePixmap(dpy, root, width, height, depth); + src_pic = XRenderCreatePicture(dpy, src_pix, format_for_depth(dpy, depth), 0, NULL); + XRenderFillRectangle(dpy, PictOpSrc, src_pic, &color, 0, 0, width, height); + XCopyArea(dpy, src_pix, dst_pix, + get_gc(dpy, dst_pix, depth), + 0, 0, width, height, 0, 0); + dri3_fence_sync(dpy, &fence); + dri3_fence_free(dpy, &fence); + + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixel(device, dst, dst_stride, dst_size, + x_loc[x], y_loc[y], + pixel, bpp, domain)) + goto fail; + + XFreePixmap(dpy, dst_pix); + XRenderFreePicture(dpy, src_pic); + XFreePixmap(dpy, src_pix); + + gem_close(device, dst); + + if (_x_error_occurred) + goto fail; + + return 0; + +fail: + printf("%s failed at (%dx%d), depth=%d, domain=%d\n", + __func__, width, height, depth, domain); + return 1; +} + +static int test_dup_pixmap(Display *dpy, int device) +{ + const uint32_t pixel = 0xffff00ff; + const XRenderColor color = { 0xffff, 0x0000, 0xffff, 0xffff }; + const XRenderColor inverse = { 0, 0xffff, 0, 0 }; + int width = 400, height = 400; + const int x_loc[] = {0, width/2, width-1}; + const int y_loc[] = {0, height/2, height-1}; + Window root = RootWindow(dpy, DefaultScreen(dpy)); + uint32_t handle; + int stride, size, fd; + Pixmap src_pix, dst_pix; + Picture src_pic, dst_pic; + struct dri3_fence fence; + int depth = 32, bpp = 32; + int x, y; + + _x_error_occurred = 0; + + printf("%s: Creating %dx%d pixmap\n", __func__, width, height); + src_pix = XCreatePixmap(dpy, root, width, height, depth); + src_pic = XRenderCreatePicture(dpy, src_pix, format_for_depth(dpy, depth), 0, NULL); + fd = dri3_create_fd(dpy, src_pix, &stride); + if (fd < 0) + goto fail; + + size = lseek(fd, 0, SEEK_END); + handle = gem_import(device, fd); + + printf("%s: Creating duplicate from pixmap exported fd\n", __func__); + dst_pix = dri3_create_pixmap(dpy, root, + width, height, depth, + fd, bpp, stride, size); + dst_pic = XRenderCreatePicture(dpy, dst_pix, format_for_depth(dpy, depth), 0, NULL); + XSync(dpy, True); + if (_x_error_occurred) + goto fail; + + printf("%s: Filling src with %08x, reading dst\n", __func__, pixel); + XRenderFillRectangle(dpy, PictOpSrc, src_pic, &color, 0, 0, width, height); + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixmap(dpy, dst_pix, + x_loc[x], y_loc[y], + pixel, 32)) + goto fail; + + printf("%s: Filling dst with %08x, reading src\n", __func__, ~pixel); + XRenderFillRectangle(dpy, PictOpSrc, dst_pic, &inverse, 0, 0, width, height); + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixmap(dpy, dst_pix, + x_loc[x], y_loc[y], + ~pixel, 32)) + goto fail; + + if (dri3_create_fence(dpy, src_pix, &fence)) + goto fail; + + printf("%s: Filling src with %08x, reading fd\n", __func__, pixel); + XRenderFillRectangle(dpy, PictOpSrc, src_pic, &color, 0, 0, width, height); + dri3_fence_sync(dpy, &fence); + dri3_fence_free(dpy, &fence); + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixel(device, handle, stride, size, + x_loc[x], y_loc[y], + pixel, bpp, GTT)) + goto fail; + + printf("%s: Filling fd with %08x, reading src\n", __func__, ~pixel); + if (gpu_fill(device, handle, width, height, stride, 32, gem_get_tiling(device, handle), ~pixel)) + goto fail; + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixmap(dpy, src_pix, + x_loc[x], y_loc[y], + ~pixel, 32)) + goto fail; + + if (dri3_create_fence(dpy, dst_pix, &fence)) + goto fail; + + printf("%s: Filling dst with %08x, reading fd\n", __func__, pixel); + XRenderFillRectangle(dpy, PictOpSrc, dst_pic, &color, 0, 0, width, height); + dri3_fence_sync(dpy, &fence); + dri3_fence_free(dpy, &fence); + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixel(device, handle, stride, size, + x_loc[x], y_loc[y], + pixel, bpp, GTT)) + goto fail; + + printf("%s: Filling fd with %08x, reading dst\n", __func__, ~pixel); + if (gpu_fill(device, handle, width, height, stride, 32, gem_get_tiling(device, handle), ~pixel)) + goto fail; + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixmap(dpy, dst_pix, + x_loc[x], y_loc[y], + ~pixel, 32)) + goto fail; + + XRenderFreePicture(dpy, src_pic); + XFreePixmap(dpy, src_pix); + + if (dri3_create_fence(dpy, dst_pix, &fence)) + goto fail; + + printf("%s: Closed original src, filling dst with %08x, reading fd\n", __func__, pixel); + XRenderFillRectangle(dpy, PictOpSrc, dst_pic, &color, 0, 0, width, height); + dri3_fence_sync(dpy, &fence); + dri3_fence_free(dpy, &fence); + for (x = 0; x < sizeof(x_loc)/sizeof(x_loc[0]); x++) + for (y = 0; y < sizeof(y_loc)/sizeof(y_loc[0]); y++) + if (!check_pixel(device, handle, stride, size, + x_loc[x], y_loc[y], + pixel, bpp, GTT)) + goto fail; + + XRenderFreePicture(dpy, dst_pic); + XFreePixmap(dpy, dst_pix); + + gem_close(device, handle); + + if (_x_error_occurred) + goto fail; + + return 0; + +fail: + printf("%s failed at (%dx%d), depth=%d\n", + __func__, width, height, depth); + return 1; +} + +static int test_bad_size(Display *dpy, int device) +{ + Window root = RootWindow(dpy, DefaultScreen(dpy)); + uint32_t src; + int src_fd; + Pixmap src_pix; + int line = -1; + + _x_error_occurred = 0; + + src = gem_create(device, 4096); + if (!src) + goto fail; + + src_fd = gem_export(device, src); + if (src_fd < 0) + goto fail; + + src_pix = dri3_create_pixmap(dpy, root, + 16, 16, 32, + dup(src_fd), 32, 16*4, 4096); + line = __LINE__; + XSync(dpy, True); + if (_x_error_occurred) + goto fail; + XFreePixmap(dpy, src_pix); + _x_error_occurred = 0; + + src_pix = dri3_create_pixmap(dpy, root, + 32, 32, 32, + dup(src_fd), 32, 32*4, 4096); + line = __LINE__; + XSync(dpy, True); + if (_x_error_occurred) + goto fail; + XFreePixmap(dpy, src_pix); + _x_error_occurred = 0; + + src_pix = dri3_create_pixmap(dpy, root, + 64, 64, 32, + dup(src_fd), 32, 64*4, 4096); + line = __LINE__; + XSync(dpy, True); + if (!_x_error_occurred) + goto fail; + _x_error_occurred = 0; + + src_pix = dri3_create_pixmap(dpy, root, + 64, 64, 32, + dup(src_fd), 32, 64*4, 64*64*4); + line = __LINE__; + XSync(dpy, True); + if (!_x_error_occurred) + goto fail; + _x_error_occurred = 0; + + src_pix = dri3_create_pixmap(dpy, root, + INT16_MAX, INT16_MAX, 8, + dup(src_fd), 8, INT16_MAX, UINT32_MAX); + line = __LINE__; + XSync(dpy, True); + if (!_x_error_occurred) + goto fail; + _x_error_occurred = 0; + + close(src_fd); + gem_close(device, src); + + return 0; + +fail: + printf("%s failed at line %d\n", __func__, line); + return 1; +} + +static int test_bad_pitch(Display *dpy, int device) +{ + Window root = RootWindow(dpy, DefaultScreen(dpy)); + uint32_t src; + int src_fd; + Pixmap src_pix; + int line = -1; + + _x_error_occurred = 0; + + src = gem_create(device, 4096); + if (!src) + goto fail; + + src_fd = gem_export(device, src); + if (src_fd < 0) + goto fail; + + src_pix = dri3_create_pixmap(dpy, root, + 16, 16, 32, + dup(src_fd), 32, 16*4, 4096); + line = __LINE__; + XSync(dpy, True); + if (_x_error_occurred) + goto fail; + XFreePixmap(dpy, src_pix); + _x_error_occurred = 0; + + src_pix = dri3_create_pixmap(dpy, root, + 256, 2, 32, + dup(src_fd), 32, 256*4, 4096); + line = __LINE__; + XSync(dpy, True); + if (_x_error_occurred) + goto fail; + XFreePixmap(dpy, src_pix); + _x_error_occurred = 0; + + src_pix = dri3_create_pixmap(dpy, root, + 256, 2, 32, + dup(src_fd), 32, 256, 4096); + line = __LINE__; + XSync(dpy, True); + if (!_x_error_occurred) + goto fail; + _x_error_occurred = 0; + + src_pix = dri3_create_pixmap(dpy, root, + 256, 2, 32, + dup(src_fd), 32, 16384, 4096); + line = __LINE__; + XSync(dpy, True); + if (!_x_error_occurred) + goto fail; + _x_error_occurred = 0; + + src_pix = dri3_create_pixmap(dpy, root, + 256, 2, 32, + dup(src_fd), 32, 1023, 4096); + line = __LINE__; + XSync(dpy, True); + if (!_x_error_occurred) + goto fail; + _x_error_occurred = 0; + + src_pix = dri3_create_pixmap(dpy, root, + 256, 2, 32, + dup(src_fd), 32, 1025, 4096); + line = __LINE__; + XSync(dpy, True); + if (!_x_error_occurred) + goto fail; + _x_error_occurred = 0; + + close(src_fd); + gem_close(device, src); + + return 0; + +fail: + printf("%s failed at line %d\n", __func__, line); + return 1; +} + +static int +_check_error_handler(Display *display, + XErrorEvent *event) +{ + printf("X11 error from display %s, serial=%ld, error=%d, req=%d.%d\n", + DisplayString(display), + event->serial, + event->error_code, + event->request_code, + event->minor_code); + _x_error_occurred++; + return False; /* ignored */ +} + +int main(void) +{ + Display *dpy; + int device; + int error = 0; + + dpy = XOpenDisplay(NULL); + if (dpy == NULL) + return 77; + + if (DefaultDepth(dpy, DefaultScreen(dpy)) != 24) + return 77; + + XSetErrorHandler(_check_error_handler); + + device = dri3_open(dpy); + if (device < 0) + return 127; + + if (!is_intel(device)) + return 77; + + printf("Opened Intel DRI3 device\n"); + + error += test_bad_size(dpy, device); + error += test_bad_pitch(dpy, device); + + error += test_shm(dpy, device, 400, 300); + error += test_shm(dpy, device, 300, 400); + + error += test_read(dpy, device, 400, 200, GTT); + error += test_read(dpy, device, 4000, 20, GTT); + error += test_read(dpy, device, 16000, 10, GTT); + error += test_read(dpy, device, 30000, 10, GTT); + + error += test_read(dpy, device, 200, 400, GTT); + error += test_read(dpy, device, 20, 4000, GTT); + error += test_read(dpy, device, 16, 16000, GTT); + error += test_read(dpy, device, 16, 30000, GTT); + + error += test_read(dpy, device, 400, 200, CPU); + error += test_read(dpy, device, 4000, 20, CPU); + error += test_read(dpy, device, 16000, 10, CPU); + error += test_read(dpy, device, 30000, 10, CPU); + + error += test_read(dpy, device, 200, 400, CPU); + error += test_read(dpy, device, 20, 4000, CPU); + error += test_read(dpy, device, 16, 16000, CPU); + error += test_read(dpy, device, 16, 30000, CPU); + + error += test_read_after_write(dpy, device, 400, 200, 24, GTT); + error += test_read_after_write(dpy, device, 4000, 20, 24, GTT); + error += test_read_after_write(dpy, device, 16000, 10, 24, GTT); + error += test_read_after_write(dpy, device, 30000, 10, 24, GTT); + error += test_read_after_write(dpy, device, 30000, 10, 8, GTT); + + error += test_read_after_write(dpy, device, 200, 400, 24, GTT); + error += test_read_after_write(dpy, device, 20, 4000, 24, GTT); + error += test_read_after_write(dpy, device, 16, 16000, 24, GTT); + error += test_read_after_write(dpy, device, 16, 30000, 24, GTT); + + error += test_read_after_write(dpy, device, 400, 200, 24, CPU); + error += test_read_after_write(dpy, device, 4000, 20, 24, CPU); + error += test_read_after_write(dpy, device, 16000, 10, 24, CPU); + error += test_read_after_write(dpy, device, 30000, 10, 24, CPU); + error += test_read_after_write(dpy, device, 30000, 10, 8, CPU); + + error += test_read_after_write(dpy, device, 200, 400, 24, CPU); + error += test_read_after_write(dpy, device, 20, 4000, 24, CPU); + error += test_read_after_write(dpy, device, 16, 16000, 24, CPU); + error += test_read_after_write(dpy, device, 16, 30000, 24, CPU); + + error += test_dup_pixmap(dpy, device); + + return !!error; +} diff --git a/driver/xf86-video-intel/test/dri3.c b/driver/xf86-video-intel/test/dri3.c new file mode 100644 index 000000000..45f3285c1 --- /dev/null +++ b/driver/xf86-video-intel/test/dri3.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include <X11/Xlib.h> +#include <X11/Xlib-xcb.h> +#include <X11/xshmfence.h> +#include <xcb/xcb.h> +#include <xcb/dri3.h> +#include <xcb/sync.h> +#include <unistd.h> + +#include "dri3.h" + +Pixmap dri3_create_pixmap(Display *dpy, + Drawable draw, + int width, int height, int depth, + int fd, int bpp, int stride, int size) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + if (fd >= 0) { + xcb_pixmap_t pixmap = xcb_generate_id(c); + xcb_dri3_pixmap_from_buffer(c, pixmap, draw, size, width, height, stride, depth, bpp, fd); + return pixmap; + } + return 0; +} + +int dri3_create_fd(Display *dpy, + Pixmap pixmap, + int *stride) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_dri3_buffer_from_pixmap_cookie_t cookie; + xcb_dri3_buffer_from_pixmap_reply_t *reply; + + cookie = xcb_dri3_buffer_from_pixmap(c, pixmap); + reply = xcb_dri3_buffer_from_pixmap_reply(c, cookie, NULL); + if (!reply) + return -1; + + if (reply->nfd != 1) + return -1; + + *stride = reply->stride; + return xcb_dri3_buffer_from_pixmap_reply_fds(c, reply)[0]; +} + +int dri3_create_fence(Display *dpy, Pixmap pixmap, struct dri3_fence *fence) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + struct dri3_fence f; + int fd; + + fd = xshmfence_alloc_shm(); + if (fd < 0) + return -1; + + f.addr = xshmfence_map_shm(fd); + if (f.addr == NULL) { + close(fd); + return -1; + } + + f.xid = xcb_generate_id(c); + xcb_dri3_fence_from_fd(c, pixmap, f.xid, 0, fd); + + *fence = f; + return 0; +} + +void dri3_fence_sync(Display *dpy, struct dri3_fence *fence) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + + xshmfence_reset(fence->addr); + + xcb_sync_trigger_fence(c, fence->xid); + xcb_flush(c); + + xshmfence_await(fence->addr); +} + +void dri3_fence_free(Display *dpy, struct dri3_fence *fence) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + + xshmfence_unmap_shm(fence->addr); + xcb_sync_destroy_fence(c, fence->xid); +} + +int dri3_open__full(Display *dpy, Window root, unsigned provider) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_dri3_open_cookie_t cookie; + xcb_dri3_open_reply_t *reply; + + cookie = xcb_dri3_open(c, root, provider); + reply = xcb_dri3_open_reply(c, cookie, NULL); + + if (!reply) + return -1; + + if (reply->nfd != 1) + return -1; + + return xcb_dri3_open_reply_fds(c, reply)[0]; +} + +int dri3_open(Display *dpy) +{ + return dri3_open__full(dpy, RootWindow(dpy, DefaultScreen(dpy)), None); +} diff --git a/driver/xf86-video-intel/test/dri3.h b/driver/xf86-video-intel/test/dri3.h new file mode 100644 index 000000000..55d294368 --- /dev/null +++ b/driver/xf86-video-intel/test/dri3.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifndef DRI3_H +#define DRI3_H + +#include <X11/X.h> + +int dri3_open(Display *dpy); +int dri3_open__full(Display *dpy, Window root, unsigned provider); + +Pixmap dri3_create_pixmap(Display *dpy, + Drawable draw, + int width, int height, int depth, + int fd, int bpp, int stride, int size); +int dri3_create_fd(Display *dpy, + Pixmap pixmap, + int *stride); + +struct dri3_fence { + XID xid; + void *addr; +}; + +int dri3_create_fence(Display *dpy, Pixmap pixmap, struct dri3_fence *out); +void dri3_fence_sync(Display *dpy, struct dri3_fence *fence); +void dri3_fence_free(Display *dpy, struct dri3_fence *fence); + +#endif /* DRI3_H */ diff --git a/driver/xf86-video-intel/test/lowlevel-blt-bench.c b/driver/xf86-video-intel/test/lowlevel-blt-bench.c index f2b6863eb..9eef8db09 100644 --- a/driver/xf86-video-intel/test/lowlevel-blt-bench.c +++ b/driver/xf86-video-intel/test/lowlevel-blt-bench.c @@ -23,6 +23,10 @@ * DEALINGS IN THE SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -31,6 +35,20 @@ #include <X11/X.h> #include <X11/Xutil.h> /* for XDestroyImage */ +#include <X11/Xlibint.h> +#include <X11/extensions/Xrender.h> +#if HAVE_MIT_SHM +#include <X11/extensions/XShm.h> +#if HAVE_X11_EXTENSIONS_SHMPROTO_H +#include <X11/extensions/shmproto.h> +#elif HAVE_X11_EXTENSIONS_SHMSTR_H +#include <X11/extensions/shmstr.h> +#else +#error Failed to find the right header for X11 MIT-SHM protocol definitions +#endif +#include <sys/ipc.h> +#include <sys/shm.h> +#endif #include <pixman.h> /* for pixman blt functions */ #include "test.h" @@ -47,32 +65,264 @@ static const struct format { }; static const struct op { + int value; const char *name; } ops[] = { - [PictOpClear] = { "Clear" }, - [PictOpSrc] = { "Src" }, - [PictOpDst] = { "Dst" }, - [PictOpOver] = { "Over" }, - [PictOpOverReverse] = { "OverReverse" }, - [PictOpIn] = { "In" }, - [PictOpInReverse] = { "InReverse" }, - [PictOpOut] = { "Out" }, - [PictOpOutReverse] = { "OutReverse" }, - [PictOpAtop] = { "Atop" }, - [PictOpAtopReverse] = { "AtopReverse" }, - [PictOpXor] = { "Xor" }, - [PictOpAdd] = { "Add" }, - [PictOpSaturate] = { "Saturate" }, + { PictOpClear, "Clear" }, + { PictOpSrc, "Src" }, + { PictOpDst, "Dst" }, + { PictOpOver, "Over" }, + { PictOpOverReverse, "OverReverse" }, + { PictOpIn, "In" }, + { PictOpInReverse, "InReverse" }, + { PictOpOut, "Out" }, + { PictOpOutReverse, "OutReverse" }, + { PictOpAtop, "Atop" }, + { PictOpAtopReverse, "AtopReverse" }, + { PictOpXor, "Xor" }, + { PictOpAdd, "Add" }, + { PictOpSaturate, "Saturate" }, + { PictOpMultiply, "Multiply" }, + { PictOpScreen, "Screen" }, + { PictOpOverlay, "Overlay" }, + { PictOpDarken, "Darken" }, + { PictOpLighten, "Lighten" }, + { PictOpColorDodge, "Dodge" }, + { PictOpColorBurn, "Burn" }, + { PictOpHardLight, "HardLight" }, + { PictOpSoftLight, "SoftLight" }, }; -static double _bench(struct test_display *t, enum target target_type, - int op, int src_format, - int loops) +static Picture source_pixmap(struct test_display *t, struct test_target *target, int format) +{ + XRenderColor render_color[2] = { + { 0x8000, 0x8000, 0x8000, 0x8000 }, + { 0xffff, 0xffff, 0xffff, 0xffff }, + }; + Pixmap pixmap; + Picture picture; + + pixmap = XCreatePixmap(t->dpy, t->root, + target->width, target->height, + PIXMAN_FORMAT_DEPTH(formats[format].pixman_format)); + + picture = XRenderCreatePicture(t->dpy, pixmap, + XRenderFindStandardFormat(t->dpy, format), + 0, NULL); + XFreePixmap(t->dpy, pixmap); + + XRenderFillRectangle(t->dpy, PictOpSrc, picture, &render_color[0], + 0, 0, target->width, target->height/2); + XRenderFillRectangle(t->dpy, PictOpSrc, picture, &render_color[1], + 0, target->height/2, target->width, target->height/2); + + return picture; +} + +static Picture source_a8r8g8b8(struct test_display *t, struct test_target *target) +{ + return source_pixmap(t, target, 0); +} + +static Picture source_x8r8g8b8(struct test_display *t, struct test_target *target) +{ + return source_pixmap(t, target, 1); +} + +static Picture source_a8(struct test_display *t, struct test_target *target) +{ + return source_pixmap(t, target, 2); +} + +static Picture source_a4(struct test_display *t, struct test_target *target) +{ + return source_pixmap(t, target, 3); +} + +static Picture source_a1(struct test_display *t, struct test_target *target) +{ + return source_pixmap(t, target, 3); +} + +static Picture source_1x1r(struct test_display *t, struct test_target *target) { XRenderColor render_color = { 0x8000, 0x8000, 0x8000, 0x8000 }; - struct test_target target; + XRenderPictureAttributes pa; + Pixmap pixmap; + Picture picture; + + pa.repeat = RepeatNormal; + + pixmap = XCreatePixmap(t->dpy, t->root, 1, 1, 32); + picture = XRenderCreatePicture(t->dpy, pixmap, + XRenderFindStandardFormat(t->dpy, 0), + CPRepeat, &pa); + XFreePixmap(t->dpy, pixmap); + + XRenderFillRectangle(t->dpy, PictOpSrc, picture, &render_color, + 0, 0, 1, 1); + + return picture; +} + +static Picture source_solid(struct test_display *t, struct test_target *target) +{ + XRenderColor render_color = { 0x8000, 0x8000, 0x8000, 0x8000 }; + return XRenderCreateSolidFill(t->dpy, &render_color); +} + +static Picture source_linear_horizontal(struct test_display *t, struct test_target *target) +{ + XRenderColor colors[2] = {{0}, {0xffff, 0xffff, 0xffff, 0xffff}}; + XFixed stops[2] = {0, 0xffff}; + XLinearGradient gradient = { {0, 0}, {target->width << 16, 0}}; + + return XRenderCreateLinearGradient(t->dpy, &gradient, stops, colors, 2); +} + +static Picture source_linear_vertical(struct test_display *t, struct test_target *target) +{ + XRenderColor colors[2] = {{0}, {0xffff, 0xffff, 0xffff, 0xffff}}; + XFixed stops[2] = {0, 0xffff}; + XLinearGradient gradient = { {0, 0}, {0, target->height << 16}}; + + return XRenderCreateLinearGradient(t->dpy, &gradient, stops, colors, 2); +} + +static Picture source_linear_diagonal(struct test_display *t, struct test_target *target) +{ + XRenderColor colors[2] = {{0}, {0xffff, 0xffff, 0xffff, 0xffff}}; + XFixed stops[2] = {0, 0xffff}; + XLinearGradient gradient = { {0, 0}, {target->width << 16, target->height << 16}}; + + return XRenderCreateLinearGradient(t->dpy, &gradient, stops, colors, 2); +} + +static Picture source_radial_concentric(struct test_display *t, struct test_target *target) +{ + XRenderColor colors[2] = {{0}, {0xffff, 0xffff, 0xffff, 0xffff}}; + XFixed stops[2] = {0, 0xffff}; + XRadialGradient gradient = { + { + ((target->width << 16) + 1) / 2, + ((target->height << 16) + 1) / 2, + 0, + }, + { + ((target->width << 16) + 1) / 2, + ((target->height << 16) + 1) / 2, + target->width << 15, + } + }; + + return XRenderCreateRadialGradient(t->dpy, &gradient, stops, colors, 2); +} + +static Picture source_radial_generic(struct test_display *t, struct test_target *target) +{ + XRenderColor colors[2] = {{0}, {0xffff, 0xffff, 0xffff, 0xffff}}; + XFixed stops[2] = {0, 0xffff}; + XRadialGradient gradient = { + { 0, 0, target->width << 14, }, + { target->width << 16, target->height << 16, target->width << 14, } + }; + + return XRenderCreateRadialGradient(t->dpy, &gradient, stops, colors, 2); +} + +#if HAVE_MIT_SHM +static XShmSegmentInfo shmref, shmout; + +static void setup_shm(struct test *t) +{ + XShmSegmentInfo shm; + int size; + + shm.shmid = -1; + + if (!(t->ref.has_shm_pixmaps && t->out.has_shm_pixmaps)) + return; + + size = t->ref.width * t->ref.height * 4; + size = (size + 4095) & -4096; + + shm.shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0666); + if (shm.shmid == -1) + return; + + shm.shmaddr = shmat(shm.shmid, 0, 0); + if (shm.shmaddr == (char *) -1) { + shmctl(shm.shmid, IPC_RMID, NULL); + shm.shmid = -1; + return; + } + + shm.readOnly = False; + + shmref = shm; + XShmAttach(t->ref.dpy, &shmref); + XSync(t->ref.dpy, True); + + shmout = shm; + XShmAttach(t->out.dpy, &shmout); + XSync(t->out.dpy, True); +} + +static Picture source_shm(struct test_display *t, struct test_target *target) +{ + XShmSegmentInfo *shm = t->target == REF ? &shmref : &shmout; Pixmap pixmap; Picture picture; + int size; + + if (shm->shmid == -1) + return 0; + + pixmap = XShmCreatePixmap(t->dpy, t->root, + shm->shmaddr, shm, + target->width, target->height, 32); + + picture = XRenderCreatePicture(t->dpy, pixmap, + XRenderFindStandardFormat(t->dpy, 0), + 0, NULL); + XFreePixmap(t->dpy, pixmap); + + size = target->width * target->height * 4; + memset(shm->shmaddr, 0x80, size/2); + memset(shm->shmaddr+size/2, 0xff, size/2); + + return picture; +} +#else +static void setup_shm(struct test *t) { } +static Picture source_shm(struct test_display *t, struct test_target *target) { return 0; } +#endif + +static const struct { + Picture (*create)(struct test_display *, struct test_target *); + const char *name; +} source[] = { + { source_a8r8g8b8, "a8r8g8b8 pixmap" }, + { source_x8r8g8b8, "x8r8g8b8 pixmap" }, + { source_a8, "a8 pixmap" }, + { source_a4, "a4 pixmap" }, + { source_a1, "a1 pixmap" }, + { source_1x1r, "a8r8g8b8 1x1R pixmap" }, + { source_solid, "solid" }, + { source_shm, "a8r8g8b8 shm" }, + { source_linear_horizontal, "linear (horizontal gradient)" }, + { source_linear_vertical, "linear (vertical gradient)" }, + { source_linear_diagonal, "linear (diagonal gradient)" }, + { source_radial_concentric, "radial (concentric)" }, + { source_radial_generic, "radial (generic)" }, +}; + +static double _bench_source(struct test_display *t, enum target target_type, + int op, int src, int loops) +{ + XRenderColor render_color = { 0x8000, 0x8000, 0x8000, 0x8000 }; + struct test_target target; + Picture picture; struct timespec tv; double elapsed; @@ -80,54 +330,134 @@ static double _bench(struct test_display *t, enum target target_type, XRenderFillRectangle(t->dpy, PictOpClear, target.picture, &render_color, 0, 0, target.width, target.height); - pixmap = XCreatePixmap(t->dpy, t->root, - target.width, target.height, - PIXMAN_FORMAT_DEPTH(formats[src_format].pixman_format)); + picture = source[src].create(t, &target); + if (picture) { + test_timer_start(t, &tv); + while (loops--) + XRenderComposite(t->dpy, op, + picture, 0, target.picture, + 0, 0, + 0, 0, + 0, 0, + target.width, target.height); + elapsed = test_timer_stop(t, &tv); + XRenderFreePicture(t->dpy, picture); + } else + elapsed = -1; - picture = XRenderCreatePicture(t->dpy, pixmap, - XRenderFindStandardFormat(t->dpy, src_format), - 0, NULL); - XRenderFillRectangle(t->dpy, PictOpSrc, picture, &render_color, + test_target_destroy_render(t, &target); + + return elapsed; +} + +static void bench_source(struct test *t, enum target target, int op, int src) +{ + double out, ref; + + fprintf(stdout, "%28s with %s: ", source[src].name, ops[op].name); + fflush(stdout); + + op = ops[op].value; + + ref = _bench_source(&t->ref, target, op, src, 1000); + if (ref < 0) { + fprintf(stdout, "SKIP\n"); + return; + } + fprintf(stdout, "ref=%f, ", ref); + fflush(stdout); + + out = _bench_source(&t->out, target, op, src, 1000); + if (out < 0) { + fprintf(stdout, "SKIP\n"); + return; + } + + fprintf(stdout, "out=%f\n", out); +} + +static double _bench_mask(struct test_display *t, enum target target_type, + int op, int src, int mask, int loops) +{ + XRenderColor render_color = { 0x8000, 0x8000, 0x8000, 0x8000 }; + struct test_target target; + Picture ps, pm; + struct timespec tv; + double elapsed; + + test_target_create_render(t, target_type, &target); + XRenderFillRectangle(t->dpy, PictOpClear, target.picture, &render_color, 0, 0, target.width, target.height); - test_timer_start(t, &tv); - while (loops--) - XRenderComposite(t->dpy, op, - picture, 0, target.picture, - 0, 0, - 0, 0, - 0, 0, - target.width, target.height); - elapsed = test_timer_stop(t, &tv); - - XRenderFreePicture(t->dpy, picture); - XFreePixmap(t->dpy, pixmap); + ps = source[src].create(t, &target); + pm = source[mask].create(t, &target); + if (ps && pm) { + test_timer_start(t, &tv); + while (loops--) + XRenderComposite(t->dpy, op, + ps, pm, target.picture, + 0, 0, + 0, 0, + 0, 0, + target.width, target.height); + elapsed = test_timer_stop(t, &tv); + } else + elapsed = -1; + + if (ps) + XRenderFreePicture(t->dpy, ps); + if (pm) + XRenderFreePicture(t->dpy, pm); + test_target_destroy_render(t, &target); return elapsed; } -static void bench(struct test *t, enum target target, int op, int sf) +static void bench_mask(struct test *t, enum target target, int op, int src, int mask) { - double real, ref; + double out, ref; - ref = _bench(&t->ref, target, op, sf, 1000); - real = _bench(&t->real, target, op, sf, 1000); + fprintf(stdout, "%28s In %28s with %s: ", + source[src].name, source[mask].name, ops[op].name); + fflush(stdout); - fprintf (stdout, "Testing %s with %s: ref=%f, real=%f\n", - formats[sf].name, ops[op].name, ref, real); + op = ops[op].value; + + ref = _bench_mask(&t->ref, target, op, src, mask, 1000); + if (ref < 0) { + fprintf(stdout, "SKIP\n"); + return; + } + fprintf(stdout, "ref=%f, ", ref); + fflush(stdout); + + out = _bench_mask(&t->out, target, op, src, mask, 1000); + if (out < 0) { + fprintf(stdout, "SKIP\n"); + return; + } + + fprintf(stdout, "out=%f\n", out); } int main(int argc, char **argv) { struct test test; - unsigned op, sf; + unsigned op, src, mask; test_init(&test, argc, argv); + setup_shm(&test); + for (op = 0; op < sizeof(ops)/sizeof(ops[0]); op++) { - for (sf = 0; sf < sizeof(formats)/sizeof(formats[0]); sf++) - bench(&test, ROOT, op, sf); + for (src = 0; src < sizeof(source)/sizeof(source[0]); src++) + bench_source(&test, ROOT, op, src); + fprintf (stdout, "\n"); + + for (src = 0; src < sizeof(source)/sizeof(source[0]); src++) + for (mask = 0; mask < sizeof(source)/sizeof(source[0]); mask++) + bench_mask(&test, ROOT, op, src, mask); fprintf (stdout, "\n"); } diff --git a/driver/xf86-video-intel/test/mixed-stress.c b/driver/xf86-video-intel/test/mixed-stress.c index a315a9c44..94fa846ae 100644 --- a/driver/xf86-video-intel/test/mixed-stress.c +++ b/driver/xf86-video-intel/test/mixed-stress.c @@ -43,19 +43,19 @@ static void _render_copy(struct test_target *tt, XFreePixmap(tt->dpy->dpy, tmp); } -static void render_copy(struct test_target *real, +static void render_copy(struct test_target *out, struct test_target *ref) { - int x = rand() % (2*real->width) - real->width; - int y = rand() % (2*real->height) - real->height; - int w = rand() % (2*real->width); - int h = rand() % (2*real->height); + int x = rand() % (2*out->width) - out->width; + int y = rand() % (2*out->height) - out->height; + int w = rand() % (2*out->width); + int h = rand() % (2*out->height); int red = rand() & 0xff; int green = rand() & 0xff; int blue = rand() & 0xff; int alpha = rand() & 0xff; - _render_copy(real, x, y, w, h, red, green, blue, alpha); + _render_copy(out, x, y, w, h, red, green, blue, alpha); _render_copy(ref, x, y, w, h, red, green, blue, alpha); } @@ -79,36 +79,36 @@ static void clear(struct test_target *tt) 0, 0, tt->width, tt->height); } -static void basic_fill(struct test_target *real, +static void basic_fill(struct test_target *out, struct test_target *ref) { - int x = rand() % (2*real->width) - real->width; - int y = rand() % (2*real->height) - real->height; - int w = rand() % (2*real->width); - int h = rand() % (2*real->height); + int x = rand() % (2*out->width) - out->width; + int y = rand() % (2*out->height) - out->height; + int w = rand() % (2*out->width); + int h = rand() % (2*out->height); int color = rand(); int alu = rand() % 16; - fill_rect(real, alu, color, x, y, w, h); + fill_rect(out, alu, color, x, y, w, h); fill_rect(ref, alu, color, x, y, w, h); } -static void basic_copy(struct test_target *real, +static void basic_copy(struct test_target *out, struct test_target *ref) { - int sx = rand() % (2*real->width) - ref->width; - int sy = rand() % (2*real->height) - ref->height; - int dx = rand() % (2*real->width) - ref->width; - int dy = rand() % (2*real->height) - ref->height; - int w = rand() % (2*real->width); - int h = rand() % (2*real->height); + int sx = rand() % (2*out->width) - ref->width; + int sy = rand() % (2*out->height) - ref->height; + int dx = rand() % (2*out->width) - ref->width; + int dy = rand() % (2*out->height) - ref->height; + int w = rand() % (2*out->width); + int h = rand() % (2*out->height); XGCValues val; val.function = rand() % 16; - XChangeGC(real->dpy->dpy, real->gc, GCFunction, &val); - XCopyArea(real->dpy->dpy, - real->draw, real->draw, real->gc, + XChangeGC(out->dpy->dpy, out->gc, GCFunction, &val); + XCopyArea(out->dpy->dpy, + out->draw, out->draw, out->gc, sx, sy, w, h, dx, dy); XChangeGC(ref->dpy->dpy, ref->gc, GCFunction, &val); @@ -142,23 +142,23 @@ static void _put(struct test_target *tt, } } -static void basic_put(struct test_target *real, +static void basic_put(struct test_target *out, struct test_target *ref) { - int x = rand() % (2*real->width) - real->width; - int y = rand() % (2*real->height) - real->height; - int w = rand() % real->width; - int h = rand() % real->height; + int x = rand() % (2*out->width) - out->width; + int y = rand() % (2*out->height) - out->height; + int w = rand() % out->width; + int h = rand() % out->height; int color = rand(); int alu = rand() % 16; - _put(real, x, y, w, h, color, alu); + _put(out, x, y, w, h, color, alu); _put(ref, x, y, w, h, color, alu); } static void rect_tests(struct test *test, int iterations, enum target target) { - struct test_target real, ref; + struct test_target out, ref; void (* const ops[])(struct test_target *, struct test_target *) = { basic_copy, basic_fill, @@ -171,24 +171,24 @@ static void rect_tests(struct test *test, int iterations, enum target target) test_target_name(target)); fflush(stdout); - test_target_create_render(&test->real, target, &real); + test_target_create_render(&test->out, target, &out); test_target_create_render(&test->ref, target, &ref); - clear(&real); + clear(&out); clear(&ref); for (n = 0; n < iterations; n++) - ops[rand() % ARRAY_SIZE(ops)](&real, &ref); + ops[rand() % ARRAY_SIZE(ops)](&out, &ref); test_compare(test, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); printf("passed [%d iterations]\n", n); - test_target_destroy_render(&test->real, &real); + test_target_destroy_render(&test->out, &out); test_target_destroy_render(&test->ref, &ref); } diff --git a/driver/xf86-video-intel/test/present-test.c b/driver/xf86-video-intel/test/present-test.c new file mode 100644 index 000000000..6b562eb00 --- /dev/null +++ b/driver/xf86-video-intel/test/present-test.c @@ -0,0 +1,726 @@ +/* + * Copyright (c) 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/Xlib.h> +#include <X11/Xlib-xcb.h> +#include <X11/xshmfence.h> +#include <X11/Xutil.h> +#include <X11/Xlibint.h> +#include <X11/extensions/randr.h> +#include <X11/extensions/Xrandr.h> +#include <X11/extensions/Xrender.h> +#include <X11/extensions/XShm.h> +#if HAVE_X11_EXTENSIONS_SHMPROTO_H +#include <X11/extensions/shmproto.h> +#elif HAVE_X11_EXTENSIONS_SHMSTR_H +#include <X11/extensions/shmstr.h> +#else +#error Failed to find the right header for X11 MIT-SHM protocol definitions +#endif +#include <xcb/xcb.h> +#include <xcb/present.h> +#include <xf86drm.h> +#include <i915_drm.h> + +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <unistd.h> +#include <assert.h> +#include <errno.h> +#include <setjmp.h> +#include <signal.h> + +#include <sys/mman.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <pciaccess.h> + +#include "dri3.h" + +#define ALIGN(x, y) (((x) + (y) - 1) & -(y)) +#define PAGE_ALIGN(x) ALIGN(x, 4096) + +#define GTT I915_GEM_DOMAIN_GTT +#define CPU I915_GEM_DOMAIN_CPU + +static int _x_error_occurred; +static uint32_t stamp; + +static int +_check_error_handler(Display *display, + XErrorEvent *event) +{ + printf("X11 error from display %s, serial=%ld, error=%d, req=%d.%d\n", + DisplayString(display), + event->serial, + event->error_code, + event->request_code, + event->minor_code); + _x_error_occurred++; + return False; /* ignored */ +} + +static int is_i915_device(int fd) +{ + drm_version_t version; + char name[5] = ""; + + memset(&version, 0, sizeof(version)); + version.name_len = 4; + version.name = name; + + if (drmIoctl(fd, DRM_IOCTL_VERSION, &version)) + return 0; + + return strcmp("i915", name) == 0; +} + +static int is_intel(int fd) +{ + struct drm_i915_getparam gp; + int ret; + + /* Confirm that this is a i915.ko device with GEM/KMS enabled */ + ret = is_i915_device(fd); + if (ret) { + gp.param = I915_PARAM_HAS_GEM; + gp.value = &ret; + if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) + ret = 0; + } + return ret; +} + +static void *setup_msc(Display *dpy, Window win) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_void_cookie_t cookie; + uint32_t id = xcb_generate_id(c); + xcb_generic_error_t *error; + void *q; + + cookie = xcb_present_select_input_checked(c, id, win, XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY); + q = xcb_register_for_special_xge(c, &xcb_present_id, id, &stamp); + + error = xcb_request_check(c, cookie); + assert(error == NULL); + + return q; +} + +static uint64_t check_msc(Display *dpy, Window win, void *q, uint64_t last_msc) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + uint64_t msc = 0; + + xcb_present_notify_msc(c, win, 0, 0, 0, 0); + xcb_flush(c); + + do { + xcb_present_complete_notify_event_t *ce; + xcb_generic_event_t *ev; + + ev = xcb_wait_for_special_event(c, q); + if (ev == NULL) + break; + + ce = (xcb_present_complete_notify_event_t *)ev; + if (ce->kind != XCB_PRESENT_COMPLETE_KIND_PIXMAP) + msc = ce->msc; + free(ev); + } while (msc == 0); + + if (msc < last_msc) { + printf("Invalid MSC: was %llu, now %llu\n", + (long long)last_msc, (long long)msc); + } + + return msc; +} + +static void teardown_msc(Display *dpy, void *q) +{ + xcb_unregister_for_special_event(XGetXCBConnection(dpy), q); +} +static int test_whole(Display *dpy) +{ + Pixmap pixmap; + struct dri3_fence fence; + Window root; + unsigned int width, height; + unsigned border, depth; + int x, y, ret = 1; + + XGetGeometry(dpy, DefaultRootWindow(dpy), + &root, &x, &y, &width, &height, &border, &depth); + + if (dri3_create_fence(dpy, root, &fence)) + return 0; + + printf("Testing whole screen flip: %dx%d\n", width, height); + _x_error_occurred = 0; + + xshmfence_reset(fence.addr); + + pixmap = XCreatePixmap(dpy, root, width, height, depth); + xcb_present_pixmap(XGetXCBConnection(dpy), + root, pixmap, + 0, /* sbc */ + 0, /* valid */ + 0, /* update */ + 0, /* x_off */ + 0, /* y_off */ + None, + None, /* wait fence */ + fence.xid, + XCB_PRESENT_OPTION_NONE, + 0, /* target msc */ + 0, /* divisor */ + 0, /* remainder */ + 0, NULL); + XFreePixmap(dpy, pixmap); + + pixmap = XCreatePixmap(dpy, root, width, height, depth); + xcb_present_pixmap(XGetXCBConnection(dpy), + root, pixmap, + 0, /* sbc */ + 0, /* valid */ + 0, /* update */ + 0, /* x_off */ + 0, /* y_off */ + None, + None, /* wait fence */ + None, /* sync fence */ + XCB_PRESENT_OPTION_NONE, + 0, /* target msc */ + 0, /* divisor */ + 0, /* remainder */ + 0, NULL); + XFreePixmap(dpy, pixmap); + XFlush(dpy); + + ret = !!xshmfence_await(fence.addr); + dri3_fence_free(dpy, &fence); + + XSync(dpy, True); + ret += !!_x_error_occurred; + + return ret; +} + +static inline XRRScreenResources *_XRRGetScreenResourcesCurrent(Display *dpy, Window window) +{ + XRRScreenResources *res; + + res = XRRGetScreenResourcesCurrent(dpy, window); + if (res == NULL) + res = XRRGetScreenResources(dpy, window); + + return res; +} + +static XRRModeInfo *lookup_mode(XRRScreenResources *res, int id) +{ + int i; + + for (i = 0; i < res->nmode; i++) { + if (res->modes[i].id == id) + return &res->modes[i]; + } + + return NULL; +} + +static int for_each_crtc(Display *dpy, + int (*func)(Display *dpy, + RRCrtc crtc, + int width, int height, + void *closure), + void *closure) +{ + XRRScreenResources *res; + XRRCrtcInfo **original_crtc; + int i, j, err = 0; + + if (!XRRQueryVersion(dpy, &i, &j)) + return -1; + + res = _XRRGetScreenResourcesCurrent(dpy, DefaultRootWindow(dpy)); + if (res == NULL) + return -1; + + original_crtc = malloc(sizeof(XRRCrtcInfo *)*res->ncrtc); + for (i = 0; i < res->ncrtc; i++) + original_crtc[i] = XRRGetCrtcInfo(dpy, res, res->crtcs[i]); + + printf("noutput=%d, ncrtc=%d\n", res->noutput, res->ncrtc); + + for (i = 0; i < res->noutput; i++) { + XRROutputInfo *output; + XRRModeInfo *mode; + + output = XRRGetOutputInfo(dpy, res, res->outputs[i]); + if (output == NULL) + continue; + + mode = NULL; + if (res->nmode) + mode = lookup_mode(res, output->modes[0]); + + for (j = 0; mode && j < output->ncrtc; j++) { + printf("[%d, %d] -- OUTPUT:%ld, CRTC:%ld\n", + i, j, (long)res->outputs[i], (long)output->crtcs[j]); + XRRSetCrtcConfig(dpy, res, output->crtcs[j], CurrentTime, + 0, 0, output->modes[0], RR_Rotate_0, &res->outputs[i], 1); + XSync(dpy, True); + + err += func(dpy, output->crtcs[j], mode->width, mode->height, closure); + + XRRSetCrtcConfig(dpy, res, output->crtcs[j], CurrentTime, + 0, 0, None, RR_Rotate_0, NULL, 0); + XSync(dpy, True); + } + + XRRFreeOutputInfo(output); + } + + for (i = 0; i < res->ncrtc; i++) + XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, + original_crtc[i]->x, + original_crtc[i]->y, + original_crtc[i]->mode, + original_crtc[i]->rotation, + original_crtc[i]->outputs, + original_crtc[i]->noutput); + + free(original_crtc); + XRRFreeScreenResources(res); + + return j; +} + +struct test_crtc { + Window win; + int depth; + unsigned flags; + + struct dri3_fence fence; + void *queue; + uint64_t msc; +}; +#define SYNC 0x1 + +static int __test_crtc(Display *dpy, RRCrtc crtc, + int width, int height, + void *closure) +{ + struct test_crtc *test = closure; + Pixmap pixmap; + int err = 0; + + test->msc = check_msc(dpy, test->win, test->queue, test->msc); + + if (test->flags & SYNC) + xshmfence_reset(test->fence.addr); + + pixmap = XCreatePixmap(dpy, test->win, width, height, test->depth); + xcb_present_pixmap(XGetXCBConnection(dpy), + test->win, pixmap, + 0, /* sbc */ + 0, /* valid */ + 0, /* update */ + 0, /* x_off */ + 0, /* y_off */ + crtc, + None, /* wait fence */ + test->flags & SYNC ? test->fence.xid : None, + XCB_PRESENT_OPTION_NONE, + 0, /* target msc */ + 1, /* divisor */ + 0, /* remainder */ + 0, NULL); + XFreePixmap(dpy, pixmap); + + if (test->flags & SYNC) { + pixmap = XCreatePixmap(dpy, test->win, width, height, test->depth); + xcb_present_pixmap(XGetXCBConnection(dpy), + test->win, pixmap, + 1, /* sbc */ + 0, /* valid */ + 0, /* update */ + 0, /* x_off */ + 0, /* y_off */ + crtc, + None, /* wait fence */ + None, /* sync fence */ + XCB_PRESENT_OPTION_NONE, + 1, /* target msc */ + 1, /* divisor */ + 0, /* remainder */ + 0, NULL); + XFreePixmap(dpy, pixmap); + XFlush(dpy); + err += !!xshmfence_await(test->fence.addr); + } + + test->msc = check_msc(dpy, test->win, test->queue, test->msc); + return err; +} + +static int test_crtc(Display *dpy, void *queue, uint64_t last_msc) +{ + struct test_crtc test; + int err = 0; + + XSync(dpy, True); + _x_error_occurred = 0; + + test.win = DefaultRootWindow(dpy); + test.depth = DefaultDepth(dpy, DefaultScreen(dpy)); + if (dri3_create_fence(dpy, test.win, &test.fence)) + return -1; + test.queue = queue; + test.msc = last_msc; + + printf("Testing each crtc, without waiting for each flip\n"); + test.flags = 0; + err += for_each_crtc(dpy, __test_crtc, &test); + + printf("Testing each crtc, waiting for flips to complete\n"); + test.flags = SYNC; + err += for_each_crtc(dpy, __test_crtc, &test); + + test.msc = check_msc(dpy, test.win, test.queue, test.msc); + dri3_fence_free(dpy, &test.fence); + + XSync(dpy, True); + err += !!_x_error_occurred; + + if (err) + printf("%s: failures=%d\n", __func__, err); + + return err; +} + +static int +can_use_shm(Display *dpy) +{ + int major, minor, has_pixmap; + + if (!XShmQueryExtension(dpy)) + return 0; + + XShmQueryVersion(dpy, &major, &minor, &has_pixmap); + return has_pixmap; +} + +static int test_shm(Display *dpy) +{ + Window win = DefaultRootWindow(dpy); + XShmSegmentInfo shm; + Pixmap pixmap; + Window root; + unsigned int width, height; + unsigned border, depth; + int x, y, ret = 1; + + if (!can_use_shm(dpy)) + return 0; + + _x_error_occurred = 0; + + XGetGeometry(dpy, win, &root, &x, &y, + &width, &height, &border, &depth); + + printf("Using %dx%d SHM\n", width, height); + + shm.shmid = shmget(IPC_PRIVATE, height * 4*width, IPC_CREAT | 0666); + if (shm.shmid == -1) + return 0; + + shm.shmaddr = shmat(shm.shmid, 0, 0); + if (shm.shmaddr == (char *) -1) + goto rmid; + + shm.readOnly = False; + XShmAttach(dpy, &shm); + + pixmap = XShmCreatePixmap(dpy, DefaultRootWindow(dpy), + shm.shmaddr, &shm, width, height, 24); + if (_x_error_occurred) + goto detach; + + xcb_present_pixmap(XGetXCBConnection(dpy), + win, pixmap, + 0, /* sbc */ + 0, /* valid */ + 0, /* update */ + 0, /* x_off */ + 0, /* y_off */ + None, + None, /* wait fence */ + None, + XCB_PRESENT_OPTION_NONE, + 0, /* target msc */ + 0, /* divisor */ + 0, /* remainder */ + 0, NULL); + XFreePixmap(dpy, pixmap); + + XSync(dpy, True); + if (_x_error_occurred) + goto detach; + + ret = 0; +detach: + XShmDetach(dpy, &shm); + shmdt(shm.shmaddr); + XSync(dpy, False); +rmid: + shmctl(shm.shmid, IPC_RMID, NULL); + return ret; +} + +static uint32_t gem_create(int fd, int size) +{ + struct drm_i915_gem_create create; + + create.handle = 0; + create.size = size; + (void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create); + + return create.handle; +} + +struct local_i915_gem_caching { + uint32_t handle; + uint32_t caching; +}; + +#define LOCAL_I915_GEM_SET_CACHING 0x2f +#define LOCAL_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + LOCAL_I915_GEM_SET_CACHING, struct local_i915_gem_caching) + +static int gem_set_caching(int fd, uint32_t handle, int caching) +{ + struct local_i915_gem_caching arg; + + arg.handle = handle; + arg.caching = caching; + + return drmIoctl(fd, LOCAL_IOCTL_I915_GEM_SET_CACHING, &arg) == 0; +} + +static int gem_export(int fd, uint32_t handle) +{ + struct drm_prime_handle args; + + args.handle = handle; + args.flags = O_CLOEXEC; + + if (drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args)) + return -1; + + return args.fd; +} + +static void gem_close(int fd, uint32_t handle) +{ + struct drm_gem_close close; + + close.handle = handle; + (void)drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &close); +} + +static int test_dri3(Display *dpy) +{ + Window win = DefaultRootWindow(dpy); + Pixmap pixmap; + Window root; + unsigned int width, height; + unsigned border, depth; + unsigned stride, size; + int x, y, ret = 1; + int device, handle; + int bpp; + + device = dri3_open(dpy); + if (device < 0) + return 0; + + if (!is_intel(device)) + return 0; + + printf("Opened Intel DRI3 device\n"); + + XGetGeometry(dpy, win, &root, &x, &y, + &width, &height, &border, &depth); + + switch (depth) { + case 8: bpp = 8; break; + case 15: case 16: bpp = 16; break; + case 24: case 32: bpp = 32; break; + default: return 0; + } + + stride = width * bpp/8; + size = PAGE_ALIGN(stride * height); + printf("Creating DRI3 %dx%d (source stride=%d, size=%d) for GTT\n", + width, height, stride, size); + + pixmap = 0; + handle = gem_create(device, size); + if (handle) { + pixmap = dri3_create_pixmap(dpy, root, + width, height, depth, + gem_export(device, handle), bpp, stride, size); + gem_close(device, handle); + } + if (pixmap == 0) + goto fail; + + xcb_present_pixmap(XGetXCBConnection(dpy), + win, pixmap, + 0, /* sbc */ + 0, /* valid */ + 0, /* update */ + 0, /* x_off */ + 0, /* y_off */ + None, + None, /* wait fence */ + None, + XCB_PRESENT_OPTION_NONE, + 0, /* target msc */ + 0, /* divisor */ + 0, /* remainder */ + 0, NULL); + XFreePixmap(dpy, pixmap); + + XSync(dpy, True); + if (_x_error_occurred) + goto fail; + + printf("Creating DRI3 %dx%d (source stride=%d, size=%d) for CPU\n", + width, height, stride, size); + + pixmap = 0; + handle = gem_create(device, size); + if (handle) { + gem_set_caching(device, handle, CPU); + handle = dri3_create_pixmap(dpy, root, + width, height, depth, + gem_export(device, handle), bpp, stride, size); + gem_close(device, handle); + } + if (pixmap == 0) + goto fail; + + xcb_present_pixmap(XGetXCBConnection(dpy), + win, pixmap, + 0, /* sbc */ + 0, /* valid */ + 0, /* update */ + 0, /* x_off */ + 0, /* y_off */ + None, + None, /* wait fence */ + None, + XCB_PRESENT_OPTION_NONE, + 0, /* target msc */ + 0, /* divisor */ + 0, /* remainder */ + 0, NULL); + XFreePixmap(dpy, pixmap); + + XSync(dpy, True); + if (_x_error_occurred) + goto fail; + + ret = 0; +fail: + close(device); + return ret; +} + +static int has_present(Display *dpy) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_present_query_version_reply_t *reply; + xcb_generic_error_t *error = NULL; + + reply = xcb_present_query_version_reply(c, + xcb_present_query_version(c, + XCB_PRESENT_MAJOR_VERSION, + XCB_PRESENT_MINOR_VERSION), + &error); + + free(reply); + free(error); + + return reply != NULL; +} + +int main(void) +{ + Display *dpy; + Window root; + int error = 0; + uint64_t last_msc; + void *queue; + + dpy = XOpenDisplay(NULL); + if (dpy == NULL) + return 77; + + if (!has_present(dpy)) + return 77; + + root = DefaultRootWindow(dpy); + + signal(SIGALRM, SIG_IGN); + XSetErrorHandler(_check_error_handler); + + queue = setup_msc(dpy, root); + last_msc = check_msc(dpy, root, queue, 0); + + error += test_whole(dpy); + last_msc = check_msc(dpy, root, queue, last_msc); + + error += test_crtc(dpy, queue, last_msc); + last_msc = check_msc(dpy, root, queue, last_msc); + + error += test_shm(dpy); + last_msc = check_msc(dpy, root, queue, last_msc); + + error += test_dri3(dpy); + last_msc = check_msc(dpy, root, queue, last_msc); + + teardown_msc(dpy, queue); + + return !!error; +} diff --git a/driver/xf86-video-intel/test/render-composite-solid-mask.c b/driver/xf86-video-intel/test/render-composite-solid-mask.c index 925df3ca8..b035e502d 100644 --- a/driver/xf86-video-intel/test/render-composite-solid-mask.c +++ b/driver/xf86-video-intel/test/render-composite-solid-mask.c @@ -48,24 +48,24 @@ static void clear(struct test_display *dpy, struct test_target *tt) static void ref_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % real.width; - int h = rand() % real.height; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % out.width; + int h = rand() % out.height; int op = ops[rand() % sizeof(ops)]; int s_red = rand() % 0xff; int s_green = rand() % 0xff; @@ -76,7 +76,7 @@ static void ref_tests(struct test *t, int reps, int sets, enum target target) int m_blue = rand() % 0xff; int m_alpha = rand() % 0xff; - fill_rect(&t->real, real.picture, + fill_rect(&t->out, out.picture, op, x, y, w, h, s_red, s_green, s_blue, s_alpha, m_red, m_green, m_blue, m_alpha); @@ -87,15 +87,15 @@ static void ref_tests(struct test *t, int reps, int sets, enum target target) } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/render-composite-solid.c b/driver/xf86-video-intel/test/render-composite-solid.c index b4742af38..9d779be2e 100644 --- a/driver/xf86-video-intel/test/render-composite-solid.c +++ b/driver/xf86-video-intel/test/render-composite-solid.c @@ -34,13 +34,13 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); int r, s; - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); printf("Testing setting of single pixels (%s): ", test_target_name(target)); @@ -55,7 +55,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) int blue = rand() % 0xff; int alpha = rand() % 0xff; - fill_rect(&t->real, tt.picture, PictOpSrc, + fill_rect(&t->out, tt.picture, PictOpSrc, x, y, 1, 1, red, green, blue, alpha); @@ -64,14 +64,14 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) cells[y*tt.width+x] = color(red, green, blue, alpha); } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t result; uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -93,7 +93,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); } @@ -109,16 +109,16 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -132,7 +132,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) x = rand() % (2*tt.width) - tt.width; y = rand() % (2*tt.height) - tt.height; - fill_rect(&t->real, tt.picture, PictOpSrc, + fill_rect(&t->out, tt.picture, PictOpSrc, x, y, w, h, red, green, blue, alpha); if (x < 0) @@ -153,7 +153,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) color(red, green, blue, alpha)); } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -179,37 +179,37 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } static void rect_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % real.width; - int h = rand() % real.height; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % out.width; + int h = rand() % out.height; int op = ops[rand() % sizeof(ops)]; int red = rand() % 0xff; int green = rand() % 0xff; int blue = rand() % 0xff; int alpha = rand() % 0xff; - fill_rect(&t->real, real.picture, + fill_rect(&t->out, out.picture, op, x, y, w, h, red, green, blue, alpha); fill_rect(&t->ref, ref.picture, @@ -218,15 +218,15 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target) } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/render-copy-alphaless.c b/driver/xf86-video-intel/test/render-copy-alphaless.c index 5f1487eb2..01c74a7ee 100644 --- a/driver/xf86-video-intel/test/render-copy-alphaless.c +++ b/driver/xf86-video-intel/test/render-copy-alphaless.c @@ -9,7 +9,7 @@ static void show_cells(char *buf, - const uint32_t *real, const uint32_t *ref, + const uint32_t *out, const uint32_t *ref, int x, int y, int w, int h) { int i, j, len = 0; @@ -22,7 +22,7 @@ show_cells(char *buf, if (i < 0 || i >= w) continue; - len += sprintf(buf+len, "%08x ", real[j*w+i]); + len += sprintf(buf+len, "%08x ", out[j*w+i]); } len += sprintf(buf+len, "\t"); @@ -68,13 +68,13 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); int r, s; - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); printf("Testing setting of single pixels (%s): ", test_target_name(target)); @@ -88,7 +88,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) uint8_t green = rand(); uint8_t blue = rand(); - fill_rect(&t->real, tt.picture, + fill_rect(&t->out, tt.picture, x, y, 1, 1, red, green, blue); @@ -97,14 +97,14 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) cells[y*tt.width+x] = color(red, green, blue, 0xff); } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; uint32_t result; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -123,7 +123,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); } @@ -139,16 +139,16 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -161,7 +161,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) x = rand() % (2*tt.width) - tt.width; y = rand() % (2*tt.height) - tt.height; - fill_rect(&t->real, tt.picture, + fill_rect(&t->out, tt.picture, x, y, w, h, red, green, blue); @@ -183,7 +183,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) color(red, green, blue, 0xff)); } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -211,20 +211,20 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } static void rect_tests(struct test *t, int reps, int sets, enum target target, int use_window) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s, using %s source): ", test_target_name(target), use_window ? "window" : "pixmap"); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); @@ -236,12 +236,12 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target, i uint8_t green = rand(); uint8_t blue = rand(); - x = rand() % (real.width - 1); - y = rand() % (real.height - 1); - w = 1 + rand() % (real.width - x - 1); - h = 1 + rand() % (real.height - y - 1); + x = rand() % (out.width - 1); + y = rand() % (out.height - 1); + w = 1 + rand() % (out.width - x - 1); + h = 1 + rand() % (out.height - y - 1); - fill_rect(&t->real, real.picture, + fill_rect(&t->out, out.picture, x, y, w, h, red, green, blue); fill_rect(&t->ref, ref.picture, @@ -250,15 +250,15 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target, i } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/render-copyarea-mask.c b/driver/xf86-video-intel/test/render-copyarea-mask.c index 5116c161e..937b5f006 100644 --- a/driver/xf86-video-intel/test/render-copyarea-mask.c +++ b/driver/xf86-video-intel/test/render-copyarea-mask.c @@ -75,14 +75,14 @@ static void clear(struct test_display *dpy, struct test_target *tt) static void rect_tests(struct test *t, int reps, int sets, enum target target, int use_window) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s, using %s source): ", test_target_name(target), use_window ? "window" : "pixmap"); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); @@ -99,12 +99,12 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target, i int try = 50; do { - x = rand() % (real.width - 1); - y = rand() % (real.height - 1); - w = 1 + rand() % (real.width - x - 1); - h = 1 + rand() % (real.height - y - 1); - tmpx = w == real.width ? 0 : rand() % (real.width - w); - tmpy = h == real.height ? 0 : rand() % (real.height - h); + x = rand() % (out.width - 1); + y = rand() % (out.height - 1); + w = 1 + rand() % (out.width - x - 1); + h = 1 + rand() % (out.height - y - 1); + tmpx = w == out.width ? 0 : rand() % (out.width - w); + tmpy = h == out.height ? 0 : rand() % (out.height - h); } while (((tmpx+w > x && tmpx < x+w) || (tmpy+h > y && tmpy < y+h)) && --try); @@ -115,7 +115,7 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target, i mask_h = rand() % h; if (try) { - fill_rect(&t->real, real.picture, real.format, + fill_rect(&t->out, out.picture, out.format, use_window, tmpx, tmpy, PictOpSrc, x, y, w, h, mask_x, mask_y, mask_w, mask_h, @@ -129,15 +129,15 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target, i } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/render-copyarea-size.c b/driver/xf86-video-intel/test/render-copyarea-size.c index 55e3b56b7..3503b329e 100644 --- a/driver/xf86-video-intel/test/render-copyarea-size.c +++ b/driver/xf86-video-intel/test/render-copyarea-size.c @@ -53,14 +53,14 @@ static void target_fini(struct test_display *t, struct draw *tt) int main(int argc, char **argv) { struct test test; - struct draw real, ref; + struct draw out, ref; int size, i; test_init(&test, argc, argv); /* Copy back and forth betwenn two pixmaps, gradually getting larger */ for (size = 1; size <= SIZE; size = (size * 3 + 1) / 2) { - target_init(&test.real, &real, size); + target_init(&test.out, &out, size); target_init(&test.ref, &ref, size); printf("size=%d\n", size); @@ -78,10 +78,10 @@ int main(int argc, char **argv) int order = rand() & 1; - XRenderComposite(test.real.dpy, PictOpSrc, - order ? real.pa : real.pb, + XRenderComposite(test.out.dpy, PictOpSrc, + order ? out.pa : out.pb, 0, - (!order) ? real.pa : real.pb, + (!order) ? out.pa : out.pb, sx, sy, 0, 0, dx, dy, @@ -99,17 +99,17 @@ int main(int argc, char **argv) } test_compare(&test, - real.a, real.format, + out.a, out.format, ref.a, ref.format, 0, 0, size, size, ""); test_compare(&test, - real.b, real.format, + out.b, out.format, ref.b, ref.format, 0, 0, size, size, ""); - target_fini(&test.real, &real); + target_fini(&test.out, &out); target_fini(&test.ref, &ref); } diff --git a/driver/xf86-video-intel/test/render-copyarea.c b/driver/xf86-video-intel/test/render-copyarea.c index 8c00b343d..a202ddeb2 100644 --- a/driver/xf86-video-intel/test/render-copyarea.c +++ b/driver/xf86-video-intel/test/render-copyarea.c @@ -9,7 +9,7 @@ static void show_cells(char *buf, - const uint32_t *real, const uint32_t *ref, + const uint32_t *out, const uint32_t *ref, int x, int y, int w, int h) { int i, j, len = 0; @@ -22,7 +22,7 @@ show_cells(char *buf, if (i < 0 || i >= w) continue; - len += sprintf(buf+len, "%08x ", real[j*w+i]); + len += sprintf(buf+len, "%08x ", out[j*w+i]); } len += sprintf(buf+len, "\t"); @@ -85,13 +85,13 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); int r, s; - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); printf("Testing setting of single pixels (%s): ", test_target_name(target)); @@ -106,7 +106,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) uint8_t blue = rand(); uint8_t alpha = rand(); - fill_rect(&t->real, tt.picture, tt.format, + fill_rect(&t->out, tt.picture, tt.format, 0, 0, 0, PictOpSrc, x, y, 1, 1, red, green, blue, alpha); @@ -116,14 +116,14 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) cells[y*tt.width+x] = color(red, green, blue, alpha); } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; uint32_t result; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -142,7 +142,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); } @@ -158,16 +158,16 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -181,7 +181,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) x = rand() % (2*tt.width) - tt.width; y = rand() % (2*tt.height) - tt.height; - fill_rect(&t->real, tt.picture, tt.format, + fill_rect(&t->out, tt.picture, tt.format, 0, 0, 0, PictOpSrc, x, y, w, h, red, green, blue, alpha); @@ -204,7 +204,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) color(red, green, blue, alpha)); } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -232,20 +232,20 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } static void rect_tests(struct test *t, int reps, int sets, enum target target, int use_window) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s, using %s source): ", test_target_name(target), use_window ? "window" : "pixmap"); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); @@ -261,19 +261,19 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target, i int try = 50; do { - x = rand() % (real.width - 1); - y = rand() % (real.height - 1); - w = 1 + rand() % (real.width - x - 1); - h = 1 + rand() % (real.height - y - 1); - tmpx = w == real.width ? 0 : rand() % (real.width - w); - tmpy = h == real.height ? 0 : rand() % (real.height - h); + x = rand() % (out.width - 1); + y = rand() % (out.height - 1); + w = 1 + rand() % (out.width - x - 1); + h = 1 + rand() % (out.height - y - 1); + tmpx = w == out.width ? 0 : rand() % (out.width - w); + tmpy = h == out.height ? 0 : rand() % (out.height - h); } while (((tmpx+w > x && tmpx < x+w) || (tmpy+h > y && tmpy < y+h)) && --try); if (try) { - fill_rect(&t->real, real.picture, real.format, + fill_rect(&t->out, out.picture, out.format, use_window, tmpx, tmpy, PictOpSrc, x, y, w, h, red, green, blue, alpha); @@ -285,15 +285,15 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target, i } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/render-fill-copy.c b/driver/xf86-video-intel/test/render-fill-copy.c index 45551b225..b5b475a08 100644 --- a/driver/xf86-video-intel/test/render-fill-copy.c +++ b/driver/xf86-video-intel/test/render-fill-copy.c @@ -57,13 +57,13 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); int r, s; - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); printf("Testing setting of single pixels (%s): ", test_target_name(target)); @@ -78,7 +78,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) int blue = rand() % 0xff; int alpha = rand() % 0xff; - fill_rect(&t->real, tt.picture, tt.format, + fill_rect(&t->out, tt.picture, tt.format, PictOpSrc, x, y, 1, 1, red, green, blue, alpha); @@ -87,14 +87,14 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) cells[y*tt.width+x] = color(red, green, blue, alpha); } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t result; uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -115,7 +115,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); } @@ -131,16 +131,16 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -154,7 +154,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) x = rand() % (2*tt.width) - tt.width; y = rand() % (2*tt.height) - tt.height; - fill_rect(&t->real, tt.picture, tt.format, + fill_rect(&t->out, tt.picture, tt.format, PictOpSrc, x, y, w, h, red, green, blue, alpha); @@ -176,7 +176,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) color(red, green, blue, alpha)); } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -203,37 +203,37 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } static void rect_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % real.width; - int h = rand() % real.height; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % out.width; + int h = rand() % out.height; int op = ops[rand() % sizeof(ops)]; int red = rand() % 0xff; int green = rand() % 0xff; int blue = rand() % 0xff; int alpha = rand() % 0xff; - fill_rect(&t->real, real.picture, real.format, + fill_rect(&t->out, out.picture, out.format, op, x, y, w, h, red, green, blue, alpha); fill_rect(&t->ref, ref.picture, ref.format, @@ -242,15 +242,15 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target) } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/render-fill.c b/driver/xf86-video-intel/test/render-fill.c index 54be1a38b..37c9d8583 100644 --- a/driver/xf86-video-intel/test/render-fill.c +++ b/driver/xf86-video-intel/test/render-fill.c @@ -31,13 +31,13 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); int r, s; - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); printf("Testing setting of single pixels (%s): ", test_target_name(target)); @@ -52,7 +52,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) int blue = rand() % 0xff; int alpha = rand() % 0xff; - fill_rect(&t->real, tt.picture, PictOpSrc, + fill_rect(&t->out, tt.picture, PictOpSrc, x, y, 1, 1, red, green, blue, alpha); @@ -61,14 +61,14 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) cells[y*tt.width+x] = color(red, green, blue, alpha); } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t result; uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -85,7 +85,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); } @@ -101,16 +101,16 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -124,7 +124,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) x = rand() % (2*tt.width) - tt.width; y = rand() % (2*tt.height) - tt.height; - fill_rect(&t->real, tt.picture, PictOpSrc, + fill_rect(&t->out, tt.picture, PictOpSrc, x, y, w, h, red, green, blue, alpha); if (x < 0) @@ -145,7 +145,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) color(red, green, blue, alpha)); } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -171,37 +171,37 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } static void rect_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % real.width; - int h = rand() % real.height; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % out.width; + int h = rand() % out.height; int op = ops[rand() % sizeof(ops)]; int red = rand() % 0xff; int green = rand() % 0xff; int blue = rand() % 0xff; int alpha = rand() % 0xff; - fill_rect(&t->real, real.picture, + fill_rect(&t->out, out.picture, op, x, y, w, h, red, green, blue, alpha); fill_rect(&t->ref, ref.picture, @@ -210,15 +210,15 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target) } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } diff --git a/driver/xf86-video-intel/test/render-trapezoid-image.c b/driver/xf86-video-intel/test/render-trapezoid-image.c index ecca70978..452b4ec99 100644 --- a/driver/xf86-video-intel/test/render-trapezoid-image.c +++ b/driver/xf86-video-intel/test/render-trapezoid-image.c @@ -56,7 +56,7 @@ static const char *trapezoid_name(enum trapezoid trapezoid) static void show_cells(char *buf, - const uint32_t *real, const uint32_t *ref, + const uint32_t *out, const uint32_t *ref, int x, int y, int w, int h) { int i, j, len = 0; @@ -69,7 +69,7 @@ show_cells(char *buf, if (i < 0 || i >= w) continue; - len += sprintf(buf+len, "%08x ", real[j*w+i]); + len += sprintf(buf+len, "%08x ", out[j*w+i]); } len += sprintf(buf+len, "\t"); @@ -143,7 +143,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target, { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); @@ -154,7 +154,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target, use_window ? "window" : "pixmap"); fflush(stdout); - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -172,8 +172,8 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target, ty = rand() % (tt.height - 1); } while (tx == x && ty == y); - fill_rect(&t->real, tt.picture, - use_window ? t->real.format : tt.format, + fill_rect(&t->out, tt.picture, + use_window ? t->out.format : tt.format, PictOpSrc, x, y, 1, 1, 0, 0, MASK_NONE, use_window, tx, ty, @@ -181,17 +181,17 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target, pixels[r].x = x; pixels[r].y = y; - cells[y*t->real.width+x] = color(red, green, blue, alpha); + cells[y*t->out.width+x] = color(red, green, blue, alpha); } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t result; uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -209,7 +209,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target, } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); @@ -265,7 +265,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s using %s source): ", @@ -273,10 +273,10 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i use_window ? "window" : "pixmap"); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -308,8 +308,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i tx = ty = 0; } - fill_rect(&t->real, tt.picture, - use_window ? t->real.format : tt.format, + fill_rect(&t->out, tt.picture, + use_window ? t->out.format : tt.format, PictOpSrc, x, y, w, h, 0, 0, MASK_NONE, use_window, tx, ty, @@ -323,7 +323,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -351,7 +351,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } @@ -362,7 +362,7 @@ static void rect_tests(struct test *t, enum target target, int use_window) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (offset %dx%d, mask %s) (%s using %s source): ", @@ -370,9 +370,9 @@ static void rect_tests(struct test *t, use_window ? "window" : "pixmap"); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); - set_mask(&t->real, &real, mask); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); + set_mask(&t->out, &out, mask); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); @@ -389,19 +389,19 @@ static void rect_tests(struct test *t, int tx, ty, try = 50; do { - x = rand() % (real.width - 1); - y = rand() % (real.height - 1); - w = 1 + rand() % (real.width - x - 1); - h = 1 + rand() % (real.height - y - 1); - tx = w == real.width ? 0 : rand() % (real.width - w); - ty = h == real.height ? 0 : rand() % (real.height - h); + x = rand() % (out.width - 1); + y = rand() % (out.height - 1); + w = 1 + rand() % (out.width - x - 1); + h = 1 + rand() % (out.height - y - 1); + tx = w == out.width ? 0 : rand() % (out.width - w); + ty = h == out.height ? 0 : rand() % (out.height - h); } while (((tx+w > x && tx < x+w) && (ty+h > y && ty < y+h)) && --try); if (try) { - fill_rect(&t->real, real.picture, - use_window ? t->real.format : real.format, + fill_rect(&t->out, out.picture, + use_window ? t->out.format : out.format, op, x, y, w, h, dx, dy, mask, use_window, tx, ty, @@ -416,15 +416,15 @@ static void rect_tests(struct test *t, } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } @@ -508,7 +508,7 @@ static void trap_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; XTrapezoid *traps; int max_traps = 65536; int r, s, n; @@ -523,9 +523,9 @@ static void trap_tests(struct test *t, test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); - set_mask(&t->real, &real, mask); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); + set_mask(&t->out, &out, mask); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); @@ -539,17 +539,17 @@ static void trap_tests(struct test *t, int blue = rand() % 0xff; int alpha = rand() % 0xff; int num_traps = rand() % max_traps; - int srcx = rand() % 2*real.width - real.width; - int srcy = rand() % 2*real.height - real.height; - int srcw = rand() % real.width; - int srch = rand() % real.height; + int srcx = rand() % 2*out.width - out.width; + int srcy = rand() % 2*out.height - out.height; + int srcw = rand() % out.width; + int srch = rand() % out.height; for (n = 0; n < num_traps; n++) random_trapezoid(&traps[n], 0, - 0, 0, real.width, real.height); + 0, 0, out.width, out.height); - fill_traps(&t->real, real.picture, real.format, + fill_traps(&t->out, out.picture, out.format, op, traps, num_traps, mask, srcx, srcy, srcw, srch, red, green, blue, alpha); @@ -561,15 +561,15 @@ static void trap_tests(struct test *t, } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); free(traps); } diff --git a/driver/xf86-video-intel/test/render-trapezoid.c b/driver/xf86-video-intel/test/render-trapezoid.c index 811d90933..cd9901437 100644 --- a/driver/xf86-video-intel/test/render-trapezoid.c +++ b/driver/xf86-video-intel/test/render-trapezoid.c @@ -79,7 +79,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = malloc(t->real.width*t->real.height*4); + uint32_t *cells = malloc(t->out.width*t->out.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); @@ -88,7 +88,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) printf("Testing setting of single pixels (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &tt); + test_target_create_render(&t->out, target, &tt); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -99,24 +99,24 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) int blue = rand() % 0xff; int alpha = rand() % 0xff; - fill_rect(&t->real, tt.picture, PictOpSrc, + fill_rect(&t->out, tt.picture, PictOpSrc, x, y, 1, 1, 0, 0, MASK_NONE, red, green, blue, alpha); pixels[r].x = x; pixels[r].y = y; - cells[y*t->real.width+x] = color(red, green, blue, alpha); + cells[y*t->out.width+x] = color(red, green, blue, alpha); } - test_init_image(&image, &t->real.shm, tt.format, 1, 1); + test_init_image(&image, &t->out.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t result; uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; - XShmGetImage(t->real.dpy, tt.draw, &image, + XShmGetImage(t->out.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; @@ -134,7 +134,7 @@ static void pixel_tests(struct test *t, int reps, int sets, enum target target) } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(pixels); free(cells); @@ -151,16 +151,16 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; - uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); + uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &tt); - clear(&t->real, &tt); + test_target_create_render(&t->out, target, &tt); + clear(&t->out, &tt); - test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); + test_init_image(&image, &t->out.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { @@ -174,7 +174,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) x = rand() % (2*tt.width) - tt.width; y = rand() % (2*tt.height) - tt.height; - fill_rect(&t->real, tt.picture, PictOpSrc, + fill_rect(&t->out, tt.picture, PictOpSrc, x, y, w, h, 0, 0, MASK_NONE, red, green, blue, alpha); @@ -197,7 +197,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) color(red, green, blue, alpha)); } - XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); + XShmGetImage(t->out.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { @@ -221,7 +221,7 @@ static void area_tests(struct test *t, int reps, int sets, enum target target) printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &tt); + test_target_destroy_render(&t->out, &tt); free(cells); } @@ -231,32 +231,32 @@ static void rect_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; int r, s; printf("Testing area fills (offset %dx%d, mask %s) (%s): ", dx, dy, mask_name(mask), test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { - int x = rand() % (2*real.width) - real.width; - int y = rand() % (2*real.height) - real.height; - int w = rand() % real.width; - int h = rand() % real.height; + int x = rand() % (2*out.width) - out.width; + int y = rand() % (2*out.height) - out.height; + int w = rand() % out.width; + int h = rand() % out.height; int op = ops[rand() % sizeof(ops)]; int red = rand() % 0xff; int green = rand() % 0xff; int blue = rand() % 0xff; int alpha = rand() % 0xff; - fill_rect(&t->real, real.picture, op, + fill_rect(&t->out, out.picture, op, x, y, w, h, dx, dy, mask, red, green, blue, alpha); fill_rect(&t->ref, ref.picture, op, @@ -265,15 +265,15 @@ static void rect_tests(struct test *t, } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } @@ -331,7 +331,7 @@ static void trap_tests(struct test *t, int reps, int sets, enum target target) { - struct test_target real, ref; + struct test_target out, ref; XTrapezoid *traps; int max_traps = 65536; int r, s, n; @@ -346,8 +346,8 @@ static void trap_tests(struct test *t, test_target_name(target)); fflush(stdout); - test_target_create_render(&t->real, target, &real); - clear(&t->real, &real); + test_target_create_render(&t->out, target, &out); + clear(&t->out, &out); test_target_create_render(&t->ref, target, &ref); clear(&t->ref, &ref); @@ -365,20 +365,20 @@ static void trap_tests(struct test *t, for (n = 0; n < num_traps; n++) random_trapezoid(&traps[n], 0, - 0, 0, real.width, real.height); + 0, 0, out.width, out.height); render_color.red = red * alpha; render_color.green = green * alpha; render_color.blue = blue * alpha; render_color.alpha = alpha << 8; - src = XRenderCreateSolidFill(t->real.dpy, + src = XRenderCreateSolidFill(t->out.dpy, &render_color); - XRenderCompositeTrapezoids(t->real.dpy, - op, src, real.picture, - mask_format(t->real.dpy, mask), + XRenderCompositeTrapezoids(t->out.dpy, + op, src, out.picture, + mask_format(t->out.dpy, mask), 0, 0, traps, num_traps); - XRenderFreePicture(t->real.dpy, src); + XRenderFreePicture(t->out.dpy, src); src = XRenderCreateSolidFill(t->ref.dpy, &render_color); @@ -390,15 +390,15 @@ static void trap_tests(struct test *t, } test_compare(t, - real.draw, real.format, + out.draw, out.format, ref.draw, ref.format, - 0, 0, real.width, real.height, + 0, 0, out.width, out.height, ""); } printf("passed [%d iterations x %d]\n", reps, sets); - test_target_destroy_render(&t->real, &real); + test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); free(traps); } diff --git a/driver/xf86-video-intel/test/shm-test.c b/driver/xf86-video-intel/test/shm-test.c new file mode 100644 index 000000000..684d142e6 --- /dev/null +++ b/driver/xf86-video-intel/test/shm-test.c @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xlibint.h> +#include <X11/extensions/Xrender.h> +#include <X11/extensions/XShm.h> +#if HAVE_X11_EXTENSIONS_SHMPROTO_H +#include <X11/extensions/shmproto.h> +#elif HAVE_X11_EXTENSIONS_SHMSTR_H +#include <X11/extensions/shmstr.h> +#else +#error Failed to find the right header for X11 MIT-SHM protocol definitions +#endif + +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <unistd.h> +#include <assert.h> +#include <errno.h> + +#include <sys/mman.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <pciaccess.h> + +static int _x_error_occurred; + +static int +can_use_shm(Display *dpy) +{ + int major, minor, has_pixmap; + + if (!XShmQueryExtension(dpy)) + return 0; + + XShmQueryVersion(dpy, &major, &minor, &has_pixmap); + return has_pixmap; +} + +static int test_subpage(Display *dpy) +{ + const int width = 10; + const int height = 10; + uint32_t pixel = 0xffffffff; + char *expected; + XShmSegmentInfo shm; + Pixmap pixmap, source; + XGCValues gcv; + GC gc; + + printf("Creating %dx%d SHM pixmap\n", width, height); + _x_error_occurred = 0; + + expected = malloc(4096); + if (expected == NULL) + return 0; + + shm.shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT | 0666); + if (shm.shmid == -1) + return 0; + + shm.shmaddr = shmat(shm.shmid, 0, 0); + if (shm.shmaddr == (char *) -1) { + shmctl(shm.shmid, IPC_RMID, NULL); + return 0; + } + + shm.readOnly = False; + XShmAttach(dpy, &shm); + + memset(shm.shmaddr, 0xcc, 4096); + memset(expected, 0xcc, 4096); + memset(expected + 64, 0xff, 4*width * height); + + pixmap = XShmCreatePixmap(dpy, DefaultRootWindow(dpy), + shm.shmaddr + 64, &shm, width, height, 24); + XSync(dpy, False); + shmctl(shm.shmid, IPC_RMID, NULL); + + source = XCreatePixmap(dpy, DefaultRootWindow(dpy), + width, height, 24); + + gcv.graphics_exposures = False; + gcv.subwindow_mode = IncludeInferiors; + gcv.foreground = pixel; + gcv.function = GXcopy; + gcv.fill_style = FillSolid; + gc = XCreateGC(dpy, pixmap, GCGraphicsExposures | GCSubwindowMode | GCFillStyle | GCForeground | GCFunction, &gcv); + + XCopyArea(dpy, pixmap, source, gc, + 0, 0, width, height, 0, 0); + + XFillRectangle(dpy, source, gc, 0, 0, width, height); + + XCopyArea(dpy, source, pixmap, gc, + 0, 0, width, height, 0, 0); + XSync(dpy, True); + + if (_x_error_occurred == 0) + _x_error_occurred = memcmp(shm.shmaddr, expected, 4096); + + printf("%s: %s\n", __func__, _x_error_occurred ? "failed" : "passed"); + + XShmDetach(dpy, &shm); + shmdt(shm.shmaddr); + free(expected); + + + return !_x_error_occurred;; +} + +static int +_check_error_handler(Display *display, + XErrorEvent *event) +{ + printf("X11 error from display %s, serial=%ld, error=%d, req=%d.%d\n", + DisplayString(display), + event->serial, + event->error_code, + event->request_code, + event->minor_code); + _x_error_occurred++; + return False; /* ignored */ +} + +int main(void) +{ + Display *dpy; + int error = 0; + + dpy = XOpenDisplay(NULL); + if (dpy == NULL) + return 77; + + if (DefaultDepth(dpy, DefaultScreen(dpy)) != 24) + return 77; + + if (!can_use_shm(dpy)) + return 0; + + XSetErrorHandler(_check_error_handler); + + error += test_subpage(dpy); + + return !!error; +} diff --git a/driver/xf86-video-intel/test/test.h b/driver/xf86-video-intel/test/test.h index 568e000cd..a3ef979d5 100644 --- a/driver/xf86-video-intel/test/test.h +++ b/driver/xf86-video-intel/test/test.h @@ -31,9 +31,11 @@ struct test { Window root; XShmSegmentInfo shm; int max_shm_size; + int has_shm_pixmaps; int width, height, depth; XRenderPictFormat *format; - } real, ref; + enum { REF, OUT } target; + } out, ref; }; void die(const char *fmt, ...); @@ -42,8 +44,8 @@ void die(const char *fmt, ...); void test_init(struct test *test, int argc, char **argv); -void test_compare(struct test *real, - Drawable real_draw, XRenderPictFormat *real_format, +void test_compare(struct test *out, + Drawable out_draw, XRenderPictFormat *out_format, Drawable ref_draw, XRenderPictFormat *ref_format, int x, int y, int w, int h, const char *info); @@ -52,15 +54,11 @@ int pixel_difference(uint32_t a, uint32_t b); static inline int pixel_equal(int depth, uint32_t a, uint32_t b) { - uint32_t mask; - - if (depth == 32) - mask = 0xffffffff; - else - mask = (1 << depth) - 1; - - a &= mask; - b &= mask; + if (depth != 32) { + uint32_t mask = (1 << depth) - 1; + a &= mask; + b &= mask; + } if (a == b) return 1; @@ -120,7 +118,7 @@ double test_timer_stop(struct test_display *t, struct timespec *tv); #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #endif +#define SETS(I) ((I) >= 12 ? 1 : 1 << (12 - (I))) #define REPS(I) (1 << (I)) -#define SETS(I) ((I) < 12 ? 1 << (12 - (I)) : 2) #endif diff --git a/driver/xf86-video-intel/test/test_display.c b/driver/xf86-video-intel/test/test_display.c index 36cfe698c..98ee4e82f 100644 --- a/driver/xf86-video-intel/test/test_display.c +++ b/driver/xf86-video-intel/test/test_display.c @@ -27,7 +27,7 @@ static Window get_root(struct test_display *t) return w; } -static Display *real_display(int argc, char **argv) +static Display *out_display(int argc, char **argv) { Display *dpy; const char *name = NULL; @@ -52,7 +52,7 @@ static Display *real_display(int argc, char **argv) dpy = XOpenDisplay(name); if (dpy == NULL) - die("unable to open real display %s\n", name); + die("unable to open out display %s\n", name); printf("Opened connection to %s for testing.\n", name); return dpy; @@ -97,10 +97,10 @@ static Display *ref_display(int width, int height, int depth) static void shm_setup(struct test_display *d) { - int major, minor, has_pixmaps; + int major, minor; int size; - XShmQueryVersion(d->dpy, &major, &minor, &has_pixmaps); + XShmQueryVersion(d->dpy, &major, &minor, &d->has_shm_pixmaps); if (major == 0 && minor == 0) die("XSHM not supported\n"); @@ -129,24 +129,26 @@ static void default_setup(struct test_display *dpy) } static void test_get_displays(int argc, char **argv, - struct test_display *real, + struct test_display *out, struct test_display *ref) { - real->dpy = real_display(argc, argv); - default_setup(real); - shm_setup(real); - real->root = get_root(real); + out->dpy = out_display(argc, argv); + default_setup(out); + shm_setup(out); + out->root = get_root(out); + out->target = OUT; - ref->dpy = ref_display(real->width, real->height, real->depth); + ref->dpy = ref_display(out->width, out->height, out->depth); default_setup(ref); shm_setup(ref); ref->root = get_root(ref); + ref->target = REF; } void test_init(struct test *test, int argc, char **argv) { memset(test, 0, sizeof(*test)); - test_get_displays(argc, argv, &test->real, &test->ref); + test_get_displays(argc, argv, &test->out, &test->ref); } void test_timer_start(struct test_display *t, struct timespec *tv) diff --git a/driver/xf86-video-intel/test/test_image.c b/driver/xf86-video-intel/test/test_image.c index f2cf90695..d15a8af8c 100644 --- a/driver/xf86-video-intel/test/test_image.c +++ b/driver/xf86-video-intel/test/test_image.c @@ -1,6 +1,7 @@ #include <stdint.h> #include <stdio.h> #include <string.h> +#include <png.h> #include "test.h" @@ -29,7 +30,7 @@ int pixel_difference(uint32_t a, uint32_t b) static void show_pixels(char *buf, - const XImage *real, const XImage *ref, + const XImage *out, const XImage *ref, int x, int y, int w, int h) { int i, j, len = 0; @@ -44,9 +45,9 @@ show_pixels(char *buf, len += sprintf(buf+len, "%08x ", - *(uint32_t*)(real->data + - j*real->bytes_per_line + - i*real->bits_per_pixel/8)); + *(uint32_t*)(out->data + + j*out->bytes_per_line + + i*out->bits_per_pixel/8)); } len += sprintf(buf+len, "\t"); @@ -58,8 +59,8 @@ show_pixels(char *buf, len += sprintf(buf+len, "%08x ", *(uint32_t*)(ref->data + - j*real->bytes_per_line + - i*real->bits_per_pixel/8)); + j*out->bytes_per_line + + i*out->bits_per_pixel/8)); } len += sprintf(buf+len, "\n"); @@ -67,92 +68,167 @@ show_pixels(char *buf, } static void test_compare_fallback(struct test *t, - Drawable real_draw, XRenderPictFormat *real_format, + Drawable out_draw, XRenderPictFormat *out_format, Drawable ref_draw, XRenderPictFormat *ref_format, int x, int y, int w, int h) { - XImage *real_image, *ref_image; - char *real, *ref; + XImage *out_image, *ref_image; + char *out, *ref; char buf[600]; uint32_t mask; int i, j; - die_unless(real_format->depth == ref_format->depth); + die_unless(out_format->depth == ref_format->depth); - real_image = XGetImage(t->real.dpy, real_draw, + out_image = XGetImage(t->out.dpy, out_draw, x, y, w, h, AllPlanes, ZPixmap); - real = real_image->data; + out = out_image->data; ref_image = XGetImage(t->ref.dpy, ref_draw, x, y, w, h, AllPlanes, ZPixmap); ref = ref_image->data; - mask = depth_mask(real_image->depth); + mask = depth_mask(out_image->depth); /* Start with an exact comparison. However, one quicky desires * a fuzzy comparator to hide hardware inaccuracies... */ for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { - uint32_t a = ((uint32_t *)real)[i] & mask; + uint32_t a = ((uint32_t *)out)[i] & mask; uint32_t b = ((uint32_t *)ref)[i] & mask; if (a != b && pixel_difference(a, b) > MAX_DELTA) { show_pixels(buf, - real_image, ref_image, + out_image, ref_image, i, j, w, h); die("discrepancy found at (%d+%d, %d+%d): found %08x, expected %08x (delta: %d)\n%s", x,i, y,j, a, b, pixel_difference(a, b), buf); } } - real += real_image->bytes_per_line; + out += out_image->bytes_per_line; ref += ref_image->bytes_per_line; } - XDestroyImage(real_image); + XDestroyImage(out_image); XDestroyImage(ref_image); } +static void +unpremultiply_data (png_structp png, png_row_infop row_info, png_bytep data) +{ + unsigned int i; + + for (i = 0; i < row_info->rowbytes; i += 4) { + uint8_t *b = &data[i]; + uint32_t pixel; + uint8_t alpha; + + memcpy (&pixel, b, sizeof (uint32_t)); + alpha = (pixel & 0xff000000) >> 24; + if (alpha == 0) { + b[0] = (pixel & 0xff0000) >> 16; + b[1] = (pixel & 0x00ff00) >> 8; + b[2] = (pixel & 0x0000ff) >> 0; + b[3] = 0xff; + } else { + b[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha; + b[1] = (((pixel & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha; + b[2] = (((pixel & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha; + b[3] = alpha; + } + } +} + +static void save_image(XImage *image, const char *filename) +{ + FILE *file; + png_struct *png = NULL; + png_info *info = NULL; + png_byte **rows = NULL; + int i; + + file = fopen(filename, "w"); + if (file == NULL) + return; + + png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (png == NULL) + goto out; + + info = png_create_info_struct(png); + if (info == NULL) + goto out; + + rows = png_malloc(png, sizeof(png_byte *) * image->height); + if (rows == NULL) + goto out; + for (i = 0; i < image->height; i++) + rows[i] = (png_byte *)(image->data + image->bytes_per_line * i); + + if (setjmp(png_jmpbuf(png))) + goto out; + + png_set_IHDR(png, info, + image->width, image->height, 8, + PNG_COLOR_TYPE_RGB_ALPHA, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_init_io(png, file); + png_write_info(png, info); + png_set_write_user_transform_fn(png, unpremultiply_data); + png_write_image(png, rows); + png_write_end(png, info); + +out: + if (rows) + png_free(png, rows); + png_destroy_write_struct(&png, &info); + fclose(file); +} + void test_compare(struct test *t, - Drawable real_draw, XRenderPictFormat *real_format, + Drawable out_draw, XRenderPictFormat *out_format, Drawable ref_draw, XRenderPictFormat *ref_format, int x, int y, int w, int h, const char *info) { - XImage real_image, ref_image; + XImage out_image, ref_image; Pixmap tmp; - char *real, *ref; + char *out, *ref; char buf[600]; uint32_t mask; int i, j; XGCValues gcv; GC gc; - if (w * h * 4 > t->real.max_shm_size) + if (w * h * 4 > t->out.max_shm_size) return test_compare_fallback(t, - real_draw, real_format, + out_draw, out_format, ref_draw, ref_format, x, y, w, h); - test_init_image(&real_image, &t->real.shm, real_format, w, h); + test_init_image(&out_image, &t->out.shm, out_format, w, h); test_init_image(&ref_image, &t->ref.shm, ref_format, w, h); gcv.graphics_exposures = 0; - die_unless(real_image.depth == ref_image.depth); - die_unless(real_image.bits_per_pixel == ref_image.bits_per_pixel); - die_unless(real_image.bits_per_pixel == 32); + die_unless(out_image.depth == ref_image.depth); + die_unless(out_image.bits_per_pixel == ref_image.bits_per_pixel); + die_unless(out_image.bits_per_pixel == 32); - mask = depth_mask(real_image.depth); + mask = depth_mask(out_image.depth); - tmp = XCreatePixmap(t->real.dpy, real_draw, w, h, real_image.depth); - gc = XCreateGC(t->real.dpy, tmp, GCGraphicsExposures, &gcv); - XCopyArea(t->real.dpy, real_draw, tmp, gc, x, y, w, h, 0, 0); - XShmGetImage(t->real.dpy, tmp, &real_image, 0, 0, AllPlanes); - XFreeGC(t->real.dpy, gc); - XFreePixmap(t->real.dpy, tmp); - real = real_image.data; + tmp = XCreatePixmap(t->out.dpy, out_draw, w, h, out_image.depth); + gc = XCreateGC(t->out.dpy, tmp, GCGraphicsExposures, &gcv); + XCopyArea(t->out.dpy, out_draw, tmp, gc, x, y, w, h, 0, 0); + XShmGetImage(t->out.dpy, tmp, &out_image, 0, 0, AllPlanes); + XFreeGC(t->out.dpy, gc); + XFreePixmap(t->out.dpy, tmp); + out = out_image.data; tmp = XCreatePixmap(t->ref.dpy, ref_draw, w, h, ref_image.depth); gc = XCreateGC(t->ref.dpy, tmp, GCGraphicsExposures, &gcv); @@ -167,17 +243,19 @@ void test_compare(struct test *t, */ for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { - uint32_t a = ((uint32_t *)real)[i] & mask; + uint32_t a = ((uint32_t *)out)[i] & mask; uint32_t b = ((uint32_t *)ref)[i] & mask; if (a != b && pixel_difference(a, b) > MAX_DELTA) { show_pixels(buf, - &real_image, &ref_image, + &out_image, &ref_image, i, j, w, h); + save_image(&out_image, "out.png"); + save_image(&ref_image, "ref.png"); die("discrepancy found at (%d+%d, %d+%d): found %08x, expected %08x (delta: %d)\n%s%s\n", x,i, y,j, a, b, pixel_difference(a, b), buf, info); } } - real += real_image.bytes_per_line; + out += out_image.bytes_per_line; ref += ref_image.bytes_per_line; } } |