~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/drivers/iris/iris_fine_fence.c

  • Committer: mmach
  • Date: 2021-04-17 06:19:36 UTC
  • Revision ID: netbit73@gmail.com-20210417061936-peb5vc5ysl5zeoad
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "iris_context.h"
 
2
#include "iris_fine_fence.h"
 
3
#include "util/u_upload_mgr.h"
 
4
 
 
5
static void
 
6
iris_fine_fence_reset(struct iris_batch *batch)
 
7
{
 
8
   u_upload_alloc(batch->fine_fences.uploader,
 
9
                  0, sizeof(uint64_t), sizeof(uint64_t),
 
10
                  &batch->fine_fences.ref.offset, &batch->fine_fences.ref.res,
 
11
                  (void **)&batch->fine_fences.map);
 
12
   WRITE_ONCE(*batch->fine_fences.map, 0);
 
13
   batch->fine_fences.next++;
 
14
}
 
15
 
 
16
void
 
17
iris_fine_fence_init(struct iris_batch *batch)
 
18
{
 
19
   batch->fine_fences.ref.res = NULL;
 
20
   batch->fine_fences.next = 0;
 
21
   iris_fine_fence_reset(batch);
 
22
}
 
23
 
 
24
static uint32_t
 
25
iris_fine_fence_next(struct iris_batch *batch)
 
26
{
 
27
   uint32_t seqno = batch->fine_fences.next++;
 
28
 
 
29
   if (batch->fine_fences.next == 0)
 
30
      iris_fine_fence_reset(batch);
 
31
 
 
32
   return seqno;
 
33
}
 
34
 
 
35
void
 
36
iris_fine_fence_destroy(struct iris_screen *screen,
 
37
                        struct iris_fine_fence *fine)
 
38
{
 
39
   iris_syncobj_reference(screen, &fine->syncobj, NULL);
 
40
   pipe_resource_reference(&fine->ref.res, NULL);
 
41
   free(fine);
 
42
}
 
43
 
 
44
struct iris_fine_fence *
 
45
iris_fine_fence_new(struct iris_batch *batch, unsigned flags)
 
46
{
 
47
   struct iris_fine_fence *fine = calloc(1, sizeof(*fine));
 
48
   if (!fine)
 
49
      return NULL;
 
50
 
 
51
   pipe_reference_init(&fine->reference, 1);
 
52
 
 
53
   fine->seqno = iris_fine_fence_next(batch);
 
54
 
 
55
   iris_syncobj_reference(batch->screen, &fine->syncobj,
 
56
                          iris_batch_get_signal_syncobj(batch));
 
57
 
 
58
   pipe_resource_reference(&fine->ref.res, batch->fine_fences.ref.res);
 
59
   fine->ref.offset = batch->fine_fences.ref.offset;
 
60
   fine->map = batch->fine_fences.map;
 
61
   fine->flags = flags;
 
62
 
 
63
   unsigned pc;
 
64
   if (flags & IRIS_FENCE_TOP_OF_PIPE) {
 
65
      pc = PIPE_CONTROL_WRITE_IMMEDIATE | PIPE_CONTROL_CS_STALL;
 
66
   } else {
 
67
      pc = PIPE_CONTROL_WRITE_IMMEDIATE |
 
68
           PIPE_CONTROL_RENDER_TARGET_FLUSH |
 
69
           PIPE_CONTROL_DEPTH_CACHE_FLUSH |
 
70
           PIPE_CONTROL_DATA_CACHE_FLUSH;
 
71
   }
 
72
   iris_emit_pipe_control_write(batch, "fence: fine", pc,
 
73
                                iris_resource_bo(fine->ref.res),
 
74
                                fine->ref.offset,
 
75
                                fine->seqno);
 
76
 
 
77
   return fine;
 
78
}