python: Fix up state tracker for sw api.

This commit is contained in:
José Fonseca
2010-03-10 10:34:29 +00:00
parent 5235c5aac7
commit 601bfb5951
8 changed files with 85 additions and 225 deletions

View File

@@ -124,6 +124,7 @@ env.Append(CPPPATH = [
'#/src/gallium/include', '#/src/gallium/include',
'#/src/gallium/auxiliary', '#/src/gallium/auxiliary',
'#/src/gallium/drivers', '#/src/gallium/drivers',
'#/src/gallium/winsys',
]) ])
if env['msvc']: if env['msvc']:

View File

@@ -33,31 +33,26 @@ if 'python' in env['statetrackers']:
'gallium.i', 'gallium.i',
'st_device.c', 'st_device.c',
'st_sample.c', 'st_sample.c',
'st_hardpipe_winsys.c',
'st_softpipe_winsys.c',
] ]
drivers = [ env.Prepend(LIBS = [
trace trace,
] gallium
])
if 'llvmpipe' in env['drivers']: if 'llvmpipe' in env['drivers']:
env.Append(CPPDEFINES = ['HAVE_LLVMPIPE'])
env.Tool('llvm') env.Tool('llvm')
sources += ['st_llvmpipe_winsys.c'] env.Prepend(LIBS = [llvmpipe])
drivers += [llvmpipe] if 'softpipe' in env['drivers']:
else: env.Append(CPPDEFINES = ['HAVE_SOFTPIPE'])
sources += ['st_softpipe_winsys.c'] env.Prepend(LIBS = [softpipe])
drivers += [softpipe]
pyst = env.ConvenienceLibrary(
target = 'pyst',
source = sources,
)
env['no_import_lib'] = 1 env['no_import_lib'] = 1
env.SharedLibrary( env.SharedLibrary(
target = '_gallium', target = '_gallium',
source = [ source = sources,
'st_hardpipe_winsys.c',
],
LIBS = [pyst] + drivers + gallium + env['LIBS'],
) )

View File

@@ -34,8 +34,7 @@
#include "util/u_math.h" #include "util/u_math.h"
#include "util/u_memory.h" #include "util/u_memory.h"
#include "util/u_simple_shaders.h" #include "util/u_simple_shaders.h"
#include "trace/tr_screen.h" #include "trace/tr_public.h"
#include "trace/tr_context.h"
#include "st_device.h" #include "st_device.h"
#include "st_winsys.h" #include "st_winsys.h"
@@ -75,43 +74,34 @@ st_device_destroy(struct st_device *st_dev)
} }
static struct st_device * struct st_device *
st_device_create_from_st_winsys(const struct st_winsys *st_ws) st_device_create(boolean hardware)
{ {
struct pipe_screen *screen;
struct st_device *st_dev; struct st_device *st_dev;
if(!st_ws->screen_create) if (hardware)
return NULL; screen = st_hardware_screen_create();
else
screen = st_software_screen_create();
screen = trace_screen_create(screen);
if (!screen)
goto no_screen;
st_dev = CALLOC_STRUCT(st_device); st_dev = CALLOC_STRUCT(st_device);
if (!st_dev) if (!st_dev)
return NULL; goto no_device;
pipe_reference_init(&st_dev->reference, 1); pipe_reference_init(&st_dev->reference, 1);
st_dev->st_ws = st_ws; st_dev->screen = screen;
st_dev->real_screen = st_ws->screen_create();
if(!st_dev->real_screen) {
st_device_destroy(st_dev);
return NULL;
}
st_dev->screen = trace_screen_create(st_dev->real_screen);
if(!st_dev->screen) {
st_device_destroy(st_dev);
return NULL;
}
return st_dev; return st_dev;
}
no_device:
struct st_device * screen->destroy(screen);
st_device_create(boolean hardware) { no_screen:
if(hardware) return NULL;
return st_device_create_from_st_winsys(&st_hardpipe_winsys);
else
return st_device_create_from_st_winsys(&st_softpipe_winsys);
} }

View File

