[Mesa-dev] [PATCH 6/9] st/dri: expose sRGB visuals
Marek Olšák
maraeo at gmail.com
Wed Jun 10 09:27:17 PDT 2015
From: Marek Olšák <marek.olsak at amd.com>
They are only useful for EGL currently, because the previous patch disables
them for GLX.
---
src/gallium/state_trackers/dri/dri2.c | 2 ++
src/gallium/state_trackers/dri/dri_screen.c | 23 +++++++++++++++++++----
src/mesa/state_tracker/st_manager.c | 1 +
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 792d565..a24c104 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -189,9 +189,11 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
*/
switch(format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_B8G8R8A8_SRGB:
depth = 32;
break;
case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_B8G8R8X8_SRGB:
depth = 24;
break;
case PIPE_FORMAT_B5G6R5_UNORM:
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 85393d8..c4c2d9c 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 a2dee62..2e2c8ff 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) {
--
2.1.0
More information about the mesa-dev
mailing list