Linux Audio

Check our new training course

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