~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
static void virgl_vtest_resource_unmap(struct virgl_winsys *vws,
42
42
                                       struct virgl_hw_res *res);
43
43
 
44
 
static inline boolean can_cache_resource_with_bind(uint32_t bind)
 
44
static inline bool can_cache_resource_with_bind(uint32_t bind)
45
45
{
46
46
   return bind == VIRGL_BIND_CONSTANT_BUFFER ||
47
47
          bind == VIRGL_BIND_INDEX_BUFFER ||
187
187
   FREE(res);
188
188
}
189
189
 
190
 
static boolean virgl_vtest_resource_is_busy(struct virgl_winsys *vws,
191
 
                                            struct virgl_hw_res *res)
 
190
static bool virgl_vtest_resource_is_busy(struct virgl_winsys *vws,
 
191
                                         struct virgl_hw_res *res)
192
192
{
193
193
   struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws);
194
194
 
197
197
   ret = virgl_vtest_busy_wait(vtws, res->res_handle, 0);
198
198
 
199
199
   if (ret < 0)
200
 
      return FALSE;
 
200
      return false;
201
201
 
202
 
   return ret == 1 ? TRUE : FALSE;
 
202
   return ret == 1 ? true : false;
203
203
}
204
204
 
205
205
static void virgl_vtest_resource_reference(struct virgl_winsys *vws,
414
414
   return res;
415
415
}
416
416
 
417
 
static boolean virgl_vtest_lookup_res(struct virgl_vtest_cmd_buf *cbuf,
418
 
                                      struct virgl_hw_res *res)
 
417
static bool virgl_vtest_lookup_res(struct virgl_vtest_cmd_buf *cbuf,
 
418
                                   struct virgl_hw_res *res)
419
419
{
420
420
   unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1);
421
421
   int i;
469
469
 
470
470
   cbuf->res_bo[cbuf->cres] = NULL;
471
471
   virgl_vtest_resource_reference(&vtws->base, &cbuf->res_bo[cbuf->cres], res);
472
 
   cbuf->is_handle_added[hash] = TRUE;
 
472
   cbuf->is_handle_added[hash] = true;
473
473
 
474
474
   cbuf->reloc_indices_hashlist[hash] = cbuf->cres;
475
475
   p_atomic_inc(&res->num_cs_references);
555
555
 
556
556
static void virgl_vtest_emit_res(struct virgl_winsys *vws,
557
557
                                 struct virgl_cmd_buf *_cbuf,
558
 
                                 struct virgl_hw_res *res, boolean write_buf)
 
558
                                 struct virgl_hw_res *res, bool write_buf)
559
559
{
560
560
   struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws);
561
561
   struct virgl_vtest_cmd_buf *cbuf = virgl_vtest_cmd_buf(_cbuf);
562
 
   boolean already_in_list = virgl_vtest_lookup_res(cbuf, res);
 
562
   bool already_in_list = virgl_vtest_lookup_res(cbuf, res);
563
563
 
564
564
   if (write_buf)
565
565
      cbuf->base.buf[cbuf->base.cdw++] = res->res_handle;
567
567
      virgl_vtest_add_res(vtws, cbuf, res);
568
568
}
569
569
 
570
 
static boolean virgl_vtest_res_is_ref(struct virgl_winsys *vws,
571
 
                                      struct virgl_cmd_buf *_cbuf,
572
 
                                      struct virgl_hw_res *res)
 
570
static bool virgl_vtest_res_is_ref(struct virgl_winsys *vws,
 
571
                                   struct virgl_cmd_buf *_cbuf,
 
572
                                   struct virgl_hw_res *res)
573
573
{
574
574
   if (!p_atomic_read(&res->num_cs_references))
575
 
      return FALSE;
 
575
      return false;
576
576
 
577
 
   return TRUE;
 
577
   return true;
578
578
}
579
579
 
580
580
static int virgl_vtest_get_caps(struct virgl_winsys *vws,
606
606
   if (timeout == 0)
607
607
      return !virgl_vtest_resource_is_busy(vws, res);
608
608
 
609
 
   if (timeout != PIPE_TIMEOUT_INFINITE) {
 
609
   if (timeout != OS_TIMEOUT_INFINITE) {
610
610
      int64_t start_time = os_time_get();
611
611
      timeout /= 1000;
612
612
      while (virgl_vtest_resource_is_busy(vws, res)) {
613
613
         if (os_time_get() - start_time >= timeout)
614
 
            return FALSE;
 
614
            return false;
615
615
         os_time_sleep(10);
616
616
      }
617
 
      return TRUE;
 
617
      return true;
618
618
   }
619
619
   virgl_vtest_resource_wait(vws, res);
620
 
   return TRUE;
 
620
   return true;
621
621
}
622
622
 
623
623
static void virgl_fence_reference(struct virgl_winsys *vws,