[Mesa-dev] [PATCH] gallium: add flush_resource context function
Marek Olšák
maraeo at gmail.com
Tue Jul 16 04:35:13 PDT 2013
r600g needs explicit flushing before DRI2 buffers are presented on the screen.
A complete implementation in all drivers will follow once this is acked.
---
src/gallium/docs/source/context.rst | 13 +++++++++++++
src/gallium/include/pipe/p_context.h | 13 +++++++++++++
src/gallium/state_trackers/dri/common/dri_drawable.c | 4 ++++
src/gallium/state_trackers/dri/drm/dri2.c | 7 ++++---
4 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
index bfd58a4..9ef0f5f 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -421,6 +421,19 @@ Flushing
``flush``
+``flush_resource``
+
+Flush the resource cache, so that the resource can be used
+by an external client. Possible usage:
+- flushing a resource before presenting it on the screen
+- flushing a resource if some other process or device wants to use it
+This shouldn't be used to flush caches if the resource is only managed
+by a single pipe_screen and is not shared with another process.
+(i.e. you shouldn't use it to flush caches explicitly if you want to e.g.
+use the resource for texturing)
+
+
+
Resource Busy Queries
^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index aa18cbf..63ba16f 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -541,6 +541,19 @@ struct pipe_context {
unsigned sample_count,
unsigned sample_index,
float *out_value);
+
+ /**
+ * Flush the resource cache, so that the resource can be used
+ * by an external client. Possible usage:
+ * - flushing a resource before presenting it on the screen
+ * - flushing a resource if some other process or device wants to use it
+ * This shouldn't be used to flush caches if the resource is only managed
+ * by a single pipe_screen and is not shared with another process.
+ * (i.e. you shouldn't use it to flush caches explicitly if you want to e.g.
+ * use the resource for texturing)
+ */
+ void (*flush_resource)(struct pipe_context *ctx,
+ struct pipe_resource *resource);
};
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c
index 18d8d89..6e5794d 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
@@ -435,6 +435,8 @@ dri_flush(__DRIcontext *cPriv,
/* Flush the drawable. */
if ((flags & __DRI2_FLUSH_DRAWABLE) &&
drawable->textures[ST_ATTACHMENT_BACK_LEFT]) {
+ struct pipe_context *pipe = ctx->st->pipe;
+
if (drawable->stvis.samples > 1 &&
reason == __DRI2_THROTTLE_SWAPBUFFER) {
/* Resolve the MSAA back buffer. */
@@ -455,6 +457,8 @@ dri_flush(__DRIcontext *cPriv,
if (ctx->hud) {
hud_draw(ctx->hud, drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
}
+
+ pipe->flush_resource(pipe, drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
}
flush_flags = 0;
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 1dcc1f7..8bb0f3d 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -490,20 +490,21 @@ dri2_flush_frontbuffer(struct dri_context *ctx,
{
__DRIdrawable *dri_drawable = drawable->dPriv;
struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader;
+ struct pipe_context *pipe = ctx->st->pipe;
if (statt != ST_ATTACHMENT_FRONT_LEFT)
return;
if (drawable->stvis.samples > 1) {
- struct pipe_context *pipe = ctx->st->pipe;
-
/* Resolve the front buffer. */
dri_pipe_blit(ctx->st->pipe,
drawable->textures[ST_ATTACHMENT_FRONT_LEFT],
drawable->msaa_textures[ST_ATTACHMENT_FRONT_LEFT]);
- pipe->flush(pipe, NULL, 0);
}
+ pipe->flush_resource(pipe, drawable->textures[ST_ATTACHMENT_FRONT_LEFT]);
+ pipe->flush(pipe, NULL, 0);
+
if (loader->flushFrontBuffer) {
loader->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate);
}
--
1.8.1.2
More information about the mesa-dev
mailing list