vmwgfx_binding.h revision 1.1
1/* $NetBSD: vmwgfx_binding.h,v 1.1 2018/08/27 01:34:59 riastradh Exp $ */ 2 3/************************************************************************** 4 * 5 * Copyright �� 2015 VMware, Inc., Palo Alto, CA., USA 6 * All Rights Reserved. 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the 10 * "Software"), to deal in the Software without restriction, including 11 * without limitation the rights to use, copy, modify, merge, publish, 12 * distribute, sub license, and/or sell copies of the Software, and to 13 * permit persons to whom the Software is furnished to do so, subject to 14 * the following conditions: 15 * 16 * The above copyright notice and this permission notice (including the 17 * next paragraph) shall be included in all copies or substantial portions 18 * of the Software. 19 * 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 23 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 24 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 25 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 * USE OR OTHER DEALINGS IN THE SOFTWARE. 27 * 28 **************************************************************************/ 29#ifndef _VMWGFX_BINDING_H_ 30#define _VMWGFX_BINDING_H_ 31 32#include "device_include/svga3d_reg.h" 33#include <linux/list.h> 34 35#define VMW_MAX_VIEW_BINDINGS 128 36 37struct vmw_private; 38struct vmw_ctx_binding_state; 39 40/* 41 * enum vmw_ctx_binding_type - abstract resource to context binding types 42 */ 43enum vmw_ctx_binding_type { 44 vmw_ctx_binding_shader, 45 vmw_ctx_binding_rt, 46 vmw_ctx_binding_tex, 47 vmw_ctx_binding_cb, 48 vmw_ctx_binding_dx_shader, 49 vmw_ctx_binding_dx_rt, 50 vmw_ctx_binding_sr, 51 vmw_ctx_binding_ds, 52 vmw_ctx_binding_so, 53 vmw_ctx_binding_vb, 54 vmw_ctx_binding_ib, 55 vmw_ctx_binding_max 56}; 57 58/** 59 * struct vmw_ctx_bindinfo - single binding metadata 60 * 61 * @ctx_list: List head for the context's list of bindings. 62 * @res_list: List head for a resource's list of bindings. 63 * @ctx: Non-refcounted pointer to the context that owns the binding. NULL 64 * indicates no binding present. 65 * @res: Non-refcounted pointer to the resource the binding points to. This 66 * is typically a surface or a view. 67 * @bt: Binding type. 68 * @scrubbed: Whether the binding has been scrubbed from the context. 69 */ 70struct vmw_ctx_bindinfo { 71 struct list_head ctx_list; 72 struct list_head res_list; 73 struct vmw_resource *ctx; 74 struct vmw_resource *res; 75 enum vmw_ctx_binding_type bt; 76 bool scrubbed; 77}; 78 79/** 80 * struct vmw_ctx_bindinfo_tex - texture stage binding metadata 81 * 82 * @bi: struct vmw_ctx_bindinfo we derive from. 83 * @texture_stage: Device data used to reconstruct binding command. 84 */ 85struct vmw_ctx_bindinfo_tex { 86 struct vmw_ctx_bindinfo bi; 87 uint32 texture_stage; 88}; 89 90/** 91 * struct vmw_ctx_bindinfo_shader - Shader binding metadata 92 * 93 * @bi: struct vmw_ctx_bindinfo we derive from. 94 * @shader_slot: Device data used to reconstruct binding command. 95 */ 96struct vmw_ctx_bindinfo_shader { 97 struct vmw_ctx_bindinfo bi; 98 SVGA3dShaderType shader_slot; 99}; 100 101/** 102 * struct vmw_ctx_bindinfo_cb - Constant buffer binding metadata 103 * 104 * @bi: struct vmw_ctx_bindinfo we derive from. 105 * @shader_slot: Device data used to reconstruct binding command. 106 * @offset: Device data used to reconstruct binding command. 107 * @size: Device data used to reconstruct binding command. 108 * @slot: Device data used to reconstruct binding command. 109 */ 110struct vmw_ctx_bindinfo_cb { 111 struct vmw_ctx_bindinfo bi; 112 SVGA3dShaderType shader_slot; 113 uint32 offset; 114 uint32 size; 115 uint32 slot; 116}; 117 118/** 119 * struct vmw_ctx_bindinfo_view - View binding metadata 120 * 121 * @bi: struct vmw_ctx_bindinfo we derive from. 122 * @shader_slot: Device data used to reconstruct binding command. 123 * @slot: Device data used to reconstruct binding command. 124 */ 125struct vmw_ctx_bindinfo_view { 126 struct vmw_ctx_bindinfo bi; 127 SVGA3dShaderType shader_slot; 128 uint32 slot; 129}; 130 131/** 132 * struct vmw_ctx_bindinfo_so - StreamOutput binding metadata 133 * 134 * @bi: struct vmw_ctx_bindinfo we derive from. 135 * @offset: Device data used to reconstruct binding command. 136 * @size: Device data used to reconstruct binding command. 137 * @slot: Device data used to reconstruct binding command. 138 */ 139struct vmw_ctx_bindinfo_so { 140 struct vmw_ctx_bindinfo bi; 141 uint32 offset; 142 uint32 size; 143 uint32 slot; 144}; 145 146/** 147 * struct vmw_ctx_bindinfo_vb - Vertex buffer binding metadata 148 * 149 * @bi: struct vmw_ctx_bindinfo we derive from. 150 * @offset: Device data used to reconstruct binding command. 151 * @stride: Device data used to reconstruct binding command. 152 * @slot: Device data used to reconstruct binding command. 153 */ 154struct vmw_ctx_bindinfo_vb { 155 struct vmw_ctx_bindinfo bi; 156 uint32 offset; 157 uint32 stride; 158 uint32 slot; 159}; 160 161/** 162 * struct vmw_ctx_bindinfo_ib - StreamOutput binding metadata 163 * 164 * @bi: struct vmw_ctx_bindinfo we derive from. 165 * @offset: Device data used to reconstruct binding command. 166 * @format: Device data used to reconstruct binding command. 167 */ 168struct vmw_ctx_bindinfo_ib { 169 struct vmw_ctx_bindinfo bi; 170 uint32 offset; 171 uint32 format; 172}; 173 174/** 175 * struct vmw_dx_shader_bindings - per shader type context binding state 176 * 177 * @shader: The shader binding for this shader type 178 * @const_buffer: Const buffer bindings for this shader type. 179 * @shader_res: Shader resource view bindings for this shader type. 180 * @dirty_sr: Bitmap tracking individual shader resource bindings changes 181 * that have not yet been emitted to the device. 182 * @dirty: Bitmap tracking per-binding type binding changes that have not 183 * yet been emitted to the device. 184 */ 185struct vmw_dx_shader_bindings { 186 struct vmw_ctx_bindinfo_shader shader; 187 struct vmw_ctx_bindinfo_cb const_buffers[SVGA3D_DX_MAX_CONSTBUFFERS]; 188 struct vmw_ctx_bindinfo_view shader_res[SVGA3D_DX_MAX_SRVIEWS]; 189 DECLARE_BITMAP(dirty_sr, SVGA3D_DX_MAX_SRVIEWS); 190 unsigned long dirty; 191}; 192 193extern void vmw_binding_add(struct vmw_ctx_binding_state *cbs, 194 const struct vmw_ctx_bindinfo *ci, 195 u32 shader_slot, u32 slot); 196extern void 197vmw_binding_state_commit(struct vmw_ctx_binding_state *to, 198 struct vmw_ctx_binding_state *from); 199extern void vmw_binding_res_list_kill(struct list_head *head); 200extern void vmw_binding_res_list_scrub(struct list_head *head); 201extern int vmw_binding_rebind_all(struct vmw_ctx_binding_state *cbs); 202extern void vmw_binding_state_kill(struct vmw_ctx_binding_state *cbs); 203extern void vmw_binding_state_scrub(struct vmw_ctx_binding_state *cbs); 204extern struct vmw_ctx_binding_state * 205vmw_binding_state_alloc(struct vmw_private *dev_priv); 206extern void vmw_binding_state_free(struct vmw_ctx_binding_state *cbs); 207extern struct list_head * 208vmw_binding_state_list(struct vmw_ctx_binding_state *cbs); 209extern void vmw_binding_state_reset(struct vmw_ctx_binding_state *cbs); 210 211#endif 212