1 /**************************************************************************
3 * Copyright 2008 Red Hat 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 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 **************************************************************************/
29 #include "main/imports.h"
30 #include "main/macros.h"
31 #include "main/mtypes.h"
32 #include "main/fbobject.h"
33 #include "main/framebuffer.h"
34 #include "main/renderbuffer.h"
35 #include "main/context.h"
36 #include "main/texformat.h"
37 #include "main/texrender.h"
39 #include "radeon_common.h"
41 static struct gl_framebuffer
*
42 radeon_new_framebuffer(GLcontext
*ctx
, GLuint name
)
44 return _mesa_new_framebuffer(ctx
, name
);
48 radeon_delete_renderbuffer(struct gl_renderbuffer
*rb
)
50 GET_CURRENT_CONTEXT(ctx
);
51 struct radeon_renderbuffer
*rrb
= radeon_renderbuffer(rb
);
56 radeon_bo_unref(rrb
->bo
);
64 radeon_resize_buffers(GLcontext
*ctx
, struct gl_framebuffer
*fb
,
65 GLuint width
, GLuint height
)
71 radeon_get_pointer(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
78 * Called via glRenderbufferStorageEXT() to set the format and allocate
79 * storage for a user-created renderbuffer.
82 radeon_alloc_renderbuffer_storage(GLcontext
* ctx
, struct gl_renderbuffer
*rb
,
83 GLenum internalFormat
,
84 GLuint width
, GLuint height
)
86 struct radeon_context
*radeon
= RADEON_CONTEXT(ctx
);
87 struct radeon_renderbuffer
*rrb
= radeon_renderbuffer(rb
);
88 GLboolean software_buffer
= GL_FALSE
;
91 ASSERT(rb
->Name
!= 0);
93 if (software_buffer
) {
94 return _mesa_soft_renderbuffer_storage(ctx
, rb
, internalFormat
,
104 static struct gl_renderbuffer
*
105 radeon_new_renderbuffer(GLcontext
* ctx
, GLuint name
)
107 struct radeon_renderbuffer
*rrb
;
109 rrb
= CALLOC_STRUCT(radeon_renderbuffer
);
113 _mesa_init_renderbuffer(&rrb
->base
, name
);
114 rrb
->base
.ClassID
= RADEON_RB_CLASS
;
116 rrb
->base
.Delete
= radeon_delete_renderbuffer
;
117 rrb
->base
.AllocStorage
= radeon_alloc_renderbuffer_storage
;
118 rrb
->base
.GetPointer
= radeon_get_pointer
;
124 radeon_bind_framebuffer(GLcontext
* ctx
, GLenum target
,
125 struct gl_framebuffer
*fb
, struct gl_framebuffer
*fbread
)
127 if (target
== GL_FRAMEBUFFER_EXT
|| target
== GL_DRAW_FRAMEBUFFER_EXT
) {
128 radeon_draw_buffer(ctx
, fb
);
131 /* don't need to do anything if target == GL_READ_FRAMEBUFFER_EXT */
136 radeon_framebuffer_renderbuffer(GLcontext
* ctx
,
137 struct gl_framebuffer
*fb
,
138 GLenum attachment
, struct gl_renderbuffer
*rb
)
143 _mesa_framebuffer_renderbuffer(ctx
, fb
, attachment
, rb
);
144 radeon_draw_buffer(ctx
, fb
);
147 static struct radeon_renderbuffer
*
148 radeon_wrap_texture(GLcontext
* ctx
, struct gl_texture_image
*texImage
)
153 radeon_render_texture(GLcontext
* ctx
,
154 struct gl_framebuffer
*fb
,
155 struct gl_renderbuffer_attachment
*att
)
161 radeon_finish_render_texture(GLcontext
* ctx
,
162 struct gl_renderbuffer_attachment
*att
)
167 radeon_validate_framebuffer(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
172 radeon_blit_framebuffer(GLcontext
*ctx
,
173 GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
174 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
,
175 GLbitfield mask
, GLenum filter
)
179 void radeon_fbo_init(struct radeon_context
*radeon
)
181 radeon
->glCtx
->Driver
.NewFramebuffer
= radeon_new_framebuffer
;
182 radeon
->glCtx
->Driver
.NewRenderbuffer
= radeon_new_renderbuffer
;
183 radeon
->glCtx
->Driver
.BindFramebuffer
= radeon_bind_framebuffer
;
184 radeon
->glCtx
->Driver
.FramebufferRenderbuffer
= radeon_framebuffer_renderbuffer
;
185 radeon
->glCtx
->Driver
.RenderTexture
= radeon_render_texture
;
186 radeon
->glCtx
->Driver
.FinishRenderTexture
= radeon_finish_render_texture
;
187 radeon
->glCtx
->Driver
.ResizeBuffers
= radeon_resize_buffers
;
188 radeon
->glCtx
->Driver
.ValidateFramebuffer
= radeon_validate_framebuffer
;
189 radeon
->glCtx
->Driver
.BlitFramebuffer
= radeon_blit_framebuffer
;