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.

intel_winsys.h 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /**************************************************************************
  2. *
  3. * Copyright © 2009 Jakob Bornecrantz
  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
  21. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. * DEALINGS IN THE SOFTWARE.
  23. *
  24. **************************************************************************/
  25. #ifndef INTEL_WINSYS_H
  26. #define INTEL_WINSYS_H
  27. #include "pipe/p_compiler.h"
  28. struct intel_winsys;
  29. struct intel_buffer;
  30. struct intel_batchbuffer;
  31. struct pipe_texture;
  32. struct pipe_fence_handle;
  33. enum intel_buffer_usage
  34. {
  35. /* use on textures */
  36. INTEL_USAGE_RENDER = 0x01,
  37. INTEL_USAGE_SAMPLER = 0x02,
  38. INTEL_USAGE_2D_TARGET = 0x04,
  39. INTEL_USAGE_2D_SOURCE = 0x08,
  40. /* use on vertex */
  41. INTEL_USAGE_VERTEX = 0x10
  42. };
  43. enum intel_buffer_type
  44. {
  45. INTEL_NEW_TEXTURE,
  46. INTEL_NEW_SCANOUT, /**< a texture used for scanning out from */
  47. INTEL_NEW_VERTEX
  48. };
  49. enum intel_buffer_tile
  50. {
  51. INTEL_TILE_NONE,
  52. INTEL_TILE_X,
  53. INTEL_TILE_Y
  54. };
  55. struct intel_batchbuffer {
  56. struct intel_winsys *iws;
  57. /**
  58. * Values exported to speed up the writing the batchbuffer,
  59. * instead of having to go trough a accesor function for
  60. * each dword written.
  61. */
  62. /*{@*/
  63. uint8_t *map;
  64. uint8_t *ptr;
  65. size_t size;
  66. size_t relocs;
  67. size_t max_relocs;
  68. /*@}*/
  69. };
  70. struct intel_winsys {
  71. /**
  72. * Batchbuffer functions.
  73. */
  74. /*@{*/
  75. /**
  76. * Create a new batchbuffer.
  77. */
  78. struct intel_batchbuffer *(*batchbuffer_create)(struct intel_winsys *iws);
  79. /**
  80. * Emit a relocation to a buffer.
  81. * Target position in batchbuffer is the same as ptr.
  82. *
  83. * @batch
  84. * @reloc buffer address to be inserted into target.
  85. * @usage how is the hardware going to use the buffer.
  86. * @offset add this to the reloc buffers address
  87. * @target buffer where to write the address, null for batchbuffer.
  88. */
  89. int (*batchbuffer_reloc)(struct intel_batchbuffer *batch,
  90. struct intel_buffer *reloc,
  91. enum intel_buffer_usage usage,
  92. unsigned offset);
  93. /**
  94. * Flush a bufferbatch.
  95. */
  96. void (*batchbuffer_flush)(struct intel_batchbuffer *batch,
  97. struct pipe_fence_handle **fence);
  98. /**
  99. * Destroy a batchbuffer.
  100. */
  101. void (*batchbuffer_destroy)(struct intel_batchbuffer *batch);
  102. /*@}*/
  103. /**
  104. * Buffer functions.
  105. */
  106. /*@{*/
  107. /**
  108. * Create a buffer.
  109. */
  110. struct intel_buffer *(*buffer_create)(struct intel_winsys *iws,
  111. unsigned size, unsigned alignment,
  112. enum intel_buffer_type type);
  113. /**
  114. * Fence a buffer with a fence reg.
  115. * Not to be confused with pipe_fence_handle.
  116. */
  117. int (*buffer_set_fence_reg)(struct intel_winsys *iws,
  118. struct intel_buffer *buffer,
  119. unsigned stride,
  120. enum intel_buffer_tile tile);
  121. /**
  122. * Map a buffer.
  123. */
  124. void *(*buffer_map)(struct intel_winsys *iws,
  125. struct intel_buffer *buffer,
  126. boolean write);
  127. /**
  128. * Unmap a buffer.
  129. */
  130. void (*buffer_unmap)(struct intel_winsys *iws,
  131. struct intel_buffer *buffer);
  132. /**
  133. * Write to a buffer.
  134. *
  135. * Arguments follows pipe_buffer_write.
  136. */
  137. int (*buffer_write)(struct intel_winsys *iws,
  138. struct intel_buffer *dst,
  139. size_t offset,
  140. size_t size,
  141. const void *data);
  142. void (*buffer_destroy)(struct intel_winsys *iws,
  143. struct intel_buffer *buffer);
  144. /*@}*/
  145. /**
  146. * Fence functions.
  147. */
  148. /*@{*/
  149. /**
  150. * Reference fence and set ptr to fence.
  151. */
  152. void (*fence_reference)(struct intel_winsys *iws,
  153. struct pipe_fence_handle **ptr,
  154. struct pipe_fence_handle *fence);
  155. /**
  156. * Check if a fence has finished.
  157. */
  158. int (*fence_signalled)(struct intel_winsys *iws,
  159. struct pipe_fence_handle *fence);
  160. /**
  161. * Wait on a fence to finish.
  162. */
  163. int (*fence_finish)(struct intel_winsys *iws,
  164. struct pipe_fence_handle *fence);
  165. /*@}*/
  166. /**
  167. * Destroy the winsys.
  168. */
  169. void (*destroy)(struct intel_winsys *iws);
  170. };
  171. /**
  172. * Create i915 pipe_screen.
  173. */
  174. struct pipe_screen *i915_create_screen(struct intel_winsys *iws, unsigned pci_id);
  175. /**
  176. * Get the intel_winsys buffer backing the texture.
  177. *
  178. * TODO UGLY
  179. */
  180. boolean i915_get_texture_buffer_intel(struct pipe_texture *texture,
  181. struct intel_buffer **buffer,
  182. unsigned *stride);
  183. /**
  184. * Wrap a intel_winsys buffer with a texture blanket.
  185. *
  186. * TODO UGLY
  187. */
  188. struct pipe_texture * i915_texture_blanket_intel(struct pipe_screen *screen,
  189. struct pipe_texture *tmplt,
  190. unsigned pitch,
  191. struct intel_buffer *buffer);
  192. #endif