#include "dri_drawable.h"
#include "pipe/p_screen.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
static uint32_t drifb_ID = 0;
-static void
-swap_fences_unref(struct dri_drawable *draw);
-
-static boolean
+static bool
dri_st_framebuffer_validate(struct st_context_iface *stctx,
struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
(struct dri_drawable *) stfbi->st_manager_private;
struct dri_screen *screen = dri_screen(drawable->sPriv);
unsigned statt_mask, new_mask;
- boolean new_stamp;
+ bool new_stamp;
int i;
unsigned int lastStamp;
struct pipe_resource **textures =
} while (lastStamp != drawable->dPriv->lastStamp);
if (!out)
- return TRUE;
+ return true;
/* Set the window-system buffers for the state tracker. */
for (i = 0; i < count; i++)
pipe_resource_reference(&out[i], textures[statts[i]]);
- return TRUE;
+ return true;
}
-static boolean
+static bool
dri_st_framebuffer_flush_front(struct st_context_iface *stctx,
struct st_framebuffer_iface *stfbi,
enum st_attachment_type statt)
/* XXX remove this and just set the correct one on the framebuffer */
drawable->flush_frontbuffer(ctx, drawable, statt);
- return TRUE;
+ return true;
}
/**
* The state tracker framebuffer interface flush_swapbuffers callback
*/
-static boolean
+static bool
dri_st_framebuffer_flush_swapbuffers(struct st_context_iface *stctx,
struct st_framebuffer_iface *stfbi)
{
if (drawable->flush_swapbuffers)
drawable->flush_swapbuffers(ctx, drawable);
- return TRUE;
+ return true;
}
/**
* This is called when we need to set up GL rendering to a new X window.
*/
-boolean
+bool
dri_create_buffer(__DRIscreen * sPriv,
__DRIdrawable * dPriv,
- const struct gl_config * visual, boolean isPixmap)
+ const struct gl_config * visual, bool isPixmap)
{
struct dri_screen *screen = sPriv->driverPrivate;
struct dri_drawable *drawable = NULL;
drawable->screen = screen;
drawable->sPriv = sPriv;
drawable->dPriv = dPriv;
- drawable->desired_fences = screen->default_throttle_frames;
- if (drawable->desired_fences > DRI_SWAP_FENCES_MAX)
- drawable->desired_fences = DRI_SWAP_FENCES_MAX;
dPriv->driverPrivate = (void *)drawable;
p_atomic_set(&drawable->base.stamp, 1);
drawable->base.ID = p_atomic_inc_return(&drifb_ID);
drawable->base.state_manager = &screen->base;
- return GL_TRUE;
+ return true;
fail:
FREE(drawable);
- return GL_FALSE;
+ return false;
}
void
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
pipe_resource_reference(&drawable->msaa_textures[i], NULL);
- swap_fences_unref(drawable);
+ screen->base.screen->fence_reference(screen->base.screen,
+ &drawable->throttle_fence, NULL);
/* Notify the st manager that this drawable is no longer valid */
stapi->destroy_drawable(stapi, &drawable->base);
if (format == __DRI_TEXTURE_FORMAT_RGB) {
/* only need to cover the formats recognized by dri_fill_st_visual */
switch (internal_format) {
+ case PIPE_FORMAT_R16G16B16A16_FLOAT:
+ internal_format = PIPE_FORMAT_R16G16B16X16_FLOAT;
+ break;
case PIPE_FORMAT_B10G10R10A2_UNORM:
internal_format = PIPE_FORMAT_B10G10R10X2_UNORM;
break;
ctx->st->teximage(ctx->st,
(target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT,
- 0, internal_format, pt, FALSE);
+ 0, internal_format, pt, false);
}
}
}
}
-
-/**
- * swap_fences_pop_front - pull a fence from the throttle queue
- *
- * If the throttle queue is filled to the desired number of fences,
- * pull fences off the queue until the number is less than the desired
- * number of fences, and return the last fence pulled.
- */
-static struct pipe_fence_handle *
-swap_fences_pop_front(struct dri_drawable *draw)
-{
- struct pipe_screen *screen = draw->screen->base.screen;
- struct pipe_fence_handle *fence = NULL;
-
- if (draw->desired_fences == 0)
- return 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->tail &= DRI_SWAP_FENCES_MASK;
- --draw->cur_fences;
- }
- return fence;
-}
-
-
-/**
- * swap_fences_push_back - push a fence onto the throttle queue
- *
- * push a fence onto the throttle queue and pull fences of the queue
- * so that the desired number of fences are on the queue.
- */
-static void
-swap_fences_push_back(struct dri_drawable *draw,
- struct pipe_fence_handle *fence)
-{
- struct pipe_screen *screen = draw->screen->base.screen;
-
- if (!fence || draw->desired_fences == 0)
- return;
-
- while(draw->cur_fences == draw->desired_fences)
- swap_fences_pop_front(draw);
-
- draw->cur_fences++;
- screen->fence_reference(screen, &draw->swap_fences[draw->head++],
- fence);
- draw->head &= DRI_SWAP_FENCES_MASK;
-}
-
-
-/**
- * swap_fences_unref - empty the throttle queue
- *
- * pulls fences of the throttle queue until it is empty.
- */
-static void
-swap_fences_unref(struct dri_drawable *draw)
-{
- struct pipe_screen *screen = draw->screen->base.screen;
-
- while(draw->cur_fences) {
- screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL);
- draw->tail &= DRI_SWAP_FENCES_MASK;
- --draw->cur_fences;
- }
-}
-
void
dri_pipe_blit(struct pipe_context *pipe,
struct pipe_resource *dst,
struct dri_drawable *drawable = dri_drawable(dPriv);
struct st_context_iface *st;
unsigned flush_flags;
- boolean swap_msaa_buffers = FALSE;
+ bool swap_msaa_buffers = false;
if (!ctx) {
assert(0);
if (drawable->flushing)
return;
- drawable->flushing = TRUE;
+ drawable->flushing = true;
}
else {
flags &= ~__DRI2_FLUSH_DRAWABLE;
struct pipe_context *pipe = st->pipe;
if (drawable->stvis.samples > 1 &&
- reason == __DRI2_THROTTLE_SWAPBUFFER) {
+ (reason == __DRI2_THROTTLE_SWAPBUFFER ||
+ reason == __DRI2_THROTTLE_COPYSUBBUFFER)) {
/* Resolve the MSAA back buffer. */
dri_pipe_blit(st->pipe,
drawable->textures[ST_ATTACHMENT_BACK_LEFT],
drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]);
- if (drawable->msaa_textures[ST_ATTACHMENT_FRONT_LEFT] &&
+ if (reason == __DRI2_THROTTLE_SWAPBUFFER &&
+ drawable->msaa_textures[ST_ATTACHMENT_FRONT_LEFT] &&
drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]) {
- swap_msaa_buffers = TRUE;
+ swap_msaa_buffers = true;
}
/* FRONT_LEFT is resolved in drawable->flush_frontbuffer. */
dri_postprocessing(ctx, drawable, ST_ATTACHMENT_BACK_LEFT);
- if (ctx->hud) {
- hud_run(ctx->hud, ctx->st->cso_context,
- drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
- }
-
- pipe->flush_resource(pipe, drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
-
if (pipe->invalidate_resource &&
(flags & __DRI2_FLUSH_INVALIDATE_ANCILLARY)) {
if (drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
if (drawable->msaa_textures[ST_ATTACHMENT_DEPTH_STENCIL])
pipe->invalidate_resource(pipe, drawable->msaa_textures[ST_ATTACHMENT_DEPTH_STENCIL]);
}
+
+ if (ctx->hud) {
+ hud_run(ctx->hud, ctx->st->cso_context,
+ drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
+ }
+
+ pipe->flush_resource(pipe, drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
}
flush_flags = 0;
flush_flags |= ST_FLUSH_END_OF_FRAME;
/* Flush the context and throttle if needed. */
- if (dri_screen(ctx->sPriv)->throttling_enabled &&
+ if (dri_screen(ctx->sPriv)->throttle &&
drawable &&
(reason == __DRI2_THROTTLE_SWAPBUFFER ||
reason == __DRI2_THROTTLE_FLUSHFRONT)) {
- /* Throttle.
- *
- * This pulls a fence off the throttling queue and waits for it if the
- * number of fences on the throttling queue has reached the desired
- * number.
- *
- * Then flushes to insert a fence at the current rendering position, and
- * pushes that fence on the queue. This requires that the st_context_iface
- * flush method returns a fence even if there are no commands to flush.
- */
- struct pipe_screen *screen = drawable->screen->base.screen;
- struct pipe_fence_handle *fence;
- fence = swap_fences_pop_front(drawable);
- if (fence) {
- (void) screen->fence_finish(screen, NULL, fence, PIPE_TIMEOUT_INFINITE);
- screen->fence_reference(screen, &fence, NULL);
- }
+ struct pipe_screen *screen = drawable->screen->base.screen;
+ struct pipe_fence_handle *new_fence = NULL;
- st->flush(st, flush_flags, &fence);
+ st->flush(st, flush_flags, &new_fence);
- if (fence) {
- swap_fences_push_back(drawable, fence);
- screen->fence_reference(screen, &fence, NULL);
+ /* throttle on the previous fence */
+ if (drawable->throttle_fence) {
+ screen->fence_finish(screen, NULL, drawable->throttle_fence, PIPE_TIMEOUT_INFINITE);
+ screen->fence_reference(screen, &drawable->throttle_fence, NULL);
}
+ drawable->throttle_fence = new_fence;
}
else if (flags & (__DRI2_FLUSH_DRAWABLE | __DRI2_FLUSH_CONTEXT)) {
st->flush(st, flush_flags, NULL);
}
if (drawable) {
- drawable->flushing = FALSE;
+ drawable->flushing = false;
}
/* Swap the MSAA front and back buffers, so that reading