diff options
Diffstat (limited to 'lib/mesa/src/gallium/winsys/virgl/drm')
-rw-r--r-- | lib/mesa/src/gallium/winsys/virgl/drm/Makefile.in | 59 | ||||
-rw-r--r-- | lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 90 | ||||
-rw-r--r-- | lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h | 1 |
3 files changed, 118 insertions, 32 deletions
diff --git a/lib/mesa/src/gallium/winsys/virgl/drm/Makefile.in b/lib/mesa/src/gallium/winsys/virgl/drm/Makefile.in index 73440d41e..f599e0433 100644 --- a/lib/mesa/src/gallium/winsys/virgl/drm/Makefile.in +++ b/lib/mesa/src/gallium/winsys/virgl/drm/Makefile.in @@ -79,10 +79,14 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ @HAVE_LIBDRM_TRUE@am__append_1 = \ @HAVE_LIBDRM_TRUE@ $(LIBDRM_LIBS) -@HAVE_DRISW_TRUE@am__append_2 = \ +@HAVE_PLATFORM_ANDROID_TRUE@am__append_2 = \ +@HAVE_PLATFORM_ANDROID_TRUE@ $(ANDROID_LIBS) \ +@HAVE_PLATFORM_ANDROID_TRUE@ $(BACKTRACE_LIBS) + +@HAVE_DRISW_TRUE@am__append_3 = \ @HAVE_DRISW_TRUE@ $(top_builddir)/src/gallium/winsys/sw/dri/libswdri.la -@HAVE_DRISW_KMS_TRUE@am__append_3 = \ +@HAVE_DRISW_KMS_TRUE@am__append_4 = \ @HAVE_DRISW_KMS_TRUE@ $(top_builddir)/src/gallium/winsys/sw/kms-dri/libswkmsdri.la \ @HAVE_DRISW_KMS_TRUE@ $(LIBDRM_LIBS) @@ -169,6 +173,8 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BACKTRACE_CFLAGS = @BACKTRACE_CFLAGS@ +BACKTRACE_LIBS = @BACKTRACE_LIBS@ BSYMBOLIC = @BSYMBOLIC@ CC = @CC@ CCAS = @CCAS@ @@ -182,6 +188,7 @@ CLOVER_STD_OVERRIDE = @CLOVER_STD_OVERRIDE@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ +CXX11_CXXFLAGS = @CXX11_CXXFLAGS@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ @@ -215,8 +222,6 @@ EXEEXT = @EXEEXT@ EXPAT_CFLAGS = @EXPAT_CFLAGS@ EXPAT_LIBS = @EXPAT_LIBS@ FGREP = @FGREP@ -FREEDRENO_CFLAGS = @FREEDRENO_CFLAGS@ -FREEDRENO_LIBS = @FREEDRENO_LIBS@ GALLIUM_PIPE_LOADER_DEFINES = @GALLIUM_PIPE_LOADER_DEFINES@ GBM_PC_LIB_PRIV = @GBM_PC_LIB_PRIV@ GBM_PC_REQ_PRIV = @GBM_PC_REQ_PRIV@ @@ -235,8 +240,8 @@ GL_LIB_DEPS = @GL_LIB_DEPS@ GL_PC_CFLAGS = @GL_PC_CFLAGS@ GL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@ GL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@ +GL_PKGCONF_LIB = @GL_PKGCONF_LIB@ GREP = @GREP@ -HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@ I915_CFLAGS = @I915_CFLAGS@ I915_LIBS = @I915_LIBS@ INDENT = @INDENT@ @@ -248,6 +253,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LD_BUILD_ID = @LD_BUILD_ID@ LD_NO_UNDEFINED = @LD_NO_UNDEFINED@ LEX = @LEX@ LEXLIB = @LEXLIB@ @@ -285,7 +291,7 @@ MSVC2013_COMPAT_CFLAGS = @MSVC2013_COMPAT_CFLAGS@ MSVC2013_COMPAT_CXXFLAGS = @MSVC2013_COMPAT_CXXFLAGS@ NINE_MAJOR = @NINE_MAJOR@ NINE_MINOR = @NINE_MINOR@ -NINE_TINY = @NINE_TINY@ +NINE_PATCH = @NINE_PATCH@ NINE_VERSION = @NINE_VERSION@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -298,6 +304,9 @@ OBJEXT = @OBJEXT@ OMX_BELLAGIO_CFLAGS = @OMX_BELLAGIO_CFLAGS@ OMX_BELLAGIO_LIBS = @OMX_BELLAGIO_LIBS@ OMX_BELLAGIO_LIB_INSTALL_DIR = @OMX_BELLAGIO_LIB_INSTALL_DIR@ +OMX_TIZONIA_CFLAGS = @OMX_TIZONIA_CFLAGS@ +OMX_TIZONIA_LIBS = @OMX_TIZONIA_LIBS@ +OMX_TIZONIA_LIB_INSTALL_DIR = @OMX_TIZONIA_LIB_INSTALL_DIR@ OPENCL_LIBNAME = @OPENCL_LIBNAME@ OPENCL_VERSION = @OPENCL_VERSION@ OSMESA_LIB = @OSMESA_LIB@ @@ -325,11 +334,16 @@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ PWR8_CFLAGS = @PWR8_CFLAGS@ -PYTHON2 = @PYTHON2@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ RADEON_CFLAGS = @RADEON_CFLAGS@ RADEON_LIBS = @RADEON_LIBS@ RANLIB = @RANLIB@ RM = @RM@ +SCANNER_ARG = @SCANNER_ARG@ SED = @SED@ SELINUX_CFLAGS = @SELINUX_CFLAGS@ SELINUX_LIBS = @SELINUX_LIBS@ @@ -341,9 +355,10 @@ SSE41_CFLAGS = @SSE41_CFLAGS@ STRIP = @STRIP@ SWR_AVX2_CXXFLAGS = @SWR_AVX2_CXXFLAGS@ SWR_AVX_CXXFLAGS = @SWR_AVX_CXXFLAGS@ -SWR_CXX11_CXXFLAGS = @SWR_CXX11_CXXFLAGS@ SWR_KNL_CXXFLAGS = @SWR_KNL_CXXFLAGS@ SWR_SKX_CXXFLAGS = @SWR_SKX_CXXFLAGS@ +V3D_SIMULATOR_CFLAGS = @V3D_SIMULATOR_CFLAGS@ +V3D_SIMULATOR_LIBS = @V3D_SIMULATOR_LIBS@ VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ VALGRIND_LIBS = @VALGRIND_LIBS@ VA_CFLAGS = @VA_CFLAGS@ @@ -351,8 +366,8 @@ VA_LIBS = @VA_LIBS@ VA_LIB_INSTALL_DIR = @VA_LIB_INSTALL_DIR@ VA_MAJOR = @VA_MAJOR@ VA_MINOR = @VA_MINOR@ -VC5_SIMULATOR_CFLAGS = @VC5_SIMULATOR_CFLAGS@ -VC5_SIMULATOR_LIBS = @VC5_SIMULATOR_LIBS@ +VC4_CFLAGS = @VC4_CFLAGS@ +VC4_LIBS = @VC4_LIBS@ VDPAU_CFLAGS = @VDPAU_CFLAGS@ VDPAU_LIBS = @VDPAU_LIBS@ VDPAU_LIB_INSTALL_DIR = @VDPAU_LIB_INSTALL_DIR@ @@ -366,7 +381,11 @@ VL_LIBS = @VL_LIBS@ VULKAN_ICD_INSTALL_DIR = @VULKAN_ICD_INSTALL_DIR@ WAYLAND_CLIENT_CFLAGS = @WAYLAND_CLIENT_CFLAGS@ WAYLAND_CLIENT_LIBS = @WAYLAND_CLIENT_LIBS@ +WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@ +WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@ +WAYLAND_PROTOCOLS_CFLAGS = @WAYLAND_PROTOCOLS_CFLAGS@ WAYLAND_PROTOCOLS_DATADIR = @WAYLAND_PROTOCOLS_DATADIR@ +WAYLAND_PROTOCOLS_LIBS = @WAYLAND_PROTOCOLS_LIBS@ WAYLAND_SCANNER = @WAYLAND_SCANNER@ WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@ WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@ @@ -376,16 +395,20 @@ WNO_OVERRIDE_INIT = @WNO_OVERRIDE_INIT@ X11_INCLUDES = @X11_INCLUDES@ XA_MAJOR = @XA_MAJOR@ XA_MINOR = @XA_MINOR@ -XA_TINY = @XA_TINY@ +XA_PATCH = @XA_PATCH@ XA_VERSION = @XA_VERSION@ XCB_DRI2_CFLAGS = @XCB_DRI2_CFLAGS@ XCB_DRI2_LIBS = @XCB_DRI2_LIBS@ XCB_DRI3_CFLAGS = @XCB_DRI3_CFLAGS@ XCB_DRI3_LIBS = @XCB_DRI3_LIBS@ -XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ -XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XCB_DRI3_MODIFIERS_CFLAGS = @XCB_DRI3_MODIFIERS_CFLAGS@ +XCB_DRI3_MODIFIERS_LIBS = @XCB_DRI3_MODIFIERS_LIBS@ +XCB_RANDR_CFLAGS = @XCB_RANDR_CFLAGS@ +XCB_RANDR_LIBS = @XCB_RANDR_LIBS@ XLIBGL_CFLAGS = @XLIBGL_CFLAGS@ XLIBGL_LIBS = @XLIBGL_LIBS@ +XLIB_RANDR_CFLAGS = @XLIB_RANDR_CFLAGS@ +XLIB_RANDR_LIBS = @XLIB_RANDR_LIBS@ XVMC_CFLAGS = @XVMC_CFLAGS@ XVMC_LIBS = @XVMC_LIBS@ XVMC_LIB_INSTALL_DIR = @XVMC_LIB_INSTALL_DIR@ @@ -440,9 +463,13 @@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -511,7 +538,8 @@ GALLIUM_TARGET_CFLAGS = \ $(VISIBILITY_CFLAGS) GALLIUM_COMMON_LIB_DEPS = -lm $(LIBUNWIND_LIBS) $(LIBSENSORS_LIBS) \ - $(CLOCK_LIB) $(PTHREAD_LIBS) $(DLOPEN_LIBS) $(am__append_1) + $(CLOCK_LIB) $(PTHREAD_LIBS) $(DLOPEN_LIBS) $(am__append_1) \ + $(am__append_2) GALLIUM_WINSYS_CFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/include \ @@ -523,7 +551,7 @@ GALLIUM_WINSYS_CFLAGS = \ GALLIUM_PIPE_LOADER_WINSYS_LIBS = \ $(top_builddir)/src/gallium/winsys/sw/null/libws_null.la \ $(top_builddir)/src/gallium/winsys/sw/wrapper/libwsw.la \ - $(am__append_2) $(am__append_3) + $(am__append_3) $(am__append_4) AM_CFLAGS = \ -I$(top_srcdir)/src/gallium/drivers \ $(GALLIUM_WINSYS_CFLAGS) \ @@ -531,6 +559,7 @@ AM_CFLAGS = \ noinst_LTLIBRARIES = libvirgldrm.la libvirgldrm_la_SOURCES = $(C_SOURCES) +EXTRA_DIST = meson.build all: all-am .SUFFIXES: diff --git a/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c index 7f542e7f1..98e0e99f6 100644 --- a/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c @@ -28,7 +28,7 @@ #include <sys/stat.h> #include "os/os_mman.h" -#include "os/os_time.h" +#include "util/os_time.h" #include "util/u_memory.h" #include "util/u_format.h" #include "util/u_hash_table.h" @@ -313,7 +313,7 @@ virgl_drm_winsys_resource_cache_create(struct virgl_winsys *qws, struct virgl_hw_res *res, *curr_res; struct list_head *curr, *next; int64_t now; - int ret; + int ret = 0; /* only store binds for vertex/index/const buffers */ if (bind != VIRGL_BIND_CONSTANT_BUFFER && bind != VIRGL_BIND_INDEX_BUFFER && @@ -398,7 +398,7 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, mtx_lock(&qdws->bo_handles_mutex); - if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { res = util_hash_table_get(qdws->bo_names, (void*)(uintptr_t)handle); if (res) { struct virgl_hw_res *r = NULL; @@ -407,7 +407,7 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, } } - if (whandle->type == DRM_API_HANDLE_TYPE_FD) { + if (whandle->type == WINSYS_HANDLE_TYPE_FD) { int r; r = drmPrimeFDToHandle(qdws->fd, whandle->handle, &handle); if (r) { @@ -417,7 +417,6 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, } res = util_hash_table_get(qdws->bo_handles, (void*)(uintptr_t)handle); - fprintf(stderr, "resource %p for handle %d, pfd=%d\n", res, handle, whandle->handle); if (res) { struct virgl_hw_res *r = NULL; virgl_drm_resource_reference(qdws, &r, res); @@ -428,10 +427,9 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, if (!res) goto done; - if (whandle->type == DRM_API_HANDLE_TYPE_FD) { + if (whandle->type == WINSYS_HANDLE_TYPE_FD) { res->bo_handle = handle; } else { - fprintf(stderr, "gem open handle %d\n", handle); memset(&open_arg, 0, sizeof(open_arg)); open_arg.name = whandle->handle; if (drmIoctl(qdws->fd, DRM_IOCTL_GEM_OPEN, &open_arg)) { @@ -478,7 +476,7 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws, if (!res) return FALSE; - if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { if (!res->flinked) { memset(&flink, 0, sizeof(flink)); flink.handle = res->bo_handle; @@ -494,9 +492,9 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws, mtx_unlock(&qdws->bo_handles_mutex); } whandle->handle = res->flink; - } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { + } else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) { whandle->handle = res->bo_handle; - } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { + } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { if (drmPrimeHandleToFD(qdws->fd, res->bo_handle, DRM_CLOEXEC, (int*)&whandle->handle)) return FALSE; mtx_lock(&qdws->bo_handles_mutex); @@ -619,9 +617,26 @@ static void virgl_drm_add_res(struct virgl_drm_winsys *qdws, { unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1); - if (cbuf->cres > cbuf->nres) { - fprintf(stderr,"failure to add relocation\n"); - return; + if (cbuf->cres >= cbuf->nres) { + unsigned new_nres = cbuf->nres + 256; + void *new_ptr = REALLOC(cbuf->res_bo, + cbuf->nres * sizeof(struct virgl_hw_buf*), + new_nres * sizeof(struct virgl_hw_buf*)); + if (!new_ptr) { + fprintf(stderr,"failure to add relocation %d, %d\n", cbuf->cres, new_nres); + return; + } + cbuf->res_bo = new_ptr; + + new_ptr = REALLOC(cbuf->res_hlist, + cbuf->nres * sizeof(uint32_t), + new_nres * sizeof(uint32_t)); + if (!new_ptr) { + fprintf(stderr,"failure to add hlist relocation %d, %d\n", cbuf->cres, cbuf->nres); + return; + } + cbuf->res_hlist = new_ptr; + cbuf->nres = new_nres; } cbuf->res_bo[cbuf->cres] = NULL; @@ -704,13 +719,31 @@ static int virgl_drm_get_caps(struct virgl_winsys *vws, { struct virgl_drm_winsys *vdws = virgl_drm_winsys(vws); struct drm_virtgpu_get_caps args; + int ret; - memset(&args, 0, sizeof(args)); + virgl_ws_fill_new_caps_defaults(caps); - args.cap_set_id = 1; + memset(&args, 0, sizeof(args)); + if (vdws->has_capset_query_fix) { + /* if we have the query fix - try and get cap set id 2 first */ + args.cap_set_id = 2; + args.size = sizeof(union virgl_caps); + } else { + args.cap_set_id = 1; + args.size = sizeof(struct virgl_caps_v1); + } args.addr = (unsigned long)&caps->caps; - args.size = sizeof(union virgl_caps); - return drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_GET_CAPS, &args); + + ret = drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_GET_CAPS, &args); + if (ret == -1 && errno == EINVAL) { + /* Fallback to v1 */ + args.cap_set_id = 1; + args.size = sizeof(struct virgl_caps_v1); + ret = drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_GET_CAPS, &args); + if (ret == -1) + return ret; + } + return ret; } #define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x))) @@ -777,6 +810,15 @@ static struct virgl_winsys * virgl_drm_winsys_create(int drmFD) { struct virgl_drm_winsys *qdws; + int ret; + int gl = 0; + struct drm_virtgpu_getparam getparam = {0}; + + getparam.param = VIRTGPU_PARAM_3D_FEATURES; + getparam.value = (uint64_t)(uintptr_t)≷ + ret = drmIoctl(drmFD, DRM_IOCTL_VIRTGPU_GETPARAM, &getparam); + if (ret < 0 || !gl) + return NULL; qdws = CALLOC_STRUCT(virgl_drm_winsys); if (!qdws) @@ -811,6 +853,16 @@ virgl_drm_winsys_create(int drmFD) qdws->base.fence_reference = virgl_fence_reference; qdws->base.get_caps = virgl_drm_get_caps; + + uint32_t value = 0; + getparam.param = VIRTGPU_PARAM_CAPSET_QUERY_FIX; + getparam.value = (uint64_t)(uintptr_t)&value; + ret = drmIoctl(qdws->fd, DRM_IOCTL_VIRTGPU_GETPARAM, &getparam); + if (ret == 0) { + if (value == 1) + qdws->has_capset_query_fix = true; + } + return &qdws->base; } @@ -880,6 +932,10 @@ virgl_drm_screen_create(int fd) int dup_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); vws = virgl_drm_winsys_create(dup_fd); + if (!vws) { + close(dup_fd); + goto unlock; + } pscreen = virgl_create_screen(vws); if (pscreen) { diff --git a/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h b/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h index f6772153a..b28e7127c 100644 --- a/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h +++ b/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h @@ -64,6 +64,7 @@ struct virgl_drm_winsys struct util_hash_table *bo_handles; struct util_hash_table *bo_names; mtx_t bo_handles_mutex; + bool has_capset_query_fix; }; struct virgl_drm_cmd_buf { |