util: fix util_clear_render_target and util_clear_depth_stencil layer handling

These functions must clear all bound layers, not just the first.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Roland Scheidegger
2013-06-07 21:10:59 +02:00
parent 201d7a352b
commit b47d13f425

View File

@@ -307,6 +307,7 @@ no_src_map:
* cpp > 4 looks like a gross hack at best...
* Plus can't use these transfer fallbacks when clearing
* multisampled surfaces for instance.
* Clears all bound layers.
*/
void
util_clear_render_target(struct pipe_context *pipe,
@@ -316,8 +317,9 @@ util_clear_render_target(struct pipe_context *pipe,
unsigned width, unsigned height)
{
struct pipe_transfer *dst_trans;
void *dst_map;
ubyte *dst_map;
union util_color uc;
unsigned max_layer, layer;
assert(dst->texture);
if (!dst->texture)
@@ -332,6 +334,7 @@ util_clear_render_target(struct pipe_context *pipe,
unsigned pixstride = util_format_get_blocksize(dst->format);
dx = (dst->u.buf.first_element + dstx) * pixstride;
w = width * pixstride;
max_layer = 0;
dst_map = pipe_transfer_map(pipe,
dst->texture,
0, 0,
@@ -340,14 +343,13 @@ util_clear_render_target(struct pipe_context *pipe,
&dst_trans);
}
else {
/* XXX: should handle multiple layers */
dst_map = pipe_transfer_map(pipe,
max_layer = dst->u.tex.last_layer - dst->u.tex.first_layer;
dst_map = pipe_transfer_map_3d(pipe,
dst->texture,
dst->u.tex.level,
dst->u.tex.first_layer,
PIPE_TRANSFER_WRITE,
dstx, dsty, width, height, &dst_trans);
dstx, dsty, dst->u.tex.first_layer,
width, height, max_layer, &dst_trans);
}
assert(dst_map);
@@ -373,9 +375,13 @@ util_clear_render_target(struct pipe_context *pipe,
else {
util_pack_color(color->f, dst->format, &uc);
}
for (layer = 0; layer <= max_layer; layer++) {
util_fill_rect(dst_map, dst->format,
dst_trans->stride,
0, 0, width, height, &uc);
dst_map += dst_trans->layer_stride;
}
pipe->transfer_unmap(pipe, dst_trans);
}
@@ -386,6 +392,7 @@ util_clear_render_target(struct pipe_context *pipe,
* sw fallback doesn't look terribly useful here.
* Plus can't use these transfer fallbacks when clearing
* multisampled surfaces for instance.
* Clears all bound layers.
*/
void
util_clear_depth_stencil(struct pipe_context *pipe,
@@ -400,6 +407,7 @@ util_clear_depth_stencil(struct pipe_context *pipe,
struct pipe_transfer *dst_trans;
ubyte *dst_map;
boolean need_rmw = FALSE;
unsigned max_layer, layer;
if ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) &&
((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) &&
@@ -409,22 +417,28 @@ util_clear_depth_stencil(struct pipe_context *pipe,
assert(dst->texture);
if (!dst->texture)
return;
dst_map = pipe_transfer_map(pipe,
max_layer = dst->u.tex.last_layer - dst->u.tex.first_layer;
dst_map = pipe_transfer_map_3d(pipe,
dst->texture,
dst->u.tex.level,
dst->u.tex.first_layer,
(need_rmw ? PIPE_TRANSFER_READ_WRITE :
PIPE_TRANSFER_WRITE),
dstx, dsty, width, height, &dst_trans);
dstx, dsty, dst->u.tex.first_layer,
width, height, max_layer + 1, &dst_trans);
assert(dst_map);
if (dst_map) {
unsigned dst_stride = dst_trans->stride;
uint64_t zstencil = util_pack64_z_stencil(format,
depth, stencil);
ubyte *dst_layer = dst_map;
unsigned i, j;
assert(dst_trans->stride > 0);
for (layer = 0; layer <= max_layer; layer++) {
dst_map = dst_layer;
switch (util_format_get_blocksize(format)) {
case 1:
assert(format == PIPE_FORMAT_S8_UINT);
@@ -506,6 +520,8 @@ util_clear_depth_stencil(struct pipe_context *pipe,
assert(0);
break;
}
dst_layer += dst_trans->layer_stride;
}
pipe->transfer_unmap(pipe, dst_trans);
}