diff options
author | Manuel Stoeckl <code@mstoeckl.com> | 2022-10-22 12:03:07 -0400 |
---|---|---|
committer | Manuel Stoeckl <code@mstoeckl.com> | 2022-10-22 12:03:11 -0400 |
commit | 434270bd727b1c30a008e7aa92f1ccf4ae4170ed (patch) | |
tree | f9e353cf2adf01fc83747e272fafc387a5c0424a | |
parent | 69847318956d5545f38005ed56d5091a2bac8119 (diff) |
Fix dmabuf write bug with amdgpu
-rw-r--r-- | src/dmabuf.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/dmabuf.c b/src/dmabuf.c index c06f431..7b8126e 100644 --- a/src/dmabuf.c +++ b/src/dmabuf.c @@ -339,9 +339,16 @@ void *map_dmabuf(struct gbm_bo *bo, bool write, void **map_handle, uint32_t stride; uint32_t width = gbm_bo_get_width(bo); uint32_t height = gbm_bo_get_height(bo); - void *data = gbm_bo_map(bo, 0, 0, width, height, - write ? GBM_BO_TRANSFER_WRITE : GBM_BO_TRANSFER_READ, - &stride, map_handle); + /* As of writing, with amdgpu, GBM_BO_TRANSFER_WRITE invalidates + * regions not written to during the mapping, while iris preserves + * the original buffer contents. GBM documentation does not say which + * WRITE behavior is correct. What the individual drivers do may change + * in the future. Specifying READ_WRITE preserves the old contents with + * both drivers. */ + uint32_t flags = write ? GBM_BO_TRANSFER_READ_WRITE + : GBM_BO_TRANSFER_READ; + void *data = gbm_bo_map( + bo, 0, 0, width, height, flags, &stride, map_handle); if (!data) { // errno is useless here wp_error("Failed to map dmabuf"); |