This patch fix segfault if an application clears a render target before setting any vertex or fragment shaders, which is a legal situation.

Vic
>From 1de6aa23d3e472db7deb819e52b1f75ac09fca55 Mon Sep 17 00:00:00 2001
From: Vic Lee <ll...@163.com>
Date: Sat, 3 Mar 2012 05:57:16 -0500
Subject: [PATCH] svga: Check vs and fs pointer when updating states.

Application may call clear command before setting any vertex or fragment. The
svga driver will try to apply all pipeline states even when a clear command is
called, which does not require any shader or rasterizer states. Add those
pointer checks to avoid segfault in such situation.

Signed-off-by: Vic Lee <ll...@163.com>
---
 src/gallium/drivers/svga/svga_state_need_swtnl.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c
index 8c39a4b..281181d 100644
--- a/src/gallium/drivers/svga/svga_state_need_swtnl.c
+++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c
@@ -136,14 +136,14 @@ update_need_pipeline( struct svga_context *svga,
 
    /* EDGEFLAGS
     */
-    if (vs->base.info.writes_edgeflag) {
+   if (vs && vs->base.info.writes_edgeflag) {
       SVGA_DBG(DEBUG_SWTNL, "%s: edgeflags\n", __FUNCTION__);
       need_pipeline = TRUE;
    }
 
    /* SVGA_NEW_FS, SVGA_NEW_RAST, SVGA_NEW_REDUCED_PRIMITIVE
     */
-   if (svga->curr.reduced_prim == PIPE_PRIM_POINTS) {
+   if (svga->curr.fs && svga->curr.reduced_prim == PIPE_PRIM_POINTS) {
       unsigned sprite_coord_gen = svga->curr.rast->templ.sprite_coord_enable;
       unsigned generic_inputs = svga->curr.fs->generic_inputs;
 
-- 
1.7.9.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to