vk/cmd_buffer: Allocate the surface_bo from device->batch_bo_pool
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 26 May 2015 01:27:43 +0000 (18:27 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 27 May 2015 18:48:28 +0000 (11:48 -0700)
src/vulkan/device.c

index 4cbf409b216b59f145722982f1d950a97de71a54..90fe8246216a59f13e02e6332a8519c1fecd3ec3 100644 (file)
@@ -2223,8 +2223,7 @@ anv_cmd_buffer_destroy(struct anv_device *device,
 
    assert(obj_type == VK_OBJECT_TYPE_COMMAND_BUFFER);
 
-   anv_gem_munmap(cmd_buffer->surface_bo.map, BATCH_SIZE);
-   anv_gem_close(device, cmd_buffer->surface_bo.gem_handle);
+   anv_bo_pool_free(&device->batch_bo_pool, &cmd_buffer->surface_bo);
    anv_reloc_list_finish(&cmd_buffer->surface_relocs, device);
    anv_state_stream_finish(&cmd_buffer->surface_state_stream);
    anv_state_stream_finish(&cmd_buffer->dynamic_state_stream);
@@ -2261,17 +2260,10 @@ VkResult anv_CreateCommandBuffer(
    if (result != VK_SUCCESS)
       goto fail;
 
-   result = anv_bo_init_new(&cmd_buffer->surface_bo, device, BATCH_SIZE);
+   result = anv_bo_pool_alloc(&device->batch_bo_pool, &cmd_buffer->surface_bo);
    if (result != VK_SUCCESS)
       goto fail_batch;
 
-   cmd_buffer->surface_bo.map =
-      anv_gem_mmap(device, cmd_buffer->surface_bo.gem_handle, 0, BATCH_SIZE);
-   if (cmd_buffer->surface_bo.map == NULL) {
-      result = vk_error(VK_ERROR_MEMORY_MAP_FAILED);
-      goto fail_surface_bo;
-   }
-
    /* Start surface_next at 1 so surface offset 0 is invalid. */
    cmd_buffer->surface_next = 1;
    anv_reloc_list_init(&cmd_buffer->surface_relocs, device);
@@ -2281,7 +2273,7 @@ VkResult anv_CreateCommandBuffer(
                        VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
    if (cmd_buffer->exec2_objects == NULL) {
       result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
-      goto fail_surface_map;
+      goto fail_surface_bo;
    }
 
    cmd_buffer->exec2_bos =
@@ -2309,10 +2301,8 @@ VkResult anv_CreateCommandBuffer(
 
  fail_exec2_objects:
    anv_device_free(device, cmd_buffer->exec2_objects);
- fail_surface_map:
-   anv_gem_munmap(cmd_buffer->surface_bo.map, BATCH_SIZE);
  fail_surface_bo:
-   anv_gem_close(device, cmd_buffer->surface_bo.gem_handle);
+   anv_bo_pool_free(&device->batch_bo_pool, &cmd_buffer->surface_bo);
  fail_batch:
    anv_batch_finish(&cmd_buffer->batch);
  fail: