X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fstate_trackers%2Fegl%2Fcommon%2Fegl_g3d_st.c;h=b839f848d7b30defe101889fdc7a4c6e37c97ec6;hb=f8e6d19f3f40931be741b44d3edf210c38e13f0f;hp=57a479f6bcad9c68580fcba16eb891cec48ce255;hpb=64644ec3b21884d4a974fa29087fa98c4ed9e112;p=mesa.git 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 57a479f6bca..b839f848d7b 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c @@ -27,8 +27,11 @@ */ #include "util/u_memory.h" +#include "util/u_string.h" #include "util/u_inlines.h" +#include "util/u_pointer.h" #include "util/u_dl.h" +#include "egldriver.h" #include "eglimage.h" #include "eglmutex.h" @@ -46,52 +49,13 @@ egl_g3d_st_manager(struct st_manager *smapi) return (struct egl_g3d_st_manager *) smapi; } -struct st_api * -egl_g3d_create_st_api(enum st_api_type api) -{ - const char *stmod_name; - struct util_dl_library *lib; - const struct st_module *mod; - - switch (api) { - case ST_API_OPENGL: - stmod_name = ST_MODULE_OPENGL_SYMBOL; - break; - case ST_API_OPENGL_ES1: - stmod_name = ST_MODULE_OPENGL_ES1_SYMBOL; - break; - case ST_API_OPENGL_ES2: - stmod_name = ST_MODULE_OPENGL_ES2_SYMBOL; - break; - case ST_API_OPENVG: - stmod_name = ST_MODULE_OPENVG_SYMBOL; - break; - default: - stmod_name = NULL; - break; - } - if (!stmod_name) - return NULL; - - mod = NULL; - lib = util_dl_open(NULL); - if (lib) { - mod = (const struct st_module *) - util_dl_get_proc_address(lib, stmod_name); - util_dl_close(lib); - } - if (!mod || mod->api != api) - return NULL; - - return mod->create_api(); -} - static boolean egl_g3d_st_manager_get_egl_image(struct st_manager *smapi, - struct st_egl_image *stimg) + void *egl_image, + struct st_egl_image *out) { struct egl_g3d_st_manager *gsmapi = egl_g3d_st_manager(smapi); - EGLImageKHR handle = (EGLImageKHR) stimg->egl_image; + EGLImageKHR handle = (EGLImageKHR) egl_image; _EGLImage *img; struct egl_g3d_image *gimg; @@ -106,17 +70,23 @@ egl_g3d_st_manager_get_egl_image(struct st_manager *smapi, gimg = egl_g3d_image(img); - stimg->texture = NULL; - pipe_resource_reference(&stimg->texture, gimg->texture); - stimg->face = gimg->face; - stimg->level = gimg->level; - stimg->zslice = gimg->zslice; + out->texture = NULL; + pipe_resource_reference(&out->texture, gimg->texture); + out->level = gimg->level; + out->layer = gimg->layer; _eglUnlockMutex(&gsmapi->display->Mutex); return TRUE; } +static int +egl_g3d_st_manager_get_param(struct st_manager *smapi, + enum st_manager_param param) +{ + return 0; +} + struct st_manager * egl_g3d_create_st_manager(_EGLDisplay *dpy) { @@ -129,6 +99,7 @@ egl_g3d_create_st_manager(_EGLDisplay *dpy) gsmapi->base.screen = gdpy->native->screen; gsmapi->base.get_egl_image = egl_g3d_st_manager_get_egl_image; + gsmapi->base.get_param = egl_g3d_st_manager_get_param; } return &gsmapi->base;; @@ -148,7 +119,36 @@ egl_g3d_st_framebuffer_flush_front_pbuffer(struct st_framebuffer_iface *stfbi, return TRUE; } -static boolean +static void +pbuffer_reference_openvg_image(struct egl_g3d_surface *gsurf) +{ + /* TODO */ +} + +static void +pbuffer_allocate_pbuffer_texture(struct egl_g3d_surface *gsurf) +{ + struct egl_g3d_display *gdpy = + egl_g3d_display(gsurf->base.Resource.Display); + struct pipe_screen *screen = gdpy->native->screen; + struct pipe_resource templ, *ptex; + + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.last_level = 0; + templ.width0 = gsurf->base.Width; + templ.height0 = gsurf->base.Height; + templ.depth0 = 1; + templ.array_size = 1; + templ.format = gsurf->stvis.color_format; + /* for rendering and binding to texture */ + templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; + + ptex = screen->resource_create(screen, &templ); + gsurf->render_texture = ptex; +} + +static boolean egl_g3d_st_framebuffer_validate_pbuffer(struct st_framebuffer_iface *stfbi, const enum st_attachment_type *statts, unsigned count, @@ -156,7 +156,6 @@ egl_g3d_st_framebuffer_validate_pbuffer(struct st_framebuffer_iface *stfbi, { _EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private; struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - struct pipe_resource templ; unsigned i; for (i = 0; i < count; i++) { @@ -166,20 +165,19 @@ egl_g3d_st_framebuffer_validate_pbuffer(struct st_framebuffer_iface *stfbi, continue; if (!gsurf->render_texture) { - struct egl_g3d_display *gdpy = - egl_g3d_display(gsurf->base.Resource.Display); - struct pipe_screen *screen = gdpy->native->screen; - - memset(&templ, 0, sizeof(templ)); - templ.target = PIPE_TEXTURE_2D; - templ.last_level = 0; - templ.width0 = gsurf->base.Width; - templ.height0 = gsurf->base.Height; - templ.depth0 = 1; - templ.format = gsurf->stvis.color_format; - templ.bind = PIPE_BIND_RENDER_TARGET; - - gsurf->render_texture = screen->resource_create(screen, &templ); + switch (gsurf->client_buffer_type) { + case EGL_NONE: + pbuffer_allocate_pbuffer_texture(gsurf); + break; + case EGL_OPENVG_IMAGE: + pbuffer_reference_openvg_image(gsurf); + break; + default: + break; + } + + if (!gsurf->render_texture) + return FALSE; } pipe_resource_reference(&out[i], gsurf->render_texture); @@ -195,7 +193,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 @@ -294,6 +293,8 @@ egl_g3d_create_st_framebuffer(_EGLSurface *surf) return NULL; stfbi->visual = &gsurf->stvis; + p_atomic_set(&stfbi->stamp, 1); + if (gsurf->base.Type != EGL_PBUFFER_BIT) { stfbi->flush_front = egl_g3d_st_framebuffer_flush_front; stfbi->validate = egl_g3d_st_framebuffer_validate;