1 /**************************************************************************
3 * Copyright 2006 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef INTEL_REGIONS_H
29 #define INTEL_REGIONS_H
31 /** @file intel_regions.h
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.
41 #include "main/mtypes.h"
42 #include "intel_bufmgr.h"
43 #include <GL/internal/dri_interface.h>
51 struct intel_buffer_object
;
54 * A layer on top of the bufmgr buffers that adds a few useful things:
56 * - Refcounting for local buffer references.
57 * - Refcounting for buffer maps
58 * - Buffer dimensions - pitch and height.
59 * - Blitter commands for copying 2D regions between buffers. (really???)
63 drm_intel_bo
*bo
; /**< buffer manager's buffer */
64 GLuint refcount
; /**< Reference count for region */
65 GLuint cpp
; /**< bytes per pixel */
66 GLuint width
; /**< in pixels */
67 GLuint height
; /**< in pixels */
68 GLuint pitch
; /**< in bytes */
70 uint32_t tiling
; /**< Which tiling mode the region is in */
72 uint32_t name
; /**< Global name for the bo */
76 /* Allocate a refcounted region. Pointers to regions should only be
77 * copied by calling intel_reference_region().
79 struct intel_region
*intel_region_alloc(struct intel_screen
*screen
,
81 GLuint cpp
, GLuint width
,
83 bool expect_accelerated_upload
);
86 intel_region_alloc_for_handle(struct intel_screen
*screen
,
88 GLuint width
, GLuint height
, GLuint pitch
,
89 unsigned int handle
, const char *name
);
92 intel_region_alloc_for_fd(struct intel_screen
*screen
,
94 GLuint width
, GLuint height
, GLuint pitch
,
96 int fd
, const char *name
);
99 intel_region_flink(struct intel_region
*region
, uint32_t *name
);
101 void intel_region_reference(struct intel_region
**dst
,
102 struct intel_region
*src
);
104 void intel_region_release(struct intel_region
**ib
);
107 intel_region_get_tile_masks(const struct intel_region
*region
,
108 uint32_t *mask_x
, uint32_t *mask_y
,
109 bool map_stencil_as_y_tiled
);
112 intel_region_get_aligned_offset(const struct intel_region
*region
, uint32_t x
,
113 uint32_t y
, bool map_stencil_as_y_tiled
);
116 * Used with images created with image_from_names
117 * to help support planar images.
119 struct intel_image_format
{
132 struct __DRIimageRec
{
133 struct intel_region
*region
;
134 GLenum internal_format
;
140 * Need to save these here between calls to
141 * image_from_names and calls to image_from_planar.
145 struct intel_image_format
*planar_format
;
147 /* particular miptree level */
152 bool has_depthstencil
;
155 * Provided by EGL_EXT_image_dma_buf_import.
157 * The flag is set in order to restrict the use of the image later on.
159 * See intel_image_target_texture_2d()
161 bool dma_buf_imported
;
162 enum __DRIYUVColorSpace yuv_color_space
;
163 enum __DRISampleRange sample_range
;
164 enum __DRIChromaSiting horizontal_siting
;
165 enum __DRIChromaSiting vertical_siting
;