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 "main/macros.h"
35 #include "intel_context.h"
36 #include "intel_mipmap_tree.h"
37 #include "intel_screen.h"
44 struct intel_mipmap_tree
;
45 struct intel_texture_image
;
48 * Intel renderbuffer, derived from gl_renderbuffer.
50 struct intel_renderbuffer
52 struct swrast_renderbuffer Base
;
53 struct intel_mipmap_tree
*mt
; /**< The renderbuffer storage. */
60 * Multiple renderbuffers may simultaneously wrap a single texture and each
61 * provide a different view into that texture. The fields below indicate
62 * which miptree slice is wrapped by this renderbuffer. The fields' values
63 * are consistent with the 'level' and 'layer' parameters of
64 * glFramebufferTextureLayer().
66 * For renderbuffers not created with glFramebufferTexture*(), mt_level and
69 unsigned int mt_level
;
70 unsigned int mt_layer
;
73 GLuint draw_x
, draw_y
; /**< Offset of drawing within the region */
78 * gl_renderbuffer is a base class which we subclass. The Class field
79 * is used for simple run-time type checking.
81 #define INTEL_RB_CLASS 0x12345678
85 * Return a gl_renderbuffer ptr casted to intel_renderbuffer.
86 * NULL will be returned if the rb isn't really an intel_renderbuffer.
87 * This is determined by checking the ClassID.
89 static INLINE
struct intel_renderbuffer
*
90 intel_renderbuffer(struct gl_renderbuffer
*rb
)
92 struct intel_renderbuffer
*irb
= (struct intel_renderbuffer
*) rb
;
93 if (irb
&& irb
->Base
.Base
.ClassID
== INTEL_RB_CLASS
) {
94 /*_mesa_warning(NULL, "Returning non-intel Rb\n");*/
103 * \brief Return the framebuffer attachment specified by attIndex.
105 * If the framebuffer lacks the specified attachment, then return null.
107 * If the attached renderbuffer is a wrapper, then return wrapped
110 static INLINE
struct intel_renderbuffer
*
111 intel_get_renderbuffer(struct gl_framebuffer
*fb
, gl_buffer_index attIndex
)
113 struct gl_renderbuffer
*rb
;
115 assert((unsigned)attIndex
< ARRAY_SIZE(fb
->Attachment
));
117 rb
= fb
->Attachment
[attIndex
].Renderbuffer
;
121 return intel_renderbuffer(rb
);
125 static INLINE gl_format
126 intel_rb_format(const struct intel_renderbuffer
*rb
)
128 return rb
->Base
.Base
.Format
;
131 extern struct intel_renderbuffer
*
132 intel_create_renderbuffer(gl_format format
);
134 struct intel_renderbuffer
*
135 intel_create_private_renderbuffer(gl_format format
);
137 struct gl_renderbuffer
*
138 intel_create_wrapped_renderbuffer(struct gl_context
* ctx
,
139 int width
, int height
,
143 intel_fbo_init(struct intel_context
*intel
);
147 intel_flip_renderbuffers(struct gl_framebuffer
*fb
);
150 intel_renderbuffer_set_draw_offset(struct intel_renderbuffer
*irb
);
152 static inline uint32_t
153 intel_renderbuffer_get_tile_offsets(struct intel_renderbuffer
*irb
,
157 return intel_miptree_get_tile_offsets(irb
->mt
, irb
->mt_level
, irb
->mt_layer
,
162 intel_get_rb_region(struct gl_framebuffer
*fb
, GLuint attIndex
);
168 #endif /* INTEL_FBO_H */