@@ -47,7 +47,8 @@ struct st_surface
}; };
struct st_context { struct st_context
{
struct st_device *st_dev; struct st_device *st_dev;
struct pipe_context *pipe; struct pipe_context *pipe;
@@ -72,13 +73,11 @@ struct st_context {
}; };
struct st_device { struct st_device
{
/* FIXME: we also need to refcount for textures and surfaces... */ /* FIXME: we also need to refcount for textures and surfaces... */
struct pipe_reference reference; struct pipe_reference reference;
const struct st_winsys *st_ws;
struct pipe_screen *real_screen;
struct pipe_screen *screen; struct pipe_screen *screen;
}; };

View File

@@ -207,16 +207,11 @@ st_hardpipe_load(void)
#endif #endif
static struct pipe_screen * struct pipe_screen *
st_hardpipe_screen_create(void) st_hardware_screen_create(void)
{ {
if(st_hardpipe_load()) if(st_hardpipe_load())
return pfnGetGalliumScreenMESA(); return pfnGetGalliumScreenMESA();
else else
return st_softpipe_winsys.screen_create(); return st_software_screen_create();
} }
const struct st_winsys st_hardpipe_winsys = {
&st_hardpipe_screen_create
};

View File

@@ -1,141 +0,0 @@
/**************************************************************************
*
* 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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 above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
**************************************************************************/
/**
* @file
* Llvmpipe support.
*
* @author Jose Fonseca
*/
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "llvmpipe/lp_winsys.h"
#include "st_winsys.h"
static boolean
llvmpipe_ws_is_displaytarget_format_supported( struct llvmpipe_winsys *ws,
enum pipe_format format )
{
return FALSE;
}
static void *
llvmpipe_ws_displaytarget_map(struct llvmpipe_winsys *ws,
struct llvmpipe_displaytarget *dt,
unsigned flags )
{
assert(0);
return NULL;
}
static void
llvmpipe_ws_displaytarget_unmap(struct llvmpipe_winsys *ws,
struct llvmpipe_displaytarget *dt )
{
assert(0);
}
static void
llvmpipe_ws_displaytarget_destroy(struct llvmpipe_winsys *winsys,
struct llvmpipe_displaytarget *dt)
{
assert(0);
}
static struct llvmpipe_displaytarget *
llvmpipe_ws_displaytarget_create(struct llvmpipe_winsys *winsys,
enum pipe_format format,
unsigned width, unsigned height,
unsigned alignment,
unsigned *stride)
{
return NULL;
}
static void
llvmpipe_ws_displaytarget_display(struct llvmpipe_winsys *winsys,
struct llvmpipe_displaytarget *dt,
void *context_private)
{
assert(0);
}
static void
llvmpipe_ws_destroy(struct llvmpipe_winsys *winsys)
{
FREE(winsys);
}
static struct pipe_screen *
st_llvmpipe_screen_create(void)
{
static struct llvmpipe_winsys *winsys;
struct pipe_screen *screen;
winsys = CALLOC_STRUCT(llvmpipe_winsys);
if (!winsys)
goto no_winsys;
winsys->destroy = llvmpipe_ws_destroy;
winsys->is_displaytarget_format_supported = llvmpipe_ws_is_displaytarget_format_supported;
winsys->displaytarget_create = llvmpipe_ws_displaytarget_create;
winsys->displaytarget_map = llvmpipe_ws_displaytarget_map;
winsys->displaytarget_unmap = llvmpipe_ws_displaytarget_unmap;
winsys->displaytarget_display = llvmpipe_ws_displaytarget_display;
winsys->displaytarget_destroy = llvmpipe_ws_displaytarget_destroy;
screen = llvmpipe_create_screen(winsys);
if (!screen)
goto no_screen;
return screen;
no_screen:
FREE(winsys);
no_winsys:
return NULL;
}
const struct st_winsys st_softpipe_winsys = {
&st_llvmpipe_screen_create
};

View File

@@ -26,18 +26,45 @@
* *
**************************************************************************/ **************************************************************************/
/** #include "util/u_debug.h"
* @file #include "softpipe/sp_public.h"
* Softpipe support. #include "llvmpipe/lp_public.h"
* #include "state_tracker/sw_winsys.h"
* @author Keith Whitwell #include "null/null_sw_winsys.h"
* @author Brian Paul
* @author Jose Fonseca
*/
#include "softpipe/sp_winsys.h"
#include "st_winsys.h" #include "st_winsys.h"
const struct st_winsys st_softpipe_winsys = {
&softpipe_create_screen_malloc struct pipe_screen *
}; st_software_screen_create(void)
{
struct sw_winsys *ws;
const char *default_driver;
const char *driver;
struct pipe_screen *screen = NULL;
#if defined(HAVE_LLVMPIPE)
default_driver = "llvmpipe";
#elif defined(HAVE_SOFTPIPE)
default_driver = "softpipe";
#endif
ws = null_sw_create();
if(!ws)
return NULL;
driver = debug_get_option("GALLIUM_DRIVER", default_driver);
#ifdef HAVE_LLVMPIPE
if (strcmp(driver, "llvmpipe") == 0) {
screen = llvmpipe_create_screen(ws);
}
#endif
#ifdef HAVE_SOFTPIPE
if (strcmp(driver, "softpipe") == 0) {
screen = softpipe_create_screen(ws);
}
#endif
return screen;
}

View File

@@ -31,19 +31,13 @@
struct pipe_screen; struct pipe_screen;
struct pipe_context;
struct st_winsys
{
struct pipe_screen * struct pipe_screen *
(*screen_create)(void); st_hardware_screen_create(void);
};
struct pipe_screen *
extern const struct st_winsys st_softpipe_winsys; st_software_screen_create(void);
extern const struct st_winsys st_hardpipe_winsys;
#endif /* ST_WINSYS_H_ */ #endif /* ST_WINSYS_H_ */