gallium: add PIPE_CAP_MAX_VARYINGS
[mesa.git] / src / gallium / drivers / svga / svga_pipe_depthstencil.c
index d84ed1df48e78fe1d25b12d1992c0639b31f0037..9f06a4b2692fe8698884bfcc2b93fce727aff045 100644 (file)
@@ -86,9 +86,9 @@ define_depth_stencil_state_object(struct svga_context *svga,
    ds->id = util_bitmask_add(svga->ds_object_id_bm);
 
    /* spot check that these comparision tokens are the same */
-   assert(SVGA3D_COMPARISON_NEVER == SVGA3D_CMP_NEVER);
-   assert(SVGA3D_COMPARISON_LESS == SVGA3D_CMP_LESS);
-   assert(SVGA3D_COMPARISON_NOT_EQUAL == SVGA3D_CMP_NOTEQUAL);
+   STATIC_ASSERT(SVGA3D_COMPARISON_NEVER == SVGA3D_CMP_NEVER);
+   STATIC_ASSERT(SVGA3D_COMPARISON_LESS == SVGA3D_CMP_LESS);
+   STATIC_ASSERT(SVGA3D_COMPARISON_NOT_EQUAL == SVGA3D_CMP_NOTEQUAL);
 
    /* Loop in case command buffer is full and we need to flush and retry */
    for (try = 0; try < 2; try++) {
@@ -132,7 +132,10 @@ svga_create_depth_stencil_state(struct pipe_context *pipe,
                                const struct pipe_depth_stencil_alpha_state *templ)
 {
    struct svga_context *svga = svga_context(pipe);
-   struct svga_depth_stencil_state *ds = CALLOC_STRUCT( svga_depth_stencil_state );
+   struct svga_depth_stencil_state *ds = CALLOC_STRUCT(svga_depth_stencil_state);
+
+   if (!ds)
+      return NULL;
 
    /* Don't try to figure out CW/CCW correspondence with
     * stencil[0]/[1] at this point.  Presumably this can change as
@@ -144,7 +147,7 @@ svga_create_depth_stencil_state(struct pipe_context *pipe,
       ds->stencil[0].fail  = svga_translate_stencil_op(templ->stencil[0].fail_op);
       ds->stencil[0].zfail = svga_translate_stencil_op(templ->stencil[0].zfail_op);
       ds->stencil[0].pass  = svga_translate_stencil_op(templ->stencil[0].zpass_op);
-      
+
       /* SVGA3D has one ref/mask/writemask triple shared between front &
        * back face stencil.  We really need two:
        */
@@ -158,7 +161,6 @@ svga_create_depth_stencil_state(struct pipe_context *pipe,
       ds->stencil[0].pass = SVGA3D_STENCILOP_KEEP;
    }
 
-
    ds->stencil[1].enabled = templ->stencil[1].enabled;
    if (templ->stencil[1].enabled) {
       assert(templ->stencil[0].enabled);
@@ -170,6 +172,21 @@ svga_create_depth_stencil_state(struct pipe_context *pipe,
 
       ds->stencil_mask      = templ->stencil[1].valuemask & 0xff;
       ds->stencil_writemask = templ->stencil[1].writemask & 0xff;
+
+      if (templ->stencil[1].valuemask != templ->stencil[0].valuemask) {
+         pipe_debug_message(&svga->debug.callback, CONFORMANCE,
+                            "two-sided stencil mask not supported "
+                            "(front=0x%x, back=0x%x)",
+                            templ->stencil[0].valuemask,
+                            templ->stencil[1].valuemask);
+      }
+      if (templ->stencil[1].writemask != templ->stencil[0].writemask) {
+         pipe_debug_message(&svga->debug.callback, CONFORMANCE,
+                            "two-sided stencil writemask not supported "
+                            "(front=0x%x, back=0x%x)",
+                            templ->stencil[0].writemask,
+                            templ->stencil[1].writemask);
+      }
    }
    else {
       /* back face state is same as front-face state */
@@ -202,13 +219,17 @@ svga_create_depth_stencil_state(struct pipe_context *pipe,
       define_depth_stencil_state_object(svga, ds);
    }
 
-   svga->hud.num_state_objects++;
+   svga->hud.num_depthstencil_objects++;
+
+   SVGA_STATS_COUNT_INC(svga_screen(svga->pipe.screen)->sws,
+                        SVGA_STATS_COUNT_DEPTHSTENCILSTATE);
 
    return ds;
 }
 
-static void svga_bind_depth_stencil_state(struct pipe_context *pipe,
-                                          void *depth_stencil)
+
+static void
+svga_bind_depth_stencil_state(struct pipe_context *pipe, void *depth_stencil)
 {
    struct svga_context *svga = svga_context(pipe);
 
@@ -221,8 +242,9 @@ static void svga_bind_depth_stencil_state(struct pipe_context *pipe,
    svga->dirty |= SVGA_NEW_DEPTH_STENCIL_ALPHA;
 }
 
-static void svga_delete_depth_stencil_state(struct pipe_context *pipe,
-                                            void *depth_stencil)
+
+static void
+svga_delete_depth_stencil_state(struct pipe_context *pipe, void *depth_stencil)
 {
    struct svga_context *svga = svga_context(pipe);
    struct svga_depth_stencil_state *ds =
@@ -250,12 +272,13 @@ static void svga_delete_depth_stencil_state(struct pipe_context *pipe,
    }
 
    FREE(depth_stencil);
-   svga->hud.num_state_objects--;
+   svga->hud.num_depthstencil_objects--;
 }
 
 
-static void svga_set_stencil_ref( struct pipe_context *pipe,
-                                  const struct pipe_stencil_ref *stencil_ref )
+static void
+svga_set_stencil_ref(struct pipe_context *pipe,
+                     const struct pipe_stencil_ref *stencil_ref)
 {
    struct svga_context *svga = svga_context(pipe);
 
@@ -269,6 +292,7 @@ static void svga_set_stencil_ref( struct pipe_context *pipe,
    svga->dirty |= SVGA_NEW_STENCIL_REF;
 }
 
+
 static void
 svga_set_sample_mask(struct pipe_context *pipe,
                      unsigned sample_mask)
@@ -281,7 +305,19 @@ svga_set_sample_mask(struct pipe_context *pipe,
 }
 
 
-void svga_init_depth_stencil_functions( struct svga_context *svga )
+static void
+svga_set_min_samples(struct pipe_context *pipe, unsigned min_samples)
+{
+   /* This specifies the minimum number of times the fragment shader
+    * must run when doing per-sample shading for a MSAA render target.
+    * For our SVGA3D device, the FS is automatically run in per-sample
+    * mode if it uses the sample ID or sample position registers.
+    */
+}
+
+
+void
+svga_init_depth_stencil_functions(struct svga_context *svga)
 {
    svga->pipe.create_depth_stencil_alpha_state = svga_create_depth_stencil_state;
    svga->pipe.bind_depth_stencil_alpha_state = svga_bind_depth_stencil_state;
@@ -289,8 +325,5 @@ void svga_init_depth_stencil_functions( struct svga_context *svga )
 
    svga->pipe.set_stencil_ref = svga_set_stencil_ref;
    svga->pipe.set_sample_mask = svga_set_sample_mask;
+   svga->pipe.set_min_samples = svga_set_min_samples;
 }
-
-
-
-