diff options
author | Marek Olšák <[email protected]> | 2012-12-10 21:35:59 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-12-12 13:09:54 +0100 |
commit | 1d0bf69f831e138a05a282e59746f20141046fd6 (patch) | |
tree | b448e744c8520908b9fe463df21a6ae7fa3ea3e6 /src/gallium/state_trackers/dri | |
parent | afa902a705b9de70902b6559a383a35f38152555 (diff) |
st/dri: add a way to force MSAA on with an environment variable
There are 2 ways. I prefer the former:
GALLIUM_MSAA=n
__GL_FSAA_MODE=n
Tested with ETQW, which doesn't support MSAA on Linux. This is
the only way to get MSAA there.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/dri')
-rw-r--r-- | src/gallium/state_trackers/dri/common/dri_screen.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 6d220f2ed7b..a908e28be76 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -194,6 +194,37 @@ dri_fill_in_modes(struct dri_screen *screen) return (const __DRIconfig **)configs; } +/* The Gallium way to force MSAA. */ +DEBUG_GET_ONCE_NUM_OPTION(msaa, "GALLIUM_MSAA", 0); + +/* The NVIDIA way to force MSAA. The same variable is used by the NVIDIA + * driver. */ +DEBUG_GET_ONCE_NUM_OPTION(msaa_nv, "__GL_FSAA_MODE", 0); + +static void +dri_force_msaa_visual(struct st_visual *stvis, + struct pipe_screen *screen) +{ + int i; + int samples = debug_get_option_msaa(); + + if (!samples) + samples = debug_get_option_msaa_nv(); + + if (samples <= 1) + return; /* nothing to do */ + + /* Choose a supported sample count greater than or equal to samples. */ + for (i = samples; i <= MSAA_VISUAL_MAX_SAMPLES; i++) { + if (screen->is_format_supported(screen, stvis->color_format, + PIPE_TEXTURE_2D, i, + PIPE_BIND_RENDER_TARGET)) { + stvis->samples = i; + break; + } + } +} + /** * Roughly the converse of dri_fill_in_modes. */ @@ -206,10 +237,6 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, if (!mode) return; - if (mode->sampleBuffers) { - stvis->samples = mode->samples; - } - if (mode->redBits == 8) { if (mode->alphaBits == 8) stvis->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; @@ -219,6 +246,14 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM; } + if (mode->sampleBuffers) { + stvis->samples = mode->samples; + } + else { + /* This must be done after stvis->color_format is set. */ + dri_force_msaa_visual(stvis, screen->base.screen); + } + switch (mode->depthBits) { default: case 0: |