summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/dri/dri1.c46
-rw-r--r--src/gallium/state_trackers/dri/dri1.h3
-rw-r--r--src/gallium/state_trackers/dri/dri_st_api.c13
3 files changed, 37 insertions, 25 deletions
diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c
index 240bc69efd5..9108d41bd94 100644
--- a/src/gallium/state_trackers/dri/dri1.c
+++ b/src/gallium/state_trackers/dri/dri1.c
@@ -318,23 +318,23 @@ dri1_copy_to_front(struct dri_context *ctx,
}
void
-dri1_flush_frontbuffer(struct dri_drawable *drawable,
- struct pipe_texture *ptex)
+dri1_flush_frontbuffer(struct dri_drawable *draw,
+ enum st_attachment_type statt)
{
- struct st_api *stapi = dri_get_st_api();
- struct dri_screen *screen = dri_screen(drawable->sPriv);
+ struct dri_context *ctx = dri_get_current();
+ struct dri_screen *screen = dri_screen(draw->sPriv);
struct pipe_screen *pipe_screen = screen->pipe_screen;
- struct dri_context *ctx;
struct pipe_fence_handle *dummy_fence;
- struct st_context_iface *st = stapi->get_current(stapi);
-
- if (!st)
- return;
+ struct pipe_texture *ptex;
- ctx = (struct dri_context *) st->st_manager_private;
+ if (!ctx)
+ return; /* For now */
- dri1_copy_to_front(ctx, ptex, ctx->dPriv, NULL, &dummy_fence);
- pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL);
+ ptex = draw->textures[statt];
+ if (ptex) {
+ dri1_copy_to_front(ctx, ptex, ctx->dPriv, NULL, &dummy_fence);
+ pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL);
+ }
/**
* FIXME: Do we need swap throttling here?
@@ -399,17 +399,31 @@ dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h)
}
}
+/**
+ * Allocate framebuffer attachments.
+ *
+ * During fixed-size operation, the function keeps allocating new attachments
+ * as they are requested. Unused attachments are not removed, not until the
+ * framebuffer is resized or destroyed.
+ */
void
dri1_allocate_textures(struct dri_drawable *drawable,
- unsigned width, unsigned height,
unsigned mask)
{
struct dri_screen *screen = dri_screen(drawable->sPriv);
struct pipe_texture templ;
+ unsigned width, height;
+ boolean resized;
int i;
+ width = drawable->dPriv->w;
+ height = drawable->dPriv->h;
+
+ resized = (drawable->old_w != width ||
+ drawable->old_h != height);
+
/* remove outdated textures */
- if (drawable->old_w != width || drawable->old_h != height) {
+ if (resized) {
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
pipe_texture_reference(&drawable->textures[i], NULL);
}
@@ -427,9 +441,6 @@ dri1_allocate_textures(struct dri_drawable *drawable,
/* the texture already exists or not requested */
if (drawable->textures[i] || !(mask & (1 << i))) {
- /* remember the texture */
- if (drawable->textures[i])
- mask |= (1 << i);
continue;
}
@@ -462,7 +473,6 @@ dri1_allocate_textures(struct dri_drawable *drawable,
drawable->old_w = width;
drawable->old_h = height;
- drawable->texture_mask = mask;
}
static void
diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h
index e83571e57be..f1004281b54 100644
--- a/src/gallium/state_trackers/dri/dri1.h
+++ b/src/gallium/state_trackers/dri/dri1.h
@@ -45,11 +45,10 @@ dri1_init_screen(__DRIscreen * sPriv);
void
dri1_flush_frontbuffer(struct dri_drawable *drawable,
- struct pipe_texture *ptex);
+ enum st_attachment_type statt);
void
dri1_allocate_textures(struct dri_drawable *drawable,
- unsigned width, unsigned height,
unsigned mask);
void dri1_swap_buffers(__DRIdrawable * dPriv);
diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c
index e721e55459d..2cdfd257b01 100644
--- a/src/gallium/state_trackers/dri/dri_st_api.c
+++ b/src/gallium/state_trackers/dri/dri_st_api.c
@@ -285,8 +285,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
if (drawable->texture_stamp != drawable->dPriv->lastStamp ||
(statt_mask & ~drawable->texture_mask)) {
if (__dri1_api_hooks) {
- dri1_allocate_textures(drawable,
- drawable->dPriv->w, drawable->dPriv->h, statt_mask);
+ dri1_allocate_textures(drawable, statt_mask);
}
else {
__DRIbuffer *buffers;
@@ -296,6 +295,12 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
dri_drawable_process_buffers(drawable, buffers, num_buffers);
}
+ /* 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;
}
@@ -321,9 +326,7 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
drawable->sPriv->dri2.loader;
if (__dri1_api_hooks) {
- struct pipe_texture *ptex = drawable->textures[statt];
- if (ptex)
- dri1_flush_frontbuffer(drawable, ptex);
+ dri1_flush_frontbuffer(drawable, statt);
return TRUE;
}