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 **************************************************************************/
33 #include "main/formats.h"
34 #include "intel_context.h"
35 #include "intel_screen.h"
38 struct intel_mipmap_tree
;
39 struct intel_texture_image
;
42 * Intel renderbuffer, derived from gl_renderbuffer.
44 struct intel_renderbuffer
46 struct swrast_renderbuffer Base
;
47 struct intel_mipmap_tree
*mt
; /**< The renderbuffer storage. */
54 * Multiple renderbuffers may simultaneously wrap a single texture and each
55 * provide a different view into that texture. The fields below indicate
56 * which miptree slice is wrapped by this renderbuffer. The fields' values
57 * are consistent with the 'level' and 'layer' parameters of
58 * glFramebufferTextureLayer().
60 * For renderbuffers not created with glFramebufferTexture*(), mt_level and
63 unsigned int mt_level
;
64 unsigned int mt_layer
;
67 GLuint draw_x
, draw_y
; /**< Offset of drawing within the region */
72 * gl_renderbuffer is a base class which we subclass. The Class field
73 * is used for simple run-time type checking.
75 #define INTEL_RB_CLASS 0x12345678
79 * Return a gl_renderbuffer ptr casted to intel_renderbuffer.
80 * NULL will be returned if the rb isn't really an intel_renderbuffer.
81 * This is determined by checking the ClassID.
83 static INLINE
struct intel_renderbuffer
*
84 intel_renderbuffer(struct gl_renderbuffer
*rb
)
86 struct intel_renderbuffer
*irb
= (struct intel_renderbuffer
*) rb
;
87 if (irb
&& irb
->Base
.Base
.ClassID
== INTEL_RB_CLASS
) {
88 /*_mesa_warning(NULL, "Returning non-intel Rb\n");*/
97 * \brief Return the framebuffer attachment specified by attIndex.
99 * If the framebuffer lacks the specified attachment, then return null.
101 * If the attached renderbuffer is a wrapper, then return wrapped
104 static INLINE
struct intel_renderbuffer
*
105 intel_get_renderbuffer(struct gl_framebuffer
*fb
, gl_buffer_index attIndex
)
107 struct gl_renderbuffer
*rb
;
109 assert((unsigned)attIndex
< ARRAY_SIZE(fb
->Attachment
));
111 rb
= fb
->Attachment
[attIndex
].Renderbuffer
;
115 return intel_renderbuffer(rb
);
119 static INLINE gl_format
120 intel_rb_format(const struct intel_renderbuffer
*rb
)
122 return rb
->Base
.Base
.Format
;
127 intel_framebuffer_has_hiz(struct gl_framebuffer
*fb
);
129 extern struct intel_renderbuffer
*
130 intel_create_renderbuffer(gl_format format
);
132 struct gl_renderbuffer
*
133 intel_create_wrapped_renderbuffer(struct gl_context
* ctx
,
134 int width
, int height
,
138 intel_alloc_renderbuffer_storage(struct gl_context
* ctx
,
139 struct gl_renderbuffer
*rb
,
140 GLenum internalFormat
,
141 GLuint width
, GLuint height
);
144 intel_fbo_init(struct intel_context
*intel
);
148 intel_flip_renderbuffers(struct gl_framebuffer
*fb
);
151 intel_renderbuffer_set_draw_offset(struct intel_renderbuffer
*irb
);
154 intel_renderbuffer_tile_offsets(struct intel_renderbuffer
*irb
,
159 intel_get_rb_region(struct gl_framebuffer
*fb
, GLuint attIndex
);
162 intel_renderbuffer_set_needs_hiz_resolve(struct intel_renderbuffer
*irb
);
165 intel_renderbuffer_set_needs_depth_resolve(struct intel_renderbuffer
*irb
);
169 * \brief Perform a HiZ resolve on the renderbuffer.
171 * It is safe to call this function on a renderbuffer without HiZ. In that
172 * case, the function is a no-op.
174 * \return false if no resolve was needed
177 intel_renderbuffer_resolve_hiz(struct intel_context
*intel
,
178 struct intel_renderbuffer
*irb
);
181 * \brief Perform a depth resolve on the renderbuffer.
183 * It is safe to call this function on a renderbuffer without HiZ. In that
184 * case, the function is a no-op.
186 * \return false if no resolve was needed
189 intel_renderbuffer_resolve_depth(struct intel_context
*intel
,
190 struct intel_renderbuffer
*irb
);
192 #endif /* INTEL_FBO_H */