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