1 diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
2 index 82a0988a63..43e54e2065 100644
3 --- a/src/gallium/state_trackers/dri/dri_screen.c
4 +++ b/src/gallium/state_trackers/dri/dri_screen.c
5 @@ -298,6 +298,37 @@ dri_fill_in_modes(struct dri_screen *screen)
6 return (const __DRIconfig **)configs;
9 +/* The Gallium way to force MSAA. */
10 +DEBUG_GET_ONCE_NUM_OPTION(msaa, "GALLIUM_MSAA", 0);
12 +/* The NVIDIA way to force MSAA. The same variable is used by the NVIDIA
14 +DEBUG_GET_ONCE_NUM_OPTION(msaa_nv, "__GL_FSAA_MODE", 0);
17 +dri_force_msaa_visual(struct st_visual *stvis,
18 + struct pipe_screen *screen)
21 + int samples = debug_get_option_msaa();
24 + samples = debug_get_option_msaa_nv();
27 + return; /* nothing to do */
29 + /* Choose a supported sample count greater than or equal to samples. */
30 + for (i = samples; i <= MSAA_VISUAL_MAX_SAMPLES; i++) {
31 + if (screen->is_format_supported(screen, stvis->color_format,
32 + PIPE_TEXTURE_2D, i, i,
33 + PIPE_BIND_RENDER_TARGET)) {
41 * Roughly the converse of dri_fill_in_modes.
43 @@ -371,6 +402,10 @@ dri_fill_st_visual(struct st_visual *stvis,
44 if (mode->sampleBuffers) {
45 stvis->samples = mode->samples;
48 + /* This must be done after stvis->color_format is set. */
49 + dri_force_msaa_visual(stvis, screen->base.screen);
52 switch (mode->depthBits) {