Path: blob/21.2-virgl/src/gallium/winsys/svga/drm/vmw_surface.h
4573 views
/**********************************************************1* Copyright 2009-2015 VMware, Inc. All rights reserved.2*3* Permission is hereby granted, free of charge, to any person4* obtaining a copy of this software and associated documentation5* files (the "Software"), to deal in the Software without6* restriction, including without limitation the rights to use, copy,7* modify, merge, publish, distribute, sublicense, and/or sell copies8* of the Software, and to permit persons to whom the Software is9* furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be12* included in all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,15* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF16* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND17* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS18* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN19* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN20* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*23**********************************************************/2425/**26* @file27* Surfaces for VMware SVGA winsys.28*29* @author Jose Fonseca <[email protected]>30*/313233#ifndef VMW_SURFACE_H_34#define VMW_SURFACE_H_353637#include "pipe/p_compiler.h"38#include "util/u_atomic.h"39#include "util/u_inlines.h"40#include "os/os_thread.h"41#include "pipebuffer/pb_buffer.h"4243#define VMW_MAX_PRESENTS 344454647struct vmw_svga_winsys_surface48{49int32_t validated; /* atomic */50struct pipe_reference refcnt;5152struct vmw_winsys_screen *screen;53uint32_t sid;5455/* FIXME: make this thread safe */56unsigned next_present_no;57uint32_t present_fences[VMW_MAX_PRESENTS];5859mtx_t mutex;60struct svga_winsys_buffer *buf; /* Current backing guest buffer */61uint32_t mapcount; /* Number of mappers */62uint32_t map_mode; /* PIPE_MAP_[READ|WRITE] */63void *data; /* Pointer to data if mapcount != 0*/64boolean shared; /* Shared surface. Never discard */65uint32_t size; /* Size of backing buffer */66boolean rebind; /* Surface needs a rebind after next unmap */67};686970static inline struct svga_winsys_surface *71svga_winsys_surface(struct vmw_svga_winsys_surface *surf)72{73assert(!surf || surf->sid != SVGA3D_INVALID_ID);74return (struct svga_winsys_surface *)surf;75}767778static inline struct vmw_svga_winsys_surface *79vmw_svga_winsys_surface(struct svga_winsys_surface *surf)80{81return (struct vmw_svga_winsys_surface *)surf;82}838485void86vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,87struct vmw_svga_winsys_surface *src);88void *89vmw_svga_winsys_surface_map(struct svga_winsys_context *swc,90struct svga_winsys_surface *srf,91unsigned flags, boolean *retry,92boolean *rebind);93void94vmw_svga_winsys_surface_unmap(struct svga_winsys_context *swc,95struct svga_winsys_surface *srf,96boolean *rebind);9798void99vmw_svga_winsys_surface_init(struct svga_winsys_screen *sws,100struct svga_winsys_surface *surface,101unsigned surf_size, SVGA3dSurfaceAllFlags flags);102103#endif /* VMW_SURFACE_H_ */104105106