From 80672e84cf79ab12b7a4ff56567184d1c39baef3 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 18:51:52 +0100 Subject: st/dri: Move common files to common directory 27 files changed, 15 insertions(+), 15 deletions(-) rename src/gallium/state_trackers/dri/{ => common}/dri1_helper.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri1_helper.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_context.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_context.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_drawable.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_drawable.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_extensions.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_screen.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_screen.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_st_api.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_st_api.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_wrapper.h (100%) --- .../state_trackers/dri/common/dri1_helper.c | 129 +++++++ .../state_trackers/dri/common/dri1_helper.h | 61 ++++ .../state_trackers/dri/common/dri_context.c | 174 ++++++++++ .../state_trackers/dri/common/dri_context.h | 97 ++++++ .../state_trackers/dri/common/dri_drawable.c | 94 ++++++ .../state_trackers/dri/common/dri_drawable.h | 89 +++++ .../state_trackers/dri/common/dri_extensions.c | 48 +++ src/gallium/state_trackers/dri/common/dri_screen.c | 373 +++++++++++++++++++++ src/gallium/state_trackers/dri/common/dri_screen.h | 114 +++++++ src/gallium/state_trackers/dri/common/dri_st_api.c | 263 +++++++++++++++ src/gallium/state_trackers/dri/common/dri_st_api.h | 55 +++ .../state_trackers/dri/common/dri_wrapper.h | 10 + src/gallium/state_trackers/dri/dri1_helper.c | 129 ------- src/gallium/state_trackers/dri/dri1_helper.h | 61 ---- src/gallium/state_trackers/dri/dri_context.c | 174 ---------- src/gallium/state_trackers/dri/dri_context.h | 97 ------ src/gallium/state_trackers/dri/dri_drawable.c | 94 ------ src/gallium/state_trackers/dri/dri_drawable.h | 89 ----- src/gallium/state_trackers/dri/dri_extensions.c | 48 --- src/gallium/state_trackers/dri/dri_screen.c | 373 --------------------- src/gallium/state_trackers/dri/dri_screen.h | 114 ------- src/gallium/state_trackers/dri/dri_st_api.c | 263 --------------- src/gallium/state_trackers/dri/dri_st_api.h | 55 --- src/gallium/state_trackers/dri/dri_wrapper.h | 10 - src/gallium/state_trackers/dri/drm/Makefile | 2 +- src/gallium/state_trackers/dri/drm/SConscript | 2 +- src/gallium/state_trackers/dri/drm/dri1_helper.c | 2 +- src/gallium/state_trackers/dri/drm/dri_context.c | 2 +- src/gallium/state_trackers/dri/drm/dri_drawable.c | 2 +- .../state_trackers/dri/drm/dri_extensions.c | 2 +- src/gallium/state_trackers/dri/drm/dri_screen.c | 2 +- src/gallium/state_trackers/dri/drm/dri_st_api.c | 2 +- src/gallium/state_trackers/dri/sw/Makefile | 2 +- src/gallium/state_trackers/dri/sw/dri1_helper.c | 2 +- src/gallium/state_trackers/dri/sw/dri_context.c | 2 +- src/gallium/state_trackers/dri/sw/dri_drawable.c | 2 +- src/gallium/state_trackers/dri/sw/dri_extensions.c | 2 +- src/gallium/state_trackers/dri/sw/dri_screen.c | 2 +- src/gallium/state_trackers/dri/sw/dri_st_api.c | 2 +- 39 files changed, 1522 insertions(+), 1522 deletions(-) create mode 100644 src/gallium/state_trackers/dri/common/dri1_helper.c create mode 100644 src/gallium/state_trackers/dri/common/dri1_helper.h create mode 100644 src/gallium/state_trackers/dri/common/dri_context.c create mode 100644 src/gallium/state_trackers/dri/common/dri_context.h create mode 100644 src/gallium/state_trackers/dri/common/dri_drawable.c create mode 100644 src/gallium/state_trackers/dri/common/dri_drawable.h create mode 100644 src/gallium/state_trackers/dri/common/dri_extensions.c create mode 100644 src/gallium/state_trackers/dri/common/dri_screen.c create mode 100644 src/gallium/state_trackers/dri/common/dri_screen.h create mode 100644 src/gallium/state_trackers/dri/common/dri_st_api.c create mode 100644 src/gallium/state_trackers/dri/common/dri_st_api.h create mode 100644 src/gallium/state_trackers/dri/common/dri_wrapper.h delete mode 100644 src/gallium/state_trackers/dri/dri1_helper.c delete mode 100644 src/gallium/state_trackers/dri/dri1_helper.h delete mode 100644 src/gallium/state_trackers/dri/dri_context.c delete mode 100644 src/gallium/state_trackers/dri/dri_context.h delete mode 100644 src/gallium/state_trackers/dri/dri_drawable.c delete mode 100644 src/gallium/state_trackers/dri/dri_drawable.h delete mode 100644 src/gallium/state_trackers/dri/dri_extensions.c delete mode 100644 src/gallium/state_trackers/dri/dri_screen.c delete mode 100644 src/gallium/state_trackers/dri/dri_screen.h delete mode 100644 src/gallium/state_trackers/dri/dri_st_api.c delete mode 100644 src/gallium/state_trackers/dri/dri_st_api.h delete mode 100644 src/gallium/state_trackers/dri/dri_wrapper.h (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/common/dri1_helper.c b/src/gallium/state_trackers/dri/common/dri1_helper.c new file mode 100644 index 00000000000..7eeb868d422 --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri1_helper.c @@ -0,0 +1,129 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ +/* + * Management of pipe objects (surface / pipe / fences) used by DRI1 and DRISW. + * + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "util/u_inlines.h" +#include "pipe/p_context.h" + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri1_helper.h" + +struct pipe_fence_handle * +dri1_swap_fences_pop_front(struct dri_drawable *draw) +{ + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + struct pipe_fence_handle *fence = NULL; + + if (draw->cur_fences >= draw->desired_fences) { + screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]); + screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL); + --draw->cur_fences; + draw->tail &= DRI_SWAP_FENCES_MASK; + } + return fence; +} + +void +dri1_swap_fences_push_back(struct dri_drawable *draw, + struct pipe_fence_handle *fence) +{ + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + + if (!fence) + return; + + if (draw->cur_fences < DRI_SWAP_FENCES_MAX) { + draw->cur_fences++; + screen->fence_reference(screen, &draw->swap_fences[draw->head++], + fence); + draw->head &= DRI_SWAP_FENCES_MASK; + } +} + +void +dri1_swap_fences_clear(struct dri_drawable *drawable) +{ + struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; + struct pipe_fence_handle *fence; + + while (drawable->cur_fences) { + fence = dri1_swap_fences_pop_front(drawable); + screen->fence_reference(screen, &fence, NULL); + } +} + +struct pipe_surface * +dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex) +{ + struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->pipe_screen; + struct pipe_surface *psurf = drawable->dri1_surface; + + if (!psurf || psurf->texture != ptex) { + pipe_surface_reference(&drawable->dri1_surface, NULL); + + drawable->dri1_surface = pipe_screen->get_tex_surface(pipe_screen, + ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); + + psurf = drawable->dri1_surface; + } + + return psurf; +} + +void +dri1_destroy_pipe_surface(struct dri_drawable *drawable) +{ + pipe_surface_reference(&drawable->dri1_surface, NULL); +} + +struct pipe_context * +dri1_get_pipe_context(struct dri_screen *screen) +{ + struct pipe_context *pipe = screen->dri1_pipe; + + if (!pipe) { + screen->dri1_pipe = + screen->pipe_screen->context_create(screen->pipe_screen, NULL); + pipe = screen->dri1_pipe; + } + + return pipe; +} + +void +dri1_destroy_pipe_context(struct dri_screen *screen) +{ + if (screen->dri1_pipe) + screen->dri1_pipe->destroy(screen->dri1_pipe); +} diff --git a/src/gallium/state_trackers/dri/common/dri1_helper.h b/src/gallium/state_trackers/dri/common/dri1_helper.h new file mode 100644 index 00000000000..3254b7ff872 --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri1_helper.h @@ -0,0 +1,61 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#ifndef DRI1_HELPER_H +#define DRI1_HELPER_H + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" + +struct pipe_fence_handle * +dri1_swap_fences_pop_front(struct dri_drawable *draw); + +void +dri1_swap_fences_push_back(struct dri_drawable *draw, + struct pipe_fence_handle *fence); + +void +dri1_swap_fences_clear(struct dri_drawable *drawable); + +struct pipe_surface * +dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex); + +void +dri1_destroy_pipe_surface(struct dri_drawable *drawable); + +struct pipe_context * +dri1_get_pipe_context(struct dri_screen *screen); + +void +dri1_destroy_pipe_context(struct dri_screen *screen); + +#endif /* DRI1_HELPER_H */ diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c new file mode 100644 index 00000000000..34d9a932ead --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_context.c @@ -0,0 +1,174 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "dri_screen.h" +#include "dri_drawable.h" +#include "dri_context.h" +#include "dri_st_api.h" + +#include "pipe/p_context.h" +#include "util/u_memory.h" + +GLboolean +dri_create_context(const __GLcontextModes * visual, + __DRIcontext * cPriv, void *sharedContextPrivate) +{ + struct st_api *stapi = dri_get_st_api(); + __DRIscreen *sPriv = cPriv->driScreenPriv; + struct dri_screen *screen = dri_screen(sPriv); + struct dri_context *ctx = NULL; + struct st_context_iface *st_share = NULL; + struct st_visual stvis; + + if (sharedContextPrivate) { + st_share = ((struct dri_context *)sharedContextPrivate)->st; + } + + ctx = CALLOC_STRUCT(dri_context); + if (ctx == NULL) + goto fail; + + cPriv->driverPrivate = ctx; + ctx->cPriv = cPriv; + ctx->sPriv = sPriv; + ctx->lock = screen->drmLock; + + driParseConfigFiles(&ctx->optionCache, + &screen->optionCache, sPriv->myNum, "dri"); + + dri_fill_st_visual(&stvis, screen, visual); + ctx->st = stapi->create_context(stapi, screen->smapi, &stvis, st_share); + if (ctx->st == NULL) + goto fail; + ctx->st->st_manager_private = (void *) ctx; + + dri_init_extensions(ctx); + + return GL_TRUE; + + fail: + if (ctx && ctx->st) + ctx->st->destroy(ctx->st); + + FREE(ctx); + return FALSE; +} + +void +dri_destroy_context(__DRIcontext * cPriv) +{ + struct dri_context *ctx = dri_context(cPriv); + + /* note: we are freeing values and nothing more because + * driParseConfigFiles allocated values only - the rest + * is owned by screen optionCache. + */ + FREE(ctx->optionCache.values); + + /* No particular reason to wait for command completion before + * destroying a context, but it is probably worthwhile flushing it + * to avoid having to add code elsewhere to cope with flushing a + * partially destroyed context. + */ + ctx->st->flush(ctx->st, 0, NULL); + ctx->st->destroy(ctx->st); + + FREE(ctx); +} + +GLboolean +dri_unbind_context(__DRIcontext * cPriv) +{ + struct st_api *stapi = dri_get_st_api(); + + if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + + if (--ctx->bind_count == 0) { + if (ctx->st == stapi->get_current(stapi)) { + ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + stapi->make_current(stapi, NULL, NULL, NULL); + } + } + } + + return GL_TRUE; +} + +GLboolean +dri_make_current(__DRIcontext * cPriv, + __DRIdrawable * driDrawPriv, + __DRIdrawable * driReadPriv) +{ + struct st_api *stapi = dri_get_st_api(); + + if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + struct dri_drawable *draw = dri_drawable(driDrawPriv); + struct dri_drawable *read = dri_drawable(driReadPriv); + struct st_context_iface *old_st; + + old_st = stapi->get_current(stapi); + if (old_st && old_st != ctx->st) + ctx->st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL); + + ++ctx->bind_count; + + if (ctx->dPriv != driDrawPriv) { + ctx->dPriv = driDrawPriv; + draw->texture_stamp = driDrawPriv->lastStamp - 1; + } + if (ctx->rPriv != driReadPriv) { + ctx->rPriv = driReadPriv; + read->texture_stamp = driReadPriv->lastStamp - 1; + } + + stapi->make_current(stapi, ctx->st, draw->stfb, read->stfb); + } + else { + stapi->make_current(stapi, NULL, NULL, NULL); + } + + return GL_TRUE; +} + +struct dri_context * +dri_get_current(void) +{ + struct st_api *stapi = dri_get_st_api(); + struct st_context_iface *st; + + st = stapi->get_current(stapi); + + return (struct dri_context *) (st) ? st->st_manager_private : NULL; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_context.h b/src/gallium/state_trackers/dri/common/dri_context.h new file mode 100644 index 00000000000..24d3d0368a4 --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_context.h @@ -0,0 +1,97 @@ +/************************************************************************** + * + * Copyright (C) 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#ifndef DRI_CONTEXT_H +#define DRI_CONTEXT_H + +#include "pipe/p_compiler.h" +#include "dri_wrapper.h" + +struct pipe_context; +struct pipe_fence; +struct st_context; +struct dri_drawable; + +struct dri_context +{ + /* dri */ + __DRIscreen *sPriv; + __DRIcontext *cPriv; + __DRIdrawable *dPriv; + __DRIdrawable *rPriv; + + driOptionCache optionCache; + + drmLock *lock; + boolean isLocked; + boolean stLostLock; + boolean wsLostLock; + + unsigned int bind_count; + + /* gallium */ + struct st_context_iface *st; +}; + +static INLINE struct dri_context * +dri_context(__DRIcontext * driContextPriv) +{ + return (struct dri_context *)driContextPriv->driverPrivate; +} + +/*********************************************************************** + * dri_context.c + */ +void dri_destroy_context(__DRIcontext * driContextPriv); + +boolean dri_unbind_context(__DRIcontext * driContextPriv); + +boolean +dri_make_current(__DRIcontext * driContextPriv, + __DRIdrawable * driDrawPriv, + __DRIdrawable * driReadPriv); + +struct dri_context * +dri_get_current(void); + +boolean +dri_create_context(const __GLcontextModes * visual, + __DRIcontext * driContextPriv, + void *sharedContextPrivate); + +/*********************************************************************** + * dri_extensions.c + */ +void dri_init_extensions(struct dri_context *ctx); + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c new file mode 100644 index 00000000000..75b4cc56289 --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_drawable.c @@ -0,0 +1,94 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri_st_api.h" +#include "dri1_helper.h" + +#include "pipe/p_screen.h" +#include "util/u_format.h" +#include "util/u_memory.h" +#include "util/u_inlines.h" + +/** + * This is called when we need to set up GL rendering to a new X window. + */ +boolean +dri_create_buffer(__DRIscreen * sPriv, + __DRIdrawable * dPriv, + const __GLcontextModes * visual, boolean isPixmap) +{ + struct dri_screen *screen = sPriv->private; + struct dri_drawable *drawable = NULL; + + if (isPixmap) + goto fail; /* not implemented */ + + drawable = CALLOC_STRUCT(dri_drawable); + if (drawable == NULL) + goto fail; + + dri_fill_st_visual(&drawable->stvis, screen, visual); + drawable->stfb = dri_create_st_framebuffer(drawable); + if (drawable->stfb == NULL) + goto fail; + + drawable->sPriv = sPriv; + drawable->dPriv = dPriv; + dPriv->driverPrivate = (void *)drawable; + + drawable->desired_fences = 2; + + return GL_TRUE; +fail: + FREE(drawable); + return GL_FALSE; +} + +void +dri_destroy_buffer(__DRIdrawable * dPriv) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + + dri1_swap_fences_clear(drawable); + + dri1_destroy_pipe_surface(drawable); + + dri_destroy_st_framebuffer(drawable->stfb); + + drawable->desired_fences = 0; + + FREE(drawable); +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h new file mode 100644 index 00000000000..98abeb9ec05 --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_drawable.h @@ -0,0 +1,89 @@ +/************************************************************************** + * + * 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 DRI_DRAWABLE_H +#define DRI_DRAWABLE_H + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "state_tracker/st_api.h" + +struct pipe_surface; +struct pipe_fence_handle; +struct st_framebuffer; +struct dri_context; + +#define DRI_SWAP_FENCES_MAX 8 +#define DRI_SWAP_FENCES_MASK 7 + +struct dri_drawable +{ + /* dri */ + __DRIdrawable *dPriv; + __DRIscreen *sPriv; + + /* gallium */ + struct st_framebuffer_iface *stfb; + struct st_visual stvis; + + __DRIbuffer old[8]; + unsigned old_num; + unsigned old_w; + unsigned old_h; + + struct pipe_texture *textures[ST_ATTACHMENT_COUNT]; + unsigned int texture_mask, texture_stamp; + + struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX]; + unsigned int head; + unsigned int tail; + unsigned int desired_fences; + unsigned int cur_fences; + + /* used only by DRI1 */ + struct pipe_surface *dri1_surface; +}; + +static INLINE struct dri_drawable * +dri_drawable(__DRIdrawable * driDrawPriv) +{ + return (struct dri_drawable *)driDrawPriv->driverPrivate; +} + +/*********************************************************************** + * dri_drawable.c + */ +boolean +dri_create_buffer(__DRIscreen * sPriv, + __DRIdrawable * dPriv, + const __GLcontextModes * visual, boolean isPixmap); + +void dri_destroy_buffer(__DRIdrawable * dPriv); + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_extensions.c b/src/gallium/state_trackers/dri/common/dri_extensions.c new file mode 100644 index 00000000000..df458e1eb0f --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_extensions.c @@ -0,0 +1,48 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "dri_screen.h" +#include "dri_context.h" +#include "state_tracker/st_context.h" + +#include "utils.h" + +void +dri_init_extensions(struct dri_context *ctx) +{ + struct st_context *st = (struct st_context *) ctx->st; + + /* New extensions should be added in mesa/state_tracker/st_extensions.c + * and not in this file. */ + driInitExtensions(st->ctx, NULL, GL_FALSE); +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c new file mode 100644 index 00000000000..598a07bb646 --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -0,0 +1,373 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "utils.h" +#ifndef __NOT_HAVE_DRM_H +#include "vblank.h" +#endif +#include "xmlpool.h" + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri_st_api.h" +#include "dri1_helper.h" +#ifndef __NOT_HAVE_DRM_H +#include "dri1.h" +#include "dri2.h" +#else +#include "drisw.h" +#endif + +#include "util/u_inlines.h" +#include "pipe/p_screen.h" +#include "pipe/p_format.h" +#include "state_tracker/drm_api.h" + +#include "util/u_debug.h" + +PUBLIC const char __driConfigOptions[] = + DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE + DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) + DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) + DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY +/* DRI_CONF_FORCE_S3TC_ENABLE(false) */ + DRI_CONF_ALLOW_LARGE_TEXTURES(1) + DRI_CONF_SECTION_END DRI_CONF_END; + +const uint __driNConfigOptions = 3; + +const __DRIconfig ** +dri_fill_in_modes(struct dri_screen *screen, + unsigned pixel_bits) +{ + __DRIconfig **configs = NULL; + __DRIconfig **configs_r5g6b5 = NULL; + __DRIconfig **configs_a8r8g8b8 = NULL; + __DRIconfig **configs_x8r8g8b8 = NULL; + unsigned num_modes; + uint8_t depth_bits_array[5]; + uint8_t stencil_bits_array[5]; + uint8_t msaa_samples_array[2]; + unsigned depth_buffer_factor; + unsigned back_buffer_factor; + unsigned msaa_samples_factor; + struct pipe_screen *p_screen = screen->pipe_screen; + boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8; + boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32; + + static const GLenum back_buffer_modes[] = { + GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML + }; + + depth_bits_array[0] = 0; + stencil_bits_array[0] = 0; + depth_buffer_factor = 1; + + pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); + pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); + pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); + pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); + pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); + pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); + pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); + + /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */ + if (dri_with_format(screen->sPriv)) { + pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); + pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); + } else { + pf_z16 = FALSE; + pf_z32 = FALSE; + } + + if (pf_z16) { + depth_bits_array[depth_buffer_factor] = 16; + stencil_bits_array[depth_buffer_factor++] = 0; + } + if (pf_x8z24 || pf_z24x8) { + depth_bits_array[depth_buffer_factor] = 24; + stencil_bits_array[depth_buffer_factor++] = 0; + screen->d_depth_bits_last = pf_x8z24; + } + if (pf_s8z24 || pf_z24s8) { + depth_bits_array[depth_buffer_factor] = 24; + stencil_bits_array[depth_buffer_factor++] = 8; + screen->sd_depth_bits_last = pf_s8z24; + } + if (pf_z32) { + depth_bits_array[depth_buffer_factor] = 32; + stencil_bits_array[depth_buffer_factor++] = 0; + } + + msaa_samples_array[0] = 0; + msaa_samples_array[1] = 4; + back_buffer_factor = 3; + msaa_samples_factor = 2; + + num_modes = + depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; + + if (pf_r5g6b5) + configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5, + depth_bits_array, stencil_bits_array, + depth_buffer_factor, back_buffer_modes, + back_buffer_factor, + msaa_samples_array, msaa_samples_factor, + GL_TRUE); + + if (pf_a8r8g8b8) + configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, + depth_bits_array, + stencil_bits_array, + depth_buffer_factor, + back_buffer_modes, + back_buffer_factor, + msaa_samples_array, + msaa_samples_factor, + GL_TRUE); + + if (pf_x8r8g8b8) + configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV, + depth_bits_array, + stencil_bits_array, + depth_buffer_factor, + back_buffer_modes, + back_buffer_factor, + msaa_samples_array, + msaa_samples_factor, + GL_TRUE); + + if (pixel_bits == 16) { + configs = configs_r5g6b5; + if (configs_a8r8g8b8) + configs = configs ? driConcatConfigs(configs, configs_a8r8g8b8) : configs_a8r8g8b8; + if (configs_x8r8g8b8) + configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8; + } else { + configs = configs_a8r8g8b8; + if (configs_x8r8g8b8) + configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8; + if (configs_r5g6b5) + configs = configs ? driConcatConfigs(configs, configs_r5g6b5) : configs_r5g6b5; + } + + if (configs == NULL) { + debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__); + return NULL; + } + + return (const __DRIconfig **)configs; +} + +/** + * Roughly the converse of dri_fill_in_modes. + */ +void +dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, + const __GLcontextModes *mode) +{ + memset(stvis, 0, sizeof(*stvis)); + + stvis->samples = mode->samples; + stvis->render_buffer = ST_ATTACHMENT_INVALID; + + if (mode->redBits == 8) { + if (mode->alphaBits == 8) + stvis->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; + else + stvis->color_format = PIPE_FORMAT_B8G8R8X8_UNORM; + } else { + stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM; + } + + switch (mode->depthBits) { + default: + case 0: + stvis->depth_stencil_format = PIPE_FORMAT_NONE; + break; + case 16: + stvis->depth_stencil_format = PIPE_FORMAT_Z16_UNORM; + break; + case 24: + if (mode->stencilBits == 0) { + stvis->depth_stencil_format = (screen->d_depth_bits_last) ? + PIPE_FORMAT_Z24X8_UNORM: + PIPE_FORMAT_X8Z24_UNORM; + } else { + stvis->depth_stencil_format = (screen->sd_depth_bits_last) ? + PIPE_FORMAT_Z24S8_UNORM: + PIPE_FORMAT_S8Z24_UNORM; + } + break; + case 32: + stvis->depth_stencil_format = PIPE_FORMAT_Z32_UNORM; + break; + } + + stvis->accum_format = (mode->haveAccumBuffer) ? + PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE; + + stvis->buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK; + if (mode->doubleBufferMode) + stvis->buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK; + if (mode->stereoMode) { + stvis->buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK; + if (mode->doubleBufferMode) + stvis->buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK; + } + + if (mode->haveDepthBuffer || mode->haveStencilBuffer) + stvis->buffer_mask |= ST_ATTACHMENT_DEPTH_STENCIL_MASK; + /* let the state tracker allocate the accum buffer */ +} + +#ifndef __NOT_HAVE_DRM_H + +/** + * Get information about previous buffer swaps. + */ +static int +dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo) +{ + if (dPriv == NULL || dPriv->driverPrivate == NULL || sInfo == NULL) + return -1; + else + return 0; +} + +#endif + +static void +dri_destroy_option_cache(struct dri_screen * screen) +{ + int i; + + for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) { + FREE(screen->optionCache.info[i].name); + FREE(screen->optionCache.info[i].ranges); + } + + FREE(screen->optionCache.info); + FREE(screen->optionCache.values); +} + +void +dri_destroy_screen(__DRIscreen * sPriv) +{ + struct dri_screen *screen = dri_screen(sPriv); + + dri1_destroy_pipe_context(screen); + + if (screen->smapi) + dri_destroy_st_manager(screen->smapi); + + if (screen->pipe_screen) + screen->pipe_screen->destroy(screen->pipe_screen); + + dri_destroy_option_cache(screen); + + FREE(screen); + sPriv->private = NULL; + sPriv->extensions = NULL; +} + +#ifndef __NOT_HAVE_DRM_H + +const struct __DriverAPIRec driDriverAPI = { + .DestroyScreen = dri_destroy_screen, + .CreateContext = dri_create_context, + .DestroyContext = dri_destroy_context, + .CreateBuffer = dri_create_buffer, + .DestroyBuffer = dri_destroy_buffer, + .MakeCurrent = dri_make_current, + .UnbindContext = dri_unbind_context, + .GetSwapInfo = dri_get_swap_info, + .GetDrawableMSC = driDrawableGetMSC32, + .WaitForMSC = driWaitForMSC32, + .InitScreen2 = dri2_init_screen, + + .InitScreen = dri1_init_screen, + .SwapBuffers = dri1_swap_buffers, + .CopySubBuffer = dri1_copy_sub_buffer, +}; + +/* This is the table of extensions that the loader will dlsym() for. */ +PUBLIC const __DRIextension *__driDriverExtensions[] = { + &driCoreExtension.base, + &driLegacyExtension.base, + &driDRI2Extension.base, + NULL +}; + +#else + +const struct __DriverAPIRec driDriverAPI = { + .DestroyScreen = dri_destroy_screen, + .CreateContext = dri_create_context, + .DestroyContext = dri_destroy_context, + .CreateBuffer = dri_create_buffer, + .DestroyBuffer = dri_destroy_buffer, + .MakeCurrent = dri_make_current, + .UnbindContext = dri_unbind_context, + + .InitScreen = drisw_init_screen, + .SwapBuffers = drisw_swap_buffers, +}; + +/* This is the table of extensions that the loader will dlsym() for. */ +PUBLIC const __DRIextension *__driDriverExtensions[] = { + &driCoreExtension.base, + &driSWRastExtension.base, + NULL +}; + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h new file mode 100644 index 00000000000..4f59db37cfa --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -0,0 +1,114 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#ifndef DRI_SCREEN_H +#define DRI_SCREEN_H + +#include "dri_wrapper.h" +#include "xmlconfig.h" + +#include "pipe/p_compiler.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "state_tracker/st_api.h" + +struct dri_screen +{ + /* dri */ + __DRIscreen *sPriv; + + /** + * Configuration cache with default values for all contexts + */ + driOptionCache optionCache; + + /* drm */ + int fd; + drmLock *drmLock; + + /* gallium */ + struct drm_api *api; + struct pipe_winsys *pipe_winsys; + struct pipe_screen *pipe_screen; + boolean d_depth_bits_last; + boolean sd_depth_bits_last; + boolean auto_fake_front; + + struct st_manager *smapi; + + /* used only by DRI1 */ + struct pipe_context *dri1_pipe; +}; + +/** cast wrapper */ +static INLINE struct dri_screen * +dri_screen(__DRIscreen * sPriv) +{ + return (struct dri_screen *)sPriv->private; +} + +#ifndef __NOT_HAVE_DRM_H + +static INLINE boolean +dri_with_format(__DRIscreen * sPriv) +{ + const __DRIdri2LoaderExtension *loader = sPriv->dri2.loader; + + return loader + && (loader->base.version >= 3) + && (loader->getBuffersWithFormat != NULL); +} + +#else + +static INLINE boolean +dri_with_format(__DRIscreen * sPriv) +{ + return TRUE; +} + +#endif + +extern const uint __driNConfigOptions; + +const __DRIconfig ** +dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits); + +void +dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, + const __GLcontextModes *mode); + +void +dri_destroy_screen(__DRIscreen * sPriv); + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c new file mode 100644 index 00000000000..40b24b18e9f --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_st_api.c @@ -0,0 +1,263 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 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 + * 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. + * + * Authors: + * Chia-I Wu + */ + +#include "util/u_memory.h" +#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_debug.h" +#include "state_tracker/st_manager.h" /* for st_manager_create_api */ + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri_st_api.h" +#include "dri1_helper.h" +#ifndef __NOT_HAVE_DRM_H +#include "dri1.h" +#include "dri2.h" +#else +#include "drisw.h" +#endif + +static boolean +dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, + const enum st_attachment_type *statts, + unsigned count, + struct pipe_texture **out) +{ + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + unsigned statt_mask, new_mask; + boolean new_stamp; + int i; + + statt_mask = 0x0; + for (i = 0; i < count; i++) + statt_mask |= (1 << statts[i]); + + /* record newly allocated textures */ + new_mask = (statt_mask & ~drawable->texture_mask); + + /* + * dPriv->pStamp is the server stamp. It should be accessed with a lock, at + * least for DRI1. dPriv->lastStamp is the client stamp. It has the value + * of the server stamp when last checked. + */ + new_stamp = (drawable->texture_stamp != drawable->dPriv->lastStamp); + + if (new_stamp || new_mask) { + +#ifndef __NOT_HAVE_DRM_H + if (__dri1_api_hooks) { + dri1_allocate_textures(drawable, statt_mask); + } + else { + dri2_allocate_textures(drawable, statts, count); + } +#else + if (new_stamp) + drisw_update_drawable_info(drawable->dPriv); + + drisw_allocate_textures(drawable, statt_mask); +#endif + + /* add existing textures */ + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + if (drawable->textures[i]) + statt_mask |= (1 << i); + } + + drawable->texture_stamp = drawable->dPriv->lastStamp; + drawable->texture_mask = statt_mask; + } + + if (!out) + return TRUE; + + for (i = 0; i < count; i++) { + out[i] = NULL; + pipe_texture_reference(&out[i], drawable->textures[statts[i]]); + } + + return TRUE; +} + +static boolean +dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt) +{ + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + +#ifndef __NOT_HAVE_DRM_H + if (__dri1_api_hooks) { + dri1_flush_frontbuffer(drawable, statt); + } + else { + dri2_flush_frontbuffer(drawable, statt); + } +#else + drisw_flush_frontbuffer(drawable, statt); +#endif + + return TRUE; +} + +/** + * Create a framebuffer from the given drawable. + */ +struct st_framebuffer_iface * +dri_create_st_framebuffer(struct dri_drawable *drawable) +{ + struct st_framebuffer_iface *stfbi; + + stfbi = CALLOC_STRUCT(st_framebuffer_iface); + if (stfbi) { + stfbi->visual = &drawable->stvis; + stfbi->flush_front = dri_st_framebuffer_flush_front; + stfbi->validate = dri_st_framebuffer_validate; + stfbi->st_manager_private = (void *) drawable; + } + + return stfbi; +} + +/** + * Destroy a framebuffer. + */ +void +dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) +{ + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + int i; + + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_texture_reference(&drawable->textures[i], NULL); + + FREE(stfbi); +} + +/** + * Validate the texture at an attachment. Allocate the texture if it does not + * exist. + */ +void +dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt) +{ + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; + unsigned i, count = 0; + + /* check if buffer already exists */ + if (drawable->texture_mask & (1 << statt)) + return; + + /* make sure DRI2 does not destroy existing buffers */ + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + if (drawable->texture_mask & (1 << i)) { + statts[count++] = i; + } + } + statts[count++] = statt; + + drawable->texture_stamp = drawable->dPriv->lastStamp - 1; + + stfbi->validate(stfbi, statts, count, NULL); +} + +/** + * Reference counted st_api. + */ +static struct { + int32_t refcnt; + struct st_api *stapi; +} dri_st_api; + +/** + * Add a reference to the st_api of the state tracker. + */ +static void +_dri_get_st_api(void) +{ + p_atomic_inc(&dri_st_api.refcnt); + if (p_atomic_read(&dri_st_api.refcnt) == 1) + dri_st_api.stapi = st_manager_create_api(); +} + +/** + * Remove a reference to the st_api of the state tracker. + */ +static void +_dri_put_st_api(void) +{ + struct st_api *stapi = dri_st_api.stapi; + + if (p_atomic_dec_zero(&dri_st_api.refcnt)) { + stapi->destroy(dri_st_api.stapi); + dri_st_api.stapi = NULL; + } +} + +/** + * Create a state tracker manager from the given screen. + */ +struct st_manager * +dri_create_st_manager(struct dri_screen *screen) +{ + struct st_manager *smapi; + + smapi = CALLOC_STRUCT(st_manager); + if (smapi) { + smapi->screen = screen->pipe_screen; + _dri_get_st_api(); + } + + return smapi; +} + +/** + * Destroy a state tracker manager. + */ +void +dri_destroy_st_manager(struct st_manager *smapi) +{ + _dri_put_st_api(); + FREE(smapi); +} + +/** + * Return the st_api of OpenGL state tracker. + */ +struct st_api * +dri_get_st_api(void) +{ + assert(dri_st_api.stapi); + return dri_st_api.stapi; +} diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.h b/src/gallium/state_trackers/dri/common/dri_st_api.h new file mode 100644 index 00000000000..99a217bfa79 --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_st_api.h @@ -0,0 +1,55 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 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 + * 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. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _DRI_ST_API_H_ +#define _DRI_ST_API_H_ + +#include "state_tracker/st_api.h" + +struct dri_screen; +struct dri_drawable; + +struct st_api * +dri_get_st_api(void); + +struct st_manager * +dri_create_st_manager(struct dri_screen *screen); + +void +dri_destroy_st_manager(struct st_manager *smapi); + +struct st_framebuffer_iface * +dri_create_st_framebuffer(struct dri_drawable *drawable); + +void +dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi); + +void +dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt); + +#endif /* _DRI_ST_API_H_ */ diff --git a/src/gallium/state_trackers/dri/common/dri_wrapper.h b/src/gallium/state_trackers/dri/common/dri_wrapper.h new file mode 100644 index 00000000000..141ba02706a --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_wrapper.h @@ -0,0 +1,10 @@ +#ifndef DRI_WRAPPER_H +#define DRI_WRAPPER_H + +#ifndef __NOT_HAVE_DRM_H +#include "dri_util.h" +#else +#include "drisw_util.h" +#endif + +#endif diff --git a/src/gallium/state_trackers/dri/dri1_helper.c b/src/gallium/state_trackers/dri/dri1_helper.c deleted file mode 100644 index 7eeb868d422..00000000000 --- a/src/gallium/state_trackers/dri/dri1_helper.c +++ /dev/null @@ -1,129 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ -/* - * Management of pipe objects (surface / pipe / fences) used by DRI1 and DRISW. - * - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "util/u_inlines.h" -#include "pipe/p_context.h" - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" -#include "dri1_helper.h" - -struct pipe_fence_handle * -dri1_swap_fences_pop_front(struct dri_drawable *draw) -{ - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; - struct pipe_fence_handle *fence = NULL; - - if (draw->cur_fences >= draw->desired_fences) { - screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]); - screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL); - --draw->cur_fences; - draw->tail &= DRI_SWAP_FENCES_MASK; - } - return fence; -} - -void -dri1_swap_fences_push_back(struct dri_drawable *draw, - struct pipe_fence_handle *fence) -{ - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; - - if (!fence) - return; - - if (draw->cur_fences < DRI_SWAP_FENCES_MAX) { - draw->cur_fences++; - screen->fence_reference(screen, &draw->swap_fences[draw->head++], - fence); - draw->head &= DRI_SWAP_FENCES_MASK; - } -} - -void -dri1_swap_fences_clear(struct dri_drawable *drawable) -{ - struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; - struct pipe_fence_handle *fence; - - while (drawable->cur_fences) { - fence = dri1_swap_fences_pop_front(drawable); - screen->fence_reference(screen, &fence, NULL); - } -} - -struct pipe_surface * -dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex) -{ - struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->pipe_screen; - struct pipe_surface *psurf = drawable->dri1_surface; - - if (!psurf || psurf->texture != ptex) { - pipe_surface_reference(&drawable->dri1_surface, NULL); - - drawable->dri1_surface = pipe_screen->get_tex_surface(pipe_screen, - ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); - - psurf = drawable->dri1_surface; - } - - return psurf; -} - -void -dri1_destroy_pipe_surface(struct dri_drawable *drawable) -{ - pipe_surface_reference(&drawable->dri1_surface, NULL); -} - -struct pipe_context * -dri1_get_pipe_context(struct dri_screen *screen) -{ - struct pipe_context *pipe = screen->dri1_pipe; - - if (!pipe) { - screen->dri1_pipe = - screen->pipe_screen->context_create(screen->pipe_screen, NULL); - pipe = screen->dri1_pipe; - } - - return pipe; -} - -void -dri1_destroy_pipe_context(struct dri_screen *screen) -{ - if (screen->dri1_pipe) - screen->dri1_pipe->destroy(screen->dri1_pipe); -} diff --git a/src/gallium/state_trackers/dri/dri1_helper.h b/src/gallium/state_trackers/dri/dri1_helper.h deleted file mode 100644 index 3254b7ff872..00000000000 --- a/src/gallium/state_trackers/dri/dri1_helper.h +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#ifndef DRI1_HELPER_H -#define DRI1_HELPER_H - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" - -struct pipe_fence_handle * -dri1_swap_fences_pop_front(struct dri_drawable *draw); - -void -dri1_swap_fences_push_back(struct dri_drawable *draw, - struct pipe_fence_handle *fence); - -void -dri1_swap_fences_clear(struct dri_drawable *drawable); - -struct pipe_surface * -dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex); - -void -dri1_destroy_pipe_surface(struct dri_drawable *drawable); - -struct pipe_context * -dri1_get_pipe_context(struct dri_screen *screen); - -void -dri1_destroy_pipe_context(struct dri_screen *screen); - -#endif /* DRI1_HELPER_H */ diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c deleted file mode 100644 index 34d9a932ead..00000000000 --- a/src/gallium/state_trackers/dri/dri_context.c +++ /dev/null @@ -1,174 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" -#include "dri_drawable.h" -#include "dri_context.h" -#include "dri_st_api.h" - -#include "pipe/p_context.h" -#include "util/u_memory.h" - -GLboolean -dri_create_context(const __GLcontextModes * visual, - __DRIcontext * cPriv, void *sharedContextPrivate) -{ - struct st_api *stapi = dri_get_st_api(); - __DRIscreen *sPriv = cPriv->driScreenPriv; - struct dri_screen *screen = dri_screen(sPriv); - struct dri_context *ctx = NULL; - struct st_context_iface *st_share = NULL; - struct st_visual stvis; - - if (sharedContextPrivate) { - st_share = ((struct dri_context *)sharedContextPrivate)->st; - } - - ctx = CALLOC_STRUCT(dri_context); - if (ctx == NULL) - goto fail; - - cPriv->driverPrivate = ctx; - ctx->cPriv = cPriv; - ctx->sPriv = sPriv; - ctx->lock = screen->drmLock; - - driParseConfigFiles(&ctx->optionCache, - &screen->optionCache, sPriv->myNum, "dri"); - - dri_fill_st_visual(&stvis, screen, visual); - ctx->st = stapi->create_context(stapi, screen->smapi, &stvis, st_share); - if (ctx->st == NULL) - goto fail; - ctx->st->st_manager_private = (void *) ctx; - - dri_init_extensions(ctx); - - return GL_TRUE; - - fail: - if (ctx && ctx->st) - ctx->st->destroy(ctx->st); - - FREE(ctx); - return FALSE; -} - -void -dri_destroy_context(__DRIcontext * cPriv) -{ - struct dri_context *ctx = dri_context(cPriv); - - /* note: we are freeing values and nothing more because - * driParseConfigFiles allocated values only - the rest - * is owned by screen optionCache. - */ - FREE(ctx->optionCache.values); - - /* No particular reason to wait for command completion before - * destroying a context, but it is probably worthwhile flushing it - * to avoid having to add code elsewhere to cope with flushing a - * partially destroyed context. - */ - ctx->st->flush(ctx->st, 0, NULL); - ctx->st->destroy(ctx->st); - - FREE(ctx); -} - -GLboolean -dri_unbind_context(__DRIcontext * cPriv) -{ - struct st_api *stapi = dri_get_st_api(); - - if (cPriv) { - struct dri_context *ctx = dri_context(cPriv); - - if (--ctx->bind_count == 0) { - if (ctx->st == stapi->get_current(stapi)) { - ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - stapi->make_current(stapi, NULL, NULL, NULL); - } - } - } - - return GL_TRUE; -} - -GLboolean -dri_make_current(__DRIcontext * cPriv, - __DRIdrawable * driDrawPriv, - __DRIdrawable * driReadPriv) -{ - struct st_api *stapi = dri_get_st_api(); - - if (cPriv) { - struct dri_context *ctx = dri_context(cPriv); - struct dri_drawable *draw = dri_drawable(driDrawPriv); - struct dri_drawable *read = dri_drawable(driReadPriv); - struct st_context_iface *old_st; - - old_st = stapi->get_current(stapi); - if (old_st && old_st != ctx->st) - ctx->st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL); - - ++ctx->bind_count; - - if (ctx->dPriv != driDrawPriv) { - ctx->dPriv = driDrawPriv; - draw->texture_stamp = driDrawPriv->lastStamp - 1; - } - if (ctx->rPriv != driReadPriv) { - ctx->rPriv = driReadPriv; - read->texture_stamp = driReadPriv->lastStamp - 1; - } - - stapi->make_current(stapi, ctx->st, draw->stfb, read->stfb); - } - else { - stapi->make_current(stapi, NULL, NULL, NULL); - } - - return GL_TRUE; -} - -struct dri_context * -dri_get_current(void) -{ - struct st_api *stapi = dri_get_st_api(); - struct st_context_iface *st; - - st = stapi->get_current(stapi); - - return (struct dri_context *) (st) ? st->st_manager_private : NULL; -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h deleted file mode 100644 index 24d3d0368a4..00000000000 --- a/src/gallium/state_trackers/dri/dri_context.h +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************** - * - * Copyright (C) 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. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#ifndef DRI_CONTEXT_H -#define DRI_CONTEXT_H - -#include "pipe/p_compiler.h" -#include "dri_wrapper.h" - -struct pipe_context; -struct pipe_fence; -struct st_context; -struct dri_drawable; - -struct dri_context -{ - /* dri */ - __DRIscreen *sPriv; - __DRIcontext *cPriv; - __DRIdrawable *dPriv; - __DRIdrawable *rPriv; - - driOptionCache optionCache; - - drmLock *lock; - boolean isLocked; - boolean stLostLock; - boolean wsLostLock; - - unsigned int bind_count; - - /* gallium */ - struct st_context_iface *st; -}; - -static INLINE struct dri_context * -dri_context(__DRIcontext * driContextPriv) -{ - return (struct dri_context *)driContextPriv->driverPrivate; -} - -/*********************************************************************** - * dri_context.c - */ -void dri_destroy_context(__DRIcontext * driContextPriv); - -boolean dri_unbind_context(__DRIcontext * driContextPriv); - -boolean -dri_make_current(__DRIcontext * driContextPriv, - __DRIdrawable * driDrawPriv, - __DRIdrawable * driReadPriv); - -struct dri_context * -dri_get_current(void); - -boolean -dri_create_context(const __GLcontextModes * visual, - __DRIcontext * driContextPriv, - void *sharedContextPrivate); - -/*********************************************************************** - * dri_extensions.c - */ -void dri_init_extensions(struct dri_context *ctx); - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c deleted file mode 100644 index 75b4cc56289..00000000000 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" -#include "dri_st_api.h" -#include "dri1_helper.h" - -#include "pipe/p_screen.h" -#include "util/u_format.h" -#include "util/u_memory.h" -#include "util/u_inlines.h" - -/** - * This is called when we need to set up GL rendering to a new X window. - */ -boolean -dri_create_buffer(__DRIscreen * sPriv, - __DRIdrawable * dPriv, - const __GLcontextModes * visual, boolean isPixmap) -{ - struct dri_screen *screen = sPriv->private; - struct dri_drawable *drawable = NULL; - - if (isPixmap) - goto fail; /* not implemented */ - - drawable = CALLOC_STRUCT(dri_drawable); - if (drawable == NULL) - goto fail; - - dri_fill_st_visual(&drawable->stvis, screen, visual); - drawable->stfb = dri_create_st_framebuffer(drawable); - if (drawable->stfb == NULL) - goto fail; - - drawable->sPriv = sPriv; - drawable->dPriv = dPriv; - dPriv->driverPrivate = (void *)drawable; - - drawable->desired_fences = 2; - - return GL_TRUE; -fail: - FREE(drawable); - return GL_FALSE; -} - -void -dri_destroy_buffer(__DRIdrawable * dPriv) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - - dri1_swap_fences_clear(drawable); - - dri1_destroy_pipe_surface(drawable); - - dri_destroy_st_framebuffer(drawable->stfb); - - drawable->desired_fences = 0; - - FREE(drawable); -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h deleted file mode 100644 index 98abeb9ec05..00000000000 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************** - * - * 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 DRI_DRAWABLE_H -#define DRI_DRAWABLE_H - -#include "pipe/p_compiler.h" -#include "pipe/p_format.h" -#include "state_tracker/st_api.h" - -struct pipe_surface; -struct pipe_fence_handle; -struct st_framebuffer; -struct dri_context; - -#define DRI_SWAP_FENCES_MAX 8 -#define DRI_SWAP_FENCES_MASK 7 - -struct dri_drawable -{ - /* dri */ - __DRIdrawable *dPriv; - __DRIscreen *sPriv; - - /* gallium */ - struct st_framebuffer_iface *stfb; - struct st_visual stvis; - - __DRIbuffer old[8]; - unsigned old_num; - unsigned old_w; - unsigned old_h; - - struct pipe_texture *textures[ST_ATTACHMENT_COUNT]; - unsigned int texture_mask, texture_stamp; - - struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX]; - unsigned int head; - unsigned int tail; - unsigned int desired_fences; - unsigned int cur_fences; - - /* used only by DRI1 */ - struct pipe_surface *dri1_surface; -}; - -static INLINE struct dri_drawable * -dri_drawable(__DRIdrawable * driDrawPriv) -{ - return (struct dri_drawable *)driDrawPriv->driverPrivate; -} - -/*********************************************************************** - * dri_drawable.c - */ -boolean -dri_create_buffer(__DRIscreen * sPriv, - __DRIdrawable * dPriv, - const __GLcontextModes * visual, boolean isPixmap); - -void dri_destroy_buffer(__DRIdrawable * dPriv); - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c deleted file mode 100644 index df458e1eb0f..00000000000 --- a/src/gallium/state_trackers/dri/dri_extensions.c +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" -#include "dri_context.h" -#include "state_tracker/st_context.h" - -#include "utils.h" - -void -dri_init_extensions(struct dri_context *ctx) -{ - struct st_context *st = (struct st_context *) ctx->st; - - /* New extensions should be added in mesa/state_tracker/st_extensions.c - * and not in this file. */ - driInitExtensions(st->ctx, NULL, GL_FALSE); -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c deleted file mode 100644 index 598a07bb646..00000000000 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ /dev/null @@ -1,373 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "utils.h" -#ifndef __NOT_HAVE_DRM_H -#include "vblank.h" -#endif -#include "xmlpool.h" - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" -#include "dri_st_api.h" -#include "dri1_helper.h" -#ifndef __NOT_HAVE_DRM_H -#include "dri1.h" -#include "dri2.h" -#else -#include "drisw.h" -#endif - -#include "util/u_inlines.h" -#include "pipe/p_screen.h" -#include "pipe/p_format.h" -#include "state_tracker/drm_api.h" - -#include "util/u_debug.h" - -PUBLIC const char __driConfigOptions[] = - DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) - DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) - DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY -/* DRI_CONF_FORCE_S3TC_ENABLE(false) */ - DRI_CONF_ALLOW_LARGE_TEXTURES(1) - DRI_CONF_SECTION_END DRI_CONF_END; - -const uint __driNConfigOptions = 3; - -const __DRIconfig ** -dri_fill_in_modes(struct dri_screen *screen, - unsigned pixel_bits) -{ - __DRIconfig **configs = NULL; - __DRIconfig **configs_r5g6b5 = NULL; - __DRIconfig **configs_a8r8g8b8 = NULL; - __DRIconfig **configs_x8r8g8b8 = NULL; - unsigned num_modes; - uint8_t depth_bits_array[5]; - uint8_t stencil_bits_array[5]; - uint8_t msaa_samples_array[2]; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - unsigned msaa_samples_factor; - struct pipe_screen *p_screen = screen->pipe_screen; - boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8; - boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32; - - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML - }; - - depth_bits_array[0] = 0; - stencil_bits_array[0] = 0; - depth_buffer_factor = 1; - - pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); - pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); - pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); - - /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */ - if (dri_with_format(screen->sPriv)) { - pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - } else { - pf_z16 = FALSE; - pf_z32 = FALSE; - } - - if (pf_z16) { - depth_bits_array[depth_buffer_factor] = 16; - stencil_bits_array[depth_buffer_factor++] = 0; - } - if (pf_x8z24 || pf_z24x8) { - depth_bits_array[depth_buffer_factor] = 24; - stencil_bits_array[depth_buffer_factor++] = 0; - screen->d_depth_bits_last = pf_x8z24; - } - if (pf_s8z24 || pf_z24s8) { - depth_bits_array[depth_buffer_factor] = 24; - stencil_bits_array[depth_buffer_factor++] = 8; - screen->sd_depth_bits_last = pf_s8z24; - } - if (pf_z32) { - depth_bits_array[depth_buffer_factor] = 32; - stencil_bits_array[depth_buffer_factor++] = 0; - } - - msaa_samples_array[0] = 0; - msaa_samples_array[1] = 4; - back_buffer_factor = 3; - msaa_samples_factor = 2; - - num_modes = - depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; - - if (pf_r5g6b5) - configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, back_buffer_modes, - back_buffer_factor, - msaa_samples_array, msaa_samples_factor, - GL_TRUE); - - if (pf_a8r8g8b8) - configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, - depth_bits_array, - stencil_bits_array, - depth_buffer_factor, - back_buffer_modes, - back_buffer_factor, - msaa_samples_array, - msaa_samples_factor, - GL_TRUE); - - if (pf_x8r8g8b8) - configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV, - depth_bits_array, - stencil_bits_array, - depth_buffer_factor, - back_buffer_modes, - back_buffer_factor, - msaa_samples_array, - msaa_samples_factor, - GL_TRUE); - - if (pixel_bits == 16) { - configs = configs_r5g6b5; - if (configs_a8r8g8b8) - configs = configs ? driConcatConfigs(configs, configs_a8r8g8b8) : configs_a8r8g8b8; - if (configs_x8r8g8b8) - configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8; - } else { - configs = configs_a8r8g8b8; - if (configs_x8r8g8b8) - configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8; - if (configs_r5g6b5) - configs = configs ? driConcatConfigs(configs, configs_r5g6b5) : configs_r5g6b5; - } - - if (configs == NULL) { - debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__); - return NULL; - } - - return (const __DRIconfig **)configs; -} - -/** - * Roughly the converse of dri_fill_in_modes. - */ -void -dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, - const __GLcontextModes *mode) -{ - memset(stvis, 0, sizeof(*stvis)); - - stvis->samples = mode->samples; - stvis->render_buffer = ST_ATTACHMENT_INVALID; - - if (mode->redBits == 8) { - if (mode->alphaBits == 8) - stvis->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; - else - stvis->color_format = PIPE_FORMAT_B8G8R8X8_UNORM; - } else { - stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM; - } - - switch (mode->depthBits) { - default: - case 0: - stvis->depth_stencil_format = PIPE_FORMAT_NONE; - break; - case 16: - stvis->depth_stencil_format = PIPE_FORMAT_Z16_UNORM; - break; - case 24: - if (mode->stencilBits == 0) { - stvis->depth_stencil_format = (screen->d_depth_bits_last) ? - PIPE_FORMAT_Z24X8_UNORM: - PIPE_FORMAT_X8Z24_UNORM; - } else { - stvis->depth_stencil_format = (screen->sd_depth_bits_last) ? - PIPE_FORMAT_Z24S8_UNORM: - PIPE_FORMAT_S8Z24_UNORM; - } - break; - case 32: - stvis->depth_stencil_format = PIPE_FORMAT_Z32_UNORM; - break; - } - - stvis->accum_format = (mode->haveAccumBuffer) ? - PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE; - - stvis->buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK; - if (mode->doubleBufferMode) - stvis->buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK; - if (mode->stereoMode) { - stvis->buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK; - if (mode->doubleBufferMode) - stvis->buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK; - } - - if (mode->haveDepthBuffer || mode->haveStencilBuffer) - stvis->buffer_mask |= ST_ATTACHMENT_DEPTH_STENCIL_MASK; - /* let the state tracker allocate the accum buffer */ -} - -#ifndef __NOT_HAVE_DRM_H - -/** - * Get information about previous buffer swaps. - */ -static int -dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo) -{ - if (dPriv == NULL || dPriv->driverPrivate == NULL || sInfo == NULL) - return -1; - else - return 0; -} - -#endif - -static void -dri_destroy_option_cache(struct dri_screen * screen) -{ - int i; - - for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) { - FREE(screen->optionCache.info[i].name); - FREE(screen->optionCache.info[i].ranges); - } - - FREE(screen->optionCache.info); - FREE(screen->optionCache.values); -} - -void -dri_destroy_screen(__DRIscreen * sPriv) -{ - struct dri_screen *screen = dri_screen(sPriv); - - dri1_destroy_pipe_context(screen); - - if (screen->smapi) - dri_destroy_st_manager(screen->smapi); - - if (screen->pipe_screen) - screen->pipe_screen->destroy(screen->pipe_screen); - - dri_destroy_option_cache(screen); - - FREE(screen); - sPriv->private = NULL; - sPriv->extensions = NULL; -} - -#ifndef __NOT_HAVE_DRM_H - -const struct __DriverAPIRec driDriverAPI = { - .DestroyScreen = dri_destroy_screen, - .CreateContext = dri_create_context, - .DestroyContext = dri_destroy_context, - .CreateBuffer = dri_create_buffer, - .DestroyBuffer = dri_destroy_buffer, - .MakeCurrent = dri_make_current, - .UnbindContext = dri_unbind_context, - .GetSwapInfo = dri_get_swap_info, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .InitScreen2 = dri2_init_screen, - - .InitScreen = dri1_init_screen, - .SwapBuffers = dri1_swap_buffers, - .CopySubBuffer = dri1_copy_sub_buffer, -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - &driDRI2Extension.base, - NULL -}; - -#else - -const struct __DriverAPIRec driDriverAPI = { - .DestroyScreen = dri_destroy_screen, - .CreateContext = dri_create_context, - .DestroyContext = dri_destroy_context, - .CreateBuffer = dri_create_buffer, - .DestroyBuffer = dri_destroy_buffer, - .MakeCurrent = dri_make_current, - .UnbindContext = dri_unbind_context, - - .InitScreen = drisw_init_screen, - .SwapBuffers = drisw_swap_buffers, -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driSWRastExtension.base, - NULL -}; - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h deleted file mode 100644 index 4f59db37cfa..00000000000 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#ifndef DRI_SCREEN_H -#define DRI_SCREEN_H - -#include "dri_wrapper.h" -#include "xmlconfig.h" - -#include "pipe/p_compiler.h" -#include "pipe/p_context.h" -#include "pipe/p_state.h" -#include "state_tracker/st_api.h" - -struct dri_screen -{ - /* dri */ - __DRIscreen *sPriv; - - /** - * Configuration cache with default values for all contexts - */ - driOptionCache optionCache; - - /* drm */ - int fd; - drmLock *drmLock; - - /* gallium */ - struct drm_api *api; - struct pipe_winsys *pipe_winsys; - struct pipe_screen *pipe_screen; - boolean d_depth_bits_last; - boolean sd_depth_bits_last; - boolean auto_fake_front; - - struct st_manager *smapi; - - /* used only by DRI1 */ - struct pipe_context *dri1_pipe; -}; - -/** cast wrapper */ -static INLINE struct dri_screen * -dri_screen(__DRIscreen * sPriv) -{ - return (struct dri_screen *)sPriv->private; -} - -#ifndef __NOT_HAVE_DRM_H - -static INLINE boolean -dri_with_format(__DRIscreen * sPriv) -{ - const __DRIdri2LoaderExtension *loader = sPriv->dri2.loader; - - return loader - && (loader->base.version >= 3) - && (loader->getBuffersWithFormat != NULL); -} - -#else - -static INLINE boolean -dri_with_format(__DRIscreen * sPriv) -{ - return TRUE; -} - -#endif - -extern const uint __driNConfigOptions; - -const __DRIconfig ** -dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits); - -void -dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, - const __GLcontextModes *mode); - -void -dri_destroy_screen(__DRIscreen * sPriv); - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c deleted file mode 100644 index 40b24b18e9f..00000000000 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 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 - * 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. - * - * Authors: - * Chia-I Wu - */ - -#include "util/u_memory.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_debug.h" -#include "state_tracker/st_manager.h" /* for st_manager_create_api */ - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" -#include "dri_st_api.h" -#include "dri1_helper.h" -#ifndef __NOT_HAVE_DRM_H -#include "dri1.h" -#include "dri2.h" -#else -#include "drisw.h" -#endif - -static boolean -dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, - const enum st_attachment_type *statts, - unsigned count, - struct pipe_texture **out) -{ - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi->st_manager_private; - unsigned statt_mask, new_mask; - boolean new_stamp; - int i; - - statt_mask = 0x0; - for (i = 0; i < count; i++) - statt_mask |= (1 << statts[i]); - - /* record newly allocated textures */ - new_mask = (statt_mask & ~drawable->texture_mask); - - /* - * dPriv->pStamp is the server stamp. It should be accessed with a lock, at - * least for DRI1. dPriv->lastStamp is the client stamp. It has the value - * of the server stamp when last checked. - */ - new_stamp = (drawable->texture_stamp != drawable->dPriv->lastStamp); - - if (new_stamp || new_mask) { - -#ifndef __NOT_HAVE_DRM_H - if (__dri1_api_hooks) { - dri1_allocate_textures(drawable, statt_mask); - } - else { - dri2_allocate_textures(drawable, statts, count); - } -#else - if (new_stamp) - drisw_update_drawable_info(drawable->dPriv); - - drisw_allocate_textures(drawable, statt_mask); -#endif - - /* add existing textures */ - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { - if (drawable->textures[i]) - statt_mask |= (1 << i); - } - - drawable->texture_stamp = drawable->dPriv->lastStamp; - drawable->texture_mask = statt_mask; - } - - if (!out) - return TRUE; - - for (i = 0; i < count; i++) { - out[i] = NULL; - pipe_texture_reference(&out[i], drawable->textures[statts[i]]); - } - - return TRUE; -} - -static boolean -dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, - enum st_attachment_type statt) -{ - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi->st_manager_private; - -#ifndef __NOT_HAVE_DRM_H - if (__dri1_api_hooks) { - dri1_flush_frontbuffer(drawable, statt); - } - else { - dri2_flush_frontbuffer(drawable, statt); - } -#else - drisw_flush_frontbuffer(drawable, statt); -#endif - - return TRUE; -} - -/** - * Create a framebuffer from the given drawable. - */ -struct st_framebuffer_iface * -dri_create_st_framebuffer(struct dri_drawable *drawable) -{ - struct st_framebuffer_iface *stfbi; - - stfbi = CALLOC_STRUCT(st_framebuffer_iface); - if (stfbi) { - stfbi->visual = &drawable->stvis; - stfbi->flush_front = dri_st_framebuffer_flush_front; - stfbi->validate = dri_st_framebuffer_validate; - stfbi->st_manager_private = (void *) drawable; - } - - return stfbi; -} - -/** - * Destroy a framebuffer. - */ -void -dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) -{ - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi->st_manager_private; - int i; - - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) - pipe_texture_reference(&drawable->textures[i], NULL); - - FREE(stfbi); -} - -/** - * Validate the texture at an attachment. Allocate the texture if it does not - * exist. - */ -void -dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, - enum st_attachment_type statt) -{ - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi->st_manager_private; - enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; - unsigned i, count = 0; - - /* check if buffer already exists */ - if (drawable->texture_mask & (1 << statt)) - return; - - /* make sure DRI2 does not destroy existing buffers */ - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { - if (drawable->texture_mask & (1 << i)) { - statts[count++] = i; - } - } - statts[count++] = statt; - - drawable->texture_stamp = drawable->dPriv->lastStamp - 1; - - stfbi->validate(stfbi, statts, count, NULL); -} - -/** - * Reference counted st_api. - */ -static struct { - int32_t refcnt; - struct st_api *stapi; -} dri_st_api; - -/** - * Add a reference to the st_api of the state tracker. - */ -static void -_dri_get_st_api(void) -{ - p_atomic_inc(&dri_st_api.refcnt); - if (p_atomic_read(&dri_st_api.refcnt) == 1) - dri_st_api.stapi = st_manager_create_api(); -} - -/** - * Remove a reference to the st_api of the state tracker. - */ -static void -_dri_put_st_api(void) -{ - struct st_api *stapi = dri_st_api.stapi; - - if (p_atomic_dec_zero(&dri_st_api.refcnt)) { - stapi->destroy(dri_st_api.stapi); - dri_st_api.stapi = NULL; - } -} - -/** - * Create a state tracker manager from the given screen. - */ -struct st_manager * -dri_create_st_manager(struct dri_screen *screen) -{ - struct st_manager *smapi; - - smapi = CALLOC_STRUCT(st_manager); - if (smapi) { - smapi->screen = screen->pipe_screen; - _dri_get_st_api(); - } - - return smapi; -} - -/** - * Destroy a state tracker manager. - */ -void -dri_destroy_st_manager(struct st_manager *smapi) -{ - _dri_put_st_api(); - FREE(smapi); -} - -/** - * Return the st_api of OpenGL state tracker. - */ -struct st_api * -dri_get_st_api(void) -{ - assert(dri_st_api.stapi); - return dri_st_api.stapi; -} diff --git a/src/gallium/state_trackers/dri/dri_st_api.h b/src/gallium/state_trackers/dri/dri_st_api.h deleted file mode 100644 index 99a217bfa79..00000000000 --- a/src/gallium/state_trackers/dri/dri_st_api.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 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 - * 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. - * - * Authors: - * Chia-I Wu - */ - -#ifndef _DRI_ST_API_H_ -#define _DRI_ST_API_H_ - -#include "state_tracker/st_api.h" - -struct dri_screen; -struct dri_drawable; - -struct st_api * -dri_get_st_api(void); - -struct st_manager * -dri_create_st_manager(struct dri_screen *screen); - -void -dri_destroy_st_manager(struct st_manager *smapi); - -struct st_framebuffer_iface * -dri_create_st_framebuffer(struct dri_drawable *drawable); - -void -dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi); - -void -dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, - enum st_attachment_type statt); - -#endif /* _DRI_ST_API_H_ */ diff --git a/src/gallium/state_trackers/dri/dri_wrapper.h b/src/gallium/state_trackers/dri/dri_wrapper.h deleted file mode 100644 index 141ba02706a..00000000000 --- a/src/gallium/state_trackers/dri/dri_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef DRI_WRAPPER_H -#define DRI_WRAPPER_H - -#ifndef __NOT_HAVE_DRM_H -#include "dri_util.h" -#else -#include "drisw_util.h" -#endif - -#endif diff --git a/src/gallium/state_trackers/dri/drm/Makefile b/src/gallium/state_trackers/dri/drm/Makefile index c43bfee8b8f..19a755b86f1 100644 --- a/src/gallium/state_trackers/dri/drm/Makefile +++ b/src/gallium/state_trackers/dri/drm/Makefile @@ -6,7 +6,7 @@ LIBNAME = dridrm LIBRARY_INCLUDES = \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/gallium/state_trackers/dri \ + -I$(TOP)/src/gallium/state_trackers/dri/common \ -I$(TOP)/src/mesa/drivers/dri/common \ -I$(TOP)/src/mesa/main \ $(shell pkg-config --cflags-only-I libdrm) diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript index a9c359c2e89..b974e298f36 100644 --- a/src/gallium/state_trackers/dri/drm/SConscript +++ b/src/gallium/state_trackers/dri/drm/SConscript @@ -9,7 +9,7 @@ if env['dri']: env.Append(CPPPATH = [ '#/src/mesa', - '#/src/gallium/state_trackers/dri', + '#/src/gallium/state_trackers/dri/common', '#/src/mesa/drivers/dri/common', ]) diff --git a/src/gallium/state_trackers/dri/drm/dri1_helper.c b/src/gallium/state_trackers/dri/drm/dri1_helper.c index 7006a8d882f..c45ebf5c102 120000 --- a/src/gallium/state_trackers/dri/drm/dri1_helper.c +++ b/src/gallium/state_trackers/dri/drm/dri1_helper.c @@ -1 +1 @@ -../dri1_helper.c \ No newline at end of file +../common/dri1_helper.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_context.c b/src/gallium/state_trackers/dri/drm/dri_context.c index 989ef4438a1..5cfbbaeb068 120000 --- a/src/gallium/state_trackers/dri/drm/dri_context.c +++ b/src/gallium/state_trackers/dri/drm/dri_context.c @@ -1 +1 @@ -../dri_context.c \ No newline at end of file +../common/dri_context.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_drawable.c b/src/gallium/state_trackers/dri/drm/dri_drawable.c index 422c4c1d740..0fc19be6ea6 120000 --- a/src/gallium/state_trackers/dri/drm/dri_drawable.c +++ b/src/gallium/state_trackers/dri/drm/dri_drawable.c @@ -1 +1 @@ -../dri_drawable.c \ No newline at end of file +../common/dri_drawable.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_extensions.c b/src/gallium/state_trackers/dri/drm/dri_extensions.c index b793f06747d..e0d06dcdfa5 120000 --- a/src/gallium/state_trackers/dri/drm/dri_extensions.c +++ b/src/gallium/state_trackers/dri/drm/dri_extensions.c @@ -1 +1 @@ -../dri_extensions.c \ No newline at end of file +../common/dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_screen.c b/src/gallium/state_trackers/dri/drm/dri_screen.c index 938f4c3bdc7..847f6515f25 120000 --- a/src/gallium/state_trackers/dri/drm/dri_screen.c +++ b/src/gallium/state_trackers/dri/drm/dri_screen.c @@ -1 +1 @@ -../dri_screen.c \ No newline at end of file +../common/dri_screen.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_st_api.c b/src/gallium/state_trackers/dri/drm/dri_st_api.c index 9ae88230ddc..a8f6bd06b09 120000 --- a/src/gallium/state_trackers/dri/drm/dri_st_api.c +++ b/src/gallium/state_trackers/dri/drm/dri_st_api.c @@ -1 +1 @@ -../dri_st_api.c \ No newline at end of file +../common/dri_st_api.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/Makefile b/src/gallium/state_trackers/dri/sw/Makefile index 35e31e6466a..75e14fd26cb 100644 --- a/src/gallium/state_trackers/dri/sw/Makefile +++ b/src/gallium/state_trackers/dri/sw/Makefile @@ -9,7 +9,7 @@ LIBRARY_INCLUDES = \ -I../dri \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/gallium/state_trackers/dri \ + -I$(TOP)/src/gallium/state_trackers/dri/common \ -I$(TOP)/src/mesa/drivers/dri/common \ -I$(TOP)/src/mesa/main \ -D__NOT_HAVE_DRM_H diff --git a/src/gallium/state_trackers/dri/sw/dri1_helper.c b/src/gallium/state_trackers/dri/sw/dri1_helper.c index 7006a8d882f..c45ebf5c102 120000 --- a/src/gallium/state_trackers/dri/sw/dri1_helper.c +++ b/src/gallium/state_trackers/dri/sw/dri1_helper.c @@ -1 +1 @@ -../dri1_helper.c \ No newline at end of file +../common/dri1_helper.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_context.c b/src/gallium/state_trackers/dri/sw/dri_context.c index 989ef4438a1..5cfbbaeb068 120000 --- a/src/gallium/state_trackers/dri/sw/dri_context.c +++ b/src/gallium/state_trackers/dri/sw/dri_context.c @@ -1 +1 @@ -../dri_context.c \ No newline at end of file +../common/dri_context.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_drawable.c b/src/gallium/state_trackers/dri/sw/dri_drawable.c index 422c4c1d740..0fc19be6ea6 120000 --- a/src/gallium/state_trackers/dri/sw/dri_drawable.c +++ b/src/gallium/state_trackers/dri/sw/dri_drawable.c @@ -1 +1 @@ -../dri_drawable.c \ No newline at end of file +../common/dri_drawable.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_extensions.c b/src/gallium/state_trackers/dri/sw/dri_extensions.c index b793f06747d..e0d06dcdfa5 120000 --- a/src/gallium/state_trackers/dri/sw/dri_extensions.c +++ b/src/gallium/state_trackers/dri/sw/dri_extensions.c @@ -1 +1 @@ -../dri_extensions.c \ No newline at end of file +../common/dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_screen.c b/src/gallium/state_trackers/dri/sw/dri_screen.c index 938f4c3bdc7..847f6515f25 120000 --- a/src/gallium/state_trackers/dri/sw/dri_screen.c +++ b/src/gallium/state_trackers/dri/sw/dri_screen.c @@ -1 +1 @@ -../dri_screen.c \ No newline at end of file +../common/dri_screen.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_st_api.c b/src/gallium/state_trackers/dri/sw/dri_st_api.c index 9ae88230ddc..a8f6bd06b09 120000 --- a/src/gallium/state_trackers/dri/sw/dri_st_api.c +++ b/src/gallium/state_trackers/dri/sw/dri_st_api.c @@ -1 +1 @@ -../dri_st_api.c \ No newline at end of file +../common/dri_st_api.c \ No newline at end of file -- cgit v1.2.3