Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
0002 /**************************************************************************
0003  *
0004  * Copyright 2015 VMware, Inc., Palo Alto, CA., USA
0005  *
0006  * Permission is hereby granted, free of charge, to any person obtaining a
0007  * copy of this software and associated documentation files (the
0008  * "Software"), to deal in the Software without restriction, including
0009  * without limitation the rights to use, copy, modify, merge, publish,
0010  * distribute, sub license, and/or sell copies of the Software, and to
0011  * permit persons to whom the Software is furnished to do so, subject to
0012  * the following conditions:
0013  *
0014  * The above copyright notice and this permission notice (including the
0015  * next paragraph) shall be included in all copies or substantial portions
0016  * of the Software.
0017  *
0018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0019  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0020  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
0021  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
0022  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
0023  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
0024  * USE OR OTHER DEALINGS IN THE SOFTWARE.
0025  *
0026  **************************************************************************/
0027 #ifndef _VMWGFX_BINDING_H_
0028 #define _VMWGFX_BINDING_H_
0029 
0030 #include <linux/list.h>
0031 
0032 #include "device_include/svga3d_reg.h"
0033 
0034 #define VMW_MAX_VIEW_BINDINGS 128
0035 
0036 #define VMW_MAX_UAV_BIND_TYPE 2
0037 
0038 struct vmw_private;
0039 struct vmw_ctx_binding_state;
0040 
0041 /*
0042  * enum vmw_ctx_binding_type - abstract resource to context binding types
0043  */
0044 enum vmw_ctx_binding_type {
0045     vmw_ctx_binding_shader,
0046     vmw_ctx_binding_rt,
0047     vmw_ctx_binding_tex,
0048     vmw_ctx_binding_cb,
0049     vmw_ctx_binding_dx_shader,
0050     vmw_ctx_binding_dx_rt,
0051     vmw_ctx_binding_sr,
0052     vmw_ctx_binding_ds,
0053     vmw_ctx_binding_so_target,
0054     vmw_ctx_binding_vb,
0055     vmw_ctx_binding_ib,
0056     vmw_ctx_binding_uav,
0057     vmw_ctx_binding_cs_uav,
0058     vmw_ctx_binding_so,
0059     vmw_ctx_binding_max
0060 };
0061 
0062 /**
0063  * struct vmw_ctx_bindinfo - single binding metadata
0064  *
0065  * @ctx_list: List head for the context's list of bindings.
0066  * @res_list: List head for a resource's list of bindings.
0067  * @ctx: Non-refcounted pointer to the context that owns the binding. NULL
0068  * indicates no binding present.
0069  * @res: Non-refcounted pointer to the resource the binding points to. This
0070  * is typically a surface or a view.
0071  * @bt: Binding type.
0072  * @scrubbed: Whether the binding has been scrubbed from the context.
0073  */
0074 struct vmw_ctx_bindinfo {
0075     struct list_head ctx_list;
0076     struct list_head res_list;
0077     struct vmw_resource *ctx;
0078     struct vmw_resource *res;
0079     enum vmw_ctx_binding_type bt;
0080     bool scrubbed;
0081 };
0082 
0083 /**
0084  * struct vmw_ctx_bindinfo_tex - texture stage binding metadata
0085  *
0086  * @bi: struct vmw_ctx_bindinfo we derive from.
0087  * @texture_stage: Device data used to reconstruct binding command.
0088  */
0089 struct vmw_ctx_bindinfo_tex {
0090     struct vmw_ctx_bindinfo bi;
0091     uint32 texture_stage;
0092 };
0093 
0094 /**
0095  * struct vmw_ctx_bindinfo_shader - Shader binding metadata
0096  *
0097  * @bi: struct vmw_ctx_bindinfo we derive from.
0098  * @shader_slot: Device data used to reconstruct binding command.
0099  */
0100 struct vmw_ctx_bindinfo_shader {
0101     struct vmw_ctx_bindinfo bi;
0102     SVGA3dShaderType shader_slot;
0103 };
0104 
0105 /**
0106  * struct vmw_ctx_bindinfo_cb - Constant buffer binding metadata
0107  *
0108  * @bi: struct vmw_ctx_bindinfo we derive from.
0109  * @shader_slot: Device data used to reconstruct binding command.
0110  * @offset: Device data used to reconstruct binding command.
0111  * @size: Device data used to reconstruct binding command.
0112  * @slot: Device data used to reconstruct binding command.
0113  */
0114 struct vmw_ctx_bindinfo_cb {
0115     struct vmw_ctx_bindinfo bi;
0116     SVGA3dShaderType shader_slot;
0117     uint32 offset;
0118     uint32 size;
0119     uint32 slot;
0120 };
0121 
0122 /**
0123  * struct vmw_ctx_bindinfo_view - View binding metadata
0124  *
0125  * @bi: struct vmw_ctx_bindinfo we derive from.
0126  * @shader_slot: Device data used to reconstruct binding command.
0127  * @slot: Device data used to reconstruct binding command.
0128  */
0129 struct vmw_ctx_bindinfo_view {
0130     struct vmw_ctx_bindinfo bi;
0131     SVGA3dShaderType shader_slot;
0132     uint32 slot;
0133 };
0134 
0135 /**
0136  * struct vmw_ctx_bindinfo_so_target - StreamOutput binding metadata
0137  *
0138  * @bi: struct vmw_ctx_bindinfo we derive from.
0139  * @offset: Device data used to reconstruct binding command.
0140  * @size: Device data used to reconstruct binding command.
0141  * @slot: Device data used to reconstruct binding command.
0142  */
0143 struct vmw_ctx_bindinfo_so_target {
0144     struct vmw_ctx_bindinfo bi;
0145     uint32 offset;
0146     uint32 size;
0147     uint32 slot;
0148 };
0149 
0150 /**
0151  * struct vmw_ctx_bindinfo_vb - Vertex buffer binding metadata
0152  *
0153  * @bi: struct vmw_ctx_bindinfo we derive from.
0154  * @offset: Device data used to reconstruct binding command.
0155  * @stride: Device data used to reconstruct binding command.
0156  * @slot: Device data used to reconstruct binding command.
0157  */
0158 struct vmw_ctx_bindinfo_vb {
0159     struct vmw_ctx_bindinfo bi;
0160     uint32 offset;
0161     uint32 stride;
0162     uint32 slot;
0163 };
0164 
0165 /**
0166  * struct vmw_ctx_bindinfo_ib - StreamOutput binding metadata
0167  *
0168  * @bi: struct vmw_ctx_bindinfo we derive from.
0169  * @offset: Device data used to reconstruct binding command.
0170  * @format: Device data used to reconstruct binding command.
0171  */
0172 struct vmw_ctx_bindinfo_ib {
0173     struct vmw_ctx_bindinfo bi;
0174     uint32 offset;
0175     uint32 format;
0176 };
0177 
0178 /**
0179  * struct vmw_dx_shader_bindings - per shader type context binding state
0180  *
0181  * @shader: The shader binding for this shader type
0182  * @const_buffer: Const buffer bindings for this shader type.
0183  * @shader_res: Shader resource view bindings for this shader type.
0184  * @dirty_sr: Bitmap tracking individual shader resource bindings changes
0185  * that have not yet been emitted to the device.
0186  * @dirty: Bitmap tracking per-binding type binding changes that have not
0187  * yet been emitted to the device.
0188  */
0189 struct vmw_dx_shader_bindings {
0190     struct vmw_ctx_bindinfo_shader shader;
0191     struct vmw_ctx_bindinfo_cb const_buffers[SVGA3D_DX_MAX_CONSTBUFFERS];
0192     struct vmw_ctx_bindinfo_view shader_res[SVGA3D_DX_MAX_SRVIEWS];
0193     DECLARE_BITMAP(dirty_sr, SVGA3D_DX_MAX_SRVIEWS);
0194     unsigned long dirty;
0195 };
0196 
0197 /**
0198  * struct vmw_ctx_bindinfo_uav - UAV context binding state.
0199  * @views: UAV view bindings.
0200  * @splice_index: The device splice index set by user-space.
0201  */
0202 struct vmw_ctx_bindinfo_uav {
0203     struct vmw_ctx_bindinfo_view views[SVGA3D_DX11_1_MAX_UAVIEWS];
0204     uint32 index;
0205 };
0206 
0207 /**
0208  * struct vmw_ctx_bindinfo_so - Stream output binding metadata.
0209  * @bi: struct vmw_ctx_bindinfo we derive from.
0210  * @slot: Device data used to reconstruct binding command.
0211  */
0212 struct vmw_ctx_bindinfo_so {
0213     struct vmw_ctx_bindinfo bi;
0214     uint32 slot;
0215 };
0216 
0217 extern void vmw_binding_add(struct vmw_ctx_binding_state *cbs,
0218                 const struct vmw_ctx_bindinfo *ci,
0219                 u32 shader_slot, u32 slot);
0220 extern void vmw_binding_cb_offset_update(struct vmw_ctx_binding_state *cbs,
0221                      u32 shader_slot, u32 slot, u32 offsetInBytes);
0222 extern void vmw_binding_add_uav_index(struct vmw_ctx_binding_state *cbs,
0223                       uint32 slot, uint32 splice_index);
0224 extern void
0225 vmw_binding_state_commit(struct vmw_ctx_binding_state *to,
0226              struct vmw_ctx_binding_state *from);
0227 extern void vmw_binding_res_list_kill(struct list_head *head);
0228 extern void vmw_binding_res_list_scrub(struct list_head *head);
0229 extern int vmw_binding_rebind_all(struct vmw_ctx_binding_state *cbs);
0230 extern void vmw_binding_state_kill(struct vmw_ctx_binding_state *cbs);
0231 extern void vmw_binding_state_scrub(struct vmw_ctx_binding_state *cbs);
0232 extern struct vmw_ctx_binding_state *
0233 vmw_binding_state_alloc(struct vmw_private *dev_priv);
0234 extern void vmw_binding_state_free(struct vmw_ctx_binding_state *cbs);
0235 extern struct list_head *
0236 vmw_binding_state_list(struct vmw_ctx_binding_state *cbs);
0237 extern void vmw_binding_state_reset(struct vmw_ctx_binding_state *cbs);
0238 extern u32 vmw_binding_dirtying(enum vmw_ctx_binding_type binding_type);
0239 
0240 
0241 #endif