2 #include "main/context.h"
3 #include "main/colormac.h"
4 #include "main/fbobject.h"
5 #include "main/macros.h"
6 #include "main/teximage.h"
7 #include "main/renderbuffer.h"
8 #include "swrast/swrast.h"
9 #include "swrast/s_context.h"
10 #include "swrast/s_texfetch.h"
14 * Render-to-texture code for GL_EXT_framebuffer_object
19 delete_texture_wrapper(struct gl_context
*ctx
, struct gl_renderbuffer
*rb
)
21 ASSERT(rb
->RefCount
== 0);
26 * Update the renderbuffer wrapper for rendering to a texture.
27 * For example, update the width, height of the RB based on the texture size,
28 * update the internal format info, etc.
31 update_wrapper(struct gl_context
*ctx
, struct gl_renderbuffer_attachment
*att
)
33 struct gl_renderbuffer
*rb
= att
->Renderbuffer
;
34 struct swrast_renderbuffer
*srb
= swrast_renderbuffer(rb
);
35 struct swrast_texture_image
*swImage
;
41 swImage
= swrast_texture_image(rb
->TexImage
);
44 format
= swImage
->Base
.TexFormat
;
46 if (att
->Texture
->Target
== GL_TEXTURE_1D_ARRAY_EXT
) {
50 zOffset
= att
->Zoffset
;
53 /* Want to store linear values, not sRGB */
54 rb
->Format
= _mesa_get_srgb_format_linear(format
);
56 srb
->Buffer
= swImage
->ImageSlices
[zOffset
];
62 * Called when rendering to a texture image begins, or when changing
63 * the dest mipmap level, cube face, etc.
64 * This is a fallback routine for software render-to-texture.
66 * Called via the glRenderbufferTexture1D/2D/3D() functions
67 * and elsewhere (such as glTexImage2D).
69 * The image we're rendering into is
70 * att->Texture->Image[att->CubeMapFace][att->TextureLevel];
71 * It'll never be NULL.
73 * \param fb the framebuffer object the texture is being bound to
74 * \param att the fb attachment point of the texture
76 * \sa _mesa_framebuffer_renderbuffer
79 _swrast_render_texture(struct gl_context
*ctx
,
80 struct gl_framebuffer
*fb
,
81 struct gl_renderbuffer_attachment
*att
)
83 struct gl_renderbuffer
*rb
= att
->Renderbuffer
;
86 /* plug in our texture_renderbuffer-specific functions */
87 rb
->Delete
= delete_texture_wrapper
;
89 update_wrapper(ctx
, att
);
94 _swrast_finish_render_texture(struct gl_context
*ctx
,
95 struct gl_renderbuffer_attachment
*att
)
98 /* The renderbuffer texture wrapper will get deleted by the
99 * normal mechanism for deleting renderbuffers.