diff options
Diffstat (limited to 'src/gallium/state_trackers')
50 files changed, 715 insertions, 371 deletions
diff --git a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp index e1c34611d1..c246fc5ef7 100644 --- a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp +++ b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp @@ -1101,6 +1101,7 @@ struct GalliumDXGISwapChain : public GalliumDXGIObject<IDXGISwapChain, GalliumDX struct pipe_resource* dst; struct pipe_resource* src; struct pipe_surface* dst_surface; + enum native_attachment att; void* present_cookie; hr = parent->backend->BeginPresent(desc.OutputWindow, &present_cookie, &cur_window, &rect, &rgndata, &preserve_aspect_ratio); @@ -1221,16 +1222,9 @@ struct GalliumDXGISwapChain : public GalliumDXGIObject<IDXGISwapChain, GalliumDX pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, 0); - if(db) - { - if(!surface->swap_buffers(surface)) - return DXGI_ERROR_DEVICE_REMOVED; - } - else - { - if(!surface->flush_frontbuffer(surface)) - return DXGI_ERROR_DEVICE_REMOVED; - } + att = (db) ? NATIVE_ATTACHMENT_BACK_LEFT : NATIVE_ATTACHMENT_FRONT_LEFT; + if(!surface->present(surface, att, FALSE, 0)) + return DXGI_ERROR_DEVICE_REMOVED; end_present: parent->backend->EndPresent(desc.OutputWindow, present_cookie); diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript index aba60fb8c5..7702d8e632 100644 --- a/src/gallium/state_trackers/dri/SConscript +++ b/src/gallium/state_trackers/dri/SConscript @@ -1,6 +1,6 @@ Import('*') SConscript([ - 'sw/SConscript', - 'drm/SConscript', + 'sw/SConscript', + 'drm/SConscript', ]) diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c index 770b37037f..3d5d24e692 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.c +++ b/src/gallium/state_trackers/dri/common/dri_context.c @@ -178,7 +178,8 @@ dri_make_current(__DRIcontext * cPriv, read->texture_stamp = driReadPriv->lastStamp - 1; } - ctx->stapi->make_current(ctx->stapi, ctx->st, &draw->base, &read->base); + ctx->stapi->make_current(ctx->stapi, ctx->st, + (draw) ? &draw->base : NULL, (read) ? &read->base : NULL); return GL_TRUE; } diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h index 837d398374..2ff6b71329 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.h +++ b/src/gallium/state_trackers/dri/common/dri_drawable.h @@ -70,7 +70,8 @@ struct dri_drawable static INLINE struct dri_drawable * dri_drawable(__DRIdrawable * driDrawPriv) { - return (struct dri_drawable *)driDrawPriv->driverPrivate; + return (struct dri_drawable *) (driDrawPriv) + ? driDrawPriv->driverPrivate : NULL; } /*********************************************************************** diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 252ad1768d..1302e9bc01 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -231,6 +231,9 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, { memset(stvis, 0, sizeof(*stvis)); + if (!mode) + return; + stvis->samples = mode->samples; stvis->render_buffer = ST_ATTACHMENT_INVALID; diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript index 2a0af65f9b..b188f76f91 100644 --- a/src/gallium/state_trackers/dri/drm/SConscript +++ b/src/gallium/state_trackers/dri/drm/SConscript @@ -3,25 +3,26 @@ Import('*') -if env['dri']: +env = env.Clone() - env = env.Clone() +env.ParseConfig('pkg-config --cflags --libs libdrm') - env.ParseConfig('pkg-config --cflags --libs libdrm') +env.Append(CPPPATH = [ + '#/src/mapi', + '#/src/mesa', + '#/src/gallium/state_trackers/dri/common', + '#/src/mesa/drivers/dri/common', +]) - env.Append(CPPPATH = [ - '#/src/mapi', - '#/src/mesa', - '#/src/gallium/state_trackers/dri/common', - '#/src/mesa/drivers/dri/common', - ]) +sources = [ + 'dri_context.c', + 'dri_drawable.c', + 'dri_screen.c', + 'dri2.c', +] - st_dri = env.ConvenienceLibrary( - target = 'st_dri', - source = [ 'dri_context.c', - 'dri_drawable.c', - 'dri_screen.c', - 'dri2.c', - ] - ) - Export('st_dri') +st_dri = env.ConvenienceLibrary( + target = 'st_dri', + source = sources, +) +Export('st_dri') diff --git a/src/gallium/state_trackers/dri/sw/SConscript b/src/gallium/state_trackers/dri/sw/SConscript index d2eb66668e..d0c3efc6fa 100644 --- a/src/gallium/state_trackers/dri/sw/SConscript +++ b/src/gallium/state_trackers/dri/sw/SConscript @@ -3,25 +3,26 @@ Import('*') -if env['dri']: +env = env.Clone() - env = env.Clone() +env.Append(CPPPATH = [ + '#/src/mapi', + '#/src/mesa', + '#/src/gallium/state_trackers/dri/common', + '#/src/mesa/drivers/dri/common', +]) - env.Append(CPPPATH = [ - '#/src/mapi', - '#/src/mesa', - '#/src/gallium/state_trackers/dri/common', - '#/src/mesa/drivers/dri/common', - ]) +env.Append(CPPDEFINES = [('__NOT_HAVE_DRM_H', '1')]) - env.Append(CPPDEFINES = [('__NOT_HAVE_DRM_H', '1')]) +sources = [ + 'dri_context.c', + 'dri_drawable.c', + 'dri_screen.c', + 'drisw.c', +] - st_drisw = env.ConvenienceLibrary( - target = 'st_drisw', - source = [ 'dri_context.c', - 'dri_drawable.c', - 'dri_screen.c', - 'drisw.c', - ] - ) - Export('st_drisw') +st_drisw = env.ConvenienceLibrary( + target = 'st_drisw', + source = sources, +) +Export('st_drisw') diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile index 8dbfc5b8e5..8cfcef968e 100644 --- a/src/gallium/state_trackers/egl/Makefile +++ b/src/gallium/state_trackers/egl/Makefile @@ -17,7 +17,7 @@ x11_INCLUDES = \ -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ $(X11_CFLAGS) \ - $(shell pkg-config --cflags-only-I libdrm) + $(shell pkg-config --cflags-only-I libdrm dri2proto) x11_SOURCES = $(wildcard x11/*.c) \ $(TOP)/src/glx/dri2.c diff --git a/src/gallium/state_trackers/egl/SConscript b/src/gallium/state_trackers/egl/SConscript index efcce25e31..50c7681995 100644 --- a/src/gallium/state_trackers/egl/SConscript +++ b/src/gallium/state_trackers/egl/SConscript @@ -3,34 +3,32 @@ Import('*') -if 'egl' in env['statetrackers']: +env = env.Clone() - env = env.Clone() +env.Append(CPPPATH = [ + '#/src/egl/main', + '#/src/gallium/winsys/sw', + '.', +]) +env.Append(CPPDEFINES = [ + 'HAVE_GDI_BACKEND', +]) - env.Append(CPPPATH = [ - '#/src/egl/main', - '#/src/gallium/winsys/sw', - '.', - ]) - env.Append(CPPDEFINES = [ - 'HAVE_GDI_BACKEND', - ]) +common_sources = [ + 'common/egl_g3d.c', + 'common/egl_g3d_api.c', + 'common/egl_g3d_image.c', + 'common/egl_g3d_st.c', + 'common/egl_g3d_sync.c', + 'common/native_helper.c', +] - common_sources = [ - 'common/egl_g3d.c', - 'common/egl_g3d_api.c', - 'common/egl_g3d_image.c', - 'common/egl_g3d_st.c', - 'common/egl_g3d_sync.c', - 'common/native_helper.c', - ] +gdi_sources = common_sources + [ + 'gdi/native_gdi.c', +] - gdi_sources = common_sources + [ - 'gdi/native_gdi.c', - ] - - st_egl_gdi = env.ConvenienceLibrary( - target = 'st_egl_gdi', - source = gdi_sources, - ) - Export('st_egl_gdi') +st_egl_gdi = env.ConvenienceLibrary( + target = 'st_egl_gdi', + source = gdi_sources, +) +Export('st_egl_gdi') diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index aaa2ff6bb2..a3750ac56f 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -126,24 +126,24 @@ egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy) continue; } - _eglInitScreen(&gscr->base); - - for (j = 0; j < num_modes; j++) { + _eglInitScreen(&gscr->base, dpy, num_modes); + for (j = 0; j < gscr->base.NumModes; j++) { const struct native_mode *nmode = native_modes[j]; - _EGLMode *mode; - - mode = _eglAddNewMode(&gscr->base, nmode->width, nmode->height, - nmode->refresh_rate, nmode->desc); - if (!mode) - break; - /* gscr->native_modes and gscr->base.Modes should be consistent */ - assert(mode == &gscr->base.Modes[j]); + _EGLMode *mode = &gscr->base.Modes[j]; + + mode->Width = nmode->width; + mode->Height = nmode->height; + mode->RefreshRate = nmode->refresh_rate; + mode->Optimal = EGL_FALSE; + mode->Interlaced = EGL_FALSE; + /* no need to strdup() */ + mode->Name = nmode->desc; } gscr->native = nconn; gscr->native_modes = native_modes; - _eglAddScreen(dpy, &gscr->base); + _eglLinkScreen(&gscr->base); } FREE(native_connectors); @@ -156,7 +156,8 @@ egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy) */ static EGLBoolean init_config_attributes(_EGLConfig *conf, const struct native_config *nconf, - EGLint api_mask, enum pipe_format depth_stencil_format) + EGLint api_mask, enum pipe_format depth_stencil_format, + EGLBoolean preserve_buffer, EGLint max_swap_interval) { uint rgba[4], depth_stencil[2], buffer_size; EGLint surface_type; @@ -238,6 +239,11 @@ init_config_attributes(_EGLConfig *conf, const struct native_config *nconf, conf->TransparentBlueValue = nconf->transparent_rgb_values[2]; } + conf->MinSwapInterval = 0; + conf->MaxSwapInterval = max_swap_interval; + if (preserve_buffer) + conf->SurfaceType |= EGL_SWAP_BEHAVIOR_PRESERVED_BIT; + return _eglValidateConfig(conf, EGL_FALSE); } @@ -247,7 +253,8 @@ init_config_attributes(_EGLConfig *conf, const struct native_config *nconf, static EGLBoolean egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const struct native_config *nconf, - enum pipe_format depth_stencil_format) + enum pipe_format depth_stencil_format, + int preserve_buffer, int max_swap_interval) { struct egl_g3d_config *gconf = egl_g3d_config(conf); EGLint buffer_mask, api_mask; @@ -288,7 +295,8 @@ egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy, } valid = init_config_attributes(&gconf->base, - nconf, api_mask, depth_stencil_format); + nconf, api_mask, depth_stencil_format, + preserve_buffer, max_swap_interval); if (!valid) { _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", nconf->native_visual_id); return EGL_FALSE; @@ -349,6 +357,7 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) const struct native_config **native_configs; enum pipe_format depth_stencil_formats[8]; int num_formats, num_configs, i, j; + int preserve_buffer, max_swap_interval; native_configs = gdpy->native->get_configs(gdpy->native, &num_configs); if (!num_configs) { @@ -357,6 +366,11 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) return id; } + preserve_buffer = + gdpy->native->get_param(gdpy->native, NATIVE_PARAM_PRESERVE_BUFFER); + max_swap_interval = + gdpy->native->get_param(gdpy->native, NATIVE_PARAM_MAX_SWAP_INTERVAL); + num_formats = egl_g3d_fill_depth_stencil_formats(dpy, depth_stencil_formats); @@ -368,12 +382,13 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) if (gconf) { _eglInitConfig(&gconf->base, dpy, id); if (!egl_g3d_init_config(drv, dpy, &gconf->base, - native_configs[i], depth_stencil_formats[j])) { + native_configs[i], depth_stencil_formats[j], + preserve_buffer, max_swap_interval)) { FREE(gconf); break; } - _eglAddConfig(dpy, &gconf->base); + _eglLinkConfig(&gconf->base); id++; } } @@ -538,7 +553,8 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, if (dpy->Platform == _EGL_PLATFORM_DRM) { dpy->Extensions.MESA_drm_display = EGL_TRUE; - dpy->Extensions.MESA_drm_image = EGL_TRUE; + if (gdpy->native->buffer) + dpy->Extensions.MESA_drm_image = EGL_TRUE; } if (egl_g3d_add_configs(drv, dpy, 1) == 1) { diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h index be450bbede..72c14f0ac4 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.h +++ b/src/gallium/state_trackers/egl/common/egl_g3d.h @@ -106,8 +106,6 @@ _EGL_DRIVER_TYPECAST(egl_g3d_image, _EGLImage, obj) struct egl_g3d_sync { _EGLSync base; - int refs; - /* the mutex protects only the condvar, not the struct */ pipe_mutex mutex; pipe_condvar condvar; 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 3bde39737b..fd7dc8f814 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c @@ -97,6 +97,70 @@ egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx, return stapi; } +static int +egl_g3d_compare_config(const _EGLConfig *conf1, const _EGLConfig *conf2, + void *priv_data) +{ + const _EGLConfig *criteria = (const _EGLConfig *) priv_data; + + /* EGL_NATIVE_VISUAL_TYPE ignored? */ + return _eglCompareConfigs(conf1, conf2, criteria, EGL_TRUE); +} + +static EGLBoolean +egl_g3d_match_config(const _EGLConfig *conf, const _EGLConfig *criteria) +{ + if (!_eglMatchConfig(conf, criteria)) + return EGL_FALSE; + + if (criteria->MatchNativePixmap != EGL_NONE && + criteria->MatchNativePixmap != EGL_DONT_CARE) { + struct egl_g3d_display *gdpy = egl_g3d_display(conf->Display); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + EGLNativePixmapType pix = + (EGLNativePixmapType) criteria->MatchNativePixmap; + + if (!gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native)) + return EGL_FALSE; + } + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_choose_config(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attribs, + EGLConfig *configs, EGLint size, EGLint *num_configs) +{ + _EGLConfig **tmp_configs, criteria; + EGLint tmp_size, i; + + if (!num_configs) + return _eglError(EGL_BAD_PARAMETER, "eglChooseConfigs"); + + if (!_eglParseConfigAttribList(&criteria, dpy, attribs)) + return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig"); + + tmp_configs = (_EGLConfig **) _eglFilterArray(dpy->Configs, &tmp_size, + (_EGLArrayForEach) egl_g3d_match_config, (void *) &criteria); + if (!tmp_configs) + return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)"); + + /* perform sorting of configs */ + if (tmp_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++) + configs[i] = _eglGetConfigHandle(tmp_configs[i]); + } + + free(tmp_configs); + + *num_configs = size; + + return EGL_TRUE; +} + static _EGLContext * egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share, const EGLint *attribs) @@ -160,7 +224,7 @@ destroy_context(_EGLDisplay *dpy, _EGLContext *ctx) static EGLBoolean egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) { - if (!_eglIsContextBound(ctx)) + if (_eglPutContext(ctx)) destroy_context(dpy, ctx); return EGL_TRUE; } @@ -433,7 +497,7 @@ destroy_surface(_EGLDisplay *dpy, _EGLSurface *surf) static EGLBoolean egl_g3d_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) { - if (!_eglIsSurfaceBound(surf)) + if (_eglPutSurface(surf)) destroy_surface(dpy, surf); return EGL_TRUE; } @@ -446,13 +510,15 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, struct egl_g3d_surface *gdraw = egl_g3d_surface(draw); struct egl_g3d_surface *gread = egl_g3d_surface(read); struct egl_g3d_context *old_gctx; + _EGLContext *old_ctx; + _EGLSurface *old_draw, *old_read; EGLBoolean ok = EGL_TRUE; - /* bind the new context and return the "orphaned" one */ - if (!_eglBindContext(&ctx, &draw, &read)) + /* make new bindings */ + if (!_eglBindContext(ctx, draw, read, &old_ctx, &old_draw, &old_read)) return EGL_FALSE; - old_gctx = egl_g3d_context(ctx); + old_gctx = egl_g3d_context(old_ctx); if (old_gctx) { /* flush old context */ old_gctx->stctxi->flush(old_gctx->stctxi, @@ -481,15 +547,33 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, } else if (old_gctx) { ok = old_gctx->stapi->make_current(old_gctx->stapi, NULL, NULL, NULL); - old_gctx->base.WindowRenderBuffer = EGL_NONE; + if (ok) + old_gctx->base.WindowRenderBuffer = EGL_NONE; } - if (ctx && !_eglIsContextLinked(ctx)) - destroy_context(dpy, ctx); - if (draw && !_eglIsSurfaceLinked(draw)) - destroy_surface(dpy, draw); - if (read && read != draw && !_eglIsSurfaceLinked(read)) - destroy_surface(dpy, read); + if (ok) { + if (_eglPutContext(old_ctx)) + destroy_context(dpy, old_ctx); + if (_eglPutSurface(old_draw)) + destroy_surface(dpy, old_draw); + if (_eglPutSurface(old_read)) + destroy_surface(dpy, old_read); + } + else { + /* undo the previous _eglBindContext */ + _eglBindContext(old_ctx, old_draw, old_read, &ctx, &draw, &read); + assert(&gctx->base == ctx && + &gdraw->base == draw && + &gread->base == read); + + _eglPutSurface(draw); + _eglPutSurface(read); + _eglPutContext(ctx); + + _eglPutSurface(old_draw); + _eglPutSurface(old_read); + _eglPutContext(old_ctx); + } return ok; } @@ -519,7 +603,10 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); } - return gsurf->native->swap_buffers(gsurf->native); + return gsurf->native->present(gsurf->native, + NATIVE_ATTACHMENT_BACK_LEFT, + gsurf->base.SwapBehavior == EGL_BUFFER_PRESERVED, + gsurf->base.SwapInterval); } /** @@ -587,8 +674,7 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, if (psrc) { gdpy->pipe->resource_copy_region(gdpy->pipe, ptex, subdst, 0, 0, 0, gsurf->render_texture, subsrc, 0, 0, 0, ptex->width0, ptex->height0); - - nsurf->flush_frontbuffer(nsurf); + nsurf->present(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT, FALSE, 0); } pipe_resource_reference(&ptex, NULL); @@ -818,6 +904,8 @@ egl_g3d_init_driver_api(_EGLDriver *drv) { _eglInitDriverFallbacks(drv); + drv->API.ChooseConfig = egl_g3d_choose_config; + drv->API.CreateContext = egl_g3d_create_context; drv->API.DestroyContext = egl_g3d_destroy_context; drv->API.CreateWindowSurface = egl_g3d_create_window_surface; 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 be9c88e5e4..6a1f8cc697 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_image.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.c @@ -38,7 +38,7 @@ #include "egl_g3d_api.h" #include "egl_g3d_image.h" -/* move this to native display? */ +/* for struct winsys_handle */ #include "state_tracker/drm_driver.h" /** @@ -137,13 +137,11 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name, _EGLImage *img, const EGLint *attribs) { struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct pipe_screen *screen = gdpy->native->screen; struct pipe_resource templ; struct winsys_handle wsh; _EGLImageAttribs attrs; EGLint format; - /* winsys_handle is in theory platform-specific */ if (dpy->Platform != _EGL_PLATFORM_DRM) return NULL; @@ -178,9 +176,10 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name, memset(&wsh, 0, sizeof(wsh)); wsh.handle = (unsigned) name; - wsh.stride = attrs.DRMBufferStrideMESA; + wsh.stride = + attrs.DRMBufferStrideMESA * util_format_get_blocksize(templ.format); - return screen->resource_from_handle(screen, &templ, &wsh); + return gdpy->native->buffer->import_buffer(gdpy->native, &templ, &wsh); } #endif /* EGL_MESA_drm_image */ @@ -302,10 +301,8 @@ egl_g3d_export_drm_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img, { struct egl_g3d_display *gdpy = egl_g3d_display(dpy); struct egl_g3d_image *gimg = egl_g3d_image(img); - struct pipe_screen *screen = gdpy->native->screen; struct winsys_handle wsh; - /* winsys_handle is in theory platform-specific */ if (dpy->Platform != _EGL_PLATFORM_DRM) return EGL_FALSE; @@ -313,9 +310,9 @@ egl_g3d_export_drm_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img, if (name) { memset(&handle, 0, sizeof(handle)); wsh.type = DRM_API_HANDLE_TYPE_SHARED; - if (!screen->resource_get_handle(screen, gimg->texture, &wsh)) { + if (!gdpy->native->buffer->export_buffer(gdpy->native, + gimg->texture, &wsh)) return EGL_FALSE; - } *name = wsh.handle; } @@ -324,7 +321,8 @@ egl_g3d_export_drm_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img, if (handle || stride) { memset(&wsh, 0, sizeof(wsh)); wsh.type = DRM_API_HANDLE_TYPE_KMS; - if (!screen->resource_get_handle(screen, gimg->texture, &wsh)) + if (!gdpy->native->buffer->export_buffer(gdpy->native, + gimg->texture, &wsh)) return EGL_FALSE; if (handle) diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c index 0affe632cf..25e2999590 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c @@ -192,7 +192,8 @@ egl_g3d_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, _EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private; struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - return gsurf->native->flush_frontbuffer(gsurf->native); + return gsurf->native->present(gsurf->native, + NATIVE_ATTACHMENT_FRONT_LEFT, FALSE, 0); } static boolean diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_sync.c b/src/gallium/state_trackers/egl/common/egl_g3d_sync.c index ec74e9eb94..4e6d944c15 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_sync.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_sync.c @@ -128,13 +128,13 @@ egl_g3d_wait_fence_sync(struct egl_g3d_sync *gsync, EGLTimeKHR timeout) static INLINE void egl_g3d_ref_sync(struct egl_g3d_sync *gsync) { - p_atomic_inc(&gsync->refs); + _eglGetSync(&gsync->base); } static INLINE void egl_g3d_unref_sync(struct egl_g3d_sync *gsync) { - if (p_atomic_dec_zero(&gsync->refs)) { + if (_eglPutSync(&gsync->base)) { pipe_condvar_destroy(gsync->condvar); pipe_mutex_destroy(gsync->mutex); @@ -194,7 +194,6 @@ egl_g3d_create_sync(_EGLDriver *drv, _EGLDisplay *dpy, pipe_mutex_init(gsync->mutex); pipe_condvar_init(gsync->condvar); - p_atomic_set(&gsync->refs, 1); return &gsync->base; } diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h index 3c3f57e267..3886ca2056 100644 --- a/src/gallium/state_trackers/egl/common/native.h +++ b/src/gallium/state_trackers/egl/common/native.h @@ -34,6 +34,11 @@ #include "pipe/p_state.h" #include "state_tracker/sw_winsys.h" +#ifdef __cplusplus +extern "C" { +#endif + +#include "native_buffer.h" #include "native_modeset.h" /** @@ -54,7 +59,17 @@ enum native_param_type { * Return TRUE if window/pixmap surfaces use the buffers of the native * types. */ - NATIVE_PARAM_USE_NATIVE_BUFFER + NATIVE_PARAM_USE_NATIVE_BUFFER, + + /** + * Return TRUE if native_surface::present can preserve the buffer. + */ + NATIVE_PARAM_PRESERVE_BUFFER, + + /** + * Return the maximum supported swap interval. + */ + NATIVE_PARAM_MAX_SWAP_INTERVAL }; struct native_surface { @@ -66,17 +81,12 @@ struct native_surface { void (*destroy)(struct native_surface *nsurf); /** - * Swap the front and back buffers so that the back buffer is visible. It - * is no-op if the surface is single-buffered. The contents of the back - * buffer after swapping may or may not be preserved. - */ - boolean (*swap_buffers)(struct native_surface *nsurf); - - /** - * Make the front buffer visible. In some native displays, changes to the - * front buffer might not be visible immediately and require manual flush. + * Present the given buffer to the native engine. */ - boolean (*flush_frontbuffer)(struct native_surface *nsurf); + boolean (*present)(struct native_surface *nsurf, + enum native_attachment natt, + boolean preserve, + uint swap_interval); /** * Validate the buffers of the surface. textures, if not NULL, points to an @@ -181,6 +191,7 @@ struct native_display { EGLNativePixmapType pix, const struct native_config *nconf); + const struct native_display_buffer *buffer; const struct native_display_modeset *modeset; }; @@ -232,4 +243,8 @@ native_get_drm_platform(void); const struct native_platform * native_get_fbdev_platform(void); +#ifdef __cplusplus +} +#endif + #endif /* _NATIVE_H_ */ diff --git a/src/gallium/state_trackers/egl/common/native_buffer.h b/src/gallium/state_trackers/egl/common/native_buffer.h new file mode 100644 index 0000000000..5c29ab9741 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/native_buffer.h @@ -0,0 +1,59 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <olv@lunarg.com> + */ + +#ifndef _NATIVE_BUFFER_H_ +#define _NATIVE_BUFFER_H_ + +#include "pipe/p_compiler.h" + +struct native_display; +struct pipe_resource; + +/** + * Buffer interface of the native display. It allows native buffers to be + * imported and exported. + * + * Just like a native window or a native pixmap, a native buffer is another + * native type. Its definition depends on the native display. + * + * For DRM platform, the type of a native buffer is struct winsys_handle. + */ +struct native_display_buffer { + struct pipe_resource *(*import_buffer)(struct native_display *ndpy, + const struct pipe_resource *templ, + void *buf); + + /** + * The resource must be creatred with PIPE_BIND_SHARED. + */ + boolean (*export_buffer)(struct native_display *ndpy, + struct pipe_resource *res, + void *buf); +}; + +#endif /* _NATIVE_BUFFER_H_ */ diff --git a/src/gallium/state_trackers/egl/common/native_modeset.h b/src/gallium/state_trackers/egl/common/native_modeset.h index dee757b3a8..2598082d68 100644 --- a/src/gallium/state_trackers/egl/common/native_modeset.h +++ b/src/gallium/state_trackers/egl/common/native_modeset.h @@ -39,7 +39,7 @@ struct native_connector { struct native_mode { const char *desc; int width, height; - int refresh_rate; + int refresh_rate; /* HZ * 1000 */ }; /** diff --git a/src/gallium/state_trackers/egl/drm/modeset.c b/src/gallium/state_trackers/egl/drm/modeset.c index 06a6077053..0cc06caa2a 100644 --- a/src/gallium/state_trackers/egl/drm/modeset.c +++ b/src/gallium/state_trackers/egl/drm/modeset.c @@ -167,6 +167,32 @@ drm_surface_swap_buffers(struct native_surface *nsurf) return TRUE; } +static boolean +drm_surface_present(struct native_surface *nsurf, + enum native_attachment natt, + boolean preserve, + uint swap_interval) +{ + boolean ret; + + if (preserve || swap_interval) + return FALSE; + + switch (natt) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + ret = drm_surface_flush_frontbuffer(nsurf); + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + ret = drm_surface_swap_buffers(nsurf); + break; + default: + ret = FALSE; + break; + } + + return ret; +} + static void drm_surface_wait(struct native_surface *nsurf) { @@ -225,8 +251,7 @@ drm_display_create_surface(struct native_display *ndpy, resource_surface_set_size(drmsurf->rsurf, drmsurf->width, drmsurf->height); drmsurf->base.destroy = drm_surface_destroy; - drmsurf->base.swap_buffers = drm_surface_swap_buffers; - drmsurf->base.flush_frontbuffer = drm_surface_flush_frontbuffer; + drmsurf->base.present = drm_surface_present; drmsurf->base.validate = drm_surface_validate; drmsurf->base.wait = drm_surface_wait; @@ -469,8 +494,8 @@ drm_display_get_modes(struct native_display *ndpy, drmmode->base.height = drmmode->mode.vdisplay; drmmode->base.refresh_rate = drmmode->mode.vrefresh; /* not all kernels have vrefresh = refresh_rate * 1000 */ - if (drmmode->base.refresh_rate > 1000) - drmmode->base.refresh_rate = (drmmode->base.refresh_rate + 500) / 1000; + if (drmmode->base.refresh_rate < 1000) + drmmode->base.refresh_rate *= 1000; } nmodes_return = MALLOC(count * sizeof(*nmodes_return)); diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c index f6dc558437..3759c2a26d 100644 --- a/src/gallium/state_trackers/egl/drm/native_drm.c +++ b/src/gallium/state_trackers/egl/drm/native_drm.c @@ -103,6 +103,9 @@ drm_display_get_param(struct native_display *ndpy, int val; switch (param) { + case NATIVE_PARAM_USE_NATIVE_BUFFER: + case NATIVE_PARAM_PRESERVE_BUFFER: + case NATIVE_PARAM_MAX_SWAP_INTERVAL: default: val = 0; break; @@ -182,6 +185,29 @@ drm_display_init_screen(struct native_display *ndpy) return TRUE; } +static struct pipe_resource * +drm_display_import_buffer(struct native_display *ndpy, + const struct pipe_resource *templ, + void *buf) +{ + return ndpy->screen->resource_from_handle(ndpy->screen, + templ, (struct winsys_handle *) buf); +} + +static boolean +drm_display_export_buffer(struct native_display *ndpy, + struct pipe_resource *res, + void *buf) +{ + return ndpy->screen->resource_get_handle(ndpy->screen, + res, (struct winsys_handle *) buf); +} + +static struct native_display_buffer drm_display_buffer = { + drm_display_import_buffer, + drm_display_export_buffer +}; + static struct native_display * drm_create_display(int fd, struct native_event_handler *event_handler, void *user_data) @@ -205,6 +231,7 @@ drm_create_display(int fd, struct native_event_handler *event_handler, drmdpy->base.get_param = drm_display_get_param; drmdpy->base.get_configs = drm_display_get_configs; + drmdpy->base.buffer = &drm_display_buffer; drm_display_init_modeset(&drmdpy->base); return &drmdpy->base; diff --git a/src/gallium/state_trackers/egl/fbdev/native_fbdev.c b/src/gallium/state_trackers/egl/fbdev/native_fbdev.c index e459402076..1b5ea8bf9d 100644 --- a/src/gallium/state_trackers/egl/fbdev/native_fbdev.c +++ b/src/gallium/state_trackers/egl/fbdev/native_fbdev.c @@ -137,6 +137,32 @@ fbdev_surface_swap_buffers(struct native_surface *nsurf) return ret; } +static boolean +fbdev_surface_present(struct native_surface *nsurf, + enum native_attachment natt, + boolean preserve, + uint swap_interval) +{ + boolean ret; + + if (preserve || swap_interval) + return FALSE; + + switch (natt) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + ret = fbdev_surface_flush_frontbuffer(nsurf); + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + ret = fbdev_surface_swap_buffers(nsurf); + break; + default: + ret = FALSE; + break; + } + + return ret; +} + static void fbdev_surface_wait(struct native_surface *nsurf) { @@ -181,8 +207,7 @@ fbdev_display_create_scanout_surface(struct native_display *ndpy, resource_surface_set_size(fbsurf->rsurf, fbsurf->width, fbsurf->height); fbsurf->base.destroy = fbdev_surface_destroy; - fbsurf->base.swap_buffers = fbdev_surface_swap_buffers; - fbsurf->base.flush_frontbuffer = fbdev_surface_flush_frontbuffer; + fbsurf->base.present = fbdev_surface_present; fbsurf->base.validate = fbdev_surface_validate; fbsurf->base.wait = fbdev_surface_wait; @@ -279,6 +304,9 @@ fbdev_display_get_param(struct native_display *ndpy, int val; switch (param) { + case NATIVE_PARAM_USE_NATIVE_BUFFER: + case NATIVE_PARAM_PRESERVE_BUFFER: + case NATIVE_PARAM_MAX_SWAP_INTERVAL: default: val = 0; break; diff --git a/src/gallium/state_trackers/egl/gdi/native_gdi.c b/src/gallium/state_trackers/egl/gdi/native_gdi.c index 91701e5b7d..d259e6edc8 100644 --- a/src/gallium/state_trackers/egl/gdi/native_gdi.c +++ b/src/gallium/state_trackers/egl/gdi/native_gdi.c @@ -160,6 +160,32 @@ gdi_surface_swap_buffers(struct native_surface *nsurf) } static boolean +gdi_surface_present(struct native_surface *nsurf, + enum native_attachment natt, + boolean preserve, + uint swap_interval) +{ + boolean ret; + + if (preserve || swap_interval) + return FALSE; + + switch (natt) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + ret = gdi_surface_flush_frontbuffer(nsurf); + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + ret = gdi_surface_swap_buffers(nsurf); + break; + default: + ret = FALSE; + break; + } + + return ret; +} + +static boolean gdi_surface_validate(struct native_surface *nsurf, uint attachment_mask, unsigned int *seq_num, struct pipe_resource **textures, int *width, int *height) @@ -231,8 +257,7 @@ gdi_display_create_window_surface(struct native_display *ndpy, gdi_surface_update_geometry(&gsurf->base); gsurf->base.destroy = gdi_surface_destroy; - gsurf->base.swap_buffers = gdi_surface_swap_buffers; - gsurf->base.flush_frontbuffer = gdi_surface_flush_frontbuffer; + gsurf->base.present = gdi_surface_present; gsurf->base.validate = gdi_surface_validate; gsurf->base.wait = gdi_surface_wait; @@ -321,6 +346,8 @@ gdi_display_get_param(struct native_display *ndpy, /* private buffers are allocated */ val = FALSE; break; + case NATIVE_PARAM_PRESERVE_BUFFER: + case NATIVE_PARAM_MAX_SWAP_INTERVAL: default: val = 0; break; diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 1169e273c3..331a7de432 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -338,6 +338,32 @@ dri2_surface_swap_buffers(struct native_surface *nsurf) } static boolean +dri2_surface_present(struct native_surface *nsurf, + enum native_attachment natt, + boolean preserve, + uint swap_interval) +{ + boolean ret; + + if (swap_interval) + return FALSE; + + switch (natt) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + ret = dri2_surface_flush_frontbuffer(nsurf); + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + ret = dri2_surface_swap_buffers(nsurf); + break; + default: + ret = FALSE; + break; + } + + return ret; +} + +static boolean dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask, unsigned int *seq_num, struct pipe_resource **textures, int *width, int *height) @@ -430,8 +456,7 @@ dri2_display_create_surface(struct native_display *ndpy, dri2surf->color_format = dri2conf->base.color_format; dri2surf->base.destroy = dri2_surface_destroy; - dri2surf->base.swap_buffers = dri2_surface_swap_buffers; - dri2surf->base.flush_frontbuffer = dri2_surface_flush_frontbuffer; + dri2surf->base.present = dri2_surface_present; dri2surf->base.validate = dri2_surface_validate; dri2surf->base.wait = dri2_surface_wait; @@ -630,9 +655,14 @@ dri2_display_get_param(struct native_display *ndpy, switch (param) { case NATIVE_PARAM_USE_NATIVE_BUFFER: - /* DRI2GetBuffers use the native buffers */ + /* DRI2GetBuffers uses the native buffers */ + val = TRUE; + break; + case NATIVE_PARAM_PRESERVE_BUFFER: + /* DRI2CopyRegion is used */ val = TRUE; break; + case NATIVE_PARAM_MAX_SWAP_INTERVAL: default: val = 0; break; diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h index 0b47837e1b..8945117276 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.h +++ b/src/gallium/state_trackers/egl/x11/native_x11.h @@ -27,6 +27,7 @@ #define _NATIVE_X11_H_ #include "common/native.h" +#include <X11/Xlib.h> struct native_display * x11_create_ximage_display(Display *dpy, diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 4b32f6e36e..84811fb6e1 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -175,6 +175,32 @@ ximage_surface_swap_buffers(struct native_surface *nsurf) } static boolean +ximage_surface_present(struct native_surface *nsurf, + enum native_attachment natt, + boolean preserve, + uint swap_interval) +{ + boolean ret; + + if (preserve || swap_interval) + return FALSE; + + switch (natt) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + ret = ximage_surface_flush_frontbuffer(nsurf); + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + ret = ximage_surface_swap_buffers(nsurf); + break; + default: + ret = FALSE; + break; + } + + return ret; +} + +static boolean ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask, unsigned int *seq_num, struct pipe_resource **textures, int *width, int *height) @@ -257,8 +283,7 @@ ximage_display_create_surface(struct native_display *ndpy, xsurf->xdraw.drawable = xsurf->drawable; xsurf->base.destroy = ximage_surface_destroy; - xsurf->base.swap_buffers = ximage_surface_swap_buffers; - xsurf->base.flush_frontbuffer = ximage_surface_flush_frontbuffer; + xsurf->base.present = ximage_surface_present; xsurf->base.validate = ximage_surface_validate; xsurf->base.wait = ximage_surface_wait; @@ -416,6 +441,8 @@ ximage_display_get_param(struct native_display *ndpy, /* private buffers are allocated */ val = FALSE; break; + case NATIVE_PARAM_PRESERVE_BUFFER: + case NATIVE_PARAM_MAX_SWAP_INTERVAL: default: val = 0; break; diff --git a/src/gallium/state_trackers/glx/xlib/SConscript b/src/gallium/state_trackers/glx/xlib/SConscript index 9df351a276..9e7ebf3fc9 100644 --- a/src/gallium/state_trackers/glx/xlib/SConscript +++ b/src/gallium/state_trackers/glx/xlib/SConscript @@ -3,25 +3,24 @@ Import('*') -if env['platform'] == 'linux' \ - and 'mesa' in env['statetrackers']: +env = env.Clone() - env = env.Clone() +env.Append(CPPPATH = [ + '#/src/mapi', + '#/src/mesa', + '#/src/mesa/main', +]) - env.Append(CPPPATH = [ - '#/src/mapi', - '#/src/mesa', - '#/src/mesa/main', - ]) +sources = [ + 'glx_api.c', + 'glx_getproc.c', + 'glx_usefont.c', + 'xm_api.c', + 'xm_st.c', +] - st_xlib = env.ConvenienceLibrary( - target = 'st_xlib', - source = [ - 'glx_api.c', - 'glx_getproc.c', - 'glx_usefont.c', - 'xm_api.c', - 'xm_st.c', - ] - ) - Export('st_xlib') +st_xlib = env.ConvenienceLibrary( + target = 'st_xlib', + source = sources, +) +Export('st_xlib') diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index dcd50e19d7..205a7e3c19 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -46,9 +46,6 @@ #define SERVER_MAJOR_VERSION 1 #define SERVER_MINOR_VERSION 4 -/* This is appended onto the glXGetClient/ServerString version strings. */ -#define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING - /* Who implemented this GLX? */ #define VENDOR "Brian Paul" @@ -1672,7 +1669,7 @@ glXQueryServerString( Display *dpy, int screen, int name ) { static char version[1000]; sprintf(version, "%d.%d %s", - SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); + SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, xmesa_get_name()); (void) dpy; (void) screen; @@ -1697,7 +1694,7 @@ glXGetClientString( Display *dpy, int name ) { static char version[1000]; sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, - CLIENT_MINOR_VERSION, MESA_GLX_VERSION); + CLIENT_MINOR_VERSION, xmesa_get_name()); (void) dpy; diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 8332633f01..7c47a25ceb 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -828,6 +828,16 @@ void XMesaDestroyVisual( XMesaVisual v ) /** + * Return the informative name. + */ +const char * +xmesa_get_name(void) +{ + return stapi->name; +} + + +/** * Do per-display initializations. */ void diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h index b8ac979edc..4ea42dc375 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.h +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h @@ -57,7 +57,7 @@ and create a window, you must do the following to use the X/Mesa interface: #define XMESA_H -#include "main/core.h" /* for GLvisual and MESA_VERSION_STRING */ +#include "main/core.h" /* for gl_config */ #include "state_tracker/st_api.h" #include "os/os_thread.h" @@ -351,6 +351,9 @@ struct xmesa_buffer { +extern const char * +xmesa_get_name(void); + extern void xmesa_init(Display *dpy); diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index aadeaa0a35..b8371865a6 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -3,57 +3,64 @@ import os.path Import('*') -if 'python' in env['statetrackers']: - - env = env.Clone() - - env.Tool('python') - - env.Tool('swig') - env.Append(SWIGPATH = ['#src/gallium/include', '#src/gallium/include/pipe']) - env.Append(SWIGFLAGS = ['-python', '-keyword']) - - env.Append(CPPPATH = '.') - - if env['platform'] == 'windows': - env.Append(LIBS = [ - 'opengl32', - 'gdi32', - 'user32', - 'kernel32', - 'ws2_32', - ]) - else: - env.Append(CPPDEFINES = ['GCC_HASCLASSVISIBILITY']) - env.Append(LIBS = [ - 'GL', - 'X11', - ]) - - sources = [ - 'gallium.i', - 'st_device.c', - 'st_sample.c', - 'st_hardpipe_winsys.c', - 'st_softpipe_winsys.c', - ] - - env.Prepend(LIBS = [ - ws_null, - trace, - gallium, +if env['toolchain'] == 'crossmingw': + # Cross-compilation not supported + Return() + +if not env.Detect(['swig']): + Return() + +env = env.Clone() + +env.Tool('python') + +env.Tool('swig') +env.Append(SWIGPATH = ['#src/gallium/include', '#src/gallium/include/pipe']) +env.Append(SWIGFLAGS = ['-python', '-keyword']) + +env.Append(CPPPATH = '.') + +if env['platform'] == 'windows': + env.Append(LIBS = [ + 'opengl32', + 'gdi32', + 'user32', + 'kernel32', + 'ws2_32', + ]) +else: + env.Append(CPPDEFINES = ['GCC_HASCLASSVISIBILITY']) + env.Append(LIBS = [ + 'GL', + 'X11', ]) - if env['llvm']: - env.Append(CPPDEFINES = ['HAVE_LLVMPIPE']) - env.Prepend(LIBS = [llvmpipe]) - if True: - env.Append(CPPDEFINES = ['HAVE_SOFTPIPE']) - env.Prepend(LIBS = [softpipe]) +sources = [ + 'gallium.i', + 'st_device.c', + 'st_sample.c', + 'st_hardpipe_winsys.c', + 'st_softpipe_winsys.c', +] + +env.Prepend(LIBS = [ + ws_null, + trace, + gallium, +]) + +if env['llvm']: + env.Append(CPPDEFINES = ['HAVE_LLVMPIPE']) + env.Prepend(LIBS = [llvmpipe]) +if True: + env.Append(CPPDEFINES = ['HAVE_SOFTPIPE']) + env.Prepend(LIBS = [softpipe]) + +env['no_import_lib'] = 1 - env['no_import_lib'] = 1 +pyst = env.SharedLibrary( + target = '_gallium', + source = sources, +) - env.SharedLibrary( - target = '_gallium', - source = sources, - ) +env.Alias('python', pyst) diff --git a/src/gallium/state_trackers/vega/Makefile b/src/gallium/state_trackers/vega/Makefile index e0a87151c4..0543fac094 100644 --- a/src/gallium/state_trackers/vega/Makefile +++ b/src/gallium/state_trackers/vega/Makefile @@ -9,6 +9,9 @@ LIBRARY_INCLUDES = \ -I$(TOP)/include \ -I$(TOP)/src/mapi +LIBRARY_DEFINES = \ + -DVEGA_VERSION_STRING=\"$(MESA_VERSION)\" + C_SOURCES = \ api.c \ api_context.c \ diff --git a/src/gallium/state_trackers/vega/SConscript b/src/gallium/state_trackers/vega/SConscript index 548053eb64..a62783ab18 100644 --- a/src/gallium/state_trackers/vega/SConscript +++ b/src/gallium/state_trackers/vega/SConscript @@ -3,49 +3,51 @@ Import('*') -if 'egl' in env['statetrackers']: +env = env.Clone() - env = env.Clone() +env.Append(CPPPATH = [ + '#/src/mapi', +]) +env.Append(CPPDEFINES = [ + 'VEGA_VERSION_STRING=', +]) - env.Append(CPPPATH = [ - '#/src/mapi', - ]) +vega_sources = [ + 'api.c', + 'api_context.c', + 'api_filters.c', + 'api_images.c', + 'api_masks.c', + 'api_misc.c', + 'api_paint.c', + 'api_params.c', + 'api_path.c', + 'api_text.c', + 'api_transform.c', + 'vgu.c', + 'vg_context.c', + 'vg_manager.c', + 'vg_state.c', + 'vg_translate.c', + 'polygon.c', + 'bezier.c', + 'path.c', + 'paint.c', + 'arc.c', + 'image.c', + 'renderer.c', + 'stroker.c', + 'mask.c', + 'shader.c', + 'shaders_cache.c', +] - vega_sources = [ - 'api.c', - 'api_context.c', - 'api_filters.c', - 'api_images.c', - 'api_masks.c', - 'api_misc.c', - 'api_paint.c', - 'api_params.c', - 'api_path.c', - 'api_text.c', - 'api_transform.c', - 'vgu.c', - 'vg_context.c', - 'vg_manager.c', - 'vg_state.c', - 'vg_translate.c', - 'polygon.c', - 'bezier.c', - 'path.c', - 'paint.c', - 'arc.c', - 'image.c', - 'renderer.c', - 'stroker.c', - 'mask.c', - 'shader.c', - 'shaders_cache.c', - ] +# vgapi_header must be generated first +env.Depends(vega_sources, vgapi_header) - # vgapi_header must be generated first - env.Depends(vega_sources, vgapi_header) +st_vega = env.ConvenienceLibrary( + target = 'st_vega', + source = vega_sources, +) - st_vega = env.ConvenienceLibrary( - target = 'st_vega', - source = vega_sources, - ) - Export('st_vega') +Export('st_vega') diff --git a/src/gallium/state_trackers/vega/api_context.c b/src/gallium/state_trackers/vega/api_context.c index 0d04d8e871..d6bbda5e07 100644 --- a/src/gallium/state_trackers/vega/api_context.c +++ b/src/gallium/state_trackers/vega/api_context.c @@ -73,7 +73,8 @@ void vegaFinish(void) pipe = ctx->pipe; pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence); - - pipe->screen->fence_finish(pipe->screen, fence, 0); - pipe->screen->fence_reference(pipe->screen, &fence, NULL); + if (fence) { + pipe->screen->fence_finish(pipe->screen, fence, 0); + pipe->screen->fence_reference(pipe->screen, &fence, NULL); + } } diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 8ace985336..fa1e00d1f8 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -37,10 +37,8 @@ #include "pipe/p_state.h" #include "util/u_inlines.h" #include "pipe/p_screen.h" -#include "pipe/p_shader_tokens.h" #include "util/u_format.h" -#include "util/u_memory.h" #include "util/u_sampler.h" #include "util/u_string.h" @@ -798,6 +796,8 @@ void vegaLookupSingle(VGImage dst, VGImage src, return; } + vg_validate_state(ctx); + for (i = 0; i < 256; ++i) { VGuint rgba = lookupTable[i]; VGubyte blue, green, red, alpha; diff --git a/src/gallium/state_trackers/vega/api_images.c b/src/gallium/state_trackers/vega/api_images.c index c36b3d2f3c..e9f038c5f9 100644 --- a/src/gallium/state_trackers/vega/api_images.c +++ b/src/gallium/state_trackers/vega/api_images.c @@ -36,9 +36,8 @@ #include "pipe/p_context.h" #include "pipe/p_screen.h" #include "util/u_inlines.h" -#include "util/u_blit.h" #include "util/u_tile.h" -#include "util/u_memory.h" +#include "util/u_math.h" static INLINE VGboolean supported_image_format(VGImageFormat format) { @@ -404,7 +403,6 @@ void vegaReadPixels(void * data, VGint dataStride, VGfloat temp[VEGA_MAX_IMAGE_WIDTH][4]; VGfloat *df = (VGfloat*)temp; - VGint y = (fb->height - sy) - 1, yStep = -1; VGint i; VGubyte *dst = (VGubyte *)data; VGint xoffset = 0, yoffset = 0; @@ -432,18 +430,26 @@ void vegaReadPixels(void * data, VGint dataStride, } if (sy < 0) { yoffset = -sy; + yoffset *= dataStride; height += sy; sy = 0; - y = (fb->height - sy) - 1; - yoffset *= dataStride; + } + + if (sx + width > fb->width || sy + height > fb->height) { + width = fb->width - sx; + height = fb->height - sy; + /* nothing to read */ + if (width <= 0 || height <= 0) + return; } { + VGint y = (fb->height - sy) - 1, yStep = -1; struct pipe_transfer *transfer; transfer = pipe_get_transfer(pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, - 0, 0, width, height); + 0, 0, sx + width, fb->height - sy); /* Do a row at a time to flip image data vertically */ for (i = 0; i < height; i++) { diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c index 94c1ff5375..189390ec2d 100644 --- a/src/gallium/state_trackers/vega/api_masks.c +++ b/src/gallium/state_trackers/vega/api_masks.c @@ -27,7 +27,6 @@ #include "VG/openvg.h" #include "mask.h" -#include "renderer.h" #include "api.h" #include "vg_context.h" @@ -36,7 +35,6 @@ #include "util/u_pack_color.h" #include "util/u_draw_quad.h" -#include "util/u_memory.h" #define DISABLE_1_1_MASKING 1 diff --git a/src/gallium/state_trackers/vega/api_paint.c b/src/gallium/state_trackers/vega/api_paint.c index d88341b04f..1411806455 100644 --- a/src/gallium/state_trackers/vega/api_paint.c +++ b/src/gallium/state_trackers/vega/api_paint.c @@ -28,7 +28,6 @@ #include "vg_context.h" #include "paint.h" -#include "image.h" #include "api.h" VGPaint vegaCreatePaint(void) diff --git a/src/gallium/state_trackers/vega/api_path.c b/src/gallium/state_trackers/vega/api_path.c index 6c9a2e8d65..f76adddb58 100644 --- a/src/gallium/state_trackers/vega/api_path.c +++ b/src/gallium/state_trackers/vega/api_path.c @@ -28,13 +28,9 @@ #include "vg_context.h" #include "path.h" -#include "polygon.h" -#include "paint.h" #include "api.h" #include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_draw_quad.h" VGPath vegaCreatePath(VGint pathFormat, VGPathDatatype datatype, diff --git a/src/gallium/state_trackers/vega/api_text.c b/src/gallium/state_trackers/vega/api_text.c index b35f3be90a..2a62da0a1d 100644 --- a/src/gallium/state_trackers/vega/api_text.c +++ b/src/gallium/state_trackers/vega/api_text.c @@ -27,7 +27,6 @@ #include "VG/openvg.h" #include "vg_context.h" -#include "api.h" #include "util/u_memory.h" diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index c12dc71b86..28bbe420a2 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -32,13 +32,11 @@ #include "renderer.h" #include "util_array.h" #include "api_consts.h" -#include "shaders_cache.h" #include "shader.h" #include "pipe/p_context.h" #include "pipe/p_screen.h" #include "util/u_inlines.h" -#include "util/u_blit.h" #include "util/u_format.h" #include "util/u_tile.h" #include "util/u_memory.h" diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index 2c0eb6b23d..c0c8cddabe 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -26,7 +26,6 @@ #include "paint.h" -#include "shaders_cache.h" #include "matrix.h" #include "image.h" #include "st_inlines.h" @@ -34,7 +33,6 @@ #include "pipe/p_compiler.h" #include "util/u_inlines.h" -#include "util/u_format.h" #include "util/u_memory.h" #include "util/u_math.h" #include "util/u_sampler.h" diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c index bc94170eb9..ca8831064c 100644 --- a/src/gallium/state_trackers/vega/polygon.c +++ b/src/gallium/state_trackers/vega/polygon.c @@ -29,7 +29,6 @@ #include "matrix.h" /*for floatsEqual*/ #include "vg_context.h" #include "vg_state.h" -#include "paint.h" #include "renderer.h" #include "util_array.h" #include "VG/openvg.h" diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index 8c023044c4..c6f5f7a05b 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -35,12 +35,9 @@ #include "pipe/p_shader_tokens.h" #include "util/u_draw_quad.h" -#include "util/u_format.h" #include "util/u_simple_shaders.h" #include "util/u_memory.h" -#include "util/u_rect.h" #include "util/u_sampler.h" -#include "util/u_surface.h" #include "cso_cache/cso_context.h" diff --git a/src/gallium/state_trackers/vega/shaders_cache.c b/src/gallium/state_trackers/vega/shaders_cache.c index 53e6bfcf16..e002a7ed42 100644 --- a/src/gallium/state_trackers/vega/shaders_cache.c +++ b/src/gallium/state_trackers/vega/shaders_cache.c @@ -30,8 +30,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "util/u_inlines.h" -#include "pipe/p_screen.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_build.h" diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 5cb2590602..99e444affd 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -37,7 +37,6 @@ #include "pipe/p_context.h" #include "util/u_inlines.h" -#include "pipe/p_shader_tokens.h" #include "cso_cache/cso_context.h" @@ -128,6 +127,7 @@ struct vg_context * vg_create_context(struct pipe_context *pipe, ctx->mask.sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->mask.sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + ctx->mask.sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->mask.sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; ctx->mask.sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->mask.sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; @@ -135,6 +135,7 @@ struct vg_context * vg_create_context(struct pipe_context *pipe, ctx->blend_sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->blend_sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + ctx->blend_sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->blend_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; ctx->blend_sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->blend_sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c index 232deefa16..bb15ec024f 100644 --- a/src/gallium/state_trackers/vega/vg_manager.c +++ b/src/gallium/state_trackers/vega/vg_manager.c @@ -535,6 +535,7 @@ vg_api_destroy(struct st_api *stapi) } static const struct st_api vg_api = { + "Vega " VEGA_VERSION_STRING, ST_API_OPENVG, ST_PROFILE_DEFAULT_MASK, vg_api_destroy, diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript index 0f580b859c..ec55f042f9 100644 --- a/src/gallium/state_trackers/wgl/SConscript +++ b/src/gallium/state_trackers/wgl/SConscript @@ -2,41 +2,38 @@ import os Import('*') -if env['platform'] in ['windows']: - - env = env.Clone() - - env.Append(CPPPATH = [ - '#src/mapi', - '#src/mesa', - '.', - ]) - - env.AppendUnique(CPPDEFINES = [ - '_GDI32_', # prevent wgl* being declared __declspec(dllimport) - 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers - 'WIN32_THREADS', # use Win32 thread API - 'WIN32_LEAN_AND_MEAN', # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx - ]) - - sources = [ - 'stw_context.c', - 'stw_device.c', - 'stw_ext_extensionsstring.c', - 'stw_ext_gallium.c', - 'stw_ext_pixelformat.c', - 'stw_ext_swapinterval.c', - 'stw_framebuffer.c', - 'stw_getprocaddress.c', - 'stw_pixelformat.c', - 'stw_st.c', - 'stw_tls.c', - 'stw_wgl.c', - ] +env = env.Clone() - wgl = env.ConvenienceLibrary( - target ='wgl', - source = sources, - ) - - Export('wgl') +env.Append(CPPPATH = [ + '#src/mapi', + '#src/mesa', + '.', +]) + +env.AppendUnique(CPPDEFINES = [ + '_GDI32_', # prevent wgl* being declared __declspec(dllimport) + 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers + 'WIN32_THREADS', # use Win32 thread API + 'WIN32_LEAN_AND_MEAN', # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx +]) + +sources = [ + 'stw_context.c', + 'stw_device.c', + 'stw_ext_extensionsstring.c', + 'stw_ext_gallium.c', + 'stw_ext_pixelformat.c', + 'stw_ext_swapinterval.c', + 'stw_framebuffer.c', + 'stw_getprocaddress.c', + 'stw_pixelformat.c', + 'stw_st.c', + 'stw_tls.c', + 'stw_wgl.c', +] + +wgl = env.ConvenienceLibrary( + target ='wgl', + source = sources, +) +Export('wgl') diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index 85878b4673..86c0a28e8d 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -29,12 +29,10 @@ #include "pipe/p_compiler.h" #include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "util/u_memory.h" #include "state_tracker/st_api.h" -/* for _mesa_share_state */ -#include "state_tracker/st_context.h" -#include "main/core.h" - #include "stw_icd.h" #include "stw_device.h" #include "stw_winsys.h" @@ -102,13 +100,8 @@ DrvShareLists( ctx1 = stw_lookup_context_locked( dhglrc1 ); ctx2 = stw_lookup_context_locked( dhglrc2 ); - if (ctx1 && ctx2) { - struct st_context *st1, *st2; - - st1 = (struct st_context *) ctx1->st; - st2 = (struct st_context *) ctx2->st; - ret = _mesa_share_state(st2->ctx, st1->ctx); - } + if (ctx1 && ctx2 && ctx2->st->share) + ret = ctx2->st->share(ctx2->st, ctx1->st); pipe_mutex_unlock( stw_dev->ctx_mutex ); diff --git a/src/gallium/state_trackers/xorg/SConscript b/src/gallium/state_trackers/xorg/SConscript index 0b598dab6e..19315694b7 100644 --- a/src/gallium/state_trackers/xorg/SConscript +++ b/src/gallium/state_trackers/xorg/SConscript @@ -3,34 +3,38 @@ Import('*') -if 'xorg' in env['statetrackers']: +env = env.Clone() - env = env.Clone() +env.Append(CPPPATH = [ + '#/src/mesa', +]) - env.Append(CPPPATH = [ - '#/src/mesa', - ]) +env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server') - env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server') +if env['kms']: + env.Append(CPPDEFINES = ['HAVE_LIBKMS']) - conf = env.Configure() +conf = env.Configure() - if conf.CheckHeader('X11/extensions/dpmsconst.h'): - env.Append(CPPDEFINES = [('HAVE_XEXTPROTO_71', '1')]) +if conf.CheckHeader('X11/extensions/dpmsconst.h'): + env.Append(CPPDEFINES = [('HAVE_XEXTPROTO_71', '1')]) - conf.Finish() +conf.Finish() - st_xorg = env.ConvenienceLibrary( - target = 'st_xorg', - source = [ 'xorg_composite.c', - 'xorg_crtc.c', - 'xorg_dri2.c', - 'xorg_driver.c', - 'xorg_exa.c', - 'xorg_exa_tgsi.c', - 'xorg_output.c', - 'xorg_renderer.c', - 'xorg_xv.c', - ] - ) - Export('st_xorg') +sources = [ + 'xorg_composite.c', + 'xorg_crtc.c', + 'xorg_dri2.c', + 'xorg_driver.c', + 'xorg_exa.c', + 'xorg_exa_tgsi.c', + 'xorg_output.c', + 'xorg_renderer.c', + 'xorg_xv.c', +] + +st_xorg = env.ConvenienceLibrary( + target = 'st_xorg', + source = sources, +) +Export('st_xorg') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 1ec772df17..1ee79ae177 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -447,7 +447,7 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags) if (!drv_init_resource_management(pScrn)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Could not init " - "Gallium3D or libKMS."); + "Gallium3D or libKMS.\n"); return FALSE; } |