intel: Kill intel_mipmap_level::nr_images [v4]
[mesa.git] / src / mesa / drivers / dri / intel / intel_fbo.h
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_FBO_H
29 #define INTEL_FBO_H
30
31 #include <stdbool.h>
32 #include <assert.h>
33 #include "main/formats.h"
34 #include "intel_context.h"
35 #include "intel_screen.h"
36
37 struct intel_context;
38 struct intel_mipmap_tree;
39 struct intel_texture_image;
40
41 /**
42 * Intel renderbuffer, derived from gl_renderbuffer.
43 */
44 struct intel_renderbuffer
45 {
46 struct gl_renderbuffer Base;
47 struct intel_mipmap_tree *mt; /**< The renderbuffer storage. */
48 drm_intel_bo *map_bo;
49
50 void *map_buffer;
51 GLuint map_x, map_y, map_w, map_h;
52 GLbitfield map_mode;
53
54 /**
55 * \name Packed depth/stencil unwrappers
56 *
57 * If the intel_context is using separate stencil and this renderbuffer has
58 * a packed depth/stencil format, then wrapped_depth and wrapped_stencil
59 * are the real renderbuffers.
60 */
61 struct gl_renderbuffer *wrapped_depth;
62 struct gl_renderbuffer *wrapped_stencil;
63 /** \} */
64
65 GLuint draw_x, draw_y; /**< Offset of drawing within the region */
66 };
67
68
69 /**
70 * gl_renderbuffer is a base class which we subclass. The Class field
71 * is used for simple run-time type checking.
72 */
73 #define INTEL_RB_CLASS 0x12345678
74
75
76 /**
77 * Return a gl_renderbuffer ptr casted to intel_renderbuffer.
78 * NULL will be returned if the rb isn't really an intel_renderbuffer.
79 * This is determined by checking the ClassID.
80 */
81 static INLINE struct intel_renderbuffer *
82 intel_renderbuffer(struct gl_renderbuffer *rb)
83 {
84 struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb;
85 if (irb && irb->Base.ClassID == INTEL_RB_CLASS) {
86 /*_mesa_warning(NULL, "Returning non-intel Rb\n");*/
87 return irb;
88 }
89 else
90 return NULL;
91 }
92
93
94 /**
95 * \brief Return the framebuffer attachment specified by attIndex.
96 *
97 * If the framebuffer lacks the specified attachment, then return null.
98 *
99 * If the attached renderbuffer is a wrapper, then return wrapped
100 * renderbuffer.
101 */
102 static INLINE struct intel_renderbuffer *
103 intel_get_renderbuffer(struct gl_framebuffer *fb, gl_buffer_index attIndex)
104 {
105 struct gl_renderbuffer *rb;
106 struct intel_renderbuffer *irb;
107
108 assert((unsigned)attIndex < ARRAY_SIZE(fb->Attachment));
109
110 rb = fb->Attachment[attIndex].Renderbuffer;
111 if (!rb)
112 return NULL;
113
114 irb = intel_renderbuffer(rb);
115 if (!irb)
116 return NULL;
117
118 switch (attIndex) {
119 case BUFFER_DEPTH:
120 if (irb->wrapped_depth) {
121 irb = intel_renderbuffer(irb->wrapped_depth);
122 }
123 break;
124 case BUFFER_STENCIL:
125 if (irb->wrapped_stencil) {
126 irb = intel_renderbuffer(irb->wrapped_stencil);
127 }
128 break;
129 default:
130 break;
131 }
132
133 return irb;
134 }
135
136 bool
137 intel_framebuffer_has_hiz(struct gl_framebuffer *fb);
138
139 extern struct intel_renderbuffer *
140 intel_create_renderbuffer(gl_format format);
141
142 struct gl_renderbuffer*
143 intel_create_wrapped_renderbuffer(struct gl_context * ctx,
144 int width, int height,
145 gl_format format);
146
147 GLboolean
148 intel_alloc_renderbuffer_storage(struct gl_context * ctx,
149 struct gl_renderbuffer *rb,
150 GLenum internalFormat,
151 GLuint width, GLuint height);
152
153 extern void
154 intel_fbo_init(struct intel_context *intel);
155
156
157 extern void
158 intel_flip_renderbuffers(struct gl_framebuffer *fb);
159
160 void
161 intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb,
162 struct intel_texture_image *intel_image,
163 int zoffset);
164
165 uint32_t
166 intel_renderbuffer_tile_offsets(struct intel_renderbuffer *irb,
167 uint32_t *tile_x,
168 uint32_t *tile_y);
169
170 struct intel_region*
171 intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex);
172
173 #endif /* INTEL_FBO_H */