summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2007-08-10 12:57:14 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2007-08-10 12:58:26 +0100
commit5c2c05600081f811e001a81a600778de0fcab85d (patch)
treeba4e239592e9798ca3e660158c668afd7d145639 /src
parent9ac1a8d416c2bd50ca10186ca09f5e86f6fa4ce6 (diff)
Handle glFlush/glFinish through the state tracker.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_context.c46
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_pipe_i915simple.c14
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_pipe_softpipe.c31
-rw-r--r--src/mesa/pipe/i915simple/i915_flush.c5
-rw-r--r--src/mesa/pipe/i915simple/i915_winsys.h6
-rw-r--r--src/mesa/pipe/p_context.h6
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_flush.c19
-rw-r--r--src/mesa/pipe/softpipe/sp_flush.h2
-rw-r--r--src/mesa/pipe/softpipe/sp_winsys.h12
-rw-r--r--src/mesa/sources1
-rw-r--r--src/mesa/state_tracker/st_cb_flush.c81
-rw-r--r--src/mesa/state_tracker/st_cb_flush.h38
-rw-r--r--src/mesa/state_tracker/st_context.c2
-rw-r--r--src/mesa/state_tracker/st_context.h4
15 files changed, 212 insertions, 57 deletions
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_context.c b/src/mesa/drivers/dri/intel_winsys/intel_context.c
index 1032fc2d0f..a1746e0965 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_context.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_context.c
@@ -240,51 +240,7 @@ intelFlush(GLcontext * ctx)
}
-/**
- * Check if we need to rotate/warp the front color buffer to the
- * rotated screen. We generally need to do this when we get a glFlush
- * or glFinish after drawing to the front color buffer.
- * If no rotation, just copy the private fake front buffer to the real one.
- */
-static void
-intelCheckFrontUpdate(GLcontext * ctx)
-{
- struct intel_context *intel = intel_context(ctx);
- /* rely on _ColorDrawBufferMask being kept up to date by mesa
- even for window-fbos. */
- /* not sure. Might need that for all masks including
- BUFFER_BIT_FRONT_LEFT maybe? */
- if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] ==
- BUFFER_BIT_FRONT_LEFT) {
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
- intelCopyBuffer(dPriv, NULL);
- }
-}
-
-/**
- * Called via glFlush.
- */
-static void
-intelglFlush(GLcontext * ctx)
-{
- intelFlush(ctx);
- intelCheckFrontUpdate(ctx);
-}
-
-void
-intelFinish(GLcontext * ctx)
-{
- struct intel_context *intel = intel_context(ctx);
- intelFlush(ctx);
- if (intel->batch->last_fence) {
- driFenceFinish(intel->batch->last_fence,
- 0, GL_FALSE);
- driFenceUnReference(intel->batch->last_fence);
- intel->batch->last_fence = NULL;
- }
- intelCheckFrontUpdate(ctx);
-}
static void
@@ -292,8 +248,6 @@ intelInitDriverFunctions(struct dd_function_table *functions)
{
_mesa_init_driver_functions(functions);
- functions->Flush = intelglFlush;
- functions->Finish = intelFinish;
functions->GetString = intelGetString;
functions->UpdateState = intelInvalidateState;
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_pipe_i915simple.c b/src/mesa/drivers/dri/intel_winsys/intel_pipe_i915simple.c
index c0e8c2349c..d78d81aa1c 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_pipe_i915simple.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_pipe_i915simple.c
@@ -37,6 +37,7 @@
#include "intel_context.h"
#include "intel_batchbuffer.h"
#include "intel_pipe.h"
+#include "intel_blit.h"
#include "pipe/i915simple/i915_winsys.h"
@@ -171,7 +172,7 @@ static unsigned *intel_i915_batch_start( struct i915_winsys *sws,
if (intel_batchbuffer_space( intel->batch ) >= dwords * 4) {
/* XXX: Hmm, the driver can't really do much with this pointer:
*/
- return intel->batch->ptr;
+ return (unsigned *)intel->batch->ptr;
}
else
return NULL;
@@ -242,6 +243,16 @@ static void intel_i915_printf( struct i915_winsys *sws,
}
+static void
+intel_i915_flush_frontbuffer( struct i915_winsys *sws )
+{
+ struct intel_context *intel = intel_i915_winsys(sws)->intel;
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+
+ intelCopyBuffer(dPriv, NULL);
+}
+
+
struct pipe_context *
intel_create_i915simple( struct intel_context *intel )
{
@@ -264,6 +275,7 @@ intel_create_i915simple( struct intel_context *intel )
iws->winsys.batch_reloc = intel_i915_batch_reloc;
iws->winsys.batch_flush = intel_i915_batch_flush;
iws->winsys.batch_wait_idle = intel_i915_batch_wait_idle;
+ iws->winsys.flush_frontbuffer = intel_i915_flush_frontbuffer;
iws->intel = intel;
/* Create the i915simple context:
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_pipe_softpipe.c b/src/mesa/drivers/dri/intel_winsys/intel_pipe_softpipe.c
index 06db5c9f43..439bb372e1 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_pipe_softpipe.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_pipe_softpipe.c
@@ -36,6 +36,8 @@
#include "intel_context.h"
#include "intel_pipe.h"
+#include "intel_batchbuffer.h"
+#include "intel_blit.h"
#include "pipe/softpipe/sp_winsys.h"
#include "pipe/p_defines.h"
@@ -175,6 +177,33 @@ intel_supported_formats(struct pipe_context *pipe, GLuint *numFormats)
}
+static void intel_wait_idle( struct softpipe_winsys *sws )
+{
+ struct intel_context *intel = intel_softpipe_winsys(sws)->intel;
+
+ if (intel->batch->last_fence) {
+ driFenceFinish(intel->batch->last_fence,
+ DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW, GL_FALSE);
+ driFenceUnReference(intel->batch->last_fence);
+ intel->batch->last_fence = NULL;
+ }
+}
+
+
+/* The state tracker (should!) keep track of whether the fake
+ * frontbuffer has been touched by any rendering since the last time
+ * we copied its contents to the real frontbuffer. Our task is easy:
+ */
+static void
+intel_flush_frontbuffer( struct softpipe_winsys *sws )
+{
+ struct intel_context *intel = intel_softpipe_winsys(sws)->intel;
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+
+ intelCopyBuffer(dPriv, NULL);
+}
+
+
struct pipe_context *
intel_create_softpipe( struct intel_context *intel )
@@ -197,6 +226,8 @@ intel_create_softpipe( struct intel_context *intel )
isws->sws.buffer_data = intel_buffer_data;
isws->sws.buffer_subdata = intel_buffer_subdata;
isws->sws.buffer_get_subdata = intel_buffer_get_subdata;
+ isws->sws.flush_frontbuffer = intel_flush_frontbuffer;
+ isws->sws.wait_idle = intel_wait_idle;
isws->intel = intel;
/* Create the softpipe context:
diff --git a/src/mesa/pipe/i915simple/i915_flush.c b/src/mesa/pipe/i915simple/i915_flush.c
index 1cf945e9a2..8af4ce770c 100644
--- a/src/mesa/pipe/i915simple/i915_flush.c
+++ b/src/mesa/pipe/i915simple/i915_flush.c
@@ -66,11 +66,10 @@ static void i915_flush( struct pipe_context *pipe,
FLUSH_BATCH();
}
-static void i915_finish(struct pipe_context *pipe)
+static void i915_wait_idle(struct pipe_context *pipe)
{
struct i915_context *i915 = i915_context(pipe);
- i915_flush( pipe, 0 );
i915->winsys->batch_wait_idle( i915->winsys );
}
@@ -78,5 +77,5 @@ static void i915_finish(struct pipe_context *pipe)
void i915_init_flush_functions( struct i915_context *i915 )
{
i915->pipe.flush = i915_flush;
- i915->pipe.finish = i915_finish;
+ i915->pipe.wait_idle = i915_wait_idle;
}
diff --git a/src/mesa/pipe/i915simple/i915_winsys.h b/src/mesa/pipe/i915simple/i915_winsys.h
index 9802148aa1..a3dadbfd3d 100644
--- a/src/mesa/pipe/i915simple/i915_winsys.h
+++ b/src/mesa/pipe/i915simple/i915_winsys.h
@@ -50,6 +50,12 @@ struct pipe_buffer_handle;
struct i915_winsys {
+ /* Do any special operations to ensure frontbuffer contents are
+ * displayed, eg copy fake frontbuffer.
+ */
+ void (*flush_frontbuffer)( struct i915_winsys *sws );
+
+
/* debug output
*/
void (*printf)( struct i915_winsys *sws,
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 7eb492816b..533840c555 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -220,10 +220,14 @@ struct pipe_context {
struct pipe_mipmap_tree *mt );
+ /* Simple flush/finish support:
+ */
void (*flush)( struct pipe_context *pipe,
unsigned flags );
- void (*finish)( struct pipe_context *pipe );
+ void (*wait_idle)( struct pipe_context *pipe );
+
+ void (*flush_frontbuffer)( struct pipe_context *pipe );
};
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 0794d9a888..db572f169d 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -221,7 +221,7 @@ struct pipe_context *softpipe_create( struct softpipe_winsys *sws )
softpipe->pipe.draw_vertices = softpipe_draw_vertices;
softpipe->pipe.clear = softpipe_clear;
softpipe->pipe.flush = softpipe_flush;
- softpipe->pipe.finish = softpipe_finish;
+ softpipe->pipe.wait_idle = softpipe_wait_idle;
softpipe->pipe.reset_occlusion_counter = softpipe_reset_occlusion_counter;
softpipe->pipe.get_occlusion_counter = softpipe_get_occlusion_counter;
diff --git a/src/mesa/pipe/softpipe/sp_flush.c b/src/mesa/pipe/softpipe/sp_flush.c
index aa609469a6..a0bce200ed 100644
--- a/src/mesa/pipe/softpipe/sp_flush.c
+++ b/src/mesa/pipe/softpipe/sp_flush.c
@@ -33,6 +33,7 @@
#include "pipe/p_defines.h"
#include "sp_flush.h"
#include "sp_context.h"
+#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
@@ -49,9 +50,21 @@ softpipe_flush( struct pipe_context *pipe,
}
void
-softpipe_finish(struct pipe_context *pipe)
+softpipe_wait_idle(struct pipe_context *pipe)
{
- /* Just calls into flush()
+ /* Nothing to do.
+ * XXX: What about swapbuffers.
+ * XXX: Even more so - what about fake frontbuffer copies??
*/
- softpipe_flush( pipe, 0 );
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+ softpipe->winsys->wait_idle( softpipe->winsys );
+}
+
+
+void
+softpipe_flush_frontbuffer( struct pipe_context *pipe )
+{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+
+ softpipe->winsys->flush_frontbuffer( softpipe->winsys );
}
diff --git a/src/mesa/pipe/softpipe/sp_flush.h b/src/mesa/pipe/softpipe/sp_flush.h
index 5e204f87a5..03c0010623 100644
--- a/src/mesa/pipe/softpipe/sp_flush.h
+++ b/src/mesa/pipe/softpipe/sp_flush.h
@@ -30,7 +30,7 @@
struct pipe_context;
-void softpipe_finish(struct pipe_context *pipe);
void softpipe_flush(struct pipe_context *pipe, unsigned flags );
+void softpipe_wait_idle(struct pipe_context *pipe);
#endif
diff --git a/src/mesa/pipe/softpipe/sp_winsys.h b/src/mesa/pipe/softpipe/sp_winsys.h
index 6f6d0f2446..73b0659067 100644
--- a/src/mesa/pipe/softpipe/sp_winsys.h
+++ b/src/mesa/pipe/softpipe/sp_winsys.h
@@ -50,9 +50,19 @@ struct pipe_buffer_handle;
struct softpipe_winsys {
+ /* Do any special operations to ensure frontbuffer contents are
+ * displayed, eg copy fake frontbuffer.
+ */
+ void (*flush_frontbuffer)( struct softpipe_winsys *sws );
+
+ /* Wait for any hw swapbuffers, etc. to finish:
+ */
+ void (*wait_idle)( struct softpipe_winsys *sws );
+
/* debug output
*/
- void (*printf)( const char *, ... );
+ void (*printf)( struct softpipe_winsys *sws,
+ const char *, ... );
/* The buffer manager is modeled after the dri_bugmgr interface,
diff --git a/src/mesa/sources b/src/mesa/sources
index 54a0978715..a2b9fed82b 100644
--- a/src/mesa/sources
+++ b/src/mesa/sources
@@ -194,6 +194,7 @@ STATETRACKER_SOURCES = \
state_tracker/st_atom_viewport.c \
state_tracker/st_cb_bufferobjects.c \
state_tracker/st_cb_clear.c \
+ state_tracker/st_cb_flush.c \
state_tracker/st_cb_drawpixels.c \
state_tracker/st_cb_fbo.c \
state_tracker/st_cb_program.c \
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c
new file mode 100644
index 0000000000..a6a8f8d90f
--- /dev/null
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -0,0 +1,81 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+ /*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Brian Paul
+ */
+
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "st_context.h"
+#include "st_cb_flush.h"
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+
+
+static void st_flush(GLcontext *ctx)
+{
+ struct st_context *st = ctx->st;
+
+ /* If there has been no rendering to the frontbuffer, consider
+ * short-circuiting this, or perhaps pass an "optional" flag down
+ * to the driver so that it can make the decision.
+ */
+ st->pipe->flush( st->pipe, 0 );
+
+
+ /* XXX: temporary hack. This flag should only be set if we do any
+ * rendering to the front buffer.
+ */
+ st->flags.frontbuffer_dirty = (ctx->DrawBuffer->_ColorDrawBufferMask[0] ==
+ BUFFER_BIT_FRONT_LEFT);
+
+
+ if (st->flags.frontbuffer_dirty) {
+ /* Hook for copying "fake" frontbuffer if necessary:
+ */
+ st->pipe->flush_frontbuffer( st->pipe );
+ st->flags.frontbuffer_dirty = 0;
+ }
+}
+
+static void st_finish(GLcontext *ctx)
+{
+ struct st_context *st = ctx->st;
+
+ st_flush( ctx );
+ st->pipe->wait_idle( st->pipe );
+}
+
+
+void st_init_flush_functions(struct dd_function_table *functions)
+{
+ functions->Flush = st_flush;
+ functions->Finish = st_finish;
+}
diff --git a/src/mesa/state_tracker/st_cb_flush.h b/src/mesa/state_tracker/st_cb_flush.h
new file mode 100644
index 0000000000..29ceab3a56
--- /dev/null
+++ b/src/mesa/state_tracker/st_cb_flush.h
@@ -0,0 +1,38 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef ST_CB_CLEAR_H
+#define ST_CB_CLEAR_H
+
+
+extern void
+st_init_flush_functions(struct dd_function_table *functions);
+
+
+#endif /* ST_CB_CLEAR_H */
+
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 80935442ae..2bdcc6caf3 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -34,6 +34,7 @@
#include "st_cb_fbo.h"
#include "st_cb_readpixels.h"
#include "st_cb_texture.h"
+#include "st_cb_flush.h"
#include "st_atom.h"
#include "st_draw.h"
#include "st_program.h"
@@ -109,4 +110,5 @@ void st_init_driver_functions(struct dd_function_table *functions)
st_init_program_functions(functions);
st_init_readpixels_functions(functions);
st_init_texture_functions(functions);
+ st_init_flush_functions(functions);
}
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index fe73630c75..88e2701fc3 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -90,6 +90,10 @@ struct st_context
struct gl_fragment_program *fragment_program;
} cb;
+ struct {
+ GLuint frontbuffer_dirty:1;
+ } flags;
+
/* State to be validated:
*/
struct st_tracked_state **atoms;