Path: blob/21.2-virgl/src/gallium/drivers/i915/i915_winsys.h
4570 views
/**************************************************************************1*2* Copyright © 2009 Jakob Bornecrantz3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER21* DEALINGS IN THE SOFTWARE.22*23**************************************************************************/2425#ifndef I915_WINSYS_H26#define I915_WINSYS_H2728#include "pipe/p_compiler.h"2930struct i915_winsys;31struct i915_winsys_buffer;32struct i915_winsys_batchbuffer;33struct pipe_resource;34struct pipe_fence_handle;35struct winsys_handle;3637enum i915_winsys_buffer_usage {38/* use on textures */39I915_USAGE_RENDER = 0x01,40I915_USAGE_SAMPLER = 0x02,41I915_USAGE_2D_TARGET = 0x04,42I915_USAGE_2D_SOURCE = 0x08,43/* use on vertex */44I915_USAGE_VERTEX = 0x1045};4647enum i915_winsys_buffer_type {48I915_NEW_TEXTURE,49I915_NEW_SCANOUT, /**< a texture used for scanning out from */50I915_NEW_VERTEX51};5253/* These need to be in sync with the definitions of libdrm-intel! */54enum i915_winsys_buffer_tile { I915_TILE_NONE, I915_TILE_X, I915_TILE_Y };5556enum i915_winsys_flush_flags {57I915_FLUSH_ASYNC = 0,58I915_FLUSH_END_OF_FRAME = 159};6061struct i915_winsys_batchbuffer {6263struct i915_winsys *iws;6465/**66* Values exported to speed up the writing the batchbuffer,67* instead of having to go trough a accesor function for68* each dword written.69*/70/*{@*/71uint8_t *map;72uint8_t *ptr;73size_t size;7475size_t relocs;76/*@}*/77};7879struct i915_winsys {8081unsigned pci_id; /**< PCI ID for the device */8283/**84* Batchbuffer functions.85*/86/*@{*/87/**88* Create a new batchbuffer.89*/90struct i915_winsys_batchbuffer *(*batchbuffer_create)(91struct i915_winsys *iws);9293/**94* Validate buffers for usage in this batchbuffer.95* Does space-checking and asorted other book-keeping.96*97* @batch98* @buffers array to buffers to validate99* @num_of_buffers size of the passed array100*/101bool (*validate_buffers)(struct i915_winsys_batchbuffer *batch,102struct i915_winsys_buffer **buffers,103int num_of_buffers);104105/**106* Emit a relocation to a buffer.107* Target position in batchbuffer is the same as ptr.108*109* @batch110* @reloc buffer address to be inserted into target.111* @usage how is the hardware going to use the buffer.112* @offset add this to the reloc buffers address113* @target buffer where to write the address, null for batchbuffer.114* @fenced relocation needs a fence.115*/116int (*batchbuffer_reloc)(struct i915_winsys_batchbuffer *batch,117struct i915_winsys_buffer *reloc,118enum i915_winsys_buffer_usage usage,119unsigned offset, bool fenced);120121/**122* Flush a bufferbatch.123*/124void (*batchbuffer_flush)(struct i915_winsys_batchbuffer *batch,125struct pipe_fence_handle **fence,126enum i915_winsys_flush_flags flags);127128/**129* Destroy a batchbuffer.130*/131void (*batchbuffer_destroy)(struct i915_winsys_batchbuffer *batch);132/*@}*/133134/**135* Buffer functions.136*/137/*@{*/138/**139* Create a buffer.140*/141struct i915_winsys_buffer *(*buffer_create)(142struct i915_winsys *iws, unsigned size,143enum i915_winsys_buffer_type type);144145/**146* Create a tiled buffer.147*148* *stride, height are in bytes. The winsys tries to allocate the buffer with149* the tiling mode provide in *tiling. If tiling is no possible, *tiling will150* be set to I915_TILE_NONE. The calculated stride (incorporateing hw/kernel151* requirements) is always returned in *stride.152*/153struct i915_winsys_buffer *(*buffer_create_tiled)(154struct i915_winsys *iws, unsigned *stride, unsigned height,155enum i915_winsys_buffer_tile *tiling, enum i915_winsys_buffer_type type);156157/**158* Creates a buffer from a handle.159* Used to implement pipe_screen::resource_from_handle.160* Also provides the stride information needed for the161* texture via the stride argument.162*/163struct i915_winsys_buffer *(*buffer_from_handle)(164struct i915_winsys *iws, struct winsys_handle *whandle, unsigned height,165enum i915_winsys_buffer_tile *tiling, unsigned *stride);166167/**168* Used to implement pipe_screen::resource_get_handle.169* The winsys might need the stride information.170*/171bool (*buffer_get_handle)(struct i915_winsys *iws,172struct i915_winsys_buffer *buffer,173struct winsys_handle *whandle, unsigned stride);174175/**176* Map a buffer.177*/178void *(*buffer_map)(struct i915_winsys *iws,179struct i915_winsys_buffer *buffer, bool write);180181/**182* Unmap a buffer.183*/184void (*buffer_unmap)(struct i915_winsys *iws,185struct i915_winsys_buffer *buffer);186187/**188* Write to a buffer.189*190* Arguments follows pipe_buffer_write.191*/192int (*buffer_write)(struct i915_winsys *iws, struct i915_winsys_buffer *dst,193size_t offset, size_t size, const void *data);194195void (*buffer_destroy)(struct i915_winsys *iws,196struct i915_winsys_buffer *buffer);197198/**199* Check if a buffer is busy.200*/201bool (*buffer_is_busy)(struct i915_winsys *iws,202struct i915_winsys_buffer *buffer);203/*@}*/204205/**206* Fence functions.207*/208/*@{*/209/**210* Reference fence and set ptr to fence.211*/212void (*fence_reference)(struct i915_winsys *iws,213struct pipe_fence_handle **ptr,214struct pipe_fence_handle *fence);215216/**217* Check if a fence has finished.218*/219int (*fence_signalled)(struct i915_winsys *iws,220struct pipe_fence_handle *fence);221222/**223* Wait on a fence to finish.224*/225int (*fence_finish)(struct i915_winsys *iws,226struct pipe_fence_handle *fence);227/*@}*/228229/**230* Retrieve the aperture size (in MiB) of the device.231*/232int (*aperture_size)(struct i915_winsys *iws);233234/**235* Destroy the winsys.236*/237void (*destroy)(struct i915_winsys *iws);238};239240#endif241242243