p_screen.h revision 3464ebd5
11.43Schristos/**************************************************************************
21.1Spetrov *
31.1Spetrov * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
41.1Spetrov * All Rights Reserved.
51.1Spetrov *
61.1Spetrov * Permission is hereby granted, free of charge, to any person obtaining a
71.1Spetrov * copy of this software and associated documentation files (the
81.1Spetrov * "Software"), to deal in the Software without restriction, including
91.1Spetrov * without limitation the rights to use, copy, modify, merge, publish,
101.1Spetrov * distribute, sub license, and/or sell copies of the Software, and to
111.1Spetrov * permit persons to whom the Software is furnished to do so, subject to
121.1Spetrov * the following conditions:
131.1Spetrov *
141.1Spetrov * The above copyright notice and this permission notice (including the
151.1Spetrov * next paragraph) shall be included in all copies or substantial portions
161.1Spetrov * of the Software.
171.1Spetrov *
181.1Spetrov * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
191.1Spetrov * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
201.1Spetrov * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
211.1Spetrov * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
221.1Spetrov * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
231.1Spetrov * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
241.1Spetrov * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
251.1Spetrov *
261.1Spetrov **************************************************************************/
271.1Spetrov
281.1Spetrov/**
291.1Spetrov * @file
301.1Spetrov *
311.1Spetrov * Screen, Adapter or GPU
321.1Spetrov *
331.1Spetrov * These are driver functions/facilities that are context independent.
341.3Slukem */
351.3Slukem
361.43Schristos
371.1Spetrov#ifndef P_SCREEN_H
381.1Spetrov#define P_SCREEN_H
391.1Spetrov
401.1Spetrov
411.1Spetrov#include "pipe/p_compiler.h"
421.1Spetrov#include "pipe/p_format.h"
431.1Spetrov#include "pipe/p_defines.h"
441.16Smacallan
451.16Smacallan
461.16Smacallan
471.1Spetrov#ifdef __cplusplus
481.1Spetrovextern "C" {
491.1Spetrov#endif
501.1Spetrov
511.11Smartin
521.1Spetrov/** Opaque type */
531.1Spetrovstruct winsys_handle;
541.11Smartin/** Opaque type */
551.11Smartinstruct pipe_fence_handle;
561.1Spetrovstruct pipe_winsys;
571.30Smartinstruct pipe_resource;
581.30Smartinstruct pipe_surface;
591.30Smartinstruct pipe_transfer;
601.39Sjdc
611.39Sjdc
621.39Sjdc/**
631.39Sjdc * Gallium screen/adapter context.  Basically everything
641.1Spetrov * hardware-specific that doesn't actually require a rendering
651.1Spetrov * context.
661.1Spetrov */
671.38Smacallanstruct pipe_screen {
681.38Smacallan   struct pipe_winsys *winsys;
691.38Smacallan
701.16Smacallan   void (*destroy)( struct pipe_screen * );
711.16Smacallan
721.16Smacallan
731.16Smacallan   const char *(*get_name)( struct pipe_screen * );
741.16Smacallan
751.38Smacallan   const char *(*get_vendor)( struct pipe_screen * );
761.38Smacallan
771.38Smacallan   /**
781.38Smacallan    * Query an integer-valued capability/parameter/limit
791.38Smacallan    * \param param  one of PIPE_CAP_x
801.38Smacallan    */
811.39Sjdc   int (*get_param)( struct pipe_screen *, enum pipe_cap param );
821.39Sjdc
831.39Sjdc   /**
841.39Sjdc    * Query a float-valued capability/parameter/limit
851.39Sjdc    * \param param  one of PIPE_CAP_x
861.39Sjdc    */
871.39Sjdc   float (*get_paramf)( struct pipe_screen *, enum pipe_cap param );
881.39Sjdc
891.39Sjdc   /**
901.39Sjdc    * Query a per-shader-stage integer-valued capability/parameter/limit
911.39Sjdc    * \param param  one of PIPE_CAP_x
921.39Sjdc    */
931.39Sjdc   int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param );
941.11Smartin
951.11Smartin   struct pipe_context * (*context_create)( struct pipe_screen *,
961.1Spetrov					    void *priv );
971.6Sheas
981.1Spetrov   /**
991.1Spetrov    * Check if the given pipe_format is supported as a texture or
1001.1Spetrov    * drawing surface.
1011.31Smartin    * \param bindings  bitmask of PIPE_BIND_*
1021.31Smartin    */
1031.1Spetrov   boolean (*is_format_supported)( struct pipe_screen *,
1041.1Spetrov                                   enum pipe_format format,
1051.1Spetrov                                   enum pipe_texture_target target,
1061.1Spetrov                                   unsigned sample_count,
1071.1Spetrov                                   unsigned bindings );
1081.1Spetrov
1091.1Spetrov   /**
1101.1Spetrov    * Create a new texture object, using the given template info.
1111.1Spetrov    */
1121.1Spetrov   struct pipe_resource * (*resource_create)(struct pipe_screen *,
1131.1Spetrov					     const struct pipe_resource *templat);
1141.1Spetrov
1151.30Smartin   /**
1161.16Smacallan    * Create a texture from a winsys_handle. The handle is often created in
1171.32Schristos    * another process by first creating a pipe texture and then calling
1181.7Sheas    * resource_get_handle.
1191.24Sjmmv    */
1201.1Spetrov   struct pipe_resource * (*resource_from_handle)(struct pipe_screen *,
1211.1Spetrov						  const struct pipe_resource *templat,
1221.1Spetrov						  struct winsys_handle *handle);
1231.1Spetrov
1241.1Spetrov   /**
1251.1Spetrov    * Get a winsys_handle from a texture. Some platforms/winsys requires
1261.1Spetrov    * that the texture is created with a special usage flag like
1271.1Spetrov    * DISPLAYTARGET or PRIMARY.
1281.38Smacallan    */
1291.38Smacallan   boolean (*resource_get_handle)(struct pipe_screen *,
1301.1Spetrov				  struct pipe_resource *tex,
1311.16Smacallan				  struct winsys_handle *handle);
1321.16Smacallan
1331.30Smartin
1341.16Smacallan   void (*resource_destroy)(struct pipe_screen *,
1351.16Smacallan			    struct pipe_resource *pt);
1361.16Smacallan
1371.16Smacallan
1381.16Smacallan   /**
1391.11Smartin    * Create a buffer that wraps user-space data.
1401.43Schristos    *
1411.11Smartin    * Effectively this schedules a delayed call to buffer_create
1421.11Smartin    * followed by an upload of the data at *some point in the future*,
1431.11Smartin    * or perhaps never.  Basically the allocate/upload is delayed
1441.11Smartin    * until the buffer is actually passed to hardware.
1451.16Smacallan    *
1461.11Smartin    * The intention is to provide a quick way to turn regular data
1471.11Smartin    * into a buffer, and secondly to avoid a copy operation if that
1481.11Smartin    * data subsequently turns out to be only accessed by the CPU.
1491.11Smartin    *
1501.11Smartin    * Common example is OpenGL vertex buffers that are subsequently
1511.1Spetrov    * processed either by software TNL in the driver or by passing to
1521.30Smartin    * hardware.
1531.30Smartin    *
1541.1Spetrov    * XXX: What happens if the delayed call to buffer_create() fails?
1551.1Spetrov    *
1561.39Sjdc    * Note that ptr may be accessed at any time upto the time when the
1571.39Sjdc    * buffer is destroyed, so the data must not be freed before then.
1581.39Sjdc    */
1591.39Sjdc   struct pipe_resource *(*user_buffer_create)(struct pipe_screen *screen,
1601.39Sjdc					       void *ptr,
1611.39Sjdc					       unsigned bytes,
1621.39Sjdc					       unsigned bind_flags);
1631.39Sjdc
1641.39Sjdc   /**
1651.39Sjdc    * Do any special operations to ensure frontbuffer contents are
1661.39Sjdc    * displayed, eg copy fake frontbuffer.
1671.39Sjdc    * \param winsys_drawable_handle  an opaque handle that the calling context
1681.39Sjdc    *                                gets out-of-band
1691.39Sjdc    */
1701.39Sjdc   void (*flush_frontbuffer)( struct pipe_screen *screen,
1711.39Sjdc                              struct pipe_resource *resource,
1721.39Sjdc                              unsigned level, unsigned layer,
1731.39Sjdc                              void *winsys_drawable_handle );
1741.39Sjdc
1751.39Sjdc
1761.39Sjdc
1771.39Sjdc   /** Set ptr = fence, with reference counting */
1781.39Sjdc   void (*fence_reference)( struct pipe_screen *screen,
1791.39Sjdc                            struct pipe_fence_handle **ptr,
1801.39Sjdc                            struct pipe_fence_handle *fence );
1811.39Sjdc
1821.39Sjdc   /**
1831.39Sjdc    * Checks whether the fence has been signalled.
1841.39Sjdc    */
1851.39Sjdc   boolean (*fence_signalled)( struct pipe_screen *screen,
1861.39Sjdc                               struct pipe_fence_handle *fence );
1871.39Sjdc
1881.39Sjdc   /**
1891.39Sjdc    * Wait for the fence to finish.
1901.1Spetrov    * \param timeout  in nanoseconds
1911.1Spetrov    */
1921.1Spetrov   boolean (*fence_finish)( struct pipe_screen *screen,
1931.1Spetrov                            struct pipe_fence_handle *fence,
1941.16Smacallan                            uint64_t timeout );
1951.16Smacallan
1961.39Sjdc};
1971.1Spetrov
1981.30Smartin
1991.4Spk#ifdef __cplusplus
2001.7Sheas}
2011.4Spk#endif
2021.39Sjdc
2031.1Spetrov#endif /* P_SCREEN_H */
2041.1Spetrov