gallium: add PIPE_FLUSH_DEFERRED
authorMarek Olšák <marek.olsak@amd.com>
Fri, 15 Jul 2016 13:44:29 +0000 (15:44 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 22 Jul 2016 20:34:49 +0000 (22:34 +0200)
There are 2 uses:
- Asynchronous flushing for multithreaded drivers.
- Return a fence without flushing (mid-command-buffer fence). The driver
  can defer flushing until fence_finish is called.

This is required to make Bioshock Infinite faster, which creates
1000 fences (flushes) per frame.

Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Rob Clark <robdclark@gmail.com>
src/gallium/docs/source/context.rst
src/gallium/include/pipe/p_defines.h
src/mesa/state_tracker/st_cb_syncobj.c

index 05c6f11ea4815bdecd6d220ccd16d94ed185bb7a..8fb621bcac32cc6108f2348f7d341fe38639bb1b 100644 (file)
@@ -463,6 +463,16 @@ Flushing
 
 ``flush``
 
+PIPE_FLUSH_END_OF_FRAME: Whether the flush marks the end of frame.
+
+PIPE_FLUSH_DEFERRED: It is not required to flush right away, but it is required
+to return a valid fence. The behavior of fence_finish or any other call isn't
+changed. The only side effect can be that fence_finish will wait a little
+longer. No guidance is given as to how drivers should implement fence_finish
+with deferred flushes. If some drivers can't do deferred flushes safely, they
+should just ignore the flag.
+
+
 
 ``flush_resource``
 
index 3ab6c2f62b0f6fe0e48f62f1ad5f48facff59168..2524e424d7b05118cfd0ec4c8bfaa366feb49835 100644 (file)
@@ -348,7 +348,8 @@ enum pipe_transfer_usage
  */
 enum pipe_flush_flags
 {
-   PIPE_FLUSH_END_OF_FRAME = (1 << 0)
+   PIPE_FLUSH_END_OF_FRAME = (1 << 0),
+   PIPE_FLUSH_DEFERRED = (1 << 1),
 };
 
 /**
index ec2687fba53010178de36be7a8f96e818c7e42f5..69f2a289adab97cd961a969c313f583fad5f8fe7 100644 (file)
@@ -73,7 +73,7 @@ static void st_fence_sync(struct gl_context *ctx, struct gl_sync_object *obj,
    assert(condition == GL_SYNC_GPU_COMMANDS_COMPLETE && flags == 0);
    assert(so->fence == NULL);
 
-   pipe->flush(pipe, &so->fence, 0);
+   pipe->flush(pipe, &so->fence, PIPE_FLUSH_DEFERRED);
 }
 
 static void st_check_sync(struct gl_context *ctx, struct gl_sync_object *obj)