Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

freedreno_fence.c 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
  2. /*
  3. * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the next
  13. * paragraph) shall be included in all copies or substantial portions of the
  14. * Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. *
  24. * Authors:
  25. * Rob Clark <robclark@freedesktop.org>
  26. */
  27. #include "util/u_inlines.h"
  28. #include "freedreno_fence.h"
  29. #include "freedreno_context.h"
  30. #include "freedreno_util.h"
  31. struct pipe_fence_handle {
  32. struct pipe_reference reference;
  33. struct fd_context *ctx;
  34. struct fd_screen *screen;
  35. uint32_t timestamp;
  36. };
  37. void
  38. fd_screen_fence_ref(struct pipe_screen *pscreen,
  39. struct pipe_fence_handle **ptr,
  40. struct pipe_fence_handle *pfence)
  41. {
  42. if (pipe_reference(&(*ptr)->reference, &pfence->reference))
  43. FREE(*ptr);
  44. *ptr = pfence;
  45. }
  46. boolean fd_screen_fence_finish(struct pipe_screen *screen,
  47. struct pipe_fence_handle *fence,
  48. uint64_t timeout)
  49. {
  50. if (fd_pipe_wait_timeout(fence->screen->pipe, fence->timestamp, timeout))
  51. return false;
  52. return true;
  53. }
  54. struct pipe_fence_handle * fd_fence_create(struct pipe_context *pctx,
  55. uint32_t timestamp)
  56. {
  57. struct pipe_fence_handle *fence;
  58. struct fd_context *ctx = fd_context(pctx);
  59. fence = CALLOC_STRUCT(pipe_fence_handle);
  60. if (!fence)
  61. return NULL;
  62. pipe_reference_init(&fence->reference, 1);
  63. fence->ctx = ctx;
  64. fence->screen = ctx->screen;
  65. fence->timestamp = timestamp;
  66. return fence;
  67. }