diff options
author | Marek Olšák <[email protected]> | 2015-06-10 01:49:36 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2015-07-22 23:56:00 +0200 |
commit | 956ebf41aca6b74052cf6876cc479b404777700c (patch) | |
tree | 95a454c3e88b7021576d30e9879dc3863908cfd0 /src | |
parent | b06a6852ff782bb20d9e91a3a67eccb92e856ed3 (diff) |
st/dri: expose sRGB visuals (v2)
v2: The fix for the darkness in Ubuntu Unity is in the hunk
with the 4-line comment.
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/state_trackers/dri/dri_drawable.c | 7 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/dri_screen.c | 23 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_manager.c | 1 |
3 files changed, 26 insertions, 5 deletions
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index b8afe6c4d23..0d2929aaaa1 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -279,7 +279,12 @@ dri_drawable_get_format(struct dri_drawable *drawable, case ST_ATTACHMENT_BACK_LEFT: case ST_ATTACHMENT_FRONT_RIGHT: case ST_ATTACHMENT_BACK_RIGHT: - *format = drawable->stvis.color_format; + /* Other pieces of the driver stack get confused and behave incorrectly + * when they get an sRGB drawable. st/mesa receives "drawable->stvis" + * though other means and handles it correctly, so we don't really need + * to use an sRGB format here. + */ + *format = util_format_linear(drawable->stvis.color_format); *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; break; case ST_ATTACHMENT_DEPTH_STENCIL: diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 85393d867e4..c4c2d9c8fb1 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -103,14 +103,18 @@ dri_fill_st_options(struct st_config_options *options, static const __DRIconfig ** dri_fill_in_modes(struct dri_screen *screen) { - static const mesa_format mesa_formats[3] = { + static const mesa_format mesa_formats[] = { MESA_FORMAT_B8G8R8A8_UNORM, MESA_FORMAT_B8G8R8X8_UNORM, + MESA_FORMAT_B8G8R8A8_SRGB, + MESA_FORMAT_B8G8R8X8_SRGB, MESA_FORMAT_B5G6R5_UNORM, }; - static const enum pipe_format pipe_formats[3] = { + static const enum pipe_format pipe_formats[] = { PIPE_FORMAT_BGRA8888_UNORM, PIPE_FORMAT_BGRX8888_UNORM, + PIPE_FORMAT_BGRA8888_SRGB, + PIPE_FORMAT_BGRX8888_SRGB, PIPE_FORMAT_B5G6R5_UNORM, }; mesa_format format; @@ -186,6 +190,11 @@ dri_fill_in_modes(struct dri_screen *screen) unsigned num_msaa_modes = 0; /* includes a single-sample mode */ uint8_t msaa_modes[MSAA_VISUAL_MAX_SAMPLES]; + if (!p_screen->is_format_supported(p_screen, pipe_formats[format], + PIPE_TEXTURE_2D, 0, + PIPE_BIND_RENDER_TARGET)) + continue; + for (i = 1; i <= msaa_samples_max; i++) { int samples = i > 1 ? i : 0; @@ -241,9 +250,15 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, if (mode->redBits == 8) { if (mode->alphaBits == 8) - stvis->color_format = PIPE_FORMAT_BGRA8888_UNORM; + if (mode->sRGBCapable) + stvis->color_format = PIPE_FORMAT_BGRA8888_SRGB; + else + stvis->color_format = PIPE_FORMAT_BGRA8888_UNORM; else - stvis->color_format = PIPE_FORMAT_BGRX8888_UNORM; + if (mode->sRGBCapable) + stvis->color_format = PIPE_FORMAT_BGRX8888_SRGB; + else + stvis->color_format = PIPE_FORMAT_BGRX8888_UNORM; } else { stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM; } diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index a2dee6298fa..2e2c8ffaed9 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -368,6 +368,7 @@ st_visual_to_context_mode(const struct st_visual *visual, mode->rgbBits = mode->redBits + mode->greenBits + mode->blueBits + mode->alphaBits; + mode->sRGBCapable = util_format_is_srgb(visual->color_format); } if (visual->depth_stencil_format != PIPE_FORMAT_NONE) { |