}
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?
}
}
+/**
+ * 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);
}
/* 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;
}
drawable->old_w = width;
drawable->old_h = height;
- drawable->texture_mask = mask;
}
static void
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;
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;
}
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;
}