Hello community,

here is the log from the commit of package virglrenderer for openSUSE:Factory 
checked in at 2017-03-11 15:19:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/virglrenderer (Old)
 and      /work/SRC/openSUSE:Factory/.virglrenderer.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "virglrenderer"

Sat Mar 11 15:19:07 2017 rev:3 rq:478186 version:0.6.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/virglrenderer/virglrenderer.changes      
2017-02-22 13:50:49.987384393 +0100
+++ /work/SRC/openSUSE:Factory/.virglrenderer.new/virglrenderer.changes 
2017-03-11 15:19:08.319784962 +0100
@@ -1,0 +2,25 @@
+Fri Mar 10 04:22:11 UTC 2017 - l...@suse.com
+
+- Fix memory leak in vertex elements state create (CVE-2017-6386 bsc#1027376)
+  0001-737c3350-renderer-fix-memory-leak-in-vertex-elements-state-cr.patch
+
+-------------------------------------------------------------------
+Thu Mar  2 09:24:22 UTC 2017 - jeng...@inai.de
+
+- Fix RPM groups
+
+-------------------------------------------------------------------
+Fri Feb 24 09:03:26 UTC 2017 - l...@suse.com
+
+- Update package to 0.6.0
+  The following patches will be removed:
+  0001-48f67f60-renderer-fix-NULL-pointer-deref-in-vrend_clear.patch
+  0002-40b0e781-renderer-fix-a-leak-in-resource-attach.patch
+  0003-6eb13f7a-vrend-fix-memory-leak-in-int-blit-context.patch
+  0004-114688c5-renderer-fix-heap-overflow-in-vertex-elements-state-.patch
+  0005-926b9b34-vrend-fix-a-stack-overflow-in-set-framebuffer-state.patch
+
+  All of the removed patches were already included in 0.6.0,
+  So we dont need them any more.
+
+-------------------------------------------------------------------

Old:
----
  0001-48f67f60-renderer-fix-NULL-pointer-deref-in-vrend_clear.patch
  0002-40b0e781-renderer-fix-a-leak-in-resource-attach.patch
  0003-6eb13f7a-vrend-fix-memory-leak-in-int-blit-context.patch
  0004-114688c5-renderer-fix-heap-overflow-in-vertex-elements-state-.patch
  0005-926b9b34-vrend-fix-a-stack-overflow-in-set-framebuffer-state.patch
  virglrenderer-0.5.0.tar.bz2

New:
----
  0001-737c3350-renderer-fix-memory-leak-in-vertex-elements-state-cr.patch
  virglrenderer-0.6.0.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ virglrenderer.spec ++++++
--- /var/tmp/diff_new_pack.mbd7EY/_old  2017-03-11 15:19:08.903702331 +0100
+++ /var/tmp/diff_new_pack.mbd7EY/_new  2017-03-11 15:19:08.907701765 +0100
@@ -18,7 +18,7 @@
 
 %define         libname lib%{name}0
 Name:           virglrenderer
-Version:        0.5.0
+Version:        0.6.0
 Release:        0
 Summary:        Virgl Rendering library
 License:        MIT
@@ -42,11 +42,9 @@
 BuildRequires:  pkgconfig(xorg-macros) >= 1.8
 
 #Upstream patches:
-Patch0001:      
0001-48f67f60-renderer-fix-NULL-pointer-deref-in-vrend_clear.patch
-Patch0002:      0002-40b0e781-renderer-fix-a-leak-in-resource-attach.patch
-Patch0003:      0003-6eb13f7a-vrend-fix-memory-leak-in-int-blit-context.patch
-Patch0004:      
0004-114688c5-renderer-fix-heap-overflow-in-vertex-elements-state-.patch
-Patch0005:      
0005-926b9b34-vrend-fix-a-stack-overflow-in-set-framebuffer-state.patch
+Patch0001:      
0001-737c3350-renderer-fix-memory-leak-in-vertex-elements-state-cr.patch
+
+# Our patches:
 
 %description
 The virgil3d rendering library is a library used by
@@ -54,7 +52,7 @@
 
 %package -n %{libname}
 Summary:        Virgil3D renderer
-Group:          Development/Libraries/C and C++
+Group:          System/Libraries
 
 %description -n %{libname}
 The virgil3d rendering library is a library used by
@@ -87,10 +85,6 @@
 %prep
 %setup -q -n %{name}-%{version}
 %patch0001 -p1
-%patch0002 -p1
-%patch0003 -p1
-%patch0004 -p1
-%patch0005 -p1
 
 %build
 sed -i -e 's|@CODE_COVERAGE_RULES@| |g' Makefile.am

++++++ 0001-737c3350-renderer-fix-memory-leak-in-vertex-elements-state-cr.patch 
++++++
>From 737c3350850ca4dbc5633b3bdb4118176ce59920 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airl...@redhat.com>
Date: Tue, 28 Feb 2017 14:52:09 +1000
Subject: [PATCH] renderer: fix memory leak in vertex elements state create

Reported-by: Li Qiang
Free the vertex array in error path.
This was introduced by this commit:
renderer: fix heap overflow in vertex elements state create.

I rewrote the code to not require the allocation in the first
place if we have an error, seems nicer.

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 src/vrend_renderer.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Index: virglrenderer-0.6.0/src/vrend_renderer.c
===================================================================
--- virglrenderer-0.6.0.orig/src/vrend_renderer.c
+++ virglrenderer-0.6.0/src/vrend_renderer.c
@@ -1648,18 +1648,19 @@ int vrend_create_vertex_elements_state(s
                                        unsigned num_elements,
                                        const struct pipe_vertex_element 
*elements)
 {
-   struct vrend_vertex_element_array *v = 
CALLOC_STRUCT(vrend_vertex_element_array);
+   struct vrend_vertex_element_array *v;
    const struct util_format_description *desc;
    GLenum type;
    int i;
    uint32_t ret_handle;
 
-   if (!v)
-      return ENOMEM;
-
    if (num_elements > PIPE_MAX_ATTRIBS)
       return EINVAL;
 
+   v = CALLOC_STRUCT(vrend_vertex_element_array);
+   if (!v)
+      return ENOMEM;
+
    v->count = num_elements;
    for (i = 0; i < num_elements; i++) {
       memcpy(&v->elements[i].base, &elements[i], sizeof(struct 
pipe_vertex_element));
++++++ virglrenderer-0.5.0.tar.bz2 -> virglrenderer-0.6.0.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/configure.ac 
new/virglrenderer-0.6.0/configure.ac
--- old/virglrenderer-0.5.0/configure.ac        2016-04-12 09:35:36.560778348 
+0200
+++ new/virglrenderer-0.6.0/configure.ac        2017-02-24 09:36:08.876722483 
+0100
@@ -2,7 +2,7 @@
 
 AC_PREREQ([2.60])
 
-AC_INIT([virglrenderer], [0.5.0],
+AC_INIT([virglrenderer], [0.6.0],
     [virglrenderer-de...@lists.freedesktop.org])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h])
@@ -102,6 +102,13 @@
 
 PKG_CHECK_MODULES([EPOXY], [epoxy])
 
+AC_ARG_WITH([glx], AS_HELP_STRING([--with-glx], [Build with the x11/glx 
backend]))
+AS_IF([test "x$with_glx" = "xyes"], [
+  PKG_CHECK_MODULES([X11], [x11])
+  AC_CHECK_HEADER([epoxy/glx.h])
+])
+AM_CONDITIONAL([WITH_GLX], [test "x$with_glx" = "xyes"])
+
 AC_SUBST([DEFINES])
 AC_CONFIG_FILES([
                virglrenderer.pc
@@ -112,3 +119,18 @@
                tests/Makefile
 ])
 AC_OUTPUT
+
+AC_MSG_NOTICE([
+
+      virgl $VERSION
+      ==============
+
+      prefix:                   $prefix
+      c compiler:               $CC
+      win32:                    $os_win32
+
+      glx:                      $with_glx
+      debug:                    $enable_debug
+      tests:                    $build_tests
+
+])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/scripts/release.sh 
new/virglrenderer-0.6.0/scripts/release.sh
--- old/virglrenderer-0.5.0/scripts/release.sh  2016-04-12 09:36:13.980963905 
+0200
+++ new/virglrenderer-0.6.0/scripts/release.sh  2017-02-24 09:36:08.876722483 
+0100
@@ -431,8 +431,8 @@
     list_to="virglrenderer-de...@lists.freedesktop.org"
 
     host_current=$host_fdo
-    section_path=www/software/virgl
-    srv_path="/srv/$host_current/$section_path"
+    section_path=software/virgl
+    srv_path="/srv/$host_current/www/$section_path"
 
     # Use personal web space on the host for unit testing (leave commented out)
     # srv_path="~/public_html$srv_path"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/Makefile.am 
new/virglrenderer-0.6.0/src/Makefile.am
--- old/virglrenderer-0.5.0/src/Makefile.am     2016-04-12 09:35:36.560778348 
+0200
+++ new/virglrenderer-0.6.0/src/Makefile.am     2017-02-24 09:36:08.868722444 
+0100
@@ -2,6 +2,7 @@
 AM_LDFLAGS = -lm \
        $(GBM_LIBS) \
        $(EPOXY_LIBS) \
+       $(X11_LIBS) \
        $(CODE_COVERAGE_LDFLAGS)
 
 AM_CFLAGS = \
@@ -12,6 +13,7 @@
        $(LIBDRM_CFLAGS) \
        $(GBM_CFLAGS) \
        $(EPOXY_CFLAGS) \
+       $(X11_CFLAGS) \
        $(VISIBILITY_CFLAGS) \
        $(CODE_COVERAGE_CFLAGS)
 
@@ -37,6 +39,12 @@
         virgl_egl_context.c
 endif
 
+if WITH_GLX
+libvrend_la_SOURCES += \
+       virgl_glx.h \
+       virgl_glx_context.c
+endif
+
 lib_LTLIBRARIES = libvirglrenderer.la
 noinst_LTLIBRARIES = libvrend.la
 
@@ -45,7 +53,7 @@
 libvirglrenderer_la_SOURCES = virglrenderer.c
 libvirglrenderer_ladir = $(libdir)
 libvirglrenderer_la_LIBADD = libvrend.la gallium/auxiliary/libgallium.la
-libvirglrenderer_la_LDFLAGS = $(GM_LDFLAGS) $(EPOXY_LDFLAGS)
+libvirglrenderer_la_LDFLAGS = $(GM_LDFLAGS) $(EPOXY_LDFLAGS) $(X11_LDFLAGS)
 
 libvirglrendererincludedir = ${includedir}/virgl
 libvirglrendererinclude_HEADERS = virglrenderer.h
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/virglrenderer-0.5.0/src/gallium/auxiliary/tgsi/tgsi_sanity.c 
new/virglrenderer-0.6.0/src/gallium/auxiliary/tgsi/tgsi_sanity.c
--- old/virglrenderer-0.5.0/src/gallium/auxiliary/tgsi/tgsi_sanity.c    
2016-04-12 09:35:36.560778348 +0200
+++ new/virglrenderer-0.6.0/src/gallium/auxiliary/tgsi/tgsi_sanity.c    
2017-02-24 09:36:08.872722464 +0100
@@ -531,6 +531,7 @@
    const struct tgsi_token *tokens )
 {
    struct sanity_check_ctx ctx;
+   boolean retval;
 
    ctx.iter.prolog = NULL;
    ctx.iter.iterate_instruction = iter_instruction;
@@ -552,11 +553,12 @@
    ctx.implied_array_size = 0;
    ctx.print = debug_get_option_print_sanity();
 
-   if (!tgsi_iterate_shader( tokens, &ctx.iter ))
-      return FALSE;
-
+   retval = tgsi_iterate_shader( tokens, &ctx.iter );
    regs_hash_destroy(ctx.regs_decl);
    regs_hash_destroy(ctx.regs_used);
    regs_hash_destroy(ctx.regs_ind_used);
+   if (retval == FALSE)
+      return FALSE;
+
    return ctx.errors == 0;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/virglrenderer-0.5.0/src/gallium/auxiliary/tgsi/tgsi_text.c 
new/virglrenderer-0.6.0/src/gallium/auxiliary/tgsi/tgsi_text.c
--- old/virglrenderer-0.5.0/src/gallium/auxiliary/tgsi/tgsi_text.c      
2016-04-12 09:35:36.564778368 +0200
+++ new/virglrenderer-0.6.0/src/gallium/auxiliary/tgsi/tgsi_text.c      
2017-02-24 09:36:08.872722464 +0100
@@ -180,14 +180,17 @@
    return FALSE;
 }
 
-static boolean parse_identifier( const char **pcur, char *ret )
+static boolean parse_identifier( const char **pcur, char *ret, size_t len )
 {
    const char *cur = *pcur;
    int i = 0;
    if (is_alpha_underscore( cur )) {
       ret[i++] = *cur++;
-      while (is_alpha_underscore( cur ) || is_digit( cur ))
+      while (is_alpha_underscore( cur ) || is_digit( cur )) {
+         if (i == len - 1)
+            return FALSE;
          ret[i++] = *cur++;
+      }
       ret[i++] = '\0';
       *pcur = cur;
       return TRUE;
@@ -1094,7 +1097,7 @@
 
    cur = ctx->cur;
    eat_opt_white( &cur );
-   for (i = 0; inst.Instruction.Texture && *cur == ','; i++) {
+   for (i = 0; inst.Instruction.Texture && *cur == ',' && i < 
TGSI_FULL_MAX_TEX_OFFSETS; i++) {
          cur++;
          eat_opt_white( &cur );
          ctx->cur = cur;
@@ -1590,7 +1593,7 @@
       report_error( ctx, "Syntax error" );
       return FALSE;
    }
-   if (!parse_identifier( &ctx->cur, id )) {
+   if (!parse_identifier( &ctx->cur, id, sizeof(id) )) {
       report_error( ctx, "Syntax error" );
       return FALSE;
    }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/virgl_glx.h 
new/virglrenderer-0.6.0/src/virgl_glx.h
--- old/virglrenderer-0.5.0/src/virgl_glx.h     1970-01-01 01:00:00.000000000 
+0100
+++ new/virglrenderer-0.6.0/src/virgl_glx.h     2017-02-24 09:36:08.876722483 
+0100
@@ -0,0 +1,38 @@
+/**************************************************************************
+ *
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * 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 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 VIRGL_GLX_H
+#define VIRGL_GLX_H
+
+#include "vrend_renderer.h"
+struct virgl_glx;
+
+struct virgl_glx *virgl_glx_init(void);
+void virgl_glx_destroy(struct virgl_glx *ve);
+
+virgl_renderer_gl_context virgl_glx_create_context(struct virgl_glx *ve, 
struct virgl_gl_ctx_param *vparams);
+void virgl_glx_destroy_context(struct virgl_glx *ve, virgl_renderer_gl_context 
virglctx);
+int virgl_glx_make_context_current(struct virgl_glx *ve, 
virgl_renderer_gl_context virglctx);
+virgl_renderer_gl_context virgl_glx_get_current_context(struct virgl_glx *ve);
+
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/virgl_glx_context.c 
new/virglrenderer-0.6.0/src/virgl_glx_context.c
--- old/virglrenderer-0.5.0/src/virgl_glx_context.c     1970-01-01 
01:00:00.000000000 +0100
+++ new/virglrenderer-0.6.0/src/virgl_glx_context.c     2017-02-24 
09:36:08.876722483 +0100
@@ -0,0 +1,109 @@
+/**************************************************************************
+ *
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * 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 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 <epoxy/glx.h>
+#include "virglrenderer.h"
+#include "virgl_glx.h"
+
+struct virgl_glx {
+   Display *display;
+   GLXFBConfig* fbConfigs;
+   GLXPbuffer pbuffer;
+};
+
+struct virgl_glx *virgl_glx_init(void)
+{
+   struct virgl_glx *d;
+
+   d = malloc(sizeof(struct virgl_glx));
+   if (!d)
+      return NULL;
+
+   d->display = XOpenDisplay(NULL);
+
+   if (!d->display) {
+      free(d);
+      return NULL;
+   }
+
+   int visualAttribs[] = { None };
+   int numberOfFramebufferConfigurations = 0;
+
+   d->fbConfigs = glXChooseFBConfig(d->display, DefaultScreen(d->display),
+                                    visualAttribs, 
&numberOfFramebufferConfigurations);
+
+   int pbufferAttribs[] = {
+      GLX_PBUFFER_WIDTH,  32,
+      GLX_PBUFFER_HEIGHT, 32,
+      None
+   };
+   d->pbuffer = glXCreatePbuffer(d->display, d->fbConfigs[0], pbufferAttribs);
+
+   return d;
+}
+
+void virgl_glx_destroy(struct virgl_glx *d)
+{
+   XFree(d->fbConfigs);
+   glXDestroyPbuffer(d->display,d->pbuffer);
+   XCloseDisplay(d->display);
+   free(d);
+}
+
+virgl_renderer_gl_context virgl_glx_create_context(struct virgl_glx *d, struct 
virgl_gl_ctx_param *vparams)
+{
+   int context_attribs[] = {
+      GLX_CONTEXT_MAJOR_VERSION_ARB, vparams->major_ver,
+      GLX_CONTEXT_MINOR_VERSION_ARB, vparams->minor_ver,
+      None
+   };
+
+   GLXContext ctx =
+      glXCreateContextAttribsARB(d->display, d->fbConfigs[0],
+                                 vparams->shared ? glXGetCurrentContext() : 
NULL,
+                                 True, context_attribs);
+   return (virgl_renderer_gl_context)ctx;
+}
+
+void virgl_glx_destroy_context(struct virgl_glx *d, virgl_renderer_gl_context 
virglctx)
+{
+   GLXContext ctx = (GLXContext)virglctx;
+
+   glXDestroyContext(d->display,ctx);
+}
+
+int virgl_glx_make_context_current(struct virgl_glx *d, 
virgl_renderer_gl_context virglctx)
+{
+   return glXMakeContextCurrent(d->display, d->pbuffer, d->pbuffer, virglctx);
+}
+
+virgl_renderer_gl_context virgl_glx_get_current_context(struct virgl_glx *d)
+{
+   return glXGetCurrentContext();
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/virglrenderer.c 
new/virglrenderer-0.6.0/src/virglrenderer.c
--- old/virglrenderer-0.5.0/src/virglrenderer.c 2016-04-12 09:35:36.564778368 
+0200
+++ new/virglrenderer-0.6.0/src/virglrenderer.c 2017-02-24 09:36:08.876722483 
+0100
@@ -41,9 +41,21 @@
 #ifdef HAVE_EPOXY_EGL_H
 #include "virgl_egl.h"
 static struct virgl_egl *egl_info;
-static int use_egl_context;
 #endif
 
+#ifdef HAVE_EPOXY_GLX_H
+#include "virgl_glx.h"
+static struct virgl_glx *glx_info;
+#endif
+
+enum {
+   CONTEXT_NONE,
+   CONTEXT_EGL,
+   CONTEXT_GLX
+};
+
+static int use_context = CONTEXT_NONE;
+
 /* new API - just wrap internal API for now */
 
 int virgl_renderer_resource_create(struct virgl_renderer_resource_create_args 
*args, struct iovec *iov, uint32_t num_iovs)
@@ -163,7 +175,7 @@
    int ret;
    ret = vrend_renderer_resource_get_info(res_handle, (struct 
vrend_renderer_resource_info *)info);
 #ifdef HAVE_EPOXY_EGL_H
-   if (ret == 0 && use_egl_context)
+   if (ret == 0 && use_context == CONTEXT_EGL)
       return virgl_egl_get_fourcc_for_texture(egl_info, info->tex_id, 
info->virgl_format, &info->drm_fourcc);
 #endif
 
@@ -199,9 +211,13 @@
    struct virgl_renderer_gl_ctx_param vparam;
 
 #ifdef HAVE_EPOXY_EGL_H
-   if (use_egl_context)
+   if (use_context == CONTEXT_EGL)
       return virgl_egl_create_context(egl_info, param);
 #endif
+#ifdef HAVE_EPOXY_GLX_H
+   if (use_context == CONTEXT_GLX)
+      return virgl_glx_create_context(glx_info, param);
+#endif
    vparam.version = 1;
    vparam.shared = param->shared;
    vparam.major_ver = param->major_ver;
@@ -212,18 +228,26 @@
 static void destroy_gl_context(virgl_renderer_gl_context ctx)
 {
 #ifdef HAVE_EPOXY_EGL_H
-   if (use_egl_context)
+   if (use_context == CONTEXT_EGL)
       return virgl_egl_destroy_context(egl_info, ctx);
 #endif
+#ifdef HAVE_EPOXY_GLX_H
+   if (use_context == CONTEXT_GLX)
+      return virgl_glx_destroy_context(glx_info, ctx);
+#endif
    return rcbs->destroy_gl_context(dev_cookie, ctx);
 }
 
 static int make_current(int scanout_idx, virgl_renderer_gl_context ctx)
 {
 #ifdef HAVE_EPOXY_EGL_H
-   if (use_egl_context)
+   if (use_context == CONTEXT_EGL)
       return virgl_egl_make_context_current(egl_info, ctx);
 #endif
+#ifdef HAVE_EPOXY_GLX_H
+   if (use_context == CONTEXT_GLX)
+      return virgl_glx_make_context_current(glx_info, ctx);
+#endif
    return rcbs->make_current(dev_cookie, scanout_idx, ctx);
 }
 
@@ -249,10 +273,17 @@
 {
    vrend_renderer_fini();
 #ifdef HAVE_EPOXY_EGL_H
-   if (use_egl_context) {
+   if (use_context == CONTEXT_EGL) {
       virgl_egl_destroy(egl_info);
       egl_info = NULL;
-      use_egl_context = 0;
+      use_context = CONTEXT_NONE;
+   }
+#endif
+#ifdef HAVE_EPOXY_GLX_H
+   if (use_context == CONTEXT_GLX) {
+      virgl_glx_destroy(glx_info);
+      glx_info = NULL;
+      use_context = CONTEXT_NONE;
    }
 #endif
 }
@@ -274,11 +305,21 @@
       egl_info = virgl_egl_init();
       if (!egl_info)
          return -1;
-      use_egl_context = 1;
+      use_context = CONTEXT_EGL;
 #else
       fprintf(stderr, "EGL is not supported on this platform\n");
       return -1;
 #endif
+   } else if (flags & VIRGL_RENDERER_USE_GLX) {
+#ifdef HAVE_EPOXY_GLX_H
+      glx_info = virgl_glx_init();
+      if (!glx_info)
+         return -1;
+      use_context = CONTEXT_GLX;
+#else
+      fprintf(stderr, "GLX is not supported on this platform\n");
+      return -1;
+#endif
    }
 
    if (flags & VIRGL_RENDERER_THREAD_SYNC)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/virglrenderer.h 
new/virglrenderer-0.6.0/src/virglrenderer.h
--- old/virglrenderer-0.5.0/src/virglrenderer.h 2016-04-12 09:35:36.564778368 
+0200
+++ new/virglrenderer-0.6.0/src/virglrenderer.h 2017-02-24 09:36:08.876722483 
+0100
@@ -61,6 +61,7 @@
  * need to use virgl_renderer_get_poll_fd to know if this feature is in effect.
  */
 #define VIRGL_RENDERER_THREAD_SYNC 2
+#define VIRGL_RENDERER_USE_GLX (1 << 2)
 
 VIRGL_EXPORT int virgl_renderer_init(void *cookie, int flags, struct 
virgl_renderer_callbacks *cb);
 VIRGL_EXPORT void virgl_renderer_poll(void); /* force fences */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/vrend_blitter.c 
new/virglrenderer-0.6.0/src/vrend_blitter.c
--- old/virglrenderer-0.5.0/src/vrend_blitter.c 2016-04-12 09:35:36.564778368 
+0200
+++ new/virglrenderer-0.6.0/src/vrend_blitter.c 2017-02-24 09:36:08.876722483 
+0100
@@ -58,6 +58,7 @@
    GLuint vs;
    GLuint vs_pos_only;
    GLuint fs_texfetch_col[PIPE_MAX_TEXTURE_TYPES];
+   GLuint fs_texfetch_col_emu_alpha[PIPE_MAX_TEXTURE_TYPES];
    GLuint fs_texfetch_depth[PIPE_MAX_TEXTURE_TYPES];
    GLuint fs_texfetch_depth_msaa[PIPE_MAX_TEXTURE_TYPES];
    GLuint fb_id;
@@ -154,6 +155,59 @@
    return fs_id;
 }
 
+static GLuint blit_build_frag_tex_col_emu_alpha(struct vrend_blitter_ctx 
*blit_ctx, int tgsi_tex_target)
+{
+   GLuint fs_id;
+   char shader_buf[4096];
+   int is_shad;
+   const char *twm;
+   const char *ext_str = "";
+   switch (tgsi_tex_target) {
+   case TGSI_TEXTURE_1D:
+   case TGSI_TEXTURE_BUFFER:
+      twm = ".x";
+      break;
+   case TGSI_TEXTURE_1D_ARRAY:
+   case TGSI_TEXTURE_2D:
+   case TGSI_TEXTURE_RECT:
+   case TGSI_TEXTURE_2D_MSAA:
+   default:
+      twm = ".xy";
+      break;
+   case TGSI_TEXTURE_SHADOW1D:
+   case TGSI_TEXTURE_SHADOW2D:
+   case TGSI_TEXTURE_SHADOW1D_ARRAY:
+   case TGSI_TEXTURE_SHADOWRECT:
+   case TGSI_TEXTURE_3D:
+   case TGSI_TEXTURE_CUBE:
+   case TGSI_TEXTURE_2D_ARRAY:
+   case TGSI_TEXTURE_2D_ARRAY_MSAA:
+      twm = ".xyz";
+      break;
+   case TGSI_TEXTURE_SHADOWCUBE:
+   case TGSI_TEXTURE_SHADOW2D_ARRAY:
+   case TGSI_TEXTURE_SHADOWCUBE_ARRAY:
+   case TGSI_TEXTURE_CUBE_ARRAY:
+      twm = "";
+      break;
+   }
+
+   if (tgsi_tex_target == TGSI_TEXTURE_CUBE_ARRAY ||
+       tgsi_tex_target == TGSI_TEXTURE_SHADOWCUBE_ARRAY)
+      ext_str = "#extension GL_ARB_texture_cube_map_array : require\n";
+
+   snprintf(shader_buf, 4096, FS_TEXFETCH_COL_ALPHA_DEST, ext_str, 
vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), twm, "");
+
+   fs_id = glCreateShader(GL_FRAGMENT_SHADER);
+
+   if (!build_and_check(fs_id, shader_buf)) {
+      glDeleteShader(fs_id);
+      return 0;
+   }
+
+   return fs_id;
+}
+
 static GLuint blit_build_frag_tex_writedepth(struct vrend_blitter_ctx 
*blit_ctx, int tgsi_tex_target)
 {
    GLuint fs_id;
@@ -280,6 +334,24 @@
    }
 }
 
+static GLuint blit_get_frag_tex_col_emu_alpha(struct vrend_blitter_ctx 
*blit_ctx, int pipe_tex_target, unsigned nr_samples)
+{
+   assert(pipe_tex_target < PIPE_MAX_TEXTURE_TYPES);
+
+   if (nr_samples > 1) {
+      return 0;
+   } else {
+      GLuint *shader = &blit_ctx->fs_texfetch_col_emu_alpha[pipe_tex_target];
+
+      if (!*shader) {
+         unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex_target, 0);
+
+         *shader = blit_build_frag_tex_col_emu_alpha(blit_ctx, tgsi_tex);
+      }
+      return *shader;
+   }
+}
+
 static void vrend_renderer_init_blit_ctx(struct vrend_blitter_ctx *blit_ctx)
 {
    struct virgl_gl_ctx_param ctx_params;
@@ -289,6 +361,7 @@
       return;
    }
 
+   blit_ctx->initialised = true;
    ctx_params.shared = true;
    ctx_params.major_ver = VREND_GL_VER_MAJOR;
    ctx_params.minor_ver = VREND_GL_VER_MINOR;
@@ -501,6 +574,8 @@
 
    if (blit_depth || blit_stencil)
       fs_id = blit_get_frag_tex_writedepth(blit_ctx, src_res->base.target, 
src_res->base.nr_samples);
+   else if (vrend_format_is_emulated_alpha(info->dst.format))
+      fs_id = blit_get_frag_tex_col_emu_alpha(blit_ctx, src_res->base.target, 
src_res->base.nr_samples);
    else
       fs_id = blit_get_frag_tex_col(blit_ctx, src_res->base.target, 
src_res->base.nr_samples);
    glAttachShader(prog_id, fs_id);
@@ -526,6 +601,9 @@
 
    glBindTexture(src_res->target, src_res->id);
 
+   if (vrend_format_is_emulated_alpha(info->src.format))
+      glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_R, GL_ALPHA);
+
    glTexParameteri(src_res->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(src_res->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(src_res->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/vrend_blitter.h 
new/virglrenderer-0.6.0/src/vrend_blitter.h
--- old/virglrenderer-0.5.0/src/vrend_blitter.h 2016-04-12 09:35:36.564778368 
+0200
+++ new/virglrenderer-0.6.0/src/vrend_blitter.h 2017-02-24 09:36:08.876722483 
+0100
@@ -45,6 +45,16 @@
    "   gl_FragColor = texture(samp, tc%s)%s;\n" \
    "}\n"
 
+#define FS_TEXFETCH_COL_ALPHA_DEST              \
+   "#version 130\n"                             \
+   "%s"                                         \
+   "uniform sampler%s samp;\n"                  \
+   "in vec4 tc;\n"                              \
+   "void main() {\n"                            \
+   "   vec4 temp = texture(samp, tc%s)%s;\n"     \
+   "   gl_FragColor = temp.aaaa;\n" \
+   "}\n"
+
 #define FS_TEXFETCH_DS                                  \
    "#version 130\n"                                     \
    "uniform sampler%s samp;\n"                          \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/vrend_decode.c 
new/virglrenderer-0.6.0/src/vrend_decode.c
--- old/virglrenderer-0.5.0/src/vrend_decode.c  2016-04-12 09:35:36.564778368 
+0200
+++ new/virglrenderer-0.6.0/src/vrend_decode.c  2017-02-24 09:36:08.876722483 
+0100
@@ -136,6 +136,10 @@
 
    if (length != (2 + nr_cbufs))
       return EINVAL;
+
+   if (nr_cbufs > 8)
+      return EINVAL;
+
    for (i = 0; i < nr_cbufs; i++)
       surf_handle[i] = get_buf_entry(ctx, 
VIRGL_SET_FRAMEBUFFER_STATE_CBUF_HANDLE(i));
    vrend_set_framebuffer_state(ctx->grctx, nr_cbufs, surf_handle, 
zsurf_handle);
@@ -608,6 +612,10 @@
          ve[i].src_offset = get_buf_entry(ctx, 
VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_OFFSET(i));
          ve[i].instance_divisor = get_buf_entry(ctx, 
VIRGL_OBJ_VERTEX_ELEMENTS_V0_INSTANCE_DIVISOR(i));
          ve[i].vertex_buffer_index = get_buf_entry(ctx, 
VIRGL_OBJ_VERTEX_ELEMENTS_V0_VERTEX_BUFFER_INDEX(i));
+
+         if (ve[i].vertex_buffer_index >= PIPE_MAX_ATTRIBS)
+            return EINVAL;
+
          ve[i].src_format = get_buf_entry(ctx, 
VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_FORMAT(i));
       }
    }
@@ -1045,6 +1053,10 @@
    if (handle >= VREND_MAX_CTX)
       return;
 
+   dctx = dec_ctx[handle];
+   if (dctx)
+      return;
+
    dctx = malloc(sizeof(struct vrend_decode_ctx));
    if (!dctx)
       return;
@@ -1081,6 +1093,11 @@
    if (handle >= VREND_MAX_CTX)
       return;
 
+   /* never destroy context 0 here, it will be destroyed in 
vrend_decode_reset()*/
+   if (handle == 0) {
+      return;
+   }
+
    ctx = dec_ctx[handle];
    if (!ctx)
       return;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/vrend_renderer.c 
new/virglrenderer-0.6.0/src/vrend_renderer.c
--- old/virglrenderer-0.5.0/src/vrend_renderer.c        2016-04-12 
09:35:36.564778368 +0200
+++ new/virglrenderer-0.6.0/src/vrend_renderer.c        2017-02-24 
09:36:08.876722483 +0100
@@ -325,7 +325,7 @@
    uint32_t fb_id;
    int nr_cbufs, old_nr_cbufs;
    struct vrend_surface *zsurf;
-   struct vrend_surface *surf[8];
+   struct vrend_surface *surf[PIPE_MAX_COLOR_BUFS];
 
    struct vrend_viewport vps[PIPE_MAX_VIEWPORTS];
    float depth_transform, depth_scale;
@@ -439,7 +439,7 @@
    return vrend_format_is_ds(format);
 }
 
