summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-05-21 16:43:12 +0200
committerChristian König <[email protected]>2011-05-21 16:43:12 +0200
commitaa63ebc48a2ee1ee9afbf2112d4d25e8a9a8d1e8 (patch)
treec97d505614f1fd84d498484a45156e0064daf649 /src/gallium/state_trackers
parent120b55a96e30f1f74ba3448665cef3d724fed647 (diff)
parent3c5e74186244f2d77cc711d2b487283459ed06ad (diff)
Merge remote-tracking branch 'origin/master' into pipe-video
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.c9
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_image.c8
-rw-r--r--src/gallium/state_trackers/egl/wayland/native_wayland.c38
-rw-r--r--src/gallium/state_trackers/glx/xlib/glx_api.c202
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c16
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.h5
6 files changed, 197 insertions, 81 deletions
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 30326a23d6c..e471e8e5be2 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -481,6 +481,15 @@ dri2_create_image(__DRIscreen *_screen,
enum pipe_format pf;
tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+ if (use & __DRI_IMAGE_USE_SCANOUT)
+ tex_usage |= PIPE_BIND_SCANOUT;
+ if (use & __DRI_IMAGE_USE_SHARE)
+ tex_usage |= PIPE_BIND_SHARED;
+ if (use & __DRI_IMAGE_USE_CURSOR) {
+ if (width != 64 || height != 64)
+ return NULL;
+ tex_usage |= PIPE_BIND_CURSOR;
+ }
switch (format) {
case __DRI_IMAGE_FORMAT_RGB565:
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_image.c b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
index 210b8c2ee82..ce72e27c3d5 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_image.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
@@ -97,7 +97,8 @@ egl_g3d_create_drm_buffer(_EGLDisplay *dpy, _EGLImage *img,
}
valid_use = EGL_DRM_BUFFER_USE_SCANOUT_MESA |
- EGL_DRM_BUFFER_USE_SHARE_MESA;
+ EGL_DRM_BUFFER_USE_SHARE_MESA |
+ EGL_DRM_BUFFER_USE_CURSOR_MESA;
if (attrs.DRMBufferUseMESA & ~valid_use) {
_eglLog(_EGL_DEBUG, "bad image use bit 0x%04x",
attrs.DRMBufferUseMESA);
@@ -122,6 +123,11 @@ egl_g3d_create_drm_buffer(_EGLDisplay *dpy, _EGLImage *img,
templ.bind |= PIPE_BIND_SCANOUT;
if (attrs.DRMBufferUseMESA & EGL_DRM_BUFFER_USE_SHARE_MESA)
templ.bind |= PIPE_BIND_SHARED;
+ if (attrs.DRMBufferUseMESA & EGL_DRM_BUFFER_USE_CURSOR_MESA) {
+ if (attrs.Width != 64 || attrs.Height != 64)
+ return NULL;
+ templ.bind |= PIPE_BIND_CURSOR;
+ }
return screen->resource_create(screen, &templ);
}
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c b/src/gallium/state_trackers/egl/wayland/native_wayland.c
index e7ed9d64b7e..0292d5631d6 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.c
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c
@@ -61,31 +61,35 @@ wayland_display_get_configs (struct native_display *ndpy, int *num_configs)
{
struct wayland_display *display = wayland_display(ndpy);
const struct native_config **configs;
+ int i;
if (!display->config) {
struct native_config *nconf;
- enum pipe_format format;
- display->config = CALLOC(1, sizeof(*display->config));
+ display->config = CALLOC(2, sizeof(*display->config));
if (!display->config)
return NULL;
- nconf = &display->config->base;
-
- nconf->buffer_mask =
- (1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
- (1 << NATIVE_ATTACHMENT_BACK_LEFT);
- format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ for (i = 0; i < 2; ++i) {
+ nconf = &display->config[i].base;
+
+ nconf->buffer_mask =
+ (1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
+ (1 << NATIVE_ATTACHMENT_BACK_LEFT);
+
+ nconf->window_bit = TRUE;
+ nconf->pixmap_bit = TRUE;
+ }
- nconf->color_format = format;
- nconf->window_bit = TRUE;
- nconf->pixmap_bit = TRUE;
+ display->config[0].base.color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ display->config[1].base.color_format = PIPE_FORMAT_B8G8R8X8_UNORM;
}
- configs = MALLOC(sizeof(*configs));
+ configs = MALLOC(2 * sizeof(*configs));
if (configs) {
- configs[0] = &display->config->base;
+ configs[0] = &display->config[0].base;
+ configs[1] = &display->config[1].base;
if (num_configs)
- *num_configs = 1;
+ *num_configs = 2;
}
return configs;
@@ -368,9 +372,9 @@ wayland_create_pixmap_surface(struct native_display *ndpy,
surface->type = WL_PIXMAP_SURFACE;
surface->pix = egl_pixmap;
- if (surface->pix->visual == wl_display_get_rgb_visual(display->dpy))
- surface->color_format = PIPE_FORMAT_B8G8R8X8_UNORM;
- else
+ if (nconf)
+ surface->color_format = nconf->color_format;
+ else /* FIXME: derive format from wl_visual */
surface->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
surface->attachment_mask = (1 << NATIVE_ATTACHMENT_FRONT_LEFT);
diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c
index 351267bae4d..6233fb81781 100644
--- a/src/gallium/state_trackers/glx/xlib/glx_api.c
+++ b/src/gallium/state_trackers/glx/xlib/glx_api.c
@@ -1018,15 +1018,18 @@ glXChooseVisual( Display *dpy, int screen, int *list )
}
-PUBLIC GLXContext
-glXCreateContext( Display *dpy, XVisualInfo *visinfo,
- GLXContext share_list, Bool direct )
+/**
+ * Helper function used by other glXCreateContext functions.
+ */
+static GLXContext
+create_context(Display *dpy, XMesaVisual xmvis,
+ XMesaContext shareCtx, Bool direct,
+ unsigned major, unsigned minor,
+ unsigned profileMask, unsigned contextFlags)
{
- XMesaVisual xmvis;
GLXContext glxCtx;
- GLXContext shareCtx = share_list;
- if (!dpy || !visinfo)
+ if (!dpy || !xmvis)
return 0;
glxCtx = CALLOC_STRUCT(__GLXcontextRec);
@@ -1038,19 +1041,8 @@ glXCreateContext( Display *dpy, XVisualInfo *visinfo,
XMesaGarbageCollect();
#endif
- xmvis = find_glx_visual( dpy, visinfo );
- if (!xmvis) {
- /* This visual wasn't found with glXChooseVisual() */
- xmvis = create_glx_visual( dpy, visinfo );
- if (!xmvis) {
- /* unusable visual */
- free(glxCtx);
- return NULL;
- }
- }
-
- glxCtx->xmesaContext = XMesaCreateContext(xmvis,
- shareCtx ? shareCtx->xmesaContext : NULL);
+ glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx, major, minor,
+ profileMask, contextFlags);
if (!glxCtx->xmesaContext) {
free(glxCtx);
return NULL;
@@ -1064,6 +1056,29 @@ glXCreateContext( Display *dpy, XVisualInfo *visinfo,
}
+PUBLIC GLXContext
+glXCreateContext( Display *dpy, XVisualInfo *visinfo,
+ GLXContext shareCtx, Bool direct )
+{
+ XMesaVisual xmvis;
+
+ xmvis = find_glx_visual( dpy, visinfo );
+ if (!xmvis) {
+ /* This visual wasn't found with glXChooseVisual() */
+ xmvis = create_glx_visual( dpy, visinfo );
+ if (!xmvis) {
+ /* unusable visual */
+ return NULL;
+ }
+ }
+
+ return create_context(dpy, xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL,
+ direct,
+ 1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0);
+}
+
+
/* XXX these may have to be removed due to thread-safety issues. */
static GLXContext MakeCurrent_PrevContext = 0;
static GLXDrawable MakeCurrent_PrevDrawable = 0;
@@ -2084,35 +2099,18 @@ glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute,
PUBLIC GLXContext
glXCreateNewContext( Display *dpy, GLXFBConfig config,
- int renderType, GLXContext shareList, Bool direct )
+ int renderType, GLXContext shareCtx, Bool direct )
{
- GLXContext glxCtx;
- GLXContext shareCtx = shareList;
XMesaVisual xmvis = (XMesaVisual) config;
if (!dpy || !config ||
(renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
return 0;
- glxCtx = CALLOC_STRUCT(__GLXcontextRec);
- if (!glxCtx)
- return 0;
-
- /* deallocate unused windows/buffers */
- XMesaGarbageCollect();
-
- glxCtx->xmesaContext = XMesaCreateContext(xmvis,
- shareCtx ? shareCtx->xmesaContext : NULL);
- if (!glxCtx->xmesaContext) {
- free(glxCtx);
- return NULL;
- }
-
- glxCtx->isDirect = DEFAULT_DIRECT;
- glxCtx->currentDpy = dpy;
- glxCtx->xid = (XID) glxCtx; /* self pointer */
-
- return glxCtx;
+ return create_context(dpy, xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL,
+ direct,
+ 1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0);
}
@@ -2315,32 +2313,19 @@ glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config,
PUBLIC GLXContext
glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config,
- int render_type, GLXContext share_list,
+ int renderType, GLXContext shareCtx,
Bool direct)
{
XMesaVisual xmvis = (XMesaVisual) config;
- GLXContext glxCtx;
- GLXContext shareCtx = share_list;
- glxCtx = CALLOC_STRUCT(__GLXcontextRec);
- if (!glxCtx)
+ if (!dpy || !config ||
+ (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
return 0;
- /* deallocate unused windows/buffers */
- XMesaGarbageCollect();
-
- glxCtx->xmesaContext = XMesaCreateContext(xmvis,
- shareCtx ? shareCtx->xmesaContext : NULL);
- if (!glxCtx->xmesaContext) {
- free(glxCtx);
- return NULL;
- }
-
- glxCtx->isDirect = DEFAULT_DIRECT;
- glxCtx->currentDpy = dpy;
- glxCtx->xid = (XID) glxCtx; /* self pointer */
-
- return glxCtx;
+ return create_context(dpy, xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL,
+ direct,
+ 1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0);
}
@@ -2654,3 +2639,98 @@ glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer)
if (b)
XMesaReleaseTexImage(dpy, b, buffer);
}
+
+
+
+/*** GLX_ARB_create_context ***/
+
+GLXContext
+glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
+ GLXContext shareCtx, Bool direct,
+ const int *attrib_list)
+{
+ XMesaVisual xmvis = (XMesaVisual) config;
+ int majorVersion = 1, minorVersion = 0;
+ int contextFlags = 0x0;
+ int profileMask = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
+ int renderType = GLX_RGBA_TYPE;
+ unsigned i;
+ Bool done = False;
+ const int contextFlagsAll = (GLX_CONTEXT_DEBUG_BIT_ARB |
+ GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB);
+
+ /* parse attrib_list */
+ for (i = 0; !done && attrib_list[i]; i++) {
+ switch (attrib_list[i]) {
+ case GLX_CONTEXT_MAJOR_VERSION_ARB:
+ majorVersion = attrib_list[++i];
+ break;
+ case GLX_CONTEXT_MINOR_VERSION_ARB:
+ minorVersion = attrib_list[++i];
+ break;
+ case GLX_CONTEXT_FLAGS_ARB:
+ contextFlags = attrib_list[++i];
+ break;
+ case GLX_CONTEXT_PROFILE_MASK_ARB:
+ profileMask = attrib_list[++i];
+ break;
+ case GLX_RENDER_TYPE:
+ renderType = attrib_list[++i];
+ break;
+ case 0:
+ /* end of list */
+ done = True;
+ break;
+ default:
+ /* bad attribute */
+ /* XXX generate BadValue X Error */
+ return NULL;
+ }
+ }
+
+ /* check contextFlags */
+ if (contextFlags & ~contextFlagsAll) {
+ return NULL; /* generate BadValue X Error */
+ }
+
+ /* check profileMask */
+ if (profileMask != GLX_CONTEXT_CORE_PROFILE_BIT_ARB &&
+ profileMask != GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) {
+ return NULL; /* generate BadValue X Error */
+ }
+
+ /* check version (generate BadMatch if bad) */
+ switch (majorVersion) {
+ case 1:
+ if (minorVersion < 0 || minorVersion > 5)
+ return NULL;
+ break;
+ case 2:
+ if (minorVersion < 0 || minorVersion > 1)
+ return NULL;
+ break;
+ case 3:
+ if (minorVersion < 0 || minorVersion > 2)
+ return NULL;
+ break;
+ case 4:
+ if (minorVersion < 0 || minorVersion > 0)
+ return NULL;
+ break;
+ default:
+ return NULL;
+ }
+
+ if ((contextFlags & GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) &&
+ majorVersion < 3)
+ return NULL; /* generate GLXBadProfileARB */
+
+ if (renderType == GLX_COLOR_INDEX_TYPE && majorVersion >= 3)
+ return NULL; /* generate BadMatch */
+
+ return create_context(dpy, xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL,
+ direct,
+ majorVersion, minorVersion,
+ profileMask, contextFlags);
+}
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 3b35cbc890c..ab4f6753e11 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -853,7 +853,9 @@ xmesa_init( Display *display )
* \return an XMesaContext or NULL if error.
*/
PUBLIC
-XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
+XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list,
+ GLuint major, GLuint minor,
+ GLuint profileMask, GLuint contextFlags)
{
XMesaDisplay xmdpy = xmesa_init_display(v->display);
struct st_context_attribs attribs;
@@ -874,6 +876,18 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
memset(&attribs, 0, sizeof(attribs));
attribs.profile = ST_PROFILE_DEFAULT;
attribs.visual = v->stvis;
+ attribs.major = major;
+ attribs.minor = minor;
+ if (contextFlags & GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
+ if (contextFlags & GLX_CONTEXT_DEBUG_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
+ if (contextFlags & GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS;
+ if (profileMask & GLX_CONTEXT_CORE_PROFILE_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_CORE_PROFILE;
+ if (profileMask & GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_COMPATIBLE_PROFILE;
c->st = stapi->create_context(stapi, xmdpy->smapi,
&attribs, (share_list) ? share_list->st : NULL);
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h
index 4ea42dc3755..57571fe2d13 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.h
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.h
@@ -140,7 +140,10 @@ extern void XMesaDestroyVisual( XMesaVisual v );
* Return: an XMesaContext or NULL if error.
*/
extern XMesaContext XMesaCreateContext( XMesaVisual v,
- XMesaContext share_list );
+ XMesaContext share_list,
+ GLuint major, GLuint minor,
+ GLuint profileMask,
+ GLuint contextFlags);
/*