[Mesa-dev] [PATCH 2/2] svga: fix crash regression since e027935a795

Brian Paul brianp at vmware.com
Thu Mar 2 02:45:54 UTC 2017


During the first update of the hw_clear_state atoms, we may not yet
have a current rasterizer state object.  So, svga->curr.rast may be
NULL and we crash.

Add a few null pointer checks to work around this.  Note that these
are only needed in the state update functions which are called for
'clear' validation.
---
 src/gallium/drivers/svga/svga_state_framebuffer.c | 4 ++--
 src/gallium/drivers/svga/svga_state_need_swtnl.c  | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c
index 8584c5d..b2b037d 100644
--- a/src/gallium/drivers/svga/svga_state_framebuffer.c
+++ b/src/gallium/drivers/svga/svga_state_framebuffer.c
@@ -393,7 +393,7 @@ emit_viewport( struct svga_context *svga,
    /* Enable prescale to adjust vertex positions to match
       VGPU10 convention only if rasterization is enabled.
     */
-   if (svga->curr.rast->templ.rasterizer_discard) {
+   if (svga->curr.rast && svga->curr.rast->templ.rasterizer_discard) {
       degenerate = TRUE;
       goto out;
    } else {
@@ -497,7 +497,7 @@ emit_viewport( struct svga_context *svga,
     * screen-space coordinates slightly relative to D3D which is
     * what hardware implements natively.
     */
-   if (svga->curr.rast->templ.half_pixel_center) {
+   if (svga->curr.rast && svga->curr.rast->templ.half_pixel_center) {
       float adjust_x = 0.0;
       float adjust_y = 0.0;
 
diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c
index b07c62d..f9cea14 100644
--- a/src/gallium/drivers/svga/svga_state_need_swtnl.c
+++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c
@@ -66,7 +66,8 @@ update_need_pipeline(struct svga_context *svga, unsigned dirty)
 
    /* SVGA_NEW_RAST, SVGA_NEW_REDUCED_PRIMITIVE
     */
-   if (svga->curr.rast->need_pipeline & (1 << svga->curr.reduced_prim)) {
+   if (svga->curr.rast &&
+       (svga->curr.rast->need_pipeline & (1 << svga->curr.reduced_prim))) {
       SVGA_DBG(DEBUG_SWTNL, "%s: rast need_pipeline (0x%x) & prim (0x%x)\n",
                  __FUNCTION__,
                  svga->curr.rast->need_pipeline,
@@ -103,7 +104,7 @@ update_need_pipeline(struct svga_context *svga, unsigned dirty)
 
    /* SVGA_NEW_FS, SVGA_NEW_RAST, SVGA_NEW_REDUCED_PRIMITIVE
     */
-   if (svga->curr.reduced_prim == PIPE_PRIM_POINTS) {
+   if (svga->curr.rast && svga->curr.reduced_prim == PIPE_PRIM_POINTS) {
       unsigned sprite_coord_gen = svga->curr.rast->templ.sprite_coord_enable;
       unsigned generic_inputs =
          svga->curr.fs ? svga->curr.fs->generic_inputs : 0;
-- 
1.9.1



More information about the mesa-dev mailing list