4, /* verts */
2); /* attribs/vert */
- pipe->flush(pipe, PIPE_FLUSH_WAIT);
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
/* need to signal that the texture has changed _after_ rendering to it */
pipe->texture_update(pipe, pt, face, (1 << dstLevel));
void
-cell_flush(struct pipe_context *pipe, unsigned flags)
+cell_flush(struct pipe_context *pipe, unsigned flags,
+ struct pipe_fence_handle **fence)
{
struct cell_context *cell = cell_context(pipe);
+ if (fence) {
+ *fence = NULL;
+ /* XXX: Implement real fencing */
+ flags |= CELL_FLUSH_WAIT;
+ }
+
if (flags & PIPE_FLUSH_SWAPBUFFERS)
- flags |= PIPE_FLUSH_WAIT;
+ flags |= CELL_FLUSH_WAIT;
draw_flush( cell->draw );
cell_flush_int(pipe, flags);
ASSERT(!flushing);
flushing = TRUE;
- if (flags & PIPE_FLUSH_WAIT) {
+ if (flags & CELL_FLUSH_WAIT) {
uint64_t *cmd = (uint64_t *) cell_batch_alloc(cell, sizeof(uint64_t));
*cmd = CELL_CMD_FINISH;
}
}
#endif
- if (flags & PIPE_FLUSH_WAIT) {
+ if (flags & CELL_FLUSH_WAIT) {
/* Wait for ack */
for (i = 0; i < cell->num_spus; i++) {
uint k = wait_mbox_message(cell_global.spe_contexts[i]);
#ifndef CELL_FLUSH
#define CELL_FLUSH
+#define CELL_FLUSH_WAIT 0x80000000
+
extern void
-cell_flush(struct pipe_context *pipe, unsigned flags);
+cell_flush(struct pipe_context *pipe, unsigned flags,
+ struct pipe_fence_handle **fence);
extern void
cell_flush_int(struct pipe_context *pipe, unsigned flags);
#if 0
/* helpful for debug */
- cell_flush_int(&cell->pipe, PIPE_FLUSH_WAIT);
+ cell_flush_int(&cell->pipe, CELL_FLUSH_WAIT);
#endif
}
vs->num_elts = n;
send_mbox_message(cell_global.spe_contexts[0], CELL_CMD_VS_EXECUTE);
- cell_flush_int(& cell->pipe, PIPE_FLUSH_WAIT);
+ cell_flush_int(& cell->pipe, CELL_FLUSH_WAIT);
}
draw->vs.post_nr = draw->vs.queue_nr;
start,
count )) {
- failover->hw->flush( failover->hw, ~0 );
+ failover->hw->flush( failover->hw, ~0, NULL );
failover->mode = FO_SW;
}
}
* intervening flush. Unlikely to be much performance impact to
* this:
*/
- failover->sw->flush( failover->sw, ~0 );
+ failover->sw->flush( failover->sw, ~0, NULL );
}
return TRUE;
#define ADVANCE_BATCH()
-#define FLUSH_BATCH() do { \
+#define FLUSH_BATCH(fence) do { \
if (0) i915_dump_batchbuffer( i915 ); \
- i915->winsys->batch_flush( i915->winsys ); \
+ i915->winsys->batch_flush( i915->winsys, fence ); \
i915->batch_start = NULL; \
i915->hardware_dirty = ~0; \
} while (0)
if (!BEGIN_BATCH(6, 1)) {
- FLUSH_BATCH();
+ FLUSH_BATCH(NULL);
assert(BEGIN_BATCH(6, 1));
}
OUT_BATCH(CMD);
if (!BEGIN_BATCH(8, 2)) {
- FLUSH_BATCH();
+ FLUSH_BATCH(NULL);
assert(BEGIN_BATCH(8, 2));
}
OUT_BATCH(CMD);
#include "i915_batch.h"
-/**
- * In future we may want a fence-like interface instead of finish.
- */
static void i915_flush( struct pipe_context *pipe,
- unsigned flags )
+ unsigned flags,
+ struct pipe_fence_handle **fence )
{
struct i915_context *i915 = i915_context(pipe);
flush |= FLUSH_MAP_CACHE;
if (!BEGIN_BATCH(1, 0)) {
- FLUSH_BATCH();
+ FLUSH_BATCH(NULL);
assert(BEGIN_BATCH(1, 0));
}
OUT_BATCH( flush );
/* If there are no flags, just flush pending commands to hardware:
*/
- FLUSH_BATCH();
-
- if (flags & PIPE_FLUSH_WAIT) {
- i915->winsys->batch_finish(i915->winsys);
- }
+ FLUSH_BATCH(fence);
}
assert(vertex_size >= 12); /* never smaller than 12 bytes */
if (!BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 )) {
- FLUSH_BATCH();
+ FLUSH_BATCH(NULL);
/* Make sure state is re-emitted after a flush:
*/
i915_emit_hardware_state( i915 );
if (!BEGIN_BATCH( 1 + (nr_indices + 1)/2, 1 )) {
- FLUSH_BATCH();
+ FLUSH_BATCH(NULL);
/* Make sure state is re-emitted after a flush:
*/
#endif
if(!BEGIN_BATCH(dwords, relocs)) {
- FLUSH_BATCH();
+ FLUSH_BATCH(NULL);
assert(BEGIN_BATCH(dwords, relocs));
}
*/
struct pipe_buffer;
+struct pipe_fence_handle;
struct pipe_winsys;
struct pipe_screen;
unsigned access_flags,
unsigned delta );
- void (*batch_flush)( struct i915_winsys *sws );
- void (*batch_finish)( struct i915_winsys *sws );
+ void (*batch_flush)( struct i915_winsys *sws,
+ struct pipe_fence_handle **fence );
};
#define I915_BUFFER_ACCESS_WRITE 0x1
#include "brw_batch.h"
-/**
- * In future we may want a fence-like interface instead of finish.
- */
static void brw_flush( struct pipe_context *pipe,
- unsigned flags )
+ unsigned flags,
+ struct pipe_fence_handle **fence )
{
struct brw_context *brw = brw_context(pipe);
- struct pipe_fence_handle *fence;
/* Do we need to emit an MI_FLUSH command to flush the hardware
* caches?
/* If there are no flags, just flush pending commands to hardware:
*/
- FLUSH_BATCH( &fence );
-
- if (flags & PIPE_FLUSH_WAIT) {
-// brw->winsys->wait_fence(brw->winsys, fence);
- }
+ FLUSH_BATCH( fence );
}
#include "sp_winsys.h"
-/* There will be actual work to do here. In future we may want a
- * fence-like interface instead of finish, and perhaps flush will take
- * flags to indicate what type of flush is required.
- */
void
softpipe_flush( struct pipe_context *pipe,
- unsigned flags )
+ unsigned flags,
+ struct pipe_fence_handle **fence )
{
struct softpipe_context *softpipe = softpipe_context(pipe);
uint i;
* to unmap surfaces when flushing.
*/
softpipe_unmap_surfaces(softpipe);
+
+ if (fence)
+ *fence = NULL;
}
#define SP_FLUSH_H
struct pipe_context;
+struct pipe_fence_handle;
-void softpipe_flush(struct pipe_context *pipe, unsigned flags );
+void softpipe_flush(struct pipe_context *pipe, unsigned flags,
+ struct pipe_fence_handle **fence);
#endif
struct pipe_screen;
-
+struct pipe_fence_handle;
struct pipe_state_cache;
/* Opaque driver handles:
/* Flush rendering:
*/
void (*flush)( struct pipe_context *pipe,
- unsigned flags );
+ unsigned flags,
+ struct pipe_fence_handle **fence );
};
*/
#define PIPE_FLUSH_RENDER_CACHE 0x1
#define PIPE_FLUSH_TEXTURE_CACHE 0x2
-#define PIPE_FLUSH_WAIT 0x4
-#define PIPE_FLUSH_SWAPBUFFERS 0x8
+#define PIPE_FLUSH_SWAPBUFFERS 0x4
/**
assert(intel); /* should never be null */
if (intel) {
- st_flush(intel->st, PIPE_FLUSH_WAIT);
+ st_finish(intel->st);
intel_batchbuffer_free(intel->batch);
intelUnbindContext(__DRIcontextPrivate * driContextPriv)
{
struct intel_context *intel = intel_context(driContextPriv);
- st_flush(intel->st, 0x0);
+ st_flush(intel->st, PIPE_FLUSH_RENDER_CACHE, NULL);
/* XXX make_current(NULL)? */
return GL_TRUE;
}
#include "intel_winsys.h"
#include "pipe/p_util.h"
+#include "pipe/p_winsys.h"
#include "i915simple/i915_winsys.h"
#include "i915simple/i915_screen.h"
struct intel_i915_winsys {
struct i915_winsys winsys; /**< batch buffer funcs */
+ struct pipe_winsys *pws;
struct intel_context *intel;
};
-static void intel_i915_batch_flush( struct i915_winsys *sws )
+static void intel_i915_batch_flush( struct i915_winsys *sws,
+ struct pipe_fence_handle **fence )
{
- struct intel_context *intel = intel_i915_winsys(sws)->intel;
+ struct intel_i915_winsys *iws = intel_i915_winsys(sws);
+ struct intel_context *intel = iws->intel;
+ union {
+ struct _DriFenceObject *dri;
+ struct pipe_fence_handle *pipe;
+ } fu;
- intel_batchbuffer_flush( intel->batch );
-// if (0) intel_i915_batch_wait_idle( sws );
-}
+ fu.dri = intel_batchbuffer_flush( intel->batch );
+ if (fu.dri)
+ iws->pws->fence_reference(iws->pws, fence, fu.pipe);
-static void intel_i915_batch_finish( struct i915_winsys *sws )
-{
- struct intel_context *intel = intel_i915_winsys(sws)->intel;
- intel_batchbuffer_finish( intel->batch );
+// if (0) intel_i915_batch_wait_idle( sws );
}
iws->winsys.batch_dword = intel_i915_batch_dword;
iws->winsys.batch_reloc = intel_i915_batch_reloc;
iws->winsys.batch_flush = intel_i915_batch_flush;
- iws->winsys.batch_finish = intel_i915_batch_finish;
+ iws->pws = winsys;
iws->intel = intel;
screen = i915_create_screen(winsys, intel->intelScreen->deviceID);
}
+/*
+ * Fence functions - basically nothing to do, as we don't create any actual
+ * fence objects.
+ */
+
+static void
+xm_fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *fence)
+{
+}
+
+
+static int
+xm_fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
+ unsigned flag)
+{
+ return 0;
+}
+
+
+static int
+xm_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
+ unsigned flag)
+{
+ return 0;
+}
+
/**
* Return pointer to a pipe_winsys object.
ws->base.surface_alloc_storage = xm_surface_alloc_storage;
ws->base.surface_release = xm_surface_release;
+ ws->fence_reference = xm_fence_reference;
+ ws->fence_signalled = xm_fence_signalled;
+ ws->fence_finish = xm_fence_finish;
+
ws->base.flush_frontbuffer = xm_flush_frontbuffer;
ws->base.printf = xm_printf;
ws->base.get_name = xm_get_name;
const GLint height = ctx->DrawBuffer->_Ymax - ypos;
/* make sure color bufs aren't cached */
- pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE);
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
switch (op) {
case GL_ADD:
GLint skipPixels;
ubyte *stmap;
- pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE);
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
/* map the stencil buffer */
stmap = pipe_surface_map(ps);
enum pipe_format srcFormat, texFormat;
/* make sure rendering has completed */
- pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE);
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
st_validate_state(st);
assert(strb);
- ctx->st->pipe->flush(ctx->st->pipe, PIPE_FLUSH_RENDER_CACHE);
+ ctx->st->pipe->flush(ctx->st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
/*
printf("FINISH RENDER TO TEXTURE surf=%p\n", strb->surface);
#include "pipe/p_winsys.h"
-void st_flush( struct st_context *st, uint pipeFlushFlags )
+void st_flush( struct st_context *st, uint pipeFlushFlags,
+ struct pipe_fence_handle **fence )
{
FLUSH_VERTICES(st->ctx, 0);
- st->pipe->flush( st->pipe, pipeFlushFlags );
+ st->pipe->flush( st->pipe, pipeFlushFlags, fence );
}
-static void st_gl_flush( struct st_context *st, uint pipeFlushFlags )
+static void st_gl_flush( struct st_context *st, uint pipeFlushFlags,
+ struct pipe_fence_handle **fence )
{
GLframebuffer *fb = st->ctx->DrawBuffer;
- FLUSH_VERTICES(st->ctx, 0);
+ st_flush( st, pipeFlushFlags, fence );
if (!fb)
return;
= st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
struct pipe_surface *front_surf = strb->surface;
- /* If we aren't rendering to the frontbuffer, this is a noop.
- * This should be uncontroversial for glFlush, though people may
- * feel more strongly about glFinish.
- *
- * Additionally, need to make sure that the frontbuffer_dirty
- * flag really gets set on frontbuffer rendering.
- */
- st->pipe->flush( st->pipe, pipeFlushFlags );
-
/* Hook for copying "fake" frontbuffer if necessary:
*/
st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf,
*/
static void st_glFlush(GLcontext *ctx)
{
- st_gl_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE);
+ st_gl_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+}
+
+
+void st_finish( struct st_context *st )
+{
+ struct pipe_fence_handle *fence;
+
+ st_gl_flush(st, PIPE_FLUSH_RENDER_CACHE, &fence);
+
+ st->pipe->winsys->fence_finish(st->pipe->winsys, fence, 0);
+ st->pipe->winsys->fence_reference(st->pipe->winsys, &fence, NULL);
}
*/
static void st_glFinish(GLcontext *ctx)
{
- st_gl_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_WAIT);
+ st_finish( ctx->st );
}
return;
/* make sure rendering has completed */
- pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE);
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
if (format == GL_STENCIL_INDEX) {
st_read_stencil_pixels(ctx, x, y, width, height, type, pack, dest);
if (ctx && ctx->DrawBuffer == &stfb->Base) {
st_flush( ctx->st,
- PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_SWAPBUFFERS);
+ PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_SWAPBUFFERS,
+ NULL );
}
}
struct st_context;
struct st_framebuffer;
struct pipe_context;
+struct pipe_fence_handle;
struct pipe_surface;
struct st_framebuffer *draw,
struct st_framebuffer *read);
-void st_flush( struct st_context *st, uint pipeFlushFlags );
+void st_flush( struct st_context *st, uint pipeFlushFlags,
+ struct pipe_fence_handle **fence );
+void st_finish( struct st_context *st );
void st_notify_swapbuffers(struct st_framebuffer *stfb);
void st_notify_swapbuffers_complete(struct st_framebuffer *stfb);