diff options
author | Marek Olšák <[email protected]> | 2019-07-03 18:51:24 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-07-15 14:58:23 -0400 |
commit | fc4302d1dfe4fe724df250d0de1fcf0f60953c99 (patch) | |
tree | b8fe616f5eafb71a2fb087eca81061b5d76026df /src/gallium/auxiliary/util | |
parent | 5e76c9992317f20f89fafe3aab03026ca550766e (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.
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_threaded_context.c | 7 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_transfer.c | 14 |
2 files changed, 14 insertions, 7 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); |