summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/dri
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>2013-09-09 13:02:08 +0200
committerMaarten Lankhorst <maarten.lankhorst@canonical.com>2013-09-11 09:03:44 +0200
commitb217d48364f368f541e53006af5dd56f664be24d (patch)
tree19cc7c1691d62564311470e8ef1c4f04a2c370cc /src/gallium/state_trackers/dri
parent169f9c030c16d1247a3a762972d8687d89a16750 (diff)
st/dri: do not create a new context for msaa copy
Commit b77316ad7594f st/dri: always copy new DRI front and back buffers to corresponding MSAA buffers introduced creating a pipe_context for every call to validate, which is not required because the callers have a context anyway. Only exception is egl_g3d_create_pbuffer_from_client_buffer, can someone test if it still works with NULL passed as context for validate? From examining the code I believe it does, but I didn't thoroughly test it. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Cc: 9.2 <mesa-stable@lists.freedesktop.org> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Diffstat (limited to 'src/gallium/state_trackers/dri')
-rw-r--r--src/gallium/state_trackers/dri/common/dri_drawable.c13
-rw-r--r--src/gallium/state_trackers/dri/common/dri_drawable.h3
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.c23
-rw-r--r--src/gallium/state_trackers/dri/sw/drisw.c3
4 files changed, 18 insertions, 24 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c
index 18d8d8988a9..ddf940048cf 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
@@ -42,11 +42,13 @@ static void
swap_fences_unref(struct dri_drawable *draw);
static boolean
-dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
+dri_st_framebuffer_validate(struct st_context_iface *stctx,
+ struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
struct pipe_resource **out)
{
+ struct dri_context *ctx = (struct dri_context *)stctx->st_manager_private;
struct dri_drawable *drawable =
(struct dri_drawable *) stfbi->st_manager_private;
struct dri_screen *screen = dri_screen(drawable->sPriv);
@@ -78,7 +80,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
if (new_stamp && drawable->update_drawable_info)
drawable->update_drawable_info(drawable);
- drawable->allocate_textures(drawable, statts, count);
+ drawable->allocate_textures(ctx, drawable, statts, count);
/* add existing textures */
for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
@@ -183,7 +185,8 @@ dri_destroy_buffer(__DRIdrawable * dPriv)
* exist. Used by the TFP extension.
*/
static void
-dri_drawable_validate_att(struct dri_drawable *drawable,
+dri_drawable_validate_att(struct dri_context *ctx,
+ struct dri_drawable *drawable,
enum st_attachment_type statt)
{
enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
@@ -203,7 +206,7 @@ dri_drawable_validate_att(struct dri_drawable *drawable,
drawable->texture_stamp = drawable->dPriv->lastStamp - 1;
- drawable->base.validate(&drawable->base, statts, count, NULL);
+ drawable->base.validate(ctx->st, &drawable->base, statts, count, NULL);
}
/**
@@ -217,7 +220,7 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
struct dri_drawable *drawable = dri_drawable(dPriv);
struct pipe_resource *pt;
- dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT);
+ dri_drawable_validate_att(ctx, drawable, ST_ATTACHMENT_FRONT_LEFT);
/* Use the pipe resource associated with the X drawable */
pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h
index 50e5cc4cd67..c5142181e89 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.h
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.h
@@ -71,7 +71,8 @@ struct dri_drawable
struct pipe_surface *drisw_surface;
/* hooks filled in by dri2 & drisw */
- void (*allocate_textures)(struct dri_drawable *drawable,
+ void (*allocate_textures)(struct dri_context *ctx,
+ struct dri_drawable *drawable,
const enum st_attachment_type *statts,
unsigned count);
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index e4477d6de77..fea1c8dfe52 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -169,7 +169,8 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
* Process __DRIbuffer and convert them into pipe_resources.
*/
static void
-dri2_drawable_process_buffers(struct dri_drawable *drawable,
+dri2_drawable_process_buffers(struct dri_context *ctx,
+ struct dri_drawable *drawable,
__DRIbuffer *buffers, unsigned buffer_count,
const enum st_attachment_type *atts,
unsigned att_count)
@@ -180,8 +181,6 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
struct winsys_handle whandle;
boolean alloc_depthstencil = FALSE;
unsigned i, j, bind;
- struct pipe_screen *pscreen = screen->base.screen;
- struct pipe_context *pipe = NULL;
if (drawable->old_num == buffer_count &&
drawable->old_w == dri_drawable->w &&
@@ -308,14 +307,8 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
* The single-sample resources are not exposed
* to the state tracker.
*
- * We don't have a context here, so create one temporarily.
- * We may need to create a persistent context if creation and
- * destruction of the context becomes a bottleneck.
*/
- if (!pipe)
- pipe = pscreen->context_create(pscreen, NULL);
-
- dri_pipe_blit(pipe,
+ dri_pipe_blit(ctx->st->pipe,
drawable->msaa_textures[att],
drawable->textures[att]);
}
@@ -371,11 +364,6 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
drawable->old_w = dri_drawable->w;
drawable->old_h = dri_drawable->h;
memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * buffer_count);
-
- if (pipe) {
- pipe->flush(pipe, NULL, 0);
- pipe->destroy(pipe);
- }
}
static __DRIbuffer *
@@ -470,7 +458,8 @@ dri2_release_buffer(__DRIscreen *sPriv, __DRIbuffer *bPriv)
*/
static void
-dri2_allocate_textures(struct dri_drawable *drawable,
+dri2_allocate_textures(struct dri_context *ctx,
+ struct dri_drawable *drawable,
const enum st_attachment_type *statts,
unsigned statts_count)
{
@@ -479,7 +468,7 @@ dri2_allocate_textures(struct dri_drawable *drawable,
buffers = dri2_drawable_get_buffers(drawable, statts, &num_buffers);
if (buffers)
- dri2_drawable_process_buffers(drawable, buffers, num_buffers,
+ dri2_drawable_process_buffers(ctx, drawable, buffers, num_buffers,
statts, statts_count);
}
diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c
index 41f66d5e4d4..121a2057a32 100644
--- a/src/gallium/state_trackers/dri/sw/drisw.c
+++ b/src/gallium/state_trackers/dri/sw/drisw.c
@@ -182,7 +182,8 @@ drisw_flush_frontbuffer(struct dri_context *ctx,
* framebuffer is resized or destroyed.
*/
static void
-drisw_allocate_textures(struct dri_drawable *drawable,
+drisw_allocate_textures(struct dri_context *stctx,
+ struct dri_drawable *drawable,
const enum st_attachment_type *statts,
unsigned count)
{