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