summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/egl/common
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-04-09 18:05:16 +0800
committerChia-I Wu <[email protected]>2010-04-11 01:17:47 +0800
commitf7730c0740cc8a43c3573dcdbf43e76630d957f6 (patch)
tree203329248def9a82d044c3f81375c0956920b64e /src/gallium/state_trackers/egl/common
parent51430c21ffd212d801f129d625f3ae8713372f68 (diff)
st/egl: Remove __GLcontextModes from the native interface.
Replace __GLcontextModes by a subset of its attributes that makes sense to EGL. This also gets rid of GL headers from the common code.
Diffstat (limited to 'src/gallium/state_trackers/egl/common')
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c133
-rw-r--r--src/gallium/state_trackers/egl/common/native.h33
-rw-r--r--src/gallium/state_trackers/egl/common/native_modeset.h4
3 files changed, 129 insertions, 41 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index efddf56cbf9..96959ec012a 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -30,9 +30,9 @@
#include "util/u_memory.h"
#include "util/u_rect.h"
#include "util/u_inlines.h"
+#include "util/u_format.h"
#include "egldriver.h"
#include "eglcurrent.h"
-#include "eglconfigutil.h"
#include "egllog.h"
#include "native.h"
@@ -209,6 +209,100 @@ egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy)
#endif /* EGL_MESA_screen_surface */
/**
+ * Initialize and validate the EGL config attributes.
+ */
+static EGLBoolean
+init_config_attributes(_EGLConfig *conf, EGLint api_mask,
+ const struct native_config *nconf)
+{
+ uint rgba[4], depth_stencil[2], buffer_size;
+ EGLint surface_type;
+ EGLint i;
+
+ /* get the color and depth/stencil component sizes */
+ assert(nconf->color_format != PIPE_FORMAT_NONE);
+ buffer_size = 0;
+ for (i = 0; i < 4; i++) {
+ rgba[i] = util_format_get_component_bits(nconf->color_format,
+ UTIL_FORMAT_COLORSPACE_RGB, i);
+ 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,
+ UTIL_FORMAT_COLORSPACE_ZS, i);
+ }
+ else {
+ depth_stencil[i] = 0;
+ }
+ }
+
+ surface_type = 0x0;
+ if (nconf->window_bit)
+ surface_type |= EGL_WINDOW_BIT;
+ if (nconf->pixmap_bit)
+ surface_type |= EGL_PIXMAP_BIT;
+#ifdef EGL_MESA_screen_surface
+ if (nconf->scanout_bit)
+ surface_type |= EGL_SCREEN_BIT_MESA;
+#endif
+
+ if (nconf->buffer_mask & (1 << NATIVE_ATTACHMENT_BACK_LEFT))
+ surface_type |= EGL_PBUFFER_BIT;
+
+ SET_CONFIG_ATTRIB(conf, EGL_CONFORMANT, api_mask);
+ SET_CONFIG_ATTRIB(conf, EGL_RENDERABLE_TYPE, api_mask);
+
+ SET_CONFIG_ATTRIB(conf, EGL_RED_SIZE, rgba[0]);
+ SET_CONFIG_ATTRIB(conf, EGL_GREEN_SIZE, rgba[1]);
+ SET_CONFIG_ATTRIB(conf, EGL_BLUE_SIZE, rgba[2]);
+ SET_CONFIG_ATTRIB(conf, EGL_ALPHA_SIZE, rgba[3]);
+ SET_CONFIG_ATTRIB(conf, EGL_BUFFER_SIZE, buffer_size);
+
+ SET_CONFIG_ATTRIB(conf, EGL_DEPTH_SIZE, depth_stencil[0]);
+ SET_CONFIG_ATTRIB(conf, EGL_STENCIL_SIZE, depth_stencil[1]);
+
+ SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE, surface_type);
+
+ SET_CONFIG_ATTRIB(conf, EGL_NATIVE_RENDERABLE, EGL_TRUE);
+ if (surface_type & EGL_WINDOW_BIT) {
+ SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID, nconf->native_visual_id);
+ SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE,
+ nconf->native_visual_type);
+ }
+
+ if (surface_type & EGL_PBUFFER_BIT) {
+ SET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE);
+ if (rgba[3])
+ SET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE);
+
+ SET_CONFIG_ATTRIB(conf, EGL_MAX_PBUFFER_WIDTH, 4096);
+ SET_CONFIG_ATTRIB(conf, EGL_MAX_PBUFFER_HEIGHT, 4096);
+ SET_CONFIG_ATTRIB(conf, EGL_MAX_PBUFFER_PIXELS, 4096 * 4096);
+ }
+
+ SET_CONFIG_ATTRIB(conf, EGL_LEVEL, nconf->level);
+ SET_CONFIG_ATTRIB(conf, EGL_SAMPLES, nconf->samples);
+ SET_CONFIG_ATTRIB(conf, EGL_SAMPLE_BUFFERS, 1);
+
+ if (nconf->slow_config)
+ SET_CONFIG_ATTRIB(conf, EGL_CONFIG_CAVEAT, EGL_SLOW_CONFIG);
+
+ if (nconf->transparent_rgb) {
+ rgba[0] = nconf->transparent_rgb_values[0];
+ rgba[1] = nconf->transparent_rgb_values[1];
+ rgba[2] = nconf->transparent_rgb_values[2];
+
+ SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_RGB);
+ SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_RED_VALUE, rgba[0]);
+ SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_GREEN_VALUE, rgba[1]);
+ SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_BLUE_VALUE, rgba[2]);
+ }
+
+ return _eglValidateConfig(conf, EGL_FALSE);
+}
+
+/**
* Initialize an EGL config from the native config.
*/
static EGLBoolean
@@ -217,25 +311,25 @@ egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy,
{
struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
struct egl_g3d_config *gconf = egl_g3d_config(conf);
- const __GLcontextModes *mode = &nconf->mode;
EGLint buffer_mask, api_mask;
EGLBoolean valid;
EGLint i;
- buffer_mask = ST_ATTACHMENT_FRONT_LEFT_MASK;
- if (mode->doubleBufferMode)
+ buffer_mask = 0x0;
+ if (nconf->buffer_mask & (1 << NATIVE_ATTACHMENT_FRONT_LEFT))
+ buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK;
+ if (nconf->buffer_mask & (1 << NATIVE_ATTACHMENT_BACK_LEFT))
buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK;
- if (mode->stereoMode) {
+ if (nconf->buffer_mask & (1 << NATIVE_ATTACHMENT_FRONT_RIGHT))
buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK;
- if (mode->doubleBufferMode)
- buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK;
- }
+ if (nconf->buffer_mask & (1 << NATIVE_ATTACHMENT_BACK_RIGHT))
+ buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK;
gconf->stvis.buffer_mask = buffer_mask;
gconf->stvis.color_format = nconf->color_format;
gconf->stvis.depth_stencil_format = nconf->depth_format;
gconf->stvis.accum_format = PIPE_FORMAT_NONE;
- gconf->stvis.samples = 0;
+ gconf->stvis.samples = nconf->samples;
gconf->stvis.render_buffer = (buffer_mask & ST_ATTACHMENT_BACK_LEFT_MASK) ?
ST_ATTACHMENT_BACK_LEFT : ST_ATTACHMENT_FRONT_LEFT;
@@ -249,29 +343,18 @@ egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy,
}
}
/* this is required by EGL, not by OpenGL ES */
- if ((mode->drawableType & GLX_WINDOW_BIT) && !mode->doubleBufferMode)
+ if (nconf->window_bit &&
+ gconf->stvis.render_buffer != ST_ATTACHMENT_BACK_LEFT)
api_mask &= ~(EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT);
if (!api_mask) {
_eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x",
- mode->visualID);
+ nconf->native_visual_id);
}
- valid = _eglConfigFromContextModesRec(&gconf->base,
- mode, api_mask, api_mask);
- if (valid) {
-#ifdef EGL_MESA_screen_surface
- /* check if scanout surface bit is set */
- if (nconf->scanout_bit) {
- EGLint val = GET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE);
- val |= EGL_SCREEN_BIT_MESA;
- SET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE, val);
- }
-#endif
- valid = _eglValidateConfig(&gconf->base, EGL_FALSE);
- }
+ valid = init_config_attributes(&gconf->base, api_mask, nconf);
if (!valid) {
- _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", mode->visualID);
+ _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", nconf->native_visual_id);
return EGL_FALSE;
}
diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
index 5ab21b639ea..628befeae26 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -27,8 +27,6 @@
#define _NATIVE_H_
#include "EGL/egl.h" /* for EGL native types */
-#include "GL/gl.h" /* for GL types needed by __GLcontextModes */
-#include "GL/internal/glcore.h" /* for __GLcontextModes */
#include "pipe/p_compiler.h"
#include "pipe/p_screen.h"
@@ -102,15 +100,28 @@ struct native_surface {
void (*wait)(struct native_surface *nsurf);
};
+/**
+ * Describe a native display config.
+ */
struct native_config {
- /* __GLcontextModes should go away some day */
- __GLcontextModes mode;
+ /* available buffers and their format */
+ uint buffer_mask;
enum pipe_format color_format;
enum pipe_format depth_format;
enum pipe_format stencil_format;
- /* treat it as an additional flag to mode.drawableType */
+ /* supported surface types */
+ boolean window_bit;
+ boolean pixmap_bit;
boolean scanout_bit;
+
+ int native_visual_id;
+ int native_visual_type;
+ int level;
+ int samples;
+ boolean slow_config;
+ boolean transparent_rgb;
+ int transparent_rgb_values[3];
};
/**
@@ -142,17 +153,13 @@ struct native_display {
/**
* Get the supported configs. The configs are owned by the display, but
* the returned array should be free()ed.
- *
- * The configs will be converted to EGL config by
- * _eglConfigFromContextModesRec and validated by _eglValidateConfig.
- * Those failing to pass the test will be skipped.
*/
const struct native_config **(*get_configs)(struct native_display *ndpy,
int *num_configs);
/**
* Test if a pixmap is supported by the given config. Required unless no
- * config has GLX_PIXMAP_BIT set.
+ * config has pixmap_bit set.
*
* This function is usually called to find a config that supports a given
* pixmap. Thus, it is usually called with the same pixmap in a row.
@@ -163,16 +170,14 @@ struct native_display {
/**
- * Create a window surface. Required unless no config has GLX_WINDOW_BIT
- * set.
+ * Create a window surface. Required unless no config has window_bit set.
*/
struct native_surface *(*create_window_surface)(struct native_display *ndpy,
EGLNativeWindowType win,
const struct native_config *nconf);
/**
- * Create a pixmap surface. Required unless no config has GLX_PIXMAP_BIT
- * set.
+ * Create a pixmap surface. Required unless no config has pixmap_bit set.
*/
struct native_surface *(*create_pixmap_surface)(struct native_display *ndpy,
EGLNativePixmapType pix,
diff --git a/src/gallium/state_trackers/egl/common/native_modeset.h b/src/gallium/state_trackers/egl/common/native_modeset.h
index 154d58381dc..dee757b3a88 100644
--- a/src/gallium/state_trackers/egl/common/native_modeset.h
+++ b/src/gallium/state_trackers/egl/common/native_modeset.h
@@ -64,8 +64,8 @@ struct native_display_modeset {
int *num_modes);
/**
- * Create a scan-out surface. Required unless no config has
- * GLX_SCREEN_BIT_MESA set.
+ * Create a scan-out surface. Required unless no config has scanout_bit
+ * set.
*/
struct native_surface *(*create_scanout_surface)(struct native_display *ndpy,
const struct native_config *nconf,