From fe9d8cd79e9380e29eb92f97903e8cb79d25371a Mon Sep 17 00:00:00 2001 From: John Sheu Date: Wed, 13 Apr 2016 13:57:42 -0700 Subject: [PATCH 01/13] xlib: do not cache return value of glXChooseVisual/glXGetVisualFromFBConfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The returned XVisualInfo from glXChooseVisual/glXGetVisualFromFBConfig is being cached in XMesaVisual.vishandle (and unconditionally overwritten on subsequent calls). However, these entry points are specified to return XVisualInfo instances to be owned by the caller and freed with XFree(), so the return values should not be retained. With this change, XMesaVisual.vishandle is essentially unused and will be removed in a subsequent change. v2: update commit message Reviewed-by: Alejandro Piñeiro --- src/mesa/drivers/x11/fakeglx.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 2f4d966973e..d62d5abd465 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -1241,16 +1241,11 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) xmvis = choose_visual(dpy, screen, list, GL_FALSE); if (xmvis) { -#if 0 - return xmvis->vishandle; -#else - /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = malloc(sizeof(XVisualInfo)); - if (xmvis->vishandle) { - memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); + XVisualInfo* visinfo = malloc(sizeof(XVisualInfo)); + if (visinfo) { + memcpy(visinfo, xmvis->visinfo, sizeof(XVisualInfo)); } - return xmvis->vishandle; -#endif + return visinfo; } else return NULL; @@ -1974,16 +1969,11 @@ Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) { if (dpy && config) { XMesaVisual xmvis = (XMesaVisual) config; -#if 0 - return xmvis->vishandle; -#else - /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = malloc(sizeof(XVisualInfo)); - if (xmvis->vishandle) { - memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); + XVisualInfo* visinfo = malloc(sizeof(XVisualInfo)); + if (visinfo) { + memcpy(visinfo, xmvis->visinfo, sizeof(XVisualInfo)); } - return xmvis->vishandle; -#endif + return visinfo; } else { return NULL; From 781232e0ac48bf608757bbd270c593a90173f951 Mon Sep 17 00:00:00 2001 From: John Sheu Date: Fri, 1 Apr 2016 16:52:20 -0700 Subject: [PATCH 02/13] xlib: fix memory leak of and remove vishandle from XMesaVisualInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The vishandle member of XMesaVisualInfo is used to support the comparison of XVisualInfo instances by pointer value, in find_glx_visual(). The comparison however will always be false, as in every case the comparison is made, the VisualInfo instance being compared to is a new allocation passed in through a GLX API call. In addition, the XVisualInfo instance pointed to by vishandle is itself never freed, causing a memory leak. Since vishandle is essentially useless, we just remove it and thereby also fix the leak. Reviewed-by: Alejandro Piñeiro --- src/mesa/drivers/x11/fakeglx.c | 62 +++++++++++++--------------------- src/mesa/drivers/x11/xmesaP.h | 1 - 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index d62d5abd465..208fc5bbc60 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -256,7 +256,6 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, GLboolean ximageFlag = GL_TRUE; XMesaVisual xmvis; GLint i; - GLboolean comparePointers; if (dbFlag) { /* Check if the MESA_BACK_BUFFER env var is set */ @@ -279,37 +278,34 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, return NULL; } - /* Comparing IDs uses less memory but sometimes fails. */ - /* XXX revisit this after 3.0 is finished. */ - if (getenv("MESA_GLX_VISUAL_HACK")) - comparePointers = GL_TRUE; - else - comparePointers = GL_FALSE; /* Force the visual to have an alpha channel */ if (getenv("MESA_GLX_FORCE_ALPHA")) alphaFlag = GL_TRUE; - /* First check if a matching visual is already in the list */ - for (i=0; idisplay == dpy - && v->mesa_visual.level == level - && v->mesa_visual.numAuxBuffers == numAuxBuffers - && v->ximage_flag == ximageFlag - && v->mesa_visual.doubleBufferMode == dbFlag - && v->mesa_visual.stereoMode == stereoFlag - && (v->mesa_visual.alphaBits > 0) == alphaFlag - && (v->mesa_visual.depthBits >= depth_size || depth_size == 0) - && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0) - && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0) - && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0) - && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0) - && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { - /* now either compare XVisualInfo pointers or visual IDs */ - if ((!comparePointers && v->visinfo->visualid == vinfo->visualid) - || (comparePointers && v->vishandle == vinfo)) { - return v; + /* Comparing IDs uses less memory but sometimes fails. */ + /* XXX revisit this after 3.0 is finished. */ + if (!getenv("MESA_GLX_VISUAL_HACK")) { + /* First check if a matching visual is already in the list */ + for (i=0; idisplay == dpy + && v->mesa_visual.level == level + && v->mesa_visual.numAuxBuffers == numAuxBuffers + && v->ximage_flag == ximageFlag + && v->mesa_visual.doubleBufferMode == dbFlag + && v->mesa_visual.stereoMode == stereoFlag + && (v->mesa_visual.alphaBits > 0) == alphaFlag + && (v->mesa_visual.depthBits >= depth_size || depth_size == 0) + && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0) + && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0) + && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0) + && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0) + && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { + /* now compare visual IDs */ + if (v->visinfo->visualid == vinfo->visualid) { + return v; + } } } } @@ -323,10 +319,6 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, accumBlueSize, accumAlphaSize, 0, level, GLX_NONE_EXT ); if (xmvis) { - /* Save a copy of the pointer now so we can find this visual again - * if we need to search for it in find_glx_visual(). - */ - xmvis->vishandle = vinfo; /* Allocate more space for additional visual */ VisualTable = realloc(VisualTable, sizeof(XMesaVisual) * (NumVisuals + 1)); /* add xmvis to the list */ @@ -442,13 +434,6 @@ find_glx_visual( Display *dpy, XVisualInfo *vinfo ) } } - /* if that fails, try to match pointers */ - for (i=0;idisplay==dpy && VisualTable[i]->vishandle==vinfo) { - return VisualTable[i]; - } - } - return NULL; } @@ -1225,6 +1210,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) stereo_flag, depth_size, stencil_size, accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize, level, numAux ); + free(vis); } return xmvis; diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index d7a934e8df4..6cd020f2ed3 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -78,7 +78,6 @@ struct xmesa_visual { int screen, visualID; int visualType; XMesaVisualInfo visinfo; /* X's visual info (pointer to private copy) */ - XVisualInfo *vishandle; /* Only used in fakeglx.c */ GLint BitsPerPixel; /* True bits per pixel for XImages */ GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */ From 8a9c0f102540f64c4a3523f6b4e11eaa2071e0a3 Mon Sep 17 00:00:00 2001 From: John Sheu Date: Fri, 1 Apr 2016 16:52:21 -0700 Subject: [PATCH 03/13] xlib: fix leaks of returned values from XGetVisualInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Alejandro Piñeiro --- src/mesa/drivers/x11/fakeglx.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 208fc5bbc60..508dc65e785 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -730,27 +730,39 @@ choose_x_overlay_visual( Display *dpy, int scr, vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask, &vistemplate, &count ); + if (!vislist) { + /* no matches */ + continue; + } + if (count!=1) { /* something went wrong */ + free(vislist); continue; } if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) { /* wrong visual class */ + free(vislist); continue; } /* Color-index rendering is not supported. Make sure we have True/DirectColor */ - if (vislist->CLASS != TrueColor && vislist->CLASS != DirectColor) + if (vislist->CLASS != TrueColor && vislist->CLASS != DirectColor) { + free(vislist); continue; - - if (deepvis==NULL || vislist->depth > deepest) { - /* YES! found a satisfactory visual */ - free(deepvis); - deepest = vislist->depth; - deepvis = vislist; - /* DEBUG tt = ov->transparent_type;*/ - /* DEBUG tv = ov->value; */ } + + if (deepvis!=NULL && vislist->depth <= deepest) { + free(vislist); + continue; + } + + /* YES! found a satisfactory visual */ + free(deepvis); + deepest = vislist->depth; + deepvis = vislist; + /* DEBUG tt = ov->transparent_type;*/ + /* DEBUG tv = ov->value; */ } /*DEBUG @@ -1912,6 +1924,7 @@ Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) for (i = 0; i < *nelements; i++) { results[i] = create_glx_visual(dpy, visuals + i); } + free(visuals); return (GLXFBConfig *) results; } return NULL; From f8752e0d95b0b562ca64e8064e98a0b66e5d1591 Mon Sep 17 00:00:00 2001 From: John Sheu Date: Fri, 1 Apr 2016 16:52:22 -0700 Subject: [PATCH 04/13] xlib: remove MESA_GLX_VISUAL_HACK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes a hack introduced in 1999 in the first version of fakeglx.c, with the comment: /* XXX revisit this after 3.0 is finished. */ Mesa 4.0 was released in 2001. It is now 2016, and Mesa 11.0 was released last year. Reviewed-by: Alejandro Piñeiro --- src/mesa/drivers/x11/fakeglx.c | 42 +++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 508dc65e785..394800f02ea 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -283,29 +283,25 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, if (getenv("MESA_GLX_FORCE_ALPHA")) alphaFlag = GL_TRUE; - /* Comparing IDs uses less memory but sometimes fails. */ - /* XXX revisit this after 3.0 is finished. */ - if (!getenv("MESA_GLX_VISUAL_HACK")) { - /* First check if a matching visual is already in the list */ - for (i=0; idisplay == dpy - && v->mesa_visual.level == level - && v->mesa_visual.numAuxBuffers == numAuxBuffers - && v->ximage_flag == ximageFlag - && v->mesa_visual.doubleBufferMode == dbFlag - && v->mesa_visual.stereoMode == stereoFlag - && (v->mesa_visual.alphaBits > 0) == alphaFlag - && (v->mesa_visual.depthBits >= depth_size || depth_size == 0) - && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0) - && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0) - && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0) - && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0) - && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { - /* now compare visual IDs */ - if (v->visinfo->visualid == vinfo->visualid) { - return v; - } + /* First check if a matching visual is already in the list */ + for (i=0; idisplay == dpy + && v->mesa_visual.level == level + && v->mesa_visual.numAuxBuffers == numAuxBuffers + && v->ximage_flag == ximageFlag + && v->mesa_visual.doubleBufferMode == dbFlag + && v->mesa_visual.stereoMode == stereoFlag + && (v->mesa_visual.alphaBits > 0) == alphaFlag + && (v->mesa_visual.depthBits >= depth_size || depth_size == 0) + && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0) + && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0) + && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0) + && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0) + && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { + /* now compare visual IDs */ + if (v->visinfo->visualid == vinfo->visualid) { + return v; } } } From 7e4628da48290f76dd0d4ddc29faf083db0d78ae Mon Sep 17 00:00:00 2001 From: Eduardo Lima Mitev Date: Fri, 15 Apr 2016 10:00:05 +0200 Subject: [PATCH 05/13] nir/print: Fix printing variable mode nir_variable_mode is currently a bitflag enum, while nir_print::print_var_decl() assumes is still a numbered list. Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir_print.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 84e926905b4..229539d44ee 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -315,6 +315,30 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state } } +static const char * +get_variable_mode_str(nir_variable_mode mode) +{ + switch (mode) { + case nir_var_shader_in: + return "shader_in"; + case nir_var_shader_out: + return "shader_out"; + case nir_var_uniform: + return "uniform"; + case nir_var_shader_storage: + return "shader_storage"; + case nir_var_system_value: + return "system"; + case nir_var_shared: + return "shared"; + case nir_var_param: + case nir_var_global: + case nir_var_local: + default: + return ""; + } +} + static void print_var_decl(nir_variable *var, print_state *state) { @@ -326,13 +350,9 @@ print_var_decl(nir_variable *var, print_state *state) const char *const samp = (var->data.sample) ? "sample " : ""; const char *const patch = (var->data.patch) ? "patch " : ""; const char *const inv = (var->data.invariant) ? "invariant " : ""; - const char *const mode[] = { "shader_in ", "shader_out ", "", "", - "uniform ", "shader_storage ", "shared ", - "system "}; - - fprintf(fp, "%s%s%s%s%s%s ", - cent, samp, patch, inv, mode[var->data.mode], - glsl_interp_qualifier_name(var->data.interpolation)); + fprintf(fp, "%s%s%s%s%s %s ", + cent, samp, patch, inv, get_variable_mode_str(var->data.mode), + glsl_interp_qualifier_name(var->data.interpolation)); glsl_print_type(var->type, fp); From 2d5bd66e4f5ba15464c1e915a259d2442e88f736 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 14 Apr 2016 13:02:48 -0700 Subject: [PATCH 06/13] configure: Add support for detecting valgrind headers We have several places where the Vulkan driver explicitly hooks into valgrind when it's available. We need to be able to detect it. Reviewed-by: Matt Turner Reviewed-by: Emil Velikov --- configure.ac | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/configure.ac b/configure.ac index 8c82c43501b..4313aff9116 100644 --- a/configure.ac +++ b/configure.ac @@ -2446,6 +2446,27 @@ AC_SUBST([XA_MINOR], $XA_MINOR) AC_SUBST([XA_TINY], $XA_TINY) AC_SUBST([XA_VERSION], "$XA_MAJOR.$XA_MINOR.$XA_TINY") +AC_ARG_ENABLE(valgrind, + [AS_HELP_STRING([--enable-valgrind], + [Build mesa with valgrind support (default: auto)])], + [VALGRIND=$enableval], [VALGRIND=auto]) +if test "x$VALGRIND" != xno; then + PKG_CHECK_MODULES(VALGRIND, [valgrind], [have_valgrind=yes], [have_valgrind=no]) +fi +AC_MSG_CHECKING([whether to enable Valgrind support]) +if test "x$VALGRIND" = xauto; then + VALGRIND="$have_valgrind" +fi + +if test "x$VALGRIND" = "xyes"; then + if ! test "x$have_valgrind" = xyes; then + AC_MSG_ERROR([Valgrind support required but not present]) + fi + AC_DEFINE([HAVE_VALGRIND], 1, [Use valgrind intrinsics to suppress false warnings]) +fi + +AC_MSG_RESULT([$VALGRIND]) + dnl Restore LDFLAGS and CPPFLAGS LDFLAGS="$_SAVE_LDFLAGS" CPPFLAGS="$_SAVE_CPPFLAGS" From ade3108bb5b074013417b31e61b8077ccefb7484 Mon Sep 17 00:00:00 2001 From: Mark Janes Date: Tue, 12 Apr 2016 11:52:53 -0700 Subject: [PATCH 07/13] util: Fix race condition on libgcrypt initialization Fixes intermittent Vulkan CTS failures within the test groups: dEQP-VK.api.object_management.multithreaded_per_thread_device dEQP-VK.api.object_management.multithreaded_per_thread_resources dEQP-VK.api.object_management.multithreaded_shared_resources Signed-off-by: Mark Janes Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94904 Reviewed-by: Edward O'Callaghan Reviewed-by: Jason Ekstrand --- src/util/mesa-sha1.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/util/mesa-sha1.c b/src/util/mesa-sha1.c index faa1c871b5d..ca6b89bb2c7 100644 --- a/src/util/mesa-sha1.c +++ b/src/util/mesa-sha1.c @@ -175,21 +175,24 @@ _mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20]) #elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */ #include +#include "c11/threads.h" + +static void _mesa_libgcrypt_init(void) +{ + if (!gcry_check_version(NULL)) + return NULL; + gcry_control(GCRYCTL_DISABLE_SECMEM, 0); + gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); +} struct mesa_sha1 * _mesa_sha1_init(void) { - static int init; + static once_flag flag = ONCE_FLAG_INIT; gcry_md_hd_t h; gcry_error_t err; - if (!init) { - if (!gcry_check_version(NULL)) - return NULL; - gcry_control(GCRYCTL_DISABLE_SECMEM, 0); - gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); - init = 1; - } + call_once(&flag, _mesa_libgcrypt_init); err = gcry_md_open(&h, GCRY_MD_SHA1, 0); if (err) From f6d21bcd6b5cd5073a571034ec640177b0abf82d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 15 Apr 2016 11:43:00 -0700 Subject: [PATCH 08/13] vc4: Fix subimage accesses to LT textures. This code started out like the T case, iterating over utile offsets, but I had partially switched it to iterating over pixel offsets. I hadn't caught this before because it's unusual to do piecemeal uploads to small textures. Fixes bad text rendering in QT5 apps, which use a 256x16 glyph cache. Also fixes 6 piglit tests related to glTexSubImage() and glGetTexSubImage(). Cc: "11.1 11.2" --- src/gallium/drivers/vc4/vc4_tiling.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_tiling.c b/src/gallium/drivers/vc4/vc4_tiling.c index cf86eb0fa31..2a803ab62ba 100644 --- a/src/gallium/drivers/vc4/vc4_tiling.c +++ b/src/gallium/drivers/vc4/vc4_tiling.c @@ -140,8 +140,8 @@ vc4_load_lt_image(void *dst, uint32_t dst_stride, { uint32_t utile_w = vc4_utile_width(cpp); uint32_t utile_h = vc4_utile_height(cpp); - uint32_t xstart = box->x / utile_w; - uint32_t ystart = box->y / utile_h; + uint32_t xstart = box->x; + uint32_t ystart = box->y; for (uint32_t y = 0; y < box->height; y += utile_h) { for (int x = 0; x < box->width; x += utile_w) { @@ -161,8 +161,8 @@ vc4_store_lt_image(void *dst, uint32_t dst_stride, { uint32_t utile_w = vc4_utile_width(cpp); uint32_t utile_h = vc4_utile_height(cpp); - uint32_t xstart = box->x / utile_w; - uint32_t ystart = box->y / utile_h; + uint32_t xstart = box->x; + uint32_t ystart = box->y; for (uint32_t y = 0; y < box->height; y += utile_h) { for (int x = 0; x < box->width; x += utile_w) { From ee72fec9cfaddfef78a112f0b8d2f3f7f67a6535 Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Fri, 15 Apr 2016 12:38:25 -0500 Subject: [PATCH 09/13] gallium/swr: allow swr use as a swrast dri driver Reviewed-by: Emil Velikov Tested-by: Ilia Mirkin --- configure.ac | 3 +++ .../auxiliary/target-helpers/sw_helper.h | 15 +++++++++++++-- src/gallium/drivers/swr/Automake.inc | 8 ++++++++ src/gallium/targets/dri/Makefile.am | 1 + src/gallium/targets/pipe-loader/Makefile.am | 19 ++++++++++++++----- 5 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 src/gallium/drivers/swr/Automake.inc diff --git a/configure.ac b/configure.ac index 4313aff9116..4a41d8f973e 100644 --- a/configure.ac +++ b/configure.ac @@ -2378,6 +2378,9 @@ AM_CONDITIONAL(HAVE_GALLIUM_FREEDRENO, test "x$HAVE_GALLIUM_FREEDRENO" = xyes) AM_CONDITIONAL(HAVE_GALLIUM_SOFTPIPE, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes) AM_CONDITIONAL(HAVE_GALLIUM_LLVMPIPE, test "x$HAVE_GALLIUM_LLVMPIPE" = xyes) AM_CONDITIONAL(HAVE_GALLIUM_SWR, test "x$HAVE_GALLIUM_SWR" = xyes) +AM_CONDITIONAL(HAVE_GALLIUM_SWRAST, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes -o \ + "x$HAVE_GALLIUM_LLVMPIPE" = xyes -o \ + "x$HAVE_GALLIUM_SWR" = xyes) AM_CONDITIONAL(HAVE_GALLIUM_VC4, test "x$HAVE_GALLIUM_VC4" = xyes) AM_CONDITIONAL(HAVE_GALLIUM_VIRGL, test "x$HAVE_GALLIUM_VIRGL" = xyes) diff --git a/src/gallium/auxiliary/target-helpers/sw_helper.h b/src/gallium/auxiliary/target-helpers/sw_helper.h index ae5f3de92ba..5e4e9f78af6 100644 --- a/src/gallium/auxiliary/target-helpers/sw_helper.h +++ b/src/gallium/auxiliary/target-helpers/sw_helper.h @@ -9,7 +9,7 @@ /* Helper function to choose and instantiate one of the software rasterizers: - * llvmpipe, softpipe. + * llvmpipe, softpipe, swr. */ #ifdef GALLIUM_SOFTPIPE @@ -20,6 +20,10 @@ #include "llvmpipe/lp_public.h" #endif +#ifdef GALLIUM_SWR +#include "swr/swr_public.h" +#endif + #ifdef GALLIUM_VIRGL #include "virgl/virgl_public.h" #include "virgl/vtest/virgl_vtest_public.h" @@ -44,10 +48,15 @@ sw_screen_create_named(struct sw_winsys *winsys, const char *driver) #endif #if defined(GALLIUM_SOFTPIPE) - if (screen == NULL) + if (screen == NULL && strcmp(driver, "softpipe") == 0) screen = softpipe_create_screen(winsys); #endif +#if defined(GALLIUM_SWR) + if (screen == NULL && strcmp(driver, "swr") == 0) + screen = swr_create_screen(winsys); +#endif + return screen; } @@ -62,6 +71,8 @@ sw_screen_create(struct sw_winsys *winsys) default_driver = "llvmpipe"; #elif defined(GALLIUM_SOFTPIPE) default_driver = "softpipe"; +#elif defined(GALLIUM_SWR) + default_driver = "swr"; #else default_driver = ""; #endif diff --git a/src/gallium/drivers/swr/Automake.inc b/src/gallium/drivers/swr/Automake.inc new file mode 100644 index 00000000000..a51921455a9 --- /dev/null +++ b/src/gallium/drivers/swr/Automake.inc @@ -0,0 +1,8 @@ +if HAVE_GALLIUM_SWR + +TARGET_DRIVERS += swrast +TARGET_CPPFLAGS += -DGALLIUM_SWR +TARGET_LIB_DEPS += \ + $(top_builddir)/src/gallium/drivers/swr/libmesaswr.la + +endif diff --git a/src/gallium/targets/dri/Makefile.am b/src/gallium/targets/dri/Makefile.am index 2666524fbfe..f42dd25a56b 100644 --- a/src/gallium/targets/dri/Makefile.am +++ b/src/gallium/targets/dri/Makefile.am @@ -86,6 +86,7 @@ include $(top_srcdir)/src/gallium/drivers/virgl/Automake.inc include $(top_srcdir)/src/gallium/drivers/softpipe/Automake.inc include $(top_srcdir)/src/gallium/drivers/llvmpipe/Automake.inc +include $(top_srcdir)/src/gallium/drivers/swr/Automake.inc if HAVE_GALLIUM_STATIC_TARGETS diff --git a/src/gallium/targets/pipe-loader/Makefile.am b/src/gallium/targets/pipe-loader/Makefile.am index 0b516de0b5b..18b403f7331 100644 --- a/src/gallium/targets/pipe-loader/Makefile.am +++ b/src/gallium/targets/pipe-loader/Makefile.am @@ -192,16 +192,18 @@ pipe_vmwgfx_la_LIBADD = \ endif -if HAVE_GALLIUM_SOFTPIPE -AM_CPPFLAGS += -DGALLIUM_SOFTPIPE - +if HAVE_GALLIUM_SWRAST pipe_LTLIBRARIES += pipe_swrast.la pipe_swrast_la_SOURCES = pipe_swrast.c nodist_EXTRA_pipe_swrast_la_SOURCES = dummy.cpp +pipe_swrast_la_LIBADD = $(PIPE_LIBS) -pipe_swrast_la_LIBADD = \ - $(PIPE_LIBS) \ +if HAVE_GALLIUM_SOFTPIPE +AM_CPPFLAGS += -DGALLIUM_SOFTPIPE + +pipe_swrast_la_LIBADD += \ $(top_builddir)/src/gallium/drivers/softpipe/libsoftpipe.la +endif if HAVE_GALLIUM_LLVMPIPE AM_CPPFLAGS += -DGALLIUM_LLVMPIPE @@ -210,6 +212,13 @@ pipe_swrast_la_LIBADD += \ $(top_builddir)/src/gallium/drivers/llvmpipe/libllvmpipe.la endif +if HAVE_GALLIUM_SWR +AM_CPPFLAGS += -DGALLIUM_SWR + +pipe_swrast_la_LIBADD += \ + $(top_builddir)/src/gallium/drivers/swr/libmesaswr.la +endif + pipe_swrast_la_LIBADD += \ $(GALLIUM_PIPE_LOADER_WINSYS_LIBS) From 082f6d75aef4e672b6e41ee77630d3add7e1ef5d Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Thu, 14 Apr 2016 18:23:33 -0500 Subject: [PATCH 10/13] gallium/swr: confine c++11 flag to swr driver On the philosophy that a driver shouldn't change the compile flags for the entire tree, take the clove approach of moving the c++11 flag to the swr driver directory. Reviewed-by: Emil Velikov --- configure.ac | 9 +- m4/ax_cxx_compile_stdcxx.m4 | 558 ---------------------------- src/gallium/drivers/swr/Makefile.am | 5 +- 3 files changed, 10 insertions(+), 562 deletions(-) delete mode 100644 m4/ax_cxx_compile_stdcxx.m4 diff --git a/configure.ac b/configure.ac index 4a41d8f973e..c9086ac196e 100644 --- a/configure.ac +++ b/configure.ac @@ -2265,14 +2265,19 @@ if test -n "$with_gallium_drivers"; then fi ;; xswr) - AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) swr_llvm_check "swr" - AC_MSG_CHECKING([whether $CXX supports AVX/AVX2]) + AC_MSG_CHECKING([whether $CXX supports c++11/AVX/AVX2]) AVX_CXXFLAGS="-march=core-avx-i" AVX2_CXXFLAGS="-march=core-avx2" AC_LANG_PUSH([C++]) + save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="-std=c++11 $CXXFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[], + [AC_MSG_ERROR([c++11 compiler support not detected])]) + CXXFLAGS="$save_CXXFLAGS" + save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$AVX_CXXFLAGS $CXXFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[], diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 deleted file mode 100644 index 079e17d2a62..00000000000 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ /dev/null @@ -1,558 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) -# -# DESCRIPTION -# -# Check for baseline language coverage in the compiler for the specified -# version of the C++ standard. If necessary, add switches to CXXFLAGS to -# enable support. VERSION may be '11' (for the C++11 standard) or '14' -# (for the C++14 standard). -# -# The second argument, if specified, indicates whether you insist on an -# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. -# -std=c++11). If neither is specified, you get whatever works, with -# preference for an extended mode. -# -# The third argument, if specified 'mandatory' or if left unspecified, -# indicates that baseline support for the specified C++ standard is -# required and that the macro should error out if no mode with that -# support is found. If specified 'optional', then configuration proceeds -# regardless, after defining HAVE_CXX${VERSION} if and only if a -# supporting mode is found. -# -# LICENSE -# -# Copyright (c) 2008 Benjamin Kosnik -# Copyright (c) 2012 Zack Weinberg -# Copyright (c) 2013 Roy Stogner -# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov -# Copyright (c) 2015 Paul Norman -# Copyright (c) 2015 Moritz Klammler -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 1 - -dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro -dnl (serial version number 13). - -AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl - m4_if([$1], [11], [], - [$1], [14], [], - [$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])], - [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$2], [], [], - [$2], [ext], [], - [$2], [noext], [], - [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], - [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], - [$3], [optional], [ax_cxx_compile_cxx$1_required=false], - [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) - AC_LANG_PUSH([C++])dnl - ac_success=no - AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, - ax_cv_cxx_compile_cxx$1, - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [ax_cv_cxx_compile_cxx$1=yes], - [ax_cv_cxx_compile_cxx$1=no])]) - if test x$ax_cv_cxx_compile_cxx$1 = xyes; then - ac_success=yes - fi - - m4_if([$2], [noext], [], [dnl - if test x$ac_success = xno; then - for switch in -std=gnu++$1 -std=gnu++0x; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXXFLAGS="$ac_save_CXXFLAGS"]) - if eval test x\$$cachevar = xyes; then - CXXFLAGS="$CXXFLAGS $switch" - ac_success=yes - break - fi - done - fi]) - - m4_if([$2], [ext], [], [dnl - if test x$ac_success = xno; then - dnl HP's aCC needs +std=c++11 according to: - dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf - dnl Cray's crayCC needs "-h std=c++11" - for switch in -std=c++$1 -std=c++0x +std=c++$1 "-h std=c++$1"; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXXFLAGS="$ac_save_CXXFLAGS"]) - if eval test x\$$cachevar = xyes; then - CXXFLAGS="$CXXFLAGS $switch" - ac_success=yes - break - fi - done - fi]) - AC_LANG_POP([C++]) - if test x$ax_cxx_compile_cxx$1_required = xtrue; then - if test x$ac_success = xno; then - AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) - fi - else - if test x$ac_success = xno; then - HAVE_CXX$1=0 - AC_MSG_NOTICE([No compiler with C++$1 support was found]) - else - HAVE_CXX$1=1 - AC_DEFINE(HAVE_CXX$1,1, - [define if the compiler supports basic C++$1 syntax]) - fi - - AC_SUBST(HAVE_CXX$1) - fi -]) - - -dnl Test body for checking C++11 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 -) - - -dnl Test body for checking C++14 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 -) - - -dnl Tests for new features in C++11 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ - -// If the compiler admits that it is not ready for C++11, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201103L - -#error "This is not a C++11 compiler" - -#else - -namespace cxx11 -{ - - namespace test_static_assert - { - - template - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; - - } - - namespace test_final_override - { - - struct Base - { - virtual void f() {} - }; - - struct Derived : public Base - { - virtual void f() override {} - }; - - } - - namespace test_double_right_angle_brackets - { - - template < typename T > - struct check {}; - - typedef check single_type; - typedef check> double_type; - typedef check>> triple_type; - typedef check>>> quadruple_type; - - } - - namespace test_decltype - { - - int - f() - { - int a = 1; - decltype(a) b = 2; - return a + b; - } - - } - - namespace test_type_deduction - { - - template < typename T1, typename T2 > - struct is_same - { - static const bool value = false; - }; - - template < typename T > - struct is_same - { - static const bool value = true; - }; - - template < typename T1, typename T2 > - auto - add(T1 a1, T2 a2) -> decltype(a1 + a2) - { - return a1 + a2; - } - - int - test(const int c, volatile int v) - { - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == false, ""); - auto ac = c; - auto av = v; - auto sumi = ac + av + 'x'; - auto sumf = ac + av + 1.0; - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == true, ""); - return (sumf > 0.0) ? sumi : add(c, v); - } - - } - - namespace test_noexcept - { - - int f() { return 0; } - int g() noexcept { return 0; } - - static_assert(noexcept(f()) == false, ""); - static_assert(noexcept(g()) == true, ""); - - } - - namespace test_constexpr - { - - template < typename CharT > - unsigned long constexpr - strlen_c_r(const CharT *const s, const unsigned long acc) noexcept - { - return *s ? strlen_c_r(s + 1, acc + 1) : acc; - } - - template < typename CharT > - unsigned long constexpr - strlen_c(const CharT *const s) noexcept - { - return strlen_c_r(s, 0UL); - } - - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("1") == 1UL, ""); - static_assert(strlen_c("example") == 7UL, ""); - static_assert(strlen_c("another\0example") == 7UL, ""); - - } - - namespace test_rvalue_references - { - - template < int N > - struct answer - { - static constexpr int value = N; - }; - - answer<1> f(int&) { return answer<1>(); } - answer<2> f(const int&) { return answer<2>(); } - answer<3> f(int&&) { return answer<3>(); } - - void - test() - { - int i = 0; - const int c = 0; - static_assert(decltype(f(i))::value == 1, ""); - static_assert(decltype(f(c))::value == 2, ""); - static_assert(decltype(f(0))::value == 3, ""); - } - - } - - namespace test_uniform_initialization - { - - struct test - { - static const int zero {}; - static const int one {1}; - }; - - static_assert(test::zero == 0, ""); - static_assert(test::one == 1, ""); - - } - - namespace test_lambdas - { - - void - test1() - { - auto lambda1 = [](){}; - auto lambda2 = lambda1; - lambda1(); - lambda2(); - } - - int - test2() - { - auto a = [](int i, int j){ return i + j; }(1, 2); - auto b = []() -> int { return '0'; }(); - auto c = [=](){ return a + b; }(); - auto d = [&](){ return c; }(); - auto e = [a, &b](int x) mutable { - const auto identity = [](int y){ return y; }; - for (auto i = 0; i < a; ++i) - a += b--; - return x + identity(a + b); - }(0); - return a + b + c + d + e; - } - - int - test3() - { - const auto nullary = [](){ return 0; }; - const auto unary = [](int x){ return x; }; - using nullary_t = decltype(nullary); - using unary_t = decltype(unary); - const auto higher1st = [](nullary_t f){ return f(); }; - const auto higher2nd = [unary](nullary_t f1){ - return [unary, f1](unary_t f2){ return f2(unary(f1())); }; - }; - return higher1st(nullary) + higher2nd(nullary)(unary); - } - - } - - namespace test_variadic_templates - { - - template - struct sum; - - template - struct sum - { - static constexpr auto value = N0 + sum::value; - }; - - template <> - struct sum<> - { - static constexpr auto value = 0; - }; - - static_assert(sum<>::value == 0, ""); - static_assert(sum<1>::value == 1, ""); - static_assert(sum<23>::value == 23, ""); - static_assert(sum<1, 2>::value == 3, ""); - static_assert(sum<5, 5, 11>::value == 21, ""); - static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); - - } - - // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae - // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function - // because of this. - namespace test_template_alias_sfinae - { - - struct foo {}; - - template - using member = typename T::member_type; - - template - void func(...) {} - - template - void func(member*) {} - - void test(); - - void test() { func(0); } - - } - -} // namespace cxx11 - -#endif // __cplusplus >= 201103L - -]]) - - -dnl Tests for new features in C++14 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ - -// If the compiler admits that it is not ready for C++14, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201402L - -#error "This is not a C++14 compiler" - -#else - -namespace cxx14 -{ - - namespace test_polymorphic_lambdas - { - - int - test() - { - const auto lambda = [](auto&&... args){ - const auto istiny = [](auto x){ - return (sizeof(x) == 1UL) ? 1 : 0; - }; - const int aretiny[] = { istiny(args)... }; - return aretiny[0]; - }; - return lambda(1, 1L, 1.0f, '1'); - } - - } - - namespace test_binary_literals - { - - constexpr auto ivii = 0b0000000000101010; - static_assert(ivii == 42, "wrong value"); - - } - - namespace test_generalized_constexpr - { - - template < typename CharT > - constexpr unsigned long - strlen_c(const CharT *const s) noexcept - { - auto length = 0UL; - for (auto p = s; *p; ++p) - ++length; - return length; - } - - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("x") == 1UL, ""); - static_assert(strlen_c("test") == 4UL, ""); - static_assert(strlen_c("another\0test") == 7UL, ""); - - } - - namespace test_lambda_init_capture - { - - int - test() - { - auto x = 0; - const auto lambda1 = [a = x](int b){ return a + b; }; - const auto lambda2 = [a = lambda1(x)](){ return a; }; - return lambda2(); - } - - } - - namespace test_digit_seperators - { - - constexpr auto ten_million = 100'000'000; - static_assert(ten_million == 100000000, ""); - - } - - namespace test_return_type_deduction - { - - auto f(int& x) { return x; } - decltype(auto) g(int& x) { return x; } - - template < typename T1, typename T2 > - struct is_same - { - static constexpr auto value = false; - }; - - template < typename T > - struct is_same - { - static constexpr auto value = true; - }; - - int - test() - { - auto x = 0; - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - return x; - } - - } - -} // namespace cxx14 - -#endif // __cplusplus >= 201402L - -]]) diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am index d6d6e7dc611..b1ff4233b56 100644 --- a/src/gallium/drivers/swr/Makefile.am +++ b/src/gallium/drivers/swr/Makefile.am @@ -22,7 +22,7 @@ include Makefile.sources include $(top_srcdir)/src/gallium/Automake.inc -AM_CXXFLAGS = $(GALLIUM_DRIVER_CFLAGS) +AM_CXXFLAGS = $(GALLIUM_DRIVER_CFLAGS) -std=c++11 noinst_LTLIBRARIES = libmesaswr.la @@ -30,7 +30,8 @@ libmesaswr_la_SOURCES = $(LOADER_SOURCES) COMMON_CXXFLAGS = \ $(GALLIUM_DRIVER_CFLAGS) \ - $(LLVM_CFLAGS) \ + $(LLVM_CXXFLAGS) \ + -std=c++11 \ -I$(builddir)/rasterizer/scripts \ -I$(builddir)/rasterizer/jitter \ -I$(srcdir)/rasterizer \ From 7dac4a2889673c52bded63e2daef360e9e927eb3 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 30 Jul 2015 11:28:22 -0700 Subject: [PATCH 11/13] util/list: Add list splicing functions This adds functions for splicing one list into another. These have more-or-less the same API as the kernel list splicing functions. The implementation, however, was stolen from the Wayland list implementation. Reviewed-by: Mark Janes Reviewed-by: Rob Clark --- src/util/list.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/util/list.h b/src/util/list.h index 066f9b8dfe5..f0dec5da608 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -116,6 +116,28 @@ static inline unsigned list_length(struct list_head *list) return length; } +static inline void list_splice(struct list_head *src, struct list_head *dst) +{ + if (list_empty(src)) + return; + + src->next->prev = dst; + src->prev->next = dst->next; + dst->next->prev = src->prev; + dst->next = src->next; +} + +static inline void list_splicetail(struct list_head *src, struct list_head *dst) +{ + if (list_empty(src)) + return; + + src->prev->next = dst; + src->next->prev = dst->prev; + dst->prev->next = src->next; + dst->prev = src->prev; +} + static inline void list_validate(struct list_head *list) { struct list_head *node; From ce7e82fb6f10c2c812d949cdeeecdbcfb2cbef44 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 14 Apr 2016 10:45:24 -0700 Subject: [PATCH 12/13] i965/surface_formats: Update some formats for more recent gens The surface format table hasn't entirely been kept up-to-date. This commit marks a couple more compressed formats as sampleable on gen8+ and adds the A4B4G4R4 format as renderable on gen9. Reviewed-by: Kenneth Graunke --- .../drivers/dri/i965/brw_surface_formats.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c b/src/mesa/drivers/dri/i965/brw_surface_formats.c index 118b18dcd7c..7ff15ccc0c6 100644 --- a/src/mesa/drivers/dri/i965/brw_surface_formats.c +++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c @@ -204,7 +204,7 @@ const struct brw_surface_format_info surface_formats[] = { SF(50, 50, x, x, x, x, x, x, x, x, P8A8_UNORM_PALETTE0) SF(50, 50, x, x, x, x, x, x, x, x, P8A8_UNORM_PALETTE1) SF( x, x, x, x, x, x, x, x, x, x, A1B5G5R5_UNORM) - SF( x, x, x, x, x, x, x, x, x, x, A4B4G4R4_UNORM) + SF(90, 90, x, x, 90, x, x, x, x, x, A4B4G4R4_UNORM) SF( x, x, x, x, x, x, x, x, x, x, L8A8_UINT) SF( x, x, x, x, x, x, x, x, x, x, L8A8_SINT) SF( Y, Y, x, 45, Y, Y, Y, x, x, x, R8_UNORM) @@ -267,13 +267,13 @@ const struct brw_surface_format_info surface_formats[] = { SF(70, 70, x, x, x, x, x, x, x, x, BC6H_UF16) SF( x, x, x, x, x, x, x, x, x, x, PLANAR_420_8) SF( x, x, x, x, x, x, x, x, x, x, R8G8B8_UNORM_SRGB) - SF( x, x, x, x, x, x, x, x, x, x, ETC1_RGB8) - SF( x, x, x, x, x, x, x, x, x, x, ETC2_RGB8) - SF( x, x, x, x, x, x, x, x, x, x, EAC_R11) - SF( x, x, x, x, x, x, x, x, x, x, EAC_RG11) - SF( x, x, x, x, x, x, x, x, x, x, EAC_SIGNED_R11) - SF( x, x, x, x, x, x, x, x, x, x, EAC_SIGNED_RG11) - SF( x, x, x, x, x, x, x, x, x, x, ETC2_SRGB8) + SF(80, 80, x, x, x, x, x, x, x, x, ETC1_RGB8) + SF(80, 80, x, x, x, x, x, x, x, x, ETC2_RGB8) + SF(80, 80, x, x, x, x, x, x, x, x, EAC_R11) + SF(80, 80, x, x, x, x, x, x, x, x, EAC_RG11) + SF(80, 80, x, x, x, x, x, x, x, x, EAC_SIGNED_R11) + SF(80, 80, x, x, x, x, x, x, x, x, EAC_SIGNED_RG11) + SF(80, 80, x, x, x, x, x, x, x, x, ETC2_SRGB8) SF( x, x, x, x, x, x, x, x, x, x, R16G16B16_UINT) SF( x, x, x, x, x, x, x, x, x, x, R16G16B16_SINT) SF( x, x, x, x, x, x, x, x, x, x, R32_SFIXED) @@ -288,10 +288,10 @@ const struct brw_surface_format_info surface_formats[] = { SF( x, x, x, x, x, x, x, x, x, x, B10G10R10A2_SINT) SF( x, x, x, x, x, x, x, x, x, x, R64G64B64A64_PASSTHRU) SF( x, x, x, x, x, x, x, x, x, x, R64G64B64_PASSTHRU) - SF( x, x, x, x, x, x, x, x, x, x, ETC2_RGB8_PTA) - SF( x, x, x, x, x, x, x, x, x, x, ETC2_SRGB8_PTA) - SF( x, x, x, x, x, x, x, x, x, x, ETC2_EAC_RGBA8) - SF( x, x, x, x, x, x, x, x, x, x, ETC2_EAC_SRGB8_A8) + SF(80, 80, x, x, x, x, x, x, x, x, ETC2_RGB8_PTA) + SF(80, 80, x, x, x, x, x, x, x, x, ETC2_SRGB8_PTA) + SF(80, 80, x, x, x, x, x, x, x, x, ETC2_EAC_RGBA8) + SF(80, 80, x, x, x, x, x, x, x, x, ETC2_EAC_SRGB8_A8) SF( x, x, x, x, x, x, x, x, x, x, R8G8B8_UINT) SF( x, x, x, x, x, x, x, x, x, x, R8G8B8_SINT) SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_4x4_FLT16) From 1a100d4f2827cdfed67b563fba7ef2d9ea6a926b Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 14 Apr 2016 13:04:22 -0700 Subject: [PATCH 13/13] configure: Add support for the Intel Vulkan driver This adds a --with-vulkan-drivers option with one driver, "intel". In the future, we may add more drivers to this list. v2: Don't enable any drivers by default. This should prevent this patch from breaking anyone's build. Reviewed-by: Kenneth Graunke --- configure.ac | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/configure.ac b/configure.ac index c9086ac196e..78895a3ced4 100644 --- a/configure.ac +++ b/configure.ac @@ -1545,6 +1545,56 @@ if test -n "$with_dri_drivers"; then DRI_DIRS=`echo $DRI_DIRS|tr " " "\n"|sort -u|tr "\n" " "` fi + +# +# Vulkan driver configuration +# + +AC_ARG_WITH([vulkan-drivers], + [AS_HELP_STRING([--with-vulkan-drivers@<:@=DIRS...@:>@], + [comma delimited Vulkan drivers list, e.g. + "intel" + @<:@default=no@:>@])], + [with_vulkan_drivers="$withval"], + [with_vulkan_drivers="no"]) + +# Doing '--without-vulkan-drivers' will set this variable to 'no'. Clear it +# here so that the script doesn't choke on an unknown driver name later. +case "x$with_vulkan_drivers" in + xyes) with_vulkan_drivers="$VULKAN_DRIVERS_DEFAULT" ;; + xno) with_vulkan_drivers='' ;; +esac + +AC_ARG_WITH([vulkan-icddir], + [AS_HELP_STRING([--with-vulkan-icddir=DIR], + [directory for the Vulkan driver icd files @<:@${sysconfdir}/vulkan/icd.d@:>@])], + [VULKAN_ICD_INSTALL_DIR="$withval"], + [VULKAN_ICD_INSTALL_DIR='${sysconfdir}/vulkan/icd.d']) +AC_SUBST([VULKAN_ICD_INSTALL_DIR]) + +if test -n "$with_vulkan_drivers"; then + VULKAN_DRIVERS=`IFS=', '; echo $with_vulkan_drivers` + for driver in $VULKAN_DRIVERS; do + case "x$driver" in + xintel) + if test "x$HAVE_I965_DRI" != xyes; then + AC_MSG_ERROR([Intel Vulkan driver requires the i965 dri driver]) + fi + if test "x$with_sha1" == "x"; then + AC_MSG_ERROR([Intel Vulkan driver requires SHA1]) + fi + HAVE_INTEL_VULKAN=yes; + + ;; + *) + AC_MSG_ERROR([Vulkan driver '$driver' does not exist]) + ;; + esac + done + VULKAN_DRIVERS=`echo $VULKAN_DRIVERS|tr " " "\n"|sort -u|tr "\n" " "` +fi + + AM_CONDITIONAL(NEED_MEGADRIVER, test -n "$DRI_DIRS") AM_CONDITIONAL(NEED_LIBMESA, test "x$enable_xlib_glx" = xyes -o \ "x$enable_osmesa" = xyes -o \ @@ -2407,6 +2457,10 @@ AM_CONDITIONAL(HAVE_R200_DRI, test x$HAVE_R200_DRI = xyes) AM_CONDITIONAL(HAVE_RADEON_DRI, test x$HAVE_RADEON_DRI = xyes) AM_CONDITIONAL(HAVE_SWRAST_DRI, test x$HAVE_SWRAST_DRI = xyes) +AM_CONDITIONAL(HAVE_INTEL_VULKAN, test "x$HAVE_INTEL_VULKAN" = xyes) + +AM_CONDITIONAL(HAVE_INTEL_DRIVERS, test "x$HAVE_INTEL_VULKAN" = xyes) + AM_CONDITIONAL(NEED_RADEON_DRM_WINSYS, test "x$HAVE_GALLIUM_R300" = xyes -o \ "x$HAVE_GALLIUM_R600" = xyes -o \ "x$HAVE_GALLIUM_RADEONSI" = xyes) @@ -2660,6 +2714,15 @@ if test "$enable_egl" = yes; then echo " EGL drivers: $egl_drivers" fi +# Vulkan +echo "" +if test "x$VULKAN_DRIVERS" != x; then + echo " Vulkan drivers: $VULKAN_DRIVERS" + echo " Vulkan ICD dir: $VULKAN_ICD_INSTALL_DIR" +else + echo " Vulkan drivers: no" +fi + echo "" if test "x$MESA_LLVM" = x1; then echo " llvm: yes"