svga: Move bootstrap code to targets

This commit is contained in:
Jakob Bornecrantz 2010-06-06 11:13:49 +01:00
parent 16fa300d55
commit 9ff10b67bc
8 changed files with 138 additions and 40 deletions

View file

@ -0,0 +1,42 @@
/**********************************************************
* Copyright 2010 VMware, Inc. All rights reserved.
*
* 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.
*
**********************************************************/
/**
* @file
* VMware SVGA public interface. Used by targets to create a stack.
*
* @author Jakob Bornecrantz Fonseca <jakob@vmware.com>
*/
#ifndef SVGA_PUBLIC_H_
#define SVGA_PUBLIC_H_
struct pipe_screen;
struct svga_winsys_screen;
struct pipe_screen *
svga_screen_create(struct svga_winsys_screen *sws);
#endif /* SVGA_PUBLIC_H_ */

View file

@ -29,6 +29,7 @@
#include "util/u_math.h"
#include "svga_winsys.h"
#include "svga_public.h"
#include "svga_context.h"
#include "svga_screen.h"
#include "svga_resource_texture.h"

View file

@ -288,9 +288,6 @@ struct svga_winsys_screen
};
struct pipe_screen *
svga_screen_create(struct svga_winsys_screen *sws);
struct svga_winsys_screen *
svga_winsys_screen(struct pipe_screen *screen);

View file

@ -1,4 +1,17 @@
#include "target-helpers/drm_api_compat.h"
#include "state_tracker/drm_driver.h"
#include "svga/drm/svga_drm_public.h"
#include "svga/svga_public.h"
DRM_API_COMPAT_STRUCT("vmwgfx", "vmwgfx")
static struct pipe_screen *
create_screen(int fd)
{
struct svga_winsys_screen *sws;
sws = svga_drm_winsys_screen_create(fd);
if (!sws)
return NULL;
return svga_screen_create(sws);
}
DRM_DRIVER_DESCRIPTOR("vmwgfx", "vmwgfx", create_screen)

View file

@ -1,6 +1,20 @@
#include "target-helpers/drm_api_compat.h"
DRM_API_COMPAT_STRUCT("vmwgfx", "vmwgfx")
#include "state_tracker/drm_driver.h"
#include "svga/drm/svga_drm_public.h"
#include "svga/svga_public.h"
static struct pipe_screen *
create_screen(int fd)
{
struct svga_winsys_screen *sws;
sws = svga_drm_winsys_screen_create(fd);
if (!sws)
return NULL;
return svga_screen_create(sws);
}
DRM_DRIVER_DESCRIPTOR("vmwgfx", "vmwgfx", create_screen)
/* A poor man's --whole-archive for EGL drivers */
void *_eglMain(void *);

View file

@ -1,4 +1,17 @@
#include "target-helpers/drm_api_compat.h"
#include "state_tracker/drm_driver.h"
#include "svga/drm/svga_drm_public.h"
#include "svga/svga_public.h"
DRM_API_COMPAT_STRUCT("vmwgfx", "vmwgfx")
static struct pipe_screen *
create_screen(int fd)
{
struct svga_winsys_screen *sws;
sws = svga_drm_winsys_screen_create(fd);
if (!sws)
return NULL;
return svga_screen_create(sws);
}
DRM_DRIVER_DESCRIPTOR("vmwgfx", "vmwgfx", create_screen)

View file

@ -0,0 +1,41 @@
/**********************************************************
* Copyright 2010 VMware, Inc. All rights reserved.
*
* 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.
*
**********************************************************/
/**
* @file
* VMware SVGA DRM winsys public interface. Used by targets to create a stack.
*
* @author Jakob Bornecrantz Fonseca <jakob@vmware.com>
*/
#ifndef SVGA_DRM_PUBLIC_H_
#define SVGA_DRM_PUBLIC_H_
struct svga_winsys_screen;
struct svga_winsys_screen *
svga_drm_winsys_screen_create(int fd);
#endif /* SVGA_PUBLIC_H_ */

View file

@ -30,14 +30,14 @@
#include "util/u_format.h"
#include "vmw_screen.h"
#include "trace/tr_drm.h"
#include "vmw_screen.h"
#include "vmw_surface.h"
#include "vmw_fence.h"
#include "vmw_context.h"
#include "svga_drm_public.h"
#include "state_tracker/drm_driver.h"
#include <state_tracker/drm_api.h>
#include "vmwgfx_drm.h"
#include <xf86drm.h>
@ -84,15 +84,13 @@ vmw_dri1_check_version(const struct dri1_api_version *cur,
return FALSE;
}
/* This is actually the entrypoint to the entire driver, called by the
* libGL (or EGL, or ...) code via the drm_api_hooks table at the
* bottom of the file.
/* This is actually the entrypoint to the entire driver,
* called by the target bootstrap code.
*/
static struct pipe_screen *
vmw_drm_create_screen(struct drm_api *drm_api, int fd)
struct svga_winsys_screen *
svga_drm_winsys_screen_create(int fd)
{
struct vmw_winsys_screen *vws;
struct pipe_screen *screen;
boolean use_old_scanout_flag = FALSE;
struct dri1_api_version drm_ver;
@ -123,16 +121,7 @@ vmw_drm_create_screen(struct drm_api *drm_api, int fd)
vws->base.surface_from_handle = vmw_drm_surface_from_handle;
vws->base.surface_get_handle = vmw_drm_surface_get_handle;
screen = svga_screen_create( &vws->base );
if (!screen)
goto out_no_screen;
return screen;
/* Failure cases:
*/
out_no_screen:
vmw_winsys_destroy( vws );
return &vws->base;
out_no_vws:
return NULL;
@ -253,15 +242,3 @@ vmw_drm_surface_get_handle(struct svga_winsys_screen *sws,
return TRUE;
}
static struct drm_api vmw_drm_api_hooks = {
.name = "vmwgfx",
.driver_name = "vmwgfx",
.create_screen = vmw_drm_create_screen,
.destroy = NULL,
};
struct drm_api* drm_api_create()
{
return trace_drm_create(&vmw_drm_api_hooks);
}