st/egl: add support for null platform

The backend calls null_sw_create() to create sw_winsys.  And that is
pretty much it...
This commit is contained in:
Chia-I Wu 2011-09-20 14:01:45 +08:00
parent 5eca41665b
commit a5f8d37be1
6 changed files with 219 additions and 2 deletions

View File

@ -1636,6 +1636,9 @@ yes)
if test "$plat" = "fbdev"; then
GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/fbdev"
fi
if test "$plat" = "null"; then
GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/null"
fi
if test "$plat" = "wayland"; then
PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server],, \
[AC_MSG_ERROR([cannot find libwayland-client])])

View File

@ -44,8 +44,13 @@ fbdev_SOURCES = $(wildcard fbdev/*.c)
fbdev_OBJECTS = $(fbdev_SOURCES:.c=.o)
ALL_INCLUDES = $(common_INCLUDES) $(x11_INCLUDES) $(drm_INCLUDES) $(fbdev_INCLUDES)
ALL_SOURCES = $(common_SOURCES) $(x11_SOURCES) $(drm_SOURCES) $(fbdev_SOURCES)
null_INCLUDES = -I$(TOP)/src/gallium/winsys/sw
null_SOURCES = $(wildcard null/*.c)
null_OBJECTS = $(null_SOURCES:.c=.o)
ALL_INCLUDES = $(common_INCLUDES) $(x11_INCLUDES) $(drm_INCLUDES) $(fbdev_INCLUDES) $(null_INCLUDES)
ALL_SOURCES = $(common_SOURCES) $(x11_SOURCES) $(drm_SOURCES) $(fbdev_SOURCES) $(null_SOURCES)
EGL_OBJECTS = $(common_OBJECTS)
EGL_CPPFLAGS = $(common_INCLUDES)
@ -68,6 +73,10 @@ ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
EGL_OBJECTS += $(fbdev_OBJECTS)
EGL_CPPFLAGS += -DHAVE_FBDEV_BACKEND
endif
ifneq ($(findstring null, $(EGL_PLATFORMS)),)
EGL_OBJECTS += $(null_OBJECTS)
EGL_CPPFLAGS += -DHAVE_NULL_BACKEND
endif
##### TARGETS #####
@ -111,4 +120,7 @@ $(drm_OBJECTS): %.o: %.c
$(fbdev_OBJECTS): %.o: %.c
$(call egl-cc,fbdev)
$(null_OBJECTS): %.o: %.c
$(call egl-cc,null)
sinclude depend

View File

@ -130,6 +130,12 @@ egl_g3d_get_platform(_EGLDriver *drv, _EGLPlatformType plat)
plat_name = "FBDEV";
#ifdef HAVE_FBDEV_BACKEND
nplat = native_get_fbdev_platform(&egl_g3d_native_event_handler);
#endif
break;
case _EGL_PLATFORM_NULL:
plat_name = "NULL";
#ifdef HAVE_NULL_BACKEND
nplat = native_get_null_platform(&egl_g3d_native_event_handler);
#endif
break;
case _EGL_PLATFORM_ANDROID:

View File

@ -319,6 +319,9 @@ native_get_drm_platform(const struct native_event_handler *event_handler);
const struct native_platform *
native_get_fbdev_platform(const struct native_event_handler *event_handler);
const struct native_platform *
native_get_null_platform(const struct native_event_handler *event_handler);
const struct native_platform *
native_get_android_platform(const struct native_event_handler *event_handler);

View File

@ -0,0 +1,190 @@
/*
* Mesa 3-D graphics library
* Version: 7.12
*
* Copyright (C) 2011 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>
*/
/**
* For NULL window system,
*
* - the only valid native display is EGL_DEFAULT_DISPLAY
* - there is no window or pixmap
*/
#include "util/u_memory.h"
#include "null/null_sw_winsys.h"
#include "common/native.h"
struct null_display {
struct native_display base;
const struct native_event_handler *event_handler;
struct native_config *configs;
int num_configs;
};
static INLINE struct null_display *
null_display(const struct native_display *ndpy)
{
return (struct null_display *) ndpy;
}
static const struct native_config **
null_display_get_configs(struct native_display *ndpy, int *num_configs)
{
struct null_display *null = null_display(ndpy);
const struct native_config **configs;
int i;
configs = MALLOC(sizeof(*configs) * null->num_configs);
if (configs) {
for (i = 0; i < null->num_configs; i++)
configs[i] = &null->configs[i];
if (num_configs)
*num_configs = null->num_configs;
}
return configs;
}
static int
null_display_get_param(struct native_display *ndpy,
enum native_param_type param)
{
return 0;
}
static void
null_display_destroy(struct native_display *ndpy)
{
struct null_display *null = null_display(ndpy);
FREE(null->configs);
ndpy_uninit(&null->base);
FREE(null);
}
static boolean
null_display_init_config(struct native_display *ndpy)
{
const enum pipe_format color_formats[] = {
PIPE_FORMAT_B8G8R8A8_UNORM,
PIPE_FORMAT_B8G8R8X8_UNORM,
PIPE_FORMAT_B5G6R5_UNORM,
PIPE_FORMAT_NONE
};
struct null_display *null = null_display(ndpy);
int i;
null->configs = CALLOC(Elements(color_formats) - 1, sizeof(*null->configs));
if (!null->configs)
return FALSE;
/* add configs */
for (i = 0; color_formats[i] != PIPE_FORMAT_NONE; i++) {
if (null->base.screen->is_format_supported(null->base.screen,
color_formats[i], PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET)) {
struct native_config *nconf = &null->configs[null->num_configs];
nconf->color_format = color_formats[i];
nconf->buffer_mask = 1 << NATIVE_ATTACHMENT_BACK_LEFT;
null->num_configs++;
}
}
return TRUE;
}
static boolean
null_display_init_screen(struct native_display *ndpy)
{
struct null_display *null = null_display(ndpy);
struct sw_winsys *ws;
ws = null_sw_create();
if (!ws)
return FALSE;
null->base.screen = null->event_handler->new_sw_screen(&null->base, ws);
if (!null->base.screen) {
if (ws->destroy)
ws->destroy(ws);
return FALSE;
}
if (!null_display_init_config(&null->base)) {
ndpy_uninit(&null->base);
return FALSE;
}
return TRUE;
}
static struct native_display *
null_display_create(const struct native_event_handler *event_handler)
{
struct null_display *null;
null = CALLOC_STRUCT(null_display);
if (!null)
return NULL;
null->event_handler = event_handler;
null->base.init_screen = null_display_init_screen;
null->base.destroy = null_display_destroy;
null->base.get_param = null_display_get_param;
null->base.get_configs = null_display_get_configs;
return &null->base;
}
static const struct native_event_handler *null_event_handler;
static struct native_display *
native_create_display(void *dpy, boolean use_sw)
{
struct native_display *ndpy = NULL;
/* the only valid display is NULL */
if (!dpy)
ndpy = null_display_create(null_event_handler);
return ndpy;
}
static const struct native_platform null_platform = {
"NULL", /* name */
native_create_display
};
const struct native_platform *
native_get_null_platform(const struct native_event_handler *event_handler)
{
null_event_handler = event_handler;
return &null_platform;
}

View File

@ -63,6 +63,9 @@ endif
ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
egl_LIBS += $(TOP)/src/gallium/winsys/sw/fbdev/libfbdev.a
endif
ifneq ($(findstring null, $(EGL_PLATFORMS)),)
egl_LIBS += $(TOP)/src/gallium/winsys/sw/null/libws_null.a
endif
# st/mesa
ifneq ($(filter $(GL_LIB), $(EGL_CLIENT_APIS)),)