summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2013-05-10 11:51:01 -0700
committerEric Anholt <[email protected]>2013-05-17 13:04:05 -0700
commite98c39c109f9b38d6bb97e3890382fdf66c25176 (patch)
tree3f51aa191af6052243787b0b10e1a4d581a64583 /src/mesa
parent7b085d1bfa7630571e04a7d630765d3e5ed63e25 (diff)
mesa: Track the TexImage being rendered to in the gl_renderbuffer.
We keep having to pass the attachments around with our gl_renderbuffers because that's the only way to find what the gl_renderbuffer actually refers to. This is a step toward removing that (though drivers still need the Zoffset as well). Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c26
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.h3
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_fbo.c3
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_fbo.c17
-rw-r--r--src/mesa/main/fbobject.c8
-rw-r--r--src/mesa/main/fbobject.h19
-rw-r--r--src/mesa/main/framebuffer.c3
-rw-r--r--src/mesa/main/mtypes.h8
-rw-r--r--src/mesa/main/teximage.c2
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c6
-rw-r--r--src/mesa/swrast/s_texrender.c2
12 files changed, 34 insertions, 65 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 784e90718b4..bbe8579c553 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1328,7 +1328,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
/* _NEW_BUFFERS */
gl_format rb_format = _mesa_get_render_format(ctx, intel_rb_format(irb));
- if (irb->tex_image && !brw->has_surface_tile_offset) {
+ if (rb->TexImage && !brw->has_surface_tile_offset) {
intel_renderbuffer_tile_offsets(irb, &tile_x, &tile_y);
if (tile_x != 0 || tile_y != 0) {
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 6b30262892a..bf8e48d779b 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -572,8 +572,9 @@ intel_render_texture(struct gl_context * ctx,
struct gl_renderbuffer_attachment *att)
{
struct intel_context *intel = intel_context(ctx);
- struct gl_texture_image *image = _mesa_get_attachment_teximage(att);
- struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+ struct gl_texture_image *image = rb->TexImage;
struct intel_texture_image *intel_image = intel_texture_image(image);
struct intel_mipmap_tree *mt = intel_image->mt;
int layer;
@@ -602,12 +603,10 @@ intel_render_texture(struct gl_context * ctx,
return;
}
- irb->tex_image = image;
-
DBG("Begin render %s texture tex=%u w=%d h=%d refcount=%d\n",
_mesa_get_format_name(image->TexFormat),
att->Texture->Name, image->Width, image->Height,
- irb->Base.Base.RefCount);
+ rb->RefCount);
/* update drawing region, etc */
intel_draw_buffer(ctx);
@@ -623,13 +622,9 @@ intel_finish_render_texture(struct gl_context * ctx,
{
struct intel_context *intel = intel_context(ctx);
struct gl_renderbuffer *rb = att->Renderbuffer;
- struct intel_renderbuffer *irb = intel_renderbuffer(rb);
DBG("Finish render %s texture\n", _mesa_get_format_name(rb->Format));
- if (irb)
- irb->tex_image = NULL;
-
/* Since we've (probably) rendered to the texture and will (likely) use
* it in the texture domain later on in this batchbuffer, flush the
* batch. Once again, we wish for a domain tracker in libdrm to cover
@@ -734,10 +729,7 @@ intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
}
if (fb->Attachment[i].Type == GL_TEXTURE) {
- const struct gl_texture_image *img =
- _mesa_get_attachment_teximage_const(&fb->Attachment[i]);
-
- if (img->Border) {
+ if (rb->TexImage->Border) {
fbo_incomplete(fb, "FBO incomplete: texture with border\n");
continue;
}
@@ -945,14 +937,14 @@ intel_renderbuffer_move_to_temp(struct intel_context *intel,
struct intel_renderbuffer *irb,
bool invalidate)
{
- struct intel_texture_image *intel_image =
- intel_texture_image(irb->tex_image);
+ struct gl_renderbuffer *rb =&irb->Base.Base;
+ struct intel_texture_image *intel_image = intel_texture_image(rb->TexImage);
struct intel_mipmap_tree *new_mt;
int width, height, depth;
- intel_miptree_get_dimensions_for_image(irb->tex_image, &width, &height, &depth);
+ intel_miptree_get_dimensions_for_image(rb->TexImage, &width, &height, &depth);
- new_mt = intel_miptree_create(intel, irb->tex_image->TexObject->Target,
+ new_mt = intel_miptree_create(intel, rb->TexImage->TexObject->Target,
intel_image->base.Base.TexFormat,
intel_image->base.Base.Level,
intel_image->base.Base.Level,
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h
index 0e0806b63bb..aa52b979f88 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.h
+++ b/src/mesa/drivers/dri/intel/intel_fbo.h
@@ -52,9 +52,6 @@ struct intel_renderbuffer
struct intel_mipmap_tree *mt; /**< The renderbuffer storage. */
drm_intel_bo *map_bo;
- /* Current texture image this renderbuffer is attached to. */
- struct gl_texture_image *tex_image;
-
/**
* \name Miptree view
* \{
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
index a692051c082..f997ac888f9 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
@@ -252,8 +252,7 @@ nouveau_render_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
struct gl_renderbuffer *rb = att->Renderbuffer;
- struct gl_texture_image *ti =
- att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+ struct gl_texture_image *ti = rb->TexImage;
/* Update the renderbuffer fields from the texture. */
nouveau_surface_ref(&to_nouveau_teximage(ti)->surface,
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index c43f527d222..1fdcf056562 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -787,9 +787,9 @@ radeon_render_texture(struct gl_context * ctx,
struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
- struct gl_texture_image *newImage
- = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
- struct radeon_renderbuffer *rrb = radeon_renderbuffer(att->Renderbuffer);
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ struct gl_texture_image *newImage = rb->TexImage;
+ struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
radeon_texture_image *radeon_image;
GLuint imageOffset;
@@ -818,7 +818,7 @@ radeon_render_texture(struct gl_context * ctx,
DBG("Begin render texture tid %lx tex=%u w=%d h=%d refcount=%d\n",
_glthread_GetID(),
att->Texture->Name, newImage->Width, newImage->Height,
- rrb->base.Base.RefCount);
+ rb->RefCount);
/* point the renderbufer's region to the texture image region */
if (rrb->bo != radeon_image->mt->bo) {
@@ -853,11 +853,8 @@ static void
radeon_finish_render_texture(struct gl_context * ctx,
struct gl_renderbuffer_attachment *att)
{
- struct gl_texture_object *tex_obj = att->Texture;
- radeon_texture_image *radeon_image = NULL;
-
- if (tex_obj)
- radeon_image = (radeon_texture_image *)_mesa_get_attachment_teximage(att);
+ struct gl_texture_image *image = att->Renderbuffer->TexImage;
+ radeon_texture_image *radeon_image = (radeon_texture_image *)image;
if (radeon_image)
radeon_image->used_as_render_target = GL_FALSE;
@@ -883,7 +880,7 @@ radeon_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
}
if (att->Type == GL_TEXTURE) {
- mesa_format = att->Texture->Image[att->CubeMapFace][att->TextureLevel]->TexFormat;
+ mesa_format = att->Renderbuffer->TexImage->TexFormat;
} else {
/* All renderbuffer formats are renderable, but not sampable */
continue;
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f00d11ab9f1..070fb8c5356 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -363,7 +363,7 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
struct gl_texture_image *texImage;
struct gl_renderbuffer *rb;
- texImage = _mesa_get_attachment_teximage(att);
+ texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
if (!texImage)
return;
@@ -390,6 +390,7 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
rb->Width = texImage->Width2;
rb->Height = texImage->Height2;
rb->NumSamples = texImage->NumSamples;
+ rb->TexImage = texImage;
ctx->Driver.RenderTexture(ctx, fb, att);
}
@@ -889,8 +890,7 @@ _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 =
- _mesa_get_attachment_teximage(att);
+ const struct gl_texture_image *texImg = att->Renderbuffer->TexImage;
minWidth = MIN2(minWidth, texImg->Width);
maxWidth = MAX2(maxWidth, texImg->Width);
minHeight = MIN2(minHeight, texImg->Height);
@@ -1862,7 +1862,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;
- if (att->Texture && _mesa_get_attachment_teximage(att)) {
+ if (att->Texture && att->Renderbuffer->TexImage) {
ctx->Driver.RenderTexture(ctx, fb, att);
}
}
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index bfab6e17da7..dfd795a3a52 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -71,25 +71,6 @@ extern struct gl_renderbuffer_attachment *
_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 911bb927a60..af3c5952583 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -962,8 +962,7 @@ _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 =
- _mesa_get_attachment_teximage_const(att);
+ const struct gl_texture_image *texImage = att->Renderbuffer->TexImage;
fprintf(stderr,
" %2d: Texture %u, level %u, face %u, slice %u, complete %d\n",
i, att->Texture->Name, att->TextureLevel, att->CubeMapFace,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5dfe911d060..244bee2e670 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2586,6 +2586,14 @@ struct gl_renderbuffer
GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
GL_STENCIL_INDEX. */
gl_format Format; /**< The actual renderbuffer memory format */
+ /**
+ * Pointer to the texture image if this renderbuffer wraps a texture,
+ * otherwise NULL.
+ *
+ * Note that the reference on the gl_texture_object containing this
+ * TexImage is held by the gl_renderbuffer_attachment.
+ */
+ struct gl_texture_image *TexImage;
/** Delete this renderbuffer */
void (*Delete)(struct gl_context *ctx, struct gl_renderbuffer *rb);
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 26fa4c38190..d07f6e9dc9e 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2759,8 +2759,8 @@ check_rtt_cb(GLuint key, void *data, void *userData)
att->Texture == texObj &&
att->TextureLevel == level &&
att->CubeMapFace == face) {
- ASSERT(_mesa_get_attachment_teximage(att));
_mesa_update_texture_renderbuffer(ctx, ctx->DrawBuffer, att);
+ ASSERT(att->Renderbuffer->TexImage);
/* Mark fb status as indeterminate to force re-validation */
fb->_Status = 0;
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index aa245d3fc0e..db4728b3237 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -394,7 +394,6 @@ st_render_texture(struct gl_context *ctx,
struct st_renderbuffer *strb = st_renderbuffer(rb);
struct pipe_resource *pt;
struct st_texture_object *stObj;
- const struct gl_texture_image *texImage;
struct pipe_surface surf_tmpl;
if (!st_finalize_texture(ctx, pipe, att->Texture))
@@ -403,9 +402,6 @@ st_render_texture(struct gl_context *ctx,
pt = st_get_texobj_resource(att->Texture);
assert(pt);
- /* get pointer to texture image we're rendeing to */
- texImage = _mesa_get_attachment_teximage(att);
-
/* get the texture for the texture object */
stObj = st_texture_object(att->Texture);
@@ -503,7 +499,7 @@ st_validate_attachment(struct gl_context *ctx,
return GL_FALSE;
format = stObj->pt->format;
- texFormat = _mesa_get_attachment_teximage_const(att)->TexFormat;
+ texFormat = att->Renderbuffer->TexImage->TexFormat;
/* If the encoding is sRGB and sRGB rendering cannot be enabled,
* check for linear format support instead.
diff --git a/src/mesa/swrast/s_texrender.c b/src/mesa/swrast/s_texrender.c
index 00b3ca55ac0..643f2bc2c24 100644
--- a/src/mesa/swrast/s_texrender.c
+++ b/src/mesa/swrast/s_texrender.c
@@ -38,7 +38,7 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
(void) ctx;
- swImage = swrast_texture_image(_mesa_get_attachment_teximage(att));
+ swImage = swrast_texture_image(rb->TexImage);
assert(swImage);
format = swImage->Base.TexFormat;