* 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,
+ * 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
- * BRIAN PAUL 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.
+ * 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>
*/
#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"
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;
gimg = egl_g3d_image(img);
- stimg->texture = NULL;
- pipe_texture_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)
{
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;;
egl_g3d_destroy_st_manager(struct st_manager *smapi)
{
struct egl_g3d_st_manager *gsmapi = egl_g3d_st_manager(smapi);
- free(gsmapi);
+ FREE(gsmapi);
+}
+
+static boolean
+egl_g3d_st_framebuffer_flush_front_pbuffer(struct st_framebuffer_iface *stfbi,
+ enum st_attachment_type statt)
+{
+ return TRUE;
+}
+
+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,
+ struct pipe_resource **out)
+{
+ _EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private;
+ struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+ unsigned i;
+
+ for (i = 0; i < count; i++) {
+ out[i] = NULL;
+
+ if (gsurf->stvis.render_buffer != statts[i])
+ continue;
+
+ if (!gsurf->render_texture) {
+ 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);
+ }
+
+ return TRUE;
}
static boolean
_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
egl_g3d_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
- struct pipe_texture **out)
+ struct pipe_resource **out)
{
_EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private;
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
- struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+ struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS];
uint attachment_mask = 0;
unsigned i;
return FALSE;
for (i = 0; i < count; i++) {
- struct pipe_texture *tex;
+ struct pipe_resource *tex;
int natt;
switch (statts[i]) {
tex = textures[natt];
if (statts[i] == stfbi->visual->render_buffer)
- pipe_texture_reference(&gsurf->render_texture, tex);
+ pipe_resource_reference(&gsurf->render_texture, tex);
if (attachment_mask & (1 << natt)) {
/* transfer the ownership to the caller */
}
else {
/* the attachment is listed more than once */
- pipe_texture_reference(&out[i], tex);
+ pipe_resource_reference(&out[i], tex);
}
}
}
return NULL;
stfbi->visual = &gsurf->stvis;
- stfbi->flush_front = egl_g3d_st_framebuffer_flush_front;
- stfbi->validate = egl_g3d_st_framebuffer_validate;
+ 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;
+ }
+ else {
+ stfbi->flush_front = egl_g3d_st_framebuffer_flush_front_pbuffer;
+ stfbi->validate = egl_g3d_st_framebuffer_validate_pbuffer;
+ }
stfbi->st_manager_private = (void *) &gsurf->base;
return stfbi;
void
egl_g3d_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi)
{
- free(stfbi);
+ FREE(stfbi);
}