Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
  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 TUNGSTEN GRAPHICS 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. #ifndef INTEL_REGIONS_H
  29. #define INTEL_REGIONS_H
  30.  
  31. /** @file intel_regions.h
  32.  *
  33.  * Structure definitions and prototypes for intel_region handling,
  34.  * which is the basic structure for rectangular collections of pixels
  35.  * stored in a drm_intel_bo.
  36.  */
  37.  
  38. #include <stdbool.h>
  39. #include <xf86drm.h>
  40.  
  41. #include "main/mtypes.h"
  42. #include "intel_bufmgr.h"
  43.  
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47.  
  48. struct brw_context;
  49. struct intel_screen;
  50. struct intel_buffer_object;
  51.  
  52. /**
  53.  * A layer on top of the bufmgr buffers that adds a few useful things:
  54.  *
  55.  * - Refcounting for local buffer references.
  56.  * - Refcounting for buffer maps
  57.  * - Buffer dimensions - pitch and height.
  58.  * - Blitter commands for copying 2D regions between buffers. (really???)
  59.  */
  60. struct intel_region
  61. {
  62.    drm_intel_bo *bo;  /**< buffer manager's buffer */
  63.    GLuint refcount; /**< Reference count for region */
  64.    GLuint cpp;      /**< bytes per pixel */
  65.    GLuint width;    /**< in pixels */
  66.    GLuint height;   /**< in pixels */
  67.    GLuint pitch;    /**< in bytes */
  68.  
  69.    uint32_t tiling; /**< Which tiling mode the region is in */
  70.  
  71.    uint32_t name; /**< Global name for the bo */
  72. };
  73.  
  74.  
  75. /* Allocate a refcounted region.  Pointers to regions should only be
  76.  * copied by calling intel_reference_region().
  77.  */
  78. struct intel_region *intel_region_alloc(struct intel_screen *screen,
  79.                                         uint32_t tiling,
  80.                                         GLuint cpp, GLuint width,
  81.                                         GLuint height,
  82.                                         bool expect_accelerated_upload);
  83.  
  84. struct intel_region *
  85. intel_region_alloc_for_handle(struct intel_screen *screen,
  86.                               GLuint cpp,
  87.                               GLuint width, GLuint height, GLuint pitch,
  88.                               unsigned int handle, const char *name);
  89.  
  90. struct intel_region *
  91. intel_region_alloc_for_fd(struct intel_screen *screen,
  92.                           GLuint cpp,
  93.                           GLuint width, GLuint height, GLuint pitch,
  94.                           int fd, const char *name);
  95.  
  96. bool
  97. intel_region_flink(struct intel_region *region, uint32_t *name);
  98.  
  99. void intel_region_reference(struct intel_region **dst,
  100.                             struct intel_region *src);
  101.  
  102. void intel_region_release(struct intel_region **ib);
  103.  
  104. void
  105. intel_region_get_tile_masks(struct intel_region *region,
  106.                             uint32_t *mask_x, uint32_t *mask_y,
  107.                             bool map_stencil_as_y_tiled);
  108.  
  109. uint32_t
  110. intel_region_get_aligned_offset(struct intel_region *region, uint32_t x,
  111.                                 uint32_t y, bool map_stencil_as_y_tiled);
  112.  
  113. /**
  114.  * Used with images created with image_from_names
  115.  * to help support planar images.
  116.  */
  117. struct intel_image_format {
  118.    int fourcc;
  119.    int components;
  120.    int nplanes;
  121.    struct {
  122.       int buffer_index;
  123.       int width_shift;
  124.       int height_shift;
  125.       uint32_t dri_format;
  126.       int cpp;
  127.    } planes[3];
  128. };
  129.  
  130. struct __DRIimageRec {
  131.    struct intel_region *region;
  132.    GLenum internal_format;
  133.    uint32_t dri_format;
  134.    GLuint format;
  135.    uint32_t offset;
  136.  
  137.    /*
  138.     * Need to save these here between calls to
  139.     * image_from_names and calls to image_from_planar.
  140.     */
  141.    uint32_t strides[3];
  142.    uint32_t offsets[3];
  143.    struct intel_image_format *planar_format;
  144.  
  145.    /* particular miptree level */
  146.    GLuint width;
  147.    GLuint height;
  148.    GLuint tile_x;
  149.    GLuint tile_y;
  150.    bool has_depthstencil;
  151.  
  152.    void *data;
  153. };
  154.  
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158.  
  159. #endif
  160.