summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/util/u_surface.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/util/u_surface.c')
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_surface.c262
1 files changed, 136 insertions, 126 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_surface.c b/lib/mesa/src/gallium/auxiliary/util/u_surface.c
index 718411d8d..1a8acb358 100644
--- a/lib/mesa/src/gallium/auxiliary/util/u_surface.c
+++ b/lib/mesa/src/gallium/auxiliary/util/u_surface.c
@@ -41,7 +41,7 @@
#include "util/u_rect.h"
#include "util/u_surface.h"
#include "util/u_pack_color.h"
-
+#include "util/u_memset.h"
/**
* Initialize a pipe_surface object. 'view' is considered to have
@@ -141,9 +141,13 @@ util_fill_rect(ubyte * dst,
break;
case 4:
for (i = 0; i < height; i++) {
- uint32_t *row = (uint32_t *)dst;
- for (j = 0; j < width; j++)
- *row++ = uc->ui[0];
+ util_memset32(dst, uc->ui[0], width);
+ dst += dst_stride;
+ }
+ break;
+ case 8:
+ for (i = 0; i < height; i++) {
+ util_memset64(dst, ((uint64_t *)uc)[0], width);
dst += dst_stride;
}
break;
@@ -287,7 +291,7 @@ util_resource_copy_region(struct pipe_context *pipe,
src_map = pipe->transfer_map(pipe,
src,
src_level,
- PIPE_TRANSFER_READ,
+ PIPE_MAP_READ,
&src_box, &src_trans);
assert(src_map);
if (!src_map) {
@@ -297,8 +301,8 @@ util_resource_copy_region(struct pipe_context *pipe,
dst_map = pipe->transfer_map(pipe,
dst,
dst_level,
- PIPE_TRANSFER_WRITE |
- PIPE_TRANSFER_DISCARD_RANGE, &dst_box,
+ PIPE_MAP_WRITE |
+ PIPE_MAP_DISCARD_RANGE, &dst_box,
&dst_trans);
assert(dst_map);
if (!dst_map) {
@@ -338,21 +342,7 @@ util_clear_color_texture_helper(struct pipe_transfer *dst_trans,
assert(dst_trans->stride > 0);
- if (util_format_is_pure_integer(format)) {
- /*
- * We expect int/uint clear values here, though some APIs
- * might disagree (but in any case util_pack_color()
- * couldn't handle it)...
- */
- if (util_format_is_pure_sint(format)) {
- util_format_write_4i(format, color->i, 0, &uc, 0, 0, 0, 1, 1);
- } else {
- assert(util_format_is_pure_uint(format));
- util_format_write_4ui(format, color->ui, 0, &uc, 0, 0, 0, 1, 1);
- }
- } else {
- util_pack_color(color->f, format, &uc);
- }
+ util_pack_color_union(format, &uc, color);
util_fill_box(dst_map, format,
dst_trans->stride, dst_trans->layer_stride,
@@ -374,7 +364,7 @@ util_clear_color_texture(struct pipe_context *pipe,
dst_map = pipe_transfer_map_3d(pipe,
texture,
level,
- PIPE_TRANSFER_WRITE,
+ PIPE_MAP_WRITE,
dstx, dsty, dstz,
width, height, depth,
&dst_trans);
@@ -426,7 +416,7 @@ util_clear_render_target(struct pipe_context *pipe,
dst_map = pipe_transfer_map(pipe,
dst->texture,
0, 0,
- PIPE_TRANSFER_WRITE,
+ PIPE_MAP_WRITE,
dx, 0, w, 1,
&dst_trans);
if (dst_map) {
@@ -444,6 +434,117 @@ util_clear_render_target(struct pipe_context *pipe,
}
static void
+util_fill_zs_rect(ubyte *dst_map,
+ enum pipe_format format,
+ bool need_rmw,
+ unsigned clear_flags,
+ unsigned dst_stride,
+ unsigned width,
+ unsigned height,
+ uint64_t zstencil)
+{
+ unsigned i, j;
+ switch (util_format_get_blocksize(format)) {
+ case 1:
+ assert(format == PIPE_FORMAT_S8_UINT);
+ if(dst_stride == width)
+ memset(dst_map, (uint8_t) zstencil, height * width);
+ else {
+ for (i = 0; i < height; i++) {
+ memset(dst_map, (uint8_t) zstencil, width);
+ dst_map += dst_stride;
+ }
+ }
+ break;
+ case 2:
+ assert(format == PIPE_FORMAT_Z16_UNORM);
+ for (i = 0; i < height; i++) {
+ uint16_t *row = (uint16_t *)dst_map;
+ for (j = 0; j < width; j++)
+ *row++ = (uint16_t) zstencil;
+ dst_map += dst_stride;
+ }
+ break;
+ case 4:
+ if (!need_rmw) {
+ for (i = 0; i < height; i++) {
+ util_memset32(dst_map, (uint32_t)zstencil, width);
+ dst_map += dst_stride;
+ }
+ }
+ else {
+ uint32_t dst_mask;
+ if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT)
+ dst_mask = 0x00ffffff;
+ else {
+ assert(format == PIPE_FORMAT_S8_UINT_Z24_UNORM);
+ dst_mask = 0xffffff00;
+ }
+ if (clear_flags & PIPE_CLEAR_DEPTH)
+ dst_mask = ~dst_mask;
+ for (i = 0; i < height; i++) {
+ uint32_t *row = (uint32_t *)dst_map;
+ for (j = 0; j < width; j++) {
+ uint32_t tmp = *row & dst_mask;
+ *row++ = tmp | ((uint32_t) zstencil & ~dst_mask);
+ }
+ dst_map += dst_stride;
+ }
+ }
+ break;
+ case 8:
+ if (!need_rmw) {
+ for (i = 0; i < height; i++) {
+ util_memset64(dst_map, zstencil, width);
+ dst_map += dst_stride;
+ }
+ }
+ else {
+ uint64_t src_mask;
+
+ if (clear_flags & PIPE_CLEAR_DEPTH)
+ src_mask = 0x00000000ffffffffull;
+ else
+ src_mask = 0x000000ff00000000ull;
+
+ for (i = 0; i < height; i++) {
+ uint64_t *row = (uint64_t *)dst_map;
+ for (j = 0; j < width; j++) {
+ uint64_t tmp = *row & ~src_mask;
+ *row++ = tmp | (zstencil & src_mask);
+ }
+ dst_map += dst_stride;
+ }
+ }
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+void
+util_fill_zs_box(ubyte *dst,
+ enum pipe_format format,
+ bool need_rmw,
+ unsigned clear_flags,
+ unsigned stride,
+ unsigned layer_stride,
+ unsigned width,
+ unsigned height,
+ unsigned depth,
+ uint64_t zstencil)
+{
+ unsigned layer;
+
+ for (layer = 0; layer < depth; layer++) {
+ util_fill_zs_rect(dst, format, need_rmw, clear_flags, stride,
+ width, height, zstencil);
+ dst += layer_stride;
+ }
+}
+
+static void
util_clear_depth_stencil_texture(struct pipe_context *pipe,
struct pipe_resource *texture,
enum pipe_format format,
@@ -455,9 +556,6 @@ util_clear_depth_stencil_texture(struct pipe_context *pipe,
struct pipe_transfer *dst_trans;
ubyte *dst_map;
boolean need_rmw = FALSE;
- unsigned dst_stride;
- ubyte *dst_layer;
- unsigned i, j, layer;
if ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) &&
((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) &&
@@ -467,104 +565,20 @@ util_clear_depth_stencil_texture(struct pipe_context *pipe,
dst_map = pipe_transfer_map_3d(pipe,
texture,
level,
- (need_rmw ? PIPE_TRANSFER_READ_WRITE :
- PIPE_TRANSFER_WRITE),
+ (need_rmw ? PIPE_MAP_READ_WRITE :
+ PIPE_MAP_WRITE),
dstx, dsty, dstz,
width, height, depth, &dst_trans);
assert(dst_map);
if (!dst_map)
return;
- dst_stride = dst_trans->stride;
- dst_layer = dst_map;
assert(dst_trans->stride > 0);
- for (layer = 0; layer < depth; layer++) {
- dst_map = dst_layer;
-
- switch (util_format_get_blocksize(format)) {
- case 1:
- assert(format == PIPE_FORMAT_S8_UINT);
- if(dst_stride == width)
- memset(dst_map, (uint8_t) zstencil, height * width);
- else {
- for (i = 0; i < height; i++) {
- memset(dst_map, (uint8_t) zstencil, width);
- dst_map += dst_stride;
- }
- }
- break;
- case 2:
- assert(format == PIPE_FORMAT_Z16_UNORM);
- for (i = 0; i < height; i++) {
- uint16_t *row = (uint16_t *)dst_map;
- for (j = 0; j < width; j++)
- *row++ = (uint16_t) zstencil;
- dst_map += dst_stride;
- }
- break;
- case 4:
- if (!need_rmw) {
- for (i = 0; i < height; i++) {
- uint32_t *row = (uint32_t *)dst_map;
- for (j = 0; j < width; j++)
- *row++ = (uint32_t) zstencil;
- dst_map += dst_stride;
- }
- }
- else {
- uint32_t dst_mask;
- if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT)
- dst_mask = 0x00ffffff;
- else {
- assert(format == PIPE_FORMAT_S8_UINT_Z24_UNORM);
- dst_mask = 0xffffff00;
- }
- if (clear_flags & PIPE_CLEAR_DEPTH)
- dst_mask = ~dst_mask;
- for (i = 0; i < height; i++) {
- uint32_t *row = (uint32_t *)dst_map;
- for (j = 0; j < width; j++) {
- uint32_t tmp = *row & dst_mask;
- *row++ = tmp | ((uint32_t) zstencil & ~dst_mask);
- }
- dst_map += dst_stride;
- }
- }
- break;
- case 8:
- if (!need_rmw) {
- for (i = 0; i < height; i++) {
- uint64_t *row = (uint64_t *)dst_map;
- for (j = 0; j < width; j++)
- *row++ = zstencil;
- dst_map += dst_stride;
- }
- }
- else {
- uint64_t src_mask;
-
- if (clear_flags & PIPE_CLEAR_DEPTH)
- src_mask = 0x00000000ffffffffull;
- else
- src_mask = 0x000000ff00000000ull;
-
- for (i = 0; i < height; i++) {
- uint64_t *row = (uint64_t *)dst_map;
- for (j = 0; j < width; j++) {
- uint64_t tmp = *row & ~src_mask;
- *row++ = tmp | (zstencil & src_mask);
- }
- dst_map += dst_stride;
- }
- }
- break;
- default:
- assert(0);
- break;
- }
- dst_layer += dst_trans->layer_stride;
- }
+ util_fill_zs_box(dst_map, format, need_rmw, clear_flags,
+ dst_trans->stride,
+ dst_trans->layer_stride, width, height,
+ depth, zstencil);
pipe->transfer_unmap(pipe, dst_trans);
}
@@ -591,12 +605,12 @@ util_clear_texture(struct pipe_context *pipe,
if (util_format_has_depth(desc)) {
clear |= PIPE_CLEAR_DEPTH;
- desc->unpack_z_float(&depth, 0, data, 0, 1, 1);
+ util_format_unpack_z_float(tex->format, &depth, data, 1);
}
if (util_format_has_stencil(desc)) {
clear |= PIPE_CLEAR_STENCIL;
- desc->unpack_s_8uint(&stencil, 0, data, 0, 1, 1);
+ util_format_unpack_s_8uint(tex->format, &stencil, data, 1);
}
zstencil = util_pack64_z_stencil(tex->format, depth, stencil);
@@ -606,12 +620,7 @@ util_clear_texture(struct pipe_context *pipe,
box->width, box->height, box->depth);
} else {
union pipe_color_union color;
- if (util_format_is_pure_uint(tex->format))
- desc->unpack_rgba_uint(color.ui, 0, data, 0, 1, 1);
- else if (util_format_is_pure_sint(tex->format))
- desc->unpack_rgba_sint(color.i, 0, data, 0, 1, 1);
- else
- desc->unpack_rgba_float(color.f, 0, data, 0, 1, 1);
+ util_format_unpack_rgba(tex->format, color.ui, data, 1);
util_clear_color_texture(pipe, tex, tex->format, &color, level,
box->x, box->y, box->z,
@@ -760,7 +769,8 @@ util_can_blit_via_copy_region(const struct pipe_blit_info *blit,
blit->filter != PIPE_TEX_FILTER_NEAREST ||
blit->scissor_enable ||
blit->num_window_rectangles > 0 ||
- blit->alpha_blend) {
+ blit->alpha_blend ||
+ blit->render_condition_enable) {
return FALSE;
}