summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c88
-rw-r--r--src/gallium/state_trackers/egl/common/native.h2
-rw-r--r--src/gallium/state_trackers/egl/kms/native_kms.c14
-rw-r--r--src/gallium/state_trackers/egl/x11/native_dri2.c47
-rw-r--r--src/gallium/state_trackers/egl/x11/native_ximage.c50
5 files changed, 93 insertions, 108 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 96959ec012a..e4f858d179f 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -212,8 +212,8 @@ egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy)
* Initialize and validate the EGL config attributes.
*/
static EGLBoolean
-init_config_attributes(_EGLConfig *conf, EGLint api_mask,
- const struct native_config *nconf)
+init_config_attributes(_EGLConfig *conf, const struct native_config *nconf,
+ EGLint api_mask, enum pipe_format depth_stencil_format)
{
uint rgba[4], depth_stencil[2], buffer_size;
EGLint surface_type;
@@ -228,8 +228,9 @@ init_config_attributes(_EGLConfig *conf, EGLint api_mask,
buffer_size += rgba[i];
}
for (i = 0; i < 2; i++) {
- if (nconf->depth_format != PIPE_FORMAT_NONE) {
- depth_stencil[i] = util_format_get_component_bits(nconf->depth_format,
+ if (depth_stencil_format != PIPE_FORMAT_NONE) {
+ depth_stencil[i] =
+ util_format_get_component_bits(depth_stencil_format,
UTIL_FORMAT_COLORSPACE_ZS, i);
}
else {
@@ -307,7 +308,8 @@ init_config_attributes(_EGLConfig *conf, EGLint api_mask,
*/
static EGLBoolean
egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy,
- _EGLConfig *conf, const struct native_config *nconf)
+ _EGLConfig *conf, const struct native_config *nconf,
+ enum pipe_format depth_stencil_format)
{
struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
struct egl_g3d_config *gconf = egl_g3d_config(conf);
@@ -327,7 +329,7 @@ egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy,
gconf->stvis.buffer_mask = buffer_mask;
gconf->stvis.color_format = nconf->color_format;
- gconf->stvis.depth_stencil_format = nconf->depth_format;
+ gconf->stvis.depth_stencil_format = depth_stencil_format;
gconf->stvis.accum_format = PIPE_FORMAT_NONE;
gconf->stvis.samples = nconf->samples;
@@ -352,7 +354,8 @@ egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy,
nconf->native_visual_id);
}
- valid = init_config_attributes(&gconf->base, api_mask, nconf);
+ valid = init_config_attributes(&gconf->base,
+ nconf, api_mask, depth_stencil_format);
if (!valid) {
_eglLog(_EGL_DEBUG, "skip invalid config 0x%x", nconf->native_visual_id);
return EGL_FALSE;
@@ -364,6 +367,46 @@ egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy,
}
/**
+ * Get all interested depth/stencil formats of a display.
+ */
+static EGLint
+egl_g3d_fill_depth_stencil_formats(_EGLDisplay *dpy,
+ enum pipe_format formats[8])
+{
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+ struct pipe_screen *screen = gdpy->native->screen;
+ const EGLint candidates[] = {
+ 1, PIPE_FORMAT_Z16_UNORM,
+ 1, PIPE_FORMAT_Z32_UNORM,
+ 2, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
+ 2, PIPE_FORMAT_Z24X8_UNORM, PIPE_FORMAT_X8Z24_UNORM,
+ 0
+ };
+ const EGLint *fmt = candidates;
+ EGLint count;
+
+ count = 0;
+ formats[count++] = PIPE_FORMAT_NONE;
+
+ while (*fmt) {
+ EGLint i, n = *fmt++;
+
+ /* pick the first supported format */
+ for (i = 0; i < n; i++) {
+ if (screen->is_format_supported(screen, fmt[i],
+ PIPE_TEXTURE_2D, PIPE_BIND_DEPTH_STENCIL, 0)) {
+ formats[count++] = fmt[i];
+ break;
+ }
+ }
+
+ fmt += n;
+ }
+
+ return count;
+}
+
+/**
* Add configs to display and return the next config ID.
*/
static EGLint
@@ -371,7 +414,8 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id)
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
const struct native_config **native_configs;
- int num_configs, i;
+ enum pipe_format depth_stencil_formats[8];
+ int num_formats, num_configs, i, j;
native_configs = gdpy->native->get_configs(gdpy->native, &num_configs);
if (!num_configs) {
@@ -380,19 +424,25 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id)
return id;
}
+ num_formats = egl_g3d_fill_depth_stencil_formats(dpy,
+ depth_stencil_formats);
+
for (i = 0; i < num_configs; i++) {
- struct egl_g3d_config *gconf;
-
- gconf = CALLOC_STRUCT(egl_g3d_config);
- if (gconf) {
- _eglInitConfig(&gconf->base, dpy, id);
- if (!egl_g3d_init_config(drv, dpy, &gconf->base, native_configs[i])) {
- free(gconf);
- continue;
+ for (j = 0; j < num_formats; j++) {
+ struct egl_g3d_config *gconf;
+
+ gconf = CALLOC_STRUCT(egl_g3d_config);
+ if (gconf) {
+ _eglInitConfig(&gconf->base, dpy, id);
+ if (!egl_g3d_init_config(drv, dpy, &gconf->base,
+ native_configs[i], depth_stencil_formats[j])) {
+ free(gconf);
+ break;
+ }
+
+ _eglAddConfig(dpy, &gconf->base);
+ id++;
}
-
- _eglAddConfig(dpy, &gconf->base);
- id++;
}
}
diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
index 628befeae26..9a163d0c869 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -107,8 +107,6 @@ struct native_config {
/* available buffers and their format */
uint buffer_mask;
enum pipe_format color_format;
- enum pipe_format depth_format;
- enum pipe_format stencil_format;
/* supported surface types */
boolean window_bit;
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c
index f8c55990237..d1ff0f47b67 100644
--- a/src/gallium/state_trackers/egl/kms/native_kms.c
+++ b/src/gallium/state_trackers/egl/kms/native_kms.c
@@ -597,20 +597,14 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs)
if (!kms_display_is_format_supported(&kdpy->base, format, TRUE))
format = PIPE_FORMAT_NONE;
}
- if (format == PIPE_FORMAT_NONE)
+ if (format == PIPE_FORMAT_NONE) {
+ free(kdpy->config);
+ kdpy->config = NULL;
return NULL;
+ }
nconf->color_format = format;
- format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) {
- format = PIPE_FORMAT_S8_USCALED_Z24_UNORM;
- if (!kms_display_is_format_supported(&kdpy->base, format, FALSE))
- format = PIPE_FORMAT_NONE;
- }
- nconf->depth_format = format;
- nconf->stencil_format = format;
-
nconf->scanout_bit = TRUE;
}
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 167115708cb..9499319424e 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -483,36 +483,6 @@ choose_color_format(const __GLcontextModes *mode, enum pipe_format formats[32])
return count;
}
-static int
-choose_depth_stencil_format(const __GLcontextModes *mode,
- enum pipe_format formats[32])
-{
- int count = 0;
-
- switch (mode->depthBits) {
- case 32:
- formats[count++] = PIPE_FORMAT_Z32_UNORM;
- break;
- case 24:
- if (mode->stencilBits) {
- formats[count++] = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- formats[count++] = PIPE_FORMAT_S8_USCALED_Z24_UNORM;
- }
- else {
- formats[count++] = PIPE_FORMAT_Z24X8_UNORM;
- formats[count++] = PIPE_FORMAT_X8Z24_UNORM;
- }
- break;
- case 16:
- formats[count++] = PIPE_FORMAT_Z16_UNORM;
- break;
- default:
- break;
- }
-
- return count;
-}
-
static boolean
is_format_supported(struct pipe_screen *screen,
enum pipe_format fmt, boolean is_color)
@@ -541,10 +511,6 @@ dri2_display_convert_config(struct native_display *ndpy,
if (!mode->xRenderable || !mode->drawableType)
return FALSE;
- nconf->color_format = PIPE_FORMAT_NONE;
- nconf->depth_format = PIPE_FORMAT_NONE;
- nconf->stencil_format = PIPE_FORMAT_NONE;
-
nconf->buffer_mask = 1 << NATIVE_ATTACHMENT_FRONT_LEFT;
if (mode->doubleBufferMode)
nconf->buffer_mask |= 1 << NATIVE_ATTACHMENT_BACK_LEFT;
@@ -565,19 +531,6 @@ dri2_display_convert_config(struct native_display *ndpy,
if (nconf->color_format == PIPE_FORMAT_NONE)
return FALSE;
- /* choose depth/stencil format */
- num_formats = choose_depth_stencil_format(mode, formats);
- for (i = 0; i < num_formats; i++) {
- if (is_format_supported(ndpy->screen, formats[i], FALSE)) {
- nconf->depth_format = formats[i];
- nconf->stencil_format = formats[i];
- break;
- }
- }
- if ((mode->depthBits && nconf->depth_format == PIPE_FORMAT_NONE) ||
- (mode->stencilBits && nconf->stencil_format == PIPE_FORMAT_NONE))
- return FALSE;
-
if (mode->drawableType & GLX_WINDOW_BIT)
nconf->window_bit = TRUE;
if (mode->drawableType & GLX_PIXMAP_BIT)
diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c
index 9d6d63344c3..203e06e1777 100644
--- a/src/gallium/state_trackers/egl/x11/native_ximage.c
+++ b/src/gallium/state_trackers/egl/x11/native_ximage.c
@@ -466,7 +466,7 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs)
/* first time */
if (!xdpy->configs) {
const XVisualInfo *visuals;
- int num_visuals, count, j;
+ int num_visuals, count;
visuals = x11_screen_get_visuals(xdpy->xscr, &num_visuals);
if (!visuals)
@@ -482,40 +482,30 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs)
count = 0;
for (i = 0; i < num_visuals; i++) {
- for (j = 0; j < 2; j++) {
- struct ximage_config *xconf = &xdpy->configs[count];
-
- xconf->visual = &visuals[i];
- xconf->base.color_format = choose_format(xconf->visual);
- if (xconf->base.color_format == PIPE_FORMAT_NONE)
- continue;
-
- xconf->base.buffer_mask =
- (1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
- (1 << NATIVE_ATTACHMENT_BACK_LEFT);
-
- xconf->base.depth_format = PIPE_FORMAT_NONE;
- xconf->base.stencil_format = PIPE_FORMAT_NONE;
- /* create the second config with depth/stencil buffer */
- if (j == 1) {
- xconf->base.depth_format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- xconf->base.stencil_format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- }
-
- xconf->base.window_bit = TRUE;
- xconf->base.pixmap_bit = TRUE;
-
- xconf->base.native_visual_id = xconf->visual->visualid;
+ struct ximage_config *xconf = &xdpy->configs[count];
+
+ xconf->visual = &visuals[i];
+ xconf->base.color_format = choose_format(xconf->visual);
+ if (xconf->base.color_format == PIPE_FORMAT_NONE)
+ continue;
+
+ xconf->base.buffer_mask =
+ (1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
+ (1 << NATIVE_ATTACHMENT_BACK_LEFT);
+
+ xconf->base.window_bit = TRUE;
+ xconf->base.pixmap_bit = TRUE;
+
+ xconf->base.native_visual_id = xconf->visual->visualid;
#if defined(__cplusplus) || defined(c_plusplus)
- xconf->base.native_visual_type = xconf->visual->c_class;
+ xconf->base.native_visual_type = xconf->visual->c_class;
#else
- xconf->base.native_visual_type = xconf->visual->class;
+ xconf->base.native_visual_type = xconf->visual->class;
#endif
- xconf->base.slow_config = TRUE;
+ xconf->base.slow_config = TRUE;
- count++;
- }
+ count++;
}
xdpy->num_configs = count;