From 9405c1b3b0b207409931166a608276198a068cb8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Jun 2015 15:32:45 -0600 Subject: st/wgl: add support for multisample pixel formats 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 --- src/gallium/state_trackers/wgl/stw_pixelformat.c | 29 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index b0cd5abd27a..db6cf8ee30f 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -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; } -- cgit v1.2.3