1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
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 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.
26 **************************************************************************/
28 #ifndef INTEL_REGIONS_H
29 #define INTEL_REGIONS_H
32 #include "intel_screen.h"
35 struct intel_buffer_object
;
38 * A layer on top of the bufmgr buffers that adds a few useful things:
40 * - Refcounting for local buffer references.
41 * - Refcounting for buffer maps
42 * - Buffer dimensions - pitch and height.
43 * - Blitter commands for copying 2D regions between buffers. (really???)
47 dri_bo
*buffer
; /**< buffer manager's buffer */
48 GLuint refcount
; /**< Reference count for region */
49 GLuint cpp
; /**< bytes per pixel */
50 GLuint pitch
; /**< in pixels */
51 GLuint height
; /**< in pixels */
52 GLubyte
*map
; /**< only non-NULL when region is actually mapped */
53 GLuint map_refcount
; /**< Reference count for mapping */
55 GLuint draw_offset
; /**< Offset of drawing address within the region */
57 struct intel_buffer_object
*pbo
; /* zero-copy uploads */
61 /* Allocate a refcounted region. Pointers to regions should only be
62 * copied by calling intel_reference_region().
64 struct intel_region
*intel_region_alloc(intelScreenPrivate
*intelScreen
,
66 GLuint pitch
, GLuint height
);
68 void intel_region_reference(struct intel_region
**dst
,
69 struct intel_region
*src
);
71 void intel_region_release(struct intel_region
**ib
);
73 extern struct intel_region
74 *intel_region_create_static(intelScreenPrivate
*intelScreen
,
76 unsigned int bo_handle
,
80 GLuint pitch
, GLuint height
);
82 intel_region_update_static(intelScreenPrivate
*intelScreen
,
83 struct intel_region
*region
,
85 unsigned int bo_handle
,
88 GLuint cpp
, GLuint pitch
, GLuint height
);
91 void intel_region_idle(intelScreenPrivate
*intelScreen
,
92 struct intel_region
*ib
);
94 /* Map/unmap regions. This is refcounted also:
96 GLubyte
*intel_region_map(intelScreenPrivate
*intelScreen
,
97 struct intel_region
*ib
);
99 void intel_region_unmap(intelScreenPrivate
*intelScreen
, struct intel_region
*ib
);
102 /* Upload data to a rectangular sub-region
104 void intel_region_data(intelScreenPrivate
*intelScreen
,
105 struct intel_region
*dest
,
107 GLuint destx
, GLuint desty
,
108 const void *src
, GLuint src_stride
,
109 GLuint srcx
, GLuint srcy
, GLuint width
, GLuint height
);
111 /* Copy rectangular sub-regions
113 void intel_region_copy(intelScreenPrivate
*intelScreen
,
114 struct intel_region
*dest
,
116 GLuint destx
, GLuint desty
,
117 struct intel_region
*src
,
119 GLuint srcx
, GLuint srcy
, GLuint width
, GLuint height
);
121 /* Fill a rectangular sub-region
123 void intel_region_fill(intelScreenPrivate
*intelScreen
,
124 struct intel_region
*dest
,
126 GLuint destx
, GLuint desty
,
127 GLuint width
, GLuint height
, GLuint color
);
129 /* Helpers for zerocopy uploads, particularly texture image uploads:
131 void intel_region_attach_pbo(intelScreenPrivate
*intelScreen
,
132 struct intel_region
*region
,
133 struct intel_buffer_object
*pbo
);
134 void intel_region_release_pbo(intelScreenPrivate
*intelScreen
,
135 struct intel_region
*region
);
136 void intel_region_cow(intelScreenPrivate
*intelScreen
,
137 struct intel_region
*region
);
139 dri_bo
*intel_region_buffer(intelScreenPrivate
*intelScreen
,
140 struct intel_region
*region
,