summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-04-05 07:51:01 -0600
committerBrian Paul <[email protected]>2011-04-05 07:51:01 -0600
commitdb0f9e701d59dcfcd3b50f4d245897692f27fec9 (patch)
tree7ac61092cbfc0a9a76ee66ca244fb804e9ddd611 /src/mesa/main
parente9375cd0e895ac2c3e7ff17f18da7a7f8cd3a82d (diff)
mesa: added _mesa_get_attachment_teximage() helpers
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/fbobject.c10
-rw-r--r--src/mesa/main/fbobject.h19
-rw-r--r--src/mesa/main/framebuffer.c4
-rw-r--r--src/mesa/main/teximage.c2
-rw-r--r--src/mesa/main/texrender.c5
5 files changed, 29 insertions, 11 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 4eab3e11911..f0065ad06a9 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -335,7 +335,7 @@ _mesa_set_texture_attachment(struct gl_context *ctx,
att->Zoffset = zoffset;
att->Complete = GL_FALSE;
- if (att->Texture->Image[att->CubeMapFace][att->TextureLevel]) {
+ if (_mesa_get_attachment_teximage(att)) {
ctx->Driver.RenderTexture(ctx, fb, att);
}
@@ -716,8 +716,8 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
/* get width, height, format of the renderbuffer/texture
*/
if (att->Type == GL_TEXTURE) {
- const struct gl_texture_image *texImg
- = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+ const struct gl_texture_image *texImg =
+ _mesa_get_attachment_teximage(att);
minWidth = MIN2(minWidth, texImg->Width);
maxWidth = MAX2(maxWidth, texImg->Width);
minHeight = MIN2(minHeight, texImg->Height);
@@ -1496,9 +1496,7 @@ check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb)
for (i = 0; i < BUFFER_COUNT; i++) {
struct gl_renderbuffer_attachment *att = fb->Attachment + i;
- struct gl_texture_object *texObj = att->Texture;
- if (texObj
- && texObj->Image[att->CubeMapFace][att->TextureLevel]) {
+ if (att->Texture && _mesa_get_attachment_teximage(att)) {
ctx->Driver.RenderTexture(ctx, fb, att);
}
}
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 0e1c096ab8d..7eb20050209 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -26,6 +26,7 @@
#ifndef FBOBJECT_H
#define FBOBJECT_H
+#include "compiler.h"
#include "glheader.h"
struct gl_context;
@@ -48,6 +49,24 @@ _mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum attachment);
+/** Return the texture image for a renderbuffer attachment */
+static INLINE struct gl_texture_image *
+_mesa_get_attachment_teximage(struct gl_renderbuffer_attachment *att)
+{
+ assert(att->Type == GL_TEXTURE);
+ return att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+}
+
+
+/** Return the (const) texture image for a renderbuffer attachment */
+static INLINE const struct gl_texture_image *
+_mesa_get_attachment_teximage_const(const struct gl_renderbuffer_attachment *att)
+{
+ assert(att->Type == GL_TEXTURE);
+ return att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+}
+
+
extern void
_mesa_remove_attachment(struct gl_context *ctx,
struct gl_renderbuffer_attachment *att);
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 430e013d017..4f0e6f57853 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -1061,12 +1061,12 @@ _mesa_print_framebuffer(const struct gl_framebuffer *fb)
for (i = 0; i < BUFFER_COUNT; i++) {
const struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
if (att->Type == GL_TEXTURE) {
- const struct gl_texture_image *texImage;
+ const struct gl_texture_image *texImage =
+ _mesa_get_attachment_teximage_const(att);
fprintf(stderr,
" %2d: Texture %u, level %u, face %u, slice %u, complete %d\n",
i, att->Texture->Name, att->TextureLevel, att->CubeMapFace,
att->Zoffset, att->Complete);
- texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
fprintf(stderr, " Size: %u x %u x %u Format %s\n",
texImage->Width, texImage->Height, texImage->Depth,
_mesa_get_format_name(texImage->TexFormat));
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 86927d3b661..6161eb41456 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2251,7 +2251,7 @@ check_rtt_cb(GLuint key, void *data, void *userData)
att->Texture == texObj &&
att->TextureLevel == level &&
att->CubeMapFace == face) {
- ASSERT(att->Texture->Image[att->CubeMapFace][att->TextureLevel]);
+ ASSERT(_mesa_get_attachment_teximage(att));
/* Tell driver about the new renderbuffer texture */
ctx->Driver.RenderTexture(ctx, ctx->DrawBuffer, att);
/* Mark fb status as indeterminate to force re-validation */
diff --git a/src/mesa/main/texrender.c b/src/mesa/main/texrender.c
index 8cec24c3e24..a7641a5f9a4 100644
--- a/src/mesa/main/texrender.c
+++ b/src/mesa/main/texrender.c
@@ -1,6 +1,7 @@
#include "context.h"
#include "colormac.h"
+#include "fbobject.h"
#include "macros.h"
#include "texfetch.h"
#include "teximage.h"
@@ -525,7 +526,7 @@ wrap_texture(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
* update the internal format info, etc.
*/
static void
-update_wrapper(struct gl_context *ctx, const struct gl_renderbuffer_attachment *att)
+update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
{
struct texture_renderbuffer *trb
= (struct texture_renderbuffer *) att->Renderbuffer;
@@ -533,7 +534,7 @@ update_wrapper(struct gl_context *ctx, const struct gl_renderbuffer_attachment *
(void) ctx;
ASSERT(trb);
- trb->TexImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+ trb->TexImage = _mesa_get_attachment_teximage(att);
ASSERT(trb->TexImage);
trb->Store = _mesa_get_texel_store_func(trb->TexImage->TexFormat);