mesa: rename rowStride to imageStride in texturesubimage()
[mesa.git] / src / mesa / state_tracker / st_atom_msaa.c
index 9baa4fcf2eb9fa2f06ee27223b49c11a18484b3b..703cb5e755cd9e12219714542b0c90108d6eb634 100644 (file)
 
 
 #include "st_context.h"
+#include "pipe/p_screen.h"
 #include "pipe/p_context.h"
 #include "st_atom.h"
+#include "st_program.h"
 
 #include "cso_cache/cso_context.h"
+#include "util/u_framebuffer.h"
 
 
 /* Second state atom for user clip planes:
 static void update_sample_mask( struct st_context *st )
 {
    unsigned sample_mask = 0xffffffff;
-   unsigned sample_count = 1;
    struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer;
-
    /* dependency here on bound surface (or rather, sample count) is worrying */
-   if (framebuffer->zsbuf)
-      sample_count = framebuffer->zsbuf->texture->nr_samples;
-   else if (framebuffer->cbufs[0])
-      sample_count = framebuffer->cbufs[0]->texture->nr_samples;
+   unsigned sample_count = util_framebuffer_get_num_samples(framebuffer);
 
    if (st->ctx->Multisample.Enabled && sample_count > 1) {
    /* unlike in gallium/d3d10 the mask is only active if msaa is enabled */
@@ -62,7 +60,8 @@ static void update_sample_mask( struct st_context *st )
          if (st->ctx->Multisample.SampleCoverageInvert)
             sample_mask = ~sample_mask;
       }
-      /* TODO merge with app-supplied sample mask */
+      if (st->ctx->Multisample.SampleMask)
+         sample_mask &= st->ctx->Multisample.SampleMaskValue;
    }
 
    /* mask off unused bits or don't care? */
@@ -73,6 +72,18 @@ static void update_sample_mask( struct st_context *st )
    }
 }
 
+static void update_sample_shading( struct st_context *st )
+{
+   if (!st->fp)
+      return;
+
+   if (!st->ctx->Extensions.ARB_sample_shading)
+      return;
+
+   cso_set_min_samples(
+        st->cso_context,
+         _mesa_get_min_invocations_per_fragment(st->ctx, &st->fp->Base, false));
+}
 
 const struct st_tracked_state st_update_msaa = {
    "st_update_msaa",                                   /* name */
@@ -82,3 +93,12 @@ const struct st_tracked_state st_update_msaa = {
    },
    update_sample_mask                                  /* update */
 };
+
+const struct st_tracked_state st_update_sample_shading = {
+   "st_update_sample_shading",                         /* name */
+   {                                                   /* dirty */
+      (_NEW_MULTISAMPLE | _NEW_PROGRAM | _NEW_BUFFERS),        /* mesa */
+      ST_NEW_FRAGMENT_PROGRAM | ST_NEW_FRAMEBUFFER,    /* st */
+   },
+   update_sample_shading                               /* update */
+};