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