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 **************************************************************************/
32 #include "main/formats.h"
33 #include "intel_screen.h"
38 * Intel renderbuffer, derived from gl_renderbuffer.
40 struct intel_renderbuffer
42 struct gl_renderbuffer Base
;
43 struct intel_region
*region
;
45 /** Only used by depth renderbuffers for which HiZ is enabled. */
46 struct intel_region
*hiz_region
;
49 * \name Packed depth/stencil unwrappers
51 * If the intel_context is using separate stencil and this renderbuffer has
52 * a a packed depth/stencil format, then wrapped_depth and wrapped_stencil
53 * are the real renderbuffers.
55 struct gl_renderbuffer
*wrapped_depth
;
56 struct gl_renderbuffer
*wrapped_stencil
;
60 GLuint draw_offset
; /**< Offset of drawing address within the region */
61 GLuint draw_x
, draw_y
; /**< Offset of drawing within the region */
66 * gl_renderbuffer is a base class which we subclass. The Class field
67 * is used for simple run-time type checking.
69 #define INTEL_RB_CLASS 0x12345678
73 * Return a gl_renderbuffer ptr casted to intel_renderbuffer.
74 * NULL will be returned if the rb isn't really an intel_renderbuffer.
75 * This is determined by checking the ClassID.
77 static INLINE
struct intel_renderbuffer
*
78 intel_renderbuffer(struct gl_renderbuffer
*rb
)
80 struct intel_renderbuffer
*irb
= (struct intel_renderbuffer
*) rb
;
81 if (irb
&& irb
->Base
.ClassID
== INTEL_RB_CLASS
) {
82 /*_mesa_warning(NULL, "Returning non-intel Rb\n");*/
91 * \brief Return the framebuffer attachment specified by attIndex.
93 * If the framebuffer lacks the specified attachment, then return null.
95 * If the attached renderbuffer is a wrapper, then return wrapped
98 static INLINE
struct intel_renderbuffer
*
99 intel_get_renderbuffer(struct gl_framebuffer
*fb
, gl_buffer_index attIndex
)
101 struct gl_renderbuffer
*rb
;
102 struct intel_renderbuffer
*irb
;
104 /* XXX: Who passes -1 to intel_get_renderbuffer? */
108 rb
= fb
->Attachment
[attIndex
].Renderbuffer
;
112 irb
= intel_renderbuffer(rb
);
118 if (irb
->wrapped_depth
) {
119 irb
= intel_renderbuffer(irb
->wrapped_depth
);
123 if (irb
->wrapped_stencil
) {
124 irb
= intel_renderbuffer(irb
->wrapped_stencil
);
135 * If the framebuffer has a depth buffer attached, then return its HiZ region.
136 * The HiZ region may be null.
138 static INLINE
struct intel_region
*
139 intel_framebuffer_get_hiz_region(struct gl_framebuffer
*fb
)
141 struct intel_renderbuffer
*rb
= NULL
;
143 rb
= intel_get_renderbuffer(fb
, BUFFER_DEPTH
);
146 return rb
->hiz_region
;
152 intel_framebuffer_has_hiz(struct gl_framebuffer
*fb
)
154 return intel_framebuffer_get_hiz_region(fb
) != NULL
;
159 intel_renderbuffer_set_region(struct intel_context
*intel
,
160 struct intel_renderbuffer
*irb
,
161 struct intel_region
*region
);
164 intel_renderbuffer_set_hiz_region(struct intel_context
*intel
,
165 struct intel_renderbuffer
*rb
,
166 struct intel_region
*region
);
169 extern struct intel_renderbuffer
*
170 intel_create_renderbuffer(gl_format format
);
174 intel_fbo_init(struct intel_context
*intel
);
178 intel_flip_renderbuffers(struct gl_framebuffer
*fb
);
181 intel_renderbuffer_tile_offsets(struct intel_renderbuffer
*irb
,
185 static INLINE
struct intel_region
*
186 intel_get_rb_region(struct gl_framebuffer
*fb
, GLuint attIndex
)
188 struct intel_renderbuffer
*irb
= intel_get_renderbuffer(fb
, attIndex
);
195 #endif /* INTEL_FBO_H */