summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-07-03 18:51:24 -0400
committerMarek Olšák <[email protected]>2019-07-15 14:58:23 -0400
commitfc4302d1dfe4fe724df250d0de1fcf0f60953c99 (patch)
treeb8fe616f5eafb71a2fb087eca81061b5d76026df
parent5e76c9992317f20f89fafe3aab03026ca550766e (diff)
gallium: use MAP_DIRECTLY to mean supression of DISCARD in buffer_subdata
This is needed to fix an issue with OpenGL when a buffer is mapped and BufferSubData is called. In this case, we can't invalidate the buffer range.
-rw-r--r--src/gallium/auxiliary/util/u_threaded_context.c7
-rw-r--r--src/gallium/auxiliary/util/u_transfer.c14
-rw-r--r--src/gallium/drivers/r600/r600_buffer_common.c11
-rw-r--r--src/gallium/drivers/radeonsi/si_buffer.c11
-rw-r--r--src/gallium/drivers/virgl/virgl_resource.c10
-rw-r--r--src/gallium/include/pipe/p_defines.h2
6 files changed, 34 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index fc448908564..8f5ed4a5a67 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -1630,8 +1630,11 @@ tc_buffer_subdata(struct pipe_context *_pipe,
if (!size)
return;
- usage |= PIPE_TRANSFER_WRITE |
- PIPE_TRANSFER_DISCARD_RANGE;
+ usage |= PIPE_TRANSFER_WRITE;
+
+ /* PIPE_TRANSFER_MAP_DIRECTLY supresses implicit DISCARD_RANGE. */
+ if (!(usage & PIPE_TRANSFER_MAP_DIRECTLY))
+ usage |= PIPE_TRANSFER_DISCARD_RANGE;
usage = tc_improve_map_buffer_flags(tc, tres, usage, offset, size);
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
index 3089bcb1f34..1ad47b00399 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -18,11 +18,15 @@ void u_default_buffer_subdata(struct pipe_context *pipe,
/* the write flag is implicit by the nature of buffer_subdata */
usage |= PIPE_TRANSFER_WRITE;
- /* buffer_subdata implicitly discards the rewritten buffer range */
- if (offset == 0 && size == resource->width0) {
- usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
- } else {
- usage |= PIPE_TRANSFER_DISCARD_RANGE;
+ /* buffer_subdata implicitly discards the rewritten buffer range.
+ * PIPE_TRANSFER_MAP_DIRECTLY supresses that.
+ */
+ if (!(usage & PIPE_TRANSFER_MAP_DIRECTLY)) {
+ if (offset == 0 && size == resource->width0) {
+ usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
+ } else {
+ usage |= PIPE_TRANSFER_DISCARD_RANGE;
+ }
}
u_box_1d(offset, size, &box);
diff --git a/src/gallium/drivers/r600/r600_buffer_common.c b/src/gallium/drivers/r600/r600_buffer_common.c
index 047394a5297..04f80daec1d 100644
--- a/src/gallium/drivers/r600/r600_buffer_common.c
+++ b/src/gallium/drivers/r600/r600_buffer_common.c
@@ -545,12 +545,13 @@ void r600_buffer_subdata(struct pipe_context *ctx,
struct pipe_box box;
uint8_t *map = NULL;
+ usage |= PIPE_TRANSFER_WRITE;
+
+ if (!(usage & PIPE_TRANSFER_MAP_DIRECTLY))
+ usage |= PIPE_TRANSFER_DISCARD_RANGE;
+
u_box_1d(offset, size, &box);
- map = r600_buffer_transfer_map(ctx, buffer, 0,
- PIPE_TRANSFER_WRITE |
- PIPE_TRANSFER_DISCARD_RANGE |
- usage,
- &box, &transfer);
+ map = r600_buffer_transfer_map(ctx, buffer, 0, usage, &box, &transfer);
if (!map)
return;
diff --git a/src/gallium/drivers/radeonsi/si_buffer.c b/src/gallium/drivers/radeonsi/si_buffer.c
index 614d00b4667..57b8aeea486 100644
--- a/src/gallium/drivers/radeonsi/si_buffer.c
+++ b/src/gallium/drivers/radeonsi/si_buffer.c
@@ -637,12 +637,13 @@ static void si_buffer_subdata(struct pipe_context *ctx,
struct pipe_box box;
uint8_t *map = NULL;
+ usage |= PIPE_TRANSFER_WRITE;
+
+ if (!(usage & PIPE_TRANSFER_MAP_DIRECTLY))
+ usage |= PIPE_TRANSFER_DISCARD_RANGE;
+
u_box_1d(offset, size, &box);
- map = si_buffer_transfer_map(ctx, buffer, 0,
- PIPE_TRANSFER_WRITE |
- PIPE_TRANSFER_DISCARD_RANGE |
- usage,
- &box, &transfer);
+ map = si_buffer_transfer_map(ctx, buffer, 0, usage, &box, &transfer);
if (!map)
return;
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c
index c8e0d23fe12..c22a78a4731 100644
--- a/src/gallium/drivers/virgl/virgl_resource.c
+++ b/src/gallium/drivers/virgl/virgl_resource.c
@@ -588,10 +588,12 @@ static void virgl_buffer_subdata(struct pipe_context *pipe,
/* the write flag is implicit by the nature of buffer_subdata */
usage |= PIPE_TRANSFER_WRITE;
- if (offset == 0 && size == resource->width0)
- usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
- else
- usage |= PIPE_TRANSFER_DISCARD_RANGE;
+ if (!(usage & PIPE_TRANSFER_MAP_DIRECTLY)) {
+ if (offset == 0 && size == resource->width0)
+ usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
+ else
+ usage |= PIPE_TRANSFER_DISCARD_RANGE;
+ }
u_box_1d(offset, size, &box);
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index d3afd442046..d6e33ce9daa 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -261,6 +261,8 @@ enum pipe_transfer_usage
* E.g. the state tracker could have a simpler path which maps textures and
* does read/modify/write cycles on them directly, and a more complicated
* path which uses minimal read and write transfers.
+ *
+ * This flag supresses implicit "DISCARD" for buffer_subdata.
*/
PIPE_TRANSFER_MAP_DIRECTLY = (1 << 2),