summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/egl/common/egl_g3d_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/egl/common/egl_g3d_api.c')
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_api.c87
1 files changed, 24 insertions, 63 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
index 8e53e1dccb..f1568329ec 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
@@ -158,17 +158,17 @@ egl_g3d_choose_config(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attribs,
(_EGLArrayForEach) egl_g3d_match_config, (void *) &criteria);
/* perform sorting of configs */
- if (tmp_configs && tmp_size) {
+ if (configs && tmp_size) {
_eglSortConfigs((const _EGLConfig **) tmp_configs, tmp_size,
egl_g3d_compare_config, (void *) &criteria);
- size = MIN2(tmp_size, size);
- for (i = 0; i < size; i++)
+ tmp_size = MIN2(tmp_size, size);
+ for (i = 0; i < tmp_size; i++)
configs[i] = _eglGetConfigHandle(tmp_configs[i]);
}
FREE(tmp_configs);
- *num_configs = size;
+ *num_configs = tmp_size;
return EGL_TRUE;
}
@@ -324,7 +324,8 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
}
gsurf->stvis = gconf->stvis;
- if (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER)
+ if (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER &&
+ gconf->stvis.buffer_mask & ST_ATTACHMENT_FRONT_LEFT_MASK)
gsurf->stvis.render_buffer = ST_ATTACHMENT_FRONT_LEFT;
gsurf->stfbi = egl_g3d_create_st_framebuffer(&gsurf->base);
@@ -402,7 +403,6 @@ egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLConfig *conf, const EGLint *attribs)
{
struct egl_g3d_surface *gsurf;
- struct pipe_resource *ptex = NULL;
gsurf = create_pbuffer_surface(dpy, conf, attribs,
"eglCreatePbufferSurface");
@@ -411,13 +411,6 @@ egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy,
gsurf->client_buffer_type = EGL_NONE;
- if (!gsurf->stfbi->validate(gsurf->stfbi,
- &gsurf->stvis.render_buffer, 1, &ptex)) {
- egl_g3d_destroy_st_framebuffer(gsurf->stfbi);
- FREE(gsurf);
- return NULL;
- }
-
return &gsurf->base;
}
@@ -477,12 +470,14 @@ egl_g3d_create_pbuffer_from_client_buffer(_EGLDriver *drv, _EGLDisplay *dpy,
gsurf->client_buffer_type = buftype;
gsurf->client_buffer = buffer;
+ /* validate now so that it fails if the client buffer is invalid */
if (!gsurf->stfbi->validate(gsurf->stfbi,
&gsurf->stvis.render_buffer, 1, &ptex)) {
egl_g3d_destroy_st_framebuffer(gsurf->stfbi);
FREE(gsurf);
return NULL;
}
+ pipe_resource_reference(&ptex, NULL);
return &gsurf->base;
}
@@ -533,8 +528,7 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy,
old_gctx = egl_g3d_context(old_ctx);
if (old_gctx) {
/* flush old context */
- old_gctx->stctxi->flush(old_gctx->stctxi,
- PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
+ old_gctx->stctxi->flush(old_gctx->stctxi, ST_FLUSH_FRONT, NULL);
}
if (gctx) {
@@ -611,8 +605,7 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
/* flush if the surface is current */
if (gctx) {
- gctx->stctxi->flush(gctx->stctxi,
- PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
+ gctx->stctxi->flush(gctx->stctxi, ST_FLUSH_FRONT, NULL);
}
return gsurf->native->present(gsurf->native,
@@ -643,47 +636,36 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
_EGLContext *ctx = _eglGetCurrentContext();
- struct egl_g3d_config *gconf;
struct native_surface *nsurf;
struct pipe_resource *ptex;
+ struct pipe_context *pipe;
if (!gsurf->render_texture)
return EGL_TRUE;
- gconf = egl_g3d_config(egl_g3d_find_pixmap_config(dpy, target));
- if (!gconf)
- return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers");
-
- nsurf = gdpy->native->create_pixmap_surface(gdpy->native,
- target, gconf->native);
+ nsurf = gdpy->native->create_pixmap_surface(gdpy->native, target, NULL);
if (!nsurf)
return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers");
/* flush if the surface is current */
if (ctx && ctx->DrawSurface == &gsurf->base) {
struct egl_g3d_context *gctx = egl_g3d_context(ctx);
- gctx->stctxi->flush(gctx->stctxi,
- PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
+ gctx->stctxi->flush(gctx->stctxi, ST_FLUSH_FRONT, NULL);
}
- /* create a pipe context to copy surfaces */
- if (!gdpy->pipe) {
- gdpy->pipe =
- gdpy->native->screen->context_create(gdpy->native->screen, NULL);
- if (!gdpy->pipe)
- return EGL_FALSE;
- }
+ pipe = ndpy_get_copy_context(gdpy->native);
+ if (!pipe)
+ return EGL_FALSE;
ptex = get_pipe_resource(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT);
if (ptex) {
- struct pipe_resource *psrc = gsurf->render_texture;
struct pipe_box src_box;
+
u_box_origin_2d(ptex->width0, ptex->height0, &src_box);
- if (psrc) {
- gdpy->pipe->resource_copy_region(gdpy->pipe, ptex, 0, 0, 0, 0,
- gsurf->render_texture, 0, &src_box);
- nsurf->present(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT, FALSE, 0);
- }
+ pipe->resource_copy_region(pipe, ptex, 0, 0, 0, 0,
+ gsurf->render_texture, 0, &src_box);
+ pipe->flush(pipe, NULL);
+ nsurf->present(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT, FALSE, 0);
pipe_resource_reference(&ptex, NULL);
}
@@ -701,10 +683,9 @@ egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
struct pipe_screen *screen = gdpy->native->screen;
struct pipe_fence_handle *fence = NULL;
- gctx->stctxi->flush(gctx->stctxi,
- PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
+ gctx->stctxi->flush(gctx->stctxi, ST_FLUSH_FRONT, &fence);
if (fence) {
- screen->fence_finish(screen, fence, 0);
+ screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE);
screen->fence_reference(screen, &fence, NULL);
}
@@ -773,8 +754,7 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy,
/* flush properly if the surface is bound */
if (gsurf->base.CurrentContext) {
gctx = egl_g3d_context(gsurf->base.CurrentContext);
- gctx->stctxi->flush(gctx->stctxi,
- PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
+ gctx->stctxi->flush(gctx->stctxi, ST_FLUSH_FRONT, NULL);
}
gctx = egl_g3d_context(es1);
@@ -888,25 +868,6 @@ egl_g3d_show_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy,
#endif /* EGL_MESA_screen_surface */
-/**
- * Find a config that supports the pixmap.
- */
-_EGLConfig *
-egl_g3d_find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix)
-{
- struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
- struct egl_g3d_config *gconf;
- EGLint i;
-
- for (i = 0; i < dpy->Configs->Size; i++) {
- gconf = egl_g3d_config((_EGLConfig *) dpy->Configs->Elements[i]);
- if (gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native))
- break;
- }
-
- return (i < dpy->Configs->Size) ? &gconf->base : NULL;
-}
-
void
egl_g3d_init_driver_api(_EGLDriver *drv)
{