i965: Add support for MRT to the new FS backend.
[mesa.git] / src / egl / main / eglconfig.h
index 799bf4ee2424e557a18d0195bc476e6b6633e4a1..0ad58cf473d4d9d0a0881bdc735db17904e7aad1 100644 (file)
@@ -8,19 +8,30 @@
 
 #define _EGL_CONFIG_FIRST_ATTRIB EGL_BUFFER_SIZE
 #define _EGL_CONFIG_LAST_ATTRIB EGL_CONFORMANT
-#define _EGL_CONFIG_NUM_ATTRIBS \
+#define _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS \
    (_EGL_CONFIG_LAST_ATTRIB - _EGL_CONFIG_FIRST_ATTRIB + 1)
 
-#define _EGL_CONFIG_STORAGE_SIZE _EGL_CONFIG_NUM_ATTRIBS
+/* Attributes outside the contiguous block:
+ *
+ *   EGL_Y_INVERTED_NOK
+ */
+#define _EGL_CONFIG_FIRST_EXTRA_ATTRIB _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS
+#define _EGL_CONFIG_NUM_EXTRA_ATTRIBS 1
+
+#define _EGL_CONFIG_NUM_ATTRIBS \
+   _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS + _EGL_CONFIG_NUM_EXTRA_ATTRIBS
 
 
 struct _egl_config
 {
    _EGLDisplay *Display;
-   EGLint Storage[_EGL_CONFIG_STORAGE_SIZE];
+   EGLint Storage[_EGL_CONFIG_NUM_ATTRIBS];
 };
 
 
+/**
+ * Macros for source level compatibility.
+ */
 #define SET_CONFIG_ATTRIB(CONF, ATTR, VAL) _eglSetConfigKey(CONF, ATTR, VAL)
 #define GET_CONFIG_ATTRIB(CONF, ATTR) _eglGetConfigKey(CONF, ATTR)
 
@@ -34,10 +45,15 @@ _eglIndexConfig(const _EGLConfig *conf, EGLint key)
 {
    (void) conf;
    if (key >= _EGL_CONFIG_FIRST_ATTRIB &&
-       key < _EGL_CONFIG_FIRST_ATTRIB + _EGL_CONFIG_NUM_ATTRIBS)
+       key < _EGL_CONFIG_FIRST_ATTRIB + _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS)
       return key - _EGL_CONFIG_FIRST_ATTRIB;
-   else
+   
+   switch (key) {
+   case EGL_Y_INVERTED_NOK:
+      return _EGL_CONFIG_FIRST_EXTRA_ATTRIB;
+   default:
       return -1;
+   }
 }
 
 
@@ -55,6 +71,10 @@ _eglResetConfigKeys(_EGLConfig *conf, EGLint val)
 
 /**
  * Update a config for a given key.
+ *
+ * Note that a valid key is not necessarily a valid attribute.  There are gaps
+ * in the attribute enums.  The separation is to catch application errors.
+ * Drivers should never set a key that is an invalid attribute.
  */
 static INLINE void
 _eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val)
@@ -77,49 +97,18 @@ _eglGetConfigKey(const _EGLConfig *conf, EGLint key)
 }
 
 
-/**
- * Set a given attribute.
- *
- * Because _eglGetConfigAttrib is already used as a fallback driver
- * function, this function is not considered to have a good name.
- * SET_CONFIG_ATTRIB is preferred over this function.
- */
-static INLINE void
-_eglSetConfigAttrib(_EGLConfig *conf, EGLint attr, EGLint val)
-{
-   SET_CONFIG_ATTRIB(conf, attr, val);
-}
-
-
 PUBLIC void
-_eglInitConfig(_EGLConfig *config, EGLint id);
+_eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id);
 
 
 PUBLIC EGLConfig
 _eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf);
 
 
-#ifndef _EGL_SKIP_HANDLE_CHECK
-
-
 extern EGLBoolean
 _eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy);
 
 
-#else
-
-
-static INLINE EGLBoolean
-_eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy)
-{
-   _EGLConfig *conf = (_EGLConfig *) config;
-   return (dpy && conf && conf->Display == dpy);
-}
-
-
-#endif /* _EGL_SKIP_HANDLE_CHECK */
-
-
 /**
  * Lookup a handle to find the linked config.
  * Return NULL if the handle has no corresponding linked config.
@@ -128,7 +117,7 @@ static INLINE _EGLConfig *
 _eglLookupConfig(EGLConfig config, _EGLDisplay *dpy)
 {
    _EGLConfig *conf = (_EGLConfig *) config;
-   if (!_eglCheckConfigHandle(config, dpy))
+   if (!dpy || !_eglCheckConfigHandle(config, dpy))
       conf = NULL;
    return conf;
 }