summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-09-13 01:05:08 +0200
committerMarek Olšák <[email protected]>2012-09-30 18:57:57 +0200
commitd37e6b15ad545106d48af5c8abb75d0e28895d43 (patch)
tree561f633c3083ee5df032124e1bb53f46c9d2befd
parentd1b929a13713e740c06e3abc8666fe56b513a41a (diff)
st/mesa: implement decompress_with_blit using gallium blit
Tested-by: Michel Dänzer <[email protected]> Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/gallium/auxiliary/util/u_surface.c30
-rw-r--r--src/gallium/auxiliary/util/u_surface.h11
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c70
3 files changed, 28 insertions, 83 deletions
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index fcfff148fe4..7fd6b36753b 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -66,11 +66,9 @@ u_surface_default_template(struct pipe_surface *surf,
* \return TRUE for success, FALSE if failure
*/
boolean
-util_create_rgba_surface(struct pipe_context *pipe,
- uint width, uint height,
- uint bind,
- struct pipe_resource **textureOut,
- struct pipe_surface **surfaceOut)
+util_create_rgba_texture(struct pipe_context *pipe,
+ uint width, uint height, uint bind,
+ struct pipe_resource **textureOut)
{
static const enum pipe_format rgbaFormats[] = {
PIPE_FORMAT_B8G8R8A8_UNORM,
@@ -113,33 +111,11 @@ util_create_rgba_surface(struct pipe_context *pipe,
/* create surface */
u_surface_default_template(&surf_templ, *textureOut, bind);
- /* create surface / view into texture */
- *surfaceOut = pipe->create_surface(pipe,
- *textureOut,
- &surf_templ);
- if (!*surfaceOut) {
- pipe_resource_reference(textureOut, NULL);
- return FALSE;
- }
-
return TRUE;
}
/**
- * Release the surface and texture from util_create_rgba_surface().
- */
-void
-util_destroy_rgba_surface(struct pipe_resource *texture,
- struct pipe_surface *surface)
-{
- pipe_surface_reference(&surface, NULL);
- pipe_resource_reference(&texture, NULL);
-}
-
-
-
-/**
* Fallback function for pipe->resource_copy_region().
* Note: (X,Y)=(0,0) is always the upper-left corner.
*/
diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h
index 1117b78da7a..6bcb63f3dad 100644
--- a/src/gallium/auxiliary/util/u_surface.h
+++ b/src/gallium/auxiliary/util/u_surface.h
@@ -44,16 +44,9 @@ u_surface_default_template(struct pipe_surface *view,
unsigned bind);
extern boolean
-util_create_rgba_surface(struct pipe_context *ctx,
+util_create_rgba_texture(struct pipe_context *ctx,
uint width, uint height, uint bind,
- struct pipe_resource **textureOut,
- struct pipe_surface **surfaceOut);
-
-
-extern void
-util_destroy_rgba_surface(struct pipe_resource *texture,
- struct pipe_surface *surface);
-
+ struct pipe_resource **textureOut);
extern void
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 5634a3e6e54..473ff3a94c5 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -575,61 +575,40 @@ decompress_with_blit(struct gl_context * ctx,
struct pipe_context *pipe = st->pipe;
struct st_texture_image *stImage = st_texture_image(texImage);
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
- struct pipe_sampler_view *src_view;
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
- struct pipe_surface *dst_surface;
struct pipe_resource *dst_texture;
struct pipe_transfer *tex_xfer;
- unsigned bind = (PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */
- PIPE_BIND_TRANSFER_READ);
+ struct pipe_blit_info blit;
+ unsigned bind = (PIPE_BIND_RENDER_TARGET | PIPE_BIND_TRANSFER_READ);
/* create temp / dest surface */
- if (!util_create_rgba_surface(pipe, width, height, bind,
- &dst_texture, &dst_surface)) {
- _mesa_problem(ctx, "util_create_rgba_surface() failed "
+ if (!util_create_rgba_texture(pipe, width, height, bind,
+ &dst_texture)) {
+ _mesa_problem(ctx, "util_create_rgba_texture() failed "
"in decompress_with_blit()");
return;
}
- /* Disable conditional rendering. */
- if (st->render_condition) {
- pipe->render_condition(pipe, NULL, 0);
- }
-
- /* Create sampler view that limits fetches to the source mipmap level */
- {
- struct pipe_sampler_view sv_temp;
-
- u_sampler_view_default_template(&sv_temp, stObj->pt, stObj->pt->format);
-
- sv_temp.format = util_format_linear(sv_temp.format);
- sv_temp.u.tex.first_level =
- sv_temp.u.tex.last_level = texImage->Level;
-
- src_view = pipe->create_sampler_view(pipe, stObj->pt, &sv_temp);
- if (!src_view) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
- return;
- }
- }
+ blit.src.resource = stObj->pt;
+ blit.src.level = texImage->Level;
+ blit.src.format = util_format_linear(stObj->pt->format);
+ blit.dst.resource = dst_texture;
+ blit.dst.level = 0;
+ blit.dst.format = dst_texture->format;
+ blit.src.box.x = blit.dst.box.x = 0;
+ blit.src.box.y = blit.dst.box.y = 0;
+ blit.src.box.z = 0; /* XXX compressed array textures? */
+ blit.dst.box.z = 0;
+ blit.src.box.width = blit.dst.box.width = width;
+ blit.src.box.height = blit.dst.box.height = height;
+ blit.src.box.depth = blit.dst.box.depth = 1;
+ blit.mask = PIPE_MASK_RGBA;
+ blit.filter = PIPE_TEX_FILTER_NEAREST;
+ blit.scissor_enable = FALSE;
/* blit/render/decompress */
- util_blit_pixels_tex(st->blit,
- src_view, /* pipe_resource (src) */
- 0, 0, /* src x0, y0 */
- width, height, /* src x1, y1 */
- dst_surface, /* pipe_surface (dst) */
- 0, 0, /* dst x0, y0 */
- width, height, /* dst x1, y1 */
- 0.0, /* z */
- PIPE_TEX_MIPFILTER_NEAREST);
-
- /* Restore conditional rendering state. */
- if (st->render_condition) {
- pipe->render_condition(pipe, st->render_condition,
- st->condition_mode);
- }
+ st->pipe->blit(st->pipe, &blit);
/* map the dst_surface so we can read from it */
tex_xfer = pipe_get_transfer(pipe,
@@ -691,10 +670,7 @@ end:
pipe->transfer_destroy(pipe, tex_xfer);
- /* destroy the temp / dest surface */
- util_destroy_rgba_surface(dst_texture, dst_surface);
-
- pipe_sampler_view_release(pipe, &src_view);
+ pipe_resource_reference(&dst_texture, NULL);
}