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.

cell_flush.c 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /**************************************************************************
  2. *
  3. * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  22. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. #include "cell_context.h"
  28. #include "cell_batch.h"
  29. #include "cell_flush.h"
  30. #include "cell_spu.h"
  31. #include "cell_render.h"
  32. #include "draw/draw_context.h"
  33. /**
  34. * Called via pipe->flush()
  35. */
  36. void
  37. cell_flush(struct pipe_context *pipe, unsigned flags,
  38. struct pipe_fence_handle **fence)
  39. {
  40. struct cell_context *cell = cell_context(pipe);
  41. if (fence) {
  42. *fence = NULL;
  43. /* XXX: Implement real fencing */
  44. flags |= CELL_FLUSH_WAIT;
  45. }
  46. if (flags & (PIPE_FLUSH_SWAPBUFFERS | PIPE_FLUSH_RENDER_CACHE))
  47. flags |= CELL_FLUSH_WAIT;
  48. draw_flush( cell->draw );
  49. cell_flush_int(cell, flags);
  50. }
  51. /**
  52. * Cell internal flush function. Send the current batch buffer to all SPUs.
  53. * If flags & CELL_FLUSH_WAIT, do not return until the SPUs are idle.
  54. * \param flags bitmask of flags CELL_FLUSH_WAIT, or zero
  55. */
  56. void
  57. cell_flush_int(struct cell_context *cell, unsigned flags)
  58. {
  59. static boolean flushing = FALSE; /* recursion catcher */
  60. uint i;
  61. ASSERT(!flushing);
  62. flushing = TRUE;
  63. if (flags & CELL_FLUSH_WAIT) {
  64. uint64_t *cmd = (uint64_t *) cell_batch_alloc(cell, sizeof(uint64_t));
  65. *cmd = CELL_CMD_FINISH;
  66. }
  67. cell_batch_flush(cell);
  68. #if 0
  69. /* Send CMD_FINISH to all SPUs */
  70. for (i = 0; i < cell->num_spus; i++) {
  71. send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FINISH);
  72. }
  73. #endif
  74. if (flags & CELL_FLUSH_WAIT) {
  75. /* Wait for ack */
  76. for (i = 0; i < cell->num_spus; i++) {
  77. uint k = wait_mbox_message(cell_global.spe_contexts[i]);
  78. assert(k == CELL_CMD_FINISH);
  79. }
  80. }
  81. flushing = FALSE;
  82. }
  83. void
  84. cell_flush_buffer_range(struct cell_context *cell, void *ptr,
  85. unsigned size)
  86. {
  87. uint64_t batch[1 + (ROUNDUP8(sizeof(struct cell_buffer_range)) / 8)];
  88. struct cell_buffer_range *br = (struct cell_buffer_range *) & batch[1];
  89. batch[0] = CELL_CMD_FLUSH_BUFFER_RANGE;
  90. br->base = (uintptr_t) ptr;
  91. br->size = size;
  92. cell_batch_append(cell, batch, sizeof(batch));
  93. }