vmwgfx_binding.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /**************************************************************************
  3. *
  4. * Copyright 2015 VMware, Inc., Palo Alto, CA., USA
  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 <linux/list.h>
  30. #include "device_include/svga3d_reg.h"
  31. #define VMW_MAX_VIEW_BINDINGS 128
  32. #define VMW_MAX_UAV_BIND_TYPE 2
  33. struct vmw_private;
  34. struct vmw_ctx_binding_state;
  35. /*
  36. * enum vmw_ctx_binding_type - abstract resource to context binding types
  37. */
  38. enum vmw_ctx_binding_type {
  39. vmw_ctx_binding_shader,
  40. vmw_ctx_binding_rt,
  41. vmw_ctx_binding_tex,
  42. vmw_ctx_binding_cb,
  43. vmw_ctx_binding_dx_shader,
  44. vmw_ctx_binding_dx_rt,
  45. vmw_ctx_binding_sr,
  46. vmw_ctx_binding_ds,
  47. vmw_ctx_binding_so_target,
  48. vmw_ctx_binding_vb,
  49. vmw_ctx_binding_ib,
  50. vmw_ctx_binding_uav,
  51. vmw_ctx_binding_cs_uav,
  52. vmw_ctx_binding_so,
  53. vmw_ctx_binding_max
  54. };
  55. /**
  56. * struct vmw_ctx_bindinfo - single binding metadata
  57. *
  58. * @ctx_list: List head for the context's list of bindings.
  59. * @res_list: List head for a resource's list of bindings.
  60. * @ctx: Non-refcounted pointer to the context that owns the binding. NULL
  61. * indicates no binding present.
  62. * @res: Non-refcounted pointer to the resource the binding points to. This
  63. * is typically a surface or a view.
  64. * @bt: Binding type.
  65. * @scrubbed: Whether the binding has been scrubbed from the context.
  66. */
  67. struct vmw_ctx_bindinfo {
  68. struct list_head ctx_list;
  69. struct list_head res_list;
  70. struct vmw_resource *ctx;
  71. struct vmw_resource *res;
  72. enum vmw_ctx_binding_type bt;
  73. bool scrubbed;
  74. };
  75. /**
  76. * struct vmw_ctx_bindinfo_tex - texture stage binding metadata
  77. *
  78. * @bi: struct vmw_ctx_bindinfo we derive from.
  79. * @texture_stage: Device data used to reconstruct binding command.
  80. */
  81. struct vmw_ctx_bindinfo_tex {
  82. struct vmw_ctx_bindinfo bi;
  83. uint32 texture_stage;
  84. };
  85. /**
  86. * struct vmw_ctx_bindinfo_shader - Shader binding metadata
  87. *
  88. * @bi: struct vmw_ctx_bindinfo we derive from.
  89. * @shader_slot: Device data used to reconstruct binding command.
  90. */
  91. struct vmw_ctx_bindinfo_shader {
  92. struct vmw_ctx_bindinfo bi;
  93. SVGA3dShaderType shader_slot;
  94. };
  95. /**
  96. * struct vmw_ctx_bindinfo_cb - Constant buffer binding metadata
  97. *
  98. * @bi: struct vmw_ctx_bindinfo we derive from.
  99. * @shader_slot: Device data used to reconstruct binding command.
  100. * @offset: Device data used to reconstruct binding command.
  101. * @size: Device data used to reconstruct binding command.
  102. * @slot: Device data used to reconstruct binding command.
  103. */
  104. struct vmw_ctx_bindinfo_cb {
  105. struct vmw_ctx_bindinfo bi;
  106. SVGA3dShaderType shader_slot;
  107. uint32 offset;
  108. uint32 size;
  109. uint32 slot;
  110. };
  111. /**
  112. * struct vmw_ctx_bindinfo_view - View binding metadata
  113. *
  114. * @bi: struct vmw_ctx_bindinfo we derive from.
  115. * @shader_slot: Device data used to reconstruct binding command.
  116. * @slot: Device data used to reconstruct binding command.
  117. */
  118. struct vmw_ctx_bindinfo_view {
  119. struct vmw_ctx_bindinfo bi;
  120. SVGA3dShaderType shader_slot;
  121. uint32 slot;
  122. };
  123. /**
  124. * struct vmw_ctx_bindinfo_so_target - StreamOutput binding metadata
  125. *
  126. * @bi: struct vmw_ctx_bindinfo we derive from.
  127. * @offset: Device data used to reconstruct binding command.
  128. * @size: Device data used to reconstruct binding command.
  129. * @slot: Device data used to reconstruct binding command.
  130. */
  131. struct vmw_ctx_bindinfo_so_target {
  132. struct vmw_ctx_bindinfo bi;
  133. uint32 offset;
  134. uint32 size;
  135. uint32 slot;
  136. };
  137. /**
  138. * struct vmw_ctx_bindinfo_vb - Vertex buffer binding metadata
  139. *
  140. * @bi: struct vmw_ctx_bindinfo we derive from.
  141. * @offset: Device data used to reconstruct binding command.
  142. * @stride: Device data used to reconstruct binding command.
  143. * @slot: Device data used to reconstruct binding command.
  144. */
  145. struct vmw_ctx_bindinfo_vb {
  146. struct vmw_ctx_bindinfo bi;
  147. uint32 offset;
  148. uint32 stride;
  149. uint32 slot;
  150. };
  151. /**
  152. * struct vmw_ctx_bindinfo_ib - StreamOutput binding metadata
  153. *
  154. * @bi: struct vmw_ctx_bindinfo we derive from.
  155. * @offset: Device data used to reconstruct binding command.
  156. * @format: Device data used to reconstruct binding command.
  157. */
  158. struct vmw_ctx_bindinfo_ib {
  159. struct vmw_ctx_bindinfo bi;
  160. uint32 offset;
  161. uint32 format;
  162. };
  163. /**
  164. * struct vmw_dx_shader_bindings - per shader type context binding state
  165. *
  166. * @shader: The shader binding for this shader type
  167. * @const_buffer: Const buffer bindings for this shader type.
  168. * @shader_res: Shader resource view bindings for this shader type.
  169. * @dirty_sr: Bitmap tracking individual shader resource bindings changes
  170. * that have not yet been emitted to the device.
  171. * @dirty: Bitmap tracking per-binding type binding changes that have not
  172. * yet been emitted to the device.
  173. */
  174. struct vmw_dx_shader_bindings {
  175. struct vmw_ctx_bindinfo_shader shader;
  176. struct vmw_ctx_bindinfo_cb const_buffers[SVGA3D_DX_MAX_CONSTBUFFERS];
  177. struct vmw_ctx_bindinfo_view shader_res[SVGA3D_DX_MAX_SRVIEWS];
  178. DECLARE_BITMAP(dirty_sr, SVGA3D_DX_MAX_SRVIEWS);
  179. unsigned long dirty;
  180. };
  181. /**
  182. * struct vmw_ctx_bindinfo_uav - UAV context binding state.
  183. * @views: UAV view bindings.
  184. * @splice_index: The device splice index set by user-space.
  185. */
  186. struct vmw_ctx_bindinfo_uav {
  187. struct vmw_ctx_bindinfo_view views[SVGA3D_MAX_UAVIEWS];
  188. uint32 index;
  189. };
  190. /**
  191. * struct vmw_ctx_bindinfo_so - Stream output binding metadata.
  192. * @bi: struct vmw_ctx_bindinfo we derive from.
  193. * @slot: Device data used to reconstruct binding command.
  194. */
  195. struct vmw_ctx_bindinfo_so {
  196. struct vmw_ctx_bindinfo bi;
  197. uint32 slot;
  198. };
  199. extern void vmw_binding_add(struct vmw_ctx_binding_state *cbs,
  200. const struct vmw_ctx_bindinfo *ci,
  201. u32 shader_slot, u32 slot);
  202. extern void vmw_binding_add_uav_index(struct vmw_ctx_binding_state *cbs,
  203. uint32 slot, uint32 splice_index);
  204. extern void
  205. vmw_binding_state_commit(struct vmw_ctx_binding_state *to,
  206. struct vmw_ctx_binding_state *from);
  207. extern void vmw_binding_res_list_kill(struct list_head *head);
  208. extern void vmw_binding_res_list_scrub(struct list_head *head);
  209. extern int vmw_binding_rebind_all(struct vmw_ctx_binding_state *cbs);
  210. extern void vmw_binding_state_kill(struct vmw_ctx_binding_state *cbs);
  211. extern void vmw_binding_state_scrub(struct vmw_ctx_binding_state *cbs);
  212. extern struct vmw_ctx_binding_state *
  213. vmw_binding_state_alloc(struct vmw_private *dev_priv);
  214. extern void vmw_binding_state_free(struct vmw_ctx_binding_state *cbs);
  215. extern struct list_head *
  216. vmw_binding_state_list(struct vmw_ctx_binding_state *cbs);
  217. extern void vmw_binding_state_reset(struct vmw_ctx_binding_state *cbs);
  218. extern u32 vmw_binding_dirtying(enum vmw_ctx_binding_type binding_type);
  219. #endif