On Wed, Sep 13, 2017 at 5:39 PM, Nicolai Hähnle <nhaeh...@gmail.com> wrote:
> On 12.09.2017 22:50, Marek Olšák wrote:
>>
>> From: Marek Olšák <marek.ol...@amd.com>
>>
>> ---
>>   src/gallium/drivers/radeon/r600_pipe_common.c | 77
>> ++++++++++++++++++++++++++-
>>   src/gallium/drivers/radeonsi/si_pipe.c        |  4 +-
>>   2 files changed, 79 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c
>> b/src/gallium/drivers/radeon/r600_pipe_common.c
>> index 48fda7b..b66acf7 100644
>> --- a/src/gallium/drivers/radeon/r600_pipe_common.c
>> +++ b/src/gallium/drivers/radeon/r600_pipe_common.c
>> @@ -31,20 +31,21 @@
>>   #include "util/u_draw_quad.h"
>>   #include "util/u_memory.h"
>>   #include "util/u_format_s3tc.h"
>>   #include "util/u_upload_mgr.h"
>>   #include "os/os_time.h"
>>   #include "vl/vl_decoder.h"
>>   #include "vl/vl_video_buffer.h"
>>   #include "radeon/radeon_video.h"
>>   #include <inttypes.h>
>>   #include <sys/utsname.h>
>> +#include <libsync.h>
>>     #ifndef HAVE_LLVM
>>   #define HAVE_LLVM 0
>>   #endif
>>     #if HAVE_LLVM
>>   #include <llvm-c/TargetMachine.h>
>>   #endif
>>     #ifndef MESA_LLVM_VERSION_PATCH
>> @@ -448,20 +449,89 @@ static void r600_fence_server_sync(struct
>> pipe_context *ctx,
>>          * this fence dependency is signalled.
>>          *
>>          * Should we flush the context to allow more GPU parallelism?
>>          */
>>         if (rfence->sdma)
>>                 r600_add_fence_dependency(rctx, rfence->sdma);
>>         if (rfence->gfx)
>>                 r600_add_fence_dependency(rctx, rfence->gfx);
>>   }
>>   +static void r600_create_fence_fd(struct pipe_context *ctx,
>> +                                struct pipe_fence_handle **pfence, int
>> fd)
>> +{
>> +       struct r600_common_screen *rscreen = (struct
>> r600_common_screen*)ctx->screen;
>> +       struct radeon_winsys *ws = rscreen->ws;
>> +       struct r600_multi_fence *rfence;
>> +
>> +       *pfence = NULL;
>> +
>> +       if (!rscreen->info.has_sync_file)
>> +               return;
>> +
>> +       rfence = CALLOC_STRUCT(r600_multi_fence);
>> +       if (!rfence)
>> +               return;
>> +
>> +       pipe_reference_init(&rfence->reference, 1);
>> +       rfence->gfx = ws->fence_import_sync_file(ws, fd);
>> +       if (!rfence->gfx) {
>> +               FREE(rfence);
>> +               return;
>> +       }
>> +
>> +       *pfence = (struct pipe_fence_handle*)rfence;
>> +}
>> +
>> +static int r600_fence_get_fd(struct pipe_screen *screen,
>> +                            struct pipe_fence_handle *fence)
>> +{
>> +       struct r600_common_screen *rscreen = (struct
>> r600_common_screen*)screen;
>> +       struct radeon_winsys *ws = rscreen->ws;
>> +       struct r600_multi_fence *rfence = (struct r600_multi_fence
>> *)fence;
>> +       int gfx_fd = -1, sdma_fd = -1;
>> +
>> +       if (!rscreen->info.has_sync_file)
>> +               return -1;
>> +
>> +       /* Deferred fences aren't supported. */
>> +       assert(!rfence->gfx_unflushed.ctx);
>> +       if (rfence->gfx_unflushed.ctx)
>> +               return -1;
>> +
>> +       if (rfence->sdma) {
>> +               sdma_fd = ws->fence_export_sync_file(ws, rfence->sdma);
>> +               if (sdma_fd == -1)
>> +                       return -1;
>> +       }
>> +       if (rfence->gfx) {
>> +               gfx_fd = ws->fence_export_sync_file(ws, rfence->gfx);
>> +               if (gfx_fd == -1) {
>> +                       if (sdma_fd != -1)
>> +                               close(sdma_fd);
>> +                       return -1;
>> +               }
>> +       }
>> +
>> +       /* If we don't have FDs at this point, it means we don't have
>> fences
>> +        * either. */
>> +       if (sdma_fd == -1)
>> +               return gfx_fd;
>> +       if (gfx_fd == -1)
>> +               return sdma_fd;
>> +
>> +       /* Get a fence that will be a combination of both fences. */
>> +       sync_accumulate("radeonsi", &gfx_fd, sdma_fd);
>
>
> What happens if this fails?

gfx_fd will be returned.

Marek
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to