svga: set rendered-to flag after updating the texture using PredCopyRegion
[mesa.git] / src / gallium / drivers / svga / svga_surface.c
index 81b0f48e53e52fee0e933da9431d8c8af8a48e8e..935384150cc8f38d01d130b6718aacd522b1c607 100644 (file)
@@ -134,7 +134,9 @@ svga_texture_view_surface(struct svga_context *svga,
    key->cachable = 1;
    key->arraySize = 1;
    key->numFaces = 1;
-   key->sampleCount = tex->b.b.nr_samples;
+
+   /* single sample surface can be treated as non-multisamples surface */
+   key->sampleCount = tex->b.b.nr_samples > 1 ? tex->b.b.nr_samples : 0;
 
    if (key->sampleCount > 1) {
       key->flags |= SVGA3D_SURFACE_MASKABLE_ANTIALIAS;
@@ -403,9 +405,9 @@ svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s)
 {
    enum pipe_error ret = PIPE_OK;
    enum pipe_shader_type shader;
-   struct pipe_surface *surf = NULL;
 
    assert(svga_have_vgpu10(svga));
+   assert(s);
 
    SVGA_STATS_TIME_PUSH(svga_sws(svga),
                         SVGA_STATS_TIME_VALIDATESURFACEVIEW);
@@ -424,14 +426,12 @@ svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s)
                   "same resource used in shaderResource and renderTarget 0x%x\n",
                   s->handle);
          s = create_backed_surface_view(svga, s);
-         if (!s)
-            goto done;
-
+         /* s may be null here if the function failed */
          break;
       }
    }
 
-   if (s->view_id == SVGA3D_INVALID_ID) {
+   if (s && s->view_id == SVGA3D_INVALID_ID) {
       SVGA3dResourceType resType;
       SVGA3dRenderTargetViewDesc desc;
 
@@ -476,15 +476,13 @@ svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s)
       if (ret != PIPE_OK) {
          util_bitmask_clear(svga->surface_view_id_bm, s->view_id);
          s->view_id = SVGA3D_INVALID_ID;
-         goto done;
+         s = NULL;
       }
    }
-   surf = &s->base;
    
-done:
    SVGA_STATS_TIME_POP(svga_sws(svga));
 
-   return surf;
+   return s ? &s->base : NULL;
 }