vmwgfx_binding.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /**************************************************************************
  2. *
  3. * Copyright © 2015 VMware, Inc., Palo Alto, CA., USA
  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 OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  21. * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. #ifndef _VMWGFX_BINDING_H_
  28. #define _VMWGFX_BINDING_H_
  29. #include "device_include/svga3d_reg.h"
  30. #include <linux/list.h>
  31. #define VMW_MAX_VIEW_BINDINGS 128
  32. struct vmw_private;
  33. struct vmw_ctx_binding_state;
  34. /*
  35. * enum vmw_ctx_binding_type - abstract resource to context binding types
  36. */
  37. enum vmw_ctx_binding_type {
  38. vmw_ctx_binding_shader,
  39. vmw_ctx_binding_rt,
  40. vmw_ctx_binding_tex,
  41. vmw_ctx_binding_cb,
  42. vmw_ctx_binding_dx_shader,
  43. vmw_ctx_binding_dx_rt,
  44. vmw_ctx_binding_sr,
  45. vmw_ctx_binding_ds,
  46. vmw_ctx_binding_so,
  47. vmw_ctx_binding_vb,
  48. vmw_ctx_binding_ib,
  49. vmw_ctx_binding_max
  50. };
  51. /**
  52. * struct vmw_ctx_bindinfo - single binding metadata
  53. *
  54. * @ctx_list: List head for the context's list of bindings.
  55. * @res_list: List head for a resource's list of bindings.
  56. * @ctx: Non-refcounted pointer to the context that owns the binding. NULL
  57. * indicates no binding present.
  58. * @res: Non-refcounted pointer to the resource the binding points to. This
  59. * is typically a surface or a view.
  60. * @bt: Binding type.
  61. * @scrubbed: Whether the binding has been scrubbed from the context.
  62. */
  63. struct vmw_ctx_bindinfo {
  64. struct list_head ctx_list;
  65. struct list_head res_list;
  66. struct vmw_resource *ctx;
  67. struct vmw_resource *res;
  68. enum vmw_ctx_binding_type bt;
  69. bool scrubbed;
  70. };
  71. /**
  72. * struct vmw_ctx_bindinfo_tex - texture stage binding metadata
  73. *
  74. * @bi: struct vmw_ctx_bindinfo we derive from.
  75. * @texture_stage: Device data used to reconstruct binding command.
  76. */
  77. struct vmw_ctx_bindinfo_tex {
  78. struct vmw_ctx_bindinfo bi;
  79. uint32 texture_stage;
  80. };
  81. /**
  82. * struct vmw_ctx_bindinfo_shader - Shader binding metadata
  83. *
  84. * @bi: struct vmw_ctx_bindinfo we derive from.
  85. * @shader_slot: Device data used to reconstruct binding command.
  86. */
  87. struct vmw_ctx_bindinfo_shader {
  88. struct vmw_ctx_bindinfo bi;
  89. SVGA3dShaderType shader_slot;
  90. };
  91. /**
  92. * struct vmw_ctx_bindinfo_cb - Constant buffer binding metadata
  93. *
  94. * @bi: struct vmw_ctx_bindinfo we derive from.
  95. * @shader_slot: Device data used to reconstruct binding command.
  96. * @offset: Device data used to reconstruct binding command.
  97. * @size: Device data used to reconstruct binding command.
  98. * @slot: Device data used to reconstruct binding command.
  99. */
  100. struct vmw_ctx_bindinfo_cb {
  101. struct vmw_ctx_bindinfo bi;
  102. SVGA3dShaderType shader_slot;
  103. uint32 offset;
  104. uint32 size;
  105. uint32 slot;
  106. };
  107. /**
  108. * struct vmw_ctx_bindinfo_view - View binding metadata
  109. *
  110. * @bi: struct vmw_ctx_bindinfo we derive from.
  111. * @shader_slot: Device data used to reconstruct binding command.
  112. * @slot: Device data used to reconstruct binding command.
  113. */
  114. struct vmw_ctx_bindinfo_view {
  115. struct vmw_ctx_bindinfo bi;
  116. SVGA3dShaderType shader_slot;
  117. uint32 slot;
  118. };
  119. /**
  120. * struct vmw_ctx_bindinfo_so - StreamOutput binding metadata
  121. *
  122. * @bi: struct vmw_ctx_bindinfo we derive from.
  123. * @offset: Device data used to reconstruct binding command.
  124. * @size: Device data used to reconstruct binding command.
  125. * @slot: Device data used to reconstruct binding command.
  126. */
  127. struct vmw_ctx_bindinfo_so {
  128. struct vmw_ctx_bindinfo bi;
  129. uint32 offset;
  130. uint32 size;
  131. uint32 slot;
  132. };
  133. /**
  134. * struct vmw_ctx_bindinfo_vb - Vertex buffer binding metadata
  135. *
  136. * @bi: struct vmw_ctx_bindinfo we derive from.
  137. * @offset: Device data used to reconstruct binding command.
  138. * @stride: Device data used to reconstruct binding command.
  139. * @slot: Device data used to reconstruct binding command.
  140. */
  141. struct vmw_ctx_bindinfo_vb {
  142. struct vmw_ctx_bindinfo bi;
  143. uint32 offset;
  144. uint32 stride;
  145. uint32 slot;
  146. };
  147. /**
  148. * struct vmw_ctx_bindinfo_ib - StreamOutput binding metadata
  149. *
  150. * @bi: struct vmw_ctx_bindinfo we derive from.
  151. * @offset: Device data used to reconstruct binding command.
  152. * @format: Device data used to reconstruct binding command.
  153. */
  154. struct vmw_ctx_bindinfo_ib {
  155. struct vmw_ctx_bindinfo bi;
  156. uint32 offset;
  157. uint32 format;
  158. };
  159. /**
  160. * struct vmw_dx_shader_bindings - per shader type context binding state
  161. *
  162. * @shader: The shader binding for this shader type
  163. * @const_buffer: Const buffer bindings for this shader type.
  164. * @shader_res: Shader resource view bindings for this shader type.
  165. * @dirty_sr: Bitmap tracking individual shader resource bindings changes
  166. * that have not yet been emitted to the device.
  167. * @dirty: Bitmap tracking per-binding type binding changes that have not
  168. * yet been emitted to the device.
  169. */
  170. struct vmw_dx_shader_bindings {
  171. struct vmw_ctx_bindinfo_shader shader;
  172. struct vmw_ctx_bindinfo_cb const_buffers[SVGA3D_DX_MAX_CONSTBUFFERS];
  173. struct vmw_ctx_bindinfo_view shader_res[SVGA3D_DX_MAX_SRVIEWS];
  174. DECLARE_BITMAP(dirty_sr, SVGA3D_DX_MAX_SRVIEWS);
  175. unsigned long dirty;
  176. };
  177. extern void vmw_binding_add(struct vmw_ctx_binding_state *cbs,
  178. const struct vmw_ctx_bindinfo *ci,
  179. u32 shader_slot, u32 slot);
  180. extern void
  181. vmw_binding_state_commit(struct vmw_ctx_binding_state *to,
  182. struct vmw_ctx_binding_state *from);
  183. extern void vmw_binding_res_list_kill(struct list_head *head);
  184. extern void vmw_binding_res_list_scrub(struct list_head *head);
  185. extern int vmw_binding_rebind_all(struct vmw_ctx_binding_state *cbs);
  186. extern void vmw_binding_state_kill(struct vmw_ctx_binding_state *cbs);
  187. extern void vmw_binding_state_scrub(struct vmw_ctx_binding_state *cbs);
  188. extern struct vmw_ctx_binding_state *
  189. vmw_binding_state_alloc(struct vmw_private *dev_priv);
  190. extern void vmw_binding_state_free(struct vmw_ctx_binding_state *cbs);
  191. extern struct list_head *
  192. vmw_binding_state_list(struct vmw_ctx_binding_state *cbs);
  193. extern void vmw_binding_state_reset(struct vmw_ctx_binding_state *cbs);
  194. #endif