-static inline bool vrend_format_is_emulated_alpha(enum virgl_formats format)
+bool vrend_format_is_emulated_alpha(enum virgl_formats format)
 {
    if (!vrend_state.use_core_profile)
       return false;
@@ -892,6 +892,7 @@
          fprintf(stderr,"geom shader: %d GLSL\n%s\n", gs->id, gs->glsl_prog);
       fprintf(stderr,"frag shader: %d GLSL\n%s\n", fs->id, fs->glsl_prog);
       glDeleteProgram(prog_id);
+      free(sprog);
       return NULL;
    }
 
@@ -1481,7 +1482,7 @@
 }
 
 void vrend_set_framebuffer_state(struct vrend_context *ctx,
-                                 uint32_t nr_cbufs, uint32_t surf_handle[8],
+                                 uint32_t nr_cbufs, uint32_t 
surf_handle[PIPE_MAX_COLOR_BUFS],
                                  uint32_t zsurf_handle)
 {
    struct vrend_surface *surf, *zsurf;
@@ -1656,6 +1657,9 @@
    if (!v)
       return ENOMEM;
 
+   if (num_elements > PIPE_MAX_ATTRIBS)
+      return EINVAL;
+
    v->count = num_elements;
    for (i = 0; i < num_elements; i++) {
       memcpy(&v->elements[i].base, &elements[i], sizeof(struct 
pipe_vertex_element));
@@ -2211,6 +2215,15 @@
          ret = EINVAL;
          goto error;
       }
+
+      /*make sure no overflow */
+      if (pkt_length * 4 < pkt_length ||
+          pkt_length * 4 + sel->buf_offset < pkt_length * 4 ||
+          pkt_length * 4 + sel->buf_offset < sel->buf_offset) {
+            ret = EINVAL;
+            goto error;
+          }
+
       if ((pkt_length * 4 + sel->buf_offset) > sel->buf_len) {
          fprintf(stderr, "Got too large shader continuation %d vs %d\n",
                  pkt_length * 4 + sel->buf_offset, sel->buf_len);
@@ -2354,10 +2367,10 @@
          mask = buffers >> 2;
          while (mask) {
             i = u_bit_scan(&mask);
-            if (util_format_is_pure_uint(ctx->sub->surf[i]->format))
+            if (i < PIPE_MAX_COLOR_BUFS && ctx->sub->surf[i] && 
util_format_is_pure_uint(ctx->sub->surf[i] && ctx->sub->surf[i]->format))
                glClearBufferuiv(GL_COLOR,
                                 i, (GLuint *)color);
-            else if (util_format_is_pure_sint(ctx->sub->surf[i]->format))
+            else if (i < PIPE_MAX_COLOR_BUFS && ctx->sub->surf[i] && 
util_format_is_pure_sint(ctx->sub->surf[i] && ctx->sub->surf[i]->format))
                glClearBufferiv(GL_COLOR,
                                 i, (GLint *)color);
             else
@@ -4031,6 +4044,9 @@
    if (!res)
       return EINVAL;
 
+   if (res->iov)
+      return 0;
+
    /* work out size and max resource size */
    res->iov = iov;
    res->num_iovs = num_iovs;
@@ -5498,6 +5514,10 @@
    if (info->src.box.depth != info->dst.box.depth)
       use_gl = true;
 
+   if (vrend_format_is_emulated_alpha(info->dst.format) ||
+       vrend_format_is_emulated_alpha(info->src.format))
+      use_gl = true;
+
    if (use_gl) {
       vrend_renderer_blit_gl(ctx, src_res, dst_res, info);
       vrend_clicbs->make_current(0, ctx->sub->gl_context);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/vrend_renderer.h 
new/virglrenderer-0.6.0/src/vrend_renderer.h
--- old/virglrenderer-0.5.0/src/vrend_renderer.h        2016-04-12 
09:35:36.564778368 +0200
+++ new/virglrenderer-0.6.0/src/vrend_renderer.h        2017-02-24 
09:36:08.876722483 +0100
@@ -127,7 +127,7 @@
                     uint32_t cso);
 
 void vrend_set_framebuffer_state(struct vrend_context *ctx,
-                                 uint32_t nr_cbufs, uint32_t surf_handle[8],
+                                 uint32_t nr_cbufs, uint32_t 
surf_handle[PIPE_MAX_COLOR_BUFS],
                                  uint32_t zsurf_handle);
 
 struct vrend_context *vrend_create_context(int id, uint32_t nlen, const char 
*debug_name);
@@ -365,7 +365,7 @@
                            int idx,
                            uint32_t level, uint32_t layer);
 bool vrend_is_ds_format(enum virgl_formats format);
-
+bool vrend_format_is_emulated_alpha(enum virgl_formats format);
 /* blitter interface */
 void vrend_renderer_blit_gl(struct vrend_context *ctx,
                             struct vrend_resource *src_res,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/src/vrend_shader.c 
new/virglrenderer-0.6.0/src/vrend_shader.c
--- old/virglrenderer-0.5.0/src/vrend_shader.c  2016-04-12 09:35:36.564778368 
+0200
+++ new/virglrenderer-0.6.0/src/vrend_shader.c  2017-02-24 09:36:08.876722483 
+0100
@@ -1632,7 +1632,7 @@
       } else if (src->Register.File == TGSI_FILE_SYSTEM_VALUE) {
          for (j = 0; j < ctx->num_system_values; j++)
             if (ctx->system_values[j].first == src->Register.Index) {
-               if (ctx->system_values[j].name == TGSI_SEMANTIC_VERTEXID)
+               if (ctx->system_values[j].name == TGSI_SEMANTIC_VERTEXID || 
ctx->system_values[j].name == TGSI_SEMANTIC_INSTANCEID)
                   snprintf(srcs[i], 255, "%s(vec4(intBitsToFloat(%s)))", 
stypeprefix, ctx->system_values[j].glsl_name);
                else
                   snprintf(srcs[i], 255, "%s%s", prefix, 
ctx->system_values[j].glsl_name);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/virglrenderer-0.5.0/vtest/vtest_renderer.c 
new/virglrenderer-0.6.0/vtest/vtest_renderer.c
--- old/virglrenderer-0.5.0/vtest/vtest_renderer.c      2016-04-12 
09:35:36.568778388 +0200
+++ new/virglrenderer-0.6.0/vtest/vtest_renderer.c      2017-02-24 
09:36:08.876722483 +0100
@@ -113,13 +113,16 @@
 {
     char *vtestname;
     int ret;
+    int ctx = VIRGL_RENDERER_USE_EGL;
 
     renderer.in_fd = in_fd;
     renderer.out_fd = out_fd;
 
+    if (getenv("VTEST_USE_GLX"))
+       ctx = VIRGL_RENDERER_USE_GLX;
+
     ret = virgl_renderer_init(&renderer,
-                              VIRGL_RENDERER_USE_EGL |
-                              VIRGL_RENDERER_THREAD_SYNC, &vtest_cbs);
+                              ctx | VIRGL_RENDERER_THREAD_SYNC, &vtest_cbs);
     if (ret) {
       fprintf(stderr, "failed to initialise renderer.\n");
       return -1;


Reply via email to