st/wgl: add support for multisample pixel formats
authorBrian Paul <brianp@vmware.com>
Tue, 16 Jun 2015 21:32:45 +0000 (15:32 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 19 Jun 2015 14:45:00 +0000 (08:45 -0600)
Create pixel formats with 0, 4, 8 and 16 samples per pixel.
Add a SVGA_FORCE_MSAA env var to force creating all pixel formats
with a particular sample count.  This is useful for testing Mesa/GLUT/
etc. programs which don't ordinarily use multisample.

Reviewed-by: Matthew McClure <mcclurem@vmware.com>
src/gallium/state_trackers/wgl/stw_pixelformat.c

index b0cd5abd27afa713e371d7ebdec04fe177899b9f..db6cf8ee30f05f40176f176ba549fb4f5975c895 100644 (file)
@@ -113,7 +113,9 @@ stw_pf_doublebuffer[] = {
 const unsigned 
 stw_pf_multisample[] = {
    0,
-   4
+   4,
+   8,
+   16
 };
 
 
@@ -222,23 +224,32 @@ add_color_format_variants(const struct stw_pf_color_info *color,
    unsigned ms, db, ds, acc;
    unsigned bind_flags = PIPE_BIND_RENDER_TARGET;
    unsigned num_added = 0;
+   int force_samples = 0;
 
-   if (!extended) {
-      bind_flags |= PIPE_BIND_DISPLAY_TARGET;
+   /* Since GLUT for Windows doesn't support MSAA we have an env var
+    * to force all pixel formats to have a particular number of samples.
+    */
+   {
+      const char *samples= getenv("SVGA_FORCE_MSAA");
+      if (samples)
+         force_samples = atoi(samples);
    }
 
-   if (!screen->is_format_supported(screen, color->format,
-                                    PIPE_TEXTURE_2D, 0, bind_flags)) {
-      return 0;
+   if (!extended) {
+      bind_flags |= PIPE_BIND_DISPLAY_TARGET;
    }
 
    for (ms = 0; ms < Elements(stw_pf_multisample); ms++) {
       unsigned samples = stw_pf_multisample[ms];
 
-      /* FIXME: re-enabled MSAA when we can query it */
-      if (samples)
+      if (force_samples && samples != force_samples)
          continue;
 
+      if (!screen->is_format_supported(screen, color->format,
+                                       PIPE_TEXTURE_2D, samples, bind_flags)) {
+         continue;
+      }
+
       for (db = 0; db < Elements(stw_pf_doublebuffer); db++) {
          unsigned doublebuffer = stw_pf_doublebuffer[db];
 
@@ -246,7 +257,7 @@ add_color_format_variants(const struct stw_pf_color_info *color,
             const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[ds];
 
             if (!screen->is_format_supported(screen, depth->format,
-                                             PIPE_TEXTURE_2D, 0,
+                                             PIPE_TEXTURE_2D, samples,
                                              PIPE_BIND_DEPTH_STENCIL)) {
                continue;
             }