Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2007 VMware, Inc.
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the
  8.  * "Software"), to deal in the Software without restriction, including
  9.  * without limitation the rights to use, copy, modify, merge, publish,
  10.  * distribute, sub license, and/or sell copies of the Software, and to
  11.  * permit persons to whom the Software is furnished to do so, subject to
  12.  * the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21.  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  22.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  *
  26.  **************************************************************************/
  27.  
  28. /**
  29.  * @file
  30.  *
  31.  * Screen, Adapter or GPU
  32.  *
  33.  * These are driver functions/facilities that are context independent.
  34.  */
  35.  
  36.  
  37. #ifndef P_SCREEN_H
  38. #define P_SCREEN_H
  39.  
  40.  
  41. #include "pipe/p_compiler.h"
  42. #include "pipe/p_format.h"
  43. #include "pipe/p_defines.h"
  44. #include "pipe/p_video_enums.h"
  45.  
  46.  
  47.  
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51.  
  52.  
  53. /** Opaque types */
  54. struct winsys_handle;
  55. struct pipe_fence_handle;
  56. struct pipe_resource;
  57. struct pipe_surface;
  58. struct pipe_transfer;
  59. struct pipe_box;
  60.  
  61.  
  62. /**
  63.  * Gallium screen/adapter context.  Basically everything
  64.  * hardware-specific that doesn't actually require a rendering
  65.  * context.
  66.  */
  67. struct pipe_screen {
  68.    void (*destroy)( struct pipe_screen * );
  69.  
  70.    const char *(*get_name)( struct pipe_screen * );
  71.  
  72.    const char *(*get_vendor)( struct pipe_screen * );
  73.  
  74.    /**
  75.     * Returns the device vendor.
  76.     *
  77.     * The returned value should return the actual device vendor/manufacturer,
  78.     * rather than a potentially generic driver string.
  79.     */
  80.    const char *(*get_device_vendor)( struct pipe_screen * );
  81.  
  82.    /**
  83.     * Query an integer-valued capability/parameter/limit
  84.     * \param param  one of PIPE_CAP_x
  85.     */
  86.    int (*get_param)( struct pipe_screen *, enum pipe_cap param );
  87.  
  88.    /**
  89.     * Query a float-valued capability/parameter/limit
  90.     * \param param  one of PIPE_CAP_x
  91.     */
  92.    float (*get_paramf)( struct pipe_screen *, enum pipe_capf param );
  93.  
  94.    /**
  95.     * Query a per-shader-stage integer-valued capability/parameter/limit
  96.     * \param param  one of PIPE_CAP_x
  97.     */
  98.    int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param );
  99.  
  100.    /**
  101.     * Query an integer-valued capability/parameter/limit for a codec/profile
  102.     * \param param  one of PIPE_VIDEO_CAP_x
  103.     */
  104.    int (*get_video_param)( struct pipe_screen *,
  105.                            enum pipe_video_profile profile,
  106.                            enum pipe_video_entrypoint entrypoint,
  107.                            enum pipe_video_cap param );
  108.  
  109.    /**
  110.     * Query a compute-specific capability/parameter/limit.
  111.     * \param param  one of PIPE_COMPUTE_CAP_x
  112.     * \param ret    pointer to a preallocated buffer that will be
  113.     *               initialized to the parameter value, or NULL.
  114.     * \return       size in bytes of the parameter value that would be
  115.     *               returned.
  116.     */
  117.    int (*get_compute_param)(struct pipe_screen *,
  118.                             enum pipe_compute_cap param,
  119.                             void *ret);
  120.  
  121.    /**
  122.     * Query a timestamp in nanoseconds. The returned value should match
  123.     * PIPE_QUERY_TIMESTAMP. This function returns immediately and doesn't
  124.     * wait for rendering to complete (which cannot be achieved with queries).
  125.     */
  126.    uint64_t (*get_timestamp)(struct pipe_screen *);
  127.  
  128.    struct pipe_context * (*context_create)( struct pipe_screen *,
  129.                                             void *priv );
  130.  
  131.    /**
  132.     * Check if the given pipe_format is supported as a texture or
  133.     * drawing surface.
  134.     * \param bindings  bitmask of PIPE_BIND_*
  135.     */
  136.    boolean (*is_format_supported)( struct pipe_screen *,
  137.                                    enum pipe_format format,
  138.                                    enum pipe_texture_target target,
  139.                                    unsigned sample_count,
  140.                                    unsigned bindings );
  141.  
  142.    /**
  143.     * Check if the given pipe_format is supported as output for this codec/profile.
  144.     * \param profile  profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN
  145.     */
  146.    boolean (*is_video_format_supported)( struct pipe_screen *,
  147.                                          enum pipe_format format,
  148.                                          enum pipe_video_profile profile,
  149.                                          enum pipe_video_entrypoint entrypoint );
  150.  
  151.    /**
  152.     * Check if we can actually create the given resource (test the dimension,
  153.     * overall size, etc).  Used to implement proxy textures.
  154.     * \return TRUE if size is OK, FALSE if too large.
  155.     */
  156.    boolean (*can_create_resource)(struct pipe_screen *screen,
  157.                                   const struct pipe_resource *templat);
  158.  
  159.    /**
  160.     * Create a new texture object, using the given template info.
  161.     */
  162.    struct pipe_resource * (*resource_create)(struct pipe_screen *,
  163.                                              const struct pipe_resource *templat);
  164.  
  165.    /**
  166.     * Create a texture from a winsys_handle. The handle is often created in
  167.     * another process by first creating a pipe texture and then calling
  168.     * resource_get_handle.
  169.     */
  170.    struct pipe_resource * (*resource_from_handle)(struct pipe_screen *,
  171.                                                   const struct pipe_resource *templat,
  172.                                                   struct winsys_handle *handle);
  173.  
  174.    /**
  175.     * Create a resource from user memory. This maps the user memory into
  176.     * the device address space.
  177.     */
  178.    struct pipe_resource * (*resource_from_user_memory)(struct pipe_screen *,
  179.                                                        const struct pipe_resource *t,
  180.                                                        void *user_memory);
  181.  
  182.    /**
  183.     * Get a winsys_handle from a texture. Some platforms/winsys requires
  184.     * that the texture is created with a special usage flag like
  185.     * DISPLAYTARGET or PRIMARY.
  186.     */
  187.    boolean (*resource_get_handle)(struct pipe_screen *,
  188.                                   struct pipe_resource *tex,
  189.                                   struct winsys_handle *handle);
  190.  
  191.  
  192.    void (*resource_destroy)(struct pipe_screen *,
  193.                             struct pipe_resource *pt);
  194.  
  195.  
  196.    /**
  197.     * Do any special operations to ensure frontbuffer contents are
  198.     * displayed, eg copy fake frontbuffer.
  199.     * \param winsys_drawable_handle  an opaque handle that the calling context
  200.     *                                gets out-of-band
  201.     * \param subbox an optional sub region to flush
  202.     */
  203.    void (*flush_frontbuffer)( struct pipe_screen *screen,
  204.                               struct pipe_resource *resource,
  205.                               unsigned level, unsigned layer,
  206.                               void *winsys_drawable_handle,
  207.                               struct pipe_box *subbox );
  208.  
  209.    /** Set ptr = fence, with reference counting */
  210.    void (*fence_reference)( struct pipe_screen *screen,
  211.                             struct pipe_fence_handle **ptr,
  212.                             struct pipe_fence_handle *fence );
  213.  
  214.    /**
  215.     * Checks whether the fence has been signalled.
  216.     */
  217.    boolean (*fence_signalled)( struct pipe_screen *screen,
  218.                                struct pipe_fence_handle *fence );
  219.  
  220.    /**
  221.     * Wait for the fence to finish.
  222.     * \param timeout  in nanoseconds (may be PIPE_TIMEOUT_INFINITE).
  223.     */
  224.    boolean (*fence_finish)( struct pipe_screen *screen,
  225.                             struct pipe_fence_handle *fence,
  226.                             uint64_t timeout );
  227.  
  228.    /**
  229.     * Returns a driver-specific query.
  230.     *
  231.     * If \p info is NULL, the number of available queries is returned.
  232.     * Otherwise, the driver query at the specified \p index is returned
  233.     * in \p info. The function returns non-zero on success.
  234.     */
  235.    int (*get_driver_query_info)(struct pipe_screen *screen,
  236.                                 unsigned index,
  237.                                 struct pipe_driver_query_info *info);
  238.  
  239.    /**
  240.     * Returns a driver-specific query group.
  241.     *
  242.     * If \p info is NULL, the number of available groups is returned.
  243.     * Otherwise, the driver query group at the specified \p index is returned
  244.     * in \p info. The function returns non-zero on success.
  245.     */
  246.    int (*get_driver_query_group_info)(struct pipe_screen *screen,
  247.                                       unsigned index,
  248.                                       struct pipe_driver_query_group_info *info);
  249.  
  250. };
  251.  
  252.  
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256.  
  257. #endif /* P_SCREEN_H */
  258.