[Mesa-dev] [PATCH 3/3] st/dri: implement __DRI2flushExtensionRec::flush_and_throttle
Marek Olšák
maraeo at gmail.com
Thu Nov 8 05:48:40 PST 2012
---
.../state_trackers/dri/common/dri_drawable.c | 10 +++++-----
.../state_trackers/dri/common/dri_drawable.h | 4 ++++
src/gallium/state_trackers/dri/drm/dri2.c | 19 ++++++++++++++++---
3 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c
index 5a261dd..249201f 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
@@ -352,7 +352,7 @@ swap_fences_unref(struct dri_drawable *draw)
/**
- * dri_throttle - A DRI2ThrottleExtension throttling function.
+ * dri_flush_and_throttle - A DRI2ThrottleExtension throttling function.
*
* pulls a fence off the throttling queue and waits for it if the
* number of fences on the throttling queue has reached the desired
@@ -362,9 +362,9 @@ swap_fences_unref(struct dri_drawable *draw)
* 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.
*/
-static void
-dri_throttle(__DRIcontext *driCtx, __DRIdrawable *dPriv,
- enum __DRI2throttleReason reason)
+void
+dri_flush_and_throttle(__DRIcontext *driCtx, __DRIdrawable *dPriv,
+ enum __DRI2throttleReason reason)
{
struct dri_drawable *draw = dri_drawable(dPriv);
struct st_context_iface *ctxi;
@@ -395,7 +395,7 @@ dri_throttle(__DRIcontext *driCtx, __DRIdrawable *dPriv,
const __DRI2throttleExtension dri2ThrottleExtension = {
.base = { __DRI2_THROTTLE, __DRI2_THROTTLE_VERSION },
- .throttle = dri_throttle,
+ .throttle = dri_flush_and_throttle,
};
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h
index 3e3876e..01cf962 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.h
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.h
@@ -106,6 +106,10 @@ dri_drawable_get_format(struct dri_drawable *drawable,
enum pipe_format *format,
unsigned *bind);
+void
+dri_flush_and_throttle(__DRIcontext *driCtx, __DRIdrawable *dPriv,
+ enum __DRI2throttleReason reason);
+
extern const __DRItexBufferExtension driTexBufferExtension;
extern const __DRI2throttleExtension dri2ThrottleExtension;
#endif
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 931867e..3059675 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -44,7 +44,7 @@
* DRI2 flush extension.
*/
static void
-dri2_flush_drawable(__DRIdrawable *dPriv)
+dri2_flush_drawable_and_throttle(__DRIdrawable *dPriv, enum __DRI2throttleReason reason)
{
struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv);
struct dri_drawable *drawable = dri_drawable(dPriv);
@@ -55,11 +55,23 @@ dri2_flush_drawable(__DRIdrawable *dPriv)
if (ptex && ctx->pp && drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
pp_run(ctx->pp, ptex, ptex, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
- ctx->st->flush(ctx->st, 0, NULL);
+ if (reason) {
+ /* Flush the context and throttle at the same time. */
+ dri_flush_and_throttle(ctx->cPriv, dPriv, reason);
+ }
+ else {
+ ctx->st->flush(ctx->st, 0, NULL);
+ }
}
}
static void
+dri2_flush_drawable(__DRIdrawable *dPriv)
+{
+ dri2_flush_drawable_and_throttle(dPriv, 0);
+}
+
+static void
dri2_invalidate_drawable(__DRIdrawable *dPriv)
{
struct dri_drawable *drawable = dri_drawable(dPriv);
@@ -71,9 +83,10 @@ dri2_invalidate_drawable(__DRIdrawable *dPriv)
}
static const __DRI2flushExtension dri2FlushExtension = {
- { __DRI2_FLUSH, 3 },
+ { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
dri2_flush_drawable,
dri2_invalidate_drawable,
+ dri2_flush_drawable_and_throttle,
};
/**
--
1.7.9.5
More information about the mesa-dev
mailing list