1 /**************************************************************************
3 * Copyright © 2015 VMware, Inc., Palo Alto, CA., USA
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
27 #ifndef _VMWGFX_BINDING_H_
28 #define _VMWGFX_BINDING_H_
30 #include "device_include/svga3d_reg.h"
31 #include <linux/list.h>
33 #define VMW_MAX_VIEW_BINDINGS 128
36 struct vmw_ctx_binding_state
;
39 * enum vmw_ctx_binding_type - abstract resource to context binding types
41 enum vmw_ctx_binding_type
{
42 vmw_ctx_binding_shader
,
46 vmw_ctx_binding_dx_shader
,
47 vmw_ctx_binding_dx_rt
,
57 * struct vmw_ctx_bindinfo - single binding metadata
59 * @ctx_list: List head for the context's list of bindings.
60 * @res_list: List head for a resource's list of bindings.
61 * @ctx: Non-refcounted pointer to the context that owns the binding. NULL
62 * indicates no binding present.
63 * @res: Non-refcounted pointer to the resource the binding points to. This
64 * is typically a surface or a view.
66 * @scrubbed: Whether the binding has been scrubbed from the context.
68 struct vmw_ctx_bindinfo
{
69 struct list_head ctx_list
;
70 struct list_head res_list
;
71 struct vmw_resource
*ctx
;
72 struct vmw_resource
*res
;
73 enum vmw_ctx_binding_type bt
;
78 * struct vmw_ctx_bindinfo_tex - texture stage binding metadata
80 * @bi: struct vmw_ctx_bindinfo we derive from.
81 * @texture_stage: Device data used to reconstruct binding command.
83 struct vmw_ctx_bindinfo_tex
{
84 struct vmw_ctx_bindinfo bi
;
89 * struct vmw_ctx_bindinfo_shader - Shader binding metadata
91 * @bi: struct vmw_ctx_bindinfo we derive from.
92 * @shader_slot: Device data used to reconstruct binding command.
94 struct vmw_ctx_bindinfo_shader
{
95 struct vmw_ctx_bindinfo bi
;
96 SVGA3dShaderType shader_slot
;
100 * struct vmw_ctx_bindinfo_cb - Constant buffer binding metadata
102 * @bi: struct vmw_ctx_bindinfo we derive from.
103 * @shader_slot: Device data used to reconstruct binding command.
104 * @offset: Device data used to reconstruct binding command.
105 * @size: Device data used to reconstruct binding command.
106 * @slot: Device data used to reconstruct binding command.
108 struct vmw_ctx_bindinfo_cb
{
109 struct vmw_ctx_bindinfo bi
;
110 SVGA3dShaderType shader_slot
;
117 * struct vmw_ctx_bindinfo_view - View binding metadata
119 * @bi: struct vmw_ctx_bindinfo we derive from.
120 * @shader_slot: Device data used to reconstruct binding command.
121 * @slot: Device data used to reconstruct binding command.
123 struct vmw_ctx_bindinfo_view
{
124 struct vmw_ctx_bindinfo bi
;
125 SVGA3dShaderType shader_slot
;
130 * struct vmw_ctx_bindinfo_so - StreamOutput binding metadata
132 * @bi: struct vmw_ctx_bindinfo we derive from.
133 * @offset: Device data used to reconstruct binding command.
134 * @size: Device data used to reconstruct binding command.
135 * @slot: Device data used to reconstruct binding command.
137 struct vmw_ctx_bindinfo_so
{
138 struct vmw_ctx_bindinfo bi
;
145 * struct vmw_ctx_bindinfo_vb - Vertex buffer binding metadata
147 * @bi: struct vmw_ctx_bindinfo we derive from.
148 * @offset: Device data used to reconstruct binding command.
149 * @stride: Device data used to reconstruct binding command.
150 * @slot: Device data used to reconstruct binding command.
152 struct vmw_ctx_bindinfo_vb
{
153 struct vmw_ctx_bindinfo bi
;
160 * struct vmw_ctx_bindinfo_ib - StreamOutput binding metadata
162 * @bi: struct vmw_ctx_bindinfo we derive from.
163 * @offset: Device data used to reconstruct binding command.
164 * @format: Device data used to reconstruct binding command.
166 struct vmw_ctx_bindinfo_ib
{
167 struct vmw_ctx_bindinfo bi
;
173 * struct vmw_dx_shader_bindings - per shader type context binding state
175 * @shader: The shader binding for this shader type
176 * @const_buffer: Const buffer bindings for this shader type.
177 * @shader_res: Shader resource view bindings for this shader type.
178 * @dirty_sr: Bitmap tracking individual shader resource bindings changes
179 * that have not yet been emitted to the device.
180 * @dirty: Bitmap tracking per-binding type binding changes that have not
181 * yet been emitted to the device.
183 struct vmw_dx_shader_bindings
{
184 struct vmw_ctx_bindinfo_shader shader
;
185 struct vmw_ctx_bindinfo_cb const_buffers
[SVGA3D_DX_MAX_CONSTBUFFERS
];
186 struct vmw_ctx_bindinfo_view shader_res
[SVGA3D_DX_MAX_SRVIEWS
];
187 DECLARE_BITMAP(dirty_sr
, SVGA3D_DX_MAX_SRVIEWS
);
191 extern void vmw_binding_add(struct vmw_ctx_binding_state
*cbs
,
192 const struct vmw_ctx_bindinfo
*ci
,
193 u32 shader_slot
, u32 slot
);
195 vmw_binding_state_commit(struct vmw_ctx_binding_state
*to
,
196 struct vmw_ctx_binding_state
*from
);
197 extern void vmw_binding_res_list_kill(struct list_head
*head
);
198 extern void vmw_binding_res_list_scrub(struct list_head
*head
);
199 extern int vmw_binding_rebind_all(struct vmw_ctx_binding_state
*cbs
);
200 extern void vmw_binding_state_kill(struct vmw_ctx_binding_state
*cbs
);
201 extern void vmw_binding_state_scrub(struct vmw_ctx_binding_state
*cbs
);
202 extern struct vmw_ctx_binding_state
*
203 vmw_binding_state_alloc(struct vmw_private
*dev_priv
);
204 extern void vmw_binding_state_free(struct vmw_ctx_binding_state
*cbs
);
205 extern struct list_head
*
206 vmw_binding_state_list(struct vmw_ctx_binding_state
*cbs
);
207 extern void vmw_binding_state_reset(struct vmw_ctx_binding_state
*cbs
);