Home | History | Annotate | Line # | Download | only in vmwgfx
      1  1.1  riastrad /*	$NetBSD: vmwgfx_so.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.3  riastrad  * Copyright 2014-2015 VMware, Inc., Palo Alto, CA., USA
      6  1.1  riastrad  *
      7  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      8  1.1  riastrad  * copy of this software and associated documentation files (the
      9  1.1  riastrad  * "Software"), to deal in the Software without restriction, including
     10  1.1  riastrad  * without limitation the rights to use, copy, modify, merge, publish,
     11  1.1  riastrad  * distribute, sub license, and/or sell copies of the Software, and to
     12  1.1  riastrad  * permit persons to whom the Software is furnished to do so, subject to
     13  1.1  riastrad  * the following conditions:
     14  1.1  riastrad  *
     15  1.1  riastrad  * The above copyright notice and this permission notice (including the
     16  1.1  riastrad  * next paragraph) shall be included in all copies or substantial portions
     17  1.1  riastrad  * of the Software.
     18  1.1  riastrad  *
     19  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     20  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     21  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
     22  1.1  riastrad  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
     23  1.1  riastrad  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
     24  1.1  riastrad  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
     25  1.1  riastrad  * USE OR OTHER DEALINGS IN THE SOFTWARE.
     26  1.1  riastrad  *
     27  1.1  riastrad  **************************************************************************/
     28  1.1  riastrad #ifndef VMW_SO_H
     29  1.1  riastrad #define VMW_SO_H
     30  1.1  riastrad 
     31  1.1  riastrad enum vmw_view_type {
     32  1.1  riastrad 	vmw_view_sr,
     33  1.1  riastrad 	vmw_view_rt,
     34  1.1  riastrad 	vmw_view_ds,
     35  1.1  riastrad 	vmw_view_max,
     36  1.1  riastrad };
     37  1.1  riastrad 
     38  1.1  riastrad enum vmw_so_type {
     39  1.1  riastrad 	vmw_so_el,
     40  1.1  riastrad 	vmw_so_bs,
     41  1.1  riastrad 	vmw_so_ds,
     42  1.1  riastrad 	vmw_so_rs,
     43  1.1  riastrad 	vmw_so_ss,
     44  1.1  riastrad 	vmw_so_so,
     45  1.1  riastrad 	vmw_so_max,
     46  1.1  riastrad };
     47  1.1  riastrad 
     48  1.1  riastrad /**
     49  1.1  riastrad  * union vmw_view_destroy - view destruction command body
     50  1.1  riastrad  *
     51  1.1  riastrad  * @rtv: RenderTarget view destruction command body
     52  1.1  riastrad  * @srv: ShaderResource view destruction command body
     53  1.1  riastrad  * @dsv: DepthStencil view destruction command body
     54  1.1  riastrad  * @view_id: A single u32 view id.
     55  1.1  riastrad  *
     56  1.1  riastrad  * The assumption here is that all union members are really represented by a
     57  1.1  riastrad  * single u32 in the command stream. If that's not the case,
     58  1.1  riastrad  * the size of this union will not equal the size of an u32, and the
     59  1.1  riastrad  * assumption is invalid, and we detect that at compile time in the
     60  1.1  riastrad  * vmw_so_build_asserts() function.
     61  1.1  riastrad  */
     62  1.1  riastrad union vmw_view_destroy {
     63  1.1  riastrad 	struct SVGA3dCmdDXDestroyRenderTargetView rtv;
     64  1.1  riastrad 	struct SVGA3dCmdDXDestroyShaderResourceView srv;
     65  1.1  riastrad 	struct SVGA3dCmdDXDestroyDepthStencilView dsv;
     66  1.1  riastrad 	u32 view_id;
     67  1.1  riastrad };
     68  1.1  riastrad 
     69  1.1  riastrad /* Map enum vmw_view_type to view destroy command ids*/
     70  1.1  riastrad extern const u32 vmw_view_destroy_cmds[];
     71  1.1  riastrad 
     72  1.1  riastrad /* Map enum vmw_view_type to SVGACOTableType */
     73  1.1  riastrad extern const SVGACOTableType vmw_view_cotables[];
     74  1.1  riastrad 
     75  1.1  riastrad /* Map enum vmw_so_type to SVGACOTableType */
     76  1.1  riastrad extern const SVGACOTableType vmw_so_cotables[];
     77  1.1  riastrad 
     78  1.1  riastrad /*
     79  1.1  riastrad  * vmw_view_cmd_to_type - Return the view type for a create or destroy command
     80  1.1  riastrad  *
     81  1.1  riastrad  * @id: The SVGA3D command id.
     82  1.1  riastrad  *
     83  1.1  riastrad  * For a given view create or destroy command id, return the corresponding
     84  1.1  riastrad  * enum vmw_view_type. If the command is unknown, return vmw_view_max.
     85  1.1  riastrad  * The validity of the simplified calculation is verified in the
     86  1.1  riastrad  * vmw_so_build_asserts() function.
     87  1.1  riastrad  */
     88  1.1  riastrad static inline enum vmw_view_type vmw_view_cmd_to_type(u32 id)
     89  1.1  riastrad {
     90  1.1  riastrad 	u32 tmp = (id - SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW) / 2;
     91  1.1  riastrad 
     92  1.1  riastrad 	if (tmp > (u32)vmw_view_max)
     93  1.1  riastrad 		return vmw_view_max;
     94  1.1  riastrad 
     95  1.1  riastrad 	return (enum vmw_view_type) tmp;
     96  1.1  riastrad }
     97  1.1  riastrad 
     98  1.1  riastrad /*
     99  1.1  riastrad  * vmw_so_cmd_to_type - Return the state object type for a
    100  1.1  riastrad  * create or destroy command
    101  1.1  riastrad  *
    102  1.1  riastrad  * @id: The SVGA3D command id.
    103  1.1  riastrad  *
    104  1.1  riastrad  * For a given state object create or destroy command id,
    105  1.1  riastrad  * return the corresponding enum vmw_so_type. If the command is uknown,
    106  1.1  riastrad  * return vmw_so_max. We should perhaps optimize this function using
    107  1.1  riastrad  * a similar strategy as vmw_view_cmd_to_type().
    108  1.1  riastrad  */
    109  1.1  riastrad static inline enum vmw_so_type vmw_so_cmd_to_type(u32 id)
    110  1.1  riastrad {
    111  1.1  riastrad 	switch (id) {
    112  1.1  riastrad 	case SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT:
    113  1.1  riastrad 	case SVGA_3D_CMD_DX_DESTROY_ELEMENTLAYOUT:
    114  1.1  riastrad 		return vmw_so_el;
    115  1.1  riastrad 	case SVGA_3D_CMD_DX_DEFINE_BLEND_STATE:
    116  1.1  riastrad 	case SVGA_3D_CMD_DX_DESTROY_BLEND_STATE:
    117  1.1  riastrad 		return vmw_so_bs;
    118  1.1  riastrad 	case SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_STATE:
    119  1.1  riastrad 	case SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_STATE:
    120  1.1  riastrad 		return vmw_so_ds;
    121  1.1  riastrad 	case SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE:
    122  1.1  riastrad 	case SVGA_3D_CMD_DX_DESTROY_RASTERIZER_STATE:
    123  1.1  riastrad 		return vmw_so_rs;
    124  1.1  riastrad 	case SVGA_3D_CMD_DX_DEFINE_SAMPLER_STATE:
    125  1.1  riastrad 	case SVGA_3D_CMD_DX_DESTROY_SAMPLER_STATE:
    126  1.1  riastrad 		return vmw_so_ss;
    127  1.1  riastrad 	case SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT:
    128  1.1  riastrad 	case SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT:
    129  1.1  riastrad 		return vmw_so_so;
    130  1.1  riastrad 	default:
    131  1.1  riastrad 		break;
    132  1.1  riastrad 	}
    133  1.1  riastrad 	return vmw_so_max;
    134  1.1  riastrad }
    135  1.1  riastrad 
    136  1.1  riastrad /*
    137  1.1  riastrad  * View management - vmwgfx_so.c
    138  1.1  riastrad  */
    139  1.1  riastrad extern int vmw_view_add(struct vmw_cmdbuf_res_manager *man,
    140  1.1  riastrad 			struct vmw_resource *ctx,
    141  1.1  riastrad 			struct vmw_resource *srf,
    142  1.1  riastrad 			enum vmw_view_type view_type,
    143  1.1  riastrad 			u32 user_key,
    144  1.1  riastrad 			const void *cmd,
    145  1.1  riastrad 			size_t cmd_size,
    146  1.1  riastrad 			struct list_head *list);
    147  1.1  riastrad 
    148  1.1  riastrad extern int vmw_view_remove(struct vmw_cmdbuf_res_manager *man,
    149  1.1  riastrad 			   u32 user_key, enum vmw_view_type view_type,
    150  1.1  riastrad 			   struct list_head *list,
    151  1.1  riastrad 			   struct vmw_resource **res_p);
    152  1.1  riastrad 
    153  1.1  riastrad extern void vmw_view_surface_list_destroy(struct vmw_private *dev_priv,
    154  1.1  riastrad 					  struct list_head *view_list);
    155  1.1  riastrad extern void vmw_view_cotable_list_destroy(struct vmw_private *dev_priv,
    156  1.1  riastrad 					  struct list_head *list,
    157  1.1  riastrad 					  bool readback);
    158  1.1  riastrad extern struct vmw_resource *vmw_view_srf(struct vmw_resource *res);
    159  1.1  riastrad extern struct vmw_resource *vmw_view_lookup(struct vmw_cmdbuf_res_manager *man,
    160  1.1  riastrad 					    enum vmw_view_type view_type,
    161  1.1  riastrad 					    u32 user_key);
    162  1.3  riastrad extern u32 vmw_view_dirtying(struct vmw_resource *res);
    163  1.1  riastrad #endif
    164