anv: Set correct write domain on window system BOs

We need to make sure GEM understands that we're writing to the BO, in
case it needs to synchronize with other rings (blitter use in display
server, for example).
This commit is contained in:
Kristian Høgsberg Kristensen 2016-02-17 11:19:56 -08:00
parent 5caa995c32
commit b63e28c0e1
5 changed files with 15 additions and 3 deletions

View File

@ -147,6 +147,9 @@ anv_reloc_list_add(struct anv_reloc_list *list,
struct drm_i915_gem_relocation_entry *entry;
int index;
const uint32_t domain =
target_bo->is_winsys_bo ? I915_GEM_DOMAIN_RENDER : 0;
anv_reloc_list_grow(list, alloc, 1);
/* TODO: Handle failure */
@ -158,8 +161,8 @@ anv_reloc_list_add(struct anv_reloc_list *list,
entry->delta = delta;
entry->offset = offset;
entry->presumed_offset = target_bo->offset;
entry->read_domains = 0;
entry->write_domain = 0;
entry->read_domains = domain;
entry->write_domain = domain;
VG(VALGRIND_CHECK_MEM_IS_DEFINED(entry, sizeof(*entry)));
return target_bo->offset + delta;
@ -854,7 +857,7 @@ anv_cmd_buffer_add_bo(struct anv_cmd_buffer *cmd_buffer,
obj->relocs_ptr = 0;
obj->alignment = 0;
obj->offset = bo->offset;
obj->flags = 0;
obj->flags = bo->is_winsys_bo ? EXEC_OBJECT_WRITE : 0;
obj->rsvd1 = 0;
obj->rsvd2 = 0;
}

View File

@ -1070,6 +1070,7 @@ anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size)
bo->index = 0;
bo->offset = 0;
bo->size = size;
bo->is_winsys_bo = false;
return VK_SUCCESS;
}

View File

@ -297,6 +297,12 @@ struct anv_bo {
uint64_t size;
void *map;
/* We need to set the WRITE flag on winsys bos so GEM will know we're
* writing to them and synchronize uses on other rings (eg if the display
* server uses the blitter ring).
*/
bool is_winsys_bo;
};
/* Represents a lock-free linked list of "free" things. This is used by

View File

@ -656,6 +656,7 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image,
goto fail_image;
image->memory = anv_device_memory_from_handle(vk_memory);
image->memory->bo.is_winsys_bo = true;
result = anv_BindImageMemory(vk_device, vk_image, vk_memory, 0);

View File

@ -624,6 +624,7 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
&memory_h);
memory = anv_device_memory_from_handle(memory_h);
memory->bo.is_winsys_bo = true;
anv_BindImageMemory(VK_NULL_HANDLE, anv_image_to_handle(image),
memory_h, 0);