1 /**************************************************************************
3 * Copyright 2006 VMware, Inc.
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 VMWARE 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 "brw_context.h"
36 #include "intel_mipmap_tree.h"
37 #include "intel_screen.h"
43 struct intel_mipmap_tree
;
44 struct intel_texture_image
;
47 * Intel renderbuffer, derived from gl_renderbuffer.
49 struct intel_renderbuffer
51 struct swrast_renderbuffer Base
;
52 struct intel_mipmap_tree
*mt
; /**< The renderbuffer storage. */
58 * Multiple renderbuffers may simultaneously wrap a single texture and each
59 * provide a different view into that texture. The fields below indicate
60 * which miptree slice is wrapped by this renderbuffer. The fields' values
61 * are consistent with the 'level' and 'layer' parameters of
62 * glFramebufferTextureLayer().
64 * For renderbuffers not created with glFramebufferTexture*(), mt_level and
67 * Note: for a 2D multisample array texture on Gen7+ using
68 * INTEL_MSAA_LAYOUT_UMS or INTEL_MSAA_LAYOUT_CMS, mt_layer is the physical
69 * layer holding sample 0. So, for example, if mt->num_samples == 4, then
70 * logical layer n corresponds to mt_layer == 4*n.
72 unsigned int mt_level
;
73 unsigned int mt_layer
;
76 GLuint draw_x
, draw_y
; /**< Offset of drawing within the region */
81 * gl_renderbuffer is a base class which we subclass. The Class field
82 * is used for simple run-time type checking.
84 #define INTEL_RB_CLASS 0x12345678
88 * Return a gl_renderbuffer ptr casted to intel_renderbuffer.
89 * NULL will be returned if the rb isn't really an intel_renderbuffer.
90 * This is determined by checking the ClassID.
92 static inline struct intel_renderbuffer
*
93 intel_renderbuffer(struct gl_renderbuffer
*rb
)
95 struct intel_renderbuffer
*irb
= (struct intel_renderbuffer
*) rb
;
96 if (irb
&& irb
->Base
.Base
.ClassID
== INTEL_RB_CLASS
) {
97 /*_mesa_warning(NULL, "Returning non-intel Rb\n");*/
106 * \brief Return the framebuffer attachment specified by attIndex.
108 * If the framebuffer lacks the specified attachment, then return null.
110 * If the attached renderbuffer is a wrapper, then return wrapped
113 static inline struct intel_renderbuffer
*
114 intel_get_renderbuffer(struct gl_framebuffer
*fb
, gl_buffer_index attIndex
)
116 struct gl_renderbuffer
*rb
;
118 assert((unsigned)attIndex
< ARRAY_SIZE(fb
->Attachment
));
120 rb
= fb
->Attachment
[attIndex
].Renderbuffer
;
124 return intel_renderbuffer(rb
);
128 static inline gl_format
129 intel_rb_format(const struct intel_renderbuffer
*rb
)
131 return rb
->Base
.Base
.Format
;
134 extern struct intel_renderbuffer
*
135 intel_create_renderbuffer(gl_format format
, unsigned num_samples
);
137 struct intel_renderbuffer
*
138 intel_create_private_renderbuffer(gl_format format
, unsigned num_samples
);
140 struct gl_renderbuffer
*
141 intel_create_wrapped_renderbuffer(struct gl_context
* ctx
,
142 int width
, int height
,
146 intel_fbo_init(struct brw_context
*brw
);
149 intel_renderbuffer_set_draw_offset(struct intel_renderbuffer
*irb
);
151 static inline uint32_t
152 intel_renderbuffer_get_tile_offsets(struct intel_renderbuffer
*irb
,
156 return intel_miptree_get_tile_offsets(irb
->mt
, irb
->mt_level
, irb
->mt_layer
,
161 intel_renderbuffer_set_needs_downsample(struct intel_renderbuffer
*irb
);
164 intel_renderbuffer_has_hiz(struct intel_renderbuffer
*irb
);
167 intel_renderbuffer_att_set_needs_depth_resolve(struct gl_renderbuffer_attachment
*att
);
171 * \brief Perform a HiZ resolve on the renderbuffer.
173 * It is safe to call this function on a renderbuffer without HiZ. In that
174 * case, the function is a no-op.
176 * \return false if no resolve was needed
179 intel_renderbuffer_resolve_hiz(struct brw_context
*brw
,
180 struct intel_renderbuffer
*irb
);
183 * \brief Perform a depth resolve on the renderbuffer.
185 * It is safe to call this function on a renderbuffer without HiZ. In that
186 * case, the function is a no-op.
188 * \return false if no resolve was needed
191 intel_renderbuffer_resolve_depth(struct brw_context
*brw
,
192 struct intel_renderbuffer
*irb
);
194 void intel_renderbuffer_move_to_temp(struct brw_context
*brw
,
195 struct intel_renderbuffer
*irb
,
199 intel_quantize_num_samples(struct intel_screen
*intel
, unsigned num_samples
);
205 #endif /* INTEL_FBO_H */