1bf215546Sopenharmony_ci/********************************************************** 2bf215546Sopenharmony_ci * Copyright 2008-2009 VMware, Inc. All rights reserved. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person 5bf215546Sopenharmony_ci * obtaining a copy of this software and associated documentation 6bf215546Sopenharmony_ci * files (the "Software"), to deal in the Software without 7bf215546Sopenharmony_ci * restriction, including without limitation the rights to use, copy, 8bf215546Sopenharmony_ci * modify, merge, publish, distribute, sublicense, and/or sell copies 9bf215546Sopenharmony_ci * of the Software, and to permit persons to whom the Software is 10bf215546Sopenharmony_ci * furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be 13bf215546Sopenharmony_ci * included in all copies or substantial portions of the Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16bf215546Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18bf215546Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19bf215546Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20bf215546Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21bf215546Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22bf215546Sopenharmony_ci * SOFTWARE. 23bf215546Sopenharmony_ci * 24bf215546Sopenharmony_ci **********************************************************/ 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci/** 27bf215546Sopenharmony_ci * @file 28bf215546Sopenharmony_ci * VMware SVGA specific winsys interface. 29bf215546Sopenharmony_ci * 30bf215546Sopenharmony_ci * @author Jose Fonseca <jfonseca@vmware.com> 31bf215546Sopenharmony_ci * 32bf215546Sopenharmony_ci * Documentation taken from the VMware SVGA DDK. 33bf215546Sopenharmony_ci */ 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#ifndef SVGA_WINSYS_H_ 36bf215546Sopenharmony_ci#define SVGA_WINSYS_H_ 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci#include "svga_types.h" 39bf215546Sopenharmony_ci#include "svga3d_types.h" 40bf215546Sopenharmony_ci#include "svga_reg.h" 41bf215546Sopenharmony_ci#include "svga3d_reg.h" 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_ci#include "pipe/p_compiler.h" 44bf215546Sopenharmony_ci#include "pipe/p_defines.h" 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci#include "svga_mksstats.h" 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_cistruct svga_winsys_screen; 49bf215546Sopenharmony_cistruct svga_winsys_buffer; 50bf215546Sopenharmony_cistruct pipe_screen; 51bf215546Sopenharmony_cistruct pipe_context; 52bf215546Sopenharmony_cistruct util_debug_callback; 53bf215546Sopenharmony_cistruct pipe_fence_handle; 54bf215546Sopenharmony_cistruct pipe_resource; 55bf215546Sopenharmony_cistruct svga_region; 56bf215546Sopenharmony_cistruct winsys_handle; 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci#define SVGA_BUFFER_USAGE_PINNED (1 << 0) 60bf215546Sopenharmony_ci#define SVGA_BUFFER_USAGE_WRAPPED (1 << 1) 61bf215546Sopenharmony_ci#define SVGA_BUFFER_USAGE_SHADER (1 << 2) 62bf215546Sopenharmony_ci 63bf215546Sopenharmony_ci/** 64bf215546Sopenharmony_ci * Relocation flags to help with dirty tracking 65bf215546Sopenharmony_ci * SVGA_RELOC_WRITE - The command will cause a GPU write to this 66bf215546Sopenharmony_ci * resource. 67bf215546Sopenharmony_ci * SVGA_RELOC_READ - The command will cause a GPU read from this 68bf215546Sopenharmony_ci * resource. 69bf215546Sopenharmony_ci * SVGA_RELOC_INTERNAL The command will only transfer data internally 70bf215546Sopenharmony_ci * within the resource, and optionally clear 71bf215546Sopenharmony_ci * dirty bits 72bf215546Sopenharmony_ci * SVGA_RELOC_DMA - Only set for resource buffer DMA uploads for winsys 73bf215546Sopenharmony_ci * implementations that want to track the amount 74bf215546Sopenharmony_ci * of such data referenced in the command stream. 75bf215546Sopenharmony_ci */ 76bf215546Sopenharmony_ci#define SVGA_RELOC_WRITE (1 << 0) 77bf215546Sopenharmony_ci#define SVGA_RELOC_READ (1 << 1) 78bf215546Sopenharmony_ci#define SVGA_RELOC_INTERNAL (1 << 2) 79bf215546Sopenharmony_ci#define SVGA_RELOC_DMA (1 << 3) 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci#define SVGA_FENCE_FLAG_EXEC (1 << 0) 82bf215546Sopenharmony_ci#define SVGA_FENCE_FLAG_QUERY (1 << 1) 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ci#define SVGA_SURFACE_USAGE_SHARED (1 << 0) 85bf215546Sopenharmony_ci#define SVGA_SURFACE_USAGE_SCANOUT (1 << 1) 86bf215546Sopenharmony_ci#define SVGA_SURFACE_USAGE_COHERENT (1 << 2) 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci#define SVGA_QUERY_FLAG_SET (1 << 0) 89bf215546Sopenharmony_ci#define SVGA_QUERY_FLAG_REF (1 << 1) 90bf215546Sopenharmony_ci 91bf215546Sopenharmony_ci#define SVGA_HINT_FLAG_CAN_PRE_FLUSH (1 << 0) /* Can preemptively flush */ 92bf215546Sopenharmony_ci#define SVGA_HINT_FLAG_EXPORT_FENCE_FD (1 << 1) /* Export a Fence FD */ 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci/** 95bf215546Sopenharmony_ci * SVGA mks statistics info 96bf215546Sopenharmony_ci */ 97bf215546Sopenharmony_cistruct svga_winsys_stats_timeframe { 98bf215546Sopenharmony_ci void *counterTime; 99bf215546Sopenharmony_ci uint64 startTime; 100bf215546Sopenharmony_ci uint64 adjustedStartTime; 101bf215546Sopenharmony_ci struct svga_winsys_stats_timeframe *enclosing; 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci struct svga_winsys_screen *sws; 104bf215546Sopenharmony_ci int32 slot; 105bf215546Sopenharmony_ci}; 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_cienum svga_stats_count { 108bf215546Sopenharmony_ci SVGA_STATS_COUNT_BLENDSTATE, 109bf215546Sopenharmony_ci SVGA_STATS_COUNT_BLITBLITTERCOPY, 110bf215546Sopenharmony_ci SVGA_STATS_COUNT_DEPTHSTENCILSTATE, 111bf215546Sopenharmony_ci SVGA_STATS_COUNT_RASTERIZERSTATE, 112bf215546Sopenharmony_ci SVGA_STATS_COUNT_RAWBUFFERSRVIEW, 113bf215546Sopenharmony_ci SVGA_STATS_COUNT_SAMPLER, 114bf215546Sopenharmony_ci SVGA_STATS_COUNT_SAMPLERVIEW, 115bf215546Sopenharmony_ci SVGA_STATS_COUNT_SURFACEWRITEFLUSH, 116bf215546Sopenharmony_ci SVGA_STATS_COUNT_TEXREADBACK, 117bf215546Sopenharmony_ci SVGA_STATS_COUNT_VERTEXELEMENT, 118bf215546Sopenharmony_ci SVGA_STATS_COUNT_MAX 119bf215546Sopenharmony_ci}; 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_cienum svga_stats_time { 122bf215546Sopenharmony_ci SVGA_STATS_TIME_BLIT, 123bf215546Sopenharmony_ci SVGA_STATS_TIME_BLITBLITTER, 124bf215546Sopenharmony_ci SVGA_STATS_TIME_BLITFALLBACK, 125bf215546Sopenharmony_ci SVGA_STATS_TIME_BUFFERSFLUSH, 126bf215546Sopenharmony_ci SVGA_STATS_TIME_BUFFERTRANSFERMAP, 127bf215546Sopenharmony_ci SVGA_STATS_TIME_BUFFERTRANSFERUNMAP, 128bf215546Sopenharmony_ci SVGA_STATS_TIME_CONTEXTFINISH, 129bf215546Sopenharmony_ci SVGA_STATS_TIME_CONTEXTFLUSH, 130bf215546Sopenharmony_ci SVGA_STATS_TIME_COPYREGION, 131bf215546Sopenharmony_ci SVGA_STATS_TIME_COPYREGIONFALLBACK, 132bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATEBACKEDSURFACEVIEW, 133bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATEBUFFER, 134bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATECONTEXT, 135bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATECS, 136bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATEFS, 137bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATEGS, 138bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATESURFACE, 139bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATESURFACEVIEW, 140bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATETCS, 141bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATETES, 142bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATETEXTURE, 143bf215546Sopenharmony_ci SVGA_STATS_TIME_CREATEVS, 144bf215546Sopenharmony_ci SVGA_STATS_TIME_DEFINESHADER, 145bf215546Sopenharmony_ci SVGA_STATS_TIME_DESTROYSURFACE, 146bf215546Sopenharmony_ci SVGA_STATS_TIME_DRAWVBO, 147bf215546Sopenharmony_ci SVGA_STATS_TIME_DRAWARRAYS, 148bf215546Sopenharmony_ci SVGA_STATS_TIME_DRAWELEMENTS, 149bf215546Sopenharmony_ci SVGA_STATS_TIME_EMITCS, 150bf215546Sopenharmony_ci SVGA_STATS_TIME_EMITFS, 151bf215546Sopenharmony_ci SVGA_STATS_TIME_EMITGS, 152bf215546Sopenharmony_ci SVGA_STATS_TIME_EMITRAWBUFFER, 153bf215546Sopenharmony_ci SVGA_STATS_TIME_EMITTCS, 154bf215546Sopenharmony_ci SVGA_STATS_TIME_EMITTES, 155bf215546Sopenharmony_ci SVGA_STATS_TIME_EMITVS, 156bf215546Sopenharmony_ci SVGA_STATS_TIME_EMULATESURFACEVIEW, 157bf215546Sopenharmony_ci SVGA_STATS_TIME_FENCEFINISH, 158bf215546Sopenharmony_ci SVGA_STATS_TIME_GENERATEINDICES, 159bf215546Sopenharmony_ci SVGA_STATS_TIME_HWTNLDRAWARRAYS, 160bf215546Sopenharmony_ci SVGA_STATS_TIME_HWTNLDRAWELEMENTS, 161bf215546Sopenharmony_ci SVGA_STATS_TIME_HWTNLFLUSH, 162bf215546Sopenharmony_ci SVGA_STATS_TIME_HWTNLPRIM, 163bf215546Sopenharmony_ci SVGA_STATS_TIME_LAUNCHGRID, 164bf215546Sopenharmony_ci SVGA_STATS_TIME_PROPAGATESURFACE, 165bf215546Sopenharmony_ci SVGA_STATS_TIME_SETSAMPLERVIEWS, 166bf215546Sopenharmony_ci SVGA_STATS_TIME_SURFACEFLUSH, 167bf215546Sopenharmony_ci SVGA_STATS_TIME_SWTNLDRAWVBO, 168bf215546Sopenharmony_ci SVGA_STATS_TIME_SWTNLUPDATEDRAW, 169bf215546Sopenharmony_ci SVGA_STATS_TIME_SWTNLUPDATEVDECL, 170bf215546Sopenharmony_ci SVGA_STATS_TIME_TEXTRANSFERMAP, 171bf215546Sopenharmony_ci SVGA_STATS_TIME_TEXTRANSFERUNMAP, 172bf215546Sopenharmony_ci SVGA_STATS_TIME_TGSIVGPU10TRANSLATE, 173bf215546Sopenharmony_ci SVGA_STATS_TIME_TGSIVGPU9TRANSLATE, 174bf215546Sopenharmony_ci SVGA_STATS_TIME_UPDATECSUAV, 175bf215546Sopenharmony_ci SVGA_STATS_TIME_UPDATESTATE, 176bf215546Sopenharmony_ci SVGA_STATS_TIME_UPDATEUAV, 177bf215546Sopenharmony_ci SVGA_STATS_TIME_VALIDATESURFACEVIEW, 178bf215546Sopenharmony_ci SVGA_STATS_TIME_VBUFDRAWARRAYS, 179bf215546Sopenharmony_ci SVGA_STATS_TIME_VBUFDRAWELEMENTS, 180bf215546Sopenharmony_ci SVGA_STATS_TIME_VBUFRENDERALLOCVERT, 181bf215546Sopenharmony_ci SVGA_STATS_TIME_VBUFRENDERMAPVERT, 182bf215546Sopenharmony_ci SVGA_STATS_TIME_VBUFRENDERUNMAPVERT, 183bf215546Sopenharmony_ci SVGA_STATS_TIME_VBUFSUBMITSTATE, 184bf215546Sopenharmony_ci SVGA_STATS_TIME_MAX 185bf215546Sopenharmony_ci}; 186bf215546Sopenharmony_ci 187bf215546Sopenharmony_ci#define SVGA_STATS_PREFIX "GuestGL_" 188bf215546Sopenharmony_ci 189bf215546Sopenharmony_ci#define SVGA_STATS_COUNT_NAMES \ 190bf215546Sopenharmony_ci SVGA_STATS_PREFIX "BlendState", \ 191bf215546Sopenharmony_ci SVGA_STATS_PREFIX "BlitBlitterCopy", \ 192bf215546Sopenharmony_ci SVGA_STATS_PREFIX "DepthStencilState", \ 193bf215546Sopenharmony_ci SVGA_STATS_PREFIX "RasterizerState", \ 194bf215546Sopenharmony_ci SVGA_STATS_PREFIX "RawBufferSRView", \ 195bf215546Sopenharmony_ci SVGA_STATS_PREFIX "Sampler", \ 196bf215546Sopenharmony_ci SVGA_STATS_PREFIX "SamplerView", \ 197bf215546Sopenharmony_ci SVGA_STATS_PREFIX "SurfaceWriteFlush", \ 198bf215546Sopenharmony_ci SVGA_STATS_PREFIX "TextureReadback", \ 199bf215546Sopenharmony_ci SVGA_STATS_PREFIX "VertexElement" \ 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_ci#define SVGA_STATS_TIME_NAMES \ 202bf215546Sopenharmony_ci SVGA_STATS_PREFIX "Blit", \ 203bf215546Sopenharmony_ci SVGA_STATS_PREFIX "BlitBlitter", \ 204bf215546Sopenharmony_ci SVGA_STATS_PREFIX "BlitFallback", \ 205bf215546Sopenharmony_ci SVGA_STATS_PREFIX "BuffersFlush", \ 206bf215546Sopenharmony_ci SVGA_STATS_PREFIX "BufferTransferMap", \ 207bf215546Sopenharmony_ci SVGA_STATS_PREFIX "BufferTransferUnmap", \ 208bf215546Sopenharmony_ci SVGA_STATS_PREFIX "ContextFinish", \ 209bf215546Sopenharmony_ci SVGA_STATS_PREFIX "ContextFlush", \ 210bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CopyRegion", \ 211bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CopyRegionFallback", \ 212bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateBackedSurfaceView", \ 213bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateBuffer", \ 214bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateContext", \ 215bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateCS", \ 216bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateFS", \ 217bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateGS", \ 218bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateSurface", \ 219bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateSurfaceView", \ 220bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateTCS", \ 221bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateTES", \ 222bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateTexture", \ 223bf215546Sopenharmony_ci SVGA_STATS_PREFIX "CreateVS", \ 224bf215546Sopenharmony_ci SVGA_STATS_PREFIX "DefineShader", \ 225bf215546Sopenharmony_ci SVGA_STATS_PREFIX "DestroySurface", \ 226bf215546Sopenharmony_ci SVGA_STATS_PREFIX "DrawVBO", \ 227bf215546Sopenharmony_ci SVGA_STATS_PREFIX "DrawArrays", \ 228bf215546Sopenharmony_ci SVGA_STATS_PREFIX "DrawElements", \ 229bf215546Sopenharmony_ci SVGA_STATS_PREFIX "EmitCS", \ 230bf215546Sopenharmony_ci SVGA_STATS_PREFIX "EmitFS", \ 231bf215546Sopenharmony_ci SVGA_STATS_PREFIX "EmitGS", \ 232bf215546Sopenharmony_ci SVGA_STATS_PREFIX "EmitRawBuffer", \ 233bf215546Sopenharmony_ci SVGA_STATS_PREFIX "EmitTCS", \ 234bf215546Sopenharmony_ci SVGA_STATS_PREFIX "EmitTES", \ 235bf215546Sopenharmony_ci SVGA_STATS_PREFIX "EmitVS", \ 236bf215546Sopenharmony_ci SVGA_STATS_PREFIX "EmulateSurfaceView", \ 237bf215546Sopenharmony_ci SVGA_STATS_PREFIX "FenceFinish", \ 238bf215546Sopenharmony_ci SVGA_STATS_PREFIX "GenerateIndices", \ 239bf215546Sopenharmony_ci SVGA_STATS_PREFIX "HWtnlDrawArrays", \ 240bf215546Sopenharmony_ci SVGA_STATS_PREFIX "HWtnlDrawElements", \ 241bf215546Sopenharmony_ci SVGA_STATS_PREFIX "HWtnlFlush", \ 242bf215546Sopenharmony_ci SVGA_STATS_PREFIX "HWtnlPrim", \ 243bf215546Sopenharmony_ci SVGA_STATS_PREFIX "LaunchGrid", \ 244bf215546Sopenharmony_ci SVGA_STATS_PREFIX "PropagateSurface", \ 245bf215546Sopenharmony_ci SVGA_STATS_PREFIX "SetSamplerViews", \ 246bf215546Sopenharmony_ci SVGA_STATS_PREFIX "SurfaceFlush", \ 247bf215546Sopenharmony_ci SVGA_STATS_PREFIX "SwtnlDrawVBO", \ 248bf215546Sopenharmony_ci SVGA_STATS_PREFIX "SwtnlUpdateDraw", \ 249bf215546Sopenharmony_ci SVGA_STATS_PREFIX "SwtnlUpdateVDecl", \ 250bf215546Sopenharmony_ci SVGA_STATS_PREFIX "TextureTransferMap", \ 251bf215546Sopenharmony_ci SVGA_STATS_PREFIX "TextureTransferUnmap", \ 252bf215546Sopenharmony_ci SVGA_STATS_PREFIX "TGSIVGPU10Translate", \ 253bf215546Sopenharmony_ci SVGA_STATS_PREFIX "TGSIVGPU9Translate", \ 254bf215546Sopenharmony_ci SVGA_STATS_PREFIX "UpdateCSUAV", \ 255bf215546Sopenharmony_ci SVGA_STATS_PREFIX "UpdateState", \ 256bf215546Sopenharmony_ci SVGA_STATS_PREFIX "UpdateUAV", \ 257bf215546Sopenharmony_ci SVGA_STATS_PREFIX "ValidateSurfaceView", \ 258bf215546Sopenharmony_ci SVGA_STATS_PREFIX "VbufDrawArrays", \ 259bf215546Sopenharmony_ci SVGA_STATS_PREFIX "VbufDrawElements", \ 260bf215546Sopenharmony_ci SVGA_STATS_PREFIX "VbufRenderAllocVertices", \ 261bf215546Sopenharmony_ci SVGA_STATS_PREFIX "VbufRenderMapVertices", \ 262bf215546Sopenharmony_ci SVGA_STATS_PREFIX "VbufRenderUnmapVertices", \ 263bf215546Sopenharmony_ci SVGA_STATS_PREFIX "VbufSubmitState" 264bf215546Sopenharmony_ci 265bf215546Sopenharmony_ci 266bf215546Sopenharmony_ci/** Opaque surface handle */ 267bf215546Sopenharmony_cistruct svga_winsys_surface; 268bf215546Sopenharmony_ci 269bf215546Sopenharmony_ci/** Opaque guest-backed objects */ 270bf215546Sopenharmony_cistruct svga_winsys_gb_shader; 271bf215546Sopenharmony_cistruct svga_winsys_gb_query; 272bf215546Sopenharmony_ci 273bf215546Sopenharmony_ci 274bf215546Sopenharmony_ci/** 275bf215546Sopenharmony_ci * SVGA per-context winsys interface. 276bf215546Sopenharmony_ci */ 277bf215546Sopenharmony_cistruct svga_winsys_context 278bf215546Sopenharmony_ci{ 279bf215546Sopenharmony_ci void 280bf215546Sopenharmony_ci (*destroy)(struct svga_winsys_context *swc); 281bf215546Sopenharmony_ci 282bf215546Sopenharmony_ci void * 283bf215546Sopenharmony_ci (*reserve)(struct svga_winsys_context *swc, 284bf215546Sopenharmony_ci uint32_t nr_bytes, uint32_t nr_relocs ); 285bf215546Sopenharmony_ci 286bf215546Sopenharmony_ci /** 287bf215546Sopenharmony_ci * Returns current size of command buffer, in bytes. 288bf215546Sopenharmony_ci */ 289bf215546Sopenharmony_ci unsigned 290bf215546Sopenharmony_ci (*get_command_buffer_size)(struct svga_winsys_context *swc); 291bf215546Sopenharmony_ci 292bf215546Sopenharmony_ci /** 293bf215546Sopenharmony_ci * Emit a relocation for a host surface. 294bf215546Sopenharmony_ci * 295bf215546Sopenharmony_ci * @param flags bitmask of SVGA_RELOC_* flags 296bf215546Sopenharmony_ci * 297bf215546Sopenharmony_ci * NOTE: Order of this call does matter. It should be the same order 298bf215546Sopenharmony_ci * as relocations appear in the command buffer. 299bf215546Sopenharmony_ci */ 300bf215546Sopenharmony_ci void 301bf215546Sopenharmony_ci (*surface_relocation)(struct svga_winsys_context *swc, 302bf215546Sopenharmony_ci uint32 *sid, 303bf215546Sopenharmony_ci uint32 *mobid, 304bf215546Sopenharmony_ci struct svga_winsys_surface *surface, 305bf215546Sopenharmony_ci unsigned flags); 306bf215546Sopenharmony_ci 307bf215546Sopenharmony_ci /** 308bf215546Sopenharmony_ci * Emit a relocation for a guest memory region. 309bf215546Sopenharmony_ci * 310bf215546Sopenharmony_ci * @param flags bitmask of SVGA_RELOC_* flags 311bf215546Sopenharmony_ci * 312bf215546Sopenharmony_ci * NOTE: Order of this call does matter. It should be the same order 313bf215546Sopenharmony_ci * as relocations appear in the command buffer. 314bf215546Sopenharmony_ci */ 315bf215546Sopenharmony_ci void 316bf215546Sopenharmony_ci (*region_relocation)(struct svga_winsys_context *swc, 317bf215546Sopenharmony_ci struct SVGAGuestPtr *ptr, 318bf215546Sopenharmony_ci struct svga_winsys_buffer *buffer, 319bf215546Sopenharmony_ci uint32 offset, 320bf215546Sopenharmony_ci unsigned flags); 321bf215546Sopenharmony_ci 322bf215546Sopenharmony_ci /** 323bf215546Sopenharmony_ci * Emit a relocation for a guest-backed shader object. 324bf215546Sopenharmony_ci * 325bf215546Sopenharmony_ci * NOTE: Order of this call does matter. It should be the same order 326bf215546Sopenharmony_ci * as relocations appear in the command buffer. 327bf215546Sopenharmony_ci */ 328bf215546Sopenharmony_ci void 329bf215546Sopenharmony_ci (*shader_relocation)(struct svga_winsys_context *swc, 330bf215546Sopenharmony_ci uint32 *shid, 331bf215546Sopenharmony_ci uint32 *mobid, 332bf215546Sopenharmony_ci uint32 *offset, 333bf215546Sopenharmony_ci struct svga_winsys_gb_shader *shader, 334bf215546Sopenharmony_ci unsigned flags); 335bf215546Sopenharmony_ci 336bf215546Sopenharmony_ci /** 337bf215546Sopenharmony_ci * Emit a relocation for a guest-backed context. 338bf215546Sopenharmony_ci * 339bf215546Sopenharmony_ci * NOTE: Order of this call does matter. It should be the same order 340bf215546Sopenharmony_ci * as relocations appear in the command buffer. 341bf215546Sopenharmony_ci */ 342bf215546Sopenharmony_ci void 343bf215546Sopenharmony_ci (*context_relocation)(struct svga_winsys_context *swc, uint32 *cid); 344bf215546Sopenharmony_ci 345bf215546Sopenharmony_ci /** 346bf215546Sopenharmony_ci * Emit a relocation for a guest Memory OBject. 347bf215546Sopenharmony_ci * 348bf215546Sopenharmony_ci * @param flags bitmask of SVGA_RELOC_* flags 349bf215546Sopenharmony_ci * @param offset_into_mob Buffer starts at this offset into the MOB. 350bf215546Sopenharmony_ci * 351bf215546Sopenharmony_ci * Note that not all commands accept an offset into the MOB and 352bf215546Sopenharmony_ci * those commands can't use suballocated buffer pools. To trap 353bf215546Sopenharmony_ci * errors from improper buffer pool usage, set the offset_into_mob 354bf215546Sopenharmony_ci * pointer to NULL. 355bf215546Sopenharmony_ci */ 356bf215546Sopenharmony_ci void 357bf215546Sopenharmony_ci (*mob_relocation)(struct svga_winsys_context *swc, 358bf215546Sopenharmony_ci SVGAMobId *id, 359bf215546Sopenharmony_ci uint32 *offset_into_mob, 360bf215546Sopenharmony_ci struct svga_winsys_buffer *buffer, 361bf215546Sopenharmony_ci uint32 offset, 362bf215546Sopenharmony_ci unsigned flags); 363bf215546Sopenharmony_ci 364bf215546Sopenharmony_ci /** 365bf215546Sopenharmony_ci * Emit a relocation for a guest-backed query object. 366bf215546Sopenharmony_ci * 367bf215546Sopenharmony_ci * NOTE: Order of this call does matter. It should be the same order 368bf215546Sopenharmony_ci * as relocations appear in the command buffer. 369bf215546Sopenharmony_ci */ 370bf215546Sopenharmony_ci void 371bf215546Sopenharmony_ci (*query_relocation)(struct svga_winsys_context *swc, 372bf215546Sopenharmony_ci SVGAMobId *id, 373bf215546Sopenharmony_ci struct svga_winsys_gb_query *query); 374bf215546Sopenharmony_ci 375bf215546Sopenharmony_ci /** 376bf215546Sopenharmony_ci * Bind queries to context. 377bf215546Sopenharmony_ci * \param flags exactly one of SVGA_QUERY_FLAG_SET/REF 378bf215546Sopenharmony_ci */ 379bf215546Sopenharmony_ci enum pipe_error 380bf215546Sopenharmony_ci (*query_bind)(struct svga_winsys_context *sws, 381bf215546Sopenharmony_ci struct svga_winsys_gb_query *query, 382bf215546Sopenharmony_ci unsigned flags); 383bf215546Sopenharmony_ci 384bf215546Sopenharmony_ci void 385bf215546Sopenharmony_ci (*commit)(struct svga_winsys_context *swc); 386bf215546Sopenharmony_ci 387bf215546Sopenharmony_ci enum pipe_error 388bf215546Sopenharmony_ci (*flush)(struct svga_winsys_context *swc, 389bf215546Sopenharmony_ci struct pipe_fence_handle **pfence); 390bf215546Sopenharmony_ci 391bf215546Sopenharmony_ci /** 392bf215546Sopenharmony_ci * Context ID used to fill in the commands 393bf215546Sopenharmony_ci * 394bf215546Sopenharmony_ci * Context IDs are arbitrary small non-negative integers, 395bf215546Sopenharmony_ci * global to the entire SVGA device. 396bf215546Sopenharmony_ci */ 397bf215546Sopenharmony_ci uint32 cid; 398bf215546Sopenharmony_ci 399bf215546Sopenharmony_ci /** 400bf215546Sopenharmony_ci * Flags to hint the current context state 401bf215546Sopenharmony_ci */ 402bf215546Sopenharmony_ci uint32 hints; 403bf215546Sopenharmony_ci 404bf215546Sopenharmony_ci /** 405bf215546Sopenharmony_ci * File descriptor for imported fence 406bf215546Sopenharmony_ci */ 407bf215546Sopenharmony_ci int32 imported_fence_fd; 408bf215546Sopenharmony_ci 409bf215546Sopenharmony_ci /** 410bf215546Sopenharmony_ci ** BEGIN new functions for guest-backed surfaces. 411bf215546Sopenharmony_ci **/ 412bf215546Sopenharmony_ci 413bf215546Sopenharmony_ci boolean have_gb_objects; 414bf215546Sopenharmony_ci boolean force_coherent; 415bf215546Sopenharmony_ci 416bf215546Sopenharmony_ci /** 417bf215546Sopenharmony_ci * Map a guest-backed surface. 418bf215546Sopenharmony_ci * \param swc The winsys context 419bf215546Sopenharmony_ci * \param surface The surface to map 420bf215546Sopenharmony_ci * \param flags bitmask of PIPE_MAP_x flags 421bf215546Sopenharmony_ci * \param retry Whether to flush and retry the map 422bf215546Sopenharmony_ci * \param rebind Whether to issue an immediate rebind and flush. 423bf215546Sopenharmony_ci * 424bf215546Sopenharmony_ci * The surface_map() member is allowed to fail due to a 425bf215546Sopenharmony_ci * shortage of command buffer space, if the 426bf215546Sopenharmony_ci * PIPE_MAP_DISCARD_WHOLE_RESOURCE bit is set in flags. 427bf215546Sopenharmony_ci * In that case, the caller must flush the current command 428bf215546Sopenharmony_ci * buffer and reissue the map. 429bf215546Sopenharmony_ci */ 430bf215546Sopenharmony_ci void * 431bf215546Sopenharmony_ci (*surface_map)(struct svga_winsys_context *swc, 432bf215546Sopenharmony_ci struct svga_winsys_surface *surface, 433bf215546Sopenharmony_ci unsigned flags, boolean *retry, 434bf215546Sopenharmony_ci boolean *rebind); 435bf215546Sopenharmony_ci 436bf215546Sopenharmony_ci /** 437bf215546Sopenharmony_ci * Unmap a guest-backed surface. 438bf215546Sopenharmony_ci * \param rebind returns a flag indicating whether the caller should 439bf215546Sopenharmony_ci * issue a SVGA3D_BindGBSurface() call. 440bf215546Sopenharmony_ci */ 441bf215546Sopenharmony_ci void 442bf215546Sopenharmony_ci (*surface_unmap)(struct svga_winsys_context *swc, 443bf215546Sopenharmony_ci struct svga_winsys_surface *surface, 444bf215546Sopenharmony_ci boolean *rebind); 445bf215546Sopenharmony_ci 446bf215546Sopenharmony_ci /** 447bf215546Sopenharmony_ci * Create and define a DX GB shader that resides in the device COTable. 448bf215546Sopenharmony_ci * Caller of this function will issue the DXDefineShader command. 449bf215546Sopenharmony_ci */ 450bf215546Sopenharmony_ci struct svga_winsys_gb_shader * 451bf215546Sopenharmony_ci (*shader_create)(struct svga_winsys_context *swc, 452bf215546Sopenharmony_ci uint32 shaderId, 453bf215546Sopenharmony_ci SVGA3dShaderType shaderType, 454bf215546Sopenharmony_ci const uint32 *bytecode, 455bf215546Sopenharmony_ci uint32 bytecodeLen, 456bf215546Sopenharmony_ci const SVGA3dDXShaderSignatureHeader *sgnInfo, 457bf215546Sopenharmony_ci uint32 sgnLen); 458bf215546Sopenharmony_ci 459bf215546Sopenharmony_ci /** 460bf215546Sopenharmony_ci * Destroy a DX GB shader. 461bf215546Sopenharmony_ci * This function will issue the DXDestroyShader command. 462bf215546Sopenharmony_ci */ 463bf215546Sopenharmony_ci void 464bf215546Sopenharmony_ci (*shader_destroy)(struct svga_winsys_context *swc, 465bf215546Sopenharmony_ci struct svga_winsys_gb_shader *shader); 466bf215546Sopenharmony_ci 467bf215546Sopenharmony_ci /** 468bf215546Sopenharmony_ci * Rebind a DX GB resource to a context. 469bf215546Sopenharmony_ci * This is called to reference a DX GB resource in the command stream in 470bf215546Sopenharmony_ci * order to page in the associated resource in case the memory has been 471bf215546Sopenharmony_ci * paged out, and to fence it if necessary after command submission. 472bf215546Sopenharmony_ci */ 473bf215546Sopenharmony_ci enum pipe_error 474bf215546Sopenharmony_ci (*resource_rebind)(struct svga_winsys_context *swc, 475bf215546Sopenharmony_ci struct svga_winsys_surface *surface, 476bf215546Sopenharmony_ci struct svga_winsys_gb_shader *shader, 477bf215546Sopenharmony_ci unsigned flags); 478bf215546Sopenharmony_ci 479bf215546Sopenharmony_ci /** To report perf/conformance/etc issues to the gallium frontend */ 480bf215546Sopenharmony_ci struct util_debug_callback *debug_callback; 481bf215546Sopenharmony_ci 482bf215546Sopenharmony_ci /** The more recent command issued to command buffer */ 483bf215546Sopenharmony_ci SVGAFifo3dCmdId last_command; 484bf215546Sopenharmony_ci 485bf215546Sopenharmony_ci /** For HUD queries */ 486bf215546Sopenharmony_ci uint64_t num_commands; 487bf215546Sopenharmony_ci uint64_t num_command_buffers; 488bf215546Sopenharmony_ci uint64_t num_draw_commands; 489bf215546Sopenharmony_ci uint64_t num_shader_reloc; 490bf215546Sopenharmony_ci uint64_t num_surf_reloc; 491bf215546Sopenharmony_ci 492bf215546Sopenharmony_ci /* Whether we are in retry processing */ 493bf215546Sopenharmony_ci unsigned int in_retry; 494bf215546Sopenharmony_ci}; 495bf215546Sopenharmony_ci 496bf215546Sopenharmony_ci 497bf215546Sopenharmony_ci/** 498bf215546Sopenharmony_ci * SVGA per-screen winsys interface. 499bf215546Sopenharmony_ci */ 500bf215546Sopenharmony_cistruct svga_winsys_screen 501bf215546Sopenharmony_ci{ 502bf215546Sopenharmony_ci void 503bf215546Sopenharmony_ci (*destroy)(struct svga_winsys_screen *sws); 504bf215546Sopenharmony_ci 505bf215546Sopenharmony_ci SVGA3dHardwareVersion 506bf215546Sopenharmony_ci (*get_hw_version)(struct svga_winsys_screen *sws); 507bf215546Sopenharmony_ci 508bf215546Sopenharmony_ci boolean 509bf215546Sopenharmony_ci (*get_cap)(struct svga_winsys_screen *sws, 510bf215546Sopenharmony_ci SVGA3dDevCapIndex index, 511bf215546Sopenharmony_ci SVGA3dDevCapResult *result); 512bf215546Sopenharmony_ci 513bf215546Sopenharmony_ci /** 514bf215546Sopenharmony_ci * Create a new context. 515bf215546Sopenharmony_ci * 516bf215546Sopenharmony_ci * Context objects encapsulate all render state, and shader 517bf215546Sopenharmony_ci * objects are per-context. 518bf215546Sopenharmony_ci * 519bf215546Sopenharmony_ci * Surfaces are not per-context. The same surface can be shared 520bf215546Sopenharmony_ci * between multiple contexts, and surface operations can occur 521bf215546Sopenharmony_ci * without a context. 522bf215546Sopenharmony_ci */ 523bf215546Sopenharmony_ci struct svga_winsys_context * 524bf215546Sopenharmony_ci (*context_create)(struct svga_winsys_screen *sws); 525bf215546Sopenharmony_ci 526bf215546Sopenharmony_ci /** 527bf215546Sopenharmony_ci * This creates a "surface" object in the SVGA3D device. 528bf215546Sopenharmony_ci * 529bf215546Sopenharmony_ci * \param sws Pointer to an svga_winsys_context 530bf215546Sopenharmony_ci * \param flags Device surface create flags 531bf215546Sopenharmony_ci * \param format Format Device surface format 532bf215546Sopenharmony_ci * \param usage Winsys usage: bitmask of SVGA_SURFACE_USAGE_x flags 533bf215546Sopenharmony_ci * \param size Surface size given in device format 534bf215546Sopenharmony_ci * \param numLayers Number of layers of the surface (or cube faces) 535bf215546Sopenharmony_ci * \param numMipLevels Number of mipmap levels for each face 536bf215546Sopenharmony_ci * 537bf215546Sopenharmony_ci * Returns the surface ID (sid). Surfaces are generic 538bf215546Sopenharmony_ci * containers for host VRAM objects like textures, vertex 539bf215546Sopenharmony_ci * buffers, and depth/stencil buffers. 540bf215546Sopenharmony_ci * 541bf215546Sopenharmony_ci * Surfaces are hierarchial: 542bf215546Sopenharmony_ci * 543bf215546Sopenharmony_ci * - Surface may have multiple faces (for cube maps) 544bf215546Sopenharmony_ci * 545bf215546Sopenharmony_ci * - Each face has a list of mipmap levels 546bf215546Sopenharmony_ci * 547bf215546Sopenharmony_ci * - Each mipmap image may have multiple volume 548bf215546Sopenharmony_ci * slices for 3D image, or multiple 2D slices for texture array. 549bf215546Sopenharmony_ci * 550bf215546Sopenharmony_ci * - Each slice is a 2D array of 'blocks' 551bf215546Sopenharmony_ci * 552bf215546Sopenharmony_ci * - Each block may be one or more pixels. 553bf215546Sopenharmony_ci * (Usually 1, more for DXT or YUV formats.) 554bf215546Sopenharmony_ci * 555bf215546Sopenharmony_ci * Surfaces are generic host VRAM objects. The SVGA3D device 556bf215546Sopenharmony_ci * may optimize surfaces according to the format they were 557bf215546Sopenharmony_ci * created with, but this format does not limit the ways in 558bf215546Sopenharmony_ci * which the surface may be used. For example, a depth surface 559bf215546Sopenharmony_ci * can be used as a texture, or a floating point image may 560bf215546Sopenharmony_ci * be used as a vertex buffer. Some surface usages may be 561bf215546Sopenharmony_ci * lower performance, due to software emulation, but any 562bf215546Sopenharmony_ci * usage should work with any surface. 563bf215546Sopenharmony_ci */ 564bf215546Sopenharmony_ci struct svga_winsys_surface * 565bf215546Sopenharmony_ci (*surface_create)(struct svga_winsys_screen *sws, 566bf215546Sopenharmony_ci SVGA3dSurfaceAllFlags flags, 567bf215546Sopenharmony_ci SVGA3dSurfaceFormat format, 568bf215546Sopenharmony_ci unsigned usage, 569bf215546Sopenharmony_ci SVGA3dSize size, 570bf215546Sopenharmony_ci uint32 numLayers, 571bf215546Sopenharmony_ci uint32 numMipLevels, 572bf215546Sopenharmony_ci unsigned sampleCount); 573bf215546Sopenharmony_ci 574bf215546Sopenharmony_ci /** 575bf215546Sopenharmony_ci * Creates a surface from a winsys handle. 576bf215546Sopenharmony_ci * Used to implement pipe_screen::resource_from_handle. 577bf215546Sopenharmony_ci */ 578bf215546Sopenharmony_ci struct svga_winsys_surface * 579bf215546Sopenharmony_ci (*surface_from_handle)(struct svga_winsys_screen *sws, 580bf215546Sopenharmony_ci struct winsys_handle *whandle, 581bf215546Sopenharmony_ci SVGA3dSurfaceFormat *format); 582bf215546Sopenharmony_ci 583bf215546Sopenharmony_ci /** 584bf215546Sopenharmony_ci * Get a winsys_handle from a surface. 585bf215546Sopenharmony_ci * Used to implement pipe_screen::resource_get_handle. 586bf215546Sopenharmony_ci */ 587bf215546Sopenharmony_ci boolean 588bf215546Sopenharmony_ci (*surface_get_handle)(struct svga_winsys_screen *sws, 589bf215546Sopenharmony_ci struct svga_winsys_surface *surface, 590bf215546Sopenharmony_ci unsigned stride, 591bf215546Sopenharmony_ci struct winsys_handle *whandle); 592bf215546Sopenharmony_ci 593bf215546Sopenharmony_ci /** 594bf215546Sopenharmony_ci * Whether this surface is sitting in a validate list 595bf215546Sopenharmony_ci */ 596bf215546Sopenharmony_ci boolean 597bf215546Sopenharmony_ci (*surface_is_flushed)(struct svga_winsys_screen *sws, 598bf215546Sopenharmony_ci struct svga_winsys_surface *surface); 599bf215546Sopenharmony_ci 600bf215546Sopenharmony_ci /** 601bf215546Sopenharmony_ci * Reference a SVGA3D surface object. This allows sharing of a 602bf215546Sopenharmony_ci * surface between different objects. 603bf215546Sopenharmony_ci */ 604bf215546Sopenharmony_ci void 605bf215546Sopenharmony_ci (*surface_reference)(struct svga_winsys_screen *sws, 606bf215546Sopenharmony_ci struct svga_winsys_surface **pdst, 607bf215546Sopenharmony_ci struct svga_winsys_surface *src); 608bf215546Sopenharmony_ci 609bf215546Sopenharmony_ci /** 610bf215546Sopenharmony_ci * Check if a resource (texture, buffer) of the given size 611bf215546Sopenharmony_ci * and format can be created. 612bf215546Sopenharmony_ci * \Return TRUE if OK, FALSE if too large. 613bf215546Sopenharmony_ci */ 614bf215546Sopenharmony_ci boolean 615bf215546Sopenharmony_ci (*surface_can_create)(struct svga_winsys_screen *sws, 616bf215546Sopenharmony_ci SVGA3dSurfaceFormat format, 617bf215546Sopenharmony_ci SVGA3dSize size, 618bf215546Sopenharmony_ci uint32 numLayers, 619bf215546Sopenharmony_ci uint32 numMipLevels, 620bf215546Sopenharmony_ci uint32 numSamples); 621bf215546Sopenharmony_ci 622bf215546Sopenharmony_ci void 623bf215546Sopenharmony_ci (*surface_init)(struct svga_winsys_screen *sws, 624bf215546Sopenharmony_ci struct svga_winsys_surface *surface, 625bf215546Sopenharmony_ci unsigned surf_size, SVGA3dSurfaceAllFlags flags); 626bf215546Sopenharmony_ci 627bf215546Sopenharmony_ci /** 628bf215546Sopenharmony_ci * Buffer management. Buffer attributes are mostly fixed over its lifetime. 629bf215546Sopenharmony_ci * 630bf215546Sopenharmony_ci * @param usage bitmask of SVGA_BUFFER_USAGE_* flags. 631bf215546Sopenharmony_ci * 632bf215546Sopenharmony_ci * alignment indicates the client's alignment requirements, eg for 633bf215546Sopenharmony_ci * SSE instructions. 634bf215546Sopenharmony_ci */ 635bf215546Sopenharmony_ci struct svga_winsys_buffer * 636bf215546Sopenharmony_ci (*buffer_create)( struct svga_winsys_screen *sws, 637bf215546Sopenharmony_ci unsigned alignment, 638bf215546Sopenharmony_ci unsigned usage, 639bf215546Sopenharmony_ci unsigned size ); 640bf215546Sopenharmony_ci 641bf215546Sopenharmony_ci /** 642bf215546Sopenharmony_ci * Map the entire data store of a buffer object into the client's address. 643bf215546Sopenharmony_ci * usage is a bitmask of PIPE_MAP_* 644bf215546Sopenharmony_ci */ 645bf215546Sopenharmony_ci void * 646bf215546Sopenharmony_ci (*buffer_map)( struct svga_winsys_screen *sws, 647bf215546Sopenharmony_ci struct svga_winsys_buffer *buf, 648bf215546Sopenharmony_ci unsigned usage ); 649bf215546Sopenharmony_ci 650bf215546Sopenharmony_ci void 651bf215546Sopenharmony_ci (*buffer_unmap)( struct svga_winsys_screen *sws, 652bf215546Sopenharmony_ci struct svga_winsys_buffer *buf ); 653bf215546Sopenharmony_ci 654bf215546Sopenharmony_ci void 655bf215546Sopenharmony_ci (*buffer_destroy)( struct svga_winsys_screen *sws, 656bf215546Sopenharmony_ci struct svga_winsys_buffer *buf ); 657bf215546Sopenharmony_ci 658bf215546Sopenharmony_ci 659bf215546Sopenharmony_ci /** 660bf215546Sopenharmony_ci * Reference a fence object. 661bf215546Sopenharmony_ci */ 662bf215546Sopenharmony_ci void 663bf215546Sopenharmony_ci (*fence_reference)( struct svga_winsys_screen *sws, 664bf215546Sopenharmony_ci struct pipe_fence_handle **pdst, 665bf215546Sopenharmony_ci struct pipe_fence_handle *src ); 666bf215546Sopenharmony_ci 667bf215546Sopenharmony_ci /** 668bf215546Sopenharmony_ci * Checks whether the fence has been signalled. 669bf215546Sopenharmony_ci * \param flags driver-specific meaning 670bf215546Sopenharmony_ci * \return zero on success. 671bf215546Sopenharmony_ci */ 672bf215546Sopenharmony_ci int (*fence_signalled)( struct svga_winsys_screen *sws, 673bf215546Sopenharmony_ci struct pipe_fence_handle *fence, 674bf215546Sopenharmony_ci unsigned flag ); 675bf215546Sopenharmony_ci 676bf215546Sopenharmony_ci /** 677bf215546Sopenharmony_ci * Wait for the fence to finish. 678bf215546Sopenharmony_ci * \param timeout in nanoseconds (may be PIPE_TIMEOUT_INFINITE). 679bf215546Sopenharmony_ci * 0 to return immediately, if the API suports it. 680bf215546Sopenharmony_ci * \param flags driver-specific meaning 681bf215546Sopenharmony_ci * \return zero on success. 682bf215546Sopenharmony_ci */ 683bf215546Sopenharmony_ci int (*fence_finish)( struct svga_winsys_screen *sws, 684bf215546Sopenharmony_ci struct pipe_fence_handle *fence, 685bf215546Sopenharmony_ci uint64_t timeout, 686bf215546Sopenharmony_ci unsigned flag ); 687bf215546Sopenharmony_ci 688bf215546Sopenharmony_ci /** 689bf215546Sopenharmony_ci * Get the file descriptor associated with the fence 690bf215546Sopenharmony_ci * \param duplicate duplicate the fd before returning it 691bf215546Sopenharmony_ci * \return zero on success. 692bf215546Sopenharmony_ci */ 693bf215546Sopenharmony_ci int (*fence_get_fd)( struct svga_winsys_screen *sws, 694bf215546Sopenharmony_ci struct pipe_fence_handle *fence, 695bf215546Sopenharmony_ci boolean duplicate ); 696bf215546Sopenharmony_ci 697bf215546Sopenharmony_ci /** 698bf215546Sopenharmony_ci * Create a fence using the given file descriptor 699bf215546Sopenharmony_ci * \return zero on success. 700bf215546Sopenharmony_ci */ 701bf215546Sopenharmony_ci void (*fence_create_fd)( struct svga_winsys_screen *sws, 702bf215546Sopenharmony_ci struct pipe_fence_handle **fence, 703bf215546Sopenharmony_ci int32_t fd ); 704bf215546Sopenharmony_ci 705bf215546Sopenharmony_ci /** 706bf215546Sopenharmony_ci * Accumulates fence FD from other devices into the current context 707bf215546Sopenharmony_ci * \param context_fd FD the context will be waiting on 708bf215546Sopenharmony_ci * \return zero on success 709bf215546Sopenharmony_ci */ 710bf215546Sopenharmony_ci int (*fence_server_sync)( struct svga_winsys_screen *sws, 711bf215546Sopenharmony_ci int32_t *context_fd, 712bf215546Sopenharmony_ci struct pipe_fence_handle *fence ); 713bf215546Sopenharmony_ci 714bf215546Sopenharmony_ci /** 715bf215546Sopenharmony_ci ** BEGIN new functions for guest-backed surfaces. 716bf215546Sopenharmony_ci **/ 717bf215546Sopenharmony_ci 718bf215546Sopenharmony_ci /** Are guest-backed objects enabled? */ 719bf215546Sopenharmony_ci bool have_gb_objects; 720bf215546Sopenharmony_ci 721bf215546Sopenharmony_ci /** Can we do DMA with guest-backed objects enabled? */ 722bf215546Sopenharmony_ci bool have_gb_dma; 723bf215546Sopenharmony_ci 724bf215546Sopenharmony_ci /** Do we support coherent surface memory? */ 725bf215546Sopenharmony_ci bool have_coherent; 726bf215546Sopenharmony_ci /** 727bf215546Sopenharmony_ci * Create and define a GB shader. 728bf215546Sopenharmony_ci */ 729bf215546Sopenharmony_ci struct svga_winsys_gb_shader * 730bf215546Sopenharmony_ci (*shader_create)(struct svga_winsys_screen *sws, 731bf215546Sopenharmony_ci SVGA3dShaderType shaderType, 732bf215546Sopenharmony_ci const uint32 *bytecode, 733bf215546Sopenharmony_ci uint32 bytecodeLen); 734bf215546Sopenharmony_ci 735bf215546Sopenharmony_ci /** 736bf215546Sopenharmony_ci * Destroy a GB shader. It's safe to call this function even 737bf215546Sopenharmony_ci * if the shader is referenced in a context's command stream. 738bf215546Sopenharmony_ci */ 739bf215546Sopenharmony_ci void 740bf215546Sopenharmony_ci (*shader_destroy)(struct svga_winsys_screen *sws, 741bf215546Sopenharmony_ci struct svga_winsys_gb_shader *shader); 742bf215546Sopenharmony_ci 743bf215546Sopenharmony_ci /** 744bf215546Sopenharmony_ci * Create and define a GB query. 745bf215546Sopenharmony_ci */ 746bf215546Sopenharmony_ci struct svga_winsys_gb_query * 747bf215546Sopenharmony_ci (*query_create)(struct svga_winsys_screen *sws, uint32 len); 748bf215546Sopenharmony_ci 749bf215546Sopenharmony_ci /** 750bf215546Sopenharmony_ci * Destroy a GB query. 751bf215546Sopenharmony_ci */ 752bf215546Sopenharmony_ci void 753bf215546Sopenharmony_ci (*query_destroy)(struct svga_winsys_screen *sws, 754bf215546Sopenharmony_ci struct svga_winsys_gb_query *query); 755bf215546Sopenharmony_ci 756bf215546Sopenharmony_ci /** 757bf215546Sopenharmony_ci * Initialize the query state of the query that resides in the slot 758bf215546Sopenharmony_ci * specified in offset 759bf215546Sopenharmony_ci * \return zero on success. 760bf215546Sopenharmony_ci */ 761bf215546Sopenharmony_ci int 762bf215546Sopenharmony_ci (*query_init)(struct svga_winsys_screen *sws, 763bf215546Sopenharmony_ci struct svga_winsys_gb_query *query, 764bf215546Sopenharmony_ci unsigned offset, 765bf215546Sopenharmony_ci SVGA3dQueryState queryState); 766bf215546Sopenharmony_ci 767bf215546Sopenharmony_ci /** 768bf215546Sopenharmony_ci * Inquire for the query state and result of the query that resides 769bf215546Sopenharmony_ci * in the slot specified in offset 770bf215546Sopenharmony_ci */ 771bf215546Sopenharmony_ci void 772bf215546Sopenharmony_ci (*query_get_result)(struct svga_winsys_screen *sws, 773bf215546Sopenharmony_ci struct svga_winsys_gb_query *query, 774bf215546Sopenharmony_ci unsigned offset, 775bf215546Sopenharmony_ci SVGA3dQueryState *queryState, 776bf215546Sopenharmony_ci void *result, uint32 resultLen); 777bf215546Sopenharmony_ci 778bf215546Sopenharmony_ci /** 779bf215546Sopenharmony_ci * Increment a statistic counter 780bf215546Sopenharmony_ci */ 781bf215546Sopenharmony_ci void 782bf215546Sopenharmony_ci (*stats_inc)(struct svga_winsys_screen *, enum svga_stats_count); 783bf215546Sopenharmony_ci 784bf215546Sopenharmony_ci /** 785bf215546Sopenharmony_ci * Push a time frame onto the stack 786bf215546Sopenharmony_ci */ 787bf215546Sopenharmony_ci void 788bf215546Sopenharmony_ci (*stats_time_push)(struct svga_winsys_screen *, enum svga_stats_time, struct svga_winsys_stats_timeframe *); 789bf215546Sopenharmony_ci 790bf215546Sopenharmony_ci /** 791bf215546Sopenharmony_ci * Pop a time frame. 792bf215546Sopenharmony_ci */ 793bf215546Sopenharmony_ci void 794bf215546Sopenharmony_ci (*stats_time_pop)(struct svga_winsys_screen *); 795bf215546Sopenharmony_ci 796bf215546Sopenharmony_ci /** 797bf215546Sopenharmony_ci * Send a host log message 798bf215546Sopenharmony_ci */ 799bf215546Sopenharmony_ci void 800bf215546Sopenharmony_ci (*host_log)(struct svga_winsys_screen *sws, const char *message); 801bf215546Sopenharmony_ci 802bf215546Sopenharmony_ci /** Have VGPU v10 hardware? */ 803bf215546Sopenharmony_ci boolean have_vgpu10; 804bf215546Sopenharmony_ci 805bf215546Sopenharmony_ci /** Have SM4_1 hardware? */ 806bf215546Sopenharmony_ci boolean have_sm4_1; 807bf215546Sopenharmony_ci 808bf215546Sopenharmony_ci /** Have SM5 hardware? */ 809bf215546Sopenharmony_ci boolean have_sm5; 810bf215546Sopenharmony_ci 811bf215546Sopenharmony_ci /** To rebind resources at the beginning of a new command buffer */ 812bf215546Sopenharmony_ci boolean need_to_rebind_resources; 813bf215546Sopenharmony_ci 814bf215546Sopenharmony_ci boolean have_generate_mipmap_cmd; 815bf215546Sopenharmony_ci boolean have_set_predication_cmd; 816bf215546Sopenharmony_ci boolean have_transfer_from_buffer_cmd; 817bf215546Sopenharmony_ci boolean have_fence_fd; 818bf215546Sopenharmony_ci boolean have_intra_surface_copy; 819bf215546Sopenharmony_ci boolean have_constant_buffer_offset_cmd; 820bf215546Sopenharmony_ci boolean have_index_vertex_buffer_offset_cmd; 821bf215546Sopenharmony_ci 822bf215546Sopenharmony_ci /* Have rasterizer state v2 command support */ 823bf215546Sopenharmony_ci boolean have_rasterizer_state_v2_cmd; 824bf215546Sopenharmony_ci 825bf215546Sopenharmony_ci /** Have GL43 capable device */ 826bf215546Sopenharmony_ci boolean have_gl43; 827bf215546Sopenharmony_ci 828bf215546Sopenharmony_ci /** SVGA device_id version we're running on */ 829bf215546Sopenharmony_ci uint16_t device_id; 830bf215546Sopenharmony_ci}; 831bf215546Sopenharmony_ci 832bf215546Sopenharmony_ci 833bf215546Sopenharmony_cistruct svga_winsys_screen * 834bf215546Sopenharmony_cisvga_winsys_screen(struct pipe_screen *screen); 835bf215546Sopenharmony_ci 836bf215546Sopenharmony_cistruct svga_winsys_context * 837bf215546Sopenharmony_cisvga_winsys_context(struct pipe_context *context); 838bf215546Sopenharmony_ci 839bf215546Sopenharmony_cistruct pipe_resource * 840bf215546Sopenharmony_cisvga_screen_buffer_wrap_surface(struct pipe_screen *screen, 841bf215546Sopenharmony_ci enum SVGA3dSurfaceFormat format, 842bf215546Sopenharmony_ci struct svga_winsys_surface *srf); 843bf215546Sopenharmony_ci 844bf215546Sopenharmony_cistruct svga_winsys_surface * 845bf215546Sopenharmony_cisvga_screen_buffer_get_winsys_surface(struct pipe_resource *buffer); 846bf215546Sopenharmony_ci 847bf215546Sopenharmony_ci#endif /* SVGA_WINSYS_H_ */ 848