Merge commit 'origin/7.8'
[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 "main/formats.h"
32 #include "intel_screen.h"
33
34 struct intel_context;
35
36 /**
37 * Intel renderbuffer, derived from gl_renderbuffer.
38 */
39 struct intel_renderbuffer
40 {
41 struct gl_renderbuffer Base;
42 struct intel_region *region;
43 };
44
45
46 /**
47 * gl_renderbuffer is a base class which we subclass. The Class field
48 * is used for simple run-time type checking.
49 */
50 #define INTEL_RB_CLASS 0x12345678
51
52
53 /**
54 * Return a gl_renderbuffer ptr casted to intel_renderbuffer.
55 * NULL will be returned if the rb isn't really an intel_renderbuffer.
56 * This is determined by checking the ClassID.
57 */
58 static INLINE struct intel_renderbuffer *
59 intel_renderbuffer(struct gl_renderbuffer *rb)
60 {
61 struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb;
62 if (irb && irb->Base.ClassID == INTEL_RB_CLASS) {
63 /*_mesa_warning(NULL, "Returning non-intel Rb\n");*/
64 return irb;
65 }
66 else
67 return NULL;
68 }
69
70
71 /**
72 * Return a framebuffer's renderbuffer, named by a BUFFER_x index.
73 */
74 static INLINE struct intel_renderbuffer *
75 intel_get_renderbuffer(struct gl_framebuffer *fb, int attIndex)
76 {
77 if (attIndex >= 0)
78 return intel_renderbuffer(fb->Attachment[attIndex].Renderbuffer);
79 else
80 return NULL;
81 }
82
83
84 extern void
85 intel_renderbuffer_set_region(struct intel_renderbuffer *irb,
86 struct intel_region *region);
87
88
89 extern struct intel_renderbuffer *
90 intel_create_renderbuffer(gl_format format);
91
92
93 extern void
94 intel_fbo_init(struct intel_context *intel);
95
96
97 extern void
98 intel_flip_renderbuffers(struct gl_framebuffer *fb);
99
100
101 static INLINE struct intel_region *
102 intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex)
103 {
104 struct intel_renderbuffer *irb = intel_get_renderbuffer(fb, attIndex);
105 if (irb)
106 return irb->region;
107 else
108 return NULL;
109 }
110
111
112 #endif /* INTEL_FBO_H */