From c074b86cbc664e973486caaca0817b9a1654be3d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 1 Sep 2008 13:10:00 -0600 Subject: gallium: added st_bind/release_teximage() functions --- src/mesa/state_tracker/st_texture.c | 92 +++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'src/mesa/state_tracker/st_texture.c') diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 73cebff33f..a23c7fe790 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -27,8 +27,11 @@ #include "st_context.h" #include "st_format.h" +#include "st_public.h" #include "st_texture.h" +#include "st_cb_fbo.h" #include "main/enums.h" +#include "main/teximage.h" #undef Elements /* fix re-defined macro warning */ @@ -351,3 +354,92 @@ st_texture_image_copy(struct pipe_context *pipe, screen->tex_surface_release(screen, &dst_surface); } } + + +/** Redirect rendering into stfb's surface to a texture image */ +int +st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex, + int target, int format, int level) +{ + GET_CURRENT_CONTEXT(ctx); + struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; + struct pipe_screen *screen = pipe->screen; + const GLuint unit = ctx->Texture.CurrentUnit; + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + struct st_texture_image *stImage; + struct st_renderbuffer *strb; + GLint face = 0, slice = 0; + + assert(surfIndex <= ST_SURFACE_DEPTH); + + strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer); + + if (strb->texture_save || strb->surface_save) { + /* Error! */ + return 0; + } + + if (target == ST_TEXTURE_2D) { + texObj = texUnit->Current2D; + texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, level); + stImage = st_texture_image(texImage); + } + else { + /* unsupported target */ + return 0; + } + + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + + /* save the renderbuffer's surface/texture info */ + pipe_texture_reference(&strb->texture_save, strb->texture); + pipe_surface_reference(&strb->surface_save, strb->surface); + + /* plug in new surface/texture info */ + pipe_texture_reference(&strb->texture, stImage->pt); + strb->surface = screen->get_tex_surface(screen, strb->texture, + face, level, slice, + (PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE)); + + st->dirty.st |= ST_NEW_FRAMEBUFFER; + + return 1; +} + + +/** Undo surface-to-texture binding */ +int +st_release_teximage(struct st_framebuffer *stfb, uint surfIndex, + int target, int format, int level) +{ + GET_CURRENT_CONTEXT(ctx); + struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; + struct st_renderbuffer *strb; + + assert(surfIndex <= ST_SURFACE_DEPTH); + + strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer); + + if (!strb->texture_save || !strb->surface_save) { + /* Error! */ + return 0; + } + + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + + /* free tex surface, restore original */ + pipe_surface_reference(&strb->surface, strb->surface_save); + pipe_texture_reference(&strb->texture, strb->texture_save); + + pipe_surface_reference(&strb->surface_save, NULL); + pipe_texture_reference(&strb->texture_save, NULL); + + st->dirty.st |= ST_NEW_FRAMEBUFFER; + + return 1; +} -- cgit v1.2.3 From 2c45b5575ad4396fa939ada1ccd977cad1b09f10 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 4 Sep 2008 11:15:19 +0900 Subject: mesa: Remove unused var. --- src/mesa/state_tracker/st_texture.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/state_tracker/st_texture.c') diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index a23c7fe790..fc0934367d 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -418,7 +418,6 @@ st_release_teximage(struct st_framebuffer *stfb, uint surfIndex, { GET_CURRENT_CONTEXT(ctx); struct st_context *st = ctx->st; - struct pipe_context *pipe = st->pipe; struct st_renderbuffer *strb; assert(surfIndex <= ST_SURFACE_DEPTH); -- cgit v1.2.3 From 69897223a8e0b9e5cd187a3c0e2249ba73b652c0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Sep 2008 10:31:50 -0600 Subject: gallium: remove the copyHeight hack for compresssed formats --- src/mesa/state_tracker/st_texture.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/mesa/state_tracker/st_texture.c') diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index fc0934367d..29b1634762 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -304,9 +304,6 @@ st_texture_image_copy(struct pipe_context *pipe, struct pipe_surface *dst_surface; GLuint i; - /* XXX this is a hack */ - const GLuint copyHeight = dst->compressed ? height / 4 : height; - for (i = 0; i < depth; i++) { GLuint srcLevel; @@ -348,7 +345,7 @@ st_texture_image_copy(struct pipe_context *pipe, 0, 0, /* destX, Y */ src_surface, 0, 0, /* srcX, Y */ - width, copyHeight); + width, height); screen->tex_surface_release(screen, &src_surface); screen->tex_surface_release(screen, &dst_surface); -- cgit v1.2.3