Commit d60b2c68 authored by Jakob Bornecrantz's avatar Jakob Bornecrantz
Browse files

identity: Add new identity driver

	This driver does no transformation of the gallium calls
	going to the real driver, like the identity matrix. It is
	intended to be the basis for transforming and/or debug
	drivers like trace and rbug.

	Authors of this patch are:
		Michal Krol, orignal heavy lifting.
		José Fonesca, object wrapping code stolen from trace.
		Jakob Bornecrantz, put it all toghether and renamed a stuff.
parent b8e638d4
......@@ -32,10 +32,10 @@ import common
default_statetrackers = 'mesa'
if common.default_platform in ('linux', 'freebsd', 'darwin'):
default_drivers = 'softpipe,failover,i915simple,trace'
default_drivers = 'softpipe,failover,i915simple,trace,identity'
default_winsys = 'xlib'
elif common.default_platform in ('winddk',):
default_drivers = 'softpipe,i915simple,trace'
default_drivers = 'softpipe,i915simple,trace,identity'
default_winsys = 'all'
else:
default_drivers = 'all'
......@@ -46,7 +46,7 @@ common.AddOptions(opts)
opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
['mesa', 'python']))
opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300']))
['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300', 'identity']))
opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
['xlib', 'intel', 'gdi', 'radeon']))
......
......@@ -95,7 +95,7 @@ EGL_DRIVERS_DIRS = demo
GALLIUM_DIRS = auxiliary drivers state_trackers
GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
GALLIUM_DRIVERS_DIRS = softpipe i915simple failover trace
GALLIUM_DRIVERS_DIRS = softpipe i915simple failover trace identity
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
GALLIUM_WINSYS_DIRS = xlib egl_xlib
GALLIUM_WINSYS_DRM_DIRS =
......
......@@ -417,7 +417,7 @@ GALLIUM_DIRS="auxiliary drivers state_trackers"
GALLIUM_WINSYS_DIRS=""
GALLIUM_WINSYS_DRM_DIRS=""
GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices"
GALLIUM_DRIVERS_DIRS="softpipe failover trace"
GALLIUM_DRIVERS_DIRS="softpipe failover trace identity"
GALLIUM_STATE_TRACKERS_DIRS=""
case "$mesa_driver" in
......
TOP = ../../../..
include $(TOP)/configs/current
LIBNAME = identity
C_SOURCES = \
id_objects.c \
id_context.c \
id_screen.c
include ../../Makefile.template
Import('*')
env = env.Clone()
identity = env.ConvenienceLibrary(
target = 'identity',
source = [
'id_screen.c',
'id_context.c',
'id_objects.c',
])
Export('identity')
This diff is collapsed.
/**************************************************************************
*
* Copyright 2009 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 above copyright notice and this permission notice (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE 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.
*
**************************************************************************/
#ifndef ID_CONTEXT_H
#define ID_CONTEXT_H
#include "pipe/p_state.h"
#include "pipe/p_context.h"
struct identity_context {
struct pipe_context base; /**< base class */
struct pipe_context *pipe;
};
static INLINE struct identity_context *
identity_context(struct pipe_context *pipe)
{
return (struct identity_context *)pipe;
}
#endif /* ID_CONTEXT_H */
/**************************************************************************
*
* Copyright 2009 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 above copyright notice and this permission notice (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE 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.
*
**************************************************************************/
#include "util/u_memory.h"
#include "id_public.h"
#include "id_screen.h"
#include "id_objects.h"
struct pipe_buffer *
identity_buffer_create(struct identity_screen *id_screen,
struct pipe_buffer *buffer)
{
struct identity_buffer *id_buffer;
if(!buffer)
goto error;
assert(buffer->screen == id_screen->screen);
id_buffer = CALLOC_STRUCT(identity_buffer);
if(!id_buffer)
goto error;
memcpy(&id_buffer->base, buffer, sizeof(struct pipe_buffer));
pipe_reference_init(&id_buffer->base.reference, 1);
id_buffer->base.screen = &id_screen->base;
id_buffer->buffer = buffer;
return &id_buffer->base;
error:
pipe_buffer_reference(&buffer, NULL);
return NULL;
}
void
identity_buffer_destroy(struct identity_buffer *id_buffer)
{
pipe_buffer_reference(&id_buffer->buffer, NULL);
FREE(id_buffer);
}
struct pipe_texture *
identity_texture_create(struct identity_screen *id_screen,
struct pipe_texture *texture)
{
struct identity_texture *id_texture;
if(!texture)
goto error;
assert(texture->screen == id_screen->screen);
id_texture = CALLOC_STRUCT(identity_texture);
if(!id_texture)
goto error;
memcpy(&id_texture->base, texture, sizeof(struct pipe_texture));
pipe_reference_init(&id_texture->base.reference, 1);
id_texture->base.screen = &id_screen->base;
id_texture->texture = texture;
return &id_texture->base;
error:
pipe_texture_reference(&texture, NULL);
return NULL;
}
void
identity_texture_destroy(struct identity_texture *id_texture)
{
pipe_texture_reference(&id_texture->texture, NULL);
FREE(id_texture);
}
struct pipe_surface *
identity_surface_create(struct identity_texture *id_texture,
struct pipe_surface *surface)
{
struct identity_surface *id_surface;
if(!surface)
goto error;
assert(surface->texture == id_texture->texture);
id_surface = CALLOC_STRUCT(identity_surface);
if(!id_surface)
goto error;
memcpy(&id_surface->base, surface, sizeof(struct pipe_surface));
pipe_reference_init(&id_surface->base.reference, 1);
id_surface->base.texture = NULL;
pipe_texture_reference(&id_surface->base.texture, &id_texture->base);
id_surface->surface = surface;
return &id_surface->base;
error:
pipe_surface_reference(&surface, NULL);
return NULL;
}
void
identity_surface_destroy(struct identity_surface *id_surface)
{
pipe_texture_reference(&id_surface->base.texture, NULL);
pipe_surface_reference(&id_surface->surface, NULL);
FREE(id_surface);
}
struct pipe_transfer *
identity_transfer_create(struct identity_texture *id_texture,
struct pipe_transfer *transfer)
{
struct identity_transfer *id_transfer;
if(!transfer)
goto error;
assert(transfer->texture == id_texture->texture);
id_transfer = CALLOC_STRUCT(identity_transfer);
if(!id_transfer)
goto error;
memcpy(&id_transfer->base, transfer, sizeof(struct pipe_transfer));
id_transfer->base.texture = NULL;
pipe_texture_reference(&id_transfer->base.texture, &id_texture->base);
id_transfer->transfer = transfer;
assert(id_transfer->base.texture == &id_texture->base);
return &id_transfer->base;
error:
transfer->texture->screen->tex_transfer_destroy(transfer);
return NULL;
}
void
identity_transfer_destroy(struct identity_transfer *id_transfer)
{
struct identity_screen *id_screen = identity_screen(id_transfer->base.texture->screen);
struct pipe_screen *screen = id_screen->screen;
pipe_texture_reference(&id_transfer->base.texture, NULL);
screen->tex_transfer_destroy(id_transfer->transfer);
FREE(id_transfer);
}
/**************************************************************************
*
* Copyright 2009 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 above copyright notice and this permission notice (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE 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.
*
**************************************************************************/
#ifndef ID_OBJECTS_H
#define ID_OBJECTS_H
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
#include "id_screen.h"
struct identity_buffer
{
struct pipe_buffer base;
struct pipe_buffer *buffer;
};
struct identity_texture
{
struct pipe_texture base;
struct pipe_texture *texture;
};
struct identity_surface
{
struct pipe_surface base;
struct pipe_surface *surface;
};
struct identity_transfer
{
struct pipe_transfer base;
struct pipe_transfer *transfer;
};
static INLINE struct identity_buffer *
identity_buffer(struct pipe_buffer *_buffer)
{
if(!_buffer)
return NULL;
(void)identity_screen(_buffer->screen);
return (struct identity_buffer *)_buffer;
}
static INLINE struct identity_texture *
identity_texture(struct pipe_texture *_texture)
{
if(!_texture)
return NULL;
(void)identity_screen(_texture->screen);
return (struct identity_texture *)_texture;
}
static INLINE struct identity_surface *
identity_surface(struct pipe_surface *_surface)
{
if(!_surface)
return NULL;
(void)identity_texture(_surface->texture);
return (struct identity_surface *)_surface;
}
static INLINE struct identity_transfer *
identity_transfer(struct pipe_transfer *_transfer)
{
if(!_transfer)
return NULL;
(void)identity_texture(_transfer->texture);
return (struct identity_transfer *)_transfer;
}
static INLINE struct pipe_buffer *
identity_buffer_unwrap(struct pipe_buffer *_buffer)
{
if(!_buffer)
return NULL;
return identity_buffer(_buffer)->buffer;
}
static INLINE struct pipe_texture *
identity_texture_unwrap(struct pipe_texture *_texture)
{
if(!_texture)
return NULL;
return identity_texture(_texture)->texture;
}
static INLINE struct pipe_surface *
identity_surface_unwrap(struct pipe_surface *_surface)
{
if(!_surface)
return NULL;
return identity_surface(_surface)->surface;
}
static INLINE struct pipe_transfer *
identity_transfer_unwrap(struct pipe_transfer *_transfer)
{
if(!_transfer)
return NULL;
return identity_transfer(_transfer)->transfer;
}
struct pipe_buffer *
identity_buffer_create(struct identity_screen *id_screen,
struct pipe_buffer *buffer);
void
identity_buffer_destroy(struct identity_buffer *id_buffer);
struct pipe_texture *
identity_texture_create(struct identity_screen *id_screen,
struct pipe_texture *texture);
void
identity_texture_destroy(struct identity_texture *id_texture);
struct pipe_surface *
identity_surface_create(struct identity_texture *id_texture,
struct pipe_surface *surface);
void
identity_surface_destroy(struct identity_surface *id_surface);
struct pipe_transfer *
identity_transfer_create(struct identity_texture *id_texture,
struct pipe_transfer *transfer);
void
identity_transfer_destroy(struct identity_transfer *id_transfer);
#endif /* ID_OBJECTS_H */
/**************************************************************************
*
* Copyright 2009 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 above copyright notice and this permission notice (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE 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.
*
**************************************************************************/
#ifndef ID_PUBLIC_H
#define ID_PUBLIC_H
struct pipe_screen;
struct pipe_context;
struct pipe_screen *
identity_screen_create(struct pipe_screen *screen);
struct pipe_context *
identity_context_create(struct pipe_screen *screen, struct pipe_context *pipe);
#endif /* PT_PUBLIC_H */
/**************************************************************************
*
* Copyright 2009 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 above copyright notice and this permission notice (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE 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.
*
**************************************************************************/
#include "pipe/p_screen.h"
#include "pipe/p_state.h"
#include "util/u_memory.h"
#include "id_public.h"
#include "id_screen.h"
#include "id_objects.h"
static void
identity_screen_destroy(struct pipe_screen *_screen)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
screen->destroy(screen);
FREE(id_screen);
}
static const char *
identity_screen_get_name(struct pipe_screen *_screen)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
return screen->get_name(screen);
}
static const char *
identity_screen_get_vendor(struct pipe_screen *_screen)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
return screen->get_vendor(screen);
}
static int
identity_screen_get_param(struct pipe_screen *_screen,
int param)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
return screen->get_param(screen,
param);
}
static float
identity_screen_get_paramf(struct pipe_screen *_screen,
int param)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
return screen->get_paramf(screen,
param);
}
static boolean
identity_screen_is_format_supported(struct pipe_screen *_screen,
enum pipe_format format,
enum pipe_texture_target target,
unsigned tex_usage,
unsigned geom_flags)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
return screen->is_format_supported(screen,
format,
target,
tex_usage,
geom_flags);
}
static struct pipe_texture *
identity_screen_texture_create(struct pipe_screen *_screen,