summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2010-05-21 20:02:22 +0200
committerRoland Scheidegger <[email protected]>2010-05-21 20:02:22 +0200
commit3293bcdc80cdfa20a2381aae2b94505bdf95d857 (patch)
tree16ab1ae66010f6d8b1325dbfa9006126a8e95771 /src/gallium/auxiliary
parent8504c5d931e47765a15fdaec2df2cb6502a1bd5c (diff)
parentce65caba846b03b5ef4144e311b85cfd48ab9bbb (diff)
Merge branch 'gallium-msaa'
Conflicts: src/mesa/state_tracker/st_gen_mipmap.c src/mesa/state_tracker/st_texture.c
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c11
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h2
-rw-r--r--src/gallium/auxiliary/util/u_blit.c130
-rw-r--r--src/gallium/auxiliary/util/u_blit.h10
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c82
-rw-r--r--src/gallium/auxiliary/util/u_caps.c1
-rw-r--r--src/gallium/auxiliary/util/u_clear.h23
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c2
-rw-r--r--src/gallium/auxiliary/util/u_surface.c76
-rw-r--r--src/gallium/auxiliary/util/u_surface.h41
10 files changed, 176 insertions, 202 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 75bf8d5d407..20a8612dcae 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -99,6 +99,7 @@ struct cso_context {
struct pipe_framebuffer_state fb, fb_saved;
struct pipe_viewport_state vp, vp_saved;
struct pipe_blend_color blend_color;
+ unsigned sample_mask;
struct pipe_stencil_ref stencil_ref, stencil_ref_saved;
};
@@ -953,6 +954,16 @@ enum pipe_error cso_set_blend_color(struct cso_context *ctx,
return PIPE_OK;
}
+enum pipe_error cso_set_sample_mask(struct cso_context *ctx,
+ unsigned sample_mask)
+{
+ if (ctx->sample_mask != sample_mask) {
+ ctx->sample_mask = sample_mask;
+ ctx->pipe->set_sample_mask(ctx->pipe, sample_mask);
+ }
+ return PIPE_OK;
+}
+
enum pipe_error cso_set_stencil_ref(struct cso_context *ctx,
const struct pipe_stencil_ref *sr)
{
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index d6bcb1fe8f7..f0b07f73765 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -159,6 +159,8 @@ void cso_restore_viewport(struct cso_context *cso);
enum pipe_error cso_set_blend_color(struct cso_context *cso,
const struct pipe_blend_color *bc);
+enum pipe_error cso_set_sample_mask(struct cso_context *cso,
+ unsigned stencil_mask);
enum pipe_error cso_set_stencil_ref(struct cso_context *cso,
const struct pipe_stencil_ref *sr);
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index f6f6e481d94..d4fbd658f40 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -190,7 +190,6 @@ get_next_slot( struct blit_state *ctx )
return ctx->vbuf_slot++ * sizeof ctx->vertices;
}
-
@@ -277,10 +276,11 @@ regions_overlap(int srcX0, int srcY0,
*/
void
util_blit_pixels_writemask(struct blit_state *ctx,
- struct pipe_surface *src,
- struct pipe_sampler_view *src_sampler_view,
+ struct pipe_resource *src_tex,
+ struct pipe_subresource srcsub,
int srcX0, int srcY0,
int srcX1, int srcY1,
+ int srcZ0,
struct pipe_surface *dst,
int dstX0, int dstY0,
int dstX1, int dstY1,
@@ -290,6 +290,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_sampler_view *sampler_view = NULL;
+ struct pipe_sampler_view sv_templ;
struct pipe_framebuffer_state fb;
const int srcW = abs(srcX1 - srcX0);
const int srcH = abs(srcY1 - srcY0);
@@ -300,13 +301,13 @@ util_blit_pixels_writemask(struct blit_state *ctx,
assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
filter == PIPE_TEX_MIPFILTER_LINEAR);
- assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D,
- PIPE_BIND_SAMPLER_VIEW, 0));
- assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_BIND_RENDER_TARGET, 0));
+ assert(srcsub.level <= src_tex->last_level);
/* do the regions overlap? */
- overlap = util_same_surface(src, dst) &&
+ overlap = src_tex == dst->texture &&
+ dst->face == srcsub.face &&
+ dst->level == srcsub.level &&
+ dst->zslice == srcZ0 &&
regions_overlap(srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1);
@@ -315,8 +316,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
* no overlapping.
* Filter mode should not matter since there's no stretching.
*/
- if (pipe->surface_copy &&
- dst->format == src->format &&
+ if (dst->format == src_tex->format &&
srcX0 < srcX1 &&
dstX0 < dstX1 &&
srcY0 < srcY1 &&
@@ -324,29 +324,36 @@ util_blit_pixels_writemask(struct blit_state *ctx,
(dstX1 - dstX0) == (srcX1 - srcX0) &&
(dstY1 - dstY0) == (srcY1 - srcY0) &&
!overlap) {
- pipe->surface_copy(pipe,
- dst, dstX0, dstY0, /* dest */
- src, srcX0, srcY0, /* src */
- srcW, srcH); /* size */
+ struct pipe_subresource subdst;
+ subdst.face = dst->face;
+ subdst.level = dst->level;
+ pipe->resource_copy_region(pipe,
+ dst->texture, subdst,
+ dstX0, dstY0, dst->zslice,/* dest */
+ src_tex, srcsub,
+ srcX0, srcY0, srcZ0,/* src */
+ srcW, srcH); /* size */
return;
}
-
- assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_BIND_RENDER_TARGET, 0));
+
/* Create a temporary texture when src and dest alias or when src
- * is anything other than a single-level 2d texture.
+ * is anything other than a 2d texture.
+ * XXX should just use appropriate shader to access 1d / 3d slice / cube face,
+ * much like the u_blitter code does (should be pretty trivial).
*
* This can still be improved upon.
*/
- if (util_same_surface(src, dst) ||
- src->texture->target != PIPE_TEXTURE_2D ||
- src->texture->last_level != 0)
+ if ((src_tex == dst->texture &&
+ dst->face == srcsub.face &&
+ dst->level == srcsub.level &&
+ dst->zslice == srcZ0) ||
+ src_tex->target != PIPE_TEXTURE_2D)
{
struct pipe_resource texTemp;
struct pipe_resource *tex;
struct pipe_sampler_view sv_templ;
- struct pipe_surface *texSurf;
+ struct pipe_subresource texsub;
const int srcLeft = MIN2(srcX0, srcX1);
const int srcTop = MIN2(srcY0, srcY1);
@@ -367,7 +374,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
/* create temp texture */
memset(&texTemp, 0, sizeof(texTemp));
texTemp.target = PIPE_TEXTURE_2D;
- texTemp.format = src->format;
+ texTemp.format = src_tex->format;
texTemp.last_level = 0;
texTemp.width0 = srcW;
texTemp.height0 = srcH;
@@ -378,49 +385,50 @@ util_blit_pixels_writemask(struct blit_state *ctx,
if (!tex)
return;
- u_sampler_view_default_template(&sv_templ, tex, tex->format);
-
- sampler_view = ctx->pipe->create_sampler_view(ctx->pipe, tex, &sv_templ);
- if (!sampler_view) {
- pipe_resource_reference(&tex, NULL);
- return;
- }
-
- texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0,
- PIPE_BIND_BLIT_DESTINATION);
-
+ texsub.face = 0;
+ texsub.level = 0;
/* load temp texture */
- if (pipe->surface_copy) {
- pipe->surface_copy(pipe,
- texSurf, 0, 0, /* dest */
- src, srcLeft, srcTop, /* src */
- srcW, srcH); /* size */
- } else {
- util_surface_copy(pipe, FALSE,
- texSurf, 0, 0, /* dest */
- src, srcLeft, srcTop, /* src */
- srcW, srcH); /* size */
- }
+ pipe->resource_copy_region(pipe,
+ tex, texsub, 0, 0, 0, /* dest */
+ src_tex, srcsub, srcLeft, srcTop, srcZ0, /* src */
+ srcW, srcH); /* size */
- /* free the surface, update the texture if necessary.
- */
- pipe_surface_reference(&texSurf, NULL);
s0 = 0.0f;
s1 = 1.0f;
t0 = 0.0f;
t1 = 1.0f;
+ u_sampler_view_default_template(&sv_templ, tex, tex->format);
+ sampler_view = pipe->create_sampler_view(pipe, tex, &sv_templ);
+
+ if (!sampler_view) {
+ pipe_resource_reference(&tex, NULL);
+ return;
+ }
pipe_resource_reference(&tex, NULL);
}
else {
- pipe_sampler_view_reference(&sampler_view, src_sampler_view);
- s0 = srcX0 / (float)src->texture->width0;
- s1 = srcX1 / (float)src->texture->width0;
- t0 = srcY0 / (float)src->texture->height0;
- t1 = srcY1 / (float)src->texture->height0;
+ u_sampler_view_default_template(&sv_templ, src_tex, src_tex->format);
+ sv_templ.first_level = sv_templ.last_level = srcsub.level;
+ sampler_view = pipe->create_sampler_view(pipe, src_tex, &sv_templ);
+
+ if (!sampler_view) {
+ return;
+ }
+
+ s0 = srcX0 / (float)(u_minify(sampler_view->texture->width0, srcsub.level));
+ s1 = srcX1 / (float)(u_minify(sampler_view->texture->width0, srcsub.level));
+ t0 = srcY0 / (float)(u_minify(sampler_view->texture->height0, srcsub.level));
+ t1 = srcY1 / (float)(u_minify(sampler_view->texture->height0, srcsub.level));
}
-
+
+ assert(screen->is_format_supported(screen, sampler_view->format, PIPE_TEXTURE_2D,
+ sampler_view->texture->nr_samples,
+ PIPE_BIND_SAMPLER_VIEW, 0));
+ assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
+ dst->texture->nr_samples,
+ PIPE_BIND_RENDER_TARGET, 0));
/* save state (restored below) */
cso_save_blend(ctx->cso);
@@ -445,6 +453,9 @@ util_blit_pixels_writemask(struct blit_state *ctx,
/* sampler */
ctx->sampler.min_img_filter = filter;
ctx->sampler.mag_img_filter = filter;
+ /* we've limited this already with the sampler view but you never know... */
+ ctx->sampler.min_lod = srcsub.level;
+ ctx->sampler.max_lod = srcsub.level;
cso_single_sampler(ctx->cso, 0, &ctx->sampler);
cso_single_sampler_done(ctx->cso);
@@ -513,18 +524,21 @@ util_blit_pixels_writemask(struct blit_state *ctx,
void
util_blit_pixels(struct blit_state *ctx,
- struct pipe_surface *src,
- struct pipe_sampler_view *src_sampler_view,
+ struct pipe_resource *src_tex,
+ struct pipe_subresource srcsub,
int srcX0, int srcY0,
int srcX1, int srcY1,
+ int srcZ,
struct pipe_surface *dst,
int dstX0, int dstY0,
int dstX1, int dstY1,
float z, uint filter )
{
- util_blit_pixels_writemask( ctx, src, src_sampler_view,
+ util_blit_pixels_writemask( ctx, src_tex,
+ srcsub,
srcX0, srcY0,
srcX1, srcY1,
+ srcZ,
dst,
dstX0, dstY0,
dstX1, dstY1,
@@ -546,7 +560,6 @@ void util_blit_flush( struct blit_state *ctx )
/**
* Copy pixel block from src texture to dst surface.
- * Overlapping regions are acceptable.
*
* XXX Should support selection of level.
* XXX need some control over blitting Z and/or stencil.
@@ -580,6 +593,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format,
PIPE_TEXTURE_2D,
+ dst->texture->nr_samples,
PIPE_BIND_RENDER_TARGET,
0));
diff --git a/src/gallium/auxiliary/util/u_blit.h b/src/gallium/auxiliary/util/u_blit.h
index 464ff9aaced..ef95134f324 100644
--- a/src/gallium/auxiliary/util/u_blit.h
+++ b/src/gallium/auxiliary/util/u_blit.h
@@ -52,10 +52,11 @@ util_destroy_blit(struct blit_state *ctx);
extern void
util_blit_pixels(struct blit_state *ctx,
- struct pipe_surface *src,
- struct pipe_sampler_view *src_sampler_view,
+ struct pipe_resource *src_tex,
+ struct pipe_subresource srcsub,
int srcX0, int srcY0,
int srcX1, int srcY1,
+ int srcZ0,
struct pipe_surface *dst,
int dstX0, int dstY0,
int dstX1, int dstY1,
@@ -63,10 +64,11 @@ util_blit_pixels(struct blit_state *ctx,
void
util_blit_pixels_writemask(struct blit_state *ctx,
- struct pipe_surface *src,
- struct pipe_sampler_view *src_sampler_view,
+ struct pipe_resource *src_tex,
+ struct pipe_subresource srcsub,
int srcX0, int srcY0,
int srcX1, int srcY1,
+ int srcZ0,
struct pipe_surface *dst,
int dstX0, int dstY0,
int dstX1, int dstY1,
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 3a7c4db6f34..e0bd89154cb 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -26,8 +26,8 @@
/**
* @file
- * Blitter utility to facilitate acceleration of the clear, surface_copy,
- * and surface_fill functions.
+ * Blitter utility to facilitate acceleration of the clear, resource_copy_region,
+ * and resource_fill_region functions.
*
* @author Marek Olšák
*/
@@ -709,53 +709,6 @@ static void util_blitter_do_copy(struct blitter_context *blitter,
}
-static void util_blitter_overlap_copy(struct blitter_context *blitter,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
- struct pipe_context *pipe = ctx->pipe;
- struct pipe_screen *screen = pipe->screen;
-
- struct pipe_resource texTemp;
- struct pipe_resource *texture;
- struct pipe_surface *tex_surf;
-
- /* check whether the states are properly saved */
- blitter_check_saved_CSOs(ctx);
-
- memset(&texTemp, 0, sizeof(texTemp));
- texTemp.target = PIPE_TEXTURE_2D;
- texTemp.format = dst->texture->format; /* XXX verify supported by driver! */
- texTemp.last_level = 0;
- texTemp.width0 = width;
- texTemp.height0 = height;
- texTemp.depth0 = 1;
-
- texture = screen->resource_create(screen, &texTemp);
- if (!texture)
- return;
-
- tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0,
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION);
-
- /* blit from the src to the temp */
- util_blitter_do_copy(blitter, tex_surf, 0, 0,
- src, srcx, srcy,
- width, height,
- FALSE);
- util_blitter_do_copy(blitter, dst, dstx, dsty,
- tex_surf, 0, 0,
- width, height,
- FALSE);
- pipe_surface_reference(&tex_surf, NULL);
- pipe_resource_reference(&texture, NULL);
- blitter_restore_CSOs(ctx);
-}
void util_blitter_copy(struct blitter_context *blitter,
struct pipe_surface *dst,
@@ -777,14 +730,10 @@ void util_blitter_copy(struct blitter_context *blitter,
return;
if (dst->texture == src->texture) {
- if (is_overlap(srcx, srcx + width, srcy, srcy + height,
- dstx, dstx + width, dsty, dsty + height)) {
- util_blitter_overlap_copy(blitter, dst, dstx, dsty, src, srcx, srcy,
- width, height);
- return;
- }
+ assert(!is_overlap(srcx, srcx + width, srcy, srcy + height,
+ dstx, dstx + width, dsty, dsty + height));
}
-
+
is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
dst_tex_usage = is_depth || is_stencil ? PIPE_BIND_DEPTH_STENCIL :
@@ -794,11 +743,17 @@ void util_blitter_copy(struct blitter_context *blitter,
/* (assuming copying a stencil buffer is not possible) */
if ((!ignore_stencil && is_stencil) ||
!screen->is_format_supported(screen, dst->format, dst->texture->target,
- dst_tex_usage, 0) ||
+ dst->texture->nr_samples, dst_tex_usage, 0) ||
!screen->is_format_supported(screen, src->format, src->texture->target,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
- util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy,
- width, height);
+ src->texture->nr_samples, PIPE_BIND_SAMPLER_VIEW, 0)) {
+ struct pipe_subresource subdst, subsrc;
+ subdst.face = dst->face;
+ subdst.level = dst->level;
+ subsrc.face = src->face;
+ subsrc.level = src->level;
+ util_resource_copy_region(pipe, dst->texture, subdst, dstx, dsty, dst->zslice,
+ src->texture, subsrc, srcx, srcy, src->zslice,
+ width, height);
return;
}
@@ -833,8 +788,13 @@ void util_blitter_fill(struct blitter_context *blitter,
/* check if we can render to the surface */
if (util_format_is_depth_or_stencil(dst->format) || /* unlikely, but you never know */
!screen->is_format_supported(screen, dst->format, dst->texture->target,
+ dst->texture->nr_samples,
PIPE_BIND_RENDER_TARGET, 0)) {
- util_surface_fill(pipe, dst, dstx, dsty, width, height, value);
+ struct pipe_subresource subdst;
+ subdst.face = dst->face;
+ subdst.level = dst->level;
+ util_resource_fill_region(pipe, dst->texture, subdst, dstx, dsty,
+ dst->zslice, width, height, value);
return;
}
diff --git a/src/gallium/auxiliary/util/u_caps.c b/src/gallium/auxiliary/util/u_caps.c
index c7c1e830e01..294ee37033d 100644
--- a/src/gallium/auxiliary/util/u_caps.c
+++ b/src/gallium/auxiliary/util/u_caps.c
@@ -68,6 +68,7 @@ util_check_caps_out(struct pipe_screen *screen, const unsigned *list, int *out)
if (!screen->is_format_supported(screen,
list[i++],
PIPE_TEXTURE_2D,
+ 0,
PIPE_BIND_SAMPLER_VIEW,
0)) {
*out = i - 2;
diff --git a/src/gallium/auxiliary/util/u_clear.h b/src/gallium/auxiliary/util/u_clear.h
index 40da2d75a72..31f7fb2169a 100644
--- a/src/gallium/auxiliary/util/u_clear.h
+++ b/src/gallium/auxiliary/util/u_clear.h
@@ -47,25 +47,24 @@ util_clear(struct pipe_context *pipe,
{
if (buffers & PIPE_CLEAR_COLOR) {
struct pipe_surface *ps = framebuffer->cbufs[0];
+ struct pipe_subresource subdst;
union util_color uc;
+ subdst.face = ps->face;
+ subdst.level = ps->level;
util_pack_color(rgba, ps->format, &uc);
- if (pipe->surface_fill) {
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
- } else {
- util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
- }
+ pipe->resource_fill_region(pipe, ps->texture, subdst, 0, 0, ps->zslice,
+ ps->width, ps->height, uc.ui);
}
if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
struct pipe_surface *ps = framebuffer->zsbuf;
+ struct pipe_subresource subdst;
- if (pipe->surface_fill) {
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
- util_pack_z_stencil(ps->format, depth, stencil));
- } else {
- util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
- util_pack_z_stencil(ps->format, depth, stencil));
- }
+ subdst.face = ps->face;
+ subdst.level = ps->level;
+ pipe->resource_fill_region(pipe, ps->texture, subdst, 0, 0, ps->zslice,
+ ps->width, ps->height,
+ util_pack_z_stencil(ps->format, depth, stencil));
}
}
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 1553e08d6ce..d19267be72f 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -1493,7 +1493,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
/* check if we can render in the texture's format */
if (!screen->is_format_supported(screen, psv->format, PIPE_TEXTURE_2D,
- PIPE_BIND_RENDER_TARGET, 0)) {
+ pt->nr_samples, PIPE_BIND_RENDER_TARGET, 0)) {
fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel);
return;
}
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index 377c48c0266..9adf22c471e 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -69,7 +69,7 @@ util_create_rgba_surface(struct pipe_screen *screen,
/* Choose surface format */
for (i = 0; rgbaFormats[i]; i++) {
if (screen->is_format_supported(screen, rgbaFormats[i],
- target, bind, 0)) {
+ target, 0, bind, 0)) {
format = rgbaFormats[i];
break;
}
@@ -119,44 +119,44 @@ util_destroy_rgba_surface(struct pipe_resource *texture,
/**
- * Fallback function for pipe->surface_copy().
+ * Fallback function for pipe->resource_copy_region().
* Note: (X,Y)=(0,0) is always the upper-left corner.
- * if do_flip, flip the image vertically on its way from src rect to dst rect.
*/
void
-util_surface_copy(struct pipe_context *pipe,
- boolean do_flip,
- struct pipe_surface *dst,
- unsigned dst_x, unsigned dst_y,
- struct pipe_surface *src,
- unsigned src_x, unsigned src_y,
- unsigned w, unsigned h)
+util_resource_copy_region(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ struct pipe_resource *src,
+ struct pipe_subresource subsrc,
+ unsigned src_x, unsigned src_y, unsigned src_z,
+ unsigned w, unsigned h)
{
struct pipe_transfer *src_trans, *dst_trans;
void *dst_map;
const void *src_map;
enum pipe_format src_format, dst_format;
- assert(src->texture && dst->texture);
- if (!src->texture || !dst->texture)
+ assert(src && dst);
+ if (!src || !dst)
return;
- src_format = src->texture->format;
- dst_format = dst->texture->format;
+ src_format = src->format;
+ dst_format = dst->format;
src_trans = pipe_get_transfer(pipe,
- src->texture,
- src->face,
- src->level,
- src->zslice,
+ src,
+ subsrc.face,
+ subsrc.level,
+ src_z,
PIPE_TRANSFER_READ,
src_x, src_y, w, h);
dst_trans = pipe_get_transfer(pipe,
- dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
+ dst,
+ subdst.face,
+ subdst.level,
+ src_z,
PIPE_TRANSFER_WRITE,
dst_x, dst_y, w, h);
@@ -171,16 +171,15 @@ util_surface_copy(struct pipe_context *pipe,
assert(dst_map);
if (src_map && dst_map) {
- /* If do_flip, invert src_y position and pass negative src stride */
util_copy_rect(dst_map,
dst_format,
dst_trans->stride,
0, 0,
w, h,
src_map,
- do_flip ? -(int) src_trans->stride : src_trans->stride,
+ src_trans->stride,
0,
- do_flip ? h - 1 : 0);
+ 0);
}
pipe->transfer_unmap(pipe, src_trans);
@@ -196,25 +195,26 @@ util_surface_copy(struct pipe_context *pipe,
/**
- * Fallback for pipe->surface_fill() function.
+ * Fallback for pipe->resource_fill_region() function.
*/
void
-util_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value)
+util_resource_fill_region(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ unsigned width, unsigned height, unsigned value)
{
struct pipe_transfer *dst_trans;
void *dst_map;
- assert(dst->texture);
- if (!dst->texture)
+ assert(dst);
+ if (!dst)
return;
dst_trans = pipe_get_transfer(pipe,
- dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
+ dst,
+ subdst.face,
+ subdst.level,
+ dstz,
PIPE_TRANSFER_WRITE,
dstx, dsty, width, height);
@@ -225,11 +225,11 @@ util_surface_fill(struct pipe_context *pipe,
if (dst_map) {
assert(dst_trans->stride > 0);
- switch (util_format_get_blocksize(dst->texture->format)) {
+ switch (util_format_get_blocksize(dst->format)) {
case 1:
case 2:
case 4:
- util_fill_rect(dst_map, dst->texture->format,
+ util_fill_rect(dst_map, dst->format,
dst_trans->stride,
0, 0, width, height, value);
break;
diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h
index c43169b5278..ccde738ca40 100644
--- a/src/gallium/auxiliary/util/u_surface.h
+++ b/src/gallium/auxiliary/util/u_surface.h
@@ -33,23 +33,6 @@
#include "pipe/p_state.h"
-/**
- * Are s1 and s2 the same surface?
- * Surfaces are basically views into textures so check if the two surfaces
- * name the same part of the same texture.
- */
-static INLINE boolean
-util_same_surface(const struct pipe_surface *s1, const struct pipe_surface *s2)
-{
- return (s1->texture == s2->texture &&
- s1->face == s2->face &&
- s1->level == s2->level &&
- s1->zslice == s2->zslice);
-}
-
-
-
-
extern boolean
util_create_rgba_surface(struct pipe_screen *screen,
uint width, uint height, uint bind,
@@ -64,19 +47,21 @@ util_destroy_rgba_surface(struct pipe_resource *texture,
extern void
-util_surface_copy(struct pipe_context *pipe,
- boolean do_flip,
- struct pipe_surface *dst,
- unsigned dst_x, unsigned dst_y,
- struct pipe_surface *src,
- unsigned src_x, unsigned src_y,
- unsigned w, unsigned h);
+util_resource_copy_region(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ struct pipe_resource *src,
+ struct pipe_subresource subsrc,
+ unsigned src_x, unsigned src_y, unsigned src_z,
+ unsigned w, unsigned h);
extern void
-util_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value);
+util_resource_fill_region(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ unsigned width, unsigned height, unsigned value);