summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorGeorge Sapountzis <[email protected]>2010-03-25 17:01:53 +0200
committerGeorge Sapountzis <[email protected]>2010-03-25 17:01:53 +0200
commit4ce16e13ce5ca89943b86a8e8cdb5354892a13a6 (patch)
treee67a8ae88389d38a4b4640a0dd28664f0d97480c /src/gallium
parent6a7bd8eb95e7d304725b09272dc9c40a337182e1 (diff)
st/dri: export DRI1 surface / pipe
They will be used by DRISW. Also, add destroy functions.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/dri/Makefile1
-rw-r--r--src/gallium/state_trackers/dri/SConscript1
-rw-r--r--src/gallium/state_trackers/dri/dri1.c93
-rw-r--r--src/gallium/state_trackers/dri/dri1.h3
-rw-r--r--src/gallium/state_trackers/dri/dri1_helper.c129
-rw-r--r--src/gallium/state_trackers/dri/dri1_helper.h61
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.c7
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.c5
-rw-r--r--src/gallium/state_trackers/dri/dri_st_api.c8
9 files changed, 218 insertions, 90 deletions
diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile
index 6d95a277f82..f1a54e80b61 100644
--- a/src/gallium/state_trackers/dri/Makefile
+++ b/src/gallium/state_trackers/dri/Makefile
@@ -17,6 +17,7 @@ C_SOURCES = \
dri_drawable.c \
dri_extensions.c \
dri_st_api.c \
+ dri1_helper.c \
dri1.c \
dri2.c
diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript
index d6dc126723d..2ca9f420683 100644
--- a/src/gallium/state_trackers/dri/SConscript
+++ b/src/gallium/state_trackers/dri/SConscript
@@ -19,6 +19,7 @@ if env['dri']:
'dri_extensions.c',
'dri_screen.c',
'dri_st_api.c',
+ 'dri1_helper.c',
'dri1.c',
'dri2.c',
]
diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c
index 9108d41bd94..98bdb2936a1 100644
--- a/src/gallium/state_trackers/dri/dri1.c
+++ b/src/gallium/state_trackers/dri/dri1.c
@@ -41,6 +41,7 @@
#include "dri_context.h"
#include "dri_drawable.h"
#include "dri_st_api.h"
+#include "dri1_helper.h"
#include "dri1.h"
static INLINE void
@@ -65,50 +66,6 @@ dri1_unlock(struct dri_context *ctx)
DRM_UNLOCK(ctx->sPriv->fd, ctx->lock, ctx->cPriv->hHWContext);
}
-static struct pipe_fence_handle *
-dri_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;
-}
-
-static void
-dri_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 = dri_swap_fences_pop_front(drawable);
- screen->fence_reference(screen, &fence, NULL);
- }
-}
-
static void
dri1_update_drawables_locked(struct dri_context *ctx,
__DRIdrawable * driDrawPriv,
@@ -213,39 +170,6 @@ dri1_swap_copy(struct pipe_context *pipe,
}
}
-static 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;
-}
-
-static struct pipe_context *
-dri1_get_pipe_context(struct dri_drawable *drawable)
-{
- struct dri_screen *screen = dri_screen(drawable->sPriv);
- 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;
-}
-
static void
dri1_present_texture_locked(__DRIdrawable * dPriv,
struct pipe_texture *ptex,
@@ -253,6 +177,7 @@ dri1_present_texture_locked(__DRIdrawable * dPriv,
struct pipe_fence_handle **fence)
{
struct dri_drawable *drawable = dri_drawable(dPriv);
+ struct dri_screen *screen = dri_screen(drawable->sPriv);
struct pipe_context *pipe;
struct pipe_surface *psurf;
struct drm_clip_rect bbox;
@@ -270,7 +195,7 @@ dri1_present_texture_locked(__DRIdrawable * dPriv,
if (!visible)
return;
- pipe = dri1_get_pipe_context(drawable);
+ pipe = dri1_get_pipe_context(screen);
psurf = dri1_get_pipe_surface(drawable, ptex);
if (!pipe || !psurf)
return;
@@ -317,6 +242,10 @@ dri1_copy_to_front(struct dri_context *ctx,
dri1_propagate_drawable_change(ctx);
}
+/*
+ * Backend functions for st_framebuffer interface and swap_buffers.
+ */
+
void
dri1_flush_frontbuffer(struct dri_drawable *draw,
enum st_attachment_type statt)
@@ -359,13 +288,13 @@ dri1_swap_buffers(__DRIdrawable * dPriv)
ptex = draw->textures[ST_ATTACHMENT_BACK_LEFT];
if (ptex) {
ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
- fence = dri_swap_fences_pop_front(draw);
+ fence = dri1_swap_fences_pop_front(draw);
if (fence) {
(void)pipe_screen->fence_finish(pipe_screen, fence, 0);
pipe_screen->fence_reference(pipe_screen, &fence, NULL);
}
dri1_copy_to_front(ctx, ptex, dPriv, NULL, &fence);
- dri_swap_fences_push_back(draw, fence);
+ dri1_swap_fences_push_back(draw, fence);
pipe_screen->fence_reference(pipe_screen, &fence, NULL);
}
}
@@ -513,6 +442,10 @@ static struct dri1_api_lock_funcs dri1_lf = {
.clear_lost_lock = st_dri_clear_lost_lock
};
+/*
+ * Backend function for init_screen.
+ */
+
static const __DRIextension *dri1_screen_extensions[] = {
&driReadDrawableExtension,
&driCopySubBufferExtension.base,
diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h
index f1004281b54..cced505ea97 100644
--- a/src/gallium/state_trackers/dri/dri1.h
+++ b/src/gallium/state_trackers/dri/dri1.h
@@ -56,7 +56,4 @@ void dri1_swap_buffers(__DRIdrawable * dPriv);
void
dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h);
-void
-dri1_swap_fences_clear(struct dri_drawable *drawable);
-
#endif /* DRI1_H */
diff --git a/src/gallium/state_trackers/dri/dri1_helper.c b/src/gallium/state_trackers/dri/dri1_helper.c
new file mode 100644
index 00000000000..7eeb868d422
--- /dev/null
+++ b/src/gallium/state_trackers/dri/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 <[email protected]>
+ * Author: Jakob Bornecrantz <[email protected]>
+ */
+
+#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
new file mode 100644
index 00000000000..3254b7ff872
--- /dev/null
+++ b/src/gallium/state_trackers/dri/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 <[email protected]>
+ * Author: Jakob Bornecrantz <[email protected]>
+ */
+
+#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_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index 9b0ae8b27a9..75b4cc56289 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -33,7 +33,7 @@
#include "dri_context.h"
#include "dri_drawable.h"
#include "dri_st_api.h"
-#include "dri1.h"
+#include "dri1_helper.h"
#include "pipe/p_screen.h"
#include "util/u_format.h"
@@ -79,13 +79,10 @@ void
dri_destroy_buffer(__DRIdrawable * dPriv)
{
struct dri_drawable *drawable = dri_drawable(dPriv);
- int i;
dri1_swap_fences_clear(drawable);
- pipe_surface_reference(&drawable->dri1_surface, NULL);
- for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
- pipe_texture_reference(&drawable->textures[i], NULL);
+ dri1_destroy_pipe_surface(drawable);
dri_destroy_st_framebuffer(drawable->stfb);
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 6aef2d57002..1d808f0f7f9 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -37,6 +37,7 @@
#include "dri_context.h"
#include "dri_drawable.h"
#include "dri_st_api.h"
+#include "dri1_helper.h"
#include "dri1.h"
#include "dri2.h"
@@ -292,11 +293,11 @@ dri_destroy_screen(__DRIscreen * sPriv)
{
struct dri_screen *screen = dri_screen(sPriv);
- if (screen->dri1_pipe)
- screen->dri1_pipe->destroy(screen->dri1_pipe);
+ 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);
diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c
index 88cc410a9f9..3592a782229 100644
--- a/src/gallium/state_trackers/dri/dri_st_api.c
+++ b/src/gallium/state_trackers/dri/dri_st_api.c
@@ -35,6 +35,7 @@
#include "dri_context.h"
#include "dri_drawable.h"
#include "dri_st_api.h"
+#include "dri1_helper.h"
#include "dri1.h"
#include "dri2.h"
@@ -136,6 +137,13 @@ dri_create_st_framebuffer(struct dri_drawable *drawable)
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);
}