~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/i915tex/intel_regions.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include "mtypes.h"
 
32
#include "intel_screen.h"
 
33
 
 
34
struct intel_context;
 
35
struct intel_buffer_object;
 
36
 
 
37
/**
 
38
 * A layer on top of the bufmgr buffers that adds a few useful things:
 
39
 *
 
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???)
 
44
 */
 
45
struct intel_region
 
46
{
 
47
   struct _DriBufferObject *buffer;   /**< buffer manager's buffer ID */
 
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 */
 
54
 
 
55
   GLuint draw_offset; /**< Offset of drawing address within the region */
 
56
 
 
57
   struct intel_buffer_object *pbo;     /* zero-copy uploads */
 
58
};
 
59
 
 
60
 
 
61
/* Allocate a refcounted region.  Pointers to regions should only be
 
62
 * copied by calling intel_reference_region().
 
63
 */
 
64
struct intel_region *intel_region_alloc(intelScreenPrivate *intelScreen,
 
65
                                        GLuint cpp,
 
66
                                        GLuint pitch, GLuint height);
 
67
 
 
68
void intel_region_reference(struct intel_region **dst,
 
69
                            struct intel_region *src);
 
70
 
 
71
void intel_region_release(struct intel_region **ib);
 
72
 
 
73
extern struct intel_region 
 
74
*intel_region_create_static(intelScreenPrivate *intelScreen,
 
75
                            GLuint mem_type,
 
76
                            GLuint offset,
 
77
                            void *virtual,
 
78
                            GLuint cpp,
 
79
                            GLuint pitch, GLuint height);
 
80
extern void 
 
81
intel_region_update_static(intelScreenPrivate *intelScreen,
 
82
                           struct intel_region *region,
 
83
                           GLuint mem_type,
 
84
                           GLuint offset,
 
85
                           void *virtual,
 
86
                           GLuint cpp, GLuint pitch, GLuint height);
 
87
 
 
88
 
 
89
void intel_region_idle(intelScreenPrivate *intelScreen,
 
90
                       struct intel_region *ib);
 
91
 
 
92
/* Map/unmap regions.  This is refcounted also: 
 
93
 */
 
94
GLubyte *intel_region_map(intelScreenPrivate *intelScreen,
 
95
                          struct intel_region *ib);
 
96
 
 
97
void intel_region_unmap(intelScreenPrivate *intelScreen, struct intel_region *ib);
 
98
 
 
99
 
 
100
/* Upload data to a rectangular sub-region
 
101
 */
 
102
void intel_region_data(intelScreenPrivate *intelScreen,
 
103
                       struct intel_region *dest,
 
104
                       GLuint dest_offset,
 
105
                       GLuint destx, GLuint desty,
 
106
                       void *src, GLuint src_stride,
 
107
                       GLuint srcx, GLuint srcy, GLuint width, GLuint height);
 
108
 
 
109
/* Copy rectangular sub-regions
 
110
 */
 
111
void intel_region_copy(intelScreenPrivate *intelScreen,
 
112
                       struct intel_region *dest,
 
113
                       GLuint dest_offset,
 
114
                       GLuint destx, GLuint desty,
 
115
                       struct intel_region *src,
 
116
                       GLuint src_offset,
 
117
                       GLuint srcx, GLuint srcy, GLuint width, GLuint height);
 
118
 
 
119
/* Fill a rectangular sub-region
 
120
 */
 
121
void intel_region_fill(intelScreenPrivate *intelScreen,
 
122
                       struct intel_region *dest,
 
123
                       GLuint dest_offset,
 
124
                       GLuint destx, GLuint desty,
 
125
                       GLuint width, GLuint height, GLuint color);
 
126
 
 
127
/* Helpers for zerocopy uploads, particularly texture image uploads:
 
128
 */
 
129
void intel_region_attach_pbo(intelScreenPrivate *intelScreen,
 
130
                             struct intel_region *region,
 
131
                             struct intel_buffer_object *pbo);
 
132
void intel_region_release_pbo(intelScreenPrivate *intelScreen,
 
133
                              struct intel_region *region);
 
134
void intel_region_cow(intelScreenPrivate *intelScreen,
 
135
                      struct intel_region *region);
 
136
 
 
137
struct _DriBufferObject *intel_region_buffer(intelScreenPrivate *intelScreen,
 
138
                                             struct intel_region *region,
 
139
                                             GLuint flag);
 
140
 
 
141
#endif